Annotation of embedaddon/quagga/isisd/isisd.c, revision 1.1.1.4

1.1       misho       1: /*
                      2:  * IS-IS Rout(e)ing protocol - isisd.c
                      3:  *
                      4:  * Copyright (C) 2001,2002   Sampo Saaristo
                      5:  *                           Tampere University of Technology      
                      6:  *                           Institute of Communications Engineering
                      7:  *
                      8:  * This program is free software; you can redistribute it and/or modify it 
                      9:  * under the terms of the GNU General Public Licenseas published by the Free 
                     10:  * Software Foundation; either version 2 of the License, or (at your option) 
                     11:  * any later version.
                     12:  *
                     13:  * This program is distributed in the hope that it will be useful,but WITHOUT 
                     14:  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
                     15:  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
                     16:  * more details.
                     17: 
                     18:  * You should have received a copy of the GNU General Public License along 
                     19:  * with this program; if not, write to the Free Software Foundation, Inc., 
                     20:  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
                     21:  */
                     22: 
                     23: #include <zebra.h>
                     24: 
                     25: #include "thread.h"
                     26: #include "vty.h"
                     27: #include "command.h"
                     28: #include "log.h"
                     29: #include "memory.h"
1.1.1.2   misho      30: #include "time.h"
1.1       misho      31: #include "linklist.h"
                     32: #include "if.h"
                     33: #include "hash.h"
                     34: #include "stream.h"
                     35: #include "prefix.h"
                     36: #include "table.h"
                     37: 
                     38: #include "isisd/dict.h"
                     39: #include "isisd/include-netbsd/iso.h"
                     40: #include "isisd/isis_constants.h"
                     41: #include "isisd/isis_common.h"
                     42: #include "isisd/isis_flags.h"
1.1.1.2   misho      43: #include "isisd/isis_circuit.h"
                     44: #include "isisd/isis_csm.h"
1.1       misho      45: #include "isisd/isisd.h"
                     46: #include "isisd/isis_dynhn.h"
                     47: #include "isisd/isis_adjacency.h"
                     48: #include "isisd/isis_pdu.h"
                     49: #include "isisd/isis_misc.h"
                     50: #include "isisd/isis_constants.h"
                     51: #include "isisd/isis_tlv.h"
                     52: #include "isisd/isis_lsp.h"
                     53: #include "isisd/isis_spf.h"
                     54: #include "isisd/isis_route.h"
                     55: #include "isisd/isis_zebra.h"
                     56: #include "isisd/isis_events.h"
                     57: 
                     58: #ifdef TOPOLOGY_GENERATE
                     59: #include "spgrid.h"
                     60: u_char DEFAULT_TOPOLOGY_BASEIS[6] = { 0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00 };
                     61: #endif /* TOPOLOGY_GENERATE */
                     62: 
                     63: struct isis *isis = NULL;
                     64: 
                     65: /*
                     66:  * Prototypes.
                     67:  */
                     68: int isis_area_get(struct vty *, const char *);
                     69: int isis_area_destroy(struct vty *, const char *);
1.1.1.2   misho      70: int area_net_title(struct vty *, const char *);
                     71: int area_clear_net_title(struct vty *, const char *);
                     72: int show_isis_interface_common(struct vty *, const char *ifname, char);
                     73: int show_isis_neighbor_common(struct vty *, const char *id, char);
                     74: int clear_isis_neighbor_common(struct vty *, const char *id);
1.1       misho      75: int isis_config_write(struct vty *);
                     76: 
                     77: 
                     78: 
                     79: void
                     80: isis_new (unsigned long process_id)
                     81: {
                     82:   isis = XCALLOC (MTYPE_ISIS, sizeof (struct isis));
                     83:   /*
                     84:    * Default values
                     85:    */
                     86:   isis->max_area_addrs = 3;
                     87:   isis->process_id = process_id;
1.1.1.2   misho      88:   isis->router_id = 0;
1.1       misho      89:   isis->area_list = list_new ();
                     90:   isis->init_circ_list = list_new ();
                     91:   isis->uptime = time (NULL);
                     92:   isis->nexthops = list_new ();
                     93: #ifdef HAVE_IPV6
                     94:   isis->nexthops6 = list_new ();
                     95: #endif /* HAVE_IPV6 */
1.1.1.2   misho      96:   dyn_cache_init ();
1.1       misho      97:   /*
                     98:    * uncomment the next line for full debugs
                     99:    */
                    100:   /* isis->debugs = 0xFFFF; */
                    101: }
                    102: 
                    103: struct isis_area *
1.1.1.2   misho     104: isis_area_create (const char *area_tag)
1.1       misho     105: {
                    106:   struct isis_area *area;
                    107: 
                    108:   area = XCALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area));
                    109: 
                    110:   /*
                    111:    * The first instance is level-1-2 rest are level-1, unless otherwise
                    112:    * configured
                    113:    */
                    114:   if (listcount (isis->area_list) > 0)
                    115:     area->is_type = IS_LEVEL_1;
                    116:   else
                    117:     area->is_type = IS_LEVEL_1_AND_2;
1.1.1.2   misho     118: 
1.1       misho     119:   /*
                    120:    * intialize the databases
                    121:    */
1.1.1.2   misho     122:   if (area->is_type & IS_LEVEL_1)
                    123:     {
                    124:       area->lspdb[0] = lsp_db_init ();
                    125:       area->route_table[0] = route_table_init ();
                    126: #ifdef HAVE_IPV6
                    127:       area->route_table6[0] = route_table_init ();
                    128: #endif /* HAVE_IPV6 */
                    129:     }
                    130:   if (area->is_type & IS_LEVEL_2)
                    131:     {
                    132:       area->lspdb[1] = lsp_db_init ();
                    133:       area->route_table[1] = route_table_init ();
1.1       misho     134: #ifdef HAVE_IPV6
1.1.1.2   misho     135:       area->route_table6[1] = route_table_init ();
1.1       misho     136: #endif /* HAVE_IPV6 */
1.1.1.2   misho     137:     }
                    138: 
                    139:   spftree_area_init (area);
                    140: 
1.1       misho     141:   area->circuit_list = list_new ();
                    142:   area->area_addrs = list_new ();
                    143:   THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
                    144:   flags_initialize (&area->flags);
1.1.1.2   misho     145: 
1.1       misho     146:   /*
                    147:    * Default values
                    148:    */
1.1.1.2   misho     149:   area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME;    /* 1200 */
                    150:   area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME;    /* 1200 */
                    151:   area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
                    152:   area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
                    153:   area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL;
                    154:   area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL;
1.1       misho     155:   area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
                    156:   area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
                    157:   area->dynhostname = 1;
1.1.1.2   misho     158:   area->oldmetric = 0;
                    159:   area->newmetric = 1;
1.1       misho     160:   area->lsp_frag_threshold = 90;
1.1.1.4 ! misho     161:   area->lsp_mtu = DEFAULT_LSP_MTU;
1.1       misho     162: #ifdef TOPOLOGY_GENERATE
                    163:   memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
                    164: #endif /* TOPOLOGY_GENERATE */
                    165: 
1.1.1.2   misho     166:   area->area_tag = strdup (area_tag);
                    167:   listnode_add (isis->area_list, area);
                    168:   area->isis = isis;
                    169: 
1.1       misho     170:   return area;
                    171: }
                    172: 
                    173: struct isis_area *
                    174: isis_area_lookup (const char *area_tag)
                    175: {
                    176:   struct isis_area *area;
                    177:   struct listnode *node;
                    178: 
                    179:   for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
                    180:     if ((area->area_tag == NULL && area_tag == NULL) ||
                    181:        (area->area_tag && area_tag
                    182:         && strcmp (area->area_tag, area_tag) == 0))
                    183:     return area;
                    184: 
                    185:   return NULL;
                    186: }
                    187: 
                    188: int
                    189: isis_area_get (struct vty *vty, const char *area_tag)
                    190: {
                    191:   struct isis_area *area;
                    192: 
                    193:   area = isis_area_lookup (area_tag);
                    194: 
                    195:   if (area)
                    196:     {
                    197:       vty->node = ISIS_NODE;
                    198:       vty->index = area;
                    199:       return CMD_SUCCESS;
                    200:     }
                    201: 
1.1.1.2   misho     202:   area = isis_area_create (area_tag);
1.1       misho     203: 
                    204:   if (isis->debugs & DEBUG_EVENTS)
                    205:     zlog_debug ("New IS-IS area instance %s", area->area_tag);
                    206: 
                    207:   vty->node = ISIS_NODE;
                    208:   vty->index = area;
                    209: 
                    210:   return CMD_SUCCESS;
                    211: }
                    212: 
                    213: int
                    214: isis_area_destroy (struct vty *vty, const char *area_tag)
                    215: {
                    216:   struct isis_area *area;
                    217:   struct listnode *node, *nnode;
                    218:   struct isis_circuit *circuit;
1.1.1.2   misho     219:   struct area_addr *addr;
1.1       misho     220: 
                    221:   area = isis_area_lookup (area_tag);
                    222: 
                    223:   if (area == NULL)
                    224:     {
                    225:       vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1.1.1.2   misho     226:       return CMD_ERR_NO_MATCH;
1.1       misho     227:     }
                    228: 
                    229:   if (area->circuit_list)
                    230:     {
                    231:       for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
1.1.1.2   misho     232:         {
                    233:           circuit->ip_router = 0;
                    234: #ifdef HAVE_IPV6
                    235:           circuit->ipv6_router = 0;
                    236: #endif
                    237:           isis_csm_state_change (ISIS_DISABLE, circuit, area);
                    238:         }
1.1       misho     239:       list_delete (area->circuit_list);
1.1.1.2   misho     240:       area->circuit_list = NULL;
1.1       misho     241:     }
1.1.1.2   misho     242: 
                    243:   if (area->lspdb[0] != NULL)
                    244:     {
                    245:       lsp_db_destroy (area->lspdb[0]);
                    246:       area->lspdb[0] = NULL;
                    247:     }
                    248:   if (area->lspdb[1] != NULL)
                    249:     {
                    250:       lsp_db_destroy (area->lspdb[1]);
                    251:       area->lspdb[1] = NULL;
                    252:     }
                    253: 
                    254:   spftree_area_del (area);
                    255: 
                    256:   /* invalidate and validate would delete all routes from zebra */
                    257:   isis_route_invalidate (area);
                    258:   isis_route_validate (area);
                    259: 
                    260:   if (area->route_table[0])
                    261:     {
                    262:       route_table_finish (area->route_table[0]);
                    263:       area->route_table[0] = NULL;
                    264:     }
                    265:   if (area->route_table[1])
                    266:     {
                    267:       route_table_finish (area->route_table[1]);
                    268:       area->route_table[1] = NULL;
                    269:     }
                    270: #ifdef HAVE_IPV6
                    271:   if (area->route_table6[0])
                    272:     {
                    273:       route_table_finish (area->route_table6[0]);
                    274:       area->route_table6[0] = NULL;
                    275:     }
                    276:   if (area->route_table6[1])
                    277:     {
                    278:       route_table_finish (area->route_table6[1]);
                    279:       area->route_table6[1] = NULL;
                    280:     }
                    281: #endif /* HAVE_IPV6 */
                    282: 
1.1.1.4 ! misho     283:   isis_redist_area_finish(area);
        !           284: 
1.1.1.2   misho     285:   for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addr))
                    286:     {
                    287:       list_delete_node (area->area_addrs, node);
                    288:       XFREE (MTYPE_ISIS_AREA_ADDR, addr);
                    289:     }
                    290:   area->area_addrs = NULL;
1.1       misho     291: 
                    292:   THREAD_TIMER_OFF (area->t_tick);
                    293:   THREAD_TIMER_OFF (area->t_lsp_refresh[0]);
                    294:   THREAD_TIMER_OFF (area->t_lsp_refresh[1]);
                    295: 
1.1.1.2   misho     296:   thread_cancel_event (master, area);
                    297: 
                    298:   listnode_delete (isis->area_list, area);
1.1       misho     299: 
1.1.1.2   misho     300:   free (area->area_tag);
1.1       misho     301: 
                    302:   XFREE (MTYPE_ISIS_AREA, area);
                    303: 
1.1.1.2   misho     304:   if (listcount (isis->area_list) == 0)
                    305:     {
                    306:       memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
                    307:       isis->sysid_set = 0;
                    308:     }
1.1       misho     309: 
                    310:   return CMD_SUCCESS;
                    311: }
                    312: 
                    313: int
1.1.1.2   misho     314: area_net_title (struct vty *vty, const char *net_title)
1.1       misho     315: {
                    316:   struct isis_area *area;
                    317:   struct area_addr *addr;
                    318:   struct area_addr *addrp;
                    319:   struct listnode *node;
                    320: 
                    321:   u_char buff[255];
                    322:   area = vty->index;
                    323: 
                    324:   if (!area)
                    325:     {
                    326:       vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1.1.1.2   misho     327:       return CMD_ERR_NO_MATCH;
1.1       misho     328:     }
                    329: 
                    330:   /* We check that we are not over the maximal number of addresses */
                    331:   if (listcount (area->area_addrs) >= isis->max_area_addrs)
                    332:     {
                    333:       vty_out (vty, "Maximum of area addresses (%d) already reached %s",
                    334:               isis->max_area_addrs, VTY_NEWLINE);
1.1.1.2   misho     335:       return CMD_ERR_NOTHING_TODO;
1.1       misho     336:     }
                    337: 
                    338:   addr = XMALLOC (MTYPE_ISIS_AREA_ADDR, sizeof (struct area_addr));
                    339:   addr->addr_len = dotformat2buff (buff, net_title);
                    340:   memcpy (addr->area_addr, buff, addr->addr_len);
                    341: #ifdef EXTREME_DEBUG
                    342:   zlog_debug ("added area address %s for area %s (address length %d)",
                    343:             net_title, area->area_tag, addr->addr_len);
                    344: #endif /* EXTREME_DEBUG */
                    345:   if (addr->addr_len < 8 || addr->addr_len > 20)
                    346:     {
1.1.1.2   misho     347:       vty_out (vty, "area address must be at least 8..20 octets long (%d)%s",
                    348:                addr->addr_len, VTY_NEWLINE);
                    349:       XFREE (MTYPE_ISIS_AREA_ADDR, addr);
                    350:       return CMD_ERR_AMBIGUOUS;
                    351:     }
                    352: 
                    353:   if (addr->area_addr[addr->addr_len-1] != 0)
                    354:     {
                    355:       vty_out (vty, "nsel byte (last byte) in area address must be 0%s",
                    356:                VTY_NEWLINE);
1.1       misho     357:       XFREE (MTYPE_ISIS_AREA_ADDR, addr);
1.1.1.2   misho     358:       return CMD_ERR_AMBIGUOUS;
1.1       misho     359:     }
                    360: 
                    361:   if (isis->sysid_set == 0)
                    362:     {
                    363:       /*
                    364:        * First area address - get the SystemID for this router
                    365:        */
1.1.1.2   misho     366:       memcpy (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN);
1.1       misho     367:       isis->sysid_set = 1;
                    368:       if (isis->debugs & DEBUG_EVENTS)
                    369:        zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid));
                    370:     }
                    371:   else
                    372:     {
                    373:       /*
                    374:        * Check that the SystemID portions match
                    375:        */
1.1.1.2   misho     376:       if (memcmp (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN))
1.1       misho     377:        {
                    378:          vty_out (vty,
                    379:                   "System ID must not change when defining additional area"
                    380:                   " addresses%s", VTY_NEWLINE);
                    381:          XFREE (MTYPE_ISIS_AREA_ADDR, addr);
1.1.1.2   misho     382:          return CMD_ERR_AMBIGUOUS;
1.1       misho     383:        }
                    384: 
                    385:       /* now we see that we don't already have this address */
                    386:       for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
                    387:        {
1.1.1.2   misho     388:          if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != (addr->addr_len))
1.1       misho     389:            continue;
                    390:          if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
                    391:            {
                    392:              XFREE (MTYPE_ISIS_AREA_ADDR, addr);
                    393:              return CMD_SUCCESS;       /* silent fail */
                    394:            }
                    395:        }
                    396:     }
1.1.1.2   misho     397: 
1.1       misho     398:   /*
                    399:    * Forget the systemID part of the address
                    400:    */
1.1.1.2   misho     401:   addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
1.1       misho     402:   listnode_add (area->area_addrs, addr);
                    403: 
                    404:   /* only now we can safely generate our LSPs for this area */
                    405:   if (listcount (area->area_addrs) > 0)
                    406:     {
1.1.1.2   misho     407:       if (area->is_type & IS_LEVEL_1)
                    408:         lsp_generate (area, IS_LEVEL_1);
                    409:       if (area->is_type & IS_LEVEL_2)
                    410:         lsp_generate (area, IS_LEVEL_2);
1.1       misho     411:     }
                    412: 
                    413:   return CMD_SUCCESS;
                    414: }
                    415: 
                    416: int
1.1.1.2   misho     417: area_clear_net_title (struct vty *vty, const char *net_title)
1.1       misho     418: {
                    419:   struct isis_area *area;
                    420:   struct area_addr addr, *addrp = NULL;
                    421:   struct listnode *node;
                    422:   u_char buff[255];
                    423: 
                    424:   area = vty->index;
                    425:   if (!area)
                    426:     {
                    427:       vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1.1.1.2   misho     428:       return CMD_ERR_NO_MATCH;
1.1       misho     429:     }
                    430: 
                    431:   addr.addr_len = dotformat2buff (buff, net_title);
                    432:   if (addr.addr_len < 8 || addr.addr_len > 20)
                    433:     {
                    434:       vty_out (vty, "Unsupported area address length %d, should be 8...20 %s",
                    435:               addr.addr_len, VTY_NEWLINE);
1.1.1.2   misho     436:       return CMD_ERR_AMBIGUOUS;
1.1       misho     437:     }
                    438: 
                    439:   memcpy (addr.area_addr, buff, (int) addr.addr_len);
                    440: 
                    441:   for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
1.1.1.2   misho     442:     if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len &&
1.1       misho     443:        !memcmp (addrp->area_addr, addr.area_addr, addr.addr_len))
                    444:     break;
                    445: 
                    446:   if (!addrp)
                    447:     {
                    448:       vty_out (vty, "No area address %s for area %s %s", net_title,
                    449:               area->area_tag, VTY_NEWLINE);
1.1.1.2   misho     450:       return CMD_ERR_NO_MATCH;
1.1       misho     451:     }
                    452: 
                    453:   listnode_delete (area->area_addrs, addrp);
