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;
}
}
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);
}
Aggregations