2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.bgp.rib.spi;
10 import io.netty.channel.ChannelInboundHandler;
11 import io.netty.util.concurrent.ScheduledFuture;
12 import java.util.List;
14 import java.util.concurrent.TimeUnit;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.protocol.bgp.parser.GracefulRestartUtil;
17 import org.opendaylight.protocol.bgp.parser.spi.PeerConstraint;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapability;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.add.path.capability.AddressFamilies;
26 * BGP Session represents the finite state machine in BGP, including timers and its purpose is to create a BGP
27 * connection between BGP speakers. Session is automatically started, when TCP connection is created,
28 * but can be stopped manually via close method of the {@link java.io.Closeable} interface.
29 * If the session is up, it has to redirect messages to/from user. Handles also malformed messages and unknown requests.
31 public interface BGPSession extends AutoCloseable, ChannelInboundHandler {
33 * Return the list of tables which the peer has advertised to support.
35 * @return Set of tables which it supports.
37 @NonNull Set<BgpTableType> getAdvertisedTableTypes();
40 * Return the BGP router ID advertised by the peer.
42 * @return Peer's BGP Router ID.
44 @NonNull Ipv4Address getBgpId();
47 * Return the AS number which the peer advertises.
49 * @return Peer's AS Number
51 @NonNull AsNumber getAsNumber();
54 * Return a list with Add Path tables supported advertised and corresponding SendReceive mode.
56 * @return AddPathTables supported
58 @NonNull List<AddressFamilies> getAdvertisedAddPathTableTypes();
61 * Return advertised graceful capability containing the list of tables which the peer has advertised to support,
62 * restart time and restarting flags.
64 * @return Advertised graceful restart capability.
66 default @NonNull GracefulRestartCapability getAdvertisedGracefulRestartCapability() {
67 return GracefulRestartUtil.EMPTY_GR_CAPABILITY;
71 * Return advertised long-lived graceful capability containing the list of tables with stale time which
72 * the peer has advertised to support.
74 * @return Advertised long-lived graceful restart capability.
76 default @NonNull LlGracefulRestartCapability getAdvertisedLlGracefulRestartCapability() {
77 return GracefulRestartUtil.EMPTY_LLGR_CAPABILITY;
81 * Close peer session without sending Notification message.
83 void closeWithoutMessage();
86 * Add peer constraint to session pipeline decoder.
88 <T extends PeerConstraint> void addDecoderConstraint(Class<T> constraintClass, T constraint);
91 * Schedule a task to be executed in the context of the session handling thread.
93 * @param command the task to execute
94 * @param delay the time from now to delay execution
95 * @param unit the time unit of the delay parameter
96 * @return Future representing the scheduled task.
98 ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit);