--- /dev/null
+/*
+ * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.flowspec;
+
+import io.netty.buffer.ByteBuf;
+import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.Flowspec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
+
+abstract class AbstractFlowspecIpNlriParser extends AbstractFlowspecNlriParser {
+ AbstractFlowspecIpNlriParser(final FlowspecTypeRegistry flowspecTypeRegistry) {
+ super(flowspecTypeRegistry);
+ }
+
+ @Override
+ protected final DestinationType parseAdvertizedNlri(final ByteBuf nlri, final PathId pathId)
+ throws BGPParsingException {
+ return createAdvertizedRoutesDestinationType(parseNlriFlowspecList(nlri), pathId);
+ }
+
+ abstract @NonNull DestinationType createAdvertizedRoutesDestinationType(List<Flowspec> flowspecList,
+ @Nullable PathId pathId);
+
+ @Override
+ protected final DestinationType parseWithdrawnNlri(final ByteBuf nlri, final PathId pathId)
+ throws BGPParsingException {
+ return createWithdrawnDestinationType(parseNlriFlowspecList(nlri), pathId);
+ }
+
+ abstract @NonNull DestinationType createWithdrawnDestinationType(List<Flowspec> flowspecList,
+ @Nullable PathId pathId);
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.flowspec;
+
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.SubsequentAddressFamily;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+
+abstract class AbstractFlowspecIpRIBSupport<
+ T extends AbstractFlowspecIpNlriParser,
+ C extends Routes & DataObject,
+ S extends ChildOf<? super C>,
+ R extends Route & ChildOf<? super S> & Identifiable<?>> extends AbstractFlowspecRIBSupport<T, C, S, R> {
+ AbstractFlowspecIpRIBSupport(final BindingNormalizedNodeSerializer mappingService, final Class<C> cazeClass,
+ final Class<S> containerClass, final Class<R> listClass, final AddressFamily afiClass,
+ final SubsequentAddressFamily safiClass, final QName dstContainerClassQName, final T nlriParser) {
+ super(mappingService, cazeClass, containerClass, listClass, afiClass, safiClass, dstContainerClassQName,
+ nlriParser);
+ }
+
+ @Override
+ protected final DestinationType buildDestination(final MapEntryNode route, final PathId pathId) {
+ return nlriParser.createAdvertizedRoutesDestinationType(nlriParser.extractFlowspec(route), pathId);
+ }
+
+ @Override
+ protected final DestinationType buildWithdrawnDestination(final MapEntryNode route, final PathId pathId) {
+ return nlriParser.createWithdrawnDestinationType(nlriParser.extractFlowspec(route), pathId);
+ }
+}
protected abstract void stringSpecificFSNlriType(FlowspecType value, StringBuilder buffer);
- /**
- * Create withdrawn destination type.
- *
- * @param nlriFields a list of NLRI fields to be included in the destination type
- * @param pathId associated path id with given NLRI
- * @return created destination type
- */
- public abstract DestinationType createWithdrawnDestinationType(Object @NonNull[] nlriFields,
- @Nullable PathId pathId);
-
- /**
- * Create advertized destination type.
- *
- * @param nlriFields a list of NLRI fields to be included in the destination type
- * @param pathId associated path id with given NLRI
- * @return created destination type
- */
- public abstract DestinationType createAdvertizedRoutesDestinationType(Object @NonNull[] nlriFields,
- @Nullable PathId pathId);
-
@Override
public final void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final AttributesReach pathAttributes1 = pathAttributes.augmentation(AttributesReach.class);
* @param nlri byte representation of NLRI which will be parsed
* @return list of Flowspec
*/
+ // FIXME: throws BGPParsingException
protected final List<Flowspec> parseNlriFlowspecList(final @NonNull ByteBuf nlri) {
if (!nlri.isReadable()) {
return null;
return fss;
}
- /**
- * Override this function to parse additional NLRI fields.
- *
- * @param nlri NLRI buffer
- * @return Parsed additional fields
- */
- protected Object @NonNull[] parseNlri(final @NonNull ByteBuf nlri) throws BGPParsingException {
- return new Object[] {parseNlriFlowspecList(nlri)};
- }
-
@Override
- public final void parseNlri(final @NonNull ByteBuf nlri, final @NonNull MpReachNlriBuilder builder,
+ public final void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder,
final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final PathId pathId = readPathId(nlri, builder.getAfi(), builder.getSafi(), constraint);
- final Object[] nlriFields = parseNlri(nlri);
builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder()
- .setDestinationType(createAdvertizedRoutesDestinationType(nlriFields, pathId))
+ .setDestinationType(parseAdvertizedNlri(nlri, pathId))
.build());
}
@Override
- public final void parseNlri(final @NonNull ByteBuf nlri, final @NonNull MpUnreachNlriBuilder builder,
+ public final void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder,
final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final PathId pathId = readPathId(nlri, builder.getAfi(), builder.getSafi(), constraint);
- final Object[] nlriFields = parseNlri(nlri);
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder()
- .setDestinationType(createWithdrawnDestinationType(nlriFields, pathId))
+ .setDestinationType(parseWithdrawnNlri(nlri, pathId))
.build()
);
}
- protected static @Nullable PathId readPathId(final @NonNull ByteBuf nlri, final AddressFamily afi,
+ /**
+ * Create advertized destination type.
+ *
+ * @param nlri on-wire NLRI, with path ID already peeled
+ * @param pathId associated path id with given NLRI
+ * @return created destination type
+ */
+ protected abstract @NonNull DestinationType parseAdvertizedNlri(@NonNull ByteBuf nlri, @Nullable PathId pathId)
+ throws BGPParsingException;
+
+ /**
+ * Parse and create withdrawn destination type.
+ *
+ * @param nlri on-wire NLRI, with path ID already peeled
+ * @param pathId associated path id with given NLRI
+ * @return created destination type
+ */
+ protected abstract @NonNull DestinationType parseWithdrawnNlri(@NonNull ByteBuf nlri, @Nullable PathId pathId)
+ throws BGPParsingException;
+
+ protected static final @Nullable PathId readPathId(final @NonNull ByteBuf nlri, final AddressFamily afi,
final SubsequentAddressFamily safi, final PeerSpecificParserConstraint constraint) {
if (MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(afi, safi))) {
return PathIdUtil.readPathId(nlri);
import com.google.common.collect.Iterables;
import java.util.Collection;
import java.util.Collections;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
C extends Routes & DataObject,
S extends ChildOf<? super C>,
R extends Route & ChildOf<? super S> & Identifiable<?>> extends AbstractRIBSupport<C, S, R> {
- protected final T nlriParser;
+ protected final @NonNull T nlriParser;
protected AbstractFlowspecRIBSupport(
final BindingNormalizedNodeSerializer mappingService,
}
@Override
- protected DestinationType buildDestination(final Collection<MapEntryNode> routes) {
- final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
- final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
- return nlriParser.createAdvertizedRoutesDestinationType(
- new Object[] {nlriParser.extractFlowspec(routesCont)},
- pathId
- );
+ protected final DestinationType buildDestination(final Collection<MapEntryNode> routes) {
+ final var route = Iterables.getOnlyElement(routes);
+ return buildDestination(route, PathIdUtil.buildPathId(route, routePathIdNid()));
}
+ protected abstract @NonNull DestinationType buildDestination(MapEntryNode route, @Nullable PathId pathId);
+
@Override
- protected DestinationType buildWithdrawnDestination(final Collection<MapEntryNode> routes) {
- final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
- final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
- return nlriParser.createWithdrawnDestinationType(
- new Object[] {nlriParser.extractFlowspec(Iterables.getOnlyElement(routes))},
- pathId
- );
+ protected final DestinationType buildWithdrawnDestination(final Collection<MapEntryNode> routes) {
+ final var route = Iterables.getOnlyElement(routes);
+ return buildWithdrawnDestination(route, PathIdUtil.buildPathId(route, routePathIdNid()));
}
+ protected abstract @NonNull DestinationType buildWithdrawnDestination(MapEntryNode route, @Nullable PathId pathId);
+
@Override
protected final Collection<NodeIdentifierWithPredicates> processDestination(
final DOMDataTreeWriteTransaction tx,
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
public final class FlowspecIpv4RIBSupport
- extends AbstractFlowspecRIBSupport<SimpleFlowspecIpv4NlriParser,
+ extends AbstractFlowspecIpRIBSupport<SimpleFlowspecIpv4NlriParser,
FlowspecRoutesCase,
FlowspecRoutes,
FlowspecRoute> {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily;
public final class FlowspecIpv6RIBSupport
- extends AbstractFlowspecRIBSupport<SimpleFlowspecIpv6NlriParser,
+ extends AbstractFlowspecIpRIBSupport<SimpleFlowspecIpv6NlriParser,
FlowspecIpv6RoutesCase,
FlowspecIpv6Routes,
FlowspecRoute> {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
-public final class SimpleFlowspecIpv4NlriParser extends AbstractFlowspecNlriParser {
+public final class SimpleFlowspecIpv4NlriParser extends AbstractFlowspecIpNlriParser {
public SimpleFlowspecIpv4NlriParser(final SAFI safi) {
super(FlowspecTypeRegistries.getFlowspecTypeRegistry(AFI.IPV4, safi));
}
@Override
- public DestinationType createWithdrawnDestinationType(final Object[] nlriFields, final PathId pathId) {
- final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
+ DestinationType createAdvertizedRoutesDestinationType(final List<Flowspec> flowspecList, final PathId pathId) {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCaseBuilder()
- .setDestinationFlowspecIpv4(
- new DestinationFlowspecIpv4Builder()
- .setFlowspec(flowspecList)
- .setPathId(pathId)
- .build()
- ).build();
+ .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecCaseBuilder()
+ .setDestinationFlowspecIpv4(new DestinationFlowspecIpv4Builder()
+ .setFlowspec(flowspecList)
+ .setPathId(pathId)
+ .build())
+ .build();
}
@Override
- public DestinationType createAdvertizedRoutesDestinationType(final Object[] nlriFields, final PathId pathId) {
- final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
+ DestinationType createWithdrawnDestinationType(final List<Flowspec> flowspecList, final PathId pathId) {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
- .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecCaseBuilder()
- .setDestinationFlowspecIpv4(new DestinationFlowspecIpv4Builder()
- .setFlowspec(flowspecList)
- .setPathId(pathId)
- .build()).build();
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCaseBuilder()
+ .setDestinationFlowspecIpv4(new DestinationFlowspecIpv4Builder()
+ .setFlowspec(flowspecList)
+ .setPathId(pathId)
+ .build())
+ .build();
}
@Override
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
-public final class SimpleFlowspecIpv6NlriParser extends AbstractFlowspecNlriParser {
+public final class SimpleFlowspecIpv6NlriParser extends AbstractFlowspecIpNlriParser {
public SimpleFlowspecIpv6NlriParser(final SAFI safi) {
super(FlowspecTypeRegistries.getFlowspecTypeRegistry(AFI.IPV6, safi));
}
@Override
- public DestinationType createWithdrawnDestinationType(final Object[] nlriFields, final PathId pathId) {
- final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
+ DestinationType createAdvertizedRoutesDestinationType(final List<Flowspec> flowspecList, final PathId pathId) {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6CaseBuilder()
- .setDestinationFlowspecIpv6(
- new DestinationFlowspecIpv6Builder()
- .setFlowspec(flowspecList)
- .setPathId(pathId)
- .build()
- ).build();
+ .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecIpv6CaseBuilder()
+ .setDestinationFlowspecIpv6(new DestinationFlowspecIpv6Builder()
+ .setFlowspec(flowspecList)
+ .setPathId(pathId)
+ .build())
+ .build();
}
@Override
- public DestinationType createAdvertizedRoutesDestinationType(final Object[] nlriFields, final PathId pathId) {
- final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
+ DestinationType createWithdrawnDestinationType(final List<Flowspec> flowspecList, final PathId pathId) {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
- .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecIpv6CaseBuilder()
- .setDestinationFlowspecIpv6(
- new DestinationFlowspecIpv6Builder()
- .setFlowspec(flowspecList)
- .setPathId(pathId)
- .build()
- ).build();
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6CaseBuilder()
+ .setDestinationFlowspecIpv6(new DestinationFlowspecIpv6Builder()
+ .setFlowspec(flowspecList)
+ .setPathId(pathId)
+ .build())
+ .build();
}
@Override
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
import org.opendaylight.protocol.bgp.flowspec.AbstractFlowspecNlriParser;
import org.opendaylight.protocol.bgp.flowspec.FlowspecTypeRegistry;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.Flowspec;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.FlowspecBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RouteDistinguisher;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
}
@Override
- public String stringNlri(final DataContainerNode flowspec) {
+ public final String stringNlri(final DataContainerNode flowspec) {
final StringBuilder buffer = new StringBuilder();
final RouteDistinguisher rd = extractRouteDistinguisher(flowspec, RD_NID);
if (rd != null) {
}
@Override
- protected void serializeNlri(final Object[] nlriFields, final ByteBuf buffer) {
+ protected final void serializeNlri(final Object[] nlriFields, final ByteBuf buffer) {
final RouteDistinguisher rd = requireNonNull((RouteDistinguisher) nlriFields[0]);
RouteDistinguisherUtil.serializeRouteDistinquisher(rd, buffer);
final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
}
@Override
- protected Object[] parseNlri(final ByteBuf nlri) {
+ protected final DestinationType parseAdvertizedNlri(final ByteBuf nlri, final PathId pathId)
+ throws BGPParsingException {
readNlriLength(nlri);
- return new Object[] {
- requireNonNull(readRouteDistinguisher(nlri)),
- parseL3vpnNlriFlowspecList(nlri)
- };
+ return createAdvertizedRoutesDestinationType(requireNonNull(readRouteDistinguisher(nlri)),
+ parseL3vpnNlriFlowspecList(nlri), pathId);
}
- protected final List<Flowspec> parseL3vpnNlriFlowspecList(final ByteBuf nlri) {
+ /**
+ * Create advertized destination type.
+ *
+ * @param rd the RouteDistinguisher
+ * @param flowspecList a list of {@link Flowspec}s
+ * @param pathId associated path id with given destination
+ * @return created destination type
+ */
+ protected abstract @NonNull DestinationType createAdvertizedRoutesDestinationType(RouteDistinguisher rd,
+ @Nullable List<Flowspec> flowspecList, @Nullable PathId pathId);
+
+ @Override
+ protected final DestinationType parseWithdrawnNlri(final ByteBuf nlri, final PathId pathId)
+ throws BGPParsingException {
+ readNlriLength(nlri);
+ return createWithdrawnDestinationType(requireNonNull(readRouteDistinguisher(nlri)),
+ parseL3vpnNlriFlowspecList(nlri), pathId);
+ }
+
+ /**
+ * Create withdrawn destination type.
+ *
+ * @param rd the RouteDistinguisher
+ * @param flowspecList a list of {@link Flowspec}s
+ * @param pathId associated path id with given destination
+ * @return created destination type
+ */
+ protected abstract @NonNull DestinationType createWithdrawnDestinationType(RouteDistinguisher rd,
+ @Nullable List<Flowspec> flowspecList, @Nullable PathId pathId);
+
+ private @Nullable List<Flowspec> parseL3vpnNlriFlowspecList(final ByteBuf nlri) {
if (!nlri.isReadable()) {
return null;
}
- final List<Flowspec> fss = new ArrayList<>();
+ final var fss = new ArrayList<Flowspec>();
while (nlri.isReadable()) {
- final FlowspecBuilder builder = new FlowspecBuilder();
- builder.setFlowspecType(flowspecTypeRegistry.parseFlowspecType(nlri));
- fss.add(builder.build());
+ fss.add(new FlowspecBuilder().setFlowspecType(flowspecTypeRegistry.parseFlowspecType(nlri)).build());
}
-
return fss;
}
}
*/
package org.opendaylight.protocol.bgp.flowspec.l3vpn;
-import com.google.common.collect.Iterables;
-import java.util.Collection;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.flowspec.AbstractFlowspecRIBSupport;
-import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.FlowspecL3vpnSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RouteDistinguisher;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-public abstract class AbstractFlowspecL3vpnRIBSupport
- <T extends AbstractFlowspecL3vpnNlriParser,
- C extends Routes & DataObject,
- S extends ChildOf<? super C>,
- R extends Route & ChildOf<? super S> & Identifiable<?>>
- extends AbstractFlowspecRIBSupport<T, C, S, R> {
-
+public abstract class AbstractFlowspecL3vpnRIBSupport<
+ T extends AbstractFlowspecL3vpnNlriParser,
+ C extends Routes & DataObject,
+ S extends ChildOf<? super C>,
+ R extends Route & ChildOf<? super S> & Identifiable<?>> extends AbstractFlowspecRIBSupport<T, C, S, R> {
protected AbstractFlowspecL3vpnRIBSupport(
final BindingNormalizedNodeSerializer mappingService,
final Class<C> cazeClass,
}
@Override
- protected DestinationType buildDestination(final Collection<MapEntryNode> routes) {
- final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
- final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
- final RouteDistinguisher rd = extractRouteDistinguisher(routesCont);
- return this.nlriParser.createAdvertizedRoutesDestinationType(
- new Object[]{rd, this.nlriParser.extractFlowspec(routesCont)},
- pathId
- );
+ protected final DestinationType buildDestination(final MapEntryNode route, final PathId pathId) {
+ return nlriParser.createAdvertizedRoutesDestinationType(extractRouteDistinguisher(route),
+ nlriParser.extractFlowspec(route), pathId);
}
@Override
- protected DestinationType buildWithdrawnDestination(final Collection<MapEntryNode> routes) {
- final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
- final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
- final RouteDistinguisher rd = extractRouteDistinguisher(routesCont);
- return this.nlriParser.createWithdrawnDestinationType(
- new Object[]{rd, this.nlriParser.extractFlowspec(Iterables.getOnlyElement(routes))},
- pathId
- );
+ protected final DestinationType buildWithdrawnDestination(final MapEntryNode route, final PathId pathId) {
+ return nlriParser.createWithdrawnDestinationType(extractRouteDistinguisher(route),
+ nlriParser.extractFlowspec(route), pathId);
}
}
}
@Override
- public DestinationType createWithdrawnDestinationType(final Object[] nlriFields, final PathId pathId) {
- final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
- final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
+ protected DestinationType createAdvertizedRoutesDestinationType(final RouteDistinguisher rd,
+ final List<Flowspec> flowspecList, final PathId pathId) {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv4CaseBuilder()
- .setDestinationFlowspecL3vpnIpv4(new DestinationFlowspecL3vpnIpv4Builder()
- .setRouteDistinguisher(rd)
- .setFlowspec(flowspecList)
- .setPathId(pathId)
- .build()).build();
+ .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv4CaseBuilder()
+ .setDestinationFlowspecL3vpnIpv4(new DestinationFlowspecL3vpnIpv4Builder()
+ .setRouteDistinguisher(rd)
+ .setFlowspec(flowspecList)
+ .setPathId(pathId)
+ .build()).build();
}
@Override
- public DestinationType createAdvertizedRoutesDestinationType(final Object[] nlriFields, final PathId pathId) {
- final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
- final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
+ protected DestinationType createWithdrawnDestinationType(final RouteDistinguisher rd,
+ final List<Flowspec> flowspecList, final PathId pathId) {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
- .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv4CaseBuilder()
- .setDestinationFlowspecL3vpnIpv4(new DestinationFlowspecL3vpnIpv4Builder()
- .setRouteDistinguisher(rd)
- .setFlowspec(flowspecList)
- .setPathId(pathId)
- .build()).build();
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv4CaseBuilder()
+ .setDestinationFlowspecL3vpnIpv4(new DestinationFlowspecL3vpnIpv4Builder()
+ .setRouteDistinguisher(rd)
+ .setFlowspec(flowspecList)
+ .setPathId(pathId)
+ .build())
+ .build();
}
@Override
}
@Override
- public DestinationType createWithdrawnDestinationType(final Object[] nlriFields, final PathId pathId) {
- final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
- final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
+ protected DestinationType createAdvertizedRoutesDestinationType(final RouteDistinguisher rd,
+ final List<Flowspec> flowspecList, final PathId pathId) {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder()
- .setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder()
- .setRouteDistinguisher(rd)
- .setFlowspec(flowspecList)
- .setPathId(pathId)
- .build()).build();
+ .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder()
+ .setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder()
+ .setRouteDistinguisher(rd)
+ .setFlowspec(flowspecList)
+ .setPathId(pathId)
+ .build())
+ .build();
}
@Override
- public DestinationType createAdvertizedRoutesDestinationType(final Object[] nlriFields, final PathId pathId) {
- final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
- final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
+ protected DestinationType createWithdrawnDestinationType(final RouteDistinguisher rd,
+ final List<Flowspec> flowspecList, final PathId pathId) {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
- .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder()
- .setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder()
- .setRouteDistinguisher(rd)
- .setFlowspec(flowspecList)
- .setPathId(pathId)
- .build()).build();
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder()
+ .setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder()
+ .setRouteDistinguisher(rd)
+ .setFlowspec(flowspecList)
+ .setPathId(pathId)
+ .build())
+ .build();
}
@Override