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