use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPClassTypeObjectParser 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.");
if (!header.getProcessingRule()) {
LOG.debug("Processed bit not set on CLASS TYPE OBJECT, ignoring it");
return null;
}
if (bytes.readableBytes() != SIZE) {
throw new PCEPDeserializerException("Size of byte array doesn't match defined size. Expected: " + SIZE + "; Passed: " + bytes.readableBytes());
}
final short ct = (short) bytes.readUnsignedInt();
final ClassTypeBuilder builder = new ClassTypeBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setClassType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType(Uint8.valueOf(ct)));
if (ct < 0 || ct > Byte.SIZE) {
LOG.debug("Invalid class type {}", ct);
return new UnknownObject(PCEPErrors.INVALID_CT, builder.build());
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPExistingBandwidthObjectParser method parseObject.
@Override
public ReoptimizationBandwidth 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() != PCEPBandwidthObjectParser.BANDWIDTH_F_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: " + PCEPBandwidthObjectParser.BANDWIDTH_F_LENGTH + ".");
}
final ReoptimizationBandwidthBuilder builder = new ReoptimizationBandwidthBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setBandwidth(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth(ByteArray.getAllBytes(bytes)));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPMetricObjectParser method parseObject.
@Override
public Metric parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
if (bytes.readableBytes() != SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: " + SIZE + ".");
}
bytes.skipBytes(RESERVED);
final BitArray flags = BitArray.valueOf(bytes.readByte());
return new MetricBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setBound(flags.get(B_FLAG_OFFSET)).setComputed(flags.get(C_FLAG_OFFSET)).setMetricType(ByteBufUtils.readUint8(bytes)).setValue(new Float32(ByteArray.readBytes(bytes, METRIC_VALUE_F_LENGTH))).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPNoPathObjectParser method parseObject.
@Override
public NoPath 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 Uint8 issue = ByteBufUtils.readUint8(bytes);
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
bytes.skipBytes(RESERVED_F_LENGTH);
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
parseTlvs(tlvsBuilder, bytes.slice());
return new NoPathBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setNatureOfIssue(issue).setUnsatisfiedConstraints(flags.get(C_FLAG_OFFSET)).setTlvs(tlvsBuilder.build()).build();
}
Aggregations