Search in sources :

Example 1 with NextHopParserSerializer

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

the class BGPActivator method registerNlriHandler.

private static void registerNlriHandler(final BGPExtensionProviderContext context, final List<AutoCloseable> regs) {
    final NextHopParserSerializer nextHopParser = new NextHopParserSerializer() {
    };
    final EvpnNlriParser nlriHandler = new EvpnNlriParser();
    regs.add(context.registerNlriParser(L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class, nlriHandler, nextHopParser, Ipv4NextHopCase.class, Ipv6NextHopCase.class));
    regs.add(context.registerNlriSerializer(EvpnRoutes.class, nlriHandler));
}
Also used : EvpnRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.EvpnRoutes) L2vpnAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.L2vpnAddressFamily) EvpnSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.EvpnSubsequentAddressFamily) Ipv4NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCase) EvpnNlriParser(org.opendaylight.protocol.bgp.evpn.impl.nlri.EvpnNlriParser) NextHopParserSerializer(org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer) Ipv6NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCase)

Example 2 with NextHopParserSerializer

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

the class BgpTestActivator method startImpl.

@Override
protected List<AutoCloseable> startImpl(final BGPExtensionProviderContext context) {
    initMock();
    final List<AutoCloseable> regs = Lists.newArrayList();
    regs.add(context.registerAttributeParser(TYPE, this.attrParser));
    regs.add(context.registerAttributeSerializer(DataObject.class, this.attrSerializer));
    regs.add(context.registerParameterParser(TYPE, this.paramParser));
    regs.add(context.registerParameterSerializer(BgpParameters.class, this.paramSerializer));
    regs.add(context.registerCapabilityParser(TYPE, this.capaParser));
    regs.add(context.registerCapabilitySerializer(CParameters.class, this.capaSerializer));
    regs.add(context.registerBgpPrefixSidTlvParser(TYPE, this.sidTlvParser));
    regs.add(context.registerBgpPrefixSidTlvSerializer(BgpPrefixSidTlv.class, this.sidTlvSerializer));
    regs.add(context.registerMessageParser(TYPE, this.msgParser));
    regs.add(context.registerMessageSerializer(Notification.class, this.msgSerializer));
    regs.add(context.registerAddressFamily(Ipv4AddressFamily.class, 1));
    regs.add(context.registerAddressFamily(Ipv6AddressFamily.class, 2));
    regs.add(context.registerSubsequentAddressFamily(UnicastSubsequentAddressFamily.class, 1));
    this.nextHopParserSerializer = new NextHopParserSerializer() {

        @Override
        public CNextHop parseNextHop(final ByteBuf buffer) throws BGPParsingException {
            return new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("127.0.0.1")).build()).build();
        }

        @Override
        public void serializeNextHop(final CNextHop cNextHop, final ByteBuf byteAggregator) {
            final byte[] mpReachBytes = { 0x7f, 0x00, 0x00, 0x01 };
            byteAggregator.writeBytes(mpReachBytes);
        }
    };
    regs.add(context.registerNlriParser(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, this.nlriParser, this.nextHopParserSerializer, Ipv4NextHopCase.class));
    regs.add(context.registerNlriParser(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class, this.nlriParser, this.nextHopParserSerializer, Ipv6NextHopCase.class));
    regs.add(context.registerNlriSerializer(DataObject.class, this.nlriSerializer));
    regs.add(context.registerExtendedCommunityParser(0, 0, this.exParser));
    regs.add(context.registerExtendedCommunitySerializer(RouteTargetIpv4Case.class, this.exSerializer));
    return regs;
}
Also used : Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily) RouteTargetIpv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteTargetIpv4Case) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParameters) BGPParsingException(org.opendaylight.protocol.bgp.parser.BGPParsingException) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) ByteBuf(io.netty.buffer.ByteBuf) CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop) Ipv4NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCase) Notification(org.opendaylight.yangtools.yang.binding.Notification) Ipv6NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCase) 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) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) BgpPrefixSidTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv) Ipv4NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily) NextHopParserSerializer(org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 3 with NextHopParserSerializer

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

the class SimpleNlriRegistry method serializeMpReach.

@Override
public void serializeMpReach(final MpReachNlri mpReachNlri, final ByteBuf byteAggregator) {
    final Class<? extends AddressFamily> afi = mpReachNlri.getAfi();
    final Class<? extends SubsequentAddressFamily> safi = mpReachNlri.getSafi();
    byteAggregator.writeShort(this.afiReg.numberForClass(afi));
    byteAggregator.writeByte(this.safiReg.numberForClass(safi));
    final CNextHop cNextHop = mpReachNlri.getCNextHop();
    if (cNextHop != null) {
        final Entry<Class<? extends CNextHop>, BgpTableType> key = new SimpleEntry(cNextHop.getImplementedInterface(), new BgpTableTypeImpl(afi, safi));
        final NextHopParserSerializer nextHopSerializer = this.nextHopSerializers.get(key);
        final ByteBuf nextHopBuffer = Unpooled.buffer();
        nextHopSerializer.serializeNextHop(cNextHop, nextHopBuffer);
        byteAggregator.writeByte(nextHopBuffer.writerIndex());
        byteAggregator.writeBytes(nextHopBuffer);
    } else {
        byteAggregator.writeZero(NEXT_HOP_LENGHT);
    }
    byteAggregator.writeZero(RESERVED);
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) SimpleEntry(java.util.AbstractMap.SimpleEntry) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop) ByteBuf(io.netty.buffer.ByteBuf) NextHopParserSerializer(org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer)

