blob: 71466896091347f85900374204570d5b133d567a [file] [log] [blame]
jardineb5d44e2003-12-23 08:09:43 +00001/*
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
jardineb5d44e2003-12-23 08:09:43 +000023#include <zebra.h>
jardineb5d44e2003-12-23 08:09:43 +000024
25#include "thread.h"
26#include "vty.h"
27#include "command.h"
28#include "log.h"
29#include "memory.h"
Josh Bailey3f045a02012-03-24 08:35:20 -070030#include "time.h"
jardineb5d44e2003-12-23 08:09:43 +000031#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"
jardineb5d44e2003-12-23 08:09:43 +000042#include "isisd/isis_flags.h"
Josh Bailey3f045a02012-03-24 08:35:20 -070043#include "isisd/isis_circuit.h"
44#include "isisd/isis_csm.h"
jardineb5d44e2003-12-23 08:09:43 +000045#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"
hassof390d2c2004-09-10 20:48:21 +000060u_char DEFAULT_TOPOLOGY_BASEIS[6] = { 0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00 };
jardineb5d44e2003-12-23 08:09:43 +000061#endif /* TOPOLOGY_GENERATE */
62
jardineb5d44e2003-12-23 08:09:43 +000063struct isis *isis = NULL;
jardineb5d44e2003-12-23 08:09:43 +000064
Paul Jakma41b36e92006-12-08 01:09:50 +000065/*
66 * Prototypes.
67 */
Paul Jakma41b36e92006-12-08 01:09:50 +000068int isis_area_get(struct vty *, const char *);
69int isis_area_destroy(struct vty *, const char *);
Josh Bailey3f045a02012-03-24 08:35:20 -070070int 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);
Paul Jakma41b36e92006-12-08 01:09:50 +000075int isis_config_write(struct vty *);
76
77
78
jardineb5d44e2003-12-23 08:09:43 +000079void
80isis_new (unsigned long process_id)
81{
hassoaac372f2005-09-01 17:52:33 +000082 isis = XCALLOC (MTYPE_ISIS, sizeof (struct isis));
jardineb5d44e2003-12-23 08:09:43 +000083 /*
84 * Default values
85 */
86 isis->max_area_addrs = 3;
jardineb5d44e2003-12-23 08:09:43 +000087 isis->process_id = process_id;
Josh Bailey3f045a02012-03-24 08:35:20 -070088 isis->router_id = 0;
jardineb5d44e2003-12-23 08:09:43 +000089 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 */
Josh Bailey3f045a02012-03-24 08:35:20 -070096 dyn_cache_init ();
jardineb5d44e2003-12-23 08:09:43 +000097 /*
98 * uncomment the next line for full debugs
99 */
hassof390d2c2004-09-10 20:48:21 +0000100 /* isis->debugs = 0xFFFF; */
jardineb5d44e2003-12-23 08:09:43 +0000101}
102
103struct isis_area *
Josh Bailey3f045a02012-03-24 08:35:20 -0700104isis_area_create (const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000105{
jardineb5d44e2003-12-23 08:09:43 +0000106 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000107
hassoaac372f2005-09-01 17:52:33 +0000108 area = XCALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area));
jardineb5d44e2003-12-23 08:09:43 +0000109
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;
Josh Bailey3f045a02012-03-24 08:35:20 -0700118
jardineb5d44e2003-12-23 08:09:43 +0000119 /*
120 * intialize the databases
121 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700122 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 ();
134#ifdef HAVE_IPV6
135 area->route_table6[1] = route_table_init ();
136#endif /* HAVE_IPV6 */
137 }
hassof390d2c2004-09-10 20:48:21 +0000138
jardineb5d44e2003-12-23 08:09:43 +0000139 spftree_area_init (area);
Josh Bailey3f045a02012-03-24 08:35:20 -0700140
jardineb5d44e2003-12-23 08:09:43 +0000141 area->circuit_list = list_new ();
142 area->area_addrs = list_new ();
hassof390d2c2004-09-10 20:48:21 +0000143 THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
Paul Jakmac7350c42008-01-29 19:29:44 +0000144 flags_initialize (&area->flags);
Josh Bailey3f045a02012-03-24 08:35:20 -0700145
jardineb5d44e2003-12-23 08:09:43 +0000146 /*
147 * Default values
148 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700149 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;
jardineb5d44e2003-12-23 08:09:43 +0000155 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
156 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
157 area->dynhostname = 1;
Josh Bailey3f045a02012-03-24 08:35:20 -0700158 area->oldmetric = 0;
159 area->newmetric = 1;
jardineb5d44e2003-12-23 08:09:43 +0000160 area->lsp_frag_threshold = 90;
Christian Frankef1fc1db2015-11-10 18:43:31 +0100161 area->lsp_mtu = DEFAULT_LSP_MTU;
jardineb5d44e2003-12-23 08:09:43 +0000162#ifdef TOPOLOGY_GENERATE
163 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
164#endif /* TOPOLOGY_GENERATE */
165
Josh Bailey3f045a02012-03-24 08:35:20 -0700166 area->area_tag = strdup (area_tag);
167 listnode_add (isis->area_list, area);
168 area->isis = isis;
169
jardineb5d44e2003-12-23 08:09:43 +0000170 return area;
171}
172
173struct isis_area *
hassof90a5f62004-10-11 13:11:56 +0000174isis_area_lookup (const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000175{
176 struct isis_area *area;
hasso3fdb2dd2005-09-28 18:45:54 +0000177 struct listnode *node;
hassof390d2c2004-09-10 20:48:21 +0000178
hasso3fdb2dd2005-09-28 18:45:54 +0000179 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
jardineb5d44e2003-12-23 08:09:43 +0000180 if ((area->area_tag == NULL && area_tag == NULL) ||
hassof390d2c2004-09-10 20:48:21 +0000181 (area->area_tag && area_tag
182 && strcmp (area->area_tag, area_tag) == 0))
183 return area;
184
jardineb5d44e2003-12-23 08:09:43 +0000185 return NULL;
186}
187
hassof390d2c2004-09-10 20:48:21 +0000188int
hassof90a5f62004-10-11 13:11:56 +0000189isis_area_get (struct vty *vty, const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000190{
jardineb5d44e2003-12-23 08:09:43 +0000191 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000192
jardineb5d44e2003-12-23 08:09:43 +0000193 area = isis_area_lookup (area_tag);
hassof390d2c2004-09-10 20:48:21 +0000194
195 if (area)
196 {
197 vty->node = ISIS_NODE;
198 vty->index = area;
199 return CMD_SUCCESS;
200 }
201
Josh Bailey3f045a02012-03-24 08:35:20 -0700202 area = isis_area_create (area_tag);
hassof390d2c2004-09-10 20:48:21 +0000203
hassoc89c05d2005-09-04 21:36:36 +0000204 if (isis->debugs & DEBUG_EVENTS)
205 zlog_debug ("New IS-IS area instance %s", area->area_tag);
jardineb5d44e2003-12-23 08:09:43 +0000206
207 vty->node = ISIS_NODE;
208 vty->index = area;
hassof390d2c2004-09-10 20:48:21 +0000209
jardineb5d44e2003-12-23 08:09:43 +0000210 return CMD_SUCCESS;
211}
212
213int
hassof90a5f62004-10-11 13:11:56 +0000214isis_area_destroy (struct vty *vty, const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000215{
jardineb5d44e2003-12-23 08:09:43 +0000216 struct isis_area *area;
paul1eb8ef22005-04-07 07:30:20 +0000217 struct listnode *node, *nnode;
jardineb5d44e2003-12-23 08:09:43 +0000218 struct isis_circuit *circuit;
Josh Bailey3f045a02012-03-24 08:35:20 -0700219 struct area_addr *addr;
jardineb5d44e2003-12-23 08:09:43 +0000220
221 area = isis_area_lookup (area_tag);
jardineb5d44e2003-12-23 08:09:43 +0000222
hassof390d2c2004-09-10 20:48:21 +0000223 if (area == NULL)
224 {
225 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700226 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +0000227 }
hassof390d2c2004-09-10 20:48:21 +0000228
229 if (area->circuit_list)
230 {
paul1eb8ef22005-04-07 07:30:20 +0000231 for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
Josh Bailey3f045a02012-03-24 08:35:20 -0700232 {
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 }
hassof390d2c2004-09-10 20:48:21 +0000239 list_delete (area->circuit_list);
Josh Bailey3f045a02012-03-24 08:35:20 -0700240 area->circuit_list = NULL;
hassof390d2c2004-09-10 20:48:21 +0000241 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700242
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
283 for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addr))
284 {
285 list_delete_node (area->area_addrs, node);
286 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
287 }
288 area->area_addrs = NULL;
289
hassof390d2c2004-09-10 20:48:21 +0000290 THREAD_TIMER_OFF (area->t_tick);
hassof390d2c2004-09-10 20:48:21 +0000291 THREAD_TIMER_OFF (area->t_lsp_refresh[0]);
292 THREAD_TIMER_OFF (area->t_lsp_refresh[1]);
jardineb5d44e2003-12-23 08:09:43 +0000293
Josh Bailey3f045a02012-03-24 08:35:20 -0700294 thread_cancel_event (master, area);
295
296 listnode_delete (isis->area_list, area);
297
298 free (area->area_tag);
299
jardineb5d44e2003-12-23 08:09:43 +0000300 XFREE (MTYPE_ISIS_AREA, area);
hassof390d2c2004-09-10 20:48:21 +0000301
Josh Bailey3f045a02012-03-24 08:35:20 -0700302 if (listcount (isis->area_list) == 0)
303 {
304 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
305 isis->sysid_set = 0;
306 }
307
jardineb5d44e2003-12-23 08:09:43 +0000308 return CMD_SUCCESS;
309}
310
hassof390d2c2004-09-10 20:48:21 +0000311int
Josh Bailey3f045a02012-03-24 08:35:20 -0700312area_net_title (struct vty *vty, const char *net_title)
jardineb5d44e2003-12-23 08:09:43 +0000313{
jardineb5d44e2003-12-23 08:09:43 +0000314 struct isis_area *area;
315 struct area_addr *addr;
316 struct area_addr *addrp;
hasso3fdb2dd2005-09-28 18:45:54 +0000317 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +0000318
319 u_char buff[255];
320 area = vty->index;
321
hassof390d2c2004-09-10 20:48:21 +0000322 if (!area)
323 {
324 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700325 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +0000326 }
jardineb5d44e2003-12-23 08:09:43 +0000327
328 /* We check that we are not over the maximal number of addresses */
hassof390d2c2004-09-10 20:48:21 +0000329 if (listcount (area->area_addrs) >= isis->max_area_addrs)
330 {
331 vty_out (vty, "Maximum of area addresses (%d) already reached %s",
332 isis->max_area_addrs, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700333 return CMD_ERR_NOTHING_TODO;
hassof390d2c2004-09-10 20:48:21 +0000334 }
jardineb5d44e2003-12-23 08:09:43 +0000335
336 addr = XMALLOC (MTYPE_ISIS_AREA_ADDR, sizeof (struct area_addr));
337 addr->addr_len = dotformat2buff (buff, net_title);
338 memcpy (addr->area_addr, buff, addr->addr_len);
339#ifdef EXTREME_DEBUG
hasso529d65b2004-12-24 00:14:50 +0000340 zlog_debug ("added area address %s for area %s (address length %d)",
jardineb5d44e2003-12-23 08:09:43 +0000341 net_title, area->area_tag, addr->addr_len);
342#endif /* EXTREME_DEBUG */
hassof390d2c2004-09-10 20:48:21 +0000343 if (addr->addr_len < 8 || addr->addr_len > 20)
344 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700345 vty_out (vty, "area address must be at least 8..20 octets long (%d)%s",
346 addr->addr_len, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000347 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
Josh Bailey3f045a02012-03-24 08:35:20 -0700348 return CMD_ERR_AMBIGUOUS;
349 }
350
351 if (addr->area_addr[addr->addr_len-1] != 0)
352 {
353 vty_out (vty, "nsel byte (last byte) in area address must be 0%s",
354 VTY_NEWLINE);
355 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
356 return CMD_ERR_AMBIGUOUS;
jardineb5d44e2003-12-23 08:09:43 +0000357 }
358
hassof390d2c2004-09-10 20:48:21 +0000359 if (isis->sysid_set == 0)
360 {
361 /*
362 * First area address - get the SystemID for this router
363 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700364 memcpy (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN);
hassof390d2c2004-09-10 20:48:21 +0000365 isis->sysid_set = 1;
hassoc89c05d2005-09-04 21:36:36 +0000366 if (isis->debugs & DEBUG_EVENTS)
367 zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid));
jardineb5d44e2003-12-23 08:09:43 +0000368 }
hassof390d2c2004-09-10 20:48:21 +0000369 else
370 {
371 /*
372 * Check that the SystemID portions match
373 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700374 if (memcmp (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN))
hassof390d2c2004-09-10 20:48:21 +0000375 {
376 vty_out (vty,
377 "System ID must not change when defining additional area"
378 " addresses%s", VTY_NEWLINE);
379 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
Josh Bailey3f045a02012-03-24 08:35:20 -0700380 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +0000381 }
jardineb5d44e2003-12-23 08:09:43 +0000382
hassof390d2c2004-09-10 20:48:21 +0000383 /* now we see that we don't already have this address */
hasso3fdb2dd2005-09-28 18:45:54 +0000384 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
385 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700386 if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != (addr->addr_len))
hasso3fdb2dd2005-09-28 18:45:54 +0000387 continue;
388 if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
389 {
390 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
391 return CMD_SUCCESS; /* silent fail */
392 }
393 }
hassof390d2c2004-09-10 20:48:21 +0000394 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700395
jardineb5d44e2003-12-23 08:09:43 +0000396 /*
397 * Forget the systemID part of the address
398 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700399 addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
jardineb5d44e2003-12-23 08:09:43 +0000400 listnode_add (area->area_addrs, addr);
401
402 /* only now we can safely generate our LSPs for this area */
hassof390d2c2004-09-10 20:48:21 +0000403 if (listcount (area->area_addrs) > 0)
404 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700405 if (area->is_type & IS_LEVEL_1)
406 lsp_generate (area, IS_LEVEL_1);
407 if (area->is_type & IS_LEVEL_2)
408 lsp_generate (area, IS_LEVEL_2);
hassof390d2c2004-09-10 20:48:21 +0000409 }
jardineb5d44e2003-12-23 08:09:43 +0000410
411 return CMD_SUCCESS;
412}
413
414int
Josh Bailey3f045a02012-03-24 08:35:20 -0700415area_clear_net_title (struct vty *vty, const char *net_title)
jardineb5d44e2003-12-23 08:09:43 +0000416{
417 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000418 struct area_addr addr, *addrp = NULL;
hasso3fdb2dd2005-09-28 18:45:54 +0000419 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +0000420 u_char buff[255];
421
422 area = vty->index;
hassof390d2c2004-09-10 20:48:21 +0000423 if (!area)
424 {
425 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700426 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +0000427 }
428
jardineb5d44e2003-12-23 08:09:43 +0000429 addr.addr_len = dotformat2buff (buff, net_title);
hassof390d2c2004-09-10 20:48:21 +0000430 if (addr.addr_len < 8 || addr.addr_len > 20)
431 {
432 vty_out (vty, "Unsupported area address length %d, should be 8...20 %s",
433 addr.addr_len, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700434 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +0000435 }
436
437 memcpy (addr.area_addr, buff, (int) addr.addr_len);
438
hasso3fdb2dd2005-09-28 18:45:54 +0000439 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
Josh Bailey3f045a02012-03-24 08:35:20 -0700440 if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len &&
jardineb5d44e2003-12-23 08:09:43 +0000441 !memcmp (addrp->area_addr, addr.area_addr, addr.addr_len))
hassof390d2c2004-09-10 20:48:21 +0000442 break;
443
444 if (!addrp)
445 {
446 vty_out (vty, "No area address %s for area %s %s", net_title,
447 area->area_tag, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700448 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +0000449 }
450
jardineb5d44e2003-12-23 08:09:43 +0000451 listnode_delete (area->area_addrs, addrp);
Josh Bailey3f045a02012-03-24 08:35:20 -0700452 XFREE (MTYPE_ISIS_AREA_ADDR, addrp);
453
454 /*
455 * Last area address - reset the SystemID for this router
456 */
457 if (listcount (area->area_addrs) == 0)
458 {
459 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
460 isis->sysid_set = 0;
461 if (isis->debugs & DEBUG_EVENTS)
462 zlog_debug ("Router has no SystemID");
463 }
hassof390d2c2004-09-10 20:48:21 +0000464
jardineb5d44e2003-12-23 08:09:43 +0000465 return CMD_SUCCESS;
466}
467
jardineb5d44e2003-12-23 08:09:43 +0000468/*
Josh Bailey3f045a02012-03-24 08:35:20 -0700469 * 'show isis interface' command
jardineb5d44e2003-12-23 08:09:43 +0000470 */
471
472int
Josh Bailey3f045a02012-03-24 08:35:20 -0700473show_isis_interface_common (struct vty *vty, const char *ifname, char detail)
jardineb5d44e2003-12-23 08:09:43 +0000474{
hasso3fdb2dd2005-09-28 18:45:54 +0000475 struct listnode *anode, *cnode;
jardineb5d44e2003-12-23 08:09:43 +0000476 struct isis_area *area;
477 struct isis_circuit *circuit;
jardineb5d44e2003-12-23 08:09:43 +0000478
hassof390d2c2004-09-10 20:48:21 +0000479 if (!isis)
480 {
481 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
482 return CMD_SUCCESS;
483 }
jardineb5d44e2003-12-23 08:09:43 +0000484
hasso3fdb2dd2005-09-28 18:45:54 +0000485 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
hassof390d2c2004-09-10 20:48:21 +0000486 {
hassof390d2c2004-09-10 20:48:21 +0000487 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000488
hassof390d2c2004-09-10 20:48:21 +0000489 if (detail == ISIS_UI_LEVEL_BRIEF)
Josh Bailey3f045a02012-03-24 08:35:20 -0700490 vty_out (vty, " Interface CircId State Type Level%s",
491 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000492
hasso3fdb2dd2005-09-28 18:45:54 +0000493 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
Josh Bailey3f045a02012-03-24 08:35:20 -0700494 if (!ifname)
495 isis_circuit_print_vty (circuit, vty, detail);
496 else if (strcmp(circuit->interface->name, ifname) == 0)
497 isis_circuit_print_vty (circuit, vty, detail);
jardineb5d44e2003-12-23 08:09:43 +0000498 }
hassof390d2c2004-09-10 20:48:21 +0000499
jardineb5d44e2003-12-23 08:09:43 +0000500 return CMD_SUCCESS;
501}
502
Josh Bailey3f045a02012-03-24 08:35:20 -0700503DEFUN (show_isis_interface,
504 show_isis_interface_cmd,
505 "show isis interface",
jardineb5d44e2003-12-23 08:09:43 +0000506 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -0700507 "ISIS network information\n"
508 "ISIS interface\n")
jardineb5d44e2003-12-23 08:09:43 +0000509{
Josh Bailey3f045a02012-03-24 08:35:20 -0700510 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
jardineb5d44e2003-12-23 08:09:43 +0000511}
512
Josh Bailey3f045a02012-03-24 08:35:20 -0700513DEFUN (show_isis_interface_detail,
514 show_isis_interface_detail_cmd,
515 "show isis interface detail",
jardineb5d44e2003-12-23 08:09:43 +0000516 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -0700517 "ISIS network information\n"
518 "ISIS interface\n"
jardineb5d44e2003-12-23 08:09:43 +0000519 "show detailed information\n")
520{
Josh Bailey3f045a02012-03-24 08:35:20 -0700521 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
jardineb5d44e2003-12-23 08:09:43 +0000522}
523
Josh Bailey3f045a02012-03-24 08:35:20 -0700524DEFUN (show_isis_interface_arg,
525 show_isis_interface_arg_cmd,
526 "show isis interface WORD",
jardineb5d44e2003-12-23 08:09:43 +0000527 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -0700528 "ISIS network information\n"
529 "ISIS interface\n"
530 "ISIS interface name\n")
531{
532 return show_isis_interface_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
533}
534
535/*
536 * 'show isis neighbor' command
537 */
538
539int
540show_isis_neighbor_common (struct vty *vty, const char *id, char detail)
541{
542 struct listnode *anode, *cnode, *node;
543 struct isis_area *area;
544 struct isis_circuit *circuit;
545 struct list *adjdb;
546 struct isis_adjacency *adj;
547 struct isis_dynhn *dynhn;
548 u_char sysid[ISIS_SYS_ID_LEN];
549 int i;
550
551 if (!isis)
552 {
553 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
554 return CMD_SUCCESS;
555 }
556
557 memset (sysid, 0, ISIS_SYS_ID_LEN);
558 if (id)
559 {
560 if (sysid2buff (sysid, id) == 0)
561 {
562 dynhn = dynhn_find_by_name (id);
563 if (dynhn == NULL)
564 {
565 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
566 return CMD_SUCCESS;
567 }
568 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
569 }
570 }
571
572 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
573 {
574 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
575
576 if (detail == ISIS_UI_LEVEL_BRIEF)
577 vty_out (vty, " System Id Interface L State"
578 " Holdtime SNPA%s", VTY_NEWLINE);
579
580 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
581 {
582 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
583 {
584 for (i = 0; i < 2; i++)
585 {
586 adjdb = circuit->u.bc.adjdb[i];
587 if (adjdb && adjdb->count)
588 {
589 for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
590 if (!id || !memcmp (adj->sysid, sysid,
591 ISIS_SYS_ID_LEN))
592 isis_adj_print_vty (adj, vty, detail);
593 }
594 }
595 }
596 else if (circuit->circ_type == CIRCUIT_T_P2P &&
597 circuit->u.p2p.neighbor)
598 {
599 adj = circuit->u.p2p.neighbor;
600 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
601 isis_adj_print_vty (adj, vty, detail);
602 }
603 }
604 }
605
606 return CMD_SUCCESS;
607}
608
609/*
610 * 'clear isis neighbor' command
611 */
612int
613clear_isis_neighbor_common (struct vty *vty, const char *id)
614{
615 struct listnode *anode, *cnode, *cnextnode, *node, *nnode;
616 struct isis_area *area;
617 struct isis_circuit *circuit;
618 struct list *adjdb;
619 struct isis_adjacency *adj;
620 struct isis_dynhn *dynhn;
621 u_char sysid[ISIS_SYS_ID_LEN];
622 int i;
623
624 if (!isis)
625 {
626 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
627 return CMD_SUCCESS;
628 }
629
630 memset (sysid, 0, ISIS_SYS_ID_LEN);
631 if (id)
632 {
633 if (sysid2buff (sysid, id) == 0)
634 {
635 dynhn = dynhn_find_by_name (id);
636 if (dynhn == NULL)
637 {
638 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
639 return CMD_SUCCESS;
640 }
641 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
642 }
643 }
644
645 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
646 {
647 for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnextnode, circuit))
648 {
649 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
650 {
651 for (i = 0; i < 2; i++)
652 {
653 adjdb = circuit->u.bc.adjdb[i];
654 if (adjdb && adjdb->count)
655 {
656 for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj))
657 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
658 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
659 "clear user request");
660 }
661 }
662 }
663 else if (circuit->circ_type == CIRCUIT_T_P2P &&
664 circuit->u.p2p.neighbor)
665 {
666 adj = circuit->u.p2p.neighbor;
667 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
668 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
669 "clear user request");
670 }
671 }
672 }
673
674 return CMD_SUCCESS;
675}
676
677DEFUN (show_isis_neighbor,
678 show_isis_neighbor_cmd,
679 "show isis neighbor",
680 SHOW_STR
681 "ISIS network information\n"
682 "ISIS neighbor adjacencies\n")
683{
684 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
685}
686
687DEFUN (show_isis_neighbor_detail,
688 show_isis_neighbor_detail_cmd,
689 "show isis neighbor detail",
690 SHOW_STR
691 "ISIS network information\n"
692 "ISIS neighbor adjacencies\n"
jardineb5d44e2003-12-23 08:09:43 +0000693 "show detailed information\n")
Josh Bailey3f045a02012-03-24 08:35:20 -0700694{
695 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
696}
697
698DEFUN (show_isis_neighbor_arg,
699 show_isis_neighbor_arg_cmd,
700 "show isis neighbor WORD",
701 SHOW_STR
702 "ISIS network information\n"
703 "ISIS neighbor adjacencies\n"
704 "System id\n")
705{
706 return show_isis_neighbor_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
707}
708
709DEFUN (clear_isis_neighbor,
710 clear_isis_neighbor_cmd,
711 "clear isis neighbor",
712 CLEAR_STR
713 "Reset ISIS network information\n"
714 "Reset ISIS neighbor adjacencies\n")
715{
716 return clear_isis_neighbor_common (vty, NULL);
717}
718
719DEFUN (clear_isis_neighbor_arg,
720 clear_isis_neighbor_arg_cmd,
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700721 "clear isis neighbor WORD",
Josh Bailey3f045a02012-03-24 08:35:20 -0700722 CLEAR_STR
723 "ISIS network information\n"
724 "ISIS neighbor adjacencies\n"
725 "System id\n")
726{
727 return clear_isis_neighbor_common (vty, argv[0]);
728}
729
jardineb5d44e2003-12-23 08:09:43 +0000730/*
731 * 'isis debug', 'show debugging'
732 */
jardineb5d44e2003-12-23 08:09:43 +0000733void
734print_debug (struct vty *vty, int flags, int onoff)
735{
736 char onoffs[4];
737 if (onoff)
hassof390d2c2004-09-10 20:48:21 +0000738 strcpy (onoffs, "on");
jardineb5d44e2003-12-23 08:09:43 +0000739 else
hassof390d2c2004-09-10 20:48:21 +0000740 strcpy (onoffs, "off");
jardineb5d44e2003-12-23 08:09:43 +0000741
742 if (flags & DEBUG_ADJ_PACKETS)
hassof390d2c2004-09-10 20:48:21 +0000743 vty_out (vty, "IS-IS Adjacency related packets debugging is %s%s", onoffs,
744 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000745 if (flags & DEBUG_CHECKSUM_ERRORS)
hassof390d2c2004-09-10 20:48:21 +0000746 vty_out (vty, "IS-IS checksum errors debugging is %s%s", onoffs,
747 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000748 if (flags & DEBUG_LOCAL_UPDATES)
hassof390d2c2004-09-10 20:48:21 +0000749 vty_out (vty, "IS-IS local updates debugging is %s%s", onoffs,
750 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000751 if (flags & DEBUG_PROTOCOL_ERRORS)
hassof390d2c2004-09-10 20:48:21 +0000752 vty_out (vty, "IS-IS protocol errors debugging is %s%s", onoffs,
753 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000754 if (flags & DEBUG_SNP_PACKETS)
hassof390d2c2004-09-10 20:48:21 +0000755 vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s%s", onoffs,
756 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000757 if (flags & DEBUG_SPF_EVENTS)
hassof390d2c2004-09-10 20:48:21 +0000758 vty_out (vty, "IS-IS SPF events debugging is %s%s", onoffs, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000759 if (flags & DEBUG_SPF_STATS)
hassof390d2c2004-09-10 20:48:21 +0000760 vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s%s",
761 onoffs, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000762 if (flags & DEBUG_SPF_TRIGGERS)
hassof390d2c2004-09-10 20:48:21 +0000763 vty_out (vty, "IS-IS SPF triggering events debugging is %s%s", onoffs,
764 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000765 if (flags & DEBUG_UPDATE_PACKETS)
hassof390d2c2004-09-10 20:48:21 +0000766 vty_out (vty, "IS-IS Update related packet debugging is %s%s", onoffs,
767 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000768 if (flags & DEBUG_RTE_EVENTS)
hassof390d2c2004-09-10 20:48:21 +0000769 vty_out (vty, "IS-IS Route related debuggin is %s%s", onoffs,
770 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000771 if (flags & DEBUG_EVENTS)
hassof390d2c2004-09-10 20:48:21 +0000772 vty_out (vty, "IS-IS Event debugging is %s%s", onoffs, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700773 if (flags & DEBUG_PACKET_DUMP)
774 vty_out (vty, "IS-IS Packet dump debugging is %s%s", onoffs, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000775}
776
777DEFUN (show_debugging,
778 show_debugging_cmd,
779 "show debugging",
780 SHOW_STR
781 "State of each debugging option\n")
782{
hassof390d2c2004-09-10 20:48:21 +0000783 vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000784 print_debug (vty, isis->debugs, 1);
785 return CMD_SUCCESS;
786}
787
jardin9e867fe2003-12-23 08:56:18 +0000788/* Debug node. */
hassof390d2c2004-09-10 20:48:21 +0000789static struct cmd_node debug_node = {
jardin9e867fe2003-12-23 08:56:18 +0000790 DEBUG_NODE,
hassof390d2c2004-09-10 20:48:21 +0000791 "",
792 1
jardin9e867fe2003-12-23 08:56:18 +0000793};
794
795static int
796config_write_debug (struct vty *vty)
797{
798 int write = 0;
799 int flags = isis->debugs;
800
hassof390d2c2004-09-10 20:48:21 +0000801 if (flags & DEBUG_ADJ_PACKETS)
802 {
803 vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
804 write++;
805 }
806 if (flags & DEBUG_CHECKSUM_ERRORS)
807 {
808 vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
809 write++;
810 }
811 if (flags & DEBUG_LOCAL_UPDATES)
812 {
813 vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
814 write++;
815 }
816 if (flags & DEBUG_PROTOCOL_ERRORS)
817 {
818 vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
819 write++;
820 }
821 if (flags & DEBUG_SNP_PACKETS)
822 {
823 vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
824 write++;
825 }
826 if (flags & DEBUG_SPF_EVENTS)
827 {
828 vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
829 write++;
830 }
831 if (flags & DEBUG_SPF_STATS)
832 {
833 vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
834 write++;
835 }
836 if (flags & DEBUG_SPF_TRIGGERS)
837 {
838 vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
839 write++;
840 }
841 if (flags & DEBUG_UPDATE_PACKETS)
842 {
843 vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
844 write++;
845 }
846 if (flags & DEBUG_RTE_EVENTS)
847 {
848 vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
849 write++;
850 }
851 if (flags & DEBUG_EVENTS)
852 {
853 vty_out (vty, "debug isis events%s", VTY_NEWLINE);
854 write++;
855 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700856 if (flags & DEBUG_PACKET_DUMP)
857 {
858 vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE);
859 write++;
860 }
jardin9e867fe2003-12-23 08:56:18 +0000861
862 return write;
863}
864
jardineb5d44e2003-12-23 08:09:43 +0000865DEFUN (debug_isis_adj,
866 debug_isis_adj_cmd,
867 "debug isis adj-packets",
868 DEBUG_STR
869 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000870 "IS-IS Adjacency related packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000871{
872 isis->debugs |= DEBUG_ADJ_PACKETS;
hassof390d2c2004-09-10 20:48:21 +0000873 print_debug (vty, DEBUG_ADJ_PACKETS, 1);
jardineb5d44e2003-12-23 08:09:43 +0000874
875 return CMD_SUCCESS;
876}
877
878DEFUN (no_debug_isis_adj,
879 no_debug_isis_adj_cmd,
880 "no debug isis adj-packets",
881 UNDEBUG_STR
882 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000883 "IS-IS Adjacency related packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000884{
jardineb5d44e2003-12-23 08:09:43 +0000885 isis->debugs &= ~DEBUG_ADJ_PACKETS;
886 print_debug (vty, DEBUG_ADJ_PACKETS, 0);
887
888 return CMD_SUCCESS;
889}
890
jardineb5d44e2003-12-23 08:09:43 +0000891DEFUN (debug_isis_csum,
892 debug_isis_csum_cmd,
893 "debug isis checksum-errors",
894 DEBUG_STR
895 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000896 "IS-IS LSP checksum errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000897{
898 isis->debugs |= DEBUG_CHECKSUM_ERRORS;
899 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1);
900
901 return CMD_SUCCESS;
902}
903
904DEFUN (no_debug_isis_csum,
905 no_debug_isis_csum_cmd,
906 "no debug isis checksum-errors",
907 UNDEBUG_STR
908 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000909 "IS-IS LSP checksum errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000910{
911 isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
912 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
hassof390d2c2004-09-10 20:48:21 +0000913
jardineb5d44e2003-12-23 08:09:43 +0000914 return CMD_SUCCESS;
915}
916
917DEFUN (debug_isis_lupd,
918 debug_isis_lupd_cmd,
919 "debug isis local-updates",
920 DEBUG_STR
921 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000922 "IS-IS local update packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000923{
924 isis->debugs |= DEBUG_LOCAL_UPDATES;
925 print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
926
927 return CMD_SUCCESS;
928}
929
930DEFUN (no_debug_isis_lupd,
931 no_debug_isis_lupd_cmd,
932 "no debug isis local-updates",
933 UNDEBUG_STR
934 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000935 "IS-IS local update packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000936{
937 isis->debugs &= ~DEBUG_LOCAL_UPDATES;
hassof390d2c2004-09-10 20:48:21 +0000938 print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
939
jardineb5d44e2003-12-23 08:09:43 +0000940 return CMD_SUCCESS;
941}
942
943DEFUN (debug_isis_err,
944 debug_isis_err_cmd,
hassof390d2c2004-09-10 20:48:21 +0000945 "debug isis protocol-errors",
jardineb5d44e2003-12-23 08:09:43 +0000946 DEBUG_STR
947 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000948 "IS-IS LSP protocol errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000949{
950 isis->debugs |= DEBUG_PROTOCOL_ERRORS;
951 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1);
952
953 return CMD_SUCCESS;
954}
955
956DEFUN (no_debug_isis_err,
957 no_debug_isis_err_cmd,
958 "no debug isis protocol-errors",
959 UNDEBUG_STR
960 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000961 "IS-IS LSP protocol errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000962{
963 isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
964 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
hassof390d2c2004-09-10 20:48:21 +0000965
jardineb5d44e2003-12-23 08:09:43 +0000966 return CMD_SUCCESS;
967}
968
969DEFUN (debug_isis_snp,
970 debug_isis_snp_cmd,
971 "debug isis snp-packets",
972 DEBUG_STR
973 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000974 "IS-IS CSNP/PSNP packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000975{
976 isis->debugs |= DEBUG_SNP_PACKETS;
977 print_debug (vty, DEBUG_SNP_PACKETS, 1);
978
979 return CMD_SUCCESS;
980}
981
982DEFUN (no_debug_isis_snp,
983 no_debug_isis_snp_cmd,
984 "no debug isis snp-packets",
985 UNDEBUG_STR
986 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000987 "IS-IS CSNP/PSNP packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000988{
hassof390d2c2004-09-10 20:48:21 +0000989 isis->debugs &= ~DEBUG_SNP_PACKETS;
jardineb5d44e2003-12-23 08:09:43 +0000990 print_debug (vty, DEBUG_SNP_PACKETS, 0);
hassof390d2c2004-09-10 20:48:21 +0000991
jardineb5d44e2003-12-23 08:09:43 +0000992 return CMD_SUCCESS;
993}
994
jardineb5d44e2003-12-23 08:09:43 +0000995DEFUN (debug_isis_upd,
996 debug_isis_upd_cmd,
997 "debug isis update-packets",
998 DEBUG_STR
999 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001000 "IS-IS Update related packets\n")
jardineb5d44e2003-12-23 08:09:43 +00001001{
1002 isis->debugs |= DEBUG_UPDATE_PACKETS;
1003 print_debug (vty, DEBUG_UPDATE_PACKETS, 1);
1004
1005 return CMD_SUCCESS;
1006}
1007
1008DEFUN (no_debug_isis_upd,
1009 no_debug_isis_upd_cmd,
1010 "no debug isis update-packets",
1011 UNDEBUG_STR
1012 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001013 "IS-IS Update related packets\n")
jardineb5d44e2003-12-23 08:09:43 +00001014{
1015 isis->debugs &= ~DEBUG_UPDATE_PACKETS;
1016 print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
hassof390d2c2004-09-10 20:48:21 +00001017
jardineb5d44e2003-12-23 08:09:43 +00001018 return CMD_SUCCESS;
1019}
1020
jardineb5d44e2003-12-23 08:09:43 +00001021DEFUN (debug_isis_spfevents,
1022 debug_isis_spfevents_cmd,
1023 "debug isis spf-events",
1024 DEBUG_STR
1025 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001026 "IS-IS Shortest Path First Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001027{
1028 isis->debugs |= DEBUG_SPF_EVENTS;
hassof390d2c2004-09-10 20:48:21 +00001029 print_debug (vty, DEBUG_SPF_EVENTS, 1);
jardineb5d44e2003-12-23 08:09:43 +00001030
1031 return CMD_SUCCESS;
1032}
1033
1034DEFUN (no_debug_isis_spfevents,
1035 no_debug_isis_spfevents_cmd,
1036 "no debug isis spf-events",
1037 UNDEBUG_STR
1038 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001039 "IS-IS Shortest Path First Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001040{
1041 isis->debugs &= ~DEBUG_SPF_EVENTS;
hassof390d2c2004-09-10 20:48:21 +00001042 print_debug (vty, DEBUG_SPF_EVENTS, 0);
1043
jardineb5d44e2003-12-23 08:09:43 +00001044 return CMD_SUCCESS;
1045}
1046
jardineb5d44e2003-12-23 08:09:43 +00001047DEFUN (debug_isis_spfstats,
1048 debug_isis_spfstats_cmd,
1049 "debug isis spf-statistics ",
1050 DEBUG_STR
1051 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001052 "IS-IS SPF Timing and Statistic Data\n")
jardineb5d44e2003-12-23 08:09:43 +00001053{
1054 isis->debugs |= DEBUG_SPF_STATS;
1055 print_debug (vty, DEBUG_SPF_STATS, 1);
1056
1057 return CMD_SUCCESS;
1058}
1059
1060DEFUN (no_debug_isis_spfstats,
1061 no_debug_isis_spfstats_cmd,
1062 "no debug isis spf-statistics",
1063 UNDEBUG_STR
1064 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001065 "IS-IS SPF Timing and Statistic Data\n")
jardineb5d44e2003-12-23 08:09:43 +00001066{
1067 isis->debugs &= ~DEBUG_SPF_STATS;
1068 print_debug (vty, DEBUG_SPF_STATS, 0);
hassof390d2c2004-09-10 20:48:21 +00001069
jardineb5d44e2003-12-23 08:09:43 +00001070 return CMD_SUCCESS;
1071}
1072
1073DEFUN (debug_isis_spftrigg,
1074 debug_isis_spftrigg_cmd,
1075 "debug isis spf-triggers",
1076 DEBUG_STR
1077 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001078 "IS-IS SPF triggering events\n")
jardineb5d44e2003-12-23 08:09:43 +00001079{
1080 isis->debugs |= DEBUG_SPF_TRIGGERS;
1081 print_debug (vty, DEBUG_SPF_TRIGGERS, 1);
1082
1083 return CMD_SUCCESS;
1084}
1085
1086DEFUN (no_debug_isis_spftrigg,
1087 no_debug_isis_spftrigg_cmd,
1088 "no debug isis spf-triggers",
1089 UNDEBUG_STR
1090 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001091 "IS-IS SPF triggering events\n")
jardineb5d44e2003-12-23 08:09:43 +00001092{
1093 isis->debugs &= ~DEBUG_SPF_TRIGGERS;
1094 print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
hassof390d2c2004-09-10 20:48:21 +00001095
jardineb5d44e2003-12-23 08:09:43 +00001096 return CMD_SUCCESS;
1097}
1098
1099DEFUN (debug_isis_rtevents,
1100 debug_isis_rtevents_cmd,
1101 "debug isis route-events",
1102 DEBUG_STR
1103 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001104 "IS-IS Route related events\n")
jardineb5d44e2003-12-23 08:09:43 +00001105{
1106 isis->debugs |= DEBUG_RTE_EVENTS;
1107 print_debug (vty, DEBUG_RTE_EVENTS, 1);
1108
1109 return CMD_SUCCESS;
1110}
1111
1112DEFUN (no_debug_isis_rtevents,
1113 no_debug_isis_rtevents_cmd,
1114 "no debug isis route-events",
1115 UNDEBUG_STR
1116 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001117 "IS-IS Route related events\n")
jardineb5d44e2003-12-23 08:09:43 +00001118{
1119 isis->debugs &= ~DEBUG_RTE_EVENTS;
1120 print_debug (vty, DEBUG_RTE_EVENTS, 0);
hassof390d2c2004-09-10 20:48:21 +00001121
jardineb5d44e2003-12-23 08:09:43 +00001122 return CMD_SUCCESS;
1123}
1124
1125DEFUN (debug_isis_events,
1126 debug_isis_events_cmd,
1127 "debug isis events",
1128 DEBUG_STR
1129 "IS-IS information\n"
hassof1082d12005-09-19 04:23:34 +00001130 "IS-IS Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001131{
1132 isis->debugs |= DEBUG_EVENTS;
1133 print_debug (vty, DEBUG_EVENTS, 1);
1134
1135 return CMD_SUCCESS;
1136}
1137
1138DEFUN (no_debug_isis_events,
1139 no_debug_isis_events_cmd,
1140 "no debug isis events",
1141 UNDEBUG_STR
1142 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001143 "IS-IS Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001144{
1145 isis->debugs &= ~DEBUG_EVENTS;
1146 print_debug (vty, DEBUG_EVENTS, 0);
hassof390d2c2004-09-10 20:48:21 +00001147
jardineb5d44e2003-12-23 08:09:43 +00001148 return CMD_SUCCESS;
1149}
1150
Josh Bailey3f045a02012-03-24 08:35:20 -07001151DEFUN (debug_isis_packet_dump,
1152 debug_isis_packet_dump_cmd,
1153 "debug isis packet-dump",
1154 DEBUG_STR
1155 "IS-IS information\n"
1156 "IS-IS packet dump\n")
1157{
1158 isis->debugs |= DEBUG_PACKET_DUMP;
1159 print_debug (vty, DEBUG_PACKET_DUMP, 1);
1160
1161 return CMD_SUCCESS;
1162}
1163
1164DEFUN (no_debug_isis_packet_dump,
1165 no_debug_isis_packet_dump_cmd,
1166 "no debug isis packet-dump",
1167 UNDEBUG_STR
1168 "IS-IS information\n"
1169 "IS-IS packet dump\n")
1170{
1171 isis->debugs &= ~DEBUG_PACKET_DUMP;
1172 print_debug (vty, DEBUG_PACKET_DUMP, 0);
1173
1174 return CMD_SUCCESS;
1175}
1176
jardineb5d44e2003-12-23 08:09:43 +00001177DEFUN (show_hostname,
1178 show_hostname_cmd,
1179 "show isis hostname",
1180 SHOW_STR
1181 "IS-IS information\n"
1182 "IS-IS Dynamic hostname mapping\n")
1183{
1184 dynhn_print_all (vty);
hassof390d2c2004-09-10 20:48:21 +00001185
jardineb5d44e2003-12-23 08:09:43 +00001186 return CMD_SUCCESS;
1187}
1188
Josh Bailey3f045a02012-03-24 08:35:20 -07001189static void
1190vty_out_timestr(struct vty *vty, time_t uptime)
1191{
1192 struct tm *tm;
1193 time_t difftime = time (NULL);
1194 difftime -= uptime;
1195 tm = gmtime (&difftime);
1196
1197#define ONE_DAY_SECOND 60*60*24
1198#define ONE_WEEK_SECOND 60*60*24*7
1199 if (difftime < ONE_DAY_SECOND)
1200 vty_out (vty, "%02d:%02d:%02d",
1201 tm->tm_hour, tm->tm_min, tm->tm_sec);
1202 else if (difftime < ONE_WEEK_SECOND)
1203 vty_out (vty, "%dd%02dh%02dm",
1204 tm->tm_yday, tm->tm_hour, tm->tm_min);
1205 else
1206 vty_out (vty, "%02dw%dd%02dh",
1207 tm->tm_yday/7,
1208 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1209 vty_out (vty, " ago");
1210}
1211
1212DEFUN (show_isis_summary,
1213 show_isis_summary_cmd,
1214 "show isis summary",
1215 SHOW_STR "IS-IS information\n" "IS-IS summary\n")
1216{
1217 struct listnode *node, *node2;
1218 struct isis_area *area;
1219 struct isis_spftree *spftree;
1220 int level;
1221
1222 if (isis == NULL)
1223 {
1224 vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
1225 return CMD_SUCCESS;
1226 }
1227
1228 vty_out (vty, "Process Id : %ld%s", isis->process_id,
1229 VTY_NEWLINE);
1230 if (isis->sysid_set)
1231 vty_out (vty, "System Id : %s%s", sysid_print (isis->sysid),
1232 VTY_NEWLINE);
1233
1234 vty_out (vty, "Up time : ");
1235 vty_out_timestr(vty, isis->uptime);
1236 vty_out (vty, "%s", VTY_NEWLINE);
1237
1238 if (isis->area_list)
1239 vty_out (vty, "Number of areas : %d%s", isis->area_list->count,
1240 VTY_NEWLINE);
1241
1242 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1243 {
1244 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1245 VTY_NEWLINE);
1246
1247 if (listcount (area->area_addrs) > 0)
1248 {
1249 struct area_addr *area_addr;
1250 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
1251 {
1252 vty_out (vty, " Net: %s%s",
1253 isonet_print (area_addr->area_addr,
1254 area_addr->addr_len + ISIS_SYS_ID_LEN +
1255 1), VTY_NEWLINE);
1256 }
1257 }
1258
1259 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
1260 {
1261 if ((area->is_type & level) == 0)
1262 continue;
1263
1264 vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE);
1265 spftree = area->spftree[level - 1];
1266 if (spftree->pending)
1267 vty_out (vty, " IPv4 SPF: (pending)%s", VTY_NEWLINE);
1268 else
1269 vty_out (vty, " IPv4 SPF:%s", VTY_NEWLINE);
1270
1271 vty_out (vty, " minimum interval : %d%s",
1272 area->min_spf_interval[level - 1], VTY_NEWLINE);
1273
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001274 vty_out (vty, " last run elapsed : ");
1275 vty_out_timestr(vty, spftree->last_run_timestamp);
Josh Bailey3f045a02012-03-24 08:35:20 -07001276 vty_out (vty, "%s", VTY_NEWLINE);
1277
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001278 vty_out (vty, " last run duration : %u usec%s",
1279 (u_int32_t)spftree->last_run_duration, VTY_NEWLINE);
1280
Josh Bailey3f045a02012-03-24 08:35:20 -07001281 vty_out (vty, " run count : %d%s",
1282 spftree->runcount, VTY_NEWLINE);
1283
1284#ifdef HAVE_IPV6
1285 spftree = area->spftree6[level - 1];
1286 if (spftree->pending)
1287 vty_out (vty, " IPv6 SPF: (pending)%s", VTY_NEWLINE);
1288 else
1289 vty_out (vty, " IPv6 SPF:%s", VTY_NEWLINE);
1290
1291 vty_out (vty, " minimum interval : %d%s",
1292 area->min_spf_interval[level - 1], VTY_NEWLINE);
1293
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001294 vty_out (vty, " last run elapsed : ");
1295 vty_out_timestr(vty, spftree->last_run_timestamp);
Josh Bailey3f045a02012-03-24 08:35:20 -07001296 vty_out (vty, "%s", VTY_NEWLINE);
1297
David Lamparteref008d22015-03-03 08:48:11 +01001298 vty_out (vty, " last run duration : %llu msec%s",
1299 (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001300
Josh Bailey3f045a02012-03-24 08:35:20 -07001301 vty_out (vty, " run count : %d%s",
1302 spftree->runcount, VTY_NEWLINE);
1303#endif
1304 }
1305 }
1306 vty_out (vty, "%s", VTY_NEWLINE);
1307
1308 return CMD_SUCCESS;
1309}
1310
1311/*
1312 * This function supports following display options:
1313 * [ show isis database [detail] ]
1314 * [ show isis database <sysid> [detail] ]
1315 * [ show isis database <hostname> [detail] ]
1316 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1317 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1318 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1319 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1320 * [ show isis database detail <sysid> ]
1321 * [ show isis database detail <hostname> ]
1322 * [ show isis database detail <sysid>.<pseudo-id> ]
1323 * [ show isis database detail <hostname>.<pseudo-id> ]
1324 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1325 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1326 */
1327static int
1328show_isis_database (struct vty *vty, const char *argv, int ui_level)
jardineb5d44e2003-12-23 08:09:43 +00001329{
hasso3fdb2dd2005-09-28 18:45:54 +00001330 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +00001331 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07001332 struct isis_lsp *lsp;
1333 struct isis_dynhn *dynhn;
1334 const char *pos = argv;
1335 u_char lspid[ISIS_SYS_ID_LEN+2];
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001336 char sysid[255];
Josh Bailey3f045a02012-03-24 08:35:20 -07001337 u_char number[3];
hassof390d2c2004-09-10 20:48:21 +00001338 int level, lsp_count;
jardineb5d44e2003-12-23 08:09:43 +00001339
1340 if (isis->area_list->count == 0)
1341 return CMD_SUCCESS;
jardineb5d44e2003-12-23 08:09:43 +00001342
Josh Bailey3f045a02012-03-24 08:35:20 -07001343 memset (&lspid, 0, ISIS_SYS_ID_LEN);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001344 memset (&sysid, 0, 255);
Josh Bailey3f045a02012-03-24 08:35:20 -07001345
1346 /*
1347 * extract fragment and pseudo id from the string argv
1348 * in the forms:
1349 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1350 * (b) <systemid/hostname>.<pseudo-id> or
1351 * (c) <systemid/hostname> or
1352 * Where systemid is in the form:
1353 * xxxx.xxxx.xxxx
1354 */
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001355 if (argv)
1356 strncpy (sysid, argv, 254);
Josh Bailey3f045a02012-03-24 08:35:20 -07001357 if (argv && strlen (argv) > 3)
1358 {
1359 pos = argv + strlen (argv) - 3;
1360 if (strncmp (pos, "-", 1) == 0)
1361 {
1362 memcpy (number, ++pos, 2);
1363 lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16);
1364 pos -= 4;
1365 if (strncmp (pos, ".", 1) != 0)
1366 return CMD_ERR_AMBIGUOUS;
1367 }
1368 if (strncmp (pos, ".", 1) == 0)
1369 {
1370 memcpy (number, ++pos, 2);
1371 lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16);
1372 sysid[pos - argv - 1] = '\0';
1373 }
1374 }
1375
hasso3fdb2dd2005-09-28 18:45:54 +00001376 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof390d2c2004-09-10 20:48:21 +00001377 {
hassof390d2c2004-09-10 20:48:21 +00001378 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
Josh Bailey3f045a02012-03-24 08:35:20 -07001379 VTY_NEWLINE);
1380
hassof390d2c2004-09-10 20:48:21 +00001381 for (level = 0; level < ISIS_LEVELS; level++)
Josh Bailey3f045a02012-03-24 08:35:20 -07001382 {
1383 if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
1384 {
1385 lsp = NULL;
1386 if (argv != NULL)
1387 {
1388 /*
1389 * Try to find the lsp-id if the argv string is in
1390 * the form hostname.<pseudo-id>-<fragment>
1391 */
1392 if (sysid2buff (lspid, sysid))
1393 {
1394 lsp = lsp_search (lspid, area->lspdb[level]);
1395 }
1396 else if ((dynhn = dynhn_find_by_name (sysid)))
1397 {
1398 memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN);
1399 lsp = lsp_search (lspid, area->lspdb[level]);
1400 }
1401 else if (strncmp(unix_hostname (), sysid, 15) == 0)
1402 {
1403 memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
1404 lsp = lsp_search (lspid, area->lspdb[level]);
1405 }
1406 }
jardineb5d44e2003-12-23 08:09:43 +00001407
Josh Bailey3f045a02012-03-24 08:35:20 -07001408 if (lsp != NULL || argv == NULL)
1409 {
1410 vty_out (vty, "IS-IS Level-%d link-state database:%s",
1411 level + 1, VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +00001412
Josh Bailey3f045a02012-03-24 08:35:20 -07001413 /* print the title in all cases */
1414 vty_out (vty, "LSP ID PduLen "
1415 "SeqNumber Chksum Holdtime ATT/P/OL%s",
1416 VTY_NEWLINE);
1417 }
1418
1419 if (lsp)
1420 {
1421 if (ui_level == ISIS_UI_LEVEL_DETAIL)
1422 lsp_print_detail (lsp, vty, area->dynhostname);
1423 else
1424 lsp_print (lsp, vty, area->dynhostname);
1425 }
1426 else if (argv == NULL)
1427 {
1428 lsp_count = lsp_print_all (vty, area->lspdb[level],
1429 ui_level,
1430 area->dynhostname);
1431
1432 vty_out (vty, " %u LSPs%s%s",
1433 lsp_count, VTY_NEWLINE, VTY_NEWLINE);
1434 }
1435 }
1436 }
jardineb5d44e2003-12-23 08:09:43 +00001437 }
jardineb5d44e2003-12-23 08:09:43 +00001438
1439 return CMD_SUCCESS;
1440}
1441
Josh Bailey3f045a02012-03-24 08:35:20 -07001442DEFUN (show_database_brief,
1443 show_database_cmd,
1444 "show isis database",
1445 SHOW_STR
1446 "IS-IS information\n"
1447 "IS-IS link state database\n")
1448{
1449 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_BRIEF);
1450}
1451
1452DEFUN (show_database_lsp_brief,
1453 show_database_arg_cmd,
1454 "show isis database WORD",
1455 SHOW_STR
1456 "IS-IS information\n"
1457 "IS-IS link state database\n"
1458 "LSP ID\n")
1459{
1460 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_BRIEF);
1461}
1462
1463DEFUN (show_database_lsp_detail,
1464 show_database_arg_detail_cmd,
1465 "show isis database WORD detail",
1466 SHOW_STR
1467 "IS-IS information\n"
1468 "IS-IS link state database\n"
1469 "LSP ID\n"
1470 "Detailed information\n")
1471{
1472 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
1473}
1474
jardineb5d44e2003-12-23 08:09:43 +00001475DEFUN (show_database_detail,
1476 show_database_detail_cmd,
1477 "show isis database detail",
1478 SHOW_STR
1479 "IS-IS information\n"
1480 "IS-IS link state database\n")
1481{
Josh Bailey3f045a02012-03-24 08:35:20 -07001482 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_DETAIL);
1483}
jardineb5d44e2003-12-23 08:09:43 +00001484
Josh Bailey3f045a02012-03-24 08:35:20 -07001485DEFUN (show_database_detail_lsp,
1486 show_database_detail_arg_cmd,
1487 "show isis database detail WORD",
1488 SHOW_STR
1489 "IS-IS information\n"
1490 "IS-IS link state database\n"
1491 "Detailed information\n"
1492 "LSP ID\n")
1493{
1494 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
jardineb5d44e2003-12-23 08:09:43 +00001495}
1496
1497/*
1498 * 'router isis' command
1499 */
1500DEFUN (router_isis,
1501 router_isis_cmd,
1502 "router isis WORD",
hassof390d2c2004-09-10 20:48:21 +00001503 ROUTER_STR
jardineb5d44e2003-12-23 08:09:43 +00001504 "ISO IS-IS\n"
1505 "ISO Routing area tag")
1506{
jardineb5d44e2003-12-23 08:09:43 +00001507 return isis_area_get (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001508}
1509
1510/*
1511 *'no router isis' command
1512 */
1513DEFUN (no_router_isis,
1514 no_router_isis_cmd,
1515 "no router isis WORD",
hassof390d2c2004-09-10 20:48:21 +00001516 "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
jardineb5d44e2003-12-23 08:09:43 +00001517{
1518 return isis_area_destroy (vty, argv[0]);
1519}
1520
1521/*
1522 * 'net' command
1523 */
1524DEFUN (net,
1525 net_cmd,
1526 "net WORD",
1527 "A Network Entity Title for this process (OSI only)\n"
hassof390d2c2004-09-10 20:48:21 +00001528 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00001529{
Paul Jakma41b36e92006-12-08 01:09:50 +00001530 return area_net_title (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001531}
1532
jardineb5d44e2003-12-23 08:09:43 +00001533/*
1534 * 'no net' command
1535 */
1536DEFUN (no_net,
1537 no_net_cmd,
1538 "no net WORD",
1539 NO_STR
1540 "A Network Entity Title for this process (OSI only)\n"
hassof390d2c2004-09-10 20:48:21 +00001541 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00001542{
Paul Jakma41b36e92006-12-08 01:09:50 +00001543 return area_clear_net_title (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001544}
1545
Christian Frankef1fc1db2015-11-10 18:43:31 +01001546static
1547int area_set_lsp_mtu(struct vty *vty, struct isis_area *area, unsigned int lsp_mtu)
1548{
1549 struct isis_circuit *circuit;
1550 struct listnode *node;
1551
1552 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
1553 {
1554 if(lsp_mtu > isis_circuit_pdu_size(circuit))
1555 {
1556 vty_out(vty, "ISIS area contains circuit %s, which has a maximum PDU size of %zu.%s",
1557 circuit->interface->name, isis_circuit_pdu_size(circuit),
1558 VTY_NEWLINE);
1559 return CMD_ERR_AMBIGUOUS;
1560 }
1561 }
1562
1563 area->lsp_mtu = lsp_mtu;
1564 lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
1565
1566 return CMD_SUCCESS;
1567}
1568
1569DEFUN (area_lsp_mtu,
1570 area_lsp_mtu_cmd,
1571 "lsp-mtu <128-4352>",
1572 "Configure the maximum size of generated LSPs\n"
1573 "Maximum size of generated LSPs\n")
1574{
1575 struct isis_area *area;
1576
1577 area = vty->index;
1578 if (!area)
1579 {
1580 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1581 return CMD_ERR_NO_MATCH;
1582 }
1583
1584 unsigned int lsp_mtu;
1585
1586 VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[0], 128, 4352);
1587
1588 return area_set_lsp_mtu(vty, area, lsp_mtu);
1589}
1590
1591DEFUN(no_area_lsp_mtu,
1592 no_area_lsp_mtu_cmd,
1593 "no lsp-mtu",
1594 NO_STR
1595 "Configure the maximum size of generated LSPs\n")
1596{
1597 struct isis_area *area;
1598
1599 area = vty->index;
1600 if (!area)
1601 {
1602 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1603 return CMD_ERR_NO_MATCH;
1604 }
1605
1606 return area_set_lsp_mtu(vty, area, DEFAULT_LSP_MTU);
1607}
1608
1609ALIAS(no_area_lsp_mtu,
1610 no_area_lsp_mtu_arg_cmd,
1611 "no lsp-mtu <128-4352>",
1612 NO_STR
1613 "Configure the maximum size of generated LSPs\n"
1614 "Maximum size of generated LSPs\n");
1615
Josh Bailey3f045a02012-03-24 08:35:20 -07001616DEFUN (area_passwd_md5,
1617 area_passwd_md5_cmd,
1618 "area-password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001619 "Configure the authentication password for an area\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001620 "Authentication type\n"
hassof390d2c2004-09-10 20:48:21 +00001621 "Area password\n")
jardineb5d44e2003-12-23 08:09:43 +00001622{
1623 struct isis_area *area;
1624 int len;
1625
1626 area = vty->index;
1627
hassof390d2c2004-09-10 20:48:21 +00001628 if (!area)
1629 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001630 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1631 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001632 }
1633
jardineb5d44e2003-12-23 08:09:43 +00001634 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001635 if (len > 254)
1636 {
1637 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001638 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001639 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001640
1641 area->area_passwd.len = (u_char) len;
1642 area->area_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1643 strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
1644
1645 if (argc > 1)
1646 {
1647 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1648 if (strncmp(argv[1], "v", 1) == 0)
1649 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1650 else
1651 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1652 }
1653 else
1654 {
1655 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1656 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1657 }
1658 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1659
1660 return CMD_SUCCESS;
1661}
1662
1663ALIAS (area_passwd_md5,
1664 area_passwd_md5_snpauth_cmd,
1665 "area-password md5 WORD authenticate snp (send-only|validate)",
1666 "Configure the authentication password for an area\n"
1667 "Authentication type\n"
1668 "Area password\n"
1669 "Authentication\n"
1670 "SNP PDUs\n"
1671 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001672 "Send and check PDUs on receiving\n")
Josh Bailey3f045a02012-03-24 08:35:20 -07001673
1674DEFUN (area_passwd_clear,
1675 area_passwd_clear_cmd,
1676 "area-password clear WORD",
1677 "Configure the authentication password for an area\n"
1678 "Authentication type\n"
1679 "Area password\n")
1680{
1681 struct isis_area *area;
1682 int len;
1683
1684 area = vty->index;
1685
1686 if (!area)
1687 {
1688 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1689 return CMD_ERR_NO_MATCH;
1690 }
1691
1692 len = strlen (argv[0]);
1693 if (len > 254)
1694 {
1695 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1696 return CMD_ERR_AMBIGUOUS;
1697 }
1698
hassof390d2c2004-09-10 20:48:21 +00001699 area->area_passwd.len = (u_char) len;
jardineb5d44e2003-12-23 08:09:43 +00001700 area->area_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001701 strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001702
hasso1cbc5622005-01-01 10:29:51 +00001703 if (argc > 1)
1704 {
1705 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1706 if (strncmp(argv[1], "v", 1) == 0)
1707 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1708 else
1709 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1710 }
1711 else
1712 {
1713 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1714 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1715 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001716 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hasso1cbc5622005-01-01 10:29:51 +00001717
jardineb5d44e2003-12-23 08:09:43 +00001718 return CMD_SUCCESS;
1719}
1720
Josh Bailey3f045a02012-03-24 08:35:20 -07001721ALIAS (area_passwd_clear,
1722 area_passwd_clear_snpauth_cmd,
1723 "area-password clear WORD authenticate snp (send-only|validate)",
hasso1cbc5622005-01-01 10:29:51 +00001724 "Configure the authentication password for an area\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001725 "Authentication type\n"
hasso1cbc5622005-01-01 10:29:51 +00001726 "Area password\n"
1727 "Authentication\n"
1728 "SNP PDUs\n"
1729 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001730 "Send and check PDUs on receiving\n")
hasso1cbc5622005-01-01 10:29:51 +00001731
jardineb5d44e2003-12-23 08:09:43 +00001732DEFUN (no_area_passwd,
1733 no_area_passwd_cmd,
1734 "no area-password",
1735 NO_STR
1736 "Configure the authentication password for an area\n")
1737{
1738 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00001739
jardineb5d44e2003-12-23 08:09:43 +00001740 area = vty->index;
1741
hassof390d2c2004-09-10 20:48:21 +00001742 if (!area)
1743 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001744 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1745 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001746 }
1747
jardineb5d44e2003-12-23 08:09:43 +00001748 memset (&area->area_passwd, 0, sizeof (struct isis_passwd));
Josh Bailey3f045a02012-03-24 08:35:20 -07001749 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
jardineb5d44e2003-12-23 08:09:43 +00001750
1751 return CMD_SUCCESS;
1752}
1753
Josh Bailey3f045a02012-03-24 08:35:20 -07001754DEFUN (domain_passwd_md5,
1755 domain_passwd_md5_cmd,
1756 "domain-password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001757 "Set the authentication password for a routing domain\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001758 "Authentication type\n"
hassof390d2c2004-09-10 20:48:21 +00001759 "Routing domain password\n")
jardineb5d44e2003-12-23 08:09:43 +00001760{
1761 struct isis_area *area;
1762 int len;
1763
1764 area = vty->index;
1765
hassof390d2c2004-09-10 20:48:21 +00001766 if (!area)
1767 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001768 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1769 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001770 }
1771
jardineb5d44e2003-12-23 08:09:43 +00001772 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001773 if (len > 254)
1774 {
1775 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001776 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001777 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001778
1779 area->domain_passwd.len = (u_char) len;
1780 area->domain_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1781 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
1782
1783 if (argc > 1)
1784 {
1785 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1786 if (strncmp(argv[1], "v", 1) == 0)
1787 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1788 else
1789 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1790 }
1791 else
1792 {
1793 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1794 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1795 }
1796 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1797
1798 return CMD_SUCCESS;
1799}
1800
1801ALIAS (domain_passwd_md5,
1802 domain_passwd_md5_snpauth_cmd,
1803 "domain-password md5 WORD authenticate snp (send-only|validate)",
1804 "Set the authentication password for a routing domain\n"
1805 "Authentication type\n"
1806 "Routing domain password\n"
1807 "Authentication\n"
1808 "SNP PDUs\n"
1809 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001810 "Send and check PDUs on receiving\n")
Josh Bailey3f045a02012-03-24 08:35:20 -07001811
1812DEFUN (domain_passwd_clear,
1813 domain_passwd_clear_cmd,
1814 "domain-password clear WORD",
1815 "Set the authentication password for a routing domain\n"
1816 "Authentication type\n"
1817 "Routing domain password\n")
1818{
1819 struct isis_area *area;
1820 int len;
1821
1822 area = vty->index;
1823
1824 if (!area)
1825 {
1826 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1827 return CMD_ERR_NO_MATCH;
1828 }
1829
1830 len = strlen (argv[0]);
1831 if (len > 254)
1832 {
1833 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1834 return CMD_ERR_AMBIGUOUS;
1835 }
1836
hassof390d2c2004-09-10 20:48:21 +00001837 area->domain_passwd.len = (u_char) len;
jardineb5d44e2003-12-23 08:09:43 +00001838 area->domain_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001839 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001840
hasso1cbc5622005-01-01 10:29:51 +00001841 if (argc > 1)
1842 {
1843 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1844 if (strncmp(argv[1], "v", 1) == 0)
1845 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1846 else
1847 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1848 }
1849 else
1850 {
1851 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1852 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1853 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001854 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hasso1cbc5622005-01-01 10:29:51 +00001855
jardineb5d44e2003-12-23 08:09:43 +00001856 return CMD_SUCCESS;
1857}
1858
Josh Bailey3f045a02012-03-24 08:35:20 -07001859ALIAS (domain_passwd_clear,
1860 domain_passwd_clear_snpauth_cmd,
1861 "domain-password clear WORD authenticate snp (send-only|validate)",
hasso1cbc5622005-01-01 10:29:51 +00001862 "Set the authentication password for a routing domain\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001863 "Authentication type\n"
hasso1cbc5622005-01-01 10:29:51 +00001864 "Routing domain password\n"
1865 "Authentication\n"
1866 "SNP PDUs\n"
1867 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001868 "Send and check PDUs on receiving\n")
hasso1cbc5622005-01-01 10:29:51 +00001869
jardineb5d44e2003-12-23 08:09:43 +00001870DEFUN (no_domain_passwd,
1871 no_domain_passwd_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07001872 "no domain-password",
jardineb5d44e2003-12-23 08:09:43 +00001873 NO_STR
1874 "Set the authentication password for a routing domain\n")
1875{
1876 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00001877
jardineb5d44e2003-12-23 08:09:43 +00001878 area = vty->index;
1879
hassof390d2c2004-09-10 20:48:21 +00001880 if (!area)
1881 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001882 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1883 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001884 }
1885
jardineb5d44e2003-12-23 08:09:43 +00001886 memset (&area->domain_passwd, 0, sizeof (struct isis_passwd));
Josh Bailey3f045a02012-03-24 08:35:20 -07001887 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hassof390d2c2004-09-10 20:48:21 +00001888
jardineb5d44e2003-12-23 08:09:43 +00001889 return CMD_SUCCESS;
1890}
1891
1892DEFUN (is_type,
1893 is_type_cmd,
1894 "is-type (level-1|level-1-2|level-2-only)",
1895 "IS Level for this routing process (OSI only)\n"
1896 "Act as a station router only\n"
1897 "Act as both a station router and an area router\n"
1898 "Act as an area router only\n")
1899{
1900 struct isis_area *area;
1901 int type;
1902
1903 area = vty->index;
1904
hassof390d2c2004-09-10 20:48:21 +00001905 if (!area)
1906 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001907 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1908 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001909 }
jardineb5d44e2003-12-23 08:09:43 +00001910
Paul Jakma41b36e92006-12-08 01:09:50 +00001911 type = string2circuit_t (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001912 if (!type)
1913 {
1914 vty_out (vty, "Unknown IS level %s", VTY_NEWLINE);
1915 return CMD_SUCCESS;
1916 }
jardineb5d44e2003-12-23 08:09:43 +00001917
1918 isis_event_system_type_change (area, type);
hassof390d2c2004-09-10 20:48:21 +00001919
jardineb5d44e2003-12-23 08:09:43 +00001920 return CMD_SUCCESS;
1921}
1922
1923DEFUN (no_is_type,
1924 no_is_type_cmd,
1925 "no is-type (level-1|level-1-2|level-2-only)",
1926 NO_STR
1927 "IS Level for this routing process (OSI only)\n"
1928 "Act as a station router only\n"
1929 "Act as both a station router and an area router\n"
1930 "Act as an area router only\n")
1931{
jardineb5d44e2003-12-23 08:09:43 +00001932 struct isis_area *area;
1933 int type;
1934
1935 area = vty->index;
1936 assert (area);
hassof390d2c2004-09-10 20:48:21 +00001937
jardineb5d44e2003-12-23 08:09:43 +00001938 /*
Josh Bailey3f045a02012-03-24 08:35:20 -07001939 * Put the is-type back to defaults:
1940 * - level-1-2 on first area
1941 * - level-1 for the rest
jardineb5d44e2003-12-23 08:09:43 +00001942 */
paul1eb8ef22005-04-07 07:30:20 +00001943 if (listgetdata (listhead (isis->area_list)) == area)
jardineb5d44e2003-12-23 08:09:43 +00001944 type = IS_LEVEL_1_AND_2;
1945 else
1946 type = IS_LEVEL_1;
1947
1948 isis_event_system_type_change (area, type);
1949
1950 return CMD_SUCCESS;
1951}
1952
Josh Bailey3f045a02012-03-24 08:35:20 -07001953static int
1954set_lsp_gen_interval (struct vty *vty, struct isis_area *area,
1955 uint16_t interval, int level)
1956{
1957 int lvl;
1958
1959 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
1960 {
1961 if (!(lvl & level))
1962 continue;
1963
1964 if (interval >= area->lsp_refresh[lvl-1])
1965 {
1966 vty_out (vty, "LSP gen interval %us must be less than "
1967 "the LSP refresh interval %us%s",
1968 interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
1969 return CMD_ERR_AMBIGUOUS;
1970 }
1971 }
1972
1973 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
1974 {
1975 if (!(lvl & level))
1976 continue;
1977 area->lsp_gen_interval[lvl-1] = interval;
1978 }
1979
1980 return CMD_SUCCESS;
1981}
1982
jardineb5d44e2003-12-23 08:09:43 +00001983DEFUN (lsp_gen_interval,
1984 lsp_gen_interval_cmd,
1985 "lsp-gen-interval <1-120>",
1986 "Minimum interval between regenerating same LSP\n"
1987 "Minimum interval in seconds\n")
1988{
1989 struct isis_area *area;
1990 uint16_t interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07001991 int level;
jardineb5d44e2003-12-23 08:09:43 +00001992
1993 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001994 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07001995 level = IS_LEVEL_1 | IS_LEVEL_2;
1996 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00001997}
1998
1999DEFUN (no_lsp_gen_interval,
2000 no_lsp_gen_interval_cmd,
2001 "no lsp-gen-interval",
2002 NO_STR
hassof390d2c2004-09-10 20:48:21 +00002003 "Minimum interval between regenerating same LSP\n")
jardineb5d44e2003-12-23 08:09:43 +00002004{
2005 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002006 uint16_t interval;
2007 int level;
jardineb5d44e2003-12-23 08:09:43 +00002008
2009 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002010 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2011 level = IS_LEVEL_1 | IS_LEVEL_2;
2012 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002013}
2014
2015ALIAS (no_lsp_gen_interval,
2016 no_lsp_gen_interval_arg_cmd,
2017 "no lsp-gen-interval <1-120>",
2018 NO_STR
2019 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002020 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002021
2022DEFUN (lsp_gen_interval_l1,
2023 lsp_gen_interval_l1_cmd,
2024 "lsp-gen-interval level-1 <1-120>",
2025 "Minimum interval between regenerating same LSP\n"
2026 "Set interval for level 1 only\n"
hassof390d2c2004-09-10 20:48:21 +00002027 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002028{
2029 struct isis_area *area;
2030 uint16_t interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002031 int level;
jardineb5d44e2003-12-23 08:09:43 +00002032
2033 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002034 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002035 level = IS_LEVEL_1;
2036 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002037}
2038
2039DEFUN (no_lsp_gen_interval_l1,
2040 no_lsp_gen_interval_l1_cmd,
2041 "no lsp-gen-interval level-1",
2042 NO_STR
2043 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002044 "Set interval for level 1 only\n")
jardineb5d44e2003-12-23 08:09:43 +00002045{
2046 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002047 uint16_t interval;
2048 int level;
jardineb5d44e2003-12-23 08:09:43 +00002049
2050 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002051 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2052 level = IS_LEVEL_1;
2053 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002054}
2055
2056ALIAS (no_lsp_gen_interval_l1,
2057 no_lsp_gen_interval_l1_arg_cmd,
2058 "no lsp-gen-interval level-1 <1-120>",
2059 NO_STR
2060 "Minimum interval between regenerating same LSP\n"
2061 "Set interval for level 1 only\n"
hassof390d2c2004-09-10 20:48:21 +00002062 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002063
2064DEFUN (lsp_gen_interval_l2,
2065 lsp_gen_interval_l2_cmd,
2066 "lsp-gen-interval level-2 <1-120>",
2067 "Minimum interval between regenerating same LSP\n"
2068 "Set interval for level 2 only\n"
hassof390d2c2004-09-10 20:48:21 +00002069 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002070{
2071 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002072 uint16_t interval;
2073 int level;
jardineb5d44e2003-12-23 08:09:43 +00002074
2075 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002076 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002077 level = IS_LEVEL_2;
2078 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002079}
2080
2081DEFUN (no_lsp_gen_interval_l2,
2082 no_lsp_gen_interval_l2_cmd,
2083 "no lsp-gen-interval level-2",
2084 NO_STR
2085 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002086 "Set interval for level 2 only\n")
jardineb5d44e2003-12-23 08:09:43 +00002087{
2088 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002089 uint16_t interval;
2090 int level;
jardineb5d44e2003-12-23 08:09:43 +00002091
2092 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002093 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2094 level = IS_LEVEL_2;
2095 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002096}
2097
2098ALIAS (no_lsp_gen_interval_l2,
2099 no_lsp_gen_interval_l2_arg_cmd,
2100 "no lsp-gen-interval level-2 <1-120>",
2101 NO_STR
2102 "Minimum interval between regenerating same LSP\n"
2103 "Set interval for level 2 only\n"
hassof390d2c2004-09-10 20:48:21 +00002104 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002105
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002106static int
2107validate_metric_style_narrow (struct vty *vty, struct isis_area *area)
2108{
2109 struct isis_circuit *circuit;
2110 struct listnode *node;
2111
2112 if (! vty)
2113 return CMD_ERR_AMBIGUOUS;
2114
2115 if (! area)
2116 {
2117 vty_out (vty, "ISIS area is invalid%s", VTY_NEWLINE);
2118 return CMD_ERR_AMBIGUOUS;
2119 }
2120
2121 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
2122 {
2123 if ((area->is_type & IS_LEVEL_1) &&
2124 (circuit->is_type & IS_LEVEL_1) &&
Christian Franke4fb7c842012-11-27 19:51:59 +00002125 (circuit->te_metric[0] > MAX_NARROW_LINK_METRIC))
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002126 {
2127 vty_out (vty, "ISIS circuit %s metric is invalid%s",
2128 circuit->interface->name, VTY_NEWLINE);
2129 return CMD_ERR_AMBIGUOUS;
2130 }
2131 if ((area->is_type & IS_LEVEL_2) &&
2132 (circuit->is_type & IS_LEVEL_2) &&
Christian Franke4fb7c842012-11-27 19:51:59 +00002133 (circuit->te_metric[1] > MAX_NARROW_LINK_METRIC))
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002134 {
2135 vty_out (vty, "ISIS circuit %s metric is invalid%s",
2136 circuit->interface->name, VTY_NEWLINE);
2137 return CMD_ERR_AMBIGUOUS;
2138 }
2139 }
2140
2141 return CMD_SUCCESS;
2142}
2143
jardineb5d44e2003-12-23 08:09:43 +00002144DEFUN (metric_style,
2145 metric_style_cmd,
hasso2984d262005-09-26 16:49:07 +00002146 "metric-style (narrow|transition|wide)",
jardineb5d44e2003-12-23 08:09:43 +00002147 "Use old-style (ISO 10589) or new-style packet formats\n"
2148 "Use old style of TLVs with narrow metric\n"
hasso2984d262005-09-26 16:49:07 +00002149 "Send and accept both styles of TLVs during transition\n"
jardineb5d44e2003-12-23 08:09:43 +00002150 "Use new style of TLVs to carry wider metric\n")
2151{
2152 struct isis_area *area;
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002153 int ret;
jardineb5d44e2003-12-23 08:09:43 +00002154
2155 area = vty->index;
2156 assert (area);
hasso2984d262005-09-26 16:49:07 +00002157
2158 if (strncmp (argv[0], "w", 1) == 0)
2159 {
2160 area->newmetric = 1;
2161 area->oldmetric = 0;
2162 }
Christian Franke478c1122012-11-27 19:52:00 +00002163 else
hasso2984d262005-09-26 16:49:07 +00002164 {
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002165 ret = validate_metric_style_narrow (vty, area);
2166 if (ret != CMD_SUCCESS)
2167 return ret;
2168
Christian Franke478c1122012-11-27 19:52:00 +00002169 if (strncmp (argv[0], "t", 1) == 0)
2170 {
2171 area->newmetric = 1;
2172 area->oldmetric = 1;
2173 }
2174 else if (strncmp (argv[0], "n", 1) == 0)
2175 {
2176 area->newmetric = 0;
2177 area->oldmetric = 1;
2178 }
hasso2984d262005-09-26 16:49:07 +00002179 }
jardineb5d44e2003-12-23 08:09:43 +00002180
2181 return CMD_SUCCESS;
2182}
2183
2184DEFUN (no_metric_style,
2185 no_metric_style_cmd,
hasso2984d262005-09-26 16:49:07 +00002186 "no metric-style",
jardineb5d44e2003-12-23 08:09:43 +00002187 NO_STR
hasso2984d262005-09-26 16:49:07 +00002188 "Use old-style (ISO 10589) or new-style packet formats\n")
jardineb5d44e2003-12-23 08:09:43 +00002189{
2190 struct isis_area *area;
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002191 int ret;
jardineb5d44e2003-12-23 08:09:43 +00002192
2193 area = vty->index;
2194 assert (area);
2195
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002196 ret = validate_metric_style_narrow (vty, area);
2197 if (ret != CMD_SUCCESS)
2198 return ret;
2199
hasso2984d262005-09-26 16:49:07 +00002200 /* Default is narrow metric. */
2201 area->newmetric = 0;
2202 area->oldmetric = 1;
jardineb5d44e2003-12-23 08:09:43 +00002203
2204 return CMD_SUCCESS;
2205}
2206
Josh Bailey3f045a02012-03-24 08:35:20 -07002207DEFUN (set_overload_bit,
2208 set_overload_bit_cmd,
2209 "set-overload-bit",
2210 "Set overload bit to avoid any transit traffic\n"
2211 "Set overload bit\n")
2212{
2213 struct isis_area *area;
2214
2215 area = vty->index;
2216 assert (area);
2217
2218 area->overload_bit = LSPBIT_OL;
2219 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2220
2221 return CMD_SUCCESS;
2222}
2223
2224DEFUN (no_set_overload_bit,
2225 no_set_overload_bit_cmd,
2226 "no set-overload-bit",
2227 "Reset overload bit to accept transit traffic\n"
2228 "Reset overload bit\n")
2229{
2230 struct isis_area *area;
2231
2232 area = vty->index;
2233 assert (area);
2234
2235 area->overload_bit = 0;
2236 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2237
2238 return CMD_SUCCESS;
2239}
2240
Amritha Nambiarc8ee9402015-08-24 16:40:14 -07002241DEFUN (set_attached_bit,
2242 set_attached_bit_cmd,
2243 "set-attached-bit",
2244 "Set attached bit to identify as L1/L2 router for inter-area traffic\n"
2245 "Set attached bit\n")
2246{
2247 struct isis_area *area;
2248
2249 area = vty->index;
2250 assert (area);
2251
2252 area->attached_bit = LSPBIT_ATT;
2253 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2254
2255 return CMD_SUCCESS;
2256}
2257
2258DEFUN (no_set_attached_bit,
2259 no_set_attached_bit_cmd,
2260 "no set-attached-bit",
2261 "Reset attached bit\n")
2262{
2263 struct isis_area *area;
2264
2265 area = vty->index;
2266 assert (area);
2267
2268 area->attached_bit = 0;
2269 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2270
2271 return CMD_SUCCESS;
2272}
2273
jardineb5d44e2003-12-23 08:09:43 +00002274DEFUN (dynamic_hostname,
2275 dynamic_hostname_cmd,
2276 "hostname dynamic",
2277 "Dynamic hostname for IS-IS\n"
hassof390d2c2004-09-10 20:48:21 +00002278 "Dynamic hostname\n")
jardineb5d44e2003-12-23 08:09:43 +00002279{
2280 struct isis_area *area;
2281
2282 area = vty->index;
2283 assert (area);
hassof390d2c2004-09-10 20:48:21 +00002284
Josh Bailey3f045a02012-03-24 08:35:20 -07002285 if (!area->dynhostname)
2286 {
2287 area->dynhostname = 1;
2288 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
2289 }
hassof390d2c2004-09-10 20:48:21 +00002290
jardineb5d44e2003-12-23 08:09:43 +00002291 return CMD_SUCCESS;
2292}
2293
2294DEFUN (no_dynamic_hostname,
2295 no_dynamic_hostname_cmd,
2296 "no hostname dynamic",
2297 NO_STR
2298 "Dynamic hostname for IS-IS\n"
hassof390d2c2004-09-10 20:48:21 +00002299 "Dynamic hostname\n")
jardineb5d44e2003-12-23 08:09:43 +00002300{
2301 struct isis_area *area;
2302
2303 area = vty->index;
2304 assert (area);
hassof390d2c2004-09-10 20:48:21 +00002305
Josh Bailey3f045a02012-03-24 08:35:20 -07002306 if (area->dynhostname)
2307 {
2308 area->dynhostname = 0;
2309 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
2310 }
hassof390d2c2004-09-10 20:48:21 +00002311
jardineb5d44e2003-12-23 08:09:43 +00002312 return CMD_SUCCESS;
2313}
2314
2315DEFUN (spf_interval,
2316 spf_interval_cmd,
2317 "spf-interval <1-120>",
hasso2097cd82003-12-23 11:51:08 +00002318 "Minimum interval between SPF calculations\n"
jardineb5d44e2003-12-23 08:09:43 +00002319 "Minimum interval between consecutive SPFs in seconds\n")
2320{
2321 struct isis_area *area;
2322 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002323
jardineb5d44e2003-12-23 08:09:43 +00002324 area = vty->index;
2325 interval = atoi (argv[0]);
2326 area->min_spf_interval[0] = interval;
2327 area->min_spf_interval[1] = interval;
hassof390d2c2004-09-10 20:48:21 +00002328
jardineb5d44e2003-12-23 08:09:43 +00002329 return CMD_SUCCESS;
2330}
2331
2332DEFUN (no_spf_interval,
2333 no_spf_interval_cmd,
2334 "no spf-interval",
2335 NO_STR
hassof390d2c2004-09-10 20:48:21 +00002336 "Minimum interval between SPF calculations\n")
jardineb5d44e2003-12-23 08:09:43 +00002337{
2338 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002339
jardineb5d44e2003-12-23 08:09:43 +00002340 area = vty->index;
2341
2342 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
2343 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002344
jardineb5d44e2003-12-23 08:09:43 +00002345 return CMD_SUCCESS;
2346}
2347
2348ALIAS (no_spf_interval,
2349 no_spf_interval_arg_cmd,
2350 "no spf-interval <1-120>",
2351 NO_STR
2352 "Minimum interval between SPF calculations\n"
hassof390d2c2004-09-10 20:48:21 +00002353 "Minimum interval between consecutive SPFs in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002354
2355DEFUN (spf_interval_l1,
2356 spf_interval_l1_cmd,
2357 "spf-interval level-1 <1-120>",
2358 "Minimum interval between SPF calculations\n"
2359 "Set interval for level 1 only\n"
2360 "Minimum interval between consecutive SPFs in seconds\n")
2361{
2362 struct isis_area *area;
2363 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002364
jardineb5d44e2003-12-23 08:09:43 +00002365 area = vty->index;
2366 interval = atoi (argv[0]);
2367 area->min_spf_interval[0] = interval;
hassof390d2c2004-09-10 20:48:21 +00002368
jardineb5d44e2003-12-23 08:09:43 +00002369 return CMD_SUCCESS;
2370}
2371
2372DEFUN (no_spf_interval_l1,
2373 no_spf_interval_l1_cmd,
2374 "no spf-interval level-1",
2375 NO_STR
2376 "Minimum interval between SPF calculations\n"
2377 "Set interval for level 1 only\n")
2378{
2379 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002380
jardineb5d44e2003-12-23 08:09:43 +00002381 area = vty->index;
2382
2383 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002384
jardineb5d44e2003-12-23 08:09:43 +00002385 return CMD_SUCCESS;
2386}
2387
2388ALIAS (no_spf_interval,
2389 no_spf_interval_l1_arg_cmd,
2390 "no spf-interval level-1 <1-120>",
2391 NO_STR
2392 "Minimum interval between SPF calculations\n"
2393 "Set interval for level 1 only\n"
2394 "Minimum interval between consecutive SPFs in seconds\n")
2395
2396DEFUN (spf_interval_l2,
2397 spf_interval_l2_cmd,
2398 "spf-interval level-2 <1-120>",
2399 "Minimum interval between SPF calculations\n"
2400 "Set interval for level 2 only\n"
2401 "Minimum interval between consecutive SPFs in seconds\n")
2402{
2403 struct isis_area *area;
2404 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002405
jardineb5d44e2003-12-23 08:09:43 +00002406 area = vty->index;
2407 interval = atoi (argv[0]);
2408 area->min_spf_interval[1] = interval;
hassof390d2c2004-09-10 20:48:21 +00002409
jardineb5d44e2003-12-23 08:09:43 +00002410 return CMD_SUCCESS;
2411}
2412
2413DEFUN (no_spf_interval_l2,
2414 no_spf_interval_l2_cmd,
2415 "no spf-interval level-2",
2416 NO_STR
2417 "Minimum interval between SPF calculations\n"
2418 "Set interval for level 2 only\n")
2419{
2420 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002421
jardineb5d44e2003-12-23 08:09:43 +00002422 area = vty->index;
2423
2424 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002425
jardineb5d44e2003-12-23 08:09:43 +00002426 return CMD_SUCCESS;
2427}
2428
2429ALIAS (no_spf_interval,
2430 no_spf_interval_l2_arg_cmd,
2431 "no spf-interval level-2 <1-120>",
2432 NO_STR
2433 "Minimum interval between SPF calculations\n"
2434 "Set interval for level 2 only\n"
2435 "Minimum interval between consecutive SPFs in seconds\n")
2436
Josh Bailey3f045a02012-03-24 08:35:20 -07002437static int
2438set_lsp_max_lifetime (struct vty *vty, struct isis_area *area,
2439 uint16_t interval, int level)
2440{
2441 int lvl;
2442 int set_refresh_interval[ISIS_LEVELS] = {0, 0};
2443 uint16_t refresh_interval;
2444
2445 refresh_interval = interval - 300;
2446
2447 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
2448 {
2449 if (!(lvl & level))
2450 continue;
2451 if (refresh_interval < area->lsp_refresh[lvl-1])
2452 {
2453 vty_out (vty, "Level %d Max LSP lifetime %us must be 300s greater than "
2454 "the configured LSP refresh interval %us%s",
2455 lvl, interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
2456 vty_out (vty, "Automatically reducing level %d LSP refresh interval "
2457 "to %us%s", lvl, refresh_interval, VTY_NEWLINE);
2458 set_refresh_interval[lvl-1] = 1;
2459
2460 if (refresh_interval <= area->lsp_gen_interval[lvl-1])
2461 {
2462 vty_out (vty, "LSP refresh interval %us must be greater than "
2463 "the configured LSP gen interval %us%s",
2464 refresh_interval, area->lsp_gen_interval[lvl-1],
2465 VTY_NEWLINE);
2466 return CMD_ERR_AMBIGUOUS;
2467 }
2468 }
2469 }
2470
2471 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
2472 {
2473 if (!(lvl & level))
2474 continue;
2475 area->max_lsp_lifetime[lvl-1] = interval;
2476 /* Automatically reducing lsp_refresh_interval to interval - 300 */
2477 if (set_refresh_interval[lvl-1])
2478 area->lsp_refresh[lvl-1] = refresh_interval;
2479 }
2480
2481 lsp_regenerate_schedule (area, level, 1);
2482
2483 return CMD_SUCCESS;
2484}
2485
2486DEFUN (max_lsp_lifetime,
2487 max_lsp_lifetime_cmd,
2488 "max-lsp-lifetime <350-65535>",
2489 "Maximum LSP lifetime\n"
2490 "LSP lifetime in seconds\n")
2491{
2492 struct isis_area *area;
2493 uint16_t interval;
2494 int level;
2495
2496 area = vty->index;
2497 interval = atoi (argv[0]);
2498 level = IS_LEVEL_1 | IS_LEVEL_2;
2499 return set_lsp_max_lifetime (vty, area, interval, level);
2500}
2501
2502DEFUN (no_max_lsp_lifetime,
2503 no_max_lsp_lifetime_cmd,
2504 "no max-lsp-lifetime",
2505 NO_STR
2506 "LSP lifetime in seconds\n")
2507{
2508 struct isis_area *area;
2509 uint16_t interval;
2510 int level;
2511
2512 area = vty->index;
2513 interval = DEFAULT_LSP_LIFETIME;
2514 level = IS_LEVEL_1 | IS_LEVEL_2;
2515 return set_lsp_max_lifetime (vty, area, interval, level);
2516}
2517
2518ALIAS (no_max_lsp_lifetime,
2519 no_max_lsp_lifetime_arg_cmd,
2520 "no max-lsp-lifetime <350-65535>",
2521 NO_STR
2522 "Maximum LSP lifetime\n"
2523 "LSP lifetime in seconds\n")
2524
2525DEFUN (max_lsp_lifetime_l1,
2526 max_lsp_lifetime_l1_cmd,
2527 "max-lsp-lifetime level-1 <350-65535>",
2528 "Maximum LSP lifetime for Level 1 only\n"
2529 "LSP lifetime for Level 1 only in seconds\n")
2530{
2531 struct isis_area *area;
2532 uint16_t interval;
2533 int level;
2534
2535 area = vty->index;
2536 interval = atoi (argv[0]);
2537 level = IS_LEVEL_1;
2538 return set_lsp_max_lifetime (vty, area, interval, level);
2539}
2540
2541DEFUN (no_max_lsp_lifetime_l1,
2542 no_max_lsp_lifetime_l1_cmd,
2543 "no max-lsp-lifetime level-1",
2544 NO_STR
2545 "LSP lifetime for Level 1 only in seconds\n")
2546{
2547 struct isis_area *area;
2548 uint16_t interval;
2549 int level;
2550
2551 area = vty->index;
2552 interval = DEFAULT_LSP_LIFETIME;
2553 level = IS_LEVEL_1;
2554 return set_lsp_max_lifetime (vty, area, interval, level);
2555}
2556
2557ALIAS (no_max_lsp_lifetime_l1,
2558 no_max_lsp_lifetime_l1_arg_cmd,
2559 "no max-lsp-lifetime level-1 <350-65535>",
2560 NO_STR
2561 "Maximum LSP lifetime for Level 1 only\n"
2562 "LSP lifetime for Level 1 only in seconds\n")
2563
2564DEFUN (max_lsp_lifetime_l2,
2565 max_lsp_lifetime_l2_cmd,
2566 "max-lsp-lifetime level-2 <350-65535>",
2567 "Maximum LSP lifetime for Level 2 only\n"
2568 "LSP lifetime for Level 2 only in seconds\n")
2569{
2570 struct isis_area *area;
2571 uint16_t interval;
2572 int level;
2573
2574 area = vty->index;
2575 interval = atoi (argv[0]);
2576 level = IS_LEVEL_2;
2577 return set_lsp_max_lifetime (vty, area, interval, level);
2578}
2579
2580DEFUN (no_max_lsp_lifetime_l2,
2581 no_max_lsp_lifetime_l2_cmd,
2582 "no max-lsp-lifetime level-2",
2583 NO_STR
2584 "LSP lifetime for Level 2 only in seconds\n")
2585{
2586 struct isis_area *area;
2587 uint16_t interval;
2588 int level;
2589
2590 area = vty->index;
2591 interval = DEFAULT_LSP_LIFETIME;
2592 level = IS_LEVEL_2;
2593 return set_lsp_max_lifetime (vty, area, interval, level);
2594}
2595
2596ALIAS (no_max_lsp_lifetime_l2,
2597 no_max_lsp_lifetime_l2_arg_cmd,
2598 "no max-lsp-lifetime level-2 <350-65535>",
2599 NO_STR
2600 "Maximum LSP lifetime for Level 2 only\n"
2601 "LSP lifetime for Level 2 only in seconds\n")
2602
2603static int
2604set_lsp_refresh_interval (struct vty *vty, struct isis_area *area,
2605 uint16_t interval, int level)
2606{
2607 int lvl;
2608
2609 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2610 {
2611 if (!(lvl & level))
2612 continue;
2613 if (interval <= area->lsp_gen_interval[lvl-1])
2614 {
2615 vty_out (vty, "LSP refresh interval %us must be greater than "
2616 "the configured LSP gen interval %us%s",
2617 interval, area->lsp_gen_interval[lvl-1],
2618 VTY_NEWLINE);
2619 return CMD_ERR_AMBIGUOUS;
2620 }
2621 if (interval > (area->max_lsp_lifetime[lvl-1] - 300))
2622 {
2623 vty_out (vty, "LSP refresh interval %us must be less than "
2624 "the configured LSP lifetime %us less 300%s",
2625 interval, area->max_lsp_lifetime[lvl-1],
2626 VTY_NEWLINE);
2627 return CMD_ERR_AMBIGUOUS;
2628 }
2629 }
2630
2631 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2632 {
2633 if (!(lvl & level))
2634 continue;
2635 area->lsp_refresh[lvl-1] = interval;
2636 }
2637 lsp_regenerate_schedule (area, level, 1);
2638
2639 return CMD_SUCCESS;
2640}
2641
2642DEFUN (lsp_refresh_interval,
2643 lsp_refresh_interval_cmd,
2644 "lsp-refresh-interval <1-65235>",
2645 "LSP refresh interval\n"
2646 "LSP refresh interval in seconds\n")
2647{
2648 struct isis_area *area;
2649 uint16_t interval;
2650 int level;
2651
2652 area = vty->index;
2653 interval = atoi (argv[0]);
2654 level = IS_LEVEL_1 | IS_LEVEL_2;
2655 return set_lsp_refresh_interval (vty, area, interval, level);
2656}
2657
2658DEFUN (no_lsp_refresh_interval,
2659 no_lsp_refresh_interval_cmd,
2660 "no lsp-refresh-interval",
2661 NO_STR
2662 "LSP refresh interval in seconds\n")
2663{
2664 struct isis_area *area;
2665 uint16_t interval;
2666 int level;
2667
2668 area = vty->index;
2669 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2670 level = IS_LEVEL_1 | IS_LEVEL_2;
2671 return set_lsp_refresh_interval (vty, area, interval, level);
2672}
2673
2674ALIAS (no_lsp_refresh_interval,
2675 no_lsp_refresh_interval_arg_cmd,
2676 "no lsp-refresh-interval <1-65235>",
2677 NO_STR
2678 "LSP refresh interval\n"
2679 "LSP refresh interval in seconds\n")
2680
2681DEFUN (lsp_refresh_interval_l1,
2682 lsp_refresh_interval_l1_cmd,
2683 "lsp-refresh-interval level-1 <1-65235>",
2684 "LSP refresh interval for Level 1 only\n"
2685 "LSP refresh interval for Level 1 only in seconds\n")
2686{
2687 struct isis_area *area;
2688 uint16_t interval;
2689 int level;
2690
2691 area = vty->index;
2692 interval = atoi (argv[0]);
2693 level = IS_LEVEL_1;
2694 return set_lsp_refresh_interval (vty, area, interval, level);
2695}
2696
2697DEFUN (no_lsp_refresh_interval_l1,
2698 no_lsp_refresh_interval_l1_cmd,
2699 "no lsp-refresh-interval level-1",
2700 NO_STR
2701 "LSP refresh interval for Level 1 only in seconds\n")
2702{
2703 struct isis_area *area;
2704 uint16_t interval;
2705 int level;
2706
2707 area = vty->index;
2708 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2709 level = IS_LEVEL_1;
2710 return set_lsp_refresh_interval (vty, area, interval, level);
2711}
2712
2713ALIAS (no_lsp_refresh_interval_l1,
2714 no_lsp_refresh_interval_l1_arg_cmd,
2715 "no lsp-refresh-interval level-1 <1-65235>",
2716 NO_STR
2717 "LSP refresh interval for Level 1 only\n"
2718 "LSP refresh interval for Level 1 only in seconds\n")
2719
2720DEFUN (lsp_refresh_interval_l2,
2721 lsp_refresh_interval_l2_cmd,
2722 "lsp-refresh-interval level-2 <1-65235>",
2723 "LSP refresh interval for Level 2 only\n"
2724 "LSP refresh interval for Level 2 only in seconds\n")
2725{
2726 struct isis_area *area;
2727 uint16_t interval;
2728 int level;
2729
2730 area = vty->index;
2731 interval = atoi (argv[0]);
2732 level = IS_LEVEL_2;
2733 return set_lsp_refresh_interval (vty, area, interval, level);
2734}
2735
2736DEFUN (no_lsp_refresh_interval_l2,
2737 no_lsp_refresh_interval_l2_cmd,
2738 "no lsp-refresh-interval level-2",
2739 NO_STR
2740 "LSP refresh interval for Level 2 only in seconds\n")
2741{
2742 struct isis_area *area;
2743 uint16_t interval;
2744 int level;
2745
2746 area = vty->index;
2747 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2748 level = IS_LEVEL_2;
2749 return set_lsp_refresh_interval (vty, area, interval, level);
2750}
2751
2752ALIAS (no_lsp_refresh_interval_l2,
2753 no_lsp_refresh_interval_l2_arg_cmd,
2754 "no lsp-refresh-interval level-2 <1-65235>",
2755 NO_STR
2756 "LSP refresh interval for Level 2 only\n"
2757 "LSP refresh interval for Level 2 only in seconds\n")
2758
2759DEFUN (log_adj_changes,
2760 log_adj_changes_cmd,
2761 "log-adjacency-changes",
2762 "Log changes in adjacency state\n")
2763{
2764 struct isis_area *area;
2765
2766 area = vty->index;
2767 assert (area);
2768
2769 area->log_adj_changes = 1;
2770
2771 return CMD_SUCCESS;
2772}
2773
2774DEFUN (no_log_adj_changes,
2775 no_log_adj_changes_cmd,
2776 "no log-adjacency-changes",
2777 "Stop logging changes in adjacency state\n")
2778{
2779 struct isis_area *area;
2780
2781 area = vty->index;
2782 assert (area);
2783
2784 area->log_adj_changes = 0;
2785
2786 return CMD_SUCCESS;
2787}
2788
jardineb5d44e2003-12-23 08:09:43 +00002789#ifdef TOPOLOGY_GENERATE
Josh Bailey3f045a02012-03-24 08:35:20 -07002790
jardineb5d44e2003-12-23 08:09:43 +00002791DEFUN (topology_generate_grid,
2792 topology_generate_grid_cmd,
2793 "topology generate grid <1-100> <1-100> <1-65000> [param] [param] "
2794 "[param]",
hassof1082d12005-09-19 04:23:34 +00002795 "Topology generation for IS-IS\n"
2796 "Topology generation\n"
2797 "Grid topology\n"
jardineb5d44e2003-12-23 08:09:43 +00002798 "X parameter of the grid\n"
2799 "Y parameter of the grid\n"
2800 "Random seed\n"
2801 "Optional param 1\n"
2802 "Optional param 2\n"
2803 "Optional param 3\n"
2804 "Topology\n")
2805{
2806 struct isis_area *area;
2807
2808 area = vty->index;
2809 assert (area);
2810
hassof390d2c2004-09-10 20:48:21 +00002811 if (!spgrid_check_params (vty, argc, argv))
2812 {
2813 if (area->topology)
2814 list_delete (area->topology);
2815 area->topology = list_new ();
2816 memcpy (area->top_params, vty->buf, 200);
2817 gen_spgrid_topology (vty, area->topology);
2818 remove_topology_lsps (area);
2819 generate_topology_lsps (area);
hassof1082d12005-09-19 04:23:34 +00002820 /* Regenerate L1 LSP to get two way connection to the generated
2821 * topology. */
Josh Bailey3f045a02012-03-24 08:35:20 -07002822 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hassof390d2c2004-09-10 20:48:21 +00002823 }
jardineb5d44e2003-12-23 08:09:43 +00002824
2825 return CMD_SUCCESS;
2826}
2827
hassof695b012005-04-02 19:03:39 +00002828DEFUN (show_isis_generated_topology,
2829 show_isis_generated_topology_cmd,
hassof1082d12005-09-19 04:23:34 +00002830 "show isis generated-topologies",
jardineb5d44e2003-12-23 08:09:43 +00002831 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -07002832 "ISIS network information\n"
hassof1082d12005-09-19 04:23:34 +00002833 "Show generated topologies\n")
jardineb5d44e2003-12-23 08:09:43 +00002834{
2835 struct isis_area *area;
paul92c9f222005-05-25 12:21:13 +00002836 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +00002837 struct listnode *node2;
2838 struct arc *arc;
hassof1082d12005-09-19 04:23:34 +00002839
paul92c9f222005-05-25 12:21:13 +00002840 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof1082d12005-09-19 04:23:34 +00002841 {
2842 if (!area->topology)
2843 continue;
2844
2845 vty_out (vty, "Topology for isis area: %s%s", area->area_tag,
2846 VTY_NEWLINE);
2847 vty_out (vty, "From node To node Distance%s", VTY_NEWLINE);
2848
2849 for (ALL_LIST_ELEMENTS_RO (area->topology, node2, arc))
2850 vty_out (vty, "%9ld %11ld %12ld%s", arc->from_node, arc->to_node,
2851 arc->distance, VTY_NEWLINE);
2852 }
jardineb5d44e2003-12-23 08:09:43 +00002853 return CMD_SUCCESS;
2854}
2855
hassof1082d12005-09-19 04:23:34 +00002856/* Base IS for topology generation. */
hassof390d2c2004-09-10 20:48:21 +00002857DEFUN (topology_baseis,
jardineb5d44e2003-12-23 08:09:43 +00002858 topology_baseis_cmd,
2859 "topology base-is WORD",
hassof1082d12005-09-19 04:23:34 +00002860 "Topology generation for IS-IS\n"
2861 "A Network IS Base for this topology\n"
2862 "XXXX.XXXX.XXXX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00002863{
2864 struct isis_area *area;
2865 u_char buff[ISIS_SYS_ID_LEN];
2866
2867 area = vty->index;
2868 assert (area);
2869
hassof390d2c2004-09-10 20:48:21 +00002870 if (sysid2buff (buff, argv[0]))
hassof1082d12005-09-19 04:23:34 +00002871 sysid2buff (area->topology_baseis, argv[0]);
hassof390d2c2004-09-10 20:48:21 +00002872
jardineb5d44e2003-12-23 08:09:43 +00002873 return CMD_SUCCESS;
2874}
2875
jardineb5d44e2003-12-23 08:09:43 +00002876DEFUN (no_topology_baseis,
2877 no_topology_baseis_cmd,
2878 "no topology base-is WORD",
2879 NO_STR
hassof1082d12005-09-19 04:23:34 +00002880 "Topology generation for IS-IS\n"
2881 "A Network IS Base for this topology\n"
2882 "XXXX.XXXX.XXXX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00002883{
2884 struct isis_area *area;
2885
2886 area = vty->index;
2887 assert (area);
2888
hassof390d2c2004-09-10 20:48:21 +00002889 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
jardineb5d44e2003-12-23 08:09:43 +00002890 return CMD_SUCCESS;
2891}
2892
hassof1082d12005-09-19 04:23:34 +00002893ALIAS (no_topology_baseis,
2894 no_topology_baseis_noid_cmd,
2895 "no topology base-is",
2896 NO_STR
2897 "Topology generation for IS-IS\n"
2898 "A Network IS Base for this topology\n")
2899
2900DEFUN (topology_basedynh,
2901 topology_basedynh_cmd,
2902 "topology base-dynh WORD",
2903 "Topology generation for IS-IS\n"
2904 "Dynamic hostname base for this topology\n"
2905 "Dynamic hostname base\n")
2906{
2907 struct isis_area *area;
2908
2909 area = vty->index;
2910 assert (area);
2911
2912 /* I hope that it's enough. */
2913 area->topology_basedynh = strndup (argv[0], 16);
2914 return CMD_SUCCESS;
2915}
Josh Bailey3f045a02012-03-24 08:35:20 -07002916
jardineb5d44e2003-12-23 08:09:43 +00002917#endif /* TOPOLOGY_GENERATE */
2918
jardineb5d44e2003-12-23 08:09:43 +00002919/* IS-IS configuration write function */
2920int
2921isis_config_write (struct vty *vty)
2922{
2923 int write = 0;
jardineb5d44e2003-12-23 08:09:43 +00002924
hassof390d2c2004-09-10 20:48:21 +00002925 if (isis != NULL)
2926 {
2927 struct isis_area *area;
hasso3fdb2dd2005-09-28 18:45:54 +00002928 struct listnode *node, *node2;
jardineb5d44e2003-12-23 08:09:43 +00002929
hasso3fdb2dd2005-09-28 18:45:54 +00002930 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof390d2c2004-09-10 20:48:21 +00002931 {
2932 /* ISIS - Area name */
2933 vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
2934 write++;
2935 /* ISIS - Net */
2936 if (listcount (area->area_addrs) > 0)
2937 {
2938 struct area_addr *area_addr;
hasso3fdb2dd2005-09-28 18:45:54 +00002939 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
2940 {
2941 vty_out (vty, " net %s%s",
2942 isonet_print (area_addr->area_addr,
2943 area_addr->addr_len + ISIS_SYS_ID_LEN +
2944 1), VTY_NEWLINE);
2945 write++;
2946 }
hassof390d2c2004-09-10 20:48:21 +00002947 }
hasso3fdb2dd2005-09-28 18:45:54 +00002948 /* ISIS - Dynamic hostname - Defaults to true so only display if
2949 * false. */
hassof390d2c2004-09-10 20:48:21 +00002950 if (!area->dynhostname)
2951 {
2952 vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
2953 write++;
2954 }
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002955 /* ISIS - Metric-Style - when true displays wide */
2956 if (area->newmetric)
hassof390d2c2004-09-10 20:48:21 +00002957 {
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002958 if (!area->oldmetric)
2959 vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
hasso2984d262005-09-26 16:49:07 +00002960 else
2961 vty_out (vty, " metric-style transition%s", VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +00002962 write++;
2963 }
Christian Frankef818c8f2012-11-27 01:10:28 +00002964 else
2965 {
2966 vty_out (vty, " metric-style narrow%s", VTY_NEWLINE);
2967 write++;
2968 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002969 /* ISIS - overload-bit */
2970 if (area->overload_bit)
2971 {
2972 vty_out (vty, " set-overload-bit%s", VTY_NEWLINE);
2973 write++;
2974 }
hassof390d2c2004-09-10 20:48:21 +00002975 /* ISIS - Area is-type (level-1-2 is default) */
2976 if (area->is_type == IS_LEVEL_1)
2977 {
2978 vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
2979 write++;
2980 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002981 else if (area->is_type == IS_LEVEL_2)
hassof390d2c2004-09-10 20:48:21 +00002982 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002983 vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
2984 write++;
hassof390d2c2004-09-10 20:48:21 +00002985 }
2986 /* ISIS - Lsp generation interval */
2987 if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1])
2988 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002989 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002990 {
2991 vty_out (vty, " lsp-gen-interval %d%s",
2992 area->lsp_gen_interval[0], VTY_NEWLINE);
2993 write++;
2994 }
2995 }
2996 else
2997 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002998 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002999 {
3000 vty_out (vty, " lsp-gen-interval level-1 %d%s",
3001 area->lsp_gen_interval[0], VTY_NEWLINE);
3002 write++;
3003 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003004 if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00003005 {
3006 vty_out (vty, " lsp-gen-interval level-2 %d%s",
3007 area->lsp_gen_interval[1], VTY_NEWLINE);
3008 write++;
3009 }
3010 }
3011 /* ISIS - LSP lifetime */
3012 if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1])
3013 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003014 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00003015 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003016 vty_out (vty, " max-lsp-lifetime %u%s", area->max_lsp_lifetime[0],
hassof390d2c2004-09-10 20:48:21 +00003017 VTY_NEWLINE);
3018 write++;
3019 }
3020 }
3021 else
3022 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003023 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00003024 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003025 vty_out (vty, " max-lsp-lifetime level-1 %u%s",
hassof390d2c2004-09-10 20:48:21 +00003026 area->max_lsp_lifetime[0], VTY_NEWLINE);
3027 write++;
3028 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003029 if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00003030 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003031 vty_out (vty, " max-lsp-lifetime level-2 %u%s",
hassof390d2c2004-09-10 20:48:21 +00003032 area->max_lsp_lifetime[1], VTY_NEWLINE);
3033 write++;
3034 }
3035 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003036 /* ISIS - LSP refresh interval */
3037 if (area->lsp_refresh[0] == area->lsp_refresh[1])
3038 {
3039 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3040 {
3041 vty_out (vty, " lsp-refresh-interval %u%s", area->lsp_refresh[0],
3042 VTY_NEWLINE);
3043 write++;
3044 }
3045 }
3046 else
3047 {
3048 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3049 {
3050 vty_out (vty, " lsp-refresh-interval level-1 %u%s",
3051 area->lsp_refresh[0], VTY_NEWLINE);
3052 write++;
3053 }
3054 if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3055 {
3056 vty_out (vty, " lsp-refresh-interval level-2 %u%s",
3057 area->lsp_refresh[1], VTY_NEWLINE);
3058 write++;
3059 }
3060 }
Christian Frankef1fc1db2015-11-10 18:43:31 +01003061 if (area->lsp_mtu != DEFAULT_LSP_MTU)
3062 {
3063 vty_out(vty, " lsp-mtu %u%s", area->lsp_mtu, VTY_NEWLINE);
3064 write++;
3065 }
3066
hasso13fb40a2005-10-01 06:03:04 +00003067 /* Minimum SPF interval. */
3068 if (area->min_spf_interval[0] == area->min_spf_interval[1])
3069 {
3070 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
3071 {
3072 vty_out (vty, " spf-interval %d%s",
3073 area->min_spf_interval[0], VTY_NEWLINE);
3074 write++;
3075 }
3076 }
3077 else
3078 {
3079 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
3080 {
3081 vty_out (vty, " spf-interval level-1 %d%s",
3082 area->min_spf_interval[0], VTY_NEWLINE);
3083 write++;
3084 }
3085 if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL)
3086 {
3087 vty_out (vty, " spf-interval level-2 %d%s",
3088 area->min_spf_interval[1], VTY_NEWLINE);
3089 write++;
3090 }
3091 }
hasso53c997c2004-09-15 16:21:59 +00003092 /* Authentication passwords. */
Josh Bailey3f045a02012-03-24 08:35:20 -07003093 if (area->area_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
hasso53c997c2004-09-15 16:21:59 +00003094 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003095 vty_out(vty, " area-password md5 %s", area->area_passwd.passwd);
hasso1cbc5622005-01-01 10:29:51 +00003096 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
3097 {
3098 vty_out(vty, " authenticate snp ");
3099 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
3100 vty_out(vty, "validate");
3101 else
3102 vty_out(vty, "send-only");
3103 }
3104 vty_out(vty, "%s", VTY_NEWLINE);
hasso53c997c2004-09-15 16:21:59 +00003105 write++;
Josh Bailey3f045a02012-03-24 08:35:20 -07003106 }
3107 else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
3108 {
3109 vty_out(vty, " area-password clear %s", area->area_passwd.passwd);
3110 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
3111 {
3112 vty_out(vty, " authenticate snp ");
3113 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
3114 vty_out(vty, "validate");
3115 else
3116 vty_out(vty, "send-only");
3117 }
3118 vty_out(vty, "%s", VTY_NEWLINE);
3119 write++;
3120 }
3121 if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
hasso53c997c2004-09-15 16:21:59 +00003122 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003123 vty_out(vty, " domain-password md5 %s",
3124 area->domain_passwd.passwd);
3125 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3126 {
3127 vty_out(vty, " authenticate snp ");
3128 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3129 vty_out(vty, "validate");
3130 else
3131 vty_out(vty, "send-only");
3132 }
3133 vty_out(vty, "%s", VTY_NEWLINE);
3134 write++;
3135 }
3136 else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
3137 {
3138 vty_out(vty, " domain-password clear %s",
3139 area->domain_passwd.passwd);
hasso1cbc5622005-01-01 10:29:51 +00003140 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3141 {
3142 vty_out(vty, " authenticate snp ");
3143 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3144 vty_out(vty, "validate");
3145 else
3146 vty_out(vty, "send-only");
3147 }
3148 vty_out(vty, "%s", VTY_NEWLINE);
hasso53c997c2004-09-15 16:21:59 +00003149 write++;
3150 }
hassof1082d12005-09-19 04:23:34 +00003151
Josh Bailey3f045a02012-03-24 08:35:20 -07003152 if (area->log_adj_changes)
3153 {
3154 vty_out (vty, " log-adjacency-changes%s", VTY_NEWLINE);
3155 write++;
3156 }
3157
hassof390d2c2004-09-10 20:48:21 +00003158#ifdef TOPOLOGY_GENERATE
hassof1082d12005-09-19 04:23:34 +00003159 if (memcmp (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS,
3160 ISIS_SYS_ID_LEN))
3161 {
3162 vty_out (vty, " topology base-is %s%s",
Josh Bailey3f045a02012-03-24 08:35:20 -07003163 sysid_print ((u_char *)area->topology_baseis), VTY_NEWLINE);
hassof1082d12005-09-19 04:23:34 +00003164 write++;
3165 }
3166 if (area->topology_basedynh)
3167 {
3168 vty_out (vty, " topology base-dynh %s%s",
3169 area->topology_basedynh, VTY_NEWLINE);
3170 write++;
3171 }
3172 /* We save the whole command line here. */
3173 if (strlen(area->top_params))
hassof390d2c2004-09-10 20:48:21 +00003174 {
3175 vty_out (vty, " %s%s", area->top_params, VTY_NEWLINE);
3176 write++;
3177 }
hassof390d2c2004-09-10 20:48:21 +00003178#endif /* TOPOLOGY_GENERATE */
hassof1082d12005-09-19 04:23:34 +00003179
hassof390d2c2004-09-10 20:48:21 +00003180 }
jardineb5d44e2003-12-23 08:09:43 +00003181 }
hassof390d2c2004-09-10 20:48:21 +00003182
jardineb5d44e2003-12-23 08:09:43 +00003183 return write;
3184}
3185
Josh Bailey3f045a02012-03-24 08:35:20 -07003186struct cmd_node isis_node = {
jardineb5d44e2003-12-23 08:09:43 +00003187 ISIS_NODE,
hasso2097cd82003-12-23 11:51:08 +00003188 "%s(config-router)# ",
jardineb5d44e2003-12-23 08:09:43 +00003189 1
3190};
3191
hassof390d2c2004-09-10 20:48:21 +00003192void
jardineb5d44e2003-12-23 08:09:43 +00003193isis_init ()
3194{
jardineb5d44e2003-12-23 08:09:43 +00003195 /* Install IS-IS top node */
3196 install_node (&isis_node, isis_config_write);
hassof390d2c2004-09-10 20:48:21 +00003197
Josh Bailey3f045a02012-03-24 08:35:20 -07003198 install_element (VIEW_NODE, &show_isis_summary_cmd);
3199
3200 install_element (VIEW_NODE, &show_isis_interface_cmd);
3201 install_element (VIEW_NODE, &show_isis_interface_detail_cmd);
3202 install_element (VIEW_NODE, &show_isis_interface_arg_cmd);
3203
3204 install_element (VIEW_NODE, &show_isis_neighbor_cmd);
3205 install_element (VIEW_NODE, &show_isis_neighbor_detail_cmd);
3206 install_element (VIEW_NODE, &show_isis_neighbor_arg_cmd);
3207 install_element (VIEW_NODE, &clear_isis_neighbor_cmd);
3208 install_element (VIEW_NODE, &clear_isis_neighbor_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003209
3210 install_element (VIEW_NODE, &show_hostname_cmd);
3211 install_element (VIEW_NODE, &show_database_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003212 install_element (VIEW_NODE, &show_database_arg_cmd);
3213 install_element (VIEW_NODE, &show_database_arg_detail_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003214 install_element (VIEW_NODE, &show_database_detail_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003215 install_element (VIEW_NODE, &show_database_detail_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003216
Josh Bailey3f045a02012-03-24 08:35:20 -07003217 install_element (ENABLE_NODE, &show_isis_summary_cmd);
3218
3219 install_element (ENABLE_NODE, &show_isis_interface_cmd);
3220 install_element (ENABLE_NODE, &show_isis_interface_detail_cmd);
3221 install_element (ENABLE_NODE, &show_isis_interface_arg_cmd);
3222
3223 install_element (ENABLE_NODE, &show_isis_neighbor_cmd);
3224 install_element (ENABLE_NODE, &show_isis_neighbor_detail_cmd);
3225 install_element (ENABLE_NODE, &show_isis_neighbor_arg_cmd);
3226 install_element (ENABLE_NODE, &clear_isis_neighbor_cmd);
3227 install_element (ENABLE_NODE, &clear_isis_neighbor_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003228
3229 install_element (ENABLE_NODE, &show_hostname_cmd);
3230 install_element (ENABLE_NODE, &show_database_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003231 install_element (ENABLE_NODE, &show_database_arg_cmd);
3232 install_element (ENABLE_NODE, &show_database_arg_detail_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003233 install_element (ENABLE_NODE, &show_database_detail_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003234 install_element (ENABLE_NODE, &show_database_detail_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003235 install_element (ENABLE_NODE, &show_debugging_cmd);
3236
hassof390d2c2004-09-10 20:48:21 +00003237 install_node (&debug_node, config_write_debug);
jardin9e867fe2003-12-23 08:56:18 +00003238
jardineb5d44e2003-12-23 08:09:43 +00003239 install_element (ENABLE_NODE, &debug_isis_adj_cmd);
3240 install_element (ENABLE_NODE, &no_debug_isis_adj_cmd);
3241 install_element (ENABLE_NODE, &debug_isis_csum_cmd);
3242 install_element (ENABLE_NODE, &no_debug_isis_csum_cmd);
3243 install_element (ENABLE_NODE, &debug_isis_lupd_cmd);
3244 install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd);
3245 install_element (ENABLE_NODE, &debug_isis_err_cmd);
3246 install_element (ENABLE_NODE, &no_debug_isis_err_cmd);
3247 install_element (ENABLE_NODE, &debug_isis_snp_cmd);
3248 install_element (ENABLE_NODE, &no_debug_isis_snp_cmd);
3249 install_element (ENABLE_NODE, &debug_isis_upd_cmd);
3250 install_element (ENABLE_NODE, &no_debug_isis_upd_cmd);
3251 install_element (ENABLE_NODE, &debug_isis_spfevents_cmd);
3252 install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd);
3253 install_element (ENABLE_NODE, &debug_isis_spfstats_cmd);
3254 install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd);
3255 install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd);
3256 install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd);
3257 install_element (ENABLE_NODE, &debug_isis_rtevents_cmd);
3258 install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd);
3259 install_element (ENABLE_NODE, &debug_isis_events_cmd);
3260 install_element (ENABLE_NODE, &no_debug_isis_events_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003261 install_element (ENABLE_NODE, &debug_isis_packet_dump_cmd);
3262 install_element (ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003263
jardin9e867fe2003-12-23 08:56:18 +00003264 install_element (CONFIG_NODE, &debug_isis_adj_cmd);
3265 install_element (CONFIG_NODE, &no_debug_isis_adj_cmd);
3266 install_element (CONFIG_NODE, &debug_isis_csum_cmd);
3267 install_element (CONFIG_NODE, &no_debug_isis_csum_cmd);
3268 install_element (CONFIG_NODE, &debug_isis_lupd_cmd);
3269 install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd);
3270 install_element (CONFIG_NODE, &debug_isis_err_cmd);
3271 install_element (CONFIG_NODE, &no_debug_isis_err_cmd);
3272 install_element (CONFIG_NODE, &debug_isis_snp_cmd);
3273 install_element (CONFIG_NODE, &no_debug_isis_snp_cmd);
3274 install_element (CONFIG_NODE, &debug_isis_upd_cmd);
3275 install_element (CONFIG_NODE, &no_debug_isis_upd_cmd);
3276 install_element (CONFIG_NODE, &debug_isis_spfevents_cmd);
3277 install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd);
3278 install_element (CONFIG_NODE, &debug_isis_spfstats_cmd);
3279 install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd);
3280 install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd);
3281 install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd);
3282 install_element (CONFIG_NODE, &debug_isis_rtevents_cmd);
3283 install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd);
3284 install_element (CONFIG_NODE, &debug_isis_events_cmd);
3285 install_element (CONFIG_NODE, &no_debug_isis_events_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003286 install_element (CONFIG_NODE, &debug_isis_packet_dump_cmd);
3287 install_element (CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
jardin9e867fe2003-12-23 08:56:18 +00003288
jardineb5d44e2003-12-23 08:09:43 +00003289 install_element (CONFIG_NODE, &router_isis_cmd);
3290 install_element (CONFIG_NODE, &no_router_isis_cmd);
3291
3292 install_default (ISIS_NODE);
3293
3294 install_element (ISIS_NODE, &net_cmd);
3295 install_element (ISIS_NODE, &no_net_cmd);
3296
3297 install_element (ISIS_NODE, &is_type_cmd);
3298 install_element (ISIS_NODE, &no_is_type_cmd);
3299
Christian Frankef1fc1db2015-11-10 18:43:31 +01003300 install_element (ISIS_NODE, &area_lsp_mtu_cmd);
3301 install_element (ISIS_NODE, &no_area_lsp_mtu_cmd);
3302 install_element (ISIS_NODE, &no_area_lsp_mtu_arg_cmd);
3303
Josh Bailey3f045a02012-03-24 08:35:20 -07003304 install_element (ISIS_NODE, &area_passwd_md5_cmd);
3305 install_element (ISIS_NODE, &area_passwd_md5_snpauth_cmd);
3306 install_element (ISIS_NODE, &area_passwd_clear_cmd);
3307 install_element (ISIS_NODE, &area_passwd_clear_snpauth_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003308 install_element (ISIS_NODE, &no_area_passwd_cmd);
3309
Josh Bailey3f045a02012-03-24 08:35:20 -07003310 install_element (ISIS_NODE, &domain_passwd_md5_cmd);
3311 install_element (ISIS_NODE, &domain_passwd_md5_snpauth_cmd);
3312 install_element (ISIS_NODE, &domain_passwd_clear_cmd);
3313 install_element (ISIS_NODE, &domain_passwd_clear_snpauth_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003314 install_element (ISIS_NODE, &no_domain_passwd_cmd);
3315
3316 install_element (ISIS_NODE, &lsp_gen_interval_cmd);
3317 install_element (ISIS_NODE, &no_lsp_gen_interval_cmd);
3318 install_element (ISIS_NODE, &no_lsp_gen_interval_arg_cmd);
3319 install_element (ISIS_NODE, &lsp_gen_interval_l1_cmd);
3320 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_cmd);
3321 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_arg_cmd);
3322 install_element (ISIS_NODE, &lsp_gen_interval_l2_cmd);
3323 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_cmd);
3324 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_arg_cmd);
3325
3326 install_element (ISIS_NODE, &spf_interval_cmd);
3327 install_element (ISIS_NODE, &no_spf_interval_cmd);
3328 install_element (ISIS_NODE, &no_spf_interval_arg_cmd);
3329 install_element (ISIS_NODE, &spf_interval_l1_cmd);
3330 install_element (ISIS_NODE, &no_spf_interval_l1_cmd);
3331 install_element (ISIS_NODE, &no_spf_interval_l1_arg_cmd);
3332 install_element (ISIS_NODE, &spf_interval_l2_cmd);
3333 install_element (ISIS_NODE, &no_spf_interval_l2_cmd);
3334 install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd);
hassof390d2c2004-09-10 20:48:21 +00003335
Josh Bailey3f045a02012-03-24 08:35:20 -07003336 install_element (ISIS_NODE, &max_lsp_lifetime_cmd);
3337 install_element (ISIS_NODE, &no_max_lsp_lifetime_cmd);
3338 install_element (ISIS_NODE, &no_max_lsp_lifetime_arg_cmd);
3339 install_element (ISIS_NODE, &max_lsp_lifetime_l1_cmd);
3340 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_cmd);
3341 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_arg_cmd);
3342 install_element (ISIS_NODE, &max_lsp_lifetime_l2_cmd);
3343 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_cmd);
3344 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_arg_cmd);
3345
3346 install_element (ISIS_NODE, &lsp_refresh_interval_cmd);
3347 install_element (ISIS_NODE, &no_lsp_refresh_interval_cmd);
3348 install_element (ISIS_NODE, &no_lsp_refresh_interval_arg_cmd);
3349 install_element (ISIS_NODE, &lsp_refresh_interval_l1_cmd);
3350 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_cmd);
3351 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_arg_cmd);
3352 install_element (ISIS_NODE, &lsp_refresh_interval_l2_cmd);
3353 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_cmd);
3354 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_arg_cmd);
3355
3356 install_element (ISIS_NODE, &set_overload_bit_cmd);
3357 install_element (ISIS_NODE, &no_set_overload_bit_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003358
Amritha Nambiarc8ee9402015-08-24 16:40:14 -07003359 install_element (ISIS_NODE, &set_attached_bit_cmd);
3360 install_element (ISIS_NODE, &no_set_attached_bit_cmd);
3361
jardineb5d44e2003-12-23 08:09:43 +00003362 install_element (ISIS_NODE, &dynamic_hostname_cmd);
3363 install_element (ISIS_NODE, &no_dynamic_hostname_cmd);
3364
3365 install_element (ISIS_NODE, &metric_style_cmd);
3366 install_element (ISIS_NODE, &no_metric_style_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003367
3368 install_element (ISIS_NODE, &log_adj_changes_cmd);
3369 install_element (ISIS_NODE, &no_log_adj_changes_cmd);
3370
jardineb5d44e2003-12-23 08:09:43 +00003371#ifdef TOPOLOGY_GENERATE
3372 install_element (ISIS_NODE, &topology_generate_grid_cmd);
3373 install_element (ISIS_NODE, &topology_baseis_cmd);
hassof1082d12005-09-19 04:23:34 +00003374 install_element (ISIS_NODE, &topology_basedynh_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003375 install_element (ISIS_NODE, &no_topology_baseis_cmd);
hassof1082d12005-09-19 04:23:34 +00003376 install_element (ISIS_NODE, &no_topology_baseis_noid_cmd);
hassof695b012005-04-02 19:03:39 +00003377 install_element (VIEW_NODE, &show_isis_generated_topology_cmd);
3378 install_element (ENABLE_NODE, &show_isis_generated_topology_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003379#endif /* TOPOLOGY_GENERATE */
jardineb5d44e2003-12-23 08:09:43 +00003380}