2 * IS-IS Rout(e)ing protocol - isisd.c
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
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)
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
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.
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"
59 #ifdef TOPOLOGY_GENERATE
61 u_char DEFAULT_TOPOLOGY_BASEIS[6] = { 0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00 };
62 #endif /* TOPOLOGY_GENERATE */
64 struct isis *isis = NULL;
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 *);
81 isis_new (unsigned long process_id)
83 isis = XCALLOC (MTYPE_ISIS, sizeof (struct isis));
87 isis->max_area_addrs = 3;
88 isis->process_id = process_id;
90 isis->area_list = list_new ();
91 isis->init_circ_list = list_new ();
92 isis->uptime = time (NULL);
93 isis->nexthops = list_new ();
95 isis->nexthops6 = list_new ();
96 #endif /* HAVE_IPV6 */
99 * uncomment the next line for full debugs
101 /* isis->debugs = 0xFFFF; */
102 isisMplsTE.status = disable; /* Only support TE metric */
106 isis_area_create (const char *area_tag)
108 struct isis_area *area;
110 area = XCALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area));
113 * The first instance is level-1-2 rest are level-1, unless otherwise
116 if (listcount (isis->area_list) > 0)
117 area->is_type = IS_LEVEL_1;
119 area->is_type = IS_LEVEL_1_AND_2;
122 * intialize the databases
124 if (area->is_type & IS_LEVEL_1)
126 area->lspdb[0] = lsp_db_init ();
127 area->route_table[0] = route_table_init ();
129 area->route_table6[0] = route_table_init ();
130 #endif /* HAVE_IPV6 */
132 if (area->is_type & IS_LEVEL_2)
134 area->lspdb[1] = lsp_db_init ();
135 area->route_table[1] = route_table_init ();
137 area->route_table6[1] = route_table_init ();
138 #endif /* HAVE_IPV6 */
141 spftree_area_init (area);
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);
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;
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 */
168 area->area_tag = strdup (area_tag);
169 listnode_add (isis->area_list, area);
176 isis_area_lookup (const char *area_tag)
178 struct isis_area *area;
179 struct listnode *node;
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))
191 isis_area_get (struct vty *vty, const char *area_tag)
193 struct isis_area *area;
195 area = isis_area_lookup (area_tag);
199 vty->node = ISIS_NODE;
204 area = isis_area_create (area_tag);
206 if (isis->debugs & DEBUG_EVENTS)
207 zlog_debug ("New IS-IS area instance %s", area->area_tag);
209 vty->node = ISIS_NODE;
216 isis_area_destroy (struct vty *vty, const char *area_tag)
218 struct isis_area *area;
219 struct listnode *node, *nnode;
220 struct isis_circuit *circuit;
221 struct area_addr *addr;
223 area = isis_area_lookup (area_tag);
227 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
228 return CMD_ERR_NO_MATCH;
231 if (area->circuit_list)
233 for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
235 circuit->ip_router = 0;
237 circuit->ipv6_router = 0;
239 isis_csm_state_change (ISIS_DISABLE, circuit, area);
241 list_delete (area->circuit_list);
242 area->circuit_list = NULL;
245 if (area->lspdb[0] != NULL)
247 lsp_db_destroy (area->lspdb[0]);
248 area->lspdb[0] = NULL;
250 if (area->lspdb[1] != NULL)
252 lsp_db_destroy (area->lspdb[1]);
253 area->lspdb[1] = NULL;
256 spftree_area_del (area);
258 /* invalidate and validate would delete all routes from zebra */
259 isis_route_invalidate (area);
260 isis_route_validate (area);
262 if (area->route_table[0])
264 route_table_finish (area->route_table[0]);
265 area->route_table[0] = NULL;
267 if (area->route_table[1])
269 route_table_finish (area->route_table[1]);
270 area->route_table[1] = NULL;
273 if (area->route_table6[0])
275 route_table_finish (area->route_table6[0]);
276 area->route_table6[0] = NULL;
278 if (area->route_table6[1])
280 route_table_finish (area->route_table6[1]);
281 area->route_table6[1] = NULL;
283 #endif /* HAVE_IPV6 */
285 isis_redist_area_finish(area);
287 for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addr))
289 list_delete_node (area->area_addrs, node);
290 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
292 area->area_addrs = NULL;
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]);
298 thread_cancel_event (master, area);
300 listnode_delete (isis->area_list, area);
302 free (area->area_tag);
304 XFREE (MTYPE_ISIS_AREA, area);
306 if (listcount (isis->area_list) == 0)
308 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
316 area_net_title (struct vty *vty, const char *net_title)
318 struct isis_area *area;
319 struct area_addr *addr;
320 struct area_addr *addrp;
321 struct listnode *node;
328 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
329 return CMD_ERR_NO_MATCH;
332 /* We check that we are not over the maximal number of addresses */
333 if (listcount (area->area_addrs) >= isis->max_area_addrs)
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;
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);
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)
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;
355 if (addr->area_addr[addr->addr_len-1] != 0)
357 vty_out (vty, "nsel byte (last byte) in area address must be 0%s",
359 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
360 return CMD_ERR_AMBIGUOUS;
363 if (isis->sysid_set == 0)
366 * First area address - get the SystemID for this router
368 memcpy (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN);
370 if (isis->debugs & DEBUG_EVENTS)
371 zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid));
376 * Check that the SystemID portions match
378 if (memcmp (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN))
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;
387 /* now we see that we don't already have this address */
388 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
390 if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != (addr->addr_len))
392 if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
394 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
395 return CMD_SUCCESS; /* silent fail */
401 * Forget the systemID part of the address
403 addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
404 listnode_add (area->area_addrs, addr);
406 /* only now we can safely generate our LSPs for this area */
407 if (listcount (area->area_addrs) > 0)
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);
419 area_clear_net_title (struct vty *vty, const char *net_title)
421 struct isis_area *area;
422 struct area_addr addr, *addrp = NULL;
423 struct listnode *node;
429 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
430 return CMD_ERR_NO_MATCH;
433 addr.addr_len = dotformat2buff (buff, net_title);
434 if (addr.addr_len < 8 || addr.addr_len > 20)
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;
441 memcpy (addr.area_addr, buff, (int) addr.addr_len);
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))
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;
455 listnode_delete (area->area_addrs, addrp);
456 XFREE (MTYPE_ISIS_AREA_ADDR, addrp);
459 * Last area address - reset the SystemID for this router
461 if (listcount (area->area_addrs) == 0)
463 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
465 if (isis->debugs & DEBUG_EVENTS)
466 zlog_debug ("Router has no SystemID");
473 * 'show isis interface' command
477 show_isis_interface_common (struct vty *vty, const char *ifname, char detail)
479 struct listnode *anode, *cnode;
480 struct isis_area *area;
481 struct isis_circuit *circuit;
485 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
489 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
491 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
493 if (detail == ISIS_UI_LEVEL_BRIEF)
494 vty_out (vty, " Interface CircId State Type Level%s",
497 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
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);
507 DEFUN (show_isis_interface,
508 show_isis_interface_cmd,
509 "show isis interface",
511 "ISIS network information\n"
514 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
517 DEFUN (show_isis_interface_detail,
518 show_isis_interface_detail_cmd,
519 "show isis interface detail",
521 "ISIS network information\n"
523 "show detailed information\n")
525 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
528 DEFUN (show_isis_interface_arg,
529 show_isis_interface_arg_cmd,
530 "show isis interface WORD",
532 "ISIS network information\n"
534 "ISIS interface name\n")
536 return show_isis_interface_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
540 * 'show isis neighbor' command
544 show_isis_neighbor_common (struct vty *vty, const char *id, char detail)
546 struct listnode *anode, *cnode, *node;
547 struct isis_area *area;
548 struct isis_circuit *circuit;
550 struct isis_adjacency *adj;
551 struct isis_dynhn *dynhn;
552 u_char sysid[ISIS_SYS_ID_LEN];
557 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
561 memset (sysid, 0, ISIS_SYS_ID_LEN);
564 if (sysid2buff (sysid, id) == 0)
566 dynhn = dynhn_find_by_name (id);
569 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
572 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
576 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
578 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
580 if (detail == ISIS_UI_LEVEL_BRIEF)
581 vty_out (vty, " System Id Interface L State"
582 " Holdtime SNPA%s", VTY_NEWLINE);
584 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
586 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
588 for (i = 0; i < 2; i++)
590 adjdb = circuit->u.bc.adjdb[i];
591 if (adjdb && adjdb->count)
593 for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
594 if (!id || !memcmp (adj->sysid, sysid,
596 isis_adj_print_vty (adj, vty, detail);
600 else if (circuit->circ_type == CIRCUIT_T_P2P &&
601 circuit->u.p2p.neighbor)
603 adj = circuit->u.p2p.neighbor;
604 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
605 isis_adj_print_vty (adj, vty, detail);
614 * 'clear isis neighbor' command
617 clear_isis_neighbor_common (struct vty *vty, const char *id)
619 struct listnode *anode, *cnode, *cnextnode, *node, *nnode;
620 struct isis_area *area;
621 struct isis_circuit *circuit;
623 struct isis_adjacency *adj;
624 struct isis_dynhn *dynhn;
625 u_char sysid[ISIS_SYS_ID_LEN];
630 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
634 memset (sysid, 0, ISIS_SYS_ID_LEN);
637 if (sysid2buff (sysid, id) == 0)
639 dynhn = dynhn_find_by_name (id);
642 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
645 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
649 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
651 for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnextnode, circuit))
653 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
655 for (i = 0; i < 2; i++)
657 adjdb = circuit->u.bc.adjdb[i];
658 if (adjdb && adjdb->count)
660 for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj))
661 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
662 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
663 "clear user request");
667 else if (circuit->circ_type == CIRCUIT_T_P2P &&
668 circuit->u.p2p.neighbor)
670 adj = circuit->u.p2p.neighbor;
671 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
672 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
673 "clear user request");
681 DEFUN (show_isis_neighbor,
682 show_isis_neighbor_cmd,
683 "show isis neighbor",
685 "ISIS network information\n"
686 "ISIS neighbor adjacencies\n")
688 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
691 DEFUN (show_isis_neighbor_detail,
692 show_isis_neighbor_detail_cmd,
693 "show isis neighbor detail",
695 "ISIS network information\n"
696 "ISIS neighbor adjacencies\n"
697 "show detailed information\n")
699 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
702 DEFUN (show_isis_neighbor_arg,
703 show_isis_neighbor_arg_cmd,
704 "show isis neighbor WORD",
706 "ISIS network information\n"
707 "ISIS neighbor adjacencies\n"
710 return show_isis_neighbor_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
713 DEFUN (clear_isis_neighbor,
714 clear_isis_neighbor_cmd,
715 "clear isis neighbor",
717 "Reset ISIS network information\n"
718 "Reset ISIS neighbor adjacencies\n")
720 return clear_isis_neighbor_common (vty, NULL);
723 DEFUN (clear_isis_neighbor_arg,
724 clear_isis_neighbor_arg_cmd,
725 "clear isis neighbor WORD",
727 "ISIS network information\n"
728 "ISIS neighbor adjacencies\n"
731 return clear_isis_neighbor_common (vty, argv[0]);
735 * 'isis debug', 'show debugging'
738 print_debug (struct vty *vty, int flags, int onoff)
742 strcpy (onoffs, "on");
744 strcpy (onoffs, "off");
746 if (flags & DEBUG_ADJ_PACKETS)
747 vty_out (vty, "IS-IS Adjacency related packets debugging is %s%s", onoffs,
749 if (flags & DEBUG_CHECKSUM_ERRORS)
750 vty_out (vty, "IS-IS checksum errors debugging is %s%s", onoffs,
752 if (flags & DEBUG_LOCAL_UPDATES)
753 vty_out (vty, "IS-IS local updates debugging is %s%s", onoffs,
755 if (flags & DEBUG_PROTOCOL_ERRORS)
756 vty_out (vty, "IS-IS protocol errors debugging is %s%s", onoffs,
758 if (flags & DEBUG_SNP_PACKETS)
759 vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s%s", onoffs,
761 if (flags & DEBUG_SPF_EVENTS)
762 vty_out (vty, "IS-IS SPF events debugging is %s%s", onoffs, VTY_NEWLINE);
763 if (flags & DEBUG_SPF_STATS)
764 vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s%s",
765 onoffs, VTY_NEWLINE);
766 if (flags & DEBUG_SPF_TRIGGERS)
767 vty_out (vty, "IS-IS SPF triggering events debugging is %s%s", onoffs,
769 if (flags & DEBUG_UPDATE_PACKETS)
770 vty_out (vty, "IS-IS Update related packet debugging is %s%s", onoffs,
772 if (flags & DEBUG_RTE_EVENTS)
773 vty_out (vty, "IS-IS Route related debuggin is %s%s", onoffs,
775 if (flags & DEBUG_EVENTS)
776 vty_out (vty, "IS-IS Event debugging is %s%s", onoffs, VTY_NEWLINE);
777 if (flags & DEBUG_PACKET_DUMP)
778 vty_out (vty, "IS-IS Packet dump debugging is %s%s", onoffs, VTY_NEWLINE);
779 if (flags & DEBUG_LSP_GEN)
780 vty_out (vty, "IS-IS LSP generation debugging is %s%s", onoffs, VTY_NEWLINE);
781 if (flags & DEBUG_LSP_SCHED)
782 vty_out (vty, "IS-IS LSP scheduling debugging is %s%s", onoffs, VTY_NEWLINE);
785 DEFUN (show_debugging,
786 show_debugging_isis_cmd,
787 "show debugging isis",
789 "State of each debugging option\n")
792 vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
793 print_debug (vty, isis->debugs, 1);
799 static struct cmd_node debug_node = {
806 config_write_debug (struct vty *vty)
809 int flags = isis->debugs;
811 if (flags & DEBUG_ADJ_PACKETS)
813 vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
816 if (flags & DEBUG_CHECKSUM_ERRORS)
818 vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
821 if (flags & DEBUG_LOCAL_UPDATES)
823 vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
826 if (flags & DEBUG_PROTOCOL_ERRORS)
828 vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
831 if (flags & DEBUG_SNP_PACKETS)
833 vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
836 if (flags & DEBUG_SPF_EVENTS)
838 vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
841 if (flags & DEBUG_SPF_STATS)
843 vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
846 if (flags & DEBUG_SPF_TRIGGERS)
848 vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
851 if (flags & DEBUG_UPDATE_PACKETS)
853 vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
856 if (flags & DEBUG_RTE_EVENTS)
858 vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
861 if (flags & DEBUG_EVENTS)
863 vty_out (vty, "debug isis events%s", VTY_NEWLINE);
866 if (flags & DEBUG_PACKET_DUMP)
868 vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE);
871 if (flags & DEBUG_LSP_GEN)
873 vty_out (vty, "debug isis lsp-gen%s", VTY_NEWLINE);
876 if (flags & DEBUG_LSP_SCHED)
878 vty_out (vty, "debug isis lsp-sched%s", VTY_NEWLINE);
885 DEFUN (debug_isis_adj,
887 "debug isis adj-packets",
889 "IS-IS information\n"
890 "IS-IS Adjacency related packets\n")
892 isis->debugs |= DEBUG_ADJ_PACKETS;
893 print_debug (vty, DEBUG_ADJ_PACKETS, 1);
898 DEFUN (no_debug_isis_adj,
899 no_debug_isis_adj_cmd,
900 "no debug isis adj-packets",
902 "IS-IS information\n"
903 "IS-IS Adjacency related packets\n")
905 isis->debugs &= ~DEBUG_ADJ_PACKETS;
906 print_debug (vty, DEBUG_ADJ_PACKETS, 0);
911 DEFUN (debug_isis_csum,
913 "debug isis checksum-errors",
915 "IS-IS information\n"
916 "IS-IS LSP checksum errors\n")
918 isis->debugs |= DEBUG_CHECKSUM_ERRORS;
919 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1);
924 DEFUN (no_debug_isis_csum,
925 no_debug_isis_csum_cmd,
926 "no debug isis checksum-errors",
928 "IS-IS information\n"
929 "IS-IS LSP checksum errors\n")
931 isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
932 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
937 DEFUN (debug_isis_lupd,
939 "debug isis local-updates",
941 "IS-IS information\n"
942 "IS-IS local update packets\n")
944 isis->debugs |= DEBUG_LOCAL_UPDATES;
945 print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
950 DEFUN (no_debug_isis_lupd,
951 no_debug_isis_lupd_cmd,
952 "no debug isis local-updates",
954 "IS-IS information\n"
955 "IS-IS local update packets\n")
957 isis->debugs &= ~DEBUG_LOCAL_UPDATES;
958 print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
963 DEFUN (debug_isis_err,
965 "debug isis protocol-errors",
967 "IS-IS information\n"
968 "IS-IS LSP protocol errors\n")
970 isis->debugs |= DEBUG_PROTOCOL_ERRORS;
971 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1);
976 DEFUN (no_debug_isis_err,
977 no_debug_isis_err_cmd,
978 "no debug isis protocol-errors",
980 "IS-IS information\n"
981 "IS-IS LSP protocol errors\n")
983 isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
984 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
989 DEFUN (debug_isis_snp,
991 "debug isis snp-packets",
993 "IS-IS information\n"
994 "IS-IS CSNP/PSNP packets\n")
996 isis->debugs |= DEBUG_SNP_PACKETS;
997 print_debug (vty, DEBUG_SNP_PACKETS, 1);
1002 DEFUN (no_debug_isis_snp,
1003 no_debug_isis_snp_cmd,
1004 "no debug isis snp-packets",
1006 "IS-IS information\n"
1007 "IS-IS CSNP/PSNP packets\n")
1009 isis->debugs &= ~DEBUG_SNP_PACKETS;
1010 print_debug (vty, DEBUG_SNP_PACKETS, 0);
1015 DEFUN (debug_isis_upd,
1017 "debug isis update-packets",
1019 "IS-IS information\n"
1020 "IS-IS Update related packets\n")
1022 isis->debugs |= DEBUG_UPDATE_PACKETS;
1023 print_debug (vty, DEBUG_UPDATE_PACKETS, 1);
1028 DEFUN (no_debug_isis_upd,
1029 no_debug_isis_upd_cmd,
1030 "no debug isis update-packets",
1032 "IS-IS information\n"
1033 "IS-IS Update related packets\n")
1035 isis->debugs &= ~DEBUG_UPDATE_PACKETS;
1036 print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
1041 DEFUN (debug_isis_spfevents,
1042 debug_isis_spfevents_cmd,
1043 "debug isis spf-events",
1045 "IS-IS information\n"
1046 "IS-IS Shortest Path First Events\n")
1048 isis->debugs |= DEBUG_SPF_EVENTS;
1049 print_debug (vty, DEBUG_SPF_EVENTS, 1);
1054 DEFUN (no_debug_isis_spfevents,
1055 no_debug_isis_spfevents_cmd,
1056 "no debug isis spf-events",
1058 "IS-IS information\n"
1059 "IS-IS Shortest Path First Events\n")
1061 isis->debugs &= ~DEBUG_SPF_EVENTS;
1062 print_debug (vty, DEBUG_SPF_EVENTS, 0);
1067 DEFUN (debug_isis_spfstats,
1068 debug_isis_spfstats_cmd,
1069 "debug isis spf-statistics ",
1071 "IS-IS information\n"
1072 "IS-IS SPF Timing and Statistic Data\n")
1074 isis->debugs |= DEBUG_SPF_STATS;
1075 print_debug (vty, DEBUG_SPF_STATS, 1);
1080 DEFUN (no_debug_isis_spfstats,
1081 no_debug_isis_spfstats_cmd,
1082 "no debug isis spf-statistics",
1084 "IS-IS information\n"
1085 "IS-IS SPF Timing and Statistic Data\n")
1087 isis->debugs &= ~DEBUG_SPF_STATS;
1088 print_debug (vty, DEBUG_SPF_STATS, 0);
1093 DEFUN (debug_isis_spftrigg,
1094 debug_isis_spftrigg_cmd,
1095 "debug isis spf-triggers",
1097 "IS-IS information\n"
1098 "IS-IS SPF triggering events\n")
1100 isis->debugs |= DEBUG_SPF_TRIGGERS;
1101 print_debug (vty, DEBUG_SPF_TRIGGERS, 1);
1106 DEFUN (no_debug_isis_spftrigg,
1107 no_debug_isis_spftrigg_cmd,
1108 "no debug isis spf-triggers",
1110 "IS-IS information\n"
1111 "IS-IS SPF triggering events\n")
1113 isis->debugs &= ~DEBUG_SPF_TRIGGERS;
1114 print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
1119 DEFUN (debug_isis_rtevents,
1120 debug_isis_rtevents_cmd,
1121 "debug isis route-events",
1123 "IS-IS information\n"
1124 "IS-IS Route related events\n")
1126 isis->debugs |= DEBUG_RTE_EVENTS;
1127 print_debug (vty, DEBUG_RTE_EVENTS, 1);
1132 DEFUN (no_debug_isis_rtevents,
1133 no_debug_isis_rtevents_cmd,
1134 "no debug isis route-events",
1136 "IS-IS information\n"
1137 "IS-IS Route related events\n")
1139 isis->debugs &= ~DEBUG_RTE_EVENTS;
1140 print_debug (vty, DEBUG_RTE_EVENTS, 0);
1145 DEFUN (debug_isis_events,
1146 debug_isis_events_cmd,
1147 "debug isis events",
1149 "IS-IS information\n"
1152 isis->debugs |= DEBUG_EVENTS;
1153 print_debug (vty, DEBUG_EVENTS, 1);
1158 DEFUN (no_debug_isis_events,
1159 no_debug_isis_events_cmd,
1160 "no debug isis events",
1162 "IS-IS information\n"
1165 isis->debugs &= ~DEBUG_EVENTS;
1166 print_debug (vty, DEBUG_EVENTS, 0);
1171 DEFUN (debug_isis_packet_dump,
1172 debug_isis_packet_dump_cmd,
1173 "debug isis packet-dump",
1175 "IS-IS information\n"
1176 "IS-IS packet dump\n")
1178 isis->debugs |= DEBUG_PACKET_DUMP;
1179 print_debug (vty, DEBUG_PACKET_DUMP, 1);
1184 DEFUN (no_debug_isis_packet_dump,
1185 no_debug_isis_packet_dump_cmd,
1186 "no debug isis packet-dump",
1188 "IS-IS information\n"
1189 "IS-IS packet dump\n")
1191 isis->debugs &= ~DEBUG_PACKET_DUMP;
1192 print_debug (vty, DEBUG_PACKET_DUMP, 0);
1197 DEFUN (debug_isis_lsp_gen,
1198 debug_isis_lsp_gen_cmd,
1199 "debug isis lsp-gen",
1201 "IS-IS information\n"
1202 "IS-IS generation of own LSPs\n")
1204 isis->debugs |= DEBUG_LSP_GEN;
1205 print_debug (vty, DEBUG_LSP_GEN, 1);
1210 DEFUN (no_debug_isis_lsp_gen,
1211 no_debug_isis_lsp_gen_cmd,
1212 "no debug isis lsp-gen",
1214 "IS-IS information\n"
1215 "IS-IS generation of own LSPs\n")
1217 isis->debugs &= ~DEBUG_LSP_GEN;
1218 print_debug (vty, DEBUG_LSP_GEN, 0);
1223 DEFUN (debug_isis_lsp_sched,
1224 debug_isis_lsp_sched_cmd,
1225 "debug isis lsp-sched",
1227 "IS-IS information\n"
1228 "IS-IS scheduling of LSP generation\n")
1230 isis->debugs |= DEBUG_LSP_SCHED;
1231 print_debug (vty, DEBUG_LSP_SCHED, 1);
1236 DEFUN (no_debug_isis_lsp_sched,
1237 no_debug_isis_lsp_sched_cmd,
1238 "no debug isis lsp-gen",
1240 "IS-IS information\n"
1241 "IS-IS scheduling of LSP generation\n")
1243 isis->debugs &= ~DEBUG_LSP_SCHED;
1244 print_debug (vty, DEBUG_LSP_SCHED, 0);
1249 DEFUN (show_hostname,
1251 "show isis hostname",
1253 "IS-IS information\n"
1254 "IS-IS Dynamic hostname mapping\n")
1256 dynhn_print_all (vty);
1262 vty_out_timestr(struct vty *vty, time_t uptime)
1265 time_t difftime = time (NULL);
1267 tm = gmtime (&difftime);
1269 #define ONE_DAY_SECOND 60*60*24
1270 #define ONE_WEEK_SECOND 60*60*24*7
1271 if (difftime < ONE_DAY_SECOND)
1272 vty_out (vty, "%02d:%02d:%02d",
1273 tm->tm_hour, tm->tm_min, tm->tm_sec);
1274 else if (difftime < ONE_WEEK_SECOND)
1275 vty_out (vty, "%dd%02dh%02dm",
1276 tm->tm_yday, tm->tm_hour, tm->tm_min);
1278 vty_out (vty, "%02dw%dd%02dh",
1280 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1281 vty_out (vty, " ago");
1284 DEFUN (show_isis_summary,
1285 show_isis_summary_cmd,
1286 "show isis summary",
1287 SHOW_STR "IS-IS information\n" "IS-IS summary\n")
1289 struct listnode *node, *node2;
1290 struct isis_area *area;
1291 struct isis_spftree *spftree;
1296 vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
1300 vty_out (vty, "Process Id : %ld%s", isis->process_id,
1302 if (isis->sysid_set)
1303 vty_out (vty, "System Id : %s%s", sysid_print (isis->sysid),
1306 vty_out (vty, "Up time : ");
1307 vty_out_timestr(vty, isis->uptime);
1308 vty_out (vty, "%s", VTY_NEWLINE);
1310 if (isis->area_list)
1311 vty_out (vty, "Number of areas : %d%s", isis->area_list->count,
1314 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1316 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1319 if (listcount (area->area_addrs) > 0)
1321 struct area_addr *area_addr;
1322 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
1324 vty_out (vty, " Net: %s%s",
1325 isonet_print (area_addr->area_addr,
1326 area_addr->addr_len + ISIS_SYS_ID_LEN +
1331 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
1333 if ((area->is_type & level) == 0)
1336 vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE);
1337 spftree = area->spftree[level - 1];
1338 if (spftree->pending)
1339 vty_out (vty, " IPv4 SPF: (pending)%s", VTY_NEWLINE);
1341 vty_out (vty, " IPv4 SPF:%s", VTY_NEWLINE);
1343 vty_out (vty, " minimum interval : %d%s",
1344 area->min_spf_interval[level - 1], VTY_NEWLINE);
1346 vty_out (vty, " last run elapsed : ");
1347 vty_out_timestr(vty, spftree->last_run_timestamp);
1348 vty_out (vty, "%s", VTY_NEWLINE);
1350 vty_out (vty, " last run duration : %u usec%s",
1351 (u_int32_t)spftree->last_run_duration, VTY_NEWLINE);
1353 vty_out (vty, " run count : %d%s",
1354 spftree->runcount, VTY_NEWLINE);
1357 spftree = area->spftree6[level - 1];
1358 if (spftree->pending)
1359 vty_out (vty, " IPv6 SPF: (pending)%s", VTY_NEWLINE);
1361 vty_out (vty, " IPv6 SPF:%s", VTY_NEWLINE);
1363 vty_out (vty, " minimum interval : %d%s",
1364 area->min_spf_interval[level - 1], VTY_NEWLINE);
1366 vty_out (vty, " last run elapsed : ");
1367 vty_out_timestr(vty, spftree->last_run_timestamp);
1368 vty_out (vty, "%s", VTY_NEWLINE);
1370 vty_out (vty, " last run duration : %llu msec%s",
1371 (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
1373 vty_out (vty, " run count : %d%s",
1374 spftree->runcount, VTY_NEWLINE);
1378 vty_out (vty, "%s", VTY_NEWLINE);
1384 * This function supports following display options:
1385 * [ show isis database [detail] ]
1386 * [ show isis database <sysid> [detail] ]
1387 * [ show isis database <hostname> [detail] ]
1388 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1389 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1390 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1391 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1392 * [ show isis database detail <sysid> ]
1393 * [ show isis database detail <hostname> ]
1394 * [ show isis database detail <sysid>.<pseudo-id> ]
1395 * [ show isis database detail <hostname>.<pseudo-id> ]
1396 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1397 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1400 show_isis_database (struct vty *vty, const char *argv, int ui_level)
1402 struct listnode *node;
1403 struct isis_area *area;
1404 struct isis_lsp *lsp;
1405 struct isis_dynhn *dynhn;
1406 const char *pos = argv;
1407 u_char lspid[ISIS_SYS_ID_LEN+2];
1410 int level, lsp_count;
1412 if (isis->area_list->count == 0)
1415 memset (&lspid, 0, ISIS_SYS_ID_LEN);
1416 memset (&sysid, 0, 255);
1419 * extract fragment and pseudo id from the string argv
1421 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1422 * (b) <systemid/hostname>.<pseudo-id> or
1423 * (c) <systemid/hostname> or
1424 * Where systemid is in the form:
1428 strncpy (sysid, argv, 254);
1429 if (argv && strlen (argv) > 3)
1431 pos = argv + strlen (argv) - 3;
1432 if (strncmp (pos, "-", 1) == 0)
1434 memcpy (number, ++pos, 2);
1435 lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16);
1437 if (strncmp (pos, ".", 1) != 0)
1438 return CMD_ERR_AMBIGUOUS;
1440 if (strncmp (pos, ".", 1) == 0)
1442 memcpy (number, ++pos, 2);
1443 lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16);
1444 sysid[pos - argv - 1] = '\0';
1448 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1450 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1453 for (level = 0; level < ISIS_LEVELS; level++)
1455 if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
1461 * Try to find the lsp-id if the argv string is in
1462 * the form hostname.<pseudo-id>-<fragment>
1464 if (sysid2buff (lspid, sysid))
1466 lsp = lsp_search (lspid, area->lspdb[level]);
1468 else if ((dynhn = dynhn_find_by_name (sysid)))
1470 memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN);
1471 lsp = lsp_search (lspid, area->lspdb[level]);
1473 else if (strncmp(unix_hostname (), sysid, 15) == 0)
1475 memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
1476 lsp = lsp_search (lspid, area->lspdb[level]);
1480 if (lsp != NULL || argv == NULL)
1482 vty_out (vty, "IS-IS Level-%d link-state database:%s",
1483 level + 1, VTY_NEWLINE);
1485 /* print the title in all cases */
1486 vty_out (vty, "LSP ID PduLen "
1487 "SeqNumber Chksum Holdtime ATT/P/OL%s",
1493 if (ui_level == ISIS_UI_LEVEL_DETAIL)
1494 lsp_print_detail (lsp, vty, area->dynhostname);
1496 lsp_print (lsp, vty, area->dynhostname);
1498 else if (argv == NULL)
1500 lsp_count = lsp_print_all (vty, area->lspdb[level],
1504 vty_out (vty, " %u LSPs%s%s",
1505 lsp_count, VTY_NEWLINE, VTY_NEWLINE);
1514 DEFUN (show_database_brief,
1516 "show isis database",
1518 "IS-IS information\n"
1519 "IS-IS link state database\n")
1521 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_BRIEF);
1524 DEFUN (show_database_lsp_brief,
1525 show_database_arg_cmd,
1526 "show isis database WORD",
1528 "IS-IS information\n"
1529 "IS-IS link state database\n"
1532 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_BRIEF);
1535 DEFUN (show_database_lsp_detail,
1536 show_database_arg_detail_cmd,
1537 "show isis database WORD detail",
1539 "IS-IS information\n"
1540 "IS-IS link state database\n"
1542 "Detailed information\n")
1544 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
1547 DEFUN (show_database_detail,
1548 show_database_detail_cmd,
1549 "show isis database detail",
1551 "IS-IS information\n"
1552 "IS-IS link state database\n")
1554 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_DETAIL);
1557 DEFUN (show_database_detail_lsp,
1558 show_database_detail_arg_cmd,
1559 "show isis database detail WORD",
1561 "IS-IS information\n"
1562 "IS-IS link state database\n"
1563 "Detailed information\n"
1566 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
1570 * 'router isis' command
1577 "ISO Routing area tag")
1579 return isis_area_get (vty, argv[0]);
1583 *'no router isis' command
1585 DEFUN (no_router_isis,
1587 "no router isis WORD",
1588 "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
1590 return isis_area_destroy (vty, argv[0]);
1599 "A Network Entity Title for this process (OSI only)\n"
1600 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1602 return area_net_title (vty, argv[0]);
1612 "A Network Entity Title for this process (OSI only)\n"
1613 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
1615 return area_clear_net_title (vty, argv[0]);
1618 void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu)
1620 area->lsp_mtu = lsp_mtu;
1621 lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
1625 isis_area_passwd_set(struct isis_area *area, int level, u_char passwd_type,
1626 const char *passwd, u_char snp_auth)
1628 struct isis_passwd *dest;
1629 struct isis_passwd modified;
1632 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
1633 dest = (level == IS_LEVEL_1) ? &area->area_passwd : &area->domain_passwd;
1634 memset(&modified, 0, sizeof(modified));
1636 if (passwd_type != ISIS_PASSWD_TYPE_UNUSED)
1641 len = strlen(passwd);
1646 strncpy((char*)modified.passwd, passwd, 255);
1647 modified.type = passwd_type;
1648 modified.snp_auth = snp_auth;
1651 if (memcmp(&modified, dest, sizeof(modified)))
1653 memcpy(dest, &modified, sizeof(modified));
1654 lsp_regenerate_schedule(area, IS_LEVEL_1|IS_LEVEL_2, 1);
1661 isis_area_passwd_unset (struct isis_area *area, int level)
1663 return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_UNUSED, NULL, 0);
1667 isis_area_passwd_cleartext_set (struct isis_area *area, int level,
1668 const char *passwd, u_char snp_auth)
1670 return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_CLEARTXT,
1675 isis_area_passwd_hmac_md5_set (struct isis_area *area, int level,
1676 const char *passwd, u_char snp_auth)
1678 return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_HMAC_MD5,
1683 area_resign_level (struct isis_area *area, int level)
1685 if (area->lspdb[level - 1])
1687 lsp_db_destroy (area->lspdb[level - 1]);
1688 area->lspdb[level - 1] = NULL;
1690 if (area->spftree[level - 1])
1692 isis_spftree_del (area->spftree[level - 1]);
1693 area->spftree[level - 1] = NULL;
1696 if (area->spftree6[level - 1])
1698 isis_spftree_del (area->spftree6[level - 1]);
1699 area->spftree6[level - 1] = NULL;
1702 if (area->route_table[level - 1])
1704 route_table_finish (area->route_table[level - 1]);
1705 area->route_table[level - 1] = NULL;
1708 if (area->route_table6[level - 1])
1710 route_table_finish (area->route_table6[level - 1]);
1711 area->route_table6[level - 1] = NULL;
1713 #endif /* HAVE_IPV6 */
1715 sched_debug("ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
1716 area->area_tag, level);
1717 THREAD_TIMER_OFF (area->t_lsp_refresh[level - 1]);
1718 area->lsp_regenerate_pending[level - 1] = 0;
1722 isis_area_is_type_set(struct isis_area *area, int is_type)
1724 struct listnode *node;
1725 struct isis_circuit *circuit;
1727 if (isis->debugs & DEBUG_EVENTS)
1728 zlog_debug ("ISIS-Evt (%s) system type change %s -> %s", area->area_tag,
1729 circuit_t2string (area->is_type), circuit_t2string (is_type));
1731 if (area->is_type == is_type)
1732 return; /* No change */
1734 switch (area->is_type)
1737 if (is_type == IS_LEVEL_2)
1738 area_resign_level (area, IS_LEVEL_1);
1740 if (area->lspdb[1] == NULL)
1741 area->lspdb[1] = lsp_db_init ();
1742 if (area->route_table[1] == NULL)
1743 area->route_table[1] = route_table_init ();
1745 if (area->route_table6[1] == NULL)
1746 area->route_table6[1] = route_table_init ();
1747 #endif /* HAVE_IPV6 */
1750 case IS_LEVEL_1_AND_2:
1751 if (is_type == IS_LEVEL_1)
1752 area_resign_level (area, IS_LEVEL_2);
1754 area_resign_level (area, IS_LEVEL_1);
1758 if (is_type == IS_LEVEL_1)
1759 area_resign_level (area, IS_LEVEL_2);
1761 if (area->lspdb[0] == NULL)
1762 area->lspdb[0] = lsp_db_init ();
1763 if (area->route_table[0] == NULL)
1764 area->route_table[0] = route_table_init ();
1766 if (area->route_table6[0] == NULL)
1767 area->route_table6[0] = route_table_init ();
1768 #endif /* HAVE_IPV6 */
1775 area->is_type = is_type;
1777 /* override circuit's is_type */
1778 if (area->is_type != IS_LEVEL_1_AND_2)
1780 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
1781 isis_circuit_is_type_set (circuit, is_type);
1784 spftree_area_init (area);
1786 if (is_type & IS_LEVEL_1)
1787 lsp_generate (area, IS_LEVEL_1);
1788 if (is_type & IS_LEVEL_2)
1789 lsp_generate (area, IS_LEVEL_2);
1790 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1795 void isis_area_metricstyle_set(struct isis_area *area, bool old_metric,
1798 if (area->oldmetric != old_metric
1799 || area->newmetric != new_metric)
1801 area->oldmetric = old_metric;
1802 area->newmetric = new_metric;
1803 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1807 void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit)
1809 char new_overload_bit = overload_bit ? LSPBIT_OL : 0;
1811 if (new_overload_bit != area->overload_bit)
1813 area->overload_bit = new_overload_bit;
1814 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1818 void isis_area_attached_bit_set(struct isis_area *area, bool attached_bit)
1820 char new_attached_bit = attached_bit ? LSPBIT_ATT : 0;
1822 if (new_attached_bit != area->attached_bit)
1824 area->attached_bit = new_attached_bit;
1825 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1829 void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname)
1831 if (area->dynhostname != dynhostname)
1833 area->dynhostname = dynhostname;
1834 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
1839 isis_area_max_lsp_lifetime_set(struct isis_area *area, int level,
1840 uint16_t max_lsp_lifetime)
1842 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
1844 if (area->max_lsp_lifetime[level-1] == max_lsp_lifetime)
1847 area->max_lsp_lifetime[level-1] = max_lsp_lifetime;
1848 lsp_regenerate_schedule(area, level, 1);
1852 isis_area_lsp_refresh_set(struct isis_area *area, int level,
1853 uint16_t lsp_refresh)
1855 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
1857 if (area->lsp_refresh[level-1] == lsp_refresh)
1860 area->lsp_refresh[level-1] = lsp_refresh;
1861 lsp_regenerate_schedule(area, level, 1);
1864 DEFUN (log_adj_changes,
1865 log_adj_changes_cmd,
1866 "log-adjacency-changes",
1867 "Log changes in adjacency state\n")
1869 struct isis_area *area;
1874 area->log_adj_changes = 1;
1879 DEFUN (no_log_adj_changes,
1880 no_log_adj_changes_cmd,
1881 "no log-adjacency-changes",
1882 "Stop logging changes in adjacency state\n")
1884 struct isis_area *area;
1889 area->log_adj_changes = 0;
1894 #ifdef TOPOLOGY_GENERATE
1896 DEFUN (topology_generate_grid,
1897 topology_generate_grid_cmd,
1898 "topology generate grid <1-100> <1-100> <1-65000> [param] [param] "
1900 "Topology generation for IS-IS\n"
1901 "Topology generation\n"
1903 "X parameter of the grid\n"
1904 "Y parameter of the grid\n"
1906 "Optional param 1\n"
1907 "Optional param 2\n"
1908 "Optional param 3\n"
1911 struct isis_area *area;
1916 if (!spgrid_check_params (vty, argc, argv))
1919 list_delete (area->topology);
1920 area->topology = list_new ();
1921 memcpy (area->top_params, vty->buf, 200);
1922 gen_spgrid_topology (vty, area->topology);
1923 remove_topology_lsps (area);
1924 generate_topology_lsps (area);
1925 /* Regenerate L1 LSP to get two way connection to the generated
1927 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1933 DEFUN (show_isis_generated_topology,
1934 show_isis_generated_topology_cmd,
1935 "show isis generated-topologies",
1937 "ISIS network information\n"
1938 "Show generated topologies\n")
1940 struct isis_area *area;
1941 struct listnode *node;
1942 struct listnode *node2;
1945 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1947 if (!area->topology)
1950 vty_out (vty, "Topology for isis area: %s%s", area->area_tag,
1952 vty_out (vty, "From node To node Distance%s", VTY_NEWLINE);
1954 for (ALL_LIST_ELEMENTS_RO (area->topology, node2, arc))
1955 vty_out (vty, "%9ld %11ld %12ld%s", arc->from_node, arc->to_node,
1956 arc->distance, VTY_NEWLINE);
1961 /* Base IS for topology generation. */
1962 DEFUN (topology_baseis,
1963 topology_baseis_cmd,
1964 "topology base-is WORD",
1965 "Topology generation for IS-IS\n"
1966 "A Network IS Base for this topology\n"
1967 "XXXX.XXXX.XXXX Network entity title (NET)\n")
1969 struct isis_area *area;
1970 u_char buff[ISIS_SYS_ID_LEN];
1975 if (sysid2buff (buff, argv[0]))
1976 sysid2buff (area->topology_baseis, argv[0]);
1981 DEFUN (no_topology_baseis,
1982 no_topology_baseis_cmd,
1983 "no topology base-is WORD",
1985 "Topology generation for IS-IS\n"
1986 "A Network IS Base for this topology\n"
1987 "XXXX.XXXX.XXXX Network entity title (NET)\n")
1989 struct isis_area *area;
1994 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
1998 ALIAS (no_topology_baseis,
1999 no_topology_baseis_noid_cmd,
2000 "no topology base-is",
2002 "Topology generation for IS-IS\n"
2003 "A Network IS Base for this topology\n")
2005 DEFUN (topology_basedynh,
2006 topology_basedynh_cmd,
2007 "topology base-dynh WORD",
2008 "Topology generation for IS-IS\n"
2009 "Dynamic hostname base for this topology\n"
2010 "Dynamic hostname base\n")
2012 struct isis_area *area;
2017 /* I hope that it's enough. */
2018 area->topology_basedynh = strndup (argv[0], 16);
2022 #endif /* TOPOLOGY_GENERATE */
2024 /* IS-IS configuration write function */
2026 isis_config_write (struct vty *vty)
2032 struct isis_area *area;
2033 struct listnode *node, *node2;
2035 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
2037 /* ISIS - Area name */
2038 vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
2041 if (listcount (area->area_addrs) > 0)
2043 struct area_addr *area_addr;
2044 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
2046 vty_out (vty, " net %s%s",
2047 isonet_print (area_addr->area_addr,
2048 area_addr->addr_len + ISIS_SYS_ID_LEN +
2053 /* ISIS - Dynamic hostname - Defaults to true so only display if
2055 if (!area->dynhostname)
2057 vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
2060 /* ISIS - Metric-Style - when true displays wide */
2061 if (area->newmetric)
2063 if (!area->oldmetric)
2064 vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
2066 vty_out (vty, " metric-style transition%s", VTY_NEWLINE);
2071 vty_out (vty, " metric-style narrow%s", VTY_NEWLINE);
2074 /* ISIS - overload-bit */
2075 if (area->overload_bit)
2077 vty_out (vty, " set-overload-bit%s", VTY_NEWLINE);
2080 /* ISIS - Area is-type (level-1-2 is default) */
2081 if (area->is_type == IS_LEVEL_1)
2083 vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
2086 else if (area->is_type == IS_LEVEL_2)
2088 vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
2091 write += isis_redist_config_write(vty, area, AF_INET);
2092 write += isis_redist_config_write(vty, area, AF_INET6);
2093 /* ISIS - Lsp generation interval */
2094 if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1])
2096 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
2098 vty_out (vty, " lsp-gen-interval %d%s",
2099 area->lsp_gen_interval[0], VTY_NEWLINE);
2105 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
2107 vty_out (vty, " lsp-gen-interval level-1 %d%s",
2108 area->lsp_gen_interval[0], VTY_NEWLINE);
2111 if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL)
2113 vty_out (vty, " lsp-gen-interval level-2 %d%s",
2114 area->lsp_gen_interval[1], VTY_NEWLINE);
2118 /* ISIS - LSP lifetime */
2119 if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1])
2121 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
2123 vty_out (vty, " max-lsp-lifetime %u%s", area->max_lsp_lifetime[0],
2130 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
2132 vty_out (vty, " max-lsp-lifetime level-1 %u%s",
2133 area->max_lsp_lifetime[0], VTY_NEWLINE);
2136 if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME)
2138 vty_out (vty, " max-lsp-lifetime level-2 %u%s",
2139 area->max_lsp_lifetime[1], VTY_NEWLINE);
2143 /* ISIS - LSP refresh interval */
2144 if (area->lsp_refresh[0] == area->lsp_refresh[1])
2146 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2148 vty_out (vty, " lsp-refresh-interval %u%s", area->lsp_refresh[0],
2155 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2157 vty_out (vty, " lsp-refresh-interval level-1 %u%s",
2158 area->lsp_refresh[0], VTY_NEWLINE);
2161 if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2163 vty_out (vty, " lsp-refresh-interval level-2 %u%s",
2164 area->lsp_refresh[1], VTY_NEWLINE);
2168 if (area->lsp_mtu != DEFAULT_LSP_MTU)
2170 vty_out(vty, " lsp-mtu %u%s", area->lsp_mtu, VTY_NEWLINE);
2174 /* Minimum SPF interval. */
2175 if (area->min_spf_interval[0] == area->min_spf_interval[1])
2177 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
2179 vty_out (vty, " spf-interval %d%s",
2180 area->min_spf_interval[0], VTY_NEWLINE);
2186 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
2188 vty_out (vty, " spf-interval level-1 %d%s",
2189 area->min_spf_interval[0], VTY_NEWLINE);
2192 if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL)
2194 vty_out (vty, " spf-interval level-2 %d%s",
2195 area->min_spf_interval[1], VTY_NEWLINE);
2199 /* Authentication passwords. */
2200 if (area->area_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
2202 vty_out(vty, " area-password md5 %s", area->area_passwd.passwd);
2203 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
2205 vty_out(vty, " authenticate snp ");
2206 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
2207 vty_out(vty, "validate");
2209 vty_out(vty, "send-only");
2211 vty_out(vty, "%s", VTY_NEWLINE);
2214 else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
2216 vty_out(vty, " area-password clear %s", area->area_passwd.passwd);
2217 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
2219 vty_out(vty, " authenticate snp ");
2220 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
2221 vty_out(vty, "validate");
2223 vty_out(vty, "send-only");
2225 vty_out(vty, "%s", VTY_NEWLINE);
2228 if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
2230 vty_out(vty, " domain-password md5 %s",
2231 area->domain_passwd.passwd);
2232 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
2234 vty_out(vty, " authenticate snp ");
2235 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
2236 vty_out(vty, "validate");
2238 vty_out(vty, "send-only");
2240 vty_out(vty, "%s", VTY_NEWLINE);
2243 else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
2245 vty_out(vty, " domain-password clear %s",
2246 area->domain_passwd.passwd);
2247 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
2249 vty_out(vty, " authenticate snp ");
2250 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
2251 vty_out(vty, "validate");
2253 vty_out(vty, "send-only");
2255 vty_out(vty, "%s", VTY_NEWLINE);
2259 if (area->log_adj_changes)
2261 vty_out (vty, " log-adjacency-changes%s", VTY_NEWLINE);
2265 #ifdef TOPOLOGY_GENERATE
2266 if (memcmp (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS,
2269 vty_out (vty, " topology base-is %s%s",
2270 sysid_print ((u_char *)area->topology_baseis), VTY_NEWLINE);
2273 if (area->topology_basedynh)
2275 vty_out (vty, " topology base-dynh %s%s",
2276 area->topology_basedynh, VTY_NEWLINE);
2279 /* We save the whole command line here. */
2280 if (strlen(area->top_params))
2282 vty_out (vty, " %s%s", area->top_params, VTY_NEWLINE);
2285 #endif /* TOPOLOGY_GENERATE */
2288 isis_mpls_te_config_write_router(vty);
2294 struct cmd_node isis_node = {
2296 "%s(config-router)# ",
2303 /* Install IS-IS top node */
2304 install_node (&isis_node, isis_config_write);
2306 install_element (VIEW_NODE, &show_isis_summary_cmd);
2308 install_element (VIEW_NODE, &show_isis_interface_cmd);
2309 install_element (VIEW_NODE, &show_isis_interface_detail_cmd);
2310 install_element (VIEW_NODE, &show_isis_interface_arg_cmd);
2312 install_element (VIEW_NODE, &show_isis_neighbor_cmd);
2313 install_element (VIEW_NODE, &show_isis_neighbor_detail_cmd);
2314 install_element (VIEW_NODE, &show_isis_neighbor_arg_cmd);
2315 install_element (VIEW_NODE, &clear_isis_neighbor_cmd);
2316 install_element (VIEW_NODE, &clear_isis_neighbor_arg_cmd);
2318 install_element (VIEW_NODE, &show_hostname_cmd);
2319 install_element (VIEW_NODE, &show_database_cmd);
2320 install_element (VIEW_NODE, &show_database_arg_cmd);
2321 install_element (VIEW_NODE, &show_database_arg_detail_cmd);
2322 install_element (VIEW_NODE, &show_database_detail_cmd);
2323 install_element (VIEW_NODE, &show_database_detail_arg_cmd);
2325 install_element (ENABLE_NODE, &show_debugging_isis_cmd);
2327 install_node (&debug_node, config_write_debug);
2329 install_element (ENABLE_NODE, &debug_isis_adj_cmd);
2330 install_element (ENABLE_NODE, &no_debug_isis_adj_cmd);
2331 install_element (ENABLE_NODE, &debug_isis_csum_cmd);
2332 install_element (ENABLE_NODE, &no_debug_isis_csum_cmd);
2333 install_element (ENABLE_NODE, &debug_isis_lupd_cmd);
2334 install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd);
2335 install_element (ENABLE_NODE, &debug_isis_err_cmd);
2336 install_element (ENABLE_NODE, &no_debug_isis_err_cmd);
2337 install_element (ENABLE_NODE, &debug_isis_snp_cmd);
2338 install_element (ENABLE_NODE, &no_debug_isis_snp_cmd);
2339 install_element (ENABLE_NODE, &debug_isis_upd_cmd);
2340 install_element (ENABLE_NODE, &no_debug_isis_upd_cmd);
2341 install_element (ENABLE_NODE, &debug_isis_spfevents_cmd);
2342 install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd);
2343 install_element (ENABLE_NODE, &debug_isis_spfstats_cmd);
2344 install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd);
2345 install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd);
2346 install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd);
2347 install_element (ENABLE_NODE, &debug_isis_rtevents_cmd);
2348 install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd);
2349 install_element (ENABLE_NODE, &debug_isis_events_cmd);
2350 install_element (ENABLE_NODE, &no_debug_isis_events_cmd);
2351 install_element (ENABLE_NODE, &debug_isis_packet_dump_cmd);
2352 install_element (ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
2353 install_element (ENABLE_NODE, &debug_isis_lsp_gen_cmd);
2354 install_element (ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
2355 install_element (ENABLE_NODE, &debug_isis_lsp_sched_cmd);
2356 install_element (ENABLE_NODE, &no_debug_isis_lsp_sched_cmd);
2358 install_element (CONFIG_NODE, &debug_isis_adj_cmd);
2359 install_element (CONFIG_NODE, &no_debug_isis_adj_cmd);
2360 install_element (CONFIG_NODE, &debug_isis_csum_cmd);
2361 install_element (CONFIG_NODE, &no_debug_isis_csum_cmd);
2362 install_element (CONFIG_NODE, &debug_isis_lupd_cmd);
2363 install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd);
2364 install_element (CONFIG_NODE, &debug_isis_err_cmd);
2365 install_element (CONFIG_NODE, &no_debug_isis_err_cmd);
2366 install_element (CONFIG_NODE, &debug_isis_snp_cmd);
2367 install_element (CONFIG_NODE, &no_debug_isis_snp_cmd);
2368 install_element (CONFIG_NODE, &debug_isis_upd_cmd);
2369 install_element (CONFIG_NODE, &no_debug_isis_upd_cmd);
2370 install_element (CONFIG_NODE, &debug_isis_spfevents_cmd);
2371 install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd);
2372 install_element (CONFIG_NODE, &debug_isis_spfstats_cmd);
2373 install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd);
2374 install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd);
2375 install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd);
2376 install_element (CONFIG_NODE, &debug_isis_rtevents_cmd);
2377 install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd);
2378 install_element (CONFIG_NODE, &debug_isis_events_cmd);
2379 install_element (CONFIG_NODE, &no_debug_isis_events_cmd);
2380 install_element (CONFIG_NODE, &debug_isis_packet_dump_cmd);
2381 install_element (CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
2382 install_element (CONFIG_NODE, &debug_isis_lsp_gen_cmd);
2383 install_element (CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
2384 install_element (CONFIG_NODE, &debug_isis_lsp_sched_cmd);
2385 install_element (CONFIG_NODE, &no_debug_isis_lsp_sched_cmd);
2387 install_element (CONFIG_NODE, &router_isis_cmd);
2388 install_element (CONFIG_NODE, &no_router_isis_cmd);
2390 install_default (ISIS_NODE);
2392 install_element (ISIS_NODE, &net_cmd);
2393 install_element (ISIS_NODE, &no_net_cmd);
2395 install_element (ISIS_NODE, &log_adj_changes_cmd);
2396 install_element (ISIS_NODE, &no_log_adj_changes_cmd);
2398 #ifdef TOPOLOGY_GENERATE
2399 install_element (ISIS_NODE, &topology_generate_grid_cmd);
2400 install_element (ISIS_NODE, &topology_baseis_cmd);
2401 install_element (ISIS_NODE, &topology_basedynh_cmd);
2402 install_element (ISIS_NODE, &no_topology_baseis_cmd);
2403 install_element (ISIS_NODE, &no_topology_baseis_noid_cmd);
2404 install_element (VIEW_NODE, &show_isis_generated_topology_cmd);
2405 #endif /* TOPOLOGY_GENERATE */