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.ipv4;
10 import java.util.Collection;
11 import java.util.Collections;
12 import java.util.List;
13 import org.opendaylight.protocol.bgp.l3vpn.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.rev171207.destination.DestinationType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.bgp.rib.rib.loc.rib.tables.routes.VpnIpv4RoutesCase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.l3vpn.ipv4.destination.VpnIpv4Destination;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.l3vpn.ipv4.destination.VpnIpv4DestinationBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.l3vpn.ipv4.routes.VpnIpv4Routes;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.route.VpnRoute;
24 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
25 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
27 final class VpnIpv4RIBSupport extends AbstractVpnRIBSupport<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
28 .ns.yang.bgp.vpn.ipv4.rev171207.bgp.rib.rib.peer.adj.rib.in.tables.routes.VpnIpv4RoutesCase> {
30 * Default constructor. Requires the QName of the container augmented under the routes choice
31 * node in instantiations of the rib grouping. It is assumed that this container is defined by
32 * the same model which populates it with route grouping instantiation, and by extension with
33 * the route attributes container.
36 super(VpnIpv4RoutesCase.class, VpnIpv4Routes.class, VpnRoute.class,
37 Ipv4AddressFamily.class, VpnIpv4Destination.QNAME);
41 protected IpPrefix extractPrefix(final DataContainerNode<? extends YangInstanceIdentifier.PathArgument> route,
42 final YangInstanceIdentifier.NodeIdentifier prefixTypeNid) {
43 if (route.getChild(prefixTypeNid).isPresent()) {
44 final String prefixType = (String) route.getChild(prefixTypeNid).get().getValue();
45 return new IpPrefix(new Ipv4Prefix(prefixType));
51 protected DestinationType getAdvertisedDestinationType(List<VpnDestination> dests) {
52 return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update
53 .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder()
54 .setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(dests).build()).build();
58 protected DestinationType getWithdrawnDestinationType(List<VpnDestination> dests) {
59 return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update
60 .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
61 .setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(dests).build()).build();
65 public Collection<VpnRoute> changedRoutes(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
66 .bgp.vpn.ipv4.rev171207.bgp.rib.rib.peer.adj.rib.in.tables.routes.VpnIpv4RoutesCase routes) {
67 final VpnIpv4Routes routeCont = routes.getVpnIpv4Routes();
68 if (routeCont == null) {
69 return Collections.emptyList();
71 return routeCont.getVpnRoute();