e2c117724aace44d189dbe71da33e473cbcd2a55
[bgpcep.git] / bgp / flowspec / src / main / java / org / opendaylight / protocol / bgp / flowspec / l3vpn / ipv6 / FlowspecL3vpnIpv6RIBSupport.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.ipv6;
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.FlowspecL3vpnIpv6RoutesCase;
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.FlowspecL3vpnIpv6RoutesCaseBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRoute;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteKey;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6Routes;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6RoutesBuilder;
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.rib.rev180329.rib.tables.Routes;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
24
25 public final class FlowspecL3vpnIpv6RIBSupport extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv6NlriParser,
26         FlowspecL3vpnRoute, FlowspecL3vpnRouteKey> {
27     private FlowspecL3vpnIpv6RIBSupport(SimpleFlowspecExtensionProviderContext context) {
28         super(
29                 FlowspecL3vpnIpv6RoutesCase.class,
30                 FlowspecL3vpnIpv6Routes.class,
31                 FlowspecL3vpnRoute.class,
32                 DestinationFlowspecL3vpnIpv6.QNAME,
33                 Ipv6AddressFamily.class,
34                 new FlowspecL3vpnIpv6NlriParser(context
35                         .getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6,
36                                 SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
37         );
38     }
39
40     public static FlowspecL3vpnIpv6RIBSupport getInstance(final SimpleFlowspecExtensionProviderContext context) {
41         return new FlowspecL3vpnIpv6RIBSupport(context);
42     }
43
44     @Override
45     public final FlowspecL3vpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
46         return new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey);
47     }
48
49     @Override
50     public FlowspecL3vpnRoute createRoute(final FlowspecL3vpnRoute route, final String routeKey,
51             final long pathId, final Attributes attributes) {
52         final FlowspecL3vpnRouteBuilder builder;
53         if (route != null) {
54             builder = new FlowspecL3vpnRouteBuilder(route);
55         } else {
56             builder = new FlowspecL3vpnRouteBuilder();
57         }
58         return builder.setKey(new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey))
59                 .setAttributes(attributes).build();
60     }
61
62     @Override
63     public Routes emptyRoutesContainer() {
64         return new FlowspecL3vpnIpv6RoutesCaseBuilder()
65                 .setFlowspecL3vpnIpv6Routes(new FlowspecL3vpnIpv6RoutesBuilder().build()).build();
66     }
67 }