use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLabeledUnicastCaseBuilder in project bgpcep by opendaylight.
the class LUNlriParserTest method testMpReachNlriIpv4.
@Test
public void testMpReachNlriIpv4() throws BGPParsingException {
final LUNlriParser parser = new LUNlriParser();
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPrefix(IPv4_PREFIX).setLabelStack(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu)).build()).build()).build());
final MpReachNlri mpReachExpected = mpBuilder.build();
// test parser
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPv4), testBuilder);
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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLabeledUnicastCaseBuilder in project bgpcep by opendaylight.
the class LUNlriParserTest method testMpReachNlriIpv4Constraint.
@Test
public void testMpReachNlriIpv4Constraint() throws BGPParsingException {
final LUNlriParser parser = new LUNlriParser();
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID).setPrefix(IPv4_PREFIX).setLabelStack(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu)).build()).build()).build());
final MpReachNlri mpReachExpected = mpBuilder.build();
// test parser
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);
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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLabeledUnicastCaseBuilder in project bgpcep by opendaylight.
the class LUNlriParser method parseNlri.
@Override
public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder, 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 List<CLabeledUnicastDestination> dst = parseNlri(nlri, afi, mPathSupported);
DestinationType destination = null;
if (afi == Ipv4AddressFamily.class) {
destination = new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(dst).build()).build();
} else if (afi == Ipv6AddressFamily.class) {
destination = new DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(new DestinationIpv6LabeledUnicastBuilder().setCLabeledUnicastDestination(dst).build()).build();
}
builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(destination).build());
}
Aggregations