[ONOS-5451] Implement virtual switch and controller connection handler
- ONOS-5453 that implement OF message encoder/decoder is also covered
- When OFConnectionHandler.connect() is called, it connects to the tenant controller with given vSwitch
- OpenFlow sesstion establishment will covered with ONOS-5452
Change-Id: I0c69d0ceac5aa04590d41f5b26170939ef6f5268
diff --git a/apps/ofagent/src/main/java/org/onosproject/ofagent/impl/OFChannelInitializer.java b/apps/ofagent/src/main/java/org/onosproject/ofagent/impl/OFChannelInitializer.java
index a3be413..e93b0c9 100644
--- a/apps/ofagent/src/main/java/org/onosproject/ofagent/impl/OFChannelInitializer.java
+++ b/apps/ofagent/src/main/java/org/onosproject/ofagent/impl/OFChannelInitializer.java
@@ -17,6 +17,7 @@
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
+import io.netty.handler.timeout.ReadTimeoutHandler;
import org.onosproject.ofagent.api.OFSwitch;
/**
@@ -25,6 +26,7 @@
public final class OFChannelInitializer extends ChannelInitializer<SocketChannel> {
private final OFSwitch ofSwitch;
+ private static final int READ_TIMEOUT = 30;
/**
* Default constructor.
@@ -38,6 +40,9 @@
@Override
protected void initChannel(SocketChannel ch) throws Exception {
- // TODO configure OF channel pipeline
+ ch.pipeline().addLast(new OFMessageDecoder())
+ .addLast(new OFMessageEncoder())
+ .addLast(new ReadTimeoutHandler(READ_TIMEOUT))
+ .addLast(new OFChannelHandler(ofSwitch));
}
}