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