@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 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 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 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);
    }
Ejemplo n.º 5
0
    @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;
    }
Ejemplo n.º 6
0
 @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 void write(ChannelBuffer bb, OFBsnPduTxRequestVer10 message) {
      int startIndex = bb.writerIndex();
      // fixed value property version = 1
      bb.writeByte((byte) 0x1);
      // 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 = 0x1fL
      bb.writeInt(0x1f);
      bb.writeInt(U32.t(message.txIntervalMs));
      message.portNo.write2Bytes(bb);
      bb.writeByte(U8.t(message.slotNum));
      // pad: 3 bytes
      bb.writeZero(3);
      bb.writeBytes(message.data);

      // update length field
      int length = bb.writerIndex() - startIndex;
      bb.setShort(lengthIndex, length);
    }
    @Override
    public OFMeterFeaturesStatsReply 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 != 32) throw new OFParseError("Wrong length: Expected=32(32), 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 == 11
      short statsType = bb.readShort();
      if (statsType != (short) 0xb)
        throw new OFParseError(
            "Wrong statsType: Expected=OFStatsType.METER_FEATURES(11), got=" + statsType);
      Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer14.readFrom(bb);
      // pad: 4 bytes
      bb.skipBytes(4);
      OFMeterFeatures features = OFMeterFeaturesVer14.READER.readFrom(bb);

      OFMeterFeaturesStatsReplyVer14 meterFeaturesStatsReplyVer14 =
          new OFMeterFeaturesStatsReplyVer14(xid, flags, features);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", meterFeaturesStatsReplyVer14);
      return meterFeaturesStatsReplyVer14;
    }
    @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;
    }
    @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 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 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(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 OFBsnSetPktinSuppressionRequest readFrom(ByteBuf 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 == 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 != 32) throw new OFParseError("Wrong length: Expected=32(32), 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 experimenter == 0x5c16c7L
      int experimenter = bb.readInt();
      if (experimenter != 0x5c16c7)
        throw new OFParseError(
            "Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got=" + experimenter);
      // fixed value property subtype == 0xbL
      int subtype = bb.readInt();
      if (subtype != 0xb)
        throw new OFParseError("Wrong subtype: Expected=0xbL(0xbL), got=" + subtype);
      boolean enabled = (bb.readByte() != 0);
      // pad: 1 bytes
      bb.skipBytes(1);
      int idleTimeout = U16.f(bb.readShort());
      int hardTimeout = U16.f(bb.readShort());
      int priority = U16.f(bb.readShort());
      U64 cookie = U64.ofRaw(bb.readLong());

      OFBsnSetPktinSuppressionRequestVer12 bsnSetPktinSuppressionRequestVer12 =
          new OFBsnSetPktinSuppressionRequestVer12(
              xid, enabled, idleTimeout, hardTimeout, priority, cookie);
      if (logger.isTraceEnabled())
        logger.trace("readFrom - read={}", bsnSetPktinSuppressionRequestVer12);
      return bsnSetPktinSuppressionRequestVer12;
    }
    @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;
    }
    @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(ByteBuf bb, OFBsnSetPktinSuppressionRequestVer12 message) {
   // fixed value property version = 3
   bb.writeByte((byte) 0x3);
   // fixed value property type = 4
   bb.writeByte((byte) 0x4);
   // fixed value property length = 32
   bb.writeShort((short) 0x20);
   bb.writeInt(U32.t(message.xid));
   // fixed value property experimenter = 0x5c16c7L
   bb.writeInt(0x5c16c7);
   // fixed value property subtype = 0xbL
   bb.writeInt(0xb);
   bb.writeByte(message.enabled ? 1 : 0);
   // pad: 1 bytes
   bb.writeZero(1);
   bb.writeShort(U16.t(message.idleTimeout));
   bb.writeShort(U16.t(message.hardTimeout));
   bb.writeShort(U16.t(message.priority));
   bb.writeLong(message.cookie.getValue());
 }
    @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 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 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 void write(ChannelBuffer bb, OFActionSetFieldVer12 message) {
      int startIndex = bb.writerIndex();
      // fixed value property type = 25
      bb.writeShort((short) 0x19);
      // length is length of variable message, will be updated at the end
      int lengthIndex = bb.writerIndex();
      bb.writeShort(U16.t(0));

      message.field.writeTo(bb);

      // update length field
      int length = bb.writerIndex() - startIndex;
      int alignedLength = ((length + 7) / 8 * 8);
      bb.setShort(lengthIndex, alignedLength);
      // align message to 8 bytes
      bb.writeZero(alignedLength - length);
    }
