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