Search in sources :

Example 21 with MpReachNlri

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri in project bgpcep by opendaylight.

the class SimpleRegistryTest method testMpReachWithZeroNextHop.

@Test
public void testMpReachWithZeroNextHop() throws BGPParsingException {
    final NlriRegistry nlriReg = this.ctx.getNlriRegistry();
    final byte[] mpReachBytes = { 0x00, 0x01, 0x01, 0x00, 0x00 };
    final MpReachNlri mpReach = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
    final ByteBuf buffer = Unpooled.buffer(mpReachBytes.length);
    nlriReg.serializeMpReach(mpReach, buffer);
    assertArrayEquals(mpReachBytes, buffer.array());
    assertEquals(mpReach, nlriReg.parseMpReach(Unpooled.wrappedBuffer(mpReachBytes), CONSTRAINT));
}
Also used : MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) NlriRegistry(org.opendaylight.protocol.bgp.parser.spi.NlriRegistry) ByteBuf(io.netty.buffer.ByteBuf) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily) Test(org.junit.Test)

Example 22 with MpReachNlri

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri in project bgpcep by opendaylight.

the class SimpleRegistryTest method testMpReachIpv6.

@Test
public void testMpReachIpv6() throws BGPParsingException {
    final NlriRegistry nlriReg = this.ctx.getNlriRegistry();
    final byte[] mpReachBytes = { 0x00, 0x02, 0x01, 0x00, 0x00 };
    final MpReachNlri mpReach = new MpReachNlriBuilder().setAfi(Ipv6AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
    final ByteBuf buffer = Unpooled.buffer(mpReachBytes.length);
    nlriReg.serializeMpReach(mpReach, buffer);
    assertArrayEquals(mpReachBytes, buffer.array());
    assertEquals(mpReach, nlriReg.parseMpReach(Unpooled.wrappedBuffer(mpReachBytes), CONSTRAINT));
}
Also used : MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) NlriRegistry(org.opendaylight.protocol.bgp.parser.spi.NlriRegistry) ByteBuf(io.netty.buffer.ByteBuf) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily) Test(org.junit.Test)

Example 23 with MpReachNlri

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri in project bgpcep by opendaylight.

the class SimpleFlowspecIpv4NlriParserTest method testBatchedFlowspecNlri.

@Test
public void testBatchedFlowspecNlri() throws Exception {
    final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(flowspecContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC));
    final MpReachNlriBuilder result = new MpReachNlriBuilder();
    result.setAfi(Ipv4AddressFamily.class);
    result.setSafi(FlowspecSubsequentAddressFamily.class);
    parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_BATCHED), result);
    final MpReachNlri nlri = result.build();
    final List<Flowspec> flowspecList = ((DestinationFlowspecCase) nlri.getAdvertizedRoutes().getDestinationType()).getDestinationFlowspec().getFlowspec();
    assertEquals(3, flowspecList.size());
    assertEquals("216.58.245.101/32", ((DestinationPrefixCase) flowspecList.get(0).getFlowspecType()).getDestinationPrefix().getValue());
    assertEquals("216.58.218.196/32", ((DestinationPrefixCase) flowspecList.get(1).getFlowspecType()).getDestinationPrefix().getValue());
    assertEquals("216.58.216.195/32", ((DestinationPrefixCase) flowspecList.get(2).getFlowspecType()).getDestinationPrefix().getValue());
}
Also used : MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) Flowspec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec) DestinationPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.group.ipv4.flowspec.flowspec.type.DestinationPrefixCase) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri) Test(org.junit.Test)

Example 24 with MpReachNlri

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri in project bgpcep by opendaylight.

the class VpnIpv4NlriParserTest method testMpReachNlri.

@Test
public void testMpReachNlri() throws BGPParsingException {
    final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
    mpBuilder.setAfi(Ipv4AddressFamily.class);
    mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(Collections.singletonList(IPV4_VPN)).build()).build()).build()).build();
    final MpReachNlri mpReachExpected = mpBuilder.build();
    final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
    testBuilder.setAfi(Ipv4AddressFamily.class);
    PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder);
    Assert.assertEquals(mpReachExpected, testBuilder.build());
    final ByteBuf output = Unpooled.buffer();
    PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
    Assert.assertArrayEquals(REACH_NLRI, ByteArray.readAllBytes(output));
}
Also used : MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) ByteBuf(io.netty.buffer.ByteBuf) AdvertizedRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder) Attributes1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder) VpnIpv4DestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.l3vpn.ipv4.destination.VpnIpv4DestinationBuilder) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 25 with MpReachNlri

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri in project bgpcep by opendaylight.

the class MPReachAttributeParser method parseAttribute.

@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder, final PeerSpecificParserConstraint constraint) throws BGPDocumentedException {
    try {
        final MpReachNlri mpReachNlri = this.reg.parseMpReach(buffer, constraint);
        final Attributes1 a = new Attributes1Builder().setMpReachNlri(mpReachNlri).build();
        builder.addAugmentation(Attributes1.class, a);
    } catch (final BGPParsingException e) {
        throw new BGPDocumentedException("Could not parse MP_REACH_NLRI", BGPError.OPT_ATTR_ERROR, e);
    }
}
Also used : Attributes1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) BGPParsingException(org.opendaylight.protocol.bgp.parser.BGPParsingException) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri)

Aggregations

MpReachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri)22 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder)20 ByteBuf (io.netty.buffer.ByteBuf)15 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder)15 Test (org.junit.Test)14 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)13 Attributes1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder)12 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1)8 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)7 MpUnreachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlri)6 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily)5 UnicastSubsequentAddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily)5 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)4 CLabeledUnicastDestination (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.destination.CLabeledUnicastDestination)4 CLabeledUnicastDestinationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.destination.CLabeledUnicastDestinationBuilder)4 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder)4 Map (java.util.Map)3 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)3 NlriRegistry (org.opendaylight.protocol.bgp.parser.spi.NlriRegistry)3 DestinationIpv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.DestinationIpv4Builder)3