blob: a8edf5ebbe2e6b8aac5ebaeeb36c2adb6da6c10e [file] [log] [blame]
Thejaswi N K6a4cd002015-09-21 17:19:55 +05301/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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 */
16package org.onosproject.bgp.controller;
17
18import java.util.TreeMap;
19
20/**
21 * Abstraction of an BGP configuration. Manages the BGP configuration from CLI to the BGP controller.
22 */
23public interface BGPCfg {
24
25 enum State {
26 /**
27 * Signifies that its just created.
28 */
29 INIT,
30
31 /**
32 * Signifies that only IP Address is configured.
33 */
34 IP_CONFIGURED,
35
36 /**
37 * Signifies that only Autonomous System is configured.
38 */
39 AS_CONFIGURED,
40
41 /**
42 * Signifies that both IP and Autonomous System is configured.
43 */
44 IP_AS_CONFIGURED
45 }
46
47 /**
48 * Returns the status of the configuration based on this state certain operations like connection is handled.
49 *
50 * @return
51 * State of the configuration
52 */
53 State getState();
54
55 /**
56 * To set the current state of the configuration.
57 *
58 * @param state
59 * Configuration State enum
60 */
61 void setState(State state);
62
63 /**
64 * Get the status of the link state support for this BGP speaker.
65 *
66 * @return
67 * true if the link state is supported else false
68 */
69 boolean getLsCapability();
70
71 /**
72 * Set the link state support to this BGP speaker.
73 *
74 * @param lscapability
75 * true value if link state is supported else false
76 */
77 void setLsCapability(boolean lscapability);
78
79 /**
80 * Get the status of the 32 bit AS support for this BGP speaker.
81 *
82 * @return
83 * true if the 32 bit AS number is supported else false
84 */
85 boolean getLargeASCapability();
86
87 /**
88 * Set the 32 bit AS support capability to this BGP speaker.
89 *
90 * @param largeAs
91 * true value if the 32 bit AS is supported else false
92 */
93 void setLargeASCapability(boolean largeAs);
94
95 /**
96 * Set the AS number to which this BGP speaker belongs.
97 *
98 * @param localAs
99 * 16 or 32 bit AS number, length is dependent on the capability
100 */
101 void setAsNumber(int localAs);
102
103 /**
104 * Get the AS number to which this BGP speaker belongs.
105 *
106 * @return
107 * 16 or 32 bit AS number, length is dependent on the capability
108 */
109 int getAsNumber();
110
111 /**
112 * Get the connection retry count number.
113 *
114 * @return
115 * connection retry count if there is a connection error
116 */
117 int getMaxConnRetryCount();
118
119 /**
120 * Set the connection retry count.
121 *
122 * @param retryCount
123 * number of times to try to connect if there is any error
124 */
125 void setMaxConnRetryCout(int retryCount);
126
127 /**
128 * Get the connection retry time in seconds.
129 *
130 * @return
131 * connection retry time in seconds
132 */
133 int getMaxConnRetryTime();
134
135 /**
136 * Set the connection retry time in seconds.
137 *
138 * @param retryTime
139 * connection retry times in seconds
140 */
141 void setMaxConnRetryTime(int retryTime);
142
143 /**
144 * Set the keep alive timer for the connection.
145 *
146 * @param holdTime
147 * connection hold timer in seconds
148 */
149 void setHoldTime(short holdTime);
150
151 /**
152 * Returns the connection hold timer in seconds.
153 *
154 * @return
155 * connection hold timer in seconds
156 */
157 short getHoldTime();
158
159 /**
160 * Returns the maximum number of session supported.
161 *
162 * @return
163 * maximum number of session supported
164 */
165 int getMaxSession();
166
167 /**
168 * Set the maximum number of sessions to support.
169 *
170 * @param maxsession
171 * maximum number of session
172 */
173 void setMaxSession(int maxsession);
174
175 /**
176 * Returns the Router ID of this BGP speaker.
177 *
178 * @return
179 * IP address in string format
180 */
181 String getRouterId();
182
183 /**
184 * Set the Router ID of this BGP speaker.
185 *
186 * @param routerid
187 * IP address in string format
188 */
189 void setRouterId(String routerid);
190
191 /**
192 * Add the BGP peer IP address and the AS number to which it belongs.
193 *
194 * @param routerid
195 * IP address in string format
196 * @param remoteAs
197 * AS number to which it belongs
198 * @return
199 * true if added successfully else false
200 */
201 boolean addPeer(String routerid, int remoteAs);
202
203 /**
204 * Add the BGP peer IP address and the keep alive time.
205 *
206 * @param routerid
207 * IP address in string format
208 * @param holdTime
209 * keep alive time for the connection
210 * @return
211 * true if added successfully else false
212 */
213 boolean addPeer(String routerid, short holdTime);
214
215 /**
216 * Add the BGP peer IP address, the AS number to which it belongs and keep alive time.
217 *
218 * @param routerid
219 * IP address in string format
220 * @param remoteAs
221 * AS number to which it belongs
222 * @param holdTime
223 * keep alive time for the connection
224 * @return
225 * true if added successfully else false
226 */
227 boolean addPeer(String routerid, int remoteAs, short holdTime);
228
229 /**
230 * Remove the BGP peer with this IP address.
231 *
232 * @param routerid
233 * router IP address
234 * @return
235 * true if removed successfully else false
236 */
237 boolean removePeer(String routerid);
238
239 /**
240 * Connect to BGP peer with this IP address.
241 *
242 * @param routerid
243 * router IP address
244 * @return
245 * true of the configuration is found and able to connect else false
246 */
247 boolean connectPeer(String routerid);
248
249 /**
250 * Disconnect this BGP peer with this IP address.
251 *
252 * @param routerid
253 * router IP address in string format
254 * @return
255 * true if the configuration is found and able to disconnect else false
256 */
257 boolean disconnectPeer(String routerid);
258
259 /**
260 * Returns the peer tree information.
261 *
262 * @return
263 * return the tree map with IP as key and BGPPeerCfg as object
264 */
265 TreeMap<String, BGPPeerCfg> displayPeers();
266
267 /**
268 * Return the BGP Peer information with this matching IP.
269 *
270 * @param routerid
271 * router IP address in string format
272 * @return
273 * BGPPeerCfg object
274 */
275 BGPPeerCfg displayPeers(String routerid);
276
277 /**
278 * Check if this BGP peer is configured.
279 *
280 * @param routerid
281 * router IP address in string format
282 * @return
283 * true if configured exists else false
284 */
285 boolean isPeerConfigured(String routerid);
286
287 /**
288 * Check if this BGP speaker is having connection with the peer.
289 *
290 * @param routerid
291 * router IP address in string format
292 * @return
293 * true if the connection exists else false
294 */
295 boolean isPeerConnected(String routerid);
296
297 /**
298 * Return the peer tree map.
299 *
300 * @return
301 * return the tree map with IP as key and BGPPeerCfg as object
302 */
303 TreeMap<String, BGPPeerCfg> getPeerTree();
304
305 /**
306 * Set the current connection state information.
307 *
308 * @param routerid
309 * router IP address in string format
310 * @param state
311 * state information
312 */
313 void setPeerConnState(String routerid, BGPPeerCfg.State state);
314
315 /**
316 * Check if the peer can be connected or not.
317 *
318 * @param routerid
319 * router IP address in string format
320 * @return
321 * true if the peer can be connected else false
322 */
323 boolean isPeerConnectable(String routerid);
324
325 /**
326 * Get the current peer connection state information.
327 *
328 * @param routerid
329 * router IP address in string format
330 * @return
331 * state information
332 */
333 BGPPeerCfg.State getPeerConnState(String routerid);
334}