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()));
}
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());
}
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());
}
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));
}
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));
}
Aggregations