1.1.1.2   misho     454:   XFREE (MTYPE_ISIS_AREA_ADDR, addrp);
                    455: 
                    456:   /*
                    457:    * Last area address - reset the SystemID for this router
                    458:    */
                    459:   if (listcount (area->area_addrs) == 0)
                    460:     {
                    461:       memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
                    462:       isis->sysid_set = 0;
                    463:       if (isis->debugs & DEBUG_EVENTS)
                    464:         zlog_debug ("Router has no SystemID");
                    465:     }
1.1       misho     466: 
                    467:   return CMD_SUCCESS;
                    468: }
                    469: 
                    470: /*
1.1.1.2   misho     471:  * 'show isis interface' command
1.1       misho     472:  */
                    473: 
                    474: int
1.1.1.2   misho     475: show_isis_interface_common (struct vty *vty, const char *ifname, char detail)
1.1       misho     476: {
                    477:   struct listnode *anode, *cnode;
                    478:   struct isis_area *area;
                    479:   struct isis_circuit *circuit;
                    480: 
                    481:   if (!isis)
                    482:     {
                    483:       vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
                    484:       return CMD_SUCCESS;
                    485:     }
                    486: 
                    487:   for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
                    488:     {
                    489:       vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
                    490: 
                    491:       if (detail == ISIS_UI_LEVEL_BRIEF)
1.1.1.2   misho     492:         vty_out (vty, "  Interface   CircId   State    Type     Level%s",
                    493:                  VTY_NEWLINE);
1.1       misho     494: 
                    495:       for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
1.1.1.2   misho     496:         if (!ifname)
                    497:           isis_circuit_print_vty (circuit, vty, detail);
                    498:         else if (strcmp(circuit->interface->name, ifname) == 0)
                    499:           isis_circuit_print_vty (circuit, vty, detail);
1.1       misho     500:     }
                    501: 
                    502:   return CMD_SUCCESS;
                    503: }
                    504: 
1.1.1.2   misho     505: DEFUN (show_isis_interface,
                    506:        show_isis_interface_cmd,
                    507:        "show isis interface",
1.1       misho     508:        SHOW_STR
1.1.1.2   misho     509:        "ISIS network information\n"
                    510:        "ISIS interface\n")
1.1       misho     511: {
1.1.1.2   misho     512:   return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
1.1       misho     513: }
                    514: 
1.1.1.2   misho     515: DEFUN (show_isis_interface_detail,
                    516:        show_isis_interface_detail_cmd,
                    517:        "show isis interface detail",
1.1       misho     518:        SHOW_STR
1.1.1.2   misho     519:        "ISIS network information\n"
                    520:        "ISIS interface\n"
                    521:        "show detailed information\n")
                    522: {
                    523:   return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
                    524: }
1.1       misho     525: 
1.1.1.2   misho     526: DEFUN (show_isis_interface_arg,
                    527:        show_isis_interface_arg_cmd,
                    528:        "show isis interface WORD",
1.1       misho     529:        SHOW_STR
1.1.1.2   misho     530:        "ISIS network information\n"
                    531:        "ISIS interface\n"
                    532:        "ISIS interface name\n")
                    533: {
                    534:   return show_isis_interface_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
                    535: }
                    536: 
                    537: /*
                    538:  * 'show isis neighbor' command
                    539:  */
                    540: 
                    541: int
                    542: show_isis_neighbor_common (struct vty *vty, const char *id, char detail)
                    543: {
                    544:   struct listnode *anode, *cnode, *node;
                    545:   struct isis_area *area;
                    546:   struct isis_circuit *circuit;
                    547:   struct list *adjdb;
                    548:   struct isis_adjacency *adj;
                    549:   struct isis_dynhn *dynhn;
                    550:   u_char sysid[ISIS_SYS_ID_LEN];
                    551:   int i;
                    552: 
                    553:   if (!isis)
                    554:     {
                    555:       vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
                    556:       return CMD_SUCCESS;
                    557:     }
                    558: 
                    559:   memset (sysid, 0, ISIS_SYS_ID_LEN);
                    560:   if (id)
                    561:     {
                    562:       if (sysid2buff (sysid, id) == 0)
                    563:         {
                    564:           dynhn = dynhn_find_by_name (id);
                    565:           if (dynhn == NULL)
                    566:             {
                    567:               vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
                    568:               return CMD_SUCCESS;
                    569:             }
                    570:           memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
                    571:         }
                    572:     }
                    573: 
                    574:   for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
                    575:     {
                    576:       vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
                    577: 
                    578:       if (detail == ISIS_UI_LEVEL_BRIEF)
                    579:         vty_out (vty, "  System Id           Interface   L  State"
                    580:                       "        Holdtime SNPA%s", VTY_NEWLINE);
                    581: 
                    582:       for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
                    583:         {
                    584:           if (circuit->circ_type == CIRCUIT_T_BROADCAST)
                    585:             {
                    586:               for (i = 0; i < 2; i++)
                    587:                 {
                    588:                   adjdb = circuit->u.bc.adjdb[i];
                    589:                   if (adjdb && adjdb->count)
                    590:                     {
                    591:                       for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
                    592:                         if (!id || !memcmp (adj->sysid, sysid,
                    593:                                             ISIS_SYS_ID_LEN))
                    594:                           isis_adj_print_vty (adj, vty, detail);
                    595:                     }
                    596:                 }
                    597:             }
                    598:           else if (circuit->circ_type == CIRCUIT_T_P2P &&
                    599:                    circuit->u.p2p.neighbor)
                    600:             {
                    601:               adj = circuit->u.p2p.neighbor;
                    602:               if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
                    603:                 isis_adj_print_vty (adj, vty, detail);
                    604:             }
                    605:         }
                    606:     }
                    607: 
                    608:   return CMD_SUCCESS;
                    609: }
                    610: 
                    611: /*
                    612:  * 'clear isis neighbor' command
                    613:  */
                    614: int
                    615: clear_isis_neighbor_common (struct vty *vty, const char *id)
                    616: {
                    617:   struct listnode *anode, *cnode, *cnextnode, *node, *nnode;
                    618:   struct isis_area *area;
                    619:   struct isis_circuit *circuit;
                    620:   struct list *adjdb;
                    621:   struct isis_adjacency *adj;
                    622:   struct isis_dynhn *dynhn;
                    623:   u_char sysid[ISIS_SYS_ID_LEN];
                    624:   int i;
                    625: 
                    626:   if (!isis)
                    627:     {
                    628:       vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
                    629:       return CMD_SUCCESS;
                    630:     }
                    631: 
                    632:   memset (sysid, 0, ISIS_SYS_ID_LEN);
                    633:   if (id)
                    634:     {
                    635:       if (sysid2buff (sysid, id) == 0)
                    636:         {
                    637:           dynhn = dynhn_find_by_name (id);
                    638:           if (dynhn == NULL)
                    639:             {
                    640:               vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
                    641:               return CMD_SUCCESS;
                    642:             }
                    643:           memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
                    644:         }
                    645:     }
                    646: 
                    647:   for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
                    648:     {
                    649:       for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnextnode, circuit))
                    650:         {
                    651:           if (circuit->circ_type == CIRCUIT_T_BROADCAST)
                    652:             {
                    653:               for (i = 0; i < 2; i++)
                    654:                 {
                    655:                   adjdb = circuit->u.bc.adjdb[i];
                    656:                   if (adjdb && adjdb->count)
                    657:                     {
                    658:                       for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj))
                    659:                         if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
                    660:                           isis_adj_state_change (adj, ISIS_ADJ_DOWN,
                    661:                                                  "clear user request");
                    662:                     }
                    663:                 }
                    664:             }
                    665:           else if (circuit->circ_type == CIRCUIT_T_P2P &&
                    666:                    circuit->u.p2p.neighbor)
                    667:             {
                    668:               adj = circuit->u.p2p.neighbor;
                    669:               if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
                    670:                 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
                    671:                                        "clear user request");
                    672:             }
                    673:         }
                    674:     }
                    675: 
                    676:   return CMD_SUCCESS;
                    677: }
                    678: 
                    679: DEFUN (show_isis_neighbor,
                    680:        show_isis_neighbor_cmd,
                    681:        "show isis neighbor",
                    682:        SHOW_STR
                    683:        "ISIS network information\n"
                    684:        "ISIS neighbor adjacencies\n")
1.1       misho     685: {
1.1.1.2   misho     686:   return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
1.1       misho     687: }
                    688: 
1.1.1.2   misho     689: DEFUN (show_isis_neighbor_detail,
                    690:        show_isis_neighbor_detail_cmd,
                    691:        "show isis neighbor detail",
1.1       misho     692:        SHOW_STR
1.1.1.2   misho     693:        "ISIS network information\n"
                    694:        "ISIS neighbor adjacencies\n"
1.1       misho     695:        "show detailed information\n")
1.1.1.2   misho     696: {
                    697:   return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
                    698: }
                    699: 
                    700: DEFUN (show_isis_neighbor_arg,
                    701:        show_isis_neighbor_arg_cmd,
                    702:        "show isis neighbor WORD",
                    703:        SHOW_STR
                    704:        "ISIS network information\n"
                    705:        "ISIS neighbor adjacencies\n"
                    706:        "System id\n")
                    707: {
                    708:   return show_isis_neighbor_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
                    709: }
                    710: 
                    711: DEFUN (clear_isis_neighbor,
                    712:        clear_isis_neighbor_cmd,
                    713:        "clear isis neighbor",
                    714:        CLEAR_STR
                    715:        "Reset ISIS network information\n"
                    716:        "Reset ISIS neighbor adjacencies\n")
                    717: {
                    718:   return clear_isis_neighbor_common (vty, NULL);
                    719: }
                    720: 
                    721: DEFUN (clear_isis_neighbor_arg,
                    722:        clear_isis_neighbor_arg_cmd,
                    723:        "clear isis neighbor WORD",
                    724:        CLEAR_STR
                    725:        "ISIS network information\n"
                    726:        "ISIS neighbor adjacencies\n"
                    727:        "System id\n")
                    728: {
                    729:   return clear_isis_neighbor_common (vty, argv[0]);
                    730: }
                    731: 
1.1       misho     732: /*
                    733:  * 'isis debug', 'show debugging'
                    734:  */
                    735: void
                    736: print_debug (struct vty *vty, int flags, int onoff)
                    737: {
                    738:   char onoffs[4];
                    739:   if (onoff)
                    740:     strcpy (onoffs, "on");
                    741:   else
                    742:     strcpy (onoffs, "off");
                    743: 
                    744:   if (flags & DEBUG_ADJ_PACKETS)
                    745:     vty_out (vty, "IS-IS Adjacency related packets debugging is %s%s", onoffs,
                    746:             VTY_NEWLINE);
                    747:   if (flags & DEBUG_CHECKSUM_ERRORS)
                    748:     vty_out (vty, "IS-IS checksum errors debugging is %s%s", onoffs,
                    749:             VTY_NEWLINE);
                    750:   if (flags & DEBUG_LOCAL_UPDATES)
                    751:     vty_out (vty, "IS-IS local updates debugging is %s%s", onoffs,
                    752:             VTY_NEWLINE);
                    753:   if (flags & DEBUG_PROTOCOL_ERRORS)
                    754:     vty_out (vty, "IS-IS protocol errors debugging is %s%s", onoffs,
                    755:             VTY_NEWLINE);
                    756:   if (flags & DEBUG_SNP_PACKETS)
                    757:     vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s%s", onoffs,
                    758:             VTY_NEWLINE);
                    759:   if (flags & DEBUG_SPF_EVENTS)
                    760:     vty_out (vty, "IS-IS SPF events debugging is %s%s", onoffs, VTY_NEWLINE);
                    761:   if (flags & DEBUG_SPF_STATS)
                    762:     vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s%s",
                    763:             onoffs, VTY_NEWLINE);
                    764:   if (flags & DEBUG_SPF_TRIGGERS)
                    765:     vty_out (vty, "IS-IS SPF triggering events debugging is %s%s", onoffs,
                    766:             VTY_NEWLINE);
                    767:   if (flags & DEBUG_UPDATE_PACKETS)
                    768:     vty_out (vty, "IS-IS Update related packet debugging is %s%s", onoffs,
                    769:             VTY_NEWLINE);
                    770:   if (flags & DEBUG_RTE_EVENTS)
                    771:     vty_out (vty, "IS-IS Route related debuggin is %s%s", onoffs,
                    772:             VTY_NEWLINE);
                    773:   if (flags & DEBUG_EVENTS)
                    774:     vty_out (vty, "IS-IS Event debugging is %s%s", onoffs, VTY_NEWLINE);
1.1.1.2   misho     775:   if (flags & DEBUG_PACKET_DUMP)
                    776:     vty_out (vty, "IS-IS Packet dump debugging is %s%s", onoffs, VTY_NEWLINE);
1.1.1.4 ! misho     777:   if (flags & DEBUG_LSP_GEN)
        !           778:     vty_out (vty, "IS-IS LSP generation debugging is %s%s", onoffs, VTY_NEWLINE);
        !           779:   if (flags & DEBUG_LSP_SCHED)
        !           780:     vty_out (vty, "IS-IS LSP scheduling debugging is %s%s", onoffs, VTY_NEWLINE);
1.1       misho     781: }
                    782: 
                    783: DEFUN (show_debugging,
                    784:        show_debugging_cmd,
                    785:        "show debugging",
                    786:        SHOW_STR
                    787:        "State of each debugging option\n")
                    788: {
                    789:   vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
                    790:   print_debug (vty, isis->debugs, 1);
                    791:   return CMD_SUCCESS;
                    792: }
                    793: 
                    794: /* Debug node. */
                    795: static struct cmd_node debug_node = {
                    796:   DEBUG_NODE,
                    797:   "",
                    798:   1
                    799: };
                    800: 
                    801: static int
                    802: config_write_debug (struct vty *vty)
                    803: {
                    804:   int write = 0;
                    805:   int flags = isis->debugs;
                    806: 
                    807:   if (flags & DEBUG_ADJ_PACKETS)
                    808:     {
                    809:       vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
                    810:       write++;
                    811:     }
                    812:   if (flags & DEBUG_CHECKSUM_ERRORS)
                    813:     {
                    814:       vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
                    815:       write++;
                    816:     }
                    817:   if (flags & DEBUG_LOCAL_UPDATES)
                    818:     {
                    819:       vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
                    820:       write++;
                    821:     }
                    822:   if (flags & DEBUG_PROTOCOL_ERRORS)
                    823:     {
                    824:       vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
                    825:       write++;
                    826:     }
                    827:   if (flags & DEBUG_SNP_PACKETS)
                    828:     {
                    829:       vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
                    830:       write++;
                    831:     }
                    832:   if (flags & DEBUG_SPF_EVENTS)
                    833:     {
                    834:       vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
                    835:       write++;
                    836:     }
                    837:   if (flags & DEBUG_SPF_STATS)
                    838:     {
                    839:       vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
                    840:       write++;
                    841:     }
                    842:   if (flags & DEBUG_SPF_TRIGGERS)
                    843:     {
                    844:       vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
                    845:       write++;
                    846:     }
                    847:   if (flags & DEBUG_UPDATE_PACKETS)
                    848:     {
                    849:       vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
                    850:       write++;
                    851:     }
                    852:   if (flags & DEBUG_RTE_EVENTS)
                    853:     {
                    854:       vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
                    855:       write++;
                    856:     }
                    857:   if (flags & DEBUG_EVENTS)
                    858:     {
                    859:       vty_out (vty, "debug isis events%s", VTY_NEWLINE);
                    860:       write++;
                    861:     }
1.1.1.2   misho     862:   if (flags & DEBUG_PACKET_DUMP)
                    863:     {
                    864:       vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE);
                    865:       write++;
                    866:     }
1.1.1.4 ! misho     867:   if (flags & DEBUG_LSP_GEN)
        !           868:     {
        !           869:       vty_out (vty, "debug isis lsp-gen%s", VTY_NEWLINE);
        !           870:       write++;
        !           871:     }
        !           872:   if (flags & DEBUG_LSP_SCHED)
        !           873:     {
        !           874:       vty_out (vty, "debug isis lsp-sched%s", VTY_NEWLINE);
        !           875:       write++;
        !           876:     }
