blob: 20b8e5012c07c63810d8b9bb42facc20f509cffa [file] [log] [blame]
jardineb5d44e2003-12-23 08:09:43 +00001/*
2 * IS-IS Rout(e)ing protocol - isisd.c
3 *
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public Licenseas published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
jardineb5d44e2003-12-23 08:09:43 +000023#include <zebra.h>
jardineb5d44e2003-12-23 08:09:43 +000024
25#include "thread.h"
26#include "vty.h"
27#include "command.h"
28#include "log.h"
29#include "memory.h"
Josh Bailey3f045a02012-03-24 08:35:20 -070030#include "time.h"
jardineb5d44e2003-12-23 08:09:43 +000031#include "linklist.h"
32#include "if.h"
33#include "hash.h"
34#include "stream.h"
35#include "prefix.h"
36#include "table.h"
37
38#include "isisd/dict.h"
39#include "isisd/include-netbsd/iso.h"
40#include "isisd/isis_constants.h"
41#include "isisd/isis_common.h"
jardineb5d44e2003-12-23 08:09:43 +000042#include "isisd/isis_flags.h"
Josh Bailey3f045a02012-03-24 08:35:20 -070043#include "isisd/isis_circuit.h"
44#include "isisd/isis_csm.h"
jardineb5d44e2003-12-23 08:09:43 +000045#include "isisd/isisd.h"
46#include "isisd/isis_dynhn.h"
47#include "isisd/isis_adjacency.h"
48#include "isisd/isis_pdu.h"
49#include "isisd/isis_misc.h"
50#include "isisd/isis_constants.h"
51#include "isisd/isis_tlv.h"
52#include "isisd/isis_lsp.h"
53#include "isisd/isis_spf.h"
54#include "isisd/isis_route.h"
55#include "isisd/isis_zebra.h"
56#include "isisd/isis_events.h"
57
58#ifdef TOPOLOGY_GENERATE
59#include "spgrid.h"
hassof390d2c2004-09-10 20:48:21 +000060u_char DEFAULT_TOPOLOGY_BASEIS[6] = { 0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00 };
jardineb5d44e2003-12-23 08:09:43 +000061#endif /* TOPOLOGY_GENERATE */
62
jardineb5d44e2003-12-23 08:09:43 +000063struct isis *isis = NULL;
jardineb5d44e2003-12-23 08:09:43 +000064
Paul Jakma41b36e92006-12-08 01:09:50 +000065/*
66 * Prototypes.
67 */
Paul Jakma41b36e92006-12-08 01:09:50 +000068int isis_area_get(struct vty *, const char *);
69int isis_area_destroy(struct vty *, const char *);
Josh Bailey3f045a02012-03-24 08:35:20 -070070int area_net_title(struct vty *, const char *);
71int area_clear_net_title(struct vty *, const char *);
72int show_isis_interface_common(struct vty *, const char *ifname, char);
73int show_isis_neighbor_common(struct vty *, const char *id, char);
74int clear_isis_neighbor_common(struct vty *, const char *id);
Paul Jakma41b36e92006-12-08 01:09:50 +000075int isis_config_write(struct vty *);
76
77
78
jardineb5d44e2003-12-23 08:09:43 +000079void
80isis_new (unsigned long process_id)
81{
hassoaac372f2005-09-01 17:52:33 +000082 isis = XCALLOC (MTYPE_ISIS, sizeof (struct isis));
jardineb5d44e2003-12-23 08:09:43 +000083 /*
84 * Default values
85 */
86 isis->max_area_addrs = 3;
jardineb5d44e2003-12-23 08:09:43 +000087 isis->process_id = process_id;
Josh Bailey3f045a02012-03-24 08:35:20 -070088 isis->router_id = 0;
jardineb5d44e2003-12-23 08:09:43 +000089 isis->area_list = list_new ();
90 isis->init_circ_list = list_new ();
91 isis->uptime = time (NULL);
92 isis->nexthops = list_new ();
93#ifdef HAVE_IPV6
94 isis->nexthops6 = list_new ();
95#endif /* HAVE_IPV6 */
Josh Bailey3f045a02012-03-24 08:35:20 -070096 dyn_cache_init ();
jardineb5d44e2003-12-23 08:09:43 +000097 /*
98 * uncomment the next line for full debugs
99 */
hassof390d2c2004-09-10 20:48:21 +0000100 /* isis->debugs = 0xFFFF; */
jardineb5d44e2003-12-23 08:09:43 +0000101}
102
103struct isis_area *
Josh Bailey3f045a02012-03-24 08:35:20 -0700104isis_area_create (const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000105{
jardineb5d44e2003-12-23 08:09:43 +0000106 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000107
hassoaac372f2005-09-01 17:52:33 +0000108 area = XCALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area));
jardineb5d44e2003-12-23 08:09:43 +0000109
110 /*
111 * The first instance is level-1-2 rest are level-1, unless otherwise
112 * configured
113 */
114 if (listcount (isis->area_list) > 0)
115 area->is_type = IS_LEVEL_1;
116 else
117 area->is_type = IS_LEVEL_1_AND_2;
Josh Bailey3f045a02012-03-24 08:35:20 -0700118
jardineb5d44e2003-12-23 08:09:43 +0000119 /*
120 * intialize the databases
121 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700122 if (area->is_type & IS_LEVEL_1)
123 {
124 area->lspdb[0] = lsp_db_init ();
125 area->route_table[0] = route_table_init ();
126#ifdef HAVE_IPV6
127 area->route_table6[0] = route_table_init ();
128#endif /* HAVE_IPV6 */
129 }
130 if (area->is_type & IS_LEVEL_2)
131 {
132 area->lspdb[1] = lsp_db_init ();
133 area->route_table[1] = route_table_init ();
134#ifdef HAVE_IPV6
135 area->route_table6[1] = route_table_init ();
136#endif /* HAVE_IPV6 */
137 }
hassof390d2c2004-09-10 20:48:21 +0000138
jardineb5d44e2003-12-23 08:09:43 +0000139 spftree_area_init (area);
Josh Bailey3f045a02012-03-24 08:35:20 -0700140
jardineb5d44e2003-12-23 08:09:43 +0000141 area->circuit_list = list_new ();
142 area->area_addrs = list_new ();
hassof390d2c2004-09-10 20:48:21 +0000143 THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
Paul Jakmac7350c42008-01-29 19:29:44 +0000144 flags_initialize (&area->flags);
Josh Bailey3f045a02012-03-24 08:35:20 -0700145
jardineb5d44e2003-12-23 08:09:43 +0000146 /*
147 * Default values
148 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700149 area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */
150 area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */
151 area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
152 area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
153 area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL;
154 area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL;
jardineb5d44e2003-12-23 08:09:43 +0000155 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
156 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
157 area->dynhostname = 1;
Josh Bailey3f045a02012-03-24 08:35:20 -0700158 area->oldmetric = 0;
159 area->newmetric = 1;
jardineb5d44e2003-12-23 08:09:43 +0000160 area->lsp_frag_threshold = 90;
161#ifdef TOPOLOGY_GENERATE
162 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
163#endif /* TOPOLOGY_GENERATE */
164
165 /* FIXME: Think of a better way... */
166 area->min_bcast_mtu = 1497;
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
285 for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addr))
286 {
287 list_delete_node (area->area_addrs, node);
288 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
289 }
290 area->area_addrs = NULL;
291
hassof390d2c2004-09-10 20:48:21 +0000292 THREAD_TIMER_OFF (area->t_tick);
hassof390d2c2004-09-10 20:48:21 +0000293 THREAD_TIMER_OFF (area->t_lsp_refresh[0]);
294 THREAD_TIMER_OFF (area->t_lsp_refresh[1]);
jardineb5d44e2003-12-23 08:09:43 +0000295
Josh Bailey3f045a02012-03-24 08:35:20 -0700296 thread_cancel_event (master, area);
297
298 listnode_delete (isis->area_list, area);
299
300 free (area->area_tag);
301
jardineb5d44e2003-12-23 08:09:43 +0000302 XFREE (MTYPE_ISIS_AREA, area);
hassof390d2c2004-09-10 20:48:21 +0000303
Josh Bailey3f045a02012-03-24 08:35:20 -0700304 if (listcount (isis->area_list) == 0)
305 {
306 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
307 isis->sysid_set = 0;
308 }
309
jardineb5d44e2003-12-23 08:09:43 +0000310 return CMD_SUCCESS;
311}
312
hassof390d2c2004-09-10 20:48:21 +0000313int
Josh Bailey3f045a02012-03-24 08:35:20 -0700314area_net_title (struct vty *vty, const char *net_title)
jardineb5d44e2003-12-23 08:09:43 +0000315{
jardineb5d44e2003-12-23 08:09:43 +0000316 struct isis_area *area;
317 struct area_addr *addr;
318 struct area_addr *addrp;
hasso3fdb2dd2005-09-28 18:45:54 +0000319 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +0000320
321 u_char buff[255];
322 area = vty->index;
323
hassof390d2c2004-09-10 20:48:21 +0000324 if (!area)
325 {
326 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700327 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +0000328 }
jardineb5d44e2003-12-23 08:09:43 +0000329
330 /* We check that we are not over the maximal number of addresses */
hassof390d2c2004-09-10 20:48:21 +0000331 if (listcount (area->area_addrs) >= isis->max_area_addrs)
332 {
333 vty_out (vty, "Maximum of area addresses (%d) already reached %s",
334 isis->max_area_addrs, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700335 return CMD_ERR_NOTHING_TODO;
hassof390d2c2004-09-10 20:48:21 +0000336 }
jardineb5d44e2003-12-23 08:09:43 +0000337
338 addr = XMALLOC (MTYPE_ISIS_AREA_ADDR, sizeof (struct area_addr));
339 addr->addr_len = dotformat2buff (buff, net_title);
340 memcpy (addr->area_addr, buff, addr->addr_len);
341#ifdef EXTREME_DEBUG
hasso529d65b2004-12-24 00:14:50 +0000342 zlog_debug ("added area address %s for area %s (address length %d)",
jardineb5d44e2003-12-23 08:09:43 +0000343 net_title, area->area_tag, addr->addr_len);
344#endif /* EXTREME_DEBUG */
hassof390d2c2004-09-10 20:48:21 +0000345 if (addr->addr_len < 8 || addr->addr_len > 20)
346 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700347 vty_out (vty, "area address must be at least 8..20 octets long (%d)%s",
348 addr->addr_len, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000349 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
Josh Bailey3f045a02012-03-24 08:35:20 -0700350 return CMD_ERR_AMBIGUOUS;
351 }
352
353 if (addr->area_addr[addr->addr_len-1] != 0)
354 {
355 vty_out (vty, "nsel byte (last byte) in area address must be 0%s",
356 VTY_NEWLINE);
357 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
358 return CMD_ERR_AMBIGUOUS;
jardineb5d44e2003-12-23 08:09:43 +0000359 }
360
hassof390d2c2004-09-10 20:48:21 +0000361 if (isis->sysid_set == 0)
362 {
363 /*
364 * First area address - get the SystemID for this router
365 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700366 memcpy (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN);
hassof390d2c2004-09-10 20:48:21 +0000367 isis->sysid_set = 1;
hassoc89c05d2005-09-04 21:36:36 +0000368 if (isis->debugs & DEBUG_EVENTS)
369 zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid));
jardineb5d44e2003-12-23 08:09:43 +0000370 }
hassof390d2c2004-09-10 20:48:21 +0000371 else
372 {
373 /*
374 * Check that the SystemID portions match
375 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700376 if (memcmp (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN))
hassof390d2c2004-09-10 20:48:21 +0000377 {
378 vty_out (vty,
379 "System ID must not change when defining additional area"
380 " addresses%s", VTY_NEWLINE);
381 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
Josh Bailey3f045a02012-03-24 08:35:20 -0700382 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +0000383 }
jardineb5d44e2003-12-23 08:09:43 +0000384
hassof390d2c2004-09-10 20:48:21 +0000385 /* now we see that we don't already have this address */
hasso3fdb2dd2005-09-28 18:45:54 +0000386 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
387 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700388 if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != (addr->addr_len))
hasso3fdb2dd2005-09-28 18:45:54 +0000389 continue;
390 if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
391 {
392 XFREE (MTYPE_ISIS_AREA_ADDR, addr);
393 return CMD_SUCCESS; /* silent fail */
394 }
395 }
hassof390d2c2004-09-10 20:48:21 +0000396 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700397
jardineb5d44e2003-12-23 08:09:43 +0000398 /*
399 * Forget the systemID part of the address
400 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700401 addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
jardineb5d44e2003-12-23 08:09:43 +0000402 listnode_add (area->area_addrs, addr);
403
404 /* only now we can safely generate our LSPs for this area */
hassof390d2c2004-09-10 20:48:21 +0000405 if (listcount (area->area_addrs) > 0)
406 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700407 if (area->is_type & IS_LEVEL_1)
408 lsp_generate (area, IS_LEVEL_1);
409 if (area->is_type & IS_LEVEL_2)
410 lsp_generate (area, IS_LEVEL_2);
hassof390d2c2004-09-10 20:48:21 +0000411 }
jardineb5d44e2003-12-23 08:09:43 +0000412
413 return CMD_SUCCESS;
414}
415
416int
Josh Bailey3f045a02012-03-24 08:35:20 -0700417area_clear_net_title (struct vty *vty, const char *net_title)
jardineb5d44e2003-12-23 08:09:43 +0000418{
419 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000420 struct area_addr addr, *addrp = NULL;
hasso3fdb2dd2005-09-28 18:45:54 +0000421 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +0000422 u_char buff[255];
423
424 area = vty->index;
hassof390d2c2004-09-10 20:48:21 +0000425 if (!area)
426 {
427 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700428 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +0000429 }
430
jardineb5d44e2003-12-23 08:09:43 +0000431 addr.addr_len = dotformat2buff (buff, net_title);
hassof390d2c2004-09-10 20:48:21 +0000432 if (addr.addr_len < 8 || addr.addr_len > 20)
433 {
434 vty_out (vty, "Unsupported area address length %d, should be 8...20 %s",
435 addr.addr_len, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700436 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +0000437 }
438
439 memcpy (addr.area_addr, buff, (int) addr.addr_len);
440
hasso3fdb2dd2005-09-28 18:45:54 +0000441 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
Josh Bailey3f045a02012-03-24 08:35:20 -0700442 if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len &&
jardineb5d44e2003-12-23 08:09:43 +0000443 !memcmp (addrp->area_addr, addr.area_addr, addr.addr_len))
hassof390d2c2004-09-10 20:48:21 +0000444 break;
445
446 if (!addrp)
447 {
448 vty_out (vty, "No area address %s for area %s %s", net_title,
449 area->area_tag, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700450 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +0000451 }
452
jardineb5d44e2003-12-23 08:09:43 +0000453 listnode_delete (area->area_addrs, addrp);
Josh Bailey3f045a02012-03-24 08:35:20 -0700454 XFREE (MTYPE_ISIS_AREA_ADDR, addrp);
455
456 /*
457 * Last area address - reset the SystemID for this router
458 */
459 if (listcount (area->area_addrs) == 0)
460 {
461 memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
462 isis->sysid_set = 0;
463 if (isis->debugs & DEBUG_EVENTS)
464 zlog_debug ("Router has no SystemID");
465 }
hassof390d2c2004-09-10 20:48:21 +0000466
jardineb5d44e2003-12-23 08:09:43 +0000467 return CMD_SUCCESS;
468}
469
jardineb5d44e2003-12-23 08:09:43 +0000470/*
Josh Bailey3f045a02012-03-24 08:35:20 -0700471 * 'show isis interface' command
jardineb5d44e2003-12-23 08:09:43 +0000472 */
473
474int
Josh Bailey3f045a02012-03-24 08:35:20 -0700475show_isis_interface_common (struct vty *vty, const char *ifname, char detail)
jardineb5d44e2003-12-23 08:09:43 +0000476{
hasso3fdb2dd2005-09-28 18:45:54 +0000477 struct listnode *anode, *cnode;
jardineb5d44e2003-12-23 08:09:43 +0000478 struct isis_area *area;
479 struct isis_circuit *circuit;
jardineb5d44e2003-12-23 08:09:43 +0000480
hassof390d2c2004-09-10 20:48:21 +0000481 if (!isis)
482 {
483 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
484 return CMD_SUCCESS;
485 }
jardineb5d44e2003-12-23 08:09:43 +0000486
hasso3fdb2dd2005-09-28 18:45:54 +0000487 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
hassof390d2c2004-09-10 20:48:21 +0000488 {
hassof390d2c2004-09-10 20:48:21 +0000489 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000490
hassof390d2c2004-09-10 20:48:21 +0000491 if (detail == ISIS_UI_LEVEL_BRIEF)
Josh Bailey3f045a02012-03-24 08:35:20 -0700492 vty_out (vty, " Interface CircId State Type Level%s",
493 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000494
hasso3fdb2dd2005-09-28 18:45:54 +0000495 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
Josh Bailey3f045a02012-03-24 08:35:20 -0700496 if (!ifname)
497 isis_circuit_print_vty (circuit, vty, detail);
498 else if (strcmp(circuit->interface->name, ifname) == 0)
499 isis_circuit_print_vty (circuit, vty, detail);
jardineb5d44e2003-12-23 08:09:43 +0000500 }
hassof390d2c2004-09-10 20:48:21 +0000501
jardineb5d44e2003-12-23 08:09:43 +0000502 return CMD_SUCCESS;
503}
504
Josh Bailey3f045a02012-03-24 08:35:20 -0700505DEFUN (show_isis_interface,
506 show_isis_interface_cmd,
507 "show isis interface",
jardineb5d44e2003-12-23 08:09:43 +0000508 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -0700509 "ISIS network information\n"
510 "ISIS interface\n")
jardineb5d44e2003-12-23 08:09:43 +0000511{
Josh Bailey3f045a02012-03-24 08:35:20 -0700512 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
jardineb5d44e2003-12-23 08:09:43 +0000513}
514
Josh Bailey3f045a02012-03-24 08:35:20 -0700515DEFUN (show_isis_interface_detail,
516 show_isis_interface_detail_cmd,
517 "show isis interface detail",
jardineb5d44e2003-12-23 08:09:43 +0000518 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -0700519 "ISIS network information\n"
520 "ISIS interface\n"
jardineb5d44e2003-12-23 08:09:43 +0000521 "show detailed information\n")
522{
Josh Bailey3f045a02012-03-24 08:35:20 -0700523 return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
jardineb5d44e2003-12-23 08:09:43 +0000524}
525
Josh Bailey3f045a02012-03-24 08:35:20 -0700526DEFUN (show_isis_interface_arg,
527 show_isis_interface_arg_cmd,
528 "show isis interface WORD",
jardineb5d44e2003-12-23 08:09:43 +0000529 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -0700530 "ISIS network information\n"
531 "ISIS interface\n"
532 "ISIS interface name\n")
533{
534 return show_isis_interface_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
535}
536
537/*
538 * 'show isis neighbor' command
539 */
540
541int
542show_isis_neighbor_common (struct vty *vty, const char *id, char detail)
543{
544 struct listnode *anode, *cnode, *node;
545 struct isis_area *area;
546 struct isis_circuit *circuit;
547 struct list *adjdb;
548 struct isis_adjacency *adj;
549 struct isis_dynhn *dynhn;
550 u_char sysid[ISIS_SYS_ID_LEN];
551 int i;
552
553 if (!isis)
554 {
555 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
556 return CMD_SUCCESS;
557 }
558
559 memset (sysid, 0, ISIS_SYS_ID_LEN);
560 if (id)
561 {
562 if (sysid2buff (sysid, id) == 0)
563 {
564 dynhn = dynhn_find_by_name (id);
565 if (dynhn == NULL)
566 {
567 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
568 return CMD_SUCCESS;
569 }
570 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
571 }
572 }
573
574 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
575 {
576 vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
577
578 if (detail == ISIS_UI_LEVEL_BRIEF)
579 vty_out (vty, " System Id Interface L State"
580 " Holdtime SNPA%s", VTY_NEWLINE);
581
582 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
583 {
584 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
585 {
586 for (i = 0; i < 2; i++)
587 {
588 adjdb = circuit->u.bc.adjdb[i];
589 if (adjdb && adjdb->count)
590 {
591 for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
592 if (!id || !memcmp (adj->sysid, sysid,
593 ISIS_SYS_ID_LEN))
594 isis_adj_print_vty (adj, vty, detail);
595 }
596 }
597 }
598 else if (circuit->circ_type == CIRCUIT_T_P2P &&
599 circuit->u.p2p.neighbor)
600 {
601 adj = circuit->u.p2p.neighbor;
602 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
603 isis_adj_print_vty (adj, vty, detail);
604 }
605 }
606 }
607
608 return CMD_SUCCESS;
609}
610
611/*
612 * 'clear isis neighbor' command
613 */
614int
615clear_isis_neighbor_common (struct vty *vty, const char *id)
616{
617 struct listnode *anode, *cnode, *cnextnode, *node, *nnode;
618 struct isis_area *area;
619 struct isis_circuit *circuit;
620 struct list *adjdb;
621 struct isis_adjacency *adj;
622 struct isis_dynhn *dynhn;
623 u_char sysid[ISIS_SYS_ID_LEN];
624 int i;
625
626 if (!isis)
627 {
628 vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
629 return CMD_SUCCESS;
630 }
631
632 memset (sysid, 0, ISIS_SYS_ID_LEN);
633 if (id)
634 {
635 if (sysid2buff (sysid, id) == 0)
636 {
637 dynhn = dynhn_find_by_name (id);
638 if (dynhn == NULL)
639 {
640 vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
641 return CMD_SUCCESS;
642 }
643 memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
644 }
645 }
646
647 for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
648 {
649 for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnextnode, circuit))
650 {
651 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
652 {
653 for (i = 0; i < 2; i++)
654 {
655 adjdb = circuit->u.bc.adjdb[i];
656 if (adjdb && adjdb->count)
657 {
658 for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj))
659 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
660 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
661 "clear user request");
662 }
663 }
664 }
665 else if (circuit->circ_type == CIRCUIT_T_P2P &&
666 circuit->u.p2p.neighbor)
667 {
668 adj = circuit->u.p2p.neighbor;
669 if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
670 isis_adj_state_change (adj, ISIS_ADJ_DOWN,
671 "clear user request");
672 }
673 }
674 }
675
676 return CMD_SUCCESS;
677}
678
679DEFUN (show_isis_neighbor,
680 show_isis_neighbor_cmd,
681 "show isis neighbor",
682 SHOW_STR
683 "ISIS network information\n"
684 "ISIS neighbor adjacencies\n")
685{
686 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
687}
688
689DEFUN (show_isis_neighbor_detail,
690 show_isis_neighbor_detail_cmd,
691 "show isis neighbor detail",
692 SHOW_STR
693 "ISIS network information\n"
694 "ISIS neighbor adjacencies\n"
jardineb5d44e2003-12-23 08:09:43 +0000695 "show detailed information\n")
Josh Bailey3f045a02012-03-24 08:35:20 -0700696{
697 return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
698}
699
700DEFUN (show_isis_neighbor_arg,
701 show_isis_neighbor_arg_cmd,
702 "show isis neighbor WORD",
703 SHOW_STR
704 "ISIS network information\n"
705 "ISIS neighbor adjacencies\n"
706 "System id\n")
707{
708 return show_isis_neighbor_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
709}
710
711DEFUN (clear_isis_neighbor,
712 clear_isis_neighbor_cmd,
713 "clear isis neighbor",
714 CLEAR_STR
715 "Reset ISIS network information\n"
716 "Reset ISIS neighbor adjacencies\n")
717{
718 return clear_isis_neighbor_common (vty, NULL);
719}
720
721DEFUN (clear_isis_neighbor_arg,
722 clear_isis_neighbor_arg_cmd,
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700723 "clear isis neighbor WORD",
Josh Bailey3f045a02012-03-24 08:35:20 -0700724 CLEAR_STR
725 "ISIS network information\n"
726 "ISIS neighbor adjacencies\n"
727 "System id\n")
728{
729 return clear_isis_neighbor_common (vty, argv[0]);
730}
731
jardineb5d44e2003-12-23 08:09:43 +0000732/*
733 * 'isis debug', 'show debugging'
734 */
jardineb5d44e2003-12-23 08:09:43 +0000735void
736print_debug (struct vty *vty, int flags, int onoff)
737{
738 char onoffs[4];
739 if (onoff)
hassof390d2c2004-09-10 20:48:21 +0000740 strcpy (onoffs, "on");
jardineb5d44e2003-12-23 08:09:43 +0000741 else
hassof390d2c2004-09-10 20:48:21 +0000742 strcpy (onoffs, "off");
jardineb5d44e2003-12-23 08:09:43 +0000743
744 if (flags & DEBUG_ADJ_PACKETS)
hassof390d2c2004-09-10 20:48:21 +0000745 vty_out (vty, "IS-IS Adjacency related packets debugging is %s%s", onoffs,
746 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000747 if (flags & DEBUG_CHECKSUM_ERRORS)
hassof390d2c2004-09-10 20:48:21 +0000748 vty_out (vty, "IS-IS checksum errors debugging is %s%s", onoffs,
749 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000750 if (flags & DEBUG_LOCAL_UPDATES)
hassof390d2c2004-09-10 20:48:21 +0000751 vty_out (vty, "IS-IS local updates debugging is %s%s", onoffs,
752 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000753 if (flags & DEBUG_PROTOCOL_ERRORS)
hassof390d2c2004-09-10 20:48:21 +0000754 vty_out (vty, "IS-IS protocol errors debugging is %s%s", onoffs,
755 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000756 if (flags & DEBUG_SNP_PACKETS)
hassof390d2c2004-09-10 20:48:21 +0000757 vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s%s", onoffs,
758 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000759 if (flags & DEBUG_SPF_EVENTS)
hassof390d2c2004-09-10 20:48:21 +0000760 vty_out (vty, "IS-IS SPF events debugging is %s%s", onoffs, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000761 if (flags & DEBUG_SPF_STATS)
hassof390d2c2004-09-10 20:48:21 +0000762 vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s%s",
763 onoffs, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000764 if (flags & DEBUG_SPF_TRIGGERS)
hassof390d2c2004-09-10 20:48:21 +0000765 vty_out (vty, "IS-IS SPF triggering events debugging is %s%s", onoffs,
766 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000767 if (flags & DEBUG_UPDATE_PACKETS)
hassof390d2c2004-09-10 20:48:21 +0000768 vty_out (vty, "IS-IS Update related packet debugging is %s%s", onoffs,
769 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000770 if (flags & DEBUG_RTE_EVENTS)
hassof390d2c2004-09-10 20:48:21 +0000771 vty_out (vty, "IS-IS Route related debuggin is %s%s", onoffs,
772 VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000773 if (flags & DEBUG_EVENTS)
hassof390d2c2004-09-10 20:48:21 +0000774 vty_out (vty, "IS-IS Event debugging is %s%s", onoffs, VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700775 if (flags & DEBUG_PACKET_DUMP)
776 vty_out (vty, "IS-IS Packet dump debugging is %s%s", onoffs, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000777}
778
779DEFUN (show_debugging,
780 show_debugging_cmd,
781 "show debugging",
782 SHOW_STR
783 "State of each debugging option\n")
784{
hassof390d2c2004-09-10 20:48:21 +0000785 vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000786 print_debug (vty, isis->debugs, 1);
787 return CMD_SUCCESS;
788}
789
jardin9e867fe2003-12-23 08:56:18 +0000790/* Debug node. */
hassof390d2c2004-09-10 20:48:21 +0000791static struct cmd_node debug_node = {
jardin9e867fe2003-12-23 08:56:18 +0000792 DEBUG_NODE,
hassof390d2c2004-09-10 20:48:21 +0000793 "",
794 1
jardin9e867fe2003-12-23 08:56:18 +0000795};
796
797static int
798config_write_debug (struct vty *vty)
799{
800 int write = 0;
801 int flags = isis->debugs;
802
hassof390d2c2004-09-10 20:48:21 +0000803 if (flags & DEBUG_ADJ_PACKETS)
804 {
805 vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
806 write++;
807 }
808 if (flags & DEBUG_CHECKSUM_ERRORS)
809 {
810 vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
811 write++;
812 }
813 if (flags & DEBUG_LOCAL_UPDATES)
814 {
815 vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
816 write++;
817 }
818 if (flags & DEBUG_PROTOCOL_ERRORS)
819 {
820 vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
821 write++;
822 }
823 if (flags & DEBUG_SNP_PACKETS)
824 {
825 vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
826 write++;
827 }
828 if (flags & DEBUG_SPF_EVENTS)
829 {
830 vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
831 write++;
832 }
833 if (flags & DEBUG_SPF_STATS)
834 {
835 vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
836 write++;
837 }
838 if (flags & DEBUG_SPF_TRIGGERS)
839 {
840 vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
841 write++;
842 }
843 if (flags & DEBUG_UPDATE_PACKETS)
844 {
845 vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
846 write++;
847 }
848 if (flags & DEBUG_RTE_EVENTS)
849 {
850 vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
851 write++;
852 }
853 if (flags & DEBUG_EVENTS)
854 {
855 vty_out (vty, "debug isis events%s", VTY_NEWLINE);
856 write++;
857 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700858 if (flags & DEBUG_PACKET_DUMP)
859 {
860 vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE);
861 write++;
862 }
jardin9e867fe2003-12-23 08:56:18 +0000863
864 return write;
865}
866
jardineb5d44e2003-12-23 08:09:43 +0000867DEFUN (debug_isis_adj,
868 debug_isis_adj_cmd,
869 "debug isis adj-packets",
870 DEBUG_STR
871 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000872 "IS-IS Adjacency related packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000873{
874 isis->debugs |= DEBUG_ADJ_PACKETS;
hassof390d2c2004-09-10 20:48:21 +0000875 print_debug (vty, DEBUG_ADJ_PACKETS, 1);
jardineb5d44e2003-12-23 08:09:43 +0000876
877 return CMD_SUCCESS;
878}
879
880DEFUN (no_debug_isis_adj,
881 no_debug_isis_adj_cmd,
882 "no debug isis adj-packets",
883 UNDEBUG_STR
884 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000885 "IS-IS Adjacency related packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000886{
jardineb5d44e2003-12-23 08:09:43 +0000887 isis->debugs &= ~DEBUG_ADJ_PACKETS;
888 print_debug (vty, DEBUG_ADJ_PACKETS, 0);
889
890 return CMD_SUCCESS;
891}
892
jardineb5d44e2003-12-23 08:09:43 +0000893DEFUN (debug_isis_csum,
894 debug_isis_csum_cmd,
895 "debug isis checksum-errors",
896 DEBUG_STR
897 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000898 "IS-IS LSP checksum errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000899{
900 isis->debugs |= DEBUG_CHECKSUM_ERRORS;
901 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1);
902
903 return CMD_SUCCESS;
904}
905
906DEFUN (no_debug_isis_csum,
907 no_debug_isis_csum_cmd,
908 "no debug isis checksum-errors",
909 UNDEBUG_STR
910 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000911 "IS-IS LSP checksum errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000912{
913 isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
914 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
hassof390d2c2004-09-10 20:48:21 +0000915
jardineb5d44e2003-12-23 08:09:43 +0000916 return CMD_SUCCESS;
917}
918
919DEFUN (debug_isis_lupd,
920 debug_isis_lupd_cmd,
921 "debug isis local-updates",
922 DEBUG_STR
923 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000924 "IS-IS local update packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000925{
926 isis->debugs |= DEBUG_LOCAL_UPDATES;
927 print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
928
929 return CMD_SUCCESS;
930}
931
932DEFUN (no_debug_isis_lupd,
933 no_debug_isis_lupd_cmd,
934 "no debug isis local-updates",
935 UNDEBUG_STR
936 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000937 "IS-IS local update packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000938{
939 isis->debugs &= ~DEBUG_LOCAL_UPDATES;
hassof390d2c2004-09-10 20:48:21 +0000940 print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
941
jardineb5d44e2003-12-23 08:09:43 +0000942 return CMD_SUCCESS;
943}
944
945DEFUN (debug_isis_err,
946 debug_isis_err_cmd,
hassof390d2c2004-09-10 20:48:21 +0000947 "debug isis protocol-errors",
jardineb5d44e2003-12-23 08:09:43 +0000948 DEBUG_STR
949 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000950 "IS-IS LSP protocol errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000951{
952 isis->debugs |= DEBUG_PROTOCOL_ERRORS;
953 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1);
954
955 return CMD_SUCCESS;
956}
957
958DEFUN (no_debug_isis_err,
959 no_debug_isis_err_cmd,
960 "no debug isis protocol-errors",
961 UNDEBUG_STR
962 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000963 "IS-IS LSP protocol errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000964{
965 isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
966 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
hassof390d2c2004-09-10 20:48:21 +0000967
jardineb5d44e2003-12-23 08:09:43 +0000968 return CMD_SUCCESS;
969}
970
971DEFUN (debug_isis_snp,
972 debug_isis_snp_cmd,
973 "debug isis snp-packets",
974 DEBUG_STR
975 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000976 "IS-IS CSNP/PSNP packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000977{
978 isis->debugs |= DEBUG_SNP_PACKETS;
979 print_debug (vty, DEBUG_SNP_PACKETS, 1);
980
981 return CMD_SUCCESS;
982}
983
984DEFUN (no_debug_isis_snp,
985 no_debug_isis_snp_cmd,
986 "no debug isis snp-packets",
987 UNDEBUG_STR
988 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000989 "IS-IS CSNP/PSNP packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000990{
hassof390d2c2004-09-10 20:48:21 +0000991 isis->debugs &= ~DEBUG_SNP_PACKETS;
jardineb5d44e2003-12-23 08:09:43 +0000992 print_debug (vty, DEBUG_SNP_PACKETS, 0);
hassof390d2c2004-09-10 20:48:21 +0000993
jardineb5d44e2003-12-23 08:09:43 +0000994 return CMD_SUCCESS;
995}
996
jardineb5d44e2003-12-23 08:09:43 +0000997DEFUN (debug_isis_upd,
998 debug_isis_upd_cmd,
999 "debug isis update-packets",
1000 DEBUG_STR
1001 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001002 "IS-IS Update related packets\n")
jardineb5d44e2003-12-23 08:09:43 +00001003{
1004 isis->debugs |= DEBUG_UPDATE_PACKETS;
1005 print_debug (vty, DEBUG_UPDATE_PACKETS, 1);
1006
1007 return CMD_SUCCESS;
1008}
1009
1010DEFUN (no_debug_isis_upd,
1011 no_debug_isis_upd_cmd,
1012 "no debug isis update-packets",
1013 UNDEBUG_STR
1014 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001015 "IS-IS Update related packets\n")
jardineb5d44e2003-12-23 08:09:43 +00001016{
1017 isis->debugs &= ~DEBUG_UPDATE_PACKETS;
1018 print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
hassof390d2c2004-09-10 20:48:21 +00001019
jardineb5d44e2003-12-23 08:09:43 +00001020 return CMD_SUCCESS;
1021}
1022
jardineb5d44e2003-12-23 08:09:43 +00001023DEFUN (debug_isis_spfevents,
1024 debug_isis_spfevents_cmd,
1025 "debug isis spf-events",
1026 DEBUG_STR
1027 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001028 "IS-IS Shortest Path First Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001029{
1030 isis->debugs |= DEBUG_SPF_EVENTS;
hassof390d2c2004-09-10 20:48:21 +00001031 print_debug (vty, DEBUG_SPF_EVENTS, 1);
jardineb5d44e2003-12-23 08:09:43 +00001032
1033 return CMD_SUCCESS;
1034}
1035
1036DEFUN (no_debug_isis_spfevents,
1037 no_debug_isis_spfevents_cmd,
1038 "no debug isis spf-events",
1039 UNDEBUG_STR
1040 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001041 "IS-IS Shortest Path First Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001042{
1043 isis->debugs &= ~DEBUG_SPF_EVENTS;
hassof390d2c2004-09-10 20:48:21 +00001044 print_debug (vty, DEBUG_SPF_EVENTS, 0);
1045
jardineb5d44e2003-12-23 08:09:43 +00001046 return CMD_SUCCESS;
1047}
1048
jardineb5d44e2003-12-23 08:09:43 +00001049DEFUN (debug_isis_spfstats,
1050 debug_isis_spfstats_cmd,
1051 "debug isis spf-statistics ",
1052 DEBUG_STR
1053 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001054 "IS-IS SPF Timing and Statistic Data\n")
jardineb5d44e2003-12-23 08:09:43 +00001055{
1056 isis->debugs |= DEBUG_SPF_STATS;
1057 print_debug (vty, DEBUG_SPF_STATS, 1);
1058
1059 return CMD_SUCCESS;
1060}
1061
1062DEFUN (no_debug_isis_spfstats,
1063 no_debug_isis_spfstats_cmd,
1064 "no debug isis spf-statistics",
1065 UNDEBUG_STR
1066 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001067 "IS-IS SPF Timing and Statistic Data\n")
jardineb5d44e2003-12-23 08:09:43 +00001068{
1069 isis->debugs &= ~DEBUG_SPF_STATS;
1070 print_debug (vty, DEBUG_SPF_STATS, 0);
hassof390d2c2004-09-10 20:48:21 +00001071
jardineb5d44e2003-12-23 08:09:43 +00001072 return CMD_SUCCESS;
1073}
1074
1075DEFUN (debug_isis_spftrigg,
1076 debug_isis_spftrigg_cmd,
1077 "debug isis spf-triggers",
1078 DEBUG_STR
1079 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001080 "IS-IS SPF triggering events\n")
jardineb5d44e2003-12-23 08:09:43 +00001081{
1082 isis->debugs |= DEBUG_SPF_TRIGGERS;
1083 print_debug (vty, DEBUG_SPF_TRIGGERS, 1);
1084
1085 return CMD_SUCCESS;
1086}
1087
1088DEFUN (no_debug_isis_spftrigg,
1089 no_debug_isis_spftrigg_cmd,
1090 "no debug isis spf-triggers",
1091 UNDEBUG_STR
1092 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001093 "IS-IS SPF triggering events\n")
jardineb5d44e2003-12-23 08:09:43 +00001094{
1095 isis->debugs &= ~DEBUG_SPF_TRIGGERS;
1096 print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
hassof390d2c2004-09-10 20:48:21 +00001097
jardineb5d44e2003-12-23 08:09:43 +00001098 return CMD_SUCCESS;
1099}
1100
1101DEFUN (debug_isis_rtevents,
1102 debug_isis_rtevents_cmd,
1103 "debug isis route-events",
1104 DEBUG_STR
1105 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001106 "IS-IS Route related events\n")
jardineb5d44e2003-12-23 08:09:43 +00001107{
1108 isis->debugs |= DEBUG_RTE_EVENTS;
1109 print_debug (vty, DEBUG_RTE_EVENTS, 1);
1110
1111 return CMD_SUCCESS;
1112}
1113
1114DEFUN (no_debug_isis_rtevents,
1115 no_debug_isis_rtevents_cmd,
1116 "no debug isis route-events",
1117 UNDEBUG_STR
1118 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001119 "IS-IS Route related events\n")
jardineb5d44e2003-12-23 08:09:43 +00001120{
1121 isis->debugs &= ~DEBUG_RTE_EVENTS;
1122 print_debug (vty, DEBUG_RTE_EVENTS, 0);
hassof390d2c2004-09-10 20:48:21 +00001123
jardineb5d44e2003-12-23 08:09:43 +00001124 return CMD_SUCCESS;
1125}
1126
1127DEFUN (debug_isis_events,
1128 debug_isis_events_cmd,
1129 "debug isis events",
1130 DEBUG_STR
1131 "IS-IS information\n"
hassof1082d12005-09-19 04:23:34 +00001132 "IS-IS Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001133{
1134 isis->debugs |= DEBUG_EVENTS;
1135 print_debug (vty, DEBUG_EVENTS, 1);
1136
1137 return CMD_SUCCESS;
1138}
1139
1140DEFUN (no_debug_isis_events,
1141 no_debug_isis_events_cmd,
1142 "no debug isis events",
1143 UNDEBUG_STR
1144 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001145 "IS-IS Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001146{
1147 isis->debugs &= ~DEBUG_EVENTS;
1148 print_debug (vty, DEBUG_EVENTS, 0);
hassof390d2c2004-09-10 20:48:21 +00001149
jardineb5d44e2003-12-23 08:09:43 +00001150 return CMD_SUCCESS;
1151}
1152
Josh Bailey3f045a02012-03-24 08:35:20 -07001153DEFUN (debug_isis_packet_dump,
1154 debug_isis_packet_dump_cmd,
1155 "debug isis packet-dump",
1156 DEBUG_STR
1157 "IS-IS information\n"
1158 "IS-IS packet dump\n")
1159{
1160 isis->debugs |= DEBUG_PACKET_DUMP;
1161 print_debug (vty, DEBUG_PACKET_DUMP, 1);
1162
1163 return CMD_SUCCESS;
1164}
1165
1166DEFUN (no_debug_isis_packet_dump,
1167 no_debug_isis_packet_dump_cmd,
1168 "no debug isis packet-dump",
1169 UNDEBUG_STR
1170 "IS-IS information\n"
1171 "IS-IS packet dump\n")
1172{
1173 isis->debugs &= ~DEBUG_PACKET_DUMP;
1174 print_debug (vty, DEBUG_PACKET_DUMP, 0);
1175
1176 return CMD_SUCCESS;
1177}
1178
jardineb5d44e2003-12-23 08:09:43 +00001179DEFUN (show_hostname,
1180 show_hostname_cmd,
1181 "show isis hostname",
1182 SHOW_STR
1183 "IS-IS information\n"
1184 "IS-IS Dynamic hostname mapping\n")
1185{
1186 dynhn_print_all (vty);
hassof390d2c2004-09-10 20:48:21 +00001187
jardineb5d44e2003-12-23 08:09:43 +00001188 return CMD_SUCCESS;
1189}
1190
Josh Bailey3f045a02012-03-24 08:35:20 -07001191static void
1192vty_out_timestr(struct vty *vty, time_t uptime)
1193{
1194 struct tm *tm;
1195 time_t difftime = time (NULL);
1196 difftime -= uptime;
1197 tm = gmtime (&difftime);
1198
1199#define ONE_DAY_SECOND 60*60*24
1200#define ONE_WEEK_SECOND 60*60*24*7
1201 if (difftime < ONE_DAY_SECOND)
1202 vty_out (vty, "%02d:%02d:%02d",
1203 tm->tm_hour, tm->tm_min, tm->tm_sec);
1204 else if (difftime < ONE_WEEK_SECOND)
1205 vty_out (vty, "%dd%02dh%02dm",
1206 tm->tm_yday, tm->tm_hour, tm->tm_min);
1207 else
1208 vty_out (vty, "%02dw%dd%02dh",
1209 tm->tm_yday/7,
1210 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1211 vty_out (vty, " ago");
1212}
1213
1214DEFUN (show_isis_summary,
1215 show_isis_summary_cmd,
1216 "show isis summary",
1217 SHOW_STR "IS-IS information\n" "IS-IS summary\n")
1218{
1219 struct listnode *node, *node2;
1220 struct isis_area *area;
1221 struct isis_spftree *spftree;
1222 int level;
1223
1224 if (isis == NULL)
1225 {
1226 vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
1227 return CMD_SUCCESS;
1228 }
1229
1230 vty_out (vty, "Process Id : %ld%s", isis->process_id,
1231 VTY_NEWLINE);
1232 if (isis->sysid_set)
1233 vty_out (vty, "System Id : %s%s", sysid_print (isis->sysid),
1234 VTY_NEWLINE);
1235
1236 vty_out (vty, "Up time : ");
1237 vty_out_timestr(vty, isis->uptime);
1238 vty_out (vty, "%s", VTY_NEWLINE);
1239
1240 if (isis->area_list)
1241 vty_out (vty, "Number of areas : %d%s", isis->area_list->count,
1242 VTY_NEWLINE);
1243
1244 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1245 {
1246 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1247 VTY_NEWLINE);
1248
1249 if (listcount (area->area_addrs) > 0)
1250 {
1251 struct area_addr *area_addr;
1252 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
1253 {
1254 vty_out (vty, " Net: %s%s",
1255 isonet_print (area_addr->area_addr,
1256 area_addr->addr_len + ISIS_SYS_ID_LEN +
1257 1), VTY_NEWLINE);
1258 }
1259 }
1260
1261 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
1262 {
1263 if ((area->is_type & level) == 0)
1264 continue;
1265
1266 vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE);
1267 spftree = area->spftree[level - 1];
1268 if (spftree->pending)
1269 vty_out (vty, " IPv4 SPF: (pending)%s", VTY_NEWLINE);
1270 else
1271 vty_out (vty, " IPv4 SPF:%s", VTY_NEWLINE);
1272
1273 vty_out (vty, " minimum interval : %d%s",
1274 area->min_spf_interval[level - 1], VTY_NEWLINE);
1275
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001276 vty_out (vty, " last run elapsed : ");
1277 vty_out_timestr(vty, spftree->last_run_timestamp);
Josh Bailey3f045a02012-03-24 08:35:20 -07001278 vty_out (vty, "%s", VTY_NEWLINE);
1279
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001280 vty_out (vty, " last run duration : %u usec%s",
1281 (u_int32_t)spftree->last_run_duration, VTY_NEWLINE);
1282
Josh Bailey3f045a02012-03-24 08:35:20 -07001283 vty_out (vty, " run count : %d%s",
1284 spftree->runcount, VTY_NEWLINE);
1285
1286#ifdef HAVE_IPV6
1287 spftree = area->spftree6[level - 1];
1288 if (spftree->pending)
1289 vty_out (vty, " IPv6 SPF: (pending)%s", VTY_NEWLINE);
1290 else
1291 vty_out (vty, " IPv6 SPF:%s", VTY_NEWLINE);
1292
1293 vty_out (vty, " minimum interval : %d%s",
1294 area->min_spf_interval[level - 1], VTY_NEWLINE);
1295
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001296 vty_out (vty, " last run elapsed : ");
1297 vty_out_timestr(vty, spftree->last_run_timestamp);
Josh Bailey3f045a02012-03-24 08:35:20 -07001298 vty_out (vty, "%s", VTY_NEWLINE);
1299
David Lamparteref008d22015-03-03 08:48:11 +01001300 vty_out (vty, " last run duration : %llu msec%s",
1301 (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001302
Josh Bailey3f045a02012-03-24 08:35:20 -07001303 vty_out (vty, " run count : %d%s",
1304 spftree->runcount, VTY_NEWLINE);
1305#endif
1306 }
1307 }
1308 vty_out (vty, "%s", VTY_NEWLINE);
1309
1310 return CMD_SUCCESS;
1311}
1312
1313/*
1314 * This function supports following display options:
1315 * [ show isis database [detail] ]
1316 * [ show isis database <sysid> [detail] ]
1317 * [ show isis database <hostname> [detail] ]
1318 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1319 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1320 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1321 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1322 * [ show isis database detail <sysid> ]
1323 * [ show isis database detail <hostname> ]
1324 * [ show isis database detail <sysid>.<pseudo-id> ]
1325 * [ show isis database detail <hostname>.<pseudo-id> ]
1326 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1327 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1328 */
1329static int
1330show_isis_database (struct vty *vty, const char *argv, int ui_level)
jardineb5d44e2003-12-23 08:09:43 +00001331{
hasso3fdb2dd2005-09-28 18:45:54 +00001332 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +00001333 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07001334 struct isis_lsp *lsp;
1335 struct isis_dynhn *dynhn;
1336 const char *pos = argv;
1337 u_char lspid[ISIS_SYS_ID_LEN+2];
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001338 char sysid[255];
Josh Bailey3f045a02012-03-24 08:35:20 -07001339 u_char number[3];
hassof390d2c2004-09-10 20:48:21 +00001340 int level, lsp_count;
jardineb5d44e2003-12-23 08:09:43 +00001341
1342 if (isis->area_list->count == 0)
1343 return CMD_SUCCESS;
jardineb5d44e2003-12-23 08:09:43 +00001344
Josh Bailey3f045a02012-03-24 08:35:20 -07001345 memset (&lspid, 0, ISIS_SYS_ID_LEN);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001346 memset (&sysid, 0, 255);
Josh Bailey3f045a02012-03-24 08:35:20 -07001347
1348 /*
1349 * extract fragment and pseudo id from the string argv
1350 * in the forms:
1351 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1352 * (b) <systemid/hostname>.<pseudo-id> or
1353 * (c) <systemid/hostname> or
1354 * Where systemid is in the form:
1355 * xxxx.xxxx.xxxx
1356 */
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001357 if (argv)
1358 strncpy (sysid, argv, 254);
Josh Bailey3f045a02012-03-24 08:35:20 -07001359 if (argv && strlen (argv) > 3)
1360 {
1361 pos = argv + strlen (argv) - 3;
1362 if (strncmp (pos, "-", 1) == 0)
1363 {
1364 memcpy (number, ++pos, 2);
1365 lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16);
1366 pos -= 4;
1367 if (strncmp (pos, ".", 1) != 0)
1368 return CMD_ERR_AMBIGUOUS;
1369 }
1370 if (strncmp (pos, ".", 1) == 0)
1371 {
1372 memcpy (number, ++pos, 2);
1373 lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16);
1374 sysid[pos - argv - 1] = '\0';
1375 }
1376 }
1377
hasso3fdb2dd2005-09-28 18:45:54 +00001378 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof390d2c2004-09-10 20:48:21 +00001379 {
hassof390d2c2004-09-10 20:48:21 +00001380 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
Josh Bailey3f045a02012-03-24 08:35:20 -07001381 VTY_NEWLINE);
1382
hassof390d2c2004-09-10 20:48:21 +00001383 for (level = 0; level < ISIS_LEVELS; level++)
Josh Bailey3f045a02012-03-24 08:35:20 -07001384 {
1385 if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
1386 {
1387 lsp = NULL;
1388 if (argv != NULL)
1389 {
1390 /*
1391 * Try to find the lsp-id if the argv string is in
1392 * the form hostname.<pseudo-id>-<fragment>
1393 */
1394 if (sysid2buff (lspid, sysid))
1395 {
1396 lsp = lsp_search (lspid, area->lspdb[level]);
1397 }
1398 else if ((dynhn = dynhn_find_by_name (sysid)))
1399 {
1400 memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN);
1401 lsp = lsp_search (lspid, area->lspdb[level]);
1402 }
1403 else if (strncmp(unix_hostname (), sysid, 15) == 0)
1404 {
1405 memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
1406 lsp = lsp_search (lspid, area->lspdb[level]);
1407 }
1408 }
jardineb5d44e2003-12-23 08:09:43 +00001409
Josh Bailey3f045a02012-03-24 08:35:20 -07001410 if (lsp != NULL || argv == NULL)
1411 {
1412 vty_out (vty, "IS-IS Level-%d link-state database:%s",
1413 level + 1, VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +00001414
Josh Bailey3f045a02012-03-24 08:35:20 -07001415 /* print the title in all cases */
1416 vty_out (vty, "LSP ID PduLen "
1417 "SeqNumber Chksum Holdtime ATT/P/OL%s",
1418 VTY_NEWLINE);
1419 }
1420
1421 if (lsp)
1422 {
1423 if (ui_level == ISIS_UI_LEVEL_DETAIL)
1424 lsp_print_detail (lsp, vty, area->dynhostname);
1425 else
1426 lsp_print (lsp, vty, area->dynhostname);
1427 }
1428 else if (argv == NULL)
1429 {
1430 lsp_count = lsp_print_all (vty, area->lspdb[level],
1431 ui_level,
1432 area->dynhostname);
1433
1434 vty_out (vty, " %u LSPs%s%s",
1435 lsp_count, VTY_NEWLINE, VTY_NEWLINE);
1436 }
1437 }
1438 }
jardineb5d44e2003-12-23 08:09:43 +00001439 }
jardineb5d44e2003-12-23 08:09:43 +00001440
1441 return CMD_SUCCESS;
1442}
1443
Josh Bailey3f045a02012-03-24 08:35:20 -07001444DEFUN (show_database_brief,
1445 show_database_cmd,
1446 "show isis database",
1447 SHOW_STR
1448 "IS-IS information\n"
1449 "IS-IS link state database\n")
1450{
1451 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_BRIEF);
1452}
1453
1454DEFUN (show_database_lsp_brief,
1455 show_database_arg_cmd,
1456 "show isis database WORD",
1457 SHOW_STR
1458 "IS-IS information\n"
1459 "IS-IS link state database\n"
1460 "LSP ID\n")
1461{
1462 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_BRIEF);
1463}
1464
1465DEFUN (show_database_lsp_detail,
1466 show_database_arg_detail_cmd,
1467 "show isis database WORD detail",
1468 SHOW_STR
1469 "IS-IS information\n"
1470 "IS-IS link state database\n"
1471 "LSP ID\n"
1472 "Detailed information\n")
1473{
1474 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
1475}
1476
jardineb5d44e2003-12-23 08:09:43 +00001477DEFUN (show_database_detail,
1478 show_database_detail_cmd,
1479 "show isis database detail",
1480 SHOW_STR
1481 "IS-IS information\n"
1482 "IS-IS link state database\n")
1483{
Josh Bailey3f045a02012-03-24 08:35:20 -07001484 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_DETAIL);
1485}
jardineb5d44e2003-12-23 08:09:43 +00001486
Josh Bailey3f045a02012-03-24 08:35:20 -07001487DEFUN (show_database_detail_lsp,
1488 show_database_detail_arg_cmd,
1489 "show isis database detail WORD",
1490 SHOW_STR
1491 "IS-IS information\n"
1492 "IS-IS link state database\n"
1493 "Detailed information\n"
1494 "LSP ID\n")
1495{
1496 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
jardineb5d44e2003-12-23 08:09:43 +00001497}
1498
1499/*
1500 * 'router isis' command
1501 */
1502DEFUN (router_isis,
1503 router_isis_cmd,
1504 "router isis WORD",
hassof390d2c2004-09-10 20:48:21 +00001505 ROUTER_STR
jardineb5d44e2003-12-23 08:09:43 +00001506 "ISO IS-IS\n"
1507 "ISO Routing area tag")
1508{
jardineb5d44e2003-12-23 08:09:43 +00001509 return isis_area_get (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001510}
1511
1512/*
1513 *'no router isis' command
1514 */
1515DEFUN (no_router_isis,
1516 no_router_isis_cmd,
1517 "no router isis WORD",
hassof390d2c2004-09-10 20:48:21 +00001518 "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
jardineb5d44e2003-12-23 08:09:43 +00001519{
1520 return isis_area_destroy (vty, argv[0]);
1521}
1522
1523/*
1524 * 'net' command
1525 */
1526DEFUN (net,
1527 net_cmd,
1528 "net WORD",
1529 "A Network Entity Title for this process (OSI only)\n"
hassof390d2c2004-09-10 20:48:21 +00001530 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00001531{
Paul Jakma41b36e92006-12-08 01:09:50 +00001532 return area_net_title (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001533}
1534
jardineb5d44e2003-12-23 08:09:43 +00001535/*
1536 * 'no net' command
1537 */
1538DEFUN (no_net,
1539 no_net_cmd,
1540 "no net WORD",
1541 NO_STR
1542 "A Network Entity Title for this process (OSI only)\n"
hassof390d2c2004-09-10 20:48:21 +00001543 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00001544{
Paul Jakma41b36e92006-12-08 01:09:50 +00001545 return area_clear_net_title (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001546}
1547
Josh Bailey3f045a02012-03-24 08:35:20 -07001548DEFUN (area_passwd_md5,
1549 area_passwd_md5_cmd,
1550 "area-password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001551 "Configure the authentication password for an area\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001552 "Authentication type\n"
hassof390d2c2004-09-10 20:48:21 +00001553 "Area password\n")
jardineb5d44e2003-12-23 08:09:43 +00001554{
1555 struct isis_area *area;
1556 int len;
1557
1558 area = vty->index;
1559
hassof390d2c2004-09-10 20:48:21 +00001560 if (!area)
1561 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001562 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1563 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001564 }
1565
jardineb5d44e2003-12-23 08:09:43 +00001566 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001567 if (len > 254)
1568 {
1569 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001570 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001571 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001572
1573 area->area_passwd.len = (u_char) len;
1574 area->area_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1575 strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
1576
1577 if (argc > 1)
1578 {
1579 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1580 if (strncmp(argv[1], "v", 1) == 0)
1581 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1582 else
1583 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1584 }
1585 else
1586 {
1587 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1588 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1589 }
1590 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1591
1592 return CMD_SUCCESS;
1593}
1594
1595ALIAS (area_passwd_md5,
1596 area_passwd_md5_snpauth_cmd,
1597 "area-password md5 WORD authenticate snp (send-only|validate)",
1598 "Configure the authentication password for an area\n"
1599 "Authentication type\n"
1600 "Area password\n"
1601 "Authentication\n"
1602 "SNP PDUs\n"
1603 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001604 "Send and check PDUs on receiving\n")
Josh Bailey3f045a02012-03-24 08:35:20 -07001605
1606DEFUN (area_passwd_clear,
1607 area_passwd_clear_cmd,
1608 "area-password clear WORD",
1609 "Configure the authentication password for an area\n"
1610 "Authentication type\n"
1611 "Area password\n")
1612{
1613 struct isis_area *area;
1614 int len;
1615
1616 area = vty->index;
1617
1618 if (!area)
1619 {
1620 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1621 return CMD_ERR_NO_MATCH;
1622 }
1623
1624 len = strlen (argv[0]);
1625 if (len > 254)
1626 {
1627 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1628 return CMD_ERR_AMBIGUOUS;
1629 }
1630
hassof390d2c2004-09-10 20:48:21 +00001631 area->area_passwd.len = (u_char) len;
jardineb5d44e2003-12-23 08:09:43 +00001632 area->area_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001633 strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001634
hasso1cbc5622005-01-01 10:29:51 +00001635 if (argc > 1)
1636 {
1637 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1638 if (strncmp(argv[1], "v", 1) == 0)
1639 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1640 else
1641 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1642 }
1643 else
1644 {
1645 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1646 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1647 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001648 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hasso1cbc5622005-01-01 10:29:51 +00001649
jardineb5d44e2003-12-23 08:09:43 +00001650 return CMD_SUCCESS;
1651}
1652
Josh Bailey3f045a02012-03-24 08:35:20 -07001653ALIAS (area_passwd_clear,
1654 area_passwd_clear_snpauth_cmd,
1655 "area-password clear WORD authenticate snp (send-only|validate)",
hasso1cbc5622005-01-01 10:29:51 +00001656 "Configure the authentication password for an area\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001657 "Authentication type\n"
hasso1cbc5622005-01-01 10:29:51 +00001658 "Area password\n"
1659 "Authentication\n"
1660 "SNP PDUs\n"
1661 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001662 "Send and check PDUs on receiving\n")
hasso1cbc5622005-01-01 10:29:51 +00001663
jardineb5d44e2003-12-23 08:09:43 +00001664DEFUN (no_area_passwd,
1665 no_area_passwd_cmd,
1666 "no area-password",
1667 NO_STR
1668 "Configure the authentication password for an area\n")
1669{
1670 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00001671
jardineb5d44e2003-12-23 08:09:43 +00001672 area = vty->index;
1673
hassof390d2c2004-09-10 20:48:21 +00001674 if (!area)
1675 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001676 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1677 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001678 }
1679
jardineb5d44e2003-12-23 08:09:43 +00001680 memset (&area->area_passwd, 0, sizeof (struct isis_passwd));
Josh Bailey3f045a02012-03-24 08:35:20 -07001681 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
jardineb5d44e2003-12-23 08:09:43 +00001682
1683 return CMD_SUCCESS;
1684}
1685
Josh Bailey3f045a02012-03-24 08:35:20 -07001686DEFUN (domain_passwd_md5,
1687 domain_passwd_md5_cmd,
1688 "domain-password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001689 "Set the authentication password for a routing domain\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001690 "Authentication type\n"
hassof390d2c2004-09-10 20:48:21 +00001691 "Routing domain password\n")
jardineb5d44e2003-12-23 08:09:43 +00001692{
1693 struct isis_area *area;
1694 int len;
1695
1696 area = vty->index;
1697
hassof390d2c2004-09-10 20:48:21 +00001698 if (!area)
1699 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001700 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1701 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001702 }
1703
jardineb5d44e2003-12-23 08:09:43 +00001704 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001705 if (len > 254)
1706 {
1707 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001708 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001709 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001710
1711 area->domain_passwd.len = (u_char) len;
1712 area->domain_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1713 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
1714
1715 if (argc > 1)
1716 {
1717 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1718 if (strncmp(argv[1], "v", 1) == 0)
1719 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1720 else
1721 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1722 }
1723 else
1724 {
1725 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1726 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1727 }
1728 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1729
1730 return CMD_SUCCESS;
1731}
1732
1733ALIAS (domain_passwd_md5,
1734 domain_passwd_md5_snpauth_cmd,
1735 "domain-password md5 WORD authenticate snp (send-only|validate)",
1736 "Set the authentication password for a routing domain\n"
1737 "Authentication type\n"
1738 "Routing domain password\n"
1739 "Authentication\n"
1740 "SNP PDUs\n"
1741 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001742 "Send and check PDUs on receiving\n")
Josh Bailey3f045a02012-03-24 08:35:20 -07001743
1744DEFUN (domain_passwd_clear,
1745 domain_passwd_clear_cmd,
1746 "domain-password clear WORD",
1747 "Set the authentication password for a routing domain\n"
1748 "Authentication type\n"
1749 "Routing domain password\n")
1750{
1751 struct isis_area *area;
1752 int len;
1753
1754 area = vty->index;
1755
1756 if (!area)
1757 {
1758 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1759 return CMD_ERR_NO_MATCH;
1760 }
1761
1762 len = strlen (argv[0]);
1763 if (len > 254)
1764 {
1765 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1766 return CMD_ERR_AMBIGUOUS;
1767 }
1768
hassof390d2c2004-09-10 20:48:21 +00001769 area->domain_passwd.len = (u_char) len;
jardineb5d44e2003-12-23 08:09:43 +00001770 area->domain_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001771 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001772
hasso1cbc5622005-01-01 10:29:51 +00001773 if (argc > 1)
1774 {
1775 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1776 if (strncmp(argv[1], "v", 1) == 0)
1777 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1778 else
1779 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1780 }
1781 else
1782 {
1783 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1784 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1785 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001786 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hasso1cbc5622005-01-01 10:29:51 +00001787
jardineb5d44e2003-12-23 08:09:43 +00001788 return CMD_SUCCESS;
1789}
1790
Josh Bailey3f045a02012-03-24 08:35:20 -07001791ALIAS (domain_passwd_clear,
1792 domain_passwd_clear_snpauth_cmd,
1793 "domain-password clear WORD authenticate snp (send-only|validate)",
hasso1cbc5622005-01-01 10:29:51 +00001794 "Set the authentication password for a routing domain\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001795 "Authentication type\n"
hasso1cbc5622005-01-01 10:29:51 +00001796 "Routing domain password\n"
1797 "Authentication\n"
1798 "SNP PDUs\n"
1799 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001800 "Send and check PDUs on receiving\n")
hasso1cbc5622005-01-01 10:29:51 +00001801
jardineb5d44e2003-12-23 08:09:43 +00001802DEFUN (no_domain_passwd,
1803 no_domain_passwd_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07001804 "no domain-password",
jardineb5d44e2003-12-23 08:09:43 +00001805 NO_STR
1806 "Set the authentication password for a routing domain\n")
1807{
1808 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00001809
jardineb5d44e2003-12-23 08:09:43 +00001810 area = vty->index;
1811
hassof390d2c2004-09-10 20:48:21 +00001812 if (!area)
1813 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001814 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1815 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001816 }
1817
jardineb5d44e2003-12-23 08:09:43 +00001818 memset (&area->domain_passwd, 0, sizeof (struct isis_passwd));
Josh Bailey3f045a02012-03-24 08:35:20 -07001819 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hassof390d2c2004-09-10 20:48:21 +00001820
jardineb5d44e2003-12-23 08:09:43 +00001821 return CMD_SUCCESS;
1822}
1823
1824DEFUN (is_type,
1825 is_type_cmd,
1826 "is-type (level-1|level-1-2|level-2-only)",
1827 "IS Level for this routing process (OSI only)\n"
1828 "Act as a station router only\n"
1829 "Act as both a station router and an area router\n"
1830 "Act as an area router only\n")
1831{
1832 struct isis_area *area;
1833 int type;
1834
1835 area = vty->index;
1836
hassof390d2c2004-09-10 20:48:21 +00001837 if (!area)
1838 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001839 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1840 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001841 }
jardineb5d44e2003-12-23 08:09:43 +00001842
Paul Jakma41b36e92006-12-08 01:09:50 +00001843 type = string2circuit_t (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001844 if (!type)
1845 {
1846 vty_out (vty, "Unknown IS level %s", VTY_NEWLINE);
1847 return CMD_SUCCESS;
1848 }
jardineb5d44e2003-12-23 08:09:43 +00001849
1850 isis_event_system_type_change (area, type);
hassof390d2c2004-09-10 20:48:21 +00001851
jardineb5d44e2003-12-23 08:09:43 +00001852 return CMD_SUCCESS;
1853}
1854
1855DEFUN (no_is_type,
1856 no_is_type_cmd,
1857 "no is-type (level-1|level-1-2|level-2-only)",
1858 NO_STR
1859 "IS Level for this routing process (OSI only)\n"
1860 "Act as a station router only\n"
1861 "Act as both a station router and an area router\n"
1862 "Act as an area router only\n")
1863{
jardineb5d44e2003-12-23 08:09:43 +00001864 struct isis_area *area;
1865 int type;
1866
1867 area = vty->index;
1868 assert (area);
hassof390d2c2004-09-10 20:48:21 +00001869
jardineb5d44e2003-12-23 08:09:43 +00001870 /*
Josh Bailey3f045a02012-03-24 08:35:20 -07001871 * Put the is-type back to defaults:
1872 * - level-1-2 on first area
1873 * - level-1 for the rest
jardineb5d44e2003-12-23 08:09:43 +00001874 */
paul1eb8ef22005-04-07 07:30:20 +00001875 if (listgetdata (listhead (isis->area_list)) == area)
jardineb5d44e2003-12-23 08:09:43 +00001876 type = IS_LEVEL_1_AND_2;
1877 else
1878 type = IS_LEVEL_1;
1879
1880 isis_event_system_type_change (area, type);
1881
1882 return CMD_SUCCESS;
1883}
1884
Josh Bailey3f045a02012-03-24 08:35:20 -07001885static int
1886set_lsp_gen_interval (struct vty *vty, struct isis_area *area,
1887 uint16_t interval, int level)
1888{
1889 int lvl;
1890
1891 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
1892 {
1893 if (!(lvl & level))
1894 continue;
1895
1896 if (interval >= area->lsp_refresh[lvl-1])
1897 {
1898 vty_out (vty, "LSP gen interval %us must be less than "
1899 "the LSP refresh interval %us%s",
1900 interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
1901 return CMD_ERR_AMBIGUOUS;
1902 }
1903 }
1904
1905 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
1906 {
1907 if (!(lvl & level))
1908 continue;
1909 area->lsp_gen_interval[lvl-1] = interval;
1910 }
1911
1912 return CMD_SUCCESS;
1913}
1914
jardineb5d44e2003-12-23 08:09:43 +00001915DEFUN (lsp_gen_interval,
1916 lsp_gen_interval_cmd,
1917 "lsp-gen-interval <1-120>",
1918 "Minimum interval between regenerating same LSP\n"
1919 "Minimum interval in seconds\n")
1920{
1921 struct isis_area *area;
1922 uint16_t interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07001923 int level;
jardineb5d44e2003-12-23 08:09:43 +00001924
1925 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001926 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07001927 level = IS_LEVEL_1 | IS_LEVEL_2;
1928 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00001929}
1930
1931DEFUN (no_lsp_gen_interval,
1932 no_lsp_gen_interval_cmd,
1933 "no lsp-gen-interval",
1934 NO_STR
hassof390d2c2004-09-10 20:48:21 +00001935 "Minimum interval between regenerating same LSP\n")
jardineb5d44e2003-12-23 08:09:43 +00001936{
1937 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07001938 uint16_t interval;
1939 int level;
jardineb5d44e2003-12-23 08:09:43 +00001940
1941 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07001942 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
1943 level = IS_LEVEL_1 | IS_LEVEL_2;
1944 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00001945}
1946
1947ALIAS (no_lsp_gen_interval,
1948 no_lsp_gen_interval_arg_cmd,
1949 "no lsp-gen-interval <1-120>",
1950 NO_STR
1951 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00001952 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00001953
1954DEFUN (lsp_gen_interval_l1,
1955 lsp_gen_interval_l1_cmd,
1956 "lsp-gen-interval level-1 <1-120>",
1957 "Minimum interval between regenerating same LSP\n"
1958 "Set interval for level 1 only\n"
hassof390d2c2004-09-10 20:48:21 +00001959 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00001960{
1961 struct isis_area *area;
1962 uint16_t interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07001963 int level;
jardineb5d44e2003-12-23 08:09:43 +00001964
1965 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001966 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07001967 level = IS_LEVEL_1;
1968 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00001969}
1970
1971DEFUN (no_lsp_gen_interval_l1,
1972 no_lsp_gen_interval_l1_cmd,
1973 "no lsp-gen-interval level-1",
1974 NO_STR
1975 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00001976 "Set interval for level 1 only\n")
jardineb5d44e2003-12-23 08:09:43 +00001977{
1978 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07001979 uint16_t interval;
1980 int level;
jardineb5d44e2003-12-23 08:09:43 +00001981
1982 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07001983 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
1984 level = IS_LEVEL_1;
1985 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00001986}
1987
1988ALIAS (no_lsp_gen_interval_l1,
1989 no_lsp_gen_interval_l1_arg_cmd,
1990 "no lsp-gen-interval level-1 <1-120>",
1991 NO_STR
1992 "Minimum interval between regenerating same LSP\n"
1993 "Set interval for level 1 only\n"
hassof390d2c2004-09-10 20:48:21 +00001994 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00001995
1996DEFUN (lsp_gen_interval_l2,
1997 lsp_gen_interval_l2_cmd,
1998 "lsp-gen-interval level-2 <1-120>",
1999 "Minimum interval between regenerating same LSP\n"
2000 "Set interval for level 2 only\n"
hassof390d2c2004-09-10 20:48:21 +00002001 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002002{
2003 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002004 uint16_t interval;
2005 int level;
jardineb5d44e2003-12-23 08:09:43 +00002006
2007 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002008 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002009 level = IS_LEVEL_2;
2010 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002011}
2012
2013DEFUN (no_lsp_gen_interval_l2,
2014 no_lsp_gen_interval_l2_cmd,
2015 "no lsp-gen-interval level-2",
2016 NO_STR
2017 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002018 "Set interval for level 2 only\n")
jardineb5d44e2003-12-23 08:09:43 +00002019{
2020 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002021 uint16_t interval;
2022 int level;
jardineb5d44e2003-12-23 08:09:43 +00002023
2024 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002025 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2026 level = IS_LEVEL_2;
2027 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002028}
2029
2030ALIAS (no_lsp_gen_interval_l2,
2031 no_lsp_gen_interval_l2_arg_cmd,
2032 "no lsp-gen-interval level-2 <1-120>",
2033 NO_STR
2034 "Minimum interval between regenerating same LSP\n"
2035 "Set interval for level 2 only\n"
hassof390d2c2004-09-10 20:48:21 +00002036 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002037
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002038static int
2039validate_metric_style_narrow (struct vty *vty, struct isis_area *area)
2040{
2041 struct isis_circuit *circuit;
2042 struct listnode *node;
2043
2044 if (! vty)
2045 return CMD_ERR_AMBIGUOUS;
2046
2047 if (! area)
2048 {
2049 vty_out (vty, "ISIS area is invalid%s", VTY_NEWLINE);
2050 return CMD_ERR_AMBIGUOUS;
2051 }
2052
2053 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
2054 {
2055 if ((area->is_type & IS_LEVEL_1) &&
2056 (circuit->is_type & IS_LEVEL_1) &&
Christian Franke4fb7c842012-11-27 19:51:59 +00002057 (circuit->te_metric[0] > MAX_NARROW_LINK_METRIC))
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002058 {
2059 vty_out (vty, "ISIS circuit %s metric is invalid%s",
2060 circuit->interface->name, VTY_NEWLINE);
2061 return CMD_ERR_AMBIGUOUS;
2062 }
2063 if ((area->is_type & IS_LEVEL_2) &&
2064 (circuit->is_type & IS_LEVEL_2) &&
Christian Franke4fb7c842012-11-27 19:51:59 +00002065 (circuit->te_metric[1] > MAX_NARROW_LINK_METRIC))
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002066 {
2067 vty_out (vty, "ISIS circuit %s metric is invalid%s",
2068 circuit->interface->name, VTY_NEWLINE);
2069 return CMD_ERR_AMBIGUOUS;
2070 }
2071 }
2072
2073 return CMD_SUCCESS;
2074}
2075
jardineb5d44e2003-12-23 08:09:43 +00002076DEFUN (metric_style,
2077 metric_style_cmd,
hasso2984d262005-09-26 16:49:07 +00002078 "metric-style (narrow|transition|wide)",
jardineb5d44e2003-12-23 08:09:43 +00002079 "Use old-style (ISO 10589) or new-style packet formats\n"
2080 "Use old style of TLVs with narrow metric\n"
hasso2984d262005-09-26 16:49:07 +00002081 "Send and accept both styles of TLVs during transition\n"
jardineb5d44e2003-12-23 08:09:43 +00002082 "Use new style of TLVs to carry wider metric\n")
2083{
2084 struct isis_area *area;
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002085 int ret;
jardineb5d44e2003-12-23 08:09:43 +00002086
2087 area = vty->index;
2088 assert (area);
hasso2984d262005-09-26 16:49:07 +00002089
2090 if (strncmp (argv[0], "w", 1) == 0)
2091 {
2092 area->newmetric = 1;
2093 area->oldmetric = 0;
2094 }
Christian Franke478c1122012-11-27 19:52:00 +00002095 else
hasso2984d262005-09-26 16:49:07 +00002096 {
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002097 ret = validate_metric_style_narrow (vty, area);
2098 if (ret != CMD_SUCCESS)
2099 return ret;
2100
Christian Franke478c1122012-11-27 19:52:00 +00002101 if (strncmp (argv[0], "t", 1) == 0)
2102 {
2103 area->newmetric = 1;
2104 area->oldmetric = 1;
2105 }
2106 else if (strncmp (argv[0], "n", 1) == 0)
2107 {
2108 area->newmetric = 0;
2109 area->oldmetric = 1;
2110 }
hasso2984d262005-09-26 16:49:07 +00002111 }
jardineb5d44e2003-12-23 08:09:43 +00002112
2113 return CMD_SUCCESS;
2114}
2115
2116DEFUN (no_metric_style,
2117 no_metric_style_cmd,
hasso2984d262005-09-26 16:49:07 +00002118 "no metric-style",
jardineb5d44e2003-12-23 08:09:43 +00002119 NO_STR
hasso2984d262005-09-26 16:49:07 +00002120 "Use old-style (ISO 10589) or new-style packet formats\n")
jardineb5d44e2003-12-23 08:09:43 +00002121{
2122 struct isis_area *area;
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002123 int ret;
jardineb5d44e2003-12-23 08:09:43 +00002124
2125 area = vty->index;
2126 assert (area);
2127
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002128 ret = validate_metric_style_narrow (vty, area);
2129 if (ret != CMD_SUCCESS)
2130 return ret;
2131
hasso2984d262005-09-26 16:49:07 +00002132 /* Default is narrow metric. */
2133 area->newmetric = 0;
2134 area->oldmetric = 1;
jardineb5d44e2003-12-23 08:09:43 +00002135
2136 return CMD_SUCCESS;
2137}
2138
Josh Bailey3f045a02012-03-24 08:35:20 -07002139DEFUN (set_overload_bit,
2140 set_overload_bit_cmd,
2141 "set-overload-bit",
2142 "Set overload bit to avoid any transit traffic\n"
2143 "Set overload bit\n")
2144{
2145 struct isis_area *area;
2146
2147 area = vty->index;
2148 assert (area);
2149
2150 area->overload_bit = LSPBIT_OL;
2151 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2152
2153 return CMD_SUCCESS;
2154}
2155
2156DEFUN (no_set_overload_bit,
2157 no_set_overload_bit_cmd,
2158 "no set-overload-bit",
2159 "Reset overload bit to accept transit traffic\n"
2160 "Reset overload bit\n")
2161{
2162 struct isis_area *area;
2163
2164 area = vty->index;
2165 assert (area);
2166
2167 area->overload_bit = 0;
2168 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2169
2170 return CMD_SUCCESS;
2171}
2172
Amritha Nambiarc8ee9402015-08-24 16:40:14 -07002173DEFUN (set_attached_bit,
2174 set_attached_bit_cmd,
2175 "set-attached-bit",
2176 "Set attached bit to identify as L1/L2 router for inter-area traffic\n"
2177 "Set attached bit\n")
2178{
2179 struct isis_area *area;
2180
2181 area = vty->index;
2182 assert (area);
2183
2184 area->attached_bit = LSPBIT_ATT;
2185 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2186
2187 return CMD_SUCCESS;
2188}
2189
2190DEFUN (no_set_attached_bit,
2191 no_set_attached_bit_cmd,
2192 "no set-attached-bit",
2193 "Reset attached bit\n")
2194{
2195 struct isis_area *area;
2196
2197 area = vty->index;
2198 assert (area);
2199
2200 area->attached_bit = 0;
2201 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2202
2203 return CMD_SUCCESS;
2204}
2205
jardineb5d44e2003-12-23 08:09:43 +00002206DEFUN (dynamic_hostname,
2207 dynamic_hostname_cmd,
2208 "hostname dynamic",
2209 "Dynamic hostname for IS-IS\n"
hassof390d2c2004-09-10 20:48:21 +00002210 "Dynamic hostname\n")
jardineb5d44e2003-12-23 08:09:43 +00002211{
2212 struct isis_area *area;
2213
2214 area = vty->index;
2215 assert (area);
hassof390d2c2004-09-10 20:48:21 +00002216
Josh Bailey3f045a02012-03-24 08:35:20 -07002217 if (!area->dynhostname)
2218 {
2219 area->dynhostname = 1;
2220 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
2221 }
hassof390d2c2004-09-10 20:48:21 +00002222
jardineb5d44e2003-12-23 08:09:43 +00002223 return CMD_SUCCESS;
2224}
2225
2226DEFUN (no_dynamic_hostname,
2227 no_dynamic_hostname_cmd,
2228 "no hostname dynamic",
2229 NO_STR
2230 "Dynamic hostname for IS-IS\n"
hassof390d2c2004-09-10 20:48:21 +00002231 "Dynamic hostname\n")
jardineb5d44e2003-12-23 08:09:43 +00002232{
2233 struct isis_area *area;
2234
2235 area = vty->index;
2236 assert (area);
hassof390d2c2004-09-10 20:48:21 +00002237
Josh Bailey3f045a02012-03-24 08:35:20 -07002238 if (area->dynhostname)
2239 {
2240 area->dynhostname = 0;
2241 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
2242 }
hassof390d2c2004-09-10 20:48:21 +00002243
jardineb5d44e2003-12-23 08:09:43 +00002244 return CMD_SUCCESS;
2245}
2246
2247DEFUN (spf_interval,
2248 spf_interval_cmd,
2249 "spf-interval <1-120>",
hasso2097cd82003-12-23 11:51:08 +00002250 "Minimum interval between SPF calculations\n"
jardineb5d44e2003-12-23 08:09:43 +00002251 "Minimum interval between consecutive SPFs in seconds\n")
2252{
2253 struct isis_area *area;
2254 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002255
jardineb5d44e2003-12-23 08:09:43 +00002256 area = vty->index;
2257 interval = atoi (argv[0]);
2258 area->min_spf_interval[0] = interval;
2259 area->min_spf_interval[1] = interval;
hassof390d2c2004-09-10 20:48:21 +00002260
jardineb5d44e2003-12-23 08:09:43 +00002261 return CMD_SUCCESS;
2262}
2263
2264DEFUN (no_spf_interval,
2265 no_spf_interval_cmd,
2266 "no spf-interval",
2267 NO_STR
hassof390d2c2004-09-10 20:48:21 +00002268 "Minimum interval between SPF calculations\n")
jardineb5d44e2003-12-23 08:09:43 +00002269{
2270 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002271
jardineb5d44e2003-12-23 08:09:43 +00002272 area = vty->index;
2273
2274 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
2275 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002276
jardineb5d44e2003-12-23 08:09:43 +00002277 return CMD_SUCCESS;
2278}
2279
2280ALIAS (no_spf_interval,
2281 no_spf_interval_arg_cmd,
2282 "no spf-interval <1-120>",
2283 NO_STR
2284 "Minimum interval between SPF calculations\n"
hassof390d2c2004-09-10 20:48:21 +00002285 "Minimum interval between consecutive SPFs in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002286
2287DEFUN (spf_interval_l1,
2288 spf_interval_l1_cmd,
2289 "spf-interval level-1 <1-120>",
2290 "Minimum interval between SPF calculations\n"
2291 "Set interval for level 1 only\n"
2292 "Minimum interval between consecutive SPFs in seconds\n")
2293{
2294 struct isis_area *area;
2295 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002296
jardineb5d44e2003-12-23 08:09:43 +00002297 area = vty->index;
2298 interval = atoi (argv[0]);
2299 area->min_spf_interval[0] = interval;
hassof390d2c2004-09-10 20:48:21 +00002300
jardineb5d44e2003-12-23 08:09:43 +00002301 return CMD_SUCCESS;
2302}
2303
2304DEFUN (no_spf_interval_l1,
2305 no_spf_interval_l1_cmd,
2306 "no spf-interval level-1",
2307 NO_STR
2308 "Minimum interval between SPF calculations\n"
2309 "Set interval for level 1 only\n")
2310{
2311 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002312
jardineb5d44e2003-12-23 08:09:43 +00002313 area = vty->index;
2314
2315 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002316
jardineb5d44e2003-12-23 08:09:43 +00002317 return CMD_SUCCESS;
2318}
2319
2320ALIAS (no_spf_interval,
2321 no_spf_interval_l1_arg_cmd,
2322 "no spf-interval level-1 <1-120>",
2323 NO_STR
2324 "Minimum interval between SPF calculations\n"
2325 "Set interval for level 1 only\n"
2326 "Minimum interval between consecutive SPFs in seconds\n")
2327
2328DEFUN (spf_interval_l2,
2329 spf_interval_l2_cmd,
2330 "spf-interval level-2 <1-120>",
2331 "Minimum interval between SPF calculations\n"
2332 "Set interval for level 2 only\n"
2333 "Minimum interval between consecutive SPFs in seconds\n")
2334{
2335 struct isis_area *area;
2336 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002337
jardineb5d44e2003-12-23 08:09:43 +00002338 area = vty->index;
2339 interval = atoi (argv[0]);
2340 area->min_spf_interval[1] = interval;
hassof390d2c2004-09-10 20:48:21 +00002341
jardineb5d44e2003-12-23 08:09:43 +00002342 return CMD_SUCCESS;
2343}
2344
2345DEFUN (no_spf_interval_l2,
2346 no_spf_interval_l2_cmd,
2347 "no spf-interval level-2",
2348 NO_STR
2349 "Minimum interval between SPF calculations\n"
2350 "Set interval for level 2 only\n")
2351{
2352 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002353
jardineb5d44e2003-12-23 08:09:43 +00002354 area = vty->index;
2355
2356 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002357
jardineb5d44e2003-12-23 08:09:43 +00002358 return CMD_SUCCESS;
2359}
2360
2361ALIAS (no_spf_interval,
2362 no_spf_interval_l2_arg_cmd,
2363 "no spf-interval level-2 <1-120>",
2364 NO_STR
2365 "Minimum interval between SPF calculations\n"
2366 "Set interval for level 2 only\n"
2367 "Minimum interval between consecutive SPFs in seconds\n")
2368
Josh Bailey3f045a02012-03-24 08:35:20 -07002369static int
2370set_lsp_max_lifetime (struct vty *vty, struct isis_area *area,
2371 uint16_t interval, int level)
2372{
2373 int lvl;
2374 int set_refresh_interval[ISIS_LEVELS] = {0, 0};
2375 uint16_t refresh_interval;
2376
2377 refresh_interval = interval - 300;
2378
2379 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
2380 {
2381 if (!(lvl & level))
2382 continue;
2383 if (refresh_interval < area->lsp_refresh[lvl-1])
2384 {
2385 vty_out (vty, "Level %d Max LSP lifetime %us must be 300s greater than "
2386 "the configured LSP refresh interval %us%s",
2387 lvl, interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
2388 vty_out (vty, "Automatically reducing level %d LSP refresh interval "
2389 "to %us%s", lvl, refresh_interval, VTY_NEWLINE);
2390 set_refresh_interval[lvl-1] = 1;
2391
2392 if (refresh_interval <= area->lsp_gen_interval[lvl-1])
2393 {
2394 vty_out (vty, "LSP refresh interval %us must be greater than "
2395 "the configured LSP gen interval %us%s",
2396 refresh_interval, area->lsp_gen_interval[lvl-1],
2397 VTY_NEWLINE);
2398 return CMD_ERR_AMBIGUOUS;
2399 }
2400 }
2401 }
2402
2403 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
2404 {
2405 if (!(lvl & level))
2406 continue;
2407 area->max_lsp_lifetime[lvl-1] = interval;
2408 /* Automatically reducing lsp_refresh_interval to interval - 300 */
2409 if (set_refresh_interval[lvl-1])
2410 area->lsp_refresh[lvl-1] = refresh_interval;
2411 }
2412
2413 lsp_regenerate_schedule (area, level, 1);
2414
2415 return CMD_SUCCESS;
2416}
2417
2418DEFUN (max_lsp_lifetime,
2419 max_lsp_lifetime_cmd,
2420 "max-lsp-lifetime <350-65535>",
2421 "Maximum LSP lifetime\n"
2422 "LSP lifetime in seconds\n")
2423{
2424 struct isis_area *area;
2425 uint16_t interval;
2426 int level;
2427
2428 area = vty->index;
2429 interval = atoi (argv[0]);
2430 level = IS_LEVEL_1 | IS_LEVEL_2;
2431 return set_lsp_max_lifetime (vty, area, interval, level);
2432}
2433
2434DEFUN (no_max_lsp_lifetime,
2435 no_max_lsp_lifetime_cmd,
2436 "no max-lsp-lifetime",
2437 NO_STR
2438 "LSP lifetime in seconds\n")
2439{
2440 struct isis_area *area;
2441 uint16_t interval;
2442 int level;
2443
2444 area = vty->index;
2445 interval = DEFAULT_LSP_LIFETIME;
2446 level = IS_LEVEL_1 | IS_LEVEL_2;
2447 return set_lsp_max_lifetime (vty, area, interval, level);
2448}
2449
2450ALIAS (no_max_lsp_lifetime,
2451 no_max_lsp_lifetime_arg_cmd,
2452 "no max-lsp-lifetime <350-65535>",
2453 NO_STR
2454 "Maximum LSP lifetime\n"
2455 "LSP lifetime in seconds\n")
2456
2457DEFUN (max_lsp_lifetime_l1,
2458 max_lsp_lifetime_l1_cmd,
2459 "max-lsp-lifetime level-1 <350-65535>",
2460 "Maximum LSP lifetime for Level 1 only\n"
2461 "LSP lifetime for Level 1 only in seconds\n")
2462{
2463 struct isis_area *area;
2464 uint16_t interval;
2465 int level;
2466
2467 area = vty->index;
2468 interval = atoi (argv[0]);
2469 level = IS_LEVEL_1;
2470 return set_lsp_max_lifetime (vty, area, interval, level);
2471}
2472
2473DEFUN (no_max_lsp_lifetime_l1,
2474 no_max_lsp_lifetime_l1_cmd,
2475 "no max-lsp-lifetime level-1",
2476 NO_STR
2477 "LSP lifetime for Level 1 only in seconds\n")
2478{
2479 struct isis_area *area;
2480 uint16_t interval;
2481 int level;
2482
2483 area = vty->index;
2484 interval = DEFAULT_LSP_LIFETIME;
2485 level = IS_LEVEL_1;
2486 return set_lsp_max_lifetime (vty, area, interval, level);
2487}
2488
2489ALIAS (no_max_lsp_lifetime_l1,
2490 no_max_lsp_lifetime_l1_arg_cmd,
2491 "no max-lsp-lifetime level-1 <350-65535>",
2492 NO_STR
2493 "Maximum LSP lifetime for Level 1 only\n"
2494 "LSP lifetime for Level 1 only in seconds\n")
2495
2496DEFUN (max_lsp_lifetime_l2,
2497 max_lsp_lifetime_l2_cmd,
2498 "max-lsp-lifetime level-2 <350-65535>",
2499 "Maximum LSP lifetime for Level 2 only\n"
2500 "LSP lifetime for Level 2 only in seconds\n")
2501{
2502 struct isis_area *area;
2503 uint16_t interval;
2504 int level;
2505
2506 area = vty->index;
2507 interval = atoi (argv[0]);
2508 level = IS_LEVEL_2;
2509 return set_lsp_max_lifetime (vty, area, interval, level);
2510}
2511
2512DEFUN (no_max_lsp_lifetime_l2,
2513 no_max_lsp_lifetime_l2_cmd,
2514 "no max-lsp-lifetime level-2",
2515 NO_STR
2516 "LSP lifetime for Level 2 only in seconds\n")
2517{
2518 struct isis_area *area;
2519 uint16_t interval;
2520 int level;
2521
2522 area = vty->index;
2523 interval = DEFAULT_LSP_LIFETIME;
2524 level = IS_LEVEL_2;
2525 return set_lsp_max_lifetime (vty, area, interval, level);
2526}
2527
2528ALIAS (no_max_lsp_lifetime_l2,
2529 no_max_lsp_lifetime_l2_arg_cmd,
2530 "no max-lsp-lifetime level-2 <350-65535>",
2531 NO_STR
2532 "Maximum LSP lifetime for Level 2 only\n"
2533 "LSP lifetime for Level 2 only in seconds\n")
2534
2535static int
2536set_lsp_refresh_interval (struct vty *vty, struct isis_area *area,
2537 uint16_t interval, int level)
2538{
2539 int lvl;
2540
2541 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2542 {
2543 if (!(lvl & level))
2544 continue;
2545 if (interval <= area->lsp_gen_interval[lvl-1])
2546 {
2547 vty_out (vty, "LSP refresh interval %us must be greater than "
2548 "the configured LSP gen interval %us%s",
2549 interval, area->lsp_gen_interval[lvl-1],
2550 VTY_NEWLINE);
2551 return CMD_ERR_AMBIGUOUS;
2552 }
2553 if (interval > (area->max_lsp_lifetime[lvl-1] - 300))
2554 {
2555 vty_out (vty, "LSP refresh interval %us must be less than "
2556 "the configured LSP lifetime %us less 300%s",
2557 interval, area->max_lsp_lifetime[lvl-1],
2558 VTY_NEWLINE);
2559 return CMD_ERR_AMBIGUOUS;
2560 }
2561 }
2562
2563 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2564 {
2565 if (!(lvl & level))
2566 continue;
2567 area->lsp_refresh[lvl-1] = interval;
2568 }
2569 lsp_regenerate_schedule (area, level, 1);
2570
2571 return CMD_SUCCESS;
2572}
2573
2574DEFUN (lsp_refresh_interval,
2575 lsp_refresh_interval_cmd,
2576 "lsp-refresh-interval <1-65235>",
2577 "LSP refresh interval\n"
2578 "LSP refresh interval in seconds\n")
2579{
2580 struct isis_area *area;
2581 uint16_t interval;
2582 int level;
2583
2584 area = vty->index;
2585 interval = atoi (argv[0]);
2586 level = IS_LEVEL_1 | IS_LEVEL_2;
2587 return set_lsp_refresh_interval (vty, area, interval, level);
2588}
2589
2590DEFUN (no_lsp_refresh_interval,
2591 no_lsp_refresh_interval_cmd,
2592 "no lsp-refresh-interval",
2593 NO_STR
2594 "LSP refresh interval in seconds\n")
2595{
2596 struct isis_area *area;
2597 uint16_t interval;
2598 int level;
2599
2600 area = vty->index;
2601 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2602 level = IS_LEVEL_1 | IS_LEVEL_2;
2603 return set_lsp_refresh_interval (vty, area, interval, level);
2604}
2605
2606ALIAS (no_lsp_refresh_interval,
2607 no_lsp_refresh_interval_arg_cmd,
2608 "no lsp-refresh-interval <1-65235>",
2609 NO_STR
2610 "LSP refresh interval\n"
2611 "LSP refresh interval in seconds\n")
2612
2613DEFUN (lsp_refresh_interval_l1,
2614 lsp_refresh_interval_l1_cmd,
2615 "lsp-refresh-interval level-1 <1-65235>",
2616 "LSP refresh interval for Level 1 only\n"
2617 "LSP refresh interval for Level 1 only in seconds\n")
2618{
2619 struct isis_area *area;
2620 uint16_t interval;
2621 int level;
2622
2623 area = vty->index;
2624 interval = atoi (argv[0]);
2625 level = IS_LEVEL_1;
2626 return set_lsp_refresh_interval (vty, area, interval, level);
2627}
2628
2629DEFUN (no_lsp_refresh_interval_l1,
2630 no_lsp_refresh_interval_l1_cmd,
2631 "no lsp-refresh-interval level-1",
2632 NO_STR
2633 "LSP refresh interval for Level 1 only in seconds\n")
2634{
2635 struct isis_area *area;
2636 uint16_t interval;
2637 int level;
2638
2639 area = vty->index;
2640 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2641 level = IS_LEVEL_1;
2642 return set_lsp_refresh_interval (vty, area, interval, level);
2643}
2644
2645ALIAS (no_lsp_refresh_interval_l1,
2646 no_lsp_refresh_interval_l1_arg_cmd,
2647 "no lsp-refresh-interval level-1 <1-65235>",
2648 NO_STR
2649 "LSP refresh interval for Level 1 only\n"
2650 "LSP refresh interval for Level 1 only in seconds\n")
2651
2652DEFUN (lsp_refresh_interval_l2,
2653 lsp_refresh_interval_l2_cmd,
2654 "lsp-refresh-interval level-2 <1-65235>",
2655 "LSP refresh interval for Level 2 only\n"
2656 "LSP refresh interval for Level 2 only in seconds\n")
2657{
2658 struct isis_area *area;
2659 uint16_t interval;
2660 int level;
2661
2662 area = vty->index;
2663 interval = atoi (argv[0]);
2664 level = IS_LEVEL_2;
2665 return set_lsp_refresh_interval (vty, area, interval, level);
2666}
2667
2668DEFUN (no_lsp_refresh_interval_l2,
2669 no_lsp_refresh_interval_l2_cmd,
2670 "no lsp-refresh-interval level-2",
2671 NO_STR
2672 "LSP refresh interval for Level 2 only in seconds\n")
2673{
2674 struct isis_area *area;
2675 uint16_t interval;
2676 int level;
2677
2678 area = vty->index;
2679 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2680 level = IS_LEVEL_2;
2681 return set_lsp_refresh_interval (vty, area, interval, level);
2682}
2683
2684ALIAS (no_lsp_refresh_interval_l2,
2685 no_lsp_refresh_interval_l2_arg_cmd,
2686 "no lsp-refresh-interval level-2 <1-65235>",
2687 NO_STR
2688 "LSP refresh interval for Level 2 only\n"
2689 "LSP refresh interval for Level 2 only in seconds\n")
2690
2691DEFUN (log_adj_changes,
2692 log_adj_changes_cmd,
2693 "log-adjacency-changes",
2694 "Log changes in adjacency state\n")
2695{
2696 struct isis_area *area;
2697
2698 area = vty->index;
2699 assert (area);
2700
2701 area->log_adj_changes = 1;
2702
2703 return CMD_SUCCESS;
2704}
2705
2706DEFUN (no_log_adj_changes,
2707 no_log_adj_changes_cmd,
2708 "no log-adjacency-changes",
2709 "Stop logging changes in adjacency state\n")
2710{
2711 struct isis_area *area;
2712
2713 area = vty->index;
2714 assert (area);
2715
2716 area->log_adj_changes = 0;
2717
2718 return CMD_SUCCESS;
2719}
2720
jardineb5d44e2003-12-23 08:09:43 +00002721#ifdef TOPOLOGY_GENERATE
Josh Bailey3f045a02012-03-24 08:35:20 -07002722
jardineb5d44e2003-12-23 08:09:43 +00002723DEFUN (topology_generate_grid,
2724 topology_generate_grid_cmd,
2725 "topology generate grid <1-100> <1-100> <1-65000> [param] [param] "
2726 "[param]",
hassof1082d12005-09-19 04:23:34 +00002727 "Topology generation for IS-IS\n"
2728 "Topology generation\n"
2729 "Grid topology\n"
jardineb5d44e2003-12-23 08:09:43 +00002730 "X parameter of the grid\n"
2731 "Y parameter of the grid\n"
2732 "Random seed\n"
2733 "Optional param 1\n"
2734 "Optional param 2\n"
2735 "Optional param 3\n"
2736 "Topology\n")
2737{
2738 struct isis_area *area;
2739
2740 area = vty->index;
2741 assert (area);
2742
hassof390d2c2004-09-10 20:48:21 +00002743 if (!spgrid_check_params (vty, argc, argv))
2744 {
2745 if (area->topology)
2746 list_delete (area->topology);
2747 area->topology = list_new ();
2748 memcpy (area->top_params, vty->buf, 200);
2749 gen_spgrid_topology (vty, area->topology);
2750 remove_topology_lsps (area);
2751 generate_topology_lsps (area);
hassof1082d12005-09-19 04:23:34 +00002752 /* Regenerate L1 LSP to get two way connection to the generated
2753 * topology. */
Josh Bailey3f045a02012-03-24 08:35:20 -07002754 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hassof390d2c2004-09-10 20:48:21 +00002755 }
jardineb5d44e2003-12-23 08:09:43 +00002756
2757 return CMD_SUCCESS;
2758}
2759
hassof695b012005-04-02 19:03:39 +00002760DEFUN (show_isis_generated_topology,
2761 show_isis_generated_topology_cmd,
hassof1082d12005-09-19 04:23:34 +00002762 "show isis generated-topologies",
jardineb5d44e2003-12-23 08:09:43 +00002763 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -07002764 "ISIS network information\n"
hassof1082d12005-09-19 04:23:34 +00002765 "Show generated topologies\n")
jardineb5d44e2003-12-23 08:09:43 +00002766{
2767 struct isis_area *area;
paul92c9f222005-05-25 12:21:13 +00002768 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +00002769 struct listnode *node2;
2770 struct arc *arc;
hassof1082d12005-09-19 04:23:34 +00002771
paul92c9f222005-05-25 12:21:13 +00002772 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof1082d12005-09-19 04:23:34 +00002773 {
2774 if (!area->topology)
2775 continue;
2776
2777 vty_out (vty, "Topology for isis area: %s%s", area->area_tag,
2778 VTY_NEWLINE);
2779 vty_out (vty, "From node To node Distance%s", VTY_NEWLINE);
2780
2781 for (ALL_LIST_ELEMENTS_RO (area->topology, node2, arc))
2782 vty_out (vty, "%9ld %11ld %12ld%s", arc->from_node, arc->to_node,
2783 arc->distance, VTY_NEWLINE);
2784 }
jardineb5d44e2003-12-23 08:09:43 +00002785 return CMD_SUCCESS;
2786}
2787
hassof1082d12005-09-19 04:23:34 +00002788/* Base IS for topology generation. */
hassof390d2c2004-09-10 20:48:21 +00002789DEFUN (topology_baseis,
jardineb5d44e2003-12-23 08:09:43 +00002790 topology_baseis_cmd,
2791 "topology base-is WORD",
hassof1082d12005-09-19 04:23:34 +00002792 "Topology generation for IS-IS\n"
2793 "A Network IS Base for this topology\n"
2794 "XXXX.XXXX.XXXX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00002795{
2796 struct isis_area *area;
2797 u_char buff[ISIS_SYS_ID_LEN];
2798
2799 area = vty->index;
2800 assert (area);
2801
hassof390d2c2004-09-10 20:48:21 +00002802 if (sysid2buff (buff, argv[0]))
hassof1082d12005-09-19 04:23:34 +00002803 sysid2buff (area->topology_baseis, argv[0]);
hassof390d2c2004-09-10 20:48:21 +00002804
jardineb5d44e2003-12-23 08:09:43 +00002805 return CMD_SUCCESS;
2806}
2807
jardineb5d44e2003-12-23 08:09:43 +00002808DEFUN (no_topology_baseis,
2809 no_topology_baseis_cmd,
2810 "no topology base-is WORD",
2811 NO_STR
hassof1082d12005-09-19 04:23:34 +00002812 "Topology generation for IS-IS\n"
2813 "A Network IS Base for this topology\n"
2814 "XXXX.XXXX.XXXX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00002815{
2816 struct isis_area *area;
2817
2818 area = vty->index;
2819 assert (area);
2820
hassof390d2c2004-09-10 20:48:21 +00002821 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
jardineb5d44e2003-12-23 08:09:43 +00002822 return CMD_SUCCESS;
2823}
2824
hassof1082d12005-09-19 04:23:34 +00002825ALIAS (no_topology_baseis,
2826 no_topology_baseis_noid_cmd,
2827 "no topology base-is",
2828 NO_STR
2829 "Topology generation for IS-IS\n"
2830 "A Network IS Base for this topology\n")
2831
2832DEFUN (topology_basedynh,
2833 topology_basedynh_cmd,
2834 "topology base-dynh WORD",
2835 "Topology generation for IS-IS\n"
2836 "Dynamic hostname base for this topology\n"
2837 "Dynamic hostname base\n")
2838{
2839 struct isis_area *area;
2840
2841 area = vty->index;
2842 assert (area);
2843
2844 /* I hope that it's enough. */
2845 area->topology_basedynh = strndup (argv[0], 16);
2846 return CMD_SUCCESS;
2847}
Josh Bailey3f045a02012-03-24 08:35:20 -07002848
jardineb5d44e2003-12-23 08:09:43 +00002849#endif /* TOPOLOGY_GENERATE */
2850
jardineb5d44e2003-12-23 08:09:43 +00002851/* IS-IS configuration write function */
2852int
2853isis_config_write (struct vty *vty)
2854{
2855 int write = 0;
jardineb5d44e2003-12-23 08:09:43 +00002856
hassof390d2c2004-09-10 20:48:21 +00002857 if (isis != NULL)
2858 {
2859 struct isis_area *area;
hasso3fdb2dd2005-09-28 18:45:54 +00002860 struct listnode *node, *node2;
jardineb5d44e2003-12-23 08:09:43 +00002861
hasso3fdb2dd2005-09-28 18:45:54 +00002862 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof390d2c2004-09-10 20:48:21 +00002863 {
2864 /* ISIS - Area name */
2865 vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
2866 write++;
2867 /* ISIS - Net */
2868 if (listcount (area->area_addrs) > 0)
2869 {
2870 struct area_addr *area_addr;
hasso3fdb2dd2005-09-28 18:45:54 +00002871 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
2872 {
2873 vty_out (vty, " net %s%s",
2874 isonet_print (area_addr->area_addr,
2875 area_addr->addr_len + ISIS_SYS_ID_LEN +
2876 1), VTY_NEWLINE);
2877 write++;
2878 }
hassof390d2c2004-09-10 20:48:21 +00002879 }
hasso3fdb2dd2005-09-28 18:45:54 +00002880 /* ISIS - Dynamic hostname - Defaults to true so only display if
2881 * false. */
hassof390d2c2004-09-10 20:48:21 +00002882 if (!area->dynhostname)
2883 {
2884 vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
2885 write++;
2886 }
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002887 /* ISIS - Metric-Style - when true displays wide */
2888 if (area->newmetric)
hassof390d2c2004-09-10 20:48:21 +00002889 {
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002890 if (!area->oldmetric)
2891 vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
hasso2984d262005-09-26 16:49:07 +00002892 else
2893 vty_out (vty, " metric-style transition%s", VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +00002894 write++;
2895 }
Christian Frankef818c8f2012-11-27 01:10:28 +00002896 else
2897 {
2898 vty_out (vty, " metric-style narrow%s", VTY_NEWLINE);
2899 write++;
2900 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002901 /* ISIS - overload-bit */
2902 if (area->overload_bit)
2903 {
2904 vty_out (vty, " set-overload-bit%s", VTY_NEWLINE);
2905 write++;
2906 }
hassof390d2c2004-09-10 20:48:21 +00002907 /* ISIS - Area is-type (level-1-2 is default) */
2908 if (area->is_type == IS_LEVEL_1)
2909 {
2910 vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
2911 write++;
2912 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002913 else if (area->is_type == IS_LEVEL_2)
hassof390d2c2004-09-10 20:48:21 +00002914 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002915 vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
2916 write++;
hassof390d2c2004-09-10 20:48:21 +00002917 }
2918 /* ISIS - Lsp generation interval */
2919 if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1])
2920 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002921 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002922 {
2923 vty_out (vty, " lsp-gen-interval %d%s",
2924 area->lsp_gen_interval[0], VTY_NEWLINE);
2925 write++;
2926 }
2927 }
2928 else
2929 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002930 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002931 {
2932 vty_out (vty, " lsp-gen-interval level-1 %d%s",
2933 area->lsp_gen_interval[0], VTY_NEWLINE);
2934 write++;
2935 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002936 if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002937 {
2938 vty_out (vty, " lsp-gen-interval level-2 %d%s",
2939 area->lsp_gen_interval[1], VTY_NEWLINE);
2940 write++;
2941 }
2942 }
2943 /* ISIS - LSP lifetime */
2944 if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1])
2945 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002946 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00002947 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002948 vty_out (vty, " max-lsp-lifetime %u%s", area->max_lsp_lifetime[0],
hassof390d2c2004-09-10 20:48:21 +00002949 VTY_NEWLINE);
2950 write++;
2951 }
2952 }
2953 else
2954 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002955 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00002956 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002957 vty_out (vty, " max-lsp-lifetime level-1 %u%s",
hassof390d2c2004-09-10 20:48:21 +00002958 area->max_lsp_lifetime[0], VTY_NEWLINE);
2959 write++;
2960 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002961 if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00002962 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002963 vty_out (vty, " max-lsp-lifetime level-2 %u%s",
hassof390d2c2004-09-10 20:48:21 +00002964 area->max_lsp_lifetime[1], VTY_NEWLINE);
2965 write++;
2966 }
2967 }
Josh Bailey3f045a02012-03-24 08:35:20 -07002968 /* ISIS - LSP refresh interval */
2969 if (area->lsp_refresh[0] == area->lsp_refresh[1])
2970 {
2971 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2972 {
2973 vty_out (vty, " lsp-refresh-interval %u%s", area->lsp_refresh[0],
2974 VTY_NEWLINE);
2975 write++;
2976 }
2977 }
2978 else
2979 {
2980 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2981 {
2982 vty_out (vty, " lsp-refresh-interval level-1 %u%s",
2983 area->lsp_refresh[0], VTY_NEWLINE);
2984 write++;
2985 }
2986 if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL)
2987 {
2988 vty_out (vty, " lsp-refresh-interval level-2 %u%s",
2989 area->lsp_refresh[1], VTY_NEWLINE);
2990 write++;
2991 }
2992 }
hasso13fb40a2005-10-01 06:03:04 +00002993 /* Minimum SPF interval. */
2994 if (area->min_spf_interval[0] == area->min_spf_interval[1])
2995 {
2996 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
2997 {
2998 vty_out (vty, " spf-interval %d%s",
2999 area->min_spf_interval[0], VTY_NEWLINE);
3000 write++;
3001 }
3002 }
3003 else
3004 {
3005 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
3006 {
3007 vty_out (vty, " spf-interval level-1 %d%s",
3008 area->min_spf_interval[0], VTY_NEWLINE);
3009 write++;
3010 }
3011 if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL)
3012 {
3013 vty_out (vty, " spf-interval level-2 %d%s",
3014 area->min_spf_interval[1], VTY_NEWLINE);
3015 write++;
3016 }
3017 }
hasso53c997c2004-09-15 16:21:59 +00003018 /* Authentication passwords. */
Josh Bailey3f045a02012-03-24 08:35:20 -07003019 if (area->area_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
hasso53c997c2004-09-15 16:21:59 +00003020 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003021 vty_out(vty, " area-password md5 %s", area->area_passwd.passwd);
hasso1cbc5622005-01-01 10:29:51 +00003022 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
3023 {
3024 vty_out(vty, " authenticate snp ");
3025 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
3026 vty_out(vty, "validate");
3027 else
3028 vty_out(vty, "send-only");
3029 }
3030 vty_out(vty, "%s", VTY_NEWLINE);
hasso53c997c2004-09-15 16:21:59 +00003031 write++;
Josh Bailey3f045a02012-03-24 08:35:20 -07003032 }
3033 else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
3034 {
3035 vty_out(vty, " area-password clear %s", area->area_passwd.passwd);
3036 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
3037 {
3038 vty_out(vty, " authenticate snp ");
3039 if (CHECK_FLAG(area->area_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);
3045 write++;
3046 }
3047 if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
hasso53c997c2004-09-15 16:21:59 +00003048 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003049 vty_out(vty, " domain-password md5 %s",
3050 area->domain_passwd.passwd);
3051 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3052 {
3053 vty_out(vty, " authenticate snp ");
3054 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3055 vty_out(vty, "validate");
3056 else
3057 vty_out(vty, "send-only");
3058 }
3059 vty_out(vty, "%s", VTY_NEWLINE);
3060 write++;
3061 }
3062 else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
3063 {
3064 vty_out(vty, " domain-password clear %s",
3065 area->domain_passwd.passwd);
hasso1cbc5622005-01-01 10:29:51 +00003066 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3067 {
3068 vty_out(vty, " authenticate snp ");
3069 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3070 vty_out(vty, "validate");
3071 else
3072 vty_out(vty, "send-only");
3073 }
3074 vty_out(vty, "%s", VTY_NEWLINE);
hasso53c997c2004-09-15 16:21:59 +00003075 write++;
3076 }
hassof1082d12005-09-19 04:23:34 +00003077
Josh Bailey3f045a02012-03-24 08:35:20 -07003078 if (area->log_adj_changes)
3079 {
3080 vty_out (vty, " log-adjacency-changes%s", VTY_NEWLINE);
3081 write++;
3082 }
3083
hassof390d2c2004-09-10 20:48:21 +00003084#ifdef TOPOLOGY_GENERATE
hassof1082d12005-09-19 04:23:34 +00003085 if (memcmp (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS,
3086 ISIS_SYS_ID_LEN))
3087 {
3088 vty_out (vty, " topology base-is %s%s",
Josh Bailey3f045a02012-03-24 08:35:20 -07003089 sysid_print ((u_char *)area->topology_baseis), VTY_NEWLINE);
hassof1082d12005-09-19 04:23:34 +00003090 write++;
3091 }
3092 if (area->topology_basedynh)
3093 {
3094 vty_out (vty, " topology base-dynh %s%s",
3095 area->topology_basedynh, VTY_NEWLINE);
3096 write++;
3097 }
3098 /* We save the whole command line here. */
3099 if (strlen(area->top_params))
hassof390d2c2004-09-10 20:48:21 +00003100 {
3101 vty_out (vty, " %s%s", area->top_params, VTY_NEWLINE);
3102 write++;
3103 }
hassof390d2c2004-09-10 20:48:21 +00003104#endif /* TOPOLOGY_GENERATE */
hassof1082d12005-09-19 04:23:34 +00003105
hassof390d2c2004-09-10 20:48:21 +00003106 }
jardineb5d44e2003-12-23 08:09:43 +00003107 }
hassof390d2c2004-09-10 20:48:21 +00003108
jardineb5d44e2003-12-23 08:09:43 +00003109 return write;
3110}
3111
Josh Bailey3f045a02012-03-24 08:35:20 -07003112struct cmd_node isis_node = {
jardineb5d44e2003-12-23 08:09:43 +00003113 ISIS_NODE,
hasso2097cd82003-12-23 11:51:08 +00003114 "%s(config-router)# ",
jardineb5d44e2003-12-23 08:09:43 +00003115 1
3116};
3117
hassof390d2c2004-09-10 20:48:21 +00003118void
jardineb5d44e2003-12-23 08:09:43 +00003119isis_init ()
3120{
jardineb5d44e2003-12-23 08:09:43 +00003121 /* Install IS-IS top node */
3122 install_node (&isis_node, isis_config_write);
hassof390d2c2004-09-10 20:48:21 +00003123
Josh Bailey3f045a02012-03-24 08:35:20 -07003124 install_element (VIEW_NODE, &show_isis_summary_cmd);
3125
3126 install_element (VIEW_NODE, &show_isis_interface_cmd);
3127 install_element (VIEW_NODE, &show_isis_interface_detail_cmd);
3128 install_element (VIEW_NODE, &show_isis_interface_arg_cmd);
3129
3130 install_element (VIEW_NODE, &show_isis_neighbor_cmd);
3131 install_element (VIEW_NODE, &show_isis_neighbor_detail_cmd);
3132 install_element (VIEW_NODE, &show_isis_neighbor_arg_cmd);
3133 install_element (VIEW_NODE, &clear_isis_neighbor_cmd);
3134 install_element (VIEW_NODE, &clear_isis_neighbor_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003135
3136 install_element (VIEW_NODE, &show_hostname_cmd);
3137 install_element (VIEW_NODE, &show_database_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003138 install_element (VIEW_NODE, &show_database_arg_cmd);
3139 install_element (VIEW_NODE, &show_database_arg_detail_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003140 install_element (VIEW_NODE, &show_database_detail_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003141 install_element (VIEW_NODE, &show_database_detail_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003142
Josh Bailey3f045a02012-03-24 08:35:20 -07003143 install_element (ENABLE_NODE, &show_isis_summary_cmd);
3144
3145 install_element (ENABLE_NODE, &show_isis_interface_cmd);
3146 install_element (ENABLE_NODE, &show_isis_interface_detail_cmd);
3147 install_element (ENABLE_NODE, &show_isis_interface_arg_cmd);
3148
3149 install_element (ENABLE_NODE, &show_isis_neighbor_cmd);
3150 install_element (ENABLE_NODE, &show_isis_neighbor_detail_cmd);
3151 install_element (ENABLE_NODE, &show_isis_neighbor_arg_cmd);
3152 install_element (ENABLE_NODE, &clear_isis_neighbor_cmd);
3153 install_element (ENABLE_NODE, &clear_isis_neighbor_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003154
3155 install_element (ENABLE_NODE, &show_hostname_cmd);
3156 install_element (ENABLE_NODE, &show_database_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003157 install_element (ENABLE_NODE, &show_database_arg_cmd);
3158 install_element (ENABLE_NODE, &show_database_arg_detail_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003159 install_element (ENABLE_NODE, &show_database_detail_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003160 install_element (ENABLE_NODE, &show_database_detail_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003161 install_element (ENABLE_NODE, &show_debugging_cmd);
3162
hassof390d2c2004-09-10 20:48:21 +00003163 install_node (&debug_node, config_write_debug);
jardin9e867fe2003-12-23 08:56:18 +00003164
jardineb5d44e2003-12-23 08:09:43 +00003165 install_element (ENABLE_NODE, &debug_isis_adj_cmd);
3166 install_element (ENABLE_NODE, &no_debug_isis_adj_cmd);
3167 install_element (ENABLE_NODE, &debug_isis_csum_cmd);
3168 install_element (ENABLE_NODE, &no_debug_isis_csum_cmd);
3169 install_element (ENABLE_NODE, &debug_isis_lupd_cmd);
3170 install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd);
3171 install_element (ENABLE_NODE, &debug_isis_err_cmd);
3172 install_element (ENABLE_NODE, &no_debug_isis_err_cmd);
3173 install_element (ENABLE_NODE, &debug_isis_snp_cmd);
3174 install_element (ENABLE_NODE, &no_debug_isis_snp_cmd);
3175 install_element (ENABLE_NODE, &debug_isis_upd_cmd);
3176 install_element (ENABLE_NODE, &no_debug_isis_upd_cmd);
3177 install_element (ENABLE_NODE, &debug_isis_spfevents_cmd);
3178 install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd);
3179 install_element (ENABLE_NODE, &debug_isis_spfstats_cmd);
3180 install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd);
3181 install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd);
3182 install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd);
3183 install_element (ENABLE_NODE, &debug_isis_rtevents_cmd);
3184 install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd);
3185 install_element (ENABLE_NODE, &debug_isis_events_cmd);
3186 install_element (ENABLE_NODE, &no_debug_isis_events_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003187 install_element (ENABLE_NODE, &debug_isis_packet_dump_cmd);
3188 install_element (ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003189
jardin9e867fe2003-12-23 08:56:18 +00003190 install_element (CONFIG_NODE, &debug_isis_adj_cmd);
3191 install_element (CONFIG_NODE, &no_debug_isis_adj_cmd);
3192 install_element (CONFIG_NODE, &debug_isis_csum_cmd);
3193 install_element (CONFIG_NODE, &no_debug_isis_csum_cmd);
3194 install_element (CONFIG_NODE, &debug_isis_lupd_cmd);
3195 install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd);
3196 install_element (CONFIG_NODE, &debug_isis_err_cmd);
3197 install_element (CONFIG_NODE, &no_debug_isis_err_cmd);
3198 install_element (CONFIG_NODE, &debug_isis_snp_cmd);
3199 install_element (CONFIG_NODE, &no_debug_isis_snp_cmd);
3200 install_element (CONFIG_NODE, &debug_isis_upd_cmd);
3201 install_element (CONFIG_NODE, &no_debug_isis_upd_cmd);
3202 install_element (CONFIG_NODE, &debug_isis_spfevents_cmd);
3203 install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd);
3204 install_element (CONFIG_NODE, &debug_isis_spfstats_cmd);
3205 install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd);
3206 install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd);
3207 install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd);
3208 install_element (CONFIG_NODE, &debug_isis_rtevents_cmd);
3209 install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd);
3210 install_element (CONFIG_NODE, &debug_isis_events_cmd);
3211 install_element (CONFIG_NODE, &no_debug_isis_events_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003212 install_element (CONFIG_NODE, &debug_isis_packet_dump_cmd);
3213 install_element (CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
jardin9e867fe2003-12-23 08:56:18 +00003214
jardineb5d44e2003-12-23 08:09:43 +00003215 install_element (CONFIG_NODE, &router_isis_cmd);
3216 install_element (CONFIG_NODE, &no_router_isis_cmd);
3217
3218 install_default (ISIS_NODE);
3219
3220 install_element (ISIS_NODE, &net_cmd);
3221 install_element (ISIS_NODE, &no_net_cmd);
3222
3223 install_element (ISIS_NODE, &is_type_cmd);
3224 install_element (ISIS_NODE, &no_is_type_cmd);
3225
Josh Bailey3f045a02012-03-24 08:35:20 -07003226 install_element (ISIS_NODE, &area_passwd_md5_cmd);
3227 install_element (ISIS_NODE, &area_passwd_md5_snpauth_cmd);
3228 install_element (ISIS_NODE, &area_passwd_clear_cmd);
3229 install_element (ISIS_NODE, &area_passwd_clear_snpauth_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003230 install_element (ISIS_NODE, &no_area_passwd_cmd);
3231
Josh Bailey3f045a02012-03-24 08:35:20 -07003232 install_element (ISIS_NODE, &domain_passwd_md5_cmd);
3233 install_element (ISIS_NODE, &domain_passwd_md5_snpauth_cmd);
3234 install_element (ISIS_NODE, &domain_passwd_clear_cmd);
3235 install_element (ISIS_NODE, &domain_passwd_clear_snpauth_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003236 install_element (ISIS_NODE, &no_domain_passwd_cmd);
3237
3238 install_element (ISIS_NODE, &lsp_gen_interval_cmd);
3239 install_element (ISIS_NODE, &no_lsp_gen_interval_cmd);
3240 install_element (ISIS_NODE, &no_lsp_gen_interval_arg_cmd);
3241 install_element (ISIS_NODE, &lsp_gen_interval_l1_cmd);
3242 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_cmd);
3243 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_arg_cmd);
3244 install_element (ISIS_NODE, &lsp_gen_interval_l2_cmd);
3245 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_cmd);
3246 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_arg_cmd);
3247
3248 install_element (ISIS_NODE, &spf_interval_cmd);
3249 install_element (ISIS_NODE, &no_spf_interval_cmd);
3250 install_element (ISIS_NODE, &no_spf_interval_arg_cmd);
3251 install_element (ISIS_NODE, &spf_interval_l1_cmd);
3252 install_element (ISIS_NODE, &no_spf_interval_l1_cmd);
3253 install_element (ISIS_NODE, &no_spf_interval_l1_arg_cmd);
3254 install_element (ISIS_NODE, &spf_interval_l2_cmd);
3255 install_element (ISIS_NODE, &no_spf_interval_l2_cmd);
3256 install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd);
hassof390d2c2004-09-10 20:48:21 +00003257
Josh Bailey3f045a02012-03-24 08:35:20 -07003258 install_element (ISIS_NODE, &max_lsp_lifetime_cmd);
3259 install_element (ISIS_NODE, &no_max_lsp_lifetime_cmd);
3260 install_element (ISIS_NODE, &no_max_lsp_lifetime_arg_cmd);
3261 install_element (ISIS_NODE, &max_lsp_lifetime_l1_cmd);
3262 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_cmd);
3263 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_arg_cmd);
3264 install_element (ISIS_NODE, &max_lsp_lifetime_l2_cmd);
3265 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_cmd);
3266 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_arg_cmd);
3267
3268 install_element (ISIS_NODE, &lsp_refresh_interval_cmd);
3269 install_element (ISIS_NODE, &no_lsp_refresh_interval_cmd);
3270 install_element (ISIS_NODE, &no_lsp_refresh_interval_arg_cmd);
3271 install_element (ISIS_NODE, &lsp_refresh_interval_l1_cmd);
3272 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_cmd);
3273 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_arg_cmd);
3274 install_element (ISIS_NODE, &lsp_refresh_interval_l2_cmd);
3275 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_cmd);
3276 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_arg_cmd);
3277
3278 install_element (ISIS_NODE, &set_overload_bit_cmd);
3279 install_element (ISIS_NODE, &no_set_overload_bit_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003280
Amritha Nambiarc8ee9402015-08-24 16:40:14 -07003281 install_element (ISIS_NODE, &set_attached_bit_cmd);
3282 install_element (ISIS_NODE, &no_set_attached_bit_cmd);
3283
jardineb5d44e2003-12-23 08:09:43 +00003284 install_element (ISIS_NODE, &dynamic_hostname_cmd);
3285 install_element (ISIS_NODE, &no_dynamic_hostname_cmd);
3286
3287 install_element (ISIS_NODE, &metric_style_cmd);
3288 install_element (ISIS_NODE, &no_metric_style_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003289
3290 install_element (ISIS_NODE, &log_adj_changes_cmd);
3291 install_element (ISIS_NODE, &no_log_adj_changes_cmd);
3292
jardineb5d44e2003-12-23 08:09:43 +00003293#ifdef TOPOLOGY_GENERATE
3294 install_element (ISIS_NODE, &topology_generate_grid_cmd);
3295 install_element (ISIS_NODE, &topology_baseis_cmd);
hassof1082d12005-09-19 04:23:34 +00003296 install_element (ISIS_NODE, &topology_basedynh_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003297 install_element (ISIS_NODE, &no_topology_baseis_cmd);
hassof1082d12005-09-19 04:23:34 +00003298 install_element (ISIS_NODE, &no_topology_baseis_noid_cmd);
hassof695b012005-04-02 19:03:39 +00003299 install_element (VIEW_NODE, &show_isis_generated_topology_cmd);
3300 install_element (ENABLE_NODE, &show_isis_generated_topology_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003301#endif /* TOPOLOGY_GENERATE */
jardineb5d44e2003-12-23 08:09:43 +00003302}