Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +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 | 3887962 | 2015-12-08 22:14:47 +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.provider.bgp.cfg.impl; |
| 17 | |
| 18 | import com.fasterxml.jackson.databind.JsonNode; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 19 | import org.osgi.service.component.annotations.Reference; |
| 20 | import org.osgi.service.component.annotations.ReferenceCardinality; |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 21 | import org.onlab.osgi.DefaultServiceDirectory; |
| 22 | import org.onlab.packet.IpAddress; |
| 23 | import org.onosproject.bgp.controller.BgpCfg; |
| 24 | import org.onosproject.bgp.controller.BgpController; |
| 25 | import org.onosproject.core.ApplicationId; |
| 26 | import org.onosproject.net.config.Config; |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 27 | import org.slf4j.Logger; |
| 28 | import org.slf4j.LoggerFactory; |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 29 | |
| 30 | import java.util.ArrayList; |
| 31 | import java.util.List; |
| 32 | |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 33 | import static com.google.common.base.Preconditions.checkNotNull; |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 34 | import static org.onosproject.net.config.Config.FieldPresence.MANDATORY; |
| 35 | import static org.onosproject.net.config.Config.FieldPresence.OPTIONAL; |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * Configuration object for BGP. |
| 39 | */ |
| 40 | public class BgpAppConfig extends Config<ApplicationId> { |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 41 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 42 | BgpController bgpController; |
| 43 | |
| 44 | BgpCfg bgpConfig = null; |
| 45 | |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 46 | protected final Logger log = LoggerFactory.getLogger(BgpAppConfig.class); |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 47 | public static final String ROUTER_ID = "routerId"; |
| 48 | public static final String LOCAL_AS = "localAs"; |
| 49 | public static final String MAX_SESSION = "maxSession"; |
| 50 | public static final String LS_CAPABILITY = "lsCapability"; |
| 51 | public static final String HOLD_TIME = "holdTime"; |
| 52 | public static final String LARGE_AS_CAPABILITY = "largeAsCapability"; |
Shashikanth VH | 580bdeb | 2016-02-19 17:26:03 +0530 | [diff] [blame] | 53 | public static final String FLOW_SPEC_CAPABILITY = "flowSpecCapability"; |
Shashikanth VH | b650bfa | 2016-04-18 12:54:03 +0530 | [diff] [blame] | 54 | public static final String FLOW_SPEC_RPD_CAPABILITY = "flowSpecRpdCapability"; |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 55 | public static final String EVPN_CAPABILITY = "evpnCapability"; |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 56 | |
| 57 | public static final String BGP_PEER = "bgpPeer"; |
| 58 | public static final String PEER_IP = "peerIp"; |
| 59 | public static final String REMOTE_AS = "remoteAs"; |
| 60 | public static final String PEER_HOLD_TIME = "peerHoldTime"; |
Thejaswi N K | 0008f1d | 2015-12-11 12:47:41 +0530 | [diff] [blame] | 61 | public static final String PEER_CONNECT_MODE = "connectMode"; |
| 62 | public static final String PEER_CONNECT_PASSIVE = "passive"; |
| 63 | public static final String PEER_CONNECT_ACTIVE = "active"; |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 64 | |
Ankur Aggarwal | f363d1a | 2019-11-11 14:56:18 +0530 | [diff] [blame] | 65 | public static final String CONNECTION_TYPE = "connectionType"; |
| 66 | public static final String CONNECTION_TYPE_IPV4 = "IPV4"; |
| 67 | public static final String CONNECTION_TYPE_IPV6 = "IPV6"; |
| 68 | public static final String CONNECTION_TYPE_IPV4_AND_IPV6 = "IPV4_IPV6"; |
| 69 | |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 70 | static final int MAX_SHORT_AS_NUMBER = 65535; |
| 71 | static final long MAX_LONG_AS_NUMBER = 4294967295L; |
| 72 | |
Shashikanth VH | de66383 | 2016-04-25 18:42:04 +0530 | [diff] [blame] | 73 | static final int MIN_SESSION_NUMBER = 1; |
| 74 | static final long MAX_SESSION_NUMBER = 21; |
| 75 | |
| 76 | static final int MIN_HOLDTIME = 0; |
| 77 | static final long MAX_HOLDTIME = 65535; |
| 78 | |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 79 | @Override |
| 80 | public boolean isValid() { |
| 81 | boolean fields = false; |
| 82 | |
| 83 | this.bgpController = DefaultServiceDirectory.getService(BgpController.class); |
| 84 | bgpConfig = bgpController.getConfig(); |
| 85 | |
| 86 | fields = hasOnlyFields(ROUTER_ID, LOCAL_AS, MAX_SESSION, LS_CAPABILITY, |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 87 | HOLD_TIME, LARGE_AS_CAPABILITY, FLOW_SPEC_CAPABILITY, |
Ankur Aggarwal | f363d1a | 2019-11-11 14:56:18 +0530 | [diff] [blame] | 88 | FLOW_SPEC_RPD_CAPABILITY, BGP_PEER, EVPN_CAPABILITY, CONNECTION_TYPE) && |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 89 | isIpAddress(ROUTER_ID, MANDATORY) && isNumber(LOCAL_AS, MANDATORY) && |
Shashikanth VH | de66383 | 2016-04-25 18:42:04 +0530 | [diff] [blame] | 90 | isNumber(MAX_SESSION, OPTIONAL, MIN_SESSION_NUMBER, MAX_SESSION_NUMBER) |
| 91 | && isNumber(HOLD_TIME, OPTIONAL, MIN_HOLDTIME, MAX_HOLDTIME) && |
Shashikanth VH | 580bdeb | 2016-02-19 17:26:03 +0530 | [diff] [blame] | 92 | isBoolean(LS_CAPABILITY, OPTIONAL) && isBoolean(LARGE_AS_CAPABILITY, OPTIONAL) && |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 93 | isString(FLOW_SPEC_CAPABILITY, OPTIONAL) && isBoolean(FLOW_SPEC_RPD_CAPABILITY, OPTIONAL) |
Ankur Aggarwal | f363d1a | 2019-11-11 14:56:18 +0530 | [diff] [blame] | 94 | && isBoolean(EVPN_CAPABILITY, OPTIONAL) && isString(CONNECTION_TYPE, OPTIONAL); |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 95 | |
| 96 | if (!fields) { |
| 97 | return fields; |
| 98 | } |
| 99 | |
| 100 | return validateBgpConfiguration(); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Returns routerId from the configuration. |
| 105 | * |
| 106 | * @return routerId |
| 107 | */ |
| 108 | public String routerId() { |
| 109 | return get(ROUTER_ID, null); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Returns localAs number from the configuration. |
| 114 | * |
| 115 | * @return local As number |
| 116 | */ |
| 117 | public int localAs() { |
| 118 | return Integer.parseInt(get(LOCAL_AS, null)); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Returns max session from the configuration. |
| 123 | * |
| 124 | * @return max session |
| 125 | */ |
| 126 | public int maxSession() { |
| 127 | return Integer.parseInt(get(MAX_SESSION, null)); |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Returns BGP-LS capability support from the configuration. |
| 132 | * |
| 133 | * @return true if BGP-LS capability is set else false |
| 134 | */ |
| 135 | public boolean lsCapability() { |
| 136 | return Boolean.parseBoolean(get(LS_CAPABILITY, null)); |
| 137 | } |
| 138 | |
| 139 | /** |
Shashikanth VH | b650bfa | 2016-04-18 12:54:03 +0530 | [diff] [blame] | 140 | * Returns flow spec route policy distribution capability support from the configuration. |
| 141 | * |
| 142 | * @return true if flow spec route policy distribution capability is set otherwise false |
| 143 | */ |
| 144 | public boolean rpdCapability() { |
| 145 | return Boolean.parseBoolean(get(FLOW_SPEC_RPD_CAPABILITY, null)); |
| 146 | } |
| 147 | |
| 148 | /** |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 149 | * Returns largeAs capability support from the configuration. |
| 150 | * |
| 151 | * @return largeAs capability |
| 152 | */ |
| 153 | public boolean largeAsCapability() { |
| 154 | return Boolean.parseBoolean(get(LARGE_AS_CAPABILITY, null)); |
| 155 | } |
| 156 | |
| 157 | /** |
Shashikanth VH | 580bdeb | 2016-02-19 17:26:03 +0530 | [diff] [blame] | 158 | * Returns flow specification capability support from the configuration. |
| 159 | * |
| 160 | * @return flow specification capability |
| 161 | */ |
| 162 | public String flowSpecCapability() { |
| 163 | return get(FLOW_SPEC_CAPABILITY, null); |
| 164 | } |
| 165 | |
| 166 | /** |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 167 | * Returns holdTime of the local node from the configuration. |
| 168 | * |
| 169 | * @return holdTime |
| 170 | */ |
| 171 | public short holdTime() { |
| 172 | return Short.parseShort(get(HOLD_TIME, null)); |
| 173 | } |
| 174 | |
| 175 | /** |
Ankur Aggarwal | f363d1a | 2019-11-11 14:56:18 +0530 | [diff] [blame] | 176 | * Returns BGP connection type from the configuration. |
| 177 | * |
| 178 | * @return BGP connection type |
| 179 | */ |
| 180 | public String connectionType() { |
| 181 | return get(CONNECTION_TYPE, null); |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Validates the BGP connection type. |
| 186 | * |
| 187 | * @return true if valid else false |
| 188 | */ |
| 189 | public boolean validateConnectionType() { |
| 190 | if (connectionType() != null) { |
| 191 | String connectionType = connectionType(); |
| 192 | if (!connectionType.equals(CONNECTION_TYPE_IPV4) && !connectionType.equals(CONNECTION_TYPE_IPV6) |
| 193 | && !connectionType.equals(CONNECTION_TYPE_IPV4_AND_IPV6)) { |
| 194 | log.error("Connection Type is invalid"); |
| 195 | return false; |
| 196 | } |
| 197 | } |
| 198 | log.debug("Connection Type is valid"); |
| 199 | return true; |
| 200 | } |
| 201 | |
| 202 | /** |
Shashikanth VH | 580bdeb | 2016-02-19 17:26:03 +0530 | [diff] [blame] | 203 | * Validates the flow specification capability. |
| 204 | * |
| 205 | * @return true if valid else false |
| 206 | */ |
| 207 | public boolean validateFlowSpec() { |
| 208 | if (flowSpecCapability() != null) { |
| 209 | String flowSpec = flowSpecCapability(); |
Shashikanth VH | 09792f0 | 2016-05-10 16:59:57 +0530 | [diff] [blame] | 210 | if ((!flowSpec.equals("IPV4")) && (!flowSpec.equals("VPNV4")) && (!flowSpec.equals("IPV4_VPNV4"))) { |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 211 | log.debug("Flow specification capabality is false"); |
Shashikanth VH | 09792f0 | 2016-05-10 16:59:57 +0530 | [diff] [blame] | 212 | return false; |
Shashikanth VH | 580bdeb | 2016-02-19 17:26:03 +0530 | [diff] [blame] | 213 | } |
| 214 | } |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 215 | log.debug("Flow specification capabality is true"); |
Shashikanth VH | 09792f0 | 2016-05-10 16:59:57 +0530 | [diff] [blame] | 216 | return true; |
Shashikanth VH | 580bdeb | 2016-02-19 17:26:03 +0530 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | /** |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 220 | * Returns evpn capability support from the configuration. |
| 221 | * |
| 222 | * @return evpn capability |
| 223 | */ |
| 224 | public boolean evpnCapability() { |
| 225 | return Boolean.parseBoolean(get(EVPN_CAPABILITY, null)); |
| 226 | } |
| 227 | |
| 228 | /** |
Shashikanth VH | de66383 | 2016-04-25 18:42:04 +0530 | [diff] [blame] | 229 | * Validates the hold time value. |
| 230 | * |
| 231 | * @return true if valid else false |
| 232 | */ |
| 233 | public boolean validateHoldTime() { |
| 234 | if (holdTime() != 0) { |
| 235 | short holdTime = holdTime(); |
| 236 | if ((holdTime == 1) || (holdTime == 2)) { |
| 237 | return false; |
| 238 | } |
| 239 | } |
| 240 | return true; |
| 241 | } |
| 242 | |
| 243 | /** |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 244 | * Validates the Bgp local and peer configuration. |
| 245 | * |
| 246 | * @return true if valid else false |
| 247 | */ |
| 248 | public boolean validateBgpConfiguration() { |
| 249 | |
| 250 | if (!validateLocalAs()) { |
| 251 | return false; |
| 252 | } |
| 253 | |
| 254 | if (!validateRouterId()) { |
| 255 | return false; |
| 256 | } |
| 257 | |
| 258 | if (!validateBgpPeers()) { |
| 259 | return false; |
| 260 | } |
| 261 | |
Shashikanth VH | 580bdeb | 2016-02-19 17:26:03 +0530 | [diff] [blame] | 262 | if (!validateFlowSpec()) { |
| 263 | return false; |
| 264 | } |
Shashikanth VH | de66383 | 2016-04-25 18:42:04 +0530 | [diff] [blame] | 265 | |
| 266 | if (!validateHoldTime()) { |
| 267 | return false; |
| 268 | } |
Ankur Aggarwal | f363d1a | 2019-11-11 14:56:18 +0530 | [diff] [blame] | 269 | |
| 270 | if (!validateConnectionType()) { |
| 271 | return false; |
| 272 | } |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 273 | return true; |
| 274 | } |
| 275 | |
| 276 | /** |
| 277 | * Validates the Bgp As number. |
| 278 | * |
| 279 | * @return true if valid else false |
| 280 | */ |
| 281 | public boolean validateLocalAs() { |
| 282 | |
| 283 | long localAs = 0; |
| 284 | localAs = localAs(); |
| 285 | |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 286 | if (largeAsCapability()) { |
| 287 | |
| 288 | if (localAs == 0 || localAs >= MAX_LONG_AS_NUMBER) { |
| 289 | return false; |
| 290 | } |
| 291 | } else { |
| 292 | if (localAs == 0 || localAs >= MAX_SHORT_AS_NUMBER) { |
| 293 | return false; |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | return true; |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Validates the Bgp peer As number. |
| 302 | * |
Jian Li | dfba739 | 2016-01-22 16:46:58 -0800 | [diff] [blame] | 303 | * @param remoteAs remote As number |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 304 | * @return true if valid else false |
| 305 | */ |
| 306 | public boolean validateRemoteAs(long remoteAs) { |
| 307 | if (largeAsCapability()) { |
| 308 | |
| 309 | if (remoteAs == 0 || remoteAs >= MAX_LONG_AS_NUMBER) { |
| 310 | return false; |
| 311 | } |
| 312 | } else { |
| 313 | if (remoteAs == 0 || remoteAs >= MAX_SHORT_AS_NUMBER) { |
| 314 | return false; |
| 315 | } |
| 316 | } |
| 317 | return true; |
| 318 | } |
| 319 | |
| 320 | /** |
| 321 | * Validates the Bgp Router ID configuration. |
| 322 | * |
| 323 | * @return true if valid else false |
| 324 | */ |
| 325 | public boolean validateRouterId() { |
| 326 | String routerId = routerId(); |
Shashikanth VH | de66383 | 2016-04-25 18:42:04 +0530 | [diff] [blame] | 327 | // TODO: router ID validation |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 328 | return true; |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Validates the Bgp peer holdTime. |
| 333 | * |
Jian Li | dfba739 | 2016-01-22 16:46:58 -0800 | [diff] [blame] | 334 | * @param remoteAs remote As number |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 335 | * @return true if valid else false |
| 336 | */ |
| 337 | public boolean validatePeerHoldTime(long remoteAs) { |
| 338 | //TODO:Validate it later.. |
| 339 | return true; |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Validates the Bgp peer configuration. |
| 344 | * |
| 345 | * @return true if valid else false |
| 346 | */ |
| 347 | public boolean validateBgpPeers() { |
| 348 | List<BgpPeerConfig> nodes; |
Thejaswi N K | 0008f1d | 2015-12-11 12:47:41 +0530 | [diff] [blame] | 349 | String connectMode; |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 350 | |
| 351 | nodes = bgpPeer(); |
| 352 | for (int i = 0; i < nodes.size(); i++) { |
Thejaswi N K | 0008f1d | 2015-12-11 12:47:41 +0530 | [diff] [blame] | 353 | connectMode = nodes.get(i).connectMode(); |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 354 | if ((IpAddress.valueOf(nodes.get(i).hostname()) == null) || |
| 355 | !validateRemoteAs(nodes.get(i).asNumber()) || |
Thejaswi N K | 0008f1d | 2015-12-11 12:47:41 +0530 | [diff] [blame] | 356 | !validatePeerHoldTime(nodes.get(i).holdTime()) || |
| 357 | !(connectMode.equals(PEER_CONNECT_ACTIVE) || connectMode.equals(PEER_CONNECT_PASSIVE))) { |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 358 | log.debug("BGP peer configration false"); |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 359 | return false; |
| 360 | } |
| 361 | } |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 362 | log.debug("BGP peer configration true"); |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 363 | return true; |
| 364 | } |
| 365 | |
| 366 | /** |
| 367 | * Returns the set of nodes read from network config. |
| 368 | * |
| 369 | * @return list of BgpPeerConfig or null |
| 370 | */ |
| 371 | public List<BgpPeerConfig> bgpPeer() { |
| 372 | List<BgpPeerConfig> nodes = new ArrayList<BgpPeerConfig>(); |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 373 | JsonNode jsonNodes = object.get(BGP_PEER); |
| 374 | if (jsonNodes == null) { |
| 375 | return null; |
| 376 | } |
| 377 | |
| 378 | jsonNodes.forEach(jsonNode -> nodes.add(new BgpPeerConfig( |
| 379 | jsonNode.path(PEER_IP).asText(), |
| 380 | jsonNode.path(REMOTE_AS).asInt(), |
Thejaswi N K | 0008f1d | 2015-12-11 12:47:41 +0530 | [diff] [blame] | 381 | jsonNode.path(PEER_HOLD_TIME).asInt(), |
| 382 | jsonNode.path(PEER_CONNECT_MODE).asText()))); |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 383 | |
| 384 | return nodes; |
| 385 | } |
| 386 | |
| 387 | /** |
| 388 | * Configuration for Bgp peer nodes. |
| 389 | */ |
| 390 | public static class BgpPeerConfig { |
| 391 | |
| 392 | private final String hostname; |
| 393 | private final int asNumber; |
| 394 | private final short holdTime; |
Thejaswi N K | 0008f1d | 2015-12-11 12:47:41 +0530 | [diff] [blame] | 395 | private final String connectMode; |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 396 | |
Thejaswi N K | 0008f1d | 2015-12-11 12:47:41 +0530 | [diff] [blame] | 397 | public BgpPeerConfig(String hostname, int asNumber, int holdTime, String connectMode) { |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 398 | this.hostname = checkNotNull(hostname); |
| 399 | this.asNumber = asNumber; |
| 400 | this.holdTime = (short) holdTime; |
Thejaswi N K | 0008f1d | 2015-12-11 12:47:41 +0530 | [diff] [blame] | 401 | this.connectMode = connectMode; |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Returns hostname of the peer node. |
| 406 | * |
| 407 | * @return hostname |
| 408 | */ |
| 409 | public String hostname() { |
| 410 | return this.hostname; |
| 411 | } |
| 412 | |
| 413 | /** |
| 414 | * Returns asNumber if peer. |
| 415 | * |
| 416 | * @return asNumber |
| 417 | */ |
| 418 | public int asNumber() { |
| 419 | return this.asNumber; |
| 420 | } |
| 421 | |
| 422 | /** |
| 423 | * Returns holdTime of the peer node. |
| 424 | * |
| 425 | * @return holdTime |
| 426 | */ |
| 427 | public short holdTime() { |
| 428 | return this.holdTime; |
| 429 | } |
Thejaswi N K | 0008f1d | 2015-12-11 12:47:41 +0530 | [diff] [blame] | 430 | |
| 431 | /** |
| 432 | * Returns connection mode for the peer node. |
| 433 | * |
| 434 | * @return active or passive connection |
| 435 | */ |
| 436 | public String connectMode() { |
| 437 | return this.connectMode; |
| 438 | } |
Thejaswi N K | 3887962 | 2015-12-08 22:14:47 +0530 | [diff] [blame] | 439 | } |
| 440 | } |