Search in sources :

Example 6 with ObjectHeader

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader in project bgpcep by opendaylight.

the class PCEPGlobalConstraintsObjectParser method parseObject.

@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();
}
Also used : TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.gc.object.gc.TlvsBuilder) GcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.gc.object.GcBuilder)

Example 7 with ObjectHeader

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader in project bgpcep by opendaylight.

the class PCEPIncludeRouteObjectParser method parseObject.

@Override
public Iro 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 IroBuilder builder = new IroBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    final List<Subobject> subs = new ArrayList<>();
    for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject s : parseSubobjects(bytes)) {
        subs.add(new SubobjectBuilder().setLoose(s.isLoose()).setSubobjectType(s.getSubobjectType()).build());
    }
    builder.setSubobject(subs);
    return builder.build();
}
Also used : Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.Subobject) Preconditions(com.google.common.base.Preconditions) ArrayList(java.util.ArrayList) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.SubobjectBuilder) IroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.IroBuilder)

Example 8 with ObjectHeader

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader in project bgpcep by opendaylight.

the class PCEPLspaObjectParser method parseObject.

@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);
    parseTlvs(tbuilder, bytes.slice());
    builder.setTlvs(tbuilder.build());
    return builder.build();
}
Also used : LspaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.TlvsBuilder) AttributeFilter(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter) BitArray(org.opendaylight.protocol.util.BitArray)

Example 9 with ObjectHeader

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader in project bgpcep by opendaylight.

the class PCEPMetricObjectParser method parseObject.

@Override
public Metric 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() != 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());
    final MetricBuilder builder = new MetricBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    builder.setBound(flags.get(B_FLAG_OFFSET));
    builder.setComputed(flags.get(C_FLAG_OFFSET));
    builder.setMetricType(bytes.readUnsignedByte());
    builder.setValue(new Float32(ByteArray.readBytes(bytes, METRIC_VALUE_F_LENGTH)));
    return builder.build();
}
Also used : ByteBufWriteUtil.writeFloat32(org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32) Float32(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32) BitArray(org.opendaylight.protocol.util.BitArray) MetricBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.MetricBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 10 with ObjectHeader

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader in project bgpcep by opendaylight.

the class PCEPMonitoringObjectParser method parseObject.

@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);
    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();
}
Also used : MonitoringBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.MonitoringBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.monitoring.TlvsBuilder) BitArray(org.opendaylight.protocol.util.BitArray) Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring.Flags)

Aggregations

PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)11 BitArray (org.opendaylight.protocol.util.BitArray)8 Preconditions (com.google.common.base.Preconditions)5 ByteBuf (io.netty.buffer.ByteBuf)5 ObjectHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)4 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 EndpointsObjBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObjBuilder)3 EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)2 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)2 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)2 RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId)2 Ipv4CaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.Ipv4CaseBuilder)2 Ipv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4Builder)2 ByteBufWriteUtil.writeFloat32 (org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 BandwidthUsageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.auto.bandwidth.rev171025.bandwidth.usage.object.BandwidthUsageBuilder)1