Search in sources :

Example 1 with L3vpnMcastDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestination 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 2 with L3vpnMcastDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestination in project bgpcep by opendaylight.

the class L3VpnMcastIpv4RIBSupport method createRouteKey.

@Override
public NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode l3vpn) {
    final ByteBuf buffer = Unpooled.buffer();
    final L3vpnMcastDestination dest = extractDestinations(l3vpn);
    L3vpnMcastNlriSerializer.serializeNlri(List.of(dest), buffer);
    return PathIdUtil.createNidKey(routeQName(), routeKeyTemplate(), ByteArray.encodeBase64(buffer), l3vpn.findChildByArg(routePathIdNid()));
}
Also used : L3vpnMcastDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestination) ByteBuf(io.netty.buffer.ByteBuf)

Example 3 with L3vpnMcastDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestination in project bgpcep by opendaylight.

the class L3VpnMcastIpv6RIBSupport method createRouteKey.

@Override
public NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode l3vpn) {
    final ByteBuf buffer = Unpooled.buffer();
    final L3vpnMcastDestination dest = extractDestinations(l3vpn);
    L3vpnMcastNlriSerializer.serializeNlri(List.of(dest), buffer);
    return PathIdUtil.createNidKey(routeQName(), routeKeyTemplate(), ByteArray.encodeBase64(buffer), l3vpn.findChildByArg(routePathIdNid()));
}
Also used : L3vpnMcastDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestination) ByteBuf(io.netty.buffer.ByteBuf)

Example 4 with L3vpnMcastDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestination in project bgpcep by opendaylight.

the class L3vpnMcastNlriSerializer method serializeNlri.

public static void serializeNlri(final List<L3vpnMcastDestination> destinationList, final ByteBuf output) {
    for (final L3vpnMcastDestination dest : destinationList) {
        PathIdUtil.writePathId(dest.getPathId(), output);
        ByteBuf prefixBuf = Unpooled.buffer();
        RouteDistinguisherUtil.serializeRouteDistinquisher(dest.getRouteDistinguisher(), prefixBuf);
        final IpPrefix prefix = dest.getPrefix();
        if (prefix.getIpv4Prefix() != null) {
            output.writeByte(Ipv4Util.IP4_BITS_LENGTH);
            Ipv4Util.writeMinimalPrefix(prefix.getIpv4Prefix(), prefixBuf);
        } else {
            output.writeByte(Ipv6Util.IPV6_BITS_LENGTH);
            Ipv6Util.writeMinimalPrefix(prefix.getIpv6Prefix(), prefixBuf);
        }
        // FIXME: remove this funky loop
        while (prefixBuf.readableBytes() % 8 != 0) {
            prefixBuf.writeByte(0);
        }
        output.writeBytes(prefixBuf);
    }
}
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) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

L3vpnMcastDestination (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestination)4 ByteBuf (io.netty.buffer.ByteBuf)3 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 ArrayList (java.util.ArrayList)1 L3vpnMcastDestinationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestinationBuilder)1