MVPN RFC6514 Extendend communities
[bgpcep.git] / bgp / flowspec / src / main / java / org / opendaylight / protocol / bgp / flowspec / l3vpn / ipv4 / FlowspecL3vpnIpv4RIBSupport.java
1 /*
2  * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv4;
9
10 import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
11 import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv4RoutesCase;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.FlowspecL3vpnIpv4RoutesCaseBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRoute;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRouteBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRouteKey;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.routes.FlowspecL3vpnIpv4Routes;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.routes.FlowspecL3vpnIpv4RoutesBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
24
25 public final class FlowspecL3vpnIpv4RIBSupport extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv4NlriParser,
26         FlowspecL3vpnRoute, FlowspecL3vpnRouteKey> {
27
28     public FlowspecL3vpnIpv4RIBSupport(final SimpleFlowspecExtensionProviderContext context) {
29         super(
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))
38         );
39     }
40
41     public static FlowspecL3vpnIpv4RIBSupport getInstance(final SimpleFlowspecExtensionProviderContext context) {
42         return new FlowspecL3vpnIpv4RIBSupport(context);
43     }
44
45     @Override
46     public final FlowspecL3vpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
47         return new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey);
48     }
49
50     @Override
51     public FlowspecL3vpnRoute createRoute(final FlowspecL3vpnRoute route, final String routeKey,
52             final long pathId, final Attributes attributes) {
53         final FlowspecL3vpnRouteBuilder builder;
54         if (route != null) {
55             builder = new FlowspecL3vpnRouteBuilder(route);
56         } else {
57             builder = new FlowspecL3vpnRouteBuilder();
58         }
59         return builder.setKey(new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey))
60                 .setAttributes(attributes).build();
61     }
62
63     @Override
64     public Routes emptyRoutesContainer() {
65         return new FlowspecL3vpnIpv4RoutesCaseBuilder()
66                 .setFlowspecL3vpnIpv4Routes(new FlowspecL3vpnIpv4RoutesBuilder().build()).build();
67     }
68 }