use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.
the class LUNlriParser method parseNlri.
private static List<CLabeledUnicastDestination> parseNlri(final ByteBuf nlri, final Class<? extends AddressFamily> afi, final boolean multiPathSupported) {
if (!nlri.isReadable()) {
return null;
}
final List<CLabeledUnicastDestination> dests = new ArrayList<>();
while (nlri.isReadable()) {
final CLabeledUnicastDestinationBuilder builder = new CLabeledUnicastDestinationBuilder();
if (multiPathSupported) {
builder.setPathId(PathIdUtil.readPathId(nlri));
}
final short length = nlri.readUnsignedByte();
final List<LabelStack> labels = parseLabel(nlri);
builder.setLabelStack(labels);
final int labelNum = labels != null ? labels.size() : 1;
final int prefixLen = length - LABEL_LENGTH * Byte.SIZE * labelNum;
builder.setPrefix(parseIpPrefix(nlri, prefixLen, afi));
dests.add(builder.build());
}
return dests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.
the class LUNlriParser method parseLabel.
public static List<LabelStack> parseLabel(final ByteBuf nlri) {
if (!nlri.isReadable()) {
return null;
}
final List<LabelStack> labels = new ArrayList<>();
boolean bottomBit;
do {
final ByteBuf slice = nlri.readSlice(LABEL_LENGTH);
bottomBit = MplsLabelUtil.getBottomBit(slice);
final MplsLabel mplsLabel = MplsLabelUtil.mplsLabelForByteBuf(slice);
if (MplsLabelUtil.intForMplsLabel(mplsLabel) == WITHDRAW_LABEL_INT_VALUE) {
return null;
}
labels.add(new LabelStackBuilder().setLabelValue(mplsLabel).build());
} while (!bottomBit);
return labels;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.
the class LUNlriParser method parseNlri.
@Override
public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final Class<? extends AddressFamily> afi = builder.getAfi();
final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
final List<CLabeledUnicastDestination> dst = parseNlri(nlri, afi, mPathSupported);
DestinationType destination = null;
if (afi == Ipv4AddressFamily.class) {
destination = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(dst).build()).build();
} else if (afi == Ipv6AddressFamily.class) {
destination = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder().setCLabeledUnicastDestination(dst).build()).build();
}
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(destination).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.
the class LinkstateAttributeParser method parseAttribute.
@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder, final RevisedErrorHandling errorHandling, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
// FIXME: BGPCEP-359: we need an updated link-state spec for RFC7606
final CLinkstateDestination lsDestination = getNlriType(builder);
if (lsDestination == null) {
LOG.warn("No Linkstate NLRI found, not parsing Linkstate attribute");
return;
}
final ObjectType nlriType = lsDestination.getObjectType();
final ProtocolId protocolId = lsDestination.getProtocolId();
builder.addAugmentation(new Attributes1Builder().setLinkStateAttribute(parseLinkState(nlriType, protocolId, buffer)).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.
the class L3vpnMcastIpv4NlriHandler method parseNlri.
@Override
public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new DestinationL3vpnMcastIpv4WithdrawnCaseBuilder().setDestinationIpv4L3vpnMcast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.l3vpn.mcast.ipv4.withdrawn._case.DestinationIpv4L3vpnMcastBuilder().setL3vpnMcastDestination(L3vpnMcastNlriSerializer.extractDest(nlri, mPathSupported)).build()).build()).build());
}
Aggregations