* 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.labeled.unicast;
import io.netty.buffer.ByteBuf;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlriBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
final AdvertizedRoutes routes = pathAttributes1.getMpReachNlri().getAdvertizedRoutes();
if (routes != null) {
final DestinationType destinationType = routes.getDestinationType();
- if ( destinationType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
- .labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLabeledUnicastCase){
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLabeledUnicastCase labeledUnicastCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLabeledUnicastCase) routes.getDestinationType();
- serializeNlri(labeledUnicastCase.getDestinationLabeledUnicast().getCLabeledUnicastDestination(), false, byteAggregator);
- } else if (destinationType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
- .labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv6LabeledUnicastCase) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv6LabeledUnicastCase labeledUnicastCase = ( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv6LabeledUnicastCase) routes.getDestinationType();
- serializeNlri(labeledUnicastCase.getDestinationIpv6LabeledUnicast().getCLabeledUnicastDestination(), false, byteAggregator);
+ if (destinationType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
+ .DestinationLabeledUnicastCase) {
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329
+ .update.attributes.mp.reach.nlri.advertized.routes.destination.type
+ .DestinationLabeledUnicastCase labeledUnicastCase = (org.opendaylight.yang.gen.v1.urn
+ .opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp
+ .reach.nlri.advertized.routes.destination.type.DestinationLabeledUnicastCase)
+ destinationType;
+ serializeNlri(labeledUnicastCase.getDestinationLabeledUnicast().getCLabeledUnicastDestination(),
+ false, byteAggregator);
+ } else if (destinationType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination
+ .type.DestinationIpv6LabeledUnicastCase) {
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329
+ .update.attributes.mp.reach.nlri.advertized.routes.destination.type
+ .DestinationIpv6LabeledUnicastCase labeledUnicastCase = (org.opendaylight.yang.gen.v1.urn
+ .opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp
+ .reach.nlri.advertized.routes.destination.type.DestinationIpv6LabeledUnicastCase)
+ destinationType;
+ serializeNlri(labeledUnicastCase.getDestinationIpv6LabeledUnicast().getCLabeledUnicastDestination(),
+ false, byteAggregator);
}
}
} else if (pathAttributes2 != null) {
final MpUnreachNlri mpUnreachNlri = pathAttributes2.getMpUnreachNlri();
- if (mpUnreachNlri.getWithdrawnRoutes() != null) {
- final DestinationType destinationType = mpUnreachNlri.getWithdrawnRoutes().getDestinationType();
+ final WithdrawnRoutes withDrawnRoutes = mpUnreachNlri.getWithdrawnRoutes();
+
+ if (withDrawnRoutes != null) {
+ final DestinationType destinationType = withDrawnRoutes.getDestinationType();
if (destinationType instanceof DestinationLabeledUnicastCase) {
final DestinationLabeledUnicastCase labeledUnicastCase = (DestinationLabeledUnicastCase)
- mpUnreachNlri.getWithdrawnRoutes().getDestinationType();
+ destinationType;
serializeNlri(labeledUnicastCase.getDestinationLabeledUnicast().getCLabeledUnicastDestination(),
true, byteAggregator);
- } else if(destinationType instanceof DestinationIpv6LabeledUnicastCase) {
+ } else if (destinationType instanceof DestinationIpv6LabeledUnicastCase) {
final DestinationIpv6LabeledUnicastCase labeledUnicastCase = (DestinationIpv6LabeledUnicastCase)
- mpUnreachNlri.getWithdrawnRoutes().getDestinationType();
+ destinationType;
serializeNlri(labeledUnicastCase.getDestinationIpv6LabeledUnicast().getCLabeledUnicastDestination(),
true, byteAggregator);
}
final IpPrefix prefix = dest.getPrefix();
// Serialize the length field
// Length field contains one Byte which represents the length of label stack and prefix in bits
- nlriByteBuf.writeByte((LABEL_LENGTH * (!isUnreachNlri ? labelStack.size() : 1) + getPrefixLength(prefix)) * Byte.SIZE);
+ nlriByteBuf.writeByte((LABEL_LENGTH * (!isUnreachNlri ? labelStack.size() : 1)
+ + getPrefixLength(prefix)) * Byte.SIZE);
serializeLabelStackEntries(labelStack, isUnreachNlri, nlriByteBuf);
serializePrefixField(prefix, nlriByteBuf);
public static void serializeLabelStackEntries(final List<LabelStack> stack, final boolean isUnreachNlri,
final ByteBuf buffer) {
if (!isUnreachNlri) {
- int i = 1;
+ int entry = 1;
for (final LabelStack labelStackEntry : stack) {
- if (i++ == stack.size()) {
+ if (entry++ == stack.size()) {
// mark last label stack entry with bottom-bit
buffer.writeBytes(MplsLabelUtil.byteBufForMplsLabelWithBottomBit(labelStackEntry.getLabelValue()));
} else {
return ByteArray.readAllBytes(buffer);
}
- private static List<CLabeledUnicastDestination> parseNlri(final ByteBuf nlri, final Class<? extends AddressFamily> afi, final boolean mPathSupported) {
- if (!nlri.isReadable()) {
- return null;
- }
- final List<CLabeledUnicastDestination> dests = new ArrayList<>();
-
- while (nlri.isReadable()) {
- final CLabeledUnicastDestinationBuilder builder = new CLabeledUnicastDestinationBuilder();
- if (mPathSupported) {
- builder.setPathId(PathIdUtil.readPathId(nlri));
- }
- final short length = nlri.readUnsignedByte();
- final List<LabelStack> labels = parseLabel(nlri);
- builder.setLabelStack(labels);
- final int labelNum = labels != null ? labels.size() : 1;
- final int prefixLen = length - LABEL_LENGTH * Byte.SIZE * labelNum;
- builder.setPrefix(parseIpPrefix(nlri, prefixLen, afi));
- dests.add(builder.build());
- }
- return dests;
- }
-
- public static IpPrefix parseIpPrefix(final ByteBuf nlri, final int prefixLen, final Class<? extends AddressFamily> afi) {
+ public static IpPrefix parseIpPrefix(final ByteBuf nlri, final int prefixLen,
+ final Class<? extends AddressFamily> afi) {
final int prefixLenInByte = prefixLen / Byte.SIZE + (prefixLen % Byte.SIZE == 0 ? 0 : 1);
if (afi.equals(Ipv4AddressFamily.class)) {
return new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.readBytes(nlri, prefixLenInByte), prefixLen));
return labels;
}
+ private static List<CLabeledUnicastDestination> parseNlri(final ByteBuf nlri,
+ final Class<? extends AddressFamily> afi, final boolean multiPathSupported) {
+ if (!nlri.isReadable()) {
+ return null;
+ }
+ final List<CLabeledUnicastDestination> dests = new ArrayList<>();
+
+ while (nlri.isReadable()) {
+ final CLabeledUnicastDestinationBuilder builder = new CLabeledUnicastDestinationBuilder();
+ if (multiPathSupported) {
+ builder.setPathId(PathIdUtil.readPathId(nlri));
+ }
+ final short length = nlri.readUnsignedByte();
+ final List<LabelStack> labels = parseLabel(nlri);
+ builder.setLabelStack(labels);
+ final int labelNum = labels != null ? labels.size() : 1;
+ final int prefixLen = length - LABEL_LENGTH * Byte.SIZE * labelNum;
+ builder.setPrefix(parseIpPrefix(nlri, prefixLen, afi));
+ dests.add(builder.build());
+ }
+ return dests;
+ }
+
@Override
public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder,
final PeerSpecificParserConstraint constraint) throws BGPParsingException {
return;
}
final Class<? extends AddressFamily> afi = builder.getAfi();
- final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint,
+ final boolean multiPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint,
new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
- final List<CLabeledUnicastDestination> dst = parseNlri(nlri, afi, mPathSupported);
+ final List<CLabeledUnicastDestination> dst = parseNlri(nlri, afi, multiPathSupported);
DestinationType destination = null;
- if(afi == Ipv4AddressFamily.class){
+ if (afi == Ipv4AddressFamily.class) {
destination = new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(dst).build()).build();
- } else if(afi == Ipv6AddressFamily.class) {
+ } else if (afi == Ipv6AddressFamily.class) {
destination = new DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
new DestinationIpv6LabeledUnicastBuilder()
.setCLabeledUnicastDestination(dst).build()).build();
}
@Override
- public void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpUnreachNlriBuilder builder, @Nullable final PeerSpecificParserConstraint constraint) throws BGPParsingException {
+ public void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpUnreachNlriBuilder builder,
+ @Nullable final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final Class<? extends AddressFamily> afi = builder.getAfi();
- final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
+ final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint,
+ new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
final List<CLabeledUnicastDestination> dst = parseNlri(nlri, afi, mPathSupported);
DestinationType destination = null;
if (afi == Ipv4AddressFamily.class) {
- destination = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp
- .unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder()
- .setCLabeledUnicastDestination(dst).build()).build();
+ destination = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast
+ .rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast
+ .rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination
+ .labeled.unicast._case.DestinationLabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(dst).build()).build();
} else if (afi == Ipv6AddressFamily.class) {
- destination = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp
- .unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
- .setCLabeledUnicastDestination(dst).build()).build();
+ destination = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast
+ .rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast
+ .rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.ipv6
+ .labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(dst).build()).build();
}
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(destination).build());
}
public class LUNlriParserTest {
- /*label stacks with multiple labels.
+ /*
+ * label stacks with multiple labels.
*
* label stack:
* 60 <- length 96
* 1 <- bottomBit 1
* 22 01 16 <- prefixType IPV4=34.1.22.0/24
*/
- private static final byte[] LU_REACH_NLRI_IPv4 = new byte[]{
+ private static final byte[] LU_REACH_NLRI_IPV4 = new byte[]{
(byte) 0x60,
(byte) 0x00, (byte) 0x16, (byte) 0x30,
(byte) 0x00, (byte) 0x16, (byte) 0x40,
(byte) 0x22, (byte) 0x01, (byte) 0x16,
};
- /*label value for withdraw message.
- *
- * label stack:
- * 30 <- length 48
- * 80 00 00 <- labelValue for withdraw
- * 22 01 16 <- prefixType IPV4=34.1.22.0/24
- */
- private static final byte[] LU_UNREACH_NLRI_IPv4 = new byte[] {
- (byte) 0x30,
- (byte) 0x80, (byte) 0x00, (byte) 0x00,
- (byte) 0x22, (byte) 0x01, (byte) 0x16,
- };
-
- /*label stacks with multiple labels.
- *
- * label stack:
- * 1 <- Path Id
- * 60 <- length 96
- * 00 16 3 <- labelValue 355
- * 0 <- etc&bottomBit 0
- * 00 16 4 <- labelValue 356
- * 0 <- etc&bottomBit 0
- * 00 16 6 <- labelValue 357
- * 1 <- bottomBit 1
- * 22 01 16 <- prefixType IPV4=34.1.22.0/24
- */
- private static final byte[] LU_REACH_NLRI_IPv4_ADD_PATH = new byte[]{
+ /*
+ * label value for withdraw message.
+ *
+ * label stack:
+ * 30 <- length 48
+ * 80 00 00 <- labelValue for withdraw
+ * 22 01 16 <- prefixType IPV4=34.1.22.0/24
+ */
+ private static final byte[] LU_UNREACH_NLRI_IPV4 = new byte[] {
+ (byte) 0x30,
+ (byte) 0x80, (byte) 0x00, (byte) 0x00,
+ (byte) 0x22, (byte) 0x01, (byte) 0x16,
+ };
+
+ /*
+ * label stacks with multiple labels.
+ *
+ * label stack:
+ * 1 <- Path Id
+ * 60 <- length 96
+ * 00 16 3 <- labelValue 355
+ * 0 <- etc&bottomBit 0
+ * 00 16 4 <- labelValue 356
+ * 0 <- etc&bottomBit 0
+ * 00 16 6 <- labelValue 357
+ * 1 <- bottomBit 1
+ * 22 01 16 <- prefixType IPV4=34.1.22.0/24
+ */
+ private static final byte[] LU_REACH_NLRI_IPV4_ADD_PATH = new byte[]{
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
(byte) 0x60,
(byte) 0x00, (byte) 0x16, (byte) 0x30,
(byte) 0x22, (byte) 0x01, (byte) 0x16,
};
- /*label value for withdraw message.
- *
- * label stack:
- * 1 <- Path Id
- * 30 <- length 48
- * 80 00 00 <- labelValue for withdraw
- * 22 01 16 <- prefixType IPV4=34.1.22.0/24
- */
- private static final byte[] LU_UNREACH_NLRI_IPv4_ADD_PATH = new byte[] {
+ /*
+ * label value for withdraw message.
+ *
+ * label stack:
+ * 1 <- Path Id
+ * 30 <- length 48
+ * 80 00 00 <- labelValue for withdraw
+ * 22 01 16 <- prefixType IPV4=34.1.22.0/24
+ */
+ private static final byte[] LU_UNREACH_NLRI_IPV4_ADD_PATH = new byte[] {
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
(byte) 0x30,
(byte) 0x80, (byte) 0x00, (byte) 0x00,
(byte) 0x22, (byte) 0x01, (byte) 0x16,
};
- /*label stacks with multiple labels.
+ /*
+ * label stacks with multiple labels.
*
* label stack:
* C8 <- length 200
* 1 <- bottomBit 1
* 20 01 D B8 0 1 0 2 0 0 0 0 0 0 0 0 80 <- prefixType IPV6=2001:db8:1:2::/128
*/
- private static final byte[] LU_REACH_NLRI_IPv6 = new byte[]{
+ private static final byte[] LU_REACH_NLRI_IPV6 = new byte[]{
(byte) 0xC8,
(byte) 0x00, (byte) 0x16, (byte) 0x30,
(byte) 0x00, (byte) 0x16, (byte) 0x40,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
};
- /*label value for withdraw message.
- *
- * label stack:
- * 98 <- length 152
- * 80 00 00 <- labelValue for withdraw
- * 20 01 D B8 0 1 0 2 0 0 0 0 0 0 0 0 80 <- prefixType IPV6=2001:db8:1:2::/128
- */
- private static final byte[] LU_UNREACH_NLRI_IPv6 = new byte[] {
- (byte) 0x98,
- (byte) 0x80, (byte) 0x00, (byte) 0x00,
- (byte) 0x20, (byte) 0x01, (byte) 0x0d, (byte) 0xb8,
- (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x02,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- };
-
- /*label stacks with multiple labels.
+ /*
+ * label value for withdraw message.
+ *
+ * label stack:
+ * 98 <- length 152
+ * 80 00 00 <- labelValue for withdraw
+ * 20 01 D B8 0 1 0 2 0 0 0 0 0 0 0 0 80 <- prefixType IPV6=2001:db8:1:2::/128
+ */
+ private static final byte[] LU_UNREACH_NLRI_IPV6 = new byte[] {
+ (byte) 0x98,
+ (byte) 0x80, (byte) 0x00, (byte) 0x00,
+ (byte) 0x20, (byte) 0x01, (byte) 0x0d, (byte) 0xb8,
+ (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x02,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ };
+
+ /*
+ * label stacks with multiple labels.
*
* label stack:
* C8 <- length 200
* 1 <- bottomBit 1
* 20 01 D B8 0 1 0 2 0 0 0 0 0 0 0 0 80 <- prefixType IPV6=2001:db8:1:2::/128
*/
- private static final byte[] LU_REACH_NLRI_IPv6_ADD_PATH = new byte[]{
+ private static final byte[] LU_REACH_NLRI_IPV6_ADD_PATH = new byte[]{
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
(byte) 0xC8,
(byte) 0x00, (byte) 0x16, (byte) 0x30,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
};
- /*label value for withdraw message.
- *
- * label stack:
- * 98 <- length 152
- * 80 00 00 <- labelValue for withdraw
- * 20 01 D B8 0 1 0 2 0 0 0 0 0 0 0 0 80 <- prefixType IPV6=2001:db8:1:2::/128
- */
- private static final byte[] LU_UNREACH_NLRI_IPv6_ADD_PATH = new byte[] {
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
- (byte) 0x98,
- (byte) 0x80, (byte) 0x00, (byte) 0x00,
- (byte) 0x20, (byte) 0x01, (byte) 0x0d, (byte) 0xb8,
- (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x02,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- };
+ /*
+ * label value for withdraw message.
+ *
+ * label stack:
+ * 98 <- length 152
+ * 80 00 00 <- labelValue for withdraw
+ * 20 01 D B8 0 1 0 2 0 0 0 0 0 0 0 0 80 <- prefixType IPV6=2001:db8:1:2::/128
+ */
+ private static final byte[] LU_UNREACH_NLRI_IPV6_ADD_PATH = new byte[] {
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
+ (byte) 0x98,
+ (byte) 0x80, (byte) 0x00, (byte) 0x00,
+ (byte) 0x20, (byte) 0x01, (byte) 0x0d, (byte) 0xb8,
+ (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x02,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ };
private static final List<LabelStack> LABEL_STACK = Lists.newArrayList(
new LabelStackBuilder().setLabelValue(new MplsLabel(355L)).build(),
new LabelStackBuilder().setLabelValue(new MplsLabel(356L)).build(),
new LabelStackBuilder().setLabelValue(new MplsLabel(357L)).build());
- private static final IpPrefix IPv4_PREFIX = new IpPrefix(new Ipv4Prefix("34.1.22.0/24"));
- private static final IpPrefix IPv6_PREFIX = new IpPrefix(new Ipv6Prefix("2001:db8:1:2::/128"));
+ private static final IpPrefix IPV4_PREFIX = new IpPrefix(new Ipv4Prefix("34.1.22.0/24"));
+ private static final IpPrefix IPV6_PREFIX = new IpPrefix(new Ipv6Prefix("2001:db8:1:2::/128"));
private static final PathId PATH_ID = new PathId(1L);
@Mock
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPrefix(IPv4_PREFIX)
+ final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPrefix(IPV4_PREFIX)
.setLabelStack(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv4), testBuilder, null);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPV4), testBuilder, null);
assertEquals(mpReachExpected, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
- assertArrayEquals(LU_REACH_NLRI_IPv4, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_REACH_NLRI_IPV4, ByteArray.readAllBytes(output));
}
@Test
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
- .setPrefix(IPv4_PREFIX).setLabelStack
- (LABEL_STACK).build();
+ .setPrefix(IPV4_PREFIX).setLabelStack(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu))
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv4_ADD_PATH), testBuilder, this.constraint);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPV4_ADD_PATH), testBuilder, this.constraint);
assertEquals(mpReachExpected, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
- assertArrayEquals(LU_REACH_NLRI_IPv4_ADD_PATH, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_REACH_NLRI_IPV4_ADD_PATH, ByteArray.readAllBytes(output));
}
@Test
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPrefix(IPv4_PREFIX).build();
+ final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPrefix(IPV4_PREFIX).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder()
.build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
- final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPrefix(IPv4_PREFIX)
+ final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPrefix(IPV4_PREFIX)
.setLabelStack(LABEL_STACK).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder()
.setDestinationLabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
- .labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- destination.labeled.unicast._case.DestinationLabeledUnicastBuilder()
+ .labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .destination.labeled.unicast._case.DestinationLabeledUnicastBuilder()
.setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build())
.build()).build());
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv4), testBuilder, null);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPV4), testBuilder, null);
assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
- assertArrayEquals(LU_UNREACH_NLRI_IPv4, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_UNREACH_NLRI_IPV4, ByteArray.readAllBytes(output));
final ByteBuf output1 = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected1).build()).build(), output1);
- assertArrayEquals(LU_UNREACH_NLRI_IPv4, ByteArray.readAllBytes(output1));
+ assertArrayEquals(LU_UNREACH_NLRI_IPV4, ByteArray.readAllBytes(output1));
}
@Test
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
- .setPrefix(IPv4_PREFIX).build();
+ .setPrefix(IPV4_PREFIX).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder()
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
- .setPrefix(IPv4_PREFIX).setLabelStack(LABEL_STACK).build();
+ .setPrefix(IPV4_PREFIX).setLabelStack(LABEL_STACK).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder()
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv4_ADD_PATH), testBuilder, this.constraint);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPV4_ADD_PATH), testBuilder, this.constraint);
assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
- assertArrayEquals(LU_UNREACH_NLRI_IPv4_ADD_PATH, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_UNREACH_NLRI_IPV4_ADD_PATH, ByteArray.readAllBytes(output));
final ByteBuf output1 = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected1).build()).build(), output1);
- assertArrayEquals(LU_UNREACH_NLRI_IPv4_ADD_PATH, ByteArray.readAllBytes(output1));
+ assertArrayEquals(LU_UNREACH_NLRI_IPV4_ADD_PATH, ByteArray.readAllBytes(output1));
}
@Test
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv6AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPrefix(IPv6_PREFIX)
+ final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPrefix(IPV6_PREFIX)
.setLabelStack(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationIpv6LabeledUnicastCaseBuilder()
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv6), testBuilder, null);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPV6), testBuilder, null);
assertEquals(mpReachExpected, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
- assertArrayEquals(LU_REACH_NLRI_IPv6, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_REACH_NLRI_IPV6, ByteArray.readAllBytes(output));
}
@Test
mpBuilder.setAfi(Ipv6AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
- .setPrefix(IPv6_PREFIX).setLabelStack(LABEL_STACK).build();
+ .setPrefix(IPV6_PREFIX).setLabelStack(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
new DestinationIpv6LabeledUnicastBuilder()
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv6_ADD_PATH), testBuilder, this.constraint);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPV6_ADD_PATH), testBuilder, this.constraint);
assertEquals(mpReachExpected, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class,
new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
- assertArrayEquals(LU_REACH_NLRI_IPv6_ADD_PATH, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_REACH_NLRI_IPV6_ADD_PATH, ByteArray.readAllBytes(output));
}
@Test
mpBuilder.setAfi(Ipv6AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPrefix(IPv6_PREFIX).build();
+ final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPrefix(IPV6_PREFIX).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder()
.setCLabeledUnicastDestination(Lists.newArrayList(lu1)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
- final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPrefix(IPv6_PREFIX)
+ final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPrefix(IPV6_PREFIX)
.setLabelStack(LABEL_STACK).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1
.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv6), testBuilder, null);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPV6), testBuilder, null);
assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
- assertArrayEquals(LU_UNREACH_NLRI_IPv6, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_UNREACH_NLRI_IPV6, ByteArray.readAllBytes(output));
final ByteBuf output1 = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected1).build()).build(), output1);
- assertArrayEquals(LU_UNREACH_NLRI_IPv6, ByteArray.readAllBytes(output1));
+ assertArrayEquals(LU_UNREACH_NLRI_IPV6, ByteArray.readAllBytes(output1));
}
@Test
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
- .setPrefix(IPv6_PREFIX).build();
+ .setPrefix(IPV6_PREFIX).build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder()
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
- .setPrefix(IPv6_PREFIX).setLabelStack(LABEL_STACK).build();
- mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
+ .setPrefix(IPV6_PREFIX).setLabelStack(LABEL_STACK).build();
+ mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329
+ .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329
- .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
- .DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329
- .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled
- .unicast._case.DestinationIpv6LabeledUnicastBuilder()
- .setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build()).build()).build());
- final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
+ .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled
+ .unicast._case.DestinationIpv6LabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build()).build()).build());
+ final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
//test parser
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPv6_ADD_PATH), testBuilder, this.constraint);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPV6_ADD_PATH), testBuilder, this.constraint);
assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
- assertArrayEquals(LU_UNREACH_NLRI_IPv6_ADD_PATH, ByteArray.readAllBytes(output));
+ assertArrayEquals(LU_UNREACH_NLRI_IPV6_ADD_PATH, ByteArray.readAllBytes(output));
final ByteBuf output1 = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreachExpected1).build()).build(), output1);
- assertArrayEquals(LU_UNREACH_NLRI_IPv6_ADD_PATH, ByteArray.readAllBytes(output1));
+ assertArrayEquals(LU_UNREACH_NLRI_IPV6_ADD_PATH, ByteArray.readAllBytes(output1));
}
}