</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>
/**
* Common {@link org.opendaylight.protocol.bgp.rib.spi.RIBSupport} class for IPv4 and IPv6 addresses.
*/
-abstract class AbstractIPRIBSupport extends MultiPathAbstractRIBSupport {
- private static final Logger LOG = LoggerFactory.getLogger(AbstractIPRIBSupport.class);
+abstract class AbstractIPRibSupport extends MultiPathAbstractRIBSupport {
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractIPRibSupport.class);
private final NodeIdentifier prefixNid;
private final NodeIdentifier nlriRoutesList;
private final ImmutableCollection<Class<? extends DataObject>> cacheableNlriObjects;
- protected AbstractIPRIBSupport(final Class<? extends DataObject> prefixClass, final Class<? extends AddressFamily> addressFamilyClass,
- final Class<? extends Routes> cazeClass, final Class<? extends DataObject> containerClass, final Class<? extends Route> listClass,
+ protected AbstractIPRibSupport(final Class<? extends DataObject> prefixClass,
+ final Class<? extends AddressFamily> addressFamilyClass,
+ final Class<? extends Routes> cazeClass,
+ final Class<? extends DataObject> containerClass, final Class<? extends Route> listClass,
final QName destinationQname, final QName prefixesQname) {
- super(cazeClass, containerClass, listClass, addressFamilyClass, UnicastSubsequentAddressFamily.class, "prefix", destinationQname);
+ super(cazeClass, containerClass, listClass, addressFamilyClass,
+ UnicastSubsequentAddressFamily.class, "prefix", destinationQname);
this.prefixNid = new NodeIdentifier(routeKeyQName());
this.nlriRoutesList = new NodeIdentifier(prefixesQname);
this.cacheableNlriObjects = ImmutableSet.of(prefixClass);
protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath,
final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) {
if (destination != null) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes = destination.getChild(this.nlriRoutesList);
+ final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes =
+ destination.getChild(this.nlriRoutesList);
if (maybeRoutes.isPresent()) {
final DataContainerChild<? extends PathArgument, ?> routes = maybeRoutes.get();
if (routes instanceof UnkeyedListNode) {
}
/**
- * Prefix and Path Id are the route key
+ * Prefix and Path Id are the route key.
*
* @param prefixes UnkeyedListEntryNode containing route
* @return Nid with Route Key
*/
private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode prefixes) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> maybePrefixLeaf = prefixes.getChild(routePrefixIdentifier());
- final Optional<DataContainerChild<? extends PathArgument, ?>> maybePathIdLeaf = prefixes.getChild(routePathIdNid());
+ final Optional<DataContainerChild<? extends PathArgument, ?>> maybePrefixLeaf =
+ prefixes.getChild(routePrefixIdentifier());
+ final Optional<DataContainerChild<? extends PathArgument, ?>> maybePathIdLeaf =
+ prefixes.getChild(routePathIdNid());
Preconditions.checkState(maybePrefixLeaf.isPresent());
final Object prefixValue = maybePrefixLeaf.get().getValue();
return PathIdUtil.createNidKey(routeQName(), routeKeyQName(), pathIdQName(), prefixValue, maybePathIdLeaf);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.Ipv4Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.ipv4.routes.Ipv4Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Ipv4PrefixAndPathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.destination.DestinationType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
/**
* Class supporting IPv4 unicast RIBs.
*/
-final class IPv4RIBSupport extends AbstractIPRIBSupport {
+final class IPv4RIBSupport extends AbstractIPRibSupport {
private static final IPv4RIBSupport SINGLETON = new IPv4RIBSupport();
private IPv4RIBSupport() {
- super(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Ipv4PrefixAndPathId.class, Ipv4AddressFamily.class,
+ super(Ipv4PrefixAndPathId.class, Ipv4AddressFamily.class,
Ipv4RoutesCase.class, Ipv4Routes.class, Ipv4Route.class, DestinationIpv4.QNAME, Ipv4Prefixes.QNAME);
}
@Nonnull
@Override
protected DestinationType buildDestination(@Nonnull final Collection<MapEntryNode> routes) {
- return new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(extractPrefixes(routes)).build()).build();
+ return new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder()
+ .setIpv4Prefixes(extractPrefixes(routes)).build()).build();
}
@Nonnull
@Override
protected DestinationType buildWithdrawnDestination(@Nonnull final Collection<MapEntryNode> routes) {
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(
- new DestinationIpv4Builder().setIpv4Prefixes(extractPrefixes(routes)).build()).build();
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder()
+ .setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(extractPrefixes(routes))
+ .build()).build();
}
}
/**
* Class supporting IPv6 unicast RIBs.
*/
-final class IPv6RIBSupport extends AbstractIPRIBSupport {
+final class IPv6RIBSupport extends AbstractIPRibSupport {
private static final IPv6RIBSupport SINGLETON = new IPv6RIBSupport();
private IPv6RIBSupport() {
super(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.Ipv6Prefix.class,
- Ipv6AddressFamily.class, Ipv6RoutesCase.class, Ipv6Routes.class, Ipv6Route.class, DestinationIpv6.QNAME, Ipv6Prefixes.QNAME);
+ Ipv6AddressFamily.class, Ipv6RoutesCase.class, Ipv6Routes.class, Ipv6Route.class,
+ DestinationIpv6.QNAME, Ipv6Prefixes.QNAME);
}
static IPv6RIBSupport getInstance() {
@Nonnull
@Override
protected DestinationType buildDestination(@Nonnull final Collection<MapEntryNode> routes) {
- return new DestinationIpv6CaseBuilder().setDestinationIpv6(new DestinationIpv6Builder().setIpv6Prefixes(extractPrefixes(routes)).build()).build();
+ return new DestinationIpv6CaseBuilder().setDestinationIpv6(new DestinationIpv6Builder()
+ .setIpv6Prefixes(extractPrefixes(routes)).build()).build();
}
@Nonnull
@Override
protected DestinationType buildWithdrawnDestination(@Nonnull final Collection<MapEntryNode> routes) {
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes
- .destination.type.DestinationIpv6CaseBuilder().setDestinationIpv6(
- new DestinationIpv6Builder().setIpv6Prefixes(extractPrefixes(routes)).build()).build();
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder()
+ .setDestinationIpv6(new DestinationIpv6Builder().setIpv6Prefixes(extractPrefixes(routes))
+ .build()).build();
}
private List<Ipv6Prefixes> extractPrefixes(final Collection<MapEntryNode> routes) {
final List<Ipv6Prefixes> prefs = new ArrayList<>(routes.size());
for (final MapEntryNode route : routes) {
final String prefix = (String) NormalizedNodes.findNode(route, routePrefixIdentifier()).get().getValue();
- prefs.add(new Ipv6PrefixesBuilder().setPathId(PathIdUtil.buildPathId(route, routePathIdNid())).setPrefix(new Ipv6Prefix(prefix)).build());
+ prefs.add(new Ipv6PrefixesBuilder().setPathId(PathIdUtil.buildPathId(route, routePathIdNid()))
+ .setPrefix(new Ipv6Prefix(prefix)).build());
}
return prefs;
}
@Override
protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
return Lists.newArrayList(
- context.registerRIBSupport(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, IPv4RIBSupport.getInstance()),
- context.registerRIBSupport(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class, IPv6RIBSupport.getInstance()));
+ context.registerRIBSupport(Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class, IPv4RIBSupport.getInstance()),
+ context.registerRIBSupport(Ipv6AddressFamily.class,
+ UnicastSubsequentAddressFamily.class, IPv6RIBSupport.getInstance()));
}
}
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, UnicastSubsequentAddressFamily.class, IPV4UNICAST.class),
- provider.registerBGPTableType(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class, IPV6UNICAST.class));
+ provider.registerBGPTableType(Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class, IPV4UNICAST.class),
+ provider.registerBGPTableType(Ipv6AddressFamily.class,
+ UnicastSubsequentAddressFamily.class, IPV6UNICAST.class));
}
}
}
@Override
- public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder, final PeerSpecificParserConstraint constraint) {
+ public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder,
+ final PeerSpecificParserConstraint constraint) {
builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
- new DestinationIpv4CaseBuilder().setDestinationIpv4(prefixes(nlri, constraint, builder.getAfi(), builder.getSafi())).build()).build());
+ new DestinationIpv4CaseBuilder().setDestinationIpv4(prefixes(nlri, constraint,
+ builder.getAfi(), builder.getSafi())).build()).build());
}
@Override
- public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder, final PeerSpecificParserConstraint constraint) {
- builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(
- prefixes(nlri, constraint, builder.getAfi(), builder.getSafi())).build()).build());
+ public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder,
+ final PeerSpecificParserConstraint constraint) {
+ builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder()
+ .setDestinationIpv4(prefixes(nlri, constraint, builder.getAfi(), builder.getSafi()))
+ .build()).build());
}
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final Attributes pathAttributes = (Attributes) attribute;
final Attributes1 pathAttributes1 = pathAttributes.getAugmentation(Attributes1.class);
final Attributes2 pathAttributes2 = pathAttributes.getAugmentation(Attributes2.class);
if (pathAttributes1 != null) {
final AdvertizedRoutes advertizedRoutes = pathAttributes1.getMpReachNlri().getAdvertizedRoutes();
if (advertizedRoutes != null && advertizedRoutes.getDestinationType() instanceof DestinationIpv4Case) {
- final DestinationIpv4Case destinationIpv4Case = (DestinationIpv4Case) advertizedRoutes.getDestinationType();
+ final DestinationIpv4Case destinationIpv4Case =
+ (DestinationIpv4Case) advertizedRoutes.getDestinationType();
for (final Ipv4Prefixes ipv4Prefix : destinationIpv4Case.getDestinationIpv4().getIpv4Prefixes()) {
PathIdUtil.writePathId(ipv4Prefix.getPathId(), byteAggregator);
ByteBufWriteUtil.writeMinimalPrefix(ipv4Prefix.getPrefix(), byteAggregator);
}
} else if (pathAttributes2 != null) {
final WithdrawnRoutes withdrawnRoutes = pathAttributes2.getMpUnreachNlri().getWithdrawnRoutes();
- if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case destinationIpv4Case =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case) withdrawnRoutes.getDestinationType();
+ if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof org.opendaylight.yang.gen
+ .v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri
+ .withdrawn.routes.destination.type.DestinationIpv4Case) {
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationIpv4Case destinationIpv4Case = (org.opendaylight.yang.gen.v1.urn.opendaylight
+ .params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes
+ .destination.type.DestinationIpv4Case) withdrawnRoutes.getDestinationType();
for (final Ipv4Prefixes ipv4Prefix : destinationIpv4Case.getDestinationIpv4().getIpv4Prefixes()) {
PathIdUtil.writePathId(ipv4Prefix.getPathId(), byteAggregator);
ByteBufWriteUtil.writeMinimalPrefix(ipv4Prefix.getPrefix(), byteAggregator);
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
import org.opendaylight.protocol.bgp.parser.spi.MultiPathSupportUtil;
private static DestinationIpv6 prefixes(final ByteBuf nlri, final PeerSpecificParserConstraint constraint,
final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
final List<Ipv6Prefixes> prefixes = new ArrayList<>();
- final boolean supported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(afi, safi));
+ final boolean supported = MultiPathSupportUtil.isTableTypeSupported(constraint,
+ new BgpTableTypeImpl(afi, safi));
while (nlri.isReadable()) {
final Ipv6PrefixesBuilder prefixesBuilder = new Ipv6PrefixesBuilder();
if (supported) {
}
@Override
- public void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpReachNlriBuilder builder,
- @Nullable final PeerSpecificParserConstraint constraint) throws BGPParsingException {
- builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv6CaseBuilder().
- setDestinationIpv6(prefixes(nlri, constraint, builder.getAfi(), builder.getSafi())).build()).build());
+ public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder,
+ final PeerSpecificParserConstraint constraint) {
+ builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv6CaseBuilder()
+ .setDestinationIpv6(prefixes(nlri, constraint, builder.getAfi(), builder.getSafi())).build()).build());
}
@Override
- public void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpUnreachNlriBuilder builder, @Nullable final PeerSpecificParserConstraint constraint) throws BGPParsingException {
- builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder().setDestinationIpv6(
+ public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder,
+ final PeerSpecificParserConstraint constraint) {
+ builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn
+ .opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes
+ .destination.type.DestinationIpv6CaseBuilder().setDestinationIpv6(
prefixes(nlri, constraint, builder.getAfi(), builder.getSafi())).build()).build());
}
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final Attributes pathAttributes = (Attributes) attribute;
final Attributes1 pathAttributes1 = pathAttributes.getAugmentation(Attributes1.class);
final Attributes2 pathAttributes2 = pathAttributes.getAugmentation(Attributes2.class);
if (pathAttributes1 != null) {
final AdvertizedRoutes advertizedRoutes = pathAttributes1.getMpReachNlri().getAdvertizedRoutes();
if (advertizedRoutes != null && advertizedRoutes.getDestinationType() instanceof DestinationIpv6Case) {
- final DestinationIpv6Case destinationIpv6Case = (DestinationIpv6Case) advertizedRoutes.getDestinationType();
+ final DestinationIpv6Case destinationIpv6Case =
+ (DestinationIpv6Case) advertizedRoutes.getDestinationType();
for (final Ipv6Prefixes ipv6Prefix : destinationIpv6Case.getDestinationIpv6().getIpv6Prefixes()) {
PathIdUtil.writePathId(ipv6Prefix.getPathId(), byteAggregator);
ByteBufWriteUtil.writeMinimalPrefix(ipv6Prefix.getPrefix(), byteAggregator);
}
} else if (pathAttributes2 != null) {
final WithdrawnRoutes withdrawnRoutes = pathAttributes2.getMpUnreachNlri().getWithdrawnRoutes();
- if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6Case) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6Case destinationIpv6Case =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6Case) withdrawnRoutes.getDestinationType();
+ if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof org.opendaylight.yang.gen
+ .v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri
+ .withdrawn.routes.destination.type.DestinationIpv6Case) {
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationIpv6Case destinationIpv6Case =
+ (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationIpv6Case) withdrawnRoutes.getDestinationType();
for (final Ipv6Prefixes ipv6Prefix : destinationIpv6Case.getDestinationIpv6().getIpv6Prefixes()) {
PathIdUtil.writePathId(ipv6Prefix.getPathId(), byteAggregator);
ByteBufWriteUtil.writeMinimalPrefix(ipv6Prefix.getPrefix(), byteAggregator);
public final class Ipv4NextHopParserSerializer implements NextHopParserSerializer {
@Override
public CNextHop parseNextHop(final ByteBuf buffer) throws BGPParsingException {
- Preconditions.checkArgument(buffer.readableBytes() == Ipv4Util.IP4_LENGTH, "Length of byte array for NEXT_HOP should be %s, but is %s", buffer.readableBytes(), Ipv4Util.IP4_LENGTH);
+ Preconditions.checkArgument(buffer.readableBytes() == Ipv4Util.IP4_LENGTH,
+ "Length of byte array for NEXT_HOP should be %s, but is %s",
+ buffer.readableBytes(), Ipv4Util.IP4_LENGTH);
return NextHopUtil.parseNextHop(buffer);
}
@Override
- public void serializeNextHop(final CNextHop cNextHop, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(cNextHop instanceof Ipv4NextHopCase, "cNextHop is not a Ipv4 NextHop object.");
- NextHopUtil.serializeNextHop( cNextHop, byteAggregator);
+ public void serializeNextHop(final CNextHop nextHop, final ByteBuf byteAggregator) {
+ Preconditions.checkArgument(nextHop instanceof Ipv4NextHopCase,
+ "cNextHop is not a Ipv4 NextHop object.");
+ NextHopUtil.serializeNextHop(nextHop, byteAggregator);
}
}
}
@Override
- public void serializeNextHop(final CNextHop cNextHop, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(cNextHop instanceof Ipv6NextHopCase, "cNextHop is not a Ipv6 NextHop object.");
- NextHopUtil.serializeNextHop(cNextHop,byteAggregator);
+ public void serializeNextHop(final CNextHop nextHop, final ByteBuf byteAggregator) {
+ Preconditions.checkArgument(nextHop instanceof Ipv6NextHopCase,
+ "cNextHop is not a Ipv6 NextHop object.");
+ NextHopUtil.serializeNextHop(nextHop, byteAggregator);
}
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
private static final Ipv4RouteKey ROUTE_KEY = new Ipv4RouteKey(PATH_ID, PREFIX);
private static final Ipv4Prefixes IPV4_PREFIXES = new Ipv4PrefixesBuilder().setPathId(PATH_ID)
.setPrefix(PREFIX).build();
- private static final DestinationIpv4Case REACH_NLRI = new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder()
- .setIpv4Prefixes(Lists.newArrayList(IPV4_PREFIXES)).build()).build();
+ private static final DestinationIpv4Case REACH_NLRI = new DestinationIpv4CaseBuilder()
+ .setDestinationIpv4(new DestinationIpv4Builder()
+ .setIpv4Prefixes(Lists.newArrayList(IPV4_PREFIXES)).build()).build();
private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case UNREACH_NLRI =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(
- new DestinationIpv4Builder().setIpv4Prefixes(Lists.newArrayList(IPV4_PREFIXES)).build()).build();
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case UNREACH_NLRI =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder()
+ .setDestinationIpv4(new DestinationIpv4Builder()
+ .setIpv4Prefixes(Collections.singletonList(IPV4_PREFIXES)).build()).build();
- private static final Ipv4Route ROUTE = new Ipv4RouteBuilder().setAttributes(ATTRIBUTES).setPathId(PATH_ID).setPrefix(PREFIX).build();
- private static final Ipv4Routes ROUTES = new Ipv4RoutesBuilder().setIpv4Route(Collections.singletonList(ROUTE)).build();
- private static final Ipv4Routes EMPTY_ROUTES = new Ipv4RoutesBuilder().setIpv4Route(Collections.emptyList()).build();
+ private static final Ipv4Route ROUTE = new Ipv4RouteBuilder().setAttributes(ATTRIBUTES).setPathId(PATH_ID)
+ .setPrefix(PREFIX).build();
+ private static final Ipv4Routes ROUTES = new Ipv4RoutesBuilder()
+ .setIpv4Route(Collections.singletonList(ROUTE)).build();
+ private static final Ipv4Routes EMPTY_ROUTES = new Ipv4RoutesBuilder()
+ .setIpv4Route(Collections.emptyList()).build();
@Override
public void setUp() throws Exception {
@Test
public void testDeleteRoutes() {
RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<Ipv4Route> instanceIdentifier = (InstanceIdentifier<Ipv4Route>) this.deletedRoutes.get(0);
+ @SuppressWarnings("unchecked") final InstanceIdentifier<Ipv4Route> instanceIdentifier =
+ (InstanceIdentifier<Ipv4Route>) this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(Ipv4Route.class));
}
@Test
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());
+ assertEquals(UNREACH_NLRI, update.getAttributes().getAugmentation(Attributes2.class).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(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Ipv4PrefixAndPathId.class), RIB_SUPPORT.cacheableNlriObjects());
+ assertEquals(ImmutableSet.of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .message.rev171207.Ipv4PrefixAndPathId.class), RIB_SUPPORT.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
}
@Test
public void testRouteIdAddPath() {
final NodeIdentifierWithPredicates expected = createRouteNIWP(ROUTES);
- final NodeIdentifierWithPredicates prefixNii = new NodeIdentifierWithPredicates(RIB_SUPPORT.routeQName(), ImmutableMap.of(RIB_SUPPORT.routeKeyQName(), PREFIX.getValue()));
- Assert.assertEquals(expected, RIB_SUPPORT.getRouteIdAddPath(AbstractRIBSupportTest.PATH_ID, prefixNii));
+ final NodeIdentifierWithPredicates prefixNii = new NodeIdentifierWithPredicates(RIB_SUPPORT.routeQName(),
+ ImmutableMap.of(RIB_SUPPORT.routeKeyQName(), PREFIX.getValue()));
+ assertEquals(expected, RIB_SUPPORT.getRouteIdAddPath(AbstractRIBSupportTest.PATH_ID, prefixNii));
}
@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() {
final NormalizedNode<?, ?> route = Iterables.getOnlyElement(createRoutes(ROUTES));
- Assert.assertEquals(PATH_ID.getValue(), RIB_SUPPORT.extractPathId(route));
+ assertEquals(PATH_ID.getValue(), RIB_SUPPORT.extractPathId(route));
}
@Test
public void testRouteAttributesIdentifier() {
- Assert.assertEquals(new NodeIdentifier(QName.create(Ipv4Routes.QNAME, Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT
- .routeAttributesIdentifier());
+ assertEquals(new NodeIdentifier(QName.create(Ipv4Routes.QNAME, Attributes.QNAME.getLocalName().intern())),
+ RIB_SUPPORT.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- Assert.assertEquals(Ipv4RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(Ipv4RoutesCase.class, RIB_SUPPORT.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(Ipv4Routes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(Ipv4Routes.class, RIB_SUPPORT.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(Ipv4Route.class, RIB_SUPPORT.routesListClass());
+ assertEquals(Ipv4Route.class, RIB_SUPPORT.routesListClass());
}
@Test
public void testChangedRoutes() {
final Routes emptyCase = new Ipv4RoutesCaseBuilder().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 Ipv4RoutesCaseBuilder().setIpv4Routes(new Ipv4RoutesBuilder().build()).build();
package org.opendaylight.protocol.bgp.inet;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
private static final Ipv6Prefix PREFIX = new Ipv6Prefix("2001:db8:1:2::/64");
private static final Ipv6RouteKey ROUTE_KEY = new Ipv6RouteKey(PATH_ID, PREFIX);
private static final Ipv6Prefixes IPV6_PREFIXES = new Ipv6PrefixesBuilder().setPathId(PATH_ID)
- .setPrefix(PREFIX).build();
- private static final DestinationIpv6Case REACH_NLRI = new DestinationIpv6CaseBuilder().setDestinationIpv6(new DestinationIpv6Builder()
- .setIpv6Prefixes(Lists.newArrayList(IPV6_PREFIXES)).build()).build();
+ .setPrefix(PREFIX).build();
+ private static final DestinationIpv6Case REACH_NLRI = new DestinationIpv6CaseBuilder()
+ .setDestinationIpv6(new DestinationIpv6Builder()
+ .setIpv6Prefixes(Lists.newArrayList(IPV6_PREFIXES)).build()).build();
private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6Case UNREACH_NLRI =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder().setDestinationIpv6(
- new DestinationIpv6Builder().setIpv6Prefixes(Lists.newArrayList(IPV6_PREFIXES)).build()).build();
-
- private static final Ipv6Route ROUTE = new Ipv6RouteBuilder().setAttributes(ATTRIBUTES).setPathId(PATH_ID).setPrefix(PREFIX).build();
- private static final Ipv6Routes ROUTES = new Ipv6RoutesBuilder().setIpv6Route(Collections.singletonList(ROUTE)).build();
- private static final Ipv6Routes EMPTY_ROUTES = new Ipv6RoutesBuilder().setIpv6Route(Collections.emptyList()).build();
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6Case UNREACH_NLRI =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder()
+ .setDestinationIpv6(new DestinationIpv6Builder()
+ .setIpv6Prefixes(Collections.singletonList(IPV6_PREFIXES)).build()).build();
+
+ private static final Ipv6Route ROUTE = new Ipv6RouteBuilder().setAttributes(ATTRIBUTES).setPathId(PATH_ID)
+ .setPrefix(PREFIX).build();
+ private static final Ipv6Routes ROUTES = new Ipv6RoutesBuilder()
+ .setIpv6Route(Collections.singletonList(ROUTE)).build();
+ private static final Ipv6Routes EMPTY_ROUTES = new Ipv6RoutesBuilder()
+ .setIpv6Route(Collections.emptyList()).build();
@Override
public void setUp() throws Exception {
@Test
public void testDeleteRoutes() {
RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<Ipv6Route> instanceIdentifier = (InstanceIdentifier<Ipv6Route>) this.deletedRoutes.get(0);
+ @SuppressWarnings("unchecked") final InstanceIdentifier<Ipv6Route> instanceIdentifier =
+ (InstanceIdentifier<Ipv6Route>) this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(Ipv6Route.class));
}
@Test
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());
+ assertEquals(UNREACH_NLRI, update.getAttributes().getAugmentation(Attributes2.class)
+ .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(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.Ipv6Prefix.class),
- RIB_SUPPORT.cacheableNlriObjects());
+ assertEquals(ImmutableSet.of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet
+ .rev171207.Ipv6Prefix.class), RIB_SUPPORT.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
}
@Test
public void testRouteIdAddPath() {
final NodeIdentifierWithPredicates expected = createRouteNIWP(ROUTES);
- final NodeIdentifierWithPredicates prefixNii = new NodeIdentifierWithPredicates(RIB_SUPPORT.routeQName(), ImmutableMap.of(RIB_SUPPORT.routeKeyQName(), PREFIX.getValue()));
- Assert.assertEquals(expected, RIB_SUPPORT.getRouteIdAddPath(AbstractRIBSupportTest.PATH_ID, prefixNii));
+ final NodeIdentifierWithPredicates prefixNii = new NodeIdentifierWithPredicates(RIB_SUPPORT.routeQName(),
+ ImmutableMap.of(RIB_SUPPORT.routeKeyQName(), PREFIX.getValue()));
+ assertEquals(expected, RIB_SUPPORT.getRouteIdAddPath(AbstractRIBSupportTest.PATH_ID, prefixNii));
}
@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() {
final NormalizedNode<?, ?> route = Iterables.getOnlyElement(createRoutes(ROUTES));
- Assert.assertEquals(PATH_ID.getValue(), RIB_SUPPORT.extractPathId(route));
+ assertEquals(PATH_ID.getValue(), RIB_SUPPORT.extractPathId(route));
}
@Test
public void testRouteAttributesIdentifier() {
- Assert.assertEquals(new NodeIdentifier(QName.create(Ipv6Routes.QNAME, Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT
- .routeAttributesIdentifier());
+ assertEquals(new NodeIdentifier(QName.create(Ipv6Routes.QNAME,
+ Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- Assert.assertEquals(Ipv6RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(Ipv6RoutesCase.class, RIB_SUPPORT.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(Ipv6Routes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(Ipv6Routes.class, RIB_SUPPORT.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(Ipv6Route.class, RIB_SUPPORT.routesListClass());
+ assertEquals(Ipv6Route.class, RIB_SUPPORT.routesListClass());
}
@Test
public void testChangedRoutes() {
final Routes emptyCase = new Ipv6RoutesCaseBuilder().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 Ipv6RoutesCaseBuilder().setIpv6Routes(new Ipv6RoutesBuilder().build()).build();
private final Ipv6BgpPrefixSidParser handler = new Ipv6BgpPrefixSidParser();
- private final byte[] expected = new byte[] {0, (byte)0x80, 0};
+ private final byte[] expected = new byte[]{0, (byte) 0x80, 0};
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testWrongTlvType() {
this.handler.serializeBgpPrefixSidTlv(() -> BgpPrefixSidTlv.class, Unpooled.EMPTY_BUFFER);
}
package org.opendaylight.protocol.bgp.inet;
+import static org.junit.Assert.assertEquals;
+
import java.util.Optional;
-import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.protocol.bgp.openconfig.spi.SimpleBGPTableTypeRegistryProvider;
import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
public class TableTypeActivatorTest {
- private static final BgpTableType IPV4 = new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
- private static final BgpTableType IPV6 = new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class);
+ private static final BgpTableType IPV4 = new BgpTableTypeImpl(Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class);
+ private static final BgpTableType IPV6 = new BgpTableTypeImpl(Ipv6AddressFamily.class,
+ UnicastSubsequentAddressFamily.class);
@Test
public void testActivator() {
tableTypeActivator.startBGPTableTypeRegistryProvider(registry);
final Optional<Class<? extends AfiSafiType>> afiSafiType = registry.getAfiSafiType(IPV4);
- Assert.assertEquals(IPV4UNICAST.class, afiSafiType.get());
+ assertEquals(IPV4UNICAST.class, afiSafiType.get());
final Optional<Class<? extends AfiSafiType>> afiSafiType2 = registry.getAfiSafiType(IPV6);
- Assert.assertEquals(IPV6UNICAST.class, afiSafiType2.get());
+ assertEquals(IPV6UNICAST.class, afiSafiType2.get());
final Optional<BgpTableType> tableType = registry.getTableType(IPV4UNICAST.class);
- Assert.assertEquals(IPV4, tableType.get());
+ assertEquals(IPV4, tableType.get());
final Optional<BgpTableType> tableType2 = registry.getTableType(IPV6UNICAST.class);
- Assert.assertEquals(IPV6, tableType2.get());
+ assertEquals(IPV6, tableType2.get());
tableTypeActivator.stopBGPTableTypeRegistryProvider();
tableTypeActivator.close();
messageRegistry = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry();
final String name = "/up2.bin";
- try (final InputStream is = BGPParserTest.class.getResourceAsStream(name)) {
+ try (InputStream is = BGPParserTest.class.getResourceAsStream(name)) {
if (is == null) {
throw new IOException("Failed to get resource " + name);
}
final ByteArrayOutputStream bis = new ByteArrayOutputStream();
final byte[] data = new byte[MAX_SIZE];
- int nRead = 0;
- while ((nRead = is.read(data, 0, data.length)) != -1) {
- bis.write(data, 0, nRead);
+ int position;
+ while ((position = is.read(data, 0, data.length)) != -1) {
+ bis.write(data, 0, position);
}
bis.flush();
asPath.add(new SegmentsBuilder().setAsSequence(asNumbers).build());
final Ipv6NextHopCase nextHop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(
- new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8::1")).setLinkLocal(new Ipv6Address("fe80::c001:bff:fe7e:0")).build()).build();
+ new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8::1"))
+ .setLinkLocal(new Ipv6Address("fe80::c001:bff:fe7e:0")).build()).build();
final List<ClusterIdentifier> clusters = Lists.newArrayList(new ClusterIdentifier(new Ipv4Address("1.2.3.4")),
new ClusterIdentifier(new Ipv4Address("5.6.7.8")));
mpBuilder.setSafi(UnicastSubsequentAddressFamily.class);
mpBuilder.setCNextHop(nextHop);
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
- new DestinationIpv6CaseBuilder().setDestinationIpv6(new DestinationIpv6Builder().setIpv6Prefixes(prefs).build()).build()).build());
+ new DestinationIpv6CaseBuilder().setDestinationIpv6(new DestinationIpv6Builder()
+ .setIpv6Prefixes(prefs).build()).build()).build());
- paBuilder.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpBuilder.build()).build());
+ paBuilder.addAugmentation(Attributes1.class, new Attributes1Builder()
+ .setMpReachNlri(mpBuilder.build()).build());
assertEquals(paBuilder.getAugmentation(Attributes1.class).getMpReachNlri(),
attrs.getAugmentation(Attributes1.class).getMpReachNlri());
paBuilder.setUnrecognizedAttributes(Collections.emptyList());
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
public class Ipv4NlriParserTest {
- private final Ipv4NlriParser parser = new Ipv4NlriParser();
-
- private final String ipPrefix1 = "1.2.3.4/32";
- private final String ipPrefix2 = "1.2.3.5/32";
- private final String additionalIpWD = "1.2.3.6/32";
-
- private final List<Ipv4Prefixes> prefixes = new ArrayList<>();
- private final ByteBuf inputBytes = Unpooled.buffer();
-
- private static final byte[] MP_NLRI_BYTES = new byte[] {
+ private static final byte[] MP_NLRI_BYTES = new byte[]{
0x0, 0x0, 0x0, 0x1, 0x18, 0x1, 0x1, 0x1,
0x0, 0x0, 0x0, 0x2, 0x18, 0x1, 0x1, 0x1};
-
private static final Ipv4Prefix DESTINATION = new Ipv4Prefix("1.1.1.0/24");
-
private static final ArrayList<Ipv4Prefixes> PREFIXES = Lists.newArrayList(
createIpv4Prefix(1L, DESTINATION),
createIpv4Prefix(2L, DESTINATION));
-
- private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case ip4caseWD;
- private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case ip4caseWDWrong;
+ private final Ipv4NlriParser parser = new Ipv4NlriParser();
+ private final String ipPrefix1 = "1.2.3.4/32";
+ private final String ipPrefix2 = "1.2.3.5/32";
+ private final String additionalIpWD = "1.2.3.6/32";
+ private final List<Ipv4Prefixes> prefixes = new ArrayList<>();
+ private final ByteBuf inputBytes = Unpooled.buffer();
+ private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp
+ .unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case ip4caseWD;
+ private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp
+ .unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case ip4caseWDWrong;
private DestinationIpv4Case ip4caseAD;
private DestinationIpv4Case ip4caseADWrong;
@Mock
private MultiPathSupport muliPathSupport;
+ private static Ipv4Prefixes createIpv4Prefix(final long pathId, final Ipv4Prefix prefix) {
+ return new Ipv4PrefixesBuilder().setPathId(new PathId(pathId)).setPrefix(prefix).build();
+ }
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
this.prefixes.add(new Ipv4PrefixesBuilder().setPrefix(prefix1).build());
this.prefixes.add(new Ipv4PrefixesBuilder().setPrefix(prefix2).build());
- this.ip4caseWD = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(
- new DestinationIpv4Builder().setIpv4Prefixes(this.prefixes).build()).build();
- this.ip4caseAD = new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(this.prefixes).build()).build();
+ this.ip4caseWD = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207
+ .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder()
+ .setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(this.prefixes).build()).build();
+ this.ip4caseAD = new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder()
+ .setIpv4Prefixes(this.prefixes).build()).build();
final ArrayList<Ipv4Prefixes> fakePrefixes = new ArrayList<>(this.prefixes);
fakePrefixes.add(new Ipv4PrefixesBuilder().setPrefix(wrongPrefix).build());
- this.ip4caseWDWrong = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(
- new DestinationIpv4Builder().setIpv4Prefixes(fakePrefixes).build()).build();
- this.ip4caseADWrong = new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(fakePrefixes).build()).build();
+ this.ip4caseWDWrong = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207
+ .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder()
+ .setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(fakePrefixes).build()).build();
+ this.ip4caseADWrong = new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder()
+ .setIpv4Prefixes(fakePrefixes).build()).build();
final ByteBuf buffer1 = Unpooled.buffer(5);
ByteBufWriteUtil.writeMinimalPrefix(prefix1, buffer1);
final MpUnreachNlriBuilder b = new MpUnreachNlriBuilder();
b.setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class);
this.parser.parseNlri(this.inputBytes, b);
- assertNotNull("Withdrawn routes, destination type should not be null", b.getWithdrawnRoutes().getDestinationType());
+ assertNotNull("Withdrawn routes, destination type should not be null", b.getWithdrawnRoutes()
+ .getDestinationType());
assertEquals(this.ip4caseWD.hashCode(), b.getWithdrawnRoutes().getDestinationType().hashCode());
assertFalse(this.ip4caseWDWrong.hashCode() == b.getWithdrawnRoutes().getDestinationType().hashCode());
final MpReachNlriBuilder b = new MpReachNlriBuilder();
b.setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class);
this.parser.parseNlri(this.inputBytes, b);
- assertNotNull("Advertized routes, destination type should not be null", b.getAdvertizedRoutes().getDestinationType());
+ assertNotNull("Advertized routes, destination type should not be null", b.getAdvertizedRoutes()
+ .getDestinationType());
assertEquals(this.ip4caseAD.hashCode(), b.getAdvertizedRoutes().getDestinationType().hashCode());
assertFalse(this.ip4caseADWrong.hashCode() == b.getAdvertizedRoutes().getDestinationType().hashCode());
public void parseUnreachNlriMultiPathTest() {
final MpUnreachNlri mpUnreachNlri = new MpUnreachNlriBuilder().setWithdrawnRoutes(
new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(
- new DestinationIpv4Builder().setIpv4Prefixes(
- PREFIXES).build()).build()).build()).build();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder()
+ .setIpv4Prefixes(PREFIXES).build()).build()).build()).build();
final MpUnreachNlriBuilder mpUnreachNlriBuilder = new MpUnreachNlriBuilder();
mpUnreachNlriBuilder.setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class);
this.parser.parseNlri(Unpooled.wrappedBuffer(MP_NLRI_BYTES), mpUnreachNlriBuilder, this.constraint);
serializer.serializeAttribute(attributes, output);
Assert.assertArrayEquals(MP_NLRI_BYTES, output.array());
}
-
- private static Ipv4Prefixes createIpv4Prefix(final long pathId, final Ipv4Prefix prefix) {
- return new Ipv4PrefixesBuilder().setPathId(new PathId(pathId)).setPrefix(prefix).build();
- }
}
import io.netty.buffer.Unpooled;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.protocol.bgp.inet.codec.nexthop.Ipv4NextHopParserSerializer;
-import org.opendaylight.protocol.bgp.inet.codec.nexthop.Ipv6NextHopParserSerializer;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
public class NextHopParserSerializerTest {
- public static final byte[] ipv6lB = {0x20, 1, 0x0d, (byte) 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ private static final byte[] IPV6LB = {0x20, 1, 0x0d, (byte) 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, (byte) 0xfe, (byte) 0x80, 0, 0, 0, 0, 0, 0, (byte) 0xc0, 1, 0x0b, (byte) 0xff, (byte) 0xfe, 0x7e, 0, 0};
- public static final Ipv6Address ipv6 = new Ipv6Address("2001:db8::1");
- public static final Ipv6Address ipv6l = new Ipv6Address("fe80::c001:bff:fe7e:0");
+ private static final Ipv6Address IPV6 = new Ipv6Address("2001:db8::1");
+ private static final Ipv6Address IPV6L = new Ipv6Address("fe80::c001:bff:fe7e:0");
- Ipv4NextHopParserSerializer ipv4NextHopParserSerializer;
- Ipv6NextHopParserSerializer ipv6NextHopParserSerializer;
- CNextHop hop;
- ByteBuf buffer;
+ private Ipv4NextHopParserSerializer ipv4NextHopParserSerializer;
+ private Ipv6NextHopParserSerializer ipv6NextHopParserSerializer;
+ private CNextHop hop;
+ private ByteBuf buffer;
@Before
public final void setUp() {
@Test
public void testSerializeIpv6LinkNextHopCase() throws BGPParsingException {
- this.hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(ipv6).setLinkLocal(ipv6l).build()).build();
+ this.hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder()
+ .setGlobal(IPV6).setLinkLocal(IPV6L).build()).build();
this.buffer.clear();
this.ipv6NextHopParserSerializer.serializeNextHop(this.hop, this.buffer);
- assertArrayEquals(ipv6lB, ByteArray.readAllBytes(this.buffer));
+ assertArrayEquals(IPV6LB, ByteArray.readAllBytes(this.buffer));
- final CNextHop parsedHop = this.ipv6NextHopParserSerializer.parseNextHop(Unpooled.wrappedBuffer(ipv6lB));
+ final CNextHop parsedHop = this.ipv6NextHopParserSerializer.parseNextHop(Unpooled.wrappedBuffer(IPV6LB));
assertTrue(parsedHop instanceof Ipv6NextHopCase);
assertEquals(this.hop, parsedHop);
}