@Override public void write(ChannelBuffer bb, OFBsnGentableEntryAddVer13 message) { int startIndex = bb.writerIndex(); // fixed value property version = 4 bb.writeByte((byte) 0x4); // fixed value property type = 4 bb.writeByte((byte) 0x4); // length is length of variable message, will be updated at the end int lengthIndex = bb.writerIndex(); bb.writeShort(U16.t(0)); bb.writeInt(U32.t(message.xid)); // fixed value property experimenter = 0x5c16c7L bb.writeInt(0x5c16c7); // fixed value property subtype = 0x2eL bb.writeInt(0x2e); message.tableId.write2Bytes(bb); // keyLength is length indicator for key, will be // udpated when key has been written int keyLengthIndex = bb.writerIndex(); bb.writeShort(0); message.checksum.write16Bytes(bb); int keyStartIndex = bb.writerIndex(); ChannelUtils.writeList(bb, message.key); // update field length member keyLength int keyLength = bb.writerIndex() - keyStartIndex; bb.setShort(keyLengthIndex, keyLength); ChannelUtils.writeList(bb, message.value); // update length field int length = bb.writerIndex() - startIndex; bb.setShort(lengthIndex, length); }
@Override public OFPortDesc readFrom(ByteBuf bb) throws OFParseError { OFPort portNo = OFPort.read4Bytes(bb); // pad: 4 bytes bb.skipBytes(4); MacAddress hwAddr = MacAddress.read6Bytes(bb); // pad: 2 bytes bb.skipBytes(2); String name = ChannelUtils.readFixedLengthString(bb, 16); Set<OFPortConfig> config = OFPortConfigSerializerVer12.readFrom(bb); Set<OFPortState> state = OFPortStateSerializerVer12.readFrom(bb); Set<OFPortFeatures> curr = OFPortFeaturesSerializerVer12.readFrom(bb); Set<OFPortFeatures> advertised = OFPortFeaturesSerializerVer12.readFrom(bb); Set<OFPortFeatures> supported = OFPortFeaturesSerializerVer12.readFrom(bb); Set<OFPortFeatures> peer = OFPortFeaturesSerializerVer12.readFrom(bb); long currSpeed = U32.f(bb.readInt()); long maxSpeed = U32.f(bb.readInt()); OFPortDescVer12 portDescVer12 = new OFPortDescVer12( portNo, hwAddr, name, config, state, curr, advertised, supported, peer, currSpeed, maxSpeed); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", portDescVer12); return portDescVer12; }
@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 void write(ChannelBuffer bb, OFBsnGentableBucketStatsReplyVer13 message) { int startIndex = bb.writerIndex(); // fixed value property version = 4 bb.writeByte((byte) 0x4); // fixed value property type = 19 bb.writeByte((byte) 0x13); // length is length of variable message, will be updated at the end int lengthIndex = bb.writerIndex(); bb.writeShort(U16.t(0)); bb.writeInt(U32.t(message.xid)); // fixed value property statsType = 65535 bb.writeShort((short) 0xffff); OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags); // pad: 4 bytes bb.writeZero(4); // fixed value property experimenter = 0x5c16c7L bb.writeInt(0x5c16c7); // fixed value property subtype = 0x5L bb.writeInt(0x5); ChannelUtils.writeList(bb, message.entries); // update length field int length = bb.writerIndex() - startIndex; bb.setShort(lengthIndex, length); }
@Override public void write(ByteBuf bb, OFFlowStatsEntryVer10 message) { int startIndex = bb.writerIndex(); // length is length of variable message, will be updated at the end int lengthIndex = bb.writerIndex(); bb.writeShort(U16.t(0)); message.tableId.writeByte(bb); // pad: 1 bytes bb.writeZero(1); message.match.writeTo(bb); bb.writeInt(U32.t(message.durationSec)); bb.writeInt(U32.t(message.durationNsec)); bb.writeShort(U16.t(message.priority)); bb.writeShort(U16.t(message.idleTimeout)); bb.writeShort(U16.t(message.hardTimeout)); // pad: 6 bytes bb.writeZero(6); bb.writeLong(message.cookie.getValue()); bb.writeLong(message.packetCount.getValue()); bb.writeLong(message.byteCount.getValue()); ChannelUtils.writeList(bb, message.actions); // update length field int length = bb.writerIndex() - startIndex; bb.setShort(lengthIndex, length); }
@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 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 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 void write(ChannelBuffer bb, OFBsnImageDescStatsReplyVer14 message) { // fixed value property version = 5 bb.writeByte((byte) 0x5); // fixed value property type = 19 bb.writeByte((byte) 0x13); // fixed value property length = 536 bb.writeShort((short) 0x218); bb.writeInt(U32.t(message.xid)); // fixed value property statsType = 65535 bb.writeShort((short) 0xffff); OFStatsReplyFlagsSerializerVer14.writeTo(bb, message.flags); // pad: 4 bytes bb.writeZero(4); // fixed value property experimenter = 0x5c16c7L bb.writeInt(0x5c16c7); // fixed value property subtype = 0xeL bb.writeInt(0xe); ChannelUtils.writeFixedLengthString(bb, message.imageChecksum, 256); ChannelUtils.writeFixedLengthString(bb, message.startupConfigChecksum, 256); }
@Override public OFFlowStatsEntry readFrom(ByteBuf bb) throws OFParseError { int start = bb.readerIndex(); 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); TableId tableId = TableId.readByte(bb); // pad: 1 bytes bb.skipBytes(1); long durationSec = U32.f(bb.readInt()); long durationNsec = U32.f(bb.readInt()); int priority = U16.f(bb.readShort()); int idleTimeout = U16.f(bb.readShort()); int hardTimeout = U16.f(bb.readShort()); Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer14.readFrom(bb); int importance = U16.f(bb.readShort()); // pad: 2 bytes bb.skipBytes(2); U64 cookie = U64.ofRaw(bb.readLong()); U64 packetCount = U64.ofRaw(bb.readLong()); U64 byteCount = U64.ofRaw(bb.readLong()); Match match = ChannelUtilsVer14.readOFMatch(bb); List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer14.READER); OFFlowStatsEntryVer14 flowStatsEntryVer14 = new OFFlowStatsEntryVer14( tableId, durationSec, durationNsec, priority, idleTimeout, hardTimeout, flags, importance, cookie, packetCount, byteCount, match, instructions); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", flowStatsEntryVer14); return flowStatsEntryVer14; }
@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 write(ChannelBuffer bb, OFBsnVlanCounterStatsEntryVer13 message) { int startIndex = bb.writerIndex(); // length is length of variable message, will be updated at the end int lengthIndex = bb.writerIndex(); bb.writeShort(U16.t(0)); bb.writeShort(U16.t(message.vlanVid)); // pad: 4 bytes bb.writeZero(4); ChannelUtils.writeList(bb, message.values); // update length field int length = bb.writerIndex() - startIndex; bb.setShort(lengthIndex, length); }
@Override public void write(ByteBuf bb, OFPortDescVer12 message) { message.portNo.write4Bytes(bb); // pad: 4 bytes bb.writeZero(4); message.hwAddr.write6Bytes(bb); // pad: 2 bytes bb.writeZero(2); ChannelUtils.writeFixedLengthString(bb, message.name, 16); OFPortConfigSerializerVer12.writeTo(bb, message.config); OFPortStateSerializerVer12.writeTo(bb, message.state); OFPortFeaturesSerializerVer12.writeTo(bb, message.curr); OFPortFeaturesSerializerVer12.writeTo(bb, message.advertised); OFPortFeaturesSerializerVer12.writeTo(bb, message.supported); OFPortFeaturesSerializerVer12.writeTo(bb, message.peer); bb.writeInt(U32.t(message.currSpeed)); bb.writeInt(U32.t(message.maxSpeed)); }
@Override public OFBsnPduTxRequest 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 == 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 == 0x1fL int subtype = bb.readInt(); if (subtype != 0x1f) throw new OFParseError("Wrong subtype: Expected=0x1fL(0x1fL), got=" + subtype); long txIntervalMs = U32.f(bb.readInt()); OFPort portNo = OFPort.read2Bytes(bb); short slotNum = U8.f(bb.readByte()); // pad: 3 bytes bb.skipBytes(3); byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start)); OFBsnPduTxRequestVer10 bsnPduTxRequestVer10 = new OFBsnPduTxRequestVer10(xid, txIntervalMs, portNo, slotNum, data); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnPduTxRequestVer10); return bsnPduTxRequestVer10; }
@Override public void write(ByteBuf bb, OFMeterStatsReplyVer14 message) { int startIndex = bb.writerIndex(); // fixed value property version = 5 bb.writeByte((byte) 0x5); // fixed value property type = 19 bb.writeByte((byte) 0x13); // length is length of variable message, will be updated at the end int lengthIndex = bb.writerIndex(); bb.writeShort(U16.t(0)); bb.writeInt(U32.t(message.xid)); // fixed value property statsType = 9 bb.writeShort((short) 0x9); OFStatsReplyFlagsSerializerVer14.writeTo(bb, message.flags); // pad: 4 bytes bb.writeZero(4); ChannelUtils.writeList(bb, message.entries); // update length field int length = bb.writerIndex() - startIndex; bb.setShort(lengthIndex, length); }
@Override public OFBsnVlanCounterStatsEntry readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); 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); int vlanVid = U16.f(bb.readShort()); // pad: 4 bytes bb.skipBytes(4); List<U64> values = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U64.READER); OFBsnVlanCounterStatsEntryVer13 bsnVlanCounterStatsEntryVer13 = new OFBsnVlanCounterStatsEntryVer13(vlanVid, values); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnVlanCounterStatsEntryVer13); return bsnVlanCounterStatsEntryVer13; }
@Override public OFMeterStatsReply readFrom(ByteBuf 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 < 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 == 9 short statsType = bb.readShort(); if (statsType != (short) 0x9) throw new OFParseError("Wrong statsType: Expected=OFStatsType.METER(9), got=" + statsType); Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer14.readFrom(bb); // pad: 4 bytes bb.skipBytes(4); List<OFMeterStats> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFMeterStatsVer14.READER); OFMeterStatsReplyVer14 meterStatsReplyVer14 = new OFMeterStatsReplyVer14(xid, flags, entries); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", meterStatsReplyVer14); return meterStatsReplyVer14; }