Search in sources :

Example 16 with BGPExtensionProviderContext

use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.

the class PMSITunnelAttributeHandlerTest method testMldpP2MpLsp.

@Test
public void testMldpP2MpLsp() throws Exception {
    final ByteBuf actualIpv4 = Unpooled.buffer();
    final Attributes expectedIpv4Att = buildMldpP2mpLspIpv4Attribute();
    final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
    providerContext.getAttributeRegistry().serializeAttribute(expectedIpv4Att, actualIpv4);
    assertArrayEquals(M_LDP_P2MP_LSP_EXPECTED_IPV4, ByteArray.readAllBytes(actualIpv4));
    final Attributes actualIpv4Attribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV4_2), null);
    assertEquals(expectedIpv4Att, actualIpv4Attribute);
    final Attributes expectedIpv6Att = buildMldpP2mpLspIpv6Attribute();
    final ByteBuf actualIpv6 = Unpooled.buffer();
    this.handler.serializeAttribute(expectedIpv6Att, actualIpv6);
    assertArrayEquals(M_LDP_P2MP_LSP_EXPECTED_IPV6, ByteArray.readAllBytes(actualIpv6));
    final Attributes actualIpv6Attribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV6), null);
    assertEquals(expectedIpv6Att, actualIpv6Attribute);
    final ByteBuf actualL2vpn = Unpooled.buffer();
    this.handler.serializeAttribute(buildNoSupportedFamilyAttribute(), actualL2vpn);
    assertArrayEquals(new byte[0], ByteArray.readAllBytes(actualIpv4));
    final Attributes actualWrongFamily = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_WRONG_FAMILY), null);
    assertEquals(buildWOTunnelInfAttribute(), actualWrongFamily);
    final Attributes expectedL2vpnAtt = buildMldpp2MPLspL2vpnAttribute();
    final Attributes actualL2vpnAttribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_L2VPN), null);
    assertEquals(expectedL2vpnAtt, actualL2vpnAttribute);
    final ByteBuf actualL2vp = Unpooled.buffer();
    this.handler.serializeAttribute(expectedL2vpnAtt, actualL2vp);
    assertArrayEquals(M_LDP_P2MP_LSP_EXPECTED_L2VPN, ByteArray.readAllBytes(actualL2vp));
    final ByteBuf actualNonSupportedOpaques = Unpooled.buffer();
    this.handler.serializeAttribute(buildNoSupportedOpaqueAttribute(), actualNonSupportedOpaques);
    assertArrayEquals(NO_TUNNEL_INFORMATION_PRESENT_EXPECTED, ByteArray.readAllBytes(actualNonSupportedOpaques));
}
Also used : SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) ServiceLoaderBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 17 with BGPExtensionProviderContext

use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.

the class BgpIpv6ActivatorTest method testActivator.

@Test
public void testActivator() throws Exception {
    final BgpIpv6Activator act = new BgpIpv6Activator();
    final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
    assertFalse(context.getNlriRegistry().getSerializers().iterator().hasNext());
    act.start(context);
    assertTrue(context.getNlriRegistry().getSerializers().iterator().next() instanceof VpnIpv6NlriParser);
    act.close();
}
Also used : SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) Test(org.junit.Test)

Example 18 with BGPExtensionProviderContext

use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.

the class PathAttributeParserTest method testSerializingAigpAttribute.

@Test
public void testSerializingAigpAttribute() throws BGPDocumentedException, BGPParsingException {
    final byte[] value = new byte[] { 1, 0, 11, 0, 0, 0, 0, 0, 0, 0, 8 };
    final ByteBuf inputData = Unpooled.buffer();
    final ByteBuf testBuffer = Unpooled.buffer();
    AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, AigpAttributeParser.TYPE, Unpooled.copiedBuffer(value), inputData);
    final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
    final Attributes pathAttributes = providerContext.getAttributeRegistry().parseAttributes(inputData, null);
    final Aigp aigp = pathAttributes.getAigp();
    final AttributesBuilder pathAttributesBuilder = new AttributesBuilder();
    pathAttributesBuilder.setAigp(aigp);
    final AigpAttributeParser parser = new AigpAttributeParser();
    parser.serializeAttribute(pathAttributesBuilder.build(), testBuffer);
    final byte[] unparserData = inputData.copy(0, inputData.writerIndex()).array();
    final byte[] serializedData = testBuffer.copy(0, inputData.writerIndex()).array();
    assertTrue("Buffers should be the same.", Arrays.equals(unparserData, serializedData));
}
Also used : BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) ServiceLoaderBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) AigpAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.AigpAttributeParser) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Aigp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Aigp) Test(org.junit.Test)

Example 19 with BGPExtensionProviderContext

use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.

the class LinkstateNlriParserTest method setUp.

private void setUp(final byte[] data) throws BGPParsingException {
    final LinkstateNlriParser parser = new LinkstateNlriParser();
    final MpReachNlriBuilder builder = new MpReachNlriBuilder();
    this.registry = SimpleNlriTypeRegistry.getInstance();
    final BGPActivator act = new BGPActivator(true, ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
    final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
    act.start(context);
    parser.parseNlri(Unpooled.copiedBuffer(data), builder);
    final DestinationLinkstate ls = ((DestinationLinkstateCase) builder.getAdvertizedRoutes().getDestinationType()).getDestinationLinkstate();
    assertEquals(1, ls.getCLinkstateDestination().size());
    this.dest = ls.getCLinkstateDestination().get(0);
}
Also used : MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) DestinationLinkstate(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.linkstate._case.DestinationLinkstate) BGPActivator(org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator) LinkstateNlriParser(org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser) DestinationLinkstateCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCase)

Example 20 with BGPExtensionProviderContext

use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.

the class ActivatorTest method testActivator.

@Test
public void testActivator() throws Exception {
    final BGPActivator act = new BGPActivator();
    final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
    assertNull(context.getSubsequentAddressFamilyRegistry().classForFamily(4));
    act.start(context);
    assertEquals(LabeledUnicastSubsequentAddressFamily.class, context.getSubsequentAddressFamilyRegistry().classForFamily(4));
    act.close();
}
Also used : SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) Test(org.junit.Test)

Aggregations

BGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext)20 SimpleBGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext)15 Test (org.junit.Test)10 Before (org.junit.Before)7 ServiceLoaderBGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext)6 BGPActivator (org.opendaylight.protocol.bgp.parser.impl.BGPActivator)5 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)4 BmpActivator (org.opendaylight.protocol.bmp.parser.BmpActivator)4 SimpleBmpExtensionProviderContext (org.opendaylight.protocol.bmp.spi.registry.SimpleBmpExtensionProviderContext)4 ByteBuf (io.netty.buffer.ByteBuf)3 BGPActivator (org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator)3 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)3 InetSocketAddress (java.net.InetSocketAddress)2 FlowspecActivator (org.opendaylight.protocol.bgp.flowspec.FlowspecActivator)2 SimpleFlowspecExtensionProviderContext (org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext)2 BmpDispatcherImpl (org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl)2 Channel (io.netty.channel.Channel)1 ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 After (org.junit.After)1