2 * Copyright (c) 2014 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.impl.spi;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
12 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Open;
16 import org.opendaylight.yangtools.concepts.Registration;
19 * Registry that contains configured bgp peers ready for when a bgp session is established with remote peer.
20 * IP address is uses as a key for configured peers. TODO Is IP sufficient ID for peers ?
22 public interface BGPPeerRegistry extends AutoCloseable {
25 * Add configured peer, its IP address and preferences. To be used when a BGP session is established.
27 * @param ip address of remote peer
28 * @param peer configured peer as BGPSessionListener
29 * @param prefs session preferences for configured peer
31 void addPeer(IpAddress ip, BGPSessionListener peer, BGPSessionPreferences prefs);
34 * Remove configured peer from registry.
36 * @param ip address of remote peer
38 void removePeer(@NonNull IpAddress ip);
41 * Remove peer session from registry.
43 * @param ip address of remote peer
45 void removePeerSession(@NonNull IpAddress ip);
48 * Check whether peer on provided IP address is present in this registry.
50 * @param ip address of remote peer
51 * @return true if peer is present false otherwise
53 boolean isPeerConfigured(@NonNull IpAddress ip);
56 * Get configured peer after BGP session was successfully established. Called by negotiators.
58 * @param ip address of remote peer
59 * @param sourceId BGP ID of peer that initiated the session (current device or remote peer)
60 * @param remoteId BGP ID of peer that accepted the session (current device or remote peer)
61 * @param open remote Open message
62 * @return BGPSessionListener configured Peer as BGP listener
64 * @throws BGPDocumentedException if session establishment cannot be finished successfully
65 * @throws java.lang.IllegalStateException if there is no peer configured for provided ip address
67 BGPSessionListener getPeer(IpAddress ip, Ipv4Address sourceId, Ipv4Address remoteId, Open open)
68 throws BGPDocumentedException;
71 * Get preferences for a remote peer.
73 * @param ip address of remote peer
74 * @return BGP session preferences for configured peer
75 * @throws IllegalStateException if there is no peer configured for provided ip address
77 BGPSessionPreferences getPeerPreferences(IpAddress ip);
80 * Register PeerRegistryListener, which listens to the changes in peer
81 * registry (add peer, remove peer). After registration, an initial
82 * drop is provided by calling onPeerAdded().
84 * @param listener The PeerRegistryListener to be registered.
85 * @return Registration ticked, used for closing of registration.
87 @NonNull Registration registerPeerRegisterListener(@NonNull PeerRegistryListener listener);
90 * Register PeerRegistrySessionListener, which listens to the changes in sessions
91 * of peers in peer registry (create session, remove session). After registration,
92 * an initial drop is provided by calling onSessionCreated().
94 * @param listener The PeerRegistrySessionListener to be registered.
95 * @return Registration ticked, used for closing of registration.
97 @NonNull Registration registerPeerSessionListener(PeerRegistrySessionListener listener);
100 * Set new preferences. In case of graceful restart execution we need to send
101 * updated GracefulRestartCapability when sesison re-establish, information
102 * which tables where preserved during restart will change.
103 * Note that this method only updates preferences of already registered peer.
104 * To add new peer to registry use addPeer().
106 * @param ip of neighbor
107 * @param preferences to send in OPEN message
109 void updatePeerPreferences(IpAddress ip, BGPSessionPreferences preferences);