use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.WithdrawnRoutesBuilder in project bgpcep by opendaylight.
the class EvpnNlriParser method convertMpReachToMpUnReach.
@Override
public boolean convertMpReachToMpUnReach(final MpReachNlri mpReachNlri, final MpUnreachNlriBuilder builder) {
final WithdrawnRoutesBuilder withdrawnRoutes = new WithdrawnRoutesBuilder(builder.getWithdrawnRoutes());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder destinationType = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase) withdrawnRoutes.getDestinationType());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.evpn._case.DestinationEvpnBuilder destinationEvpn = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.evpn._case.DestinationEvpnBuilder(destinationType.getDestinationEvpn());
List<EvpnDestination> evpnDestination = destinationEvpn.getEvpnDestination();
if (evpnDestination == null) {
evpnDestination = new ArrayList<>();
}
evpnDestination.addAll(((DestinationEvpnCase) mpReachNlri.getAdvertizedRoutes().getDestinationType()).getDestinationEvpn().getEvpnDestination());
builder.setWithdrawnRoutes(withdrawnRoutes.setDestinationType(destinationType.setDestinationEvpn(destinationEvpn.setEvpnDestination(evpnDestination).build()).build()).build());
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.WithdrawnRoutesBuilder in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv4NlriParserTest 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 FlowspecType icmpType = createIcmpType();
builder.setFlowspecType(icmpType);
fs.add(builder.build());
final FlowspecType icmpCode = createIcmpCode();
builder.setFlowspecType(icmpCode);
fs.add(builder.build());
final TcpFlagsCase tcp = createTcp();
builder.setFlowspecType(tcp);
fs.add(builder.build());
final PacketLengthCase packet = createPackets();
builder.setFlowspecType(packet);
fs.add(builder.build());
final FlowspecType dscp = createDscp();
builder.setFlowspecType(dscp);
fs.add(builder.build());
final FlowspecType fragment = createFragment();
builder.setFlowspecType(fragment);
fs.add(builder.build());
final FlowspecL3vpnIpv4NlriParser parser = new FlowspecL3vpnIpv4NlriParser(SAFI.FLOWSPEC_VPN);
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, this.constraint);
DestinationFlowspecL3vpnIpv4 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv4Case) result.getWithdrawnRoutes().getDestinationType()).getDestinationFlowspecL3vpnIpv4();
final List<Flowspec> flows = flowspecDst.getFlowspec();
checkUnreachFlows(flows, icmpType, icmpCode, tcp, packet, dscp, fragment);
final RouteDistinguisher rd = flowspecDst.getRouteDistinguisher();
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.DestinationFlowspecL3vpnIpv4CaseBuilder().setDestinationFlowspecL3vpnIpv4(new DestinationFlowspecL3vpnIpv4Builder().setRouteDistinguisher(rd).setPathId(PATH_ID).setFlowspec(fs).build()).build()).build());
final ByteBuf buffer = Unpooled.buffer();
parser.serializeNlri(new Object[] { rd, flows }, PATH_ID, buffer);
assertArrayEquals(UNREACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
parser.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build()).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' ", this.fsParser.stringNlri(flows));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.WithdrawnRoutesBuilder 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.message.rev200120.update.message.WithdrawnRoutesBuilder in project bgpcep by opendaylight.
the class Ipv4NlriParserTest method parseUnreachNlriMultiPathTest.
@Test
public void parseUnreachNlriMultiPathTest() {
final MpUnreachNlri mpUnreachNlri = new MpUnreachNlriBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(PREFIXES).build()).build()).build()).build();
final MpUnreachNlriBuilder mpUnreachNlriBuilder = new MpUnreachNlriBuilder();
mpUnreachNlriBuilder.setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class);
this.parser.parseNlri(Unpooled.wrappedBuffer(MP_NLRI_BYTES), mpUnreachNlriBuilder, this.constraint);
mpUnreachNlriBuilder.setAfi(null).setSafi(null);
Assert.assertEquals(mpUnreachNlri, mpUnreachNlriBuilder.build());
final Ipv4NlriParser serializer = new Ipv4NlriParser();
final ByteBuf output = Unpooled.buffer(MP_NLRI_BYTES.length);
final Attributes attributes = new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mpUnreachNlri).build()).build();
serializer.serializeAttribute(attributes, output);
Assert.assertArrayEquals(MP_NLRI_BYTES, output.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.WithdrawnRoutesBuilder in project bgpcep by opendaylight.
the class L3vpnMcastIpv6NlriHandler 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 DestinationL3vpnMcastIpv6WithdrawnCaseBuilder().setDestinationIpv6L3vpnMcast(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.ipv6.withdrawn._case.DestinationIpv6L3vpnMcastBuilder().setL3vpnMcastDestination(L3vpnMcastNlriSerializer.extractDest(nlri, mPathSupported)).build()).build()).build());
}
Aggregations