@Override public OFActionSetField readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property type == 25 short type = bb.readShort(); if (type != (short) 0x19) throw new OFParseError("Wrong type: Expected=OFActionType.SET_FIELD(25), got=" + type); int length = U16.f(bb.readShort()); if (length < MINIMUM_LENGTH) throw new OFParseError( "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); OFOxm<?> field = OFOxmVer12.READER.readFrom(bb); // align message to 8 bytes (length contains aligned value) bb.skipBytes(length - (bb.readerIndex() - start)); OFActionSetFieldVer12 actionSetFieldVer12 = new OFActionSetFieldVer12(field); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", actionSetFieldVer12); return actionSetFieldVer12; }
@Override public OFQueueOpFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property version == 4 byte version = bb.readByte(); if (version != (byte) 0x4) throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got=" + version); // fixed value property type == 1 byte type = bb.readByte(); if (type != (byte) 0x1) throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got=" + type); int length = U16.f(bb.readShort()); if (length < MINIMUM_LENGTH) throw new OFParseError( "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); long xid = U32.f(bb.readInt()); // fixed value property errType == 9 short errType = bb.readShort(); if (errType != (short) 0x9) throw new OFParseError( "Wrong errType: Expected=OFErrorType.QUEUE_OP_FAILED(9), got=" + errType); OFQueueOpFailedCode code = OFQueueOpFailedCodeSerializerVer13.readFrom(bb); byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start)); OFQueueOpFailedErrorMsgVer13 queueOpFailedErrorMsgVer13 = new OFQueueOpFailedErrorMsgVer13(xid, code, data); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", queueOpFailedErrorMsgVer13); return queueOpFailedErrorMsgVer13; }
@Override public OFMatchV3 readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property type == 0x1 short type = bb.readShort(); if (type != (short) 0x1) throw new OFParseError("Wrong type: Expected=0x1(0x1), got=" + type); int length = U16.f(bb.readShort()); if (length < MINIMUM_LENGTH) throw new OFParseError( "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); OFOxmList oxmList = OFOxmList.readFrom(bb, length - (bb.readerIndex() - start), OFOxmVer14.READER); // align message to 8 bytes (length does not contain alignment) bb.skipBytes(((length + 7) / 8 * 8) - length); OFMatchV3Ver14 matchV3Ver14 = new OFMatchV3Ver14(oxmList); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", matchV3Ver14); return matchV3Ver14; }
@Override public EntityObjectMessage decode(ChannelBuffer buffer) throws IOException { int entityId = buffer.readInt(); byte type = buffer.readByte(); int x = buffer.readInt(); int y = buffer.readInt(); int z = buffer.readInt(); int throwerId = buffer.readInt(); if (throwerId > 0) { short speedX = buffer.readShort(); short speedY = buffer.readShort(); short speedZ = buffer.readShort(); return new EntityObjectMessage( entityId, type, x, y, z, throwerId, speedX, speedY, speedZ, NullRepositionManager.getInstance()); } return new EntityObjectMessage( entityId, type, x, y, z, throwerId, NullRepositionManager.getInstance()); }
@Override public OFActionBsn readFrom(ChannelBuffer bb) throws OFParseError { if (bb.readableBytes() < MINIMUM_LENGTH) return null; int start = bb.readerIndex(); // fixed value property type == 65535 short type = bb.readShort(); if (type != (short) 0xffff) throw new OFParseError( "Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got=" + type); int length = U16.f(bb.readShort()); if (length < MINIMUM_LENGTH) throw new OFParseError( "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); // fixed value property experimenter == 0x5c16c7L int experimenter = bb.readInt(); if (experimenter != 0x5c16c7) throw new OFParseError( "Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got=" + experimenter); int subtype = bb.readInt(); bb.readerIndex(start); switch (subtype) { case 0x4: // discriminator value 0x4L=0x4L for class OFActionBsnChecksumVer10 return OFActionBsnChecksumVer10.READER.readFrom(bb); case 0x1: // discriminator value 0x1L=0x1L for class OFActionBsnMirrorVer10 return OFActionBsnMirrorVer10.READER.readFrom(bb); case 0x2: // discriminator value 0x2L=0x2L for class OFActionBsnSetTunnelDstVer10 return OFActionBsnSetTunnelDstVer10.READER.readFrom(bb); default: throw new OFParseError( "Unknown value for discriminator subtype of class OFActionBsnVer10: " + subtype); } }
@Override public OFInstructionIdBsnRequireVlanXlate readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property type == 65535 short type = bb.readShort(); if (type != (short) 0xffff) throw new OFParseError( "Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got=" + type); int length = U16.f(bb.readShort()); if (length != 12) throw new OFParseError("Wrong length: Expected=12(12), got=" + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); // fixed value property experimenter == 0x5c16c7L int experimenter = bb.readInt(); if (experimenter != 0x5c16c7) throw new OFParseError( "Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got=" + experimenter); // fixed value property subtype == 0x8L int subtype = bb.readInt(); if (subtype != 0x8) throw new OFParseError("Wrong subtype: Expected=0x8L(0x8L), got=" + subtype); if (logger.isTraceEnabled()) logger.trace("readFrom - returning shared instance={}", INSTANCE); return INSTANCE; }
/** * Returns Linked list of optional tlvs. * * @param cb of channel buffer. * @return list of optional tlvs * @throws PcepParseException when unsupported tlv is received */ protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException { LinkedList<PcepValueType> llOutOptionalTlv; llOutOptionalTlv = new LinkedList<>(); while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) { PcepValueType tlv = null; short hType = cb.readShort(); short hLength = cb.readShort(); int iValue = 0; switch (hType) { case StatefulIPv4LspIdentifiersTlv.TYPE: tlv = StatefulIPv4LspIdentifiersTlv.read(cb); break; case StatefulLspErrorCodeTlv.TYPE: iValue = cb.readInt(); tlv = new StatefulLspErrorCodeTlv(iValue); break; case StatefulRsvpErrorSpecTlv.TYPE: tlv = StatefulRsvpErrorSpecTlv.read(cb); break; case SymbolicPathNameTlv.TYPE: tlv = SymbolicPathNameTlv.read(cb, hLength); break; case StatefulLspDbVerTlv.TYPE: tlv = StatefulLspDbVerTlv.read(cb); break; default: // Skip the unknown TLV. cb.skipBytes(hLength); tlv = null; log.info("Received unsupported TLV type :" + hType + " in LSP object."); } // Check for the padding int pad = hLength % 4; if (0 < pad) { pad = 4 - pad; if (pad <= cb.readableBytes()) { cb.skipBytes(pad); } } if (tlv != null) { llOutOptionalTlv.add(tlv); } } if (0 < cb.readableBytes()) { throw new PcepParseException("Optional Tlv parsing error. Extra bytes received."); } return llOutOptionalTlv; }
/** * Reads the channel buffer and returns object of NodeAttributesTlv. * * @param c input channel buffer * @param hLength length * @return object of NodeAttributesTlv * @throws PcepParseException if mandatory fields are missing */ public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException { // Node Descriptor Sub-TLVs (variable) List<PcepValueType> llNodeAttributesSubTLVs = new LinkedList<>(); ChannelBuffer tempCb = c.readBytes(hLength); while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) { PcepValueType tlv; short hType = tempCb.readShort(); int iValue = 0; short length = tempCb.readShort(); switch (hType) { case NodeFlagBitsSubTlv.TYPE: byte cValue = tempCb.readByte(); tlv = new NodeFlagBitsSubTlv(cValue); break; case OpaqueNodePropertiesSubTlv.TYPE: tlv = OpaqueNodePropertiesSubTlv.read(tempCb, length); break; case NodeNameSubTlv.TYPE: tlv = NodeNameSubTlv.read(tempCb, length); break; case IsisAreaIdentifierSubTlv.TYPE: tlv = IsisAreaIdentifierSubTlv.read(tempCb, length); break; case IPv4RouterIdOfLocalNodeSubTlv.TYPE: iValue = tempCb.readInt(); tlv = new IPv4RouterIdOfLocalNodeSubTlv(iValue); break; case IPv6RouterIdofLocalNodeSubTlv.TYPE: byte[] ipv6Value = new byte[IPv6RouterIdofLocalNodeSubTlv.VALUE_LENGTH]; tempCb.readBytes(ipv6Value, 0, IPv6RouterIdofLocalNodeSubTlv.VALUE_LENGTH); tlv = new IPv6RouterIdofLocalNodeSubTlv(ipv6Value); break; default: throw new PcepParseException("Unsupported Sub TLV type :" + hType); } // Check for the padding int pad = length % 4; if (0 < pad) { pad = 4 - pad; if (pad <= tempCb.readableBytes()) { tempCb.skipBytes(pad); } } llNodeAttributesSubTLVs.add(tlv); } if (0 < tempCb.readableBytes()) { throw new PcepParseException("Sub Tlv parsing error. Extra bytes received."); } return new NodeAttributesTlv(llNodeAttributesSubTLVs); }
/** * Reads the channel buffer and returns object of StatefulIPv4LspIdentidiersTlv. * * @param c of type channel buffer * @return object of StatefulIPv4LspIdentidiersTlv */ public static PcepValueType read(ChannelBuffer c) { int ipv4IngressAddress = c.readInt(); short lspId = c.readShort(); short tunnelId = c.readShort(); int extendedTunnelId = c.readInt(); int ipv4EgressAddress = c.readInt(); return new StatefulIPv4LspIdentifiersTlv( ipv4IngressAddress, lspId, tunnelId, extendedTunnelId, ipv4EgressAddress); }
@Override public OFGroupFeaturesStatsReply readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property version == 3 byte version = bb.readByte(); if (version != (byte) 0x3) throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got=" + version); // fixed value property type == 19 byte type = bb.readByte(); if (type != (byte) 0x13) throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got=" + type); int length = U16.f(bb.readShort()); if (length != 56) throw new OFParseError("Wrong length: Expected=56(56), got=" + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); long xid = U32.f(bb.readInt()); // fixed value property statsType == 8 short statsType = bb.readShort(); if (statsType != (short) 0x8) throw new OFParseError( "Wrong statsType: Expected=OFStatsType.GROUP_FEATURES(8), got=" + statsType); Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer12.readFrom(bb); // pad: 4 bytes bb.skipBytes(4); long types = U32.f(bb.readInt()); long capabilities = U32.f(bb.readInt()); long maxGroupsAll = U32.f(bb.readInt()); long maxGroupsSelect = U32.f(bb.readInt()); long maxGroupsIndirect = U32.f(bb.readInt()); long maxGroupsFf = U32.f(bb.readInt()); long actionsAll = U32.f(bb.readInt()); long actionsSelect = U32.f(bb.readInt()); long actionsIndirect = U32.f(bb.readInt()); long actionsFf = U32.f(bb.readInt()); OFGroupFeaturesStatsReplyVer12 groupFeaturesStatsReplyVer12 = new OFGroupFeaturesStatsReplyVer12( xid, flags, types, capabilities, maxGroupsAll, maxGroupsSelect, maxGroupsIndirect, maxGroupsFf, actionsAll, actionsSelect, actionsIndirect, actionsFf); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", groupFeaturesStatsReplyVer12); return groupFeaturesStatsReplyVer12; }
/** * Returns Linked list of PCEP Value Type. * * @param cb of channel buffer * @return Linked list of PCEP Value Type * @throws PcepParseException if mandatory fields are missing */ protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException { LinkedList<PcepValueType> llOutOptionalTlv; llOutOptionalTlv = new LinkedList<PcepValueType>(); while (MINIMUM_TLV_HEADER_LENGTH <= cb.readableBytes()) { PcepValueType tlv; short hType = cb.readShort(); short hLength = cb.readShort(); long lValue = 0; switch (hType) { case RoutingUniverseTlv.TYPE: lValue = cb.readLong(); tlv = new RoutingUniverseTlv(lValue); break; case LocalTENodeDescriptorsTlv.TYPE: tlv = LocalTENodeDescriptorsTlv.read(cb, hLength); break; case RemoteTENodeDescriptorsTlv.TYPE: tlv = RemoteTENodeDescriptorsTlv.read(cb, hLength); break; case TELinkDescriptorsTlv.TYPE: tlv = TELinkDescriptorsTlv.read(cb, hLength); break; case TENodeAttributesTlv.TYPE: tlv = TENodeAttributesTlv.read(cb, hLength); break; case TELinkAttributesTlv.TYPE: tlv = TELinkAttributesTlv.read(cb, hLength); break; default: throw new PcepParseException("Unsupported TLV type :" + hType); } // Check for the padding int pad = hLength % 4; if (0 < pad) { pad = 4 - pad; if (pad <= cb.readableBytes()) { cb.skipBytes(pad); } } llOutOptionalTlv.add(tlv); } if (0 < cb.readableBytes()) { throw new PcepParseException("Optional Tlv parsing error. Extra bytes received."); } return llOutOptionalTlv; }
@Override public EncryptionKeyRequestMessage decode(ChannelBuffer buffer) { String sessionId = ChannelBufferUtils.readString(buffer); int length = buffer.readShort() & 0xFFFF; byte[] publicKey = new byte[length]; buffer.readBytes(publicKey); int tokenLength = buffer.readShort() & 0xFFFF; byte[] token = new byte[tokenLength]; buffer.readBytes(token); return new EncryptionKeyRequestMessage(sessionId, false, publicKey, token); }
@Override public PlayerSpawnMessage decode(ChannelBuffer buffer) throws IOException { byte playerId = buffer.readByte(); String name = ChannelBufferUtils.readString(buffer); float x = buffer.readShort() / 32; float y = buffer.readShort() / 32; float z = buffer.readShort() / 32; float yaw = (buffer.readByte() * 360) / 256f; float pitch = (buffer.readByte() * 360) / 256f; return new PlayerSpawnMessage(playerId, name, x, y, z, yaw, pitch); }
public void readFrom(ChannelBuffer data) { this.fieldId = data.readShort(); this.offset = data.readShort(); this.length = data.readShort(); data.readShort(); value = new byte[OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE]; data.readBytes(value); mask = new byte[OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE]; data.readBytes(mask); }
@Override public OFBsnGentableBucketStatsReply readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property version == 4 byte version = bb.readByte(); if (version != (byte) 0x4) throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got=" + version); // fixed value property type == 19 byte type = bb.readByte(); if (type != (byte) 0x13) throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got=" + type); int length = U16.f(bb.readShort()); if (length < MINIMUM_LENGTH) throw new OFParseError( "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); long xid = U32.f(bb.readInt()); // fixed value property statsType == 65535 short statsType = bb.readShort(); if (statsType != (short) 0xffff) throw new OFParseError( "Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got=" + statsType); Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb); // pad: 4 bytes bb.skipBytes(4); // fixed value property experimenter == 0x5c16c7L int experimenter = bb.readInt(); if (experimenter != 0x5c16c7) throw new OFParseError( "Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got=" + experimenter); // fixed value property subtype == 0x5L int subtype = bb.readInt(); if (subtype != 0x5) throw new OFParseError("Wrong subtype: Expected=0x5L(0x5L), got=" + subtype); List<OFBsnGentableBucketStatsEntry> entries = ChannelUtils.readList( bb, length - (bb.readerIndex() - start), OFBsnGentableBucketStatsEntryVer13.READER); OFBsnGentableBucketStatsReplyVer13 bsnGentableBucketStatsReplyVer13 = new OFBsnGentableBucketStatsReplyVer13(xid, flags, entries); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnGentableBucketStatsReplyVer13); return bsnGentableBucketStatsReplyVer13; }
@Override public void readFrom(ChannelBuffer data) { super.readFrom(data); this.virtualLanPriorityCodePoint = data.readByte(); data.readShort(); // pad data.readByte(); // pad }
@Override public OFEchoRequest readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property version == 1 byte version = bb.readByte(); if (version != (byte) 0x1) throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got=" + version); // fixed value property type == 2 byte type = bb.readByte(); if (type != (byte) 0x2) throw new OFParseError("Wrong type: Expected=OFType.ECHO_REQUEST(2), got=" + type); int length = U16.f(bb.readShort()); if (length < MINIMUM_LENGTH) throw new OFParseError( "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); long xid = U32.f(bb.readInt()); byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start)); OFEchoRequestVer10 echoRequestVer10 = new OFEchoRequestVer10(xid, data); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", echoRequestVer10); return echoRequestVer10; }
@Override public PlayerListMessage decode(ChannelBuffer buffer) throws IOException { String name = ChannelBufferUtils.readString(buffer); boolean addOrRemove = buffer.readByte() == 1; short ping = buffer.readShort(); return new PlayerListMessage(name, addOrRemove, ping); }
public static OFQueueOpFailedCode readFrom(ChannelBuffer bb) throws OFParseError { try { return ofWireValue(bb.readShort()); } catch (IllegalArgumentException e) { throw new OFParseError(e); } }
/** * Reads from the channel buffer and returns Object of PcepTEObject. * * @param cb of type channel buffer * @return Object of PcepTEObject * @throws PcepParseException if mandatory fields are missing */ public static PcepTEObject read(ChannelBuffer cb) throws PcepParseException { log.debug("read"); PcepObjectHeader teObjHeader; byte yProtocolId; // 2-flags boolean bRFlag; boolean bSFlag; int iTEId; LinkedList<PcepValueType> llOptionalTlv; teObjHeader = PcepObjectHeader.read(cb); // take only TEObject buffer. ChannelBuffer tempCb = cb.readBytes(teObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); yProtocolId = tempCb.readByte(); // ignore first two bytes of Flags tempCb.readShort(); Integer iTemp = (int) tempCb.readByte(); // read 3rd byte Flag bSFlag = ((iTemp & FLAG_SET_S_FLAG) == FLAG_SET_S_FLAG) ? true : false; bRFlag = ((iTemp & FLAG_SET_R_FLAG) == FLAG_SET_R_FLAG) ? true : false; iTEId = tempCb.readInt(); // parse optional TLV llOptionalTlv = parseOptionalTlv(tempCb); return new PcepTEObjectVer1(teObjHeader, yProtocolId, bRFlag, bSFlag, iTEId, llOptionalTlv); }
/** * Read short from this packet buffer. * * @return int */ protected final int readH() { try { return buf.readShort() & 0xFFFF; } catch (Exception e) { log.error("Missing H for: " + this); } return 0; }
@Test public void testToBuffer() throws Exception { PongPacket pongPacket = new PongPacket(); ChannelBuffer channelBuffer = pongPacket.toBuffer(); short pongCode = channelBuffer.readShort(); Assert.assertEquals(PacketType.CONTROL_PONG, pongCode); }
@Override public OFBsnImageDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property version == 5 byte version = bb.readByte(); if (version != (byte) 0x5) throw new OFParseError("Wrong version: Expected=OFVersion.OF_14(5), got=" + version); // fixed value property type == 19 byte type = bb.readByte(); if (type != (byte) 0x13) throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got=" + type); int length = U16.f(bb.readShort()); if (length != 536) throw new OFParseError("Wrong length: Expected=536(536), got=" + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); long xid = U32.f(bb.readInt()); // fixed value property statsType == 65535 short statsType = bb.readShort(); if (statsType != (short) 0xffff) throw new OFParseError( "Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got=" + statsType); Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer14.readFrom(bb); // pad: 4 bytes bb.skipBytes(4); // fixed value property experimenter == 0x5c16c7L int experimenter = bb.readInt(); if (experimenter != 0x5c16c7) throw new OFParseError( "Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got=" + experimenter); // fixed value property subtype == 0xeL int subtype = bb.readInt(); if (subtype != 0xe) throw new OFParseError("Wrong subtype: Expected=0xeL(0xeL), got=" + subtype); String imageChecksum = ChannelUtils.readFixedLengthString(bb, 256); String startupConfigChecksum = ChannelUtils.readFixedLengthString(bb, 256); OFBsnImageDescStatsReplyVer14 bsnImageDescStatsReplyVer14 = new OFBsnImageDescStatsReplyVer14(xid, flags, imageChecksum, startupConfigChecksum); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnImageDescStatsReplyVer14); return bsnImageDescStatsReplyVer14; }
@Override public RespawnMessage decode(ChannelBuffer buffer) throws IOException { int dimension = buffer.readInt(); byte difficulty = buffer.readByte(); byte mode = buffer.readByte(); int worldHeight = ChannelBufferUtils.getExpandedHeight(buffer.readShort()); String worldType = ChannelBufferUtils.readString(buffer); return new RespawnMessage(dimension, difficulty, mode, worldHeight, worldType); }
@Override public ExperienceOrbMessage decode(ChannelBuffer buffer) throws IOException { int id = buffer.readInt(); int x = buffer.readInt(); int y = buffer.readInt(); int z = buffer.readInt(); short count = buffer.readShort(); return new ExperienceOrbMessage(id, x, y, z, count); }
@Override public OFBsnGentableDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property version == 4 byte version = bb.readByte(); if (version != (byte) 0x4) throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got=" + version); // fixed value property type == 18 byte type = bb.readByte(); if (type != (byte) 0x12) throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got=" + type); int length = U16.f(bb.readShort()); if (length != 24) throw new OFParseError("Wrong length: Expected=24(24), got=" + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); long xid = U32.f(bb.readInt()); // fixed value property statsType == 65535 short statsType = bb.readShort(); if (statsType != (short) 0xffff) throw new OFParseError( "Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got=" + statsType); Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb); // pad: 4 bytes bb.skipBytes(4); // fixed value property experimenter == 0x5c16c7L int experimenter = bb.readInt(); if (experimenter != 0x5c16c7) throw new OFParseError( "Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got=" + experimenter); // fixed value property subtype == 0x4L int subtype = bb.readInt(); if (subtype != 0x4) throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got=" + subtype); OFBsnGentableDescStatsRequestVer13 bsnGentableDescStatsRequestVer13 = new OFBsnGentableDescStatsRequestVer13(xid, flags); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnGentableDescStatsRequestVer13); return bsnGentableDescStatsRequestVer13; }
@Override public OFBsnGentableEntryAdd readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property version == 4 byte version = bb.readByte(); if (version != (byte) 0x4) throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got=" + version); // fixed value property type == 4 byte type = bb.readByte(); if (type != (byte) 0x4) throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got=" + type); int length = U16.f(bb.readShort()); if (length < MINIMUM_LENGTH) throw new OFParseError( "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); long xid = U32.f(bb.readInt()); // fixed value property experimenter == 0x5c16c7L int experimenter = bb.readInt(); if (experimenter != 0x5c16c7) throw new OFParseError( "Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got=" + experimenter); // fixed value property subtype == 0x2eL int subtype = bb.readInt(); if (subtype != 0x2e) throw new OFParseError("Wrong subtype: Expected=0x2eL(0x2eL), got=" + subtype); GenTableId tableId = GenTableId.read2Bytes(bb); int keyLength = U16.f(bb.readShort()); U128 checksum = U128.read16Bytes(bb); List<OFBsnTlv> key = ChannelUtils.readList(bb, keyLength, OFBsnTlvVer13.READER); List<OFBsnTlv> value = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnTlvVer13.READER); OFBsnGentableEntryAddVer13 bsnGentableEntryAddVer13 = new OFBsnGentableEntryAddVer13(xid, tableId, checksum, key, value); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnGentableEntryAddVer13); return bsnGentableEntryAddVer13; }
@Override public BlockActionMessage decode(ChannelBuffer buffer) throws IOException { int x = buffer.readInt(); int y = buffer.readUnsignedShort(); int z = buffer.readInt(); byte firstByte = buffer.readByte(); byte secondByte = buffer.readByte(); short blockId = buffer.readShort(); return new BlockActionMessage(x, y, z, blockId, firstByte, secondByte); }
@Override public OFBsnTlvQueueWeight readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property type == 0x15 short type = bb.readShort(); if (type != (short) 0x15) throw new OFParseError("Wrong type: Expected=0x15(0x15), got=" + type); int length = U16.f(bb.readShort()); if (length != 8) throw new OFParseError("Wrong length: Expected=8(8), got=" + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); long value = U32.f(bb.readInt()); OFBsnTlvQueueWeightVer13 bsnTlvQueueWeightVer13 = new OFBsnTlvQueueWeightVer13(value); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnTlvQueueWeightVer13); return bsnTlvQueueWeightVer13; }
@Override public OFActionSetNwDst readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property type == 6 short type = bb.readShort(); if (type != (short) 0x6) throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_DST(6), got=" + type); int length = U16.f(bb.readShort()); if (length != 8) throw new OFParseError("Wrong length: Expected=8(8), got=" + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); IPv4Address nwAddr = IPv4Address.read4Bytes(bb); OFActionSetNwDstVer11 actionSetNwDstVer11 = new OFActionSetNwDstVer11(nwAddr); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", actionSetNwDstVer11); return actionSetNwDstVer11; }