use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder in project bgpcep by opendaylight.
the class MultiPathAbstractRIBSupportTest method buildUpdate.
@Test
public void buildUpdate() {
final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.2")).build()).build();
final Attributes attr = new AttributesBuilder().setCNextHop(nextHop).build();
final Collection<MapEntryNode> routes = new HashSet<>();
assertEquals(new UpdateBuilder().setAttributes(new AttributesBuilder().build()).build(), MULTI_PATH_ABSTRACT_TEST.buildUpdate(routes, routes, attr));
routes.add(this.mapEntryNode);
final MpReachNlri mpReach = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setCNextHop(nextHop).setAdvertizedRoutes(new AdvertizedRoutesBuilder().build()).build();
final Attributes attMpR = new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpReach).build()).build();
assertEquals(new UpdateBuilder().setAttributes(attMpR).build(), MULTI_PATH_ABSTRACT_TEST.buildUpdate(routes, Collections.emptySet(), attr));
final MpUnreachNlri mpUnreach = new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().build()).build();
final Attributes attMpU = new AttributesBuilder().addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(mpUnreach).build()).build();
assertEquals(new UpdateBuilder().setAttributes(attMpU).build(), MULTI_PATH_ABSTRACT_TEST.buildUpdate(Collections.emptySet(), routes, attr));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder in project bgpcep by opendaylight.
the class EvpnNlriParser method parseNlri.
@Override
public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final List<EvpnDestination> dst = parseNlri(nlri);
builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationEvpnCaseBuilder().setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(dst).build()).build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder in project bgpcep by opendaylight.
the class AbstractRIBSupport method buildReach.
/**
* Build MpReachNlri object from DOM representation.
*
* @param routes Collection of MapEntryNode DOM representation of routes
* @param hop CNextHop as it was parsed from Attributes, to be included in MpReach object
* @return MpReachNlri
*/
private MpReachNlri buildReach(final Collection<MapEntryNode> routes, final CNextHop hop) {
final MpReachNlriBuilder mb = new MpReachNlriBuilder();
mb.setAfi(this.getAfi());
mb.setSafi(this.getSafi());
mb.setCNextHop(hop);
mb.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(buildDestination(routes)).build());
return mb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder 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.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(Collections.singletonList(IPV4_VPN)).build()).build()).build()).build();
final MpReachNlri mpReachExpected = mpBuilder.build();
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder);
Assert.assertEquals(mpReachExpected, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
Assert.assertArrayEquals(REACH_NLRI, ByteArray.readAllBytes(output));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder 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.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(Collections.singletonList(IPV6_VPN)).build()).build()).build()).build();
final MpReachNlri mpReachExpected = mpBuilder.build();
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder);
Assert.assertEquals(mpReachExpected, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
Assert.assertArrayEquals(REACH_NLRI, ByteArray.readAllBytes(output));
}
Aggregations