Mass-convert all compontents to use -no-zone addresses
[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 package org.opendaylight.protocol.bgp.rib.impl.spi;
9
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.IpAddressNoZone;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Open;
16 import org.opendaylight.yangtools.concepts.Registration;
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(IpAddressNoZone 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 IpAddressNoZone ip);
39
40     /**
41      * Remove peer session from registry.
42      *
43      * @param ip address of remote peer
44      */
45     void removePeerSession(@NonNull IpAddressNoZone 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 IpAddressNoZone 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(IpAddressNoZone ip, Ipv4AddressNoZone sourceId, Ipv4AddressNoZone remoteId, Open open)
68             throws BGPDocumentedException;
69
70     /**
71      * Get preferences for a remote peer.
72      *
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
76      */
77     BGPSessionPreferences getPeerPreferences(IpAddressNoZone ip);
78
79     /**
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().
83      *
84      * @param listener The PeerRegistryListener to be registered.
85      * @return Registration ticked, used for closing of registration.
86      */
87     @NonNull Registration registerPeerRegisterListener(@NonNull PeerRegistryListener listener);
88
89     /**
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().
93      *
94      * @param listener The PeerRegistrySessionListener to be registered.
95      * @return Registration ticked, used for closing of registration.
96      */
97     @NonNull Registration registerPeerSessionListener(PeerRegistrySessionListener listener);
98
99     /**
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().
105      *
106      * @param ip of neighbor
107      * @param preferences to send in OPEN message
108      */
109     void updatePeerPreferences(IpAddressNoZone ip, BGPSessionPreferences preferences);
110 }