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.ipv6;
10 import static com.google.common.base.Verify.verify;
12 import java.util.Collections;
13 import java.util.List;
14 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
15 import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
16 import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRoute;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteKey;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6Routes;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6RoutesBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily;
29 public final class FlowspecL3vpnIpv6RIBSupport
30 extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv6NlriParser,
31 FlowspecL3vpnIpv6RoutesCase,
32 FlowspecL3vpnIpv6Routes,
34 FlowspecL3vpnRouteKey> {
35 private static final FlowspecL3vpnIpv6Routes EMPTY_CONTAINER
36 = new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(Collections.emptyList()).build();
37 private static FlowspecL3vpnIpv6RIBSupport SINGLETON;
39 private FlowspecL3vpnIpv6RIBSupport(
40 final SimpleFlowspecExtensionProviderContext context,
41 final BindingNormalizedNodeSerializer mappingService) {
44 FlowspecL3vpnIpv6RoutesCase.class,
45 FlowspecL3vpnIpv6Routes.class,
46 FlowspecL3vpnRoute.class,
47 DestinationFlowspecL3vpnIpv6.QNAME,
48 Ipv6AddressFamily.class,
49 new FlowspecL3vpnIpv6NlriParser(context
50 .getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6,
51 SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
55 public static synchronized FlowspecL3vpnIpv6RIBSupport getInstance(
56 final SimpleFlowspecExtensionProviderContext context,
57 final BindingNormalizedNodeSerializer mappingService) {
58 if (SINGLETON == null) {
59 SINGLETON = new FlowspecL3vpnIpv6RIBSupport(context, mappingService);
65 public FlowspecL3vpnRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
66 return new FlowspecL3vpnRouteKey(pathId, routeKey);
70 public FlowspecL3vpnRoute createRoute(final FlowspecL3vpnRoute route, final FlowspecL3vpnRouteKey key,
71 final Attributes attributes) {
72 final FlowspecL3vpnRouteBuilder builder;
74 builder = new FlowspecL3vpnRouteBuilder(route);
76 builder = new FlowspecL3vpnRouteBuilder();
78 return builder.withKey(key).setAttributes(attributes).build();
82 public FlowspecL3vpnIpv6Routes emptyRoutesContainer() {
83 return EMPTY_CONTAINER;
87 public PathId extractPathId(final FlowspecL3vpnRouteKey routeListKey) {
88 return routeListKey.getPathId();
92 public String extractRouteKey(final FlowspecL3vpnRouteKey routeListKey) {
93 return routeListKey.getRouteKey();
97 public List<FlowspecL3vpnRoute> extractAdjRibInRoutes(final Routes routes) {
98 verify(routes instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120
99 .bgp.rib.rib.peer.adj.rib.in.tables.routes.FlowspecL3vpnIpv6RoutesCase, "Unrecognized routes %s", routes);
100 return ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120
101 .bgp.rib.rib.peer.adj.rib.in.tables.routes.FlowspecL3vpnIpv6RoutesCase) routes)
102 .getFlowspecL3vpnIpv6Routes().nonnullFlowspecL3vpnRoute();