David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_circuit.h |
| 3 | * |
| 4 | * Copyright (C) 2001,2002 Sampo Saaristo |
| 5 | * Tampere University of Technology |
| 6 | * Institute of Communications Engineering |
| 7 | * Copyright (C) 2016 David Lamparter, for NetDEF, Inc. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public Licenseas published by the Free |
| 11 | * Software Foundation; either version 2 of the License, or (at your option) |
| 12 | * any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful,but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 17 | * more details. |
| 18 | |
| 19 | * You should have received a copy of the GNU General Public License along |
| 20 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 22 | */ |
| 23 | |
| 24 | #include <zebra.h> |
| 25 | #include <command.h> |
| 26 | |
| 27 | #include "isis_circuit.h" |
| 28 | #include "isis_csm.h" |
| 29 | #include "isis_misc.h" |
| 30 | #include "isisd.h" |
| 31 | |
| 32 | static struct isis_circuit * |
| 33 | isis_circuit_lookup (struct vty *vty) |
| 34 | { |
| 35 | struct interface *ifp; |
| 36 | struct isis_circuit *circuit; |
| 37 | |
| 38 | ifp = (struct interface *) vty->index; |
| 39 | if (!ifp) |
| 40 | { |
| 41 | vty_out (vty, "Invalid interface %s", VTY_NEWLINE); |
| 42 | return NULL; |
| 43 | } |
| 44 | |
| 45 | circuit = circuit_scan_by_ifp (ifp); |
| 46 | if (!circuit) |
| 47 | { |
| 48 | vty_out (vty, "ISIS is not enabled on circuit %s%s", |
| 49 | ifp->name, VTY_NEWLINE); |
| 50 | return NULL; |
| 51 | } |
| 52 | |
| 53 | return circuit; |
| 54 | } |
| 55 | |
| 56 | DEFUN (ip_router_isis, |
| 57 | ip_router_isis_cmd, |
| 58 | "(ip|ipv6) router isis WORD", |
| 59 | "Interface Internet Protocol config commands\n" |
| 60 | "IP router interface commands\n" |
| 61 | "IS-IS Routing for IP\n" |
| 62 | "Routing process tag\n") |
| 63 | { |
| 64 | struct interface *ifp; |
| 65 | struct isis_circuit *circuit; |
| 66 | struct isis_area *area; |
| 67 | const char *af = argv[0]; |
| 68 | const char *area_tag = argv[1]; |
| 69 | |
| 70 | ifp = (struct interface *) vty->index; |
| 71 | assert (ifp); |
| 72 | |
| 73 | /* Prevent more than one area per circuit */ |
| 74 | circuit = circuit_scan_by_ifp (ifp); |
David Lamparter | 515812d | 2016-08-11 16:59:08 +0200 | [diff] [blame] | 75 | if (circuit && circuit->area) |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 76 | { |
David Lamparter | 515812d | 2016-08-11 16:59:08 +0200 | [diff] [blame] | 77 | if (strcmp (circuit->area->area_tag, area_tag)) |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 78 | { |
David Lamparter | 515812d | 2016-08-11 16:59:08 +0200 | [diff] [blame] | 79 | vty_out (vty, "ISIS circuit is already defined on %s%s", |
| 80 | circuit->area->area_tag, VTY_NEWLINE); |
| 81 | return CMD_ERR_NOTHING_TODO; |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 82 | } |
| 83 | } |
| 84 | |
| 85 | area = isis_area_lookup (area_tag); |
| 86 | if (!area) |
| 87 | area = isis_area_create (area_tag); |
| 88 | |
Christian Franke | af177b2 | 2016-08-15 13:36:59 +0200 | [diff] [blame^] | 89 | if (!circuit || !circuit->area) { |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 90 | circuit = isis_circuit_create (area, ifp); |
| 91 | |
Christian Franke | af177b2 | 2016-08-15 13:36:59 +0200 | [diff] [blame^] | 92 | if (circuit->state != C_STATE_CONF && circuit->state != C_STATE_UP) |
| 93 | { |
| 94 | vty_out(vty, "Couldn't bring up interface, please check log.%s", VTY_NEWLINE); |
| 95 | return CMD_WARNING; |
| 96 | } |
| 97 | } |
| 98 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 99 | bool ip = circuit->ip_router, ipv6 = circuit->ipv6_router; |
| 100 | if (af[2] != '\0') |
| 101 | ipv6 = true; |
| 102 | else |
| 103 | ip = true; |
| 104 | |
| 105 | isis_circuit_af_set (circuit, ip, ipv6); |
| 106 | return CMD_SUCCESS; |
| 107 | } |
| 108 | |
| 109 | DEFUN (no_ip_router_isis, |
| 110 | no_ip_router_isis_cmd, |
| 111 | "no (ip|ipv6) router isis WORD", |
| 112 | NO_STR |
| 113 | "Interface Internet Protocol config commands\n" |
| 114 | "IP router interface commands\n" |
| 115 | "IS-IS Routing for IP\n" |
| 116 | "Routing process tag\n") |
| 117 | { |
| 118 | struct interface *ifp; |
| 119 | struct isis_area *area; |
| 120 | struct isis_circuit *circuit; |
| 121 | const char *af = argv[0]; |
| 122 | const char *area_tag = argv[1]; |
| 123 | |
| 124 | ifp = (struct interface *) vty->index; |
| 125 | if (!ifp) |
| 126 | { |
| 127 | vty_out (vty, "Invalid interface %s", VTY_NEWLINE); |
| 128 | return CMD_ERR_NO_MATCH; |
| 129 | } |
| 130 | |
| 131 | area = isis_area_lookup (area_tag); |
| 132 | if (!area) |
| 133 | { |
| 134 | vty_out (vty, "Can't find ISIS instance %s%s", |
| 135 | argv[0], VTY_NEWLINE); |
| 136 | return CMD_ERR_NO_MATCH; |
| 137 | } |
| 138 | |
| 139 | circuit = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 140 | if (!circuit) |
| 141 | { |
| 142 | vty_out (vty, "ISIS is not enabled on circuit %s%s", |
| 143 | ifp->name, VTY_NEWLINE); |
| 144 | return CMD_ERR_NO_MATCH; |
| 145 | } |
| 146 | |
| 147 | bool ip = circuit->ip_router, ipv6 = circuit->ipv6_router; |
| 148 | if (af[2] != '\0') |
| 149 | ipv6 = false; |
| 150 | else |
| 151 | ip = false; |
| 152 | |
| 153 | isis_circuit_af_set (circuit, ip, ipv6); |
| 154 | return CMD_SUCCESS; |
| 155 | } |
| 156 | |
| 157 | DEFUN (isis_passive, |
| 158 | isis_passive_cmd, |
| 159 | "isis passive", |
| 160 | "IS-IS commands\n" |
| 161 | "Configure the passive mode for interface\n") |
| 162 | { |
| 163 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 164 | if (!circuit) |
| 165 | return CMD_ERR_NO_MATCH; |
| 166 | |
| 167 | isis_circuit_passive_set (circuit, 1); |
| 168 | return CMD_SUCCESS; |
| 169 | } |
| 170 | |
| 171 | DEFUN (no_isis_passive, |
| 172 | no_isis_passive_cmd, |
| 173 | "no isis passive", |
| 174 | NO_STR |
| 175 | "IS-IS commands\n" |
| 176 | "Configure the passive mode for interface\n") |
| 177 | { |
| 178 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 179 | if (!circuit) |
| 180 | return CMD_ERR_NO_MATCH; |
| 181 | |
| 182 | if (if_is_loopback (circuit->interface)) |
| 183 | { |
| 184 | vty_out (vty, "Can't set no passive for loopback interface%s", |
| 185 | VTY_NEWLINE); |
| 186 | return CMD_ERR_AMBIGUOUS; |
| 187 | } |
| 188 | |
| 189 | isis_circuit_passive_set (circuit, 0); |
| 190 | return CMD_SUCCESS; |
| 191 | } |
| 192 | |
| 193 | DEFUN (isis_circuit_type, |
| 194 | isis_circuit_type_cmd, |
| 195 | "isis circuit-type (level-1|level-1-2|level-2-only)", |
| 196 | "IS-IS commands\n" |
| 197 | "Configure circuit type for interface\n" |
| 198 | "Level-1 only adjacencies are formed\n" |
| 199 | "Level-1-2 adjacencies are formed\n" |
| 200 | "Level-2 only adjacencies are formed\n") |
| 201 | { |
| 202 | int is_type; |
| 203 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 204 | if (!circuit) |
| 205 | return CMD_ERR_NO_MATCH; |
| 206 | |
| 207 | is_type = string2circuit_t (argv[0]); |
| 208 | if (!is_type) |
| 209 | { |
| 210 | vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE); |
| 211 | return CMD_ERR_AMBIGUOUS; |
| 212 | } |
| 213 | |
| 214 | if (circuit->state == C_STATE_UP && |
| 215 | circuit->area->is_type != IS_LEVEL_1_AND_2 && |
| 216 | circuit->area->is_type != is_type) |
| 217 | { |
| 218 | vty_out (vty, "Invalid circuit level for area %s.%s", |
| 219 | circuit->area->area_tag, VTY_NEWLINE); |
| 220 | return CMD_ERR_AMBIGUOUS; |
| 221 | } |
| 222 | isis_circuit_is_type_set (circuit, is_type); |
| 223 | |
| 224 | return CMD_SUCCESS; |
| 225 | } |
| 226 | |
| 227 | DEFUN (no_isis_circuit_type, |
| 228 | no_isis_circuit_type_cmd, |
| 229 | "no isis circuit-type (level-1|level-1-2|level-2-only)", |
| 230 | NO_STR |
| 231 | "IS-IS commands\n" |
| 232 | "Configure circuit type for interface\n" |
| 233 | "Level-1 only adjacencies are formed\n" |
| 234 | "Level-1-2 adjacencies are formed\n" |
| 235 | "Level-2 only adjacencies are formed\n") |
| 236 | { |
| 237 | int is_type; |
| 238 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 239 | if (!circuit) |
| 240 | return CMD_ERR_NO_MATCH; |
| 241 | |
| 242 | /* |
| 243 | * Set the circuits level to its default value |
| 244 | */ |
| 245 | if (circuit->state == C_STATE_UP) |
| 246 | is_type = circuit->area->is_type; |
| 247 | else |
| 248 | is_type = IS_LEVEL_1_AND_2; |
| 249 | isis_circuit_is_type_set (circuit, is_type); |
| 250 | |
| 251 | return CMD_SUCCESS; |
| 252 | } |
| 253 | |
| 254 | DEFUN (isis_network, |
| 255 | isis_network_cmd, |
| 256 | "isis network point-to-point", |
| 257 | "IS-IS commands\n" |
| 258 | "Set network type\n" |
| 259 | "point-to-point network type\n") |
| 260 | { |
| 261 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 262 | if (!circuit) |
| 263 | return CMD_ERR_NO_MATCH; |
| 264 | |
Christian Franke | a798abb | 2016-08-11 16:08:05 +0200 | [diff] [blame] | 265 | if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_P2P)) |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 266 | { |
| 267 | vty_out (vty, "isis network point-to-point " |
| 268 | "is valid only on broadcast interfaces%s", |
| 269 | VTY_NEWLINE); |
| 270 | return CMD_ERR_AMBIGUOUS; |
| 271 | } |
| 272 | |
| 273 | return CMD_SUCCESS; |
| 274 | } |
| 275 | |
| 276 | DEFUN (no_isis_network, |
| 277 | no_isis_network_cmd, |
| 278 | "no isis network point-to-point", |
| 279 | NO_STR |
| 280 | "IS-IS commands\n" |
| 281 | "Set network type for circuit\n" |
| 282 | "point-to-point network type\n") |
| 283 | { |
| 284 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 285 | if (!circuit) |
| 286 | return CMD_ERR_NO_MATCH; |
| 287 | |
Christian Franke | a798abb | 2016-08-11 16:08:05 +0200 | [diff] [blame] | 288 | if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_BROADCAST)) |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 289 | { |
| 290 | vty_out (vty, "isis network point-to-point " |
| 291 | "is valid only on broadcast interfaces%s", |
| 292 | VTY_NEWLINE); |
| 293 | return CMD_ERR_AMBIGUOUS; |
| 294 | } |
| 295 | |
| 296 | return CMD_SUCCESS; |
| 297 | } |
| 298 | |
Christian Franke | f5fbfb2 | 2016-07-28 17:23:27 +0200 | [diff] [blame] | 299 | DEFUN (isis_passwd, |
| 300 | isis_passwd_cmd, |
| 301 | "isis password (md5|clear) WORD", |
| 302 | "IS-IS commands\n" |
| 303 | "Configure the authentication password for a circuit\n" |
| 304 | "HMAC-MD5 authentication\n" |
| 305 | "Cleartext password\n" |
| 306 | "Circuit password\n") |
| 307 | { |
| 308 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 309 | int rv; |
| 310 | if (!circuit) |
| 311 | return CMD_ERR_NO_MATCH; |
| 312 | |
| 313 | if (argv[0][0] == 'm') |
| 314 | rv = isis_circuit_passwd_hmac_md5_set(circuit, argv[1]); |
| 315 | else |
| 316 | rv = isis_circuit_passwd_cleartext_set(circuit, argv[1]); |
| 317 | if (rv) |
| 318 | { |
| 319 | vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE); |
| 320 | return CMD_ERR_AMBIGUOUS; |
| 321 | } |
| 322 | |
| 323 | return CMD_SUCCESS; |
| 324 | } |
| 325 | |
| 326 | DEFUN (no_isis_passwd, |
| 327 | no_isis_passwd_cmd, |
| 328 | "no isis password", |
| 329 | NO_STR |
| 330 | "IS-IS commands\n" |
| 331 | "Configure the authentication password for a circuit\n") |
| 332 | { |
| 333 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 334 | if (!circuit) |
| 335 | return CMD_ERR_NO_MATCH; |
| 336 | |
| 337 | isis_circuit_passwd_unset(circuit); |
| 338 | |
| 339 | return CMD_SUCCESS; |
| 340 | } |
| 341 | |
| 342 | ALIAS (no_isis_passwd, |
| 343 | no_isis_passwd_arg_cmd, |
| 344 | "no isis password (md5|clear) WORD", |
| 345 | NO_STR |
| 346 | "IS-IS commands\n" |
| 347 | "Configure the authentication password for a circuit\n" |
| 348 | "HMAC-MD5 authentication\n" |
| 349 | "Cleartext password\n" |
| 350 | "Circuit password\n") |
| 351 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 352 | DEFUN (isis_priority, |
| 353 | isis_priority_cmd, |
| 354 | "isis priority <0-127>", |
| 355 | "IS-IS commands\n" |
| 356 | "Set priority for Designated Router election\n" |
| 357 | "Priority value\n") |
| 358 | { |
| 359 | int prio; |
| 360 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 361 | if (!circuit) |
| 362 | return CMD_ERR_NO_MATCH; |
| 363 | |
| 364 | prio = atoi (argv[0]); |
| 365 | if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) |
| 366 | { |
| 367 | vty_out (vty, "Invalid priority %d - should be <0-127>%s", |
| 368 | prio, VTY_NEWLINE); |
| 369 | return CMD_ERR_AMBIGUOUS; |
| 370 | } |
| 371 | |
| 372 | circuit->priority[0] = prio; |
| 373 | circuit->priority[1] = prio; |
| 374 | |
| 375 | return CMD_SUCCESS; |
| 376 | } |
| 377 | |
| 378 | DEFUN (no_isis_priority, |
| 379 | no_isis_priority_cmd, |
| 380 | "no isis priority", |
| 381 | NO_STR |
| 382 | "IS-IS commands\n" |
| 383 | "Set priority for Designated Router election\n") |
| 384 | { |
| 385 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 386 | if (!circuit) |
| 387 | return CMD_ERR_NO_MATCH; |
| 388 | |
| 389 | circuit->priority[0] = DEFAULT_PRIORITY; |
| 390 | circuit->priority[1] = DEFAULT_PRIORITY; |
| 391 | |
| 392 | return CMD_SUCCESS; |
| 393 | } |
| 394 | |
| 395 | ALIAS (no_isis_priority, |
| 396 | no_isis_priority_arg_cmd, |
| 397 | "no isis priority <0-127>", |
| 398 | NO_STR |
| 399 | "IS-IS commands\n" |
| 400 | "Set priority for Designated Router election\n" |
| 401 | "Priority value\n") |
| 402 | |
| 403 | DEFUN (isis_priority_l1, |
| 404 | isis_priority_l1_cmd, |
| 405 | "isis priority <0-127> level-1", |
| 406 | "IS-IS commands\n" |
| 407 | "Set priority for Designated Router election\n" |
| 408 | "Priority value\n" |
| 409 | "Specify priority for level-1 routing\n") |
| 410 | { |
| 411 | int prio; |
| 412 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 413 | if (!circuit) |
| 414 | return CMD_ERR_NO_MATCH; |
| 415 | |
| 416 | prio = atoi (argv[0]); |
| 417 | if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) |
| 418 | { |
| 419 | vty_out (vty, "Invalid priority %d - should be <0-127>%s", |
| 420 | prio, VTY_NEWLINE); |
| 421 | return CMD_ERR_AMBIGUOUS; |
| 422 | } |
| 423 | |
| 424 | circuit->priority[0] = prio; |
| 425 | |
| 426 | return CMD_SUCCESS; |
| 427 | } |
| 428 | |
| 429 | DEFUN (no_isis_priority_l1, |
| 430 | no_isis_priority_l1_cmd, |
| 431 | "no isis priority level-1", |
| 432 | NO_STR |
| 433 | "IS-IS commands\n" |
| 434 | "Set priority for Designated Router election\n" |
| 435 | "Specify priority for level-1 routing\n") |
| 436 | { |
| 437 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 438 | if (!circuit) |
| 439 | return CMD_ERR_NO_MATCH; |
| 440 | |
| 441 | circuit->priority[0] = DEFAULT_PRIORITY; |
| 442 | |
| 443 | return CMD_SUCCESS; |
| 444 | } |
| 445 | |
| 446 | ALIAS (no_isis_priority_l1, |
| 447 | no_isis_priority_l1_arg_cmd, |
| 448 | "no isis priority <0-127> level-1", |
| 449 | NO_STR |
| 450 | "IS-IS commands\n" |
| 451 | "Set priority for Designated Router election\n" |
| 452 | "Priority value\n" |
| 453 | "Specify priority for level-1 routing\n") |
| 454 | |
| 455 | DEFUN (isis_priority_l2, |
| 456 | isis_priority_l2_cmd, |
| 457 | "isis priority <0-127> level-2", |
| 458 | "IS-IS commands\n" |
| 459 | "Set priority for Designated Router election\n" |
| 460 | "Priority value\n" |
| 461 | "Specify priority for level-2 routing\n") |
| 462 | { |
| 463 | int prio; |
| 464 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 465 | if (!circuit) |
| 466 | return CMD_ERR_NO_MATCH; |
| 467 | |
| 468 | prio = atoi (argv[0]); |
| 469 | if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) |
| 470 | { |
| 471 | vty_out (vty, "Invalid priority %d - should be <0-127>%s", |
| 472 | prio, VTY_NEWLINE); |
| 473 | return CMD_ERR_AMBIGUOUS; |
| 474 | } |
| 475 | |
| 476 | circuit->priority[1] = prio; |
| 477 | |
| 478 | return CMD_SUCCESS; |
| 479 | } |
| 480 | |
| 481 | DEFUN (no_isis_priority_l2, |
| 482 | no_isis_priority_l2_cmd, |
| 483 | "no isis priority level-2", |
| 484 | NO_STR |
| 485 | "IS-IS commands\n" |
| 486 | "Set priority for Designated Router election\n" |
| 487 | "Specify priority for level-2 routing\n") |
| 488 | { |
| 489 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 490 | if (!circuit) |
| 491 | return CMD_ERR_NO_MATCH; |
| 492 | |
| 493 | circuit->priority[1] = DEFAULT_PRIORITY; |
| 494 | |
| 495 | return CMD_SUCCESS; |
| 496 | } |
| 497 | |
| 498 | ALIAS (no_isis_priority_l2, |
| 499 | no_isis_priority_l2_arg_cmd, |
| 500 | "no isis priority <0-127> level-2", |
| 501 | NO_STR |
| 502 | "IS-IS commands\n" |
| 503 | "Set priority for Designated Router election\n" |
| 504 | "Priority value\n" |
| 505 | "Specify priority for level-2 routing\n") |
| 506 | |
| 507 | /* Metric command */ |
| 508 | DEFUN (isis_metric, |
| 509 | isis_metric_cmd, |
| 510 | "isis metric <0-16777215>", |
| 511 | "IS-IS commands\n" |
| 512 | "Set default metric for circuit\n" |
| 513 | "Default metric value\n") |
| 514 | { |
| 515 | int met; |
| 516 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 517 | if (!circuit) |
| 518 | return CMD_ERR_NO_MATCH; |
| 519 | |
| 520 | met = atoi (argv[0]); |
| 521 | |
| 522 | /* RFC3787 section 5.1 */ |
| 523 | if (circuit->area && circuit->area->oldmetric == 1 && |
| 524 | met > MAX_NARROW_LINK_METRIC) |
| 525 | { |
| 526 | vty_out (vty, "Invalid metric %d - should be <0-63> " |
| 527 | "when narrow metric type enabled%s", |
| 528 | met, VTY_NEWLINE); |
| 529 | return CMD_ERR_AMBIGUOUS; |
| 530 | } |
| 531 | |
| 532 | /* RFC4444 */ |
| 533 | if (circuit->area && circuit->area->newmetric == 1 && |
| 534 | met > MAX_WIDE_LINK_METRIC) |
| 535 | { |
| 536 | vty_out (vty, "Invalid metric %d - should be <0-16777215> " |
| 537 | "when wide metric type enabled%s", |
| 538 | met, VTY_NEWLINE); |
| 539 | return CMD_ERR_AMBIGUOUS; |
| 540 | } |
| 541 | |
| 542 | isis_circuit_metric_set (circuit, IS_LEVEL_1, met); |
| 543 | isis_circuit_metric_set (circuit, IS_LEVEL_2, met); |
| 544 | return CMD_SUCCESS; |
| 545 | } |
| 546 | |
| 547 | DEFUN (no_isis_metric, |
| 548 | no_isis_metric_cmd, |
| 549 | "no isis metric", |
| 550 | NO_STR |
| 551 | "IS-IS commands\n" |
| 552 | "Set default metric for circuit\n") |
| 553 | { |
| 554 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 555 | if (!circuit) |
| 556 | return CMD_ERR_NO_MATCH; |
| 557 | |
| 558 | isis_circuit_metric_set (circuit, IS_LEVEL_1, DEFAULT_CIRCUIT_METRIC); |
| 559 | isis_circuit_metric_set (circuit, IS_LEVEL_2, DEFAULT_CIRCUIT_METRIC); |
| 560 | return CMD_SUCCESS; |
| 561 | } |
| 562 | |
| 563 | ALIAS (no_isis_metric, |
| 564 | no_isis_metric_arg_cmd, |
| 565 | "no isis metric <0-16777215>", |
| 566 | NO_STR |
| 567 | "IS-IS commands\n" |
| 568 | "Set default metric for circuit\n" |
| 569 | "Default metric value\n") |
| 570 | |
| 571 | DEFUN (isis_metric_l1, |
| 572 | isis_metric_l1_cmd, |
| 573 | "isis metric <0-16777215> level-1", |
| 574 | "IS-IS commands\n" |
| 575 | "Set default metric for circuit\n" |
| 576 | "Default metric value\n" |
| 577 | "Specify metric for level-1 routing\n") |
| 578 | { |
| 579 | int met; |
| 580 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 581 | if (!circuit) |
| 582 | return CMD_ERR_NO_MATCH; |
| 583 | |
| 584 | met = atoi (argv[0]); |
| 585 | |
| 586 | /* RFC3787 section 5.1 */ |
| 587 | if (circuit->area && circuit->area->oldmetric == 1 && |
| 588 | met > MAX_NARROW_LINK_METRIC) |
| 589 | { |
| 590 | vty_out (vty, "Invalid metric %d - should be <0-63> " |
| 591 | "when narrow metric type enabled%s", |
| 592 | met, VTY_NEWLINE); |
| 593 | return CMD_ERR_AMBIGUOUS; |
| 594 | } |
| 595 | |
| 596 | /* RFC4444 */ |
| 597 | if (circuit->area && circuit->area->newmetric == 1 && |
| 598 | met > MAX_WIDE_LINK_METRIC) |
| 599 | { |
| 600 | vty_out (vty, "Invalid metric %d - should be <0-16777215> " |
| 601 | "when wide metric type enabled%s", |
| 602 | met, VTY_NEWLINE); |
| 603 | return CMD_ERR_AMBIGUOUS; |
| 604 | } |
| 605 | |
| 606 | isis_circuit_metric_set (circuit, IS_LEVEL_1, met); |
| 607 | return CMD_SUCCESS; |
| 608 | } |
| 609 | |
| 610 | DEFUN (no_isis_metric_l1, |
| 611 | no_isis_metric_l1_cmd, |
| 612 | "no isis metric level-1", |
| 613 | NO_STR |
| 614 | "IS-IS commands\n" |
| 615 | "Set default metric for circuit\n" |
| 616 | "Specify metric for level-1 routing\n") |
| 617 | { |
| 618 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 619 | if (!circuit) |
| 620 | return CMD_ERR_NO_MATCH; |
| 621 | |
| 622 | isis_circuit_metric_set (circuit, IS_LEVEL_1, DEFAULT_CIRCUIT_METRIC); |
| 623 | return CMD_SUCCESS; |
| 624 | } |
| 625 | |
| 626 | ALIAS (no_isis_metric_l1, |
| 627 | no_isis_metric_l1_arg_cmd, |
| 628 | "no isis metric <0-16777215> level-1", |
| 629 | NO_STR |
| 630 | "IS-IS commands\n" |
| 631 | "Set default metric for circuit\n" |
| 632 | "Default metric value\n" |
| 633 | "Specify metric for level-1 routing\n") |
| 634 | |
| 635 | DEFUN (isis_metric_l2, |
| 636 | isis_metric_l2_cmd, |
| 637 | "isis metric <0-16777215> level-2", |
| 638 | "IS-IS commands\n" |
| 639 | "Set default metric for circuit\n" |
| 640 | "Default metric value\n" |
| 641 | "Specify metric for level-2 routing\n") |
| 642 | { |
| 643 | int met; |
| 644 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 645 | if (!circuit) |
| 646 | return CMD_ERR_NO_MATCH; |
| 647 | |
| 648 | met = atoi (argv[0]); |
| 649 | |
| 650 | /* RFC3787 section 5.1 */ |
| 651 | if (circuit->area && circuit->area->oldmetric == 1 && |
| 652 | met > MAX_NARROW_LINK_METRIC) |
| 653 | { |
| 654 | vty_out (vty, "Invalid metric %d - should be <0-63> " |
| 655 | "when narrow metric type enabled%s", |
| 656 | met, VTY_NEWLINE); |
| 657 | return CMD_ERR_AMBIGUOUS; |
| 658 | } |
| 659 | |
| 660 | /* RFC4444 */ |
| 661 | if (circuit->area && circuit->area->newmetric == 1 && |
| 662 | met > MAX_WIDE_LINK_METRIC) |
| 663 | { |
| 664 | vty_out (vty, "Invalid metric %d - should be <0-16777215> " |
| 665 | "when wide metric type enabled%s", |
| 666 | met, VTY_NEWLINE); |
| 667 | return CMD_ERR_AMBIGUOUS; |
| 668 | } |
| 669 | |
| 670 | isis_circuit_metric_set (circuit, IS_LEVEL_2, met); |
| 671 | return CMD_SUCCESS; |
| 672 | } |
| 673 | |
| 674 | DEFUN (no_isis_metric_l2, |
| 675 | no_isis_metric_l2_cmd, |
| 676 | "no isis metric level-2", |
| 677 | NO_STR |
| 678 | "IS-IS commands\n" |
| 679 | "Set default metric for circuit\n" |
| 680 | "Specify metric for level-2 routing\n") |
| 681 | { |
| 682 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 683 | if (!circuit) |
| 684 | return CMD_ERR_NO_MATCH; |
| 685 | |
| 686 | isis_circuit_metric_set (circuit, IS_LEVEL_2, DEFAULT_CIRCUIT_METRIC); |
| 687 | return CMD_SUCCESS; |
| 688 | } |
| 689 | |
| 690 | ALIAS (no_isis_metric_l2, |
| 691 | no_isis_metric_l2_arg_cmd, |
| 692 | "no isis metric <0-16777215> level-2", |
| 693 | NO_STR |
| 694 | "IS-IS commands\n" |
| 695 | "Set default metric for circuit\n" |
| 696 | "Default metric value\n" |
| 697 | "Specify metric for level-2 routing\n") |
| 698 | /* end of metrics */ |
| 699 | |
David Lamparter | b5d2f5f | 2016-07-28 17:23:28 +0200 | [diff] [blame] | 700 | DEFUN (isis_hello_interval, |
| 701 | isis_hello_interval_cmd, |
| 702 | "isis hello-interval <1-600>", |
| 703 | "IS-IS commands\n" |
| 704 | "Set Hello interval\n" |
| 705 | "Hello interval value\n" |
| 706 | "Holdtime 1 seconds, interval depends on multiplier\n") |
| 707 | { |
| 708 | int interval; |
| 709 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 710 | if (!circuit) |
| 711 | return CMD_ERR_NO_MATCH; |
| 712 | |
| 713 | interval = atoi (argv[0]); |
| 714 | if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) |
| 715 | { |
| 716 | vty_out (vty, "Invalid hello-interval %d - should be <1-600>%s", |
| 717 | interval, VTY_NEWLINE); |
| 718 | return CMD_ERR_AMBIGUOUS; |
| 719 | } |
| 720 | |
| 721 | circuit->hello_interval[0] = (u_int16_t) interval; |
| 722 | circuit->hello_interval[1] = (u_int16_t) interval; |
| 723 | |
| 724 | return CMD_SUCCESS; |
| 725 | } |
| 726 | |
| 727 | DEFUN (no_isis_hello_interval, |
| 728 | no_isis_hello_interval_cmd, |
| 729 | "no isis hello-interval", |
| 730 | NO_STR |
| 731 | "IS-IS commands\n" |
| 732 | "Set Hello interval\n") |
| 733 | { |
| 734 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 735 | if (!circuit) |
| 736 | return CMD_ERR_NO_MATCH; |
| 737 | |
| 738 | circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL; |
| 739 | circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL; |
| 740 | |
| 741 | return CMD_SUCCESS; |
| 742 | } |
| 743 | |
| 744 | ALIAS (no_isis_hello_interval, |
| 745 | no_isis_hello_interval_arg_cmd, |
| 746 | "no isis hello-interval <1-600>", |
| 747 | NO_STR |
| 748 | "IS-IS commands\n" |
| 749 | "Set Hello interval\n" |
| 750 | "Hello interval value\n" |
| 751 | "Holdtime 1 second, interval depends on multiplier\n") |
| 752 | |
| 753 | DEFUN (isis_hello_interval_l1, |
| 754 | isis_hello_interval_l1_cmd, |
| 755 | "isis hello-interval <1-600> level-1", |
| 756 | "IS-IS commands\n" |
| 757 | "Set Hello interval\n" |
| 758 | "Hello interval value\n" |
| 759 | "Holdtime 1 second, interval depends on multiplier\n" |
| 760 | "Specify hello-interval for level-1 IIHs\n") |
| 761 | { |
| 762 | long interval; |
| 763 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 764 | if (!circuit) |
| 765 | return CMD_ERR_NO_MATCH; |
| 766 | |
| 767 | interval = atoi (argv[0]); |
| 768 | if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) |
| 769 | { |
| 770 | vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s", |
| 771 | interval, VTY_NEWLINE); |
| 772 | return CMD_ERR_AMBIGUOUS; |
| 773 | } |
| 774 | |
| 775 | circuit->hello_interval[0] = (u_int16_t) interval; |
| 776 | |
| 777 | return CMD_SUCCESS; |
| 778 | } |
| 779 | |
| 780 | DEFUN (no_isis_hello_interval_l1, |
| 781 | no_isis_hello_interval_l1_cmd, |
| 782 | "no isis hello-interval level-1", |
| 783 | NO_STR |
| 784 | "IS-IS commands\n" |
| 785 | "Set Hello interval\n" |
| 786 | "Specify hello-interval for level-1 IIHs\n") |
| 787 | { |
| 788 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 789 | if (!circuit) |
| 790 | return CMD_ERR_NO_MATCH; |
| 791 | |
| 792 | circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL; |
| 793 | |
| 794 | return CMD_SUCCESS; |
| 795 | } |
| 796 | |
| 797 | ALIAS (no_isis_hello_interval_l1, |
| 798 | no_isis_hello_interval_l1_arg_cmd, |
| 799 | "no isis hello-interval <1-600> level-1", |
| 800 | NO_STR |
| 801 | "IS-IS commands\n" |
| 802 | "Set Hello interval\n" |
| 803 | "Hello interval value\n" |
| 804 | "Holdtime 1 second, interval depends on multiplier\n" |
| 805 | "Specify hello-interval for level-1 IIHs\n") |
| 806 | |
| 807 | DEFUN (isis_hello_interval_l2, |
| 808 | isis_hello_interval_l2_cmd, |
| 809 | "isis hello-interval <1-600> level-2", |
| 810 | "IS-IS commands\n" |
| 811 | "Set Hello interval\n" |
| 812 | "Hello interval value\n" |
| 813 | "Holdtime 1 second, interval depends on multiplier\n" |
| 814 | "Specify hello-interval for level-2 IIHs\n") |
| 815 | { |
| 816 | long interval; |
| 817 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 818 | if (!circuit) |
| 819 | return CMD_ERR_NO_MATCH; |
| 820 | |
| 821 | interval = atoi (argv[0]); |
| 822 | if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) |
| 823 | { |
| 824 | vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s", |
| 825 | interval, VTY_NEWLINE); |
| 826 | return CMD_ERR_AMBIGUOUS; |
| 827 | } |
| 828 | |
| 829 | circuit->hello_interval[1] = (u_int16_t) interval; |
| 830 | |
| 831 | return CMD_SUCCESS; |
| 832 | } |
| 833 | |
| 834 | DEFUN (no_isis_hello_interval_l2, |
| 835 | no_isis_hello_interval_l2_cmd, |
| 836 | "no isis hello-interval level-2", |
| 837 | NO_STR |
| 838 | "IS-IS commands\n" |
| 839 | "Set Hello interval\n" |
| 840 | "Specify hello-interval for level-2 IIHs\n") |
| 841 | { |
| 842 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 843 | if (!circuit) |
| 844 | return CMD_ERR_NO_MATCH; |
| 845 | |
| 846 | circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL; |
| 847 | |
| 848 | return CMD_SUCCESS; |
| 849 | } |
| 850 | |
| 851 | ALIAS (no_isis_hello_interval_l2, |
| 852 | no_isis_hello_interval_l2_arg_cmd, |
| 853 | "no isis hello-interval <1-600> level-2", |
| 854 | NO_STR |
| 855 | "IS-IS commands\n" |
| 856 | "Set Hello interval\n" |
| 857 | "Hello interval value\n" |
| 858 | "Holdtime 1 second, interval depends on multiplier\n" |
| 859 | "Specify hello-interval for level-2 IIHs\n") |
| 860 | |
| 861 | DEFUN (isis_hello_multiplier, |
| 862 | isis_hello_multiplier_cmd, |
| 863 | "isis hello-multiplier <2-100>", |
| 864 | "IS-IS commands\n" |
| 865 | "Set multiplier for Hello holding time\n" |
| 866 | "Hello multiplier value\n") |
| 867 | { |
| 868 | int mult; |
| 869 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 870 | if (!circuit) |
| 871 | return CMD_ERR_NO_MATCH; |
| 872 | |
| 873 | mult = atoi (argv[0]); |
| 874 | if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) |
| 875 | { |
| 876 | vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", |
| 877 | mult, VTY_NEWLINE); |
| 878 | return CMD_ERR_AMBIGUOUS; |
| 879 | } |
| 880 | |
| 881 | circuit->hello_multiplier[0] = (u_int16_t) mult; |
| 882 | circuit->hello_multiplier[1] = (u_int16_t) mult; |
| 883 | |
| 884 | return CMD_SUCCESS; |
| 885 | } |
| 886 | |
| 887 | DEFUN (no_isis_hello_multiplier, |
| 888 | no_isis_hello_multiplier_cmd, |
| 889 | "no isis hello-multiplier", |
| 890 | NO_STR |
| 891 | "IS-IS commands\n" |
| 892 | "Set multiplier for Hello holding time\n") |
| 893 | { |
| 894 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 895 | if (!circuit) |
| 896 | return CMD_ERR_NO_MATCH; |
| 897 | |
| 898 | circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER; |
| 899 | circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER; |
| 900 | |
| 901 | return CMD_SUCCESS; |
| 902 | } |
| 903 | |
| 904 | ALIAS (no_isis_hello_multiplier, |
| 905 | no_isis_hello_multiplier_arg_cmd, |
| 906 | "no isis hello-multiplier <2-100>", |
| 907 | NO_STR |
| 908 | "IS-IS commands\n" |
| 909 | "Set multiplier for Hello holding time\n" |
| 910 | "Hello multiplier value\n") |
| 911 | |
| 912 | DEFUN (isis_hello_multiplier_l1, |
| 913 | isis_hello_multiplier_l1_cmd, |
| 914 | "isis hello-multiplier <2-100> level-1", |
| 915 | "IS-IS commands\n" |
| 916 | "Set multiplier for Hello holding time\n" |
| 917 | "Hello multiplier value\n" |
| 918 | "Specify hello multiplier for level-1 IIHs\n") |
| 919 | { |
| 920 | int mult; |
| 921 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 922 | if (!circuit) |
| 923 | return CMD_ERR_NO_MATCH; |
| 924 | |
| 925 | mult = atoi (argv[0]); |
| 926 | if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) |
| 927 | { |
| 928 | vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", |
| 929 | mult, VTY_NEWLINE); |
| 930 | return CMD_ERR_AMBIGUOUS; |
| 931 | } |
| 932 | |
| 933 | circuit->hello_multiplier[0] = (u_int16_t) mult; |
| 934 | |
| 935 | return CMD_SUCCESS; |
| 936 | } |
| 937 | |
| 938 | DEFUN (no_isis_hello_multiplier_l1, |
| 939 | no_isis_hello_multiplier_l1_cmd, |
| 940 | "no isis hello-multiplier level-1", |
| 941 | NO_STR |
| 942 | "IS-IS commands\n" |
| 943 | "Set multiplier for Hello holding time\n" |
| 944 | "Specify hello multiplier for level-1 IIHs\n") |
| 945 | { |
| 946 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 947 | if (!circuit) |
| 948 | return CMD_ERR_NO_MATCH; |
| 949 | |
| 950 | circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER; |
| 951 | |
| 952 | return CMD_SUCCESS; |
| 953 | } |
| 954 | |
| 955 | ALIAS (no_isis_hello_multiplier_l1, |
| 956 | no_isis_hello_multiplier_l1_arg_cmd, |
| 957 | "no isis hello-multiplier <2-100> level-1", |
| 958 | NO_STR |
| 959 | "IS-IS commands\n" |
| 960 | "Set multiplier for Hello holding time\n" |
| 961 | "Hello multiplier value\n" |
| 962 | "Specify hello multiplier for level-1 IIHs\n") |
| 963 | |
| 964 | DEFUN (isis_hello_multiplier_l2, |
| 965 | isis_hello_multiplier_l2_cmd, |
| 966 | "isis hello-multiplier <2-100> level-2", |
| 967 | "IS-IS commands\n" |
| 968 | "Set multiplier for Hello holding time\n" |
| 969 | "Hello multiplier value\n" |
| 970 | "Specify hello multiplier for level-2 IIHs\n") |
| 971 | { |
| 972 | int mult; |
| 973 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 974 | if (!circuit) |
| 975 | return CMD_ERR_NO_MATCH; |
| 976 | |
| 977 | mult = atoi (argv[0]); |
| 978 | if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) |
| 979 | { |
| 980 | vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", |
| 981 | mult, VTY_NEWLINE); |
| 982 | return CMD_ERR_AMBIGUOUS; |
| 983 | } |
| 984 | |
| 985 | circuit->hello_multiplier[1] = (u_int16_t) mult; |
| 986 | |
| 987 | return CMD_SUCCESS; |
| 988 | } |
| 989 | |
| 990 | DEFUN (no_isis_hello_multiplier_l2, |
| 991 | no_isis_hello_multiplier_l2_cmd, |
| 992 | "no isis hello-multiplier level-2", |
| 993 | NO_STR |
| 994 | "IS-IS commands\n" |
| 995 | "Set multiplier for Hello holding time\n" |
| 996 | "Specify hello multiplier for level-2 IIHs\n") |
| 997 | { |
| 998 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 999 | if (!circuit) |
| 1000 | return CMD_ERR_NO_MATCH; |
| 1001 | |
| 1002 | circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER; |
| 1003 | |
| 1004 | return CMD_SUCCESS; |
| 1005 | } |
| 1006 | |
| 1007 | ALIAS (no_isis_hello_multiplier_l2, |
| 1008 | no_isis_hello_multiplier_l2_arg_cmd, |
| 1009 | "no isis hello-multiplier <2-100> level-2", |
| 1010 | NO_STR |
| 1011 | "IS-IS commands\n" |
| 1012 | "Set multiplier for Hello holding time\n" |
| 1013 | "Hello multiplier value\n" |
| 1014 | "Specify hello multiplier for level-2 IIHs\n") |
| 1015 | |
| 1016 | DEFUN (isis_hello_padding, |
| 1017 | isis_hello_padding_cmd, |
| 1018 | "isis hello padding", |
| 1019 | "IS-IS commands\n" |
| 1020 | "Add padding to IS-IS hello packets\n" |
| 1021 | "Pad hello packets\n" |
| 1022 | "<cr>\n") |
| 1023 | { |
| 1024 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1025 | if (!circuit) |
| 1026 | return CMD_ERR_NO_MATCH; |
| 1027 | |
| 1028 | circuit->pad_hellos = 1; |
| 1029 | |
| 1030 | return CMD_SUCCESS; |
| 1031 | } |
| 1032 | |
| 1033 | DEFUN (no_isis_hello_padding, |
| 1034 | no_isis_hello_padding_cmd, |
| 1035 | "no isis hello padding", |
| 1036 | NO_STR |
| 1037 | "IS-IS commands\n" |
| 1038 | "Add padding to IS-IS hello packets\n" |
| 1039 | "Pad hello packets\n" |
| 1040 | "<cr>\n") |
| 1041 | { |
| 1042 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1043 | if (!circuit) |
| 1044 | return CMD_ERR_NO_MATCH; |
| 1045 | |
| 1046 | circuit->pad_hellos = 0; |
| 1047 | |
| 1048 | return CMD_SUCCESS; |
| 1049 | } |
| 1050 | |
| 1051 | DEFUN (csnp_interval, |
| 1052 | csnp_interval_cmd, |
| 1053 | "isis csnp-interval <1-600>", |
| 1054 | "IS-IS commands\n" |
| 1055 | "Set CSNP interval in seconds\n" |
| 1056 | "CSNP interval value\n") |
| 1057 | { |
| 1058 | unsigned long interval; |
| 1059 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1060 | if (!circuit) |
| 1061 | return CMD_ERR_NO_MATCH; |
| 1062 | |
| 1063 | interval = atol (argv[0]); |
| 1064 | if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) |
| 1065 | { |
| 1066 | vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", |
| 1067 | interval, VTY_NEWLINE); |
| 1068 | return CMD_ERR_AMBIGUOUS; |
| 1069 | } |
| 1070 | |
| 1071 | circuit->csnp_interval[0] = (u_int16_t) interval; |
| 1072 | circuit->csnp_interval[1] = (u_int16_t) interval; |
| 1073 | |
| 1074 | return CMD_SUCCESS; |
| 1075 | } |
| 1076 | |
| 1077 | DEFUN (no_csnp_interval, |
| 1078 | no_csnp_interval_cmd, |
| 1079 | "no isis csnp-interval", |
| 1080 | NO_STR |
| 1081 | "IS-IS commands\n" |
| 1082 | "Set CSNP interval in seconds\n") |
| 1083 | { |
| 1084 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1085 | if (!circuit) |
| 1086 | return CMD_ERR_NO_MATCH; |
| 1087 | |
| 1088 | circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL; |
| 1089 | circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL; |
| 1090 | |
| 1091 | return CMD_SUCCESS; |
| 1092 | } |
| 1093 | |
| 1094 | ALIAS (no_csnp_interval, |
| 1095 | no_csnp_interval_arg_cmd, |
| 1096 | "no isis csnp-interval <1-600>", |
| 1097 | NO_STR |
| 1098 | "IS-IS commands\n" |
| 1099 | "Set CSNP interval in seconds\n" |
| 1100 | "CSNP interval value\n") |
| 1101 | |
| 1102 | DEFUN (csnp_interval_l1, |
| 1103 | csnp_interval_l1_cmd, |
| 1104 | "isis csnp-interval <1-600> level-1", |
| 1105 | "IS-IS commands\n" |
| 1106 | "Set CSNP interval in seconds\n" |
| 1107 | "CSNP interval value\n" |
| 1108 | "Specify interval for level-1 CSNPs\n") |
| 1109 | { |
| 1110 | unsigned long interval; |
| 1111 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1112 | if (!circuit) |
| 1113 | return CMD_ERR_NO_MATCH; |
| 1114 | |
| 1115 | interval = atol (argv[0]); |
| 1116 | if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) |
| 1117 | { |
| 1118 | vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", |
| 1119 | interval, VTY_NEWLINE); |
| 1120 | return CMD_ERR_AMBIGUOUS; |
| 1121 | } |
| 1122 | |
| 1123 | circuit->csnp_interval[0] = (u_int16_t) interval; |
| 1124 | |
| 1125 | return CMD_SUCCESS; |
| 1126 | } |
| 1127 | |
| 1128 | DEFUN (no_csnp_interval_l1, |
| 1129 | no_csnp_interval_l1_cmd, |
| 1130 | "no isis csnp-interval level-1", |
| 1131 | NO_STR |
| 1132 | "IS-IS commands\n" |
| 1133 | "Set CSNP interval in seconds\n" |
| 1134 | "Specify interval for level-1 CSNPs\n") |
| 1135 | { |
| 1136 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1137 | if (!circuit) |
| 1138 | return CMD_ERR_NO_MATCH; |
| 1139 | |
| 1140 | circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL; |
| 1141 | |
| 1142 | return CMD_SUCCESS; |
| 1143 | } |
| 1144 | |
| 1145 | ALIAS (no_csnp_interval_l1, |
| 1146 | no_csnp_interval_l1_arg_cmd, |
| 1147 | "no isis csnp-interval <1-600> level-1", |
| 1148 | NO_STR |
| 1149 | "IS-IS commands\n" |
| 1150 | "Set CSNP interval in seconds\n" |
| 1151 | "CSNP interval value\n" |
| 1152 | "Specify interval for level-1 CSNPs\n") |
| 1153 | |
| 1154 | DEFUN (csnp_interval_l2, |
| 1155 | csnp_interval_l2_cmd, |
| 1156 | "isis csnp-interval <1-600> level-2", |
| 1157 | "IS-IS commands\n" |
| 1158 | "Set CSNP interval in seconds\n" |
| 1159 | "CSNP interval value\n" |
| 1160 | "Specify interval for level-2 CSNPs\n") |
| 1161 | { |
| 1162 | unsigned long interval; |
| 1163 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1164 | if (!circuit) |
| 1165 | return CMD_ERR_NO_MATCH; |
| 1166 | |
| 1167 | interval = atol (argv[0]); |
| 1168 | if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) |
| 1169 | { |
| 1170 | vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", |
| 1171 | interval, VTY_NEWLINE); |
| 1172 | return CMD_ERR_AMBIGUOUS; |
| 1173 | } |
| 1174 | |
| 1175 | circuit->csnp_interval[1] = (u_int16_t) interval; |
| 1176 | |
| 1177 | return CMD_SUCCESS; |
| 1178 | } |
| 1179 | |
| 1180 | DEFUN (no_csnp_interval_l2, |
| 1181 | no_csnp_interval_l2_cmd, |
| 1182 | "no isis csnp-interval level-2", |
| 1183 | NO_STR |
| 1184 | "IS-IS commands\n" |
| 1185 | "Set CSNP interval in seconds\n" |
| 1186 | "Specify interval for level-2 CSNPs\n") |
| 1187 | { |
| 1188 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1189 | if (!circuit) |
| 1190 | return CMD_ERR_NO_MATCH; |
| 1191 | |
| 1192 | circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL; |
| 1193 | |
| 1194 | return CMD_SUCCESS; |
| 1195 | } |
| 1196 | |
| 1197 | ALIAS (no_csnp_interval_l2, |
| 1198 | no_csnp_interval_l2_arg_cmd, |
| 1199 | "no isis csnp-interval <1-600> level-2", |
| 1200 | NO_STR |
| 1201 | "IS-IS commands\n" |
| 1202 | "Set CSNP interval in seconds\n" |
| 1203 | "CSNP interval value\n" |
| 1204 | "Specify interval for level-2 CSNPs\n") |
| 1205 | |
| 1206 | DEFUN (psnp_interval, |
| 1207 | psnp_interval_cmd, |
| 1208 | "isis psnp-interval <1-120>", |
| 1209 | "IS-IS commands\n" |
| 1210 | "Set PSNP interval in seconds\n" |
| 1211 | "PSNP interval value\n") |
| 1212 | { |
| 1213 | unsigned long interval; |
| 1214 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1215 | if (!circuit) |
| 1216 | return CMD_ERR_NO_MATCH; |
| 1217 | |
| 1218 | interval = atol (argv[0]); |
| 1219 | if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) |
| 1220 | { |
| 1221 | vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", |
| 1222 | interval, VTY_NEWLINE); |
| 1223 | return CMD_ERR_AMBIGUOUS; |
| 1224 | } |
| 1225 | |
| 1226 | circuit->psnp_interval[0] = (u_int16_t) interval; |
| 1227 | circuit->psnp_interval[1] = (u_int16_t) interval; |
| 1228 | |
| 1229 | return CMD_SUCCESS; |
| 1230 | } |
| 1231 | |
| 1232 | DEFUN (no_psnp_interval, |
| 1233 | no_psnp_interval_cmd, |
| 1234 | "no isis psnp-interval", |
| 1235 | NO_STR |
| 1236 | "IS-IS commands\n" |
| 1237 | "Set PSNP interval in seconds\n") |
| 1238 | { |
| 1239 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1240 | if (!circuit) |
| 1241 | return CMD_ERR_NO_MATCH; |
| 1242 | |
| 1243 | circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL; |
| 1244 | circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL; |
| 1245 | |
| 1246 | return CMD_SUCCESS; |
| 1247 | } |
| 1248 | |
| 1249 | ALIAS (no_psnp_interval, |
| 1250 | no_psnp_interval_arg_cmd, |
| 1251 | "no isis psnp-interval <1-120>", |
| 1252 | NO_STR |
| 1253 | "IS-IS commands\n" |
| 1254 | "Set PSNP interval in seconds\n" |
| 1255 | "PSNP interval value\n") |
| 1256 | |
| 1257 | DEFUN (psnp_interval_l1, |
| 1258 | psnp_interval_l1_cmd, |
| 1259 | "isis psnp-interval <1-120> level-1", |
| 1260 | "IS-IS commands\n" |
| 1261 | "Set PSNP interval in seconds\n" |
| 1262 | "PSNP interval value\n" |
| 1263 | "Specify interval for level-1 PSNPs\n") |
| 1264 | { |
| 1265 | unsigned long interval; |
| 1266 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1267 | if (!circuit) |
| 1268 | return CMD_ERR_NO_MATCH; |
| 1269 | |
| 1270 | interval = atol (argv[0]); |
| 1271 | if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) |
| 1272 | { |
| 1273 | vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", |
| 1274 | interval, VTY_NEWLINE); |
| 1275 | return CMD_ERR_AMBIGUOUS; |
| 1276 | } |
| 1277 | |
| 1278 | circuit->psnp_interval[0] = (u_int16_t) interval; |
| 1279 | |
| 1280 | return CMD_SUCCESS; |
| 1281 | } |
| 1282 | |
| 1283 | DEFUN (no_psnp_interval_l1, |
| 1284 | no_psnp_interval_l1_cmd, |
| 1285 | "no isis psnp-interval level-1", |
| 1286 | NO_STR |
| 1287 | "IS-IS commands\n" |
| 1288 | "Set PSNP interval in seconds\n" |
| 1289 | "Specify interval for level-1 PSNPs\n") |
| 1290 | { |
| 1291 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1292 | if (!circuit) |
| 1293 | return CMD_ERR_NO_MATCH; |
| 1294 | |
| 1295 | circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL; |
| 1296 | |
| 1297 | return CMD_SUCCESS; |
| 1298 | } |
| 1299 | |
| 1300 | ALIAS (no_psnp_interval_l1, |
| 1301 | no_psnp_interval_l1_arg_cmd, |
| 1302 | "no isis psnp-interval <1-120> level-1", |
| 1303 | NO_STR |
| 1304 | "IS-IS commands\n" |
| 1305 | "Set PSNP interval in seconds\n" |
| 1306 | "PSNP interval value\n" |
| 1307 | "Specify interval for level-1 PSNPs\n") |
| 1308 | |
| 1309 | DEFUN (psnp_interval_l2, |
| 1310 | psnp_interval_l2_cmd, |
| 1311 | "isis psnp-interval <1-120> level-2", |
| 1312 | "IS-IS commands\n" |
| 1313 | "Set PSNP interval in seconds\n" |
| 1314 | "PSNP interval value\n" |
| 1315 | "Specify interval for level-2 PSNPs\n") |
| 1316 | { |
| 1317 | unsigned long interval; |
| 1318 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1319 | if (!circuit) |
| 1320 | return CMD_ERR_NO_MATCH; |
| 1321 | |
| 1322 | interval = atol (argv[0]); |
| 1323 | if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) |
| 1324 | { |
| 1325 | vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", |
| 1326 | interval, VTY_NEWLINE); |
| 1327 | return CMD_ERR_AMBIGUOUS; |
| 1328 | } |
| 1329 | |
| 1330 | circuit->psnp_interval[1] = (u_int16_t) interval; |
| 1331 | |
| 1332 | return CMD_SUCCESS; |
| 1333 | } |
| 1334 | |
| 1335 | DEFUN (no_psnp_interval_l2, |
| 1336 | no_psnp_interval_l2_cmd, |
| 1337 | "no isis psnp-interval level-2", |
| 1338 | NO_STR |
| 1339 | "IS-IS commands\n" |
| 1340 | "Set PSNP interval in seconds\n" |
| 1341 | "Specify interval for level-2 PSNPs\n") |
| 1342 | { |
| 1343 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1344 | if (!circuit) |
| 1345 | return CMD_ERR_NO_MATCH; |
| 1346 | |
| 1347 | circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL; |
| 1348 | |
| 1349 | return CMD_SUCCESS; |
| 1350 | } |
| 1351 | |
| 1352 | ALIAS (no_psnp_interval_l2, |
| 1353 | no_psnp_interval_l2_arg_cmd, |
| 1354 | "no isis psnp-interval <1-120> level-2", |
| 1355 | NO_STR |
| 1356 | "IS-IS commands\n" |
| 1357 | "Set PSNP interval in seconds\n" |
| 1358 | "PSNP interval value\n" |
| 1359 | "Specify interval for level-2 PSNPs\n") |
| 1360 | |
Christian Franke | ccd485d | 2016-07-28 17:23:26 +0200 | [diff] [blame] | 1361 | static int |
| 1362 | validate_metric_style_narrow (struct vty *vty, struct isis_area *area) |
| 1363 | { |
| 1364 | struct isis_circuit *circuit; |
| 1365 | struct listnode *node; |
| 1366 | |
| 1367 | if (! vty) |
| 1368 | return CMD_ERR_AMBIGUOUS; |
| 1369 | |
| 1370 | if (! area) |
| 1371 | { |
| 1372 | vty_out (vty, "ISIS area is invalid%s", VTY_NEWLINE); |
| 1373 | return CMD_ERR_AMBIGUOUS; |
| 1374 | } |
| 1375 | |
| 1376 | for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit)) |
| 1377 | { |
| 1378 | if ((area->is_type & IS_LEVEL_1) && |
| 1379 | (circuit->is_type & IS_LEVEL_1) && |
| 1380 | (circuit->te_metric[0] > MAX_NARROW_LINK_METRIC)) |
| 1381 | { |
| 1382 | vty_out (vty, "ISIS circuit %s metric is invalid%s", |
| 1383 | circuit->interface->name, VTY_NEWLINE); |
| 1384 | return CMD_ERR_AMBIGUOUS; |
| 1385 | } |
| 1386 | if ((area->is_type & IS_LEVEL_2) && |
| 1387 | (circuit->is_type & IS_LEVEL_2) && |
| 1388 | (circuit->te_metric[1] > MAX_NARROW_LINK_METRIC)) |
| 1389 | { |
| 1390 | vty_out (vty, "ISIS circuit %s metric is invalid%s", |
| 1391 | circuit->interface->name, VTY_NEWLINE); |
| 1392 | return CMD_ERR_AMBIGUOUS; |
| 1393 | } |
| 1394 | } |
| 1395 | |
| 1396 | return CMD_SUCCESS; |
| 1397 | } |
| 1398 | |
| 1399 | DEFUN (metric_style, |
| 1400 | metric_style_cmd, |
| 1401 | "metric-style (narrow|transition|wide)", |
| 1402 | "Use old-style (ISO 10589) or new-style packet formats\n" |
| 1403 | "Use old style of TLVs with narrow metric\n" |
| 1404 | "Send and accept both styles of TLVs during transition\n" |
| 1405 | "Use new style of TLVs to carry wider metric\n") |
| 1406 | { |
| 1407 | struct isis_area *area = vty->index; |
| 1408 | int ret; |
| 1409 | |
| 1410 | assert(area); |
| 1411 | |
| 1412 | if (strncmp (argv[0], "w", 1) == 0) |
| 1413 | { |
| 1414 | isis_area_metricstyle_set(area, false, true); |
| 1415 | return CMD_SUCCESS; |
| 1416 | } |
| 1417 | |
| 1418 | ret = validate_metric_style_narrow (vty, area); |
| 1419 | if (ret != CMD_SUCCESS) |
| 1420 | return ret; |
| 1421 | |
| 1422 | if (strncmp (argv[0], "t", 1) == 0) |
| 1423 | isis_area_metricstyle_set(area, true, true); |
| 1424 | else if (strncmp (argv[0], "n", 1) == 0) |
| 1425 | isis_area_metricstyle_set(area, true, false); |
| 1426 | return CMD_SUCCESS; |
| 1427 | |
| 1428 | return CMD_SUCCESS; |
| 1429 | } |
| 1430 | |
| 1431 | DEFUN (no_metric_style, |
| 1432 | no_metric_style_cmd, |
| 1433 | "no metric-style", |
| 1434 | NO_STR |
| 1435 | "Use old-style (ISO 10589) or new-style packet formats\n") |
| 1436 | { |
| 1437 | struct isis_area *area = vty->index; |
| 1438 | int ret; |
| 1439 | |
| 1440 | assert (area); |
| 1441 | ret = validate_metric_style_narrow (vty, area); |
| 1442 | if (ret != CMD_SUCCESS) |
| 1443 | return ret; |
| 1444 | |
| 1445 | isis_area_metricstyle_set(area, true, false); |
| 1446 | return CMD_SUCCESS; |
| 1447 | } |
| 1448 | |
| 1449 | DEFUN (set_overload_bit, |
| 1450 | set_overload_bit_cmd, |
| 1451 | "set-overload-bit", |
| 1452 | "Set overload bit to avoid any transit traffic\n" |
| 1453 | "Set overload bit\n") |
| 1454 | { |
| 1455 | struct isis_area *area = vty->index; |
| 1456 | assert (area); |
| 1457 | |
| 1458 | isis_area_overload_bit_set(area, true); |
| 1459 | return CMD_SUCCESS; |
| 1460 | } |
| 1461 | |
| 1462 | DEFUN (no_set_overload_bit, |
| 1463 | no_set_overload_bit_cmd, |
| 1464 | "no set-overload-bit", |
| 1465 | "Reset overload bit to accept transit traffic\n" |
| 1466 | "Reset overload bit\n") |
| 1467 | { |
| 1468 | struct isis_area *area = vty->index; |
| 1469 | assert (area); |
| 1470 | |
| 1471 | isis_area_overload_bit_set(area, false); |
| 1472 | return CMD_SUCCESS; |
| 1473 | } |
| 1474 | |
| 1475 | DEFUN (set_attached_bit, |
| 1476 | set_attached_bit_cmd, |
| 1477 | "set-attached-bit", |
| 1478 | "Set attached bit to identify as L1/L2 router for inter-area traffic\n" |
| 1479 | "Set attached bit\n") |
| 1480 | { |
| 1481 | struct isis_area *area = vty->index; |
| 1482 | assert (area); |
| 1483 | |
| 1484 | isis_area_attached_bit_set(area, true); |
| 1485 | return CMD_SUCCESS; |
| 1486 | } |
| 1487 | |
| 1488 | DEFUN (no_set_attached_bit, |
| 1489 | no_set_attached_bit_cmd, |
| 1490 | "no set-attached-bit", |
| 1491 | "Reset attached bit\n") |
| 1492 | { |
| 1493 | struct isis_area *area = vty->index; |
| 1494 | assert (area); |
| 1495 | |
| 1496 | isis_area_attached_bit_set(area, false); |
| 1497 | return CMD_SUCCESS; |
| 1498 | } |
| 1499 | |
| 1500 | DEFUN (dynamic_hostname, |
| 1501 | dynamic_hostname_cmd, |
| 1502 | "hostname dynamic", |
| 1503 | "Dynamic hostname for IS-IS\n" |
| 1504 | "Dynamic hostname\n") |
| 1505 | { |
| 1506 | struct isis_area *area = vty->index; |
| 1507 | assert(area); |
| 1508 | |
| 1509 | isis_area_dynhostname_set(area, true); |
| 1510 | return CMD_SUCCESS; |
| 1511 | } |
| 1512 | |
| 1513 | DEFUN (no_dynamic_hostname, |
| 1514 | no_dynamic_hostname_cmd, |
| 1515 | "no hostname dynamic", |
| 1516 | NO_STR |
| 1517 | "Dynamic hostname for IS-IS\n" |
| 1518 | "Dynamic hostname\n") |
| 1519 | { |
| 1520 | struct isis_area *area = vty->index; |
| 1521 | assert(area); |
| 1522 | |
| 1523 | isis_area_dynhostname_set(area, false); |
| 1524 | return CMD_SUCCESS; |
| 1525 | } |
| 1526 | |
Christian Franke | 304c7da | 2016-07-28 17:23:29 +0200 | [diff] [blame] | 1527 | static int area_lsp_mtu_set(struct vty *vty, unsigned int lsp_mtu) |
| 1528 | { |
| 1529 | struct isis_area *area = vty->index; |
| 1530 | struct listnode *node; |
| 1531 | struct isis_circuit *circuit; |
| 1532 | |
| 1533 | if (!area) |
| 1534 | { |
| 1535 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 1536 | return CMD_ERR_NO_MATCH; |
| 1537 | } |
| 1538 | |
| 1539 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) |
| 1540 | { |
| 1541 | if(circuit->state != C_STATE_INIT && circuit->state != C_STATE_UP) |
| 1542 | continue; |
| 1543 | if(lsp_mtu > isis_circuit_pdu_size(circuit)) |
| 1544 | { |
| 1545 | vty_out(vty, "ISIS area contains circuit %s, which has a maximum PDU size of %zu.%s", |
| 1546 | circuit->interface->name, isis_circuit_pdu_size(circuit), |
| 1547 | VTY_NEWLINE); |
| 1548 | return CMD_ERR_AMBIGUOUS; |
| 1549 | } |
| 1550 | } |
| 1551 | |
| 1552 | isis_area_lsp_mtu_set(area, lsp_mtu); |
| 1553 | return CMD_SUCCESS; |
| 1554 | } |
| 1555 | |
| 1556 | DEFUN (area_lsp_mtu, |
| 1557 | area_lsp_mtu_cmd, |
| 1558 | "lsp-mtu <128-4352>", |
| 1559 | "Configure the maximum size of generated LSPs\n" |
| 1560 | "Maximum size of generated LSPs\n") |
| 1561 | { |
| 1562 | unsigned int lsp_mtu; |
| 1563 | |
| 1564 | VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[0], 128, 4352); |
| 1565 | |
| 1566 | return area_lsp_mtu_set(vty, lsp_mtu); |
| 1567 | } |
| 1568 | |
| 1569 | DEFUN(no_area_lsp_mtu, |
| 1570 | no_area_lsp_mtu_cmd, |
| 1571 | "no lsp-mtu", |
| 1572 | NO_STR |
| 1573 | "Configure the maximum size of generated LSPs\n") |
| 1574 | { |
| 1575 | return area_lsp_mtu_set(vty, DEFAULT_LSP_MTU); |
| 1576 | } |
| 1577 | |
| 1578 | ALIAS(no_area_lsp_mtu, |
| 1579 | no_area_lsp_mtu_arg_cmd, |
| 1580 | "no lsp-mtu <128-4352>", |
| 1581 | NO_STR |
| 1582 | "Configure the maximum size of generated LSPs\n" |
| 1583 | "Maximum size of generated LSPs\n"); |
| 1584 | |
| 1585 | DEFUN (is_type, |
| 1586 | is_type_cmd, |
| 1587 | "is-type (level-1|level-1-2|level-2-only)", |
| 1588 | "IS Level for this routing process (OSI only)\n" |
| 1589 | "Act as a station router only\n" |
| 1590 | "Act as both a station router and an area router\n" |
| 1591 | "Act as an area router only\n") |
| 1592 | { |
| 1593 | struct isis_area *area; |
| 1594 | int type; |
| 1595 | |
| 1596 | area = vty->index; |
| 1597 | |
| 1598 | if (!area) |
| 1599 | { |
| 1600 | vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE); |
| 1601 | return CMD_ERR_NO_MATCH; |
| 1602 | } |
| 1603 | |
| 1604 | type = string2circuit_t (argv[0]); |
| 1605 | if (!type) |
| 1606 | { |
| 1607 | vty_out (vty, "Unknown IS level %s", VTY_NEWLINE); |
| 1608 | return CMD_SUCCESS; |
| 1609 | } |
| 1610 | |
| 1611 | isis_area_is_type_set(area, type); |
| 1612 | |
| 1613 | return CMD_SUCCESS; |
| 1614 | } |
| 1615 | |
| 1616 | DEFUN (no_is_type, |
| 1617 | no_is_type_cmd, |
| 1618 | "no is-type (level-1|level-1-2|level-2-only)", |
| 1619 | NO_STR |
| 1620 | "IS Level for this routing process (OSI only)\n" |
| 1621 | "Act as a station router only\n" |
| 1622 | "Act as both a station router and an area router\n" |
| 1623 | "Act as an area router only\n") |
| 1624 | { |
| 1625 | struct isis_area *area; |
| 1626 | int type; |
| 1627 | |
| 1628 | area = vty->index; |
| 1629 | assert (area); |
| 1630 | |
| 1631 | /* |
| 1632 | * Put the is-type back to defaults: |
| 1633 | * - level-1-2 on first area |
| 1634 | * - level-1 for the rest |
| 1635 | */ |
| 1636 | if (listgetdata (listhead (isis->area_list)) == area) |
| 1637 | type = IS_LEVEL_1_AND_2; |
| 1638 | else |
| 1639 | type = IS_LEVEL_1; |
| 1640 | |
| 1641 | isis_area_is_type_set(area, type); |
| 1642 | |
| 1643 | return CMD_SUCCESS; |
| 1644 | } |
| 1645 | |
Christian Franke | 4570ca4 | 2016-07-28 17:23:30 +0200 | [diff] [blame] | 1646 | static int |
| 1647 | set_lsp_gen_interval (struct vty *vty, struct isis_area *area, |
| 1648 | uint16_t interval, int level) |
| 1649 | { |
| 1650 | int lvl; |
| 1651 | |
| 1652 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) |
| 1653 | { |
| 1654 | if (!(lvl & level)) |
| 1655 | continue; |
| 1656 | |
| 1657 | if (interval >= area->lsp_refresh[lvl-1]) |
| 1658 | { |
| 1659 | vty_out (vty, "LSP gen interval %us must be less than " |
| 1660 | "the LSP refresh interval %us%s", |
| 1661 | interval, area->lsp_refresh[lvl-1], VTY_NEWLINE); |
| 1662 | return CMD_ERR_AMBIGUOUS; |
| 1663 | } |
| 1664 | } |
| 1665 | |
| 1666 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) |
| 1667 | { |
| 1668 | if (!(lvl & level)) |
| 1669 | continue; |
| 1670 | area->lsp_gen_interval[lvl-1] = interval; |
| 1671 | } |
| 1672 | |
| 1673 | return CMD_SUCCESS; |
| 1674 | } |
| 1675 | |
| 1676 | DEFUN (lsp_gen_interval, |
| 1677 | lsp_gen_interval_cmd, |
| 1678 | "lsp-gen-interval <1-120>", |
| 1679 | "Minimum interval between regenerating same LSP\n" |
| 1680 | "Minimum interval in seconds\n") |
| 1681 | { |
| 1682 | struct isis_area *area; |
| 1683 | uint16_t interval; |
| 1684 | int level; |
| 1685 | |
| 1686 | area = vty->index; |
| 1687 | interval = atoi (argv[0]); |
| 1688 | level = IS_LEVEL_1 | IS_LEVEL_2; |
| 1689 | return set_lsp_gen_interval (vty, area, interval, level); |
| 1690 | } |
| 1691 | |
| 1692 | DEFUN (no_lsp_gen_interval, |
| 1693 | no_lsp_gen_interval_cmd, |
| 1694 | "no lsp-gen-interval", |
| 1695 | NO_STR |
| 1696 | "Minimum interval between regenerating same LSP\n") |
| 1697 | { |
| 1698 | struct isis_area *area; |
| 1699 | uint16_t interval; |
| 1700 | int level; |
| 1701 | |
| 1702 | area = vty->index; |
| 1703 | interval = DEFAULT_MIN_LSP_GEN_INTERVAL; |
| 1704 | level = IS_LEVEL_1 | IS_LEVEL_2; |
| 1705 | return set_lsp_gen_interval (vty, area, interval, level); |
| 1706 | } |
| 1707 | |
| 1708 | ALIAS (no_lsp_gen_interval, |
| 1709 | no_lsp_gen_interval_arg_cmd, |
| 1710 | "no lsp-gen-interval <1-120>", |
| 1711 | NO_STR |
| 1712 | "Minimum interval between regenerating same LSP\n" |
| 1713 | "Minimum interval in seconds\n") |
| 1714 | |
| 1715 | DEFUN (lsp_gen_interval_l1, |
| 1716 | lsp_gen_interval_l1_cmd, |
| 1717 | "lsp-gen-interval level-1 <1-120>", |
| 1718 | "Minimum interval between regenerating same LSP\n" |
| 1719 | "Set interval for level 1 only\n" |
| 1720 | "Minimum interval in seconds\n") |
| 1721 | { |
| 1722 | struct isis_area *area; |
| 1723 | uint16_t interval; |
| 1724 | int level; |
| 1725 | |
| 1726 | area = vty->index; |
| 1727 | interval = atoi (argv[0]); |
| 1728 | level = IS_LEVEL_1; |
| 1729 | return set_lsp_gen_interval (vty, area, interval, level); |
| 1730 | } |
| 1731 | |
| 1732 | DEFUN (no_lsp_gen_interval_l1, |
| 1733 | no_lsp_gen_interval_l1_cmd, |
| 1734 | "no lsp-gen-interval level-1", |
| 1735 | NO_STR |
| 1736 | "Minimum interval between regenerating same LSP\n" |
| 1737 | "Set interval for level 1 only\n") |
| 1738 | { |
| 1739 | struct isis_area *area; |
| 1740 | uint16_t interval; |
| 1741 | int level; |
| 1742 | |
| 1743 | area = vty->index; |
| 1744 | interval = DEFAULT_MIN_LSP_GEN_INTERVAL; |
| 1745 | level = IS_LEVEL_1; |
| 1746 | return set_lsp_gen_interval (vty, area, interval, level); |
| 1747 | } |
| 1748 | |
| 1749 | ALIAS (no_lsp_gen_interval_l1, |
| 1750 | no_lsp_gen_interval_l1_arg_cmd, |
| 1751 | "no lsp-gen-interval level-1 <1-120>", |
| 1752 | NO_STR |
| 1753 | "Minimum interval between regenerating same LSP\n" |
| 1754 | "Set interval for level 1 only\n" |
| 1755 | "Minimum interval in seconds\n") |
| 1756 | |
| 1757 | DEFUN (lsp_gen_interval_l2, |
| 1758 | lsp_gen_interval_l2_cmd, |
| 1759 | "lsp-gen-interval level-2 <1-120>", |
| 1760 | "Minimum interval between regenerating same LSP\n" |
| 1761 | "Set interval for level 2 only\n" |
| 1762 | "Minimum interval in seconds\n") |
| 1763 | { |
| 1764 | struct isis_area *area; |
| 1765 | uint16_t interval; |
| 1766 | int level; |
| 1767 | |
| 1768 | area = vty->index; |
| 1769 | interval = atoi (argv[0]); |
| 1770 | level = IS_LEVEL_2; |
| 1771 | return set_lsp_gen_interval (vty, area, interval, level); |
| 1772 | } |
| 1773 | |
| 1774 | DEFUN (no_lsp_gen_interval_l2, |
| 1775 | no_lsp_gen_interval_l2_cmd, |
| 1776 | "no lsp-gen-interval level-2", |
| 1777 | NO_STR |
| 1778 | "Minimum interval between regenerating same LSP\n" |
| 1779 | "Set interval for level 2 only\n") |
| 1780 | { |
| 1781 | struct isis_area *area; |
| 1782 | uint16_t interval; |
| 1783 | int level; |
| 1784 | |
| 1785 | area = vty->index; |
| 1786 | interval = DEFAULT_MIN_LSP_GEN_INTERVAL; |
| 1787 | level = IS_LEVEL_2; |
| 1788 | return set_lsp_gen_interval (vty, area, interval, level); |
| 1789 | } |
| 1790 | |
| 1791 | ALIAS (no_lsp_gen_interval_l2, |
| 1792 | no_lsp_gen_interval_l2_arg_cmd, |
| 1793 | "no lsp-gen-interval level-2 <1-120>", |
| 1794 | NO_STR |
| 1795 | "Minimum interval between regenerating same LSP\n" |
| 1796 | "Set interval for level 2 only\n" |
| 1797 | "Minimum interval in seconds\n") |
| 1798 | |
| 1799 | DEFUN (spf_interval, |
| 1800 | spf_interval_cmd, |
| 1801 | "spf-interval <1-120>", |
| 1802 | "Minimum interval between SPF calculations\n" |
| 1803 | "Minimum interval between consecutive SPFs in seconds\n") |
| 1804 | { |
| 1805 | struct isis_area *area; |
| 1806 | u_int16_t interval; |
| 1807 | |
| 1808 | area = vty->index; |
| 1809 | interval = atoi (argv[0]); |
| 1810 | area->min_spf_interval[0] = interval; |
| 1811 | area->min_spf_interval[1] = interval; |
| 1812 | |
| 1813 | return CMD_SUCCESS; |
| 1814 | } |
| 1815 | |
| 1816 | DEFUN (no_spf_interval, |
| 1817 | no_spf_interval_cmd, |
| 1818 | "no spf-interval", |
| 1819 | NO_STR |
| 1820 | "Minimum interval between SPF calculations\n") |
| 1821 | { |
| 1822 | struct isis_area *area; |
| 1823 | |
| 1824 | area = vty->index; |
| 1825 | |
| 1826 | area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL; |
| 1827 | area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL; |
| 1828 | |
| 1829 | return CMD_SUCCESS; |
| 1830 | } |
| 1831 | |
| 1832 | ALIAS (no_spf_interval, |
| 1833 | no_spf_interval_arg_cmd, |
| 1834 | "no spf-interval <1-120>", |
| 1835 | NO_STR |
| 1836 | "Minimum interval between SPF calculations\n" |
| 1837 | "Minimum interval between consecutive SPFs in seconds\n") |
| 1838 | |
| 1839 | DEFUN (spf_interval_l1, |
| 1840 | spf_interval_l1_cmd, |
| 1841 | "spf-interval level-1 <1-120>", |
| 1842 | "Minimum interval between SPF calculations\n" |
| 1843 | "Set interval for level 1 only\n" |
| 1844 | "Minimum interval between consecutive SPFs in seconds\n") |
| 1845 | { |
| 1846 | struct isis_area *area; |
| 1847 | u_int16_t interval; |
| 1848 | |
| 1849 | area = vty->index; |
| 1850 | interval = atoi (argv[0]); |
| 1851 | area->min_spf_interval[0] = interval; |
| 1852 | |
| 1853 | return CMD_SUCCESS; |
| 1854 | } |
| 1855 | |
| 1856 | DEFUN (no_spf_interval_l1, |
| 1857 | no_spf_interval_l1_cmd, |
| 1858 | "no spf-interval level-1", |
| 1859 | NO_STR |
| 1860 | "Minimum interval between SPF calculations\n" |
| 1861 | "Set interval for level 1 only\n") |
| 1862 | { |
| 1863 | struct isis_area *area; |
| 1864 | |
| 1865 | area = vty->index; |
| 1866 | |
| 1867 | area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL; |
| 1868 | |
| 1869 | return CMD_SUCCESS; |
| 1870 | } |
| 1871 | |
| 1872 | ALIAS (no_spf_interval, |
| 1873 | no_spf_interval_l1_arg_cmd, |
| 1874 | "no spf-interval level-1 <1-120>", |
| 1875 | NO_STR |
| 1876 | "Minimum interval between SPF calculations\n" |
| 1877 | "Set interval for level 1 only\n" |
| 1878 | "Minimum interval between consecutive SPFs in seconds\n") |
| 1879 | |
| 1880 | DEFUN (spf_interval_l2, |
| 1881 | spf_interval_l2_cmd, |
| 1882 | "spf-interval level-2 <1-120>", |
| 1883 | "Minimum interval between SPF calculations\n" |
| 1884 | "Set interval for level 2 only\n" |
| 1885 | "Minimum interval between consecutive SPFs in seconds\n") |
| 1886 | { |
| 1887 | struct isis_area *area; |
| 1888 | u_int16_t interval; |
| 1889 | |
| 1890 | area = vty->index; |
| 1891 | interval = atoi (argv[0]); |
| 1892 | area->min_spf_interval[1] = interval; |
| 1893 | |
| 1894 | return CMD_SUCCESS; |
| 1895 | } |
| 1896 | |
| 1897 | DEFUN (no_spf_interval_l2, |
| 1898 | no_spf_interval_l2_cmd, |
| 1899 | "no spf-interval level-2", |
| 1900 | NO_STR |
| 1901 | "Minimum interval between SPF calculations\n" |
| 1902 | "Set interval for level 2 only\n") |
| 1903 | { |
| 1904 | struct isis_area *area; |
| 1905 | |
| 1906 | area = vty->index; |
| 1907 | |
| 1908 | area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL; |
| 1909 | |
| 1910 | return CMD_SUCCESS; |
| 1911 | } |
| 1912 | |
| 1913 | ALIAS (no_spf_interval, |
| 1914 | no_spf_interval_l2_arg_cmd, |
| 1915 | "no spf-interval level-2 <1-120>", |
| 1916 | NO_STR |
| 1917 | "Minimum interval between SPF calculations\n" |
| 1918 | "Set interval for level 2 only\n" |
| 1919 | "Minimum interval between consecutive SPFs in seconds\n") |
| 1920 | |
| 1921 | static int |
| 1922 | area_max_lsp_lifetime_set(struct vty *vty, int level, |
| 1923 | uint16_t interval) |
| 1924 | { |
| 1925 | struct isis_area *area = vty->index; |
| 1926 | int lvl; |
| 1927 | uint16_t refresh_interval = interval - 300; |
| 1928 | int set_refresh_interval[ISIS_LEVELS] = {0, 0}; |
| 1929 | |
| 1930 | if (!area) |
| 1931 | { |
| 1932 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 1933 | return CMD_ERR_NO_MATCH; |
| 1934 | } |
| 1935 | |
| 1936 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++) |
| 1937 | { |
| 1938 | if (!(lvl & level)) |
| 1939 | continue; |
| 1940 | |
| 1941 | if (refresh_interval < area->lsp_refresh[lvl-1]) |
| 1942 | { |
| 1943 | vty_out (vty, "Level %d Max LSP lifetime %us must be 300s greater than " |
| 1944 | "the configured LSP refresh interval %us%s", |
| 1945 | lvl, interval, area->lsp_refresh[lvl-1], VTY_NEWLINE); |
| 1946 | vty_out (vty, "Automatically reducing level %d LSP refresh interval " |
| 1947 | "to %us%s", lvl, refresh_interval, VTY_NEWLINE); |
| 1948 | set_refresh_interval[lvl-1] = 1; |
| 1949 | |
| 1950 | if (refresh_interval <= area->lsp_gen_interval[lvl-1]) |
| 1951 | { |
| 1952 | vty_out (vty, "LSP refresh interval %us must be greater than " |
| 1953 | "the configured LSP gen interval %us%s", |
| 1954 | refresh_interval, area->lsp_gen_interval[lvl-1], |
| 1955 | VTY_NEWLINE); |
| 1956 | return CMD_ERR_AMBIGUOUS; |
| 1957 | } |
| 1958 | } |
| 1959 | } |
| 1960 | |
| 1961 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++) |
| 1962 | { |
| 1963 | if (!(lvl & level)) |
| 1964 | continue; |
| 1965 | isis_area_max_lsp_lifetime_set(area, lvl, interval); |
| 1966 | if (set_refresh_interval[lvl-1]) |
| 1967 | isis_area_lsp_refresh_set(area, lvl, refresh_interval); |
| 1968 | } |
| 1969 | |
| 1970 | return CMD_SUCCESS; |
| 1971 | } |
| 1972 | |
| 1973 | DEFUN (max_lsp_lifetime, |
| 1974 | max_lsp_lifetime_cmd, |
| 1975 | "max-lsp-lifetime <350-65535>", |
| 1976 | "Maximum LSP lifetime\n" |
| 1977 | "LSP lifetime in seconds\n") |
| 1978 | { |
| 1979 | return area_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, atoi(argv[0])); |
| 1980 | } |
| 1981 | |
| 1982 | DEFUN (no_max_lsp_lifetime, |
| 1983 | no_max_lsp_lifetime_cmd, |
| 1984 | "no max-lsp-lifetime", |
| 1985 | NO_STR |
| 1986 | "LSP lifetime in seconds\n") |
| 1987 | { |
| 1988 | return area_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, |
| 1989 | DEFAULT_LSP_LIFETIME); |
| 1990 | } |
| 1991 | |
| 1992 | ALIAS (no_max_lsp_lifetime, |
| 1993 | no_max_lsp_lifetime_arg_cmd, |
| 1994 | "no max-lsp-lifetime <350-65535>", |
| 1995 | NO_STR |
| 1996 | "Maximum LSP lifetime\n" |
| 1997 | "LSP lifetime in seconds\n") |
| 1998 | |
| 1999 | DEFUN (max_lsp_lifetime_l1, |
| 2000 | max_lsp_lifetime_l1_cmd, |
| 2001 | "max-lsp-lifetime level-1 <350-65535>", |
| 2002 | "Maximum LSP lifetime for Level 1 only\n" |
| 2003 | "LSP lifetime for Level 1 only in seconds\n") |
| 2004 | { |
| 2005 | return area_max_lsp_lifetime_set(vty, IS_LEVEL_1, atoi(argv[0])); |
| 2006 | } |
| 2007 | |
| 2008 | DEFUN (no_max_lsp_lifetime_l1, |
| 2009 | no_max_lsp_lifetime_l1_cmd, |
| 2010 | "no max-lsp-lifetime level-1", |
| 2011 | NO_STR |
| 2012 | "LSP lifetime for Level 1 only in seconds\n") |
| 2013 | { |
| 2014 | return area_max_lsp_lifetime_set(vty, IS_LEVEL_1, DEFAULT_LSP_LIFETIME); |
| 2015 | } |
| 2016 | |
| 2017 | ALIAS (no_max_lsp_lifetime_l1, |
| 2018 | no_max_lsp_lifetime_l1_arg_cmd, |
| 2019 | "no max-lsp-lifetime level-1 <350-65535>", |
| 2020 | NO_STR |
| 2021 | "Maximum LSP lifetime for Level 1 only\n" |
| 2022 | "LSP lifetime for Level 1 only in seconds\n") |
| 2023 | |
| 2024 | DEFUN (max_lsp_lifetime_l2, |
| 2025 | max_lsp_lifetime_l2_cmd, |
| 2026 | "max-lsp-lifetime level-2 <350-65535>", |
| 2027 | "Maximum LSP lifetime for Level 2 only\n" |
| 2028 | "LSP lifetime for Level 2 only in seconds\n") |
| 2029 | { |
| 2030 | return area_max_lsp_lifetime_set(vty, IS_LEVEL_2, atoi(argv[0])); |
| 2031 | } |
| 2032 | |
| 2033 | DEFUN (no_max_lsp_lifetime_l2, |
| 2034 | no_max_lsp_lifetime_l2_cmd, |
| 2035 | "no max-lsp-lifetime level-2", |
| 2036 | NO_STR |
| 2037 | "LSP lifetime for Level 2 only in seconds\n") |
| 2038 | { |
| 2039 | return area_max_lsp_lifetime_set(vty, IS_LEVEL_2, DEFAULT_LSP_LIFETIME); |
| 2040 | } |
| 2041 | |
| 2042 | ALIAS (no_max_lsp_lifetime_l2, |
| 2043 | no_max_lsp_lifetime_l2_arg_cmd, |
| 2044 | "no max-lsp-lifetime level-2 <350-65535>", |
| 2045 | NO_STR |
| 2046 | "Maximum LSP lifetime for Level 2 only\n" |
| 2047 | "LSP lifetime for Level 2 only in seconds\n") |
| 2048 | |
| 2049 | static int |
| 2050 | area_lsp_refresh_interval_set(struct vty *vty, int level, uint16_t interval) |
| 2051 | { |
| 2052 | struct isis_area *area = vty->index; |
| 2053 | int lvl; |
| 2054 | |
| 2055 | if (!area) |
| 2056 | { |
| 2057 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 2058 | return CMD_ERR_NO_MATCH; |
| 2059 | } |
| 2060 | |
| 2061 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) |
| 2062 | { |
| 2063 | if (!(lvl & level)) |
| 2064 | continue; |
| 2065 | if (interval <= area->lsp_gen_interval[lvl-1]) |
| 2066 | { |
| 2067 | vty_out (vty, "LSP refresh interval %us must be greater than " |
| 2068 | "the configured LSP gen interval %us%s", |
| 2069 | interval, area->lsp_gen_interval[lvl-1], |
| 2070 | VTY_NEWLINE); |
| 2071 | return CMD_ERR_AMBIGUOUS; |
| 2072 | } |
| 2073 | if (interval > (area->max_lsp_lifetime[lvl-1] - 300)) |
| 2074 | { |
| 2075 | vty_out (vty, "LSP refresh interval %us must be less than " |
| 2076 | "the configured LSP lifetime %us less 300%s", |
| 2077 | interval, area->max_lsp_lifetime[lvl-1], |
| 2078 | VTY_NEWLINE); |
| 2079 | return CMD_ERR_AMBIGUOUS; |
| 2080 | } |
| 2081 | } |
| 2082 | |
| 2083 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) |
| 2084 | { |
| 2085 | if (!(lvl & level)) |
| 2086 | continue; |
| 2087 | isis_area_lsp_refresh_set(area, lvl, interval); |
| 2088 | } |
| 2089 | |
| 2090 | return CMD_SUCCESS; |
| 2091 | } |
| 2092 | |
| 2093 | DEFUN (lsp_refresh_interval, |
| 2094 | lsp_refresh_interval_cmd, |
| 2095 | "lsp-refresh-interval <1-65235>", |
| 2096 | "LSP refresh interval\n" |
| 2097 | "LSP refresh interval in seconds\n") |
| 2098 | { |
| 2099 | return area_lsp_refresh_interval_set(vty, IS_LEVEL_1_AND_2, atoi(argv[0])); |
| 2100 | } |
| 2101 | |
| 2102 | DEFUN (no_lsp_refresh_interval, |
| 2103 | no_lsp_refresh_interval_cmd, |
| 2104 | "no lsp-refresh-interval", |
| 2105 | NO_STR |
| 2106 | "LSP refresh interval in seconds\n") |
| 2107 | { |
| 2108 | return area_lsp_refresh_interval_set(vty, IS_LEVEL_1_AND_2, |
| 2109 | DEFAULT_MAX_LSP_GEN_INTERVAL); |
| 2110 | } |
| 2111 | |
| 2112 | ALIAS (no_lsp_refresh_interval, |
| 2113 | no_lsp_refresh_interval_arg_cmd, |
| 2114 | "no lsp-refresh-interval <1-65235>", |
| 2115 | NO_STR |
| 2116 | "LSP refresh interval\n" |
| 2117 | "LSP refresh interval in seconds\n") |
| 2118 | |
| 2119 | DEFUN (lsp_refresh_interval_l1, |
| 2120 | lsp_refresh_interval_l1_cmd, |
| 2121 | "lsp-refresh-interval level-1 <1-65235>", |
| 2122 | "LSP refresh interval for Level 1 only\n" |
| 2123 | "LSP refresh interval for Level 1 only in seconds\n") |
| 2124 | { |
| 2125 | return area_lsp_refresh_interval_set(vty, IS_LEVEL_1, atoi(argv[0])); |
| 2126 | } |
| 2127 | |
| 2128 | DEFUN (no_lsp_refresh_interval_l1, |
| 2129 | no_lsp_refresh_interval_l1_cmd, |
| 2130 | "no lsp-refresh-interval level-1", |
| 2131 | NO_STR |
| 2132 | "LSP refresh interval for Level 1 only in seconds\n") |
| 2133 | { |
| 2134 | return area_lsp_refresh_interval_set(vty, IS_LEVEL_1, |
| 2135 | DEFAULT_MAX_LSP_GEN_INTERVAL); |
| 2136 | } |
| 2137 | |
| 2138 | ALIAS (no_lsp_refresh_interval_l1, |
| 2139 | no_lsp_refresh_interval_l1_arg_cmd, |
| 2140 | "no lsp-refresh-interval level-1 <1-65235>", |
| 2141 | NO_STR |
| 2142 | "LSP refresh interval for Level 1 only\n" |
| 2143 | "LSP refresh interval for Level 1 only in seconds\n") |
| 2144 | |
| 2145 | DEFUN (lsp_refresh_interval_l2, |
| 2146 | lsp_refresh_interval_l2_cmd, |
| 2147 | "lsp-refresh-interval level-2 <1-65235>", |
| 2148 | "LSP refresh interval for Level 2 only\n" |
| 2149 | "LSP refresh interval for Level 2 only in seconds\n") |
| 2150 | { |
| 2151 | return area_lsp_refresh_interval_set(vty, IS_LEVEL_2, atoi(argv[0])); |
| 2152 | } |
| 2153 | |
| 2154 | DEFUN (no_lsp_refresh_interval_l2, |
| 2155 | no_lsp_refresh_interval_l2_cmd, |
| 2156 | "no lsp-refresh-interval level-2", |
| 2157 | NO_STR |
| 2158 | "LSP refresh interval for Level 2 only in seconds\n") |
| 2159 | { |
| 2160 | return area_lsp_refresh_interval_set(vty, IS_LEVEL_2, |
| 2161 | DEFAULT_MAX_LSP_GEN_INTERVAL); |
| 2162 | } |
| 2163 | |
| 2164 | ALIAS (no_lsp_refresh_interval_l2, |
| 2165 | no_lsp_refresh_interval_l2_arg_cmd, |
| 2166 | "no lsp-refresh-interval level-2 <1-65235>", |
| 2167 | NO_STR |
| 2168 | "LSP refresh interval for Level 2 only\n" |
| 2169 | "LSP refresh interval for Level 2 only in seconds\n") |
| 2170 | |
Christian Franke | 68845c1 | 2016-07-28 17:23:31 +0200 | [diff] [blame] | 2171 | static int |
| 2172 | area_passwd_set(struct vty *vty, int level, |
| 2173 | int (*type_set)(struct isis_area *area, int level, |
| 2174 | const char *passwd, u_char snp_auth), |
| 2175 | const char *passwd, u_char snp_auth) |
| 2176 | { |
| 2177 | struct isis_area *area = vty->index; |
| 2178 | |
| 2179 | if (!area) |
| 2180 | { |
| 2181 | vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE); |
| 2182 | return CMD_ERR_NO_MATCH; |
| 2183 | } |
| 2184 | |
| 2185 | if (passwd && strlen(passwd) > 254) |
| 2186 | { |
| 2187 | vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE); |
| 2188 | return CMD_ERR_AMBIGUOUS; |
| 2189 | } |
| 2190 | |
| 2191 | type_set(area, level, passwd, snp_auth); |
| 2192 | return CMD_SUCCESS; |
| 2193 | } |
| 2194 | |
| 2195 | DEFUN (area_passwd_md5, |
| 2196 | area_passwd_md5_cmd, |
| 2197 | "(area-password|domain-password) md5 WORD", |
| 2198 | "Configure the authentication password for an area\n" |
| 2199 | "Set the authentication password for a routing domain\n" |
| 2200 | "Authentication type\n" |
| 2201 | "Level-wide password\n") |
| 2202 | { |
| 2203 | u_char snp_auth = 0; |
| 2204 | int level = (argv[0][0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; |
| 2205 | |
| 2206 | if (argc > 2) |
| 2207 | { |
| 2208 | snp_auth = SNP_AUTH_SEND; |
| 2209 | if (strncmp(argv[2], "v", 1) == 0) |
| 2210 | snp_auth |= SNP_AUTH_RECV; |
| 2211 | } |
| 2212 | |
| 2213 | return area_passwd_set(vty, level, isis_area_passwd_hmac_md5_set, |
| 2214 | argv[1], snp_auth); |
| 2215 | } |
| 2216 | |
| 2217 | ALIAS (area_passwd_md5, |
| 2218 | area_passwd_md5_snpauth_cmd, |
| 2219 | "(area-password|domain-password) md5 WORD authenticate snp (send-only|validate)", |
| 2220 | "Configure the authentication password for an area\n" |
| 2221 | "Set the authentication password for a routing domain\n" |
| 2222 | "Authentication type\n" |
| 2223 | "Level-wide password\n" |
| 2224 | "Authentication\n" |
| 2225 | "SNP PDUs\n" |
| 2226 | "Send but do not check PDUs on receiving\n" |
| 2227 | "Send and check PDUs on receiving\n") |
| 2228 | |
| 2229 | DEFUN (area_passwd_clear, |
| 2230 | area_passwd_clear_cmd, |
| 2231 | "(area-password|domain-password) clear WORD", |
| 2232 | "Configure the authentication password for an area\n" |
| 2233 | "Set the authentication password for a routing domain\n" |
| 2234 | "Authentication type\n" |
| 2235 | "Area password\n") |
| 2236 | { |
| 2237 | u_char snp_auth = 0; |
| 2238 | int level = (argv[0][0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; |
| 2239 | |
| 2240 | if (argc > 2) |
| 2241 | { |
| 2242 | snp_auth = SNP_AUTH_SEND; |
| 2243 | if (strncmp(argv[2], "v", 1) == 0) |
| 2244 | snp_auth |= SNP_AUTH_RECV; |
| 2245 | } |
| 2246 | |
| 2247 | return area_passwd_set(vty, level, isis_area_passwd_cleartext_set, |
| 2248 | argv[1], snp_auth); |
| 2249 | } |
| 2250 | |
| 2251 | ALIAS (area_passwd_clear, |
| 2252 | area_passwd_clear_snpauth_cmd, |
| 2253 | "(area-password|domain-password) clear WORD authenticate snp (send-only|validate)", |
| 2254 | "Configure the authentication password for an area\n" |
| 2255 | "Set the authentication password for a routing domain\n" |
| 2256 | "Authentication type\n" |
| 2257 | "Area password\n" |
| 2258 | "Authentication\n" |
| 2259 | "SNP PDUs\n" |
| 2260 | "Send but do not check PDUs on receiving\n" |
| 2261 | "Send and check PDUs on receiving\n") |
| 2262 | |
| 2263 | DEFUN (no_area_passwd, |
| 2264 | no_area_passwd_cmd, |
| 2265 | "no (area-password|domain-password)", |
| 2266 | NO_STR |
| 2267 | "Configure the authentication password for an area\n" |
| 2268 | "Set the authentication password for a routing domain\n") |
| 2269 | { |
| 2270 | int level = (argv[0][0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; |
| 2271 | struct isis_area *area = vty->index; |
| 2272 | |
| 2273 | if (!area) |
| 2274 | { |
| 2275 | vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE); |
| 2276 | return CMD_ERR_NO_MATCH; |
| 2277 | } |
| 2278 | |
| 2279 | return isis_area_passwd_unset (area, level); |
| 2280 | } |
| 2281 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 2282 | void |
| 2283 | isis_vty_init (void) |
| 2284 | { |
| 2285 | install_element (INTERFACE_NODE, &ip_router_isis_cmd); |
| 2286 | install_element (INTERFACE_NODE, &no_ip_router_isis_cmd); |
| 2287 | |
| 2288 | install_element (INTERFACE_NODE, &isis_passive_cmd); |
| 2289 | install_element (INTERFACE_NODE, &no_isis_passive_cmd); |
| 2290 | |
| 2291 | install_element (INTERFACE_NODE, &isis_circuit_type_cmd); |
| 2292 | install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd); |
| 2293 | |
| 2294 | install_element (INTERFACE_NODE, &isis_network_cmd); |
| 2295 | install_element (INTERFACE_NODE, &no_isis_network_cmd); |
| 2296 | |
Christian Franke | f5fbfb2 | 2016-07-28 17:23:27 +0200 | [diff] [blame] | 2297 | install_element (INTERFACE_NODE, &isis_passwd_cmd); |
| 2298 | install_element (INTERFACE_NODE, &no_isis_passwd_cmd); |
| 2299 | install_element (INTERFACE_NODE, &no_isis_passwd_arg_cmd); |
| 2300 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 2301 | install_element (INTERFACE_NODE, &isis_priority_cmd); |
| 2302 | install_element (INTERFACE_NODE, &no_isis_priority_cmd); |
| 2303 | install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd); |
| 2304 | install_element (INTERFACE_NODE, &isis_priority_l1_cmd); |
| 2305 | install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd); |
| 2306 | install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd); |
| 2307 | install_element (INTERFACE_NODE, &isis_priority_l2_cmd); |
| 2308 | install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd); |
| 2309 | install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd); |
| 2310 | |
| 2311 | install_element (INTERFACE_NODE, &isis_metric_cmd); |
| 2312 | install_element (INTERFACE_NODE, &no_isis_metric_cmd); |
| 2313 | install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd); |
| 2314 | install_element (INTERFACE_NODE, &isis_metric_l1_cmd); |
| 2315 | install_element (INTERFACE_NODE, &no_isis_metric_l1_cmd); |
| 2316 | install_element (INTERFACE_NODE, &no_isis_metric_l1_arg_cmd); |
| 2317 | install_element (INTERFACE_NODE, &isis_metric_l2_cmd); |
| 2318 | install_element (INTERFACE_NODE, &no_isis_metric_l2_cmd); |
| 2319 | install_element (INTERFACE_NODE, &no_isis_metric_l2_arg_cmd); |
Christian Franke | ccd485d | 2016-07-28 17:23:26 +0200 | [diff] [blame] | 2320 | |
David Lamparter | b5d2f5f | 2016-07-28 17:23:28 +0200 | [diff] [blame] | 2321 | install_element (INTERFACE_NODE, &isis_hello_interval_cmd); |
| 2322 | install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd); |
| 2323 | install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd); |
| 2324 | install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd); |
| 2325 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd); |
| 2326 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd); |
| 2327 | install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd); |
| 2328 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd); |
| 2329 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd); |
| 2330 | |
| 2331 | install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd); |
| 2332 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd); |
| 2333 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd); |
| 2334 | install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd); |
| 2335 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd); |
| 2336 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd); |
| 2337 | install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd); |
| 2338 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd); |
| 2339 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd); |
| 2340 | |
| 2341 | install_element (INTERFACE_NODE, &isis_hello_padding_cmd); |
| 2342 | install_element (INTERFACE_NODE, &no_isis_hello_padding_cmd); |
| 2343 | |
| 2344 | install_element (INTERFACE_NODE, &csnp_interval_cmd); |
| 2345 | install_element (INTERFACE_NODE, &no_csnp_interval_cmd); |
| 2346 | install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd); |
| 2347 | install_element (INTERFACE_NODE, &csnp_interval_l1_cmd); |
| 2348 | install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd); |
| 2349 | install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd); |
| 2350 | install_element (INTERFACE_NODE, &csnp_interval_l2_cmd); |
| 2351 | install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd); |
| 2352 | install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd); |
| 2353 | |
| 2354 | install_element (INTERFACE_NODE, &psnp_interval_cmd); |
| 2355 | install_element (INTERFACE_NODE, &no_psnp_interval_cmd); |
| 2356 | install_element (INTERFACE_NODE, &no_psnp_interval_arg_cmd); |
| 2357 | install_element (INTERFACE_NODE, &psnp_interval_l1_cmd); |
| 2358 | install_element (INTERFACE_NODE, &no_psnp_interval_l1_cmd); |
| 2359 | install_element (INTERFACE_NODE, &no_psnp_interval_l1_arg_cmd); |
| 2360 | install_element (INTERFACE_NODE, &psnp_interval_l2_cmd); |
| 2361 | install_element (INTERFACE_NODE, &no_psnp_interval_l2_cmd); |
| 2362 | install_element (INTERFACE_NODE, &no_psnp_interval_l2_arg_cmd); |
| 2363 | |
Christian Franke | ccd485d | 2016-07-28 17:23:26 +0200 | [diff] [blame] | 2364 | install_element (ISIS_NODE, &metric_style_cmd); |
| 2365 | install_element (ISIS_NODE, &no_metric_style_cmd); |
| 2366 | |
| 2367 | install_element (ISIS_NODE, &set_overload_bit_cmd); |
| 2368 | install_element (ISIS_NODE, &no_set_overload_bit_cmd); |
| 2369 | |
| 2370 | install_element (ISIS_NODE, &set_attached_bit_cmd); |
| 2371 | install_element (ISIS_NODE, &no_set_attached_bit_cmd); |
| 2372 | |
| 2373 | install_element (ISIS_NODE, &dynamic_hostname_cmd); |
| 2374 | install_element (ISIS_NODE, &no_dynamic_hostname_cmd); |
Christian Franke | 304c7da | 2016-07-28 17:23:29 +0200 | [diff] [blame] | 2375 | |
| 2376 | install_element (ISIS_NODE, &area_lsp_mtu_cmd); |
| 2377 | install_element (ISIS_NODE, &no_area_lsp_mtu_cmd); |
| 2378 | install_element (ISIS_NODE, &no_area_lsp_mtu_arg_cmd); |
| 2379 | |
| 2380 | install_element (ISIS_NODE, &is_type_cmd); |
| 2381 | install_element (ISIS_NODE, &no_is_type_cmd); |
Christian Franke | 4570ca4 | 2016-07-28 17:23:30 +0200 | [diff] [blame] | 2382 | |
| 2383 | install_element (ISIS_NODE, &lsp_gen_interval_cmd); |
| 2384 | install_element (ISIS_NODE, &no_lsp_gen_interval_cmd); |
| 2385 | install_element (ISIS_NODE, &no_lsp_gen_interval_arg_cmd); |
| 2386 | install_element (ISIS_NODE, &lsp_gen_interval_l1_cmd); |
| 2387 | install_element (ISIS_NODE, &no_lsp_gen_interval_l1_cmd); |
| 2388 | install_element (ISIS_NODE, &no_lsp_gen_interval_l1_arg_cmd); |
| 2389 | install_element (ISIS_NODE, &lsp_gen_interval_l2_cmd); |
| 2390 | install_element (ISIS_NODE, &no_lsp_gen_interval_l2_cmd); |
| 2391 | install_element (ISIS_NODE, &no_lsp_gen_interval_l2_arg_cmd); |
| 2392 | |
| 2393 | install_element (ISIS_NODE, &spf_interval_cmd); |
| 2394 | install_element (ISIS_NODE, &no_spf_interval_cmd); |
| 2395 | install_element (ISIS_NODE, &no_spf_interval_arg_cmd); |
| 2396 | install_element (ISIS_NODE, &spf_interval_l1_cmd); |
| 2397 | install_element (ISIS_NODE, &no_spf_interval_l1_cmd); |
| 2398 | install_element (ISIS_NODE, &no_spf_interval_l1_arg_cmd); |
| 2399 | install_element (ISIS_NODE, &spf_interval_l2_cmd); |
| 2400 | install_element (ISIS_NODE, &no_spf_interval_l2_cmd); |
| 2401 | install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd); |
| 2402 | |
| 2403 | install_element (ISIS_NODE, &max_lsp_lifetime_cmd); |
| 2404 | install_element (ISIS_NODE, &no_max_lsp_lifetime_cmd); |
| 2405 | install_element (ISIS_NODE, &no_max_lsp_lifetime_arg_cmd); |
| 2406 | install_element (ISIS_NODE, &max_lsp_lifetime_l1_cmd); |
| 2407 | install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_cmd); |
| 2408 | install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_arg_cmd); |
| 2409 | install_element (ISIS_NODE, &max_lsp_lifetime_l2_cmd); |
| 2410 | install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_cmd); |
| 2411 | install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_arg_cmd); |
| 2412 | |
| 2413 | install_element (ISIS_NODE, &lsp_refresh_interval_cmd); |
| 2414 | install_element (ISIS_NODE, &no_lsp_refresh_interval_cmd); |
| 2415 | install_element (ISIS_NODE, &no_lsp_refresh_interval_arg_cmd); |
| 2416 | install_element (ISIS_NODE, &lsp_refresh_interval_l1_cmd); |
| 2417 | install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_cmd); |
| 2418 | install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_arg_cmd); |
| 2419 | install_element (ISIS_NODE, &lsp_refresh_interval_l2_cmd); |
| 2420 | install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_cmd); |
| 2421 | install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_arg_cmd); |
Christian Franke | 68845c1 | 2016-07-28 17:23:31 +0200 | [diff] [blame] | 2422 | |
| 2423 | install_element (ISIS_NODE, &area_passwd_md5_cmd); |
| 2424 | install_element (ISIS_NODE, &area_passwd_md5_snpauth_cmd); |
| 2425 | install_element (ISIS_NODE, &area_passwd_clear_cmd); |
| 2426 | install_element (ISIS_NODE, &area_passwd_clear_snpauth_cmd); |
| 2427 | install_element (ISIS_NODE, &no_area_passwd_cmd); |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 2428 | } |