Search in sources :

Example 1 with NlriRegistry

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

the class BGPActivator method registerAttributeParsers.

private static void registerAttributeParsers(final List<AutoCloseable> regs, final BGPExtensionProviderContext context) {
    final BgpPrefixSidAttributeParser prefixSidAttributeParser = new BgpPrefixSidAttributeParser(context.getBgpPrefixSidTlvRegistry());
    regs.add(context.registerAttributeSerializer(BgpPrefixSid.class, prefixSidAttributeParser));
    regs.add(context.registerAttributeParser(BgpPrefixSidAttributeParser.TYPE, prefixSidAttributeParser));
    final OriginAttributeParser originAttributeParser = new OriginAttributeParser();
    regs.add(context.registerAttributeSerializer(Origin.class, originAttributeParser));
    regs.add(context.registerAttributeParser(OriginAttributeParser.TYPE, originAttributeParser));
    final AigpAttributeParser aigpAttributeParser = new AigpAttributeParser();
    regs.add(context.registerAttributeSerializer(Aigp.class, aigpAttributeParser));
    regs.add(context.registerAttributeParser(AigpAttributeParser.TYPE, aigpAttributeParser));
    final AsPathAttributeParser asPathAttributeParser = new AsPathAttributeParser(context.getReferenceCache());
    regs.add(context.registerAttributeSerializer(AsPath.class, asPathAttributeParser));
    regs.add(context.registerAttributeParser(AsPathAttributeParser.TYPE, asPathAttributeParser));
    final NextHopAttributeParser nextHopAttributeParser = new NextHopAttributeParser();
    regs.add(context.registerAttributeSerializer(NextHop.class, nextHopAttributeParser));
    regs.add(context.registerAttributeParser(NextHopAttributeParser.TYPE, nextHopAttributeParser));
    final MultiExitDiscriminatorAttributeParser multiExitDiscriminatorAttributeParser = new MultiExitDiscriminatorAttributeParser();
    regs.add(context.registerAttributeSerializer(MultiExitDisc.class, multiExitDiscriminatorAttributeParser));
    regs.add(context.registerAttributeParser(MultiExitDiscriminatorAttributeParser.TYPE, multiExitDiscriminatorAttributeParser));
    final LocalPreferenceAttributeParser localPreferenceAttributeParser = new LocalPreferenceAttributeParser();
    regs.add(context.registerAttributeSerializer(LocalPref.class, localPreferenceAttributeParser));
    regs.add(context.registerAttributeParser(LocalPreferenceAttributeParser.TYPE, localPreferenceAttributeParser));
    final AtomicAggregateAttributeParser atomicAggregateAttributeParser = new AtomicAggregateAttributeParser();
    regs.add(context.registerAttributeSerializer(AtomicAggregate.class, atomicAggregateAttributeParser));
    regs.add(context.registerAttributeParser(AtomicAggregateAttributeParser.TYPE, atomicAggregateAttributeParser));
    final AggregatorAttributeParser as4AggregatorAttributeParser = new AggregatorAttributeParser(context.getReferenceCache());
    regs.add(context.registerAttributeSerializer(Aggregator.class, as4AggregatorAttributeParser));
    regs.add(context.registerAttributeParser(AggregatorAttributeParser.TYPE, as4AggregatorAttributeParser));
    final CommunitiesAttributeParser communitiesAttributeParser = new CommunitiesAttributeParser(context.getReferenceCache());
    regs.add(context.registerAttributeSerializer(Communities.class, communitiesAttributeParser));
    regs.add(context.registerAttributeParser(CommunitiesAttributeParser.TYPE, communitiesAttributeParser));
    final OriginatorIdAttributeParser originatorIdAttributeParser = new OriginatorIdAttributeParser();
    regs.add(context.registerAttributeSerializer(OriginatorId.class, originatorIdAttributeParser));
    regs.add(context.registerAttributeParser(OriginatorIdAttributeParser.TYPE, originatorIdAttributeParser));
    final ClusterIdAttributeParser clusterIdAttributeParser = new ClusterIdAttributeParser();
    regs.add(context.registerAttributeSerializer(ClusterId.class, clusterIdAttributeParser));
    regs.add(context.registerAttributeParser(ClusterIdAttributeParser.TYPE, clusterIdAttributeParser));
    final NlriRegistry nlriReg = context.getNlriRegistry();
    final MPReachAttributeParser mpReachAttributeParser = new MPReachAttributeParser(nlriReg);
    regs.add(context.registerAttributeSerializer(MpReachNlri.class, mpReachAttributeParser));
    regs.add(context.registerAttributeParser(MPReachAttributeParser.TYPE, mpReachAttributeParser));
    final MPUnreachAttributeParser mpUnreachAttributeParser = new MPUnreachAttributeParser(nlriReg);
    regs.add(context.registerAttributeSerializer(MpUnreachNlri.class, mpUnreachAttributeParser));
    regs.add(context.registerAttributeParser(MPUnreachAttributeParser.TYPE, mpUnreachAttributeParser));
    final ExtendedCommunitiesAttributeParser extendedCommunitiesAttributeParser = new ExtendedCommunitiesAttributeParser(context.getExtendedCommunityRegistry());
    regs.add(context.registerAttributeSerializer(ExtendedCommunities.class, extendedCommunitiesAttributeParser));
    regs.add(context.registerAttributeParser(ExtendedCommunitiesAttributeParser.TYPE, extendedCommunitiesAttributeParser));
    regs.add(context.registerAttributeParser(AS4AggregatorAttributeParser.TYPE, new AS4AggregatorAttributeParser()));
    regs.add(context.registerAttributeParser(AS4PathAttributeParser.TYPE, new AS4PathAttributeParser()));
    regs.add(context.registerAttributeSerializer(UnrecognizedAttributes.class, new UnrecognizedAttributesSerializer()));
}
Also used : Origin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Origin) AS4AggregatorAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.AS4AggregatorAttributeParser) AS4AggregatorAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.AS4AggregatorAttributeParser) AggregatorAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.AggregatorAttributeParser) CommunitiesAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.CommunitiesAttributeParser) ExtendedCommunitiesAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.ExtendedCommunitiesAttributeParser) Communities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Communities) ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities) AtomicAggregate(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AtomicAggregate) BgpPrefixSid(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.BgpPrefixSid) AtomicAggregateAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.AtomicAggregateAttributeParser) UnrecognizedAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributes) LocalPreferenceAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.LocalPreferenceAttributeParser) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.LocalPref) ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities) AsPathAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.AsPathAttributeParser) OriginatorIdAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.OriginatorIdAttributeParser) OriginatorId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginatorId) ClusterId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterId) NextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.NextHop) MultiExitDiscriminatorAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.MultiExitDiscriminatorAttributeParser) Aggregator(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Aggregator) ExtendedCommunitiesAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.ExtendedCommunitiesAttributeParser) BgpPrefixSidAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.BgpPrefixSidAttributeParser) NlriRegistry(org.opendaylight.protocol.bgp.parser.spi.NlriRegistry) Aigp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Aigp) ClusterIdAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.ClusterIdAttributeParser) AS4PathAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.AS4PathAttributeParser) MPUnreachAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.MPUnreachAttributeParser) AsPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPath) NextHopAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.NextHopAttributeParser) OriginAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.OriginAttributeParser) MultiExitDisc(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.MultiExitDisc) MPReachAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.MPReachAttributeParser) MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlri) AigpAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.AigpAttributeParser) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri) UnrecognizedAttributesSerializer(org.opendaylight.protocol.bgp.parser.impl.message.update.UnrecognizedAttributesSerializer)

