use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder in project bgpcep by opendaylight.
the class LUNlriParserTest method testMpUnreachNlriIpv6Constraint.
@Test
public void testMpUnreachNlriIpv6Constraint() throws BGPParsingException {
final LUNlriParser parser = new LUNlriParser();
final MpUnreachNlriBuilder mpBuilder = new MpUnreachNlriBuilder();
mpBuilder.setAfi(Ipv6AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID).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().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(lu1)).build()).build()).build());
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(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();
// 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);
assertEquals(mpUnreachExpected1, testBuilder.build());
// test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
assertArrayEquals(LU_UNREACH_NLRI_IPV6_ADD_PATH, ByteArray.readAllBytes(output));
final ByteBuf output1 = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mpUnreachExpected1).build()).build(), output1);
assertArrayEquals(LU_UNREACH_NLRI_IPV6_ADD_PATH, ByteArray.readAllBytes(output1));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder in project bgpcep by opendaylight.
the class LUNlriParserTest method testMpUnreachNlriIpv4.
@Test
public void testMpUnreachNlriIpv4() throws BGPParsingException {
final LUNlriParser parser = new LUNlriParser();
final MpUnreachNlriBuilder mpBuilder = new MpUnreachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
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().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(Lists.newArrayList(lu1)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
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().setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
// test parser
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
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(new AttributesUnreachBuilder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
assertArrayEquals(LU_UNREACH_NLRI_IPV4, ByteArray.readAllBytes(output));
final ByteBuf output1 = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mpUnreachExpected1).build()).build(), output1);
assertArrayEquals(LU_UNREACH_NLRI_IPV4, ByteArray.readAllBytes(output1));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder in project bgpcep by opendaylight.
the class LUNlriParserTest method testMpUnreachNlriIpv4Constraint.
@Test
public void testMpUnreachNlriIpv4Constraint() throws BGPParsingException {
final LUNlriParser parser = new LUNlriParser();
final MpUnreachNlriBuilder mpBuilder = new MpUnreachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
final CLabeledUnicastDestination lu1 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID).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().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(Lists.newArrayList(lu1)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID).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().setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
// test parser
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);
assertEquals(mpUnreachExpected1, testBuilder.build());
// test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
assertArrayEquals(LU_UNREACH_NLRI_IPV4_ADD_PATH, ByteArray.readAllBytes(output));
final ByteBuf output1 = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mpUnreachExpected1).build()).build(), output1);
assertArrayEquals(LU_UNREACH_NLRI_IPV4_ADD_PATH, ByteArray.readAllBytes(output1));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder in project bgpcep by opendaylight.
the class L3vpnMcastIpv4NlriHandler method parseNlri.
@Override
public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new DestinationL3vpnMcastIpv4WithdrawnCaseBuilder().setDestinationIpv4L3vpnMcast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.l3vpn.mcast.ipv4.withdrawn._case.DestinationIpv4L3vpnMcastBuilder().setL3vpnMcastDestination(L3vpnMcastNlriSerializer.extractDest(nlri, mPathSupported)).build()).build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder in project bgpcep by opendaylight.
the class RouteTargetConstrainNlriHandler method parseNlri.
@Override
public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new DestinationRouteTargetConstrainWithdrawnCaseBuilder().setDestinationRouteTargetConstrain(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.route.target.constrain.withdrawn._case.DestinationRouteTargetConstrainBuilder().setRouteTargetConstrainDestination(parseNlriDestinations(nlri, mPathSupported)).build()).build()).build());
}
Aggregations