@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 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, 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);
    }
Пример #4
0
  @Override
  public int write(ChannelBuffer cb) throws PcepParseException {
    // write Object header
    int objStartIndex = cb.writerIndex();

    int objLenIndex = iroObjHeader.write(cb);

    if (objLenIndex <= 0) {
      throw new PcepParseException(" ObjectLength is " + objLenIndex);
    }

    ListIterator<PcepValueType> listIterator = llSubObjects.listIterator();
    while (listIterator.hasNext()) {
      listIterator.next().write(cb);
    }

    // Update object length now
    int length = cb.writerIndex() - objStartIndex;
    // will be helpful during print().
    iroObjHeader.setObjLen((short) length);
    // As per RFC the length of object should be
    // multiples of 4
    int pad = length % 4;
    if (pad != 0) {
      pad = 4 - pad;
      for (int i = 0; i < pad; i++) {
        cb.writeByte((byte) 0);
      }
      length = length + pad;
    }
    cb.setShort(objLenIndex, (short) length);
    objLenIndex = cb.writerIndex();
    return objLenIndex;
  }
Пример #5
0
  @Override
  public int write(ChannelBuffer c) {
    int tlvStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    int tlvLenIndex = c.writerIndex();
    hLength = 0;
    c.writeShort(hLength);

    ListIterator<PcepValueType> listIterator = llNodeAttributesSubTLVs.listIterator();

    while (listIterator.hasNext()) {
      PcepValueType tlv = listIterator.next();

      tlv.write(c);

      // need to take care of padding
      int pad = tlv.getLength() % 4;

      if (0 != pad) {
        pad = 4 - pad;
        for (int i = 0; i < pad; ++i) {
          c.writeByte((byte) 0);
        }
      }
    }

    hLength = (short) (c.writerIndex() - tlvStartIndex);
    c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));

    return c.writerIndex() - tlvStartIndex;
  }
    @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(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);
    }
    @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);
    }
Пример #9
0
  @Override
  public int write(ChannelBuffer cb) throws PcepParseException {

    // write Object header
    int objStartIndex = cb.writerIndex();
    int objLenIndex = teObjHeader.write(cb);

    if (objLenIndex <= 0) {
      throw new PcepParseException("ObjectLength Index is " + objLenIndex);
    }

    // write Protocol ID
    cb.writeByte(this.yProtocolId);

    // write Flag
    cb.writeShort(0);

    byte bTemp = 0;
    if (bSFlag) {
      bTemp = FLAG_SET_S_FLAG;
    }

    if (bRFlag) {
      bTemp = (byte) (bTemp | FLAG_SET_R_FLAG);
    }
    cb.writeByte(bTemp);

    // write TEId
    cb.writeInt(iTEId);

    // Add optional TLV
    packOptionalTlv(cb);

    // Update object length now
    int length = cb.writerIndex() - objStartIndex;

    // will be helpful during print().
    teObjHeader.setObjLen((short) length);

    cb.setShort(objLenIndex, (short) length);

    return cb.writerIndex();
  }
Пример #10
0
  @Override
  public int write(ChannelBuffer cb) throws PcepParseException {

    // write Object header
    int objStartIndex = cb.writerIndex();

    int objLenIndex = lspObjHeader.write(cb);

    if (objLenIndex <= 0) {
      throw new PcepParseException("Failed to write lsp object header. Index " + objLenIndex);
    }

    int iTemp = iPlspId << PLSPID_SHIFT_VALUE;

    iTemp = iTemp | (((bCFlag) ? BIT_SET : BIT_RESET) << CFLAG_SHIFT_VALUE);

    iTemp = iTemp | (yOFlag << OFLAG_SHIFT_VALUE);
    byte bFlag;
    iTemp = bAFlag ? (iTemp | AFLAG_TEMP_SHIFT_VALUE) : iTemp;

    bFlag = (bRFlag) ? (byte) BIT_SET : BIT_RESET;
    iTemp = iTemp | (bFlag << RFLAG_SHIFT_VALUE);
    bFlag = (bSFlag) ? (byte) BIT_SET : BIT_RESET;
    iTemp = iTemp | (bFlag << SFLAG_SHIFT_VALUE);
    bFlag = (bDFlag) ? (byte) BIT_SET : BIT_RESET;
    iTemp = iTemp | bFlag;
    cb.writeInt(iTemp);

    // Add optional TLV
    packOptionalTlv(cb);

    // Update object length now
    int length = cb.writerIndex() - objStartIndex;
    // will be helpful during print().
    lspObjHeader.setObjLen((short) length);
    // As per RFC the length of object should be
    // multiples of 4

    cb.setShort(objLenIndex, (short) length);

    return length;
  }
    @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);
    }