blob: 202b04061c8989a6e485f87fad0ead512ccfe1fd [file] [log] [blame]
jardineb5d44e2003-12-23 08:09:43 +00001/*
2 * IS-IS Rout(e)ing protocol - isisd.c
3 *
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public Licenseas published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
jardineb5d44e2003-12-23 08:09:43 +000023#include <zebra.h>
jardineb5d44e2003-12-23 08:09:43 +000024
25#include "thread.h"
26#include "vty.h"
27#include "command.h"
28#include "log.h"
29#include "memory.h"
Josh Bailey3f045a02012-03-24 08:35:20 -070030#include "time.h"
jardineb5d44e2003-12-23 08:09:43 +000031#include "linklist.h"
32#include "if.h"
33#include "hash.h"
34#include "stream.h"
35#include "prefix.h"
36#include "table.h"
37
38#include "isisd/dict.h"
39#include "isisd/include-netbsd/iso.h"
40#include "isisd/isis_constants.h"
41#include "isisd/isis_common.h"
jardineb5d44e2003-12-23 08:09:43 +000042#include "isisd/isis_flags.h"
Josh Bailey3f045a02012-03-24 08:35:20 -070043#include "isisd/isis_circuit.h"
44#include "isisd/isis_csm.h"
jardineb5d44e2003-12-23 08:09:43 +000045#include "isisd/isisd.h"
46#include "isisd/isis_dynhn.h"
47#include "isisd/isis_adjacency.h"
48#include "isisd/isis_pdu.h"
49#include "isisd/isis_misc.h"
50#include "isisd/isis_constants.h"
51#include "isisd/isis_tlv.h"
52#include "isisd/isis_lsp.h"
53#include "isisd/isis_spf.h"
54#include "isisd/isis_route.h"
55#include "isisd/isis_zebra.h"
56#include "isisd/isis_events.h"
57
58#ifdef TOPOLOGY_GENERATE
59#include "spgrid.h"
hassof390d2c2004-09-10 20:48:21 +000060u_char DEFAULT_TOPOLOGY_BASEIS[6] = { 0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00 };
jardineb5d44e2003-12-23 08:09:43 +000061#endif /* TOPOLOGY_GENERATE */
62
jardineb5d44e2003-12-23 08:09:43 +000063struct isis *isis = NULL;
jardineb5d44e2003-12-23 08:09:43 +000064
Paul Jakma41b36e92006-12-08 01:09:50 +000065/*
66 * Prototypes.
67 */
Paul Jakma41b36e92006-12-08 01:09:50 +000068int isis_area_get(struct vty *, const char *);
69int isis_area_destroy(struct vty *, const char *);
Josh Bailey3f045a02012-03-24 08:35:20 -070070int area_net_title(struct vty *, const char *);
71int area_clear_net_title(struct vty *, const char *);
72int show_isis_interface_common(struct vty *, const char *ifname, char);
73int show_isis_neighbor_common(struct vty *, const char *id, char);
74int clear_isis_neighbor_common(struct vty *, const char *id);
Paul Jakma41b36e92006-12-08 01:09:50 +000075int isis_config_write(struct vty *);
76
77
78
jardineb5d44e2003-12-23 08:09:43 +000079void
80isis_new (unsigned long process_id)
81{
hassoaac372f2005-09-01 17:52:33 +000082 isis = XCALLOC (MTYPE_ISIS, sizeof (struct isis));
jardineb5d44e2003-12-23 08:09:43 +000083 /*
84 * Default values
85 */
86 isis->max_area_addrs = 3;
jardineb5d44e2003-12-23 08:09:43 +000087 isis->process_id = process_id;
Josh Bailey3f045a02012-03-24 08:35:20 -070088 isis->router_id = 0;
jardineb5d44e2003-12-23 08:09:43 +000089 isis->area_list = list_new ();
90 isis->init_circ_list = list_new ();
91 isis->uptime = time (NULL);
92 isis->nexthops = list_new ();
93#ifdef HAVE_IPV6
94 isis->nexthops6 = list_new ();
95#endif /* HAVE_IPV6 */
Josh Bailey3f045a02012-03-24 08:35:20 -070096 dyn_cache_init ();
jardineb5d44e2003-12-23 08:09:43 +000097 /*
98 * uncomment the next line for full debugs
99 */
hassof390d2c2004-09-10 20:48:21 +0000100 /* isis->debugs = 0xFFFF; */
jardineb5d44e2003-12-23 08:09:43 +0000101}
102
103struct isis_area *
Josh Bailey3f045a02012-03-24 08:35:20 -0700104isis_area_create (const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000105{
jardineb5d44e2003-12-23 08:09:43 +0000106 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000107
hassoaac372f2005-09-01 17:52:33 +0000108 area = XCALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area));
jardineb5d44e2003-12-23 08:09:43 +0000109
110 /*
111 * The first instance is level-1-2 rest are level-1, unless otherwise
112 * configured
113 */
114 if (listcount (isis->area_list) > 0)
115 area->is_type = IS_LEVEL_1;
116 else
117 area->is_type = IS_LEVEL_1_AND_2;
Josh Bailey3f045a02012-03-24 08:35:20 -0700118
jardineb5d44e2003-12-23 08:09:43 +0000119 /*
120 * intialize the databases
121 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700122 if (area->is_type & IS_LEVEL_1)
123 {
124 area->lspdb[0] = lsp_db_init ();
125 area->route_table[0] = route_table_init ();
126#ifdef HAVE_IPV6
127 area->route_table6[0] = route_table_init ();
128#endif /* HAVE_IPV6 */
129 }
130 if (area->is_type & IS_LEVEL_2)
131 {
132 area->lspdb[1] = lsp_db_init ();
133 area->route_table[1] = route_table_init ();
134#ifdef HAVE_IPV6
135 area->route_table6[1] = route_table_init ();
136#endif /* HAVE_IPV6 */
137 }
hassof390d2c2004-09-10 20:48:21 +0000138
jardineb5d44e2003-12-23 08:09:43 +0000139 spftree_area_init (area);
Josh Bailey3f045a02012-03-24 08:35:20 -0700140
jardineb5d44e2003-12-23 08:09:43 +0000141 area->circuit_list = list_new ();
142 area->area_addrs = list_new ();
hassof390d2c2004-09-10 20:48:21 +0000143 THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
Paul Jakmac7350c42008-01-29 19:29:44 +0000144 flags_initialize (&area->flags);
Josh Bailey3f045a02012-03-24 08:35:20 -0700145
jardineb5d44e2003-12-23 08:09:43 +0000146 /*
147 * Default values
148 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700149 area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */
150 area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */
151 area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
152 area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
153 area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL;
154 area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL;
jardineb5d44e2003-12-23 08:09:43 +0000155 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
156 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
157 area->dynhostname = 1;
Josh Bailey3f045a02012-03-24 08:35:20 -0700158 area->oldmetric = 0;
159 area->newmetric = 1;
jardineb5d44e2003-12-23 08:09:43 +0000160 area->lsp_frag_threshold = 90;
Christian Frankef1fc1db2015-11-10 18:43:31 +0100161 area->lsp_mtu = DEFAULT_LSP_MTU;
jardineb5d44e2003-12-23 08:09:43 +0000162#ifdef TOPOLOGY_GENERATE
163 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
164#endif /* TOPOLOGY_GENERATE */
165
Josh Bailey3f045a02012-03-24 08:35:20 -0700166 area->area_tag = strdup (area_tag);
167 listnode_add (isis->area_list, area);
168 area->isis = isis;
169
jardineb5d44e2003-12-23 08:09:43 +0000170 return area;
171}
172
173struct isis_area *
hassof90a5f62004-10-11 13:11:56 +0000174isis_area_lookup (const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000175{
176 struct isis_area *area;
hasso3fdb2dd2005-09-28 18:45:54 +0000177 struct listnode *node;
hassof390d2c2004-09-10 20:48:21 +0000178
hasso3fdb2dd2005-09-28 18:45:54 +0000179 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
jardineb5d44e2003-12-23 08:09:43 +0000180 if ((area->area_tag == NULL && area_tag == NULL) ||
hassof390d2c2004-09-10 20:48:21 +0000181 (area->area_tag && area_tag
182 && strcmp (area->area_tag, area_tag) == 0))
183 return area;
184
jardineb5d44e2003-12-23 08:09:43 +0000185 return NULL;
186}
187
hassof390d2c2004-09-10 20:48:21 +0000188int
hassof90a5f62004-10-11 13:11:56 +0000189isis_area_get (struct vty *vty, const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000190{
jardineb5d44e2003-12-23 08:09:43 +0000191 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000192
jardineb5d44e2003-12-23 08:09:43 +0000193 area = isis_area_lookup (area_tag);
hassof390d2c2004-09-10 20:48:21 +0000194
195 if (area)
196 {
197 vty->node = ISIS_NODE;
198 vty->index = area;
199 return CMD_SUCCESS;
200 }
201
Josh Bailey3f045a02012-03-24 08:35:20 -0700202 area = isis_area_create (area_tag);
hassof390d2c2004-09-10 20:48:21 +0000203
hassoc89c05d2005-09-04 21:36:36 +0000204 if (isis->debugs & DEBUG_EVENTS)
205 zlog_debug ("New IS-IS area instance %s", area->area_tag);
jardineb5d44e2003-12-23 08:09:43 +0000206
207 vty->node = ISIS_NODE;
208 vty->index = area;
hassof390d2c2004-09-10 20:48:21 +0000209
jardineb5d44e2003-12-23 08:09:43 +0000210 return CMD_SUCCESS;
211}
212
213int
hassof90a5f62004-10-11 13:11:56 +0000214isis_area_destroy (struct vty *vty, const char *area_tag)
jardineb5d44e2003-12-23 08:09:43 +0000215{
jardineb5d44e2003-12-23 08:09:43 +0000216 struct isis_area *area;
paul1eb8ef22005-04-07 07:30:20 +0000217 struct listnode *node, *nnode;
jardineb5d44e2003-12-23 08:09:43 +0000218 struct isis_circuit *circuit;
Josh Bailey3f045a02012-03-24 08:35:20 -0700219 struct area_addr *addr;
jardineb5d44e2003-12-23 08:09:43 +0000220
221 area = isis_area_lookup (area_tag);
jardineb5d44e2003-12-23 08:09:43 +0000222
hassof390d2c2004-09-10 20:48:21 +0000223 if (area == NULL)
224 {
225 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -0700226 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +0000227 }
hassof390d2c2004-09-10 20:48:21 +0000228
229 if (area->circuit_list)
230 {
paul1eb8ef22005-04-07 07:30:20 +0000231 for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
Josh Bailey3f045a02012-03-24 08:35:20 -0700232 {
233 circuit->ip_router = 0;
234#ifdef HAVE_IPV6
235 circuit->ipv6_router = 0;
236#endif
237 isis_csm_state_change (ISIS_DISABLE, circuit, area);
238 }
hassof390d2c2004-09-10 20:48:21 +0000239 list_delete (area->circuit_list);
Josh Bailey3f045a02012-03-24 08:35:20 -0700240 area->circuit_list = NULL;
hassof390d2c2004-09-10 20:48:21 +0000241 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700242
243 if (area->lspdb[0] != NULL)
244 {
245 lsp_db_destroy (area->lspdb[0]);
246 area->lspdb[0] = NULL;
247 }
248 if (area->lspdb[1] != NULL)
249 {
250 lsp_db_destroy (area->lspdb[1]);
251 area->lspdb[1] = NULL;
252 }
253
254 spftree_area_del (area);
255
256 /* invalidate and validate would delete all routes from zebra */
257 isis_route_invalidate (area);
258 isis_route_validate (area);
259
260 if (area->route_table[0])
261 {
262 route_table_finish (area->route_table[0]);
263 area->route_table[0] = NULL;
264 }
265 if (area->route_table[1])
266 {
267 route_table_finish (area->route_table[1]);
268 area->route_table[1] = NULL;
269 }
270#ifdef HAVE_IPV6
271 if (area->route_table6[0])
272 {
273 route_table_finish (area->route_table6[0]);
274 area->route_table6[0] = NULL;
275 }
276 if (area->route_table6[1])
277 {
278 route_table_finish (area->route_table6[1]);
279 area->route_table6[1] = NULL;
280 }
281#endif /* HAVE_IPV6 */
282
Christian Frankeacf98652015-11-12 14:24:22 +0100283 isis_redist_area_finish(area);
284
Josh Bailey3f045a02012-03-24 08:35:20 -0700285 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);
Christian Franke80a8f722015-11-12 14:21:47 +0100777 if (flags & DEBUG_LSP_GEN)
778 vty_out (vty, "IS-IS LSP generation debugging is %s%s", onoffs, VTY_NEWLINE);
Christian Franke61010c32015-11-10 18:43:34 +0100779 if (flags & DEBUG_LSP_SCHED)
780 vty_out (vty, "IS-IS LSP scheduling debugging is %s%s", onoffs, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000781}
782
783DEFUN (show_debugging,
784 show_debugging_cmd,
785 "show debugging",
786 SHOW_STR
787 "State of each debugging option\n")
788{
hassof390d2c2004-09-10 20:48:21 +0000789 vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000790 print_debug (vty, isis->debugs, 1);
791 return CMD_SUCCESS;
792}
793
jardin9e867fe2003-12-23 08:56:18 +0000794/* Debug node. */
hassof390d2c2004-09-10 20:48:21 +0000795static struct cmd_node debug_node = {
jardin9e867fe2003-12-23 08:56:18 +0000796 DEBUG_NODE,
hassof390d2c2004-09-10 20:48:21 +0000797 "",
798 1
jardin9e867fe2003-12-23 08:56:18 +0000799};
800
801static int
802config_write_debug (struct vty *vty)
803{
804 int write = 0;
805 int flags = isis->debugs;
806
hassof390d2c2004-09-10 20:48:21 +0000807 if (flags & DEBUG_ADJ_PACKETS)
808 {
809 vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
810 write++;
811 }
812 if (flags & DEBUG_CHECKSUM_ERRORS)
813 {
814 vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
815 write++;
816 }
817 if (flags & DEBUG_LOCAL_UPDATES)
818 {
819 vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
820 write++;
821 }
822 if (flags & DEBUG_PROTOCOL_ERRORS)
823 {
824 vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
825 write++;
826 }
827 if (flags & DEBUG_SNP_PACKETS)
828 {
829 vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
830 write++;
831 }
832 if (flags & DEBUG_SPF_EVENTS)
833 {
834 vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
835 write++;
836 }
837 if (flags & DEBUG_SPF_STATS)
838 {
839 vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
840 write++;
841 }
842 if (flags & DEBUG_SPF_TRIGGERS)
843 {
844 vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
845 write++;
846 }
847 if (flags & DEBUG_UPDATE_PACKETS)
848 {
849 vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
850 write++;
851 }
852 if (flags & DEBUG_RTE_EVENTS)
853 {
854 vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
855 write++;
856 }
857 if (flags & DEBUG_EVENTS)
858 {
859 vty_out (vty, "debug isis events%s", VTY_NEWLINE);
860 write++;
861 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700862 if (flags & DEBUG_PACKET_DUMP)
863 {
864 vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE);
865 write++;
866 }
Christian Franke80a8f722015-11-12 14:21:47 +0100867 if (flags & DEBUG_LSP_GEN)
868 {
869 vty_out (vty, "debug isis lsp-gen%s", VTY_NEWLINE);
870 write++;
871 }
Christian Franke61010c32015-11-10 18:43:34 +0100872 if (flags & DEBUG_LSP_SCHED)
873 {
874 vty_out (vty, "debug isis lsp-sched%s", VTY_NEWLINE);
875 write++;
876 }
jardin9e867fe2003-12-23 08:56:18 +0000877
878 return write;
879}
880
jardineb5d44e2003-12-23 08:09:43 +0000881DEFUN (debug_isis_adj,
882 debug_isis_adj_cmd,
883 "debug isis adj-packets",
884 DEBUG_STR
885 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000886 "IS-IS Adjacency related packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000887{
888 isis->debugs |= DEBUG_ADJ_PACKETS;
hassof390d2c2004-09-10 20:48:21 +0000889 print_debug (vty, DEBUG_ADJ_PACKETS, 1);
jardineb5d44e2003-12-23 08:09:43 +0000890
891 return CMD_SUCCESS;
892}
893
894DEFUN (no_debug_isis_adj,
895 no_debug_isis_adj_cmd,
896 "no debug isis adj-packets",
897 UNDEBUG_STR
898 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000899 "IS-IS Adjacency related packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000900{
jardineb5d44e2003-12-23 08:09:43 +0000901 isis->debugs &= ~DEBUG_ADJ_PACKETS;
902 print_debug (vty, DEBUG_ADJ_PACKETS, 0);
903
904 return CMD_SUCCESS;
905}
906
jardineb5d44e2003-12-23 08:09:43 +0000907DEFUN (debug_isis_csum,
908 debug_isis_csum_cmd,
909 "debug isis checksum-errors",
910 DEBUG_STR
911 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000912 "IS-IS LSP checksum errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000913{
914 isis->debugs |= DEBUG_CHECKSUM_ERRORS;
915 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1);
916
917 return CMD_SUCCESS;
918}
919
920DEFUN (no_debug_isis_csum,
921 no_debug_isis_csum_cmd,
922 "no debug isis checksum-errors",
923 UNDEBUG_STR
924 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000925 "IS-IS LSP checksum errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000926{
927 isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
928 print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
hassof390d2c2004-09-10 20:48:21 +0000929
jardineb5d44e2003-12-23 08:09:43 +0000930 return CMD_SUCCESS;
931}
932
933DEFUN (debug_isis_lupd,
934 debug_isis_lupd_cmd,
935 "debug isis local-updates",
936 DEBUG_STR
937 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000938 "IS-IS local update packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000939{
940 isis->debugs |= DEBUG_LOCAL_UPDATES;
941 print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
942
943 return CMD_SUCCESS;
944}
945
946DEFUN (no_debug_isis_lupd,
947 no_debug_isis_lupd_cmd,
948 "no debug isis local-updates",
949 UNDEBUG_STR
950 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000951 "IS-IS local update packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000952{
953 isis->debugs &= ~DEBUG_LOCAL_UPDATES;
hassof390d2c2004-09-10 20:48:21 +0000954 print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
955
jardineb5d44e2003-12-23 08:09:43 +0000956 return CMD_SUCCESS;
957}
958
959DEFUN (debug_isis_err,
960 debug_isis_err_cmd,
hassof390d2c2004-09-10 20:48:21 +0000961 "debug isis protocol-errors",
jardineb5d44e2003-12-23 08:09:43 +0000962 DEBUG_STR
963 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000964 "IS-IS LSP protocol errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000965{
966 isis->debugs |= DEBUG_PROTOCOL_ERRORS;
967 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1);
968
969 return CMD_SUCCESS;
970}
971
972DEFUN (no_debug_isis_err,
973 no_debug_isis_err_cmd,
974 "no debug isis protocol-errors",
975 UNDEBUG_STR
976 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000977 "IS-IS LSP protocol errors\n")
jardineb5d44e2003-12-23 08:09:43 +0000978{
979 isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
980 print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
hassof390d2c2004-09-10 20:48:21 +0000981
jardineb5d44e2003-12-23 08:09:43 +0000982 return CMD_SUCCESS;
983}
984
985DEFUN (debug_isis_snp,
986 debug_isis_snp_cmd,
987 "debug isis snp-packets",
988 DEBUG_STR
989 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +0000990 "IS-IS CSNP/PSNP packets\n")
jardineb5d44e2003-12-23 08:09:43 +0000991{
992 isis->debugs |= DEBUG_SNP_PACKETS;
993 print_debug (vty, DEBUG_SNP_PACKETS, 1);
994
995 return CMD_SUCCESS;
996}
997
998DEFUN (no_debug_isis_snp,
999 no_debug_isis_snp_cmd,
1000 "no debug isis snp-packets",
1001 UNDEBUG_STR
1002 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001003 "IS-IS CSNP/PSNP packets\n")
jardineb5d44e2003-12-23 08:09:43 +00001004{
hassof390d2c2004-09-10 20:48:21 +00001005 isis->debugs &= ~DEBUG_SNP_PACKETS;
jardineb5d44e2003-12-23 08:09:43 +00001006 print_debug (vty, DEBUG_SNP_PACKETS, 0);
hassof390d2c2004-09-10 20:48:21 +00001007
jardineb5d44e2003-12-23 08:09:43 +00001008 return CMD_SUCCESS;
1009}
1010
jardineb5d44e2003-12-23 08:09:43 +00001011DEFUN (debug_isis_upd,
1012 debug_isis_upd_cmd,
1013 "debug isis update-packets",
1014 DEBUG_STR
1015 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001016 "IS-IS Update related packets\n")
jardineb5d44e2003-12-23 08:09:43 +00001017{
1018 isis->debugs |= DEBUG_UPDATE_PACKETS;
1019 print_debug (vty, DEBUG_UPDATE_PACKETS, 1);
1020
1021 return CMD_SUCCESS;
1022}
1023
1024DEFUN (no_debug_isis_upd,
1025 no_debug_isis_upd_cmd,
1026 "no debug isis update-packets",
1027 UNDEBUG_STR
1028 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001029 "IS-IS Update related packets\n")
jardineb5d44e2003-12-23 08:09:43 +00001030{
1031 isis->debugs &= ~DEBUG_UPDATE_PACKETS;
1032 print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
hassof390d2c2004-09-10 20:48:21 +00001033
jardineb5d44e2003-12-23 08:09:43 +00001034 return CMD_SUCCESS;
1035}
1036
jardineb5d44e2003-12-23 08:09:43 +00001037DEFUN (debug_isis_spfevents,
1038 debug_isis_spfevents_cmd,
1039 "debug isis spf-events",
1040 DEBUG_STR
1041 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001042 "IS-IS Shortest Path First Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001043{
1044 isis->debugs |= DEBUG_SPF_EVENTS;
hassof390d2c2004-09-10 20:48:21 +00001045 print_debug (vty, DEBUG_SPF_EVENTS, 1);
jardineb5d44e2003-12-23 08:09:43 +00001046
1047 return CMD_SUCCESS;
1048}
1049
1050DEFUN (no_debug_isis_spfevents,
1051 no_debug_isis_spfevents_cmd,
1052 "no debug isis spf-events",
1053 UNDEBUG_STR
1054 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001055 "IS-IS Shortest Path First Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001056{
1057 isis->debugs &= ~DEBUG_SPF_EVENTS;
hassof390d2c2004-09-10 20:48:21 +00001058 print_debug (vty, DEBUG_SPF_EVENTS, 0);
1059
jardineb5d44e2003-12-23 08:09:43 +00001060 return CMD_SUCCESS;
1061}
1062
jardineb5d44e2003-12-23 08:09:43 +00001063DEFUN (debug_isis_spfstats,
1064 debug_isis_spfstats_cmd,
1065 "debug isis spf-statistics ",
1066 DEBUG_STR
1067 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001068 "IS-IS SPF Timing and Statistic Data\n")
jardineb5d44e2003-12-23 08:09:43 +00001069{
1070 isis->debugs |= DEBUG_SPF_STATS;
1071 print_debug (vty, DEBUG_SPF_STATS, 1);
1072
1073 return CMD_SUCCESS;
1074}
1075
1076DEFUN (no_debug_isis_spfstats,
1077 no_debug_isis_spfstats_cmd,
1078 "no debug isis spf-statistics",
1079 UNDEBUG_STR
1080 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001081 "IS-IS SPF Timing and Statistic Data\n")
jardineb5d44e2003-12-23 08:09:43 +00001082{
1083 isis->debugs &= ~DEBUG_SPF_STATS;
1084 print_debug (vty, DEBUG_SPF_STATS, 0);
hassof390d2c2004-09-10 20:48:21 +00001085
jardineb5d44e2003-12-23 08:09:43 +00001086 return CMD_SUCCESS;
1087}
1088
1089DEFUN (debug_isis_spftrigg,
1090 debug_isis_spftrigg_cmd,
1091 "debug isis spf-triggers",
1092 DEBUG_STR
1093 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001094 "IS-IS SPF triggering events\n")
jardineb5d44e2003-12-23 08:09:43 +00001095{
1096 isis->debugs |= DEBUG_SPF_TRIGGERS;
1097 print_debug (vty, DEBUG_SPF_TRIGGERS, 1);
1098
1099 return CMD_SUCCESS;
1100}
1101
1102DEFUN (no_debug_isis_spftrigg,
1103 no_debug_isis_spftrigg_cmd,
1104 "no debug isis spf-triggers",
1105 UNDEBUG_STR
1106 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001107 "IS-IS SPF triggering events\n")
jardineb5d44e2003-12-23 08:09:43 +00001108{
1109 isis->debugs &= ~DEBUG_SPF_TRIGGERS;
1110 print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
hassof390d2c2004-09-10 20:48:21 +00001111
jardineb5d44e2003-12-23 08:09:43 +00001112 return CMD_SUCCESS;
1113}
1114
1115DEFUN (debug_isis_rtevents,
1116 debug_isis_rtevents_cmd,
1117 "debug isis route-events",
1118 DEBUG_STR
1119 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001120 "IS-IS Route related events\n")
jardineb5d44e2003-12-23 08:09:43 +00001121{
1122 isis->debugs |= DEBUG_RTE_EVENTS;
1123 print_debug (vty, DEBUG_RTE_EVENTS, 1);
1124
1125 return CMD_SUCCESS;
1126}
1127
1128DEFUN (no_debug_isis_rtevents,
1129 no_debug_isis_rtevents_cmd,
1130 "no debug isis route-events",
1131 UNDEBUG_STR
1132 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001133 "IS-IS Route related events\n")
jardineb5d44e2003-12-23 08:09:43 +00001134{
1135 isis->debugs &= ~DEBUG_RTE_EVENTS;
1136 print_debug (vty, DEBUG_RTE_EVENTS, 0);
hassof390d2c2004-09-10 20:48:21 +00001137
jardineb5d44e2003-12-23 08:09:43 +00001138 return CMD_SUCCESS;
1139}
1140
1141DEFUN (debug_isis_events,
1142 debug_isis_events_cmd,
1143 "debug isis events",
1144 DEBUG_STR
1145 "IS-IS information\n"
hassof1082d12005-09-19 04:23:34 +00001146 "IS-IS Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001147{
1148 isis->debugs |= DEBUG_EVENTS;
1149 print_debug (vty, DEBUG_EVENTS, 1);
1150
1151 return CMD_SUCCESS;
1152}
1153
1154DEFUN (no_debug_isis_events,
1155 no_debug_isis_events_cmd,
1156 "no debug isis events",
1157 UNDEBUG_STR
1158 "IS-IS information\n"
hassof390d2c2004-09-10 20:48:21 +00001159 "IS-IS Events\n")
jardineb5d44e2003-12-23 08:09:43 +00001160{
1161 isis->debugs &= ~DEBUG_EVENTS;
1162 print_debug (vty, DEBUG_EVENTS, 0);
hassof390d2c2004-09-10 20:48:21 +00001163
jardineb5d44e2003-12-23 08:09:43 +00001164 return CMD_SUCCESS;
1165}
1166
Josh Bailey3f045a02012-03-24 08:35:20 -07001167DEFUN (debug_isis_packet_dump,
1168 debug_isis_packet_dump_cmd,
1169 "debug isis packet-dump",
1170 DEBUG_STR
1171 "IS-IS information\n"
1172 "IS-IS packet dump\n")
1173{
1174 isis->debugs |= DEBUG_PACKET_DUMP;
1175 print_debug (vty, DEBUG_PACKET_DUMP, 1);
1176
1177 return CMD_SUCCESS;
1178}
1179
1180DEFUN (no_debug_isis_packet_dump,
1181 no_debug_isis_packet_dump_cmd,
1182 "no debug isis packet-dump",
1183 UNDEBUG_STR
1184 "IS-IS information\n"
1185 "IS-IS packet dump\n")
1186{
1187 isis->debugs &= ~DEBUG_PACKET_DUMP;
1188 print_debug (vty, DEBUG_PACKET_DUMP, 0);
1189
1190 return CMD_SUCCESS;
1191}
1192
Christian Franke80a8f722015-11-12 14:21:47 +01001193DEFUN (debug_isis_lsp_gen,
1194 debug_isis_lsp_gen_cmd,
1195 "debug isis lsp-gen",
1196 DEBUG_STR
1197 "IS-IS information\n"
1198 "IS-IS generation of own LSPs\n")
1199{
1200 isis->debugs |= DEBUG_LSP_GEN;
1201 print_debug (vty, DEBUG_LSP_GEN, 1);
1202
1203 return CMD_SUCCESS;
1204}
1205
1206DEFUN (no_debug_isis_lsp_gen,
1207 no_debug_isis_lsp_gen_cmd,
1208 "no debug isis lsp-gen",
1209 UNDEBUG_STR
1210 "IS-IS information\n"
1211 "IS-IS generation of own LSPs\n")
1212{
1213 isis->debugs &= ~DEBUG_LSP_GEN;
1214 print_debug (vty, DEBUG_LSP_GEN, 0);
1215
1216 return CMD_SUCCESS;
1217}
1218
Christian Franke61010c32015-11-10 18:43:34 +01001219DEFUN (debug_isis_lsp_sched,
1220 debug_isis_lsp_sched_cmd,
1221 "debug isis lsp-sched",
1222 DEBUG_STR
1223 "IS-IS information\n"
1224 "IS-IS scheduling of LSP generation\n")
1225{
1226 isis->debugs |= DEBUG_LSP_SCHED;
1227 print_debug (vty, DEBUG_LSP_SCHED, 1);
1228
1229 return CMD_SUCCESS;
1230}
1231
1232DEFUN (no_debug_isis_lsp_sched,
1233 no_debug_isis_lsp_sched_cmd,
1234 "no debug isis lsp-gen",
1235 UNDEBUG_STR
1236 "IS-IS information\n"
1237 "IS-IS scheduling of LSP generation\n")
1238{
1239 isis->debugs &= ~DEBUG_LSP_SCHED;
1240 print_debug (vty, DEBUG_LSP_SCHED, 0);
1241
1242 return CMD_SUCCESS;
1243}
1244
jardineb5d44e2003-12-23 08:09:43 +00001245DEFUN (show_hostname,
1246 show_hostname_cmd,
1247 "show isis hostname",
1248 SHOW_STR
1249 "IS-IS information\n"
1250 "IS-IS Dynamic hostname mapping\n")
1251{
1252 dynhn_print_all (vty);
hassof390d2c2004-09-10 20:48:21 +00001253
jardineb5d44e2003-12-23 08:09:43 +00001254 return CMD_SUCCESS;
1255}
1256
Josh Bailey3f045a02012-03-24 08:35:20 -07001257static void
1258vty_out_timestr(struct vty *vty, time_t uptime)
1259{
1260 struct tm *tm;
1261 time_t difftime = time (NULL);
1262 difftime -= uptime;
1263 tm = gmtime (&difftime);
1264
1265#define ONE_DAY_SECOND 60*60*24
1266#define ONE_WEEK_SECOND 60*60*24*7
1267 if (difftime < ONE_DAY_SECOND)
1268 vty_out (vty, "%02d:%02d:%02d",
1269 tm->tm_hour, tm->tm_min, tm->tm_sec);
1270 else if (difftime < ONE_WEEK_SECOND)
1271 vty_out (vty, "%dd%02dh%02dm",
1272 tm->tm_yday, tm->tm_hour, tm->tm_min);
1273 else
1274 vty_out (vty, "%02dw%dd%02dh",
1275 tm->tm_yday/7,
1276 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1277 vty_out (vty, " ago");
1278}
1279
1280DEFUN (show_isis_summary,
1281 show_isis_summary_cmd,
1282 "show isis summary",
1283 SHOW_STR "IS-IS information\n" "IS-IS summary\n")
1284{
1285 struct listnode *node, *node2;
1286 struct isis_area *area;
1287 struct isis_spftree *spftree;
1288 int level;
1289
1290 if (isis == NULL)
1291 {
1292 vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
1293 return CMD_SUCCESS;
1294 }
1295
1296 vty_out (vty, "Process Id : %ld%s", isis->process_id,
1297 VTY_NEWLINE);
1298 if (isis->sysid_set)
1299 vty_out (vty, "System Id : %s%s", sysid_print (isis->sysid),
1300 VTY_NEWLINE);
1301
1302 vty_out (vty, "Up time : ");
1303 vty_out_timestr(vty, isis->uptime);
1304 vty_out (vty, "%s", VTY_NEWLINE);
1305
1306 if (isis->area_list)
1307 vty_out (vty, "Number of areas : %d%s", isis->area_list->count,
1308 VTY_NEWLINE);
1309
1310 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
1311 {
1312 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
1313 VTY_NEWLINE);
1314
1315 if (listcount (area->area_addrs) > 0)
1316 {
1317 struct area_addr *area_addr;
1318 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
1319 {
1320 vty_out (vty, " Net: %s%s",
1321 isonet_print (area_addr->area_addr,
1322 area_addr->addr_len + ISIS_SYS_ID_LEN +
1323 1), VTY_NEWLINE);
1324 }
1325 }
1326
1327 for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
1328 {
1329 if ((area->is_type & level) == 0)
1330 continue;
1331
1332 vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE);
1333 spftree = area->spftree[level - 1];
1334 if (spftree->pending)
1335 vty_out (vty, " IPv4 SPF: (pending)%s", VTY_NEWLINE);
1336 else
1337 vty_out (vty, " IPv4 SPF:%s", VTY_NEWLINE);
1338
1339 vty_out (vty, " minimum interval : %d%s",
1340 area->min_spf_interval[level - 1], VTY_NEWLINE);
1341
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001342 vty_out (vty, " last run elapsed : ");
1343 vty_out_timestr(vty, spftree->last_run_timestamp);
Josh Bailey3f045a02012-03-24 08:35:20 -07001344 vty_out (vty, "%s", VTY_NEWLINE);
1345
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001346 vty_out (vty, " last run duration : %u usec%s",
1347 (u_int32_t)spftree->last_run_duration, VTY_NEWLINE);
1348
Josh Bailey3f045a02012-03-24 08:35:20 -07001349 vty_out (vty, " run count : %d%s",
1350 spftree->runcount, VTY_NEWLINE);
1351
1352#ifdef HAVE_IPV6
1353 spftree = area->spftree6[level - 1];
1354 if (spftree->pending)
1355 vty_out (vty, " IPv6 SPF: (pending)%s", VTY_NEWLINE);
1356 else
1357 vty_out (vty, " IPv6 SPF:%s", VTY_NEWLINE);
1358
1359 vty_out (vty, " minimum interval : %d%s",
1360 area->min_spf_interval[level - 1], VTY_NEWLINE);
1361
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001362 vty_out (vty, " last run elapsed : ");
1363 vty_out_timestr(vty, spftree->last_run_timestamp);
Josh Bailey3f045a02012-03-24 08:35:20 -07001364 vty_out (vty, "%s", VTY_NEWLINE);
1365
David Lamparteref008d22015-03-03 08:48:11 +01001366 vty_out (vty, " last run duration : %llu msec%s",
1367 (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001368
Josh Bailey3f045a02012-03-24 08:35:20 -07001369 vty_out (vty, " run count : %d%s",
1370 spftree->runcount, VTY_NEWLINE);
1371#endif
1372 }
1373 }
1374 vty_out (vty, "%s", VTY_NEWLINE);
1375
1376 return CMD_SUCCESS;
1377}
1378
1379/*
1380 * This function supports following display options:
1381 * [ show isis database [detail] ]
1382 * [ show isis database <sysid> [detail] ]
1383 * [ show isis database <hostname> [detail] ]
1384 * [ show isis database <sysid>.<pseudo-id> [detail] ]
1385 * [ show isis database <hostname>.<pseudo-id> [detail] ]
1386 * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
1387 * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
1388 * [ show isis database detail <sysid> ]
1389 * [ show isis database detail <hostname> ]
1390 * [ show isis database detail <sysid>.<pseudo-id> ]
1391 * [ show isis database detail <hostname>.<pseudo-id> ]
1392 * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
1393 * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
1394 */
1395static int
1396show_isis_database (struct vty *vty, const char *argv, int ui_level)
jardineb5d44e2003-12-23 08:09:43 +00001397{
hasso3fdb2dd2005-09-28 18:45:54 +00001398 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +00001399 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07001400 struct isis_lsp *lsp;
1401 struct isis_dynhn *dynhn;
1402 const char *pos = argv;
1403 u_char lspid[ISIS_SYS_ID_LEN+2];
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001404 char sysid[255];
Josh Bailey3f045a02012-03-24 08:35:20 -07001405 u_char number[3];
hassof390d2c2004-09-10 20:48:21 +00001406 int level, lsp_count;
jardineb5d44e2003-12-23 08:09:43 +00001407
1408 if (isis->area_list->count == 0)
1409 return CMD_SUCCESS;
jardineb5d44e2003-12-23 08:09:43 +00001410
Josh Bailey3f045a02012-03-24 08:35:20 -07001411 memset (&lspid, 0, ISIS_SYS_ID_LEN);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001412 memset (&sysid, 0, 255);
Josh Bailey3f045a02012-03-24 08:35:20 -07001413
1414 /*
1415 * extract fragment and pseudo id from the string argv
1416 * in the forms:
1417 * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
1418 * (b) <systemid/hostname>.<pseudo-id> or
1419 * (c) <systemid/hostname> or
1420 * Where systemid is in the form:
1421 * xxxx.xxxx.xxxx
1422 */
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07001423 if (argv)
1424 strncpy (sysid, argv, 254);
Josh Bailey3f045a02012-03-24 08:35:20 -07001425 if (argv && strlen (argv) > 3)
1426 {
1427 pos = argv + strlen (argv) - 3;
1428 if (strncmp (pos, "-", 1) == 0)
1429 {
1430 memcpy (number, ++pos, 2);
1431 lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16);
1432 pos -= 4;
1433 if (strncmp (pos, ".", 1) != 0)
1434 return CMD_ERR_AMBIGUOUS;
1435 }
1436 if (strncmp (pos, ".", 1) == 0)
1437 {
1438 memcpy (number, ++pos, 2);
1439 lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16);
1440 sysid[pos - argv - 1] = '\0';
1441 }
1442 }
1443
hasso3fdb2dd2005-09-28 18:45:54 +00001444 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof390d2c2004-09-10 20:48:21 +00001445 {
hassof390d2c2004-09-10 20:48:21 +00001446 vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
Josh Bailey3f045a02012-03-24 08:35:20 -07001447 VTY_NEWLINE);
1448
hassof390d2c2004-09-10 20:48:21 +00001449 for (level = 0; level < ISIS_LEVELS; level++)
Josh Bailey3f045a02012-03-24 08:35:20 -07001450 {
1451 if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
1452 {
1453 lsp = NULL;
1454 if (argv != NULL)
1455 {
1456 /*
1457 * Try to find the lsp-id if the argv string is in
1458 * the form hostname.<pseudo-id>-<fragment>
1459 */
1460 if (sysid2buff (lspid, sysid))
1461 {
1462 lsp = lsp_search (lspid, area->lspdb[level]);
1463 }
1464 else if ((dynhn = dynhn_find_by_name (sysid)))
1465 {
1466 memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN);
1467 lsp = lsp_search (lspid, area->lspdb[level]);
1468 }
1469 else if (strncmp(unix_hostname (), sysid, 15) == 0)
1470 {
1471 memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
1472 lsp = lsp_search (lspid, area->lspdb[level]);
1473 }
1474 }
jardineb5d44e2003-12-23 08:09:43 +00001475
Josh Bailey3f045a02012-03-24 08:35:20 -07001476 if (lsp != NULL || argv == NULL)
1477 {
1478 vty_out (vty, "IS-IS Level-%d link-state database:%s",
1479 level + 1, VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +00001480
Josh Bailey3f045a02012-03-24 08:35:20 -07001481 /* print the title in all cases */
1482 vty_out (vty, "LSP ID PduLen "
1483 "SeqNumber Chksum Holdtime ATT/P/OL%s",
1484 VTY_NEWLINE);
1485 }
1486
1487 if (lsp)
1488 {
1489 if (ui_level == ISIS_UI_LEVEL_DETAIL)
1490 lsp_print_detail (lsp, vty, area->dynhostname);
1491 else
1492 lsp_print (lsp, vty, area->dynhostname);
1493 }
1494 else if (argv == NULL)
1495 {
1496 lsp_count = lsp_print_all (vty, area->lspdb[level],
1497 ui_level,
1498 area->dynhostname);
1499
1500 vty_out (vty, " %u LSPs%s%s",
1501 lsp_count, VTY_NEWLINE, VTY_NEWLINE);
1502 }
1503 }
1504 }
jardineb5d44e2003-12-23 08:09:43 +00001505 }
jardineb5d44e2003-12-23 08:09:43 +00001506
1507 return CMD_SUCCESS;
1508}
1509
Josh Bailey3f045a02012-03-24 08:35:20 -07001510DEFUN (show_database_brief,
1511 show_database_cmd,
1512 "show isis database",
1513 SHOW_STR
1514 "IS-IS information\n"
1515 "IS-IS link state database\n")
1516{
1517 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_BRIEF);
1518}
1519
1520DEFUN (show_database_lsp_brief,
1521 show_database_arg_cmd,
1522 "show isis database WORD",
1523 SHOW_STR
1524 "IS-IS information\n"
1525 "IS-IS link state database\n"
1526 "LSP ID\n")
1527{
1528 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_BRIEF);
1529}
1530
1531DEFUN (show_database_lsp_detail,
1532 show_database_arg_detail_cmd,
1533 "show isis database WORD detail",
1534 SHOW_STR
1535 "IS-IS information\n"
1536 "IS-IS link state database\n"
1537 "LSP ID\n"
1538 "Detailed information\n")
1539{
1540 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
1541}
1542
jardineb5d44e2003-12-23 08:09:43 +00001543DEFUN (show_database_detail,
1544 show_database_detail_cmd,
1545 "show isis database detail",
1546 SHOW_STR
1547 "IS-IS information\n"
1548 "IS-IS link state database\n")
1549{
Josh Bailey3f045a02012-03-24 08:35:20 -07001550 return show_isis_database (vty, NULL, ISIS_UI_LEVEL_DETAIL);
1551}
jardineb5d44e2003-12-23 08:09:43 +00001552
Josh Bailey3f045a02012-03-24 08:35:20 -07001553DEFUN (show_database_detail_lsp,
1554 show_database_detail_arg_cmd,
1555 "show isis database detail WORD",
1556 SHOW_STR
1557 "IS-IS information\n"
1558 "IS-IS link state database\n"
1559 "Detailed information\n"
1560 "LSP ID\n")
1561{
1562 return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
jardineb5d44e2003-12-23 08:09:43 +00001563}
1564
1565/*
1566 * 'router isis' command
1567 */
1568DEFUN (router_isis,
1569 router_isis_cmd,
1570 "router isis WORD",
hassof390d2c2004-09-10 20:48:21 +00001571 ROUTER_STR
jardineb5d44e2003-12-23 08:09:43 +00001572 "ISO IS-IS\n"
1573 "ISO Routing area tag")
1574{
jardineb5d44e2003-12-23 08:09:43 +00001575 return isis_area_get (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001576}
1577
1578/*
1579 *'no router isis' command
1580 */
1581DEFUN (no_router_isis,
1582 no_router_isis_cmd,
1583 "no router isis WORD",
hassof390d2c2004-09-10 20:48:21 +00001584 "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
jardineb5d44e2003-12-23 08:09:43 +00001585{
1586 return isis_area_destroy (vty, argv[0]);
1587}
1588
1589/*
1590 * 'net' command
1591 */
1592DEFUN (net,
1593 net_cmd,
1594 "net WORD",
1595 "A Network Entity Title for this process (OSI only)\n"
hassof390d2c2004-09-10 20:48:21 +00001596 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00001597{
Paul Jakma41b36e92006-12-08 01:09:50 +00001598 return area_net_title (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001599}
1600
jardineb5d44e2003-12-23 08:09:43 +00001601/*
1602 * 'no net' command
1603 */
1604DEFUN (no_net,
1605 no_net_cmd,
1606 "no net WORD",
1607 NO_STR
1608 "A Network Entity Title for this process (OSI only)\n"
hassof390d2c2004-09-10 20:48:21 +00001609 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00001610{
Paul Jakma41b36e92006-12-08 01:09:50 +00001611 return area_clear_net_title (vty, argv[0]);
jardineb5d44e2003-12-23 08:09:43 +00001612}
1613
Christian Frankef1fc1db2015-11-10 18:43:31 +01001614static
1615int area_set_lsp_mtu(struct vty *vty, struct isis_area *area, unsigned int lsp_mtu)
1616{
1617 struct isis_circuit *circuit;
1618 struct listnode *node;
1619
1620 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
1621 {
Christian Frankee7207092016-04-03 12:46:28 -03001622 if(circuit->state != C_STATE_INIT && circuit->state != C_STATE_UP)
1623 continue;
Christian Frankef1fc1db2015-11-10 18:43:31 +01001624 if(lsp_mtu > isis_circuit_pdu_size(circuit))
1625 {
1626 vty_out(vty, "ISIS area contains circuit %s, which has a maximum PDU size of %zu.%s",
1627 circuit->interface->name, isis_circuit_pdu_size(circuit),
1628 VTY_NEWLINE);
1629 return CMD_ERR_AMBIGUOUS;
1630 }
1631 }
1632
1633 area->lsp_mtu = lsp_mtu;
1634 lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1);
1635
1636 return CMD_SUCCESS;
1637}
1638
1639DEFUN (area_lsp_mtu,
1640 area_lsp_mtu_cmd,
1641 "lsp-mtu <128-4352>",
1642 "Configure the maximum size of generated LSPs\n"
1643 "Maximum size of generated LSPs\n")
1644{
1645 struct isis_area *area;
1646
1647 area = vty->index;
1648 if (!area)
1649 {
1650 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1651 return CMD_ERR_NO_MATCH;
1652 }
1653
1654 unsigned int lsp_mtu;
1655
1656 VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[0], 128, 4352);
1657
1658 return area_set_lsp_mtu(vty, area, lsp_mtu);
1659}
1660
1661DEFUN(no_area_lsp_mtu,
1662 no_area_lsp_mtu_cmd,
1663 "no lsp-mtu",
1664 NO_STR
1665 "Configure the maximum size of generated LSPs\n")
1666{
1667 struct isis_area *area;
1668
1669 area = vty->index;
1670 if (!area)
1671 {
1672 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1673 return CMD_ERR_NO_MATCH;
1674 }
1675
1676 return area_set_lsp_mtu(vty, area, DEFAULT_LSP_MTU);
1677}
1678
1679ALIAS(no_area_lsp_mtu,
1680 no_area_lsp_mtu_arg_cmd,
1681 "no lsp-mtu <128-4352>",
1682 NO_STR
1683 "Configure the maximum size of generated LSPs\n"
1684 "Maximum size of generated LSPs\n");
1685
Josh Bailey3f045a02012-03-24 08:35:20 -07001686DEFUN (area_passwd_md5,
1687 area_passwd_md5_cmd,
1688 "area-password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001689 "Configure the authentication password for an area\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001690 "Authentication type\n"
hassof390d2c2004-09-10 20:48:21 +00001691 "Area 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->area_passwd.len = (u_char) len;
1712 area->area_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1713 strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
1714
1715 if (argc > 1)
1716 {
1717 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1718 if (strncmp(argv[1], "v", 1) == 0)
1719 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1720 else
1721 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1722 }
1723 else
1724 {
1725 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1726 UNSET_FLAG(area->area_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 (area_passwd_md5,
1734 area_passwd_md5_snpauth_cmd,
1735 "area-password md5 WORD authenticate snp (send-only|validate)",
1736 "Configure the authentication password for an area\n"
1737 "Authentication type\n"
1738 "Area 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 (area_passwd_clear,
1745 area_passwd_clear_cmd,
1746 "area-password clear WORD",
1747 "Configure the authentication password for an area\n"
1748 "Authentication type\n"
1749 "Area 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->area_passwd.len = (u_char) len;
jardineb5d44e2003-12-23 08:09:43 +00001770 area->area_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001771 strncpy ((char *)area->area_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->area_passwd.snp_auth, SNP_AUTH_SEND);
1776 if (strncmp(argv[1], "v", 1) == 0)
1777 SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1778 else
1779 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
1780 }
1781 else
1782 {
1783 UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
1784 UNSET_FLAG(area->area_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 (area_passwd_clear,
1792 area_passwd_clear_snpauth_cmd,
1793 "area-password clear WORD authenticate snp (send-only|validate)",
hasso1cbc5622005-01-01 10:29:51 +00001794 "Configure the authentication password for an area\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001795 "Authentication type\n"
hasso1cbc5622005-01-01 10:29:51 +00001796 "Area 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_area_passwd,
1803 no_area_passwd_cmd,
1804 "no area-password",
1805 NO_STR
1806 "Configure the authentication password for an area\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->area_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);
jardineb5d44e2003-12-23 08:09:43 +00001820
1821 return CMD_SUCCESS;
1822}
1823
Josh Bailey3f045a02012-03-24 08:35:20 -07001824DEFUN (domain_passwd_md5,
1825 domain_passwd_md5_cmd,
1826 "domain-password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001827 "Set the authentication password for a routing domain\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001828 "Authentication type\n"
hassof390d2c2004-09-10 20:48:21 +00001829 "Routing domain password\n")
jardineb5d44e2003-12-23 08:09:43 +00001830{
1831 struct isis_area *area;
1832 int len;
1833
1834 area = vty->index;
1835
hassof390d2c2004-09-10 20:48:21 +00001836 if (!area)
1837 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001838 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1839 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001840 }
1841
jardineb5d44e2003-12-23 08:09:43 +00001842 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001843 if (len > 254)
1844 {
1845 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001846 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001847 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001848
1849 area->domain_passwd.len = (u_char) len;
1850 area->domain_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1851 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
1852
1853 if (argc > 1)
1854 {
1855 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1856 if (strncmp(argv[1], "v", 1) == 0)
1857 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1858 else
1859 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1860 }
1861 else
1862 {
1863 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1864 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1865 }
1866 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1867
1868 return CMD_SUCCESS;
1869}
1870
1871ALIAS (domain_passwd_md5,
1872 domain_passwd_md5_snpauth_cmd,
1873 "domain-password md5 WORD authenticate snp (send-only|validate)",
1874 "Set the authentication password for a routing domain\n"
1875 "Authentication type\n"
1876 "Routing domain password\n"
1877 "Authentication\n"
1878 "SNP PDUs\n"
1879 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001880 "Send and check PDUs on receiving\n")
Josh Bailey3f045a02012-03-24 08:35:20 -07001881
1882DEFUN (domain_passwd_clear,
1883 domain_passwd_clear_cmd,
1884 "domain-password clear WORD",
1885 "Set the authentication password for a routing domain\n"
1886 "Authentication type\n"
1887 "Routing domain password\n")
1888{
1889 struct isis_area *area;
1890 int len;
1891
1892 area = vty->index;
1893
1894 if (!area)
1895 {
1896 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1897 return CMD_ERR_NO_MATCH;
1898 }
1899
1900 len = strlen (argv[0]);
1901 if (len > 254)
1902 {
1903 vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
1904 return CMD_ERR_AMBIGUOUS;
1905 }
1906
hassof390d2c2004-09-10 20:48:21 +00001907 area->domain_passwd.len = (u_char) len;
jardineb5d44e2003-12-23 08:09:43 +00001908 area->domain_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001909 strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001910
hasso1cbc5622005-01-01 10:29:51 +00001911 if (argc > 1)
1912 {
1913 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1914 if (strncmp(argv[1], "v", 1) == 0)
1915 SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1916 else
1917 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1918 }
1919 else
1920 {
1921 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
1922 UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
1923 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001924 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hasso1cbc5622005-01-01 10:29:51 +00001925
jardineb5d44e2003-12-23 08:09:43 +00001926 return CMD_SUCCESS;
1927}
1928
Josh Bailey3f045a02012-03-24 08:35:20 -07001929ALIAS (domain_passwd_clear,
1930 domain_passwd_clear_snpauth_cmd,
1931 "domain-password clear WORD authenticate snp (send-only|validate)",
hasso1cbc5622005-01-01 10:29:51 +00001932 "Set the authentication password for a routing domain\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001933 "Authentication type\n"
hasso1cbc5622005-01-01 10:29:51 +00001934 "Routing domain password\n"
1935 "Authentication\n"
1936 "SNP PDUs\n"
1937 "Send but do not check PDUs on receiving\n"
David Lamparterb7d50212015-03-03 08:53:18 +01001938 "Send and check PDUs on receiving\n")
hasso1cbc5622005-01-01 10:29:51 +00001939
jardineb5d44e2003-12-23 08:09:43 +00001940DEFUN (no_domain_passwd,
1941 no_domain_passwd_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07001942 "no domain-password",
jardineb5d44e2003-12-23 08:09:43 +00001943 NO_STR
1944 "Set the authentication password for a routing domain\n")
1945{
1946 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00001947
jardineb5d44e2003-12-23 08:09:43 +00001948 area = vty->index;
1949
hassof390d2c2004-09-10 20:48:21 +00001950 if (!area)
1951 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001952 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1953 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001954 }
1955
jardineb5d44e2003-12-23 08:09:43 +00001956 memset (&area->domain_passwd, 0, sizeof (struct isis_passwd));
Josh Bailey3f045a02012-03-24 08:35:20 -07001957 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hassof390d2c2004-09-10 20:48:21 +00001958
jardineb5d44e2003-12-23 08:09:43 +00001959 return CMD_SUCCESS;
1960}
1961
1962DEFUN (is_type,
1963 is_type_cmd,
1964 "is-type (level-1|level-1-2|level-2-only)",
1965 "IS Level for this routing process (OSI only)\n"
1966 "Act as a station router only\n"
1967 "Act as both a station router and an area router\n"
1968 "Act as an area router only\n")
1969{
1970 struct isis_area *area;
1971 int type;
1972
1973 area = vty->index;
1974
hassof390d2c2004-09-10 20:48:21 +00001975 if (!area)
1976 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001977 vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
1978 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001979 }
jardineb5d44e2003-12-23 08:09:43 +00001980
Paul Jakma41b36e92006-12-08 01:09:50 +00001981 type = string2circuit_t (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001982 if (!type)
1983 {
1984 vty_out (vty, "Unknown IS level %s", VTY_NEWLINE);
1985 return CMD_SUCCESS;
1986 }
jardineb5d44e2003-12-23 08:09:43 +00001987
1988 isis_event_system_type_change (area, type);
hassof390d2c2004-09-10 20:48:21 +00001989
jardineb5d44e2003-12-23 08:09:43 +00001990 return CMD_SUCCESS;
1991}
1992
1993DEFUN (no_is_type,
1994 no_is_type_cmd,
1995 "no is-type (level-1|level-1-2|level-2-only)",
1996 NO_STR
1997 "IS Level for this routing process (OSI only)\n"
1998 "Act as a station router only\n"
1999 "Act as both a station router and an area router\n"
2000 "Act as an area router only\n")
2001{
jardineb5d44e2003-12-23 08:09:43 +00002002 struct isis_area *area;
2003 int type;
2004
2005 area = vty->index;
2006 assert (area);
hassof390d2c2004-09-10 20:48:21 +00002007
jardineb5d44e2003-12-23 08:09:43 +00002008 /*
Josh Bailey3f045a02012-03-24 08:35:20 -07002009 * Put the is-type back to defaults:
2010 * - level-1-2 on first area
2011 * - level-1 for the rest
jardineb5d44e2003-12-23 08:09:43 +00002012 */
paul1eb8ef22005-04-07 07:30:20 +00002013 if (listgetdata (listhead (isis->area_list)) == area)
jardineb5d44e2003-12-23 08:09:43 +00002014 type = IS_LEVEL_1_AND_2;
2015 else
2016 type = IS_LEVEL_1;
2017
2018 isis_event_system_type_change (area, type);
2019
2020 return CMD_SUCCESS;
2021}
2022
Josh Bailey3f045a02012-03-24 08:35:20 -07002023static int
2024set_lsp_gen_interval (struct vty *vty, struct isis_area *area,
2025 uint16_t interval, int level)
2026{
2027 int lvl;
2028
2029 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2030 {
2031 if (!(lvl & level))
2032 continue;
2033
2034 if (interval >= area->lsp_refresh[lvl-1])
2035 {
2036 vty_out (vty, "LSP gen interval %us must be less than "
2037 "the LSP refresh interval %us%s",
2038 interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
2039 return CMD_ERR_AMBIGUOUS;
2040 }
2041 }
2042
2043 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2044 {
2045 if (!(lvl & level))
2046 continue;
2047 area->lsp_gen_interval[lvl-1] = interval;
2048 }
2049
2050 return CMD_SUCCESS;
2051}
2052
jardineb5d44e2003-12-23 08:09:43 +00002053DEFUN (lsp_gen_interval,
2054 lsp_gen_interval_cmd,
2055 "lsp-gen-interval <1-120>",
2056 "Minimum interval between regenerating same LSP\n"
2057 "Minimum interval in seconds\n")
2058{
2059 struct isis_area *area;
2060 uint16_t interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002061 int level;
jardineb5d44e2003-12-23 08:09:43 +00002062
2063 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002064 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002065 level = IS_LEVEL_1 | IS_LEVEL_2;
2066 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002067}
2068
2069DEFUN (no_lsp_gen_interval,
2070 no_lsp_gen_interval_cmd,
2071 "no lsp-gen-interval",
2072 NO_STR
hassof390d2c2004-09-10 20:48:21 +00002073 "Minimum interval between regenerating same LSP\n")
jardineb5d44e2003-12-23 08:09:43 +00002074{
2075 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002076 uint16_t interval;
2077 int level;
jardineb5d44e2003-12-23 08:09:43 +00002078
2079 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002080 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2081 level = IS_LEVEL_1 | IS_LEVEL_2;
2082 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002083}
2084
2085ALIAS (no_lsp_gen_interval,
2086 no_lsp_gen_interval_arg_cmd,
2087 "no lsp-gen-interval <1-120>",
2088 NO_STR
2089 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002090 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002091
2092DEFUN (lsp_gen_interval_l1,
2093 lsp_gen_interval_l1_cmd,
2094 "lsp-gen-interval level-1 <1-120>",
2095 "Minimum interval between regenerating same LSP\n"
2096 "Set interval for level 1 only\n"
hassof390d2c2004-09-10 20:48:21 +00002097 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002098{
2099 struct isis_area *area;
2100 uint16_t interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002101 int level;
jardineb5d44e2003-12-23 08:09:43 +00002102
2103 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002104 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002105 level = IS_LEVEL_1;
2106 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002107}
2108
2109DEFUN (no_lsp_gen_interval_l1,
2110 no_lsp_gen_interval_l1_cmd,
2111 "no lsp-gen-interval level-1",
2112 NO_STR
2113 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002114 "Set interval for level 1 only\n")
jardineb5d44e2003-12-23 08:09:43 +00002115{
2116 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002117 uint16_t interval;
2118 int level;
jardineb5d44e2003-12-23 08:09:43 +00002119
2120 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002121 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2122 level = IS_LEVEL_1;
2123 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002124}
2125
2126ALIAS (no_lsp_gen_interval_l1,
2127 no_lsp_gen_interval_l1_arg_cmd,
2128 "no lsp-gen-interval level-1 <1-120>",
2129 NO_STR
2130 "Minimum interval between regenerating same LSP\n"
2131 "Set interval for level 1 only\n"
hassof390d2c2004-09-10 20:48:21 +00002132 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002133
2134DEFUN (lsp_gen_interval_l2,
2135 lsp_gen_interval_l2_cmd,
2136 "lsp-gen-interval level-2 <1-120>",
2137 "Minimum interval between regenerating same LSP\n"
2138 "Set interval for level 2 only\n"
hassof390d2c2004-09-10 20:48:21 +00002139 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002140{
2141 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002142 uint16_t interval;
2143 int level;
jardineb5d44e2003-12-23 08:09:43 +00002144
2145 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002146 interval = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002147 level = IS_LEVEL_2;
2148 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002149}
2150
2151DEFUN (no_lsp_gen_interval_l2,
2152 no_lsp_gen_interval_l2_cmd,
2153 "no lsp-gen-interval level-2",
2154 NO_STR
2155 "Minimum interval between regenerating same LSP\n"
hassof390d2c2004-09-10 20:48:21 +00002156 "Set interval for level 2 only\n")
jardineb5d44e2003-12-23 08:09:43 +00002157{
2158 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07002159 uint16_t interval;
2160 int level;
jardineb5d44e2003-12-23 08:09:43 +00002161
2162 area = vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07002163 interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
2164 level = IS_LEVEL_2;
2165 return set_lsp_gen_interval (vty, area, interval, level);
jardineb5d44e2003-12-23 08:09:43 +00002166}
2167
2168ALIAS (no_lsp_gen_interval_l2,
2169 no_lsp_gen_interval_l2_arg_cmd,
2170 "no lsp-gen-interval level-2 <1-120>",
2171 NO_STR
2172 "Minimum interval between regenerating same LSP\n"
2173 "Set interval for level 2 only\n"
hassof390d2c2004-09-10 20:48:21 +00002174 "Minimum interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002175
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002176static int
2177validate_metric_style_narrow (struct vty *vty, struct isis_area *area)
2178{
2179 struct isis_circuit *circuit;
2180 struct listnode *node;
2181
2182 if (! vty)
2183 return CMD_ERR_AMBIGUOUS;
2184
2185 if (! area)
2186 {
2187 vty_out (vty, "ISIS area is invalid%s", VTY_NEWLINE);
2188 return CMD_ERR_AMBIGUOUS;
2189 }
2190
2191 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
2192 {
2193 if ((area->is_type & IS_LEVEL_1) &&
2194 (circuit->is_type & IS_LEVEL_1) &&
Christian Franke4fb7c842012-11-27 19:51:59 +00002195 (circuit->te_metric[0] > MAX_NARROW_LINK_METRIC))
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002196 {
2197 vty_out (vty, "ISIS circuit %s metric is invalid%s",
2198 circuit->interface->name, VTY_NEWLINE);
2199 return CMD_ERR_AMBIGUOUS;
2200 }
2201 if ((area->is_type & IS_LEVEL_2) &&
2202 (circuit->is_type & IS_LEVEL_2) &&
Christian Franke4fb7c842012-11-27 19:51:59 +00002203 (circuit->te_metric[1] > MAX_NARROW_LINK_METRIC))
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002204 {
2205 vty_out (vty, "ISIS circuit %s metric is invalid%s",
2206 circuit->interface->name, VTY_NEWLINE);
2207 return CMD_ERR_AMBIGUOUS;
2208 }
2209 }
2210
2211 return CMD_SUCCESS;
2212}
2213
jardineb5d44e2003-12-23 08:09:43 +00002214DEFUN (metric_style,
2215 metric_style_cmd,
hasso2984d262005-09-26 16:49:07 +00002216 "metric-style (narrow|transition|wide)",
jardineb5d44e2003-12-23 08:09:43 +00002217 "Use old-style (ISO 10589) or new-style packet formats\n"
2218 "Use old style of TLVs with narrow metric\n"
hasso2984d262005-09-26 16:49:07 +00002219 "Send and accept both styles of TLVs during transition\n"
jardineb5d44e2003-12-23 08:09:43 +00002220 "Use new style of TLVs to carry wider metric\n")
2221{
2222 struct isis_area *area;
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002223 int ret;
jardineb5d44e2003-12-23 08:09:43 +00002224
2225 area = vty->index;
2226 assert (area);
hasso2984d262005-09-26 16:49:07 +00002227
2228 if (strncmp (argv[0], "w", 1) == 0)
2229 {
2230 area->newmetric = 1;
2231 area->oldmetric = 0;
2232 }
Christian Franke478c1122012-11-27 19:52:00 +00002233 else
hasso2984d262005-09-26 16:49:07 +00002234 {
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002235 ret = validate_metric_style_narrow (vty, area);
2236 if (ret != CMD_SUCCESS)
2237 return ret;
2238
Christian Franke478c1122012-11-27 19:52:00 +00002239 if (strncmp (argv[0], "t", 1) == 0)
2240 {
2241 area->newmetric = 1;
2242 area->oldmetric = 1;
2243 }
2244 else if (strncmp (argv[0], "n", 1) == 0)
2245 {
2246 area->newmetric = 0;
2247 area->oldmetric = 1;
2248 }
hasso2984d262005-09-26 16:49:07 +00002249 }
jardineb5d44e2003-12-23 08:09:43 +00002250
2251 return CMD_SUCCESS;
2252}
2253
2254DEFUN (no_metric_style,
2255 no_metric_style_cmd,
hasso2984d262005-09-26 16:49:07 +00002256 "no metric-style",
jardineb5d44e2003-12-23 08:09:43 +00002257 NO_STR
hasso2984d262005-09-26 16:49:07 +00002258 "Use old-style (ISO 10589) or new-style packet formats\n")
jardineb5d44e2003-12-23 08:09:43 +00002259{
2260 struct isis_area *area;
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002261 int ret;
jardineb5d44e2003-12-23 08:09:43 +00002262
2263 area = vty->index;
2264 assert (area);
2265
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002266 ret = validate_metric_style_narrow (vty, area);
2267 if (ret != CMD_SUCCESS)
2268 return ret;
2269
hasso2984d262005-09-26 16:49:07 +00002270 /* Default is narrow metric. */
2271 area->newmetric = 0;
2272 area->oldmetric = 1;
jardineb5d44e2003-12-23 08:09:43 +00002273
2274 return CMD_SUCCESS;
2275}
2276
Josh Bailey3f045a02012-03-24 08:35:20 -07002277DEFUN (set_overload_bit,
2278 set_overload_bit_cmd,
2279 "set-overload-bit",
2280 "Set overload bit to avoid any transit traffic\n"
2281 "Set overload bit\n")
2282{
2283 struct isis_area *area;
2284
2285 area = vty->index;
2286 assert (area);
2287
2288 area->overload_bit = LSPBIT_OL;
2289 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2290
2291 return CMD_SUCCESS;
2292}
2293
2294DEFUN (no_set_overload_bit,
2295 no_set_overload_bit_cmd,
2296 "no set-overload-bit",
2297 "Reset overload bit to accept transit traffic\n"
2298 "Reset overload bit\n")
2299{
2300 struct isis_area *area;
2301
2302 area = vty->index;
2303 assert (area);
2304
2305 area->overload_bit = 0;
2306 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2307
2308 return CMD_SUCCESS;
2309}
2310
Amritha Nambiarc8ee9402015-08-24 16:40:14 -07002311DEFUN (set_attached_bit,
2312 set_attached_bit_cmd,
2313 "set-attached-bit",
2314 "Set attached bit to identify as L1/L2 router for inter-area traffic\n"
2315 "Set attached bit\n")
2316{
2317 struct isis_area *area;
2318
2319 area = vty->index;
2320 assert (area);
2321
2322 area->attached_bit = LSPBIT_ATT;
2323 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2324
2325 return CMD_SUCCESS;
2326}
2327
2328DEFUN (no_set_attached_bit,
2329 no_set_attached_bit_cmd,
2330 "no set-attached-bit",
2331 "Reset attached bit\n")
2332{
2333 struct isis_area *area;
2334
2335 area = vty->index;
2336 assert (area);
2337
2338 area->attached_bit = 0;
2339 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
2340
2341 return CMD_SUCCESS;
2342}
2343
jardineb5d44e2003-12-23 08:09:43 +00002344DEFUN (dynamic_hostname,
2345 dynamic_hostname_cmd,
2346 "hostname dynamic",
2347 "Dynamic hostname for IS-IS\n"
hassof390d2c2004-09-10 20:48:21 +00002348 "Dynamic hostname\n")
jardineb5d44e2003-12-23 08:09:43 +00002349{
2350 struct isis_area *area;
2351
2352 area = vty->index;
2353 assert (area);
hassof390d2c2004-09-10 20:48:21 +00002354
Josh Bailey3f045a02012-03-24 08:35:20 -07002355 if (!area->dynhostname)
2356 {
2357 area->dynhostname = 1;
2358 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
2359 }
hassof390d2c2004-09-10 20:48:21 +00002360
jardineb5d44e2003-12-23 08:09:43 +00002361 return CMD_SUCCESS;
2362}
2363
2364DEFUN (no_dynamic_hostname,
2365 no_dynamic_hostname_cmd,
2366 "no hostname dynamic",
2367 NO_STR
2368 "Dynamic hostname for IS-IS\n"
hassof390d2c2004-09-10 20:48:21 +00002369 "Dynamic hostname\n")
jardineb5d44e2003-12-23 08:09:43 +00002370{
2371 struct isis_area *area;
2372
2373 area = vty->index;
2374 assert (area);
hassof390d2c2004-09-10 20:48:21 +00002375
Josh Bailey3f045a02012-03-24 08:35:20 -07002376 if (area->dynhostname)
2377 {
2378 area->dynhostname = 0;
2379 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
2380 }
hassof390d2c2004-09-10 20:48:21 +00002381
jardineb5d44e2003-12-23 08:09:43 +00002382 return CMD_SUCCESS;
2383}
2384
2385DEFUN (spf_interval,
2386 spf_interval_cmd,
2387 "spf-interval <1-120>",
hasso2097cd82003-12-23 11:51:08 +00002388 "Minimum interval between SPF calculations\n"
jardineb5d44e2003-12-23 08:09:43 +00002389 "Minimum interval between consecutive SPFs in seconds\n")
2390{
2391 struct isis_area *area;
2392 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002393
jardineb5d44e2003-12-23 08:09:43 +00002394 area = vty->index;
2395 interval = atoi (argv[0]);
2396 area->min_spf_interval[0] = interval;
2397 area->min_spf_interval[1] = interval;
hassof390d2c2004-09-10 20:48:21 +00002398
jardineb5d44e2003-12-23 08:09:43 +00002399 return CMD_SUCCESS;
2400}
2401
2402DEFUN (no_spf_interval,
2403 no_spf_interval_cmd,
2404 "no spf-interval",
2405 NO_STR
hassof390d2c2004-09-10 20:48:21 +00002406 "Minimum interval between SPF calculations\n")
jardineb5d44e2003-12-23 08:09:43 +00002407{
2408 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002409
jardineb5d44e2003-12-23 08:09:43 +00002410 area = vty->index;
2411
2412 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
2413 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002414
jardineb5d44e2003-12-23 08:09:43 +00002415 return CMD_SUCCESS;
2416}
2417
2418ALIAS (no_spf_interval,
2419 no_spf_interval_arg_cmd,
2420 "no spf-interval <1-120>",
2421 NO_STR
2422 "Minimum interval between SPF calculations\n"
hassof390d2c2004-09-10 20:48:21 +00002423 "Minimum interval between consecutive SPFs in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002424
2425DEFUN (spf_interval_l1,
2426 spf_interval_l1_cmd,
2427 "spf-interval level-1 <1-120>",
2428 "Minimum interval between SPF calculations\n"
2429 "Set interval for level 1 only\n"
2430 "Minimum interval between consecutive SPFs in seconds\n")
2431{
2432 struct isis_area *area;
2433 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002434
jardineb5d44e2003-12-23 08:09:43 +00002435 area = vty->index;
2436 interval = atoi (argv[0]);
2437 area->min_spf_interval[0] = interval;
hassof390d2c2004-09-10 20:48:21 +00002438
jardineb5d44e2003-12-23 08:09:43 +00002439 return CMD_SUCCESS;
2440}
2441
2442DEFUN (no_spf_interval_l1,
2443 no_spf_interval_l1_cmd,
2444 "no spf-interval level-1",
2445 NO_STR
2446 "Minimum interval between SPF calculations\n"
2447 "Set interval for level 1 only\n")
2448{
2449 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002450
jardineb5d44e2003-12-23 08:09:43 +00002451 area = vty->index;
2452
2453 area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002454
jardineb5d44e2003-12-23 08:09:43 +00002455 return CMD_SUCCESS;
2456}
2457
2458ALIAS (no_spf_interval,
2459 no_spf_interval_l1_arg_cmd,
2460 "no spf-interval level-1 <1-120>",
2461 NO_STR
2462 "Minimum interval between SPF calculations\n"
2463 "Set interval for level 1 only\n"
2464 "Minimum interval between consecutive SPFs in seconds\n")
2465
2466DEFUN (spf_interval_l2,
2467 spf_interval_l2_cmd,
2468 "spf-interval level-2 <1-120>",
2469 "Minimum interval between SPF calculations\n"
2470 "Set interval for level 2 only\n"
2471 "Minimum interval between consecutive SPFs in seconds\n")
2472{
2473 struct isis_area *area;
2474 u_int16_t interval;
hassof390d2c2004-09-10 20:48:21 +00002475
jardineb5d44e2003-12-23 08:09:43 +00002476 area = vty->index;
2477 interval = atoi (argv[0]);
2478 area->min_spf_interval[1] = interval;
hassof390d2c2004-09-10 20:48:21 +00002479
jardineb5d44e2003-12-23 08:09:43 +00002480 return CMD_SUCCESS;
2481}
2482
2483DEFUN (no_spf_interval_l2,
2484 no_spf_interval_l2_cmd,
2485 "no spf-interval level-2",
2486 NO_STR
2487 "Minimum interval between SPF calculations\n"
2488 "Set interval for level 2 only\n")
2489{
2490 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002491
jardineb5d44e2003-12-23 08:09:43 +00002492 area = vty->index;
2493
2494 area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002495
jardineb5d44e2003-12-23 08:09:43 +00002496 return CMD_SUCCESS;
2497}
2498
2499ALIAS (no_spf_interval,
2500 no_spf_interval_l2_arg_cmd,
2501 "no spf-interval level-2 <1-120>",
2502 NO_STR
2503 "Minimum interval between SPF calculations\n"
2504 "Set interval for level 2 only\n"
2505 "Minimum interval between consecutive SPFs in seconds\n")
2506
Josh Bailey3f045a02012-03-24 08:35:20 -07002507static int
2508set_lsp_max_lifetime (struct vty *vty, struct isis_area *area,
2509 uint16_t interval, int level)
2510{
2511 int lvl;
2512 int set_refresh_interval[ISIS_LEVELS] = {0, 0};
2513 uint16_t refresh_interval;
2514
2515 refresh_interval = interval - 300;
2516
2517 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
2518 {
2519 if (!(lvl & level))
2520 continue;
2521 if (refresh_interval < area->lsp_refresh[lvl-1])
2522 {
2523 vty_out (vty, "Level %d Max LSP lifetime %us must be 300s greater than "
2524 "the configured LSP refresh interval %us%s",
2525 lvl, interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
2526 vty_out (vty, "Automatically reducing level %d LSP refresh interval "
2527 "to %us%s", lvl, refresh_interval, VTY_NEWLINE);
2528 set_refresh_interval[lvl-1] = 1;
2529
2530 if (refresh_interval <= area->lsp_gen_interval[lvl-1])
2531 {
2532 vty_out (vty, "LSP refresh interval %us must be greater than "
2533 "the configured LSP gen interval %us%s",
2534 refresh_interval, area->lsp_gen_interval[lvl-1],
2535 VTY_NEWLINE);
2536 return CMD_ERR_AMBIGUOUS;
2537 }
2538 }
2539 }
2540
2541 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
2542 {
2543 if (!(lvl & level))
2544 continue;
2545 area->max_lsp_lifetime[lvl-1] = interval;
2546 /* Automatically reducing lsp_refresh_interval to interval - 300 */
2547 if (set_refresh_interval[lvl-1])
2548 area->lsp_refresh[lvl-1] = refresh_interval;
2549 }
2550
2551 lsp_regenerate_schedule (area, level, 1);
2552
2553 return CMD_SUCCESS;
2554}
2555
2556DEFUN (max_lsp_lifetime,
2557 max_lsp_lifetime_cmd,
2558 "max-lsp-lifetime <350-65535>",
2559 "Maximum LSP lifetime\n"
2560 "LSP lifetime in seconds\n")
2561{
2562 struct isis_area *area;
2563 uint16_t interval;
2564 int level;
2565
2566 area = vty->index;
2567 interval = atoi (argv[0]);
2568 level = IS_LEVEL_1 | IS_LEVEL_2;
2569 return set_lsp_max_lifetime (vty, area, interval, level);
2570}
2571
2572DEFUN (no_max_lsp_lifetime,
2573 no_max_lsp_lifetime_cmd,
2574 "no max-lsp-lifetime",
2575 NO_STR
2576 "LSP lifetime in seconds\n")
2577{
2578 struct isis_area *area;
2579 uint16_t interval;
2580 int level;
2581
2582 area = vty->index;
2583 interval = DEFAULT_LSP_LIFETIME;
2584 level = IS_LEVEL_1 | IS_LEVEL_2;
2585 return set_lsp_max_lifetime (vty, area, interval, level);
2586}
2587
2588ALIAS (no_max_lsp_lifetime,
2589 no_max_lsp_lifetime_arg_cmd,
2590 "no max-lsp-lifetime <350-65535>",
2591 NO_STR
2592 "Maximum LSP lifetime\n"
2593 "LSP lifetime in seconds\n")
2594
2595DEFUN (max_lsp_lifetime_l1,
2596 max_lsp_lifetime_l1_cmd,
2597 "max-lsp-lifetime level-1 <350-65535>",
2598 "Maximum LSP lifetime for Level 1 only\n"
2599 "LSP lifetime for Level 1 only in seconds\n")
2600{
2601 struct isis_area *area;
2602 uint16_t interval;
2603 int level;
2604
2605 area = vty->index;
2606 interval = atoi (argv[0]);
2607 level = IS_LEVEL_1;
2608 return set_lsp_max_lifetime (vty, area, interval, level);
2609}
2610
2611DEFUN (no_max_lsp_lifetime_l1,
2612 no_max_lsp_lifetime_l1_cmd,
2613 "no max-lsp-lifetime level-1",
2614 NO_STR
2615 "LSP lifetime for Level 1 only in seconds\n")
2616{
2617 struct isis_area *area;
2618 uint16_t interval;
2619 int level;
2620
2621 area = vty->index;
2622 interval = DEFAULT_LSP_LIFETIME;
2623 level = IS_LEVEL_1;
2624 return set_lsp_max_lifetime (vty, area, interval, level);
2625}
2626
2627ALIAS (no_max_lsp_lifetime_l1,
2628 no_max_lsp_lifetime_l1_arg_cmd,
2629 "no max-lsp-lifetime level-1 <350-65535>",
2630 NO_STR
2631 "Maximum LSP lifetime for Level 1 only\n"
2632 "LSP lifetime for Level 1 only in seconds\n")
2633
2634DEFUN (max_lsp_lifetime_l2,
2635 max_lsp_lifetime_l2_cmd,
2636 "max-lsp-lifetime level-2 <350-65535>",
2637 "Maximum LSP lifetime for Level 2 only\n"
2638 "LSP lifetime for Level 2 only in seconds\n")
2639{
2640 struct isis_area *area;
2641 uint16_t interval;
2642 int level;
2643
2644 area = vty->index;
2645 interval = atoi (argv[0]);
2646 level = IS_LEVEL_2;
2647 return set_lsp_max_lifetime (vty, area, interval, level);
2648}
2649
2650DEFUN (no_max_lsp_lifetime_l2,
2651 no_max_lsp_lifetime_l2_cmd,
2652 "no max-lsp-lifetime level-2",
2653 NO_STR
2654 "LSP lifetime for Level 2 only in seconds\n")
2655{
2656 struct isis_area *area;
2657 uint16_t interval;
2658 int level;
2659
2660 area = vty->index;
2661 interval = DEFAULT_LSP_LIFETIME;
2662 level = IS_LEVEL_2;
2663 return set_lsp_max_lifetime (vty, area, interval, level);
2664}
2665
2666ALIAS (no_max_lsp_lifetime_l2,
2667 no_max_lsp_lifetime_l2_arg_cmd,
2668 "no max-lsp-lifetime level-2 <350-65535>",
2669 NO_STR
2670 "Maximum LSP lifetime for Level 2 only\n"
2671 "LSP lifetime for Level 2 only in seconds\n")
2672
2673static int
2674set_lsp_refresh_interval (struct vty *vty, struct isis_area *area,
2675 uint16_t interval, int level)
2676{
2677 int lvl;
2678
2679 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2680 {
2681 if (!(lvl & level))
2682 continue;
2683 if (interval <= area->lsp_gen_interval[lvl-1])
2684 {
2685 vty_out (vty, "LSP refresh interval %us must be greater than "
2686 "the configured LSP gen interval %us%s",
2687 interval, area->lsp_gen_interval[lvl-1],
2688 VTY_NEWLINE);
2689 return CMD_ERR_AMBIGUOUS;
2690 }
2691 if (interval > (area->max_lsp_lifetime[lvl-1] - 300))
2692 {
2693 vty_out (vty, "LSP refresh interval %us must be less than "
2694 "the configured LSP lifetime %us less 300%s",
2695 interval, area->max_lsp_lifetime[lvl-1],
2696 VTY_NEWLINE);
2697 return CMD_ERR_AMBIGUOUS;
2698 }
2699 }
2700
2701 for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
2702 {
2703 if (!(lvl & level))
2704 continue;
2705 area->lsp_refresh[lvl-1] = interval;
2706 }
2707 lsp_regenerate_schedule (area, level, 1);
2708
2709 return CMD_SUCCESS;
2710}
2711
2712DEFUN (lsp_refresh_interval,
2713 lsp_refresh_interval_cmd,
2714 "lsp-refresh-interval <1-65235>",
2715 "LSP refresh interval\n"
2716 "LSP refresh interval in seconds\n")
2717{
2718 struct isis_area *area;
2719 uint16_t interval;
2720 int level;
2721
2722 area = vty->index;
2723 interval = atoi (argv[0]);
2724 level = IS_LEVEL_1 | IS_LEVEL_2;
2725 return set_lsp_refresh_interval (vty, area, interval, level);
2726}
2727
2728DEFUN (no_lsp_refresh_interval,
2729 no_lsp_refresh_interval_cmd,
2730 "no lsp-refresh-interval",
2731 NO_STR
2732 "LSP refresh interval in seconds\n")
2733{
2734 struct isis_area *area;
2735 uint16_t interval;
2736 int level;
2737
2738 area = vty->index;
2739 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2740 level = IS_LEVEL_1 | IS_LEVEL_2;
2741 return set_lsp_refresh_interval (vty, area, interval, level);
2742}
2743
2744ALIAS (no_lsp_refresh_interval,
2745 no_lsp_refresh_interval_arg_cmd,
2746 "no lsp-refresh-interval <1-65235>",
2747 NO_STR
2748 "LSP refresh interval\n"
2749 "LSP refresh interval in seconds\n")
2750
2751DEFUN (lsp_refresh_interval_l1,
2752 lsp_refresh_interval_l1_cmd,
2753 "lsp-refresh-interval level-1 <1-65235>",
2754 "LSP refresh interval for Level 1 only\n"
2755 "LSP refresh interval for Level 1 only in seconds\n")
2756{
2757 struct isis_area *area;
2758 uint16_t interval;
2759 int level;
2760
2761 area = vty->index;
2762 interval = atoi (argv[0]);
2763 level = IS_LEVEL_1;
2764 return set_lsp_refresh_interval (vty, area, interval, level);
2765}
2766
2767DEFUN (no_lsp_refresh_interval_l1,
2768 no_lsp_refresh_interval_l1_cmd,
2769 "no lsp-refresh-interval level-1",
2770 NO_STR
2771 "LSP refresh interval for Level 1 only in seconds\n")
2772{
2773 struct isis_area *area;
2774 uint16_t interval;
2775 int level;
2776
2777 area = vty->index;
2778 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2779 level = IS_LEVEL_1;
2780 return set_lsp_refresh_interval (vty, area, interval, level);
2781}
2782
2783ALIAS (no_lsp_refresh_interval_l1,
2784 no_lsp_refresh_interval_l1_arg_cmd,
2785 "no lsp-refresh-interval level-1 <1-65235>",
2786 NO_STR
2787 "LSP refresh interval for Level 1 only\n"
2788 "LSP refresh interval for Level 1 only in seconds\n")
2789
2790DEFUN (lsp_refresh_interval_l2,
2791 lsp_refresh_interval_l2_cmd,
2792 "lsp-refresh-interval level-2 <1-65235>",
2793 "LSP refresh interval for Level 2 only\n"
2794 "LSP refresh interval for Level 2 only in seconds\n")
2795{
2796 struct isis_area *area;
2797 uint16_t interval;
2798 int level;
2799
2800 area = vty->index;
2801 interval = atoi (argv[0]);
2802 level = IS_LEVEL_2;
2803 return set_lsp_refresh_interval (vty, area, interval, level);
2804}
2805
2806DEFUN (no_lsp_refresh_interval_l2,
2807 no_lsp_refresh_interval_l2_cmd,
2808 "no lsp-refresh-interval level-2",
2809 NO_STR
2810 "LSP refresh interval for Level 2 only in seconds\n")
2811{
2812 struct isis_area *area;
2813 uint16_t interval;
2814 int level;
2815
2816 area = vty->index;
2817 interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
2818 level = IS_LEVEL_2;
2819 return set_lsp_refresh_interval (vty, area, interval, level);
2820}
2821
2822ALIAS (no_lsp_refresh_interval_l2,
2823 no_lsp_refresh_interval_l2_arg_cmd,
2824 "no lsp-refresh-interval level-2 <1-65235>",
2825 NO_STR
2826 "LSP refresh interval for Level 2 only\n"
2827 "LSP refresh interval for Level 2 only in seconds\n")
2828
2829DEFUN (log_adj_changes,
2830 log_adj_changes_cmd,
2831 "log-adjacency-changes",
2832 "Log changes in adjacency state\n")
2833{
2834 struct isis_area *area;
2835
2836 area = vty->index;
2837 assert (area);
2838
2839 area->log_adj_changes = 1;
2840
2841 return CMD_SUCCESS;
2842}
2843
2844DEFUN (no_log_adj_changes,
2845 no_log_adj_changes_cmd,
2846 "no log-adjacency-changes",
2847 "Stop logging changes in adjacency state\n")
2848{
2849 struct isis_area *area;
2850
2851 area = vty->index;
2852 assert (area);
2853
2854 area->log_adj_changes = 0;
2855
2856 return CMD_SUCCESS;
2857}
2858
jardineb5d44e2003-12-23 08:09:43 +00002859#ifdef TOPOLOGY_GENERATE
Josh Bailey3f045a02012-03-24 08:35:20 -07002860
jardineb5d44e2003-12-23 08:09:43 +00002861DEFUN (topology_generate_grid,
2862 topology_generate_grid_cmd,
2863 "topology generate grid <1-100> <1-100> <1-65000> [param] [param] "
2864 "[param]",
hassof1082d12005-09-19 04:23:34 +00002865 "Topology generation for IS-IS\n"
2866 "Topology generation\n"
2867 "Grid topology\n"
jardineb5d44e2003-12-23 08:09:43 +00002868 "X parameter of the grid\n"
2869 "Y parameter of the grid\n"
2870 "Random seed\n"
2871 "Optional param 1\n"
2872 "Optional param 2\n"
2873 "Optional param 3\n"
2874 "Topology\n")
2875{
2876 struct isis_area *area;
2877
2878 area = vty->index;
2879 assert (area);
2880
hassof390d2c2004-09-10 20:48:21 +00002881 if (!spgrid_check_params (vty, argc, argv))
2882 {
2883 if (area->topology)
2884 list_delete (area->topology);
2885 area->topology = list_new ();
2886 memcpy (area->top_params, vty->buf, 200);
2887 gen_spgrid_topology (vty, area->topology);
2888 remove_topology_lsps (area);
2889 generate_topology_lsps (area);
hassof1082d12005-09-19 04:23:34 +00002890 /* Regenerate L1 LSP to get two way connection to the generated
2891 * topology. */
Josh Bailey3f045a02012-03-24 08:35:20 -07002892 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
hassof390d2c2004-09-10 20:48:21 +00002893 }
jardineb5d44e2003-12-23 08:09:43 +00002894
2895 return CMD_SUCCESS;
2896}
2897
hassof695b012005-04-02 19:03:39 +00002898DEFUN (show_isis_generated_topology,
2899 show_isis_generated_topology_cmd,
hassof1082d12005-09-19 04:23:34 +00002900 "show isis generated-topologies",
jardineb5d44e2003-12-23 08:09:43 +00002901 SHOW_STR
Josh Bailey3f045a02012-03-24 08:35:20 -07002902 "ISIS network information\n"
hassof1082d12005-09-19 04:23:34 +00002903 "Show generated topologies\n")
jardineb5d44e2003-12-23 08:09:43 +00002904{
2905 struct isis_area *area;
paul92c9f222005-05-25 12:21:13 +00002906 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +00002907 struct listnode *node2;
2908 struct arc *arc;
hassof1082d12005-09-19 04:23:34 +00002909
paul92c9f222005-05-25 12:21:13 +00002910 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof1082d12005-09-19 04:23:34 +00002911 {
2912 if (!area->topology)
2913 continue;
2914
2915 vty_out (vty, "Topology for isis area: %s%s", area->area_tag,
2916 VTY_NEWLINE);
2917 vty_out (vty, "From node To node Distance%s", VTY_NEWLINE);
2918
2919 for (ALL_LIST_ELEMENTS_RO (area->topology, node2, arc))
2920 vty_out (vty, "%9ld %11ld %12ld%s", arc->from_node, arc->to_node,
2921 arc->distance, VTY_NEWLINE);
2922 }
jardineb5d44e2003-12-23 08:09:43 +00002923 return CMD_SUCCESS;
2924}
2925
hassof1082d12005-09-19 04:23:34 +00002926/* Base IS for topology generation. */
hassof390d2c2004-09-10 20:48:21 +00002927DEFUN (topology_baseis,
jardineb5d44e2003-12-23 08:09:43 +00002928 topology_baseis_cmd,
2929 "topology base-is WORD",
hassof1082d12005-09-19 04:23:34 +00002930 "Topology generation for IS-IS\n"
2931 "A Network IS Base for this topology\n"
2932 "XXXX.XXXX.XXXX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00002933{
2934 struct isis_area *area;
2935 u_char buff[ISIS_SYS_ID_LEN];
2936
2937 area = vty->index;
2938 assert (area);
2939
hassof390d2c2004-09-10 20:48:21 +00002940 if (sysid2buff (buff, argv[0]))
hassof1082d12005-09-19 04:23:34 +00002941 sysid2buff (area->topology_baseis, argv[0]);
hassof390d2c2004-09-10 20:48:21 +00002942
jardineb5d44e2003-12-23 08:09:43 +00002943 return CMD_SUCCESS;
2944}
2945
jardineb5d44e2003-12-23 08:09:43 +00002946DEFUN (no_topology_baseis,
2947 no_topology_baseis_cmd,
2948 "no topology base-is WORD",
2949 NO_STR
hassof1082d12005-09-19 04:23:34 +00002950 "Topology generation for IS-IS\n"
2951 "A Network IS Base for this topology\n"
2952 "XXXX.XXXX.XXXX Network entity title (NET)\n")
jardineb5d44e2003-12-23 08:09:43 +00002953{
2954 struct isis_area *area;
2955
2956 area = vty->index;
2957 assert (area);
2958
hassof390d2c2004-09-10 20:48:21 +00002959 memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
jardineb5d44e2003-12-23 08:09:43 +00002960 return CMD_SUCCESS;
2961}
2962
hassof1082d12005-09-19 04:23:34 +00002963ALIAS (no_topology_baseis,
2964 no_topology_baseis_noid_cmd,
2965 "no topology base-is",
2966 NO_STR
2967 "Topology generation for IS-IS\n"
2968 "A Network IS Base for this topology\n")
2969
2970DEFUN (topology_basedynh,
2971 topology_basedynh_cmd,
2972 "topology base-dynh WORD",
2973 "Topology generation for IS-IS\n"
2974 "Dynamic hostname base for this topology\n"
2975 "Dynamic hostname base\n")
2976{
2977 struct isis_area *area;
2978
2979 area = vty->index;
2980 assert (area);
2981
2982 /* I hope that it's enough. */
2983 area->topology_basedynh = strndup (argv[0], 16);
2984 return CMD_SUCCESS;
2985}
Josh Bailey3f045a02012-03-24 08:35:20 -07002986
jardineb5d44e2003-12-23 08:09:43 +00002987#endif /* TOPOLOGY_GENERATE */
2988
jardineb5d44e2003-12-23 08:09:43 +00002989/* IS-IS configuration write function */
2990int
2991isis_config_write (struct vty *vty)
2992{
2993 int write = 0;
jardineb5d44e2003-12-23 08:09:43 +00002994
hassof390d2c2004-09-10 20:48:21 +00002995 if (isis != NULL)
2996 {
2997 struct isis_area *area;
hasso3fdb2dd2005-09-28 18:45:54 +00002998 struct listnode *node, *node2;
jardineb5d44e2003-12-23 08:09:43 +00002999
hasso3fdb2dd2005-09-28 18:45:54 +00003000 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof390d2c2004-09-10 20:48:21 +00003001 {
3002 /* ISIS - Area name */
3003 vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
3004 write++;
3005 /* ISIS - Net */
3006 if (listcount (area->area_addrs) > 0)
3007 {
3008 struct area_addr *area_addr;
hasso3fdb2dd2005-09-28 18:45:54 +00003009 for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
3010 {
3011 vty_out (vty, " net %s%s",
3012 isonet_print (area_addr->area_addr,
3013 area_addr->addr_len + ISIS_SYS_ID_LEN +
3014 1), VTY_NEWLINE);
3015 write++;
3016 }
hassof390d2c2004-09-10 20:48:21 +00003017 }
hasso3fdb2dd2005-09-28 18:45:54 +00003018 /* ISIS - Dynamic hostname - Defaults to true so only display if
3019 * false. */
hassof390d2c2004-09-10 20:48:21 +00003020 if (!area->dynhostname)
3021 {
3022 vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
3023 write++;
3024 }
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07003025 /* ISIS - Metric-Style - when true displays wide */
3026 if (area->newmetric)
hassof390d2c2004-09-10 20:48:21 +00003027 {
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07003028 if (!area->oldmetric)
3029 vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
hasso2984d262005-09-26 16:49:07 +00003030 else
3031 vty_out (vty, " metric-style transition%s", VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +00003032 write++;
3033 }
Christian Frankef818c8f2012-11-27 01:10:28 +00003034 else
3035 {
3036 vty_out (vty, " metric-style narrow%s", VTY_NEWLINE);
3037 write++;
3038 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003039 /* ISIS - overload-bit */
3040 if (area->overload_bit)
3041 {
3042 vty_out (vty, " set-overload-bit%s", VTY_NEWLINE);
3043 write++;
3044 }
hassof390d2c2004-09-10 20:48:21 +00003045 /* ISIS - Area is-type (level-1-2 is default) */
3046 if (area->is_type == IS_LEVEL_1)
3047 {
3048 vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
3049 write++;
3050 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003051 else if (area->is_type == IS_LEVEL_2)
hassof390d2c2004-09-10 20:48:21 +00003052 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003053 vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
3054 write++;
hassof390d2c2004-09-10 20:48:21 +00003055 }
Christian Frankeacf98652015-11-12 14:24:22 +01003056 write += isis_redist_config_write(vty, area, AF_INET);
3057 write += isis_redist_config_write(vty, area, AF_INET6);
hassof390d2c2004-09-10 20:48:21 +00003058 /* ISIS - Lsp generation interval */
3059 if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1])
3060 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003061 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00003062 {
3063 vty_out (vty, " lsp-gen-interval %d%s",
3064 area->lsp_gen_interval[0], VTY_NEWLINE);
3065 write++;
3066 }
3067 }
3068 else
3069 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003070 if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00003071 {
3072 vty_out (vty, " lsp-gen-interval level-1 %d%s",
3073 area->lsp_gen_interval[0], VTY_NEWLINE);
3074 write++;
3075 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003076 if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00003077 {
3078 vty_out (vty, " lsp-gen-interval level-2 %d%s",
3079 area->lsp_gen_interval[1], VTY_NEWLINE);
3080 write++;
3081 }
3082 }
3083 /* ISIS - LSP lifetime */
3084 if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1])
3085 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003086 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00003087 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003088 vty_out (vty, " max-lsp-lifetime %u%s", area->max_lsp_lifetime[0],
hassof390d2c2004-09-10 20:48:21 +00003089 VTY_NEWLINE);
3090 write++;
3091 }
3092 }
3093 else
3094 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003095 if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00003096 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003097 vty_out (vty, " max-lsp-lifetime level-1 %u%s",
hassof390d2c2004-09-10 20:48:21 +00003098 area->max_lsp_lifetime[0], VTY_NEWLINE);
3099 write++;
3100 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003101 if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME)
hassof390d2c2004-09-10 20:48:21 +00003102 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003103 vty_out (vty, " max-lsp-lifetime level-2 %u%s",
hassof390d2c2004-09-10 20:48:21 +00003104 area->max_lsp_lifetime[1], VTY_NEWLINE);
3105 write++;
3106 }
3107 }
Josh Bailey3f045a02012-03-24 08:35:20 -07003108 /* ISIS - LSP refresh interval */
3109 if (area->lsp_refresh[0] == area->lsp_refresh[1])
3110 {
3111 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3112 {
3113 vty_out (vty, " lsp-refresh-interval %u%s", area->lsp_refresh[0],
3114 VTY_NEWLINE);
3115 write++;
3116 }
3117 }
3118 else
3119 {
3120 if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3121 {
3122 vty_out (vty, " lsp-refresh-interval level-1 %u%s",
3123 area->lsp_refresh[0], VTY_NEWLINE);
3124 write++;
3125 }
3126 if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL)
3127 {
3128 vty_out (vty, " lsp-refresh-interval level-2 %u%s",
3129 area->lsp_refresh[1], VTY_NEWLINE);
3130 write++;
3131 }
3132 }
Christian Frankef1fc1db2015-11-10 18:43:31 +01003133 if (area->lsp_mtu != DEFAULT_LSP_MTU)
3134 {
3135 vty_out(vty, " lsp-mtu %u%s", area->lsp_mtu, VTY_NEWLINE);
3136 write++;
3137 }
3138
hasso13fb40a2005-10-01 06:03:04 +00003139 /* Minimum SPF interval. */
3140 if (area->min_spf_interval[0] == area->min_spf_interval[1])
3141 {
3142 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
3143 {
3144 vty_out (vty, " spf-interval %d%s",
3145 area->min_spf_interval[0], VTY_NEWLINE);
3146 write++;
3147 }
3148 }
3149 else
3150 {
3151 if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
3152 {
3153 vty_out (vty, " spf-interval level-1 %d%s",
3154 area->min_spf_interval[0], VTY_NEWLINE);
3155 write++;
3156 }
3157 if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL)
3158 {
3159 vty_out (vty, " spf-interval level-2 %d%s",
3160 area->min_spf_interval[1], VTY_NEWLINE);
3161 write++;
3162 }
3163 }
hasso53c997c2004-09-15 16:21:59 +00003164 /* Authentication passwords. */
Josh Bailey3f045a02012-03-24 08:35:20 -07003165 if (area->area_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
hasso53c997c2004-09-15 16:21:59 +00003166 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003167 vty_out(vty, " area-password md5 %s", area->area_passwd.passwd);
hasso1cbc5622005-01-01 10:29:51 +00003168 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
3169 {
3170 vty_out(vty, " authenticate snp ");
3171 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
3172 vty_out(vty, "validate");
3173 else
3174 vty_out(vty, "send-only");
3175 }
3176 vty_out(vty, "%s", VTY_NEWLINE);
hasso53c997c2004-09-15 16:21:59 +00003177 write++;
Josh Bailey3f045a02012-03-24 08:35:20 -07003178 }
3179 else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
3180 {
3181 vty_out(vty, " area-password clear %s", area->area_passwd.passwd);
3182 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
3183 {
3184 vty_out(vty, " authenticate snp ");
3185 if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
3186 vty_out(vty, "validate");
3187 else
3188 vty_out(vty, "send-only");
3189 }
3190 vty_out(vty, "%s", VTY_NEWLINE);
3191 write++;
3192 }
3193 if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
hasso53c997c2004-09-15 16:21:59 +00003194 {
Josh Bailey3f045a02012-03-24 08:35:20 -07003195 vty_out(vty, " domain-password md5 %s",
3196 area->domain_passwd.passwd);
3197 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3198 {
3199 vty_out(vty, " authenticate snp ");
3200 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3201 vty_out(vty, "validate");
3202 else
3203 vty_out(vty, "send-only");
3204 }
3205 vty_out(vty, "%s", VTY_NEWLINE);
3206 write++;
3207 }
3208 else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
3209 {
3210 vty_out(vty, " domain-password clear %s",
3211 area->domain_passwd.passwd);
hasso1cbc5622005-01-01 10:29:51 +00003212 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
3213 {
3214 vty_out(vty, " authenticate snp ");
3215 if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
3216 vty_out(vty, "validate");
3217 else
3218 vty_out(vty, "send-only");
3219 }
3220 vty_out(vty, "%s", VTY_NEWLINE);
hasso53c997c2004-09-15 16:21:59 +00003221 write++;
3222 }
hassof1082d12005-09-19 04:23:34 +00003223
Josh Bailey3f045a02012-03-24 08:35:20 -07003224 if (area->log_adj_changes)
3225 {
3226 vty_out (vty, " log-adjacency-changes%s", VTY_NEWLINE);
3227 write++;
3228 }
3229
hassof390d2c2004-09-10 20:48:21 +00003230#ifdef TOPOLOGY_GENERATE
hassof1082d12005-09-19 04:23:34 +00003231 if (memcmp (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS,
3232 ISIS_SYS_ID_LEN))
3233 {
3234 vty_out (vty, " topology base-is %s%s",
Josh Bailey3f045a02012-03-24 08:35:20 -07003235 sysid_print ((u_char *)area->topology_baseis), VTY_NEWLINE);
hassof1082d12005-09-19 04:23:34 +00003236 write++;
3237 }
3238 if (area->topology_basedynh)
3239 {
3240 vty_out (vty, " topology base-dynh %s%s",
3241 area->topology_basedynh, VTY_NEWLINE);
3242 write++;
3243 }
3244 /* We save the whole command line here. */
3245 if (strlen(area->top_params))
hassof390d2c2004-09-10 20:48:21 +00003246 {
3247 vty_out (vty, " %s%s", area->top_params, VTY_NEWLINE);
3248 write++;
3249 }
hassof390d2c2004-09-10 20:48:21 +00003250#endif /* TOPOLOGY_GENERATE */
hassof1082d12005-09-19 04:23:34 +00003251
hassof390d2c2004-09-10 20:48:21 +00003252 }
jardineb5d44e2003-12-23 08:09:43 +00003253 }
hassof390d2c2004-09-10 20:48:21 +00003254
jardineb5d44e2003-12-23 08:09:43 +00003255 return write;
3256}
3257
Josh Bailey3f045a02012-03-24 08:35:20 -07003258struct cmd_node isis_node = {
jardineb5d44e2003-12-23 08:09:43 +00003259 ISIS_NODE,
hasso2097cd82003-12-23 11:51:08 +00003260 "%s(config-router)# ",
jardineb5d44e2003-12-23 08:09:43 +00003261 1
3262};
3263
hassof390d2c2004-09-10 20:48:21 +00003264void
jardineb5d44e2003-12-23 08:09:43 +00003265isis_init ()
3266{
jardineb5d44e2003-12-23 08:09:43 +00003267 /* Install IS-IS top node */
3268 install_node (&isis_node, isis_config_write);
hassof390d2c2004-09-10 20:48:21 +00003269
Josh Bailey3f045a02012-03-24 08:35:20 -07003270 install_element (VIEW_NODE, &show_isis_summary_cmd);
3271
3272 install_element (VIEW_NODE, &show_isis_interface_cmd);
3273 install_element (VIEW_NODE, &show_isis_interface_detail_cmd);
3274 install_element (VIEW_NODE, &show_isis_interface_arg_cmd);
3275
3276 install_element (VIEW_NODE, &show_isis_neighbor_cmd);
3277 install_element (VIEW_NODE, &show_isis_neighbor_detail_cmd);
3278 install_element (VIEW_NODE, &show_isis_neighbor_arg_cmd);
3279 install_element (VIEW_NODE, &clear_isis_neighbor_cmd);
3280 install_element (VIEW_NODE, &clear_isis_neighbor_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003281
3282 install_element (VIEW_NODE, &show_hostname_cmd);
3283 install_element (VIEW_NODE, &show_database_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003284 install_element (VIEW_NODE, &show_database_arg_cmd);
3285 install_element (VIEW_NODE, &show_database_arg_detail_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003286 install_element (VIEW_NODE, &show_database_detail_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003287 install_element (VIEW_NODE, &show_database_detail_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003288
hassof390d2c2004-09-10 20:48:21 +00003289 install_node (&debug_node, config_write_debug);
jardin9e867fe2003-12-23 08:56:18 +00003290
jardineb5d44e2003-12-23 08:09:43 +00003291 install_element (ENABLE_NODE, &debug_isis_adj_cmd);
3292 install_element (ENABLE_NODE, &no_debug_isis_adj_cmd);
3293 install_element (ENABLE_NODE, &debug_isis_csum_cmd);
3294 install_element (ENABLE_NODE, &no_debug_isis_csum_cmd);
3295 install_element (ENABLE_NODE, &debug_isis_lupd_cmd);
3296 install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd);
3297 install_element (ENABLE_NODE, &debug_isis_err_cmd);
3298 install_element (ENABLE_NODE, &no_debug_isis_err_cmd);
3299 install_element (ENABLE_NODE, &debug_isis_snp_cmd);
3300 install_element (ENABLE_NODE, &no_debug_isis_snp_cmd);
3301 install_element (ENABLE_NODE, &debug_isis_upd_cmd);
3302 install_element (ENABLE_NODE, &no_debug_isis_upd_cmd);
3303 install_element (ENABLE_NODE, &debug_isis_spfevents_cmd);
3304 install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd);
3305 install_element (ENABLE_NODE, &debug_isis_spfstats_cmd);
3306 install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd);
3307 install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd);
3308 install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd);
3309 install_element (ENABLE_NODE, &debug_isis_rtevents_cmd);
3310 install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd);
3311 install_element (ENABLE_NODE, &debug_isis_events_cmd);
3312 install_element (ENABLE_NODE, &no_debug_isis_events_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003313 install_element (ENABLE_NODE, &debug_isis_packet_dump_cmd);
3314 install_element (ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
Christian Franke80a8f722015-11-12 14:21:47 +01003315 install_element (ENABLE_NODE, &debug_isis_lsp_gen_cmd);
3316 install_element (ENABLE_NODE, &no_debug_isis_lsp_gen_cmd);
Christian Franke61010c32015-11-10 18:43:34 +01003317 install_element (ENABLE_NODE, &debug_isis_lsp_sched_cmd);
3318 install_element (ENABLE_NODE, &no_debug_isis_lsp_sched_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003319
jardin9e867fe2003-12-23 08:56:18 +00003320 install_element (CONFIG_NODE, &debug_isis_adj_cmd);
3321 install_element (CONFIG_NODE, &no_debug_isis_adj_cmd);
3322 install_element (CONFIG_NODE, &debug_isis_csum_cmd);
3323 install_element (CONFIG_NODE, &no_debug_isis_csum_cmd);
3324 install_element (CONFIG_NODE, &debug_isis_lupd_cmd);
3325 install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd);
3326 install_element (CONFIG_NODE, &debug_isis_err_cmd);
3327 install_element (CONFIG_NODE, &no_debug_isis_err_cmd);
3328 install_element (CONFIG_NODE, &debug_isis_snp_cmd);
3329 install_element (CONFIG_NODE, &no_debug_isis_snp_cmd);
3330 install_element (CONFIG_NODE, &debug_isis_upd_cmd);
3331 install_element (CONFIG_NODE, &no_debug_isis_upd_cmd);
3332 install_element (CONFIG_NODE, &debug_isis_spfevents_cmd);
3333 install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd);
3334 install_element (CONFIG_NODE, &debug_isis_spfstats_cmd);
3335 install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd);
3336 install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd);
3337 install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd);
3338 install_element (CONFIG_NODE, &debug_isis_rtevents_cmd);
3339 install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd);
3340 install_element (CONFIG_NODE, &debug_isis_events_cmd);
3341 install_element (CONFIG_NODE, &no_debug_isis_events_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003342 install_element (CONFIG_NODE, &debug_isis_packet_dump_cmd);
3343 install_element (CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
Christian Franke80a8f722015-11-12 14:21:47 +01003344 install_element (CONFIG_NODE, &debug_isis_lsp_gen_cmd);
3345 install_element (CONFIG_NODE, &no_debug_isis_lsp_gen_cmd);
Christian Franke61010c32015-11-10 18:43:34 +01003346 install_element (CONFIG_NODE, &debug_isis_lsp_sched_cmd);
3347 install_element (CONFIG_NODE, &no_debug_isis_lsp_sched_cmd);
jardin9e867fe2003-12-23 08:56:18 +00003348
jardineb5d44e2003-12-23 08:09:43 +00003349 install_element (CONFIG_NODE, &router_isis_cmd);
3350 install_element (CONFIG_NODE, &no_router_isis_cmd);
3351
3352 install_default (ISIS_NODE);
3353
3354 install_element (ISIS_NODE, &net_cmd);
3355 install_element (ISIS_NODE, &no_net_cmd);
3356
3357 install_element (ISIS_NODE, &is_type_cmd);
3358 install_element (ISIS_NODE, &no_is_type_cmd);
3359
Christian Frankef1fc1db2015-11-10 18:43:31 +01003360 install_element (ISIS_NODE, &area_lsp_mtu_cmd);
3361 install_element (ISIS_NODE, &no_area_lsp_mtu_cmd);
3362 install_element (ISIS_NODE, &no_area_lsp_mtu_arg_cmd);
3363
Josh Bailey3f045a02012-03-24 08:35:20 -07003364 install_element (ISIS_NODE, &area_passwd_md5_cmd);
3365 install_element (ISIS_NODE, &area_passwd_md5_snpauth_cmd);
3366 install_element (ISIS_NODE, &area_passwd_clear_cmd);
3367 install_element (ISIS_NODE, &area_passwd_clear_snpauth_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003368 install_element (ISIS_NODE, &no_area_passwd_cmd);
3369
Josh Bailey3f045a02012-03-24 08:35:20 -07003370 install_element (ISIS_NODE, &domain_passwd_md5_cmd);
3371 install_element (ISIS_NODE, &domain_passwd_md5_snpauth_cmd);
3372 install_element (ISIS_NODE, &domain_passwd_clear_cmd);
3373 install_element (ISIS_NODE, &domain_passwd_clear_snpauth_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003374 install_element (ISIS_NODE, &no_domain_passwd_cmd);
3375
3376 install_element (ISIS_NODE, &lsp_gen_interval_cmd);
3377 install_element (ISIS_NODE, &no_lsp_gen_interval_cmd);
3378 install_element (ISIS_NODE, &no_lsp_gen_interval_arg_cmd);
3379 install_element (ISIS_NODE, &lsp_gen_interval_l1_cmd);
3380 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_cmd);
3381 install_element (ISIS_NODE, &no_lsp_gen_interval_l1_arg_cmd);
3382 install_element (ISIS_NODE, &lsp_gen_interval_l2_cmd);
3383 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_cmd);
3384 install_element (ISIS_NODE, &no_lsp_gen_interval_l2_arg_cmd);
3385
3386 install_element (ISIS_NODE, &spf_interval_cmd);
3387 install_element (ISIS_NODE, &no_spf_interval_cmd);
3388 install_element (ISIS_NODE, &no_spf_interval_arg_cmd);
3389 install_element (ISIS_NODE, &spf_interval_l1_cmd);
3390 install_element (ISIS_NODE, &no_spf_interval_l1_cmd);
3391 install_element (ISIS_NODE, &no_spf_interval_l1_arg_cmd);
3392 install_element (ISIS_NODE, &spf_interval_l2_cmd);
3393 install_element (ISIS_NODE, &no_spf_interval_l2_cmd);
3394 install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd);
hassof390d2c2004-09-10 20:48:21 +00003395
Josh Bailey3f045a02012-03-24 08:35:20 -07003396 install_element (ISIS_NODE, &max_lsp_lifetime_cmd);
3397 install_element (ISIS_NODE, &no_max_lsp_lifetime_cmd);
3398 install_element (ISIS_NODE, &no_max_lsp_lifetime_arg_cmd);
3399 install_element (ISIS_NODE, &max_lsp_lifetime_l1_cmd);
3400 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_cmd);
3401 install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_arg_cmd);
3402 install_element (ISIS_NODE, &max_lsp_lifetime_l2_cmd);
3403 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_cmd);
3404 install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_arg_cmd);
3405
3406 install_element (ISIS_NODE, &lsp_refresh_interval_cmd);
3407 install_element (ISIS_NODE, &no_lsp_refresh_interval_cmd);
3408 install_element (ISIS_NODE, &no_lsp_refresh_interval_arg_cmd);
3409 install_element (ISIS_NODE, &lsp_refresh_interval_l1_cmd);
3410 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_cmd);
3411 install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_arg_cmd);
3412 install_element (ISIS_NODE, &lsp_refresh_interval_l2_cmd);
3413 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_cmd);
3414 install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_arg_cmd);
3415
3416 install_element (ISIS_NODE, &set_overload_bit_cmd);
3417 install_element (ISIS_NODE, &no_set_overload_bit_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003418
Amritha Nambiarc8ee9402015-08-24 16:40:14 -07003419 install_element (ISIS_NODE, &set_attached_bit_cmd);
3420 install_element (ISIS_NODE, &no_set_attached_bit_cmd);
3421
jardineb5d44e2003-12-23 08:09:43 +00003422 install_element (ISIS_NODE, &dynamic_hostname_cmd);
3423 install_element (ISIS_NODE, &no_dynamic_hostname_cmd);
3424
3425 install_element (ISIS_NODE, &metric_style_cmd);
3426 install_element (ISIS_NODE, &no_metric_style_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07003427
3428 install_element (ISIS_NODE, &log_adj_changes_cmd);
3429 install_element (ISIS_NODE, &no_log_adj_changes_cmd);
3430
jardineb5d44e2003-12-23 08:09:43 +00003431#ifdef TOPOLOGY_GENERATE
3432 install_element (ISIS_NODE, &topology_generate_grid_cmd);
3433 install_element (ISIS_NODE, &topology_baseis_cmd);
hassof1082d12005-09-19 04:23:34 +00003434 install_element (ISIS_NODE, &topology_basedynh_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003435 install_element (ISIS_NODE, &no_topology_baseis_cmd);
hassof1082d12005-09-19 04:23:34 +00003436 install_element (ISIS_NODE, &no_topology_baseis_noid_cmd);
hassof695b012005-04-02 19:03:39 +00003437 install_element (VIEW_NODE, &show_isis_generated_topology_cmd);
jardineb5d44e2003-12-23 08:09:43 +00003438#endif /* TOPOLOGY_GENERATE */
jardineb5d44e2003-12-23 08:09:43 +00003439}