Example 4 with NextHopParserSerializer

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

the class SimpleNlriRegistry method parseMpReach.

@Override
public MpReachNlri parseMpReach(final ByteBuf buffer, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
    final MpReachNlriBuilder builder = new MpReachNlriBuilder();
    final Class<? extends AddressFamily> afi = getAfi(buffer);
    final Class<? extends SubsequentAddressFamily> safi = getSafi(buffer);
    builder.setAfi(afi);
    builder.setSafi(safi);
    final BgpTableType key = createKey(builder.getAfi(), builder.getSafi());
    final int nextHopLength = buffer.readUnsignedByte();
    if (nextHopLength != 0) {
        final NextHopParserSerializer nextHopParser = this.nextHopParsers.get(key);
        if (nextHopParser != null) {
            builder.setCNextHop(nextHopParser.parseNextHop(buffer.readSlice(nextHopLength)));
        } else {
            builder.setCNextHop(NextHopUtil.parseNextHop(buffer.readSlice(nextHopLength)));
            LOG.warn("NexHop Parser/Serializer for AFI/SAFI ({},{}) not bound", afi, safi);
        }
    }
    buffer.skipBytes(RESERVED);
    final ByteBuf nlri = buffer.slice();
    final NlriParser parser = this.handlers.get(key);
    if (parser == null) {
        LOG.warn(PARSER_NOT_FOUND, key);
    } else {
        parser.parseNlri(nlri, builder, constraint);
    }
    return builder.build();
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) NlriParser(org.opendaylight.protocol.bgp.parser.spi.NlriParser) ByteBuf(io.netty.buffer.ByteBuf) PeerSpecificParserConstraint(org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint) NextHopParserSerializer(org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer)

Example 5 with NextHopParserSerializer

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

NextHopParserSerializer (org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer)5 ByteBuf (io.netty.buffer.ByteBuf)3 Ipv4NextHopCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCase)3 Ipv6NextHopCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCase)3 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType)2 CNextHop (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop)2 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 ArrayList (java.util.ArrayList)1 EvpnNlriParser (org.opendaylight.protocol.bgp.evpn.impl.nlri.EvpnNlriParser)1 LinkstateAttributeParser (org.opendaylight.protocol.bgp.linkstate.impl.attribute.LinkstateAttributeParser)1 LinkstateNlriParser (org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser)1 SimpleNlriTypeRegistry (org.opendaylight.protocol.bgp.linkstate.spi.pojo.SimpleNlriTypeRegistry)1 BGPParsingException (org.opendaylight.protocol.bgp.parser.BGPParsingException)1 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)1 NlriParser (org.opendaylight.protocol.bgp.parser.spi.NlriParser)1 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 EvpnSubsequentAddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.EvpnSubsequentAddressFamily)1 L2vpnAddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.L2vpnAddressFamily)1 EvpnRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.EvpnRoutes)1