Search in sources :

Example 1 with LinkstateNlriParser

use of org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser 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 2 with LinkstateNlriParser

use of org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser in project bgpcep by opendaylight.

the class LinkstateNlriParserTest method testSerializeAttribute.

@Test
public void testSerializeAttribute() throws BGPParsingException {
    final LinkstateNlriParser parser = new LinkstateNlriParser();
    setUp(this.prefixNlri);
    final List<CLinkstateDestination> dests = Lists.newArrayList(this.dest);
    final DestinationLinkstateCase dlc = new DestinationLinkstateCaseBuilder().setDestinationLinkstate(new DestinationLinkstateBuilder().setCLinkstateDestination(dests).build()).build();
    final AdvertizedRoutes aroutes = new AdvertizedRoutesBuilder().setDestinationType(dlc).build();
    final Attributes1 reach = new Attributes1Builder().setMpReachNlri(new MpReachNlriBuilder().setAdvertizedRoutes(aroutes).build()).build();
    Attributes pa = new AttributesBuilder().addAugmentation(Attributes1.class, reach).build();
    ByteBuf result = Unpooled.buffer();
    parser.serializeAttribute(pa, result);
    assertArrayEquals(this.prefixNlri, ByteArray.getAllBytes(result));
    setUp(this.nodeNlri);
    final List<CLinkstateDestination> destsU = Lists.newArrayList(this.dest);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase dlcU = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder().setDestinationLinkstate(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.linkstate._case.DestinationLinkstateBuilder().setCLinkstateDestination(destsU).build()).build();
    final WithdrawnRoutes wroutes = new WithdrawnRoutesBuilder().setDestinationType(dlcU).build();
    final Attributes2 unreach = new Attributes2Builder().setMpUnreachNlri(new MpUnreachNlriBuilder().setWithdrawnRoutes(wroutes).build()).build();
    pa = new AttributesBuilder().addAugmentation(Attributes2.class, unreach).build();
    result = Unpooled.buffer();
    parser.serializeAttribute(pa, result);
    assertArrayEquals(this.nodeNlri, ByteArray.getAllBytes(result));
}
Also used : MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) AdvertizedRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes) DestinationLinkstateBuilder(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.DestinationLinkstateBuilder) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) WithdrawnRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutes) 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) DestinationLinkstateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder) LinkstateNlriParser(org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser) CLinkstateDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.destination.CLinkstateDestination) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlriBuilder) Attributes2(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1) 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) Attributes2Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2Builder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 3 with LinkstateNlriParser

use of org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser in project bgpcep by opendaylight.

the class BGPActivator method startImpl.

@Override
protected List<AutoCloseable> startImpl(final BGPExtensionProviderContext context) {
    final List<AutoCloseable> regs = new ArrayList<>();
    final SimpleNlriTypeRegistry nlriTypeReg = SimpleNlriTypeRegistry.getInstance();
    regs.add(context.registerAddressFamily(LinkstateAddressFamily.class, LINKSTATE_AFI));
    regs.add(context.registerSubsequentAddressFamily(LinkstateSubsequentAddressFamily.class, LINKSTATE_SAFI));
    final NextHopParserSerializer linkstateNextHopParser = new NextHopParserSerializer() {
    };
    final LinkstateNlriParser parser = new LinkstateNlriParser();
    regs.add(context.registerNlriParser(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class, parser, linkstateNextHopParser, Ipv4NextHopCase.class, Ipv6NextHopCase.class));
    regs.add(context.registerNlriSerializer(LinkstateRoutes.class, parser));
    regs.add(context.registerAttributeSerializer(Attributes1.class, new LinkstateAttributeParser(this.ianaLinkstateAttributeType, this.rsvpTeObjectRegistry)));
    final LinkstateAttributeParser linkstateAttributeParser = new LinkstateAttributeParser(this.ianaLinkstateAttributeType, this.rsvpTeObjectRegistry);
    regs.add(context.registerAttributeParser(linkstateAttributeParser.getType(), linkstateAttributeParser));
    registerNlriCodecs(regs, nlriTypeReg);
    registerNlriTlvCodecs(regs, nlriTypeReg);
    registerBindingSubTlvs(regs);
    return regs;
}
Also used : LinkstateSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.LinkstateSubsequentAddressFamily) SimpleNlriTypeRegistry(org.opendaylight.protocol.bgp.linkstate.spi.pojo.SimpleNlriTypeRegistry) ArrayList(java.util.ArrayList) LinkstateAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.LinkstateAddressFamily) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1) Ipv4NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCase) Ipv6NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCase) LinkstateAttributeParser(org.opendaylight.protocol.bgp.linkstate.impl.attribute.LinkstateAttributeParser) LinkstateRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.routes.LinkstateRoutes) LinkstateNlriParser(org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser) NextHopParserSerializer(org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer)

Aggregations

LinkstateNlriParser (org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser)3 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)2 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 BGPActivator (org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator)1 LinkstateAttributeParser (org.opendaylight.protocol.bgp.linkstate.impl.attribute.LinkstateAttributeParser)1 SimpleNlriTypeRegistry (org.opendaylight.protocol.bgp.linkstate.spi.pojo.SimpleNlriTypeRegistry)1 BGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext)1 NextHopParserSerializer (org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer)1 SimpleBGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext)1 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1)1 LinkstateAddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.LinkstateAddressFamily)1 LinkstateSubsequentAddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.LinkstateSubsequentAddressFamily)1 CLinkstateDestination (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.destination.CLinkstateDestination)1 LinkstateRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.routes.LinkstateRoutes)1 DestinationLinkstateCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCaseBuilder)1 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)1 DestinationLinkstateBuilder (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.DestinationLinkstateBuilder)1