1/* OSPF VTY interface. 2 * Copyright (C) 2000 Toshiaki Takada 3 * 4 * This file is part of GNU Zebra. 5 * 6 * GNU Zebra is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License as published by the 8 * Free Software Foundation; either version 2, or (at your option) any 9 * later version. 10 * 11 * GNU Zebra is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with GNU Zebra; see the file COPYING. If not, write to the Free 18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 * 02111-1307, USA. 20 */ 21 22#include <zebra.h> 23 24#include "memory.h" 25#include "thread.h" 26#include "prefix.h" 27#include "table.h" 28#include "vty.h" 29#include "command.h" 30#include "plist.h" 31#include "log.h" 32#include "zclient.h" 33 34#include "ospfd/ospfd.h" 35#include "ospfd/ospf_asbr.h" 36#include "ospfd/ospf_lsa.h" 37#include "ospfd/ospf_lsdb.h" 38#include "ospfd/ospf_ism.h" 39#include "ospfd/ospf_interface.h" 40#include "ospfd/ospf_nsm.h" 41#include "ospfd/ospf_neighbor.h" 42#include "ospfd/ospf_flood.h" 43#include "ospfd/ospf_abr.h" 44#include "ospfd/ospf_spf.h" 45#include "ospfd/ospf_route.h" 46#include "ospfd/ospf_zebra.h" 47/*#include "ospfd/ospf_routemap.h" */ 48#include "ospfd/ospf_vty.h" 49#include "ospfd/ospf_dump.h" 50 51 52static char *ospf_network_type_str[] = 53{ 54 "Null", 55 "POINTOPOINT", 56 "BROADCAST", 57 "NBMA", 58 "POINTOMULTIPOINT", 59 "VIRTUALLINK", 60 "LOOPBACK" 61}; 62 63 64/* Utility functions. */ 65int 66ospf_str2area_id (char *str, struct in_addr *area_id, int *format) 67{ 68 char *endptr = NULL; 69 unsigned long ret; 70 71 /* match "A.B.C.D". */ 72 if (strchr (str, '.') != NULL) 73 { 74 ret = inet_aton (str, area_id); 75 if (!ret) 76 return -1; 77 *format = OSPF_AREA_ID_FORMAT_ADDRESS; 78 } 79 /* match "<0-4294967295>". */ 80 else 81 { 82 ret = strtoul (str, &endptr, 10); 83 if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE)) 84 return -1; 85 86 area_id->s_addr = htonl (ret); 87 *format = OSPF_AREA_ID_FORMAT_DECIMAL; 88 } 89 90 return 0; 91} 92 93 94int 95str2distribute_source (char *str, int *source) 96{ 97 /* Sanity check. */ 98 if (str == NULL) 99 return 0; 100 101 if (strncmp (str, "k", 1) == 0) 102 *source = ZEBRA_ROUTE_KERNEL; 103 else if (strncmp (str, "c", 1) == 0) 104 *source = ZEBRA_ROUTE_CONNECT; 105 else if (strncmp (str, "s", 1) == 0) 106 *source = ZEBRA_ROUTE_STATIC; 107 else if (strncmp (str, "r", 1) == 0) 108 *source = ZEBRA_ROUTE_RIP; 109 else if (strncmp (str, "b", 1) == 0) 110 *source = ZEBRA_ROUTE_BGP; 111 else 112 return 0; 113 114 return 1; 115} 116 117int 118str2metric (char *str, int *metric) 119{ 120 /* Sanity check. */ 121 if (str == NULL) 122 return 0; 123 124 *metric = strtol (str, NULL, 10); 125 if (*metric < 0 && *metric > 16777214) 126 { 127 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ 128 return 0; 129 } 130 131 return 1; 132} 133 134int 135str2metric_type (char *str, int *metric_type) 136{ 137 /* Sanity check. */ 138 if (str == NULL) 139 return 0; 140 141 if (strncmp (str, "1", 1) == 0) 142 *metric_type = EXTERNAL_METRIC_TYPE_1; 143 else if (strncmp (str, "2", 1) == 0) 144 *metric_type = EXTERNAL_METRIC_TYPE_2; 145 else 146 return 0; 147 148 return 1; 149} 150 151int 152ospf_oi_count (struct interface *ifp) 153{ 154 struct route_node *rn; 155 int i = 0; 156 157 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) 158 if (rn->info) 159 i++; 160 161 return i; 162} 163 164 165DEFUN (router_ospf, 166 router_ospf_cmd, 167 "router ospf", 168 "Enable a routing process\n" 169 "Start OSPF configuration\n") 170{ 171 vty->node = OSPF_NODE; 172 vty->index = ospf_get (); 173 174 return CMD_SUCCESS; 175} 176 177DEFUN (no_router_ospf, 178 no_router_ospf_cmd, 179 "no router ospf", 180 NO_STR 181 "Enable a routing process\n" 182 "Start OSPF configuration\n") 183{ 184 if (ospf_top == NULL) 185 { 186 vty_out (vty, "There isn't active ospf instance.%s", VTY_NEWLINE); 187 return CMD_WARNING; 188 } 189 190 ospf_finish (ospf_top); 191 192 return CMD_SUCCESS; 193} 194 195DEFUN (ospf_router_id, 196 ospf_router_id_cmd, 197 "ospf router-id A.B.C.D", 198 "OSPF specific commands\n" 199 "router-id for the OSPF process\n" 200 "OSPF router-id in IP address format\n") 201{ 202 int ret; 203 struct in_addr router_id; 204 205 ret = inet_aton (argv[0], &router_id); 206 if (!ret) 207 { 208 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); 209 return CMD_WARNING; 210 } 211 212 /* ospf_top->router_id = router_id; */ 213 ospf_top->router_id_static = router_id; 214 215 if (ospf_top->t_router_id_update == NULL) 216 ospf_top->t_router_id_update = 217 thread_add_timer (master, ospf_router_id_update_timer, NULL, 218 OSPF_ROUTER_ID_UPDATE_DELAY); 219 220 return CMD_SUCCESS; 221} 222 223ALIAS (ospf_router_id, 224 router_id_cmd, 225 "router-id A.B.C.D", 226 "router-id for the OSPF process\n" 227 "OSPF router-id in IP address format\n") 228 229DEFUN (no_ospf_router_id, 230 no_ospf_router_id_cmd, 231 "no ospf router-id", 232 NO_STR 233 "OSPF specific commands\n" 234 "router-id for the OSPF process\n") 235{ 236 ospf_top->router_id_static.s_addr = 0; 237 238 ospf_router_id_update (); 239 240 return CMD_SUCCESS; 241} 242 243ALIAS (no_ospf_router_id, 244 no_router_id_cmd, 245 "no router-id", 246 NO_STR 247 "router-id for the OSPF process\n") 248 249DEFUN (passive_interface, 250 passive_interface_addr_cmd, 251 "passive-interface IFNAME A.B.C.D", 252 "Suppress routing updates on an interface\n" 253 "Interface's name\n") 254{ 255 struct interface *ifp; 256 struct in_addr addr; 257 int ret; 258 struct ospf_if_params *params; 259 260 ifp = if_lookup_by_name (argv[0]); 261 262 if (ifp == NULL) 263 { 264 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); 265 return CMD_WARNING; 266 } 267 268 params = IF_DEF_PARAMS (ifp); 269 270 if (argc == 2) 271 { 272 ret = inet_aton(argv[1], &addr); 273 if (!ret) 274 { 275 vty_out (vty, "Please specify interface address by A.B.C.D%s", 276 VTY_NEWLINE); 277 return CMD_WARNING; 278 } 279 280 params = ospf_get_if_params (ifp, addr); 281 ospf_if_update_params (ifp, addr); 282 } 283 284 SET_IF_PARAM (params, passive_interface); 285 params->passive_interface = OSPF_IF_PASSIVE; 286 287 return CMD_SUCCESS; 288} 289 290ALIAS (passive_interface, 291 passive_interface_cmd, 292 "passive-interface IFNAME", 293 "Suppress routing updates on an interface\n" 294 "Interface's name\n") 295 296DEFUN (no_passive_interface, 297 no_passive_interface_addr_cmd, 298 "no passive-interface IFNAME A.B.C.D", 299 NO_STR 300 "Allow routing updates on an interface\n" 301 "Interface's name\n") 302{ 303 struct interface *ifp; 304 struct in_addr addr; 305 struct ospf_if_params *params; 306 int ret; 307 308 ifp = if_lookup_by_name (argv[0]); 309 310 if (ifp == NULL) 311 { 312 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); 313 return CMD_WARNING; 314 } 315 316 params = IF_DEF_PARAMS (ifp); 317 318 if (argc == 2) 319 { 320 ret = inet_aton(argv[1], &addr); 321 if (!ret) 322 { 323 vty_out (vty, "Please specify interface address by A.B.C.D%s", 324 VTY_NEWLINE); 325 return CMD_WARNING; 326 } 327 328 params = ospf_lookup_if_params (ifp, addr); 329 if (params == NULL) 330 return CMD_SUCCESS; 331 } 332 333 UNSET_IF_PARAM (params, passive_interface); 334 params->passive_interface = OSPF_IF_ACTIVE; 335 336 if (params != IF_DEF_PARAMS (ifp)) 337 { 338 ospf_free_if_params (ifp, addr); 339 ospf_if_update_params (ifp, addr); 340 } 341 342 return CMD_SUCCESS; 343} 344 345ALIAS (no_passive_interface, 346 no_passive_interface_cmd, 347 "no passive-interface IFNAME", 348 NO_STR 349 "Allow routing updates on an interface\n" 350 "Interface's name\n") 351 352DEFUN (network_area, 353 network_area_cmd, 354 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", 355 "Enable routing on an IP network\n" 356 "OSPF network prefix\n" 357 "Set the OSPF area ID\n" 358 "OSPF area ID in IP address format\n" 359 "OSPF area ID as a decimal value\n") 360{ 361 struct ospf *ospf= vty->index; 362 struct prefix_ipv4 p; 363 struct in_addr area_id; 364 int ret, format; 365 366 /* Get network prefix and Area ID. */ 367 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); 368 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); 369 370 ret = ospf_network_set (ospf, &p, area_id); 371 if (ret == 0) 372 { 373 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); 374 return CMD_WARNING; 375 } 376 377 return CMD_SUCCESS; 378} 379 380DEFUN (no_network_area, 381 no_network_area_cmd, 382 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", 383 NO_STR 384 "Enable routing on an IP network\n" 385 "OSPF network prefix\n" 386 "Set the OSPF area ID\n" 387 "OSPF area ID in IP address format\n" 388 "OSPF area ID as a decimal value\n") 389{ 390 struct ospf *ospf = (struct ospf *) vty->index; 391 struct prefix_ipv4 p; 392 struct in_addr area_id; 393 int ret, format; 394 395 /* Get network prefix and Area ID. */ 396 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); 397 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); 398 399 ret = ospf_network_unset (ospf, &p, area_id); 400 if (ret == 0) 401 { 402 vty_out (vty, "Can't find specified network area configuration.%s", 403 VTY_NEWLINE); 404 return CMD_WARNING; 405 } 406 407 return CMD_SUCCESS; 408} 409 410 411DEFUN (area_range, 412 area_range_cmd, 413 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", 414 "OSPF area parameters\n" 415 "OSPF area ID in IP address format\n" 416 "OSPF area ID as a decimal value\n" 417 "Summarize routes matching address/mask (border routers only)\n" 418 "Area range prefix\n") 419{ 420 struct ospf *ospf = vty->index; 421 struct prefix_ipv4 p; 422 struct in_addr area_id; 423 int format; 424 u_int32_t cost; 425 426 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); 427 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); 428 429 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); 430 if (argc > 2) 431 { 432 VTY_GET_UINT32 ("range cost", cost, argv[2]); 433 ospf_area_range_cost_set (ospf, area_id, &p, cost); 434 } 435 436 return CMD_SUCCESS; 437} 438 439ALIAS (area_range, 440 area_range_advertise_cmd, 441 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", 442 "OSPF area parameters\n" 443 "OSPF area ID in IP address format\n" 444 "OSPF area ID as a decimal value\n" 445 "OSPF area range for route advertise (default)\n" 446 "Area range prefix\n" 447 "Advertise this range (default)\n") 448 449ALIAS (area_range, 450 area_range_cost_cmd, 451 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", 452 "OSPF area parameters\n" 453 "OSPF area ID in IP address format\n" 454 "OSPF area ID as a decimal value\n" 455 "Summarize routes matching address/mask (border routers only)\n" 456 "Area range prefix\n" 457 "User specified metric for this range\n" 458 "Advertised metric for this range\n") 459 460ALIAS (area_range, 461 area_range_advertise_cost_cmd, 462 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", 463 "OSPF area parameters\n" 464 "OSPF area ID in IP address format\n" 465 "OSPF area ID as a decimal value\n" 466 "Summarize routes matching address/mask (border routers only)\n" 467 "Area range prefix\n" 468 "Advertise this range (default)\n" 469 "User specified metric for this range\n" 470 "Advertised metric for this range\n") 471 472DEFUN (area_range_not_advertise, 473 area_range_not_advertise_cmd, 474 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", 475 "OSPF area parameters\n" 476 "OSPF area ID in IP address format\n" 477 "OSPF area ID as a decimal value\n" 478 "Summarize routes matching address/mask (border routers only)\n" 479 "Area range prefix\n" 480 "DoNotAdvertise this range\n") 481{ 482 struct ospf *ospf = vty->index; 483 struct prefix_ipv4 p; 484 struct in_addr area_id; 485 int format; 486 487 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); 488 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); 489 490 ospf_area_range_set (ospf, area_id, &p, 0); 491 492 return CMD_SUCCESS; 493} 494 495DEFUN (no_area_range, 496 no_area_range_cmd, 497 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", 498 NO_STR 499 "OSPF area parameters\n" 500 "OSPF area ID in IP address format\n" 501 "OSPF area ID as a decimal value\n" 502 "Summarize routes matching address/mask (border routers only)\n" 503 "Area range prefix\n") 504{ 505 struct ospf *ospf = vty->index; 506 struct prefix_ipv4 p; 507 struct in_addr area_id; 508 int format; 509 510 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); 511 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); 512 513 ospf_area_range_unset (ospf, area_id, &p); 514 515 return CMD_SUCCESS; 516} 517 518ALIAS (no_area_range, 519 no_area_range_advertise_cmd, 520 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", 521 NO_STR 522 "OSPF area parameters\n" 523 "OSPF area ID in IP address format\n" 524 "OSPF area ID as a decimal value\n" 525 "Summarize routes matching address/mask (border routers only)\n" 526 "Area range prefix\n" 527 "Advertise this range (default)\n" 528 "DoNotAdvertise this range\n") 529 530ALIAS (no_area_range, 531 no_area_range_cost_cmd, 532 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", 533 NO_STR 534 "OSPF area parameters\n" 535 "OSPF area ID in IP address format\n" 536 "OSPF area ID as a decimal value\n" 537 "Summarize routes matching address/mask (border routers only)\n" 538 "Area range prefix\n" 539 "User specified metric for this range\n" 540 "Advertised metric for this range\n") 541 542ALIAS (no_area_range, 543 no_area_range_advertise_cost_cmd, 544 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", 545 NO_STR 546 "OSPF area parameters\n" 547 "OSPF area ID in IP address format\n" 548 "OSPF area ID as a decimal value\n" 549 "Summarize routes matching address/mask (border routers only)\n" 550 "Area range prefix\n" 551 "Advertise this range (default)\n" 552 "User specified metric for this range\n" 553 "Advertised metric for this range\n") 554 555DEFUN (area_range_substitute, 556 area_range_substitute_cmd, 557 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", 558 "OSPF area parameters\n" 559 "OSPF area ID in IP address format\n" 560 "OSPF area ID as a decimal value\n" 561 "Summarize routes matching address/mask (border routers only)\n" 562 "Area range prefix\n" 563 "Announce area range as another prefix\n" 564 "Network prefix to be announced instead of range\n") 565{ 566 struct ospf *ospf = vty->index; 567 struct prefix_ipv4 p, s; 568 struct in_addr area_id; 569 int format; 570 571 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); 572 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); 573 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); 574 575 ospf_area_range_substitute_set (ospf, area_id, &p, &s); 576 577 return CMD_SUCCESS; 578} 579 580DEFUN (no_area_range_substitute, 581 no_area_range_substitute_cmd, 582 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", 583 NO_STR 584 "OSPF area parameters\n" 585 "OSPF area ID in IP address format\n" 586 "OSPF area ID as a decimal value\n" 587 "Summarize routes matching address/mask (border routers only)\n" 588 "Area range prefix\n" 589 "Announce area range as another prefix\n" 590 "Network prefix to be announced instead of range\n") 591{ 592 struct ospf *ospf = vty->index; 593 struct prefix_ipv4 p, s; 594 struct in_addr area_id; 595 int format; 596 597 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); 598 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); 599 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); 600 601 ospf_area_range_substitute_unset (ospf, area_id, &p); 602 603 return CMD_SUCCESS; 604} 605 606 607/* Command Handler Logic in VLink stuff is delicate!! 608 609 ALTER AT YOUR OWN RISK!!!! 610 611 Various dummy values are used to represent 'NoChange' state for 612 VLink configuration NOT being changed by a VLink command, and 613 special syntax is used within the command strings so that the 614 typed in command verbs can be seen in the configuration command 615 bacckend handler. This is to drastically reduce the verbeage 616 required to coe up with a reasonably compatible Cisco VLink command 617 618 - Matthew Grant <grantma@anathoth.gen.nz> 619 Wed, 21 Feb 2001 15:13:52 +1300 620 */ 621 622 623/* Configuration data for virtual links 624 */ 625struct ospf_vl_config_data { 626 struct vty *vty; /* vty stuff */ 627 struct in_addr area_id; /* area ID from command line */ 628 int format; /* command line area ID format */ 629 struct in_addr vl_peer; /* command line vl_peer */ 630 int auth_type; /* Authehntication type, if given */ 631 char *auth_key; /* simple password if present */ 632 int crypto_key_id; /* Cryptographic key ID */ 633 char *md5_key; /* MD5 authentication key */ 634 int hello_interval; /* Obvious what these are... */ 635 int retransmit_interval; 636 int transmit_delay; 637 int dead_interval; 638}; 639 640void 641ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, 642 struct vty *vty) 643{ 644 memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); 645 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; 646 vl_config->vty = vty; 647} 648 649struct ospf_vl_data * 650ospf_find_vl_data (struct ospf_vl_config_data *vl_config) 651{ 652 struct ospf_area *area; 653 struct ospf_vl_data *vl_data; 654 struct vty *vty; 655 struct in_addr area_id; 656 657 vty = vl_config->vty; 658 area_id = vl_config->area_id; 659 660 if (area_id.s_addr == OSPF_AREA_BACKBONE) 661 { 662 vty_out (vty, 663 "Configuring VLs over the backbone is not allowed%s", 664 VTY_NEWLINE); 665 return NULL; 666 } 667 area = ospf_area_get (area_id, vl_config->format); 668 669 if (area->external_routing != OSPF_AREA_DEFAULT) 670 { 671 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) 672 vty_out (vty, "Area %s is %s%s", 673 inet_ntoa (area_id), 674#ifdef HAVE_NSSA 675 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", 676#else 677 "stub", 678#endif /* HAVE_NSSA */ 679 VTY_NEWLINE); 680 else 681 vty_out (vty, "Area %ld is %s%s", 682 (u_long)ntohl (area_id.s_addr), 683#ifdef HAVE_NSSA 684 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", 685#else 686 "stub", 687#endif /* HAVE_NSSA */ 688 VTY_NEWLINE); 689 return NULL; 690 } 691 692 if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL) 693 { 694 vl_data = ospf_vl_data_new (area, vl_config->vl_peer); 695 if (vl_data->vl_oi == NULL) 696 { 697 vl_data->vl_oi = ospf_vl_new (vl_data); 698 ospf_vl_add (vl_data); 699 ospf_spf_calculate_schedule (); 700 } 701 } 702 return vl_data; 703} 704 705 706int 707ospf_vl_set_security (struct ospf_vl_data *vl_data, 708 struct ospf_vl_config_data *vl_config) 709{ 710 struct crypt_key *ck; 711 struct vty *vty; 712 struct interface *ifp = vl_data->vl_oi->ifp; 713 714 vty = vl_config->vty; 715 716 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) 717 { 718 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); 719 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; 720 } 721 722 if (vl_config->auth_key) 723 { 724 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); 725 strncpy (IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, 726 OSPF_AUTH_SIMPLE_SIZE); 727 } 728 else if (vl_config->md5_key) 729 { 730 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) 731 != NULL) 732 { 733 vty_out (vty, "OSPF: Key %d already exists%s", 734 vl_config->crypto_key_id, VTY_NEWLINE); 735 return CMD_WARNING; 736 } 737 ck = ospf_crypt_key_new (); 738 ck->key_id = vl_config->crypto_key_id; 739 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); 740 strncpy (ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); 741 742 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); 743 } 744 else if (vl_config->crypto_key_id != 0) 745 { 746 /* Delete a key */ 747 748 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, 749 vl_config->crypto_key_id) == NULL) 750 { 751 vty_out (vty, "OSPF: Key %d does not exist%s", 752 vl_config->crypto_key_id, VTY_NEWLINE); 753 return CMD_WARNING; 754 } 755 756 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); 757 758 } 759 760 return CMD_SUCCESS; 761} 762 763 764 765int 766ospf_vl_set_timers (struct ospf_vl_data *vl_data, 767 struct ospf_vl_config_data *vl_config) 768{ 769 struct interface *ifp = ifp = vl_data->vl_oi->ifp; 770 /* Virtual Link data initialised to defaults, so only set 771 if a value given */ 772 if (vl_config->hello_interval) 773 { 774 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); 775 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; 776 } 777 778 if (vl_config->dead_interval) 779 { 780 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); 781 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; 782 } 783 784 if (vl_config->retransmit_interval) 785 { 786 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); 787 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; 788 } 789 790 if (vl_config->transmit_delay) 791 { 792 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); 793 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; 794 } 795 796 return CMD_SUCCESS; 797} 798 799 800 801/* The business end of all of the above */ 802int 803ospf_vl_set (struct ospf_vl_config_data *vl_config) 804{ 805 struct ospf_vl_data *vl_data; 806 int ret; 807 808 vl_data = ospf_find_vl_data (vl_config); 809 if (!vl_data) 810 return CMD_WARNING; 811 812 /* Process this one first as it can have a fatal result, which can 813 only logically occur if the virtual link exists already 814 Thus a command error does not result in a change to the 815 running configuration such as unexpectedly altered timer 816 values etc.*/ 817 ret = ospf_vl_set_security (vl_data, vl_config); 818 if (ret != CMD_SUCCESS) 819 return ret; 820 821 /* Set any time based parameters, these area already range checked */ 822 823 ret = ospf_vl_set_timers (vl_data, vl_config); 824 if (ret != CMD_SUCCESS) 825 return ret; 826 827 return CMD_SUCCESS; 828 829} 830 831/* This stuff exists to make specifying all the alias commands A LOT simpler 832 */ 833#define VLINK_HELPSTR_IPADDR \ 834 "OSPF area parameters\n" \ 835 "OSPF area ID in IP address format\n" \ 836 "OSPF area ID as a decimal value\n" \ 837 "Configure a virtual link\n" \ 838 "Router ID of the remote ABR\n" 839 840#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ 841 "Enable authentication on this virtual link\n" \ 842 "dummy string \n" 843 844#define VLINK_HELPSTR_AUTHTYPE_ALL \ 845 VLINK_HELPSTR_AUTHTYPE_SIMPLE \ 846 "Use null authentication\n" \ 847 "Use message-digest authentication\n" 848 849#define VLINK_HELPSTR_TIME_PARAM_NOSECS \ 850 "Time between HELLO packets\n" \ 851 "Time between retransmitting lost link state advertisements\n" \ 852 "Link state transmit delay\n" \ 853 "Interval after which a neighbor is declared dead\n" 854 855#define VLINK_HELPSTR_TIME_PARAM \ 856 VLINK_HELPSTR_TIME_PARAM_NOSECS \ 857 "Seconds\n" 858 859#define VLINK_HELPSTR_AUTH_SIMPLE \ 860 "Authentication password (key)\n" \ 861 "The OSPF password (key)" 862 863#define VLINK_HELPSTR_AUTH_MD5 \ 864 "Message digest authentication password (key)\n" \ 865 "dummy string \n" \ 866 "Key ID\n" \ 867 "Use MD5 algorithm\n" \ 868 "The OSPF password (key)" 869 870DEFUN (area_vlink, 871 area_vlink_cmd, 872 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", 873 VLINK_HELPSTR_IPADDR) 874{ 875 struct ospf_vl_config_data vl_config; 876 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; 877 char md5_key[OSPF_AUTH_MD5_SIZE+1]; 878 int i; 879 int ret; 880 881 ospf_vl_config_data_init(&vl_config, vty); 882 883 /* Read off first 2 parameters and check them */ 884 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); 885 if (ret < 0) 886 { 887 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); 888 return CMD_WARNING; 889 } 890 891 ret = inet_aton (argv[1], &vl_config.vl_peer); 892 if (! ret) 893 { 894 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", 895 VTY_NEWLINE); 896 return CMD_WARNING; 897 } 898 899 if (argc <=2) 900 { 901 /* Thats all folks! - BUGS B. strikes again!!!*/ 902 903 return ospf_vl_set (&vl_config); 904 } 905 906 /* Deal with other parameters */ 907 for (i=2; i < argc; i++) 908 { 909 910 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ 911 912 switch (argv[i][0]) 913 { 914 915 case 'a': 916 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) 917 { 918 /* authentication-key - this option can occur anywhere on 919 command line. At start of command line 920 must check for authentication option. */ 921 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); 922 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); 923 vl_config.auth_key = auth_key; 924 i++; 925 } 926 else if (strncmp (argv[i], "authentication", 14) == 0) 927 { 928 /* authentication - this option can only occur at start 929 of command line */ 930 vl_config.auth_type = OSPF_AUTH_SIMPLE; 931 if ((i+1) < argc) 932 { 933 if (strncmp (argv[i+1], "n", 1) == 0) 934 { 935 /* "authentication null" */ 936 vl_config.auth_type = OSPF_AUTH_NULL; 937 i++; 938 } 939 else if (strncmp (argv[i+1], "m", 1) == 0 940 && strcmp (argv[i+1], "message-digest-") != 0) 941 { 942 /* "authentication message-digest" */ 943 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; 944 i++; 945 } 946 } 947 } 948 break; 949 950 case 'm': 951 /* message-digest-key */ 952 i++; 953 vl_config.crypto_key_id = strtol (argv[i], NULL, 10); 954 if (vl_config.crypto_key_id < 0) 955 return CMD_WARNING; 956 i++; 957 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); 958 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); 959 vl_config.md5_key = md5_key; 960 break; 961 962 case 'h': 963 /* Hello interval */ 964 i++; 965 vl_config.hello_interval = strtol (argv[i], NULL, 10); 966 if (vl_config.hello_interval < 0) 967 return CMD_WARNING; 968 break; 969 970 case 'r': 971 /* Retransmit Interval */ 972 i++; 973 vl_config.retransmit_interval = strtol (argv[i], NULL, 10); 974 if (vl_config.retransmit_interval < 0) 975 return CMD_WARNING; 976 break; 977 978 case 't': 979 /* Transmit Delay */ 980 i++; 981 vl_config.transmit_delay = strtol (argv[i], NULL, 10); 982 if (vl_config.transmit_delay < 0) 983 return CMD_WARNING; 984 break; 985 986 case 'd': 987 /* Dead Interval */ 988 i++; 989 vl_config.dead_interval = strtol (argv[i], NULL, 10); 990 if (vl_config.dead_interval < 0) 991 return CMD_WARNING; 992 break; 993 } 994 } 995 996 997 /* Action configuration */ 998 999 return ospf_vl_set (&vl_config); 1000 1001} 1002 1003DEFUN (no_area_vlink, 1004 no_area_vlink_cmd, 1005 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", 1006 NO_STR 1007 VLINK_HELPSTR_IPADDR) 1008{ 1009 struct ospf_area *area; 1010 struct ospf_vl_config_data vl_config; 1011 struct ospf_vl_data *vl_data = NULL; 1012 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; 1013 int i; 1014 int ret, format; 1015 1016 ospf_vl_config_data_init(&vl_config, vty); 1017 1018 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); 1019 if (ret < 0) 1020 { 1021 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); 1022 return CMD_WARNING; 1023 } 1024 1025 area = ospf_area_lookup_by_area_id (vl_config.area_id); 1026 if (!area) 1027 { 1028 vty_out (vty, "Area does not exist%s", VTY_NEWLINE); 1029 return CMD_WARNING; 1030 } 1031 1032 ret = inet_aton (argv[1], &vl_config.vl_peer); 1033 if (! ret) 1034 { 1035 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", 1036 VTY_NEWLINE); 1037 return CMD_WARNING; 1038 } 1039 1040 if (argc <=2) 1041 { 1042 /* Basic VLink no command */ 1043 /* Thats all folks! - BUGS B. strikes again!!!*/ 1044 if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer))) 1045 ospf_vl_delete (vl_data); 1046 1047 ospf_area_check_free (vl_config.area_id); 1048 1049 return CMD_SUCCESS; 1050 } 1051 1052 /* If we are down here, we are reseting parameters */ 1053 1054 /* Deal with other parameters */ 1055 for (i=2; i < argc; i++) 1056 { 1057 1058 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ 1059 1060 switch (argv[i][0]) 1061 { 1062 1063 case 'a': 1064 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) 1065 { 1066 /* authentication-key - this option can occur anywhere on 1067 command line. At start of command line 1068 must check for authentication option. */ 1069 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); 1070 vl_config.auth_key = auth_key; 1071 } 1072 else if (strncmp (argv[i], "authentication", 14) == 0) 1073 { 1074 /* authentication - this option can only occur at start 1075 of command line */ 1076 vl_config.auth_type = OSPF_AUTH_NOTSET; 1077 } 1078 break; 1079 1080 case 'm': 1081 /* message-digest-key */ 1082 /* Delete one key */ 1083 i++; 1084 vl_config.crypto_key_id = strtol (argv[i], NULL, 10); 1085 if (vl_config.crypto_key_id < 0) 1086 return CMD_WARNING; 1087 vl_config.md5_key = NULL; 1088 break; 1089 1090 case 'h': 1091 /* Hello interval */ 1092 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; 1093 break; 1094 1095 case 'r': 1096 /* Retransmit Interval */ 1097 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; 1098 break; 1099 1100 case 't': 1101 /* Transmit Delay */ 1102 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; 1103 break; 1104 1105 case 'd': 1106 /* Dead Interval */ 1107 i++; 1108 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; 1109 break; 1110 } 1111 } 1112 1113 1114 /* Action configuration */ 1115 1116 return ospf_vl_set (&vl_config); 1117} 1118 1119ALIAS (area_vlink, 1120 area_vlink_param1_cmd, 1121 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1122 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", 1123 VLINK_HELPSTR_IPADDR 1124 VLINK_HELPSTR_TIME_PARAM) 1125 1126ALIAS (no_area_vlink, 1127 no_area_vlink_param1_cmd, 1128 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1129 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", 1130 NO_STR 1131 VLINK_HELPSTR_IPADDR 1132 VLINK_HELPSTR_TIME_PARAM) 1133 1134ALIAS (area_vlink, 1135 area_vlink_param2_cmd, 1136 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1137 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " 1138 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", 1139 VLINK_HELPSTR_IPADDR 1140 VLINK_HELPSTR_TIME_PARAM 1141 VLINK_HELPSTR_TIME_PARAM) 1142 1143ALIAS (no_area_vlink, 1144 no_area_vlink_param2_cmd, 1145 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1146 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " 1147 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", 1148 NO_STR 1149 VLINK_HELPSTR_IPADDR 1150 VLINK_HELPSTR_TIME_PARAM 1151 VLINK_HELPSTR_TIME_PARAM) 1152 1153ALIAS (area_vlink, 1154 area_vlink_param3_cmd, 1155 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1156 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " 1157 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " 1158 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", 1159 VLINK_HELPSTR_IPADDR 1160 VLINK_HELPSTR_TIME_PARAM 1161 VLINK_HELPSTR_TIME_PARAM 1162 VLINK_HELPSTR_TIME_PARAM) 1163 1164ALIAS (no_area_vlink, 1165 no_area_vlink_param3_cmd, 1166 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1167 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " 1168 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " 1169 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", 1170 NO_STR 1171 VLINK_HELPSTR_IPADDR 1172 VLINK_HELPSTR_TIME_PARAM 1173 VLINK_HELPSTR_TIME_PARAM 1174 VLINK_HELPSTR_TIME_PARAM) 1175 1176ALIAS (area_vlink, 1177 area_vlink_param4_cmd, 1178 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1179 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " 1180 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " 1181 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " 1182 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", 1183 VLINK_HELPSTR_IPADDR 1184 VLINK_HELPSTR_TIME_PARAM 1185 VLINK_HELPSTR_TIME_PARAM 1186 VLINK_HELPSTR_TIME_PARAM 1187 VLINK_HELPSTR_TIME_PARAM) 1188 1189ALIAS (no_area_vlink, 1190 no_area_vlink_param4_cmd, 1191 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1192 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " 1193 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " 1194 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " 1195 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", 1196 NO_STR 1197 VLINK_HELPSTR_IPADDR 1198 VLINK_HELPSTR_TIME_PARAM 1199 VLINK_HELPSTR_TIME_PARAM 1200 VLINK_HELPSTR_TIME_PARAM 1201 VLINK_HELPSTR_TIME_PARAM) 1202 1203ALIAS (area_vlink, 1204 area_vlink_authtype_args_cmd, 1205 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1206 "(authentication|) (message-digest|null)", 1207 VLINK_HELPSTR_IPADDR 1208 VLINK_HELPSTR_AUTHTYPE_ALL) 1209 1210ALIAS (area_vlink, 1211 area_vlink_authtype_cmd, 1212 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1213 "(authentication|)", 1214 VLINK_HELPSTR_IPADDR 1215 VLINK_HELPSTR_AUTHTYPE_SIMPLE) 1216 1217ALIAS (no_area_vlink, 1218 no_area_vlink_authtype_cmd, 1219 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1220 "(authentication|)", 1221 NO_STR 1222 VLINK_HELPSTR_IPADDR 1223 VLINK_HELPSTR_AUTHTYPE_SIMPLE) 1224 1225ALIAS (area_vlink, 1226 area_vlink_md5_cmd, 1227 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1228 "(message-digest-key|) <1-255> md5 KEY", 1229 VLINK_HELPSTR_IPADDR 1230 VLINK_HELPSTR_AUTH_MD5) 1231 1232ALIAS (no_area_vlink, 1233 no_area_vlink_md5_cmd, 1234 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1235 "(message-digest-key|) <1-255>", 1236 NO_STR 1237 VLINK_HELPSTR_IPADDR 1238 VLINK_HELPSTR_AUTH_MD5) 1239 1240ALIAS (area_vlink, 1241 area_vlink_authkey_cmd, 1242 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1243 "(authentication-key|) AUTH_KEY", 1244 VLINK_HELPSTR_IPADDR 1245 VLINK_HELPSTR_AUTH_SIMPLE) 1246 1247ALIAS (no_area_vlink, 1248 no_area_vlink_authkey_cmd, 1249 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1250 "(authentication-key|)", 1251 NO_STR 1252 VLINK_HELPSTR_IPADDR 1253 VLINK_HELPSTR_AUTH_SIMPLE) 1254 1255ALIAS (area_vlink, 1256 area_vlink_authtype_args_authkey_cmd, 1257 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1258 "(authentication|) (message-digest|null) " 1259 "(authentication-key|) AUTH_KEY", 1260 VLINK_HELPSTR_IPADDR 1261 VLINK_HELPSTR_AUTHTYPE_ALL 1262 VLINK_HELPSTR_AUTH_SIMPLE) 1263 1264ALIAS (area_vlink, 1265 area_vlink_authtype_authkey_cmd, 1266 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1267 "(authentication|) " 1268 "(authentication-key|) AUTH_KEY", 1269 VLINK_HELPSTR_IPADDR 1270 VLINK_HELPSTR_AUTHTYPE_SIMPLE 1271 VLINK_HELPSTR_AUTH_SIMPLE) 1272 1273ALIAS (no_area_vlink, 1274 no_area_vlink_authtype_authkey_cmd, 1275 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1276 "(authentication|) " 1277 "(authentication-key|)", 1278 NO_STR 1279 VLINK_HELPSTR_IPADDR 1280 VLINK_HELPSTR_AUTHTYPE_SIMPLE 1281 VLINK_HELPSTR_AUTH_SIMPLE) 1282 1283ALIAS (area_vlink, 1284 area_vlink_authtype_args_md5_cmd, 1285 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1286 "(authentication|) (message-digest|null) " 1287 "(message-digest-key|) <1-255> md5 KEY", 1288 VLINK_HELPSTR_IPADDR 1289 VLINK_HELPSTR_AUTHTYPE_ALL 1290 VLINK_HELPSTR_AUTH_MD5) 1291 1292ALIAS (area_vlink, 1293 area_vlink_authtype_md5_cmd, 1294 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1295 "(authentication|) " 1296 "(message-digest-key|) <1-255> md5 KEY", 1297 VLINK_HELPSTR_IPADDR 1298 VLINK_HELPSTR_AUTHTYPE_SIMPLE 1299 VLINK_HELPSTR_AUTH_MD5) 1300 1301ALIAS (no_area_vlink, 1302 no_area_vlink_authtype_md5_cmd, 1303 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " 1304 "(authentication|) " 1305 "(message-digest-key|)", 1306 NO_STR 1307 VLINK_HELPSTR_IPADDR 1308 VLINK_HELPSTR_AUTHTYPE_SIMPLE 1309 VLINK_HELPSTR_AUTH_MD5) 1310 1311 1312DEFUN (area_shortcut, 1313 area_shortcut_cmd, 1314 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", 1315 "OSPF area parameters\n" 1316 "OSPF area ID in IP address format\n" 1317 "OSPF area ID as a decimal value\n" 1318 "Configure the area's shortcutting mode\n" 1319 "Set default shortcutting behavior\n" 1320 "Enable shortcutting through the area\n" 1321 "Disable shortcutting through the area\n") 1322{ 1323 struct ospf *ospf = vty->index; 1324 struct ospf_area *area; 1325 struct in_addr area_id; 1326 int mode; 1327 int format; 1328 1329 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); 1330 1331 area = ospf_area_get (area_id, format); 1332 1333 if (strncmp (argv[1], "de", 2) == 0) 1334 mode = OSPF_SHORTCUT_DEFAULT; 1335 else if (strncmp (argv[1], "di", 2) == 0) 1336 mode = OSPF_SHORTCUT_DISABLE; 1337 else if (strncmp (argv[1], "e", 1) == 0) 1338 mode = OSPF_SHORTCUT_ENABLE; 1339 else 1340 return CMD_WARNING; 1341 1342 ospf_area_shortcut_set (area, mode); 1343 1344 if (ospf_top->abr_type != OSPF_ABR_SHORTCUT) 1345 vty_out (vty, "Shortcut area setting will take effect " 1346 "only when the router is configured as Shortcut ABR%s", 1347 VTY_NEWLINE); 1348 1349 return CMD_SUCCESS; 1350} 1351 1352DEFUN (no_area_shortcut, 1353 no_area_shortcut_cmd, 1354 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", 1355 NO_STR 1356 "OSPF area parameters\n" 1357 "OSPF area ID in IP address format\n" 1358 "OSPF area ID as a decimal value\n" 1359 "Deconfigure the area's shortcutting mode\n" 1360 "Deconfigure enabled shortcutting through the area\n" 1361 "Deconfigure disabled shortcutting through the area\n") 1362{ 1363 struct ospf_area *area; 1364 struct in_addr area_id; 1365 int format; 1366 1367 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); 1368 1369 area = ospf_area_lookup_by_area_id (area_id); 1370 if (!area) 1371 return CMD_SUCCESS; 1372 1373 ospf_area_shortcut_unset (area); 1374 1375 return CMD_SUCCESS; 1376} 1377 1378 1379DEFUN (area_stub, 1380 area_stub_cmd, 1381 "area (A.B.C.D|<0-4294967295>) stub", 1382 "OSPF area parameters\n" 1383 "OSPF area ID in IP address format\n" 1384 "OSPF area ID as a decimal value\n" 1385 "Configure OSPF area as stub\n") 1386{ 1387 struct ospf *ospf = vty->index; 1388 struct in_addr area_id; 1389 int ret, format; 1390 1391 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); 1392 1393 ret = ospf_area_stub_set (ospf, area_id); 1394 if (ret == 0) 1395 { 1396 vty_out (vty, "First deconfigure all virtual link through this area%s", 1397 VTY_NEWLINE); 1398 return CMD_WARNING; 1399 } 1400 1401 ospf_area_no_summary_unset (ospf, area_id); 1402 1403 return CMD_SUCCESS; 1404} 1405 1406DEFUN (area_stub_no_summary, 1407 area_stub_no_summary_cmd, 1408 "area (A.B.C.D|<0-4294967295>) stub no-summary", 1409 "OSPF stub parameters\n" 1410 "OSPF area ID in IP address format\n" 1411 "OSPF area ID as a decimal value\n" 1412 "Configure OSPF area as stub\n" 1413 "Do not inject inter-area routes into stub\n") 1414{ 1415 struct ospf *ospf = vty->index; 1416 struct in_addr area_id; 1417 int ret, format; 1418 1419 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); 1420 1421 ret = ospf_area_stub_set (ospf, area_id); 1422 if (ret == 0) 1423 { 1424 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", 1425 VTY_NEWLINE); 1426 return CMD_WARNING; 1427 } 1428 1429 ospf_area_no_summary_set (ospf, area_id); 1430 1431 return CMD_SUCCESS; 1432} 1433 1434DEFUN (no_area_stub, 1435 no_area_stub_cmd, 1436 "no area (A.B.C.D|<0-4294967295>) stub", 1437 NO_STR 1438 "OSPF area parameters\n" 1439 "OSPF area ID in IP address format\n" 1440 "OSPF area ID as a decimal value\n" 1441 "Configure OSPF area as stub\n") 1442{ 1443 struct ospf *ospf = vty->index; 1444 struct in_addr area_id; 1445 int format; 1446 1447 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); 1448 1449 ospf_area_stub_unset (ospf, area_id); 1450 ospf_area_no_summary_unset (ospf, area_id); 1451 1452 return CMD_SUCCESS; 1453} 1454 1455DEFUN (no_area_stub_no_summary, 1456 no_area_stub_no_summary_cmd, 1457 "no area (A.B.C.D|<0-4294967295>) stub no-summary", 1458 NO_STR 1459 "OSPF area parameters\n" 1460 "OSPF area ID in IP address format\n" 1461 "OSPF area ID as a decimal value\n" 1462 "Configure OSPF area as stub\n" 1463 "Do not inject inter-area routes into area\n") 1464{ 1465 struct ospf *ospf = vty->index; 1466 struct in_addr area_id; 1467 int format; 1468 1469 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); 1470 ospf_area_no_summary_unset (ospf, area_id); 1471 1472 return CMD_SUCCESS; 1473} 1474 1475#ifdef HAVE_NSSA 1476DEFUN (area_nssa, 1477 area_nssa_cmd, 1478 "area (A.B.C.D|<0-4294967295>) nssa", 1479 "OSPF area parameters\n" 1480 "OSPF area ID in IP address format\n" 1481 "OSPF area ID as a decimal value\n" 1482 "Configure OSPF area as nssa\n") 1483{ 1484 struct ospf *ospf = vty->index; 1485 struct in_addr area_id; 1486 int ret, format; 1487 1488 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); 1489 1490 ret = ospf_area_nssa_set (ospf, area_id); 1491 if (ret == 0) 1492 { 1493 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", 1494 VTY_NEWLINE); 1495 return CMD_WARNING; 1496 } 1497 1498 if (argc > 1) 1499 { 1500 if (strncmp (argv[1], "translate-c", 11) == 0) 1501 ospf_area_nssa_translator_role_set (ospf, area_id, 1502 OSPF_NSSA_ROLE_CANDIDATE); 1503 else if (strncmp (argv[1], "translate-n", 11) == 0) 1504 ospf_area_nssa_translator_role_set (ospf, area_id, 1505 OSPF_NSSA_ROLE_NEVER); 1506 else if (strncmp (argv[1], "translate-a", 11) == 0) 1507 ospf_area_nssa_translator_role_set (ospf, area_id, 1508 OSPF_NSSA_ROLE_ALWAYS); 1509 } 1510 1511 if (argc > 2) 1512 ospf_area_no_summary_set (ospf, area_id); 1513 1514 return CMD_SUCCESS; 1515} 1516 1517ALIAS (area_nssa, 1518 area_nssa_translate_no_summary_cmd, 1519 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) (no-summary|)", 1520 "OSPF area parameters\n" 1521 "OSPF area ID in IP address format\n" 1522 "OSPF area ID as a decimal value\n" 1523 "Configure OSPF area as nssa\n" 1524 "Configure NSSA-ABR for translate election (default)\n" 1525 "Configure NSSA-ABR to never translate\n" 1526 "Configure NSSA-ABR to always translate\n" 1527 "Do not inject inter-area routes into nssa\n" 1528 "dummy\n") 1529 1530ALIAS (area_nssa, 1531 area_nssa_translate_cmd, 1532 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", 1533 "OSPF area parameters\n" 1534 "OSPF area ID in IP address format\n" 1535 "OSPF area ID as a decimal value\n" 1536 "Configure OSPF area as nssa\n" 1537 "Configure NSSA-ABR for translate election (default)\n" 1538 "Configure NSSA-ABR to never translate\n" 1539 "Configure NSSA-ABR to always translate\n") 1540 1541DEFUN (area_nssa_no_summary, 1542 area_nssa_no_summary_cmd, 1543 "area (A.B.C.D|<0-4294967295>) nssa no-summary", 1544 "OSPF area parameters\n" 1545 "OSPF area ID in IP address format\n" 1546 "OSPF area ID as a decimal value\n" 1547 "Configure OSPF area as nssa\n" 1548 "Do not inject inter-area routes into nssa\n") 1549{ 1550 struct ospf *ospf = vty->index; 1551 struct in_addr area_id; 1552 int ret, format; 1553 1554 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); 1555 1556 ret = ospf_area_nssa_set (ospf, area_id); 1557 if (ret == 0) 1558 { 1559 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", 1560 VTY_NEWLINE); 1561 return CMD_WARNING; 1562 } 1563 1564 ospf_area_no_summary_set (ospf, area_id); 1565 1566 return CMD_SUCCESS; 1567} 1568 1569DEFUN (no_area_nssa, 1570 no_area_nssa_cmd, 1571 "no area (A.B.C.D|<0-4294967295>) nssa", 1572 NO_STR 1573 "OSPF area parameters\n" 1574 "OSPF area ID in IP address format\n" 1575 "OSPF area ID as a decimal value\n" 1576 "Configure OSPF area as nssa\n") 1577{ 1578 struct ospf *ospf = vty->index; 1579 struct in_addr area_id; 1580 int format; 1581 1582 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); 1583 1584 ospf_area_nssa_unset (ospf, area_id); 1585 ospf_area_no_summary_unset (ospf, area_id); 1586 1587 return CMD_SUCCESS; 1588} 1589 1590DEFUN (no_area_nssa_no_summary, 1591 no_area_nssa_no_summary_cmd, 1592 "no area (A.B.C.D|<0-4294967295>) nssa no-summary", 1593 NO_STR 1594 "OSPF area parameters\n" 1595 "OSPF area ID in IP address format\n" 1596 "OSPF area ID as a decimal value\n" 1597 "Configure OSPF area as nssa\n" 1598 "Do not inject inter-area routes into nssa\n") 1599{ 1600 struct ospf *ospf = vty->index; 1601 struct in_addr area_id; 1602 int format; 1603 1604 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); 1605 ospf_area_no_summary_unset (ospf, area_id); 1606 1607 return CMD_SUCCESS; 1608} 1609 1610#endif /* HAVE_NSSA */ 1611 1612DEFUN (area_default_cost, 1613 area_default_cost_cmd, 1614 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", 1615 "OSPF area parameters\n" 1616 "OSPF area ID in IP address format\n" 1617 "OSPF area ID as a decimal value\n" 1618 "Set the summary-default cost of a NSSA or stub area\n" 1619 "Stub's advertised default summary cost\n") 1620{ 1621 struct ospf_area *area; 1622 struct in_addr area_id; 1623 u_int32_t cost; 1624 int format; 1625 1626 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); 1627 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); 1628 1629 area = ospf_area_get (area_id, format); 1630 1631 if (area->external_routing == OSPF_AREA_DEFAULT) 1632 { 1633 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); 1634 return CMD_WARNING; 1635 } 1636 1637 area->default_cost = cost; 1638 1639 return CMD_SUCCESS; 1640} 1641 1642DEFUN (no_area_default_cost, 1643 no_area_default_cost_cmd, 1644 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", 1645 NO_STR 1646 "OSPF area parameters\n" 1647 "OSPF area ID in IP address format\n" 1648 "OSPF area ID as a decimal value\n" 1649 "Set the summary-default cost of a NSSA or stub area\n" 1650 "Stub's advertised default summary cost\n") 1651{ 1652 struct ospf_area *area; 1653 struct in_addr area_id; 1654 u_int32_t cost; 1655 int format; 1656 1657 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); 1658 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); 1659 1660 area = ospf_area_lookup_by_area_id (area_id); 1661 if (area == NULL) 1662 return CMD_SUCCESS; 1663 1664 if (area->external_routing == OSPF_AREA_DEFAULT) 1665 { 1666 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); 1667 return CMD_WARNING; 1668 } 1669 1670 area->default_cost = 1; 1671 1672 ospf_area_check_free (area_id); 1673 1674 return CMD_SUCCESS; 1675} 1676 1677DEFUN (area_export_list, 1678 area_export_list_cmd, 1679 "area (A.B.C.D|<0-4294967295>) export-list NAME", 1680 "OSPF area parameters\n" 1681 "OSPF area ID in IP address format\n" 1682 "OSPF area ID as a decimal value\n" 1683 "Set the filter for networks announced to other areas\n" 1684 "Name of the access-list\n") 1685{ 1686 struct ospf_area *area; 1687 struct in_addr area_id; 1688 int format; 1689 1690 VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]); 1691 1692 area = ospf_area_get (area_id, format); 1693 ospf_area_export_list_set (area, argv[1]); 1694 1695 return CMD_SUCCESS; 1696} 1697 1698DEFUN (no_area_export_list, 1699 no_area_export_list_cmd, 1700 "no area (A.B.C.D|<0-4294967295>) export-list NAME", 1701 NO_STR 1702 "OSPF area parameters\n" 1703 "OSPF area ID in IP address format\n" 1704 "OSPF area ID as a decimal value\n" 1705 "Unset the filter for networks announced to other areas\n" 1706 "Name of the access-list\n") 1707{ 1708 struct ospf_area *area; 1709 struct in_addr area_id; 1710 int format; 1711 1712 VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]); 1713 1714 area = ospf_area_lookup_by_area_id (area_id); 1715 if (area == NULL) 1716 return CMD_SUCCESS; 1717 1718 ospf_area_export_list_unset (area); 1719 1720 return CMD_SUCCESS; 1721} 1722 1723 1724DEFUN (area_import_list, 1725 area_import_list_cmd, 1726 "area (A.B.C.D|<0-4294967295>) import-list NAME", 1727 "OSPF area parameters\n" 1728 "OSPF area ID in IP address format\n" 1729 "OSPF area ID as a decimal value\n" 1730 "Set the filter for networks from other areas announced to the specified one\n" 1731 "Name of the access-list\n") 1732{ 1733 struct ospf_area *area; 1734 struct in_addr area_id; 1735 int format; 1736 1737 VTY_GET_OSPF_AREA_ID_NO_BB ("import-list", area_id, format, argv[0]); 1738 1739 area = ospf_area_get (area_id, format); 1740 ospf_area_import_list_set (area, argv[1]); 1741 1742 return CMD_SUCCESS; 1743} 1744 1745DEFUN (no_area_import_list, 1746 no_area_import_list_cmd, 1747 "no area (A.B.C.D|<0-4294967295>) import-list NAME", 1748 NO_STR 1749 "OSPF area parameters\n" 1750 "OSPF area ID in IP address format\n" 1751 "OSPF area ID as a decimal value\n" 1752 "Unset the filter for networks announced to other areas\n" 1753 "Name of the access-list\n") 1754{ 1755 struct ospf_area *area; 1756 struct in_addr area_id; 1757 int format; 1758 1759 VTY_GET_OSPF_AREA_ID_NO_BB ("import-list", area_id, format, argv[0]); 1760 area = ospf_area_lookup_by_area_id (area_id); 1761 if (area == NULL) 1762 return CMD_SUCCESS; 1763 1764 ospf_area_import_list_unset (area); 1765 1766 return CMD_SUCCESS; 1767} 1768 1769DEFUN (area_filter_list, 1770 area_filter_list_cmd, 1771 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", 1772 "OSPF area parameters\n" 1773 "OSPF area ID in IP address format\n" 1774 "OSPF area ID as a decimal value\n" 1775 "Filter networks between OSPF areas\n" 1776 "Filter prefixes between OSPF areas\n" 1777 "Name of an IP prefix-list\n" 1778 "Filter networks sent to this area\n" 1779 "Filter networks sent from this area\n") 1780{ 1781 struct ospf_area *area; 1782 struct in_addr area_id; 1783 struct prefix_list *plist; 1784 int format; 1785 1786 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); 1787 1788 area = ospf_area_get (area_id, format); 1789 plist = prefix_list_lookup (AFI_IP, argv[1]); 1790 if (strncmp (argv[2], "in", 2) == 0) 1791 { 1792 PREFIX_LIST_IN (area) = plist; 1793 if (PREFIX_NAME_IN (area)) 1794 free (PREFIX_NAME_IN (area)); 1795 1796 PREFIX_NAME_IN (area) = strdup (argv[1]); 1797 ospf_schedule_abr_task (); 1798 } 1799 else 1800 { 1801 PREFIX_LIST_OUT (area) = plist; 1802 if (PREFIX_NAME_OUT (area)) 1803 free (PREFIX_NAME_OUT (area)); 1804 1805 PREFIX_NAME_OUT (area) = strdup (argv[1]); 1806 ospf_schedule_abr_task (); 1807 } 1808 1809 return CMD_SUCCESS; 1810} 1811 1812DEFUN (no_area_filter_list, 1813 no_area_filter_list_cmd, 1814 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", 1815 NO_STR 1816 "OSPF area parameters\n" 1817 "OSPF area ID in IP address format\n" 1818 "OSPF area ID as a decimal value\n" 1819 "Filter networks between OSPF areas\n" 1820 "Filter prefixes between OSPF areas\n" 1821 "Name of an IP prefix-list\n" 1822 "Filter networks sent to this area\n" 1823 "Filter networks sent from this area\n") 1824{ 1825 struct ospf_area *area; 1826 struct in_addr area_id; 1827 struct prefix_list *plist; 1828 int format; 1829 1830 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); 1831 1832 area = ospf_area_lookup_by_area_id (area_id); 1833 plist = prefix_list_lookup (AFI_IP, argv[1]); 1834 if (strncmp (argv[2], "in", 2) == 0) 1835 { 1836 if (PREFIX_NAME_IN (area)) 1837 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) 1838 return CMD_SUCCESS; 1839 1840 PREFIX_LIST_IN (area) = NULL; 1841 if (PREFIX_NAME_IN (area)) 1842 free (PREFIX_NAME_IN (area)); 1843 1844 PREFIX_NAME_IN (area) = NULL; 1845 1846 ospf_schedule_abr_task (); 1847 } 1848 else 1849 { 1850 if (PREFIX_NAME_OUT (area)) 1851 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) 1852 return CMD_SUCCESS; 1853 1854 PREFIX_LIST_OUT (area) = NULL; 1855 if (PREFIX_NAME_OUT (area)) 1856 free (PREFIX_NAME_OUT (area)); 1857 1858 PREFIX_NAME_OUT (area) = NULL; 1859 1860 ospf_schedule_abr_task (); 1861 } 1862 1863 return CMD_SUCCESS; 1864} 1865 1866 1867DEFUN (area_authentication_message_digest, 1868 area_authentication_message_digest_cmd, 1869 "area (A.B.C.D|<0-4294967295>) authentication message-digest", 1870 "OSPF area parameters\n" 1871 "Enable authentication\n" 1872 "Use message-digest authentication\n") 1873{ 1874 struct ospf_area *area; 1875 struct in_addr area_id; 1876 int format; 1877 1878 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); 1879 1880 area = ospf_area_get (area_id, format); 1881 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; 1882 1883 return CMD_SUCCESS; 1884} 1885 1886DEFUN (area_authentication, 1887 area_authentication_cmd, 1888 "area (A.B.C.D|<0-4294967295>) authentication", 1889 "OSPF area parameters\n" 1890 "OSPF area ID in IP address format\n" 1891 "OSPF area ID as a decimal value\n" 1892 "Enable authentication\n") 1893{ 1894 struct ospf_area *area; 1895 struct in_addr area_id; 1896 int format; 1897 1898 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); 1899 1900 area = ospf_area_get (area_id, format); 1901 area->auth_type = OSPF_AUTH_SIMPLE; 1902 1903 return CMD_SUCCESS; 1904} 1905 1906DEFUN (no_area_authentication, 1907 no_area_authentication_cmd, 1908 "no area (A.B.C.D|<0-4294967295>) authentication", 1909 NO_STR 1910 "OSPF area parameters\n" 1911 "OSPF area ID in IP address format\n" 1912 "OSPF area ID as a decimal value\n" 1913 "Enable authentication\n") 1914{ 1915 struct ospf_area *area; 1916 struct in_addr area_id; 1917 int format; 1918 1919 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); 1920 1921 area = ospf_area_lookup_by_area_id (area_id); 1922 if (area == NULL) 1923 return CMD_SUCCESS; 1924 1925 area->auth_type = OSPF_AUTH_NULL; 1926 1927 ospf_area_check_free (area_id); 1928 1929 return CMD_SUCCESS; 1930} 1931 1932 1933DEFUN (ospf_abr_type, 1934 ospf_abr_type_cmd, 1935 "ospf abr-type (cisco|ibm|shortcut|standard)", 1936 "OSPF specific commands\n" 1937 "Set OSPF ABR type\n" 1938 "Alternative ABR, cisco implementation\n" 1939 "Alternative ABR, IBM implementation\n" 1940 "Shortcut ABR\n" 1941 "Standard behavior (RFC2328)\n") 1942{ 1943 u_char abr_type = OSPF_ABR_UNKNOWN; 1944 1945 if (strncmp (argv[0], "c", 1) == 0) 1946 abr_type = OSPF_ABR_CISCO; 1947 else if (strncmp (argv[0], "i", 1) == 0) 1948 abr_type = OSPF_ABR_IBM; 1949 else if (strncmp (argv[0], "sh", 2) == 0) 1950 abr_type = OSPF_ABR_SHORTCUT; 1951 else if (strncmp (argv[0], "st", 2) == 0) 1952 abr_type = OSPF_ABR_STAND; 1953 else 1954 return CMD_WARNING; 1955 1956 /* If ABR type value is changed, schedule ABR task. */ 1957 if (ospf_top->abr_type != abr_type) 1958 { 1959 ospf_top->abr_type = abr_type; 1960 ospf_schedule_abr_task (); 1961 } 1962 1963 return CMD_SUCCESS; 1964} 1965 1966DEFUN (no_ospf_abr_type, 1967 no_ospf_abr_type_cmd, 1968 "no ospf abr-type (cisco|ibm|shortcut)", 1969 NO_STR 1970 "OSPF specific commands\n" 1971 "Set OSPF ABR type\n" 1972 "Alternative ABR, cisco implementation\n" 1973 "Alternative ABR, IBM implementation\n" 1974 "Shortcut ABR\n") 1975{ 1976 u_char abr_type = OSPF_ABR_UNKNOWN; 1977 1978 if (strncmp (argv[0], "c", 1) == 0) 1979 abr_type = OSPF_ABR_CISCO; 1980 else if (strncmp (argv[0], "i", 1) == 0) 1981 abr_type = OSPF_ABR_IBM; 1982 else if (strncmp (argv[0], "s", 1) == 0) 1983 abr_type = OSPF_ABR_SHORTCUT; 1984 else 1985 return CMD_WARNING; 1986 1987 /* If ABR type value is changed, schedule ABR task. */ 1988 if (ospf_top->abr_type == abr_type) 1989 { 1990 ospf_top->abr_type = OSPF_ABR_STAND; 1991 ospf_schedule_abr_task (); 1992 } 1993 1994 return CMD_SUCCESS; 1995} 1996 1997DEFUN (ospf_compatible_rfc1583, 1998 ospf_compatible_rfc1583_cmd, 1999 "compatible rfc1583", 2000 "OSPF compatibility list\n" 2001 "compatible with RFC 1583\n") 2002{ 2003 struct ospf *ospf = vty->index; 2004 2005 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) 2006 { 2007 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); 2008 ospf_spf_calculate_schedule (); 2009 } 2010 return CMD_SUCCESS; 2011} 2012 2013DEFUN (no_ospf_compatible_rfc1583, 2014 no_ospf_compatible_rfc1583_cmd, 2015 "no compatible rfc1583", 2016 NO_STR 2017 "OSPF compatibility list\n" 2018 "compatible with RFC 1583\n") 2019{ 2020 struct ospf *ospf = vty->index; 2021 2022 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) 2023 { 2024 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); 2025 ospf_spf_calculate_schedule (); 2026 } 2027 return CMD_SUCCESS; 2028} 2029 2030ALIAS (ospf_compatible_rfc1583, 2031 ospf_rfc1583_flag_cmd, 2032 "ospf rfc1583compatibility", 2033 "OSPF specific commands\n" 2034 "Enable the RFC1583Compatibility flag\n") 2035 2036ALIAS (no_ospf_compatible_rfc1583, 2037 no_ospf_rfc1583_flag_cmd, 2038 "no ospf rfc1583compatibility", 2039 NO_STR 2040 "OSPF specific commands\n" 2041 "Disable the RFC1583Compatibility flag\n") 2042 2043DEFUN (timers_spf, 2044 timers_spf_cmd, 2045 "timers spf <0-4294967295> <0-4294967295>", 2046 "Adjust routing timers\n" 2047 "OSPF SPF timers\n" 2048 "Delay between receiving a change to SPF calculation\n" 2049 "Hold time between consecutive SPF calculations\n") 2050{ 2051 struct ospf *ospf = vty->index; 2052 u_int32_t delay, hold; 2053 2054 VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]); 2055 VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]); 2056 2057 ospf_timers_spf_set (ospf, delay, hold); 2058 2059 return CMD_SUCCESS; 2060} 2061 2062DEFUN (no_timers_spf, 2063 no_timers_spf_cmd, 2064 "no timers spf", 2065 NO_STR 2066 "Adjust routing timers\n" 2067 "OSPF SPF timers\n") 2068{ 2069 ospf_top->spf_delay = OSPF_SPF_DELAY_DEFAULT; 2070 ospf_top->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT; 2071 2072 return CMD_SUCCESS; 2073} 2074 2075 2076DEFUN (neighbor, 2077 neighbor_cmd, 2078 "neighbor A.B.C.D", 2079 NEIGHBOR_STR 2080 "Neighbor IP address\n") 2081{ 2082 struct ospf *ospf = vty->index; 2083 struct in_addr nbr_addr; 2084 int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; 2085 int interval = OSPF_POLL_INTERVAL_DEFAULT; 2086 2087 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); 2088 2089 if (argc > 1) 2090 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); 2091 2092 if (argc > 2) 2093 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); 2094 2095 ospf_nbr_nbma_set (ospf, nbr_addr); 2096 if (argc > 1) 2097 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); 2098 if (argc > 2) 2099 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority); 2100 2101 return CMD_SUCCESS; 2102} 2103 2104ALIAS (neighbor, 2105 neighbor_priority_poll_interval_cmd, 2106 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", 2107 NEIGHBOR_STR 2108 "Neighbor IP address\n" 2109 "Neighbor Priority\n" 2110 "Priority\n" 2111 "Dead Neighbor Polling interval\n" 2112 "Seconds\n") 2113 2114ALIAS (neighbor, 2115 neighbor_priority_cmd, 2116 "neighbor A.B.C.D priority <0-255>", 2117 NEIGHBOR_STR 2118 "Neighbor IP address\n" 2119 "Neighbor Priority\n" 2120 "Seconds\n") 2121 2122DEFUN (neighbor_poll_interval, 2123 neighbor_poll_interval_cmd, 2124 "neighbor A.B.C.D poll-interval <1-65535>", 2125 NEIGHBOR_STR 2126 "Neighbor IP address\n" 2127 "Dead Neighbor Polling interval\n" 2128 "Seconds\n") 2129{ 2130 struct ospf *ospf = vty->index; 2131 struct in_addr nbr_addr; 2132 int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; 2133 int interval = OSPF_POLL_INTERVAL_DEFAULT; 2134 2135 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); 2136 2137 if (argc > 1) 2138 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); 2139 2140 if (argc > 2) 2141 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); 2142 2143 ospf_nbr_nbma_set (ospf, nbr_addr); 2144 if (argc > 1) 2145 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); 2146 if (argc > 2) 2147 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); 2148 2149 return CMD_SUCCESS; 2150} 2151 2152ALIAS (neighbor_poll_interval, 2153 neighbor_poll_interval_priority_cmd, 2154 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", 2155 NEIGHBOR_STR 2156 "Neighbor address\n" 2157 "OSPF dead-router polling interval\n" 2158 "Seconds\n" 2159 "OSPF priority of non-broadcast neighbor\n" 2160 "Priority\n") 2161 2162DEFUN (no_neighbor, 2163 no_neighbor_cmd, 2164 "no neighbor A.B.C.D", 2165 NO_STR 2166 NEIGHBOR_STR 2167 "Neighbor IP address\n") 2168{ 2169 struct ospf *ospf = vty->index; 2170 struct in_addr nbr_addr; 2171 int ret; 2172 2173 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); 2174 2175 ret = ospf_nbr_nbma_unset (ospf, nbr_addr); 2176 2177 return CMD_SUCCESS; 2178} 2179 2180ALIAS (no_neighbor, 2181 no_neighbor_priority_cmd, 2182 "no neighbor A.B.C.D priority <0-255>", 2183 NO_STR 2184 NEIGHBOR_STR 2185 "Neighbor IP address\n" 2186 "Neighbor Priority\n" 2187 "Priority\n") 2188 2189ALIAS (no_neighbor, 2190 no_neighbor_poll_interval_cmd, 2191 "no neighbor A.B.C.D poll-interval <1-65535>", 2192 NO_STR 2193 NEIGHBOR_STR 2194 "Neighbor IP address\n" 2195 "Dead Neighbor Polling interval\n" 2196 "Seconds\n") 2197 2198ALIAS (no_neighbor, 2199 no_neighbor_priority_pollinterval_cmd, 2200 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", 2201 NO_STR 2202 NEIGHBOR_STR 2203 "Neighbor IP address\n" 2204 "Neighbor Priority\n" 2205 "Priority\n" 2206 "Dead Neighbor Polling interval\n" 2207 "Seconds\n") 2208 2209 2210DEFUN (refresh_timer, refresh_timer_cmd, 2211 "refresh timer <10-1800>", 2212 "Adjust refresh parameters\n" 2213 "Set refresh timer\n" 2214 "Timer value in seconds\n") 2215{ 2216 struct ospf *ospf = vty->index; 2217 int interval; 2218 2219 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); 2220 interval = (interval / 10) * 10; 2221 2222 ospf_timers_refresh_set (ospf, interval); 2223 2224 return CMD_SUCCESS; 2225} 2226 2227DEFUN (no_refresh_timer, no_refresh_timer_val_cmd, 2228 "no refresh timer <10-1800>", 2229 "Adjust refresh parameters\n" 2230 "Unset refresh timer\n" 2231 "Timer value in seconds\n") 2232{ 2233 struct ospf *ospf = vty->index; 2234 int interval; 2235 2236 if (argc == 1) 2237 { 2238 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); 2239 2240 if (ospf->lsa_refresh_interval != interval || 2241 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) 2242 return CMD_SUCCESS; 2243 } 2244 2245 ospf_timers_refresh_unset (ospf); 2246 2247 return CMD_SUCCESS; 2248} 2249 2250ALIAS (no_refresh_timer, 2251 no_refresh_timer_cmd, 2252 "no refresh timer", 2253 "Adjust refresh parameters\n" 2254 "Unset refresh timer\n") 2255 2256DEFUN (auto_cost_reference_bandwidth, 2257 auto_cost_reference_bandwidth_cmd, 2258 "auto-cost reference-bandwidth <1-4294967>", 2259 "Calculate OSPF interface cost according to bandwidth\n" 2260 "Use reference bandwidth method to assign OSPF cost\n" 2261 "The reference bandwidth in terms of Mbits per second\n") 2262{ 2263 u_int32_t refbw; 2264 listnode node; 2265 2266 refbw = strtol (argv[0], NULL, 10); 2267 if (refbw < 1 || refbw > 4294967) 2268 { 2269 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); 2270 return CMD_WARNING; 2271 } 2272 2273 /* If reference bandwidth is changed. */ 2274 if ((refbw * 1000) == ospf_top->ref_bandwidth) 2275 return CMD_SUCCESS; 2276 2277 ospf_top->ref_bandwidth = refbw * 1000; 2278 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); 2279 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); 2280 2281 for (node = listhead (ospf_top->iflist); node; nextnode (node)) 2282 ospf_if_recalculate_output_cost (getdata (node)); 2283 2284 return CMD_SUCCESS; 2285} 2286 2287DEFUN (no_auto_cost_reference_bandwidth, 2288 no_auto_cost_reference_bandwidth_cmd, 2289 "no auto-cost reference-bandwidth", 2290 NO_STR 2291 "Calculate OSPF interface cost according to bandwidth\n" 2292 "Use reference bandwidth method to assign OSPF cost\n") 2293{ 2294 listnode node; 2295 2296 if (ospf_top->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) 2297 return CMD_SUCCESS; 2298 2299 ospf_top->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; 2300 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); 2301 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); 2302 2303 2304 for (node = listhead (ospf_top->iflist); node; nextnode (node)) 2305 ospf_if_recalculate_output_cost (getdata (node)); 2306 2307 return CMD_SUCCESS; 2308} 2309 2310 2311DEFUN (clear_ip_ospf_neighbor, 2312 clear_ip_ospf_neighbor_cmd, 2313 "clear ip ospf neighbor A.B.C.D", 2314 "Reset functions\n" 2315 "IP\n" 2316 "Clear OSPF\n" 2317 "Neighbor list\n" 2318 "Neighbor ID\n") 2319{ 2320 listnode node; 2321 struct ospf_neighbor *nbr; 2322 struct in_addr router_id; 2323 int ret; 2324 2325 ret = inet_aton (argv[0], &router_id); 2326 if (!ret) 2327 { 2328 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); 2329 return CMD_WARNING; 2330 } 2331 2332 for (node = listhead (ospf_top->oiflist); node; nextnode (node)) 2333 { 2334 struct ospf_interface *oi = getdata (node); 2335 2336 nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id); 2337 2338 if (nbr) 2339 { 2340 OSPF_NSM_EVENT_SCHEDULE (nbr, NSM_SeqNumberMismatch); 2341 vty_out (vty, "clear neighbor %s%s", argv[0], VTY_NEWLINE); 2342 break; 2343 } 2344 } 2345 2346 return CMD_SUCCESS; 2347} 2348 2349char *ospf_abr_type_descr_str[] = 2350{ 2351 "Unknown", 2352 "Standard (RFC2328)", 2353 "Alternative IBM", 2354 "Alternative Cisco", 2355 "Alternative Shortcut" 2356}; 2357 2358char *ospf_shortcut_mode_descr_str[] = 2359{ 2360 "Default", 2361 "Enabled", 2362 "Disabled" 2363}; 2364 2365 2366 2367void 2368show_ip_ospf_area (struct vty *vty, struct ospf_area *area) 2369{ 2370 /* Show Area ID. */ 2371 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); 2372 2373 /* Show Area type/mode. */ 2374 if (OSPF_IS_AREA_BACKBONE (area)) 2375 vty_out (vty, " (Backbone)%s", VTY_NEWLINE); 2376 else 2377 { 2378 if (area->external_routing == OSPF_AREA_STUB) 2379 vty_out (vty, " (Stub%s%s)", 2380 area->no_summary ? ", no summary" : "", 2381 area->shortcut_configured ? "; " : ""); 2382 2383#ifdef HAVE_NSSA 2384 2385 else 2386 if (area->external_routing == OSPF_AREA_NSSA) 2387 vty_out (vty, " (NSSA%s%s)", 2388 area->no_summary ? ", no summary" : "", 2389 area->shortcut_configured ? "; " : ""); 2390#endif /* HAVE_NSSA */ 2391 2392 vty_out (vty, "%s", VTY_NEWLINE); 2393 vty_out (vty, " Shortcutting mode: %s", 2394 ospf_shortcut_mode_descr_str[area->shortcut_configured]); 2395 vty_out (vty, ", S-bit consensus: %s%s", 2396 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); 2397 } 2398 2399 /* Show number of interfaces. */ 2400 vty_out (vty, " Number of interfaces in this area: Total: %d, " 2401 "Active: %d%s", listcount (area->oiflist), 2402 area->act_ints, VTY_NEWLINE); 2403 2404#ifdef HAVE_NSSA 2405 if (area->external_routing == OSPF_AREA_NSSA) 2406 { 2407 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE); 2408 if (! OSPF_IS_ABR) 2409 vty_out (vty, " It is not ABR, therefore not Translator. %s", 2410 VTY_NEWLINE); 2411 else 2412 { 2413 if (area->NSSATranslator) 2414 vty_out (vty, " We are an ABR and the NSSA Elected Translator. %s", VTY_NEWLINE); 2415 else 2416 vty_out (vty, " We are an ABR, but not the NSSA Elected Translator. %s", VTY_NEWLINE); 2417 } 2418 } 2419#endif /* HAVE_NSSA */ 2420 2421 /* Show number of fully adjacent neighbors. */ 2422 vty_out (vty, " Number of fully adjacent neighbors in this area:" 2423 " %d%s", area->full_nbrs, VTY_NEWLINE); 2424 2425 /* Show authentication type. */ 2426 vty_out (vty, " Area has "); 2427 if (area->auth_type == OSPF_AUTH_NULL) 2428 vty_out (vty, "no authentication%s", VTY_NEWLINE); 2429 else if (area->auth_type == OSPF_AUTH_SIMPLE) 2430 vty_out (vty, "simple password authentication%s", VTY_NEWLINE); 2431 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) 2432 vty_out (vty, "message digest authentication%s", VTY_NEWLINE); 2433 2434 if (!OSPF_IS_AREA_BACKBONE (area)) 2435 vty_out (vty, " Number of full virtual adjacencies going through" 2436 " this area: %d%s", area->full_vls, VTY_NEWLINE); 2437 2438 /* Show SPF calculation times. */ 2439 vty_out (vty, " SPF algorithm executed %d times%s", 2440 area->spf_calculation, VTY_NEWLINE); 2441 2442 /* Show number of LSA. */ 2443 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); 2444 2445 vty_out (vty, "%s", VTY_NEWLINE); 2446} 2447 2448DEFUN (show_ip_ospf, 2449 show_ip_ospf_cmd, 2450 "show ip ospf", 2451 SHOW_STR 2452 IP_STR 2453 "OSPF information\n") 2454{ 2455 listnode node; 2456 struct ospf_area * area; 2457 2458 /* Check OSPF is enable. */ 2459 if (ospf_top == NULL) 2460 { 2461 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); 2462 return CMD_SUCCESS; 2463 } 2464 2465 /* Show Router ID. */ 2466 vty_out (vty, " OSPF Routing Process, Router ID: %s%s", 2467 inet_ntoa (ospf_top->router_id), 2468 VTY_NEWLINE); 2469 2470 /* Show capability. */ 2471 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); 2472 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); 2473 vty_out (vty, " RFC1583Compatibility flag is %s%s", 2474 CHECK_FLAG (ospf_top->config, OSPF_RFC1583_COMPATIBLE) ? 2475 "enabled" : "disabled", VTY_NEWLINE); 2476#ifdef HAVE_OPAQUE_LSA 2477 vty_out (vty, " OpaqueCapability flag is %s%s%s", 2478 CHECK_FLAG (ospf_top->config, OSPF_OPAQUE_CAPABLE) ? 2479 "enabled" : "disabled", 2480 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf_top->opaque) ? 2481 " (origination blocked)" : "", 2482 VTY_NEWLINE); 2483#endif /* HAVE_OPAQUE_LSA */ 2484 2485 /* Show SPF timers. */ 2486 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s", 2487 ospf_top->spf_delay, ospf_top->spf_holdtime, VTY_NEWLINE); 2488 2489 /* Show refresh parameters. */ 2490 vty_out (vty, " Refresh timer %d secs%s", 2491 ospf_top->lsa_refresh_interval, VTY_NEWLINE); 2492 2493 /* Show ABR/ASBR flags. */ 2494 if (CHECK_FLAG (ospf_top->flags, OSPF_FLAG_ABR)) 2495 vty_out (vty, " This router is an ABR, ABR type is: %s%s", 2496 ospf_abr_type_descr_str[ospf_top->abr_type], VTY_NEWLINE); 2497 2498 if (CHECK_FLAG (ospf_top->flags, OSPF_FLAG_ASBR)) 2499 vty_out (vty, " This router is an ASBR " 2500 "(injecting external routing information)%s", VTY_NEWLINE); 2501 2502 /* Show Number of AS-external-LSAs. */ 2503 vty_out (vty, " Number of external LSA %ld%s", 2504 ospf_lsdb_count_all (ospf_top->lsdb), VTY_NEWLINE); 2505 2506 /* Show number of areas attached. */ 2507 vty_out (vty, " Number of areas attached to this router: %d%s%s", 2508 listcount (ospf_top->areas), VTY_NEWLINE, VTY_NEWLINE); 2509 2510 /* Show each area status. */ 2511 for (node = listhead (ospf_top->areas); node; nextnode (node)) 2512 if ((area = getdata (node)) != NULL) 2513 show_ip_ospf_area (vty, area); 2514 2515 return CMD_SUCCESS; 2516} 2517 2518 2519void 2520show_ip_ospf_interface_sub (struct vty *vty, struct interface *ifp) 2521{ 2522 struct ospf_neighbor *nbr; 2523 int oi_count; 2524 struct route_node *rn; 2525 char buf[9]; 2526 2527 oi_count = ospf_oi_count (ifp); 2528 2529 /* Is interface up? */ 2530 if (if_is_up (ifp)) 2531 vty_out (vty, "%s is up, line protocol is up%s", ifp->name, VTY_NEWLINE); 2532 else 2533 { 2534 vty_out (vty, "%s is down, line protocol is down%s", ifp->name, 2535 VTY_NEWLINE); 2536 2537 2538 if (oi_count == 0) 2539 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); 2540 else 2541 vty_out (vty, " OSPF is enabled, but not running on this interface%s", 2542 VTY_NEWLINE); 2543 return; 2544 } 2545 2546 /* Is interface OSPF enabled? */ 2547 if (oi_count == 0) 2548 { 2549 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); 2550 return; 2551 } 2552 2553 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) 2554 { 2555 struct ospf_interface *oi = rn->info; 2556 2557 if (oi == NULL) 2558 continue; 2559 2560 /* Show OSPF interface information. */ 2561 vty_out (vty, " Internet Address %s/%d,", 2562 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); 2563 2564 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), 2565 VTY_NEWLINE); 2566 2567 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", 2568 inet_ntoa (ospf_top->router_id), ospf_network_type_str[oi->type], 2569 oi->output_cost, VTY_NEWLINE); 2570 2571 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", 2572 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), 2573 PRIORITY (oi), VTY_NEWLINE); 2574 2575 /* Show DR information. */ 2576 if (DR (oi).s_addr == 0) 2577 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); 2578 else 2579 { 2580 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); 2581 if (nbr == NULL) 2582 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); 2583 else 2584 { 2585 vty_out (vty, " Designated Router (ID) %s,", 2586 inet_ntoa (nbr->router_id)); 2587 vty_out (vty, " Interface Address %s%s", 2588 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); 2589 } 2590 } 2591 2592 /* Show BDR information. */ 2593 if (BDR (oi).s_addr == 0) 2594 vty_out (vty, " No backup designated router on this network%s", 2595 VTY_NEWLINE); 2596 else 2597 { 2598 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); 2599 if (nbr == NULL) 2600 vty_out (vty, " No backup designated router on this network%s", 2601 VTY_NEWLINE); 2602 else 2603 { 2604 vty_out (vty, " Backup Designated Router (ID) %s,", 2605 inet_ntoa (nbr->router_id)); 2606 vty_out (vty, " Interface Address %s%s", 2607 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); 2608 } 2609 } 2610 vty_out (vty, " Timer intervals configured,"); 2611 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s", 2612 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait), 2613 OSPF_IF_PARAM (oi, v_wait), 2614 OSPF_IF_PARAM (oi, retransmit_interval), 2615 VTY_NEWLINE); 2616 2617 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE) 2618 vty_out (vty, " Hello due in %s%s", 2619 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE); 2620 else /* OSPF_IF_PASSIVE is set */ 2621 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); 2622 2623 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", 2624 ospf_nbr_count (oi->nbrs, 0), ospf_nbr_count (oi->nbrs, NSM_Full), 2625 VTY_NEWLINE); 2626 } 2627} 2628 2629DEFUN (show_ip_ospf_interface, 2630 show_ip_ospf_interface_cmd, 2631 "show ip ospf interface [INTERFACE]", 2632 SHOW_STR 2633 IP_STR 2634 "OSPF information\n" 2635 "Interface information\n" 2636 "Interface name\n") 2637{ 2638 struct interface *ifp; 2639 listnode node; 2640 2641 /* Show All Interfaces. */ 2642 if (argc == 0) 2643 for (node = listhead (iflist); node; nextnode (node)) 2644 show_ip_ospf_interface_sub (vty, node->data); 2645 /* Interface name is specified. */ 2646 else 2647 { 2648 if ((ifp = if_lookup_by_name (argv[0])) == NULL) 2649 vty_out (vty, "No such interface name%s", VTY_NEWLINE); 2650 else 2651 show_ip_ospf_interface_sub (vty, ifp); 2652 } 2653 2654 return CMD_SUCCESS; 2655} 2656 2657void 2658show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) 2659{ 2660 struct route_node *rn; 2661 struct ospf_neighbor *nbr; 2662 char msgbuf[16]; 2663 char timebuf[9]; 2664 2665 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) 2666 if ((nbr = rn->info)) 2667 /* Do not show myself. */ 2668 if (nbr != oi->nbr_self) 2669 /* Down state is not shown. */ 2670 if (nbr->state != NSM_Down) 2671 { 2672 ospf_nbr_state_message (nbr, msgbuf, 16); 2673 2674 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) 2675 vty_out (vty, "%-15s %3d %-15s %8s ", 2676 "-", nbr->priority, 2677 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9)); 2678 else 2679 vty_out (vty, "%-15s %3d %-15s %8s ", 2680 inet_ntoa (nbr->router_id), nbr->priority, 2681 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9)); 2682 vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); 2683 vty_out (vty, "%-15s %5ld %5ld %5d%s", 2684 IF_NAME (oi), ospf_ls_retransmit_count (nbr), 2685 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), 2686 VTY_NEWLINE); 2687 } 2688} 2689 2690DEFUN (show_ip_ospf_neighbor, 2691 show_ip_ospf_neighbor_cmd, 2692 "show ip ospf neighbor", 2693 SHOW_STR 2694 IP_STR 2695 "OSPF information\n" 2696 "Neighbor list\n") 2697{ 2698 listnode node; 2699 2700 if (!ospf_top) 2701 { 2702 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); 2703 return CMD_SUCCESS; 2704 } 2705 2706 /* Show All neighbors. */ 2707 vty_out (vty, "%sNeighbor ID Pri State Dead " 2708 "Time Address Interface RXmtL " 2709 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); 2710 2711 for (node = listhead (ospf_top->oiflist); node; nextnode (node)) 2712 show_ip_ospf_neighbor_sub (vty, getdata (node)); 2713 2714 return CMD_SUCCESS; 2715} 2716 2717DEFUN (show_ip_ospf_neighbor_all, 2718 show_ip_ospf_neighbor_all_cmd, 2719 "show ip ospf neighbor all", 2720 SHOW_STR 2721 IP_STR 2722 "OSPF information\n" 2723 "Neighbor list\n" 2724 "include down status neighbor\n") 2725{ 2726 listnode node; 2727 2728 if (!ospf_top) 2729 { 2730 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); 2731 return CMD_SUCCESS; 2732 } 2733 2734 /* Show All neighbors. */ 2735 vty_out (vty, "%sNeighbor ID Pri State Dead " 2736 "Time Address Interface RXmtL " 2737 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); 2738 2739 for (node = listhead (ospf_top->oiflist); node; nextnode (node)) 2740 { 2741 struct ospf_interface *oi = getdata (node); 2742 listnode nbr_node; 2743 2744 show_ip_ospf_neighbor_sub (vty, oi); 2745 2746 /* print Down neighbor status */ 2747 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node)) 2748 { 2749 struct ospf_nbr_nbma *nbr_nbma; 2750 2751 nbr_nbma = getdata (nbr_node); 2752 2753 if (nbr_nbma->nbr == NULL 2754 || nbr_nbma->nbr->state == NSM_Down) 2755 { 2756 vty_out (vty, "%-15s %3d %-15s %8s ", 2757 "-", nbr_nbma->priority, "Down", "-"); 2758 vty_out (vty, "%-15s %-15s %5d %5d %5d%s", 2759 inet_ntoa (nbr_nbma->addr), IF_NAME (oi), 2760 0, 0, 0, VTY_NEWLINE); 2761 } 2762 } 2763 } 2764 2765 return CMD_SUCCESS; 2766} 2767 2768DEFUN (show_ip_ospf_neighbor_int, 2769 show_ip_ospf_neighbor_int_cmd, 2770 "show ip ospf neighbor A.B.C.D", 2771 SHOW_STR 2772 IP_STR 2773 "OSPF information\n" 2774 "Neighbor list\n" 2775 "Interface name\n") 2776{ 2777 struct ospf_interface *oi; 2778 struct in_addr addr; 2779 int ret; 2780 2781 if (!ospf_top) 2782 { 2783 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); 2784 return CMD_SUCCESS; 2785 } 2786 2787 ret = inet_aton (argv[0], &addr); 2788 if (!ret) 2789 { 2790 vty_out (vty, "Please specify interface address by A.B.C.D%s", 2791 VTY_NEWLINE); 2792 return CMD_WARNING; 2793 } 2794 2795 if ((oi = ospf_if_is_configured (&addr)) == NULL) 2796 vty_out (vty, "No such interface address%s", VTY_NEWLINE); 2797 else 2798 { 2799 vty_out (vty, "%sNeighbor ID Pri State Dead " 2800 "Time Address Interface RXmtL " 2801 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); 2802 show_ip_ospf_neighbor_sub (vty, oi); 2803 } 2804 2805 return CMD_SUCCESS; 2806} 2807 2808void 2809show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, 2810 struct ospf_nbr_nbma *nbr_nbma) 2811{ 2812 char timebuf[9]; 2813 2814 /* Show neighbor ID. */ 2815 vty_out (vty, " Neighbor %s,", "-"); 2816 2817 /* Show interface address. */ 2818 vty_out (vty, " interface address %s%s", 2819 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); 2820 /* Show Area ID. */ 2821 vty_out (vty, " In the area %s via interface %s%s", 2822 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); 2823 /* Show neighbor priority and state. */ 2824 vty_out (vty, " Neighbor priority is %d, State is %s,", 2825 nbr_nbma->priority, "Down"); 2826 /* Show state changes. */ 2827 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); 2828 2829 /* Show PollInterval */ 2830 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); 2831 2832 /* Show poll-interval timer. */ 2833 vty_out (vty, " Poll timer due in %s%s", 2834 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE); 2835 2836 /* Show poll-interval timer thread. */ 2837 vty_out (vty, " Thread Poll Timer %s%s", 2838 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); 2839} 2840 2841void 2842show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, 2843 struct ospf_neighbor *nbr) 2844{ 2845 char timebuf[9]; 2846 2847 /* Show neighbor ID. */ 2848 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) 2849 vty_out (vty, " Neighbor %s,", "-"); 2850 else 2851 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); 2852 2853 /* Show interface address. */ 2854 vty_out (vty, " interface address %s%s", 2855 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); 2856 /* Show Area ID. */ 2857 vty_out (vty, " In the area %s via interface %s%s", 2858 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); 2859 /* Show neighbor priority and state. */ 2860 vty_out (vty, " Neighbor priority is %d, State is %s,", 2861 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); 2862 /* Show state changes. */ 2863 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); 2864 2865 /* Show Designated Rotuer ID. */ 2866 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); 2867 /* Show Backup Designated Rotuer ID. */ 2868 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); 2869 /* Show options. */ 2870 vty_out (vty, " Options %d %s%s", nbr->options, 2871 ospf_options_dump (nbr->options), VTY_NEWLINE); 2872 /* Show Router Dead interval timer. */ 2873 vty_out (vty, " Dead timer due in %s%s", 2874 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE); 2875 /* Show Database Summary list. */ 2876 vty_out (vty, " Database Summary List %d%s", 2877 ospf_db_summary_count (nbr), VTY_NEWLINE); 2878 /* Show Link State Request list. */ 2879 vty_out (vty, " Link State Request List %ld%s", 2880 ospf_ls_request_count (nbr), VTY_NEWLINE); 2881 /* Show Link State Retransmission list. */ 2882 vty_out (vty, " Link State Retransmission List %ld%s", 2883 ospf_ls_retransmit_count (nbr), VTY_NEWLINE); 2884 /* Show inactivity timer thread. */ 2885 vty_out (vty, " Thread Inactivity Timer %s%s", 2886 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); 2887 /* Show Database Description retransmission thread. */ 2888 vty_out (vty, " Thread Database Description Retransmision %s%s", 2889 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); 2890 /* Show Link State Request Retransmission thread. */ 2891 vty_out (vty, " Thread Link State Request Retransmission %s%s", 2892 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); 2893 /* Show Link State Update Retransmission thread. */ 2894 vty_out (vty, " Thread Link State Update Retransmission %s%s%s", 2895 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); 2896} 2897 2898DEFUN (show_ip_ospf_neighbor_id, 2899 show_ip_ospf_neighbor_id_cmd, 2900 "show ip ospf neighbor A.B.C.D", 2901 SHOW_STR 2902 IP_STR 2903 "OSPF information\n" 2904 "Neighbor list\n" 2905 "Neighbor ID\n") 2906{ 2907 listnode node; 2908 struct ospf_neighbor *nbr; 2909 struct in_addr router_id; 2910 int ret; 2911 2912 ret = inet_aton (argv[0], &router_id); 2913 if (!ret) 2914 { 2915 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); 2916 return CMD_WARNING; 2917 } 2918 2919 for (node = listhead (ospf_top->oiflist); node; nextnode (node)) 2920 { 2921 struct ospf_interface *oi = getdata (node); 2922 2923 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) 2924 { 2925 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); 2926 return CMD_SUCCESS; 2927 } 2928 } 2929 2930 /* Nothing to show. */ 2931 return CMD_SUCCESS; 2932} 2933 2934DEFUN (show_ip_ospf_neighbor_detail, 2935 show_ip_ospf_neighbor_detail_cmd, 2936 "show ip ospf neighbor detail", 2937 SHOW_STR 2938 IP_STR 2939 "OSPF information\n" 2940 "Neighbor list\n" 2941 "detail of all neighbors\n") 2942{ 2943 listnode node; 2944 2945 if (!ospf_top) 2946 return CMD_SUCCESS; 2947 2948 for (node = listhead (ospf_top->oiflist); node; nextnode (node)) 2949 { 2950 struct ospf_interface *oi = getdata (node); 2951 struct route_node *rn; 2952 struct ospf_neighbor *nbr; 2953 2954 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) 2955 if ((nbr = rn->info)) 2956 if (nbr != oi->nbr_self) 2957 if (nbr->state != NSM_Down) 2958 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); 2959 } 2960 2961 return CMD_SUCCESS; 2962} 2963 2964DEFUN (show_ip_ospf_neighbor_detail_all, 2965 show_ip_ospf_neighbor_detail_all_cmd, 2966 "show ip ospf neighbor detail all", 2967 SHOW_STR 2968 IP_STR 2969 "OSPF information\n" 2970 "Neighbor list\n" 2971 "detail of all neighbors\n" 2972 "include down status neighbor\n") 2973{ 2974 listnode node; 2975 2976 if (!ospf_top) 2977 return CMD_SUCCESS; 2978 2979 for (node = listhead (ospf_top->oiflist); node; nextnode (node)) 2980 { 2981 struct ospf_interface *oi = getdata (node); 2982 struct route_node *rn; 2983 struct ospf_neighbor *nbr; 2984 2985 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) 2986 if ((nbr = rn->info)) 2987 if (nbr != oi->nbr_self) 2988 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) 2989 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); 2990 2991 if (oi->type == OSPF_IFTYPE_NBMA) 2992 { 2993 listnode nd; 2994 2995 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd)) 2996 { 2997 struct ospf_nbr_nbma *nbr_nbma = getdata (nd); 2998 if (nbr_nbma->nbr == NULL 2999 || nbr_nbma->nbr->state == NSM_Down) 3000 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); 3001 } 3002 } 3003 } 3004 3005 return CMD_SUCCESS; 3006} 3007 3008DEFUN (show_ip_ospf_neighbor_int_detail, 3009 show_ip_ospf_neighbor_int_detail_cmd, 3010 "show ip ospf neighbor A.B.C.D detail", 3011 SHOW_STR 3012 IP_STR 3013 "OSPF information\n" 3014 "Neighbor list\n" 3015 "Interface address\n" 3016 "detail of all neighbors") 3017{ 3018 struct ospf_interface *oi; 3019 struct in_addr addr; 3020 int ret; 3021 3022 ret = inet_aton (argv[0], &addr); 3023 if (!ret) 3024 { 3025 vty_out (vty, "Please specify interface address by A.B.C.D%s", 3026 VTY_NEWLINE); 3027 return CMD_WARNING; 3028 } 3029 3030 if ((oi = ospf_if_is_configured (&addr)) == NULL) 3031 vty_out (vty, "No such interface address%s", VTY_NEWLINE); 3032 else 3033 { 3034 struct route_node *rn; 3035 struct ospf_neighbor *nbr; 3036 3037 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) 3038 if ((nbr = rn->info)) 3039 if (nbr != oi->nbr_self) 3040 if (nbr->state != NSM_Down) 3041 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); 3042 } 3043 3044 return CMD_SUCCESS; 3045} 3046 3047 3048/* Show functions */ 3049int 3050show_lsa_summary (struct ospf_lsa *lsa, void *v, int self) 3051{ 3052 struct vty *vty = (struct vty *) v; 3053 struct router_lsa *rl; 3054 struct summary_lsa *sl; 3055 struct as_external_lsa *asel; 3056 struct prefix_ipv4 p; 3057 3058 if (lsa != NULL) 3059 /* If self option is set, check LSA self flag. */ 3060 if (self == 0 || IS_LSA_SELF (lsa)) 3061 { 3062 /* LSA common part show. */ 3063 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); 3064 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", 3065 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), 3066 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); 3067 /* LSA specific part show. */ 3068 switch (lsa->data->type) 3069 { 3070 case OSPF_ROUTER_LSA: 3071 rl = (struct router_lsa *) lsa->data; 3072 vty_out (vty, " %-d", ntohs (rl->links)); 3073 break; 3074 case OSPF_SUMMARY_LSA: 3075 sl = (struct summary_lsa *) lsa->data; 3076 3077 p.family = AF_INET; 3078 p.prefix = sl->header.id; 3079 p.prefixlen = ip_masklen (sl->mask); 3080 apply_mask_ipv4 (&p); 3081 3082 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); 3083 break; 3084 case OSPF_AS_EXTERNAL_LSA: 3085 asel = (struct as_external_lsa *) lsa->data; 3086 3087 p.family = AF_INET; 3088 p.prefix = asel->header.id; 3089 p.prefixlen = ip_masklen (asel->mask); 3090 apply_mask_ipv4 (&p); 3091 3092 vty_out (vty, " %s %s/%d [0x%lx]", 3093 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", 3094 inet_ntoa (p.prefix), p.prefixlen, 3095 (u_long)ntohl (asel->e[0].route_tag)); 3096 break; 3097 case OSPF_NETWORK_LSA: 3098 case OSPF_ASBR_SUMMARY_LSA: 3099#ifdef HAVE_OPAQUE_LSA 3100 case OSPF_OPAQUE_LINK_LSA: 3101 case OSPF_OPAQUE_AREA_LSA: 3102 case OSPF_OPAQUE_AS_LSA: 3103#endif /* HAVE_OPAQUE_LSA */ 3104 default: 3105 break; 3106 } 3107 vty_out (vty, VTY_NEWLINE); 3108 } 3109 3110 return 0; 3111} 3112 3113char *show_database_desc[] = 3114{ 3115 "unknown", 3116 "Router Link States", 3117 "Net Link States", 3118 "Summary Link States", 3119 "ASBR-Summary Link States", 3120 "AS External Link States", 3121#if defined (HAVE_NSSA) || defined (HAVE_OPAQUE_LSA) 3122 "Group Membership LSA", 3123 "NSSA-external Link States", 3124#endif /* HAVE_NSSA */ 3125#ifdef HAVE_OPAQUE_LSA 3126 "Type-8 LSA", 3127 "Link-Local Opaque-LSA", 3128 "Area-Local Opaque-LSA", 3129 "AS-external Opaque-LSA", 3130#endif /* HAVE_OPAQUE_LSA */ 3131}; 3132 3133#define SHOW_OSPF_COMMON_HEADER \ 3134 "Link ID ADV Router Age Seq# CkSum" 3135 3136char *show_database_header[] = 3137{ 3138 "", 3139 "Link ID ADV Router Age Seq# CkSum Link count", 3140 "Link ID ADV Router Age Seq# CkSum", 3141 "Link ID ADV Router Age Seq# CkSum Route", 3142 "Link ID ADV Router Age Seq# CkSum", 3143 "Link ID ADV Router Age Seq# CkSum Route", 3144#ifdef HAVE_NSSA 3145 " --- header for Group Member ----", 3146 "Link ID ADV Router Age Seq# CkSum Route", 3147#endif /* HAVE_NSSA */ 3148#ifdef HAVE_OPAQUE_LSA 3149#ifndef HAVE_NSSA 3150 " --- type-6 ---", 3151 " --- type-7 ---", 3152#endif /* HAVE_NSSA */ 3153 " --- type-8 ---", 3154 "Opaque-Type/Id ADV Router Age Seq# CkSum", 3155 "Opaque-Type/Id ADV Router Age Seq# CkSum", 3156 "Opaque-Type/Id ADV Router Age Seq# CkSum", 3157#endif /* HAVE_OPAQUE_LSA */ 3158}; 3159 3160void 3161show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) 3162{ 3163 struct router_lsa *rlsa = (struct router_lsa*) lsa->data; 3164 3165 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); 3166 vty_out (vty, " Options: %d%s", lsa->data->options, VTY_NEWLINE); 3167 3168 if (lsa->data->type == OSPF_ROUTER_LSA) 3169 { 3170 vty_out (vty, " Flags: 0x%x" , rlsa->flags); 3171 3172 if (rlsa->flags) 3173 vty_out (vty, " :%s%s%s%s", 3174 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", 3175 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", 3176 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", 3177 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); 3178 3179 vty_out (vty, "%s", VTY_NEWLINE); 3180 } 3181 vty_out (vty, " LS Type: %s%s", 3182 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); 3183 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), 3184 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); 3185 vty_out (vty, " Advertising Router: %s%s", 3186 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); 3187 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), 3188 VTY_NEWLINE); 3189 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), 3190 VTY_NEWLINE); 3191 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); 3192} 3193 3194char *link_type_desc[] = 3195{ 3196 "(null)", 3197 "another Router (point-to-point)", 3198 "a Transit Network", 3199 "Stub Network", 3200 "a Virtual Link", 3201}; 3202 3203char *link_id_desc[] = 3204{ 3205 "(null)", 3206 "Neighboring Router ID", 3207 "Designated Router address", 3208 "Network/subnet number", 3209 "Neighboring Router ID", 3210}; 3211 3212char *link_data_desc[] = 3213{ 3214 "(null)", 3215 "Router Interface address", 3216 "Router Interface address", 3217 "Network Mask", 3218 "Router Interface address", 3219}; 3220 3221/* Show router-LSA each Link information. */ 3222void 3223show_ip_ospf_database_router_links (struct vty *vty, 3224 struct router_lsa *rl) 3225{ 3226 int len, i, type; 3227 3228 len = ntohs (rl->header.length) - 4; 3229 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) 3230 { 3231 type = rl->link[i].type; 3232 3233 vty_out (vty, " Link connected to: %s%s", 3234 link_type_desc[type], VTY_NEWLINE); 3235 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], 3236 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); 3237 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], 3238 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); 3239 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); 3240 vty_out (vty, " TOS 0 Metric: %d%s", 3241 ntohs (rl->link[i].metric), VTY_NEWLINE); 3242 vty_out (vty, "%s", VTY_NEWLINE); 3243 } 3244} 3245 3246/* Show router-LSA detail information. */ 3247int 3248show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) 3249{ 3250 if (lsa != NULL) 3251 { 3252 struct router_lsa *rl = (struct router_lsa *) lsa->data; 3253 3254 show_ip_ospf_database_header (vty, lsa); 3255 3256 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), 3257 VTY_NEWLINE, VTY_NEWLINE); 3258 3259 show_ip_ospf_database_router_links (vty, rl); 3260 } 3261 3262 return 0; 3263} 3264 3265/* Show network-LSA detail information. */ 3266int 3267show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) 3268{ 3269 int length, i; 3270 3271 if (lsa != NULL) 3272 { 3273 struct network_lsa *nl = (struct network_lsa *) lsa->data; 3274 3275 show_ip_ospf_database_header (vty, lsa); 3276 3277 vty_out (vty, " Network Mask: /%d%s", 3278 ip_masklen (nl->mask), VTY_NEWLINE); 3279 3280 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; 3281 3282 for (i = 0; length > 0; i++, length -= 4) 3283 vty_out (vty, " Attached Router: %s%s", 3284 inet_ntoa (nl->routers[i]), VTY_NEWLINE); 3285 3286 vty_out (vty, "%s", VTY_NEWLINE); 3287 } 3288 3289 return 0; 3290} 3291 3292/* Show summary-LSA detail information. */ 3293int 3294show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) 3295{ 3296 if (lsa != NULL) 3297 { 3298 struct summary_lsa *sl = (struct summary_lsa *) lsa->data; 3299 3300 show_ip_ospf_database_header (vty, lsa); 3301 3302 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), 3303 VTY_NEWLINE); 3304 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), 3305 VTY_NEWLINE); 3306 } 3307 3308 return 0; 3309} 3310 3311/* Show summary-ASBR-LSA detail information. */ 3312int 3313show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) 3314{ 3315 if (lsa != NULL) 3316 { 3317 struct summary_lsa *sl = (struct summary_lsa *) lsa->data; 3318 3319 show_ip_ospf_database_header (vty, lsa); 3320 3321 vty_out (vty, " Network Mask: /%d%s", 3322 ip_masklen (sl->mask), VTY_NEWLINE); 3323 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), 3324 VTY_NEWLINE); 3325 } 3326 3327 return 0; 3328} 3329 3330/* Show AS-external-LSA detail information. */ 3331int 3332show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) 3333{ 3334 if (lsa != NULL) 3335 { 3336 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; 3337 3338 show_ip_ospf_database_header (vty, lsa); 3339 3340 vty_out (vty, " Network Mask: /%d%s", 3341 ip_masklen (al->mask), VTY_NEWLINE); 3342 vty_out (vty, " Metric Type: %s%s", 3343 IS_EXTERNAL_METRIC (al->e[0].tos) ? 3344 "2 (Larger than any link state path)" : "1", VTY_NEWLINE); 3345 vty_out (vty, " TOS: 0%s", VTY_NEWLINE); 3346 vty_out (vty, " Metric: %d%s", 3347 GET_METRIC (al->e[0].metric), VTY_NEWLINE); 3348 vty_out (vty, " Forward Address: %s%s", 3349 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); 3350 3351 vty_out (vty, " External Route Tag: %lu%s%s", 3352 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); 3353 } 3354 3355 return 0; 3356} 3357 3358#ifdef HAVE_NSSA 3359int 3360show_as_external_lsa_stdvty (struct ospf_lsa *lsa) 3361{ 3362 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; 3363 3364 /* show_ip_ospf_database_header (vty, lsa); */ 3365 3366 zlog_info( " Network Mask: /%d%s", 3367 ip_masklen (al->mask), "\n"); 3368 zlog_info( " Metric Type: %s%s", 3369 IS_EXTERNAL_METRIC (al->e[0].tos) ? 3370 "2 (Larger than any link state path)" : "1", "\n"); 3371 zlog_info( " TOS: 0%s", "\n"); 3372 zlog_info( " Metric: %d%s", 3373 GET_METRIC (al->e[0].metric), "\n"); 3374 zlog_info( " Forward Address: %s%s", 3375 inet_ntoa (al->e[0].fwd_addr), "\n"); 3376 3377 zlog_info( " External Route Tag: %u%s%s", 3378 ntohl (al->e[0].route_tag), "\n", "\n"); 3379 3380 return 0; 3381} 3382 3383/* Show AS-NSSA-LSA detail information. */ 3384int 3385show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) 3386{ 3387 if (lsa != NULL) 3388 { 3389 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; 3390 3391 show_ip_ospf_database_header (vty, lsa); 3392 3393 vty_out (vty, " Network Mask: /%d%s", 3394 ip_masklen (al->mask), VTY_NEWLINE); 3395 vty_out (vty, " Metric Type: %s%s", 3396 IS_EXTERNAL_METRIC (al->e[0].tos) ? 3397 "2 (Larger than any link state path)" : "1", VTY_NEWLINE); 3398 vty_out (vty, " TOS: 0%s", VTY_NEWLINE); 3399 vty_out (vty, " Metric: %d%s", 3400 GET_METRIC (al->e[0].metric), VTY_NEWLINE); 3401 vty_out (vty, " NSSA: Forward Address: %s%s", 3402 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); 3403 3404 vty_out (vty, " External Route Tag: %u%s%s", 3405 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); 3406 } 3407 3408 return 0; 3409} 3410 3411#endif /* HAVE_NSSA */ 3412 3413int 3414show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) 3415{ 3416 return 0; 3417} 3418 3419#ifdef HAVE_OPAQUE_LSA 3420int 3421show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) 3422{ 3423 if (lsa != NULL) 3424 { 3425 show_ip_ospf_database_header (vty, lsa); 3426 show_opaque_info_detail (vty, lsa); 3427 3428 vty_out (vty, "%s", VTY_NEWLINE); 3429 } 3430 return 0; 3431} 3432#endif /* HAVE_OPAQUE_LSA */ 3433 3434int (*show_function[])(struct vty *, struct ospf_lsa *) = 3435{ 3436 NULL, 3437 show_router_lsa_detail, 3438 show_network_lsa_detail, 3439 show_summary_lsa_detail, 3440 show_summary_asbr_lsa_detail, 3441 show_as_external_lsa_detail, 3442#ifdef HAVE_NSSA 3443 show_func_dummy, 3444 show_as_nssa_lsa_detail, /* almost same as external */ 3445#endif /* HAVE_NSSA */ 3446#ifdef HAVE_OPAQUE_LSA 3447#ifndef HAVE_NSSA 3448 show_func_dummy, 3449 show_func_dummy, 3450#endif /* HAVE_NSSA */ 3451 NULL, /* type-8 */ 3452 show_opaque_lsa_detail, 3453 show_opaque_lsa_detail, 3454 show_opaque_lsa_detail, 3455#endif /* HAVE_OPAQUE_LSA */ 3456}; 3457 3458void 3459show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, 3460 struct in_addr *adv_router) 3461{ 3462 memset (lp, 0, sizeof (struct prefix_ls)); 3463 lp->family = 0; 3464 if (id == NULL) 3465 lp->prefixlen = 0; 3466 else if (adv_router == NULL) 3467 { 3468 lp->prefixlen = 32; 3469 lp->id = *id; 3470 } 3471 else 3472 { 3473 lp->prefixlen = 64; 3474 lp->id = *id; 3475 lp->adv_router = *adv_router; 3476 } 3477} 3478 3479void 3480show_lsa_detail_proc (struct vty *vty, struct route_table *rt, 3481 struct in_addr *id, struct in_addr *adv_router) 3482{ 3483 struct prefix_ls lp; 3484 struct route_node *rn, *start; 3485 struct ospf_lsa *lsa; 3486 3487 show_lsa_prefix_set (vty, &lp, id, adv_router); 3488 start = route_node_get (rt, (struct prefix *) &lp); 3489 if (start) 3490 { 3491 route_lock_node (start); 3492 for (rn = start; rn; rn = route_next_until (rn, start)) 3493 if ((lsa = rn->info)) 3494 { 3495#ifdef HAVE_NSSA 3496 /* Stay away from any Local Translated Type-7 LSAs */ 3497 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) 3498 continue; 3499#endif /* HAVE_NSSA */ 3500 3501 if (show_function[lsa->data->type] != NULL) 3502 show_function[lsa->data->type] (vty, lsa); 3503 } 3504 route_unlock_node (start); 3505 } 3506} 3507 3508/* Show detail LSA information 3509 -- if id is NULL then show all LSAs. */ 3510void 3511show_lsa_detail (struct vty *vty, int type, 3512 struct in_addr *id, struct in_addr *adv_router) 3513{ 3514 listnode node; 3515 3516 switch (type) 3517 { 3518 case OSPF_AS_EXTERNAL_LSA: 3519#ifdef HAVE_OPAQUE_LSA 3520 case OSPF_OPAQUE_AS_LSA: 3521#endif /* HAVE_OPAQUE_LSA */ 3522 vty_out (vty, " %s %s%s", 3523 show_database_desc[type], 3524 VTY_NEWLINE, VTY_NEWLINE); 3525 show_lsa_detail_proc (vty, AS_LSDB (ospf_top, type), id, adv_router); 3526 break; 3527 default: 3528 for (node = listhead (ospf_top->areas); node; nextnode (node)) 3529 { 3530 struct ospf_area *area = node->data; 3531 vty_out (vty, "%s %s (Area %s)%s%s", 3532 VTY_NEWLINE, show_database_desc[type], 3533 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); 3534 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); 3535 } 3536 break; 3537 } 3538} 3539 3540void 3541show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, 3542 struct in_addr *adv_router) 3543{ 3544 struct route_node *rn; 3545 struct ospf_lsa *lsa; 3546 3547 for (rn = route_top (rt); rn; rn = route_next (rn)) 3548 if ((lsa = rn->info)) 3549 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) 3550 { 3551#ifdef HAVE_NSSA 3552 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) 3553 continue; 3554#endif /* HAVE_NSSA */ 3555 if (show_function[lsa->data->type] != NULL) 3556 show_function[lsa->data->type] (vty, lsa); 3557 } 3558} 3559 3560/* Show detail LSA information. */ 3561void 3562show_lsa_detail_adv_router (struct vty *vty, int type, 3563 struct in_addr *adv_router) 3564{ 3565 listnode node; 3566 3567 switch (type) 3568 { 3569 case OSPF_AS_EXTERNAL_LSA: 3570#ifdef HAVE_OPAQUE_LSA 3571 case OSPF_OPAQUE_AS_LSA: 3572#endif /* HAVE_OPAQUE_LSA */ 3573 vty_out (vty, " %s %s%s", 3574 show_database_desc[type], 3575 VTY_NEWLINE, VTY_NEWLINE); 3576 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf_top, type), 3577 adv_router); 3578 break; 3579 default: 3580 for (node = listhead (ospf_top->areas); node; nextnode (node)) 3581 { 3582 struct ospf_area *area = node->data; 3583 vty_out (vty, "%s %s (Area %s)%s%s", 3584 VTY_NEWLINE, show_database_desc[type], 3585 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); 3586 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), 3587 adv_router); 3588 } 3589 break; 3590 } 3591} 3592 3593void 3594show_ip_ospf_database_summary (struct vty *vty, int self) 3595{ 3596 listnode node; 3597 int type; 3598 3599 for (node = listhead (ospf_top->areas); node; nextnode (node)) 3600 { 3601 struct ospf_area *area = node->data; 3602 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) 3603 { 3604 switch (type) 3605 { 3606 case OSPF_AS_EXTERNAL_LSA: 3607#ifdef HAVE_OPAQUE_LSA 3608 case OSPF_OPAQUE_AS_LSA: 3609#endif /* HAVE_OPAQUE_LSA */ 3610 continue; 3611 default: 3612 break; 3613 } 3614 if (ospf_lsdb_count_self (area->lsdb, type) > 0 || 3615 (!self && ospf_lsdb_count (area->lsdb, type) > 0)) 3616 { 3617 vty_out (vty, " %s (Area %s)%s%s", 3618 show_database_desc[type], 3619 ospf_area_desc_string (area), 3620 VTY_NEWLINE, VTY_NEWLINE); 3621 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); 3622 3623 foreach_lsa (AREA_LSDB (area, type), vty, self, show_lsa_summary); 3624 3625 vty_out (vty, "%s", VTY_NEWLINE); 3626 } 3627 } 3628 } 3629 3630 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) 3631 { 3632 switch (type) 3633 { 3634 case OSPF_AS_EXTERNAL_LSA: 3635#ifdef HAVE_OPAQUE_LSA 3636 case OSPF_OPAQUE_AS_LSA: 3637#endif /* HAVE_OPAQUE_LSA */ 3638 break;; 3639 default: 3640 continue; 3641 } 3642 if (ospf_lsdb_count_self (ospf_top->lsdb, type) || 3643 (!self && ospf_lsdb_count (ospf_top->lsdb, type))) 3644 { 3645 vty_out (vty, " %s%s%s", 3646 show_database_desc[type], 3647 VTY_NEWLINE, VTY_NEWLINE); 3648 vty_out (vty, "%s%s", show_database_header[type], 3649 VTY_NEWLINE); 3650 foreach_lsa (AS_LSDB (ospf_top, type), vty, self, show_lsa_summary); 3651 vty_out (vty, "%s", VTY_NEWLINE); 3652 } 3653 } 3654 3655 vty_out (vty, "%s", VTY_NEWLINE); 3656} 3657 3658void 3659show_ip_ospf_database_maxage (struct vty *vty) 3660{ 3661 listnode node; 3662 struct ospf_lsa *lsa; 3663 3664 vty_out (vty, "%s MaxAge Link States:%s%s", 3665 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); 3666 3667 for (node = listhead (ospf_top->maxage_lsa); node; nextnode (node)) 3668 if ((lsa = node->data) != NULL) 3669 { 3670 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); 3671 vty_out (vty, "Link State ID: %s%s", 3672 inet_ntoa (lsa->data->id), VTY_NEWLINE); 3673 vty_out (vty, "Advertising Router: %s%s", 3674 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); 3675 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); 3676 vty_out (vty, "%s", VTY_NEWLINE); 3677 } 3678} 3679 3680#ifdef HAVE_NSSA 3681#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" 3682#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" 3683#else /* HAVE_NSSA */ 3684#define OSPF_LSA_TYPE_NSSA_DESC "" 3685#define OSPF_LSA_TYPE_NSSA_CMD_STR "" 3686#endif /* HAVE_NSSA */ 3687 3688#ifdef HAVE_OPAQUE_LSA 3689#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" 3690#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" 3691#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" 3692#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" 3693#else /* HAVE_OPAQUE_LSA */ 3694#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" 3695#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" 3696#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" 3697#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" 3698#endif /* HAVE_OPAQUE_LSA */ 3699 3700#define OSPF_LSA_TYPES_CMD_STR \ 3701 "asbr-summary|external|network|router|summary" \ 3702 OSPF_LSA_TYPE_NSSA_CMD_STR \ 3703 OSPF_LSA_TYPE_OPAQUE_CMD_STR 3704 3705#define OSPF_LSA_TYPES_DESC \ 3706 "ASBR summary link states\n" \ 3707 "External link states\n" \ 3708 "Network link states\n" \ 3709 "Router link states\n" \ 3710 "Network summary link states\n" \ 3711 OSPF_LSA_TYPE_NSSA_DESC \ 3712 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ 3713 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ 3714 OSPF_LSA_TYPE_OPAQUE_AS_DESC 3715 3716DEFUN (show_ip_ospf_database, 3717 show_ip_ospf_database_cmd, 3718 "show ip ospf database", 3719 SHOW_STR 3720 IP_STR 3721 "OSPF information\n" 3722 "Database summary\n") 3723{ 3724 int type, ret; 3725 struct in_addr id, adv_router; 3726 3727 if (ospf_top == NULL) 3728 return CMD_SUCCESS; 3729 3730 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, 3731 inet_ntoa (ospf_top->router_id), VTY_NEWLINE, VTY_NEWLINE); 3732 3733 /* Show all LSA. */ 3734 if (argc == 0) 3735 { 3736 show_ip_ospf_database_summary (vty, 0); 3737 return CMD_SUCCESS; 3738 } 3739 3740 /* Set database type to show. */ 3741 if (strncmp (argv[0], "r", 1) == 0) 3742 type = OSPF_ROUTER_LSA; 3743 else if (strncmp (argv[0], "ne", 2) == 0) 3744 type = OSPF_NETWORK_LSA; 3745#ifdef HAVE_NSSA 3746 else if (strncmp (argv[0], "ns", 2) == 0) 3747 type = OSPF_AS_NSSA_LSA; 3748#endif /* HAVE_NSSA */ 3749 else if (strncmp (argv[0], "su", 2) == 0) 3750 type = OSPF_SUMMARY_LSA; 3751 else if (strncmp (argv[0], "a", 1) == 0) 3752 type = OSPF_ASBR_SUMMARY_LSA; 3753 else if (strncmp (argv[0], "e", 1) == 0) 3754 type = OSPF_AS_EXTERNAL_LSA; 3755 else if (strncmp (argv[0], "se", 2) == 0) 3756 { 3757 show_ip_ospf_database_summary (vty, 1); 3758 return CMD_SUCCESS; 3759 } 3760 else if (strncmp (argv[0], "m", 1) == 0) 3761 { 3762 show_ip_ospf_database_maxage (vty); 3763 return CMD_SUCCESS; 3764 } 3765#ifdef HAVE_OPAQUE_LSA 3766 else if (strncmp (argv[0], "opaque-l", 8) == 0) 3767 type = OSPF_OPAQUE_LINK_LSA; 3768 else if (strncmp (argv[0], "opaque-a", 8) == 0) 3769 type = OSPF_OPAQUE_AREA_LSA; 3770 else if (strncmp (argv[0], "opaque-e", 8) == 0) 3771 type = OSPF_OPAQUE_AS_LSA; 3772#endif /* HAVE_OPAQUE_LSA */ 3773 else 3774 return CMD_WARNING; 3775 3776 /* `show ip ospf database LSA'. */ 3777 if (argc == 1) 3778 show_lsa_detail (vty, type, NULL, NULL); 3779 else if (argc >= 2) 3780 { 3781 ret = inet_aton (argv[1], &id); 3782 if (!ret) 3783 return CMD_WARNING; 3784 3785 /* `show ip ospf database LSA ID'. */ 3786 if (argc == 2) 3787 show_lsa_detail (vty, type, &id, NULL); 3788 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ 3789 else if (argc == 3) 3790 { 3791 if (strncmp (argv[2], "s", 1) == 0) 3792 adv_router = ospf_top->router_id; 3793 else 3794 { 3795 ret = inet_aton (argv[2], &adv_router); 3796 if (!ret) 3797 return CMD_WARNING; 3798 } 3799 show_lsa_detail (vty, type, &id, &adv_router); 3800 } 3801 } 3802 3803 return CMD_SUCCESS; 3804} 3805 3806ALIAS (show_ip_ospf_database, 3807 show_ip_ospf_database_type_cmd, 3808 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", 3809 SHOW_STR 3810 IP_STR 3811 "OSPF information\n" 3812 "Database summary\n" 3813 OSPF_LSA_TYPES_DESC 3814 "LSAs in MaxAge list\n" 3815 "Self-originated link states\n") 3816 3817ALIAS (show_ip_ospf_database, 3818 show_ip_ospf_database_type_id_cmd, 3819 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", 3820 SHOW_STR 3821 IP_STR 3822 "OSPF information\n" 3823 "Database summary\n" 3824 OSPF_LSA_TYPES_DESC 3825 "Link State ID (as an IP address)\n") 3826 3827ALIAS (show_ip_ospf_database, 3828 show_ip_ospf_database_type_id_adv_router_cmd, 3829 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", 3830 SHOW_STR 3831 IP_STR 3832 "OSPF information\n" 3833 "Database summary\n" 3834 OSPF_LSA_TYPES_DESC 3835 "Link State ID (as an IP address)\n" 3836 "Advertising Router link states\n" 3837 "Advertising Router (as an IP address)\n") 3838 3839ALIAS (show_ip_ospf_database, 3840 show_ip_ospf_database_type_id_self_cmd, 3841 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", 3842 SHOW_STR 3843 IP_STR 3844 "OSPF information\n" 3845 "Database summary\n" 3846 OSPF_LSA_TYPES_DESC 3847 "Link State ID (as an IP address)\n" 3848 "Self-originated link states\n" 3849 "\n") 3850 3851DEFUN (show_ip_ospf_database_type_adv_router, 3852 show_ip_ospf_database_type_adv_router_cmd, 3853 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", 3854 SHOW_STR 3855 IP_STR 3856 "OSPF information\n" 3857 "Database summary\n" 3858 OSPF_LSA_TYPES_DESC 3859 "Advertising Router link states\n" 3860 "Advertising Router (as an IP address)\n") 3861{ 3862 int type, ret; 3863 struct in_addr adv_router; 3864 3865 if (ospf_top == NULL) 3866 return CMD_SUCCESS; 3867 3868 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, 3869 inet_ntoa (ospf_top->router_id), VTY_NEWLINE, VTY_NEWLINE); 3870 3871 if (argc != 2) 3872 return CMD_WARNING; 3873 3874 /* Set database type to show. */ 3875 if (strncmp (argv[0], "r", 1) == 0) 3876 type = OSPF_ROUTER_LSA; 3877 else if (strncmp (argv[0], "ne", 2) == 0) 3878 type = OSPF_NETWORK_LSA; 3879#ifdef HAVE_NSSA 3880 else if (strncmp (argv[0], "ns", 2) == 0) 3881 type = OSPF_AS_NSSA_LSA; 3882#endif /* HAVE_NSSA */ 3883 else if (strncmp (argv[0], "s", 1) == 0) 3884 type = OSPF_SUMMARY_LSA; 3885 else if (strncmp (argv[0], "a", 1) == 0) 3886 type = OSPF_ASBR_SUMMARY_LSA; 3887 else if (strncmp (argv[0], "e", 1) == 0) 3888 type = OSPF_AS_EXTERNAL_LSA; 3889#ifdef HAVE_OPAQUE_LSA 3890 else if (strncmp (argv[0], "opaque-l", 8) == 0) 3891 type = OSPF_OPAQUE_LINK_LSA; 3892 else if (strncmp (argv[0], "opaque-a", 8) == 0) 3893 type = OSPF_OPAQUE_AREA_LSA; 3894 else if (strncmp (argv[0], "opaque-e", 8) == 0) 3895 type = OSPF_OPAQUE_AS_LSA; 3896#endif /* HAVE_OPAQUE_LSA */ 3897 else 3898 return CMD_WARNING; 3899 3900 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ 3901 if (strncmp (argv[1], "s", 1) == 0) 3902 adv_router = ospf_top->router_id; 3903 else 3904 { 3905 ret = inet_aton (argv[1], &adv_router); 3906 if (!ret) 3907 return CMD_WARNING; 3908 } 3909 3910 show_lsa_detail_adv_router (vty, type, &adv_router); 3911 3912 return CMD_SUCCESS; 3913} 3914 3915ALIAS (show_ip_ospf_database_type_adv_router, 3916 show_ip_ospf_database_type_self_cmd, 3917 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", 3918 SHOW_STR 3919 IP_STR 3920 "OSPF information\n" 3921 "Database summary\n" 3922 OSPF_LSA_TYPES_DESC 3923 "Self-originated link states\n") 3924 3925 3926DEFUN (ip_ospf_authentication_args, 3927 ip_ospf_authentication_args_addr_cmd, 3928 "ip ospf authentication (null|message-digest) A.B.C.D", 3929 "IP Information\n" 3930 "OSPF interface commands\n" 3931 "Enable authentication on this interface\n" 3932 "Use null authentication\n" 3933 "Use message-digest authentication\n" 3934 "Address of interface") 3935{ 3936 struct interface *ifp; 3937 struct in_addr addr; 3938 int ret; 3939 struct ospf_if_params *params; 3940 3941 ifp = vty->index; 3942 params = IF_DEF_PARAMS (ifp); 3943 3944 if (argc == 2) 3945 { 3946 ret = inet_aton(argv[1], &addr); 3947 if (!ret) 3948 { 3949 vty_out (vty, "Please specify interface address by A.B.C.D%s", 3950 VTY_NEWLINE); 3951 return CMD_WARNING; 3952 } 3953 3954 params = ospf_get_if_params (ifp, addr); 3955 ospf_if_update_params (ifp, addr); 3956 } 3957 3958 /* Handle null authentication */ 3959 if ( argv[0][0] == 'n' ) 3960 { 3961 SET_IF_PARAM (params, auth_type); 3962 params->auth_type = OSPF_AUTH_NULL; 3963 return CMD_SUCCESS; 3964 } 3965 3966 /* Handle message-digest authentication */ 3967 if ( argv[0][0] == 'm' ) 3968 { 3969 SET_IF_PARAM (params, auth_type); 3970 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; 3971 return CMD_SUCCESS; 3972 } 3973 3974 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); 3975 return CMD_WARNING; 3976} 3977 3978ALIAS (ip_ospf_authentication_args, 3979 ip_ospf_authentication_args_cmd, 3980 "ip ospf authentication (null|message-digest)", 3981 "IP Information\n" 3982 "OSPF interface commands\n" 3983 "Enable authentication on this interface\n" 3984 "Use null authentication\n" 3985 "Use message-digest authentication\n") 3986 3987DEFUN (ip_ospf_authentication, 3988 ip_ospf_authentication_addr_cmd, 3989 "ip ospf authentication A.B.C.D", 3990 "IP Information\n" 3991 "OSPF interface commands\n" 3992 "Enable authentication on this interface\n" 3993 "Address of interface") 3994{ 3995 struct interface *ifp; 3996 struct in_addr addr; 3997 int ret; 3998 struct ospf_if_params *params; 3999 4000 ifp = vty->index; 4001 params = IF_DEF_PARAMS (ifp); 4002 4003 if (argc == 1) 4004 { 4005 ret = inet_aton(argv[1], &addr); 4006 if (!ret) 4007 { 4008 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4009 VTY_NEWLINE); 4010 return CMD_WARNING; 4011 } 4012 4013 params = ospf_get_if_params (ifp, addr); 4014 ospf_if_update_params (ifp, addr); 4015 } 4016 4017 SET_IF_PARAM (params, auth_type); 4018 params->auth_type = OSPF_AUTH_SIMPLE; 4019 4020 return CMD_SUCCESS; 4021} 4022 4023ALIAS (ip_ospf_authentication, 4024 ip_ospf_authentication_cmd, 4025 "ip ospf authentication", 4026 "IP Information\n" 4027 "OSPF interface commands\n" 4028 "Enable authentication on this interface\n") 4029 4030DEFUN (no_ip_ospf_authentication, 4031 no_ip_ospf_authentication_addr_cmd, 4032 "no ip ospf authentication A.B.C.D", 4033 NO_STR 4034 "IP Information\n" 4035 "OSPF interface commands\n" 4036 "Enable authentication on this interface\n" 4037 "Address of interface") 4038{ 4039 struct interface *ifp; 4040 struct in_addr addr; 4041 int ret; 4042 struct ospf_if_params *params; 4043 4044 ifp = vty->index; 4045 params = IF_DEF_PARAMS (ifp); 4046 4047 if (argc == 1) 4048 { 4049 ret = inet_aton(argv[1], &addr); 4050 if (!ret) 4051 { 4052 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4053 VTY_NEWLINE); 4054 return CMD_WARNING; 4055 } 4056 4057 params = ospf_lookup_if_params (ifp, addr); 4058 if (params == NULL) 4059 return CMD_SUCCESS; 4060 } 4061 4062 params->auth_type = OSPF_AUTH_NOTSET; 4063 UNSET_IF_PARAM (params, auth_type); 4064 4065 if (params != IF_DEF_PARAMS (ifp)) 4066 { 4067 ospf_free_if_params (ifp, addr); 4068 ospf_if_update_params (ifp, addr); 4069 } 4070 4071 return CMD_SUCCESS; 4072} 4073 4074ALIAS (no_ip_ospf_authentication, 4075 no_ip_ospf_authentication_cmd, 4076 "no ip ospf authentication", 4077 NO_STR 4078 "IP Information\n" 4079 "OSPF interface commands\n" 4080 "Enable authentication on this interface\n") 4081 4082DEFUN (ip_ospf_authentication_key, 4083 ip_ospf_authentication_key_addr_cmd, 4084 "ip ospf authentication-key AUTH_KEY A.B.C.D", 4085 "IP Information\n" 4086 "OSPF interface commands\n" 4087 "Authentication password (key)\n" 4088 "The OSPF password (key)\n" 4089 "Address of interface") 4090{ 4091 struct interface *ifp; 4092 struct in_addr addr; 4093 int ret; 4094 struct ospf_if_params *params; 4095 4096 ifp = vty->index; 4097 params = IF_DEF_PARAMS (ifp); 4098 4099 if (argc == 2) 4100 { 4101 ret = inet_aton(argv[1], &addr); 4102 if (!ret) 4103 { 4104 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4105 VTY_NEWLINE); 4106 return CMD_WARNING; 4107 } 4108 4109 params = ospf_get_if_params (ifp, addr); 4110 ospf_if_update_params (ifp, addr); 4111 } 4112 4113 4114 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); 4115 strncpy (params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); 4116 SET_IF_PARAM (params, auth_simple); 4117 4118 return CMD_SUCCESS; 4119} 4120 4121ALIAS (ip_ospf_authentication_key, 4122 ip_ospf_authentication_key_cmd, 4123 "ip ospf authentication-key AUTH_KEY", 4124 "IP Information\n" 4125 "OSPF interface commands\n" 4126 "Authentication password (key)\n" 4127 "The OSPF password (key)") 4128 4129ALIAS (ip_ospf_authentication_key, 4130 ospf_authentication_key_cmd, 4131 "ospf authentication-key AUTH_KEY", 4132 "OSPF interface commands\n" 4133 "Authentication password (key)\n" 4134 "The OSPF password (key)") 4135 4136DEFUN (no_ip_ospf_authentication_key, 4137 no_ip_ospf_authentication_key_addr_cmd, 4138 "no ip ospf authentication-key A.B.C.D", 4139 NO_STR 4140 "IP Information\n" 4141 "OSPF interface commands\n" 4142 "Authentication password (key)\n" 4143 "Address of interface") 4144{ 4145 struct interface *ifp; 4146 struct in_addr addr; 4147 int ret; 4148 struct ospf_if_params *params; 4149 4150 ifp = vty->index; 4151 params = IF_DEF_PARAMS (ifp); 4152 4153 if (argc == 2) 4154 { 4155 ret = inet_aton(argv[1], &addr); 4156 if (!ret) 4157 { 4158 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4159 VTY_NEWLINE); 4160 return CMD_WARNING; 4161 } 4162 4163 params = ospf_lookup_if_params (ifp, addr); 4164 if (params == NULL) 4165 return CMD_SUCCESS; 4166 } 4167 4168 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); 4169 UNSET_IF_PARAM (params, auth_simple); 4170 4171 if (params != IF_DEF_PARAMS (ifp)) 4172 { 4173 ospf_free_if_params (ifp, addr); 4174 ospf_if_update_params (ifp, addr); 4175 } 4176 4177 return CMD_SUCCESS; 4178} 4179 4180ALIAS (no_ip_ospf_authentication_key, 4181 no_ip_ospf_authentication_key_cmd, 4182 "no ip ospf authentication-key", 4183 NO_STR 4184 "IP Information\n" 4185 "OSPF interface commands\n" 4186 "Authentication password (key)\n") 4187 4188ALIAS (no_ip_ospf_authentication_key, 4189 no_ospf_authentication_key_cmd, 4190 "no ospf authentication-key", 4191 NO_STR 4192 "OSPF interface commands\n" 4193 "Authentication password (key)\n") 4194 4195DEFUN (ip_ospf_message_digest_key, 4196 ip_ospf_message_digest_key_addr_cmd, 4197 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", 4198 "IP Information\n" 4199 "OSPF interface commands\n" 4200 "Message digest authentication password (key)\n" 4201 "Key ID\n" 4202 "Use MD5 algorithm\n" 4203 "The OSPF password (key)" 4204 "Address of interface") 4205{ 4206 struct interface *ifp; 4207 struct crypt_key *ck; 4208 u_char key_id; 4209 struct in_addr addr; 4210 int ret; 4211 struct ospf_if_params *params; 4212 4213 ifp = vty->index; 4214 params = IF_DEF_PARAMS (ifp); 4215 4216 if (argc == 3) 4217 { 4218 ret = inet_aton(argv[2], &addr); 4219 if (!ret) 4220 { 4221 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4222 VTY_NEWLINE); 4223 return CMD_WARNING; 4224 } 4225 4226 params = ospf_get_if_params (ifp, addr); 4227 ospf_if_update_params (ifp, addr); 4228 } 4229 4230 key_id = strtol (argv[0], NULL, 10); 4231 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) 4232 { 4233 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); 4234 return CMD_WARNING; 4235 } 4236 4237 ck = ospf_crypt_key_new (); 4238 ck->key_id = (u_char) key_id; 4239 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); 4240 strncpy (ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); 4241 4242 ospf_crypt_key_add (params->auth_crypt, ck); 4243 SET_IF_PARAM (params, auth_crypt); 4244 4245 return CMD_SUCCESS; 4246} 4247 4248ALIAS (ip_ospf_message_digest_key, 4249 ip_ospf_message_digest_key_cmd, 4250 "ip ospf message-digest-key <1-255> md5 KEY", 4251 "IP Information\n" 4252 "OSPF interface commands\n" 4253 "Message digest authentication password (key)\n" 4254 "Key ID\n" 4255 "Use MD5 algorithm\n" 4256 "The OSPF password (key)") 4257 4258ALIAS (ip_ospf_message_digest_key, 4259 ospf_message_digest_key_cmd, 4260 "ospf message-digest-key <1-255> md5 KEY", 4261 "OSPF interface commands\n" 4262 "Message digest authentication password (key)\n" 4263 "Key ID\n" 4264 "Use MD5 algorithm\n" 4265 "The OSPF password (key)") 4266 4267DEFUN (no_ip_ospf_message_digest_key, 4268 no_ip_ospf_message_digest_key_addr_cmd, 4269 "no ip ospf message-digest-key <1-255> A.B.C.D", 4270 NO_STR 4271 "IP Information\n" 4272 "OSPF interface commands\n" 4273 "Message digest authentication password (key)\n" 4274 "Key ID\n" 4275 "Address of interface") 4276{ 4277 struct interface *ifp; 4278 struct crypt_key *ck; 4279 int key_id; 4280 struct in_addr addr; 4281 int ret; 4282 struct ospf_if_params *params; 4283 4284 ifp = vty->index; 4285 params = IF_DEF_PARAMS (ifp); 4286 4287 if (argc == 2) 4288 { 4289 ret = inet_aton(argv[1], &addr); 4290 if (!ret) 4291 { 4292 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4293 VTY_NEWLINE); 4294 return CMD_WARNING; 4295 } 4296 4297 params = ospf_lookup_if_params (ifp, addr); 4298 if (params == NULL) 4299 return CMD_SUCCESS; 4300 } 4301 4302 key_id = strtol (argv[0], NULL, 10); 4303 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); 4304 if (ck == NULL) 4305 { 4306 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); 4307 return CMD_WARNING; 4308 } 4309 4310 ospf_crypt_key_delete (params->auth_crypt, key_id); 4311 4312 if (params != IF_DEF_PARAMS (ifp)) 4313 { 4314 ospf_free_if_params (ifp, addr); 4315 ospf_if_update_params (ifp, addr); 4316 } 4317 4318 return CMD_SUCCESS; 4319} 4320 4321ALIAS (no_ip_ospf_message_digest_key, 4322 no_ip_ospf_message_digest_key_cmd, 4323 "no ip ospf message-digest-key <1-255>", 4324 NO_STR 4325 "IP Information\n" 4326 "OSPF interface commands\n" 4327 "Message digest authentication password (key)\n" 4328 "Key ID\n") 4329 4330ALIAS (no_ip_ospf_message_digest_key, 4331 no_ospf_message_digest_key_cmd, 4332 "no ospf message-digest-key <1-255>", 4333 NO_STR 4334 "OSPF interface commands\n" 4335 "Message digest authentication password (key)\n" 4336 "Key ID\n") 4337 4338DEFUN (ip_ospf_cost, 4339 ip_ospf_cost_addr_cmd, 4340 "ip ospf cost <1-65535> A.B.C.D", 4341 "IP Information\n" 4342 "OSPF interface commands\n" 4343 "Interface cost\n" 4344 "Cost\n" 4345 "Address of interface") 4346{ 4347 struct interface *ifp = vty->index; 4348 u_int32_t cost; 4349 struct in_addr addr; 4350 int ret; 4351 struct ospf_if_params *params; 4352 4353 params = IF_DEF_PARAMS (ifp); 4354 4355 cost = strtol (argv[0], NULL, 10); 4356 4357 /* cost range is <1-65535>. */ 4358 if (cost < 1 || cost > 65535) 4359 { 4360 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); 4361 return CMD_WARNING; 4362 } 4363 4364 if (argc == 2) 4365 { 4366 ret = inet_aton(argv[1], &addr); 4367 if (!ret) 4368 { 4369 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4370 VTY_NEWLINE); 4371 return CMD_WARNING; 4372 } 4373 4374 params = ospf_get_if_params (ifp, addr); 4375 ospf_if_update_params (ifp, addr); 4376 } 4377 4378 SET_IF_PARAM (params, output_cost_cmd); 4379 params->output_cost_cmd = cost; 4380 4381 ospf_if_recalculate_output_cost (ifp); 4382 4383 return CMD_SUCCESS; 4384} 4385 4386ALIAS (ip_ospf_cost, 4387 ip_ospf_cost_cmd, 4388 "ip ospf cost <1-65535>", 4389 "IP Information\n" 4390 "OSPF interface commands\n" 4391 "Interface cost\n" 4392 "Cost") 4393 4394ALIAS (ip_ospf_cost, 4395 ospf_cost_cmd, 4396 "ospf cost <1-65535>", 4397 "OSPF interface commands\n" 4398 "Interface cost\n" 4399 "Cost") 4400 4401DEFUN (no_ip_ospf_cost, 4402 no_ip_ospf_cost_addr_cmd, 4403 "no ip ospf cost A.B.C.D", 4404 NO_STR 4405 "IP Information\n" 4406 "OSPF interface commands\n" 4407 "Interface cost\n" 4408 "Address of interface") 4409{ 4410 struct interface *ifp = vty->index; 4411 struct in_addr addr; 4412 int ret; 4413 struct ospf_if_params *params; 4414 4415 ifp = vty->index; 4416 params = IF_DEF_PARAMS (ifp); 4417 4418 if (argc == 1) 4419 { 4420 ret = inet_aton(argv[0], &addr); 4421 if (!ret) 4422 { 4423 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4424 VTY_NEWLINE); 4425 return CMD_WARNING; 4426 } 4427 4428 params = ospf_lookup_if_params (ifp, addr); 4429 if (params == NULL) 4430 return CMD_SUCCESS; 4431 } 4432 4433 UNSET_IF_PARAM (params, output_cost_cmd); 4434 4435 if (params != IF_DEF_PARAMS (ifp)) 4436 { 4437 ospf_free_if_params (ifp, addr); 4438 ospf_if_update_params (ifp, addr); 4439 } 4440 4441 ospf_if_recalculate_output_cost (ifp); 4442 4443 return CMD_SUCCESS; 4444} 4445 4446ALIAS (no_ip_ospf_cost, 4447 no_ip_ospf_cost_cmd, 4448 "no ip ospf cost", 4449 NO_STR 4450 "IP Information\n" 4451 "OSPF interface commands\n" 4452 "Interface cost\n") 4453 4454ALIAS (no_ip_ospf_cost, 4455 no_ospf_cost_cmd, 4456 "no ospf cost", 4457 NO_STR 4458 "OSPF interface commands\n" 4459 "Interface cost\n") 4460 4461void 4462ospf_nbr_timer_update (struct ospf_interface *oi) 4463{ 4464 struct route_node *rn; 4465 struct ospf_neighbor *nbr; 4466 4467 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) 4468 if ((nbr = rn->info)) 4469 { 4470 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); 4471 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); 4472 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); 4473 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); 4474 } 4475} 4476 4477DEFUN (ip_ospf_dead_interval, 4478 ip_ospf_dead_interval_addr_cmd, 4479 "ip ospf dead-interval <1-65535> A.B.C.D", 4480 "IP Information\n" 4481 "OSPF interface commands\n" 4482 "Interval after which a neighbor is declared dead\n" 4483 "Seconds\n" 4484 "Address of interface") 4485{ 4486 struct interface *ifp = vty->index; 4487 u_int32_t seconds; 4488 struct in_addr addr; 4489 int ret; 4490 struct ospf_if_params *params; 4491 struct ospf_interface *oi; 4492 struct route_node *rn; 4493 4494 params = IF_DEF_PARAMS (ifp); 4495 4496 seconds = strtol (argv[0], NULL, 10); 4497 4498 /* dead_interval range is <1-65535>. */ 4499 if (seconds < 1 || seconds > 65535) 4500 { 4501 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE); 4502 return CMD_WARNING; 4503 } 4504 4505 if (argc == 2) 4506 { 4507 ret = inet_aton(argv[1], &addr); 4508 if (!ret) 4509 { 4510 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4511 VTY_NEWLINE); 4512 return CMD_WARNING; 4513 } 4514 4515 params = ospf_get_if_params (ifp, addr); 4516 ospf_if_update_params (ifp, addr); 4517 } 4518 4519 SET_IF_PARAM (params, v_wait); 4520 params->v_wait = seconds; 4521 4522 /* Update timer values in neighbor structure. */ 4523 if (argc == 2) 4524 { 4525 oi = ospf_if_lookup_by_local_addr (ifp, addr); 4526 if (oi) 4527 ospf_nbr_timer_update (oi); 4528 } 4529 else 4530 { 4531 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) 4532 if ((oi = rn->info)) 4533 ospf_nbr_timer_update (oi); 4534 } 4535 4536 return CMD_SUCCESS; 4537} 4538 4539ALIAS (ip_ospf_dead_interval, 4540 ip_ospf_dead_interval_cmd, 4541 "ip ospf dead-interval <1-65535>", 4542 "IP Information\n" 4543 "OSPF interface commands\n" 4544 "Interval after which a neighbor is declared dead\n" 4545 "Seconds\n") 4546 4547ALIAS (ip_ospf_dead_interval, 4548 ospf_dead_interval_cmd, 4549 "ospf dead-interval <1-65535>", 4550 "OSPF interface commands\n" 4551 "Interval after which a neighbor is declared dead\n" 4552 "Seconds\n") 4553 4554DEFUN (no_ip_ospf_dead_interval, 4555 no_ip_ospf_dead_interval_addr_cmd, 4556 "no ip ospf dead-interval A.B.C.D", 4557 NO_STR 4558 "IP Information\n" 4559 "OSPF interface commands\n" 4560 "Interval after which a neighbor is declared dead\n" 4561 "Address of interface") 4562{ 4563 struct interface *ifp = vty->index; 4564 struct in_addr addr; 4565 int ret; 4566 struct ospf_if_params *params; 4567 struct ospf_interface *oi; 4568 struct route_node *rn; 4569 4570 ifp = vty->index; 4571 params = IF_DEF_PARAMS (ifp); 4572 4573 if (argc == 1) 4574 { 4575 ret = inet_aton(argv[0], &addr); 4576 if (!ret) 4577 { 4578 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4579 VTY_NEWLINE); 4580 return CMD_WARNING; 4581 } 4582 4583 params = ospf_lookup_if_params (ifp, addr); 4584 if (params == NULL) 4585 return CMD_SUCCESS; 4586 } 4587 4588 UNSET_IF_PARAM (params, v_wait); 4589 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; 4590 4591 if (params != IF_DEF_PARAMS (ifp)) 4592 { 4593 ospf_free_if_params (ifp, addr); 4594 ospf_if_update_params (ifp, addr); 4595 } 4596 4597 /* Update timer values in neighbor structure. */ 4598 if (argc == 1) 4599 { 4600 oi = ospf_if_lookup_by_local_addr (ifp, addr); 4601 if (oi) 4602 ospf_nbr_timer_update (oi); 4603 } 4604 else 4605 { 4606 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) 4607 if ((oi = rn->info)) 4608 ospf_nbr_timer_update (oi); 4609 } 4610 4611 return CMD_SUCCESS; 4612} 4613 4614ALIAS (no_ip_ospf_dead_interval, 4615 no_ip_ospf_dead_interval_cmd, 4616 "no ip ospf dead-interval", 4617 NO_STR 4618 "IP Information\n" 4619 "OSPF interface commands\n" 4620 "Interval after which a neighbor is declared dead\n") 4621 4622ALIAS (no_ip_ospf_dead_interval, 4623 no_ospf_dead_interval_cmd, 4624 "no ospf dead-interval", 4625 NO_STR 4626 "OSPF interface commands\n" 4627 "Interval after which a neighbor is declared dead\n") 4628 4629DEFUN (ip_ospf_hello_interval, 4630 ip_ospf_hello_interval_addr_cmd, 4631 "ip ospf hello-interval <1-65535> A.B.C.D", 4632 "IP Information\n" 4633 "OSPF interface commands\n" 4634 "Time between HELLO packets\n" 4635 "Seconds\n" 4636 "Address of interface") 4637{ 4638 struct interface *ifp = vty->index; 4639 u_int32_t seconds; 4640 struct in_addr addr; 4641 int ret; 4642 struct ospf_if_params *params; 4643 4644 params = IF_DEF_PARAMS (ifp); 4645 4646 seconds = strtol (argv[0], NULL, 10); 4647 4648 /* HelloInterval range is <1-65535>. */ 4649 if (seconds < 1 || seconds > 65535) 4650 { 4651 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); 4652 return CMD_WARNING; 4653 } 4654 4655 if (argc == 2) 4656 { 4657 ret = inet_aton(argv[1], &addr); 4658 if (!ret) 4659 { 4660 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4661 VTY_NEWLINE); 4662 return CMD_WARNING; 4663 } 4664 4665 params = ospf_get_if_params (ifp, addr); 4666 ospf_if_update_params (ifp, addr); 4667 } 4668 4669 SET_IF_PARAM (params, v_hello); 4670 params->v_hello = seconds; 4671 4672 return CMD_SUCCESS; 4673} 4674 4675ALIAS (ip_ospf_hello_interval, 4676 ip_ospf_hello_interval_cmd, 4677 "ip ospf hello-interval <1-65535>", 4678 "IP Information\n" 4679 "OSPF interface commands\n" 4680 "Time between HELLO packets\n" 4681 "Seconds\n") 4682 4683ALIAS (ip_ospf_hello_interval, 4684 ospf_hello_interval_cmd, 4685 "ospf hello-interval <1-65535>", 4686 "OSPF interface commands\n" 4687 "Time between HELLO packets\n" 4688 "Seconds\n") 4689 4690DEFUN (no_ip_ospf_hello_interval, 4691 no_ip_ospf_hello_interval_addr_cmd, 4692 "no ip ospf hello-interval A.B.C.D", 4693 NO_STR 4694 "IP Information\n" 4695 "OSPF interface commands\n" 4696 "Time between HELLO packets\n" 4697 "Address of interface") 4698{ 4699 struct interface *ifp = vty->index; 4700 struct in_addr addr; 4701 int ret; 4702 struct ospf_if_params *params; 4703 4704 ifp = vty->index; 4705 params = IF_DEF_PARAMS (ifp); 4706 4707 if (argc == 1) 4708 { 4709 ret = inet_aton(argv[0], &addr); 4710 if (!ret) 4711 { 4712 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4713 VTY_NEWLINE); 4714 return CMD_WARNING; 4715 } 4716 4717 params = ospf_lookup_if_params (ifp, addr); 4718 if (params == NULL) 4719 return CMD_SUCCESS; 4720 } 4721 4722 UNSET_IF_PARAM (params, v_hello); 4723 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; 4724 4725 if (params != IF_DEF_PARAMS (ifp)) 4726 { 4727 ospf_free_if_params (ifp, addr); 4728 ospf_if_update_params (ifp, addr); 4729 } 4730 4731 return CMD_SUCCESS; 4732} 4733 4734ALIAS (no_ip_ospf_hello_interval, 4735 no_ip_ospf_hello_interval_cmd, 4736 "no ip ospf hello-interval", 4737 NO_STR 4738 "IP Information\n" 4739 "OSPF interface commands\n" 4740 "Time between HELLO packets\n") 4741 4742ALIAS (no_ip_ospf_hello_interval, 4743 no_ospf_hello_interval_cmd, 4744 "no ospf hello-interval", 4745 NO_STR 4746 "OSPF interface commands\n" 4747 "Time between HELLO packets\n") 4748 4749DEFUN (ip_ospf_network, 4750 ip_ospf_network_cmd, 4751 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", 4752 "IP Information\n" 4753 "OSPF interface commands\n" 4754 "Network type\n" 4755 "Specify OSPF broadcast multi-access network\n" 4756 "Specify OSPF NBMA network\n" 4757 "Specify OSPF point-to-multipoint network\n" 4758 "Specify OSPF point-to-point network\n") 4759{ 4760 struct interface *ifp = vty->index; 4761 int old_type = IF_DEF_PARAMS (ifp)->type; 4762 struct route_node *rn; 4763 4764 if (strncmp (argv[0], "b", 1) == 0) 4765 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; 4766 else if (strncmp (argv[0], "n", 1) == 0) 4767 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; 4768 else if (strncmp (argv[0], "point-to-m", 10) == 0) 4769 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; 4770 else if (strncmp (argv[0], "point-to-p", 10) == 0) 4771 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; 4772 4773 if (IF_DEF_PARAMS (ifp)->type == old_type) 4774 return CMD_SUCCESS; 4775 4776 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); 4777 4778 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) 4779 { 4780 struct ospf_interface *oi = rn->info; 4781 4782 if (!oi) 4783 continue; 4784 4785 oi->type = IF_DEF_PARAMS (ifp)->type; 4786 4787 if (oi->state > ISM_Down) 4788 { 4789 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); 4790 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); 4791 } 4792 } 4793 4794 return CMD_SUCCESS; 4795} 4796 4797ALIAS (ip_ospf_network, 4798 ospf_network_cmd, 4799 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", 4800 "OSPF interface commands\n" 4801 "Network type\n" 4802 "Specify OSPF broadcast multi-access network\n" 4803 "Specify OSPF NBMA network\n" 4804 "Specify OSPF point-to-multipoint network\n" 4805 "Specify OSPF point-to-point network\n") 4806 4807DEFUN (no_ip_ospf_network, 4808 no_ip_ospf_network_cmd, 4809 "no ip ospf network", 4810 NO_STR 4811 "IP Information\n" 4812 "OSPF interface commands\n" 4813 "Network type\n") 4814{ 4815 struct interface *ifp = vty->index; 4816 int old_type = IF_DEF_PARAMS (ifp)->type; 4817 struct route_node *rn; 4818 4819 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; 4820 4821 if (IF_DEF_PARAMS (ifp)->type == old_type) 4822 return CMD_SUCCESS; 4823 4824 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) 4825 { 4826 struct ospf_interface *oi = rn->info; 4827 4828 if (!oi) 4829 continue; 4830 4831 oi->type = IF_DEF_PARAMS (ifp)->type; 4832 4833 if (oi->state > ISM_Down) 4834 { 4835 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); 4836 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); 4837 } 4838 } 4839 4840 return CMD_SUCCESS; 4841} 4842 4843ALIAS (no_ip_ospf_network, 4844 no_ospf_network_cmd, 4845 "no ospf network", 4846 NO_STR 4847 "OSPF interface commands\n" 4848 "Network type\n") 4849 4850DEFUN (ip_ospf_priority, 4851 ip_ospf_priority_addr_cmd, 4852 "ip ospf priority <0-255> A.B.C.D", 4853 "IP Information\n" 4854 "OSPF interface commands\n" 4855 "Router priority\n" 4856 "Priority\n" 4857 "Address of interface") 4858{ 4859 struct interface *ifp = vty->index; 4860 u_int32_t priority; 4861 struct route_node *rn; 4862 struct in_addr addr; 4863 int ret; 4864 struct ospf_if_params *params; 4865 4866 params = IF_DEF_PARAMS (ifp); 4867 4868 priority = strtol (argv[0], NULL, 10); 4869 4870 /* Router Priority range is <0-255>. */ 4871 if (priority < 0 || priority > 255) 4872 { 4873 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); 4874 return CMD_WARNING; 4875 } 4876 4877 if (argc == 2) 4878 { 4879 ret = inet_aton(argv[1], &addr); 4880 if (!ret) 4881 { 4882 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4883 VTY_NEWLINE); 4884 return CMD_WARNING; 4885 } 4886 4887 params = ospf_get_if_params (ifp, addr); 4888 ospf_if_update_params (ifp, addr); 4889 } 4890 4891 SET_IF_PARAM (params, priority); 4892 params->priority = priority; 4893 4894 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) 4895 { 4896 struct ospf_interface *oi = rn->info; 4897 4898 if (!oi) 4899 continue; 4900 4901 4902 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) 4903 { 4904 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); 4905 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); 4906 } 4907 } 4908 4909 return CMD_SUCCESS; 4910} 4911 4912ALIAS (ip_ospf_priority, 4913 ip_ospf_priority_cmd, 4914 "ip ospf priority <0-255>", 4915 "IP Information\n" 4916 "OSPF interface commands\n" 4917 "Router priority\n" 4918 "Priority\n") 4919 4920ALIAS (ip_ospf_priority, 4921 ospf_priority_cmd, 4922 "ospf priority <0-255>", 4923 "OSPF interface commands\n" 4924 "Router priority\n" 4925 "Priority\n") 4926 4927DEFUN (no_ip_ospf_priority, 4928 no_ip_ospf_priority_addr_cmd, 4929 "no ip ospf priority A.B.C.D", 4930 NO_STR 4931 "IP Information\n" 4932 "OSPF interface commands\n" 4933 "Router priority\n" 4934 "Address of interface") 4935{ 4936 struct interface *ifp = vty->index; 4937 struct route_node *rn; 4938 struct in_addr addr; 4939 int ret; 4940 struct ospf_if_params *params; 4941 4942 ifp = vty->index; 4943 params = IF_DEF_PARAMS (ifp); 4944 4945 if (argc == 1) 4946 { 4947 ret = inet_aton(argv[0], &addr); 4948 if (!ret) 4949 { 4950 vty_out (vty, "Please specify interface address by A.B.C.D%s", 4951 VTY_NEWLINE); 4952 return CMD_WARNING; 4953 } 4954 4955 params = ospf_lookup_if_params (ifp, addr); 4956 if (params == NULL) 4957 return CMD_SUCCESS; 4958 } 4959 4960 UNSET_IF_PARAM (params, priority); 4961 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; 4962 4963 if (params != IF_DEF_PARAMS (ifp)) 4964 { 4965 ospf_free_if_params (ifp, addr); 4966 ospf_if_update_params (ifp, addr); 4967 } 4968 4969 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) 4970 { 4971 struct ospf_interface *oi = rn->info; 4972 4973 if (!oi) 4974 continue; 4975 4976 4977 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) 4978 { 4979 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); 4980 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); 4981 } 4982 } 4983 4984 return CMD_SUCCESS; 4985} 4986 4987ALIAS (no_ip_ospf_priority, 4988 no_ip_ospf_priority_cmd, 4989 "no ip ospf priority", 4990 NO_STR 4991 "IP Information\n" 4992 "OSPF interface commands\n" 4993 "Router priority\n") 4994 4995ALIAS (no_ip_ospf_priority, 4996 no_ospf_priority_cmd, 4997 "no ospf priority", 4998 NO_STR 4999 "OSPF interface commands\n" 5000 "Router priority\n") 5001 5002DEFUN (ip_ospf_retransmit_interval, 5003 ip_ospf_retransmit_interval_addr_cmd, 5004 "ip ospf retransmit-interval <3-65535> A.B.C.D", 5005 "IP Information\n" 5006 "OSPF interface commands\n" 5007 "Time between retransmitting lost link state advertisements\n" 5008 "Seconds\n" 5009 "Address of interface") 5010{ 5011 struct interface *ifp = vty->index; 5012 u_int32_t seconds; 5013 struct in_addr addr; 5014 int ret; 5015 struct ospf_if_params *params; 5016 5017 params = IF_DEF_PARAMS (ifp); 5018 seconds = strtol (argv[0], NULL, 10); 5019 5020 /* Retransmit Interval range is <3-65535>. */ 5021 if (seconds < 3 || seconds > 65535) 5022 { 5023 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); 5024 return CMD_WARNING; 5025 } 5026 5027 5028 if (argc == 2) 5029 { 5030 ret = inet_aton(argv[1], &addr); 5031 if (!ret) 5032 { 5033 vty_out (vty, "Please specify interface address by A.B.C.D%s", 5034 VTY_NEWLINE); 5035 return CMD_WARNING; 5036 } 5037 5038 params = ospf_get_if_params (ifp, addr); 5039 ospf_if_update_params (ifp, addr); 5040 } 5041 5042 SET_IF_PARAM (params, retransmit_interval); 5043 params->retransmit_interval = seconds; 5044 5045 return CMD_SUCCESS; 5046} 5047 5048ALIAS (ip_ospf_retransmit_interval, 5049 ip_ospf_retransmit_interval_cmd, 5050 "ip ospf retransmit-interval <3-65535>", 5051 "IP Information\n" 5052 "OSPF interface commands\n" 5053 "Time between retransmitting lost link state advertisements\n" 5054 "Seconds\n") 5055 5056ALIAS (ip_ospf_retransmit_interval, 5057 ospf_retransmit_interval_cmd, 5058 "ospf retransmit-interval <3-65535>", 5059 "OSPF interface commands\n" 5060 "Time between retransmitting lost link state advertisements\n" 5061 "Seconds\n") 5062 5063DEFUN (no_ip_ospf_retransmit_interval, 5064 no_ip_ospf_retransmit_interval_addr_cmd, 5065 "no ip ospf retransmit-interval A.B.C.D", 5066 NO_STR 5067 "IP Information\n" 5068 "OSPF interface commands\n" 5069 "Time between retransmitting lost link state advertisements\n" 5070 "Address of interface") 5071{ 5072 struct interface *ifp = vty->index; 5073 struct in_addr addr; 5074 int ret; 5075 struct ospf_if_params *params; 5076 5077 ifp = vty->index; 5078 params = IF_DEF_PARAMS (ifp); 5079 5080 if (argc == 1) 5081 { 5082 ret = inet_aton(argv[0], &addr); 5083 if (!ret) 5084 { 5085 vty_out (vty, "Please specify interface address by A.B.C.D%s", 5086 VTY_NEWLINE); 5087 return CMD_WARNING; 5088 } 5089 5090 params = ospf_lookup_if_params (ifp, addr); 5091 if (params == NULL) 5092 return CMD_SUCCESS; 5093 } 5094 5095 UNSET_IF_PARAM (params, retransmit_interval); 5096 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; 5097 5098 if (params != IF_DEF_PARAMS (ifp)) 5099 { 5100 ospf_free_if_params (ifp, addr); 5101 ospf_if_update_params (ifp, addr); 5102 } 5103 5104 return CMD_SUCCESS; 5105} 5106 5107ALIAS (no_ip_ospf_retransmit_interval, 5108 no_ip_ospf_retransmit_interval_cmd, 5109 "no ip ospf retransmit-interval", 5110 NO_STR 5111 "IP Information\n" 5112 "OSPF interface commands\n" 5113 "Time between retransmitting lost link state advertisements\n") 5114 5115ALIAS (no_ip_ospf_retransmit_interval, 5116 no_ospf_retransmit_interval_cmd, 5117 "no ospf retransmit-interval", 5118 NO_STR 5119 "OSPF interface commands\n" 5120 "Time between retransmitting lost link state advertisements\n") 5121 5122DEFUN (ip_ospf_transmit_delay, 5123 ip_ospf_transmit_delay_addr_cmd, 5124 "ip ospf transmit-delay <1-65535> A.B.C.D", 5125 "IP Information\n" 5126 "OSPF interface commands\n" 5127 "Link state transmit delay\n" 5128 "Seconds\n" 5129 "Address of interface") 5130{ 5131 struct interface *ifp = vty->index; 5132 u_int32_t seconds; 5133 struct in_addr addr; 5134 int ret; 5135 struct ospf_if_params *params; 5136 5137 params = IF_DEF_PARAMS (ifp); 5138 seconds = strtol (argv[0], NULL, 10); 5139 5140 /* Transmit Delay range is <1-65535>. */ 5141 if (seconds < 1 || seconds > 65535) 5142 { 5143 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); 5144 return CMD_WARNING; 5145 } 5146 5147 if (argc == 2) 5148 { 5149 ret = inet_aton(argv[1], &addr); 5150 if (!ret) 5151 { 5152 vty_out (vty, "Please specify interface address by A.B.C.D%s", 5153 VTY_NEWLINE); 5154 return CMD_WARNING; 5155 } 5156 5157 params = ospf_get_if_params (ifp, addr); 5158 ospf_if_update_params (ifp, addr); 5159 } 5160 5161 SET_IF_PARAM (params, transmit_delay); 5162 params->transmit_delay = seconds; 5163 5164 return CMD_SUCCESS; 5165} 5166 5167ALIAS (ip_ospf_transmit_delay, 5168 ip_ospf_transmit_delay_cmd, 5169 "ip ospf transmit-delay <1-65535>", 5170 "IP Information\n" 5171 "OSPF interface commands\n" 5172 "Link state transmit delay\n" 5173 "Seconds\n") 5174 5175ALIAS (ip_ospf_transmit_delay, 5176 ospf_transmit_delay_cmd, 5177 "ospf transmit-delay <1-65535>", 5178 "OSPF interface commands\n" 5179 "Link state transmit delay\n" 5180 "Seconds\n") 5181 5182DEFUN (no_ip_ospf_transmit_delay, 5183 no_ip_ospf_transmit_delay_addr_cmd, 5184 "no ip ospf transmit-delay A.B.C.D", 5185 NO_STR 5186 "IP Information\n" 5187 "OSPF interface commands\n" 5188 "Link state transmit delay\n" 5189 "Address of interface") 5190{ 5191 struct interface *ifp = vty->index; 5192 struct in_addr addr; 5193 int ret; 5194 struct ospf_if_params *params; 5195 5196 ifp = vty->index; 5197 params = IF_DEF_PARAMS (ifp); 5198 5199 if (argc == 1) 5200 { 5201 ret = inet_aton(argv[0], &addr); 5202 if (!ret) 5203 { 5204 vty_out (vty, "Please specify interface address by A.B.C.D%s", 5205 VTY_NEWLINE); 5206 return CMD_WARNING; 5207 } 5208 5209 params = ospf_lookup_if_params (ifp, addr); 5210 if (params == NULL) 5211 return CMD_SUCCESS; 5212 } 5213 5214 UNSET_IF_PARAM (params, transmit_delay); 5215 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; 5216 5217 if (params != IF_DEF_PARAMS (ifp)) 5218 { 5219 ospf_free_if_params (ifp, addr); 5220 ospf_if_update_params (ifp, addr); 5221 } 5222 5223 return CMD_SUCCESS; 5224} 5225 5226ALIAS (no_ip_ospf_transmit_delay, 5227 no_ip_ospf_transmit_delay_cmd, 5228 "no ip ospf transmit-delay", 5229 NO_STR 5230 "IP Information\n" 5231 "OSPF interface commands\n" 5232 "Link state transmit delay\n") 5233 5234ALIAS (no_ip_ospf_transmit_delay, 5235 no_ospf_transmit_delay_cmd, 5236 "no ospf transmit-delay", 5237 NO_STR 5238 "OSPF interface commands\n" 5239 "Link state transmit delay\n") 5240 5241 5242DEFUN (ospf_redistribute_source_metric_type, 5243 ospf_redistribute_source_metric_type_routemap_cmd, 5244 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD", 5245 "Redistribute information from another routing protocol\n" 5246 "Kernel routes\n" 5247 "Connected\n" 5248 "Static routes\n" 5249 "Routing Information Protocol (RIP)\n" 5250 "Border Gateway Protocol (BGP)\n" 5251 "Metric for redistributed routes\n" 5252 "OSPF default metric\n" 5253 "OSPF exterior metric type for redistributed routes\n" 5254 "Set OSPF External Type 1 metrics\n" 5255 "Set OSPF External Type 2 metrics\n" 5256 "Route map reference\n" 5257 "Pointer to route-map entries\n") 5258{ 5259 int source; 5260 int type = -1; 5261 int metric = -1; 5262 5263 /* Get distribute source. */ 5264 if (!str2distribute_source (argv[0], &source)) 5265 return CMD_WARNING; 5266 5267 /* Get metric value. */ 5268 if (argc >= 2) 5269 if (!str2metric (argv[1], &metric)) 5270 return CMD_WARNING; 5271 5272 /* Get metric type. */ 5273 if (argc >= 3) 5274 if (!str2metric_type (argv[2], &type)) 5275 return CMD_WARNING; 5276 5277 if (argc == 4) 5278 ospf_routemap_set (source, argv[3]); 5279 else 5280 ospf_routemap_unset (source); 5281 5282 return ospf_redistribute_set (source, type, metric); 5283} 5284 5285ALIAS (ospf_redistribute_source_metric_type, 5286 ospf_redistribute_source_metric_type_cmd, 5287 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)", 5288 "Redistribute information from another routing protocol\n" 5289 "Kernel routes\n" 5290 "Connected\n" 5291 "Static routes\n" 5292 "Routing Information Protocol (RIP)\n" 5293 "Border Gateway Protocol (BGP)\n" 5294 "Metric for redistributed routes\n" 5295 "OSPF default metric\n" 5296 "OSPF exterior metric type for redistributed routes\n" 5297 "Set OSPF External Type 1 metrics\n" 5298 "Set OSPF External Type 2 metrics\n") 5299 5300ALIAS (ospf_redistribute_source_metric_type, 5301 ospf_redistribute_source_metric_cmd, 5302 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>", 5303 "Redistribute information from another routing protocol\n" 5304 "Kernel routes\n" 5305 "Connected\n" 5306 "Static routes\n" 5307 "Routing Information Protocol (RIP)\n" 5308 "Border Gateway Protocol (BGP)\n" 5309 "Metric for redistributed routes\n" 5310 "OSPF default metric\n") 5311 5312DEFUN (ospf_redistribute_source_type_metric, 5313 ospf_redistribute_source_type_metric_routemap_cmd, 5314 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD", 5315 "Redistribute information from another routing protocol\n" 5316 "Kernel routes\n" 5317 "Connected\n" 5318 "Static routes\n" 5319 "Routing Information Protocol (RIP)\n" 5320 "Border Gateway Protocol (BGP)\n" 5321 "OSPF exterior metric type for redistributed routes\n" 5322 "Set OSPF External Type 1 metrics\n" 5323 "Set OSPF External Type 2 metrics\n" 5324 "Metric for redistributed routes\n" 5325 "OSPF default metric\n" 5326 "Route map reference\n" 5327 "Pointer to route-map entries\n") 5328{ 5329 int source; 5330 int type = -1; 5331 int metric = -1; 5332 5333 /* Get distribute source. */ 5334 if (!str2distribute_source (argv[0], &source)) 5335 return CMD_WARNING; 5336 5337 /* Get metric value. */ 5338 if (argc >= 2) 5339 if (!str2metric_type (argv[1], &type)) 5340 return CMD_WARNING; 5341 5342 /* Get metric type. */ 5343 if (argc >= 3) 5344 if (!str2metric (argv[2], &metric)) 5345 return CMD_WARNING; 5346 5347 if (argc == 4) 5348 ospf_routemap_set (source, argv[3]); 5349 else 5350 ospf_routemap_unset (source); 5351 5352 return ospf_redistribute_set (source, type, metric); 5353} 5354 5355ALIAS (ospf_redistribute_source_type_metric, 5356 ospf_redistribute_source_type_metric_cmd, 5357 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>", 5358 "Redistribute information from another routing protocol\n" 5359 "Kernel routes\n" 5360 "Connected\n" 5361 "Static routes\n" 5362 "Routing Information Protocol (RIP)\n" 5363 "Border Gateway Protocol (BGP)\n" 5364 "OSPF exterior metric type for redistributed routes\n" 5365 "Set OSPF External Type 1 metrics\n" 5366 "Set OSPF External Type 2 metrics\n" 5367 "Metric for redistributed routes\n" 5368 "OSPF default metric\n") 5369 5370ALIAS (ospf_redistribute_source_type_metric, 5371 ospf_redistribute_source_type_cmd, 5372 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)", 5373 "Redistribute information from another routing protocol\n" 5374 "Kernel routes\n" 5375 "Connected\n" 5376 "Static routes\n" 5377 "Routing Information Protocol (RIP)\n" 5378 "Border Gateway Protocol (BGP)\n" 5379 "OSPF exterior metric type for redistributed routes\n" 5380 "Set OSPF External Type 1 metrics\n" 5381 "Set OSPF External Type 2 metrics\n") 5382 5383ALIAS (ospf_redistribute_source_type_metric, 5384 ospf_redistribute_source_cmd, 5385 "redistribute (kernel|connected|static|rip|bgp)", 5386 "Redistribute information from another routing protocol\n" 5387 "Kernel routes\n" 5388 "Connected\n" 5389 "Static routes\n" 5390 "Routing Information Protocol (RIP)\n" 5391 "Border Gateway Protocol (BGP)\n") 5392 5393DEFUN (ospf_redistribute_source_metric_routemap, 5394 ospf_redistribute_source_metric_routemap_cmd, 5395 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD", 5396 "Redistribute information from another routing protocol\n" 5397 "Kernel routes\n" 5398 "Connected\n" 5399 "Static routes\n" 5400 "Routing Information Protocol (RIP)\n" 5401 "Border Gateway Protocol (BGP)\n" 5402 "Metric for redistributed routes\n" 5403 "OSPF default metric\n" 5404 "Route map reference\n" 5405 "Pointer to route-map entries\n") 5406{ 5407 int source; 5408 int metric = -1; 5409 5410 /* Get distribute source. */ 5411 if (!str2distribute_source (argv[0], &source)) 5412 return CMD_WARNING; 5413 5414 /* Get metric value. */ 5415 if (argc >= 2) 5416 if (!str2metric (argv[1], &metric)) 5417 return CMD_WARNING; 5418 5419 if (argc == 3) 5420 ospf_routemap_set (source, argv[2]); 5421 else 5422 ospf_routemap_unset (source); 5423 5424 return ospf_redistribute_set (source, -1, metric); 5425} 5426 5427DEFUN (ospf_redistribute_source_type_routemap, 5428 ospf_redistribute_source_type_routemap_cmd, 5429 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD", 5430 "Redistribute information from another routing protocol\n" 5431 "Kernel routes\n" 5432 "Connected\n" 5433 "Static routes\n" 5434 "Routing Information Protocol (RIP)\n" 5435 "Border Gateway Protocol (BGP)\n" 5436 "OSPF exterior metric type for redistributed routes\n" 5437 "Set OSPF External Type 1 metrics\n" 5438 "Set OSPF External Type 2 metrics\n" 5439 "Route map reference\n" 5440 "Pointer to route-map entries\n") 5441{ 5442 int source; 5443 int type = -1; 5444 5445 /* Get distribute source. */ 5446 if (!str2distribute_source (argv[0], &source)) 5447 return CMD_WARNING; 5448 5449 /* Get metric value. */ 5450 if (argc >= 2) 5451 if (!str2metric_type (argv[1], &type)) 5452 return CMD_WARNING; 5453 5454 if (argc == 3) 5455 ospf_routemap_set (source, argv[2]); 5456 else 5457 ospf_routemap_unset (source); 5458 5459 return ospf_redistribute_set (source, type, -1); 5460} 5461 5462DEFUN (ospf_redistribute_source_routemap, 5463 ospf_redistribute_source_routemap_cmd, 5464 "redistribute (kernel|connected|static|rip|bgp) route-map WORD", 5465 "Redistribute information from another routing protocol\n" 5466 "Kernel routes\n" 5467 "Connected\n" 5468 "Static routes\n" 5469 "Routing Information Protocol (RIP)\n" 5470 "Border Gateway Protocol (BGP)\n" 5471 "Route map reference\n" 5472 "Pointer to route-map entries\n") 5473{ 5474 int source; 5475 5476 /* Get distribute source. */ 5477 if (!str2distribute_source (argv[0], &source)) 5478 return CMD_WARNING; 5479 5480 if (argc == 2) 5481 ospf_routemap_set (source, argv[1]); 5482 else 5483 ospf_routemap_unset (source); 5484 5485 return ospf_redistribute_set (source, -1, -1); 5486} 5487 5488DEFUN (no_ospf_redistribute_source, 5489 no_ospf_redistribute_source_cmd, 5490 "no redistribute (kernel|connected|static|rip|bgp)", 5491 NO_STR 5492 "Redistribute information from another routing protocol\n" 5493 "Kernel routes\n" 5494 "Connected\n" 5495 "Static routes\n" 5496 "Routing Information Protocol (RIP)\n" 5497 "Border Gateway Protocol (BGP)\n") 5498{ 5499 int source; 5500 5501 if (!str2distribute_source (argv[0], &source)) 5502 return CMD_WARNING; 5503 5504 ospf_routemap_unset (source); 5505 return ospf_redistribute_unset (source); 5506} 5507 5508DEFUN (ospf_distribute_list_out, 5509 ospf_distribute_list_out_cmd, 5510 "distribute-list WORD out (kernel|connected|static|rip|bgp)", 5511 "Filter networks in routing updates\n" 5512 "Access-list name\n" 5513 OUT_STR 5514 "Kernel routes\n" 5515 "Connected\n" 5516 "Static routes\n" 5517 "Routing Information Protocol (RIP)\n" 5518 "Border Gateway Protocol (BGP)\n") 5519{ 5520 int source; 5521 5522 /* Get distribute source. */ 5523 if (!str2distribute_source (argv[1], &source)) 5524 return CMD_WARNING; 5525 5526 return ospf_distribute_list_out_set (source, argv[0]); 5527} 5528 5529DEFUN (no_ospf_distribute_list_out, 5530 no_ospf_distribute_list_out_cmd, 5531 "no distribute-list WORD out (kernel|connected|static|rip|bgp)", 5532 NO_STR 5533 "Filter networks in routing updates\n" 5534 "Access-list name\n" 5535 OUT_STR 5536 "Kernel routes\n" 5537 "Connected\n" 5538 "Static routes\n" 5539 "Routing Information Protocol (RIP)\n" 5540 "Border Gateway Protocol (BGP)\n") 5541{ 5542 int source; 5543 5544 if (!str2distribute_source (argv[1], &source)) 5545 return CMD_WARNING; 5546 5547 return ospf_distribute_list_out_unset (source, argv[0]); 5548} 5549 5550/* Default information originate. */ 5551DEFUN (ospf_default_information_originate_metric_type_routemap, 5552 ospf_default_information_originate_metric_type_routemap_cmd, 5553 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD", 5554 "Control distribution of default information\n" 5555 "Distribute a default route\n" 5556 "OSPF default metric\n" 5557 "OSPF metric\n" 5558 "OSPF metric type for default routes\n" 5559 "Set OSPF External Type 1 metrics\n" 5560 "Set OSPF External Type 2 metrics\n" 5561 "Route map reference\n" 5562 "Pointer to route-map entries\n") 5563{ 5564 int type = -1; 5565 int metric = -1; 5566 5567 /* Get metric value. */ 5568 if (argc >= 1) 5569 if (!str2metric (argv[0], &metric)) 5570 return CMD_WARNING; 5571 5572 /* Get metric type. */ 5573 if (argc >= 2) 5574 if (!str2metric_type (argv[1], &type)) 5575 return CMD_WARNING; 5576 5577 if (argc == 3) 5578 ospf_routemap_set (DEFAULT_ROUTE, argv[2]); 5579 else 5580 ospf_routemap_unset (DEFAULT_ROUTE); 5581 5582 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, type, metric); 5583} 5584 5585ALIAS (ospf_default_information_originate_metric_type_routemap, 5586 ospf_default_information_originate_metric_type_cmd, 5587 "default-information originate metric <0-16777214> metric-type (1|2)", 5588 "Control distribution of default information\n" 5589 "Distribute a default route\n" 5590 "OSPF default metric\n" 5591 "OSPF metric\n" 5592 "OSPF metric type for default routes\n" 5593 "Set OSPF External Type 1 metrics\n" 5594 "Set OSPF External Type 2 metrics\n") 5595 5596ALIAS (ospf_default_information_originate_metric_type_routemap, 5597 ospf_default_information_originate_metric_cmd, 5598 "default-information originate metric <0-16777214>", 5599 "Control distribution of default information\n" 5600 "Distribute a default route\n" 5601 "OSPF default metric\n" 5602 "OSPF metric\n") 5603 5604ALIAS (ospf_default_information_originate_metric_type_routemap, 5605 ospf_default_information_originate_cmd, 5606 "default-information originate", 5607 "Control distribution of default information\n" 5608 "Distribute a default route\n") 5609 5610/* Default information originate. */ 5611DEFUN (ospf_default_information_originate_metric_routemap, 5612 ospf_default_information_originate_metric_routemap_cmd, 5613 "default-information originate metric <0-16777214> route-map WORD", 5614 "Control distribution of default information\n" 5615 "Distribute a default route\n" 5616 "OSPF default metric\n" 5617 "OSPF metric\n" 5618 "Route map reference\n" 5619 "Pointer to route-map entries\n") 5620{ 5621 int metric = -1; 5622 5623 /* Get metric value. */ 5624 if (argc >= 1) 5625 if (!str2metric (argv[0], &metric)) 5626 return CMD_WARNING; 5627 5628 if (argc == 2) 5629 ospf_routemap_set (DEFAULT_ROUTE, argv[1]); 5630 else 5631 ospf_routemap_unset (DEFAULT_ROUTE); 5632 5633 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, -1, metric); 5634} 5635 5636/* Default information originate. */ 5637DEFUN (ospf_default_information_originate_routemap, 5638 ospf_default_information_originate_routemap_cmd, 5639 "default-information originate route-map WORD", 5640 "Control distribution of default information\n" 5641 "Distribute a default route\n" 5642 "Route map reference\n" 5643 "Pointer to route-map entries\n") 5644{ 5645 if (argc == 1) 5646 ospf_routemap_set (DEFAULT_ROUTE, argv[0]); 5647 else 5648 ospf_routemap_unset (DEFAULT_ROUTE); 5649 5650 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, -1, -1); 5651} 5652 5653DEFUN (ospf_default_information_originate_type_metric_routemap, 5654 ospf_default_information_originate_type_metric_routemap_cmd, 5655 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD", 5656 "Control distribution of default information\n" 5657 "Distribute a default route\n" 5658 "OSPF metric type for default routes\n" 5659 "Set OSPF External Type 1 metrics\n" 5660 "Set OSPF External Type 2 metrics\n" 5661 "OSPF default metric\n" 5662 "OSPF metric\n" 5663 "Route map reference\n" 5664 "Pointer to route-map entries\n") 5665{ 5666 int type = -1; 5667 int metric = -1; 5668 5669 /* Get metric type. */ 5670 if (argc >= 1) 5671 if (!str2metric_type (argv[0], &type)) 5672 return CMD_WARNING; 5673 5674 /* Get metric value. */ 5675 if (argc >= 2) 5676 if (!str2metric (argv[1], &metric)) 5677 return CMD_WARNING; 5678 5679 if (argc == 3) 5680 ospf_routemap_set (DEFAULT_ROUTE, argv[2]); 5681 else 5682 ospf_routemap_unset (DEFAULT_ROUTE); 5683 5684 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, type, metric); 5685} 5686 5687ALIAS (ospf_default_information_originate_type_metric_routemap, 5688 ospf_default_information_originate_type_metric_cmd, 5689 "default-information originate metric-type (1|2) metric <0-16777214>", 5690 "Control distribution of default information\n" 5691 "Distribute a default route\n" 5692 "OSPF metric type for default routes\n" 5693 "Set OSPF External Type 1 metrics\n" 5694 "Set OSPF External Type 2 metrics\n" 5695 "OSPF default metric\n" 5696 "OSPF metric\n") 5697 5698ALIAS (ospf_default_information_originate_type_metric_routemap, 5699 ospf_default_information_originate_type_cmd, 5700 "default-information originate metric-type (1|2)", 5701 "Control distribution of default information\n" 5702 "Distribute a default route\n" 5703 "OSPF metric type for default routes\n" 5704 "Set OSPF External Type 1 metrics\n" 5705 "Set OSPF External Type 2 metrics\n") 5706 5707DEFUN (ospf_default_information_originate_type_routemap, 5708 ospf_default_information_originate_type_routemap_cmd, 5709 "default-information originate metric-type (1|2) route-map WORD", 5710 "Control distribution of default information\n" 5711 "Distribute a default route\n" 5712 "OSPF metric type for default routes\n" 5713 "Set OSPF External Type 1 metrics\n" 5714 "Set OSPF External Type 2 metrics\n" 5715 "Route map reference\n" 5716 "Pointer to route-map entries\n") 5717{ 5718 int type = -1; 5719 5720 /* Get metric type. */ 5721 if (argc >= 1) 5722 if (!str2metric_type (argv[0], &type)) 5723 return CMD_WARNING; 5724 5725 if (argc == 2) 5726 ospf_routemap_set (DEFAULT_ROUTE, argv[1]); 5727 else 5728 ospf_routemap_unset (DEFAULT_ROUTE); 5729 5730 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, type, -1); 5731} 5732 5733DEFUN (ospf_default_information_originate_always_metric_type_routemap, 5734 ospf_default_information_originate_always_metric_type_routemap_cmd, 5735 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD", 5736 "Control distribution of default information\n" 5737 "Distribute a default route\n" 5738 "Always advertise default route\n" 5739 "OSPF default metric\n" 5740 "OSPF metric\n" 5741 "OSPF metric type for default routes\n" 5742 "Set OSPF External Type 1 metrics\n" 5743 "Set OSPF External Type 2 metrics\n" 5744 "Route map reference\n" 5745 "Pointer to route-map entries\n") 5746{ 5747 int type = -1; 5748 int metric = -1; 5749 5750 /* Get metric value. */ 5751 if (argc >= 1) 5752 if (!str2metric (argv[0], &metric)) 5753 return CMD_WARNING; 5754 5755 /* Get metric type. */ 5756 if (argc >= 2) 5757 if (!str2metric_type (argv[1], &type)) 5758 return CMD_WARNING; 5759 5760 if (argc == 3) 5761 ospf_routemap_set (DEFAULT_ROUTE, argv[2]); 5762 else 5763 ospf_routemap_unset (DEFAULT_ROUTE); 5764 5765 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS, 5766 type, metric); 5767} 5768 5769ALIAS (ospf_default_information_originate_always_metric_type_routemap, 5770 ospf_default_information_originate_always_metric_type_cmd, 5771 "default-information originate always metric <0-16777214> metric-type (1|2)", 5772 "Control distribution of default information\n" 5773 "Distribute a default route\n" 5774 "Always advertise default route\n" 5775 "OSPF default metric\n" 5776 "OSPF metric\n" 5777 "OSPF metric type for default routes\n" 5778 "Set OSPF External Type 1 metrics\n" 5779 "Set OSPF External Type 2 metrics\n") 5780 5781ALIAS (ospf_default_information_originate_always_metric_type_routemap, 5782 ospf_default_information_originate_always_metric_cmd, 5783 "default-information originate always metric <0-16777214>", 5784 "Control distribution of default information\n" 5785 "Distribute a default route\n" 5786 "Always advertise default route\n" 5787 "OSPF default metric\n" 5788 "OSPF metric\n" 5789 "OSPF metric type for default routes\n") 5790 5791ALIAS (ospf_default_information_originate_always_metric_type_routemap, 5792 ospf_default_information_originate_always_cmd, 5793 "default-information originate always", 5794 "Control distribution of default information\n" 5795 "Distribute a default route\n" 5796 "Always advertise default route\n") 5797 5798DEFUN (ospf_default_information_originate_always_metric_routemap, 5799 ospf_default_information_originate_always_metric_routemap_cmd, 5800 "default-information originate always metric <0-16777214> route-map WORD", 5801 "Control distribution of default information\n" 5802 "Distribute a default route\n" 5803 "Always advertise default route\n" 5804 "OSPF default metric\n" 5805 "OSPF metric\n" 5806 "Route map reference\n" 5807 "Pointer to route-map entries\n") 5808{ 5809 int metric = -1; 5810 5811 /* Get metric value. */ 5812 if (argc >= 1) 5813 if (!str2metric (argv[0], &metric)) 5814 return CMD_WARNING; 5815 5816 if (argc == 2) 5817 ospf_routemap_set (DEFAULT_ROUTE, argv[1]); 5818 else 5819 ospf_routemap_unset (DEFAULT_ROUTE); 5820 5821 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS, -1, metric); 5822} 5823 5824DEFUN (ospf_default_information_originate_always_routemap, 5825 ospf_default_information_originate_always_routemap_cmd, 5826 "default-information originate always route-map WORD", 5827 "Control distribution of default information\n" 5828 "Distribute a default route\n" 5829 "Always advertise default route\n" 5830 "Route map reference\n" 5831 "Pointer to route-map entries\n") 5832{ 5833 if (argc == 1) 5834 ospf_routemap_set (DEFAULT_ROUTE, argv[0]); 5835 else 5836 ospf_routemap_unset (DEFAULT_ROUTE); 5837 5838 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS, -1, -1); 5839} 5840 5841DEFUN (ospf_default_information_originate_always_type_metric_routemap, 5842 ospf_default_information_originate_always_type_metric_routemap_cmd, 5843 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD", 5844 "Control distribution of default information\n" 5845 "Distribute a default route\n" 5846 "Always advertise default route\n" 5847 "OSPF metric type for default routes\n" 5848 "Set OSPF External Type 1 metrics\n" 5849 "Set OSPF External Type 2 metrics\n" 5850 "OSPF default metric\n" 5851 "OSPF metric\n" 5852 "Route map reference\n" 5853 "Pointer to route-map entries\n") 5854{ 5855 int type = -1; 5856 int metric = -1; 5857 5858 /* Get metric type. */ 5859 if (argc >= 1) 5860 if (!str2metric_type (argv[0], &type)) 5861 return CMD_WARNING; 5862 5863 /* Get metric value. */ 5864 if (argc >= 2) 5865 if (!str2metric (argv[1], &metric)) 5866 return CMD_WARNING; 5867 5868 if (argc == 3) 5869 ospf_routemap_set (DEFAULT_ROUTE, argv[2]); 5870 else 5871 ospf_routemap_unset (DEFAULT_ROUTE); 5872 5873 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS, 5874 type, metric); 5875} 5876 5877ALIAS (ospf_default_information_originate_always_type_metric_routemap, 5878 ospf_default_information_originate_always_type_metric_cmd, 5879 "default-information originate always metric-type (1|2) metric <0-16777214>", 5880 "Control distribution of default information\n" 5881 "Distribute a default route\n" 5882 "Always advertise default route\n" 5883 "OSPF metric type for default routes\n" 5884 "Set OSPF External Type 1 metrics\n" 5885 "Set OSPF External Type 2 metrics\n" 5886 "OSPF default metric\n" 5887 "OSPF metric\n") 5888 5889ALIAS (ospf_default_information_originate_always_type_metric_routemap, 5890 ospf_default_information_originate_always_type_cmd, 5891 "default-information originate always metric-type (1|2)", 5892 "Control distribution of default information\n" 5893 "Distribute a default route\n" 5894 "Always advertise default route\n" 5895 "OSPF metric type for default routes\n" 5896 "Set OSPF External Type 1 metrics\n" 5897 "Set OSPF External Type 2 metrics\n") 5898 5899DEFUN (ospf_default_information_originate_always_type_routemap, 5900 ospf_default_information_originate_always_type_routemap_cmd, 5901 "default-information originate always metric-type (1|2) route-map WORD", 5902 "Control distribution of default information\n" 5903 "Distribute a default route\n" 5904 "Always advertise default route\n" 5905 "OSPF metric type for default routes\n" 5906 "Set OSPF External Type 1 metrics\n" 5907 "Set OSPF External Type 2 metrics\n" 5908 "Route map reference\n" 5909 "Pointer to route-map entries\n") 5910{ 5911 int type = -1; 5912 5913 /* Get metric type. */ 5914 if (argc >= 1) 5915 if (!str2metric_type (argv[0], &type)) 5916 return CMD_WARNING; 5917 5918 if (argc == 2) 5919 ospf_routemap_set (DEFAULT_ROUTE, argv[1]); 5920 else 5921 ospf_routemap_unset (DEFAULT_ROUTE); 5922 5923 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS, 5924 type, -1); 5925} 5926 5927DEFUN (no_ospf_default_information_originate, 5928 no_ospf_default_information_originate_cmd, 5929 "no default-information originate", 5930 NO_STR 5931 "Control distribution of default information\n" 5932 "Distribute a default route\n") 5933{ 5934 struct prefix_ipv4 p; 5935 struct in_addr nexthop; 5936 5937 p.family = AF_INET; 5938 p.prefix.s_addr = 0; 5939 p.prefixlen = 0; 5940 5941 ospf_external_lsa_flush (DEFAULT_ROUTE, &p, 0, nexthop); 5942 5943 if (EXTERNAL_INFO (DEFAULT_ROUTE)) { 5944 ospf_external_info_delete (DEFAULT_ROUTE, p); 5945 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); 5946 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; 5947 } 5948 5949 ospf_routemap_unset (DEFAULT_ROUTE); 5950 return ospf_redistribute_default_unset (); 5951} 5952 5953DEFUN (ospf_default_metric, 5954 ospf_default_metric_cmd, 5955 "default-metric <0-16777214>", 5956 "Set metric of redistributed routes\n" 5957 "Default metric\n") 5958{ 5959 int metric = -1; 5960 5961 if (!str2metric (argv[0], &metric)) 5962 return CMD_WARNING; 5963 5964 ospf_top->default_metric = metric; 5965 5966 return CMD_SUCCESS; 5967} 5968 5969DEFUN (no_ospf_default_metric, 5970 no_ospf_default_metric_cmd, 5971 "no default-metric", 5972 NO_STR 5973 "Set metric of redistributed routes\n") 5974{ 5975 ospf_top->default_metric = -1; 5976 return CMD_SUCCESS; 5977} 5978 5979ALIAS (no_ospf_default_metric, 5980 no_ospf_default_metric_val_cmd, 5981 "no default-metric <0-16777214>", 5982 NO_STR 5983 "Set metric of redistributed routes\n" 5984 "Default metric\n") 5985 5986DEFUN (ospf_distance, 5987 ospf_distance_cmd, 5988 "distance <1-255>", 5989 "Define an administrative distance\n" 5990 "OSPF Administrative distance\n") 5991{ 5992 ospf_top->distance_all = atoi (argv[0]); 5993 return CMD_SUCCESS; 5994} 5995 5996DEFUN (no_ospf_distance, 5997 no_ospf_distance_cmd, 5998 "no distance <1-255>", 5999 NO_STR 6000 "Define an administrative distance\n" 6001 "OSPF Administrative distance\n") 6002{ 6003 ospf_top->distance_all = 0; 6004 return CMD_SUCCESS; 6005} 6006 6007DEFUN (no_ospf_distance_ospf, 6008 no_ospf_distance_ospf_cmd, 6009 "no distance ospf", 6010 NO_STR 6011 "Define an administrative distance\n" 6012 "OSPF Administrative distance\n" 6013 "OSPF Distance\n") 6014{ 6015 ospf_top->distance_intra = 0; 6016 ospf_top->distance_inter = 0; 6017 ospf_top->distance_external = 0; 6018 return CMD_SUCCESS; 6019} 6020 6021DEFUN (ospf_distance_ospf_intra, 6022 ospf_distance_ospf_intra_cmd, 6023 "distance ospf intra-area <1-255>", 6024 "Define an administrative distance\n" 6025 "OSPF Administrative distance\n" 6026 "Intra-area routes\n" 6027 "Distance for intra-area routes\n") 6028{ 6029 ospf_top->distance_intra = atoi (argv[0]); 6030 return CMD_SUCCESS; 6031} 6032 6033DEFUN (ospf_distance_ospf_intra_inter, 6034 ospf_distance_ospf_intra_inter_cmd, 6035 "distance ospf intra-area <1-255> inter-area <1-255>", 6036 "Define an administrative distance\n" 6037 "OSPF Administrative distance\n" 6038 "Intra-area routes\n" 6039 "Distance for intra-area routes\n" 6040 "Inter-area routes\n" 6041 "Distance for inter-area routes\n") 6042{ 6043 ospf_top->distance_intra = atoi (argv[0]); 6044 ospf_top->distance_inter = atoi (argv[1]); 6045 return CMD_SUCCESS; 6046} 6047 6048DEFUN (ospf_distance_ospf_intra_external, 6049 ospf_distance_ospf_intra_external_cmd, 6050 "distance ospf intra-area <1-255> external <1-255>", 6051 "Define an administrative distance\n" 6052 "OSPF Administrative distance\n" 6053 "Intra-area routes\n" 6054 "Distance for intra-area routes\n" 6055 "External routes\n" 6056 "Distance for external routes\n") 6057{ 6058 ospf_top->distance_intra = atoi (argv[0]); 6059 ospf_top->distance_external = atoi (argv[1]); 6060 return CMD_SUCCESS; 6061} 6062 6063DEFUN (ospf_distance_ospf_intra_inter_external, 6064 ospf_distance_ospf_intra_inter_external_cmd, 6065 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>", 6066 "Define an administrative distance\n" 6067 "OSPF Administrative distance\n" 6068 "Intra-area routes\n" 6069 "Distance for intra-area routes\n" 6070 "Inter-area routes\n" 6071 "Distance for inter-area routes\n" 6072 "External routes\n" 6073 "Distance for external routes\n") 6074{ 6075 ospf_top->distance_intra = atoi (argv[0]); 6076 ospf_top->distance_inter = atoi (argv[1]); 6077 ospf_top->distance_external = atoi (argv[2]); 6078 return CMD_SUCCESS; 6079} 6080 6081DEFUN (ospf_distance_ospf_intra_external_inter, 6082 ospf_distance_ospf_intra_external_inter_cmd, 6083 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>", 6084 "Define an administrative distance\n" 6085 "OSPF Administrative distance\n" 6086 "Intra-area routes\n" 6087 "Distance for intra-area routes\n" 6088 "External routes\n" 6089 "Distance for external routes\n" 6090 "Inter-area routes\n" 6091 "Distance for inter-area routes\n") 6092{ 6093 ospf_top->distance_intra = atoi (argv[0]); 6094 ospf_top->distance_external = atoi (argv[1]); 6095 ospf_top->distance_inter = atoi (argv[2]); 6096 return CMD_SUCCESS; 6097} 6098 6099DEFUN (ospf_distance_ospf_inter, 6100 ospf_distance_ospf_inter_cmd, 6101 "distance ospf inter-area <1-255>", 6102 "Define an administrative distance\n" 6103 "OSPF Administrative distance\n" 6104 "Inter-area routes\n" 6105 "Distance for inter-area routes\n") 6106{ 6107 ospf_top->distance_inter = atoi (argv[0]); 6108 return CMD_SUCCESS; 6109} 6110 6111DEFUN (ospf_distance_ospf_inter_intra, 6112 ospf_distance_ospf_inter_intra_cmd, 6113 "distance ospf inter-area <1-255> intra-area <1-255>", 6114 "Define an administrative distance\n" 6115 "OSPF Administrative distance\n" 6116 "Inter-area routes\n" 6117 "Distance for inter-area routes\n" 6118 "Intra-area routes\n" 6119 "Distance for intra-area routes\n") 6120{ 6121 ospf_top->distance_inter = atoi (argv[0]); 6122 ospf_top->distance_intra = atoi (argv[1]); 6123 return CMD_SUCCESS; 6124} 6125 6126DEFUN (ospf_distance_ospf_inter_external, 6127 ospf_distance_ospf_inter_external_cmd, 6128 "distance ospf inter-area <1-255> external <1-255>", 6129 "Define an administrative distance\n" 6130 "OSPF Administrative distance\n" 6131 "Inter-area routes\n" 6132 "Distance for inter-area routes\n" 6133 "External routes\n" 6134 "Distance for external routes\n") 6135{ 6136 ospf_top->distance_inter = atoi (argv[0]); 6137 ospf_top->distance_external = atoi (argv[1]); 6138 return CMD_SUCCESS; 6139} 6140 6141DEFUN (ospf_distance_ospf_inter_intra_external, 6142 ospf_distance_ospf_inter_intra_external_cmd, 6143 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>", 6144 "Define an administrative distance\n" 6145 "OSPF Administrative distance\n" 6146 "Inter-area routes\n" 6147 "Distance for inter-area routes\n" 6148 "Intra-area routes\n" 6149 "Distance for intra-area routes\n" 6150 "External routes\n" 6151 "Distance for external routes\n") 6152{ 6153 ospf_top->distance_inter = atoi (argv[0]); 6154 ospf_top->distance_intra = atoi (argv[1]); 6155 ospf_top->distance_external = atoi (argv[2]); 6156 return CMD_SUCCESS; 6157} 6158 6159DEFUN (ospf_distance_ospf_inter_external_intra, 6160 ospf_distance_ospf_inter_external_intra_cmd, 6161 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>", 6162 "Define an administrative distance\n" 6163 "OSPF Administrative distance\n" 6164 "Inter-area routes\n" 6165 "Distance for inter-area routes\n" 6166 "External routes\n" 6167 "Distance for external routes\n" 6168 "Intra-area routes\n" 6169 "Distance for intra-area routes\n") 6170{ 6171 ospf_top->distance_inter = atoi (argv[0]); 6172 ospf_top->distance_external = atoi (argv[1]); 6173 ospf_top->distance_intra = atoi (argv[2]); 6174 return CMD_SUCCESS; 6175} 6176 6177DEFUN (ospf_distance_ospf_external, 6178 ospf_distance_ospf_external_cmd, 6179 "distance ospf external <1-255>", 6180 "Define an administrative distance\n" 6181 "OSPF Administrative distance\n" 6182 "External routes\n" 6183 "Distance for external routes\n") 6184{ 6185 ospf_top->distance_external = atoi (argv[0]); 6186 return CMD_SUCCESS; 6187} 6188 6189DEFUN (ospf_distance_ospf_external_intra, 6190 ospf_distance_ospf_external_intra_cmd, 6191 "distance ospf external <1-255> intra-area <1-255>", 6192 "Define an administrative distance\n" 6193 "OSPF Administrative distance\n" 6194 "External routes\n" 6195 "Distance for external routes\n" 6196 "Intra-area routes\n" 6197 "Distance for intra-area routes\n") 6198{ 6199 ospf_top->distance_external = atoi (argv[0]); 6200 ospf_top->distance_intra = atoi (argv[1]); 6201 return CMD_SUCCESS; 6202} 6203 6204DEFUN (ospf_distance_ospf_external_inter, 6205 ospf_distance_ospf_external_inter_cmd, 6206 "distance ospf external <1-255> inter-area <1-255>", 6207 "Define an administrative distance\n" 6208 "OSPF Administrative distance\n" 6209 "External routes\n" 6210 "Distance for external routes\n" 6211 "Inter-area routes\n" 6212 "Distance for inter-area routes\n") 6213{ 6214 ospf_top->distance_external = atoi (argv[0]); 6215 ospf_top->distance_inter = atoi (argv[1]); 6216 return CMD_SUCCESS; 6217} 6218 6219DEFUN (ospf_distance_ospf_external_intra_inter, 6220 ospf_distance_ospf_external_intra_inter_cmd, 6221 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>", 6222 "Define an administrative distance\n" 6223 "OSPF Administrative distance\n" 6224 "External routes\n" 6225 "Distance for external routes\n" 6226 "Intra-area routes\n" 6227 "Distance for intra-area routes\n" 6228 "Inter-area routes\n" 6229 "Distance for inter-area routes\n") 6230{ 6231 ospf_top->distance_external = atoi (argv[0]); 6232 ospf_top->distance_intra = atoi (argv[1]); 6233 ospf_top->distance_inter = atoi (argv[2]); 6234 return CMD_SUCCESS; 6235} 6236 6237DEFUN (ospf_distance_ospf_external_inter_intra, 6238 ospf_distance_ospf_external_inter_intra_cmd, 6239 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>", 6240 "Define an administrative distance\n" 6241 "OSPF Administrative distance\n" 6242 "External routes\n" 6243 "Distance for external routes\n" 6244 "Inter-area routes\n" 6245 "Distance for inter-area routes\n" 6246 "Intra-area routes\n" 6247 "Distance for intra-area routes\n") 6248{ 6249 ospf_top->distance_external = atoi (argv[0]); 6250 ospf_top->distance_inter = atoi (argv[1]); 6251 ospf_top->distance_intra = atoi (argv[2]); 6252 return CMD_SUCCESS; 6253} 6254 6255DEFUN (ospf_distance_source, 6256 ospf_distance_source_cmd, 6257 "distance <1-255> A.B.C.D/M", 6258 "Administrative distance\n" 6259 "Distance value\n" 6260 "IP source prefix\n") 6261{ 6262 ospf_distance_set (vty, argv[0], argv[1], NULL); 6263 return CMD_SUCCESS; 6264} 6265 6266DEFUN (no_ospf_distance_source, 6267 no_ospf_distance_source_cmd, 6268 "no distance <1-255> A.B.C.D/M", 6269 NO_STR 6270 "Administrative distance\n" 6271 "Distance value\n" 6272 "IP source prefix\n") 6273{ 6274 ospf_distance_unset (vty, argv[0], argv[1], NULL); 6275 return CMD_SUCCESS; 6276} 6277 6278DEFUN (ospf_distance_source_access_list, 6279 ospf_distance_source_access_list_cmd, 6280 "distance <1-255> A.B.C.D/M WORD", 6281 "Administrative distance\n" 6282 "Distance value\n" 6283 "IP source prefix\n" 6284 "Access list name\n") 6285{ 6286 ospf_distance_set (vty, argv[0], argv[1], argv[2]); 6287 return CMD_SUCCESS; 6288} 6289 6290DEFUN (no_ospf_distance_source_access_list, 6291 no_ospf_distance_source_access_list_cmd, 6292 "no distance <1-255> A.B.C.D/M WORD", 6293 NO_STR 6294 "Administrative distance\n" 6295 "Distance value\n" 6296 "IP source prefix\n" 6297 "Access list name\n") 6298{ 6299 ospf_distance_unset (vty, argv[0], argv[1], argv[2]); 6300 return CMD_SUCCESS; 6301} 6302 6303void 6304show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) 6305{ 6306 struct route_node *rn; 6307 struct ospf_route *or; 6308 listnode pnode; 6309 struct ospf_path *path; 6310 6311 vty_out (vty, "============ OSPF network routing table ============%s", 6312 VTY_NEWLINE); 6313 6314 for (rn = route_top (rt); rn; rn = route_next (rn)) 6315 if ((or = rn->info) != NULL) 6316 { 6317 char buf1[19]; 6318 snprintf (buf1, 19, "%s/%d", 6319 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); 6320 6321 switch (or->path_type) 6322 { 6323 case OSPF_PATH_INTER_AREA: 6324 if (or->type == OSPF_DESTINATION_NETWORK) 6325 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, 6326 inet_ntoa (or->u.std.area_id), VTY_NEWLINE); 6327 else if (or->type == OSPF_DESTINATION_DISCARD) 6328 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); 6329 break; 6330 case OSPF_PATH_INTRA_AREA: 6331 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, 6332 inet_ntoa (or->u.std.area_id), VTY_NEWLINE); 6333 break; 6334 default: 6335 break; 6336 } 6337 6338 if (or->type == OSPF_DESTINATION_NETWORK) 6339 for (pnode = listhead (or->path); pnode; nextnode (pnode)) 6340 { 6341 path = getdata (pnode); 6342 if (path->oi != NULL) 6343 { 6344 if (path->nexthop.s_addr == 0) 6345 vty_out (vty, "%24s directly attached to %s%s", 6346 "", path->oi->ifp->name, VTY_NEWLINE); 6347 else 6348 vty_out (vty, "%24s via %s, %s%s", "", 6349 inet_ntoa (path->nexthop), path->oi->ifp->name, 6350 VTY_NEWLINE); 6351 } 6352 } 6353 } 6354 vty_out (vty, "%s", VTY_NEWLINE); 6355} 6356 6357void 6358show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) 6359{ 6360 struct route_node *rn; 6361 struct ospf_route *or; 6362 listnode pn, nn; 6363 struct ospf_path *path; 6364 6365 vty_out (vty, "============ OSPF router routing table =============%s", 6366 VTY_NEWLINE); 6367 for (rn = route_top (rtrs); rn; rn = route_next (rn)) 6368 if (rn->info) 6369 { 6370 int flag = 0; 6371 6372 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); 6373 6374 for (nn = listhead ((list) rn->info); nn; nextnode (nn)) 6375 if ((or = getdata (nn)) != NULL) 6376 { 6377 if (flag++) 6378 vty_out(vty," " ); 6379 6380 /* Show path. */ 6381 vty_out (vty, "%s [%d] area: %s", 6382 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), 6383 or->cost, inet_ntoa (or->u.std.area_id)); 6384 /* Show flags. */ 6385 vty_out (vty, "%s%s%s", 6386 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), 6387 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), 6388 VTY_NEWLINE); 6389 6390 for (pn = listhead (or->path); pn; nextnode (pn)) 6391 { 6392 path = getdata (pn); 6393 if (path->nexthop.s_addr == 0) 6394 vty_out (vty, "%24s directly attached to %s%s", 6395 "", path->oi->ifp->name, VTY_NEWLINE); 6396 else 6397 vty_out (vty, "%24s via %s, %s%s", "", 6398 inet_ntoa (path->nexthop), path->oi->ifp->name, 6399 VTY_NEWLINE); 6400 } 6401 } 6402 } 6403 vty_out (vty, "%s", VTY_NEWLINE); 6404} 6405 6406void 6407show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) 6408{ 6409 struct route_node *rn; 6410 struct ospf_route *er; 6411 listnode pnode; 6412 struct ospf_path *path; 6413 6414 vty_out (vty, "============ OSPF external routing table ===========%s", 6415 VTY_NEWLINE); 6416 for (rn = route_top (rt); rn; rn = route_next (rn)) 6417 if ((er = rn->info) != NULL) 6418 { 6419 char buf1[19]; 6420 snprintf (buf1, 19, "%s/%d", 6421 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); 6422 6423 switch (er->path_type) 6424 { 6425 case OSPF_PATH_TYPE1_EXTERNAL: 6426 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, 6427 er->cost, er->u.ext.tag, VTY_NEWLINE); 6428 break; 6429 case OSPF_PATH_TYPE2_EXTERNAL: 6430 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, 6431 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); 6432 break; 6433 } 6434 6435 for (pnode = listhead (er->path); pnode; nextnode (pnode)) 6436 { 6437 path = getdata (pnode); 6438 if (path->oi != NULL) 6439 { 6440 if (path->nexthop.s_addr == 0) 6441 vty_out (vty, "%24s directly attached to %s%s", 6442 "", path->oi->ifp->name, VTY_NEWLINE); 6443 else 6444 vty_out (vty, "%24s via %s, %s%s", "", 6445 inet_ntoa (path->nexthop), path->oi->ifp->name, 6446 VTY_NEWLINE); 6447 } 6448 } 6449 } 6450 vty_out (vty, "%s", VTY_NEWLINE); 6451} 6452 6453#ifdef HAVE_NSSA 6454DEFUN (show_ip_ospf_border_routers, 6455 show_ip_ospf_border_routers_cmd, 6456 "show ip ospf border-routers", 6457 SHOW_STR 6458 IP_STR 6459 "show all the ABR's and ASBR's\n" 6460 "for this area\n") 6461{ 6462 if (ospf_top == NULL) 6463 { 6464 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); 6465 return CMD_SUCCESS; 6466 } 6467 6468 if (ospf_top->new_table == NULL) 6469 { 6470 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); 6471 return CMD_SUCCESS; 6472 } 6473 6474 /* Show Network routes. 6475 show_ip_ospf_route_network (vty, ospf_top->new_table); */ 6476 6477 /* Show Router routes. */ 6478 show_ip_ospf_route_router (vty, ospf_top->new_rtrs); 6479 6480 return CMD_SUCCESS; 6481} 6482#endif /* HAVE_NSSA */ 6483 6484DEFUN (show_ip_ospf_route, 6485 show_ip_ospf_route_cmd, 6486 "show ip ospf route", 6487 SHOW_STR 6488 IP_STR 6489 "OSPF information\n" 6490 "OSPF routing table\n") 6491{ 6492 if (ospf_top == NULL) 6493 { 6494 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); 6495 return CMD_SUCCESS; 6496 } 6497 6498 if (ospf_top->new_table == NULL) 6499 { 6500 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); 6501 return CMD_SUCCESS; 6502 } 6503 6504 /* Show Network routes. */ 6505 show_ip_ospf_route_network (vty, ospf_top->new_table); 6506 6507 /* Show Router routes. */ 6508 show_ip_ospf_route_router (vty, ospf_top->new_rtrs); 6509 6510 /* Show AS External routes. */ 6511 show_ip_ospf_route_external (vty, ospf_top->old_external_route); 6512 6513 return CMD_SUCCESS; 6514} 6515 6516 6517char *ospf_abr_type_str[] = 6518{ 6519 "unknown", 6520 "standard", 6521 "ibm", 6522 "cisco", 6523 "shortcut" 6524}; 6525 6526char *ospf_shortcut_mode_str[] = 6527{ 6528 "default", 6529 "enable", 6530 "disable" 6531}; 6532 6533 6534void 6535area_id2str (char *buf, int length, struct ospf_area *area) 6536{ 6537 memset (buf, 0, length); 6538 6539 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) 6540 strncpy (buf, inet_ntoa (area->area_id), length); 6541 else 6542 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); 6543} 6544 6545 6546char *ospf_int_type_str[] = 6547{ 6548 "unknown", /* should never be used. */ 6549 "point-to-point", 6550 "broadcast", 6551 "non-broadcast", 6552 "point-to-multipoint", 6553 "virtual-link", /* should never be used. */ 6554 "loopback" 6555}; 6556 6557/* Configuration write function for ospfd. */ 6558int 6559config_write_interface (struct vty *vty) 6560{ 6561 listnode n1, n2; 6562 struct interface *ifp; 6563 struct crypt_key *ck; 6564 int write = 0; 6565 struct route_node *rn = NULL; 6566 struct ospf_if_params *params; 6567 6568 for (n1 = listhead (iflist); n1; nextnode (n1)) 6569 { 6570 ifp = getdata (n1); 6571 6572 if (memcmp (ifp->name, "VLINK", 5) == 0) 6573 continue; 6574 6575 vty_out (vty, "!%s", VTY_NEWLINE); 6576 vty_out (vty, "interface %s%s", ifp->name, 6577 VTY_NEWLINE); 6578 if (ifp->desc) 6579 vty_out (vty, " description %s%s", ifp->desc, 6580 VTY_NEWLINE); 6581 6582 write++; 6583 6584 params = IF_DEF_PARAMS (ifp); 6585 6586 do { 6587 /* Interface Network print. */ 6588 if (OSPF_IF_PARAM_CONFIGURED (params, type) && 6589 params->type != OSPF_IFTYPE_BROADCAST && 6590 params->type != OSPF_IFTYPE_LOOPBACK) 6591 { 6592 vty_out (vty, " ip ospf network %s", 6593 ospf_int_type_str[params->type]); 6594 if (params != IF_DEF_PARAMS (ifp)) 6595 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); 6596 vty_out (vty, "%s", VTY_NEWLINE); 6597 } 6598 6599 /* OSPF interface authentication print */ 6600 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && 6601 params->auth_type != OSPF_AUTH_NOTSET) 6602 { 6603 char *auth_str; 6604 6605 /* Translation tables are not that much help here due to syntax 6606 of the simple option */ 6607 switch (params->auth_type) 6608 { 6609 6610 case OSPF_AUTH_NULL: 6611 auth_str = " null"; 6612 break; 6613 6614 case OSPF_AUTH_SIMPLE: 6615 auth_str = ""; 6616 break; 6617 6618 case OSPF_AUTH_CRYPTOGRAPHIC: 6619 auth_str = " message-digest"; 6620 break; 6621 6622 default: 6623 auth_str = ""; 6624 break; 6625 } 6626 6627 vty_out (vty, " ip ospf authentication%s", auth_str); 6628 if (params != IF_DEF_PARAMS (ifp)) 6629 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); 6630 vty_out (vty, "%s", VTY_NEWLINE); 6631 } 6632 6633 /* Simple Authentication Password print. */ 6634 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && 6635 params->auth_simple[0] != '\0') 6636 { 6637 vty_out (vty, " ip ospf authentication-key %s", 6638 params->auth_simple); 6639 if (params != IF_DEF_PARAMS (ifp)) 6640 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); 6641 vty_out (vty, "%s", VTY_NEWLINE); 6642 } 6643 6644 /* Cryptographic Authentication Key print. */ 6645 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2)) 6646 { 6647 ck = getdata (n2); 6648 vty_out (vty, " ip ospf message-digest-key %d md5 %s", 6649 ck->key_id, ck->auth_key); 6650 if (params != IF_DEF_PARAMS (ifp)) 6651 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); 6652 vty_out (vty, "%s", VTY_NEWLINE); 6653 } 6654 6655 /* Interface Output Cost print. */ 6656 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) 6657 { 6658 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); 6659 if (params != IF_DEF_PARAMS (ifp)) 6660 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); 6661 vty_out (vty, "%s", VTY_NEWLINE); 6662 } 6663 6664 /* Hello Interval print. */ 6665 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && 6666 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) 6667 { 6668 vty_out (vty, " ip ospf hello-interval %u", params->v_hello); 6669 if (params != IF_DEF_PARAMS (ifp)) 6670 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); 6671 vty_out (vty, "%s", VTY_NEWLINE); 6672 } 6673 6674 6675 /* Router Dead Interval print. */ 6676 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && 6677 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) 6678 { 6679 vty_out (vty, " ip ospf dead-interval %u", params->v_wait); 6680 if (params != IF_DEF_PARAMS (ifp)) 6681 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); 6682 vty_out (vty, "%s", VTY_NEWLINE); 6683 } 6684 6685 /* Router Priority print. */ 6686 if (OSPF_IF_PARAM_CONFIGURED (params, priority) && 6687 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) 6688 { 6689 vty_out (vty, " ip ospf priority %u", params->priority); 6690 if (params != IF_DEF_PARAMS (ifp)) 6691 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); 6692 vty_out (vty, "%s", VTY_NEWLINE); 6693 } 6694 6695 /* Retransmit Interval print. */ 6696 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && 6697 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) 6698 { 6699 vty_out (vty, " ip ospf retransmit-interval %u", 6700 params->retransmit_interval); 6701 if (params != IF_DEF_PARAMS (ifp)) 6702 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); 6703 vty_out (vty, "%s", VTY_NEWLINE); 6704 } 6705 6706 /* Transmit Delay print. */ 6707 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && 6708 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) 6709 { 6710 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); 6711 if (params != IF_DEF_PARAMS (ifp)) 6712 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); 6713 vty_out (vty, "%s", VTY_NEWLINE); 6714 } 6715 6716 while (1) 6717 { 6718 if (rn == NULL) 6719 rn = route_top (IF_OIFS_PARAMS (ifp)); 6720 else 6721 rn = route_next (rn); 6722 6723 if (rn == NULL) 6724 break; 6725 params = rn->info; 6726 if (params != NULL) 6727 break; 6728 } 6729 } while (rn); 6730 6731#ifdef HAVE_OPAQUE_LSA 6732 ospf_opaque_config_write_if (vty, ifp); 6733#endif /* HAVE_OPAQUE_LSA */ 6734 } 6735 6736 return write; 6737} 6738 6739int 6740config_write_network_area (struct vty *vty) 6741{ 6742 struct route_node *rn; 6743 u_char buf[INET_ADDRSTRLEN]; 6744 6745 /* `network area' print. */ 6746 for (rn = route_top (ospf_top->networks); rn; rn = route_next (rn)) 6747 if (rn->info) 6748 { 6749 struct ospf_network *n = rn->info; 6750 6751 memset (buf, 0, INET_ADDRSTRLEN); 6752 6753 /* Create Area ID string by specified Area ID format. */ 6754 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) 6755 strncpy (buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); 6756 else 6757 sprintf (buf, "%lu", 6758 (unsigned long int) ntohl (n->area_id.s_addr)); 6759 6760 /* Network print. */ 6761 vty_out (vty, " network %s/%d area %s%s", 6762 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, 6763 buf, VTY_NEWLINE); 6764 } 6765 6766 return 0; 6767} 6768 6769int 6770config_write_ospf_area (struct vty *vty) 6771{ 6772 listnode node; 6773 u_char buf[INET_ADDRSTRLEN]; 6774 6775 /* Area configuration print. */ 6776 for (node = listhead (ospf_top->areas); node; nextnode (node)) 6777 { 6778 struct ospf_area *area = getdata (node); 6779 struct route_node *rn1; 6780 6781 area_id2str (buf, INET_ADDRSTRLEN, area); 6782 6783 if (area->auth_type != OSPF_AUTH_NULL) 6784 { 6785 if (area->auth_type == OSPF_AUTH_SIMPLE) 6786 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); 6787 else 6788 vty_out (vty, " area %s authentication message-digest%s", 6789 buf, VTY_NEWLINE); 6790 } 6791 6792 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) 6793 vty_out (vty, " area %s shortcut %s%s", buf, 6794 ospf_shortcut_mode_str[area->shortcut_configured], 6795 VTY_NEWLINE); 6796 6797 if ((area->external_routing == OSPF_AREA_STUB) 6798#ifdef HAVE_NSSA 6799 || (area->external_routing == OSPF_AREA_NSSA) 6800#endif /* HAVE_NSSA */ 6801 ) 6802 { 6803#ifdef HAVE_NSSA 6804 if (area->external_routing == OSPF_AREA_NSSA) 6805 vty_out (vty, " area %s nssa", buf); 6806 else 6807#endif /* HAVE_NSSA */ 6808 vty_out (vty, " area %s stub", buf); 6809 6810 if (area->no_summary) 6811 vty_out (vty, " no-summary"); 6812 6813 vty_out (vty, "%s", VTY_NEWLINE); 6814 6815 if (area->default_cost != 1) 6816 vty_out (vty, " area %s default-cost %d%s", buf, 6817 area->default_cost, VTY_NEWLINE); 6818 } 6819 6820 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) 6821 if (rn1->info) 6822 { 6823 struct ospf_area_range *range = rn1->info; 6824 6825 vty_out (vty, " area %s range %s/%d", buf, 6826 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); 6827 6828 if (range->cost_config != -1) 6829 vty_out (vty, " cost %d", range->cost_config); 6830 6831 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) 6832 vty_out (vty, " not-advertise"); 6833 6834 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) 6835 vty_out (vty, " substitute %s/%d", 6836 inet_ntoa (range->subst_addr), range->subst_masklen); 6837 6838 vty_out (vty, "%s", VTY_NEWLINE); 6839 } 6840 6841 if (EXPORT_NAME (area)) 6842 vty_out (vty, " area %s export-list %s%s", buf, 6843 EXPORT_NAME (area), VTY_NEWLINE); 6844 6845 if (IMPORT_NAME (area)) 6846 vty_out (vty, " area %s import-list %s%s", buf, 6847 IMPORT_NAME (area), VTY_NEWLINE); 6848 6849 if (PREFIX_NAME_IN (area)) 6850 vty_out (vty, " area %s filter-list prefix %s in%s", buf, 6851 PREFIX_NAME_IN (area), VTY_NEWLINE); 6852 6853 if (PREFIX_NAME_OUT (area)) 6854 vty_out (vty, " area %s filter-list prefix %s out%s", buf, 6855 PREFIX_NAME_OUT (area), VTY_NEWLINE); 6856 } 6857 6858 return 0; 6859} 6860 6861int 6862config_write_ospf_nbr_nbma (struct vty *vty) 6863{ 6864 struct ospf_nbr_nbma *nbr_nbma; 6865 struct route_node *rn; 6866 6867 /* Static Neighbor configuration print. */ 6868 for (rn = route_top (ospf_top->nbr_nbma); rn; rn = route_next (rn)) 6869 if ((nbr_nbma = rn->info)) 6870 { 6871 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); 6872 6873 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) 6874 vty_out (vty, " priority %d", nbr_nbma->priority); 6875 6876 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) 6877 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); 6878 6879 vty_out (vty, "%s", VTY_NEWLINE); 6880 } 6881 6882 return 0; 6883} 6884 6885int 6886config_write_virtual_link (struct vty *vty) 6887{ 6888 listnode node; 6889 u_char buf[INET_ADDRSTRLEN]; 6890 6891 /* Virtual-Link print */ 6892 for (node = listhead (ospf_top->vlinks); node; nextnode (node)) 6893 { 6894 listnode n2; 6895 struct crypt_key *ck; 6896 struct ospf_vl_data *vl_data = getdata (node); 6897 struct ospf_interface *oi; 6898 6899 if (vl_data != NULL) 6900 { 6901 memset (buf, 0, INET_ADDRSTRLEN); 6902 6903 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) 6904 strncpy (buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); 6905 else 6906 sprintf (buf, "%lu", 6907 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); 6908 oi = vl_data->vl_oi; 6909 6910 /* timers */ 6911 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || 6912 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || 6913 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || 6914 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) 6915 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", 6916 buf, 6917 inet_ntoa (vl_data->vl_peer), 6918 OSPF_IF_PARAM (oi, v_hello), 6919 OSPF_IF_PARAM (oi, retransmit_interval), 6920 OSPF_IF_PARAM (oi, transmit_delay), 6921 OSPF_IF_PARAM (oi, v_wait), 6922 VTY_NEWLINE); 6923 else 6924 vty_out (vty, " area %s virtual-link %s%s", buf, 6925 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); 6926 /* Auth key */ 6927 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') 6928 vty_out (vty, " area %s virtual-link %s authentication-key %s%s", 6929 buf, 6930 inet_ntoa (vl_data->vl_peer), 6931 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, 6932 VTY_NEWLINE); 6933 /* md5 keys */ 6934 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2)) 6935 { 6936 ck = getdata (n2); 6937 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s", 6938 buf, 6939 inet_ntoa (vl_data->vl_peer), 6940 ck->key_id, ck->auth_key, VTY_NEWLINE); 6941 } 6942 6943 } 6944 } 6945 6946 return 0; 6947} 6948 6949 6950char *distribute_str[] = { "system", "kernel", "connected", "static", "rip", 6951 "ripng", "ospf", "ospf6", "bgp"}; 6952int 6953config_write_ospf_redistribute (struct vty *vty) 6954{ 6955 int type; 6956 6957 /* redistribute print. */ 6958 for (type = 0; type < ZEBRA_ROUTE_MAX; type++) 6959 if (type != zclient->redist_default && zclient->redist[type]) 6960 { 6961 vty_out (vty, " redistribute %s", distribute_str[type]); 6962 if (ospf_top->dmetric[type].value >= 0) 6963 vty_out (vty, " metric %d", ospf_top->dmetric[type].value); 6964 6965 if (ospf_top->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) 6966 vty_out (vty, " metric-type 1"); 6967 6968 if (ROUTEMAP_NAME (type)) 6969 vty_out (vty, " route-map %s", ROUTEMAP_NAME (type)); 6970 6971 vty_out (vty, "%s", VTY_NEWLINE); 6972 } 6973 6974 return 0; 6975} 6976 6977int 6978config_write_ospf_default_metric (struct vty *vty) 6979{ 6980 if (ospf_top->default_metric != -1) 6981 vty_out (vty, " default-metric %d%s", ospf_top->default_metric, 6982 VTY_NEWLINE); 6983 return 0; 6984} 6985 6986int 6987config_write_ospf_distribute (struct vty *vty) 6988{ 6989 int type; 6990 6991 if (ospf_top) 6992 { 6993 /* distribute-list print. */ 6994 for (type = 0; type < ZEBRA_ROUTE_MAX; type++) 6995 if (ospf_top->dlist[type].name) 6996 vty_out (vty, " distribute-list %s out %s%s", 6997 ospf_top->dlist[type].name, 6998 distribute_str[type], VTY_NEWLINE); 6999 7000 /* default-information print. */ 7001 if (ospf_top->default_originate != DEFAULT_ORIGINATE_NONE) 7002 { 7003 if (ospf_top->default_originate == DEFAULT_ORIGINATE_ZEBRA) 7004 vty_out (vty, " default-information originate"); 7005 else 7006 vty_out (vty, " default-information originate always"); 7007 7008 if (ospf_top->dmetric[DEFAULT_ROUTE].value >= 0) 7009 vty_out (vty, " metric %d", 7010 ospf_top->dmetric[DEFAULT_ROUTE].value); 7011 if (ospf_top->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) 7012 vty_out (vty, " metric-type 1"); 7013 7014 if (ROUTEMAP_NAME (DEFAULT_ROUTE)) 7015 vty_out (vty, " route-map %s", ROUTEMAP_NAME (DEFAULT_ROUTE)); 7016 7017 vty_out (vty, "%s", VTY_NEWLINE); 7018 } 7019 7020 } 7021 7022 return 0; 7023} 7024 7025int 7026config_write_ospf_distance (struct vty *vty) 7027{ 7028 struct route_node *rn; 7029 struct ospf_distance *odistance; 7030 7031 if (ospf_top->distance_all) 7032 vty_out (vty, " distance %d%s", ospf_top->distance_all, VTY_NEWLINE); 7033 7034 if (ospf_top->distance_intra 7035 || ospf_top->distance_inter 7036 || ospf_top->distance_external) 7037 { 7038 vty_out (vty, " distance ospf"); 7039 7040 if (ospf_top->distance_intra) 7041 vty_out (vty, " intra-area %d", ospf_top->distance_intra); 7042 if (ospf_top->distance_inter) 7043 vty_out (vty, " inter-area %d", ospf_top->distance_inter); 7044 if (ospf_top->distance_external) 7045 vty_out (vty, " external %d", ospf_top->distance_external); 7046 7047 vty_out (vty, "%s", VTY_NEWLINE); 7048 } 7049 7050 for (rn = route_top (ospf_top->distance_table); rn; rn = route_next (rn)) 7051 if ((odistance = rn->info) != NULL) 7052 { 7053 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, 7054 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, 7055 odistance->access_list ? odistance->access_list : "", 7056 VTY_NEWLINE); 7057 } 7058 return 0; 7059} 7060 7061/* OSPF configuration write function. */ 7062int 7063ospf_config_write (struct vty *vty) 7064{ 7065 listnode node; 7066 int write = 0; 7067 7068 if (ospf_top != NULL) 7069 { 7070 /* `router ospf' print. */ 7071 vty_out (vty, "router ospf%s", VTY_NEWLINE); 7072 7073 write++; 7074 7075 if (!ospf_top->networks) 7076 return write; 7077 7078 /* Router ID print. */ 7079 if (ospf_top->router_id_static.s_addr != 0) 7080 vty_out (vty, " ospf router-id %s%s", 7081 inet_ntoa (ospf_top->router_id_static), VTY_NEWLINE); 7082 7083 /* ABR type print. */ 7084 if (ospf_top->abr_type != OSPF_ABR_STAND) 7085 vty_out (vty, " ospf abr-type %s%s", 7086 ospf_abr_type_str[ospf_top->abr_type], VTY_NEWLINE); 7087 7088 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ 7089 if (CHECK_FLAG (ospf_top->config, OSPF_RFC1583_COMPATIBLE)) 7090 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); 7091 7092 /* auto-cost reference-bandwidth configuration. */ 7093 if (ospf_top->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) 7094 vty_out (vty, " auto-cost reference-bandwidth %d%s", 7095 ospf_top->ref_bandwidth / 1000, VTY_NEWLINE); 7096 7097 /* SPF timers print. */ 7098 if (ospf_top->spf_delay != OSPF_SPF_DELAY_DEFAULT || 7099 ospf_top->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT) 7100 vty_out (vty, " timers spf %d %d%s", 7101 ospf_top->spf_delay, ospf_top->spf_holdtime, VTY_NEWLINE); 7102 7103 /* SPF refresh parameters print. */ 7104 if (ospf_top->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) 7105 vty_out (vty, " refresh timer %d%s", 7106 ospf_top->lsa_refresh_interval, VTY_NEWLINE); 7107 7108 /* Redistribute information print. */ 7109 config_write_ospf_redistribute (vty); 7110 7111 /* passive-interface print. */ 7112 for (node = listhead (ospf_top->iflist); node; nextnode (node)) 7113 { 7114 struct interface *ifp = getdata (node); 7115 7116 if (!ifp) 7117 continue; 7118 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE) 7119 vty_out (vty, " passive-interface %s%s", 7120 ifp->name, VTY_NEWLINE); 7121 } 7122 7123 for (node = listhead (ospf_top->oiflist); node; nextnode (node)) 7124 { 7125 struct ospf_interface *oi = getdata (node); 7126 7127 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) && 7128 oi->params->passive_interface == OSPF_IF_PASSIVE) 7129 vty_out (vty, " passive-interface %s%s", 7130 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); 7131 } 7132 7133 7134 /* Network area print. */ 7135 config_write_network_area (vty); 7136 7137 /* Area config print. */ 7138 config_write_ospf_area (vty); 7139 7140 /* static neighbor print. */ 7141 config_write_ospf_nbr_nbma (vty); 7142 7143 /* Virtual-Link print. */ 7144 config_write_virtual_link (vty); 7145 7146 /* Default metric configuration. */ 7147 config_write_ospf_default_metric (vty); 7148 7149 /* Distribute-list and default-information print. */ 7150 config_write_ospf_distribute (vty); 7151 7152 /* Distance configuration. */ 7153 config_write_ospf_distance (vty); 7154 7155#ifdef HAVE_OPAQUE_LSA 7156 ospf_opaque_config_write_router (vty, ospf_top); 7157#endif /* HAVE_OPAQUE_LSA */ 7158 } 7159 7160 return write; 7161} 7162 7163void 7164ospf_vty_show_init () 7165{ 7166 /* "show ip ospf" commands. */ 7167 install_element (VIEW_NODE, &show_ip_ospf_cmd); 7168 install_element (ENABLE_NODE, &show_ip_ospf_cmd); 7169 7170 /* "show ip ospf database" commands. */ 7171 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); 7172 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); 7173 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); 7174 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); 7175 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); 7176 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); 7177 install_element (VIEW_NODE, &show_ip_ospf_database_cmd); 7178 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); 7179 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); 7180 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); 7181 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); 7182 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); 7183 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); 7184 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); 7185 7186 /* "show ip ospf interface" commands. */ 7187 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); 7188 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); 7189 7190 /* "show ip ospf neighbor" commands. */ 7191 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); 7192 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); 7193 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); 7194 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); 7195 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); 7196 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); 7197 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); 7198 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); 7199 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); 7200 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); 7201 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); 7202 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); 7203 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); 7204 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); 7205 7206 /* "show ip ospf route" commands. */ 7207 install_element (VIEW_NODE, &show_ip_ospf_route_cmd); 7208 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); 7209#ifdef HAVE_NSSA 7210 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); 7211 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); 7212#endif /* HAVE_NSSA */ 7213} 7214 7215 7216/* ospfd's interface node. */ 7217struct cmd_node interface_node = 7218{ 7219 INTERFACE_NODE, 7220 "%s(config-if)# ", 7221 1 7222}; 7223 7224/* Initialization of OSPF interface. */ 7225void 7226ospf_vty_if_init () 7227{ 7228 /* Install interface node. */ 7229 install_node (&interface_node, config_write_interface); 7230 7231 install_element (CONFIG_NODE, &interface_cmd); 7232 install_default (INTERFACE_NODE); 7233 7234 /* "description" commands. */ 7235 install_element (INTERFACE_NODE, &interface_desc_cmd); 7236 install_element (INTERFACE_NODE, &no_interface_desc_cmd); 7237 7238 /* "ip ospf authentication" commands. */ 7239 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); 7240 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); 7241 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); 7242 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); 7243 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); 7244 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); 7245 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); 7246 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); 7247 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); 7248 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); 7249 7250 /* "ip ospf message-digest-key" commands. */ 7251 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); 7252 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); 7253 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); 7254 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); 7255 7256 /* "ip ospf cost" commands. */ 7257 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd); 7258 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); 7259 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd); 7260 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); 7261 7262 /* "ip ospf dead-interval" commands. */ 7263 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); 7264 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); 7265 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); 7266 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); 7267 7268 /* "ip ospf hello-interval" commands. */ 7269 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); 7270 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); 7271 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); 7272 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); 7273 7274 /* "ip ospf network" commands. */ 7275 install_element (INTERFACE_NODE, &ip_ospf_network_cmd); 7276 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); 7277 7278 /* "ip ospf priority" commands. */ 7279 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); 7280 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); 7281 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); 7282 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); 7283 7284 /* "ip ospf retransmit-interval" commands. */ 7285 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); 7286 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); 7287 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); 7288 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); 7289 7290 /* "ip ospf transmit-delay" commands. */ 7291 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); 7292 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); 7293 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); 7294 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); 7295 7296 /* These commands are compatibitliy for previous version. */ 7297 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); 7298 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); 7299 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); 7300 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); 7301 install_element (INTERFACE_NODE, &ospf_cost_cmd); 7302 install_element (INTERFACE_NODE, &no_ospf_cost_cmd); 7303 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); 7304 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); 7305 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); 7306 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); 7307 install_element (INTERFACE_NODE, &ospf_network_cmd); 7308 install_element (INTERFACE_NODE, &no_ospf_network_cmd); 7309 install_element (INTERFACE_NODE, &ospf_priority_cmd); 7310 install_element (INTERFACE_NODE, &no_ospf_priority_cmd); 7311 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); 7312 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); 7313 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); 7314 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); 7315} 7316 7317/* Zebra node structure. */ 7318struct cmd_node zebra_node = 7319{ 7320 ZEBRA_NODE, 7321 "%s(config-router)#", 7322}; 7323 7324void 7325ospf_vty_zebra_init () 7326{ 7327 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd); 7328 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd); 7329 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd); 7330 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd); 7331 install_element (OSPF_NODE, &ospf_redistribute_source_cmd); 7332 install_element (OSPF_NODE, 7333 &ospf_redistribute_source_metric_type_routemap_cmd); 7334 install_element (OSPF_NODE, 7335 &ospf_redistribute_source_type_metric_routemap_cmd); 7336 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd); 7337 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd); 7338 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd); 7339 7340 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); 7341 7342 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); 7343 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); 7344 7345 install_element (OSPF_NODE, 7346 &ospf_default_information_originate_metric_type_cmd); 7347 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd); 7348 install_element (OSPF_NODE, 7349 &ospf_default_information_originate_type_metric_cmd); 7350 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd); 7351 install_element (OSPF_NODE, &ospf_default_information_originate_cmd); 7352 install_element (OSPF_NODE, 7353 &ospf_default_information_originate_always_metric_type_cmd); 7354 install_element (OSPF_NODE, 7355 &ospf_default_information_originate_always_metric_cmd); 7356 install_element (OSPF_NODE, 7357 &ospf_default_information_originate_always_cmd); 7358 install_element (OSPF_NODE, 7359 &ospf_default_information_originate_always_type_metric_cmd); 7360 install_element (OSPF_NODE, 7361 &ospf_default_information_originate_always_type_cmd); 7362 7363 install_element (OSPF_NODE, 7364 &ospf_default_information_originate_metric_type_routemap_cmd); 7365 install_element (OSPF_NODE, 7366 &ospf_default_information_originate_metric_routemap_cmd); 7367 install_element (OSPF_NODE, 7368 &ospf_default_information_originate_routemap_cmd); 7369 install_element (OSPF_NODE, 7370 &ospf_default_information_originate_type_metric_routemap_cmd); 7371 install_element (OSPF_NODE, 7372 &ospf_default_information_originate_type_routemap_cmd); 7373 install_element (OSPF_NODE, 7374 &ospf_default_information_originate_always_metric_type_routemap_cmd); 7375 install_element (OSPF_NODE, 7376 &ospf_default_information_originate_always_metric_routemap_cmd); 7377 install_element (OSPF_NODE, 7378 &ospf_default_information_originate_always_routemap_cmd); 7379 install_element (OSPF_NODE, 7380 &ospf_default_information_originate_always_type_metric_routemap_cmd); 7381 install_element (OSPF_NODE, 7382 &ospf_default_information_originate_always_type_routemap_cmd); 7383 7384 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); 7385 7386 install_element (OSPF_NODE, &ospf_default_metric_cmd); 7387 install_element (OSPF_NODE, &no_ospf_default_metric_cmd); 7388 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); 7389 7390 install_element (OSPF_NODE, &ospf_distance_cmd); 7391 install_element (OSPF_NODE, &no_ospf_distance_cmd); 7392 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); 7393 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd); 7394 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd); 7395 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd); 7396 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd); 7397 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd); 7398 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd); 7399 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd); 7400 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd); 7401 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd); 7402 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd); 7403 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd); 7404 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd); 7405 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd); 7406 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd); 7407 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd); 7408#if 0 7409 install_element (OSPF_NODE, &ospf_distance_source_cmd); 7410 install_element (OSPF_NODE, &no_ospf_distance_source_cmd); 7411 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); 7412 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); 7413#endif /* 0 */ 7414} 7415 7416struct cmd_node ospf_node = 7417{ 7418 OSPF_NODE, 7419 "%s(config-router)# ", 7420 1 7421}; 7422 7423 7424/* Install OSPF related vty commands. */ 7425void 7426ospf_vty_init () 7427{ 7428 /* Install ospf top node. */ 7429 install_node (&ospf_node, ospf_config_write); 7430 7431 /* "router ospf" commands. */ 7432 install_element (CONFIG_NODE, &router_ospf_cmd); 7433 install_element (CONFIG_NODE, &no_router_ospf_cmd); 7434 7435 install_default (OSPF_NODE); 7436 7437 /* "ospf router-id" commands. */ 7438 install_element (OSPF_NODE, &ospf_router_id_cmd); 7439 install_element (OSPF_NODE, &no_ospf_router_id_cmd); 7440 install_element (OSPF_NODE, &router_id_cmd); 7441 install_element (OSPF_NODE, &no_router_id_cmd); 7442 7443 /* "passive-interface" commands. */ 7444 install_element (OSPF_NODE, &passive_interface_addr_cmd); 7445 install_element (OSPF_NODE, &passive_interface_cmd); 7446 install_element (OSPF_NODE, &no_passive_interface_addr_cmd); 7447 install_element (OSPF_NODE, &no_passive_interface_cmd); 7448 7449 /* "ospf abr-type" commands. */ 7450 install_element (OSPF_NODE, &ospf_abr_type_cmd); 7451 install_element (OSPF_NODE, &no_ospf_abr_type_cmd); 7452 7453 /* "ospf rfc1583-compatible" commands. */ 7454 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); 7455 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); 7456 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); 7457 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); 7458 7459 /* "network area" commands. */ 7460 install_element (OSPF_NODE, &network_area_cmd); 7461 install_element (OSPF_NODE, &no_network_area_cmd); 7462 7463 /* "area authentication" commands. */ 7464 install_element (OSPF_NODE, &area_authentication_message_digest_cmd); 7465 install_element (OSPF_NODE, &area_authentication_cmd); 7466 install_element (OSPF_NODE, &no_area_authentication_cmd); 7467 7468 /* "area range" commands. */ 7469 install_element (OSPF_NODE, &area_range_cmd); 7470 install_element (OSPF_NODE, &area_range_advertise_cmd); 7471 install_element (OSPF_NODE, &area_range_cost_cmd); 7472 install_element (OSPF_NODE, &area_range_advertise_cost_cmd); 7473 install_element (OSPF_NODE, &area_range_not_advertise_cmd); 7474 install_element (OSPF_NODE, &no_area_range_cmd); 7475 install_element (OSPF_NODE, &no_area_range_advertise_cmd); 7476 install_element (OSPF_NODE, &no_area_range_cost_cmd); 7477 install_element (OSPF_NODE, &no_area_range_advertise_cost_cmd); 7478 install_element (OSPF_NODE, &area_range_substitute_cmd); 7479 install_element (OSPF_NODE, &no_area_range_substitute_cmd); 7480 7481 /* "area virtual-link" commands. */ 7482 install_element (OSPF_NODE, &area_vlink_cmd); 7483 install_element (OSPF_NODE, &no_area_vlink_cmd); 7484 7485 install_element (OSPF_NODE, &area_vlink_param1_cmd); 7486 install_element (OSPF_NODE, &no_area_vlink_param1_cmd); 7487 7488 install_element (OSPF_NODE, &area_vlink_param2_cmd); 7489 install_element (OSPF_NODE, &no_area_vlink_param2_cmd); 7490 7491 install_element (OSPF_NODE, &area_vlink_param3_cmd); 7492 install_element (OSPF_NODE, &no_area_vlink_param3_cmd); 7493 7494 install_element (OSPF_NODE, &area_vlink_param4_cmd); 7495 install_element (OSPF_NODE, &no_area_vlink_param4_cmd); 7496 7497 install_element (OSPF_NODE, &area_vlink_authtype_args_cmd); 7498 install_element (OSPF_NODE, &area_vlink_authtype_cmd); 7499 install_element (OSPF_NODE, &no_area_vlink_authtype_cmd); 7500 7501 install_element (OSPF_NODE, &area_vlink_md5_cmd); 7502 install_element (OSPF_NODE, &no_area_vlink_md5_cmd); 7503 7504 install_element (OSPF_NODE, &area_vlink_authkey_cmd); 7505 install_element (OSPF_NODE, &no_area_vlink_authkey_cmd); 7506 7507 install_element (OSPF_NODE, &area_vlink_authtype_args_authkey_cmd); 7508 install_element (OSPF_NODE, &area_vlink_authtype_authkey_cmd); 7509 install_element (OSPF_NODE, &no_area_vlink_authtype_authkey_cmd); 7510 7511 install_element (OSPF_NODE, &area_vlink_authtype_args_md5_cmd); 7512 install_element (OSPF_NODE, &area_vlink_authtype_md5_cmd); 7513 install_element (OSPF_NODE, &no_area_vlink_authtype_md5_cmd); 7514 7515 /* "area stub" commands. */ 7516 install_element (OSPF_NODE, &area_stub_no_summary_cmd); 7517 install_element (OSPF_NODE, &area_stub_cmd); 7518 install_element (OSPF_NODE, &no_area_stub_no_summary_cmd); 7519 install_element (OSPF_NODE, &no_area_stub_cmd); 7520 7521#ifdef HAVE_NSSA 7522 /* "area nssa" commands. */ 7523 install_element (OSPF_NODE, &area_nssa_cmd); 7524 install_element (OSPF_NODE, &area_nssa_translate_no_summary_cmd); 7525 install_element (OSPF_NODE, &area_nssa_translate_cmd); 7526 install_element (OSPF_NODE, &area_nssa_no_summary_cmd); 7527 install_element (OSPF_NODE, &no_area_nssa_cmd); 7528 install_element (OSPF_NODE, &no_area_nssa_no_summary_cmd); 7529#endif /* HAVE_NSSA */ 7530 7531 install_element (OSPF_NODE, &area_default_cost_cmd); 7532 install_element (OSPF_NODE, &no_area_default_cost_cmd); 7533 7534 install_element (OSPF_NODE, &area_shortcut_cmd); 7535 install_element (OSPF_NODE, &no_area_shortcut_cmd); 7536 7537 install_element (OSPF_NODE, &area_export_list_cmd); 7538 install_element (OSPF_NODE, &no_area_export_list_cmd); 7539 7540 install_element (OSPF_NODE, &area_filter_list_cmd); 7541 install_element (OSPF_NODE, &no_area_filter_list_cmd); 7542 7543 install_element (OSPF_NODE, &area_import_list_cmd); 7544 install_element (OSPF_NODE, &no_area_import_list_cmd); 7545 7546 install_element (OSPF_NODE, &timers_spf_cmd); 7547 install_element (OSPF_NODE, &no_timers_spf_cmd); 7548 7549 install_element (OSPF_NODE, &refresh_timer_cmd); 7550 install_element (OSPF_NODE, &no_refresh_timer_val_cmd); 7551 install_element (OSPF_NODE, &no_refresh_timer_cmd); 7552 7553 install_element (OSPF_NODE, &auto_cost_reference_bandwidth_cmd); 7554 install_element (OSPF_NODE, &no_auto_cost_reference_bandwidth_cmd); 7555 7556 /* "neighbor" commands. */ 7557 install_element (OSPF_NODE, &neighbor_cmd); 7558 install_element (OSPF_NODE, &neighbor_priority_poll_interval_cmd); 7559 install_element (OSPF_NODE, &neighbor_priority_cmd); 7560 install_element (OSPF_NODE, &neighbor_poll_interval_cmd); 7561 install_element (OSPF_NODE, &neighbor_poll_interval_priority_cmd); 7562 install_element (OSPF_NODE, &no_neighbor_cmd); 7563 install_element (OSPF_NODE, &no_neighbor_priority_cmd); 7564 install_element (OSPF_NODE, &no_neighbor_poll_interval_cmd); 7565 7566 /* Init interface related vty commands. */ 7567 ospf_vty_if_init (); 7568 7569 /* Init zebra related vty commands. */ 7570 ospf_vty_zebra_init (); 7571} 7572 7573