-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
package org.opendaylight.openflowjava.protocol.impl.core;
import io.netty.channel.Channel;
import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory;
import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade;
import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private SwitchConnectionHandler switchConnectionHandler;
private long switchIdleTimeout;
private boolean encryption;
-
+ private SerializationFactory serializationFactory;
+
/**
* default ctor
*/
@Override
protected void initChannel(SocketChannel ch) {
InetAddress switchAddress = ch.remoteAddress().getAddress();
- LOGGER.info("Incoming connection from (remote address): " + switchAddress.toString());
+ int port = ch.localAddress().getPort();
+ int remotePort = ch.remoteAddress().getPort();
+ LOGGER.info("Incoming connection from (remote address): " + switchAddress.toString()
+ + ":" + remotePort + " --> :" + port);
if (!switchConnectionHandler.accept(switchAddress)) {
ch.disconnect();
LOGGER.info("Incoming connection rejected");
}
ch.pipeline().addLast(COMPONENT_NAMES.OF_FRAME_DECODER.name(), new OFFrameDecoder());
ch.pipeline().addLast(COMPONENT_NAMES.OF_VERSION_DETECTOR.name(), new OFVersionDetector());
- ch.pipeline().addLast(COMPONENT_NAMES.OF_DECODER.name(), new OF13Decoder());
- ch.pipeline().addLast(COMPONENT_NAMES.OF_ENCODER.name(), new OF13Encoder());
+ ch.pipeline().addLast(COMPONENT_NAMES.OF_DECODER.name(), new OFDecoder());
+ OFEncoder ofEncoder = new OFEncoder();
+ ofEncoder.setSerializationFactory(serializationFactory);
+ ch.pipeline().addLast(COMPONENT_NAMES.OF_ENCODER.name(), ofEncoder);
ch.pipeline().addLast(COMPONENT_NAMES.DELEGATING_INBOUND_HANDLER.name(), new DelegatingInboundHandler(connectionFacade));
+ if (!encryption) {
+ connectionFacade.fireConnectionReadyNotification();
+ }
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
ch.close();
public void setEncryption(boolean tlsSupported) {
encryption = tlsSupported;
}
-
+
+ /**
+ * @param serializationFactory
+ */
+ public void setSerializationFactory(SerializationFactory serializationFactory) {
+ this.serializationFactory = serializationFactory;
+ }
}