blob: b601032a87db0b1485ed0881227f7b756f195cec [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);
Christian Franke80a8f722015-11-12 14:21:47 +0100775 if (flags & DEBUG_LSP_GEN)
776 vty_out (vty, "IS-IS LSP generation debugging is %s%s", onoffs, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000777}
778
779DEFUN (show_debugging,
780 show_debugging_cmd,
781 "show debugging",
782 SHOW_STR
783 "State of each debugging option\n")
784{
hassof390d2c2004-09-10 20:48:21 +0000785 vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000786 print_debug (vty, isis->debugs, 1);
787 return CMD_SUCCESS;
788}
789
jardin9e867fe2003-12-23 08:56:18 +0000790/* Debug node. */
hassof390d2c2004-09-10 20:48:21 +0000791static struct cmd_node debug_node = {
jardin9e867fe2003-12-23 08:56:18 +0000792 DEBUG_NODE,
hassof390d2c2004-09-10 20:48:21 +0000793 "",
794 1
jardin9e867fe2003-12-23 08:56:18 +0000795};
796
797static int
798config_write_debug (struct vty *vty)
799{
800 int write = 0;
801 int flags = isis->debugs;
802
hassof390d2c2004-09-10 20:48:21 +0000803 if (flags & DEBUG_ADJ_PACKETS)
804 {
805 vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
806 write++;
807 }
808 if (flags & DEBUG_CHECKSUM_ERRORS)
809 {
810 vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
811 write++;
812 }
813 if (flags & DEBUG_LOCAL_UPDATES)
814 {
815 vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
816 write++;
817 }
818 if (flags & DEBUG_PROTOCOL_ERRORS)
819 {
820 vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
821 write++;
822 }
823 if (flags & DEBUG_SNP_PACKETS)
824 {
825 vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
826 write++;
827 }
828 if (flags & DEBUG_SPF_EVENTS)
829 {
830 vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
831 write++;
832 }
833 if (flags & DEBUG_SPF_STATS)
834 {
835 vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
836 write++;
837 }
838 if (flags & DEBUG_SPF_TRIGGERS)
839 {
840 vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
841 write++;
842 }
843 if (flags & DEBUG_UPDATE_PACKETS)
844 {
845 vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
846 write++;
847 }
848 if (flags & DEBUG_RTE_EVENTS)
849 {
850 vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
851 write++;
852 }
853 if (flags & DEBUG_EVENTS)
854 {
855 vty_out (vty, "debug isis events%s", VTY_NEWLINE);
856 write++;
857 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700858 if (flags & DEBUG_PACKET_DUMP)
859 {
860 vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE);
861 write++;
862 }
Christian Franke80a8f722015-11-12 14:21:47 +0100863 if (flags & DEBUG_LSP_GEN)
864 {
865 vty_out (vty, "debug isis lsp-gen%s", VTY_NEWLINE);
866 write++;
867 }
jardin9e867fe2003-12-23 08:56:18 +0000868
869 return write;
870}
871
jardineb5d44e2003-12-23 08:09:43 +0000872DEFUN (debug_isis_adj,
873 debug_isis_adj_cmd,
874 "debug isis adj-packets",
875 DEBUG_STR
876 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000877 "IS-IS Adjacency related packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000878{
879 isis->debugs |= DEBUG_ADJ_PACKETS;
hassof390d2c2004-09-10 20:48:21 +0000880 print_debug (vty, DEBUG_ADJ_PACKETS, 1);
jardineb5d44e2003-12-23 08:09:43 +0000881
882 return CMD_SUCCESS;
883}
884
885DEFUN (no_debug_isis_adj,
886 no_debug_isis_adj_cmd,
887 "no debug isis adj-packets",
888 UNDEBUG_STR
889 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000890 "IS-IS Adjacency related packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000891{
jardineb5d44e2003-12-23 08:09:43 +0000892 isis->debugs &= ~DEBUG_ADJ_PACKETS;
893 print_debug (vty, DEBUG_ADJ_PACKETS, 0);
894
895 return CMD_SUCCESS;
896}
897
jardineb5d44e2003-12-23 08:09:43 +0000898DEFUN (debug_isis_csum,
899 debug_isis_csum_cmd,
900 "debug isis checksum-errors",
901 DEBUG_STR
902 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000903 "IS-IS LSP checksum errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000904{
905 isis->debugs |= DEBUG_CHECKSUM_ERRORS;
906 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1);
907
908 return CMD_SUCCESS;
909}
910
911DEFUN (no_debug_isis_csum,
912 no_debug_isis_csum_cmd,
913 "no debug isis checksum-errors",
914 UNDEBUG_STR
915 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000916 "IS-IS LSP checksum errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000917{
918 isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
919 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
hassof390d2c2004-09-10 20:48:21 +0000920
jardineb5d44e2003-12-23 08:09:43 +0000921 return CMD_SUCCESS;
922}
923
924DEFUN (debug_isis_lupd,
925 debug_isis_lupd_cmd,
926 "debug isis local-updates",
927 DEBUG_STR
928 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000929 "IS-IS local update packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000930{
931 isis->debugs |= DEBUG_LOCAL_UPDATES;
932 print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
933
934 return CMD_SUCCESS;
935}
936
937DEFUN (no_debug_isis_lupd,
938 no_debug_isis_lupd_cmd,
939 "no debug isis local-updates",
940 UNDEBUG_STR
941 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000942 "IS-IS local update packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000943{
944 isis->debugs &= ~DEBUG_LOCAL_UPDATES;
hassof390d2c2004-09-10 20:48:21 +0000945 print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
946
jardineb5d44e2003-12-23 08:09:43 +0000947 return CMD_SUCCESS;
948}
949
950DEFUN (debug_isis_err,
951 debug_isis_err_cmd,
hassof390d2c2004-09-10 20:48:21 +0000952 "debug isis protocol-errors",
jardineb5d44e2003-12-23 08:09:43 +0000953 DEBUG_STR
954 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000955 "IS-IS LSP protocol errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000956{
957 isis->debugs |= DEBUG_PROTOCOL_ERRORS;
958 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1);
959
960 return CMD_SUCCESS;
961}
962
963DEFUN (no_debug_isis_err,
964 no_debug_isis_err_cmd,
965 "no debug isis protocol-errors",
966 UNDEBUG_STR
967 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000968 "IS-IS LSP protocol errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000969{
970 isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
971 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
hassof390d2c2004-09-10 20:48:21 +0000972
jardineb5d44e2003-12-23 08:09:43 +0000973 return CMD_SUCCESS;
974}
975
976DEFUN (debug_isis_snp,
977 debug_isis_snp_cmd,
978 "debug isis snp-packets",
979 DEBUG_STR
980 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000981 "IS-IS CSNP/PSNP packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000982{
983 isis->debugs |= DEBUG_SNP_PACKETS;
984 print_debug (vty, DEBUG_SNP_PACKETS, 1);
985
986 return CMD_SUCCESS;
987}
988
989DEFUN (no_debug_isis_snp,
990 no_debug_isis_snp_cmd,
991 "no debug isis snp-packets",
992 UNDEBUG_STR
993 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000994 "IS-IS CSNP/PSNP packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000995{
hassof390d2c2004-09-10 20:48:21 +0000996 isis->debugs &= ~DEBUG_SNP_PACKETS;
jardineb5d44e2003-12-23 08:09:43 +0000997 print_debug (vty, DEBUG_SNP_PACKETS, 0);
hassof390d2c2004-09-10 20:48:21 +0000998
jardineb5d44e2003-12-23 08:09:43 +0000999 return CMD_SUCCESS;
1000}
1001
jardineb5d44e2003-12-23 08:09:43 +00001002DEFUN (debug_isis_upd,
1003 debug_isis_upd_cmd,
1004 "debug isis update-packets",
1005 DEBUG_STR
1006 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001007 "IS-IS Update related packets\n")
jardineb5d44e2003-12-23 08:09:43 +00001008{
1009 isis->debugs |= DEBUG_UPDATE_PACKETS;
1010 print_debug (vty, DEBUG_UPDATE_PACKETS, 1);
1011
1012 return CMD_SUCCESS;
1013}
1014
1015DEFUN (no_debug_isis_upd,
1016 no_debug_isis_upd_cmd,
1017 "no debug isis update-packets",
1018 UNDEBUG_STR
1019 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001020 "IS-IS Update related packets\n")
jardineb5d44e2003-12-23 08:09:43 +00001021{
1022 isis->debugs &= ~DEBUG_UPDATE_PACKETS;
1023 print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
hassof390d2c2004-09-10 20:48:21 +00001024
jardineb5d44e2003-12-23 08:09:43 +00001025 return CMD_SUCCESS;
1026}
1027
jardineb5d44e2003-12-23 08:09:43 +00001028DEFUN (debug_isis_spfevents,
1029 debug_isis_spfevents_cmd,
1030 "debug isis spf-events",
1031 DEBUG_STR
1032 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001033 "IS-IS Shortest Path First Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001034{
1035 isis->debugs |= DEBUG_SPF_EVENTS;
hassof390d2c2004-09-10 20:48:21 +00001036 print_debug (vty, DEBUG_SPF_EVENTS, 1);
jardineb5d44e2003-12-23 08:09:43 +00001037
1038 return CMD_SUCCESS;
1039}
1040
1041DEFUN (no_debug_isis_spfevents,
1042 no_debug_isis_spfevents_cmd,
1043 "no debug isis spf-events",
1044 UNDEBUG_STR
1045 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001046 "IS-IS Shortest Path First Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001047{
1048 isis->debugs &= ~DEBUG_SPF_EVENTS;
hassof390d2c2004-09-10 20:48:21 +00001049 print_debug (vty, DEBUG_SPF_EVENTS, 0);
1050
jardineb5d44e2003-12-23 08:09:43 +00001051 return CMD_SUCCESS;
1052}
1053
jardineb5d44e2003-12-23 08:09:43 +00001054DEFUN (debug_isis_spfstats,
1055 debug_isis_spfstats_cmd,
1056 "debug isis spf-statistics ",
1057 DEBUG_STR
1058 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001059 "IS-IS SPF Timing and Statistic Data\n")
jardineb5d44e2003-12-23 08:09:43 +00001060{
1061 isis->debugs |= DEBUG_SPF_STATS;
1062 print_debug (vty, DEBUG_SPF_STATS, 1);
1063
1064 return CMD_SUCCESS;
1065}
1066
1067DEFUN (no_debug_isis_spfstats,
1068 no_debug_isis_spfstats_cmd,
1069 "no debug isis spf-statistics",
1070 UNDEBUG_STR
1071 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001072 "IS-IS SPF Timing and Statistic Data\n")
jardineb5d44e2003-12-23 08:09:43 +00001073{
1074 isis->debugs &= ~DEBUG_SPF_STATS;
1075 print_debug (vty, DEBUG_SPF_STATS, 0);
hassof390d2c2004-09-10 20:48:21 +00001076
jardineb5d44e2003-12-23 08:09:43 +00001077 return CMD_SUCCESS;
1078}
1079
1080DEFUN (debug_isis_spftrigg,
1081 debug_isis_spftrigg_cmd,
1082 "debug isis spf-triggers",
1083 DEBUG_STR
1084 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001085 "IS-IS SPF triggering events\n")
jardineb5d44e2003-12-23 08:09:43 +00001086{
1087 isis->debugs |= DEBUG_SPF_TRIGGERS;
1088 print_debug (vty, DEBUG_SPF_TRIGGERS, 1);
1089
1090 return CMD_SUCCESS;
1091}
1092
1093DEFUN (no_debug_isis_spftrigg,
1094 no_debug_isis_spftrigg_cmd,
1095 "no debug isis spf-triggers",
1096 UNDEBUG_STR
1097 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001098 "IS-IS SPF triggering events\n")
jardineb5d44e2003-12-23 08:09:43 +00001099{
1100 isis->debugs &= ~DEBUG_SPF_TRIGGERS;
1101 print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
hassof390d2c2004-09-10 20:48:21 +00001102
jardineb5d44e2003-12-23 08:09:43 +00001103 return CMD_SUCCESS;
1104}
1105
1106DEFUN (debug_isis_rtevents,
1107 debug_isis_rtevents_cmd,
1108 "debug isis route-events",
1109 DEBUG_STR
1110 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001111 "IS-IS Route related events\n")
jardineb5d44e2003-12-23 08:09:43 +00001112{
1113 isis->debugs |= DEBUG_RTE_EVENTS;
1114 print_debug (vty, DEBUG_RTE_EVENTS, 1);
1115
1116 return CMD_SUCCESS;
1117}
1118
1119DEFUN (no_debug_isis_rtevents,
1120 no_debug_isis_rtevents_cmd,
1121 "no debug isis route-events",
1122 UNDEBUG_STR
1123 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001124 "IS-IS Route related events\n")
jardineb5d44e2003-12-23 08:09:43 +00001125{
1126 isis->debugs &= ~DEBUG_RTE_EVENTS;
1127 print_debug (vty, DEBUG_RTE_EVENTS, 0);
hassof390d2c2004-09-10 20:48:21 +00001128
jardineb5d44e2003-12-23 08:09:43 +00001129 return CMD_SUCCESS;
1130}
1131
1132DEFUN (debug_isis_events,
1133 debug_isis_events_cmd,
1134 "debug isis events",
1135 DEBUG_STR
1136 "IS-IS information\n"
hassof1082d12005-09-19 04:23:34 +00001137 "IS-IS Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001138{
1139 isis->debugs |= DEBUG_EVENTS;
1140 print_debug (vty, DEBUG_EVENTS, 1);
1141
1142 return CMD_SUCCESS;
1143}
1144
1145DEFUN (no_debug_isis_events,
1146 no_debug_isis_events_cmd,
1147 "no debug isis events",
1148 UNDEBUG_STR
1149 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001150 "IS-IS Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001151{
1152 isis->debugs &= ~DEBUG_EVENTS;
1153 print_debug (vty, DEBUG_EVENTS, 0);
hassof390d2c2004-09-10 20:48:21 +00001154
jardineb5d44e2003-12-23 08:09:43 +00001155 return CMD_SUCCESS;
1156}
1157
Josh Bailey3f045a02012-03-24 08:35:20 -07001158DEFUN (debug_isis_packet_dump,
1159 debug_isis_packet_dump_cmd,
1160 "debug isis packet-dump",
1161 DEBUG_STR
1162 "IS-IS information\n"
1163 "IS-IS packet dump\n")
1164{
1165 isis->debugs |= DEBUG_PACKET_DUMP;
1166 print_debug (vty, DEBUG_PACKET_DUMP, 1);
1167
1168 return CMD_SUCCESS;
1169}
1170
1171DEFUN (no_debug_isis_packet_dump,
1172 no_debug_isis_packet_dump_cmd,
1173 "no debug isis packet-dump",
1174 UNDEBUG_STR
1175 "IS-IS information\n"
1176 "IS-IS packet dump\n")
1177{
1178 isis->debugs &= ~DEBUG_PACKET_DUMP;
1179 print_debug (vty, DEBUG_PACKET_DUMP, 0);
1180
1181 return CMD_SUCCESS;
1182}
1183
Christian Franke80a8f722015-11-12 14:21:47 +01001184DEFUN (debug_isis_lsp_gen,
1185 debug_isis_lsp_gen_cmd,
1186 "debug isis lsp-gen",
1187 DEBUG_STR
1188 "IS-IS information\n"
1189 "IS-IS generation of own LSPs\n")
1190{
1191 isis->debugs |= DEBUG_LSP_GEN;
1192 print_debug (vty, DEBUG_LSP_GEN, 1);
1193
1194 return CMD_SUCCESS;
1195}
1196
1197DEFUN (no_debug_isis_lsp_gen,
1198 no_debug_isis_lsp_gen_cmd,
1199 "no debug isis lsp-gen",
1200 UNDEBUG_STR
1201 "IS-IS information\n"
1202 "IS-IS generation of own LSPs\n")
1203{
1204 isis->debugs &= ~DEBUG_LSP_GEN;
1205 print_debug (vty, DEBUG_LSP_GEN, 0);
1206
1207 return CMD_SUCCESS;
1208}
1209
jardineb5d44e2003-12-23 08:09:43 +00001210DEFUN (show_hostname,
1211 show_hostname_cmd,
1212 "show isis hostname",
1213 SHOW_STR
1214 "IS-IS information\n"
1215 "IS-IS Dynamic hostname mapping\n")
1216{
1217 dynhn_print_all (vty);
hassof390d2c2004-09-10 20:48:21 +00001218
jardineb5d44e2003-12-23 08:09:43 +00001219 return CMD_SUCCESS;
1220}
1221
Josh Bailey3f045a02012-03-24 08:35:20 -07001222static void
1223vty_out_timestr(struct vty *vty, time_t uptime)
1224{
1225 struct tm *tm;
1226 time_t difftime = time (NULL);
1227 difftime -= uptime;
1228 tm = gmtime (&difftime);
1229
1230#define ONE_DAY_SECOND 60*60*24
1231#define ONE_WEEK_SECOND 60*60*24*7
1232 if (difftime < ONE_DAY_SECOND)
1233 vty_out (vty, "%02d:%02d:%02d",
1234 tm->tm_hour, tm->tm_min, tm->tm_sec);
1235 else if (difftime < ONE_WEEK_SECOND)
1236 vty_out (vty, "%dd%02dh%02dm",
1237 tm->tm_yday, tm->tm_hour, tm->tm_min);
1238 else
1239 vty_out (vty, "%02dw%dd%02dh",
1240 tm->tm_yday/7,
1241 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1242 vty_out (vty, " ago");
1243}
1244
1245DEFUN (show_isis_summary,
1246 show_isis_summary_cmd,
1247 "show isis summary",
1248 SHOW_STR "IS-IS information\n" "IS-IS summary\n")
1249{
1250 struct listnode *node, *node2;
1251 struct isis_area *area;
1252 struct isis_spftree *spftree;
1253 int level;
1254
1255 if (isis == NULL)
1256 {
1257 vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
1258 return CMD_SUCCESS;
1259 }
1260
1261 vty_out (vty, "Process Id : %ld%s", isis->process_id,
1262 VTY_NEWLINE);
1263 if (isis->sysid_set)
1264 vty_out (vty, "System Id : %s%s", sysid_print (isis->sysid),
1265 VTY_NEWLINE);
1266
1267 vty_out (vty, "Up time : ");
1268 vty_out_timestr(vty, isis->uptime);
1269 vty_out (vty, "%s", VTY_NEWLINE);
1270
1271 if (isis->area_list)
1272 vty_out (vty, "Number of areas : %d%s", isis->area_list->count,
1273 VTY_NEWLINE);
1274
1275 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1276 {
1277 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1278 VTY_NEWLINE);
1279
1280 if (listcount (area->area_addrs) > 0)
1281 {
1282 struct area_addr *area_addr;
1283 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
1284 {
1285 vty_out (vty, " Net: %s%s",
1286 isonet_print (area_addr->area_addr,
1287 area_addr->addr_len + ISIS_SYS_ID_LEN +
1288 1), VTY_NEWLINE);
1289 }
1290 }
1291
1292 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
1293 {
1294 if ((area->is_type & level) == 0)
1295 continue;
1296
1297 vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE);
1298 spftree = area->spftree[level - 1];
1299 if (spftree->pending)
1300 vty_out (vty, " IPv4 SPF: (pending)%s", VTY_NEWLINE);
1301 else
1302 vty_out (vty, " IPv4 SPF:%s", VTY_NEWLINE);
1303
1304 vty_out (vty, " minimum interval : %d%s",
1305 area->min_spf_interval[level - 1], VTY_NEWLINE);
1306
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001307 vty_out (vty, " last run elapsed : ");
1308 vty_out_timestr(vty, spftree->last_run_timestamp);
Josh Bailey3f045a02012-03-24 08:35:20 -07001309 vty_out (vty, "%s", VTY_NEWLINE);
1310
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001311 vty_out (vty, " last run duration : %u usec%s",
1312 (u_int32_t)spftree->last_run_duration, VTY_NEWLINE);
1313
Josh Bailey3f045a02012-03-24 08:35:20 -07001314 vty_out (vty, " run count : %d%s",
1315 spftree->runcount, VTY_NEWLINE);
1316
1317#ifdef HAVE_IPV6
1318 spftree = area->spftree6[level - 1];
1319 if (spftree->pending)
1320 vty_out (vty, " IPv6 SPF: (pending)%s", VTY_NEWLINE);
1321 else
1322 vty_out (vty, " IPv6 SPF:%s", VTY_NEWLINE);
1323
1324 vty_out (vty, " minimum interval : %d%s",
1325 area->min_spf_interval[level - 1], VTY_NEWLINE);
1326
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001327 vty_out (vty, " last run elapsed : ");
1328 vty_out_timestr(vty, spftree->last_run_timestamp);
Josh Bailey3f045a02012-03-24 08:35:20 -07001329 vty_out (vty, "%s", VTY_NEWLINE);
1330
David Lamparteref008d22015-03-03 08:48:11 +01001331 vty_out (vty, " last run duration : %llu msec%s",
1332 (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001333
Josh Bailey3f045a02012-03-24 08:35:20 -07001334 vty_out (vty, " run count : %d%s",
1335 spftree->runcount, VTY_NEWLINE);
1336#endif
1337 }
1338 }
1339 vty_out (vty, "%s", VTY_NEWLINE);
1340
1341 return CMD_SUCCESS;
1342}
1343
1344/*
1345 * This function supports following display options:
1346 * [ show isis database [detail] ]
1347 * [ show isis database <sysid> [detail] ]
1348 * [ show isis database <hostname> [detail] ]
1349 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1350 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1351 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1352 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1353 * [ show isis database detail <sysid> ]
1354 * [ show isis database detail <hostname> ]
1355 * [ show isis database detail <sysid>.<pseudo-id> ]
1356 * [ show isis database detail <hostname>.<pseudo-id> ]
1357 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1358 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1359 */
1360static int
1361show_isis_database (struct vty *vty, const char *argv, int ui_level)
jardineb5d44e2003-12-23 08:09:43 +00001362{
hasso3fdb2dd2005-09-28 18:45:54 +00001363 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +00001364 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07001365 struct isis_lsp *lsp;
1366 struct isis_dynhn *dynhn;
1367 const char *pos = argv;
1368 u_char lspid[ISIS_SYS_ID_LEN+2];
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001369 char sysid[255];
Josh Bailey3f045a02012-03-24 08:35:20 -07001370 u_char number[3];
hassof390d2c2004-09-10 20:48:21 +00001371 int level, lsp_count;
jardineb5d44e2003-12-23 08:09:43 +00001372
1373 if (isis->area_list->count == 0)
1374 return CMD_SUCCESS;
jardineb5d44e2003-12-23 08:09:43 +00001375
Josh Bailey3f045a02012-03-24 08:35:20 -07001376 memset (&lspid, 0, ISIS_SYS_ID_LEN);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001377 memset (&sysid, 0, 255);
Josh Bailey3f045a02012-03-24 08:35:20 -07001378
1379 /*
1380 * extract fragment and pseudo id from the string argv
1381 * in the forms:
1382 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1383 * (b) <systemid/hostname>.<pseudo-id> or
1384 * (c) <systemid/hostname> or
1385 * Where systemid is in the form:
1386 * xxxx.xxxx.xxxx
1387 */
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001388 if (argv)
1389 strncpy (sysid, argv, 254);
Josh Bailey3f045a02012-03-24 08:35:20 -07001390 if (argv && strlen (argv) > 3)
1391 {
1392 pos = argv + strlen (argv) - 3;
1393 if (strncmp (pos, "-", 1) == 0)
1394 {
1395 memcpy (number, ++pos, 2);
1396 lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16);
1397 pos -= 4;
1398 if (strncmp (pos, ".", 1) != 0)
1399 return CMD_ERR_AMBIGUOUS;
1400 }
1401 if (strncmp (pos, ".", 1) == 0)
1402 {
1403 memcpy (number, ++pos, 2);
1404 lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16);
1405 sysid[pos - argv - 1] = '\0';
1406 }
1407 }
1408
hasso3fdb2dd2005-09-28 18:45:54 +00001409 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof390d2c2004-09-10 20:48:21 +00001410 {
hassof390d2c2004-09-10 20:48:21 +00001411 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
Josh Bailey3f045a02012-03-24 08:35:20 -07001412 VTY_NEWLINE);
1413
hassof390d2c2004-09-10 20:48:21 +00001414 for (level = 0; level < ISIS_LEVELS; level++)
Josh Bailey3f045a02012-03-24 08:35:20 -07001415 {
1416 if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
1417 {
1418 lsp = NULL;
1419 if (argv != NULL)
1420 {
1421 /*
1422 * Try to find the lsp-id if the argv string is in
1423 * the form hostname.<pseudo-id>-<fragment>
1424 */
1425 if (sysid2buff (lspid, sysid))
1426 {
1427 lsp = lsp_search (lspid, area->lspdb[level]);
1428 }
1429 else if ((dynhn = dynhn_find_by_name (sysid)))
1430 {
1431 memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN);
1432 lsp = lsp_search (lspid, area->lspdb[level]);
1433 }
1434 else if (strncmp(unix_hostname (), sysid, 15) == 0)
1435 {
1436 memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
1437 lsp = lsp_search (lspid, area->lspdb[level]);
1438 }
1439 }
jardineb5d44e2003-12-23 08:09:43 +00001440
Josh Bailey3f045a02012-03-24 08:35:20 -07001441 if (lsp != NULL || argv == NULL)
1442 {
1443 vty_out (vty, "IS-IS Level-%d link-state database:%s",
1444 level + 1, VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +00001445
Josh Bailey3f045a02012-03-24 08:35:20 -07001446 /* print the title in all cases */
1447 vty_out (vty, "LSP ID PduLen "
1448 "SeqNumber Chksum Holdtime ATT/P/OL%s",
1449 VTY_NEWLINE);
1450 }
1451
1452 if (lsp)
1453 {
1454 if (ui_level == ISIS_UI_LEVEL_DETAIL)
1455 lsp_print_detail (lsp, vty, area->dynhostname);
1456 else
1457 lsp_print (lsp, vty, area->dynhostname);
1458 }
1459 else if (argv == NULL)
1460 {
1461 lsp_count = lsp_print_all (vty, area->lspdb[level],
1462 ui_level,
1463 area->dynhostname);
1464
1465 vty_out (vty, " %u LSPs%s%s",
1466 lsp_count, VTY_NEWLINE, VTY_NEWLINE);
1467 }
1468 }
1469 }
jardineb5d44e2003-12-23 08:09:43 +00001470 }
jardineb5d44e2003-12-23 08:09:43 +00001471
1472 return CMD_SUCCESS;
1473}
1474
Josh Bailey3f045a02012-03-24 08:35:20 -07001475DEFUN (show_database_brief,
1476 show_database_cmd,
1477 "show isis database",
1478 SHOW_STR
1479 "IS-IS information\n"
1480 "IS-IS link state database\n")
1481{
1482 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_BRIEF);
1483}
1484
1485DEFUN (show_database_lsp_brief,
1486 show_database_arg_cmd,
1487 "show isis database WORD",
1488 SHOW_STR
1489 "IS-IS information\n"
1490 "IS-IS link state database\n"
1491 "LSP ID\n")
1492{
1493 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_BRIEF);
1494}
1495
1496DEFUN (show_database_lsp_detail,
1497 show_database_arg_detail_cmd,
1498 "show isis database WORD detail",
1499 SHOW_STR
1500 "IS-IS information\n"
1501 "IS-IS link state database\n"
1502 "LSP ID\n"
1503 "Detailed information\n")
1504{
1505 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
1506}
1507
jardineb5d44e2003-12-23 08:09:43 +00001508DEFUN (show_database_detail,
1509 show_database_detail_cmd,
1510 "show isis database detail",
1511 SHOW_STR
1512 "IS-IS information\n"
1513 "IS-IS link state database\n")
1514{
Josh Bailey3f045a02012-03-24 08:35:20 -07001515 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_DETAIL);
1516}
jardineb5d44e2003-12-23 08:09:43 +00001517
Josh Bailey3f045a02012-03-24 08:35:20 -07001518DEFUN (show_database_detail_lsp,
1519 show_database_detail_arg_cmd,
1520 "show isis database detail WORD",
1521 SHOW_STR
1522 "IS-IS information\n"
1523 "IS-IS link state database\n"
1524 "Detailed information\n"
1525 "LSP ID\n")
1526{
1527 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
jardineb5d44e2003-12-23 08:09:43 +00001528}
1529
1530/*
1531 * 'router isis' command
1532 */
1533DEFUN (router_isis,
1534 router_isis_cmd,
1535 "router isis WORD",
hassof390d2c2004-09-10 20:48:21 +00001536 ROUTER_STR
jardineb5d44e2003-12-23 08:09:43 +00001537 "ISO IS-IS\n"
1538 "ISO Routing area tag")
1539{
jardineb5d44e2003-12-23 08:09:43 +00001540 return isis_area_get (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001541}
1542
1543/*
1544 *'no router isis' command
1545 */
1546DEFUN (no_router_isis,
1547 no_router_isis_cmd,
1548 "no router isis WORD",
hassof390d2c2004-09-10 20:48:21 +00001549 "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
jardineb5d44e2003-12-23 08:09:43 +00001550{
1551 return isis_area_destroy (vty, argv[0]);
1552}
1553
1554/*
1555 * 'net' command
1556 */
1557DEFUN (net,
1558 net_cmd,
1559 "net WORD",
1560 "A Network Entity Title for this process (OSI only)\n"
hassof390d2c2004-09-10 20:48:21 +00001561 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00001562{
Paul Jakma41b36e92006-12-08 01:09:50 +00001563 return area_net_title (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001564}
1565
jardineb5d44e2003-12-23 08:09:43 +00001566/*
1567 * 'no net' command
1568 */
1569DEFUN (no_net,
1570 no_net_cmd,
1571 "no net WORD",
1572 NO_STR
1573 "A Network Entity Title for this process (OSI only)\n"
hassof390d2c2004-09-10 20:48:21 +00001574 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00001575{
Paul Jakma41b36e92006-12-08 01:09:50 +00001576 return area_clear_net_title (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001577}
1578
Christian Frankef1fc1db2015-11-10 18:43:31 +01001579static
1580int area_set_lsp_mtu(struct vty *vty, struct isis_area *area, unsigned int lsp_mtu)
1581{
1582 struct isis_circuit *circuit;
1583 struct listnode *node;
1584
1585 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
1586 {
1587 if(lsp_mtu > isis_circuit_pdu_size(circuit))
1588 {
1589 vty_out(vty, "ISIS area contains circuit %s, which has a maximum PDU size of %zu.%s",
1590 circuit->interface->name, isis_circuit_pdu_size(circuit),
1591 VTY_NEWLINE);
1592 return CMD_ERR_AMBIGUOUS;
1593 }
1594 }
1595
1596 area->lsp_mtu = lsp_mtu;
1597 lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
1598
1599 return CMD_SUCCESS;
1600}
1601
1602DEFUN (area_lsp_mtu,
1603 area_lsp_mtu_cmd,
1604 "lsp-mtu <128-4352>",
1605 "Configure the maximum size of generated LSPs\n"
1606 "Maximum size of generated LSPs\n")
1607{
1608 struct isis_area *area;
1609
1610 area = vty->index;
1611 if (!area)
1612 {
1613 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1614 return CMD_ERR_NO_MATCH;
1615 }
1616
1617 unsigned int lsp_mtu;
1618
1619 VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[0], 128, 4352);
1620
1621 return area_set_lsp_mtu(vty, area, lsp_mtu);
1622}
1623
1624DEFUN(no_area_lsp_mtu,
1625 no_area_lsp_mtu_cmd,
1626 "no lsp-mtu",
1627 NO_STR
1628 "Configure the maximum size of generated LSPs\n")
1629{
1630 struct isis_area *area;
1631
1632 area = vty->index;
1633 if (!area)
1634 {
1635 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1636 return CMD_ERR_NO_MATCH;
1637 }
1638
1639 return area_set_lsp_mtu(vty, area, DEFAULT_LSP_MTU);
1640}
1641
1642ALIAS(no_area_lsp_mtu,
1643 no_area_lsp_mtu_arg_cmd,
1644 "no lsp-mtu <128-4352>",
1645 NO_STR
1646 "Configure the maximum size of generated LSPs\n"
1647 "Maximum size of generated LSPs\n");
1648
Josh Bailey3f045a02012-03-24 08:35:20 -07001649DEFUN (area_passwd_md5,
1650 area_passwd_md5_cmd,
1651 "area-password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001652 "Configure the authentication password for an area\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001653 "Authentication type\n"
hassof390d2c2004-09-10 20:48:21 +00001654 "Area password\n")
jardineb5d44e2003-12-23 08:09:43 +00001655{
1656 struct isis_area *area;
1657 int len;
1658
1659 area = vty->index;
1660
hassof390d2c2004-09-10 20:48:21 +00001661 if (!area)
1662 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001663 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1664 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001665 }
1666
jardineb5d44e2003-12-23 08:09:43 +00001667 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001668 if (len > 254)
1669 {
1670 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001671 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001672 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001673
1674 area->area_passwd.len = (u_char) len;
1675 area->area_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1676 strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
1677
1678 if (argc > 1)
1679 {
1680 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1681 if (strncmp(argv[1], "v", 1) == 0)
1682 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1683 else
1684 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1685 }
1686 else
1687 {
1688 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1689 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1690 }
1691 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1692
1693 return CMD_SUCCESS;
1694}
1695
1696ALIAS (area_passwd_md5,
1697 area_passwd_md5_snpauth_cmd,
1698 "area-password md5 WORD authenticate snp (send-only|validate)",
1699 "Configure the authentication password for an area\n"
1700 "Authentication type\n"
1701 "Area password\n"
1702 "Authentication\n"
1703 "SNP PDUs\n"
1704 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001705 "Send and check PDUs on receiving\n")
Josh Bailey3f045a02012-03-24 08:35:20 -07001706
1707DEFUN (area_passwd_clear,
1708 area_passwd_clear_cmd,
1709 "area-password clear WORD",
1710 "Configure the authentication password for an area\n"
1711 "Authentication type\n"
1712 "Area password\n")
1713{
1714 struct isis_area *area;
1715 int len;
1716
1717 area = vty->index;
1718
1719 if (!area)
1720 {
1721 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1722 return CMD_ERR_NO_MATCH;
1723 }
1724
1725 len = strlen (argv[0]);
1726 if (len > 254)
1727 {
1728 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1729 return CMD_ERR_AMBIGUOUS;
1730 }
1731
hassof390d2c2004-09-10 20:48:21 +00001732 area->area_passwd.len = (u_char) len;
jardineb5d44e2003-12-23 08:09:43 +00001733 area->area_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001734 strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001735
hasso1cbc5622005-01-01 10:29:51 +00001736 if (argc > 1)
1737 {
1738 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1739 if (strncmp(argv[1], "v", 1) == 0)
1740 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1741 else
1742 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1743 }
1744 else
1745 {
1746 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1747 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1748 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001749 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hasso1cbc5622005-01-01 10:29:51 +00001750
jardineb5d44e2003-12-23 08:09:43 +00001751 return CMD_SUCCESS;
1752}
1753
Josh Bailey3f045a02012-03-24 08:35:20 -07001754ALIAS (area_passwd_clear,
1755 area_passwd_clear_snpauth_cmd,
1756 "area-password clear WORD authenticate snp (send-only|validate)",
hasso1cbc5622005-01-01 10:29:51 +00001757 "Configure the authentication password for an area\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001758 "Authentication type\n"
hasso1cbc5622005-01-01 10:29:51 +00001759 "Area password\n"
1760 "Authentication\n"
1761 "SNP PDUs\n"
1762 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001763 "Send and check PDUs on receiving\n")
hasso1cbc5622005-01-01 10:29:51 +00001764
jardineb5d44e2003-12-23 08:09:43 +00001765DEFUN (no_area_passwd,
1766 no_area_passwd_cmd,
1767 "no area-password",
1768 NO_STR
1769 "Configure the authentication password for an area\n")
1770{
1771 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00001772
jardineb5d44e2003-12-23 08:09:43 +00001773 area = vty->index;
1774
hassof390d2c2004-09-10 20:48:21 +00001775 if (!area)
1776 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001777 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1778 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001779 }
1780
jardineb5d44e2003-12-23 08:09:43 +00001781 memset (&area->area_passwd, 0, sizeof (struct isis_passwd));
Josh Bailey3f045a02012-03-24 08:35:20 -07001782 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
jardineb5d44e2003-12-23 08:09:43 +00001783
1784 return CMD_SUCCESS;
1785}
1786
Josh Bailey3f045a02012-03-24 08:35:20 -07001787DEFUN (domain_passwd_md5,
1788 domain_passwd_md5_cmd,
1789 "domain-password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001790 "Set the authentication password for a routing domain\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001791 "Authentication type\n"
hassof390d2c2004-09-10 20:48:21 +00001792 "Routing domain password\n")
jardineb5d44e2003-12-23 08:09:43 +00001793{
1794 struct isis_area *area;
1795 int len;
1796
1797 area = vty->index;
1798
hassof390d2c2004-09-10 20:48:21 +00001799 if (!area)
1800 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001801 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1802 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001803 }
1804
jardineb5d44e2003-12-23 08:09:43 +00001805 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001806 if (len > 254)
1807 {
1808 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001809 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001810 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001811
1812 area->domain_passwd.len = (u_char) len;
1813 area->domain_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1814 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
1815
1816 if (argc > 1)
1817 {
1818 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1819 if (strncmp(argv[1], "v", 1) == 0)
1820 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1821 else
1822 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1823 }
1824 else
1825 {
1826 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1827 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1828 }
1829 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1830
1831 return CMD_SUCCESS;
1832}
1833
1834ALIAS (domain_passwd_md5,
1835 domain_passwd_md5_snpauth_cmd,
1836 "domain-password md5 WORD authenticate snp (send-only|validate)",
1837 "Set the authentication password for a routing domain\n"
1838 "Authentication type\n"
1839 "Routing domain password\n"
1840 "Authentication\n"
1841 "SNP PDUs\n"
1842 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001843 "Send and check PDUs on receiving\n")
Josh Bailey3f045a02012-03-24 08:35:20 -07001844
1845DEFUN (domain_passwd_clear,
1846 domain_passwd_clear_cmd,
1847 "domain-password clear WORD",
1848 "Set the authentication password for a routing domain\n"
1849 "Authentication type\n"
1850 "Routing domain password\n")
1851{
1852 struct isis_area *area;
1853 int len;
1854
1855 area = vty->index;
1856
1857 if (!area)
1858 {
1859 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1860 return CMD_ERR_NO_MATCH;
1861 }
1862
1863 len = strlen (argv[0]);
1864 if (len > 254)
1865 {
1866 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1867 return CMD_ERR_AMBIGUOUS;
1868 }
1869
hassof390d2c2004-09-10 20:48:21 +00001870 area->domain_passwd.len = (u_char) len;
jardineb5d44e2003-12-23 08:09:43 +00001871 area->domain_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001872 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001873
hasso1cbc5622005-01-01 10:29:51 +00001874 if (argc > 1)
1875 {
1876 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1877 if (strncmp(argv[1], "v", 1) == 0)
1878 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1879 else
1880 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1881 }
1882 else
1883 {
1884 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1885 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1886 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001887 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hasso1cbc5622005-01-01 10:29:51 +00001888
jardineb5d44e2003-12-23 08:09:43 +00001889 return CMD_SUCCESS;
1890}
1891
Josh Bailey3f045a02012-03-24 08:35:20 -07001892ALIAS (domain_passwd_clear,
1893 domain_passwd_clear_snpauth_cmd,
1894 "domain-password clear WORD authenticate snp (send-only|validate)",
hasso1cbc5622005-01-01 10:29:51 +00001895 "Set the authentication password for a routing domain\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001896 "Authentication type\n"
hasso1cbc5622005-01-01 10:29:51 +00001897 "Routing domain password\n"
1898 "Authentication\n"
1899 "SNP PDUs\n"
1900 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001901 "Send and check PDUs on receiving\n")
hasso1cbc5622005-01-01 10:29:51 +00001902
jardineb5d44e2003-12-23 08:09:43 +00001903DEFUN (no_domain_passwd,
1904 no_domain_passwd_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07001905 "no domain-password",
jardineb5d44e2003-12-23 08:09:43 +00001906 NO_STR
1907 "Set the authentication password for a routing domain\n")
1908{
1909 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00001910
jardineb5d44e2003-12-23 08:09:43 +00001911 area = vty->index;
1912
hassof390d2c2004-09-10 20:48:21 +00001913 if (!area)
1914 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001915 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1916 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001917 }
1918
jardineb5d44e2003-12-23 08:09:43 +00001919 memset (&area->domain_passwd, 0, sizeof (struct isis_passwd));
Josh Bailey3f045a02012-03-24 08:35:20 -07001920 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hassof390d2c2004-09-10 20:48:21 +00001921
jardineb5d44e2003-12-23 08:09:43 +00001922 return CMD_SUCCESS;
1923}
1924
1925DEFUN (is_type,
1926 is_type_cmd,
1927 "is-type (level-1|level-1-2|level-2-only)",
1928 "IS Level for this routing process (OSI only)\n"
1929 "Act as a station router only\n"
1930 "Act as both a station router and an area router\n"
1931 "Act as an area router only\n")
1932{
1933 struct isis_area *area;
1934 int type;
1935
1936 area = vty->index;
1937
hassof390d2c2004-09-10 20:48:21 +00001938 if (!area)
1939 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001940 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1941 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001942 }
jardineb5d44e2003-12-23 08:09:43 +00001943
Paul Jakma41b36e92006-12-08 01:09:50 +00001944 type = string2circuit_t (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001945 if (!type)
1946 {
1947 vty_out (vty, "Unknown IS level %s", VTY_NEWLINE);
1948 return CMD_SUCCESS;
1949 }
jardineb5d44e2003-12-23 08:09:43 +00001950
1951 isis_event_system_type_change (area, type);
hassof390d2c2004-09-10 20:48:21 +00001952
jardineb5d44e2003-12-23 08:09:43 +00001953 return CMD_SUCCESS;
1954}
1955
1956DEFUN (no_is_type,
1957 no_is_type_cmd,
1958 "no is-type (level-1|level-1-2|level-2-only)",
1959 NO_STR
1960 "IS Level for this routing process (OSI only)\n"
1961 "Act as a station router only\n"
1962 "Act as both a station router and an area router\n"
1963 "Act as an area router only\n")
1964{
jardineb5d44e2003-12-23 08:09:43 +00001965 struct isis_area *area;
1966 int type;
1967
1968 area = vty->index;
1969 assert (area);
hassof390d2c2004-09-10 20:48:21 +00001970
jardineb5d44e2003-12-23 08:09:43 +00001971 /*
Josh Bailey3f045a02012-03-24 08:35:20 -07001972 * Put the is-type back to defaults:
1973 * - level-1-2 on first area
1974 * - level-1 for the rest
jardineb5d44e2003-12-23 08:09:43 +00001975 */
paul1eb8ef22005-04-07 07:30:20 +00001976 if (listgetdata (listhead (isis->area_list)) == area)
jardineb5d44e2003-12-23 08:09:43 +00001977 type = IS_LEVEL_1_AND_2;
1978 else
1979 type = IS_LEVEL_1;
1980
1981 isis_event_system_type_change (area, type);
1982
1983 return CMD_SUCCESS;
1984}
1985
Josh Bailey3f045a02012-03-24 08:35:20 -07001986static int
1987set_lsp_gen_interval (struct vty *vty, struct isis_area *area,
1988 uint16_t interval, int level)
1989{
1990 int lvl;
1991
1992 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
1993 {
1994 if (!(lvl & level))
1995 continue;
1996
1997 if (interval >= area->lsp_refresh[lvl-1])
1998 {
1999 vty_out (vty, "LSP gen interval %us must be less than "
2000 "the LSP refresh interval %us%s",
2001 interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
2002 return CMD_ERR_AMBIGUOUS;
2003 }
2004 }
2005
2006 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2007 {
2008 if (!(lvl & level))
2009 continue;
2010 area->lsp_gen_interval[lvl-1] = interval;
2011 }
2012
2013 return CMD_SUCCESS;
2014}
2015
jardineb5d44e2003-12-23 08:09:43 +00002016DEFUN (lsp_gen_interval,
2017 lsp_gen_interval_cmd,
2018 "lsp-gen-interval <1-120>",
2019 "Minimum interval between regenerating same LSP\n"
2020 "Minimum interval in seconds\n")
2021{
2022 struct isis_area *area;
2023 uint16_t interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002024 int level;
jardineb5d44e2003-12-23 08:09:43 +00002025
2026 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002027 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002028 level = IS_LEVEL_1 | IS_LEVEL_2;
2029 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002030}
2031
2032DEFUN (no_lsp_gen_interval,
2033 no_lsp_gen_interval_cmd,
2034 "no lsp-gen-interval",
2035 NO_STR
hassof390d2c2004-09-10 20:48:21 +00002036 "Minimum interval between regenerating same LSP\n")
jardineb5d44e2003-12-23 08:09:43 +00002037{
2038 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002039 uint16_t interval;
2040 int level;
jardineb5d44e2003-12-23 08:09:43 +00002041
2042 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002043 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2044 level = IS_LEVEL_1 | IS_LEVEL_2;
2045 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002046}
2047
2048ALIAS (no_lsp_gen_interval,
2049 no_lsp_gen_interval_arg_cmd,
2050 "no lsp-gen-interval <1-120>",
2051 NO_STR
2052 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002053 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002054
2055DEFUN (lsp_gen_interval_l1,
2056 lsp_gen_interval_l1_cmd,
2057 "lsp-gen-interval level-1 <1-120>",
2058 "Minimum interval between regenerating same LSP\n"
2059 "Set interval for level 1 only\n"
hassof390d2c2004-09-10 20:48:21 +00002060 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002061{
2062 struct isis_area *area;
2063 uint16_t interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002064 int level;
jardineb5d44e2003-12-23 08:09:43 +00002065
2066 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002067 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002068 level = IS_LEVEL_1;
2069 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002070}
2071
2072DEFUN (no_lsp_gen_interval_l1,
2073 no_lsp_gen_interval_l1_cmd,
2074 "no lsp-gen-interval level-1",
2075 NO_STR
2076 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002077 "Set interval for level 1 only\n")
jardineb5d44e2003-12-23 08:09:43 +00002078{
2079 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002080 uint16_t interval;
2081 int level;
jardineb5d44e2003-12-23 08:09:43 +00002082
2083 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002084 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2085 level = IS_LEVEL_1;
2086 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002087}
2088
2089ALIAS (no_lsp_gen_interval_l1,
2090 no_lsp_gen_interval_l1_arg_cmd,
2091 "no lsp-gen-interval level-1 <1-120>",
2092 NO_STR
2093 "Minimum interval between regenerating same LSP\n"
2094 "Set interval for level 1 only\n"
hassof390d2c2004-09-10 20:48:21 +00002095 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002096
2097DEFUN (lsp_gen_interval_l2,
2098 lsp_gen_interval_l2_cmd,
2099 "lsp-gen-interval level-2 <1-120>",
2100 "Minimum interval between regenerating same LSP\n"
2101 "Set interval for level 2 only\n"
hassof390d2c2004-09-10 20:48:21 +00002102 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002103{
2104 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002105 uint16_t interval;
2106 int level;
jardineb5d44e2003-12-23 08:09:43 +00002107
2108 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002109 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002110 level = IS_LEVEL_2;
2111 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002112}
2113
2114DEFUN (no_lsp_gen_interval_l2,
2115 no_lsp_gen_interval_l2_cmd,
2116 "no lsp-gen-interval level-2",
2117 NO_STR
2118 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002119 "Set interval for level 2 only\n")
jardineb5d44e2003-12-23 08:09:43 +00002120{
2121 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002122 uint16_t interval;
2123 int level;
jardineb5d44e2003-12-23 08:09:43 +00002124
2125 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002126 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2127 level = IS_LEVEL_2;
2128 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002129}
2130
2131ALIAS (no_lsp_gen_interval_l2,
2132 no_lsp_gen_interval_l2_arg_cmd,
2133 "no lsp-gen-interval level-2 <1-120>",
2134 NO_STR
2135 "Minimum interval between regenerating same LSP\n"
2136 "Set interval for level 2 only\n"
hassof390d2c2004-09-10 20:48:21 +00002137 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002138
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002139static int
2140validate_metric_style_narrow (struct vty *vty, struct isis_area *area)
2141{
2142 struct isis_circuit *circuit;
2143 struct listnode *node;
2144
2145 if (! vty)
2146 return CMD_ERR_AMBIGUOUS;
2147
2148 if (! area)
2149 {
2150 vty_out (vty, "ISIS area is invalid%s", VTY_NEWLINE);
2151 return CMD_ERR_AMBIGUOUS;
2152 }
2153
2154 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
2155 {
2156 if ((area->is_type & IS_LEVEL_1) &&
2157 (circuit->is_type & IS_LEVEL_1) &&
Christian Franke4fb7c842012-11-27 19:51:59 +00002158 (circuit->te_metric[0] > MAX_NARROW_LINK_METRIC))
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002159 {
2160 vty_out (vty, "ISIS circuit %s metric is invalid%s",
2161 circuit->interface->name, VTY_NEWLINE);
2162 return CMD_ERR_AMBIGUOUS;
2163 }
2164 if ((area->is_type & IS_LEVEL_2) &&
2165 (circuit->is_type & IS_LEVEL_2) &&
Christian Franke4fb7c842012-11-27 19:51:59 +00002166 (circuit->te_metric[1] > MAX_NARROW_LINK_METRIC))
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002167 {
2168 vty_out (vty, "ISIS circuit %s metric is invalid%s",
2169 circuit->interface->name, VTY_NEWLINE);
2170 return CMD_ERR_AMBIGUOUS;
2171 }
2172 }
2173
2174 return CMD_SUCCESS;
2175}
2176
jardineb5d44e2003-12-23 08:09:43 +00002177DEFUN (metric_style,
2178 metric_style_cmd,
hasso2984d262005-09-26 16:49:07 +00002179 "metric-style (narrow|transition|wide)",
jardineb5d44e2003-12-23 08:09:43 +00002180 "Use old-style (ISO 10589) or new-style packet formats\n"
2181 "Use old style of TLVs with narrow metric\n"
hasso2984d262005-09-26 16:49:07 +00002182 "Send and accept both styles of TLVs during transition\n"
jardineb5d44e2003-12-23 08:09:43 +00002183 "Use new style of TLVs to carry wider metric\n")
2184{
2185 struct isis_area *area;
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002186 int ret;
jardineb5d44e2003-12-23 08:09:43 +00002187
2188 area = vty->index;
2189 assert (area);
hasso2984d262005-09-26 16:49:07 +00002190
2191 if (strncmp (argv[0], "w", 1) == 0)
2192 {
2193 area->newmetric = 1;
2194 area->oldmetric = 0;
2195 }
Christian Franke478c1122012-11-27 19:52:00 +00002196 else
hasso2984d262005-09-26 16:49:07 +00002197 {
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002198 ret = validate_metric_style_narrow (vty, area);
2199 if (ret != CMD_SUCCESS)
2200 return ret;
2201
Christian Franke478c1122012-11-27 19:52:00 +00002202 if (strncmp (argv[0], "t", 1) == 0)
2203 {
2204 area->newmetric = 1;
2205 area->oldmetric = 1;
2206 }
2207 else if (strncmp (argv[0], "n", 1) == 0)
2208 {
2209 area->newmetric = 0;
2210 area->oldmetric = 1;
2211 }
hasso2984d262005-09-26 16:49:07 +00002212 }
jardineb5d44e2003-12-23 08:09:43 +00002213
2214 return CMD_SUCCESS;
2215}
2216
2217DEFUN (no_metric_style,
2218 no_metric_style_cmd,
hasso2984d262005-09-26 16:49:07 +00002219 "no metric-style",
jardineb5d44e2003-12-23 08:09:43 +00002220 NO_STR
hasso2984d262005-09-26 16:49:07 +00002221 "Use old-style (ISO 10589) or new-style packet formats\n")
jardineb5d44e2003-12-23 08:09:43 +00002222{
2223 struct isis_area *area;
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002224 int ret;
jardineb5d44e2003-12-23 08:09:43 +00002225
2226 area = vty->index;
2227 assert (area);
2228
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002229 ret = validate_metric_style_narrow (vty, area);
2230 if (ret != CMD_SUCCESS)
2231 return ret;
2232
hasso2984d262005-09-26 16:49:07 +00002233 /* Default is narrow metric. */
2234 area->newmetric = 0;
2235 area->oldmetric = 1;
jardineb5d44e2003-12-23 08:09:43 +00002236
2237 return CMD_SUCCESS;
2238}
2239
Josh Bailey3f045a02012-03-24 08:35:20 -07002240DEFUN (set_overload_bit,
2241 set_overload_bit_cmd,
2242 "set-overload-bit",
2243 "Set overload bit to avoid any transit traffic\n"
2244 "Set overload bit\n")
2245{
2246 struct isis_area *area;
2247
2248 area = vty->index;
2249 assert (area);
2250
2251 area->overload_bit = LSPBIT_OL;
2252 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2253
2254 return CMD_SUCCESS;
2255}
2256
2257DEFUN (no_set_overload_bit,
2258 no_set_overload_bit_cmd,
2259 "no set-overload-bit",
2260 "Reset overload bit to accept transit traffic\n"
2261 "Reset overload bit\n")
2262{
2263 struct isis_area *area;
2264
2265 area = vty->index;
2266 assert (area);
2267
2268 area->overload_bit = 0;
2269 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2270
2271 return CMD_SUCCESS;
2272}
2273
Amritha Nambiarc8ee9402015-08-24 16:40:14 -07002274DEFUN (set_attached_bit,
2275 set_attached_bit_cmd,
2276 "set-attached-bit",
2277 "Set attached bit to identify as L1/L2 router for inter-area traffic\n"
2278 "Set attached bit\n")
2279{
2280 struct isis_area *area;
2281
2282 area = vty->index;
2283 assert (area);
2284
2285 area->attached_bit = LSPBIT_ATT;
2286 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2287
2288 return CMD_SUCCESS;
2289}
2290
2291DEFUN (no_set_attached_bit,
2292 no_set_attached_bit_cmd,
2293 "no set-attached-bit",
2294 "Reset attached bit\n")
2295{
2296 struct isis_area *area;
2297
2298 area = vty->index;
2299 assert (area);
2300
2301 area->attached_bit = 0;
2302 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2303
2304 return CMD_SUCCESS;
2305}
2306
jardineb5d44e2003-12-23 08:09:43 +00002307DEFUN (dynamic_hostname,
2308 dynamic_hostname_cmd,
2309 "hostname dynamic",
2310 "Dynamic hostname for IS-IS\n"
hassof390d2c2004-09-10 20:48:21 +00002311 "Dynamic hostname\n")
jardineb5d44e2003-12-23 08:09:43 +00002312{
2313 struct isis_area *area;
2314
2315 area = vty->index;
2316 assert (area);
hassof390d2c2004-09-10 20:48:21 +00002317
Josh Bailey3f045a02012-03-24 08:35:20 -07002318 if (!area->dynhostname)
2319 {
2320 area->dynhostname = 1;
2321 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
2322 }
hassof390d2c2004-09-10 20:48:21 +00002323
jardineb5d44e2003-12-23 08:09:43 +00002324 return CMD_SUCCESS;
2325}
2326
2327DEFUN (no_dynamic_hostname,
2328 no_dynamic_hostname_cmd,
2329 "no hostname dynamic",
2330 NO_STR
2331 "Dynamic hostname for IS-IS\n"
hassof390d2c2004-09-10 20:48:21 +00002332 "Dynamic hostname\n")
jardineb5d44e2003-12-23 08:09:43 +00002333{
2334 struct isis_area *area;
2335
2336 area = vty->index;
2337 assert (area);
hassof390d2c2004-09-10 20:48:21 +00002338
Josh Bailey3f045a02012-03-24 08:35:20 -07002339 if (area->dynhostname)
2340 {
2341 area->dynhostname = 0;
2342 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
2343 }
hassof390d2c2004-09-10 20:48:21 +00002344
jardineb5d44e2003-12-23 08:09:43 +00002345 return CMD_SUCCESS;
2346}
2347
2348DEFUN (spf_interval,
2349 spf_interval_cmd,
2350 "spf-interval <1-120>",
hasso2097cd82003-12-23 11:51:08 +00002351 "Minimum interval between SPF calculations\n"
jardineb5d44e2003-12-23 08:09:43 +00002352 "Minimum interval between consecutive SPFs in seconds\n")
2353{
2354 struct isis_area *area;
2355 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002356
jardineb5d44e2003-12-23 08:09:43 +00002357 area = vty->index;
2358 interval = atoi (argv[0]);
2359 area->min_spf_interval[0] = interval;
2360 area->min_spf_interval[1] = interval;
hassof390d2c2004-09-10 20:48:21 +00002361
jardineb5d44e2003-12-23 08:09:43 +00002362 return CMD_SUCCESS;
2363}
2364
2365DEFUN (no_spf_interval,
2366 no_spf_interval_cmd,
2367 "no spf-interval",
2368 NO_STR
hassof390d2c2004-09-10 20:48:21 +00002369 "Minimum interval between SPF calculations\n")
jardineb5d44e2003-12-23 08:09:43 +00002370{
2371 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002372
jardineb5d44e2003-12-23 08:09:43 +00002373 area = vty->index;
2374
2375 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
2376 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002377
jardineb5d44e2003-12-23 08:09:43 +00002378 return CMD_SUCCESS;
2379}
2380
2381ALIAS (no_spf_interval,
2382 no_spf_interval_arg_cmd,
2383 "no spf-interval <1-120>",
2384 NO_STR
2385 "Minimum interval between SPF calculations\n"
hassof390d2c2004-09-10 20:48:21 +00002386 "Minimum interval between consecutive SPFs in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002387
2388DEFUN (spf_interval_l1,
2389 spf_interval_l1_cmd,
2390 "spf-interval level-1 <1-120>",
2391 "Minimum interval between SPF calculations\n"
2392 "Set interval for level 1 only\n"
2393 "Minimum interval between consecutive SPFs in seconds\n")
2394{
2395 struct isis_area *area;
2396 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002397
jardineb5d44e2003-12-23 08:09:43 +00002398 area = vty->index;
2399 interval = atoi (argv[0]);
2400 area->min_spf_interval[0] = interval;
hassof390d2c2004-09-10 20:48:21 +00002401
jardineb5d44e2003-12-23 08:09:43 +00002402 return CMD_SUCCESS;
2403}
2404
2405DEFUN (no_spf_interval_l1,
2406 no_spf_interval_l1_cmd,
2407 "no spf-interval level-1",
2408 NO_STR
2409 "Minimum interval between SPF calculations\n"
2410 "Set interval for level 1 only\n")
2411{
2412 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002413
jardineb5d44e2003-12-23 08:09:43 +00002414 area = vty->index;
2415
2416 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002417
jardineb5d44e2003-12-23 08:09:43 +00002418 return CMD_SUCCESS;
2419}
2420
2421ALIAS (no_spf_interval,
2422 no_spf_interval_l1_arg_cmd,
2423 "no spf-interval level-1 <1-120>",
2424 NO_STR
2425 "Minimum interval between SPF calculations\n"
2426 "Set interval for level 1 only\n"
2427 "Minimum interval between consecutive SPFs in seconds\n")
2428
2429DEFUN (spf_interval_l2,
2430 spf_interval_l2_cmd,
2431 "spf-interval level-2 <1-120>",
2432 "Minimum interval between SPF calculations\n"
2433 "Set interval for level 2 only\n"
2434 "Minimum interval between consecutive SPFs in seconds\n")
2435{
2436 struct isis_area *area;
2437 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002438
jardineb5d44e2003-12-23 08:09:43 +00002439 area = vty->index;
2440 interval = atoi (argv[0]);
2441 area->min_spf_interval[1] = interval;
hassof390d2c2004-09-10 20:48:21 +00002442
jardineb5d44e2003-12-23 08:09:43 +00002443 return CMD_SUCCESS;
2444}
2445
2446DEFUN (no_spf_interval_l2,
2447 no_spf_interval_l2_cmd,
2448 "no spf-interval level-2",
2449 NO_STR
2450 "Minimum interval between SPF calculations\n"
2451 "Set interval for level 2 only\n")
2452{
2453 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002454
jardineb5d44e2003-12-23 08:09:43 +00002455 area = vty->index;
2456
2457 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002458
jardineb5d44e2003-12-23 08:09:43 +00002459 return CMD_SUCCESS;
2460}
2461
2462ALIAS (no_spf_interval,
2463 no_spf_interval_l2_arg_cmd,
2464 "no spf-interval level-2 <1-120>",
2465 NO_STR
2466 "Minimum interval between SPF calculations\n"
2467 "Set interval for level 2 only\n"
2468 "Minimum interval between consecutive SPFs in seconds\n")
2469
Josh Bailey3f045a02012-03-24 08:35:20 -07002470static int
2471set_lsp_max_lifetime (struct vty *vty, struct isis_area *area,
2472 uint16_t interval, int level)
2473{
2474 int lvl;
2475 int set_refresh_interval[ISIS_LEVELS] = {0, 0};
2476 uint16_t refresh_interval;
2477
2478 refresh_interval = interval - 300;
2479
2480 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
2481 {
2482 if (!(lvl & level))
2483 continue;
2484 if (refresh_interval < area->lsp_refresh[lvl-1])
2485 {
2486 vty_out (vty, "Level %d Max LSP lifetime %us must be 300s greater than "
2487 "the configured LSP refresh interval %us%s",
2488 lvl, interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
2489 vty_out (vty, "Automatically reducing level %d LSP refresh interval "
2490 "to %us%s", lvl, refresh_interval, VTY_NEWLINE);
2491 set_refresh_interval[lvl-1] = 1;
2492
2493 if (refresh_interval <= area->lsp_gen_interval[lvl-1])
2494 {
2495 vty_out (vty, "LSP refresh interval %us must be greater than "
2496 "the configured LSP gen interval %us%s",
2497 refresh_interval, area->lsp_gen_interval[lvl-1],
2498 VTY_NEWLINE);
2499 return CMD_ERR_AMBIGUOUS;
2500 }
2501 }
2502 }
2503
2504 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
2505 {
2506 if (!(lvl & level))
2507 continue;
2508 area->max_lsp_lifetime[lvl-1] = interval;
2509 /* Automatically reducing lsp_refresh_interval to interval - 300 */
2510 if (set_refresh_interval[lvl-1])
2511 area->lsp_refresh[lvl-1] = refresh_interval;
2512 }
2513
2514 lsp_regenerate_schedule (area, level, 1);
2515
2516 return CMD_SUCCESS;
2517}
2518
2519DEFUN (max_lsp_lifetime,
2520 max_lsp_lifetime_cmd,
2521 "max-lsp-lifetime <350-65535>",
2522 "Maximum LSP lifetime\n"
2523 "LSP lifetime in seconds\n")
2524{
2525 struct isis_area *area;
2526 uint16_t interval;
2527 int level;
2528
2529 area = vty->index;
2530 interval = atoi (argv[0]);
2531 level = IS_LEVEL_1 | IS_LEVEL_2;
2532 return set_lsp_max_lifetime (vty, area, interval, level);
2533}
2534
2535DEFUN (no_max_lsp_lifetime,
2536 no_max_lsp_lifetime_cmd,
2537 "no max-lsp-lifetime",
2538 NO_STR
2539 "LSP lifetime in seconds\n")
2540{
2541 struct isis_area *area;
2542 uint16_t interval;
2543 int level;
2544
2545 area = vty->index;
2546 interval = DEFAULT_LSP_LIFETIME;
2547 level = IS_LEVEL_1 | IS_LEVEL_2;
2548 return set_lsp_max_lifetime (vty, area, interval, level);
2549}
2550
2551ALIAS (no_max_lsp_lifetime,
2552 no_max_lsp_lifetime_arg_cmd,
2553 "no max-lsp-lifetime <350-65535>",
2554 NO_STR
2555 "Maximum LSP lifetime\n"
2556 "LSP lifetime in seconds\n")
2557
2558DEFUN (max_lsp_lifetime_l1,
2559 max_lsp_lifetime_l1_cmd,
2560 "max-lsp-lifetime level-1 <350-65535>",
2561 "Maximum LSP lifetime for Level 1 only\n"
2562 "LSP lifetime for Level 1 only in seconds\n")
2563{
2564 struct isis_area *area;
2565 uint16_t interval;
2566 int level;
2567
2568 area = vty->index;
2569 interval = atoi (argv[0]);
2570 level = IS_LEVEL_1;
2571 return set_lsp_max_lifetime (vty, area, interval, level);
2572}
2573
2574DEFUN (no_max_lsp_lifetime_l1,
2575 no_max_lsp_lifetime_l1_cmd,
2576 "no max-lsp-lifetime level-1",
2577 NO_STR
2578 "LSP lifetime for Level 1 only in seconds\n")
2579{
2580 struct isis_area *area;
2581 uint16_t interval;
2582 int level;
2583
2584 area = vty->index;
2585 interval = DEFAULT_LSP_LIFETIME;
2586 level = IS_LEVEL_1;
2587 return set_lsp_max_lifetime (vty, area, interval, level);
2588}
2589
2590ALIAS (no_max_lsp_lifetime_l1,
2591 no_max_lsp_lifetime_l1_arg_cmd,
2592 "no max-lsp-lifetime level-1 <350-65535>",
2593 NO_STR
2594 "Maximum LSP lifetime for Level 1 only\n"
2595 "LSP lifetime for Level 1 only in seconds\n")
2596
2597DEFUN (max_lsp_lifetime_l2,
2598 max_lsp_lifetime_l2_cmd,
2599 "max-lsp-lifetime level-2 <350-65535>",
2600 "Maximum LSP lifetime for Level 2 only\n"
2601 "LSP lifetime for Level 2 only in seconds\n")
2602{
2603 struct isis_area *area;
2604 uint16_t interval;
2605 int level;
2606
2607 area = vty->index;
2608 interval = atoi (argv[0]);
2609 level = IS_LEVEL_2;
2610 return set_lsp_max_lifetime (vty, area, interval, level);
2611}
2612
2613DEFUN (no_max_lsp_lifetime_l2,
2614 no_max_lsp_lifetime_l2_cmd,
2615 "no max-lsp-lifetime level-2",
2616 NO_STR
2617 "LSP lifetime for Level 2 only in seconds\n")
2618{
2619 struct isis_area *area;
2620 uint16_t interval;
2621 int level;
2622
2623 area = vty->index;
2624 interval = DEFAULT_LSP_LIFETIME;
2625 level = IS_LEVEL_2;
2626 return set_lsp_max_lifetime (vty, area, interval, level);
2627}
2628
2629ALIAS (no_max_lsp_lifetime_l2,
2630 no_max_lsp_lifetime_l2_arg_cmd,
2631 "no max-lsp-lifetime level-2 <350-65535>",
2632 NO_STR
2633 "Maximum LSP lifetime for Level 2 only\n"
2634 "LSP lifetime for Level 2 only in seconds\n")
2635
2636static int
2637set_lsp_refresh_interval (struct vty *vty, struct isis_area *area,
2638 uint16_t interval, int level)
2639{
2640 int lvl;
2641
2642 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2643 {
2644 if (!(lvl & level))
2645 continue;
2646 if (interval <= area->lsp_gen_interval[lvl-1])
2647 {
2648 vty_out (vty, "LSP refresh interval %us must be greater than "
2649 "the configured LSP gen interval %us%s",
2650 interval, area->lsp_gen_interval[lvl-1],
2651 VTY_NEWLINE);
2652 return CMD_ERR_AMBIGUOUS;
2653 }
2654 if (interval > (area->max_lsp_lifetime[lvl-1] - 300))
2655 {
2656 vty_out (vty, "LSP refresh interval %us must be less than "
2657 "the configured LSP lifetime %us less 300%s",
2658 interval, area->max_lsp_lifetime[lvl-1],
2659 VTY_NEWLINE);
2660 return CMD_ERR_AMBIGUOUS;
2661 }
2662 }
2663
2664 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2665 {
2666 if (!(lvl & level))
2667 continue;
2668 area->lsp_refresh[lvl-1] = interval;
2669 }
2670 lsp_regenerate_schedule (area, level, 1);
2671
2672 return CMD_SUCCESS;
2673}
2674
2675DEFUN (lsp_refresh_interval,
2676 lsp_refresh_interval_cmd,
2677 "lsp-refresh-interval <1-65235>",
2678 "LSP refresh interval\n"
2679 "LSP refresh interval in seconds\n")
2680{
2681 struct isis_area *area;
2682 uint16_t interval;
2683 int level;
2684
2685 area = vty->index;
2686 interval = atoi (argv[0]);
2687 level = IS_LEVEL_1 | IS_LEVEL_2;
2688 return set_lsp_refresh_interval (vty, area, interval, level);
2689}
2690
2691DEFUN (no_lsp_refresh_interval,
2692 no_lsp_refresh_interval_cmd,
2693 "no lsp-refresh-interval",
2694 NO_STR
2695 "LSP refresh interval in seconds\n")
2696{
2697 struct isis_area *area;
2698 uint16_t interval;
2699 int level;
2700
2701 area = vty->index;
2702 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2703 level = IS_LEVEL_1 | IS_LEVEL_2;
2704 return set_lsp_refresh_interval (vty, area, interval, level);
2705}
2706
2707ALIAS (no_lsp_refresh_interval,
2708 no_lsp_refresh_interval_arg_cmd,
2709 "no lsp-refresh-interval <1-65235>",
2710 NO_STR
2711 "LSP refresh interval\n"
2712 "LSP refresh interval in seconds\n")
2713
2714DEFUN (lsp_refresh_interval_l1,
2715 lsp_refresh_interval_l1_cmd,
2716 "lsp-refresh-interval level-1 <1-65235>",
2717 "LSP refresh interval for Level 1 only\n"
2718 "LSP refresh interval for Level 1 only in seconds\n")
2719{
2720 struct isis_area *area;
2721 uint16_t interval;
2722 int level;
2723
2724 area = vty->index;
2725 interval = atoi (argv[0]);
2726 level = IS_LEVEL_1;
2727 return set_lsp_refresh_interval (vty, area, interval, level);
2728}
2729
2730DEFUN (no_lsp_refresh_interval_l1,
2731 no_lsp_refresh_interval_l1_cmd,
2732 "no lsp-refresh-interval level-1",
2733 NO_STR
2734 "LSP refresh interval for Level 1 only in seconds\n")
2735{
2736 struct isis_area *area;
2737 uint16_t interval;
2738 int level;
2739
2740 area = vty->index;
2741 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2742 level = IS_LEVEL_1;
2743 return set_lsp_refresh_interval (vty, area, interval, level);
2744}
2745
2746ALIAS (no_lsp_refresh_interval_l1,
2747 no_lsp_refresh_interval_l1_arg_cmd,
2748 "no lsp-refresh-interval level-1 <1-65235>",
2749 NO_STR
2750 "LSP refresh interval for Level 1 only\n"
2751 "LSP refresh interval for Level 1 only in seconds\n")
2752
2753DEFUN (lsp_refresh_interval_l2,
2754 lsp_refresh_interval_l2_cmd,
2755 "lsp-refresh-interval level-2 <1-65235>",
2756 "LSP refresh interval for Level 2 only\n"
2757 "LSP refresh interval for Level 2 only in seconds\n")
2758{
2759 struct isis_area *area;
2760 uint16_t interval;
2761 int level;
2762
2763 area = vty->index;
2764 interval = atoi (argv[0]);
2765 level = IS_LEVEL_2;
2766 return set_lsp_refresh_interval (vty, area, interval, level);
2767}
2768
2769DEFUN (no_lsp_refresh_interval_l2,
2770 no_lsp_refresh_interval_l2_cmd,
2771 "no lsp-refresh-interval level-2",
2772 NO_STR
2773 "LSP refresh interval for Level 2 only in seconds\n")
2774{
2775 struct isis_area *area;
2776 uint16_t interval;
2777 int level;
2778
2779 area = vty->index;
2780 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2781 level = IS_LEVEL_2;
2782 return set_lsp_refresh_interval (vty, area, interval, level);
2783}
2784
2785ALIAS (no_lsp_refresh_interval_l2,
2786 no_lsp_refresh_interval_l2_arg_cmd,
2787 "no lsp-refresh-interval level-2 <1-65235>",
2788 NO_STR
2789 "LSP refresh interval for Level 2 only\n"
2790 "LSP refresh interval for Level 2 only in seconds\n")
2791
2792DEFUN (log_adj_changes,
2793 log_adj_changes_cmd,
2794 "log-adjacency-changes",
2795 "Log changes in adjacency state\n")
2796{
2797 struct isis_area *area;
2798
2799 area = vty->index;
2800 assert (area);
2801
2802 area->log_adj_changes = 1;
2803
2804 return CMD_SUCCESS;
2805}
2806
2807DEFUN (no_log_adj_changes,
2808 no_log_adj_changes_cmd,
2809 "no log-adjacency-changes",
2810 "Stop logging changes in adjacency state\n")
2811{
2812 struct isis_area *area;
2813
2814 area = vty->index;
2815 assert (area);
2816
2817 area->log_adj_changes = 0;
2818
2819 return CMD_SUCCESS;
2820}
2821
jardineb5d44e2003-12-23 08:09:43 +00002822#ifdef TOPOLOGY_GENERATE
Josh Bailey3f045a02012-03-24 08:35:20 -07002823
jardineb5d44e2003-12-23 08:09:43 +00002824DEFUN (topology_generate_grid,
2825 topology_generate_grid_cmd,
2826 "topology generate grid <1-100> <1-100> <1-65000> [param] [param] "
2827 "[param]",
hassof1082d12005-09-19 04:23:34 +00002828 "Topology generation for IS-IS\n"
2829 "Topology generation\n"
2830 "Grid topology\n"
jardineb5d44e2003-12-23 08:09:43 +00002831 "X parameter of the grid\n"
2832 "Y parameter of the grid\n"
2833 "Random seed\n"
2834 "Optional param 1\n"
2835 "Optional param 2\n"
2836 "Optional param 3\n"
2837 "Topology\n")
2838{
2839 struct isis_area *area;
2840
2841 area = vty->index;
2842 assert (area);
2843
hassof390d2c2004-09-10 20:48:21 +00002844 if (!spgrid_check_params (vty, argc, argv))
2845 {
2846 if (area->topology)
2847 list_delete (area->topology);
2848 area->topology = list_new ();
2849 memcpy (area->top_params, vty->buf, 200);
2850 gen_spgrid_topology (vty, area->topology);
2851 remove_topology_lsps (area);
2852 generate_topology_lsps (area);
hassof1082d12005-09-19 04:23:34 +00002853 /* Regenerate L1 LSP to get two way connection to the generated
2854 * topology. */
Josh Bailey3f045a02012-03-24 08:35:20 -07002855 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hassof390d2c2004-09-10 20:48:21 +00002856 }
jardineb5d44e2003-12-23 08:09:43 +00002857
2858 return CMD_SUCCESS;
2859}
2860
hassof695b012005-04-02 19:03:39 +00002861DEFUN (show_isis_generated_topology,
2862 show_isis_generated_topology_cmd,
hassof1082d12005-09-19 04:23:34 +00002863 "show isis generated-topologies",
jardineb5d44e2003-12-23 08:09:43 +00002864 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -07002865 "ISIS network information\n"
hassof1082d12005-09-19 04:23:34 +00002866 "Show generated topologies\n")
jardineb5d44e2003-12-23 08:09:43 +00002867{
2868 struct isis_area *area;
paul92c9f222005-05-25 12:21:13 +00002869 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +00002870 struct listnode *node2;
2871 struct arc *arc;
hassof1082d12005-09-19 04:23:34 +00002872
paul92c9f222005-05-25 12:21:13 +00002873 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof1082d12005-09-19 04:23:34 +00002874 {
2875 if (!area->topology)
2876 continue;
2877
2878 vty_out (vty, "Topology for isis area: %s%s", area->area_tag,
2879 VTY_NEWLINE);
2880 vty_out (vty, "From node To node Distance%s", VTY_NEWLINE);
2881
2882 for (ALL_LIST_ELEMENTS_RO (area->topology, node2, arc))
2883 vty_out (vty, "%9ld %11ld %12ld%s", arc->from_node, arc->to_node,
2884 arc->distance, VTY_NEWLINE);
2885 }
jardineb5d44e2003-12-23 08:09:43 +00002886 return CMD_SUCCESS;
2887}
2888
hassof1082d12005-09-19 04:23:34 +00002889/* Base IS for topology generation. */
hassof390d2c2004-09-10 20:48:21 +00002890DEFUN (topology_baseis,
jardineb5d44e2003-12-23 08:09:43 +00002891 topology_baseis_cmd,
2892 "topology base-is WORD",
hassof1082d12005-09-19 04:23:34 +00002893 "Topology generation for IS-IS\n"
2894 "A Network IS Base for this topology\n"
2895 "XXXX.XXXX.XXXX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00002896{
2897 struct isis_area *area;
2898 u_char buff[ISIS_SYS_ID_LEN];
2899
2900 area = vty->index;
2901 assert (area);
2902
hassof390d2c2004-09-10 20:48:21 +00002903 if (sysid2buff (buff, argv[0]))
hassof1082d12005-09-19 04:23:34 +00002904 sysid2buff (area->topology_baseis, argv[0]);
hassof390d2c2004-09-10 20:48:21 +00002905
jardineb5d44e2003-12-23 08:09:43 +00002906 return CMD_SUCCESS;
2907}
2908
jardineb5d44e2003-12-23 08:09:43 +00002909DEFUN (no_topology_baseis,
2910 no_topology_baseis_cmd,
2911 "no topology base-is WORD",
2912 NO_STR
hassof1082d12005-09-19 04:23:34 +00002913 "Topology generation for IS-IS\n"
2914 "A Network IS Base for this topology\n"
2915 "XXXX.XXXX.XXXX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00002916{
2917 struct isis_area *area;
2918
2919 area = vty->index;
2920 assert (area);
2921
hassof390d2c2004-09-10 20:48:21 +00002922 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
jardineb5d44e2003-12-23 08:09:43 +00002923 return CMD_SUCCESS;
2924}
2925
hassof1082d12005-09-19 04:23:34 +00002926ALIAS (no_topology_baseis,
2927 no_topology_baseis_noid_cmd,
2928 "no topology base-is",
2929 NO_STR
2930 "Topology generation for IS-IS\n"
2931 "A Network IS Base for this topology\n")
2932
2933DEFUN (topology_basedynh,
2934 topology_basedynh_cmd,
2935 "topology base-dynh WORD",
2936 "Topology generation for IS-IS\n"
2937 "Dynamic hostname base for this topology\n"
2938 "Dynamic hostname base\n")
2939{
2940 struct isis_area *area;
2941
2942 area = vty->index;
2943 assert (area);
2944
2945 /* I hope that it's enough. */
2946 area->topology_basedynh = strndup (argv[0], 16);
2947 return CMD_SUCCESS;
2948}
Josh Bailey3f045a02012-03-24 08:35:20 -07002949
jardineb5d44e2003-12-23 08:09:43 +00002950#endif /* TOPOLOGY_GENERATE */
2951
jardineb5d44e2003-12-23 08:09:43 +00002952/* IS-IS configuration write function */
2953int
2954isis_config_write (struct vty *vty)
2955{
2956 int write = 0;
jardineb5d44e2003-12-23 08:09:43 +00002957
hassof390d2c2004-09-10 20:48:21 +00002958 if (isis != NULL)
2959 {
2960 struct isis_area *area;
hasso3fdb2dd2005-09-28 18:45:54 +00002961 struct listnode *node, *node2;
jardineb5d44e2003-12-23 08:09:43 +00002962
hasso3fdb2dd2005-09-28 18:45:54 +00002963 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof390d2c2004-09-10 20:48:21 +00002964 {
2965 /* ISIS - Area name */
2966 vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
2967 write++;
2968 /* ISIS - Net */
2969 if (listcount (area->area_addrs) > 0)
2970 {
2971 struct area_addr *area_addr;
hasso3fdb2dd2005-09-28 18:45:54 +00002972 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
2973 {
2974 vty_out (vty, " net %s%s",
2975 isonet_print (area_addr->area_addr,
2976 area_addr->addr_len + ISIS_SYS_ID_LEN +
2977 1), VTY_NEWLINE);
2978 write++;
2979 }
hassof390d2c2004-09-10 20:48:21 +00002980 }
hasso3fdb2dd2005-09-28 18:45:54 +00002981 /* ISIS - Dynamic hostname - Defaults to true so only display if
2982 * false. */
hassof390d2c2004-09-10 20:48:21 +00002983 if (!area->dynhostname)
2984 {
2985 vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
2986 write++;
2987 }
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002988 /* ISIS - Metric-Style - when true displays wide */
2989 if (area->newmetric)
hassof390d2c2004-09-10 20:48:21 +00002990 {
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002991 if (!area->oldmetric)
2992 vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
hasso2984d262005-09-26 16:49:07 +00002993 else
2994 vty_out (vty, " metric-style transition%s", VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +00002995 write++;
2996 }
Christian Frankef818c8f2012-11-27 01:10:28 +00002997 else
2998 {
2999 vty_out (vty, " metric-style narrow%s", VTY_NEWLINE);
3000 write++;
3001 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003002 /* ISIS - overload-bit */
3003 if (area->overload_bit)
3004 {
3005 vty_out (vty, " set-overload-bit%s", VTY_NEWLINE);
3006 write++;
3007 }
hassof390d2c2004-09-10 20:48:21 +00003008 /* ISIS - Area is-type (level-1-2 is default) */
3009 if (area->is_type == IS_LEVEL_1)
3010 {
3011 vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
3012 write++;
3013 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003014 else if (area->is_type == IS_LEVEL_2)
hassof390d2c2004-09-10 20:48:21 +00003015 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003016 vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
3017 write++;
hassof390d2c2004-09-10 20:48:21 +00003018 }
3019 /* ISIS - Lsp generation interval */
3020 if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1])
3021 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003022 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00003023 {
3024 vty_out (vty, " lsp-gen-interval %d%s",
3025 area->lsp_gen_interval[0], VTY_NEWLINE);
3026 write++;
3027 }
3028 }
3029 else
3030 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003031 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00003032 {
3033 vty_out (vty, " lsp-gen-interval level-1 %d%s",
3034 area->lsp_gen_interval[0], VTY_NEWLINE);
3035 write++;
3036 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003037 if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00003038 {
3039 vty_out (vty, " lsp-gen-interval level-2 %d%s",
3040 area->lsp_gen_interval[1], VTY_NEWLINE);
3041 write++;
3042 }
3043 }
3044 /* ISIS - LSP lifetime */
3045 if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1])
3046 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003047 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00003048 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003049 vty_out (vty, " max-lsp-lifetime %u%s", area->max_lsp_lifetime[0],
hassof390d2c2004-09-10 20:48:21 +00003050 VTY_NEWLINE);
3051 write++;
3052 }
3053 }
3054 else
3055 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003056 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00003057 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003058 vty_out (vty, " max-lsp-lifetime level-1 %u%s",
hassof390d2c2004-09-10 20:48:21 +00003059 area->max_lsp_lifetime[0], VTY_NEWLINE);
3060 write++;
3061 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003062 if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00003063 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003064 vty_out (vty, " max-lsp-lifetime level-2 %u%s",
hassof390d2c2004-09-10 20:48:21 +00003065 area->max_lsp_lifetime[1], VTY_NEWLINE);
3066 write++;
3067 }
3068 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003069 /* ISIS - LSP refresh interval */
3070 if (area->lsp_refresh[0] == area->lsp_refresh[1])
3071 {
3072 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3073 {
3074 vty_out (vty, " lsp-refresh-interval %u%s", area->lsp_refresh[0],
3075 VTY_NEWLINE);
3076 write++;
3077 }
3078 }
3079 else
3080 {
3081 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3082 {
3083 vty_out (vty, " lsp-refresh-interval level-1 %u%s",
3084 area->lsp_refresh[0], VTY_NEWLINE);
3085 write++;
3086 }
3087 if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3088 {
3089 vty_out (vty, " lsp-refresh-interval level-2 %u%s",
3090 area->lsp_refresh[1], VTY_NEWLINE);
3091 write++;
3092 }
3093 }
Christian Frankef1fc1db2015-11-10 18:43:31 +01003094 if (area->lsp_mtu != DEFAULT_LSP_MTU)
3095 {
3096 vty_out(vty, " lsp-mtu %u%s", area->lsp_mtu, VTY_NEWLINE);
3097 write++;
3098 }
3099
hasso13fb40a2005-10-01 06:03:04 +00003100 /* Minimum SPF interval. */
3101 if (area->min_spf_interval[0] == area->min_spf_interval[1])
3102 {
3103 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
3104 {
3105 vty_out (vty, " spf-interval %d%s",
3106 area->min_spf_interval[0], VTY_NEWLINE);
3107 write++;
3108 }
3109 }
3110 else
3111 {
3112 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
3113 {
3114 vty_out (vty, " spf-interval level-1 %d%s",
3115 area->min_spf_interval[0], VTY_NEWLINE);
3116 write++;
3117 }
3118 if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL)
3119 {
3120 vty_out (vty, " spf-interval level-2 %d%s",
3121 area->min_spf_interval[1], VTY_NEWLINE);
3122 write++;
3123 }
3124 }
hasso53c997c2004-09-15 16:21:59 +00003125 /* Authentication passwords. */
Josh Bailey3f045a02012-03-24 08:35:20 -07003126 if (area->area_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
hasso53c997c2004-09-15 16:21:59 +00003127 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003128 vty_out(vty, " area-password md5 %s", area->area_passwd.passwd);
hasso1cbc5622005-01-01 10:29:51 +00003129 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
3130 {
3131 vty_out(vty, " authenticate snp ");
3132 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
3133 vty_out(vty, "validate");
3134 else
3135 vty_out(vty, "send-only");
3136 }
3137 vty_out(vty, "%s", VTY_NEWLINE);
hasso53c997c2004-09-15 16:21:59 +00003138 write++;
Josh Bailey3f045a02012-03-24 08:35:20 -07003139 }
3140 else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
3141 {
3142 vty_out(vty, " area-password clear %s", area->area_passwd.passwd);
3143 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
3144 {
3145 vty_out(vty, " authenticate snp ");
3146 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
3147 vty_out(vty, "validate");
3148 else
3149 vty_out(vty, "send-only");
3150 }
3151 vty_out(vty, "%s", VTY_NEWLINE);
3152 write++;
3153 }
3154 if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
hasso53c997c2004-09-15 16:21:59 +00003155 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003156 vty_out(vty, " domain-password md5 %s",
3157 area->domain_passwd.passwd);
3158 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3159 {
3160 vty_out(vty, " authenticate snp ");
3161 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3162 vty_out(vty, "validate");
3163 else
3164 vty_out(vty, "send-only");
3165 }
3166 vty_out(vty, "%s", VTY_NEWLINE);
3167 write++;
3168 }
3169 else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
3170 {
3171 vty_out(vty, " domain-password clear %s",
3172 area->domain_passwd.passwd);
hasso1cbc5622005-01-01 10:29:51 +00003173 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3174 {
3175 vty_out(vty, " authenticate snp ");
3176 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3177 vty_out(vty, "validate");
3178 else
3179 vty_out(vty, "send-only");
3180 }
3181 vty_out(vty, "%s", VTY_NEWLINE);
hasso53c997c2004-09-15 16:21:59 +00003182 write++;
3183 }
hassof1082d12005-09-19 04:23:34 +00003184
Josh Bailey3f045a02012-03-24 08:35:20 -07003185 if (area->log_adj_changes)
3186 {
3187 vty_out (vty, " log-adjacency-changes%s", VTY_NEWLINE);
3188 write++;
3189 }
3190
hassof390d2c2004-09-10 20:48:21 +00003191#ifdef TOPOLOGY_GENERATE
hassof1082d12005-09-19 04:23:34 +00003192 if (memcmp (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS,
3193 ISIS_SYS_ID_LEN))
3194 {
3195 vty_out (vty, " topology base-is %s%s",
Josh Bailey3f045a02012-03-24 08:35:20 -07003196 sysid_print ((u_char *)area->topology_baseis), VTY_NEWLINE);
hassof1082d12005-09-19 04:23:34 +00003197 write++;
3198 }
3199 if (area->topology_basedynh)
3200 {
3201 vty_out (vty, " topology base-dynh %s%s",
3202 area->topology_basedynh, VTY_NEWLINE);
3203 write++;
3204 }
3205 /* We save the whole command line here. */
3206 if (strlen(area->top_params))
hassof390d2c2004-09-10 20:48:21 +00003207 {
3208 vty_out (vty, " %s%s", area->top_params, VTY_NEWLINE);
3209 write++;
3210 }
hassof390d2c2004-09-10 20:48:21 +00003211#endif /* TOPOLOGY_GENERATE */
hassof1082d12005-09-19 04:23:34 +00003212
hassof390d2c2004-09-10 20:48:21 +00003213 }
jardineb5d44e2003-12-23 08:09:43 +00003214 }
hassof390d2c2004-09-10 20:48:21 +00003215
jardineb5d44e2003-12-23 08:09:43 +00003216 return write;
3217}
3218
Josh Bailey3f045a02012-03-24 08:35:20 -07003219struct cmd_node isis_node = {
jardineb5d44e2003-12-23 08:09:43 +00003220 ISIS_NODE,
hasso2097cd82003-12-23 11:51:08 +00003221 "%s(config-router)# ",
jardineb5d44e2003-12-23 08:09:43 +00003222 1
3223};
3224
hassof390d2c2004-09-10 20:48:21 +00003225void
jardineb5d44e2003-12-23 08:09:43 +00003226isis_init ()
3227{
jardineb5d44e2003-12-23 08:09:43 +00003228 /* Install IS-IS top node */
3229 install_node (&isis_node, isis_config_write);
hassof390d2c2004-09-10 20:48:21 +00003230
Josh Bailey3f045a02012-03-24 08:35:20 -07003231 install_element (VIEW_NODE, &show_isis_summary_cmd);
3232
3233 install_element (VIEW_NODE, &show_isis_interface_cmd);
3234 install_element (VIEW_NODE, &show_isis_interface_detail_cmd);
3235 install_element (VIEW_NODE, &show_isis_interface_arg_cmd);
3236
3237 install_element (VIEW_NODE, &show_isis_neighbor_cmd);
3238 install_element (VIEW_NODE, &show_isis_neighbor_detail_cmd);
3239 install_element (VIEW_NODE, &show_isis_neighbor_arg_cmd);
3240 install_element (VIEW_NODE, &clear_isis_neighbor_cmd);
3241 install_element (VIEW_NODE, &clear_isis_neighbor_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003242
3243 install_element (VIEW_NODE, &show_hostname_cmd);
3244 install_element (VIEW_NODE, &show_database_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003245 install_element (VIEW_NODE, &show_database_arg_cmd);
3246 install_element (VIEW_NODE, &show_database_arg_detail_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003247 install_element (VIEW_NODE, &show_database_detail_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003248 install_element (VIEW_NODE, &show_database_detail_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003249
Josh Bailey3f045a02012-03-24 08:35:20 -07003250 install_element (ENABLE_NODE, &show_isis_summary_cmd);
3251
3252 install_element (ENABLE_NODE, &show_isis_interface_cmd);
3253 install_element (ENABLE_NODE, &show_isis_interface_detail_cmd);
3254 install_element (ENABLE_NODE, &show_isis_interface_arg_cmd);
3255
3256 install_element (ENABLE_NODE, &show_isis_neighbor_cmd);
3257 install_element (ENABLE_NODE, &show_isis_neighbor_detail_cmd);
3258 install_element (ENABLE_NODE, &show_isis_neighbor_arg_cmd);
3259 install_element (ENABLE_NODE, &clear_isis_neighbor_cmd);
3260 install_element (ENABLE_NODE, &clear_isis_neighbor_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003261
3262 install_element (ENABLE_NODE, &show_hostname_cmd);
3263 install_element (ENABLE_NODE, &show_database_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003264 install_element (ENABLE_NODE, &show_database_arg_cmd);
3265 install_element (ENABLE_NODE, &show_database_arg_detail_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003266 install_element (ENABLE_NODE, &show_database_detail_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003267 install_element (ENABLE_NODE, &show_database_detail_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003268 install_element (ENABLE_NODE, &show_debugging_cmd);
3269
hassof390d2c2004-09-10 20:48:21 +00003270 install_node (&debug_node, config_write_debug);
jardin9e867fe2003-12-23 08:56:18 +00003271
jardineb5d44e2003-12-23 08:09:43 +00003272 install_element (ENABLE_NODE, &debug_isis_adj_cmd);
3273 install_element (ENABLE_NODE, &no_debug_isis_adj_cmd);
3274 install_element (ENABLE_NODE, &debug_isis_csum_cmd);
3275 install_element (ENABLE_NODE, &no_debug_isis_csum_cmd);
3276 install_element (ENABLE_NODE, &debug_isis_lupd_cmd);
3277 install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd);
3278 install_element (ENABLE_NODE, &debug_isis_err_cmd);
3279 install_element (ENABLE_NODE, &no_debug_isis_err_cmd);
3280 install_element (ENABLE_NODE, &debug_isis_snp_cmd);
3281 install_element (ENABLE_NODE, &no_debug_isis_snp_cmd);
3282 install_element (ENABLE_NODE, &debug_isis_upd_cmd);
3283 install_element (ENABLE_NODE, &no_debug_isis_upd_cmd);
3284 install_element (ENABLE_NODE, &debug_isis_spfevents_cmd);
3285 install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd);
3286 install_element (ENABLE_NODE, &debug_isis_spfstats_cmd);
3287 install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd);
3288 install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd);
3289 install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd);
3290 install_element (ENABLE_NODE, &debug_isis_rtevents_cmd);
3291 install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd);
3292 install_element (ENABLE_NODE, &debug_isis_events_cmd);
3293 install_element (ENABLE_NODE, &no_debug_isis_events_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003294 install_element (ENABLE_NODE, &debug_isis_packet_dump_cmd);
3295 install_element (ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
Christian Franke80a8f722015-11-12 14:21:47 +01003296 install_element (ENABLE_NODE, &debug_isis_lsp_gen_cmd);
3297 install_element (ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003298
jardin9e867fe2003-12-23 08:56:18 +00003299 install_element (CONFIG_NODE, &debug_isis_adj_cmd);
3300 install_element (CONFIG_NODE, &no_debug_isis_adj_cmd);
3301 install_element (CONFIG_NODE, &debug_isis_csum_cmd);
3302 install_element (CONFIG_NODE, &no_debug_isis_csum_cmd);
3303 install_element (CONFIG_NODE, &debug_isis_lupd_cmd);
3304 install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd);
3305 install_element (CONFIG_NODE, &debug_isis_err_cmd);
3306 install_element (CONFIG_NODE, &no_debug_isis_err_cmd);
3307 install_element (CONFIG_NODE, &debug_isis_snp_cmd);
3308 install_element (CONFIG_NODE, &no_debug_isis_snp_cmd);
3309 install_element (CONFIG_NODE, &debug_isis_upd_cmd);
3310 install_element (CONFIG_NODE, &no_debug_isis_upd_cmd);
3311 install_element (CONFIG_NODE, &debug_isis_spfevents_cmd);
3312 install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd);
3313 install_element (CONFIG_NODE, &debug_isis_spfstats_cmd);
3314 install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd);
3315 install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd);
3316 install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd);
3317 install_element (CONFIG_NODE, &debug_isis_rtevents_cmd);
3318 install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd);
3319 install_element (CONFIG_NODE, &debug_isis_events_cmd);
3320 install_element (CONFIG_NODE, &no_debug_isis_events_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003321 install_element (CONFIG_NODE, &debug_isis_packet_dump_cmd);
3322 install_element (CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
Christian Franke80a8f722015-11-12 14:21:47 +01003323 install_element (CONFIG_NODE, &debug_isis_lsp_gen_cmd);
3324 install_element (CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
jardin9e867fe2003-12-23 08:56:18 +00003325
jardineb5d44e2003-12-23 08:09:43 +00003326 install_element (CONFIG_NODE, &router_isis_cmd);
3327 install_element (CONFIG_NODE, &no_router_isis_cmd);
3328
3329 install_default (ISIS_NODE);
3330
3331 install_element (ISIS_NODE, &net_cmd);
3332 install_element (ISIS_NODE, &no_net_cmd);
3333
3334 install_element (ISIS_NODE, &is_type_cmd);
3335 install_element (ISIS_NODE, &no_is_type_cmd);
3336
Christian Frankef1fc1db2015-11-10 18:43:31 +01003337 install_element (ISIS_NODE, &area_lsp_mtu_cmd);
3338 install_element (ISIS_NODE, &no_area_lsp_mtu_cmd);
3339 install_element (ISIS_NODE, &no_area_lsp_mtu_arg_cmd);
3340
Josh Bailey3f045a02012-03-24 08:35:20 -07003341 install_element (ISIS_NODE, &area_passwd_md5_cmd);
3342 install_element (ISIS_NODE, &area_passwd_md5_snpauth_cmd);
3343 install_element (ISIS_NODE, &area_passwd_clear_cmd);
3344 install_element (ISIS_NODE, &area_passwd_clear_snpauth_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003345 install_element (ISIS_NODE, &no_area_passwd_cmd);
3346
Josh Bailey3f045a02012-03-24 08:35:20 -07003347 install_element (ISIS_NODE, &domain_passwd_md5_cmd);
3348 install_element (ISIS_NODE, &domain_passwd_md5_snpauth_cmd);
3349 install_element (ISIS_NODE, &domain_passwd_clear_cmd);
3350 install_element (ISIS_NODE, &domain_passwd_clear_snpauth_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003351 install_element (ISIS_NODE, &no_domain_passwd_cmd);
3352
3353 install_element (ISIS_NODE, &lsp_gen_interval_cmd);
3354 install_element (ISIS_NODE, &no_lsp_gen_interval_cmd);
3355 install_element (ISIS_NODE, &no_lsp_gen_interval_arg_cmd);
3356 install_element (ISIS_NODE, &lsp_gen_interval_l1_cmd);
3357 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_cmd);
3358 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_arg_cmd);
3359 install_element (ISIS_NODE, &lsp_gen_interval_l2_cmd);
3360 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_cmd);
3361 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_arg_cmd);
3362
3363 install_element (ISIS_NODE, &spf_interval_cmd);
3364 install_element (ISIS_NODE, &no_spf_interval_cmd);
3365 install_element (ISIS_NODE, &no_spf_interval_arg_cmd);
3366 install_element (ISIS_NODE, &spf_interval_l1_cmd);
3367 install_element (ISIS_NODE, &no_spf_interval_l1_cmd);
3368 install_element (ISIS_NODE, &no_spf_interval_l1_arg_cmd);
3369 install_element (ISIS_NODE, &spf_interval_l2_cmd);
3370 install_element (ISIS_NODE, &no_spf_interval_l2_cmd);
3371 install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd);
hassof390d2c2004-09-10 20:48:21 +00003372
Josh Bailey3f045a02012-03-24 08:35:20 -07003373 install_element (ISIS_NODE, &max_lsp_lifetime_cmd);
3374 install_element (ISIS_NODE, &no_max_lsp_lifetime_cmd);
3375 install_element (ISIS_NODE, &no_max_lsp_lifetime_arg_cmd);
3376 install_element (ISIS_NODE, &max_lsp_lifetime_l1_cmd);
3377 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_cmd);
3378 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_arg_cmd);
3379 install_element (ISIS_NODE, &max_lsp_lifetime_l2_cmd);
3380 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_cmd);
3381 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_arg_cmd);
3382
3383 install_element (ISIS_NODE, &lsp_refresh_interval_cmd);
3384 install_element (ISIS_NODE, &no_lsp_refresh_interval_cmd);
3385 install_element (ISIS_NODE, &no_lsp_refresh_interval_arg_cmd);
3386 install_element (ISIS_NODE, &lsp_refresh_interval_l1_cmd);
3387 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_cmd);
3388 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_arg_cmd);
3389 install_element (ISIS_NODE, &lsp_refresh_interval_l2_cmd);
3390 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_cmd);
3391 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_arg_cmd);
3392
3393 install_element (ISIS_NODE, &set_overload_bit_cmd);
3394 install_element (ISIS_NODE, &no_set_overload_bit_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003395
Amritha Nambiarc8ee9402015-08-24 16:40:14 -07003396 install_element (ISIS_NODE, &set_attached_bit_cmd);
3397 install_element (ISIS_NODE, &no_set_attached_bit_cmd);
3398
jardineb5d44e2003-12-23 08:09:43 +00003399 install_element (ISIS_NODE, &dynamic_hostname_cmd);
3400 install_element (ISIS_NODE, &no_dynamic_hostname_cmd);
3401
3402 install_element (ISIS_NODE, &metric_style_cmd);
3403 install_element (ISIS_NODE, &no_metric_style_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003404
3405 install_element (ISIS_NODE, &log_adj_changes_cmd);
3406 install_element (ISIS_NODE, &no_log_adj_changes_cmd);
3407
jardineb5d44e2003-12-23 08:09:43 +00003408#ifdef TOPOLOGY_GENERATE
3409 install_element (ISIS_NODE, &topology_generate_grid_cmd);
3410 install_element (ISIS_NODE, &topology_baseis_cmd);
hassof1082d12005-09-19 04:23:34 +00003411 install_element (ISIS_NODE, &topology_basedynh_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003412 install_element (ISIS_NODE, &no_topology_baseis_cmd);
hassof1082d12005-09-19 04:23:34 +00003413 install_element (ISIS_NODE, &no_topology_baseis_noid_cmd);
hassof695b012005-04-02 19:03:39 +00003414 install_element (VIEW_NODE, &show_isis_generated_topology_cmd);
3415 install_element (ENABLE_NODE, &show_isis_generated_topology_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003416#endif /* TOPOLOGY_GENERATE */
jardineb5d44e2003-12-23 08:09:43 +00003417}