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