2  * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
 
   3  * Copyright (C) 2000 Toshiaki Takada
 
   5  * This file is part of GNU Zebra.
 
   7  * GNU Zebra is free software; you can redistribute it and/or modify it
 
   8  * under the terms of the GNU General Public License as published by the
 
   9  * Free Software Foundation; either version 2, or (at your option) any
 
  12  * GNU Zebra is distributed in the hope that it will be useful, but
 
  13  * WITHOUT ANY WARRANTY; without even the implied warranty of
 
  14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
  15  * General Public License for more details.
 
  17  * You should have received a copy of the GNU General Public License
 
  18  * along with GNU Zebra; see the file COPYING.  If not, write to the Free
 
  19  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
  35 #include "ospfd/ospfd.h"
 
  36 #include "ospfd/ospf_asbr.h"
 
  37 #include "ospfd/ospf_lsa.h"
 
  38 #include "ospfd/ospf_lsdb.h"
 
  39 #include "ospfd/ospf_ism.h"
 
  40 #include "ospfd/ospf_interface.h"
 
  41 #include "ospfd/ospf_nsm.h"
 
  42 #include "ospfd/ospf_neighbor.h"
 
  43 #include "ospfd/ospf_flood.h"
 
  44 #include "ospfd/ospf_abr.h"
 
  45 #include "ospfd/ospf_spf.h"
 
  46 #include "ospfd/ospf_route.h"
 
  47 #include "ospfd/ospf_zebra.h"
 
  48 /*#include "ospfd/ospf_routemap.h" */
 
  49 #include "ospfd/ospf_vty.h"
 
  50 #include "ospfd/ospf_dump.h"
 
  53 static const char *ospf_network_type_str[] =
 
  65 /* Utility functions. */
 
  67 ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
 
  72   /* match "A.B.C.D". */
 
  73   if (strchr (str, '.') != NULL)
 
  75       ret = inet_aton (str, area_id);
 
  78       *format = OSPF_AREA_ID_FORMAT_ADDRESS;
 
  80   /* match "<0-4294967295>". */
 
  86       ret = strtoul (str, &endptr, 10);
 
  87       if (*endptr != '\0' || errno || ret > UINT32_MAX)
 
  90       area_id->s_addr = htonl (ret);
 
  91       *format = OSPF_AREA_ID_FORMAT_DECIMAL;
 
  99 str2metric (const char *str, int *metric)
 
 105   *metric = strtol (str, NULL, 10);
 
 106   if (*metric < 0 && *metric > 16777214)
 
 108       /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
 
 116 str2metric_type (const char *str, int *metric_type)
 
 122   if (strncmp (str, "1", 1) == 0)
 
 123     *metric_type = EXTERNAL_METRIC_TYPE_1;
 
 124   else if (strncmp (str, "2", 1) == 0)
 
 125     *metric_type = EXTERNAL_METRIC_TYPE_2;
 
 133 ospf_oi_count (struct interface *ifp)
 
 135   struct route_node *rn;
 
 138   for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
 
 149        "Enable a routing process\n"
 
 150        "Start OSPF configuration\n")
 
 152   vty->node = OSPF_NODE;
 
 153   vty->index = ospf_get ();
 
 158 DEFUN (no_router_ospf,
 
 162        "Enable a routing process\n"
 
 163        "Start OSPF configuration\n")
 
 167   ospf = ospf_lookup ();
 
 170       vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
 
 179 DEFUN (ospf_router_id,
 
 181        "ospf router-id A.B.C.D",
 
 182        "OSPF specific commands\n"
 
 183        "router-id for the OSPF process\n"
 
 184        "OSPF router-id in IP address format\n")
 
 186   struct ospf *ospf = vty->index;
 
 187   struct in_addr router_id;
 
 190   ret = inet_aton (argv[0], &router_id);
 
 193       vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
 
 197   ospf->router_id_static = router_id;
 
 199   ospf_router_id_update (ospf);
 
 204 ALIAS (ospf_router_id,
 
 207        "router-id for the OSPF process\n"
 
 208        "OSPF router-id in IP address format\n")
 
 210 DEFUN (no_ospf_router_id,
 
 211        no_ospf_router_id_cmd,
 
 214        "OSPF specific commands\n"
 
 215        "router-id for the OSPF process\n")
 
 217   struct ospf *ospf = vty->index;
 
 219   ospf->router_id_static.s_addr = 0;
 
 221   ospf_router_id_update (ospf);
 
 226 ALIAS (no_ospf_router_id,
 
 227        no_router_ospf_id_cmd,
 
 230        "router-id for the OSPF process\n")
 
 233 ospf_passive_interface_default (struct ospf *ospf, u_char newval)
 
 236   struct interface *ifp;
 
 237   struct ospf_interface *oi;
 
 239   ospf->passive_interface_default = newval;
 
 241   for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp))
 
 244           OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
 
 245         UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface);
 
 247   for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi))
 
 249       if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
 
 250         UNSET_IF_PARAM (oi->params, passive_interface);
 
 251       /* update multicast memberships */
 
 252       ospf_if_set_multicast(oi);
 
 257 ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp,
 
 258                                struct ospf_if_params *params, u_char value,
 
 263   params->passive_interface = value;
 
 264   if (params != IF_DEF_PARAMS (ifp))
 
 266       if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
 
 267         dflt = IF_DEF_PARAMS (ifp)->passive_interface;
 
 269         dflt = ospf->passive_interface_default;
 
 272         SET_IF_PARAM (params, passive_interface);
 
 274         UNSET_IF_PARAM (params, passive_interface);
 
 276       ospf_free_if_params (ifp, addr);
 
 277       ospf_if_update_params (ifp, addr);
 
 282 ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
 
 283                                struct ospf_if_params *params, u_char value)
 
 285   params->passive_interface = value;
 
 286   if (params == IF_DEF_PARAMS (ifp))
 
 288       if (value != ospf->passive_interface_default)
 
 289         SET_IF_PARAM (params, passive_interface);
 
 291         UNSET_IF_PARAM (params, passive_interface);
 
 295 /* get the appropriate ospf parameters structure, checking if
 
 296  * there's a valid interface address at the argi'th argv index
 
 302 #define OSPF_VTY_GET_IF_PARAMS(ifp,params,argi,addr,set) \
 
 303   (params) = IF_DEF_PARAMS ((ifp));           \
 
 305   if (argc == (argi) + 1)                     \
 
 307       int ret = inet_aton(argv[(argi)], &(addr)); \
 
 310           vty_out (vty, "Please specify interface address by A.B.C.D%s", \
 
 312           return CMD_WARNING;                 \
 
 314       (params) = ospf_get_if_params ((ifp), (addr)); \
 
 317         ospf_if_update_params ((ifp), (addr));  \
 
 318       else if ((params) == NULL)              \
 
 319         return CMD_SUCCESS;                   \
 
 322 #define OSPF_VTY_PARAM_UNSET(params,var,ifp,addr) \
 
 323   UNSET_IF_PARAM ((params), var);               \
 
 324     if ((params) != IF_DEF_PARAMS ((ifp)))        \
 
 326       ospf_free_if_params ((ifp), (addr));        \
 
 327       ospf_if_update_params ((ifp), (addr));      \
 
 330 DEFUN (ospf_passive_interface,
 
 331        ospf_passive_interface_addr_cmd,
 
 332        "passive-interface IFNAME A.B.C.D",
 
 333        "Suppress routing updates on an interface\n"
 
 334        "Interface's name\n")
 
 336   struct interface *ifp;
 
 339   struct ospf_if_params *params;
 
 340   struct route_node *rn;
 
 341   struct ospf *ospf = vty->index;
 
 345       ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
 
 349   ifp = if_get_by_name (argv[0]);
 
 351   params = IF_DEF_PARAMS (ifp);
 
 355       ret = inet_aton(argv[1], &addr);
 
 358           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
 363       params = ospf_get_if_params (ifp, addr);
 
 364       ospf_if_update_params (ifp, addr);
 
 365       ospf_passive_interface_update_addr (ospf, ifp, params,
 
 366                                           OSPF_IF_PASSIVE, addr);
 
 369   ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE);
 
 371   /* XXX We should call ospf_if_set_multicast on exactly those
 
 372    * interfaces for which the passive property changed.  It is too much
 
 373    * work to determine this set, so we do this for every interface.
 
 374    * This is safe and reasonable because ospf_if_set_multicast uses a
 
 375    * record of joined groups to avoid systems calls if the desired
 
 376    * memberships match the current memership.
 
 379   for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
 
 381       struct ospf_interface *oi = rn->info;
 
 383       if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
 
 384         ospf_if_set_multicast(oi);
 
 387    * XXX It is not clear what state transitions the interface needs to
 
 388    * undergo when going from active to passive.  Fixing this will
 
 389    * require precise identification of interfaces having such a
 
 396 ALIAS (ospf_passive_interface,
 
 397        ospf_passive_interface_cmd,
 
 398        "passive-interface IFNAME",
 
 399        "Suppress routing updates on an interface\n"
 
 400        "Interface's name\n")
 
 402 ALIAS (ospf_passive_interface,
 
 403        ospf_passive_interface_default_cmd,
 
 404        "passive-interface default",
 
 405        "Suppress routing updates on an interface\n"
 
 406        "Suppress routing updates on interfaces by default\n")
 
 408 DEFUN (no_ospf_passive_interface,
 
 409        no_ospf_passive_interface_addr_cmd,
 
 410        "no passive-interface IFNAME A.B.C.D",
 
 412        "Allow routing updates on an interface\n"
 
 413        "Interface's name\n")
 
 415   struct interface *ifp;
 
 417   struct ospf_if_params *params;
 
 419   struct route_node *rn;
 
 420   struct ospf *ospf = vty->index;
 
 424       ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
 
 428   ifp = if_get_by_name (argv[0]);
 
 430   params = IF_DEF_PARAMS (ifp);
 
 434       ret = inet_aton(argv[1], &addr);
 
 437           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
 442       params = ospf_lookup_if_params (ifp, addr);
 
 445       ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE, 
 
 448   ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE);
 
 450   /* XXX We should call ospf_if_set_multicast on exactly those
 
 451    * interfaces for which the passive property changed.  It is too much
 
 452    * work to determine this set, so we do this for every interface.
 
 453    * This is safe and reasonable because ospf_if_set_multicast uses a
 
 454    * record of joined groups to avoid systems calls if the desired
 
 455    * memberships match the current memership.
 
 457   for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
 
 459       struct ospf_interface *oi = rn->info;
 
 461       if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
 
 462         ospf_if_set_multicast(oi);
 
 468 ALIAS (no_ospf_passive_interface,
 
 469        no_ospf_passive_interface_cmd,
 
 470        "no passive-interface IFNAME",
 
 472        "Allow routing updates on an interface\n"
 
 473        "Interface's name\n")
 
 475 ALIAS (no_ospf_passive_interface,
 
 476        no_ospf_passive_interface_default_cmd,
 
 477        "no passive-interface default",
 
 479        "Allow routing updates on an interface\n"
 
 480        "Allow routing updates on interfaces by default\n")
 
 482 DEFUN (ospf_network_area,
 
 483        ospf_network_area_cmd,
 
 484        "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
 
 485        "Enable routing on an IP network\n"
 
 486        "OSPF network prefix\n"
 
 487        "Set the OSPF area ID\n"
 
 488        "OSPF area ID in IP address format\n"
 
 489        "OSPF area ID as a decimal value\n")
 
 491   struct ospf *ospf = vty->index;
 
 492   struct prefix_ipv4 p;
 
 493   struct in_addr area_id;
 
 496   /* Get network prefix and Area ID. */
 
 497   VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
 
 498   VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
 
 500   ret = ospf_network_set (ospf, &p, area_id);
 
 503       vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
 
 510 DEFUN (no_ospf_network_area,
 
 511        no_ospf_network_area_cmd,
 
 512        "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
 
 514        "Enable routing on an IP network\n"
 
 515        "OSPF network prefix\n"
 
 516        "Set the OSPF area ID\n"
 
 517        "OSPF area ID in IP address format\n"
 
 518        "OSPF area ID as a decimal value\n")
 
 520   struct ospf *ospf = (struct ospf *) vty->index;
 
 521   struct prefix_ipv4 p;
 
 522   struct in_addr area_id;
 
 525   /* Get network prefix and Area ID. */
 
 526   VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
 
 527   VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
 
 529   ret = ospf_network_unset (ospf, &p, area_id);
 
 532       vty_out (vty, "Can't find specified network area configuration.%s",
 
 541 DEFUN (ospf_area_range,
 
 543        "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
 
 544        "OSPF area parameters\n"
 
 545        "OSPF area ID in IP address format\n"
 
 546        "OSPF area ID as a decimal value\n"
 
 547        "Summarize routes matching address/mask (border routers only)\n"
 
 548        "Area range prefix\n")
 
 550   struct ospf *ospf = vty->index;
 
 551   struct prefix_ipv4 p;
 
 552   struct in_addr area_id;
 
 556   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
 557   VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
 
 559   ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
 
 562       VTY_GET_INTEGER ("range cost", cost, argv[2]);
 
 563       ospf_area_range_cost_set (ospf, area_id, &p, cost);
 
 569 ALIAS (ospf_area_range,
 
 570        ospf_area_range_advertise_cmd,
 
 571        "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
 
 572        "OSPF area parameters\n"
 
 573        "OSPF area ID in IP address format\n"
 
 574        "OSPF area ID as a decimal value\n"
 
 575        "OSPF area range for route advertise (default)\n"
 
 576        "Area range prefix\n"
 
 577        "Advertise this range (default)\n")
 
 579 ALIAS (ospf_area_range,
 
 580        ospf_area_range_cost_cmd,
 
 581        "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
 
 582        "OSPF area parameters\n"
 
 583        "OSPF area ID in IP address format\n"
 
 584        "OSPF area ID as a decimal value\n"
 
 585        "Summarize routes matching address/mask (border routers only)\n"
 
 586        "Area range prefix\n"
 
 587        "User specified metric for this range\n"
 
 588        "Advertised metric for this range\n")
 
 590 ALIAS (ospf_area_range,
 
 591        ospf_area_range_advertise_cost_cmd,
 
 592        "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
 
 593        "OSPF area parameters\n"
 
 594        "OSPF area ID in IP address format\n"
 
 595        "OSPF area ID as a decimal value\n"
 
 596        "Summarize routes matching address/mask (border routers only)\n"
 
 597        "Area range prefix\n"
 
 598        "Advertise this range (default)\n"
 
 599        "User specified metric for this range\n"
 
 600        "Advertised metric for this range\n")
 
 602 DEFUN (ospf_area_range_not_advertise,
 
 603        ospf_area_range_not_advertise_cmd,
 
 604        "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
 
 605        "OSPF area parameters\n"
 
 606        "OSPF area ID in IP address format\n"
 
 607        "OSPF area ID as a decimal value\n"
 
 608        "Summarize routes matching address/mask (border routers only)\n"
 
 609        "Area range prefix\n"
 
 610        "DoNotAdvertise this range\n")
 
 612   struct ospf *ospf = vty->index;
 
 613   struct prefix_ipv4 p;
 
 614   struct in_addr area_id;
 
 617   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
 618   VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
 
 620   ospf_area_range_set (ospf, area_id, &p, 0);
 
 625 DEFUN (no_ospf_area_range,
 
 626        no_ospf_area_range_cmd,
 
 627        "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
 
 629        "OSPF area parameters\n"
 
 630        "OSPF area ID in IP address format\n"
 
 631        "OSPF area ID as a decimal value\n"
 
 632        "Summarize routes matching address/mask (border routers only)\n"
 
 633        "Area range prefix\n")
 
 635   struct ospf *ospf = vty->index;
 
 636   struct prefix_ipv4 p;
 
 637   struct in_addr area_id;
 
 640   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
 641   VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
 
 643   ospf_area_range_unset (ospf, area_id, &p);
 
 648 ALIAS (no_ospf_area_range,
 
 649        no_ospf_area_range_advertise_cmd,
 
 650        "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
 
 652        "OSPF area parameters\n"
 
 653        "OSPF area ID in IP address format\n"
 
 654        "OSPF area ID as a decimal value\n"
 
 655        "Summarize routes matching address/mask (border routers only)\n"
 
 656        "Area range prefix\n"
 
 657        "Advertise this range (default)\n"
 
 658        "DoNotAdvertise this range\n")
 
 660 ALIAS (no_ospf_area_range,
 
 661        no_ospf_area_range_cost_cmd,
 
 662        "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
 
 664        "OSPF area parameters\n"
 
 665        "OSPF area ID in IP address format\n"
 
 666        "OSPF area ID as a decimal value\n"
 
 667        "Summarize routes matching address/mask (border routers only)\n"
 
 668        "Area range prefix\n"
 
 669        "User specified metric for this range\n"
 
 670        "Advertised metric for this range\n")
 
 672 ALIAS (no_ospf_area_range,
 
 673        no_ospf_area_range_advertise_cost_cmd,
 
 674        "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
 
 676        "OSPF area parameters\n"
 
 677        "OSPF area ID in IP address format\n"
 
 678        "OSPF area ID as a decimal value\n"
 
 679        "Summarize routes matching address/mask (border routers only)\n"
 
 680        "Area range prefix\n"
 
 681        "Advertise this range (default)\n"
 
 682        "User specified metric for this range\n"
 
 683        "Advertised metric for this range\n")
 
 685 DEFUN (ospf_area_range_substitute,
 
 686        ospf_area_range_substitute_cmd,
 
 687        "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
 
 688        "OSPF area parameters\n"
 
 689        "OSPF area ID in IP address format\n"
 
 690        "OSPF area ID as a decimal value\n"
 
 691        "Summarize routes matching address/mask (border routers only)\n"
 
 692        "Area range prefix\n"
 
 693        "Announce area range as another prefix\n"
 
 694        "Network prefix to be announced instead of range\n")
 
 696   struct ospf *ospf = vty->index;
 
 697   struct prefix_ipv4 p, s;
 
 698   struct in_addr area_id;
 
 701   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
 702   VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
 
 703   VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
 
 705   ospf_area_range_substitute_set (ospf, area_id, &p, &s);
 
 710 DEFUN (no_ospf_area_range_substitute,
 
 711        no_ospf_area_range_substitute_cmd,
 
 712        "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
 
 714        "OSPF area parameters\n"
 
 715        "OSPF area ID in IP address format\n"
 
 716        "OSPF area ID as a decimal value\n"
 
 717        "Summarize routes matching address/mask (border routers only)\n"
 
 718        "Area range prefix\n"
 
 719        "Announce area range as another prefix\n"
 
 720        "Network prefix to be announced instead of range\n")
 
 722   struct ospf *ospf = vty->index;
 
 723   struct prefix_ipv4 p, s;
 
 724   struct in_addr area_id;
 
 727   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
 728   VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
 
 729   VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
 
 731   ospf_area_range_substitute_unset (ospf, area_id, &p);
 
 737 /* Command Handler Logic in VLink stuff is delicate!!
 
 739         ALTER AT YOUR OWN RISK!!!!
 
 741         Various dummy values are used to represent 'NoChange' state for
 
 742         VLink configuration NOT being changed by a VLink command, and
 
 743         special syntax is used within the command strings so that the
 
 744         typed in command verbs can be seen in the configuration command
 
 745         bacckend handler.  This is to drastically reduce the verbeage
 
 746         required to coe up with a reasonably compatible Cisco VLink command
 
 748         - Matthew Grant <grantma@anathoth.gen.nz> 
 
 749         Wed, 21 Feb 2001 15:13:52 +1300
 
 753 /* Configuration data for virtual links 
 
 755 struct ospf_vl_config_data {
 
 756   struct vty *vty;              /* vty stuff */
 
 757   struct in_addr area_id;       /* area ID from command line */
 
 758   int format;                   /* command line area ID format */
 
 759   struct in_addr vl_peer;       /* command line vl_peer */
 
 760   int auth_type;                /* Authehntication type, if given */
 
 761   char *auth_key;               /* simple password if present */
 
 762   int crypto_key_id;            /* Cryptographic key ID */
 
 763   char *md5_key;                /* MD5 authentication key */
 
 764   int hello_interval;           /* Obvious what these are... */
 
 765   int retransmit_interval; 
 
 771 ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, 
 
 774   memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
 
 775   vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
 
 776   vl_config->vty = vty;
 
 779 static struct ospf_vl_data *
 
 780 ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
 
 782   struct ospf_area *area;
 
 783   struct ospf_vl_data *vl_data;
 
 785   struct in_addr area_id;
 
 787   vty = vl_config->vty;
 
 788   area_id = vl_config->area_id;
 
 790   if (area_id.s_addr == OSPF_AREA_BACKBONE)
 
 793                "Configuring VLs over the backbone is not allowed%s",
 
 797   area = ospf_area_get (ospf, area_id, vl_config->format);
 
 799   if (area->external_routing != OSPF_AREA_DEFAULT)
 
 801       if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
 
 802         vty_out (vty, "Area %s is %s%s",
 
 804                  area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
 
 807         vty_out (vty, "Area %ld is %s%s",
 
 808                  (u_long)ntohl (area_id.s_addr),
 
 809                  area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
 
 814   if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
 
 816       vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
 
 817       if (vl_data->vl_oi == NULL)
 
 819           vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
 
 820           ospf_vl_add (ospf, vl_data);
 
 821           ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
 
 829 ospf_vl_set_security (struct ospf_vl_data *vl_data,
 
 830                       struct ospf_vl_config_data *vl_config)
 
 832   struct crypt_key *ck;
 
 834   struct interface *ifp = vl_data->vl_oi->ifp;
 
 836   vty = vl_config->vty;
 
 838   if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
 
 840       SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
 
 841       IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
 
 844   if (vl_config->auth_key)
 
 846       memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
 
 847       strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, 
 
 848                OSPF_AUTH_SIMPLE_SIZE);
 
 850   else if (vl_config->md5_key)
 
 852       if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) 
 
 855           vty_out (vty, "OSPF: Key %d already exists%s",
 
 856                    vl_config->crypto_key_id, VTY_NEWLINE);
 
 859       ck = ospf_crypt_key_new ();
 
 860       ck->key_id = vl_config->crypto_key_id;
 
 861       memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
 
 862       strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
 
 864       ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
 
 866   else if (vl_config->crypto_key_id != 0)
 
 870       if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, 
 
 871                                  vl_config->crypto_key_id) == NULL)
 
 873           vty_out (vty, "OSPF: Key %d does not exist%s", 
 
 874                    vl_config->crypto_key_id, VTY_NEWLINE);
 
 878       ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
 
 886 ospf_vl_set_timers (struct ospf_vl_data *vl_data,
 
 887                     struct ospf_vl_config_data *vl_config)
 
 889   struct interface *ifp = vl_data->vl_oi->ifp;
 
 890   /* Virtual Link data initialised to defaults, so only set
 
 892   if (vl_config->hello_interval)
 
 894       SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
 
 895       IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
 
 898   if (vl_config->dead_interval)
 
 900       SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
 
 901       IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
 
 904   if (vl_config->retransmit_interval)
 
 906       SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
 
 907       IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
 
 910   if (vl_config->transmit_delay)
 
 912       SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
 
 913       IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
 
 921 /* The business end of all of the above */
 
 923 ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
 
 925   struct ospf_vl_data *vl_data;
 
 928   vl_data = ospf_find_vl_data (ospf, vl_config);
 
 932   /* Process this one first as it can have a fatal result, which can
 
 933      only logically occur if the virtual link exists already
 
 934      Thus a command error does not result in a change to the
 
 935      running configuration such as unexpectedly altered timer 
 
 937   ret = ospf_vl_set_security (vl_data, vl_config);
 
 938   if (ret != CMD_SUCCESS)
 
 941   /* Set any time based parameters, these area already range checked */
 
 943   ret = ospf_vl_set_timers (vl_data, vl_config);
 
 944   if (ret != CMD_SUCCESS)
 
 951 /* This stuff exists to make specifying all the alias commands A LOT simpler
 
 953 #define VLINK_HELPSTR_IPADDR \
 
 954        "OSPF area parameters\n" \
 
 955        "OSPF area ID in IP address format\n" \
 
 956        "OSPF area ID as a decimal value\n" \
 
 957        "Configure a virtual link\n" \
 
 958        "Router ID of the remote ABR\n"
 
 960 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
 
 961        "Enable authentication on this virtual link\n" \
 
 964 #define VLINK_HELPSTR_AUTHTYPE_ALL \
 
 965        VLINK_HELPSTR_AUTHTYPE_SIMPLE \
 
 966        "Use null authentication\n" \
 
 967        "Use message-digest authentication\n"
 
 969 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
 
 970        "Time between HELLO packets\n" \
 
 971        "Time between retransmitting lost link state advertisements\n" \
 
 972        "Link state transmit delay\n" \
 
 973        "Interval after which a neighbor is declared dead\n"
 
 975 #define VLINK_HELPSTR_TIME_PARAM \
 
 976        VLINK_HELPSTR_TIME_PARAM_NOSECS \
 
 979 #define VLINK_HELPSTR_AUTH_SIMPLE \
 
 980        "Authentication password (key)\n" \
 
 981        "The OSPF password (key)"
 
 983 #define VLINK_HELPSTR_AUTH_MD5 \
 
 984        "Message digest authentication password (key)\n" \
 
 987        "Use MD5 algorithm\n" \
 
 988        "The OSPF password (key)"
 
 990 DEFUN (ospf_area_vlink,
 
 992        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
 
 993        VLINK_HELPSTR_IPADDR)
 
 995   struct ospf *ospf = vty->index;
 
 996   struct ospf_vl_config_data vl_config;
 
 997   char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
 
 998   char md5_key[OSPF_AUTH_MD5_SIZE+1]; 
 
1002   ospf_vl_config_data_init(&vl_config, vty);
 
1004   /* Read off first 2 parameters and check them */
 
1005   ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
 
1008       vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
 
1012   ret = inet_aton (argv[1], &vl_config.vl_peer);
 
1015       vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
 
1022       /* Thats all folks! - BUGS B. strikes again!!!*/
 
1024       return  ospf_vl_set (ospf, &vl_config);
 
1027   /* Deal with other parameters */
 
1028   for (i=2; i < argc; i++)
 
1031       /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
 
1037           if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
 
1039               /* authentication-key - this option can occur anywhere on 
 
1040                                       command line.  At start of command line
 
1041                                       must check for authentication option. */
 
1042               memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
 
1043               strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
 
1044               vl_config.auth_key = auth_key;
 
