import java.util.List;
+import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade;
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public static final byte LENGTH_OF_HEADER = 8;
private static final byte LENGTH_INDEX_IN_HEADER = 2;
private static final Logger LOGGER = LoggerFactory.getLogger(OFFrameDecoder.class);
+ private ConnectionFacade connectionFacade;
+ private boolean started = false;
/**
* Constructor of class.
+ * @param connectionFacade
*/
- public OFFrameDecoder() {
+ public OFFrameDecoder(ConnectionFacade connectionFacade) {
LOGGER.trace("Creating OFFrameDecoder");
+ this.connectionFacade = connectionFacade;
}
@Override
@Override
protected void decode(ChannelHandlerContext chc, ByteBuf bb, List<Object> list) throws Exception {
+ if (!started) {
+ connectionFacade.fireConnectionReadyNotification();
+ started = true;
+ }
int readableBytes = bb.readableBytes();
if (readableBytes < LENGTH_OF_HEADER) {
- LOGGER.debug("skipping bb - too few data for header: " + readableBytes);
+ LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER );
+ LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb));
return;
}
LOGGER.debug("length of actual message: {}", length);
if (readableBytes < length) {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("skipping bb - too few data for msg: " +
+ LOGGER.debug("skipping bytebuf - too few bytes for msg: " +
readableBytes + " < " + length);
- LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb));
- }
+ LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb));
return;
}
LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));