use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6 in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv6NlriParserTest method testParseMpUnreachNlri.
@Test
public void testParseMpUnreachNlri() throws BGPParsingException {
final List<Flowspec> fs = new ArrayList<>();
final MpUnreachNlriBuilder mp = new MpUnreachNlriBuilder();
final FlowspecBuilder builder = new FlowspecBuilder();
final FragmentCase fragment = createFragment();
builder.setFlowspecType(fragment);
fs.add(builder.build());
final FlowspecType label = createLabel();
builder.setFlowspecType(label);
fs.add(builder.build());
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
this.fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
final DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) result.getWithdrawnRoutes().getDestinationType()).getDestinationFlowspecL3vpnIpv6();
final List<Flowspec> flows = flowspecDst.getFlowspec();
final RouteDistinguisher rd = flowspecDst.getRouteDistinguisher();
assertEquals(2, flows.size());
assertEquals(ROUTE_DISTINGUISHER, rd.stringValue());
assertEquals(fragment, flows.get(0).getFlowspecType());
assertEquals(label, flows.get(1).getFlowspecType());
mp.setAfi(Ipv6AddressFamily.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.DestinationFlowspecL3vpnIpv6CaseBuilder().setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder().setRouteDistinguisher(rd).setFlowspec(fs).build()).build()).build());
final ByteBuf buffer = Unpooled.buffer();
this.fsParser.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build()).build(), buffer);
assertArrayEquals(UNREACHED_NLRI, ByteArray.readAllBytes(buffer));
assertEquals("all packets where fragment does match 'IS FIRST' 'IS LAST' 'IS A' AND where flow label equals to " + "16777222 or equals to 258 ", this.fsParser.stringNlri(flows));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6 in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv6NlriParser method serializeMpUnreachNlri.
@Override
protected void serializeMpUnreachNlri(final DestinationType dstType, final ByteBuf byteAggregator) {
if (dstType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) {
final DestinationFlowspecL3vpnIpv6 destFlowspec = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) dstType).getDestinationFlowspecL3vpnIpv6();
serializeNlri(new Object[] { destFlowspec.getRouteDistinguisher(), destFlowspec.getFlowspec() }, destFlowspec.getPathId(), byteAggregator);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6 in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv6NlriParser method serializeMpReachNlri.
@Override
protected void serializeMpReachNlri(final DestinationType dstType, final ByteBuf byteAggregator) {
if (dstType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) {
final DestinationFlowspecL3vpnIpv6 destFlowspec = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) dstType).getDestinationFlowspecL3vpnIpv6();
serializeNlri(new Object[] { destFlowspec.getRouteDistinguisher(), destFlowspec.getFlowspec() }, destFlowspec.getPathId(), byteAggregator);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6 in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv6NlriParserTest method testParseMpUnreachNlriConstraint.
@Test
public void testParseMpUnreachNlriConstraint() throws BGPParsingException {
final List<Flowspec> fs = new ArrayList<>();
final MpUnreachNlriBuilder mp = new MpUnreachNlriBuilder();
final FlowspecBuilder builder = new FlowspecBuilder();
final FragmentCase fragment = createFragment();
builder.setFlowspecType(fragment);
fs.add(builder.build());
final FlowspecType label = createLabel();
builder.setFlowspecType(label);
fs.add(builder.build());
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
this.fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, this.constraint);
final DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) result.getWithdrawnRoutes().getDestinationType()).getDestinationFlowspecL3vpnIpv6();
final List<Flowspec> flows = flowspecDst.getFlowspec();
final RouteDistinguisher rd = flowspecDst.getRouteDistinguisher();
assertEquals(2, flows.size());
assertEquals(ROUTE_DISTINGUISHER, rd.stringValue());
assertEquals(fragment, flows.get(0).getFlowspecType());
assertEquals(label, flows.get(1).getFlowspecType());
mp.setAfi(Ipv6AddressFamily.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.DestinationFlowspecL3vpnIpv6CaseBuilder().setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder().setRouteDistinguisher(rd).setPathId(PATH_ID).setFlowspec(fs).build()).build()).build());
final ByteBuf buffer = Unpooled.buffer();
this.fsParser.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build()).build(), buffer);
assertArrayEquals(UNREACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
assertEquals("all packets where fragment does match 'IS FIRST' 'IS LAST' 'IS A' AND where flow label equals to " + "16777222 or equals to 258 ", this.fsParser.stringNlri(flows));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6 in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv6NlriParserTest method testParseMpReachNlri.
@Test
public void testParseMpReachNlri() 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(Uint8.valueOf(6)).build());
final NextHeaderCase headersCase = new NextHeaderCaseBuilder().setNextHeaders(nextheaders).build();
builder.setFlowspecType(headersCase);
fs.add(builder.build());
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
this.fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) result.getAdvertizedRoutes().getDestinationType()).getDestinationFlowspecL3vpnIpv6();
final List<Flowspec> flows = flowspecDst.getFlowspec();
final RouteDistinguisher rd = flowspecDst.getRouteDistinguisher();
assertEquals(3, flows.size());
assertEquals(ROUTE_DISTINGUISHER, rd.stringValue());
assertEquals(destinationPrefix, flows.get(0).getFlowspecType());
assertEquals(sourcePrefix, flows.get(1).getFlowspecType());
assertEquals(headersCase, flows.get(2).getFlowspecType());
mp.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder().setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder().setRouteDistinguisher(rd).setFlowspec(fs).build()).build()).build());
final ByteBuf buffer = Unpooled.buffer();
this.fsParser.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesReachBuilder().setMpReachNlri(mp.setAfi(Ipv6AddressFamily.class).build()).build()).build(), buffer);
assertArrayEquals(REACHED_NLRI, 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.fsParser.stringNlri(flows));
}
Aggregations