Search in sources :

Example 1 with SidType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.SidType in project bgpcep by opendaylight.

the class AbstractSrSubobjectParser method serializeNai.

private static void serializeNai(final Nai nai, final SidType sidType, final ByteBuf buffer) {
    switch(sidType) {
        case Ipv4NodeId:
            writeIpv4Address(((IpNodeId) nai).getIpAddress().getIpv4Address(), buffer);
            break;
        case Ipv6NodeId:
            writeIpv6Address(((IpNodeId) nai).getIpAddress().getIpv6Address(), buffer);
            break;
        case Ipv4Adjacency:
            writeIpv4Address(((IpAdjacency) nai).getLocalIpAddress().getIpv4Address(), buffer);
            writeIpv4Address(((IpAdjacency) nai).getRemoteIpAddress().getIpv4Address(), buffer);
            break;
        case Ipv6Adjacency:
            writeIpv6Address(((IpAdjacency) nai).getLocalIpAddress().getIpv6Address(), buffer);
            writeIpv6Address(((IpAdjacency) nai).getRemoteIpAddress().getIpv6Address(), buffer);
            break;
        case Unnumbered:
            final UnnumberedAdjacency unnumbered = (UnnumberedAdjacency) nai;
            ByteBufWriteUtil.writeUnsignedInt(unnumbered.getLocalNodeId(), buffer);
            ByteBufWriteUtil.writeUnsignedInt(unnumbered.getLocalInterfaceId(), buffer);
            ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRemoteNodeId(), buffer);
            ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRemoteInterfaceId(), buffer);
            break;
        default:
            break;
    }
}
Also used : IpNodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.nai.IpNodeId) UnnumberedAdjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.nai.UnnumberedAdjacency) IpAdjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.nai.IpAdjacency)

Example 2 with SidType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.SidType 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)1 BitArray (org.opendaylight.protocol.util.BitArray)1 SidType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.SidType)1 Nai (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.Nai)1 IpAdjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.nai.IpAdjacency)1 IpNodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.nai.IpNodeId)1 UnnumberedAdjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.nai.UnnumberedAdjacency)1