2 * Copyright (C) 2003 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
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
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.
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
30 #include "ospf6_proto.h"
31 #include "ospf6_top.h"
32 #include "ospf6_network.h"
33 #include "ospf6_lsa.h"
34 #include "ospf6_lsdb.h"
35 #include "ospf6_message.h"
36 #include "ospf6_route.h"
37 #include "ospf6_zebra.h"
38 #include "ospf6_spf.h"
39 #include "ospf6_area.h"
40 #include "ospf6_interface.h"
41 #include "ospf6_neighbor.h"
42 #include "ospf6_intra.h"
43 #include "ospf6_asbr.h"
44 #include "ospf6_abr.h"
45 #include "ospf6_flood.h"
47 #include "ospf6_bfd.h"
50 #include "ospf6_nssa.h"
52 DEFINE_MGROUP(OSPF6D
, "ospf6d");
54 struct route_node
*route_prev(struct route_node
*node
)
56 struct route_node
*end
;
57 struct route_node
*prev
= NULL
;
62 route_lock_node(node
);
65 node
= route_next(node
);
67 route_unlock_node(node
);
71 route_unlock_node(end
);
73 route_lock_node(prev
);
78 static int config_write_ospf6_debug(struct vty
*vty
);
79 static struct cmd_node debug_node
= {
83 .config_write
= config_write_ospf6_debug
,
86 static int config_write_ospf6_debug(struct vty
*vty
)
88 config_write_ospf6_debug_message(vty
);
89 config_write_ospf6_debug_lsa(vty
);
90 config_write_ospf6_debug_zebra(vty
);
91 config_write_ospf6_debug_interface(vty
);
92 config_write_ospf6_debug_neighbor(vty
);
93 config_write_ospf6_debug_spf(vty
);
94 config_write_ospf6_debug_route(vty
);
95 config_write_ospf6_debug_brouter(vty
);
96 config_write_ospf6_debug_asbr(vty
);
97 config_write_ospf6_debug_abr(vty
);
98 config_write_ospf6_debug_flood(vty
);
99 config_write_ospf6_debug_nssa(vty
);
100 config_write_ospf6_debug_gr_helper(vty
);
105 DEFUN_NOSH (show_debugging_ospf6
,
106 show_debugging_ospf6_cmd
,
107 "show debugging [ospf6]",
112 vty_out(vty
, "OSPF6 debugging status:\n");
114 config_write_ospf6_debug(vty
);
119 #define AREA_LSDB_TITLE_FORMAT \
120 "\n Area Scoped Link State Database (Area %s)\n\n"
121 #define IF_LSDB_TITLE_FORMAT \
122 "\n I/F Scoped Link State Database (I/F %s in Area %s)\n\n"
123 #define AS_LSDB_TITLE_FORMAT "\n AS Scoped Link State Database\n\n"
125 static int parse_show_level(int idx_level
, int argc
, struct cmd_token
**argv
)
127 int level
= OSPF6_LSDB_SHOW_LEVEL_NORMAL
;
129 if (argc
> idx_level
) {
130 if (strmatch(argv
[idx_level
]->text
, "detail"))
131 level
= OSPF6_LSDB_SHOW_LEVEL_DETAIL
;
132 else if (strmatch(argv
[idx_level
]->text
, "dump"))
133 level
= OSPF6_LSDB_SHOW_LEVEL_DUMP
;
134 else if (strmatch(argv
[idx_level
]->text
, "internal"))
135 level
= OSPF6_LSDB_SHOW_LEVEL_INTERNAL
;
141 static uint16_t parse_type_spec(int idx_lsa
, int argc
, struct cmd_token
**argv
)
145 if (argc
> idx_lsa
) {
146 if (strmatch(argv
[idx_lsa
]->text
, "router"))
147 type
= htons(OSPF6_LSTYPE_ROUTER
);
148 else if (strmatch(argv
[idx_lsa
]->text
, "network"))
149 type
= htons(OSPF6_LSTYPE_NETWORK
);
150 else if (strmatch(argv
[idx_lsa
]->text
, "as-external"))
151 type
= htons(OSPF6_LSTYPE_AS_EXTERNAL
);
152 else if (strmatch(argv
[idx_lsa
]->text
, "intra-prefix"))
153 type
= htons(OSPF6_LSTYPE_INTRA_PREFIX
);
154 else if (strmatch(argv
[idx_lsa
]->text
, "inter-router"))
155 type
= htons(OSPF6_LSTYPE_INTER_ROUTER
);
156 else if (strmatch(argv
[idx_lsa
]->text
, "inter-prefix"))
157 type
= htons(OSPF6_LSTYPE_INTER_PREFIX
);
158 else if (strmatch(argv
[idx_lsa
]->text
, "link"))
159 type
= htons(OSPF6_LSTYPE_LINK
);
160 else if (strmatch(argv
[idx_lsa
]->text
, "type-7"))
161 type
= htons(OSPF6_LSTYPE_TYPE_7
);
167 void ospf6_lsdb_show(struct vty
*vty
, enum ospf_lsdb_show_level level
,
168 uint16_t *type
, uint32_t *id
, uint32_t *adv_router
,
169 struct ospf6_lsdb
*lsdb
, json_object
*json_obj
,
172 struct ospf6_lsa
*lsa
;
173 const struct route_node
*end
= NULL
;
174 void (*showfunc
)(struct vty
*, struct ospf6_lsa
*, json_object
*,
176 json_object
*json_array
= NULL
;
179 case OSPF6_LSDB_SHOW_LEVEL_DETAIL
:
180 showfunc
= ospf6_lsa_show
;
182 case OSPF6_LSDB_SHOW_LEVEL_INTERNAL
:
183 showfunc
= ospf6_lsa_show_internal
;
185 case OSPF6_LSDB_SHOW_LEVEL_DUMP
:
186 showfunc
= ospf6_lsa_show_dump
;
188 case OSPF6_LSDB_SHOW_LEVEL_NORMAL
:
190 showfunc
= ospf6_lsa_show_summary
;
194 json_array
= json_object_new_array();
196 if (type
&& id
&& adv_router
) {
197 lsa
= ospf6_lsdb_lookup(*type
, *id
, *adv_router
, lsdb
);
199 if (level
== OSPF6_LSDB_SHOW_LEVEL_NORMAL
)
200 ospf6_lsa_show(vty
, lsa
, json_array
, use_json
);
202 (*showfunc
)(vty
, lsa
, json_array
, use_json
);
206 json_object_object_add(json_obj
, "lsa", json_array
);
210 if ((level
== OSPF6_LSDB_SHOW_LEVEL_NORMAL
) && !use_json
)
211 ospf6_lsa_show_summary_header(vty
);
213 end
= ospf6_lsdb_head(lsdb
, !!type
+ !!(type
&& adv_router
),
214 type
? *type
: 0, adv_router
? *adv_router
: 0,
217 if ((!adv_router
|| lsa
->header
->adv_router
== *adv_router
)
218 && (!id
|| lsa
->header
->id
== *id
))
219 (*showfunc
)(vty
, lsa
, json_array
, use_json
);
220 lsa
= ospf6_lsdb_next(end
, lsa
);
224 json_object_object_add(json_obj
, "lsa", json_array
);
227 static void ospf6_lsdb_show_wrapper(struct vty
*vty
,
228 enum ospf_lsdb_show_level level
,
229 uint16_t *type
, uint32_t *id
,
230 uint32_t *adv_router
, bool uj
,
233 struct listnode
*i
, *j
;
234 struct ospf6
*o
= ospf6
;
235 struct ospf6_area
*oa
;
236 struct ospf6_interface
*oi
;
237 json_object
*json
= NULL
;
238 json_object
*json_array
= NULL
;
239 json_object
*json_obj
= NULL
;
242 json
= json_object_new_object();
243 json_array
= json_object_new_array();
245 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
247 json_obj
= json_object_new_object();
248 json_object_string_add(json_obj
, "areaId", oa
->name
);
250 vty_out(vty
, AREA_LSDB_TITLE_FORMAT
, oa
->name
);
251 ospf6_lsdb_show(vty
, level
, type
, id
, adv_router
, oa
->lsdb
,
254 json_object_array_add(json_array
, json_obj
);
257 json_object_object_add(json
, "areaScopedLinkStateDb",
261 json_array
= json_object_new_array();
262 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
263 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
)) {
265 json_obj
= json_object_new_object();
266 json_object_string_add(json_obj
, "areaId",
268 json_object_string_add(json_obj
, "interface",
269 oi
->interface
->name
);
271 vty_out(vty
, IF_LSDB_TITLE_FORMAT
,
272 oi
->interface
->name
, oa
->name
);
273 ospf6_lsdb_show(vty
, level
, type
, id
, adv_router
,
274 oi
->lsdb
, json_obj
, uj
);
276 json_object_array_add(json_array
, json_obj
);
280 json_object_object_add(json
, "interfaceScopedLinkStateDb",
283 json_array
= json_object_new_array();
284 json_obj
= json_object_new_object();
286 vty_out(vty
, AS_LSDB_TITLE_FORMAT
);
288 ospf6_lsdb_show(vty
, level
, type
, id
, adv_router
, o
->lsdb
, json_obj
,
292 json_object_array_add(json_array
, json_obj
);
293 json_object_object_add(json
, "asScopedLinkStateDb", json_array
);
300 static void ospf6_lsdb_type_show_wrapper(struct vty
*vty
,
301 enum ospf_lsdb_show_level level
,
302 uint16_t *type
, uint32_t *id
,
303 uint32_t *adv_router
, bool uj
,
306 struct listnode
*i
, *j
;
307 struct ospf6
*o
= ospf6
;
308 struct ospf6_area
*oa
;
309 struct ospf6_interface
*oi
;
310 json_object
*json
= NULL
;
311 json_object
*json_array
= NULL
;
312 json_object
*json_obj
= NULL
;
315 json
= json_object_new_object();
316 json_array
= json_object_new_array();
319 switch (OSPF6_LSA_SCOPE(*type
)) {
320 case OSPF6_SCOPE_AREA
:
321 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
323 json_obj
= json_object_new_object();
324 json_object_string_add(json_obj
, "areaId",
327 vty_out(vty
, AREA_LSDB_TITLE_FORMAT
, oa
->name
);
329 ospf6_lsdb_show(vty
, level
, type
, id
, adv_router
,
330 oa
->lsdb
, json_obj
, uj
);
332 json_object_array_add(json_array
, json_obj
);
335 json_object_object_add(json
, "areaScopedLinkStateDb",
339 case OSPF6_SCOPE_LINKLOCAL
:
340 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
341 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
)) {
343 json_obj
= json_object_new_object();
344 json_object_string_add(
345 json_obj
, "areaId", oa
->name
);
346 json_object_string_add(
347 json_obj
, "interface",
348 oi
->interface
->name
);
350 vty_out(vty
, IF_LSDB_TITLE_FORMAT
,
351 oi
->interface
->name
, oa
->name
);
353 ospf6_lsdb_show(vty
, level
, type
, id
,
354 adv_router
, oi
->lsdb
, json_obj
,
358 json_object_array_add(json_array
,
363 json_object_object_add(
364 json
, "interfaceScopedLinkStateDb", json_array
);
369 json_obj
= json_object_new_object();
371 vty_out(vty
, AS_LSDB_TITLE_FORMAT
);
373 ospf6_lsdb_show(vty
, level
, type
, id
, adv_router
, o
->lsdb
,
376 json_object_array_add(json_array
, json_obj
);
377 json_object_object_add(json
, "asScopedLinkStateDb",
392 DEFUN(show_ipv6_ospf6_database
, show_ipv6_ospf6_database_cmd
,
393 "show ipv6 ospf6 [vrf <NAME|all>] database [<detail|dump|internal>] [json]",
394 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
396 "Display Link state database\n"
397 "Display details of LSAs\n"
399 "Display LSA's internal information\n" JSON_STR
)
403 struct listnode
*node
;
405 const char *vrf_name
= NULL
;
406 bool all_vrf
= false;
408 bool uj
= use_json(argc
, argv
);
410 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
414 level
= parse_show_level(idx_level
, argc
, argv
);
415 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
416 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
417 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, NULL
, NULL
,
424 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
429 DEFUN(show_ipv6_ospf6_database_type
, show_ipv6_ospf6_database_type_cmd
,
430 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> [<detail|dump|internal>] [json]",
431 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
433 "Display Link state database\n"
434 "Display Router LSAs\n"
435 "Display Network LSAs\n"
436 "Display Inter-Area-Prefix LSAs\n"
437 "Display Inter-Area-Router LSAs\n"
438 "Display As-External LSAs\n"
439 "Display Group-Membership LSAs\n"
440 "Display Type-7 LSAs\n"
441 "Display Link LSAs\n"
442 "Display Intra-Area-Prefix LSAs\n"
443 "Display details of LSAs\n"
445 "Display LSA's internal information\n" JSON_STR
)
450 bool uj
= use_json(argc
, argv
);
451 struct listnode
*node
;
454 const char *vrf_name
= NULL
;
455 bool all_vrf
= false;
458 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
464 type
= parse_type_spec(idx_lsa
, argc
, argv
);
465 level
= parse_show_level(idx_level
, argc
, argv
);
467 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
468 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
469 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, NULL
,
476 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
481 DEFUN(show_ipv6_ospf6_database_id
, show_ipv6_ospf6_database_id_cmd
,
482 "show ipv6 ospf6 [vrf <NAME|all>] database <*|linkstate-id> A.B.C.D [<detail|dump|internal>] [json]",
483 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
485 "Display Link state database\n"
486 "Any Link state Type\n"
487 "Search by Link state ID\n"
488 "Specify Link state ID as IPv4 address notation\n"
489 "Display details of LSAs\n"
491 "Display LSA's internal information\n" JSON_STR
)
496 bool uj
= use_json(argc
, argv
);
497 struct listnode
*node
;
500 const char *vrf_name
= NULL
;
501 bool all_vrf
= false;
504 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
505 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
506 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &id
);
508 level
= parse_show_level(idx_level
, argc
, argv
);
510 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
511 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
512 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, &id
, NULL
, uj
,
519 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
524 DEFUN(show_ipv6_ospf6_database_router
, show_ipv6_ospf6_database_router_cmd
,
525 "show ipv6 ospf6 [vrf <NAME|all>] database <*|adv-router> * A.B.C.D <detail|dump|internal> [json]",
526 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
528 "Display Link state database\n"
529 "Any Link state Type\n"
530 "Search by Advertising Router\n"
531 "Any Link state ID\n"
532 "Specify Advertising Router as IPv4 address notation\n"
533 "Display details of LSAs\n"
535 "Display LSA's internal information\n" JSON_STR
)
540 struct listnode
*node
;
542 uint32_t adv_router
= 0;
543 const char *vrf_name
= NULL
;
544 bool all_vrf
= false;
546 bool uj
= use_json(argc
, argv
);
548 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
554 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
555 level
= parse_show_level(idx_level
, argc
, argv
);
557 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
558 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
559 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, NULL
,
560 &adv_router
, uj
, ospf6
);
566 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
571 static int ipv6_ospf6_database_aggr_router_common(struct vty
*vty
,
575 int level
= OSPF6_LSDB_SHOW_LEVEL_DETAIL
;
576 uint16_t type
= htons(OSPF6_LSTYPE_ROUTER
);
578 struct ospf6_area
*oa
;
579 struct ospf6_lsdb
*lsdb
;
581 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, i
, oa
)) {
582 if (adv_router
== ospf6
->router_id
)
583 lsdb
= oa
->lsdb_self
;
586 if (ospf6_create_single_router_lsa(oa
, lsdb
, adv_router
)
588 vty_out(vty
, "Adv router is not found in LSDB.");
591 ospf6_lsdb_show(vty
, level
, &type
, NULL
, NULL
,
592 oa
->temp_router_lsa_lsdb
, NULL
, false);
593 /* Remove the temp cache */
594 ospf6_remove_temp_router_lsa(oa
);
602 show_ipv6_ospf6_database_aggr_router
,
603 show_ipv6_ospf6_database_aggr_router_cmd
,
604 "show ipv6 ospf6 [vrf <NAME|all>] database aggr adv-router A.B.C.D",
605 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
607 "Display Link state database\n"
608 "Aggregated Router LSA\n"
609 "Search by Advertising Router\n"
610 "Specify Advertising Router as IPv4 address notation\n")
613 struct listnode
*node
;
615 uint32_t adv_router
= 0;
616 const char *vrf_name
= NULL
;
617 bool all_vrf
= false;
620 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
624 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
626 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
627 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
628 ipv6_ospf6_database_aggr_router_common(vty
, adv_router
,
636 OSPF6_CMD_CHECK_VRF(false, all_vrf
, ospf6
);
641 DEFUN(show_ipv6_ospf6_database_type_id
, show_ipv6_ospf6_database_type_id_cmd
,
642 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> linkstate-id A.B.C.D [<detail|dump|internal>] [json]",
643 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
645 "Display Link state database\n"
646 "Display Router LSAs\n"
647 "Display Network LSAs\n"
648 "Display Inter-Area-Prefix LSAs\n"
649 "Display Inter-Area-Router LSAs\n"
650 "Display As-External LSAs\n"
651 "Display Group-Membership LSAs\n"
652 "Display Type-7 LSAs\n"
653 "Display Link LSAs\n"
654 "Display Intra-Area-Prefix LSAs\n"
655 "Search by Link state ID\n"
656 "Specify Link state ID as IPv4 address notation\n"
657 "Display details of LSAs\n"
659 "Display LSA's internal information\n" JSON_STR
)
665 bool uj
= use_json(argc
, argv
);
666 struct listnode
*node
;
670 const char *vrf_name
= NULL
;
671 bool all_vrf
= false;
674 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
681 type
= parse_type_spec(idx_lsa
, argc
, argv
);
682 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &id
);
683 level
= parse_show_level(idx_level
, argc
, argv
);
685 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
686 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
687 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
694 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
699 DEFUN(show_ipv6_ospf6_database_type_router
,
700 show_ipv6_ospf6_database_type_router_cmd
,
701 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> <*|adv-router> A.B.C.D [<detail|dump|internal>] [json]",
702 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
704 "Display Link state database\n"
705 "Display Router LSAs\n"
706 "Display Network LSAs\n"
707 "Display Inter-Area-Prefix LSAs\n"
708 "Display Inter-Area-Router LSAs\n"
709 "Display As-External LSAs\n"
710 "Display Group-Membership LSAs\n"
711 "Display Type-7 LSAs\n"
712 "Display Link LSAs\n"
713 "Display Intra-Area-Prefix LSAs\n"
714 "Any Link state ID\n"
715 "Search by Advertising Router\n"
716 "Specify Advertising Router as IPv4 address notation\n"
717 "Display details of LSAs\n"
719 "Display LSA's internal information\n" JSON_STR
)
725 bool uj
= use_json(argc
, argv
);
726 struct listnode
*node
;
729 uint32_t adv_router
= 0;
730 const char *vrf_name
= NULL
;
731 bool all_vrf
= false;
734 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
741 type
= parse_type_spec(idx_lsa
, argc
, argv
);
742 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
743 level
= parse_show_level(idx_level
, argc
, argv
);
745 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
746 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
747 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, NULL
,
748 &adv_router
, uj
, ospf6
);
755 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
760 DEFUN(show_ipv6_ospf6_database_id_router
,
761 show_ipv6_ospf6_database_id_router_cmd
,
762 "show ipv6 ospf6 [vrf <NAME|all>] database * A.B.C.D A.B.C.D [<detail|dump|internal>] [json]",
763 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
765 "Display Link state database\n"
766 "Any Link state Type\n"
767 "Specify Link state ID as IPv4 address notation\n"
768 "Specify Advertising Router as IPv4 address notation\n"
769 "Display details of LSAs\n"
771 "Display LSA's internal information\n" JSON_STR
)
777 bool uj
= use_json(argc
, argv
);
778 struct listnode
*node
;
781 uint32_t adv_router
= 0;
782 const char *vrf_name
= NULL
;
783 bool all_vrf
= false;
786 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
793 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
794 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
795 level
= parse_show_level(idx_level
, argc
, argv
);
797 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
798 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
799 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, &id
,
800 &adv_router
, uj
, ospf6
);
806 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
811 DEFUN(show_ipv6_ospf6_database_adv_router_linkstate_id
,
812 show_ipv6_ospf6_database_adv_router_linkstate_id_cmd
,
813 "show ipv6 ospf6 [vrf <NAME|all>] database adv-router A.B.C.D linkstate-id A.B.C.D [<detail|dump|internal>] [json]",
814 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
816 "Display Link state database\n"
817 "Search by Advertising Router\n"
818 "Specify Advertising Router as IPv4 address notation\n"
819 "Search by Link state ID\n"
820 "Specify Link state ID as IPv4 address notation\n"
821 "Display details of LSAs\n"
823 "Display LSA's internal information\n" JSON_STR
)
829 bool uj
= use_json(argc
, argv
);
830 struct listnode
*node
;
833 uint32_t adv_router
= 0;
834 const char *vrf_name
= NULL
;
835 bool all_vrf
= false;
838 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
844 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
845 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
846 level
= parse_show_level(idx_level
, argc
, argv
);
848 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
849 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
850 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, &id
,
851 &adv_router
, uj
, ospf6
);
857 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
862 DEFUN(show_ipv6_ospf6_database_type_id_router
,
863 show_ipv6_ospf6_database_type_id_router_cmd
,
864 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> A.B.C.D A.B.C.D [<dump|internal>] [json]",
865 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
867 "Display Link state database\n"
868 "Display Router LSAs\n"
869 "Display Network LSAs\n"
870 "Display Inter-Area-Prefix LSAs\n"
871 "Display Inter-Area-Router LSAs\n"
872 "Display As-External LSAs\n"
873 "Display Group-Membership LSAs\n"
874 "Display Type-7 LSAs\n"
875 "Display Link LSAs\n"
876 "Display Intra-Area-Prefix LSAs\n"
877 "Specify Link state ID as IPv4 address notation\n"
878 "Specify Advertising Router as IPv4 address notation\n"
880 "Display LSA's internal information\n" JSON_STR
)
887 bool uj
= use_json(argc
, argv
);
888 struct listnode
*node
;
892 uint32_t adv_router
= 0;
893 const char *vrf_name
= NULL
;
894 bool all_vrf
= false;
897 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
905 type
= parse_type_spec(idx_lsa
, argc
, argv
);
906 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
907 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
908 level
= parse_show_level(idx_level
, argc
, argv
);
910 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
911 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
912 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
913 &adv_router
, uj
, ospf6
);
920 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
926 DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id
,
927 show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd
,
928 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> adv-router A.B.C.D linkstate-id A.B.C.D [<dump|internal>] [json]",
934 "Display Link state database\n"
935 "Display Router LSAs\n"
936 "Display Network LSAs\n"
937 "Display Inter-Area-Prefix LSAs\n"
938 "Display Inter-Area-Router LSAs\n"
939 "Display As-External LSAs\n"
940 "Display Group-Membership LSAs\n"
941 "Display Type-7 LSAs\n"
942 "Display Link LSAs\n"
943 "Display Intra-Area-Prefix LSAs\n"
944 "Search by Advertising Router\n"
945 "Specify Advertising Router as IPv4 address notation\n"
946 "Search by Link state ID\n"
947 "Specify Link state ID as IPv4 address notation\n"
949 "Display LSA's internal information\n"
957 bool uj
= use_json(argc
, argv
);
958 struct listnode
*node
;
962 uint32_t adv_router
= 0;
963 const char *vrf_name
= NULL
;
964 bool all_vrf
= false;
967 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
975 type
= parse_type_spec(idx_lsa
, argc
, argv
);
976 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
977 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
978 level
= parse_show_level(idx_level
, argc
, argv
);
980 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
981 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
982 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
983 &adv_router
, uj
, ospf6
);
990 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
995 DEFUN(show_ipv6_ospf6_database_self_originated
,
996 show_ipv6_ospf6_database_self_originated_cmd
,
997 "show ipv6 ospf6 [vrf <NAME|all>] database self-originated [<detail|dump|internal>] [json]",
998 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1000 "Display Link state database\n"
1001 "Display Self-originated LSAs\n"
1002 "Display details of LSAs\n"
1004 "Display LSA's internal information\n" JSON_STR
)
1008 struct listnode
*node
;
1009 struct ospf6
*ospf6
;
1010 const char *vrf_name
= NULL
;
1011 bool all_vrf
= false;
1013 uint32_t adv_router
= 0;
1014 bool uj
= use_json(argc
, argv
);
1016 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1020 level
= parse_show_level(idx_level
, argc
, argv
);
1022 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1023 adv_router
= ospf6
->router_id
;
1024 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1025 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, NULL
,
1026 &adv_router
, uj
, ospf6
);
1033 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1039 DEFUN(show_ipv6_ospf6_database_type_self_originated
,
1040 show_ipv6_ospf6_database_type_self_originated_cmd
,
1041 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> self-originated [<detail|dump|internal>] [json]",
1042 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1044 "Display Link state database\n"
1045 "Display Router LSAs\n"
1046 "Display Network LSAs\n"
1047 "Display Inter-Area-Prefix LSAs\n"
1048 "Display Inter-Area-Router LSAs\n"
1049 "Display As-External LSAs\n"
1050 "Display Group-Membership LSAs\n"
1051 "Display Type-7 LSAs\n"
1052 "Display Link LSAs\n"
1053 "Display Intra-Area-Prefix LSAs\n"
1054 "Display Self-originated LSAs\n"
1055 "Display details of LSAs\n"
1057 "Display LSA's internal information\n" JSON_STR
)
1062 struct listnode
*node
;
1063 struct ospf6
*ospf6
;
1065 uint32_t adv_router
= 0;
1066 bool uj
= use_json(argc
, argv
);
1068 const char *vrf_name
= NULL
;
1069 bool all_vrf
= false;
1072 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1078 type
= parse_type_spec(idx_lsa
, argc
, argv
);
1079 level
= parse_show_level(idx_level
, argc
, argv
);
1081 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1082 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1083 adv_router
= ospf6
->router_id
;
1084 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, NULL
,
1085 &adv_router
, uj
, ospf6
);
1092 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1097 DEFUN(show_ipv6_ospf6_database_type_self_originated_linkstate_id
,
1098 show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd
,
1099 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> self-originated linkstate-id A.B.C.D [<detail|dump|internal>] [json]",
1100 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1102 "Display Link state database\n"
1103 "Display Router LSAs\n"
1104 "Display Network LSAs\n"
1105 "Display Inter-Area-Prefix LSAs\n"
1106 "Display Inter-Area-Router LSAs\n"
1107 "Display As-External LSAs\n"
1108 "Display Group-Membership LSAs\n"
1109 "Display Type-7 LSAs\n"
1110 "Display Link LSAs\n"
1111 "Display Intra-Area-Prefix LSAs\n"
1112 "Display Self-originated LSAs\n"
1113 "Search by Link state ID\n"
1114 "Specify Link state ID as IPv4 address notation\n"
1115 "Display details of LSAs\n"
1117 "Display LSA's internal information\n" JSON_STR
)
1123 bool uj
= use_json(argc
, argv
);
1124 struct listnode
*node
;
1125 struct ospf6
*ospf6
;
1127 uint32_t adv_router
= 0;
1129 const char *vrf_name
= NULL
;
1130 bool all_vrf
= false;
1133 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1141 type
= parse_type_spec(idx_lsa
, argc
, argv
);
1142 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
1143 level
= parse_show_level(idx_level
, argc
, argv
);
1145 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1146 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1147 adv_router
= ospf6
->router_id
;
1148 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
1149 &adv_router
, uj
, ospf6
);
1156 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1161 DEFUN(show_ipv6_ospf6_database_type_id_self_originated
,
1162 show_ipv6_ospf6_database_type_id_self_originated_cmd
,
1163 "show ipv6 ospf6 [vrf <NAME|all>] database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> A.B.C.D self-originated [<detail|dump|internal>] [json]",
1164 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1166 "Display Link state database\n"
1167 "Display Router LSAs\n"
1168 "Display Network LSAs\n"
1169 "Display Inter-Area-Prefix LSAs\n"
1170 "Display Inter-Area-Router LSAs\n"
1171 "Display As-External LSAs\n"
1172 "Display Group-Membership LSAs\n"
1173 "Display Type-7 LSAs\n"
1174 "Display Link LSAs\n"
1175 "Display Intra-Area-Prefix LSAs\n"
1176 "Specify Link state ID as IPv4 address notation\n"
1177 "Display Self-originated LSAs\n"
1178 "Display details of LSAs\n"
1180 "Display LSA's internal information\n" JSON_STR
)
1186 bool uj
= use_json(argc
, argv
);
1187 struct listnode
*node
;
1188 struct ospf6
*ospf6
;
1190 uint32_t adv_router
= 0;
1192 const char *vrf_name
= NULL
;
1193 bool all_vrf
= false;
1196 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1203 type
= parse_type_spec(idx_lsa
, argc
, argv
);
1204 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
1205 level
= parse_show_level(idx_level
, argc
, argv
);
1207 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1208 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1209 adv_router
= ospf6
->router_id
;
1210 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
1211 &adv_router
, uj
, ospf6
);
1218 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1223 static int show_ospf6_border_routers_common(struct vty
*vty
, int argc
,
1224 struct cmd_token
**argv
,
1225 struct ospf6
*ospf6
, int idx_ipv4
,
1228 uint32_t adv_router
;
1229 struct ospf6_route
*ro
;
1230 struct prefix prefix
;
1233 if (argc
== idx_argc
) {
1234 if (strmatch(argv
[idx_ipv4
]->text
, "detail")) {
1235 for (ro
= ospf6_route_head(ospf6
->brouter_table
); ro
;
1236 ro
= ospf6_route_next(ro
))
1237 ospf6_route_show_detail(vty
, ro
, NULL
, false);
1239 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
1241 ospf6_linkstate_prefix(adv_router
, 0, &prefix
);
1242 ro
= ospf6_route_lookup(&prefix
, ospf6
->brouter_table
);
1245 "No Route found for Router ID: %s\n",
1246 argv
[idx_ipv4
]->arg
);
1250 ospf6_route_show_detail(vty
, ro
, NULL
, false);
1254 ospf6_brouter_show_header(vty
);
1256 for (ro
= ospf6_route_head(ospf6
->brouter_table
); ro
;
1257 ro
= ospf6_route_next(ro
))
1258 ospf6_brouter_show(vty
, ro
);
1264 DEFUN(show_ipv6_ospf6_border_routers
, show_ipv6_ospf6_border_routers_cmd
,
1265 "show ipv6 ospf6 [vrf <NAME|all>] border-routers [<A.B.C.D|detail>]",
1266 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1268 "Display routing table for ABR and ASBR\n"
1270 "Show detailed output\n")
1273 struct ospf6
*ospf6
= NULL
;
1274 struct listnode
*node
;
1275 const char *vrf_name
= NULL
;
1276 bool all_vrf
= false;
1280 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1286 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1287 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1288 show_ospf6_border_routers_common(vty
, argc
, argv
, ospf6
,
1289 idx_ipv4
, idx_argc
);
1296 OSPF6_CMD_CHECK_VRF(false, all_vrf
, ospf6
);
1302 DEFUN(show_ipv6_ospf6_linkstate
, show_ipv6_ospf6_linkstate_cmd
,
1303 "show ipv6 ospf6 [vrf <NAME|all>] linkstate <router A.B.C.D|network A.B.C.D A.B.C.D>",
1304 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1306 "Display linkstate routing table\n"
1307 "Display Router Entry\n"
1308 "Specify Router ID as IPv4 address notation\n"
1309 "Display Network Entry\n"
1310 "Specify Router ID as IPv4 address notation\n"
1311 "Specify Link state ID as IPv4 address notation\n")
1314 struct listnode
*node
, *nnode
;
1315 struct ospf6_area
*oa
;
1316 struct ospf6
*ospf6
= NULL
;
1317 const char *vrf_name
= NULL
;
1318 bool all_vrf
= false;
1321 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1325 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, nnode
, ospf6
)) {
1326 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1327 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, node
, oa
)) {
1329 "\n SPF Result in Area %s\n\n",
1331 ospf6_linkstate_table_show(vty
, idx_ipv4
, argc
,
1332 argv
, oa
->spf_table
);
1341 OSPF6_CMD_CHECK_VRF(false, all_vrf
, ospf6
);
1347 DEFUN(show_ipv6_ospf6_linkstate_detail
, show_ipv6_ospf6_linkstate_detail_cmd
,
1348 "show ipv6 ospf6 [vrf <NAME|all>] linkstate detail",
1349 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1351 "Display linkstate routing table\n"
1352 "Display detailed information\n")
1355 struct listnode
*node
;
1356 struct ospf6_area
*oa
;
1357 struct ospf6
*ospf6
= NULL
;
1358 const char *vrf_name
= NULL
;
1359 bool all_vrf
= false;
1362 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1366 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1367 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1368 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, node
, oa
)) {
1370 "\n SPF Result in Area %s\n\n",
1372 ospf6_linkstate_table_show(vty
, idx_detail
,
1383 OSPF6_CMD_CHECK_VRF(false, all_vrf
, ospf6
);
1388 /* Install ospf related commands. */
1389 void ospf6_init(struct thread_master
*master
)
1393 ospf6_interface_init();
1394 ospf6_neighbor_init();
1395 ospf6_zebra_init(master
);
1403 ospf6_gr_helper_config_init();
1405 /* initialize hooks for modifying filter rules */
1406 prefix_list_add_hook(ospf6_plist_update
);
1407 prefix_list_delete_hook(ospf6_plist_update
);
1408 access_list_add_hook(ospf6_filter_update
);
1409 access_list_delete_hook(ospf6_filter_update
);
1412 install_node(&debug_node
);
1414 install_element_ospf6_debug_message();
1415 install_element_ospf6_debug_lsa();
1416 install_element_ospf6_debug_interface();
1417 install_element_ospf6_debug_neighbor();
1418 install_element_ospf6_debug_zebra();
1419 install_element_ospf6_debug_spf();
1420 install_element_ospf6_debug_route();
1421 install_element_ospf6_debug_brouter();
1422 install_element_ospf6_debug_asbr();
1423 install_element_ospf6_debug_abr();
1424 install_element_ospf6_debug_flood();
1425 install_element_ospf6_debug_nssa();
1427 install_element_ospf6_clear_process();
1428 install_element_ospf6_clear_interface();
1430 install_element(ENABLE_NODE
, &show_debugging_ospf6_cmd
);
1432 install_element(VIEW_NODE
, &show_ipv6_ospf6_border_routers_cmd
);
1434 install_element(VIEW_NODE
, &show_ipv6_ospf6_linkstate_cmd
);
1435 install_element(VIEW_NODE
, &show_ipv6_ospf6_linkstate_detail_cmd
);
1437 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_cmd
);
1438 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_type_cmd
);
1439 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_id_cmd
);
1440 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_router_cmd
);
1441 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_type_id_cmd
);
1442 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_type_router_cmd
);
1443 install_element(VIEW_NODE
,
1444 &show_ipv6_ospf6_database_adv_router_linkstate_id_cmd
);
1445 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_id_router_cmd
);
1446 install_element(VIEW_NODE
,
1447 &show_ipv6_ospf6_database_type_id_router_cmd
);
1450 &show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd
);
1451 install_element(VIEW_NODE
,
1452 &show_ipv6_ospf6_database_self_originated_cmd
);
1453 install_element(VIEW_NODE
,
1454 &show_ipv6_ospf6_database_type_self_originated_cmd
);
1455 install_element(VIEW_NODE
,
1456 &show_ipv6_ospf6_database_type_id_self_originated_cmd
);
1459 &show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd
);
1460 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_aggr_router_cmd
);