Search in sources :

Example 6 with SubsequentAddressFamily

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily in project bgpcep by opendaylight.

the class SimpleRIBExtensionProviderContext method registerRIBSupport.

@Override
public <T extends RIBSupport> RIBSupportRegistration<T> registerRIBSupport(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final T support) {
    final TablesKey key = new TablesKey(afi, safi);
    final RIBSupport prev = this.supports.putIfAbsent(key, support);
    Preconditions.checkArgument(prev == null, "AFI %s SAFI %s is already registered with %s", afi, safi, prev);
    this.domSupports.put(RibSupportUtils.toYangTablesKey(afi, safi), support);
    addClassLoadingSupport(afi, safi, support);
    return new AbstractRIBSupportRegistration<T>(support) {

        @Override
        protected void removeRegistration() {
            SimpleRIBExtensionProviderContext.this.supports.remove(key);
        }
    };
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)

Example 7 with SubsequentAddressFamily

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily in project bgpcep by opendaylight.

the class SimpleBGPTableTypeRegistryProvider method registerBGPTableType.

@Override
public synchronized AbstractRegistration registerBGPTableType(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final Class<? extends AfiSafiType> afiSafiType) {
    final BgpTableType tableType = new BgpTableTypeImpl(afi, safi);
    final Class<? extends AfiSafiType> prev = this.tableTypes.putIfAbsent(tableType, afiSafiType);
    Preconditions.checkState(prev == null, "AFI %s SAFI %s is already registered with %s", afi, safi, prev);
    final TablesKey tableKey = new TablesKey(tableType.getAfi(), tableType.getSafi());
    this.tableKeys.put(tableKey, afiSafiType);
    return new AbstractRegistration() {

        @Override
        protected void removeRegistration() {
            synchronized (SimpleBGPTableTypeRegistryProvider.this) {
                SimpleBGPTableTypeRegistryProvider.this.tableTypes.remove(tableType);
                SimpleBGPTableTypeRegistryProvider.this.tableKeys.remove(tableKey);
            }
        }
    };
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) AbstractRegistration(org.opendaylight.yangtools.concepts.AbstractRegistration) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)

Example 8 with SubsequentAddressFamily

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily in project bgpcep by opendaylight.

the class BGPPeer method onRouteRefreshMessage.

private void onRouteRefreshMessage(final RouteRefresh message) {
    final Class<? extends AddressFamily> rrAfi = message.getAfi();
    final Class<? extends SubsequentAddressFamily> rrSafi = message.getSafi();
    final TablesKey key = new TablesKey(rrAfi, rrSafi);
    final AdjRibOutListener listener = this.adjRibOutListenerSet.get(key);
    if (listener != null) {
        listener.close();
        this.adjRibOutListenerSet.remove(key);
        createAdjRibOutListener(key, listener.isMpSupported());
    } else {
        LOG.info("Ignoring RouteRefresh message. Afi/Safi is not supported: {}, {}.", rrAfi, rrSafi);
    }
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)

Example 9 with SubsequentAddressFamily

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily 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 10 with SubsequentAddressFamily

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily in project bgpcep by opendaylight.

the class SimpleNlriRegistry method registerNlriParser.

synchronized AutoCloseable registerNlriParser(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final NlriParser parser, final NextHopParserSerializer nextHopSerializer, final Class<? extends CNextHop> cNextHopClass, final Class<? extends CNextHop>... cNextHopClassList) {
    final BgpTableType key = createKey(afi, safi);
    final NlriParser prev = this.handlers.get(key);
    Preconditions.checkState(prev == null, "AFI/SAFI is already bound to parser " + prev);
    this.handlers.put(key, parser);
    this.nextHopParsers.put(key, nextHopSerializer);
    if (cNextHopClass != null) {
        final Entry<Class<? extends CNextHop>, BgpTableType> nhKey = new SimpleEntry<>(cNextHopClass, key);
        this.nextHopSerializers.put(nhKey, nextHopSerializer);
        for (final Class<? extends CNextHop> cNextHop : cNextHopClassList) {
            final Entry<Class<? extends CNextHop>, BgpTableType> nhKeys = new SimpleEntry<>(cNextHop, key);
            this.nextHopSerializers.put(nhKeys, nextHopSerializer);
        }
    }
    final Object lock = this;
    return new AbstractRegistration() {

        @Override
        protected void removeRegistration() {
            synchronized (lock) {
                SimpleNlriRegistry.this.handlers.remove(key);
                SimpleNlriRegistry.this.nextHopParsers.remove(key);
                if (cNextHopClass != null) {
                    final Entry<Class<? extends CNextHop>, BgpTableType> nhKey = new SimpleEntry<>(cNextHopClass, key);
                    SimpleNlriRegistry.this.nextHopSerializers.remove(nhKey);
                    for (final Class<? extends CNextHop> cNextHop : cNextHopClassList) {
                        final Entry<Class<? extends CNextHop>, BgpTableType> nhKeys = new SimpleEntry<>(cNextHop, key);
                        SimpleNlriRegistry.this.nextHopSerializers.remove(nhKeys);
                    }
                }
            }
        }
    };
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) SimpleEntry(java.util.AbstractMap.SimpleEntry) AbstractRegistration(org.opendaylight.protocol.concepts.AbstractRegistration) NlriParser(org.opendaylight.protocol.bgp.parser.spi.NlriParser) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)6 ArrayList (java.util.ArrayList)4 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)4 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType)4 Test (org.junit.Test)3 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)3 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)3 CParameters1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1)3 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)3 SimpleEntry (java.util.AbstractMap.SimpleEntry)2 NextHopParserSerializer (org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer)2 NlriParser (org.opendaylight.protocol.bgp.parser.spi.NlriParser)2 CParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder)2 CParameters1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder)2 SendReceive (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.SendReceive)2 AddressFamilies (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.add.path.capability.AddressFamilies)2 Tables (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables)2 CNextHop (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop)2 BGPParsingException (org.opendaylight.protocol.bgp.parser.BGPParsingException)1 AbstractRegistration (org.opendaylight.protocol.concepts.AbstractRegistration)1