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;
55 /* Enable debug option variables -- valid only session. */
56 unsigned long term_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
57 unsigned long term_debug_ospf_event
= 0;
58 unsigned long term_debug_ospf_ism
= 0;
59 unsigned long term_debug_ospf_nsm
= 0;
60 unsigned long term_debug_ospf_lsa
= 0;
61 unsigned long term_debug_ospf_zebra
= 0;
62 unsigned long term_debug_ospf_nssa
= 0;
63 unsigned long term_debug_ospf_te
= 0;
66 const char *ospf_redist_string(u_int route_type
)
68 return (route_type
== ZEBRA_ROUTE_MAX
) ? "Default"
69 : zebra_route_string(route_type
);
72 #define OSPF_AREA_STRING_MAXLEN 16
73 const char *ospf_area_name_string(struct ospf_area
*area
)
75 static char buf
[OSPF_AREA_STRING_MAXLEN
] = "";
81 area_id
= ntohl(area
->area_id
.s_addr
);
82 snprintf(buf
, OSPF_AREA_STRING_MAXLEN
, "%d.%d.%d.%d",
83 (area_id
>> 24) & 0xff, (area_id
>> 16) & 0xff,
84 (area_id
>> 8) & 0xff, area_id
& 0xff);
88 #define OSPF_AREA_DESC_STRING_MAXLEN 23
89 const char *ospf_area_desc_string(struct ospf_area
*area
)
91 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
95 return "(incomplete)";
97 type
= area
->external_routing
;
100 snprintf(buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [NSSA]",
101 ospf_area_name_string(area
));
104 snprintf(buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [Stub]",
105 ospf_area_name_string(area
));
108 return ospf_area_name_string(area
);
114 #define OSPF_IF_STRING_MAXLEN 40
115 const char *ospf_if_name_string(struct ospf_interface
*oi
)
117 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
120 if (!oi
|| !oi
->address
)
123 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
124 return oi
->ifp
->name
;
126 ifaddr
= ntohl(oi
->address
->u
.prefix4
.s_addr
);
127 snprintf(buf
, OSPF_IF_STRING_MAXLEN
, "%s:%d.%d.%d.%d", oi
->ifp
->name
,
128 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
129 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
134 void ospf_nbr_state_message(struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
137 struct ospf_interface
*oi
= nbr
->oi
;
139 if (IPV4_ADDR_SAME(&DR(oi
), &nbr
->address
.u
.prefix4
))
141 else if (IPV4_ADDR_SAME(&BDR(oi
), &nbr
->address
.u
.prefix4
))
146 memset(buf
, 0, size
);
148 snprintf(buf
, size
, "%s/%s",
149 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
),
150 lookup_msg(ospf_ism_state_msg
, state
, NULL
));
153 const char *ospf_timeval_dump(struct timeval
*t
, char *buf
, size_t size
)
155 /* Making formatted timer strings. */
156 #define MINUTE_IN_SECONDS 60
157 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
158 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
159 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
160 unsigned long w
, d
, h
, m
, s
, ms
, us
;
165 w
= d
= h
= m
= s
= ms
= us
= 0;
166 memset(buf
, 0, size
);
175 t
->tv_sec
+= ms
/ 1000;
179 if (t
->tv_sec
> WEEK_IN_SECONDS
) {
180 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
181 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
184 if (t
->tv_sec
> DAY_IN_SECONDS
) {
185 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
186 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
189 if (t
->tv_sec
>= HOUR_IN_SECONDS
) {
190 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
191 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
194 if (t
->tv_sec
>= MINUTE_IN_SECONDS
) {
195 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
196 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
200 snprintf(buf
, size
, "%ldw%1ldd", w
, d
);
202 snprintf(buf
, size
, "%ldw%1ldd%02ldh", w
, d
, h
);
204 snprintf(buf
, size
, "%1ldd%02ldh%02ldm", d
, h
, m
);
206 snprintf(buf
, size
, "%ldh%02ldm%02lds", h
, m
, (long)t
->tv_sec
);
208 snprintf(buf
, size
, "%ldm%02lds", m
, (long)t
->tv_sec
);
210 snprintf(buf
, size
, "%ld.%03lds", (long)t
->tv_sec
, ms
);
212 snprintf(buf
, size
, "%ld usecs", (long)t
->tv_usec
);
217 const char *ospf_timer_dump(struct thread
*t
, char *buf
, size_t size
)
219 struct timeval result
;
223 monotime_until(&t
->u
.sands
, &result
);
224 return ospf_timeval_dump(&result
, buf
, size
);
227 static void ospf_packet_hello_dump(struct stream
*s
, u_int16_t length
)
229 struct ospf_hello
*hello
;
232 hello
= (struct ospf_hello
*)STREAM_PNT(s
);
235 zlog_debug(" NetworkMask %s", inet_ntoa(hello
->network_mask
));
236 zlog_debug(" HelloInterval %d", ntohs(hello
->hello_interval
));
237 zlog_debug(" Options %d (%s)", hello
->options
,
238 ospf_options_dump(hello
->options
));
239 zlog_debug(" RtrPriority %d", hello
->priority
);
240 zlog_debug(" RtrDeadInterval %ld",
241 (u_long
)ntohl(hello
->dead_interval
));
242 zlog_debug(" DRouter %s", inet_ntoa(hello
->d_router
));
243 zlog_debug(" BDRouter %s", inet_ntoa(hello
->bd_router
));
245 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
246 zlog_debug(" # Neighbors %d", length
/ 4);
247 for (i
= 0; length
> 0; i
++, length
-= sizeof(struct in_addr
))
248 zlog_debug(" Neighbor %s", inet_ntoa(hello
->neighbors
[i
]));
251 static char *ospf_dd_flags_dump(u_char flags
, char *buf
, size_t size
)
253 memset(buf
, 0, 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(u_char flags
, char *buf
, size_t size
)
264 memset(buf
, 0, size
);
266 snprintf(buf
, size
, "%s|%s|%s",
267 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
268 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
269 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
274 static void ospf_router_lsa_dump(struct stream
*s
, u_int16_t length
)
277 struct router_lsa
*rl
;
280 rl
= (struct router_lsa
*)STREAM_PNT(s
);
282 zlog_debug(" Router-LSA");
283 zlog_debug(" flags %s",
284 ospf_router_lsa_flags_dump(rl
->flags
, buf
, BUFSIZ
));
285 zlog_debug(" # links %d", ntohs(rl
->links
));
287 len
= ntohs(rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
288 for (i
= 0; len
> 0; i
++) {
289 zlog_debug(" Link ID %s", inet_ntoa(rl
->link
[i
].link_id
));
290 zlog_debug(" Link Data %s",
291 inet_ntoa(rl
->link
[i
].link_data
));
292 zlog_debug(" Type %d", (u_char
)rl
->link
[i
].type
);
293 zlog_debug(" TOS %d", (u_char
)rl
->link
[i
].tos
);
294 zlog_debug(" metric %d", ntohs(rl
->link
[i
].metric
));
300 static void ospf_network_lsa_dump(struct stream
*s
, u_int16_t length
)
302 struct network_lsa
*nl
;
305 nl
= (struct network_lsa
*)STREAM_PNT(s
);
306 cnt
= (ntohs(nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
308 zlog_debug(" Network-LSA");
310 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
311 zlog_debug ("Network-LSA size %d",
312 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
314 zlog_debug(" Network Mask %s", inet_ntoa(nl
->mask
));
315 zlog_debug(" # Attached Routers %d", cnt
);
316 for (i
= 0; i
< cnt
; i
++)
317 zlog_debug(" Attached Router %s",
318 inet_ntoa(nl
->routers
[i
]));
321 static void ospf_summary_lsa_dump(struct stream
*s
, u_int16_t length
)
323 struct summary_lsa
*sl
;
327 sl
= (struct summary_lsa
*)STREAM_PNT(s
);
329 zlog_debug(" Summary-LSA");
330 zlog_debug(" Network Mask %s", inet_ntoa(sl
->mask
));
332 size
= ntohs(sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
333 for (i
= 0; size
> 0; size
-= 4, i
++)
334 zlog_debug(" TOS=%d metric %d", sl
->tos
,
335 GET_METRIC(sl
->metric
));
338 static void ospf_as_external_lsa_dump(struct stream
*s
, u_int16_t length
)
340 struct as_external_lsa
*al
;
344 al
= (struct as_external_lsa
*)STREAM_PNT(s
);
345 zlog_debug(" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
346 zlog_debug(" Network Mask %s", inet_ntoa(al
->mask
));
348 size
= ntohs(al
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
349 for (i
= 0; size
> 0; size
-= 12, i
++) {
350 zlog_debug(" bit %s TOS=%d metric %d",
351 IS_EXTERNAL_METRIC(al
->e
[i
].tos
) ? "E" : "-",
352 al
->e
[i
].tos
& 0x7f, GET_METRIC(al
->e
[i
].metric
));
353 zlog_debug(" Forwarding address %s",
354 inet_ntoa(al
->e
[i
].fwd_addr
));
355 zlog_debug(" External Route Tag %" ROUTE_TAG_PRI
,
360 static void ospf_lsa_header_list_dump(struct stream
*s
, u_int16_t length
)
362 struct lsa_header
*lsa
;
364 zlog_debug(" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
368 lsa
= (struct lsa_header
*)STREAM_PNT(s
);
369 ospf_lsa_header_dump(lsa
);
371 stream_forward_getp(s
, OSPF_LSA_HEADER_SIZE
);
372 length
-= OSPF_LSA_HEADER_SIZE
;
376 static void ospf_packet_db_desc_dump(struct stream
*s
, u_int16_t length
)
378 struct ospf_db_desc
*dd
;
383 gp
= stream_get_getp(s
);
384 dd
= (struct ospf_db_desc
*)STREAM_PNT(s
);
386 zlog_debug("Database Description");
387 zlog_debug(" Interface MTU %d", ntohs(dd
->mtu
));
388 zlog_debug(" Options %d (%s)", dd
->options
,
389 ospf_options_dump(dd
->options
));
390 zlog_debug(" Flags %d (%s)", dd
->flags
,
391 ospf_dd_flags_dump(dd
->flags
, dd_flags
, sizeof dd_flags
));
392 zlog_debug(" Sequence Number 0x%08lx", (u_long
)ntohl(dd
->dd_seqnum
));
394 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
396 stream_forward_getp(s
, OSPF_DB_DESC_MIN_SIZE
);
398 ospf_lsa_header_list_dump(s
, length
);
400 stream_set_getp(s
, gp
);
403 static void ospf_packet_ls_req_dump(struct stream
*s
, u_int16_t length
)
407 struct in_addr ls_id
;
408 struct in_addr adv_router
;
410 sp
= stream_get_getp(s
);
412 length
-= OSPF_HEADER_SIZE
;
414 zlog_debug("Link State Request");
415 zlog_debug(" # Requests %d", length
/ 12);
417 for (; length
> 0; length
-= 12) {
418 ls_type
= stream_getl(s
);
419 ls_id
.s_addr
= stream_get_ipv4(s
);
420 adv_router
.s_addr
= stream_get_ipv4(s
);
422 zlog_debug(" LS type %d", ls_type
);
423 zlog_debug(" Link State ID %s", inet_ntoa(ls_id
));
424 zlog_debug(" Advertising Router %s", inet_ntoa(adv_router
));
427 stream_set_getp(s
, sp
);
430 static void ospf_packet_ls_upd_dump(struct stream
*s
, u_int16_t length
)
433 struct lsa_header
*lsa
;
437 length
-= OSPF_HEADER_SIZE
;
439 sp
= stream_get_getp(s
);
441 count
= stream_getl(s
);
444 zlog_debug("Link State Update");
445 zlog_debug(" # LSAs %d", count
);
447 while (length
> 0 && count
> 0) {
448 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0) {
449 zlog_debug(" Remaining %d bytes; Incorrect length.",
454 lsa
= (struct lsa_header
*)STREAM_PNT(s
);
455 lsa_len
= ntohs(lsa
->length
);
456 ospf_lsa_header_dump(lsa
);
459 case OSPF_ROUTER_LSA
:
460 ospf_router_lsa_dump(s
, length
);
462 case OSPF_NETWORK_LSA
:
463 ospf_network_lsa_dump(s
, length
);
465 case OSPF_SUMMARY_LSA
:
466 case OSPF_ASBR_SUMMARY_LSA
:
467 ospf_summary_lsa_dump(s
, length
);
469 case OSPF_AS_EXTERNAL_LSA
:
470 ospf_as_external_lsa_dump(s
, length
);
472 case OSPF_AS_NSSA_LSA
:
473 ospf_as_external_lsa_dump(s
, length
);
475 case OSPF_OPAQUE_LINK_LSA
:
476 case OSPF_OPAQUE_AREA_LSA
:
477 case OSPF_OPAQUE_AS_LSA
:
478 ospf_opaque_lsa_dump(s
, length
);
484 stream_forward_getp(s
, lsa_len
);
489 stream_set_getp(s
, sp
);
492 static void ospf_packet_ls_ack_dump(struct stream
*s
, u_int16_t length
)
496 length
-= OSPF_HEADER_SIZE
;
497 sp
= stream_get_getp(s
);
499 zlog_debug("Link State Acknowledgment");
500 ospf_lsa_header_list_dump(s
, length
);
502 stream_set_getp(s
, sp
);
505 /* Expects header to be in host order */
506 void ospf_ip_header_dump(struct ip
*iph
)
508 /* IP Header dump. */
509 zlog_debug("ip_v %d", iph
->ip_v
);
510 zlog_debug("ip_hl %d", iph
->ip_hl
);
511 zlog_debug("ip_tos %d", iph
->ip_tos
);
512 zlog_debug("ip_len %d", iph
->ip_len
);
513 zlog_debug("ip_id %u", (u_int32_t
)iph
->ip_id
);
514 zlog_debug("ip_off %u", (u_int32_t
)iph
->ip_off
);
515 zlog_debug("ip_ttl %d", iph
->ip_ttl
);
516 zlog_debug("ip_p %d", iph
->ip_p
);
517 zlog_debug("ip_sum 0x%x", (u_int32_t
)iph
->ip_sum
);
518 zlog_debug("ip_src %s", inet_ntoa(iph
->ip_src
));
519 zlog_debug("ip_dst %s", inet_ntoa(iph
->ip_dst
));
522 static void ospf_header_dump(struct ospf_header
*ospfh
)
525 u_int16_t auth_type
= ntohs(ospfh
->auth_type
);
527 zlog_debug("Header");
528 zlog_debug(" Version %d", ospfh
->version
);
529 zlog_debug(" Type %d (%s)", ospfh
->type
,
530 lookup_msg(ospf_packet_type_str
, ospfh
->type
, NULL
));
531 zlog_debug(" Packet Len %d", ntohs(ospfh
->length
));
532 zlog_debug(" Router ID %s", inet_ntoa(ospfh
->router_id
));
533 zlog_debug(" Area ID %s", inet_ntoa(ospfh
->area_id
));
534 zlog_debug(" Checksum 0x%x", ntohs(ospfh
->checksum
));
535 zlog_debug(" AuType %s",
536 lookup_msg(ospf_auth_type_str
, auth_type
, NULL
));
541 case OSPF_AUTH_SIMPLE
:
543 strncpy(buf
, (char *)ospfh
->u
.auth_data
, 8);
544 zlog_debug(" Simple Password %s", buf
);
546 case OSPF_AUTH_CRYPTOGRAPHIC
:
547 zlog_debug(" Cryptographic Authentication");
548 zlog_debug(" Key ID %d", ospfh
->u
.crypt
.key_id
);
549 zlog_debug(" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
550 zlog_debug(" Sequence number %ld",
551 (u_long
)ntohl(ospfh
->u
.crypt
.crypt_seqnum
));
554 zlog_debug("* This is not supported authentication type");
559 void ospf_packet_dump(struct stream
*s
)
561 struct ospf_header
*ospfh
;
564 /* Preserve pointer. */
565 gp
= stream_get_getp(s
);
567 /* OSPF Header dump. */
568 ospfh
= (struct ospf_header
*)STREAM_PNT(s
);
570 /* Until detail flag is set, return. */
571 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
574 /* Show OSPF header detail. */
575 ospf_header_dump(ospfh
);
576 stream_forward_getp(s
, OSPF_HEADER_SIZE
);
578 switch (ospfh
->type
) {
580 ospf_packet_hello_dump(s
, ntohs(ospfh
->length
));
582 case OSPF_MSG_DB_DESC
:
583 ospf_packet_db_desc_dump(s
, ntohs(ospfh
->length
));
585 case OSPF_MSG_LS_REQ
:
586 ospf_packet_ls_req_dump(s
, ntohs(ospfh
->length
));
588 case OSPF_MSG_LS_UPD
:
589 ospf_packet_ls_upd_dump(s
, ntohs(ospfh
->length
));
591 case OSPF_MSG_LS_ACK
:
592 ospf_packet_ls_ack_dump(s
, ntohs(ospfh
->length
));
598 stream_set_getp(s
, gp
);
601 DEFUN (debug_ospf_packet
,
602 debug_ospf_packet_cmd
,
603 "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
609 "OSPF Database Description\n"
610 "OSPF Link State Request\n"
611 "OSPF Link State Update\n"
612 "OSPF Link State Acknowledgment\n"
615 "Detail Information\n"
617 "Detail Information\n"
618 "Detail Information\n")
620 int inst
= (argv
[2]->type
== RANGE_TKN
) ? 1 : 0;
621 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
622 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
623 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
624 char *packet
= argv
[3 + inst
]->text
;
626 if (inst
) // user passed instance ID
628 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
629 return CMD_NOT_MY_INSTANCE
;
636 /* Check packet type. */
637 if (strmatch(packet
, "hello"))
638 type
= OSPF_DEBUG_HELLO
;
639 else if (strmatch(packet
, "dd"))
640 type
= OSPF_DEBUG_DB_DESC
;
641 else if (strmatch(packet
, "ls-request"))
642 type
= OSPF_DEBUG_LS_REQ
;
643 else if (strmatch(packet
, "ls-update"))
644 type
= OSPF_DEBUG_LS_UPD
;
645 else if (strmatch(packet
, "ls-ack"))
646 type
= OSPF_DEBUG_LS_ACK
;
647 else if (strmatch(packet
, "all"))
648 type
= OSPF_DEBUG_ALL
;
651 * (none) = send + recv
652 * detail = send + recv + detail
655 * recv detail = recv + detail
656 * send detail = send + detail
661 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
662 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
663 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
665 for (i
= 0; i
< 5; i
++)
666 if (type
& (0x01 << i
)) {
667 if (vty
->node
== CONFIG_NODE
)
668 DEBUG_PACKET_ON(i
, flag
);
670 TERM_DEBUG_PACKET_ON(i
, flag
);
676 DEFUN (no_debug_ospf_packet
,
677 no_debug_ospf_packet_cmd
,
678 "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
685 "OSPF Database Description\n"
686 "OSPF Link State Request\n"
687 "OSPF Link State Update\n"
688 "OSPF Link State Acknowledgment\n"
691 "Detail Information\n"
693 "Detail Information\n"
694 "Detail Information\n")
696 int inst
= (argv
[3]->type
== RANGE_TKN
) ? 1 : 0;
697 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
698 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
699 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
700 char *packet
= argv
[4 + inst
]->text
;
702 if (inst
) // user passed instance ID
704 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
705 return CMD_NOT_MY_INSTANCE
;
712 /* Check packet type. */
713 if (strmatch(packet
, "hello"))
714 type
= OSPF_DEBUG_HELLO
;
715 else if (strmatch(packet
, "dd"))
716 type
= OSPF_DEBUG_DB_DESC
;
717 else if (strmatch(packet
, "ls-request"))
718 type
= OSPF_DEBUG_LS_REQ
;
719 else if (strmatch(packet
, "ls-update"))
720 type
= OSPF_DEBUG_LS_UPD
;
721 else if (strmatch(packet
, "ls-ack"))
722 type
= OSPF_DEBUG_LS_ACK
;
723 else if (strmatch(packet
, "all"))
724 type
= OSPF_DEBUG_ALL
;
727 * (none) = send + recv
728 * detail = send + recv + detail
731 * recv detail = recv + detail
732 * send detail = send + detail
737 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
738 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
739 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
741 for (i
= 0; i
< 5; i
++)
742 if (type
& (0x01 << i
)) {
743 if (vty
->node
== CONFIG_NODE
)
744 DEBUG_PACKET_OFF(i
, flag
);
746 TERM_DEBUG_PACKET_OFF(i
, flag
);
751 for (i = 0; i < 5; i++)
752 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
759 DEFUN (debug_ospf_ism
,
761 "debug ospf [(1-65535)] ism [<status|events|timers>]",
765 "OSPF Interface State Machine\n"
766 "ISM Status Information\n"
767 "ISM Event Information\n"
768 "ISM TImer Information\n")
770 int inst
= (argv
[2]->type
== RANGE_TKN
);
771 char *dbgparam
= (argc
== 4 + inst
) ? argv
[argc
- 1]->text
: NULL
;
773 if (inst
) // user passed instance ID
775 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
776 return CMD_NOT_MY_INSTANCE
;
779 if (vty
->node
== CONFIG_NODE
) {
783 if (strmatch(dbgparam
, "status"))
784 DEBUG_ON(ism
, ISM_STATUS
);
785 else if (strmatch(dbgparam
, "events"))
786 DEBUG_ON(ism
, ISM_EVENTS
);
787 else if (strmatch(dbgparam
, "timers"))
788 DEBUG_ON(ism
, ISM_TIMERS
);
796 TERM_DEBUG_ON(ism
, ISM
);
798 if (strmatch(dbgparam
, "status"))
799 TERM_DEBUG_ON(ism
, ISM_STATUS
);
800 else if (strmatch(dbgparam
, "events"))
801 TERM_DEBUG_ON(ism
, ISM_EVENTS
);
802 else if (strmatch(dbgparam
, "timers"))
803 TERM_DEBUG_ON(ism
, ISM_TIMERS
);
809 DEFUN (no_debug_ospf_ism
,
810 no_debug_ospf_ism_cmd
,
811 "no debug ospf [(1-65535)] ism [<status|events|timers>]",
816 "OSPF Interface State Machine\n"
817 "ISM Status Information\n"
818 "ISM Event Information\n"
819 "ISM TImer Information\n")
821 int inst
= (argv
[3]->type
== RANGE_TKN
);
822 char *dbgparam
= (argc
== 5 + inst
) ? argv
[argc
- 1]->text
: NULL
;
824 if (inst
) // user passed instance ID
826 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
827 return CMD_NOT_MY_INSTANCE
;
830 if (vty
->node
== CONFIG_NODE
) {
834 if (strmatch(dbgparam
, "status"))
835 DEBUG_OFF(ism
, ISM_STATUS
);
836 else if (strmatch(dbgparam
, "events"))
837 DEBUG_OFF(ism
, ISM_EVENTS
);
838 else if (strmatch(dbgparam
, "timers"))
839 DEBUG_OFF(ism
, ISM_TIMERS
);
847 TERM_DEBUG_OFF(ism
, ISM
);
849 if (strmatch(dbgparam
, "status"))
850 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
851 else if (strmatch(dbgparam
, "events"))
852 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
853 else if (strmatch(dbgparam
, "timers"))
854 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
860 static int debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
861 struct cmd_token
**argv
)
863 if (vty
->node
== CONFIG_NODE
) {
864 if (argc
== arg_base
+ 0)
866 else if (argc
== arg_base
+ 1) {
867 if (strmatch(argv
[arg_base
]->text
, "status"))
868 DEBUG_ON(nsm
, NSM_STATUS
);
869 else if (strmatch(argv
[arg_base
]->text
, "events"))
870 DEBUG_ON(nsm
, NSM_EVENTS
);
871 else if (strmatch(argv
[arg_base
]->text
, "timers"))
872 DEBUG_ON(nsm
, NSM_TIMERS
);
879 if (argc
== arg_base
+ 0)
880 TERM_DEBUG_ON(nsm
, NSM
);
881 else if (argc
== arg_base
+ 1) {
882 if (strmatch(argv
[arg_base
]->text
, "status"))
883 TERM_DEBUG_ON(nsm
, NSM_STATUS
);
884 else if (strmatch(argv
[arg_base
]->text
, "events"))
885 TERM_DEBUG_ON(nsm
, NSM_EVENTS
);
886 else if (strmatch(argv
[arg_base
]->text
, "timers"))
887 TERM_DEBUG_ON(nsm
, NSM_TIMERS
);
893 DEFUN (debug_ospf_nsm
,
895 "debug ospf nsm [<status|events|timers>]",
898 "OSPF Neighbor State Machine\n"
899 "NSM Status Information\n"
900 "NSM Event Information\n"
901 "NSM Timer Information\n")
903 return debug_ospf_nsm_common(vty
, 3, argc
, argv
);
906 DEFUN (debug_ospf_instance_nsm
,
907 debug_ospf_instance_nsm_cmd
,
908 "debug ospf (1-65535) nsm [<status|events|timers>]",
912 "OSPF Neighbor State Machine\n"
913 "NSM Status Information\n"
914 "NSM Event Information\n"
915 "NSM Timer Information\n")
918 u_short instance
= 0;
920 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
921 if (!ospf_lookup_instance(instance
))
924 return debug_ospf_nsm_common(vty
, 4, argc
, argv
);
928 static int no_debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
929 struct cmd_token
**argv
)
932 if (vty
->node
== CONFIG_NODE
) {
933 if (argc
== arg_base
+ 0)
935 else if (argc
== arg_base
+ 1) {
936 if (strmatch(argv
[arg_base
]->text
, "status"))
937 DEBUG_OFF(nsm
, NSM_STATUS
);
938 else if (strmatch(argv
[arg_base
]->text
, "events"))
939 DEBUG_OFF(nsm
, NSM_EVENTS
);
940 else if (strmatch(argv
[arg_base
]->text
, "timers"))
941 DEBUG_OFF(nsm
, NSM_TIMERS
);
948 if (argc
== arg_base
+ 0)
949 TERM_DEBUG_OFF(nsm
, NSM
);
950 else if (argc
== arg_base
+ 1) {
951 if (strmatch(argv
[arg_base
]->text
, "status"))
952 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
953 else if (strmatch(argv
[arg_base
]->text
, "events"))
954 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
955 else if (strmatch(argv
[arg_base
]->text
, "timers"))
956 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
962 DEFUN (no_debug_ospf_nsm
,
963 no_debug_ospf_nsm_cmd
,
964 "no debug ospf nsm [<status|events|timers>]",
968 "OSPF Neighbor State Machine\n"
969 "NSM Status Information\n"
970 "NSM Event Information\n"
971 "NSM Timer Information\n")
973 return no_debug_ospf_nsm_common(vty
, 4, argc
, argv
);
977 DEFUN (no_debug_ospf_instance_nsm
,
978 no_debug_ospf_instance_nsm_cmd
,
979 "no debug ospf (1-65535) nsm [<status|events|timers>]",
984 "OSPF Neighbor State Machine\n"
985 "NSM Status Information\n"
986 "NSM Event Information\n"
987 "NSM Timer Information\n")
990 u_short instance
= 0;
992 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
993 if (!ospf_lookup_instance(instance
))
994 return CMD_NOT_MY_INSTANCE
;
996 return no_debug_ospf_nsm_common(vty
, 5, argc
, argv
);
1000 static int debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
1001 struct cmd_token
**argv
)
1003 if (vty
->node
== CONFIG_NODE
) {
1004 if (argc
== arg_base
+ 0)
1006 else if (argc
== arg_base
+ 1) {
1007 if (strmatch(argv
[arg_base
]->text
, "generate"))
1008 DEBUG_ON(lsa
, LSA_GENERATE
);
1009 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1010 DEBUG_ON(lsa
, LSA_FLOODING
);
1011 else if (strmatch(argv
[arg_base
]->text
, "install"))
1012 DEBUG_ON(lsa
, LSA_INSTALL
);
1013 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1014 DEBUG_ON(lsa
, LSA_REFRESH
);
1021 if (argc
== arg_base
+ 0)
1022 TERM_DEBUG_ON(lsa
, LSA
);
1023 else if (argc
== arg_base
+ 1) {
1024 if (strmatch(argv
[arg_base
]->text
, "generate"))
1025 TERM_DEBUG_ON(lsa
, LSA_GENERATE
);
1026 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1027 TERM_DEBUG_ON(lsa
, LSA_FLOODING
);
1028 else if (strmatch(argv
[arg_base
]->text
, "install"))
1029 TERM_DEBUG_ON(lsa
, LSA_INSTALL
);
1030 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1031 TERM_DEBUG_ON(lsa
, LSA_REFRESH
);
1037 DEFUN (debug_ospf_lsa
,
1039 "debug ospf lsa [<generate|flooding|install|refresh>]",
1042 "OSPF Link State Advertisement\n"
1045 "LSA Install/Delete\n"
1048 return debug_ospf_lsa_common(vty
, 3, argc
, argv
);
1051 DEFUN (debug_ospf_instance_lsa
,
1052 debug_ospf_instance_lsa_cmd
,
1053 "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1057 "OSPF Link State Advertisement\n"
1060 "LSA Install/Delete\n"
1064 u_short instance
= 0;
1066 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1067 if (!ospf_lookup_instance(instance
))
1068 return CMD_NOT_MY_INSTANCE
;
1070 return debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1074 static int no_debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
1075 struct cmd_token
**argv
)
1077 if (vty
->node
== CONFIG_NODE
) {
1078 if (argc
== arg_base
+ 0)
1079 DEBUG_OFF(lsa
, LSA
);
1080 else if (argc
== arg_base
+ 1) {
1081 if (strmatch(argv
[arg_base
]->text
, "generate"))
1082 DEBUG_OFF(lsa
, LSA_GENERATE
);
1083 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1084 DEBUG_OFF(lsa
, LSA_FLOODING
);
1085 else if (strmatch(argv
[arg_base
]->text
, "install"))
1086 DEBUG_OFF(lsa
, LSA_INSTALL
);
1087 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1088 DEBUG_OFF(lsa
, LSA_REFRESH
);
1095 if (argc
== arg_base
+ 0)
1096 TERM_DEBUG_OFF(lsa
, LSA
);
1097 else if (argc
== arg_base
+ 1) {
1098 if (strmatch(argv
[arg_base
]->text
, "generate"))
1099 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1100 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1101 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1102 else if (strmatch(argv
[arg_base
]->text
, "install"))
1103 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1104 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1105 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1111 DEFUN (no_debug_ospf_lsa
,
1112 no_debug_ospf_lsa_cmd
,
1113 "no debug ospf lsa [<generate|flooding|install|refresh>]",
1117 "OSPF Link State Advertisement\n"
1120 "LSA Install/Delete\n"
1123 return no_debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1126 DEFUN (no_debug_ospf_instance_lsa
,
1127 no_debug_ospf_instance_lsa_cmd
,
1128 "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1133 "OSPF Link State Advertisement\n"
1136 "LSA Install/Delete\n"
1140 u_short instance
= 0;
1142 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1143 if (!ospf_lookup_instance(instance
))
1144 return CMD_NOT_MY_INSTANCE
;
1146 return no_debug_ospf_lsa_common(vty
, 5, argc
, argv
);
1150 static int debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1151 struct cmd_token
**argv
)
1153 if (vty
->node
== CONFIG_NODE
) {
1154 if (argc
== arg_base
+ 0)
1155 DEBUG_ON(zebra
, ZEBRA
);
1156 else if (argc
== arg_base
+ 1) {
1157 if (strmatch(argv
[arg_base
]->text
, "interface"))
1158 DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1159 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1160 DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1167 if (argc
== arg_base
+ 0)
1168 TERM_DEBUG_ON(zebra
, ZEBRA
);
1169 else if (argc
== arg_base
+ 1) {
1170 if (strmatch(argv
[arg_base
]->text
, "interface"))
1171 TERM_DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1172 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1173 TERM_DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1179 DEFUN (debug_ospf_zebra
,
1180 debug_ospf_zebra_cmd
,
1181 "debug ospf zebra [<interface|redistribute>]",
1184 "OSPF Zebra information\n"
1186 "Zebra redistribute\n")
1188 return debug_ospf_zebra_common(vty
, 3, argc
, argv
);
1191 DEFUN (debug_ospf_instance_zebra
,
1192 debug_ospf_instance_zebra_cmd
,
1193 "debug ospf (1-65535) zebra [<interface|redistribute>]",
1197 "OSPF Zebra information\n"
1199 "Zebra redistribute\n")
1202 u_short instance
= 0;
1204 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1205 if (!ospf_lookup_instance(instance
))
1206 return CMD_NOT_MY_INSTANCE
;
1208 return debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1212 static int no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1213 struct cmd_token
**argv
)
1215 if (vty
->node
== CONFIG_NODE
) {
1216 if (argc
== arg_base
+ 0)
1217 DEBUG_OFF(zebra
, ZEBRA
);
1218 else if (argc
== arg_base
+ 1) {
1219 if (strmatch(argv
[arg_base
]->text
, "interface"))
1220 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1221 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1222 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1229 if (argc
== arg_base
+ 0)
1230 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1231 else if (argc
== arg_base
+ 1) {
1232 if (strmatch(argv
[arg_base
]->text
, "interface"))
1233 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1234 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1235 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1241 DEFUN (no_debug_ospf_zebra
,
1242 no_debug_ospf_zebra_cmd
,
1243 "no debug ospf zebra [<interface|redistribute>]",
1247 "OSPF Zebra information\n"
1249 "Zebra redistribute\n")
1251 return no_debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1254 DEFUN (no_debug_ospf_instance_zebra
,
1255 no_debug_ospf_instance_zebra_cmd
,
1256 "no debug ospf (1-65535) zebra [<interface|redistribute>]",
1261 "OSPF Zebra information\n"
1263 "Zebra redistribute\n")
1266 u_short instance
= 0;
1268 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1269 if (!ospf_lookup_instance(instance
))
1272 return no_debug_ospf_zebra_common(vty
, 5, argc
, argv
);
1276 DEFUN (debug_ospf_event
,
1277 debug_ospf_event_cmd
,
1281 "OSPF event information\n")
1283 if (vty
->node
== CONFIG_NODE
)
1284 CONF_DEBUG_ON(event
, EVENT
);
1285 TERM_DEBUG_ON(event
, EVENT
);
1289 DEFUN (no_debug_ospf_event
,
1290 no_debug_ospf_event_cmd
,
1291 "no debug ospf event",
1295 "OSPF event information\n")
1297 if (vty
->node
== CONFIG_NODE
)
1298 CONF_DEBUG_OFF(event
, EVENT
);
1299 TERM_DEBUG_OFF(event
, EVENT
);
1303 DEFUN (debug_ospf_instance_event
,
1304 debug_ospf_instance_event_cmd
,
1305 "debug ospf (1-65535) event",
1309 "OSPF event information\n")
1312 u_short instance
= 0;
1314 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1315 if (!ospf_lookup_instance(instance
))
1318 if (vty
->node
== CONFIG_NODE
)
1319 CONF_DEBUG_ON(event
, EVENT
);
1320 TERM_DEBUG_ON(event
, EVENT
);
1324 DEFUN (no_debug_ospf_instance_event
,
1325 no_debug_ospf_instance_event_cmd
,
1326 "no debug ospf (1-65535) event",
1331 "OSPF event information\n")
1334 u_short instance
= 0;
1336 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1337 if (!ospf_lookup_instance(instance
))
1340 if (vty
->node
== CONFIG_NODE
)
1341 CONF_DEBUG_OFF(event
, EVENT
);
1342 TERM_DEBUG_OFF(event
, EVENT
);
1346 DEFUN (debug_ospf_nssa
,
1347 debug_ospf_nssa_cmd
,
1351 "OSPF nssa information\n")
1353 if (vty
->node
== CONFIG_NODE
)
1354 CONF_DEBUG_ON(nssa
, NSSA
);
1355 TERM_DEBUG_ON(nssa
, NSSA
);
1359 DEFUN (no_debug_ospf_nssa
,
1360 no_debug_ospf_nssa_cmd
,
1361 "no debug ospf nssa",
1365 "OSPF nssa information\n")
1367 if (vty
->node
== CONFIG_NODE
)
1368 CONF_DEBUG_OFF(nssa
, NSSA
);
1369 TERM_DEBUG_OFF(nssa
, NSSA
);
1373 DEFUN (debug_ospf_instance_nssa
,
1374 debug_ospf_instance_nssa_cmd
,
1375 "debug ospf (1-65535) nssa",
1379 "OSPF nssa information\n")
1382 u_short instance
= 0;
1384 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1385 if (!ospf_lookup_instance(instance
))
1388 if (vty
->node
== CONFIG_NODE
)
1389 CONF_DEBUG_ON(nssa
, NSSA
);
1390 TERM_DEBUG_ON(nssa
, NSSA
);
1394 DEFUN (no_debug_ospf_instance_nssa
,
1395 no_debug_ospf_instance_nssa_cmd
,
1396 "no debug ospf (1-65535) nssa",
1401 "OSPF nssa information\n")
1404 u_short instance
= 0;
1406 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1407 if (!ospf_lookup_instance(instance
))
1410 if (vty
->node
== CONFIG_NODE
)
1411 CONF_DEBUG_OFF(nssa
, NSSA
);
1412 TERM_DEBUG_OFF(nssa
, NSSA
);
1416 DEFUN (debug_ospf_te
,
1421 "OSPF-TE information\n")
1423 if (vty
->node
== CONFIG_NODE
)
1424 CONF_DEBUG_ON(te
, TE
);
1425 TERM_DEBUG_ON(te
, TE
);
1429 DEFUN (no_debug_ospf_te
,
1430 no_debug_ospf_te_cmd
,
1435 "OSPF-TE information\n")
1437 if (vty
->node
== CONFIG_NODE
)
1438 CONF_DEBUG_OFF(te
, TE
);
1439 TERM_DEBUG_OFF(te
, TE
);
1443 DEFUN (no_debug_ospf
,
1450 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1453 if (vty
->node
== CONFIG_NODE
) {
1454 CONF_DEBUG_OFF(event
, EVENT
);
1455 CONF_DEBUG_OFF(nssa
, NSSA
);
1456 DEBUG_OFF(ism
, ISM_EVENTS
);
1457 DEBUG_OFF(ism
, ISM_STATUS
);
1458 DEBUG_OFF(ism
, ISM_TIMERS
);
1459 DEBUG_OFF(lsa
, LSA
);
1460 DEBUG_OFF(lsa
, LSA_FLOODING
);
1461 DEBUG_OFF(lsa
, LSA_GENERATE
);
1462 DEBUG_OFF(lsa
, LSA_INSTALL
);
1463 DEBUG_OFF(lsa
, LSA_REFRESH
);
1464 DEBUG_OFF(nsm
, NSM
);
1465 DEBUG_OFF(nsm
, NSM_EVENTS
);
1466 DEBUG_OFF(nsm
, NSM_STATUS
);
1467 DEBUG_OFF(nsm
, NSM_TIMERS
);
1468 DEBUG_OFF(zebra
, ZEBRA
);
1469 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1470 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1472 for (i
= 0; i
< 5; i
++)
1473 DEBUG_PACKET_OFF(i
, flag
);
1476 for (i
= 0; i
< 5; i
++)
1477 TERM_DEBUG_PACKET_OFF(i
, flag
);
1479 TERM_DEBUG_OFF(event
, EVENT
);
1480 TERM_DEBUG_OFF(ism
, ISM
);
1481 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
1482 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
1483 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
1484 TERM_DEBUG_OFF(lsa
, LSA
);
1485 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1486 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1487 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1488 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1489 TERM_DEBUG_OFF(nsm
, NSM
);
1490 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
1491 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
1492 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
1493 TERM_DEBUG_OFF(nssa
, NSSA
);
1494 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1495 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1496 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1501 static int show_debugging_ospf_common(struct vty
*vty
, struct ospf
*ospf
)
1506 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
1508 vty_out(vty
, "OSPF debugging status:\n");
1510 /* Show debug status for events. */
1511 if (IS_DEBUG_OSPF(event
, EVENT
))
1512 vty_out(vty
, " OSPF event debugging is on\n");
1514 /* Show debug status for ISM. */
1515 if (IS_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1516 vty_out(vty
, " OSPF ISM debugging is on\n");
1518 if (IS_DEBUG_OSPF(ism
, ISM_STATUS
))
1519 vty_out(vty
, " OSPF ISM status debugging is on\n");
1520 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
1521 vty_out(vty
, " OSPF ISM event debugging is on\n");
1522 if (IS_DEBUG_OSPF(ism
, ISM_TIMERS
))
1523 vty_out(vty
, " OSPF ISM timer debugging is on\n");
1526 /* Show debug status for NSM. */
1527 if (IS_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1528 vty_out(vty
, " OSPF NSM debugging is on\n");
1530 if (IS_DEBUG_OSPF(nsm
, NSM_STATUS
))
1531 vty_out(vty
, " OSPF NSM status debugging is on\n");
1532 if (IS_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1533 vty_out(vty
, " OSPF NSM event debugging is on\n");
1534 if (IS_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1535 vty_out(vty
, " OSPF NSM timer debugging is on\n");
1538 /* Show debug status for OSPF Packets. */
1539 for (i
= 0; i
< 5; i
++)
1540 if (IS_DEBUG_OSPF_PACKET(i
, SEND
)
1541 && IS_DEBUG_OSPF_PACKET(i
, RECV
)) {
1542 vty_out(vty
, " OSPF packet %s%s debugging is on\n",
1543 lookup_msg(ospf_packet_type_str
, i
+ 1, NULL
),
1544 IS_DEBUG_OSPF_PACKET(i
, DETAIL
) ? " detail"
1547 if (IS_DEBUG_OSPF_PACKET(i
, SEND
))
1549 " OSPF packet %s send%s debugging is on\n",
1550 lookup_msg(ospf_packet_type_str
, i
+ 1,
1552 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1555 if (IS_DEBUG_OSPF_PACKET(i
, RECV
))
1557 " OSPF packet %s receive%s debugging is on\n",
1558 lookup_msg(ospf_packet_type_str
, i
+ 1,
1560 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1565 /* Show debug status for OSPF LSAs. */
1566 if (IS_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1567 vty_out(vty
, " OSPF LSA debugging is on\n");
1569 if (IS_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1570 vty_out(vty
, " OSPF LSA generation debugging is on\n");
1571 if (IS_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1572 vty_out(vty
, " OSPF LSA flooding debugging is on\n");
1573 if (IS_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1574 vty_out(vty
, " OSPF LSA install debugging is on\n");
1575 if (IS_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1576 vty_out(vty
, " OSPF LSA refresh debugging is on\n");
1579 /* Show debug status for Zebra. */
1580 if (IS_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1581 vty_out(vty
, " OSPF Zebra debugging is on\n");
1583 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1585 " OSPF Zebra interface debugging is on\n");
1586 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1588 " OSPF Zebra redistribute debugging is on\n");
1591 /* Show debug status for NSSA. */
1592 if (IS_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1593 vty_out(vty
, " OSPF NSSA debugging is on\n");
1600 DEFUN_NOSH (show_debugging_ospf
,
1601 show_debugging_ospf_cmd
,
1602 "show debugging [ospf]",
1609 if ((ospf
= ospf_lookup()) == NULL
)
1612 return show_debugging_ospf_common(vty
, ospf
);
1615 DEFUN_NOSH (show_debugging_ospf_instance
,
1616 show_debugging_ospf_instance_cmd
,
1617 "show debugging ospf (1-65535)",
1625 u_short instance
= 0;
1627 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1628 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
)
1631 return show_debugging_ospf_common(vty
, ospf
);
1635 static struct cmd_node debug_node
= {
1636 DEBUG_NODE
, "", 1 /* VTYSH */
1639 static int config_write_debug(struct vty
*vty
)
1644 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update",
1646 const char *detail_str
[] = {
1647 "", " send", " recv", "",
1648 " detail", " send detail", " recv detail", " detail"};
1654 if ((ospf
= ospf_lookup()) == NULL
)
1658 sprintf(str
, " %d", ospf
->instance
);
1660 /* debug ospf ism (status|events|timers). */
1661 if (IS_CONF_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1662 vty_out(vty
, "debug ospf%s ism\n", str
);
1664 if (IS_CONF_DEBUG_OSPF(ism
, ISM_STATUS
))
1665 vty_out(vty
, "debug ospf%s ism status\n", str
);
1666 if (IS_CONF_DEBUG_OSPF(ism
, ISM_EVENTS
))
1667 vty_out(vty
, "debug ospf%s ism event\n", str
);
1668 if (IS_CONF_DEBUG_OSPF(ism
, ISM_TIMERS
))
1669 vty_out(vty
, "debug ospf%s ism timer\n", str
);
1672 /* debug ospf nsm (status|events|timers). */
1673 if (IS_CONF_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1674 vty_out(vty
, "debug ospf%s nsm\n", str
);
1676 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_STATUS
))
1677 vty_out(vty
, "debug ospf%s nsm status\n", str
);
1678 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1679 vty_out(vty
, "debug ospf%s nsm event\n", str
);
1680 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1681 vty_out(vty
, "debug ospf%s nsm timer\n", str
);
1684 /* debug ospf lsa (generate|flooding|install|refresh). */
1685 if (IS_CONF_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1686 vty_out(vty
, "debug ospf%s lsa\n", str
);
1688 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1689 vty_out(vty
, "debug ospf%s lsa generate\n", str
);
1690 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1691 vty_out(vty
, "debug ospf%s lsa flooding\n", str
);
1692 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1693 vty_out(vty
, "debug ospf%s lsa install\n", str
);
1694 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1695 vty_out(vty
, "debug ospf%s lsa refresh\n", str
);
1700 /* debug ospf zebra (interface|redistribute). */
1701 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1702 vty_out(vty
, "debug ospf%s zebra\n", str
);
1704 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1705 vty_out(vty
, "debug ospf%s zebra interface\n", str
);
1706 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1707 vty_out(vty
, "debug ospf%s zebra redistribute\n", str
);
1712 /* debug ospf event. */
1713 if (IS_CONF_DEBUG_OSPF(event
, EVENT
) == OSPF_DEBUG_EVENT
) {
1714 vty_out(vty
, "debug ospf%s event\n", str
);
1718 /* debug ospf nssa. */
1719 if (IS_CONF_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
) {
1720 vty_out(vty
, "debug ospf%s nssa\n", str
);
1724 /* debug ospf packet all detail. */
1725 r
= OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
;
1726 for (i
= 0; i
< 5; i
++)
1727 r
&= conf_debug_ospf_packet
[i
]
1728 & (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
);
1729 if (r
== (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
)) {
1730 vty_out(vty
, "debug ospf%s packet all detail\n", str
);
1734 /* debug ospf packet all. */
1735 r
= OSPF_DEBUG_SEND_RECV
;
1736 for (i
= 0; i
< 5; i
++)
1737 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
1738 if (r
== OSPF_DEBUG_SEND_RECV
) {
1739 vty_out(vty
, "debug ospf%s packet all\n", str
);
1740 for (i
= 0; i
< 5; i
++)
1741 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
1742 vty_out(vty
, "debug ospf%s packet %s detail\n",
1747 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1748 (send|recv) (detail). */
1749 for (i
= 0; i
< 5; i
++) {
1750 if (conf_debug_ospf_packet
[i
] == 0)
1753 vty_out(vty
, "debug ospf%s packet %s%s\n", str
, type_str
[i
],
1754 detail_str
[conf_debug_ospf_packet
[i
]]);
1761 /* Initialize debug commands. */
1764 install_node(&debug_node
, config_write_debug
);
1766 install_element(ENABLE_NODE
, &show_debugging_ospf_cmd
);
1767 install_element(ENABLE_NODE
, &debug_ospf_ism_cmd
);
1768 install_element(ENABLE_NODE
, &debug_ospf_nsm_cmd
);
1769 install_element(ENABLE_NODE
, &debug_ospf_lsa_cmd
);
1770 install_element(ENABLE_NODE
, &debug_ospf_zebra_cmd
);
1771 install_element(ENABLE_NODE
, &debug_ospf_event_cmd
);
1772 install_element(ENABLE_NODE
, &debug_ospf_nssa_cmd
);
1773 install_element(ENABLE_NODE
, &debug_ospf_te_cmd
);
1774 install_element(ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
1775 install_element(ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
1776 install_element(ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
1777 install_element(ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
1778 install_element(ENABLE_NODE
, &no_debug_ospf_event_cmd
);
1779 install_element(ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
1780 install_element(ENABLE_NODE
, &no_debug_ospf_te_cmd
);
1782 install_element(ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
1783 install_element(ENABLE_NODE
, &debug_ospf_packet_cmd
);
1784 install_element(ENABLE_NODE
, &no_debug_ospf_packet_cmd
);
1786 install_element(ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
1787 install_element(ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
1788 install_element(ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
1789 install_element(ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
1790 install_element(ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
1791 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1792 install_element(ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1793 install_element(ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1794 install_element(ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
1795 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1796 install_element(ENABLE_NODE
, &no_debug_ospf_cmd
);
1798 install_element(CONFIG_NODE
, &debug_ospf_packet_cmd
);
1799 install_element(CONFIG_NODE
, &no_debug_ospf_packet_cmd
);
1800 install_element(CONFIG_NODE
, &debug_ospf_ism_cmd
);
1801 install_element(CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
1803 install_element(CONFIG_NODE
, &debug_ospf_nsm_cmd
);
1804 install_element(CONFIG_NODE
, &debug_ospf_lsa_cmd
);
1805 install_element(CONFIG_NODE
, &debug_ospf_zebra_cmd
);
1806 install_element(CONFIG_NODE
, &debug_ospf_event_cmd
);
1807 install_element(CONFIG_NODE
, &debug_ospf_nssa_cmd
);
1808 install_element(CONFIG_NODE
, &debug_ospf_te_cmd
);
1809 install_element(CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
1810 install_element(CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
1811 install_element(CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
1812 install_element(CONFIG_NODE
, &no_debug_ospf_event_cmd
);
1813 install_element(CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
1814 install_element(CONFIG_NODE
, &no_debug_ospf_te_cmd
);
1816 install_element(CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
1817 install_element(CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
1818 install_element(CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
1819 install_element(CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
1820 install_element(CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
1821 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1822 install_element(CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1823 install_element(CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1824 install_element(CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
1825 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1826 install_element(CONFIG_NODE
, &no_debug_ospf_cmd
);