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
,
427 DEFUN(show_ipv6_ospf6_database_type
, show_ipv6_ospf6_database_type_cmd
,
428 "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]",
429 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
431 "Display Link state database\n"
432 "Display Router LSAs\n"
433 "Display Network LSAs\n"
434 "Display Inter-Area-Prefix LSAs\n"
435 "Display Inter-Area-Router LSAs\n"
436 "Display As-External LSAs\n"
437 "Display Group-Membership LSAs\n"
438 "Display Type-7 LSAs\n"
439 "Display Link LSAs\n"
440 "Display Intra-Area-Prefix LSAs\n"
441 "Display details of LSAs\n"
443 "Display LSA's internal information\n" JSON_STR
)
448 bool uj
= use_json(argc
, argv
);
449 struct listnode
*node
;
452 const char *vrf_name
= NULL
;
453 bool all_vrf
= false;
456 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
462 type
= parse_type_spec(idx_lsa
, argc
, argv
);
463 level
= parse_show_level(idx_level
, argc
, argv
);
465 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
466 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
467 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, NULL
,
477 DEFUN(show_ipv6_ospf6_database_id
, show_ipv6_ospf6_database_id_cmd
,
478 "show ipv6 ospf6 [vrf <NAME|all>] database <*|linkstate-id> A.B.C.D [<detail|dump|internal>] [json]",
479 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
481 "Display Link state database\n"
482 "Any Link state Type\n"
483 "Search by Link state ID\n"
484 "Specify Link state ID as IPv4 address notation\n"
485 "Display details of LSAs\n"
487 "Display LSA's internal information\n" JSON_STR
)
492 bool uj
= use_json(argc
, argv
);
493 struct listnode
*node
;
496 const char *vrf_name
= NULL
;
497 bool all_vrf
= false;
500 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
501 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
502 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &id
);
504 level
= parse_show_level(idx_level
, argc
, argv
);
506 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
507 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
508 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, &id
, NULL
, uj
,
518 DEFUN(show_ipv6_ospf6_database_router
, show_ipv6_ospf6_database_router_cmd
,
519 "show ipv6 ospf6 [vrf <NAME|all>] database <*|adv-router> * A.B.C.D <detail|dump|internal> [json]",
520 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
522 "Display Link state database\n"
523 "Any Link state Type\n"
524 "Search by Advertising Router\n"
525 "Any Link state ID\n"
526 "Specify Advertising Router as IPv4 address notation\n"
527 "Display details of LSAs\n"
529 "Display LSA's internal information\n" JSON_STR
)
534 struct listnode
*node
;
536 uint32_t adv_router
= 0;
537 const char *vrf_name
= NULL
;
538 bool all_vrf
= false;
540 bool uj
= use_json(argc
, argv
);
542 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
548 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
549 level
= parse_show_level(idx_level
, argc
, argv
);
551 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
552 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
553 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, NULL
,
554 &adv_router
, uj
, ospf6
);
563 static int ipv6_ospf6_database_aggr_router_common(struct vty
*vty
,
567 int level
= OSPF6_LSDB_SHOW_LEVEL_DETAIL
;
568 uint16_t type
= htons(OSPF6_LSTYPE_ROUTER
);
570 struct ospf6_area
*oa
;
571 struct ospf6_lsdb
*lsdb
;
573 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, i
, oa
)) {
574 if (adv_router
== ospf6
->router_id
)
575 lsdb
= oa
->lsdb_self
;
578 if (ospf6_create_single_router_lsa(oa
, lsdb
, adv_router
)
580 vty_out(vty
, "Adv router is not found in LSDB.");
583 ospf6_lsdb_show(vty
, level
, &type
, NULL
, NULL
,
584 oa
->temp_router_lsa_lsdb
, NULL
, false);
585 /* Remove the temp cache */
586 ospf6_remove_temp_router_lsa(oa
);
594 show_ipv6_ospf6_database_aggr_router
,
595 show_ipv6_ospf6_database_aggr_router_cmd
,
596 "show ipv6 ospf6 [vrf <NAME|all>] database aggr adv-router A.B.C.D",
597 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
599 "Display Link state database\n"
600 "Aggregated Router LSA\n"
601 "Search by Advertising Router\n"
602 "Specify Advertising Router as IPv4 address notation\n")
605 struct listnode
*node
;
607 uint32_t adv_router
= 0;
608 const char *vrf_name
= NULL
;
609 bool all_vrf
= false;
612 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
616 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
618 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
619 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
620 ipv6_ospf6_database_aggr_router_common(vty
, adv_router
,
631 DEFUN(show_ipv6_ospf6_database_type_id
, show_ipv6_ospf6_database_type_id_cmd
,
632 "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]",
633 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
635 "Display Link state database\n"
636 "Display Router LSAs\n"
637 "Display Network LSAs\n"
638 "Display Inter-Area-Prefix LSAs\n"
639 "Display Inter-Area-Router LSAs\n"
640 "Display As-External LSAs\n"
641 "Display Group-Membership LSAs\n"
642 "Display Type-7 LSAs\n"
643 "Display Link LSAs\n"
644 "Display Intra-Area-Prefix LSAs\n"
645 "Search by Link state ID\n"
646 "Specify Link state ID as IPv4 address notation\n"
647 "Display details of LSAs\n"
649 "Display LSA's internal information\n" JSON_STR
)
655 bool uj
= use_json(argc
, argv
);
656 struct listnode
*node
;
660 const char *vrf_name
= NULL
;
661 bool all_vrf
= false;
664 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
671 type
= parse_type_spec(idx_lsa
, argc
, argv
);
672 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &id
);
673 level
= parse_show_level(idx_level
, argc
, argv
);
675 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
676 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
677 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
687 DEFUN(show_ipv6_ospf6_database_type_router
,
688 show_ipv6_ospf6_database_type_router_cmd
,
689 "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]",
690 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
692 "Display Link state database\n"
693 "Display Router LSAs\n"
694 "Display Network LSAs\n"
695 "Display Inter-Area-Prefix LSAs\n"
696 "Display Inter-Area-Router LSAs\n"
697 "Display As-External LSAs\n"
698 "Display Group-Membership LSAs\n"
699 "Display Type-7 LSAs\n"
700 "Display Link LSAs\n"
701 "Display Intra-Area-Prefix LSAs\n"
702 "Any Link state ID\n"
703 "Search by Advertising Router\n"
704 "Specify Advertising Router as IPv4 address notation\n"
705 "Display details of LSAs\n"
707 "Display LSA's internal information\n" JSON_STR
)
713 bool uj
= use_json(argc
, argv
);
714 struct listnode
*node
;
717 uint32_t adv_router
= 0;
718 const char *vrf_name
= NULL
;
719 bool all_vrf
= false;
722 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
729 type
= parse_type_spec(idx_lsa
, argc
, argv
);
730 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
731 level
= parse_show_level(idx_level
, argc
, argv
);
733 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
734 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
735 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, NULL
,
736 &adv_router
, uj
, ospf6
);
746 DEFUN(show_ipv6_ospf6_database_id_router
,
747 show_ipv6_ospf6_database_id_router_cmd
,
748 "show ipv6 ospf6 [vrf <NAME|all>] database * A.B.C.D A.B.C.D [<detail|dump|internal>] [json]",
749 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
751 "Display Link state database\n"
752 "Any Link state Type\n"
753 "Specify Link state ID as IPv4 address notation\n"
754 "Specify Advertising Router as IPv4 address notation\n"
755 "Display details of LSAs\n"
757 "Display LSA's internal information\n" JSON_STR
)
763 bool uj
= use_json(argc
, argv
);
764 struct listnode
*node
;
767 uint32_t adv_router
= 0;
768 const char *vrf_name
= NULL
;
769 bool all_vrf
= false;
772 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
779 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
780 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
781 level
= parse_show_level(idx_level
, argc
, argv
);
783 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
784 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
785 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, &id
,
786 &adv_router
, uj
, ospf6
);
795 DEFUN(show_ipv6_ospf6_database_adv_router_linkstate_id
,
796 show_ipv6_ospf6_database_adv_router_linkstate_id_cmd
,
797 "show ipv6 ospf6 [vrf <NAME|all>] database adv-router A.B.C.D linkstate-id A.B.C.D [<detail|dump|internal>] [json]",
798 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
800 "Display Link state database\n"
801 "Search by Advertising Router\n"
802 "Specify Advertising Router as IPv4 address notation\n"
803 "Search by Link state ID\n"
804 "Specify Link state ID as IPv4 address notation\n"
805 "Display details of LSAs\n"
807 "Display LSA's internal information\n" JSON_STR
)
813 bool uj
= use_json(argc
, argv
);
814 struct listnode
*node
;
817 uint32_t adv_router
= 0;
818 const char *vrf_name
= NULL
;
819 bool all_vrf
= false;
822 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
828 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
829 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
830 level
= parse_show_level(idx_level
, argc
, argv
);
832 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
833 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
834 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, &id
,
835 &adv_router
, uj
, ospf6
);
844 DEFUN(show_ipv6_ospf6_database_type_id_router
,
845 show_ipv6_ospf6_database_type_id_router_cmd
,
846 "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]",
847 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
849 "Display Link state database\n"
850 "Display Router LSAs\n"
851 "Display Network LSAs\n"
852 "Display Inter-Area-Prefix LSAs\n"
853 "Display Inter-Area-Router LSAs\n"
854 "Display As-External LSAs\n"
855 "Display Group-Membership LSAs\n"
856 "Display Type-7 LSAs\n"
857 "Display Link LSAs\n"
858 "Display Intra-Area-Prefix LSAs\n"
859 "Specify Link state ID as IPv4 address notation\n"
860 "Specify Advertising Router as IPv4 address notation\n"
862 "Display LSA's internal information\n" JSON_STR
)
869 bool uj
= use_json(argc
, argv
);
870 struct listnode
*node
;
874 uint32_t adv_router
= 0;
875 const char *vrf_name
= NULL
;
876 bool all_vrf
= false;
879 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
887 type
= parse_type_spec(idx_lsa
, argc
, argv
);
888 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
889 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
890 level
= parse_show_level(idx_level
, argc
, argv
);
892 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
893 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
894 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
895 &adv_router
, uj
, ospf6
);
906 DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id
,
907 show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd
,
908 "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]",
914 "Display Link state database\n"
915 "Display Router LSAs\n"
916 "Display Network LSAs\n"
917 "Display Inter-Area-Prefix LSAs\n"
918 "Display Inter-Area-Router LSAs\n"
919 "Display As-External LSAs\n"
920 "Display Group-Membership LSAs\n"
921 "Display Type-7 LSAs\n"
922 "Display Link LSAs\n"
923 "Display Intra-Area-Prefix LSAs\n"
924 "Search by Advertising Router\n"
925 "Specify Advertising Router as IPv4 address notation\n"
926 "Search by Link state ID\n"
927 "Specify Link state ID as IPv4 address notation\n"
929 "Display LSA's internal information\n"
937 bool uj
= use_json(argc
, argv
);
938 struct listnode
*node
;
942 uint32_t adv_router
= 0;
943 const char *vrf_name
= NULL
;
944 bool all_vrf
= false;
947 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
955 type
= parse_type_spec(idx_lsa
, argc
, argv
);
956 inet_pton(AF_INET
, argv
[idx_adv_rtr
]->arg
, &adv_router
);
957 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
958 level
= parse_show_level(idx_level
, argc
, argv
);
960 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
961 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
962 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
963 &adv_router
, uj
, ospf6
);
973 DEFUN(show_ipv6_ospf6_database_self_originated
,
974 show_ipv6_ospf6_database_self_originated_cmd
,
975 "show ipv6 ospf6 [vrf <NAME|all>] database self-originated [<detail|dump|internal>] [json]",
976 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
978 "Display Link state database\n"
979 "Display Self-originated LSAs\n"
980 "Display details of LSAs\n"
982 "Display LSA's internal information\n" JSON_STR
)
986 struct listnode
*node
;
988 const char *vrf_name
= NULL
;
989 bool all_vrf
= false;
991 uint32_t adv_router
= 0;
992 bool uj
= use_json(argc
, argv
);
994 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
998 level
= parse_show_level(idx_level
, argc
, argv
);
1000 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1001 adv_router
= ospf6
->router_id
;
1002 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1003 ospf6_lsdb_show_wrapper(vty
, level
, NULL
, NULL
,
1004 &adv_router
, uj
, ospf6
);
1015 DEFUN(show_ipv6_ospf6_database_type_self_originated
,
1016 show_ipv6_ospf6_database_type_self_originated_cmd
,
1017 "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]",
1018 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1020 "Display Link state database\n"
1021 "Display Router LSAs\n"
1022 "Display Network LSAs\n"
1023 "Display Inter-Area-Prefix LSAs\n"
1024 "Display Inter-Area-Router LSAs\n"
1025 "Display As-External LSAs\n"
1026 "Display Group-Membership LSAs\n"
1027 "Display Type-7 LSAs\n"
1028 "Display Link LSAs\n"
1029 "Display Intra-Area-Prefix LSAs\n"
1030 "Display Self-originated LSAs\n"
1031 "Display details of LSAs\n"
1033 "Display LSA's internal information\n" JSON_STR
)
1038 struct listnode
*node
;
1039 struct ospf6
*ospf6
;
1041 uint32_t adv_router
= 0;
1042 bool uj
= use_json(argc
, argv
);
1044 const char *vrf_name
= NULL
;
1045 bool all_vrf
= false;
1048 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1054 type
= parse_type_spec(idx_lsa
, argc
, argv
);
1055 level
= parse_show_level(idx_level
, argc
, argv
);
1057 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1058 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1059 adv_router
= ospf6
->router_id
;
1060 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, NULL
,
1061 &adv_router
, uj
, ospf6
);
1071 DEFUN(show_ipv6_ospf6_database_type_self_originated_linkstate_id
,
1072 show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd
,
1073 "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]",
1074 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1076 "Display Link state database\n"
1077 "Display Router LSAs\n"
1078 "Display Network LSAs\n"
1079 "Display Inter-Area-Prefix LSAs\n"
1080 "Display Inter-Area-Router LSAs\n"
1081 "Display As-External LSAs\n"
1082 "Display Group-Membership LSAs\n"
1083 "Display Type-7 LSAs\n"
1084 "Display Link LSAs\n"
1085 "Display Intra-Area-Prefix LSAs\n"
1086 "Display Self-originated LSAs\n"
1087 "Search by Link state ID\n"
1088 "Specify Link state ID as IPv4 address notation\n"
1089 "Display details of LSAs\n"
1091 "Display LSA's internal information\n" JSON_STR
)
1097 bool uj
= use_json(argc
, argv
);
1098 struct listnode
*node
;
1099 struct ospf6
*ospf6
;
1101 uint32_t adv_router
= 0;
1103 const char *vrf_name
= NULL
;
1104 bool all_vrf
= false;
1107 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1115 type
= parse_type_spec(idx_lsa
, argc
, argv
);
1116 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
1117 level
= parse_show_level(idx_level
, argc
, argv
);
1119 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1120 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1121 adv_router
= ospf6
->router_id
;
1122 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
1123 &adv_router
, uj
, ospf6
);
1133 DEFUN(show_ipv6_ospf6_database_type_id_self_originated
,
1134 show_ipv6_ospf6_database_type_id_self_originated_cmd
,
1135 "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]",
1136 SHOW_STR IPV6_STR OSPF6_STR VRF_CMD_HELP_STR
1138 "Display Link state database\n"
1139 "Display Router LSAs\n"
1140 "Display Network LSAs\n"
1141 "Display Inter-Area-Prefix LSAs\n"
1142 "Display Inter-Area-Router LSAs\n"
1143 "Display As-External LSAs\n"
1144 "Display Group-Membership LSAs\n"
1145 "Display Type-7 LSAs\n"
1146 "Display Link LSAs\n"
1147 "Display Intra-Area-Prefix LSAs\n"
1148 "Specify Link state ID as IPv4 address notation\n"
1149 "Display Self-originated LSAs\n"
1150 "Display details of LSAs\n"
1152 "Display LSA's internal information\n" JSON_STR
)
1158 bool uj
= use_json(argc
, argv
);
1159 struct listnode
*node
;
1160 struct ospf6
*ospf6
;
1162 uint32_t adv_router
= 0;
1164 const char *vrf_name
= NULL
;
1165 bool all_vrf
= false;
1168 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1175 type
= parse_type_spec(idx_lsa
, argc
, argv
);
1176 inet_pton(AF_INET
, argv
[idx_ls_id
]->arg
, &id
);
1177 level
= parse_show_level(idx_level
, argc
, argv
);
1179 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1180 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1181 adv_router
= ospf6
->router_id
;
1182 ospf6_lsdb_type_show_wrapper(vty
, level
, &type
, &id
,
1183 &adv_router
, uj
, ospf6
);
1193 static int show_ospf6_border_routers_common(struct vty
*vty
, int argc
,
1194 struct cmd_token
**argv
,
1195 struct ospf6
*ospf6
, int idx_ipv4
,
1198 uint32_t adv_router
;
1199 struct ospf6_route
*ro
;
1200 struct prefix prefix
;
1203 if (argc
== idx_argc
) {
1204 if (strmatch(argv
[idx_ipv4
]->text
, "detail")) {
1205 for (ro
= ospf6_route_head(ospf6
->brouter_table
); ro
;
1206 ro
= ospf6_route_next(ro
))
1207 ospf6_route_show_detail(vty
, ro
, NULL
, false);
1209 inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &adv_router
);
1211 ospf6_linkstate_prefix(adv_router
, 0, &prefix
);
1212 ro
= ospf6_route_lookup(&prefix
, ospf6
->brouter_table
);
1215 "No Route found for Router ID: %s\n",
1216 argv
[idx_ipv4
]->arg
);
1220 ospf6_route_show_detail(vty
, ro
, NULL
, false);
1224 ospf6_brouter_show_header(vty
);
1226 for (ro
= ospf6_route_head(ospf6
->brouter_table
); ro
;
1227 ro
= ospf6_route_next(ro
))
1228 ospf6_brouter_show(vty
, ro
);
1234 DEFUN(show_ipv6_ospf6_border_routers
, show_ipv6_ospf6_border_routers_cmd
,
1235 "show ipv6 ospf6 [vrf <NAME|all>] border-routers [<A.B.C.D|detail>]",
1236 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1238 "Display routing table for ABR and ASBR\n"
1240 "Show detailed output\n")
1243 struct ospf6
*ospf6
= NULL
;
1244 struct listnode
*node
;
1245 const char *vrf_name
= NULL
;
1246 bool all_vrf
= false;
1250 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1256 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1257 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1258 show_ospf6_border_routers_common(vty
, argc
, argv
, ospf6
,
1259 idx_ipv4
, idx_argc
);
1270 DEFUN(show_ipv6_ospf6_linkstate
, show_ipv6_ospf6_linkstate_cmd
,
1271 "show ipv6 ospf6 [vrf <NAME|all>] linkstate <router A.B.C.D|network A.B.C.D A.B.C.D>",
1272 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1274 "Display linkstate routing table\n"
1275 "Display Router Entry\n"
1276 "Specify Router ID as IPv4 address notation\n"
1277 "Display Network Entry\n"
1278 "Specify Router ID as IPv4 address notation\n"
1279 "Specify Link state ID as IPv4 address notation\n")
1282 struct listnode
*node
, *nnode
;
1283 struct ospf6_area
*oa
;
1284 struct ospf6
*ospf6
= NULL
;
1285 const char *vrf_name
= NULL
;
1286 bool all_vrf
= false;
1289 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1293 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, nnode
, ospf6
)) {
1294 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1295 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, node
, oa
)) {
1297 "\n SPF Result in Area %s\n\n",
1299 ospf6_linkstate_table_show(vty
, idx_ipv4
, argc
,
1300 argv
, oa
->spf_table
);
1313 DEFUN(show_ipv6_ospf6_linkstate_detail
, show_ipv6_ospf6_linkstate_detail_cmd
,
1314 "show ipv6 ospf6 [vrf <NAME|all>] linkstate detail",
1315 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1317 "Display linkstate routing table\n"
1318 "Display detailed information\n")
1321 struct listnode
*node
;
1322 struct ospf6_area
*oa
;
1323 struct ospf6
*ospf6
= NULL
;
1324 const char *vrf_name
= NULL
;
1325 bool all_vrf
= false;
1328 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1332 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1333 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1334 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, node
, oa
)) {
1336 "\n SPF Result in Area %s\n\n",
1338 ospf6_linkstate_table_show(vty
, idx_detail
,
1352 /* Install ospf related commands. */
1353 void ospf6_init(struct thread_master
*master
)
1357 ospf6_interface_init();
1358 ospf6_neighbor_init();
1359 ospf6_zebra_init(master
);
1367 ospf6_gr_helper_config_init();
1369 /* initialize hooks for modifying filter rules */
1370 prefix_list_add_hook(ospf6_plist_update
);
1371 prefix_list_delete_hook(ospf6_plist_update
);
1372 access_list_add_hook(ospf6_filter_update
);
1373 access_list_delete_hook(ospf6_filter_update
);
1376 install_node(&debug_node
);
1378 install_element_ospf6_debug_message();
1379 install_element_ospf6_debug_lsa();
1380 install_element_ospf6_debug_interface();
1381 install_element_ospf6_debug_neighbor();
1382 install_element_ospf6_debug_zebra();
1383 install_element_ospf6_debug_spf();
1384 install_element_ospf6_debug_route();
1385 install_element_ospf6_debug_brouter();
1386 install_element_ospf6_debug_asbr();
1387 install_element_ospf6_debug_abr();
1388 install_element_ospf6_debug_flood();
1389 install_element_ospf6_debug_nssa();
1391 install_element_ospf6_clear_process();
1392 install_element_ospf6_clear_interface();
1394 install_element(ENABLE_NODE
, &show_debugging_ospf6_cmd
);
1396 install_element(VIEW_NODE
, &show_ipv6_ospf6_border_routers_cmd
);
1398 install_element(VIEW_NODE
, &show_ipv6_ospf6_linkstate_cmd
);
1399 install_element(VIEW_NODE
, &show_ipv6_ospf6_linkstate_detail_cmd
);
1401 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_cmd
);
1402 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_type_cmd
);
1403 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_id_cmd
);
1404 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_router_cmd
);
1405 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_type_id_cmd
);
1406 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_type_router_cmd
);
1407 install_element(VIEW_NODE
,
1408 &show_ipv6_ospf6_database_adv_router_linkstate_id_cmd
);
1409 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_id_router_cmd
);
1410 install_element(VIEW_NODE
,
1411 &show_ipv6_ospf6_database_type_id_router_cmd
);
1414 &show_ipv6_ospf6_database_type_adv_router_linkstate_id_cmd
);
1415 install_element(VIEW_NODE
,
1416 &show_ipv6_ospf6_database_self_originated_cmd
);
1417 install_element(VIEW_NODE
,
1418 &show_ipv6_ospf6_database_type_self_originated_cmd
);
1419 install_element(VIEW_NODE
,
1420 &show_ipv6_ospf6_database_type_id_self_originated_cmd
);
1423 &show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd
);
1424 install_element(VIEW_NODE
, &show_ipv6_ospf6_database_aggr_router_cmd
);