2 * Copyright (c) 2015 Cisco 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;
10 import java.util.Collections;
11 import java.util.List;
12 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.FlowspecSubsequentAddressFamily;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecRoutesCase;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecRoutesCaseBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.ipv4.DestinationFlowspecIpv4;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv4.route.FlowspecRoute;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv4.route.FlowspecRouteBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv4.route.FlowspecRouteKey;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.routes.FlowspecRoutes;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.routes.FlowspecRoutesBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
26 public final class FlowspecIpv4RIBSupport
27 extends AbstractFlowspecRIBSupport<SimpleFlowspecIpv4NlriParser,
32 private static final FlowspecRoutes EMPTY_CONTAINER
33 = new FlowspecRoutesBuilder().setFlowspecRoute(Collections.emptyList()).build();
34 private static final FlowspecRoutesCase EMPTY_CASE
35 = new FlowspecRoutesCaseBuilder().setFlowspecRoutes(EMPTY_CONTAINER).build();
36 private static FlowspecIpv4RIBSupport SINGLETON;
38 private FlowspecIpv4RIBSupport(final SimpleFlowspecExtensionProviderContext context,
39 final BindingNormalizedNodeSerializer mappingService) {
42 FlowspecRoutesCase.class,
45 Ipv4AddressFamily.class,
46 FlowspecSubsequentAddressFamily.class,
47 DestinationFlowspecIpv4.QNAME,
48 new SimpleFlowspecIpv4NlriParser(context
49 .getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
50 SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC))
54 static synchronized FlowspecIpv4RIBSupport getInstance(
55 final SimpleFlowspecExtensionProviderContext context,
56 final BindingNormalizedNodeSerializer mappingService) {
57 if (SINGLETON == null){
58 SINGLETON = new FlowspecIpv4RIBSupport(context, mappingService);
64 public FlowspecRoute createRoute(final FlowspecRoute route, final String routeKey, final long pathId,
65 final Attributes attributes) {
66 final FlowspecRouteBuilder builder;
68 builder = new FlowspecRouteBuilder(route);
70 builder = new FlowspecRouteBuilder();
72 return builder.withKey(new FlowspecRouteKey(new PathId(pathId), routeKey)).setAttributes(attributes).build();
76 public FlowspecRoutesCase emptyRoutesCase() {
81 public FlowspecRoutes emptyRoutesContainer() {
82 return EMPTY_CONTAINER;
86 public FlowspecRouteKey createRouteListKey(final long pathId, final String routeKey) {
87 return new FlowspecRouteKey(new PathId(pathId), routeKey);
91 public List<FlowspecRoute> routesFromContainer(final FlowspecRoutes container) {
92 return container.getFlowspecRoute();