final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
- final MpReachNlriBuilder result = new MpReachNlriBuilder();
- result.setAfi(Ipv4AddressFamily.class);
- result.setSafi(FlowspecSubsequentAddressFamily.class);
+ final MpReachNlriBuilder result = new MpReachNlriBuilder()
+ .setAfi(Ipv4AddressFamily.VALUE)
+ .setSafi(FlowspecSubsequentAddressFamily.VALUE);
parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
final ByteBuf buffer = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder()
.addAugmentation(new AttributesReachBuilder()
- .setMpReachNlri(mp.setAfi(Ipv4AddressFamily.class).build())
+ .setMpReachNlri(mp.setAfi(Ipv4AddressFamily.VALUE).build())
.build())
.build(), buffer);
assertArrayEquals(REACHED_NLRI, ByteArray.readAllBytes(buffer));
- assertEquals("all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port "
- + "is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where "
- + "destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 ",
- fsParser.stringNlri(flows));
+ assertEquals("""
+ all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port \
+ is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where \
+ destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 \
+ """,
+ fsParser.stringNlri(flows));
}
private static void testFlows(final List<Flowspec> flows, final DestinationPrefixCase destinationPrefix,
final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
- final MpReachNlriBuilder result = new MpReachNlriBuilder();
- result.setAfi(Ipv4AddressFamily.class);
- result.setSafi(FlowspecSubsequentAddressFamily.class);
+ final MpReachNlriBuilder result = new MpReachNlriBuilder()
+ .setAfi(Ipv4AddressFamily.VALUE)
+ .setSafi(FlowspecSubsequentAddressFamily.VALUE);
parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, constraint);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
final ByteBuf buffer = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder()
.addAugmentation(new AttributesReachBuilder()
- .setMpReachNlri(mp.setAfi(Ipv4AddressFamily.class).build())
+ .setMpReachNlri(mp.setAfi(Ipv4AddressFamily.VALUE).build())
.build())
.build(), buffer);
assertArrayEquals(REACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
- assertEquals("all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port "
- + "is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where "
- + "destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 ",
- fsParser.stringNlri(flows));
+ assertEquals("""
+ all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port \
+ is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where \
+ destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 \
+ """,
+ fsParser.stringNlri(flows));
}
private static PortCase createPorts() {
@Test
public void testParseMpUnreachNlri() throws BGPParsingException {
final List<Flowspec> fs = new ArrayList<>();
- final MpUnreachNlriBuilder mp = new MpUnreachNlriBuilder();
final FlowspecBuilder builder = new FlowspecBuilder();
builder.setFlowspecType(fragment);
fs.add(builder.build());
- mp.setAfi(Ipv4AddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCaseBuilder()
- .setDestinationFlowspecIpv4(
- new DestinationFlowspecIpv4Builder()
+ final MpUnreachNlriBuilder mp = new MpUnreachNlriBuilder()
+ .setAfi(Ipv4AddressFamily.VALUE)
+ .setWithdrawnRoutes(new WithdrawnRoutesBuilder()
+ .setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec
+ .rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationFlowspecCaseBuilder().setDestinationFlowspecIpv4(new DestinationFlowspecIpv4Builder()
.setFlowspec(fs)
- .build()
- ).build()
- ).build()
- );
+ .build())
+ .build())
+ .build());
final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
- final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
- result.setAfi(Ipv4AddressFamily.class);
- result.setSafi(FlowspecSubsequentAddressFamily.class);
+ final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder()
+ .setAfi(Ipv4AddressFamily.VALUE)
+ .setSafi(FlowspecSubsequentAddressFamily.VALUE);
parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.build(), buffer);
assertArrayEquals(UNREACHED_NLRI, ByteArray.readAllBytes(buffer));
- assertEquals("all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 "
- + "or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 "
- + "AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' ",
- fsParser.stringNlri(flows));
-
+ assertEquals("""
+ all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 \
+ or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 \
+ AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' \
+ """,
+ fsParser.stringNlri(flows));
}
private static FlowspecType createFragment() {
builder.setFlowspecType(fragment);
fs.add(builder.build());
- mp.setAfi(Ipv4AddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
+ mp.setAfi(Ipv4AddressFamily.VALUE).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCaseBuilder()
.setDestinationFlowspecIpv4(
final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
- final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
- result.setAfi(Ipv4AddressFamily.class);
- result.setSafi(FlowspecSubsequentAddressFamily.class);
+ final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder()
+ .setAfi(Ipv4AddressFamily.VALUE)
+ .setSafi(FlowspecSubsequentAddressFamily.VALUE);
parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, constraint);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.build(), buffer);
assertArrayEquals(UNREACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
- assertEquals("all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 "
- + "or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 "
- + "AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' ",
- fsParser.stringNlri(flows));
-
+ assertEquals("""
+ all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 \
+ or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 \
+ AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' \
+ """,
+ fsParser.stringNlri(flows));
}
@Test
public void testBatchedFlowspecNlri() throws Exception {
final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
- final MpReachNlriBuilder result = new MpReachNlriBuilder();
- result.setAfi(Ipv4AddressFamily.class);
- result.setSafi(FlowspecSubsequentAddressFamily.class);
+ final MpReachNlriBuilder result = new MpReachNlriBuilder()
+ .setAfi(Ipv4AddressFamily.VALUE)
+ .setSafi(FlowspecSubsequentAddressFamily.VALUE);
parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_BATCHED), result, null);
final MpReachNlri nlri = result.build();
final List<Flowspec> flowspecList = ((DestinationFlowspecCase) nlri.getAdvertizedRoutes().getDestinationType())
- .getDestinationFlowspecIpv4().getFlowspec();
+ .getDestinationFlowspecIpv4().nonnullFlowspec();
assertEquals(3, flowspecList.size());
assertEquals("216.58.245.101/32", ((DestinationPrefixCase) flowspecList.get(0).getFlowspecType())
.getDestinationPrefix().getValue());