blob: 130e75236ee445afb3138ac390dc74714bfa16b3 [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"
Olivier Dugeon4f593572016-04-19 19:03:05 +020057#include "isisd/isis_te.h"
jardineb5d44e2003-12-23 08:09:43 +000058
59#ifdef TOPOLOGY_GENERATE
60#include "spgrid.h"
hassof390d2c2004-09-10 20:48:21 +000061u_char DEFAULT_TOPOLOGY_BASEIS[6] = { 0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00 };
jardineb5d44e2003-12-23 08:09:43 +000062#endif /* TOPOLOGY_GENERATE */
63
jardineb5d44e2003-12-23 08:09:43 +000064struct isis *isis = NULL;
jardineb5d44e2003-12-23 08:09:43 +000065
Paul Jakma41b36e92006-12-08 01:09:50 +000066/*
67 * Prototypes.
68 */
Paul Jakma41b36e92006-12-08 01:09:50 +000069int isis_area_get(struct vty *, const char *);
70int isis_area_destroy(struct vty *, const char *);
Josh Bailey3f045a02012-03-24 08:35:20 -070071int area_net_title(struct vty *, const char *);
72int area_clear_net_title(struct vty *, const char *);
73int show_isis_interface_common(struct vty *, const char *ifname, char);
74int show_isis_neighbor_common(struct vty *, const char *id, char);
75int clear_isis_neighbor_common(struct vty *, const char *id);
Paul Jakma41b36e92006-12-08 01:09:50 +000076int isis_config_write(struct vty *);
77
78
79
jardineb5d44e2003-12-23 08:09:43 +000080void
81isis_new (unsigned long process_id)
82{
hassoaac372f2005-09-01 17:52:33 +000083 isis = XCALLOC (MTYPE_ISIS, sizeof (struct isis));
jardineb5d44e2003-12-23 08:09:43 +000084 /*
85 * Default values
86 */
87 isis->max_area_addrs = 3;
jardineb5d44e2003-12-23 08:09:43 +000088 isis->process_id = process_id;
Josh Bailey3f045a02012-03-24 08:35:20 -070089 isis->router_id = 0;
jardineb5d44e2003-12-23 08:09:43 +000090 isis->area_list = list_new ();
91 isis->init_circ_list = list_new ();
92 isis->uptime = time (NULL);
93 isis->nexthops = list_new ();
94#ifdef HAVE_IPV6
95 isis->nexthops6 = list_new ();
96#endif /* HAVE_IPV6 */
Josh Bailey3f045a02012-03-24 08:35:20 -070097 dyn_cache_init ();
jardineb5d44e2003-12-23 08:09:43 +000098 /*
99 * uncomment the next line for full debugs
100 */
hassof390d2c2004-09-10 20:48:21 +0000101 /* isis->debugs = 0xFFFF; */
Olivier Dugeon4f593572016-04-19 19:03:05 +0200102 isisMplsTE.status = disable; /* Only support TE metric */
jardineb5d44e2003-12-23 08:09:43 +0000103}
104
105struct isis_area *
Josh Bailey3f045a02012-03-24 08:35:20 -0700106isis_area_create (const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000107{
jardineb5d44e2003-12-23 08:09:43 +0000108 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000109
hassoaac372f2005-09-01 17:52:33 +0000110 area = XCALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area));
jardineb5d44e2003-12-23 08:09:43 +0000111
112 /*
113 * The first instance is level-1-2 rest are level-1, unless otherwise
114 * configured
115 */
116 if (listcount (isis->area_list) > 0)
117 area->is_type = IS_LEVEL_1;
118 else
119 area->is_type = IS_LEVEL_1_AND_2;
Josh Bailey3f045a02012-03-24 08:35:20 -0700120
jardineb5d44e2003-12-23 08:09:43 +0000121 /*
122 * intialize the databases
123 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700124 if (area->is_type & IS_LEVEL_1)
125 {
126 area->lspdb[0] = lsp_db_init ();
127 area->route_table[0] = route_table_init ();
128#ifdef HAVE_IPV6
129 area->route_table6[0] = route_table_init ();
130#endif /* HAVE_IPV6 */
131 }
132 if (area->is_type & IS_LEVEL_2)
133 {
134 area->lspdb[1] = lsp_db_init ();
135 area->route_table[1] = route_table_init ();
136#ifdef HAVE_IPV6
137 area->route_table6[1] = route_table_init ();
138#endif /* HAVE_IPV6 */
139 }
hassof390d2c2004-09-10 20:48:21 +0000140
jardineb5d44e2003-12-23 08:09:43 +0000141 spftree_area_init (area);
Josh Bailey3f045a02012-03-24 08:35:20 -0700142
jardineb5d44e2003-12-23 08:09:43 +0000143 area->circuit_list = list_new ();
144 area->area_addrs = list_new ();
hassof390d2c2004-09-10 20:48:21 +0000145 THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
Paul Jakmac7350c42008-01-29 19:29:44 +0000146 flags_initialize (&area->flags);
Josh Bailey3f045a02012-03-24 08:35:20 -0700147
jardineb5d44e2003-12-23 08:09:43 +0000148 /*
149 * Default values
150 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700151 area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */
152 area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */
153 area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
154 area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
155 area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL;
156 area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL;
jardineb5d44e2003-12-23 08:09:43 +0000157 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
158 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
159 area->dynhostname = 1;
Josh Bailey3f045a02012-03-24 08:35:20 -0700160 area->oldmetric = 0;
161 area->newmetric = 1;
jardineb5d44e2003-12-23 08:09:43 +0000162 area->lsp_frag_threshold = 90;
Christian Frankef1fc1db2015-11-10 18:43:31 +0100163 area->lsp_mtu = DEFAULT_LSP_MTU;
jardineb5d44e2003-12-23 08:09:43 +0000164#ifdef TOPOLOGY_GENERATE
165 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
166#endif /* TOPOLOGY_GENERATE */
167
Josh Bailey3f045a02012-03-24 08:35:20 -0700168 area->area_tag = strdup (area_tag);
169 listnode_add (isis->area_list, area);
170 area->isis = isis;
171
jardineb5d44e2003-12-23 08:09:43 +0000172 return area;
173}
174
175struct isis_area *
hassof90a5f62004-10-11 13:11:56 +0000176isis_area_lookup (const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000177{
178 struct isis_area *area;
hasso3fdb2dd2005-09-28 18:45:54 +0000179 struct listnode *node;
hassof390d2c2004-09-10 20:48:21 +0000180
hasso3fdb2dd2005-09-28 18:45:54 +0000181 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
jardineb5d44e2003-12-23 08:09:43 +0000182 if ((area->area_tag == NULL && area_tag == NULL) ||
hassof390d2c2004-09-10 20:48:21 +0000183 (area->area_tag && area_tag
184 && strcmp (area->area_tag, area_tag) == 0))
185 return area;
186
jardineb5d44e2003-12-23 08:09:43 +0000187 return NULL;
188}
189
hassof390d2c2004-09-10 20:48:21 +0000190int
hassof90a5f62004-10-11 13:11:56 +0000191isis_area_get (struct vty *vty, const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000192{
jardineb5d44e2003-12-23 08:09:43 +0000193 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000194
jardineb5d44e2003-12-23 08:09:43 +0000195 area = isis_area_lookup (area_tag);
hassof390d2c2004-09-10 20:48:21 +0000196
197 if (area)
198 {
199 vty->node = ISIS_NODE;
200 vty->index = area;
201 return CMD_SUCCESS;
202 }
203
Josh Bailey3f045a02012-03-24 08:35:20 -0700204 area = isis_area_create (area_tag);
hassof390d2c2004-09-10 20:48:21 +0000205
hassoc89c05d2005-09-04 21:36:36 +0000206 if (isis->debugs & DEBUG_EVENTS)
207 zlog_debug ("New IS-IS area instance %s", area->area_tag);
jardineb5d44e2003-12-23 08:09:43 +0000208
209 vty->node = ISIS_NODE;
210 vty->index = area;
hassof390d2c2004-09-10 20:48:21 +0000211
jardineb5d44e2003-12-23 08:09:43 +0000212 return CMD_SUCCESS;
213}
214
215int
hassof90a5f62004-10-11 13:11:56 +0000216isis_area_destroy (struct vty *vty, const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000217{
jardineb5d44e2003-12-23 08:09:43 +0000218 struct isis_area *area;
paul1eb8ef22005-04-07 07:30:20 +0000219 struct listnode *node, *nnode;
jardineb5d44e2003-12-23 08:09:43 +0000220 struct isis_circuit *circuit;
Josh Bailey3f045a02012-03-24 08:35:20 -0700221 struct area_addr *addr;
jardineb5d44e2003-12-23 08:09:43 +0000222
223 area = isis_area_lookup (area_tag);
jardineb5d44e2003-12-23 08:09:43 +0000224
hassof390d2c2004-09-10 20:48:21 +0000225 if (area == NULL)
226 {
227 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700228 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +0000229 }
hassof390d2c2004-09-10 20:48:21 +0000230
231 if (area->circuit_list)
232 {
paul1eb8ef22005-04-07 07:30:20 +0000233 for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
Josh Bailey3f045a02012-03-24 08:35:20 -0700234 {
235 circuit->ip_router = 0;
236#ifdef HAVE_IPV6
237 circuit->ipv6_router = 0;
238#endif
239 isis_csm_state_change (ISIS_DISABLE, circuit, area);
240 }
hassof390d2c2004-09-10 20:48:21 +0000241 list_delete (area->circuit_list);
Josh Bailey3f045a02012-03-24 08:35:20 -0700242 area->circuit_list = NULL;
hassof390d2c2004-09-10 20:48:21 +0000243 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700244
245 if (area->lspdb[0] != NULL)
246 {
247 lsp_db_destroy (area->lspdb[0]);
248 area->lspdb[0] = NULL;
249 }
250 if (area->lspdb[1] != NULL)
251 {
252 lsp_db_destroy (area->lspdb[1]);
253 area->lspdb[1] = NULL;
254 }
255
256 spftree_area_del (area);
257
258 /* invalidate and validate would delete all routes from zebra */
259 isis_route_invalidate (area);
260 isis_route_validate (area);
261
262 if (area->route_table[0])
263 {
264 route_table_finish (area->route_table[0]);
265 area->route_table[0] = NULL;
266 }
267 if (area->route_table[1])
268 {
269 route_table_finish (area->route_table[1]);
270 area->route_table[1] = NULL;
271 }
272#ifdef HAVE_IPV6
273 if (area->route_table6[0])
274 {
275 route_table_finish (area->route_table6[0]);
276 area->route_table6[0] = NULL;
277 }
278 if (area->route_table6[1])
279 {
280 route_table_finish (area->route_table6[1]);
281 area->route_table6[1] = NULL;
282 }
283#endif /* HAVE_IPV6 */
284
Christian Frankeacf98652015-11-12 14:24:22 +0100285 isis_redist_area_finish(area);
286
Josh Bailey3f045a02012-03-24 08:35:20 -0700287 for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addr))
288 {
289 list_delete_node (area->area_addrs, node);
290 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
291 }
292 area->area_addrs = NULL;
293
hassof390d2c2004-09-10 20:48:21 +0000294 THREAD_TIMER_OFF (area->t_tick);
hassof390d2c2004-09-10 20:48:21 +0000295 THREAD_TIMER_OFF (area->t_lsp_refresh[0]);
296 THREAD_TIMER_OFF (area->t_lsp_refresh[1]);
jardineb5d44e2003-12-23 08:09:43 +0000297
Josh Bailey3f045a02012-03-24 08:35:20 -0700298 thread_cancel_event (master, area);
299
300 listnode_delete (isis->area_list, area);
301
302 free (area->area_tag);
303
jardineb5d44e2003-12-23 08:09:43 +0000304 XFREE (MTYPE_ISIS_AREA, area);
hassof390d2c2004-09-10 20:48:21 +0000305
Josh Bailey3f045a02012-03-24 08:35:20 -0700306 if (listcount (isis->area_list) == 0)
307 {
308 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
309 isis->sysid_set = 0;
310 }
311
jardineb5d44e2003-12-23 08:09:43 +0000312 return CMD_SUCCESS;
313}
314
hassof390d2c2004-09-10 20:48:21 +0000315int
Josh Bailey3f045a02012-03-24 08:35:20 -0700316area_net_title (struct vty *vty, const char *net_title)
jardineb5d44e2003-12-23 08:09:43 +0000317{
jardineb5d44e2003-12-23 08:09:43 +0000318 struct isis_area *area;
319 struct area_addr *addr;
320 struct area_addr *addrp;
hasso3fdb2dd2005-09-28 18:45:54 +0000321 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +0000322
323 u_char buff[255];
324 area = vty->index;
325
hassof390d2c2004-09-10 20:48:21 +0000326 if (!area)
327 {
328 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700329 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +0000330 }
jardineb5d44e2003-12-23 08:09:43 +0000331
332 /* We check that we are not over the maximal number of addresses */
hassof390d2c2004-09-10 20:48:21 +0000333 if (listcount (area->area_addrs) >= isis->max_area_addrs)
334 {
335 vty_out (vty, "Maximum of area addresses (%d) already reached %s",
336 isis->max_area_addrs, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700337 return CMD_ERR_NOTHING_TODO;
hassof390d2c2004-09-10 20:48:21 +0000338 }
jardineb5d44e2003-12-23 08:09:43 +0000339
340 addr = XMALLOC (MTYPE_ISIS_AREA_ADDR, sizeof (struct area_addr));
341 addr->addr_len = dotformat2buff (buff, net_title);
342 memcpy (addr->area_addr, buff, addr->addr_len);
343#ifdef EXTREME_DEBUG
hasso529d65b2004-12-24 00:14:50 +0000344 zlog_debug ("added area address %s for area %s (address length %d)",
jardineb5d44e2003-12-23 08:09:43 +0000345 net_title, area->area_tag, addr->addr_len);
346#endif /* EXTREME_DEBUG */
hassof390d2c2004-09-10 20:48:21 +0000347 if (addr->addr_len < 8 || addr->addr_len > 20)
348 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700349 vty_out (vty, "area address must be at least 8..20 octets long (%d)%s",
350 addr->addr_len, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000351 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
Josh Bailey3f045a02012-03-24 08:35:20 -0700352 return CMD_ERR_AMBIGUOUS;
353 }
354
355 if (addr->area_addr[addr->addr_len-1] != 0)
356 {
357 vty_out (vty, "nsel byte (last byte) in area address must be 0%s",
358 VTY_NEWLINE);
359 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
360 return CMD_ERR_AMBIGUOUS;
jardineb5d44e2003-12-23 08:09:43 +0000361 }
362
hassof390d2c2004-09-10 20:48:21 +0000363 if (isis->sysid_set == 0)
364 {
365 /*
366 * First area address - get the SystemID for this router
367 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700368 memcpy (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN);
hassof390d2c2004-09-10 20:48:21 +0000369 isis->sysid_set = 1;
hassoc89c05d2005-09-04 21:36:36 +0000370 if (isis->debugs & DEBUG_EVENTS)
371 zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid));
jardineb5d44e2003-12-23 08:09:43 +0000372 }
hassof390d2c2004-09-10 20:48:21 +0000373 else
374 {
375 /*
376 * Check that the SystemID portions match
377 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700378 if (memcmp (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN))
hassof390d2c2004-09-10 20:48:21 +0000379 {
380 vty_out (vty,
381 "System ID must not change when defining additional area"
382 " addresses%s", VTY_NEWLINE);
383 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
Josh Bailey3f045a02012-03-24 08:35:20 -0700384 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +0000385 }
jardineb5d44e2003-12-23 08:09:43 +0000386
hassof390d2c2004-09-10 20:48:21 +0000387 /* now we see that we don't already have this address */
hasso3fdb2dd2005-09-28 18:45:54 +0000388 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
389 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700390 if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != (addr->addr_len))
hasso3fdb2dd2005-09-28 18:45:54 +0000391 continue;
392 if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
393 {
394 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
395 return CMD_SUCCESS; /* silent fail */
396 }
397 }
hassof390d2c2004-09-10 20:48:21 +0000398 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700399
jardineb5d44e2003-12-23 08:09:43 +0000400 /*
401 * Forget the systemID part of the address
402 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700403 addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
jardineb5d44e2003-12-23 08:09:43 +0000404 listnode_add (area->area_addrs, addr);
405
406 /* only now we can safely generate our LSPs for this area */
hassof390d2c2004-09-10 20:48:21 +0000407 if (listcount (area->area_addrs) > 0)
408 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700409 if (area->is_type & IS_LEVEL_1)
410 lsp_generate (area, IS_LEVEL_1);
411 if (area->is_type & IS_LEVEL_2)
412 lsp_generate (area, IS_LEVEL_2);
hassof390d2c2004-09-10 20:48:21 +0000413 }
jardineb5d44e2003-12-23 08:09:43 +0000414
415 return CMD_SUCCESS;
416}
417
418int
Josh Bailey3f045a02012-03-24 08:35:20 -0700419area_clear_net_title (struct vty *vty, const char *net_title)
jardineb5d44e2003-12-23 08:09:43 +0000420{
421 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000422 struct area_addr addr, *addrp = NULL;
hasso3fdb2dd2005-09-28 18:45:54 +0000423 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +0000424 u_char buff[255];
425
426 area = vty->index;
hassof390d2c2004-09-10 20:48:21 +0000427 if (!area)
428 {
429 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700430 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +0000431 }
432
jardineb5d44e2003-12-23 08:09:43 +0000433 addr.addr_len = dotformat2buff (buff, net_title);
hassof390d2c2004-09-10 20:48:21 +0000434 if (addr.addr_len < 8 || addr.addr_len > 20)
435 {
436 vty_out (vty, "Unsupported area address length %d, should be 8...20 %s",
437 addr.addr_len, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700438 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +0000439 }
440
441 memcpy (addr.area_addr, buff, (int) addr.addr_len);
442
hasso3fdb2dd2005-09-28 18:45:54 +0000443 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
Josh Bailey3f045a02012-03-24 08:35:20 -0700444 if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len &&
jardineb5d44e2003-12-23 08:09:43 +0000445 !memcmp (addrp->area_addr, addr.area_addr, addr.addr_len))
hassof390d2c2004-09-10 20:48:21 +0000446 break;
447
448 if (!addrp)
449 {
450 vty_out (vty, "No area address %s for area %s %s", net_title,
451 area->area_tag, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700452 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +0000453 }
454
jardineb5d44e2003-12-23 08:09:43 +0000455 listnode_delete (area->area_addrs, addrp);
Josh Bailey3f045a02012-03-24 08:35:20 -0700456 XFREE (MTYPE_ISIS_AREA_ADDR, addrp);
457
458 /*
459 * Last area address - reset the SystemID for this router
460 */
461 if (listcount (area->area_addrs) == 0)
462 {
463 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
464 isis->sysid_set = 0;
465 if (isis->debugs & DEBUG_EVENTS)
466 zlog_debug ("Router has no SystemID");
467 }
hassof390d2c2004-09-10 20:48:21 +0000468
jardineb5d44e2003-12-23 08:09:43 +0000469 return CMD_SUCCESS;
470}
471
jardineb5d44e2003-12-23 08:09:43 +0000472/*
Josh Bailey3f045a02012-03-24 08:35:20 -0700473 * 'show isis interface' command
jardineb5d44e2003-12-23 08:09:43 +0000474 */
475
476int
Josh Bailey3f045a02012-03-24 08:35:20 -0700477show_isis_interface_common (struct vty *vty, const char *ifname, char detail)
jardineb5d44e2003-12-23 08:09:43 +0000478{
hasso3fdb2dd2005-09-28 18:45:54 +0000479 struct listnode *anode, *cnode;
jardineb5d44e2003-12-23 08:09:43 +0000480 struct isis_area *area;
481 struct isis_circuit *circuit;
jardineb5d44e2003-12-23 08:09:43 +0000482
hassof390d2c2004-09-10 20:48:21 +0000483 if (!isis)
484 {
485 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
486 return CMD_SUCCESS;
487 }
jardineb5d44e2003-12-23 08:09:43 +0000488
hasso3fdb2dd2005-09-28 18:45:54 +0000489 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
hassof390d2c2004-09-10 20:48:21 +0000490 {
hassof390d2c2004-09-10 20:48:21 +0000491 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000492
hassof390d2c2004-09-10 20:48:21 +0000493 if (detail == ISIS_UI_LEVEL_BRIEF)
Josh Bailey3f045a02012-03-24 08:35:20 -0700494 vty_out (vty, " Interface CircId State Type Level%s",
495 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000496
hasso3fdb2dd2005-09-28 18:45:54 +0000497 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
Josh Bailey3f045a02012-03-24 08:35:20 -0700498 if (!ifname)
499 isis_circuit_print_vty (circuit, vty, detail);
500 else if (strcmp(circuit->interface->name, ifname) == 0)
501 isis_circuit_print_vty (circuit, vty, detail);
jardineb5d44e2003-12-23 08:09:43 +0000502 }
hassof390d2c2004-09-10 20:48:21 +0000503
jardineb5d44e2003-12-23 08:09:43 +0000504 return CMD_SUCCESS;
505}
506
Josh Bailey3f045a02012-03-24 08:35:20 -0700507DEFUN (show_isis_interface,
508 show_isis_interface_cmd,
509 "show isis interface",
jardineb5d44e2003-12-23 08:09:43 +0000510 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -0700511 "ISIS network information\n"
512 "ISIS interface\n")
jardineb5d44e2003-12-23 08:09:43 +0000513{
Josh Bailey3f045a02012-03-24 08:35:20 -0700514 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
jardineb5d44e2003-12-23 08:09:43 +0000515}
516
Josh Bailey3f045a02012-03-24 08:35:20 -0700517DEFUN (show_isis_interface_detail,
518 show_isis_interface_detail_cmd,
519 "show isis interface detail",
jardineb5d44e2003-12-23 08:09:43 +0000520 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -0700521 "ISIS network information\n"
522 "ISIS interface\n"
jardineb5d44e2003-12-23 08:09:43 +0000523 "show detailed information\n")
524{
Josh Bailey3f045a02012-03-24 08:35:20 -0700525 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
jardineb5d44e2003-12-23 08:09:43 +0000526}
527
Josh Bailey3f045a02012-03-24 08:35:20 -0700528DEFUN (show_isis_interface_arg,
529 show_isis_interface_arg_cmd,
530 "show isis interface WORD",
jardineb5d44e2003-12-23 08:09:43 +0000531 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -0700532 "ISIS network information\n"
533 "ISIS interface\n"
534 "ISIS interface name\n")
535{
536 return show_isis_interface_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
537}
538
539/*
540 * 'show isis neighbor' command
541 */
542
543int
544show_isis_neighbor_common (struct vty *vty, const char *id, char detail)
545{
546 struct listnode *anode, *cnode, *node;
547 struct isis_area *area;
548 struct isis_circuit *circuit;
549 struct list *adjdb;
550 struct isis_adjacency *adj;
551 struct isis_dynhn *dynhn;
552 u_char sysid[ISIS_SYS_ID_LEN];
553 int i;
554
555 if (!isis)
556 {
557 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
558 return CMD_SUCCESS;
559 }
560
561 memset (sysid, 0, ISIS_SYS_ID_LEN);
562 if (id)
563 {
564 if (sysid2buff (sysid, id) == 0)
565 {
566 dynhn = dynhn_find_by_name (id);
567 if (dynhn == NULL)
568 {
569 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
570 return CMD_SUCCESS;
571 }
572 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
573 }
574 }
575
576 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
577 {
578 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
579
580 if (detail == ISIS_UI_LEVEL_BRIEF)
581 vty_out (vty, " System Id Interface L State"
582 " Holdtime SNPA%s", VTY_NEWLINE);
583
584 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
585 {
586 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
587 {
588 for (i = 0; i < 2; i++)
589 {
590 adjdb = circuit->u.bc.adjdb[i];
591 if (adjdb && adjdb->count)
592 {
593 for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
594 if (!id || !memcmp (adj->sysid, sysid,
595 ISIS_SYS_ID_LEN))
596 isis_adj_print_vty (adj, vty, detail);
597 }
598 }
599 }
600 else if (circuit->circ_type == CIRCUIT_T_P2P &&
601 circuit->u.p2p.neighbor)
602 {
603 adj = circuit->u.p2p.neighbor;
604 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
605 isis_adj_print_vty (adj, vty, detail);
606 }
607 }
608 }
609
610 return CMD_SUCCESS;
611}
612
613/*
614 * 'clear isis neighbor' command
615 */
616int
617clear_isis_neighbor_common (struct vty *vty, const char *id)
618{
619 struct listnode *anode, *cnode, *cnextnode, *node, *nnode;
620 struct isis_area *area;
621 struct isis_circuit *circuit;
622 struct list *adjdb;
623 struct isis_adjacency *adj;
624 struct isis_dynhn *dynhn;
625 u_char sysid[ISIS_SYS_ID_LEN];
626 int i;
627
628 if (!isis)
629 {
630 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
631 return CMD_SUCCESS;
632 }
633
634 memset (sysid, 0, ISIS_SYS_ID_LEN);
635 if (id)
636 {
637 if (sysid2buff (sysid, id) == 0)
638 {
639 dynhn = dynhn_find_by_name (id);
640 if (dynhn == NULL)
641 {
642 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
643 return CMD_SUCCESS;
644 }
645 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
646 }
647 }
648
649 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
650 {
651 for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnextnode, circuit))
652 {
653 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
654 {
655 for (i = 0; i < 2; i++)
656 {
657 adjdb = circuit->u.bc.adjdb[i];
658 if (adjdb && adjdb->count)
659 {
660 for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj))
661 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
662 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
663 "clear user request");
664 }
665 }
666 }
667 else if (circuit->circ_type == CIRCUIT_T_P2P &&
668 circuit->u.p2p.neighbor)
669 {
670 adj = circuit->u.p2p.neighbor;
671 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
672 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
673 "clear user request");
674 }
675 }
676 }
677
678 return CMD_SUCCESS;
679}
680
681DEFUN (show_isis_neighbor,
682 show_isis_neighbor_cmd,
683 "show isis neighbor",
684 SHOW_STR
685 "ISIS network information\n"
686 "ISIS neighbor adjacencies\n")
687{
688 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
689}
690
691DEFUN (show_isis_neighbor_detail,
692 show_isis_neighbor_detail_cmd,
693 "show isis neighbor detail",
694 SHOW_STR
695 "ISIS network information\n"
696 "ISIS neighbor adjacencies\n"
jardineb5d44e2003-12-23 08:09:43 +0000697 "show detailed information\n")
Josh Bailey3f045a02012-03-24 08:35:20 -0700698{
699 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
700}
701
702DEFUN (show_isis_neighbor_arg,
703 show_isis_neighbor_arg_cmd,
704 "show isis neighbor WORD",
705 SHOW_STR
706 "ISIS network information\n"
707 "ISIS neighbor adjacencies\n"
708 "System id\n")
709{
710 return show_isis_neighbor_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
711}
712
713DEFUN (clear_isis_neighbor,
714 clear_isis_neighbor_cmd,
715 "clear isis neighbor",
716 CLEAR_STR
717 "Reset ISIS network information\n"
718 "Reset ISIS neighbor adjacencies\n")
719{
720 return clear_isis_neighbor_common (vty, NULL);
721}
722
723DEFUN (clear_isis_neighbor_arg,
724 clear_isis_neighbor_arg_cmd,
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700725 "clear isis neighbor WORD",
Josh Bailey3f045a02012-03-24 08:35:20 -0700726 CLEAR_STR
727 "ISIS network information\n"
728 "ISIS neighbor adjacencies\n"
729 "System id\n")
730{
731 return clear_isis_neighbor_common (vty, argv[0]);
732}
733
jardineb5d44e2003-12-23 08:09:43 +0000734/*
735 * 'isis debug', 'show debugging'
736 */
jardineb5d44e2003-12-23 08:09:43 +0000737void
738print_debug (struct vty *vty, int flags, int onoff)
739{
740 char onoffs[4];
741 if (onoff)
hassof390d2c2004-09-10 20:48:21 +0000742 strcpy (onoffs, "on");
jardineb5d44e2003-12-23 08:09:43 +0000743 else
hassof390d2c2004-09-10 20:48:21 +0000744 strcpy (onoffs, "off");
jardineb5d44e2003-12-23 08:09:43 +0000745
746 if (flags & DEBUG_ADJ_PACKETS)
hassof390d2c2004-09-10 20:48:21 +0000747 vty_out (vty, "IS-IS Adjacency related packets debugging is %s%s", onoffs,
748 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000749 if (flags & DEBUG_CHECKSUM_ERRORS)
hassof390d2c2004-09-10 20:48:21 +0000750 vty_out (vty, "IS-IS checksum errors debugging is %s%s", onoffs,
751 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000752 if (flags & DEBUG_LOCAL_UPDATES)
hassof390d2c2004-09-10 20:48:21 +0000753 vty_out (vty, "IS-IS local updates debugging is %s%s", onoffs,
754 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000755 if (flags & DEBUG_PROTOCOL_ERRORS)
hassof390d2c2004-09-10 20:48:21 +0000756 vty_out (vty, "IS-IS protocol errors debugging is %s%s", onoffs,
757 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000758 if (flags & DEBUG_SNP_PACKETS)
hassof390d2c2004-09-10 20:48:21 +0000759 vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s%s", onoffs,
760 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000761 if (flags & DEBUG_SPF_EVENTS)
hassof390d2c2004-09-10 20:48:21 +0000762 vty_out (vty, "IS-IS SPF events debugging is %s%s", onoffs, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000763 if (flags & DEBUG_SPF_STATS)
hassof390d2c2004-09-10 20:48:21 +0000764 vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s%s",
765 onoffs, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000766 if (flags & DEBUG_SPF_TRIGGERS)
hassof390d2c2004-09-10 20:48:21 +0000767 vty_out (vty, "IS-IS SPF triggering events debugging is %s%s", onoffs,
768 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000769 if (flags & DEBUG_UPDATE_PACKETS)
hassof390d2c2004-09-10 20:48:21 +0000770 vty_out (vty, "IS-IS Update related packet debugging is %s%s", onoffs,
771 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000772 if (flags & DEBUG_RTE_EVENTS)
hassof390d2c2004-09-10 20:48:21 +0000773 vty_out (vty, "IS-IS Route related debuggin is %s%s", onoffs,
774 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000775 if (flags & DEBUG_EVENTS)
hassof390d2c2004-09-10 20:48:21 +0000776 vty_out (vty, "IS-IS Event debugging is %s%s", onoffs, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700777 if (flags & DEBUG_PACKET_DUMP)
778 vty_out (vty, "IS-IS Packet dump debugging is %s%s", onoffs, VTY_NEWLINE);
Christian Franke80a8f722015-11-12 14:21:47 +0100779 if (flags & DEBUG_LSP_GEN)
780 vty_out (vty, "IS-IS LSP generation debugging is %s%s", onoffs, VTY_NEWLINE);
Christian Franke61010c32015-11-10 18:43:34 +0100781 if (flags & DEBUG_LSP_SCHED)
782 vty_out (vty, "IS-IS LSP scheduling debugging is %s%s", onoffs, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000783}
784
785DEFUN (show_debugging,
Olivier Dugeon4f593572016-04-19 19:03:05 +0200786 show_debugging_isis_cmd,
787 "show debugging isis",
jardineb5d44e2003-12-23 08:09:43 +0000788 SHOW_STR
789 "State of each debugging option\n")
790{
Olivier Dugeon4f593572016-04-19 19:03:05 +0200791 if (isis->debugs) {
792 vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
793 print_debug (vty, isis->debugs, 1);
794 }
jardineb5d44e2003-12-23 08:09:43 +0000795 return CMD_SUCCESS;
796}
797
jardin9e867fe2003-12-23 08:56:18 +0000798/* Debug node. */
hassof390d2c2004-09-10 20:48:21 +0000799static struct cmd_node debug_node = {
jardin9e867fe2003-12-23 08:56:18 +0000800 DEBUG_NODE,
hassof390d2c2004-09-10 20:48:21 +0000801 "",
802 1
jardin9e867fe2003-12-23 08:56:18 +0000803};
804
805static int
806config_write_debug (struct vty *vty)
807{
808 int write = 0;
809 int flags = isis->debugs;
810
hassof390d2c2004-09-10 20:48:21 +0000811 if (flags & DEBUG_ADJ_PACKETS)
812 {
813 vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
814 write++;
815 }
816 if (flags & DEBUG_CHECKSUM_ERRORS)
817 {
818 vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
819 write++;
820 }
821 if (flags & DEBUG_LOCAL_UPDATES)
822 {
823 vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
824 write++;
825 }
826 if (flags & DEBUG_PROTOCOL_ERRORS)
827 {
828 vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
829 write++;
830 }
831 if (flags & DEBUG_SNP_PACKETS)
832 {
833 vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
834 write++;
835 }
836 if (flags & DEBUG_SPF_EVENTS)
837 {
838 vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
839 write++;
840 }
841 if (flags & DEBUG_SPF_STATS)
842 {
843 vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
844 write++;
845 }
846 if (flags & DEBUG_SPF_TRIGGERS)
847 {
848 vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
849 write++;
850 }
851 if (flags & DEBUG_UPDATE_PACKETS)
852 {
853 vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
854 write++;
855 }
856 if (flags & DEBUG_RTE_EVENTS)
857 {
858 vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
859 write++;
860 }
861 if (flags & DEBUG_EVENTS)
862 {
863 vty_out (vty, "debug isis events%s", VTY_NEWLINE);
864 write++;
865 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700866 if (flags & DEBUG_PACKET_DUMP)
867 {
868 vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE);
869 write++;
870 }
Christian Franke80a8f722015-11-12 14:21:47 +0100871 if (flags & DEBUG_LSP_GEN)
872 {
873 vty_out (vty, "debug isis lsp-gen%s", VTY_NEWLINE);
874 write++;
875 }
Christian Franke61010c32015-11-10 18:43:34 +0100876 if (flags & DEBUG_LSP_SCHED)
877 {
878 vty_out (vty, "debug isis lsp-sched%s", VTY_NEWLINE);
879 write++;
880 }
jardin9e867fe2003-12-23 08:56:18 +0000881
882 return write;
883}
884
jardineb5d44e2003-12-23 08:09:43 +0000885DEFUN (debug_isis_adj,
886 debug_isis_adj_cmd,
887 "debug isis adj-packets",
888 DEBUG_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{
892 isis->debugs |= DEBUG_ADJ_PACKETS;
hassof390d2c2004-09-10 20:48:21 +0000893 print_debug (vty, DEBUG_ADJ_PACKETS, 1);
jardineb5d44e2003-12-23 08:09:43 +0000894
895 return CMD_SUCCESS;
896}
897
898DEFUN (no_debug_isis_adj,
899 no_debug_isis_adj_cmd,
900 "no debug isis adj-packets",
901 UNDEBUG_STR
902 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000903 "IS-IS Adjacency related packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000904{
jardineb5d44e2003-12-23 08:09:43 +0000905 isis->debugs &= ~DEBUG_ADJ_PACKETS;
906 print_debug (vty, DEBUG_ADJ_PACKETS, 0);
907
908 return CMD_SUCCESS;
909}
910
jardineb5d44e2003-12-23 08:09:43 +0000911DEFUN (debug_isis_csum,
912 debug_isis_csum_cmd,
913 "debug isis checksum-errors",
914 DEBUG_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, 1);
920
921 return CMD_SUCCESS;
922}
923
924DEFUN (no_debug_isis_csum,
925 no_debug_isis_csum_cmd,
926 "no debug isis checksum-errors",
927 UNDEBUG_STR
928 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000929 "IS-IS LSP checksum errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000930{
931 isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
932 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
hassof390d2c2004-09-10 20:48:21 +0000933
jardineb5d44e2003-12-23 08:09:43 +0000934 return CMD_SUCCESS;
935}
936
937DEFUN (debug_isis_lupd,
938 debug_isis_lupd_cmd,
939 "debug isis local-updates",
940 DEBUG_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;
945 print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
946
947 return CMD_SUCCESS;
948}
949
950DEFUN (no_debug_isis_lupd,
951 no_debug_isis_lupd_cmd,
952 "no debug isis local-updates",
953 UNDEBUG_STR
954 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000955 "IS-IS local update packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000956{
957 isis->debugs &= ~DEBUG_LOCAL_UPDATES;
hassof390d2c2004-09-10 20:48:21 +0000958 print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
959
jardineb5d44e2003-12-23 08:09:43 +0000960 return CMD_SUCCESS;
961}
962
963DEFUN (debug_isis_err,
964 debug_isis_err_cmd,
hassof390d2c2004-09-10 20:48:21 +0000965 "debug isis protocol-errors",
jardineb5d44e2003-12-23 08:09:43 +0000966 DEBUG_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, 1);
972
973 return CMD_SUCCESS;
974}
975
976DEFUN (no_debug_isis_err,
977 no_debug_isis_err_cmd,
978 "no debug isis protocol-errors",
979 UNDEBUG_STR
980 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000981 "IS-IS LSP protocol errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000982{
983 isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
984 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
hassof390d2c2004-09-10 20:48:21 +0000985
jardineb5d44e2003-12-23 08:09:43 +0000986 return CMD_SUCCESS;
987}
988
989DEFUN (debug_isis_snp,
990 debug_isis_snp_cmd,
991 "debug isis snp-packets",
992 DEBUG_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{
996 isis->debugs |= DEBUG_SNP_PACKETS;
997 print_debug (vty, DEBUG_SNP_PACKETS, 1);
998
999 return CMD_SUCCESS;
1000}
1001
1002DEFUN (no_debug_isis_snp,
1003 no_debug_isis_snp_cmd,
1004 "no debug isis snp-packets",
1005 UNDEBUG_STR
1006 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001007 "IS-IS CSNP/PSNP packets\n")
jardineb5d44e2003-12-23 08:09:43 +00001008{
hassof390d2c2004-09-10 20:48:21 +00001009 isis->debugs &= ~DEBUG_SNP_PACKETS;
jardineb5d44e2003-12-23 08:09:43 +00001010 print_debug (vty, DEBUG_SNP_PACKETS, 0);
hassof390d2c2004-09-10 20:48:21 +00001011
jardineb5d44e2003-12-23 08:09:43 +00001012 return CMD_SUCCESS;
1013}
1014
jardineb5d44e2003-12-23 08:09:43 +00001015DEFUN (debug_isis_upd,
1016 debug_isis_upd_cmd,
1017 "debug isis update-packets",
1018 DEBUG_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, 1);
1024
1025 return CMD_SUCCESS;
1026}
1027
1028DEFUN (no_debug_isis_upd,
1029 no_debug_isis_upd_cmd,
1030 "no debug isis update-packets",
1031 UNDEBUG_STR
1032 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001033 "IS-IS Update related packets\n")
jardineb5d44e2003-12-23 08:09:43 +00001034{
1035 isis->debugs &= ~DEBUG_UPDATE_PACKETS;
1036 print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
hassof390d2c2004-09-10 20:48:21 +00001037
jardineb5d44e2003-12-23 08:09:43 +00001038 return CMD_SUCCESS;
1039}
1040
jardineb5d44e2003-12-23 08:09:43 +00001041DEFUN (debug_isis_spfevents,
1042 debug_isis_spfevents_cmd,
1043 "debug isis spf-events",
1044 DEBUG_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, 1);
jardineb5d44e2003-12-23 08:09:43 +00001050
1051 return CMD_SUCCESS;
1052}
1053
1054DEFUN (no_debug_isis_spfevents,
1055 no_debug_isis_spfevents_cmd,
1056 "no debug isis spf-events",
1057 UNDEBUG_STR
1058 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001059 "IS-IS Shortest Path First Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001060{
1061 isis->debugs &= ~DEBUG_SPF_EVENTS;
hassof390d2c2004-09-10 20:48:21 +00001062 print_debug (vty, DEBUG_SPF_EVENTS, 0);
1063
jardineb5d44e2003-12-23 08:09:43 +00001064 return CMD_SUCCESS;
1065}
1066
jardineb5d44e2003-12-23 08:09:43 +00001067DEFUN (debug_isis_spfstats,
1068 debug_isis_spfstats_cmd,
1069 "debug isis spf-statistics ",
1070 DEBUG_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, 1);
1076
1077 return CMD_SUCCESS;
1078}
1079
1080DEFUN (no_debug_isis_spfstats,
1081 no_debug_isis_spfstats_cmd,
1082 "no debug isis spf-statistics",
1083 UNDEBUG_STR
1084 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001085 "IS-IS SPF Timing and Statistic Data\n")
jardineb5d44e2003-12-23 08:09:43 +00001086{
1087 isis->debugs &= ~DEBUG_SPF_STATS;
1088 print_debug (vty, DEBUG_SPF_STATS, 0);
hassof390d2c2004-09-10 20:48:21 +00001089
jardineb5d44e2003-12-23 08:09:43 +00001090 return CMD_SUCCESS;
1091}
1092
1093DEFUN (debug_isis_spftrigg,
1094 debug_isis_spftrigg_cmd,
1095 "debug isis spf-triggers",
1096 DEBUG_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, 1);
1102
1103 return CMD_SUCCESS;
1104}
1105
1106DEFUN (no_debug_isis_spftrigg,
1107 no_debug_isis_spftrigg_cmd,
1108 "no debug isis spf-triggers",
1109 UNDEBUG_STR
1110 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001111 "IS-IS SPF triggering events\n")
jardineb5d44e2003-12-23 08:09:43 +00001112{
1113 isis->debugs &= ~DEBUG_SPF_TRIGGERS;
1114 print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
hassof390d2c2004-09-10 20:48:21 +00001115
jardineb5d44e2003-12-23 08:09:43 +00001116 return CMD_SUCCESS;
1117}
1118
1119DEFUN (debug_isis_rtevents,
1120 debug_isis_rtevents_cmd,
1121 "debug isis route-events",
1122 DEBUG_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, 1);
1128
1129 return CMD_SUCCESS;
1130}
1131
1132DEFUN (no_debug_isis_rtevents,
1133 no_debug_isis_rtevents_cmd,
1134 "no debug isis route-events",
1135 UNDEBUG_STR
1136 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001137 "IS-IS Route related events\n")
jardineb5d44e2003-12-23 08:09:43 +00001138{
1139 isis->debugs &= ~DEBUG_RTE_EVENTS;
1140 print_debug (vty, DEBUG_RTE_EVENTS, 0);
hassof390d2c2004-09-10 20:48:21 +00001141
jardineb5d44e2003-12-23 08:09:43 +00001142 return CMD_SUCCESS;
1143}
1144
1145DEFUN (debug_isis_events,
1146 debug_isis_events_cmd,
1147 "debug isis events",
1148 DEBUG_STR
1149 "IS-IS information\n"
hassof1082d12005-09-19 04:23:34 +00001150 "IS-IS Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001151{
1152 isis->debugs |= DEBUG_EVENTS;
1153 print_debug (vty, DEBUG_EVENTS, 1);
1154
1155 return CMD_SUCCESS;
1156}
1157
1158DEFUN (no_debug_isis_events,
1159 no_debug_isis_events_cmd,
1160 "no debug isis events",
1161 UNDEBUG_STR
1162 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001163 "IS-IS Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001164{
1165 isis->debugs &= ~DEBUG_EVENTS;
1166 print_debug (vty, DEBUG_EVENTS, 0);
hassof390d2c2004-09-10 20:48:21 +00001167
jardineb5d44e2003-12-23 08:09:43 +00001168 return CMD_SUCCESS;
1169}
1170
Josh Bailey3f045a02012-03-24 08:35:20 -07001171DEFUN (debug_isis_packet_dump,
1172 debug_isis_packet_dump_cmd,
1173 "debug isis packet-dump",
1174 DEBUG_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, 1);
1180
1181 return CMD_SUCCESS;
1182}
1183
1184DEFUN (no_debug_isis_packet_dump,
1185 no_debug_isis_packet_dump_cmd,
1186 "no debug isis packet-dump",
1187 UNDEBUG_STR
1188 "IS-IS information\n"
1189 "IS-IS packet dump\n")
1190{
1191 isis->debugs &= ~DEBUG_PACKET_DUMP;
1192 print_debug (vty, DEBUG_PACKET_DUMP, 0);
1193
1194 return CMD_SUCCESS;
1195}
1196
Christian Franke80a8f722015-11-12 14:21:47 +01001197DEFUN (debug_isis_lsp_gen,
1198 debug_isis_lsp_gen_cmd,
1199 "debug isis lsp-gen",
1200 DEBUG_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, 1);
1206
1207 return CMD_SUCCESS;
1208}
1209
1210DEFUN (no_debug_isis_lsp_gen,
1211 no_debug_isis_lsp_gen_cmd,
1212 "no debug isis lsp-gen",
1213 UNDEBUG_STR
1214 "IS-IS information\n"
1215 "IS-IS generation of own LSPs\n")
1216{
1217 isis->debugs &= ~DEBUG_LSP_GEN;
1218 print_debug (vty, DEBUG_LSP_GEN, 0);
1219
1220 return CMD_SUCCESS;
1221}
1222
Christian Franke61010c32015-11-10 18:43:34 +01001223DEFUN (debug_isis_lsp_sched,
1224 debug_isis_lsp_sched_cmd,
1225 "debug isis lsp-sched",
1226 DEBUG_STR
1227 "IS-IS information\n"
1228 "IS-IS scheduling of LSP generation\n")
1229{
1230 isis->debugs |= DEBUG_LSP_SCHED;
1231 print_debug (vty, DEBUG_LSP_SCHED, 1);
1232
1233 return CMD_SUCCESS;
1234}
1235
1236DEFUN (no_debug_isis_lsp_sched,
1237 no_debug_isis_lsp_sched_cmd,
1238 "no debug isis lsp-gen",
1239 UNDEBUG_STR
1240 "IS-IS information\n"
1241 "IS-IS scheduling of LSP generation\n")
1242{
1243 isis->debugs &= ~DEBUG_LSP_SCHED;
1244 print_debug (vty, DEBUG_LSP_SCHED, 0);
1245
1246 return CMD_SUCCESS;
1247}
1248
jardineb5d44e2003-12-23 08:09:43 +00001249DEFUN (show_hostname,
1250 show_hostname_cmd,
1251 "show isis hostname",
1252 SHOW_STR
1253 "IS-IS information\n"
1254 "IS-IS Dynamic hostname mapping\n")
1255{
1256 dynhn_print_all (vty);
hassof390d2c2004-09-10 20:48:21 +00001257
jardineb5d44e2003-12-23 08:09:43 +00001258 return CMD_SUCCESS;
1259}
1260
Josh Bailey3f045a02012-03-24 08:35:20 -07001261static void
1262vty_out_timestr(struct vty *vty, time_t uptime)
1263{
1264 struct tm *tm;
1265 time_t difftime = time (NULL);
1266 difftime -= uptime;
1267 tm = gmtime (&difftime);
1268
1269#define ONE_DAY_SECOND 60*60*24
1270#define ONE_WEEK_SECOND 60*60*24*7
1271 if (difftime < ONE_DAY_SECOND)
1272 vty_out (vty, "%02d:%02d:%02d",
1273 tm->tm_hour, tm->tm_min, tm->tm_sec);
1274 else if (difftime < ONE_WEEK_SECOND)
1275 vty_out (vty, "%dd%02dh%02dm",
1276 tm->tm_yday, tm->tm_hour, tm->tm_min);
1277 else
1278 vty_out (vty, "%02dw%dd%02dh",
1279 tm->tm_yday/7,
1280 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1281 vty_out (vty, " ago");
1282}
1283
1284DEFUN (show_isis_summary,
1285 show_isis_summary_cmd,
1286 "show isis summary",
1287 SHOW_STR "IS-IS information\n" "IS-IS summary\n")
1288{
1289 struct listnode *node, *node2;
1290 struct isis_area *area;
1291 struct isis_spftree *spftree;
1292 int level;
1293
1294 if (isis == NULL)
1295 {
1296 vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
1297 return CMD_SUCCESS;
1298 }
1299
1300 vty_out (vty, "Process Id : %ld%s", isis->process_id,
1301 VTY_NEWLINE);
1302 if (isis->sysid_set)
1303 vty_out (vty, "System Id : %s%s", sysid_print (isis->sysid),
1304 VTY_NEWLINE);
1305
1306 vty_out (vty, "Up time : ");
1307 vty_out_timestr(vty, isis->uptime);
1308 vty_out (vty, "%s", VTY_NEWLINE);
1309
1310 if (isis->area_list)
1311 vty_out (vty, "Number of areas : %d%s", isis->area_list->count,
1312 VTY_NEWLINE);
1313
1314 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1315 {
1316 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1317 VTY_NEWLINE);
1318
1319 if (listcount (area->area_addrs) > 0)
1320 {
1321 struct area_addr *area_addr;
1322 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
1323 {
1324 vty_out (vty, " Net: %s%s",
1325 isonet_print (area_addr->area_addr,
1326 area_addr->addr_len + ISIS_SYS_ID_LEN +
1327 1), VTY_NEWLINE);
1328 }
1329 }
1330
1331 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
1332 {
1333 if ((area->is_type & level) == 0)
1334 continue;
1335
1336 vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE);
1337 spftree = area->spftree[level - 1];
1338 if (spftree->pending)
1339 vty_out (vty, " IPv4 SPF: (pending)%s", VTY_NEWLINE);
1340 else
1341 vty_out (vty, " IPv4 SPF:%s", VTY_NEWLINE);
1342
1343 vty_out (vty, " minimum interval : %d%s",
1344 area->min_spf_interval[level - 1], VTY_NEWLINE);
1345
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001346 vty_out (vty, " last run elapsed : ");
1347 vty_out_timestr(vty, spftree->last_run_timestamp);
Josh Bailey3f045a02012-03-24 08:35:20 -07001348 vty_out (vty, "%s", VTY_NEWLINE);
1349
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001350 vty_out (vty, " last run duration : %u usec%s",
1351 (u_int32_t)spftree->last_run_duration, VTY_NEWLINE);
1352
Josh Bailey3f045a02012-03-24 08:35:20 -07001353 vty_out (vty, " run count : %d%s",
1354 spftree->runcount, VTY_NEWLINE);
1355
1356#ifdef HAVE_IPV6
1357 spftree = area->spftree6[level - 1];
1358 if (spftree->pending)
1359 vty_out (vty, " IPv6 SPF: (pending)%s", VTY_NEWLINE);
1360 else
1361 vty_out (vty, " IPv6 SPF:%s", VTY_NEWLINE);
1362
1363 vty_out (vty, " minimum interval : %d%s",
1364 area->min_spf_interval[level - 1], VTY_NEWLINE);
1365
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001366 vty_out (vty, " last run elapsed : ");
1367 vty_out_timestr(vty, spftree->last_run_timestamp);
Josh Bailey3f045a02012-03-24 08:35:20 -07001368 vty_out (vty, "%s", VTY_NEWLINE);
1369
David Lamparteref008d22015-03-03 08:48:11 +01001370 vty_out (vty, " last run duration : %llu msec%s",
1371 (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001372
Josh Bailey3f045a02012-03-24 08:35:20 -07001373 vty_out (vty, " run count : %d%s",
1374 spftree->runcount, VTY_NEWLINE);
1375#endif
1376 }
1377 }
1378 vty_out (vty, "%s", VTY_NEWLINE);
1379
1380 return CMD_SUCCESS;
1381}
1382
1383/*
1384 * This function supports following display options:
1385 * [ show isis database [detail] ]
1386 * [ show isis database <sysid> [detail] ]
1387 * [ show isis database <hostname> [detail] ]
1388 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1389 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1390 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1391 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1392 * [ show isis database detail <sysid> ]
1393 * [ show isis database detail <hostname> ]
1394 * [ show isis database detail <sysid>.<pseudo-id> ]
1395 * [ show isis database detail <hostname>.<pseudo-id> ]
1396 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1397 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1398 */
1399static int
1400show_isis_database (struct vty *vty, const char *argv, int ui_level)
jardineb5d44e2003-12-23 08:09:43 +00001401{
hasso3fdb2dd2005-09-28 18:45:54 +00001402 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +00001403 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07001404 struct isis_lsp *lsp;
1405 struct isis_dynhn *dynhn;
1406 const char *pos = argv;
1407 u_char lspid[ISIS_SYS_ID_LEN+2];
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001408 char sysid[255];
Josh Bailey3f045a02012-03-24 08:35:20 -07001409 u_char number[3];
hassof390d2c2004-09-10 20:48:21 +00001410 int level, lsp_count;
jardineb5d44e2003-12-23 08:09:43 +00001411
1412 if (isis->area_list->count == 0)
1413 return CMD_SUCCESS;
jardineb5d44e2003-12-23 08:09:43 +00001414
Josh Bailey3f045a02012-03-24 08:35:20 -07001415 memset (&lspid, 0, ISIS_SYS_ID_LEN);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001416 memset (&sysid, 0, 255);
Josh Bailey3f045a02012-03-24 08:35:20 -07001417
1418 /*
1419 * extract fragment and pseudo id from the string argv
1420 * in the forms:
1421 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1422 * (b) <systemid/hostname>.<pseudo-id> or
1423 * (c) <systemid/hostname> or
1424 * Where systemid is in the form:
1425 * xxxx.xxxx.xxxx
1426 */
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001427 if (argv)
1428 strncpy (sysid, argv, 254);
Josh Bailey3f045a02012-03-24 08:35:20 -07001429 if (argv && strlen (argv) > 3)
1430 {
1431 pos = argv + strlen (argv) - 3;
1432 if (strncmp (pos, "-", 1) == 0)
1433 {
1434 memcpy (number, ++pos, 2);
1435 lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16);
1436 pos -= 4;
1437 if (strncmp (pos, ".", 1) != 0)
1438 return CMD_ERR_AMBIGUOUS;
1439 }
1440 if (strncmp (pos, ".", 1) == 0)
1441 {
1442 memcpy (number, ++pos, 2);
1443 lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16);
1444 sysid[pos - argv - 1] = '\0';
1445 }
1446 }
1447
hasso3fdb2dd2005-09-28 18:45:54 +00001448 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof390d2c2004-09-10 20:48:21 +00001449 {
hassof390d2c2004-09-10 20:48:21 +00001450 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
Josh Bailey3f045a02012-03-24 08:35:20 -07001451 VTY_NEWLINE);
1452
hassof390d2c2004-09-10 20:48:21 +00001453 for (level = 0; level < ISIS_LEVELS; level++)
Josh Bailey3f045a02012-03-24 08:35:20 -07001454 {
1455 if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
1456 {
1457 lsp = NULL;
1458 if (argv != NULL)
1459 {
1460 /*
1461 * Try to find the lsp-id if the argv string is in
1462 * the form hostname.<pseudo-id>-<fragment>
1463 */
1464 if (sysid2buff (lspid, sysid))
1465 {
1466 lsp = lsp_search (lspid, area->lspdb[level]);
1467 }
1468 else if ((dynhn = dynhn_find_by_name (sysid)))
1469 {
1470 memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN);
1471 lsp = lsp_search (lspid, area->lspdb[level]);
1472 }
1473 else if (strncmp(unix_hostname (), sysid, 15) == 0)
1474 {
1475 memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
1476 lsp = lsp_search (lspid, area->lspdb[level]);
1477 }
1478 }
jardineb5d44e2003-12-23 08:09:43 +00001479
Josh Bailey3f045a02012-03-24 08:35:20 -07001480 if (lsp != NULL || argv == NULL)
1481 {
1482 vty_out (vty, "IS-IS Level-%d link-state database:%s",
1483 level + 1, VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +00001484
Josh Bailey3f045a02012-03-24 08:35:20 -07001485 /* print the title in all cases */
1486 vty_out (vty, "LSP ID PduLen "
1487 "SeqNumber Chksum Holdtime ATT/P/OL%s",
1488 VTY_NEWLINE);
1489 }
1490
1491 if (lsp)
1492 {
1493 if (ui_level == ISIS_UI_LEVEL_DETAIL)
1494 lsp_print_detail (lsp, vty, area->dynhostname);
1495 else
1496 lsp_print (lsp, vty, area->dynhostname);
1497 }
1498 else if (argv == NULL)
1499 {
1500 lsp_count = lsp_print_all (vty, area->lspdb[level],
1501 ui_level,
1502 area->dynhostname);
1503
1504 vty_out (vty, " %u LSPs%s%s",
1505 lsp_count, VTY_NEWLINE, VTY_NEWLINE);
1506 }
1507 }
1508 }
jardineb5d44e2003-12-23 08:09:43 +00001509 }
jardineb5d44e2003-12-23 08:09:43 +00001510
1511 return CMD_SUCCESS;
1512}
1513
Josh Bailey3f045a02012-03-24 08:35:20 -07001514DEFUN (show_database_brief,
1515 show_database_cmd,
1516 "show isis database",
1517 SHOW_STR
1518 "IS-IS information\n"
1519 "IS-IS link state database\n")
1520{
1521 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_BRIEF);
1522}
1523
1524DEFUN (show_database_lsp_brief,
1525 show_database_arg_cmd,
1526 "show isis database WORD",
1527 SHOW_STR
1528 "IS-IS information\n"
1529 "IS-IS link state database\n"
1530 "LSP ID\n")
1531{
1532 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_BRIEF);
1533}
1534
1535DEFUN (show_database_lsp_detail,
1536 show_database_arg_detail_cmd,
1537 "show isis database WORD detail",
1538 SHOW_STR
1539 "IS-IS information\n"
1540 "IS-IS link state database\n"
1541 "LSP ID\n"
1542 "Detailed information\n")
1543{
1544 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
1545}
1546
jardineb5d44e2003-12-23 08:09:43 +00001547DEFUN (show_database_detail,
1548 show_database_detail_cmd,
1549 "show isis database detail",
1550 SHOW_STR
1551 "IS-IS information\n"
1552 "IS-IS link state database\n")
1553{
Josh Bailey3f045a02012-03-24 08:35:20 -07001554 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_DETAIL);
1555}
jardineb5d44e2003-12-23 08:09:43 +00001556
Josh Bailey3f045a02012-03-24 08:35:20 -07001557DEFUN (show_database_detail_lsp,
1558 show_database_detail_arg_cmd,
1559 "show isis database detail WORD",
1560 SHOW_STR
1561 "IS-IS information\n"
1562 "IS-IS link state database\n"
1563 "Detailed information\n"
1564 "LSP ID\n")
1565{
1566 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
jardineb5d44e2003-12-23 08:09:43 +00001567}
1568
1569/*
1570 * 'router isis' command
1571 */
1572DEFUN (router_isis,
1573 router_isis_cmd,
1574 "router isis WORD",
hassof390d2c2004-09-10 20:48:21 +00001575 ROUTER_STR
jardineb5d44e2003-12-23 08:09:43 +00001576 "ISO IS-IS\n"
1577 "ISO Routing area tag")
1578{
jardineb5d44e2003-12-23 08:09:43 +00001579 return isis_area_get (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001580}
1581
1582/*
1583 *'no router isis' command
1584 */
1585DEFUN (no_router_isis,
1586 no_router_isis_cmd,
1587 "no router isis WORD",
hassof390d2c2004-09-10 20:48:21 +00001588 "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
jardineb5d44e2003-12-23 08:09:43 +00001589{
1590 return isis_area_destroy (vty, argv[0]);
1591}
1592
1593/*
1594 * 'net' command
1595 */
1596DEFUN (net,
1597 net_cmd,
1598 "net WORD",
1599 "A Network Entity Title for this process (OSI only)\n"
hassof390d2c2004-09-10 20:48:21 +00001600 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00001601{
Paul Jakma41b36e92006-12-08 01:09:50 +00001602 return area_net_title (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001603}
1604
jardineb5d44e2003-12-23 08:09:43 +00001605/*
1606 * 'no net' command
1607 */
1608DEFUN (no_net,
1609 no_net_cmd,
1610 "no net WORD",
1611 NO_STR
1612 "A Network Entity Title for this process (OSI only)\n"
hassof390d2c2004-09-10 20:48:21 +00001613 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00001614{
Paul Jakma41b36e92006-12-08 01:09:50 +00001615 return area_clear_net_title (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001616}
1617
Christian Franke304c7da2016-07-28 17:23:29 +02001618void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu)
Christian Frankef1fc1db2015-11-10 18:43:31 +01001619{
Christian Frankef1fc1db2015-11-10 18:43:31 +01001620 area->lsp_mtu = lsp_mtu;
1621 lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
Christian Frankef1fc1db2015-11-10 18:43:31 +01001622}
1623
Josh Bailey3f045a02012-03-24 08:35:20 -07001624DEFUN (area_passwd_md5,
1625 area_passwd_md5_cmd,
1626 "area-password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001627 "Configure the authentication password for an area\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001628 "Authentication type\n"
hassof390d2c2004-09-10 20:48:21 +00001629 "Area password\n")
jardineb5d44e2003-12-23 08:09:43 +00001630{
1631 struct isis_area *area;
1632 int len;
1633
1634 area = vty->index;
1635
hassof390d2c2004-09-10 20:48:21 +00001636 if (!area)
1637 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001638 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1639 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001640 }
1641
jardineb5d44e2003-12-23 08:09:43 +00001642 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001643 if (len > 254)
1644 {
1645 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001646 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001647 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001648
1649 area->area_passwd.len = (u_char) len;
1650 area->area_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1651 strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
1652
1653 if (argc > 1)
1654 {
1655 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1656 if (strncmp(argv[1], "v", 1) == 0)
1657 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1658 else
1659 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1660 }
1661 else
1662 {
1663 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1664 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1665 }
1666 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1667
1668 return CMD_SUCCESS;
1669}
1670
1671ALIAS (area_passwd_md5,
1672 area_passwd_md5_snpauth_cmd,
1673 "area-password md5 WORD authenticate snp (send-only|validate)",
1674 "Configure the authentication password for an area\n"
1675 "Authentication type\n"
1676 "Area password\n"
1677 "Authentication\n"
1678 "SNP PDUs\n"
1679 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001680 "Send and check PDUs on receiving\n")
Josh Bailey3f045a02012-03-24 08:35:20 -07001681
1682DEFUN (area_passwd_clear,
1683 area_passwd_clear_cmd,
1684 "area-password clear WORD",
1685 "Configure the authentication password for an area\n"
1686 "Authentication type\n"
1687 "Area password\n")
1688{
1689 struct isis_area *area;
1690 int len;
1691
1692 area = vty->index;
1693
1694 if (!area)
1695 {
1696 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1697 return CMD_ERR_NO_MATCH;
1698 }
1699
1700 len = strlen (argv[0]);
1701 if (len > 254)
1702 {
1703 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1704 return CMD_ERR_AMBIGUOUS;
1705 }
1706
hassof390d2c2004-09-10 20:48:21 +00001707 area->area_passwd.len = (u_char) len;
jardineb5d44e2003-12-23 08:09:43 +00001708 area->area_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001709 strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001710
hasso1cbc5622005-01-01 10:29:51 +00001711 if (argc > 1)
1712 {
1713 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1714 if (strncmp(argv[1], "v", 1) == 0)
1715 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1716 else
1717 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1718 }
1719 else
1720 {
1721 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1722 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1723 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001724 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hasso1cbc5622005-01-01 10:29:51 +00001725
jardineb5d44e2003-12-23 08:09:43 +00001726 return CMD_SUCCESS;
1727}
1728
Josh Bailey3f045a02012-03-24 08:35:20 -07001729ALIAS (area_passwd_clear,
1730 area_passwd_clear_snpauth_cmd,
1731 "area-password clear WORD authenticate snp (send-only|validate)",
hasso1cbc5622005-01-01 10:29:51 +00001732 "Configure the authentication password for an area\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001733 "Authentication type\n"
hasso1cbc5622005-01-01 10:29:51 +00001734 "Area password\n"
1735 "Authentication\n"
1736 "SNP PDUs\n"
1737 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001738 "Send and check PDUs on receiving\n")
hasso1cbc5622005-01-01 10:29:51 +00001739
jardineb5d44e2003-12-23 08:09:43 +00001740DEFUN (no_area_passwd,
1741 no_area_passwd_cmd,
1742 "no area-password",
1743 NO_STR
1744 "Configure the authentication password for an area\n")
1745{
1746 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00001747
jardineb5d44e2003-12-23 08:09:43 +00001748 area = vty->index;
1749
hassof390d2c2004-09-10 20:48:21 +00001750 if (!area)
1751 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001752 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1753 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001754 }
1755
jardineb5d44e2003-12-23 08:09:43 +00001756 memset (&area->area_passwd, 0, sizeof (struct isis_passwd));
Josh Bailey3f045a02012-03-24 08:35:20 -07001757 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
jardineb5d44e2003-12-23 08:09:43 +00001758
1759 return CMD_SUCCESS;
1760}
1761
Josh Bailey3f045a02012-03-24 08:35:20 -07001762DEFUN (domain_passwd_md5,
1763 domain_passwd_md5_cmd,
1764 "domain-password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001765 "Set the authentication password for a routing domain\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001766 "Authentication type\n"
hassof390d2c2004-09-10 20:48:21 +00001767 "Routing domain password\n")
jardineb5d44e2003-12-23 08:09:43 +00001768{
1769 struct isis_area *area;
1770 int len;
1771
1772 area = vty->index;
1773
hassof390d2c2004-09-10 20:48:21 +00001774 if (!area)
1775 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001776 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1777 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001778 }
1779
jardineb5d44e2003-12-23 08:09:43 +00001780 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001781 if (len > 254)
1782 {
1783 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001784 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001785 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001786
1787 area->domain_passwd.len = (u_char) len;
1788 area->domain_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1789 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
1790
1791 if (argc > 1)
1792 {
1793 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1794 if (strncmp(argv[1], "v", 1) == 0)
1795 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1796 else
1797 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1798 }
1799 else
1800 {
1801 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1802 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1803 }
1804 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1805
1806 return CMD_SUCCESS;
1807}
1808
1809ALIAS (domain_passwd_md5,
1810 domain_passwd_md5_snpauth_cmd,
1811 "domain-password md5 WORD authenticate snp (send-only|validate)",
1812 "Set the authentication password for a routing domain\n"
1813 "Authentication type\n"
1814 "Routing domain password\n"
1815 "Authentication\n"
1816 "SNP PDUs\n"
1817 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001818 "Send and check PDUs on receiving\n")
Josh Bailey3f045a02012-03-24 08:35:20 -07001819
1820DEFUN (domain_passwd_clear,
1821 domain_passwd_clear_cmd,
1822 "domain-password clear WORD",
1823 "Set the authentication password for a routing domain\n"
1824 "Authentication type\n"
1825 "Routing domain password\n")
1826{
1827 struct isis_area *area;
1828 int len;
1829
1830 area = vty->index;
1831
1832 if (!area)
1833 {
1834 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1835 return CMD_ERR_NO_MATCH;
1836 }
1837
1838 len = strlen (argv[0]);
1839 if (len > 254)
1840 {
1841 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1842 return CMD_ERR_AMBIGUOUS;
1843 }
1844
hassof390d2c2004-09-10 20:48:21 +00001845 area->domain_passwd.len = (u_char) len;
jardineb5d44e2003-12-23 08:09:43 +00001846 area->domain_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001847 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001848
hasso1cbc5622005-01-01 10:29:51 +00001849 if (argc > 1)
1850 {
1851 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1852 if (strncmp(argv[1], "v", 1) == 0)
1853 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1854 else
1855 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1856 }
1857 else
1858 {
1859 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1860 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1861 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001862 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hasso1cbc5622005-01-01 10:29:51 +00001863
jardineb5d44e2003-12-23 08:09:43 +00001864 return CMD_SUCCESS;
1865}
1866
Josh Bailey3f045a02012-03-24 08:35:20 -07001867ALIAS (domain_passwd_clear,
1868 domain_passwd_clear_snpauth_cmd,
1869 "domain-password clear WORD authenticate snp (send-only|validate)",
hasso1cbc5622005-01-01 10:29:51 +00001870 "Set the authentication password for a routing domain\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001871 "Authentication type\n"
hasso1cbc5622005-01-01 10:29:51 +00001872 "Routing domain password\n"
1873 "Authentication\n"
1874 "SNP PDUs\n"
1875 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001876 "Send and check PDUs on receiving\n")
hasso1cbc5622005-01-01 10:29:51 +00001877
jardineb5d44e2003-12-23 08:09:43 +00001878DEFUN (no_domain_passwd,
1879 no_domain_passwd_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07001880 "no domain-password",
jardineb5d44e2003-12-23 08:09:43 +00001881 NO_STR
1882 "Set the authentication password for a routing domain\n")
1883{
1884 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00001885
jardineb5d44e2003-12-23 08:09:43 +00001886 area = vty->index;
1887
hassof390d2c2004-09-10 20:48:21 +00001888 if (!area)
1889 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001890 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1891 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001892 }
1893
jardineb5d44e2003-12-23 08:09:43 +00001894 memset (&area->domain_passwd, 0, sizeof (struct isis_passwd));
Josh Bailey3f045a02012-03-24 08:35:20 -07001895 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hassof390d2c2004-09-10 20:48:21 +00001896
jardineb5d44e2003-12-23 08:09:43 +00001897 return CMD_SUCCESS;
1898}
1899
Christian Franke304c7da2016-07-28 17:23:29 +02001900static void
1901area_resign_level (struct isis_area *area, int level)
jardineb5d44e2003-12-23 08:09:43 +00001902{
Christian Franke304c7da2016-07-28 17:23:29 +02001903 if (area->lspdb[level - 1])
hassof390d2c2004-09-10 20:48:21 +00001904 {
Christian Franke304c7da2016-07-28 17:23:29 +02001905 lsp_db_destroy (area->lspdb[level - 1]);
1906 area->lspdb[level - 1] = NULL;
hassof390d2c2004-09-10 20:48:21 +00001907 }
Christian Franke304c7da2016-07-28 17:23:29 +02001908 if (area->spftree[level - 1])
hassof390d2c2004-09-10 20:48:21 +00001909 {
Christian Franke304c7da2016-07-28 17:23:29 +02001910 isis_spftree_del (area->spftree[level - 1]);
1911 area->spftree[level - 1] = NULL;
hassof390d2c2004-09-10 20:48:21 +00001912 }
Christian Franke304c7da2016-07-28 17:23:29 +02001913#ifdef HAVE_IPV6
1914 if (area->spftree6[level - 1])
1915 {
1916 isis_spftree_del (area->spftree6[level - 1]);
1917 area->spftree6[level - 1] = NULL;
1918 }
1919#endif
1920 if (area->route_table[level - 1])
1921 {
1922 route_table_finish (area->route_table[level - 1]);
1923 area->route_table[level - 1] = NULL;
1924 }
1925#ifdef HAVE_IPV6
1926 if (area->route_table6[level - 1])
1927 {
1928 route_table_finish (area->route_table6[level - 1]);
1929 area->route_table6[level - 1] = NULL;
1930 }
1931#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +00001932
Christian Franke304c7da2016-07-28 17:23:29 +02001933 sched_debug("ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
1934 area->area_tag, level);
1935 THREAD_TIMER_OFF (area->t_lsp_refresh[level - 1]);
1936 area->lsp_regenerate_pending[level - 1] = 0;
jardineb5d44e2003-12-23 08:09:43 +00001937}
1938
Christian Franke304c7da2016-07-28 17:23:29 +02001939void
1940isis_area_is_type_set(struct isis_area *area, int is_type)
jardineb5d44e2003-12-23 08:09:43 +00001941{
Christian Franke304c7da2016-07-28 17:23:29 +02001942 struct listnode *node;
1943 struct isis_circuit *circuit;
jardineb5d44e2003-12-23 08:09:43 +00001944
Christian Franke304c7da2016-07-28 17:23:29 +02001945 if (isis->debugs & DEBUG_EVENTS)
1946 zlog_debug ("ISIS-Evt (%s) system type change %s -> %s", area->area_tag,
1947 circuit_t2string (area->is_type), circuit_t2string (is_type));
hassof390d2c2004-09-10 20:48:21 +00001948
Christian Franke304c7da2016-07-28 17:23:29 +02001949 if (area->is_type == is_type)
1950 return; /* No change */
jardineb5d44e2003-12-23 08:09:43 +00001951
Christian Franke304c7da2016-07-28 17:23:29 +02001952 switch (area->is_type)
1953 {
1954 case IS_LEVEL_1:
1955 if (is_type == IS_LEVEL_2)
1956 area_resign_level (area, IS_LEVEL_1);
jardineb5d44e2003-12-23 08:09:43 +00001957
Christian Franke304c7da2016-07-28 17:23:29 +02001958 if (area->lspdb[1] == NULL)
1959 area->lspdb[1] = lsp_db_init ();
1960 if (area->route_table[1] == NULL)
1961 area->route_table[1] = route_table_init ();
1962#ifdef HAVE_IPV6
1963 if (area->route_table6[1] == NULL)
1964 area->route_table6[1] = route_table_init ();
1965#endif /* HAVE_IPV6 */
1966 break;
1967
1968 case IS_LEVEL_1_AND_2:
1969 if (is_type == IS_LEVEL_1)
1970 area_resign_level (area, IS_LEVEL_2);
1971 else
1972 area_resign_level (area, IS_LEVEL_1);
1973 break;
1974
1975 case IS_LEVEL_2:
1976 if (is_type == IS_LEVEL_1)
1977 area_resign_level (area, IS_LEVEL_2);
1978
1979 if (area->lspdb[0] == NULL)
1980 area->lspdb[0] = lsp_db_init ();
1981 if (area->route_table[0] == NULL)
1982 area->route_table[0] = route_table_init ();
1983#ifdef HAVE_IPV6
1984 if (area->route_table6[0] == NULL)
1985 area->route_table6[0] = route_table_init ();
1986#endif /* HAVE_IPV6 */
1987 break;
1988
1989 default:
1990 break;
1991 }
1992
1993 area->is_type = is_type;
1994
1995 /* override circuit's is_type */
1996 if (area->is_type != IS_LEVEL_1_AND_2)
1997 {
1998 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
1999 isis_event_circuit_type_change (circuit, is_type);
2000 }
2001
2002 spftree_area_init (area);
2003
2004 if (is_type & IS_LEVEL_1)
2005 lsp_generate (area, IS_LEVEL_1);
2006 if (is_type & IS_LEVEL_2)
2007 lsp_generate (area, IS_LEVEL_2);
2008 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2009
2010 return;
jardineb5d44e2003-12-23 08:09:43 +00002011}
2012
Josh Bailey3f045a02012-03-24 08:35:20 -07002013static int
2014set_lsp_gen_interval (struct vty *vty, struct isis_area *area,
2015 uint16_t interval, int level)
2016{
2017 int lvl;
2018
2019 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2020 {
2021 if (!(lvl & level))
2022 continue;
2023
2024 if (interval >= area->lsp_refresh[lvl-1])
2025 {
2026 vty_out (vty, "LSP gen interval %us must be less than "
2027 "the LSP refresh interval %us%s",
2028 interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
2029 return CMD_ERR_AMBIGUOUS;
2030 }
2031 }
2032
2033 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2034 {
2035 if (!(lvl & level))
2036 continue;
2037 area->lsp_gen_interval[lvl-1] = interval;
2038 }
2039
2040 return CMD_SUCCESS;
2041}
2042
jardineb5d44e2003-12-23 08:09:43 +00002043DEFUN (lsp_gen_interval,
2044 lsp_gen_interval_cmd,
2045 "lsp-gen-interval <1-120>",
2046 "Minimum interval between regenerating same LSP\n"
2047 "Minimum interval in seconds\n")
2048{
2049 struct isis_area *area;
2050 uint16_t interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002051 int level;
jardineb5d44e2003-12-23 08:09:43 +00002052
2053 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002054 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002055 level = IS_LEVEL_1 | IS_LEVEL_2;
2056 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002057}
2058
2059DEFUN (no_lsp_gen_interval,
2060 no_lsp_gen_interval_cmd,
2061 "no lsp-gen-interval",
2062 NO_STR
hassof390d2c2004-09-10 20:48:21 +00002063 "Minimum interval between regenerating same LSP\n")
jardineb5d44e2003-12-23 08:09:43 +00002064{
2065 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002066 uint16_t interval;
2067 int level;
jardineb5d44e2003-12-23 08:09:43 +00002068
2069 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002070 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2071 level = IS_LEVEL_1 | IS_LEVEL_2;
2072 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002073}
2074
2075ALIAS (no_lsp_gen_interval,
2076 no_lsp_gen_interval_arg_cmd,
2077 "no lsp-gen-interval <1-120>",
2078 NO_STR
2079 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002080 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002081
2082DEFUN (lsp_gen_interval_l1,
2083 lsp_gen_interval_l1_cmd,
2084 "lsp-gen-interval level-1 <1-120>",
2085 "Minimum interval between regenerating same LSP\n"
2086 "Set interval for level 1 only\n"
hassof390d2c2004-09-10 20:48:21 +00002087 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002088{
2089 struct isis_area *area;
2090 uint16_t interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002091 int level;
jardineb5d44e2003-12-23 08:09:43 +00002092
2093 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002094 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002095 level = IS_LEVEL_1;
2096 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002097}
2098
2099DEFUN (no_lsp_gen_interval_l1,
2100 no_lsp_gen_interval_l1_cmd,
2101 "no lsp-gen-interval level-1",
2102 NO_STR
2103 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002104 "Set interval for level 1 only\n")
jardineb5d44e2003-12-23 08:09:43 +00002105{
2106 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002107 uint16_t interval;
2108 int level;
jardineb5d44e2003-12-23 08:09:43 +00002109
2110 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002111 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2112 level = IS_LEVEL_1;
2113 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002114}
2115
2116ALIAS (no_lsp_gen_interval_l1,
2117 no_lsp_gen_interval_l1_arg_cmd,
2118 "no lsp-gen-interval level-1 <1-120>",
2119 NO_STR
2120 "Minimum interval between regenerating same LSP\n"
2121 "Set interval for level 1 only\n"
hassof390d2c2004-09-10 20:48:21 +00002122 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002123
2124DEFUN (lsp_gen_interval_l2,
2125 lsp_gen_interval_l2_cmd,
2126 "lsp-gen-interval level-2 <1-120>",
2127 "Minimum interval between regenerating same LSP\n"
2128 "Set interval for level 2 only\n"
hassof390d2c2004-09-10 20:48:21 +00002129 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002130{
2131 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002132 uint16_t interval;
2133 int level;
jardineb5d44e2003-12-23 08:09:43 +00002134
2135 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002136 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002137 level = IS_LEVEL_2;
2138 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002139}
2140
2141DEFUN (no_lsp_gen_interval_l2,
2142 no_lsp_gen_interval_l2_cmd,
2143 "no lsp-gen-interval level-2",
2144 NO_STR
2145 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002146 "Set interval for level 2 only\n")
jardineb5d44e2003-12-23 08:09:43 +00002147{
2148 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002149 uint16_t interval;
2150 int level;
jardineb5d44e2003-12-23 08:09:43 +00002151
2152 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002153 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2154 level = IS_LEVEL_2;
2155 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002156}
2157
2158ALIAS (no_lsp_gen_interval_l2,
2159 no_lsp_gen_interval_l2_arg_cmd,
2160 "no lsp-gen-interval level-2 <1-120>",
2161 NO_STR
2162 "Minimum interval between regenerating same LSP\n"
2163 "Set interval for level 2 only\n"
hassof390d2c2004-09-10 20:48:21 +00002164 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002165
Christian Frankeccd485d2016-07-28 17:23:26 +02002166void isis_area_metricstyle_set(struct isis_area *area, bool old_metric,
2167 bool new_metric)
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002168{
Christian Frankeccd485d2016-07-28 17:23:26 +02002169 if (area->oldmetric != old_metric
2170 || area->newmetric != new_metric)
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002171 {
Christian Frankeccd485d2016-07-28 17:23:26 +02002172 area->oldmetric = old_metric;
2173 area->newmetric = new_metric;
2174 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002175 }
Christian Frankeccd485d2016-07-28 17:23:26 +02002176}
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002177
Christian Frankeccd485d2016-07-28 17:23:26 +02002178void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit)
2179{
2180 char new_overload_bit = overload_bit ? LSPBIT_OL : 0;
2181
2182 if (new_overload_bit != area->overload_bit)
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002183 {
Christian Frankeccd485d2016-07-28 17:23:26 +02002184 area->overload_bit = new_overload_bit;
2185 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002186 }
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002187}
2188
Christian Frankeccd485d2016-07-28 17:23:26 +02002189void isis_area_attached_bit_set(struct isis_area *area, bool attached_bit)
jardineb5d44e2003-12-23 08:09:43 +00002190{
Christian Frankeccd485d2016-07-28 17:23:26 +02002191 char new_attached_bit = attached_bit ? LSPBIT_ATT : 0;
jardineb5d44e2003-12-23 08:09:43 +00002192
Christian Frankeccd485d2016-07-28 17:23:26 +02002193 if (new_attached_bit != area->attached_bit)
hasso2984d262005-09-26 16:49:07 +00002194 {
Christian Frankeccd485d2016-07-28 17:23:26 +02002195 area->attached_bit = new_attached_bit;
2196 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hasso2984d262005-09-26 16:49:07 +00002197 }
Christian Frankeccd485d2016-07-28 17:23:26 +02002198}
2199
2200void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname)
2201{
2202 if (area->dynhostname != dynhostname)
hasso2984d262005-09-26 16:49:07 +00002203 {
Christian Frankeccd485d2016-07-28 17:23:26 +02002204 area->dynhostname = dynhostname;
2205 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
hasso2984d262005-09-26 16:49:07 +00002206 }
jardineb5d44e2003-12-23 08:09:43 +00002207}
2208
2209DEFUN (spf_interval,
2210 spf_interval_cmd,
2211 "spf-interval <1-120>",
hasso2097cd82003-12-23 11:51:08 +00002212 "Minimum interval between SPF calculations\n"
jardineb5d44e2003-12-23 08:09:43 +00002213 "Minimum interval between consecutive SPFs in seconds\n")
2214{
2215 struct isis_area *area;
2216 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002217
jardineb5d44e2003-12-23 08:09:43 +00002218 area = vty->index;
2219 interval = atoi (argv[0]);
2220 area->min_spf_interval[0] = interval;
2221 area->min_spf_interval[1] = interval;
hassof390d2c2004-09-10 20:48:21 +00002222
jardineb5d44e2003-12-23 08:09:43 +00002223 return CMD_SUCCESS;
2224}
2225
2226DEFUN (no_spf_interval,
2227 no_spf_interval_cmd,
2228 "no spf-interval",
2229 NO_STR
hassof390d2c2004-09-10 20:48:21 +00002230 "Minimum interval between SPF calculations\n")
jardineb5d44e2003-12-23 08:09:43 +00002231{
2232 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002233
jardineb5d44e2003-12-23 08:09:43 +00002234 area = vty->index;
2235
2236 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
2237 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002238
jardineb5d44e2003-12-23 08:09:43 +00002239 return CMD_SUCCESS;
2240}
2241
2242ALIAS (no_spf_interval,
2243 no_spf_interval_arg_cmd,
2244 "no spf-interval <1-120>",
2245 NO_STR
2246 "Minimum interval between SPF calculations\n"
hassof390d2c2004-09-10 20:48:21 +00002247 "Minimum interval between consecutive SPFs in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002248
2249DEFUN (spf_interval_l1,
2250 spf_interval_l1_cmd,
2251 "spf-interval level-1 <1-120>",
2252 "Minimum interval between SPF calculations\n"
2253 "Set interval for level 1 only\n"
2254 "Minimum interval between consecutive SPFs in seconds\n")
2255{
2256 struct isis_area *area;
2257 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002258
jardineb5d44e2003-12-23 08:09:43 +00002259 area = vty->index;
2260 interval = atoi (argv[0]);
2261 area->min_spf_interval[0] = interval;
hassof390d2c2004-09-10 20:48:21 +00002262
jardineb5d44e2003-12-23 08:09:43 +00002263 return CMD_SUCCESS;
2264}
2265
2266DEFUN (no_spf_interval_l1,
2267 no_spf_interval_l1_cmd,
2268 "no spf-interval level-1",
2269 NO_STR
2270 "Minimum interval between SPF calculations\n"
2271 "Set interval for level 1 only\n")
2272{
2273 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002274
jardineb5d44e2003-12-23 08:09:43 +00002275 area = vty->index;
2276
2277 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002278
jardineb5d44e2003-12-23 08:09:43 +00002279 return CMD_SUCCESS;
2280}
2281
2282ALIAS (no_spf_interval,
2283 no_spf_interval_l1_arg_cmd,
2284 "no spf-interval level-1 <1-120>",
2285 NO_STR
2286 "Minimum interval between SPF calculations\n"
2287 "Set interval for level 1 only\n"
2288 "Minimum interval between consecutive SPFs in seconds\n")
2289
2290DEFUN (spf_interval_l2,
2291 spf_interval_l2_cmd,
2292 "spf-interval level-2 <1-120>",
2293 "Minimum interval between SPF calculations\n"
2294 "Set interval for level 2 only\n"
2295 "Minimum interval between consecutive SPFs in seconds\n")
2296{
2297 struct isis_area *area;
2298 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002299
jardineb5d44e2003-12-23 08:09:43 +00002300 area = vty->index;
2301 interval = atoi (argv[0]);
2302 area->min_spf_interval[1] = interval;
hassof390d2c2004-09-10 20:48:21 +00002303
jardineb5d44e2003-12-23 08:09:43 +00002304 return CMD_SUCCESS;
2305}
2306
2307DEFUN (no_spf_interval_l2,
2308 no_spf_interval_l2_cmd,
2309 "no spf-interval level-2",
2310 NO_STR
2311 "Minimum interval between SPF calculations\n"
2312 "Set interval for level 2 only\n")
2313{
2314 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002315
jardineb5d44e2003-12-23 08:09:43 +00002316 area = vty->index;
2317
2318 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002319
jardineb5d44e2003-12-23 08:09:43 +00002320 return CMD_SUCCESS;
2321}
2322
2323ALIAS (no_spf_interval,
2324 no_spf_interval_l2_arg_cmd,
2325 "no spf-interval level-2 <1-120>",
2326 NO_STR
2327 "Minimum interval between SPF calculations\n"
2328 "Set interval for level 2 only\n"
2329 "Minimum interval between consecutive SPFs in seconds\n")
2330
Josh Bailey3f045a02012-03-24 08:35:20 -07002331static int
2332set_lsp_max_lifetime (struct vty *vty, struct isis_area *area,
2333 uint16_t interval, int level)
2334{
2335 int lvl;
2336 int set_refresh_interval[ISIS_LEVELS] = {0, 0};
2337 uint16_t refresh_interval;
2338
2339 refresh_interval = interval - 300;
2340
2341 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
2342 {
2343 if (!(lvl & level))
2344 continue;
2345 if (refresh_interval < area->lsp_refresh[lvl-1])
2346 {
2347 vty_out (vty, "Level %d Max LSP lifetime %us must be 300s greater than "
2348 "the configured LSP refresh interval %us%s",
2349 lvl, interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
2350 vty_out (vty, "Automatically reducing level %d LSP refresh interval "
2351 "to %us%s", lvl, refresh_interval, VTY_NEWLINE);
2352 set_refresh_interval[lvl-1] = 1;
2353
2354 if (refresh_interval <= area->lsp_gen_interval[lvl-1])
2355 {
2356 vty_out (vty, "LSP refresh interval %us must be greater than "
2357 "the configured LSP gen interval %us%s",
2358 refresh_interval, area->lsp_gen_interval[lvl-1],
2359 VTY_NEWLINE);
2360 return CMD_ERR_AMBIGUOUS;
2361 }
2362 }
2363 }
2364
2365 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
2366 {
2367 if (!(lvl & level))
2368 continue;
2369 area->max_lsp_lifetime[lvl-1] = interval;
2370 /* Automatically reducing lsp_refresh_interval to interval - 300 */
2371 if (set_refresh_interval[lvl-1])
2372 area->lsp_refresh[lvl-1] = refresh_interval;
2373 }
2374
2375 lsp_regenerate_schedule (area, level, 1);
2376
2377 return CMD_SUCCESS;
2378}
2379
2380DEFUN (max_lsp_lifetime,
2381 max_lsp_lifetime_cmd,
2382 "max-lsp-lifetime <350-65535>",
2383 "Maximum LSP lifetime\n"
2384 "LSP lifetime in seconds\n")
2385{
2386 struct isis_area *area;
2387 uint16_t interval;
2388 int level;
2389
2390 area = vty->index;
2391 interval = atoi (argv[0]);
2392 level = IS_LEVEL_1 | IS_LEVEL_2;
2393 return set_lsp_max_lifetime (vty, area, interval, level);
2394}
2395
2396DEFUN (no_max_lsp_lifetime,
2397 no_max_lsp_lifetime_cmd,
2398 "no max-lsp-lifetime",
2399 NO_STR
2400 "LSP lifetime in seconds\n")
2401{
2402 struct isis_area *area;
2403 uint16_t interval;
2404 int level;
2405
2406 area = vty->index;
2407 interval = DEFAULT_LSP_LIFETIME;
2408 level = IS_LEVEL_1 | IS_LEVEL_2;
2409 return set_lsp_max_lifetime (vty, area, interval, level);
2410}
2411
2412ALIAS (no_max_lsp_lifetime,
2413 no_max_lsp_lifetime_arg_cmd,
2414 "no max-lsp-lifetime <350-65535>",
2415 NO_STR
2416 "Maximum LSP lifetime\n"
2417 "LSP lifetime in seconds\n")
2418
2419DEFUN (max_lsp_lifetime_l1,
2420 max_lsp_lifetime_l1_cmd,
2421 "max-lsp-lifetime level-1 <350-65535>",
2422 "Maximum LSP lifetime for Level 1 only\n"
2423 "LSP lifetime for Level 1 only in seconds\n")
2424{
2425 struct isis_area *area;
2426 uint16_t interval;
2427 int level;
2428
2429 area = vty->index;
2430 interval = atoi (argv[0]);
2431 level = IS_LEVEL_1;
2432 return set_lsp_max_lifetime (vty, area, interval, level);
2433}
2434
2435DEFUN (no_max_lsp_lifetime_l1,
2436 no_max_lsp_lifetime_l1_cmd,
2437 "no max-lsp-lifetime level-1",
2438 NO_STR
2439 "LSP lifetime for Level 1 only in seconds\n")
2440{
2441 struct isis_area *area;
2442 uint16_t interval;
2443 int level;
2444
2445 area = vty->index;
2446 interval = DEFAULT_LSP_LIFETIME;
2447 level = IS_LEVEL_1;
2448 return set_lsp_max_lifetime (vty, area, interval, level);
2449}
2450
2451ALIAS (no_max_lsp_lifetime_l1,
2452 no_max_lsp_lifetime_l1_arg_cmd,
2453 "no max-lsp-lifetime level-1 <350-65535>",
2454 NO_STR
2455 "Maximum LSP lifetime for Level 1 only\n"
2456 "LSP lifetime for Level 1 only in seconds\n")
2457
2458DEFUN (max_lsp_lifetime_l2,
2459 max_lsp_lifetime_l2_cmd,
2460 "max-lsp-lifetime level-2 <350-65535>",
2461 "Maximum LSP lifetime for Level 2 only\n"
2462 "LSP lifetime for Level 2 only in seconds\n")
2463{
2464 struct isis_area *area;
2465 uint16_t interval;
2466 int level;
2467
2468 area = vty->index;
2469 interval = atoi (argv[0]);
2470 level = IS_LEVEL_2;
2471 return set_lsp_max_lifetime (vty, area, interval, level);
2472}
2473
2474DEFUN (no_max_lsp_lifetime_l2,
2475 no_max_lsp_lifetime_l2_cmd,
2476 "no max-lsp-lifetime level-2",
2477 NO_STR
2478 "LSP lifetime for Level 2 only in seconds\n")
2479{
2480 struct isis_area *area;
2481 uint16_t interval;
2482 int level;
2483
2484 area = vty->index;
2485 interval = DEFAULT_LSP_LIFETIME;
2486 level = IS_LEVEL_2;
2487 return set_lsp_max_lifetime (vty, area, interval, level);
2488}
2489
2490ALIAS (no_max_lsp_lifetime_l2,
2491 no_max_lsp_lifetime_l2_arg_cmd,
2492 "no max-lsp-lifetime level-2 <350-65535>",
2493 NO_STR
2494 "Maximum LSP lifetime for Level 2 only\n"
2495 "LSP lifetime for Level 2 only in seconds\n")
2496
2497static int
2498set_lsp_refresh_interval (struct vty *vty, struct isis_area *area,
2499 uint16_t interval, int level)
2500{
2501 int lvl;
2502
2503 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2504 {
2505 if (!(lvl & level))
2506 continue;
2507 if (interval <= area->lsp_gen_interval[lvl-1])
2508 {
2509 vty_out (vty, "LSP refresh interval %us must be greater than "
2510 "the configured LSP gen interval %us%s",
2511 interval, area->lsp_gen_interval[lvl-1],
2512 VTY_NEWLINE);
2513 return CMD_ERR_AMBIGUOUS;
2514 }
2515 if (interval > (area->max_lsp_lifetime[lvl-1] - 300))
2516 {
2517 vty_out (vty, "LSP refresh interval %us must be less than "
2518 "the configured LSP lifetime %us less 300%s",
2519 interval, area->max_lsp_lifetime[lvl-1],
2520 VTY_NEWLINE);
2521 return CMD_ERR_AMBIGUOUS;
2522 }
2523 }
2524
2525 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2526 {
2527 if (!(lvl & level))
2528 continue;
2529 area->lsp_refresh[lvl-1] = interval;
2530 }
2531 lsp_regenerate_schedule (area, level, 1);
2532
2533 return CMD_SUCCESS;
2534}
2535
2536DEFUN (lsp_refresh_interval,
2537 lsp_refresh_interval_cmd,
2538 "lsp-refresh-interval <1-65235>",
2539 "LSP refresh interval\n"
2540 "LSP refresh interval in seconds\n")
2541{
2542 struct isis_area *area;
2543 uint16_t interval;
2544 int level;
2545
2546 area = vty->index;
2547 interval = atoi (argv[0]);
2548 level = IS_LEVEL_1 | IS_LEVEL_2;
2549 return set_lsp_refresh_interval (vty, area, interval, level);
2550}
2551
2552DEFUN (no_lsp_refresh_interval,
2553 no_lsp_refresh_interval_cmd,
2554 "no lsp-refresh-interval",
2555 NO_STR
2556 "LSP refresh interval in seconds\n")
2557{
2558 struct isis_area *area;
2559 uint16_t interval;
2560 int level;
2561
2562 area = vty->index;
2563 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2564 level = IS_LEVEL_1 | IS_LEVEL_2;
2565 return set_lsp_refresh_interval (vty, area, interval, level);
2566}
2567
2568ALIAS (no_lsp_refresh_interval,
2569 no_lsp_refresh_interval_arg_cmd,
2570 "no lsp-refresh-interval <1-65235>",
2571 NO_STR
2572 "LSP refresh interval\n"
2573 "LSP refresh interval in seconds\n")
2574
2575DEFUN (lsp_refresh_interval_l1,
2576 lsp_refresh_interval_l1_cmd,
2577 "lsp-refresh-interval level-1 <1-65235>",
2578 "LSP refresh interval for Level 1 only\n"
2579 "LSP refresh interval for Level 1 only in seconds\n")
2580{
2581 struct isis_area *area;
2582 uint16_t interval;
2583 int level;
2584
2585 area = vty->index;
2586 interval = atoi (argv[0]);
2587 level = IS_LEVEL_1;
2588 return set_lsp_refresh_interval (vty, area, interval, level);
2589}
2590
2591DEFUN (no_lsp_refresh_interval_l1,
2592 no_lsp_refresh_interval_l1_cmd,
2593 "no lsp-refresh-interval level-1",
2594 NO_STR
2595 "LSP refresh interval for Level 1 only in seconds\n")
2596{
2597 struct isis_area *area;
2598 uint16_t interval;
2599 int level;
2600
2601 area = vty->index;
2602 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2603 level = IS_LEVEL_1;
2604 return set_lsp_refresh_interval (vty, area, interval, level);
2605}
2606
2607ALIAS (no_lsp_refresh_interval_l1,
2608 no_lsp_refresh_interval_l1_arg_cmd,
2609 "no lsp-refresh-interval level-1 <1-65235>",
2610 NO_STR
2611 "LSP refresh interval for Level 1 only\n"
2612 "LSP refresh interval for Level 1 only in seconds\n")
2613
2614DEFUN (lsp_refresh_interval_l2,
2615 lsp_refresh_interval_l2_cmd,
2616 "lsp-refresh-interval level-2 <1-65235>",
2617 "LSP refresh interval for Level 2 only\n"
2618 "LSP refresh interval for Level 2 only in seconds\n")
2619{
2620 struct isis_area *area;
2621 uint16_t interval;
2622 int level;
2623
2624 area = vty->index;
2625 interval = atoi (argv[0]);
2626 level = IS_LEVEL_2;
2627 return set_lsp_refresh_interval (vty, area, interval, level);
2628}
2629
2630DEFUN (no_lsp_refresh_interval_l2,
2631 no_lsp_refresh_interval_l2_cmd,
2632 "no lsp-refresh-interval level-2",
2633 NO_STR
2634 "LSP refresh interval for Level 2 only in seconds\n")
2635{
2636 struct isis_area *area;
2637 uint16_t interval;
2638 int level;
2639
2640 area = vty->index;
2641 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2642 level = IS_LEVEL_2;
2643 return set_lsp_refresh_interval (vty, area, interval, level);
2644}
2645
2646ALIAS (no_lsp_refresh_interval_l2,
2647 no_lsp_refresh_interval_l2_arg_cmd,
2648 "no lsp-refresh-interval level-2 <1-65235>",
2649 NO_STR
2650 "LSP refresh interval for Level 2 only\n"
2651 "LSP refresh interval for Level 2 only in seconds\n")
2652
2653DEFUN (log_adj_changes,
2654 log_adj_changes_cmd,
2655 "log-adjacency-changes",
2656 "Log changes in adjacency state\n")
2657{
2658 struct isis_area *area;
2659
2660 area = vty->index;
2661 assert (area);
2662
2663 area->log_adj_changes = 1;
2664
2665 return CMD_SUCCESS;
2666}
2667
2668DEFUN (no_log_adj_changes,
2669 no_log_adj_changes_cmd,
2670 "no log-adjacency-changes",
2671 "Stop logging changes in adjacency state\n")
2672{
2673 struct isis_area *area;
2674
2675 area = vty->index;
2676 assert (area);
2677
2678 area->log_adj_changes = 0;
2679
2680 return CMD_SUCCESS;
2681}
2682
jardineb5d44e2003-12-23 08:09:43 +00002683#ifdef TOPOLOGY_GENERATE
Josh Bailey3f045a02012-03-24 08:35:20 -07002684
jardineb5d44e2003-12-23 08:09:43 +00002685DEFUN (topology_generate_grid,
2686 topology_generate_grid_cmd,
2687 "topology generate grid <1-100> <1-100> <1-65000> [param] [param] "
2688 "[param]",
hassof1082d12005-09-19 04:23:34 +00002689 "Topology generation for IS-IS\n"
2690 "Topology generation\n"
2691 "Grid topology\n"
jardineb5d44e2003-12-23 08:09:43 +00002692 "X parameter of the grid\n"
2693 "Y parameter of the grid\n"
2694 "Random seed\n"
2695 "Optional param 1\n"
2696 "Optional param 2\n"
2697 "Optional param 3\n"
2698 "Topology\n")
2699{
2700 struct isis_area *area;
2701
2702 area = vty->index;
2703 assert (area);
2704
hassof390d2c2004-09-10 20:48:21 +00002705 if (!spgrid_check_params (vty, argc, argv))
2706 {
2707 if (area->topology)
2708 list_delete (area->topology);
2709 area->topology = list_new ();
2710 memcpy (area->top_params, vty->buf, 200);
2711 gen_spgrid_topology (vty, area->topology);
2712 remove_topology_lsps (area);
2713 generate_topology_lsps (area);
hassof1082d12005-09-19 04:23:34 +00002714 /* Regenerate L1 LSP to get two way connection to the generated
2715 * topology. */
Josh Bailey3f045a02012-03-24 08:35:20 -07002716 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hassof390d2c2004-09-10 20:48:21 +00002717 }
jardineb5d44e2003-12-23 08:09:43 +00002718
2719 return CMD_SUCCESS;
2720}
2721
hassof695b012005-04-02 19:03:39 +00002722DEFUN (show_isis_generated_topology,
2723 show_isis_generated_topology_cmd,
hassof1082d12005-09-19 04:23:34 +00002724 "show isis generated-topologies",
jardineb5d44e2003-12-23 08:09:43 +00002725 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -07002726 "ISIS network information\n"
hassof1082d12005-09-19 04:23:34 +00002727 "Show generated topologies\n")
jardineb5d44e2003-12-23 08:09:43 +00002728{
2729 struct isis_area *area;
paul92c9f222005-05-25 12:21:13 +00002730 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +00002731 struct listnode *node2;
2732 struct arc *arc;
hassof1082d12005-09-19 04:23:34 +00002733
paul92c9f222005-05-25 12:21:13 +00002734 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof1082d12005-09-19 04:23:34 +00002735 {
2736 if (!area->topology)
2737 continue;
2738
2739 vty_out (vty, "Topology for isis area: %s%s", area->area_tag,
2740 VTY_NEWLINE);
2741 vty_out (vty, "From node To node Distance%s", VTY_NEWLINE);
2742
2743 for (ALL_LIST_ELEMENTS_RO (area->topology, node2, arc))
2744 vty_out (vty, "%9ld %11ld %12ld%s", arc->from_node, arc->to_node,
2745 arc->distance, VTY_NEWLINE);
2746 }
jardineb5d44e2003-12-23 08:09:43 +00002747 return CMD_SUCCESS;
2748}
2749
hassof1082d12005-09-19 04:23:34 +00002750/* Base IS for topology generation. */
hassof390d2c2004-09-10 20:48:21 +00002751DEFUN (topology_baseis,
jardineb5d44e2003-12-23 08:09:43 +00002752 topology_baseis_cmd,
2753 "topology base-is WORD",
hassof1082d12005-09-19 04:23:34 +00002754 "Topology generation for IS-IS\n"
2755 "A Network IS Base for this topology\n"
2756 "XXXX.XXXX.XXXX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00002757{
2758 struct isis_area *area;
2759 u_char buff[ISIS_SYS_ID_LEN];
2760
2761 area = vty->index;
2762 assert (area);
2763
hassof390d2c2004-09-10 20:48:21 +00002764 if (sysid2buff (buff, argv[0]))
hassof1082d12005-09-19 04:23:34 +00002765 sysid2buff (area->topology_baseis, argv[0]);
hassof390d2c2004-09-10 20:48:21 +00002766
jardineb5d44e2003-12-23 08:09:43 +00002767 return CMD_SUCCESS;
2768}
2769
jardineb5d44e2003-12-23 08:09:43 +00002770DEFUN (no_topology_baseis,
2771 no_topology_baseis_cmd,
2772 "no topology base-is WORD",
2773 NO_STR
hassof1082d12005-09-19 04:23:34 +00002774 "Topology generation for IS-IS\n"
2775 "A Network IS Base for this topology\n"
2776 "XXXX.XXXX.XXXX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00002777{
2778 struct isis_area *area;
2779
2780 area = vty->index;
2781 assert (area);
2782
hassof390d2c2004-09-10 20:48:21 +00002783 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
jardineb5d44e2003-12-23 08:09:43 +00002784 return CMD_SUCCESS;
2785}
2786
hassof1082d12005-09-19 04:23:34 +00002787ALIAS (no_topology_baseis,
2788 no_topology_baseis_noid_cmd,
2789 "no topology base-is",
2790 NO_STR
2791 "Topology generation for IS-IS\n"
2792 "A Network IS Base for this topology\n")
2793
2794DEFUN (topology_basedynh,
2795 topology_basedynh_cmd,
2796 "topology base-dynh WORD",
2797 "Topology generation for IS-IS\n"
2798 "Dynamic hostname base for this topology\n"
2799 "Dynamic hostname base\n")
2800{
2801 struct isis_area *area;
2802
2803 area = vty->index;
2804 assert (area);
2805
2806 /* I hope that it's enough. */
2807 area->topology_basedynh = strndup (argv[0], 16);
2808 return CMD_SUCCESS;
2809}
Josh Bailey3f045a02012-03-24 08:35:20 -07002810
jardineb5d44e2003-12-23 08:09:43 +00002811#endif /* TOPOLOGY_GENERATE */
2812
jardineb5d44e2003-12-23 08:09:43 +00002813/* IS-IS configuration write function */
2814int
2815isis_config_write (struct vty *vty)
2816{
2817 int write = 0;
jardineb5d44e2003-12-23 08:09:43 +00002818
hassof390d2c2004-09-10 20:48:21 +00002819 if (isis != NULL)
2820 {
2821 struct isis_area *area;
hasso3fdb2dd2005-09-28 18:45:54 +00002822 struct listnode *node, *node2;
jardineb5d44e2003-12-23 08:09:43 +00002823
hasso3fdb2dd2005-09-28 18:45:54 +00002824 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof390d2c2004-09-10 20:48:21 +00002825 {
2826 /* ISIS - Area name */
2827 vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
2828 write++;
2829 /* ISIS - Net */
2830 if (listcount (area->area_addrs) > 0)
2831 {
2832 struct area_addr *area_addr;
hasso3fdb2dd2005-09-28 18:45:54 +00002833 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
2834 {
2835 vty_out (vty, " net %s%s",
2836 isonet_print (area_addr->area_addr,
2837 area_addr->addr_len + ISIS_SYS_ID_LEN +
2838 1), VTY_NEWLINE);
2839 write++;
2840 }
hassof390d2c2004-09-10 20:48:21 +00002841 }
hasso3fdb2dd2005-09-28 18:45:54 +00002842 /* ISIS - Dynamic hostname - Defaults to true so only display if
2843 * false. */
hassof390d2c2004-09-10 20:48:21 +00002844 if (!area->dynhostname)
2845 {
2846 vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
2847 write++;
2848 }
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002849 /* ISIS - Metric-Style - when true displays wide */
2850 if (area->newmetric)
hassof390d2c2004-09-10 20:48:21 +00002851 {
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002852 if (!area->oldmetric)
2853 vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
hasso2984d262005-09-26 16:49:07 +00002854 else
2855 vty_out (vty, " metric-style transition%s", VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +00002856 write++;
2857 }
Christian Frankef818c8f2012-11-27 01:10:28 +00002858 else
2859 {
2860 vty_out (vty, " metric-style narrow%s", VTY_NEWLINE);
2861 write++;
2862 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002863 /* ISIS - overload-bit */
2864 if (area->overload_bit)
2865 {
2866 vty_out (vty, " set-overload-bit%s", VTY_NEWLINE);
2867 write++;
2868 }
hassof390d2c2004-09-10 20:48:21 +00002869 /* ISIS - Area is-type (level-1-2 is default) */
2870 if (area->is_type == IS_LEVEL_1)
2871 {
2872 vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
2873 write++;
2874 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002875 else if (area->is_type == IS_LEVEL_2)
hassof390d2c2004-09-10 20:48:21 +00002876 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002877 vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
2878 write++;
hassof390d2c2004-09-10 20:48:21 +00002879 }
Christian Frankeacf98652015-11-12 14:24:22 +01002880 write += isis_redist_config_write(vty, area, AF_INET);
2881 write += isis_redist_config_write(vty, area, AF_INET6);
hassof390d2c2004-09-10 20:48:21 +00002882 /* ISIS - Lsp generation interval */
2883 if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1])
2884 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002885 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002886 {
2887 vty_out (vty, " lsp-gen-interval %d%s",
2888 area->lsp_gen_interval[0], VTY_NEWLINE);
2889 write++;
2890 }
2891 }
2892 else
2893 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002894 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002895 {
2896 vty_out (vty, " lsp-gen-interval level-1 %d%s",
2897 area->lsp_gen_interval[0], VTY_NEWLINE);
2898 write++;
2899 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002900 if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002901 {
2902 vty_out (vty, " lsp-gen-interval level-2 %d%s",
2903 area->lsp_gen_interval[1], VTY_NEWLINE);
2904 write++;
2905 }
2906 }
2907 /* ISIS - LSP lifetime */
2908 if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1])
2909 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002910 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00002911 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002912 vty_out (vty, " max-lsp-lifetime %u%s", area->max_lsp_lifetime[0],
hassof390d2c2004-09-10 20:48:21 +00002913 VTY_NEWLINE);
2914 write++;
2915 }
2916 }
2917 else
2918 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002919 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00002920 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002921 vty_out (vty, " max-lsp-lifetime level-1 %u%s",
hassof390d2c2004-09-10 20:48:21 +00002922 area->max_lsp_lifetime[0], VTY_NEWLINE);
2923 write++;
2924 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002925 if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00002926 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002927 vty_out (vty, " max-lsp-lifetime level-2 %u%s",
hassof390d2c2004-09-10 20:48:21 +00002928 area->max_lsp_lifetime[1], VTY_NEWLINE);
2929 write++;
2930 }
2931 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002932 /* ISIS - LSP refresh interval */
2933 if (area->lsp_refresh[0] == area->lsp_refresh[1])
2934 {
2935 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2936 {
2937 vty_out (vty, " lsp-refresh-interval %u%s", area->lsp_refresh[0],
2938 VTY_NEWLINE);
2939 write++;
2940 }
2941 }
2942 else
2943 {
2944 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2945 {
2946 vty_out (vty, " lsp-refresh-interval level-1 %u%s",
2947 area->lsp_refresh[0], VTY_NEWLINE);
2948 write++;
2949 }
2950 if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2951 {
2952 vty_out (vty, " lsp-refresh-interval level-2 %u%s",
2953 area->lsp_refresh[1], VTY_NEWLINE);
2954 write++;
2955 }
2956 }
Christian Frankef1fc1db2015-11-10 18:43:31 +01002957 if (area->lsp_mtu != DEFAULT_LSP_MTU)
2958 {
2959 vty_out(vty, " lsp-mtu %u%s", area->lsp_mtu, VTY_NEWLINE);
2960 write++;
2961 }
2962
hasso13fb40a2005-10-01 06:03:04 +00002963 /* Minimum SPF interval. */
2964 if (area->min_spf_interval[0] == area->min_spf_interval[1])
2965 {
2966 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
2967 {
2968 vty_out (vty, " spf-interval %d%s",
2969 area->min_spf_interval[0], VTY_NEWLINE);
2970 write++;
2971 }
2972 }
2973 else
2974 {
2975 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
2976 {
2977 vty_out (vty, " spf-interval level-1 %d%s",
2978 area->min_spf_interval[0], VTY_NEWLINE);
2979 write++;
2980 }
2981 if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL)
2982 {
2983 vty_out (vty, " spf-interval level-2 %d%s",
2984 area->min_spf_interval[1], VTY_NEWLINE);
2985 write++;
2986 }
2987 }
hasso53c997c2004-09-15 16:21:59 +00002988 /* Authentication passwords. */
Josh Bailey3f045a02012-03-24 08:35:20 -07002989 if (area->area_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
hasso53c997c2004-09-15 16:21:59 +00002990 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002991 vty_out(vty, " area-password md5 %s", area->area_passwd.passwd);
hasso1cbc5622005-01-01 10:29:51 +00002992 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
2993 {
2994 vty_out(vty, " authenticate snp ");
2995 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
2996 vty_out(vty, "validate");
2997 else
2998 vty_out(vty, "send-only");
2999 }
3000 vty_out(vty, "%s", VTY_NEWLINE);
hasso53c997c2004-09-15 16:21:59 +00003001 write++;
Josh Bailey3f045a02012-03-24 08:35:20 -07003002 }
3003 else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
3004 {
3005 vty_out(vty, " area-password clear %s", area->area_passwd.passwd);
3006 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
3007 {
3008 vty_out(vty, " authenticate snp ");
3009 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
3010 vty_out(vty, "validate");
3011 else
3012 vty_out(vty, "send-only");
3013 }
3014 vty_out(vty, "%s", VTY_NEWLINE);
3015 write++;
3016 }
3017 if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
hasso53c997c2004-09-15 16:21:59 +00003018 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003019 vty_out(vty, " domain-password md5 %s",
3020 area->domain_passwd.passwd);
3021 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3022 {
3023 vty_out(vty, " authenticate snp ");
3024 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3025 vty_out(vty, "validate");
3026 else
3027 vty_out(vty, "send-only");
3028 }
3029 vty_out(vty, "%s", VTY_NEWLINE);
3030 write++;
3031 }
3032 else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
3033 {
3034 vty_out(vty, " domain-password clear %s",
3035 area->domain_passwd.passwd);
hasso1cbc5622005-01-01 10:29:51 +00003036 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3037 {
3038 vty_out(vty, " authenticate snp ");
3039 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3040 vty_out(vty, "validate");
3041 else
3042 vty_out(vty, "send-only");
3043 }
3044 vty_out(vty, "%s", VTY_NEWLINE);
hasso53c997c2004-09-15 16:21:59 +00003045 write++;
3046 }
hassof1082d12005-09-19 04:23:34 +00003047
Josh Bailey3f045a02012-03-24 08:35:20 -07003048 if (area->log_adj_changes)
3049 {
3050 vty_out (vty, " log-adjacency-changes%s", VTY_NEWLINE);
3051 write++;
3052 }
3053
hassof390d2c2004-09-10 20:48:21 +00003054#ifdef TOPOLOGY_GENERATE
hassof1082d12005-09-19 04:23:34 +00003055 if (memcmp (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS,
3056 ISIS_SYS_ID_LEN))
3057 {
3058 vty_out (vty, " topology base-is %s%s",
Josh Bailey3f045a02012-03-24 08:35:20 -07003059 sysid_print ((u_char *)area->topology_baseis), VTY_NEWLINE);
hassof1082d12005-09-19 04:23:34 +00003060 write++;
3061 }
3062 if (area->topology_basedynh)
3063 {
3064 vty_out (vty, " topology base-dynh %s%s",
3065 area->topology_basedynh, VTY_NEWLINE);
3066 write++;
3067 }
3068 /* We save the whole command line here. */
3069 if (strlen(area->top_params))
hassof390d2c2004-09-10 20:48:21 +00003070 {
3071 vty_out (vty, " %s%s", area->top_params, VTY_NEWLINE);
3072 write++;
3073 }
hassof390d2c2004-09-10 20:48:21 +00003074#endif /* TOPOLOGY_GENERATE */
hassof1082d12005-09-19 04:23:34 +00003075
hassof390d2c2004-09-10 20:48:21 +00003076 }
Olivier Dugeon4f593572016-04-19 19:03:05 +02003077 isis_mpls_te_config_write_router(vty);
jardineb5d44e2003-12-23 08:09:43 +00003078 }
hassof390d2c2004-09-10 20:48:21 +00003079
jardineb5d44e2003-12-23 08:09:43 +00003080 return write;
3081}
3082
Josh Bailey3f045a02012-03-24 08:35:20 -07003083struct cmd_node isis_node = {
jardineb5d44e2003-12-23 08:09:43 +00003084 ISIS_NODE,
hasso2097cd82003-12-23 11:51:08 +00003085 "%s(config-router)# ",
jardineb5d44e2003-12-23 08:09:43 +00003086 1
3087};
3088
hassof390d2c2004-09-10 20:48:21 +00003089void
jardineb5d44e2003-12-23 08:09:43 +00003090isis_init ()
3091{
jardineb5d44e2003-12-23 08:09:43 +00003092 /* Install IS-IS top node */
3093 install_node (&isis_node, isis_config_write);
hassof390d2c2004-09-10 20:48:21 +00003094
Josh Bailey3f045a02012-03-24 08:35:20 -07003095 install_element (VIEW_NODE, &show_isis_summary_cmd);
3096
3097 install_element (VIEW_NODE, &show_isis_interface_cmd);
3098 install_element (VIEW_NODE, &show_isis_interface_detail_cmd);
3099 install_element (VIEW_NODE, &show_isis_interface_arg_cmd);
3100
3101 install_element (VIEW_NODE, &show_isis_neighbor_cmd);
3102 install_element (VIEW_NODE, &show_isis_neighbor_detail_cmd);
3103 install_element (VIEW_NODE, &show_isis_neighbor_arg_cmd);
3104 install_element (VIEW_NODE, &clear_isis_neighbor_cmd);
3105 install_element (VIEW_NODE, &clear_isis_neighbor_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003106
3107 install_element (VIEW_NODE, &show_hostname_cmd);
3108 install_element (VIEW_NODE, &show_database_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003109 install_element (VIEW_NODE, &show_database_arg_cmd);
3110 install_element (VIEW_NODE, &show_database_arg_detail_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003111 install_element (VIEW_NODE, &show_database_detail_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003112 install_element (VIEW_NODE, &show_database_detail_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003113
Olivier Dugeon4f593572016-04-19 19:03:05 +02003114 install_element (ENABLE_NODE, &show_debugging_isis_cmd);
3115
hassof390d2c2004-09-10 20:48:21 +00003116 install_node (&debug_node, config_write_debug);
jardin9e867fe2003-12-23 08:56:18 +00003117
jardineb5d44e2003-12-23 08:09:43 +00003118 install_element (ENABLE_NODE, &debug_isis_adj_cmd);
3119 install_element (ENABLE_NODE, &no_debug_isis_adj_cmd);
3120 install_element (ENABLE_NODE, &debug_isis_csum_cmd);
3121 install_element (ENABLE_NODE, &no_debug_isis_csum_cmd);
3122 install_element (ENABLE_NODE, &debug_isis_lupd_cmd);
3123 install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd);
3124 install_element (ENABLE_NODE, &debug_isis_err_cmd);
3125 install_element (ENABLE_NODE, &no_debug_isis_err_cmd);
3126 install_element (ENABLE_NODE, &debug_isis_snp_cmd);
3127 install_element (ENABLE_NODE, &no_debug_isis_snp_cmd);
3128 install_element (ENABLE_NODE, &debug_isis_upd_cmd);
3129 install_element (ENABLE_NODE, &no_debug_isis_upd_cmd);
3130 install_element (ENABLE_NODE, &debug_isis_spfevents_cmd);
3131 install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd);
3132 install_element (ENABLE_NODE, &debug_isis_spfstats_cmd);
3133 install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd);
3134 install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd);
3135 install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd);
3136 install_element (ENABLE_NODE, &debug_isis_rtevents_cmd);
3137 install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd);
3138 install_element (ENABLE_NODE, &debug_isis_events_cmd);
3139 install_element (ENABLE_NODE, &no_debug_isis_events_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003140 install_element (ENABLE_NODE, &debug_isis_packet_dump_cmd);
3141 install_element (ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
Christian Franke80a8f722015-11-12 14:21:47 +01003142 install_element (ENABLE_NODE, &debug_isis_lsp_gen_cmd);
3143 install_element (ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
Christian Franke61010c32015-11-10 18:43:34 +01003144 install_element (ENABLE_NODE, &debug_isis_lsp_sched_cmd);
3145 install_element (ENABLE_NODE, &no_debug_isis_lsp_sched_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003146
jardin9e867fe2003-12-23 08:56:18 +00003147 install_element (CONFIG_NODE, &debug_isis_adj_cmd);
3148 install_element (CONFIG_NODE, &no_debug_isis_adj_cmd);
3149 install_element (CONFIG_NODE, &debug_isis_csum_cmd);
3150 install_element (CONFIG_NODE, &no_debug_isis_csum_cmd);
3151 install_element (CONFIG_NODE, &debug_isis_lupd_cmd);
3152 install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd);
3153 install_element (CONFIG_NODE, &debug_isis_err_cmd);
3154 install_element (CONFIG_NODE, &no_debug_isis_err_cmd);
3155 install_element (CONFIG_NODE, &debug_isis_snp_cmd);
3156 install_element (CONFIG_NODE, &no_debug_isis_snp_cmd);
3157 install_element (CONFIG_NODE, &debug_isis_upd_cmd);
3158 install_element (CONFIG_NODE, &no_debug_isis_upd_cmd);
3159 install_element (CONFIG_NODE, &debug_isis_spfevents_cmd);
3160 install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd);
3161 install_element (CONFIG_NODE, &debug_isis_spfstats_cmd);
3162 install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd);
3163 install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd);
3164 install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd);
3165 install_element (CONFIG_NODE, &debug_isis_rtevents_cmd);
3166 install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd);
3167 install_element (CONFIG_NODE, &debug_isis_events_cmd);
3168 install_element (CONFIG_NODE, &no_debug_isis_events_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003169 install_element (CONFIG_NODE, &debug_isis_packet_dump_cmd);
3170 install_element (CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
Christian Franke80a8f722015-11-12 14:21:47 +01003171 install_element (CONFIG_NODE, &debug_isis_lsp_gen_cmd);
3172 install_element (CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
Christian Franke61010c32015-11-10 18:43:34 +01003173 install_element (CONFIG_NODE, &debug_isis_lsp_sched_cmd);
3174 install_element (CONFIG_NODE, &no_debug_isis_lsp_sched_cmd);
jardin9e867fe2003-12-23 08:56:18 +00003175
jardineb5d44e2003-12-23 08:09:43 +00003176 install_element (CONFIG_NODE, &router_isis_cmd);
3177 install_element (CONFIG_NODE, &no_router_isis_cmd);
3178
3179 install_default (ISIS_NODE);
3180
3181 install_element (ISIS_NODE, &net_cmd);
3182 install_element (ISIS_NODE, &no_net_cmd);
3183
Josh Bailey3f045a02012-03-24 08:35:20 -07003184 install_element (ISIS_NODE, &area_passwd_md5_cmd);
3185 install_element (ISIS_NODE, &area_passwd_md5_snpauth_cmd);
3186 install_element (ISIS_NODE, &area_passwd_clear_cmd);
3187 install_element (ISIS_NODE, &area_passwd_clear_snpauth_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003188 install_element (ISIS_NODE, &no_area_passwd_cmd);
3189
Josh Bailey3f045a02012-03-24 08:35:20 -07003190 install_element (ISIS_NODE, &domain_passwd_md5_cmd);
3191 install_element (ISIS_NODE, &domain_passwd_md5_snpauth_cmd);
3192 install_element (ISIS_NODE, &domain_passwd_clear_cmd);
3193 install_element (ISIS_NODE, &domain_passwd_clear_snpauth_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003194 install_element (ISIS_NODE, &no_domain_passwd_cmd);
3195
3196 install_element (ISIS_NODE, &lsp_gen_interval_cmd);
3197 install_element (ISIS_NODE, &no_lsp_gen_interval_cmd);
3198 install_element (ISIS_NODE, &no_lsp_gen_interval_arg_cmd);
3199 install_element (ISIS_NODE, &lsp_gen_interval_l1_cmd);
3200 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_cmd);
3201 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_arg_cmd);
3202 install_element (ISIS_NODE, &lsp_gen_interval_l2_cmd);
3203 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_cmd);
3204 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_arg_cmd);
3205
3206 install_element (ISIS_NODE, &spf_interval_cmd);
3207 install_element (ISIS_NODE, &no_spf_interval_cmd);
3208 install_element (ISIS_NODE, &no_spf_interval_arg_cmd);
3209 install_element (ISIS_NODE, &spf_interval_l1_cmd);
3210 install_element (ISIS_NODE, &no_spf_interval_l1_cmd);
3211 install_element (ISIS_NODE, &no_spf_interval_l1_arg_cmd);
3212 install_element (ISIS_NODE, &spf_interval_l2_cmd);
3213 install_element (ISIS_NODE, &no_spf_interval_l2_cmd);
3214 install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd);
hassof390d2c2004-09-10 20:48:21 +00003215
Josh Bailey3f045a02012-03-24 08:35:20 -07003216 install_element (ISIS_NODE, &max_lsp_lifetime_cmd);
3217 install_element (ISIS_NODE, &no_max_lsp_lifetime_cmd);
3218 install_element (ISIS_NODE, &no_max_lsp_lifetime_arg_cmd);
3219 install_element (ISIS_NODE, &max_lsp_lifetime_l1_cmd);
3220 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_cmd);
3221 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_arg_cmd);
3222 install_element (ISIS_NODE, &max_lsp_lifetime_l2_cmd);
3223 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_cmd);
3224 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_arg_cmd);
3225
3226 install_element (ISIS_NODE, &lsp_refresh_interval_cmd);
3227 install_element (ISIS_NODE, &no_lsp_refresh_interval_cmd);
3228 install_element (ISIS_NODE, &no_lsp_refresh_interval_arg_cmd);
3229 install_element (ISIS_NODE, &lsp_refresh_interval_l1_cmd);
3230 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_cmd);
3231 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_arg_cmd);
3232 install_element (ISIS_NODE, &lsp_refresh_interval_l2_cmd);
3233 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_cmd);
3234 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_arg_cmd);
3235
Josh Bailey3f045a02012-03-24 08:35:20 -07003236 install_element (ISIS_NODE, &log_adj_changes_cmd);
3237 install_element (ISIS_NODE, &no_log_adj_changes_cmd);
3238
jardineb5d44e2003-12-23 08:09:43 +00003239#ifdef TOPOLOGY_GENERATE
3240 install_element (ISIS_NODE, &topology_generate_grid_cmd);
3241 install_element (ISIS_NODE, &topology_baseis_cmd);
hassof1082d12005-09-19 04:23:34 +00003242 install_element (ISIS_NODE, &topology_basedynh_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003243 install_element (ISIS_NODE, &no_topology_baseis_cmd);
hassof1082d12005-09-19 04:23:34 +00003244 install_element (ISIS_NODE, &no_topology_baseis_noid_cmd);
hassof695b012005-04-02 19:03:39 +00003245 install_element (VIEW_NODE, &show_isis_generated_topology_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003246#endif /* TOPOLOGY_GENERATE */
jardineb5d44e2003-12-23 08:09:43 +00003247}