File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / quagga / ospfd / ospf_vty.c
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Sun Jul 21 23:54:40 2013 UTC (10 years, 11 months ago) by misho
Branches: quagga, MAIN
CVS tags: v0_99_22p0, v0_99_22, HEAD
0.99.22

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>