List of usage examples for io.netty.buffer ByteBuf skipBytes
public abstract ByteBuf skipBytes(int length);
From source file:org.opendaylight.openflowjava.nx.codec.action.SetNshc4Codec.java
License:Open Source License
@Override public Action deserialize(ByteBuf message) { ActionBuilder actionBuilder = deserializeHeader(message); ActionSetNshc4Builder builder = new ActionSetNshc4Builder(); NxActionSetNshc4Builder nxActionSetNspBuilder = new NxActionSetNshc4Builder(); message.skipBytes(padding); nxActionSetNspBuilder.setNshc(message.readUnsignedInt()); builder.setNxActionSetNshc4(nxActionSetNspBuilder.build()); actionBuilder.setActionChoice(builder.build()); return actionBuilder.build(); }
From source file:org.opendaylight.openflowjava.nx.codec.action.SetNsiCodec.java
License:Open Source License
@Override public Action deserialize(final ByteBuf message) { ActionBuilder actionBuilder = deserializeHeader(message); ActionSetNsiBuilder builder = new ActionSetNsiBuilder(); NxActionSetNsiBuilder nxActionSetNsiBuilder = new NxActionSetNsiBuilder(); nxActionSetNsiBuilder.setNsi(message.readUnsignedByte()); message.skipBytes(padding); builder.setNxActionSetNsi(nxActionSetNsiBuilder.build()); actionBuilder.setActionChoice(builder.build()); return actionBuilder.build(); }
From source file:org.opendaylight.openflowjava.nx.codec.action.SetNspCodec.java
License:Open Source License
@Override public Action deserialize(ByteBuf message) { ActionBuilder actionBuilder = deserializeHeader(message); ActionSetNspBuilder builder = new ActionSetNspBuilder(); NxActionSetNspBuilder nxActionSetNspBuilder = new NxActionSetNspBuilder(); message.skipBytes(padding); nxActionSetNspBuilder.setNsp(message.readUnsignedInt()); builder.setNxActionSetNsp(nxActionSetNspBuilder.build()); actionBuilder.setActionChoice(builder.build()); return actionBuilder.build(); }
From source file:org.opendaylight.openflowjava.nx.codec.match.AbstractMatchCodec.java
License:Open Source License
protected MatchEntryBuilder deserializeHeader(ByteBuf message) { MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(getOxmClass());//w w w. ja v a 2 s . c om // skip oxm_class - provided message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); builder.setOxmMatchField(getNxmField()); boolean hasMask = (message.readUnsignedByte() & 1) != 0; builder.setHasMask(hasMask); // skip match entry length - not needed message.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); return builder; }
From source file:org.opendaylight.openflowjava.protocol.impl.clients.SimpleClientFramer.java
License:Open Source License
@Override protected void decode(ChannelHandlerContext chc, ByteBuf bb, List<Object> list) throws Exception { if (bb.readableBytes() < LENGTH_OF_HEADER) { LOGGER.debug("skipping bb - too few data for header: " + bb.readableBytes()); return;/*from www .j a v a 2 s . c om*/ } int length = bb.getUnsignedShort(LENGTH_INDEX_IN_HEADER); if (bb.readableBytes() < length) { LOGGER.debug("skipping bb - too few data for msg: " + bb.readableBytes() + " < " + length); return; } LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(1)); ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length); list.add(messageBuffer); messageBuffer.retain(); bb.skipBytes(length); }
From source file:org.opendaylight.openflowjava.protocol.impl.clients.UdpSimpleClientFramer.java
License:Open Source License
@Override protected void decode(ChannelHandlerContext chc, DatagramPacket msg, List<Object> list) throws Exception { ByteBuf bb = msg.content(); if (bb.readableBytes() < LENGTH_OF_HEADER) { LOG.debug("skipping bb - too few data for header: {}", bb.readableBytes()); return;/*w w w . j ava 2 s. c o m*/ } int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); if (bb.readableBytes() < length) { LOG.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length); return; } LOG.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length); list.add(messageBuffer); messageBuffer.retain(); bb.skipBytes(length); }
From source file:org.opendaylight.openflowjava.protocol.impl.core.OFDatagramPacketHandler.java
License:Open Source License
@Override protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, List<Object> out) throws Exception { LOG.debug("OFDatagramPacketFramer"); MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.sender()); if (consumer == null) { ConnectionFacade connectionFacade = adapterFactory.createConnectionFacade(ctx.channel(), msg.sender(), false);/* w w w . j a v a2 s . com*/ connectionHandler.onSwitchConnected(connectionFacade); connectionFacade.checkListeners(); UdpConnectionMap.addConnection(msg.sender(), connectionFacade); } ByteBuf bb = msg.content(); int readableBytes = bb.readableBytes(); if (readableBytes < LENGTH_OF_HEADER) { if (LOG.isDebugEnabled()) { LOG.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER); LOG.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb)); } return; } int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); LOG.debug("length of actual message: {}", length); if (readableBytes < length) { if (LOG.isDebugEnabled()) { LOG.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length); LOG.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb)); } return; } LOG.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); byte version = bb.readByte(); if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) { LOG.debug("detected version: {}", version); ByteBuf messageBuffer = bb.slice(); out.add(new VersionMessageUdpWrapper(version, messageBuffer, msg.sender())); messageBuffer.retain(); } else { LOG.warn("detected version: {} - currently not supported", version); } bb.skipBytes(bb.readableBytes()); }
From source file:org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder.java
License:Open Source License
@Override protected void decode(ChannelHandlerContext chc, ByteBuf bb, List<Object> list) throws Exception { int readableBytes = bb.readableBytes(); if (readableBytes < LENGTH_OF_HEADER) { LOGGER.debug("skipping bb - too few data for header: " + readableBytes); return;/*from w w w . ja va2 s . co m*/ } int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); LOGGER.debug("length of actual message: {}", length); if (readableBytes < length) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("skipping bb - too few data for msg: " + readableBytes + " < " + length); LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb)); } return; } LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length); list.add(messageBuffer); messageBuffer.retain(); bb.skipBytes(length); }
From source file:org.opendaylight.openflowjava.protocol.impl.core.OFVersionDetector.java
License:Open Source License
@Override protected void decode(ChannelHandlerContext chc, ByteBuf bb, List<Object> list) throws Exception { if (bb.readableBytes() == 0) { LOGGER.debug("not enough data"); bb.release();//from www .j av a 2 s .com return; } byte version = bb.readByte(); if ((version == OF13_VERSION_ID) || (version == OF10_VERSION_ID)) { LOGGER.debug("detected version: " + version); } else { LOGGER.warn("detected version: " + version + " - currently not supported"); bb.skipBytes(bb.readableBytes()); return; } ByteBuf messageBuffer = bb.slice(); list.add(new VersionMessageWrapper(version, messageBuffer)); messageBuffer.retain(); bb.skipBytes(bb.readableBytes()); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.action.AbstractActionDeserializer.java
License:Open Source License
@Override public Action deserializeHeader(ByteBuf input) { ActionBuilder actionBuilder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); actionBuilder.setActionChoice(getType()); return actionBuilder.build(); }