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