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