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
9 package org.opendaylight.protocol.bgp.rib.impl.spi;
11 import javax.annotation.Nonnull;
12 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
13 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Open;
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 * @param ip address of remote peer
72 * @return BGP session preferences for configured peer
74 * @throws java.lang.IllegalStateException if there is no peer configured for provided ip address
76 BGPSessionPreferences getPeerPreferences(IpAddress ip);
79 * Register PeerRegistryListener, which listens to the changes in peer
80 * registry (add peer, remove peer). After registration, an initial
81 * drop is provided by calling onPeerAdded().
83 * @param listener The PeerRegistryListener to be registered.
84 * @return Registration ticked, used for closing of registration.
86 @Nonnull AutoCloseable registerPeerRegisterListener(@Nonnull PeerRegistryListener listener);
89 * Register PeerRegistrySessionListener, which listens to the changes in sessions
90 * of peers in peer registry (create session, remove session). After registration,
91 * an initial drop is provided by calling onSessionCreated().
93 * @param listener The PeerRegistrySessionListener to be registered.
94 * @return Registration ticked, used for closing of registration.
96 @Nonnull AutoCloseable registerPeerSessionListener(PeerRegistrySessionListener listener);