1.1       misho     877: 
                    878:   return write;
                    879: }
                    880: 
                    881: DEFUN (debug_isis_adj,
                    882:        debug_isis_adj_cmd,
                    883:        "debug isis adj-packets",
                    884:        DEBUG_STR
                    885:        "IS-IS information\n"
                    886:        "IS-IS Adjacency related packets\n")
                    887: {
                    888:   isis->debugs |= DEBUG_ADJ_PACKETS;
                    889:   print_debug (vty, DEBUG_ADJ_PACKETS, 1);
                    890: 
                    891:   return CMD_SUCCESS;
                    892: }
                    893: 
                    894: DEFUN (no_debug_isis_adj,
                    895:        no_debug_isis_adj_cmd,
                    896:        "no debug isis adj-packets",
                    897:        UNDEBUG_STR
                    898:        "IS-IS information\n"
                    899:        "IS-IS Adjacency related packets\n")
                    900: {
                    901:   isis->debugs &= ~DEBUG_ADJ_PACKETS;
                    902:   print_debug (vty, DEBUG_ADJ_PACKETS, 0);
                    903: 
                    904:   return CMD_SUCCESS;
                    905: }
                    906: 
                    907: DEFUN (debug_isis_csum,
                    908:        debug_isis_csum_cmd,
                    909:        "debug isis checksum-errors",
                    910:        DEBUG_STR
                    911:        "IS-IS information\n"
                    912:        "IS-IS LSP checksum errors\n")
                    913: {
                    914:   isis->debugs |= DEBUG_CHECKSUM_ERRORS;
                    915:   print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1);
                    916: 
                    917:   return CMD_SUCCESS;
                    918: }
                    919: 
                    920: DEFUN (no_debug_isis_csum,
                    921:        no_debug_isis_csum_cmd,
                    922:        "no debug isis checksum-errors",
                    923:        UNDEBUG_STR
                    924:        "IS-IS information\n"
                    925:        "IS-IS LSP checksum errors\n")
                    926: {
                    927:   isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
                    928:   print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
                    929: 
                    930:   return CMD_SUCCESS;
                    931: }
                    932: 
                    933: DEFUN (debug_isis_lupd,
                    934:        debug_isis_lupd_cmd,
                    935:        "debug isis local-updates",
                    936:        DEBUG_STR
                    937:        "IS-IS information\n"
                    938:        "IS-IS local update packets\n")
                    939: {
                    940:   isis->debugs |= DEBUG_LOCAL_UPDATES;
                    941:   print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
                    942: 
                    943:   return CMD_SUCCESS;
                    944: }
                    945: 
                    946: DEFUN (no_debug_isis_lupd,
                    947:        no_debug_isis_lupd_cmd,
                    948:        "no debug isis local-updates",
                    949:        UNDEBUG_STR
                    950:        "IS-IS information\n"
                    951:        "IS-IS local update packets\n")
                    952: {
                    953:   isis->debugs &= ~DEBUG_LOCAL_UPDATES;
                    954:   print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
                    955: 
                    956:   return CMD_SUCCESS;
                    957: }
                    958: 
                    959: DEFUN (debug_isis_err,
                    960:        debug_isis_err_cmd,
                    961:        "debug isis protocol-errors",
                    962:        DEBUG_STR
                    963:        "IS-IS information\n"
                    964:        "IS-IS LSP protocol errors\n")
                    965: {
                    966:   isis->debugs |= DEBUG_PROTOCOL_ERRORS;
                    967:   print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1);
                    968: 
                    969:   return CMD_SUCCESS;
                    970: }
                    971: 
                    972: DEFUN (no_debug_isis_err,
                    973:        no_debug_isis_err_cmd,
                    974:        "no debug isis protocol-errors",
                    975:        UNDEBUG_STR
                    976:        "IS-IS information\n"
                    977:        "IS-IS LSP protocol errors\n")
                    978: {
                    979:   isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
                    980:   print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
                    981: 
                    982:   return CMD_SUCCESS;
                    983: }
                    984: 
                    985: DEFUN (debug_isis_snp,
                    986:        debug_isis_snp_cmd,
                    987:        "debug isis snp-packets",
                    988:        DEBUG_STR
                    989:        "IS-IS information\n"
                    990:        "IS-IS CSNP/PSNP packets\n")
                    991: {
                    992:   isis->debugs |= DEBUG_SNP_PACKETS;
                    993:   print_debug (vty, DEBUG_SNP_PACKETS, 1);
                    994: 
                    995:   return CMD_SUCCESS;
                    996: }
                    997: 
                    998: DEFUN (no_debug_isis_snp,
                    999:        no_debug_isis_snp_cmd,
                   1000:        "no debug isis snp-packets",
                   1001:        UNDEBUG_STR
                   1002:        "IS-IS information\n"
                   1003:        "IS-IS CSNP/PSNP packets\n")
                   1004: {
                   1005:   isis->debugs &= ~DEBUG_SNP_PACKETS;
                   1006:   print_debug (vty, DEBUG_SNP_PACKETS, 0);
                   1007: 
                   1008:   return CMD_SUCCESS;
                   1009: }
                   1010: 
                   1011: DEFUN (debug_isis_upd,
                   1012:        debug_isis_upd_cmd,
                   1013:        "debug isis update-packets",
                   1014:        DEBUG_STR
                   1015:        "IS-IS information\n"
                   1016:        "IS-IS Update related packets\n")
                   1017: {
                   1018:   isis->debugs |= DEBUG_UPDATE_PACKETS;
                   1019:   print_debug (vty, DEBUG_UPDATE_PACKETS, 1);
                   1020: 
                   1021:   return CMD_SUCCESS;
                   1022: }
                   1023: 
                   1024: DEFUN (no_debug_isis_upd,
                   1025:        no_debug_isis_upd_cmd,
                   1026:        "no debug isis update-packets",
                   1027:        UNDEBUG_STR
                   1028:        "IS-IS information\n"
                   1029:        "IS-IS Update related packets\n")
                   1030: {
                   1031:   isis->debugs &= ~DEBUG_UPDATE_PACKETS;
                   1032:   print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
                   1033: 
                   1034:   return CMD_SUCCESS;
                   1035: }
                   1036: 
                   1037: DEFUN (debug_isis_spfevents,
                   1038:        debug_isis_spfevents_cmd,
                   1039:        "debug isis spf-events",
                   1040:        DEBUG_STR
                   1041:        "IS-IS information\n"
                   1042:        "IS-IS Shortest Path First Events\n")
                   1043: {
                   1044:   isis->debugs |= DEBUG_SPF_EVENTS;
                   1045:   print_debug (vty, DEBUG_SPF_EVENTS, 1);
                   1046: 
                   1047:   return CMD_SUCCESS;
                   1048: }
                   1049: 
                   1050: DEFUN (no_debug_isis_spfevents,
                   1051:        no_debug_isis_spfevents_cmd,
                   1052:        "no debug isis spf-events",
                   1053:        UNDEBUG_STR
                   1054:        "IS-IS information\n"
                   1055:        "IS-IS Shortest Path First Events\n")
                   1056: {
                   1057:   isis->debugs &= ~DEBUG_SPF_EVENTS;
                   1058:   print_debug (vty, DEBUG_SPF_EVENTS, 0);
                   1059: 
                   1060:   return CMD_SUCCESS;
                   1061: }
                   1062: 
                   1063: DEFUN (debug_isis_spfstats,
                   1064:        debug_isis_spfstats_cmd,
                   1065:        "debug isis spf-statistics ",
                   1066:        DEBUG_STR
                   1067:        "IS-IS information\n"
                   1068:        "IS-IS SPF Timing and Statistic Data\n")
                   1069: {
                   1070:   isis->debugs |= DEBUG_SPF_STATS;
                   1071:   print_debug (vty, DEBUG_SPF_STATS, 1);
                   1072: 
                   1073:   return CMD_SUCCESS;
                   1074: }
                   1075: 
                   1076: DEFUN (no_debug_isis_spfstats,
                   1077:        no_debug_isis_spfstats_cmd,
                   1078:        "no debug isis spf-statistics",
                   1079:        UNDEBUG_STR
                   1080:        "IS-IS information\n"
                   1081:        "IS-IS SPF Timing and Statistic Data\n")
                   1082: {
                   1083:   isis->debugs &= ~DEBUG_SPF_STATS;
                   1084:   print_debug (vty, DEBUG_SPF_STATS, 0);
                   1085: 
                   1086:   return CMD_SUCCESS;
                   1087: }
                   1088: 
                   1089: DEFUN (debug_isis_spftrigg,
                   1090:        debug_isis_spftrigg_cmd,
                   1091:        "debug isis spf-triggers",
                   1092:        DEBUG_STR
                   1093:        "IS-IS information\n"
                   1094:        "IS-IS SPF triggering events\n")
                   1095: {
                   1096:   isis->debugs |= DEBUG_SPF_TRIGGERS;
                   1097:   print_debug (vty, DEBUG_SPF_TRIGGERS, 1);
                   1098: 
                   1099:   return CMD_SUCCESS;
                   1100: }
                   1101: 
                   1102: DEFUN (no_debug_isis_spftrigg,
                   1103:        no_debug_isis_spftrigg_cmd,
                   1104:        "no debug isis spf-triggers",
                   1105:        UNDEBUG_STR
                   1106:        "IS-IS information\n"
                   1107:        "IS-IS SPF triggering events\n")
                   1108: {
                   1109:   isis->debugs &= ~DEBUG_SPF_TRIGGERS;
                   1110:   print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
                   1111: 
                   1112:   return CMD_SUCCESS;
                   1113: }
                   1114: 
                   1115: DEFUN (debug_isis_rtevents,
                   1116:        debug_isis_rtevents_cmd,
                   1117:        "debug isis route-events",
                   1118:        DEBUG_STR
                   1119:        "IS-IS information\n"
                   1120:        "IS-IS Route related events\n")
                   1121: {
                   1122:   isis->debugs |= DEBUG_RTE_EVENTS;
                   1123:   print_debug (vty, DEBUG_RTE_EVENTS, 1);
                   1124: 
                   1125:   return CMD_SUCCESS;
                   1126: }
                   1127: 
                   1128: DEFUN (no_debug_isis_rtevents,
                   1129:        no_debug_isis_rtevents_cmd,
                   1130:        "no debug isis route-events",
                   1131:        UNDEBUG_STR
                   1132:        "IS-IS information\n"
                   1133:        "IS-IS Route related events\n")
                   1134: {
                   1135:   isis->debugs &= ~DEBUG_RTE_EVENTS;
                   1136:   print_debug (vty, DEBUG_RTE_EVENTS, 0);
                   1137: 
                   1138:   return CMD_SUCCESS;
                   1139: }
                   1140: 
                   1141: DEFUN (debug_isis_events,
                   1142:        debug_isis_events_cmd,
                   1143:        "debug isis events",
                   1144:        DEBUG_STR
                   1145:        "IS-IS information\n"
                   1146:        "IS-IS Events\n")
                   1147: {
                   1148:   isis->debugs |= DEBUG_EVENTS;
                   1149:   print_debug (vty, DEBUG_EVENTS, 1);
                   1150: 
                   1151:   return CMD_SUCCESS;
                   1152: }
                   1153: 
                   1154: DEFUN (no_debug_isis_events,
                   1155:        no_debug_isis_events_cmd,
                   1156:        "no debug isis events",
                   1157:        UNDEBUG_STR
                   1158:        "IS-IS information\n"
                   1159:        "IS-IS Events\n")
                   1160: {
                   1161:   isis->debugs &= ~DEBUG_EVENTS;
                   1162:   print_debug (vty, DEBUG_EVENTS, 0);
                   1163: 
                   1164:   return CMD_SUCCESS;
                   1165: }
                   1166: 
1.1.1.2   misho    1167: DEFUN (debug_isis_packet_dump,
                   1168:        debug_isis_packet_dump_cmd,
                   1169:        "debug isis packet-dump",
                   1170:        DEBUG_STR
                   1171:        "IS-IS information\n"
                   1172:        "IS-IS packet dump\n")
                   1173: {
                   1174:   isis->debugs |= DEBUG_PACKET_DUMP;
                   1175:   print_debug (vty, DEBUG_PACKET_DUMP, 1);
                   1176: 
                   1177:   return CMD_SUCCESS;
                   1178: }
                   1179: 
                   1180: DEFUN (no_debug_isis_packet_dump,
                   1181:        no_debug_isis_packet_dump_cmd,
                   1182:        "no debug isis packet-dump",
                   1183:        UNDEBUG_STR
                   1184:        "IS-IS information\n"
                   1185:        "IS-IS packet dump\n")
                   1186: {
                   1187:   isis->debugs &= ~DEBUG_PACKET_DUMP;
                   1188:   print_debug (vty, DEBUG_PACKET_DUMP, 0);
                   1189: 
                   1190:   return CMD_SUCCESS;
                   1191: }
                   1192: 
1.1.1.4 ! misho    1193: DEFUN (debug_isis_lsp_gen,
        !          1194:        debug_isis_lsp_gen_cmd,
        !          1195:        "debug isis lsp-gen",
        !          1196:        DEBUG_STR
        !          1197:        "IS-IS information\n"
        !          1198:        "IS-IS generation of own LSPs\n")
        !          1199: {
        !          1200:   isis->debugs |= DEBUG_LSP_GEN;
        !          1201:   print_debug (vty, DEBUG_LSP_GEN, 1);
        !          1202: 
        !          1203:   return CMD_SUCCESS;
        !          1204: }
        !          1205: 
        !          1206: DEFUN (no_debug_isis_lsp_gen,
        !          1207:        no_debug_isis_lsp_gen_cmd,
        !          1208:        "no debug isis lsp-gen",
        !          1209:        UNDEBUG_STR
        !          1210:        "IS-IS information\n"
        !          1211:        "IS-IS generation of own LSPs\n")
        !          1212: {
        !          1213:   isis->debugs &= ~DEBUG_LSP_GEN;
        !          1214:   print_debug (vty, DEBUG_LSP_GEN, 0);
        !          1215: 
        !          1216:   return CMD_SUCCESS;
        !          1217: }
        !          1218: 
        !          1219: DEFUN (debug_isis_lsp_sched,
        !          1220:        debug_isis_lsp_sched_cmd,
        !          1221:        "debug isis lsp-sched",
        !          1222:        DEBUG_STR
        !          1223:        "IS-IS information\n"
        !          1224:        "IS-IS scheduling of LSP generation\n")
        !          1225: {
        !          1226:   isis->debugs |= DEBUG_LSP_SCHED;
        !          1227:   print_debug (vty, DEBUG_LSP_SCHED, 1);
        !          1228: 
        !          1229:   return CMD_SUCCESS;
        !          1230: }
        !          1231: 
        !          1232: DEFUN (no_debug_isis_lsp_sched,
        !          1233:        no_debug_isis_lsp_sched_cmd,
        !          1234:        "no debug isis lsp-gen",
        !          1235:        UNDEBUG_STR
        !          1236:        "IS-IS information\n"
        !          1237:        "IS-IS scheduling of LSP generation\n")
        !          1238: {
        !          1239:   isis->debugs &= ~DEBUG_LSP_SCHED;
        !          1240:   print_debug (vty, DEBUG_LSP_SCHED, 0);
        !          1241: 
        !          1242:   return CMD_SUCCESS;
        !          1243: }
        !          1244: 
1.1       misho    1245: DEFUN (show_hostname,
                   1246:        show_hostname_cmd,
                   1247:        "show isis hostname",
                   1248:        SHOW_STR
                   1249:        "IS-IS information\n"
                   1250:        "IS-IS Dynamic hostname mapping\n")
                   1251: {
                   1252:   dynhn_print_all (vty);
                   1253: 
                   1254:   return CMD_SUCCESS;
                   1255: }
                   1256: 
1.1.1.2   misho    1257: static void
                   1258: vty_out_timestr(struct vty *vty, time_t uptime)
