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.ipv4;
10 import java.util.Collections;
11 import java.util.List;
12 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
13 import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
14 import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv4RoutesCase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv4RoutesCaseBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRoute;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRouteBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRouteKey;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.routes.FlowspecL3vpnIpv4Routes;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.routes.FlowspecL3vpnIpv4RoutesBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
27 public final class FlowspecL3vpnIpv4RIBSupport
28 extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv4NlriParser,
29 FlowspecL3vpnIpv4RoutesCase,
30 FlowspecL3vpnIpv4Routes,
32 FlowspecL3vpnRouteKey> {
33 private static final FlowspecL3vpnIpv4Routes EMPTY_CONTAINER
34 = new FlowspecL3vpnIpv4RoutesBuilder().setFlowspecL3vpnRoute(Collections.emptyList()).build();
35 private static final FlowspecL3vpnIpv4RoutesCase EMPTY_CASE = new FlowspecL3vpnIpv4RoutesCaseBuilder()
36 .setFlowspecL3vpnIpv4Routes(EMPTY_CONTAINER).build();
37 private static FlowspecL3vpnIpv4RIBSupport SINGLETON;
39 private FlowspecL3vpnIpv4RIBSupport(
40 final SimpleFlowspecExtensionProviderContext context,
41 final BindingNormalizedNodeSerializer mappingService) {
44 FlowspecL3vpnIpv4RoutesCase.class,
45 FlowspecL3vpnIpv4Routes.class,
46 FlowspecL3vpnRoute.class,
47 DestinationFlowspecL3vpnIpv4.QNAME,
48 Ipv4AddressFamily.class,
49 new FlowspecL3vpnIpv4NlriParser(context
50 .getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
51 SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
55 public static synchronized FlowspecL3vpnIpv4RIBSupport getInstance(
56 final SimpleFlowspecExtensionProviderContext context,
57 final BindingNormalizedNodeSerializer mappingService) {
58 if(SINGLETON == null){
59 SINGLETON = new FlowspecL3vpnIpv4RIBSupport(context, mappingService);
65 public FlowspecL3vpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
66 return new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey);
70 public FlowspecL3vpnRoute createRoute(final FlowspecL3vpnRoute route, final String routeKey,
71 final long pathId, final Attributes attributes) {
72 final FlowspecL3vpnRouteBuilder builder;
74 builder = new FlowspecL3vpnRouteBuilder(route);
76 builder = new FlowspecL3vpnRouteBuilder();
78 return builder.withKey(new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey))
79 .setAttributes(attributes).build();
83 public FlowspecL3vpnIpv4RoutesCase emptyRoutesCase() {
88 public FlowspecL3vpnIpv4Routes emptyRoutesContainer() {
89 return EMPTY_CONTAINER;
93 public List<FlowspecL3vpnRoute> routesFromContainer(final FlowspecL3vpnIpv4Routes container) {
94 return container.getFlowspecL3vpnRoute();