Line data Source code
1 : /*
2 : * Copyright (C) 2003 Yasuhiro Ohara
3 : *
4 : * This file is part of GNU Zebra.
5 : *
6 : * GNU Zebra is free software; you can redistribute it and/or modify it
7 : * under the terms of the GNU General Public License as published by the
8 : * Free Software Foundation; either version 2, or (at your option) any
9 : * later version.
10 : *
11 : * GNU Zebra is distributed in the hope that it will be useful, but
12 : * WITHOUT ANY WARRANTY; without even the implied warranty of
13 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 : * General Public License for more details.
15 : *
16 : * You should have received a copy of the GNU General Public License along
17 : * with this program; see the file COPYING; if not, write to the Free Software
18 : * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 : */
20 :
21 : #include <zebra.h>
22 :
23 : #include "thread.h"
24 : #include "linklist.h"
25 : #include "vty.h"
26 : #include "command.h"
27 : #include "plist.h"
28 : #include "filter.h"
29 :
30 : #include "ospf6_proto.h"
31 : #include "ospf6_top.h"
32 : #include "ospf6_network.h"
33 : #include "ospf6_lsa.h"
34 : #include "ospf6_lsdb.h"
35 : #include "ospf6_message.h"
36 : #include "ospf6_route.h"
37 : #include "ospf6_zebra.h"
38 : #include "ospf6_spf.h"
39 : #include "ospf6_area.h"
40 : #include "ospf6_interface.h"
41 : #include "ospf6_neighbor.h"
42 : #include "ospf6_intra.h"
43 : #include "ospf6_asbr.h"
44 : #include "ospf6_abr.h"
45 : #include "ospf6_flood.h"
46 : #include "ospf6d.h"
47 : #include "ospf6_bfd.h"
48 : #include "ospf6_gr.h"
49 : #include "lib/json.h"
50 : #include "ospf6_nssa.h"
51 : #include "ospf6_auth_trailer.h"
52 : #include "ospf6_vlink.h"
53 :
54 12 : DEFINE_MGROUP(OSPF6D, "ospf6d");
55 :
56 256 : struct route_node *route_prev(struct route_node *node)
57 : {
58 256 : struct route_node *end;
59 256 : struct route_node *prev = NULL;
60 :
61 256 : end = node;
62 256 : node = node->parent;
63 256 : if (node)
64 141 : route_lock_node(node);
65 352 : while (node) {
66 237 : prev = node;
67 237 : node = route_next(node);
68 237 : if (node == end) {
69 141 : route_unlock_node(node);
70 141 : node = NULL;
71 : }
72 : }
73 256 : route_unlock_node(end);
74 256 : if (prev)
75 141 : route_lock_node(prev);
76 :
77 256 : return prev;
78 : }
79 :
80 : static int config_write_ospf6_debug(struct vty *vty);
81 : static struct cmd_node debug_node = {
82 : .name = "debug",
83 : .node = DEBUG_NODE,
84 : .prompt = "",
85 : .config_write = config_write_ospf6_debug,
86 : };
87 :
88 0 : static int config_write_ospf6_debug(struct vty *vty)
89 : {
90 0 : config_write_ospf6_debug_message(vty);
91 0 : config_write_ospf6_debug_lsa(vty);
92 0 : config_write_ospf6_debug_zebra(vty);
93 0 : config_write_ospf6_debug_interface(vty);
94 0 : config_write_ospf6_debug_neighbor(vty);
95 0 : config_write_ospf6_debug_spf(vty);
96 0 : config_write_ospf6_debug_route(vty);
97 0 : config_write_ospf6_debug_brouter(vty);
98 0 : config_write_ospf6_debug_asbr(vty);
99 0 : config_write_ospf6_debug_abr(vty);
100 0 : config_write_ospf6_debug_flood(vty);
101 0 : config_write_ospf6_debug_nssa(vty);
102 0 : config_write_ospf6_debug_gr_helper(vty);
103 0 : config_write_ospf6_debug_auth(vty);
104 0 : config_write_ospf6_debug_vlink(vty);
105 :
106 0 : return 0;
107 : }
108 :
109 0 : DEFUN_NOSH (show_debugging_ospf6,
110 : show_debugging_ospf6_cmd,
111 : "show debugging [ospf6]",
112 : SHOW_STR
113 : DEBUG_STR
114 : OSPF6_STR)
115 : {
116 0 : vty_out(vty, "OSPF6 debugging status:\n");
117 :
118 0 : config_write_ospf6_debug(vty);
119 :
120 0 : cmd_show_lib_debugs(vty);
121 :
122 0 : return CMD_SUCCESS;
123 : }
124 :
125 : #define AREA_LSDB_TITLE_FORMAT \
126 : "\n Area Scoped Link State Database (Area %s)\n\n"
127 : #define IF_LSDB_TITLE_FORMAT \
128 : "\n I/F Scoped Link State Database (I/F %pOI in Area %s)\n\n"
129 : #define AS_LSDB_TITLE_FORMAT "\n AS Scoped Link State Database\n\n"
130 :
131 73 : static int parse_show_level(int idx_level, int argc, struct cmd_token **argv)
132 : {
133 73 : int level = OSPF6_LSDB_SHOW_LEVEL_NORMAL;
134 :
135 73 : if (argc > idx_level) {
136 73 : if (strmatch(argv[idx_level]->text, "detail"))
137 : level = OSPF6_LSDB_SHOW_LEVEL_DETAIL;
138 0 : else if (strmatch(argv[idx_level]->text, "dump"))
139 : level = OSPF6_LSDB_SHOW_LEVEL_DUMP;
140 0 : else if (strmatch(argv[idx_level]->text, "internal"))
141 73 : level = OSPF6_LSDB_SHOW_LEVEL_INTERNAL;
142 : }
143 :
144 73 : return level;
145 : }
146 :
147 0 : static uint16_t parse_type_spec(int idx_lsa, int argc, struct cmd_token **argv)
148 : {
149 0 : uint16_t type = 0;
150 :
151 0 : if (argc > idx_lsa) {
152 0 : if (strmatch(argv[idx_lsa]->text, "router"))
153 : type = htons(OSPF6_LSTYPE_ROUTER);
154 0 : else if (strmatch(argv[idx_lsa]->text, "network"))
155 : type = htons(OSPF6_LSTYPE_NETWORK);
156 0 : else if (strmatch(argv[idx_lsa]->text, "as-external"))
157 : type = htons(OSPF6_LSTYPE_AS_EXTERNAL);
158 0 : else if (strmatch(argv[idx_lsa]->text, "intra-prefix"))
159 : type = htons(OSPF6_LSTYPE_INTRA_PREFIX);
160 0 : else if (strmatch(argv[idx_lsa]->text, "inter-router"))
161 : type = htons(OSPF6_LSTYPE_INTER_ROUTER);
162 0 : else if (strmatch(argv[idx_lsa]->text, "inter-prefix"))
163 : type = htons(OSPF6_LSTYPE_INTER_PREFIX);
164 0 : else if (strmatch(argv[idx_lsa]->text, "link"))
165 : type = htons(OSPF6_LSTYPE_LINK);
166 0 : else if (strmatch(argv[idx_lsa]->text, "type-7"))
167 0 : type = htons(OSPF6_LSTYPE_TYPE_7);
168 : }
169 :
170 0 : return type;
171 : }
172 :
173 222 : void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level,
174 : uint16_t *type, uint32_t *id, uint32_t *adv_router,
175 : struct ospf6_lsdb *lsdb, json_object *json_obj,
176 : bool use_json)
177 : {
178 222 : struct ospf6_lsa *lsa;
179 222 : const struct route_node *end = NULL;
180 222 : void (*showfunc)(struct vty *, struct ospf6_lsa *, json_object *,
181 : bool) = NULL;
182 222 : json_object *json_array = NULL;
183 :
184 222 : switch (level) {
185 : case OSPF6_LSDB_SHOW_LEVEL_DETAIL:
186 : showfunc = ospf6_lsa_show;
187 : break;
188 0 : case OSPF6_LSDB_SHOW_LEVEL_INTERNAL:
189 0 : showfunc = ospf6_lsa_show_internal;
190 0 : break;
191 0 : case OSPF6_LSDB_SHOW_LEVEL_DUMP:
192 0 : showfunc = ospf6_lsa_show_dump;
193 0 : break;
194 0 : case OSPF6_LSDB_SHOW_LEVEL_NORMAL:
195 : default:
196 0 : showfunc = ospf6_lsa_show_summary;
197 : }
198 :
199 222 : if (use_json)
200 222 : json_array = json_object_new_array();
201 :
202 222 : if (type && id && adv_router) {
203 0 : lsa = ospf6_lsdb_lookup(*type, *id, *adv_router, lsdb);
204 0 : if (lsa) {
205 0 : if (level == OSPF6_LSDB_SHOW_LEVEL_NORMAL)
206 0 : ospf6_lsa_show(vty, lsa, json_array, use_json);
207 : else
208 0 : (*showfunc)(vty, lsa, json_array, use_json);
209 : }
210 :
211 0 : if (use_json)
212 0 : json_object_object_add(json_obj, "lsa", json_array);
213 0 : return;
214 : }
215 :
216 222 : if ((level == OSPF6_LSDB_SHOW_LEVEL_NORMAL) && !use_json)
217 0 : ospf6_lsa_show_summary_header(vty);
218 :
219 222 : end = ospf6_lsdb_head(lsdb, !!type + !!(type && adv_router),
220 0 : type ? *type : 0, adv_router ? *adv_router : 0,
221 : &lsa);
222 1028 : while (lsa) {
223 806 : if ((!adv_router || lsa->header->adv_router == *adv_router)
224 806 : && (!id || lsa->header->id == *id))
225 806 : (*showfunc)(vty, lsa, json_array, use_json);
226 806 : lsa = ospf6_lsdb_next(end, lsa);
227 : }
228 :
229 222 : if (use_json)
230 222 : json_object_object_add(json_obj, "lsa", json_array);
231 : }
232 :
233 73 : static void ospf6_lsdb_show_wrapper(struct vty *vty,
234 : enum ospf_lsdb_show_level level,
235 : uint16_t *type, uint32_t *id,
236 : uint32_t *adv_router, bool uj,
237 : struct ospf6 *ospf6)
238 : {
239 73 : struct listnode *i, *j;
240 73 : struct ospf6 *o = ospf6;
241 73 : struct ospf6_area *oa;
242 73 : struct ospf6_interface *oi;
243 73 : json_object *json = NULL;
244 73 : json_object *json_array = NULL;
245 73 : json_object *json_obj = NULL;
246 :
247 73 : if (uj) {
248 73 : json = json_object_new_object();
249 73 : json_array = json_object_new_array();
250 : }
251 219 : for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
252 73 : if (uj) {
253 73 : json_obj = json_object_new_object();
254 73 : json_object_string_add(json_obj, "areaId", oa->name);
255 : } else
256 0 : vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
257 73 : ospf6_lsdb_show(vty, level, type, id, adv_router, oa->lsdb,
258 : json_obj, uj);
259 73 : if (uj)
260 73 : json_object_array_add(json_array, json_obj);
261 : }
262 73 : if (uj)
263 73 : json_object_object_add(json, "areaScopedLinkStateDb",
264 : json_array);
265 :
266 73 : if (uj)
267 73 : json_array = json_object_new_array();
268 219 : for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
269 222 : for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
270 76 : if (!oi->lsdb)
271 0 : continue;
272 :
273 76 : if (uj) {
274 76 : json_obj = json_object_new_object();
275 76 : json_object_string_add(json_obj, "areaId",
276 76 : oa->name);
277 152 : json_object_string_add(json_obj, "interface",
278 : ospf6_ifname(oi));
279 : } else
280 0 : vty_out(vty, IF_LSDB_TITLE_FORMAT, oi,
281 0 : oa->name);
282 76 : ospf6_lsdb_show(vty, level, type, id, adv_router,
283 : oi->lsdb, json_obj, uj);
284 76 : if (uj)
285 76 : json_object_array_add(json_array, json_obj);
286 : }
287 : }
288 73 : if (uj)
289 73 : json_object_object_add(json, "interfaceScopedLinkStateDb",
290 : json_array);
291 73 : if (uj) {
292 73 : json_array = json_object_new_array();
293 73 : json_obj = json_object_new_object();
294 : } else
295 0 : vty_out(vty, AS_LSDB_TITLE_FORMAT);
296 :
297 73 : ospf6_lsdb_show(vty, level, type, id, adv_router, o->lsdb, json_obj,
298 : uj);
299 :
300 73 : if (uj) {
301 73 : json_object_array_add(json_array, json_obj);
302 73 : json_object_object_add(json, "asScopedLinkStateDb", json_array);
303 :
304 73 : vty_json(vty, json);
305 : } else
306 0 : vty_out(vty, "\n");
307 73 : }
308 :
309 0 : static void ospf6_lsdb_type_show_wrapper(struct vty *vty,
310 : enum ospf_lsdb_show_level level,
311 : uint16_t *type, uint32_t *id,
312 : uint32_t *adv_router, bool uj,
313 : struct ospf6 *ospf6)
314 : {
315 0 : struct listnode *i, *j;
316 0 : struct ospf6 *o = ospf6;
317 0 : struct ospf6_area *oa;
318 0 : struct ospf6_interface *oi;
319 0 : json_object *json = NULL;
320 0 : json_object *json_array = NULL;
321 0 : json_object *json_obj = NULL;
322 :
323 0 : if (uj) {
324 0 : json = json_object_new_object();
325 0 : json_array = json_object_new_array();
326 : }
327 :
328 0 : switch (OSPF6_LSA_SCOPE(*type)) {
329 0 : case OSPF6_SCOPE_AREA:
330 0 : for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
331 0 : if (uj) {
332 0 : json_obj = json_object_new_object();
333 0 : json_object_string_add(json_obj, "areaId",
334 0 : oa->name);
335 : } else
336 0 : vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
337 :
338 0 : ospf6_lsdb_show(vty, level, type, id, adv_router,
339 : oa->lsdb, json_obj, uj);
340 0 : if (uj)
341 0 : json_object_array_add(json_array, json_obj);
342 : }
343 0 : if (uj)
344 0 : json_object_object_add(json, "areaScopedLinkStateDb",
345 : json_array);
346 : break;
347 :
348 0 : case OSPF6_SCOPE_LINKLOCAL:
349 0 : for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
350 0 : for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
351 0 : if (!oi->lsdb)
352 0 : continue;
353 :
354 0 : if (uj) {
355 0 : json_obj = json_object_new_object();
356 0 : json_object_string_add(
357 0 : json_obj, "areaId", oa->name);
358 0 : json_object_string_add(
359 : json_obj, "interface",
360 : ospf6_ifname(oi));
361 : } else
362 0 : vty_out(vty, IF_LSDB_TITLE_FORMAT, oi,
363 0 : oa->name);
364 :
365 0 : ospf6_lsdb_show(vty, level, type, id,
366 : adv_router, oi->lsdb, json_obj,
367 : uj);
368 :
369 0 : if (uj)
370 0 : json_object_array_add(json_array,
371 : json_obj);
372 : }
373 : }
374 0 : if (uj)
375 0 : json_object_object_add(
376 : json, "interfaceScopedLinkStateDb", json_array);
377 : break;
378 :
379 0 : case OSPF6_SCOPE_AS:
380 0 : if (uj)
381 0 : json_obj = json_object_new_object();
382 : else
383 0 : vty_out(vty, AS_LSDB_TITLE_FORMAT);
384 :
385 0 : ospf6_lsdb_show(vty, level, type, id, adv_router, o->lsdb,
386 : json_obj, uj);
387 0 : if (uj) {
388 0 : json_object_array_add(json_array, json_obj);
389 0 : json_object_object_add(json, "asScopedLinkStateDb",
390 : json_array);
391 : }
392 : break;
393 :
394 : default:
395 0 : assert(0);
396 : break;
397 : }
398 0 : if (uj)
399 0 : vty_json(vty, json);
400 : else
401 0 : vty_out(vty, "\n");
402 0 : }
403 :
404 73 : DEFUN(show_ipv6_ospf6_database, show_ipv6_ospf6_database_cmd,
405 : "show ipv6 ospf6 [vrf <NAME|all>] database [<detail|dump|internal>] [json]",
406 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
407 : "All VRFs\n"
408 : "Display Link state database\n"
409 : "Display details of LSAs\n"
410 : "Dump LSAs\n"
411 : "Display LSA's internal information\n" JSON_STR)
412 : {
413 73 : int level;
414 73 : int idx_level = 4;
415 73 : struct listnode *node;
416 73 : struct ospf6 *ospf6;
417 73 : const char *vrf_name = NULL;
418 73 : bool all_vrf = false;
419 73 : int idx_vrf = 0;
420 73 : bool uj = use_json(argc, argv);
421 :
422 73 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
423 73 : if (idx_vrf > 0)
424 0 : idx_level += 2;
425 :
426 73 : level = parse_show_level(idx_level, argc, argv);
427 146 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
428 73 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
429 73 : ospf6_lsdb_show_wrapper(vty, level, NULL, NULL, NULL,
430 : uj, ospf6);
431 73 : if (!all_vrf)
432 : break;
433 : }
434 : }
435 :
436 73 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
437 :
438 : return CMD_SUCCESS;
439 : }
440 :
441 0 : DEFUN(show_ipv6_ospf6_database_type, show_ipv6_ospf6_database_type_cmd,
442 : "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> [<detail|dump|internal>] [json]",
443 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
444 : "All VRFs\n"
445 : "Display Link state database\n"
446 : "Display Router LSAs\n"
447 : "Display Network LSAs\n"
448 : "Display Inter-Area-Prefix LSAs\n"
449 : "Display Inter-Area-Router LSAs\n"
450 : "Display As-External LSAs\n"
451 : "Display Group-Membership LSAs\n"
452 : "Display Type-7 LSAs\n"
453 : "Display Link LSAs\n"
454 : "Display Intra-Area-Prefix LSAs\n"
455 : "Display details of LSAs\n"
456 : "Dump LSAs\n"
457 : "Display LSA's internal information\n" JSON_STR)
458 : {
459 0 : int idx_lsa = 4;
460 0 : int idx_level = 5;
461 0 : int level;
462 0 : bool uj = use_json(argc, argv);
463 0 : struct listnode *node;
464 0 : struct ospf6 *ospf6;
465 0 : uint16_t type = 0;
466 0 : const char *vrf_name = NULL;
467 0 : bool all_vrf = false;
468 0 : int idx_vrf = 0;
469 :
470 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
471 0 : if (idx_vrf > 0) {
472 0 : idx_lsa += 2;
473 0 : idx_level += 2;
474 : }
475 :
476 0 : type = parse_type_spec(idx_lsa, argc, argv);
477 0 : level = parse_show_level(idx_level, argc, argv);
478 :
479 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
480 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
481 0 : ospf6_lsdb_type_show_wrapper(vty, level, &type, NULL,
482 : NULL, uj, ospf6);
483 0 : if (!all_vrf)
484 : break;
485 : }
486 : }
487 :
488 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
489 :
490 : return CMD_SUCCESS;
491 : }
492 :
493 0 : DEFUN(show_ipv6_ospf6_database_id, show_ipv6_ospf6_database_id_cmd,
494 : "show ipv6 ospf6 [vrf <NAME|all>] database <*|linkstate-id> A.B.C.D [<detail|dump|internal>] [json]",
495 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
496 : "All VRFs\n"
497 : "Display Link state database\n"
498 : "Any Link state Type\n"
499 : "Search by Link state ID\n"
500 : "Specify Link state ID as IPv4 address notation\n"
501 : "Display details of LSAs\n"
502 : "Dump LSAs\n"
503 : "Display LSA's internal information\n" JSON_STR)
504 : {
505 0 : int idx_ipv4 = 5;
506 0 : int idx_level = 6;
507 0 : int level;
508 0 : bool uj = use_json(argc, argv);
509 0 : struct listnode *node;
510 0 : struct ospf6 *ospf6;
511 0 : uint32_t id = 0;
512 0 : const char *vrf_name = NULL;
513 0 : bool all_vrf = false;
514 0 : int idx_vrf = 0;
515 :
516 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
517 0 : if (argv[idx_ipv4]->type == IPV4_TKN)
518 0 : inet_pton(AF_INET, argv[idx_ipv4]->arg, &id);
519 :
520 0 : level = parse_show_level(idx_level, argc, argv);
521 :
522 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
523 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
524 0 : ospf6_lsdb_show_wrapper(vty, level, NULL, &id, NULL, uj,
525 : ospf6);
526 0 : if (!all_vrf)
527 : break;
528 : }
529 : }
530 :
531 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
532 :
533 : return CMD_SUCCESS;
534 : }
535 :
536 0 : DEFUN(show_ipv6_ospf6_database_router, show_ipv6_ospf6_database_router_cmd,
537 : "show ipv6 ospf6 [vrf <NAME|all>] database <*|adv-router> * A.B.C.D <detail|dump|internal> [json]",
538 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
539 : "All VRFs\n"
540 : "Display Link state database\n"
541 : "Any Link state Type\n"
542 : "Search by Advertising Router\n"
543 : "Any Link state ID\n"
544 : "Specify Advertising Router as IPv4 address notation\n"
545 : "Display details of LSAs\n"
546 : "Dump LSAs\n"
547 : "Display LSA's internal information\n" JSON_STR)
548 : {
549 0 : int idx_ipv4 = 6;
550 0 : int idx_level = 7;
551 0 : int level;
552 0 : struct listnode *node;
553 0 : struct ospf6 *ospf6;
554 0 : uint32_t adv_router = 0;
555 0 : const char *vrf_name = NULL;
556 0 : bool all_vrf = false;
557 0 : int idx_vrf = 0;
558 0 : bool uj = use_json(argc, argv);
559 :
560 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
561 0 : if (idx_vrf > 0) {
562 0 : idx_ipv4 += 2;
563 0 : idx_level += 2;
564 : }
565 :
566 0 : inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
567 0 : level = parse_show_level(idx_level, argc, argv);
568 :
569 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
570 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
571 0 : ospf6_lsdb_show_wrapper(vty, level, NULL, NULL,
572 : &adv_router, uj, ospf6);
573 0 : if (!all_vrf)
574 : break;
575 : }
576 : }
577 :
578 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
579 :
580 : return CMD_SUCCESS;
581 : }
582 :
583 0 : static int ipv6_ospf6_database_aggr_router_common(struct vty *vty,
584 : uint32_t adv_router,
585 : struct ospf6 *ospf6)
586 : {
587 0 : int level = OSPF6_LSDB_SHOW_LEVEL_DETAIL;
588 0 : uint16_t type = htons(OSPF6_LSTYPE_ROUTER);
589 0 : struct listnode *i;
590 0 : struct ospf6_area *oa;
591 0 : struct ospf6_lsdb *lsdb;
592 :
593 0 : for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
594 0 : if (adv_router == ospf6->router_id)
595 0 : lsdb = oa->lsdb_self;
596 : else
597 0 : lsdb = oa->lsdb;
598 0 : if (ospf6_create_single_router_lsa(oa, lsdb, adv_router)
599 : == NULL) {
600 0 : vty_out(vty, "Adv router is not found in LSDB.");
601 0 : return CMD_SUCCESS;
602 : }
603 0 : ospf6_lsdb_show(vty, level, &type, NULL, NULL,
604 : oa->temp_router_lsa_lsdb, NULL, false);
605 : /* Remove the temp cache */
606 0 : ospf6_remove_temp_router_lsa(oa);
607 : }
608 :
609 0 : vty_out(vty, "\n");
610 0 : return CMD_SUCCESS;
611 : }
612 :
613 0 : DEFUN_HIDDEN(
614 : show_ipv6_ospf6_database_aggr_router,
615 : show_ipv6_ospf6_database_aggr_router_cmd,
616 : "show ipv6 ospf6 [vrf <NAME|all>] database aggr adv-router A.B.C.D",
617 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
618 : "All VRFs\n"
619 : "Display Link state database\n"
620 : "Aggregated Router LSA\n"
621 : "Search by Advertising Router\n"
622 : "Specify Advertising Router as IPv4 address notation\n")
623 : {
624 0 : int idx_ipv4 = 6;
625 0 : struct listnode *node;
626 0 : struct ospf6 *ospf6;
627 0 : uint32_t adv_router = 0;
628 0 : const char *vrf_name = NULL;
629 0 : bool all_vrf = false;
630 0 : int idx_vrf = 0;
631 :
632 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
633 0 : if (idx_vrf > 0)
634 0 : idx_ipv4 += 2;
635 :
636 0 : inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
637 :
638 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
639 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
640 0 : ipv6_ospf6_database_aggr_router_common(vty, adv_router,
641 : ospf6);
642 :
643 0 : if (!all_vrf)
644 : break;
645 : }
646 : }
647 :
648 0 : OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
649 :
650 : return CMD_SUCCESS;
651 : }
652 :
653 0 : DEFUN(show_ipv6_ospf6_database_type_id, show_ipv6_ospf6_database_type_id_cmd,
654 : "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> linkstate-id A.B.C.D [<detail|dump|internal>] [json]",
655 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
656 : "All VRFs\n"
657 : "Display Link state database\n"
658 : "Display Router LSAs\n"
659 : "Display Network LSAs\n"
660 : "Display Inter-Area-Prefix LSAs\n"
661 : "Display Inter-Area-Router LSAs\n"
662 : "Display As-External LSAs\n"
663 : "Display Group-Membership LSAs\n"
664 : "Display Type-7 LSAs\n"
665 : "Display Link LSAs\n"
666 : "Display Intra-Area-Prefix LSAs\n"
667 : "Search by Link state ID\n"
668 : "Specify Link state ID as IPv4 address notation\n"
669 : "Display details of LSAs\n"
670 : "Dump LSAs\n"
671 : "Display LSA's internal information\n" JSON_STR)
672 : {
673 0 : int idx_lsa = 4;
674 0 : int idx_ipv4 = 6;
675 0 : int idx_level = 7;
676 0 : int level;
677 0 : bool uj = use_json(argc, argv);
678 0 : struct listnode *node;
679 0 : struct ospf6 *ospf6;
680 0 : uint16_t type = 0;
681 0 : uint32_t id = 0;
682 0 : const char *vrf_name = NULL;
683 0 : bool all_vrf = false;
684 0 : int idx_vrf = 0;
685 :
686 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
687 0 : if (idx_vrf > 0) {
688 0 : idx_lsa += 2;
689 0 : idx_ipv4 += 2;
690 0 : idx_level += 2;
691 : }
692 :
693 0 : type = parse_type_spec(idx_lsa, argc, argv);
694 0 : inet_pton(AF_INET, argv[idx_ipv4]->arg, &id);
695 0 : level = parse_show_level(idx_level, argc, argv);
696 :
697 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
698 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
699 0 : ospf6_lsdb_type_show_wrapper(vty, level, &type, &id,
700 : NULL, uj, ospf6);
701 0 : if (!all_vrf)
702 : break;
703 : }
704 : }
705 :
706 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
707 :
708 : return CMD_SUCCESS;
709 : }
710 :
711 0 : DEFUN(show_ipv6_ospf6_database_type_router,
712 : show_ipv6_ospf6_database_type_router_cmd,
713 : "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> <*|adv-router> A.B.C.D [<detail|dump|internal>] [json]",
714 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
715 : "All VRFs\n"
716 : "Display Link state database\n"
717 : "Display Router LSAs\n"
718 : "Display Network LSAs\n"
719 : "Display Inter-Area-Prefix LSAs\n"
720 : "Display Inter-Area-Router LSAs\n"
721 : "Display As-External LSAs\n"
722 : "Display Group-Membership LSAs\n"
723 : "Display Type-7 LSAs\n"
724 : "Display Link LSAs\n"
725 : "Display Intra-Area-Prefix LSAs\n"
726 : "Any Link state ID\n"
727 : "Search by Advertising Router\n"
728 : "Specify Advertising Router as IPv4 address notation\n"
729 : "Display details of LSAs\n"
730 : "Dump LSAs\n"
731 : "Display LSA's internal information\n" JSON_STR)
732 : {
733 0 : int idx_lsa = 4;
734 0 : int idx_ipv4 = 6;
735 0 : int idx_level = 7;
736 0 : int level;
737 0 : bool uj = use_json(argc, argv);
738 0 : struct listnode *node;
739 0 : struct ospf6 *ospf6;
740 0 : uint16_t type = 0;
741 0 : uint32_t adv_router = 0;
742 0 : const char *vrf_name = NULL;
743 0 : bool all_vrf = false;
744 0 : int idx_vrf = 0;
745 :
746 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
747 0 : if (idx_vrf > 0) {
748 0 : idx_lsa += 2;
749 0 : idx_ipv4 += 2;
750 0 : idx_level += 2;
751 : }
752 :
753 0 : type = parse_type_spec(idx_lsa, argc, argv);
754 0 : inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
755 0 : level = parse_show_level(idx_level, argc, argv);
756 :
757 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
758 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
759 0 : ospf6_lsdb_type_show_wrapper(vty, level, &type, NULL,
760 : &adv_router, uj, ospf6);
761 :
762 0 : if (!all_vrf)
763 : break;
764 : }
765 : }
766 :
767 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
768 :
769 : return CMD_SUCCESS;
770 : }
771 :
772 0 : DEFUN(show_ipv6_ospf6_database_id_router,
773 : show_ipv6_ospf6_database_id_router_cmd,
774 : "show ipv6 ospf6 [vrf <NAME|all>] database * A.B.C.D A.B.C.D [<detail|dump|internal>] [json]",
775 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
776 : "All VRFs\n"
777 : "Display Link state database\n"
778 : "Any Link state Type\n"
779 : "Specify Link state ID as IPv4 address notation\n"
780 : "Specify Advertising Router as IPv4 address notation\n"
781 : "Display details of LSAs\n"
782 : "Dump LSAs\n"
783 : "Display LSA's internal information\n" JSON_STR)
784 : {
785 0 : int idx_ls_id = 5;
786 0 : int idx_adv_rtr = 6;
787 0 : int idx_level = 7;
788 0 : int level;
789 0 : bool uj = use_json(argc, argv);
790 0 : struct listnode *node;
791 0 : struct ospf6 *ospf6;
792 0 : uint32_t id = 0;
793 0 : uint32_t adv_router = 0;
794 0 : const char *vrf_name = NULL;
795 0 : bool all_vrf = false;
796 0 : int idx_vrf = 0;
797 :
798 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
799 0 : if (idx_vrf > 0) {
800 0 : idx_ls_id += 2;
801 0 : idx_adv_rtr += 2;
802 0 : idx_level += 2;
803 : }
804 :
805 0 : inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
806 0 : inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
807 0 : level = parse_show_level(idx_level, argc, argv);
808 :
809 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
810 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
811 0 : ospf6_lsdb_show_wrapper(vty, level, NULL, &id,
812 : &adv_router, uj, ospf6);
813 0 : if (!all_vrf)
814 : break;
815 : }
816 : }
817 :
818 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
819 :
820 : return CMD_SUCCESS;
821 : }
822 :
823 0 : DEFUN(show_ipv6_ospf6_database_adv_router_linkstate_id,
824 : show_ipv6_ospf6_database_adv_router_linkstate_id_cmd,
825 : "show ipv6 ospf6 [vrf <NAME|all>] database adv-router A.B.C.D linkstate-id A.B.C.D [<detail|dump|internal>] [json]",
826 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
827 : "All VRFs\n"
828 : "Display Link state database\n"
829 : "Search by Advertising Router\n"
830 : "Specify Advertising Router as IPv4 address notation\n"
831 : "Search by Link state ID\n"
832 : "Specify Link state ID as IPv4 address notation\n"
833 : "Display details of LSAs\n"
834 : "Dump LSAs\n"
835 : "Display LSA's internal information\n" JSON_STR)
836 : {
837 0 : int idx_adv_rtr = 5;
838 0 : int idx_ls_id = 7;
839 0 : int idx_level = 8;
840 0 : int level;
841 0 : bool uj = use_json(argc, argv);
842 0 : struct listnode *node;
843 0 : struct ospf6 *ospf6;
844 0 : uint32_t id = 0;
845 0 : uint32_t adv_router = 0;
846 0 : const char *vrf_name = NULL;
847 0 : bool all_vrf = false;
848 0 : int idx_vrf = 0;
849 :
850 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
851 0 : if (idx_vrf > 0) {
852 0 : idx_adv_rtr += 2;
853 0 : idx_ls_id += 2;
854 0 : idx_level += 2;
855 : }
856 0 : inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
857 0 : inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
858 0 : level = parse_show_level(idx_level, argc, argv);
859 :
860 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
861 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
862 0 : ospf6_lsdb_show_wrapper(vty, level, NULL, &id,
863 : &adv_router, uj, ospf6);
864 0 : if (!all_vrf)
865 : break;
866 : }
867 : }
868 :
869 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
870 :
871 : return CMD_SUCCESS;
872 : }
873 :
874 0 : DEFUN(show_ipv6_ospf6_database_type_id_router,
875 : show_ipv6_ospf6_database_type_id_router_cmd,
876 : "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> A.B.C.D A.B.C.D [<dump|internal>] [json]",
877 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
878 : "All VRFs\n"
879 : "Display Link state database\n"
880 : "Display Router LSAs\n"
881 : "Display Network LSAs\n"
882 : "Display Inter-Area-Prefix LSAs\n"
883 : "Display Inter-Area-Router LSAs\n"
884 : "Display As-External LSAs\n"
885 : "Display Group-Membership LSAs\n"
886 : "Display Type-7 LSAs\n"
887 : "Display Link LSAs\n"
888 : "Display Intra-Area-Prefix LSAs\n"
889 : "Specify Link state ID as IPv4 address notation\n"
890 : "Specify Advertising Router as IPv4 address notation\n"
891 : "Dump LSAs\n"
892 : "Display LSA's internal information\n" JSON_STR)
893 : {
894 0 : int idx_lsa = 4;
895 0 : int idx_ls_id = 5;
896 0 : int idx_adv_rtr = 6;
897 0 : int idx_level = 7;
898 0 : int level;
899 0 : bool uj = use_json(argc, argv);
900 0 : struct listnode *node;
901 0 : struct ospf6 *ospf6;
902 0 : uint16_t type = 0;
903 0 : uint32_t id = 0;
904 0 : uint32_t adv_router = 0;
905 0 : const char *vrf_name = NULL;
906 0 : bool all_vrf = false;
907 0 : int idx_vrf = 0;
908 :
909 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
910 0 : if (idx_vrf > 0) {
911 0 : idx_lsa += 2;
912 0 : idx_ls_id += 2;
913 0 : idx_adv_rtr += 2;
914 0 : idx_level += 2;
915 : }
916 :
917 0 : type = parse_type_spec(idx_lsa, argc, argv);
918 0 : inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
919 0 : inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
920 0 : level = parse_show_level(idx_level, argc, argv);
921 :
922 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
923 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
924 0 : ospf6_lsdb_type_show_wrapper(vty, level, &type, &id,
925 : &adv_router, uj, ospf6);
926 :
927 0 : if (!all_vrf)
928 : break;
929 : }
930 : }
931 :
932 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
933 :
934 : return CMD_SUCCESS;
935 : }
936 :
937 :
938 0 : DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id,
939 : show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd,
940 : "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> adv-router A.B.C.D linkstate-id A.B.C.D [<dump|internal>] [json]",
941 : SHOW_STR
942 : IPV6_STR
943 : OSPF6_STR
944 : VRF_CMD_HELP_STR
945 : "All VRFs\n"
946 : "Display Link state database\n"
947 : "Display Router LSAs\n"
948 : "Display Network LSAs\n"
949 : "Display Inter-Area-Prefix LSAs\n"
950 : "Display Inter-Area-Router LSAs\n"
951 : "Display As-External LSAs\n"
952 : "Display Group-Membership LSAs\n"
953 : "Display Type-7 LSAs\n"
954 : "Display Link LSAs\n"
955 : "Display Intra-Area-Prefix LSAs\n"
956 : "Search by Advertising Router\n"
957 : "Specify Advertising Router as IPv4 address notation\n"
958 : "Search by Link state ID\n"
959 : "Specify Link state ID as IPv4 address notation\n"
960 : "Dump LSAs\n"
961 : "Display LSA's internal information\n"
962 : JSON_STR)
963 : {
964 0 : int idx_lsa = 4;
965 0 : int idx_adv_rtr = 6;
966 0 : int idx_ls_id = 8;
967 0 : int idx_level = 9;
968 0 : int level;
969 0 : bool uj = use_json(argc, argv);
970 0 : struct listnode *node;
971 0 : struct ospf6 *ospf6;
972 0 : uint16_t type = 0;
973 0 : uint32_t id = 0;
974 0 : uint32_t adv_router = 0;
975 0 : const char *vrf_name = NULL;
976 0 : bool all_vrf = false;
977 0 : int idx_vrf = 0;
978 :
979 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
980 0 : if (idx_vrf > 0) {
981 0 : idx_lsa += 2;
982 0 : idx_adv_rtr += 2;
983 0 : idx_ls_id += 2;
984 0 : idx_level += 2;
985 : }
986 :
987 0 : type = parse_type_spec(idx_lsa, argc, argv);
988 0 : inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
989 0 : inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
990 0 : level = parse_show_level(idx_level, argc, argv);
991 :
992 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
993 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
994 0 : ospf6_lsdb_type_show_wrapper(vty, level, &type, &id,
995 : &adv_router, uj, ospf6);
996 :
997 0 : if (!all_vrf)
998 : break;
999 : }
1000 : }
1001 :
1002 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1003 :
1004 : return CMD_SUCCESS;
1005 : }
1006 :
1007 0 : DEFUN(show_ipv6_ospf6_database_self_originated,
1008 : show_ipv6_ospf6_database_self_originated_cmd,
1009 : "show ipv6 ospf6 [vrf <NAME|all>] database self-originated [<detail|dump|internal>] [json]",
1010 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1011 : "All VRFs\n"
1012 : "Display Link state database\n"
1013 : "Display Self-originated LSAs\n"
1014 : "Display details of LSAs\n"
1015 : "Dump LSAs\n"
1016 : "Display LSA's internal information\n" JSON_STR)
1017 : {
1018 0 : int idx_level = 5;
1019 0 : int level;
1020 0 : struct listnode *node;
1021 0 : struct ospf6 *ospf6;
1022 0 : const char *vrf_name = NULL;
1023 0 : bool all_vrf = false;
1024 0 : int idx_vrf = 0;
1025 0 : uint32_t adv_router = 0;
1026 0 : bool uj = use_json(argc, argv);
1027 :
1028 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1029 0 : if (idx_vrf > 0)
1030 0 : idx_level += 2;
1031 :
1032 0 : level = parse_show_level(idx_level, argc, argv);
1033 :
1034 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1035 0 : adv_router = ospf6->router_id;
1036 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1037 0 : ospf6_lsdb_show_wrapper(vty, level, NULL, NULL,
1038 : &adv_router, uj, ospf6);
1039 :
1040 0 : if (!all_vrf)
1041 : break;
1042 : }
1043 : }
1044 :
1045 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1046 :
1047 : return CMD_SUCCESS;
1048 : }
1049 :
1050 :
1051 0 : DEFUN(show_ipv6_ospf6_database_type_self_originated,
1052 : show_ipv6_ospf6_database_type_self_originated_cmd,
1053 : "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> self-originated [<detail|dump|internal>] [json]",
1054 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1055 : "All VRFs\n"
1056 : "Display Link state database\n"
1057 : "Display Router LSAs\n"
1058 : "Display Network LSAs\n"
1059 : "Display Inter-Area-Prefix LSAs\n"
1060 : "Display Inter-Area-Router LSAs\n"
1061 : "Display As-External LSAs\n"
1062 : "Display Group-Membership LSAs\n"
1063 : "Display Type-7 LSAs\n"
1064 : "Display Link LSAs\n"
1065 : "Display Intra-Area-Prefix LSAs\n"
1066 : "Display Self-originated LSAs\n"
1067 : "Display details of LSAs\n"
1068 : "Dump LSAs\n"
1069 : "Display LSA's internal information\n" JSON_STR)
1070 : {
1071 0 : int idx_lsa = 4;
1072 0 : int idx_level = 6;
1073 0 : int level;
1074 0 : struct listnode *node;
1075 0 : struct ospf6 *ospf6;
1076 0 : uint16_t type = 0;
1077 0 : uint32_t adv_router = 0;
1078 0 : bool uj = use_json(argc, argv);
1079 :
1080 0 : const char *vrf_name = NULL;
1081 0 : bool all_vrf = false;
1082 0 : int idx_vrf = 0;
1083 :
1084 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1085 0 : if (idx_vrf > 0) {
1086 0 : idx_lsa += 2;
1087 0 : idx_level += 2;
1088 : }
1089 :
1090 0 : type = parse_type_spec(idx_lsa, argc, argv);
1091 0 : level = parse_show_level(idx_level, argc, argv);
1092 :
1093 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1094 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1095 0 : adv_router = ospf6->router_id;
1096 0 : ospf6_lsdb_type_show_wrapper(vty, level, &type, NULL,
1097 : &adv_router, uj, ospf6);
1098 :
1099 0 : if (!all_vrf)
1100 : break;
1101 : }
1102 : }
1103 :
1104 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1105 :
1106 : return CMD_SUCCESS;
1107 : }
1108 :
1109 0 : DEFUN(show_ipv6_ospf6_database_type_self_originated_linkstate_id,
1110 : show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd,
1111 : "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> self-originated linkstate-id A.B.C.D [<detail|dump|internal>] [json]",
1112 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1113 : "All VRFs\n"
1114 : "Display Link state database\n"
1115 : "Display Router LSAs\n"
1116 : "Display Network LSAs\n"
1117 : "Display Inter-Area-Prefix LSAs\n"
1118 : "Display Inter-Area-Router LSAs\n"
1119 : "Display As-External LSAs\n"
1120 : "Display Group-Membership LSAs\n"
1121 : "Display Type-7 LSAs\n"
1122 : "Display Link LSAs\n"
1123 : "Display Intra-Area-Prefix LSAs\n"
1124 : "Display Self-originated LSAs\n"
1125 : "Search by Link state ID\n"
1126 : "Specify Link state ID as IPv4 address notation\n"
1127 : "Display details of LSAs\n"
1128 : "Dump LSAs\n"
1129 : "Display LSA's internal information\n" JSON_STR)
1130 : {
1131 0 : int idx_lsa = 4;
1132 0 : int idx_ls_id = 7;
1133 0 : int idx_level = 8;
1134 0 : int level;
1135 0 : bool uj = use_json(argc, argv);
1136 0 : struct listnode *node;
1137 0 : struct ospf6 *ospf6;
1138 0 : uint16_t type = 0;
1139 0 : uint32_t adv_router = 0;
1140 0 : uint32_t id = 0;
1141 0 : const char *vrf_name = NULL;
1142 0 : bool all_vrf = false;
1143 0 : int idx_vrf = 0;
1144 :
1145 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1146 0 : if (idx_vrf > 0) {
1147 0 : idx_lsa += 2;
1148 0 : idx_ls_id += 2;
1149 0 : idx_level += 2;
1150 : }
1151 :
1152 :
1153 0 : type = parse_type_spec(idx_lsa, argc, argv);
1154 0 : inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
1155 0 : level = parse_show_level(idx_level, argc, argv);
1156 :
1157 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1158 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1159 0 : adv_router = ospf6->router_id;
1160 0 : ospf6_lsdb_type_show_wrapper(vty, level, &type, &id,
1161 : &adv_router, uj, ospf6);
1162 :
1163 0 : if (!all_vrf)
1164 : break;
1165 : }
1166 : }
1167 :
1168 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1169 :
1170 : return CMD_SUCCESS;
1171 : }
1172 :
1173 0 : DEFUN(show_ipv6_ospf6_database_type_id_self_originated,
1174 : show_ipv6_ospf6_database_type_id_self_originated_cmd,
1175 : "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> A.B.C.D self-originated [<detail|dump|internal>] [json]",
1176 : SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1177 : "All VRFs\n"
1178 : "Display Link state database\n"
1179 : "Display Router LSAs\n"
1180 : "Display Network LSAs\n"
1181 : "Display Inter-Area-Prefix LSAs\n"
1182 : "Display Inter-Area-Router LSAs\n"
1183 : "Display As-External LSAs\n"
1184 : "Display Group-Membership LSAs\n"
1185 : "Display Type-7 LSAs\n"
1186 : "Display Link LSAs\n"
1187 : "Display Intra-Area-Prefix LSAs\n"
1188 : "Specify Link state ID as IPv4 address notation\n"
1189 : "Display Self-originated LSAs\n"
1190 : "Display details of LSAs\n"
1191 : "Dump LSAs\n"
1192 : "Display LSA's internal information\n" JSON_STR)
1193 : {
1194 0 : int idx_lsa = 4;
1195 0 : int idx_ls_id = 5;
1196 0 : int idx_level = 7;
1197 0 : int level;
1198 0 : bool uj = use_json(argc, argv);
1199 0 : struct listnode *node;
1200 0 : struct ospf6 *ospf6;
1201 0 : uint16_t type = 0;
1202 0 : uint32_t adv_router = 0;
1203 0 : uint32_t id = 0;
1204 0 : const char *vrf_name = NULL;
1205 0 : bool all_vrf = false;
1206 0 : int idx_vrf = 0;
1207 :
1208 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1209 0 : if (idx_vrf > 0) {
1210 0 : idx_lsa += 2;
1211 0 : idx_ls_id += 2;
1212 0 : idx_level += 2;
1213 : }
1214 :
1215 0 : type = parse_type_spec(idx_lsa, argc, argv);
1216 0 : inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
1217 0 : level = parse_show_level(idx_level, argc, argv);
1218 :
1219 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1220 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1221 0 : adv_router = ospf6->router_id;
1222 0 : ospf6_lsdb_type_show_wrapper(vty, level, &type, &id,
1223 : &adv_router, uj, ospf6);
1224 :
1225 0 : if (!all_vrf)
1226 : break;
1227 : }
1228 : }
1229 :
1230 0 : OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1231 :
1232 : return CMD_SUCCESS;
1233 : }
1234 :
1235 0 : static int show_ospf6_border_routers_common(struct vty *vty, int argc,
1236 : struct cmd_token **argv,
1237 : struct ospf6 *ospf6, int idx_ipv4,
1238 : int idx_argc)
1239 : {
1240 0 : uint32_t adv_router;
1241 0 : struct ospf6_route *ro;
1242 0 : struct prefix prefix;
1243 :
1244 :
1245 0 : if (argc == idx_argc) {
1246 0 : if (strmatch(argv[idx_ipv4]->text, "detail")) {
1247 0 : for (ro = ospf6_route_head(ospf6->brouter_table); ro;
1248 0 : ro = ospf6_route_next(ro))
1249 0 : ospf6_route_show_detail(vty, ro, NULL, false);
1250 : } else {
1251 0 : inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
1252 :
1253 0 : ospf6_linkstate_prefix(adv_router, 0, &prefix);
1254 0 : ro = ospf6_route_lookup(&prefix, ospf6->brouter_table);
1255 0 : if (!ro) {
1256 0 : vty_out(vty,
1257 : "No Route found for Router ID: %s\n",
1258 0 : argv[idx_ipv4]->arg);
1259 0 : return CMD_SUCCESS;
1260 : }
1261 :
1262 0 : ospf6_route_show_detail(vty, ro, NULL, false);
1263 0 : return CMD_SUCCESS;
1264 : }
1265 : } else {
1266 0 : ospf6_brouter_show_header(vty);
1267 :
1268 0 : for (ro = ospf6_route_head(ospf6->brouter_table); ro;
1269 0 : ro = ospf6_route_next(ro))
1270 0 : ospf6_brouter_show(vty, ro);
1271 : }
1272 :
1273 : return CMD_SUCCESS;
1274 : }
1275 :
1276 0 : DEFUN(show_ipv6_ospf6_border_routers, show_ipv6_ospf6_border_routers_cmd,
1277 : "show ipv6 ospf6 [vrf <NAME|all>] border-routers [<A.B.C.D|detail>]",
1278 : SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1279 : "All VRFs\n"
1280 : "Display routing table for ABR and ASBR\n"
1281 : "Router ID\n"
1282 : "Show detailed output\n")
1283 : {
1284 0 : int idx_ipv4 = 4;
1285 0 : struct ospf6 *ospf6 = NULL;
1286 0 : struct listnode *node;
1287 0 : const char *vrf_name = NULL;
1288 0 : bool all_vrf = false;
1289 0 : int idx_vrf = 0;
1290 0 : int idx_argc = 5;
1291 :
1292 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1293 0 : if (idx_vrf > 0) {
1294 0 : idx_argc += 2;
1295 0 : idx_ipv4 += 2;
1296 : }
1297 :
1298 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1299 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1300 0 : show_ospf6_border_routers_common(vty, argc, argv, ospf6,
1301 : idx_ipv4, idx_argc);
1302 :
1303 0 : if (!all_vrf)
1304 : break;
1305 : }
1306 : }
1307 :
1308 0 : OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
1309 :
1310 : return CMD_SUCCESS;
1311 : }
1312 :
1313 :
1314 0 : DEFUN(show_ipv6_ospf6_linkstate, show_ipv6_ospf6_linkstate_cmd,
1315 : "show ipv6 ospf6 [vrf <NAME|all>] linkstate <router A.B.C.D|network A.B.C.D A.B.C.D>",
1316 : SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1317 : "All VRFs\n"
1318 : "Display linkstate routing table\n"
1319 : "Display Router Entry\n"
1320 : "Specify Router ID as IPv4 address notation\n"
1321 : "Display Network Entry\n"
1322 : "Specify Router ID as IPv4 address notation\n"
1323 : "Specify Link state ID as IPv4 address notation\n")
1324 : {
1325 0 : int idx_ipv4 = 5;
1326 0 : struct listnode *node, *nnode;
1327 0 : struct ospf6_area *oa;
1328 0 : struct ospf6 *ospf6 = NULL;
1329 0 : const char *vrf_name = NULL;
1330 0 : bool all_vrf = false;
1331 0 : int idx_vrf = 0;
1332 :
1333 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1334 0 : if (idx_vrf > 0)
1335 0 : idx_ipv4 += 2;
1336 :
1337 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, nnode, ospf6)) {
1338 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1339 0 : for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
1340 0 : vty_out(vty,
1341 : "\n SPF Result in Area %s\n\n",
1342 0 : oa->name);
1343 0 : ospf6_linkstate_table_show(vty, idx_ipv4, argc,
1344 : argv, oa->spf_table);
1345 : }
1346 0 : vty_out(vty, "\n");
1347 :
1348 0 : if (!all_vrf)
1349 : break;
1350 : }
1351 : }
1352 :
1353 0 : OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
1354 :
1355 : return CMD_SUCCESS;
1356 : }
1357 :
1358 :
1359 0 : DEFUN(show_ipv6_ospf6_linkstate_detail, show_ipv6_ospf6_linkstate_detail_cmd,
1360 : "show ipv6 ospf6 [vrf <NAME|all>] linkstate detail",
1361 : SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1362 : "All VRFs\n"
1363 : "Display linkstate routing table\n"
1364 : "Display detailed information\n")
1365 : {
1366 0 : int idx_detail = 4;
1367 0 : struct listnode *node;
1368 0 : struct ospf6_area *oa;
1369 0 : struct ospf6 *ospf6 = NULL;
1370 0 : const char *vrf_name = NULL;
1371 0 : bool all_vrf = false;
1372 0 : int idx_vrf = 0;
1373 :
1374 0 : OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1375 0 : if (idx_vrf > 0)
1376 0 : idx_detail += 2;
1377 :
1378 0 : for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1379 0 : if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1380 0 : for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
1381 0 : vty_out(vty,
1382 : "\n SPF Result in Area %s\n\n",
1383 0 : oa->name);
1384 0 : ospf6_linkstate_table_show(vty, idx_detail,
1385 : argc, argv,
1386 : oa->spf_table);
1387 : }
1388 0 : vty_out(vty, "\n");
1389 :
1390 0 : if (!all_vrf)
1391 : break;
1392 : }
1393 : }
1394 :
1395 0 : OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
1396 :
1397 : return CMD_SUCCESS;
1398 : }
1399 :
1400 : /* Install ospf related commands. */
1401 4 : void ospf6_init(struct thread_master *master)
1402 : {
1403 4 : ospf6_top_init();
1404 4 : ospf6_area_init();
1405 4 : ospf6_interface_init();
1406 4 : ospf6_neighbor_init();
1407 4 : ospf6_zebra_init(master);
1408 :
1409 4 : ospf6_lsa_init();
1410 4 : ospf6_spf_init();
1411 4 : ospf6_intra_init();
1412 4 : ospf6_asbr_init();
1413 4 : ospf6_abr_init();
1414 4 : ospf6_gr_init();
1415 4 : ospf6_gr_helper_config_init();
1416 4 : ospf6_virtual_link_init();
1417 :
1418 : /* initialize hooks for modifying filter rules */
1419 4 : prefix_list_add_hook(ospf6_plist_update);
1420 4 : prefix_list_delete_hook(ospf6_plist_update);
1421 4 : access_list_add_hook(ospf6_filter_update);
1422 4 : access_list_delete_hook(ospf6_filter_update);
1423 :
1424 4 : ospf6_bfd_init();
1425 4 : install_node(&debug_node);
1426 :
1427 4 : install_element_ospf6_debug_message();
1428 4 : install_element_ospf6_debug_lsa();
1429 4 : install_element_ospf6_debug_interface();
1430 4 : install_element_ospf6_debug_neighbor();
1431 4 : install_element_ospf6_debug_zebra();
1432 4 : install_element_ospf6_debug_spf();
1433 4 : install_element_ospf6_debug_route();
1434 4 : install_element_ospf6_debug_brouter();
1435 4 : install_element_ospf6_debug_asbr();
1436 4 : install_element_ospf6_debug_abr();
1437 4 : install_element_ospf6_debug_flood();
1438 4 : install_element_ospf6_debug_nssa();
1439 :
1440 4 : install_element_ospf6_clear_process();
1441 4 : install_element_ospf6_clear_interface();
1442 :
1443 4 : install_element(ENABLE_NODE, &show_debugging_ospf6_cmd);
1444 :
1445 4 : install_element(VIEW_NODE, &show_ipv6_ospf6_border_routers_cmd);
1446 :
1447 4 : install_element(VIEW_NODE, &show_ipv6_ospf6_linkstate_cmd);
1448 4 : install_element(VIEW_NODE, &show_ipv6_ospf6_linkstate_detail_cmd);
1449 :
1450 4 : install_element(VIEW_NODE, &show_ipv6_ospf6_database_cmd);
1451 4 : install_element(VIEW_NODE, &show_ipv6_ospf6_database_type_cmd);
1452 4 : install_element(VIEW_NODE, &show_ipv6_ospf6_database_id_cmd);
1453 4 : install_element(VIEW_NODE, &show_ipv6_ospf6_database_router_cmd);
1454 4 : install_element(VIEW_NODE, &show_ipv6_ospf6_database_type_id_cmd);
1455 4 : install_element(VIEW_NODE, &show_ipv6_ospf6_database_type_router_cmd);
1456 4 : install_element(VIEW_NODE,
1457 : &show_ipv6_ospf6_database_adv_router_linkstate_id_cmd);
1458 4 : install_element(VIEW_NODE, &show_ipv6_ospf6_database_id_router_cmd);
1459 4 : install_element(VIEW_NODE,
1460 : &show_ipv6_ospf6_database_type_id_router_cmd);
1461 4 : install_element(
1462 : VIEW_NODE,
1463 : &show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd);
1464 4 : install_element(VIEW_NODE,
1465 : &show_ipv6_ospf6_database_self_originated_cmd);
1466 4 : install_element(VIEW_NODE,
1467 : &show_ipv6_ospf6_database_type_self_originated_cmd);
1468 4 : install_element(VIEW_NODE,
1469 : &show_ipv6_ospf6_database_type_id_self_originated_cmd);
1470 4 : install_element(
1471 : VIEW_NODE,
1472 : &show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd);
1473 4 : install_element(VIEW_NODE, &show_ipv6_ospf6_database_aggr_router_cmd);
1474 4 : install_element_ospf6_debug_auth();
1475 4 : ospf6_interface_auth_trailer_cmd_init();
1476 4 : install_element_ospf6_clear_intf_auth();
1477 4 : }
|