1.1       misho    1259: {
1.1.1.2   misho    1260:   struct tm *tm;
                   1261:   time_t difftime = time (NULL);
                   1262:   difftime -= uptime;
                   1263:   tm = gmtime (&difftime);
                   1264: 
                   1265: #define ONE_DAY_SECOND 60*60*24
                   1266: #define ONE_WEEK_SECOND 60*60*24*7
                   1267:   if (difftime < ONE_DAY_SECOND)
                   1268:     vty_out (vty,  "%02d:%02d:%02d", 
                   1269:         tm->tm_hour, tm->tm_min, tm->tm_sec);
                   1270:   else if (difftime < ONE_WEEK_SECOND)
                   1271:     vty_out (vty, "%dd%02dh%02dm", 
                   1272:         tm->tm_yday, tm->tm_hour, tm->tm_min);
                   1273:   else
                   1274:     vty_out (vty, "%02dw%dd%02dh", 
                   1275:         tm->tm_yday/7,
                   1276:         tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
                   1277:   vty_out (vty, " ago");
                   1278: }
                   1279: 
                   1280: DEFUN (show_isis_summary,
                   1281:        show_isis_summary_cmd,
                   1282:        "show isis summary",
                   1283:        SHOW_STR "IS-IS information\n" "IS-IS summary\n")
                   1284: {
                   1285:   struct listnode *node, *node2;
1.1       misho    1286:   struct isis_area *area;
1.1.1.2   misho    1287:   struct isis_spftree *spftree;
                   1288:   int level;
1.1       misho    1289: 
1.1.1.2   misho    1290:   if (isis == NULL)
                   1291:   {
                   1292:     vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
1.1       misho    1293:     return CMD_SUCCESS;
1.1.1.2   misho    1294:   }
                   1295: 
                   1296:   vty_out (vty, "Process Id      : %ld%s", isis->process_id,
                   1297:       VTY_NEWLINE);
                   1298:   if (isis->sysid_set)
                   1299:     vty_out (vty, "System Id       : %s%s", sysid_print (isis->sysid),
                   1300:         VTY_NEWLINE);
                   1301: 
                   1302:   vty_out (vty, "Up time         : ");
                   1303:   vty_out_timestr(vty, isis->uptime);
                   1304:   vty_out (vty, "%s", VTY_NEWLINE);
                   1305: 
                   1306:   if (isis->area_list)
                   1307:     vty_out (vty, "Number of areas : %d%s", isis->area_list->count,
                   1308:         VTY_NEWLINE);
1.1       misho    1309: 
                   1310:   for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1.1.1.2   misho    1311:   {
                   1312:     vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
                   1313:         VTY_NEWLINE);
                   1314: 
                   1315:     if (listcount (area->area_addrs) > 0)
1.1       misho    1316:     {
1.1.1.2   misho    1317:       struct area_addr *area_addr;
                   1318:       for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
                   1319:       {
                   1320:         vty_out (vty, "  Net: %s%s",
                   1321:             isonet_print (area_addr->area_addr,
                   1322:               area_addr->addr_len + ISIS_SYS_ID_LEN +
                   1323:               1), VTY_NEWLINE);
                   1324:       }
                   1325:     }
                   1326: 
                   1327:     for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
                   1328:     {
                   1329:       if ((area->is_type & level) == 0)
                   1330:         continue;
1.1       misho    1331: 
1.1.1.2   misho    1332:       vty_out (vty, "  Level-%d:%s", level, VTY_NEWLINE);
                   1333:       spftree = area->spftree[level - 1];
                   1334:       if (spftree->pending)
                   1335:         vty_out (vty, "    IPv4 SPF: (pending)%s", VTY_NEWLINE);
                   1336:       else
                   1337:         vty_out (vty, "    IPv4 SPF:%s", VTY_NEWLINE);
1.1       misho    1338: 
1.1.1.2   misho    1339:       vty_out (vty, "      minimum interval  : %d%s",
                   1340:           area->min_spf_interval[level - 1], VTY_NEWLINE);
                   1341: 
                   1342:       vty_out (vty, "      last run elapsed  : ");
                   1343:       vty_out_timestr(vty, spftree->last_run_timestamp);
                   1344:       vty_out (vty, "%s", VTY_NEWLINE);
                   1345: 
                   1346:       vty_out (vty, "      last run duration : %u usec%s",
                   1347:                (u_int32_t)spftree->last_run_duration, VTY_NEWLINE);
                   1348: 
                   1349:       vty_out (vty, "      run count         : %d%s",
                   1350:           spftree->runcount, VTY_NEWLINE);
                   1351: 
                   1352: #ifdef HAVE_IPV6
                   1353:       spftree = area->spftree6[level - 1];
                   1354:       if (spftree->pending)
                   1355:         vty_out (vty, "    IPv6 SPF: (pending)%s", VTY_NEWLINE);
                   1356:       else
                   1357:         vty_out (vty, "    IPv6 SPF:%s", VTY_NEWLINE);
                   1358: 
                   1359:       vty_out (vty, "      minimum interval  : %d%s",
                   1360:           area->min_spf_interval[level - 1], VTY_NEWLINE);
                   1361: 
                   1362:       vty_out (vty, "      last run elapsed  : ");
                   1363:       vty_out_timestr(vty, spftree->last_run_timestamp);
                   1364:       vty_out (vty, "%s", VTY_NEWLINE);
                   1365: 
1.1.1.4 ! misho    1366:       vty_out (vty, "      last run duration : %llu msec%s",
        !          1367:                (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
1.1.1.2   misho    1368: 
                   1369:       vty_out (vty, "      run count         : %d%s",
                   1370:           spftree->runcount, VTY_NEWLINE);
                   1371: #endif
1.1       misho    1372:     }
1.1.1.2   misho    1373:   }
                   1374:   vty_out (vty, "%s", VTY_NEWLINE);
1.1       misho    1375: 
                   1376:   return CMD_SUCCESS;
                   1377: }
                   1378: 
1.1.1.2   misho    1379: /*
                   1380:  * This function supports following display options:
                   1381:  * [ show isis database [detail] ]
                   1382:  * [ show isis database <sysid> [detail] ]
                   1383:  * [ show isis database <hostname> [detail] ]
                   1384:  * [ show isis database <sysid>.<pseudo-id> [detail] ]
                   1385:  * [ show isis database <hostname>.<pseudo-id> [detail] ]
                   1386:  * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
                   1387:  * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
                   1388:  * [ show isis database detail <sysid> ]
                   1389:  * [ show isis database detail <hostname> ]
                   1390:  * [ show isis database detail <sysid>.<pseudo-id> ]
                   1391:  * [ show isis database detail <hostname>.<pseudo-id> ]
                   1392:  * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
                   1393:  * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
                   1394:  */
                   1395: static int
                   1396: show_isis_database (struct vty *vty, const char *argv, int ui_level)
1.1       misho    1397: {
                   1398:   struct listnode *node;
                   1399:   struct isis_area *area;
1.1.1.2   misho    1400:   struct isis_lsp *lsp;
                   1401:   struct isis_dynhn *dynhn;
                   1402:   const char *pos = argv;
                   1403:   u_char lspid[ISIS_SYS_ID_LEN+2];
                   1404:   char sysid[255];
                   1405:   u_char number[3];
1.1       misho    1406:   int level, lsp_count;
                   1407: 
                   1408:   if (isis->area_list->count == 0)
                   1409:     return CMD_SUCCESS;
                   1410: 
1.1.1.2   misho    1411:   memset (&lspid, 0, ISIS_SYS_ID_LEN);
                   1412:   memset (&sysid, 0, 255);
                   1413: 
                   1414:   /*
                   1415:    * extract fragment and pseudo id from the string argv
                   1416:    * in the forms:
                   1417:    * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
                   1418:    * (b) <systemid/hostname>.<pseudo-id> or
                   1419:    * (c) <systemid/hostname> or
                   1420:    * Where systemid is in the form:
                   1421:    * xxxx.xxxx.xxxx
                   1422:    */
                   1423:   if (argv)
                   1424:      strncpy (sysid, argv, 254);
                   1425:   if (argv && strlen (argv) > 3)
                   1426:     {
                   1427:       pos = argv + strlen (argv) - 3;
                   1428:       if (strncmp (pos, "-", 1) == 0)
                   1429:       {
                   1430:         memcpy (number, ++pos, 2);
                   1431:         lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16);
                   1432:         pos -= 4;
                   1433:         if (strncmp (pos, ".", 1) != 0)
                   1434:           return CMD_ERR_AMBIGUOUS;
                   1435:       }
                   1436:       if (strncmp (pos, ".", 1) == 0)
                   1437:       {
                   1438:         memcpy (number, ++pos, 2);
                   1439:         lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16);
                   1440:         sysid[pos - argv - 1] = '\0';
                   1441:       }
                   1442:     }
                   1443: 
1.1       misho    1444:   for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
                   1445:     {
                   1446:       vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1.1.1.2   misho    1447:                VTY_NEWLINE);
1.1       misho    1448: 
1.1.1.2   misho    1449:       for (level = 0; level < ISIS_LEVELS; level++)
                   1450:         {
                   1451:           if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
                   1452:             {
                   1453:               lsp = NULL;
                   1454:               if (argv != NULL)
                   1455:                 {
                   1456:                   /*
                   1457:                    * Try to find the lsp-id if the argv string is in
                   1458:                    * the form hostname.<pseudo-id>-<fragment>
                   1459:                    */
                   1460:                   if (sysid2buff (lspid, sysid))
                   1461:                     {
                   1462:                       lsp = lsp_search (lspid, area->lspdb[level]);
                   1463:                     }
                   1464:                   else if ((dynhn = dynhn_find_by_name (sysid)))
                   1465:                     {
                   1466:                       memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN);
                   1467:                       lsp = lsp_search (lspid, area->lspdb[level]);
                   1468:                     }
                   1469:                   else if (strncmp(unix_hostname (), sysid, 15) == 0)
                   1470:                     {
                   1471:                       memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
                   1472:                       lsp = lsp_search (lspid, area->lspdb[level]);
                   1473:                     }
                   1474:                 }
                   1475: 
                   1476:               if (lsp != NULL || argv == NULL)
                   1477:                 {
                   1478:                   vty_out (vty, "IS-IS Level-%d link-state database:%s",
                   1479:                            level + 1, VTY_NEWLINE);
                   1480: 
                   1481:                   /* print the title in all cases */
                   1482:                   vty_out (vty, "LSP ID                  PduLen  "
                   1483:                            "SeqNumber   Chksum  Holdtime  ATT/P/OL%s",
                   1484:                            VTY_NEWLINE);
                   1485:                 }
                   1486: 
                   1487:               if (lsp)
                   1488:                 {
                   1489:                   if (ui_level == ISIS_UI_LEVEL_DETAIL)
                   1490:                     lsp_print_detail (lsp, vty, area->dynhostname);
                   1491:                   else
                   1492:                     lsp_print (lsp, vty, area->dynhostname);
                   1493:                 }
                   1494:               else if (argv == NULL)
                   1495:                 {
                   1496:                   lsp_count = lsp_print_all (vty, area->lspdb[level],
                   1497:                                              ui_level,
                   1498:                                              area->dynhostname);
                   1499: 
                   1500:                   vty_out (vty, "    %u LSPs%s%s",
                   1501:                            lsp_count, VTY_NEWLINE, VTY_NEWLINE);
                   1502:                 }
                   1503:             }
                   1504:         }
1.1       misho    1505:     }
                   1506: 
                   1507:   return CMD_SUCCESS;
                   1508: }
                   1509: 
1.1.1.2   misho    1510: DEFUN (show_database_brief,
                   1511:        show_database_cmd,
                   1512:        "show isis database",
                   1513:        SHOW_STR
                   1514:        "IS-IS information\n"
                   1515:        "IS-IS link state database\n")
1.1       misho    1516: {
1.1.1.2   misho    1517:   return show_isis_database (vty, NULL, ISIS_UI_LEVEL_BRIEF);
1.1       misho    1518: }
                   1519: 
1.1.1.2   misho    1520: DEFUN (show_database_lsp_brief,
                   1521:        show_database_arg_cmd,
                   1522:        "show isis database WORD",
                   1523:        SHOW_STR
                   1524:        "IS-IS information\n"
                   1525:        "IS-IS link state database\n"
                   1526:        "LSP ID\n")
1.1       misho    1527: {
1.1.1.2   misho    1528:   return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_BRIEF);
1.1       misho    1529: }
                   1530: 
1.1.1.2   misho    1531: DEFUN (show_database_lsp_detail,
                   1532:        show_database_arg_detail_cmd,
                   1533:        "show isis database WORD detail",
                   1534:        SHOW_STR
                   1535:        "IS-IS information\n"
                   1536:        "IS-IS link state database\n"
                   1537:        "LSP ID\n"
                   1538:        "Detailed information\n")
                   1539: {
                   1540:   return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
                   1541: }
                   1542: 
                   1543: DEFUN (show_database_detail,
                   1544:        show_database_detail_cmd,
                   1545:        "show isis database detail",
                   1546:        SHOW_STR
                   1547:        "IS-IS information\n"
                   1548:        "IS-IS link state database\n")
                   1549: {
                   1550:   return show_isis_database (vty, NULL, ISIS_UI_LEVEL_DETAIL);
                   1551: }
                   1552: 
                   1553: DEFUN (show_database_detail_lsp,
                   1554:        show_database_detail_arg_cmd,
                   1555:        "show isis database detail WORD",
                   1556:        SHOW_STR
                   1557:        "IS-IS information\n"
                   1558:        "IS-IS link state database\n"
                   1559:        "Detailed information\n"
                   1560:        "LSP ID\n")
                   1561: {
                   1562:   return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
                   1563: }
                   1564: 
                   1565: /* 
                   1566:  * 'router isis' command 
                   1567:  */
                   1568: DEFUN (router_isis,
                   1569:        router_isis_cmd,
                   1570:        "router isis WORD",
                   1571:        ROUTER_STR
                   1572:        "ISO IS-IS\n"
                   1573:        "ISO Routing area tag")
                   1574: {
                   1575:   return isis_area_get (vty, argv[0]);
                   1576: }
                   1577: 
                   1578: /* 
                   1579:  *'no router isis' command 
                   1580:  */
                   1581: DEFUN (no_router_isis,
                   1582:        no_router_isis_cmd,
                   1583:        "no router isis WORD",
                   1584:        "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
                   1585: {
                   1586:   return isis_area_destroy (vty, argv[0]);
                   1587: }
                   1588: 
                   1589: /*
                   1590:  * 'net' command
1.1       misho    1591:  */
                   1592: DEFUN (net,
                   1593:        net_cmd,
                   1594:        "net WORD",
                   1595:        "A Network Entity Title for this process (OSI only)\n"
                   1596:        "XX.XXXX. ... .XXX.XX  Network entity title (NET)\n")
                   1597: {
                   1598:   return area_net_title (vty, argv[0]);
                   1599: }
                   1600: 
                   1601: /*
                   1602:  * 'no net' command
                   1603:  */
                   1604: DEFUN (no_net,
                   1605:        no_net_cmd,
                   1606:        "no net WORD",
                   1607:        NO_STR
                   1608:        "A Network Entity Title for this process (OSI only)\n"
                   1609:        "XX.XXXX. ... .XXX.XX  Network entity title (NET)\n")
                   1610: {
                   1611:   return area_clear_net_title (vty, argv[0]);
                   1612: }
                   1613: 
1.1.1.4 ! misho    1614: static
        !          1615: int area_set_lsp_mtu(struct vty *vty, struct isis_area *area, unsigned int lsp_mtu)
        !          1616: {
        !          1617:   struct isis_circuit *circuit;
        !          1618:   struct listnode *node;
        !          1619: 
        !          1620:   for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
        !          1621:     {
        !          1622:       if(lsp_mtu > isis_circuit_pdu_size(circuit))
        !          1623:         {
        !          1624:           vty_out(vty, "ISIS area contains circuit %s, which has a maximum PDU size of %zu.%s",
        !          1625:                   circuit->interface->name, isis_circuit_pdu_size(circuit),
        !          1626:                   VTY_NEWLINE);
        !          1627:           return CMD_ERR_AMBIGUOUS;
        !          1628:         }
        !          1629:     }
        !          1630: 
        !          1631:   area->lsp_mtu = lsp_mtu;
        !          1632:   lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
        !          1633: 
        !          1634:   return CMD_SUCCESS;
        !          1635: }
        !          1636: 
        !          1637: DEFUN (area_lsp_mtu,
        !          1638:        area_lsp_mtu_cmd,
        !          1639:        "lsp-mtu <128-4352>",
        !          1640:        "Configure the maximum size of generated LSPs\n"
        !          1641:        "Maximum size of generated LSPs\n")
        !          1642: {
        !          1643:   struct isis_area *area;
        !          1644: 
        !          1645:   area = vty->index;
        !          1646:   if (!area)
        !          1647:     {
        !          1648:       vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
        !          1649:       return CMD_ERR_NO_MATCH;
        !          1650:     }
        !          1651: 
        !          1652:   unsigned int lsp_mtu;
        !          1653: 
        !          1654:   VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[0], 128, 4352);
        !          1655: 
        !          1656:   return area_set_lsp_mtu(vty, area, lsp_mtu);
        !          1657: }
        !          1658: 
        !          1659: DEFUN(no_area_lsp_mtu,
        !          1660:       no_area_lsp_mtu_cmd,
        !          1661:       "no lsp-mtu",
        !          1662:       NO_STR
        !          1663:       "Configure the maximum size of generated LSPs\n")
        !          1664: {
        !          1665:   struct isis_area *area;
        !          1666: 
        !          1667:   area = vty->index;
        !          1668:   if (!area)
        !          1669:     {
        !          1670:       vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
        !          1671:       return CMD_ERR_NO_MATCH;
        !          1672:     }
        !          1673: 
        !          1674:   return area_set_lsp_mtu(vty, area, DEFAULT_LSP_MTU);
        !          1675: }
        !          1676: 
        !          1677: ALIAS(no_area_lsp_mtu,
        !          1678:       no_area_lsp_mtu_arg_cmd,
        !          1679:       "no lsp-mtu <128-4352>",
        !          1680:       NO_STR
        !          1681:       "Configure the maximum size of generated LSPs\n"
        !          1682:       "Maximum size of generated LSPs\n");
        !          1683: 
1.1.1.2   misho    1684: DEFUN (area_passwd_md5,
                   1685:        area_passwd_md5_cmd,
                   1686:        "area-password md5 WORD",
                   1687:        "Configure the authentication password for an area\n"
                   1688:        "Authentication type\n"
                   1689:        "Area password\n")
                   1690: {
                   1691:   struct isis_area *area;
                   1692:   int len;
                   1693: 
                   1694:   area = vty->index;
                   1695: 
                   1696:   if (!area)
                   1697:     {
                   1698:       vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
                   1699:       return CMD_ERR_NO_MATCH;
                   1700:     }
                   1701: 
                   1702:   len = strlen (argv[0]);
                   1703:   if (len > 254)
                   1704:     {
                   1705:       vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
                   1706:       return CMD_ERR_AMBIGUOUS;
                   1707:     }
                   1708: 
                   1709:   area->area_passwd.len = (u_char) len;
                   1710:   area->area_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
                   1711:   strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
                   1712: 
                   1713:   if (argc > 1)
                   1714:     {
                   1715:       SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
                   1716:       if (strncmp(argv[1], "v", 1) == 0)
                   1717:        SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
                   1718:       else
                   1719:        UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
                   1720:     }
                   1721:   else
                   1722:     {
                   1723:       UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
                   1724:       UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
                   1725:     }
                   1726:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
                   1727: 
                   1728:   return CMD_SUCCESS;
                   1729: }
                   1730: 
                   1731: ALIAS (area_passwd_md5,
                   1732:        area_passwd_md5_snpauth_cmd,
                   1733:        "area-password md5 WORD authenticate snp (send-only|validate)",
                   1734:        "Configure the authentication password for an area\n"
                   1735:        "Authentication type\n"
                   1736:        "Area password\n"
                   1737:        "Authentication\n"
                   1738:        "SNP PDUs\n"
                   1739:        "Send but do not check PDUs on receiving\n"
1.1.1.4 ! misho    1740:        "Send and check PDUs on receiving\n")
1.1.1.2   misho    1741: 
                   1742: DEFUN (area_passwd_clear,
                   1743:        area_passwd_clear_cmd,
                   1744:        "area-password clear WORD",
1.1       misho    1745:        "Configure the authentication password for an area\n"
1.1.1.2   misho    1746:        "Authentication type\n"
1.1       misho    1747:        "Area password\n")
                   1748: {
                   1749:   struct isis_area *area;
                   1750:   int len;
                   1751: 
                   1752:   area = vty->index;
                   1753: 
                   1754:   if (!area)
                   1755:     {
1.1.1.2   misho    1756:       vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
                   1757:       return CMD_ERR_NO_MATCH;
1.1       misho    1758:     }
                   1759: 
                   1760:   len = strlen (argv[0]);
                   1761:   if (len > 254)
                   1762:     {
                   1763:       vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1.1.1.2   misho    1764:       return CMD_ERR_AMBIGUOUS;
1.1       misho    1765:     }
1.1.1.2   misho    1766: 
1.1       misho    1767:   area->area_passwd.len = (u_char) len;
                   1768:   area->area_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
                   1769:   strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
                   1770: 
                   1771:   if (argc > 1)
                   1772:     {
                   1773:       SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
                   1774:       if (strncmp(argv[1], "v", 1) == 0)
                   1775:        SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
                   1776:       else
                   1777:        UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
                   1778:     }
                   1779:   else
                   1780:     {
                   1781:       UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
                   1782:       UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
                   1783:     }
1.1.1.2   misho    1784:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1.1       misho    1785: 
                   1786:   return CMD_SUCCESS;
                   1787: }
                   1788: 
1.1.1.2   misho    1789: ALIAS (area_passwd_clear,
                   1790:        area_passwd_clear_snpauth_cmd,
                   1791:        "area-password clear WORD authenticate snp (send-only|validate)",
1.1       misho    1792:        "Configure the authentication password for an area\n"
1.1.1.2   misho    1793:        "Authentication type\n"
1.1       misho    1794:        "Area password\n"
                   1795:        "Authentication\n"
                   1796:        "SNP PDUs\n"
                   1797:        "Send but do not check PDUs on receiving\n"
1.1.1.4 ! misho    1798:        "Send and check PDUs on receiving\n")
1.1       misho    1799: 
                   1800: DEFUN (no_area_passwd,
                   1801:        no_area_passwd_cmd,
                   1802:        "no area-password",
                   1803:        NO_STR
                   1804:        "Configure the authentication password for an area\n")
                   1805: {
                   1806:   struct isis_area *area;
                   1807: 
                   1808:   area = vty->index;
                   1809: 
                   1810:   if (!area)
                   1811:     {
1.1.1.2   misho    1812:       vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
                   1813:       return CMD_ERR_NO_MATCH;
1.1       misho    1814:     }
                   1815: 
                   1816:   memset (&area->area_passwd, 0, sizeof (struct isis_passwd));
1.1.1.2   misho    1817:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
                   1818: 
                   1819:   return CMD_SUCCESS;
                   1820: }
                   1821: 
                   1822: DEFUN (domain_passwd_md5,
                   1823:        domain_passwd_md5_cmd,
                   1824:        "domain-password md5 WORD",
                   1825:        "Set the authentication password for a routing domain\n"
                   1826:        "Authentication type\n"
                   1827:        "Routing domain password\n")
                   1828: {
                   1829:   struct isis_area *area;
                   1830:   int len;
                   1831: 
                   1832:   area = vty->index;
                   1833: 
                   1834:   if (!area)
                   1835:     {
                   1836:       vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
                   1837:       return CMD_ERR_NO_MATCH;
                   1838:     }
                   1839: 
                   1840:   len = strlen (argv[0]);
                   1841:   if (len > 254)
                   1842:     {
                   1843:       vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
                   1844:       return CMD_ERR_AMBIGUOUS;
                   1845:     }
                   1846: 
                   1847:   area->domain_passwd.len = (u_char) len;
                   1848:   area->domain_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
                   1849:   strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
                   1850: 
                   1851:   if (argc > 1)
                   1852:     {
                   1853:       SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
                   1854:       if (strncmp(argv[1], "v", 1) == 0)
                   1855:        SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
                   1856:       else
                   1857:        UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
                   1858:     }
                   1859:   else
                   1860:     {
                   1861:       UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
                   1862:       UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
                   1863:     }
                   1864:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1.1       misho    1865: 
                   1866:   return CMD_SUCCESS;
                   1867: }
                   1868: 
