2 * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.bgp.l3vpn.unicast.ipv6;
10 import static com.google.common.base.Verify.verify;
12 import java.util.Collections;
13 import java.util.List;
15 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
16 import org.opendaylight.protocol.bgp.l3vpn.unicast.AbstractVpnRIBSupport;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.bgp.rib.rib.loc.rib.tables.routes.VpnIpv6RoutesCase;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.destination.VpnIpv6Destination;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.destination.VpnIpv6DestinationBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.routes.VpnIpv6Routes;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.routes.VpnIpv6RoutesBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.destination.type.VpnDestination;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.route.VpnRoute;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.route.VpnRouteKey;
31 public final class VpnIpv6RIBSupport extends AbstractVpnRIBSupport<VpnIpv6RoutesCase, VpnIpv6Routes> {
32 private static final VpnIpv6Routes EMPTY_CONTAINER
33 = new VpnIpv6RoutesBuilder().setVpnRoute(Collections.emptyList()).build();
34 private static VpnIpv6RIBSupport SINGLETON;
37 * Default constructor. Requires the QName of the container augmented under the routes choice
38 * node in instantiations of the rib grouping. It is assumed that this container is defined by
39 * the same model which populates it with route grouping instantiation, and by extension with
40 * the route attributes container.
42 private VpnIpv6RIBSupport(final BindingNormalizedNodeSerializer mappingService) {
44 VpnIpv6RoutesCase.class,
46 Ipv6AddressFamily.class,
47 VpnIpv6Destination.QNAME);
50 public static synchronized VpnIpv6RIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
51 if (SINGLETON == null) {
52 SINGLETON = new VpnIpv6RIBSupport(mappingService);
58 protected IpPrefix createPrefix(final String prefix) {
59 return new IpPrefix(new Ipv6Prefix(prefix));
63 protected DestinationType getAdvertisedDestinationType(final List<VpnDestination> dests) {
64 return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
65 .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder()
66 .setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(dests).build()).build();
70 protected DestinationType getWithdrawnDestinationType(final List<VpnDestination> dests) {
71 return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
72 .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
73 .setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(dests).build()).build();
77 public VpnIpv6Routes emptyRoutesContainer() {
78 return EMPTY_CONTAINER;
82 public Map<VpnRouteKey, VpnRoute> extractAdjRibInRoutes(final Routes routes) {
83 verify(routes instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329
84 .bgp.rib.rib.peer.adj.rib.in.tables.routes.VpnIpv6RoutesCase, "Unrecognized routes %s", routes);
85 return ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329
86 .bgp.rib.rib.peer.adj.rib.in.tables.routes.VpnIpv6RoutesCase) routes).getVpnIpv6Routes()