MVPN RFC6514 Extendend communities
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / spi / BGPPeerRegistry.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.protocol.bgp.rib.impl.spi;
10
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;
17
18 /**
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 ?
21  */
22 public interface BGPPeerRegistry extends AutoCloseable {
23
24     /**
25      * Add configured peer, its IP address and preferences. To be used when a BGP session is established.
26      *
27      * @param ip address of remote peer
28      * @param peer configured peer as BGPSessionListener
29      * @param prefs session preferences for configured peer
30      */
31     void addPeer(IpAddress ip, BGPSessionListener peer, BGPSessionPreferences prefs);
32
33     /**
34      * Remove configured peer from registry.
35      *
36      * @param ip address of remote peer
37      */
38     void removePeer(@Nonnull IpAddress ip);
39
40     /**
41      * Remove peer session from registry.
42      *
43      * @param ip address of remote peer
44      */
45     void removePeerSession(@Nonnull IpAddress ip);
46
47     /**
48      * Check whether peer on provided IP address is present in this registry.
49      *
50      * @param ip address of remote peer
51      * @return true if peer is present false otherwise
52      */
53     boolean isPeerConfigured(@Nonnull IpAddress ip);
54
55     /**
56      * Get configured peer after BGP session was successfully established. Called by negotiators.
57      *
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
63      *
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
66      */
67     BGPSessionListener getPeer(IpAddress ip, Ipv4Address sourceId, Ipv4Address remoteId, Open open) throws BGPDocumentedException;
68
69     /**
70      * @param ip address of remote peer
71      * @return BGP session preferences for configured peer
72      *
73      * @throws java.lang.IllegalStateException if there is no peer configured for provided ip address
74      */
75     BGPSessionPreferences getPeerPreferences(IpAddress ip);
76
77     /**
78      * Register PeerRegistryListener, which listens to the changes in peer
79      * registry (add peer, remove peer). After registration, an initial
80      * drop is provided by calling onPeerAdded().
81      *
82      * @param listener The PeerRegistryListener to be registered.
83      * @return Registration ticked, used for closing of registration.
84      */
85     @Nonnull AutoCloseable registerPeerRegisterListener(@Nonnull PeerRegistryListener listener);
86
87     /**
88      * Register PeerRegistrySessionListener, which listens to the changes in sessions
89      * of peers in peer registry (create session, remove session). After registration,
90      * an initial drop is provided by calling onSessionCreated().
91      *
92      * @param listener The PeerRegistrySessionListener to be registered.
93      * @return Registration ticked, used for closing of registration.
94      */
95     @Nonnull AutoCloseable registerPeerSessionListener(PeerRegistrySessionListener listener);
96
97 }