Exemplo n.º 1
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;
  }
Exemplo n.º 2
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();
  }
Exemplo n.º 3
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;
  }