1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2003 Yasuhiro Ohara
15 #include "ospf6_proto.h"
16 #include "ospf6_top.h"
17 #include "ospf6_network.h"
18 #include "ospf6_lsa.h"
19 #include "ospf6_lsdb.h"
20 #include "ospf6_message.h"
21 #include "ospf6_route.h"
22 #include "ospf6_zebra.h"
23 #include "ospf6_spf.h"
24 #include "ospf6_area.h"
25 #include "ospf6_interface.h"
26 #include "ospf6_neighbor.h"
27 #include "ospf6_intra.h"
28 #include "ospf6_asbr.h"
29 #include "ospf6_abr.h"
30 #include "ospf6_flood.h"
32 #include "ospf6_bfd.h"
35 #include "ospf6_nssa.h"
36 #include "ospf6_auth_trailer.h"
38 DEFINE_MGROUP(OSPF6D
, "ospf6d");
40 struct route_node
*route_prev(struct route_node
*node
)
42 struct route_node
*end
;
43 struct route_node
*prev
= NULL
;
48 route_lock_node(node
);
51 node
= route_next(node
);
53 route_unlock_node(node
);
57 route_unlock_node(end
);
59 route_lock_node(prev
);
64 static int config_write_ospf6_debug(struct vty
*vty
);
65 static struct cmd_node debug_node
= {
69 .config_write
= config_write_ospf6_debug
,
72 static int config_write_ospf6_debug(struct vty
*vty
)
74 config_write_ospf6_debug_message(vty
);
75 config_write_ospf6_debug_lsa(vty
);
76 config_write_ospf6_debug_zebra(vty
);
77 config_write_ospf6_debug_interface(vty
);
78 config_write_ospf6_debug_neighbor(vty
);
79 config_write_ospf6_debug_spf(vty
);
80 config_write_ospf6_debug_route(vty
);
81 config_write_ospf6_debug_brouter(vty
);
82 config_write_ospf6_debug_asbr(vty
);
83 config_write_ospf6_debug_abr(vty
);
84 config_write_ospf6_debug_flood(vty
);
85 config_write_ospf6_debug_nssa(vty
);
86 config_write_ospf6_debug_gr_helper(vty
);
87 config_write_ospf6_debug_auth(vty
);
92 DEFUN_NOSH (show_debugging_ospf6
,
93 show_debugging_ospf6_cmd
,
94 "show debugging [ospf6]",
99 vty_out(vty
, "OSPF6 debugging status:\n");
101 config_write_ospf6_debug(vty
);
103 cmd_show_lib_debugs(vty
);
108 #define AREA_LSDB_TITLE_FORMAT \
109 "\n Area Scoped Link State Database (Area %s)\n\n"
110 #define IF_LSDB_TITLE_FORMAT \
111 "\n I/F Scoped Link State Database (I/F %s in Area %s)\n\n"
112 #define AS_LSDB_TITLE_FORMAT "\n AS Scoped Link State Database\n\n"
114 static int parse_show_level(int idx_level
, int argc
, struct cmd_token
**argv
)
116 int level
= OSPF6_LSDB_SHOW_LEVEL_NORMAL
;
118 if (argc
> idx_level
) {
119 if (strmatch(argv
[idx_level
]->text
, "detail"))
120 level
= OSPF6_LSDB_SHOW_LEVEL_DETAIL
;
121 else if (strmatch(argv
[idx_level
]->text
, "dump"))
122 level
= OSPF6_LSDB_SHOW_LEVEL_DUMP
;
123 else if (strmatch(argv
[idx_level
]->text
, "internal"))
124 level
= OSPF6_LSDB_SHOW_LEVEL_INTERNAL
;
130 static uint16_t parse_type_spec(int idx_lsa
, int argc
, struct cmd_token
**argv
)
134 if (argc
> idx_lsa
) {
135 if (strmatch(argv
[idx_lsa
]->text
, "router"))
136 type
= htons(OSPF6_LSTYPE_ROUTER
);
137 else if (strmatch(argv
[idx_lsa
]->text
, "network"))
138 type
= htons(OSPF6_LSTYPE_NETWORK
);
139 else if (strmatch(argv
[idx_lsa
]->text
, "as-external"))
140 type
= htons(OSPF6_LSTYPE_AS_EXTERNAL
);
141 else if (strmatch(argv
[idx_lsa
]->text
, "intra-prefix"))
142 type
= htons(OSPF6_LSTYPE_INTRA_PREFIX
);
143 else if (strmatch(argv
[idx_lsa
]->text
, "inter-router"))
144 type
= htons(OSPF6_LSTYPE_INTER_ROUTER
);
145 else if (strmatch(argv
[idx_lsa
]->text
, "inter-prefix"))
146 type
= htons(OSPF6_LSTYPE_INTER_PREFIX
);
147 else if (strmatch(argv
[idx_lsa
]->text
, "link"))
148 type
= htons(OSPF6_LSTYPE_LINK
);
149 else if (strmatch(argv
[idx_lsa
]->text
, "type-7"))
150 type
= htons(OSPF6_LSTYPE_TYPE_7
);
156 void ospf6_lsdb_show(struct vty
*vty
, enum ospf_lsdb_show_level level
,
157 uint16_t *type
, uint32_t *id
, uint32_t *adv_router
,
158 struct ospf6_lsdb
*lsdb
, json_object
*json_obj
,
161 struct ospf6_lsa
*lsa
;
162 const struct route_node
*end
= NULL
;
163 void (*showfunc
)(struct vty
*, struct ospf6_lsa
*, json_object
*,
165 json_object
*json_array
= NULL
;
168 case OSPF6_LSDB_SHOW_LEVEL_DETAIL
:
169 showfunc
= ospf6_lsa_show
;
171 case OSPF6_LSDB_SHOW_LEVEL_INTERNAL
:
172 showfunc
= ospf6_lsa_show_internal
;
174 case OSPF6_LSDB_SHOW_LEVEL_DUMP
:
175 showfunc
= ospf6_lsa_show_dump
;
177 case OSPF6_LSDB_SHOW_LEVEL_NORMAL
:
179 showfunc
= ospf6_lsa_show_summary
;
183 json_array
= json_object_new_array();
185 if (type
&& id
&& adv_router
) {
186 lsa
= ospf6_lsdb_lookup(*type
, *id
, *adv_router
, lsdb
);
188 if (level
== OSPF6_LSDB_SHOW_LEVEL_NORMAL
)
189 ospf6_lsa_show(vty
, lsa
, json_array
, use_json
);
191 (*showfunc
)(vty
, lsa
, json_array
, use_json
);
195 json_object_object_add(json_obj
, "lsa", json_array
);
199 if ((level
== OSPF6_LSDB_SHOW_LEVEL_NORMAL
) && !use_json
)
200 ospf6_lsa_show_summary_header(vty
);
202 end
= ospf6_lsdb_head(lsdb
, !!type
+ !!(type
&& adv_router
),
203 type
? *type
: 0, adv_router
? *adv_router
: 0,
206 if ((!adv_router
|| lsa
->header
->adv_router
== *adv_router
)
207 && (!id
|| lsa
->header
->id
== *id
))
208 (*showfunc
)(vty
, lsa
, json_array
, use_json
);
209 lsa
= ospf6_lsdb_next(end
, lsa
);
213 json_object_object_add(json_obj
, "lsa", json_array
);
216 static void ospf6_lsdb_show_wrapper(struct vty
*vty
,
217 enum ospf_lsdb_show_level level
,
218 uint16_t *type
, uint32_t *id
,
219 uint32_t *adv_router
, bool uj
,
222 struct listnode
*i
, *j
;
223 struct ospf6
*o
= ospf6
;
224 struct ospf6_area
*oa
;
225 struct ospf6_interface
*oi
;
226 json_object
*json
= NULL
;
227 json_object
*json_array
= NULL
;
228 json_object
*json_obj
= NULL
;
231 json
= json_object_new_object();
232 json_array
= json_object_new_array();
234 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
236 json_obj
= json_object_new_object();
237 json_object_string_add(json_obj
, "areaId", oa
->name
);
239 vty_out(vty
, AREA_LSDB_TITLE_FORMAT
, oa
->name
);
240 ospf6_lsdb_show(vty
, level
, type
, id
, adv_router
, oa
->lsdb
,
243 json_object_array_add(json_array
, json_obj
);
246 json_object_object_add(json
, "areaScopedLinkStateDb",
250 json_array
= json_object_new_array();
251 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
252 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
)) {
254 json_obj
= json_object_new_object();
255 json_object_string_add(json_obj
, "areaId",
257 json_object_string_add(json_obj
, "interface",
258 oi
->interface
->name
);
260 vty_out(vty
, IF_LSDB_TITLE_FORMAT
,
261 oi
->interface
->name
, oa
->name
);
262 ospf6_lsdb_show(vty
, level
, type
, id
, adv_router
,
263 oi
->lsdb
, json_obj
, uj
);
265 json_object_array_add(json_array
, json_obj
);
269 json_object_object_add(json
, "interfaceScopedLinkStateDb",
272 json_array
= json_object_new_array();
273 json_obj
= json_object_new_object();
275 vty_out(vty
, AS_LSDB_TITLE_FORMAT
);
277 ospf6_lsdb_show(vty
, level
, type
, id
, adv_router
, o
->lsdb
, json_obj
,
281 json_object_array_add(json_array
, json_obj
);
282 json_object_object_add(json
, "asScopedLinkStateDb", json_array
);
289 static void ospf6_lsdb_type_show_wrapper(struct vty
*vty
,
290 enum ospf_lsdb_show_level level
,
291 uint16_t *type
, uint32_t *id
,
292 uint32_t *adv_router
, bool uj
,
295 struct listnode
*i
, *j
;
296 struct ospf6
*o
= ospf6
;
297 struct ospf6_area
*oa
;
298 struct ospf6_interface
*oi
;
299 json_object
*json
= NULL
;
300 json_object
*json_array
= NULL
;
301 json_object
*json_obj
= NULL
;
304 json
= json_object_new_object();
305 json_array
= json_object_new_array();
308 switch (OSPF6_LSA_SCOPE(*type
)) {
309 case OSPF6_SCOPE_AREA
:
310 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
312 json_obj
= json_object_new_object();
313 json_object_string_add(json_obj
, "areaId",
316 vty_out(vty
, AREA_LSDB_TITLE_FORMAT
, oa
->name
);
318 ospf6_lsdb_show(vty
, level
, type
, id
, adv_router
,
319 oa
->lsdb
, json_obj
, uj
);
321 json_object_array_add(json_array
, json_obj
);
324 json_object_object_add(json
, "areaScopedLinkStateDb",
328 case OSPF6_SCOPE_LINKLOCAL
:
329 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
330 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
)) {
332 json_obj
= json_object_new_object();
333 json_object_string_add(
334 json_obj
, "areaId", oa
->name
);
335 json_object_string_add(
336 json_obj
, "interface",
337 oi
->interface
->name
);
339 vty_out(vty
, IF_LSDB_TITLE_FORMAT
,
340 oi
->interface
->name
, oa
->name
);
342 ospf6_lsdb_show(vty
, level
, type
, id
,
343 adv_router
, oi
->lsdb
, json_obj
,
347 json_object_array_add(json_array
,
352 json_object_object_add(
353 json
, "interfaceScopedLinkStateDb", json_array
);
358 json_obj
= json_object_new_object();
360 vty_out(vty
, AS_LSDB_TITLE_FORMAT
);
362 ospf6_lsdb_show(vty
, level
, type
, id
, adv_router
, o
->lsdb
,
365 json_object_array_add(json_array
, json_obj
);
366 json_object_object_add(json
, "asScopedLinkStateDb",
381 DEFUN(show_ipv6_ospf6_database
, show_ipv6_ospf6_database_cmd
,
382 "show ipv6 ospf6 [vrf <NAME|all>] database [<detail|dump|internal>] [json]",
383 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
385 "Display Link state database\n"
386 "Display details of LSAs\n"
388 "Display LSA's internal information\n" JSON_STR
)
392 struct listnode
*node
;
394 const char *vrf_name
= NULL
;
395 bool all_vrf
= false;
397 bool uj
= use_json(argc
, argv
);
399 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
403 level
= parse_show_level(idx_level
, argc
, argv
);
404 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
405 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
406 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, NULL
, NULL
,
413 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
418 DEFUN(show_ipv6_ospf6_database_type
, show_ipv6_ospf6_database_type_cmd
,
419 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> [<detail|dump|internal>] [json]",
420 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
422 "Display Link state database\n"
423 "Display Router LSAs\n"
424 "Display Network LSAs\n"
425 "Display Inter-Area-Prefix LSAs\n"
426 "Display Inter-Area-Router LSAs\n"
427 "Display As-External LSAs\n"
428 "Display Group-Membership LSAs\n"
429 "Display Type-7 LSAs\n"
430 "Display Link LSAs\n"
431 "Display Intra-Area-Prefix LSAs\n"
432 "Display details of LSAs\n"
434 "Display LSA's internal information\n" JSON_STR
)
439 bool uj
= use_json(argc
, argv
);
440 struct listnode
*node
;
443 const char *vrf_name
= NULL
;
444 bool all_vrf
= false;
447 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
453 type
= parse_type_spec(idx_lsa
, argc
, argv
);
454 level
= parse_show_level(idx_level
, argc
, argv
);
456 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
457 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
458 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, NULL
,
465 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
470 DEFUN(show_ipv6_ospf6_database_id
, show_ipv6_ospf6_database_id_cmd
,
471 "show ipv6 ospf6 [vrf <NAME|all>] database <*|linkstate-id> A.B.C.D [<detail|dump|internal>] [json]",
472 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
474 "Display Link state database\n"
475 "Any Link state Type\n"
476 "Search by Link state ID\n"
477 "Specify Link state ID as IPv4 address notation\n"
478 "Display details of LSAs\n"
480 "Display LSA's internal information\n" JSON_STR
)
485 bool uj
= use_json(argc
, argv
);
486 struct listnode
*node
;
489 const char *vrf_name
= NULL
;
490 bool all_vrf
= false;
493 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
494 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
495 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &id
);
497 level
= parse_show_level(idx_level
, argc
, argv
);
499 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
500 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
501 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, &id
, NULL
, uj
,
508 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
513 DEFUN(show_ipv6_ospf6_database_router
, show_ipv6_ospf6_database_router_cmd
,
514 "show ipv6 ospf6 [vrf <NAME|all>] database <*|adv-router> * A.B.C.D <detail|dump|internal> [json]",
515 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
517 "Display Link state database\n"
518 "Any Link state Type\n"
519 "Search by Advertising Router\n"
520 "Any Link state ID\n"
521 "Specify Advertising Router as IPv4 address notation\n"
522 "Display details of LSAs\n"
524 "Display LSA's internal information\n" JSON_STR
)
529 struct listnode
*node
;
531 uint32_t adv_router
= 0;
532 const char *vrf_name
= NULL
;
533 bool all_vrf
= false;
535 bool uj
= use_json(argc
, argv
);
537 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
543 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
544 level
= parse_show_level(idx_level
, argc
, argv
);
546 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
547 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
548 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, NULL
,
549 &adv_router
, uj
, ospf6
);
555 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
560 static int ipv6_ospf6_database_aggr_router_common(struct vty
*vty
,
564 int level
= OSPF6_LSDB_SHOW_LEVEL_DETAIL
;
565 uint16_t type
= htons(OSPF6_LSTYPE_ROUTER
);
567 struct ospf6_area
*oa
;
568 struct ospf6_lsdb
*lsdb
;
570 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, i
, oa
)) {
571 if (adv_router
== ospf6
->router_id
)
572 lsdb
= oa
->lsdb_self
;
575 if (ospf6_create_single_router_lsa(oa
, lsdb
, adv_router
)
577 vty_out(vty
, "Adv router is not found in LSDB.");
580 ospf6_lsdb_show(vty
, level
, &type
, NULL
, NULL
,
581 oa
->temp_router_lsa_lsdb
, NULL
, false);
582 /* Remove the temp cache */
583 ospf6_remove_temp_router_lsa(oa
);
591 show_ipv6_ospf6_database_aggr_router
,
592 show_ipv6_ospf6_database_aggr_router_cmd
,
593 "show ipv6 ospf6 [vrf <NAME|all>] database aggr adv-router A.B.C.D",
594 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
596 "Display Link state database\n"
597 "Aggregated Router LSA\n"
598 "Search by Advertising Router\n"
599 "Specify Advertising Router as IPv4 address notation\n")
602 struct listnode
*node
;
604 uint32_t adv_router
= 0;
605 const char *vrf_name
= NULL
;
606 bool all_vrf
= false;
609 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
613 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
615 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
616 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
617 ipv6_ospf6_database_aggr_router_common(vty
, adv_router
,
625 OSPF6_CMD_CHECK_VRF(false, all_vrf
, ospf6
);
630 DEFUN(show_ipv6_ospf6_database_type_id
, show_ipv6_ospf6_database_type_id_cmd
,
631 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> linkstate-id A.B.C.D [<detail|dump|internal>] [json]",
632 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
634 "Display Link state database\n"
635 "Display Router LSAs\n"
636 "Display Network LSAs\n"
637 "Display Inter-Area-Prefix LSAs\n"
638 "Display Inter-Area-Router LSAs\n"
639 "Display As-External LSAs\n"
640 "Display Group-Membership LSAs\n"
641 "Display Type-7 LSAs\n"
642 "Display Link LSAs\n"
643 "Display Intra-Area-Prefix LSAs\n"
644 "Search by Link state ID\n"
645 "Specify Link state ID as IPv4 address notation\n"
646 "Display details of LSAs\n"
648 "Display LSA's internal information\n" JSON_STR
)
654 bool uj
= use_json(argc
, argv
);
655 struct listnode
*node
;
659 const char *vrf_name
= NULL
;
660 bool all_vrf
= false;
663 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
670 type
= parse_type_spec(idx_lsa
, argc
, argv
);
671 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &id
);
672 level
= parse_show_level(idx_level
, argc
, argv
);
674 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
675 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
676 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
683 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
688 DEFUN(show_ipv6_ospf6_database_type_router
,
689 show_ipv6_ospf6_database_type_router_cmd
,
690 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> <*|adv-router> A.B.C.D [<detail|dump|internal>] [json]",
691 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
693 "Display Link state database\n"
694 "Display Router LSAs\n"
695 "Display Network LSAs\n"
696 "Display Inter-Area-Prefix LSAs\n"
697 "Display Inter-Area-Router LSAs\n"
698 "Display As-External LSAs\n"
699 "Display Group-Membership LSAs\n"
700 "Display Type-7 LSAs\n"
701 "Display Link LSAs\n"
702 "Display Intra-Area-Prefix LSAs\n"
703 "Any Link state ID\n"
704 "Search by Advertising Router\n"
705 "Specify Advertising Router as IPv4 address notation\n"
706 "Display details of LSAs\n"
708 "Display LSA's internal information\n" JSON_STR
)
714 bool uj
= use_json(argc
, argv
);
715 struct listnode
*node
;
718 uint32_t adv_router
= 0;
719 const char *vrf_name
= NULL
;
720 bool all_vrf
= false;
723 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
730 type
= parse_type_spec(idx_lsa
, argc
, argv
);
731 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
732 level
= parse_show_level(idx_level
, argc
, argv
);
734 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
735 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
736 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, NULL
,
737 &adv_router
, uj
, ospf6
);
744 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
749 DEFUN(show_ipv6_ospf6_database_id_router
,
750 show_ipv6_ospf6_database_id_router_cmd
,
751 "show ipv6 ospf6 [vrf <NAME|all>] database * A.B.C.D A.B.C.D [<detail|dump|internal>] [json]",
752 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
754 "Display Link state database\n"
755 "Any Link state Type\n"
756 "Specify Link state ID as IPv4 address notation\n"
757 "Specify Advertising Router as IPv4 address notation\n"
758 "Display details of LSAs\n"
760 "Display LSA's internal information\n" JSON_STR
)
766 bool uj
= use_json(argc
, argv
);
767 struct listnode
*node
;
770 uint32_t adv_router
= 0;
771 const char *vrf_name
= NULL
;
772 bool all_vrf
= false;
775 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
782 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
783 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
784 level
= parse_show_level(idx_level
, argc
, argv
);
786 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
787 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
788 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, &id
,
789 &adv_router
, uj
, ospf6
);
795 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
800 DEFUN(show_ipv6_ospf6_database_adv_router_linkstate_id
,
801 show_ipv6_ospf6_database_adv_router_linkstate_id_cmd
,
802 "show ipv6 ospf6 [vrf <NAME|all>] database adv-router A.B.C.D linkstate-id A.B.C.D [<detail|dump|internal>] [json]",
803 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
805 "Display Link state database\n"
806 "Search by Advertising Router\n"
807 "Specify Advertising Router as IPv4 address notation\n"
808 "Search by Link state ID\n"
809 "Specify Link state ID as IPv4 address notation\n"
810 "Display details of LSAs\n"
812 "Display LSA's internal information\n" JSON_STR
)
818 bool uj
= use_json(argc
, argv
);
819 struct listnode
*node
;
822 uint32_t adv_router
= 0;
823 const char *vrf_name
= NULL
;
824 bool all_vrf
= false;
827 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
833 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
834 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
835 level
= parse_show_level(idx_level
, argc
, argv
);
837 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
838 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
839 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, &id
,
840 &adv_router
, uj
, ospf6
);
846 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
851 DEFUN(show_ipv6_ospf6_database_type_id_router
,
852 show_ipv6_ospf6_database_type_id_router_cmd
,
853 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> A.B.C.D A.B.C.D [<dump|internal>] [json]",
854 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
856 "Display Link state database\n"
857 "Display Router LSAs\n"
858 "Display Network LSAs\n"
859 "Display Inter-Area-Prefix LSAs\n"
860 "Display Inter-Area-Router LSAs\n"
861 "Display As-External LSAs\n"
862 "Display Group-Membership LSAs\n"
863 "Display Type-7 LSAs\n"
864 "Display Link LSAs\n"
865 "Display Intra-Area-Prefix LSAs\n"
866 "Specify Link state ID as IPv4 address notation\n"
867 "Specify Advertising Router as IPv4 address notation\n"
869 "Display LSA's internal information\n" JSON_STR
)
876 bool uj
= use_json(argc
, argv
);
877 struct listnode
*node
;
881 uint32_t adv_router
= 0;
882 const char *vrf_name
= NULL
;
883 bool all_vrf
= false;
886 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
894 type
= parse_type_spec(idx_lsa
, argc
, argv
);
895 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
896 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
897 level
= parse_show_level(idx_level
, argc
, argv
);
899 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
900 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
901 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
902 &adv_router
, uj
, ospf6
);
909 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
915 DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id
,
916 show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd
,
917 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> adv-router A.B.C.D linkstate-id A.B.C.D [<dump|internal>] [json]",
923 "Display Link state database\n"
924 "Display Router LSAs\n"
925 "Display Network LSAs\n"
926 "Display Inter-Area-Prefix LSAs\n"
927 "Display Inter-Area-Router LSAs\n"
928 "Display As-External LSAs\n"
929 "Display Group-Membership LSAs\n"
930 "Display Type-7 LSAs\n"
931 "Display Link LSAs\n"
932 "Display Intra-Area-Prefix LSAs\n"
933 "Search by Advertising Router\n"
934 "Specify Advertising Router as IPv4 address notation\n"
935 "Search by Link state ID\n"
936 "Specify Link state ID as IPv4 address notation\n"
938 "Display LSA's internal information\n"
946 bool uj
= use_json(argc
, argv
);
947 struct listnode
*node
;
951 uint32_t adv_router
= 0;
952 const char *vrf_name
= NULL
;
953 bool all_vrf
= false;
956 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
964 type
= parse_type_spec(idx_lsa
, argc
, argv
);
965 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
966 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
967 level
= parse_show_level(idx_level
, argc
, argv
);
969 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
970 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
971 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
972 &adv_router
, uj
, ospf6
);
979 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
984 DEFUN(show_ipv6_ospf6_database_self_originated
,
985 show_ipv6_ospf6_database_self_originated_cmd
,
986 "show ipv6 ospf6 [vrf <NAME|all>] database self-originated [<detail|dump|internal>] [json]",
987 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
989 "Display Link state database\n"
990 "Display Self-originated LSAs\n"
991 "Display details of LSAs\n"
993 "Display LSA's internal information\n" JSON_STR
)
997 struct listnode
*node
;
999 const char *vrf_name
= NULL
;
1000 bool all_vrf
= false;
1002 uint32_t adv_router
= 0;
1003 bool uj
= use_json(argc
, argv
);
1005 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1009 level
= parse_show_level(idx_level
, argc
, argv
);
1011 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1012 adv_router
= ospf6
->router_id
;
1013 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1014 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, NULL
,
1015 &adv_router
, uj
, ospf6
);
1022 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1028 DEFUN(show_ipv6_ospf6_database_type_self_originated
,
1029 show_ipv6_ospf6_database_type_self_originated_cmd
,
1030 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> self-originated [<detail|dump|internal>] [json]",
1031 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1033 "Display Link state database\n"
1034 "Display Router LSAs\n"
1035 "Display Network LSAs\n"
1036 "Display Inter-Area-Prefix LSAs\n"
1037 "Display Inter-Area-Router LSAs\n"
1038 "Display As-External LSAs\n"
1039 "Display Group-Membership LSAs\n"
1040 "Display Type-7 LSAs\n"
1041 "Display Link LSAs\n"
1042 "Display Intra-Area-Prefix LSAs\n"
1043 "Display Self-originated LSAs\n"
1044 "Display details of LSAs\n"
1046 "Display LSA's internal information\n" JSON_STR
)
1051 struct listnode
*node
;
1052 struct ospf6
*ospf6
;
1054 uint32_t adv_router
= 0;
1055 bool uj
= use_json(argc
, argv
);
1057 const char *vrf_name
= NULL
;
1058 bool all_vrf
= false;
1061 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1067 type
= parse_type_spec(idx_lsa
, argc
, argv
);
1068 level
= parse_show_level(idx_level
, argc
, argv
);
1070 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1071 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1072 adv_router
= ospf6
->router_id
;
1073 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, NULL
,
1074 &adv_router
, uj
, ospf6
);
1081 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1086 DEFUN(show_ipv6_ospf6_database_type_self_originated_linkstate_id
,
1087 show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd
,
1088 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> self-originated linkstate-id A.B.C.D [<detail|dump|internal>] [json]",
1089 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1091 "Display Link state database\n"
1092 "Display Router LSAs\n"
1093 "Display Network LSAs\n"
1094 "Display Inter-Area-Prefix LSAs\n"
1095 "Display Inter-Area-Router LSAs\n"
1096 "Display As-External LSAs\n"
1097 "Display Group-Membership LSAs\n"
1098 "Display Type-7 LSAs\n"
1099 "Display Link LSAs\n"
1100 "Display Intra-Area-Prefix LSAs\n"
1101 "Display Self-originated LSAs\n"
1102 "Search by Link state ID\n"
1103 "Specify Link state ID as IPv4 address notation\n"
1104 "Display details of LSAs\n"
1106 "Display LSA's internal information\n" JSON_STR
)
1112 bool uj
= use_json(argc
, argv
);
1113 struct listnode
*node
;
1114 struct ospf6
*ospf6
;
1116 uint32_t adv_router
= 0;
1118 const char *vrf_name
= NULL
;
1119 bool all_vrf
= false;
1122 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1130 type
= parse_type_spec(idx_lsa
, argc
, argv
);
1131 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
1132 level
= parse_show_level(idx_level
, argc
, argv
);
1134 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1135 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1136 adv_router
= ospf6
->router_id
;
1137 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
1138 &adv_router
, uj
, ospf6
);
1145 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1150 DEFUN(show_ipv6_ospf6_database_type_id_self_originated
,
1151 show_ipv6_ospf6_database_type_id_self_originated_cmd
,
1152 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> A.B.C.D self-originated [<detail|dump|internal>] [json]",
1153 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1155 "Display Link state database\n"
1156 "Display Router LSAs\n"
1157 "Display Network LSAs\n"
1158 "Display Inter-Area-Prefix LSAs\n"
1159 "Display Inter-Area-Router LSAs\n"
1160 "Display As-External LSAs\n"
1161 "Display Group-Membership LSAs\n"
1162 "Display Type-7 LSAs\n"
1163 "Display Link LSAs\n"
1164 "Display Intra-Area-Prefix LSAs\n"
1165 "Specify Link state ID as IPv4 address notation\n"
1166 "Display Self-originated LSAs\n"
1167 "Display details of LSAs\n"
1169 "Display LSA's internal information\n" JSON_STR
)
1175 bool uj
= use_json(argc
, argv
);
1176 struct listnode
*node
;
1177 struct ospf6
*ospf6
;
1179 uint32_t adv_router
= 0;
1181 const char *vrf_name
= NULL
;
1182 bool all_vrf
= false;
1185 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1192 type
= parse_type_spec(idx_lsa
, argc
, argv
);
1193 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
1194 level
= parse_show_level(idx_level
, argc
, argv
);
1196 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1197 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1198 adv_router
= ospf6
->router_id
;
1199 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
1200 &adv_router
, uj
, ospf6
);
1207 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1212 static int show_ospf6_border_routers_common(struct vty
*vty
, int argc
,
1213 struct cmd_token
**argv
,
1214 struct ospf6
*ospf6
, int idx_ipv4
,
1217 uint32_t adv_router
;
1218 struct ospf6_route
*ro
;
1219 struct prefix prefix
;
1222 if (argc
== idx_argc
) {
1223 if (strmatch(argv
[idx_ipv4
]->text
, "detail")) {
1224 for (ro
= ospf6_route_head(ospf6
->brouter_table
); ro
;
1225 ro
= ospf6_route_next(ro
))
1226 ospf6_route_show_detail(vty
, ro
, NULL
, false);
1228 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
1230 ospf6_linkstate_prefix(adv_router
, 0, &prefix
);
1231 ro
= ospf6_route_lookup(&prefix
, ospf6
->brouter_table
);
1234 "No Route found for Router ID: %s\n",
1235 argv
[idx_ipv4
]->arg
);
1239 ospf6_route_show_detail(vty
, ro
, NULL
, false);
1243 ospf6_brouter_show_header(vty
);
1245 for (ro
= ospf6_route_head(ospf6
->brouter_table
); ro
;
1246 ro
= ospf6_route_next(ro
))
1247 ospf6_brouter_show(vty
, ro
);
1253 DEFUN(show_ipv6_ospf6_border_routers
, show_ipv6_ospf6_border_routers_cmd
,
1254 "show ipv6 ospf6 [vrf <NAME|all>] border-routers [<A.B.C.D|detail>]",
1255 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1257 "Display routing table for ABR and ASBR\n"
1259 "Show detailed output\n")
1262 struct ospf6
*ospf6
= NULL
;
1263 struct listnode
*node
;
1264 const char *vrf_name
= NULL
;
1265 bool all_vrf
= false;
1269 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1275 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1276 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1277 show_ospf6_border_routers_common(vty
, argc
, argv
, ospf6
,
1278 idx_ipv4
, idx_argc
);
1285 OSPF6_CMD_CHECK_VRF(false, all_vrf
, ospf6
);
1291 DEFUN(show_ipv6_ospf6_linkstate
, show_ipv6_ospf6_linkstate_cmd
,
1292 "show ipv6 ospf6 [vrf <NAME|all>] linkstate <router A.B.C.D|network A.B.C.D A.B.C.D>",
1293 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1295 "Display linkstate routing table\n"
1296 "Display Router Entry\n"
1297 "Specify Router ID as IPv4 address notation\n"
1298 "Display Network Entry\n"
1299 "Specify Router ID as IPv4 address notation\n"
1300 "Specify Link state ID as IPv4 address notation\n")
1303 struct listnode
*node
, *nnode
;
1304 struct ospf6_area
*oa
;
1305 struct ospf6
*ospf6
= NULL
;
1306 const char *vrf_name
= NULL
;
1307 bool all_vrf
= false;
1310 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1314 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, nnode
, ospf6
)) {
1315 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1316 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, node
, oa
)) {
1318 "\n SPF Result in Area %s\n\n",
1320 ospf6_linkstate_table_show(vty
, idx_ipv4
, argc
,
1321 argv
, oa
->spf_table
);
1330 OSPF6_CMD_CHECK_VRF(false, all_vrf
, ospf6
);
1336 DEFUN(show_ipv6_ospf6_linkstate_detail
, show_ipv6_ospf6_linkstate_detail_cmd
,
1337 "show ipv6 ospf6 [vrf <NAME|all>] linkstate detail",
1338 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1340 "Display linkstate routing table\n"
1341 "Display detailed information\n")
1344 struct listnode
*node
;
1345 struct ospf6_area
*oa
;
1346 struct ospf6
*ospf6
= NULL
;
1347 const char *vrf_name
= NULL
;
1348 bool all_vrf
= false;
1351 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1355 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1356 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1357 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, node
, oa
)) {
1359 "\n SPF Result in Area %s\n\n",
1361 ospf6_linkstate_table_show(vty
, idx_detail
,
1372 OSPF6_CMD_CHECK_VRF(false, all_vrf
, ospf6
);
1377 /* Install ospf related commands. */
1378 void ospf6_init(struct event_loop
*master
)
1382 ospf6_interface_init();
1383 ospf6_neighbor_init();
1384 ospf6_zebra_init(master
);
1392 ospf6_gr_helper_config_init();
1394 /* initialize hooks for modifying filter rules */
1395 prefix_list_add_hook(ospf6_plist_update
);
1396 prefix_list_delete_hook(ospf6_plist_update
);
1397 access_list_add_hook(ospf6_filter_update
);
1398 access_list_delete_hook(ospf6_filter_update
);
1401 install_node(&debug_node
);
1403 install_element_ospf6_debug_message();
1404 install_element_ospf6_debug_lsa();
1405 install_element_ospf6_debug_interface();
1406 install_element_ospf6_debug_neighbor();
1407 install_element_ospf6_debug_zebra();
1408 install_element_ospf6_debug_spf();
1409 install_element_ospf6_debug_route();
1410 install_element_ospf6_debug_brouter();
1411 install_element_ospf6_debug_asbr();
1412 install_element_ospf6_debug_abr();
1413 install_element_ospf6_debug_flood();
1414 install_element_ospf6_debug_nssa();
1416 install_element_ospf6_clear_process();
1417 install_element_ospf6_clear_interface();
1419 install_element(ENABLE_NODE
, &show_debugging_ospf6_cmd
);
1421 install_element(VIEW_NODE
, &show_ipv6_ospf6_border_routers_cmd
);
1423 install_element(VIEW_NODE
, &show_ipv6_ospf6_linkstate_cmd
);
1424 install_element(VIEW_NODE
, &show_ipv6_ospf6_linkstate_detail_cmd
);
1426 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_cmd
);
1427 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_type_cmd
);
1428 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_id_cmd
);
1429 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_router_cmd
);
1430 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_type_id_cmd
);
1431 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_type_router_cmd
);
1432 install_element(VIEW_NODE
,
1433 &show_ipv6_ospf6_database_adv_router_linkstate_id_cmd
);
1434 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_id_router_cmd
);
1435 install_element(VIEW_NODE
,
1436 &show_ipv6_ospf6_database_type_id_router_cmd
);
1439 &show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd
);
1440 install_element(VIEW_NODE
,
1441 &show_ipv6_ospf6_database_self_originated_cmd
);
1442 install_element(VIEW_NODE
,
1443 &show_ipv6_ospf6_database_type_self_originated_cmd
);
1444 install_element(VIEW_NODE
,
1445 &show_ipv6_ospf6_database_type_id_self_originated_cmd
);
1448 &show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd
);
1449 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_aggr_router_cmd
);
1450 install_element_ospf6_debug_auth();
1451 ospf6_interface_auth_trailer_cmd_init();
1452 install_element_ospf6_clear_intf_auth();