]>
Commit | Line | Data |
---|---|---|
eb5d44eb | 1 | /* |
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 | ||
eb5d44eb | 23 | #include <zebra.h> |
eb5d44eb | 24 | |
25 | #include "thread.h" | |
26 | #include "vty.h" | |
27 | #include "command.h" | |
28 | #include "log.h" | |
29 | #include "memory.h" | |
3f045a08 | 30 | #include "time.h" |
eb5d44eb | 31 | #include "linklist.h" |
32 | #include "if.h" | |
33 | #include "hash.h" | |
34 | #include "stream.h" | |
35 | #include "prefix.h" | |
36 | #include "table.h" | |
676a4ea3 | 37 | #include "qobj.h" |
03f7e182 | 38 | #include "spf_backoff.h" |
eb5d44eb | 39 | |
40 | #include "isisd/dict.h" | |
eb5d44eb | 41 | #include "isisd/isis_constants.h" |
42 | #include "isisd/isis_common.h" | |
eb5d44eb | 43 | #include "isisd/isis_flags.h" |
3f045a08 JB |
44 | #include "isisd/isis_circuit.h" |
45 | #include "isisd/isis_csm.h" | |
eb5d44eb | 46 | #include "isisd/isisd.h" |
47 | #include "isisd/isis_dynhn.h" | |
48 | #include "isisd/isis_adjacency.h" | |
49 | #include "isisd/isis_pdu.h" | |
50 | #include "isisd/isis_misc.h" | |
51 | #include "isisd/isis_constants.h" | |
52 | #include "isisd/isis_tlv.h" | |
53 | #include "isisd/isis_lsp.h" | |
54 | #include "isisd/isis_spf.h" | |
55 | #include "isisd/isis_route.h" | |
56 | #include "isisd/isis_zebra.h" | |
57 | #include "isisd/isis_events.h" | |
f8c06e2c | 58 | #include "isisd/isis_te.h" |
eb5d44eb | 59 | |
eb5d44eb | 60 | struct isis *isis = NULL; |
eb5d44eb | 61 | |
676a4ea3 DL |
62 | DEFINE_QOBJ_TYPE(isis) |
63 | DEFINE_QOBJ_TYPE(isis_area) | |
64 | ||
41b36e90 PJ |
65 | /* |
66 | * Prototypes. | |
67 | */ | |
41b36e90 PJ |
68 | int isis_area_get(struct vty *, const char *); |
69 | int isis_area_destroy(struct vty *, const char *); | |
3f045a08 JB |
70 | int area_net_title(struct vty *, const char *); |
71 | int area_clear_net_title(struct vty *, const char *); | |
72 | int show_isis_interface_common(struct vty *, const char *ifname, char); | |
73 | int show_isis_neighbor_common(struct vty *, const char *id, char); | |
74 | int clear_isis_neighbor_common(struct vty *, const char *id); | |
41b36e90 PJ |
75 | int isis_config_write(struct vty *); |
76 | ||
77 | ||
78 | ||
eb5d44eb | 79 | void |
80 | isis_new (unsigned long process_id) | |
81 | { | |
aac372f4 | 82 | isis = XCALLOC (MTYPE_ISIS, sizeof (struct isis)); |
eb5d44eb | 83 | /* |
84 | * Default values | |
85 | */ | |
86 | isis->max_area_addrs = 3; | |
eb5d44eb | 87 | isis->process_id = process_id; |
3f045a08 | 88 | isis->router_id = 0; |
eb5d44eb | 89 | isis->area_list = list_new (); |
90 | isis->init_circ_list = list_new (); | |
91 | isis->uptime = time (NULL); | |
92 | isis->nexthops = list_new (); | |
eb5d44eb | 93 | isis->nexthops6 = list_new (); |
3f045a08 | 94 | dyn_cache_init (); |
eb5d44eb | 95 | /* |
96 | * uncomment the next line for full debugs | |
97 | */ | |
f390d2c7 | 98 | /* isis->debugs = 0xFFFF; */ |
f8c06e2c | 99 | isisMplsTE.status = disable; /* Only support TE metric */ |
676a4ea3 | 100 | QOBJ_REG (isis, isis); |
eb5d44eb | 101 | } |
102 | ||
103 | struct isis_area * | |
3f045a08 | 104 | isis_area_create (const char *area_tag) |
eb5d44eb | 105 | { |
eb5d44eb | 106 | struct isis_area *area; |
f390d2c7 | 107 | |
aac372f4 | 108 | area = XCALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area)); |
eb5d44eb | 109 | |
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; | |
3f045a08 | 118 | |
eb5d44eb | 119 | /* |
120 | * intialize the databases | |
121 | */ | |
3f045a08 JB |
122 | if (area->is_type & IS_LEVEL_1) |
123 | { | |
124 | area->lspdb[0] = lsp_db_init (); | |
125 | area->route_table[0] = route_table_init (); | |
3f045a08 | 126 | area->route_table6[0] = route_table_init (); |
3f045a08 JB |
127 | } |
128 | if (area->is_type & IS_LEVEL_2) | |
129 | { | |
130 | area->lspdb[1] = lsp_db_init (); | |
131 | area->route_table[1] = route_table_init (); | |
3f045a08 | 132 | area->route_table6[1] = route_table_init (); |
3f045a08 JB |
133 | } |
134 | ||
135 | spftree_area_init (area); | |
136 | ||
eb5d44eb | 137 | area->circuit_list = list_new (); |
138 | area->area_addrs = list_new (); | |
f390d2c7 | 139 | THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1); |
c7350c48 | 140 | flags_initialize (&area->flags); |
3f045a08 | 141 | |
eb5d44eb | 142 | /* |
143 | * Default values | |
144 | */ | |
3f045a08 JB |
145 | area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */ |
146 | area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */ | |
147 | area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */ | |
148 | area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */ | |
149 | area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL; | |
150 | area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL; | |
eb5d44eb | 151 | area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL; |
152 | area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL; | |
153 | area->dynhostname = 1; | |
3f045a08 JB |
154 | area->oldmetric = 0; |
155 | area->newmetric = 1; | |
eb5d44eb | 156 | area->lsp_frag_threshold = 90; |
b20ccb3a | 157 | area->lsp_mtu = DEFAULT_LSP_MTU; |
eb5d44eb | 158 | |
3f045a08 JB |
159 | area->area_tag = strdup (area_tag); |
160 | listnode_add (isis->area_list, area); | |
161 | area->isis = isis; | |
162 | ||
676a4ea3 DL |
163 | QOBJ_REG (area, isis_area); |
164 | ||
eb5d44eb | 165 | return area; |
166 | } | |
167 | ||
168 | struct isis_area * | |
f90a5f6f | 169 | isis_area_lookup (const char *area_tag) |
eb5d44eb | 170 | { |
171 | struct isis_area *area; | |
3fdb2dd9 | 172 | struct listnode *node; |
f390d2c7 | 173 | |
3fdb2dd9 | 174 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
eb5d44eb | 175 | if ((area->area_tag == NULL && area_tag == NULL) || |
f390d2c7 | 176 | (area->area_tag && area_tag |
177 | && strcmp (area->area_tag, area_tag) == 0)) | |
178 | return area; | |
179 | ||
eb5d44eb | 180 | return NULL; |
181 | } | |
182 | ||
f390d2c7 | 183 | int |
f90a5f6f | 184 | isis_area_get (struct vty *vty, const char *area_tag) |
eb5d44eb | 185 | { |
eb5d44eb | 186 | struct isis_area *area; |
f390d2c7 | 187 | |
eb5d44eb | 188 | area = isis_area_lookup (area_tag); |
f390d2c7 | 189 | |
190 | if (area) | |
191 | { | |
8ff5a399 | 192 | VTY_PUSH_CONTEXT (ISIS_NODE, area); |
f390d2c7 | 193 | return CMD_SUCCESS; |
194 | } | |
195 | ||
3f045a08 | 196 | area = isis_area_create (area_tag); |
f390d2c7 | 197 | |
c89c05dd | 198 | if (isis->debugs & DEBUG_EVENTS) |
199 | zlog_debug ("New IS-IS area instance %s", area->area_tag); | |
eb5d44eb | 200 | |
8ff5a399 | 201 | VTY_PUSH_CONTEXT (ISIS_NODE, area); |
f390d2c7 | 202 | |
eb5d44eb | 203 | return CMD_SUCCESS; |
204 | } | |
205 | ||
206 | int | |
f90a5f6f | 207 | isis_area_destroy (struct vty *vty, const char *area_tag) |
eb5d44eb | 208 | { |
eb5d44eb | 209 | struct isis_area *area; |
1eb8ef25 | 210 | struct listnode *node, *nnode; |
eb5d44eb | 211 | struct isis_circuit *circuit; |
3f045a08 | 212 | struct area_addr *addr; |
eb5d44eb | 213 | |
214 | area = isis_area_lookup (area_tag); | |
eb5d44eb | 215 | |
f390d2c7 | 216 | if (area == NULL) |
217 | { | |
218 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); | |
3f045a08 | 219 | return CMD_ERR_NO_MATCH; |
f390d2c7 | 220 | } |
221 | ||
676a4ea3 DL |
222 | QOBJ_UNREG (area); |
223 | ||
f390d2c7 | 224 | if (area->circuit_list) |
225 | { | |
1eb8ef25 | 226 | for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit)) |
3f045a08 JB |
227 | { |
228 | circuit->ip_router = 0; | |
3f045a08 | 229 | circuit->ipv6_router = 0; |
3f045a08 JB |
230 | isis_csm_state_change (ISIS_DISABLE, circuit, area); |
231 | } | |
f390d2c7 | 232 | list_delete (area->circuit_list); |
3f045a08 | 233 | area->circuit_list = NULL; |
eb5d44eb | 234 | } |
3f045a08 JB |
235 | |
236 | if (area->lspdb[0] != NULL) | |
237 | { | |
238 | lsp_db_destroy (area->lspdb[0]); | |
239 | area->lspdb[0] = NULL; | |
240 | } | |
241 | if (area->lspdb[1] != NULL) | |
242 | { | |
243 | lsp_db_destroy (area->lspdb[1]); | |
244 | area->lspdb[1] = NULL; | |
245 | } | |
246 | ||
247 | spftree_area_del (area); | |
248 | ||
5475ecf7 SL |
249 | THREAD_TIMER_OFF(area->spf_timer[0]); |
250 | THREAD_TIMER_OFF(area->spf_timer[1]); | |
251 | ||
03f7e182 SL |
252 | spf_backoff_free(area->spf_delay_ietf[0]); |
253 | spf_backoff_free(area->spf_delay_ietf[1]); | |
254 | ||
3f045a08 JB |
255 | /* invalidate and validate would delete all routes from zebra */ |
256 | isis_route_invalidate (area); | |
257 | isis_route_validate (area); | |
258 | ||
259 | if (area->route_table[0]) | |
260 | { | |
261 | route_table_finish (area->route_table[0]); | |
262 | area->route_table[0] = NULL; | |
263 | } | |
264 | if (area->route_table[1]) | |
265 | { | |
266 | route_table_finish (area->route_table[1]); | |
267 | area->route_table[1] = NULL; | |
268 | } | |
3f045a08 JB |
269 | if (area->route_table6[0]) |
270 | { | |
271 | route_table_finish (area->route_table6[0]); | |
272 | area->route_table6[0] = NULL; | |
273 | } | |
274 | if (area->route_table6[1]) | |
275 | { | |
276 | route_table_finish (area->route_table6[1]); | |
277 | area->route_table6[1] = NULL; | |
278 | } | |
3f045a08 | 279 | |
f3ccedaa CF |
280 | isis_redist_area_finish(area); |
281 | ||
3f045a08 JB |
282 | for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addr)) |
283 | { | |
284 | list_delete_node (area->area_addrs, node); | |
285 | XFREE (MTYPE_ISIS_AREA_ADDR, addr); | |
286 | } | |
287 | area->area_addrs = NULL; | |
288 | ||
f390d2c7 | 289 | THREAD_TIMER_OFF (area->t_tick); |
f390d2c7 | 290 | THREAD_TIMER_OFF (area->t_lsp_refresh[0]); |
291 | THREAD_TIMER_OFF (area->t_lsp_refresh[1]); | |
eb5d44eb | 292 | |
3f045a08 JB |
293 | thread_cancel_event (master, area); |
294 | ||
295 | listnode_delete (isis->area_list, area); | |
296 | ||
297 | free (area->area_tag); | |
298 | ||
eb5d44eb | 299 | XFREE (MTYPE_ISIS_AREA, area); |
f390d2c7 | 300 | |
3f045a08 JB |
301 | if (listcount (isis->area_list) == 0) |
302 | { | |
303 | memset (isis->sysid, 0, ISIS_SYS_ID_LEN); | |
304 | isis->sysid_set = 0; | |
305 | } | |
306 | ||
eb5d44eb | 307 | return CMD_SUCCESS; |
308 | } | |
309 | ||
f390d2c7 | 310 | int |
3f045a08 | 311 | area_net_title (struct vty *vty, const char *net_title) |
eb5d44eb | 312 | { |
8ff5a399 | 313 | VTY_DECLVAR_CONTEXT (isis_area, area); |
eb5d44eb | 314 | struct area_addr *addr; |
315 | struct area_addr *addrp; | |
3fdb2dd9 | 316 | struct listnode *node; |
eb5d44eb | 317 | |
318 | u_char buff[255]; | |
eb5d44eb | 319 | |
eb5d44eb | 320 | /* We check that we are not over the maximal number of addresses */ |
f390d2c7 | 321 | if (listcount (area->area_addrs) >= isis->max_area_addrs) |
322 | { | |
323 | vty_out (vty, "Maximum of area addresses (%d) already reached %s", | |
324 | isis->max_area_addrs, VTY_NEWLINE); | |
3f045a08 | 325 | return CMD_ERR_NOTHING_TODO; |
f390d2c7 | 326 | } |
eb5d44eb | 327 | |
328 | addr = XMALLOC (MTYPE_ISIS_AREA_ADDR, sizeof (struct area_addr)); | |
329 | addr->addr_len = dotformat2buff (buff, net_title); | |
330 | memcpy (addr->area_addr, buff, addr->addr_len); | |
331 | #ifdef EXTREME_DEBUG | |
529d65b3 | 332 | zlog_debug ("added area address %s for area %s (address length %d)", |
eb5d44eb | 333 | net_title, area->area_tag, addr->addr_len); |
334 | #endif /* EXTREME_DEBUG */ | |
f390d2c7 | 335 | if (addr->addr_len < 8 || addr->addr_len > 20) |
336 | { | |
3f045a08 JB |
337 | vty_out (vty, "area address must be at least 8..20 octets long (%d)%s", |
338 | addr->addr_len, VTY_NEWLINE); | |
339 | XFREE (MTYPE_ISIS_AREA_ADDR, addr); | |
340 | return CMD_ERR_AMBIGUOUS; | |
341 | } | |
342 | ||
343 | if (addr->area_addr[addr->addr_len-1] != 0) | |
344 | { | |
345 | vty_out (vty, "nsel byte (last byte) in area address must be 0%s", | |
346 | VTY_NEWLINE); | |
eb5d44eb | 347 | XFREE (MTYPE_ISIS_AREA_ADDR, addr); |
3f045a08 | 348 | return CMD_ERR_AMBIGUOUS; |
eb5d44eb | 349 | } |
350 | ||
f390d2c7 | 351 | if (isis->sysid_set == 0) |
352 | { | |
353 | /* | |
354 | * First area address - get the SystemID for this router | |
355 | */ | |
3f045a08 | 356 | memcpy (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN); |
f390d2c7 | 357 | isis->sysid_set = 1; |
c89c05dd | 358 | if (isis->debugs & DEBUG_EVENTS) |
359 | zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid)); | |
eb5d44eb | 360 | } |
f390d2c7 | 361 | else |
362 | { | |
363 | /* | |
364 | * Check that the SystemID portions match | |
365 | */ | |
3f045a08 | 366 | if (memcmp (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN)) |
f390d2c7 | 367 | { |
368 | vty_out (vty, | |
369 | "System ID must not change when defining additional area" | |
370 | " addresses%s", VTY_NEWLINE); | |
371 | XFREE (MTYPE_ISIS_AREA_ADDR, addr); | |
3f045a08 | 372 | return CMD_ERR_AMBIGUOUS; |
f390d2c7 | 373 | } |
eb5d44eb | 374 | |
f390d2c7 | 375 | /* now we see that we don't already have this address */ |
3fdb2dd9 | 376 | for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp)) |
377 | { | |
3f045a08 | 378 | if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != (addr->addr_len)) |
3fdb2dd9 | 379 | continue; |
380 | if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len)) | |
381 | { | |
382 | XFREE (MTYPE_ISIS_AREA_ADDR, addr); | |
383 | return CMD_SUCCESS; /* silent fail */ | |
384 | } | |
385 | } | |
f390d2c7 | 386 | } |
3f045a08 | 387 | |
eb5d44eb | 388 | /* |
389 | * Forget the systemID part of the address | |
390 | */ | |
3f045a08 | 391 | addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN); |
eb5d44eb | 392 | listnode_add (area->area_addrs, addr); |
393 | ||
394 | /* only now we can safely generate our LSPs for this area */ | |
f390d2c7 | 395 | if (listcount (area->area_addrs) > 0) |
396 | { | |
3f045a08 JB |
397 | if (area->is_type & IS_LEVEL_1) |
398 | lsp_generate (area, IS_LEVEL_1); | |
399 | if (area->is_type & IS_LEVEL_2) | |
400 | lsp_generate (area, IS_LEVEL_2); | |
f390d2c7 | 401 | } |
eb5d44eb | 402 | |
403 | return CMD_SUCCESS; | |
404 | } | |
405 | ||
406 | int | |
3f045a08 | 407 | area_clear_net_title (struct vty *vty, const char *net_title) |
eb5d44eb | 408 | { |
8ff5a399 | 409 | VTY_DECLVAR_CONTEXT (isis_area, area); |
f390d2c7 | 410 | struct area_addr addr, *addrp = NULL; |
3fdb2dd9 | 411 | struct listnode *node; |
eb5d44eb | 412 | u_char buff[255]; |
413 | ||
eb5d44eb | 414 | addr.addr_len = dotformat2buff (buff, net_title); |
f390d2c7 | 415 | if (addr.addr_len < 8 || addr.addr_len > 20) |
416 | { | |
417 | vty_out (vty, "Unsupported area address length %d, should be 8...20 %s", | |
418 | addr.addr_len, VTY_NEWLINE); | |
3f045a08 | 419 | return CMD_ERR_AMBIGUOUS; |
f390d2c7 | 420 | } |
421 | ||
422 | memcpy (addr.area_addr, buff, (int) addr.addr_len); | |
423 | ||
3fdb2dd9 | 424 | for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp)) |
3f045a08 | 425 | if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len && |
eb5d44eb | 426 | !memcmp (addrp->area_addr, addr.area_addr, addr.addr_len)) |
f390d2c7 | 427 | break; |
428 | ||
429 | if (!addrp) | |
430 | { | |
431 | vty_out (vty, "No area address %s for area %s %s", net_title, | |
432 | area->area_tag, VTY_NEWLINE); | |
3f045a08 | 433 | return CMD_ERR_NO_MATCH; |
f390d2c7 | 434 | } |
435 | ||
eb5d44eb | 436 | listnode_delete (area->area_addrs, addrp); |
3f045a08 JB |
437 | XFREE (MTYPE_ISIS_AREA_ADDR, addrp); |
438 | ||
439 | /* | |
440 | * Last area address - reset the SystemID for this router | |
441 | */ | |
442 | if (listcount (area->area_addrs) == 0) | |
443 | { | |
444 | memset (isis->sysid, 0, ISIS_SYS_ID_LEN); | |
445 | isis->sysid_set = 0; | |
446 | if (isis->debugs & DEBUG_EVENTS) | |
447 | zlog_debug ("Router has no SystemID"); | |
448 | } | |
f390d2c7 | 449 | |
eb5d44eb | 450 | return CMD_SUCCESS; |
451 | } | |
452 | ||
eb5d44eb | 453 | /* |
3f045a08 | 454 | * 'show isis interface' command |
eb5d44eb | 455 | */ |
456 | ||
457 | int | |
3f045a08 | 458 | show_isis_interface_common (struct vty *vty, const char *ifname, char detail) |
eb5d44eb | 459 | { |
3fdb2dd9 | 460 | struct listnode *anode, *cnode; |
eb5d44eb | 461 | struct isis_area *area; |
462 | struct isis_circuit *circuit; | |
eb5d44eb | 463 | |
f390d2c7 | 464 | if (!isis) |
465 | { | |
466 | vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE); | |
467 | return CMD_SUCCESS; | |
468 | } | |
eb5d44eb | 469 | |
3fdb2dd9 | 470 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area)) |
f390d2c7 | 471 | { |
f390d2c7 | 472 | vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE); |
473 | ||
474 | if (detail == ISIS_UI_LEVEL_BRIEF) | |
3f045a08 JB |
475 | vty_out (vty, " Interface CircId State Type Level%s", |
476 | VTY_NEWLINE); | |
f390d2c7 | 477 | |
3fdb2dd9 | 478 | for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit)) |
3f045a08 JB |
479 | if (!ifname) |
480 | isis_circuit_print_vty (circuit, vty, detail); | |
481 | else if (strcmp(circuit->interface->name, ifname) == 0) | |
482 | isis_circuit_print_vty (circuit, vty, detail); | |
eb5d44eb | 483 | } |
f390d2c7 | 484 | |
eb5d44eb | 485 | return CMD_SUCCESS; |
486 | } | |
487 | ||
3f045a08 JB |
488 | DEFUN (show_isis_interface, |
489 | show_isis_interface_cmd, | |
490 | "show isis interface", | |
eb5d44eb | 491 | SHOW_STR |
3f045a08 JB |
492 | "ISIS network information\n" |
493 | "ISIS interface\n") | |
eb5d44eb | 494 | { |
3f045a08 | 495 | return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_BRIEF); |
eb5d44eb | 496 | } |
497 | ||
3f045a08 JB |
498 | DEFUN (show_isis_interface_detail, |
499 | show_isis_interface_detail_cmd, | |
500 | "show isis interface detail", | |
eb5d44eb | 501 | SHOW_STR |
3f045a08 JB |
502 | "ISIS network information\n" |
503 | "ISIS interface\n" | |
504 | "show detailed information\n") | |
505 | { | |
506 | return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_DETAIL); | |
507 | } | |
eb5d44eb | 508 | |
3f045a08 JB |
509 | DEFUN (show_isis_interface_arg, |
510 | show_isis_interface_arg_cmd, | |
511 | "show isis interface WORD", | |
eb5d44eb | 512 | SHOW_STR |
3f045a08 JB |
513 | "ISIS network information\n" |
514 | "ISIS interface\n" | |
515 | "ISIS interface name\n") | |
516 | { | |
ba4c5c83 DW |
517 | int idx_word = 3; |
518 | return show_isis_interface_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL); | |
3f045a08 JB |
519 | } |
520 | ||
521 | /* | |
522 | * 'show isis neighbor' command | |
523 | */ | |
524 | ||
525 | int | |
526 | show_isis_neighbor_common (struct vty *vty, const char *id, char detail) | |
527 | { | |
528 | struct listnode *anode, *cnode, *node; | |
529 | struct isis_area *area; | |
530 | struct isis_circuit *circuit; | |
531 | struct list *adjdb; | |
532 | struct isis_adjacency *adj; | |
533 | struct isis_dynhn *dynhn; | |
534 | u_char sysid[ISIS_SYS_ID_LEN]; | |
535 | int i; | |
536 | ||
537 | if (!isis) | |
538 | { | |
539 | vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE); | |
540 | return CMD_SUCCESS; | |
541 | } | |
542 | ||
543 | memset (sysid, 0, ISIS_SYS_ID_LEN); | |
544 | if (id) | |
545 | { | |
546 | if (sysid2buff (sysid, id) == 0) | |
547 | { | |
548 | dynhn = dynhn_find_by_name (id); | |
549 | if (dynhn == NULL) | |
550 | { | |
551 | vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE); | |
552 | return CMD_SUCCESS; | |
553 | } | |
554 | memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN); | |
555 | } | |
556 | } | |
557 | ||
558 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area)) | |
559 | { | |
560 | vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE); | |
561 | ||
562 | if (detail == ISIS_UI_LEVEL_BRIEF) | |
563 | vty_out (vty, " System Id Interface L State" | |
564 | " Holdtime SNPA%s", VTY_NEWLINE); | |
565 | ||
566 | for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit)) | |
567 | { | |
568 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) | |
569 | { | |
570 | for (i = 0; i < 2; i++) | |
571 | { | |
572 | adjdb = circuit->u.bc.adjdb[i]; | |
573 | if (adjdb && adjdb->count) | |
574 | { | |
575 | for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj)) | |
576 | if (!id || !memcmp (adj->sysid, sysid, | |
577 | ISIS_SYS_ID_LEN)) | |
578 | isis_adj_print_vty (adj, vty, detail); | |
579 | } | |
580 | } | |
581 | } | |
582 | else if (circuit->circ_type == CIRCUIT_T_P2P && | |
583 | circuit->u.p2p.neighbor) | |
584 | { | |
585 | adj = circuit->u.p2p.neighbor; | |
586 | if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN)) | |
587 | isis_adj_print_vty (adj, vty, detail); | |
588 | } | |
589 | } | |
590 | } | |
591 | ||
592 | return CMD_SUCCESS; | |
593 | } | |
594 | ||
595 | /* | |
596 | * 'clear isis neighbor' command | |
597 | */ | |
598 | int | |
599 | clear_isis_neighbor_common (struct vty *vty, const char *id) | |
600 | { | |
601 | struct listnode *anode, *cnode, *cnextnode, *node, *nnode; | |
602 | struct isis_area *area; | |
603 | struct isis_circuit *circuit; | |
604 | struct list *adjdb; | |
605 | struct isis_adjacency *adj; | |
606 | struct isis_dynhn *dynhn; | |
607 | u_char sysid[ISIS_SYS_ID_LEN]; | |
608 | int i; | |
609 | ||
610 | if (!isis) | |
611 | { | |
612 | vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE); | |
613 | return CMD_SUCCESS; | |
614 | } | |
615 | ||
616 | memset (sysid, 0, ISIS_SYS_ID_LEN); | |
617 | if (id) | |
618 | { | |
619 | if (sysid2buff (sysid, id) == 0) | |
620 | { | |
621 | dynhn = dynhn_find_by_name (id); | |
622 | if (dynhn == NULL) | |
623 | { | |
624 | vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE); | |
625 | return CMD_SUCCESS; | |
626 | } | |
627 | memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN); | |
628 | } | |
629 | } | |
630 | ||
631 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area)) | |
632 | { | |
633 | for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnextnode, circuit)) | |
634 | { | |
635 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) | |
636 | { | |
637 | for (i = 0; i < 2; i++) | |
638 | { | |
639 | adjdb = circuit->u.bc.adjdb[i]; | |
640 | if (adjdb && adjdb->count) | |
641 | { | |
642 | for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj)) | |
643 | if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN)) | |
644 | isis_adj_state_change (adj, ISIS_ADJ_DOWN, | |
645 | "clear user request"); | |
646 | } | |
647 | } | |
648 | } | |
649 | else if (circuit->circ_type == CIRCUIT_T_P2P && | |
650 | circuit->u.p2p.neighbor) | |
651 | { | |
652 | adj = circuit->u.p2p.neighbor; | |
653 | if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN)) | |
654 | isis_adj_state_change (adj, ISIS_ADJ_DOWN, | |
655 | "clear user request"); | |
656 | } | |
657 | } | |
658 | } | |
659 | ||
660 | return CMD_SUCCESS; | |
661 | } | |
662 | ||
663 | DEFUN (show_isis_neighbor, | |
664 | show_isis_neighbor_cmd, | |
665 | "show isis neighbor", | |
666 | SHOW_STR | |
667 | "ISIS network information\n" | |
668 | "ISIS neighbor adjacencies\n") | |
eb5d44eb | 669 | { |
3f045a08 | 670 | return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_BRIEF); |
eb5d44eb | 671 | } |
672 | ||
3f045a08 JB |
673 | DEFUN (show_isis_neighbor_detail, |
674 | show_isis_neighbor_detail_cmd, | |
675 | "show isis neighbor detail", | |
eb5d44eb | 676 | SHOW_STR |
3f045a08 JB |
677 | "ISIS network information\n" |
678 | "ISIS neighbor adjacencies\n" | |
eb5d44eb | 679 | "show detailed information\n") |
3f045a08 JB |
680 | { |
681 | return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_DETAIL); | |
682 | } | |
683 | ||
684 | DEFUN (show_isis_neighbor_arg, | |
685 | show_isis_neighbor_arg_cmd, | |
686 | "show isis neighbor WORD", | |
687 | SHOW_STR | |
688 | "ISIS network information\n" | |
689 | "ISIS neighbor adjacencies\n" | |
690 | "System id\n") | |
691 | { | |
ba4c5c83 DW |
692 | int idx_word = 3; |
693 | return show_isis_neighbor_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL); | |
3f045a08 JB |
694 | } |
695 | ||
696 | DEFUN (clear_isis_neighbor, | |
697 | clear_isis_neighbor_cmd, | |
698 | "clear isis neighbor", | |
699 | CLEAR_STR | |
700 | "Reset ISIS network information\n" | |
701 | "Reset ISIS neighbor adjacencies\n") | |
702 | { | |
703 | return clear_isis_neighbor_common (vty, NULL); | |
704 | } | |
705 | ||
706 | DEFUN (clear_isis_neighbor_arg, | |
707 | clear_isis_neighbor_arg_cmd, | |
e38e0df0 | 708 | "clear isis neighbor WORD", |
3f045a08 JB |
709 | CLEAR_STR |
710 | "ISIS network information\n" | |
711 | "ISIS neighbor adjacencies\n" | |
712 | "System id\n") | |
713 | { | |
ba4c5c83 DW |
714 | int idx_word = 3; |
715 | return clear_isis_neighbor_common (vty, argv[idx_word]->arg); | |
3f045a08 JB |
716 | } |
717 | ||
eb5d44eb | 718 | /* |
719 | * 'isis debug', 'show debugging' | |
720 | */ | |
eb5d44eb | 721 | void |
722 | print_debug (struct vty *vty, int flags, int onoff) | |
723 | { | |
724 | char onoffs[4]; | |
725 | if (onoff) | |
f390d2c7 | 726 | strcpy (onoffs, "on"); |
eb5d44eb | 727 | else |
f390d2c7 | 728 | strcpy (onoffs, "off"); |
eb5d44eb | 729 | |
730 | if (flags & DEBUG_ADJ_PACKETS) | |
f390d2c7 | 731 | vty_out (vty, "IS-IS Adjacency related packets debugging is %s%s", onoffs, |
732 | VTY_NEWLINE); | |
eb5d44eb | 733 | if (flags & DEBUG_CHECKSUM_ERRORS) |
f390d2c7 | 734 | vty_out (vty, "IS-IS checksum errors debugging is %s%s", onoffs, |
735 | VTY_NEWLINE); | |
eb5d44eb | 736 | if (flags & DEBUG_LOCAL_UPDATES) |
f390d2c7 | 737 | vty_out (vty, "IS-IS local updates debugging is %s%s", onoffs, |
738 | VTY_NEWLINE); | |
eb5d44eb | 739 | if (flags & DEBUG_PROTOCOL_ERRORS) |
f390d2c7 | 740 | vty_out (vty, "IS-IS protocol errors debugging is %s%s", onoffs, |
741 | VTY_NEWLINE); | |
eb5d44eb | 742 | if (flags & DEBUG_SNP_PACKETS) |
f390d2c7 | 743 | vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s%s", onoffs, |
744 | VTY_NEWLINE); | |
eb5d44eb | 745 | if (flags & DEBUG_SPF_EVENTS) |
f390d2c7 | 746 | vty_out (vty, "IS-IS SPF events debugging is %s%s", onoffs, VTY_NEWLINE); |
eb5d44eb | 747 | if (flags & DEBUG_SPF_STATS) |
f390d2c7 | 748 | vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s%s", |
749 | onoffs, VTY_NEWLINE); | |
eb5d44eb | 750 | if (flags & DEBUG_SPF_TRIGGERS) |
f390d2c7 | 751 | vty_out (vty, "IS-IS SPF triggering events debugging is %s%s", onoffs, |
752 | VTY_NEWLINE); | |
eb5d44eb | 753 | if (flags & DEBUG_UPDATE_PACKETS) |
f390d2c7 | 754 | vty_out (vty, "IS-IS Update related packet debugging is %s%s", onoffs, |
755 | VTY_NEWLINE); | |
eb5d44eb | 756 | if (flags & DEBUG_RTE_EVENTS) |
f390d2c7 | 757 | vty_out (vty, "IS-IS Route related debuggin is %s%s", onoffs, |
758 | VTY_NEWLINE); | |
eb5d44eb | 759 | if (flags & DEBUG_EVENTS) |
f390d2c7 | 760 | vty_out (vty, "IS-IS Event debugging is %s%s", onoffs, VTY_NEWLINE); |
3f045a08 JB |
761 | if (flags & DEBUG_PACKET_DUMP) |
762 | vty_out (vty, "IS-IS Packet dump debugging is %s%s", onoffs, VTY_NEWLINE); | |
14872644 CF |
763 | if (flags & DEBUG_LSP_GEN) |
764 | vty_out (vty, "IS-IS LSP generation debugging is %s%s", onoffs, VTY_NEWLINE); | |
414766a1 CF |
765 | if (flags & DEBUG_LSP_SCHED) |
766 | vty_out (vty, "IS-IS LSP scheduling debugging is %s%s", onoffs, VTY_NEWLINE); | |
eb5d44eb | 767 | } |
768 | ||
769 | DEFUN (show_debugging, | |
f8c06e2c | 770 | show_debugging_isis_cmd, |
16286195 | 771 | "show debugging isis", |
eb5d44eb | 772 | SHOW_STR |
16286195 DS |
773 | "State of each debugging option\n" |
774 | ISIS_STR) | |
eb5d44eb | 775 | { |
f8c06e2c OD |
776 | if (isis->debugs) { |
777 | vty_out (vty, "IS-IS:%s", VTY_NEWLINE); | |
778 | print_debug (vty, isis->debugs, 1); | |
779 | } | |
eb5d44eb | 780 | return CMD_SUCCESS; |
781 | } | |
782 | ||
9e867fe6 | 783 | /* Debug node. */ |
f390d2c7 | 784 | static struct cmd_node debug_node = { |
9e867fe6 | 785 | DEBUG_NODE, |
f390d2c7 | 786 | "", |
787 | 1 | |
9e867fe6 | 788 | }; |
789 | ||
790 | static int | |
791 | config_write_debug (struct vty *vty) | |
792 | { | |
793 | int write = 0; | |
794 | int flags = isis->debugs; | |
795 | ||
f390d2c7 | 796 | if (flags & DEBUG_ADJ_PACKETS) |
797 | { | |
798 | vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE); | |
799 | write++; | |
800 | } | |
801 | if (flags & DEBUG_CHECKSUM_ERRORS) | |
802 | { | |
803 | vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE); | |
804 | write++; | |
805 | } | |
806 | if (flags & DEBUG_LOCAL_UPDATES) | |
807 | { | |
808 | vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE); | |
809 | write++; | |
810 | } | |
811 | if (flags & DEBUG_PROTOCOL_ERRORS) | |
812 | { | |
813 | vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE); | |
814 | write++; | |
815 | } | |
816 | if (flags & DEBUG_SNP_PACKETS) | |
817 | { | |
818 | vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE); | |
819 | write++; | |
820 | } | |
821 | if (flags & DEBUG_SPF_EVENTS) | |
822 | { | |
823 | vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE); | |
824 | write++; | |
825 | } | |
826 | if (flags & DEBUG_SPF_STATS) | |
827 | { | |
828 | vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE); | |
829 | write++; | |
830 | } | |
831 | if (flags & DEBUG_SPF_TRIGGERS) | |
832 | { | |
833 | vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE); | |
834 | write++; | |
835 | } | |
836 | if (flags & DEBUG_UPDATE_PACKETS) | |
837 | { | |
838 | vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE); | |
839 | write++; | |
840 | } | |
841 | if (flags & DEBUG_RTE_EVENTS) | |
842 | { | |
843 | vty_out (vty, "debug isis route-events%s", VTY_NEWLINE); | |
844 | write++; | |
845 | } | |
846 | if (flags & DEBUG_EVENTS) | |
847 | { | |
848 | vty_out (vty, "debug isis events%s", VTY_NEWLINE); | |
849 | write++; | |
850 | } | |
3f045a08 JB |
851 | if (flags & DEBUG_PACKET_DUMP) |
852 | { | |
853 | vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE); | |
854 | write++; | |
855 | } | |
14872644 CF |
856 | if (flags & DEBUG_LSP_GEN) |
857 | { | |
858 | vty_out (vty, "debug isis lsp-gen%s", VTY_NEWLINE); | |
859 | write++; | |
860 | } | |
414766a1 CF |
861 | if (flags & DEBUG_LSP_SCHED) |
862 | { | |
863 | vty_out (vty, "debug isis lsp-sched%s", VTY_NEWLINE); | |
864 | write++; | |
865 | } | |
03f7e182 | 866 | write += spf_backoff_write_config(vty); |
9e867fe6 | 867 | |
868 | return write; | |
869 | } | |
870 | ||
eb5d44eb | 871 | DEFUN (debug_isis_adj, |
872 | debug_isis_adj_cmd, | |
873 | "debug isis adj-packets", | |
874 | DEBUG_STR | |
875 | "IS-IS information\n" | |
f390d2c7 | 876 | "IS-IS Adjacency related packets\n") |
eb5d44eb | 877 | { |
878 | isis->debugs |= DEBUG_ADJ_PACKETS; | |
f390d2c7 | 879 | print_debug (vty, DEBUG_ADJ_PACKETS, 1); |
eb5d44eb | 880 | |
881 | return CMD_SUCCESS; | |
882 | } | |
883 | ||
884 | DEFUN (no_debug_isis_adj, | |
885 | no_debug_isis_adj_cmd, | |
886 | "no debug isis adj-packets", | |
16cedbb0 | 887 | NO_STR |
eb5d44eb | 888 | UNDEBUG_STR |
889 | "IS-IS information\n" | |
f390d2c7 | 890 | "IS-IS Adjacency related packets\n") |
eb5d44eb | 891 | { |
eb5d44eb | 892 | isis->debugs &= ~DEBUG_ADJ_PACKETS; |
893 | print_debug (vty, DEBUG_ADJ_PACKETS, 0); | |
894 | ||
895 | return CMD_SUCCESS; | |
896 | } | |
897 | ||
eb5d44eb | 898 | DEFUN (debug_isis_csum, |
899 | debug_isis_csum_cmd, | |
900 | "debug isis checksum-errors", | |
901 | DEBUG_STR | |
902 | "IS-IS information\n" | |
f390d2c7 | 903 | "IS-IS LSP checksum errors\n") |
eb5d44eb | 904 | { |
905 | isis->debugs |= DEBUG_CHECKSUM_ERRORS; | |
906 | print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1); | |
907 | ||
908 | return CMD_SUCCESS; | |
909 | } | |
910 | ||
911 | DEFUN (no_debug_isis_csum, | |
912 | no_debug_isis_csum_cmd, | |
913 | "no debug isis checksum-errors", | |
16cedbb0 | 914 | NO_STR |
eb5d44eb | 915 | UNDEBUG_STR |
916 | "IS-IS information\n" | |
f390d2c7 | 917 | "IS-IS LSP checksum errors\n") |
eb5d44eb | 918 | { |
919 | isis->debugs &= ~DEBUG_CHECKSUM_ERRORS; | |
920 | print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0); | |
f390d2c7 | 921 | |
eb5d44eb | 922 | return CMD_SUCCESS; |
923 | } | |
924 | ||
925 | DEFUN (debug_isis_lupd, | |
926 | debug_isis_lupd_cmd, | |
927 | "debug isis local-updates", | |
928 | DEBUG_STR | |
929 | "IS-IS information\n" | |
f390d2c7 | 930 | "IS-IS local update packets\n") |
eb5d44eb | 931 | { |
932 | isis->debugs |= DEBUG_LOCAL_UPDATES; | |
933 | print_debug (vty, DEBUG_LOCAL_UPDATES, 1); | |
934 | ||
935 | return CMD_SUCCESS; | |
936 | } | |
937 | ||
938 | DEFUN (no_debug_isis_lupd, | |
939 | no_debug_isis_lupd_cmd, | |
940 | "no debug isis local-updates", | |
16cedbb0 | 941 | NO_STR |
eb5d44eb | 942 | UNDEBUG_STR |
943 | "IS-IS information\n" | |
f390d2c7 | 944 | "IS-IS local update packets\n") |
eb5d44eb | 945 | { |
946 | isis->debugs &= ~DEBUG_LOCAL_UPDATES; | |
f390d2c7 | 947 | print_debug (vty, DEBUG_LOCAL_UPDATES, 0); |
948 | ||
eb5d44eb | 949 | return CMD_SUCCESS; |
950 | } | |
951 | ||
952 | DEFUN (debug_isis_err, | |
953 | debug_isis_err_cmd, | |
f390d2c7 | 954 | "debug isis protocol-errors", |
eb5d44eb | 955 | DEBUG_STR |
956 | "IS-IS information\n" | |
f390d2c7 | 957 | "IS-IS LSP protocol errors\n") |
eb5d44eb | 958 | { |
959 | isis->debugs |= DEBUG_PROTOCOL_ERRORS; | |
960 | print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1); | |
961 | ||
962 | return CMD_SUCCESS; | |
963 | } | |
964 | ||
965 | DEFUN (no_debug_isis_err, | |
966 | no_debug_isis_err_cmd, | |
967 | "no debug isis protocol-errors", | |
16cedbb0 | 968 | NO_STR |
eb5d44eb | 969 | UNDEBUG_STR |
970 | "IS-IS information\n" | |
f390d2c7 | 971 | "IS-IS LSP protocol errors\n") |
eb5d44eb | 972 | { |
973 | isis->debugs &= ~DEBUG_PROTOCOL_ERRORS; | |
974 | print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0); | |
f390d2c7 | 975 | |
eb5d44eb | 976 | return CMD_SUCCESS; |
977 | } | |
978 | ||
979 | DEFUN (debug_isis_snp, | |
980 | debug_isis_snp_cmd, | |
981 | "debug isis snp-packets", | |
982 | DEBUG_STR | |
983 | "IS-IS information\n" | |
f390d2c7 | 984 | "IS-IS CSNP/PSNP packets\n") |
eb5d44eb | 985 | { |
986 | isis->debugs |= DEBUG_SNP_PACKETS; | |
987 | print_debug (vty, DEBUG_SNP_PACKETS, 1); | |
988 | ||
989 | return CMD_SUCCESS; | |
990 | } | |
991 | ||
992 | DEFUN (no_debug_isis_snp, | |
993 | no_debug_isis_snp_cmd, | |
994 | "no debug isis snp-packets", | |
16cedbb0 | 995 | NO_STR |
eb5d44eb | 996 | UNDEBUG_STR |
997 | "IS-IS information\n" | |
f390d2c7 | 998 | "IS-IS CSNP/PSNP packets\n") |
eb5d44eb | 999 | { |
f390d2c7 | 1000 | isis->debugs &= ~DEBUG_SNP_PACKETS; |
eb5d44eb | 1001 | print_debug (vty, DEBUG_SNP_PACKETS, 0); |
f390d2c7 | 1002 | |
eb5d44eb | 1003 | return CMD_SUCCESS; |
1004 | } | |
1005 | ||
eb5d44eb | 1006 | DEFUN (debug_isis_upd, |
1007 | debug_isis_upd_cmd, | |
1008 | "debug isis update-packets", | |
1009 | DEBUG_STR | |
1010 | "IS-IS information\n" | |
f390d2c7 | 1011 | "IS-IS Update related packets\n") |
eb5d44eb | 1012 | { |
1013 | isis->debugs |= DEBUG_UPDATE_PACKETS; | |
1014 | print_debug (vty, DEBUG_UPDATE_PACKETS, 1); | |
1015 | ||
1016 | return CMD_SUCCESS; | |
1017 | } | |
1018 | ||
1019 | DEFUN (no_debug_isis_upd, | |
1020 | no_debug_isis_upd_cmd, | |
1021 | "no debug isis update-packets", | |
16cedbb0 | 1022 | NO_STR |
eb5d44eb | 1023 | UNDEBUG_STR |
1024 | "IS-IS information\n" | |
f390d2c7 | 1025 | "IS-IS Update related packets\n") |
eb5d44eb | 1026 | { |
1027 | isis->debugs &= ~DEBUG_UPDATE_PACKETS; | |
1028 | print_debug (vty, DEBUG_UPDATE_PACKETS, 0); | |
f390d2c7 | 1029 | |
eb5d44eb | 1030 | return CMD_SUCCESS; |
1031 | } | |
1032 | ||
eb5d44eb | 1033 | DEFUN (debug_isis_spfevents, |
1034 | debug_isis_spfevents_cmd, | |
1035 | "debug isis spf-events", | |
1036 | DEBUG_STR | |
1037 | "IS-IS information\n" | |
f390d2c7 | 1038 | "IS-IS Shortest Path First Events\n") |
eb5d44eb | 1039 | { |
1040 | isis->debugs |= DEBUG_SPF_EVENTS; | |
f390d2c7 | 1041 | print_debug (vty, DEBUG_SPF_EVENTS, 1); |
eb5d44eb | 1042 | |
1043 | return CMD_SUCCESS; | |
1044 | } | |
1045 | ||
1046 | DEFUN (no_debug_isis_spfevents, | |
1047 | no_debug_isis_spfevents_cmd, | |
1048 | "no debug isis spf-events", | |
16cedbb0 | 1049 | NO_STR |
eb5d44eb | 1050 | UNDEBUG_STR |
1051 | "IS-IS information\n" | |
f390d2c7 | 1052 | "IS-IS Shortest Path First Events\n") |
eb5d44eb | 1053 | { |
1054 | isis->debugs &= ~DEBUG_SPF_EVENTS; | |
f390d2c7 | 1055 | print_debug (vty, DEBUG_SPF_EVENTS, 0); |
1056 | ||
eb5d44eb | 1057 | return CMD_SUCCESS; |
1058 | } | |
1059 | ||
eb5d44eb | 1060 | DEFUN (debug_isis_spfstats, |
1061 | debug_isis_spfstats_cmd, | |
1062 | "debug isis spf-statistics ", | |
1063 | DEBUG_STR | |
1064 | "IS-IS information\n" | |
f390d2c7 | 1065 | "IS-IS SPF Timing and Statistic Data\n") |
eb5d44eb | 1066 | { |
1067 | isis->debugs |= DEBUG_SPF_STATS; | |
1068 | print_debug (vty, DEBUG_SPF_STATS, 1); | |
1069 | ||
1070 | return CMD_SUCCESS; | |
1071 | } | |
1072 | ||
1073 | DEFUN (no_debug_isis_spfstats, | |
1074 | no_debug_isis_spfstats_cmd, | |
1075 | "no debug isis spf-statistics", | |
16cedbb0 | 1076 | NO_STR |
eb5d44eb | 1077 | UNDEBUG_STR |
1078 | "IS-IS information\n" | |
f390d2c7 | 1079 | "IS-IS SPF Timing and Statistic Data\n") |
eb5d44eb | 1080 | { |
1081 | isis->debugs &= ~DEBUG_SPF_STATS; | |
1082 | print_debug (vty, DEBUG_SPF_STATS, 0); | |
f390d2c7 | 1083 | |
eb5d44eb | 1084 | return CMD_SUCCESS; |
1085 | } | |
1086 | ||
1087 | DEFUN (debug_isis_spftrigg, | |
1088 | debug_isis_spftrigg_cmd, | |
1089 | "debug isis spf-triggers", | |
1090 | DEBUG_STR | |
1091 | "IS-IS information\n" | |
f390d2c7 | 1092 | "IS-IS SPF triggering events\n") |
eb5d44eb | 1093 | { |
1094 | isis->debugs |= DEBUG_SPF_TRIGGERS; | |
1095 | print_debug (vty, DEBUG_SPF_TRIGGERS, 1); | |
1096 | ||
1097 | return CMD_SUCCESS; | |
1098 | } | |
1099 | ||
1100 | DEFUN (no_debug_isis_spftrigg, | |
1101 | no_debug_isis_spftrigg_cmd, | |
1102 | "no debug isis spf-triggers", | |
16cedbb0 | 1103 | NO_STR |
eb5d44eb | 1104 | UNDEBUG_STR |
1105 | "IS-IS information\n" | |
f390d2c7 | 1106 | "IS-IS SPF triggering events\n") |
eb5d44eb | 1107 | { |
1108 | isis->debugs &= ~DEBUG_SPF_TRIGGERS; | |
1109 | print_debug (vty, DEBUG_SPF_TRIGGERS, 0); | |
f390d2c7 | 1110 | |
eb5d44eb | 1111 | return CMD_SUCCESS; |
1112 | } | |
1113 | ||
1114 | DEFUN (debug_isis_rtevents, | |
1115 | debug_isis_rtevents_cmd, | |
1116 | "debug isis route-events", | |
1117 | DEBUG_STR | |
1118 | "IS-IS information\n" | |
f390d2c7 | 1119 | "IS-IS Route related events\n") |
eb5d44eb | 1120 | { |
1121 | isis->debugs |= DEBUG_RTE_EVENTS; | |
1122 | print_debug (vty, DEBUG_RTE_EVENTS, 1); | |
1123 | ||
1124 | return CMD_SUCCESS; | |
1125 | } | |
1126 | ||
1127 | DEFUN (no_debug_isis_rtevents, | |
1128 | no_debug_isis_rtevents_cmd, | |
1129 | "no debug isis route-events", | |
16cedbb0 | 1130 | NO_STR |
eb5d44eb | 1131 | UNDEBUG_STR |
1132 | "IS-IS information\n" | |
f390d2c7 | 1133 | "IS-IS Route related events\n") |
eb5d44eb | 1134 | { |
1135 | isis->debugs &= ~DEBUG_RTE_EVENTS; | |
1136 | print_debug (vty, DEBUG_RTE_EVENTS, 0); | |
f390d2c7 | 1137 | |
eb5d44eb | 1138 | return CMD_SUCCESS; |
1139 | } | |
1140 | ||
1141 | DEFUN (debug_isis_events, | |
1142 | debug_isis_events_cmd, | |
1143 | "debug isis events", | |
1144 | DEBUG_STR | |
1145 | "IS-IS information\n" | |
f1082d19 | 1146 | "IS-IS Events\n") |
eb5d44eb | 1147 | { |
1148 | isis->debugs |= DEBUG_EVENTS; | |
1149 | print_debug (vty, DEBUG_EVENTS, 1); | |
1150 | ||
1151 | return CMD_SUCCESS; | |
1152 | } | |
1153 | ||
1154 | DEFUN (no_debug_isis_events, | |
1155 | no_debug_isis_events_cmd, | |
1156 | "no debug isis events", | |
16cedbb0 | 1157 | NO_STR |
eb5d44eb | 1158 | UNDEBUG_STR |
1159 | "IS-IS information\n" | |
f390d2c7 | 1160 | "IS-IS Events\n") |
eb5d44eb | 1161 | { |
1162 | isis->debugs &= ~DEBUG_EVENTS; | |
1163 | print_debug (vty, DEBUG_EVENTS, 0); | |
f390d2c7 | 1164 | |
eb5d44eb | 1165 | return CMD_SUCCESS; |
1166 | } | |
1167 | ||
3f045a08 JB |
1168 | DEFUN (debug_isis_packet_dump, |
1169 | debug_isis_packet_dump_cmd, | |
1170 | "debug isis packet-dump", | |
1171 | DEBUG_STR | |
1172 | "IS-IS information\n" | |
1173 | "IS-IS packet dump\n") | |
1174 | { | |
1175 | isis->debugs |= DEBUG_PACKET_DUMP; | |
1176 | print_debug (vty, DEBUG_PACKET_DUMP, 1); | |
1177 | ||
1178 | return CMD_SUCCESS; | |
1179 | } | |
1180 | ||
1181 | DEFUN (no_debug_isis_packet_dump, | |
1182 | no_debug_isis_packet_dump_cmd, | |
1183 | "no debug isis packet-dump", | |
16cedbb0 | 1184 | NO_STR |
3f045a08 JB |
1185 | UNDEBUG_STR |
1186 | "IS-IS information\n" | |
1187 | "IS-IS packet dump\n") | |
1188 | { | |
1189 | isis->debugs &= ~DEBUG_PACKET_DUMP; | |
1190 | print_debug (vty, DEBUG_PACKET_DUMP, 0); | |
1191 | ||
1192 | return CMD_SUCCESS; | |
1193 | } | |
1194 | ||
14872644 CF |
1195 | DEFUN (debug_isis_lsp_gen, |
1196 | debug_isis_lsp_gen_cmd, | |
1197 | "debug isis lsp-gen", | |
1198 | DEBUG_STR | |
1199 | "IS-IS information\n" | |
1200 | "IS-IS generation of own LSPs\n") | |
1201 | { | |
1202 | isis->debugs |= DEBUG_LSP_GEN; | |
1203 | print_debug (vty, DEBUG_LSP_GEN, 1); | |
1204 | ||
1205 | return CMD_SUCCESS; | |
1206 | } | |
1207 | ||
1208 | DEFUN (no_debug_isis_lsp_gen, | |
1209 | no_debug_isis_lsp_gen_cmd, | |
1210 | "no debug isis lsp-gen", | |
16cedbb0 | 1211 | NO_STR |
14872644 CF |
1212 | UNDEBUG_STR |
1213 | "IS-IS information\n" | |
1214 | "IS-IS generation of own LSPs\n") | |
1215 | { | |
1216 | isis->debugs &= ~DEBUG_LSP_GEN; | |
1217 | print_debug (vty, DEBUG_LSP_GEN, 0); | |
1218 | ||
1219 | return CMD_SUCCESS; | |
1220 | } | |
1221 | ||
414766a1 CF |
1222 | DEFUN (debug_isis_lsp_sched, |
1223 | debug_isis_lsp_sched_cmd, | |
1224 | "debug isis lsp-sched", | |
1225 | DEBUG_STR | |
1226 | "IS-IS information\n" | |
1227 | "IS-IS scheduling of LSP generation\n") | |
1228 | { | |
1229 | isis->debugs |= DEBUG_LSP_SCHED; | |
1230 | print_debug (vty, DEBUG_LSP_SCHED, 1); | |
1231 | ||
1232 | return CMD_SUCCESS; | |
1233 | } | |
1234 | ||
49d41a26 DS |
1235 | DEFUN (no_debug_isis_lsp_sched, |
1236 | no_debug_isis_lsp_sched_cmd, | |
1237 | "no debug isis lsp-sched", | |
16cedbb0 | 1238 | NO_STR |
49d41a26 DS |
1239 | UNDEBUG_STR |
1240 | "IS-IS information\n" | |
1241 | "IS-IS scheduling of LSP generation\n") | |
1242 | { | |
1243 | isis->debugs &= ~DEBUG_LSP_SCHED; | |
1244 | print_debug (vty, DEBUG_LSP_SCHED, 0); | |
1245 | ||
1246 | return CMD_SUCCESS; | |
1247 | } | |
1248 | ||
eb5d44eb | 1249 | DEFUN (show_hostname, |
1250 | show_hostname_cmd, | |
1251 | "show isis hostname", | |
1252 | SHOW_STR | |
1253 | "IS-IS information\n" | |
1254 | "IS-IS Dynamic hostname mapping\n") | |
1255 | { | |
1256 | dynhn_print_all (vty); | |
f390d2c7 | 1257 | |
eb5d44eb | 1258 | return CMD_SUCCESS; |
1259 | } | |
1260 | ||
3f045a08 JB |
1261 | static void |
1262 | vty_out_timestr(struct vty *vty, time_t uptime) | |
eb5d44eb | 1263 | { |
3f045a08 JB |
1264 | struct tm *tm; |
1265 | time_t difftime = time (NULL); | |
1266 | difftime -= uptime; | |
1267 | tm = gmtime (&difftime); | |
1268 | ||
1269 | #define ONE_DAY_SECOND 60*60*24 | |
1270 | #define ONE_WEEK_SECOND 60*60*24*7 | |
1271 | if (difftime < ONE_DAY_SECOND) | |
1272 | vty_out (vty, "%02d:%02d:%02d", | |
1273 | tm->tm_hour, tm->tm_min, tm->tm_sec); | |
1274 | else if (difftime < ONE_WEEK_SECOND) | |
1275 | vty_out (vty, "%dd%02dh%02dm", | |
1276 | tm->tm_yday, tm->tm_hour, tm->tm_min); | |
1277 | else | |
1278 | vty_out (vty, "%02dw%dd%02dh", | |
1279 | tm->tm_yday/7, | |
1280 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); | |
1281 | vty_out (vty, " ago"); | |
1282 | } | |
1283 | ||
03f7e182 SL |
1284 | DEFUN (show_isis_spf_ietf, |
1285 | show_isis_spf_ietf_cmd, | |
1286 | "show isis spf-delay-ietf", | |
1287 | SHOW_STR | |
1288 | "IS-IS information\n" | |
1289 | "IS-IS SPF delay IETF information\n") | |
1290 | { | |
1291 | if (!isis) | |
1292 | { | |
1293 | vty_out (vty, "ISIS is not running%s", VTY_NEWLINE); | |
1294 | return CMD_SUCCESS; | |
1295 | } | |
1296 | ||
1297 | struct listnode *node; | |
1298 | struct isis_area *area; | |
1299 | ||
1300 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) | |
1301 | { | |
1302 | vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null", | |
1303 | VTY_NEWLINE); | |
1304 | ||
1305 | for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) | |
1306 | { | |
1307 | if ((area->is_type & level) == 0) | |
1308 | continue; | |
1309 | ||
1310 | vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE); | |
1311 | vty_out (vty, " SPF delay status: "); | |
1312 | if (area->spf_timer[level -1]) | |
1313 | { | |
1314 | struct timeval remain = thread_timer_remain(area->spf_timer[level - 1]); | |
1315 | vty_out(vty, "Pending, due in %ld msec%s", | |
1316 | remain.tv_sec * 1000 + remain.tv_usec / 1000, | |
1317 | VTY_NEWLINE); | |
1318 | } | |
1319 | else | |
1320 | { | |
1321 | vty_out(vty, "Not scheduled%s", VTY_NEWLINE); | |
1322 | } | |
1323 | ||
1324 | if (area->spf_delay_ietf[level - 1]) { | |
1325 | vty_out(vty, " Using draft-ietf-rtgwg-backoff-algo-04%s", VTY_NEWLINE); | |
1326 | spf_backoff_show(area->spf_delay_ietf[level - 1], vty, " "); | |
1327 | } else { | |
1328 | vty_out(vty, " Using legacy backoff algo%s", VTY_NEWLINE); | |
1329 | } | |
1330 | } | |
1331 | } | |
1332 | return CMD_SUCCESS; | |
1333 | } | |
1334 | ||
3f045a08 JB |
1335 | DEFUN (show_isis_summary, |
1336 | show_isis_summary_cmd, | |
1337 | "show isis summary", | |
1338 | SHOW_STR "IS-IS information\n" "IS-IS summary\n") | |
1339 | { | |
1340 | struct listnode *node, *node2; | |
eb5d44eb | 1341 | struct isis_area *area; |
3f045a08 JB |
1342 | struct isis_spftree *spftree; |
1343 | int level; | |
eb5d44eb | 1344 | |
3f045a08 JB |
1345 | if (isis == NULL) |
1346 | { | |
1347 | vty_out (vty, "ISIS is not running%s", VTY_NEWLINE); | |
eb5d44eb | 1348 | return CMD_SUCCESS; |
3f045a08 JB |
1349 | } |
1350 | ||
1351 | vty_out (vty, "Process Id : %ld%s", isis->process_id, | |
1352 | VTY_NEWLINE); | |
1353 | if (isis->sysid_set) | |
1354 | vty_out (vty, "System Id : %s%s", sysid_print (isis->sysid), | |
1355 | VTY_NEWLINE); | |
1356 | ||
1357 | vty_out (vty, "Up time : "); | |
1358 | vty_out_timestr(vty, isis->uptime); | |
1359 | vty_out (vty, "%s", VTY_NEWLINE); | |
1360 | ||
1361 | if (isis->area_list) | |
1362 | vty_out (vty, "Number of areas : %d%s", isis->area_list->count, | |
1363 | VTY_NEWLINE); | |
f390d2c7 | 1364 | |
3fdb2dd9 | 1365 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
3f045a08 JB |
1366 | { |
1367 | vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null", | |
1368 | VTY_NEWLINE); | |
1369 | ||
1370 | if (listcount (area->area_addrs) > 0) | |
f390d2c7 | 1371 | { |
3f045a08 JB |
1372 | struct area_addr *area_addr; |
1373 | for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr)) | |
1374 | { | |
1375 | vty_out (vty, " Net: %s%s", | |
1376 | isonet_print (area_addr->area_addr, | |
1377 | area_addr->addr_len + ISIS_SYS_ID_LEN + | |
1378 | 1), VTY_NEWLINE); | |
1379 | } | |
1380 | } | |
f390d2c7 | 1381 | |
3f045a08 JB |
1382 | for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) |
1383 | { | |
1384 | if ((area->is_type & level) == 0) | |
1385 | continue; | |
f390d2c7 | 1386 | |
3f045a08 JB |
1387 | vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE); |
1388 | spftree = area->spftree[level - 1]; | |
5475ecf7 SL |
1389 | if (area->spf_timer[level - 1]) |
1390 | vty_out (vty, " SPF: (pending)%s", VTY_NEWLINE); | |
3f045a08 | 1391 | else |
5475ecf7 | 1392 | vty_out (vty, " SPF:%s", VTY_NEWLINE); |
3f045a08 | 1393 | |
5475ecf7 SL |
1394 | vty_out (vty, " minimum interval : %d", |
1395 | area->min_spf_interval[level - 1]); | |
03f7e182 SL |
1396 | if (area->spf_delay_ietf[level - 1]) |
1397 | vty_out (vty, " (not used, IETF SPF delay activated)"); | |
5475ecf7 | 1398 | vty_out (vty, VTY_NEWLINE); |
3f045a08 | 1399 | |
5475ecf7 | 1400 | vty_out (vty, " IPv4 route computation:%s", VTY_NEWLINE); |
e38e0df0 SV |
1401 | vty_out (vty, " last run elapsed : "); |
1402 | vty_out_timestr(vty, spftree->last_run_timestamp); | |
3f045a08 JB |
1403 | vty_out (vty, "%s", VTY_NEWLINE); |
1404 | ||
e38e0df0 SV |
1405 | vty_out (vty, " last run duration : %u usec%s", |
1406 | (u_int32_t)spftree->last_run_duration, VTY_NEWLINE); | |
1407 | ||
3f045a08 JB |
1408 | vty_out (vty, " run count : %d%s", |
1409 | spftree->runcount, VTY_NEWLINE); | |
1410 | ||
3f045a08 | 1411 | spftree = area->spftree6[level - 1]; |
5475ecf7 | 1412 | vty_out (vty, " IPv6 route computation:%s", VTY_NEWLINE); |
3f045a08 | 1413 | |
e38e0df0 SV |
1414 | vty_out (vty, " last run elapsed : "); |
1415 | vty_out_timestr(vty, spftree->last_run_timestamp); | |
3f045a08 JB |
1416 | vty_out (vty, "%s", VTY_NEWLINE); |
1417 | ||
8f2c16aa DL |
1418 | vty_out (vty, " last run duration : %llu msec%s", |
1419 | (unsigned long long)spftree->last_run_duration, VTY_NEWLINE); | |
e38e0df0 | 1420 | |
3f045a08 JB |
1421 | vty_out (vty, " run count : %d%s", |
1422 | spftree->runcount, VTY_NEWLINE); | |
eb5d44eb | 1423 | } |
3f045a08 JB |
1424 | } |
1425 | vty_out (vty, "%s", VTY_NEWLINE); | |
eb5d44eb | 1426 | |
1427 | return CMD_SUCCESS; | |
1428 | } | |
1429 | ||
3f045a08 JB |
1430 | /* |
1431 | * This function supports following display options: | |
1432 | * [ show isis database [detail] ] | |
1433 | * [ show isis database <sysid> [detail] ] | |
1434 | * [ show isis database <hostname> [detail] ] | |
1435 | * [ show isis database <sysid>.<pseudo-id> [detail] ] | |
1436 | * [ show isis database <hostname>.<pseudo-id> [detail] ] | |
1437 | * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ] | |
1438 | * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ] | |
1439 | * [ show isis database detail <sysid> ] | |
1440 | * [ show isis database detail <hostname> ] | |
1441 | * [ show isis database detail <sysid>.<pseudo-id> ] | |
1442 | * [ show isis database detail <hostname>.<pseudo-id> ] | |
1443 | * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ] | |
1444 | * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ] | |
1445 | */ | |
1446 | static int | |
1447 | show_isis_database (struct vty *vty, const char *argv, int ui_level) | |
eb5d44eb | 1448 | { |
3fdb2dd9 | 1449 | struct listnode *node; |
eb5d44eb | 1450 | struct isis_area *area; |
3f045a08 JB |
1451 | struct isis_lsp *lsp; |
1452 | struct isis_dynhn *dynhn; | |
1453 | const char *pos = argv; | |
1454 | u_char lspid[ISIS_SYS_ID_LEN+2]; | |
e38e0df0 | 1455 | char sysid[255]; |
3f045a08 | 1456 | u_char number[3]; |
eb5d44eb | 1457 | int level, lsp_count; |
1458 | ||
1459 | if (isis->area_list->count == 0) | |
1460 | return CMD_SUCCESS; | |
1461 | ||
3f045a08 | 1462 | memset (&lspid, 0, ISIS_SYS_ID_LEN); |
e38e0df0 | 1463 | memset (&sysid, 0, 255); |
3f045a08 JB |
1464 | |
1465 | /* | |
1466 | * extract fragment and pseudo id from the string argv | |
1467 | * in the forms: | |
1468 | * (a) <systemid/hostname>.<pseudo-id>-<framenent> or | |
1469 | * (b) <systemid/hostname>.<pseudo-id> or | |
1470 | * (c) <systemid/hostname> or | |
1471 | * Where systemid is in the form: | |
1472 | * xxxx.xxxx.xxxx | |
1473 | */ | |
e38e0df0 SV |
1474 | if (argv) |
1475 | strncpy (sysid, argv, 254); | |
3f045a08 JB |
1476 | if (argv && strlen (argv) > 3) |
1477 | { | |
1478 | pos = argv + strlen (argv) - 3; | |
1479 | if (strncmp (pos, "-", 1) == 0) | |
1480 | { | |
1481 | memcpy (number, ++pos, 2); | |
1482 | lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16); | |
1483 | pos -= 4; | |
1484 | if (strncmp (pos, ".", 1) != 0) | |
1485 | return CMD_ERR_AMBIGUOUS; | |
1486 | } | |
1487 | if (strncmp (pos, ".", 1) == 0) | |
1488 | { | |
1489 | memcpy (number, ++pos, 2); | |
1490 | lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16); | |
1491 | sysid[pos - argv - 1] = '\0'; | |
1492 | } | |
1493 | } | |
1494 | ||
3fdb2dd9 | 1495 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
f390d2c7 | 1496 | { |
f390d2c7 | 1497 | vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null", |
3f045a08 | 1498 | VTY_NEWLINE); |
f390d2c7 | 1499 | |
3f045a08 JB |
1500 | for (level = 0; level < ISIS_LEVELS; level++) |
1501 | { | |
1502 | if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0) | |
1503 | { | |
1504 | lsp = NULL; | |
1505 | if (argv != NULL) | |
1506 | { | |
1507 | /* | |
1508 | * Try to find the lsp-id if the argv string is in | |
1509 | * the form hostname.<pseudo-id>-<fragment> | |
1510 | */ | |
1511 | if (sysid2buff (lspid, sysid)) | |
1512 | { | |
1513 | lsp = lsp_search (lspid, area->lspdb[level]); | |
1514 | } | |
1515 | else if ((dynhn = dynhn_find_by_name (sysid))) | |
1516 | { | |
1517 | memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN); | |
1518 | lsp = lsp_search (lspid, area->lspdb[level]); | |
1519 | } | |
1520 | else if (strncmp(unix_hostname (), sysid, 15) == 0) | |
1521 | { | |
1522 | memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN); | |
1523 | lsp = lsp_search (lspid, area->lspdb[level]); | |
1524 | } | |
1525 | } | |
1526 | ||
1527 | if (lsp != NULL || argv == NULL) | |
1528 | { | |
1529 | vty_out (vty, "IS-IS Level-%d link-state database:%s", | |
1530 | level + 1, VTY_NEWLINE); | |
1531 | ||
1532 | /* print the title in all cases */ | |
1533 | vty_out (vty, "LSP ID PduLen " | |
1534 | "SeqNumber Chksum Holdtime ATT/P/OL%s", | |
1535 | VTY_NEWLINE); | |
1536 | } | |
1537 | ||
1538 | if (lsp) | |
1539 | { | |
1540 | if (ui_level == ISIS_UI_LEVEL_DETAIL) | |
1541 | lsp_print_detail (lsp, vty, area->dynhostname); | |
1542 | else | |
1543 | lsp_print (lsp, vty, area->dynhostname); | |
1544 | } | |
1545 | else if (argv == NULL) | |
1546 | { | |
1547 | lsp_count = lsp_print_all (vty, area->lspdb[level], | |
1548 | ui_level, | |
1549 | area->dynhostname); | |
1550 | ||
1551 | vty_out (vty, " %u LSPs%s%s", | |
1552 | lsp_count, VTY_NEWLINE, VTY_NEWLINE); | |
1553 | } | |
1554 | } | |
1555 | } | |
eb5d44eb | 1556 | } |
eb5d44eb | 1557 | |
1558 | return CMD_SUCCESS; | |
1559 | } | |
1560 | ||
3a2d747c | 1561 | DEFUN (show_database, |
3f045a08 | 1562 | show_database_cmd, |
3a2d747c | 1563 | "show isis database [detail] [WORD]", |
3f045a08 JB |
1564 | SHOW_STR |
1565 | "IS-IS information\n" | |
1566 | "IS-IS link state database\n" | |
1567 | "Detailed information\n" | |
1568 | "LSP ID\n") | |
1569 | { | |
3a2d747c QY |
1570 | int idx = 0; |
1571 | int uilevel = argv_find (argv, argc, "detail", &idx) ? ISIS_UI_LEVEL_DETAIL : ISIS_UI_LEVEL_BRIEF; | |
1572 | char *id = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; | |
1573 | return show_isis_database (vty, id, uilevel); | |
3f045a08 JB |
1574 | } |
1575 | ||
1576 | /* | |
1577 | * 'router isis' command | |
1578 | */ | |
505e5056 | 1579 | DEFUN_NOSH (router_isis, |
3f045a08 JB |
1580 | router_isis_cmd, |
1581 | "router isis WORD", | |
1582 | ROUTER_STR | |
1583 | "ISO IS-IS\n" | |
1584 | "ISO Routing area tag") | |
1585 | { | |
ba4c5c83 DW |
1586 | int idx_word = 2; |
1587 | return isis_area_get (vty, argv[idx_word]->arg); | |
3f045a08 JB |
1588 | } |
1589 | ||
1590 | /* | |
1591 | *'no router isis' command | |
1592 | */ | |
1593 | DEFUN (no_router_isis, | |
1594 | no_router_isis_cmd, | |
1595 | "no router isis WORD", | |
f390d2c7 | 1596 | "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag") |
eb5d44eb | 1597 | { |
ba4c5c83 DW |
1598 | int idx_word = 3; |
1599 | return isis_area_destroy (vty, argv[idx_word]->arg); | |
eb5d44eb | 1600 | } |
1601 | ||
1602 | /* | |
1603 | * 'net' command | |
1604 | */ | |
1605 | DEFUN (net, | |
1606 | net_cmd, | |
1607 | "net WORD", | |
1608 | "A Network Entity Title for this process (OSI only)\n" | |
f390d2c7 | 1609 | "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") |
eb5d44eb | 1610 | { |
ba4c5c83 DW |
1611 | int idx_word = 1; |
1612 | return area_net_title (vty, argv[idx_word]->arg); | |
eb5d44eb | 1613 | } |
1614 | ||
eb5d44eb | 1615 | /* |
1616 | * 'no net' command | |
1617 | */ | |
1618 | DEFUN (no_net, | |
1619 | no_net_cmd, | |
1620 | "no net WORD", | |
1621 | NO_STR | |
1622 | "A Network Entity Title for this process (OSI only)\n" | |
f390d2c7 | 1623 | "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") |
eb5d44eb | 1624 | { |
ba4c5c83 DW |
1625 | int idx_word = 2; |
1626 | return area_clear_net_title (vty, argv[idx_word]->arg); | |
eb5d44eb | 1627 | } |
1628 | ||
6754fc66 | 1629 | void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu) |
b20ccb3a | 1630 | { |
b20ccb3a CF |
1631 | area->lsp_mtu = lsp_mtu; |
1632 | lsp_regenerate_schedule(area, IS_LEVEL_1_AND_2, 1); | |
b20ccb3a CF |
1633 | } |
1634 | ||
9093b230 CF |
1635 | static int |
1636 | isis_area_passwd_set(struct isis_area *area, int level, u_char passwd_type, | |
1637 | const char *passwd, u_char snp_auth) | |
3f045a08 | 1638 | { |
9093b230 CF |
1639 | struct isis_passwd *dest; |
1640 | struct isis_passwd modified; | |
3f045a08 JB |
1641 | int len; |
1642 | ||
9093b230 CF |
1643 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); |
1644 | dest = (level == IS_LEVEL_1) ? &area->area_passwd : &area->domain_passwd; | |
1645 | memset(&modified, 0, sizeof(modified)); | |
3f045a08 | 1646 | |
9093b230 | 1647 | if (passwd_type != ISIS_PASSWD_TYPE_UNUSED) |
3f045a08 | 1648 | { |
9093b230 CF |
1649 | if (!passwd) |
1650 | return -1; | |
3f045a08 | 1651 | |
9093b230 CF |
1652 | len = strlen(passwd); |
1653 | if (len > 254) | |
1654 | return -1; | |
f390d2c7 | 1655 | |
9093b230 CF |
1656 | modified.len = len; |
1657 | strncpy((char*)modified.passwd, passwd, 255); | |
1658 | modified.type = passwd_type; | |
1659 | modified.snp_auth = snp_auth; | |
f390d2c7 | 1660 | } |
3f045a08 | 1661 | |
9093b230 | 1662 | if (memcmp(&modified, dest, sizeof(modified))) |
1cbc562b | 1663 | { |
9093b230 CF |
1664 | memcpy(dest, &modified, sizeof(modified)); |
1665 | lsp_regenerate_schedule(area, IS_LEVEL_1|IS_LEVEL_2, 1); | |
1cbc562b | 1666 | } |
1667 | ||
9093b230 | 1668 | return 0; |
eb5d44eb | 1669 | } |
1670 | ||
9093b230 CF |
1671 | int |
1672 | isis_area_passwd_unset (struct isis_area *area, int level) | |
eb5d44eb | 1673 | { |
9093b230 | 1674 | return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_UNUSED, NULL, 0); |
3f045a08 JB |
1675 | } |
1676 | ||
9093b230 CF |
1677 | int |
1678 | isis_area_passwd_cleartext_set (struct isis_area *area, int level, | |
1679 | const char *passwd, u_char snp_auth) | |
eb5d44eb | 1680 | { |
9093b230 CF |
1681 | return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_CLEARTXT, |
1682 | passwd, snp_auth); | |
eb5d44eb | 1683 | } |
1684 | ||
9093b230 CF |
1685 | int |
1686 | isis_area_passwd_hmac_md5_set (struct isis_area *area, int level, | |
1687 | const char *passwd, u_char snp_auth) | |
eb5d44eb | 1688 | { |
9093b230 CF |
1689 | return isis_area_passwd_set (area, level, ISIS_PASSWD_TYPE_HMAC_MD5, |
1690 | passwd, snp_auth); | |
eb5d44eb | 1691 | } |
1692 | ||
6754fc66 CF |
1693 | static void |
1694 | area_resign_level (struct isis_area *area, int level) | |
eb5d44eb | 1695 | { |
6754fc66 | 1696 | if (area->lspdb[level - 1]) |
f390d2c7 | 1697 | { |
6754fc66 CF |
1698 | lsp_db_destroy (area->lspdb[level - 1]); |
1699 | area->lspdb[level - 1] = NULL; | |
f390d2c7 | 1700 | } |
6754fc66 | 1701 | if (area->spftree[level - 1]) |
f390d2c7 | 1702 | { |
6754fc66 CF |
1703 | isis_spftree_del (area->spftree[level - 1]); |
1704 | area->spftree[level - 1] = NULL; | |
f390d2c7 | 1705 | } |
6754fc66 CF |
1706 | if (area->spftree6[level - 1]) |
1707 | { | |
1708 | isis_spftree_del (area->spftree6[level - 1]); | |
1709 | area->spftree6[level - 1] = NULL; | |
1710 | } | |
5475ecf7 | 1711 | THREAD_TIMER_OFF(area->spf_timer[level - 1]); |
6754fc66 CF |
1712 | if (area->route_table[level - 1]) |
1713 | { | |
1714 | route_table_finish (area->route_table[level - 1]); | |
1715 | area->route_table[level - 1] = NULL; | |
1716 | } | |
6754fc66 CF |
1717 | if (area->route_table6[level - 1]) |
1718 | { | |
1719 | route_table_finish (area->route_table6[level - 1]); | |
1720 | area->route_table6[level - 1] = NULL; | |
1721 | } | |
eb5d44eb | 1722 | |
6754fc66 CF |
1723 | sched_debug("ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.", |
1724 | area->area_tag, level); | |
1725 | THREAD_TIMER_OFF (area->t_lsp_refresh[level - 1]); | |
1726 | area->lsp_regenerate_pending[level - 1] = 0; | |
eb5d44eb | 1727 | } |
1728 | ||
6754fc66 CF |
1729 | void |
1730 | isis_area_is_type_set(struct isis_area *area, int is_type) | |
eb5d44eb | 1731 | { |
6754fc66 CF |
1732 | struct listnode *node; |
1733 | struct isis_circuit *circuit; | |
eb5d44eb | 1734 | |
6754fc66 CF |
1735 | if (isis->debugs & DEBUG_EVENTS) |
1736 | zlog_debug ("ISIS-Evt (%s) system type change %s -> %s", area->area_tag, | |
1737 | circuit_t2string (area->is_type), circuit_t2string (is_type)); | |
f390d2c7 | 1738 | |
6754fc66 CF |
1739 | if (area->is_type == is_type) |
1740 | return; /* No change */ | |
eb5d44eb | 1741 | |
6754fc66 CF |
1742 | switch (area->is_type) |
1743 | { | |
1744 | case IS_LEVEL_1: | |
1745 | if (is_type == IS_LEVEL_2) | |
1746 | area_resign_level (area, IS_LEVEL_1); | |
1747 | ||
1748 | if (area->lspdb[1] == NULL) | |
1749 | area->lspdb[1] = lsp_db_init (); | |
1750 | if (area->route_table[1] == NULL) | |
1751 | area->route_table[1] = route_table_init (); | |
6754fc66 CF |
1752 | if (area->route_table6[1] == NULL) |
1753 | area->route_table6[1] = route_table_init (); | |
6754fc66 | 1754 | break; |
eb5d44eb | 1755 | |
6754fc66 CF |
1756 | case IS_LEVEL_1_AND_2: |
1757 | if (is_type == IS_LEVEL_1) | |
1758 | area_resign_level (area, IS_LEVEL_2); | |
1759 | else | |
1760 | area_resign_level (area, IS_LEVEL_1); | |
1761 | break; | |
1762 | ||
1763 | case IS_LEVEL_2: | |
1764 | if (is_type == IS_LEVEL_1) | |
1765 | area_resign_level (area, IS_LEVEL_2); | |
1766 | ||
1767 | if (area->lspdb[0] == NULL) | |
1768 | area->lspdb[0] = lsp_db_init (); | |
1769 | if (area->route_table[0] == NULL) | |
1770 | area->route_table[0] = route_table_init (); | |
6754fc66 CF |
1771 | if (area->route_table6[0] == NULL) |
1772 | area->route_table6[0] = route_table_init (); | |
6754fc66 CF |
1773 | break; |
1774 | ||
1775 | default: | |
1776 | break; | |
1777 | } | |
1778 | ||
1779 | area->is_type = is_type; | |
1780 | ||
1781 | /* override circuit's is_type */ | |
1782 | if (area->is_type != IS_LEVEL_1_AND_2) | |
1783 | { | |
1784 | for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit)) | |
ab1f20e6 | 1785 | isis_circuit_is_type_set (circuit, is_type); |
6754fc66 CF |
1786 | } |
1787 | ||
1788 | spftree_area_init (area); | |
1789 | ||
4fedc05c CF |
1790 | if (listcount (area->area_addrs) > 0) |
1791 | { | |
1792 | if (is_type & IS_LEVEL_1) | |
1793 | lsp_generate (area, IS_LEVEL_1); | |
1794 | if (is_type & IS_LEVEL_2) | |
1795 | lsp_generate (area, IS_LEVEL_2); | |
1796 | } | |
6754fc66 CF |
1797 | lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1); |
1798 | ||
1799 | return; | |
eb5d44eb | 1800 | } |
1801 | ||
a38a72db CF |
1802 | void isis_area_metricstyle_set(struct isis_area *area, bool old_metric, |
1803 | bool new_metric) | |
e38e0df0 | 1804 | { |
a38a72db CF |
1805 | if (area->oldmetric != old_metric |
1806 | || area->newmetric != new_metric) | |
e38e0df0 | 1807 | { |
a38a72db CF |
1808 | area->oldmetric = old_metric; |
1809 | area->newmetric = new_metric; | |
1810 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
e38e0df0 | 1811 | } |
e38e0df0 SV |
1812 | } |
1813 | ||
a38a72db | 1814 | void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit) |
eb5d44eb | 1815 | { |
a38a72db | 1816 | char new_overload_bit = overload_bit ? LSPBIT_OL : 0; |
eb5d44eb | 1817 | |
a38a72db | 1818 | if (new_overload_bit != area->overload_bit) |
2984d26e | 1819 | { |
a38a72db CF |
1820 | area->overload_bit = new_overload_bit; |
1821 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
2984d26e | 1822 | } |
3f045a08 JB |
1823 | } |
1824 | ||
a38a72db | 1825 | void isis_area_attached_bit_set(struct isis_area *area, bool attached_bit) |
3f045a08 | 1826 | { |
a38a72db | 1827 | char new_attached_bit = attached_bit ? LSPBIT_ATT : 0; |
3f045a08 | 1828 | |
a38a72db CF |
1829 | if (new_attached_bit != area->attached_bit) |
1830 | { | |
1831 | area->attached_bit = new_attached_bit; | |
1832 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1); | |
1833 | } | |
eb5d44eb | 1834 | } |
1835 | ||
a38a72db | 1836 | void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname) |
eb5d44eb | 1837 | { |
a38a72db | 1838 | if (area->dynhostname != dynhostname) |
3f045a08 | 1839 | { |
a38a72db CF |
1840 | area->dynhostname = dynhostname; |
1841 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
3f045a08 | 1842 | } |
eb5d44eb | 1843 | } |
1844 | ||
466ed406 CF |
1845 | void |
1846 | isis_area_max_lsp_lifetime_set(struct isis_area *area, int level, | |
1847 | uint16_t max_lsp_lifetime) | |
eb5d44eb | 1848 | { |
466ed406 | 1849 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); |
eb5d44eb | 1850 | |
466ed406 CF |
1851 | if (area->max_lsp_lifetime[level-1] == max_lsp_lifetime) |
1852 | return; | |
3f045a08 | 1853 | |
466ed406 CF |
1854 | area->max_lsp_lifetime[level-1] = max_lsp_lifetime; |
1855 | lsp_regenerate_schedule(area, level, 1); | |
3f045a08 JB |
1856 | } |
1857 | ||
466ed406 CF |
1858 | void |
1859 | isis_area_lsp_refresh_set(struct isis_area *area, int level, | |
1860 | uint16_t lsp_refresh) | |
3f045a08 | 1861 | { |
466ed406 | 1862 | assert((level == IS_LEVEL_1) || (level == IS_LEVEL_2)); |
eb5d44eb | 1863 | |
466ed406 CF |
1864 | if (area->lsp_refresh[level-1] == lsp_refresh) |
1865 | return; | |
eb5d44eb | 1866 | |
466ed406 CF |
1867 | area->lsp_refresh[level-1] = lsp_refresh; |
1868 | lsp_regenerate_schedule(area, level, 1); | |
3f045a08 JB |
1869 | } |
1870 | ||
3f045a08 JB |
1871 | DEFUN (log_adj_changes, |
1872 | log_adj_changes_cmd, | |
1873 | "log-adjacency-changes", | |
1874 | "Log changes in adjacency state\n") | |
1875 | { | |
8ff5a399 | 1876 | VTY_DECLVAR_CONTEXT (isis_area, area); |
eb5d44eb | 1877 | |
3f045a08 | 1878 | area->log_adj_changes = 1; |
eb5d44eb | 1879 | |
1880 | return CMD_SUCCESS; | |
1881 | } | |
1882 | ||
3f045a08 JB |
1883 | DEFUN (no_log_adj_changes, |
1884 | no_log_adj_changes_cmd, | |
1885 | "no log-adjacency-changes", | |
d7fa34c1 | 1886 | NO_STR |
3f045a08 | 1887 | "Stop logging changes in adjacency state\n") |
eb5d44eb | 1888 | { |
8ff5a399 | 1889 | VTY_DECLVAR_CONTEXT (isis_area, area); |
f390d2c7 | 1890 | |
3f045a08 | 1891 | area->log_adj_changes = 0; |
eb5d44eb | 1892 | |
1893 | return CMD_SUCCESS; | |
1894 | } | |
1895 | ||
eb5d44eb | 1896 | /* IS-IS configuration write function */ |
1897 | int | |
1898 | isis_config_write (struct vty *vty) | |
1899 | { | |
1900 | int write = 0; | |
eb5d44eb | 1901 | |
f390d2c7 | 1902 | if (isis != NULL) |
1903 | { | |
1904 | struct isis_area *area; | |
3fdb2dd9 | 1905 | struct listnode *node, *node2; |
f390d2c7 | 1906 | |
3fdb2dd9 | 1907 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
f390d2c7 | 1908 | { |
1909 | /* ISIS - Area name */ | |
1910 | vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE); | |
1911 | write++; | |
1912 | /* ISIS - Net */ | |
1913 | if (listcount (area->area_addrs) > 0) | |
1914 | { | |
1915 | struct area_addr *area_addr; | |
3fdb2dd9 | 1916 | for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr)) |
1917 | { | |
1918 | vty_out (vty, " net %s%s", | |
1919 | isonet_print (area_addr->area_addr, | |
1920 | area_addr->addr_len + ISIS_SYS_ID_LEN + | |
1921 | 1), VTY_NEWLINE); | |
1922 | write++; | |
1923 | } | |
f390d2c7 | 1924 | } |
3fdb2dd9 | 1925 | /* ISIS - Dynamic hostname - Defaults to true so only display if |
1926 | * false. */ | |
f390d2c7 | 1927 | if (!area->dynhostname) |
1928 | { | |
1929 | vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE); | |
1930 | write++; | |
1931 | } | |
e38e0df0 SV |
1932 | /* ISIS - Metric-Style - when true displays wide */ |
1933 | if (area->newmetric) | |
f390d2c7 | 1934 | { |
e38e0df0 SV |
1935 | if (!area->oldmetric) |
1936 | vty_out (vty, " metric-style wide%s", VTY_NEWLINE); | |
2984d26e | 1937 | else |
1938 | vty_out (vty, " metric-style transition%s", VTY_NEWLINE); | |
f390d2c7 | 1939 | write++; |
1940 | } | |
f818c8f3 CF |
1941 | else |
1942 | { | |
1943 | vty_out (vty, " metric-style narrow%s", VTY_NEWLINE); | |
1944 | write++; | |
1945 | } | |
3f045a08 JB |
1946 | /* ISIS - overload-bit */ |
1947 | if (area->overload_bit) | |
1948 | { | |
1949 | vty_out (vty, " set-overload-bit%s", VTY_NEWLINE); | |
1950 | write++; | |
1951 | } | |
f390d2c7 | 1952 | /* ISIS - Area is-type (level-1-2 is default) */ |
1953 | if (area->is_type == IS_LEVEL_1) | |
1954 | { | |
1955 | vty_out (vty, " is-type level-1%s", VTY_NEWLINE); | |
1956 | write++; | |
1957 | } | |
3f045a08 | 1958 | else if (area->is_type == IS_LEVEL_2) |
f390d2c7 | 1959 | { |
3f045a08 JB |
1960 | vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE); |
1961 | write++; | |
f390d2c7 | 1962 | } |
f3ccedaa CF |
1963 | write += isis_redist_config_write(vty, area, AF_INET); |
1964 | write += isis_redist_config_write(vty, area, AF_INET6); | |
f390d2c7 | 1965 | /* ISIS - Lsp generation interval */ |
1966 | if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1]) | |
1967 | { | |
3f045a08 | 1968 | if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL) |
f390d2c7 | 1969 | { |
1970 | vty_out (vty, " lsp-gen-interval %d%s", | |
1971 | area->lsp_gen_interval[0], VTY_NEWLINE); | |
1972 | write++; | |
1973 | } | |
1974 | } | |
1975 | else | |
1976 | { | |
3f045a08 | 1977 | if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL) |
f390d2c7 | 1978 | { |
1979 | vty_out (vty, " lsp-gen-interval level-1 %d%s", | |
1980 | area->lsp_gen_interval[0], VTY_NEWLINE); | |
1981 | write++; | |
1982 | } | |
3f045a08 | 1983 | if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL) |
f390d2c7 | 1984 | { |
1985 | vty_out (vty, " lsp-gen-interval level-2 %d%s", | |
1986 | area->lsp_gen_interval[1], VTY_NEWLINE); | |
1987 | write++; | |
1988 | } | |
1989 | } | |
1990 | /* ISIS - LSP lifetime */ | |
1991 | if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1]) | |
1992 | { | |
3f045a08 | 1993 | if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME) |
f390d2c7 | 1994 | { |
3f045a08 | 1995 | vty_out (vty, " max-lsp-lifetime %u%s", area->max_lsp_lifetime[0], |
f390d2c7 | 1996 | VTY_NEWLINE); |
1997 | write++; | |
1998 | } | |
1999 | } | |
2000 | else | |
2001 | { | |
3f045a08 | 2002 | if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME) |
f390d2c7 | 2003 | { |
3f045a08 | 2004 | vty_out (vty, " max-lsp-lifetime level-1 %u%s", |
f390d2c7 | 2005 | area->max_lsp_lifetime[0], VTY_NEWLINE); |
2006 | write++; | |
2007 | } | |
3f045a08 | 2008 | if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME) |
f390d2c7 | 2009 | { |
3f045a08 | 2010 | vty_out (vty, " max-lsp-lifetime level-2 %u%s", |
f390d2c7 | 2011 | area->max_lsp_lifetime[1], VTY_NEWLINE); |
2012 | write++; | |
2013 | } | |
2014 | } | |
3f045a08 JB |
2015 | /* ISIS - LSP refresh interval */ |
2016 | if (area->lsp_refresh[0] == area->lsp_refresh[1]) | |
2017 | { | |
2018 | if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL) | |
2019 | { | |
2020 | vty_out (vty, " lsp-refresh-interval %u%s", area->lsp_refresh[0], | |
2021 | VTY_NEWLINE); | |
2022 | write++; | |
2023 | } | |
2024 | } | |
2025 | else | |
2026 | { | |
2027 | if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL) | |
2028 | { | |
2029 | vty_out (vty, " lsp-refresh-interval level-1 %u%s", | |
2030 | area->lsp_refresh[0], VTY_NEWLINE); | |
2031 | write++; | |
2032 | } | |
2033 | if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL) | |
2034 | { | |
2035 | vty_out (vty, " lsp-refresh-interval level-2 %u%s", | |
2036 | area->lsp_refresh[1], VTY_NEWLINE); | |
2037 | write++; | |
2038 | } | |
2039 | } | |
b20ccb3a CF |
2040 | if (area->lsp_mtu != DEFAULT_LSP_MTU) |
2041 | { | |
2042 | vty_out(vty, " lsp-mtu %u%s", area->lsp_mtu, VTY_NEWLINE); | |
2043 | write++; | |
2044 | } | |
2045 | ||
13fb40ac | 2046 | /* Minimum SPF interval. */ |
2047 | if (area->min_spf_interval[0] == area->min_spf_interval[1]) | |
2048 | { | |
2049 | if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL) | |
2050 | { | |
2051 | vty_out (vty, " spf-interval %d%s", | |
2052 | area->min_spf_interval[0], VTY_NEWLINE); | |
2053 | write++; | |
2054 | } | |
2055 | } | |
2056 | else | |
2057 | { | |
2058 | if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL) | |
2059 | { | |
2060 | vty_out (vty, " spf-interval level-1 %d%s", | |
2061 | area->min_spf_interval[0], VTY_NEWLINE); | |
2062 | write++; | |
2063 | } | |
2064 | if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL) | |
2065 | { | |
2066 | vty_out (vty, " spf-interval level-2 %d%s", | |
2067 | area->min_spf_interval[1], VTY_NEWLINE); | |
2068 | write++; | |
2069 | } | |
2070 | } | |
03f7e182 SL |
2071 | |
2072 | /* IETF SPF interval */ | |
2073 | if (area->spf_delay_ietf[0]) | |
2074 | { | |
2075 | vty_out (vty, " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld%s", | |
2076 | spf_backoff_init_delay(area->spf_delay_ietf[0]), | |
2077 | spf_backoff_short_delay(area->spf_delay_ietf[0]), | |
2078 | spf_backoff_long_delay(area->spf_delay_ietf[0]), | |
2079 | spf_backoff_holddown(area->spf_delay_ietf[0]), | |
2080 | spf_backoff_timetolearn(area->spf_delay_ietf[0]), | |
2081 | VTY_NEWLINE); | |
2082 | write++; | |
2083 | } | |
2084 | ||
53c997c9 | 2085 | /* Authentication passwords. */ |
3f045a08 | 2086 | if (area->area_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5) |
53c997c9 | 2087 | { |
3f045a08 | 2088 | vty_out(vty, " area-password md5 %s", area->area_passwd.passwd); |
1cbc562b | 2089 | if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND)) |
2090 | { | |
2091 | vty_out(vty, " authenticate snp "); | |
2092 | if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV)) | |
2093 | vty_out(vty, "validate"); | |
2094 | else | |
2095 | vty_out(vty, "send-only"); | |
2096 | } | |
2097 | vty_out(vty, "%s", VTY_NEWLINE); | |
53c997c9 | 2098 | write++; |
3f045a08 JB |
2099 | } |
2100 | else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT) | |
2101 | { | |
2102 | vty_out(vty, " area-password clear %s", area->area_passwd.passwd); | |
2103 | if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND)) | |
2104 | { | |
2105 | vty_out(vty, " authenticate snp "); | |
2106 | if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV)) | |
2107 | vty_out(vty, "validate"); | |
2108 | else | |
2109 | vty_out(vty, "send-only"); | |
2110 | } | |
2111 | vty_out(vty, "%s", VTY_NEWLINE); | |
2112 | write++; | |
2113 | } | |
2114 | if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5) | |
2115 | { | |
2116 | vty_out(vty, " domain-password md5 %s", | |
2117 | area->domain_passwd.passwd); | |
2118 | if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND)) | |
2119 | { | |
2120 | vty_out(vty, " authenticate snp "); | |
2121 | if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV)) | |
2122 | vty_out(vty, "validate"); | |
2123 | else | |
2124 | vty_out(vty, "send-only"); | |
2125 | } | |
2126 | vty_out(vty, "%s", VTY_NEWLINE); | |
2127 | write++; | |
2128 | } | |
2129 | else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT) | |
53c997c9 | 2130 | { |
3f045a08 JB |
2131 | vty_out(vty, " domain-password clear %s", |
2132 | area->domain_passwd.passwd); | |
1cbc562b | 2133 | if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND)) |
2134 | { | |
2135 | vty_out(vty, " authenticate snp "); | |
2136 | if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV)) | |
2137 | vty_out(vty, "validate"); | |
2138 | else | |
2139 | vty_out(vty, "send-only"); | |
2140 | } | |
2141 | vty_out(vty, "%s", VTY_NEWLINE); | |
53c997c9 | 2142 | write++; |
2143 | } | |
f390d2c7 | 2144 | |
3f045a08 JB |
2145 | if (area->log_adj_changes) |
2146 | { | |
2147 | vty_out (vty, " log-adjacency-changes%s", VTY_NEWLINE); | |
2148 | write++; | |
2149 | } | |
2150 | ||
f390d2c7 | 2151 | } |
f8c06e2c | 2152 | isis_mpls_te_config_write_router(vty); |
eb5d44eb | 2153 | } |
f390d2c7 | 2154 | |
eb5d44eb | 2155 | return write; |
2156 | } | |
2157 | ||
3f045a08 | 2158 | struct cmd_node isis_node = { |
eb5d44eb | 2159 | ISIS_NODE, |
2097cd8a | 2160 | "%s(config-router)# ", |
eb5d44eb | 2161 | 1 |
2162 | }; | |
2163 | ||
f390d2c7 | 2164 | void |
eb5d44eb | 2165 | isis_init () |
2166 | { | |
eb5d44eb | 2167 | /* Install IS-IS top node */ |
2168 | install_node (&isis_node, isis_config_write); | |
f390d2c7 | 2169 | |
3f045a08 JB |
2170 | install_element (VIEW_NODE, &show_isis_summary_cmd); |
2171 | ||
03f7e182 SL |
2172 | install_element (VIEW_NODE, &show_isis_spf_ietf_cmd); |
2173 | ||
3f045a08 JB |
2174 | install_element (VIEW_NODE, &show_isis_interface_cmd); |
2175 | install_element (VIEW_NODE, &show_isis_interface_detail_cmd); | |
2176 | install_element (VIEW_NODE, &show_isis_interface_arg_cmd); | |
2177 | ||
2178 | install_element (VIEW_NODE, &show_isis_neighbor_cmd); | |
2179 | install_element (VIEW_NODE, &show_isis_neighbor_detail_cmd); | |
2180 | install_element (VIEW_NODE, &show_isis_neighbor_arg_cmd); | |
2181 | install_element (VIEW_NODE, &clear_isis_neighbor_cmd); | |
2182 | install_element (VIEW_NODE, &clear_isis_neighbor_arg_cmd); | |
eb5d44eb | 2183 | |
2184 | install_element (VIEW_NODE, &show_hostname_cmd); | |
2185 | install_element (VIEW_NODE, &show_database_cmd); | |
3f045a08 | 2186 | |
f8c06e2c | 2187 | install_element (ENABLE_NODE, &show_debugging_isis_cmd); |
eb5d44eb | 2188 | |
f390d2c7 | 2189 | install_node (&debug_node, config_write_debug); |
9e867fe6 | 2190 | |
eb5d44eb | 2191 | install_element (ENABLE_NODE, &debug_isis_adj_cmd); |
2192 | install_element (ENABLE_NODE, &no_debug_isis_adj_cmd); | |
2193 | install_element (ENABLE_NODE, &debug_isis_csum_cmd); | |
2194 | install_element (ENABLE_NODE, &no_debug_isis_csum_cmd); | |
2195 | install_element (ENABLE_NODE, &debug_isis_lupd_cmd); | |
2196 | install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd); | |
2197 | install_element (ENABLE_NODE, &debug_isis_err_cmd); | |
2198 | install_element (ENABLE_NODE, &no_debug_isis_err_cmd); | |
2199 | install_element (ENABLE_NODE, &debug_isis_snp_cmd); | |
2200 | install_element (ENABLE_NODE, &no_debug_isis_snp_cmd); | |
2201 | install_element (ENABLE_NODE, &debug_isis_upd_cmd); | |
2202 | install_element (ENABLE_NODE, &no_debug_isis_upd_cmd); | |
2203 | install_element (ENABLE_NODE, &debug_isis_spfevents_cmd); | |
2204 | install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd); | |
2205 | install_element (ENABLE_NODE, &debug_isis_spfstats_cmd); | |
2206 | install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd); | |
2207 | install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd); | |
2208 | install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd); | |
2209 | install_element (ENABLE_NODE, &debug_isis_rtevents_cmd); | |
2210 | install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd); | |
2211 | install_element (ENABLE_NODE, &debug_isis_events_cmd); | |
2212 | install_element (ENABLE_NODE, &no_debug_isis_events_cmd); | |
3f045a08 JB |
2213 | install_element (ENABLE_NODE, &debug_isis_packet_dump_cmd); |
2214 | install_element (ENABLE_NODE, &no_debug_isis_packet_dump_cmd); | |
14872644 CF |
2215 | install_element (ENABLE_NODE, &debug_isis_lsp_gen_cmd); |
2216 | install_element (ENABLE_NODE, &no_debug_isis_lsp_gen_cmd); | |
414766a1 CF |
2217 | install_element (ENABLE_NODE, &debug_isis_lsp_sched_cmd); |
2218 | install_element (ENABLE_NODE, &no_debug_isis_lsp_sched_cmd); | |
eb5d44eb | 2219 | |
9e867fe6 | 2220 | install_element (CONFIG_NODE, &debug_isis_adj_cmd); |
2221 | install_element (CONFIG_NODE, &no_debug_isis_adj_cmd); | |
2222 | install_element (CONFIG_NODE, &debug_isis_csum_cmd); | |
2223 | install_element (CONFIG_NODE, &no_debug_isis_csum_cmd); | |
2224 | install_element (CONFIG_NODE, &debug_isis_lupd_cmd); | |
2225 | install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd); | |
2226 | install_element (CONFIG_NODE, &debug_isis_err_cmd); | |
2227 | install_element (CONFIG_NODE, &no_debug_isis_err_cmd); | |
2228 | install_element (CONFIG_NODE, &debug_isis_snp_cmd); | |
2229 | install_element (CONFIG_NODE, &no_debug_isis_snp_cmd); | |
2230 | install_element (CONFIG_NODE, &debug_isis_upd_cmd); | |
2231 | install_element (CONFIG_NODE, &no_debug_isis_upd_cmd); | |
2232 | install_element (CONFIG_NODE, &debug_isis_spfevents_cmd); | |
2233 | install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd); | |
2234 | install_element (CONFIG_NODE, &debug_isis_spfstats_cmd); | |
2235 | install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd); | |
2236 | install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd); | |
2237 | install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd); | |
2238 | install_element (CONFIG_NODE, &debug_isis_rtevents_cmd); | |
2239 | install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd); | |
2240 | install_element (CONFIG_NODE, &debug_isis_events_cmd); | |
2241 | install_element (CONFIG_NODE, &no_debug_isis_events_cmd); | |
3f045a08 JB |
2242 | install_element (CONFIG_NODE, &debug_isis_packet_dump_cmd); |
2243 | install_element (CONFIG_NODE, &no_debug_isis_packet_dump_cmd); | |
14872644 CF |
2244 | install_element (CONFIG_NODE, &debug_isis_lsp_gen_cmd); |
2245 | install_element (CONFIG_NODE, &no_debug_isis_lsp_gen_cmd); | |
414766a1 CF |
2246 | install_element (CONFIG_NODE, &debug_isis_lsp_sched_cmd); |
2247 | install_element (CONFIG_NODE, &no_debug_isis_lsp_sched_cmd); | |
9e867fe6 | 2248 | |
eb5d44eb | 2249 | install_element (CONFIG_NODE, &router_isis_cmd); |
2250 | install_element (CONFIG_NODE, &no_router_isis_cmd); | |
2251 | ||
2252 | install_default (ISIS_NODE); | |
2253 | ||
2254 | install_element (ISIS_NODE, &net_cmd); | |
2255 | install_element (ISIS_NODE, &no_net_cmd); | |
2256 | ||
3f045a08 JB |
2257 | install_element (ISIS_NODE, &log_adj_changes_cmd); |
2258 | install_element (ISIS_NODE, &no_log_adj_changes_cmd); | |
03f7e182 SL |
2259 | |
2260 | spf_backoff_cmd_init(); | |
eb5d44eb | 2261 | } |