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;
10 import com.google.common.collect.Iterables;
11 import java.util.Collection;
12 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
13 import org.opendaylight.protocol.bgp.flowspec.AbstractFlowspecRIBSupport;
14 import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.FlowspecL3vpnSubsequentAddressFamily;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher;
22 import org.opendaylight.yangtools.yang.binding.ChildOf;
23 import org.opendaylight.yangtools.yang.binding.DataObject;
24 import org.opendaylight.yangtools.yang.binding.Identifiable;
25 import org.opendaylight.yangtools.yang.binding.Identifier;
26 import org.opendaylight.yangtools.yang.common.QName;
27 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
29 public abstract class AbstractFlowspecL3vpnRIBSupport
30 <T extends AbstractFlowspecL3vpnNlriParser,
31 C extends Routes & DataObject,
32 S extends ChildOf<? super C>,
33 R extends Route & ChildOf<? super S> & Identifiable<I>,
34 I extends Identifier<R>>
35 extends AbstractFlowspecRIBSupport<T, C, S, R, I> {
37 protected AbstractFlowspecL3vpnRIBSupport(
38 final BindingNormalizedNodeSerializer mappingService,
39 final Class<C> cazeClass,
40 final Class<S> containerClass,
41 final Class<R> listClass,
42 final QName dstContainerClassQName,
43 final Class<? extends AddressFamily> afiClass,
44 final T flowspecNlriParser
46 super(mappingService, cazeClass, containerClass, listClass, afiClass,
47 FlowspecL3vpnSubsequentAddressFamily.class, dstContainerClassQName, flowspecNlriParser);
51 protected DestinationType buildDestination(final Collection<MapEntryNode> routes) {
52 final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
53 final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
54 final RouteDistinguisher rd = extractRouteDistinguisher(routesCont);
55 return this.nlriParser.createAdvertizedRoutesDestinationType(
56 new Object[]{rd, this.nlriParser.extractFlowspec(routesCont)},
62 protected DestinationType buildWithdrawnDestination(final Collection<MapEntryNode> routes) {
63 final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
64 final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
65 final RouteDistinguisher rd = extractRouteDistinguisher(routesCont);
66 return this.nlriParser.createWithdrawnDestinationType(
67 new Object[]{rd, this.nlriParser.extractFlowspec(Iterables.getOnlyElement(routes))},