1.1.1.2   misho    1869: ALIAS (domain_passwd_md5,
                   1870:        domain_passwd_md5_snpauth_cmd,
                   1871:        "domain-password md5 WORD authenticate snp (send-only|validate)",
                   1872:        "Set the authentication password for a routing domain\n"
                   1873:        "Authentication type\n"
                   1874:        "Routing domain password\n"
                   1875:        "Authentication\n"
                   1876:        "SNP PDUs\n"
                   1877:        "Send but do not check PDUs on receiving\n"
1.1.1.4 ! misho    1878:        "Send and check PDUs on receiving\n")
1.1.1.2   misho    1879: 
                   1880: DEFUN (domain_passwd_clear,
                   1881:        domain_passwd_clear_cmd,
                   1882:        "domain-password clear WORD",
1.1       misho    1883:        "Set the authentication password for a routing domain\n"
1.1.1.2   misho    1884:        "Authentication type\n"
1.1       misho    1885:        "Routing domain password\n")
                   1886: {
                   1887:   struct isis_area *area;
                   1888:   int len;
                   1889: 
                   1890:   area = vty->index;
                   1891: 
                   1892:   if (!area)
                   1893:     {
1.1.1.2   misho    1894:       vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
                   1895:       return CMD_ERR_NO_MATCH;
1.1       misho    1896:     }
                   1897: 
                   1898:   len = strlen (argv[0]);
                   1899:   if (len > 254)
                   1900:     {
                   1901:       vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1.1.1.2   misho    1902:       return CMD_ERR_AMBIGUOUS;
1.1       misho    1903:     }
1.1.1.2   misho    1904: 
1.1       misho    1905:   area->domain_passwd.len = (u_char) len;
                   1906:   area->domain_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
                   1907:   strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
                   1908: 
                   1909:   if (argc > 1)
                   1910:     {
                   1911:       SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
                   1912:       if (strncmp(argv[1], "v", 1) == 0)
                   1913:        SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
                   1914:       else
                   1915:        UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
                   1916:     }
                   1917:   else
                   1918:     {
                   1919:       UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
                   1920:       UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
                   1921:     }
1.1.1.2   misho    1922:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1.1       misho    1923: 
                   1924:   return CMD_SUCCESS;
                   1925: }
                   1926: 
1.1.1.2   misho    1927: ALIAS (domain_passwd_clear,
                   1928:        domain_passwd_clear_snpauth_cmd,
                   1929:        "domain-password clear WORD authenticate snp (send-only|validate)",
1.1       misho    1930:        "Set the authentication password for a routing domain\n"
1.1.1.2   misho    1931:        "Authentication type\n"
1.1       misho    1932:        "Routing domain password\n"
                   1933:        "Authentication\n"
                   1934:        "SNP PDUs\n"
                   1935:        "Send but do not check PDUs on receiving\n"
1.1.1.4 ! misho    1936:        "Send and check PDUs on receiving\n")
1.1       misho    1937: 
                   1938: DEFUN (no_domain_passwd,
                   1939:        no_domain_passwd_cmd,
1.1.1.2   misho    1940:        "no domain-password",
1.1       misho    1941:        NO_STR
                   1942:        "Set the authentication password for a routing domain\n")
                   1943: {
                   1944:   struct isis_area *area;
                   1945: 
                   1946:   area = vty->index;
                   1947: 
                   1948:   if (!area)
                   1949:     {
1.1.1.2   misho    1950:       vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
                   1951:       return CMD_ERR_NO_MATCH;
1.1       misho    1952:     }
                   1953: 
                   1954:   memset (&area->domain_passwd, 0, sizeof (struct isis_passwd));
1.1.1.2   misho    1955:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1.1       misho    1956: 
                   1957:   return CMD_SUCCESS;
                   1958: }
                   1959: 
                   1960: DEFUN (is_type,
                   1961:        is_type_cmd,
                   1962:        "is-type (level-1|level-1-2|level-2-only)",
                   1963:        "IS Level for this routing process (OSI only)\n"
                   1964:        "Act as a station router only\n"
                   1965:        "Act as both a station router and an area router\n"
                   1966:        "Act as an area router only\n")
                   1967: {
                   1968:   struct isis_area *area;
                   1969:   int type;
                   1970: 
                   1971:   area = vty->index;
                   1972: 
                   1973:   if (!area)
                   1974:     {
1.1.1.2   misho    1975:       vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
                   1976:       return CMD_ERR_NO_MATCH;
1.1       misho    1977:     }
                   1978: 
                   1979:   type = string2circuit_t (argv[0]);
                   1980:   if (!type)
                   1981:     {
                   1982:       vty_out (vty, "Unknown IS level %s", VTY_NEWLINE);
                   1983:       return CMD_SUCCESS;
                   1984:     }
                   1985: 
                   1986:   isis_event_system_type_change (area, type);
                   1987: 
                   1988:   return CMD_SUCCESS;
                   1989: }
                   1990: 
                   1991: DEFUN (no_is_type,
                   1992:        no_is_type_cmd,
                   1993:        "no is-type (level-1|level-1-2|level-2-only)",
                   1994:        NO_STR
                   1995:        "IS Level for this routing process (OSI only)\n"
                   1996:        "Act as a station router only\n"
                   1997:        "Act as both a station router and an area router\n"
                   1998:        "Act as an area router only\n")
                   1999: {
                   2000:   struct isis_area *area;
                   2001:   int type;
                   2002: 
                   2003:   area = vty->index;
                   2004:   assert (area);
                   2005: 
                   2006:   /*
1.1.1.2   misho    2007:    * Put the is-type back to defaults:
                   2008:    * - level-1-2 on first area
                   2009:    * - level-1 for the rest
1.1       misho    2010:    */
                   2011:   if (listgetdata (listhead (isis->area_list)) == area)
                   2012:     type = IS_LEVEL_1_AND_2;
                   2013:   else
                   2014:     type = IS_LEVEL_1;
                   2015: 
                   2016:   isis_event_system_type_change (area, type);
                   2017: 
                   2018:   return CMD_SUCCESS;
                   2019: }
                   2020: 
