Search in sources :

Example 31 with Nlri

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 MpReachNlriBuilder builder, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
    if (!nlri.isReadable()) {
        return;
    }
    final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
    builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationL3vpnMcastIpv4AdvertizedCaseBuilder().setDestinationIpv4L3vpnMcast(new DestinationIpv4L3vpnMcastBuilder().setL3vpnMcastDestination(L3vpnMcastNlriSerializer.extractDest(nlri, mPathSupported)).build()).build()).build());
}
Also used : AdvertizedRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder) DestinationL3vpnMcastIpv4AdvertizedCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationL3vpnMcastIpv4AdvertizedCaseBuilder) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) DestinationIpv4L3vpnMcastBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.l3vpn.mcast.ipv4.advertized._case.DestinationIpv4L3vpnMcastBuilder)

Example 32 with Nlri

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 L3vpnMcastNlriSerializer method extractDest.

static List<L3vpnMcastDestination> extractDest(final ByteBuf nlri, final boolean addPath) {
    List<L3vpnMcastDestination> dests = new ArrayList<>();
    while (nlri.isReadable()) {
        final L3vpnMcastDestinationBuilder builder = new L3vpnMcastDestinationBuilder();
        if (addPath) {
            builder.setPathId(PathIdUtil.readPathId(nlri));
        }
        final int length = nlri.readUnsignedByte();
        final int initialLength = nlri.readableBytes();
        builder.setRouteDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(nlri));
        if (length == Ipv6Util.IPV6_BITS_LENGTH) {
            builder.setPrefix(new IpPrefix(Ipv6Util.prefixForByteBuf(nlri)));
        } else {
            builder.setPrefix(new IpPrefix(Ipv4Util.prefixForByteBuf(nlri)));
        }
        dests.add(builder.build());
        int readed = initialLength - nlri.readableBytes();
        while (readed % 8 != 0) {
            nlri.readByte();
            readed = initialLength - nlri.readableBytes();
        }
    }
    return dests;
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) L3vpnMcastDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestination) ArrayList(java.util.ArrayList) L3vpnMcastDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestinationBuilder)

Example 33 with Nlri

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 AbstractVpnNlriParser method serializeNlri.

private static void serializeNlri(final List<VpnDestination> dests, final boolean isWithdrawnRoute, final ByteBuf buffer) {
    final ByteBuf nlriByteBuf = Unpooled.buffer();
    for (final VpnDestination dest : dests) {
        final List<LabelStack> labelStack = dest.getLabelStack();
        final IpPrefix prefix = dest.getPrefix();
        LOG.debug("Serializing Nlri: VpnDestination={}, IpPrefix={}", dest, prefix);
        AbstractVpnNlriParser.serializeLengtField(prefix, labelStack, nlriByteBuf);
        LUNlriParser.serializeLabelStackEntries(labelStack, isWithdrawnRoute, nlriByteBuf);
        RouteDistinguisherUtil.serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriByteBuf);
        Preconditions.checkArgument(prefix.getIpv6Prefix() != null || prefix.getIpv4Prefix() != null, "Ipv6 or Ipv4 prefix is missing.");
        LUNlriParser.serializePrefixField(prefix, nlriByteBuf);
    }
    buffer.writeBytes(nlriByteBuf);
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) VpnDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.destination.type.VpnDestination) LabelStack(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStack) ByteBuf(io.netty.buffer.ByteBuf)

Example 34 with Nlri

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 RouteTargetConstrainNlriHandler method parseNlriDestinations.

private static List<RouteTargetConstrainDestination> parseNlriDestinations(final ByteBuf nlri, final boolean addPathSupported) {
    final List<RouteTargetConstrainDestination> dests = new ArrayList<>();
    while (nlri.isReadable()) {
        final RouteTargetConstrainDestinationBuilder builder = new RouteTargetConstrainDestinationBuilder();
        if (addPathSupported) {
            builder.setPathId(PathIdUtil.readPathId(nlri));
        }
        final int length = nlri.readUnsignedByte() / 8;
        final ByteBuf nlriBuf = nlri.readSlice(length);
        Integer type = null;
        if (length != 0) {
            builder.setOriginAs(new AsNumber(ByteBufUtils.readUint32(nlriBuf)));
            type = (int) nlriBuf.readUnsignedByte();
            // Skip Subtype
            nlriBuf.skipBytes(1);
        }
        builder.setRouteTargetConstrainChoice(ImmutableRouteTargetConstrainNlriRegistry.getInstance().parseRouteTargetConstrain(type, nlriBuf));
        dests.add(builder.build());
    }
    return dests;
}
Also used : RouteTargetConstrainDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestinationBuilder) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) RouteTargetConstrainDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) PeerSpecificParserConstraint(org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)

Example 35 with Nlri

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 RouteTargetConstrainNlriHandler method serializeNlriDestinations.

public static ByteBuf serializeNlriDestinations(final List<RouteTargetConstrainDestination> destinationList) {
    final ByteBuf nlri = Unpooled.buffer();
    for (final RouteTargetConstrainDestination dest : destinationList) {
        final RouteTargetConstrainChoice rtcChoice = dest.getRouteTargetConstrainChoice();
        if (rtcChoice instanceof RouteTargetConstrainDefaultCase) {
            nlri.writeByte(0);
        } else {
            nlri.writeByte(RT_BITS_LENGTH);
            final AsNumber originAs = dest.getOriginAs();
            if (originAs != null) {
                ByteBufUtils.write(nlri, originAs.getValue());
            }
            nlri.writeBytes(ImmutableRouteTargetConstrainNlriRegistry.getInstance().serializeRouteTargetConstrain(rtcChoice));
        }
    }
    return nlri;
}
Also used : RouteTargetConstrainDefaultCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.route.target.constrain.choice.RouteTargetConstrainDefaultCase) ByteBuf(io.netty.buffer.ByteBuf) RouteTargetConstrainDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) RouteTargetConstrainChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.RouteTargetConstrainChoice)

Aggregations

ArrayList (java.util.ArrayList)40 ByteBuf (io.netty.buffer.ByteBuf)26 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)18 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder)14 Test (org.junit.Test)13 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)13 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)13 Nlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri)13 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder)12 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)12 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)11 NlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.NlriBuilder)11 WithdrawnRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder)11 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)10 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)10 NumericOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand)10 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder)10 OriginBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder)10 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)10 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)9