fad64a23e60273a36c9f69a222ed9bc85a1ed8d7
[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 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.rev100924.IpAddress;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
15
16 /**
17  * Registry that contains configured bgp peers ready for when a bgp session is established with remote peer.
18  * IP address is uses as a key for configured peers. TODO Is IP sufficient ID for peers ?
19  */
20 public interface BGPPeerRegistry extends AutoCloseable {
21
22     /**
23      * Add configured peer, its IP address and preferences. To be used when a BGP session is established.
24      *
25      * @param ip address of remote peer
26      * @param peer configured peer as ReusableBGPPeer
27      * @param prefs session preferences for configured peer
28      */
29     void addPeer(IpAddress ip, ReusableBGPPeer peer, BGPSessionPreferences prefs);
30
31     /**
32      * Remove configured peer from registry.
33      *
34      * @param ip address of remote peer
35      */
36     void removePeer(IpAddress ip);
37
38     /**
39      * Remove peer session from registry.
40      *
41      * @param ip address of remote peer
42      */
43     void removePeerSession(IpAddress ip);
44
45     /**
46      * Check whether peer on provided IP address is present in this registry.
47      *
48      * @param ip address of remote peer
49      * @return true if peer is present false otherwise
50      */
51     boolean isPeerConfigured(IpAddress ip);
52
53     /**
54      * Get configured peer after BGP session was successfully established. Called by negotiators.
55      *
56      * @param ip address of remote peer
57      * @param sourceId BGP ID of peer that initiated the session (current device or remote peer)
58      * @param remoteId BGP ID of peer that accepted the session (current device or remote peer)
59      * @return configured Peer as BGP listener
60      *
61      * @throws BGPDocumentedException if session establishment cannot be finished successfully
62      * @throws java.lang.IllegalStateException if there is no peer configured for provided ip address
63      */
64     BGPSessionListener getPeer(IpAddress ip, Ipv4Address sourceId, Ipv4Address remoteId) throws BGPDocumentedException;
65
66     /**
67      * @param ip address of remote peer
68      * @return BGP session preferences for configured peer
69      *
70      * @throws java.lang.IllegalStateException if there is no peer configured for provided ip address
71      */
72     BGPSessionPreferences getPeerPreferences(IpAddress ip);
73
74 }