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