]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6d.c
Merge pull request #10279 from SaiGomathiN/pim_intf
[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 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
425
426 return CMD_SUCCESS;
427 }
428
429 DEFUN(show_ipv6_ospf6_database_type, show_ipv6_ospf6_database_type_cmd,
430 "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]",
431 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
432 "All VRFs\n"
433 "Display Link state database\n"
434 "Display Router LSAs\n"
435 "Display Network LSAs\n"
436 "Display Inter-Area-Prefix LSAs\n"
437 "Display Inter-Area-Router LSAs\n"
438 "Display As-External LSAs\n"
439 "Display Group-Membership LSAs\n"
440 "Display Type-7 LSAs\n"
441 "Display Link LSAs\n"
442 "Display Intra-Area-Prefix LSAs\n"
443 "Display details of LSAs\n"
444 "Dump LSAs\n"
445 "Display LSA's internal information\n" JSON_STR)
446 {
447 int idx_lsa = 4;
448 int idx_level = 5;
449 int level;
450 bool uj = use_json(argc, argv);
451 struct listnode *node;
452 struct ospf6 *ospf6;
453 uint16_t type = 0;
454 const char *vrf_name = NULL;
455 bool all_vrf = false;
456 int idx_vrf = 0;
457
458 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
459 if (idx_vrf > 0) {
460 idx_lsa += 2;
461 idx_level += 2;
462 }
463
464 type = parse_type_spec(idx_lsa, argc, argv);
465 level = parse_show_level(idx_level, argc, argv);
466
467 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
468 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
469 ospf6_lsdb_type_show_wrapper(vty, level, &type, NULL,
470 NULL, uj, ospf6);
471 if (!all_vrf)
472 break;
473 }
474 }
475
476 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
477
478 return CMD_SUCCESS;
479 }
480
481 DEFUN(show_ipv6_ospf6_database_id, show_ipv6_ospf6_database_id_cmd,
482 "show ipv6 ospf6 [vrf <NAME|all>] database <*|linkstate-id> A.B.C.D [<detail|dump|internal>] [json]",
483 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
484 "All VRFs\n"
485 "Display Link state database\n"
486 "Any Link state Type\n"
487 "Search by Link state ID\n"
488 "Specify Link state ID as IPv4 address notation\n"
489 "Display details of LSAs\n"
490 "Dump LSAs\n"
491 "Display LSA's internal information\n" JSON_STR)
492 {
493 int idx_ipv4 = 5;
494 int idx_level = 6;
495 int level;
496 bool uj = use_json(argc, argv);
497 struct listnode *node;
498 struct ospf6 *ospf6;
499 uint32_t id = 0;
500 const char *vrf_name = NULL;
501 bool all_vrf = false;
502 int idx_vrf = 0;
503
504 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
505 if (argv[idx_ipv4]->type == IPV4_TKN)
506 inet_pton(AF_INET, argv[idx_ipv4]->arg, &id);
507
508 level = parse_show_level(idx_level, argc, argv);
509
510 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
511 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
512 ospf6_lsdb_show_wrapper(vty, level, NULL, &id, NULL, uj,
513 ospf6);
514 if (!all_vrf)
515 break;
516 }
517 }
518
519 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
520
521 return CMD_SUCCESS;
522 }
523
524 DEFUN(show_ipv6_ospf6_database_router, show_ipv6_ospf6_database_router_cmd,
525 "show ipv6 ospf6 [vrf <NAME|all>] database <*|adv-router> * A.B.C.D <detail|dump|internal> [json]",
526 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
527 "All VRFs\n"
528 "Display Link state database\n"
529 "Any Link state Type\n"
530 "Search by Advertising Router\n"
531 "Any Link state ID\n"
532 "Specify Advertising Router as IPv4 address notation\n"
533 "Display details of LSAs\n"
534 "Dump LSAs\n"
535 "Display LSA's internal information\n" JSON_STR)
536 {
537 int idx_ipv4 = 6;
538 int idx_level = 7;
539 int level;
540 struct listnode *node;
541 struct ospf6 *ospf6;
542 uint32_t adv_router = 0;
543 const char *vrf_name = NULL;
544 bool all_vrf = false;
545 int idx_vrf = 0;
546 bool uj = use_json(argc, argv);
547
548 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
549 if (idx_vrf > 0) {
550 idx_ipv4 += 2;
551 idx_level += 2;
552 }
553
554 inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
555 level = parse_show_level(idx_level, argc, argv);
556
557 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
558 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
559 ospf6_lsdb_show_wrapper(vty, level, NULL, NULL,
560 &adv_router, uj, ospf6);
561 if (!all_vrf)
562 break;
563 }
564 }
565
566 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
567
568 return CMD_SUCCESS;
569 }
570
571 static int ipv6_ospf6_database_aggr_router_common(struct vty *vty,
572 uint32_t adv_router,
573 struct ospf6 *ospf6)
574 {
575 int level = OSPF6_LSDB_SHOW_LEVEL_DETAIL;
576 uint16_t type = htons(OSPF6_LSTYPE_ROUTER);
577 struct listnode *i;
578 struct ospf6_area *oa;
579 struct ospf6_lsdb *lsdb;
580
581 for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
582 if (adv_router == ospf6->router_id)
583 lsdb = oa->lsdb_self;
584 else
585 lsdb = oa->lsdb;
586 if (ospf6_create_single_router_lsa(oa, lsdb, adv_router)
587 == NULL) {
588 vty_out(vty, "Adv router is not found in LSDB.");
589 return CMD_SUCCESS;
590 }
591 ospf6_lsdb_show(vty, level, &type, NULL, NULL,
592 oa->temp_router_lsa_lsdb, NULL, false);
593 /* Remove the temp cache */
594 ospf6_remove_temp_router_lsa(oa);
595 }
596
597 vty_out(vty, "\n");
598 return CMD_SUCCESS;
599 }
600
601 DEFUN_HIDDEN(
602 show_ipv6_ospf6_database_aggr_router,
603 show_ipv6_ospf6_database_aggr_router_cmd,
604 "show ipv6 ospf6 [vrf <NAME|all>] database aggr adv-router A.B.C.D",
605 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
606 "All VRFs\n"
607 "Display Link state database\n"
608 "Aggregated Router LSA\n"
609 "Search by Advertising Router\n"
610 "Specify Advertising Router as IPv4 address notation\n")
611 {
612 int idx_ipv4 = 6;
613 struct listnode *node;
614 struct ospf6 *ospf6;
615 uint32_t adv_router = 0;
616 const char *vrf_name = NULL;
617 bool all_vrf = false;
618 int idx_vrf = 0;
619
620 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
621 if (idx_vrf > 0)
622 idx_ipv4 += 2;
623
624 inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
625
626 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
627 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
628 ipv6_ospf6_database_aggr_router_common(vty, adv_router,
629 ospf6);
630
631 if (!all_vrf)
632 break;
633 }
634 }
635
636 OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
637
638 return CMD_SUCCESS;
639 }
640
641 DEFUN(show_ipv6_ospf6_database_type_id, show_ipv6_ospf6_database_type_id_cmd,
642 "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]",
643 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
644 "All VRFs\n"
645 "Display Link state database\n"
646 "Display Router LSAs\n"
647 "Display Network LSAs\n"
648 "Display Inter-Area-Prefix LSAs\n"
649 "Display Inter-Area-Router LSAs\n"
650 "Display As-External LSAs\n"
651 "Display Group-Membership LSAs\n"
652 "Display Type-7 LSAs\n"
653 "Display Link LSAs\n"
654 "Display Intra-Area-Prefix LSAs\n"
655 "Search by Link state ID\n"
656 "Specify Link state ID as IPv4 address notation\n"
657 "Display details of LSAs\n"
658 "Dump LSAs\n"
659 "Display LSA's internal information\n" JSON_STR)
660 {
661 int idx_lsa = 4;
662 int idx_ipv4 = 6;
663 int idx_level = 7;
664 int level;
665 bool uj = use_json(argc, argv);
666 struct listnode *node;
667 struct ospf6 *ospf6;
668 uint16_t type = 0;
669 uint32_t id = 0;
670 const char *vrf_name = NULL;
671 bool all_vrf = false;
672 int idx_vrf = 0;
673
674 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
675 if (idx_vrf > 0) {
676 idx_lsa += 2;
677 idx_ipv4 += 2;
678 idx_level += 2;
679 }
680
681 type = parse_type_spec(idx_lsa, argc, argv);
682 inet_pton(AF_INET, argv[idx_ipv4]->arg, &id);
683 level = parse_show_level(idx_level, argc, argv);
684
685 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
686 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
687 ospf6_lsdb_type_show_wrapper(vty, level, &type, &id,
688 NULL, uj, ospf6);
689 if (!all_vrf)
690 break;
691 }
692 }
693
694 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
695
696 return CMD_SUCCESS;
697 }
698
699 DEFUN(show_ipv6_ospf6_database_type_router,
700 show_ipv6_ospf6_database_type_router_cmd,
701 "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]",
702 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
703 "All VRFs\n"
704 "Display Link state database\n"
705 "Display Router LSAs\n"
706 "Display Network LSAs\n"
707 "Display Inter-Area-Prefix LSAs\n"
708 "Display Inter-Area-Router LSAs\n"
709 "Display As-External LSAs\n"
710 "Display Group-Membership LSAs\n"
711 "Display Type-7 LSAs\n"
712 "Display Link LSAs\n"
713 "Display Intra-Area-Prefix LSAs\n"
714 "Any Link state ID\n"
715 "Search by Advertising Router\n"
716 "Specify Advertising Router as IPv4 address notation\n"
717 "Display details of LSAs\n"
718 "Dump LSAs\n"
719 "Display LSA's internal information\n" JSON_STR)
720 {
721 int idx_lsa = 4;
722 int idx_ipv4 = 6;
723 int idx_level = 7;
724 int level;
725 bool uj = use_json(argc, argv);
726 struct listnode *node;
727 struct ospf6 *ospf6;
728 uint16_t type = 0;
729 uint32_t adv_router = 0;
730 const char *vrf_name = NULL;
731 bool all_vrf = false;
732 int idx_vrf = 0;
733
734 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
735 if (idx_vrf > 0) {
736 idx_lsa += 2;
737 idx_ipv4 += 2;
738 idx_level += 2;
739 }
740
741 type = parse_type_spec(idx_lsa, argc, argv);
742 inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
743 level = parse_show_level(idx_level, argc, argv);
744
745 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
746 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
747 ospf6_lsdb_type_show_wrapper(vty, level, &type, NULL,
748 &adv_router, uj, ospf6);
749
750 if (!all_vrf)
751 break;
752 }
753 }
754
755 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
756
757 return CMD_SUCCESS;
758 }
759
760 DEFUN(show_ipv6_ospf6_database_id_router,
761 show_ipv6_ospf6_database_id_router_cmd,
762 "show ipv6 ospf6 [vrf <NAME|all>] database * A.B.C.D A.B.C.D [<detail|dump|internal>] [json]",
763 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
764 "All VRFs\n"
765 "Display Link state database\n"
766 "Any Link state Type\n"
767 "Specify Link state ID as IPv4 address notation\n"
768 "Specify Advertising Router as IPv4 address notation\n"
769 "Display details of LSAs\n"
770 "Dump LSAs\n"
771 "Display LSA's internal information\n" JSON_STR)
772 {
773 int idx_ls_id = 5;
774 int idx_adv_rtr = 6;
775 int idx_level = 7;
776 int level;
777 bool uj = use_json(argc, argv);
778 struct listnode *node;
779 struct ospf6 *ospf6;
780 uint32_t id = 0;
781 uint32_t adv_router = 0;
782 const char *vrf_name = NULL;
783 bool all_vrf = false;
784 int idx_vrf = 0;
785
786 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
787 if (idx_vrf > 0) {
788 idx_ls_id += 2;
789 idx_adv_rtr += 2;
790 idx_level += 2;
791 }
792
793 inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
794 inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
795 level = parse_show_level(idx_level, argc, argv);
796
797 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
798 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
799 ospf6_lsdb_show_wrapper(vty, level, NULL, &id,
800 &adv_router, uj, ospf6);
801 if (!all_vrf)
802 break;
803 }
804 }
805
806 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
807
808 return CMD_SUCCESS;
809 }
810
811 DEFUN(show_ipv6_ospf6_database_adv_router_linkstate_id,
812 show_ipv6_ospf6_database_adv_router_linkstate_id_cmd,
813 "show ipv6 ospf6 [vrf <NAME|all>] database adv-router A.B.C.D linkstate-id A.B.C.D [<detail|dump|internal>] [json]",
814 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
815 "All VRFs\n"
816 "Display Link state database\n"
817 "Search by Advertising Router\n"
818 "Specify Advertising Router as IPv4 address notation\n"
819 "Search by Link state ID\n"
820 "Specify Link state ID as IPv4 address notation\n"
821 "Display details of LSAs\n"
822 "Dump LSAs\n"
823 "Display LSA's internal information\n" JSON_STR)
824 {
825 int idx_adv_rtr = 5;
826 int idx_ls_id = 7;
827 int idx_level = 8;
828 int level;
829 bool uj = use_json(argc, argv);
830 struct listnode *node;
831 struct ospf6 *ospf6;
832 uint32_t id = 0;
833 uint32_t adv_router = 0;
834 const char *vrf_name = NULL;
835 bool all_vrf = false;
836 int idx_vrf = 0;
837
838 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
839 if (idx_vrf > 0) {
840 idx_adv_rtr += 2;
841 idx_ls_id += 2;
842 idx_level += 2;
843 }
844 inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
845 inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
846 level = parse_show_level(idx_level, argc, argv);
847
848 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
849 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
850 ospf6_lsdb_show_wrapper(vty, level, NULL, &id,
851 &adv_router, uj, ospf6);
852 if (!all_vrf)
853 break;
854 }
855 }
856
857 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
858
859 return CMD_SUCCESS;
860 }
861
862 DEFUN(show_ipv6_ospf6_database_type_id_router,
863 show_ipv6_ospf6_database_type_id_router_cmd,
864 "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]",
865 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
866 "All VRFs\n"
867 "Display Link state database\n"
868 "Display Router LSAs\n"
869 "Display Network LSAs\n"
870 "Display Inter-Area-Prefix LSAs\n"
871 "Display Inter-Area-Router LSAs\n"
872 "Display As-External LSAs\n"
873 "Display Group-Membership LSAs\n"
874 "Display Type-7 LSAs\n"
875 "Display Link LSAs\n"
876 "Display Intra-Area-Prefix LSAs\n"
877 "Specify Link state ID as IPv4 address notation\n"
878 "Specify Advertising Router as IPv4 address notation\n"
879 "Dump LSAs\n"
880 "Display LSA's internal information\n" JSON_STR)
881 {
882 int idx_lsa = 4;
883 int idx_ls_id = 5;
884 int idx_adv_rtr = 6;
885 int idx_level = 7;
886 int level;
887 bool uj = use_json(argc, argv);
888 struct listnode *node;
889 struct ospf6 *ospf6;
890 uint16_t type = 0;
891 uint32_t id = 0;
892 uint32_t adv_router = 0;
893 const char *vrf_name = NULL;
894 bool all_vrf = false;
895 int idx_vrf = 0;
896
897 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
898 if (idx_vrf > 0) {
899 idx_lsa += 2;
900 idx_ls_id += 2;
901 idx_adv_rtr += 2;
902 idx_level += 2;
903 }
904
905 type = parse_type_spec(idx_lsa, argc, argv);
906 inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
907 inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
908 level = parse_show_level(idx_level, argc, argv);
909
910 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
911 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
912 ospf6_lsdb_type_show_wrapper(vty, level, &type, &id,
913 &adv_router, uj, ospf6);
914
915 if (!all_vrf)
916 break;
917 }
918 }
919
920 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
921
922 return CMD_SUCCESS;
923 }
924
925
926 DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id,
927 show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd,
928 "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]",
929 SHOW_STR
930 IPV6_STR
931 OSPF6_STR
932 VRF_CMD_HELP_STR
933 "All VRFs\n"
934 "Display Link state database\n"
935 "Display Router LSAs\n"
936 "Display Network LSAs\n"
937 "Display Inter-Area-Prefix LSAs\n"
938 "Display Inter-Area-Router LSAs\n"
939 "Display As-External LSAs\n"
940 "Display Group-Membership LSAs\n"
941 "Display Type-7 LSAs\n"
942 "Display Link LSAs\n"
943 "Display Intra-Area-Prefix LSAs\n"
944 "Search by Advertising Router\n"
945 "Specify Advertising Router as IPv4 address notation\n"
946 "Search by Link state ID\n"
947 "Specify Link state ID as IPv4 address notation\n"
948 "Dump LSAs\n"
949 "Display LSA's internal information\n"
950 JSON_STR)
951 {
952 int idx_lsa = 4;
953 int idx_adv_rtr = 6;
954 int idx_ls_id = 8;
955 int idx_level = 9;
956 int level;
957 bool uj = use_json(argc, argv);
958 struct listnode *node;
959 struct ospf6 *ospf6;
960 uint16_t type = 0;
961 uint32_t id = 0;
962 uint32_t adv_router = 0;
963 const char *vrf_name = NULL;
964 bool all_vrf = false;
965 int idx_vrf = 0;
966
967 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
968 if (idx_vrf > 0) {
969 idx_lsa += 2;
970 idx_adv_rtr += 2;
971 idx_ls_id += 2;
972 idx_level += 2;
973 }
974
975 type = parse_type_spec(idx_lsa, argc, argv);
976 inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
977 inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
978 level = parse_show_level(idx_level, argc, argv);
979
980 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
981 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
982 ospf6_lsdb_type_show_wrapper(vty, level, &type, &id,
983 &adv_router, uj, ospf6);
984
985 if (!all_vrf)
986 break;
987 }
988 }
989
990 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
991
992 return CMD_SUCCESS;
993 }
994
995 DEFUN(show_ipv6_ospf6_database_self_originated,
996 show_ipv6_ospf6_database_self_originated_cmd,
997 "show ipv6 ospf6 [vrf <NAME|all>] database self-originated [<detail|dump|internal>] [json]",
998 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
999 "All VRFs\n"
1000 "Display Link state database\n"
1001 "Display Self-originated LSAs\n"
1002 "Display details of LSAs\n"
1003 "Dump LSAs\n"
1004 "Display LSA's internal information\n" JSON_STR)
1005 {
1006 int idx_level = 5;
1007 int level;
1008 struct listnode *node;
1009 struct ospf6 *ospf6;
1010 const char *vrf_name = NULL;
1011 bool all_vrf = false;
1012 int idx_vrf = 0;
1013 uint32_t adv_router = 0;
1014 bool uj = use_json(argc, argv);
1015
1016 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1017 if (idx_vrf > 0)
1018 idx_level += 2;
1019
1020 level = parse_show_level(idx_level, argc, argv);
1021
1022 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1023 adv_router = ospf6->router_id;
1024 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1025 ospf6_lsdb_show_wrapper(vty, level, NULL, NULL,
1026 &adv_router, uj, ospf6);
1027
1028 if (!all_vrf)
1029 break;
1030 }
1031 }
1032
1033 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1034
1035 return CMD_SUCCESS;
1036 }
1037
1038
1039 DEFUN(show_ipv6_ospf6_database_type_self_originated,
1040 show_ipv6_ospf6_database_type_self_originated_cmd,
1041 "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]",
1042 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1043 "All VRFs\n"
1044 "Display Link state database\n"
1045 "Display Router LSAs\n"
1046 "Display Network LSAs\n"
1047 "Display Inter-Area-Prefix LSAs\n"
1048 "Display Inter-Area-Router LSAs\n"
1049 "Display As-External LSAs\n"
1050 "Display Group-Membership LSAs\n"
1051 "Display Type-7 LSAs\n"
1052 "Display Link LSAs\n"
1053 "Display Intra-Area-Prefix LSAs\n"
1054 "Display Self-originated LSAs\n"
1055 "Display details of LSAs\n"
1056 "Dump LSAs\n"
1057 "Display LSA's internal information\n" JSON_STR)
1058 {
1059 int idx_lsa = 4;
1060 int idx_level = 6;
1061 int level;
1062 struct listnode *node;
1063 struct ospf6 *ospf6;
1064 uint16_t type = 0;
1065 uint32_t adv_router = 0;
1066 bool uj = use_json(argc, argv);
1067
1068 const char *vrf_name = NULL;
1069 bool all_vrf = false;
1070 int idx_vrf = 0;
1071
1072 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1073 if (idx_vrf > 0) {
1074 idx_lsa += 2;
1075 idx_level += 2;
1076 }
1077
1078 type = parse_type_spec(idx_lsa, argc, argv);
1079 level = parse_show_level(idx_level, argc, argv);
1080
1081 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1082 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1083 adv_router = ospf6->router_id;
1084 ospf6_lsdb_type_show_wrapper(vty, level, &type, NULL,
1085 &adv_router, uj, ospf6);
1086
1087 if (!all_vrf)
1088 break;
1089 }
1090 }
1091
1092 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1093
1094 return CMD_SUCCESS;
1095 }
1096
1097 DEFUN(show_ipv6_ospf6_database_type_self_originated_linkstate_id,
1098 show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd,
1099 "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]",
1100 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1101 "All VRFs\n"
1102 "Display Link state database\n"
1103 "Display Router LSAs\n"
1104 "Display Network LSAs\n"
1105 "Display Inter-Area-Prefix LSAs\n"
1106 "Display Inter-Area-Router LSAs\n"
1107 "Display As-External LSAs\n"
1108 "Display Group-Membership LSAs\n"
1109 "Display Type-7 LSAs\n"
1110 "Display Link LSAs\n"
1111 "Display Intra-Area-Prefix LSAs\n"
1112 "Display Self-originated LSAs\n"
1113 "Search by Link state ID\n"
1114 "Specify Link state ID as IPv4 address notation\n"
1115 "Display details of LSAs\n"
1116 "Dump LSAs\n"
1117 "Display LSA's internal information\n" JSON_STR)
1118 {
1119 int idx_lsa = 4;
1120 int idx_ls_id = 7;
1121 int idx_level = 8;
1122 int level;
1123 bool uj = use_json(argc, argv);
1124 struct listnode *node;
1125 struct ospf6 *ospf6;
1126 uint16_t type = 0;
1127 uint32_t adv_router = 0;
1128 uint32_t id = 0;
1129 const char *vrf_name = NULL;
1130 bool all_vrf = false;
1131 int idx_vrf = 0;
1132
1133 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1134 if (idx_vrf > 0) {
1135 idx_lsa += 2;
1136 idx_ls_id += 2;
1137 idx_level += 2;
1138 }
1139
1140
1141 type = parse_type_spec(idx_lsa, argc, argv);
1142 inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
1143 level = parse_show_level(idx_level, argc, argv);
1144
1145 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1146 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1147 adv_router = ospf6->router_id;
1148 ospf6_lsdb_type_show_wrapper(vty, level, &type, &id,
1149 &adv_router, uj, ospf6);
1150
1151 if (!all_vrf)
1152 break;
1153 }
1154 }
1155
1156 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1157
1158 return CMD_SUCCESS;
1159 }
1160
1161 DEFUN(show_ipv6_ospf6_database_type_id_self_originated,
1162 show_ipv6_ospf6_database_type_id_self_originated_cmd,
1163 "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]",
1164 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1165 "All VRFs\n"
1166 "Display Link state database\n"
1167 "Display Router LSAs\n"
1168 "Display Network LSAs\n"
1169 "Display Inter-Area-Prefix LSAs\n"
1170 "Display Inter-Area-Router LSAs\n"
1171 "Display As-External LSAs\n"
1172 "Display Group-Membership LSAs\n"
1173 "Display Type-7 LSAs\n"
1174 "Display Link LSAs\n"
1175 "Display Intra-Area-Prefix LSAs\n"
1176 "Specify Link state ID as IPv4 address notation\n"
1177 "Display Self-originated LSAs\n"
1178 "Display details of LSAs\n"
1179 "Dump LSAs\n"
1180 "Display LSA's internal information\n" JSON_STR)
1181 {
1182 int idx_lsa = 4;
1183 int idx_ls_id = 5;
1184 int idx_level = 7;
1185 int level;
1186 bool uj = use_json(argc, argv);
1187 struct listnode *node;
1188 struct ospf6 *ospf6;
1189 uint16_t type = 0;
1190 uint32_t adv_router = 0;
1191 uint32_t id = 0;
1192 const char *vrf_name = NULL;
1193 bool all_vrf = false;
1194 int idx_vrf = 0;
1195
1196 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1197 if (idx_vrf > 0) {
1198 idx_lsa += 2;
1199 idx_ls_id += 2;
1200 idx_level += 2;
1201 }
1202
1203 type = parse_type_spec(idx_lsa, argc, argv);
1204 inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
1205 level = parse_show_level(idx_level, argc, argv);
1206
1207 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1208 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1209 adv_router = ospf6->router_id;
1210 ospf6_lsdb_type_show_wrapper(vty, level, &type, &id,
1211 &adv_router, uj, ospf6);
1212
1213 if (!all_vrf)
1214 break;
1215 }
1216 }
1217
1218 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1219
1220 return CMD_SUCCESS;
1221 }
1222
1223 static int show_ospf6_border_routers_common(struct vty *vty, int argc,
1224 struct cmd_token **argv,
1225 struct ospf6 *ospf6, int idx_ipv4,
1226 int idx_argc)
1227 {
1228 uint32_t adv_router;
1229 struct ospf6_route *ro;
1230 struct prefix prefix;
1231
1232
1233 if (argc == idx_argc) {
1234 if (strmatch(argv[idx_ipv4]->text, "detail")) {
1235 for (ro = ospf6_route_head(ospf6->brouter_table); ro;
1236 ro = ospf6_route_next(ro))
1237 ospf6_route_show_detail(vty, ro, NULL, false);
1238 } else {
1239 inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
1240
1241 ospf6_linkstate_prefix(adv_router, 0, &prefix);
1242 ro = ospf6_route_lookup(&prefix, ospf6->brouter_table);
1243 if (!ro) {
1244 vty_out(vty,
1245 "No Route found for Router ID: %s\n",
1246 argv[idx_ipv4]->arg);
1247 return CMD_SUCCESS;
1248 }
1249
1250 ospf6_route_show_detail(vty, ro, NULL, false);
1251 return CMD_SUCCESS;
1252 }
1253 } else {
1254 ospf6_brouter_show_header(vty);
1255
1256 for (ro = ospf6_route_head(ospf6->brouter_table); ro;
1257 ro = ospf6_route_next(ro))
1258 ospf6_brouter_show(vty, ro);
1259 }
1260
1261 return CMD_SUCCESS;
1262 }
1263
1264 DEFUN(show_ipv6_ospf6_border_routers, show_ipv6_ospf6_border_routers_cmd,
1265 "show ipv6 ospf6 [vrf <NAME|all>] border-routers [<A.B.C.D|detail>]",
1266 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1267 "All VRFs\n"
1268 "Display routing table for ABR and ASBR\n"
1269 "Router ID\n"
1270 "Show detailed output\n")
1271 {
1272 int idx_ipv4 = 4;
1273 struct ospf6 *ospf6 = NULL;
1274 struct listnode *node;
1275 const char *vrf_name = NULL;
1276 bool all_vrf = false;
1277 int idx_vrf = 0;
1278 int idx_argc = 5;
1279
1280 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1281 if (idx_vrf > 0) {
1282 idx_argc += 2;
1283 idx_ipv4 += 2;
1284 }
1285
1286 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1287 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1288 show_ospf6_border_routers_common(vty, argc, argv, ospf6,
1289 idx_ipv4, idx_argc);
1290
1291 if (!all_vrf)
1292 break;
1293 }
1294 }
1295
1296 OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
1297
1298 return CMD_SUCCESS;
1299 }
1300
1301
1302 DEFUN(show_ipv6_ospf6_linkstate, show_ipv6_ospf6_linkstate_cmd,
1303 "show ipv6 ospf6 [vrf <NAME|all>] linkstate <router A.B.C.D|network A.B.C.D A.B.C.D>",
1304 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1305 "All VRFs\n"
1306 "Display linkstate routing table\n"
1307 "Display Router Entry\n"
1308 "Specify Router ID as IPv4 address notation\n"
1309 "Display Network Entry\n"
1310 "Specify Router ID as IPv4 address notation\n"
1311 "Specify Link state ID as IPv4 address notation\n")
1312 {
1313 int idx_ipv4 = 5;
1314 struct listnode *node, *nnode;
1315 struct ospf6_area *oa;
1316 struct ospf6 *ospf6 = NULL;
1317 const char *vrf_name = NULL;
1318 bool all_vrf = false;
1319 int idx_vrf = 0;
1320
1321 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1322 if (idx_vrf > 0)
1323 idx_ipv4 += 2;
1324
1325 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, nnode, ospf6)) {
1326 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1327 for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
1328 vty_out(vty,
1329 "\n SPF Result in Area %s\n\n",
1330 oa->name);
1331 ospf6_linkstate_table_show(vty, idx_ipv4, argc,
1332 argv, oa->spf_table);
1333 }
1334 vty_out(vty, "\n");
1335
1336 if (!all_vrf)
1337 break;
1338 }
1339 }
1340
1341 OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
1342
1343 return CMD_SUCCESS;
1344 }
1345
1346
1347 DEFUN(show_ipv6_ospf6_linkstate_detail, show_ipv6_ospf6_linkstate_detail_cmd,
1348 "show ipv6 ospf6 [vrf <NAME|all>] linkstate detail",
1349 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1350 "All VRFs\n"
1351 "Display linkstate routing table\n"
1352 "Display detailed information\n")
1353 {
1354 int idx_detail = 4;
1355 struct listnode *node;
1356 struct ospf6_area *oa;
1357 struct ospf6 *ospf6 = NULL;
1358 const char *vrf_name = NULL;
1359 bool all_vrf = false;
1360 int idx_vrf = 0;
1361
1362 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1363 if (idx_vrf > 0)
1364 idx_detail += 2;
1365
1366 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
1367 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
1368 for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
1369 vty_out(vty,
1370 "\n SPF Result in Area %s\n\n",
1371 oa->name);
1372 ospf6_linkstate_table_show(vty, idx_detail,
1373 argc, argv,
1374 oa->spf_table);
1375 }
1376 vty_out(vty, "\n");
1377
1378 if (!all_vrf)
1379 break;
1380 }
1381 }
1382
1383 OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
1384
1385 return CMD_SUCCESS;
1386 }
1387
1388 /* Install ospf related commands. */
1389 void ospf6_init(struct thread_master *master)
1390 {
1391 ospf6_top_init();
1392 ospf6_area_init();
1393 ospf6_interface_init();
1394 ospf6_neighbor_init();
1395 ospf6_zebra_init(master);
1396
1397 ospf6_lsa_init();
1398 ospf6_spf_init();
1399 ospf6_intra_init();
1400 ospf6_asbr_init();
1401 ospf6_abr_init();
1402 ospf6_gr_init();
1403 ospf6_gr_helper_config_init();
1404
1405 /* initialize hooks for modifying filter rules */
1406 prefix_list_add_hook(ospf6_plist_update);
1407 prefix_list_delete_hook(ospf6_plist_update);
1408 access_list_add_hook(ospf6_filter_update);
1409 access_list_delete_hook(ospf6_filter_update);
1410
1411 ospf6_bfd_init();
1412 install_node(&debug_node);
1413
1414 install_element_ospf6_debug_message();
1415 install_element_ospf6_debug_lsa();
1416 install_element_ospf6_debug_interface();
1417 install_element_ospf6_debug_neighbor();
1418 install_element_ospf6_debug_zebra();
1419 install_element_ospf6_debug_spf();
1420 install_element_ospf6_debug_route();
1421 install_element_ospf6_debug_brouter();
1422 install_element_ospf6_debug_asbr();
1423 install_element_ospf6_debug_abr();
1424 install_element_ospf6_debug_flood();
1425 install_element_ospf6_debug_nssa();
1426
1427 install_element_ospf6_clear_process();
1428 install_element_ospf6_clear_interface();
1429
1430 install_element(ENABLE_NODE, &show_debugging_ospf6_cmd);
1431
1432 install_element(VIEW_NODE, &show_ipv6_ospf6_border_routers_cmd);
1433
1434 install_element(VIEW_NODE, &show_ipv6_ospf6_linkstate_cmd);
1435 install_element(VIEW_NODE, &show_ipv6_ospf6_linkstate_detail_cmd);
1436
1437 install_element(VIEW_NODE, &show_ipv6_ospf6_database_cmd);
1438 install_element(VIEW_NODE, &show_ipv6_ospf6_database_type_cmd);
1439 install_element(VIEW_NODE, &show_ipv6_ospf6_database_id_cmd);
1440 install_element(VIEW_NODE, &show_ipv6_ospf6_database_router_cmd);
1441 install_element(VIEW_NODE, &show_ipv6_ospf6_database_type_id_cmd);
1442 install_element(VIEW_NODE, &show_ipv6_ospf6_database_type_router_cmd);
1443 install_element(VIEW_NODE,
1444 &show_ipv6_ospf6_database_adv_router_linkstate_id_cmd);
1445 install_element(VIEW_NODE, &show_ipv6_ospf6_database_id_router_cmd);
1446 install_element(VIEW_NODE,
1447 &show_ipv6_ospf6_database_type_id_router_cmd);
1448 install_element(
1449 VIEW_NODE,
1450 &show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd);
1451 install_element(VIEW_NODE,
1452 &show_ipv6_ospf6_database_self_originated_cmd);
1453 install_element(VIEW_NODE,
1454 &show_ipv6_ospf6_database_type_self_originated_cmd);
1455 install_element(VIEW_NODE,
1456 &show_ipv6_ospf6_database_type_id_self_originated_cmd);
1457 install_element(
1458 VIEW_NODE,
1459 &show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd);
1460 install_element(VIEW_NODE, &show_ipv6_ospf6_database_aggr_router_cmd);
1461 }