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 static com.google.common.base.Verify.verify;
13 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
14 import org.opendaylight.protocol.bgp.flowspec.FlowspecTypeRegistries.SAFI;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.FlowspecSubsequentAddressFamily;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.rib.loc.rib.tables.routes.FlowspecRoutesCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.ipv4.DestinationFlowspecIpv4;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.ipv4.route.FlowspecRoute;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.ipv4.route.FlowspecRouteBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.ipv4.route.FlowspecRouteKey;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.routes.FlowspecRoutes;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.routes.FlowspecRoutesBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
28 public final class FlowspecIpv4RIBSupport
29 extends AbstractFlowspecRIBSupport<SimpleFlowspecIpv4NlriParser,
34 private static final FlowspecRoutes EMPTY_CONTAINER = new FlowspecRoutesBuilder().build();
36 public FlowspecIpv4RIBSupport(final BindingNormalizedNodeSerializer mappingService) {
39 FlowspecRoutesCase.class,
42 Ipv4AddressFamily.class,
43 FlowspecSubsequentAddressFamily.class,
44 DestinationFlowspecIpv4.QNAME,
45 new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC)
50 public FlowspecRoute createRoute(final FlowspecRoute route, final FlowspecRouteKey key,
51 final Attributes attributes) {
52 final FlowspecRouteBuilder builder;
54 builder = new FlowspecRouteBuilder(route);
56 builder = new FlowspecRouteBuilder();
58 return builder.withKey(key).setAttributes(attributes).build();
62 public FlowspecRoutes emptyRoutesContainer() {
63 return EMPTY_CONTAINER;
67 public FlowspecRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
68 return new FlowspecRouteKey(pathId, routeKey);
72 public PathId extractPathId(final FlowspecRouteKey routeListKey) {
73 return routeListKey.getPathId();
77 public String extractRouteKey(final FlowspecRouteKey routeListKey) {
78 return routeListKey.getRouteKey();
82 public Map<FlowspecRouteKey, FlowspecRoute> extractAdjRibInRoutes(final Routes routes) {
83 verify(routes instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120
84 .bgp.rib.rib.peer.adj.rib.in.tables.routes.FlowspecRoutesCase, "Unrecognized routes %s", routes);
85 return ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120
86 .bgp.rib.rib.peer.adj.rib.in.tables.routes.FlowspecRoutesCase) routes).getFlowspecRoutes()
87 .nonnullFlowspecRoute();