use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPOpenObjectParser method parseObject.
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
final int versionValue = ByteArray.copyBitsRange(bytes.readByte(), VERSION_SF_OFFSET, VERSION_SF_LENGTH);
final short keepalive = bytes.readUnsignedByte();
final short deadTimer = bytes.readUnsignedByte();
final Uint8 sessionId = ByteBufUtils.readUint8(bytes);
final TlvsBuilder tbuilder = new TlvsBuilder();
parseTlvs(tbuilder, bytes.slice());
final OpenBuilder builder = new OpenBuilder().setVersion(new ProtocolVersion(Uint8.valueOf(versionValue))).setProcessingRule(header.getProcessingRule()).setIgnore(header.getIgnore()).setKeepalive(Uint8.valueOf(keepalive)).setSessionId(sessionId).setTlvs(tbuilder.build());
if (keepalive == 0) {
builder.setDeadTimer(Uint8.ZERO);
} else {
builder.setDeadTimer(Uint8.valueOf(deadTimer));
}
final Open obj = builder.build();
if (versionValue != PCEP_VERSION) {
// TODO: Should we move this check into the negotiator
LOG.debug("Unsupported PCEP version {}", versionValue);
return new UnknownObject(PCEPErrors.PCEP_VERSION_NOT_SUPPORTED, obj);
}
return obj;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPRequestParameterObjectParser method parseObject.
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
final Uint32 reqId = ByteBufUtils.readUint32(bytes);
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
parseTlvs(tlvsBuilder, bytes.slice());
final RpBuilder builder = new RpBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setFragmentation(flags.get(F_FLAG_OFFSET)).setP2mp(flags.get(N_FLAG_OFFSET)).setEroCompression(flags.get(E_FLAG_OFFSET)).setMakeBeforeBreak(flags.get(M_FLAG_OFFSET)).setOrder(flags.get(D_FLAG_OFFSET)).setPathKey(flags.get(P_FLAG_OFFSET)).setSupplyOf(flags.get(S_FLAG_OFFSET)).setLoose(flags.get(O_FLAG_OFFSET)).setBiDirectional(flags.get(B_FLAG_OFFSET)).setReoptimization(flags.get(R_FLAG_OFFSET)).setRequestId(new RequestId(reqId)).setTlvs(tlvsBuilder.build());
short priority = 0;
priority |= flags.get(PRI_SF_OFFSET + 2) ? 1 : 0;
priority |= (flags.get(PRI_SF_OFFSET + 1) ? 1 : 0) << 1;
priority |= (flags.get(PRI_SF_OFFSET) ? 1 : 0) << 2;
if (priority != 0) {
builder.setPriority(Uint8.valueOf(priority));
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPLspaObjectParser method parseObject.
@Override
public Lspa parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
final LspaBuilder builder = new LspaBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setExcludeAny(new AttributeFilter(ByteBufUtils.readUint32(bytes))).setIncludeAll(new AttributeFilter(ByteBufUtils.readUint32(bytes))).setIncludeAny(new AttributeFilter(ByteBufUtils.readUint32(bytes))).setSetupPriority(ByteBufUtils.readUint8(bytes)).setHoldPriority(ByteBufUtils.readUint8(bytes));
final BitArray flags = BitArray.valueOf(bytes.readByte());
builder.setLocalProtectionDesired(flags.get(L_FLAG_OFFSET));
final TlvsBuilder tbuilder = new TlvsBuilder();
bytes.skipBytes(RESERVED);
parseTlvs(tbuilder, bytes.slice());
return builder.setTlvs(tbuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPMonitoringObjectParser method parseObject.
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
buffer.skipBytes(RESERVED);
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));
final Uint32 monitoring = ByteBufUtils.readUint32(buffer);
final TlvsBuilder tbuilder = new TlvsBuilder();
parseTlvs(tbuilder, buffer.slice());
return new MonitoringBuilder().setFlags(flags).setMonitoringId(monitoring).setTlvs(tbuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPGlobalConstraintsObjectParser method parseObject.
@Override
public Gc parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
final GcBuilder builder = new GcBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setMaxHop(ByteBufUtils.readUint8(bytes)).setMaxUtilization(ByteBufUtils.readUint8(bytes)).setMinUtilization(ByteBufUtils.readUint8(bytes)).setOverBookingFactor(ByteBufUtils.readUint8(bytes));
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
parseTlvs(tlvsBuilder, bytes.slice());
return builder.setTlvs(tlvsBuilder.build()).build();
}
Aggregations