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
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
34 #include "ospfd/ospfd.h"
35 #include "ospfd/ospf_interface.h"
36 #include "ospfd/ospf_ism.h"
37 #include "ospfd/ospf_asbr.h"
38 #include "ospfd/ospf_lsa.h"
39 #include "ospfd/ospf_lsdb.h"
40 #include "ospfd/ospf_neighbor.h"
41 #include "ospfd/ospf_nsm.h"
42 #include "ospfd/ospf_dump.h"
43 #include "ospfd/ospf_packet.h"
44 #include "ospfd/ospf_network.h"
46 /* Configuration debug option variables. */
47 unsigned long conf_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
48 unsigned long conf_debug_ospf_event
= 0;
49 unsigned long conf_debug_ospf_ism
= 0;
50 unsigned long conf_debug_ospf_nsm
= 0;
51 unsigned long conf_debug_ospf_lsa
= 0;
52 unsigned long conf_debug_ospf_zebra
= 0;
53 unsigned long conf_debug_ospf_nssa
= 0;
54 unsigned long conf_debug_ospf_te
= 0;
56 /* Enable debug option variables -- valid only session. */
57 unsigned long term_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
58 unsigned long term_debug_ospf_event
= 0;
59 unsigned long term_debug_ospf_ism
= 0;
60 unsigned long term_debug_ospf_nsm
= 0;
61 unsigned long term_debug_ospf_lsa
= 0;
62 unsigned long term_debug_ospf_zebra
= 0;
63 unsigned long term_debug_ospf_nssa
= 0;
64 unsigned long term_debug_ospf_te
= 0;
68 ospf_redist_string(u_int route_type
)
70 return (route_type
== ZEBRA_ROUTE_MAX
) ?
71 "Default" : zebra_route_string(route_type
);
74 #define OSPF_AREA_STRING_MAXLEN 16
76 ospf_area_name_string (struct ospf_area
*area
)
78 static char buf
[OSPF_AREA_STRING_MAXLEN
] = "";
84 area_id
= ntohl (area
->area_id
.s_addr
);
85 snprintf (buf
, OSPF_AREA_STRING_MAXLEN
, "%d.%d.%d.%d",
86 (area_id
>> 24) & 0xff, (area_id
>> 16) & 0xff,
87 (area_id
>> 8) & 0xff, area_id
& 0xff);
91 #define OSPF_AREA_DESC_STRING_MAXLEN 23
93 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
;
105 snprintf (buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [NSSA]",
106 ospf_area_name_string (area
));
109 snprintf (buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [Stub]",
110 ospf_area_name_string (area
));
113 return ospf_area_name_string (area
);
119 #define OSPF_IF_STRING_MAXLEN 40
121 ospf_if_name_string (struct ospf_interface
*oi
)
123 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
126 if (!oi
|| !oi
->address
)
129 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
130 return oi
->ifp
->name
;
132 ifaddr
= ntohl (oi
->address
->u
.prefix4
.s_addr
);
133 snprintf (buf
, OSPF_IF_STRING_MAXLEN
,
134 "%s:%d.%d.%d.%d", oi
->ifp
->name
,
135 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
136 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
142 ospf_nbr_state_message (struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
145 struct ospf_interface
*oi
= nbr
->oi
;
147 if (IPV4_ADDR_SAME (&DR (oi
), &nbr
->address
.u
.prefix4
))
149 else if (IPV4_ADDR_SAME (&BDR (oi
), &nbr
->address
.u
.prefix4
))
154 memset (buf
, 0, size
);
156 snprintf (buf
, size
, "%s/%s",
157 LOOKUP (ospf_nsm_state_msg
, nbr
->state
),
158 LOOKUP (ospf_ism_state_msg
, state
));
162 ospf_timeval_dump (struct timeval
*t
, char *buf
, size_t size
)
164 /* Making formatted timer strings. */
165 #define MINUTE_IN_SECONDS 60
166 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
167 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
168 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
169 unsigned long w
, d
, h
, m
, s
, ms
, us
;
174 w
= d
= h
= m
= s
= ms
= us
= 0;
175 memset (buf
, 0, size
);
186 t
->tv_sec
+= ms
/ 1000;
190 if (t
->tv_sec
> WEEK_IN_SECONDS
)
192 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
193 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
196 if (t
->tv_sec
> DAY_IN_SECONDS
)
198 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
199 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
202 if (t
->tv_sec
>= HOUR_IN_SECONDS
)
204 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
205 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
208 if (t
->tv_sec
>= MINUTE_IN_SECONDS
)
210 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
211 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
215 snprintf (buf
, size
, "%ldw%1ldd", w
, d
);
217 snprintf (buf
, size
, "%ldw%1ldd%02ldh", w
, d
, h
);
219 snprintf (buf
, size
, "%1ldd%02ldh%02ldm", d
, h
, m
);
221 snprintf (buf
, size
, "%ldh%02ldm%02lds", h
, m
, (long)t
->tv_sec
);
223 snprintf (buf
, size
, "%ldm%02lds", m
, (long)t
->tv_sec
);
225 snprintf (buf
, size
, "%ld.%03lds", (long)t
->tv_sec
, ms
);
227 snprintf (buf
, size
, "%ld usecs", (long)t
->tv_usec
);
233 ospf_timer_dump (struct thread
*t
, char *buf
, size_t size
)
235 struct timeval result
;
239 monotime_until (&t
->u
.sands
, &result
);
240 return ospf_timeval_dump (&result
, buf
, size
);
244 ospf_packet_hello_dump (struct stream
*s
, u_int16_t length
)
246 struct ospf_hello
*hello
;
249 hello
= (struct ospf_hello
*) STREAM_PNT (s
);
251 zlog_debug ("Hello");
252 zlog_debug (" NetworkMask %s", inet_ntoa (hello
->network_mask
));
253 zlog_debug (" HelloInterval %d", ntohs (hello
->hello_interval
));
254 zlog_debug (" Options %d (%s)", hello
->options
,
255 ospf_options_dump (hello
->options
));
256 zlog_debug (" RtrPriority %d", hello
->priority
);
257 zlog_debug (" RtrDeadInterval %ld", (u_long
)ntohl (hello
->dead_interval
));
258 zlog_debug (" DRouter %s", inet_ntoa (hello
->d_router
));
259 zlog_debug (" BDRouter %s", inet_ntoa (hello
->bd_router
));
261 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
262 zlog_debug (" # Neighbors %d", length
/ 4);
263 for (i
= 0; length
> 0; i
++, length
-= sizeof (struct in_addr
))
264 zlog_debug (" Neighbor %s", inet_ntoa (hello
->neighbors
[i
]));
268 ospf_dd_flags_dump (u_char flags
, char *buf
, size_t size
)
270 memset (buf
, 0, size
);
272 snprintf (buf
, size
, "%s|%s|%s",
273 (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
274 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
275 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
281 ospf_router_lsa_flags_dump (u_char flags
, char *buf
, size_t size
)
283 memset (buf
, 0, size
);
285 snprintf (buf
, size
, "%s|%s|%s",
286 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
287 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
288 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
294 ospf_router_lsa_dump (struct stream
*s
, u_int16_t length
)
297 struct router_lsa
*rl
;
300 rl
= (struct router_lsa
*) STREAM_PNT (s
);
302 zlog_debug (" Router-LSA");
303 zlog_debug (" flags %s",
304 ospf_router_lsa_flags_dump (rl
->flags
, buf
, BUFSIZ
));
305 zlog_debug (" # links %d", ntohs (rl
->links
));
307 len
= ntohs (rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
308 for (i
= 0; len
> 0; i
++)
310 zlog_debug (" Link ID %s", inet_ntoa (rl
->link
[i
].link_id
));
311 zlog_debug (" Link Data %s", inet_ntoa (rl
->link
[i
].link_data
));
312 zlog_debug (" Type %d", (u_char
) rl
->link
[i
].type
);
313 zlog_debug (" TOS %d", (u_char
) rl
->link
[i
].tos
);
314 zlog_debug (" metric %d", ntohs (rl
->link
[i
].metric
));
321 ospf_network_lsa_dump (struct stream
*s
, u_int16_t length
)
323 struct network_lsa
*nl
;
326 nl
= (struct network_lsa
*) STREAM_PNT (s
);
327 cnt
= (ntohs (nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
329 zlog_debug (" Network-LSA");
331 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
332 zlog_debug ("Network-LSA size %d",
333 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
335 zlog_debug (" Network Mask %s", inet_ntoa (nl
->mask
));
336 zlog_debug (" # Attached Routers %d", cnt
);
337 for (i
= 0; i
< cnt
; i
++)
338 zlog_debug (" Attached Router %s", inet_ntoa (nl
->routers
[i
]));
342 ospf_summary_lsa_dump (struct stream
*s
, u_int16_t length
)
344 struct summary_lsa
*sl
;
348 sl
= (struct summary_lsa
*) STREAM_PNT (s
);
350 zlog_debug (" Summary-LSA");
351 zlog_debug (" Network Mask %s", inet_ntoa (sl
->mask
));
353 size
= ntohs (sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
354 for (i
= 0; size
> 0; size
-= 4, i
++)
355 zlog_debug (" TOS=%d metric %d", sl
->tos
,
356 GET_METRIC (sl
->metric
));
360 ospf_as_external_lsa_dump (struct stream
*s
, u_int16_t length
)
362 struct as_external_lsa
*al
;
366 al
= (struct as_external_lsa
*) STREAM_PNT (s
);
367 zlog_debug (" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
368 zlog_debug (" Network Mask %s", inet_ntoa (al
->mask
));
370 size
= ntohs (al
->header
.length
) - OSPF_LSA_HEADER_SIZE
-4;
371 for (i
= 0; size
> 0; size
-= 12, i
++)
373 zlog_debug (" bit %s TOS=%d metric %d",
374 IS_EXTERNAL_METRIC (al
->e
[i
].tos
) ? "E" : "-",
375 al
->e
[i
].tos
& 0x7f, GET_METRIC (al
->e
[i
].metric
));
376 zlog_debug (" Forwarding address %s", inet_ntoa (al
->e
[i
].fwd_addr
));
377 zlog_debug (" External Route Tag %"ROUTE_TAG_PRI
, al
->e
[i
].route_tag
);
382 ospf_lsa_header_list_dump (struct stream
*s
, u_int16_t length
)
384 struct lsa_header
*lsa
;
386 zlog_debug (" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
391 lsa
= (struct lsa_header
*) STREAM_PNT (s
);
392 ospf_lsa_header_dump (lsa
);
394 stream_forward_getp (s
, OSPF_LSA_HEADER_SIZE
);
395 length
-= OSPF_LSA_HEADER_SIZE
;
400 ospf_packet_db_desc_dump (struct stream
*s
, u_int16_t length
)
402 struct ospf_db_desc
*dd
;
407 gp
= stream_get_getp (s
);
408 dd
= (struct ospf_db_desc
*) STREAM_PNT (s
);
410 zlog_debug ("Database Description");
411 zlog_debug (" Interface MTU %d", ntohs (dd
->mtu
));
412 zlog_debug (" Options %d (%s)", dd
->options
,
413 ospf_options_dump (dd
->options
));
414 zlog_debug (" Flags %d (%s)", dd
->flags
,
415 ospf_dd_flags_dump (dd
->flags
, dd_flags
, sizeof dd_flags
));
416 zlog_debug (" Sequence Number 0x%08lx", (u_long
)ntohl (dd
->dd_seqnum
));
418 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
420 stream_forward_getp (s
, OSPF_DB_DESC_MIN_SIZE
);
422 ospf_lsa_header_list_dump (s
, length
);
424 stream_set_getp (s
, gp
);
428 ospf_packet_ls_req_dump (struct stream
*s
, u_int16_t length
)
432 struct in_addr ls_id
;
433 struct in_addr adv_router
;
435 sp
= stream_get_getp (s
);
437 length
-= OSPF_HEADER_SIZE
;
439 zlog_debug ("Link State Request");
440 zlog_debug (" # Requests %d", length
/ 12);
442 for (; length
> 0; length
-= 12)
444 ls_type
= stream_getl (s
);
445 ls_id
.s_addr
= stream_get_ipv4 (s
);
446 adv_router
.s_addr
= stream_get_ipv4 (s
);
448 zlog_debug (" LS type %d", ls_type
);
449 zlog_debug (" Link State ID %s", inet_ntoa (ls_id
));
450 zlog_debug (" Advertising Router %s",
451 inet_ntoa (adv_router
));
454 stream_set_getp (s
, sp
);
458 ospf_packet_ls_upd_dump (struct stream
*s
, u_int16_t length
)
461 struct lsa_header
*lsa
;
465 length
-= OSPF_HEADER_SIZE
;
467 sp
= stream_get_getp (s
);
469 count
= stream_getl (s
);
472 zlog_debug ("Link State Update");
473 zlog_debug (" # LSAs %d", count
);
475 while (length
> 0 && count
> 0)
477 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0)
479 zlog_debug (" Remaining %d bytes; Incorrect length.", length
);
483 lsa
= (struct lsa_header
*) STREAM_PNT (s
);
484 lsa_len
= ntohs (lsa
->length
);
485 ospf_lsa_header_dump (lsa
);
489 case OSPF_ROUTER_LSA
:
490 ospf_router_lsa_dump (s
, length
);
492 case OSPF_NETWORK_LSA
:
493 ospf_network_lsa_dump (s
, length
);
495 case OSPF_SUMMARY_LSA
:
496 case OSPF_ASBR_SUMMARY_LSA
:
497 ospf_summary_lsa_dump (s
, length
);
499 case OSPF_AS_EXTERNAL_LSA
:
500 ospf_as_external_lsa_dump (s
, length
);
502 case OSPF_AS_NSSA_LSA
:
503 ospf_as_external_lsa_dump (s
, length
);
505 case OSPF_OPAQUE_LINK_LSA
:
506 case OSPF_OPAQUE_AREA_LSA
:
507 case OSPF_OPAQUE_AS_LSA
:
508 ospf_opaque_lsa_dump (s
, length
);
514 stream_forward_getp (s
, lsa_len
);
519 stream_set_getp (s
, sp
);
523 ospf_packet_ls_ack_dump (struct stream
*s
, u_int16_t length
)
527 length
-= OSPF_HEADER_SIZE
;
528 sp
= stream_get_getp (s
);
530 zlog_debug ("Link State Acknowledgment");
531 ospf_lsa_header_list_dump (s
, length
);
533 stream_set_getp (s
, sp
);
536 /* Expects header to be in host order */
538 ospf_ip_header_dump (struct ip
*iph
)
540 /* IP Header dump. */
541 zlog_debug ("ip_v %d", iph
->ip_v
);
542 zlog_debug ("ip_hl %d", iph
->ip_hl
);
543 zlog_debug ("ip_tos %d", iph
->ip_tos
);
544 zlog_debug ("ip_len %d", iph
->ip_len
);
545 zlog_debug ("ip_id %u", (u_int32_t
) iph
->ip_id
);
546 zlog_debug ("ip_off %u", (u_int32_t
) iph
->ip_off
);
547 zlog_debug ("ip_ttl %d", iph
->ip_ttl
);
548 zlog_debug ("ip_p %d", iph
->ip_p
);
549 zlog_debug ("ip_sum 0x%x", (u_int32_t
) iph
->ip_sum
);
550 zlog_debug ("ip_src %s", inet_ntoa (iph
->ip_src
));
551 zlog_debug ("ip_dst %s", inet_ntoa (iph
->ip_dst
));
555 ospf_header_dump (struct ospf_header
*ospfh
)
558 u_int16_t auth_type
= ntohs (ospfh
->auth_type
);
560 zlog_debug ("Header");
561 zlog_debug (" Version %d", ospfh
->version
);
562 zlog_debug (" Type %d (%s)", ospfh
->type
,
563 LOOKUP (ospf_packet_type_str
, ospfh
->type
));
564 zlog_debug (" Packet Len %d", ntohs (ospfh
->length
));
565 zlog_debug (" Router ID %s", inet_ntoa (ospfh
->router_id
));
566 zlog_debug (" Area ID %s", inet_ntoa (ospfh
->area_id
));
567 zlog_debug (" Checksum 0x%x", ntohs (ospfh
->checksum
));
568 zlog_debug (" AuType %s", LOOKUP (ospf_auth_type_str
, auth_type
));
574 case OSPF_AUTH_SIMPLE
:
576 strncpy (buf
, (char *) ospfh
->u
.auth_data
, 8);
577 zlog_debug (" Simple Password %s", buf
);
579 case OSPF_AUTH_CRYPTOGRAPHIC
:
580 zlog_debug (" Cryptographic Authentication");
581 zlog_debug (" Key ID %d", ospfh
->u
.crypt
.key_id
);
582 zlog_debug (" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
583 zlog_debug (" Sequence number %ld",
584 (u_long
)ntohl (ospfh
->u
.crypt
.crypt_seqnum
));
587 zlog_debug ("* This is not supported authentication type");
594 ospf_packet_dump (struct stream
*s
)
596 struct ospf_header
*ospfh
;
599 /* Preserve pointer. */
600 gp
= stream_get_getp (s
);
602 /* OSPF Header dump. */
603 ospfh
= (struct ospf_header
*) STREAM_PNT (s
);
605 /* Until detail flag is set, return. */
606 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
609 /* Show OSPF header detail. */
610 ospf_header_dump (ospfh
);
611 stream_forward_getp (s
, OSPF_HEADER_SIZE
);
616 ospf_packet_hello_dump (s
, ntohs (ospfh
->length
));
618 case OSPF_MSG_DB_DESC
:
619 ospf_packet_db_desc_dump (s
, ntohs (ospfh
->length
));
621 case OSPF_MSG_LS_REQ
:
622 ospf_packet_ls_req_dump (s
, ntohs (ospfh
->length
));
624 case OSPF_MSG_LS_UPD
:
625 ospf_packet_ls_upd_dump (s
, ntohs (ospfh
->length
));
627 case OSPF_MSG_LS_ACK
:
628 ospf_packet_ls_ack_dump (s
, ntohs (ospfh
->length
));
634 stream_set_getp (s
, gp
);
637 DEFUN (debug_ospf_packet
,
638 debug_ospf_packet_cmd
,
639 "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
645 "OSPF Database Description\n"
646 "OSPF Link State Request\n"
647 "OSPF Link State Update\n"
648 "OSPF Link State Acknowledgment\n"
651 "Detail Information\n"
653 "Detail Information\n"
654 "Detail Information\n")
656 int inst
= (argv
[2]->type
== RANGE_TKN
) ? 1 : 0;
657 int detail
= strmatch (argv
[argc
- 1]->text
, "detail");
658 int send
= strmatch (argv
[argc
- (1+detail
)]->text
, "send");
659 int recv
= strmatch (argv
[argc
- (1+detail
)]->text
, "recv");
660 char *packet
= argv
[3 + inst
]->text
;
662 if (inst
) // user passed instance ID
664 if (!ospf_lookup_instance (strtoul (argv
[2]->arg
, NULL
, 10)))
672 /* Check packet type. */
673 if (strmatch (packet
, "hello"))
674 type
= OSPF_DEBUG_HELLO
;
675 else if (strmatch (packet
, "dd"))
676 type
= OSPF_DEBUG_DB_DESC
;
677 else if (strmatch (packet
, "ls-request"))
678 type
= OSPF_DEBUG_LS_REQ
;
679 else if (strmatch (packet
, "ls-update"))
680 type
= OSPF_DEBUG_LS_UPD
;
681 else if (strmatch (packet
, "ls-ack"))
682 type
= OSPF_DEBUG_LS_ACK
;
683 else if (strmatch (packet
, "all"))
684 type
= OSPF_DEBUG_ALL
;
687 * (none) = send + recv
688 * detail = send + recv + detail
691 * recv detail = recv + detail
692 * send detail = send + detail
697 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
698 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
699 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
701 for (i
= 0; i
< 5; i
++)
702 if (type
& (0x01 << i
))
704 if (vty
->node
== CONFIG_NODE
)
705 DEBUG_PACKET_ON (i
, flag
);
707 TERM_DEBUG_PACKET_ON (i
, flag
);
713 DEFUN (no_debug_ospf_packet
,
714 no_debug_ospf_packet_cmd
,
715 "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
722 "OSPF Database Description\n"
723 "OSPF Link State Request\n"
724 "OSPF Link State Update\n"
725 "OSPF Link State Acknowledgment\n"
728 "Detail Information\n"
730 "Detail Information\n"
731 "Detail Information\n")
733 int inst
= (argv
[3]->type
== RANGE_TKN
) ? 1 : 0;
734 int detail
= strmatch (argv
[argc
- 1]->text
, "detail");
735 int send
= strmatch (argv
[argc
- (1+detail
)]->text
, "send");
736 int recv
= strmatch (argv
[argc
- (1+detail
)]->text
, "recv");
737 char *packet
= argv
[4 + inst
]->text
;
739 if (inst
) // user passed instance ID
741 if (!ospf_lookup_instance (strtoul (argv
[3]->arg
, NULL
, 10)))
749 /* Check packet type. */
750 if (strmatch (packet
, "hello"))
751 type
= OSPF_DEBUG_HELLO
;
752 else if (strmatch (packet
, "dd"))
753 type
= OSPF_DEBUG_DB_DESC
;
754 else if (strmatch (packet
, "ls-request"))
755 type
= OSPF_DEBUG_LS_REQ
;
756 else if (strmatch (packet
, "ls-update"))
757 type
= OSPF_DEBUG_LS_UPD
;
758 else if (strmatch (packet
, "ls-ack"))
759 type
= OSPF_DEBUG_LS_ACK
;
760 else if (strmatch (packet
, "all"))
761 type
= OSPF_DEBUG_ALL
;
764 * (none) = send + recv
765 * detail = send + recv + detail
768 * recv detail = recv + detail
769 * send detail = send + detail
774 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
775 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
776 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
778 for (i
= 0; i
< 5; i
++)
779 if (type
& (0x01 << i
))
781 if (vty
->node
== CONFIG_NODE
)
782 DEBUG_PACKET_OFF (i
, flag
);
784 TERM_DEBUG_PACKET_OFF (i
, flag
);
789 for (i = 0; i < 5; i++)
790 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
797 DEFUN (debug_ospf_ism
,
799 "debug ospf [(1-65535)] ism [<status|events|timers>]",
803 "OSPF Interface State Machine\n"
804 "ISM Status Information\n"
805 "ISM Event Information\n"
806 "ISM TImer Information\n")
808 int inst
= (argv
[2]->type
== RANGE_TKN
);
809 char *dbgparam
= (argc
== 4 + inst
) ? argv
[argc
- 1]->text
: NULL
;
811 if (inst
) // user passed instance ID
813 if (!ospf_lookup_instance (strtoul (argv
[2]->arg
, NULL
, 10)))
817 if (vty
->node
== CONFIG_NODE
)
823 if (strmatch (dbgparam
, "status"))
824 DEBUG_ON (ism
, ISM_STATUS
);
825 else if (strmatch (dbgparam
, "events"))
826 DEBUG_ON (ism
, ISM_EVENTS
);
827 else if (strmatch (dbgparam
, "timers"))
828 DEBUG_ON (ism
, ISM_TIMERS
);
836 TERM_DEBUG_ON (ism
, ISM
);
839 if (strmatch (dbgparam
, "status"))
840 TERM_DEBUG_ON (ism
, ISM_STATUS
);
841 else if (strmatch (dbgparam
, "events"))
842 TERM_DEBUG_ON (ism
, ISM_EVENTS
);
843 else if (strmatch (dbgparam
, "timers"))
844 TERM_DEBUG_ON (ism
, ISM_TIMERS
);
850 DEFUN (no_debug_ospf_ism
,
851 no_debug_ospf_ism_cmd
,
852 "no debug ospf [(1-65535)] ism [<status|events|timers>]",
857 "OSPF Interface State Machine\n"
858 "ISM Status Information\n"
859 "ISM Event Information\n"
860 "ISM TImer Information\n")
862 int inst
= (argv
[3]->type
== RANGE_TKN
);
863 char *dbgparam
= (argc
== 5 + inst
) ? argv
[argc
- 1]->text
: NULL
;
865 if (inst
) // user passed instance ID
867 if (!ospf_lookup_instance (strtoul (argv
[3]->arg
, NULL
, 10)))
871 if (vty
->node
== CONFIG_NODE
)
874 DEBUG_OFF (ism
, ISM
);
877 if (strmatch (dbgparam
, "status"))
878 DEBUG_OFF (ism
, ISM_STATUS
);
879 else if (strmatch (dbgparam
, "events"))
880 DEBUG_OFF (ism
, ISM_EVENTS
);
881 else if (strmatch (dbgparam
, "timers"))
882 DEBUG_OFF (ism
, ISM_TIMERS
);
890 TERM_DEBUG_OFF (ism
, ISM
);
893 if (strmatch (dbgparam
, "status"))
894 TERM_DEBUG_OFF (ism
, ISM_STATUS
);
895 else if (strmatch (dbgparam
, "events"))
896 TERM_DEBUG_OFF (ism
, ISM_EVENTS
);
897 else if (strmatch (dbgparam
, "timers"))
898 TERM_DEBUG_OFF (ism
, ISM_TIMERS
);
905 debug_ospf_nsm_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
907 if (vty
->node
== CONFIG_NODE
)
909 if (argc
== arg_base
+ 0)
911 else if (argc
== arg_base
+ 1)
913 if (strmatch(argv
[arg_base
]->text
, "status"))
914 DEBUG_ON (nsm
, NSM_STATUS
);
915 else if (strmatch(argv
[arg_base
]->text
, "events"))
916 DEBUG_ON (nsm
, NSM_EVENTS
);
917 else if (strmatch(argv
[arg_base
]->text
, "timers"))
918 DEBUG_ON (nsm
, NSM_TIMERS
);
925 if (argc
== arg_base
+ 0)
926 TERM_DEBUG_ON (nsm
, NSM
);
927 else if (argc
== arg_base
+ 1)
929 if (strmatch(argv
[arg_base
]->text
, "status"))
930 TERM_DEBUG_ON (nsm
, NSM_STATUS
);
931 else if (strmatch(argv
[arg_base
]->text
, "events"))
932 TERM_DEBUG_ON (nsm
, NSM_EVENTS
);
933 else if (strmatch(argv
[arg_base
]->text
, "timers"))
934 TERM_DEBUG_ON (nsm
, NSM_TIMERS
);
940 DEFUN (debug_ospf_nsm
,
942 "debug ospf nsm [<status|events|timers>]",
945 "OSPF Neighbor State Machine\n"
946 "NSM Status Information\n"
947 "NSM Event Information\n"
948 "NSM Timer Information\n")
950 return debug_ospf_nsm_common (vty
, 3, argc
, argv
);
953 DEFUN (debug_ospf_instance_nsm
,
954 debug_ospf_instance_nsm_cmd
,
955 "debug ospf (1-65535) nsm [<status|events|timers>]",
959 "OSPF Neighbor State Machine\n"
960 "NSM Status Information\n"
961 "NSM Event Information\n"
962 "NSM Timer Information\n")
965 u_short instance
= 0;
967 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
968 if (!ospf_lookup_instance (instance
))
971 return debug_ospf_nsm_common (vty
, 4, argc
, argv
);
976 no_debug_ospf_nsm_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
979 if (vty
->node
== CONFIG_NODE
)
981 if (argc
== arg_base
+ 0)
982 DEBUG_OFF (nsm
, NSM
);
983 else if (argc
== arg_base
+ 1)
985 if (strmatch(argv
[arg_base
]->text
, "status"))
986 DEBUG_OFF (nsm
, NSM_STATUS
);
987 else if (strmatch(argv
[arg_base
]->text
, "events"))
988 DEBUG_OFF (nsm
, NSM_EVENTS
);
989 else if (strmatch(argv
[arg_base
]->text
, "timers"))
990 DEBUG_OFF (nsm
, NSM_TIMERS
);
997 if (argc
== arg_base
+ 0)
998 TERM_DEBUG_OFF (nsm
, NSM
);
999 else if (argc
== arg_base
+ 1)
1001 if (strmatch(argv
[arg_base
]->text
, "status"))
1002 TERM_DEBUG_OFF (nsm
, NSM_STATUS
);
1003 else if (strmatch(argv
[arg_base
]->text
, "events"))
1004 TERM_DEBUG_OFF (nsm
, NSM_EVENTS
);
1005 else if (strmatch(argv
[arg_base
]->text
, "timers"))
1006 TERM_DEBUG_OFF (nsm
, NSM_TIMERS
);
1012 DEFUN (no_debug_ospf_nsm
,
1013 no_debug_ospf_nsm_cmd
,
1014 "no debug ospf nsm [<status|events|timers>]",
1018 "OSPF Neighbor State Machine\n"
1019 "NSM Status Information\n"
1020 "NSM Event Information\n"
1021 "NSM Timer Information\n")
1023 return no_debug_ospf_nsm_common(vty
, 4, argc
, argv
);
1027 DEFUN (no_debug_ospf_instance_nsm
,
1028 no_debug_ospf_instance_nsm_cmd
,
1029 "no debug ospf (1-65535) nsm [<status|events|timers>]",
1034 "OSPF Neighbor State Machine\n"
1035 "NSM Status Information\n"
1036 "NSM Event Information\n"
1037 "NSM Timer Information\n")
1040 u_short instance
= 0;
1042 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1043 if (!ospf_lookup_instance (instance
))
1046 return no_debug_ospf_nsm_common(vty
, 5, argc
, argv
);
1051 debug_ospf_lsa_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1053 if (vty
->node
== CONFIG_NODE
)
1055 if (argc
== arg_base
+ 0)
1056 DEBUG_ON (lsa
, LSA
);
1057 else if (argc
== arg_base
+ 1)
1059 if (strmatch(argv
[arg_base
]->text
, "generate"))
1060 DEBUG_ON (lsa
, LSA_GENERATE
);
1061 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1062 DEBUG_ON (lsa
, LSA_FLOODING
);
1063 else if (strmatch(argv
[arg_base
]->text
, "install"))
1064 DEBUG_ON (lsa
, LSA_INSTALL
);
1065 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1066 DEBUG_ON (lsa
, LSA_REFRESH
);
1073 if (argc
== arg_base
+ 0)
1074 TERM_DEBUG_ON (lsa
, LSA
);
1075 else if (argc
== arg_base
+ 1)
1077 if (strmatch(argv
[arg_base
]->text
, "generate"))
1078 TERM_DEBUG_ON (lsa
, LSA_GENERATE
);
1079 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1080 TERM_DEBUG_ON (lsa
, LSA_FLOODING
);
1081 else if (strmatch(argv
[arg_base
]->text
, "install"))
1082 TERM_DEBUG_ON (lsa
, LSA_INSTALL
);
1083 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1084 TERM_DEBUG_ON (lsa
, LSA_REFRESH
);
1090 DEFUN (debug_ospf_lsa
,
1092 "debug ospf lsa [<generate|flooding|install|refresh>]",
1095 "OSPF Link State Advertisement\n"
1098 "LSA Install/Delete\n"
1101 return debug_ospf_lsa_common(vty
, 3, argc
, argv
);
1104 DEFUN (debug_ospf_instance_lsa
,
1105 debug_ospf_instance_lsa_cmd
,
1106 "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1110 "OSPF Link State Advertisement\n"
1113 "LSA Install/Delete\n"
1117 u_short instance
= 0;
1119 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1120 if (!ospf_lookup_instance (instance
))
1123 return debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1128 no_debug_ospf_lsa_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1130 if (vty
->node
== CONFIG_NODE
)
1132 if (argc
== arg_base
+ 0)
1133 DEBUG_OFF (lsa
, LSA
);
1134 else if (argc
== arg_base
+ 1)
1136 if (strmatch(argv
[arg_base
]->text
, "generate"))
1137 DEBUG_OFF (lsa
, LSA_GENERATE
);
1138 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1139 DEBUG_OFF (lsa
, LSA_FLOODING
);
1140 else if (strmatch(argv
[arg_base
]->text
, "install"))
1141 DEBUG_OFF (lsa
, LSA_INSTALL
);
1142 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1143 DEBUG_OFF (lsa
, LSA_REFRESH
);
1150 if (argc
== arg_base
+ 0)
1151 TERM_DEBUG_OFF (lsa
, LSA
);
1152 else if (argc
== arg_base
+ 1)
1154 if (strmatch(argv
[arg_base
]->text
, "generate"))
1155 TERM_DEBUG_OFF (lsa
, LSA_GENERATE
);
1156 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1157 TERM_DEBUG_OFF (lsa
, LSA_FLOODING
);
1158 else if (strmatch(argv
[arg_base
]->text
, "install"))
1159 TERM_DEBUG_OFF (lsa
, LSA_INSTALL
);
1160 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1161 TERM_DEBUG_OFF (lsa
, LSA_REFRESH
);
1167 DEFUN (no_debug_ospf_lsa
,
1168 no_debug_ospf_lsa_cmd
,
1169 "no debug ospf lsa [<generate|flooding|install|refresh>]",
1173 "OSPF Link State Advertisement\n"
1176 "LSA Install/Delete\n"
1179 return no_debug_ospf_lsa_common (vty
, 4, argc
, argv
);
1182 DEFUN (no_debug_ospf_instance_lsa
,
1183 no_debug_ospf_instance_lsa_cmd
,
1184 "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1189 "OSPF Link State Advertisement\n"
1192 "LSA Install/Delete\n"
1196 u_short instance
= 0;
1198 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1199 if (!ospf_lookup_instance (instance
))
1202 return no_debug_ospf_lsa_common (vty
, 5, argc
, argv
);
1207 debug_ospf_zebra_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1209 if (vty
->node
== CONFIG_NODE
)
1211 if (argc
== arg_base
+ 0)
1212 DEBUG_ON (zebra
, ZEBRA
);
1213 else if (argc
== arg_base
+ 1)
1215 if (strmatch(argv
[arg_base
]->text
, "interface"))
1216 DEBUG_ON (zebra
, ZEBRA_INTERFACE
);
1217 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1218 DEBUG_ON (zebra
, ZEBRA_REDISTRIBUTE
);
1225 if (argc
== arg_base
+ 0)
1226 TERM_DEBUG_ON (zebra
, ZEBRA
);
1227 else if (argc
== arg_base
+ 1)
1229 if (strmatch(argv
[arg_base
]->text
, "interface"))
1230 TERM_DEBUG_ON (zebra
, ZEBRA_INTERFACE
);
1231 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1232 TERM_DEBUG_ON (zebra
, ZEBRA_REDISTRIBUTE
);
1238 DEFUN (debug_ospf_zebra
,
1239 debug_ospf_zebra_cmd
,
1240 "debug ospf zebra [<interface|redistribute>]",
1243 "OSPF Zebra information\n"
1245 "Zebra redistribute\n")
1247 return debug_ospf_zebra_common(vty
, 3, argc
, argv
);
1250 DEFUN (debug_ospf_instance_zebra
,
1251 debug_ospf_instance_zebra_cmd
,
1252 "debug ospf (1-65535) zebra [<interface|redistribute>]",
1256 "OSPF Zebra information\n"
1258 "Zebra redistribute\n")
1261 u_short instance
= 0;
1263 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1264 if (!ospf_lookup_instance (instance
))
1267 return debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1272 no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1273 struct cmd_token
**argv
)
1275 if (vty
->node
== CONFIG_NODE
)
1277 if (argc
== arg_base
+ 0)
1278 DEBUG_OFF (zebra
, ZEBRA
);
1279 else if (argc
== arg_base
+ 1)
1281 if (strmatch(argv
[arg_base
]->text
, "interface"))
1282 DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1283 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1284 DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1291 if (argc
== arg_base
+ 0)
1292 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1293 else if (argc
== arg_base
+ 1)
1295 if (strmatch(argv
[arg_base
]->text
, "interface"))
1296 TERM_DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1297 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1298 TERM_DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1304 DEFUN (no_debug_ospf_zebra
,
1305 no_debug_ospf_zebra_cmd
,
1306 "no debug ospf zebra [<interface|redistribute>]",
1310 "OSPF Zebra information\n"
1312 "Zebra redistribute\n")
1314 return no_debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1317 DEFUN (no_debug_ospf_instance_zebra
,
1318 no_debug_ospf_instance_zebra_cmd
,
1319 "no debug ospf (1-65535) zebra [<interface|redistribute>]",
1324 "OSPF Zebra information\n"
1326 "Zebra redistribute\n")
1329 u_short instance
= 0;
1331 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1332 if (!ospf_lookup_instance (instance
))
1335 return no_debug_ospf_zebra_common(vty
, 5, argc
, argv
);
1340 DEFUN (debug_ospf_event
,
1341 debug_ospf_event_cmd
,
1345 "OSPF event information\n")
1347 if (vty
->node
== CONFIG_NODE
)
1348 CONF_DEBUG_ON (event
, EVENT
);
1349 TERM_DEBUG_ON (event
, EVENT
);
1353 DEFUN (no_debug_ospf_event
,
1354 no_debug_ospf_event_cmd
,
1355 "no debug ospf event",
1359 "OSPF event information\n")
1361 if (vty
->node
== CONFIG_NODE
)
1362 CONF_DEBUG_OFF (event
, EVENT
);
1363 TERM_DEBUG_OFF (event
, EVENT
);
1367 DEFUN (debug_ospf_instance_event
,
1368 debug_ospf_instance_event_cmd
,
1369 "debug ospf (1-65535) event",
1373 "OSPF event information\n")
1376 u_short instance
= 0;
1378 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1379 if (!ospf_lookup_instance (instance
))
1382 if (vty
->node
== CONFIG_NODE
)
1383 CONF_DEBUG_ON (event
, EVENT
);
1384 TERM_DEBUG_ON (event
, EVENT
);
1388 DEFUN (no_debug_ospf_instance_event
,
1389 no_debug_ospf_instance_event_cmd
,
1390 "no debug ospf (1-65535) event",
1395 "OSPF event information\n")
1398 u_short instance
= 0;
1400 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1401 if (!ospf_lookup_instance (instance
))
1404 if (vty
->node
== CONFIG_NODE
)
1405 CONF_DEBUG_OFF (event
, EVENT
);
1406 TERM_DEBUG_OFF (event
, EVENT
);
1410 DEFUN (debug_ospf_nssa
,
1411 debug_ospf_nssa_cmd
,
1415 "OSPF nssa information\n")
1417 if (vty
->node
== CONFIG_NODE
)
1418 CONF_DEBUG_ON (nssa
, NSSA
);
1419 TERM_DEBUG_ON (nssa
, NSSA
);
1423 DEFUN (no_debug_ospf_nssa
,
1424 no_debug_ospf_nssa_cmd
,
1425 "no debug ospf nssa",
1429 "OSPF nssa information\n")
1431 if (vty
->node
== CONFIG_NODE
)
1432 CONF_DEBUG_OFF (nssa
, NSSA
);
1433 TERM_DEBUG_OFF (nssa
, NSSA
);
1437 DEFUN (debug_ospf_instance_nssa
,
1438 debug_ospf_instance_nssa_cmd
,
1439 "debug ospf (1-65535) nssa",
1443 "OSPF nssa information\n")
1446 u_short instance
= 0;
1448 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1449 if (!ospf_lookup_instance (instance
))
1452 if (vty
->node
== CONFIG_NODE
)
1453 CONF_DEBUG_ON (nssa
, NSSA
);
1454 TERM_DEBUG_ON (nssa
, NSSA
);
1458 DEFUN (no_debug_ospf_instance_nssa
,
1459 no_debug_ospf_instance_nssa_cmd
,
1460 "no debug ospf (1-65535) nssa",
1465 "OSPF nssa information\n")
1468 u_short instance
= 0;
1470 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1471 if (!ospf_lookup_instance (instance
))
1474 if (vty
->node
== CONFIG_NODE
)
1475 CONF_DEBUG_OFF (nssa
, NSSA
);
1476 TERM_DEBUG_OFF (nssa
, NSSA
);
1480 DEFUN (debug_ospf_te
,
1485 "OSPF-TE information\n")
1487 if (vty
->node
== CONFIG_NODE
)
1488 CONF_DEBUG_ON (te
, TE
);
1489 TERM_DEBUG_ON (te
, TE
);
1493 DEFUN (no_debug_ospf_te
,
1494 no_debug_ospf_te_cmd
,
1499 "OSPF-TE information\n")
1501 if (vty
->node
== CONFIG_NODE
)
1502 CONF_DEBUG_OFF (te
, TE
);
1503 TERM_DEBUG_OFF (te
, TE
);
1507 DEFUN (no_debug_ospf
,
1514 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1517 if (vty
->node
== CONFIG_NODE
)
1519 CONF_DEBUG_OFF (event
, EVENT
);
1520 CONF_DEBUG_OFF (nssa
, NSSA
);
1521 DEBUG_OFF (ism
, ISM_EVENTS
);
1522 DEBUG_OFF (ism
, ISM_STATUS
);
1523 DEBUG_OFF (ism
, ISM_TIMERS
);
1524 DEBUG_OFF (lsa
, LSA
);
1525 DEBUG_OFF (lsa
, LSA_FLOODING
);
1526 DEBUG_OFF (lsa
, LSA_GENERATE
);
1527 DEBUG_OFF (lsa
, LSA_INSTALL
);
1528 DEBUG_OFF (lsa
, LSA_REFRESH
);
1529 DEBUG_OFF (nsm
, NSM
);
1530 DEBUG_OFF (nsm
, NSM_EVENTS
);
1531 DEBUG_OFF (nsm
, NSM_STATUS
);
1532 DEBUG_OFF (nsm
, NSM_TIMERS
);
1533 DEBUG_OFF (zebra
, ZEBRA
);
1534 DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1535 DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1537 for (i
= 0; i
< 5; i
++)
1538 DEBUG_PACKET_OFF (i
, flag
);
1541 for (i
= 0; i
< 5; i
++)
1542 TERM_DEBUG_PACKET_OFF (i
, flag
);
1544 TERM_DEBUG_OFF (event
, EVENT
);
1545 TERM_DEBUG_OFF (ism
, ISM
);
1546 TERM_DEBUG_OFF (ism
, ISM_EVENTS
);
1547 TERM_DEBUG_OFF (ism
, ISM_STATUS
);
1548 TERM_DEBUG_OFF (ism
, ISM_TIMERS
);
1549 TERM_DEBUG_OFF (lsa
, LSA
);
1550 TERM_DEBUG_OFF (lsa
, LSA_FLOODING
);
1551 TERM_DEBUG_OFF (lsa
, LSA_GENERATE
);
1552 TERM_DEBUG_OFF (lsa
, LSA_INSTALL
);
1553 TERM_DEBUG_OFF (lsa
, LSA_REFRESH
);
1554 TERM_DEBUG_OFF (nsm
, NSM
);
1555 TERM_DEBUG_OFF (nsm
, NSM_EVENTS
);
1556 TERM_DEBUG_OFF (nsm
, NSM_STATUS
);
1557 TERM_DEBUG_OFF (nsm
, NSM_TIMERS
);
1558 TERM_DEBUG_OFF (nssa
, NSSA
);
1559 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1560 TERM_DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1561 TERM_DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1567 show_debugging_ospf_common (struct vty
*vty
, struct ospf
*ospf
)
1572 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
1573 VTY_NEWLINE
, VTY_NEWLINE
);
1575 vty_out (vty
, "OSPF debugging status:%s", VTY_NEWLINE
);
1577 /* Show debug status for events. */
1578 if (IS_DEBUG_OSPF(event
,EVENT
))
1579 vty_out (vty
, " OSPF event debugging is on%s", VTY_NEWLINE
);
1581 /* Show debug status for ISM. */
1582 if (IS_DEBUG_OSPF (ism
, ISM
) == OSPF_DEBUG_ISM
)
1583 vty_out (vty
, " OSPF ISM debugging is on%s", VTY_NEWLINE
);
1586 if (IS_DEBUG_OSPF (ism
, ISM_STATUS
))
1587 vty_out (vty
, " OSPF ISM status debugging is on%s", VTY_NEWLINE
);
1588 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
1589 vty_out (vty
, " OSPF ISM event debugging is on%s", VTY_NEWLINE
);
1590 if (IS_DEBUG_OSPF (ism
, ISM_TIMERS
))
1591 vty_out (vty
, " OSPF ISM timer debugging is on%s", VTY_NEWLINE
);
1594 /* Show debug status for NSM. */
1595 if (IS_DEBUG_OSPF (nsm
, NSM
) == OSPF_DEBUG_NSM
)
1596 vty_out (vty
, " OSPF NSM debugging is on%s", VTY_NEWLINE
);
1599 if (IS_DEBUG_OSPF (nsm
, NSM_STATUS
))
1600 vty_out (vty
, " OSPF NSM status debugging is on%s", VTY_NEWLINE
);
1601 if (IS_DEBUG_OSPF (nsm
, NSM_EVENTS
))
1602 vty_out (vty
, " OSPF NSM event debugging is on%s", VTY_NEWLINE
);
1603 if (IS_DEBUG_OSPF (nsm
, NSM_TIMERS
))
1604 vty_out (vty
, " OSPF NSM timer debugging is on%s", VTY_NEWLINE
);
1607 /* Show debug status for OSPF Packets. */
1608 for (i
= 0; i
< 5; i
++)
1609 if (IS_DEBUG_OSPF_PACKET (i
, SEND
) && IS_DEBUG_OSPF_PACKET (i
, RECV
))
1611 vty_out (vty
, " OSPF packet %s%s debugging is on%s",
1612 LOOKUP (ospf_packet_type_str
, i
+ 1),
1613 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
1618 if (IS_DEBUG_OSPF_PACKET (i
, SEND
))
1619 vty_out (vty
, " OSPF packet %s send%s debugging is on%s",
1620 LOOKUP (ospf_packet_type_str
, i
+ 1),
1621 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
1623 if (IS_DEBUG_OSPF_PACKET (i
, RECV
))
1624 vty_out (vty
, " OSPF packet %s receive%s debugging is on%s",
1625 LOOKUP (ospf_packet_type_str
, i
+ 1),
1626 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
1630 /* Show debug status for OSPF LSAs. */
1631 if (IS_DEBUG_OSPF (lsa
, LSA
) == OSPF_DEBUG_LSA
)
1632 vty_out (vty
, " OSPF LSA debugging is on%s", VTY_NEWLINE
);
1635 if (IS_DEBUG_OSPF (lsa
, LSA_GENERATE
))
1636 vty_out (vty
, " OSPF LSA generation debugging is on%s", VTY_NEWLINE
);
1637 if (IS_DEBUG_OSPF (lsa
, LSA_FLOODING
))
1638 vty_out (vty
, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE
);
1639 if (IS_DEBUG_OSPF (lsa
, LSA_INSTALL
))
1640 vty_out (vty
, " OSPF LSA install debugging is on%s", VTY_NEWLINE
);
1641 if (IS_DEBUG_OSPF (lsa
, LSA_REFRESH
))
1642 vty_out (vty
, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE
);
1645 /* Show debug status for Zebra. */
1646 if (IS_DEBUG_OSPF (zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1647 vty_out (vty
, " OSPF Zebra debugging is on%s", VTY_NEWLINE
);
1650 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
1651 vty_out (vty
, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE
);
1652 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
1653 vty_out (vty
, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE
);
1656 /* Show debug status for NSSA. */
1657 if (IS_DEBUG_OSPF (nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1658 vty_out (vty
, " OSPF NSSA debugging is on%s", VTY_NEWLINE
);
1660 vty_out (vty
, "%s", VTY_NEWLINE
);
1665 DEFUN (show_debugging_ospf
,
1666 show_debugging_ospf_cmd
,
1667 "show debugging ospf",
1674 if ((ospf
= ospf_lookup()) == NULL
)
1677 return show_debugging_ospf_common(vty
, ospf
);
1680 DEFUN (show_debugging_ospf_instance
,
1681 show_debugging_ospf_instance_cmd
,
1682 "show debugging ospf (1-65535)",
1690 u_short instance
= 0;
1692 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1693 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
1696 return show_debugging_ospf_common(vty
, ospf
);
1700 static struct cmd_node debug_node
=
1708 config_write_debug (struct vty
*vty
)
1713 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
1714 const char *detail_str
[] = {"", " send", " recv", "", " detail",
1715 " send detail", " recv detail", " detail"};
1719 memset (str
, 0, 16);
1721 if ((ospf
= ospf_lookup()) == NULL
)
1725 sprintf(str
, " %d", ospf
->instance
);
1727 /* debug ospf ism (status|events|timers). */
1728 if (IS_CONF_DEBUG_OSPF (ism
, ISM
) == OSPF_DEBUG_ISM
)
1729 vty_out (vty
, "debug ospf%s ism%s", str
, VTY_NEWLINE
);
1732 if (IS_CONF_DEBUG_OSPF (ism
, ISM_STATUS
))
1733 vty_out (vty
, "debug ospf%s ism status%s", str
, VTY_NEWLINE
);
1734 if (IS_CONF_DEBUG_OSPF (ism
, ISM_EVENTS
))
1735 vty_out (vty
, "debug ospf%s ism event%s", str
, VTY_NEWLINE
);
1736 if (IS_CONF_DEBUG_OSPF (ism
, ISM_TIMERS
))
1737 vty_out (vty
, "debug ospf%s ism timer%s", str
, VTY_NEWLINE
);
1740 /* debug ospf nsm (status|events|timers). */
1741 if (IS_CONF_DEBUG_OSPF (nsm
, NSM
) == OSPF_DEBUG_NSM
)
1742 vty_out (vty
, "debug ospf%s nsm%s", str
, VTY_NEWLINE
);
1745 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_STATUS
))
1746 vty_out (vty
, "debug ospf%s nsm status%s", str
, VTY_NEWLINE
);
1747 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_EVENTS
))
1748 vty_out (vty
, "debug ospf%s nsm event%s", str
, VTY_NEWLINE
);
1749 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_TIMERS
))
1750 vty_out (vty
, "debug ospf%s nsm timer%s", str
, VTY_NEWLINE
);
1753 /* debug ospf lsa (generate|flooding|install|refresh). */
1754 if (IS_CONF_DEBUG_OSPF (lsa
, LSA
) == OSPF_DEBUG_LSA
)
1755 vty_out (vty
, "debug ospf%s lsa%s", str
, VTY_NEWLINE
);
1758 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_GENERATE
))
1759 vty_out (vty
, "debug ospf%s lsa generate%s", str
, VTY_NEWLINE
);
1760 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_FLOODING
))
1761 vty_out (vty
, "debug ospf%s lsa flooding%s", str
, VTY_NEWLINE
);
1762 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_INSTALL
))
1763 vty_out (vty
, "debug ospf%s lsa install%s", str
, VTY_NEWLINE
);
1764 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_REFRESH
))
1765 vty_out (vty
, "debug ospf%s lsa refresh%s", str
, VTY_NEWLINE
);
1770 /* debug ospf zebra (interface|redistribute). */
1771 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1772 vty_out (vty
, "debug ospf%s zebra%s", str
, VTY_NEWLINE
);
1775 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
1776 vty_out (vty
, "debug ospf%s zebra interface%s", str
, VTY_NEWLINE
);
1777 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
1778 vty_out (vty
, "debug ospf%s zebra redistribute%s", str
, VTY_NEWLINE
);
1783 /* debug ospf event. */
1784 if (IS_CONF_DEBUG_OSPF (event
, EVENT
) == OSPF_DEBUG_EVENT
)
1786 vty_out (vty
, "debug ospf%s event%s", str
, VTY_NEWLINE
);
1790 /* debug ospf nssa. */
1791 if (IS_CONF_DEBUG_OSPF (nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1793 vty_out (vty
, "debug ospf%s nssa%s", str
, VTY_NEWLINE
);
1797 /* debug ospf packet all detail. */
1798 r
= OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
;
1799 for (i
= 0; i
< 5; i
++)
1800 r
&= conf_debug_ospf_packet
[i
] & (OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
);
1801 if (r
== (OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
))
1803 vty_out (vty
, "debug ospf%s packet all detail%s", str
, VTY_NEWLINE
);
1807 /* debug ospf packet all. */
1808 r
= OSPF_DEBUG_SEND_RECV
;
1809 for (i
= 0; i
< 5; i
++)
1810 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
1811 if (r
== OSPF_DEBUG_SEND_RECV
)
1813 vty_out (vty
, "debug ospf%s packet all%s", str
, VTY_NEWLINE
);
1814 for (i
= 0; i
< 5; i
++)
1815 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
1816 vty_out (vty
, "debug ospf%s packet %s detail%s", str
,
1822 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1823 (send|recv) (detail). */
1824 for (i
= 0; i
< 5; i
++)
1826 if (conf_debug_ospf_packet
[i
] == 0)
1829 vty_out (vty
, "debug ospf%s packet %s%s%s", str
,
1830 type_str
[i
], detail_str
[conf_debug_ospf_packet
[i
]],
1838 /* Initialize debug commands. */
1842 install_node (&debug_node
, config_write_debug
);
1844 install_element (ENABLE_NODE
, &show_debugging_ospf_cmd
);
1845 install_element (ENABLE_NODE
, &debug_ospf_ism_cmd
);
1846 install_element (ENABLE_NODE
, &debug_ospf_nsm_cmd
);
1847 install_element (ENABLE_NODE
, &debug_ospf_lsa_cmd
);
1848 install_element (ENABLE_NODE
, &debug_ospf_zebra_cmd
);
1849 install_element (ENABLE_NODE
, &debug_ospf_event_cmd
);
1850 install_element (ENABLE_NODE
, &debug_ospf_nssa_cmd
);
1851 install_element (ENABLE_NODE
, &debug_ospf_te_cmd
);
1852 install_element (ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
1853 install_element (ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
1854 install_element (ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
1855 install_element (ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
1856 install_element (ENABLE_NODE
, &no_debug_ospf_event_cmd
);
1857 install_element (ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
1858 install_element (ENABLE_NODE
, &no_debug_ospf_te_cmd
);
1860 install_element (ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
1861 install_element (ENABLE_NODE
, &debug_ospf_packet_cmd
);
1862 install_element (ENABLE_NODE
, &no_debug_ospf_packet_cmd
);
1864 install_element (ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
1865 install_element (ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
1866 install_element (ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
1867 install_element (ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
1868 install_element (ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
1869 install_element (ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1870 install_element (ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1871 install_element (ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1872 install_element (ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
1873 install_element (ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1874 install_element (ENABLE_NODE
, &no_debug_ospf_cmd
);
1876 install_element (CONFIG_NODE
, &debug_ospf_packet_cmd
);
1877 install_element (CONFIG_NODE
, &no_debug_ospf_packet_cmd
);
1878 install_element (CONFIG_NODE
, &debug_ospf_ism_cmd
);
1879 install_element (CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
1881 install_element (CONFIG_NODE
, &debug_ospf_nsm_cmd
);
1882 install_element (CONFIG_NODE
, &debug_ospf_lsa_cmd
);
1883 install_element (CONFIG_NODE
, &debug_ospf_zebra_cmd
);
1884 install_element (CONFIG_NODE
, &debug_ospf_event_cmd
);
1885 install_element (CONFIG_NODE
, &debug_ospf_nssa_cmd
);
1886 install_element (CONFIG_NODE
, &debug_ospf_te_cmd
);
1887 install_element (CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
1888 install_element (CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
1889 install_element (CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
1890 install_element (CONFIG_NODE
, &no_debug_ospf_event_cmd
);
1891 install_element (CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
1892 install_element (CONFIG_NODE
, &no_debug_ospf_te_cmd
);
1894 install_element (CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
1895 install_element (CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
1896 install_element (CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
1897 install_element (CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
1898 install_element (CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
1899 install_element (CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1900 install_element (CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1901 install_element (CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1902 install_element (CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
1903 install_element (CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1904 install_element (CONFIG_NODE
, &no_debug_ospf_cmd
);