2 * Copyright (c) 2016 Cisco 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.ipv4;
10 import java.util.Collections;
11 import java.util.List;
12 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
13 import org.opendaylight.protocol.bgp.l3vpn.unicast.AbstractVpnRIBSupport;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.bgp.rib.rib.loc.rib.tables.routes.VpnIpv4RoutesCase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.bgp.rib.rib.loc.rib.tables.routes.VpnIpv4RoutesCaseBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.l3vpn.ipv4.destination.VpnIpv4Destination;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.l3vpn.ipv4.destination.VpnIpv4DestinationBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.l3vpn.ipv4.routes.VpnIpv4Routes;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.l3vpn.ipv4.routes.VpnIpv4RoutesBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.destination.type.VpnDestination;
26 public final class VpnIpv4RIBSupport extends AbstractVpnRIBSupport<VpnIpv4RoutesCase, VpnIpv4Routes> {
27 private static final VpnIpv4Routes EMPTY_CONTAINER
28 = new VpnIpv4RoutesBuilder().setVpnRoute(Collections.emptyList()).build();
29 private static final VpnIpv4RoutesCase EMPTY_CASE
30 = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(EMPTY_CONTAINER).build();
31 private static VpnIpv4RIBSupport SINGLETON;
34 * Default constructor. Requires the QName of the container augmented under the routes choice
35 * node in instantiations of the rib grouping. It is assumed that this container is defined by
36 * the same model which populates it with route grouping instantiation, and by extension with
37 * the route attributes container.
39 private VpnIpv4RIBSupport(final BindingNormalizedNodeSerializer mappingService) {
41 VpnIpv4RoutesCase.class,
43 Ipv4AddressFamily.class,
44 VpnIpv4Destination.QNAME);
47 public static synchronized VpnIpv4RIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
48 if (SINGLETON == null) {
49 SINGLETON = new VpnIpv4RIBSupport(mappingService);
55 protected IpPrefix createPrefix(final String prefix) {
56 return new IpPrefix(new Ipv4Prefix(prefix));
60 protected DestinationType getAdvertisedDestinationType(List<VpnDestination> dests) {
61 return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update
62 .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder()
63 .setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(dests).build()).build();
67 protected DestinationType getWithdrawnDestinationType(List<VpnDestination> dests) {
68 return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update
69 .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
70 .setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(dests).build()).build();
74 public VpnIpv4RoutesCase emptyRoutesCase() {
79 public VpnIpv4Routes emptyRoutesContainer() {
80 return EMPTY_CONTAINER;