3 * Copyright (C) 1999, 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 #include "ospfd/ospfd.h"
34 #include "ospfd/ospf_interface.h"
35 #include "ospfd/ospf_ism.h"
36 #include "ospfd/ospf_asbr.h"
37 #include "ospfd/ospf_lsa.h"
38 #include "ospfd/ospf_lsdb.h"
39 #include "ospfd/ospf_neighbor.h"
40 #include "ospfd/ospf_nsm.h"
41 #include "ospfd/ospf_dump.h"
42 #include "ospfd/ospf_packet.h"
43 #include "ospfd/ospf_network.h"
44 #ifndef VTYSH_EXTRACT_PL
45 #include "ospfd/ospf_dump_clippy.c"
48 /* Configuration debug option variables. */
49 unsigned long conf_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
50 unsigned long conf_debug_ospf_event
= 0;
51 unsigned long conf_debug_ospf_ism
= 0;
52 unsigned long conf_debug_ospf_nsm
= 0;
53 unsigned long conf_debug_ospf_lsa
= 0;
54 unsigned long conf_debug_ospf_zebra
= 0;
55 unsigned long conf_debug_ospf_nssa
= 0;
56 unsigned long conf_debug_ospf_te
= 0;
57 unsigned long conf_debug_ospf_ext
= 0;
58 unsigned long conf_debug_ospf_sr
= 0;
59 unsigned long conf_debug_ospf_defaultinfo
= 0;
60 unsigned long conf_debug_ospf_ldp_sync
= 0;
61 unsigned long conf_debug_ospf_gr
= 0;
63 /* Enable debug option variables -- valid only session. */
64 unsigned long term_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
65 unsigned long term_debug_ospf_event
;
66 unsigned long term_debug_ospf_ism
= 0;
67 unsigned long term_debug_ospf_nsm
= 0;
68 unsigned long term_debug_ospf_lsa
= 0;
69 unsigned long term_debug_ospf_zebra
= 0;
70 unsigned long term_debug_ospf_nssa
= 0;
71 unsigned long term_debug_ospf_te
= 0;
72 unsigned long term_debug_ospf_ext
= 0;
73 unsigned long term_debug_ospf_sr
= 0;
74 unsigned long term_debug_ospf_defaultinfo
;
75 unsigned long term_debug_ospf_ldp_sync
;
76 unsigned long term_debug_ospf_gr
= 0;
78 const char *ospf_redist_string(unsigned int route_type
)
80 return (route_type
== ZEBRA_ROUTE_MAX
) ? "Default"
81 : zebra_route_string(route_type
);
84 #define OSPF_AREA_STRING_MAXLEN 16
85 const char *ospf_area_name_string(struct ospf_area
*area
)
87 static char buf
[OSPF_AREA_STRING_MAXLEN
] = "";
93 area_id
= ntohl(area
->area_id
.s_addr
);
94 snprintf(buf
, sizeof(buf
), "%d.%d.%d.%d", (area_id
>> 24) & 0xff,
95 (area_id
>> 16) & 0xff, (area_id
>> 8) & 0xff, area_id
& 0xff);
99 #define OSPF_AREA_DESC_STRING_MAXLEN 23
100 const char *ospf_area_desc_string(struct ospf_area
*area
)
102 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
106 return "(incomplete)";
108 type
= area
->external_routing
;
111 snprintf(buf
, sizeof(buf
), "%s [NSSA]",
112 ospf_area_name_string(area
));
115 snprintf(buf
, sizeof(buf
), "%s [Stub]",
116 ospf_area_name_string(area
));
119 return ospf_area_name_string(area
);
125 #define OSPF_IF_STRING_MAXLEN 40
126 const char *ospf_if_name_string(struct ospf_interface
*oi
)
128 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
131 if (!oi
|| !oi
->address
)
134 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
135 return oi
->ifp
->name
;
137 ifaddr
= ntohl(oi
->address
->u
.prefix4
.s_addr
);
138 snprintf(buf
, sizeof(buf
), "%s:%d.%d.%d.%d", oi
->ifp
->name
,
139 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
140 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
145 void ospf_nbr_state_message(struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
148 struct ospf_interface
*oi
= nbr
->oi
;
150 if (IPV4_ADDR_SAME(&DR(oi
), &nbr
->address
.u
.prefix4
))
152 else if (IPV4_ADDR_SAME(&BDR(oi
), &nbr
->address
.u
.prefix4
))
157 snprintf(buf
, size
, "%s/%s",
158 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
),
159 lookup_msg(ospf_ism_state_msg
, state
, NULL
));
162 const char *ospf_timeval_dump(struct timeval
*t
, char *buf
, size_t size
)
164 /* Making formatted timer strings. */
165 #define MINUTE_IN_SECONDS 60
166 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
167 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
168 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
169 unsigned long w
, d
, h
, m
, ms
, us
;
174 w
= d
= h
= m
= ms
= 0;
175 memset(buf
, 0, size
);
181 (void)us
; /* unused */
185 t
->tv_sec
+= ms
/ 1000;
189 if (t
->tv_sec
> WEEK_IN_SECONDS
) {
190 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
191 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
194 if (t
->tv_sec
> DAY_IN_SECONDS
) {
195 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
196 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
199 if (t
->tv_sec
>= HOUR_IN_SECONDS
) {
200 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
201 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
204 if (t
->tv_sec
>= MINUTE_IN_SECONDS
) {
205 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
206 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
210 snprintf(buf
, size
, "%luw%1lud", w
, d
);
212 snprintf(buf
, size
, "%luw%1lud%02luh", w
, d
, h
);
214 snprintf(buf
, size
, "%1lud%02luh%02lum", d
, h
, m
);
216 snprintf(buf
, size
, "%luh%02lum%02lds", h
, m
, (long)t
->tv_sec
);
218 snprintf(buf
, size
, "%lum%02lds", m
, (long)t
->tv_sec
);
220 snprintf(buf
, size
, "%ld.%03lus", (long)t
->tv_sec
, ms
);
222 snprintf(buf
, size
, "%ld usecs", (long)t
->tv_usec
);
227 const char *ospf_timer_dump(struct thread
*t
, char *buf
, size_t size
)
229 struct timeval result
;
233 monotime_until(&t
->u
.sands
, &result
);
234 return ospf_timeval_dump(&result
, buf
, size
);
237 static void ospf_packet_hello_dump(struct stream
*s
, uint16_t length
)
239 struct ospf_hello
*hello
;
242 hello
= (struct ospf_hello
*)stream_pnt(s
);
245 zlog_debug(" NetworkMask %pI4", &hello
->network_mask
);
246 zlog_debug(" HelloInterval %d", ntohs(hello
->hello_interval
));
247 zlog_debug(" Options %d (%s)", hello
->options
,
248 ospf_options_dump(hello
->options
));
249 zlog_debug(" RtrPriority %d", hello
->priority
);
250 zlog_debug(" RtrDeadInterval %ld",
251 (unsigned long)ntohl(hello
->dead_interval
));
252 zlog_debug(" DRouter %pI4", &hello
->d_router
);
253 zlog_debug(" BDRouter %pI4", &hello
->bd_router
);
255 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
256 zlog_debug(" # Neighbors %d", length
/ 4);
257 for (i
= 0; length
> 0; i
++, length
-= sizeof(struct in_addr
))
258 zlog_debug(" Neighbor %pI4", &hello
->neighbors
[i
]);
261 static char *ospf_dd_flags_dump(uint8_t flags
, char *buf
, size_t size
)
263 snprintf(buf
, size
, "%s|%s|%s", (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
264 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
265 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
270 static char *ospf_router_lsa_flags_dump(uint8_t flags
, char *buf
, size_t size
)
272 snprintf(buf
, size
, "%s|%s|%s",
273 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
274 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
275 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
280 static void ospf_router_lsa_dump(struct stream
*s
, uint16_t length
)
283 struct router_lsa
*rl
;
286 rl
= (struct router_lsa
*)stream_pnt(s
);
288 zlog_debug(" Router-LSA");
289 zlog_debug(" flags %s",
290 ospf_router_lsa_flags_dump(rl
->flags
, buf
, BUFSIZ
));
291 zlog_debug(" # links %d", ntohs(rl
->links
));
293 len
= ntohs(rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
294 for (i
= 0; len
> 0; i
++) {
295 zlog_debug(" Link ID %pI4", &rl
->link
[i
].link_id
);
296 zlog_debug(" Link Data %pI4",
297 &rl
->link
[i
].link_data
);
298 zlog_debug(" Type %d", (uint8_t)rl
->link
[i
].type
);
299 zlog_debug(" TOS %d", (uint8_t)rl
->link
[i
].tos
);
300 zlog_debug(" metric %d", ntohs(rl
->link
[i
].metric
));
306 static void ospf_network_lsa_dump(struct stream
*s
, uint16_t length
)
308 struct network_lsa
*nl
;
311 nl
= (struct network_lsa
*)stream_pnt(s
);
312 cnt
= (ntohs(nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
314 zlog_debug(" Network-LSA");
316 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
317 zlog_debug ("Network-LSA size %d",
318 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
320 zlog_debug(" Network Mask %pI4", &nl
->mask
);
321 zlog_debug(" # Attached Routers %d", cnt
);
322 for (i
= 0; i
< cnt
; i
++)
323 zlog_debug(" Attached Router %pI4",
327 static void ospf_summary_lsa_dump(struct stream
*s
, uint16_t length
)
329 struct summary_lsa
*sl
;
333 sl
= (struct summary_lsa
*)stream_pnt(s
);
335 zlog_debug(" Summary-LSA");
336 zlog_debug(" Network Mask %pI4", &sl
->mask
);
338 size
= ntohs(sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
339 for (i
= 0; size
> 0; size
-= 4, i
++)
340 zlog_debug(" TOS=%d metric %d", sl
->tos
,
341 GET_METRIC(sl
->metric
));
344 static void ospf_as_external_lsa_dump(struct stream
*s
, uint16_t length
)
346 struct as_external_lsa
*al
;
350 al
= (struct as_external_lsa
*)stream_pnt(s
);
351 zlog_debug(" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
352 zlog_debug(" Network Mask %pI4", &al
->mask
);
354 size
= ntohs(al
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
355 for (i
= 0; size
> 0; size
-= 12, i
++) {
356 zlog_debug(" bit %s TOS=%d metric %d",
357 IS_EXTERNAL_METRIC(al
->e
[i
].tos
) ? "E" : "-",
358 al
->e
[i
].tos
& 0x7f, GET_METRIC(al
->e
[i
].metric
));
359 zlog_debug(" Forwarding address %pI4",
361 zlog_debug(" External Route Tag %" ROUTE_TAG_PRI
,
366 static void ospf_lsa_header_list_dump(struct stream
*s
, uint16_t length
)
368 struct lsa_header
*lsa
;
370 zlog_debug(" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
374 lsa
= (struct lsa_header
*)stream_pnt(s
);
375 ospf_lsa_header_dump(lsa
);
377 stream_forward_getp(s
, OSPF_LSA_HEADER_SIZE
);
378 length
-= OSPF_LSA_HEADER_SIZE
;
382 static void ospf_packet_db_desc_dump(struct stream
*s
, uint16_t length
)
384 struct ospf_db_desc
*dd
;
389 gp
= stream_get_getp(s
);
390 dd
= (struct ospf_db_desc
*)stream_pnt(s
);
392 zlog_debug("Database Description");
393 zlog_debug(" Interface MTU %d", ntohs(dd
->mtu
));
394 zlog_debug(" Options %d (%s)", dd
->options
,
395 ospf_options_dump(dd
->options
));
396 zlog_debug(" Flags %d (%s)", dd
->flags
,
397 ospf_dd_flags_dump(dd
->flags
, dd_flags
, sizeof(dd_flags
)));
398 zlog_debug(" Sequence Number 0x%08lx",
399 (unsigned long)ntohl(dd
->dd_seqnum
));
401 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
403 stream_forward_getp(s
, OSPF_DB_DESC_MIN_SIZE
);
405 ospf_lsa_header_list_dump(s
, length
);
407 stream_set_getp(s
, gp
);
410 static void ospf_packet_ls_req_dump(struct stream
*s
, uint16_t length
)
414 struct in_addr ls_id
;
415 struct in_addr adv_router
;
417 sp
= stream_get_getp(s
);
419 length
-= OSPF_HEADER_SIZE
;
421 zlog_debug("Link State Request");
422 zlog_debug(" # Requests %d", length
/ 12);
424 for (; length
> 0; length
-= 12) {
425 ls_type
= stream_getl(s
);
426 ls_id
.s_addr
= stream_get_ipv4(s
);
427 adv_router
.s_addr
= stream_get_ipv4(s
);
429 zlog_debug(" LS type %d", ls_type
);
430 zlog_debug(" Link State ID %pI4", &ls_id
);
431 zlog_debug(" Advertising Router %pI4", &adv_router
);
434 stream_set_getp(s
, sp
);
437 static void ospf_packet_ls_upd_dump(struct stream
*s
, uint16_t length
)
440 struct lsa_header
*lsa
;
444 length
-= OSPF_HEADER_SIZE
;
446 sp
= stream_get_getp(s
);
448 count
= stream_getl(s
);
451 zlog_debug("Link State Update");
452 zlog_debug(" # LSAs %d", count
);
454 while (length
> 0 && count
> 0) {
455 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0) {
456 zlog_debug(" Remaining %d bytes; Incorrect length.",
461 lsa
= (struct lsa_header
*)stream_pnt(s
);
462 lsa_len
= ntohs(lsa
->length
);
463 ospf_lsa_header_dump(lsa
);
466 case OSPF_ROUTER_LSA
:
467 ospf_router_lsa_dump(s
, length
);
469 case OSPF_NETWORK_LSA
:
470 ospf_network_lsa_dump(s
, length
);
472 case OSPF_SUMMARY_LSA
:
473 case OSPF_ASBR_SUMMARY_LSA
:
474 ospf_summary_lsa_dump(s
, length
);
476 case OSPF_AS_EXTERNAL_LSA
:
477 ospf_as_external_lsa_dump(s
, length
);
479 case OSPF_AS_NSSA_LSA
:
480 ospf_as_external_lsa_dump(s
, length
);
482 case OSPF_OPAQUE_LINK_LSA
:
483 case OSPF_OPAQUE_AREA_LSA
:
484 case OSPF_OPAQUE_AS_LSA
:
485 ospf_opaque_lsa_dump(s
, length
);
491 stream_forward_getp(s
, lsa_len
);
496 stream_set_getp(s
, sp
);
499 static void ospf_packet_ls_ack_dump(struct stream
*s
, uint16_t length
)
503 length
-= OSPF_HEADER_SIZE
;
504 sp
= stream_get_getp(s
);
506 zlog_debug("Link State Acknowledgment");
507 ospf_lsa_header_list_dump(s
, length
);
509 stream_set_getp(s
, sp
);
512 static void ospf_header_dump(struct ospf_header
*ospfh
)
515 uint16_t auth_type
= ntohs(ospfh
->auth_type
);
517 zlog_debug("Header");
518 zlog_debug(" Version %d", ospfh
->version
);
519 zlog_debug(" Type %d (%s)", ospfh
->type
,
520 lookup_msg(ospf_packet_type_str
, ospfh
->type
, NULL
));
521 zlog_debug(" Packet Len %d", ntohs(ospfh
->length
));
522 zlog_debug(" Router ID %pI4", &ospfh
->router_id
);
523 zlog_debug(" Area ID %pI4", &ospfh
->area_id
);
524 zlog_debug(" Checksum 0x%x", ntohs(ospfh
->checksum
));
525 zlog_debug(" AuType %s",
526 lookup_msg(ospf_auth_type_str
, auth_type
, NULL
));
531 case OSPF_AUTH_SIMPLE
:
532 strlcpy(buf
, (char *)ospfh
->u
.auth_data
, sizeof(buf
));
533 zlog_debug(" Simple Password %s", buf
);
535 case OSPF_AUTH_CRYPTOGRAPHIC
:
536 zlog_debug(" Cryptographic Authentication");
537 zlog_debug(" Key ID %d", ospfh
->u
.crypt
.key_id
);
538 zlog_debug(" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
539 zlog_debug(" Sequence number %ld",
540 (unsigned long)ntohl(ospfh
->u
.crypt
.crypt_seqnum
));
543 zlog_debug("* This is not supported authentication type");
548 void ospf_packet_dump(struct stream
*s
)
550 struct ospf_header
*ospfh
;
553 /* Preserve pointer. */
554 gp
= stream_get_getp(s
);
556 /* OSPF Header dump. */
557 ospfh
= (struct ospf_header
*)stream_pnt(s
);
559 /* Until detail flag is set, return. */
560 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
563 /* Show OSPF header detail. */
564 ospf_header_dump(ospfh
);
565 stream_forward_getp(s
, OSPF_HEADER_SIZE
);
567 switch (ospfh
->type
) {
569 ospf_packet_hello_dump(s
, ntohs(ospfh
->length
));
571 case OSPF_MSG_DB_DESC
:
572 ospf_packet_db_desc_dump(s
, ntohs(ospfh
->length
));
574 case OSPF_MSG_LS_REQ
:
575 ospf_packet_ls_req_dump(s
, ntohs(ospfh
->length
));
577 case OSPF_MSG_LS_UPD
:
578 ospf_packet_ls_upd_dump(s
, ntohs(ospfh
->length
));
580 case OSPF_MSG_LS_ACK
:
581 ospf_packet_ls_ack_dump(s
, ntohs(ospfh
->length
));
587 stream_set_getp(s
, gp
);
590 DEFUN (debug_ospf_packet
,
591 debug_ospf_packet_cmd
,
592 "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
598 "OSPF Database Description\n"
599 "OSPF Link State Request\n"
600 "OSPF Link State Update\n"
601 "OSPF Link State Acknowledgment\n"
604 "Detail Information\n"
606 "Detail Information\n"
607 "Detail Information\n")
609 int inst
= (argv
[2]->type
== RANGE_TKN
) ? 1 : 0;
610 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
611 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
612 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
613 char *packet
= argv
[3 + inst
]->text
;
615 if (inst
) // user passed instance ID
617 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
618 return CMD_NOT_MY_INSTANCE
;
625 /* Check packet type. */
626 if (strmatch(packet
, "hello"))
627 type
= OSPF_DEBUG_HELLO
;
628 else if (strmatch(packet
, "dd"))
629 type
= OSPF_DEBUG_DB_DESC
;
630 else if (strmatch(packet
, "ls-request"))
631 type
= OSPF_DEBUG_LS_REQ
;
632 else if (strmatch(packet
, "ls-update"))
633 type
= OSPF_DEBUG_LS_UPD
;
634 else if (strmatch(packet
, "ls-ack"))
635 type
= OSPF_DEBUG_LS_ACK
;
636 else if (strmatch(packet
, "all"))
637 type
= OSPF_DEBUG_ALL
;
640 * (none) = send + recv
641 * detail = send + recv + detail
644 * recv detail = recv + detail
645 * send detail = send + detail
650 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
651 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
652 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
654 for (i
= 0; i
< 5; i
++)
655 if (type
& (0x01 << i
)) {
656 if (vty
->node
== CONFIG_NODE
)
657 DEBUG_PACKET_ON(i
, flag
);
659 TERM_DEBUG_PACKET_ON(i
, flag
);
665 DEFUN (no_debug_ospf_packet
,
666 no_debug_ospf_packet_cmd
,
667 "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
674 "OSPF Database Description\n"
675 "OSPF Link State Request\n"
676 "OSPF Link State Update\n"
677 "OSPF Link State Acknowledgment\n"
680 "Detail Information\n"
682 "Detail Information\n"
683 "Detail Information\n")
685 int inst
= (argv
[3]->type
== RANGE_TKN
) ? 1 : 0;
686 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
687 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
688 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
689 char *packet
= argv
[4 + inst
]->text
;
691 if (inst
) // user passed instance ID
693 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
694 return CMD_NOT_MY_INSTANCE
;
701 /* Check packet type. */
702 if (strmatch(packet
, "hello"))
703 type
= OSPF_DEBUG_HELLO
;
704 else if (strmatch(packet
, "dd"))
705 type
= OSPF_DEBUG_DB_DESC
;
706 else if (strmatch(packet
, "ls-request"))
707 type
= OSPF_DEBUG_LS_REQ
;
708 else if (strmatch(packet
, "ls-update"))
709 type
= OSPF_DEBUG_LS_UPD
;
710 else if (strmatch(packet
, "ls-ack"))
711 type
= OSPF_DEBUG_LS_ACK
;
712 else if (strmatch(packet
, "all"))
713 type
= OSPF_DEBUG_ALL
;
716 * (none) = send + recv
717 * detail = send + recv + detail
720 * recv detail = recv + detail
721 * send detail = send + detail
726 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
727 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
728 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
730 for (i
= 0; i
< 5; i
++)
731 if (type
& (0x01 << i
)) {
732 if (vty
->node
== CONFIG_NODE
)
733 DEBUG_PACKET_OFF(i
, flag
);
735 TERM_DEBUG_PACKET_OFF(i
, flag
);
740 for (i = 0; i < 5; i++)
741 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
748 DEFUN (debug_ospf_ism
,
750 "debug ospf [(1-65535)] ism [<status|events|timers>]",
754 "OSPF Interface State Machine\n"
755 "ISM Status Information\n"
756 "ISM Event Information\n"
757 "ISM TImer Information\n")
759 int inst
= (argv
[2]->type
== RANGE_TKN
);
760 char *dbgparam
= (argc
== 4 + inst
) ? argv
[argc
- 1]->text
: NULL
;
762 if (inst
) // user passed instance ID
764 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
765 return CMD_NOT_MY_INSTANCE
;
768 if (vty
->node
== CONFIG_NODE
) {
772 if (strmatch(dbgparam
, "status"))
773 DEBUG_ON(ism
, ISM_STATUS
);
774 else if (strmatch(dbgparam
, "events"))
775 DEBUG_ON(ism
, ISM_EVENTS
);
776 else if (strmatch(dbgparam
, "timers"))
777 DEBUG_ON(ism
, ISM_TIMERS
);
785 TERM_DEBUG_ON(ism
, ISM
);
787 if (strmatch(dbgparam
, "status"))
788 TERM_DEBUG_ON(ism
, ISM_STATUS
);
789 else if (strmatch(dbgparam
, "events"))
790 TERM_DEBUG_ON(ism
, ISM_EVENTS
);
791 else if (strmatch(dbgparam
, "timers"))
792 TERM_DEBUG_ON(ism
, ISM_TIMERS
);
798 DEFUN (no_debug_ospf_ism
,
799 no_debug_ospf_ism_cmd
,
800 "no debug ospf [(1-65535)] ism [<status|events|timers>]",
805 "OSPF Interface State Machine\n"
806 "ISM Status Information\n"
807 "ISM Event Information\n"
808 "ISM TImer Information\n")
810 int inst
= (argv
[3]->type
== RANGE_TKN
);
811 char *dbgparam
= (argc
== 5 + inst
) ? argv
[argc
- 1]->text
: NULL
;
813 if (inst
) // user passed instance ID
815 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
816 return CMD_NOT_MY_INSTANCE
;
819 if (vty
->node
== CONFIG_NODE
) {
823 if (strmatch(dbgparam
, "status"))
824 DEBUG_OFF(ism
, ISM_STATUS
);
825 else if (strmatch(dbgparam
, "events"))
826 DEBUG_OFF(ism
, ISM_EVENTS
);
827 else if (strmatch(dbgparam
, "timers"))
828 DEBUG_OFF(ism
, ISM_TIMERS
);
836 TERM_DEBUG_OFF(ism
, ISM
);
838 if (strmatch(dbgparam
, "status"))
839 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
840 else if (strmatch(dbgparam
, "events"))
841 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
842 else if (strmatch(dbgparam
, "timers"))
843 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
849 static int debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
850 struct cmd_token
**argv
)
852 if (vty
->node
== CONFIG_NODE
) {
853 if (argc
== arg_base
+ 0)
855 else if (argc
== arg_base
+ 1) {
856 if (strmatch(argv
[arg_base
]->text
, "status"))
857 DEBUG_ON(nsm
, NSM_STATUS
);
858 else if (strmatch(argv
[arg_base
]->text
, "events"))
859 DEBUG_ON(nsm
, NSM_EVENTS
);
860 else if (strmatch(argv
[arg_base
]->text
, "timers"))
861 DEBUG_ON(nsm
, NSM_TIMERS
);
868 if (argc
== arg_base
+ 0)
869 TERM_DEBUG_ON(nsm
, NSM
);
870 else if (argc
== arg_base
+ 1) {
871 if (strmatch(argv
[arg_base
]->text
, "status"))
872 TERM_DEBUG_ON(nsm
, NSM_STATUS
);
873 else if (strmatch(argv
[arg_base
]->text
, "events"))
874 TERM_DEBUG_ON(nsm
, NSM_EVENTS
);
875 else if (strmatch(argv
[arg_base
]->text
, "timers"))
876 TERM_DEBUG_ON(nsm
, NSM_TIMERS
);
882 DEFUN (debug_ospf_nsm
,
884 "debug ospf nsm [<status|events|timers>]",
887 "OSPF Neighbor State Machine\n"
888 "NSM Status Information\n"
889 "NSM Event Information\n"
890 "NSM Timer Information\n")
892 return debug_ospf_nsm_common(vty
, 3, argc
, argv
);
895 DEFUN (debug_ospf_instance_nsm
,
896 debug_ospf_instance_nsm_cmd
,
897 "debug ospf (1-65535) nsm [<status|events|timers>]",
901 "OSPF Neighbor State Machine\n"
902 "NSM Status Information\n"
903 "NSM Event Information\n"
904 "NSM Timer Information\n")
907 unsigned short instance
= 0;
909 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
910 if (!ospf_lookup_instance(instance
))
913 return debug_ospf_nsm_common(vty
, 4, argc
, argv
);
917 static int no_debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
918 struct cmd_token
**argv
)
921 if (vty
->node
== CONFIG_NODE
) {
922 if (argc
== arg_base
+ 0)
924 else if (argc
== arg_base
+ 1) {
925 if (strmatch(argv
[arg_base
]->text
, "status"))
926 DEBUG_OFF(nsm
, NSM_STATUS
);
927 else if (strmatch(argv
[arg_base
]->text
, "events"))
928 DEBUG_OFF(nsm
, NSM_EVENTS
);
929 else if (strmatch(argv
[arg_base
]->text
, "timers"))
930 DEBUG_OFF(nsm
, NSM_TIMERS
);
937 if (argc
== arg_base
+ 0)
938 TERM_DEBUG_OFF(nsm
, NSM
);
939 else if (argc
== arg_base
+ 1) {
940 if (strmatch(argv
[arg_base
]->text
, "status"))
941 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
942 else if (strmatch(argv
[arg_base
]->text
, "events"))
943 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
944 else if (strmatch(argv
[arg_base
]->text
, "timers"))
945 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
951 DEFUN (no_debug_ospf_nsm
,
952 no_debug_ospf_nsm_cmd
,
953 "no debug ospf nsm [<status|events|timers>]",
957 "OSPF Neighbor State Machine\n"
958 "NSM Status Information\n"
959 "NSM Event Information\n"
960 "NSM Timer Information\n")
962 return no_debug_ospf_nsm_common(vty
, 4, argc
, argv
);
966 DEFUN (no_debug_ospf_instance_nsm
,
967 no_debug_ospf_instance_nsm_cmd
,
968 "no debug ospf (1-65535) nsm [<status|events|timers>]",
973 "OSPF Neighbor State Machine\n"
974 "NSM Status Information\n"
975 "NSM Event Information\n"
976 "NSM Timer Information\n")
979 unsigned short instance
= 0;
981 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
982 if (!ospf_lookup_instance(instance
))
983 return CMD_NOT_MY_INSTANCE
;
985 return no_debug_ospf_nsm_common(vty
, 5, argc
, argv
);
989 static int debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
990 struct cmd_token
**argv
)
992 if (vty
->node
== CONFIG_NODE
) {
993 if (argc
== arg_base
+ 0)
995 else if (argc
== arg_base
+ 1) {
996 if (strmatch(argv
[arg_base
]->text
, "generate"))
997 DEBUG_ON(lsa
, LSA_GENERATE
);
998 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
999 DEBUG_ON(lsa
, LSA_FLOODING
);
1000 else if (strmatch(argv
[arg_base
]->text
, "install"))
1001 DEBUG_ON(lsa
, LSA_INSTALL
);
1002 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1003 DEBUG_ON(lsa
, LSA_REFRESH
);
1010 if (argc
== arg_base
+ 0)
1011 TERM_DEBUG_ON(lsa
, LSA
);
1012 else if (argc
== arg_base
+ 1) {
1013 if (strmatch(argv
[arg_base
]->text
, "generate"))
1014 TERM_DEBUG_ON(lsa
, LSA_GENERATE
);
1015 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1016 TERM_DEBUG_ON(lsa
, LSA_FLOODING
);
1017 else if (strmatch(argv
[arg_base
]->text
, "install"))
1018 TERM_DEBUG_ON(lsa
, LSA_INSTALL
);
1019 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1020 TERM_DEBUG_ON(lsa
, LSA_REFRESH
);
1026 DEFUN (debug_ospf_lsa
,
1028 "debug ospf lsa [<generate|flooding|install|refresh>]",
1031 "OSPF Link State Advertisement\n"
1034 "LSA Install/Delete\n"
1037 return debug_ospf_lsa_common(vty
, 3, argc
, argv
);
1040 DEFUN (debug_ospf_instance_lsa
,
1041 debug_ospf_instance_lsa_cmd
,
1042 "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1046 "OSPF Link State Advertisement\n"
1049 "LSA Install/Delete\n"
1053 unsigned short instance
= 0;
1055 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1056 if (!ospf_lookup_instance(instance
))
1057 return CMD_NOT_MY_INSTANCE
;
1059 return debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1063 static int no_debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
1064 struct cmd_token
**argv
)
1066 if (vty
->node
== CONFIG_NODE
) {
1067 if (argc
== arg_base
+ 0)
1068 DEBUG_OFF(lsa
, LSA
);
1069 else if (argc
== arg_base
+ 1) {
1070 if (strmatch(argv
[arg_base
]->text
, "generate"))
1071 DEBUG_OFF(lsa
, LSA_GENERATE
);
1072 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1073 DEBUG_OFF(lsa
, LSA_FLOODING
);
1074 else if (strmatch(argv
[arg_base
]->text
, "install"))
1075 DEBUG_OFF(lsa
, LSA_INSTALL
);
1076 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1077 DEBUG_OFF(lsa
, LSA_REFRESH
);
1084 if (argc
== arg_base
+ 0)
1085 TERM_DEBUG_OFF(lsa
, LSA
);
1086 else if (argc
== arg_base
+ 1) {
1087 if (strmatch(argv
[arg_base
]->text
, "generate"))
1088 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1089 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1090 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1091 else if (strmatch(argv
[arg_base
]->text
, "install"))
1092 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1093 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1094 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1100 DEFUN (no_debug_ospf_lsa
,
1101 no_debug_ospf_lsa_cmd
,
1102 "no debug ospf lsa [<generate|flooding|install|refresh>]",
1106 "OSPF Link State Advertisement\n"
1109 "LSA Install/Delete\n"
1112 return no_debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1115 DEFUN (no_debug_ospf_instance_lsa
,
1116 no_debug_ospf_instance_lsa_cmd
,
1117 "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1122 "OSPF Link State Advertisement\n"
1125 "LSA Install/Delete\n"
1129 unsigned short instance
= 0;
1131 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1132 if (!ospf_lookup_instance(instance
))
1133 return CMD_NOT_MY_INSTANCE
;
1135 return no_debug_ospf_lsa_common(vty
, 5, argc
, argv
);
1139 static int debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1140 struct cmd_token
**argv
)
1142 if (vty
->node
== CONFIG_NODE
) {
1143 if (argc
== arg_base
+ 0)
1144 DEBUG_ON(zebra
, ZEBRA
);
1145 else if (argc
== arg_base
+ 1) {
1146 if (strmatch(argv
[arg_base
]->text
, "interface"))
1147 DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1148 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1149 DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1156 if (argc
== arg_base
+ 0)
1157 TERM_DEBUG_ON(zebra
, ZEBRA
);
1158 else if (argc
== arg_base
+ 1) {
1159 if (strmatch(argv
[arg_base
]->text
, "interface"))
1160 TERM_DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1161 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1162 TERM_DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1168 DEFUN (debug_ospf_zebra
,
1169 debug_ospf_zebra_cmd
,
1170 "debug ospf zebra [<interface|redistribute>]",
1175 "Zebra redistribute\n")
1177 return debug_ospf_zebra_common(vty
, 3, argc
, argv
);
1180 DEFUN (debug_ospf_instance_zebra
,
1181 debug_ospf_instance_zebra_cmd
,
1182 "debug ospf (1-65535) zebra [<interface|redistribute>]",
1188 "Zebra redistribute\n")
1191 unsigned short instance
= 0;
1193 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1194 if (!ospf_lookup_instance(instance
))
1195 return CMD_NOT_MY_INSTANCE
;
1197 return debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1201 static int no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1202 struct cmd_token
**argv
)
1204 if (vty
->node
== CONFIG_NODE
) {
1205 if (argc
== arg_base
+ 0)
1206 DEBUG_OFF(zebra
, ZEBRA
);
1207 else if (argc
== arg_base
+ 1) {
1208 if (strmatch(argv
[arg_base
]->text
, "interface"))
1209 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1210 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1211 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1218 if (argc
== arg_base
+ 0)
1219 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1220 else if (argc
== arg_base
+ 1) {
1221 if (strmatch(argv
[arg_base
]->text
, "interface"))
1222 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1223 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1224 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1230 DEFUN (no_debug_ospf_zebra
,
1231 no_debug_ospf_zebra_cmd
,
1232 "no debug ospf zebra [<interface|redistribute>]",
1238 "Zebra redistribute\n")
1240 return no_debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1243 DEFUN (no_debug_ospf_instance_zebra
,
1244 no_debug_ospf_instance_zebra_cmd
,
1245 "no debug ospf (1-65535) zebra [<interface|redistribute>]",
1252 "Zebra redistribute\n")
1255 unsigned short instance
= 0;
1257 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1258 if (!ospf_lookup_instance(instance
))
1261 return no_debug_ospf_zebra_common(vty
, 5, argc
, argv
);
1265 DEFUN (debug_ospf_event
,
1266 debug_ospf_event_cmd
,
1270 "OSPF event information\n")
1272 if (vty
->node
== CONFIG_NODE
)
1273 CONF_DEBUG_ON(event
, EVENT
);
1274 TERM_DEBUG_ON(event
, EVENT
);
1278 DEFUN (no_debug_ospf_event
,
1279 no_debug_ospf_event_cmd
,
1280 "no debug ospf event",
1284 "OSPF event information\n")
1286 if (vty
->node
== CONFIG_NODE
)
1287 CONF_DEBUG_OFF(event
, EVENT
);
1288 TERM_DEBUG_OFF(event
, EVENT
);
1292 DEFUN (debug_ospf_instance_event
,
1293 debug_ospf_instance_event_cmd
,
1294 "debug ospf (1-65535) event",
1298 "OSPF event information\n")
1301 unsigned short instance
= 0;
1303 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1304 if (!ospf_lookup_instance(instance
))
1307 if (vty
->node
== CONFIG_NODE
)
1308 CONF_DEBUG_ON(event
, EVENT
);
1309 TERM_DEBUG_ON(event
, EVENT
);
1313 DEFUN (no_debug_ospf_instance_event
,
1314 no_debug_ospf_instance_event_cmd
,
1315 "no debug ospf (1-65535) event",
1320 "OSPF event information\n")
1323 unsigned short instance
= 0;
1325 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1326 if (!ospf_lookup_instance(instance
))
1329 if (vty
->node
== CONFIG_NODE
)
1330 CONF_DEBUG_OFF(event
, EVENT
);
1331 TERM_DEBUG_OFF(event
, EVENT
);
1335 DEFUN (debug_ospf_nssa
,
1336 debug_ospf_nssa_cmd
,
1340 "OSPF nssa information\n")
1342 if (vty
->node
== CONFIG_NODE
)
1343 CONF_DEBUG_ON(nssa
, NSSA
);
1344 TERM_DEBUG_ON(nssa
, NSSA
);
1348 DEFUN (no_debug_ospf_nssa
,
1349 no_debug_ospf_nssa_cmd
,
1350 "no debug ospf nssa",
1354 "OSPF nssa information\n")
1356 if (vty
->node
== CONFIG_NODE
)
1357 CONF_DEBUG_OFF(nssa
, NSSA
);
1358 TERM_DEBUG_OFF(nssa
, NSSA
);
1362 DEFUN (debug_ospf_instance_nssa
,
1363 debug_ospf_instance_nssa_cmd
,
1364 "debug ospf (1-65535) nssa",
1368 "OSPF nssa information\n")
1371 unsigned short instance
= 0;
1373 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1374 if (!ospf_lookup_instance(instance
))
1377 if (vty
->node
== CONFIG_NODE
)
1378 CONF_DEBUG_ON(nssa
, NSSA
);
1379 TERM_DEBUG_ON(nssa
, NSSA
);
1383 DEFUN (no_debug_ospf_instance_nssa
,
1384 no_debug_ospf_instance_nssa_cmd
,
1385 "no debug ospf (1-65535) nssa",
1390 "OSPF nssa information\n")
1393 unsigned short instance
= 0;
1395 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1396 if (!ospf_lookup_instance(instance
))
1399 if (vty
->node
== CONFIG_NODE
)
1400 CONF_DEBUG_OFF(nssa
, NSSA
);
1401 TERM_DEBUG_OFF(nssa
, NSSA
);
1405 DEFUN (debug_ospf_te
,
1410 "OSPF-TE information\n")
1412 if (vty
->node
== CONFIG_NODE
)
1413 CONF_DEBUG_ON(te
, TE
);
1414 TERM_DEBUG_ON(te
, TE
);
1418 DEFUN (no_debug_ospf_te
,
1419 no_debug_ospf_te_cmd
,
1424 "OSPF-TE information\n")
1426 if (vty
->node
== CONFIG_NODE
)
1427 CONF_DEBUG_OFF(te
, TE
);
1428 TERM_DEBUG_OFF(te
, TE
);
1432 DEFUN (debug_ospf_sr
,
1437 "OSPF-SR information\n")
1439 if (vty
->node
== CONFIG_NODE
)
1440 CONF_DEBUG_ON(sr
, SR
);
1441 TERM_DEBUG_ON(sr
, SR
);
1445 DEFUN (no_debug_ospf_sr
,
1446 no_debug_ospf_sr_cmd
,
1451 "OSPF-SR information\n")
1453 if (vty
->node
== CONFIG_NODE
)
1454 CONF_DEBUG_OFF(sr
, SR
);
1455 TERM_DEBUG_OFF(sr
, SR
);
1459 DEFUN (debug_ospf_default_info
,
1460 debug_ospf_default_info_cmd
,
1461 "debug ospf default-information",
1464 "OSPF default information\n")
1466 if (vty
->node
== CONFIG_NODE
)
1467 CONF_DEBUG_ON(defaultinfo
, DEFAULTINFO
);
1468 TERM_DEBUG_ON(defaultinfo
, DEFAULTINFO
);
1472 DEFUN (no_debug_ospf_default_info
,
1473 no_debug_ospf_default_info_cmd
,
1474 "no debug ospf default-information",
1478 "OSPF default information\n")
1480 if (vty
->node
== CONFIG_NODE
)
1481 CONF_DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1482 TERM_DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1486 DEFUN(debug_ospf_ldp_sync
,
1487 debug_ospf_ldp_sync_cmd
,
1488 "debug ospf ldp-sync",
1490 "OSPF LDP-Sync information\n")
1492 if (vty
->node
== CONFIG_NODE
)
1493 CONF_DEBUG_ON(ldp_sync
, LDP_SYNC
);
1494 TERM_DEBUG_ON(ldp_sync
, LDP_SYNC
);
1498 DEFUN(no_debug_ospf_ldp_sync
,
1499 no_debug_ospf_ldp_sync_cmd
,
1500 "no debug ospf ldp-sync",
1504 "OSPF LDP-Sync information\n")
1506 if (vty
->node
== CONFIG_NODE
)
1507 CONF_DEBUG_OFF(ldp_sync
, LDP_SYNC
);
1508 TERM_DEBUG_OFF(ldp_sync
, LDP_SYNC
);
1513 DEFPY (debug_ospf_gr
,
1515 "[no$no] debug ospf graceful-restart helper",
1518 "Gracefull restart\n"
1519 "Helper Information\n")
1521 if (vty
->node
== CONFIG_NODE
)
1522 CONF_DEBUG_ON(gr
, GR_HELPER
);
1525 TERM_DEBUG_ON(gr
, GR_HELPER
);
1527 TERM_DEBUG_OFF(gr
, GR_HELPER
);
1532 DEFUN (no_debug_ospf
,
1539 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1542 if (vty
->node
== CONFIG_NODE
) {
1543 CONF_DEBUG_OFF(event
, EVENT
);
1544 CONF_DEBUG_OFF(nssa
, NSSA
);
1545 DEBUG_OFF(ism
, ISM_EVENTS
);
1546 DEBUG_OFF(ism
, ISM_STATUS
);
1547 DEBUG_OFF(ism
, ISM_TIMERS
);
1548 DEBUG_OFF(lsa
, LSA
);
1549 DEBUG_OFF(lsa
, LSA_FLOODING
);
1550 DEBUG_OFF(lsa
, LSA_GENERATE
);
1551 DEBUG_OFF(lsa
, LSA_INSTALL
);
1552 DEBUG_OFF(lsa
, LSA_REFRESH
);
1553 DEBUG_OFF(nsm
, NSM
);
1554 DEBUG_OFF(nsm
, NSM_EVENTS
);
1555 DEBUG_OFF(nsm
, NSM_STATUS
);
1556 DEBUG_OFF(nsm
, NSM_TIMERS
);
1557 DEBUG_OFF(zebra
, ZEBRA
);
1558 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1559 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1560 DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1561 DEBUG_OFF(ldp_sync
, LDP_SYNC
);
1563 for (i
= 0; i
< 5; i
++)
1564 DEBUG_PACKET_OFF(i
, flag
);
1567 for (i
= 0; i
< 5; i
++)
1568 TERM_DEBUG_PACKET_OFF(i
, flag
);
1570 TERM_DEBUG_OFF(event
, EVENT
);
1571 TERM_DEBUG_OFF(ism
, ISM
);
1572 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
1573 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
1574 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
1575 TERM_DEBUG_OFF(lsa
, LSA
);
1576 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1577 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1578 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1579 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1580 TERM_DEBUG_OFF(nsm
, NSM
);
1581 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
1582 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
1583 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
1584 TERM_DEBUG_OFF(nssa
, NSSA
);
1585 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1586 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1587 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1588 TERM_DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1589 TERM_DEBUG_OFF(ldp_sync
, LDP_SYNC
);
1594 static int show_debugging_ospf_common(struct vty
*vty
, struct ospf
*ospf
)
1599 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
1601 vty_out(vty
, "OSPF debugging status:\n");
1603 /* Show debug status for events. */
1604 if (IS_DEBUG_OSPF(event
, EVENT
))
1605 vty_out(vty
, " OSPF event debugging is on\n");
1607 /* Show debug status for ISM. */
1608 if (IS_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1609 vty_out(vty
, " OSPF ISM debugging is on\n");
1611 if (IS_DEBUG_OSPF(ism
, ISM_STATUS
))
1612 vty_out(vty
, " OSPF ISM status debugging is on\n");
1613 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
1614 vty_out(vty
, " OSPF ISM event debugging is on\n");
1615 if (IS_DEBUG_OSPF(ism
, ISM_TIMERS
))
1616 vty_out(vty
, " OSPF ISM timer debugging is on\n");
1619 /* Show debug status for NSM. */
1620 if (IS_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1621 vty_out(vty
, " OSPF NSM debugging is on\n");
1623 if (IS_DEBUG_OSPF(nsm
, NSM_STATUS
))
1624 vty_out(vty
, " OSPF NSM status debugging is on\n");
1625 if (IS_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1626 vty_out(vty
, " OSPF NSM event debugging is on\n");
1627 if (IS_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1628 vty_out(vty
, " OSPF NSM timer debugging is on\n");
1631 /* Show debug status for OSPF Packets. */
1632 for (i
= 0; i
< 5; i
++)
1633 if (IS_DEBUG_OSPF_PACKET(i
, SEND
)
1634 && IS_DEBUG_OSPF_PACKET(i
, RECV
)) {
1635 vty_out(vty
, " OSPF packet %s%s debugging is on\n",
1636 lookup_msg(ospf_packet_type_str
, i
+ 1, NULL
),
1637 IS_DEBUG_OSPF_PACKET(i
, DETAIL
) ? " detail"
1640 if (IS_DEBUG_OSPF_PACKET(i
, SEND
))
1642 " OSPF packet %s send%s debugging is on\n",
1643 lookup_msg(ospf_packet_type_str
, i
+ 1,
1645 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1648 if (IS_DEBUG_OSPF_PACKET(i
, RECV
))
1650 " OSPF packet %s receive%s debugging is on\n",
1651 lookup_msg(ospf_packet_type_str
, i
+ 1,
1653 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1658 /* Show debug status for OSPF LSAs. */
1659 if (IS_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1660 vty_out(vty
, " OSPF LSA debugging is on\n");
1662 if (IS_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1663 vty_out(vty
, " OSPF LSA generation debugging is on\n");
1664 if (IS_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1665 vty_out(vty
, " OSPF LSA flooding debugging is on\n");
1666 if (IS_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1667 vty_out(vty
, " OSPF LSA install debugging is on\n");
1668 if (IS_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1669 vty_out(vty
, " OSPF LSA refresh debugging is on\n");
1672 /* Show debug status for Zebra. */
1673 if (IS_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1674 vty_out(vty
, " OSPF Zebra debugging is on\n");
1676 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1678 " OSPF Zebra interface debugging is on\n");
1679 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1681 " OSPF Zebra redistribute debugging is on\n");
1684 if (IS_DEBUG_OSPF(defaultinfo
, DEFAULTINFO
) == OSPF_DEBUG_DEFAULTINFO
)
1685 vty_out(vty
, "OSPF default information is on\n");
1687 /* Show debug status for NSSA. */
1688 if (IS_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1689 vty_out(vty
, " OSPF NSSA debugging is on\n");
1691 /* Show debug status for LDP-SYNC. */
1692 if (IS_DEBUG_OSPF(ldp_sync
, LDP_SYNC
) == OSPF_DEBUG_LDP_SYNC
)
1693 vty_out(vty
, " OSPF ldp-sync debugging is on\n");
1695 /* Show debug status for GR helper. */
1696 if (IS_DEBUG_OSPF(gr
, GR_HELPER
) == OSPF_DEBUG_GR_HELPER
)
1697 vty_out(vty
, " OSPF Graceful Restart Helper debugging is on\n");
1704 DEFUN_NOSH (show_debugging_ospf
,
1705 show_debugging_ospf_cmd
,
1706 "show debugging [ospf]",
1711 struct ospf
*ospf
= NULL
;
1713 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1717 return show_debugging_ospf_common(vty
, ospf
);
1720 DEFUN_NOSH (show_debugging_ospf_instance
,
1721 show_debugging_ospf_instance_cmd
,
1722 "show debugging ospf (1-65535)",
1730 unsigned short instance
= 0;
1732 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1733 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
)
1736 return show_debugging_ospf_common(vty
, ospf
);
1739 static int config_write_debug(struct vty
*vty
);
1741 static struct cmd_node debug_node
= {
1745 .config_write
= config_write_debug
,
1748 static int config_write_debug(struct vty
*vty
)
1753 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update",
1755 const char *detail_str
[] = {
1756 "", " send", " recv", "",
1757 " detail", " send detail", " recv detail", " detail"};
1763 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1768 snprintf(str
, sizeof(str
), " %u", ospf
->instance
);
1770 /* debug ospf ism (status|events|timers). */
1771 if (IS_CONF_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1772 vty_out(vty
, "debug ospf%s ism\n", str
);
1774 if (IS_CONF_DEBUG_OSPF(ism
, ISM_STATUS
))
1775 vty_out(vty
, "debug ospf%s ism status\n", str
);
1776 if (IS_CONF_DEBUG_OSPF(ism
, ISM_EVENTS
))
1777 vty_out(vty
, "debug ospf%s ism event\n", str
);
1778 if (IS_CONF_DEBUG_OSPF(ism
, ISM_TIMERS
))
1779 vty_out(vty
, "debug ospf%s ism timer\n", str
);
1782 /* debug ospf nsm (status|events|timers). */
1783 if (IS_CONF_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1784 vty_out(vty
, "debug ospf%s nsm\n", str
);
1786 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_STATUS
))
1787 vty_out(vty
, "debug ospf%s nsm status\n", str
);
1788 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1789 vty_out(vty
, "debug ospf%s nsm event\n", str
);
1790 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1791 vty_out(vty
, "debug ospf%s nsm timer\n", str
);
1794 /* debug ospf lsa (generate|flooding|install|refresh). */
1795 if (IS_CONF_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1796 vty_out(vty
, "debug ospf%s lsa\n", str
);
1798 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1799 vty_out(vty
, "debug ospf%s lsa generate\n", str
);
1800 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1801 vty_out(vty
, "debug ospf%s lsa flooding\n", str
);
1802 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1803 vty_out(vty
, "debug ospf%s lsa install\n", str
);
1804 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1805 vty_out(vty
, "debug ospf%s lsa refresh\n", str
);
1810 /* debug ospf zebra (interface|redistribute). */
1811 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1812 vty_out(vty
, "debug ospf%s zebra\n", str
);
1814 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1815 vty_out(vty
, "debug ospf%s zebra interface\n", str
);
1816 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1817 vty_out(vty
, "debug ospf%s zebra redistribute\n", str
);
1822 /* debug ospf event. */
1823 if (IS_CONF_DEBUG_OSPF(event
, EVENT
) == OSPF_DEBUG_EVENT
) {
1824 vty_out(vty
, "debug ospf%s event\n", str
);
1828 /* debug ospf nssa. */
1829 if (IS_CONF_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
) {
1830 vty_out(vty
, "debug ospf%s nssa\n", str
);
1834 /* debug ospf packet all detail. */
1835 r
= OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
;
1836 for (i
= 0; i
< 5; i
++)
1837 r
&= conf_debug_ospf_packet
[i
]
1838 & (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
);
1839 if (r
== (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
)) {
1840 vty_out(vty
, "debug ospf%s packet all detail\n", str
);
1844 /* debug ospf packet all. */
1845 r
= OSPF_DEBUG_SEND_RECV
;
1846 for (i
= 0; i
< 5; i
++)
1847 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
1848 if (r
== OSPF_DEBUG_SEND_RECV
) {
1849 vty_out(vty
, "debug ospf%s packet all\n", str
);
1850 for (i
= 0; i
< 5; i
++)
1851 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
1852 vty_out(vty
, "debug ospf%s packet %s detail\n",
1857 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1858 (send|recv) (detail). */
1859 for (i
= 0; i
< 5; i
++) {
1860 if (conf_debug_ospf_packet
[i
] == 0)
1863 vty_out(vty
, "debug ospf%s packet %s%s\n", str
, type_str
[i
],
1864 detail_str
[conf_debug_ospf_packet
[i
]]);
1869 if (IS_CONF_DEBUG_OSPF(te
, TE
) == OSPF_DEBUG_TE
) {
1870 vty_out(vty
, "debug ospf%s te\n", str
);
1875 if (IS_CONF_DEBUG_OSPF(sr
, SR
) == OSPF_DEBUG_SR
) {
1876 vty_out(vty
, "debug ospf%s sr\n", str
);
1880 /* debug ospf ldp-sync */
1881 if (IS_CONF_DEBUG_OSPF(ldp_sync
, LDP_SYNC
) == OSPF_DEBUG_LDP_SYNC
) {
1882 vty_out(vty
, "debug ospf%s ldp-sync\n", str
);
1886 /* debug ospf gr helper */
1887 if (IS_CONF_DEBUG_OSPF(gr
, GR_HELPER
) == OSPF_DEBUG_GR_HELPER
) {
1888 vty_out(vty
, "debug ospf%s graceful-restart helper\n", str
);
1895 /* Initialize debug commands. */
1896 void ospf_debug_init(void)
1898 install_node(&debug_node
);
1900 install_element(ENABLE_NODE
, &show_debugging_ospf_cmd
);
1901 install_element(ENABLE_NODE
, &debug_ospf_ism_cmd
);
1902 install_element(ENABLE_NODE
, &debug_ospf_nsm_cmd
);
1903 install_element(ENABLE_NODE
, &debug_ospf_lsa_cmd
);
1904 install_element(ENABLE_NODE
, &debug_ospf_zebra_cmd
);
1905 install_element(ENABLE_NODE
, &debug_ospf_event_cmd
);
1906 install_element(ENABLE_NODE
, &debug_ospf_nssa_cmd
);
1907 install_element(ENABLE_NODE
, &debug_ospf_te_cmd
);
1908 install_element(ENABLE_NODE
, &debug_ospf_sr_cmd
);
1909 install_element(ENABLE_NODE
, &debug_ospf_default_info_cmd
);
1910 install_element(ENABLE_NODE
, &debug_ospf_ldp_sync_cmd
);
1911 install_element(ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
1912 install_element(ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
1913 install_element(ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
1914 install_element(ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
1915 install_element(ENABLE_NODE
, &no_debug_ospf_event_cmd
);
1916 install_element(ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
1917 install_element(ENABLE_NODE
, &no_debug_ospf_te_cmd
);
1918 install_element(ENABLE_NODE
, &no_debug_ospf_sr_cmd
);
1919 install_element(ENABLE_NODE
, &no_debug_ospf_default_info_cmd
);
1920 install_element(ENABLE_NODE
, &no_debug_ospf_ldp_sync_cmd
);
1921 install_element(ENABLE_NODE
, &debug_ospf_gr_cmd
);
1923 install_element(ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
1924 install_element(ENABLE_NODE
, &debug_ospf_packet_cmd
);
1925 install_element(ENABLE_NODE
, &no_debug_ospf_packet_cmd
);
1927 install_element(ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
1928 install_element(ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
1929 install_element(ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
1930 install_element(ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
1931 install_element(ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
1932 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1933 install_element(ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1934 install_element(ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1935 install_element(ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
1936 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1937 install_element(ENABLE_NODE
, &no_debug_ospf_cmd
);
1939 install_element(CONFIG_NODE
, &debug_ospf_packet_cmd
);
1940 install_element(CONFIG_NODE
, &no_debug_ospf_packet_cmd
);
1941 install_element(CONFIG_NODE
, &debug_ospf_ism_cmd
);
1942 install_element(CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
1944 install_element(CONFIG_NODE
, &debug_ospf_nsm_cmd
);
1945 install_element(CONFIG_NODE
, &debug_ospf_lsa_cmd
);
1946 install_element(CONFIG_NODE
, &debug_ospf_zebra_cmd
);
1947 install_element(CONFIG_NODE
, &debug_ospf_event_cmd
);
1948 install_element(CONFIG_NODE
, &debug_ospf_nssa_cmd
);
1949 install_element(CONFIG_NODE
, &debug_ospf_te_cmd
);
1950 install_element(CONFIG_NODE
, &debug_ospf_sr_cmd
);
1951 install_element(CONFIG_NODE
, &debug_ospf_default_info_cmd
);
1952 install_element(CONFIG_NODE
, &debug_ospf_ldp_sync_cmd
);
1953 install_element(CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
1954 install_element(CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
1955 install_element(CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
1956 install_element(CONFIG_NODE
, &no_debug_ospf_event_cmd
);
1957 install_element(CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
1958 install_element(CONFIG_NODE
, &no_debug_ospf_te_cmd
);
1959 install_element(CONFIG_NODE
, &no_debug_ospf_sr_cmd
);
1960 install_element(CONFIG_NODE
, &no_debug_ospf_default_info_cmd
);
1961 install_element(CONFIG_NODE
, &no_debug_ospf_ldp_sync_cmd
);
1962 install_element(CONFIG_NODE
, &debug_ospf_gr_cmd
);
1964 install_element(CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
1965 install_element(CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
1966 install_element(CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
1967 install_element(CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
1968 install_element(CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
1969 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1970 install_element(CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1971 install_element(CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1972 install_element(CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
1973 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1974 install_element(CONFIG_NODE
, &no_debug_ospf_cmd
);