use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder in project bgpcep by opendaylight.
the class EvpnNlriAttributesParserTest method testAttributes1.
@Test
public void testAttributes1() throws BGPParsingException {
final ByteBuf buffer = Unpooled.buffer();
final Attributes att = new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(createReach()).build()).build();
this.parser.serializeAttribute(att, buffer);
Assert.assertArrayEquals(IncMultEthTagRParserTest.RESULT, ByteArray.getAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder in project bgpcep by opendaylight.
the class BGPMessageParserMockTest method fillMessages.
/**
* Helper method to fill messages variable.
*
* @param asn this parameter is passed to ASNumber constructor
*/
private static Update fillMessages(final long asn) {
final UpdateBuilder builder = new UpdateBuilder();
final List<Segments> asPath = Lists.newArrayList();
asPath.add(new SegmentsBuilder().setAsSequence(Lists.newArrayList(new AsNumber(asn))).build());
final CNextHop nextHop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8::1")).setLinkLocal(new Ipv6Address("fe80::c001:bff:fe7e:0")).build()).build();
final Ipv6Prefix pref1 = new Ipv6Prefix("2001:db8:1:2::/64");
final Ipv6Prefix pref2 = new Ipv6Prefix("2001:db8:1:1::/64");
final Ipv6Prefix pref3 = new Ipv6Prefix("2001:db8:1::/64");
final AttributesBuilder paBuilder = new AttributesBuilder();
paBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
paBuilder.setAsPath(new AsPathBuilder().setSegments(asPath).build());
final MpReachNlriBuilder mpReachBuilder = new MpReachNlriBuilder();
mpReachBuilder.setAfi(Ipv6AddressFamily.class);
mpReachBuilder.setSafi(UnicastSubsequentAddressFamily.class);
mpReachBuilder.setCNextHop(nextHop);
mpReachBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv6CaseBuilder().setDestinationIpv6(new DestinationIpv6Builder().setIpv6Prefixes(Lists.newArrayList(new Ipv6PrefixesBuilder().setPrefix(pref1).build(), new Ipv6PrefixesBuilder().setPrefix(pref2).build(), new Ipv6PrefixesBuilder().setPrefix(pref3).build())).build()).build()).build());
paBuilder.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpReachBuilder.build()).build());
builder.setAttributes(paBuilder.build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder in project bgpcep by opendaylight.
the class SimpleFlowspecIpv4NlriParserTest method testParseMpReachNlriConstraint.
@Test
public void testParseMpReachNlriConstraint() throws BGPParsingException {
final List<Flowspec> fs = new ArrayList<>();
final MpReachNlriBuilder mp = new MpReachNlriBuilder();
final FlowspecBuilder builder = new FlowspecBuilder();
final DestinationPrefixCase destinationPrefix = new DestinationPrefixCaseBuilder().setDestinationPrefix(new Ipv4Prefix("10.0.1.0/32")).build();
builder.setFlowspecType(destinationPrefix);
fs.add(builder.build());
final SourcePrefixCase sourcePrefix = new SourcePrefixCaseBuilder().setSourcePrefix(new Ipv4Prefix("1.2.3.4/32")).build();
builder.setFlowspecType(sourcePrefix);
fs.add(builder.build());
final FlowspecType prots = createProts();
builder.setFlowspecType(prots);
fs.add(builder.build());
final PortCase ps = createPorts();
builder.setFlowspecType(ps);
fs.add(builder.build());
final FlowspecType dps = createDps();
builder.setFlowspecType(dps);
fs.add(builder.build());
final FlowspecType sps = createSps();
builder.setFlowspecType(sps);
fs.add(builder.build());
mp.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecCaseBuilder().setDestinationFlowspec(new DestinationFlowspecBuilder().setPathId(PATH_ID).setFlowspec(fs).build()).build()).build());
final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(this.flowspecContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC));
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, this.constraint);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecCase) result.getAdvertizedRoutes().getDestinationType()).getDestinationFlowspec().getFlowspec();
testFlows(flows, destinationPrefix, sourcePrefix, prots, ps, dps, sps);
final ByteBuf buffer = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mp.setAfi(Ipv4AddressFamily.class).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 ", this.FS_PARSER.stringNlri(flows));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder in project bgpcep by opendaylight.
the class SimpleFlowspecIpv6NlriParserTest method testParseMpReachNlriConstraint.
@Test
public void testParseMpReachNlriConstraint() throws BGPParsingException {
final List<Flowspec> fs = new ArrayList<>();
final MpReachNlriBuilder mp = new MpReachNlriBuilder();
final FlowspecBuilder builder = new FlowspecBuilder();
final DestinationIpv6PrefixCase destinationPrefix = new DestinationIpv6PrefixCaseBuilder().setDestinationPrefix(new Ipv6Prefix("102:304:500::/40")).build();
builder.setFlowspecType(destinationPrefix);
fs.add(builder.build());
final SourceIpv6PrefixCase sourcePrefix = new SourceIpv6PrefixCaseBuilder().setSourcePrefix(new Ipv6Prefix("102:304:600::/40")).build();
builder.setFlowspecType(sourcePrefix);
fs.add(builder.build());
final List<NextHeaders> nextheaders = Lists.newArrayList(new NextHeadersBuilder().setOp(new NumericOperand(false, true, true, false, false)).setValue((short) 6).build());
final NextHeaderCase headersCase = new NextHeaderCaseBuilder().setNextHeaders(nextheaders).build();
builder.setFlowspecType(headersCase);
fs.add(builder.build());
mp.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecIpv6CaseBuilder().setDestinationFlowspec(new DestinationFlowspecBuilder().setPathId(PATH_ID).setFlowspec(fs).build()).build()).build());
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, this.constraint);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecIpv6Case) result.getAdvertizedRoutes().getDestinationType()).getDestinationFlowspec().getFlowspec();
assertEquals(3, flows.size());
assertEquals(destinationPrefix, flows.get(0).getFlowspecType());
assertEquals(sourcePrefix, flows.get(1).getFlowspecType());
assertEquals(headersCase, flows.get(2).getFlowspecType());
final ByteBuf buffer = Unpooled.buffer();
this.FS_PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mp.setAfi(Ipv6AddressFamily.class).build()).build()).build(), buffer);
assertArrayEquals(REACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
assertEquals("all packets to 102:304:500::/40 AND from 102:304:600::/40 AND where next header equals to 6 ", this.FS_PARSER.stringNlri(flows));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv4NlriParserTest method testParseMpReachNlriConstraint.
@Test
public void testParseMpReachNlriConstraint() throws BGPParsingException {
final List<Flowspec> fs = new ArrayList<>();
final MpReachNlriBuilder mp = new MpReachNlriBuilder();
final FlowspecBuilder builder = new FlowspecBuilder();
final DestinationPrefixCase destinationPrefix = new DestinationPrefixCaseBuilder().setDestinationPrefix(new Ipv4Prefix("10.0.1.0/32")).build();
builder.setFlowspecType(destinationPrefix);
fs.add(builder.build());
final SourcePrefixCase sourcePrefix = new SourcePrefixCaseBuilder().setSourcePrefix(new Ipv4Prefix("1.2.3.4/32")).build();
builder.setFlowspecType(sourcePrefix);
fs.add(builder.build());
final FlowspecType prots = createProts();
builder.setFlowspecType(prots);
fs.add(builder.build());
final PortCase ps = createPorts();
builder.setFlowspecType(ps);
fs.add(builder.build());
final FlowspecType dps = createDps();
builder.setFlowspecType(dps);
fs.add(builder.build());
final FlowspecType sps = createSps();
builder.setFlowspecType(sps);
fs.add(builder.build());
final FlowspecL3vpnIpv4NlriParser parser = new FlowspecL3vpnIpv4NlriParser(this.flowspecContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN));
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, this.constraint);
final DestinationFlowspecL3vpnIpv4 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv4Case) result.getAdvertizedRoutes().getDestinationType()).getDestinationFlowspecL3vpnIpv4();
final List<Flowspec> flows = flowspecDst.getFlowspec();
final RouteDistinguisher rd = flowspecDst.getRouteDistinguisher();
testFlows(flows, destinationPrefix, sourcePrefix, prots, rd, ps, dps, sps);
mp.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv4CaseBuilder().setDestinationFlowspecL3vpnIpv4(new DestinationFlowspecL3vpnIpv4Builder().setRouteDistinguisher(rd).setPathId(PATH_ID).setFlowspec(fs).build()).build()).build());
final ByteBuf buffer = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mp.setAfi(Ipv4AddressFamily.class).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 ", this.FS_PARSER.stringNlri(flows));
}
Aggregations