1.1.1.2   misho    2021: static int
                   2022: set_lsp_gen_interval (struct vty *vty, struct isis_area *area,
                   2023:                       uint16_t interval, int level)
                   2024: {
                   2025:   int lvl;
                   2026: 
                   2027:   for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
                   2028:     {
                   2029:       if (!(lvl & level))
                   2030:         continue;
                   2031: 
                   2032:       if (interval >= area->lsp_refresh[lvl-1])
                   2033:         {
                   2034:           vty_out (vty, "LSP gen interval %us must be less than "
                   2035:                    "the LSP refresh interval %us%s",
                   2036:                    interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
                   2037:           return CMD_ERR_AMBIGUOUS;
                   2038:         }
                   2039:     }
                   2040: 
                   2041:   for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
                   2042:     {
                   2043:       if (!(lvl & level))
                   2044:         continue;
                   2045:       area->lsp_gen_interval[lvl-1] = interval;
                   2046:     }
                   2047: 
                   2048:   return CMD_SUCCESS;
                   2049: }
                   2050: 
1.1       misho    2051: DEFUN (lsp_gen_interval,
                   2052:        lsp_gen_interval_cmd,
                   2053:        "lsp-gen-interval <1-120>",
                   2054:        "Minimum interval between regenerating same LSP\n"
                   2055:        "Minimum interval in seconds\n")
                   2056: {
                   2057:   struct isis_area *area;
                   2058:   uint16_t interval;
1.1.1.2   misho    2059:   int level;
1.1       misho    2060: 
                   2061:   area = vty->index;
                   2062:   interval = atoi (argv[0]);
1.1.1.2   misho    2063:   level = IS_LEVEL_1 | IS_LEVEL_2;
                   2064:   return set_lsp_gen_interval (vty, area, interval, level);
1.1       misho    2065: }
                   2066: 
                   2067: DEFUN (no_lsp_gen_interval,
                   2068:        no_lsp_gen_interval_cmd,
                   2069:        "no lsp-gen-interval",
                   2070:        NO_STR
                   2071:        "Minimum interval between regenerating same LSP\n")
                   2072: {
                   2073:   struct isis_area *area;
1.1.1.2   misho    2074:   uint16_t interval;
                   2075:   int level;
1.1       misho    2076: 
                   2077:   area = vty->index;
1.1.1.2   misho    2078:   interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
                   2079:   level = IS_LEVEL_1 | IS_LEVEL_2;
                   2080:   return set_lsp_gen_interval (vty, area, interval, level);
1.1       misho    2081: }
                   2082: 
                   2083: ALIAS (no_lsp_gen_interval,
                   2084:        no_lsp_gen_interval_arg_cmd,
                   2085:        "no lsp-gen-interval <1-120>",
                   2086:        NO_STR
                   2087:        "Minimum interval between regenerating same LSP\n"
                   2088:        "Minimum interval in seconds\n")
                   2089: 
                   2090: DEFUN (lsp_gen_interval_l1,
                   2091:        lsp_gen_interval_l1_cmd,
                   2092:        "lsp-gen-interval level-1 <1-120>",
                   2093:        "Minimum interval between regenerating same LSP\n"
                   2094:        "Set interval for level 1 only\n"
                   2095:        "Minimum interval in seconds\n")
                   2096: {
                   2097:   struct isis_area *area;
                   2098:   uint16_t interval;
1.1.1.2   misho    2099:   int level;
1.1       misho    2100: 
                   2101:   area = vty->index;
                   2102:   interval = atoi (argv[0]);
1.1.1.2   misho    2103:   level = IS_LEVEL_1;
                   2104:   return set_lsp_gen_interval (vty, area, interval, level);
1.1       misho    2105: }
                   2106: 
                   2107: DEFUN (no_lsp_gen_interval_l1,
                   2108:        no_lsp_gen_interval_l1_cmd,
                   2109:        "no lsp-gen-interval level-1",
                   2110:        NO_STR
                   2111:        "Minimum interval between regenerating same LSP\n"
                   2112:        "Set interval for level 1 only\n")
                   2113: {
                   2114:   struct isis_area *area;
1.1.1.2   misho    2115:   uint16_t interval;
                   2116:   int level;
1.1       misho    2117: 
                   2118:   area = vty->index;
1.1.1.2   misho    2119:   interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
                   2120:   level = IS_LEVEL_1;
                   2121:   return set_lsp_gen_interval (vty, area, interval, level);
1.1       misho    2122: }
                   2123: 
                   2124: ALIAS (no_lsp_gen_interval_l1,
                   2125:        no_lsp_gen_interval_l1_arg_cmd,
                   2126:        "no lsp-gen-interval level-1 <1-120>",
                   2127:        NO_STR
                   2128:        "Minimum interval between regenerating same LSP\n"
                   2129:        "Set interval for level 1 only\n"
                   2130:        "Minimum interval in seconds\n")
                   2131: 
                   2132: DEFUN (lsp_gen_interval_l2,
                   2133:        lsp_gen_interval_l2_cmd,
                   2134:        "lsp-gen-interval level-2 <1-120>",
                   2135:        "Minimum interval between regenerating same LSP\n"
                   2136:        "Set interval for level 2 only\n"
                   2137:        "Minimum interval in seconds\n")
                   2138: {
                   2139:   struct isis_area *area;
1.1.1.2   misho    2140:   uint16_t interval;
                   2141:   int level;
1.1       misho    2142: 
                   2143:   area = vty->index;
                   2144:   interval = atoi (argv[0]);
1.1.1.2   misho    2145:   level = IS_LEVEL_2;
                   2146:   return set_lsp_gen_interval (vty, area, interval, level);
1.1       misho    2147: }
                   2148: 
                   2149: DEFUN (no_lsp_gen_interval_l2,
                   2150:        no_lsp_gen_interval_l2_cmd,
                   2151:        "no lsp-gen-interval level-2",
                   2152:        NO_STR
                   2153:        "Minimum interval between regenerating same LSP\n"
                   2154:        "Set interval for level 2 only\n")
                   2155: {
                   2156:   struct isis_area *area;
1.1.1.2   misho    2157:   uint16_t interval;
                   2158:   int level;
1.1       misho    2159: 
                   2160:   area = vty->index;
1.1.1.2   misho    2161:   interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
                   2162:   level = IS_LEVEL_2;
                   2163:   return set_lsp_gen_interval (vty, area, interval, level);
1.1       misho    2164: }
                   2165: 
                   2166: ALIAS (no_lsp_gen_interval_l2,
                   2167:        no_lsp_gen_interval_l2_arg_cmd,
                   2168:        "no lsp-gen-interval level-2 <1-120>",
                   2169:        NO_STR
                   2170:        "Minimum interval between regenerating same LSP\n"
                   2171:        "Set interval for level 2 only\n"
                   2172:        "Minimum interval in seconds\n")
                   2173: 
1.1.1.2   misho    2174: static int
                   2175: validate_metric_style_narrow (struct vty *vty, struct isis_area *area)
                   2176: {
                   2177:   struct isis_circuit *circuit;
                   2178:   struct listnode *node;
                   2179:   
                   2180:   if (! vty)
                   2181:     return CMD_ERR_AMBIGUOUS;
                   2182: 
                   2183:   if (! area)
                   2184:     {
                   2185:       vty_out (vty, "ISIS area is invalid%s", VTY_NEWLINE);
                   2186:       return CMD_ERR_AMBIGUOUS;
                   2187:     }
                   2188: 
                   2189:   for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
                   2190:     {
                   2191:       if ((area->is_type & IS_LEVEL_1) &&
                   2192:           (circuit->is_type & IS_LEVEL_1) &&
1.1.1.3   misho    2193:           (circuit->te_metric[0] > MAX_NARROW_LINK_METRIC))
1.1.1.2   misho    2194:         {
                   2195:           vty_out (vty, "ISIS circuit %s metric is invalid%s",
                   2196:                    circuit->interface->name, VTY_NEWLINE);
                   2197:           return CMD_ERR_AMBIGUOUS;
                   2198:         }
                   2199:       if ((area->is_type & IS_LEVEL_2) &&
                   2200:           (circuit->is_type & IS_LEVEL_2) &&
1.1.1.3   misho    2201:           (circuit->te_metric[1] > MAX_NARROW_LINK_METRIC))
1.1.1.2   misho    2202:         {
                   2203:           vty_out (vty, "ISIS circuit %s metric is invalid%s",
                   2204:                    circuit->interface->name, VTY_NEWLINE);
                   2205:           return CMD_ERR_AMBIGUOUS;
                   2206:         }
                   2207:     }
                   2208: 
                   2209:   return CMD_SUCCESS;
                   2210: }
                   2211: 
1.1       misho    2212: DEFUN (metric_style,
                   2213:        metric_style_cmd,
                   2214:        "metric-style (narrow|transition|wide)",
                   2215:        "Use old-style (ISO 10589) or new-style packet formats\n"
                   2216:        "Use old style of TLVs with narrow metric\n"
                   2217:        "Send and accept both styles of TLVs during transition\n"
                   2218:        "Use new style of TLVs to carry wider metric\n")
                   2219: {
                   2220:   struct isis_area *area;
1.1.1.2   misho    2221:   int ret;
1.1       misho    2222: 
                   2223:   area = vty->index;
                   2224:   assert (area);
                   2225: 
                   2226:   if (strncmp (argv[0], "w", 1) == 0)
                   2227:     {
                   2228:       area->newmetric = 1;
                   2229:       area->oldmetric = 0;
                   2230:     }
1.1.1.3   misho    2231:   else
1.1       misho    2232:     {
1.1.1.2   misho    2233:       ret = validate_metric_style_narrow (vty, area);
                   2234:       if (ret != CMD_SUCCESS)
                   2235:         return ret;
                   2236: 
1.1.1.3   misho    2237:       if (strncmp (argv[0], "t", 1) == 0)
                   2238:        {
                   2239:          area->newmetric = 1;
                   2240:          area->oldmetric = 1;
                   2241:        }
                   2242:       else if (strncmp (argv[0], "n", 1) == 0)
                   2243:        {
                   2244:          area->newmetric = 0;
                   2245:          area->oldmetric = 1;
                   2246:        }
1.1       misho    2247:     }
                   2248: 
                   2249:   return CMD_SUCCESS;
                   2250: }
                   2251: 
                   2252: DEFUN (no_metric_style,
                   2253:        no_metric_style_cmd,
                   2254:        "no metric-style",
                   2255:        NO_STR
                   2256:        "Use old-style (ISO 10589) or new-style packet formats\n")
                   2257: {
                   2258:   struct isis_area *area;
1.1.1.2   misho    2259:   int ret;
1.1       misho    2260: 
                   2261:   area = vty->index;
                   2262:   assert (area);
                   2263: 
1.1.1.2   misho    2264:   ret = validate_metric_style_narrow (vty, area);
                   2265:   if (ret != CMD_SUCCESS)
                   2266:     return ret;
                   2267: 
1.1       misho    2268:   /* Default is narrow metric. */
                   2269:   area->newmetric = 0;
                   2270:   area->oldmetric = 1;
                   2271: 
                   2272:   return CMD_SUCCESS;
                   2273: }
                   2274: 
1.1.1.2   misho    2275: DEFUN (set_overload_bit,
                   2276:        set_overload_bit_cmd,
                   2277:        "set-overload-bit",
                   2278:        "Set overload bit to avoid any transit traffic\n"
                   2279:        "Set overload bit\n")
                   2280: {
                   2281:   struct isis_area *area;
                   2282: 
                   2283:   area = vty->index;
                   2284:   assert (area);
                   2285: 
                   2286:   area->overload_bit = LSPBIT_OL;
                   2287:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
                   2288: 
                   2289:   return CMD_SUCCESS;
                   2290: }
                   2291: 
                   2292: DEFUN (no_set_overload_bit,
                   2293:        no_set_overload_bit_cmd,
                   2294:        "no set-overload-bit",
                   2295:        "Reset overload bit to accept transit traffic\n"
                   2296:        "Reset overload bit\n")
                   2297: {
                   2298:   struct isis_area *area;
                   2299: 
                   2300:   area = vty->index;
                   2301:   assert (area);
                   2302: 
                   2303:   area->overload_bit = 0;
                   2304:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
                   2305: 
                   2306:   return CMD_SUCCESS;
                   2307: }
                   2308: 
1.1.1.4 ! misho    2309: DEFUN (set_attached_bit,
        !          2310:        set_attached_bit_cmd,
        !          2311:        "set-attached-bit",
        !          2312:        "Set attached bit to identify as L1/L2 router for inter-area traffic\n"
        !          2313:        "Set attached bit\n")
        !          2314: {
        !          2315:   struct isis_area *area;
        !          2316: 
        !          2317:   area = vty->index;
        !          2318:   assert (area);
        !          2319: 
        !          2320:   area->attached_bit = LSPBIT_ATT;
        !          2321:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
        !          2322: 
        !          2323:   return CMD_SUCCESS;
        !          2324: }
        !          2325: 
        !          2326: DEFUN (no_set_attached_bit,
        !          2327:        no_set_attached_bit_cmd,
        !          2328:        "no set-attached-bit",
        !          2329:        "Reset attached bit\n")
        !          2330: {
        !          2331:   struct isis_area *area;
        !          2332: 
        !          2333:   area = vty->index;
        !          2334:   assert (area);
        !          2335: 
        !          2336:   area->attached_bit = 0;
        !          2337:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
        !          2338: 
        !          2339:   return CMD_SUCCESS;
        !          2340: }
        !          2341: 
1.1       misho    2342: DEFUN (dynamic_hostname,
                   2343:        dynamic_hostname_cmd,
                   2344:        "hostname dynamic",
                   2345:        "Dynamic hostname for IS-IS\n"
                   2346:        "Dynamic hostname\n")
                   2347: {
                   2348:   struct isis_area *area;
                   2349: 
                   2350:   area = vty->index;
                   2351:   assert (area);
                   2352: 
1.1.1.2   misho    2353:   if (!area->dynhostname)
                   2354:    {
                   2355:      area->dynhostname = 1;
                   2356:      lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
                   2357:    }
1.1       misho    2358: 
                   2359:   return CMD_SUCCESS;
                   2360: }
                   2361: 
                   2362: DEFUN (no_dynamic_hostname,
                   2363:        no_dynamic_hostname_cmd,
                   2364:        "no hostname dynamic",
                   2365:        NO_STR
                   2366:        "Dynamic hostname for IS-IS\n"
                   2367:        "Dynamic hostname\n")
                   2368: {
                   2369:   struct isis_area *area;
                   2370: 
                   2371:   area = vty->index;
                   2372:   assert (area);
                   2373: 
1.1.1.2   misho    2374:   if (area->dynhostname)
                   2375:     {
                   2376:       area->dynhostname = 0;
                   2377:       lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
                   2378:     }
1.1       misho    2379: 
                   2380:   return CMD_SUCCESS;
                   2381: }
                   2382: 
                   2383: DEFUN (spf_interval,
                   2384:        spf_interval_cmd,
                   2385:        "spf-interval <1-120>",
                   2386:        "Minimum interval between SPF calculations\n"
                   2387:        "Minimum interval between consecutive SPFs in seconds\n")
                   2388: {
                   2389:   struct isis_area *area;
                   2390:   u_int16_t interval;
                   2391: 
                   2392:   area = vty->index;
                   2393:   interval = atoi (argv[0]);
                   2394:   area->min_spf_interval[0] = interval;
                   2395:   area->min_spf_interval[1] = interval;
                   2396: 
                   2397:   return CMD_SUCCESS;
                   2398: }
                   2399: 
                   2400: DEFUN (no_spf_interval,
                   2401:        no_spf_interval_cmd,
                   2402:        "no spf-interval",
                   2403:        NO_STR
                   2404:        "Minimum interval between SPF calculations\n")
                   2405: {
                   2406:   struct isis_area *area;
                   2407: 
                   2408:   area = vty->index;
                   2409: 
                   2410:   area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
                   2411:   area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
                   2412: 
                   2413:   return CMD_SUCCESS;
                   2414: }
                   2415: 
                   2416: ALIAS (no_spf_interval,
                   2417:        no_spf_interval_arg_cmd,
                   2418:        "no spf-interval <1-120>",
                   2419:        NO_STR
                   2420:        "Minimum interval between SPF calculations\n"
                   2421:        "Minimum interval between consecutive SPFs in seconds\n")
                   2422: 
                   2423: DEFUN (spf_interval_l1,
                   2424:        spf_interval_l1_cmd,
                   2425:        "spf-interval level-1 <1-120>",
                   2426:        "Minimum interval between SPF calculations\n"
                   2427:        "Set interval for level 1 only\n"
                   2428:        "Minimum interval between consecutive SPFs in seconds\n")
                   2429: {
                   2430:   struct isis_area *area;
                   2431:   u_int16_t interval;
                   2432: 
                   2433:   area = vty->index;
                   2434:   interval = atoi (argv[0]);
                   2435:   area->min_spf_interval[0] = interval;
                   2436: 
                   2437:   return CMD_SUCCESS;
                   2438: }
                   2439: 
                   2440: DEFUN (no_spf_interval_l1,
                   2441:        no_spf_interval_l1_cmd,
                   2442:        "no spf-interval level-1",
                   2443:        NO_STR
                   2444:        "Minimum interval between SPF calculations\n"
                   2445:        "Set interval for level 1 only\n")
                   2446: {
                   2447:   struct isis_area *area;
                   2448: 
                   2449:   area = vty->index;
                   2450: 
                   2451:   area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
                   2452: 
                   2453:   return CMD_SUCCESS;
                   2454: }
                   2455: 
                   2456: ALIAS (no_spf_interval,
                   2457:        no_spf_interval_l1_arg_cmd,
                   2458:        "no spf-interval level-1 <1-120>",
                   2459:        NO_STR
                   2460:        "Minimum interval between SPF calculations\n"
                   2461:        "Set interval for level 1 only\n"
                   2462:        "Minimum interval between consecutive SPFs in seconds\n")
                   2463: 
                   2464: DEFUN (spf_interval_l2,
                   2465:        spf_interval_l2_cmd,
                   2466:        "spf-interval level-2 <1-120>",
                   2467:        "Minimum interval between SPF calculations\n"
                   2468:        "Set interval for level 2 only\n"
                   2469:        "Minimum interval between consecutive SPFs in seconds\n")
                   2470: {
                   2471:   struct isis_area *area;
                   2472:   u_int16_t interval;
                   2473: 
                   2474:   area = vty->index;
                   2475:   interval = atoi (argv[0]);
                   2476:   area->min_spf_interval[1] = interval;
                   2477: 
                   2478:   return CMD_SUCCESS;
                   2479: }
                   2480: 
                   2481: DEFUN (no_spf_interval_l2,
                   2482:        no_spf_interval_l2_cmd,
                   2483:        "no spf-interval level-2",
                   2484:        NO_STR
                   2485:        "Minimum interval between SPF calculations\n"
                   2486:        "Set interval for level 2 only\n")
                   2487: {
                   2488:   struct isis_area *area;
                   2489: 
                   2490:   area = vty->index;
                   2491: 
                   2492:   area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
                   2493: 
                   2494:   return CMD_SUCCESS;
                   2495: }
                   2496: 
                   2497: ALIAS (no_spf_interval,
                   2498:        no_spf_interval_l2_arg_cmd,
                   2499:        "no spf-interval level-2 <1-120>",
                   2500:        NO_STR
                   2501:        "Minimum interval between SPF calculations\n"
                   2502:        "Set interval for level 2 only\n"
                   2503:        "Minimum interval between consecutive SPFs in seconds\n")
                   2504: 
1.1.1.2   misho    2505: static int
                   2506: set_lsp_max_lifetime (struct vty *vty, struct isis_area *area,
                   2507:                       uint16_t interval, int level)
1.1       misho    2508: {
1.1.1.2   misho    2509:   int lvl;
                   2510:   int set_refresh_interval[ISIS_LEVELS] = {0, 0};
                   2511:   uint16_t refresh_interval;
1.1       misho    2512: 
1.1.1.2   misho    2513:   refresh_interval = interval - 300;
1.1       misho    2514: 
1.1.1.2   misho    2515:   for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
1.1       misho    2516:     {
1.1.1.2   misho    2517:       if (!(lvl & level))
                   2518:         continue;
                   2519:       if (refresh_interval < area->lsp_refresh[lvl-1])
                   2520:         {
                   2521:           vty_out (vty, "Level %d Max LSP lifetime %us must be 300s greater than "
                   2522:                    "the configured LSP refresh interval %us%s",
                   2523:                    lvl, interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
                   2524:           vty_out (vty, "Automatically reducing level %d LSP refresh interval "
                   2525:                    "to %us%s", lvl, refresh_interval, VTY_NEWLINE);
                   2526:           set_refresh_interval[lvl-1] = 1;
                   2527: 
                   2528:           if (refresh_interval <= area->lsp_gen_interval[lvl-1])
                   2529:             {
                   2530:               vty_out (vty, "LSP refresh interval %us must be greater than "
                   2531:                        "the configured LSP gen interval %us%s",
                   2532:                        refresh_interval, area->lsp_gen_interval[lvl-1],
                   2533:                        VTY_NEWLINE);
                   2534:               return CMD_ERR_AMBIGUOUS;
                   2535:             }
                   2536:         }
                   2537:     }
                   2538: 
                   2539:   for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
                   2540:     {
                   2541:       if (!(lvl & level))
                   2542:         continue;
                   2543:       area->max_lsp_lifetime[lvl-1] = interval;
                   2544:       /* Automatically reducing lsp_refresh_interval to interval - 300 */
                   2545:       if (set_refresh_interval[lvl-1])
                   2546:         area->lsp_refresh[lvl-1] = refresh_interval;
1.1       misho    2547:     }
                   2548: 
1.1.1.2   misho    2549:   lsp_regenerate_schedule (area, level, 1);
                   2550: 
1.1       misho    2551:   return CMD_SUCCESS;
                   2552: }
                   2553: 
1.1.1.2   misho    2554: DEFUN (max_lsp_lifetime,
                   2555:        max_lsp_lifetime_cmd,
                   2556:        "max-lsp-lifetime <350-65535>",
                   2557:        "Maximum LSP lifetime\n"
                   2558:        "LSP lifetime in seconds\n")
1.1       misho    2559: {
                   2560:   struct isis_area *area;
1.1.1.2   misho    2561:   uint16_t interval;
                   2562:   int level;
1.1       misho    2563: 
1.1.1.2   misho    2564:   area = vty->index;
                   2565:   interval = atoi (argv[0]);
                   2566:   level = IS_LEVEL_1 | IS_LEVEL_2;
                   2567:   return set_lsp_max_lifetime (vty, area, interval, level);
1.1       misho    2568: }
                   2569: 
1.1.1.2   misho    2570: DEFUN (no_max_lsp_lifetime,
                   2571:        no_max_lsp_lifetime_cmd,
                   2572:        "no max-lsp-lifetime",
                   2573:        NO_STR
                   2574:        "LSP lifetime in seconds\n")
1.1       misho    2575: {
                   2576:   struct isis_area *area;
1.1.1.2   misho    2577:   uint16_t interval;
                   2578:   int level;
1.1       misho    2579: 
                   2580:   area = vty->index;
1.1.1.2   misho    2581:   interval = DEFAULT_LSP_LIFETIME;
                   2582:   level = IS_LEVEL_1 | IS_LEVEL_2;
                   2583:   return set_lsp_max_lifetime (vty, area, interval, level);
1.1       misho    2584: }
                   2585: 
1.1.1.2   misho    2586: ALIAS (no_max_lsp_lifetime,
                   2587:        no_max_lsp_lifetime_arg_cmd,
                   2588:        "no max-lsp-lifetime <350-65535>",
1.1       misho    2589:        NO_STR
1.1.1.2   misho    2590:        "Maximum LSP lifetime\n"
                   2591:        "LSP lifetime in seconds\n")
                   2592: 
                   2593: DEFUN (max_lsp_lifetime_l1,
                   2594:        max_lsp_lifetime_l1_cmd,
                   2595:        "max-lsp-lifetime level-1 <350-65535>",
                   2596:        "Maximum LSP lifetime for Level 1 only\n"
                   2597:        "LSP lifetime for Level 1 only in seconds\n")
1.1       misho    2598: {
                   2599:   struct isis_area *area;
1.1.1.2   misho    2600:   uint16_t interval;
                   2601:   int level;
1.1       misho    2602: 
                   2603:   area = vty->index;
1.1.1.2   misho    2604:   interval = atoi (argv[0]);
                   2605:   level = IS_LEVEL_1;
                   2606:   return set_lsp_max_lifetime (vty, area, interval, level);
1.1       misho    2607: }
                   2608: 
1.1.1.2   misho    2609: DEFUN (no_max_lsp_lifetime_l1,
                   2610:        no_max_lsp_lifetime_l1_cmd,
                   2611:        "no max-lsp-lifetime level-1",
1.1       misho    2612:        NO_STR
1.1.1.2   misho    2613:        "LSP lifetime for Level 1 only in seconds\n")
1.1       misho    2614: {
                   2615:   struct isis_area *area;
1.1.1.2   misho    2616:   uint16_t interval;
                   2617:   int level;
1.1       misho    2618: 
                   2619:   area = vty->index;
1.1.1.2   misho    2620:   interval = DEFAULT_LSP_LIFETIME;
                   2621:   level = IS_LEVEL_1;
                   2622:   return set_lsp_max_lifetime (vty, area, interval, level);
1.1       misho    2623: }
                   2624: 
1.1.1.2   misho    2625: ALIAS (no_max_lsp_lifetime_l1,
                   2626:        no_max_lsp_lifetime_l1_arg_cmd,
                   2627:        "no max-lsp-lifetime level-1 <350-65535>",
                   2628:        NO_STR
                   2629:        "Maximum LSP lifetime for Level 1 only\n"
                   2630:        "LSP lifetime for Level 1 only in seconds\n")
                   2631: 
                   2632: DEFUN (max_lsp_lifetime_l2,
                   2633:        max_lsp_lifetime_l2_cmd,
                   2634:        "max-lsp-lifetime level-2 <350-65535>",
                   2635:        "Maximum LSP lifetime for Level 2 only\n"
                   2636:        "LSP lifetime for Level 2 only in seconds\n")
1.1       misho    2637: {
                   2638:   struct isis_area *area;
                   2639:   uint16_t interval;
1.1.1.2   misho    2640:   int level;
1.1       misho    2641: 
                   2642:   area = vty->index;
                   2643:   interval = atoi (argv[0]);
1.1.1.2   misho    2644:   level = IS_LEVEL_2;
                   2645:   return set_lsp_max_lifetime (vty, area, interval, level);
                   2646: }
1.1       misho    2647: 
1.1.1.2   misho    2648: DEFUN (no_max_lsp_lifetime_l2,
                   2649:        no_max_lsp_lifetime_l2_cmd,
                   2650:        "no max-lsp-lifetime level-2",
                   2651:        NO_STR
                   2652:        "LSP lifetime for Level 2 only in seconds\n")
                   2653: {
                   2654:   struct isis_area *area;
                   2655:   uint16_t interval;
                   2656:   int level;
1.1       misho    2657: 
1.1.1.2   misho    2658:   area = vty->index;
                   2659:   interval = DEFAULT_LSP_LIFETIME;
                   2660:   level = IS_LEVEL_2;
                   2661:   return set_lsp_max_lifetime (vty, area, interval, level);
                   2662: }
1.1       misho    2663: 
1.1.1.2   misho    2664: ALIAS (no_max_lsp_lifetime_l2,
                   2665:        no_max_lsp_lifetime_l2_arg_cmd,
                   2666:        "no max-lsp-lifetime level-2 <350-65535>",
                   2667:        NO_STR
                   2668:        "Maximum LSP lifetime for Level 2 only\n"
                   2669:        "LSP lifetime for Level 2 only in seconds\n")
1.1       misho    2670: 
1.1.1.2   misho    2671: static int
                   2672: set_lsp_refresh_interval (struct vty *vty, struct isis_area *area,
                   2673:                           uint16_t interval, int level)
                   2674: {
                   2675:   int lvl;
1.1       misho    2676: 
1.1.1.2   misho    2677:   for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
1.1       misho    2678:     {
1.1.1.2   misho    2679:       if (!(lvl & level))
                   2680:         continue;
                   2681:       if (interval <= area->lsp_gen_interval[lvl-1])
                   2682:         {
                   2683:           vty_out (vty, "LSP refresh interval %us must be greater than "
                   2684:                    "the configured LSP gen interval %us%s",
                   2685:                    interval, area->lsp_gen_interval[lvl-1],
                   2686:                    VTY_NEWLINE);
                   2687:           return CMD_ERR_AMBIGUOUS;
                   2688:         }
                   2689:       if (interval > (area->max_lsp_lifetime[lvl-1] - 300))
                   2690:         {
                   2691:           vty_out (vty, "LSP refresh interval %us must be less than "
                   2692:                    "the configured LSP lifetime %us less 300%s",
                   2693:                    interval, area->max_lsp_lifetime[lvl-1],
                   2694:                    VTY_NEWLINE);
                   2695:           return CMD_ERR_AMBIGUOUS;
                   2696:         }
1.1       misho    2697:     }
                   2698: 
1.1.1.2   misho    2699:   for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
1.1       misho    2700:     {
1.1.1.2   misho    2701:       if (!(lvl & level))
                   2702:         continue;
                   2703:       area->lsp_refresh[lvl-1] = interval;
1.1       misho    2704:     }
1.1.1.2   misho    2705:   lsp_regenerate_schedule (area, level, 1);
1.1       misho    2706: 
                   2707:   return CMD_SUCCESS;
                   2708: }
                   2709: 
1.1.1.2   misho    2710: DEFUN (lsp_refresh_interval,
                   2711:        lsp_refresh_interval_cmd,
                   2712:        "lsp-refresh-interval <1-65235>",
                   2713:        "LSP refresh interval\n"
                   2714:        "LSP refresh interval in seconds\n")
1.1       misho    2715: {
                   2716:   struct isis_area *area;
1.1.1.2   misho    2717:   uint16_t interval;
                   2718:   int level;
1.1       misho    2719: 
                   2720:   area = vty->index;
1.1.1.2   misho    2721:   interval = atoi (argv[0]);
                   2722:   level = IS_LEVEL_1 | IS_LEVEL_2;
                   2723:   return set_lsp_refresh_interval (vty, area, interval, level);
                   2724: }
1.1       misho    2725: 
1.1.1.2   misho    2726: DEFUN (no_lsp_refresh_interval,
                   2727:        no_lsp_refresh_interval_cmd,
                   2728:        "no lsp-refresh-interval",
                   2729:        NO_STR
                   2730:        "LSP refresh interval in seconds\n")
                   2731: {
                   2732:   struct isis_area *area;
                   2733:   uint16_t interval;
                   2734:   int level;
1.1       misho    2735: 
1.1.1.2   misho    2736:   area = vty->index;
                   2737:   interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
                   2738:   level = IS_LEVEL_1 | IS_LEVEL_2;
                   2739:   return set_lsp_refresh_interval (vty, area, interval, level);
1.1       misho    2740: }
                   2741: 
1.1.1.2   misho    2742: ALIAS (no_lsp_refresh_interval,
                   2743:        no_lsp_refresh_interval_arg_cmd,
                   2744:        "no lsp-refresh-interval <1-65235>",
1.1       misho    2745:        NO_STR
1.1.1.2   misho    2746:        "LSP refresh interval\n"
                   2747:        "LSP refresh interval in seconds\n")
1.1       misho    2748: 
1.1.1.2   misho    2749: DEFUN (lsp_refresh_interval_l1,
                   2750:        lsp_refresh_interval_l1_cmd,
                   2751:        "lsp-refresh-interval level-1 <1-65235>",
                   2752:        "LSP refresh interval for Level 1 only\n"
                   2753:        "LSP refresh interval for Level 1 only in seconds\n")
1.1       misho    2754: {
                   2755:   struct isis_area *area;
                   2756:   uint16_t interval;
1.1.1.2   misho    2757:   int level;
1.1       misho    2758: 
                   2759:   area = vty->index;
1.1.1.2   misho    2760:   interval = atoi (argv[0]);
                   2761:   level = IS_LEVEL_1;
                   2762:   return set_lsp_refresh_interval (vty, area, interval, level);
                   2763: }
1.1       misho    2764: 
1.1.1.2   misho    2765: DEFUN (no_lsp_refresh_interval_l1,
                   2766:        no_lsp_refresh_interval_l1_cmd,
                   2767:        "no lsp-refresh-interval level-1",
                   2768:        NO_STR
                   2769:        "LSP refresh interval for Level 1 only in seconds\n")
                   2770: {
                   2771:   struct isis_area *area;
                   2772:   uint16_t interval;
                   2773:   int level;
                   2774: 
                   2775:   area = vty->index;
                   2776:   interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
                   2777:   level = IS_LEVEL_1;
                   2778:   return set_lsp_refresh_interval (vty, area, interval, level);
                   2779: }
                   2780: 
                   2781: ALIAS (no_lsp_refresh_interval_l1,
                   2782:        no_lsp_refresh_interval_l1_arg_cmd,
                   2783:        "no lsp-refresh-interval level-1 <1-65235>",
                   2784:        NO_STR
                   2785:        "LSP refresh interval for Level 1 only\n"
                   2786:        "LSP refresh interval for Level 1 only in seconds\n")
                   2787: 
                   2788: DEFUN (lsp_refresh_interval_l2,
                   2789:        lsp_refresh_interval_l2_cmd,
                   2790:        "lsp-refresh-interval level-2 <1-65235>",
                   2791:        "LSP refresh interval for Level 2 only\n"
                   2792:        "LSP refresh interval for Level 2 only in seconds\n")
                   2793: {
                   2794:   struct isis_area *area;
                   2795:   uint16_t interval;
                   2796:   int level;
                   2797: 
                   2798:   area = vty->index;
1.1       misho    2799:   interval = atoi (argv[0]);
1.1.1.2   misho    2800:   level = IS_LEVEL_2;
                   2801:   return set_lsp_refresh_interval (vty, area, interval, level);
                   2802: }
1.1       misho    2803: 
1.1.1.2   misho    2804: DEFUN (no_lsp_refresh_interval_l2,
                   2805:        no_lsp_refresh_interval_l2_cmd,
                   2806:        "no lsp-refresh-interval level-2",
                   2807:        NO_STR
                   2808:        "LSP refresh interval for Level 2 only in seconds\n")
                   2809: {
                   2810:   struct isis_area *area;
                   2811:   uint16_t interval;
                   2812:   int level;
1.1       misho    2813: 
1.1.1.2   misho    2814:   area = vty->index;
                   2815:   interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
                   2816:   level = IS_LEVEL_2;
                   2817:   return set_lsp_refresh_interval (vty, area, interval, level);
                   2818: }
                   2819: 
                   2820: ALIAS (no_lsp_refresh_interval_l2,
                   2821:        no_lsp_refresh_interval_l2_arg_cmd,
                   2822:        "no lsp-refresh-interval level-2 <1-65235>",
                   2823:        NO_STR
                   2824:        "LSP refresh interval for Level 2 only\n"
                   2825:        "LSP refresh interval for Level 2 only in seconds\n")
                   2826: 
                   2827: DEFUN (log_adj_changes,
                   2828:        log_adj_changes_cmd,
                   2829:        "log-adjacency-changes",
                   2830:        "Log changes in adjacency state\n")
                   2831: {
                   2832:   struct isis_area *area;
1.1       misho    2833: 
1.1.1.2   misho    2834:   area = vty->index;
                   2835:   assert (area);
1.1       misho    2836: 
1.1.1.2   misho    2837:   area->log_adj_changes = 1;
1.1       misho    2838: 
                   2839:   return CMD_SUCCESS;
                   2840: }
                   2841: 
1.1.1.2   misho    2842: DEFUN (no_log_adj_changes,
                   2843:        no_log_adj_changes_cmd,
                   2844:        "no log-adjacency-changes",
                   2845:        "Stop logging changes in adjacency state\n")
1.1       misho    2846: {
                   2847:   struct isis_area *area;
                   2848: 
                   2849:   area = vty->index;
                   2850:   assert (area);
                   2851: 
1.1.1.2   misho    2852:   area->log_adj_changes = 0;
1.1       misho    2853: 
                   2854:   return CMD_SUCCESS;
                   2855: }
                   2856: 
1.1.1.2   misho    2857: #ifdef TOPOLOGY_GENERATE
1.1       misho    2858: 
1.1.1.2   misho    2859: DEFUN (topology_generate_grid,
                   2860:        topology_generate_grid_cmd,
                   2861:        "topology generate grid <1-100> <1-100> <1-65000> [param] [param] "
                   2862:        "[param]",
                   2863:        "Topology generation for IS-IS\n"
                   2864:        "Topology generation\n"
                   2865:        "Grid topology\n"
                   2866:        "X parameter of the grid\n"
                   2867:        "Y parameter of the grid\n"
                   2868:        "Random seed\n"
                   2869:        "Optional param 1\n"
                   2870:        "Optional param 2\n"
                   2871:        "Optional param 3\n"
                   2872:        "Topology\n")
1.1       misho    2873: {
                   2874:   struct isis_area *area;
                   2875: 
                   2876:   area = vty->index;
                   2877:   assert (area);
                   2878: 
1.1.1.2   misho    2879:   if (!spgrid_check_params (vty, argc, argv))
                   2880:     {
                   2881:       if (area->topology)
                   2882:        list_delete (area->topology);
                   2883:       area->topology = list_new ();
                   2884:       memcpy (area->top_params, vty->buf, 200);
                   2885:       gen_spgrid_topology (vty, area->topology);
                   2886:       remove_topology_lsps (area);
                   2887:       generate_topology_lsps (area);
                   2888:       /* Regenerate L1 LSP to get two way connection to the generated
                   2889:        * topology. */
                   2890:       lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
                   2891:     }
                   2892: 
                   2893:   return CMD_SUCCESS;
                   2894: }
                   2895: 
                   2896: DEFUN (show_isis_generated_topology,
                   2897:        show_isis_generated_topology_cmd,
                   2898:        "show isis generated-topologies",
                   2899:        SHOW_STR
                   2900:        "ISIS network information\n"
                   2901:        "Show generated topologies\n")
                   2902: {
                   2903:   struct isis_area *area;
                   2904:   struct listnode *node;
                   2905:   struct listnode *node2;
                   2906:   struct arc *arc;
1.1       misho    2907: 
1.1.1.2   misho    2908:   for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1.1       misho    2909:     {
1.1.1.2   misho    2910:       if (!area->topology)
                   2911:        continue;
                   2912: 
                   2913:       vty_out (vty, "Topology for isis area: %s%s", area->area_tag,
                   2914:               VTY_NEWLINE);
                   2915:       vty_out (vty, "From node     To node     Distance%s", VTY_NEWLINE);
1.1       misho    2916: 
1.1.1.2   misho    2917:       for (ALL_LIST_ELEMENTS_RO (area->topology, node2, arc))
                   2918:        vty_out (vty, "%9ld %11ld %12ld%s", arc->from_node, arc->to_node,
                   2919:                 arc->distance, VTY_NEWLINE);
1.1       misho    2920:     }
1.1.1.2   misho    2921:   return CMD_SUCCESS;
                   2922: }
                   2923: 
                   2924: /* Base IS for topology generation. */
                   2925: DEFUN (topology_baseis,
                   2926:        topology_baseis_cmd,
                   2927:        "topology base-is WORD",
                   2928:        "Topology generation for IS-IS\n"
                   2929:        "A Network IS Base for this topology\n"
                   2930:        "XXXX.XXXX.XXXX Network entity title (NET)\n")
                   2931: {
                   2932:   struct isis_area *area;
                   2933:   u_char buff[ISIS_SYS_ID_LEN];
                   2934: 
                   2935:   area = vty->index;
                   2936:   assert (area);
1.1       misho    2937: 
1.1.1.2   misho    2938:   if (sysid2buff (buff, argv[0]))
                   2939:     sysid2buff (area->topology_baseis, argv[0]);
1.1       misho    2940: 
                   2941:   return CMD_SUCCESS;
                   2942: }
                   2943: 
1.1.1.2   misho    2944: DEFUN (no_topology_baseis,
                   2945:        no_topology_baseis_cmd,
                   2946:        "no topology base-is WORD",
1.1       misho    2947:        NO_STR
1.1.1.2   misho    2948:        "Topology generation for IS-IS\n"
                   2949:        "A Network IS Base for this topology\n"
                   2950:        "XXXX.XXXX.XXXX Network entity title (NET)\n")
1.1       misho    2951: {
                   2952:   struct isis_area *area;
                   2953: 
                   2954:   area = vty->index;
                   2955:   assert (area);
                   2956: 
1.1.1.2   misho    2957:   memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
1.1       misho    2958:   return CMD_SUCCESS;
                   2959: }
                   2960: 
1.1.1.2   misho    2961: ALIAS (no_topology_baseis,
                   2962:        no_topology_baseis_noid_cmd,
                   2963:        "no topology base-is",
1.1       misho    2964:        NO_STR
1.1.1.2   misho    2965:        "Topology generation for IS-IS\n"
                   2966:        "A Network IS Base for this topology\n")
                   2967: 
                   2968: DEFUN (topology_basedynh,
                   2969:        topology_basedynh_cmd,
                   2970:        "topology base-dynh WORD",
                   2971:        "Topology generation for IS-IS\n"
                   2972:        "Dynamic hostname base for this topology\n"
                   2973:        "Dynamic hostname base\n")
                   2974: {
                   2975:   struct isis_area *area;
                   2976: 
                   2977:   area = vty->index;
                   2978:   assert (area);
                   2979: 
                   2980:   /* I hope that it's enough. */
                   2981:   area->topology_basedynh = strndup (argv[0], 16); 
                   2982:   return CMD_SUCCESS;
                   2983: }
                   2984: 
                   2985: #endif /* TOPOLOGY_GENERATE */
1.1       misho    2986: 
                   2987: /* IS-IS configuration write function */
                   2988: int
                   2989: isis_config_write (struct vty *vty)
                   2990: {
                   2991:   int write = 0;
                   2992: 
                   2993:   if (isis != NULL)
                   2994:     {
                   2995:       struct isis_area *area;
                   2996:       struct listnode *node, *node2;
                   2997: 
                   2998:       for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
                   2999:       {
                   3000:        /* ISIS - Area name */
                   3001:        vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
                   3002:        write++;
                   3003:        /* ISIS - Net */
                   3004:        if (listcount (area->area_addrs) > 0)
                   3005:          {
                   3006:            struct area_addr *area_addr;
                   3007:            for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
                   3008:              {
                   3009:                vty_out (vty, " net %s%s",
                   3010:                         isonet_print (area_addr->area_addr,
                   3011:                                       area_addr->addr_len + ISIS_SYS_ID_LEN +
                   3012:                                       1), VTY_NEWLINE);
                   3013:                write++;
                   3014:              }
                   3015:          }
                   3016:        /* ISIS - Dynamic hostname - Defaults to true so only display if
                   3017:         * false. */
                   3018:        if (!area->dynhostname)
                   3019:          {
                   3020:            vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
                   3021:            write++;
                   3022:          }
                   3023:        /* ISIS - Metric-Style - when true displays wide */
                   3024:        if (area->newmetric)
                   3025:          {
                   3026:            if (!area->oldmetric)
                   3027:              vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
                   3028:            else
                   3029:              vty_out (vty, " metric-style transition%s", VTY_NEWLINE);
                   3030:            write++;
                   3031:          }
1.1.1.3   misho    3032:        else
                   3033:          {
                   3034:            vty_out (vty, " metric-style narrow%s", VTY_NEWLINE);
                   3035:            write++;
                   3036:          }
1.1.1.2   misho    3037:        /* ISIS - overload-bit */
                   3038:        if (area->overload_bit)
                   3039:          {
                   3040:            vty_out (vty, " set-overload-bit%s", VTY_NEWLINE);
                   3041:            write++;
                   3042:          }
1.1       misho    3043:        /* ISIS - Area is-type (level-1-2 is default) */
                   3044:        if (area->is_type == IS_LEVEL_1)
                   3045:          {
                   3046:            vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
                   3047:            write++;
                   3048:          }
1.1.1.2   misho    3049:        else if (area->is_type == IS_LEVEL_2)
1.1       misho    3050:          {
1.1.1.2   misho    3051:            vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
                   3052:            write++;
1.1       misho    3053:          }
1.1.1.4 ! misho    3054:        write += isis_redist_config_write(vty, area, AF_INET);
        !          3055:        write += isis_redist_config_write(vty, area, AF_INET6);
1.1       misho    3056:        /* ISIS - Lsp generation interval */
                   3057:        if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1])
                   3058:          {
1.1.1.2   misho    3059:            if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
1.1       misho    3060:              {
                   3061:                vty_out (vty, " lsp-gen-interval %d%s",
                   3062:                         area->lsp_gen_interval[0], VTY_NEWLINE);
                   3063:                write++;
                   3064:              }
                   3065:          }
                   3066:        else
                   3067:          {
1.1.1.2   misho    3068:            if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
1.1       misho    3069:              {
                   3070:                vty_out (vty, " lsp-gen-interval level-1 %d%s",
                   3071:                         area->lsp_gen_interval[0], VTY_NEWLINE);
                   3072:                write++;
                   3073:              }
1.1.1.2   misho    3074:            if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL)
1.1       misho    3075:              {
                   3076:                vty_out (vty, " lsp-gen-interval level-2 %d%s",
                   3077:                         area->lsp_gen_interval[1], VTY_NEWLINE);
                   3078:                write++;
                   3079:              }
                   3080:          }
                   3081:        /* ISIS - LSP lifetime */
                   3082:        if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1])
                   3083:          {
1.1.1.2   misho    3084:            if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
1.1       misho    3085:              {
1.1.1.2   misho    3086:                vty_out (vty, " max-lsp-lifetime %u%s", area->max_lsp_lifetime[0],
1.1       misho    3087:                         VTY_NEWLINE);
                   3088:                write++;
                   3089:              }
                   3090:          }
                   3091:        else
                   3092:          {
1.1.1.2   misho    3093:            if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
1.1       misho    3094:              {
1.1.1.2   misho    3095:                vty_out (vty, " max-lsp-lifetime level-1 %u%s",
1.1       misho    3096:                         area->max_lsp_lifetime[0], VTY_NEWLINE);
                   3097:                write++;
                   3098:              }
1.1.1.2   misho    3099:            if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME)
1.1       misho    3100:              {
1.1.1.2   misho    3101:                vty_out (vty, " max-lsp-lifetime level-2 %u%s",
1.1       misho    3102:                         area->max_lsp_lifetime[1], VTY_NEWLINE);
                   3103:                write++;
                   3104:              }
                   3105:          }
