MVPN RFC6514 Extendend communities
[bgpcep.git] / bgp / flowspec / src / main / java / org / opendaylight / protocol / bgp / flowspec / FlowspecIpv6RIBSupport.java
1 /*
2  * Copyright (c) 2015 Cisco 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;
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.FlowspecSubsequentAddressFamily;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecIpv6RoutesCase;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.FlowspecIpv6RoutesCaseBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.ipv6.DestinationFlowspec;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv6.route.FlowspecRoute;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv6.route.FlowspecRouteBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv6.route.FlowspecRouteKey;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv6.routes.FlowspecIpv6Routes;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv6.routes.FlowspecIpv6RoutesBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
23
24 public final class FlowspecIpv6RIBSupport extends AbstractFlowspecRIBSupport<SimpleFlowspecIpv6NlriParser,
25         FlowspecRoute, FlowspecRouteKey> {
26
27     public FlowspecIpv6RIBSupport(SimpleFlowspecExtensionProviderContext context) {
28         super(
29                 FlowspecIpv6RoutesCase.class,
30                 FlowspecIpv6Routes.class,
31                 FlowspecRoute.class,
32                 Ipv6AddressFamily.class,
33                 FlowspecSubsequentAddressFamily.class,
34                 DestinationFlowspec.QNAME,
35                 new SimpleFlowspecIpv6NlriParser(context
36                         .getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6,
37                                 SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC))
38         );
39     }
40
41     static FlowspecIpv6RIBSupport getInstance(SimpleFlowspecExtensionProviderContext context) {
42         return new FlowspecIpv6RIBSupport(context);
43     }
44
45     @Override
46     public FlowspecRoute createRoute(final FlowspecRoute route, final String routeKey,
47             final long pathId, final Attributes attributes) {
48         final FlowspecRouteBuilder builder;
49         if (route != null) {
50             builder = new FlowspecRouteBuilder(route);
51         } else {
52             builder = new FlowspecRouteBuilder();
53         }
54         return builder.setKey(new FlowspecRouteKey(new PathId(pathId), routeKey)).setAttributes(attributes).build();
55     }
56
57     @Override
58     public Routes emptyRoutesContainer() {
59         return new FlowspecIpv6RoutesCaseBuilder()
60                 .setFlowspecIpv6Routes(new FlowspecIpv6RoutesBuilder().build()).build();
61     }
62
63     @Override
64     public FlowspecRouteKey createRouteListKey(final long pathId, final String routeKey) {
65         return new FlowspecRouteKey(new PathId(pathId), routeKey);
66     }
67 }