コード例 #1
0
    @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);
    }
コード例 #2
0
 @Override
 public void write(ChannelBuffer bb, OFBsnTlvIcmpTypeVer14 message) {
   // fixed value property type = 0x44
   bb.writeShort((short) 0x44);
   // fixed value property length = 5
   bb.writeShort((short) 0x5);
   bb.writeByte(U8.t(message.value));
 }
コード例 #3
0
 @Override
 public void write(ByteBuf bb, OFBsnSetMirroringVer14 message) {
   // fixed value property version = 5
   bb.writeByte((byte) 0x5);
   // fixed value property type = 4
   bb.writeByte((byte) 0x4);
   // fixed value property length = 20
   bb.writeShort((short) 0x14);
   bb.writeInt(U32.t(message.xid));
   // fixed value property experimenter = 0x5c16c7L
   bb.writeInt(0x5c16c7);
   // fixed value property subtype = 0x3L
   bb.writeInt(0x3);
   bb.writeByte(U8.t(message.reportMirrorPorts));
   // pad: 3 bytes
   bb.writeZero(3);
 }
コード例 #4
0
    @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;
    }
コード例 #5
0
    @Override
    public OFBsnTlvIcmpType readFrom(ChannelBuffer bb) throws OFParseError {
      int start = bb.readerIndex();
      // fixed value property type == 0x44
      short type = bb.readShort();
      if (type != (short) 0x44)
        throw new OFParseError("Wrong type: Expected=0x44(0x44), got=" + type);
      int length = U16.f(bb.readShort());
      if (length != 5) throw new OFParseError("Wrong length: Expected=5(5), 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);
      short value = U8.f(bb.readByte());

      OFBsnTlvIcmpTypeVer14 bsnTlvIcmpTypeVer14 = new OFBsnTlvIcmpTypeVer14(value);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnTlvIcmpTypeVer14);
      return bsnTlvIcmpTypeVer14;
    }
コード例 #6
0
    @Override
    public OFBsnSetMirroring 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 == 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 != 20) throw new OFParseError("Wrong length: Expected=20(20), 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 == 0x3L
      int subtype = bb.readInt();
      if (subtype != 0x3)
        throw new OFParseError("Wrong subtype: Expected=0x3L(0x3L), got=" + subtype);
      short reportMirrorPorts = U8.f(bb.readByte());
      // pad: 3 bytes
      bb.skipBytes(3);

      OFBsnSetMirroringVer14 bsnSetMirroringVer14 =
          new OFBsnSetMirroringVer14(xid, reportMirrorPorts);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnSetMirroringVer14);
      return bsnSetMirroringVer14;
    }