Beispiel #1
0
  /**
   * Parse TE List from the channel buffer.
   *
   * @param cb of type channel buffer
   * @throws PcepParseException if mandatory fields are missing
   */
  public void parseTEList(ChannelBuffer cb) throws PcepParseException {
    byte yObjClass;
    byte yObjType;

    llTEObjList = new LinkedList<PcepTEObject>();

    // caller should verify for TE object
    if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
      log.debug("Unable to find TE Object");
      return;
    }

    cb.markReaderIndex();
    PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
    cb.resetReaderIndex();
    yObjClass = tempObjHeader.getObjClass();
    yObjType = tempObjHeader.getObjType();
    PcepTEObject teObj;
    while ((yObjClass == PcepTEObjectVer1.TE_OBJ_CLASS)
        && ((yObjType == PcepTEObjectVer1.TE_OBJ_TYPE_NODE_VALUE)
            || (yObjType == PcepTEObjectVer1.TE_OBJ_TYPE_LINK_VALUE))) {
      teObj = PcepTEObjectVer1.read(cb);
      llTEObjList.add(teObj);

      if (cb.readableBytes() > OBJECT_HEADER_LENGTH) {
        cb.markReaderIndex();
        tempObjHeader = PcepObjectHeader.read(cb);
        cb.resetReaderIndex();
        yObjClass = tempObjHeader.getObjClass();
        yObjType = tempObjHeader.getObjType();
      } else {
        break;
      }
    }
  }
Beispiel #2
0
  /**
   * parseErrObjList from the channel buffer.
   *
   * @param cb of type channel buffer
   * @throws PcepParseException if mandatory fields are missing
   */
  public void parseErrObjList(ChannelBuffer cb) throws PcepParseException {
    byte yObjClass;
    byte yObjType;
    boolean bIsErrorObjFound = false;

    llErrObjList = new LinkedList<PcepErrorObject>();

    // caller should verify for RP object
    if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
      throw new PcepParseException("Unable to find PCEP-ERROR Object");
    }

    cb.markReaderIndex();
    PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
    cb.resetReaderIndex();
    yObjClass = tempObjHeader.getObjClass();
    yObjType = tempObjHeader.getObjType();
    PcepErrorObject errorObject;
    while ((yObjClass == PcepErrorObjectVer1.ERROR_OBJ_CLASS)
        && (yObjType == PcepErrorObjectVer1.ERROR_OBJ_TYPE)) {
      errorObject = PcepErrorObjectVer1.read(cb);
      llErrObjList.add(errorObject);
      bIsErrorObjFound = true;

      if (cb.readableBytes() > OBJECT_HEADER_LENGTH) {
        cb.markReaderIndex();
        tempObjHeader = PcepObjectHeader.read(cb);
        cb.resetReaderIndex();
        yObjClass = tempObjHeader.getObjClass();
        yObjType = tempObjHeader.getObjType();
      } else {
        break;
      }
    }

    if (!bIsErrorObjFound) {
      throw new PcepParseException("At least one PCEP-ERROR Object should be present.");
    }
  }