Search in sources :

Example 1 with VpnDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination in project bgpcep by opendaylight.

the class AbstractVpnRIBSupport method createRouteKey.

private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode l3vpn) {
    final ByteBuf buffer = Unpooled.buffer();
    final VpnDestination dests = new VpnDestinationBuilder().setPrefix(extractPrefix(l3vpn, this.prefixTypeNid)).setRouteDistinguisher(extractRouteDistinguisher(l3vpn)).build();
    final ByteBuf nlriByteBuf = Unpooled.buffer();
    for (final VpnDestination dest : Collections.singletonList(dests)) {
        final IpPrefix prefix = dest.getPrefix();
        LOG.debug("Serializing Nlri: VpnDestination={}, IpPrefix={}", dest, prefix);
        AbstractVpnNlriParser.serializeLengtField(prefix, null, 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);
    return new NodeIdentifierWithPredicates(routeQName(), this.routeKey, ByteArray.encodeBase64(buffer));
}
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.rev171207.l3vpn.ip.destination.type.VpnDestination) ByteBuf(io.netty.buffer.ByteBuf) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) VpnDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestinationBuilder)

Example 2 with VpnDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination in project bgpcep by opendaylight.

the class AbstractVpnNlriParser method serializeAttribute.

@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a Attributes object");
    final Attributes pathAttributes = (Attributes) attribute;
    final Attributes1 pathAttributes1 = pathAttributes.getAugmentation(Attributes1.class);
    final Attributes2 pathAttributes2 = pathAttributes.getAugmentation(Attributes2.class);
    List<VpnDestination> vpnDst = null;
    boolean isWithdrawnRoute = false;
    if (pathAttributes1 != null) {
        final AdvertizedRoutes routes = (pathAttributes1.getMpReachNlri()).getAdvertizedRoutes();
        if (routes != null) {
            vpnDst = getAdvertizedVpnDestination(routes.getDestinationType());
        }
    } else if (pathAttributes2 != null) {
        final WithdrawnRoutes routes = pathAttributes2.getMpUnreachNlri().getWithdrawnRoutes();
        if (routes != null) {
            vpnDst = getWithdrawnVpnDestination(routes.getDestinationType());
            isWithdrawnRoute = true;
        }
    }
    if (vpnDst != null) {
        serializeNlri(vpnDst, isWithdrawnRoute, byteAggregator);
    }
}
Also used : VpnDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination) AdvertizedRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) Attributes2(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1) WithdrawnRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutes)

Example 3 with VpnDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination 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.rev171207.l3vpn.ip.destination.type.VpnDestination) LabelStack(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStack) ByteBuf(io.netty.buffer.ByteBuf)

Example 4 with VpnDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination in project bgpcep by opendaylight.

the class VpnDestinationUtil method parseNlri.

static List<VpnDestination> parseNlri(final ByteBuf nlri, final Class<? extends AddressFamily> afi) {
    if (!nlri.isReadable()) {
        return null;
    }
    final List<VpnDestination> dests = new ArrayList<>();
    while (nlri.isReadable()) {
        final VpnDestinationBuilder builder = new VpnDestinationBuilder();
        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;
}
Also used : VpnDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination) LabelStack(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStack) ArrayList(java.util.ArrayList) VpnDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestinationBuilder)

Aggregations

VpnDestination (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination)4 ByteBuf (io.netty.buffer.ByteBuf)2 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 LabelStack (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStack)2 VpnDestinationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestinationBuilder)2 ArrayList (java.util.ArrayList)1 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)1 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1)1 Attributes2 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2)1 AdvertizedRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes)1 WithdrawnRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutes)1 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)1