]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isisd.c
frr: Remove HAVE_IPV6 from code base
[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
248 /* invalidate and validate would delete all routes from zebra */
249 isis_route_invalidate (area);
250 isis_route_validate (area);
251
252 if (area->route_table[0])
253 {
254 route_table_finish (area->route_table[0]);
255 area->route_table[0] = NULL;
256 }
257 if (area->route_table[1])
258 {
259 route_table_finish (area->route_table[1]);
260 area->route_table[1] = NULL;
261 }
3f045a08
JB
262 if (area->route_table6[0])
263 {
264 route_table_finish (area->route_table6[0]);
265 area->route_table6[0] = NULL;
266 }
267 if (area->route_table6[1])
268 {
269 route_table_finish (area->route_table6[1]);
270 area->route_table6[1] = NULL;
271 }
3f045a08 272
f3ccedaa
CF
273 isis_redist_area_finish(area);
274
3f045a08
JB
275 for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addr))
276 {
277 list_delete_node (area->area_addrs, node);
278 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
279 }
280 area->area_addrs = NULL;
281
f390d2c7 282 THREAD_TIMER_OFF (area->t_tick);
f390d2c7 283 THREAD_TIMER_OFF (area->t_lsp_refresh[0]);
284 THREAD_TIMER_OFF (area->t_lsp_refresh[1]);
eb5d44eb 285
3f045a08
JB
286 thread_cancel_event (master, area);
287
288 listnode_delete (isis->area_list, area);
289
290 free (area->area_tag);
291
eb5d44eb 292 XFREE (MTYPE_ISIS_AREA, area);
f390d2c7 293
3f045a08
JB
294 if (listcount (isis->area_list) == 0)
295 {
296 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
297 isis->sysid_set = 0;
298 }
299
eb5d44eb 300 return CMD_SUCCESS;
301}
302
f390d2c7 303int
3f045a08 304area_net_title (struct vty *vty, const char *net_title)
eb5d44eb 305{
8ff5a399 306 VTY_DECLVAR_CONTEXT (isis_area, area);
eb5d44eb 307 struct area_addr *addr;
308 struct area_addr *addrp;
3fdb2dd9 309 struct listnode *node;
eb5d44eb 310
311 u_char buff[255];
eb5d44eb 312
eb5d44eb 313 /* We check that we are not over the maximal number of addresses */
f390d2c7 314 if (listcount (area->area_addrs) >= isis->max_area_addrs)
315 {
316 vty_out (vty, "Maximum of area addresses (%d) already reached %s",
317 isis->max_area_addrs, VTY_NEWLINE);
3f045a08 318 return CMD_ERR_NOTHING_TODO;
f390d2c7 319 }
eb5d44eb 320
321 addr = XMALLOC (MTYPE_ISIS_AREA_ADDR, sizeof (struct area_addr));
322 addr->addr_len = dotformat2buff (buff, net_title);
323 memcpy (addr->area_addr, buff, addr->addr_len);
324#ifdef EXTREME_DEBUG
529d65b3 325 zlog_debug ("added area address %s for area %s (address length %d)",
eb5d44eb 326 net_title, area->area_tag, addr->addr_len);
327#endif /* EXTREME_DEBUG */
f390d2c7 328 if (addr->addr_len < 8 || addr->addr_len > 20)
329 {
3f045a08
JB
330 vty_out (vty, "area address must be at least 8..20 octets long (%d)%s",
331 addr->addr_len, VTY_NEWLINE);
332 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
333 return CMD_ERR_AMBIGUOUS;
334 }
335
336 if (addr->area_addr[addr->addr_len-1] != 0)
337 {
338 vty_out (vty, "nsel byte (last byte) in area address must be 0%s",
339 VTY_NEWLINE);
eb5d44eb 340 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
3f045a08 341 return CMD_ERR_AMBIGUOUS;
eb5d44eb 342 }
343
f390d2c7 344 if (isis->sysid_set == 0)
345 {
346 /*
347 * First area address - get the SystemID for this router
348 */
3f045a08 349 memcpy (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN);
f390d2c7 350 isis->sysid_set = 1;
c89c05dd 351 if (isis->debugs & DEBUG_EVENTS)
352 zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid));
eb5d44eb 353 }
f390d2c7 354 else
355 {
356 /*
357 * Check that the SystemID portions match
358 */
3f045a08 359 if (memcmp (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN))
f390d2c7 360 {
361 vty_out (vty,
362 "System ID must not change when defining additional area"
363 " addresses%s", VTY_NEWLINE);
364 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
3f045a08 365 return CMD_ERR_AMBIGUOUS;
f390d2c7 366 }
eb5d44eb 367
f390d2c7 368 /* now we see that we don't already have this address */
3fdb2dd9 369 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
370 {
3f045a08 371 if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != (addr->addr_len))
3fdb2dd9 372 continue;
373 if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
374 {
375 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
376 return CMD_SUCCESS; /* silent fail */
377 }
378 }
f390d2c7 379 }
3f045a08 380
eb5d44eb 381 /*
382 * Forget the systemID part of the address
383 */
3f045a08 384 addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
eb5d44eb 385 listnode_add (area->area_addrs, addr);
386
387 /* only now we can safely generate our LSPs for this area */
f390d2c7 388 if (listcount (area->area_addrs) > 0)
389 {
3f045a08
JB
390 if (area->is_type & IS_LEVEL_1)
391 lsp_generate (area, IS_LEVEL_1);
392 if (area->is_type & IS_LEVEL_2)
393 lsp_generate (area, IS_LEVEL_2);
f390d2c7 394 }
eb5d44eb 395
396 return CMD_SUCCESS;
397}
398
399int
3f045a08 400area_clear_net_title (struct vty *vty, const char *net_title)
eb5d44eb 401{
8ff5a399 402 VTY_DECLVAR_CONTEXT (isis_area, area);
f390d2c7 403 struct area_addr addr, *addrp = NULL;
3fdb2dd9 404 struct listnode *node;
eb5d44eb 405 u_char buff[255];
406
eb5d44eb 407 addr.addr_len = dotformat2buff (buff, net_title);
f390d2c7 408 if (addr.addr_len < 8 || addr.addr_len > 20)
409 {
410 vty_out (vty, "Unsupported area address length %d, should be 8...20 %s",
411 addr.addr_len, VTY_NEWLINE);
3f045a08 412 return CMD_ERR_AMBIGUOUS;
f390d2c7 413 }
414
415 memcpy (addr.area_addr, buff, (int) addr.addr_len);
416
3fdb2dd9 417 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
3f045a08 418 if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len &&
eb5d44eb 419 !memcmp (addrp->area_addr, addr.area_addr, addr.addr_len))
f390d2c7 420 break;
421
422 if (!addrp)
423 {
424 vty_out (vty, "No area address %s for area %s %s", net_title,
425 area->area_tag, VTY_NEWLINE);
3f045a08 426 return CMD_ERR_NO_MATCH;
f390d2c7 427 }
428
eb5d44eb 429 listnode_delete (area->area_addrs, addrp);
3f045a08
JB
430 XFREE (MTYPE_ISIS_AREA_ADDR, addrp);
431
432 /*
433 * Last area address - reset the SystemID for this router
434 */
435 if (listcount (area->area_addrs) == 0)
436 {
437 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
438 isis->sysid_set = 0;
439 if (isis->debugs & DEBUG_EVENTS)
440 zlog_debug ("Router has no SystemID");
441 }
f390d2c7 442
eb5d44eb 443 return CMD_SUCCESS;
444}
445
eb5d44eb 446/*
3f045a08 447 * 'show isis interface' command
eb5d44eb 448 */
449
450int
3f045a08 451show_isis_interface_common (struct vty *vty, const char *ifname, char detail)
eb5d44eb 452{
3fdb2dd9 453 struct listnode *anode, *cnode;
eb5d44eb 454 struct isis_area *area;
455 struct isis_circuit *circuit;
eb5d44eb 456
f390d2c7 457 if (!isis)
458 {
459 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
460 return CMD_SUCCESS;
461 }
eb5d44eb 462
3fdb2dd9 463 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
f390d2c7 464 {
f390d2c7 465 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
466
467 if (detail == ISIS_UI_LEVEL_BRIEF)
3f045a08
JB
468 vty_out (vty, " Interface CircId State Type Level%s",
469 VTY_NEWLINE);
f390d2c7 470
3fdb2dd9 471 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
3f045a08
JB
472 if (!ifname)
473 isis_circuit_print_vty (circuit, vty, detail);
474 else if (strcmp(circuit->interface->name, ifname) == 0)
475 isis_circuit_print_vty (circuit, vty, detail);
eb5d44eb 476 }
f390d2c7 477
eb5d44eb 478 return CMD_SUCCESS;
479}
480
3f045a08
JB
481DEFUN (show_isis_interface,
482 show_isis_interface_cmd,
483 "show isis interface",
eb5d44eb 484 SHOW_STR
3f045a08
JB
485 "ISIS network information\n"
486 "ISIS interface\n")
eb5d44eb 487{
3f045a08 488 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
eb5d44eb 489}
490
3f045a08
JB
491DEFUN (show_isis_interface_detail,
492 show_isis_interface_detail_cmd,
493 "show isis interface detail",
eb5d44eb 494 SHOW_STR
3f045a08
JB
495 "ISIS network information\n"
496 "ISIS interface\n"
497 "show detailed information\n")
498{
499 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
500}
eb5d44eb 501
3f045a08
JB
502DEFUN (show_isis_interface_arg,
503 show_isis_interface_arg_cmd,
504 "show isis interface WORD",
eb5d44eb 505 SHOW_STR
3f045a08
JB
506 "ISIS network information\n"
507 "ISIS interface\n"
508 "ISIS interface name\n")
509{
ba4c5c83
DW
510 int idx_word = 3;
511 return show_isis_interface_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
3f045a08
JB
512}
513
514/*
515 * 'show isis neighbor' command
516 */
517
518int
519show_isis_neighbor_common (struct vty *vty, const char *id, char detail)
520{
521 struct listnode *anode, *cnode, *node;
522 struct isis_area *area;
523 struct isis_circuit *circuit;
524 struct list *adjdb;
525 struct isis_adjacency *adj;
526 struct isis_dynhn *dynhn;
527 u_char sysid[ISIS_SYS_ID_LEN];
528 int i;
529
530 if (!isis)
531 {
532 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
533 return CMD_SUCCESS;
534 }
535
536 memset (sysid, 0, ISIS_SYS_ID_LEN);
537 if (id)
538 {
539 if (sysid2buff (sysid, id) == 0)
540 {
541 dynhn = dynhn_find_by_name (id);
542 if (dynhn == NULL)
543 {
544 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
545 return CMD_SUCCESS;
546 }
547 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
548 }
549 }
550
551 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
552 {
553 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
554
555 if (detail == ISIS_UI_LEVEL_BRIEF)
556 vty_out (vty, " System Id Interface L State"
557 " Holdtime SNPA%s", VTY_NEWLINE);
558
559 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
560 {
561 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
562 {
563 for (i = 0; i < 2; i++)
564 {
565 adjdb = circuit->u.bc.adjdb[i];
566 if (adjdb && adjdb->count)
567 {
568 for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
569 if (!id || !memcmp (adj->sysid, sysid,
570 ISIS_SYS_ID_LEN))
571 isis_adj_print_vty (adj, vty, detail);
572 }
573 }
574 }
575 else if (circuit->circ_type == CIRCUIT_T_P2P &&
576 circuit->u.p2p.neighbor)
577 {
578 adj = circuit->u.p2p.neighbor;
579 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
580 isis_adj_print_vty (adj, vty, detail);
581 }
582 }
583 }
584
585 return CMD_SUCCESS;
586}
587
588/*
589 * 'clear isis neighbor' command
590 */
591int
592clear_isis_neighbor_common (struct vty *vty, const char *id)
593{
594 struct listnode *anode, *cnode, *cnextnode, *node, *nnode;
595 struct isis_area *area;
596 struct isis_circuit *circuit;
597 struct list *adjdb;
598 struct isis_adjacency *adj;
599 struct isis_dynhn *dynhn;
600 u_char sysid[ISIS_SYS_ID_LEN];
601 int i;
602
603 if (!isis)
604 {
605 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
606 return CMD_SUCCESS;
607 }
608
609 memset (sysid, 0, ISIS_SYS_ID_LEN);
610 if (id)
611 {
612 if (sysid2buff (sysid, id) == 0)
613 {
614 dynhn = dynhn_find_by_name (id);
615 if (dynhn == NULL)
616 {
617 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
618 return CMD_SUCCESS;
619 }
620 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
621 }
622 }
623
624 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
625 {
626 for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnextnode, circuit))
627 {
628 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
629 {
630 for (i = 0; i < 2; i++)
631 {
632 adjdb = circuit->u.bc.adjdb[i];
633 if (adjdb && adjdb->count)
634 {
635 for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj))
636 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
637 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
638 "clear user request");
639 }
640 }
641 }
642 else if (circuit->circ_type == CIRCUIT_T_P2P &&
643 circuit->u.p2p.neighbor)
644 {
645 adj = circuit->u.p2p.neighbor;
646 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
647 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
648 "clear user request");
649 }
650 }
651 }
652
653 return CMD_SUCCESS;
654}
655
656DEFUN (show_isis_neighbor,
657 show_isis_neighbor_cmd,
658 "show isis neighbor",
659 SHOW_STR
660 "ISIS network information\n"
661 "ISIS neighbor adjacencies\n")
eb5d44eb 662{
3f045a08 663 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
eb5d44eb 664}
665
3f045a08
JB
666DEFUN (show_isis_neighbor_detail,
667 show_isis_neighbor_detail_cmd,
668 "show isis neighbor detail",
eb5d44eb 669 SHOW_STR
3f045a08
JB
670 "ISIS network information\n"
671 "ISIS neighbor adjacencies\n"
eb5d44eb 672 "show detailed information\n")
3f045a08
JB
673{
674 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
675}
676
677DEFUN (show_isis_neighbor_arg,
678 show_isis_neighbor_arg_cmd,
679 "show isis neighbor WORD",
680 SHOW_STR
681 "ISIS network information\n"
682 "ISIS neighbor adjacencies\n"
683 "System id\n")
684{
ba4c5c83
DW
685 int idx_word = 3;
686 return show_isis_neighbor_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
3f045a08
JB
687}
688
689DEFUN (clear_isis_neighbor,
690 clear_isis_neighbor_cmd,
691 "clear isis neighbor",
692 CLEAR_STR
693 "Reset ISIS network information\n"
694 "Reset ISIS neighbor adjacencies\n")
695{
696 return clear_isis_neighbor_common (vty, NULL);
697}
698
699DEFUN (clear_isis_neighbor_arg,
700 clear_isis_neighbor_arg_cmd,
e38e0df0 701 "clear isis neighbor WORD",
3f045a08
JB
702 CLEAR_STR
703 "ISIS network information\n"
704 "ISIS neighbor adjacencies\n"
705 "System id\n")
706{
ba4c5c83
DW
707 int idx_word = 3;
708 return clear_isis_neighbor_common (vty, argv[idx_word]->arg);
3f045a08
JB
709}
710
eb5d44eb 711/*
712 * 'isis debug', 'show debugging'
713 */
eb5d44eb 714void
715print_debug (struct vty *vty, int flags, int onoff)
716{
717 char onoffs[4];
718 if (onoff)
f390d2c7 719 strcpy (onoffs, "on");
eb5d44eb 720 else
f390d2c7 721 strcpy (onoffs, "off");
eb5d44eb 722
723 if (flags & DEBUG_ADJ_PACKETS)
f390d2c7 724 vty_out (vty, "IS-IS Adjacency related packets debugging is %s%s", onoffs,
725 VTY_NEWLINE);
eb5d44eb 726 if (flags & DEBUG_CHECKSUM_ERRORS)
f390d2c7 727 vty_out (vty, "IS-IS checksum errors debugging is %s%s", onoffs,
728 VTY_NEWLINE);
eb5d44eb 729 if (flags & DEBUG_LOCAL_UPDATES)
f390d2c7 730 vty_out (vty, "IS-IS local updates debugging is %s%s", onoffs,
731 VTY_NEWLINE);
eb5d44eb 732 if (flags & DEBUG_PROTOCOL_ERRORS)
f390d2c7 733 vty_out (vty, "IS-IS protocol errors debugging is %s%s", onoffs,
734 VTY_NEWLINE);
eb5d44eb 735 if (flags & DEBUG_SNP_PACKETS)
f390d2c7 736 vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s%s", onoffs,
737 VTY_NEWLINE);
eb5d44eb 738 if (flags & DEBUG_SPF_EVENTS)
f390d2c7 739 vty_out (vty, "IS-IS SPF events debugging is %s%s", onoffs, VTY_NEWLINE);
eb5d44eb 740 if (flags & DEBUG_SPF_STATS)
f390d2c7 741 vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s%s",
742 onoffs, VTY_NEWLINE);
eb5d44eb 743 if (flags & DEBUG_SPF_TRIGGERS)
f390d2c7 744 vty_out (vty, "IS-IS SPF triggering events debugging is %s%s", onoffs,
745 VTY_NEWLINE);
eb5d44eb 746 if (flags & DEBUG_UPDATE_PACKETS)
f390d2c7 747 vty_out (vty, "IS-IS Update related packet debugging is %s%s", onoffs,
748 VTY_NEWLINE);
eb5d44eb 749 if (flags & DEBUG_RTE_EVENTS)
f390d2c7 750 vty_out (vty, "IS-IS Route related debuggin is %s%s", onoffs,
751 VTY_NEWLINE);
eb5d44eb 752 if (flags & DEBUG_EVENTS)
f390d2c7 753 vty_out (vty, "IS-IS Event debugging is %s%s", onoffs, VTY_NEWLINE);
3f045a08
JB
754 if (flags & DEBUG_PACKET_DUMP)
755 vty_out (vty, "IS-IS Packet dump debugging is %s%s", onoffs, VTY_NEWLINE);
14872644
CF
756 if (flags & DEBUG_LSP_GEN)
757 vty_out (vty, "IS-IS LSP generation debugging is %s%s", onoffs, VTY_NEWLINE);
414766a1
CF
758 if (flags & DEBUG_LSP_SCHED)
759 vty_out (vty, "IS-IS LSP scheduling debugging is %s%s", onoffs, VTY_NEWLINE);
eb5d44eb 760}
761
762DEFUN (show_debugging,
f8c06e2c 763 show_debugging_isis_cmd,
16286195 764 "show debugging isis",
eb5d44eb 765 SHOW_STR
16286195
DS
766 "State of each debugging option\n"
767 ISIS_STR)
eb5d44eb 768{
f8c06e2c
OD
769 if (isis->debugs) {
770 vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
771 print_debug (vty, isis->debugs, 1);
772 }
eb5d44eb 773 return CMD_SUCCESS;
774}
775
9e867fe6 776/* Debug node. */
f390d2c7 777static struct cmd_node debug_node = {
9e867fe6 778 DEBUG_NODE,
f390d2c7 779 "",
780 1
9e867fe6 781};
782
783static int
784config_write_debug (struct vty *vty)
785{
786 int write = 0;
787 int flags = isis->debugs;
788
f390d2c7 789 if (flags & DEBUG_ADJ_PACKETS)
790 {
791 vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
792 write++;
793 }
794 if (flags & DEBUG_CHECKSUM_ERRORS)
795 {
796 vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
797 write++;
798 }
799 if (flags & DEBUG_LOCAL_UPDATES)
800 {
801 vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
802 write++;
803 }
804 if (flags & DEBUG_PROTOCOL_ERRORS)
805 {
806 vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
807 write++;
808 }
809 if (flags & DEBUG_SNP_PACKETS)
810 {
811 vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
812 write++;
813 }
814 if (flags & DEBUG_SPF_EVENTS)
815 {
816 vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
817 write++;
818 }
819 if (flags & DEBUG_SPF_STATS)
820 {
821 vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
822 write++;
823 }
824 if (flags & DEBUG_SPF_TRIGGERS)
825 {
826 vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
827 write++;
828 }
829 if (flags & DEBUG_UPDATE_PACKETS)
830 {
831 vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
832 write++;
833 }
834 if (flags & DEBUG_RTE_EVENTS)
835 {
836 vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
837 write++;
838 }
839 if (flags & DEBUG_EVENTS)
840 {
841 vty_out (vty, "debug isis events%s", VTY_NEWLINE);
842 write++;
843 }
3f045a08
JB
844 if (flags & DEBUG_PACKET_DUMP)
845 {
846 vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE);
847 write++;
848 }
14872644
CF
849 if (flags & DEBUG_LSP_GEN)
850 {
851 vty_out (vty, "debug isis lsp-gen%s", VTY_NEWLINE);
852 write++;
853 }
414766a1
CF
854 if (flags & DEBUG_LSP_SCHED)
855 {
856 vty_out (vty, "debug isis lsp-sched%s", VTY_NEWLINE);
857 write++;
858 }
9e867fe6 859
860 return write;
861}
862
eb5d44eb 863DEFUN (debug_isis_adj,
864 debug_isis_adj_cmd,
865 "debug isis adj-packets",
866 DEBUG_STR
867 "IS-IS information\n"
f390d2c7 868 "IS-IS Adjacency related packets\n")
eb5d44eb 869{
870 isis->debugs |= DEBUG_ADJ_PACKETS;
f390d2c7 871 print_debug (vty, DEBUG_ADJ_PACKETS, 1);
eb5d44eb 872
873 return CMD_SUCCESS;
874}
875
876DEFUN (no_debug_isis_adj,
877 no_debug_isis_adj_cmd,
878 "no debug isis adj-packets",
16cedbb0 879 NO_STR
eb5d44eb 880 UNDEBUG_STR
881 "IS-IS information\n"
f390d2c7 882 "IS-IS Adjacency related packets\n")
eb5d44eb 883{
eb5d44eb 884 isis->debugs &= ~DEBUG_ADJ_PACKETS;
885 print_debug (vty, DEBUG_ADJ_PACKETS, 0);
886
887 return CMD_SUCCESS;
888}
889
eb5d44eb 890DEFUN (debug_isis_csum,
891 debug_isis_csum_cmd,
892 "debug isis checksum-errors",
893 DEBUG_STR
894 "IS-IS information\n"
f390d2c7 895 "IS-IS LSP checksum errors\n")
eb5d44eb 896{
897 isis->debugs |= DEBUG_CHECKSUM_ERRORS;
898 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1);
899
900 return CMD_SUCCESS;
901}
902
903DEFUN (no_debug_isis_csum,
904 no_debug_isis_csum_cmd,
905 "no debug isis checksum-errors",
16cedbb0 906 NO_STR
eb5d44eb 907 UNDEBUG_STR
908 "IS-IS information\n"
f390d2c7 909 "IS-IS LSP checksum errors\n")
eb5d44eb 910{
911 isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
912 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
f390d2c7 913
eb5d44eb 914 return CMD_SUCCESS;
915}
916
917DEFUN (debug_isis_lupd,
918 debug_isis_lupd_cmd,
919 "debug isis local-updates",
920 DEBUG_STR
921 "IS-IS information\n"
f390d2c7 922 "IS-IS local update packets\n")
eb5d44eb 923{
924 isis->debugs |= DEBUG_LOCAL_UPDATES;
925 print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
926
927 return CMD_SUCCESS;
928}
929
930DEFUN (no_debug_isis_lupd,
931 no_debug_isis_lupd_cmd,
932 "no debug isis local-updates",
16cedbb0 933 NO_STR
eb5d44eb 934 UNDEBUG_STR
935 "IS-IS information\n"
f390d2c7 936 "IS-IS local update packets\n")
eb5d44eb 937{
938 isis->debugs &= ~DEBUG_LOCAL_UPDATES;
f390d2c7 939 print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
940
eb5d44eb 941 return CMD_SUCCESS;
942}
943
944DEFUN (debug_isis_err,
945 debug_isis_err_cmd,
f390d2c7 946 "debug isis protocol-errors",
eb5d44eb 947 DEBUG_STR
948 "IS-IS information\n"
f390d2c7 949 "IS-IS LSP protocol errors\n")
eb5d44eb 950{
951 isis->debugs |= DEBUG_PROTOCOL_ERRORS;
952 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1);
953
954 return CMD_SUCCESS;
955}
956
957DEFUN (no_debug_isis_err,
958 no_debug_isis_err_cmd,
959 "no debug isis protocol-errors",
16cedbb0 960 NO_STR
eb5d44eb 961 UNDEBUG_STR
962 "IS-IS information\n"
f390d2c7 963 "IS-IS LSP protocol errors\n")
eb5d44eb 964{
965 isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
966 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
f390d2c7 967
eb5d44eb 968 return CMD_SUCCESS;
969}
970
971DEFUN (debug_isis_snp,
972 debug_isis_snp_cmd,
973 "debug isis snp-packets",
974 DEBUG_STR
975 "IS-IS information\n"
f390d2c7 976 "IS-IS CSNP/PSNP packets\n")
eb5d44eb 977{
978 isis->debugs |= DEBUG_SNP_PACKETS;
979 print_debug (vty, DEBUG_SNP_PACKETS, 1);
980
981 return CMD_SUCCESS;
982}
983
984DEFUN (no_debug_isis_snp,
985 no_debug_isis_snp_cmd,
986 "no debug isis snp-packets",
16cedbb0 987 NO_STR
eb5d44eb 988 UNDEBUG_STR
989 "IS-IS information\n"
f390d2c7 990 "IS-IS CSNP/PSNP packets\n")
eb5d44eb 991{
f390d2c7 992 isis->debugs &= ~DEBUG_SNP_PACKETS;
eb5d44eb 993 print_debug (vty, DEBUG_SNP_PACKETS, 0);
f390d2c7 994
eb5d44eb 995 return CMD_SUCCESS;
996}
997
eb5d44eb 998DEFUN (debug_isis_upd,
999 debug_isis_upd_cmd,
1000 "debug isis update-packets",
1001 DEBUG_STR
1002 "IS-IS information\n"
f390d2c7 1003 "IS-IS Update related packets\n")
eb5d44eb 1004{
1005 isis->debugs |= DEBUG_UPDATE_PACKETS;
1006 print_debug (vty, DEBUG_UPDATE_PACKETS, 1);
1007
1008 return CMD_SUCCESS;
1009}
1010
1011DEFUN (no_debug_isis_upd,
1012 no_debug_isis_upd_cmd,
1013 "no debug isis update-packets",
16cedbb0 1014 NO_STR
eb5d44eb 1015 UNDEBUG_STR
1016 "IS-IS information\n"
f390d2c7 1017 "IS-IS Update related packets\n")
eb5d44eb 1018{
1019 isis->debugs &= ~DEBUG_UPDATE_PACKETS;
1020 print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
f390d2c7 1021
eb5d44eb 1022 return CMD_SUCCESS;
1023}
1024
eb5d44eb 1025DEFUN (debug_isis_spfevents,
1026 debug_isis_spfevents_cmd,
1027 "debug isis spf-events",
1028 DEBUG_STR
1029 "IS-IS information\n"
f390d2c7 1030 "IS-IS Shortest Path First Events\n")
eb5d44eb 1031{
1032 isis->debugs |= DEBUG_SPF_EVENTS;
f390d2c7 1033 print_debug (vty, DEBUG_SPF_EVENTS, 1);
eb5d44eb 1034
1035 return CMD_SUCCESS;
1036}
1037
1038DEFUN (no_debug_isis_spfevents,
1039 no_debug_isis_spfevents_cmd,
1040 "no debug isis spf-events",
16cedbb0 1041 NO_STR
eb5d44eb 1042 UNDEBUG_STR
1043 "IS-IS information\n"
f390d2c7 1044 "IS-IS Shortest Path First Events\n")
eb5d44eb 1045{
1046 isis->debugs &= ~DEBUG_SPF_EVENTS;
f390d2c7 1047 print_debug (vty, DEBUG_SPF_EVENTS, 0);
1048
eb5d44eb 1049 return CMD_SUCCESS;
1050}
1051
eb5d44eb 1052DEFUN (debug_isis_spfstats,
1053 debug_isis_spfstats_cmd,
1054 "debug isis spf-statistics ",
1055 DEBUG_STR
1056 "IS-IS information\n"
f390d2c7 1057 "IS-IS SPF Timing and Statistic Data\n")
eb5d44eb 1058{
1059 isis->debugs |= DEBUG_SPF_STATS;
1060 print_debug (vty, DEBUG_SPF_STATS, 1);
1061
1062 return CMD_SUCCESS;
1063}
1064
1065DEFUN (no_debug_isis_spfstats,
1066 no_debug_isis_spfstats_cmd,
1067 "no debug isis spf-statistics",
16cedbb0 1068 NO_STR
eb5d44eb 1069 UNDEBUG_STR
1070 "IS-IS information\n"
f390d2c7 1071 "IS-IS SPF Timing and Statistic Data\n")
eb5d44eb 1072{
1073 isis->debugs &= ~DEBUG_SPF_STATS;
1074 print_debug (vty, DEBUG_SPF_STATS, 0);
f390d2c7 1075
eb5d44eb 1076 return CMD_SUCCESS;
1077}
1078
1079DEFUN (debug_isis_spftrigg,
1080 debug_isis_spftrigg_cmd,
1081 "debug isis spf-triggers",
1082 DEBUG_STR
1083 "IS-IS information\n"
f390d2c7 1084 "IS-IS SPF triggering events\n")
eb5d44eb 1085{
1086 isis->debugs |= DEBUG_SPF_TRIGGERS;
1087 print_debug (vty, DEBUG_SPF_TRIGGERS, 1);
1088
1089 return CMD_SUCCESS;
1090}
1091
1092DEFUN (no_debug_isis_spftrigg,
1093 no_debug_isis_spftrigg_cmd,
1094 "no debug isis spf-triggers",
16cedbb0 1095 NO_STR
eb5d44eb 1096 UNDEBUG_STR
1097 "IS-IS information\n"
f390d2c7 1098 "IS-IS SPF triggering events\n")
eb5d44eb 1099{
1100 isis->debugs &= ~DEBUG_SPF_TRIGGERS;
1101 print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
f390d2c7 1102
eb5d44eb 1103 return CMD_SUCCESS;
1104}
1105
1106DEFUN (debug_isis_rtevents,
1107 debug_isis_rtevents_cmd,
1108 "debug isis route-events",
1109 DEBUG_STR
1110 "IS-IS information\n"
f390d2c7 1111 "IS-IS Route related events\n")
eb5d44eb 1112{
1113 isis->debugs |= DEBUG_RTE_EVENTS;
1114 print_debug (vty, DEBUG_RTE_EVENTS, 1);
1115
1116 return CMD_SUCCESS;
1117}
1118
1119DEFUN (no_debug_isis_rtevents,
1120 no_debug_isis_rtevents_cmd,
1121 "no debug isis route-events",
16cedbb0 1122 NO_STR
eb5d44eb 1123 UNDEBUG_STR
1124 "IS-IS information\n"
f390d2c7 1125 "IS-IS Route related events\n")
eb5d44eb 1126{
1127 isis->debugs &= ~DEBUG_RTE_EVENTS;
1128 print_debug (vty, DEBUG_RTE_EVENTS, 0);
f390d2c7 1129
eb5d44eb 1130 return CMD_SUCCESS;
1131}
1132
1133DEFUN (debug_isis_events,
1134 debug_isis_events_cmd,
1135 "debug isis events",
1136 DEBUG_STR
1137 "IS-IS information\n"
f1082d19 1138 "IS-IS Events\n")
eb5d44eb 1139{
1140 isis->debugs |= DEBUG_EVENTS;
1141 print_debug (vty, DEBUG_EVENTS, 1);
1142
1143 return CMD_SUCCESS;
1144}
1145
1146DEFUN (no_debug_isis_events,
1147 no_debug_isis_events_cmd,
1148 "no debug isis events",
16cedbb0 1149 NO_STR
eb5d44eb 1150 UNDEBUG_STR
1151 "IS-IS information\n"
f390d2c7 1152 "IS-IS Events\n")
eb5d44eb 1153{
1154 isis->debugs &= ~DEBUG_EVENTS;
1155 print_debug (vty, DEBUG_EVENTS, 0);
f390d2c7 1156
eb5d44eb 1157 return CMD_SUCCESS;
1158}
1159
3f045a08
JB
1160DEFUN (debug_isis_packet_dump,
1161 debug_isis_packet_dump_cmd,
1162 "debug isis packet-dump",
1163 DEBUG_STR
1164 "IS-IS information\n"
1165 "IS-IS packet dump\n")
1166{
1167 isis->debugs |= DEBUG_PACKET_DUMP;
1168 print_debug (vty, DEBUG_PACKET_DUMP, 1);
1169
1170 return CMD_SUCCESS;
1171}
1172
1173DEFUN (no_debug_isis_packet_dump,
1174 no_debug_isis_packet_dump_cmd,
1175 "no debug isis packet-dump",
16cedbb0 1176 NO_STR
3f045a08
JB
1177 UNDEBUG_STR
1178 "IS-IS information\n"
1179 "IS-IS packet dump\n")
1180{
1181 isis->debugs &= ~DEBUG_PACKET_DUMP;
1182 print_debug (vty, DEBUG_PACKET_DUMP, 0);
1183
1184 return CMD_SUCCESS;
1185}
1186
14872644
CF
1187DEFUN (debug_isis_lsp_gen,
1188 debug_isis_lsp_gen_cmd,
1189 "debug isis lsp-gen",
1190 DEBUG_STR
1191 "IS-IS information\n"
1192 "IS-IS generation of own LSPs\n")
1193{
1194 isis->debugs |= DEBUG_LSP_GEN;
1195 print_debug (vty, DEBUG_LSP_GEN, 1);
1196
1197 return CMD_SUCCESS;
1198}
1199
1200DEFUN (no_debug_isis_lsp_gen,
1201 no_debug_isis_lsp_gen_cmd,
1202 "no debug isis lsp-gen",
16cedbb0 1203 NO_STR
14872644
CF
1204 UNDEBUG_STR
1205 "IS-IS information\n"
1206 "IS-IS generation of own LSPs\n")
1207{
1208 isis->debugs &= ~DEBUG_LSP_GEN;
1209 print_debug (vty, DEBUG_LSP_GEN, 0);
1210
1211 return CMD_SUCCESS;
1212}
1213
414766a1
CF
1214DEFUN (debug_isis_lsp_sched,
1215 debug_isis_lsp_sched_cmd,
1216 "debug isis lsp-sched",
1217 DEBUG_STR
1218 "IS-IS information\n"
1219 "IS-IS scheduling of LSP generation\n")
1220{
1221 isis->debugs |= DEBUG_LSP_SCHED;
1222 print_debug (vty, DEBUG_LSP_SCHED, 1);
1223
1224 return CMD_SUCCESS;
1225}
1226
49d41a26
DS
1227DEFUN (no_debug_isis_lsp_sched,
1228 no_debug_isis_lsp_sched_cmd,
1229 "no debug isis lsp-sched",
16cedbb0 1230 NO_STR
49d41a26
DS
1231 UNDEBUG_STR
1232 "IS-IS information\n"
1233 "IS-IS scheduling of LSP generation\n")
1234{
1235 isis->debugs &= ~DEBUG_LSP_SCHED;
1236 print_debug (vty, DEBUG_LSP_SCHED, 0);
1237
1238 return CMD_SUCCESS;
1239}
1240
eb5d44eb 1241DEFUN (show_hostname,
1242 show_hostname_cmd,
1243 "show isis hostname",
1244 SHOW_STR
1245 "IS-IS information\n"
1246 "IS-IS Dynamic hostname mapping\n")
1247{
1248 dynhn_print_all (vty);
f390d2c7 1249
eb5d44eb 1250 return CMD_SUCCESS;
1251}
1252
3f045a08
JB
1253static void
1254vty_out_timestr(struct vty *vty, time_t uptime)
eb5d44eb 1255{
3f045a08
JB
1256 struct tm *tm;
1257 time_t difftime = time (NULL);
1258 difftime -= uptime;
1259 tm = gmtime (&difftime);
1260
1261#define ONE_DAY_SECOND 60*60*24
1262#define ONE_WEEK_SECOND 60*60*24*7
1263 if (difftime < ONE_DAY_SECOND)
1264 vty_out (vty, "%02d:%02d:%02d",
1265 tm->tm_hour, tm->tm_min, tm->tm_sec);
1266 else if (difftime < ONE_WEEK_SECOND)
1267 vty_out (vty, "%dd%02dh%02dm",
1268 tm->tm_yday, tm->tm_hour, tm->tm_min);
1269 else
1270 vty_out (vty, "%02dw%dd%02dh",
1271 tm->tm_yday/7,
1272 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1273 vty_out (vty, " ago");
1274}
1275
1276DEFUN (show_isis_summary,
1277 show_isis_summary_cmd,
1278 "show isis summary",
1279 SHOW_STR "IS-IS information\n" "IS-IS summary\n")
1280{
1281 struct listnode *node, *node2;
eb5d44eb 1282 struct isis_area *area;
3f045a08
JB
1283 struct isis_spftree *spftree;
1284 int level;
eb5d44eb 1285
3f045a08
JB
1286 if (isis == NULL)
1287 {
1288 vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
eb5d44eb 1289 return CMD_SUCCESS;
3f045a08
JB
1290 }
1291
1292 vty_out (vty, "Process Id : %ld%s", isis->process_id,
1293 VTY_NEWLINE);
1294 if (isis->sysid_set)
1295 vty_out (vty, "System Id : %s%s", sysid_print (isis->sysid),
1296 VTY_NEWLINE);
1297
1298 vty_out (vty, "Up time : ");
1299 vty_out_timestr(vty, isis->uptime);
1300 vty_out (vty, "%s", VTY_NEWLINE);
1301
1302 if (isis->area_list)
1303 vty_out (vty, "Number of areas : %d%s", isis->area_list->count,
1304 VTY_NEWLINE);
f390d2c7 1305
3fdb2dd9 1306 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
3f045a08
JB
1307 {
1308 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1309 VTY_NEWLINE);
1310
1311 if (listcount (area->area_addrs) > 0)
f390d2c7 1312 {
3f045a08
JB
1313 struct area_addr *area_addr;
1314 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
1315 {
1316 vty_out (vty, " Net: %s%s",
1317 isonet_print (area_addr->area_addr,
1318 area_addr->addr_len + ISIS_SYS_ID_LEN +
1319 1), VTY_NEWLINE);
1320 }
1321 }
f390d2c7 1322
3f045a08
JB
1323 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
1324 {
1325 if ((area->is_type & level) == 0)
1326 continue;
f390d2c7 1327
3f045a08
JB
1328 vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE);
1329 spftree = area->spftree[level - 1];
1330 if (spftree->pending)
1331 vty_out (vty, " IPv4 SPF: (pending)%s", VTY_NEWLINE);
1332 else
1333 vty_out (vty, " IPv4 SPF:%s", VTY_NEWLINE);
1334
1335 vty_out (vty, " minimum interval : %d%s",
1336 area->min_spf_interval[level - 1], VTY_NEWLINE);
1337
e38e0df0
SV
1338 vty_out (vty, " last run elapsed : ");
1339 vty_out_timestr(vty, spftree->last_run_timestamp);
3f045a08
JB
1340 vty_out (vty, "%s", VTY_NEWLINE);
1341
e38e0df0
SV
1342 vty_out (vty, " last run duration : %u usec%s",
1343 (u_int32_t)spftree->last_run_duration, VTY_NEWLINE);
1344
3f045a08
JB
1345 vty_out (vty, " run count : %d%s",
1346 spftree->runcount, VTY_NEWLINE);
1347
3f045a08
JB
1348 spftree = area->spftree6[level - 1];
1349 if (spftree->pending)
1350 vty_out (vty, " IPv6 SPF: (pending)%s", VTY_NEWLINE);
1351 else
1352 vty_out (vty, " IPv6 SPF:%s", VTY_NEWLINE);
1353
1354 vty_out (vty, " minimum interval : %d%s",
1355 area->min_spf_interval[level - 1], VTY_NEWLINE);
1356
e38e0df0
SV
1357 vty_out (vty, " last run elapsed : ");
1358 vty_out_timestr(vty, spftree->last_run_timestamp);
3f045a08
JB
1359 vty_out (vty, "%s", VTY_NEWLINE);
1360
8f2c16aa
DL
1361 vty_out (vty, " last run duration : %llu msec%s",
1362 (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
e38e0df0 1363
3f045a08
JB
1364 vty_out (vty, " run count : %d%s",
1365 spftree->runcount, VTY_NEWLINE);
eb5d44eb 1366 }
3f045a08
JB
1367 }
1368 vty_out (vty, "%s", VTY_NEWLINE);
eb5d44eb 1369
1370 return CMD_SUCCESS;
1371}
1372
3f045a08
JB
1373/*
1374 * This function supports following display options:
1375 * [ show isis database [detail] ]
1376 * [ show isis database <sysid> [detail] ]
1377 * [ show isis database <hostname> [detail] ]
1378 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1379 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1380 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1381 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1382 * [ show isis database detail <sysid> ]
1383 * [ show isis database detail <hostname> ]
1384 * [ show isis database detail <sysid>.<pseudo-id> ]
1385 * [ show isis database detail <hostname>.<pseudo-id> ]
1386 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1387 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1388 */
1389static int
1390show_isis_database (struct vty *vty, const char *argv, int ui_level)
eb5d44eb 1391{
3fdb2dd9 1392 struct listnode *node;
eb5d44eb 1393 struct isis_area *area;
3f045a08
JB
1394 struct isis_lsp *lsp;
1395 struct isis_dynhn *dynhn;
1396 const char *pos = argv;
1397 u_char lspid[ISIS_SYS_ID_LEN+2];
e38e0df0 1398 char sysid[255];
3f045a08 1399 u_char number[3];
eb5d44eb 1400 int level, lsp_count;
1401
1402 if (isis->area_list->count == 0)
1403 return CMD_SUCCESS;
1404
3f045a08 1405 memset (&lspid, 0, ISIS_SYS_ID_LEN);
e38e0df0 1406 memset (&sysid, 0, 255);
3f045a08
JB
1407
1408 /*
1409 * extract fragment and pseudo id from the string argv
1410 * in the forms:
1411 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1412 * (b) <systemid/hostname>.<pseudo-id> or
1413 * (c) <systemid/hostname> or
1414 * Where systemid is in the form:
1415 * xxxx.xxxx.xxxx
1416 */
e38e0df0
SV
1417 if (argv)
1418 strncpy (sysid, argv, 254);
3f045a08
JB
1419 if (argv && strlen (argv) > 3)
1420 {
1421 pos = argv + strlen (argv) - 3;
1422 if (strncmp (pos, "-", 1) == 0)
1423 {
1424 memcpy (number, ++pos, 2);
1425 lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16);
1426 pos -= 4;
1427 if (strncmp (pos, ".", 1) != 0)
1428 return CMD_ERR_AMBIGUOUS;
1429 }
1430 if (strncmp (pos, ".", 1) == 0)
1431 {
1432 memcpy (number, ++pos, 2);
1433 lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16);
1434 sysid[pos - argv - 1] = '\0';
1435 }
1436 }
1437
3fdb2dd9 1438 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
f390d2c7 1439 {
f390d2c7 1440 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
3f045a08 1441 VTY_NEWLINE);
f390d2c7 1442
3f045a08
JB
1443 for (level = 0; level < ISIS_LEVELS; level++)
1444 {
1445 if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
1446 {
1447 lsp = NULL;
1448 if (argv != NULL)
1449 {
1450 /*
1451 * Try to find the lsp-id if the argv string is in
1452 * the form hostname.<pseudo-id>-<fragment>
1453 */
1454 if (sysid2buff (lspid, sysid))
1455 {
1456 lsp = lsp_search (lspid, area->lspdb[level]);
1457 }
1458 else if ((dynhn = dynhn_find_by_name (sysid)))
1459 {
1460 memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN);
1461 lsp = lsp_search (lspid, area->lspdb[level]);
1462 }
1463 else if (strncmp(unix_hostname (), sysid, 15) == 0)
1464 {
1465 memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
1466 lsp = lsp_search (lspid, area->lspdb[level]);
1467 }
1468 }
1469
1470 if (lsp != NULL || argv == NULL)
1471 {
1472 vty_out (vty, "IS-IS Level-%d link-state database:%s",
1473 level + 1, VTY_NEWLINE);
1474
1475 /* print the title in all cases */
1476 vty_out (vty, "LSP ID PduLen "
1477 "SeqNumber Chksum Holdtime ATT/P/OL%s",
1478 VTY_NEWLINE);
1479 }
1480
1481 if (lsp)
1482 {
1483 if (ui_level == ISIS_UI_LEVEL_DETAIL)
1484 lsp_print_detail (lsp, vty, area->dynhostname);
1485 else
1486 lsp_print (lsp, vty, area->dynhostname);
1487 }
1488 else if (argv == NULL)
1489 {
1490 lsp_count = lsp_print_all (vty, area->lspdb[level],
1491 ui_level,
1492 area->dynhostname);
1493
1494 vty_out (vty, " %u LSPs%s%s",
1495 lsp_count, VTY_NEWLINE, VTY_NEWLINE);
1496 }
1497 }
1498 }
eb5d44eb 1499 }
eb5d44eb 1500
1501 return CMD_SUCCESS;
1502}
1503
3a2d747c 1504DEFUN (show_database,
3f045a08 1505 show_database_cmd,
3a2d747c 1506 "show isis database [detail] [WORD]",
3f045a08
JB
1507 SHOW_STR
1508 "IS-IS information\n"
1509 "IS-IS link state database\n"
1510 "Detailed information\n"
1511 "LSP ID\n")
1512{
3a2d747c
QY
1513 int idx = 0;
1514 int uilevel = argv_find (argv, argc, "detail", &idx) ? ISIS_UI_LEVEL_DETAIL : ISIS_UI_LEVEL_BRIEF;
1515 char *id = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
1516 return show_isis_database (vty, id, uilevel);
3f045a08
JB
1517}
1518
1519/*
1520 * 'router isis' command
1521 */
1522DEFUN (router_isis,
1523 router_isis_cmd,
1524 "router isis WORD",
1525 ROUTER_STR
1526 "ISO IS-IS\n"
1527 "ISO Routing area tag")
1528{
ba4c5c83
DW
1529 int idx_word = 2;
1530 return isis_area_get (vty, argv[idx_word]->arg);
3f045a08
JB
1531}
1532
1533/*
1534 *'no router isis' command
1535 */
1536DEFUN (no_router_isis,
1537 no_router_isis_cmd,
1538 "no router isis WORD",
f390d2c7 1539 "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
eb5d44eb 1540{
ba4c5c83
DW
1541 int idx_word = 3;
1542 return isis_area_destroy (vty, argv[idx_word]->arg);
eb5d44eb 1543}
1544
1545/*
1546 * 'net' command
1547 */
1548DEFUN (net,
1549 net_cmd,
1550 "net WORD",
1551 "A Network Entity Title for this process (OSI only)\n"
f390d2c7 1552 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
eb5d44eb 1553{
ba4c5c83
DW
1554 int idx_word = 1;
1555 return area_net_title (vty, argv[idx_word]->arg);
eb5d44eb 1556}
1557
eb5d44eb 1558/*
1559 * 'no net' command
1560 */
1561DEFUN (no_net,
1562 no_net_cmd,
1563 "no net WORD",
1564 NO_STR
1565 "A Network Entity Title for this process (OSI only)\n"
f390d2c7 1566 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
eb5d44eb 1567{
ba4c5c83
DW
1568 int idx_word = 2;
1569 return area_clear_net_title (vty, argv[idx_word]->arg);
eb5d44eb 1570}
1571
6754fc66 1572void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu)
b20ccb3a 1573{
b20ccb3a
CF
1574 area->lsp_mtu = lsp_mtu;
1575 lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
b20ccb3a
CF
1576}
1577
9093b230
CF
1578static int
1579isis_area_passwd_set(struct isis_area *area, int level, u_char passwd_type,
1580 const char *passwd, u_char snp_auth)
3f045a08 1581{
9093b230
CF
1582 struct isis_passwd *dest;
1583 struct isis_passwd modified;
3f045a08
JB
1584 int len;
1585
9093b230
CF
1586 assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2));
1587 dest = (level == IS_LEVEL_1) ? &area->area_passwd : &area->domain_passwd;
1588 memset(&modified, 0, sizeof(modified));
3f045a08 1589
9093b230 1590 if (passwd_type != ISIS_PASSWD_TYPE_UNUSED)
3f045a08 1591 {
9093b230
CF
1592 if (!passwd)
1593 return -1;
3f045a08 1594
9093b230
CF
1595 len = strlen(passwd);
1596 if (len > 254)
1597 return -1;
f390d2c7 1598
9093b230
CF
1599 modified.len = len;
1600 strncpy((char*)modified.passwd, passwd, 255);
1601 modified.type = passwd_type;
1602 modified.snp_auth = snp_auth;
f390d2c7 1603 }
3f045a08 1604
9093b230 1605 if (memcmp(&modified, dest, sizeof(modified)))
1cbc562b 1606 {
9093b230
CF
1607 memcpy(dest, &modified, sizeof(modified));
1608 lsp_regenerate_schedule(area, IS_LEVEL_1|IS_LEVEL_2, 1);
1cbc562b 1609 }
1610
9093b230 1611 return 0;
eb5d44eb 1612}
1613
9093b230
CF
1614int
1615isis_area_passwd_unset (struct isis_area *area, int level)
eb5d44eb 1616{
9093b230 1617 return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_UNUSED, NULL, 0);
3f045a08
JB
1618}
1619
9093b230
CF
1620int
1621isis_area_passwd_cleartext_set (struct isis_area *area, int level,
1622 const char *passwd, u_char snp_auth)
eb5d44eb 1623{
9093b230
CF
1624 return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_CLEARTXT,
1625 passwd, snp_auth);
eb5d44eb 1626}
1627
9093b230
CF
1628int
1629isis_area_passwd_hmac_md5_set (struct isis_area *area, int level,
1630 const char *passwd, u_char snp_auth)
eb5d44eb 1631{
9093b230
CF
1632 return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_HMAC_MD5,
1633 passwd, snp_auth);
eb5d44eb 1634}
1635
6754fc66
CF
1636static void
1637area_resign_level (struct isis_area *area, int level)
eb5d44eb 1638{
6754fc66 1639 if (area->lspdb[level - 1])
f390d2c7 1640 {
6754fc66
CF
1641 lsp_db_destroy (area->lspdb[level - 1]);
1642 area->lspdb[level - 1] = NULL;
f390d2c7 1643 }
6754fc66 1644 if (area->spftree[level - 1])
f390d2c7 1645 {
6754fc66
CF
1646 isis_spftree_del (area->spftree[level - 1]);
1647 area->spftree[level - 1] = NULL;
f390d2c7 1648 }
6754fc66
CF
1649 if (area->spftree6[level - 1])
1650 {
1651 isis_spftree_del (area->spftree6[level - 1]);
1652 area->spftree6[level - 1] = NULL;
1653 }
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}