1.1.1.2   misho    3106:        /* ISIS - LSP refresh interval */
                   3107:        if (area->lsp_refresh[0] == area->lsp_refresh[1])
                   3108:          {
                   3109:            if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
                   3110:              {
                   3111:                vty_out (vty, " lsp-refresh-interval %u%s", area->lsp_refresh[0],
                   3112:                         VTY_NEWLINE);
                   3113:                write++;
                   3114:              }
                   3115:          }
                   3116:        else
                   3117:          {
                   3118:            if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
                   3119:              {
                   3120:                vty_out (vty, " lsp-refresh-interval level-1 %u%s",
                   3121:                         area->lsp_refresh[0], VTY_NEWLINE);
                   3122:                write++;
                   3123:              }
                   3124:            if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL)
                   3125:              {
                   3126:                vty_out (vty, " lsp-refresh-interval level-2 %u%s",
                   3127:                         area->lsp_refresh[1], VTY_NEWLINE);
                   3128:                write++;
                   3129:              }
                   3130:          }
1.1.1.4 ! misho    3131:        if (area->lsp_mtu != DEFAULT_LSP_MTU)
        !          3132:          {
        !          3133:            vty_out(vty, " lsp-mtu %u%s", area->lsp_mtu, VTY_NEWLINE);
        !          3134:            write++;
        !          3135:          }
        !          3136: 
