]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isisd.c
isisd: API: basic circuit config
[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"
37
38#include "isisd/dict.h"
39#include "isisd/include-netbsd/iso.h"
40#include "isisd/isis_constants.h"
41#include "isisd/isis_common.h"
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"
57
58#ifdef TOPOLOGY_GENERATE
59#include "spgrid.h"
f390d2c7 60u_char DEFAULT_TOPOLOGY_BASEIS[6] = { 0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00 };
eb5d44eb 61#endif /* TOPOLOGY_GENERATE */
62
eb5d44eb 63struct isis *isis = NULL;
eb5d44eb 64
41b36e90
PJ
65/*
66 * Prototypes.
67 */
41b36e90
PJ
68int isis_area_get(struct vty *, const char *);
69int isis_area_destroy(struct vty *, const char *);
3f045a08
JB
70int area_net_title(struct vty *, const char *);
71int area_clear_net_title(struct vty *, const char *);
72int show_isis_interface_common(struct vty *, const char *ifname, char);
73int show_isis_neighbor_common(struct vty *, const char *id, char);
74int clear_isis_neighbor_common(struct vty *, const char *id);
41b36e90
PJ
75int isis_config_write(struct vty *);
76
77
78
eb5d44eb 79void
80isis_new (unsigned long process_id)
81{
aac372f4 82 isis = XCALLOC (MTYPE_ISIS, sizeof (struct isis));
eb5d44eb 83 /*
84 * Default values
85 */
86 isis->max_area_addrs = 3;
eb5d44eb 87 isis->process_id = process_id;
3f045a08 88 isis->router_id = 0;
eb5d44eb 89 isis->area_list = list_new ();
90 isis->init_circ_list = list_new ();
91 isis->uptime = time (NULL);
92 isis->nexthops = list_new ();
93#ifdef HAVE_IPV6
94 isis->nexthops6 = list_new ();
95#endif /* HAVE_IPV6 */
3f045a08 96 dyn_cache_init ();
eb5d44eb 97 /*
98 * uncomment the next line for full debugs
99 */
f390d2c7 100 /* isis->debugs = 0xFFFF; */
eb5d44eb 101}
102
103struct isis_area *
3f045a08 104isis_area_create (const char *area_tag)
eb5d44eb 105{
eb5d44eb 106 struct isis_area *area;
f390d2c7 107
aac372f4 108 area = XCALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area));
eb5d44eb 109
110 /*
111 * The first instance is level-1-2 rest are level-1, unless otherwise
112 * configured
113 */
114 if (listcount (isis->area_list) > 0)
115 area->is_type = IS_LEVEL_1;
116 else
117 area->is_type = IS_LEVEL_1_AND_2;
3f045a08 118
eb5d44eb 119 /*
120 * intialize the databases
121 */
3f045a08
JB
122 if (area->is_type & IS_LEVEL_1)
123 {
124 area->lspdb[0] = lsp_db_init ();
125 area->route_table[0] = route_table_init ();
126#ifdef HAVE_IPV6
127 area->route_table6[0] = route_table_init ();
128#endif /* HAVE_IPV6 */
129 }
130 if (area->is_type & IS_LEVEL_2)
131 {
132 area->lspdb[1] = lsp_db_init ();
133 area->route_table[1] = route_table_init ();
eb5d44eb 134#ifdef HAVE_IPV6
3f045a08 135 area->route_table6[1] = route_table_init ();
eb5d44eb 136#endif /* HAVE_IPV6 */
3f045a08
JB
137 }
138
139 spftree_area_init (area);
140
eb5d44eb 141 area->circuit_list = list_new ();
142 area->area_addrs = list_new ();
f390d2c7 143 THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
c7350c48 144 flags_initialize (&area->flags);
3f045a08 145
eb5d44eb 146 /*
147 * Default values
148 */
3f045a08
JB
149 area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */
150 area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */
151 area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
152 area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
153 area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL;
154 area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL;
eb5d44eb 155 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
156 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
157 area->dynhostname = 1;
3f045a08
JB
158 area->oldmetric = 0;
159 area->newmetric = 1;
eb5d44eb 160 area->lsp_frag_threshold = 90;
b20ccb3a 161 area->lsp_mtu = DEFAULT_LSP_MTU;
eb5d44eb 162#ifdef TOPOLOGY_GENERATE
163 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
164#endif /* TOPOLOGY_GENERATE */
165
3f045a08
JB
166 area->area_tag = strdup (area_tag);
167 listnode_add (isis->area_list, area);
168 area->isis = isis;
169
eb5d44eb 170 return area;
171}
172
173struct isis_area *
f90a5f6f 174isis_area_lookup (const char *area_tag)
eb5d44eb 175{
176 struct isis_area *area;
3fdb2dd9 177 struct listnode *node;
f390d2c7 178
3fdb2dd9 179 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
eb5d44eb 180 if ((area->area_tag == NULL && area_tag == NULL) ||
f390d2c7 181 (area->area_tag && area_tag
182 && strcmp (area->area_tag, area_tag) == 0))
183 return area;
184
eb5d44eb 185 return NULL;
186}
187
f390d2c7 188int
f90a5f6f 189isis_area_get (struct vty *vty, const char *area_tag)
eb5d44eb 190{
eb5d44eb 191 struct isis_area *area;
f390d2c7 192
eb5d44eb 193 area = isis_area_lookup (area_tag);
f390d2c7 194
195 if (area)
196 {
197 vty->node = ISIS_NODE;
198 vty->index = area;
199 return CMD_SUCCESS;
200 }
201
3f045a08 202 area = isis_area_create (area_tag);
f390d2c7 203
c89c05dd 204 if (isis->debugs & DEBUG_EVENTS)
205 zlog_debug ("New IS-IS area instance %s", area->area_tag);
eb5d44eb 206
207 vty->node = ISIS_NODE;
208 vty->index = area;
f390d2c7 209
eb5d44eb 210 return CMD_SUCCESS;
211}
212
213int
f90a5f6f 214isis_area_destroy (struct vty *vty, const char *area_tag)
eb5d44eb 215{
eb5d44eb 216 struct isis_area *area;
1eb8ef25 217 struct listnode *node, *nnode;
eb5d44eb 218 struct isis_circuit *circuit;
3f045a08 219 struct area_addr *addr;
eb5d44eb 220
221 area = isis_area_lookup (area_tag);
eb5d44eb 222
f390d2c7 223 if (area == NULL)
224 {
225 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
3f045a08 226 return CMD_ERR_NO_MATCH;
f390d2c7 227 }
228
229 if (area->circuit_list)
230 {
1eb8ef25 231 for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
3f045a08
JB
232 {
233 circuit->ip_router = 0;
234#ifdef HAVE_IPV6
235 circuit->ipv6_router = 0;
236#endif
237 isis_csm_state_change (ISIS_DISABLE, circuit, area);
238 }
f390d2c7 239 list_delete (area->circuit_list);
3f045a08 240 area->circuit_list = NULL;
eb5d44eb 241 }
3f045a08
JB
242
243 if (area->lspdb[0] != NULL)
244 {
245 lsp_db_destroy (area->lspdb[0]);
246 area->lspdb[0] = NULL;
247 }
248 if (area->lspdb[1] != NULL)
249 {
250 lsp_db_destroy (area->lspdb[1]);
251 area->lspdb[1] = NULL;
252 }
253
254 spftree_area_del (area);
255
256 /* invalidate and validate would delete all routes from zebra */
257 isis_route_invalidate (area);
258 isis_route_validate (area);
259
260 if (area->route_table[0])
261 {
262 route_table_finish (area->route_table[0]);
263 area->route_table[0] = NULL;
264 }
265 if (area->route_table[1])
266 {
267 route_table_finish (area->route_table[1]);
268 area->route_table[1] = NULL;
269 }
270#ifdef HAVE_IPV6
271 if (area->route_table6[0])
272 {
273 route_table_finish (area->route_table6[0]);
274 area->route_table6[0] = NULL;
275 }
276 if (area->route_table6[1])
277 {
278 route_table_finish (area->route_table6[1]);
279 area->route_table6[1] = NULL;
280 }
281#endif /* HAVE_IPV6 */
282
f3ccedaa
CF
283 isis_redist_area_finish(area);
284
3f045a08
JB
285 for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addr))
286 {
287 list_delete_node (area->area_addrs, node);
288 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
289 }
290 area->area_addrs = NULL;
291
f390d2c7 292 THREAD_TIMER_OFF (area->t_tick);
f390d2c7 293 THREAD_TIMER_OFF (area->t_lsp_refresh[0]);
294 THREAD_TIMER_OFF (area->t_lsp_refresh[1]);
eb5d44eb 295
3f045a08
JB
296 thread_cancel_event (master, area);
297
298 listnode_delete (isis->area_list, area);
299
300 free (area->area_tag);
301
eb5d44eb 302 XFREE (MTYPE_ISIS_AREA, area);
f390d2c7 303
3f045a08
JB
304 if (listcount (isis->area_list) == 0)
305 {
306 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
307 isis->sysid_set = 0;
308 }
309
eb5d44eb 310 return CMD_SUCCESS;
311}
312
f390d2c7 313int
3f045a08 314area_net_title (struct vty *vty, const char *net_title)
eb5d44eb 315{
eb5d44eb 316 struct isis_area *area;
317 struct area_addr *addr;
318 struct area_addr *addrp;
3fdb2dd9 319 struct listnode *node;
eb5d44eb 320
321 u_char buff[255];
322 area = vty->index;
323
f390d2c7 324 if (!area)
325 {
326 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
3f045a08 327 return CMD_ERR_NO_MATCH;
f390d2c7 328 }
eb5d44eb 329
330 /* We check that we are not over the maximal number of addresses */
f390d2c7 331 if (listcount (area->area_addrs) >= isis->max_area_addrs)
332 {
333 vty_out (vty, "Maximum of area addresses (%d) already reached %s",
334 isis->max_area_addrs, VTY_NEWLINE);
3f045a08 335 return CMD_ERR_NOTHING_TODO;
f390d2c7 336 }
eb5d44eb 337
338 addr = XMALLOC (MTYPE_ISIS_AREA_ADDR, sizeof (struct area_addr));
339 addr->addr_len = dotformat2buff (buff, net_title);
340 memcpy (addr->area_addr, buff, addr->addr_len);
341#ifdef EXTREME_DEBUG
529d65b3 342 zlog_debug ("added area address %s for area %s (address length %d)",
eb5d44eb 343 net_title, area->area_tag, addr->addr_len);
344#endif /* EXTREME_DEBUG */
f390d2c7 345 if (addr->addr_len < 8 || addr->addr_len > 20)
346 {
3f045a08
JB
347 vty_out (vty, "area address must be at least 8..20 octets long (%d)%s",
348 addr->addr_len, VTY_NEWLINE);
349 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
350 return CMD_ERR_AMBIGUOUS;
351 }
352
353 if (addr->area_addr[addr->addr_len-1] != 0)
354 {
355 vty_out (vty, "nsel byte (last byte) in area address must be 0%s",
356 VTY_NEWLINE);
eb5d44eb 357 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
3f045a08 358 return CMD_ERR_AMBIGUOUS;
eb5d44eb 359 }
360
f390d2c7 361 if (isis->sysid_set == 0)
362 {
363 /*
364 * First area address - get the SystemID for this router
365 */
3f045a08 366 memcpy (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN);
f390d2c7 367 isis->sysid_set = 1;
c89c05dd 368 if (isis->debugs & DEBUG_EVENTS)
369 zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid));
eb5d44eb 370 }
f390d2c7 371 else
372 {
373 /*
374 * Check that the SystemID portions match
375 */
3f045a08 376 if (memcmp (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN))
f390d2c7 377 {
378 vty_out (vty,
379 "System ID must not change when defining additional area"
380 " addresses%s", VTY_NEWLINE);
381 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
3f045a08 382 return CMD_ERR_AMBIGUOUS;
f390d2c7 383 }
eb5d44eb 384
f390d2c7 385 /* now we see that we don't already have this address */
3fdb2dd9 386 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
387 {
3f045a08 388 if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != (addr->addr_len))
3fdb2dd9 389 continue;
390 if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
391 {
392 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
393 return CMD_SUCCESS; /* silent fail */
394 }
395 }
f390d2c7 396 }
3f045a08 397
eb5d44eb 398 /*
399 * Forget the systemID part of the address
400 */
3f045a08 401 addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
eb5d44eb 402 listnode_add (area->area_addrs, addr);
403
404 /* only now we can safely generate our LSPs for this area */
f390d2c7 405 if (listcount (area->area_addrs) > 0)
406 {
3f045a08
JB
407 if (area->is_type & IS_LEVEL_1)
408 lsp_generate (area, IS_LEVEL_1);
409 if (area->is_type & IS_LEVEL_2)
410 lsp_generate (area, IS_LEVEL_2);
f390d2c7 411 }
eb5d44eb 412
413 return CMD_SUCCESS;
414}
415
416int
3f045a08 417area_clear_net_title (struct vty *vty, const char *net_title)
eb5d44eb 418{
419 struct isis_area *area;
f390d2c7 420 struct area_addr addr, *addrp = NULL;
3fdb2dd9 421 struct listnode *node;
eb5d44eb 422 u_char buff[255];
423
424 area = vty->index;
f390d2c7 425 if (!area)
426 {
427 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
3f045a08 428 return CMD_ERR_NO_MATCH;
f390d2c7 429 }
430
eb5d44eb 431 addr.addr_len = dotformat2buff (buff, net_title);
f390d2c7 432 if (addr.addr_len < 8 || addr.addr_len > 20)
433 {
434 vty_out (vty, "Unsupported area address length %d, should be 8...20 %s",
435 addr.addr_len, VTY_NEWLINE);
3f045a08 436 return CMD_ERR_AMBIGUOUS;
f390d2c7 437 }
438
439 memcpy (addr.area_addr, buff, (int) addr.addr_len);
440
3fdb2dd9 441 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
3f045a08 442 if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len &&
eb5d44eb 443 !memcmp (addrp->area_addr, addr.area_addr, addr.addr_len))
f390d2c7 444 break;
445
446 if (!addrp)
447 {
448 vty_out (vty, "No area address %s for area %s %s", net_title,
449 area->area_tag, VTY_NEWLINE);
3f045a08 450 return CMD_ERR_NO_MATCH;
f390d2c7 451 }
452
eb5d44eb 453 listnode_delete (area->area_addrs, addrp);
3f045a08
JB
454 XFREE (MTYPE_ISIS_AREA_ADDR, addrp);
455
456 /*
457 * Last area address - reset the SystemID for this router
458 */
459 if (listcount (area->area_addrs) == 0)
460 {
461 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
462 isis->sysid_set = 0;
463 if (isis->debugs & DEBUG_EVENTS)
464 zlog_debug ("Router has no SystemID");
465 }
f390d2c7 466
eb5d44eb 467 return CMD_SUCCESS;
468}
469
eb5d44eb 470/*
3f045a08 471 * 'show isis interface' command
eb5d44eb 472 */
473
474int
3f045a08 475show_isis_interface_common (struct vty *vty, const char *ifname, char detail)
eb5d44eb 476{
3fdb2dd9 477 struct listnode *anode, *cnode;
eb5d44eb 478 struct isis_area *area;
479 struct isis_circuit *circuit;
eb5d44eb 480
f390d2c7 481 if (!isis)
482 {
483 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
484 return CMD_SUCCESS;
485 }
eb5d44eb 486
3fdb2dd9 487 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
f390d2c7 488 {
f390d2c7 489 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
490
491 if (detail == ISIS_UI_LEVEL_BRIEF)
3f045a08
JB
492 vty_out (vty, " Interface CircId State Type Level%s",
493 VTY_NEWLINE);
f390d2c7 494
3fdb2dd9 495 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
3f045a08
JB
496 if (!ifname)
497 isis_circuit_print_vty (circuit, vty, detail);
498 else if (strcmp(circuit->interface->name, ifname) == 0)
499 isis_circuit_print_vty (circuit, vty, detail);
eb5d44eb 500 }
f390d2c7 501
eb5d44eb 502 return CMD_SUCCESS;
503}
504
3f045a08
JB
505DEFUN (show_isis_interface,
506 show_isis_interface_cmd,
507 "show isis interface",
eb5d44eb 508 SHOW_STR
3f045a08
JB
509 "ISIS network information\n"
510 "ISIS interface\n")
eb5d44eb 511{
3f045a08 512 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
eb5d44eb 513}
514
3f045a08
JB
515DEFUN (show_isis_interface_detail,
516 show_isis_interface_detail_cmd,
517 "show isis interface detail",
eb5d44eb 518 SHOW_STR
3f045a08
JB
519 "ISIS network information\n"
520 "ISIS interface\n"
521 "show detailed information\n")
522{
523 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
524}
eb5d44eb 525
3f045a08
JB
526DEFUN (show_isis_interface_arg,
527 show_isis_interface_arg_cmd,
528 "show isis interface WORD",
eb5d44eb 529 SHOW_STR
3f045a08
JB
530 "ISIS network information\n"
531 "ISIS interface\n"
532 "ISIS interface name\n")
533{
534 return show_isis_interface_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
535}
536
537/*
538 * 'show isis neighbor' command
539 */
540
541int
542show_isis_neighbor_common (struct vty *vty, const char *id, char detail)
543{
544 struct listnode *anode, *cnode, *node;
545 struct isis_area *area;
546 struct isis_circuit *circuit;
547 struct list *adjdb;
548 struct isis_adjacency *adj;
549 struct isis_dynhn *dynhn;
550 u_char sysid[ISIS_SYS_ID_LEN];
551 int i;
552
553 if (!isis)
554 {
555 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
556 return CMD_SUCCESS;
557 }
558
559 memset (sysid, 0, ISIS_SYS_ID_LEN);
560 if (id)
561 {
562 if (sysid2buff (sysid, id) == 0)
563 {
564 dynhn = dynhn_find_by_name (id);
565 if (dynhn == NULL)
566 {
567 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
568 return CMD_SUCCESS;
569 }
570 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
571 }
572 }
573
574 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
575 {
576 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
577
578 if (detail == ISIS_UI_LEVEL_BRIEF)
579 vty_out (vty, " System Id Interface L State"
580 " Holdtime SNPA%s", VTY_NEWLINE);
581
582 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
583 {
584 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
585 {
586 for (i = 0; i < 2; i++)
587 {
588 adjdb = circuit->u.bc.adjdb[i];
589 if (adjdb && adjdb->count)
590 {
591 for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
592 if (!id || !memcmp (adj->sysid, sysid,
593 ISIS_SYS_ID_LEN))
594 isis_adj_print_vty (adj, vty, detail);
595 }
596 }
597 }
598 else if (circuit->circ_type == CIRCUIT_T_P2P &&
599 circuit->u.p2p.neighbor)
600 {
601 adj = circuit->u.p2p.neighbor;
602 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
603 isis_adj_print_vty (adj, vty, detail);
604 }
605 }
606 }
607
608 return CMD_SUCCESS;
609}
610
611/*
612 * 'clear isis neighbor' command
613 */
614int
615clear_isis_neighbor_common (struct vty *vty, const char *id)
616{
617 struct listnode *anode, *cnode, *cnextnode, *node, *nnode;
618 struct isis_area *area;
619 struct isis_circuit *circuit;
620 struct list *adjdb;
621 struct isis_adjacency *adj;
622 struct isis_dynhn *dynhn;
623 u_char sysid[ISIS_SYS_ID_LEN];
624 int i;
625
626 if (!isis)
627 {
628 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
629 return CMD_SUCCESS;
630 }
631
632 memset (sysid, 0, ISIS_SYS_ID_LEN);
633 if (id)
634 {
635 if (sysid2buff (sysid, id) == 0)
636 {
637 dynhn = dynhn_find_by_name (id);
638 if (dynhn == NULL)
639 {
640 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
641 return CMD_SUCCESS;
642 }
643 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
644 }
645 }
646
647 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
648 {
649 for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnextnode, circuit))
650 {
651 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
652 {
653 for (i = 0; i < 2; i++)
654 {
655 adjdb = circuit->u.bc.adjdb[i];
656 if (adjdb && adjdb->count)
657 {
658 for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj))
659 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
660 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
661 "clear user request");
662 }
663 }
664 }
665 else if (circuit->circ_type == CIRCUIT_T_P2P &&
666 circuit->u.p2p.neighbor)
667 {
668 adj = circuit->u.p2p.neighbor;
669 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
670 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
671 "clear user request");
672 }
673 }
674 }
675
676 return CMD_SUCCESS;
677}
678
679DEFUN (show_isis_neighbor,
680 show_isis_neighbor_cmd,
681 "show isis neighbor",
682 SHOW_STR
683 "ISIS network information\n"
684 "ISIS neighbor adjacencies\n")
eb5d44eb 685{
3f045a08 686 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
eb5d44eb 687}
688
3f045a08
JB
689DEFUN (show_isis_neighbor_detail,
690 show_isis_neighbor_detail_cmd,
691 "show isis neighbor detail",
eb5d44eb 692 SHOW_STR
3f045a08
JB
693 "ISIS network information\n"
694 "ISIS neighbor adjacencies\n"
eb5d44eb 695 "show detailed information\n")
3f045a08
JB
696{
697 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
698}
699
700DEFUN (show_isis_neighbor_arg,
701 show_isis_neighbor_arg_cmd,
702 "show isis neighbor WORD",
703 SHOW_STR
704 "ISIS network information\n"
705 "ISIS neighbor adjacencies\n"
706 "System id\n")
707{
708 return show_isis_neighbor_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
709}
710
711DEFUN (clear_isis_neighbor,
712 clear_isis_neighbor_cmd,
713 "clear isis neighbor",
714 CLEAR_STR
715 "Reset ISIS network information\n"
716 "Reset ISIS neighbor adjacencies\n")
717{
718 return clear_isis_neighbor_common (vty, NULL);
719}
720
721DEFUN (clear_isis_neighbor_arg,
722 clear_isis_neighbor_arg_cmd,
e38e0df0 723 "clear isis neighbor WORD",
3f045a08
JB
724 CLEAR_STR
725 "ISIS network information\n"
726 "ISIS neighbor adjacencies\n"
727 "System id\n")
728{
729 return clear_isis_neighbor_common (vty, argv[0]);
730}
731
eb5d44eb 732/*
733 * 'isis debug', 'show debugging'
734 */
eb5d44eb 735void
736print_debug (struct vty *vty, int flags, int onoff)
737{
738 char onoffs[4];
739 if (onoff)
f390d2c7 740 strcpy (onoffs, "on");
eb5d44eb 741 else
f390d2c7 742 strcpy (onoffs, "off");
eb5d44eb 743
744 if (flags & DEBUG_ADJ_PACKETS)
f390d2c7 745 vty_out (vty, "IS-IS Adjacency related packets debugging is %s%s", onoffs,
746 VTY_NEWLINE);
eb5d44eb 747 if (flags & DEBUG_CHECKSUM_ERRORS)
f390d2c7 748 vty_out (vty, "IS-IS checksum errors debugging is %s%s", onoffs,
749 VTY_NEWLINE);
eb5d44eb 750 if (flags & DEBUG_LOCAL_UPDATES)
f390d2c7 751 vty_out (vty, "IS-IS local updates debugging is %s%s", onoffs,
752 VTY_NEWLINE);
eb5d44eb 753 if (flags & DEBUG_PROTOCOL_ERRORS)
f390d2c7 754 vty_out (vty, "IS-IS protocol errors debugging is %s%s", onoffs,
755 VTY_NEWLINE);
eb5d44eb 756 if (flags & DEBUG_SNP_PACKETS)
f390d2c7 757 vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s%s", onoffs,
758 VTY_NEWLINE);
eb5d44eb 759 if (flags & DEBUG_SPF_EVENTS)
f390d2c7 760 vty_out (vty, "IS-IS SPF events debugging is %s%s", onoffs, VTY_NEWLINE);
eb5d44eb 761 if (flags & DEBUG_SPF_STATS)
f390d2c7 762 vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s%s",
763 onoffs, VTY_NEWLINE);
eb5d44eb 764 if (flags & DEBUG_SPF_TRIGGERS)
f390d2c7 765 vty_out (vty, "IS-IS SPF triggering events debugging is %s%s", onoffs,
766 VTY_NEWLINE);
eb5d44eb 767 if (flags & DEBUG_UPDATE_PACKETS)
f390d2c7 768 vty_out (vty, "IS-IS Update related packet debugging is %s%s", onoffs,
769 VTY_NEWLINE);
eb5d44eb 770 if (flags & DEBUG_RTE_EVENTS)
f390d2c7 771 vty_out (vty, "IS-IS Route related debuggin is %s%s", onoffs,
772 VTY_NEWLINE);
eb5d44eb 773 if (flags & DEBUG_EVENTS)
f390d2c7 774 vty_out (vty, "IS-IS Event debugging is %s%s", onoffs, VTY_NEWLINE);
3f045a08
JB
775 if (flags & DEBUG_PACKET_DUMP)
776 vty_out (vty, "IS-IS Packet dump debugging is %s%s", onoffs, VTY_NEWLINE);
14872644
CF
777 if (flags & DEBUG_LSP_GEN)
778 vty_out (vty, "IS-IS LSP generation debugging is %s%s", onoffs, VTY_NEWLINE);
414766a1
CF
779 if (flags & DEBUG_LSP_SCHED)
780 vty_out (vty, "IS-IS LSP scheduling debugging is %s%s", onoffs, VTY_NEWLINE);
eb5d44eb 781}
782
783DEFUN (show_debugging,
784 show_debugging_cmd,
16286195 785 "show debugging isis",
eb5d44eb 786 SHOW_STR
16286195
DS
787 "State of each debugging option\n"
788 ISIS_STR)
eb5d44eb 789{
f390d2c7 790 vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
eb5d44eb 791 print_debug (vty, isis->debugs, 1);
792 return CMD_SUCCESS;
793}
794
9e867fe6 795/* Debug node. */
f390d2c7 796static struct cmd_node debug_node = {
9e867fe6 797 DEBUG_NODE,
f390d2c7 798 "",
799 1
9e867fe6 800};
801
802static int
803config_write_debug (struct vty *vty)
804{
805 int write = 0;
806 int flags = isis->debugs;
807
f390d2c7 808 if (flags & DEBUG_ADJ_PACKETS)
809 {
810 vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
811 write++;
812 }
813 if (flags & DEBUG_CHECKSUM_ERRORS)
814 {
815 vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
816 write++;
817 }
818 if (flags & DEBUG_LOCAL_UPDATES)
819 {
820 vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
821 write++;
822 }
823 if (flags & DEBUG_PROTOCOL_ERRORS)
824 {
825 vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
826 write++;
827 }
828 if (flags & DEBUG_SNP_PACKETS)
829 {
830 vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
831 write++;
832 }
833 if (flags & DEBUG_SPF_EVENTS)
834 {
835 vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
836 write++;
837 }
838 if (flags & DEBUG_SPF_STATS)
839 {
840 vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
841 write++;
842 }
843 if (flags & DEBUG_SPF_TRIGGERS)
844 {
845 vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
846 write++;
847 }
848 if (flags & DEBUG_UPDATE_PACKETS)
849 {
850 vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
851 write++;
852 }
853 if (flags & DEBUG_RTE_EVENTS)
854 {
855 vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
856 write++;
857 }
858 if (flags & DEBUG_EVENTS)
859 {
860 vty_out (vty, "debug isis events%s", VTY_NEWLINE);
861 write++;
862 }
3f045a08
JB
863 if (flags & DEBUG_PACKET_DUMP)
864 {
865 vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE);
866 write++;
867 }
14872644
CF
868 if (flags & DEBUG_LSP_GEN)
869 {
870 vty_out (vty, "debug isis lsp-gen%s", VTY_NEWLINE);
871 write++;
872 }
414766a1
CF
873 if (flags & DEBUG_LSP_SCHED)
874 {
875 vty_out (vty, "debug isis lsp-sched%s", VTY_NEWLINE);
876 write++;
877 }
9e867fe6 878
879 return write;
880}
881
eb5d44eb 882DEFUN (debug_isis_adj,
883 debug_isis_adj_cmd,
884 "debug isis adj-packets",
885 DEBUG_STR
886 "IS-IS information\n"
f390d2c7 887 "IS-IS Adjacency related packets\n")
eb5d44eb 888{
889 isis->debugs |= DEBUG_ADJ_PACKETS;
f390d2c7 890 print_debug (vty, DEBUG_ADJ_PACKETS, 1);
eb5d44eb 891
892 return CMD_SUCCESS;
893}
894
895DEFUN (no_debug_isis_adj,
896 no_debug_isis_adj_cmd,
897 "no debug isis adj-packets",
898 UNDEBUG_STR
899 "IS-IS information\n"
f390d2c7 900 "IS-IS Adjacency related packets\n")
eb5d44eb 901{
eb5d44eb 902 isis->debugs &= ~DEBUG_ADJ_PACKETS;
903 print_debug (vty, DEBUG_ADJ_PACKETS, 0);
904
905 return CMD_SUCCESS;
906}
907
eb5d44eb 908DEFUN (debug_isis_csum,
909 debug_isis_csum_cmd,
910 "debug isis checksum-errors",
911 DEBUG_STR
912 "IS-IS information\n"
f390d2c7 913 "IS-IS LSP checksum errors\n")
eb5d44eb 914{
915 isis->debugs |= DEBUG_CHECKSUM_ERRORS;
916 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1);
917
918 return CMD_SUCCESS;
919}
920
921DEFUN (no_debug_isis_csum,
922 no_debug_isis_csum_cmd,
923 "no debug isis checksum-errors",
924 UNDEBUG_STR
925 "IS-IS information\n"
f390d2c7 926 "IS-IS LSP checksum errors\n")
eb5d44eb 927{
928 isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
929 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
f390d2c7 930
eb5d44eb 931 return CMD_SUCCESS;
932}
933
934DEFUN (debug_isis_lupd,
935 debug_isis_lupd_cmd,
936 "debug isis local-updates",
937 DEBUG_STR
938 "IS-IS information\n"
f390d2c7 939 "IS-IS local update packets\n")
eb5d44eb 940{
941 isis->debugs |= DEBUG_LOCAL_UPDATES;
942 print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
943
944 return CMD_SUCCESS;
945}
946
947DEFUN (no_debug_isis_lupd,
948 no_debug_isis_lupd_cmd,
949 "no debug isis local-updates",
950 UNDEBUG_STR
951 "IS-IS information\n"
f390d2c7 952 "IS-IS local update packets\n")
eb5d44eb 953{
954 isis->debugs &= ~DEBUG_LOCAL_UPDATES;
f390d2c7 955 print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
956
eb5d44eb 957 return CMD_SUCCESS;
958}
959
960DEFUN (debug_isis_err,
961 debug_isis_err_cmd,
f390d2c7 962 "debug isis protocol-errors",
eb5d44eb 963 DEBUG_STR
964 "IS-IS information\n"
f390d2c7 965 "IS-IS LSP protocol errors\n")
eb5d44eb 966{
967 isis->debugs |= DEBUG_PROTOCOL_ERRORS;
968 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1);
969
970 return CMD_SUCCESS;
971}
972
973DEFUN (no_debug_isis_err,
974 no_debug_isis_err_cmd,
975 "no debug isis protocol-errors",
976 UNDEBUG_STR
977 "IS-IS information\n"
f390d2c7 978 "IS-IS LSP protocol errors\n")
eb5d44eb 979{
980 isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
981 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
f390d2c7 982
eb5d44eb 983 return CMD_SUCCESS;
984}
985
986DEFUN (debug_isis_snp,
987 debug_isis_snp_cmd,
988 "debug isis snp-packets",
989 DEBUG_STR
990 "IS-IS information\n"
f390d2c7 991 "IS-IS CSNP/PSNP packets\n")
eb5d44eb 992{
993 isis->debugs |= DEBUG_SNP_PACKETS;
994 print_debug (vty, DEBUG_SNP_PACKETS, 1);
995
996 return CMD_SUCCESS;
997}
998
999DEFUN (no_debug_isis_snp,
1000 no_debug_isis_snp_cmd,
1001 "no debug isis snp-packets",
1002 UNDEBUG_STR
1003 "IS-IS information\n"
f390d2c7 1004 "IS-IS CSNP/PSNP packets\n")
eb5d44eb 1005{
f390d2c7 1006 isis->debugs &= ~DEBUG_SNP_PACKETS;
eb5d44eb 1007 print_debug (vty, DEBUG_SNP_PACKETS, 0);
f390d2c7 1008
eb5d44eb 1009 return CMD_SUCCESS;
1010}
1011
eb5d44eb 1012DEFUN (debug_isis_upd,
1013 debug_isis_upd_cmd,
1014 "debug isis update-packets",
1015 DEBUG_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, 1);
1021
1022 return CMD_SUCCESS;
1023}
1024
1025DEFUN (no_debug_isis_upd,
1026 no_debug_isis_upd_cmd,
1027 "no debug isis update-packets",
1028 UNDEBUG_STR
1029 "IS-IS information\n"
f390d2c7 1030 "IS-IS Update related packets\n")
eb5d44eb 1031{
1032 isis->debugs &= ~DEBUG_UPDATE_PACKETS;
1033 print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
f390d2c7 1034
eb5d44eb 1035 return CMD_SUCCESS;
1036}
1037
eb5d44eb 1038DEFUN (debug_isis_spfevents,
1039 debug_isis_spfevents_cmd,
1040 "debug isis spf-events",
1041 DEBUG_STR
1042 "IS-IS information\n"
f390d2c7 1043 "IS-IS Shortest Path First Events\n")
eb5d44eb 1044{
1045 isis->debugs |= DEBUG_SPF_EVENTS;
f390d2c7 1046 print_debug (vty, DEBUG_SPF_EVENTS, 1);
eb5d44eb 1047
1048 return CMD_SUCCESS;
1049}
1050
1051DEFUN (no_debug_isis_spfevents,
1052 no_debug_isis_spfevents_cmd,
1053 "no debug isis spf-events",
1054 UNDEBUG_STR
1055 "IS-IS information\n"
f390d2c7 1056 "IS-IS Shortest Path First Events\n")
eb5d44eb 1057{
1058 isis->debugs &= ~DEBUG_SPF_EVENTS;
f390d2c7 1059 print_debug (vty, DEBUG_SPF_EVENTS, 0);
1060
eb5d44eb 1061 return CMD_SUCCESS;
1062}
1063
eb5d44eb 1064DEFUN (debug_isis_spfstats,
1065 debug_isis_spfstats_cmd,
1066 "debug isis spf-statistics ",
1067 DEBUG_STR
1068 "IS-IS information\n"
f390d2c7 1069 "IS-IS SPF Timing and Statistic Data\n")
eb5d44eb 1070{
1071 isis->debugs |= DEBUG_SPF_STATS;
1072 print_debug (vty, DEBUG_SPF_STATS, 1);
1073
1074 return CMD_SUCCESS;
1075}
1076
1077DEFUN (no_debug_isis_spfstats,
1078 no_debug_isis_spfstats_cmd,
1079 "no debug isis spf-statistics",
1080 UNDEBUG_STR
1081 "IS-IS information\n"
f390d2c7 1082 "IS-IS SPF Timing and Statistic Data\n")
eb5d44eb 1083{
1084 isis->debugs &= ~DEBUG_SPF_STATS;
1085 print_debug (vty, DEBUG_SPF_STATS, 0);
f390d2c7 1086
eb5d44eb 1087 return CMD_SUCCESS;
1088}
1089
1090DEFUN (debug_isis_spftrigg,
1091 debug_isis_spftrigg_cmd,
1092 "debug isis spf-triggers",
1093 DEBUG_STR
1094 "IS-IS information\n"
f390d2c7 1095 "IS-IS SPF triggering events\n")
eb5d44eb 1096{
1097 isis->debugs |= DEBUG_SPF_TRIGGERS;
1098 print_debug (vty, DEBUG_SPF_TRIGGERS, 1);
1099
1100 return CMD_SUCCESS;
1101}
1102
1103DEFUN (no_debug_isis_spftrigg,
1104 no_debug_isis_spftrigg_cmd,
1105 "no debug isis spf-triggers",
1106 UNDEBUG_STR
1107 "IS-IS information\n"
f390d2c7 1108 "IS-IS SPF triggering events\n")
eb5d44eb 1109{
1110 isis->debugs &= ~DEBUG_SPF_TRIGGERS;
1111 print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
f390d2c7 1112
eb5d44eb 1113 return CMD_SUCCESS;
1114}
1115
1116DEFUN (debug_isis_rtevents,
1117 debug_isis_rtevents_cmd,
1118 "debug isis route-events",
1119 DEBUG_STR
1120 "IS-IS information\n"
f390d2c7 1121 "IS-IS Route related events\n")
eb5d44eb 1122{
1123 isis->debugs |= DEBUG_RTE_EVENTS;
1124 print_debug (vty, DEBUG_RTE_EVENTS, 1);
1125
1126 return CMD_SUCCESS;
1127}
1128
1129DEFUN (no_debug_isis_rtevents,
1130 no_debug_isis_rtevents_cmd,
1131 "no debug isis route-events",
1132 UNDEBUG_STR
1133 "IS-IS information\n"
f390d2c7 1134 "IS-IS Route related events\n")
eb5d44eb 1135{
1136 isis->debugs &= ~DEBUG_RTE_EVENTS;
1137 print_debug (vty, DEBUG_RTE_EVENTS, 0);
f390d2c7 1138
eb5d44eb 1139 return CMD_SUCCESS;
1140}
1141
1142DEFUN (debug_isis_events,
1143 debug_isis_events_cmd,
1144 "debug isis events",
1145 DEBUG_STR
1146 "IS-IS information\n"
f1082d19 1147 "IS-IS Events\n")
eb5d44eb 1148{
1149 isis->debugs |= DEBUG_EVENTS;
1150 print_debug (vty, DEBUG_EVENTS, 1);
1151
1152 return CMD_SUCCESS;
1153}
1154
1155DEFUN (no_debug_isis_events,
1156 no_debug_isis_events_cmd,
1157 "no debug isis events",
1158 UNDEBUG_STR
1159 "IS-IS information\n"
f390d2c7 1160 "IS-IS Events\n")
eb5d44eb 1161{
1162 isis->debugs &= ~DEBUG_EVENTS;
1163 print_debug (vty, DEBUG_EVENTS, 0);
f390d2c7 1164
eb5d44eb 1165 return CMD_SUCCESS;
1166}
1167
3f045a08
JB
1168DEFUN (debug_isis_packet_dump,
1169 debug_isis_packet_dump_cmd,
1170 "debug isis packet-dump",
1171 DEBUG_STR
1172 "IS-IS information\n"
1173 "IS-IS packet dump\n")
1174{
1175 isis->debugs |= DEBUG_PACKET_DUMP;
1176 print_debug (vty, DEBUG_PACKET_DUMP, 1);
1177
1178 return CMD_SUCCESS;
1179}
1180
1181DEFUN (no_debug_isis_packet_dump,
1182 no_debug_isis_packet_dump_cmd,
1183 "no debug isis packet-dump",
1184 UNDEBUG_STR
1185 "IS-IS information\n"
1186 "IS-IS packet dump\n")
1187{
1188 isis->debugs &= ~DEBUG_PACKET_DUMP;
1189 print_debug (vty, DEBUG_PACKET_DUMP, 0);
1190
1191 return CMD_SUCCESS;
1192}
1193
14872644
CF
1194DEFUN (debug_isis_lsp_gen,
1195 debug_isis_lsp_gen_cmd,
1196 "debug isis lsp-gen",
1197 DEBUG_STR
1198 "IS-IS information\n"
1199 "IS-IS generation of own LSPs\n")
1200{
1201 isis->debugs |= DEBUG_LSP_GEN;
1202 print_debug (vty, DEBUG_LSP_GEN, 1);
1203
1204 return CMD_SUCCESS;
1205}
1206
1207DEFUN (no_debug_isis_lsp_gen,
1208 no_debug_isis_lsp_gen_cmd,
1209 "no debug isis lsp-gen",
1210 UNDEBUG_STR
1211 "IS-IS information\n"
1212 "IS-IS generation of own LSPs\n")
1213{
1214 isis->debugs &= ~DEBUG_LSP_GEN;
1215 print_debug (vty, DEBUG_LSP_GEN, 0);
1216
1217 return CMD_SUCCESS;
1218}
1219
414766a1
CF
1220DEFUN (debug_isis_lsp_sched,
1221 debug_isis_lsp_sched_cmd,
1222 "debug isis lsp-sched",
1223 DEBUG_STR
1224 "IS-IS information\n"
1225 "IS-IS scheduling of LSP generation\n")
1226{
1227 isis->debugs |= DEBUG_LSP_SCHED;
1228 print_debug (vty, DEBUG_LSP_SCHED, 1);
1229
1230 return CMD_SUCCESS;
1231}
1232
1233DEFUN (no_debug_isis_lsp_sched,
1234 no_debug_isis_lsp_sched_cmd,
1235 "no debug isis lsp-gen",
1236 UNDEBUG_STR
1237 "IS-IS information\n"
1238 "IS-IS scheduling of LSP generation\n")
1239{
1240 isis->debugs &= ~DEBUG_LSP_SCHED;
1241 print_debug (vty, DEBUG_LSP_SCHED, 0);
1242
1243 return CMD_SUCCESS;
1244}
1245
eb5d44eb 1246DEFUN (show_hostname,
1247 show_hostname_cmd,
1248 "show isis hostname",
1249 SHOW_STR
1250 "IS-IS information\n"
1251 "IS-IS Dynamic hostname mapping\n")
1252{
1253 dynhn_print_all (vty);
f390d2c7 1254
eb5d44eb 1255 return CMD_SUCCESS;
1256}
1257
3f045a08
JB
1258static void
1259vty_out_timestr(struct vty *vty, time_t uptime)
eb5d44eb 1260{
3f045a08
JB
1261 struct tm *tm;
1262 time_t difftime = time (NULL);
1263 difftime -= uptime;
1264 tm = gmtime (&difftime);
1265
1266#define ONE_DAY_SECOND 60*60*24
1267#define ONE_WEEK_SECOND 60*60*24*7
1268 if (difftime < ONE_DAY_SECOND)
1269 vty_out (vty, "%02d:%02d:%02d",
1270 tm->tm_hour, tm->tm_min, tm->tm_sec);
1271 else if (difftime < ONE_WEEK_SECOND)
1272 vty_out (vty, "%dd%02dh%02dm",
1273 tm->tm_yday, tm->tm_hour, tm->tm_min);
1274 else
1275 vty_out (vty, "%02dw%dd%02dh",
1276 tm->tm_yday/7,
1277 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1278 vty_out (vty, " ago");
1279}
1280
1281DEFUN (show_isis_summary,
1282 show_isis_summary_cmd,
1283 "show isis summary",
1284 SHOW_STR "IS-IS information\n" "IS-IS summary\n")
1285{
1286 struct listnode *node, *node2;
eb5d44eb 1287 struct isis_area *area;
3f045a08
JB
1288 struct isis_spftree *spftree;
1289 int level;
eb5d44eb 1290
3f045a08
JB
1291 if (isis == NULL)
1292 {
1293 vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
eb5d44eb 1294 return CMD_SUCCESS;
3f045a08
JB
1295 }
1296
1297 vty_out (vty, "Process Id : %ld%s", isis->process_id,
1298 VTY_NEWLINE);
1299 if (isis->sysid_set)
1300 vty_out (vty, "System Id : %s%s", sysid_print (isis->sysid),
1301 VTY_NEWLINE);
1302
1303 vty_out (vty, "Up time : ");
1304 vty_out_timestr(vty, isis->uptime);
1305 vty_out (vty, "%s", VTY_NEWLINE);
1306
1307 if (isis->area_list)
1308 vty_out (vty, "Number of areas : %d%s", isis->area_list->count,
1309 VTY_NEWLINE);
f390d2c7 1310
3fdb2dd9 1311 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
3f045a08
JB
1312 {
1313 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1314 VTY_NEWLINE);
1315
1316 if (listcount (area->area_addrs) > 0)
f390d2c7 1317 {
3f045a08
JB
1318 struct area_addr *area_addr;
1319 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
1320 {
1321 vty_out (vty, " Net: %s%s",
1322 isonet_print (area_addr->area_addr,
1323 area_addr->addr_len + ISIS_SYS_ID_LEN +
1324 1), VTY_NEWLINE);
1325 }
1326 }
f390d2c7 1327
3f045a08
JB
1328 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
1329 {
1330 if ((area->is_type & level) == 0)
1331 continue;
f390d2c7 1332
3f045a08
JB
1333 vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE);
1334 spftree = area->spftree[level - 1];
1335 if (spftree->pending)
1336 vty_out (vty, " IPv4 SPF: (pending)%s", VTY_NEWLINE);
1337 else
1338 vty_out (vty, " IPv4 SPF:%s", VTY_NEWLINE);
1339
1340 vty_out (vty, " minimum interval : %d%s",
1341 area->min_spf_interval[level - 1], VTY_NEWLINE);
1342
e38e0df0
SV
1343 vty_out (vty, " last run elapsed : ");
1344 vty_out_timestr(vty, spftree->last_run_timestamp);
3f045a08
JB
1345 vty_out (vty, "%s", VTY_NEWLINE);
1346
e38e0df0
SV
1347 vty_out (vty, " last run duration : %u usec%s",
1348 (u_int32_t)spftree->last_run_duration, VTY_NEWLINE);
1349
3f045a08
JB
1350 vty_out (vty, " run count : %d%s",
1351 spftree->runcount, VTY_NEWLINE);
1352
1353#ifdef HAVE_IPV6
1354 spftree = area->spftree6[level - 1];
1355 if (spftree->pending)
1356 vty_out (vty, " IPv6 SPF: (pending)%s", VTY_NEWLINE);
1357 else
1358 vty_out (vty, " IPv6 SPF:%s", VTY_NEWLINE);
1359
1360 vty_out (vty, " minimum interval : %d%s",
1361 area->min_spf_interval[level - 1], VTY_NEWLINE);
1362
e38e0df0
SV
1363 vty_out (vty, " last run elapsed : ");
1364 vty_out_timestr(vty, spftree->last_run_timestamp);
3f045a08
JB
1365 vty_out (vty, "%s", VTY_NEWLINE);
1366
8f2c16aa
DL
1367 vty_out (vty, " last run duration : %llu msec%s",
1368 (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
e38e0df0 1369
3f045a08
JB
1370 vty_out (vty, " run count : %d%s",
1371 spftree->runcount, VTY_NEWLINE);
1372#endif
eb5d44eb 1373 }
3f045a08
JB
1374 }
1375 vty_out (vty, "%s", VTY_NEWLINE);
eb5d44eb 1376
1377 return CMD_SUCCESS;
1378}
1379
3f045a08
JB
1380/*
1381 * This function supports following display options:
1382 * [ show isis database [detail] ]
1383 * [ show isis database <sysid> [detail] ]
1384 * [ show isis database <hostname> [detail] ]
1385 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1386 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1387 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1388 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1389 * [ show isis database detail <sysid> ]
1390 * [ show isis database detail <hostname> ]
1391 * [ show isis database detail <sysid>.<pseudo-id> ]
1392 * [ show isis database detail <hostname>.<pseudo-id> ]
1393 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1394 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1395 */
1396static int
1397show_isis_database (struct vty *vty, const char *argv, int ui_level)
eb5d44eb 1398{
3fdb2dd9 1399 struct listnode *node;
eb5d44eb 1400 struct isis_area *area;
3f045a08
JB
1401 struct isis_lsp *lsp;
1402 struct isis_dynhn *dynhn;
1403 const char *pos = argv;
1404 u_char lspid[ISIS_SYS_ID_LEN+2];
e38e0df0 1405 char sysid[255];
3f045a08 1406 u_char number[3];
eb5d44eb 1407 int level, lsp_count;
1408
1409 if (isis->area_list->count == 0)
1410 return CMD_SUCCESS;
1411
3f045a08 1412 memset (&lspid, 0, ISIS_SYS_ID_LEN);
e38e0df0 1413 memset (&sysid, 0, 255);
3f045a08
JB
1414
1415 /*
1416 * extract fragment and pseudo id from the string argv
1417 * in the forms:
1418 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1419 * (b) <systemid/hostname>.<pseudo-id> or
1420 * (c) <systemid/hostname> or
1421 * Where systemid is in the form:
1422 * xxxx.xxxx.xxxx
1423 */
e38e0df0
SV
1424 if (argv)
1425 strncpy (sysid, argv, 254);
3f045a08
JB
1426 if (argv && strlen (argv) > 3)
1427 {
1428 pos = argv + strlen (argv) - 3;
1429 if (strncmp (pos, "-", 1) == 0)
1430 {
1431 memcpy (number, ++pos, 2);
1432 lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16);
1433 pos -= 4;
1434 if (strncmp (pos, ".", 1) != 0)
1435 return CMD_ERR_AMBIGUOUS;
1436 }
1437 if (strncmp (pos, ".", 1) == 0)
1438 {
1439 memcpy (number, ++pos, 2);
1440 lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16);
1441 sysid[pos - argv - 1] = '\0';
1442 }
1443 }
1444
3fdb2dd9 1445 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
f390d2c7 1446 {
f390d2c7 1447 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
3f045a08 1448 VTY_NEWLINE);
f390d2c7 1449
3f045a08
JB
1450 for (level = 0; level < ISIS_LEVELS; level++)
1451 {
1452 if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
1453 {
1454 lsp = NULL;
1455 if (argv != NULL)
1456 {
1457 /*
1458 * Try to find the lsp-id if the argv string is in
1459 * the form hostname.<pseudo-id>-<fragment>
1460 */
1461 if (sysid2buff (lspid, sysid))
1462 {
1463 lsp = lsp_search (lspid, area->lspdb[level]);
1464 }
1465 else if ((dynhn = dynhn_find_by_name (sysid)))
1466 {
1467 memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN);
1468 lsp = lsp_search (lspid, area->lspdb[level]);
1469 }
1470 else if (strncmp(unix_hostname (), sysid, 15) == 0)
1471 {
1472 memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
1473 lsp = lsp_search (lspid, area->lspdb[level]);
1474 }
1475 }
1476
1477 if (lsp != NULL || argv == NULL)
1478 {
1479 vty_out (vty, "IS-IS Level-%d link-state database:%s",
1480 level + 1, VTY_NEWLINE);
1481
1482 /* print the title in all cases */
1483 vty_out (vty, "LSP ID PduLen "
1484 "SeqNumber Chksum Holdtime ATT/P/OL%s",
1485 VTY_NEWLINE);
1486 }
1487
1488 if (lsp)
1489 {
1490 if (ui_level == ISIS_UI_LEVEL_DETAIL)
1491 lsp_print_detail (lsp, vty, area->dynhostname);
1492 else
1493 lsp_print (lsp, vty, area->dynhostname);
1494 }
1495 else if (argv == NULL)
1496 {
1497 lsp_count = lsp_print_all (vty, area->lspdb[level],
1498 ui_level,
1499 area->dynhostname);
1500
1501 vty_out (vty, " %u LSPs%s%s",
1502 lsp_count, VTY_NEWLINE, VTY_NEWLINE);
1503 }
1504 }
1505 }
eb5d44eb 1506 }
eb5d44eb 1507
1508 return CMD_SUCCESS;
1509}
1510
3f045a08
JB
1511DEFUN (show_database_brief,
1512 show_database_cmd,
1513 "show isis database",
1514 SHOW_STR
1515 "IS-IS information\n"
1516 "IS-IS link state database\n")
eb5d44eb 1517{
3f045a08 1518 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_BRIEF);
eb5d44eb 1519}
1520
3f045a08
JB
1521DEFUN (show_database_lsp_brief,
1522 show_database_arg_cmd,
1523 "show isis database WORD",
1524 SHOW_STR
1525 "IS-IS information\n"
1526 "IS-IS link state database\n"
1527 "LSP ID\n")
1528{
1529 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_BRIEF);
1530}
1531
1532DEFUN (show_database_lsp_detail,
1533 show_database_arg_detail_cmd,
1534 "show isis database WORD detail",
1535 SHOW_STR
1536 "IS-IS information\n"
1537 "IS-IS link state database\n"
1538 "LSP ID\n"
1539 "Detailed information\n")
1540{
1541 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
1542}
1543
1544DEFUN (show_database_detail,
1545 show_database_detail_cmd,
1546 "show isis database detail",
1547 SHOW_STR
1548 "IS-IS information\n"
1549 "IS-IS link state database\n")
1550{
1551 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_DETAIL);
1552}
1553
1554DEFUN (show_database_detail_lsp,
1555 show_database_detail_arg_cmd,
1556 "show isis database detail WORD",
1557 SHOW_STR
1558 "IS-IS information\n"
1559 "IS-IS link state database\n"
1560 "Detailed information\n"
1561 "LSP ID\n")
1562{
1563 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
1564}
1565
1566/*
1567 * 'router isis' command
1568 */
1569DEFUN (router_isis,
1570 router_isis_cmd,
1571 "router isis WORD",
1572 ROUTER_STR
1573 "ISO IS-IS\n"
1574 "ISO Routing area tag")
1575{
1576 return isis_area_get (vty, argv[0]);
1577}
1578
1579/*
1580 *'no router isis' command
1581 */
1582DEFUN (no_router_isis,
1583 no_router_isis_cmd,
1584 "no router isis WORD",
f390d2c7 1585 "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
eb5d44eb 1586{
1587 return isis_area_destroy (vty, argv[0]);
1588}
1589
1590/*
1591 * 'net' command
1592 */
1593DEFUN (net,
1594 net_cmd,
1595 "net WORD",
1596 "A Network Entity Title for this process (OSI only)\n"
f390d2c7 1597 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
eb5d44eb 1598{
41b36e90 1599 return area_net_title (vty, argv[0]);
eb5d44eb 1600}
1601
eb5d44eb 1602/*
1603 * 'no net' command
1604 */
1605DEFUN (no_net,
1606 no_net_cmd,
1607 "no net WORD",
1608 NO_STR
1609 "A Network Entity Title for this process (OSI only)\n"
f390d2c7 1610 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
eb5d44eb 1611{
41b36e90 1612 return area_clear_net_title (vty, argv[0]);
eb5d44eb 1613}
1614
b20ccb3a
CF
1615static
1616int area_set_lsp_mtu(struct vty *vty, struct isis_area *area, unsigned int lsp_mtu)
1617{
1618 struct isis_circuit *circuit;
1619 struct listnode *node;
1620
1621 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
1622 {
be2fdb51
CF
1623 if(circuit->state != C_STATE_INIT && circuit->state != C_STATE_UP)
1624 continue;
b20ccb3a
CF
1625 if(lsp_mtu > isis_circuit_pdu_size(circuit))
1626 {
1627 vty_out(vty, "ISIS area contains circuit %s, which has a maximum PDU size of %zu.%s",
1628 circuit->interface->name, isis_circuit_pdu_size(circuit),
1629 VTY_NEWLINE);
1630 return CMD_ERR_AMBIGUOUS;
1631 }
1632 }
1633
1634 area->lsp_mtu = lsp_mtu;
1635 lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
1636
1637 return CMD_SUCCESS;
1638}
1639
1640DEFUN (area_lsp_mtu,
1641 area_lsp_mtu_cmd,
1642 "lsp-mtu <128-4352>",
1643 "Configure the maximum size of generated LSPs\n"
1644 "Maximum size of generated LSPs\n")
1645{
1646 struct isis_area *area;
1647
1648 area = vty->index;
1649 if (!area)
1650 {
1651 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1652 return CMD_ERR_NO_MATCH;
1653 }
1654
1655 unsigned int lsp_mtu;
1656
1657 VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[0], 128, 4352);
1658
1659 return area_set_lsp_mtu(vty, area, lsp_mtu);
1660}
1661
1662DEFUN(no_area_lsp_mtu,
1663 no_area_lsp_mtu_cmd,
1664 "no lsp-mtu",
1665 NO_STR
1666 "Configure the maximum size of generated LSPs\n")
1667{
1668 struct isis_area *area;
1669
1670 area = vty->index;
1671 if (!area)
1672 {
1673 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1674 return CMD_ERR_NO_MATCH;
1675 }
1676
1677 return area_set_lsp_mtu(vty, area, DEFAULT_LSP_MTU);
1678}
1679
1680ALIAS(no_area_lsp_mtu,
1681 no_area_lsp_mtu_arg_cmd,
1682 "no lsp-mtu <128-4352>",
1683 NO_STR
1684 "Configure the maximum size of generated LSPs\n"
1685 "Maximum size of generated LSPs\n");
1686
3f045a08
JB
1687DEFUN (area_passwd_md5,
1688 area_passwd_md5_cmd,
1689 "area-password md5 WORD",
1690 "Configure the authentication password for an area\n"
1691 "Authentication type\n"
1692 "Area password\n")
1693{
1694 struct isis_area *area;
1695 int len;
1696
1697 area = vty->index;
1698
1699 if (!area)
1700 {
1701 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1702 return CMD_ERR_NO_MATCH;
1703 }
1704
1705 len = strlen (argv[0]);
1706 if (len > 254)
1707 {
1708 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1709 return CMD_ERR_AMBIGUOUS;
1710 }
1711
1712 area->area_passwd.len = (u_char) len;
1713 area->area_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1714 strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
1715
1716 if (argc > 1)
1717 {
1718 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1719 if (strncmp(argv[1], "v", 1) == 0)
1720 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1721 else
1722 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1723 }
1724 else
1725 {
1726 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1727 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1728 }
1729 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1730
1731 return CMD_SUCCESS;
1732}
1733
1734ALIAS (area_passwd_md5,
1735 area_passwd_md5_snpauth_cmd,
1736 "area-password md5 WORD authenticate snp (send-only|validate)",
1737 "Configure the authentication password for an area\n"
1738 "Authentication type\n"
1739 "Area password\n"
1740 "Authentication\n"
1741 "SNP PDUs\n"
1742 "Send but do not check PDUs on receiving\n"
010e1aa6 1743 "Send and check PDUs on receiving\n")
3f045a08
JB
1744
1745DEFUN (area_passwd_clear,
1746 area_passwd_clear_cmd,
1747 "area-password clear WORD",
eb5d44eb 1748 "Configure the authentication password for an area\n"
3f045a08 1749 "Authentication type\n"
f390d2c7 1750 "Area password\n")
eb5d44eb 1751{
1752 struct isis_area *area;
1753 int len;
1754
1755 area = vty->index;
1756
f390d2c7 1757 if (!area)
1758 {
3f045a08
JB
1759 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1760 return CMD_ERR_NO_MATCH;
f390d2c7 1761 }
1762
eb5d44eb 1763 len = strlen (argv[0]);
f390d2c7 1764 if (len > 254)
1765 {
1766 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
3f045a08 1767 return CMD_ERR_AMBIGUOUS;
f390d2c7 1768 }
3f045a08 1769
f390d2c7 1770 area->area_passwd.len = (u_char) len;
eb5d44eb 1771 area->area_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
f7c43dcb 1772 strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
f390d2c7 1773
1cbc562b 1774 if (argc > 1)
1775 {
1776 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1777 if (strncmp(argv[1], "v", 1) == 0)
1778 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1779 else
1780 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1781 }
1782 else
1783 {
1784 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1785 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1786 }
3f045a08 1787 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1cbc562b 1788
eb5d44eb 1789 return CMD_SUCCESS;
1790}
1791
3f045a08
JB
1792ALIAS (area_passwd_clear,
1793 area_passwd_clear_snpauth_cmd,
1794 "area-password clear WORD authenticate snp (send-only|validate)",
1cbc562b 1795 "Configure the authentication password for an area\n"
3f045a08 1796 "Authentication type\n"
1cbc562b 1797 "Area password\n"
1798 "Authentication\n"
1799 "SNP PDUs\n"
1800 "Send but do not check PDUs on receiving\n"
010e1aa6 1801 "Send and check PDUs on receiving\n")
1cbc562b 1802
eb5d44eb 1803DEFUN (no_area_passwd,
1804 no_area_passwd_cmd,
1805 "no area-password",
1806 NO_STR
1807 "Configure the authentication password for an area\n")
1808{
1809 struct isis_area *area;
f390d2c7 1810
eb5d44eb 1811 area = vty->index;
1812
f390d2c7 1813 if (!area)
1814 {
3f045a08
JB
1815 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1816 return CMD_ERR_NO_MATCH;
f390d2c7 1817 }
1818
eb5d44eb 1819 memset (&area->area_passwd, 0, sizeof (struct isis_passwd));
3f045a08
JB
1820 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1821
1822 return CMD_SUCCESS;
1823}
1824
1825DEFUN (domain_passwd_md5,
1826 domain_passwd_md5_cmd,
1827 "domain-password md5 WORD",
1828 "Set the authentication password for a routing domain\n"
1829 "Authentication type\n"
1830 "Routing domain password\n")
1831{
1832 struct isis_area *area;
1833 int len;
1834
1835 area = vty->index;
1836
1837 if (!area)
1838 {
1839 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1840 return CMD_ERR_NO_MATCH;
1841 }
1842
1843 len = strlen (argv[0]);
1844 if (len > 254)
1845 {
1846 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1847 return CMD_ERR_AMBIGUOUS;
1848 }
1849
1850 area->domain_passwd.len = (u_char) len;
1851 area->domain_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1852 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
1853
1854 if (argc > 1)
1855 {
1856 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1857 if (strncmp(argv[1], "v", 1) == 0)
1858 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1859 else
1860 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1861 }
1862 else
1863 {
1864 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1865 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1866 }
1867 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
eb5d44eb 1868
1869 return CMD_SUCCESS;
1870}
1871
3f045a08
JB
1872ALIAS (domain_passwd_md5,
1873 domain_passwd_md5_snpauth_cmd,
1874 "domain-password md5 WORD authenticate snp (send-only|validate)",
1875 "Set the authentication password for a routing domain\n"
1876 "Authentication type\n"
1877 "Routing domain password\n"
1878 "Authentication\n"
1879 "SNP PDUs\n"
1880 "Send but do not check PDUs on receiving\n"
010e1aa6 1881 "Send and check PDUs on receiving\n")
3f045a08
JB
1882
1883DEFUN (domain_passwd_clear,
1884 domain_passwd_clear_cmd,
1885 "domain-password clear WORD",
eb5d44eb 1886 "Set the authentication password for a routing domain\n"
3f045a08 1887 "Authentication type\n"
f390d2c7 1888 "Routing domain password\n")
eb5d44eb 1889{
1890 struct isis_area *area;
1891 int len;
1892
1893 area = vty->index;
1894
f390d2c7 1895 if (!area)
1896 {
3f045a08
JB
1897 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1898 return CMD_ERR_NO_MATCH;
f390d2c7 1899 }
1900
eb5d44eb 1901 len = strlen (argv[0]);
f390d2c7 1902 if (len > 254)
1903 {
1904 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
3f045a08 1905 return CMD_ERR_AMBIGUOUS;
f390d2c7 1906 }
3f045a08 1907
f390d2c7 1908 area->domain_passwd.len = (u_char) len;
eb5d44eb 1909 area->domain_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
f7c43dcb 1910 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
f390d2c7 1911
1cbc562b 1912 if (argc > 1)
1913 {
1914 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1915 if (strncmp(argv[1], "v", 1) == 0)
1916 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1917 else
1918 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1919 }
1920 else
1921 {
1922 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1923 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1924 }
3f045a08 1925 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1cbc562b 1926
eb5d44eb 1927 return CMD_SUCCESS;
1928}
1929
3f045a08
JB
1930ALIAS (domain_passwd_clear,
1931 domain_passwd_clear_snpauth_cmd,
1932 "domain-password clear WORD authenticate snp (send-only|validate)",
1cbc562b 1933 "Set the authentication password for a routing domain\n"
3f045a08 1934 "Authentication type\n"
1cbc562b 1935 "Routing domain password\n"
1936 "Authentication\n"
1937 "SNP PDUs\n"
1938 "Send but do not check PDUs on receiving\n"
010e1aa6 1939 "Send and check PDUs on receiving\n")
1cbc562b 1940
eb5d44eb 1941DEFUN (no_domain_passwd,
1942 no_domain_passwd_cmd,
3f045a08 1943 "no domain-password",
eb5d44eb 1944 NO_STR
1945 "Set the authentication password for a routing domain\n")
1946{
1947 struct isis_area *area;
f390d2c7 1948
eb5d44eb 1949 area = vty->index;
1950
f390d2c7 1951 if (!area)
1952 {
3f045a08
JB
1953 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1954 return CMD_ERR_NO_MATCH;
f390d2c7 1955 }
1956
eb5d44eb 1957 memset (&area->domain_passwd, 0, sizeof (struct isis_passwd));
3f045a08 1958 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
f390d2c7 1959
eb5d44eb 1960 return CMD_SUCCESS;
1961}
1962
1963DEFUN (is_type,
1964 is_type_cmd,
1965 "is-type (level-1|level-1-2|level-2-only)",
1966 "IS Level for this routing process (OSI only)\n"
1967 "Act as a station router only\n"
1968 "Act as both a station router and an area router\n"
1969 "Act as an area router only\n")
1970{
1971 struct isis_area *area;
1972 int type;
1973
1974 area = vty->index;
1975
f390d2c7 1976 if (!area)
1977 {
3f045a08
JB
1978 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1979 return CMD_ERR_NO_MATCH;
f390d2c7 1980 }
eb5d44eb 1981
41b36e90 1982 type = string2circuit_t (argv[0]);
f390d2c7 1983 if (!type)
1984 {
1985 vty_out (vty, "Unknown IS level %s", VTY_NEWLINE);
1986 return CMD_SUCCESS;
1987 }
eb5d44eb 1988
1989 isis_event_system_type_change (area, type);
f390d2c7 1990
eb5d44eb 1991 return CMD_SUCCESS;
1992}
1993
1994DEFUN (no_is_type,
1995 no_is_type_cmd,
1996 "no is-type (level-1|level-1-2|level-2-only)",
1997 NO_STR
1998 "IS Level for this routing process (OSI only)\n"
1999 "Act as a station router only\n"
2000 "Act as both a station router and an area router\n"
2001 "Act as an area router only\n")
2002{
eb5d44eb 2003 struct isis_area *area;
2004 int type;
2005
2006 area = vty->index;
2007 assert (area);
f390d2c7 2008
eb5d44eb 2009 /*
3f045a08
JB
2010 * Put the is-type back to defaults:
2011 * - level-1-2 on first area
2012 * - level-1 for the rest
eb5d44eb 2013 */
1eb8ef25 2014 if (listgetdata (listhead (isis->area_list)) == area)
eb5d44eb 2015 type = IS_LEVEL_1_AND_2;
2016 else
2017 type = IS_LEVEL_1;
2018
2019 isis_event_system_type_change (area, type);
2020
2021 return CMD_SUCCESS;
2022}
2023
3f045a08
JB
2024static int
2025set_lsp_gen_interval (struct vty *vty, struct isis_area *area,
2026 uint16_t interval, int level)
2027{
2028 int lvl;
2029
2030 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2031 {
2032 if (!(lvl & level))
2033 continue;
2034
2035 if (interval >= area->lsp_refresh[lvl-1])
2036 {
2037 vty_out (vty, "LSP gen interval %us must be less than "
2038 "the LSP refresh interval %us%s",
2039 interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
2040 return CMD_ERR_AMBIGUOUS;
2041 }
2042 }
2043
2044 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2045 {
2046 if (!(lvl & level))
2047 continue;
2048 area->lsp_gen_interval[lvl-1] = interval;
2049 }
2050
2051 return CMD_SUCCESS;
2052}
2053
eb5d44eb 2054DEFUN (lsp_gen_interval,
2055 lsp_gen_interval_cmd,
2056 "lsp-gen-interval <1-120>",
2057 "Minimum interval between regenerating same LSP\n"
2058 "Minimum interval in seconds\n")
2059{
2060 struct isis_area *area;
2061 uint16_t interval;
3f045a08 2062 int level;
eb5d44eb 2063
2064 area = vty->index;
eb5d44eb 2065 interval = atoi (argv[0]);
3f045a08
JB
2066 level = IS_LEVEL_1 | IS_LEVEL_2;
2067 return set_lsp_gen_interval (vty, area, interval, level);
eb5d44eb 2068}
2069
2070DEFUN (no_lsp_gen_interval,
2071 no_lsp_gen_interval_cmd,
2072 "no lsp-gen-interval",
2073 NO_STR
f390d2c7 2074 "Minimum interval between regenerating same LSP\n")
eb5d44eb 2075{
2076 struct isis_area *area;
3f045a08
JB
2077 uint16_t interval;
2078 int level;
eb5d44eb 2079
2080 area = vty->index;
3f045a08
JB
2081 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2082 level = IS_LEVEL_1 | IS_LEVEL_2;
2083 return set_lsp_gen_interval (vty, area, interval, level);
eb5d44eb 2084}
2085
2086ALIAS (no_lsp_gen_interval,
2087 no_lsp_gen_interval_arg_cmd,
2088 "no lsp-gen-interval <1-120>",
2089 NO_STR
2090 "Minimum interval between regenerating same LSP\n"
f390d2c7 2091 "Minimum interval in seconds\n")
eb5d44eb 2092
2093DEFUN (lsp_gen_interval_l1,
2094 lsp_gen_interval_l1_cmd,
2095 "lsp-gen-interval level-1 <1-120>",
2096 "Minimum interval between regenerating same LSP\n"
2097 "Set interval for level 1 only\n"
f390d2c7 2098 "Minimum interval in seconds\n")
eb5d44eb 2099{
2100 struct isis_area *area;
2101 uint16_t interval;
3f045a08 2102 int level;
eb5d44eb 2103
2104 area = vty->index;
eb5d44eb 2105 interval = atoi (argv[0]);
3f045a08
JB
2106 level = IS_LEVEL_1;
2107 return set_lsp_gen_interval (vty, area, interval, level);
eb5d44eb 2108}
2109
2110DEFUN (no_lsp_gen_interval_l1,
2111 no_lsp_gen_interval_l1_cmd,
2112 "no lsp-gen-interval level-1",
2113 NO_STR
2114 "Minimum interval between regenerating same LSP\n"
f390d2c7 2115 "Set interval for level 1 only\n")
eb5d44eb 2116{
2117 struct isis_area *area;
3f045a08
JB
2118 uint16_t interval;
2119 int level;
eb5d44eb 2120
2121 area = vty->index;
3f045a08
JB
2122 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2123 level = IS_LEVEL_1;
2124 return set_lsp_gen_interval (vty, area, interval, level);
eb5d44eb 2125}
2126
2127ALIAS (no_lsp_gen_interval_l1,
2128 no_lsp_gen_interval_l1_arg_cmd,
2129 "no lsp-gen-interval level-1 <1-120>",
2130 NO_STR
2131 "Minimum interval between regenerating same LSP\n"
2132 "Set interval for level 1 only\n"
f390d2c7 2133 "Minimum interval in seconds\n")
eb5d44eb 2134
2135DEFUN (lsp_gen_interval_l2,
2136 lsp_gen_interval_l2_cmd,
2137 "lsp-gen-interval level-2 <1-120>",
2138 "Minimum interval between regenerating same LSP\n"
2139 "Set interval for level 2 only\n"
f390d2c7 2140 "Minimum interval in seconds\n")
eb5d44eb 2141{
2142 struct isis_area *area;
3f045a08
JB
2143 uint16_t interval;
2144 int level;
eb5d44eb 2145
2146 area = vty->index;
eb5d44eb 2147 interval = atoi (argv[0]);
3f045a08
JB
2148 level = IS_LEVEL_2;
2149 return set_lsp_gen_interval (vty, area, interval, level);
eb5d44eb 2150}
2151
2152DEFUN (no_lsp_gen_interval_l2,
2153 no_lsp_gen_interval_l2_cmd,
2154 "no lsp-gen-interval level-2",
2155 NO_STR
2156 "Minimum interval between regenerating same LSP\n"
f390d2c7 2157 "Set interval for level 2 only\n")
eb5d44eb 2158{
2159 struct isis_area *area;
3f045a08
JB
2160 uint16_t interval;
2161 int level;
eb5d44eb 2162
2163 area = vty->index;
3f045a08
JB
2164 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2165 level = IS_LEVEL_2;
2166 return set_lsp_gen_interval (vty, area, interval, level);
eb5d44eb 2167}
2168
2169ALIAS (no_lsp_gen_interval_l2,
2170 no_lsp_gen_interval_l2_arg_cmd,
2171 "no lsp-gen-interval level-2 <1-120>",
2172 NO_STR
2173 "Minimum interval between regenerating same LSP\n"
2174 "Set interval for level 2 only\n"
f390d2c7 2175 "Minimum interval in seconds\n")
eb5d44eb 2176
e38e0df0
SV
2177static int
2178validate_metric_style_narrow (struct vty *vty, struct isis_area *area)
2179{
2180 struct isis_circuit *circuit;
2181 struct listnode *node;
2182
2183 if (! vty)
2184 return CMD_ERR_AMBIGUOUS;
2185
2186 if (! area)
2187 {
2188 vty_out (vty, "ISIS area is invalid%s", VTY_NEWLINE);
2189 return CMD_ERR_AMBIGUOUS;
2190 }
2191
2192 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
2193 {
2194 if ((area->is_type & IS_LEVEL_1) &&
2195 (circuit->is_type & IS_LEVEL_1) &&
4fb7c84f 2196 (circuit->te_metric[0] > MAX_NARROW_LINK_METRIC))
e38e0df0
SV
2197 {
2198 vty_out (vty, "ISIS circuit %s metric is invalid%s",
2199 circuit->interface->name, VTY_NEWLINE);
2200 return CMD_ERR_AMBIGUOUS;
2201 }
2202 if ((area->is_type & IS_LEVEL_2) &&
2203 (circuit->is_type & IS_LEVEL_2) &&
4fb7c84f 2204 (circuit->te_metric[1] > MAX_NARROW_LINK_METRIC))
e38e0df0
SV
2205 {
2206 vty_out (vty, "ISIS circuit %s metric is invalid%s",
2207 circuit->interface->name, VTY_NEWLINE);
2208 return CMD_ERR_AMBIGUOUS;
2209 }
2210 }
2211
2212 return CMD_SUCCESS;
2213}
2214
eb5d44eb 2215DEFUN (metric_style,
2216 metric_style_cmd,
2984d26e 2217 "metric-style (narrow|transition|wide)",
eb5d44eb 2218 "Use old-style (ISO 10589) or new-style packet formats\n"
2219 "Use old style of TLVs with narrow metric\n"
2984d26e 2220 "Send and accept both styles of TLVs during transition\n"
eb5d44eb 2221 "Use new style of TLVs to carry wider metric\n")
2222{
2223 struct isis_area *area;
e38e0df0 2224 int ret;
eb5d44eb 2225
2226 area = vty->index;
2227 assert (area);
2984d26e 2228
2229 if (strncmp (argv[0], "w", 1) == 0)
2230 {
2231 area->newmetric = 1;
2232 area->oldmetric = 0;
2233 }
478c1125 2234 else
2984d26e 2235 {
e38e0df0
SV
2236 ret = validate_metric_style_narrow (vty, area);
2237 if (ret != CMD_SUCCESS)
2238 return ret;
2239
478c1125
CF
2240 if (strncmp (argv[0], "t", 1) == 0)
2241 {
2242 area->newmetric = 1;
2243 area->oldmetric = 1;
2244 }
2245 else if (strncmp (argv[0], "n", 1) == 0)
2246 {
2247 area->newmetric = 0;
2248 area->oldmetric = 1;
2249 }
2984d26e 2250 }
eb5d44eb 2251
2252 return CMD_SUCCESS;
2253}
2254
2255DEFUN (no_metric_style,
2256 no_metric_style_cmd,
2984d26e 2257 "no metric-style",
eb5d44eb 2258 NO_STR
2984d26e 2259 "Use old-style (ISO 10589) or new-style packet formats\n")
eb5d44eb 2260{
2261 struct isis_area *area;
e38e0df0 2262 int ret;
eb5d44eb 2263
2264 area = vty->index;
2265 assert (area);
2266
e38e0df0
SV
2267 ret = validate_metric_style_narrow (vty, area);
2268 if (ret != CMD_SUCCESS)
2269 return ret;
2270
2984d26e 2271 /* Default is narrow metric. */
2272 area->newmetric = 0;
2273 area->oldmetric = 1;
eb5d44eb 2274
2275 return CMD_SUCCESS;
2276}
2277
3f045a08
JB
2278DEFUN (set_overload_bit,
2279 set_overload_bit_cmd,
2280 "set-overload-bit",
2281 "Set overload bit to avoid any transit traffic\n"
2282 "Set overload bit\n")
2283{
2284 struct isis_area *area;
2285
2286 area = vty->index;
2287 assert (area);
2288
2289 area->overload_bit = LSPBIT_OL;
2290 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2291
2292 return CMD_SUCCESS;
2293}
2294
2295DEFUN (no_set_overload_bit,
2296 no_set_overload_bit_cmd,
2297 "no set-overload-bit",
2298 "Reset overload bit to accept transit traffic\n"
2299 "Reset overload bit\n")
2300{
2301 struct isis_area *area;
2302
2303 area = vty->index;
2304 assert (area);
2305
2306 area->overload_bit = 0;
2307 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2308
2309 return CMD_SUCCESS;
2310}
2311
7ed55a41
AN
2312DEFUN (set_attached_bit,
2313 set_attached_bit_cmd,
2314 "set-attached-bit",
2315 "Set attached bit to identify as L1/L2 router for inter-area traffic\n"
2316 "Set attached bit\n")
2317{
2318 struct isis_area *area;
2319
2320 area = vty->index;
2321 assert (area);
2322
2323 area->attached_bit = LSPBIT_ATT;
2324 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2325
2326 return CMD_SUCCESS;
2327}
2328
2329DEFUN (no_set_attached_bit,
2330 no_set_attached_bit_cmd,
2331 "no set-attached-bit",
2332 "Reset attached bit\n")
2333{
2334 struct isis_area *area;
2335
2336 area = vty->index;
2337 assert (area);
2338
2339 area->attached_bit = 0;
2340 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2341
2342 return CMD_SUCCESS;
2343}
2344
eb5d44eb 2345DEFUN (dynamic_hostname,
2346 dynamic_hostname_cmd,
2347 "hostname dynamic",
2348 "Dynamic hostname for IS-IS\n"
f390d2c7 2349 "Dynamic hostname\n")
eb5d44eb 2350{
2351 struct isis_area *area;
2352
2353 area = vty->index;
2354 assert (area);
f390d2c7 2355
3f045a08
JB
2356 if (!area->dynhostname)
2357 {
2358 area->dynhostname = 1;
2359 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
2360 }
f390d2c7 2361
eb5d44eb 2362 return CMD_SUCCESS;
2363}
2364
2365DEFUN (no_dynamic_hostname,
2366 no_dynamic_hostname_cmd,
2367 "no hostname dynamic",
2368 NO_STR
2369 "Dynamic hostname for IS-IS\n"
f390d2c7 2370 "Dynamic hostname\n")
eb5d44eb 2371{
2372 struct isis_area *area;
2373
2374 area = vty->index;
2375 assert (area);
f390d2c7 2376
3f045a08
JB
2377 if (area->dynhostname)
2378 {
2379 area->dynhostname = 0;
2380 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
2381 }
f390d2c7 2382
eb5d44eb 2383 return CMD_SUCCESS;
2384}
2385
2386DEFUN (spf_interval,
2387 spf_interval_cmd,
2388 "spf-interval <1-120>",
2097cd8a 2389 "Minimum interval between SPF calculations\n"
eb5d44eb 2390 "Minimum interval between consecutive SPFs in seconds\n")
2391{
2392 struct isis_area *area;
2393 u_int16_t interval;
f390d2c7 2394
eb5d44eb 2395 area = vty->index;
2396 interval = atoi (argv[0]);
2397 area->min_spf_interval[0] = interval;
2398 area->min_spf_interval[1] = interval;
f390d2c7 2399
eb5d44eb 2400 return CMD_SUCCESS;
2401}
2402
2403DEFUN (no_spf_interval,
2404 no_spf_interval_cmd,
2405 "no spf-interval",
2406 NO_STR
f390d2c7 2407 "Minimum interval between SPF calculations\n")
eb5d44eb 2408{
2409 struct isis_area *area;
f390d2c7 2410
eb5d44eb 2411 area = vty->index;
2412
2413 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
2414 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
f390d2c7 2415
eb5d44eb 2416 return CMD_SUCCESS;
2417}
2418
2419ALIAS (no_spf_interval,
2420 no_spf_interval_arg_cmd,
2421 "no spf-interval <1-120>",
2422 NO_STR
2423 "Minimum interval between SPF calculations\n"
f390d2c7 2424 "Minimum interval between consecutive SPFs in seconds\n")
eb5d44eb 2425
2426DEFUN (spf_interval_l1,
2427 spf_interval_l1_cmd,
2428 "spf-interval level-1 <1-120>",
2429 "Minimum interval between SPF calculations\n"
2430 "Set interval for level 1 only\n"
2431 "Minimum interval between consecutive SPFs in seconds\n")
2432{
2433 struct isis_area *area;
2434 u_int16_t interval;
f390d2c7 2435
eb5d44eb 2436 area = vty->index;
2437 interval = atoi (argv[0]);
2438 area->min_spf_interval[0] = interval;
f390d2c7 2439
eb5d44eb 2440 return CMD_SUCCESS;
2441}
2442
2443DEFUN (no_spf_interval_l1,
2444 no_spf_interval_l1_cmd,
2445 "no spf-interval level-1",
2446 NO_STR
2447 "Minimum interval between SPF calculations\n"
2448 "Set interval for level 1 only\n")
2449{
2450 struct isis_area *area;
f390d2c7 2451
eb5d44eb 2452 area = vty->index;
2453
2454 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
f390d2c7 2455
eb5d44eb 2456 return CMD_SUCCESS;
2457}
2458
2459ALIAS (no_spf_interval,
2460 no_spf_interval_l1_arg_cmd,
2461 "no spf-interval level-1 <1-120>",
2462 NO_STR
2463 "Minimum interval between SPF calculations\n"
2464 "Set interval for level 1 only\n"
2465 "Minimum interval between consecutive SPFs in seconds\n")
2466
2467DEFUN (spf_interval_l2,
2468 spf_interval_l2_cmd,
2469 "spf-interval level-2 <1-120>",
2470 "Minimum interval between SPF calculations\n"
2471 "Set interval for level 2 only\n"
2472 "Minimum interval between consecutive SPFs in seconds\n")
2473{
2474 struct isis_area *area;
2475 u_int16_t interval;
f390d2c7 2476
eb5d44eb 2477 area = vty->index;
2478 interval = atoi (argv[0]);
2479 area->min_spf_interval[1] = interval;
f390d2c7 2480
eb5d44eb 2481 return CMD_SUCCESS;
2482}
2483
2484DEFUN (no_spf_interval_l2,
2485 no_spf_interval_l2_cmd,
2486 "no spf-interval level-2",
2487 NO_STR
2488 "Minimum interval between SPF calculations\n"
2489 "Set interval for level 2 only\n")
2490{
2491 struct isis_area *area;
f390d2c7 2492
eb5d44eb 2493 area = vty->index;
2494
2495 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
f390d2c7 2496
eb5d44eb 2497 return CMD_SUCCESS;
2498}
2499
2500ALIAS (no_spf_interval,
2501 no_spf_interval_l2_arg_cmd,
2502 "no spf-interval level-2 <1-120>",
2503 NO_STR
2504 "Minimum interval between SPF calculations\n"
2505 "Set interval for level 2 only\n"
2506 "Minimum interval between consecutive SPFs in seconds\n")
2507
3f045a08
JB
2508static int
2509set_lsp_max_lifetime (struct vty *vty, struct isis_area *area,
2510 uint16_t interval, int level)
eb5d44eb 2511{
3f045a08
JB
2512 int lvl;
2513 int set_refresh_interval[ISIS_LEVELS] = {0, 0};
2514 uint16_t refresh_interval;
eb5d44eb 2515
3f045a08 2516 refresh_interval = interval - 300;
eb5d44eb 2517
3f045a08 2518 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
f390d2c7 2519 {
3f045a08
JB
2520 if (!(lvl & level))
2521 continue;
2522 if (refresh_interval < area->lsp_refresh[lvl-1])
2523 {
2524 vty_out (vty, "Level %d Max LSP lifetime %us must be 300s greater than "
2525 "the configured LSP refresh interval %us%s",
2526 lvl, interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
2527 vty_out (vty, "Automatically reducing level %d LSP refresh interval "
2528 "to %us%s", lvl, refresh_interval, VTY_NEWLINE);
2529 set_refresh_interval[lvl-1] = 1;
2530
2531 if (refresh_interval <= area->lsp_gen_interval[lvl-1])
2532 {
2533 vty_out (vty, "LSP refresh interval %us must be greater than "
2534 "the configured LSP gen interval %us%s",
2535 refresh_interval, area->lsp_gen_interval[lvl-1],
2536 VTY_NEWLINE);
2537 return CMD_ERR_AMBIGUOUS;
2538 }
2539 }
2540 }
2541
2542 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
2543 {
2544 if (!(lvl & level))
2545 continue;
2546 area->max_lsp_lifetime[lvl-1] = interval;
2547 /* Automatically reducing lsp_refresh_interval to interval - 300 */
2548 if (set_refresh_interval[lvl-1])
2549 area->lsp_refresh[lvl-1] = refresh_interval;
f390d2c7 2550 }
eb5d44eb 2551
3f045a08
JB
2552 lsp_regenerate_schedule (area, level, 1);
2553
eb5d44eb 2554 return CMD_SUCCESS;
2555}
2556
3f045a08
JB
2557DEFUN (max_lsp_lifetime,
2558 max_lsp_lifetime_cmd,
2559 "max-lsp-lifetime <350-65535>",
2560 "Maximum LSP lifetime\n"
2561 "LSP lifetime in seconds\n")
eb5d44eb 2562{
2563 struct isis_area *area;
3f045a08
JB
2564 uint16_t interval;
2565 int level;
f1082d19 2566
3f045a08
JB
2567 area = vty->index;
2568 interval = atoi (argv[0]);
2569 level = IS_LEVEL_1 | IS_LEVEL_2;
2570 return set_lsp_max_lifetime (vty, area, interval, level);
2571}
f1082d19 2572
3f045a08
JB
2573DEFUN (no_max_lsp_lifetime,
2574 no_max_lsp_lifetime_cmd,
2575 "no max-lsp-lifetime",
2576 NO_STR
2577 "LSP lifetime in seconds\n")
eb5d44eb 2578{
2579 struct isis_area *area;
3f045a08
JB
2580 uint16_t interval;
2581 int level;
eb5d44eb 2582
2583 area = vty->index;
3f045a08
JB
2584 interval = DEFAULT_LSP_LIFETIME;
2585 level = IS_LEVEL_1 | IS_LEVEL_2;
2586 return set_lsp_max_lifetime (vty, area, interval, level);
eb5d44eb 2587}
2588
3f045a08
JB
2589ALIAS (no_max_lsp_lifetime,
2590 no_max_lsp_lifetime_arg_cmd,
2591 "no max-lsp-lifetime <350-65535>",
eb5d44eb 2592 NO_STR
3f045a08
JB
2593 "Maximum LSP lifetime\n"
2594 "LSP lifetime in seconds\n")
2595
2596DEFUN (max_lsp_lifetime_l1,
2597 max_lsp_lifetime_l1_cmd,
2598 "max-lsp-lifetime level-1 <350-65535>",
2599 "Maximum LSP lifetime for Level 1 only\n"
2600 "LSP lifetime for Level 1 only in seconds\n")
eb5d44eb 2601{
2602 struct isis_area *area;
3f045a08
JB
2603 uint16_t interval;
2604 int level;
eb5d44eb 2605
2606 area = vty->index;
3f045a08
JB
2607 interval = atoi (argv[0]);
2608 level = IS_LEVEL_1;
2609 return set_lsp_max_lifetime (vty, area, interval, level);
eb5d44eb 2610}
2611
3f045a08
JB
2612DEFUN (no_max_lsp_lifetime_l1,
2613 no_max_lsp_lifetime_l1_cmd,
2614 "no max-lsp-lifetime level-1",
f1082d19 2615 NO_STR
3f045a08 2616 "LSP lifetime for Level 1 only in seconds\n")
f1082d19 2617{
2618 struct isis_area *area;
3f045a08
JB
2619 uint16_t interval;
2620 int level;
f1082d19 2621
2622 area = vty->index;
3f045a08
JB
2623 interval = DEFAULT_LSP_LIFETIME;
2624 level = IS_LEVEL_1;
2625 return set_lsp_max_lifetime (vty, area, interval, level);
f1082d19 2626}
eb5d44eb 2627
3f045a08
JB
2628ALIAS (no_max_lsp_lifetime_l1,
2629 no_max_lsp_lifetime_l1_arg_cmd,
2630 "no max-lsp-lifetime level-1 <350-65535>",
2631 NO_STR
2632 "Maximum LSP lifetime for Level 1 only\n"
2633 "LSP lifetime for Level 1 only in seconds\n")
2634
2635DEFUN (max_lsp_lifetime_l2,
2636 max_lsp_lifetime_l2_cmd,
2637 "max-lsp-lifetime level-2 <350-65535>",
2638 "Maximum LSP lifetime for Level 2 only\n"
2639 "LSP lifetime for Level 2 only in seconds\n")
eb5d44eb 2640{
2641 struct isis_area *area;
2642 uint16_t interval;
3f045a08 2643 int level;
eb5d44eb 2644
2645 area = vty->index;
eb5d44eb 2646 interval = atoi (argv[0]);
3f045a08
JB
2647 level = IS_LEVEL_2;
2648 return set_lsp_max_lifetime (vty, area, interval, level);
2649}
eb5d44eb 2650
3f045a08
JB
2651DEFUN (no_max_lsp_lifetime_l2,
2652 no_max_lsp_lifetime_l2_cmd,
2653 "no max-lsp-lifetime level-2",
2654 NO_STR
2655 "LSP lifetime for Level 2 only in seconds\n")
2656{
2657 struct isis_area *area;
2658 uint16_t interval;
2659 int level;
eb5d44eb 2660
3f045a08
JB
2661 area = vty->index;
2662 interval = DEFAULT_LSP_LIFETIME;
2663 level = IS_LEVEL_2;
2664 return set_lsp_max_lifetime (vty, area, interval, level);
2665}
eb5d44eb 2666
3f045a08
JB
2667ALIAS (no_max_lsp_lifetime_l2,
2668 no_max_lsp_lifetime_l2_arg_cmd,
2669 "no max-lsp-lifetime level-2 <350-65535>",
2670 NO_STR
2671 "Maximum LSP lifetime for Level 2 only\n"
2672 "LSP lifetime for Level 2 only in seconds\n")
eb5d44eb 2673
3f045a08
JB
2674static int
2675set_lsp_refresh_interval (struct vty *vty, struct isis_area *area,
2676 uint16_t interval, int level)
2677{
2678 int lvl;
eb5d44eb 2679
3f045a08 2680 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
f390d2c7 2681 {
3f045a08
JB
2682 if (!(lvl & level))
2683 continue;
2684 if (interval <= area->lsp_gen_interval[lvl-1])
2685 {
2686 vty_out (vty, "LSP refresh interval %us must be greater than "
2687 "the configured LSP gen interval %us%s",
2688 interval, area->lsp_gen_interval[lvl-1],
2689 VTY_NEWLINE);
2690 return CMD_ERR_AMBIGUOUS;
2691 }
2692 if (interval > (area->max_lsp_lifetime[lvl-1] - 300))
2693 {
2694 vty_out (vty, "LSP refresh interval %us must be less than "
2695 "the configured LSP lifetime %us less 300%s",
2696 interval, area->max_lsp_lifetime[lvl-1],
2697 VTY_NEWLINE);
2698 return CMD_ERR_AMBIGUOUS;
2699 }
f390d2c7 2700 }
eb5d44eb 2701
3f045a08 2702 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
f390d2c7 2703 {
3f045a08
JB
2704 if (!(lvl & level))
2705 continue;
2706 area->lsp_refresh[lvl-1] = interval;
f390d2c7 2707 }
3f045a08 2708 lsp_regenerate_schedule (area, level, 1);
eb5d44eb 2709
2710 return CMD_SUCCESS;
2711}
2712
3f045a08
JB
2713DEFUN (lsp_refresh_interval,
2714 lsp_refresh_interval_cmd,
2715 "lsp-refresh-interval <1-65235>",
2716 "LSP refresh interval\n"
2717 "LSP refresh interval in seconds\n")
eb5d44eb 2718{
2719 struct isis_area *area;
3f045a08
JB
2720 uint16_t interval;
2721 int level;
eb5d44eb 2722
2723 area = vty->index;
3f045a08
JB
2724 interval = atoi (argv[0]);
2725 level = IS_LEVEL_1 | IS_LEVEL_2;
2726 return set_lsp_refresh_interval (vty, area, interval, level);
2727}
f390d2c7 2728
3f045a08
JB
2729DEFUN (no_lsp_refresh_interval,
2730 no_lsp_refresh_interval_cmd,
2731 "no lsp-refresh-interval",
2732 NO_STR
2733 "LSP refresh interval in seconds\n")
2734{
2735 struct isis_area *area;
2736 uint16_t interval;
2737 int level;
eb5d44eb 2738
3f045a08
JB
2739 area = vty->index;
2740 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2741 level = IS_LEVEL_1 | IS_LEVEL_2;
2742 return set_lsp_refresh_interval (vty, area, interval, level);
eb5d44eb 2743}
2744
3f045a08
JB
2745ALIAS (no_lsp_refresh_interval,
2746 no_lsp_refresh_interval_arg_cmd,
2747 "no lsp-refresh-interval <1-65235>",
eb5d44eb 2748 NO_STR
3f045a08
JB
2749 "LSP refresh interval\n"
2750 "LSP refresh interval in seconds\n")
eb5d44eb 2751
3f045a08
JB
2752DEFUN (lsp_refresh_interval_l1,
2753 lsp_refresh_interval_l1_cmd,
2754 "lsp-refresh-interval level-1 <1-65235>",
2755 "LSP refresh interval for Level 1 only\n"
2756 "LSP refresh interval for Level 1 only in seconds\n")
eb5d44eb 2757{
2758 struct isis_area *area;
2759 uint16_t interval;
3f045a08 2760 int level;
eb5d44eb 2761
2762 area = vty->index;
3f045a08
JB
2763 interval = atoi (argv[0]);
2764 level = IS_LEVEL_1;
2765 return set_lsp_refresh_interval (vty, area, interval, level);
2766}
2767
2768DEFUN (no_lsp_refresh_interval_l1,
2769 no_lsp_refresh_interval_l1_cmd,
2770 "no lsp-refresh-interval level-1",
2771 NO_STR
2772 "LSP refresh interval for Level 1 only in seconds\n")
2773{
2774 struct isis_area *area;
2775 uint16_t interval;
2776 int level;
2777
2778 area = vty->index;
2779 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2780 level = IS_LEVEL_1;
2781 return set_lsp_refresh_interval (vty, area, interval, level);
2782}
2783
2784ALIAS (no_lsp_refresh_interval_l1,
2785 no_lsp_refresh_interval_l1_arg_cmd,
2786 "no lsp-refresh-interval level-1 <1-65235>",
2787 NO_STR
2788 "LSP refresh interval for Level 1 only\n"
2789 "LSP refresh interval for Level 1 only in seconds\n")
f390d2c7 2790
3f045a08
JB
2791DEFUN (lsp_refresh_interval_l2,
2792 lsp_refresh_interval_l2_cmd,
2793 "lsp-refresh-interval level-2 <1-65235>",
2794 "LSP refresh interval for Level 2 only\n"
2795 "LSP refresh interval for Level 2 only in seconds\n")
2796{
2797 struct isis_area *area;
2798 uint16_t interval;
2799 int level;
2800
2801 area = vty->index;
eb5d44eb 2802 interval = atoi (argv[0]);
3f045a08
JB
2803 level = IS_LEVEL_2;
2804 return set_lsp_refresh_interval (vty, area, interval, level);
2805}
eb5d44eb 2806
3f045a08
JB
2807DEFUN (no_lsp_refresh_interval_l2,
2808 no_lsp_refresh_interval_l2_cmd,
2809 "no lsp-refresh-interval level-2",
2810 NO_STR
2811 "LSP refresh interval for Level 2 only in seconds\n")
2812{
2813 struct isis_area *area;
2814 uint16_t interval;
2815 int level;
eb5d44eb 2816
3f045a08
JB
2817 area = vty->index;
2818 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2819 level = IS_LEVEL_2;
2820 return set_lsp_refresh_interval (vty, area, interval, level);
2821}
2822
2823ALIAS (no_lsp_refresh_interval_l2,
2824 no_lsp_refresh_interval_l2_arg_cmd,
2825 "no lsp-refresh-interval level-2 <1-65235>",
2826 NO_STR
2827 "LSP refresh interval for Level 2 only\n"
2828 "LSP refresh interval for Level 2 only in seconds\n")
2829
2830DEFUN (log_adj_changes,
2831 log_adj_changes_cmd,
2832 "log-adjacency-changes",
2833 "Log changes in adjacency state\n")
2834{
2835 struct isis_area *area;
eb5d44eb 2836
3f045a08
JB
2837 area = vty->index;
2838 assert (area);
eb5d44eb 2839
3f045a08 2840 area->log_adj_changes = 1;
eb5d44eb 2841
2842 return CMD_SUCCESS;
2843}
2844
3f045a08
JB
2845DEFUN (no_log_adj_changes,
2846 no_log_adj_changes_cmd,
2847 "no log-adjacency-changes",
2848 "Stop logging changes in adjacency state\n")
eb5d44eb 2849{
2850 struct isis_area *area;
2851
2852 area = vty->index;
2853 assert (area);
f390d2c7 2854
3f045a08 2855 area->log_adj_changes = 0;
eb5d44eb 2856
2857 return CMD_SUCCESS;
2858}
2859
3f045a08 2860#ifdef TOPOLOGY_GENERATE
eb5d44eb 2861
3f045a08
JB
2862DEFUN (topology_generate_grid,
2863 topology_generate_grid_cmd,
2864 "topology generate grid <1-100> <1-100> <1-65000> [param] [param] "
2865 "[param]",
2866 "Topology generation for IS-IS\n"
2867 "Topology generation\n"
2868 "Grid topology\n"
2869 "X parameter of the grid\n"
2870 "Y parameter of the grid\n"
2871 "Random seed\n"
2872 "Optional param 1\n"
2873 "Optional param 2\n"
2874 "Optional param 3\n"
2875 "Topology\n")
eb5d44eb 2876{
2877 struct isis_area *area;
eb5d44eb 2878
2879 area = vty->index;
2880 assert (area);
eb5d44eb 2881
3f045a08
JB
2882 if (!spgrid_check_params (vty, argc, argv))
2883 {
2884 if (area->topology)
2885 list_delete (area->topology);
2886 area->topology = list_new ();
2887 memcpy (area->top_params, vty->buf, 200);
2888 gen_spgrid_topology (vty, area->topology);
2889 remove_topology_lsps (area);
2890 generate_topology_lsps (area);
2891 /* Regenerate L1 LSP to get two way connection to the generated
2892 * topology. */
2893 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2894 }
eb5d44eb 2895
3f045a08
JB
2896 return CMD_SUCCESS;
2897}
2898
2899DEFUN (show_isis_generated_topology,
2900 show_isis_generated_topology_cmd,
2901 "show isis generated-topologies",
2902 SHOW_STR
2903 "ISIS network information\n"
2904 "Show generated topologies\n")
2905{
2906 struct isis_area *area;
2907 struct listnode *node;
2908 struct listnode *node2;
2909 struct arc *arc;
2910
2911 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
f390d2c7 2912 {
3f045a08
JB
2913 if (!area->topology)
2914 continue;
eb5d44eb 2915
3f045a08
JB
2916 vty_out (vty, "Topology for isis area: %s%s", area->area_tag,
2917 VTY_NEWLINE);
2918 vty_out (vty, "From node To node Distance%s", VTY_NEWLINE);
2919
2920 for (ALL_LIST_ELEMENTS_RO (area->topology, node2, arc))
2921 vty_out (vty, "%9ld %11ld %12ld%s", arc->from_node, arc->to_node,
2922 arc->distance, VTY_NEWLINE);
f390d2c7 2923 }
3f045a08
JB
2924 return CMD_SUCCESS;
2925}
2926
2927/* Base IS for topology generation. */
2928DEFUN (topology_baseis,
2929 topology_baseis_cmd,
2930 "topology base-is WORD",
2931 "Topology generation for IS-IS\n"
2932 "A Network IS Base for this topology\n"
2933 "XXXX.XXXX.XXXX Network entity title (NET)\n")
2934{
2935 struct isis_area *area;
2936 u_char buff[ISIS_SYS_ID_LEN];
2937
2938 area = vty->index;
2939 assert (area);
eb5d44eb 2940
3f045a08
JB
2941 if (sysid2buff (buff, argv[0]))
2942 sysid2buff (area->topology_baseis, argv[0]);
eb5d44eb 2943
2944 return CMD_SUCCESS;
2945}
2946
3f045a08
JB
2947DEFUN (no_topology_baseis,
2948 no_topology_baseis_cmd,
2949 "no topology base-is WORD",
eb5d44eb 2950 NO_STR
3f045a08
JB
2951 "Topology generation for IS-IS\n"
2952 "A Network IS Base for this topology\n"
2953 "XXXX.XXXX.XXXX Network entity title (NET)\n")
eb5d44eb 2954{
2955 struct isis_area *area;
2956
2957 area = vty->index;
2958 assert (area);
f390d2c7 2959
3f045a08 2960 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
eb5d44eb 2961 return CMD_SUCCESS;
2962}
2963
3f045a08
JB
2964ALIAS (no_topology_baseis,
2965 no_topology_baseis_noid_cmd,
2966 "no topology base-is",
eb5d44eb 2967 NO_STR
3f045a08
JB
2968 "Topology generation for IS-IS\n"
2969 "A Network IS Base for this topology\n")
2970
2971DEFUN (topology_basedynh,
2972 topology_basedynh_cmd,
2973 "topology base-dynh WORD",
2974 "Topology generation for IS-IS\n"
2975 "Dynamic hostname base for this topology\n"
2976 "Dynamic hostname base\n")
2977{
2978 struct isis_area *area;
2979
2980 area = vty->index;
2981 assert (area);
2982
2983 /* I hope that it's enough. */
2984 area->topology_basedynh = strndup (argv[0], 16);
2985 return CMD_SUCCESS;
2986}
2987
2988#endif /* TOPOLOGY_GENERATE */
eb5d44eb 2989
2990/* IS-IS configuration write function */
2991int
2992isis_config_write (struct vty *vty)
2993{
2994 int write = 0;
eb5d44eb 2995
f390d2c7 2996 if (isis != NULL)
2997 {
2998 struct isis_area *area;
3fdb2dd9 2999 struct listnode *node, *node2;
f390d2c7 3000
3fdb2dd9 3001 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
f390d2c7 3002 {
3003 /* ISIS - Area name */
3004 vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
3005 write++;
3006 /* ISIS - Net */
3007 if (listcount (area->area_addrs) > 0)
3008 {
3009 struct area_addr *area_addr;
3fdb2dd9 3010 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
3011 {
3012 vty_out (vty, " net %s%s",
3013 isonet_print (area_addr->area_addr,
3014 area_addr->addr_len + ISIS_SYS_ID_LEN +
3015 1), VTY_NEWLINE);
3016 write++;
3017 }
f390d2c7 3018 }
3fdb2dd9 3019 /* ISIS - Dynamic hostname - Defaults to true so only display if
3020 * false. */
f390d2c7 3021 if (!area->dynhostname)
3022 {
3023 vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
3024 write++;
3025 }
e38e0df0
SV
3026 /* ISIS - Metric-Style - when true displays wide */
3027 if (area->newmetric)
f390d2c7 3028 {
e38e0df0
SV
3029 if (!area->oldmetric)
3030 vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
2984d26e 3031 else
3032 vty_out (vty, " metric-style transition%s", VTY_NEWLINE);
f390d2c7 3033 write++;
3034 }
f818c8f3
CF
3035 else
3036 {
3037 vty_out (vty, " metric-style narrow%s", VTY_NEWLINE);
3038 write++;
3039 }
3f045a08
JB
3040 /* ISIS - overload-bit */
3041 if (area->overload_bit)
3042 {
3043 vty_out (vty, " set-overload-bit%s", VTY_NEWLINE);
3044 write++;
3045 }
f390d2c7 3046 /* ISIS - Area is-type (level-1-2 is default) */
3047 if (area->is_type == IS_LEVEL_1)
3048 {
3049 vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
3050 write++;
3051 }
3f045a08 3052 else if (area->is_type == IS_LEVEL_2)
f390d2c7 3053 {
3f045a08
JB
3054 vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
3055 write++;
f390d2c7 3056 }
f3ccedaa
CF
3057 write += isis_redist_config_write(vty, area, AF_INET);
3058 write += isis_redist_config_write(vty, area, AF_INET6);
f390d2c7 3059 /* ISIS - Lsp generation interval */
3060 if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1])
3061 {
3f045a08 3062 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
f390d2c7 3063 {
3064 vty_out (vty, " lsp-gen-interval %d%s",
3065 area->lsp_gen_interval[0], VTY_NEWLINE);
3066 write++;
3067 }
3068 }
3069 else
3070 {
3f045a08 3071 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
f390d2c7 3072 {
3073 vty_out (vty, " lsp-gen-interval level-1 %d%s",
3074 area->lsp_gen_interval[0], VTY_NEWLINE);
3075 write++;
3076 }
3f045a08 3077 if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL)
f390d2c7 3078 {
3079 vty_out (vty, " lsp-gen-interval level-2 %d%s",
3080 area->lsp_gen_interval[1], VTY_NEWLINE);
3081 write++;
3082 }
3083 }
3084 /* ISIS - LSP lifetime */
3085 if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1])
3086 {
3f045a08 3087 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
f390d2c7 3088 {
3f045a08 3089 vty_out (vty, " max-lsp-lifetime %u%s", area->max_lsp_lifetime[0],
f390d2c7 3090 VTY_NEWLINE);
3091 write++;
3092 }
3093 }
3094 else
3095 {
3f045a08 3096 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
f390d2c7 3097 {
3f045a08 3098 vty_out (vty, " max-lsp-lifetime level-1 %u%s",
f390d2c7 3099 area->max_lsp_lifetime[0], VTY_NEWLINE);
3100 write++;
3101 }
3f045a08 3102 if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME)
f390d2c7 3103 {
3f045a08 3104 vty_out (vty, " max-lsp-lifetime level-2 %u%s",
f390d2c7 3105 area->max_lsp_lifetime[1], VTY_NEWLINE);
3106 write++;
3107 }
3108 }
3f045a08
JB
3109 /* ISIS - LSP refresh interval */
3110 if (area->lsp_refresh[0] == area->lsp_refresh[1])
3111 {
3112 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3113 {
3114 vty_out (vty, " lsp-refresh-interval %u%s", area->lsp_refresh[0],
3115 VTY_NEWLINE);
3116 write++;
3117 }
3118 }
3119 else
3120 {
3121 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3122 {
3123 vty_out (vty, " lsp-refresh-interval level-1 %u%s",
3124 area->lsp_refresh[0], VTY_NEWLINE);
3125 write++;
3126 }
3127 if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3128 {
3129 vty_out (vty, " lsp-refresh-interval level-2 %u%s",
3130 area->lsp_refresh[1], VTY_NEWLINE);
3131 write++;
3132 }
3133 }
b20ccb3a
CF
3134 if (area->lsp_mtu != DEFAULT_LSP_MTU)
3135 {
3136 vty_out(vty, " lsp-mtu %u%s", area->lsp_mtu, VTY_NEWLINE);
3137 write++;
3138 }
3139
13fb40ac 3140 /* Minimum SPF interval. */
3141 if (area->min_spf_interval[0] == area->min_spf_interval[1])
3142 {
3143 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
3144 {
3145 vty_out (vty, " spf-interval %d%s",
3146 area->min_spf_interval[0], VTY_NEWLINE);
3147 write++;
3148 }
3149 }
3150 else
3151 {
3152 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
3153 {
3154 vty_out (vty, " spf-interval level-1 %d%s",
3155 area->min_spf_interval[0], VTY_NEWLINE);
3156 write++;
3157 }
3158 if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL)
3159 {
3160 vty_out (vty, " spf-interval level-2 %d%s",
3161 area->min_spf_interval[1], VTY_NEWLINE);
3162 write++;
3163 }
3164 }
53c997c9 3165 /* Authentication passwords. */
3f045a08 3166 if (area->area_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
53c997c9 3167 {
3f045a08 3168 vty_out(vty, " area-password md5 %s", area->area_passwd.passwd);
1cbc562b 3169 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
3170 {
3171 vty_out(vty, " authenticate snp ");
3172 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
3173 vty_out(vty, "validate");
3174 else
3175 vty_out(vty, "send-only");
3176 }
3177 vty_out(vty, "%s", VTY_NEWLINE);
53c997c9 3178 write++;
3f045a08
JB
3179 }
3180 else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
3181 {
3182 vty_out(vty, " area-password clear %s", area->area_passwd.passwd);
3183 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
3184 {
3185 vty_out(vty, " authenticate snp ");
3186 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
3187 vty_out(vty, "validate");
3188 else
3189 vty_out(vty, "send-only");
3190 }
3191 vty_out(vty, "%s", VTY_NEWLINE);
3192 write++;
3193 }
3194 if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
3195 {
3196 vty_out(vty, " domain-password md5 %s",
3197 area->domain_passwd.passwd);
3198 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3199 {
3200 vty_out(vty, " authenticate snp ");
3201 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3202 vty_out(vty, "validate");
3203 else
3204 vty_out(vty, "send-only");
3205 }
3206 vty_out(vty, "%s", VTY_NEWLINE);
3207 write++;
3208 }
3209 else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
53c997c9 3210 {
3f045a08
JB
3211 vty_out(vty, " domain-password clear %s",
3212 area->domain_passwd.passwd);
1cbc562b 3213 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3214 {
3215 vty_out(vty, " authenticate snp ");
3216 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3217 vty_out(vty, "validate");
3218 else
3219 vty_out(vty, "send-only");
3220 }
3221 vty_out(vty, "%s", VTY_NEWLINE);
53c997c9 3222 write++;
3223 }
f390d2c7 3224
3f045a08
JB
3225 if (area->log_adj_changes)
3226 {
3227 vty_out (vty, " log-adjacency-changes%s", VTY_NEWLINE);
3228 write++;
3229 }
3230
f1082d19 3231#ifdef TOPOLOGY_GENERATE
f390d2c7 3232 if (memcmp (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS,
3233 ISIS_SYS_ID_LEN))
3234 {
f1082d19 3235 vty_out (vty, " topology base-is %s%s",
3f045a08 3236 sysid_print ((u_char *)area->topology_baseis), VTY_NEWLINE);
f390d2c7 3237 write++;
3238 }
f1082d19 3239 if (area->topology_basedynh)
3240 {
3241 vty_out (vty, " topology base-dynh %s%s",
3242 area->topology_basedynh, VTY_NEWLINE);
3243 write++;
3244 }
3245 /* We save the whole command line here. */
3246 if (strlen(area->top_params))
3247 {
3248 vty_out (vty, " %s%s", area->top_params, VTY_NEWLINE);
3249 write++;
3250 }
f390d2c7 3251#endif /* TOPOLOGY_GENERATE */
f1082d19 3252
f390d2c7 3253 }
eb5d44eb 3254 }
f390d2c7 3255
eb5d44eb 3256 return write;
3257}
3258
3f045a08 3259struct cmd_node isis_node = {
eb5d44eb 3260 ISIS_NODE,
2097cd8a 3261 "%s(config-router)# ",
eb5d44eb 3262 1
3263};
3264
f390d2c7 3265void
eb5d44eb 3266isis_init ()
3267{
eb5d44eb 3268 /* Install IS-IS top node */
3269 install_node (&isis_node, isis_config_write);
f390d2c7 3270
3f045a08
JB
3271 install_element (VIEW_NODE, &show_isis_summary_cmd);
3272
3273 install_element (VIEW_NODE, &show_isis_interface_cmd);
3274 install_element (VIEW_NODE, &show_isis_interface_detail_cmd);
3275 install_element (VIEW_NODE, &show_isis_interface_arg_cmd);
3276
3277 install_element (VIEW_NODE, &show_isis_neighbor_cmd);
3278 install_element (VIEW_NODE, &show_isis_neighbor_detail_cmd);
3279 install_element (VIEW_NODE, &show_isis_neighbor_arg_cmd);
3280 install_element (VIEW_NODE, &clear_isis_neighbor_cmd);
3281 install_element (VIEW_NODE, &clear_isis_neighbor_arg_cmd);
eb5d44eb 3282
3283 install_element (VIEW_NODE, &show_hostname_cmd);
3284 install_element (VIEW_NODE, &show_database_cmd);
3f045a08
JB
3285 install_element (VIEW_NODE, &show_database_arg_cmd);
3286 install_element (VIEW_NODE, &show_database_arg_detail_cmd);
eb5d44eb 3287 install_element (VIEW_NODE, &show_database_detail_cmd);
3f045a08
JB
3288 install_element (VIEW_NODE, &show_database_detail_arg_cmd);
3289
3290 install_element (ENABLE_NODE, &show_isis_summary_cmd);
eb5d44eb 3291
3f045a08
JB
3292 install_element (ENABLE_NODE, &show_isis_interface_cmd);
3293 install_element (ENABLE_NODE, &show_isis_interface_detail_cmd);
3294 install_element (ENABLE_NODE, &show_isis_interface_arg_cmd);
3295
3296 install_element (ENABLE_NODE, &show_isis_neighbor_cmd);
3297 install_element (ENABLE_NODE, &show_isis_neighbor_detail_cmd);
3298 install_element (ENABLE_NODE, &show_isis_neighbor_arg_cmd);
3299 install_element (ENABLE_NODE, &clear_isis_neighbor_cmd);
3300 install_element (ENABLE_NODE, &clear_isis_neighbor_arg_cmd);
eb5d44eb 3301
3302 install_element (ENABLE_NODE, &show_hostname_cmd);
3303 install_element (ENABLE_NODE, &show_database_cmd);
3f045a08
JB
3304 install_element (ENABLE_NODE, &show_database_arg_cmd);
3305 install_element (ENABLE_NODE, &show_database_arg_detail_cmd);
eb5d44eb 3306 install_element (ENABLE_NODE, &show_database_detail_cmd);
3f045a08 3307 install_element (ENABLE_NODE, &show_database_detail_arg_cmd);
eb5d44eb 3308 install_element (ENABLE_NODE, &show_debugging_cmd);
3309
f390d2c7 3310 install_node (&debug_node, config_write_debug);
9e867fe6 3311
eb5d44eb 3312 install_element (ENABLE_NODE, &debug_isis_adj_cmd);
3313 install_element (ENABLE_NODE, &no_debug_isis_adj_cmd);
3314 install_element (ENABLE_NODE, &debug_isis_csum_cmd);
3315 install_element (ENABLE_NODE, &no_debug_isis_csum_cmd);
3316 install_element (ENABLE_NODE, &debug_isis_lupd_cmd);
3317 install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd);
3318 install_element (ENABLE_NODE, &debug_isis_err_cmd);
3319 install_element (ENABLE_NODE, &no_debug_isis_err_cmd);
3320 install_element (ENABLE_NODE, &debug_isis_snp_cmd);
3321 install_element (ENABLE_NODE, &no_debug_isis_snp_cmd);
3322 install_element (ENABLE_NODE, &debug_isis_upd_cmd);
3323 install_element (ENABLE_NODE, &no_debug_isis_upd_cmd);
3324 install_element (ENABLE_NODE, &debug_isis_spfevents_cmd);
3325 install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd);
3326 install_element (ENABLE_NODE, &debug_isis_spfstats_cmd);
3327 install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd);
3328 install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd);
3329 install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd);
3330 install_element (ENABLE_NODE, &debug_isis_rtevents_cmd);
3331 install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd);
3332 install_element (ENABLE_NODE, &debug_isis_events_cmd);
3333 install_element (ENABLE_NODE, &no_debug_isis_events_cmd);
3f045a08
JB
3334 install_element (ENABLE_NODE, &debug_isis_packet_dump_cmd);
3335 install_element (ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
14872644
CF
3336 install_element (ENABLE_NODE, &debug_isis_lsp_gen_cmd);
3337 install_element (ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
414766a1
CF
3338 install_element (ENABLE_NODE, &debug_isis_lsp_sched_cmd);
3339 install_element (ENABLE_NODE, &no_debug_isis_lsp_sched_cmd);
eb5d44eb 3340
9e867fe6 3341 install_element (CONFIG_NODE, &debug_isis_adj_cmd);
3342 install_element (CONFIG_NODE, &no_debug_isis_adj_cmd);
3343 install_element (CONFIG_NODE, &debug_isis_csum_cmd);
3344 install_element (CONFIG_NODE, &no_debug_isis_csum_cmd);
3345 install_element (CONFIG_NODE, &debug_isis_lupd_cmd);
3346 install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd);
3347 install_element (CONFIG_NODE, &debug_isis_err_cmd);
3348 install_element (CONFIG_NODE, &no_debug_isis_err_cmd);
3349 install_element (CONFIG_NODE, &debug_isis_snp_cmd);
3350 install_element (CONFIG_NODE, &no_debug_isis_snp_cmd);
3351 install_element (CONFIG_NODE, &debug_isis_upd_cmd);
3352 install_element (CONFIG_NODE, &no_debug_isis_upd_cmd);
3353 install_element (CONFIG_NODE, &debug_isis_spfevents_cmd);
3354 install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd);
3355 install_element (CONFIG_NODE, &debug_isis_spfstats_cmd);
3356 install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd);
3357 install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd);
3358 install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd);
3359 install_element (CONFIG_NODE, &debug_isis_rtevents_cmd);
3360 install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd);
3361 install_element (CONFIG_NODE, &debug_isis_events_cmd);
3362 install_element (CONFIG_NODE, &no_debug_isis_events_cmd);
3f045a08
JB
3363 install_element (CONFIG_NODE, &debug_isis_packet_dump_cmd);
3364 install_element (CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
14872644
CF
3365 install_element (CONFIG_NODE, &debug_isis_lsp_gen_cmd);
3366 install_element (CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
414766a1
CF
3367 install_element (CONFIG_NODE, &debug_isis_lsp_sched_cmd);
3368 install_element (CONFIG_NODE, &no_debug_isis_lsp_sched_cmd);
9e867fe6 3369
eb5d44eb 3370 install_element (CONFIG_NODE, &router_isis_cmd);
3371 install_element (CONFIG_NODE, &no_router_isis_cmd);
3372
3373 install_default (ISIS_NODE);
3374
3375 install_element (ISIS_NODE, &net_cmd);
3376 install_element (ISIS_NODE, &no_net_cmd);
3377
3378 install_element (ISIS_NODE, &is_type_cmd);
3379 install_element (ISIS_NODE, &no_is_type_cmd);
3380
b20ccb3a
CF
3381 install_element (ISIS_NODE, &area_lsp_mtu_cmd);
3382 install_element (ISIS_NODE, &no_area_lsp_mtu_cmd);
3383 install_element (ISIS_NODE, &no_area_lsp_mtu_arg_cmd);
3384
3f045a08
JB
3385 install_element (ISIS_NODE, &area_passwd_md5_cmd);
3386 install_element (ISIS_NODE, &area_passwd_md5_snpauth_cmd);
3387 install_element (ISIS_NODE, &area_passwd_clear_cmd);
3388 install_element (ISIS_NODE, &area_passwd_clear_snpauth_cmd);
eb5d44eb 3389 install_element (ISIS_NODE, &no_area_passwd_cmd);
3390
3f045a08
JB
3391 install_element (ISIS_NODE, &domain_passwd_md5_cmd);
3392 install_element (ISIS_NODE, &domain_passwd_md5_snpauth_cmd);
3393 install_element (ISIS_NODE, &domain_passwd_clear_cmd);
3394 install_element (ISIS_NODE, &domain_passwd_clear_snpauth_cmd);
eb5d44eb 3395 install_element (ISIS_NODE, &no_domain_passwd_cmd);
3396
3397 install_element (ISIS_NODE, &lsp_gen_interval_cmd);
3398 install_element (ISIS_NODE, &no_lsp_gen_interval_cmd);
3399 install_element (ISIS_NODE, &no_lsp_gen_interval_arg_cmd);
3400 install_element (ISIS_NODE, &lsp_gen_interval_l1_cmd);
3401 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_cmd);
3402 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_arg_cmd);
3403 install_element (ISIS_NODE, &lsp_gen_interval_l2_cmd);
3404 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_cmd);
3405 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_arg_cmd);
3406
3407 install_element (ISIS_NODE, &spf_interval_cmd);
3408 install_element (ISIS_NODE, &no_spf_interval_cmd);
3409 install_element (ISIS_NODE, &no_spf_interval_arg_cmd);
3410 install_element (ISIS_NODE, &spf_interval_l1_cmd);
3411 install_element (ISIS_NODE, &no_spf_interval_l1_cmd);
3412 install_element (ISIS_NODE, &no_spf_interval_l1_arg_cmd);
3413 install_element (ISIS_NODE, &spf_interval_l2_cmd);
3414 install_element (ISIS_NODE, &no_spf_interval_l2_cmd);
3415 install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd);
f390d2c7 3416
3f045a08
JB
3417 install_element (ISIS_NODE, &max_lsp_lifetime_cmd);
3418 install_element (ISIS_NODE, &no_max_lsp_lifetime_cmd);
3419 install_element (ISIS_NODE, &no_max_lsp_lifetime_arg_cmd);
3420 install_element (ISIS_NODE, &max_lsp_lifetime_l1_cmd);
3421 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_cmd);
3422 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_arg_cmd);
3423 install_element (ISIS_NODE, &max_lsp_lifetime_l2_cmd);
3424 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_cmd);
3425 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_arg_cmd);
3426
3427 install_element (ISIS_NODE, &lsp_refresh_interval_cmd);
3428 install_element (ISIS_NODE, &no_lsp_refresh_interval_cmd);
3429 install_element (ISIS_NODE, &no_lsp_refresh_interval_arg_cmd);
3430 install_element (ISIS_NODE, &lsp_refresh_interval_l1_cmd);
3431 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_cmd);
3432 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_arg_cmd);
3433 install_element (ISIS_NODE, &lsp_refresh_interval_l2_cmd);
3434 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_cmd);
3435 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_arg_cmd);
3436
3437 install_element (ISIS_NODE, &set_overload_bit_cmd);
3438 install_element (ISIS_NODE, &no_set_overload_bit_cmd);
eb5d44eb 3439
7ed55a41
AN
3440 install_element (ISIS_NODE, &set_attached_bit_cmd);
3441 install_element (ISIS_NODE, &no_set_attached_bit_cmd);
3442
eb5d44eb 3443 install_element (ISIS_NODE, &dynamic_hostname_cmd);
3444 install_element (ISIS_NODE, &no_dynamic_hostname_cmd);
3445
3446 install_element (ISIS_NODE, &metric_style_cmd);
3447 install_element (ISIS_NODE, &no_metric_style_cmd);
3f045a08
JB
3448
3449 install_element (ISIS_NODE, &log_adj_changes_cmd);
3450 install_element (ISIS_NODE, &no_log_adj_changes_cmd);
3451
eb5d44eb 3452#ifdef TOPOLOGY_GENERATE
3453 install_element (ISIS_NODE, &topology_generate_grid_cmd);
3454 install_element (ISIS_NODE, &topology_baseis_cmd);
f1082d19 3455 install_element (ISIS_NODE, &topology_basedynh_cmd);
eb5d44eb 3456 install_element (ISIS_NODE, &no_topology_baseis_cmd);
f1082d19 3457 install_element (ISIS_NODE, &no_topology_baseis_noid_cmd);
f695b01f 3458 install_element (VIEW_NODE, &show_isis_generated_topology_cmd);
3459 install_element (ENABLE_NODE, &show_isis_generated_topology_cmd);
eb5d44eb 3460#endif /* TOPOLOGY_GENERATE */
eb5d44eb 3461}