コード例 #1
0
    @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;
    }
コード例 #2
0
    @Override
    public OFPortStatsRequest readFrom(ByteBuf 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 == 4
      short statsType = bb.readShort();
      if (statsType != (short) 0x4)
        throw new OFParseError("Wrong statsType: Expected=OFStatsType.PORT(4), got=" + statsType);
      Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
      // pad: 4 bytes
      bb.skipBytes(4);
      OFPort portNo = OFPort.read4Bytes(bb);
      // pad: 4 bytes
      bb.skipBytes(4);

      OFPortStatsRequestVer13 portStatsRequestVer13 =
          new OFPortStatsRequestVer13(xid, flags, portNo);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", portStatsRequestVer13);
      return portStatsRequestVer13;
    }