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.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRoute;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteKey;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6Routes;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6RoutesBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
30 public final class FlowspecL3vpnIpv6RIBSupport
31 extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv6NlriParser,
32 FlowspecL3vpnIpv6RoutesCase,
33 FlowspecL3vpnIpv6Routes,
35 FlowspecL3vpnRouteKey> {
36 private static final FlowspecL3vpnIpv6Routes EMPTY_CONTAINER
37 = new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(Collections.emptyList()).build();
38 private static final FlowspecL3vpnIpv6RoutesCase EMPTY_CASE = new FlowspecL3vpnIpv6RoutesCaseBuilder()
39 .setFlowspecL3vpnIpv6Routes(EMPTY_CONTAINER).build();
40 private static FlowspecL3vpnIpv6RIBSupport SINGLETON;
42 private FlowspecL3vpnIpv6RIBSupport(
43 final SimpleFlowspecExtensionProviderContext context,
44 final BindingNormalizedNodeSerializer mappingService) {
47 FlowspecL3vpnIpv6RoutesCase.class,
48 FlowspecL3vpnIpv6Routes.class,
49 FlowspecL3vpnRoute.class,
50 DestinationFlowspecL3vpnIpv6.QNAME,
51 Ipv6AddressFamily.class,
52 new FlowspecL3vpnIpv6NlriParser(context
53 .getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6,
54 SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
58 public static synchronized FlowspecL3vpnIpv6RIBSupport getInstance(
59 final SimpleFlowspecExtensionProviderContext context,
60 final BindingNormalizedNodeSerializer mappingService) {
61 if (SINGLETON == null) {
62 SINGLETON = new FlowspecL3vpnIpv6RIBSupport(context, mappingService);
68 public FlowspecL3vpnRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
69 return new FlowspecL3vpnRouteKey(pathId, routeKey);
73 public FlowspecL3vpnRoute createRoute(final FlowspecL3vpnRoute route, final FlowspecL3vpnRouteKey key,
74 final Attributes attributes) {
75 final FlowspecL3vpnRouteBuilder builder;
77 builder = new FlowspecL3vpnRouteBuilder(route);
79 builder = new FlowspecL3vpnRouteBuilder();
81 return builder.withKey(key).setAttributes(attributes).build();
85 public FlowspecL3vpnIpv6Routes emptyRoutesContainer() {
86 return EMPTY_CONTAINER;
90 public PathId extractPathId(final FlowspecL3vpnRouteKey routeListKey) {
91 return routeListKey.getPathId();
95 public String extractRouteKey(final FlowspecL3vpnRouteKey routeListKey) {
96 return routeListKey.getRouteKey();
100 public List<FlowspecL3vpnRoute> extractAdjRibInRoutes(final Routes routes) {
101 verify(routes instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
102 .bgp.rib.rib.peer.adj.rib.in.tables.routes.FlowspecL3vpnIpv6RoutesCase, "Unrecognized routes %s", routes);
103 return ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
104 .bgp.rib.rib.peer.adj.rib.in.tables.routes.FlowspecL3vpnIpv6RoutesCase) routes)
105 .getFlowspecL3vpnIpv6Routes().nonnullFlowspecL3vpnRoute();