]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6d.c
Merge pull request #13310 from opensourcerouting/feature/bgpd_node_target_extended_co...
[mirror_frr.git] / ospf6d / ospf6d.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
718e3744 2/*
508e53e2 3 * Copyright (C) 2003 Yasuhiro Ohara
718e3744 4 */
5
508e53e2 6#include <zebra.h>
718e3744 7
24a58196 8#include "frrevent.h"
508e53e2 9#include "linklist.h"
10#include "vty.h"
11#include "command.h"
427f8e61 12#include "plist.h"
f6c5f2e0 13#include "filter.h"
718e3744 14
508e53e2 15#include "ospf6_proto.h"
c527acf1 16#include "ospf6_top.h"
508e53e2 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"
508e53e2 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"
049207c3 29#include "ospf6_abr.h"
1e05838a 30#include "ospf6_flood.h"
049207c3 31#include "ospf6d.h"
7f342629 32#include "ospf6_bfd.h"
0fc3e113 33#include "ospf6_gr.h"
de851bf2 34#include "lib/json.h"
ad500b22 35#include "ospf6_nssa.h"
6fc7e0c3 36#include "ospf6_auth_trailer.h"
718e3744 37
30043e4c
DL
38DEFINE_MGROUP(OSPF6D, "ospf6d");
39
d62a17ae 40struct route_node *route_prev(struct route_node *node)
718e3744 41{
d62a17ae 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;
718e3744 62}
63
612c2c15 64static int config_write_ospf6_debug(struct vty *vty);
d62a17ae 65static struct cmd_node debug_node = {
f4b8291f 66 .name = "debug",
62b346ee
DL
67 .node = DEBUG_NODE,
68 .prompt = "",
612c2c15 69 .config_write = config_write_ospf6_debug,
508e53e2 70};
718e3744 71
d62a17ae 72static int config_write_ospf6_debug(struct vty *vty)
508e53e2 73{
d62a17ae 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);
ad500b22 85 config_write_ospf6_debug_nssa(vty);
0fc3e113 86 config_write_ospf6_debug_gr_helper(vty);
6fc7e0c3 87 config_write_ospf6_debug_auth(vty);
87f6dc50 88
d62a17ae 89 return 0;
718e3744 90}
91
87f6dc50
DS
92DEFUN_NOSH (show_debugging_ospf6,
93 show_debugging_ospf6_cmd,
94 "show debugging [ospf6]",
95 SHOW_STR
96 DEBUG_STR
97 OSPF6_STR)
98{
257660b4 99 vty_out(vty, "OSPF6 debugging status:\n");
87f6dc50
DS
100
101 config_write_ospf6_debug(vty);
102
cf00164b
DS
103 cmd_show_lib_debugs(vty);
104
87f6dc50
DS
105 return CMD_SUCCESS;
106}
107
d62a17ae 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"
049207c3 113
d62a17ae 114static int parse_show_level(int idx_level, int argc, struct cmd_token **argv)
049207c3 115{
d62a17ae 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;
049207c3 128}
129
d7c0a89a 130static uint16_t parse_type_spec(int idx_lsa, int argc, struct cmd_token **argv)
049207c3 131{
d7c0a89a 132 uint16_t type = 0;
d62a17ae 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);
ad500b22
K
149 else if (strmatch(argv[idx_lsa]->text, "type-7"))
150 type = htons(OSPF6_LSTYPE_TYPE_7);
d62a17ae 151 }
152
153 return type;
049207c3 154}
155
de851bf2
YR
156void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level,
157 uint16_t *type, uint32_t *id, uint32_t *adv_router,
e4bacbaa
YR
158 struct ospf6_lsdb *lsdb, json_object *json_obj,
159 bool use_json)
de851bf2
YR
160{
161 struct ospf6_lsa *lsa;
162 const struct route_node *end = NULL;
e4bacbaa
YR
163 void (*showfunc)(struct vty *, struct ospf6_lsa *, json_object *,
164 bool) = NULL;
165 json_object *json_array = NULL;
de851bf2
YR
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
e4bacbaa
YR
182 if (use_json)
183 json_array = json_object_new_array();
184
de851bf2
YR
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)
e4bacbaa 189 ospf6_lsa_show(vty, lsa, json_array, use_json);
de851bf2 190 else
e4bacbaa 191 (*showfunc)(vty, lsa, json_array, use_json);
de851bf2 192 }
e4bacbaa
YR
193
194 if (use_json)
195 json_object_object_add(json_obj, "lsa", json_array);
de851bf2
YR
196 return;
197 }
198
e4bacbaa 199 if ((level == OSPF6_LSDB_SHOW_LEVEL_NORMAL) && !use_json)
de851bf2
YR
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))
e4bacbaa 208 (*showfunc)(vty, lsa, json_array, use_json);
de851bf2
YR
209 lsa = ospf6_lsdb_next(end, lsa);
210 }
e4bacbaa
YR
211
212 if (use_json)
213 json_object_object_add(json_obj, "lsa", json_array);
de851bf2
YR
214}
215
216static 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);
e4bacbaa
YR
240 ospf6_lsdb_show(vty, level, type, id, adv_router, oa->lsdb,
241 json_obj, uj);
de851bf2
YR
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,
e4bacbaa 263 oi->lsdb, json_obj, uj);
de851bf2
YR
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
e4bacbaa
YR
277 ospf6_lsdb_show(vty, level, type, id, adv_router, o->lsdb, json_obj,
278 uj);
de851bf2
YR
279
280 if (uj) {
281 json_object_array_add(json_array, json_obj);
282 json_object_object_add(json, "asScopedLinkStateDb", json_array);
283
5a6c232b 284 vty_json(vty, json);
de851bf2
YR
285 } else
286 vty_out(vty, "\n");
287}
288
289static 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,
e4bacbaa 319 oa->lsdb, json_obj, uj);
de851bf2
YR
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,
e4bacbaa
YR
343 adv_router, oi->lsdb, json_obj,
344 uj);
de851bf2
YR
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
e4bacbaa
YR
362 ospf6_lsdb_show(vty, level, type, id, adv_router, o->lsdb,
363 json_obj, uj);
de851bf2
YR
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 }
c48349e3 375 if (uj)
5a6c232b 376 vty_json(vty, json);
c48349e3 377 else
de851bf2
YR
378 vty_out(vty, "\n");
379}
380
d48ef099 381DEFUN(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)
718e3744 389{
d62a17ae 390 int level;
d48ef099 391 int idx_level = 4;
392 struct listnode *node;
beadc736 393 struct ospf6 *ospf6;
d48ef099 394 const char *vrf_name = NULL;
395 bool all_vrf = false;
396 int idx_vrf = 0;
397 bool uj = use_json(argc, argv);
beadc736 398
d48ef099 399 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
400 if (idx_vrf > 0)
401 idx_level += 2;
d62a17ae 402
403 level = parse_show_level(idx_level, argc, argv);
d48ef099 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
d6b901ac 413 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
414
d62a17ae 415 return CMD_SUCCESS;
718e3744 416}
417
d48ef099 418DEFUN(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)
718e3744 435{
d62a17ae 436 int idx_lsa = 4;
437 int idx_level = 5;
438 int level;
de851bf2 439 bool uj = use_json(argc, argv);
d48ef099 440 struct listnode *node;
de851bf2 441 struct ospf6 *ospf6;
d48ef099 442 uint16_t type = 0;
443 const char *vrf_name = NULL;
444 bool all_vrf = false;
445 int idx_vrf = 0;
446
d48ef099 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 }
d62a17ae 452
453 type = parse_type_spec(idx_lsa, argc, argv);
454 level = parse_show_level(idx_level, argc, argv);
455
d48ef099 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
d6b901ac 465 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
466
d62a17ae 467 return CMD_SUCCESS;
718e3744 468}
469
d48ef099 470DEFUN(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)
718e3744 481{
d62a17ae 482 int idx_ipv4 = 5;
483 int idx_level = 6;
484 int level;
de851bf2 485 bool uj = use_json(argc, argv);
d48ef099 486 struct listnode *node;
de851bf2 487 struct ospf6 *ospf6;
d48ef099 488 uint32_t id = 0;
489 const char *vrf_name = NULL;
490 bool all_vrf = false;
491 int idx_vrf = 0;
d62a17ae 492
d48ef099 493 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
d62a17ae 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);
d48ef099 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 }
d62a17ae 507
d6b901ac 508 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
509
d62a17ae 510 return CMD_SUCCESS;
718e3744 511}
512
d48ef099 513DEFUN(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)
718e3744 525{
d62a17ae 526 int idx_ipv4 = 6;
527 int idx_level = 7;
528 int level;
d48ef099 529 struct listnode *node;
530 struct ospf6 *ospf6;
d7c0a89a 531 uint32_t adv_router = 0;
d48ef099 532 const char *vrf_name = NULL;
533 bool all_vrf = false;
534 int idx_vrf = 0;
de851bf2 535 bool uj = use_json(argc, argv);
d62a17ae 536
d48ef099 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 }
beadc736 542
d62a17ae 543 inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
544 level = parse_show_level(idx_level, argc, argv);
545
d48ef099 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
d6b901ac 555 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
556
d62a17ae 557 return CMD_SUCCESS;
508e53e2 558}
559
d48ef099 560static int ipv6_ospf6_database_aggr_router_common(struct vty *vty,
561 uint32_t adv_router,
562 struct ospf6 *ospf6)
da086a3b
CS
563{
564 int level = OSPF6_LSDB_SHOW_LEVEL_DETAIL;
565 uint16_t type = htons(OSPF6_LSTYPE_ROUTER);
da086a3b 566 struct listnode *i;
da086a3b
CS
567 struct ospf6_area *oa;
568 struct ospf6_lsdb *lsdb;
da086a3b 569
beadc736 570 for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
571 if (adv_router == ospf6->router_id)
da086a3b
CS
572 lsdb = oa->lsdb_self;
573 else
574 lsdb = oa->lsdb;
996c9314
LB
575 if (ospf6_create_single_router_lsa(oa, lsdb, adv_router)
576 == NULL) {
da086a3b
CS
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,
e4bacbaa 581 oa->temp_router_lsa_lsdb, NULL, false);
da086a3b
CS
582 /* Remove the temp cache */
583 ospf6_remove_temp_router_lsa(oa);
584 }
585
586 vty_out(vty, "\n");
d48ef099 587 return CMD_SUCCESS;
588}
589
590DEFUN_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
d48ef099 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 }
da086a3b 624
d6b901ac 625 OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
626
da086a3b
CS
627 return CMD_SUCCESS;
628}
629
d48ef099 630DEFUN(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)
508e53e2 649{
d62a17ae 650 int idx_lsa = 4;
651 int idx_ipv4 = 6;
652 int idx_level = 7;
653 int level;
de851bf2 654 bool uj = use_json(argc, argv);
d48ef099 655 struct listnode *node;
de851bf2 656 struct ospf6 *ospf6;
d48ef099 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
d48ef099 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 }
d62a17ae 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
d48ef099 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
d6b901ac 683 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
684
d62a17ae 685 return CMD_SUCCESS;
718e3744 686}
687
d48ef099 688DEFUN(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)
718e3744 709{
d62a17ae 710 int idx_lsa = 4;
711 int idx_ipv4 = 6;
712 int idx_level = 7;
713 int level;
de851bf2 714 bool uj = use_json(argc, argv);
d48ef099 715 struct listnode *node;
de851bf2 716 struct ospf6 *ospf6;
d48ef099 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
d48ef099 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 }
d62a17ae 729
d62a17ae 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
d48ef099 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
d6b901ac 744 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
745
d62a17ae 746 return CMD_SUCCESS;
718e3744 747}
748
d48ef099 749DEFUN(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)
049207c3 761{
d62a17ae 762 int idx_ls_id = 5;
763 int idx_adv_rtr = 6;
764 int idx_level = 7;
765 int level;
de851bf2 766 bool uj = use_json(argc, argv);
d48ef099 767 struct listnode *node;
de851bf2 768 struct ospf6 *ospf6;
d48ef099 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
d48ef099 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 }
d62a17ae 781
d62a17ae 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
d48ef099 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
d6b901ac 795 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
796
d62a17ae 797 return CMD_SUCCESS;
718e3744 798}
799
d48ef099 800DEFUN(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)
049207c3 813{
d62a17ae 814 int idx_adv_rtr = 5;
815 int idx_ls_id = 7;
816 int idx_level = 8;
817 int level;
de851bf2 818 bool uj = use_json(argc, argv);
d48ef099 819 struct listnode *node;
de851bf2 820 struct ospf6 *ospf6;
d48ef099 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;
d62a17ae 826
d48ef099 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 }
d62a17ae 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
d48ef099 837 for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
838 if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
819a0202
DS
839 ospf6_lsdb_show_wrapper(vty, level, NULL, &id,
840 &adv_router, uj, ospf6);
d48ef099 841 if (!all_vrf)
842 break;
843 }
844 }
845
d6b901ac 846 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
847
d62a17ae 848 return CMD_SUCCESS;
049207c3 849}
850
d48ef099 851DEFUN(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)
718e3744 870{
d62a17ae 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;
d48ef099 876 bool uj = use_json(argc, argv);
877 struct listnode *node;
878 struct ospf6 *ospf6;
d7c0a89a
QY
879 uint16_t type = 0;
880 uint32_t id = 0;
881 uint32_t adv_router = 0;
d48ef099 882 const char *vrf_name = NULL;
883 bool all_vrf = false;
884 int idx_vrf = 0;
885
d48ef099 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 }
d62a17ae 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
d48ef099 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
d6b901ac 909 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
910
d62a17ae 911 return CMD_SUCCESS;
718e3744 912}
913
049207c3 914
915DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id,
916 show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd,
d48ef099 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]",
049207c3 918 SHOW_STR
919 IPV6_STR
920 OSPF6_STR
d48ef099 921 VRF_CMD_HELP_STR
922 "All VRFs\n"
049207c3 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"
14b16482 937 "Dump LSAs\n"
de851bf2
YR
938 "Display LSA's internal information\n"
939 JSON_STR)
049207c3 940{
d62a17ae 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;
d48ef099 946 bool uj = use_json(argc, argv);
947 struct listnode *node;
948 struct ospf6 *ospf6;
d7c0a89a
QY
949 uint16_t type = 0;
950 uint32_t id = 0;
951 uint32_t adv_router = 0;
d48ef099 952 const char *vrf_name = NULL;
953 bool all_vrf = false;
954 int idx_vrf = 0;
955
d48ef099 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 }
d62a17ae 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
d48ef099 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
d6b901ac 979 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
980
d62a17ae 981 return CMD_SUCCESS;
049207c3 982}
983
d48ef099 984DEFUN(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)
718e3744 994{
d62a17ae 995 int idx_level = 5;
996 int level;
d48ef099 997 struct listnode *node;
998 struct ospf6 *ospf6;
999 const char *vrf_name = NULL;
1000 bool all_vrf = false;
1001 int idx_vrf = 0;
d7c0a89a 1002 uint32_t adv_router = 0;
de851bf2 1003 bool uj = use_json(argc, argv);
d62a17ae 1004
d48ef099 1005 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1006 if (idx_vrf > 0)
1007 idx_level += 2;
1008
d62a17ae 1009 level = parse_show_level(idx_level, argc, argv);
d62a17ae 1010
d48ef099 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
d6b901ac 1022 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1023
d62a17ae 1024 return CMD_SUCCESS;
718e3744 1025}
1026
508e53e2 1027
d48ef099 1028DEFUN(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)
718e3744 1047{
d62a17ae 1048 int idx_lsa = 4;
1049 int idx_level = 6;
1050 int level;
d48ef099 1051 struct listnode *node;
1052 struct ospf6 *ospf6;
d7c0a89a
QY
1053 uint16_t type = 0;
1054 uint32_t adv_router = 0;
de851bf2 1055 bool uj = use_json(argc, argv);
d62a17ae 1056
d48ef099 1057 const char *vrf_name = NULL;
1058 bool all_vrf = false;
1059 int idx_vrf = 0;
1060
d48ef099 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
d62a17ae 1067 type = parse_type_spec(idx_lsa, argc, argv);
1068 level = parse_show_level(idx_level, argc, argv);
1069
d48ef099 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 }
d62a17ae 1080
d6b901ac 1081 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1082
d62a17ae 1083 return CMD_SUCCESS;
049207c3 1084}
508e53e2 1085
d48ef099 1086DEFUN(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)
049207c3 1107{
d62a17ae 1108 int idx_lsa = 4;
1109 int idx_ls_id = 7;
1110 int idx_level = 8;
1111 int level;
d48ef099 1112 bool uj = use_json(argc, argv);
1113 struct listnode *node;
1114 struct ospf6 *ospf6;
d7c0a89a
QY
1115 uint16_t type = 0;
1116 uint32_t adv_router = 0;
1117 uint32_t id = 0;
d48ef099 1118 const char *vrf_name = NULL;
1119 bool all_vrf = false;
1120 int idx_vrf = 0;
1121
d48ef099 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
d62a17ae 1129
d62a17ae 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);
d62a17ae 1133
d48ef099 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
d6b901ac 1145 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1146
d62a17ae 1147 return CMD_SUCCESS;
718e3744 1148}
718e3744 1149
d48ef099 1150DEFUN(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)
718e3744 1170{
d62a17ae 1171 int idx_lsa = 4;
1172 int idx_ls_id = 5;
1173 int idx_level = 7;
1174 int level;
d48ef099 1175 bool uj = use_json(argc, argv);
1176 struct listnode *node;
1177 struct ospf6 *ospf6;
d7c0a89a
QY
1178 uint16_t type = 0;
1179 uint32_t adv_router = 0;
1180 uint32_t id = 0;
d48ef099 1181 const char *vrf_name = NULL;
1182 bool all_vrf = false;
1183 int idx_vrf = 0;
1184
d48ef099 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 }
d62a17ae 1191
d62a17ae 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);
d62a17ae 1195
d48ef099 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
d6b901ac 1207 OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
1208
d62a17ae 1209 return CMD_SUCCESS;
718e3744 1210}
1211
d48ef099 1212static 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)
6452df09 1216{
d7c0a89a 1217 uint32_t adv_router;
d62a17ae 1218 struct ospf6_route *ro;
1219 struct prefix prefix;
1220
d62a17ae 1221
d48ef099 1222 if (argc == idx_argc) {
d62a17ae 1223 if (strmatch(argv[idx_ipv4]->text, "detail")) {
1224 for (ro = ospf6_route_head(ospf6->brouter_table); ro;
1225 ro = ospf6_route_next(ro))
eacd0828 1226 ospf6_route_show_detail(vty, ro, NULL, false);
d62a17ae 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",
d48ef099 1235 argv[idx_ipv4]->arg);
d62a17ae 1236 return CMD_SUCCESS;
1237 }
1238
eacd0828 1239 ospf6_route_show_detail(vty, ro, NULL, false);
d62a17ae 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;
6452df09 1251}
1252
d48ef099 1253DEFUN(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
d48ef099 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 }
6452df09 1274
d48ef099 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
d6b901ac 1285 OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
1286
d48ef099 1287 return CMD_SUCCESS;
1288}
1289
1290
1291DEFUN(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")
4846ef64 1301{
2026b8af 1302 int idx_ipv4 = 5;
d48ef099 1303 struct listnode *node, *nnode;
d62a17ae 1304 struct ospf6_area *oa;
beadc736 1305 struct ospf6 *ospf6 = NULL;
d48ef099 1306 const char *vrf_name = NULL;
1307 bool all_vrf = false;
1308 int idx_vrf = 0;
1309
d48ef099 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");
4846ef64 1324
d48ef099 1325 if (!all_vrf)
1326 break;
1327 }
d62a17ae 1328 }
4846ef64 1329
d6b901ac 1330 OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
1331
d62a17ae 1332 return CMD_SUCCESS;
4846ef64 1333}
1334
4846ef64 1335
d48ef099 1336DEFUN(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")
4846ef64 1342{
d62a17ae 1343 int idx_detail = 4;
1344 struct listnode *node;
1345 struct ospf6_area *oa;
beadc736 1346 struct ospf6 *ospf6 = NULL;
d48ef099 1347 const char *vrf_name = NULL;
1348 bool all_vrf = false;
1349 int idx_vrf = 0;
1350
d48ef099 1351 OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
1352 if (idx_vrf > 0)
1353 idx_detail += 2;
b52a8a52 1354
d48ef099 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 }
d62a17ae 1370 }
4846ef64 1371
d6b901ac 1372 OSPF6_CMD_CHECK_VRF(false, all_vrf, ospf6);
1373
d62a17ae 1374 return CMD_SUCCESS;
4846ef64 1375}
6452df09 1376
718e3744 1377/* Install ospf related commands. */
cd9d0537 1378void ospf6_init(struct event_loop *master)
718e3744 1379{
d62a17ae 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();
71165098 1391 ospf6_gr_init();
0fc3e113 1392 ospf6_gr_helper_config_init();
d62a17ae 1393
f6c5f2e0 1394 /* initialize hooks for modifying filter rules */
f4f0098c
RW
1395 prefix_list_add_hook(ospf6_plist_update);
1396 prefix_list_delete_hook(ospf6_plist_update);
f6c5f2e0 1397 access_list_add_hook(ospf6_filter_update);
1398 access_list_delete_hook(ospf6_filter_update);
427f8e61 1399
d62a17ae 1400 ospf6_bfd_init();
612c2c15 1401 install_node(&debug_node);
d62a17ae 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();
ad500b22 1414 install_element_ospf6_debug_nssa();
d62a17ae 1415
f71ed6df 1416 install_element_ospf6_clear_process();
d62a17ae 1417 install_element_ospf6_clear_interface();
1418
dd73744d 1419 install_element(ENABLE_NODE, &show_debugging_ospf6_cmd);
87f6dc50 1420
d62a17ae 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);
da086a3b 1449 install_element(VIEW_NODE, &show_ipv6_ospf6_database_aggr_router_cmd);
6fc7e0c3
AR
1450 install_element_ospf6_debug_auth();
1451 ospf6_interface_auth_trailer_cmd_init();
1452 install_element_ospf6_clear_intf_auth();
92300491 1453}