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