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;
56 unsigned long conf_debug_ospf_defaultinfo
= 0;
58 /* Enable debug option variables -- valid only session. */
59 unsigned long term_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
60 unsigned long term_debug_ospf_event
;
61 unsigned long term_debug_ospf_ism
= 0;
62 unsigned long term_debug_ospf_nsm
= 0;
63 unsigned long term_debug_ospf_lsa
= 0;
64 unsigned long term_debug_ospf_zebra
= 0;
65 unsigned long term_debug_ospf_nssa
= 0;
66 unsigned long term_debug_ospf_te
= 0;
67 unsigned long term_debug_ospf_ext
= 0;
68 unsigned long term_debug_ospf_sr
= 0;
69 unsigned long term_debug_ospf_defaultinfo
;
71 const char *ospf_redist_string(unsigned int route_type
)
73 return (route_type
== ZEBRA_ROUTE_MAX
) ? "Default"
74 : zebra_route_string(route_type
);
77 #define OSPF_AREA_STRING_MAXLEN 16
78 const char *ospf_area_name_string(struct ospf_area
*area
)
80 static char buf
[OSPF_AREA_STRING_MAXLEN
] = "";
86 area_id
= ntohl(area
->area_id
.s_addr
);
87 snprintf(buf
, sizeof(buf
), "%d.%d.%d.%d", (area_id
>> 24) & 0xff,
88 (area_id
>> 16) & 0xff, (area_id
>> 8) & 0xff, area_id
& 0xff);
92 #define OSPF_AREA_DESC_STRING_MAXLEN 23
93 const char *ospf_area_desc_string(struct ospf_area
*area
)
95 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
99 return "(incomplete)";
101 type
= area
->external_routing
;
104 snprintf(buf
, sizeof(buf
), "%s [NSSA]",
105 ospf_area_name_string(area
));
108 snprintf(buf
, sizeof(buf
), "%s [Stub]",
109 ospf_area_name_string(area
));
112 return ospf_area_name_string(area
);
118 #define OSPF_IF_STRING_MAXLEN 40
119 const char *ospf_if_name_string(struct ospf_interface
*oi
)
121 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
124 if (!oi
|| !oi
->address
)
127 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
128 return oi
->ifp
->name
;
130 ifaddr
= ntohl(oi
->address
->u
.prefix4
.s_addr
);
131 snprintf(buf
, sizeof(buf
), "%s:%d.%d.%d.%d", oi
->ifp
->name
,
132 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
133 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
138 void ospf_nbr_state_message(struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
141 struct ospf_interface
*oi
= nbr
->oi
;
143 if (IPV4_ADDR_SAME(&DR(oi
), &nbr
->address
.u
.prefix4
))
145 else if (IPV4_ADDR_SAME(&BDR(oi
), &nbr
->address
.u
.prefix4
))
150 snprintf(buf
, size
, "%s/%s",
151 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
),
152 lookup_msg(ospf_ism_state_msg
, state
, NULL
));
155 const char *ospf_timeval_dump(struct timeval
*t
, char *buf
, size_t size
)
157 /* Making formatted timer strings. */
158 #define MINUTE_IN_SECONDS 60
159 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
160 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
161 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
162 unsigned long w
, d
, h
, m
, ms
, us
;
167 w
= d
= h
= m
= ms
= 0;
168 memset(buf
, 0, size
);
174 (void)us
; /* unused */
178 t
->tv_sec
+= ms
/ 1000;
182 if (t
->tv_sec
> WEEK_IN_SECONDS
) {
183 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
184 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
187 if (t
->tv_sec
> DAY_IN_SECONDS
) {
188 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
189 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
192 if (t
->tv_sec
>= HOUR_IN_SECONDS
) {
193 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
194 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
197 if (t
->tv_sec
>= MINUTE_IN_SECONDS
) {
198 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
199 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
203 snprintf(buf
, size
, "%luw%1lud", w
, d
);
205 snprintf(buf
, size
, "%luw%1lud%02luh", w
, d
, h
);
207 snprintf(buf
, size
, "%1lud%02luh%02lum", d
, h
, m
);
209 snprintf(buf
, size
, "%luh%02lum%02lds", h
, m
, (long)t
->tv_sec
);
211 snprintf(buf
, size
, "%lum%02lds", m
, (long)t
->tv_sec
);
213 snprintf(buf
, size
, "%ld.%03lus", (long)t
->tv_sec
, ms
);
215 snprintf(buf
, size
, "%ld usecs", (long)t
->tv_usec
);
220 const char *ospf_timer_dump(struct thread
*t
, char *buf
, size_t size
)
222 struct timeval result
;
226 monotime_until(&t
->u
.sands
, &result
);
227 return ospf_timeval_dump(&result
, buf
, size
);
230 static void ospf_packet_hello_dump(struct stream
*s
, uint16_t length
)
232 struct ospf_hello
*hello
;
235 hello
= (struct ospf_hello
*)stream_pnt(s
);
238 zlog_debug(" NetworkMask %s", inet_ntoa(hello
->network_mask
));
239 zlog_debug(" HelloInterval %d", ntohs(hello
->hello_interval
));
240 zlog_debug(" Options %d (%s)", hello
->options
,
241 ospf_options_dump(hello
->options
));
242 zlog_debug(" RtrPriority %d", hello
->priority
);
243 zlog_debug(" RtrDeadInterval %ld",
244 (unsigned long)ntohl(hello
->dead_interval
));
245 zlog_debug(" DRouter %s", inet_ntoa(hello
->d_router
));
246 zlog_debug(" BDRouter %s", inet_ntoa(hello
->bd_router
));
248 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
249 zlog_debug(" # Neighbors %d", length
/ 4);
250 for (i
= 0; length
> 0; i
++, length
-= sizeof(struct in_addr
))
251 zlog_debug(" Neighbor %s", inet_ntoa(hello
->neighbors
[i
]));
254 static char *ospf_dd_flags_dump(uint8_t flags
, char *buf
, size_t size
)
256 snprintf(buf
, size
, "%s|%s|%s", (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
257 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
258 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
263 static char *ospf_router_lsa_flags_dump(uint8_t flags
, char *buf
, size_t size
)
265 snprintf(buf
, size
, "%s|%s|%s",
266 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
267 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
268 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
273 static void ospf_router_lsa_dump(struct stream
*s
, uint16_t length
)
276 struct router_lsa
*rl
;
279 rl
= (struct router_lsa
*)stream_pnt(s
);
281 zlog_debug(" Router-LSA");
282 zlog_debug(" flags %s",
283 ospf_router_lsa_flags_dump(rl
->flags
, buf
, BUFSIZ
));
284 zlog_debug(" # links %d", ntohs(rl
->links
));
286 len
= ntohs(rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
287 for (i
= 0; len
> 0; i
++) {
288 zlog_debug(" Link ID %s", inet_ntoa(rl
->link
[i
].link_id
));
289 zlog_debug(" Link Data %s",
290 inet_ntoa(rl
->link
[i
].link_data
));
291 zlog_debug(" Type %d", (uint8_t)rl
->link
[i
].type
);
292 zlog_debug(" TOS %d", (uint8_t)rl
->link
[i
].tos
);
293 zlog_debug(" metric %d", ntohs(rl
->link
[i
].metric
));
299 static void ospf_network_lsa_dump(struct stream
*s
, uint16_t length
)
301 struct network_lsa
*nl
;
304 nl
= (struct network_lsa
*)stream_pnt(s
);
305 cnt
= (ntohs(nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
307 zlog_debug(" Network-LSA");
309 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
310 zlog_debug ("Network-LSA size %d",
311 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
313 zlog_debug(" Network Mask %s", inet_ntoa(nl
->mask
));
314 zlog_debug(" # Attached Routers %d", cnt
);
315 for (i
= 0; i
< cnt
; i
++)
316 zlog_debug(" Attached Router %s",
317 inet_ntoa(nl
->routers
[i
]));
320 static void ospf_summary_lsa_dump(struct stream
*s
, uint16_t length
)
322 struct summary_lsa
*sl
;
326 sl
= (struct summary_lsa
*)stream_pnt(s
);
328 zlog_debug(" Summary-LSA");
329 zlog_debug(" Network Mask %s", inet_ntoa(sl
->mask
));
331 size
= ntohs(sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
332 for (i
= 0; size
> 0; size
-= 4, i
++)
333 zlog_debug(" TOS=%d metric %d", sl
->tos
,
334 GET_METRIC(sl
->metric
));
337 static void ospf_as_external_lsa_dump(struct stream
*s
, uint16_t length
)
339 struct as_external_lsa
*al
;
343 al
= (struct as_external_lsa
*)stream_pnt(s
);
344 zlog_debug(" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
345 zlog_debug(" Network Mask %s", inet_ntoa(al
->mask
));
347 size
= ntohs(al
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
348 for (i
= 0; size
> 0; size
-= 12, i
++) {
349 zlog_debug(" bit %s TOS=%d metric %d",
350 IS_EXTERNAL_METRIC(al
->e
[i
].tos
) ? "E" : "-",
351 al
->e
[i
].tos
& 0x7f, GET_METRIC(al
->e
[i
].metric
));
352 zlog_debug(" Forwarding address %s",
353 inet_ntoa(al
->e
[i
].fwd_addr
));
354 zlog_debug(" External Route Tag %" ROUTE_TAG_PRI
,
359 static void ospf_lsa_header_list_dump(struct stream
*s
, uint16_t length
)
361 struct lsa_header
*lsa
;
363 zlog_debug(" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
367 lsa
= (struct lsa_header
*)stream_pnt(s
);
368 ospf_lsa_header_dump(lsa
);
370 stream_forward_getp(s
, OSPF_LSA_HEADER_SIZE
);
371 length
-= OSPF_LSA_HEADER_SIZE
;
375 static void ospf_packet_db_desc_dump(struct stream
*s
, uint16_t length
)
377 struct ospf_db_desc
*dd
;
382 gp
= stream_get_getp(s
);
383 dd
= (struct ospf_db_desc
*)stream_pnt(s
);
385 zlog_debug("Database Description");
386 zlog_debug(" Interface MTU %d", ntohs(dd
->mtu
));
387 zlog_debug(" Options %d (%s)", dd
->options
,
388 ospf_options_dump(dd
->options
));
389 zlog_debug(" Flags %d (%s)", dd
->flags
,
390 ospf_dd_flags_dump(dd
->flags
, dd_flags
, sizeof(dd_flags
)));
391 zlog_debug(" Sequence Number 0x%08lx",
392 (unsigned 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
, uint16_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
, uint16_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
, uint16_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 static void ospf_header_dump(struct ospf_header
*ospfh
)
508 uint16_t auth_type
= ntohs(ospfh
->auth_type
);
510 zlog_debug("Header");
511 zlog_debug(" Version %d", ospfh
->version
);
512 zlog_debug(" Type %d (%s)", ospfh
->type
,
513 lookup_msg(ospf_packet_type_str
, ospfh
->type
, NULL
));
514 zlog_debug(" Packet Len %d", ntohs(ospfh
->length
));
515 zlog_debug(" Router ID %s", inet_ntoa(ospfh
->router_id
));
516 zlog_debug(" Area ID %s", inet_ntoa(ospfh
->area_id
));
517 zlog_debug(" Checksum 0x%x", ntohs(ospfh
->checksum
));
518 zlog_debug(" AuType %s",
519 lookup_msg(ospf_auth_type_str
, auth_type
, NULL
));
524 case OSPF_AUTH_SIMPLE
:
525 strlcpy(buf
, (char *)ospfh
->u
.auth_data
, sizeof(buf
));
526 zlog_debug(" Simple Password %s", buf
);
528 case OSPF_AUTH_CRYPTOGRAPHIC
:
529 zlog_debug(" Cryptographic Authentication");
530 zlog_debug(" Key ID %d", ospfh
->u
.crypt
.key_id
);
531 zlog_debug(" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
532 zlog_debug(" Sequence number %ld",
533 (unsigned long)ntohl(ospfh
->u
.crypt
.crypt_seqnum
));
536 zlog_debug("* This is not supported authentication type");
541 void ospf_packet_dump(struct stream
*s
)
543 struct ospf_header
*ospfh
;
546 /* Preserve pointer. */
547 gp
= stream_get_getp(s
);
549 /* OSPF Header dump. */
550 ospfh
= (struct ospf_header
*)stream_pnt(s
);
552 /* Until detail flag is set, return. */
553 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
556 /* Show OSPF header detail. */
557 ospf_header_dump(ospfh
);
558 stream_forward_getp(s
, OSPF_HEADER_SIZE
);
560 switch (ospfh
->type
) {
562 ospf_packet_hello_dump(s
, ntohs(ospfh
->length
));
564 case OSPF_MSG_DB_DESC
:
565 ospf_packet_db_desc_dump(s
, ntohs(ospfh
->length
));
567 case OSPF_MSG_LS_REQ
:
568 ospf_packet_ls_req_dump(s
, ntohs(ospfh
->length
));
570 case OSPF_MSG_LS_UPD
:
571 ospf_packet_ls_upd_dump(s
, ntohs(ospfh
->length
));
573 case OSPF_MSG_LS_ACK
:
574 ospf_packet_ls_ack_dump(s
, ntohs(ospfh
->length
));
580 stream_set_getp(s
, gp
);
583 DEFUN (debug_ospf_packet
,
584 debug_ospf_packet_cmd
,
585 "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
591 "OSPF Database Description\n"
592 "OSPF Link State Request\n"
593 "OSPF Link State Update\n"
594 "OSPF Link State Acknowledgment\n"
597 "Detail Information\n"
599 "Detail Information\n"
600 "Detail Information\n")
602 int inst
= (argv
[2]->type
== RANGE_TKN
) ? 1 : 0;
603 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
604 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
605 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
606 char *packet
= argv
[3 + inst
]->text
;
608 if (inst
) // user passed instance ID
610 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
611 return CMD_NOT_MY_INSTANCE
;
618 /* Check packet type. */
619 if (strmatch(packet
, "hello"))
620 type
= OSPF_DEBUG_HELLO
;
621 else if (strmatch(packet
, "dd"))
622 type
= OSPF_DEBUG_DB_DESC
;
623 else if (strmatch(packet
, "ls-request"))
624 type
= OSPF_DEBUG_LS_REQ
;
625 else if (strmatch(packet
, "ls-update"))
626 type
= OSPF_DEBUG_LS_UPD
;
627 else if (strmatch(packet
, "ls-ack"))
628 type
= OSPF_DEBUG_LS_ACK
;
629 else if (strmatch(packet
, "all"))
630 type
= OSPF_DEBUG_ALL
;
633 * (none) = send + recv
634 * detail = send + recv + detail
637 * recv detail = recv + detail
638 * send detail = send + detail
643 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
644 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
645 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
647 for (i
= 0; i
< 5; i
++)
648 if (type
& (0x01 << i
)) {
649 if (vty
->node
== CONFIG_NODE
)
650 DEBUG_PACKET_ON(i
, flag
);
652 TERM_DEBUG_PACKET_ON(i
, flag
);
658 DEFUN (no_debug_ospf_packet
,
659 no_debug_ospf_packet_cmd
,
660 "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
667 "OSPF Database Description\n"
668 "OSPF Link State Request\n"
669 "OSPF Link State Update\n"
670 "OSPF Link State Acknowledgment\n"
673 "Detail Information\n"
675 "Detail Information\n"
676 "Detail Information\n")
678 int inst
= (argv
[3]->type
== RANGE_TKN
) ? 1 : 0;
679 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
680 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
681 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
682 char *packet
= argv
[4 + inst
]->text
;
684 if (inst
) // user passed instance ID
686 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
687 return CMD_NOT_MY_INSTANCE
;
694 /* Check packet type. */
695 if (strmatch(packet
, "hello"))
696 type
= OSPF_DEBUG_HELLO
;
697 else if (strmatch(packet
, "dd"))
698 type
= OSPF_DEBUG_DB_DESC
;
699 else if (strmatch(packet
, "ls-request"))
700 type
= OSPF_DEBUG_LS_REQ
;
701 else if (strmatch(packet
, "ls-update"))
702 type
= OSPF_DEBUG_LS_UPD
;
703 else if (strmatch(packet
, "ls-ack"))
704 type
= OSPF_DEBUG_LS_ACK
;
705 else if (strmatch(packet
, "all"))
706 type
= OSPF_DEBUG_ALL
;
709 * (none) = send + recv
710 * detail = send + recv + detail
713 * recv detail = recv + detail
714 * send detail = send + detail
719 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
720 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
721 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
723 for (i
= 0; i
< 5; i
++)
724 if (type
& (0x01 << i
)) {
725 if (vty
->node
== CONFIG_NODE
)
726 DEBUG_PACKET_OFF(i
, flag
);
728 TERM_DEBUG_PACKET_OFF(i
, flag
);
733 for (i = 0; i < 5; i++)
734 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
741 DEFUN (debug_ospf_ism
,
743 "debug ospf [(1-65535)] ism [<status|events|timers>]",
747 "OSPF Interface State Machine\n"
748 "ISM Status Information\n"
749 "ISM Event Information\n"
750 "ISM TImer Information\n")
752 int inst
= (argv
[2]->type
== RANGE_TKN
);
753 char *dbgparam
= (argc
== 4 + inst
) ? argv
[argc
- 1]->text
: NULL
;
755 if (inst
) // user passed instance ID
757 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
758 return CMD_NOT_MY_INSTANCE
;
761 if (vty
->node
== CONFIG_NODE
) {
765 if (strmatch(dbgparam
, "status"))
766 DEBUG_ON(ism
, ISM_STATUS
);
767 else if (strmatch(dbgparam
, "events"))
768 DEBUG_ON(ism
, ISM_EVENTS
);
769 else if (strmatch(dbgparam
, "timers"))
770 DEBUG_ON(ism
, ISM_TIMERS
);
778 TERM_DEBUG_ON(ism
, ISM
);
780 if (strmatch(dbgparam
, "status"))
781 TERM_DEBUG_ON(ism
, ISM_STATUS
);
782 else if (strmatch(dbgparam
, "events"))
783 TERM_DEBUG_ON(ism
, ISM_EVENTS
);
784 else if (strmatch(dbgparam
, "timers"))
785 TERM_DEBUG_ON(ism
, ISM_TIMERS
);
791 DEFUN (no_debug_ospf_ism
,
792 no_debug_ospf_ism_cmd
,
793 "no debug ospf [(1-65535)] ism [<status|events|timers>]",
798 "OSPF Interface State Machine\n"
799 "ISM Status Information\n"
800 "ISM Event Information\n"
801 "ISM TImer Information\n")
803 int inst
= (argv
[3]->type
== RANGE_TKN
);
804 char *dbgparam
= (argc
== 5 + inst
) ? argv
[argc
- 1]->text
: NULL
;
806 if (inst
) // user passed instance ID
808 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
809 return CMD_NOT_MY_INSTANCE
;
812 if (vty
->node
== CONFIG_NODE
) {
816 if (strmatch(dbgparam
, "status"))
817 DEBUG_OFF(ism
, ISM_STATUS
);
818 else if (strmatch(dbgparam
, "events"))
819 DEBUG_OFF(ism
, ISM_EVENTS
);
820 else if (strmatch(dbgparam
, "timers"))
821 DEBUG_OFF(ism
, ISM_TIMERS
);
829 TERM_DEBUG_OFF(ism
, ISM
);
831 if (strmatch(dbgparam
, "status"))
832 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
833 else if (strmatch(dbgparam
, "events"))
834 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
835 else if (strmatch(dbgparam
, "timers"))
836 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
842 static int debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
843 struct cmd_token
**argv
)
845 if (vty
->node
== CONFIG_NODE
) {
846 if (argc
== arg_base
+ 0)
848 else if (argc
== arg_base
+ 1) {
849 if (strmatch(argv
[arg_base
]->text
, "status"))
850 DEBUG_ON(nsm
, NSM_STATUS
);
851 else if (strmatch(argv
[arg_base
]->text
, "events"))
852 DEBUG_ON(nsm
, NSM_EVENTS
);
853 else if (strmatch(argv
[arg_base
]->text
, "timers"))
854 DEBUG_ON(nsm
, NSM_TIMERS
);
861 if (argc
== arg_base
+ 0)
862 TERM_DEBUG_ON(nsm
, NSM
);
863 else if (argc
== arg_base
+ 1) {
864 if (strmatch(argv
[arg_base
]->text
, "status"))
865 TERM_DEBUG_ON(nsm
, NSM_STATUS
);
866 else if (strmatch(argv
[arg_base
]->text
, "events"))
867 TERM_DEBUG_ON(nsm
, NSM_EVENTS
);
868 else if (strmatch(argv
[arg_base
]->text
, "timers"))
869 TERM_DEBUG_ON(nsm
, NSM_TIMERS
);
875 DEFUN (debug_ospf_nsm
,
877 "debug ospf nsm [<status|events|timers>]",
880 "OSPF Neighbor State Machine\n"
881 "NSM Status Information\n"
882 "NSM Event Information\n"
883 "NSM Timer Information\n")
885 return debug_ospf_nsm_common(vty
, 3, argc
, argv
);
888 DEFUN (debug_ospf_instance_nsm
,
889 debug_ospf_instance_nsm_cmd
,
890 "debug ospf (1-65535) nsm [<status|events|timers>]",
894 "OSPF Neighbor State Machine\n"
895 "NSM Status Information\n"
896 "NSM Event Information\n"
897 "NSM Timer Information\n")
900 unsigned short instance
= 0;
902 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
903 if (!ospf_lookup_instance(instance
))
906 return debug_ospf_nsm_common(vty
, 4, argc
, argv
);
910 static int no_debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
911 struct cmd_token
**argv
)
914 if (vty
->node
== CONFIG_NODE
) {
915 if (argc
== arg_base
+ 0)
917 else if (argc
== arg_base
+ 1) {
918 if (strmatch(argv
[arg_base
]->text
, "status"))
919 DEBUG_OFF(nsm
, NSM_STATUS
);
920 else if (strmatch(argv
[arg_base
]->text
, "events"))
921 DEBUG_OFF(nsm
, NSM_EVENTS
);
922 else if (strmatch(argv
[arg_base
]->text
, "timers"))
923 DEBUG_OFF(nsm
, NSM_TIMERS
);
930 if (argc
== arg_base
+ 0)
931 TERM_DEBUG_OFF(nsm
, NSM
);
932 else if (argc
== arg_base
+ 1) {
933 if (strmatch(argv
[arg_base
]->text
, "status"))
934 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
935 else if (strmatch(argv
[arg_base
]->text
, "events"))
936 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
937 else if (strmatch(argv
[arg_base
]->text
, "timers"))
938 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
944 DEFUN (no_debug_ospf_nsm
,
945 no_debug_ospf_nsm_cmd
,
946 "no debug ospf nsm [<status|events|timers>]",
950 "OSPF Neighbor State Machine\n"
951 "NSM Status Information\n"
952 "NSM Event Information\n"
953 "NSM Timer Information\n")
955 return no_debug_ospf_nsm_common(vty
, 4, argc
, argv
);
959 DEFUN (no_debug_ospf_instance_nsm
,
960 no_debug_ospf_instance_nsm_cmd
,
961 "no debug ospf (1-65535) nsm [<status|events|timers>]",
966 "OSPF Neighbor State Machine\n"
967 "NSM Status Information\n"
968 "NSM Event Information\n"
969 "NSM Timer Information\n")
972 unsigned short instance
= 0;
974 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
975 if (!ospf_lookup_instance(instance
))
976 return CMD_NOT_MY_INSTANCE
;
978 return no_debug_ospf_nsm_common(vty
, 5, argc
, argv
);
982 static int debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
983 struct cmd_token
**argv
)
985 if (vty
->node
== CONFIG_NODE
) {
986 if (argc
== arg_base
+ 0)
988 else if (argc
== arg_base
+ 1) {
989 if (strmatch(argv
[arg_base
]->text
, "generate"))
990 DEBUG_ON(lsa
, LSA_GENERATE
);
991 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
992 DEBUG_ON(lsa
, LSA_FLOODING
);
993 else if (strmatch(argv
[arg_base
]->text
, "install"))
994 DEBUG_ON(lsa
, LSA_INSTALL
);
995 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
996 DEBUG_ON(lsa
, LSA_REFRESH
);
1003 if (argc
== arg_base
+ 0)
1004 TERM_DEBUG_ON(lsa
, LSA
);
1005 else if (argc
== arg_base
+ 1) {
1006 if (strmatch(argv
[arg_base
]->text
, "generate"))
1007 TERM_DEBUG_ON(lsa
, LSA_GENERATE
);
1008 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1009 TERM_DEBUG_ON(lsa
, LSA_FLOODING
);
1010 else if (strmatch(argv
[arg_base
]->text
, "install"))
1011 TERM_DEBUG_ON(lsa
, LSA_INSTALL
);
1012 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1013 TERM_DEBUG_ON(lsa
, LSA_REFRESH
);
1019 DEFUN (debug_ospf_lsa
,
1021 "debug ospf lsa [<generate|flooding|install|refresh>]",
1024 "OSPF Link State Advertisement\n"
1027 "LSA Install/Delete\n"
1030 return debug_ospf_lsa_common(vty
, 3, argc
, argv
);
1033 DEFUN (debug_ospf_instance_lsa
,
1034 debug_ospf_instance_lsa_cmd
,
1035 "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1039 "OSPF Link State Advertisement\n"
1042 "LSA Install/Delete\n"
1046 unsigned short instance
= 0;
1048 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1049 if (!ospf_lookup_instance(instance
))
1050 return CMD_NOT_MY_INSTANCE
;
1052 return debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1056 static int no_debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
1057 struct cmd_token
**argv
)
1059 if (vty
->node
== CONFIG_NODE
) {
1060 if (argc
== arg_base
+ 0)
1061 DEBUG_OFF(lsa
, LSA
);
1062 else if (argc
== arg_base
+ 1) {
1063 if (strmatch(argv
[arg_base
]->text
, "generate"))
1064 DEBUG_OFF(lsa
, LSA_GENERATE
);
1065 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1066 DEBUG_OFF(lsa
, LSA_FLOODING
);
1067 else if (strmatch(argv
[arg_base
]->text
, "install"))
1068 DEBUG_OFF(lsa
, LSA_INSTALL
);
1069 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1070 DEBUG_OFF(lsa
, LSA_REFRESH
);
1077 if (argc
== arg_base
+ 0)
1078 TERM_DEBUG_OFF(lsa
, LSA
);
1079 else if (argc
== arg_base
+ 1) {
1080 if (strmatch(argv
[arg_base
]->text
, "generate"))
1081 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1082 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1083 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1084 else if (strmatch(argv
[arg_base
]->text
, "install"))
1085 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1086 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1087 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1093 DEFUN (no_debug_ospf_lsa
,
1094 no_debug_ospf_lsa_cmd
,
1095 "no debug ospf lsa [<generate|flooding|install|refresh>]",
1099 "OSPF Link State Advertisement\n"
1102 "LSA Install/Delete\n"
1105 return no_debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1108 DEFUN (no_debug_ospf_instance_lsa
,
1109 no_debug_ospf_instance_lsa_cmd
,
1110 "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1115 "OSPF Link State Advertisement\n"
1118 "LSA Install/Delete\n"
1122 unsigned short instance
= 0;
1124 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1125 if (!ospf_lookup_instance(instance
))
1126 return CMD_NOT_MY_INSTANCE
;
1128 return no_debug_ospf_lsa_common(vty
, 5, argc
, argv
);
1132 static int debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1133 struct cmd_token
**argv
)
1135 if (vty
->node
== CONFIG_NODE
) {
1136 if (argc
== arg_base
+ 0)
1137 DEBUG_ON(zebra
, ZEBRA
);
1138 else if (argc
== arg_base
+ 1) {
1139 if (strmatch(argv
[arg_base
]->text
, "interface"))
1140 DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1141 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1142 DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1149 if (argc
== arg_base
+ 0)
1150 TERM_DEBUG_ON(zebra
, ZEBRA
);
1151 else if (argc
== arg_base
+ 1) {
1152 if (strmatch(argv
[arg_base
]->text
, "interface"))
1153 TERM_DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1154 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1155 TERM_DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1161 DEFUN (debug_ospf_zebra
,
1162 debug_ospf_zebra_cmd
,
1163 "debug ospf zebra [<interface|redistribute>]",
1168 "Zebra redistribute\n")
1170 return debug_ospf_zebra_common(vty
, 3, argc
, argv
);
1173 DEFUN (debug_ospf_instance_zebra
,
1174 debug_ospf_instance_zebra_cmd
,
1175 "debug ospf (1-65535) zebra [<interface|redistribute>]",
1181 "Zebra redistribute\n")
1184 unsigned short instance
= 0;
1186 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1187 if (!ospf_lookup_instance(instance
))
1188 return CMD_NOT_MY_INSTANCE
;
1190 return debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1194 static int no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1195 struct cmd_token
**argv
)
1197 if (vty
->node
== CONFIG_NODE
) {
1198 if (argc
== arg_base
+ 0)
1199 DEBUG_OFF(zebra
, ZEBRA
);
1200 else if (argc
== arg_base
+ 1) {
1201 if (strmatch(argv
[arg_base
]->text
, "interface"))
1202 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1203 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1204 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1211 if (argc
== arg_base
+ 0)
1212 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1213 else if (argc
== arg_base
+ 1) {
1214 if (strmatch(argv
[arg_base
]->text
, "interface"))
1215 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1216 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1217 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1223 DEFUN (no_debug_ospf_zebra
,
1224 no_debug_ospf_zebra_cmd
,
1225 "no debug ospf zebra [<interface|redistribute>]",
1231 "Zebra redistribute\n")
1233 return no_debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1236 DEFUN (no_debug_ospf_instance_zebra
,
1237 no_debug_ospf_instance_zebra_cmd
,
1238 "no debug ospf (1-65535) zebra [<interface|redistribute>]",
1245 "Zebra redistribute\n")
1248 unsigned short instance
= 0;
1250 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1251 if (!ospf_lookup_instance(instance
))
1254 return no_debug_ospf_zebra_common(vty
, 5, argc
, argv
);
1258 DEFUN (debug_ospf_event
,
1259 debug_ospf_event_cmd
,
1263 "OSPF event information\n")
1265 if (vty
->node
== CONFIG_NODE
)
1266 CONF_DEBUG_ON(event
, EVENT
);
1267 TERM_DEBUG_ON(event
, EVENT
);
1271 DEFUN (no_debug_ospf_event
,
1272 no_debug_ospf_event_cmd
,
1273 "no debug ospf event",
1277 "OSPF event information\n")
1279 if (vty
->node
== CONFIG_NODE
)
1280 CONF_DEBUG_OFF(event
, EVENT
);
1281 TERM_DEBUG_OFF(event
, EVENT
);
1285 DEFUN (debug_ospf_instance_event
,
1286 debug_ospf_instance_event_cmd
,
1287 "debug ospf (1-65535) event",
1291 "OSPF event information\n")
1294 unsigned short instance
= 0;
1296 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1297 if (!ospf_lookup_instance(instance
))
1300 if (vty
->node
== CONFIG_NODE
)
1301 CONF_DEBUG_ON(event
, EVENT
);
1302 TERM_DEBUG_ON(event
, EVENT
);
1306 DEFUN (no_debug_ospf_instance_event
,
1307 no_debug_ospf_instance_event_cmd
,
1308 "no debug ospf (1-65535) event",
1313 "OSPF event information\n")
1316 unsigned short instance
= 0;
1318 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1319 if (!ospf_lookup_instance(instance
))
1322 if (vty
->node
== CONFIG_NODE
)
1323 CONF_DEBUG_OFF(event
, EVENT
);
1324 TERM_DEBUG_OFF(event
, EVENT
);
1328 DEFUN (debug_ospf_nssa
,
1329 debug_ospf_nssa_cmd
,
1333 "OSPF nssa information\n")
1335 if (vty
->node
== CONFIG_NODE
)
1336 CONF_DEBUG_ON(nssa
, NSSA
);
1337 TERM_DEBUG_ON(nssa
, NSSA
);
1341 DEFUN (no_debug_ospf_nssa
,
1342 no_debug_ospf_nssa_cmd
,
1343 "no debug ospf nssa",
1347 "OSPF nssa information\n")
1349 if (vty
->node
== CONFIG_NODE
)
1350 CONF_DEBUG_OFF(nssa
, NSSA
);
1351 TERM_DEBUG_OFF(nssa
, NSSA
);
1355 DEFUN (debug_ospf_instance_nssa
,
1356 debug_ospf_instance_nssa_cmd
,
1357 "debug ospf (1-65535) nssa",
1361 "OSPF nssa information\n")
1364 unsigned short instance
= 0;
1366 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1367 if (!ospf_lookup_instance(instance
))
1370 if (vty
->node
== CONFIG_NODE
)
1371 CONF_DEBUG_ON(nssa
, NSSA
);
1372 TERM_DEBUG_ON(nssa
, NSSA
);
1376 DEFUN (no_debug_ospf_instance_nssa
,
1377 no_debug_ospf_instance_nssa_cmd
,
1378 "no debug ospf (1-65535) nssa",
1383 "OSPF nssa information\n")
1386 unsigned short instance
= 0;
1388 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1389 if (!ospf_lookup_instance(instance
))
1392 if (vty
->node
== CONFIG_NODE
)
1393 CONF_DEBUG_OFF(nssa
, NSSA
);
1394 TERM_DEBUG_OFF(nssa
, NSSA
);
1398 DEFUN (debug_ospf_te
,
1403 "OSPF-TE information\n")
1405 if (vty
->node
== CONFIG_NODE
)
1406 CONF_DEBUG_ON(te
, TE
);
1407 TERM_DEBUG_ON(te
, TE
);
1411 DEFUN (no_debug_ospf_te
,
1412 no_debug_ospf_te_cmd
,
1417 "OSPF-TE information\n")
1419 if (vty
->node
== CONFIG_NODE
)
1420 CONF_DEBUG_OFF(te
, TE
);
1421 TERM_DEBUG_OFF(te
, TE
);
1425 DEFUN (debug_ospf_sr
,
1430 "OSPF-SR information\n")
1432 if (vty
->node
== CONFIG_NODE
)
1433 CONF_DEBUG_ON(sr
, SR
);
1434 TERM_DEBUG_ON(sr
, SR
);
1438 DEFUN (no_debug_ospf_sr
,
1439 no_debug_ospf_sr_cmd
,
1444 "OSPF-SR information\n")
1446 if (vty
->node
== CONFIG_NODE
)
1447 CONF_DEBUG_OFF(sr
, SR
);
1448 TERM_DEBUG_OFF(sr
, SR
);
1452 DEFUN (debug_ospf_default_info
,
1453 debug_ospf_default_info_cmd
,
1454 "debug ospf default-information",
1457 "OSPF default information\n")
1459 if (vty
->node
== CONFIG_NODE
)
1460 CONF_DEBUG_ON(defaultinfo
, DEFAULTINFO
);
1461 TERM_DEBUG_ON(defaultinfo
, DEFAULTINFO
);
1465 DEFUN (no_debug_ospf_default_info
,
1466 no_debug_ospf_default_info_cmd
,
1467 "no debug ospf default-information",
1471 "OSPF default information\n")
1473 if (vty
->node
== CONFIG_NODE
)
1474 CONF_DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1475 TERM_DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1479 DEFUN (no_debug_ospf
,
1486 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1489 if (vty
->node
== CONFIG_NODE
) {
1490 CONF_DEBUG_OFF(event
, EVENT
);
1491 CONF_DEBUG_OFF(nssa
, NSSA
);
1492 DEBUG_OFF(ism
, ISM_EVENTS
);
1493 DEBUG_OFF(ism
, ISM_STATUS
);
1494 DEBUG_OFF(ism
, ISM_TIMERS
);
1495 DEBUG_OFF(lsa
, LSA
);
1496 DEBUG_OFF(lsa
, LSA_FLOODING
);
1497 DEBUG_OFF(lsa
, LSA_GENERATE
);
1498 DEBUG_OFF(lsa
, LSA_INSTALL
);
1499 DEBUG_OFF(lsa
, LSA_REFRESH
);
1500 DEBUG_OFF(nsm
, NSM
);
1501 DEBUG_OFF(nsm
, NSM_EVENTS
);
1502 DEBUG_OFF(nsm
, NSM_STATUS
);
1503 DEBUG_OFF(nsm
, NSM_TIMERS
);
1504 DEBUG_OFF(zebra
, ZEBRA
);
1505 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1506 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1507 DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1509 for (i
= 0; i
< 5; i
++)
1510 DEBUG_PACKET_OFF(i
, flag
);
1513 for (i
= 0; i
< 5; i
++)
1514 TERM_DEBUG_PACKET_OFF(i
, flag
);
1516 TERM_DEBUG_OFF(event
, EVENT
);
1517 TERM_DEBUG_OFF(ism
, ISM
);
1518 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
1519 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
1520 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
1521 TERM_DEBUG_OFF(lsa
, LSA
);
1522 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1523 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1524 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1525 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1526 TERM_DEBUG_OFF(nsm
, NSM
);
1527 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
1528 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
1529 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
1530 TERM_DEBUG_OFF(nssa
, NSSA
);
1531 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1532 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1533 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1534 TERM_DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1539 static int show_debugging_ospf_common(struct vty
*vty
, struct ospf
*ospf
)
1544 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
1546 vty_out(vty
, "OSPF debugging status:\n");
1548 /* Show debug status for events. */
1549 if (IS_DEBUG_OSPF(event
, EVENT
))
1550 vty_out(vty
, " OSPF event debugging is on\n");
1552 /* Show debug status for ISM. */
1553 if (IS_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1554 vty_out(vty
, " OSPF ISM debugging is on\n");
1556 if (IS_DEBUG_OSPF(ism
, ISM_STATUS
))
1557 vty_out(vty
, " OSPF ISM status debugging is on\n");
1558 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
1559 vty_out(vty
, " OSPF ISM event debugging is on\n");
1560 if (IS_DEBUG_OSPF(ism
, ISM_TIMERS
))
1561 vty_out(vty
, " OSPF ISM timer debugging is on\n");
1564 /* Show debug status for NSM. */
1565 if (IS_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1566 vty_out(vty
, " OSPF NSM debugging is on\n");
1568 if (IS_DEBUG_OSPF(nsm
, NSM_STATUS
))
1569 vty_out(vty
, " OSPF NSM status debugging is on\n");
1570 if (IS_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1571 vty_out(vty
, " OSPF NSM event debugging is on\n");
1572 if (IS_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1573 vty_out(vty
, " OSPF NSM timer debugging is on\n");
1576 /* Show debug status for OSPF Packets. */
1577 for (i
= 0; i
< 5; i
++)
1578 if (IS_DEBUG_OSPF_PACKET(i
, SEND
)
1579 && IS_DEBUG_OSPF_PACKET(i
, RECV
)) {
1580 vty_out(vty
, " OSPF packet %s%s debugging is on\n",
1581 lookup_msg(ospf_packet_type_str
, i
+ 1, NULL
),
1582 IS_DEBUG_OSPF_PACKET(i
, DETAIL
) ? " detail"
1585 if (IS_DEBUG_OSPF_PACKET(i
, SEND
))
1587 " OSPF packet %s send%s debugging is on\n",
1588 lookup_msg(ospf_packet_type_str
, i
+ 1,
1590 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1593 if (IS_DEBUG_OSPF_PACKET(i
, RECV
))
1595 " OSPF packet %s receive%s debugging is on\n",
1596 lookup_msg(ospf_packet_type_str
, i
+ 1,
1598 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1603 /* Show debug status for OSPF LSAs. */
1604 if (IS_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1605 vty_out(vty
, " OSPF LSA debugging is on\n");
1607 if (IS_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1608 vty_out(vty
, " OSPF LSA generation debugging is on\n");
1609 if (IS_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1610 vty_out(vty
, " OSPF LSA flooding debugging is on\n");
1611 if (IS_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1612 vty_out(vty
, " OSPF LSA install debugging is on\n");
1613 if (IS_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1614 vty_out(vty
, " OSPF LSA refresh debugging is on\n");
1617 /* Show debug status for Zebra. */
1618 if (IS_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1619 vty_out(vty
, " OSPF Zebra debugging is on\n");
1621 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1623 " OSPF Zebra interface debugging is on\n");
1624 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1626 " OSPF Zebra redistribute debugging is on\n");
1629 if (IS_DEBUG_OSPF(defaultinfo
, DEFAULTINFO
) == OSPF_DEBUG_DEFAULTINFO
)
1630 vty_out(vty
, "OSPF default information is on\n");
1632 /* Show debug status for NSSA. */
1633 if (IS_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1634 vty_out(vty
, " OSPF NSSA debugging is on\n");
1641 DEFUN_NOSH (show_debugging_ospf
,
1642 show_debugging_ospf_cmd
,
1643 "show debugging [ospf]",
1648 struct ospf
*ospf
= NULL
;
1650 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1654 return show_debugging_ospf_common(vty
, ospf
);
1657 DEFUN_NOSH (show_debugging_ospf_instance
,
1658 show_debugging_ospf_instance_cmd
,
1659 "show debugging ospf (1-65535)",
1667 unsigned short instance
= 0;
1669 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1670 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
)
1673 return show_debugging_ospf_common(vty
, ospf
);
1676 static int config_write_debug(struct vty
*vty
);
1678 static struct cmd_node debug_node
= {
1682 .config_write
= config_write_debug
,
1685 static int config_write_debug(struct vty
*vty
)
1690 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update",
1692 const char *detail_str
[] = {
1693 "", " send", " recv", "",
1694 " detail", " send detail", " recv detail", " detail"};
1700 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1705 snprintf(str
, sizeof(str
), " %u", ospf
->instance
);
1707 /* debug ospf ism (status|events|timers). */
1708 if (IS_CONF_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1709 vty_out(vty
, "debug ospf%s ism\n", str
);
1711 if (IS_CONF_DEBUG_OSPF(ism
, ISM_STATUS
))
1712 vty_out(vty
, "debug ospf%s ism status\n", str
);
1713 if (IS_CONF_DEBUG_OSPF(ism
, ISM_EVENTS
))
1714 vty_out(vty
, "debug ospf%s ism event\n", str
);
1715 if (IS_CONF_DEBUG_OSPF(ism
, ISM_TIMERS
))
1716 vty_out(vty
, "debug ospf%s ism timer\n", str
);
1719 /* debug ospf nsm (status|events|timers). */
1720 if (IS_CONF_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1721 vty_out(vty
, "debug ospf%s nsm\n", str
);
1723 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_STATUS
))
1724 vty_out(vty
, "debug ospf%s nsm status\n", str
);
1725 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1726 vty_out(vty
, "debug ospf%s nsm event\n", str
);
1727 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1728 vty_out(vty
, "debug ospf%s nsm timer\n", str
);
1731 /* debug ospf lsa (generate|flooding|install|refresh). */
1732 if (IS_CONF_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1733 vty_out(vty
, "debug ospf%s lsa\n", str
);
1735 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1736 vty_out(vty
, "debug ospf%s lsa generate\n", str
);
1737 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1738 vty_out(vty
, "debug ospf%s lsa flooding\n", str
);
1739 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1740 vty_out(vty
, "debug ospf%s lsa install\n", str
);
1741 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1742 vty_out(vty
, "debug ospf%s lsa refresh\n", str
);
1747 /* debug ospf zebra (interface|redistribute). */
1748 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1749 vty_out(vty
, "debug ospf%s zebra\n", str
);
1751 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1752 vty_out(vty
, "debug ospf%s zebra interface\n", str
);
1753 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1754 vty_out(vty
, "debug ospf%s zebra redistribute\n", str
);
1759 /* debug ospf event. */
1760 if (IS_CONF_DEBUG_OSPF(event
, EVENT
) == OSPF_DEBUG_EVENT
) {
1761 vty_out(vty
, "debug ospf%s event\n", str
);
1765 /* debug ospf nssa. */
1766 if (IS_CONF_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
) {
1767 vty_out(vty
, "debug ospf%s nssa\n", str
);
1771 /* debug ospf packet all detail. */
1772 r
= OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
;
1773 for (i
= 0; i
< 5; i
++)
1774 r
&= conf_debug_ospf_packet
[i
]
1775 & (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
);
1776 if (r
== (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
)) {
1777 vty_out(vty
, "debug ospf%s packet all detail\n", str
);
1781 /* debug ospf packet all. */
1782 r
= OSPF_DEBUG_SEND_RECV
;
1783 for (i
= 0; i
< 5; i
++)
1784 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
1785 if (r
== OSPF_DEBUG_SEND_RECV
) {
1786 vty_out(vty
, "debug ospf%s packet all\n", str
);
1787 for (i
= 0; i
< 5; i
++)
1788 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
1789 vty_out(vty
, "debug ospf%s packet %s detail\n",
1794 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1795 (send|recv) (detail). */
1796 for (i
= 0; i
< 5; i
++) {
1797 if (conf_debug_ospf_packet
[i
] == 0)
1800 vty_out(vty
, "debug ospf%s packet %s%s\n", str
, type_str
[i
],
1801 detail_str
[conf_debug_ospf_packet
[i
]]);
1806 if (IS_CONF_DEBUG_OSPF(te
, TE
) == OSPF_DEBUG_TE
) {
1807 vty_out(vty
, "debug ospf%s te\n", str
);
1812 if (IS_CONF_DEBUG_OSPF(sr
, SR
) == OSPF_DEBUG_SR
) {
1813 vty_out(vty
, "debug ospf%s sr\n", str
);
1820 /* Initialize debug commands. */
1821 void ospf_debug_init(void)
1823 install_node(&debug_node
);
1825 install_element(ENABLE_NODE
, &show_debugging_ospf_cmd
);
1826 install_element(ENABLE_NODE
, &debug_ospf_ism_cmd
);
1827 install_element(ENABLE_NODE
, &debug_ospf_nsm_cmd
);
1828 install_element(ENABLE_NODE
, &debug_ospf_lsa_cmd
);
1829 install_element(ENABLE_NODE
, &debug_ospf_zebra_cmd
);
1830 install_element(ENABLE_NODE
, &debug_ospf_event_cmd
);
1831 install_element(ENABLE_NODE
, &debug_ospf_nssa_cmd
);
1832 install_element(ENABLE_NODE
, &debug_ospf_te_cmd
);
1833 install_element(ENABLE_NODE
, &debug_ospf_sr_cmd
);
1834 install_element(ENABLE_NODE
, &debug_ospf_default_info_cmd
);
1835 install_element(ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
1836 install_element(ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
1837 install_element(ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
1838 install_element(ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
1839 install_element(ENABLE_NODE
, &no_debug_ospf_event_cmd
);
1840 install_element(ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
1841 install_element(ENABLE_NODE
, &no_debug_ospf_te_cmd
);
1842 install_element(ENABLE_NODE
, &no_debug_ospf_sr_cmd
);
1843 install_element(ENABLE_NODE
, &no_debug_ospf_default_info_cmd
);
1845 install_element(ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
1846 install_element(ENABLE_NODE
, &debug_ospf_packet_cmd
);
1847 install_element(ENABLE_NODE
, &no_debug_ospf_packet_cmd
);
1849 install_element(ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
1850 install_element(ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
1851 install_element(ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
1852 install_element(ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
1853 install_element(ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
1854 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1855 install_element(ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1856 install_element(ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1857 install_element(ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
1858 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1859 install_element(ENABLE_NODE
, &no_debug_ospf_cmd
);
1861 install_element(CONFIG_NODE
, &debug_ospf_packet_cmd
);
1862 install_element(CONFIG_NODE
, &no_debug_ospf_packet_cmd
);
1863 install_element(CONFIG_NODE
, &debug_ospf_ism_cmd
);
1864 install_element(CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
1866 install_element(CONFIG_NODE
, &debug_ospf_nsm_cmd
);
1867 install_element(CONFIG_NODE
, &debug_ospf_lsa_cmd
);
1868 install_element(CONFIG_NODE
, &debug_ospf_zebra_cmd
);
1869 install_element(CONFIG_NODE
, &debug_ospf_event_cmd
);
1870 install_element(CONFIG_NODE
, &debug_ospf_nssa_cmd
);
1871 install_element(CONFIG_NODE
, &debug_ospf_te_cmd
);
1872 install_element(CONFIG_NODE
, &debug_ospf_sr_cmd
);
1873 install_element(CONFIG_NODE
, &debug_ospf_default_info_cmd
);
1874 install_element(CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
1875 install_element(CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
1876 install_element(CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
1877 install_element(CONFIG_NODE
, &no_debug_ospf_event_cmd
);
1878 install_element(CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
1879 install_element(CONFIG_NODE
, &no_debug_ospf_te_cmd
);
1880 install_element(CONFIG_NODE
, &no_debug_ospf_sr_cmd
);
1881 install_element(CONFIG_NODE
, &no_debug_ospf_default_info_cmd
);
1883 install_element(CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
1884 install_element(CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
1885 install_element(CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
1886 install_element(CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
1887 install_element(CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
1888 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1889 install_element(CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1890 install_element(CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1891 install_element(CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
1892 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1893 install_element(CONFIG_NODE
, &no_debug_ospf_cmd
);