List of usage examples for io.netty.buffer ByteBuf slice
public abstract ByteBuf slice();
From source file:org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07RSVPErrorSpecTlvParser.java
License:Open Source License
@Override public RsvpErrorSpec parseTlv(final ByteBuf buffer) throws PCEPDeserializerException { if (buffer == null) { return null; }/* ww w. j a v a2s . co m*/ // throw away contents of length field buffer.readUnsignedShort(); final int classNum = buffer.readUnsignedByte(); final int classType = buffer.readUnsignedByte(); ErrorType errorType = null; if (classNum == RSVP_ERROR_CLASS_NUM) { errorType = parseRsvp(classType, buffer.slice()); } else if (classNum == USER_ERROR_CLASS_NUM && classType == USER_ERROR_CLASS_TYPE) { errorType = parseUserError(buffer.slice()); } return new RsvpErrorSpecBuilder().setErrorType(errorType).build(); }
From source file:org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07SrpObjectParser.java
License:Open Source License
@Override public Srp parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException { Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); if (bytes.readableBytes() < MIN_SIZE) { throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: >=" + MIN_SIZE + "."); }// w w w.jav a 2 s . co m final SrpBuilder builder = new SrpBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); parseFlags(builder, bytes); builder.setOperationId(new SrpIdNumber(bytes.readUnsignedInt())); final TlvsBuilder tlvsBuilder = new TlvsBuilder(); parseTlvs(tlvsBuilder, bytes.slice()); builder.setTlvs(tlvsBuilder.build()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPCloseObjectParser.java
License:Open Source License
@Override public CClose parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException { Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); final CCloseBuilder builder = new CCloseBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); bytes.skipBytes(FLAGS_F_LENGTH + RESERVED); builder.setReason(bytes.readUnsignedByte()); final TlvsBuilder tlvsBuilder = new TlvsBuilder(); parseTlvs(tlvsBuilder, bytes.slice()); builder.setTlvs(tlvsBuilder.build()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPErrorObjectParser.java
License:Open Source License
@Override public ErrorObject parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException { Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); final ErrorObjectBuilder builder = new ErrorObjectBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); bytes.skipBytes(FLAGS_F_LENGTH + RESERVED); builder.setType(bytes.readUnsignedByte()); builder.setValue(bytes.readUnsignedByte()); parseTlvs(builder, bytes.slice()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPExcludeRouteObjectParser.java
License:Open Source License
@Override public Xro parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException { Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); final XroBuilder builder = new XroBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); bytes.skipBytes(FLAGS_OFFSET);/*from w w w. j a va2s. c om*/ builder.setFlags(new Flags(bytes.readBoolean())); builder.setSubobject(parseSubobjects(bytes.slice())); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPGlobalConstraintsObjectParser.java
License:Open Source License
@Override public Gc parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException { Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); final GcBuilder builder = new GcBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); builder.setMaxHop(bytes.readUnsignedByte()); builder.setMaxUtilization(bytes.readUnsignedByte()); builder.setMinUtilization(bytes.readUnsignedByte()); builder.setOverBookingFactor(bytes.readUnsignedByte()); final TlvsBuilder tlvsBuilder = new TlvsBuilder(); parseTlvs(tlvsBuilder, bytes.slice()); builder.setTlvs(tlvsBuilder.build()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPLspaObjectParser.java
License:Open Source License
@Override public Lspa parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException { Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); final LspaBuilder builder = new LspaBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); builder.setExcludeAny(new AttributeFilter(bytes.readUnsignedInt())); builder.setIncludeAll(new AttributeFilter(bytes.readUnsignedInt())); builder.setIncludeAny(new AttributeFilter(bytes.readUnsignedInt())); builder.setSetupPriority(bytes.readUnsignedByte()); builder.setHoldPriority(bytes.readUnsignedByte()); final BitArray flags = BitArray.valueOf(bytes.readByte()); builder.setLocalProtectionDesired(flags.get(L_FLAG_OFFSET)); final TlvsBuilder tbuilder = new TlvsBuilder(); bytes.skipBytes(RESERVED);//from ww w.jav a2s . c om parseTlvs(tbuilder, bytes.slice()); builder.setTlvs(tbuilder.build()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPMonitoringObjectParser.java
License:Open Source License
@Override public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException { Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); final MonitoringBuilder builder = new MonitoringBuilder(); buffer.readBytes(RESERVED);/* ww w . j ava 2 s . co m*/ final BitArray flagBits = BitArray.valueOf(buffer, FLAGS_SIZE); final Flags flags = new Flags(flagBits.get(G_FLAG_POS), flagBits.get(I_FLAG_POS), flagBits.get(L_FLAG_POS), flagBits.get(C_FLAG_POS), flagBits.get(P_FLAG_POS)); builder.setFlags(flags); builder.setMonitoringId(buffer.readUnsignedInt()); final TlvsBuilder tbuilder = new TlvsBuilder(); parseTlvs(tbuilder, buffer.slice()); builder.setTlvs(tbuilder.build()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPNoPathObjectParser.java
License:Open Source License
@Override public NoPath parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException { Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); final NoPathBuilder builder = new NoPathBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); builder.setNatureOfIssue(bytes.readUnsignedByte()); final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE); builder.setUnsatisfiedConstraints(flags.get(C_FLAG_OFFSET)); bytes.skipBytes(RESERVED_F_LENGTH);/* w w w . ja v a 2 s . c o m*/ final TlvsBuilder tlvsBuilder = new TlvsBuilder(); parseTlvs(tlvsBuilder, bytes.slice()); builder.setTlvs(tlvsBuilder.build()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPNotificationObjectParser.java
License:Open Source License
@Override public CNotification parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException { Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); final CNotificationBuilder builder = new CNotificationBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); bytes.skipBytes(NT_F_OFFSET);/*from w ww . j a va2s .c om*/ builder.setType(bytes.readUnsignedByte()); builder.setValue(bytes.readUnsignedByte()); parseTlvs(builder, bytes.slice()); return builder.build(); }