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