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.flowspec.l3vpn.ipv4;
10 import java.util.Collection;
11 import java.util.Collections;
12 import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
13 import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv4RoutesCase;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRoute;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRouteBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRouteKey;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.ipv4.routes.FlowspecL3vpnIpv4Routes;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.PathId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
24 public final class FlowspecL3vpnIpv4RIBSupport extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv4NlriParser,
25 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.bgp.rib.rib.peer.adj
26 .rib.in.tables.routes.FlowspecL3vpnIpv4RoutesCase, FlowspecL3vpnRoute, FlowspecL3vpnRouteKey> {
28 public FlowspecL3vpnIpv4RIBSupport(final SimpleFlowspecExtensionProviderContext context) {
30 FlowspecL3vpnIpv4RoutesCase.class,
31 FlowspecL3vpnIpv4Routes.class,
32 FlowspecL3vpnRoute.class,
33 DestinationFlowspecL3vpnIpv4.QNAME,
34 Ipv4AddressFamily.class,
35 new FlowspecL3vpnIpv4NlriParser(context
36 .getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
37 SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
41 public static FlowspecL3vpnIpv4RIBSupport getInstance(final SimpleFlowspecExtensionProviderContext context) {
42 return new FlowspecL3vpnIpv4RIBSupport(context);
46 public final FlowspecL3vpnRouteKey createNewRouteKey(final PathId pathId, final FlowspecL3vpnRouteKey routeKey) {
47 return new FlowspecL3vpnRouteKey(pathId, routeKey.getRouteKey());
51 public FlowspecL3vpnRouteKey extractRouteKey(final FlowspecL3vpnRoute route) {
52 return route.getKey();
56 public FlowspecL3vpnRoute createRoute(
57 final FlowspecL3vpnRoute route,
58 final FlowspecL3vpnRouteKey routeKey,
60 final Attributes attributes) {
61 final FlowspecL3vpnRouteBuilder builder;
63 builder = new FlowspecL3vpnRouteBuilder(route);
65 builder = new FlowspecL3vpnRouteBuilder();
67 return builder.setRouteKey(routeKey.getRouteKey()).setPathId(pathId).setAttributes(attributes).build();
71 public Collection<FlowspecL3vpnRoute> changedRoutes(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
72 .ns.yang.bgp.flowspec.rev171207.bgp.rib.rib.peer.adj.rib.in.tables.routes.FlowspecL3vpnIpv4RoutesCase routes) {
73 final FlowspecL3vpnIpv4Routes routeCont = routes.getFlowspecL3vpnIpv4Routes();
74 if (routeCont == null) {
75 return Collections.emptyList();
77 return routeCont.getFlowspecL3vpnRoute();