Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.bgp.controller; |
| 17 | |
| 18 | import java.util.TreeMap; |
| 19 | |
| 20 | /** |
| 21 | * Abstraction of an BGP configuration. Manages the BGP configuration from CLI to the BGP controller. |
| 22 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 23 | public interface BgpCfg { |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 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 | |
Shashikanth VH | 580bdeb | 2016-02-19 17:26:03 +0530 | [diff] [blame] | 47 | enum FlowSpec { |
| 48 | |
| 49 | /** |
| 50 | * Signifies that peer support IPV4 flow specification. |
| 51 | */ |
| 52 | IPV4, |
| 53 | |
| 54 | /** |
| 55 | * Signifies that peer support VPNV4 flow specification. |
| 56 | */ |
| 57 | VPNV4, |
| 58 | |
| 59 | /** |
| 60 | * Signifies that peer support IPV4 and VPNV4 flow specification. |
| 61 | */ |
| 62 | IPV4_VPNV4, |
| 63 | |
| 64 | /** |
| 65 | * Signifies that peer flow specification capability disabled. |
| 66 | */ |
| 67 | NONE |
| 68 | } |
| 69 | |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 70 | /** |
| 71 | * Returns the status of the configuration based on this state certain operations like connection is handled. |
| 72 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 73 | * @return State of the configuration |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 74 | */ |
| 75 | State getState(); |
| 76 | |
| 77 | /** |
| 78 | * To set the current state of the configuration. |
| 79 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 80 | * @param state Configuration State enum |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 81 | */ |
| 82 | void setState(State state); |
| 83 | |
| 84 | /** |
| 85 | * Get the status of the link state support for this BGP speaker. |
| 86 | * |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 87 | * @return true if the link state is supported else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 88 | */ |
| 89 | boolean getLsCapability(); |
| 90 | |
| 91 | /** |
| 92 | * Set the link state support to this BGP speaker. |
| 93 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 94 | * @param lscapability true value if link state is supported else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 95 | */ |
| 96 | void setLsCapability(boolean lscapability); |
| 97 | |
| 98 | /** |
| 99 | * Get the status of the 32 bit AS support for this BGP speaker. |
| 100 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 101 | * @return true if the 32 bit AS number is supported else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 102 | */ |
| 103 | boolean getLargeASCapability(); |
| 104 | |
| 105 | /** |
| 106 | * Set the 32 bit AS support capability to this BGP speaker. |
| 107 | * |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 108 | * @param largeAs true value if the 32 bit AS is supported else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 109 | */ |
| 110 | void setLargeASCapability(boolean largeAs); |
| 111 | |
| 112 | /** |
| 113 | * Set the AS number to which this BGP speaker belongs. |
| 114 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 115 | * @param localAs 16 or 32 bit AS number, length is dependent on the capability |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 116 | */ |
| 117 | void setAsNumber(int localAs); |
| 118 | |
| 119 | /** |
| 120 | * Get the AS number to which this BGP speaker belongs. |
| 121 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 122 | * @return 16 or 32 bit AS number, length is dependent on the capability |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 123 | */ |
| 124 | int getAsNumber(); |
| 125 | |
| 126 | /** |
| 127 | * Get the connection retry count number. |
| 128 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 129 | * @return connection retry count if there is a connection error |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 130 | */ |
| 131 | int getMaxConnRetryCount(); |
| 132 | |
| 133 | /** |
| 134 | * Set the connection retry count. |
| 135 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 136 | * @param retryCount number of times to try to connect if there is any error |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 137 | */ |
| 138 | void setMaxConnRetryCout(int retryCount); |
| 139 | |
| 140 | /** |
| 141 | * Get the connection retry time in seconds. |
| 142 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 143 | * @return connection retry time in seconds |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 144 | */ |
| 145 | int getMaxConnRetryTime(); |
| 146 | |
| 147 | /** |
| 148 | * Set the connection retry time in seconds. |
| 149 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 150 | * @param retryTime connection retry times in seconds |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 151 | */ |
| 152 | void setMaxConnRetryTime(int retryTime); |
| 153 | |
| 154 | /** |
| 155 | * Set the keep alive timer for the connection. |
| 156 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 157 | * @param holdTime connection hold timer in seconds |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 158 | */ |
| 159 | void setHoldTime(short holdTime); |
| 160 | |
| 161 | /** |
| 162 | * Returns the connection hold timer in seconds. |
| 163 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 164 | * @return connection hold timer in seconds |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 165 | */ |
| 166 | short getHoldTime(); |
| 167 | |
| 168 | /** |
| 169 | * Returns the maximum number of session supported. |
| 170 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 171 | * @return maximum number of session supported |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 172 | */ |
| 173 | int getMaxSession(); |
| 174 | |
| 175 | /** |
| 176 | * Set the maximum number of sessions to support. |
| 177 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 178 | * @param maxsession maximum number of session |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 179 | */ |
| 180 | void setMaxSession(int maxsession); |
| 181 | |
| 182 | /** |
| 183 | * Returns the Router ID of this BGP speaker. |
| 184 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 185 | * @return IP address in string format |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 186 | */ |
| 187 | String getRouterId(); |
| 188 | |
| 189 | /** |
| 190 | * Set the Router ID of this BGP speaker. |
| 191 | * |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 192 | * @param routerid IP address in string format |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 193 | */ |
| 194 | void setRouterId(String routerid); |
| 195 | |
| 196 | /** |
| 197 | * Add the BGP peer IP address and the AS number to which it belongs. |
| 198 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 199 | * @param routerid IP address in string format |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 200 | * @param remoteAs AS number to which it belongs |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 201 | * |
| 202 | * @return true if added successfully else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 203 | */ |
| 204 | boolean addPeer(String routerid, int remoteAs); |
| 205 | |
| 206 | /** |
| 207 | * Add the BGP peer IP address and the keep alive time. |
| 208 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 209 | * @param routerid IP address in string format |
| 210 | * @param holdTime keep alive time for the connection |
| 211 | * |
| 212 | * @return true if added successfully else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 213 | */ |
| 214 | boolean addPeer(String routerid, short holdTime); |
| 215 | |
| 216 | /** |
| 217 | * Add the BGP peer IP address, the AS number to which it belongs and keep alive time. |
| 218 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 219 | * @param routerid IP address in string format |
| 220 | * @param remoteAs AS number to which it belongs |
| 221 | * @param holdTime keep alive time for the connection |
| 222 | * |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 223 | * @return true if added successfully else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 224 | */ |
| 225 | boolean addPeer(String routerid, int remoteAs, short holdTime); |
| 226 | |
| 227 | /** |
| 228 | * Remove the BGP peer with this IP address. |
| 229 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 230 | * @param routerid router IP address |
| 231 | * |
| 232 | * @return true if removed successfully else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 233 | */ |
| 234 | boolean removePeer(String routerid); |
| 235 | |
| 236 | /** |
| 237 | * Connect to BGP peer with this IP address. |
| 238 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 239 | * @param routerid router IP address |
| 240 | * |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 241 | * @return true of the configuration is found and able to connect else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 242 | */ |
| 243 | boolean connectPeer(String routerid); |
| 244 | |
| 245 | /** |
| 246 | * Disconnect this BGP peer with this IP address. |
| 247 | * |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 248 | * @param routerid router IP address in string format |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 249 | * |
| 250 | * @return true if the configuration is found and able to disconnect else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 251 | */ |
| 252 | boolean disconnectPeer(String routerid); |
| 253 | |
| 254 | /** |
| 255 | * Returns the peer tree information. |
| 256 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 257 | * @return return the tree map with IP as key and BGPPeerCfg as object |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 258 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 259 | TreeMap<String, BgpPeerCfg> displayPeers(); |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 260 | |
| 261 | /** |
| 262 | * Return the BGP Peer information with this matching IP. |
| 263 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 264 | * @param routerid router IP address in string format |
| 265 | * |
| 266 | * @return BGPPeerCfg object |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 267 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 268 | BgpPeerCfg displayPeers(String routerid); |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 269 | |
| 270 | /** |
| 271 | * Check if this BGP peer is configured. |
| 272 | * |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 273 | * @param routerid router IP address in string format |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 274 | * |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 275 | * @return true if configured exists else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 276 | */ |
| 277 | boolean isPeerConfigured(String routerid); |
| 278 | |
| 279 | /** |
| 280 | * Check if this BGP speaker is having connection with the peer. |
| 281 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 282 | * @param routerid router IP address in string format |
| 283 | * |
| 284 | * @return true if the connection exists else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 285 | */ |
| 286 | boolean isPeerConnected(String routerid); |
| 287 | |
| 288 | /** |
| 289 | * Return the peer tree map. |
| 290 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 291 | * @return return the tree map with IP as key and BGPPeerCfg as object |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 292 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 293 | TreeMap<String, BgpPeerCfg> getPeerTree(); |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 294 | |
| 295 | /** |
| 296 | * Set the current connection state information. |
| 297 | * |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 298 | * @param routerid router IP address in string format |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 299 | * @param state state information |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 300 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 301 | void setPeerConnState(String routerid, BgpPeerCfg.State state); |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 302 | |
| 303 | /** |
| 304 | * Check if the peer can be connected or not. |
| 305 | * |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 306 | * @param routerid router IP address in string format |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 307 | * |
Shashikanth VH | 0a82a8e | 2016-02-02 20:42:53 +0530 | [diff] [blame] | 308 | * @return true if the peer can be connected else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 309 | */ |
| 310 | boolean isPeerConnectable(String routerid); |
| 311 | |
| 312 | /** |
| 313 | * Get the current peer connection state information. |
| 314 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 315 | * @param routerid router IP address in string format |
| 316 | * |
| 317 | * @return state information |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 318 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 319 | BgpPeerCfg.State getPeerConnState(String routerid); |
Shashikanth VH | 580bdeb | 2016-02-19 17:26:03 +0530 | [diff] [blame] | 320 | |
| 321 | /** |
| 322 | * Gets the flow specification capability. |
| 323 | * |
| 324 | * @return flow specification capability |
| 325 | */ |
| 326 | FlowSpec flowSpecCapability(); |
| 327 | |
| 328 | /** |
| 329 | * Sets the flow specification capability. |
| 330 | * |
| 331 | * @param flowSpec flow specification capability |
| 332 | */ |
| 333 | void setFlowSpecCapability(FlowSpec flowSpec); |
Shashikanth VH | b650bfa | 2016-04-18 12:54:03 +0530 | [diff] [blame] | 334 | |
| 335 | /** |
| 336 | * Returns the flow specification route policy distribution capability. |
| 337 | * |
| 338 | * @return RDP flow specification capability |
| 339 | */ |
| 340 | boolean flowSpecRpdCapability(); |
| 341 | |
| 342 | /** |
| 343 | * Sets the flow specification route policy distribution capability. |
| 344 | * |
| 345 | * @param rpdCapability flow specification RPD capability |
| 346 | */ |
| 347 | void setFlowSpecRpdCapability(boolean rpdCapability); |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 348 | |
| 349 | /** |
| 350 | * Sets the evpn capability. |
| 351 | * |
| 352 | * @param evpnCapability evpn capability |
| 353 | */ |
| 354 | void setEvpnCapability(boolean evpnCapability); |
| 355 | /** |
| 356 | * Gets the evpn capability. |
| 357 | * |
| 358 | * @return evpn capability |
| 359 | */ |
| 360 | boolean getEvpnCapability(); |
| 361 | |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 362 | } |