use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.destination.type.VpnDestinationBuilder in project bgpcep by opendaylight.
the class VpnDestinationUtil method parseNlri.
static List<VpnDestination> parseNlri(final ByteBuf nlri, final PeerSpecificParserConstraint constraints, final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
if (!nlri.isReadable()) {
return null;
}
final List<VpnDestination> dests = new ArrayList<>();
while (nlri.isReadable()) {
final VpnDestinationBuilder builder = new VpnDestinationBuilder();
if (MultiPathSupportUtil.isTableTypeSupported(constraints, new BgpTableTypeImpl(afi, safi))) {
builder.setPathId(PathIdUtil.readPathId(nlri));
}
final short length = nlri.readUnsignedByte();
final List<LabelStack> labels = LUNlriParser.parseLabel(nlri);
builder.setLabelStack(labels);
final int labelNum = labels != null ? labels.size() : 1;
final int prefixLen = length - (LUNlriParser.LABEL_LENGTH * Byte.SIZE * labelNum) - (RouteDistinguisherUtil.RD_LENGTH * Byte.SIZE);
builder.setRouteDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(nlri));
Preconditions.checkState(prefixLen > 0, "A valid VPN IP prefix is required.");
builder.setPrefix(LUNlriParser.parseIpPrefix(nlri, prefixLen, afi));
dests.add(builder.build());
}
return dests;
}
Aggregations