]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isisd.c
*: remove THREAD_ON macros, add nullity check
[mirror_frr.git] / isisd / isisd.c
1 /*
2 * IS-IS Rout(e)ing protocol - isisd.c
3 *
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public Licenseas published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
23 #include <zebra.h>
24
25 #include "thread.h"
26 #include "vty.h"
27 #include "command.h"
28 #include "log.h"
29 #include "memory.h"
30 #include "time.h"
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 #include "qobj.h"
38 #include "spf_backoff.h"
39
40 #include "isisd/dict.h"
41 #include "isisd/isis_constants.h"
42 #include "isisd/isis_common.h"
43 #include "isisd/isis_flags.h"
44 #include "isisd/isis_circuit.h"
45 #include "isisd/isis_csm.h"
46 #include "isisd/isisd.h"
47 #include "isisd/isis_dynhn.h"
48 #include "isisd/isis_adjacency.h"
49 #include "isisd/isis_pdu.h"
50 #include "isisd/isis_misc.h"
51 #include "isisd/isis_constants.h"
52 #include "isisd/isis_tlv.h"
53 #include "isisd/isis_lsp.h"
54 #include "isisd/isis_spf.h"
55 #include "isisd/isis_route.h"
56 #include "isisd/isis_zebra.h"
57 #include "isisd/isis_events.h"
58 #include "isisd/isis_te.h"
59 #include "isisd/isis_mt.h"
60
61 struct isis *isis = NULL;
62
63 DEFINE_QOBJ_TYPE(isis)
64 DEFINE_QOBJ_TYPE(isis_area)
65
66 /*
67 * Prototypes.
68 */
69 int isis_area_get(struct vty *, const char *);
70 int isis_area_destroy(struct vty *, const char *);
71 int area_net_title(struct vty *, const char *);
72 int area_clear_net_title(struct vty *, const char *);
73 int show_isis_interface_common(struct vty *, const char *ifname, char);
74 int show_isis_neighbor_common(struct vty *, const char *id, char);
75 int clear_isis_neighbor_common(struct vty *, const char *id);
76 int isis_config_write(struct vty *);
77
78
79
80 void
81 isis_new (unsigned long process_id)
82 {
83 isis = XCALLOC (MTYPE_ISIS, sizeof (struct isis));
84 /*
85 * Default values
86 */
87 isis->max_area_addrs = 3;
88 isis->process_id = process_id;
89 isis->router_id = 0;
90 isis->area_list = list_new ();
91 isis->init_circ_list = list_new ();
92 isis->uptime = time (NULL);
93 isis->nexthops = list_new ();
94 isis->nexthops6 = list_new ();
95 dyn_cache_init ();
96 /*
97 * uncomment the next line for full debugs
98 */
99 /* isis->debugs = 0xFFFF; */
100 isisMplsTE.status = disable; /* Only support TE metric */
101 QOBJ_REG (isis, isis);
102 }
103
104 struct isis_area *
105 isis_area_create (const char *area_tag)
106 {
107 struct isis_area *area;
108
109 area = XCALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area));
110
111 /*
112 * The first instance is level-1-2 rest are level-1, unless otherwise
113 * configured
114 */
115 if (listcount (isis->area_list) > 0)
116 area->is_type = IS_LEVEL_1;
117 else
118 area->is_type = IS_LEVEL_1_AND_2;
119
120 /*
121 * intialize the databases
122 */
123 if (area->is_type & IS_LEVEL_1)
124 {
125 area->lspdb[0] = lsp_db_init ();
126 area->route_table[0] = route_table_init ();
127 area->route_table6[0] = route_table_init ();
128 }
129 if (area->is_type & IS_LEVEL_2)
130 {
131 area->lspdb[1] = lsp_db_init ();
132 area->route_table[1] = route_table_init ();
133 area->route_table6[1] = route_table_init ();
134 }
135
136 spftree_area_init (area);
137
138 area->circuit_list = list_new ();
139 area->area_addrs = list_new ();
140 thread_add_timer(master, lsp_tick, area, 1, &area->t_tick);
141 flags_initialize (&area->flags);
142
143 /*
144 * Default values
145 */
146 area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */
147 area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */
148 area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
149 area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
150 area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL;
151 area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL;
152 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
153 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
154 area->dynhostname = 1;
155 area->oldmetric = 0;
156 area->newmetric = 1;
157 area->lsp_frag_threshold = 90;
158 area->lsp_mtu = DEFAULT_LSP_MTU;
159
160 area_mt_init(area);
161
162 area->area_tag = strdup (area_tag);
163 listnode_add (isis->area_list, area);
164 area->isis = isis;
165
166 QOBJ_REG (area, isis_area);
167
168 return area;
169 }
170
171 struct isis_area *
172 isis_area_lookup (const char *area_tag)
173 {
174 struct isis_area *area;
175 struct listnode *node;
176
177 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
178 if ((area->area_tag == NULL && area_tag == NULL) ||
179 (area->area_tag && area_tag
180 && strcmp (area->area_tag, area_tag) == 0))
181 return area;
182
183 return NULL;
184 }
185
186 int
187 isis_area_get (struct vty *vty, const char *area_tag)
188 {
189 struct isis_area *area;
190
191 area = isis_area_lookup (area_tag);
192
193 if (area)
194 {
195 VTY_PUSH_CONTEXT (ISIS_NODE, area);
196 return CMD_SUCCESS;
197 }
198
199 area = isis_area_create (area_tag);
200
201 if (isis->debugs & DEBUG_EVENTS)
202 zlog_debug ("New IS-IS area instance %s", area->area_tag);
203
204 VTY_PUSH_CONTEXT (ISIS_NODE, area);
205
206 return CMD_SUCCESS;
207 }
208
209 int
210 isis_area_destroy (struct vty *vty, const char *area_tag)
211 {
212 struct isis_area *area;
213 struct listnode *node, *nnode;
214 struct isis_circuit *circuit;
215 struct area_addr *addr;
216
217 area = isis_area_lookup (area_tag);
218
219 if (area == NULL)
220 {
221 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
222 return CMD_ERR_NO_MATCH;
223 }
224
225 QOBJ_UNREG (area);
226
227 if (area->circuit_list)
228 {
229 for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
230 {
231 circuit->ip_router = 0;
232 circuit->ipv6_router = 0;
233 isis_csm_state_change (ISIS_DISABLE, circuit, area);
234 }
235 list_delete (area->circuit_list);
236 area->circuit_list = NULL;
237 }
238
239 if (area->lspdb[0] != NULL)
240 {
241 lsp_db_destroy (area->lspdb[0]);
242 area->lspdb[0] = NULL;
243 }
244 if (area->lspdb[1] != NULL)
245 {
246 lsp_db_destroy (area->lspdb[1]);
247 area->lspdb[1] = NULL;
248 }
249
250 spftree_area_del (area);
251
252 THREAD_TIMER_OFF(area->spf_timer[0]);
253 THREAD_TIMER_OFF(area->spf_timer[1]);
254
255 spf_backoff_free(area->spf_delay_ietf[0]);
256 spf_backoff_free(area->spf_delay_ietf[1]);
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 if (area->route_table6[0])
273 {
274 route_table_finish (area->route_table6[0]);
275 area->route_table6[0] = NULL;
276 }
277 if (area->route_table6[1])
278 {
279 route_table_finish (area->route_table6[1]);
280 area->route_table6[1] = NULL;
281 }
282
283 isis_redist_area_finish(area);
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
292 THREAD_TIMER_OFF (area->t_tick);
293 THREAD_TIMER_OFF (area->t_lsp_refresh[0]);
294 THREAD_TIMER_OFF (area->t_lsp_refresh[1]);
295
296 thread_cancel_event (master, area);
297
298 listnode_delete (isis->area_list, area);
299
300 free (area->area_tag);
301
302 area_mt_finish(area);
303
304 XFREE (MTYPE_ISIS_AREA, area);
305
306 if (listcount (isis->area_list) == 0)
307 {
308 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
309 isis->sysid_set = 0;
310 }
311
312 return CMD_SUCCESS;
313 }
314
315 static void
316 area_set_mt_enabled(struct isis_area *area, uint16_t mtid, bool enabled)
317 {
318 struct isis_area_mt_setting *setting;
319
320 setting = area_get_mt_setting(area, mtid);
321 if (setting->enabled != enabled)
322 {
323 setting->enabled = enabled;
324 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
325 }
326 }
327
328 static void
329 area_set_mt_overload(struct isis_area *area, uint16_t mtid, bool overload)
330 {
331 struct isis_area_mt_setting *setting;
332
333 setting = area_get_mt_setting(area, mtid);
334 if (setting->overload != overload)
335 {
336 setting->overload = overload;
337 if (setting->enabled)
338 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
339 }
340 }
341
342 int
343 area_net_title (struct vty *vty, const char *net_title)
344 {
345 VTY_DECLVAR_CONTEXT (isis_area, area);
346 struct area_addr *addr;
347 struct area_addr *addrp;
348 struct listnode *node;
349
350 u_char buff[255];
351
352 /* We check that we are not over the maximal number of addresses */
353 if (listcount (area->area_addrs) >= isis->max_area_addrs)
354 {
355 vty_out (vty, "Maximum of area addresses (%d) already reached %s",
356 isis->max_area_addrs, VTY_NEWLINE);
357 return CMD_ERR_NOTHING_TODO;
358 }
359
360 addr = XMALLOC (MTYPE_ISIS_AREA_ADDR, sizeof (struct area_addr));
361 addr->addr_len = dotformat2buff (buff, net_title);
362 memcpy (addr->area_addr, buff, addr->addr_len);
363 #ifdef EXTREME_DEBUG
364 zlog_debug ("added area address %s for area %s (address length %d)",
365 net_title, area->area_tag, addr->addr_len);
366 #endif /* EXTREME_DEBUG */
367 if (addr->addr_len < 8 || addr->addr_len > 20)
368 {
369 vty_out (vty, "area address must be at least 8..20 octets long (%d)%s",
370 addr->addr_len, VTY_NEWLINE);
371 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
372 return CMD_ERR_AMBIGUOUS;
373 }
374
375 if (addr->area_addr[addr->addr_len-1] != 0)
376 {
377 vty_out (vty, "nsel byte (last byte) in area address must be 0%s",
378 VTY_NEWLINE);
379 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
380 return CMD_ERR_AMBIGUOUS;
381 }
382
383 if (isis->sysid_set == 0)
384 {
385 /*
386 * First area address - get the SystemID for this router
387 */
388 memcpy (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN);
389 isis->sysid_set = 1;
390 if (isis->debugs & DEBUG_EVENTS)
391 zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid));
392 }
393 else
394 {
395 /*
396 * Check that the SystemID portions match
397 */
398 if (memcmp (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN))
399 {
400 vty_out (vty,
401 "System ID must not change when defining additional area"
402 " addresses%s", VTY_NEWLINE);
403 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
404 return CMD_ERR_AMBIGUOUS;
405 }
406
407 /* now we see that we don't already have this address */
408 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
409 {
410 if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != (addr->addr_len))
411 continue;
412 if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
413 {
414 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
415 return CMD_SUCCESS; /* silent fail */
416 }
417 }
418 }
419
420 /*
421 * Forget the systemID part of the address
422 */
423 addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
424 listnode_add (area->area_addrs, addr);
425
426 /* only now we can safely generate our LSPs for this area */
427 if (listcount (area->area_addrs) > 0)
428 {
429 if (area->is_type & IS_LEVEL_1)
430 lsp_generate (area, IS_LEVEL_1);
431 if (area->is_type & IS_LEVEL_2)
432 lsp_generate (area, IS_LEVEL_2);
433 }
434
435 return CMD_SUCCESS;
436 }
437
438 int
439 area_clear_net_title (struct vty *vty, const char *net_title)
440 {
441 VTY_DECLVAR_CONTEXT (isis_area, area);
442 struct area_addr addr, *addrp = NULL;
443 struct listnode *node;
444 u_char buff[255];
445
446 addr.addr_len = dotformat2buff (buff, net_title);
447 if (addr.addr_len < 8 || addr.addr_len > 20)
448 {
449 vty_out (vty, "Unsupported area address length %d, should be 8...20 %s",
450 addr.addr_len, VTY_NEWLINE);
451 return CMD_ERR_AMBIGUOUS;
452 }
453
454 memcpy (addr.area_addr, buff, (int) addr.addr_len);
455
456 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
457 if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len &&
458 !memcmp (addrp->area_addr, addr.area_addr, addr.addr_len))
459 break;
460
461 if (!addrp)
462 {
463 vty_out (vty, "No area address %s for area %s %s", net_title,
464 area->area_tag, VTY_NEWLINE);
465 return CMD_ERR_NO_MATCH;
466 }
467
468 listnode_delete (area->area_addrs, addrp);
469 XFREE (MTYPE_ISIS_AREA_ADDR, addrp);
470
471 /*
472 * Last area address - reset the SystemID for this router
473 */
474 if (listcount (area->area_addrs) == 0)
475 {
476 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
477 isis->sysid_set = 0;
478 if (isis->debugs & DEBUG_EVENTS)
479 zlog_debug ("Router has no SystemID");
480 }
481
482 return CMD_SUCCESS;
483 }
484
485 /*
486 * 'show isis interface' command
487 */
488
489 int
490 show_isis_interface_common (struct vty *vty, const char *ifname, char detail)
491 {
492 struct listnode *anode, *cnode;
493 struct isis_area *area;
494 struct isis_circuit *circuit;
495
496 if (!isis)
497 {
498 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
499 return CMD_SUCCESS;
500 }
501
502 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
503 {
504 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
505
506 if (detail == ISIS_UI_LEVEL_BRIEF)
507 vty_out (vty, " Interface CircId State Type Level%s",
508 VTY_NEWLINE);
509
510 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
511 if (!ifname)
512 isis_circuit_print_vty (circuit, vty, detail);
513 else if (strcmp(circuit->interface->name, ifname) == 0)
514 isis_circuit_print_vty (circuit, vty, detail);
515 }
516
517 return CMD_SUCCESS;
518 }
519
520 DEFUN (show_isis_interface,
521 show_isis_interface_cmd,
522 "show isis interface",
523 SHOW_STR
524 "ISIS network information\n"
525 "ISIS interface\n")
526 {
527 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
528 }
529
530 DEFUN (show_isis_interface_detail,
531 show_isis_interface_detail_cmd,
532 "show isis interface detail",
533 SHOW_STR
534 "ISIS network information\n"
535 "ISIS interface\n"
536 "show detailed information\n")
537 {
538 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
539 }
540
541 DEFUN (show_isis_interface_arg,
542 show_isis_interface_arg_cmd,
543 "show isis interface WORD",
544 SHOW_STR
545 "ISIS network information\n"
546 "ISIS interface\n"
547 "ISIS interface name\n")
548 {
549 int idx_word = 3;
550 return show_isis_interface_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
551 }
552
553 /*
554 * 'show isis neighbor' command
555 */
556
557 int
558 show_isis_neighbor_common (struct vty *vty, const char *id, char detail)
559 {
560 struct listnode *anode, *cnode, *node;
561 struct isis_area *area;
562 struct isis_circuit *circuit;
563 struct list *adjdb;
564 struct isis_adjacency *adj;
565 struct isis_dynhn *dynhn;
566 u_char sysid[ISIS_SYS_ID_LEN];
567 int i;
568
569 if (!isis)
570 {
571 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
572 return CMD_SUCCESS;
573 }
574
575 memset (sysid, 0, ISIS_SYS_ID_LEN);
576 if (id)
577 {
578 if (sysid2buff (sysid, id) == 0)
579 {
580 dynhn = dynhn_find_by_name (id);
581 if (dynhn == NULL)
582 {
583 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
584 return CMD_SUCCESS;
585 }
586 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
587 }
588 }
589
590 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
591 {
592 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
593
594 if (detail == ISIS_UI_LEVEL_BRIEF)
595 vty_out (vty, " System Id Interface L State"
596 " Holdtime SNPA%s", VTY_NEWLINE);
597
598 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
599 {
600 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
601 {
602 for (i = 0; i < 2; i++)
603 {
604 adjdb = circuit->u.bc.adjdb[i];
605 if (adjdb && adjdb->count)
606 {
607 for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
608 if (!id || !memcmp (adj->sysid, sysid,
609 ISIS_SYS_ID_LEN))
610 isis_adj_print_vty (adj, vty, detail);
611 }
612 }
613 }
614 else if (circuit->circ_type == CIRCUIT_T_P2P &&
615 circuit->u.p2p.neighbor)
616 {
617 adj = circuit->u.p2p.neighbor;
618 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
619 isis_adj_print_vty (adj, vty, detail);
620 }
621 }
622 }
623
624 return CMD_SUCCESS;
625 }
626
627 /*
628 * 'clear isis neighbor' command
629 */
630 int
631 clear_isis_neighbor_common (struct vty *vty, const char *id)
632 {
633 struct listnode *anode, *cnode, *cnextnode, *node, *nnode;
634 struct isis_area *area;
635 struct isis_circuit *circuit;
636 struct list *adjdb;
637 struct isis_adjacency *adj;
638 struct isis_dynhn *dynhn;
639 u_char sysid[ISIS_SYS_ID_LEN];
640 int i;
641
642 if (!isis)
643 {
644 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
645 return CMD_SUCCESS;
646 }
647
648 memset (sysid, 0, ISIS_SYS_ID_LEN);
649 if (id)
650 {
651 if (sysid2buff (sysid, id) == 0)
652 {
653 dynhn = dynhn_find_by_name (id);
654 if (dynhn == NULL)
655 {
656 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
657 return CMD_SUCCESS;
658 }
659 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
660 }
661 }
662
663 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
664 {
665 for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnextnode, circuit))
666 {
667 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
668 {
669 for (i = 0; i < 2; i++)
670 {
671 adjdb = circuit->u.bc.adjdb[i];
672 if (adjdb && adjdb->count)
673 {
674 for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj))
675 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
676 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
677 "clear user request");
678 }
679 }
680 }
681 else if (circuit->circ_type == CIRCUIT_T_P2P &&
682 circuit->u.p2p.neighbor)
683 {
684 adj = circuit->u.p2p.neighbor;
685 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
686 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
687 "clear user request");
688 }
689 }
690 }
691
692 return CMD_SUCCESS;
693 }
694
695 DEFUN (show_isis_neighbor,
696 show_isis_neighbor_cmd,
697 "show isis neighbor",
698 SHOW_STR
699 "ISIS network information\n"
700 "ISIS neighbor adjacencies\n")
701 {
702 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
703 }
704
705 DEFUN (show_isis_neighbor_detail,
706 show_isis_neighbor_detail_cmd,
707 "show isis neighbor detail",
708 SHOW_STR
709 "ISIS network information\n"
710 "ISIS neighbor adjacencies\n"
711 "show detailed information\n")
712 {
713 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
714 }
715
716 DEFUN (show_isis_neighbor_arg,
717 show_isis_neighbor_arg_cmd,
718 "show isis neighbor WORD",
719 SHOW_STR
720 "ISIS network information\n"
721 "ISIS neighbor adjacencies\n"
722 "System id\n")
723 {
724 int idx_word = 3;
725 return show_isis_neighbor_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
726 }
727
728 DEFUN (clear_isis_neighbor,
729 clear_isis_neighbor_cmd,
730 "clear isis neighbor",
731 CLEAR_STR
732 "Reset ISIS network information\n"
733 "Reset ISIS neighbor adjacencies\n")
734 {
735 return clear_isis_neighbor_common (vty, NULL);
736 }
737
738 DEFUN (clear_isis_neighbor_arg,
739 clear_isis_neighbor_arg_cmd,
740 "clear isis neighbor WORD",
741 CLEAR_STR
742 "ISIS network information\n"
743 "ISIS neighbor adjacencies\n"
744 "System id\n")
745 {
746 int idx_word = 3;
747 return clear_isis_neighbor_common (vty, argv[idx_word]->arg);
748 }
749
750 /*
751 * 'isis debug', 'show debugging'
752 */
753 void
754 print_debug (struct vty *vty, int flags, int onoff)
755 {
756 char onoffs[4];
757 if (onoff)
758 strcpy (onoffs, "on");
759 else
760 strcpy (onoffs, "off");
761
762 if (flags & DEBUG_ADJ_PACKETS)
763 vty_out (vty, "IS-IS Adjacency related packets debugging is %s%s", onoffs,
764 VTY_NEWLINE);
765 if (flags & DEBUG_CHECKSUM_ERRORS)
766 vty_out (vty, "IS-IS checksum errors debugging is %s%s", onoffs,
767 VTY_NEWLINE);
768 if (flags & DEBUG_LOCAL_UPDATES)
769 vty_out (vty, "IS-IS local updates debugging is %s%s", onoffs,
770 VTY_NEWLINE);
771 if (flags & DEBUG_PROTOCOL_ERRORS)
772 vty_out (vty, "IS-IS protocol errors debugging is %s%s", onoffs,
773 VTY_NEWLINE);
774 if (flags & DEBUG_SNP_PACKETS)
775 vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s%s", onoffs,
776 VTY_NEWLINE);
777 if (flags & DEBUG_SPF_EVENTS)
778 vty_out (vty, "IS-IS SPF events debugging is %s%s", onoffs, VTY_NEWLINE);
779 if (flags & DEBUG_SPF_STATS)
780 vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s%s",
781 onoffs, VTY_NEWLINE);
782 if (flags & DEBUG_SPF_TRIGGERS)
783 vty_out (vty, "IS-IS SPF triggering events debugging is %s%s", onoffs,
784 VTY_NEWLINE);
785 if (flags & DEBUG_UPDATE_PACKETS)
786 vty_out (vty, "IS-IS Update related packet debugging is %s%s", onoffs,
787 VTY_NEWLINE);
788 if (flags & DEBUG_RTE_EVENTS)
789 vty_out (vty, "IS-IS Route related debuggin is %s%s", onoffs,
790 VTY_NEWLINE);
791 if (flags & DEBUG_EVENTS)
792 vty_out (vty, "IS-IS Event debugging is %s%s", onoffs, VTY_NEWLINE);
793 if (flags & DEBUG_PACKET_DUMP)
794 vty_out (vty, "IS-IS Packet dump debugging is %s%s", onoffs, VTY_NEWLINE);
795 if (flags & DEBUG_LSP_GEN)
796 vty_out (vty, "IS-IS LSP generation debugging is %s%s", onoffs, VTY_NEWLINE);
797 if (flags & DEBUG_LSP_SCHED)
798 vty_out (vty, "IS-IS LSP scheduling debugging is %s%s", onoffs, VTY_NEWLINE);
799 }
800
801 DEFUN (show_debugging,
802 show_debugging_isis_cmd,
803 "show debugging isis",
804 SHOW_STR
805 "State of each debugging option\n"
806 ISIS_STR)
807 {
808 if (isis->debugs) {
809 vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
810 print_debug (vty, isis->debugs, 1);
811 }
812 return CMD_SUCCESS;
813 }
814
815 /* Debug node. */
816 static struct cmd_node debug_node = {
817 DEBUG_NODE,
818 "",
819 1
820 };
821
822 static int
823 config_write_debug (struct vty *vty)
824 {
825 int write = 0;
826 int flags = isis->debugs;
827
828 if (flags & DEBUG_ADJ_PACKETS)
829 {
830 vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
831 write++;
832 }
833 if (flags & DEBUG_CHECKSUM_ERRORS)
834 {
835 vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
836 write++;
837 }
838 if (flags & DEBUG_LOCAL_UPDATES)
839 {
840 vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
841 write++;
842 }
843 if (flags & DEBUG_PROTOCOL_ERRORS)
844 {
845 vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
846 write++;
847 }
848 if (flags & DEBUG_SNP_PACKETS)
849 {
850 vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
851 write++;
852 }
853 if (flags & DEBUG_SPF_EVENTS)
854 {
855 vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
856 write++;
857 }
858 if (flags & DEBUG_SPF_STATS)
859 {
860 vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
861 write++;
862 }
863 if (flags & DEBUG_SPF_TRIGGERS)
864 {
865 vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
866 write++;
867 }
868 if (flags & DEBUG_UPDATE_PACKETS)
869 {
870 vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
871 write++;
872 }
873 if (flags & DEBUG_RTE_EVENTS)
874 {
875 vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
876 write++;
877 }
878 if (flags & DEBUG_EVENTS)
879 {
880 vty_out (vty, "debug isis events%s", VTY_NEWLINE);
881 write++;
882 }
883 if (flags & DEBUG_PACKET_DUMP)
884 {
885 vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE);
886 write++;
887 }
888 if (flags & DEBUG_LSP_GEN)
889 {
890 vty_out (vty, "debug isis lsp-gen%s", VTY_NEWLINE);
891 write++;
892 }
893 if (flags & DEBUG_LSP_SCHED)
894 {
895 vty_out (vty, "debug isis lsp-sched%s", VTY_NEWLINE);
896 write++;
897 }
898 write += spf_backoff_write_config(vty);
899
900 return write;
901 }
902
903 DEFUN (debug_isis_adj,
904 debug_isis_adj_cmd,
905 "debug isis adj-packets",
906 DEBUG_STR
907 "IS-IS information\n"
908 "IS-IS Adjacency related packets\n")
909 {
910 isis->debugs |= DEBUG_ADJ_PACKETS;
911 print_debug (vty, DEBUG_ADJ_PACKETS, 1);
912
913 return CMD_SUCCESS;
914 }
915
916 DEFUN (no_debug_isis_adj,
917 no_debug_isis_adj_cmd,
918 "no debug isis adj-packets",
919 NO_STR
920 UNDEBUG_STR
921 "IS-IS information\n"
922 "IS-IS Adjacency related packets\n")
923 {
924 isis->debugs &= ~DEBUG_ADJ_PACKETS;
925 print_debug (vty, DEBUG_ADJ_PACKETS, 0);
926
927 return CMD_SUCCESS;
928 }
929
930 DEFUN (debug_isis_csum,
931 debug_isis_csum_cmd,
932 "debug isis checksum-errors",
933 DEBUG_STR
934 "IS-IS information\n"
935 "IS-IS LSP checksum errors\n")
936 {
937 isis->debugs |= DEBUG_CHECKSUM_ERRORS;
938 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1);
939
940 return CMD_SUCCESS;
941 }
942
943 DEFUN (no_debug_isis_csum,
944 no_debug_isis_csum_cmd,
945 "no debug isis checksum-errors",
946 NO_STR
947 UNDEBUG_STR
948 "IS-IS information\n"
949 "IS-IS LSP checksum errors\n")
950 {
951 isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
952 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
953
954 return CMD_SUCCESS;
955 }
956
957 DEFUN (debug_isis_lupd,
958 debug_isis_lupd_cmd,
959 "debug isis local-updates",
960 DEBUG_STR
961 "IS-IS information\n"
962 "IS-IS local update packets\n")
963 {
964 isis->debugs |= DEBUG_LOCAL_UPDATES;
965 print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
966
967 return CMD_SUCCESS;
968 }
969
970 DEFUN (no_debug_isis_lupd,
971 no_debug_isis_lupd_cmd,
972 "no debug isis local-updates",
973 NO_STR
974 UNDEBUG_STR
975 "IS-IS information\n"
976 "IS-IS local update packets\n")
977 {
978 isis->debugs &= ~DEBUG_LOCAL_UPDATES;
979 print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
980
981 return CMD_SUCCESS;
982 }
983
984 DEFUN (debug_isis_err,
985 debug_isis_err_cmd,
986 "debug isis protocol-errors",
987 DEBUG_STR
988 "IS-IS information\n"
989 "IS-IS LSP protocol errors\n")
990 {
991 isis->debugs |= DEBUG_PROTOCOL_ERRORS;
992 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1);
993
994 return CMD_SUCCESS;
995 }
996
997 DEFUN (no_debug_isis_err,
998 no_debug_isis_err_cmd,
999 "no debug isis protocol-errors",
1000 NO_STR
1001 UNDEBUG_STR
1002 "IS-IS information\n"
1003 "IS-IS LSP protocol errors\n")
1004 {
1005 isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
1006 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
1007
1008 return CMD_SUCCESS;
1009 }
1010
1011 DEFUN (debug_isis_snp,
1012 debug_isis_snp_cmd,
1013 "debug isis snp-packets",
1014 DEBUG_STR
1015 "IS-IS information\n"
1016 "IS-IS CSNP/PSNP packets\n")
1017 {
1018 isis->debugs |= DEBUG_SNP_PACKETS;
1019 print_debug (vty, DEBUG_SNP_PACKETS, 1);
1020
1021 return CMD_SUCCESS;
1022 }
1023
1024 DEFUN (no_debug_isis_snp,
1025 no_debug_isis_snp_cmd,
1026 "no debug isis snp-packets",
1027 NO_STR
1028 UNDEBUG_STR
1029 "IS-IS information\n"
1030 "IS-IS CSNP/PSNP packets\n")
1031 {
1032 isis->debugs &= ~DEBUG_SNP_PACKETS;
1033 print_debug (vty, DEBUG_SNP_PACKETS, 0);
1034
1035 return CMD_SUCCESS;
1036 }
1037
1038 DEFUN (debug_isis_upd,
1039 debug_isis_upd_cmd,
1040 "debug isis update-packets",
1041 DEBUG_STR
1042 "IS-IS information\n"
1043 "IS-IS Update related packets\n")
1044 {
1045 isis->debugs |= DEBUG_UPDATE_PACKETS;
1046 print_debug (vty, DEBUG_UPDATE_PACKETS, 1);
1047
1048 return CMD_SUCCESS;
1049 }
1050
1051 DEFUN (no_debug_isis_upd,
1052 no_debug_isis_upd_cmd,
1053 "no debug isis update-packets",
1054 NO_STR
1055 UNDEBUG_STR
1056 "IS-IS information\n"
1057 "IS-IS Update related packets\n")
1058 {
1059 isis->debugs &= ~DEBUG_UPDATE_PACKETS;
1060 print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
1061
1062 return CMD_SUCCESS;
1063 }
1064
1065 DEFUN (debug_isis_spfevents,
1066 debug_isis_spfevents_cmd,
1067 "debug isis spf-events",
1068 DEBUG_STR
1069 "IS-IS information\n"
1070 "IS-IS Shortest Path First Events\n")
1071 {
1072 isis->debugs |= DEBUG_SPF_EVENTS;
1073 print_debug (vty, DEBUG_SPF_EVENTS, 1);
1074
1075 return CMD_SUCCESS;
1076 }
1077
1078 DEFUN (no_debug_isis_spfevents,
1079 no_debug_isis_spfevents_cmd,
1080 "no debug isis spf-events",
1081 NO_STR
1082 UNDEBUG_STR
1083 "IS-IS information\n"
1084 "IS-IS Shortest Path First Events\n")
1085 {
1086 isis->debugs &= ~DEBUG_SPF_EVENTS;
1087 print_debug (vty, DEBUG_SPF_EVENTS, 0);
1088
1089 return CMD_SUCCESS;
1090 }
1091
1092 DEFUN (debug_isis_spfstats,
1093 debug_isis_spfstats_cmd,
1094 "debug isis spf-statistics ",
1095 DEBUG_STR
1096 "IS-IS information\n"
1097 "IS-IS SPF Timing and Statistic Data\n")
1098 {
1099 isis->debugs |= DEBUG_SPF_STATS;
1100 print_debug (vty, DEBUG_SPF_STATS, 1);
1101
1102 return CMD_SUCCESS;
1103 }
1104
1105 DEFUN (no_debug_isis_spfstats,
1106 no_debug_isis_spfstats_cmd,
1107 "no debug isis spf-statistics",
1108 NO_STR
1109 UNDEBUG_STR
1110 "IS-IS information\n"
1111 "IS-IS SPF Timing and Statistic Data\n")
1112 {
1113 isis->debugs &= ~DEBUG_SPF_STATS;
1114 print_debug (vty, DEBUG_SPF_STATS, 0);
1115
1116 return CMD_SUCCESS;
1117 }
1118
1119 DEFUN (debug_isis_spftrigg,
1120 debug_isis_spftrigg_cmd,
1121 "debug isis spf-triggers",
1122 DEBUG_STR
1123 "IS-IS information\n"
1124 "IS-IS SPF triggering events\n")
1125 {
1126 isis->debugs |= DEBUG_SPF_TRIGGERS;
1127 print_debug (vty, DEBUG_SPF_TRIGGERS, 1);
1128
1129 return CMD_SUCCESS;
1130 }
1131
1132 DEFUN (no_debug_isis_spftrigg,
1133 no_debug_isis_spftrigg_cmd,
1134 "no debug isis spf-triggers",
1135 NO_STR
1136 UNDEBUG_STR
1137 "IS-IS information\n"
1138 "IS-IS SPF triggering events\n")
1139 {
1140 isis->debugs &= ~DEBUG_SPF_TRIGGERS;
1141 print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
1142
1143 return CMD_SUCCESS;
1144 }
1145
1146 DEFUN (debug_isis_rtevents,
1147 debug_isis_rtevents_cmd,
1148 "debug isis route-events",
1149 DEBUG_STR
1150 "IS-IS information\n"
1151 "IS-IS Route related events\n")
1152 {
1153 isis->debugs |= DEBUG_RTE_EVENTS;
1154 print_debug (vty, DEBUG_RTE_EVENTS, 1);
1155
1156 return CMD_SUCCESS;
1157 }
1158
1159 DEFUN (no_debug_isis_rtevents,
1160 no_debug_isis_rtevents_cmd,
1161 "no debug isis route-events",
1162 NO_STR
1163 UNDEBUG_STR
1164 "IS-IS information\n"
1165 "IS-IS Route related events\n")
1166 {
1167 isis->debugs &= ~DEBUG_RTE_EVENTS;
1168 print_debug (vty, DEBUG_RTE_EVENTS, 0);
1169
1170 return CMD_SUCCESS;
1171 }
1172
1173 DEFUN (debug_isis_events,
1174 debug_isis_events_cmd,
1175 "debug isis events",
1176 DEBUG_STR
1177 "IS-IS information\n"
1178 "IS-IS Events\n")
1179 {
1180 isis->debugs |= DEBUG_EVENTS;
1181 print_debug (vty, DEBUG_EVENTS, 1);
1182
1183 return CMD_SUCCESS;
1184 }
1185
1186 DEFUN (no_debug_isis_events,
1187 no_debug_isis_events_cmd,
1188 "no debug isis events",
1189 NO_STR
1190 UNDEBUG_STR
1191 "IS-IS information\n"
1192 "IS-IS Events\n")
1193 {
1194 isis->debugs &= ~DEBUG_EVENTS;
1195 print_debug (vty, DEBUG_EVENTS, 0);
1196
1197 return CMD_SUCCESS;
1198 }
1199
1200 DEFUN (debug_isis_packet_dump,
1201 debug_isis_packet_dump_cmd,
1202 "debug isis packet-dump",
1203 DEBUG_STR
1204 "IS-IS information\n"
1205 "IS-IS packet dump\n")
1206 {
1207 isis->debugs |= DEBUG_PACKET_DUMP;
1208 print_debug (vty, DEBUG_PACKET_DUMP, 1);
1209
1210 return CMD_SUCCESS;
1211 }
1212
1213 DEFUN (no_debug_isis_packet_dump,
1214 no_debug_isis_packet_dump_cmd,
1215 "no debug isis packet-dump",
1216 NO_STR
1217 UNDEBUG_STR
1218 "IS-IS information\n"
1219 "IS-IS packet dump\n")
1220 {
1221 isis->debugs &= ~DEBUG_PACKET_DUMP;
1222 print_debug (vty, DEBUG_PACKET_DUMP, 0);
1223
1224 return CMD_SUCCESS;
1225 }
1226
1227 DEFUN (debug_isis_lsp_gen,
1228 debug_isis_lsp_gen_cmd,
1229 "debug isis lsp-gen",
1230 DEBUG_STR
1231 "IS-IS information\n"
1232 "IS-IS generation of own LSPs\n")
1233 {
1234 isis->debugs |= DEBUG_LSP_GEN;
1235 print_debug (vty, DEBUG_LSP_GEN, 1);
1236
1237 return CMD_SUCCESS;
1238 }
1239
1240 DEFUN (no_debug_isis_lsp_gen,
1241 no_debug_isis_lsp_gen_cmd,
1242 "no debug isis lsp-gen",
1243 NO_STR
1244 UNDEBUG_STR
1245 "IS-IS information\n"
1246 "IS-IS generation of own LSPs\n")
1247 {
1248 isis->debugs &= ~DEBUG_LSP_GEN;
1249 print_debug (vty, DEBUG_LSP_GEN, 0);
1250
1251 return CMD_SUCCESS;
1252 }
1253
1254 DEFUN (debug_isis_lsp_sched,
1255 debug_isis_lsp_sched_cmd,
1256 "debug isis lsp-sched",
1257 DEBUG_STR
1258 "IS-IS information\n"
1259 "IS-IS scheduling of LSP generation\n")
1260 {
1261 isis->debugs |= DEBUG_LSP_SCHED;
1262 print_debug (vty, DEBUG_LSP_SCHED, 1);
1263
1264 return CMD_SUCCESS;
1265 }
1266
1267 DEFUN (no_debug_isis_lsp_sched,
1268 no_debug_isis_lsp_sched_cmd,
1269 "no debug isis lsp-sched",
1270 NO_STR
1271 UNDEBUG_STR
1272 "IS-IS information\n"
1273 "IS-IS scheduling of LSP generation\n")
1274 {
1275 isis->debugs &= ~DEBUG_LSP_SCHED;
1276 print_debug (vty, DEBUG_LSP_SCHED, 0);
1277
1278 return CMD_SUCCESS;
1279 }
1280
1281 DEFUN (show_hostname,
1282 show_hostname_cmd,
1283 "show isis hostname",
1284 SHOW_STR
1285 "IS-IS information\n"
1286 "IS-IS Dynamic hostname mapping\n")
1287 {
1288 dynhn_print_all (vty);
1289
1290 return CMD_SUCCESS;
1291 }
1292
1293 static void
1294 vty_out_timestr(struct vty *vty, time_t uptime)
1295 {
1296 struct tm *tm;
1297 time_t difftime = time (NULL);
1298 difftime -= uptime;
1299 tm = gmtime (&difftime);
1300
1301 #define ONE_DAY_SECOND 60*60*24
1302 #define ONE_WEEK_SECOND 60*60*24*7
1303 if (difftime < ONE_DAY_SECOND)
1304 vty_out (vty, "%02d:%02d:%02d",
1305 tm->tm_hour, tm->tm_min, tm->tm_sec);
1306 else if (difftime < ONE_WEEK_SECOND)
1307 vty_out (vty, "%dd%02dh%02dm",
1308 tm->tm_yday, tm->tm_hour, tm->tm_min);
1309 else
1310 vty_out (vty, "%02dw%dd%02dh",
1311 tm->tm_yday/7,
1312 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1313 vty_out (vty, " ago");
1314 }
1315
1316 DEFUN (show_isis_spf_ietf,
1317 show_isis_spf_ietf_cmd,
1318 "show isis spf-delay-ietf",
1319 SHOW_STR
1320 "IS-IS information\n"
1321 "IS-IS SPF delay IETF information\n")
1322 {
1323 if (!isis)
1324 {
1325 vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
1326 return CMD_SUCCESS;
1327 }
1328
1329 struct listnode *node;
1330 struct isis_area *area;
1331
1332 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1333 {
1334 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1335 VTY_NEWLINE);
1336
1337 for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
1338 {
1339 if ((area->is_type & level) == 0)
1340 continue;
1341
1342 vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE);
1343 vty_out (vty, " SPF delay status: ");
1344 if (area->spf_timer[level -1])
1345 {
1346 struct timeval remain = thread_timer_remain(area->spf_timer[level - 1]);
1347 vty_out(vty, "Pending, due in %ld msec%s",
1348 remain.tv_sec * 1000 + remain.tv_usec / 1000,
1349 VTY_NEWLINE);
1350 }
1351 else
1352 {
1353 vty_out(vty, "Not scheduled%s", VTY_NEWLINE);
1354 }
1355
1356 if (area->spf_delay_ietf[level - 1]) {
1357 vty_out(vty, " Using draft-ietf-rtgwg-backoff-algo-04%s", VTY_NEWLINE);
1358 spf_backoff_show(area->spf_delay_ietf[level - 1], vty, " ");
1359 } else {
1360 vty_out(vty, " Using legacy backoff algo%s", VTY_NEWLINE);
1361 }
1362 }
1363 }
1364 return CMD_SUCCESS;
1365 }
1366
1367 DEFUN (show_isis_summary,
1368 show_isis_summary_cmd,
1369 "show isis summary",
1370 SHOW_STR "IS-IS information\n" "IS-IS summary\n")
1371 {
1372 struct listnode *node, *node2;
1373 struct isis_area *area;
1374 struct isis_spftree *spftree;
1375 int level;
1376
1377 if (isis == NULL)
1378 {
1379 vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
1380 return CMD_SUCCESS;
1381 }
1382
1383 vty_out (vty, "Process Id : %ld%s", isis->process_id,
1384 VTY_NEWLINE);
1385 if (isis->sysid_set)
1386 vty_out (vty, "System Id : %s%s", sysid_print (isis->sysid),
1387 VTY_NEWLINE);
1388
1389 vty_out (vty, "Up time : ");
1390 vty_out_timestr(vty, isis->uptime);
1391 vty_out (vty, "%s", VTY_NEWLINE);
1392
1393 if (isis->area_list)
1394 vty_out (vty, "Number of areas : %d%s", isis->area_list->count,
1395 VTY_NEWLINE);
1396
1397 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1398 {
1399 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1400 VTY_NEWLINE);
1401
1402 if (listcount (area->area_addrs) > 0)
1403 {
1404 struct area_addr *area_addr;
1405 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
1406 {
1407 vty_out (vty, " Net: %s%s",
1408 isonet_print (area_addr->area_addr,
1409 area_addr->addr_len + ISIS_SYS_ID_LEN +
1410 1), VTY_NEWLINE);
1411 }
1412 }
1413
1414 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
1415 {
1416 if ((area->is_type & level) == 0)
1417 continue;
1418
1419 vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE);
1420 spftree = area->spftree[level - 1];
1421 if (area->spf_timer[level - 1])
1422 vty_out (vty, " SPF: (pending)%s", VTY_NEWLINE);
1423 else
1424 vty_out (vty, " SPF:%s", VTY_NEWLINE);
1425
1426 vty_out (vty, " minimum interval : %d",
1427 area->min_spf_interval[level - 1]);
1428 if (area->spf_delay_ietf[level - 1])
1429 vty_out (vty, " (not used, IETF SPF delay activated)");
1430 vty_out (vty, VTY_NEWLINE);
1431
1432 vty_out (vty, " IPv4 route computation:%s", VTY_NEWLINE);
1433 vty_out (vty, " last run elapsed : ");
1434 vty_out_timestr(vty, spftree->last_run_timestamp);
1435 vty_out (vty, "%s", VTY_NEWLINE);
1436
1437 vty_out (vty, " last run duration : %u usec%s",
1438 (u_int32_t)spftree->last_run_duration, VTY_NEWLINE);
1439
1440 vty_out (vty, " run count : %d%s",
1441 spftree->runcount, VTY_NEWLINE);
1442
1443 spftree = area->spftree6[level - 1];
1444 vty_out (vty, " IPv6 route computation:%s", VTY_NEWLINE);
1445
1446 vty_out (vty, " last run elapsed : ");
1447 vty_out_timestr(vty, spftree->last_run_timestamp);
1448 vty_out (vty, "%s", VTY_NEWLINE);
1449
1450 vty_out (vty, " last run duration : %llu msec%s",
1451 (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
1452
1453 vty_out (vty, " run count : %d%s",
1454 spftree->runcount, VTY_NEWLINE);
1455 }
1456 }
1457 vty_out (vty, "%s", VTY_NEWLINE);
1458
1459 return CMD_SUCCESS;
1460 }
1461
1462 /*
1463 * This function supports following display options:
1464 * [ show isis database [detail] ]
1465 * [ show isis database <sysid> [detail] ]
1466 * [ show isis database <hostname> [detail] ]
1467 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1468 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1469 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1470 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1471 * [ show isis database detail <sysid> ]
1472 * [ show isis database detail <hostname> ]
1473 * [ show isis database detail <sysid>.<pseudo-id> ]
1474 * [ show isis database detail <hostname>.<pseudo-id> ]
1475 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1476 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1477 */
1478 static int
1479 show_isis_database (struct vty *vty, const char *argv, int ui_level)
1480 {
1481 struct listnode *node;
1482 struct isis_area *area;
1483 struct isis_lsp *lsp;
1484 struct isis_dynhn *dynhn;
1485 const char *pos = argv;
1486 u_char lspid[ISIS_SYS_ID_LEN+2];
1487 char sysid[255];
1488 u_char number[3];
1489 int level, lsp_count;
1490
1491 if (isis->area_list->count == 0)
1492 return CMD_SUCCESS;
1493
1494 memset (&lspid, 0, ISIS_SYS_ID_LEN);
1495 memset (&sysid, 0, 255);
1496
1497 /*
1498 * extract fragment and pseudo id from the string argv
1499 * in the forms:
1500 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1501 * (b) <systemid/hostname>.<pseudo-id> or
1502 * (c) <systemid/hostname> or
1503 * Where systemid is in the form:
1504 * xxxx.xxxx.xxxx
1505 */
1506 if (argv)
1507 strncpy (sysid, argv, 254);
1508 if (argv && strlen (argv) > 3)
1509 {
1510 pos = argv + strlen (argv) - 3;
1511 if (strncmp (pos, "-", 1) == 0)
1512 {
1513 memcpy (number, ++pos, 2);
1514 lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16);
1515 pos -= 4;
1516 if (strncmp (pos, ".", 1) != 0)
1517 return CMD_ERR_AMBIGUOUS;
1518 }
1519 if (strncmp (pos, ".", 1) == 0)
1520 {
1521 memcpy (number, ++pos, 2);
1522 lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16);
1523 sysid[pos - argv - 1] = '\0';
1524 }
1525 }
1526
1527 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1528 {
1529 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1530 VTY_NEWLINE);
1531
1532 for (level = 0; level < ISIS_LEVELS; level++)
1533 {
1534 if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
1535 {
1536 lsp = NULL;
1537 if (argv != NULL)
1538 {
1539 /*
1540 * Try to find the lsp-id if the argv string is in
1541 * the form hostname.<pseudo-id>-<fragment>
1542 */
1543 if (sysid2buff (lspid, sysid))
1544 {
1545 lsp = lsp_search (lspid, area->lspdb[level]);
1546 }
1547 else if ((dynhn = dynhn_find_by_name (sysid)))
1548 {
1549 memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN);
1550 lsp = lsp_search (lspid, area->lspdb[level]);
1551 }
1552 else if (strncmp(unix_hostname (), sysid, 15) == 0)
1553 {
1554 memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
1555 lsp = lsp_search (lspid, area->lspdb[level]);
1556 }
1557 }
1558
1559 if (lsp != NULL || argv == NULL)
1560 {
1561 vty_out (vty, "IS-IS Level-%d link-state database:%s",
1562 level + 1, VTY_NEWLINE);
1563
1564 /* print the title in all cases */
1565 vty_out (vty, "LSP ID PduLen "
1566 "SeqNumber Chksum Holdtime ATT/P/OL%s",
1567 VTY_NEWLINE);
1568 }
1569
1570 if (lsp)
1571 {
1572 if (ui_level == ISIS_UI_LEVEL_DETAIL)
1573 lsp_print_detail (lsp, vty, area->dynhostname);
1574 else
1575 lsp_print (lsp, vty, area->dynhostname);
1576 }
1577 else if (argv == NULL)
1578 {
1579 lsp_count = lsp_print_all (vty, area->lspdb[level],
1580 ui_level,
1581 area->dynhostname);
1582
1583 vty_out (vty, " %u LSPs%s%s",
1584 lsp_count, VTY_NEWLINE, VTY_NEWLINE);
1585 }
1586 }
1587 }
1588 }
1589
1590 return CMD_SUCCESS;
1591 }
1592
1593 DEFUN (show_database,
1594 show_database_cmd,
1595 "show isis database [detail] [WORD]",
1596 SHOW_STR
1597 "IS-IS information\n"
1598 "IS-IS link state database\n"
1599 "Detailed information\n"
1600 "LSP ID\n")
1601 {
1602 int idx = 0;
1603 int uilevel = argv_find (argv, argc, "detail", &idx) ? ISIS_UI_LEVEL_DETAIL : ISIS_UI_LEVEL_BRIEF;
1604 char *id = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
1605 return show_isis_database (vty, id, uilevel);
1606 }
1607
1608 /*
1609 * 'router isis' command
1610 */
1611 DEFUN_NOSH (router_isis,
1612 router_isis_cmd,
1613 "router isis WORD",
1614 ROUTER_STR
1615 "ISO IS-IS\n"
1616 "ISO Routing area tag")
1617 {
1618 int idx_word = 2;
1619 return isis_area_get (vty, argv[idx_word]->arg);
1620 }
1621
1622 /*
1623 *'no router isis' command
1624 */
1625 DEFUN (no_router_isis,
1626 no_router_isis_cmd,
1627 "no router isis WORD",
1628 "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
1629 {
1630 int idx_word = 3;
1631 return isis_area_destroy (vty, argv[idx_word]->arg);
1632 }
1633
1634 /*
1635 * 'net' command
1636 */
1637 DEFUN (net,
1638 net_cmd,
1639 "net WORD",
1640 "A Network Entity Title for this process (OSI only)\n"
1641 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1642 {
1643 int idx_word = 1;
1644 return area_net_title (vty, argv[idx_word]->arg);
1645 }
1646
1647 /*
1648 * 'no net' command
1649 */
1650 DEFUN (no_net,
1651 no_net_cmd,
1652 "no net WORD",
1653 NO_STR
1654 "A Network Entity Title for this process (OSI only)\n"
1655 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1656 {
1657 int idx_word = 2;
1658 return area_clear_net_title (vty, argv[idx_word]->arg);
1659 }
1660
1661 DEFUN (isis_topology,
1662 isis_topology_cmd,
1663 "topology " ISIS_MT_NAMES " [overload]",
1664 "Configure IS-IS topologies\n"
1665 ISIS_MT_DESCRIPTIONS
1666 "Set overload bit for topology\n")
1667 {
1668 VTY_DECLVAR_CONTEXT (isis_area, area);
1669
1670 const char *arg = argv[1]->arg;
1671 uint16_t mtid = isis_str2mtid(arg);
1672
1673 if (area->oldmetric)
1674 {
1675 vty_out (vty, "Multi topology IS-IS can only be used with wide metrics%s", VTY_NEWLINE);
1676 return CMD_ERR_AMBIGUOUS;
1677 }
1678
1679 if (mtid == (uint16_t)-1)
1680 {
1681 vty_out (vty, "Don't know topology '%s'%s", arg, VTY_NEWLINE);
1682 return CMD_ERR_AMBIGUOUS;
1683 }
1684 if (mtid == ISIS_MT_IPV4_UNICAST)
1685 {
1686 vty_out (vty, "Cannot configure IPv4 unicast topology%s", VTY_NEWLINE);
1687 return CMD_ERR_AMBIGUOUS;
1688 }
1689
1690 area_set_mt_enabled(area, mtid, true);
1691 area_set_mt_overload(area, mtid, (argc == 3));
1692 return CMD_SUCCESS;
1693 }
1694
1695 DEFUN (no_isis_topology,
1696 no_isis_topology_cmd,
1697 "no topology " ISIS_MT_NAMES " [overload]",
1698 NO_STR
1699 "Configure IS-IS topologies\n"
1700 ISIS_MT_DESCRIPTIONS
1701 "Set overload bit for topology\n")
1702 {
1703 VTY_DECLVAR_CONTEXT (isis_area, area);
1704
1705 const char *arg = argv[2]->arg;
1706 uint16_t mtid = isis_str2mtid(arg);
1707
1708 if (area->oldmetric)
1709 {
1710 vty_out (vty, "Multi topology IS-IS can only be used with wide metrics%s", VTY_NEWLINE);
1711 return CMD_ERR_AMBIGUOUS;
1712 }
1713
1714 if (mtid == (uint16_t)-1)
1715 {
1716 vty_out (vty, "Don't know topology '%s'%s", arg, VTY_NEWLINE);
1717 return CMD_ERR_AMBIGUOUS;
1718 }
1719 if (mtid == ISIS_MT_IPV4_UNICAST)
1720 {
1721 vty_out (vty, "Cannot configure IPv4 unicast topology%s", VTY_NEWLINE);
1722 return CMD_ERR_AMBIGUOUS;
1723 }
1724
1725 area_set_mt_enabled(area, mtid, false);
1726 area_set_mt_overload(area, mtid, false);
1727 return CMD_SUCCESS;
1728 }
1729
1730 void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu)
1731 {
1732 area->lsp_mtu = lsp_mtu;
1733 lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
1734 }
1735
1736 static int
1737 isis_area_passwd_set(struct isis_area *area, int level, u_char passwd_type,
1738 const char *passwd, u_char snp_auth)
1739 {
1740 struct isis_passwd *dest;
1741 struct isis_passwd modified;
1742 int len;
1743
1744 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
1745 dest = (level == IS_LEVEL_1) ? &area->area_passwd : &area->domain_passwd;
1746 memset(&modified, 0, sizeof(modified));
1747
1748 if (passwd_type != ISIS_PASSWD_TYPE_UNUSED)
1749 {
1750 if (!passwd)
1751 return -1;
1752
1753 len = strlen(passwd);
1754 if (len > 254)
1755 return -1;
1756
1757 modified.len = len;
1758 strncpy((char*)modified.passwd, passwd, 255);
1759 modified.type = passwd_type;
1760 modified.snp_auth = snp_auth;
1761 }
1762
1763 if (memcmp(&modified, dest, sizeof(modified)))
1764 {
1765 memcpy(dest, &modified, sizeof(modified));
1766 lsp_regenerate_schedule(area, IS_LEVEL_1|IS_LEVEL_2, 1);
1767 }
1768
1769 return 0;
1770 }
1771
1772 int
1773 isis_area_passwd_unset (struct isis_area *area, int level)
1774 {
1775 return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_UNUSED, NULL, 0);
1776 }
1777
1778 int
1779 isis_area_passwd_cleartext_set (struct isis_area *area, int level,
1780 const char *passwd, u_char snp_auth)
1781 {
1782 return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_CLEARTXT,
1783 passwd, snp_auth);
1784 }
1785
1786 int
1787 isis_area_passwd_hmac_md5_set (struct isis_area *area, int level,
1788 const char *passwd, u_char snp_auth)
1789 {
1790 return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_HMAC_MD5,
1791 passwd, snp_auth);
1792 }
1793
1794 static void
1795 area_resign_level (struct isis_area *area, int level)
1796 {
1797 if (area->lspdb[level - 1])
1798 {
1799 lsp_db_destroy (area->lspdb[level - 1]);
1800 area->lspdb[level - 1] = NULL;
1801 }
1802 if (area->spftree[level - 1])
1803 {
1804 isis_spftree_del (area->spftree[level - 1]);
1805 area->spftree[level - 1] = NULL;
1806 }
1807 if (area->spftree6[level - 1])
1808 {
1809 isis_spftree_del (area->spftree6[level - 1]);
1810 area->spftree6[level - 1] = NULL;
1811 }
1812 THREAD_TIMER_OFF(area->spf_timer[level - 1]);
1813 if (area->route_table[level - 1])
1814 {
1815 route_table_finish (area->route_table[level - 1]);
1816 area->route_table[level - 1] = NULL;
1817 }
1818 if (area->route_table6[level - 1])
1819 {
1820 route_table_finish (area->route_table6[level - 1]);
1821 area->route_table6[level - 1] = NULL;
1822 }
1823
1824 sched_debug("ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
1825 area->area_tag, level);
1826 THREAD_TIMER_OFF (area->t_lsp_refresh[level - 1]);
1827 area->lsp_regenerate_pending[level - 1] = 0;
1828 }
1829
1830 void
1831 isis_area_is_type_set(struct isis_area *area, int is_type)
1832 {
1833 struct listnode *node;
1834 struct isis_circuit *circuit;
1835
1836 if (isis->debugs & DEBUG_EVENTS)
1837 zlog_debug ("ISIS-Evt (%s) system type change %s -> %s", area->area_tag,
1838 circuit_t2string (area->is_type), circuit_t2string (is_type));
1839
1840 if (area->is_type == is_type)
1841 return; /* No change */
1842
1843 switch (area->is_type)
1844 {
1845 case IS_LEVEL_1:
1846 if (is_type == IS_LEVEL_2)
1847 area_resign_level (area, IS_LEVEL_1);
1848
1849 if (area->lspdb[1] == NULL)
1850 area->lspdb[1] = lsp_db_init ();
1851 if (area->route_table[1] == NULL)
1852 area->route_table[1] = route_table_init ();
1853 if (area->route_table6[1] == NULL)
1854 area->route_table6[1] = route_table_init ();
1855 break;
1856
1857 case IS_LEVEL_1_AND_2:
1858 if (is_type == IS_LEVEL_1)
1859 area_resign_level (area, IS_LEVEL_2);
1860 else
1861 area_resign_level (area, IS_LEVEL_1);
1862 break;
1863
1864 case IS_LEVEL_2:
1865 if (is_type == IS_LEVEL_1)
1866 area_resign_level (area, IS_LEVEL_2);
1867
1868 if (area->lspdb[0] == NULL)
1869 area->lspdb[0] = lsp_db_init ();
1870 if (area->route_table[0] == NULL)
1871 area->route_table[0] = route_table_init ();
1872 if (area->route_table6[0] == NULL)
1873 area->route_table6[0] = route_table_init ();
1874 break;
1875
1876 default:
1877 break;
1878 }
1879
1880 area->is_type = is_type;
1881
1882 /* override circuit's is_type */
1883 if (area->is_type != IS_LEVEL_1_AND_2)
1884 {
1885 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
1886 isis_circuit_is_type_set (circuit, is_type);
1887 }
1888
1889 spftree_area_init (area);
1890
1891 if (listcount (area->area_addrs) > 0)
1892 {
1893 if (is_type & IS_LEVEL_1)
1894 lsp_generate (area, IS_LEVEL_1);
1895 if (is_type & IS_LEVEL_2)
1896 lsp_generate (area, IS_LEVEL_2);
1897 }
1898 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1899
1900 return;
1901 }
1902
1903 void isis_area_metricstyle_set(struct isis_area *area, bool old_metric,
1904 bool new_metric)
1905 {
1906 if (area->oldmetric != old_metric
1907 || area->newmetric != new_metric)
1908 {
1909 area->oldmetric = old_metric;
1910 area->newmetric = new_metric;
1911 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1912 }
1913 }
1914
1915 void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit)
1916 {
1917 char new_overload_bit = overload_bit ? LSPBIT_OL : 0;
1918
1919 if (new_overload_bit != area->overload_bit)
1920 {
1921 area->overload_bit = new_overload_bit;
1922 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1923 }
1924 }
1925
1926 void isis_area_attached_bit_set(struct isis_area *area, bool attached_bit)
1927 {
1928 char new_attached_bit = attached_bit ? LSPBIT_ATT : 0;
1929
1930 if (new_attached_bit != area->attached_bit)
1931 {
1932 area->attached_bit = new_attached_bit;
1933 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1934 }
1935 }
1936
1937 void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname)
1938 {
1939 if (area->dynhostname != dynhostname)
1940 {
1941 area->dynhostname = dynhostname;
1942 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
1943 }
1944 }
1945
1946 void
1947 isis_area_max_lsp_lifetime_set(struct isis_area *area, int level,
1948 uint16_t max_lsp_lifetime)
1949 {
1950 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
1951
1952 if (area->max_lsp_lifetime[level-1] == max_lsp_lifetime)
1953 return;
1954
1955 area->max_lsp_lifetime[level-1] = max_lsp_lifetime;
1956 lsp_regenerate_schedule(area, level, 1);
1957 }
1958
1959 void
1960 isis_area_lsp_refresh_set(struct isis_area *area, int level,
1961 uint16_t lsp_refresh)
1962 {
1963 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
1964
1965 if (area->lsp_refresh[level-1] == lsp_refresh)
1966 return;
1967
1968 area->lsp_refresh[level-1] = lsp_refresh;
1969 lsp_regenerate_schedule(area, level, 1);
1970 }
1971
1972 DEFUN (log_adj_changes,
1973 log_adj_changes_cmd,
1974 "log-adjacency-changes",
1975 "Log changes in adjacency state\n")
1976 {
1977 VTY_DECLVAR_CONTEXT (isis_area, area);
1978
1979 area->log_adj_changes = 1;
1980
1981 return CMD_SUCCESS;
1982 }
1983
1984 DEFUN (no_log_adj_changes,
1985 no_log_adj_changes_cmd,
1986 "no log-adjacency-changes",
1987 NO_STR
1988 "Stop logging changes in adjacency state\n")
1989 {
1990 VTY_DECLVAR_CONTEXT (isis_area, area);
1991
1992 area->log_adj_changes = 0;
1993
1994 return CMD_SUCCESS;
1995 }
1996
1997 /* IS-IS configuration write function */
1998 int
1999 isis_config_write (struct vty *vty)
2000 {
2001 int write = 0;
2002
2003 if (isis != NULL)
2004 {
2005 struct isis_area *area;
2006 struct listnode *node, *node2;
2007
2008 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
2009 {
2010 /* ISIS - Area name */
2011 vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
2012 write++;
2013 /* ISIS - Net */
2014 if (listcount (area->area_addrs) > 0)
2015 {
2016 struct area_addr *area_addr;
2017 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
2018 {
2019 vty_out (vty, " net %s%s",
2020 isonet_print (area_addr->area_addr,
2021 area_addr->addr_len + ISIS_SYS_ID_LEN +
2022 1), VTY_NEWLINE);
2023 write++;
2024 }
2025 }
2026 /* ISIS - Dynamic hostname - Defaults to true so only display if
2027 * false. */
2028 if (!area->dynhostname)
2029 {
2030 vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
2031 write++;
2032 }
2033 /* ISIS - Metric-Style - when true displays wide */
2034 if (area->newmetric)
2035 {
2036 if (!area->oldmetric)
2037 vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
2038 else
2039 vty_out (vty, " metric-style transition%s", VTY_NEWLINE);
2040 write++;
2041 }
2042 else
2043 {
2044 vty_out (vty, " metric-style narrow%s", VTY_NEWLINE);
2045 write++;
2046 }
2047 /* ISIS - overload-bit */
2048 if (area->overload_bit)
2049 {
2050 vty_out (vty, " set-overload-bit%s", VTY_NEWLINE);
2051 write++;
2052 }
2053 /* ISIS - Area is-type (level-1-2 is default) */
2054 if (area->is_type == IS_LEVEL_1)
2055 {
2056 vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
2057 write++;
2058 }
2059 else if (area->is_type == IS_LEVEL_2)
2060 {
2061 vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
2062 write++;
2063 }
2064 write += isis_redist_config_write(vty, area, AF_INET);
2065 write += isis_redist_config_write(vty, area, AF_INET6);
2066 /* ISIS - Lsp generation interval */
2067 if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1])
2068 {
2069 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
2070 {
2071 vty_out (vty, " lsp-gen-interval %d%s",
2072 area->lsp_gen_interval[0], VTY_NEWLINE);
2073 write++;
2074 }
2075 }
2076 else
2077 {
2078 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
2079 {
2080 vty_out (vty, " lsp-gen-interval level-1 %d%s",
2081 area->lsp_gen_interval[0], VTY_NEWLINE);
2082 write++;
2083 }
2084 if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL)
2085 {
2086 vty_out (vty, " lsp-gen-interval level-2 %d%s",
2087 area->lsp_gen_interval[1], VTY_NEWLINE);
2088 write++;
2089 }
2090 }
2091 /* ISIS - LSP lifetime */
2092 if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1])
2093 {
2094 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
2095 {
2096 vty_out (vty, " max-lsp-lifetime %u%s", area->max_lsp_lifetime[0],
2097 VTY_NEWLINE);
2098 write++;
2099 }
2100 }
2101 else
2102 {
2103 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
2104 {
2105 vty_out (vty, " max-lsp-lifetime level-1 %u%s",
2106 area->max_lsp_lifetime[0], VTY_NEWLINE);
2107 write++;
2108 }
2109 if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME)
2110 {
2111 vty_out (vty, " max-lsp-lifetime level-2 %u%s",
2112 area->max_lsp_lifetime[1], VTY_NEWLINE);
2113 write++;
2114 }
2115 }
2116 /* ISIS - LSP refresh interval */
2117 if (area->lsp_refresh[0] == area->lsp_refresh[1])
2118 {
2119 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2120 {
2121 vty_out (vty, " lsp-refresh-interval %u%s", area->lsp_refresh[0],
2122 VTY_NEWLINE);
2123 write++;
2124 }
2125 }
2126 else
2127 {
2128 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2129 {
2130 vty_out (vty, " lsp-refresh-interval level-1 %u%s",
2131 area->lsp_refresh[0], VTY_NEWLINE);
2132 write++;
2133 }
2134 if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2135 {
2136 vty_out (vty, " lsp-refresh-interval level-2 %u%s",
2137 area->lsp_refresh[1], VTY_NEWLINE);
2138 write++;
2139 }
2140 }
2141 if (area->lsp_mtu != DEFAULT_LSP_MTU)
2142 {
2143 vty_out(vty, " lsp-mtu %u%s", area->lsp_mtu, VTY_NEWLINE);
2144 write++;
2145 }
2146
2147 /* Minimum SPF interval. */
2148 if (area->min_spf_interval[0] == area->min_spf_interval[1])
2149 {
2150 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
2151 {
2152 vty_out (vty, " spf-interval %d%s",
2153 area->min_spf_interval[0], VTY_NEWLINE);
2154 write++;
2155 }
2156 }
2157 else
2158 {
2159 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
2160 {
2161 vty_out (vty, " spf-interval level-1 %d%s",
2162 area->min_spf_interval[0], VTY_NEWLINE);
2163 write++;
2164 }
2165 if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL)
2166 {
2167 vty_out (vty, " spf-interval level-2 %d%s",
2168 area->min_spf_interval[1], VTY_NEWLINE);
2169 write++;
2170 }
2171 }
2172
2173 /* IETF SPF interval */
2174 if (area->spf_delay_ietf[0])
2175 {
2176 vty_out (vty, " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld%s",
2177 spf_backoff_init_delay(area->spf_delay_ietf[0]),
2178 spf_backoff_short_delay(area->spf_delay_ietf[0]),
2179 spf_backoff_long_delay(area->spf_delay_ietf[0]),
2180 spf_backoff_holddown(area->spf_delay_ietf[0]),
2181 spf_backoff_timetolearn(area->spf_delay_ietf[0]),
2182 VTY_NEWLINE);
2183 write++;
2184 }
2185
2186 /* Authentication passwords. */
2187 if (area->area_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
2188 {
2189 vty_out(vty, " area-password md5 %s", area->area_passwd.passwd);
2190 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
2191 {
2192 vty_out(vty, " authenticate snp ");
2193 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
2194 vty_out(vty, "validate");
2195 else
2196 vty_out(vty, "send-only");
2197 }
2198 vty_out(vty, "%s", VTY_NEWLINE);
2199 write++;
2200 }
2201 else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
2202 {
2203 vty_out(vty, " area-password clear %s", area->area_passwd.passwd);
2204 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
2205 {
2206 vty_out(vty, " authenticate snp ");
2207 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
2208 vty_out(vty, "validate");
2209 else
2210 vty_out(vty, "send-only");
2211 }
2212 vty_out(vty, "%s", VTY_NEWLINE);
2213 write++;
2214 }
2215 if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
2216 {
2217 vty_out(vty, " domain-password md5 %s",
2218 area->domain_passwd.passwd);
2219 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
2220 {
2221 vty_out(vty, " authenticate snp ");
2222 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
2223 vty_out(vty, "validate");
2224 else
2225 vty_out(vty, "send-only");
2226 }
2227 vty_out(vty, "%s", VTY_NEWLINE);
2228 write++;
2229 }
2230 else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
2231 {
2232 vty_out(vty, " domain-password clear %s",
2233 area->domain_passwd.passwd);
2234 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
2235 {
2236 vty_out(vty, " authenticate snp ");
2237 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
2238 vty_out(vty, "validate");
2239 else
2240 vty_out(vty, "send-only");
2241 }
2242 vty_out(vty, "%s", VTY_NEWLINE);
2243 write++;
2244 }
2245
2246 if (area->log_adj_changes)
2247 {
2248 vty_out (vty, " log-adjacency-changes%s", VTY_NEWLINE);
2249 write++;
2250 }
2251
2252 write += area_write_mt_settings(area, vty);
2253 }
2254 isis_mpls_te_config_write_router(vty);
2255 }
2256
2257 return write;
2258 }
2259
2260 struct cmd_node isis_node = {
2261 ISIS_NODE,
2262 "%s(config-router)# ",
2263 1
2264 };
2265
2266 void
2267 isis_init ()
2268 {
2269 /* Install IS-IS top node */
2270 install_node (&isis_node, isis_config_write);
2271
2272 install_element (VIEW_NODE, &show_isis_summary_cmd);
2273
2274 install_element (VIEW_NODE, &show_isis_spf_ietf_cmd);
2275
2276 install_element (VIEW_NODE, &show_isis_interface_cmd);
2277 install_element (VIEW_NODE, &show_isis_interface_detail_cmd);
2278 install_element (VIEW_NODE, &show_isis_interface_arg_cmd);
2279
2280 install_element (VIEW_NODE, &show_isis_neighbor_cmd);
2281 install_element (VIEW_NODE, &show_isis_neighbor_detail_cmd);
2282 install_element (VIEW_NODE, &show_isis_neighbor_arg_cmd);
2283 install_element (VIEW_NODE, &clear_isis_neighbor_cmd);
2284 install_element (VIEW_NODE, &clear_isis_neighbor_arg_cmd);
2285
2286 install_element (VIEW_NODE, &show_hostname_cmd);
2287 install_element (VIEW_NODE, &show_database_cmd);
2288
2289 install_element (ENABLE_NODE, &show_debugging_isis_cmd);
2290
2291 install_node (&debug_node, config_write_debug);
2292
2293 install_element (ENABLE_NODE, &debug_isis_adj_cmd);
2294 install_element (ENABLE_NODE, &no_debug_isis_adj_cmd);
2295 install_element (ENABLE_NODE, &debug_isis_csum_cmd);
2296 install_element (ENABLE_NODE, &no_debug_isis_csum_cmd);
2297 install_element (ENABLE_NODE, &debug_isis_lupd_cmd);
2298 install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd);
2299 install_element (ENABLE_NODE, &debug_isis_err_cmd);
2300 install_element (ENABLE_NODE, &no_debug_isis_err_cmd);
2301 install_element (ENABLE_NODE, &debug_isis_snp_cmd);
2302 install_element (ENABLE_NODE, &no_debug_isis_snp_cmd);
2303 install_element (ENABLE_NODE, &debug_isis_upd_cmd);
2304 install_element (ENABLE_NODE, &no_debug_isis_upd_cmd);
2305 install_element (ENABLE_NODE, &debug_isis_spfevents_cmd);
2306 install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd);
2307 install_element (ENABLE_NODE, &debug_isis_spfstats_cmd);
2308 install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd);
2309 install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd);
2310 install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd);
2311 install_element (ENABLE_NODE, &debug_isis_rtevents_cmd);
2312 install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd);
2313 install_element (ENABLE_NODE, &debug_isis_events_cmd);
2314 install_element (ENABLE_NODE, &no_debug_isis_events_cmd);
2315 install_element (ENABLE_NODE, &debug_isis_packet_dump_cmd);
2316 install_element (ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
2317 install_element (ENABLE_NODE, &debug_isis_lsp_gen_cmd);
2318 install_element (ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
2319 install_element (ENABLE_NODE, &debug_isis_lsp_sched_cmd);
2320 install_element (ENABLE_NODE, &no_debug_isis_lsp_sched_cmd);
2321
2322 install_element (CONFIG_NODE, &debug_isis_adj_cmd);
2323 install_element (CONFIG_NODE, &no_debug_isis_adj_cmd);
2324 install_element (CONFIG_NODE, &debug_isis_csum_cmd);
2325 install_element (CONFIG_NODE, &no_debug_isis_csum_cmd);
2326 install_element (CONFIG_NODE, &debug_isis_lupd_cmd);
2327 install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd);
2328 install_element (CONFIG_NODE, &debug_isis_err_cmd);
2329 install_element (CONFIG_NODE, &no_debug_isis_err_cmd);
2330 install_element (CONFIG_NODE, &debug_isis_snp_cmd);
2331 install_element (CONFIG_NODE, &no_debug_isis_snp_cmd);
2332 install_element (CONFIG_NODE, &debug_isis_upd_cmd);
2333 install_element (CONFIG_NODE, &no_debug_isis_upd_cmd);
2334 install_element (CONFIG_NODE, &debug_isis_spfevents_cmd);
2335 install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd);
2336 install_element (CONFIG_NODE, &debug_isis_spfstats_cmd);
2337 install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd);
2338 install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd);
2339 install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd);
2340 install_element (CONFIG_NODE, &debug_isis_rtevents_cmd);
2341 install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd);
2342 install_element (CONFIG_NODE, &debug_isis_events_cmd);
2343 install_element (CONFIG_NODE, &no_debug_isis_events_cmd);
2344 install_element (CONFIG_NODE, &debug_isis_packet_dump_cmd);
2345 install_element (CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
2346 install_element (CONFIG_NODE, &debug_isis_lsp_gen_cmd);
2347 install_element (CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
2348 install_element (CONFIG_NODE, &debug_isis_lsp_sched_cmd);
2349 install_element (CONFIG_NODE, &no_debug_isis_lsp_sched_cmd);
2350
2351 install_element (CONFIG_NODE, &router_isis_cmd);
2352 install_element (CONFIG_NODE, &no_router_isis_cmd);
2353
2354 install_default (ISIS_NODE);
2355
2356 install_element (ISIS_NODE, &net_cmd);
2357 install_element (ISIS_NODE, &no_net_cmd);
2358
2359 install_element (ISIS_NODE, &isis_topology_cmd);
2360 install_element (ISIS_NODE, &no_isis_topology_cmd);
2361
2362 install_element (ISIS_NODE, &log_adj_changes_cmd);
2363 install_element (ISIS_NODE, &no_log_adj_changes_cmd);
2364
2365 spf_backoff_cmd_init();
2366 }