1047           else if (strncmp (argv[i], "authentication", 14) == 0)
 
1049               /* authentication  - this option can only occur at start
 
1051               vl_config.auth_type = OSPF_AUTH_SIMPLE;
 
1054                   if (strncmp (argv[i+1], "n", 1) == 0)
 
1056                       /* "authentication null" */
 
1057                       vl_config.auth_type = OSPF_AUTH_NULL;
 
1060                   else if (strncmp (argv[i+1], "m", 1) == 0
 
1061                            && strcmp (argv[i+1], "message-digest-") != 0)
 
1063                       /* "authentication message-digest" */ 
 
1064                       vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
 
1072           /* message-digest-key */
 
1074           vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
 
1075           if (vl_config.crypto_key_id < 0)
 
1078           memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
 
1079           strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
 
1080           vl_config.md5_key = md5_key; 
 
1084           /* Hello interval */
 
1086           vl_config.hello_interval = strtol (argv[i], NULL, 10);
 
1087           if (vl_config.hello_interval < 0) 
 
1092           /* Retransmit Interval */
 
1094           vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
 
1095           if (vl_config.retransmit_interval < 0)
 
1100           /* Transmit Delay */
 
1102           vl_config.transmit_delay = strtol (argv[i], NULL, 10);
 
1103           if (vl_config.transmit_delay < 0)
 
1110           vl_config.dead_interval = strtol (argv[i], NULL, 10);
 
1111           if (vl_config.dead_interval < 0)
 
1118   /* Action configuration */
 
1120   return ospf_vl_set (ospf, &vl_config);
 
1124 DEFUN (no_ospf_area_vlink,
 
1125        no_ospf_area_vlink_cmd,
 
1126        "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
 
1128        VLINK_HELPSTR_IPADDR)
 
1130   struct ospf *ospf = vty->index;
 
1131   struct ospf_area *area;
 
1132   struct ospf_vl_config_data vl_config;
 
1133   struct ospf_vl_data *vl_data = NULL;
 
1134   char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
 
1138   ospf_vl_config_data_init(&vl_config, vty);
 
1140   ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
 
1143       vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
 
1147   area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
 
1150       vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
 
1154   ret = inet_aton (argv[1], &vl_config.vl_peer);
 
1157       vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
 
1164       /* Basic VLink no command */
 
1165       /* Thats all folks! - BUGS B. strikes again!!!*/
 
1166       if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
 
1167         ospf_vl_delete (ospf, vl_data);
 
1169       ospf_area_check_free (ospf, vl_config.area_id);
 
1174   /* If we are down here, we are reseting parameters */
 
1176   /* Deal with other parameters */
 
1177   for (i=2; i < argc; i++)
 
1179       /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
 
1185           if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
 
1187               /* authentication-key - this option can occur anywhere on 
 
1188                                       command line.  At start of command line
 
1189                                       must check for authentication option. */
 
1190               memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
 
1191               vl_config.auth_key = auth_key;
 
1193           else if (strncmp (argv[i], "authentication", 14) == 0)
 
1195               /* authentication  - this option can only occur at start
 
1197               vl_config.auth_type = OSPF_AUTH_NOTSET;
 
1202           /* message-digest-key */
 
1203           /* Delete one key */
 
1205           vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
 
1206           if (vl_config.crypto_key_id < 0)
 
1208           vl_config.md5_key = NULL; 
 
1212           /* Hello interval */
 
1213           vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
 
1217           /* Retransmit Interval */
 
1218           vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
 
1222           /* Transmit Delay */
 
1223           vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
 
1229           vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
 
1235   /* Action configuration */
 
1237   return ospf_vl_set (ospf, &vl_config);
 
1240 ALIAS (ospf_area_vlink,
 
1241        ospf_area_vlink_param1_cmd,
 
1242        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1243        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
 
1244        VLINK_HELPSTR_IPADDR
 
1245        VLINK_HELPSTR_TIME_PARAM)
 
1247 ALIAS (no_ospf_area_vlink,
 
1248        no_ospf_area_vlink_param1_cmd,
 
1249        "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1250        "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
 
1252        VLINK_HELPSTR_IPADDR
 
1253        VLINK_HELPSTR_TIME_PARAM)
 
1255 ALIAS (ospf_area_vlink,
 
1256        ospf_area_vlink_param2_cmd,
 
1257        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1258        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
 
1259        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
 
1260        VLINK_HELPSTR_IPADDR
 
1261        VLINK_HELPSTR_TIME_PARAM
 
1262        VLINK_HELPSTR_TIME_PARAM)
 
1264 ALIAS (no_ospf_area_vlink,
 
1265        no_ospf_area_vlink_param2_cmd,
 
1266        "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1267        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
 
1268        "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
 
1270        VLINK_HELPSTR_IPADDR
 
1271        VLINK_HELPSTR_TIME_PARAM
 
1272        VLINK_HELPSTR_TIME_PARAM)
 
1274 ALIAS (ospf_area_vlink,
 
1275        ospf_area_vlink_param3_cmd,
 
1276        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1277        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
 
1278        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
 
1279        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
 
1280        VLINK_HELPSTR_IPADDR
 
1281        VLINK_HELPSTR_TIME_PARAM
 
1282        VLINK_HELPSTR_TIME_PARAM
 
1283        VLINK_HELPSTR_TIME_PARAM)
 
1285 ALIAS (no_ospf_area_vlink,
 
1286        no_ospf_area_vlink_param3_cmd,
 
1287        "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1288        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
 
1289        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
 
1290        "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
 
1292        VLINK_HELPSTR_IPADDR
 
1293        VLINK_HELPSTR_TIME_PARAM
 
1294        VLINK_HELPSTR_TIME_PARAM
 
1295        VLINK_HELPSTR_TIME_PARAM)
 
1297 ALIAS (ospf_area_vlink,
 
1298        ospf_area_vlink_param4_cmd,
 
1299        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1300        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
 
1301        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
 
1302        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
 
1303        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
 
1304        VLINK_HELPSTR_IPADDR
 
1305        VLINK_HELPSTR_TIME_PARAM
 
1306        VLINK_HELPSTR_TIME_PARAM
 
1307        VLINK_HELPSTR_TIME_PARAM
 
1308        VLINK_HELPSTR_TIME_PARAM)
 
1310 ALIAS (no_ospf_area_vlink,
 
1311        no_ospf_area_vlink_param4_cmd,
 
1312        "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1313        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
 
1314        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
 
1315        "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
 
1316        "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
 
1318        VLINK_HELPSTR_IPADDR
 
1319        VLINK_HELPSTR_TIME_PARAM
 
1320        VLINK_HELPSTR_TIME_PARAM
 
1321        VLINK_HELPSTR_TIME_PARAM
 
1322        VLINK_HELPSTR_TIME_PARAM)
 
1324 ALIAS (ospf_area_vlink,
 
1325        ospf_area_vlink_authtype_args_cmd,
 
1326        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1327        "(authentication|) (message-digest|null)",
 
1328        VLINK_HELPSTR_IPADDR
 
1329        VLINK_HELPSTR_AUTHTYPE_ALL)
 
1331 ALIAS (ospf_area_vlink,
 
1332        ospf_area_vlink_authtype_cmd,
 
1333        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1334        "(authentication|)",
 
1335        VLINK_HELPSTR_IPADDR
 
1336        VLINK_HELPSTR_AUTHTYPE_SIMPLE)
 
1338 ALIAS (no_ospf_area_vlink,
 
1339        no_ospf_area_vlink_authtype_cmd,
 
1340        "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1341        "(authentication|)",
 
1343        VLINK_HELPSTR_IPADDR
 
1344        VLINK_HELPSTR_AUTHTYPE_SIMPLE)
 
1346 ALIAS (ospf_area_vlink,
 
1347        ospf_area_vlink_md5_cmd,
 
1348        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1349        "(message-digest-key|) <1-255> md5 KEY",
 
1350        VLINK_HELPSTR_IPADDR
 
1351        VLINK_HELPSTR_AUTH_MD5)
 
1353 ALIAS (no_ospf_area_vlink,
 
1354        no_ospf_area_vlink_md5_cmd,
 
1355        "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1356        "(message-digest-key|) <1-255>",
 
1358        VLINK_HELPSTR_IPADDR
 
1359        VLINK_HELPSTR_AUTH_MD5)
 
1361 ALIAS (ospf_area_vlink,
 
1362        ospf_area_vlink_authkey_cmd,
 
1363        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1364        "(authentication-key|) AUTH_KEY",
 
1365        VLINK_HELPSTR_IPADDR
 
1366        VLINK_HELPSTR_AUTH_SIMPLE)
 
1368 ALIAS (no_ospf_area_vlink,
 
1369        no_ospf_area_vlink_authkey_cmd,
 
1370        "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1371        "(authentication-key|)",
 
1373        VLINK_HELPSTR_IPADDR
 
1374        VLINK_HELPSTR_AUTH_SIMPLE)
 
1376 ALIAS (ospf_area_vlink,
 
1377        ospf_area_vlink_authtype_args_authkey_cmd,
 
1378        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1379        "(authentication|) (message-digest|null) "
 
1380        "(authentication-key|) AUTH_KEY",
 
1381        VLINK_HELPSTR_IPADDR
 
1382        VLINK_HELPSTR_AUTHTYPE_ALL
 
1383        VLINK_HELPSTR_AUTH_SIMPLE)
 
1385 ALIAS (ospf_area_vlink,
 
1386        ospf_area_vlink_authtype_authkey_cmd,
 
1387        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1388        "(authentication|) "
 
1389        "(authentication-key|) AUTH_KEY",
 
1390        VLINK_HELPSTR_IPADDR
 
1391        VLINK_HELPSTR_AUTHTYPE_SIMPLE
 
1392        VLINK_HELPSTR_AUTH_SIMPLE)
 
1394 ALIAS (no_ospf_area_vlink,
 
1395        no_ospf_area_vlink_authtype_authkey_cmd,
 
1396        "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1397        "(authentication|) "
 
1398        "(authentication-key|)",
 
1400        VLINK_HELPSTR_IPADDR
 
1401        VLINK_HELPSTR_AUTHTYPE_SIMPLE
 
1402        VLINK_HELPSTR_AUTH_SIMPLE)
 
1404 ALIAS (ospf_area_vlink,
 
1405        ospf_area_vlink_authtype_args_md5_cmd,
 
1406        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1407        "(authentication|) (message-digest|null) "
 
1408        "(message-digest-key|) <1-255> md5 KEY",
 
1409        VLINK_HELPSTR_IPADDR
 
1410        VLINK_HELPSTR_AUTHTYPE_ALL
 
1411        VLINK_HELPSTR_AUTH_MD5)
 
1413 ALIAS (ospf_area_vlink,
 
1414        ospf_area_vlink_authtype_md5_cmd,
 
1415        "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1416        "(authentication|) "
 
1417        "(message-digest-key|) <1-255> md5 KEY",
 
1418        VLINK_HELPSTR_IPADDR
 
1419        VLINK_HELPSTR_AUTHTYPE_SIMPLE
 
1420        VLINK_HELPSTR_AUTH_MD5)
 
1422 ALIAS (no_ospf_area_vlink,
 
1423        no_ospf_area_vlink_authtype_md5_cmd,
 
1424        "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
 
1425        "(authentication|) "
 
1426        "(message-digest-key|)",
 
1428        VLINK_HELPSTR_IPADDR
 
1429        VLINK_HELPSTR_AUTHTYPE_SIMPLE
 
1430        VLINK_HELPSTR_AUTH_MD5)
 
1433 DEFUN (ospf_area_shortcut,
 
1434        ospf_area_shortcut_cmd,
 
1435        "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
 
1436        "OSPF area parameters\n"
 
1437        "OSPF area ID in IP address format\n"
 
1438        "OSPF area ID as a decimal value\n"
 
1439        "Configure the area's shortcutting mode\n"
 
1440        "Set default shortcutting behavior\n"
 
1441        "Enable shortcutting through the area\n"
 
1442        "Disable shortcutting through the area\n")
 
1444   struct ospf *ospf = vty->index;
 
1445   struct ospf_area *area;
 
1446   struct in_addr area_id;
 
1450   VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
 
1452   area = ospf_area_get (ospf, area_id, format);
 
1454   if (strncmp (argv[1], "de", 2) == 0)
 
1455     mode = OSPF_SHORTCUT_DEFAULT;
 
1456   else if (strncmp (argv[1], "di", 2) == 0)
 
1457     mode = OSPF_SHORTCUT_DISABLE;
 
1458   else if (strncmp (argv[1], "e", 1) == 0)
 
1459     mode = OSPF_SHORTCUT_ENABLE;
 
1463   ospf_area_shortcut_set (ospf, area, mode);
 
1465   if (ospf->abr_type != OSPF_ABR_SHORTCUT)
 
