import javax.net.ssl.SSLEngine;
-import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory;
-import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactoryImpl;
-import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade;
+import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory;
+import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactoryImpl;
+import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Testing Constructor
- *
+ *
*/
protected TcpChannelInitializer( DefaultChannelGroup channelGroup, ConnectionAdapterFactory connAdaptorFactory ) {
allChannels = channelGroup ;
connectionAdapterFactory = connAdaptorFactory ;
}
-
+
@Override
protected void initChannel(final SocketChannel ch) {
- InetAddress switchAddress = ch.remoteAddress().getAddress();
- int port = ch.localAddress().getPort();
- int remotePort = ch.remoteAddress().getPort();
- LOGGER.info("Incoming connection from (remote address): " + switchAddress.toString()
- + ":" + remotePort + " --> :" + port);
- if (!getSwitchConnectionHandler().accept(switchAddress)) {
- ch.disconnect();
- LOGGER.info("Incoming connection rejected");
- return;
+ if (ch.remoteAddress() != null) {
+ InetAddress switchAddress = ch.remoteAddress().getAddress();
+ int port = ch.localAddress().getPort();
+ int remotePort = ch.remoteAddress().getPort();
+ LOGGER.debug("Incoming connection from (remote address): " + switchAddress.toString()
+ + ":" + remotePort + " --> :" + port);
+
+ if (!getSwitchConnectionHandler().accept(switchAddress)) {
+ ch.disconnect();
+ LOGGER.debug("Incoming connection rejected");
+ return;
+ }
}
- LOGGER.info("Incoming connection accepted - building pipeline");
+ LOGGER.debug("Incoming connection accepted - building pipeline");
allChannels.add(ch);
ConnectionFacade connectionFacade = null;
connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null);
getSwitchConnectionHandler().onSwitchConnected(connectionFacade);
connectionFacade.checkListeners();
ch.pipeline().addLast(PipelineHandlers.IDLE_HANDLER.name(), new IdleHandler(getSwitchIdleTimeout(), TimeUnit.MILLISECONDS));
-
+ boolean tlsPresent = false;
+
// If this channel is configured to support SSL it will only support SSL
if (getTlsConfiguration() != null) {
+ tlsPresent = true;
SslContextFactory sslFactory = new SslContextFactory(getTlsConfiguration());
SSLEngine engine = sslFactory.getServerContext().createSSLEngine();
engine.setNeedClientAuth(true);
engine.setUseClientMode(false);
ch.pipeline().addLast(PipelineHandlers.SSL_HANDLER.name(), new SslHandler(engine));
}
- ch.pipeline().addLast(PipelineHandlers.OF_FRAME_DECODER.name(), new OFFrameDecoder(connectionFacade));
+ ch.pipeline().addLast(PipelineHandlers.OF_FRAME_DECODER.name(),
+ new OFFrameDecoder(connectionFacade, tlsPresent));
ch.pipeline().addLast(PipelineHandlers.OF_VERSION_DETECTOR.name(), new OFVersionDetector());
OFDecoder ofDecoder = new OFDecoder();
ofDecoder.setDeserializationFactory(getDeserializationFactory());
ofEncoder.setSerializationFactory(getSerializationFactory());
ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofEncoder);
ch.pipeline().addLast(PipelineHandlers.DELEGATING_INBOUND_HANDLER.name(), new DelegatingInboundHandler(connectionFacade));
- if (getTlsConfiguration() == null) {
+ if (!tlsPresent) {
connectionFacade.fireConnectionReadyNotification();
}
} catch (Exception e) {
- LOGGER.error("Failed to initialize channel", e);
+ LOGGER.warn("Failed to initialize channel", e);
ch.close();
}
}