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