1466     vty_out (vty, "Shortcut area setting will take effect "
 
1467              "only when the router is configured as Shortcut ABR%s",
 
1473 DEFUN (no_ospf_area_shortcut,
 
1474        no_ospf_area_shortcut_cmd,
 
1475        "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
 
1477        "OSPF area parameters\n"
 
1478        "OSPF area ID in IP address format\n"
 
1479        "OSPF area ID as a decimal value\n"
 
1480        "Deconfigure the area's shortcutting mode\n"
 
1481        "Deconfigure enabled shortcutting through the area\n"
 
1482        "Deconfigure disabled shortcutting through the area\n")
 
1484   struct ospf *ospf = vty->index;
 
1485   struct ospf_area *area;
 
1486   struct in_addr area_id;
 
1489   VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
 
1491   area = ospf_area_lookup_by_area_id (ospf, area_id);
 
1495   ospf_area_shortcut_unset (ospf, area);
 
1501 DEFUN (ospf_area_stub,
 
1503        "area (A.B.C.D|<0-4294967295>) stub",
 
1504        "OSPF area parameters\n"
 
1505        "OSPF area ID in IP address format\n"
 
1506        "OSPF area ID as a decimal value\n"
 
1507        "Configure OSPF area as stub\n")
 
1509   struct ospf *ospf = vty->index;
 
1510   struct in_addr area_id;
 
1513   VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
 
1515   ret = ospf_area_stub_set (ospf, area_id);
 
1518       vty_out (vty, "First deconfigure all virtual link through this area%s",
 
1523   ospf_area_no_summary_unset (ospf, area_id);
 
1528 DEFUN (ospf_area_stub_no_summary,
 
1529        ospf_area_stub_no_summary_cmd,
 
1530        "area (A.B.C.D|<0-4294967295>) stub no-summary",
 
1531        "OSPF stub parameters\n"
 
1532        "OSPF area ID in IP address format\n"
 
1533        "OSPF area ID as a decimal value\n"
 
1534        "Configure OSPF area as stub\n"
 
1535        "Do not inject inter-area routes into stub\n")
 
1537   struct ospf *ospf = vty->index;
 
1538   struct in_addr area_id;
 
1541   VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
 
1543   ret = ospf_area_stub_set (ospf, area_id);
 
1546       vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
 
1551   ospf_area_no_summary_set (ospf, area_id);
 
1556 DEFUN (no_ospf_area_stub,
 
1557        no_ospf_area_stub_cmd,
 
1558        "no area (A.B.C.D|<0-4294967295>) stub",
 
1560        "OSPF area parameters\n"
 
1561        "OSPF area ID in IP address format\n"
 
1562        "OSPF area ID as a decimal value\n"
 
1563        "Configure OSPF area as stub\n")
 
1565   struct ospf *ospf = vty->index;
 
1566   struct in_addr area_id;
 
1569   VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
 
1571   ospf_area_stub_unset (ospf, area_id);
 
1572   ospf_area_no_summary_unset (ospf, area_id);
 
1577 DEFUN (no_ospf_area_stub_no_summary,
 
1578        no_ospf_area_stub_no_summary_cmd,
 
1579        "no area (A.B.C.D|<0-4294967295>) stub no-summary",
 
1581        "OSPF area parameters\n"
 
1582        "OSPF area ID in IP address format\n"
 
1583        "OSPF area ID as a decimal value\n"
 
1584        "Configure OSPF area as stub\n"
 
1585        "Do not inject inter-area routes into area\n")
 
1587   struct ospf *ospf = vty->index;
 
1588   struct in_addr area_id;
 
1591   VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
 
1592   ospf_area_no_summary_unset (ospf, area_id);
 
1598 ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], 
 
1601   struct ospf *ospf = vty->index;
 
1602   struct in_addr area_id;
 
1605   VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
 
1607   ret = ospf_area_nssa_set (ospf, area_id);
 
1610       vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
 
1617       if (strncmp (argv[1], "translate-c", 11) == 0)
 
1618         ospf_area_nssa_translator_role_set (ospf, area_id,
 
1619                                             OSPF_NSSA_ROLE_CANDIDATE);
 
1620       else if (strncmp (argv[1], "translate-n", 11) == 0)
 
1621         ospf_area_nssa_translator_role_set (ospf, area_id,
 
1622                                             OSPF_NSSA_ROLE_NEVER);
 
1623       else if (strncmp (argv[1], "translate-a", 11) == 0)
 
1624         ospf_area_nssa_translator_role_set (ospf, area_id,
 
1625                                             OSPF_NSSA_ROLE_ALWAYS);
 
1629       ospf_area_nssa_translator_role_set (ospf, area_id,
 
1630                         OSPF_NSSA_ROLE_CANDIDATE);
 
1634     ospf_area_no_summary_set (ospf, area_id);
 
1636     ospf_area_no_summary_unset (ospf, area_id);
 
1638   ospf_schedule_abr_task (ospf);
 
1643 DEFUN (ospf_area_nssa_translate_no_summary,
 
1644        ospf_area_nssa_translate_no_summary_cmd,
 
1645        "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
 
1646        "OSPF area parameters\n"
 
1647        "OSPF area ID in IP address format\n"
 
1648        "OSPF area ID as a decimal value\n"
 
1649        "Configure OSPF area as nssa\n"
 
1650        "Configure NSSA-ABR for translate election (default)\n"
 
1651        "Configure NSSA-ABR to never translate\n"
 
1652        "Configure NSSA-ABR to always translate\n"
 
1653        "Do not inject inter-area routes into nssa\n")
 
1655    return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
 
1658 DEFUN (ospf_area_nssa_translate,
 
1659        ospf_area_nssa_translate_cmd,
 
1660        "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
 
1661        "OSPF area parameters\n"
 
1662        "OSPF area ID in IP address format\n"
 
1663        "OSPF area ID as a decimal value\n"
 
1664        "Configure OSPF area as nssa\n"
 
1665        "Configure NSSA-ABR for translate election (default)\n"
 
1666        "Configure NSSA-ABR to never translate\n"
 
1667        "Configure NSSA-ABR to always translate\n")
 
1669   return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
 
1672 DEFUN (ospf_area_nssa,
 
1674        "area (A.B.C.D|<0-4294967295>) nssa",
 
1675        "OSPF area parameters\n"
 
1676        "OSPF area ID in IP address format\n"
 
1677        "OSPF area ID as a decimal value\n"
 
1678        "Configure OSPF area as nssa\n")
 
1680   return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
 
1683 DEFUN (ospf_area_nssa_no_summary,
 
1684        ospf_area_nssa_no_summary_cmd,
 
1685        "area (A.B.C.D|<0-4294967295>) nssa no-summary",
 
1686        "OSPF area parameters\n"
 
1687        "OSPF area ID in IP address format\n"
 
1688        "OSPF area ID as a decimal value\n"
 
1689        "Configure OSPF area as nssa\n"
 
1690        "Do not inject inter-area routes into nssa\n")
 
1692   return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
 
1695 DEFUN (no_ospf_area_nssa,
 
1696        no_ospf_area_nssa_cmd,
 
1697        "no area (A.B.C.D|<0-4294967295>) nssa",
 
1699        "OSPF area parameters\n"
 
1700        "OSPF area ID in IP address format\n"
 
1701        "OSPF area ID as a decimal value\n"
 
1702        "Configure OSPF area as nssa\n")
 
1704   struct ospf *ospf = vty->index;
 
1705   struct in_addr area_id;
 
1708   VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
 
1710   ospf_area_nssa_unset (ospf, area_id);
 
1711   ospf_area_no_summary_unset (ospf, area_id);
 
1713   ospf_schedule_abr_task (ospf);
 
1718 DEFUN (no_ospf_area_nssa_no_summary,
 
1719        no_ospf_area_nssa_no_summary_cmd,
 
1720        "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
 
1722        "OSPF area parameters\n"
 
1723        "OSPF area ID in IP address format\n"
 
1724        "OSPF area ID as a decimal value\n"
 
1725        "Configure OSPF area as nssa\n"
 
1726        "Do not inject inter-area routes into nssa\n")
 
1728   struct ospf *ospf = vty->index;
 
1729   struct in_addr area_id;
 
1732   VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
 
1733   ospf_area_no_summary_unset (ospf, area_id);
 
1738 DEFUN (ospf_area_default_cost,
 
1739        ospf_area_default_cost_cmd,
 
1740        "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
 
1741        "OSPF area parameters\n"
 
1742        "OSPF area ID in IP address format\n"
 
1743        "OSPF area ID as a decimal value\n"
 
1744        "Set the summary-default cost of a NSSA or stub area\n"
 
1745        "Stub's advertised default summary cost\n")
 
1747   struct ospf *ospf = vty->index;
 
1748   struct ospf_area *area;
 
1749   struct in_addr area_id;
 
1752   struct prefix_ipv4 p;
 
1754   VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
 
1755   VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
 
1757   area = ospf_area_get (ospf, area_id, format);
 
1759   if (area->external_routing == OSPF_AREA_DEFAULT)
 
1761       vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
 
1765   area->default_cost = cost;
 
1768   p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
 
1770   if (IS_DEBUG_OSPF_EVENT)
 
1771     zlog_debug ("ospf_abr_announce_stub_defaults(): "
 
1772                 "announcing 0.0.0.0/0 to area %s",
 
1773                inet_ntoa (area->area_id));
 
1774   ospf_abr_announce_network_to_area (&p, area->default_cost, area);
 
1779 DEFUN (no_ospf_area_default_cost,
 
1780        no_ospf_area_default_cost_cmd,
 
1781        "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
 
1783        "OSPF area parameters\n"
 
1784        "OSPF area ID in IP address format\n"
 
1785        "OSPF area ID as a decimal value\n"
 
1786        "Set the summary-default cost of a NSSA or stub area\n"
 
1787        "Stub's advertised default summary cost\n")
 
1789   struct ospf *ospf = vty->index;
 
1790   struct ospf_area *area;
 
1791   struct in_addr area_id;
 
1793   struct prefix_ipv4 p;
 
1795   VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
 
1796   VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
 
1798   area = ospf_area_lookup_by_area_id (ospf, area_id);
 
1802   if (area->external_routing == OSPF_AREA_DEFAULT)
 
1804       vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
 
1808   area->default_cost = 1;
 
1811   p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
 
1813   if (IS_DEBUG_OSPF_EVENT)
 
1814     zlog_debug ("ospf_abr_announce_stub_defaults(): "
 
1815                 "announcing 0.0.0.0/0 to area %s",
 
1816                inet_ntoa (area->area_id));
 
1817   ospf_abr_announce_network_to_area (&p, area->default_cost, area);
 
1820   ospf_area_check_free (ospf, area_id);
 
1825 DEFUN (ospf_area_export_list,
 
1826        ospf_area_export_list_cmd,
 
1827        "area (A.B.C.D|<0-4294967295>) export-list NAME",
 
1828        "OSPF area parameters\n"
 
1829        "OSPF area ID in IP address format\n"
 
1830        "OSPF area ID as a decimal value\n"
 
1831        "Set the filter for networks announced to other areas\n"
 
1832        "Name of the access-list\n")
 
1834   struct ospf *ospf = vty->index;
 
1835   struct ospf_area *area;
 
1836   struct in_addr area_id;
 
1839   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
1841   area = ospf_area_get (ospf, area_id, format);
 
1842   ospf_area_export_list_set (ospf, area, argv[1]);
 
1847 DEFUN (no_ospf_area_export_list,
 
1848        no_ospf_area_export_list_cmd,
 
1849        "no area (A.B.C.D|<0-4294967295>) export-list NAME",
 
1851        "OSPF area parameters\n"
 
1852        "OSPF area ID in IP address format\n"
 
1853        "OSPF area ID as a decimal value\n"
 
1854        "Unset the filter for networks announced to other areas\n"
 
1855        "Name of the access-list\n")
 
1857   struct ospf *ospf = vty->index;
 
1858   struct ospf_area *area;
 
1859   struct in_addr area_id;
 
1862   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
1864   area = ospf_area_lookup_by_area_id (ospf, area_id);
 
1868   ospf_area_export_list_unset (ospf, area);
 
1874 DEFUN (ospf_area_import_list,
 
1875        ospf_area_import_list_cmd,
 
1876        "area (A.B.C.D|<0-4294967295>) import-list NAME",
 
1877        "OSPF area parameters\n"
 
1878        "OSPF area ID in IP address format\n"
 
1879        "OSPF area ID as a decimal value\n"
 
1880        "Set the filter for networks from other areas announced to the specified one\n"
 
1881        "Name of the access-list\n")
 
1883   struct ospf *ospf = vty->index;
 
1884   struct ospf_area *area;
 
1885   struct in_addr area_id;
 
1888   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
1890   area = ospf_area_get (ospf, area_id, format);
 
1891   ospf_area_import_list_set (ospf, area, argv[1]);
 
1896 DEFUN (no_ospf_area_import_list,
 
1897        no_ospf_area_import_list_cmd,
 
1898        "no area (A.B.C.D|<0-4294967295>) import-list NAME",
 
1900        "OSPF area parameters\n"
 
1901        "OSPF area ID in IP address format\n"
 
1902        "OSPF area ID as a decimal value\n"
 
1903        "Unset the filter for networks announced to other areas\n"
 
1904        "Name of the access-list\n")
 
1906   struct ospf *ospf = vty->index;
 
1907   struct ospf_area *area;
 
1908   struct in_addr area_id;
 
1911   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
1913   area = ospf_area_lookup_by_area_id (ospf, area_id);
 
1917   ospf_area_import_list_unset (ospf, area);
 
1922 DEFUN (ospf_area_filter_list,
 
1923        ospf_area_filter_list_cmd,
 
1924        "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
 
1925        "OSPF area parameters\n"
 
1926        "OSPF area ID in IP address format\n"
 
1927        "OSPF area ID as a decimal value\n"
 
1928        "Filter networks between OSPF areas\n"
 
1929        "Filter prefixes between OSPF areas\n"
 
1930        "Name of an IP prefix-list\n"
 
1931        "Filter networks sent to this area\n"
 
1932        "Filter networks sent from this area\n")
 
1934   struct ospf *ospf = vty->index;
 
1935   struct ospf_area *area;
 
1936   struct in_addr area_id;
 
1937   struct prefix_list *plist;
 
1940   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
1942   area = ospf_area_get (ospf, area_id, format);
 
1943   plist = prefix_list_lookup (AFI_IP, argv[1]);
 
1944   if (strncmp (argv[2], "in", 2) == 0)
 
1946       PREFIX_LIST_IN (area) = plist;
 
1947       if (PREFIX_NAME_IN (area))
 
1948         free (PREFIX_NAME_IN (area));
 
1950       PREFIX_NAME_IN (area) = strdup (argv[1]);
 
1951       ospf_schedule_abr_task (ospf);
 
1955       PREFIX_LIST_OUT (area) = plist;
 
1956       if (PREFIX_NAME_OUT (area))
 
1957         free (PREFIX_NAME_OUT (area));
 
1959       PREFIX_NAME_OUT (area) = strdup (argv[1]);
 
1960       ospf_schedule_abr_task (ospf);
 
1966 DEFUN (no_ospf_area_filter_list,
 
1967        no_ospf_area_filter_list_cmd,
 
1968        "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
 
1970        "OSPF area parameters\n"
 
1971        "OSPF area ID in IP address format\n"
 
1972        "OSPF area ID as a decimal value\n"
 
1973        "Filter networks between OSPF areas\n"
 
1974        "Filter prefixes between OSPF areas\n"
 
1975        "Name of an IP prefix-list\n"
 
1976        "Filter networks sent to this area\n"
 
1977        "Filter networks sent from this area\n")
 
1979   struct ospf *ospf = vty->index;
 
1980   struct ospf_area *area;
 
1981   struct in_addr area_id;
 
1984   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
1986   if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
 
1989   if (strncmp (argv[2], "in", 2) == 0)
 
1991       if (PREFIX_NAME_IN (area))
 
1992         if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
 
1995       PREFIX_LIST_IN (area) = NULL;
 
1996       if (PREFIX_NAME_IN (area))
 
1997         free (PREFIX_NAME_IN (area));
 
1999       PREFIX_NAME_IN (area) = NULL;
 
2001       ospf_schedule_abr_task (ospf);
 
2005       if (PREFIX_NAME_OUT (area))
 
2006         if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
 
2009       PREFIX_LIST_OUT (area) = NULL;
 
2010       if (PREFIX_NAME_OUT (area))
 
2011         free (PREFIX_NAME_OUT (area));
 
2013       PREFIX_NAME_OUT (area) = NULL;
 
2015       ospf_schedule_abr_task (ospf);
 
2022 DEFUN (ospf_area_authentication_message_digest,
 
2023        ospf_area_authentication_message_digest_cmd,
 
2024        "area (A.B.C.D|<0-4294967295>) authentication message-digest",
 
2025        "OSPF area parameters\n"
 
2026        "OSPF area ID in IP address format\n"
 
2027        "OSPF area ID as a decimal value\n"
 
2028        "Enable authentication\n"
 
2029        "Use message-digest authentication\n")
 
2031   struct ospf *ospf = vty->index;
 
2032   struct ospf_area *area;
 
2033   struct in_addr area_id;
 
2036   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
2038   area = ospf_area_get (ospf, area_id, format);
 
2039   area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
 
2044 DEFUN (ospf_area_authentication,
 
2045        ospf_area_authentication_cmd,
 
2046        "area (A.B.C.D|<0-4294967295>) authentication",
 
2047        "OSPF area parameters\n"
 
2048        "OSPF area ID in IP address format\n"
 
2049        "OSPF area ID as a decimal value\n"
 
2050        "Enable authentication\n")
 
2052   struct ospf *ospf = vty->index;
 
2053   struct ospf_area *area;
 
2054   struct in_addr area_id;
 
2057   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
2059   area = ospf_area_get (ospf, area_id, format);
 
2060   area->auth_type = OSPF_AUTH_SIMPLE;
 
2065 DEFUN (no_ospf_area_authentication,
 
2066        no_ospf_area_authentication_cmd,
 
2067        "no area (A.B.C.D|<0-4294967295>) authentication",
 
2069        "OSPF area parameters\n"
 
2070        "OSPF area ID in IP address format\n"
 
2071        "OSPF area ID as a decimal value\n"
 
2072        "Enable authentication\n")
 
2074   struct ospf *ospf = vty->index;
 
2075   struct ospf_area *area;
 
2076   struct in_addr area_id;
 
2079   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
2081   area = ospf_area_lookup_by_area_id (ospf, area_id);
 
2085   area->auth_type = OSPF_AUTH_NULL;
 
2087   ospf_area_check_free (ospf, area_id);
 
2093 DEFUN (ospf_abr_type,
 
2095        "ospf abr-type (cisco|ibm|shortcut|standard)",
 
2096        "OSPF specific commands\n"
 
2097        "Set OSPF ABR type\n"
 
2098        "Alternative ABR, cisco implementation\n"
 
2099        "Alternative ABR, IBM implementation\n"
 
2101        "Standard behavior (RFC2328)\n")
 
2103   struct ospf *ospf = vty->index;
 
2104   u_char abr_type = OSPF_ABR_UNKNOWN;
 
2106   if (strncmp (argv[0], "c", 1) == 0)
 
2107     abr_type = OSPF_ABR_CISCO;
 
2108   else if (strncmp (argv[0], "i", 1) == 0)
 
2109     abr_type = OSPF_ABR_IBM;
 
2110   else if (strncmp (argv[0], "sh", 2) == 0)
 
2111     abr_type = OSPF_ABR_SHORTCUT;
 
2112   else if (strncmp (argv[0], "st", 2) == 0)
 
2113     abr_type = OSPF_ABR_STAND;
 
2117   /* If ABR type value is changed, schedule ABR task. */
 
2118   if (ospf->abr_type != abr_type)
 
2120       ospf->abr_type = abr_type;
 
2121       ospf_schedule_abr_task (ospf);
 
2127 DEFUN (no_ospf_abr_type,
 
2128        no_ospf_abr_type_cmd,
 
2129        "no ospf abr-type (cisco|ibm|shortcut|standard)",
 
2131        "OSPF specific commands\n"
 
2132        "Set OSPF ABR type\n"
 
2133        "Alternative ABR, cisco implementation\n"
 
2134        "Alternative ABR, IBM implementation\n"
 
2137   struct ospf *ospf = vty->index;
 
2138   u_char abr_type = OSPF_ABR_UNKNOWN;
 
2140   if (strncmp (argv[0], "c", 1) == 0)
 
2141     abr_type = OSPF_ABR_CISCO;
 
2142   else if (strncmp (argv[0], "i", 1) == 0)
 
2143     abr_type = OSPF_ABR_IBM;
 
2144   else if (strncmp (argv[0], "sh", 2) == 0)
 
2145     abr_type = OSPF_ABR_SHORTCUT;
 
2146   else if (strncmp (argv[0], "st", 2) == 0)
 
2147     abr_type = OSPF_ABR_STAND;
 
2151   /* If ABR type value is changed, schedule ABR task. */
 
2152   if (ospf->abr_type == abr_type)
 
2154       ospf->abr_type = OSPF_ABR_DEFAULT;
 
2155       ospf_schedule_abr_task (ospf);
 
2161 DEFUN (ospf_log_adjacency_changes,
 
2162        ospf_log_adjacency_changes_cmd,
 
2163        "log-adjacency-changes",
 
2164        "Log changes in adjacency state\n")
 
2166   struct ospf *ospf = vty->index;
 
2168   SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
 
2172 DEFUN (ospf_log_adjacency_changes_detail,
 
2173        ospf_log_adjacency_changes_detail_cmd,
 
2174        "log-adjacency-changes detail",
 
2175        "Log changes in adjacency state\n"
 
2176        "Log all state changes\n")
 
2178   struct ospf *ospf = vty->index;
 
2180   SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
 
2181   SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
 
2185 DEFUN (no_ospf_log_adjacency_changes,
 
2186        no_ospf_log_adjacency_changes_cmd,
 
2187        "no log-adjacency-changes",
 
2189        "Log changes in adjacency state\n")
 
2191   struct ospf *ospf = vty->index;
 
2193   UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
 
2194   UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
 
2198 DEFUN (no_ospf_log_adjacency_changes_detail,
 
2199        no_ospf_log_adjacency_changes_detail_cmd,
 
2200        "no log-adjacency-changes detail",
 
2202        "Log changes in adjacency state\n"
 
2203        "Log all state changes\n")
 
2205   struct ospf *ospf = vty->index;
 
2207   UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
 
2211 DEFUN (ospf_compatible_rfc1583,
 
2212        ospf_compatible_rfc1583_cmd,
 
2213        "compatible rfc1583",
 
2214        "OSPF compatibility list\n"
 
2215        "compatible with RFC 1583\n")
 
2217   struct ospf *ospf = vty->index;
 
2219   if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
 
2221       SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
 
2222       ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
 
2227 DEFUN (no_ospf_compatible_rfc1583,
 
2228        no_ospf_compatible_rfc1583_cmd,
 
2229        "no compatible rfc1583",
 
2231        "OSPF compatibility list\n"
 
2232        "compatible with RFC 1583\n")
 
2234   struct ospf *ospf = vty->index;
 
2236   if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
 
2238       UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
 
2239       ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
 
2244 ALIAS (ospf_compatible_rfc1583,
 
2245        ospf_rfc1583_flag_cmd,
 
2246        "ospf rfc1583compatibility",
 
2247        "OSPF specific commands\n"
 
2248        "Enable the RFC1583Compatibility flag\n")
 
2250 ALIAS (no_ospf_compatible_rfc1583,
 
2251        no_ospf_rfc1583_flag_cmd,
 
2252        "no ospf rfc1583compatibility",
 
2254        "OSPF specific commands\n"
 
2255        "Disable the RFC1583Compatibility flag\n")
 
2258 ospf_timers_spf_set (struct vty *vty, unsigned int delay,
 
2262   struct ospf *ospf = vty->index;
 
2264   ospf->spf_delay = delay;
 
2265   ospf->spf_holdtime = hold;
 
2266   ospf->spf_max_holdtime = max;
 
2271 DEFUN (ospf_timers_min_ls_interval,
 
2272        ospf_timers_min_ls_interval_cmd,
 
2273        "timers throttle lsa all <0-5000>",
 
2274        "Adjust routing timers\n"
 
2275        "Throttling adaptive timer\n"
 
2276        "LSA delay between transmissions\n"
 
2278        "Delay (msec) between sending LSAs\n")
 
2280   struct ospf *ospf = vty->index;
 
2281   unsigned int interval;
 
2285       vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
 
2289   VTY_GET_INTEGER ("LSA interval", interval, argv[0]);
 
2291   ospf->min_ls_interval = interval;
 
2296 DEFUN (no_ospf_timers_min_ls_interval,
 
2297        no_ospf_timers_min_ls_interval_cmd,
 
2298        "no timers throttle lsa all",
 
2300        "Adjust routing timers\n"
 
2301        "Throttling adaptive timer\n"
 
2302        "LSA delay between transmissions\n")
 
2304   struct ospf *ospf = vty->index;
 
2305   ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL;
 
2310 DEFUN (ospf_timers_min_ls_arrival,
 
2311        ospf_timers_min_ls_arrival_cmd,
 
2312        "timers lsa arrival <0-1000>",
 
2313        "Adjust routing timers\n"
 
2314        "Throttling link state advertisement delays\n"
 
2315        "OSPF minimum arrival interval delay\n"
 
2316        "Delay (msec) between accepted LSAs\n")
 
2318   struct ospf *ospf = vty->index;
 
2319   unsigned int arrival;
 
2323       vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
 
2327   VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[0], 0, 1000);
 
2329   ospf->min_ls_arrival = arrival;
 
2334 DEFUN (no_ospf_timers_min_ls_arrival,
 
2335        no_ospf_timers_min_ls_arrival_cmd,
 
2336        "no timers lsa arrival",
 
2338        "Adjust routing timers\n"
 
2339        "Throttling link state advertisement delays\n"
 
2340        "OSPF minimum arrival interval delay\n")
 
2342   struct ospf *ospf = vty->index;
 
2343   ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
 
2348 DEFUN (ospf_timers_throttle_spf,
 
2349        ospf_timers_throttle_spf_cmd,
 
2350        "timers throttle spf <0-600000> <0-600000> <0-600000>",
 
2351        "Adjust routing timers\n"
 
2352        "Throttling adaptive timer\n"
 
2354        "Delay (msec) from first change received till SPF calculation\n"
 
2355        "Initial hold time (msec) between consecutive SPF calculations\n"
 
2356        "Maximum hold time (msec)\n")
 
2358   unsigned int delay, hold, max;
 
2362       vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
 
2366   VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
 
2367   VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
 
2368   VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
 
2370   return ospf_timers_spf_set (vty, delay, hold, max);
 
2373 DEFUN_DEPRECATED (ospf_timers_spf,
 
2374        ospf_timers_spf_cmd,
 
2375        "timers spf <0-4294967295> <0-4294967295>",
 
2376        "Adjust routing timers\n"
 
2378        "Delay (s) between receiving a change to SPF calculation\n"
 
2379        "Hold time (s) between consecutive SPF calculations\n")
 
2381   unsigned int delay, hold;
 
2385       vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
 
2389   VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
 
2390   VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
 
2392   /* truncate down the second values if they're greater than 600000ms */
 
2393   if (delay > (600000 / 1000))
 
2395   else if (delay == 0)
 
2396     /* 0s delay was probably specified because of lack of ms resolution */
 
2397     delay = OSPF_SPF_DELAY_DEFAULT;
 
2398   if (hold > (600000 / 1000))
 
2401   return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
 
2404 DEFUN (no_ospf_timers_throttle_spf,
 
2405        no_ospf_timers_throttle_spf_cmd,
 
2406        "no timers throttle spf",
 
2408        "Adjust routing timers\n"
 
2409        "Throttling adaptive timer\n"
 
2410        "OSPF SPF timers\n")
 
2412   return ospf_timers_spf_set (vty,
 
2413                               OSPF_SPF_DELAY_DEFAULT,
 
2414                               OSPF_SPF_HOLDTIME_DEFAULT,
 
2415                               OSPF_SPF_MAX_HOLDTIME_DEFAULT);
 
2418 ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
 
2419                   no_ospf_timers_spf_cmd,
 
2422                   "Adjust routing timers\n"
 
2423                   "OSPF SPF timers\n")
 
2425 DEFUN (ospf_neighbor,
 
2429        "Neighbor IP address\n")
 
2431   struct ospf *ospf = vty->index;
 
2432   struct in_addr nbr_addr;
 
2433   unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
 
2434   unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
 
2436   VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
 
2439     VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
 
2442     VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
 
2444   ospf_nbr_nbma_set (ospf, nbr_addr);
 
2446     ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
 
2448     ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
 
2453 ALIAS (ospf_neighbor,
 
2454        ospf_neighbor_priority_poll_interval_cmd,
 
2455        "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
 
2457        "Neighbor IP address\n"
 
2458        "Neighbor Priority\n"
 
2460        "Dead Neighbor Polling interval\n"
 
2463 ALIAS (ospf_neighbor,
 
2464        ospf_neighbor_priority_cmd,
 
2465        "neighbor A.B.C.D priority <0-255>",
 
2467        "Neighbor IP address\n"
 
2468        "Neighbor Priority\n"
 
2471 DEFUN (ospf_neighbor_poll_interval,
 
2472        ospf_neighbor_poll_interval_cmd,
 
2473        "neighbor A.B.C.D poll-interval <1-65535>",
 
2475        "Neighbor IP address\n"
 
2476        "Dead Neighbor Polling interval\n"
 
2479   struct ospf *ospf = vty->index;
 
2480   struct in_addr nbr_addr;
 
2481   unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
 
2482   unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
 
2484   VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
 
2487     VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
 
2490     VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
 
2492   ospf_nbr_nbma_set (ospf, nbr_addr);
 
2494     ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
 
2496     ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
 
2501 ALIAS (ospf_neighbor_poll_interval,
 
2502        ospf_neighbor_poll_interval_priority_cmd,
 
2503        "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
 
2505        "Neighbor address\n"
 
2506        "OSPF dead-router polling interval\n"
 
2508        "OSPF priority of non-broadcast neighbor\n"
 
2511 DEFUN (no_ospf_neighbor,
 
2512        no_ospf_neighbor_cmd,
 
2513        "no neighbor A.B.C.D",
 
2516        "Neighbor IP address\n")
 
2518   struct ospf *ospf = vty->index;
 
2519   struct in_addr nbr_addr;
 
2521   VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
 
2523   (void)ospf_nbr_nbma_unset (ospf, nbr_addr);
 
2528 ALIAS (no_ospf_neighbor,
 
2529        no_ospf_neighbor_priority_cmd,
 
2530        "no neighbor A.B.C.D priority <0-255>",
 
2533        "Neighbor IP address\n"
 
2534        "Neighbor Priority\n"
 
2537 ALIAS (no_ospf_neighbor,
 
2538        no_ospf_neighbor_poll_interval_cmd,
 
2539        "no neighbor A.B.C.D poll-interval <1-65535>",
 
2542        "Neighbor IP address\n"
 
2543        "Dead Neighbor Polling interval\n"
 
2546 ALIAS (no_ospf_neighbor,
 
2547        no_ospf_neighbor_priority_pollinterval_cmd,
 
2548        "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
 
2551        "Neighbor IP address\n"
 
2552        "Neighbor Priority\n"
 
2554        "Dead Neighbor Polling interval\n"
 
2558 DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
 
2559        "refresh timer <10-1800>",
 
2560        "Adjust refresh parameters\n"
 
2561        "Set refresh timer\n"
 
2562        "Timer value in seconds\n")
 
2564   struct ospf *ospf = vty->index;
 
2565   unsigned int interval;
 
2567   VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
 
2568   interval = (interval / 10) * 10;
 
2570   ospf_timers_refresh_set (ospf, interval);
 
2575 DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
 
2576        "no refresh timer <10-1800>",
 
2577        "Adjust refresh parameters\n"
 
2578        "Unset refresh timer\n"
 
2579        "Timer value in seconds\n")
 
2581   struct ospf *ospf = vty->index;
 
2582   unsigned int interval;
 
2586       VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
 
2588       if (ospf->lsa_refresh_interval != interval ||
 
2589           interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
 
2593   ospf_timers_refresh_unset (ospf);
 
2598 ALIAS (no_ospf_refresh_timer,
 
2599        no_ospf_refresh_timer_cmd,
 
2601        "Adjust refresh parameters\n"
 
2602        "Unset refresh timer\n")
 
2604 DEFUN (ospf_auto_cost_reference_bandwidth,
 
2605        ospf_auto_cost_reference_bandwidth_cmd,
 
2606        "auto-cost reference-bandwidth <1-4294967>",
 
2607        "Calculate OSPF interface cost according to bandwidth\n"
 
2608        "Use reference bandwidth method to assign OSPF cost\n"
 
2609        "The reference bandwidth in terms of Mbits per second\n")
 
2611   struct ospf *ospf = vty->index;
 
2613   struct listnode *node;
 
2614   struct interface *ifp;
 
2616   refbw = strtol (argv[0], NULL, 10);
 
2617   if (refbw < 1 || refbw > 4294967)
 
2619       vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
 
2623   /* If reference bandwidth is changed. */
 
2624   if ((refbw * 1000) == ospf->ref_bandwidth)
 
2627   ospf->ref_bandwidth = refbw * 1000;
 
2628   for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
 
2629     ospf_if_recalculate_output_cost (ifp);
 
2634 DEFUN (no_ospf_auto_cost_reference_bandwidth,
 
2635        no_ospf_auto_cost_reference_bandwidth_cmd,
 
2636        "no auto-cost reference-bandwidth",
 
2638        "Calculate OSPF interface cost according to bandwidth\n"
 
2639        "Use reference bandwidth method to assign OSPF cost\n")
 
2641   struct ospf *ospf = vty->index;
 
2642   struct listnode *node, *nnode;
 
2643   struct interface *ifp;
 
2645   if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
 
2648   ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
 
2649   vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
 
2650   vty_out (vty, "        Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
 
2652   for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
 
2653     ospf_if_recalculate_output_cost (ifp);
 
2658 const char *ospf_abr_type_descr_str[] = 
 
2661   "Standard (RFC2328)",
 
2663   "Alternative Cisco",
 
2664   "Alternative Shortcut"
 
2667 const char *ospf_shortcut_mode_descr_str[] = 
 
2677 show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
 
2680   vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
 
2682   /* Show Area type/mode. */
 
2683   if (OSPF_IS_AREA_BACKBONE (area))
 
2684     vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
 
2687       if (area->external_routing == OSPF_AREA_STUB)
 
2688         vty_out (vty, " (Stub%s%s)",
 
2689                          area->no_summary ? ", no summary" : "",
 
2690                          area->shortcut_configured ? "; " : "");
 
2692       else if (area->external_routing == OSPF_AREA_NSSA)
 
2693         vty_out (vty, " (NSSA%s%s)",
 
2694                  area->no_summary ? ", no summary" : "",
 
2695                  area->shortcut_configured ? "; " : "");
 
2697       vty_out (vty, "%s", VTY_NEWLINE);
 
2698       vty_out (vty, "   Shortcutting mode: %s",
 
2699                ospf_shortcut_mode_descr_str[area->shortcut_configured]);
 
2700       vty_out (vty, ", S-bit consensus: %s%s",
 
2701                area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
 
2704   /* Show number of interfaces. */
 
2705   vty_out (vty, "   Number of interfaces in this area: Total: %d, "
 
2706            "Active: %d%s", listcount (area->oiflist),
 
2707            area->act_ints, VTY_NEWLINE);
 
2709   if (area->external_routing == OSPF_AREA_NSSA)
 
2711       vty_out (vty, "   It is an NSSA configuration. %s   Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
 
2712       if (! IS_OSPF_ABR (area->ospf))
 
2713         vty_out (vty, "   It is not ABR, therefore not Translator. %s",
 
2715       else if (area->NSSATranslatorState)
 
2717          vty_out (vty, "   We are an ABR and ");
 
2718          if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
 
2719            vty_out (vty, "the NSSA Elected Translator. %s", 
 
2721          else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
 
2722            vty_out (vty, "always an NSSA Translator. %s",
 
2727          vty_out (vty, "   We are an ABR, but ");
 
2728          if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
 
2729            vty_out (vty, "not the NSSA Elected Translator. %s",
 
2732            vty_out (vty, "never an NSSA Translator. %s", 
 
2736   /* Stub-router state for this area */
 
2737   if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
 
2739       char timebuf[OSPF_TIME_DUMP_SIZE];
 
2740       vty_out (vty, "   Originating stub / maximum-distance Router-LSA%s",
 
2742       if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
 
2743         vty_out (vty, "     Administratively activated (indefinitely)%s",
 
2745       if (area->t_stub_router)
 
2746         vty_out (vty, "     Active from startup, %s remaining%s",
 
2747                  ospf_timer_dump (area->t_stub_router, timebuf, 
 
2748                                   sizeof(timebuf)), VTY_NEWLINE);
 
2751   /* Show number of fully adjacent neighbors. */
 
2752   vty_out (vty, "   Number of fully adjacent neighbors in this area:"
 
2753                 " %d%s", area->full_nbrs, VTY_NEWLINE);
 
2755   /* Show authentication type. */
 
2756   vty_out (vty, "   Area has ");
 
2757   if (area->auth_type == OSPF_AUTH_NULL)
 
2758     vty_out (vty, "no authentication%s", VTY_NEWLINE);
 
2759   else if (area->auth_type == OSPF_AUTH_SIMPLE)
 
2760     vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
 
2761   else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
 
2762     vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
 
2764   if (!OSPF_IS_AREA_BACKBONE (area))
 
2765     vty_out (vty, "   Number of full virtual adjacencies going through"
 
2766              " this area: %d%s", area->full_vls, VTY_NEWLINE);
 
2768   /* Show SPF calculation times. */
 
2769   vty_out (vty, "   SPF algorithm executed %d times%s",
 
2770            area->spf_calculation, VTY_NEWLINE);
 
2772   /* Show number of LSA. */
 
2773   vty_out (vty, "   Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
 
2774   vty_out (vty, "   Number of router LSA %ld. Checksum Sum 0x%08x%s",
 
2775            ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
 
2776            ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
 
2777   vty_out (vty, "   Number of network LSA %ld. Checksum Sum 0x%08x%s",
 
2778            ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
 
2779            ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
 
2780   vty_out (vty, "   Number of summary LSA %ld. Checksum Sum 0x%08x%s",
 
2781            ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
 
2782            ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
 
2783   vty_out (vty, "   Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
 
2784            ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
 
2785            ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
 
2786   vty_out (vty, "   Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
 
2787            ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
 
2788            ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
 
2789   vty_out (vty, "   Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
 
2790            ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
 
2791            ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
 
2792   vty_out (vty, "   Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
 
2793            ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
 
2794            ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
 
2795   vty_out (vty, "%s", VTY_NEWLINE);
 
2798 DEFUN (show_ip_ospf,
 
2803        "OSPF information\n")
 
2805   struct listnode *node, *nnode;
 
2806   struct ospf_area * area;
 
2808   struct timeval result;
 
2809   char timebuf[OSPF_TIME_DUMP_SIZE];
 
2811   /* Check OSPF is enable. */
 
2812   ospf = ospf_lookup ();
 
2815       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
2819   /* Show Router ID. */
 
2820   vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
 
2821            inet_ntoa (ospf->router_id),
 
2824   /* Graceful shutdown */
 
2825   if (ospf->t_deferred_shutdown)
 
2826     vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
 
2827              ospf_timer_dump (ospf->t_deferred_shutdown,
 
2828                               timebuf, sizeof (timebuf)), VTY_NEWLINE);
 
2829   /* Show capability. */
 
2830   vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
 
2831   vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
 
2832   vty_out (vty, " RFC1583Compatibility flag is %s%s",
 
2833            CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
 
2834            "enabled" : "disabled", VTY_NEWLINE);
 
2835   vty_out (vty, " OpaqueCapability flag is %s%s",
 
2836            CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
 
2837            "enabled" : "disabled",
 
2840   /* Show stub-router configuration */
 
2841   if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
 
2842       || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
 
2844       vty_out (vty, " Stub router advertisement is configured%s",
 
2846       if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
 
2847         vty_out (vty, "   Enabled for %us after start-up%s",
 
2848                  ospf->stub_router_startup_time, VTY_NEWLINE);
 
2849       if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
 
2850         vty_out (vty, "   Enabled for %us prior to full shutdown%s",
 
2851                  ospf->stub_router_shutdown_time, VTY_NEWLINE);
 
2854   /* Show SPF timers. */
 
2855   vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
 
2856                 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
 
2857                 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
 
2858                 " Hold time multiplier is currently %d%s",
 
2859           ospf->spf_delay, VTY_NEWLINE,
 
2860           ospf->spf_holdtime, VTY_NEWLINE,
 
2861           ospf->spf_max_holdtime, VTY_NEWLINE,
 
2862           ospf->spf_hold_multiplier, VTY_NEWLINE);
 
2863   vty_out (vty, " SPF algorithm ");
 
2864   if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
 
2866       result = tv_sub (recent_relative_time (), ospf->ts_spf);
 
2867       vty_out (vty, "last executed %s ago%s",
 
2868                ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
 
2870       vty_out (vty, " Last SPF duration %s%s",
 
2871                ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)),
 
2875     vty_out (vty, "has not been run%s", VTY_NEWLINE);
 
2876   vty_out (vty, " SPF timer %s%s%s",
 
2877            (ospf->t_spf_calc ? "due in " : "is "),
 
2878            ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
 
2881   /* Show refresh parameters. */
 
2882   vty_out (vty, " Refresh timer %d secs%s",
 
2883            ospf->lsa_refresh_interval, VTY_NEWLINE);
 
2885   /* Show ABR/ASBR flags. */
 
2886   if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
 
2887     vty_out (vty, " This router is an ABR, ABR type is: %s%s",
 
2888              ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
 
2890   if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
 
2891     vty_out (vty, " This router is an ASBR "
 
2892              "(injecting external routing information)%s", VTY_NEWLINE);
 
2894   /* Show Number of AS-external-LSAs. */
 
2895   vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
 
2896            ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
 
2897            ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
 
2898   vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
 
2899            ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
 
2900            ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
 
2901   /* Show number of areas attached. */
 
2902   vty_out (vty, " Number of areas attached to this router: %d%s",
 
2903            listcount (ospf->areas), VTY_NEWLINE);
 
2905   if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
 
2907       if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
 
2908         vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
 
2910         vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
 
2913   vty_out (vty, "%s",VTY_NEWLINE);
 
2915   /* Show each area status. */
 
2916   for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
 
2917     show_ip_ospf_area (vty, area);
 
2924 show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
 
2925                             struct interface *ifp)
 
2928   struct ospf_neighbor *nbr;
 
2929   struct route_node *rn;
 
2931   /* Is interface up? */
 
2932   vty_out (vty, "%s is %s%s", ifp->name,
 
2933            ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
 
2934   vty_out (vty, "  ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
 
2935            ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
 
2938   /* Is interface OSPF enabled? */
 
2939   if (ospf_oi_count(ifp) == 0)
 
2941       vty_out (vty, "  OSPF not enabled on this interface%s", VTY_NEWLINE);
 
2946       vty_out (vty, "  OSPF is enabled, but not running on this interface%s",
 
2951   for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
 
2953       struct ospf_interface *oi = rn->info;
 
2958       /* Show OSPF interface information. */
 
2959       vty_out (vty, "  Internet Address %s/%d,",
 
2960                inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
 
2962       if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
 
2964           struct in_addr *dest;
 
2967           if (CONNECTED_PEER(oi->connected)
 
2968               || oi->type == OSPF_IFTYPE_VIRTUALLINK)
 
2973           /* For Vlinks, showing the peer address is probably more
 
2974            * informative than the local interface that is being used
 
2976           if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
 
2977             dest = &oi->vl_data->peer_addr;
 
2979             dest = &oi->connected->destination->u.prefix4;
 
2981           vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
 
2984       vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
 
2987       vty_out (vty, "  MTU mismatch detection:%s%s",
 
2988            OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
 
2990       vty_out (vty, "  Router ID %s, Network Type %s, Cost: %d%s",
 
2991                inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
 
2992                oi->output_cost, VTY_NEWLINE);
 
2994       vty_out (vty, "  Transmit Delay is %d sec, State %s, Priority %d%s",
 
2995                OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
 
2996                PRIORITY (oi), VTY_NEWLINE);
 
2998   /* Show DR information. */
 
2999       if (DR (oi).s_addr == 0)
 
3000         vty_out (vty, "  No designated router on this network%s", VTY_NEWLINE);
 
3003           nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
 
3005             vty_out (vty, "  No designated router on this network%s", VTY_NEWLINE);
 
3008               vty_out (vty, "  Designated Router (ID) %s,",
 
3009                        inet_ntoa (nbr->router_id));
 
3010               vty_out (vty, " Interface Address %s%s",
 
3011                        inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
 
3015       /* Show BDR information. */
 
3016       if (BDR (oi).s_addr == 0)
 
3017         vty_out (vty, "  No backup designated router on this network%s",
 
3021           nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
 
3023             vty_out (vty, "  No backup designated router on this network%s",
 
3027               vty_out (vty, "  Backup Designated Router (ID) %s,",
 
3028                        inet_ntoa (nbr->router_id));
 
3029               vty_out (vty, " Interface Address %s%s",
 
3030                        inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
 
3034       /* Next network-LSA sequence number we'll use, if we're elected DR */
 
3035       if (oi->params && ntohl (oi->params->network_lsa_seqnum)
 
3036                           != OSPF_INITIAL_SEQUENCE_NUMBER)
 
3037         vty_out (vty, "  Saved Network-LSA sequence number 0x%x%s",
 
3038                  ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
 
3040       vty_out (vty, "  Multicast group memberships:");
 
3041       if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
 
3042           || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
 
3044           if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
 
3045             vty_out (vty, " OSPFAllRouters");
 
3046           if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
 
3047             vty_out (vty, " OSPFDesignatedRouters");
 
3050         vty_out (vty, " <None>");
 
3051       vty_out (vty, "%s", VTY_NEWLINE);
 
3053       vty_out (vty, "  Timer intervals configured,");
 
3054       vty_out (vty, " Hello ");
 
3055       if (OSPF_IF_PARAM (oi, fast_hello) == 0)
 
3056         vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
 
3058         vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
 
3059       vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
 
3060                OSPF_IF_PARAM (oi, v_wait),
 
3061                OSPF_IF_PARAM (oi, v_wait),
 
3062                OSPF_IF_PARAM (oi, retransmit_interval),
 
3065       if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
 
3067           char timebuf[OSPF_TIME_DUMP_SIZE];
 
3068           vty_out (vty, "    Hello due in %s%s",
 
3069                    ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), 
 
3072       else /* passive-interface is set */
 
3073         vty_out (vty, "    No Hellos (Passive interface)%s", VTY_NEWLINE);
 
3075       vty_out (vty, "  Neighbor Count is %d, Adjacent neighbor count is %d%s",
 
3076                ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
 
3081 DEFUN (show_ip_ospf_interface,
 
3082        show_ip_ospf_interface_cmd,
 
3083        "show ip ospf interface [INTERFACE]",
 
3086        "OSPF information\n"
 
3087        "Interface information\n"
 
3090   struct interface *ifp;
 
3092   struct listnode *node;
 
3094   ospf = ospf_lookup ();
 
3097       vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
3101   /* Show All Interfaces. */
 
3103     for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
 
3104       show_ip_ospf_interface_sub (vty, ospf, ifp);
 
3105   /* Interface name is specified. */
 
3108       if ((ifp = if_lookup_by_name (argv[0])) == NULL)
 
3109         vty_out (vty, "No such interface name%s", VTY_NEWLINE);
 
3111         show_ip_ospf_interface_sub (vty, ospf, ifp);
 
3118 show_ip_ospf_neighbour_header (struct vty *vty)
 
3120   vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
 
3122            "Neighbor ID", "Pri", "State", "Dead Time",
 
3123            "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
 
3128 show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
 
3130   struct route_node *rn;
 
3131   struct ospf_neighbor *nbr;
 
3133   char timebuf[OSPF_TIME_DUMP_SIZE];
 
3135   for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
 
3136     if ((nbr = rn->info))
 
3137       /* Do not show myself. */
 
3138       if (nbr != oi->nbr_self)
 
3139         /* Down state is not shown. */
 
3140         if (nbr->state != NSM_Down)
 
3142             ospf_nbr_state_message (nbr, msgbuf, 16);
 
3144             if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
 
3145               vty_out (vty, "%-15s %3d %-15s ",
 
3149               vty_out (vty, "%-15s %3d %-15s ",
 
3150                        inet_ntoa (nbr->router_id), nbr->priority,
 
3153             vty_out (vty, "%9s ",
 
3154                      ospf_timer_dump (nbr->t_inactivity, timebuf, 
 
3157             vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
 
3158             vty_out (vty, "%-20s %5ld %5ld %5d%s",
 
3159                      IF_NAME (oi), ospf_ls_retransmit_count (nbr),
 
3160                      ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
 
3165 DEFUN (show_ip_ospf_neighbor,
 
3166        show_ip_ospf_neighbor_cmd,
 
3167        "show ip ospf neighbor",
 
3170        "OSPF information\n"
 
3174   struct ospf_interface *oi;
 
3175   struct listnode *node;
 
3177   ospf = ospf_lookup ();
 
3180       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
3184   show_ip_ospf_neighbour_header (vty);
 
3186   for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
 
3187     show_ip_ospf_neighbor_sub (vty, oi);
 
3192 DEFUN (show_ip_ospf_neighbor_all,
 
3193        show_ip_ospf_neighbor_all_cmd,
 
3194        "show ip ospf neighbor all",
 
3197        "OSPF information\n"
 
3199        "include down status neighbor\n")
 
3201   struct ospf *ospf = ospf_lookup ();
 
3202   struct listnode *node;
 
3203   struct ospf_interface *oi;
 
3207       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
3211   show_ip_ospf_neighbour_header (vty);
 
3213   for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
 
3215       struct listnode *nbr_node;
 
3216       struct ospf_nbr_nbma *nbr_nbma;
 
3218       show_ip_ospf_neighbor_sub (vty, oi);
 
3220     /* print Down neighbor status */
 
3221     for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
 
3223         if (nbr_nbma->nbr == NULL
 
3224             || nbr_nbma->nbr->state == NSM_Down)
 
3226             vty_out (vty, "%-15s %3d %-15s %9s ",
 
3227                      "-", nbr_nbma->priority, "Down", "-");
 
3228             vty_out (vty, "%-15s %-20s %5d %5d %5d%s", 
 
3229                      inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
 
3230                      0, 0, 0, VTY_NEWLINE);
 
3238 DEFUN (show_ip_ospf_neighbor_int,
 
3239        show_ip_ospf_neighbor_int_cmd,
 
3240        "show ip ospf neighbor IFNAME",
 
3243        "OSPF information\n"
 
3248   struct interface *ifp;
 
3249   struct route_node *rn;
 
3251   ifp = if_lookup_by_name (argv[0]);
 
3254       vty_out (vty, "No such interface.%s", VTY_NEWLINE);
 
3258   ospf = ospf_lookup ();
 
3261       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
3265   show_ip_ospf_neighbour_header (vty);
 
3267   for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
 
3269       struct ospf_interface *oi = rn->info;
 
3274       show_ip_ospf_neighbor_sub (vty, oi);
 
3281 show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
 
3282                                   struct ospf_nbr_nbma *nbr_nbma)
 
3284   char timebuf[OSPF_TIME_DUMP_SIZE];
 
3286   /* Show neighbor ID. */
 
3287   vty_out (vty, " Neighbor %s,", "-");
 
3289   /* Show interface address. */
 
3290   vty_out (vty, " interface address %s%s",
 
3291            inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
 
3293   vty_out (vty, "    In the area %s via interface %s%s",
 
3294            ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
 
3295   /* Show neighbor priority and state. */
 
3296   vty_out (vty, "    Neighbor priority is %d, State is %s,",
 
3297            nbr_nbma->priority, "Down");
 
3298   /* Show state changes. */
 
3299   vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
 
3301   /* Show PollInterval */
 
3302   vty_out (vty, "    Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
 
3304   /* Show poll-interval timer. */
 
3305   vty_out (vty, "    Poll timer due in %s%s",
 
3306            ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
 
3309   /* Show poll-interval timer thread. */
 
3310   vty_out (vty, "    Thread Poll Timer %s%s", 
 
3311            nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
 
3315 show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
 
3316                                   struct ospf_neighbor *nbr)
 
3318   char timebuf[OSPF_TIME_DUMP_SIZE];
 
3320   /* Show neighbor ID. */
 
3321   if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
 
3322     vty_out (vty, " Neighbor %s,", "-");
 
3324   vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
 
3326   /* Show interface address. */
 
3327   vty_out (vty, " interface address %s%s",
 
3328            inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
 
3330   vty_out (vty, "    In the area %s via interface %s%s",
 
3331            ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
 
3332   /* Show neighbor priority and state. */
 
3333   vty_out (vty, "    Neighbor priority is %d, State is %s,",
 
3334            nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
 
3335   /* Show state changes. */
 
3336   vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
 
3337   if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
 
3340         = tv_sub (recent_relative_time (), nbr->ts_last_progress);
 
3341       vty_out (vty, "    Most recent state change statistics:%s",
 
3343       vty_out (vty, "      Progressive change %s ago%s",
 
3344                ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
 
3347   if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
 
3350         = tv_sub (recent_relative_time (), nbr->ts_last_regress);
 
3351       vty_out (vty, "      Regressive change %s ago, due to %s%s",
 
3352                ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
 
3353                (nbr->last_regress_str ? nbr->last_regress_str : "??"),
 
3356   /* Show Designated Rotuer ID. */
 
3357   vty_out (vty, "    DR is %s,", inet_ntoa (nbr->d_router));
 
3358   /* Show Backup Designated Rotuer ID. */
 
3359   vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
 
3361   vty_out (vty, "    Options %d %s%s", nbr->options,
 
3362            ospf_options_dump (nbr->options), VTY_NEWLINE);
 
3363   /* Show Router Dead interval timer. */
 
3364   vty_out (vty, "    Dead timer due in %s%s",
 
3365            ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
 
3367   /* Show Database Summary list. */
 
3368   vty_out (vty, "    Database Summary List %d%s",
 
3369            ospf_db_summary_count (nbr), VTY_NEWLINE);
 
3370   /* Show Link State Request list. */
 
3371   vty_out (vty, "    Link State Request List %ld%s",
 
3372            ospf_ls_request_count (nbr), VTY_NEWLINE);
 
3373   /* Show Link State Retransmission list. */
 
3374   vty_out (vty, "    Link State Retransmission List %ld%s",
 
3375            ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
 
3376   /* Show inactivity timer thread. */
 
3377   vty_out (vty, "    Thread Inactivity Timer %s%s", 
 
3378            nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
 
3379   /* Show Database Description retransmission thread. */
 
3380   vty_out (vty, "    Thread Database Description Retransmision %s%s",
 
3381            nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
 
3382   /* Show Link State Request Retransmission thread. */
 
3383   vty_out (vty, "    Thread Link State Request Retransmission %s%s",
 
3384            nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
 
3385   /* Show Link State Update Retransmission thread. */
 
3386   vty_out (vty, "    Thread Link State Update Retransmission %s%s%s",
 
3387            nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
 
3390 DEFUN (show_ip_ospf_neighbor_id,
 
3391        show_ip_ospf_neighbor_id_cmd,
 
3392        "show ip ospf neighbor A.B.C.D",
 
3395        "OSPF information\n"
 
3400   struct listnode *node;
 
3401   struct ospf_neighbor *nbr;
 
3402   struct ospf_interface *oi;
 
3403   struct in_addr router_id;
 
3406   ret = inet_aton (argv[0], &router_id);
 
3409       vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
 
3413   ospf = ospf_lookup ();
 
3416       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
3420   for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
 
3421     if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
 
3422       show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
 
3427 DEFUN (show_ip_ospf_neighbor_detail,
 
3428        show_ip_ospf_neighbor_detail_cmd,
 
3429        "show ip ospf neighbor detail",
 
3432        "OSPF information\n"
 
3434        "detail of all neighbors\n")
 
3437   struct ospf_interface *oi;
 
3438   struct listnode *node;
 
3440   ospf = ospf_lookup ();
 
3443       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
3447   for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
 
3449       struct route_node *rn;
 
3450       struct ospf_neighbor *nbr;
 
3452       for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
 
3453         if ((nbr = rn->info))
 
3454           if (nbr != oi->nbr_self)
 
3455             if (nbr->state != NSM_Down)
 
3456               show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
 
3462 DEFUN (show_ip_ospf_neighbor_detail_all,
 
3463        show_ip_ospf_neighbor_detail_all_cmd,
 
3464        "show ip ospf neighbor detail all",
 
3467        "OSPF information\n"
 
3469        "detail of all neighbors\n"
 
3470        "include down status neighbor\n")
 
3473   struct listnode *node;
 
3474   struct ospf_interface *oi;
 
3476   ospf = ospf_lookup ();
 
3479       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
3483   for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
 
3485       struct route_node *rn;
 
3486       struct ospf_neighbor *nbr;
 
3487       struct ospf_nbr_nbma *nbr_nbma;
 
3489       for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
 
3490         if ((nbr = rn->info))
 
3491           if (nbr != oi->nbr_self)
 
3492             if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
 
3493               show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
 
3495       if (oi->type == OSPF_IFTYPE_NBMA)
 
3497           struct listnode *nd;
 
3499           for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
 
3500             if (nbr_nbma->nbr == NULL
 
3501                 || nbr_nbma->nbr->state == NSM_Down)
 
3502               show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
 
3509 DEFUN (show_ip_ospf_neighbor_int_detail,
 
3510        show_ip_ospf_neighbor_int_detail_cmd,
 
3511        "show ip ospf neighbor IFNAME detail",
 
3514        "OSPF information\n"
 
3517        "detail of all neighbors")
 
3520   struct ospf_interface *oi;
 
3521   struct interface *ifp;
 
3522   struct route_node *rn, *nrn;
 
3523   struct ospf_neighbor *nbr;
 
3525   ifp = if_lookup_by_name (argv[0]);
 
3528       vty_out (vty, "No such interface.%s", VTY_NEWLINE);
 
3532   ospf = ospf_lookup ();
 
3535       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
3540   for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
 
3541     if ((oi = rn->info))
 
3542       for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
 
3543         if ((nbr = nrn->info))
 
3544           if (nbr != oi->nbr_self)
 
3545             if (nbr->state != NSM_Down)
 
3546               show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
 
3552 /* Show functions */
 
3554 show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
 
3556   struct router_lsa *rl;
 
3557   struct summary_lsa *sl;
 
3558   struct as_external_lsa *asel;
 
3559   struct prefix_ipv4 p;
 
3562     /* If self option is set, check LSA self flag. */
 
3563     if (self == 0 || IS_LSA_SELF (lsa))
 
3565         /* LSA common part show. */
 
3566         vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
 
3567         vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
 
3568                  inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
 
3569                  (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
 
3570         /* LSA specific part show. */
 
3571         switch (lsa->data->type)
 
3573           case OSPF_ROUTER_LSA:
 
3574             rl = (struct router_lsa *) lsa->data;
 
3575             vty_out (vty, " %-d", ntohs (rl->links));
 
3577           case OSPF_SUMMARY_LSA:
 
3578             sl = (struct summary_lsa *) lsa->data;
 
3581             p.prefix = sl->header.id;
 
3582             p.prefixlen = ip_masklen (sl->mask);
 
3583             apply_mask_ipv4 (&p);
 
3585             vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
 
3587           case OSPF_AS_EXTERNAL_LSA:
 
3588           case OSPF_AS_NSSA_LSA:
 
3589             asel = (struct as_external_lsa *) lsa->data;
 
3592             p.prefix = asel->header.id;
 
3593             p.prefixlen = ip_masklen (asel->mask);
 
3594             apply_mask_ipv4 (&p);
 
3596             vty_out (vty, " %s %s/%d [0x%lx]",
 
3597                      IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
 
3598                      inet_ntoa (p.prefix), p.prefixlen,
 
3599                      (u_long)ntohl (asel->e[0].route_tag));
 
3601           case OSPF_NETWORK_LSA:
 
3602           case OSPF_ASBR_SUMMARY_LSA:
 
3603           case OSPF_OPAQUE_LINK_LSA:
 
3604           case OSPF_OPAQUE_AREA_LSA:
 
3605           case OSPF_OPAQUE_AS_LSA:
 
3609         vty_out (vty, VTY_NEWLINE);
 
3615 static const char *show_database_desc[] =
 
3618   "Router Link States",
 
3620   "Summary Link States",
 
3621   "ASBR-Summary Link States",
 
3622   "AS External Link States",
 
3623   "Group Membership LSA",
 
3624   "NSSA-external Link States",
 
3626   "Link-Local Opaque-LSA",
 
3627   "Area-Local Opaque-LSA",
 
3628   "AS-external Opaque-LSA",
 
3631 static const char *show_database_header[] =
 
3634   "Link ID         ADV Router      Age  Seq#       CkSum  Link count",
 
3635   "Link ID         ADV Router      Age  Seq#       CkSum",
 
3636   "Link ID         ADV Router      Age  Seq#       CkSum  Route",
 
3637   "Link ID         ADV Router      Age  Seq#       CkSum",
 
3638   "Link ID         ADV Router      Age  Seq#       CkSum  Route",
 
3639   " --- header for Group Member ----",
 
3640   "Link ID         ADV Router      Age  Seq#       CkSum  Route",
 
3642   "Opaque-Type/Id  ADV Router      Age  Seq#       CkSum",
 
3643   "Opaque-Type/Id  ADV Router      Age  Seq#       CkSum",
 
3644   "Opaque-Type/Id  ADV Router      Age  Seq#       CkSum",
 
3648 show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
 
3650   struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
 
3652   vty_out (vty, "  LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
 
3653   vty_out (vty, "  Options: 0x%-2x : %s%s", 
 
3655            ospf_options_dump(lsa->data->options), 
 
3657   vty_out (vty, "  LS Flags: 0x%-2x %s%s",
 
3659            ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
 
3662   if (lsa->data->type == OSPF_ROUTER_LSA)
 
3664       vty_out (vty, "  Flags: 0x%x" , rlsa->flags);
 
3667         vty_out (vty, " :%s%s%s%s",
 
3668                  IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
 
3669                  IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
 
3670                  IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
 
3671                  IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
 
3673       vty_out (vty, "%s", VTY_NEWLINE);
 
3675   vty_out (vty, "  LS Type: %s%s",
 
3676            LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
 
3677   vty_out (vty, "  Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
 
3678            LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
 
3679   vty_out (vty, "  Advertising Router: %s%s",
 
3680            inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
 
3681   vty_out (vty, "  LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
 
3683   vty_out (vty, "  Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
 
3685   vty_out (vty, "  Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
 
3688 const char *link_type_desc[] =
 
3691   "another Router (point-to-point)",
 
3692   "a Transit Network",
 
3697 const char *link_id_desc[] =
 
3700   "Neighboring Router ID",
 
3701   "Designated Router address",
 
3703   "Neighboring Router ID",
 
3706 const char *link_data_desc[] =
 
3709   "Router Interface address",
 
3710   "Router Interface address",
 
3712   "Router Interface address",
 
3715 /* Show router-LSA each Link information. */
 
3717 show_ip_ospf_database_router_links (struct vty *vty,
 
3718                                     struct router_lsa *rl)
 
3723   len = ntohs (rl->header.length) - 4;
 
3724   for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
 
3726       type = rl->link[i].type;
 
3728       vty_out (vty, "    Link connected to: %s%s",
 
3729                link_type_desc[type], VTY_NEWLINE);
 
3730       vty_out (vty, "     (Link ID) %s: %s%s", link_id_desc[type],
 
3731                inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
 
3732       vty_out (vty, "     (Link Data) %s: %s%s", link_data_desc[type],
 
3733                inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
 
3734       vty_out (vty, "      Number of TOS metrics: 0%s", VTY_NEWLINE);
 
3735       vty_out (vty, "       TOS 0 Metric: %d%s",
 
3736                ntohs (rl->link[i].metric), VTY_NEWLINE);
 
3737       vty_out (vty, "%s", VTY_NEWLINE);
 
3741 /* Show router-LSA detail information. */
 
3743 show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
 
3747       struct router_lsa *rl = (struct router_lsa *) lsa->data;
 
3749       show_ip_ospf_database_header (vty, lsa);
 
3751       vty_out (vty, "   Number of Links: %d%s%s", ntohs (rl->links),
 
3752                VTY_NEWLINE, VTY_NEWLINE);
 
3754       show_ip_ospf_database_router_links (vty, rl);
 
3755       vty_out (vty, "%s", VTY_NEWLINE);
 
3761 /* Show network-LSA detail information. */
 
3763 show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
 
3769       struct network_lsa *nl = (struct network_lsa *) lsa->data;
 
3771       show_ip_ospf_database_header (vty, lsa);
 
3773       vty_out (vty, "  Network Mask: /%d%s",
 
3774                ip_masklen (nl->mask), VTY_NEWLINE);
 
3776       length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
 
3778       for (i = 0; length > 0; i++, length -= 4)
 
3779         vty_out (vty, "        Attached Router: %s%s",
 
3780                  inet_ntoa (nl->routers[i]), VTY_NEWLINE);
 
3782       vty_out (vty, "%s", VTY_NEWLINE);
 
3788 /* Show summary-LSA detail information. */
 
3790 show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
 
3794       struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
 
3796       show_ip_ospf_database_header (vty, lsa);
 
3798       vty_out (vty, "  Network Mask: /%d%s", ip_masklen (sl->mask),
 
3800       vty_out (vty, "        TOS: 0  Metric: %d%s", GET_METRIC (sl->metric),
 
3802           vty_out (vty, "%s", VTY_NEWLINE);
 
3808 /* Show summary-ASBR-LSA detail information. */
 
3810 show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
 
3814       struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
 
3816       show_ip_ospf_database_header (vty, lsa);
 
3818       vty_out (vty, "  Network Mask: /%d%s",
 
3819                ip_masklen (sl->mask), VTY_NEWLINE);
 
3820       vty_out (vty, "        TOS: 0  Metric: %d%s", GET_METRIC (sl->metric),
 
3822           vty_out (vty, "%s", VTY_NEWLINE);
 
3828 /* Show AS-external-LSA detail information. */
 
3830 show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
 
3834       struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
 
3836       show_ip_ospf_database_header (vty, lsa);
 
3838       vty_out (vty, "  Network Mask: /%d%s",
 
3839                ip_masklen (al->mask), VTY_NEWLINE);
 
3840       vty_out (vty, "        Metric Type: %s%s",
 
3841                IS_EXTERNAL_METRIC (al->e[0].tos) ?
 
3842                "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
 
3843       vty_out (vty, "        TOS: 0%s", VTY_NEWLINE);
 
3844       vty_out (vty, "        Metric: %d%s",
 
3845                GET_METRIC (al->e[0].metric), VTY_NEWLINE);
 
3846       vty_out (vty, "        Forward Address: %s%s",
 
3847                inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
 
3849       vty_out (vty, "        External Route Tag: %lu%s%s",
 
3850                (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
 
3858 show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
 
3860   struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
 
3862   /* show_ip_ospf_database_header (vty, lsa); */
 
3864   zlog_debug( "  Network Mask: /%d%s",
 
3865              ip_masklen (al->mask), "\n");
 
3866   zlog_debug( "        Metric Type: %s%s",
 
3867              IS_EXTERNAL_METRIC (al->e[0].tos) ?
 
3868              "2 (Larger than any link state path)" : "1", "\n");
 
3869   zlog_debug( "        TOS: 0%s", "\n");
 
3870   zlog_debug( "        Metric: %d%s",
 
3871              GET_METRIC (al->e[0].metric), "\n");
 
3872   zlog_debug( "        Forward Address: %s%s",
 
3873              inet_ntoa (al->e[0].fwd_addr), "\n");
 
3875   zlog_debug( "        External Route Tag: %lu%s%s",
 
3876              (u_long)ntohl (al->e[0].route_tag), "\n", "\n");
 
3882 /* Show AS-NSSA-LSA detail information. */
 
3884 show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
 
3888       struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
 
3890       show_ip_ospf_database_header (vty, lsa);
 
3892       vty_out (vty, "  Network Mask: /%d%s",
 
3893                ip_masklen (al->mask), VTY_NEWLINE);
 
3894       vty_out (vty, "        Metric Type: %s%s",
 
3895                IS_EXTERNAL_METRIC (al->e[0].tos) ?
 
3896                "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
 
3897       vty_out (vty, "        TOS: 0%s", VTY_NEWLINE);
 
3898       vty_out (vty, "        Metric: %d%s",
 
3899                GET_METRIC (al->e[0].metric), VTY_NEWLINE);
 
3900       vty_out (vty, "        NSSA: Forward Address: %s%s",
 
3901                inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
 
3903       vty_out (vty, "        External Route Tag: %lu%s%s",
 
3904                (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
 
3911 show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
 
3917 show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
 
3921       show_ip_ospf_database_header (vty, lsa);
 
3922       show_opaque_info_detail (vty, lsa);
 
3924       vty_out (vty, "%s", VTY_NEWLINE);
 
3929 int (*show_function[])(struct vty *, struct ospf_lsa *) =
 
3932   show_router_lsa_detail,
 
3933   show_network_lsa_detail,
 
3934   show_summary_lsa_detail,
 
3935   show_summary_asbr_lsa_detail,
 
3936   show_as_external_lsa_detail,
 
3938   show_as_nssa_lsa_detail,  /* almost same as external */
 
3940   show_opaque_lsa_detail,
 
3941   show_opaque_lsa_detail,
 
3942   show_opaque_lsa_detail,
 
3946 show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
 
3947                      struct in_addr *adv_router)
 
3949   memset (lp, 0, sizeof (struct prefix_ls));
 
3953   else if (adv_router == NULL)
 
3962       lp->adv_router = *adv_router;
 
3967 show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
 
3968                       struct in_addr *id, struct in_addr *adv_router)
 
3970   struct prefix_ls lp;
 
3971   struct route_node *rn, *start;
 
3972   struct ospf_lsa *lsa;
 
3974   show_lsa_prefix_set (vty, &lp, id, adv_router);
 
3975   start = route_node_get (rt, (struct prefix *) &lp);
 
3978       route_lock_node (start);
 
3979       for (rn = start; rn; rn = route_next_until (rn, start))
 
3980         if ((lsa = rn->info))
 
3982             if (show_function[lsa->data->type] != NULL)
 
3983               show_function[lsa->data->type] (vty, lsa);
 
3985       route_unlock_node (start);
 
3989 /* Show detail LSA information
 
3990    -- if id is NULL then show all LSAs. */
 
3992 show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
 
3993                  struct in_addr *id, struct in_addr *adv_router)
 
3995   struct listnode *node;
 
3996   struct ospf_area *area;
 
4000     case OSPF_AS_EXTERNAL_LSA:
 
4001     case OSPF_OPAQUE_AS_LSA:
 
4002       vty_out (vty, "                %s %s%s",
 
4003                show_database_desc[type],
 
4004                VTY_NEWLINE, VTY_NEWLINE);
 
4005       show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
 
4008       for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
 
4010           vty_out (vty, "%s                %s (Area %s)%s%s",
 
4011                    VTY_NEWLINE, show_database_desc[type],
 
4012                    ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
 
4013           show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
 
4020 show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
 
4021                                  struct in_addr *adv_router)
 
4023   struct route_node *rn;
 
4024   struct ospf_lsa *lsa;
 
4026   for (rn = route_top (rt); rn; rn = route_next (rn))
 
4027     if ((lsa = rn->info))
 
4028       if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
 
4030           if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
 
4032           if (show_function[lsa->data->type] != NULL)
 
4033             show_function[lsa->data->type] (vty, lsa);
 
4037 /* Show detail LSA information. */
 
4039 show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
 
4040                             struct in_addr *adv_router)
 
4042   struct listnode *node;
 
4043   struct ospf_area *area;
 
4047     case OSPF_AS_EXTERNAL_LSA:
 
4048     case OSPF_OPAQUE_AS_LSA:
 
4049       vty_out (vty, "                %s %s%s",
 
4050                show_database_desc[type],
 
4051                VTY_NEWLINE, VTY_NEWLINE);
 
4052       show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
 
4056       for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
 
4058           vty_out (vty, "%s                %s (Area %s)%s%s",
 
4059                    VTY_NEWLINE, show_database_desc[type],
 
4060                    ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
 
4061           show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
 
4069 show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
 
4071   struct ospf_lsa *lsa;
 
4072   struct route_node *rn;
 
4073   struct ospf_area *area;
 
4074   struct listnode *node;
 
4077   for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
 
4079       for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
 
4083             case OSPF_AS_EXTERNAL_LSA:
 
4084             case OSPF_OPAQUE_AS_LSA:
 
4089           if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
 
4090               (!self && ospf_lsdb_count (area->lsdb, type) > 0))
 
4092               vty_out (vty, "                %s (Area %s)%s%s",
 
4093                        show_database_desc[type],
 
4094                        ospf_area_desc_string (area),
 
4095                        VTY_NEWLINE, VTY_NEWLINE);
 
4096               vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
 
4098               LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
 
4099                 show_lsa_summary (vty, lsa, self);
 
4101               vty_out (vty, "%s", VTY_NEWLINE);
 
4106   for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
 
4110           case OSPF_AS_EXTERNAL_LSA:
 
4111           case OSPF_OPAQUE_AS_LSA:
 
4116       if (ospf_lsdb_count_self (ospf->lsdb, type) ||
 
4117          (!self && ospf_lsdb_count (ospf->lsdb, type)))
 
4119           vty_out (vty, "                %s%s%s",
 
4120                show_database_desc[type],
 
4121                VTY_NEWLINE, VTY_NEWLINE);
 
4122           vty_out (vty, "%s%s", show_database_header[type],
 
4125           LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
 
4126             show_lsa_summary (vty, lsa, self);
 
4128           vty_out (vty, "%s", VTY_NEWLINE);
 
4132   vty_out (vty, "%s", VTY_NEWLINE);
 
4136 show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
 
4138   struct route_node *rn;
 
4140   vty_out (vty, "%s                MaxAge Link States:%s%s",
 
4141            VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
 
4143   for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
 
4145       struct ospf_lsa *lsa;
 
4147       if ((lsa = rn->info) != NULL)
 
4149           vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
 
4150           vty_out (vty, "Link State ID: %s%s",
 
4151                    inet_ntoa (lsa->data->id), VTY_NEWLINE);
 
4152           vty_out (vty, "Advertising Router: %s%s",
 
4153                    inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
 
4154           vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
 
4155           vty_out (vty, "%s", VTY_NEWLINE);
 
4160 #define OSPF_LSA_TYPE_NSSA_DESC      "NSSA external link state\n"
 
4161 #define OSPF_LSA_TYPE_NSSA_CMD_STR   "|nssa-external"
 
4163 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
 
4164 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
 
4165 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC   "Link AS Opaque-LSA\n"
 
4166 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR   "|opaque-link|opaque-area|opaque-as"
 
4168 #define OSPF_LSA_TYPES_CMD_STR                                                \
 
4169     "asbr-summary|external|network|router|summary"                            \
 
4170     OSPF_LSA_TYPE_NSSA_CMD_STR                                                \
 
4171     OSPF_LSA_TYPE_OPAQUE_CMD_STR
 
4173 #define OSPF_LSA_TYPES_DESC                                                   \
 
4174    "ASBR summary link states\n"                                               \
 
4175    "External link states\n"                                                   \
 
4176    "Network link states\n"                                                    \
 
4177    "Router link states\n"                                                     \
 
4178    "Network summary link states\n"                                            \
 
4179    OSPF_LSA_TYPE_NSSA_DESC                                                    \
 
4180    OSPF_LSA_TYPE_OPAQUE_LINK_DESC                                             \
 
4181    OSPF_LSA_TYPE_OPAQUE_AREA_DESC                                             \
 
4182    OSPF_LSA_TYPE_OPAQUE_AS_DESC     
 
4184 DEFUN (show_ip_ospf_database,
 
4185        show_ip_ospf_database_cmd,
 
4186        "show ip ospf database",
 
4189        "OSPF information\n"
 
4190        "Database summary\n")
 
4194   struct in_addr id, adv_router;
 
4196   ospf = ospf_lookup ();
 
4199       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
4203   vty_out (vty, "%s       OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
 
4204            inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
 
4209       show_ip_ospf_database_summary (vty, ospf, 0);
 
4213   /* Set database type to show. */
 
4214   if (strncmp (argv[0], "r", 1) == 0)
 
4215     type = OSPF_ROUTER_LSA;
 
4216   else if (strncmp (argv[0], "ne", 2) == 0)
 
4217     type = OSPF_NETWORK_LSA;
 
4218   else if (strncmp (argv[0], "ns", 2) == 0)
 
4219     type = OSPF_AS_NSSA_LSA;
 
4220   else if (strncmp (argv[0], "su", 2) == 0)
 
4221     type = OSPF_SUMMARY_LSA;
 
4222   else if (strncmp (argv[0], "a", 1) == 0)
 
4223     type = OSPF_ASBR_SUMMARY_LSA;
 
4224   else if (strncmp (argv[0], "e", 1) == 0)
 
4225     type = OSPF_AS_EXTERNAL_LSA;
 
4226   else if (strncmp (argv[0], "se", 2) == 0)
 
4228       show_ip_ospf_database_summary (vty, ospf, 1);
 
4231   else if (strncmp (argv[0], "m", 1) == 0)
 
4233       show_ip_ospf_database_maxage (vty, ospf);
 
4236   else if (strncmp (argv[0], "opaque-l", 8) == 0)
 
4237     type = OSPF_OPAQUE_LINK_LSA;
 
4238   else if (strncmp (argv[0], "opaque-ar", 9) == 0)
 
4239     type = OSPF_OPAQUE_AREA_LSA;
 
4240   else if (strncmp (argv[0], "opaque-as", 9) == 0)
 
4241     type = OSPF_OPAQUE_AS_LSA;
 
4245   /* `show ip ospf database LSA'. */
 
4247     show_lsa_detail (vty, ospf, type, NULL, NULL);
 
4250       ret = inet_aton (argv[1], &id);
 
4254       /* `show ip ospf database LSA ID'. */
 
4256         show_lsa_detail (vty, ospf, type, &id, NULL);
 
4257       /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
 
4260           if (strncmp (argv[2], "s", 1) == 0)
 
4261             adv_router = ospf->router_id;
 
4264               ret = inet_aton (argv[2], &adv_router);
 
4268           show_lsa_detail (vty, ospf, type, &id, &adv_router);
 
4275 ALIAS (show_ip_ospf_database,
 
4276        show_ip_ospf_database_type_cmd,
 
4277        "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
 
4280        "OSPF information\n"
 
4281        "Database summary\n"
 
4283        "LSAs in MaxAge list\n"
 
4284        "Self-originated link states\n")
 
4286 ALIAS (show_ip_ospf_database,
 
4287        show_ip_ospf_database_type_id_cmd,
 
4288        "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
 
4291        "OSPF information\n"
 
4292        "Database summary\n"
 
4294        "Link State ID (as an IP address)\n")
 
4296 ALIAS (show_ip_ospf_database,
 
4297        show_ip_ospf_database_type_id_adv_router_cmd,
 
4298        "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
 
4301        "OSPF information\n"
 
4302        "Database summary\n"
 
4304        "Link State ID (as an IP address)\n"
 
4305        "Advertising Router link states\n"
 
4306        "Advertising Router (as an IP address)\n")
 
4308 ALIAS (show_ip_ospf_database,
 
4309        show_ip_ospf_database_type_id_self_cmd,
 
4310        "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
 
4313        "OSPF information\n"
 
4314        "Database summary\n"
 
4316        "Link State ID (as an IP address)\n"
 
4317        "Self-originated link states\n"
 
4320 DEFUN (show_ip_ospf_database_type_adv_router,
 
4321        show_ip_ospf_database_type_adv_router_cmd,
 
4322        "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
 
4325        "OSPF information\n"
 
4326        "Database summary\n"
 
4328        "Advertising Router link states\n"
 
4329        "Advertising Router (as an IP address)\n")
 
4333   struct in_addr adv_router;
 
4335   ospf = ospf_lookup ();
 
4338       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
4342   vty_out (vty, "%s       OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
 
4343            inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
 
4348   /* Set database type to show. */
 
4349   if (strncmp (argv[0], "r", 1) == 0)
 
4350     type = OSPF_ROUTER_LSA;
 
4351   else if (strncmp (argv[0], "ne", 2) == 0)
 
4352     type = OSPF_NETWORK_LSA;
 
4353   else if (strncmp (argv[0], "ns", 2) == 0)
 
4354     type = OSPF_AS_NSSA_LSA;
 
4355   else if (strncmp (argv[0], "s", 1) == 0)
 
4356     type = OSPF_SUMMARY_LSA;
 
4357   else if (strncmp (argv[0], "a", 1) == 0)
 
4358     type = OSPF_ASBR_SUMMARY_LSA;
 
4359   else if (strncmp (argv[0], "e", 1) == 0)
 
4360     type = OSPF_AS_EXTERNAL_LSA;
 
4361   else if (strncmp (argv[0], "opaque-l", 8) == 0)
 
4362     type = OSPF_OPAQUE_LINK_LSA;
 
4363   else if (strncmp (argv[0], "opaque-ar", 9) == 0)
 
4364     type = OSPF_OPAQUE_AREA_LSA;
 
4365   else if (strncmp (argv[0], "opaque-as", 9) == 0)
 
4366     type = OSPF_OPAQUE_AS_LSA;
 
4370   /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
 
4371   if (strncmp (argv[1], "s", 1) == 0)
 
4372     adv_router = ospf->router_id;
 
4375       ret = inet_aton (argv[1], &adv_router);
 
4380   show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
 
4385 ALIAS (show_ip_ospf_database_type_adv_router,
 
4386        show_ip_ospf_database_type_self_cmd,
 
4387        "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
 
4390        "OSPF information\n"
 
4391        "Database summary\n"
 
4393        "Self-originated link states\n")
 
4396 DEFUN (ip_ospf_authentication_args,
 
4397        ip_ospf_authentication_args_addr_cmd,
 
4398        "ip ospf authentication (null|message-digest) A.B.C.D",
 
4400        "OSPF interface commands\n"
 
4401        "Enable authentication on this interface\n"
 
4402        "Use null authentication\n"
 
4403        "Use message-digest authentication\n"
 
4404        "Address of interface")
 
4406   struct interface *ifp;
 
4407   struct in_addr addr;
 
4409   struct ospf_if_params *params;
 
4412   params = IF_DEF_PARAMS (ifp);
 
4416       ret = inet_aton(argv[1], &addr);
 
4419           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
4424       params = ospf_get_if_params (ifp, addr);
 
4425       ospf_if_update_params (ifp, addr);
 
4428   /* Handle null authentication */
 
4429   if ( argv[0][0] == 'n' )
 
4431       SET_IF_PARAM (params, auth_type);
 
4432       params->auth_type = OSPF_AUTH_NULL;
 
4436   /* Handle message-digest authentication */
 
4437   if ( argv[0][0] == 'm' )
 
4439       SET_IF_PARAM (params, auth_type);
 
4440       params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
 
4444   vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
 
4448 ALIAS (ip_ospf_authentication_args,
 
4449        ip_ospf_authentication_args_cmd,
 
4450        "ip ospf authentication (null|message-digest)",
 
4452        "OSPF interface commands\n"
 
4453        "Enable authentication on this interface\n"
 
4454        "Use null authentication\n"
 
4455        "Use message-digest authentication\n")
 
4457 DEFUN (ip_ospf_authentication,
 
4458        ip_ospf_authentication_addr_cmd,
 
4459        "ip ospf authentication A.B.C.D",
 
4461        "OSPF interface commands\n"
 
4462        "Enable authentication on this interface\n"
 
4463        "Address of interface")
 
4465   struct interface *ifp;
 
4466   struct in_addr addr;
 
4468   struct ospf_if_params *params;
 
4471   params = IF_DEF_PARAMS (ifp);
 
4475       ret = inet_aton(argv[0], &addr);
 
4478           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
4483       params = ospf_get_if_params (ifp, addr);
 
4484       ospf_if_update_params (ifp, addr);
 
4487   SET_IF_PARAM (params, auth_type);
 
4488   params->auth_type = OSPF_AUTH_SIMPLE;
 
4493 ALIAS (ip_ospf_authentication,
 
4494        ip_ospf_authentication_cmd,
 
4495        "ip ospf authentication",
 
4497        "OSPF interface commands\n"
 
4498        "Enable authentication on this interface\n")
 
4500 DEFUN (no_ip_ospf_authentication,
 
4501        no_ip_ospf_authentication_addr_cmd,
 
4502        "no ip ospf authentication A.B.C.D",
 
4505        "OSPF interface commands\n"
 
4506        "Enable authentication on this interface\n"
 
4507        "Address of interface")
 
4509   struct interface *ifp;
 
4510   struct in_addr addr;
 
4512   struct ospf_if_params *params;
 
4515   params = IF_DEF_PARAMS (ifp);
 
4519       ret = inet_aton(argv[0], &addr);
 
4522           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
4527       params = ospf_lookup_if_params (ifp, addr);
 
4532   params->auth_type = OSPF_AUTH_NOTSET;
 
4533   UNSET_IF_PARAM (params, auth_type);
 
4535   if (params != IF_DEF_PARAMS (ifp))
 
4537       ospf_free_if_params (ifp, addr);
 
4538       ospf_if_update_params (ifp, addr);
 
4544 ALIAS (no_ip_ospf_authentication,
 
4545        no_ip_ospf_authentication_cmd,
 
4546        "no ip ospf authentication",
 
4549        "OSPF interface commands\n"
 
4550        "Enable authentication on this interface\n")
 
4552 DEFUN (ip_ospf_authentication_key,
 
4553        ip_ospf_authentication_key_addr_cmd,
 
4554        "ip ospf authentication-key AUTH_KEY A.B.C.D",
 
4556        "OSPF interface commands\n"
 
4557        "Authentication password (key)\n"
 
4558        "The OSPF password (key)\n"
 
4559        "Address of interface")
 
4561   struct interface *ifp;
 
4562   struct in_addr addr;
 
4564   struct ospf_if_params *params;
 
4567   params = IF_DEF_PARAMS (ifp);
 
4571       ret = inet_aton(argv[1], &addr);
 
4574           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
4579       params = ospf_get_if_params (ifp, addr);
 
4580       ospf_if_update_params (ifp, addr);
 
4584   memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
 
4585   strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
 
4586   SET_IF_PARAM (params, auth_simple);
 
4591 ALIAS (ip_ospf_authentication_key,
 
4592        ip_ospf_authentication_key_cmd,
 
4593        "ip ospf authentication-key AUTH_KEY",
 
4595        "OSPF interface commands\n"
 
4596        "Authentication password (key)\n"
 
4597        "The OSPF password (key)")
 
4599 ALIAS (ip_ospf_authentication_key,
 
4600        ospf_authentication_key_cmd,
 
4601        "ospf authentication-key AUTH_KEY",
 
4602        "OSPF interface commands\n"
 
4603        "Authentication password (key)\n"
 
4604        "The OSPF password (key)")
 
4606 DEFUN (no_ip_ospf_authentication_key,
 
4607        no_ip_ospf_authentication_key_addr_cmd,
 
4608        "no ip ospf authentication-key A.B.C.D",
 
4611        "OSPF interface commands\n"
 
4612        "Authentication password (key)\n"
 
4613        "Address of interface")
 
4615   struct interface *ifp;
 
4616   struct in_addr addr;
 
4618   struct ospf_if_params *params;
 
4621   params = IF_DEF_PARAMS (ifp);
 
4625       ret = inet_aton(argv[0], &addr);
 
4628           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
4633       params = ospf_lookup_if_params (ifp, addr);
 
4638   memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
 
4639   UNSET_IF_PARAM (params, auth_simple);
 
4641   if (params != IF_DEF_PARAMS (ifp))
 
4643       ospf_free_if_params (ifp, addr);
 
4644       ospf_if_update_params (ifp, addr);
 
4650 ALIAS (no_ip_ospf_authentication_key,
 
4651        no_ip_ospf_authentication_key_cmd,
 
4652        "no ip ospf authentication-key",
 
4655        "OSPF interface commands\n"
 
4656        "Authentication password (key)\n")
 
4658 ALIAS (no_ip_ospf_authentication_key,
 
4659        no_ospf_authentication_key_cmd,
 
4660        "no ospf authentication-key",
 
4662        "OSPF interface commands\n"
 
4663        "Authentication password (key)\n")
 
4665 DEFUN (ip_ospf_message_digest_key,
 
4666        ip_ospf_message_digest_key_addr_cmd,
 
4667        "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
 
4669        "OSPF interface commands\n"
 
4670        "Message digest authentication password (key)\n"
 
4672        "Use MD5 algorithm\n"
 
4673        "The OSPF password (key)"
 
4674        "Address of interface")
 
4676   struct interface *ifp;
 
4677   struct crypt_key *ck;
 
4679   struct in_addr addr;
 
4681   struct ospf_if_params *params;
 
4684   params = IF_DEF_PARAMS (ifp);
 
4688       ret = inet_aton(argv[2], &addr);
 
4691           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
4696       params = ospf_get_if_params (ifp, addr);
 
4697       ospf_if_update_params (ifp, addr);
 
4700   key_id = strtol (argv[0], NULL, 10);
 
4701   if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
 
4703       vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
 
4707   ck = ospf_crypt_key_new ();
 
4708   ck->key_id = (u_char) key_id;
 
4709   memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
 
4710   strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
 
4712   ospf_crypt_key_add (params->auth_crypt, ck);
 
4713   SET_IF_PARAM (params, auth_crypt);
 
4718 ALIAS (ip_ospf_message_digest_key,
 
4719        ip_ospf_message_digest_key_cmd,
 
4720        "ip ospf message-digest-key <1-255> md5 KEY",
 
4722        "OSPF interface commands\n"
 
4723        "Message digest authentication password (key)\n"
 
4725        "Use MD5 algorithm\n"
 
4726        "The OSPF password (key)")
 
4728 ALIAS (ip_ospf_message_digest_key,
 
4729        ospf_message_digest_key_cmd,
 
4730        "ospf message-digest-key <1-255> md5 KEY",
 
4731        "OSPF interface commands\n"
 
4732        "Message digest authentication password (key)\n"
 
4734        "Use MD5 algorithm\n"
 
4735        "The OSPF password (key)")
 
4737 DEFUN (no_ip_ospf_message_digest_key,
 
4738        no_ip_ospf_message_digest_key_addr_cmd,
 
4739        "no ip ospf message-digest-key <1-255> A.B.C.D",
 
4742        "OSPF interface commands\n"
 
4743        "Message digest authentication password (key)\n"
 
4745        "Address of interface")
 
4747   struct interface *ifp;
 
4748   struct crypt_key *ck;
 
4750   struct in_addr addr;
 
4752   struct ospf_if_params *params;
 
4755   params = IF_DEF_PARAMS (ifp);
 
4759       ret = inet_aton(argv[1], &addr);
 
4762           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
4767       params = ospf_lookup_if_params (ifp, addr);
 
4772   key_id = strtol (argv[0], NULL, 10);
 
4773   ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
 
4776       vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
 
4780   ospf_crypt_key_delete (params->auth_crypt, key_id);
 
4782   if (params != IF_DEF_PARAMS (ifp))
 
4784       ospf_free_if_params (ifp, addr);
 
4785       ospf_if_update_params (ifp, addr);
 
4791 ALIAS (no_ip_ospf_message_digest_key,
 
4792        no_ip_ospf_message_digest_key_cmd,
 
4793        "no ip ospf message-digest-key <1-255>",
 
4796        "OSPF interface commands\n"
 
4797        "Message digest authentication password (key)\n"
 
4800 ALIAS (no_ip_ospf_message_digest_key,
 
4801        no_ospf_message_digest_key_cmd,
 
4802        "no ospf message-digest-key <1-255>",
 
4804        "OSPF interface commands\n"
 
4805        "Message digest authentication password (key)\n"
 
4808 DEFUN (ip_ospf_cost,
 
4809        ip_ospf_cost_u32_inet4_cmd,
 
4810        "ip ospf cost <1-65535> A.B.C.D",
 
4812        "OSPF interface commands\n"
 
4815        "Address of interface")
 
4817   struct interface *ifp = vty->index;
 
4819   struct in_addr addr;
 
4821   struct ospf_if_params *params;
 
4823   params = IF_DEF_PARAMS (ifp);
 
4825   cost = strtol (argv[0], NULL, 10);
 
4827   /* cost range is <1-65535>. */
 
4828   if (cost < 1 || cost > 65535)
 
4830       vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
 
4836       ret = inet_aton(argv[1], &addr);
 
4839           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
4844       params = ospf_get_if_params (ifp, addr);
 
4845       ospf_if_update_params (ifp, addr);
 
4848   SET_IF_PARAM (params, output_cost_cmd);
 
4849   params->output_cost_cmd = cost;
 
4851   ospf_if_recalculate_output_cost (ifp);
 
4856 ALIAS (ip_ospf_cost,
 
4857        ip_ospf_cost_u32_cmd,
 
4858        "ip ospf cost <1-65535>",
 
4860        "OSPF interface commands\n"
 
4864 ALIAS (ip_ospf_cost,
 
4866        "ospf cost <1-65535>",
 
4867        "OSPF interface commands\n"
 
4871 ALIAS (ip_ospf_cost,
 
4872        ospf_cost_u32_inet4_cmd,
 
4873        "ospf cost <1-65535> A.B.C.D",
 
4874        "OSPF interface commands\n"
 
4877        "Address of interface")
 
4879 DEFUN (no_ip_ospf_cost,
 
4880        no_ip_ospf_cost_inet4_cmd,
 
4881        "no ip ospf cost A.B.C.D",
 
4884        "OSPF interface commands\n"
 
4886        "Address of interface")
 
4888   struct interface *ifp = vty->index;
 
4889   struct in_addr addr;
 
4891   struct ospf_if_params *params;
 
4894   params = IF_DEF_PARAMS (ifp);
 
4898       ret = inet_aton(argv[0], &addr);
 
4901           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
4906       params = ospf_lookup_if_params (ifp, addr);
 
4911   UNSET_IF_PARAM (params, output_cost_cmd);
 
4913   if (params != IF_DEF_PARAMS (ifp))
 
4915       ospf_free_if_params (ifp, addr);
 
4916       ospf_if_update_params (ifp, addr);
 
4919   ospf_if_recalculate_output_cost (ifp);
 
4924 ALIAS (no_ip_ospf_cost,
 
4925        no_ip_ospf_cost_cmd,
 
4929        "OSPF interface commands\n"
 
4932 ALIAS (no_ip_ospf_cost,
 
4936        "OSPF interface commands\n"
 
4939 ALIAS (no_ip_ospf_cost,
 
4940        no_ospf_cost_inet4_cmd,
 
4941        "no ospf cost A.B.C.D",
 
4943        "OSPF interface commands\n"
 
4945        "Address of interface")
 
4947 DEFUN (no_ip_ospf_cost2,
 
4948        no_ip_ospf_cost_u32_cmd,
 
4949        "no ip ospf cost <1-65535>",
 
4952        "OSPF interface commands\n"
 
4956   struct interface *ifp = vty->index;
 
4957   struct in_addr addr;
 
4960   struct ospf_if_params *params;
 
4963   params = IF_DEF_PARAMS (ifp);
 
4965   /* According to the semantics we are mimicking "no ip ospf cost N" is
 
4966    * always treated as "no ip ospf cost" regardless of the actual value
 
4967    * of N already configured for the interface. Thus the first argument
 
4968    * is always checked to be a number, but is ignored after that.
 
4970   cost = strtol (argv[0], NULL, 10);
 
4971   if (cost < 1 || cost > 65535)
 
4973       vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
 
4979       ret = inet_aton(argv[1], &addr);
 
4982           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
4987       params = ospf_lookup_if_params (ifp, addr);
 
4992   UNSET_IF_PARAM (params, output_cost_cmd);
 
4994   if (params != IF_DEF_PARAMS (ifp))
 
4996       ospf_free_if_params (ifp, addr);
 
4997       ospf_if_update_params (ifp, addr);
 
5000   ospf_if_recalculate_output_cost (ifp);
 
5005 ALIAS (no_ip_ospf_cost2,
 
5006        no_ospf_cost_u32_cmd,
 
5007        "no ospf cost <1-65535>",
 
5009        "OSPF interface commands\n"
 
5013 ALIAS (no_ip_ospf_cost2,
 
5014        no_ip_ospf_cost_u32_inet4_cmd,
 
5015        "no ip ospf cost <1-65535> A.B.C.D",
 
5018        "OSPF interface commands\n"
 
5021        "Address of interface")
 
5023 ALIAS (no_ip_ospf_cost2,
 
5024        no_ospf_cost_u32_inet4_cmd,
 
5025        "no ospf cost <1-65535> A.B.C.D",
 
5027        "OSPF interface commands\n"
 
5030        "Address of interface")
 
5033 ospf_nbr_timer_update (struct ospf_interface *oi)
 
5035   struct route_node *rn;
 
5036   struct ospf_neighbor *nbr;
 
5038   for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
 
5039     if ((nbr = rn->info))
 
5041         nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
 
5042         nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
 
5043         nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
 
5044         nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
 
5049 ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
 
5050                             const char *nbr_str,
 
5051                             const char *fast_hello_str)
 
5053   struct interface *ifp = vty->index;
 
5056   struct in_addr addr;
 
5058   struct ospf_if_params *params;
 
5059   struct ospf_interface *oi;
 
5060   struct route_node *rn;
 
5062   params = IF_DEF_PARAMS (ifp);
 
5066       ret = inet_aton(nbr_str, &addr);
 
5069           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
5074       params = ospf_get_if_params (ifp, addr);
 
5075       ospf_if_update_params (ifp, addr);
 
5080       VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
 
5083       /* reset fast_hello too, just to be sure */
 
5084       UNSET_IF_PARAM (params, fast_hello);
 
5085       params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
 
5087   else if (fast_hello_str)
 
5089       VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
 
5091       /* 1s dead-interval with sub-second hellos desired */
 
5092       seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
 
5093       SET_IF_PARAM (params, fast_hello);
 
5094       params->fast_hello = hellomult;
 
5098       vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
 
5103   SET_IF_PARAM (params, v_wait);
 
5104   params->v_wait = seconds;
 
5106   /* Update timer values in neighbor structure. */
 
5110       if ((ospf = ospf_lookup()))
 
5112           oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
 
5114             ospf_nbr_timer_update (oi);
 
5119       for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
 
5120         if ((oi = rn->info))
 
5121           ospf_nbr_timer_update (oi);
 
5128 DEFUN (ip_ospf_dead_interval,
 
5129        ip_ospf_dead_interval_addr_cmd,
 
5130        "ip ospf dead-interval <1-65535> A.B.C.D",
 
5132        "OSPF interface commands\n"
 
5133        "Interval after which a neighbor is declared dead\n"
 
5135        "Address of interface\n")
 
5138     return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
 
5140     return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
 
5143 ALIAS (ip_ospf_dead_interval,
 
5144        ip_ospf_dead_interval_cmd,
 
5145        "ip ospf dead-interval <1-65535>",
 
5147        "OSPF interface commands\n"
 
5148        "Interval after which a neighbor is declared dead\n"
 
5151 ALIAS (ip_ospf_dead_interval,
 
5152        ospf_dead_interval_cmd,
 
5153        "ospf dead-interval <1-65535>",
 
5154        "OSPF interface commands\n"
 
5155        "Interval after which a neighbor is declared dead\n"
 
5158 DEFUN (ip_ospf_dead_interval_minimal,
 
5159        ip_ospf_dead_interval_minimal_addr_cmd,
 
5160        "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
 
5162        "OSPF interface commands\n"
 
5163        "Interval after which a neighbor is declared dead\n"
 
5164        "Minimal 1s dead-interval with fast sub-second hellos\n"
 
5165        "Hello multiplier factor\n"
 
5166        "Number of Hellos to send each second\n"
 
5167        "Address of interface\n")
 
5170     return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
 
5172     return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
 
5175 ALIAS (ip_ospf_dead_interval_minimal,
 
5176        ip_ospf_dead_interval_minimal_cmd,
 
5177        "ip ospf dead-interval minimal hello-multiplier <1-10>",
 
5179        "OSPF interface commands\n"
 
5180        "Interval after which a neighbor is declared dead\n"
 
5181        "Minimal 1s dead-interval with fast sub-second hellos\n"
 
5182        "Hello multiplier factor\n"
 
5183        "Number of Hellos to send each second\n")
 
5185 DEFUN (no_ip_ospf_dead_interval,
 
5186        no_ip_ospf_dead_interval_addr_cmd,
 
5187        "no ip ospf dead-interval <1-65535> A.B.C.D",
 
5190        "OSPF interface commands\n"
 
5191        "Interval after which a neighbor is declared dead\n"
 
5193        "Address of interface")
 
5195   struct interface *ifp = vty->index;
 
5196   struct in_addr addr;
 
5198   struct ospf_if_params *params;
 
5199   struct ospf_interface *oi;
 
5200   struct route_node *rn;
 
5203   params = IF_DEF_PARAMS (ifp);
 
5207       ret = inet_aton(argv[1], &addr);
 
5210           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
5215       params = ospf_lookup_if_params (ifp, addr);
 
5220   UNSET_IF_PARAM (params, v_wait);
 
5221   params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
 
5223   UNSET_IF_PARAM (params, fast_hello);
 
5224   params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
 
5226   if (params != IF_DEF_PARAMS (ifp))
 
5228       ospf_free_if_params (ifp, addr);
 
5229       ospf_if_update_params (ifp, addr);
 
5232   /* Update timer values in neighbor structure. */
 
5237       if ((ospf = ospf_lookup()))
 
5239           oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
 
5241             ospf_nbr_timer_update (oi);
 
5246       for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
 
5247         if ((oi = rn->info))
 
5248           ospf_nbr_timer_update (oi);
 
5254 ALIAS (no_ip_ospf_dead_interval,
 
5255        no_ip_ospf_dead_interval_seconds_cmd,
 
5256        "no ip ospf dead-interval <1-65535>",
 
5259        "OSPF interface commands\n"
 
5260        "Interval after which a neighbor is declared dead\n"
 
5263 ALIAS (no_ip_ospf_dead_interval,
 
5264        no_ip_ospf_dead_interval_cmd,
 
5265        "no ip ospf dead-interval",
 
5268        "OSPF interface commands\n"
 
5269        "Interval after which a neighbor is declared dead\n")
 
5271 ALIAS (no_ip_ospf_dead_interval,
 
5272        no_ospf_dead_interval_cmd,
 
5273        "no ospf dead-interval",
 
5275        "OSPF interface commands\n"
 
5276        "Interval after which a neighbor is declared dead\n")
 
5278 DEFUN (ip_ospf_hello_interval,
 
5279        ip_ospf_hello_interval_addr_cmd,
 
5280        "ip ospf hello-interval <1-65535> A.B.C.D",
 
5282        "OSPF interface commands\n"
 
5283        "Time between HELLO packets\n"
 
5285        "Address of interface")
 
5287   struct interface *ifp = vty->index;
 
5289   struct in_addr addr;
 
5291   struct ospf_if_params *params;
 
5293   params = IF_DEF_PARAMS (ifp);
 
5295   seconds = strtol (argv[0], NULL, 10);
 
5297   /* HelloInterval range is <1-65535>. */
 
5298   if (seconds < 1 || seconds > 65535)
 
5300       vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
 
5306       ret = inet_aton(argv[1], &addr);
 
5309           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
5314       params = ospf_get_if_params (ifp, addr);
 
5315       ospf_if_update_params (ifp, addr);
 
5318   SET_IF_PARAM (params, v_hello);
 
5319   params->v_hello = seconds;
 
5324 ALIAS (ip_ospf_hello_interval,
 
5325        ip_ospf_hello_interval_cmd,
 
5326        "ip ospf hello-interval <1-65535>",
 
5328        "OSPF interface commands\n"
 
5329        "Time between HELLO packets\n"
 
5332 ALIAS (ip_ospf_hello_interval,
 
5333        ospf_hello_interval_cmd,
 
5334        "ospf hello-interval <1-65535>",
 
5335        "OSPF interface commands\n"
 
5336        "Time between HELLO packets\n"
 
5339 DEFUN (no_ip_ospf_hello_interval,
 
5340        no_ip_ospf_hello_interval_addr_cmd,
 
5341        "no ip ospf hello-interval <1-65535> A.B.C.D",
 
5344        "OSPF interface commands\n"
 
5345        "Time between HELLO packets\n"
 
5347        "Address of interface")
 
5349   struct interface *ifp = vty->index;
 
5350   struct in_addr addr;
 
5352   struct ospf_if_params *params;
 
5355   params = IF_DEF_PARAMS (ifp);
 
5359       ret = inet_aton(argv[1], &addr);
 
5362           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
5367       params = ospf_lookup_if_params (ifp, addr);
 
5372   UNSET_IF_PARAM (params, v_hello);
 
5373   params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
 
5375   if (params != IF_DEF_PARAMS (ifp))
 
5377       ospf_free_if_params (ifp, addr);
 
5378       ospf_if_update_params (ifp, addr);
 
5384 ALIAS (no_ip_ospf_hello_interval,
 
5385        no_ip_ospf_hello_interval_seconds_cmd,
 
5386        "no ip ospf hello-interval <1-65535>",
 
5389        "OSPF interface commands\n"
 
5390        "Time between HELLO packets\n"
 
5393 ALIAS (no_ip_ospf_hello_interval,
 
5394        no_ip_ospf_hello_interval_cmd,
 
5395        "no ip ospf hello-interval",
 
5398        "OSPF interface commands\n"
 
5399        "Time between HELLO packets\n")
 
5401 ALIAS (no_ip_ospf_hello_interval,
 
5402        no_ospf_hello_interval_cmd,
 
5403        "no ospf hello-interval",
 
5405        "OSPF interface commands\n"
 
5406        "Time between HELLO packets\n")
 
5408 DEFUN (ip_ospf_network,
 
5409        ip_ospf_network_cmd,
 
5410        "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
 
5412        "OSPF interface commands\n"
 
5414        "Specify OSPF broadcast multi-access network\n"
 
5415        "Specify OSPF NBMA network\n"
 
5416        "Specify OSPF point-to-multipoint network\n"
 
5417        "Specify OSPF point-to-point network\n")
 
5419   struct interface *ifp = vty->index;
 
5420   int old_type = IF_DEF_PARAMS (ifp)->type;
 
5422   if (old_type == OSPF_IFTYPE_LOOPBACK)
 
5424       vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE);
 
5428   if (strncmp (argv[0], "b", 1) == 0)
 
5429     IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
 
5430   else if (strncmp (argv[0], "n", 1) == 0)
 
5431     IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
 
5432   else if (strncmp (argv[0], "point-to-m", 10) == 0)
 
5433     IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
 
5434   else if (strncmp (argv[0], "point-to-p", 10) == 0)
 
5435     IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
 
5437   if (IF_DEF_PARAMS (ifp)->type == old_type)
 
5440   SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
 
5441   ospf_if_reset_type (ifp, IF_DEF_PARAMS (ifp)->type);
 
5445 ALIAS (ip_ospf_network,
 
5447        "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
 
5448        "OSPF interface commands\n"
 
5450        "Specify OSPF broadcast multi-access network\n"
 
5451        "Specify OSPF NBMA network\n"
 
5452        "Specify OSPF point-to-multipoint network\n"
 
5453        "Specify OSPF point-to-point network\n")
 
5455 DEFUN (no_ip_ospf_network,
 
5456        no_ip_ospf_network_cmd,
 
5457        "no ip ospf network",
 
5460        "OSPF interface commands\n"
 
5463   struct interface *ifp = vty->index;
 
5464   int old_type = IF_DEF_PARAMS (ifp)->type;
 
5466   IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
 
5468   if (IF_DEF_PARAMS (ifp)->type == old_type)
 
5471   ospf_if_reset_type (ifp, IF_DEF_PARAMS (ifp)->type);
 
5476 ALIAS (no_ip_ospf_network,
 
5477        no_ospf_network_cmd,
 
5480        "OSPF interface commands\n"
 
5483 DEFUN (ip_ospf_priority,
 
5484        ip_ospf_priority_addr_cmd,
 
5485        "ip ospf priority <0-255> A.B.C.D",
 
5487        "OSPF interface commands\n"
 
5490        "Address of interface")
 
5492   struct interface *ifp = vty->index;
 
5494   struct route_node *rn;
 
5495   struct in_addr addr;
 
5497   struct ospf_if_params *params;
 
5499   params = IF_DEF_PARAMS (ifp);
 
5501   priority = strtol (argv[0], NULL, 10);
 
5503   /* Router Priority range is <0-255>. */
 
5504   if (priority < 0 || priority > 255)
 
5506       vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
 
5512       ret = inet_aton(argv[1], &addr);
 
5515           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
5520       params = ospf_get_if_params (ifp, addr);
 
5521       ospf_if_update_params (ifp, addr);
 
5524   SET_IF_PARAM (params, priority);
 
5525   params->priority = priority;
 
5527   for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
 
5529       struct ospf_interface *oi = rn->info;
 
5535       if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
 
5537           PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
 
5538           OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
 
5545 ALIAS (ip_ospf_priority,
 
5546        ip_ospf_priority_cmd,
 
5547        "ip ospf priority <0-255>",
 
5549        "OSPF interface commands\n"
 
5553 ALIAS (ip_ospf_priority,
 
5555        "ospf priority <0-255>",
 
5556        "OSPF interface commands\n"
 
5560 DEFUN (no_ip_ospf_priority,
 
5561        no_ip_ospf_priority_addr_cmd,
 
5562        "no ip ospf priority A.B.C.D",
 
5565        "OSPF interface commands\n"
 
5567        "Address of interface")
 
5569   struct interface *ifp = vty->index;
 
5570   struct route_node *rn;
 
5571   struct in_addr addr;
 
5573   struct ospf_if_params *params;
 
5576   params = IF_DEF_PARAMS (ifp);
 
5580       ret = inet_aton(argv[0], &addr);
 
5583           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
5588       params = ospf_lookup_if_params (ifp, addr);
 
5593   UNSET_IF_PARAM (params, priority);
 
5594   params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
 
5596   if (params != IF_DEF_PARAMS (ifp))
 
5598       ospf_free_if_params (ifp, addr);
 
5599       ospf_if_update_params (ifp, addr);
 
5602   for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
 
5604       struct ospf_interface *oi = rn->info;
 
5610       if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
 
5612           PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
 
5613           OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
 
5620 ALIAS (no_ip_ospf_priority,
 
5621        no_ip_ospf_priority_cmd,
 
5622        "no ip ospf priority",
 
5625        "OSPF interface commands\n"
 
5626        "Router priority\n")
 
5628 ALIAS (no_ip_ospf_priority,
 
5629        no_ospf_priority_cmd,
 
5632        "OSPF interface commands\n"
 
5633        "Router priority\n")
 
5635 DEFUN (ip_ospf_retransmit_interval,
 
5636        ip_ospf_retransmit_interval_addr_cmd,
 
5637        "ip ospf retransmit-interval <3-65535> A.B.C.D",
 
5639        "OSPF interface commands\n"
 
5640        "Time between retransmitting lost link state advertisements\n"
 
5642        "Address of interface")
 
5644   struct interface *ifp = vty->index;
 
5646   struct in_addr addr;
 
5648   struct ospf_if_params *params;
 
5650   params = IF_DEF_PARAMS (ifp);
 
5651   seconds = strtol (argv[0], NULL, 10);
 
5653   /* Retransmit Interval range is <3-65535>. */
 
5654   if (seconds < 3 || seconds > 65535)
 
5656       vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
 
5663       ret = inet_aton(argv[1], &addr);
 
5666           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
5671       params = ospf_get_if_params (ifp, addr);
 
5672       ospf_if_update_params (ifp, addr);
 
5675   SET_IF_PARAM (params, retransmit_interval);
 
5676   params->retransmit_interval = seconds;
 
5681 ALIAS (ip_ospf_retransmit_interval,
 
5682        ip_ospf_retransmit_interval_cmd,
 
5683        "ip ospf retransmit-interval <3-65535>",
 
5685        "OSPF interface commands\n"
 
5686        "Time between retransmitting lost link state advertisements\n"
 
5689 ALIAS (ip_ospf_retransmit_interval,
 
5690        ospf_retransmit_interval_cmd,
 
5691        "ospf retransmit-interval <3-65535>",
 
5692        "OSPF interface commands\n"
 
5693        "Time between retransmitting lost link state advertisements\n"
 
5696 DEFUN (no_ip_ospf_retransmit_interval,
 
5697        no_ip_ospf_retransmit_interval_addr_cmd,
 
5698        "no ip ospf retransmit-interval A.B.C.D",
 
5701        "OSPF interface commands\n"
 
5702        "Time between retransmitting lost link state advertisements\n"
 
5703        "Address of interface")
 
5705   struct interface *ifp = vty->index;
 
5706   struct in_addr addr;
 
5708   struct ospf_if_params *params;
 
5711   params = IF_DEF_PARAMS (ifp);
 
5715       ret = inet_aton(argv[0], &addr);
 
5718           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
5723       params = ospf_lookup_if_params (ifp, addr);
 
5728   UNSET_IF_PARAM (params, retransmit_interval);
 
5729   params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
 
5731   if (params != IF_DEF_PARAMS (ifp))
 
5733       ospf_free_if_params (ifp, addr);
 
5734       ospf_if_update_params (ifp, addr);
 
5740 ALIAS (no_ip_ospf_retransmit_interval,
 
5741        no_ip_ospf_retransmit_interval_cmd,
 
5742        "no ip ospf retransmit-interval",
 
5745        "OSPF interface commands\n"
 
5746        "Time between retransmitting lost link state advertisements\n")
 
5748 ALIAS (no_ip_ospf_retransmit_interval,
 
5749        no_ospf_retransmit_interval_cmd,
 
5750        "no ospf retransmit-interval",
 
5752        "OSPF interface commands\n"
 
5753        "Time between retransmitting lost link state advertisements\n")
 
5755 DEFUN (ip_ospf_transmit_delay,
 
5756        ip_ospf_transmit_delay_addr_cmd,
 
5757        "ip ospf transmit-delay <1-65535> A.B.C.D",
 
5759        "OSPF interface commands\n"
 
5760        "Link state transmit delay\n"
 
5762        "Address of interface")
 
5764   struct interface *ifp = vty->index;
 
5766   struct in_addr addr;
 
5768   struct ospf_if_params *params;
 
5770   params = IF_DEF_PARAMS (ifp);
 
5771   seconds = strtol (argv[0], NULL, 10);
 
5773   /* Transmit Delay range is <1-65535>. */
 
5774   if (seconds < 1 || seconds > 65535)
 
5776       vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
 
5782       ret = inet_aton(argv[1], &addr);
 
5785           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
5790       params = ospf_get_if_params (ifp, addr);
 
5791       ospf_if_update_params (ifp, addr);
 
5794   SET_IF_PARAM (params, transmit_delay); 
 
5795   params->transmit_delay = seconds;
 
5800 ALIAS (ip_ospf_transmit_delay,
 
5801        ip_ospf_transmit_delay_cmd,
 
5802        "ip ospf transmit-delay <1-65535>",
 
5804        "OSPF interface commands\n"
 
5805        "Link state transmit delay\n"
 
5808 ALIAS (ip_ospf_transmit_delay,
 
5809        ospf_transmit_delay_cmd,
 
5810        "ospf transmit-delay <1-65535>",
 
5811        "OSPF interface commands\n"
 
5812        "Link state transmit delay\n"
 
5815 DEFUN (no_ip_ospf_transmit_delay,
 
5816        no_ip_ospf_transmit_delay_addr_cmd,
 
5817        "no ip ospf transmit-delay A.B.C.D",
 
5820        "OSPF interface commands\n"
 
5821        "Link state transmit delay\n"
 
5822        "Address of interface")
 
5824   struct interface *ifp = vty->index;
 
5825   struct in_addr addr;
 
5827   struct ospf_if_params *params;
 
5830   params = IF_DEF_PARAMS (ifp);
 
5834       ret = inet_aton(argv[0], &addr);
 
5837           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
5842       params = ospf_lookup_if_params (ifp, addr);
 
5847   UNSET_IF_PARAM (params, transmit_delay);
 
5848   params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
 
5850   if (params != IF_DEF_PARAMS (ifp))
 
5852       ospf_free_if_params (ifp, addr);
 
5853       ospf_if_update_params (ifp, addr);
 
5859 ALIAS (no_ip_ospf_transmit_delay,
 
5860        no_ip_ospf_transmit_delay_cmd,
 
5861        "no ip ospf transmit-delay",
 
5864        "OSPF interface commands\n"
 
5865        "Link state transmit delay\n")
 
5867 ALIAS (no_ip_ospf_transmit_delay,
 
5868        no_ospf_transmit_delay_cmd,
 
5869        "no ospf transmit-delay",
 
5871        "OSPF interface commands\n"
 
5872        "Link state transmit delay\n")
 
5874 DEFUN (ip_ospf_area,
 
5876        "ip ospf area (A.B.C.D|<0-4294967295>) [A.B.C.D]",
 
5878        "OSPF interface commands\n"
 
5879        "Enable OSPF on this interface\n"
 
5880        "OSPF area ID in IP address format\n"
 
5881        "OSPF area ID as a decimal value\n"
 
5882        "Address of interface\n")
 
5884   struct interface *ifp = vty->index;
 
5885   struct in_addr area_id;
 
5886   struct in_addr addr;
 
5888   struct ospf_if_params *params;
 
5890   VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
 
5892   OSPF_VTY_GET_IF_PARAMS(ifp, params, 1, addr, VTY_SET);
 
5894   if (OSPF_IF_PARAM_CONFIGURED(params, if_area))
 
5896       vty_out (vty, "There is already an interface area statement.%s",
 
5900   if (memcmp (ifp->name, "VLINK", 5) == 0)
 
5902       vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE);
 
5906   SET_IF_PARAM (params, if_area);
 
5907   params->if_area = area_id;
 
5908   ospf_interface_area_set (ifp);
 
5913 DEFUN (no_ip_ospf_area,
 
5914        no_ip_ospf_area_cmd,
 
5915        "no ip ospf area [A.B.C.D]",
 
5918        "OSPF interface commands\n"
 
5919        "Disable OSPF on this interface\n"
 
5920        "Address of interface\n")
 
5922   struct interface *ifp = vty->index;
 
5923   struct ospf_if_params *params;
 
5924   struct in_addr addr;
 
5926   OSPF_VTY_GET_IF_PARAMS(ifp, params, 0, addr, VTY_UNSET);
 
5928   if (!OSPF_IF_PARAM_CONFIGURED(params, if_area))
 
5931   OSPF_VTY_PARAM_UNSET(params, if_area, ifp, addr);
 
5933   ospf_interface_area_unset (ifp);
 
5938 DEFUN (ospf_redistribute_source,
 
5939        ospf_redistribute_source_cmd,
 
5940        "redistribute " QUAGGA_REDIST_STR_OSPFD
 
5941          " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
 
5943        QUAGGA_REDIST_HELP_STR_OSPFD
 
5944        "Metric for redistributed routes\n"
 
5945        "OSPF default metric\n"
 
5946        "OSPF exterior metric type for redistributed routes\n"
 
5947        "Set OSPF External Type 1 metrics\n"
 
5948        "Set OSPF External Type 2 metrics\n"
 
5949        "Route map reference\n"
 
5950        "Pointer to route-map entries\n")
 
5952   struct ospf *ospf = vty->index;
 
5958     return CMD_WARNING; /* should not happen */
 
5960   /* Get distribute source. */
 
5961   source = proto_redistnum(AFI_IP, argv[0]);
 
5962   if (source < 0 || source == ZEBRA_ROUTE_OSPF)
 
5965   /* Get metric value. */
 
5966   if (argv[1] != NULL)
 
5967     if (!str2metric (argv[1], &metric))
 
5970   /* Get metric type. */
 
5971   if (argv[2] != NULL)
 
5972     if (!str2metric_type (argv[2], &type))
 
5975   if (argv[3] != NULL)
 
5976     ospf_routemap_set (ospf, source, argv[3]);
 
5978     ospf_routemap_unset (ospf, source);
 
5980   return ospf_redistribute_set (ospf, source, type, metric);
 
5983 DEFUN (no_ospf_redistribute_source,
 
5984        no_ospf_redistribute_source_cmd,
 
5985        "no redistribute " QUAGGA_REDIST_STR_OSPFD,
 
5988        QUAGGA_REDIST_HELP_STR_OSPFD)
 
5990   struct ospf *ospf = vty->index;
 
5993   source = proto_redistnum(AFI_IP, argv[0]);
 
5994   if (source < 0 || source == ZEBRA_ROUTE_OSPF)
 
5997   ospf_routemap_unset (ospf, source);
 
5998   return ospf_redistribute_unset (ospf, source);
 
6001 DEFUN (ospf_distribute_list_out,
 
6002        ospf_distribute_list_out_cmd,
 
6003        "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
 
6004        "Filter networks in routing updates\n"
 
6005        "Access-list name\n"
 
6007        QUAGGA_REDIST_HELP_STR_OSPFD)
 
6009   struct ospf *ospf = vty->index;
 
6012   /* Get distribute source. */
 
6013   source = proto_redistnum(AFI_IP, argv[1]);
 
6014   if (source < 0 || source == ZEBRA_ROUTE_OSPF)
 
6017   return ospf_distribute_list_out_set (ospf, source, argv[0]);
 
6020 DEFUN (no_ospf_distribute_list_out,
 
6021        no_ospf_distribute_list_out_cmd,
 
6022        "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
 
6024        "Filter networks in routing updates\n"
 
6025        "Access-list name\n"
 
6027        QUAGGA_REDIST_HELP_STR_OSPFD)
 
6029   struct ospf *ospf = vty->index;
 
6032   source = proto_redistnum(AFI_IP, argv[1]);
 
6033   if (source < 0 || source == ZEBRA_ROUTE_OSPF)
 
6036   return ospf_distribute_list_out_unset (ospf, source, argv[0]);
 
6039 /* Default information originate. */
 
6040 DEFUN (ospf_default_information_originate,
 
6041        ospf_default_information_originate_cmd,
 
6042        "default-information originate "
 
6043          "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
 
6044        "Control distribution of default information\n"
 
6045        "Distribute a default route\n"
 
6046        "Always advertise default route\n"
 
6047        "OSPF default metric\n"
 
6049        "OSPF metric type for default routes\n"
 
6050        "Set OSPF External Type 1 metrics\n"
 
6051        "Set OSPF External Type 2 metrics\n"
 
6052        "Route map reference\n"
 
6053        "Pointer to route-map entries\n")
 
6055   struct ospf *ospf = vty->index;
 
6056   int default_originate = DEFAULT_ORIGINATE_ZEBRA;
 
6061     return CMD_WARNING; /* this should not happen */
 
6063   /* Check whether "always" was specified */
 
6064   if (argv[0] != NULL)
 
6065     default_originate = DEFAULT_ORIGINATE_ALWAYS;
 
6067   /* Get metric value. */
 
6068   if (argv[1] != NULL)
 
6069     if (!str2metric (argv[1], &metric))
 
6072   /* Get metric type. */
 
6073   if (argv[2] != NULL)
 
6074     if (!str2metric_type (argv[2], &type))
 
6077   if (argv[3] != NULL)
 
6078     ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]);
 
6080     ospf_routemap_unset (ospf, DEFAULT_ROUTE);
 
6082   return ospf_redistribute_default_set (ospf, default_originate,
 
6086 DEFUN (no_ospf_default_information_originate,
 
6087        no_ospf_default_information_originate_cmd,
 
6088        "no default-information originate",
 
6090        "Control distribution of default information\n"
 
6091        "Distribute a default route\n")
 
6093   struct ospf *ospf = vty->index;
 
6094   struct prefix_ipv4 p;
 
6097   p.prefix.s_addr = 0;
 
6100   ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
 
6102   if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
 
6103     ospf_external_info_delete (DEFAULT_ROUTE, p);
 
6104     route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
 
6105     EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
 
6108   ospf_routemap_unset (ospf, DEFAULT_ROUTE);
 
6109   return ospf_redistribute_default_unset (ospf);
 
6112 DEFUN (ospf_default_metric,
 
6113        ospf_default_metric_cmd,
 
6114        "default-metric <0-16777214>",
 
6115        "Set metric of redistributed routes\n"
 
6118   struct ospf *ospf = vty->index;
 
6121   if (!str2metric (argv[0], &metric))
 
6124   ospf->default_metric = metric;
 
6129 DEFUN (no_ospf_default_metric,
 
6130        no_ospf_default_metric_cmd,
 
6131        "no default-metric",
 
6133        "Set metric of redistributed routes\n")
 
6135   struct ospf *ospf = vty->index;
 
6137   ospf->default_metric = -1;
 
6142 ALIAS (no_ospf_default_metric,
 
6143        no_ospf_default_metric_val_cmd,
 
6144        "no default-metric <0-16777214>",
 
6146        "Set metric of redistributed routes\n"
 
6149 DEFUN (ospf_distance,
 
6152        "Define an administrative distance\n"
 
6153        "OSPF Administrative distance\n")
 
6155   struct ospf *ospf = vty->index;
 
6157   ospf->distance_all = atoi (argv[0]);
 
6162 DEFUN (no_ospf_distance,
 
6163        no_ospf_distance_cmd,
 
6164        "no distance <1-255>",
 
6166        "Define an administrative distance\n"
 
6167        "OSPF Administrative distance\n")
 
6169   struct ospf *ospf = vty->index;
 
6171   ospf->distance_all = 0;
 
6176 DEFUN (no_ospf_distance_ospf,
 
6177        no_ospf_distance_ospf_cmd,
 
6178        "no distance ospf {intra-area|inter-area|external}",
 
6180        "Define an administrative distance\n"
 
6181        "OSPF Administrative distance\n"
 
6183        "Intra-area routes\n"
 
6184        "Inter-area routes\n"
 
6185        "External routes\n")
 
6187   struct ospf *ospf = vty->index;
 
6192   if (argv[0] != NULL)
 
6193     ospf->distance_intra = 0;
 
6195   if (argv[1] != NULL)
 
6196     ospf->distance_inter = 0;
 
6198   if (argv[2] != NULL)
 
6199     ospf->distance_external = 0;
 
6201   if (argv[0] || argv[1] || argv[2])
 
6204   /* If no arguments are given, clear all distance information */
 
6205   ospf->distance_intra = 0;
 
6206   ospf->distance_inter = 0;
 
6207   ospf->distance_external = 0;
 
6212 DEFUN (ospf_distance_ospf,
 
6213        ospf_distance_ospf_cmd,
 
6215          "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
 
6216        "Define an administrative distance\n"
 
6217        "OSPF Administrative distance\n"
 
6218        "Intra-area routes\n"
 
6219        "Distance for intra-area routes\n"
 
6220        "Inter-area routes\n"
 
6221        "Distance for inter-area routes\n"
 
6223        "Distance for external routes\n")
 
6225   struct ospf *ospf = vty->index;
 
6227   if (argc < 3) /* should not happen */
 
6230   if (!argv[0] && !argv[1] && !argv[2])
 
6232       vty_out(vty, "%% Command incomplete. (Arguments required)%s",
 
6237   if (argv[0] != NULL)
 
6238     ospf->distance_intra = atoi(argv[0]);
 
6240   if (argv[1] != NULL)
 
6241     ospf->distance_inter = atoi(argv[1]);
 
6243   if (argv[2] != NULL)
 
6244     ospf->distance_external = atoi(argv[2]);
 
6249 DEFUN (ospf_distance_source,
 
6250        ospf_distance_source_cmd,
 
6251        "distance <1-255> A.B.C.D/M",
 
6252        "Administrative distance\n"
 
6254        "IP source prefix\n")
 
6256   struct ospf *ospf = vty->index;
 
6258   ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
 
6263 DEFUN (no_ospf_distance_source,
 
6264        no_ospf_distance_source_cmd,
 
6265        "no distance <1-255> A.B.C.D/M",
 
6267        "Administrative distance\n"
 
6269        "IP source prefix\n")
 
6271   struct ospf *ospf = vty->index;
 
6273   ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
 
6278 DEFUN (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"
 
6283        "IP source prefix\n"
 
6284        "Access list name\n")
 
6286   struct ospf *ospf = vty->index;
 
6288   ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
 
6293 DEFUN (no_ospf_distance_source_access_list,
 
6294        no_ospf_distance_source_access_list_cmd,
 
6295        "no distance <1-255> A.B.C.D/M WORD",
 
6297        "Administrative distance\n"
 
6299        "IP source prefix\n"
 
6300        "Access list name\n")
 
6302   struct ospf *ospf = vty->index;
 
6304   ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
 
6309 DEFUN (ip_ospf_mtu_ignore,
 
6310        ip_ospf_mtu_ignore_addr_cmd,
 
6311        "ip ospf mtu-ignore A.B.C.D",
 
6313        "OSPF interface commands\n"
 
6314        "Disable mtu mismatch detection\n"
 
6315        "Address of interface")
 
6317   struct interface *ifp = vty->index;
 
6318   struct in_addr addr;
 
6321   struct ospf_if_params *params;
 
6322   params = IF_DEF_PARAMS (ifp);
 
6326       ret = inet_aton(argv[0], &addr);
 
6329           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
6333       params = ospf_get_if_params (ifp, addr);
 
6334       ospf_if_update_params (ifp, addr);
 
6336   params->mtu_ignore = 1;
 
6337   if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
 
6338     SET_IF_PARAM (params, mtu_ignore);
 
6341       UNSET_IF_PARAM (params, mtu_ignore);
 
6342       if (params != IF_DEF_PARAMS (ifp))
 
6344           ospf_free_if_params (ifp, addr);
 
6345           ospf_if_update_params (ifp, addr);
 
6351 ALIAS (ip_ospf_mtu_ignore,
 
6352       ip_ospf_mtu_ignore_cmd,
 
6353       "ip ospf mtu-ignore",
 
6355       "OSPF interface commands\n"
 
6356       "Disable mtu mismatch detection\n")
 
6359 DEFUN (no_ip_ospf_mtu_ignore,
 
6360        no_ip_ospf_mtu_ignore_addr_cmd,
 
6361        "no ip ospf mtu-ignore A.B.C.D",
 
6363        "OSPF interface commands\n"
 
6364        "Disable mtu mismatch detection\n"
 
6365        "Address of interface")
 
6367   struct interface *ifp = vty->index;
 
6368   struct in_addr addr;
 
6371   struct ospf_if_params *params;
 
6372   params = IF_DEF_PARAMS (ifp);
 
6376       ret = inet_aton(argv[0], &addr);
 
6379           vty_out (vty, "Please specify interface address by A.B.C.D%s",
 
6383       params = ospf_get_if_params (ifp, addr);
 
6384       ospf_if_update_params (ifp, addr);
 
6386   params->mtu_ignore = 0;
 
6387   if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
 
6388     SET_IF_PARAM (params, mtu_ignore);
 
6391       UNSET_IF_PARAM (params, mtu_ignore);
 
6392       if (params != IF_DEF_PARAMS (ifp))
 
6394           ospf_free_if_params (ifp, addr);
 
6395           ospf_if_update_params (ifp, addr);
 
6401 ALIAS (no_ip_ospf_mtu_ignore,
 
6402        no_ip_ospf_mtu_ignore_cmd,
 
6403       "no ip ospf mtu-ignore",
 
6405       "OSPF interface commands\n"
 
6406       "Disable mtu mismatch detection\n")
 
6408 DEFUN (ospf_max_metric_router_lsa_admin,
 
6409        ospf_max_metric_router_lsa_admin_cmd,
 
6410        "max-metric router-lsa administrative",
 
6411        "OSPF maximum / infinite-distance metric\n"
 
6412        "Advertise own Router-LSA with infinite distance (stub router)\n"
 
6413        "Administratively applied, for an indefinite period\n")
 
6415   struct listnode *ln;
 
6416   struct ospf_area *area;
 
6417   struct ospf *ospf = vty->index;
 
6419   for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
 
6421       SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
 
6423       if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
 
6424           ospf_router_lsa_update_area (area);
 
6427   /* Allows for areas configured later to get the property */
 
6428   ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
 
6433 DEFUN (no_ospf_max_metric_router_lsa_admin,
 
6434        no_ospf_max_metric_router_lsa_admin_cmd,
 
6435        "no max-metric router-lsa administrative",
 
6437        "OSPF maximum / infinite-distance metric\n"
 
6438        "Advertise own Router-LSA with infinite distance (stub router)\n"
 
6439        "Administratively applied, for an indefinite period\n")
 
6441   struct listnode *ln;
 
6442   struct ospf_area *area;
 
6443   struct ospf *ospf = vty->index;
 
6445   for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
 
6447       UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
 
6449       /* Don't trample on the start-up stub timer */
 
6450       if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
 
6451           && !area->t_stub_router)
 
6453           UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
 
6454           ospf_router_lsa_update_area (area);
 
6457   ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
 
6461 DEFUN (ospf_max_metric_router_lsa_startup,
 
6462        ospf_max_metric_router_lsa_startup_cmd,
 
6463        "max-metric router-lsa on-startup <5-86400>",
 
6464        "OSPF maximum / infinite-distance metric\n"
 
6465        "Advertise own Router-LSA with infinite distance (stub router)\n"
 
6466        "Automatically advertise stub Router-LSA on startup of OSPF\n"
 
6467        "Time (seconds) to advertise self as stub-router\n")
 
6469   unsigned int seconds;
 
6470   struct ospf *ospf = vty->index;
 
6474       vty_out (vty, "%% Must supply stub-router period");
 
6478   VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
 
6480   ospf->stub_router_startup_time = seconds;
 
6485 DEFUN (no_ospf_max_metric_router_lsa_startup,
 
6486        no_ospf_max_metric_router_lsa_startup_cmd,
 
6487        "no max-metric router-lsa on-startup",
 
6489        "OSPF maximum / infinite-distance metric\n"
 
6490        "Advertise own Router-LSA with infinite distance (stub router)\n"
 
6491        "Automatically advertise stub Router-LSA on startup of OSPF\n")
 
6493   struct listnode *ln;
 
6494   struct ospf_area *area;
 
6495   struct ospf *ospf = vty->index;
 
6497   ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
 
6499   for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
 
6501       SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
 
6502       OSPF_TIMER_OFF (area->t_stub_router);
 
6504       /* Don't trample on admin stub routed */
 
6505       if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
 
6507           UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
 
6508           ospf_router_lsa_update_area (area);
 
6514 DEFUN (ospf_max_metric_router_lsa_shutdown,
 
6515        ospf_max_metric_router_lsa_shutdown_cmd,
 
6516        "max-metric router-lsa on-shutdown <5-86400>",
 
6517        "OSPF maximum / infinite-distance metric\n"
 
6518        "Advertise own Router-LSA with infinite distance (stub router)\n"
 
6519        "Advertise stub-router prior to full shutdown of OSPF\n"
 
6520        "Time (seconds) to wait till full shutdown\n")
 
6522   unsigned int seconds;
 
6523   struct ospf *ospf = vty->index;
 
6527       vty_out (vty, "%% Must supply stub-router shutdown period");
 
6531   VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
 
6533   ospf->stub_router_shutdown_time = seconds;
 
6538 DEFUN (no_ospf_max_metric_router_lsa_shutdown,
 
6539        no_ospf_max_metric_router_lsa_shutdown_cmd,
 
6540        "no max-metric router-lsa on-shutdown",
 
6542        "OSPF maximum / infinite-distance metric\n"
 
6543        "Advertise own Router-LSA with infinite distance (stub router)\n"
 
6544        "Advertise stub-router prior to full shutdown of OSPF\n")
 
6546   struct ospf *ospf = vty->index;
 
6548   ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
 
6554 config_write_stub_router (struct vty *vty, struct ospf *ospf)
 
6556   struct listnode *ln;
 
6557   struct ospf_area *area;
 
6559   if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
 
6560     vty_out (vty, " max-metric router-lsa on-startup %u%s",
 
6561              ospf->stub_router_startup_time, VTY_NEWLINE);
 
6562   if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
 
6563     vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
 
6564              ospf->stub_router_shutdown_time, VTY_NEWLINE);
 
6565   for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
 
6567       if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
 
6569           vty_out (vty, " max-metric router-lsa administrative%s",
 
6578 show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
 
6580   struct route_node *rn;
 
6581   struct ospf_route *or;
 
6582   struct listnode *pnode, *pnnode;
 
6583   struct ospf_path *path;
 
6585   vty_out (vty, "============ OSPF network routing table ============%s",
 
6588   for (rn = route_top (rt); rn; rn = route_next (rn))
 
6589     if ((or = rn->info) != NULL)
 
6592         snprintf (buf1, 19, "%s/%d",
 
6593                   inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
 
6595         switch (or->path_type)
 
6597           case OSPF_PATH_INTER_AREA:
 
6598             if (or->type == OSPF_DESTINATION_NETWORK)
 
6599               vty_out (vty, "N IA %-18s    [%d] area: %s%s", buf1, or->cost,
 
6600                        inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
 
6601             else if (or->type == OSPF_DESTINATION_DISCARD)
 
6602               vty_out (vty, "D IA %-18s    Discard entry%s", buf1, VTY_NEWLINE);
 
6604           case OSPF_PATH_INTRA_AREA:
 
6605             vty_out (vty, "N    %-18s    [%d] area: %s%s", buf1, or->cost,
 
6606                      inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
 
6612         if (or->type == OSPF_DESTINATION_NETWORK)
 
6613           for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
 
6615               if (if_lookup_by_index(path->ifindex))
 
6617                   if (path->nexthop.s_addr == 0)
 
6618                     vty_out (vty, "%24s   directly attached to %s%s",
 
6619                              "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
 
6621                     vty_out (vty, "%24s   via %s, %s%s", "",
 
6622                              inet_ntoa (path->nexthop),
 
6623                              ifindex2ifname (path->ifindex), VTY_NEWLINE);
 
6627   vty_out (vty, "%s", VTY_NEWLINE);
 
6631 show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
 
6633   struct route_node *rn;
 
6634   struct ospf_route *or;
 
6635   struct listnode *pnode;
 
6636   struct listnode *node;
 
6637   struct ospf_path *path;
 
6639   vty_out (vty, "============ OSPF router routing table =============%s",
 
6641   for (rn = route_top (rtrs); rn; rn = route_next (rn))
 
6646         vty_out (vty, "R    %-15s    ", inet_ntoa (rn->p.u.prefix4));
 
6648         for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
 
6651           vty_out (vty, "%24s", "");
 
6654             vty_out (vty, "%s [%d] area: %s",
 
6655                      (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : "  "),
 
6656                      or->cost, inet_ntoa (or->u.std.area_id));
 
6658             vty_out (vty, "%s%s%s",
 
6659                      (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
 
6660                      (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
 
6663                   for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
 
6665                       if (if_lookup_by_index(path->ifindex))
 
6667                           if (path->nexthop.s_addr == 0)
 
6668                             vty_out (vty, "%24s   directly attached to %s%s",
 
6669                                      "", ifindex2ifname (path->ifindex),
 
6672                             vty_out (vty, "%24s   via %s, %s%s", "",
 
6673                                      inet_ntoa (path->nexthop),
 
6674                                      ifindex2ifname (path->ifindex),
 
6680   vty_out (vty, "%s", VTY_NEWLINE);
 
6684 show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
 
6686   struct route_node *rn;
 
6687   struct ospf_route *er;
 
6688   struct listnode *pnode, *pnnode;
 
6689   struct ospf_path *path;
 
6691   vty_out (vty, "============ OSPF external routing table ===========%s",
 
6693   for (rn = route_top (rt); rn; rn = route_next (rn))
 
6694     if ((er = rn->info) != NULL)
 
6697         snprintf (buf1, 19, "%s/%d",
 
6698                   inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
 
6700         switch (er->path_type)
 
6702           case OSPF_PATH_TYPE1_EXTERNAL:
 
6703             vty_out (vty, "N E1 %-18s    [%d] tag: %u%s", buf1,
 
6704                      er->cost, er->u.ext.tag, VTY_NEWLINE);
 
6706           case OSPF_PATH_TYPE2_EXTERNAL:
 
6707             vty_out (vty, "N E2 %-18s    [%d/%d] tag: %u%s", buf1, er->cost,
 
6708                      er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
 
6712         for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
 
6714             if (if_lookup_by_index(path->ifindex))
 
6716                 if (path->nexthop.s_addr == 0)
 
6717                   vty_out (vty, "%24s   directly attached to %s%s",
 
6718                            "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
 
6720                   vty_out (vty, "%24s   via %s, %s%s", "",
 
6721                            inet_ntoa (path->nexthop),
 
6722                            ifindex2ifname (path->ifindex),
 
6727   vty_out (vty, "%s", VTY_NEWLINE);
 
6730 DEFUN (show_ip_ospf_border_routers,
 
6731        show_ip_ospf_border_routers_cmd,
 
6732        "show ip ospf border-routers",
 
6735        "show all the ABR's and ASBR's\n"
 
6740   if ((ospf = ospf_lookup ()) == NULL)
 
6742       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
6746   if (ospf->new_table == NULL)
 
6748       vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
 
6752   /* Show Network routes.
 
6753   show_ip_ospf_route_network (vty, ospf->new_table);   */
 
6755   /* Show Router routes. */
 
6756   show_ip_ospf_route_router (vty, ospf->new_rtrs);
 
6761 DEFUN (show_ip_ospf_route,
 
6762        show_ip_ospf_route_cmd,
 
6763        "show ip ospf route",
 
6766        "OSPF information\n"
 
6767        "OSPF routing table\n")
 
6771   if ((ospf = ospf_lookup ()) == NULL)
 
6773       vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
 
6777   if (ospf->new_table == NULL)
 
6779       vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
 
6783   /* Show Network routes. */
 
6784   show_ip_ospf_route_network (vty, ospf->new_table);
 
6786   /* Show Router routes. */
 
6787   show_ip_ospf_route_router (vty, ospf->new_rtrs);
 
6789   /* Show AS External routes. */
 
6790   show_ip_ospf_route_external (vty, ospf->old_external_route);
 
6796 const char *ospf_abr_type_str[] = 
 
6805 const char *ospf_shortcut_mode_str[] = 
 
6814 area_id2str (char *buf, int length, struct ospf_area *area)
 
6816   memset (buf, 0, length);
 
6818   if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
 
6819     strncpy (buf, inet_ntoa (area->area_id), length);
 
6821     sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
 
6825 const char *ospf_int_type_str[] = 
 
6827   "unknown",            /* should never be used. */
 
6831   "point-to-multipoint",
 
6832   "virtual-link",       /* should never be used. */
 
6836 /* Configuration write function for ospfd. */
 
6838 config_write_interface (struct vty *vty)
 
6840   struct listnode *n1, *n2;
 
6841   struct interface *ifp;
 
6842   struct crypt_key *ck;
 
6844   struct route_node *rn = NULL;
 
6845   struct ospf_if_params *params;
 
6847   for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
 
6849       if (memcmp (ifp->name, "VLINK", 5) == 0)
 
6852       vty_out (vty, "!%s", VTY_NEWLINE);
 
6853       vty_out (vty, "interface %s%s", ifp->name,
 
6856         vty_out (vty, " description %s%s", ifp->desc,
 
6861       params = IF_DEF_PARAMS (ifp);
 
6864         /* Interface Network print. */
 
6865         if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
 
6866             params->type != OSPF_IFTYPE_LOOPBACK)
 
6868             if (params->type != ospf_default_iftype(ifp))
 
6870                 vty_out (vty, " ip ospf network %s",
 
6871                          ospf_int_type_str[params->type]);
 
6872                 if (params != IF_DEF_PARAMS (ifp))
 
6873                   vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
6874                 vty_out (vty, "%s", VTY_NEWLINE);
 
6878         /* OSPF interface authentication print */
 
6879         if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
 
6880             params->auth_type != OSPF_AUTH_NOTSET)
 
6882             const char *auth_str;
 
6884             /* Translation tables are not that much help here due to syntax
 
6885                of the simple option */
 
6886             switch (params->auth_type)
 
6889               case OSPF_AUTH_NULL:
 
6893               case OSPF_AUTH_SIMPLE:
 
6897               case OSPF_AUTH_CRYPTOGRAPHIC:
 
6898                 auth_str = " message-digest";
 
6906             vty_out (vty, " ip ospf authentication%s", auth_str);
 
6907             if (params != IF_DEF_PARAMS (ifp))
 
6908               vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
6909             vty_out (vty, "%s", VTY_NEWLINE);
 
6912         /* Simple Authentication Password print. */
 
6913         if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
 
6914             params->auth_simple[0] != '\0')
 
6916             vty_out (vty, " ip ospf authentication-key %s",
 
6917                      params->auth_simple);
 
6918             if (params != IF_DEF_PARAMS (ifp))
 
6919               vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
6920             vty_out (vty, "%s", VTY_NEWLINE);
 
6923         /* Cryptographic Authentication Key print. */
 
6924         for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
 
6926             vty_out (vty, " ip ospf message-digest-key %d md5 %s",
 
6927                      ck->key_id, ck->auth_key);
 
6928             if (params != IF_DEF_PARAMS (ifp))
 
6929               vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
6930             vty_out (vty, "%s", VTY_NEWLINE);
 
6933         /* Interface Output Cost print. */
 
6934         if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
 
6936             vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
 
6937             if (params != IF_DEF_PARAMS (ifp))
 
6938               vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
6939             vty_out (vty, "%s", VTY_NEWLINE);
 
6942         /* Hello Interval print. */
 
6943         if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
 
6944             params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
 
6946             vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
 
6947             if (params != IF_DEF_PARAMS (ifp))
 
6948               vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
6949             vty_out (vty, "%s", VTY_NEWLINE);
 
6953         /* Router Dead Interval print. */
 
6954         if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
 
6955             params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
 
6957             vty_out (vty, " ip ospf dead-interval ");
 
6960             if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
 
6961               vty_out (vty, "minimal hello-multiplier %d",
 
6962                        params->fast_hello);
 
6964               vty_out (vty, "%u", params->v_wait);
 
6966             if (params != IF_DEF_PARAMS (ifp))
 
6967               vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
6968             vty_out (vty, "%s", VTY_NEWLINE);
 
6971       /* Router Priority print. */
 
6972         if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
 
6973             params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
 
6975             vty_out (vty, " ip ospf priority %u", params->priority);
 
6976             if (params != IF_DEF_PARAMS (ifp))
 
6977               vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
6978             vty_out (vty, "%s", VTY_NEWLINE);
 
6981         /* Retransmit Interval print. */
 
6982         if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
 
6983             params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
 
6985             vty_out (vty, " ip ospf retransmit-interval %u",
 
6986                      params->retransmit_interval);
 
6987             if (params != IF_DEF_PARAMS (ifp))
 
6988               vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
6989             vty_out (vty, "%s", VTY_NEWLINE);
 
6992         /* Transmit Delay print. */
 
6993         if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
 
6994             params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
 
6996             vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
 
6997             if (params != IF_DEF_PARAMS (ifp))
 
6998               vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
6999             vty_out (vty, "%s", VTY_NEWLINE);
 
7003         if (OSPF_IF_PARAM_CONFIGURED (params, if_area))
 
7005             vty_out (vty, " ip ospf area %s", inet_ntoa (params->if_area));
 
7006             if (params != IF_DEF_PARAMS (ifp))
 
7007               vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
7008             vty_out (vty, "%s", VTY_NEWLINE);
 
7011     /* MTU ignore print. */
 
7012     if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
 
7013        params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
 
7015         if (params->mtu_ignore == 0)
 
7016           vty_out (vty, " no ip ospf mtu-ignore");
 
7018           vty_out (vty, " ip ospf mtu-ignore");
 
7019         if (params != IF_DEF_PARAMS (ifp))
 
7020            vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
 
7021         vty_out (vty, "%s", VTY_NEWLINE);
 
7028               rn = route_top (IF_OIFS_PARAMS (ifp));
 
7030               rn = route_next (rn);
 
7040       ospf_opaque_config_write_if (vty, ifp);
 
7047 config_write_network_area (struct vty *vty, struct ospf *ospf)
 
7049   struct route_node *rn;
 
7050   u_char buf[INET_ADDRSTRLEN];
 
7052   /* `network area' print. */
 
7053   for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
 
7056         struct ospf_network *n = rn->info;
 
7058         memset (buf, 0, INET_ADDRSTRLEN);
 
7060         /* Create Area ID string by specified Area ID format. */
 
7061         if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
 
7062           strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
 
7064           sprintf ((char *) buf, "%lu", 
 
7065                    (unsigned long int) ntohl (n->area_id.s_addr));
 
7067         /* Network print. */
 
7068         vty_out (vty, " network %s/%d area %s%s",
 
7069                  inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
 
7077 config_write_ospf_area (struct vty *vty, struct ospf *ospf)
 
7079   struct listnode *node;
 
7080   struct ospf_area *area;
 
7081   u_char buf[INET_ADDRSTRLEN];
 
7083   /* Area configuration print. */
 
7084   for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
 
7086       struct route_node *rn1;
 
7088       area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
 
7090       if (area->auth_type != OSPF_AUTH_NULL)
 
7092           if (area->auth_type == OSPF_AUTH_SIMPLE)
 
7093             vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
 
7095             vty_out (vty, " area %s authentication message-digest%s",
 
7099       if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
 
7100         vty_out (vty, " area %s shortcut %s%s", buf,
 
7101                  ospf_shortcut_mode_str[area->shortcut_configured],
 
7104       if ((area->external_routing == OSPF_AREA_STUB)
 
7105           || (area->external_routing == OSPF_AREA_NSSA)
 
7108           if (area->external_routing == OSPF_AREA_STUB)
 
7109             vty_out (vty, " area %s stub", buf);
 
7110           else if (area->external_routing == OSPF_AREA_NSSA)
 
7112               vty_out (vty, " area %s nssa", buf);
 
7113               switch (area->NSSATranslatorRole)
 
7115                   case OSPF_NSSA_ROLE_NEVER:
 
7116                     vty_out (vty, " translate-never");
 
7118                   case OSPF_NSSA_ROLE_ALWAYS:
 
7119                     vty_out (vty, " translate-always");
 
7121                   case OSPF_NSSA_ROLE_CANDIDATE:
 
7123                     vty_out (vty, " translate-candidate");
 
7127           if (area->no_summary)
 
7128             vty_out (vty, " no-summary");
 
7130           vty_out (vty, "%s", VTY_NEWLINE);
 
7132           if (area->default_cost != 1)
 
7133             vty_out (vty, " area %s default-cost %d%s", buf, 
 
7134                      area->default_cost, VTY_NEWLINE);
 
7137       for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
 
7140             struct ospf_area_range *range = rn1->info;
 
7142             vty_out (vty, " area %s range %s/%d", buf,
 
7143                      inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
 
7145             if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
 
7146               vty_out (vty, " cost %d", range->cost_config);
 
7148             if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
 
7149               vty_out (vty, " not-advertise");
 
7151             if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
 
7152               vty_out (vty, " substitute %s/%d",
 
7153                        inet_ntoa (range->subst_addr), range->subst_masklen);
 
7155             vty_out (vty, "%s", VTY_NEWLINE);
 
7158       if (EXPORT_NAME (area))
 
7159         vty_out (vty, " area %s export-list %s%s", buf,
 
7160                  EXPORT_NAME (area), VTY_NEWLINE);
 
7162       if (IMPORT_NAME (area))
 
7163         vty_out (vty, " area %s import-list %s%s", buf,
 
7164                  IMPORT_NAME (area), VTY_NEWLINE);
 
7166       if (PREFIX_NAME_IN (area))
 
7167         vty_out (vty, " area %s filter-list prefix %s in%s", buf,
 
7168                  PREFIX_NAME_IN (area), VTY_NEWLINE);
 
7170       if (PREFIX_NAME_OUT (area))
 
7171         vty_out (vty, " area %s filter-list prefix %s out%s", buf,
 
7172                  PREFIX_NAME_OUT (area), VTY_NEWLINE);
 
7179 config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
 
7181   struct ospf_nbr_nbma *nbr_nbma;
 
7182   struct route_node *rn;
 
7184   /* Static Neighbor configuration print. */
 
7185   for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
 
7186     if ((nbr_nbma = rn->info))
 
7188         vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
 
7190         if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
 
7191           vty_out (vty, " priority %d", nbr_nbma->priority);
 
7193         if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
 
7194           vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
 
7196         vty_out (vty, "%s", VTY_NEWLINE);
 
7203 config_write_virtual_link (struct vty *vty, struct ospf *ospf)
 
7205   struct listnode *node;
 
7206   struct ospf_vl_data *vl_data;
 
7207   u_char buf[INET_ADDRSTRLEN];
 
7209   /* Virtual-Link print */
 
7210   for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
 
7212       struct listnode *n2;
 
7213       struct crypt_key *ck;
 
7214       struct ospf_interface *oi;
 
7216       if (vl_data != NULL)
 
7218           memset (buf, 0, INET_ADDRSTRLEN);
 
7220           if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
 
7221             strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
 
7223             sprintf ((char *) buf, "%lu", 
 
7224                      (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
 
7225           oi = vl_data->vl_oi;
 
7228           if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
 
7229               OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
 
7230               OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
 
7231               OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
 
7232             vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
 
7234                      inet_ntoa (vl_data->vl_peer), 
 
7235                      OSPF_IF_PARAM (oi, v_hello),
 
7236                      OSPF_IF_PARAM (oi, retransmit_interval),
 
7237                      OSPF_IF_PARAM (oi, transmit_delay),
 
7238                      OSPF_IF_PARAM (oi, v_wait),
 
7241             vty_out (vty, " area %s virtual-link %s%s", buf,
 
7242                      inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
 
7244           if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
 
7245             vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
 
7247                      inet_ntoa (vl_data->vl_peer),
 
7248                      IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
 
7251           for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
 
7253             vty_out (vty, " area %s virtual-link %s"
 
7254                      " message-digest-key %d md5 %s%s",
 
7256                      inet_ntoa (vl_data->vl_peer),
 
7257                      ck->key_id, ck->auth_key, VTY_NEWLINE);
 
7267 config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
 
7271   /* redistribute print. */
 
7272   for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
 
7273     if (type != zclient->redist_default &&
 
7274         vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT))
 
7276         vty_out (vty, " redistribute %s", zebra_route_string(type));
 
7277         if (ospf->dmetric[type].value >= 0)
 
7278           vty_out (vty, " metric %d", ospf->dmetric[type].value);
 
7280         if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
 
7281           vty_out (vty, " metric-type 1");
 
7283         if (ROUTEMAP_NAME (ospf, type))
 
7284           vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
 
7286         vty_out (vty, "%s", VTY_NEWLINE);
 
7293 config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
 
7295   if (ospf->default_metric != -1)
 
7296     vty_out (vty, " default-metric %d%s", ospf->default_metric,
 
7302 config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
 
7308       /* distribute-list print. */
 
7309       for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
 
7310         if (DISTRIBUTE_NAME (ospf, type))
 
7311           vty_out (vty, " distribute-list %s out %s%s", 
 
7312                    DISTRIBUTE_NAME (ospf, type),
 
7313                    zebra_route_string(type), VTY_NEWLINE);
 
7315       /* default-information print. */
 
7316       if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
 
7318           vty_out (vty, " default-information originate");
 
7319           if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
 
7320             vty_out (vty, " always");
 
7322           if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
 
7323             vty_out (vty, " metric %d",
 
7324                      ospf->dmetric[DEFAULT_ROUTE].value);
 
7325           if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
 
7326             vty_out (vty, " metric-type 1");
 
7328           if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
 
7329             vty_out (vty, " route-map %s",
 
7330                      ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
 
7332           vty_out (vty, "%s", VTY_NEWLINE);
 
7341 config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
 
7343   struct route_node *rn;
 
7344   struct ospf_distance *odistance;
 
7346   if (ospf->distance_all)
 
7347     vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
 
7349   if (ospf->distance_intra 
 
7350       || ospf->distance_inter 
 
7351       || ospf->distance_external)
 
7353       vty_out (vty, " distance ospf");
 
7355       if (ospf->distance_intra)
 
7356         vty_out (vty, " intra-area %d", ospf->distance_intra);
 
7357       if (ospf->distance_inter)
 
7358         vty_out (vty, " inter-area %d", ospf->distance_inter);
 
7359       if (ospf->distance_external)
 
7360         vty_out (vty, " external %d", ospf->distance_external);
 
7362       vty_out (vty, "%s", VTY_NEWLINE);
 
7365   for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
 
7366     if ((odistance = rn->info) != NULL)
 
7368         vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
 
7369                  inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
 
7370                  odistance->access_list ? odistance->access_list : "",
 
7376 /* OSPF configuration write function. */
 
7378 ospf_config_write (struct vty *vty)
 
7381   struct interface *ifp;
 
7382   struct ospf_interface *oi;
 
7383   struct listnode *node;
 
7386   ospf = ospf_lookup ();
 
7389       /* `router ospf' print. */
 
7390       vty_out (vty, "router ospf%s", VTY_NEWLINE);
 
7394       if (!ospf->networks)
 
7397       /* Router ID print. */
 
7398       if (ospf->router_id_static.s_addr != 0)
 
7399         vty_out (vty, " ospf router-id %s%s",
 
7400                  inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
 
7402       /* ABR type print. */
 
7403       if (ospf->abr_type != OSPF_ABR_DEFAULT)
 
7404         vty_out (vty, " ospf abr-type %s%s", 
 
7405                  ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
 
7407       /* log-adjacency-changes flag print. */
 
7408       if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
 
7410           vty_out(vty, " log-adjacency-changes");
 
7411           if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
 
7412             vty_out(vty, " detail");
 
7413           vty_out(vty, "%s", VTY_NEWLINE);
 
7416       /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
 
7417       if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
 
7418         vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
 
7420       /* auto-cost reference-bandwidth configuration.  */
 
7421       if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
 
7423           vty_out (vty, "! Important: ensure reference bandwidth "
 
7424                         "is consistent across all routers%s", VTY_NEWLINE);
 
7425           vty_out (vty, " auto-cost reference-bandwidth %d%s",
 
7426                    ospf->ref_bandwidth / 1000, VTY_NEWLINE);
 
7430       if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL)
 
7431   vty_out (vty, " timers throttle lsa all %d%s",
 
7432      ospf->min_ls_interval, VTY_NEWLINE);
 
7433       if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL)
 
7434   vty_out (vty, " timers lsa arrival %d%s",
 
7435      ospf->min_ls_arrival, VTY_NEWLINE);
 
7437       /* SPF timers print. */
 
7438       if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
 
7439           ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
 
7440           ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
 
7441         vty_out (vty, " timers throttle spf %d %d %d%s",
 
7442                  ospf->spf_delay, ospf->spf_holdtime,
 
7443                  ospf->spf_max_holdtime, VTY_NEWLINE);
 
7445       /* Max-metric router-lsa print */
 
7446       config_write_stub_router (vty, ospf);
 
7448       /* SPF refresh parameters print. */
 
7449       if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
 
7450         vty_out (vty, " refresh timer %d%s",
 
7451                  ospf->lsa_refresh_interval, VTY_NEWLINE);
 
7453       /* Redistribute information print. */
 
7454       config_write_ospf_redistribute (vty, ospf);
 
7456       /* passive-interface print. */
 
7457       if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
 
7458         vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
 
7460       for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
 
7461         if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
 
7462             && IF_DEF_PARAMS (ifp)->passive_interface != 
 
7463                               ospf->passive_interface_default)
 
7465             vty_out (vty, " %spassive-interface %s%s",
 
7466                      IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
 
7467                      ifp->name, VTY_NEWLINE);
 
7469       for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
 
7471           if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
 
7473           if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
 
7476               if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
 
7479           else if (oi->params->passive_interface == ospf->passive_interface_default)
 
7482           vty_out (vty, " %spassive-interface %s %s%s",
 
7483                    oi->params->passive_interface ? "" : "no ",
 
7485                    inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
 
7488       /* Network area print. */
 
7489       config_write_network_area (vty, ospf);
 
7491       /* Area config print. */
 
7492       config_write_ospf_area (vty, ospf);
 
7494       /* static neighbor print. */
 
7495       config_write_ospf_nbr_nbma (vty, ospf);
 
7497       /* Virtual-Link print. */
 
7498       config_write_virtual_link (vty, ospf);
 
7500       /* Default metric configuration.  */
 
7501       config_write_ospf_default_metric (vty, ospf);
 
7503       /* Distribute-list and default-information print. */
 
7504       config_write_ospf_distribute (vty, ospf);
 
7506       /* Distance configuration. */
 
7507       config_write_ospf_distance (vty, ospf);
 
7509       ospf_opaque_config_write_router (vty, ospf);
 
7516 ospf_vty_show_init (void)
 
7518   /* "show ip ospf" commands. */
 
7519   install_element (VIEW_NODE, &show_ip_ospf_cmd);
 
7521   /* "show ip ospf database" commands. */
 
7522   install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
 
7523   install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
 
7524   install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
 
7525   install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
 
7526   install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
 
7527   install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
 
7528   install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
 
7530   /* "show ip ospf interface" commands. */
 
7531   install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
 
7533   /* "show ip ospf neighbor" commands. */
 
7534   install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
 
7535   install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
 
7536   install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
 
7537   install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
 
7538   install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
 
7539   install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
 
7540   install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
 
7542   /* "show ip ospf route" commands. */
 
7543   install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
 
7544   install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
 
7548 /* ospfd's interface node. */
 
7549 static struct cmd_node interface_node =
 
7556 /* Initialization of OSPF interface. */
 
7558 ospf_vty_if_init (void)
 
7560   /* Install interface node. */
 
7561   install_node (&interface_node, config_write_interface);
 
7563   install_element (CONFIG_NODE, &interface_cmd);
 
7564   install_element (CONFIG_NODE, &no_interface_cmd);
 
7565   install_default (INTERFACE_NODE);
 
7567   /* "description" commands. */
 
7568   install_element (INTERFACE_NODE, &interface_desc_cmd);
 
7569   install_element (INTERFACE_NODE, &no_interface_desc_cmd);
 
7571   /* "ip ospf authentication" commands. */
 
7572   install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
 
7573   install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
 
7574   install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
 
7575   install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
 
7576   install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
 
7577   install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
 
7578   install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
 
7579   install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
 
7580   install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
 
7581   install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
 
7583   /* "ip ospf message-digest-key" commands. */
 
7584   install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
 
7585   install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
 
7586   install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
 
7587   install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
 
7589   /* "ip ospf cost" commands. */
 
7590   install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
 
7591   install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
 
7592   install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
 
7593   install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
 
7594   install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
 
7595   install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
 
7597   /* "ip ospf mtu-ignore" commands. */
 
7598   install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
 
7599   install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
 
7600   install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
 
7601   install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
 
7603   /* "ip ospf dead-interval" commands. */
 
7604   install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
 
7605   install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
 
7606   install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
 
7607   install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
 
7608   install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
 
7609   install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
 
7610   install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_seconds_cmd);
 
7612   /* "ip ospf hello-interval" commands. */
 
7613   install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
 
7614   install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
 
7615   install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
 
7616   install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
 
7617   install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_seconds_cmd);
 
7619   /* "ip ospf network" commands. */
 
7620   install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
 
7621   install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
 
7623   /* "ip ospf priority" commands. */
 
7624   install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
 
7625   install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
 
7626   install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
 
7627   install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
 
7629   /* "ip ospf retransmit-interval" commands. */
 
7630   install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
 
7631   install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
 
7632   install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
 
7633   install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
 
7635   /* "ip ospf transmit-delay" commands. */
 
7636   install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
 
7637   install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
 
7638   install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
 
7639   install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
 
7641   /* "ip ospf area" commands. */
 
7642   install_element (INTERFACE_NODE, &ip_ospf_area_cmd);
 
7643   install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd);
 
7645   /* These commands are compatibitliy for previous version. */
 
7646   install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
 
7647   install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
 
7648   install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
 
7649   install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
 
7650   install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
 
7651   install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
 
7652   install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
 
7653   install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
 
7654   install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
 
7655   install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
 
7656   install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
 
7657   install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
 
7658   install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
 
7659   install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
 
7660   install_element (INTERFACE_NODE, &ospf_network_cmd);
 
7661   install_element (INTERFACE_NODE, &no_ospf_network_cmd);
 
7662   install_element (INTERFACE_NODE, &ospf_priority_cmd);
 
7663   install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
 
7664   install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
 
7665   install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
 
7666   install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
 
7667   install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
 
7671 ospf_vty_zebra_init (void)
 
7673   install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
 
7674   install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
 
7676   install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
 
7677   install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
 
7679   install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
 
7680   install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
 
7682   install_element (OSPF_NODE, &ospf_default_metric_cmd);
 
7683   install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
 
7684   install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
 
7686   install_element (OSPF_NODE, &ospf_distance_cmd);
 
7687   install_element (OSPF_NODE, &no_ospf_distance_cmd);
 
7688   install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
 
7689   install_element (OSPF_NODE, &ospf_distance_ospf_cmd);
 
7691   install_element (OSPF_NODE, &ospf_distance_source_cmd);
 
7692   install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
 
7693   install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
 
7694   install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
 
7698 static struct cmd_node ospf_node =
 
7701   "%s(config-router)# ",
 
7706 ospf_interface_clear (struct interface *ifp)
 
7708   if (!if_is_operative (ifp)) return;
 
7710   if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
 
7711     zlog (NULL, LOG_DEBUG, "ISM[%s]: clear by reset", ifp->name);
 
7716 DEFUN (clear_ip_ospf_interface,
 
7717        clear_ip_ospf_interface_cmd,
 
7718        "clear ip ospf interface [IFNAME]",
 
7721        "OSPF information\n"
 
7722        "Interface information\n"
 
7725   struct interface *ifp;
 
7726   struct listnode *node;
 
7728   if (argc == 0) /* Clear all the ospfv2 interfaces. */
 
7730       for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
 
7731         ospf_interface_clear(ifp);
 
7733   else /* Interface name is specified. */
 
7735       if ((ifp = if_lookup_by_name (argv[0])) == NULL)
 
7736         vty_out (vty, "No such interface name%s", VTY_NEWLINE);
 
7738         ospf_interface_clear(ifp);
 
7745 ospf_vty_clear_init (void)
 
7747   install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd);
 
7751 /* Install OSPF related vty commands. */
 
7753 ospf_vty_init (void)
 
7755   /* Install ospf top node. */
 
7756   install_node (&ospf_node, ospf_config_write);
 
7758   /* "router ospf" commands. */
 
7759   install_element (CONFIG_NODE, &router_ospf_cmd);
 
7760   install_element (CONFIG_NODE, &no_router_ospf_cmd);
 
7762   install_default (OSPF_NODE);
 
7764   /* "ospf router-id" commands. */
 
7765   install_element (OSPF_NODE, &ospf_router_id_cmd);
 
7766   install_element (OSPF_NODE, &no_ospf_router_id_cmd);
 
7767   install_element (OSPF_NODE, &router_ospf_id_cmd);
 
7768   install_element (OSPF_NODE, &no_router_ospf_id_cmd);
 
7770   /* "passive-interface" commands. */
 
7771   install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
 
7772   install_element (OSPF_NODE, &ospf_passive_interface_cmd);
 
7773   install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
 
7774   install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
 
7775   install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
 
7776   install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
 
7778   /* "ospf abr-type" commands. */
 
7779   install_element (OSPF_NODE, &ospf_abr_type_cmd);
 
7780   install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
 
7782   /* "ospf log-adjacency-changes" commands. */
 
7783   install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
 
7784   install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
 
7785   install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
 
7786   install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
 
7788   /* "ospf rfc1583-compatible" commands. */
 
7789   install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
 
7790   install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
 
7791   install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
 
7792   install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
 
7794   /* "network area" commands. */
 
7795   install_element (OSPF_NODE, &ospf_network_area_cmd);
 
7796   install_element (OSPF_NODE, &no_ospf_network_area_cmd);
 
7798   /* "area authentication" commands. */
 
7799   install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
 
7800   install_element (OSPF_NODE, &ospf_area_authentication_cmd);
 
7801   install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
 
7803   /* "area range" commands.  */
 
7804   install_element (OSPF_NODE, &ospf_area_range_cmd);
 
7805   install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
 
7806   install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
 
7807   install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
 
7808   install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
 
7809   install_element (OSPF_NODE, &no_ospf_area_range_cmd);
 
7810   install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
 
7811   install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
 
7812   install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
 
7813   install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
 
7814   install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
 
7816   /* "area virtual-link" commands. */
 
7817   install_element (OSPF_NODE, &ospf_area_vlink_cmd);
 
7818   install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
 
7820   install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
 
7821   install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
 
7823   install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
 
7824   install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
 
7826   install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
 
7827   install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
 
7829   install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
 
7830   install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
 
7832   install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
 
7833   install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
 
7834   install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
 
7836   install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
 
7837   install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
 
7839   install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
 
7840   install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
 
7842   install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
 
7843   install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
 
7844   install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
 
7846   install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
 
7847   install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
 
7848   install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
 
7850   /* "area stub" commands. */
 
7851   install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
 
7852   install_element (OSPF_NODE, &ospf_area_stub_cmd);
 
7853   install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
 
7854   install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
 
7856   /* "area nssa" commands. */
 
7857   install_element (OSPF_NODE, &ospf_area_nssa_cmd);
 
7858   install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
 
7859   install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
 
7860   install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
 
7861   install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
 
7862   install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
 
7864   install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
 
7865   install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
 
7867   install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
 
7868   install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
 
7870   install_element (OSPF_NODE, &ospf_area_export_list_cmd);
 
7871   install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
 
7873   install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
 
7874   install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
 
7876   install_element (OSPF_NODE, &ospf_area_import_list_cmd);
 
7877   install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
 
7879   /* LSA timer commands */
 
7880   install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd);
 
7881   install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd);
 
7882   install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd);
 
7883   install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd);
 
7885   /* SPF timer commands */
 
7886   install_element (OSPF_NODE, &ospf_timers_spf_cmd);
 
7887   install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
 
7888   install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
 
7889   install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
 
7891   /* refresh timer commands */
 
7892   install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
 
7893   install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
 
7894   install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
 
7896   /* max-metric commands */
 
7897   install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
 
7898   install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
 
7899   install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
 
7900   install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
 
7901   install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
 
7902   install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
 
7904   /* reference bandwidth commands */
 
7905   install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
 
7906   install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
 
7908   /* "neighbor" commands. */
 
7909   install_element (OSPF_NODE, &ospf_neighbor_cmd);
 
7910   install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
 
7911   install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
 
7912   install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
 
7913   install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
 
7914   install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
 
7915   install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
 
7916   install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
 
7918   /* Init interface related vty commands. */
 
7919   ospf_vty_if_init ();
 
7921   /* Init zebra related vty commands. */
 
7922   ospf_vty_zebra_init ();