Example 2 with NlriRegistry

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

the class SimpleRegistryTest method testMpReachParser.

@Test
public void testMpReachParser() throws BGPParsingException {
    final NlriRegistry nlriReg = this.ctx.getNlriRegistry();
    final byte[] mpReachBytes = { 0x00, 0x01, 0x01, 0x04, 0x7f, 0x00, 0x00, 0x01, 0x00 };
    final MpReachNlri mpReach = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("127.0.0.1")).build()).build()).build();
    final ByteBuf buffer = Unpooled.buffer(mpReachBytes.length);
    nlriReg.serializeMpReach(mpReach, buffer);
    assertArrayEquals(mpReachBytes, buffer.array());
    assertEquals(mpReach, nlriReg.parseMpReach(Unpooled.wrappedBuffer(mpReachBytes), CONSTRAINT));
    verify(this.activator.nlriParser, times(1)).parseNlri(Mockito.any(ByteBuf.class), Mockito.any(MpReachNlriBuilder.class), Mockito.any());
}
Also used : MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) Ipv4NextHopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder) Ipv4NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily) 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) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 3 with NlriRegistry

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

the class SimpleRegistryTest method testMpUnReachParser.

@Test
public void testMpUnReachParser() 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, times(1)).parseNlri(Mockito.any(ByteBuf.class), Mockito.any(MpUnreachNlriBuilder.class), Mockito.any());
}
Also used : MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlri) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.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.rev130919.UnicastSubsequentAddressFamily) Test(org.junit.Test)

Example 4 with NlriRegistry

use of org.opendaylight.protocol.bgp.parser.spi.NlriRegistry 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 5 with NlriRegistry

use of org.opendaylight.protocol.bgp.parser.spi.NlriRegistry 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)

Aggregations

NlriRegistry (org.opendaylight.protocol.bgp.parser.spi.NlriRegistry)5 ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)4 MpReachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri)4 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder)3 MpUnreachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlri)2 UnicastSubsequentAddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily)2 AS4AggregatorAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.AS4AggregatorAttributeParser)1 AS4PathAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.AS4PathAttributeParser)1 AggregatorAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.AggregatorAttributeParser)1 AigpAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.AigpAttributeParser)1 AsPathAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.AsPathAttributeParser)1 AtomicAggregateAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.AtomicAggregateAttributeParser)1 BgpPrefixSidAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.BgpPrefixSidAttributeParser)1 ClusterIdAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.ClusterIdAttributeParser)1 CommunitiesAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.CommunitiesAttributeParser)1 ExtendedCommunitiesAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.ExtendedCommunitiesAttributeParser)1 LocalPreferenceAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.LocalPreferenceAttributeParser)1 MPReachAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.MPReachAttributeParser)1 MPUnreachAttributeParser (org.opendaylight.protocol.bgp.parser.impl.message.update.MPUnreachAttributeParser)1