Search in sources :

Example 1 with RouteRefresh

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh in project bgpcep by opendaylight.

the class BGPActivator method registerCapabilityParsers.

private static void registerCapabilityParsers(final List<AutoCloseable> regs, final BGPExtensionProviderContext context) {
    final AddressFamilyRegistry afiReg = context.getAddressFamilyRegistry();
    final SubsequentAddressFamilyRegistry safiReg = context.getSubsequentAddressFamilyRegistry();
    final MultiProtocolCapabilityHandler multi = new MultiProtocolCapabilityHandler(afiReg, safiReg);
    regs.add(context.registerCapabilityParser(MultiProtocolCapabilityHandler.CODE, multi));
    regs.add(context.registerCapabilitySerializer(MultiprotocolCapability.class, multi));
    final AddPathCapabilityHandler addPath = new AddPathCapabilityHandler(afiReg, safiReg);
    regs.add(context.registerCapabilityParser(AddPathCapabilityHandler.CODE, addPath));
    regs.add(context.registerCapabilitySerializer(AddPathCapability.class, addPath));
    final RouteRefreshCapabilityHandler routeRefresh = new RouteRefreshCapabilityHandler();
    regs.add(context.registerCapabilityParser(RouteRefreshCapabilityHandler.CODE, routeRefresh));
    regs.add(context.registerCapabilitySerializer(RouteRefreshCapability.class, routeRefresh));
    final As4CapabilityHandler as4 = new As4CapabilityHandler();
    regs.add(context.registerCapabilityParser(As4CapabilityHandler.CODE, as4));
    regs.add(context.registerCapabilitySerializer(As4BytesCapability.class, as4));
    final GracefulCapabilityHandler grace = new GracefulCapabilityHandler(afiReg, safiReg);
    regs.add(context.registerCapabilitySerializer(GracefulRestartCapability.class, grace));
    regs.add(context.registerCapabilityParser(GracefulCapabilityHandler.CODE, grace));
    final CapabilityParameterParser cpp = new CapabilityParameterParser(context.getCapabilityRegistry());
    regs.add(context.registerParameterParser(CapabilityParameterParser.TYPE, cpp));
    regs.add(context.registerParameterSerializer(BgpParameters.class, cpp));
    final BgpExtendedMessageCapabilityHandler bgpextmessage = new BgpExtendedMessageCapabilityHandler();
    regs.add(context.registerCapabilityParser(BgpExtendedMessageCapabilityHandler.CODE, bgpextmessage));
    regs.add(context.registerCapabilitySerializer(BgpExtendedMessageCapability.class, bgpextmessage));
}
Also used : AddressFamilyRegistry(org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry) SubsequentAddressFamilyRegistry(org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry) RouteRefreshCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.RouteRefreshCapability) RouteRefreshCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.RouteRefreshCapabilityHandler) AddPathCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler) GracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler) CapabilityParameterParser(org.opendaylight.protocol.bgp.parser.impl.message.open.CapabilityParameterParser) As4CapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.As4CapabilityHandler) As4BytesCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapability) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) MultiProtocolCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.MultiProtocolCapabilityHandler) BgpExtendedMessageCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.BgpExtendedMessageCapabilityHandler) SubsequentAddressFamilyRegistry(org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry) MultiprotocolCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapability) AddPathCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.AddPathCapability) GracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapability) BgpExtendedMessageCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.BgpExtendedMessageCapability)

Example 2 with RouteRefresh

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh in project bgpcep by opendaylight.

the class BGPRouteRefreshMessageParser method serializeMessage.

/**
 * Serializes BGP Route Refresh message.
 *
 * @param message to be serialized
 * @param bytes ByteBuf where the message will be serialized
 */
@Override
public void serializeMessage(final Notification message, final ByteBuf bytes) {
    checkArgument(message instanceof RouteRefresh, ARGUMENT_ERROR);
    final RouteRefresh msg = (RouteRefresh) message;
    final ByteBuf msgBuf = Unpooled.buffer(TRIPLET_BYTE_SIZE);
    MultiprotocolCapabilitiesUtil.serializeMPAfiSafi(this.afiReg, this.safiReg, msg.getAfi(), msg.getSafi(), msgBuf);
    if (LOG.isTraceEnabled()) {
        LOG.trace("RouteRefresh message serialized to: {}", ByteBufUtil.hexDump(msgBuf));
    }
    MessageUtil.formatMessage(TYPE, msgBuf, bytes);
}
Also used : RouteRefresh(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh) ByteBuf(io.netty.buffer.ByteBuf)

