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