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"
45 /* Configuration debug option variables. */
46 unsigned long conf_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
47 unsigned long conf_debug_ospf_event
= 0;
48 unsigned long conf_debug_ospf_ism
= 0;
49 unsigned long conf_debug_ospf_nsm
= 0;
50 unsigned long conf_debug_ospf_lsa
= 0;
51 unsigned long conf_debug_ospf_zebra
= 0;
52 unsigned long conf_debug_ospf_nssa
= 0;
53 unsigned long conf_debug_ospf_te
= 0;
54 unsigned long conf_debug_ospf_ext
= 0;
55 unsigned long conf_debug_ospf_sr
= 0;
57 /* Enable debug option variables -- valid only session. */
58 unsigned long term_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
59 unsigned long term_debug_ospf_event
= 0;
60 unsigned long term_debug_ospf_ism
= 0;
61 unsigned long term_debug_ospf_nsm
= 0;
62 unsigned long term_debug_ospf_lsa
= 0;
63 unsigned long term_debug_ospf_zebra
= 0;
64 unsigned long term_debug_ospf_nssa
= 0;
65 unsigned long term_debug_ospf_te
= 0;
66 unsigned long term_debug_ospf_ext
= 0;
67 unsigned long term_debug_ospf_sr
= 0;
69 const char *ospf_redist_string(unsigned int route_type
)
71 return (route_type
== ZEBRA_ROUTE_MAX
) ? "Default"
72 : zebra_route_string(route_type
);
75 #define OSPF_AREA_STRING_MAXLEN 16
76 const char *ospf_area_name_string(struct ospf_area
*area
)
78 static char buf
[OSPF_AREA_STRING_MAXLEN
] = "";
84 area_id
= ntohl(area
->area_id
.s_addr
);
85 snprintf(buf
, OSPF_AREA_STRING_MAXLEN
, "%d.%d.%d.%d",
86 (area_id
>> 24) & 0xff, (area_id
>> 16) & 0xff,
87 (area_id
>> 8) & 0xff, area_id
& 0xff);
91 #define OSPF_AREA_DESC_STRING_MAXLEN 23
92 const char *ospf_area_desc_string(struct ospf_area
*area
)
94 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
98 return "(incomplete)";
100 type
= area
->external_routing
;
103 snprintf(buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [NSSA]",
104 ospf_area_name_string(area
));
107 snprintf(buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [Stub]",
108 ospf_area_name_string(area
));
111 return ospf_area_name_string(area
);
117 #define OSPF_IF_STRING_MAXLEN 40
118 const char *ospf_if_name_string(struct ospf_interface
*oi
)
120 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
123 if (!oi
|| !oi
->address
)
126 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
127 return oi
->ifp
->name
;
129 ifaddr
= ntohl(oi
->address
->u
.prefix4
.s_addr
);
130 snprintf(buf
, OSPF_IF_STRING_MAXLEN
, "%s:%d.%d.%d.%d", oi
->ifp
->name
,
131 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
132 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
137 void ospf_nbr_state_message(struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
140 struct ospf_interface
*oi
= nbr
->oi
;
142 if (IPV4_ADDR_SAME(&DR(oi
), &nbr
->address
.u
.prefix4
))
144 else if (IPV4_ADDR_SAME(&BDR(oi
), &nbr
->address
.u
.prefix4
))
149 snprintf(buf
, size
, "%s/%s",
150 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
),
151 lookup_msg(ospf_ism_state_msg
, state
, NULL
));
154 const char *ospf_timeval_dump(struct timeval
*t
, char *buf
, size_t size
)
156 /* Making formatted timer strings. */
157 #define MINUTE_IN_SECONDS 60
158 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
159 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
160 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
161 unsigned long w
, d
, h
, m
, ms
, us
;
166 w
= d
= h
= m
= ms
= 0;
167 memset(buf
, 0, size
);
173 (void)us
; /* unused */
177 t
->tv_sec
+= ms
/ 1000;
181 if (t
->tv_sec
> WEEK_IN_SECONDS
) {
182 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
183 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
186 if (t
->tv_sec
> DAY_IN_SECONDS
) {
187 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
188 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
191 if (t
->tv_sec
>= HOUR_IN_SECONDS
) {
192 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
193 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
196 if (t
->tv_sec
>= MINUTE_IN_SECONDS
) {
197 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
198 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
202 snprintf(buf
, size
, "%luw%1lud", w
, d
);
204 snprintf(buf
, size
, "%luw%1lud%02luh", w
, d
, h
);
206 snprintf(buf
, size
, "%1lud%02luh%02lum", d
, h
, m
);
208 snprintf(buf
, size
, "%luh%02lum%02lds", h
, m
, (long)t
->tv_sec
);
210 snprintf(buf
, size
, "%lum%02lds", m
, (long)t
->tv_sec
);
212 snprintf(buf
, size
, "%ld.%03lus", (long)t
->tv_sec
, ms
);
214 snprintf(buf
, size
, "%ld usecs", (long)t
->tv_usec
);
219 const char *ospf_timer_dump(struct thread
*t
, char *buf
, size_t size
)
221 struct timeval result
;
225 monotime_until(&t
->u
.sands
, &result
);
226 return ospf_timeval_dump(&result
, buf
, size
);
229 static void ospf_packet_hello_dump(struct stream
*s
, uint16_t length
)
231 struct ospf_hello
*hello
;
234 hello
= (struct ospf_hello
*)stream_pnt(s
);
237 zlog_debug(" NetworkMask %s", inet_ntoa(hello
->network_mask
));
238 zlog_debug(" HelloInterval %d", ntohs(hello
->hello_interval
));
239 zlog_debug(" Options %d (%s)", hello
->options
,
240 ospf_options_dump(hello
->options
));
241 zlog_debug(" RtrPriority %d", hello
->priority
);
242 zlog_debug(" RtrDeadInterval %ld",
243 (unsigned long)ntohl(hello
->dead_interval
));
244 zlog_debug(" DRouter %s", inet_ntoa(hello
->d_router
));
245 zlog_debug(" BDRouter %s", inet_ntoa(hello
->bd_router
));
247 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
248 zlog_debug(" # Neighbors %d", length
/ 4);
249 for (i
= 0; length
> 0; i
++, length
-= sizeof(struct in_addr
))
250 zlog_debug(" Neighbor %s", inet_ntoa(hello
->neighbors
[i
]));
253 static char *ospf_dd_flags_dump(uint8_t flags
, char *buf
, size_t size
)
255 snprintf(buf
, size
, "%s|%s|%s", (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
256 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
257 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
262 static char *ospf_router_lsa_flags_dump(uint8_t flags
, char *buf
, size_t size
)
264 snprintf(buf
, size
, "%s|%s|%s",
265 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
266 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
267 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
272 static void ospf_router_lsa_dump(struct stream
*s
, uint16_t length
)
275 struct router_lsa
*rl
;
278 rl
= (struct router_lsa
*)stream_pnt(s
);
280 zlog_debug(" Router-LSA");
281 zlog_debug(" flags %s",
282 ospf_router_lsa_flags_dump(rl
->flags
, buf
, BUFSIZ
));
283 zlog_debug(" # links %d", ntohs(rl
->links
));
285 len
= ntohs(rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
286 for (i
= 0; len
> 0; i
++) {
287 zlog_debug(" Link ID %s", inet_ntoa(rl
->link
[i
].link_id
));
288 zlog_debug(" Link Data %s",
289 inet_ntoa(rl
->link
[i
].link_data
));
290 zlog_debug(" Type %d", (uint8_t)rl
->link
[i
].type
);
291 zlog_debug(" TOS %d", (uint8_t)rl
->link
[i
].tos
);
292 zlog_debug(" metric %d", ntohs(rl
->link
[i
].metric
));
298 static void ospf_network_lsa_dump(struct stream
*s
, uint16_t length
)
300 struct network_lsa
*nl
;
303 nl
= (struct network_lsa
*)stream_pnt(s
);
304 cnt
= (ntohs(nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
306 zlog_debug(" Network-LSA");
308 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
309 zlog_debug ("Network-LSA size %d",
310 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
312 zlog_debug(" Network Mask %s", inet_ntoa(nl
->mask
));
313 zlog_debug(" # Attached Routers %d", cnt
);
314 for (i
= 0; i
< cnt
; i
++)
315 zlog_debug(" Attached Router %s",
316 inet_ntoa(nl
->routers
[i
]));
319 static void ospf_summary_lsa_dump(struct stream
*s
, uint16_t length
)
321 struct summary_lsa
*sl
;
325 sl
= (struct summary_lsa
*)stream_pnt(s
);
327 zlog_debug(" Summary-LSA");
328 zlog_debug(" Network Mask %s", inet_ntoa(sl
->mask
));
330 size
= ntohs(sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
331 for (i
= 0; size
> 0; size
-= 4, i
++)
332 zlog_debug(" TOS=%d metric %d", sl
->tos
,
333 GET_METRIC(sl
->metric
));
336 static void ospf_as_external_lsa_dump(struct stream
*s
, uint16_t length
)
338 struct as_external_lsa
*al
;
342 al
= (struct as_external_lsa
*)stream_pnt(s
);
343 zlog_debug(" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
344 zlog_debug(" Network Mask %s", inet_ntoa(al
->mask
));
346 size
= ntohs(al
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
347 for (i
= 0; size
> 0; size
-= 12, i
++) {
348 zlog_debug(" bit %s TOS=%d metric %d",
349 IS_EXTERNAL_METRIC(al
->e
[i
].tos
) ? "E" : "-",
350 al
->e
[i
].tos
& 0x7f, GET_METRIC(al
->e
[i
].metric
));
351 zlog_debug(" Forwarding address %s",
352 inet_ntoa(al
->e
[i
].fwd_addr
));
353 zlog_debug(" External Route Tag %" ROUTE_TAG_PRI
,
358 static void ospf_lsa_header_list_dump(struct stream
*s
, uint16_t length
)
360 struct lsa_header
*lsa
;
362 zlog_debug(" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
366 lsa
= (struct lsa_header
*)stream_pnt(s
);
367 ospf_lsa_header_dump(lsa
);
369 stream_forward_getp(s
, OSPF_LSA_HEADER_SIZE
);
370 length
-= OSPF_LSA_HEADER_SIZE
;
374 static void ospf_packet_db_desc_dump(struct stream
*s
, uint16_t length
)
376 struct ospf_db_desc
*dd
;
381 gp
= stream_get_getp(s
);
382 dd
= (struct ospf_db_desc
*)stream_pnt(s
);
384 zlog_debug("Database Description");
385 zlog_debug(" Interface MTU %d", ntohs(dd
->mtu
));
386 zlog_debug(" Options %d (%s)", dd
->options
,
387 ospf_options_dump(dd
->options
));
388 zlog_debug(" Flags %d (%s)", dd
->flags
,
389 ospf_dd_flags_dump(dd
->flags
, dd_flags
, sizeof(dd_flags
)));
390 zlog_debug(" Sequence Number 0x%08lx",
391 (unsigned long)ntohl(dd
->dd_seqnum
));
393 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
395 stream_forward_getp(s
, OSPF_DB_DESC_MIN_SIZE
);
397 ospf_lsa_header_list_dump(s
, length
);
399 stream_set_getp(s
, gp
);
402 static void ospf_packet_ls_req_dump(struct stream
*s
, uint16_t length
)
406 struct in_addr ls_id
;
407 struct in_addr adv_router
;
409 sp
= stream_get_getp(s
);
411 length
-= OSPF_HEADER_SIZE
;
413 zlog_debug("Link State Request");
414 zlog_debug(" # Requests %d", length
/ 12);
416 for (; length
> 0; length
-= 12) {
417 ls_type
= stream_getl(s
);
418 ls_id
.s_addr
= stream_get_ipv4(s
);
419 adv_router
.s_addr
= stream_get_ipv4(s
);
421 zlog_debug(" LS type %d", ls_type
);
422 zlog_debug(" Link State ID %s", inet_ntoa(ls_id
));
423 zlog_debug(" Advertising Router %s", inet_ntoa(adv_router
));
426 stream_set_getp(s
, sp
);
429 static void ospf_packet_ls_upd_dump(struct stream
*s
, uint16_t length
)
432 struct lsa_header
*lsa
;
436 length
-= OSPF_HEADER_SIZE
;
438 sp
= stream_get_getp(s
);
440 count
= stream_getl(s
);
443 zlog_debug("Link State Update");
444 zlog_debug(" # LSAs %d", count
);
446 while (length
> 0 && count
> 0) {
447 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0) {
448 zlog_debug(" Remaining %d bytes; Incorrect length.",
453 lsa
= (struct lsa_header
*)stream_pnt(s
);
454 lsa_len
= ntohs(lsa
->length
);
455 ospf_lsa_header_dump(lsa
);
458 case OSPF_ROUTER_LSA
:
459 ospf_router_lsa_dump(s
, length
);
461 case OSPF_NETWORK_LSA
:
462 ospf_network_lsa_dump(s
, length
);
464 case OSPF_SUMMARY_LSA
:
465 case OSPF_ASBR_SUMMARY_LSA
:
466 ospf_summary_lsa_dump(s
, length
);
468 case OSPF_AS_EXTERNAL_LSA
:
469 ospf_as_external_lsa_dump(s
, length
);
471 case OSPF_AS_NSSA_LSA
:
472 ospf_as_external_lsa_dump(s
, length
);
474 case OSPF_OPAQUE_LINK_LSA
:
475 case OSPF_OPAQUE_AREA_LSA
:
476 case OSPF_OPAQUE_AS_LSA
:
477 ospf_opaque_lsa_dump(s
, length
);
483 stream_forward_getp(s
, lsa_len
);
488 stream_set_getp(s
, sp
);
491 static void ospf_packet_ls_ack_dump(struct stream
*s
, uint16_t length
)
495 length
-= OSPF_HEADER_SIZE
;
496 sp
= stream_get_getp(s
);
498 zlog_debug("Link State Acknowledgment");
499 ospf_lsa_header_list_dump(s
, length
);
501 stream_set_getp(s
, sp
);
504 static void ospf_header_dump(struct ospf_header
*ospfh
)
507 uint16_t auth_type
= ntohs(ospfh
->auth_type
);
509 zlog_debug("Header");
510 zlog_debug(" Version %d", ospfh
->version
);
511 zlog_debug(" Type %d (%s)", ospfh
->type
,
512 lookup_msg(ospf_packet_type_str
, ospfh
->type
, NULL
));
513 zlog_debug(" Packet Len %d", ntohs(ospfh
->length
));
514 zlog_debug(" Router ID %s", inet_ntoa(ospfh
->router_id
));
515 zlog_debug(" Area ID %s", inet_ntoa(ospfh
->area_id
));
516 zlog_debug(" Checksum 0x%x", ntohs(ospfh
->checksum
));
517 zlog_debug(" AuType %s",
518 lookup_msg(ospf_auth_type_str
, auth_type
, NULL
));
523 case OSPF_AUTH_SIMPLE
:
524 strlcpy(buf
, (char *)ospfh
->u
.auth_data
, sizeof(buf
));
525 zlog_debug(" Simple Password %s", buf
);
527 case OSPF_AUTH_CRYPTOGRAPHIC
:
528 zlog_debug(" Cryptographic Authentication");
529 zlog_debug(" Key ID %d", ospfh
->u
.crypt
.key_id
);
530 zlog_debug(" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
531 zlog_debug(" Sequence number %ld",
532 (unsigned long)ntohl(ospfh
->u
.crypt
.crypt_seqnum
));
535 zlog_debug("* This is not supported authentication type");
540 void ospf_packet_dump(struct stream
*s
)
542 struct ospf_header
*ospfh
;
545 /* Preserve pointer. */
546 gp
= stream_get_getp(s
);
548 /* OSPF Header dump. */
549 ospfh
= (struct ospf_header
*)stream_pnt(s
);
551 /* Until detail flag is set, return. */
552 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
555 /* Show OSPF header detail. */
556 ospf_header_dump(ospfh
);
557 stream_forward_getp(s
, OSPF_HEADER_SIZE
);
559 switch (ospfh
->type
) {
561 ospf_packet_hello_dump(s
, ntohs(ospfh
->length
));
563 case OSPF_MSG_DB_DESC
:
564 ospf_packet_db_desc_dump(s
, ntohs(ospfh
->length
));
566 case OSPF_MSG_LS_REQ
:
567 ospf_packet_ls_req_dump(s
, ntohs(ospfh
->length
));
569 case OSPF_MSG_LS_UPD
:
570 ospf_packet_ls_upd_dump(s
, ntohs(ospfh
->length
));
572 case OSPF_MSG_LS_ACK
:
573 ospf_packet_ls_ack_dump(s
, ntohs(ospfh
->length
));
579 stream_set_getp(s
, gp
);
582 DEFUN (debug_ospf_packet
,
583 debug_ospf_packet_cmd
,
584 "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
590 "OSPF Database Description\n"
591 "OSPF Link State Request\n"
592 "OSPF Link State Update\n"
593 "OSPF Link State Acknowledgment\n"
596 "Detail Information\n"
598 "Detail Information\n"
599 "Detail Information\n")
601 int inst
= (argv
[2]->type
== RANGE_TKN
) ? 1 : 0;
602 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
603 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
604 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
605 char *packet
= argv
[3 + inst
]->text
;
607 if (inst
) // user passed instance ID
609 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
610 return CMD_NOT_MY_INSTANCE
;
617 /* Check packet type. */
618 if (strmatch(packet
, "hello"))
619 type
= OSPF_DEBUG_HELLO
;
620 else if (strmatch(packet
, "dd"))
621 type
= OSPF_DEBUG_DB_DESC
;
622 else if (strmatch(packet
, "ls-request"))
623 type
= OSPF_DEBUG_LS_REQ
;
624 else if (strmatch(packet
, "ls-update"))
625 type
= OSPF_DEBUG_LS_UPD
;
626 else if (strmatch(packet
, "ls-ack"))
627 type
= OSPF_DEBUG_LS_ACK
;
628 else if (strmatch(packet
, "all"))
629 type
= OSPF_DEBUG_ALL
;
632 * (none) = send + recv
633 * detail = send + recv + detail
636 * recv detail = recv + detail
637 * send detail = send + detail
642 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
643 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
644 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
646 for (i
= 0; i
< 5; i
++)
647 if (type
& (0x01 << i
)) {
648 if (vty
->node
== CONFIG_NODE
)
649 DEBUG_PACKET_ON(i
, flag
);
651 TERM_DEBUG_PACKET_ON(i
, flag
);
657 DEFUN (no_debug_ospf_packet
,
658 no_debug_ospf_packet_cmd
,
659 "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
666 "OSPF Database Description\n"
667 "OSPF Link State Request\n"
668 "OSPF Link State Update\n"
669 "OSPF Link State Acknowledgment\n"
672 "Detail Information\n"
674 "Detail Information\n"
675 "Detail Information\n")
677 int inst
= (argv
[3]->type
== RANGE_TKN
) ? 1 : 0;
678 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
679 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
680 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
681 char *packet
= argv
[4 + inst
]->text
;
683 if (inst
) // user passed instance ID
685 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
686 return CMD_NOT_MY_INSTANCE
;
693 /* Check packet type. */
694 if (strmatch(packet
, "hello"))
695 type
= OSPF_DEBUG_HELLO
;
696 else if (strmatch(packet
, "dd"))
697 type
= OSPF_DEBUG_DB_DESC
;
698 else if (strmatch(packet
, "ls-request"))
699 type
= OSPF_DEBUG_LS_REQ
;
700 else if (strmatch(packet
, "ls-update"))
701 type
= OSPF_DEBUG_LS_UPD
;
702 else if (strmatch(packet
, "ls-ack"))
703 type
= OSPF_DEBUG_LS_ACK
;
704 else if (strmatch(packet
, "all"))
705 type
= OSPF_DEBUG_ALL
;
708 * (none) = send + recv
709 * detail = send + recv + detail
712 * recv detail = recv + detail
713 * send detail = send + detail
718 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
719 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
720 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
722 for (i
= 0; i
< 5; i
++)
723 if (type
& (0x01 << i
)) {
724 if (vty
->node
== CONFIG_NODE
)
725 DEBUG_PACKET_OFF(i
, flag
);
727 TERM_DEBUG_PACKET_OFF(i
, flag
);
732 for (i = 0; i < 5; i++)
733 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
740 DEFUN (debug_ospf_ism
,
742 "debug ospf [(1-65535)] ism [<status|events|timers>]",
746 "OSPF Interface State Machine\n"
747 "ISM Status Information\n"
748 "ISM Event Information\n"
749 "ISM TImer Information\n")
751 int inst
= (argv
[2]->type
== RANGE_TKN
);
752 char *dbgparam
= (argc
== 4 + inst
) ? argv
[argc
- 1]->text
: NULL
;
754 if (inst
) // user passed instance ID
756 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
757 return CMD_NOT_MY_INSTANCE
;
760 if (vty
->node
== CONFIG_NODE
) {
764 if (strmatch(dbgparam
, "status"))
765 DEBUG_ON(ism
, ISM_STATUS
);
766 else if (strmatch(dbgparam
, "events"))
767 DEBUG_ON(ism
, ISM_EVENTS
);
768 else if (strmatch(dbgparam
, "timers"))
769 DEBUG_ON(ism
, ISM_TIMERS
);
777 TERM_DEBUG_ON(ism
, ISM
);
779 if (strmatch(dbgparam
, "status"))
780 TERM_DEBUG_ON(ism
, ISM_STATUS
);
781 else if (strmatch(dbgparam
, "events"))
782 TERM_DEBUG_ON(ism
, ISM_EVENTS
);
783 else if (strmatch(dbgparam
, "timers"))
784 TERM_DEBUG_ON(ism
, ISM_TIMERS
);
790 DEFUN (no_debug_ospf_ism
,
791 no_debug_ospf_ism_cmd
,
792 "no debug ospf [(1-65535)] ism [<status|events|timers>]",
797 "OSPF Interface State Machine\n"
798 "ISM Status Information\n"
799 "ISM Event Information\n"
800 "ISM TImer Information\n")
802 int inst
= (argv
[3]->type
== RANGE_TKN
);
803 char *dbgparam
= (argc
== 5 + inst
) ? argv
[argc
- 1]->text
: NULL
;
805 if (inst
) // user passed instance ID
807 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
808 return CMD_NOT_MY_INSTANCE
;
811 if (vty
->node
== CONFIG_NODE
) {
815 if (strmatch(dbgparam
, "status"))
816 DEBUG_OFF(ism
, ISM_STATUS
);
817 else if (strmatch(dbgparam
, "events"))
818 DEBUG_OFF(ism
, ISM_EVENTS
);
819 else if (strmatch(dbgparam
, "timers"))
820 DEBUG_OFF(ism
, ISM_TIMERS
);
828 TERM_DEBUG_OFF(ism
, ISM
);
830 if (strmatch(dbgparam
, "status"))
831 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
832 else if (strmatch(dbgparam
, "events"))
833 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
834 else if (strmatch(dbgparam
, "timers"))
835 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
841 static int debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
842 struct cmd_token
**argv
)
844 if (vty
->node
== CONFIG_NODE
) {
845 if (argc
== arg_base
+ 0)
847 else if (argc
== arg_base
+ 1) {
848 if (strmatch(argv
[arg_base
]->text
, "status"))
849 DEBUG_ON(nsm
, NSM_STATUS
);
850 else if (strmatch(argv
[arg_base
]->text
, "events"))
851 DEBUG_ON(nsm
, NSM_EVENTS
);
852 else if (strmatch(argv
[arg_base
]->text
, "timers"))
853 DEBUG_ON(nsm
, NSM_TIMERS
);
860 if (argc
== arg_base
+ 0)
861 TERM_DEBUG_ON(nsm
, NSM
);
862 else if (argc
== arg_base
+ 1) {
863 if (strmatch(argv
[arg_base
]->text
, "status"))
864 TERM_DEBUG_ON(nsm
, NSM_STATUS
);
865 else if (strmatch(argv
[arg_base
]->text
, "events"))
866 TERM_DEBUG_ON(nsm
, NSM_EVENTS
);
867 else if (strmatch(argv
[arg_base
]->text
, "timers"))
868 TERM_DEBUG_ON(nsm
, NSM_TIMERS
);
874 DEFUN (debug_ospf_nsm
,
876 "debug ospf nsm [<status|events|timers>]",
879 "OSPF Neighbor State Machine\n"
880 "NSM Status Information\n"
881 "NSM Event Information\n"
882 "NSM Timer Information\n")
884 return debug_ospf_nsm_common(vty
, 3, argc
, argv
);
887 DEFUN (debug_ospf_instance_nsm
,
888 debug_ospf_instance_nsm_cmd
,
889 "debug ospf (1-65535) nsm [<status|events|timers>]",
893 "OSPF Neighbor State Machine\n"
894 "NSM Status Information\n"
895 "NSM Event Information\n"
896 "NSM Timer Information\n")
899 unsigned short instance
= 0;
901 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
902 if (!ospf_lookup_instance(instance
))
905 return debug_ospf_nsm_common(vty
, 4, argc
, argv
);
909 static int no_debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
910 struct cmd_token
**argv
)
913 if (vty
->node
== CONFIG_NODE
) {
914 if (argc
== arg_base
+ 0)
916 else if (argc
== arg_base
+ 1) {
917 if (strmatch(argv
[arg_base
]->text
, "status"))
918 DEBUG_OFF(nsm
, NSM_STATUS
);
919 else if (strmatch(argv
[arg_base
]->text
, "events"))
920 DEBUG_OFF(nsm
, NSM_EVENTS
);
921 else if (strmatch(argv
[arg_base
]->text
, "timers"))
922 DEBUG_OFF(nsm
, NSM_TIMERS
);
929 if (argc
== arg_base
+ 0)
930 TERM_DEBUG_OFF(nsm
, NSM
);
931 else if (argc
== arg_base
+ 1) {
932 if (strmatch(argv
[arg_base
]->text
, "status"))
933 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
934 else if (strmatch(argv
[arg_base
]->text
, "events"))
935 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
936 else if (strmatch(argv
[arg_base
]->text
, "timers"))
937 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
943 DEFUN (no_debug_ospf_nsm
,
944 no_debug_ospf_nsm_cmd
,
945 "no debug ospf nsm [<status|events|timers>]",
949 "OSPF Neighbor State Machine\n"
950 "NSM Status Information\n"
951 "NSM Event Information\n"
952 "NSM Timer Information\n")
954 return no_debug_ospf_nsm_common(vty
, 4, argc
, argv
);
958 DEFUN (no_debug_ospf_instance_nsm
,
959 no_debug_ospf_instance_nsm_cmd
,
960 "no debug ospf (1-65535) nsm [<status|events|timers>]",
965 "OSPF Neighbor State Machine\n"
966 "NSM Status Information\n"
967 "NSM Event Information\n"
968 "NSM Timer Information\n")
971 unsigned short instance
= 0;
973 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
974 if (!ospf_lookup_instance(instance
))
975 return CMD_NOT_MY_INSTANCE
;
977 return no_debug_ospf_nsm_common(vty
, 5, argc
, argv
);
981 static int debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
982 struct cmd_token
**argv
)
984 if (vty
->node
== CONFIG_NODE
) {
985 if (argc
== arg_base
+ 0)
987 else if (argc
== arg_base
+ 1) {
988 if (strmatch(argv
[arg_base
]->text
, "generate"))
989 DEBUG_ON(lsa
, LSA_GENERATE
);
990 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
991 DEBUG_ON(lsa
, LSA_FLOODING
);
992 else if (strmatch(argv
[arg_base
]->text
, "install"))
993 DEBUG_ON(lsa
, LSA_INSTALL
);
994 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
995 DEBUG_ON(lsa
, LSA_REFRESH
);
1002 if (argc
== arg_base
+ 0)
1003 TERM_DEBUG_ON(lsa
, LSA
);
1004 else if (argc
== arg_base
+ 1) {
1005 if (strmatch(argv
[arg_base
]->text
, "generate"))
1006 TERM_DEBUG_ON(lsa
, LSA_GENERATE
);
1007 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1008 TERM_DEBUG_ON(lsa
, LSA_FLOODING
);
1009 else if (strmatch(argv
[arg_base
]->text
, "install"))
1010 TERM_DEBUG_ON(lsa
, LSA_INSTALL
);
1011 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1012 TERM_DEBUG_ON(lsa
, LSA_REFRESH
);
1018 DEFUN (debug_ospf_lsa
,
1020 "debug ospf lsa [<generate|flooding|install|refresh>]",
1023 "OSPF Link State Advertisement\n"
1026 "LSA Install/Delete\n"
1029 return debug_ospf_lsa_common(vty
, 3, argc
, argv
);
1032 DEFUN (debug_ospf_instance_lsa
,
1033 debug_ospf_instance_lsa_cmd
,
1034 "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1038 "OSPF Link State Advertisement\n"
1041 "LSA Install/Delete\n"
1045 unsigned short instance
= 0;
1047 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1048 if (!ospf_lookup_instance(instance
))
1049 return CMD_NOT_MY_INSTANCE
;
1051 return debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1055 static int no_debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
1056 struct cmd_token
**argv
)
1058 if (vty
->node
== CONFIG_NODE
) {
1059 if (argc
== arg_base
+ 0)
1060 DEBUG_OFF(lsa
, LSA
);
1061 else if (argc
== arg_base
+ 1) {
1062 if (strmatch(argv
[arg_base
]->text
, "generate"))
1063 DEBUG_OFF(lsa
, LSA_GENERATE
);
1064 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1065 DEBUG_OFF(lsa
, LSA_FLOODING
);
1066 else if (strmatch(argv
[arg_base
]->text
, "install"))
1067 DEBUG_OFF(lsa
, LSA_INSTALL
);
1068 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1069 DEBUG_OFF(lsa
, LSA_REFRESH
);
1076 if (argc
== arg_base
+ 0)
1077 TERM_DEBUG_OFF(lsa
, LSA
);
1078 else if (argc
== arg_base
+ 1) {
1079 if (strmatch(argv
[arg_base
]->text
, "generate"))
1080 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1081 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1082 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1083 else if (strmatch(argv
[arg_base
]->text
, "install"))
1084 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1085 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1086 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1092 DEFUN (no_debug_ospf_lsa
,
1093 no_debug_ospf_lsa_cmd
,
1094 "no debug ospf lsa [<generate|flooding|install|refresh>]",
1098 "OSPF Link State Advertisement\n"
1101 "LSA Install/Delete\n"
1104 return no_debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1107 DEFUN (no_debug_ospf_instance_lsa
,
1108 no_debug_ospf_instance_lsa_cmd
,
1109 "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1114 "OSPF Link State Advertisement\n"
1117 "LSA Install/Delete\n"
1121 unsigned short instance
= 0;
1123 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1124 if (!ospf_lookup_instance(instance
))
1125 return CMD_NOT_MY_INSTANCE
;
1127 return no_debug_ospf_lsa_common(vty
, 5, argc
, argv
);
1131 static int debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1132 struct cmd_token
**argv
)
1134 if (vty
->node
== CONFIG_NODE
) {
1135 if (argc
== arg_base
+ 0)
1136 DEBUG_ON(zebra
, ZEBRA
);
1137 else if (argc
== arg_base
+ 1) {
1138 if (strmatch(argv
[arg_base
]->text
, "interface"))
1139 DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1140 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1141 DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1148 if (argc
== arg_base
+ 0)
1149 TERM_DEBUG_ON(zebra
, ZEBRA
);
1150 else if (argc
== arg_base
+ 1) {
1151 if (strmatch(argv
[arg_base
]->text
, "interface"))
1152 TERM_DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1153 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1154 TERM_DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1160 DEFUN (debug_ospf_zebra
,
1161 debug_ospf_zebra_cmd
,
1162 "debug ospf zebra [<interface|redistribute>]",
1167 "Zebra redistribute\n")
1169 return debug_ospf_zebra_common(vty
, 3, argc
, argv
);
1172 DEFUN (debug_ospf_instance_zebra
,
1173 debug_ospf_instance_zebra_cmd
,
1174 "debug ospf (1-65535) zebra [<interface|redistribute>]",
1180 "Zebra redistribute\n")
1183 unsigned short instance
= 0;
1185 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1186 if (!ospf_lookup_instance(instance
))
1187 return CMD_NOT_MY_INSTANCE
;
1189 return debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1193 static int no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1194 struct cmd_token
**argv
)
1196 if (vty
->node
== CONFIG_NODE
) {
1197 if (argc
== arg_base
+ 0)
1198 DEBUG_OFF(zebra
, ZEBRA
);
1199 else if (argc
== arg_base
+ 1) {
1200 if (strmatch(argv
[arg_base
]->text
, "interface"))
1201 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1202 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1203 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1210 if (argc
== arg_base
+ 0)
1211 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1212 else if (argc
== arg_base
+ 1) {
1213 if (strmatch(argv
[arg_base
]->text
, "interface"))
1214 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1215 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1216 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1222 DEFUN (no_debug_ospf_zebra
,
1223 no_debug_ospf_zebra_cmd
,
1224 "no debug ospf zebra [<interface|redistribute>]",
1230 "Zebra redistribute\n")
1232 return no_debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1235 DEFUN (no_debug_ospf_instance_zebra
,
1236 no_debug_ospf_instance_zebra_cmd
,
1237 "no debug ospf (1-65535) zebra [<interface|redistribute>]",
1244 "Zebra redistribute\n")
1247 unsigned short instance
= 0;
1249 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1250 if (!ospf_lookup_instance(instance
))
1253 return no_debug_ospf_zebra_common(vty
, 5, argc
, argv
);
1257 DEFUN (debug_ospf_event
,
1258 debug_ospf_event_cmd
,
1262 "OSPF event information\n")
1264 if (vty
->node
== CONFIG_NODE
)
1265 CONF_DEBUG_ON(event
, EVENT
);
1266 TERM_DEBUG_ON(event
, EVENT
);
1270 DEFUN (no_debug_ospf_event
,
1271 no_debug_ospf_event_cmd
,
1272 "no debug ospf event",
1276 "OSPF event information\n")
1278 if (vty
->node
== CONFIG_NODE
)
1279 CONF_DEBUG_OFF(event
, EVENT
);
1280 TERM_DEBUG_OFF(event
, EVENT
);
1284 DEFUN (debug_ospf_instance_event
,
1285 debug_ospf_instance_event_cmd
,
1286 "debug ospf (1-65535) event",
1290 "OSPF event information\n")
1293 unsigned short instance
= 0;
1295 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1296 if (!ospf_lookup_instance(instance
))
1299 if (vty
->node
== CONFIG_NODE
)
1300 CONF_DEBUG_ON(event
, EVENT
);
1301 TERM_DEBUG_ON(event
, EVENT
);
1305 DEFUN (no_debug_ospf_instance_event
,
1306 no_debug_ospf_instance_event_cmd
,
1307 "no debug ospf (1-65535) event",
1312 "OSPF event information\n")
1315 unsigned short instance
= 0;
1317 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1318 if (!ospf_lookup_instance(instance
))
1321 if (vty
->node
== CONFIG_NODE
)
1322 CONF_DEBUG_OFF(event
, EVENT
);
1323 TERM_DEBUG_OFF(event
, EVENT
);
1327 DEFUN (debug_ospf_nssa
,
1328 debug_ospf_nssa_cmd
,
1332 "OSPF nssa information\n")
1334 if (vty
->node
== CONFIG_NODE
)
1335 CONF_DEBUG_ON(nssa
, NSSA
);
1336 TERM_DEBUG_ON(nssa
, NSSA
);
1340 DEFUN (no_debug_ospf_nssa
,
1341 no_debug_ospf_nssa_cmd
,
1342 "no debug ospf nssa",
1346 "OSPF nssa information\n")
1348 if (vty
->node
== CONFIG_NODE
)
1349 CONF_DEBUG_OFF(nssa
, NSSA
);
1350 TERM_DEBUG_OFF(nssa
, NSSA
);
1354 DEFUN (debug_ospf_instance_nssa
,
1355 debug_ospf_instance_nssa_cmd
,
1356 "debug ospf (1-65535) nssa",
1360 "OSPF nssa information\n")
1363 unsigned short instance
= 0;
1365 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1366 if (!ospf_lookup_instance(instance
))
1369 if (vty
->node
== CONFIG_NODE
)
1370 CONF_DEBUG_ON(nssa
, NSSA
);
1371 TERM_DEBUG_ON(nssa
, NSSA
);
1375 DEFUN (no_debug_ospf_instance_nssa
,
1376 no_debug_ospf_instance_nssa_cmd
,
1377 "no debug ospf (1-65535) nssa",
1382 "OSPF nssa information\n")
1385 unsigned short instance
= 0;
1387 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1388 if (!ospf_lookup_instance(instance
))
1391 if (vty
->node
== CONFIG_NODE
)
1392 CONF_DEBUG_OFF(nssa
, NSSA
);
1393 TERM_DEBUG_OFF(nssa
, NSSA
);
1397 DEFUN (debug_ospf_te
,
1402 "OSPF-TE information\n")
1404 if (vty
->node
== CONFIG_NODE
)
1405 CONF_DEBUG_ON(te
, TE
);
1406 TERM_DEBUG_ON(te
, TE
);
1410 DEFUN (no_debug_ospf_te
,
1411 no_debug_ospf_te_cmd
,
1416 "OSPF-TE information\n")
1418 if (vty
->node
== CONFIG_NODE
)
1419 CONF_DEBUG_OFF(te
, TE
);
1420 TERM_DEBUG_OFF(te
, TE
);
1424 DEFUN (debug_ospf_sr
,
1429 "OSPF-SR information\n")
1431 if (vty
->node
== CONFIG_NODE
)
1432 CONF_DEBUG_ON(sr
, SR
);
1433 TERM_DEBUG_ON(sr
, SR
);
1437 DEFUN (no_debug_ospf_sr
,
1438 no_debug_ospf_sr_cmd
,
1443 "OSPF-SR information\n")
1445 if (vty
->node
== CONFIG_NODE
)
1446 CONF_DEBUG_OFF(sr
, SR
);
1447 TERM_DEBUG_OFF(sr
, SR
);
1451 DEFUN (no_debug_ospf
,
1458 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1461 if (vty
->node
== CONFIG_NODE
) {
1462 CONF_DEBUG_OFF(event
, EVENT
);
1463 CONF_DEBUG_OFF(nssa
, NSSA
);
1464 DEBUG_OFF(ism
, ISM_EVENTS
);
1465 DEBUG_OFF(ism
, ISM_STATUS
);
1466 DEBUG_OFF(ism
, ISM_TIMERS
);
1467 DEBUG_OFF(lsa
, LSA
);
1468 DEBUG_OFF(lsa
, LSA_FLOODING
);
1469 DEBUG_OFF(lsa
, LSA_GENERATE
);
1470 DEBUG_OFF(lsa
, LSA_INSTALL
);
1471 DEBUG_OFF(lsa
, LSA_REFRESH
);
1472 DEBUG_OFF(nsm
, NSM
);
1473 DEBUG_OFF(nsm
, NSM_EVENTS
);
1474 DEBUG_OFF(nsm
, NSM_STATUS
);
1475 DEBUG_OFF(nsm
, NSM_TIMERS
);
1476 DEBUG_OFF(zebra
, ZEBRA
);
1477 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1478 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1480 for (i
= 0; i
< 5; i
++)
1481 DEBUG_PACKET_OFF(i
, flag
);
1484 for (i
= 0; i
< 5; i
++)
1485 TERM_DEBUG_PACKET_OFF(i
, flag
);
1487 TERM_DEBUG_OFF(event
, EVENT
);
1488 TERM_DEBUG_OFF(ism
, ISM
);
1489 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
1490 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
1491 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
1492 TERM_DEBUG_OFF(lsa
, LSA
);
1493 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1494 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1495 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1496 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1497 TERM_DEBUG_OFF(nsm
, NSM
);
1498 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
1499 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
1500 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
1501 TERM_DEBUG_OFF(nssa
, NSSA
);
1502 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1503 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1504 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1509 static int show_debugging_ospf_common(struct vty
*vty
, struct ospf
*ospf
)
1514 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
1516 vty_out(vty
, "OSPF debugging status:\n");
1518 /* Show debug status for events. */
1519 if (IS_DEBUG_OSPF(event
, EVENT
))
1520 vty_out(vty
, " OSPF event debugging is on\n");
1522 /* Show debug status for ISM. */
1523 if (IS_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1524 vty_out(vty
, " OSPF ISM debugging is on\n");
1526 if (IS_DEBUG_OSPF(ism
, ISM_STATUS
))
1527 vty_out(vty
, " OSPF ISM status debugging is on\n");
1528 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
1529 vty_out(vty
, " OSPF ISM event debugging is on\n");
1530 if (IS_DEBUG_OSPF(ism
, ISM_TIMERS
))
1531 vty_out(vty
, " OSPF ISM timer debugging is on\n");
1534 /* Show debug status for NSM. */
1535 if (IS_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1536 vty_out(vty
, " OSPF NSM debugging is on\n");
1538 if (IS_DEBUG_OSPF(nsm
, NSM_STATUS
))
1539 vty_out(vty
, " OSPF NSM status debugging is on\n");
1540 if (IS_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1541 vty_out(vty
, " OSPF NSM event debugging is on\n");
1542 if (IS_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1543 vty_out(vty
, " OSPF NSM timer debugging is on\n");
1546 /* Show debug status for OSPF Packets. */
1547 for (i
= 0; i
< 5; i
++)
1548 if (IS_DEBUG_OSPF_PACKET(i
, SEND
)
1549 && IS_DEBUG_OSPF_PACKET(i
, RECV
)) {
1550 vty_out(vty
, " OSPF packet %s%s debugging is on\n",
1551 lookup_msg(ospf_packet_type_str
, i
+ 1, NULL
),
1552 IS_DEBUG_OSPF_PACKET(i
, DETAIL
) ? " detail"
1555 if (IS_DEBUG_OSPF_PACKET(i
, SEND
))
1557 " OSPF packet %s send%s debugging is on\n",
1558 lookup_msg(ospf_packet_type_str
, i
+ 1,
1560 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1563 if (IS_DEBUG_OSPF_PACKET(i
, RECV
))
1565 " OSPF packet %s receive%s debugging is on\n",
1566 lookup_msg(ospf_packet_type_str
, i
+ 1,
1568 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1573 /* Show debug status for OSPF LSAs. */
1574 if (IS_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1575 vty_out(vty
, " OSPF LSA debugging is on\n");
1577 if (IS_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1578 vty_out(vty
, " OSPF LSA generation debugging is on\n");
1579 if (IS_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1580 vty_out(vty
, " OSPF LSA flooding debugging is on\n");
1581 if (IS_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1582 vty_out(vty
, " OSPF LSA install debugging is on\n");
1583 if (IS_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1584 vty_out(vty
, " OSPF LSA refresh debugging is on\n");
1587 /* Show debug status for Zebra. */
1588 if (IS_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1589 vty_out(vty
, " OSPF Zebra debugging is on\n");
1591 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1593 " OSPF Zebra interface debugging is on\n");
1594 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1596 " OSPF Zebra redistribute debugging is on\n");
1599 /* Show debug status for NSSA. */
1600 if (IS_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1601 vty_out(vty
, " OSPF NSSA debugging is on\n");
1608 DEFUN_NOSH (show_debugging_ospf
,
1609 show_debugging_ospf_cmd
,
1610 "show debugging [ospf]",
1615 struct ospf
*ospf
= NULL
;
1617 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1621 return show_debugging_ospf_common(vty
, ospf
);
1624 DEFUN_NOSH (show_debugging_ospf_instance
,
1625 show_debugging_ospf_instance_cmd
,
1626 "show debugging ospf (1-65535)",
1634 unsigned short instance
= 0;
1636 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1637 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
)
1640 return show_debugging_ospf_common(vty
, ospf
);
1643 static int config_write_debug(struct vty
*vty
);
1645 static struct cmd_node debug_node
= {
1649 .config_write
= config_write_debug
,
1652 static int config_write_debug(struct vty
*vty
)
1657 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update",
1659 const char *detail_str
[] = {
1660 "", " send", " recv", "",
1661 " detail", " send detail", " recv detail", " detail"};
1667 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1672 sprintf(str
, " %u", ospf
->instance
);
1674 /* debug ospf ism (status|events|timers). */
1675 if (IS_CONF_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1676 vty_out(vty
, "debug ospf%s ism\n", str
);
1678 if (IS_CONF_DEBUG_OSPF(ism
, ISM_STATUS
))
1679 vty_out(vty
, "debug ospf%s ism status\n", str
);
1680 if (IS_CONF_DEBUG_OSPF(ism
, ISM_EVENTS
))
1681 vty_out(vty
, "debug ospf%s ism event\n", str
);
1682 if (IS_CONF_DEBUG_OSPF(ism
, ISM_TIMERS
))
1683 vty_out(vty
, "debug ospf%s ism timer\n", str
);
1686 /* debug ospf nsm (status|events|timers). */
1687 if (IS_CONF_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1688 vty_out(vty
, "debug ospf%s nsm\n", str
);
1690 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_STATUS
))
1691 vty_out(vty
, "debug ospf%s nsm status\n", str
);
1692 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1693 vty_out(vty
, "debug ospf%s nsm event\n", str
);
1694 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1695 vty_out(vty
, "debug ospf%s nsm timer\n", str
);
1698 /* debug ospf lsa (generate|flooding|install|refresh). */
1699 if (IS_CONF_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1700 vty_out(vty
, "debug ospf%s lsa\n", str
);
1702 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1703 vty_out(vty
, "debug ospf%s lsa generate\n", str
);
1704 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1705 vty_out(vty
, "debug ospf%s lsa flooding\n", str
);
1706 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1707 vty_out(vty
, "debug ospf%s lsa install\n", str
);
1708 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1709 vty_out(vty
, "debug ospf%s lsa refresh\n", str
);
1714 /* debug ospf zebra (interface|redistribute). */
1715 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1716 vty_out(vty
, "debug ospf%s zebra\n", str
);
1718 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1719 vty_out(vty
, "debug ospf%s zebra interface\n", str
);
1720 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1721 vty_out(vty
, "debug ospf%s zebra redistribute\n", str
);
1726 /* debug ospf event. */
1727 if (IS_CONF_DEBUG_OSPF(event
, EVENT
) == OSPF_DEBUG_EVENT
) {
1728 vty_out(vty
, "debug ospf%s event\n", str
);
1732 /* debug ospf nssa. */
1733 if (IS_CONF_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
) {
1734 vty_out(vty
, "debug ospf%s nssa\n", str
);
1738 /* debug ospf packet all detail. */
1739 r
= OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
;
1740 for (i
= 0; i
< 5; i
++)
1741 r
&= conf_debug_ospf_packet
[i
]
1742 & (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
);
1743 if (r
== (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
)) {
1744 vty_out(vty
, "debug ospf%s packet all detail\n", str
);
1748 /* debug ospf packet all. */
1749 r
= OSPF_DEBUG_SEND_RECV
;
1750 for (i
= 0; i
< 5; i
++)
1751 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
1752 if (r
== OSPF_DEBUG_SEND_RECV
) {
1753 vty_out(vty
, "debug ospf%s packet all\n", str
);
1754 for (i
= 0; i
< 5; i
++)
1755 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
1756 vty_out(vty
, "debug ospf%s packet %s detail\n",
1761 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1762 (send|recv) (detail). */
1763 for (i
= 0; i
< 5; i
++) {
1764 if (conf_debug_ospf_packet
[i
] == 0)
1767 vty_out(vty
, "debug ospf%s packet %s%s\n", str
, type_str
[i
],
1768 detail_str
[conf_debug_ospf_packet
[i
]]);
1773 if (IS_CONF_DEBUG_OSPF(te
, TE
) == OSPF_DEBUG_TE
) {
1774 vty_out(vty
, "debug ospf%s te\n", str
);
1779 if (IS_CONF_DEBUG_OSPF(sr
, SR
) == OSPF_DEBUG_SR
) {
1780 vty_out(vty
, "debug ospf%s sr\n", str
);
1787 /* Initialize debug commands. */
1788 void ospf_debug_init(void)
1790 install_node(&debug_node
);
1792 install_element(ENABLE_NODE
, &show_debugging_ospf_cmd
);
1793 install_element(ENABLE_NODE
, &debug_ospf_ism_cmd
);
1794 install_element(ENABLE_NODE
, &debug_ospf_nsm_cmd
);
1795 install_element(ENABLE_NODE
, &debug_ospf_lsa_cmd
);
1796 install_element(ENABLE_NODE
, &debug_ospf_zebra_cmd
);
1797 install_element(ENABLE_NODE
, &debug_ospf_event_cmd
);
1798 install_element(ENABLE_NODE
, &debug_ospf_nssa_cmd
);
1799 install_element(ENABLE_NODE
, &debug_ospf_te_cmd
);
1800 install_element(ENABLE_NODE
, &debug_ospf_sr_cmd
);
1801 install_element(ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
1802 install_element(ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
1803 install_element(ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
1804 install_element(ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
1805 install_element(ENABLE_NODE
, &no_debug_ospf_event_cmd
);
1806 install_element(ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
1807 install_element(ENABLE_NODE
, &no_debug_ospf_te_cmd
);
1808 install_element(ENABLE_NODE
, &no_debug_ospf_sr_cmd
);
1810 install_element(ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
1811 install_element(ENABLE_NODE
, &debug_ospf_packet_cmd
);
1812 install_element(ENABLE_NODE
, &no_debug_ospf_packet_cmd
);
1814 install_element(ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
1815 install_element(ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
1816 install_element(ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
1817 install_element(ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
1818 install_element(ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
1819 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1820 install_element(ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1821 install_element(ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1822 install_element(ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
1823 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1824 install_element(ENABLE_NODE
, &no_debug_ospf_cmd
);
1826 install_element(CONFIG_NODE
, &debug_ospf_packet_cmd
);
1827 install_element(CONFIG_NODE
, &no_debug_ospf_packet_cmd
);
1828 install_element(CONFIG_NODE
, &debug_ospf_ism_cmd
);
1829 install_element(CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
1831 install_element(CONFIG_NODE
, &debug_ospf_nsm_cmd
);
1832 install_element(CONFIG_NODE
, &debug_ospf_lsa_cmd
);
1833 install_element(CONFIG_NODE
, &debug_ospf_zebra_cmd
);
1834 install_element(CONFIG_NODE
, &debug_ospf_event_cmd
);
1835 install_element(CONFIG_NODE
, &debug_ospf_nssa_cmd
);
1836 install_element(CONFIG_NODE
, &debug_ospf_te_cmd
);
1837 install_element(CONFIG_NODE
, &debug_ospf_sr_cmd
);
1838 install_element(CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
1839 install_element(CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
1840 install_element(CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
1841 install_element(CONFIG_NODE
, &no_debug_ospf_event_cmd
);
1842 install_element(CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
1843 install_element(CONFIG_NODE
, &no_debug_ospf_te_cmd
);
1844 install_element(CONFIG_NODE
, &no_debug_ospf_sr_cmd
);
1846 install_element(CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
1847 install_element(CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
1848 install_element(CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
1849 install_element(CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
1850 install_element(CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
1851 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1852 install_element(CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1853 install_element(CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1854 install_element(CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
1855 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1856 install_element(CONFIG_NODE
, &no_debug_ospf_cmd
);