Search in sources :

Example 26 with MpUnreachNlri

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));
}
Also used : AttributesUnreachBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreachBuilder) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder) ByteBuf(io.netty.buffer.ByteBuf) WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder) VpnIpv4DestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.l3vpn.ipv4.destination.VpnIpv4DestinationBuilder) MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 27 with MpUnreachNlri

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());
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Example 28 with MpUnreachNlri

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();
}
Also used : Ipv4Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4Prefixes) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily) ArrayList(java.util.ArrayList) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder) DestinationIpv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.DestinationIpv4Builder) WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder) Ipv4PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder) DestinationIpv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder)

Example 29 with MpUnreachNlri

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());
}
Also used : MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder) NlriRegistry(org.opendaylight.protocol.bgp.parser.spi.NlriRegistry) ByteBuf(io.netty.buffer.ByteBuf) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily) Test(org.junit.Test)

Example 30 with MpUnreachNlri

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();
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) NlriParser(org.opendaylight.protocol.bgp.parser.spi.NlriParser) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

MpUnreachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri)19 Test (org.junit.Test)16 MpUnreachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder)16 WithdrawnRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder)14 ByteBuf (io.netty.buffer.ByteBuf)13 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)12 AttributesUnreachBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreachBuilder)12 MpUnreachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlri)8 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)5 Attributes2 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2)5 MpUnreachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlriBuilder)5 AttributesUnreach (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach)5 MpReachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri)5 Mockito.doReturn (org.mockito.Mockito.doReturn)4 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)4 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder)4 Attributes2Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2Builder)4 WithdrawnRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder)4 AttributesReach (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReach)4 WithdrawnRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutes)4