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