3 * Copyright (C) 1999, 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 #include "ospfd/ospfd.h"
34 #include "ospfd/ospf_interface.h"
35 #include "ospfd/ospf_ism.h"
36 #include "ospfd/ospf_asbr.h"
37 #include "ospfd/ospf_lsa.h"
38 #include "ospfd/ospf_lsdb.h"
39 #include "ospfd/ospf_neighbor.h"
40 #include "ospfd/ospf_nsm.h"
41 #include "ospfd/ospf_dump.h"
42 #include "ospfd/ospf_packet.h"
43 #include "ospfd/ospf_network.h"
45 /* Configuration debug option variables. */
46 unsigned long conf_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
47 unsigned long conf_debug_ospf_event
= 0;
48 unsigned long conf_debug_ospf_ism
= 0;
49 unsigned long conf_debug_ospf_nsm
= 0;
50 unsigned long conf_debug_ospf_lsa
= 0;
51 unsigned long conf_debug_ospf_zebra
= 0;
52 unsigned long conf_debug_ospf_nssa
= 0;
53 unsigned long conf_debug_ospf_te
= 0;
55 /* Enable debug option variables -- valid only session. */
56 unsigned long term_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
57 unsigned long term_debug_ospf_event
= 0;
58 unsigned long term_debug_ospf_ism
= 0;
59 unsigned long term_debug_ospf_nsm
= 0;
60 unsigned long term_debug_ospf_lsa
= 0;
61 unsigned long term_debug_ospf_zebra
= 0;
62 unsigned long term_debug_ospf_nssa
= 0;
63 unsigned long term_debug_ospf_te
= 0;
67 ospf_redist_string(u_int route_type
)
69 return (route_type
== ZEBRA_ROUTE_MAX
) ?
70 "Default" : zebra_route_string(route_type
);
73 #define OSPF_AREA_STRING_MAXLEN 16
75 ospf_area_name_string (struct ospf_area
*area
)
77 static char buf
[OSPF_AREA_STRING_MAXLEN
] = "";
83 area_id
= ntohl (area
->area_id
.s_addr
);
84 snprintf (buf
, OSPF_AREA_STRING_MAXLEN
, "%d.%d.%d.%d",
85 (area_id
>> 24) & 0xff, (area_id
>> 16) & 0xff,
86 (area_id
>> 8) & 0xff, area_id
& 0xff);
90 #define OSPF_AREA_DESC_STRING_MAXLEN 23
92 ospf_area_desc_string (struct ospf_area
*area
)
94 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
98 return "(incomplete)";
100 type
= area
->external_routing
;
104 snprintf (buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [NSSA]",
105 ospf_area_name_string (area
));
108 snprintf (buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [Stub]",
109 ospf_area_name_string (area
));
112 return ospf_area_name_string (area
);
118 #define OSPF_IF_STRING_MAXLEN 40
120 ospf_if_name_string (struct ospf_interface
*oi
)
122 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
125 if (!oi
|| !oi
->address
)
128 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
129 return oi
->ifp
->name
;
131 ifaddr
= ntohl (oi
->address
->u
.prefix4
.s_addr
);
132 snprintf (buf
, OSPF_IF_STRING_MAXLEN
,
133 "%s:%d.%d.%d.%d", oi
->ifp
->name
,
134 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
135 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
141 ospf_nbr_state_message (struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
144 struct ospf_interface
*oi
= nbr
->oi
;
146 if (IPV4_ADDR_SAME (&DR (oi
), &nbr
->address
.u
.prefix4
))
148 else if (IPV4_ADDR_SAME (&BDR (oi
), &nbr
->address
.u
.prefix4
))
153 memset (buf
, 0, size
);
155 snprintf (buf
, size
, "%s/%s",
156 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
),
157 lookup_msg(ospf_ism_state_msg
, state
, NULL
));
161 ospf_timeval_dump (struct timeval
*t
, char *buf
, size_t size
)
163 /* Making formatted timer strings. */
164 #define MINUTE_IN_SECONDS 60
165 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
166 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
167 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
168 unsigned long w
, d
, h
, m
, s
, ms
, us
;
173 w
= d
= h
= m
= s
= ms
= us
= 0;
174 memset (buf
, 0, size
);
185 t
->tv_sec
+= ms
/ 1000;
189 if (t
->tv_sec
> WEEK_IN_SECONDS
)
191 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
192 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
195 if (t
->tv_sec
> DAY_IN_SECONDS
)
197 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
198 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
201 if (t
->tv_sec
>= HOUR_IN_SECONDS
)
203 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
204 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
207 if (t
->tv_sec
>= MINUTE_IN_SECONDS
)
209 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
210 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
214 snprintf (buf
, size
, "%ldw%1ldd", w
, d
);
216 snprintf (buf
, size
, "%ldw%1ldd%02ldh", w
, d
, h
);
218 snprintf (buf
, size
, "%1ldd%02ldh%02ldm", d
, h
, m
);
220 snprintf (buf
, size
, "%ldh%02ldm%02lds", h
, m
, (long)t
->tv_sec
);
222 snprintf (buf
, size
, "%ldm%02lds", m
, (long)t
->tv_sec
);
224 snprintf (buf
, size
, "%ld.%03lds", (long)t
->tv_sec
, ms
);
226 snprintf (buf
, size
, "%ld usecs", (long)t
->tv_usec
);
232 ospf_timer_dump (struct thread
*t
, char *buf
, size_t size
)
234 struct timeval result
;
238 monotime_until (&t
->u
.sands
, &result
);
239 return ospf_timeval_dump (&result
, buf
, size
);
243 ospf_packet_hello_dump (struct stream
*s
, u_int16_t length
)
245 struct ospf_hello
*hello
;
248 hello
= (struct ospf_hello
*) STREAM_PNT (s
);
250 zlog_debug ("Hello");
251 zlog_debug (" NetworkMask %s", inet_ntoa (hello
->network_mask
));
252 zlog_debug (" HelloInterval %d", ntohs (hello
->hello_interval
));
253 zlog_debug (" Options %d (%s)", hello
->options
,
254 ospf_options_dump (hello
->options
));
255 zlog_debug (" RtrPriority %d", hello
->priority
);
256 zlog_debug (" RtrDeadInterval %ld", (u_long
)ntohl (hello
->dead_interval
));
257 zlog_debug (" DRouter %s", inet_ntoa (hello
->d_router
));
258 zlog_debug (" BDRouter %s", inet_ntoa (hello
->bd_router
));
260 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
261 zlog_debug (" # Neighbors %d", length
/ 4);
262 for (i
= 0; length
> 0; i
++, length
-= sizeof (struct in_addr
))
263 zlog_debug (" Neighbor %s", inet_ntoa (hello
->neighbors
[i
]));
267 ospf_dd_flags_dump (u_char flags
, char *buf
, size_t size
)
269 memset (buf
, 0, size
);
271 snprintf (buf
, size
, "%s|%s|%s",
272 (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
273 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
274 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
280 ospf_router_lsa_flags_dump (u_char flags
, char *buf
, size_t size
)
282 memset (buf
, 0, size
);
284 snprintf (buf
, size
, "%s|%s|%s",
285 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
286 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
287 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
293 ospf_router_lsa_dump (struct stream
*s
, u_int16_t length
)
296 struct router_lsa
*rl
;
299 rl
= (struct router_lsa
*) STREAM_PNT (s
);
301 zlog_debug (" Router-LSA");
302 zlog_debug (" flags %s",
303 ospf_router_lsa_flags_dump (rl
->flags
, buf
, BUFSIZ
));
304 zlog_debug (" # links %d", ntohs (rl
->links
));
306 len
= ntohs (rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
307 for (i
= 0; len
> 0; i
++)
309 zlog_debug (" Link ID %s", inet_ntoa (rl
->link
[i
].link_id
));
310 zlog_debug (" Link Data %s", inet_ntoa (rl
->link
[i
].link_data
));
311 zlog_debug (" Type %d", (u_char
) rl
->link
[i
].type
);
312 zlog_debug (" TOS %d", (u_char
) rl
->link
[i
].tos
);
313 zlog_debug (" metric %d", ntohs (rl
->link
[i
].metric
));
320 ospf_network_lsa_dump (struct stream
*s
, u_int16_t length
)
322 struct network_lsa
*nl
;
325 nl
= (struct network_lsa
*) STREAM_PNT (s
);
326 cnt
= (ntohs (nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
328 zlog_debug (" Network-LSA");
330 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
331 zlog_debug ("Network-LSA size %d",
332 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
334 zlog_debug (" Network Mask %s", inet_ntoa (nl
->mask
));
335 zlog_debug (" # Attached Routers %d", cnt
);
336 for (i
= 0; i
< cnt
; i
++)
337 zlog_debug (" Attached Router %s", inet_ntoa (nl
->routers
[i
]));
341 ospf_summary_lsa_dump (struct stream
*s
, u_int16_t length
)
343 struct summary_lsa
*sl
;
347 sl
= (struct summary_lsa
*) STREAM_PNT (s
);
349 zlog_debug (" Summary-LSA");
350 zlog_debug (" Network Mask %s", inet_ntoa (sl
->mask
));
352 size
= ntohs (sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
353 for (i
= 0; size
> 0; size
-= 4, i
++)
354 zlog_debug (" TOS=%d metric %d", sl
->tos
,
355 GET_METRIC (sl
->metric
));
359 ospf_as_external_lsa_dump (struct stream
*s
, u_int16_t length
)
361 struct as_external_lsa
*al
;
365 al
= (struct as_external_lsa
*) STREAM_PNT (s
);
366 zlog_debug (" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
367 zlog_debug (" Network Mask %s", inet_ntoa (al
->mask
));
369 size
= ntohs (al
->header
.length
) - OSPF_LSA_HEADER_SIZE
-4;
370 for (i
= 0; size
> 0; size
-= 12, i
++)
372 zlog_debug (" bit %s TOS=%d metric %d",
373 IS_EXTERNAL_METRIC (al
->e
[i
].tos
) ? "E" : "-",
374 al
->e
[i
].tos
& 0x7f, GET_METRIC (al
->e
[i
].metric
));
375 zlog_debug (" Forwarding address %s", inet_ntoa (al
->e
[i
].fwd_addr
));
376 zlog_debug (" External Route Tag %"ROUTE_TAG_PRI
, al
->e
[i
].route_tag
);
381 ospf_lsa_header_list_dump (struct stream
*s
, u_int16_t length
)
383 struct lsa_header
*lsa
;
385 zlog_debug (" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
390 lsa
= (struct lsa_header
*) STREAM_PNT (s
);
391 ospf_lsa_header_dump (lsa
);
393 stream_forward_getp (s
, OSPF_LSA_HEADER_SIZE
);
394 length
-= OSPF_LSA_HEADER_SIZE
;
399 ospf_packet_db_desc_dump (struct stream
*s
, u_int16_t length
)
401 struct ospf_db_desc
*dd
;
406 gp
= stream_get_getp (s
);
407 dd
= (struct ospf_db_desc
*) STREAM_PNT (s
);
409 zlog_debug ("Database Description");
410 zlog_debug (" Interface MTU %d", ntohs (dd
->mtu
));
411 zlog_debug (" Options %d (%s)", dd
->options
,
412 ospf_options_dump (dd
->options
));
413 zlog_debug (" Flags %d (%s)", dd
->flags
,
414 ospf_dd_flags_dump (dd
->flags
, dd_flags
, sizeof dd_flags
));
415 zlog_debug (" Sequence Number 0x%08lx", (u_long
)ntohl (dd
->dd_seqnum
));
417 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
419 stream_forward_getp (s
, OSPF_DB_DESC_MIN_SIZE
);
421 ospf_lsa_header_list_dump (s
, length
);
423 stream_set_getp (s
, gp
);
427 ospf_packet_ls_req_dump (struct stream
*s
, u_int16_t length
)
431 struct in_addr ls_id
;
432 struct in_addr adv_router
;
434 sp
= stream_get_getp (s
);
436 length
-= OSPF_HEADER_SIZE
;
438 zlog_debug ("Link State Request");
439 zlog_debug (" # Requests %d", length
/ 12);
441 for (; length
> 0; length
-= 12)
443 ls_type
= stream_getl (s
);
444 ls_id
.s_addr
= stream_get_ipv4 (s
);
445 adv_router
.s_addr
= stream_get_ipv4 (s
);
447 zlog_debug (" LS type %d", ls_type
);
448 zlog_debug (" Link State ID %s", inet_ntoa (ls_id
));
449 zlog_debug (" Advertising Router %s",
450 inet_ntoa (adv_router
));
453 stream_set_getp (s
, sp
);
457 ospf_packet_ls_upd_dump (struct stream
*s
, u_int16_t length
)
460 struct lsa_header
*lsa
;
464 length
-= OSPF_HEADER_SIZE
;
466 sp
= stream_get_getp (s
);
468 count
= stream_getl (s
);
471 zlog_debug ("Link State Update");
472 zlog_debug (" # LSAs %d", count
);
474 while (length
> 0 && count
> 0)
476 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0)
478 zlog_debug (" Remaining %d bytes; Incorrect length.", length
);
482 lsa
= (struct lsa_header
*) STREAM_PNT (s
);
483 lsa_len
= ntohs (lsa
->length
);
484 ospf_lsa_header_dump (lsa
);
488 case OSPF_ROUTER_LSA
:
489 ospf_router_lsa_dump (s
, length
);
491 case OSPF_NETWORK_LSA
:
492 ospf_network_lsa_dump (s
, length
);
494 case OSPF_SUMMARY_LSA
:
495 case OSPF_ASBR_SUMMARY_LSA
:
496 ospf_summary_lsa_dump (s
, length
);
498 case OSPF_AS_EXTERNAL_LSA
:
499 ospf_as_external_lsa_dump (s
, length
);
501 case OSPF_AS_NSSA_LSA
:
502 ospf_as_external_lsa_dump (s
, length
);
504 case OSPF_OPAQUE_LINK_LSA
:
505 case OSPF_OPAQUE_AREA_LSA
:
506 case OSPF_OPAQUE_AS_LSA
:
507 ospf_opaque_lsa_dump (s
, length
);
513 stream_forward_getp (s
, lsa_len
);
518 stream_set_getp (s
, sp
);
522 ospf_packet_ls_ack_dump (struct stream
*s
, u_int16_t length
)
526 length
-= OSPF_HEADER_SIZE
;
527 sp
= stream_get_getp (s
);
529 zlog_debug ("Link State Acknowledgment");
530 ospf_lsa_header_list_dump (s
, length
);
532 stream_set_getp (s
, sp
);
535 /* Expects header to be in host order */
537 ospf_ip_header_dump (struct ip
*iph
)
539 /* IP Header dump. */
540 zlog_debug ("ip_v %d", iph
->ip_v
);
541 zlog_debug ("ip_hl %d", iph
->ip_hl
);
542 zlog_debug ("ip_tos %d", iph
->ip_tos
);
543 zlog_debug ("ip_len %d", iph
->ip_len
);
544 zlog_debug ("ip_id %u", (u_int32_t
) iph
->ip_id
);
545 zlog_debug ("ip_off %u", (u_int32_t
) iph
->ip_off
);
546 zlog_debug ("ip_ttl %d", iph
->ip_ttl
);
547 zlog_debug ("ip_p %d", iph
->ip_p
);
548 zlog_debug ("ip_sum 0x%x", (u_int32_t
) iph
->ip_sum
);
549 zlog_debug ("ip_src %s", inet_ntoa (iph
->ip_src
));
550 zlog_debug ("ip_dst %s", inet_ntoa (iph
->ip_dst
));
554 ospf_header_dump (struct ospf_header
*ospfh
)
557 u_int16_t auth_type
= ntohs (ospfh
->auth_type
);
559 zlog_debug ("Header");
560 zlog_debug (" Version %d", ospfh
->version
);
561 zlog_debug (" Type %d (%s)", ospfh
->type
,
562 lookup_msg(ospf_packet_type_str
, ospfh
->type
, NULL
));
563 zlog_debug (" Packet Len %d", ntohs (ospfh
->length
));
564 zlog_debug (" Router ID %s", inet_ntoa (ospfh
->router_id
));
565 zlog_debug (" Area ID %s", inet_ntoa (ospfh
->area_id
));
566 zlog_debug (" Checksum 0x%x", ntohs (ospfh
->checksum
));
567 zlog_debug (" AuType %s", lookup_msg(ospf_auth_type_str
, auth_type
, NULL
));
573 case OSPF_AUTH_SIMPLE
:
575 strncpy (buf
, (char *) ospfh
->u
.auth_data
, 8);
576 zlog_debug (" Simple Password %s", buf
);
578 case OSPF_AUTH_CRYPTOGRAPHIC
:
579 zlog_debug (" Cryptographic Authentication");
580 zlog_debug (" Key ID %d", ospfh
->u
.crypt
.key_id
);
581 zlog_debug (" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
582 zlog_debug (" Sequence number %ld",
583 (u_long
)ntohl (ospfh
->u
.crypt
.crypt_seqnum
));
586 zlog_debug ("* This is not supported authentication type");
593 ospf_packet_dump (struct stream
*s
)
595 struct ospf_header
*ospfh
;
598 /* Preserve pointer. */
599 gp
= stream_get_getp (s
);
601 /* OSPF Header dump. */
602 ospfh
= (struct ospf_header
*) STREAM_PNT (s
);
604 /* Until detail flag is set, return. */
605 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
608 /* Show OSPF header detail. */
609 ospf_header_dump (ospfh
);
610 stream_forward_getp (s
, OSPF_HEADER_SIZE
);
615 ospf_packet_hello_dump (s
, ntohs (ospfh
->length
));
617 case OSPF_MSG_DB_DESC
:
618 ospf_packet_db_desc_dump (s
, ntohs (ospfh
->length
));
620 case OSPF_MSG_LS_REQ
:
621 ospf_packet_ls_req_dump (s
, ntohs (ospfh
->length
));
623 case OSPF_MSG_LS_UPD
:
624 ospf_packet_ls_upd_dump (s
, ntohs (ospfh
->length
));
626 case OSPF_MSG_LS_ACK
:
627 ospf_packet_ls_ack_dump (s
, ntohs (ospfh
->length
));
633 stream_set_getp (s
, gp
);
636 DEFUN (debug_ospf_packet
,
637 debug_ospf_packet_cmd
,
638 "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
644 "OSPF Database Description\n"
645 "OSPF Link State Request\n"
646 "OSPF Link State Update\n"
647 "OSPF Link State Acknowledgment\n"
650 "Detail Information\n"
652 "Detail Information\n"
653 "Detail Information\n")
655 int inst
= (argv
[2]->type
== RANGE_TKN
) ? 1 : 0;
656 int detail
= strmatch (argv
[argc
- 1]->text
, "detail");
657 int send
= strmatch (argv
[argc
- (1+detail
)]->text
, "send");
658 int recv
= strmatch (argv
[argc
- (1+detail
)]->text
, "recv");
659 char *packet
= argv
[3 + inst
]->text
;
661 if (inst
) // user passed instance ID
663 if (!ospf_lookup_instance (strtoul (argv
[2]->arg
, NULL
, 10)))
671 /* Check packet type. */
672 if (strmatch (packet
, "hello"))
673 type
= OSPF_DEBUG_HELLO
;
674 else if (strmatch (packet
, "dd"))
675 type
= OSPF_DEBUG_DB_DESC
;
676 else if (strmatch (packet
, "ls-request"))
677 type
= OSPF_DEBUG_LS_REQ
;
678 else if (strmatch (packet
, "ls-update"))
679 type
= OSPF_DEBUG_LS_UPD
;
680 else if (strmatch (packet
, "ls-ack"))
681 type
= OSPF_DEBUG_LS_ACK
;
682 else if (strmatch (packet
, "all"))
683 type
= OSPF_DEBUG_ALL
;
686 * (none) = send + recv
687 * detail = send + recv + detail
690 * recv detail = recv + detail
691 * send detail = send + detail
696 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
697 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
698 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
700 for (i
= 0; i
< 5; i
++)
701 if (type
& (0x01 << i
))
703 if (vty
->node
== CONFIG_NODE
)
704 DEBUG_PACKET_ON (i
, flag
);
706 TERM_DEBUG_PACKET_ON (i
, flag
);
712 DEFUN (no_debug_ospf_packet
,
713 no_debug_ospf_packet_cmd
,
714 "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
721 "OSPF Database Description\n"
722 "OSPF Link State Request\n"
723 "OSPF Link State Update\n"
724 "OSPF Link State Acknowledgment\n"
727 "Detail Information\n"
729 "Detail Information\n"
730 "Detail Information\n")
732 int inst
= (argv
[3]->type
== RANGE_TKN
) ? 1 : 0;
733 int detail
= strmatch (argv
[argc
- 1]->text
, "detail");
734 int send
= strmatch (argv
[argc
- (1+detail
)]->text
, "send");
735 int recv
= strmatch (argv
[argc
- (1+detail
)]->text
, "recv");
736 char *packet
= argv
[4 + inst
]->text
;
738 if (inst
) // user passed instance ID
740 if (!ospf_lookup_instance (strtoul (argv
[3]->arg
, NULL
, 10)))
748 /* Check packet type. */
749 if (strmatch (packet
, "hello"))
750 type
= OSPF_DEBUG_HELLO
;
751 else if (strmatch (packet
, "dd"))
752 type
= OSPF_DEBUG_DB_DESC
;
753 else if (strmatch (packet
, "ls-request"))
754 type
= OSPF_DEBUG_LS_REQ
;
755 else if (strmatch (packet
, "ls-update"))
756 type
= OSPF_DEBUG_LS_UPD
;
757 else if (strmatch (packet
, "ls-ack"))
758 type
= OSPF_DEBUG_LS_ACK
;
759 else if (strmatch (packet
, "all"))
760 type
= OSPF_DEBUG_ALL
;
763 * (none) = send + recv
764 * detail = send + recv + detail
767 * recv detail = recv + detail
768 * send detail = send + detail
773 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
774 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
775 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
777 for (i
= 0; i
< 5; i
++)
778 if (type
& (0x01 << i
))
780 if (vty
->node
== CONFIG_NODE
)
781 DEBUG_PACKET_OFF (i
, flag
);
783 TERM_DEBUG_PACKET_OFF (i
, flag
);
788 for (i = 0; i < 5; i++)
789 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
796 DEFUN (debug_ospf_ism
,
798 "debug ospf [(1-65535)] ism [<status|events|timers>]",
802 "OSPF Interface State Machine\n"
803 "ISM Status Information\n"
804 "ISM Event Information\n"
805 "ISM TImer Information\n")
807 int inst
= (argv
[2]->type
== RANGE_TKN
);
808 char *dbgparam
= (argc
== 4 + inst
) ? argv
[argc
- 1]->text
: NULL
;
810 if (inst
) // user passed instance ID
812 if (!ospf_lookup_instance (strtoul (argv
[2]->arg
, NULL
, 10)))
816 if (vty
->node
== CONFIG_NODE
)
822 if (strmatch (dbgparam
, "status"))
823 DEBUG_ON (ism
, ISM_STATUS
);
824 else if (strmatch (dbgparam
, "events"))
825 DEBUG_ON (ism
, ISM_EVENTS
);
826 else if (strmatch (dbgparam
, "timers"))
827 DEBUG_ON (ism
, ISM_TIMERS
);
835 TERM_DEBUG_ON (ism
, ISM
);
838 if (strmatch (dbgparam
, "status"))
839 TERM_DEBUG_ON (ism
, ISM_STATUS
);
840 else if (strmatch (dbgparam
, "events"))
841 TERM_DEBUG_ON (ism
, ISM_EVENTS
);
842 else if (strmatch (dbgparam
, "timers"))
843 TERM_DEBUG_ON (ism
, ISM_TIMERS
);
849 DEFUN (no_debug_ospf_ism
,
850 no_debug_ospf_ism_cmd
,
851 "no debug ospf [(1-65535)] ism [<status|events|timers>]",
856 "OSPF Interface State Machine\n"
857 "ISM Status Information\n"
858 "ISM Event Information\n"
859 "ISM TImer Information\n")
861 int inst
= (argv
[3]->type
== RANGE_TKN
);
862 char *dbgparam
= (argc
== 5 + inst
) ? argv
[argc
- 1]->text
: NULL
;
864 if (inst
) // user passed instance ID
866 if (!ospf_lookup_instance (strtoul (argv
[3]->arg
, NULL
, 10)))
870 if (vty
->node
== CONFIG_NODE
)
873 DEBUG_OFF (ism
, ISM
);
876 if (strmatch (dbgparam
, "status"))
877 DEBUG_OFF (ism
, ISM_STATUS
);
878 else if (strmatch (dbgparam
, "events"))
879 DEBUG_OFF (ism
, ISM_EVENTS
);
880 else if (strmatch (dbgparam
, "timers"))
881 DEBUG_OFF (ism
, ISM_TIMERS
);
889 TERM_DEBUG_OFF (ism
, ISM
);
892 if (strmatch (dbgparam
, "status"))
893 TERM_DEBUG_OFF (ism
, ISM_STATUS
);
894 else if (strmatch (dbgparam
, "events"))
895 TERM_DEBUG_OFF (ism
, ISM_EVENTS
);
896 else if (strmatch (dbgparam
, "timers"))
897 TERM_DEBUG_OFF (ism
, ISM_TIMERS
);
904 debug_ospf_nsm_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
906 if (vty
->node
== CONFIG_NODE
)
908 if (argc
== arg_base
+ 0)
910 else if (argc
== arg_base
+ 1)
912 if (strmatch(argv
[arg_base
]->text
, "status"))
913 DEBUG_ON (nsm
, NSM_STATUS
);
914 else if (strmatch(argv
[arg_base
]->text
, "events"))
915 DEBUG_ON (nsm
, NSM_EVENTS
);
916 else if (strmatch(argv
[arg_base
]->text
, "timers"))
917 DEBUG_ON (nsm
, NSM_TIMERS
);
924 if (argc
== arg_base
+ 0)
925 TERM_DEBUG_ON (nsm
, NSM
);
926 else if (argc
== arg_base
+ 1)
928 if (strmatch(argv
[arg_base
]->text
, "status"))
929 TERM_DEBUG_ON (nsm
, NSM_STATUS
);
930 else if (strmatch(argv
[arg_base
]->text
, "events"))
931 TERM_DEBUG_ON (nsm
, NSM_EVENTS
);
932 else if (strmatch(argv
[arg_base
]->text
, "timers"))
933 TERM_DEBUG_ON (nsm
, NSM_TIMERS
);
939 DEFUN (debug_ospf_nsm
,
941 "debug ospf nsm [<status|events|timers>]",
944 "OSPF Neighbor State Machine\n"
945 "NSM Status Information\n"
946 "NSM Event Information\n"
947 "NSM Timer Information\n")
949 return debug_ospf_nsm_common (vty
, 3, argc
, argv
);
952 DEFUN (debug_ospf_instance_nsm
,
953 debug_ospf_instance_nsm_cmd
,
954 "debug ospf (1-65535) nsm [<status|events|timers>]",
958 "OSPF Neighbor State Machine\n"
959 "NSM Status Information\n"
960 "NSM Event Information\n"
961 "NSM Timer Information\n")
964 u_short instance
= 0;
966 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
967 if (!ospf_lookup_instance (instance
))
970 return debug_ospf_nsm_common (vty
, 4, argc
, argv
);
975 no_debug_ospf_nsm_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
978 if (vty
->node
== CONFIG_NODE
)
980 if (argc
== arg_base
+ 0)
981 DEBUG_OFF (nsm
, NSM
);
982 else if (argc
== arg_base
+ 1)
984 if (strmatch(argv
[arg_base
]->text
, "status"))
985 DEBUG_OFF (nsm
, NSM_STATUS
);
986 else if (strmatch(argv
[arg_base
]->text
, "events"))
987 DEBUG_OFF (nsm
, NSM_EVENTS
);
988 else if (strmatch(argv
[arg_base
]->text
, "timers"))
989 DEBUG_OFF (nsm
, NSM_TIMERS
);
996 if (argc
== arg_base
+ 0)
997 TERM_DEBUG_OFF (nsm
, NSM
);
998 else if (argc
== arg_base
+ 1)
1000 if (strmatch(argv
[arg_base
]->text
, "status"))
1001 TERM_DEBUG_OFF (nsm
, NSM_STATUS
);
1002 else if (strmatch(argv
[arg_base
]->text
, "events"))
1003 TERM_DEBUG_OFF (nsm
, NSM_EVENTS
);
1004 else if (strmatch(argv
[arg_base
]->text
, "timers"))
1005 TERM_DEBUG_OFF (nsm
, NSM_TIMERS
);
1011 DEFUN (no_debug_ospf_nsm
,
1012 no_debug_ospf_nsm_cmd
,
1013 "no debug ospf nsm [<status|events|timers>]",
1017 "OSPF Neighbor State Machine\n"
1018 "NSM Status Information\n"
1019 "NSM Event Information\n"
1020 "NSM Timer Information\n")
1022 return no_debug_ospf_nsm_common(vty
, 4, argc
, argv
);
1026 DEFUN (no_debug_ospf_instance_nsm
,
1027 no_debug_ospf_instance_nsm_cmd
,
1028 "no debug ospf (1-65535) nsm [<status|events|timers>]",
1033 "OSPF Neighbor State Machine\n"
1034 "NSM Status Information\n"
1035 "NSM Event Information\n"
1036 "NSM Timer Information\n")
1039 u_short instance
= 0;
1041 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1042 if (!ospf_lookup_instance (instance
))
1045 return no_debug_ospf_nsm_common(vty
, 5, argc
, argv
);
1050 debug_ospf_lsa_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1052 if (vty
->node
== CONFIG_NODE
)
1054 if (argc
== arg_base
+ 0)
1055 DEBUG_ON (lsa
, LSA
);
1056 else if (argc
== arg_base
+ 1)
1058 if (strmatch(argv
[arg_base
]->text
, "generate"))
1059 DEBUG_ON (lsa
, LSA_GENERATE
);
1060 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1061 DEBUG_ON (lsa
, LSA_FLOODING
);
1062 else if (strmatch(argv
[arg_base
]->text
, "install"))
1063 DEBUG_ON (lsa
, LSA_INSTALL
);
1064 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1065 DEBUG_ON (lsa
, LSA_REFRESH
);
1072 if (argc
== arg_base
+ 0)
1073 TERM_DEBUG_ON (lsa
, LSA
);
1074 else if (argc
== arg_base
+ 1)
1076 if (strmatch(argv
[arg_base
]->text
, "generate"))
1077 TERM_DEBUG_ON (lsa
, LSA_GENERATE
);
1078 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1079 TERM_DEBUG_ON (lsa
, LSA_FLOODING
);
1080 else if (strmatch(argv
[arg_base
]->text
, "install"))
1081 TERM_DEBUG_ON (lsa
, LSA_INSTALL
);
1082 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1083 TERM_DEBUG_ON (lsa
, LSA_REFRESH
);
1089 DEFUN (debug_ospf_lsa
,
1091 "debug ospf lsa [<generate|flooding|install|refresh>]",
1094 "OSPF Link State Advertisement\n"
1097 "LSA Install/Delete\n"
1100 return debug_ospf_lsa_common(vty
, 3, argc
, argv
);
1103 DEFUN (debug_ospf_instance_lsa
,
1104 debug_ospf_instance_lsa_cmd
,
1105 "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1109 "OSPF Link State Advertisement\n"
1112 "LSA Install/Delete\n"
1116 u_short instance
= 0;
1118 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1119 if (!ospf_lookup_instance (instance
))
1122 return debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1127 no_debug_ospf_lsa_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1129 if (vty
->node
== CONFIG_NODE
)
1131 if (argc
== arg_base
+ 0)
1132 DEBUG_OFF (lsa
, LSA
);
1133 else if (argc
== arg_base
+ 1)
1135 if (strmatch(argv
[arg_base
]->text
, "generate"))
1136 DEBUG_OFF (lsa
, LSA_GENERATE
);
1137 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1138 DEBUG_OFF (lsa
, LSA_FLOODING
);
1139 else if (strmatch(argv
[arg_base
]->text
, "install"))
1140 DEBUG_OFF (lsa
, LSA_INSTALL
);
1141 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1142 DEBUG_OFF (lsa
, LSA_REFRESH
);
1149 if (argc
== arg_base
+ 0)
1150 TERM_DEBUG_OFF (lsa
, LSA
);
1151 else if (argc
== arg_base
+ 1)
1153 if (strmatch(argv
[arg_base
]->text
, "generate"))
1154 TERM_DEBUG_OFF (lsa
, LSA_GENERATE
);
1155 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1156 TERM_DEBUG_OFF (lsa
, LSA_FLOODING
);
1157 else if (strmatch(argv
[arg_base
]->text
, "install"))
1158 TERM_DEBUG_OFF (lsa
, LSA_INSTALL
);
1159 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1160 TERM_DEBUG_OFF (lsa
, LSA_REFRESH
);
1166 DEFUN (no_debug_ospf_lsa
,
1167 no_debug_ospf_lsa_cmd
,
1168 "no debug ospf lsa [<generate|flooding|install|refresh>]",
1172 "OSPF Link State Advertisement\n"
1175 "LSA Install/Delete\n"
1178 return no_debug_ospf_lsa_common (vty
, 4, argc
, argv
);
1181 DEFUN (no_debug_ospf_instance_lsa
,
1182 no_debug_ospf_instance_lsa_cmd
,
1183 "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1188 "OSPF Link State Advertisement\n"
1191 "LSA Install/Delete\n"
1195 u_short instance
= 0;
1197 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1198 if (!ospf_lookup_instance (instance
))
1201 return no_debug_ospf_lsa_common (vty
, 5, argc
, argv
);
1206 debug_ospf_zebra_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1208 if (vty
->node
== CONFIG_NODE
)
1210 if (argc
== arg_base
+ 0)
1211 DEBUG_ON (zebra
, ZEBRA
);
1212 else if (argc
== arg_base
+ 1)
1214 if (strmatch(argv
[arg_base
]->text
, "interface"))
1215 DEBUG_ON (zebra
, ZEBRA_INTERFACE
);
1216 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1217 DEBUG_ON (zebra
, ZEBRA_REDISTRIBUTE
);
1224 if (argc
== arg_base
+ 0)
1225 TERM_DEBUG_ON (zebra
, ZEBRA
);
1226 else if (argc
== arg_base
+ 1)
1228 if (strmatch(argv
[arg_base
]->text
, "interface"))
1229 TERM_DEBUG_ON (zebra
, ZEBRA_INTERFACE
);
1230 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1231 TERM_DEBUG_ON (zebra
, ZEBRA_REDISTRIBUTE
);
1237 DEFUN (debug_ospf_zebra
,
1238 debug_ospf_zebra_cmd
,
1239 "debug ospf zebra [<interface|redistribute>]",
1242 "OSPF Zebra information\n"
1244 "Zebra redistribute\n")
1246 return debug_ospf_zebra_common(vty
, 3, argc
, argv
);
1249 DEFUN (debug_ospf_instance_zebra
,
1250 debug_ospf_instance_zebra_cmd
,
1251 "debug ospf (1-65535) zebra [<interface|redistribute>]",
1255 "OSPF Zebra information\n"
1257 "Zebra redistribute\n")
1260 u_short instance
= 0;
1262 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1263 if (!ospf_lookup_instance (instance
))
1266 return debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1271 no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1272 struct cmd_token
**argv
)
1274 if (vty
->node
== CONFIG_NODE
)
1276 if (argc
== arg_base
+ 0)
1277 DEBUG_OFF (zebra
, ZEBRA
);
1278 else if (argc
== arg_base
+ 1)
1280 if (strmatch(argv
[arg_base
]->text
, "interface"))
1281 DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1282 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1283 DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1290 if (argc
== arg_base
+ 0)
1291 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1292 else if (argc
== arg_base
+ 1)
1294 if (strmatch(argv
[arg_base
]->text
, "interface"))
1295 TERM_DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1296 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1297 TERM_DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1303 DEFUN (no_debug_ospf_zebra
,
1304 no_debug_ospf_zebra_cmd
,
1305 "no debug ospf zebra [<interface|redistribute>]",
1309 "OSPF Zebra information\n"
1311 "Zebra redistribute\n")
1313 return no_debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1316 DEFUN (no_debug_ospf_instance_zebra
,
1317 no_debug_ospf_instance_zebra_cmd
,
1318 "no debug ospf (1-65535) zebra [<interface|redistribute>]",
1323 "OSPF Zebra information\n"
1325 "Zebra redistribute\n")
1328 u_short instance
= 0;
1330 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1331 if (!ospf_lookup_instance (instance
))
1334 return no_debug_ospf_zebra_common(vty
, 5, argc
, argv
);
1339 DEFUN (debug_ospf_event
,
1340 debug_ospf_event_cmd
,
1344 "OSPF event information\n")
1346 if (vty
->node
== CONFIG_NODE
)
1347 CONF_DEBUG_ON (event
, EVENT
);
1348 TERM_DEBUG_ON (event
, EVENT
);
1352 DEFUN (no_debug_ospf_event
,
1353 no_debug_ospf_event_cmd
,
1354 "no debug ospf event",
1358 "OSPF event information\n")
1360 if (vty
->node
== CONFIG_NODE
)
1361 CONF_DEBUG_OFF (event
, EVENT
);
1362 TERM_DEBUG_OFF (event
, EVENT
);
1366 DEFUN (debug_ospf_instance_event
,
1367 debug_ospf_instance_event_cmd
,
1368 "debug ospf (1-65535) event",
1372 "OSPF event information\n")
1375 u_short instance
= 0;
1377 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1378 if (!ospf_lookup_instance (instance
))
1381 if (vty
->node
== CONFIG_NODE
)
1382 CONF_DEBUG_ON (event
, EVENT
);
1383 TERM_DEBUG_ON (event
, EVENT
);
1387 DEFUN (no_debug_ospf_instance_event
,
1388 no_debug_ospf_instance_event_cmd
,
1389 "no debug ospf (1-65535) event",
1394 "OSPF event information\n")
1397 u_short instance
= 0;
1399 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1400 if (!ospf_lookup_instance (instance
))
1403 if (vty
->node
== CONFIG_NODE
)
1404 CONF_DEBUG_OFF (event
, EVENT
);
1405 TERM_DEBUG_OFF (event
, EVENT
);
1409 DEFUN (debug_ospf_nssa
,
1410 debug_ospf_nssa_cmd
,
1414 "OSPF nssa information\n")
1416 if (vty
->node
== CONFIG_NODE
)
1417 CONF_DEBUG_ON (nssa
, NSSA
);
1418 TERM_DEBUG_ON (nssa
, NSSA
);
1422 DEFUN (no_debug_ospf_nssa
,
1423 no_debug_ospf_nssa_cmd
,
1424 "no debug ospf nssa",
1428 "OSPF nssa information\n")
1430 if (vty
->node
== CONFIG_NODE
)
1431 CONF_DEBUG_OFF (nssa
, NSSA
);
1432 TERM_DEBUG_OFF (nssa
, NSSA
);
1436 DEFUN (debug_ospf_instance_nssa
,
1437 debug_ospf_instance_nssa_cmd
,
1438 "debug ospf (1-65535) nssa",
1442 "OSPF nssa information\n")
1445 u_short instance
= 0;
1447 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1448 if (!ospf_lookup_instance (instance
))
1451 if (vty
->node
== CONFIG_NODE
)
1452 CONF_DEBUG_ON (nssa
, NSSA
);
1453 TERM_DEBUG_ON (nssa
, NSSA
);
1457 DEFUN (no_debug_ospf_instance_nssa
,
1458 no_debug_ospf_instance_nssa_cmd
,
1459 "no debug ospf (1-65535) nssa",
1464 "OSPF nssa information\n")
1467 u_short instance
= 0;
1469 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1470 if (!ospf_lookup_instance (instance
))
1473 if (vty
->node
== CONFIG_NODE
)
1474 CONF_DEBUG_OFF (nssa
, NSSA
);
1475 TERM_DEBUG_OFF (nssa
, NSSA
);
1479 DEFUN (debug_ospf_te
,
1484 "OSPF-TE information\n")
1486 if (vty
->node
== CONFIG_NODE
)
1487 CONF_DEBUG_ON (te
, TE
);
1488 TERM_DEBUG_ON (te
, TE
);
1492 DEFUN (no_debug_ospf_te
,
1493 no_debug_ospf_te_cmd
,
1498 "OSPF-TE information\n")
1500 if (vty
->node
== CONFIG_NODE
)
1501 CONF_DEBUG_OFF (te
, TE
);
1502 TERM_DEBUG_OFF (te
, TE
);
1506 DEFUN (no_debug_ospf
,
1513 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1516 if (vty
->node
== CONFIG_NODE
)
1518 CONF_DEBUG_OFF (event
, EVENT
);
1519 CONF_DEBUG_OFF (nssa
, NSSA
);
1520 DEBUG_OFF (ism
, ISM_EVENTS
);
1521 DEBUG_OFF (ism
, ISM_STATUS
);
1522 DEBUG_OFF (ism
, ISM_TIMERS
);
1523 DEBUG_OFF (lsa
, LSA
);
1524 DEBUG_OFF (lsa
, LSA_FLOODING
);
1525 DEBUG_OFF (lsa
, LSA_GENERATE
);
1526 DEBUG_OFF (lsa
, LSA_INSTALL
);
1527 DEBUG_OFF (lsa
, LSA_REFRESH
);
1528 DEBUG_OFF (nsm
, NSM
);
1529 DEBUG_OFF (nsm
, NSM_EVENTS
);
1530 DEBUG_OFF (nsm
, NSM_STATUS
);
1531 DEBUG_OFF (nsm
, NSM_TIMERS
);
1532 DEBUG_OFF (zebra
, ZEBRA
);
1533 DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1534 DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1536 for (i
= 0; i
< 5; i
++)
1537 DEBUG_PACKET_OFF (i
, flag
);
1540 for (i
= 0; i
< 5; i
++)
1541 TERM_DEBUG_PACKET_OFF (i
, flag
);
1543 TERM_DEBUG_OFF (event
, EVENT
);
1544 TERM_DEBUG_OFF (ism
, ISM
);
1545 TERM_DEBUG_OFF (ism
, ISM_EVENTS
);
1546 TERM_DEBUG_OFF (ism
, ISM_STATUS
);
1547 TERM_DEBUG_OFF (ism
, ISM_TIMERS
);
1548 TERM_DEBUG_OFF (lsa
, LSA
);
1549 TERM_DEBUG_OFF (lsa
, LSA_FLOODING
);
1550 TERM_DEBUG_OFF (lsa
, LSA_GENERATE
);
1551 TERM_DEBUG_OFF (lsa
, LSA_INSTALL
);
1552 TERM_DEBUG_OFF (lsa
, LSA_REFRESH
);
1553 TERM_DEBUG_OFF (nsm
, NSM
);
1554 TERM_DEBUG_OFF (nsm
, NSM_EVENTS
);
1555 TERM_DEBUG_OFF (nsm
, NSM_STATUS
);
1556 TERM_DEBUG_OFF (nsm
, NSM_TIMERS
);
1557 TERM_DEBUG_OFF (nssa
, NSSA
);
1558 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1559 TERM_DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1560 TERM_DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1566 show_debugging_ospf_common (struct vty
*vty
, struct ospf
*ospf
)
1571 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
1572 VTY_NEWLINE
, VTY_NEWLINE
);
1574 vty_out (vty
, "OSPF debugging status:%s", VTY_NEWLINE
);
1576 /* Show debug status for events. */
1577 if (IS_DEBUG_OSPF(event
,EVENT
))
1578 vty_out (vty
, " OSPF event debugging is on%s", VTY_NEWLINE
);
1580 /* Show debug status for ISM. */
1581 if (IS_DEBUG_OSPF (ism
, ISM
) == OSPF_DEBUG_ISM
)
1582 vty_out (vty
, " OSPF ISM debugging is on%s", VTY_NEWLINE
);
1585 if (IS_DEBUG_OSPF (ism
, ISM_STATUS
))
1586 vty_out (vty
, " OSPF ISM status debugging is on%s", VTY_NEWLINE
);
1587 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
1588 vty_out (vty
, " OSPF ISM event debugging is on%s", VTY_NEWLINE
);
1589 if (IS_DEBUG_OSPF (ism
, ISM_TIMERS
))
1590 vty_out (vty
, " OSPF ISM timer debugging is on%s", VTY_NEWLINE
);
1593 /* Show debug status for NSM. */
1594 if (IS_DEBUG_OSPF (nsm
, NSM
) == OSPF_DEBUG_NSM
)
1595 vty_out (vty
, " OSPF NSM debugging is on%s", VTY_NEWLINE
);
1598 if (IS_DEBUG_OSPF (nsm
, NSM_STATUS
))
1599 vty_out (vty
, " OSPF NSM status debugging is on%s", VTY_NEWLINE
);
1600 if (IS_DEBUG_OSPF (nsm
, NSM_EVENTS
))
1601 vty_out (vty
, " OSPF NSM event debugging is on%s", VTY_NEWLINE
);
1602 if (IS_DEBUG_OSPF (nsm
, NSM_TIMERS
))
1603 vty_out (vty
, " OSPF NSM timer debugging is on%s", VTY_NEWLINE
);
1606 /* Show debug status for OSPF Packets. */
1607 for (i
= 0; i
< 5; i
++)
1608 if (IS_DEBUG_OSPF_PACKET (i
, SEND
) && IS_DEBUG_OSPF_PACKET (i
, RECV
))
1610 vty_out (vty
, " OSPF packet %s%s debugging is on%s",
1611 lookup_msg(ospf_packet_type_str
, i
+ 1, NULL
),
1612 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
1617 if (IS_DEBUG_OSPF_PACKET (i
, SEND
))
1618 vty_out (vty
, " OSPF packet %s send%s debugging is on%s",
1619 lookup_msg(ospf_packet_type_str
, i
+ 1, NULL
),
1620 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
1622 if (IS_DEBUG_OSPF_PACKET (i
, RECV
))
1623 vty_out (vty
, " OSPF packet %s receive%s debugging is on%s",
1624 lookup_msg(ospf_packet_type_str
, i
+ 1, NULL
),
1625 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
1629 /* Show debug status for OSPF LSAs. */
1630 if (IS_DEBUG_OSPF (lsa
, LSA
) == OSPF_DEBUG_LSA
)
1631 vty_out (vty
, " OSPF LSA debugging is on%s", VTY_NEWLINE
);
1634 if (IS_DEBUG_OSPF (lsa
, LSA_GENERATE
))
1635 vty_out (vty
, " OSPF LSA generation debugging is on%s", VTY_NEWLINE
);
1636 if (IS_DEBUG_OSPF (lsa
, LSA_FLOODING
))
1637 vty_out (vty
, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE
);
1638 if (IS_DEBUG_OSPF (lsa
, LSA_INSTALL
))
1639 vty_out (vty
, " OSPF LSA install debugging is on%s", VTY_NEWLINE
);
1640 if (IS_DEBUG_OSPF (lsa
, LSA_REFRESH
))
1641 vty_out (vty
, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE
);
1644 /* Show debug status for Zebra. */
1645 if (IS_DEBUG_OSPF (zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1646 vty_out (vty
, " OSPF Zebra debugging is on%s", VTY_NEWLINE
);
1649 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
1650 vty_out (vty
, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE
);
1651 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
1652 vty_out (vty
, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE
);
1655 /* Show debug status for NSSA. */
1656 if (IS_DEBUG_OSPF (nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1657 vty_out (vty
, " OSPF NSSA debugging is on%s", VTY_NEWLINE
);
1659 vty_out (vty
, "%s", VTY_NEWLINE
);
1664 DEFUN (show_debugging_ospf
,
1665 show_debugging_ospf_cmd
,
1666 "show debugging ospf",
1673 if ((ospf
= ospf_lookup()) == NULL
)
1676 return show_debugging_ospf_common(vty
, ospf
);
1679 DEFUN (show_debugging_ospf_instance
,
1680 show_debugging_ospf_instance_cmd
,
1681 "show debugging ospf (1-65535)",
1689 u_short instance
= 0;
1691 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1692 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
1695 return show_debugging_ospf_common(vty
, ospf
);
1699 static struct cmd_node debug_node
=
1707 config_write_debug (struct vty
*vty
)
1712 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
1713 const char *detail_str
[] = {"", " send", " recv", "", " detail",
1714 " send detail", " recv detail", " detail"};
1718 memset (str
, 0, 16);
1720 if ((ospf
= ospf_lookup()) == NULL
)
1724 sprintf(str
, " %d", ospf
->instance
);
1726 /* debug ospf ism (status|events|timers). */
1727 if (IS_CONF_DEBUG_OSPF (ism
, ISM
) == OSPF_DEBUG_ISM
)
1728 vty_out (vty
, "debug ospf%s ism%s", str
, VTY_NEWLINE
);
1731 if (IS_CONF_DEBUG_OSPF (ism
, ISM_STATUS
))
1732 vty_out (vty
, "debug ospf%s ism status%s", str
, VTY_NEWLINE
);
1733 if (IS_CONF_DEBUG_OSPF (ism
, ISM_EVENTS
))
1734 vty_out (vty
, "debug ospf%s ism event%s", str
, VTY_NEWLINE
);
1735 if (IS_CONF_DEBUG_OSPF (ism
, ISM_TIMERS
))
1736 vty_out (vty
, "debug ospf%s ism timer%s", str
, VTY_NEWLINE
);
1739 /* debug ospf nsm (status|events|timers). */
1740 if (IS_CONF_DEBUG_OSPF (nsm
, NSM
) == OSPF_DEBUG_NSM
)
1741 vty_out (vty
, "debug ospf%s nsm%s", str
, VTY_NEWLINE
);
1744 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_STATUS
))
1745 vty_out (vty
, "debug ospf%s nsm status%s", str
, VTY_NEWLINE
);
1746 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_EVENTS
))
1747 vty_out (vty
, "debug ospf%s nsm event%s", str
, VTY_NEWLINE
);
1748 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_TIMERS
))
1749 vty_out (vty
, "debug ospf%s nsm timer%s", str
, VTY_NEWLINE
);
1752 /* debug ospf lsa (generate|flooding|install|refresh). */
1753 if (IS_CONF_DEBUG_OSPF (lsa
, LSA
) == OSPF_DEBUG_LSA
)
1754 vty_out (vty
, "debug ospf%s lsa%s", str
, VTY_NEWLINE
);
1757 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_GENERATE
))
1758 vty_out (vty
, "debug ospf%s lsa generate%s", str
, VTY_NEWLINE
);
1759 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_FLOODING
))
1760 vty_out (vty
, "debug ospf%s lsa flooding%s", str
, VTY_NEWLINE
);
1761 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_INSTALL
))
1762 vty_out (vty
, "debug ospf%s lsa install%s", str
, VTY_NEWLINE
);
1763 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_REFRESH
))
1764 vty_out (vty
, "debug ospf%s lsa refresh%s", str
, VTY_NEWLINE
);
1769 /* debug ospf zebra (interface|redistribute). */
1770 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1771 vty_out (vty
, "debug ospf%s zebra%s", str
, VTY_NEWLINE
);
1774 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
1775 vty_out (vty
, "debug ospf%s zebra interface%s", str
, VTY_NEWLINE
);
1776 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
1777 vty_out (vty
, "debug ospf%s zebra redistribute%s", str
, VTY_NEWLINE
);
1782 /* debug ospf event. */
1783 if (IS_CONF_DEBUG_OSPF (event
, EVENT
) == OSPF_DEBUG_EVENT
)
1785 vty_out (vty
, "debug ospf%s event%s", str
, VTY_NEWLINE
);
1789 /* debug ospf nssa. */
1790 if (IS_CONF_DEBUG_OSPF (nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1792 vty_out (vty
, "debug ospf%s nssa%s", str
, VTY_NEWLINE
);
1796 /* debug ospf packet all detail. */
1797 r
= OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
;
1798 for (i
= 0; i
< 5; i
++)
1799 r
&= conf_debug_ospf_packet
[i
] & (OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
);
1800 if (r
== (OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
))
1802 vty_out (vty
, "debug ospf%s packet all detail%s", str
, VTY_NEWLINE
);
1806 /* debug ospf packet all. */
1807 r
= OSPF_DEBUG_SEND_RECV
;
1808 for (i
= 0; i
< 5; i
++)
1809 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
1810 if (r
== OSPF_DEBUG_SEND_RECV
)
1812 vty_out (vty
, "debug ospf%s packet all%s", str
, VTY_NEWLINE
);
1813 for (i
= 0; i
< 5; i
++)
1814 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
1815 vty_out (vty
, "debug ospf%s packet %s detail%s", str
,
1821 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1822 (send|recv) (detail). */
1823 for (i
= 0; i
< 5; i
++)
1825 if (conf_debug_ospf_packet
[i
] == 0)
1828 vty_out (vty
, "debug ospf%s packet %s%s%s", str
,
1829 type_str
[i
], detail_str
[conf_debug_ospf_packet
[i
]],
1837 /* Initialize debug commands. */
1841 install_node (&debug_node
, config_write_debug
);
1843 install_element (ENABLE_NODE
, &show_debugging_ospf_cmd
);
1844 install_element (ENABLE_NODE
, &debug_ospf_ism_cmd
);
1845 install_element (ENABLE_NODE
, &debug_ospf_nsm_cmd
);
1846 install_element (ENABLE_NODE
, &debug_ospf_lsa_cmd
);
1847 install_element (ENABLE_NODE
, &debug_ospf_zebra_cmd
);
1848 install_element (ENABLE_NODE
, &debug_ospf_event_cmd
);
1849 install_element (ENABLE_NODE
, &debug_ospf_nssa_cmd
);
1850 install_element (ENABLE_NODE
, &debug_ospf_te_cmd
);
1851 install_element (ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
1852 install_element (ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
1853 install_element (ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
1854 install_element (ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
1855 install_element (ENABLE_NODE
, &no_debug_ospf_event_cmd
);
1856 install_element (ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
1857 install_element (ENABLE_NODE
, &no_debug_ospf_te_cmd
);
1859 install_element (ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
1860 install_element (ENABLE_NODE
, &debug_ospf_packet_cmd
);
1861 install_element (ENABLE_NODE
, &no_debug_ospf_packet_cmd
);
1863 install_element (ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
1864 install_element (ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
1865 install_element (ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
1866 install_element (ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
1867 install_element (ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
1868 install_element (ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1869 install_element (ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1870 install_element (ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1871 install_element (ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
1872 install_element (ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1873 install_element (ENABLE_NODE
, &no_debug_ospf_cmd
);
1875 install_element (CONFIG_NODE
, &debug_ospf_packet_cmd
);
1876 install_element (CONFIG_NODE
, &no_debug_ospf_packet_cmd
);
1877 install_element (CONFIG_NODE
, &debug_ospf_ism_cmd
);
1878 install_element (CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
1880 install_element (CONFIG_NODE
, &debug_ospf_nsm_cmd
);
1881 install_element (CONFIG_NODE
, &debug_ospf_lsa_cmd
);
1882 install_element (CONFIG_NODE
, &debug_ospf_zebra_cmd
);
1883 install_element (CONFIG_NODE
, &debug_ospf_event_cmd
);
1884 install_element (CONFIG_NODE
, &debug_ospf_nssa_cmd
);
1885 install_element (CONFIG_NODE
, &debug_ospf_te_cmd
);
1886 install_element (CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
1887 install_element (CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
1888 install_element (CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
1889 install_element (CONFIG_NODE
, &no_debug_ospf_event_cmd
);
1890 install_element (CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
1891 install_element (CONFIG_NODE
, &no_debug_ospf_te_cmd
);
1893 install_element (CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
1894 install_element (CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
1895 install_element (CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
1896 install_element (CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
1897 install_element (CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
1898 install_element (CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1899 install_element (CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1900 install_element (CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1901 install_element (CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
1902 install_element (CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1903 install_element (CONFIG_NODE
, &no_debug_ospf_cmd
);