</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <failOnError>true</failOnError>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
import org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop;
-/**
- * @author Kevin Wang
- */
public abstract class AbstractVpnNextHopParserSerializer implements NextHopParserSerializer {
private final int ipAddrLength;
private final Class<?> ipNextHopCaseClazz;
@Override
public CNextHop parseNextHop(final ByteBuf buffer) throws BGPParsingException {
- Preconditions.checkArgument(buffer.readableBytes() == (this.ipAddrLength + RouteDistinguisherUtil.RD_LENGTH), "Length of byte array for NEXT_HOP should be %s, but is %s", this.ipAddrLength + RouteDistinguisherUtil.RD_LENGTH, buffer.readableBytes());
+ Preconditions.checkArgument(buffer.readableBytes() == (this.ipAddrLength + RouteDistinguisherUtil.RD_LENGTH),
+ "Length of byte array for NEXT_HOP should be %s, but is %s",
+ this.ipAddrLength + RouteDistinguisherUtil.RD_LENGTH, buffer.readableBytes());
buffer.readBytes(RouteDistinguisherUtil.RD_LENGTH);
return NextHopUtil.parseNextHop(buffer.readBytes(this.ipAddrLength));
}
@Override
- public void serializeNextHop(final CNextHop cNextHop, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(this.ipNextHopCaseClazz.isInstance(cNextHop), "cNextHop is not a VPN %s NextHop object.", this.ipNextHopCaseClazz.getSimpleName());
+ public void serializeNextHop(final CNextHop nextHop, final ByteBuf byteAggregator) {
+ Preconditions.checkArgument(this.ipNextHopCaseClazz.isInstance(nextHop),
+ "cNextHop is not a VPN %s NextHop object.", this.ipNextHopCaseClazz.getSimpleName());
byteAggregator.writeZero(RouteDistinguisherUtil.RD_LENGTH);
- NextHopUtil.serializeNextHop(cNextHop, byteAggregator);
+ NextHopUtil.serializeNextHop(nextHop, byteAggregator);
}
}
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.ArrayList;
import java.util.List;
import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
import org.opendaylight.protocol.bgp.labeled.unicast.LUNlriParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlriBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestinationBuilder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
protected abstract AdvertizedRoutes getAdvertizedRoutesByDestination(List<VpnDestination> dst);
- private static void serializeNlri(final List<VpnDestination> dests, final boolean isWithdrawnRoute, final ByteBuf buffer) {
+ private static void serializeNlri(final List<VpnDestination> dests,
+ final boolean isWithdrawnRoute, final ByteBuf buffer) {
final ByteBuf nlriByteBuf = Unpooled.buffer();
for (final VpnDestination dest : dests) {
final List<LabelStack> labelStack = dest.getLabelStack();
AbstractVpnNlriParser.serializeLengtField(prefix, labelStack, nlriByteBuf);
LUNlriParser.serializeLabelStackEntries(labelStack, isWithdrawnRoute, nlriByteBuf);
RouteDistinguisherUtil.serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriByteBuf);
- Preconditions.checkArgument(prefix.getIpv6Prefix() != null || prefix.getIpv4Prefix() != null, "Ipv6 or Ipv4 prefix is missing.");
+ Preconditions.checkArgument(prefix.getIpv6Prefix() != null || prefix.getIpv4Prefix() != null,
+ "Ipv6 or Ipv4 prefix is missing.");
LUNlriParser.serializePrefixField(prefix, nlriByteBuf);
}
buffer.writeBytes(nlriByteBuf);
}
/**
- * Serialize the length field Length field contains one Byte which represents the length of label stack and prefix in bits
- * @param prefix ipPrefix
- * @param labelStack list of labelStack
+ * Serialize the length field Length field contains one Byte which represents the length of label stack and prefix
+ * in bits.
+ *
+ * @param prefix ipPrefix
+ * @param labelStack list of labelStack
* @param nlriByteBuf ByteBuf
*/
- static void serializeLengtField(final IpPrefix prefix, final List<LabelStack> labelStack, final ByteBuf nlriByteBuf) {
+ static void serializeLengtField(final IpPrefix prefix, final List<LabelStack> labelStack,
+ final ByteBuf nlriByteBuf) {
final int prefixLenght = LUNlriParser.getPrefixLength(prefix);
int labelStackLenght = 0;
- if(labelStack != null) {
+ if (labelStack != null) {
labelStackLenght = LUNlriParser.LABEL_LENGTH * labelStack.size();
}
nlriByteBuf.writeByte((labelStackLenght + prefixLenght + RouteDistinguisherUtil.RD_LENGTH) * Byte.SIZE);
}
-
- private static List<VpnDestination> parseNlri(final ByteBuf nlri, final Class<? extends AddressFamily> afi) {
- if (!nlri.isReadable()) {
- return null;
- }
- final List<VpnDestination> dests = new ArrayList<>();
-
- while (nlri.isReadable()) {
- final VpnDestinationBuilder builder = new VpnDestinationBuilder();
- final short length = nlri.readUnsignedByte();
- final List<LabelStack> labels = LUNlriParser.parseLabel(nlri);
- builder.setLabelStack(labels);
- final int labelNum = labels != null ? labels.size() : 1;
- final int prefixLen = length - (LUNlriParser.LABEL_LENGTH * Byte.SIZE * labelNum) - (RouteDistinguisherUtil.RD_LENGTH * Byte.SIZE);
- builder.setRouteDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(nlri));
- Preconditions.checkState(prefixLen > 0, "A valid VPN IP prefix is required.");
- builder.setPrefix(LUNlriParser.parseIpPrefix(nlri, prefixLen, afi));
- dests.add(builder.build());
- }
- return dests;
- }
-
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a Attributes object");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a Attributes object");
final Attributes pathAttributes = (Attributes) attribute;
final Attributes1 pathAttributes1 = pathAttributes.getAugmentation(Attributes1.class);
final Attributes2 pathAttributes2 = pathAttributes.getAugmentation(Attributes2.class);
if (!nlri.isReadable()) {
return;
}
- final List<VpnDestination> dst = parseNlri(nlri, builder.getAfi());
+ final List<VpnDestination> dst = VpnDestinationUtil.parseNlri(nlri, builder.getAfi());
builder.setWithdrawnRoutes(getWithdrawnRoutesByDestination(dst));
}
if (!nlri.isReadable()) {
return;
}
- final List<VpnDestination> dst = parseNlri(nlri, builder.getAfi());
+ final List<VpnDestination> dst = VpnDestinationUtil.parseNlri(nlri, builder.getAfi());
builder.setAdvertizedRoutes(getAdvertizedRoutesByDestination(dst));
}
}
* @param containerClass Binding class of the container in routes choice, must not be null.
* @param listClass Binding class of the route list, nust not be null;
*/
- protected AbstractVpnRIBSupport(final Class<? extends Routes> cazeClass, final Class<? extends DataObject> containerClass, final Class<? extends Route> listClass,
+ protected AbstractVpnRIBSupport(final Class<? extends Routes> cazeClass,
+ final Class<? extends DataObject> containerClass, final Class<? extends Route> listClass,
final Class<? extends AddressFamily> afiClass, final QName vpnDstContainerClassQname) {
- super(cazeClass, containerClass, listClass, afiClass, MplsLabeledVpnSubsequentAddressFamily.class, vpnDstContainerClassQname);
+ super(cazeClass, containerClass, listClass, afiClass,
+ MplsLabeledVpnSubsequentAddressFamily.class, vpnDstContainerClassQname);
final QName classQname = BindingReflections.findQName(containerClass).intern();
this.routeKey = QName.create(routeQName(), "route-key").intern();
final QName vpnDstClassQname = QName.create(classQname, VpnDestination.QNAME.getLocalName());
return dst;
}
- protected abstract IpPrefix extractPrefix(final DataContainerNode<? extends PathArgument> route, final NodeIdentifier prefixTypeNid);
+ protected abstract IpPrefix extractPrefix(DataContainerNode<? extends PathArgument> route,
+ NodeIdentifier prefixTypeNid);
- private RouteDistinguisher extractRouteDistinguisher(final DataContainerNode<? extends YangInstanceIdentifier.PathArgument> route) {
+ private RouteDistinguisher extractRouteDistinguisher(
+ final DataContainerNode<? extends YangInstanceIdentifier.PathArgument> route) {
if (route.getChild(this.rdNid).isPresent()) {
return RouteDistinguisherBuilder.getDefaultInstance((String) route.getChild(this.rdNid).get().getValue());
}
@Override
protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath,
- final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) {
+ final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) {
if (destination != null) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes = destination.getChild(this.nlriRoutesListNid);
+ final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes =
+ destination.getChild(this.nlriRoutesListNid);
if (maybeRoutes.isPresent()) {
final DataContainerChild<? extends PathArgument, ?> routes = maybeRoutes.get();
if (routes instanceof UnkeyedListNode) {
LOG.debug("Serializing Nlri: VpnDestination={}, IpPrefix={}", dest, prefix);
AbstractVpnNlriParser.serializeLengtField(prefix, null, nlriByteBuf);
RouteDistinguisherUtil.serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriByteBuf);
- Preconditions.checkArgument(prefix.getIpv6Prefix() != null || prefix.getIpv4Prefix() != null, "Ipv6 or Ipv4 prefix is missing.");
+ Preconditions.checkArgument(prefix.getIpv6Prefix() != null || prefix.getIpv4Prefix() != null,
+ "Ipv6 or Ipv4 prefix is missing.");
LUNlriParser.serializePrefixField(prefix, nlriByteBuf);
}
buffer.writeBytes(nlriByteBuf);
public final class TableTypeActivator extends AbstractBGPTableTypeRegistryProviderActivator {
@Override
- protected List<AbstractRegistration> startBGPTableTypeRegistryProviderImpl(final BGPTableTypeRegistryProvider provider) {
+ protected List<AbstractRegistration> startBGPTableTypeRegistryProviderImpl(
+ final BGPTableTypeRegistryProvider provider) {
return Lists.newArrayList(
- provider.registerBGPTableType(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class, L3VPNIPV4UNICAST.class),
- provider.registerBGPTableType(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class, L3VPNIPV6UNICAST.class));
+ provider.registerBGPTableType(Ipv4AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class, L3VPNIPV4UNICAST.class),
+ provider.registerBGPTableType(Ipv6AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class, L3VPNIPV6UNICAST.class));
}
}
--- /dev/null
+/*
+ * Copyright (c) 2017 AT&T Intellectual Property. 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.l3vpn;
+
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
+import org.opendaylight.protocol.bgp.labeled.unicast.LUNlriParser;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStack;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestinationBuilder;
+
+final class VpnDestinationUtil {
+ private VpnDestinationUtil() {
+ throw new UnsupportedOperationException();
+ }
+
+ static List<VpnDestination> parseNlri(final ByteBuf nlri, final Class<? extends AddressFamily> afi) {
+ if (!nlri.isReadable()) {
+ return null;
+ }
+ final List<VpnDestination> dests = new ArrayList<>();
+
+ while (nlri.isReadable()) {
+ final VpnDestinationBuilder builder = new VpnDestinationBuilder();
+ final short length = nlri.readUnsignedByte();
+ final List<LabelStack> labels = LUNlriParser.parseLabel(nlri);
+ builder.setLabelStack(labels);
+ final int labelNum = labels != null ? labels.size() : 1;
+ final int prefixLen = length - (LUNlriParser.LABEL_LENGTH * Byte.SIZE * labelNum)
+ - (RouteDistinguisherUtil.RD_LENGTH * Byte.SIZE);
+ builder.setRouteDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(nlri));
+ Preconditions.checkState(prefixLen > 0, "A valid VPN IP prefix is required.");
+ builder.setPrefix(LUNlriParser.parseIpPrefix(nlri, prefixLen, afi));
+ dests.add(builder.build());
+ }
+ return dests;
+ }
+}
@Override
protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
final List<AutoCloseable> regs = new ArrayList<>();
- regs.add(context.registerRIBSupport(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class, new VpnIpv4RIBSupport()));
+ regs.add(context.registerRIBSupport(Ipv4AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class, new VpnIpv4RIBSupport()));
return regs;
}
final class VpnIpv4NlriParser extends AbstractVpnNlriParser {
- private <T extends L3vpnIpv4Destination> List<VpnDestination> getVpnDestination(DestinationType dst, Class<T> dstTypeCaseClazz) {
+ private <T extends L3vpnIpv4Destination> List<VpnDestination> getVpnDestination(DestinationType dst,
+ Class<T> dstTypeCaseClazz) {
if (dstTypeCaseClazz.isInstance(dst)) {
return dstTypeCaseClazz.cast(dst).getVpnIpv4Destination().getVpnDestination();
} else {
@Override
protected List<VpnDestination> getWithdrawnVpnDestination(DestinationType dstType) {
- return getVpnDestination(dstType, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4Case.class);
+ return getVpnDestination(dstType, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4
+ .rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationVpnIpv4Case.class);
}
@Override
protected List<VpnDestination> getAdvertizedVpnDestination(DestinationType dstType) {
- return getVpnDestination(dstType, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4Case.class);
+ return getVpnDestination(dstType, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4
+ .rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type
+ .DestinationVpnIpv4Case.class);
}
@Override
protected WithdrawnRoutes getWithdrawnRoutesByDestination(List<VpnDestination> dst) {
return new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(
- new VpnIpv4DestinationBuilder().setVpnDestination(dst).build()
- ).build()
- ).build();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
+ .setVpnIpv4Destination(new VpnIpv4DestinationBuilder()
+ .setVpnDestination(dst).build()).build()).build();
}
@Override
protected AdvertizedRoutes getAdvertizedRoutesByDestination(List<VpnDestination> dst) {
return new AdvertizedRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(
- new VpnIpv4DestinationBuilder().setVpnDestination(dst).build()
- ).build()
- ).build();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update
+ .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder()
+ .setVpnIpv4Destination(new VpnIpv4DestinationBuilder()
+ .setVpnDestination(dst).build()).build()).build();
}
}
* the same model which populates it with route grouping instantiation, and by extension with
* the route attributes container.
*/
- public VpnIpv4RIBSupport() {
- super(VpnIpv4RoutesCase.class, VpnIpv4Routes.class, VpnRoute.class, Ipv4AddressFamily.class, VpnIpv4Destination.QNAME);
+ VpnIpv4RIBSupport() {
+ super(VpnIpv4RoutesCase.class, VpnIpv4Routes.class, VpnRoute.class,
+ Ipv4AddressFamily.class, VpnIpv4Destination.QNAME);
}
@Override
- protected IpPrefix extractPrefix(final DataContainerNode<? extends YangInstanceIdentifier.PathArgument> route, final YangInstanceIdentifier.NodeIdentifier prefixTypeNid) {
+ protected IpPrefix extractPrefix(final DataContainerNode<? extends YangInstanceIdentifier.PathArgument> route,
+ final YangInstanceIdentifier.NodeIdentifier prefixTypeNid) {
if (route.getChild(prefixTypeNid).isPresent()) {
final String prefixType = (String) route.getChild(prefixTypeNid).get().getValue();
return new IpPrefix(new Ipv4Prefix(prefixType));
@Override
protected DestinationType getAdvertisedDestinationType(List<VpnDestination> dests) {
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(
- new VpnIpv4DestinationBuilder().setVpnDestination(dests).build()
- ).build();
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update
+ .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder()
+ .setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(dests).build()).build();
}
@Override
protected DestinationType getWithdrawnDestinationType(List<VpnDestination> dests) {
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(
- new VpnIpv4DestinationBuilder().setVpnDestination(dests).build()
- ).build();
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
+ .setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(dests).build()).build();
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.l3vpn.ipv6.routes.VpnIpv6Routes;
-/**
- * @author Kevin Wang
- */
public final class BgpIpv6Activator extends AbstractBGPExtensionProviderActivator {
@Override
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
-/**
- * @author Kevin Wang
- */
public class RibIpv6Activator extends AbstractRIBExtensionProviderActivator {
@Override
protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
final List<AutoCloseable> regs = new ArrayList<>();
- regs.add(context.registerRIBSupport(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class, new VpnIpv6RIBSupport()));
+ regs.add(context.registerRIBSupport(Ipv6AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class, new VpnIpv6RIBSupport()));
return regs;
}
import org.opendaylight.protocol.util.Ipv6Util;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCase;
-/**
- * @author Kevin Wang
- */
public final class VpnIpv6NextHopParserSerializer extends AbstractVpnNextHopParserSerializer {
public VpnIpv6NextHopParserSerializer() {
super(Ipv6Util.IPV6_LENGTH, Ipv6NextHopCase.class);
class VpnIpv6NlriParser extends AbstractVpnNlriParser {
- private <T extends L3vpnIpv6Destination> List<VpnDestination> getVpnDestination(DestinationType dst, Class<T> dstTypeCaseClazz) {
+ private <T extends L3vpnIpv6Destination> List<VpnDestination> getVpnDestination(DestinationType dst,
+ Class<T> dstTypeCaseClazz) {
if (dstTypeCaseClazz.isInstance(dst)) {
return dstTypeCaseClazz.cast(dst).getVpnIpv6Destination().getVpnDestination();
} else {
@Override
protected List<VpnDestination> getWithdrawnVpnDestination(DestinationType dstType) {
- return getVpnDestination(
- dstType,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6Case.class);
+ return getVpnDestination(dstType,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes
+ .mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6Case.class);
}
@Override
protected List<VpnDestination> getAdvertizedVpnDestination(DestinationType dstType) {
return getVpnDestination(
dstType,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6Case.class
- );
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes
+ .mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6Case.class);
}
@Override
protected WithdrawnRoutes getWithdrawnRoutesByDestination(List<VpnDestination> dst) {
return new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(
- new VpnIpv6DestinationBuilder().setVpnDestination(dst).build()
- ).build()
- ).build();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
+ .setVpnIpv6Destination(new VpnIpv6DestinationBuilder()
+ .setVpnDestination(dst).build()).build()).build();
}
@Override
protected AdvertizedRoutes getAdvertizedRoutesByDestination(List<VpnDestination> dst) {
return new AdvertizedRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(
- new VpnIpv6DestinationBuilder().setVpnDestination(dst).build()
- ).build()
- ).build();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update
+ .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder()
+ .setVpnIpv6Destination(new VpnIpv6DestinationBuilder()
+ .setVpnDestination(dst).build()).build()).build();
}
}
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
-/**
- * @author Kevin Wang
- */
final class VpnIpv6RIBSupport extends AbstractVpnRIBSupport {
/**
* the same model which populates it with route grouping instantiation, and by extension with
* the route attributes container.
*/
- public VpnIpv6RIBSupport() {
- super(VpnIpv6RoutesCase.class, VpnIpv6Routes.class, VpnRoute.class, Ipv6AddressFamily.class, VpnIpv6Destination.QNAME);
+ VpnIpv6RIBSupport() {
+ super(VpnIpv6RoutesCase.class, VpnIpv6Routes.class, VpnRoute.class,
+ Ipv6AddressFamily.class, VpnIpv6Destination.QNAME);
}
@Override
- protected IpPrefix extractPrefix(final DataContainerNode<? extends YangInstanceIdentifier.PathArgument> route, final YangInstanceIdentifier.NodeIdentifier prefixTypeNid) {
+ protected IpPrefix extractPrefix(final DataContainerNode<? extends YangInstanceIdentifier.PathArgument> route,
+ final YangInstanceIdentifier.NodeIdentifier prefixTypeNid) {
if (route.getChild(prefixTypeNid).isPresent()) {
final String prefixType = (String) route.getChild(prefixTypeNid).get().getValue();
return new IpPrefix(new Ipv6Prefix(prefixType));
@Override
protected DestinationType getAdvertisedDestinationType(List<VpnDestination> dests) {
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(
- new VpnIpv6DestinationBuilder().setVpnDestination(dests).build()).build();
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update
+ .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder()
+ .setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(dests).build()).build();
}
@Override
protected DestinationType getWithdrawnDestinationType(List<VpnDestination> dests) {
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(
- new VpnIpv6DestinationBuilder().setVpnDestination(dests).build()).build();
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
+ .setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(dests).build()).build();
}
}
public class TableTypeActivatorTest {
- private static final BgpTableType IPV4 = new BgpTableTypeImpl(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
- private static final BgpTableType IPV6 = new BgpTableTypeImpl(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
+ private static final BgpTableType IPV4 = new BgpTableTypeImpl(Ipv4AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class);
+ private static final BgpTableType IPV6 = new BgpTableTypeImpl(Ipv6AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class);
@Test
public void testActivator() {
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Test;
final ByteBuf buffer = Unpooled.buffer();
final byte[] nextHop = {0, 0, 0, 0, 0, 0, 0, 0, 42, 42, 42, 42};
final CNextHop hop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
- .setGlobal(new Ipv4Address("42.42.42.42")).build()).build();
+ .setGlobal(new Ipv4Address("42.42.42.42")).build()).build();
HANDLER.serializeNextHop(hop, buffer);
assertArrayEquals(nextHop, ByteArray.readAllBytes(buffer));
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.Collections;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
(byte) 0x22, (byte) 0x01, (byte) 0x16,
};
- static final IpPrefix IPv4_PREFIX = new IpPrefix(new Ipv4Prefix("34.1.22.0/24"));
+ static final IpPrefix IPV4_PREFIX = new IpPrefix(new Ipv4Prefix("34.1.22.0/24"));
static final List<LabelStack> LABEL_STACK = Lists.newArrayList(
new LabelStackBuilder().setLabelValue(new MplsLabel(355L)).build());
- static final RouteDistinguisher DISTINGUISHER = RouteDistinguisherBuilder.getDefaultInstance("1.2.3.4:258");
- static final VpnDestination IPV4_VPN = new VpnDestinationBuilder().setRouteDistinguisher(DISTINGUISHER).setPrefix(IPv4_PREFIX).setLabelStack(LABEL_STACK).build();
- private static final VpnDestination IPV4_VPN_WITHOUT_LABELS = new VpnDestinationBuilder().setRouteDistinguisher(DISTINGUISHER).setPrefix(IPv4_PREFIX).build();
+ static final RouteDistinguisher DISTINGUISHER = RouteDistinguisherBuilder
+ .getDefaultInstance("1.2.3.4:258");
+ static final VpnDestination IPV4_VPN = new VpnDestinationBuilder().setRouteDistinguisher(DISTINGUISHER)
+ .setPrefix(IPV4_PREFIX).setLabelStack(LABEL_STACK).build();
+ private static final VpnDestination IPV4_VPN_WITHOUT_LABELS = new VpnDestinationBuilder()
+ .setRouteDistinguisher(DISTINGUISHER).setPrefix(IPV4_PREFIX).build();
@Test
public void testMpReachNlri() throws BGPParsingException {
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setAdvertizedRoutes(
new AdvertizedRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(
- new VpnIpv4DestinationBuilder().setVpnDestination(Lists.newArrayList(IPV4_VPN)).build()
- ).build()
- ).build()
- ).build();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update
+ .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder()
+ .setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(
+ Collections.singletonList(IPV4_VPN)).build()).build()).build()).build();
final MpReachNlri mpReachExpected = mpBuilder.build();
mpBuilder.setWithdrawnRoutes(
new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(
- new VpnIpv4DestinationBuilder().setVpnDestination(Lists.newArrayList(IPV4_VPN_WITHOUT_LABELS)).build()
- ).build()
- ).build()
- ).build();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
+ .setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(
+ Collections.singletonList(IPV4_VPN_WITHOUT_LABELS)).build()).build()).build()).build();
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
mpBuilder.setWithdrawnRoutes(
new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(
- new VpnIpv4DestinationBuilder().setVpnDestination(Lists.newArrayList(IPV4_VPN)).build()
- ).build()
- ).build()
- ).build();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
+ .setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(
+ Collections.singletonList(IPV4_VPN)).build()).build()).build()).build();
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.opendaylight.protocol.bgp.l3vpn.ipv4.VpnIpv4NlriParserTest.DISTINGUISHER;
+import static org.opendaylight.protocol.bgp.l3vpn.ipv4.VpnIpv4NlriParserTest.IPV4_PREFIX;
import static org.opendaylight.protocol.bgp.l3vpn.ipv4.VpnIpv4NlriParserTest.IPV4_VPN;
-import static org.opendaylight.protocol.bgp.l3vpn.ipv4.VpnIpv4NlriParserTest.IPv4_PREFIX;
import static org.opendaylight.protocol.bgp.l3vpn.ipv4.VpnIpv4NlriParserTest.LABEL_STACK;
import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
import java.util.Collection;
import java.util.Collections;
import org.junit.Assert;
private static final VpnIpv4RIBSupport RIB_SUPPORT = new VpnIpv4RIBSupport();
private static final DestinationVpnIpv4Case REACH_NLRI = new DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(
- new VpnIpv4DestinationBuilder().setVpnDestination(Lists.newArrayList(IPV4_VPN)).build()).build();
-
- private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- DestinationVpnIpv4Case UNREACH_NLRI = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(Lists.newArrayList(IPV4_VPN)).build()).build();
+ new VpnIpv4DestinationBuilder().setVpnDestination(Collections.singletonList(IPV4_VPN)).build()).build();
+
+ private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4Case UNREACH_NLRI =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
+ .setVpnIpv4Destination(new VpnIpv4DestinationBuilder()
+ .setVpnDestination(Collections.singletonList(IPV4_VPN)).build()).build();
private static final VpnRouteKey ROUTE_KEY = new VpnRouteKey("WAABAQIDBAECIgEW");
- private static final VpnRoute ROUTE = new VpnRouteBuilder().setPathId(new PathId(NON_PATH_ID)).setAttributes(ATTRIBUTES).setPrefix(IPv4_PREFIX)
+ private static final VpnRoute ROUTE = new VpnRouteBuilder().setPathId(new PathId(NON_PATH_ID))
+ .setAttributes(ATTRIBUTES).setPrefix(IPV4_PREFIX)
.setLabelStack(LABEL_STACK).setRouteDistinguisher(DISTINGUISHER).setKey(ROUTE_KEY).build();
- private static final VpnIpv4Routes ROUTES = new VpnIpv4RoutesBuilder().setVpnRoute(Collections.singletonList(ROUTE)).build();
+ private static final VpnIpv4Routes ROUTES = new VpnIpv4RoutesBuilder()
+ .setVpnRoute(Collections.singletonList(ROUTE)).build();
@Override
public void setUp() throws Exception {
@Test
public void testDeleteRoutes() {
RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<VpnRoute> instanceIdentifier = (InstanceIdentifier<VpnRoute>) this.deletedRoutes.get(0);
+ @SuppressWarnings("unchecked")
+ final InstanceIdentifier<VpnRoute> instanceIdentifier =
+ (InstanceIdentifier<VpnRoute>) this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(VpnRoute.class));
}
@Test
public void testEmptyRoute() throws Exception {
- final Routes empty = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(new VpnIpv4RoutesBuilder().setVpnRoute(Collections.emptyList()).build()).build();
+ final Routes empty = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(new VpnIpv4RoutesBuilder()
+ .setVpnRoute(Collections.emptyList()).build()).build();
final ChoiceNode emptyRoutes = RIB_SUPPORT.emptyRoutes();
assertEquals(createRoutes(empty), emptyRoutes);
}
@Test
public void testBuildMpReachNlriUpdate() {
final Update update = RIB_SUPPORT.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
- assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri().getAdvertizedRoutes().getDestinationType());
+ assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri()
+ .getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().getAugmentation(Attributes2.class));
}
@Test
public void testIsComplexRoute() {
- Assert.assertTrue(RIB_SUPPORT.isComplexRoute());
+ assertTrue(RIB_SUPPORT.isComplexRoute());
}
@Test
public void testCacheableNlriObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects());
+ assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
}
@Test
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
- Assert.assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
+ assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT
+ .routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testExtractPathId() {
- Assert.assertEquals((Long) NON_PATH_ID, RIB_SUPPORT.extractPathId(null));
+ assertEquals((Long) NON_PATH_ID, RIB_SUPPORT.extractPathId(null));
}
@Test
public void testRouteAttributesIdentifier() {
- Assert.assertEquals(new NodeIdentifier(QName.create(VpnIpv4Routes.QNAME, Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT
- .routeAttributesIdentifier());
+ assertEquals(new NodeIdentifier(QName.create(VpnIpv4Routes.QNAME,
+ Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- Assert.assertEquals(VpnIpv4RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(VpnIpv4RoutesCase.class, RIB_SUPPORT.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(VpnIpv4Routes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(VpnIpv4Routes.class, RIB_SUPPORT.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(VpnRoute.class, RIB_SUPPORT.routesListClass());
+ assertEquals(VpnRoute.class, RIB_SUPPORT.routesListClass());
}
@Test
public void testChangedRoutes() {
final Routes emptyCase = new VpnIpv4RoutesCaseBuilder().build();
- DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
+ createRoutes(emptyCase)).getRootNode();
+ assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
- final Routes emptyRoutes = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(new VpnIpv4RoutesBuilder().build()).build();
+ final Routes emptyRoutes = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(
+ new VpnIpv4RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
final Routes routes = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext;
-/**
- * @author Kevin Wang
- */
public class BgpIpv6ActivatorTest {
@Test
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.net.Inet6Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv6.next.hop._case.Ipv6NextHopBuilder;
-/**
- * @author Kevin Wang
- */
public class VpnIpv6NextHopTest {
private static final VpnIpv6NextHopParserSerializer HANDLER = new VpnIpv6NextHopParserSerializer();
@Test
public void testSerializeIpv6NextHopCase() throws Exception {
- final String TEST_IPV6_ADDRESS = "2001::1234:5678:90ab:cdef"; // put some random valid IPv6 address here
+ final String TEST_IPV6 = "2001::1234:5678:90ab:cdef"; // put some random valid IPv6 address here
final ByteBuf buffer = Unpooled.buffer();
final byte[] nextHop = new byte[Ipv6Util.IPV6_LENGTH + RouteDistinguisherUtil.RD_LENGTH];
// now copy the IPv6 address to the byte array
- System.arraycopy(Inet6Address.getByName(TEST_IPV6_ADDRESS).getAddress(), 0, nextHop, RouteDistinguisherUtil.RD_LENGTH, Ipv6Util.IPV6_LENGTH);
+ System.arraycopy(Inet6Address.getByName(TEST_IPV6).getAddress(), 0, nextHop,
+ RouteDistinguisherUtil.RD_LENGTH, Ipv6Util.IPV6_LENGTH);
final CNextHop hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder()
- .setGlobal(new Ipv6Address(TEST_IPV6_ADDRESS)).build()).build();
+ .setGlobal(new Ipv6Address(TEST_IPV6)).build()).build();
HANDLER.serializeNextHop(hop, buffer);
assertArrayEquals(nextHop, ByteArray.readAllBytes(buffer));
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.Collections;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestinationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel;
-/**
- * @author Kevin Wang
- */
public class VpnIpv6NlriParserTest {
private static final VpnIpv6NlriParser PARSER = new VpnIpv6NlriParser();
(byte) 0x20, (byte) 0x01, (byte) 0x23, (byte) 0x45, (byte) 0x56, (byte) 0x89
};
- static final IpPrefix IPv6_PREFIX = new IpPrefix(new Ipv6Prefix("2001:2345:5689::/48"));
+ static final IpPrefix IPV6PREFIX = new IpPrefix(new Ipv6Prefix("2001:2345:5689::/48"));
static final List<LabelStack> LABEL_STACK = Lists.newArrayList(
new LabelStackBuilder().setLabelValue(new MplsLabel(355L)).build());
- static final RouteDistinguisher DISTINGUISHER = RouteDistinguisherBuilder.getDefaultInstance("1.2.3.4:258");
- static final VpnDestination IPV6_VPN = new VpnDestinationBuilder().setRouteDistinguisher(DISTINGUISHER).setPrefix(IPv6_PREFIX).setLabelStack(LABEL_STACK).build();
- private static final VpnDestination IPV6_VPN_WITHOUT_LABELS = new VpnDestinationBuilder().setRouteDistinguisher(DISTINGUISHER).setPrefix(IPv6_PREFIX).build();
+ static final RouteDistinguisher DISTINGUISHER = RouteDistinguisherBuilder
+ .getDefaultInstance("1.2.3.4:258");
+ static final VpnDestination IPV6_VPN = new VpnDestinationBuilder().setRouteDistinguisher(DISTINGUISHER)
+ .setPrefix(IPV6PREFIX).setLabelStack(LABEL_STACK).build();
+ private static final VpnDestination IPV6_VPN_WITHOUT_LABELS = new VpnDestinationBuilder()
+ .setRouteDistinguisher(DISTINGUISHER).setPrefix(IPV6PREFIX).build();
@Test
public void testMpReachNlri() throws BGPParsingException {
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv6AddressFamily.class);
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(
- new VpnIpv6DestinationBuilder().setVpnDestination(Lists.newArrayList(IPV6_VPN)).build()
- ).build()
- ).build()
- ).build();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update
+ .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder()
+ .setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(
+ Collections.singletonList(IPV6_VPN)).build()).build()).build()).build();
final MpReachNlri mpReachExpected = mpBuilder.build();
mpBuilder.setWithdrawnRoutes(
new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(
- new VpnIpv6DestinationBuilder().setVpnDestination(Lists.newArrayList(IPV6_VPN_WITHOUT_LABELS)).build()
- ).build()
- ).build()
- ).build();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
+ .setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(
+ Collections.singletonList(IPV6_VPN_WITHOUT_LABELS)).build()).build()).build()).build();
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
mpBuilder.setWithdrawnRoutes(
new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(
- new VpnIpv6DestinationBuilder().setVpnDestination(Lists.newArrayList(IPV6_VPN)).build()
- ).build()
- ).build()
- ).build();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
+ .setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(
+ Collections.singletonList(IPV6_VPN)).build()).build()).build()).build();
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.opendaylight.protocol.bgp.l3vpn.ipv6.VpnIpv6NlriParserTest.DISTINGUISHER;
+import static org.opendaylight.protocol.bgp.l3vpn.ipv6.VpnIpv6NlriParserTest.IPV6PREFIX;
import static org.opendaylight.protocol.bgp.l3vpn.ipv6.VpnIpv6NlriParserTest.IPV6_VPN;
-import static org.opendaylight.protocol.bgp.l3vpn.ipv6.VpnIpv6NlriParserTest.IPv6_PREFIX;
import static org.opendaylight.protocol.bgp.l3vpn.ipv6.VpnIpv6NlriParserTest.LABEL_STACK;
import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
public class VpnIpv6RIBSupportTest extends AbstractRIBSupportTest {
private static final VpnIpv6RIBSupport RIB_SUPPORT = new VpnIpv6RIBSupport();
- private static final DestinationVpnIpv6Case REACH_NLRI = new DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(new VpnIpv6DestinationBuilder()
- .setVpnDestination(Lists.newArrayList(IPV6_VPN)).build()).build();
+ private static final DestinationVpnIpv6Case REACH_NLRI = new DestinationVpnIpv6CaseBuilder()
+ .setVpnIpv6Destination(new VpnIpv6DestinationBuilder()
+ .setVpnDestination(Lists.newArrayList(IPV6_VPN)).build()).build();
- private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- DestinationVpnIpv6Case UNREACH_NLRI = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(Lists.newArrayList(IPV6_VPN)).build()).build();
+ private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6Case UNREACH_NLRI =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
+ .setVpnIpv6Destination(new VpnIpv6DestinationBuilder()
+ .setVpnDestination(Collections.singletonList(IPV6_VPN)).build()).build();
private static final VpnRouteKey ROUTE_KEY = new VpnRouteKey("cAABAQIDBAECIAEjRVaJ");
- private static final VpnRoute ROUTE = new VpnRouteBuilder().setPathId(new PathId(NON_PATH_ID)).setAttributes(ATTRIBUTES).setPrefix(IPv6_PREFIX)
- .setLabelStack(LABEL_STACK).setRouteDistinguisher(DISTINGUISHER).setKey(ROUTE_KEY).build();
- private static final VpnIpv6Routes ROUTES = new VpnIpv6RoutesBuilder().setVpnRoute(Collections.singletonList(ROUTE)).build();
+ private static final VpnRoute ROUTE = new VpnRouteBuilder().setPathId(new PathId(NON_PATH_ID))
+ .setAttributes(ATTRIBUTES).setPrefix(IPV6PREFIX)
+ .setLabelStack(LABEL_STACK).setRouteDistinguisher(DISTINGUISHER).setKey(ROUTE_KEY).build();
+ private static final VpnIpv6Routes ROUTES = new VpnIpv6RoutesBuilder()
+ .setVpnRoute(Collections.singletonList(ROUTE)).build();
@Override
public void setUp() throws Exception {
@Test
public void testDeleteRoutes() {
RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<VpnRoute> instanceIdentifier = (InstanceIdentifier<VpnRoute>) this.deletedRoutes.get(0);
+ @SuppressWarnings("unchecked") final InstanceIdentifier<VpnRoute> instanceIdentifier =
+ (InstanceIdentifier<VpnRoute>) this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(VpnRoute.class));
}
@Test
public void testEmptyRoute() throws Exception {
- final Routes empty = new VpnIpv6RoutesCaseBuilder().setVpnIpv6Routes(new VpnIpv6RoutesBuilder().setVpnRoute(Collections.emptyList()).build()).build();
+ final Routes empty = new VpnIpv6RoutesCaseBuilder().setVpnIpv6Routes(new VpnIpv6RoutesBuilder()
+ .setVpnRoute(Collections.emptyList()).build()).build();
final ChoiceNode emptyRoutes = RIB_SUPPORT.emptyRoutes();
assertEquals(createRoutes(empty), emptyRoutes);
}
public void testBuildMpUnreachNlriUpdate() {
final Update update = RIB_SUPPORT.buildUpdate(Collections.emptyList(), createRoutes(ROUTES), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().getAugmentation(Attributes2.class)
- .getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
+ .getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().getAugmentation(Attributes1.class));
}
@Test
public void testBuildMpReachNlriUpdate() {
final Update update = RIB_SUPPORT.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
- assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri().getAdvertizedRoutes().getDestinationType());
+ assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri()
+ .getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().getAugmentation(Attributes2.class));
}
@Test
public void testCacheableNlriObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects());
+ assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
}
@Test
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
- Assert.assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
+ assertEquals(getRoutePath().node(prefixNii),
+ RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testExtractPathId() {
- Assert.assertEquals((Long) NON_PATH_ID, RIB_SUPPORT.extractPathId(null));
+ assertEquals((Long) NON_PATH_ID, RIB_SUPPORT.extractPathId(null));
}
@Test
public void testRouteAttributesIdentifier() {
- Assert.assertEquals(new NodeIdentifier(QName.create(VpnIpv6Routes.QNAME, Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT
- .routeAttributesIdentifier());
+ assertEquals(new NodeIdentifier(QName.create(VpnIpv6Routes.QNAME,
+ Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- Assert.assertEquals(VpnIpv6RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(VpnIpv6RoutesCase.class, RIB_SUPPORT.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(VpnIpv6Routes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(VpnIpv6Routes.class, RIB_SUPPORT.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(VpnRoute.class, RIB_SUPPORT.routesListClass());
+ assertEquals(VpnRoute.class, RIB_SUPPORT.routesListClass());
}
@Test
public void testChangedRoutes() {
final Routes emptyCase = new VpnIpv6RoutesCaseBuilder().build();
- DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyCase)).getRootNode();
+ DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
+ createRoutes(emptyCase)).getRootNode();
Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
- final Routes emptyRoutes = new VpnIpv6RoutesCaseBuilder().setVpnIpv6Routes(new VpnIpv6RoutesBuilder().build()).build();
+ final Routes emptyRoutes = new VpnIpv6RoutesCaseBuilder()
+ .setVpnIpv6Routes(new VpnIpv6RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());