Search in sources :

Example 46 with PCEPDeserializerException

use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.

the class AbstractSrSubobjectParser method parseSrSubobject.

protected static SrSubobject parseSrSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
    final int sidTypeByte = buffer.readByte() >> SID_TYPE_BITS_OFFSET;
    final SidType sidType = SidType.forValue(sidTypeByte);
    final BitArray bitSet = BitArray.valueOf(buffer.readByte());
    final boolean f = bitSet.get(F_FLAG_POSITION);
    final boolean s = bitSet.get(S_FLAG_POSITION);
    final boolean c = bitSet.get(C_FLAG_POSITION);
    final boolean m = bitSet.get(M_FLAG_POSITION);
    if (f && s) {
        throw new PCEPDeserializerException("Both SID and NAI are absent in SR subobject.");
    }
    Long tmp = null;
    if (!s) {
        if (m) {
            tmp = buffer.readUnsignedInt() >>> MPLS_LABEL_OFFSET;
        } else {
            tmp = buffer.readUnsignedInt();
        }
    }
    final Long sid = tmp;
    final Nai nai;
    if (sidType != null && !f) {
        nai = parseNai(sidType, buffer);
    } else {
        nai = null;
    }
    return new SrSubobjectImpl(m, c, sidType, sid, nai);
}
Also used : SidType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.SidType) Nai(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.Nai) BitArray(org.opendaylight.protocol.util.BitArray) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Aggregations

PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)46 ArrayList (java.util.ArrayList)8 BitArray (org.opendaylight.protocol.util.BitArray)8 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)6 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.SubobjectBuilder)6 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)5 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)5 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)5 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder)4 IpPrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder)4 IpPrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder)4 Preconditions (com.google.common.base.Preconditions)3 EndpointsObjBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObjBuilder)3 PathKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey)3 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId)3 ByteBuf (io.netty.buffer.ByteBuf)2 PCEPErrors (org.opendaylight.protocol.pcep.spi.PCEPErrors)2 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)2 PcerrBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder)2 Ipv4CaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.Ipv4CaseBuilder)2