BUG-2663: Support v6 in BGP flowspec
[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.rev150807.bgp.rib.rib.loc.rib.tables.routes.FlowspecIpv6RoutesCase;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.ipv6.routes.FlowspecIpv6Routes;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.ipv6.routes.flowspec.ipv6.routes.FlowspecRoute;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.flowspec.ipv6._case.DestinationFlowspec;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Routes;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
19 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
20 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
21
22 public class FlowspecIpv6RIBSupport extends AbstractFlowspecRIBSupport {
23
24     private static final FSIpv6NlriParser FS_PARSER = new FSIpv6NlriParser();
25
26     private static final FlowspecIpv6RIBSupport SINGLETON = new FlowspecIpv6RIBSupport();
27
28     private final NodeIdentifier destinationNid = new NodeIdentifier(DestinationFlowspec.QNAME);
29     private final NodeIdentifier routeNid = new NodeIdentifier(FlowspecRoute.QNAME);
30     private final ChoiceNode emptyRoutes = Builders.choiceBuilder()
31         .withNodeIdentifier(new NodeIdentifier(Routes.QNAME))
32         .addChild(Builders.containerBuilder()
33             .withNodeIdentifier(new NodeIdentifier(FlowspecIpv6Routes.QNAME))
34             .addChild(ImmutableNodes.mapNodeBuilder(FlowspecRoute.QNAME).build()).build()).build();
35
36     private FlowspecIpv6RIBSupport() {
37         super(FlowspecIpv6RoutesCase.class, FlowspecIpv6Routes.class, FlowspecRoute.class);
38     }
39
40     static FlowspecIpv6RIBSupport getInstance() {
41         return SINGLETON;
42     }
43
44     @Override
45     public ChoiceNode emptyRoutes() {
46         return this.emptyRoutes;
47     }
48
49     @Override
50     protected NodeIdentifier destinationContainerIdentifier() {
51         return this.destinationNid;
52     }
53
54     @Override
55     protected NodeIdentifier routeIdentifier() {
56         return this.routeNid;
57     }
58
59     @Override
60     protected AbstractFSNlriParser getParser() {
61         return FS_PARSER;
62     }
63
64     @Override
65     protected Class<? extends AddressFamily> getAfiClass() {
66         return Ipv6AddressFamily.class;
67     }
68
69 }