use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv6NlriParserTest 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());
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, this.constraint);
final DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.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, new String(rd.getValue()));
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.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder().setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder().setPathId(PATH_ID).setRouteDistinguisher(rd).setFlowspec(fs).build()).build()).build());
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.flowspec.rev171207.flowspec.destination.Flowspec in project bgpcep by opendaylight.
the class AbstractFlowspecL3vpnNlriParser method stringNlri.
@Override
public String stringNlri(final DataContainerNode<?> flowspec) {
final StringBuilder buffer = new StringBuilder();
final RouteDistinguisher rd = extractRouteDistinguisher(flowspec, RD_NID);
if (rd != null) {
buffer.append("[l3vpn with route-distinguisher ").append(rd.getValue()).append("] ");
}
buffer.append(super.stringNlri(flowspec));
return buffer.toString();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec in project bgpcep by opendaylight.
the class AbstractFlowspecL3vpnNlriParser method readRouteDistinguisher.
/**
* For flowspec-l3vpn, there is a route distinguisher field at the beginning of NLRI (8 bytes)
*/
private static RouteDistinguisher readRouteDistinguisher(final ByteBuf nlri) {
final RouteDistinguisher rd = RouteDistinguisherUtil.parseRouteDistinguisher(nlri);
LOG.trace("Route Distinguisher read from NLRI: {}", rd);
return rd;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec in project bgpcep by opendaylight.
the class AbstractFlowspecL3vpnNlriParser method parseL3vpnNlriFlowspecList.
protected final List<Flowspec> parseL3vpnNlriFlowspecList(final ByteBuf nlri) {
if (!nlri.isReadable()) {
return null;
}
final List<Flowspec> fss = new ArrayList<>();
while (nlri.isReadable()) {
final FlowspecBuilder builder = new FlowspecBuilder();
builder.setFlowspecType(this.flowspecTypeRegistry.parseFlowspecType(nlri));
fss.add(builder.build());
}
return fss;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv4NlriParser method createAdvertizedRoutesDestinationType.
@Override
public DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
return 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).setFlowspec(flowspecList).setPathId(pathId).build()).build();
}
Aggregations