use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri 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(new AttributesReachBuilder().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.multiprotocol.rev180329.attributes.reach.MpReachNlri in project bgpcep by opendaylight.
the class VpnIpv6NlriParserTest method testMpReachNlri.
@Test
public void testMpReachNlri() throws BGPParsingException {
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv6AddressFamily.class);
mpBuilder.setSafi(MplsLabeledVpnSubsequentAddressFamily.class);
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(Collections.singletonList(new VpnDestinationBuilder(IPV6_VPN).setPathId(null).build())).build()).build()).build()).build();
final MpReachNlri mpReachExpected = mpBuilder.build();
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(MplsLabeledVpnSubsequentAddressFamily.class);
PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder, null);
assertEquals(mpReachExpected, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesReachBuilder().setMpReachNlri(mpReachExpected).build()).build(), output);
assertArrayEquals(REACH_NLRI, ByteArray.readAllBytes(output));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri in project bgpcep by opendaylight.
the class VpnIpv4NlriParserTest method testMpReachNlri.
@Test
public void testMpReachNlri() throws BGPParsingException {
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(MplsLabeledVpnSubsequentAddressFamily.class);
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(Collections.singletonList(new VpnDestinationBuilder(IPV4_VPN).setPathId(null).build())).build()).build()).build()).build();
final MpReachNlri mpReachExpected = mpBuilder.build();
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(MplsLabeledVpnSubsequentAddressFamily.class);
PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder, null);
assertEquals(mpReachExpected, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesReachBuilder().setMpReachNlri(mpReachExpected).build()).build(), output);
assertArrayEquals(REACH_NLRI, ByteArray.readAllBytes(output));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri in project bgpcep by opendaylight.
the class BmpRibInWriter method prefixesToMpReach.
/**
* Creates MPReach for the prefixes to be handled in the same way as linkstate routes.
*
* @param message Update message containing prefixes in NLRI
* @return MpReachNlri with prefixes from the nlri field
*/
private static MpReachNlri prefixesToMpReach(final UpdateMessage message) {
final List<Ipv4Prefixes> prefixes = message.getNlri().stream().map(n -> new Ipv4PrefixesBuilder().setPrefix(n.getPrefix()).setPathId(n.getPathId()).build()).collect(Collectors.toList());
final MpReachNlriBuilder b = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(prefixes).build()).build()).build());
if (message.getAttributes() != null) {
b.setCNextHop(message.getAttributes().getCNextHop());
}
return b.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri in project bgpcep by opendaylight.
the class SimpleRegistryTest method testMpReachWithZeroNextHop.
@Test
public void testMpReachWithZeroNextHop() throws BGPParsingException {
final NlriRegistry nlriReg = this.ctx.getNlriRegistry();
final byte[] mpReachBytes = { 0x00, 0x01, 0x01, 0x00, 0x00 };
final MpReachNlri mpReach = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
final ByteBuf buffer = Unpooled.buffer(mpReachBytes.length);
nlriReg.serializeMpReach(mpReach, buffer);
assertArrayEquals(mpReachBytes, buffer.array());
assertEquals(mpReach, nlriReg.parseMpReach(Unpooled.wrappedBuffer(mpReachBytes), CONSTRAINT));
}
Aggregations