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