blob: 4620d18861d3fc52330bbaa4f95e5deca0efc83c [file] [log] [blame]
Satish Ke107e662015-09-21 19:00:17 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Satish Ke107e662015-09-21 19:00:17 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.bgp.controller;
18
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053019import org.onosproject.bgpio.exceptions.BgpParseException;
20import org.onosproject.bgpio.protocol.BgpMessage;
Satish Ke107e662015-09-21 19:00:17 +053021
mohamedrahil00f6f262016-11-24 20:20:41 +053022import java.util.List;
Jonathan Hart51539b82015-10-29 09:53:04 -070023import java.util.Map;
24import java.util.Set;
25
Satish Ke107e662015-09-21 19:00:17 +053026/**
Shashikanth VHf62b5c02015-11-20 22:23:08 +053027 * Abstraction of an BGP controller. Serves as a one stop shop for obtaining BGP devices and (un)register listeners on
28 * bgp events
Satish Ke107e662015-09-21 19:00:17 +053029 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053030public interface BgpController {
Satish Ke107e662015-09-21 19:00:17 +053031
32 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053033 * Returns list of bgp peers connected to this BGP controller.
34 *
35 * @return Iterable of BGPPeer elements
36 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053037 Iterable<BgpPeer> getPeers();
Shashikanth VH6de20d32015-10-09 12:04:13 +053038
39 /**
40 * Returns the actual bgp peer for the given ip address.
41 *
42 * @param bgpId the id of the bgp peer to fetch
43 * @return the interface to this bgp peer
44 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053045 BgpPeer getPeer(BgpId bgpId);
Shashikanth VH6de20d32015-10-09 12:04:13 +053046
47 /**
Shashikanth VHf62b5c02015-11-20 22:23:08 +053048 * Register a listener for BGP message events.
49 *
50 * @param listener the listener to notify
51 */
52 void addListener(BgpNodeListener listener);
53
54 /**
55 * Unregister a listener.
56 *
57 * @param listener the listener to unregister
58 */
59 void removeListener(BgpNodeListener listener);
60
61 /**
Satish Ke107e662015-09-21 19:00:17 +053062 * Send a message to a particular bgp peer.
63 *
64 * @param bgpId the id of the peer to send message.
mohamedrahil00f6f262016-11-24 20:20:41 +053065 * @param msg the message to send
Satish Ke107e662015-09-21 19:00:17 +053066 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053067 void writeMsg(BgpId bgpId, BgpMessage msg);
Satish Ke107e662015-09-21 19:00:17 +053068
69 /**
70 * Process a message and notify the appropriate listeners.
71 *
72 * @param bgpId id of the peer the message arrived on
mohamedrahil00f6f262016-11-24 20:20:41 +053073 * @param msg the message to process.
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053074 * @throws BgpParseException on data processing error
Satish Ke107e662015-09-21 19:00:17 +053075 */
Jonathan Hart51539b82015-10-29 09:53:04 -070076 void processBgpPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException;
Satish Ke107e662015-09-21 19:00:17 +053077
78 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053079 * Close all connected BGP peers.
Shashikanth VH6de20d32015-10-09 12:04:13 +053080 */
81 void closeConnectedPeers();
82
83 /**
Satish Ke107e662015-09-21 19:00:17 +053084 * Get the BGPConfig class to the caller.
85 *
86 * @return configuration object
87 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053088 BgpCfg getConfig();
Shashikanth VH6de20d32015-10-09 12:04:13 +053089
90 /**
91 * Get the BGP connected peers to this controller.
92 *
93 * @return the integer number
94 */
Shashikanth VH9f8afb42015-11-04 18:00:30 +053095 int connectedPeerCount();
96
97 /**
Shashikanth VH3fe37982015-11-30 11:50:07 +053098 * Return BGP local RIB instance with VPN.
99 *
100 * @return BGPLocalRibImpl local RIB with VPN
101 */
102 BgpLocalRib bgpLocalRibVpn();
103
104 /**
105 * Return BGP local RIB instance.
106 *
107 * @return BGPLocalRibImpl local RIB
108 */
109 BgpLocalRib bgpLocalRib();
110
111 /**
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530112 * Return BGP peer manager.
113 *
114 * @return BGPPeerManager peer manager instance
115 */
116 BgpPeerManager peerManager();
117
118 /**
119 * Return BGP connected peers.
120 *
121 * @return connectedPeers connected peers
122 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530123 Map<BgpId, BgpPeer> connectedPeers();
Shashikanth VHf62b5c02015-11-20 22:23:08 +0530124
125 /**
126 * Return BGP node listener.
127 *
128 * @return node listener
129 */
130 Set<BgpNodeListener> listener();
Priyanka Bfc51c952016-03-26 14:30:33 +0530131
132 /**
133 * Register a listener for BGP message events.
134 *
135 * @param listener the listener to notify
136 */
137 void addLinkListener(BgpLinkListener listener);
138
139 /**
140 * Unregister a listener.
141 *
142 * @param listener the listener to unregister
143 */
144 void removeLinkListener(BgpLinkListener listener);
145
146 /**
147 * Return BGP link listener.
148 *
149 * @return link listener
150 */
151 Set<BgpLinkListener> linkListener();
mohamedrahil00f6f262016-11-24 20:20:41 +0530152
153 /**
Maciej Skala3251a302019-03-26 09:16:55 +0100154 * Register a listener for BGP Prefix message events.
155 *
156 * @param listener the listener to notify
157 */
158 void addPrefixListener(BgpPrefixListener listener);
159
160 /**
161 * Unregister a listener for BGP Prefix message events.
162 *
163 * @param listener the listener to unregister
164 */
165 void removePrefixListener(BgpPrefixListener listener);
166
167 /**
168 * Returns set of BGP prefix listeners.
169 *
170 * @return set of BGP prefix listeners
171 */
172 Set<BgpPrefixListener> prefixListener();
173
174 /**
Ray Milkeyc108a6b2017-08-23 15:23:50 -0700175 * Stores the exceptions occurred during an active session.
mohamedrahil00f6f262016-11-24 20:20:41 +0530176 *
177 * @param peerId BGP peer id
178 * @param exception exceptions based on the peer id.
179 */
180 void activeSessionExceptionAdd(String peerId, String exception);
181
182 /**
Ray Milkeyc108a6b2017-08-23 15:23:50 -0700183 * Stores the exceptions occurred during an closed session.
mohamedrahil00f6f262016-11-24 20:20:41 +0530184 *
185 * @param peerId BGP peer id
186 * @param exception exceptions based on the peer id
187 */
188 void closedSessionExceptionAdd(String peerId, String exception);
189
190 /**
191 * Return active session exceptions.
192 *
193 * @return activeSessionMap
194 */
195 Map<String, List<String>> activeSessionMap();
196
197 /**
198 * Return closed session exceptions.
199 *
200 * @return closedSessionMap
201 */
202 Map<String, List<String>> closedSessionMap();
Mohammad Shahid30fedc52017-08-09 11:49:40 +0530203 /**
204 * Register a listener for BGP message events.
205 *
206 * @param listener the listener to notify
207 */
208 void addRouteListener(BgpRouteListener listener);
209
210 /**
211 * Unregister a listener.
212 *
213 * @param listener the listener to unregister
214 */
215 void removeRouteListener(BgpRouteListener listener);
216
217 /**
218 * Return BGP route listener.
219 *
220 * @return route listener
221 */
222 Set<BgpRouteListener> routeListener();
mohamedrahil00f6f262016-11-24 20:20:41 +0530223
Shashikanth VHf62b5c02015-11-20 22:23:08 +0530224}