Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 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 | |
| 47 | /** |
| 48 | * Returns the status of the configuration based on this state certain operations like connection is handled. |
| 49 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 50 | * @return State of the configuration |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 51 | */ |
| 52 | State getState(); |
| 53 | |
| 54 | /** |
| 55 | * To set the current state of the configuration. |
| 56 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 57 | * @param state Configuration State enum |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 58 | */ |
| 59 | void setState(State state); |
| 60 | |
| 61 | /** |
| 62 | * Get the status of the link state support for this BGP speaker. |
| 63 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 64 | * @return true if the link state is supported else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 65 | */ |
| 66 | boolean getLsCapability(); |
| 67 | |
| 68 | /** |
| 69 | * Set the link state support to this BGP speaker. |
| 70 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 71 | * @param lscapability true value if link state is supported else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 72 | */ |
| 73 | void setLsCapability(boolean lscapability); |
| 74 | |
| 75 | /** |
| 76 | * Get the status of the 32 bit AS support for this BGP speaker. |
| 77 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 78 | * @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] | 79 | */ |
| 80 | boolean getLargeASCapability(); |
| 81 | |
| 82 | /** |
| 83 | * Set the 32 bit AS support capability to this BGP speaker. |
| 84 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 85 | * @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] | 86 | */ |
| 87 | void setLargeASCapability(boolean largeAs); |
| 88 | |
| 89 | /** |
| 90 | * Set the AS number to which this BGP speaker belongs. |
| 91 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 92 | * @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] | 93 | */ |
| 94 | void setAsNumber(int localAs); |
| 95 | |
| 96 | /** |
| 97 | * Get the AS number to which this BGP speaker belongs. |
| 98 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 99 | * @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] | 100 | */ |
| 101 | int getAsNumber(); |
| 102 | |
| 103 | /** |
| 104 | * Get the connection retry count number. |
| 105 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 106 | * @return connection retry count if there is a connection error |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 107 | */ |
| 108 | int getMaxConnRetryCount(); |
| 109 | |
| 110 | /** |
| 111 | * Set the connection retry count. |
| 112 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 113 | * @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] | 114 | */ |
| 115 | void setMaxConnRetryCout(int retryCount); |
| 116 | |
| 117 | /** |
| 118 | * Get the connection retry time in seconds. |
| 119 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 120 | * @return connection retry time in seconds |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 121 | */ |
| 122 | int getMaxConnRetryTime(); |
| 123 | |
| 124 | /** |
| 125 | * Set the connection retry time in seconds. |
| 126 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 127 | * @param retryTime connection retry times in seconds |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 128 | */ |
| 129 | void setMaxConnRetryTime(int retryTime); |
| 130 | |
| 131 | /** |
| 132 | * Set the keep alive timer for the connection. |
| 133 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 134 | * @param holdTime connection hold timer in seconds |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 135 | */ |
| 136 | void setHoldTime(short holdTime); |
| 137 | |
| 138 | /** |
| 139 | * Returns the connection hold timer in seconds. |
| 140 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 141 | * @return connection hold timer in seconds |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 142 | */ |
| 143 | short getHoldTime(); |
| 144 | |
| 145 | /** |
| 146 | * Returns the maximum number of session supported. |
| 147 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 148 | * @return maximum number of session supported |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 149 | */ |
| 150 | int getMaxSession(); |
| 151 | |
| 152 | /** |
| 153 | * Set the maximum number of sessions to support. |
| 154 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 155 | * @param maxsession maximum number of session |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 156 | */ |
| 157 | void setMaxSession(int maxsession); |
| 158 | |
| 159 | /** |
| 160 | * Returns the Router ID of this BGP speaker. |
| 161 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 162 | * @return IP address in string format |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 163 | */ |
| 164 | String getRouterId(); |
| 165 | |
| 166 | /** |
| 167 | * Set the Router ID of this BGP speaker. |
| 168 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 169 | * @param routerid IP address in string format |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 170 | */ |
| 171 | void setRouterId(String routerid); |
| 172 | |
| 173 | /** |
| 174 | * Add the BGP peer IP address and the AS number to which it belongs. |
| 175 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 176 | * @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 K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 180 | */ |
| 181 | boolean addPeer(String routerid, int remoteAs); |
| 182 | |
| 183 | /** |
| 184 | * Add the BGP peer IP address and the keep alive time. |
| 185 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 186 | * @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 K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 190 | */ |
| 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 K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 196 | * @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 K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 201 | */ |
| 202 | boolean addPeer(String routerid, int remoteAs, short holdTime); |
| 203 | |
| 204 | /** |
| 205 | * Remove the BGP peer with this IP address. |
| 206 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 207 | * @param routerid router IP address |
| 208 | * |
| 209 | * @return true if removed successfully else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 210 | */ |
| 211 | boolean removePeer(String routerid); |
| 212 | |
| 213 | /** |
| 214 | * Connect to BGP peer with this IP address. |
| 215 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 216 | * @param routerid router IP address |
| 217 | * |
| 218 | * @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] | 219 | */ |
| 220 | boolean connectPeer(String routerid); |
| 221 | |
| 222 | /** |
| 223 | * Disconnect this BGP peer with this IP address. |
| 224 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 225 | * @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 K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 228 | */ |
| 229 | boolean disconnectPeer(String routerid); |
| 230 | |
| 231 | /** |
| 232 | * Returns the peer tree information. |
| 233 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 234 | * @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] | 235 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 236 | TreeMap<String, BgpPeerCfg> displayPeers(); |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 237 | |
| 238 | /** |
| 239 | * Return the BGP Peer information with this matching IP. |
| 240 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 241 | * @param routerid router IP address in string format |
| 242 | * |
| 243 | * @return BGPPeerCfg object |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 244 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 245 | BgpPeerCfg displayPeers(String routerid); |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 246 | |
| 247 | /** |
| 248 | * Check if this BGP peer is configured. |
| 249 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 250 | * @param routerid router IP address in string format |
| 251 | * |
| 252 | * @return true if configured exists else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 253 | */ |
| 254 | boolean isPeerConfigured(String routerid); |
| 255 | |
| 256 | /** |
| 257 | * Check if this BGP speaker is having connection with the peer. |
| 258 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 259 | * @param routerid router IP address in string format |
| 260 | * |
| 261 | * @return true if the connection exists else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 262 | */ |
| 263 | boolean isPeerConnected(String routerid); |
| 264 | |
| 265 | /** |
| 266 | * Return the peer tree map. |
| 267 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 268 | * @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] | 269 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 270 | TreeMap<String, BgpPeerCfg> getPeerTree(); |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 271 | |
| 272 | /** |
| 273 | * Set the current connection state information. |
| 274 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 275 | * @param routerid router IP address in string format |
| 276 | * @param state state information |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 277 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 278 | void setPeerConnState(String routerid, BgpPeerCfg.State state); |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 279 | |
| 280 | /** |
| 281 | * Check if the peer can be connected or not. |
| 282 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 283 | * @param routerid router IP address in string format |
| 284 | * |
| 285 | * @return true if the peer can be connected else false |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 286 | */ |
| 287 | boolean isPeerConnectable(String routerid); |
| 288 | |
| 289 | /** |
| 290 | * Get the current peer connection state information. |
| 291 | * |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 292 | * @param routerid router IP address in string format |
| 293 | * |
| 294 | * @return state information |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 295 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 296 | BgpPeerCfg.State getPeerConnState(String routerid); |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 297 | } |