Example 3 with RouteRefresh

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh in project bgpcep by opendaylight.

the class BGPSessionImpl method handleMessage.

/**
 * Handles incoming message based on their type.
 *
 * @param msg incoming message
 */
void handleMessage(final Notification msg) {
    // synchronize on listener and then on this object to ensure correct order of locking
    synchronized (this.listener) {
        synchronized (this) {
            if (this.state == State.IDLE) {
                return;
            }
            try {
                // Update last reception time
                this.lastMessageReceivedAt = System.nanoTime();
                if (msg instanceof Open) {
                    // Open messages should not be present here
                    terminate(new BGPDocumentedException(null, BGPError.FSM_ERROR));
                } else if (msg instanceof Notify) {
                    final Notify notify = (Notify) msg;
                    // Notifications are handled internally
                    LOG.info("Session closed because Notification message received: {} / {}, data={}", notify.getErrorCode(), notify.getErrorSubcode(), notify.getData() != null ? ByteBufUtil.hexDump(notify.getData()) : null);
                    notifyTerminationReasonAndCloseWithoutMessage(notify.getErrorCode(), notify.getErrorSubcode());
                } else if (msg instanceof Keepalive) {
                    // Keepalives are handled internally
                    LOG.trace("Received KeepAlive message.");
                    this.kaCounter++;
                    if (this.kaCounter >= 2) {
                        this.sync.kaReceived();
                    }
                } else if (msg instanceof RouteRefresh) {
                    this.listener.onMessage(this, msg);
                } else if (msg instanceof Update) {
                    this.listener.onMessage(this, msg);
                    this.sync.updReceived((Update) msg);
                } else {
                    LOG.warn("Ignoring unhandled message: {}.", msg.getClass());
                }
                this.sessionState.messageReceived(msg);
            } catch (final BGPDocumentedException e) {
                terminate(e);
            }
        }
    }
}
Also used : Notify(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) RouteRefresh(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh) Keepalive(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Keepalive) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open)

Example 4 with RouteRefresh

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh in project bgpcep by opendaylight.

the class BGPRouteRefreshMessageParser method parseMessageBody.

/**
 * Parses BGP Route Refresh message to bytes.
 *
 * @param body ByteBuf to be parsed
 * @param messageLength the length of the message
 * @return {@link RouteRefresh} which represents BGP notification message
 * @throws BGPDocumentedException if parsing goes wrong
 */
@Override
public RouteRefresh parseMessageBody(final ByteBuf body, final int messageLength) throws BGPDocumentedException {
    Preconditions.checkArgument(body != null, "Body buffer cannot be null.");
    if (body.readableBytes() < TRIPLET_BYTE_SIZE) {
        throw BGPDocumentedException.badMessageLength("RouteRefresh message is too small.", messageLength);
    }
    final Optional<BgpTableType> parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(body, this.afiReg, this.safiReg);
    if (!parsedAfiSafi.isPresent()) {
        throw new BGPDocumentedException("Unsupported afi/safi in Route Refresh message.", BGPError.WELL_KNOWN_ATTR_NOT_RECOGNIZED);
    }
    return new RouteRefreshBuilder(parsedAfiSafi.get()).build();
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) RouteRefreshBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.RouteRefreshBuilder) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException)

Example 5 with RouteRefresh

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh 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);
    synchronized (this) {
        final AdjRibOutListener listener = this.adjRibOutListenerSet.remove(key);
        if (listener != null) {
            listener.close();
            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.rev180329.rib.TablesKey)

Aggregations

BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)2 AddPathCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler)2 As4CapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.As4CapabilityHandler)2 BgpExtendedMessageCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.BgpExtendedMessageCapabilityHandler)2 CapabilityParameterParser (org.opendaylight.protocol.bgp.parser.impl.message.open.CapabilityParameterParser)2 GracefulCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler)2 MultiProtocolCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.MultiProtocolCapabilityHandler)2 RouteRefreshCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.RouteRefreshCapabilityHandler)2 AddressFamilyRegistry (org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry)2 SubsequentAddressFamilyRegistry (org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry)2 RouteRefresh (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh)2 ByteBuf (io.netty.buffer.ByteBuf)1 LlGracefulCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler)1 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)1 As4BytesCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapability)1 BgpExtendedMessageCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.BgpExtendedMessageCapability)1 Keepalive (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Keepalive)1 Notify (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify)1 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open)1 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)1