1.1       misho    3137:        /* Minimum SPF interval. */
                   3138:        if (area->min_spf_interval[0] == area->min_spf_interval[1])
                   3139:          {
                   3140:            if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
                   3141:              {
                   3142:                vty_out (vty, " spf-interval %d%s",
                   3143:                         area->min_spf_interval[0], VTY_NEWLINE);
                   3144:                write++;
                   3145:              }
                   3146:          }
                   3147:        else
                   3148:          {
                   3149:            if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
                   3150:              {
                   3151:                vty_out (vty, " spf-interval level-1 %d%s",
                   3152:                         area->min_spf_interval[0], VTY_NEWLINE);
                   3153:                write++;
                   3154:              }
                   3155:            if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL)
                   3156:              {
                   3157:                vty_out (vty, " spf-interval level-2 %d%s",
                   3158:                         area->min_spf_interval[1], VTY_NEWLINE);
                   3159:                write++;
                   3160:              }
                   3161:          }
                   3162:        /* Authentication passwords. */
1.1.1.2   misho    3163:        if (area->area_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
1.1       misho    3164:          {
1.1.1.2   misho    3165:            vty_out(vty, " area-password md5 %s", area->area_passwd.passwd);
                   3166:            if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
                   3167:              {
                   3168:                vty_out(vty, " authenticate snp ");
                   3169:                if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
                   3170:                  vty_out(vty, "validate");
                   3171:                else
                   3172:                  vty_out(vty, "send-only");
                   3173:              }
                   3174:            vty_out(vty, "%s", VTY_NEWLINE);
                   3175:            write++; 
                   3176:          }
                   3177:         else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
                   3178:           {
                   3179:            vty_out(vty, " area-password clear %s", area->area_passwd.passwd);
1.1       misho    3180:            if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
                   3181:              {
                   3182:                vty_out(vty, " authenticate snp ");
                   3183:                if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
                   3184:                  vty_out(vty, "validate");
                   3185:                else
                   3186:                  vty_out(vty, "send-only");
                   3187:              }
                   3188:            vty_out(vty, "%s", VTY_NEWLINE);
                   3189:            write++; 
1.1.1.2   misho    3190:           }
                   3191:        if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
1.1       misho    3192:          {
1.1.1.2   misho    3193:             vty_out(vty, " domain-password md5 %s",
                   3194:                     area->domain_passwd.passwd);
                   3195:            if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
                   3196:              {
                   3197:                vty_out(vty, " authenticate snp ");
                   3198:                if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
                   3199:                  vty_out(vty, "validate");
                   3200:                else
                   3201:                  vty_out(vty, "send-only");
                   3202:              }
                   3203:            vty_out(vty, "%s", VTY_NEWLINE);
                   3204:            write++;
                   3205:          }
                   3206:         else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
                   3207:          {
                   3208:            vty_out(vty, " domain-password clear %s",
                   3209:                     area->domain_passwd.passwd); 
1.1       misho    3210:            if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
                   3211:              {
                   3212:                vty_out(vty, " authenticate snp ");
                   3213:                if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
                   3214:                  vty_out(vty, "validate");
                   3215:                else
                   3216:                  vty_out(vty, "send-only");
                   3217:              }
                   3218:            vty_out(vty, "%s", VTY_NEWLINE);
                   3219:            write++;
                   3220:          }
                   3221: 
1.1.1.2   misho    3222:        if (area->log_adj_changes)
                   3223:          {
                   3224:            vty_out (vty, " log-adjacency-changes%s", VTY_NEWLINE);
                   3225:            write++;
                   3226:          }
                   3227: 
1.1       misho    3228: #ifdef TOPOLOGY_GENERATE
                   3229:        if (memcmp (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS,
                   3230:                    ISIS_SYS_ID_LEN))
                   3231:          {
                   3232:            vty_out (vty, " topology base-is %s%s",
1.1.1.2   misho    3233:                     sysid_print ((u_char *)area->topology_baseis), VTY_NEWLINE);
1.1       misho    3234:            write++;
                   3235:          }
                   3236:        if (area->topology_basedynh)
                   3237:          {
                   3238:            vty_out (vty, " topology base-dynh %s%s",
                   3239:                     area->topology_basedynh, VTY_NEWLINE);
                   3240:            write++;
                   3241:          }
                   3242:        /* We save the whole command line here. */
                   3243:        if (strlen(area->top_params))
                   3244:          {
                   3245:            vty_out (vty, " %s%s", area->top_params, VTY_NEWLINE);
                   3246:            write++;
                   3247:          }
                   3248: #endif /* TOPOLOGY_GENERATE */
                   3249: 
                   3250:       }
                   3251:     }
                   3252: 
                   3253:   return write;
                   3254: }
                   3255: 
1.1.1.2   misho    3256: struct cmd_node isis_node = {
1.1       misho    3257:   ISIS_NODE,
                   3258:   "%s(config-router)# ",
                   3259:   1
                   3260: };
                   3261: 
                   3262: void
                   3263: isis_init ()
                   3264: {
                   3265:   /* Install IS-IS top node */
                   3266:   install_node (&isis_node, isis_config_write);
                   3267: 
1.1.1.2   misho    3268:   install_element (VIEW_NODE, &show_isis_summary_cmd);
                   3269: 
                   3270:   install_element (VIEW_NODE, &show_isis_interface_cmd);
                   3271:   install_element (VIEW_NODE, &show_isis_interface_detail_cmd);
                   3272:   install_element (VIEW_NODE, &show_isis_interface_arg_cmd);
                   3273: 
                   3274:   install_element (VIEW_NODE, &show_isis_neighbor_cmd);
                   3275:   install_element (VIEW_NODE, &show_isis_neighbor_detail_cmd);
                   3276:   install_element (VIEW_NODE, &show_isis_neighbor_arg_cmd);
                   3277:   install_element (VIEW_NODE, &clear_isis_neighbor_cmd);
                   3278:   install_element (VIEW_NODE, &clear_isis_neighbor_arg_cmd);
1.1       misho    3279: 
                   3280:   install_element (VIEW_NODE, &show_hostname_cmd);
                   3281:   install_element (VIEW_NODE, &show_database_cmd);
1.1.1.2   misho    3282:   install_element (VIEW_NODE, &show_database_arg_cmd);
                   3283:   install_element (VIEW_NODE, &show_database_arg_detail_cmd);
1.1       misho    3284:   install_element (VIEW_NODE, &show_database_detail_cmd);
1.1.1.2   misho    3285:   install_element (VIEW_NODE, &show_database_detail_arg_cmd);
                   3286: 
                   3287:   install_element (ENABLE_NODE, &show_isis_summary_cmd);
1.1       misho    3288: 
1.1.1.2   misho    3289:   install_element (ENABLE_NODE, &show_isis_interface_cmd);
                   3290:   install_element (ENABLE_NODE, &show_isis_interface_detail_cmd);
                   3291:   install_element (ENABLE_NODE, &show_isis_interface_arg_cmd);
                   3292: 
                   3293:   install_element (ENABLE_NODE, &show_isis_neighbor_cmd);
                   3294:   install_element (ENABLE_NODE, &show_isis_neighbor_detail_cmd);
                   3295:   install_element (ENABLE_NODE, &show_isis_neighbor_arg_cmd);
                   3296:   install_element (ENABLE_NODE, &clear_isis_neighbor_cmd);
                   3297:   install_element (ENABLE_NODE, &clear_isis_neighbor_arg_cmd);
1.1       misho    3298: 
                   3299:   install_element (ENABLE_NODE, &show_hostname_cmd);
                   3300:   install_element (ENABLE_NODE, &show_database_cmd);
1.1.1.2   misho    3301:   install_element (ENABLE_NODE, &show_database_arg_cmd);
                   3302:   install_element (ENABLE_NODE, &show_database_arg_detail_cmd);
1.1       misho    3303:   install_element (ENABLE_NODE, &show_database_detail_cmd);
1.1.1.2   misho    3304:   install_element (ENABLE_NODE, &show_database_detail_arg_cmd);
1.1       misho    3305:   install_element (ENABLE_NODE, &show_debugging_cmd);
                   3306: 
                   3307:   install_node (&debug_node, config_write_debug);
                   3308: 
                   3309:   install_element (ENABLE_NODE, &debug_isis_adj_cmd);
                   3310:   install_element (ENABLE_NODE, &no_debug_isis_adj_cmd);
                   3311:   install_element (ENABLE_NODE, &debug_isis_csum_cmd);
                   3312:   install_element (ENABLE_NODE, &no_debug_isis_csum_cmd);
                   3313:   install_element (ENABLE_NODE, &debug_isis_lupd_cmd);
                   3314:   install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd);
                   3315:   install_element (ENABLE_NODE, &debug_isis_err_cmd);
                   3316:   install_element (ENABLE_NODE, &no_debug_isis_err_cmd);
                   3317:   install_element (ENABLE_NODE, &debug_isis_snp_cmd);
                   3318:   install_element (ENABLE_NODE, &no_debug_isis_snp_cmd);
                   3319:   install_element (ENABLE_NODE, &debug_isis_upd_cmd);
                   3320:   install_element (ENABLE_NODE, &no_debug_isis_upd_cmd);
                   3321:   install_element (ENABLE_NODE, &debug_isis_spfevents_cmd);
                   3322:   install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd);
                   3323:   install_element (ENABLE_NODE, &debug_isis_spfstats_cmd);
                   3324:   install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd);
                   3325:   install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd);
                   3326:   install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd);
                   3327:   install_element (ENABLE_NODE, &debug_isis_rtevents_cmd);
                   3328:   install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd);
                   3329:   install_element (ENABLE_NODE, &debug_isis_events_cmd);
                   3330:   install_element (ENABLE_NODE, &no_debug_isis_events_cmd);
1.1.1.2   misho    3331:   install_element (ENABLE_NODE, &debug_isis_packet_dump_cmd);
                   3332:   install_element (ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
1.1.1.4 ! misho    3333:   install_element (ENABLE_NODE, &debug_isis_lsp_gen_cmd);
        !          3334:   install_element (ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
        !          3335:   install_element (ENABLE_NODE, &debug_isis_lsp_sched_cmd);
        !          3336:   install_element (ENABLE_NODE, &no_debug_isis_lsp_sched_cmd);
1.1       misho    3337: 
                   3338:   install_element (CONFIG_NODE, &debug_isis_adj_cmd);
                   3339:   install_element (CONFIG_NODE, &no_debug_isis_adj_cmd);
                   3340:   install_element (CONFIG_NODE, &debug_isis_csum_cmd);
                   3341:   install_element (CONFIG_NODE, &no_debug_isis_csum_cmd);
                   3342:   install_element (CONFIG_NODE, &debug_isis_lupd_cmd);
                   3343:   install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd);
                   3344:   install_element (CONFIG_NODE, &debug_isis_err_cmd);
                   3345:   install_element (CONFIG_NODE, &no_debug_isis_err_cmd);
                   3346:   install_element (CONFIG_NODE, &debug_isis_snp_cmd);
                   3347:   install_element (CONFIG_NODE, &no_debug_isis_snp_cmd);
                   3348:   install_element (CONFIG_NODE, &debug_isis_upd_cmd);
                   3349:   install_element (CONFIG_NODE, &no_debug_isis_upd_cmd);
                   3350:   install_element (CONFIG_NODE, &debug_isis_spfevents_cmd);
                   3351:   install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd);
                   3352:   install_element (CONFIG_NODE, &debug_isis_spfstats_cmd);
                   3353:   install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd);
                   3354:   install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd);
                   3355:   install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd);
                   3356:   install_element (CONFIG_NODE, &debug_isis_rtevents_cmd);
                   3357:   install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd);
                   3358:   install_element (CONFIG_NODE, &debug_isis_events_cmd);
                   3359:   install_element (CONFIG_NODE, &no_debug_isis_events_cmd);
1.1.1.2   misho    3360:   install_element (CONFIG_NODE, &debug_isis_packet_dump_cmd);
                   3361:   install_element (CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
1.1.1.4 ! misho    3362:   install_element (CONFIG_NODE, &debug_isis_lsp_gen_cmd);
        !          3363:   install_element (CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
        !          3364:   install_element (CONFIG_NODE, &debug_isis_lsp_sched_cmd);
        !          3365:   install_element (CONFIG_NODE, &no_debug_isis_lsp_sched_cmd);
1.1       misho    3366: 
                   3367:   install_element (CONFIG_NODE, &router_isis_cmd);
                   3368:   install_element (CONFIG_NODE, &no_router_isis_cmd);
                   3369: 
                   3370:   install_default (ISIS_NODE);
                   3371: 
                   3372:   install_element (ISIS_NODE, &net_cmd);
                   3373:   install_element (ISIS_NODE, &no_net_cmd);
                   3374: 
                   3375:   install_element (ISIS_NODE, &is_type_cmd);
                   3376:   install_element (ISIS_NODE, &no_is_type_cmd);
                   3377: 
1.1.1.4 ! misho    3378:   install_element (ISIS_NODE, &area_lsp_mtu_cmd);
        !          3379:   install_element (ISIS_NODE, &no_area_lsp_mtu_cmd);
        !          3380:   install_element (ISIS_NODE, &no_area_lsp_mtu_arg_cmd);
        !          3381: 
1.1.1.2   misho    3382:   install_element (ISIS_NODE, &area_passwd_md5_cmd);
                   3383:   install_element (ISIS_NODE, &area_passwd_md5_snpauth_cmd);
                   3384:   install_element (ISIS_NODE, &area_passwd_clear_cmd);
                   3385:   install_element (ISIS_NODE, &area_passwd_clear_snpauth_cmd);
1.1       misho    3386:   install_element (ISIS_NODE, &no_area_passwd_cmd);
                   3387: 
1.1.1.2   misho    3388:   install_element (ISIS_NODE, &domain_passwd_md5_cmd);
                   3389:   install_element (ISIS_NODE, &domain_passwd_md5_snpauth_cmd);
                   3390:   install_element (ISIS_NODE, &domain_passwd_clear_cmd);
                   3391:   install_element (ISIS_NODE, &domain_passwd_clear_snpauth_cmd);
1.1       misho    3392:   install_element (ISIS_NODE, &no_domain_passwd_cmd);
                   3393: 
                   3394:   install_element (ISIS_NODE, &lsp_gen_interval_cmd);
                   3395:   install_element (ISIS_NODE, &no_lsp_gen_interval_cmd);
                   3396:   install_element (ISIS_NODE, &no_lsp_gen_interval_arg_cmd);
                   3397:   install_element (ISIS_NODE, &lsp_gen_interval_l1_cmd);
                   3398:   install_element (ISIS_NODE, &no_lsp_gen_interval_l1_cmd);
                   3399:   install_element (ISIS_NODE, &no_lsp_gen_interval_l1_arg_cmd);
                   3400:   install_element (ISIS_NODE, &lsp_gen_interval_l2_cmd);
                   3401:   install_element (ISIS_NODE, &no_lsp_gen_interval_l2_cmd);
                   3402:   install_element (ISIS_NODE, &no_lsp_gen_interval_l2_arg_cmd);
                   3403: 
                   3404:   install_element (ISIS_NODE, &spf_interval_cmd);
                   3405:   install_element (ISIS_NODE, &no_spf_interval_cmd);
                   3406:   install_element (ISIS_NODE, &no_spf_interval_arg_cmd);
                   3407:   install_element (ISIS_NODE, &spf_interval_l1_cmd);
                   3408:   install_element (ISIS_NODE, &no_spf_interval_l1_cmd);
                   3409:   install_element (ISIS_NODE, &no_spf_interval_l1_arg_cmd);
                   3410:   install_element (ISIS_NODE, &spf_interval_l2_cmd);
                   3411:   install_element (ISIS_NODE, &no_spf_interval_l2_cmd);
                   3412:   install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd);
                   3413: 
1.1.1.2   misho    3414:   install_element (ISIS_NODE, &max_lsp_lifetime_cmd);
                   3415:   install_element (ISIS_NODE, &no_max_lsp_lifetime_cmd);
                   3416:   install_element (ISIS_NODE, &no_max_lsp_lifetime_arg_cmd);
                   3417:   install_element (ISIS_NODE, &max_lsp_lifetime_l1_cmd);
                   3418:   install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_cmd);
                   3419:   install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_arg_cmd);
                   3420:   install_element (ISIS_NODE, &max_lsp_lifetime_l2_cmd);
                   3421:   install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_cmd);
                   3422:   install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_arg_cmd);
                   3423: 
                   3424:   install_element (ISIS_NODE, &lsp_refresh_interval_cmd);
                   3425:   install_element (ISIS_NODE, &no_lsp_refresh_interval_cmd);
                   3426:   install_element (ISIS_NODE, &no_lsp_refresh_interval_arg_cmd);
                   3427:   install_element (ISIS_NODE, &lsp_refresh_interval_l1_cmd);
                   3428:   install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_cmd);
                   3429:   install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_arg_cmd);
                   3430:   install_element (ISIS_NODE, &lsp_refresh_interval_l2_cmd);
                   3431:   install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_cmd);
                   3432:   install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_arg_cmd);
                   3433: 
                   3434:   install_element (ISIS_NODE, &set_overload_bit_cmd);
                   3435:   install_element (ISIS_NODE, &no_set_overload_bit_cmd);
1.1.1.4 ! misho    3436: 
        !          3437:   install_element (ISIS_NODE, &set_attached_bit_cmd);
        !          3438:   install_element (ISIS_NODE, &no_set_attached_bit_cmd);
1.1       misho    3439: 
                   3440:   install_element (ISIS_NODE, &dynamic_hostname_cmd);
                   3441:   install_element (ISIS_NODE, &no_dynamic_hostname_cmd);
                   3442: 
                   3443:   install_element (ISIS_NODE, &metric_style_cmd);
                   3444:   install_element (ISIS_NODE, &no_metric_style_cmd);
1.1.1.2   misho    3445: 
                   3446:   install_element (ISIS_NODE, &log_adj_changes_cmd);
                   3447:   install_element (ISIS_NODE, &no_log_adj_changes_cmd);
                   3448: 
1.1       misho    3449: #ifdef TOPOLOGY_GENERATE
                   3450:   install_element (ISIS_NODE, &topology_generate_grid_cmd);
                   3451:   install_element (ISIS_NODE, &topology_baseis_cmd);
                   3452:   install_element (ISIS_NODE, &topology_basedynh_cmd);
                   3453:   install_element (ISIS_NODE, &no_topology_baseis_cmd);
                   3454:   install_element (ISIS_NODE, &no_topology_baseis_noid_cmd);
                   3455:   install_element (VIEW_NODE, &show_isis_generated_topology_cmd);
                   3456:   install_element (ENABLE_NODE, &show_isis_generated_topology_cmd);
                   3457: #endif /* TOPOLOGY_GENERATE */
                   3458: }

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