use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri in project bgpcep by opendaylight.
the class VpnIpv4NlriParserTest method testMpUnreachNlri.
@Test
public void testMpUnreachNlri() throws BGPParsingException {
final MpUnreachNlriBuilder mpBuilder = new MpUnreachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(MplsLabeledVpnSubsequentAddressFamily.class);
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(Collections.singletonList(IPV4_VPN_WITHOUT_LABELS)).build()).build()).build()).build();
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
mpBuilder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(Collections.singletonList(IPV4_VPN)).build()).build()).build()).build();
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(MplsLabeledVpnSubsequentAddressFamily.class);
PARSER.parseNlri(Unpooled.copiedBuffer(UNREACH_NLRI), testBuilder, null);
assertEquals(mpUnreachExpected1, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mpUnreachExpected2).build()).build(), output);
assertArrayEquals(UNREACH_NLRI, ByteArray.readAllBytes(output));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri in project bgpcep by opendaylight.
the class BmpRibInWriter method removeRoutes.
private synchronized void removeRoutes(final MpUnreachNlri nlri) {
final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
final TableContext ctx = this.tables.get(key);
if (ctx == null) {
LOG.debug("No table for {}, not accepting NLRI {}", key, nlri);
return;
}
LOG.trace("Removing routes {}", nlri);
final DOMDataTreeWriteTransaction tx = this.chain.newWriteOnlyTransaction();
ctx.removeRoutes(tx, nlri);
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Successful commit");
}
@Override
public void onFailure(final Throwable trw) {
LOG.error("Failed commit", trw);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri in project bgpcep by opendaylight.
the class BmpRibInWriter method prefixesToMpUnreach.
/**
* Create MPUnreach for the prefixes to be handled in the same way as linkstate routes.
*
* @param message Update message containing withdrawn routes
* @return MpUnreachNlri with prefixes from the withdrawn routes field
*/
private static MpUnreachNlri prefixesToMpUnreach(final UpdateMessage message) {
final List<Ipv4Prefixes> prefixes = new ArrayList<>();
message.getWithdrawnRoutes().forEach(w -> prefixes.add(new Ipv4PrefixesBuilder().setPrefix(w.getPrefix()).setPathId(w.getPathId()).build()));
return new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri in project bgpcep by opendaylight.
the class SimpleRegistryTest method testEOTMpUnReachParser.
@Test
public void testEOTMpUnReachParser() throws BGPParsingException {
final NlriRegistry nlriReg = this.ctx.getNlriRegistry();
final byte[] mpUnreachBytes = { 0x00, 0x01, 0x01 };
final MpUnreachNlri mpUnreach = new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
final ByteBuf buffer = Unpooled.buffer(mpUnreachBytes.length);
nlriReg.serializeMpUnReach(mpUnreach, buffer);
assertArrayEquals(mpUnreachBytes, buffer.array());
assertEquals(mpUnreach, nlriReg.parseMpUnreach(Unpooled.wrappedBuffer(mpUnreachBytes), CONSTRAINT));
verify(this.activator.nlriParser, never()).parseNlri(any(ByteBuf.class), any(MpUnreachNlriBuilder.class), any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri in project bgpcep by opendaylight.
the class SimpleNlriRegistry method parseMpUnreach.
@Override
public MpUnreachNlri parseMpUnreach(final ByteBuf buffer, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
final MpUnreachNlriBuilder builder = new MpUnreachNlriBuilder();
builder.setAfi(getAfi(buffer));
builder.setSafi(getSafi(buffer));
if (buffer.isReadable()) {
final ByteBuf nlri = buffer.slice();
final BgpTableType key = createKey(builder.getAfi(), builder.getSafi());
final NlriParser parser = this.handlers.get(key);
if (parser == null) {
LOG.warn(PARSER_NOT_FOUND, key);
} else {
parser.parseNlri(nlri, builder, constraint);
}
}
return builder.build();
}
Aggregations