Ejemplo n.º 22
0
    @Override
    public void write(ChannelBuffer bb, OFEchoRequestVer10 message) {
      int startIndex = bb.writerIndex();
      // fixed value property version = 1
      bb.writeByte((byte) 0x1);
      // fixed value property type = 2
      bb.writeByte((byte) 0x2);
      // 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));
      bb.writeBytes(message.data);

      // update length field
      int length = bb.writerIndex() - startIndex;
      bb.setShort(lengthIndex, length);
    }
    @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 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 OFBsnTlvMissPackets readFrom(ByteBuf bb) throws OFParseError {
      int start = bb.readerIndex();
      // fixed value property type == 0xd
      short type = bb.readShort();
      if (type != (short) 0xd) throw new OFParseError("Wrong type: Expected=0xd(0xd), 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);
      U64 value = U64.ofRaw(bb.readLong());

      OFBsnTlvMissPacketsVer13 bsnTlvMissPacketsVer13 = new OFBsnTlvMissPacketsVer13(value);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnTlvMissPacketsVer13);
      return bsnTlvMissPacketsVer13;
    }
    @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;
    }
    @Override
    public void write(ChannelBuffer bb, OFBadPropertyErrorMsgVer14 message) {
      int startIndex = bb.writerIndex();
      // fixed value property version = 5
      bb.writeByte((byte) 0x5);
      // fixed value property type = 1
      bb.writeByte((byte) 0x1);
      // 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 errType = 14
      bb.writeShort((short) 0xe);
      OFBadPropertyCodeSerializerVer14.writeTo(bb, message.code);
      message.data.writeTo(bb);

      // update length field
      int length = bb.writerIndex() - startIndex;
      bb.setShort(lengthIndex, length);
    }
    @Override
    public void write(ByteBuf bb, OFFlowModFailedErrorMsgVer10 message) {
      int startIndex = bb.writerIndex();
      // fixed value property version = 1
      bb.writeByte((byte) 0x1);
      // fixed value property type = 1
      bb.writeByte((byte) 0x1);
      // 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 errType = 3
      bb.writeShort((short) 0x3);
      OFFlowModFailedCodeSerializerVer10.writeTo(bb, message.code);
      message.data.writeTo(bb);

      // update length field
      int length = bb.writerIndex() - startIndex;
      bb.setShort(lengthIndex, length);
    }
 @Override
 public OFPortStatsPropExperimenter readFrom(ByteBuf bb) throws OFParseError {
   if (bb.readableBytes() < MINIMUM_LENGTH) return null;
   int start = bb.readerIndex();
   // fixed value property type == 0xffff
   short type = bb.readShort();
   if (type != (short) 0xffff)
     throw new OFParseError("Wrong type: Expected=0xffff(0xffff), got=" + type);
   int length = U16.f(bb.readShort());
   if (length < MINIMUM_LENGTH)
     throw new OFParseError(
         "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
   int experimenter = bb.readInt();
   bb.readerIndex(start);
   switch (experimenter) {
     default:
       throw new OFParseError(
           "Unknown value for discriminator experimenter of class OFPortStatsPropExperimenterVer14: "
               + experimenter);
   }
 }