blob: 6f64d2bb13d56a7261dc40514d7cf0b6d4e45a16 [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 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053023public interface BgpCfg {
Thejaswi N K6a4cd002015-09-21 17:19:55 +053024
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 *
Satish Ke107e662015-09-21 19:00:17 +053050 * @return State of the configuration
Thejaswi N K6a4cd002015-09-21 17:19:55 +053051 */
52 State getState();
53
54 /**
55 * To set the current state of the configuration.
56 *
Satish Ke107e662015-09-21 19:00:17 +053057 * @param state Configuration State enum
Thejaswi N K6a4cd002015-09-21 17:19:55 +053058 */
59 void setState(State state);
60
61 /**
62 * Get the status of the link state support for this BGP speaker.
63 *
Satish Ke107e662015-09-21 19:00:17 +053064 * @return true if the link state is supported else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +053065 */
66 boolean getLsCapability();
67
68 /**
69 * Set the link state support to this BGP speaker.
70 *
Satish Ke107e662015-09-21 19:00:17 +053071 * @param lscapability true value if link state is supported else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +053072 */
73 void setLsCapability(boolean lscapability);
74
75 /**
76 * Get the status of the 32 bit AS support for this BGP speaker.
77 *
Satish Ke107e662015-09-21 19:00:17 +053078 * @return true if the 32 bit AS number is supported else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +053079 */
80 boolean getLargeASCapability();
81
82 /**
83 * Set the 32 bit AS support capability to this BGP speaker.
84 *
Satish Ke107e662015-09-21 19:00:17 +053085 * @param largeAs true value if the 32 bit AS is supported else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +053086 */
87 void setLargeASCapability(boolean largeAs);
88
89 /**
90 * Set the AS number to which this BGP speaker belongs.
91 *
Satish Ke107e662015-09-21 19:00:17 +053092 * @param localAs 16 or 32 bit AS number, length is dependent on the capability
Thejaswi N K6a4cd002015-09-21 17:19:55 +053093 */
94 void setAsNumber(int localAs);
95
96 /**
97 * Get the AS number to which this BGP speaker belongs.
98 *
Satish Ke107e662015-09-21 19:00:17 +053099 * @return 16 or 32 bit AS number, length is dependent on the capability
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530100 */
101 int getAsNumber();
102
103 /**
104 * Get the connection retry count number.
105 *
Satish Ke107e662015-09-21 19:00:17 +0530106 * @return connection retry count if there is a connection error
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530107 */
108 int getMaxConnRetryCount();
109
110 /**
111 * Set the connection retry count.
112 *
Satish Ke107e662015-09-21 19:00:17 +0530113 * @param retryCount number of times to try to connect if there is any error
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530114 */
115 void setMaxConnRetryCout(int retryCount);
116
117 /**
118 * Get the connection retry time in seconds.
119 *
Satish Ke107e662015-09-21 19:00:17 +0530120 * @return connection retry time in seconds
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530121 */
122 int getMaxConnRetryTime();
123
124 /**
125 * Set the connection retry time in seconds.
126 *
Satish Ke107e662015-09-21 19:00:17 +0530127 * @param retryTime connection retry times in seconds
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530128 */
129 void setMaxConnRetryTime(int retryTime);
130
131 /**
132 * Set the keep alive timer for the connection.
133 *
Satish Ke107e662015-09-21 19:00:17 +0530134 * @param holdTime connection hold timer in seconds
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530135 */
136 void setHoldTime(short holdTime);
137
138 /**
139 * Returns the connection hold timer in seconds.
140 *
Satish Ke107e662015-09-21 19:00:17 +0530141 * @return connection hold timer in seconds
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530142 */
143 short getHoldTime();
144
145 /**
146 * Returns the maximum number of session supported.
147 *
Satish Ke107e662015-09-21 19:00:17 +0530148 * @return maximum number of session supported
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530149 */
150 int getMaxSession();
151
152 /**
153 * Set the maximum number of sessions to support.
154 *
Satish Ke107e662015-09-21 19:00:17 +0530155 * @param maxsession maximum number of session
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530156 */
157 void setMaxSession(int maxsession);
158
159 /**
160 * Returns the Router ID of this BGP speaker.
161 *
Satish Ke107e662015-09-21 19:00:17 +0530162 * @return IP address in string format
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530163 */
164 String getRouterId();
165
166 /**
167 * Set the Router ID of this BGP speaker.
168 *
Satish Ke107e662015-09-21 19:00:17 +0530169 * @param routerid IP address in string format
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530170 */
171 void setRouterId(String routerid);
172
173 /**
174 * Add the BGP peer IP address and the AS number to which it belongs.
175 *
Satish Ke107e662015-09-21 19:00:17 +0530176 * @param routerid IP address in string format
177 * @param remoteAs AS number to which it belongs
178 *
179 * @return true if added successfully else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530180 */
181 boolean addPeer(String routerid, int remoteAs);
182
183 /**
184 * Add the BGP peer IP address and the keep alive time.
185 *
Satish Ke107e662015-09-21 19:00:17 +0530186 * @param routerid IP address in string format
187 * @param holdTime keep alive time for the connection
188 *
189 * @return true if added successfully else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530190 */
191 boolean addPeer(String routerid, short holdTime);
192
193 /**
194 * Add the BGP peer IP address, the AS number to which it belongs and keep alive time.
195 *
Satish Ke107e662015-09-21 19:00:17 +0530196 * @param routerid IP address in string format
197 * @param remoteAs AS number to which it belongs
198 * @param holdTime keep alive time for the connection
199 *
200 * @return true if added successfully else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530201 */
202 boolean addPeer(String routerid, int remoteAs, short holdTime);
203
204 /**
205 * Remove the BGP peer with this IP address.
206 *
Satish Ke107e662015-09-21 19:00:17 +0530207 * @param routerid router IP address
208 *
209 * @return true if removed successfully else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530210 */
211 boolean removePeer(String routerid);
212
213 /**
214 * Connect to BGP peer with this IP address.
215 *
Satish Ke107e662015-09-21 19:00:17 +0530216 * @param routerid router IP address
217 *
218 * @return true of the configuration is found and able to connect else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530219 */
220 boolean connectPeer(String routerid);
221
222 /**
223 * Disconnect this BGP peer with this IP address.
224 *
Satish Ke107e662015-09-21 19:00:17 +0530225 * @param routerid router IP address in string format
226 *
227 * @return true if the configuration is found and able to disconnect else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530228 */
229 boolean disconnectPeer(String routerid);
230
231 /**
232 * Returns the peer tree information.
233 *
Satish Ke107e662015-09-21 19:00:17 +0530234 * @return return the tree map with IP as key and BGPPeerCfg as object
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530235 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530236 TreeMap<String, BgpPeerCfg> displayPeers();
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530237
238 /**
239 * Return the BGP Peer information with this matching IP.
240 *
Satish Ke107e662015-09-21 19:00:17 +0530241 * @param routerid router IP address in string format
242 *
243 * @return BGPPeerCfg object
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530244 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530245 BgpPeerCfg displayPeers(String routerid);
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530246
247 /**
248 * Check if this BGP peer is configured.
249 *
Satish Ke107e662015-09-21 19:00:17 +0530250 * @param routerid router IP address in string format
251 *
252 * @return true if configured exists else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530253 */
254 boolean isPeerConfigured(String routerid);
255
256 /**
257 * Check if this BGP speaker is having connection with the peer.
258 *
Satish Ke107e662015-09-21 19:00:17 +0530259 * @param routerid router IP address in string format
260 *
261 * @return true if the connection exists else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530262 */
263 boolean isPeerConnected(String routerid);
264
265 /**
266 * Return the peer tree map.
267 *
Satish Ke107e662015-09-21 19:00:17 +0530268 * @return return the tree map with IP as key and BGPPeerCfg as object
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530269 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530270 TreeMap<String, BgpPeerCfg> getPeerTree();
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530271
272 /**
273 * Set the current connection state information.
274 *
Satish Ke107e662015-09-21 19:00:17 +0530275 * @param routerid router IP address in string format
276 * @param state state information
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530277 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530278 void setPeerConnState(String routerid, BgpPeerCfg.State state);
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530279
280 /**
281 * Check if the peer can be connected or not.
282 *
Satish Ke107e662015-09-21 19:00:17 +0530283 * @param routerid router IP address in string format
284 *
285 * @return true if the peer can be connected else false
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530286 */
287 boolean isPeerConnectable(String routerid);
288
289 /**
290 * Get the current peer connection state information.
291 *
Satish Ke107e662015-09-21 19:00:17 +0530292 * @param routerid router IP address in string format
293 *
294 * @return state information
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530295 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530296 BgpPeerCfg.State getPeerConnState(String routerid);
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530297}