3 * Copyright (C) 1999, 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 #include "ospfd/ospfd.h"
34 #include "ospfd/ospf_interface.h"
35 #include "ospfd/ospf_ism.h"
36 #include "ospfd/ospf_asbr.h"
37 #include "ospfd/ospf_lsa.h"
38 #include "ospfd/ospf_lsdb.h"
39 #include "ospfd/ospf_neighbor.h"
40 #include "ospfd/ospf_nsm.h"
41 #include "ospfd/ospf_dump.h"
42 #include "ospfd/ospf_packet.h"
43 #include "ospfd/ospf_network.h"
45 /* Configuration debug option variables. */
46 unsigned long conf_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
47 unsigned long conf_debug_ospf_event
= 0;
48 unsigned long conf_debug_ospf_ism
= 0;
49 unsigned long conf_debug_ospf_nsm
= 0;
50 unsigned long conf_debug_ospf_lsa
= 0;
51 unsigned long conf_debug_ospf_zebra
= 0;
52 unsigned long conf_debug_ospf_nssa
= 0;
53 unsigned long conf_debug_ospf_te
= 0;
54 unsigned long conf_debug_ospf_ext
= 0;
55 unsigned long conf_debug_ospf_sr
= 0;
57 /* Enable debug option variables -- valid only session. */
58 unsigned long term_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
59 unsigned long term_debug_ospf_event
= 0;
60 unsigned long term_debug_ospf_ism
= 0;
61 unsigned long term_debug_ospf_nsm
= 0;
62 unsigned long term_debug_ospf_lsa
= 0;
63 unsigned long term_debug_ospf_zebra
= 0;
64 unsigned long term_debug_ospf_nssa
= 0;
65 unsigned long term_debug_ospf_te
= 0;
66 unsigned long term_debug_ospf_ext
= 0;
67 unsigned long term_debug_ospf_sr
= 0;
69 const char *ospf_redist_string(u_int route_type
)
71 return (route_type
== ZEBRA_ROUTE_MAX
) ? "Default"
72 : zebra_route_string(route_type
);
75 #define OSPF_AREA_STRING_MAXLEN 16
76 const char *ospf_area_name_string(struct ospf_area
*area
)
78 static char buf
[OSPF_AREA_STRING_MAXLEN
] = "";
84 area_id
= ntohl(area
->area_id
.s_addr
);
85 snprintf(buf
, OSPF_AREA_STRING_MAXLEN
, "%d.%d.%d.%d",
86 (area_id
>> 24) & 0xff, (area_id
>> 16) & 0xff,
87 (area_id
>> 8) & 0xff, area_id
& 0xff);
91 #define OSPF_AREA_DESC_STRING_MAXLEN 23
92 const char *ospf_area_desc_string(struct ospf_area
*area
)
94 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
98 return "(incomplete)";
100 type
= area
->external_routing
;
103 snprintf(buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [NSSA]",
104 ospf_area_name_string(area
));
107 snprintf(buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [Stub]",
108 ospf_area_name_string(area
));
111 return ospf_area_name_string(area
);
117 #define OSPF_IF_STRING_MAXLEN 40
118 const char *ospf_if_name_string(struct ospf_interface
*oi
)
120 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
123 if (!oi
|| !oi
->address
)
126 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
127 return oi
->ifp
->name
;
129 ifaddr
= ntohl(oi
->address
->u
.prefix4
.s_addr
);
130 snprintf(buf
, OSPF_IF_STRING_MAXLEN
, "%s:%d.%d.%d.%d", oi
->ifp
->name
,
131 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
132 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
137 void ospf_nbr_state_message(struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
140 struct ospf_interface
*oi
= nbr
->oi
;
142 if (IPV4_ADDR_SAME(&DR(oi
), &nbr
->address
.u
.prefix4
))
144 else if (IPV4_ADDR_SAME(&BDR(oi
), &nbr
->address
.u
.prefix4
))
149 memset(buf
, 0, size
);
151 snprintf(buf
, size
, "%s/%s",
152 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
),
153 lookup_msg(ospf_ism_state_msg
, state
, NULL
));
156 const char *ospf_timeval_dump(struct timeval
*t
, char *buf
, size_t size
)
158 /* Making formatted timer strings. */
159 #define MINUTE_IN_SECONDS 60
160 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
161 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
162 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
163 unsigned long w
, d
, h
, m
, s
, ms
, us
;
168 w
= d
= h
= m
= s
= ms
= us
= 0;
169 memset(buf
, 0, size
);
175 (void)us
; /* unused */
179 t
->tv_sec
+= ms
/ 1000;
183 if (t
->tv_sec
> WEEK_IN_SECONDS
) {
184 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
185 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
188 if (t
->tv_sec
> DAY_IN_SECONDS
) {
189 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
190 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
193 if (t
->tv_sec
>= HOUR_IN_SECONDS
) {
194 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
195 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
198 if (t
->tv_sec
>= MINUTE_IN_SECONDS
) {
199 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
200 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
204 snprintf(buf
, size
, "%ldw%1ldd", w
, d
);
206 snprintf(buf
, size
, "%ldw%1ldd%02ldh", w
, d
, h
);
208 snprintf(buf
, size
, "%1ldd%02ldh%02ldm", d
, h
, m
);
210 snprintf(buf
, size
, "%ldh%02ldm%02lds", h
, m
, (long)t
->tv_sec
);
212 snprintf(buf
, size
, "%ldm%02lds", m
, (long)t
->tv_sec
);
214 snprintf(buf
, size
, "%ld.%03lds", (long)t
->tv_sec
, ms
);
216 snprintf(buf
, size
, "%ld usecs", (long)t
->tv_usec
);
221 const char *ospf_timer_dump(struct thread
*t
, char *buf
, size_t size
)
223 struct timeval result
;
227 monotime_until(&t
->u
.sands
, &result
);
228 return ospf_timeval_dump(&result
, buf
, size
);
231 static void ospf_packet_hello_dump(struct stream
*s
, u_int16_t length
)
233 struct ospf_hello
*hello
;
236 hello
= (struct ospf_hello
*)stream_pnt(s
);
239 zlog_debug(" NetworkMask %s", inet_ntoa(hello
->network_mask
));
240 zlog_debug(" HelloInterval %d", ntohs(hello
->hello_interval
));
241 zlog_debug(" Options %d (%s)", hello
->options
,
242 ospf_options_dump(hello
->options
));
243 zlog_debug(" RtrPriority %d", hello
->priority
);
244 zlog_debug(" RtrDeadInterval %ld",
245 (u_long
)ntohl(hello
->dead_interval
));
246 zlog_debug(" DRouter %s", inet_ntoa(hello
->d_router
));
247 zlog_debug(" BDRouter %s", inet_ntoa(hello
->bd_router
));
249 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
250 zlog_debug(" # Neighbors %d", length
/ 4);
251 for (i
= 0; length
> 0; i
++, length
-= sizeof(struct in_addr
))
252 zlog_debug(" Neighbor %s", inet_ntoa(hello
->neighbors
[i
]));
255 static char *ospf_dd_flags_dump(u_char flags
, char *buf
, size_t size
)
257 memset(buf
, 0, size
);
259 snprintf(buf
, size
, "%s|%s|%s", (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
260 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
261 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
266 static char *ospf_router_lsa_flags_dump(u_char flags
, char *buf
, size_t size
)
268 memset(buf
, 0, size
);
270 snprintf(buf
, size
, "%s|%s|%s",
271 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
272 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
273 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
278 static void ospf_router_lsa_dump(struct stream
*s
, u_int16_t length
)
281 struct router_lsa
*rl
;
284 rl
= (struct router_lsa
*)stream_pnt(s
);
286 zlog_debug(" Router-LSA");
287 zlog_debug(" flags %s",
288 ospf_router_lsa_flags_dump(rl
->flags
, buf
, BUFSIZ
));
289 zlog_debug(" # links %d", ntohs(rl
->links
));
291 len
= ntohs(rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
292 for (i
= 0; len
> 0; i
++) {
293 zlog_debug(" Link ID %s", inet_ntoa(rl
->link
[i
].link_id
));
294 zlog_debug(" Link Data %s",
295 inet_ntoa(rl
->link
[i
].link_data
));
296 zlog_debug(" Type %d", (u_char
)rl
->link
[i
].type
);
297 zlog_debug(" TOS %d", (u_char
)rl
->link
[i
].tos
);
298 zlog_debug(" metric %d", ntohs(rl
->link
[i
].metric
));
304 static void ospf_network_lsa_dump(struct stream
*s
, u_int16_t length
)
306 struct network_lsa
*nl
;
309 nl
= (struct network_lsa
*)stream_pnt(s
);
310 cnt
= (ntohs(nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
312 zlog_debug(" Network-LSA");
314 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
315 zlog_debug ("Network-LSA size %d",
316 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
318 zlog_debug(" Network Mask %s", inet_ntoa(nl
->mask
));
319 zlog_debug(" # Attached Routers %d", cnt
);
320 for (i
= 0; i
< cnt
; i
++)
321 zlog_debug(" Attached Router %s",
322 inet_ntoa(nl
->routers
[i
]));
325 static void ospf_summary_lsa_dump(struct stream
*s
, u_int16_t length
)
327 struct summary_lsa
*sl
;
331 sl
= (struct summary_lsa
*)stream_pnt(s
);
333 zlog_debug(" Summary-LSA");
334 zlog_debug(" Network Mask %s", inet_ntoa(sl
->mask
));
336 size
= ntohs(sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
337 for (i
= 0; size
> 0; size
-= 4, i
++)
338 zlog_debug(" TOS=%d metric %d", sl
->tos
,
339 GET_METRIC(sl
->metric
));
342 static void ospf_as_external_lsa_dump(struct stream
*s
, u_int16_t length
)
344 struct as_external_lsa
*al
;
348 al
= (struct as_external_lsa
*)stream_pnt(s
);
349 zlog_debug(" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
350 zlog_debug(" Network Mask %s", inet_ntoa(al
->mask
));
352 size
= ntohs(al
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
353 for (i
= 0; size
> 0; size
-= 12, i
++) {
354 zlog_debug(" bit %s TOS=%d metric %d",
355 IS_EXTERNAL_METRIC(al
->e
[i
].tos
) ? "E" : "-",
356 al
->e
[i
].tos
& 0x7f, GET_METRIC(al
->e
[i
].metric
));
357 zlog_debug(" Forwarding address %s",
358 inet_ntoa(al
->e
[i
].fwd_addr
));
359 zlog_debug(" External Route Tag %" ROUTE_TAG_PRI
,
364 static void ospf_lsa_header_list_dump(struct stream
*s
, u_int16_t length
)
366 struct lsa_header
*lsa
;
368 zlog_debug(" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
372 lsa
= (struct lsa_header
*)stream_pnt(s
);
373 ospf_lsa_header_dump(lsa
);
375 stream_forward_getp(s
, OSPF_LSA_HEADER_SIZE
);
376 length
-= OSPF_LSA_HEADER_SIZE
;
380 static void ospf_packet_db_desc_dump(struct stream
*s
, u_int16_t length
)
382 struct ospf_db_desc
*dd
;
387 gp
= stream_get_getp(s
);
388 dd
= (struct ospf_db_desc
*)stream_pnt(s
);
390 zlog_debug("Database Description");
391 zlog_debug(" Interface MTU %d", ntohs(dd
->mtu
));
392 zlog_debug(" Options %d (%s)", dd
->options
,
393 ospf_options_dump(dd
->options
));
394 zlog_debug(" Flags %d (%s)", dd
->flags
,
395 ospf_dd_flags_dump(dd
->flags
, dd_flags
, sizeof dd_flags
));
396 zlog_debug(" Sequence Number 0x%08lx", (u_long
)ntohl(dd
->dd_seqnum
));
398 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
400 stream_forward_getp(s
, OSPF_DB_DESC_MIN_SIZE
);
402 ospf_lsa_header_list_dump(s
, length
);
404 stream_set_getp(s
, gp
);
407 static void ospf_packet_ls_req_dump(struct stream
*s
, u_int16_t length
)
411 struct in_addr ls_id
;
412 struct in_addr adv_router
;
414 sp
= stream_get_getp(s
);
416 length
-= OSPF_HEADER_SIZE
;
418 zlog_debug("Link State Request");
419 zlog_debug(" # Requests %d", length
/ 12);
421 for (; length
> 0; length
-= 12) {
422 ls_type
= stream_getl(s
);
423 ls_id
.s_addr
= stream_get_ipv4(s
);
424 adv_router
.s_addr
= stream_get_ipv4(s
);
426 zlog_debug(" LS type %d", ls_type
);
427 zlog_debug(" Link State ID %s", inet_ntoa(ls_id
));
428 zlog_debug(" Advertising Router %s", inet_ntoa(adv_router
));
431 stream_set_getp(s
, sp
);
434 static void ospf_packet_ls_upd_dump(struct stream
*s
, u_int16_t length
)
437 struct lsa_header
*lsa
;
441 length
-= OSPF_HEADER_SIZE
;
443 sp
= stream_get_getp(s
);
445 count
= stream_getl(s
);
448 zlog_debug("Link State Update");
449 zlog_debug(" # LSAs %d", count
);
451 while (length
> 0 && count
> 0) {
452 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0) {
453 zlog_debug(" Remaining %d bytes; Incorrect length.",
458 lsa
= (struct lsa_header
*)stream_pnt(s
);
459 lsa_len
= ntohs(lsa
->length
);
460 ospf_lsa_header_dump(lsa
);
463 case OSPF_ROUTER_LSA
:
464 ospf_router_lsa_dump(s
, length
);
466 case OSPF_NETWORK_LSA
:
467 ospf_network_lsa_dump(s
, length
);
469 case OSPF_SUMMARY_LSA
:
470 case OSPF_ASBR_SUMMARY_LSA
:
471 ospf_summary_lsa_dump(s
, length
);
473 case OSPF_AS_EXTERNAL_LSA
:
474 ospf_as_external_lsa_dump(s
, length
);
476 case OSPF_AS_NSSA_LSA
:
477 ospf_as_external_lsa_dump(s
, length
);
479 case OSPF_OPAQUE_LINK_LSA
:
480 case OSPF_OPAQUE_AREA_LSA
:
481 case OSPF_OPAQUE_AS_LSA
:
482 ospf_opaque_lsa_dump(s
, length
);
488 stream_forward_getp(s
, lsa_len
);
493 stream_set_getp(s
, sp
);
496 static void ospf_packet_ls_ack_dump(struct stream
*s
, u_int16_t length
)
500 length
-= OSPF_HEADER_SIZE
;
501 sp
= stream_get_getp(s
);
503 zlog_debug("Link State Acknowledgment");
504 ospf_lsa_header_list_dump(s
, length
);
506 stream_set_getp(s
, sp
);
509 /* Expects header to be in host order */
510 void ospf_ip_header_dump(struct ip
*iph
)
512 /* IP Header dump. */
513 zlog_debug("ip_v %d", iph
->ip_v
);
514 zlog_debug("ip_hl %d", iph
->ip_hl
);
515 zlog_debug("ip_tos %d", iph
->ip_tos
);
516 zlog_debug("ip_len %d", iph
->ip_len
);
517 zlog_debug("ip_id %u", (u_int32_t
)iph
->ip_id
);
518 zlog_debug("ip_off %u", (u_int32_t
)iph
->ip_off
);
519 zlog_debug("ip_ttl %d", iph
->ip_ttl
);
520 zlog_debug("ip_p %d", iph
->ip_p
);
521 zlog_debug("ip_sum 0x%x", (u_int32_t
)iph
->ip_sum
);
522 zlog_debug("ip_src %s", inet_ntoa(iph
->ip_src
));
523 zlog_debug("ip_dst %s", inet_ntoa(iph
->ip_dst
));
526 static void ospf_header_dump(struct ospf_header
*ospfh
)
529 u_int16_t auth_type
= ntohs(ospfh
->auth_type
);
531 zlog_debug("Header");
532 zlog_debug(" Version %d", ospfh
->version
);
533 zlog_debug(" Type %d (%s)", ospfh
->type
,
534 lookup_msg(ospf_packet_type_str
, ospfh
->type
, NULL
));
535 zlog_debug(" Packet Len %d", ntohs(ospfh
->length
));
536 zlog_debug(" Router ID %s", inet_ntoa(ospfh
->router_id
));
537 zlog_debug(" Area ID %s", inet_ntoa(ospfh
->area_id
));
538 zlog_debug(" Checksum 0x%x", ntohs(ospfh
->checksum
));
539 zlog_debug(" AuType %s",
540 lookup_msg(ospf_auth_type_str
, auth_type
, NULL
));
545 case OSPF_AUTH_SIMPLE
:
547 strncpy(buf
, (char *)ospfh
->u
.auth_data
, 8);
548 zlog_debug(" Simple Password %s", buf
);
550 case OSPF_AUTH_CRYPTOGRAPHIC
:
551 zlog_debug(" Cryptographic Authentication");
552 zlog_debug(" Key ID %d", ospfh
->u
.crypt
.key_id
);
553 zlog_debug(" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
554 zlog_debug(" Sequence number %ld",
555 (u_long
)ntohl(ospfh
->u
.crypt
.crypt_seqnum
));
558 zlog_debug("* This is not supported authentication type");
563 void ospf_packet_dump(struct stream
*s
)
565 struct ospf_header
*ospfh
;
568 /* Preserve pointer. */
569 gp
= stream_get_getp(s
);
571 /* OSPF Header dump. */
572 ospfh
= (struct ospf_header
*)stream_pnt(s
);
574 /* Until detail flag is set, return. */
575 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
578 /* Show OSPF header detail. */
579 ospf_header_dump(ospfh
);
580 stream_forward_getp(s
, OSPF_HEADER_SIZE
);
582 switch (ospfh
->type
) {
584 ospf_packet_hello_dump(s
, ntohs(ospfh
->length
));
586 case OSPF_MSG_DB_DESC
:
587 ospf_packet_db_desc_dump(s
, ntohs(ospfh
->length
));
589 case OSPF_MSG_LS_REQ
:
590 ospf_packet_ls_req_dump(s
, ntohs(ospfh
->length
));
592 case OSPF_MSG_LS_UPD
:
593 ospf_packet_ls_upd_dump(s
, ntohs(ospfh
->length
));
595 case OSPF_MSG_LS_ACK
:
596 ospf_packet_ls_ack_dump(s
, ntohs(ospfh
->length
));
602 stream_set_getp(s
, gp
);
605 DEFUN (debug_ospf_packet
,
606 debug_ospf_packet_cmd
,
607 "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
613 "OSPF Database Description\n"
614 "OSPF Link State Request\n"
615 "OSPF Link State Update\n"
616 "OSPF Link State Acknowledgment\n"
619 "Detail Information\n"
621 "Detail Information\n"
622 "Detail Information\n")
624 int inst
= (argv
[2]->type
== RANGE_TKN
) ? 1 : 0;
625 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
626 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
627 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
628 char *packet
= argv
[3 + inst
]->text
;
630 if (inst
) // user passed instance ID
632 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
633 return CMD_NOT_MY_INSTANCE
;
640 /* Check packet type. */
641 if (strmatch(packet
, "hello"))
642 type
= OSPF_DEBUG_HELLO
;
643 else if (strmatch(packet
, "dd"))
644 type
= OSPF_DEBUG_DB_DESC
;
645 else if (strmatch(packet
, "ls-request"))
646 type
= OSPF_DEBUG_LS_REQ
;
647 else if (strmatch(packet
, "ls-update"))
648 type
= OSPF_DEBUG_LS_UPD
;
649 else if (strmatch(packet
, "ls-ack"))
650 type
= OSPF_DEBUG_LS_ACK
;
651 else if (strmatch(packet
, "all"))
652 type
= OSPF_DEBUG_ALL
;
655 * (none) = send + recv
656 * detail = send + recv + detail
659 * recv detail = recv + detail
660 * send detail = send + detail
665 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
666 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
667 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
669 for (i
= 0; i
< 5; i
++)
670 if (type
& (0x01 << i
)) {
671 if (vty
->node
== CONFIG_NODE
)
672 DEBUG_PACKET_ON(i
, flag
);
674 TERM_DEBUG_PACKET_ON(i
, flag
);
680 DEFUN (no_debug_ospf_packet
,
681 no_debug_ospf_packet_cmd
,
682 "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
689 "OSPF Database Description\n"
690 "OSPF Link State Request\n"
691 "OSPF Link State Update\n"
692 "OSPF Link State Acknowledgment\n"
695 "Detail Information\n"
697 "Detail Information\n"
698 "Detail Information\n")
700 int inst
= (argv
[3]->type
== RANGE_TKN
) ? 1 : 0;
701 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
702 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
703 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
704 char *packet
= argv
[4 + inst
]->text
;
706 if (inst
) // user passed instance ID
708 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
709 return CMD_NOT_MY_INSTANCE
;
716 /* Check packet type. */
717 if (strmatch(packet
, "hello"))
718 type
= OSPF_DEBUG_HELLO
;
719 else if (strmatch(packet
, "dd"))
720 type
= OSPF_DEBUG_DB_DESC
;
721 else if (strmatch(packet
, "ls-request"))
722 type
= OSPF_DEBUG_LS_REQ
;
723 else if (strmatch(packet
, "ls-update"))
724 type
= OSPF_DEBUG_LS_UPD
;
725 else if (strmatch(packet
, "ls-ack"))
726 type
= OSPF_DEBUG_LS_ACK
;
727 else if (strmatch(packet
, "all"))
728 type
= OSPF_DEBUG_ALL
;
731 * (none) = send + recv
732 * detail = send + recv + detail
735 * recv detail = recv + detail
736 * send detail = send + detail
741 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
742 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
743 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
745 for (i
= 0; i
< 5; i
++)
746 if (type
& (0x01 << i
)) {
747 if (vty
->node
== CONFIG_NODE
)
748 DEBUG_PACKET_OFF(i
, flag
);
750 TERM_DEBUG_PACKET_OFF(i
, flag
);
755 for (i = 0; i < 5; i++)
756 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
763 DEFUN (debug_ospf_ism
,
765 "debug ospf [(1-65535)] ism [<status|events|timers>]",
769 "OSPF Interface State Machine\n"
770 "ISM Status Information\n"
771 "ISM Event Information\n"
772 "ISM TImer Information\n")
774 int inst
= (argv
[2]->type
== RANGE_TKN
);
775 char *dbgparam
= (argc
== 4 + inst
) ? argv
[argc
- 1]->text
: NULL
;
777 if (inst
) // user passed instance ID
779 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
780 return CMD_NOT_MY_INSTANCE
;
783 if (vty
->node
== CONFIG_NODE
) {
787 if (strmatch(dbgparam
, "status"))
788 DEBUG_ON(ism
, ISM_STATUS
);
789 else if (strmatch(dbgparam
, "events"))
790 DEBUG_ON(ism
, ISM_EVENTS
);
791 else if (strmatch(dbgparam
, "timers"))
792 DEBUG_ON(ism
, ISM_TIMERS
);
800 TERM_DEBUG_ON(ism
, ISM
);
802 if (strmatch(dbgparam
, "status"))
803 TERM_DEBUG_ON(ism
, ISM_STATUS
);
804 else if (strmatch(dbgparam
, "events"))
805 TERM_DEBUG_ON(ism
, ISM_EVENTS
);
806 else if (strmatch(dbgparam
, "timers"))
807 TERM_DEBUG_ON(ism
, ISM_TIMERS
);
813 DEFUN (no_debug_ospf_ism
,
814 no_debug_ospf_ism_cmd
,
815 "no debug ospf [(1-65535)] ism [<status|events|timers>]",
820 "OSPF Interface State Machine\n"
821 "ISM Status Information\n"
822 "ISM Event Information\n"
823 "ISM TImer Information\n")
825 int inst
= (argv
[3]->type
== RANGE_TKN
);
826 char *dbgparam
= (argc
== 5 + inst
) ? argv
[argc
- 1]->text
: NULL
;
828 if (inst
) // user passed instance ID
830 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
831 return CMD_NOT_MY_INSTANCE
;
834 if (vty
->node
== CONFIG_NODE
) {
838 if (strmatch(dbgparam
, "status"))
839 DEBUG_OFF(ism
, ISM_STATUS
);
840 else if (strmatch(dbgparam
, "events"))
841 DEBUG_OFF(ism
, ISM_EVENTS
);
842 else if (strmatch(dbgparam
, "timers"))
843 DEBUG_OFF(ism
, ISM_TIMERS
);
851 TERM_DEBUG_OFF(ism
, ISM
);
853 if (strmatch(dbgparam
, "status"))
854 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
855 else if (strmatch(dbgparam
, "events"))
856 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
857 else if (strmatch(dbgparam
, "timers"))
858 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
864 static int debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
865 struct cmd_token
**argv
)
867 if (vty
->node
== CONFIG_NODE
) {
868 if (argc
== arg_base
+ 0)
870 else if (argc
== arg_base
+ 1) {
871 if (strmatch(argv
[arg_base
]->text
, "status"))
872 DEBUG_ON(nsm
, NSM_STATUS
);
873 else if (strmatch(argv
[arg_base
]->text
, "events"))
874 DEBUG_ON(nsm
, NSM_EVENTS
);
875 else if (strmatch(argv
[arg_base
]->text
, "timers"))
876 DEBUG_ON(nsm
, NSM_TIMERS
);
883 if (argc
== arg_base
+ 0)
884 TERM_DEBUG_ON(nsm
, NSM
);
885 else if (argc
== arg_base
+ 1) {
886 if (strmatch(argv
[arg_base
]->text
, "status"))
887 TERM_DEBUG_ON(nsm
, NSM_STATUS
);
888 else if (strmatch(argv
[arg_base
]->text
, "events"))
889 TERM_DEBUG_ON(nsm
, NSM_EVENTS
);
890 else if (strmatch(argv
[arg_base
]->text
, "timers"))
891 TERM_DEBUG_ON(nsm
, NSM_TIMERS
);
897 DEFUN (debug_ospf_nsm
,
899 "debug ospf nsm [<status|events|timers>]",
902 "OSPF Neighbor State Machine\n"
903 "NSM Status Information\n"
904 "NSM Event Information\n"
905 "NSM Timer Information\n")
907 return debug_ospf_nsm_common(vty
, 3, argc
, argv
);
910 DEFUN (debug_ospf_instance_nsm
,
911 debug_ospf_instance_nsm_cmd
,
912 "debug ospf (1-65535) nsm [<status|events|timers>]",
916 "OSPF Neighbor State Machine\n"
917 "NSM Status Information\n"
918 "NSM Event Information\n"
919 "NSM Timer Information\n")
922 u_short instance
= 0;
924 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
925 if (!ospf_lookup_instance(instance
))
928 return debug_ospf_nsm_common(vty
, 4, argc
, argv
);
932 static int no_debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
933 struct cmd_token
**argv
)
936 if (vty
->node
== CONFIG_NODE
) {
937 if (argc
== arg_base
+ 0)
939 else if (argc
== arg_base
+ 1) {
940 if (strmatch(argv
[arg_base
]->text
, "status"))
941 DEBUG_OFF(nsm
, NSM_STATUS
);
942 else if (strmatch(argv
[arg_base
]->text
, "events"))
943 DEBUG_OFF(nsm
, NSM_EVENTS
);
944 else if (strmatch(argv
[arg_base
]->text
, "timers"))
945 DEBUG_OFF(nsm
, NSM_TIMERS
);
952 if (argc
== arg_base
+ 0)
953 TERM_DEBUG_OFF(nsm
, NSM
);
954 else if (argc
== arg_base
+ 1) {
955 if (strmatch(argv
[arg_base
]->text
, "status"))
956 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
957 else if (strmatch(argv
[arg_base
]->text
, "events"))
958 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
959 else if (strmatch(argv
[arg_base
]->text
, "timers"))
960 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
966 DEFUN (no_debug_ospf_nsm
,
967 no_debug_ospf_nsm_cmd
,
968 "no debug ospf nsm [<status|events|timers>]",
972 "OSPF Neighbor State Machine\n"
973 "NSM Status Information\n"
974 "NSM Event Information\n"
975 "NSM Timer Information\n")
977 return no_debug_ospf_nsm_common(vty
, 4, argc
, argv
);
981 DEFUN (no_debug_ospf_instance_nsm
,
982 no_debug_ospf_instance_nsm_cmd
,
983 "no debug ospf (1-65535) nsm [<status|events|timers>]",
988 "OSPF Neighbor State Machine\n"
989 "NSM Status Information\n"
990 "NSM Event Information\n"
991 "NSM Timer Information\n")
994 u_short instance
= 0;
996 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
997 if (!ospf_lookup_instance(instance
))
998 return CMD_NOT_MY_INSTANCE
;
1000 return no_debug_ospf_nsm_common(vty
, 5, argc
, argv
);
1004 static int debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
1005 struct cmd_token
**argv
)
1007 if (vty
->node
== CONFIG_NODE
) {
1008 if (argc
== arg_base
+ 0)
1010 else if (argc
== arg_base
+ 1) {
1011 if (strmatch(argv
[arg_base
]->text
, "generate"))
1012 DEBUG_ON(lsa
, LSA_GENERATE
);
1013 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1014 DEBUG_ON(lsa
, LSA_FLOODING
);
1015 else if (strmatch(argv
[arg_base
]->text
, "install"))
1016 DEBUG_ON(lsa
, LSA_INSTALL
);
1017 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1018 DEBUG_ON(lsa
, LSA_REFRESH
);
1025 if (argc
== arg_base
+ 0)
1026 TERM_DEBUG_ON(lsa
, LSA
);
1027 else if (argc
== arg_base
+ 1) {
1028 if (strmatch(argv
[arg_base
]->text
, "generate"))
1029 TERM_DEBUG_ON(lsa
, LSA_GENERATE
);
1030 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1031 TERM_DEBUG_ON(lsa
, LSA_FLOODING
);
1032 else if (strmatch(argv
[arg_base
]->text
, "install"))
1033 TERM_DEBUG_ON(lsa
, LSA_INSTALL
);
1034 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1035 TERM_DEBUG_ON(lsa
, LSA_REFRESH
);
1041 DEFUN (debug_ospf_lsa
,
1043 "debug ospf lsa [<generate|flooding|install|refresh>]",
1046 "OSPF Link State Advertisement\n"
1049 "LSA Install/Delete\n"
1052 return debug_ospf_lsa_common(vty
, 3, argc
, argv
);
1055 DEFUN (debug_ospf_instance_lsa
,
1056 debug_ospf_instance_lsa_cmd
,
1057 "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1061 "OSPF Link State Advertisement\n"
1064 "LSA Install/Delete\n"
1068 u_short instance
= 0;
1070 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1071 if (!ospf_lookup_instance(instance
))
1072 return CMD_NOT_MY_INSTANCE
;
1074 return debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1078 static int no_debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
1079 struct cmd_token
**argv
)
1081 if (vty
->node
== CONFIG_NODE
) {
1082 if (argc
== arg_base
+ 0)
1083 DEBUG_OFF(lsa
, LSA
);
1084 else if (argc
== arg_base
+ 1) {
1085 if (strmatch(argv
[arg_base
]->text
, "generate"))
1086 DEBUG_OFF(lsa
, LSA_GENERATE
);
1087 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1088 DEBUG_OFF(lsa
, LSA_FLOODING
);
1089 else if (strmatch(argv
[arg_base
]->text
, "install"))
1090 DEBUG_OFF(lsa
, LSA_INSTALL
);
1091 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1092 DEBUG_OFF(lsa
, LSA_REFRESH
);
1099 if (argc
== arg_base
+ 0)
1100 TERM_DEBUG_OFF(lsa
, LSA
);
1101 else if (argc
== arg_base
+ 1) {
1102 if (strmatch(argv
[arg_base
]->text
, "generate"))
1103 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1104 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1105 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1106 else if (strmatch(argv
[arg_base
]->text
, "install"))
1107 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1108 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1109 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1115 DEFUN (no_debug_ospf_lsa
,
1116 no_debug_ospf_lsa_cmd
,
1117 "no debug ospf lsa [<generate|flooding|install|refresh>]",
1121 "OSPF Link State Advertisement\n"
1124 "LSA Install/Delete\n"
1127 return no_debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1130 DEFUN (no_debug_ospf_instance_lsa
,
1131 no_debug_ospf_instance_lsa_cmd
,
1132 "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1137 "OSPF Link State Advertisement\n"
1140 "LSA Install/Delete\n"
1144 u_short instance
= 0;
1146 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1147 if (!ospf_lookup_instance(instance
))
1148 return CMD_NOT_MY_INSTANCE
;
1150 return no_debug_ospf_lsa_common(vty
, 5, argc
, argv
);
1154 static int debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1155 struct cmd_token
**argv
)
1157 if (vty
->node
== CONFIG_NODE
) {
1158 if (argc
== arg_base
+ 0)
1159 DEBUG_ON(zebra
, ZEBRA
);
1160 else if (argc
== arg_base
+ 1) {
1161 if (strmatch(argv
[arg_base
]->text
, "interface"))
1162 DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1163 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1164 DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1171 if (argc
== arg_base
+ 0)
1172 TERM_DEBUG_ON(zebra
, ZEBRA
);
1173 else if (argc
== arg_base
+ 1) {
1174 if (strmatch(argv
[arg_base
]->text
, "interface"))
1175 TERM_DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1176 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1177 TERM_DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1183 DEFUN (debug_ospf_zebra
,
1184 debug_ospf_zebra_cmd
,
1185 "debug ospf zebra [<interface|redistribute>]",
1190 "Zebra redistribute\n")
1192 return debug_ospf_zebra_common(vty
, 3, argc
, argv
);
1195 DEFUN (debug_ospf_instance_zebra
,
1196 debug_ospf_instance_zebra_cmd
,
1197 "debug ospf (1-65535) zebra [<interface|redistribute>]",
1203 "Zebra redistribute\n")
1206 u_short instance
= 0;
1208 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1209 if (!ospf_lookup_instance(instance
))
1210 return CMD_NOT_MY_INSTANCE
;
1212 return debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1216 static int no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1217 struct cmd_token
**argv
)
1219 if (vty
->node
== CONFIG_NODE
) {
1220 if (argc
== arg_base
+ 0)
1221 DEBUG_OFF(zebra
, ZEBRA
);
1222 else if (argc
== arg_base
+ 1) {
1223 if (strmatch(argv
[arg_base
]->text
, "interface"))
1224 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1225 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1226 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1233 if (argc
== arg_base
+ 0)
1234 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1235 else if (argc
== arg_base
+ 1) {
1236 if (strmatch(argv
[arg_base
]->text
, "interface"))
1237 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1238 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1239 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1245 DEFUN (no_debug_ospf_zebra
,
1246 no_debug_ospf_zebra_cmd
,
1247 "no debug ospf zebra [<interface|redistribute>]",
1253 "Zebra redistribute\n")
1255 return no_debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1258 DEFUN (no_debug_ospf_instance_zebra
,
1259 no_debug_ospf_instance_zebra_cmd
,
1260 "no debug ospf (1-65535) zebra [<interface|redistribute>]",
1267 "Zebra redistribute\n")
1270 u_short instance
= 0;
1272 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1273 if (!ospf_lookup_instance(instance
))
1276 return no_debug_ospf_zebra_common(vty
, 5, argc
, argv
);
1280 DEFUN (debug_ospf_event
,
1281 debug_ospf_event_cmd
,
1285 "OSPF event information\n")
1287 if (vty
->node
== CONFIG_NODE
)
1288 CONF_DEBUG_ON(event
, EVENT
);
1289 TERM_DEBUG_ON(event
, EVENT
);
1293 DEFUN (no_debug_ospf_event
,
1294 no_debug_ospf_event_cmd
,
1295 "no debug ospf event",
1299 "OSPF event information\n")
1301 if (vty
->node
== CONFIG_NODE
)
1302 CONF_DEBUG_OFF(event
, EVENT
);
1303 TERM_DEBUG_OFF(event
, EVENT
);
1307 DEFUN (debug_ospf_instance_event
,
1308 debug_ospf_instance_event_cmd
,
1309 "debug ospf (1-65535) event",
1313 "OSPF event information\n")
1316 u_short instance
= 0;
1318 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1319 if (!ospf_lookup_instance(instance
))
1322 if (vty
->node
== CONFIG_NODE
)
1323 CONF_DEBUG_ON(event
, EVENT
);
1324 TERM_DEBUG_ON(event
, EVENT
);
1328 DEFUN (no_debug_ospf_instance_event
,
1329 no_debug_ospf_instance_event_cmd
,
1330 "no debug ospf (1-65535) event",
1335 "OSPF event information\n")
1338 u_short instance
= 0;
1340 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1341 if (!ospf_lookup_instance(instance
))
1344 if (vty
->node
== CONFIG_NODE
)
1345 CONF_DEBUG_OFF(event
, EVENT
);
1346 TERM_DEBUG_OFF(event
, EVENT
);
1350 DEFUN (debug_ospf_nssa
,
1351 debug_ospf_nssa_cmd
,
1355 "OSPF nssa information\n")
1357 if (vty
->node
== CONFIG_NODE
)
1358 CONF_DEBUG_ON(nssa
, NSSA
);
1359 TERM_DEBUG_ON(nssa
, NSSA
);
1363 DEFUN (no_debug_ospf_nssa
,
1364 no_debug_ospf_nssa_cmd
,
1365 "no debug ospf nssa",
1369 "OSPF nssa information\n")
1371 if (vty
->node
== CONFIG_NODE
)
1372 CONF_DEBUG_OFF(nssa
, NSSA
);
1373 TERM_DEBUG_OFF(nssa
, NSSA
);
1377 DEFUN (debug_ospf_instance_nssa
,
1378 debug_ospf_instance_nssa_cmd
,
1379 "debug ospf (1-65535) nssa",
1383 "OSPF nssa information\n")
1386 u_short instance
= 0;
1388 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1389 if (!ospf_lookup_instance(instance
))
1392 if (vty
->node
== CONFIG_NODE
)
1393 CONF_DEBUG_ON(nssa
, NSSA
);
1394 TERM_DEBUG_ON(nssa
, NSSA
);
1398 DEFUN (no_debug_ospf_instance_nssa
,
1399 no_debug_ospf_instance_nssa_cmd
,
1400 "no debug ospf (1-65535) nssa",
1405 "OSPF nssa information\n")
1408 u_short instance
= 0;
1410 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1411 if (!ospf_lookup_instance(instance
))
1414 if (vty
->node
== CONFIG_NODE
)
1415 CONF_DEBUG_OFF(nssa
, NSSA
);
1416 TERM_DEBUG_OFF(nssa
, NSSA
);
1420 DEFUN (debug_ospf_te
,
1425 "OSPF-TE information\n")
1427 if (vty
->node
== CONFIG_NODE
)
1428 CONF_DEBUG_ON(te
, TE
);
1429 TERM_DEBUG_ON(te
, TE
);
1433 DEFUN (no_debug_ospf_te
,
1434 no_debug_ospf_te_cmd
,
1439 "OSPF-TE information\n")
1441 if (vty
->node
== CONFIG_NODE
)
1442 CONF_DEBUG_OFF(te
, TE
);
1443 TERM_DEBUG_OFF(te
, TE
);
1447 DEFUN (debug_ospf_sr
,
1452 "OSPF-SR information\n")
1454 if (vty
->node
== CONFIG_NODE
)
1455 CONF_DEBUG_ON(sr
, SR
);
1456 TERM_DEBUG_ON(sr
, SR
);
1460 DEFUN (no_debug_ospf_sr
,
1461 no_debug_ospf_sr_cmd
,
1466 "OSPF-SR information\n")
1468 if (vty
->node
== CONFIG_NODE
)
1469 CONF_DEBUG_OFF(sr
, SR
);
1470 TERM_DEBUG_OFF(sr
, SR
);
1474 DEFUN (no_debug_ospf
,
1481 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1484 if (vty
->node
== CONFIG_NODE
) {
1485 CONF_DEBUG_OFF(event
, EVENT
);
1486 CONF_DEBUG_OFF(nssa
, NSSA
);
1487 DEBUG_OFF(ism
, ISM_EVENTS
);
1488 DEBUG_OFF(ism
, ISM_STATUS
);
1489 DEBUG_OFF(ism
, ISM_TIMERS
);
1490 DEBUG_OFF(lsa
, LSA
);
1491 DEBUG_OFF(lsa
, LSA_FLOODING
);
1492 DEBUG_OFF(lsa
, LSA_GENERATE
);
1493 DEBUG_OFF(lsa
, LSA_INSTALL
);
1494 DEBUG_OFF(lsa
, LSA_REFRESH
);
1495 DEBUG_OFF(nsm
, NSM
);
1496 DEBUG_OFF(nsm
, NSM_EVENTS
);
1497 DEBUG_OFF(nsm
, NSM_STATUS
);
1498 DEBUG_OFF(nsm
, NSM_TIMERS
);
1499 DEBUG_OFF(zebra
, ZEBRA
);
1500 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1501 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1503 for (i
= 0; i
< 5; i
++)
1504 DEBUG_PACKET_OFF(i
, flag
);
1507 for (i
= 0; i
< 5; i
++)
1508 TERM_DEBUG_PACKET_OFF(i
, flag
);
1510 TERM_DEBUG_OFF(event
, EVENT
);
1511 TERM_DEBUG_OFF(ism
, ISM
);
1512 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
1513 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
1514 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
1515 TERM_DEBUG_OFF(lsa
, LSA
);
1516 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1517 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1518 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1519 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1520 TERM_DEBUG_OFF(nsm
, NSM
);
1521 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
1522 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
1523 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
1524 TERM_DEBUG_OFF(nssa
, NSSA
);
1525 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1526 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1527 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1532 static int show_debugging_ospf_common(struct vty
*vty
, struct ospf
*ospf
)
1537 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
1539 vty_out(vty
, "OSPF debugging status:\n");
1541 /* Show debug status for events. */
1542 if (IS_DEBUG_OSPF(event
, EVENT
))
1543 vty_out(vty
, " OSPF event debugging is on\n");
1545 /* Show debug status for ISM. */
1546 if (IS_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1547 vty_out(vty
, " OSPF ISM debugging is on\n");
1549 if (IS_DEBUG_OSPF(ism
, ISM_STATUS
))
1550 vty_out(vty
, " OSPF ISM status debugging is on\n");
1551 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
1552 vty_out(vty
, " OSPF ISM event debugging is on\n");
1553 if (IS_DEBUG_OSPF(ism
, ISM_TIMERS
))
1554 vty_out(vty
, " OSPF ISM timer debugging is on\n");
1557 /* Show debug status for NSM. */
1558 if (IS_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1559 vty_out(vty
, " OSPF NSM debugging is on\n");
1561 if (IS_DEBUG_OSPF(nsm
, NSM_STATUS
))
1562 vty_out(vty
, " OSPF NSM status debugging is on\n");
1563 if (IS_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1564 vty_out(vty
, " OSPF NSM event debugging is on\n");
1565 if (IS_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1566 vty_out(vty
, " OSPF NSM timer debugging is on\n");
1569 /* Show debug status for OSPF Packets. */
1570 for (i
= 0; i
< 5; i
++)
1571 if (IS_DEBUG_OSPF_PACKET(i
, SEND
)
1572 && IS_DEBUG_OSPF_PACKET(i
, RECV
)) {
1573 vty_out(vty
, " OSPF packet %s%s debugging is on\n",
1574 lookup_msg(ospf_packet_type_str
, i
+ 1, NULL
),
1575 IS_DEBUG_OSPF_PACKET(i
, DETAIL
) ? " detail"
1578 if (IS_DEBUG_OSPF_PACKET(i
, SEND
))
1580 " OSPF packet %s send%s debugging is on\n",
1581 lookup_msg(ospf_packet_type_str
, i
+ 1,
1583 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1586 if (IS_DEBUG_OSPF_PACKET(i
, RECV
))
1588 " OSPF packet %s receive%s debugging is on\n",
1589 lookup_msg(ospf_packet_type_str
, i
+ 1,
1591 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1596 /* Show debug status for OSPF LSAs. */
1597 if (IS_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1598 vty_out(vty
, " OSPF LSA debugging is on\n");
1600 if (IS_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1601 vty_out(vty
, " OSPF LSA generation debugging is on\n");
1602 if (IS_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1603 vty_out(vty
, " OSPF LSA flooding debugging is on\n");
1604 if (IS_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1605 vty_out(vty
, " OSPF LSA install debugging is on\n");
1606 if (IS_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1607 vty_out(vty
, " OSPF LSA refresh debugging is on\n");
1610 /* Show debug status for Zebra. */
1611 if (IS_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1612 vty_out(vty
, " OSPF Zebra debugging is on\n");
1614 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1616 " OSPF Zebra interface debugging is on\n");
1617 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1619 " OSPF Zebra redistribute debugging is on\n");
1622 /* Show debug status for NSSA. */
1623 if (IS_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1624 vty_out(vty
, " OSPF NSSA debugging is on\n");
1631 DEFUN_NOSH (show_debugging_ospf
,
1632 show_debugging_ospf_cmd
,
1633 "show debugging [ospf]",
1638 struct ospf
*ospf
= NULL
;
1640 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1644 return show_debugging_ospf_common(vty
, ospf
);
1647 DEFUN_NOSH (show_debugging_ospf_instance
,
1648 show_debugging_ospf_instance_cmd
,
1649 "show debugging ospf (1-65535)",
1657 u_short instance
= 0;
1659 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1660 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
)
1663 return show_debugging_ospf_common(vty
, ospf
);
1667 static struct cmd_node debug_node
= {
1668 DEBUG_NODE
, "", 1 /* VTYSH */
1671 static int config_write_debug(struct vty
*vty
)
1676 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update",
1678 const char *detail_str
[] = {
1679 "", " send", " recv", "",
1680 " detail", " send detail", " recv detail", " detail"};
1686 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1691 sprintf(str
, " %d", ospf
->instance
);
1693 /* debug ospf ism (status|events|timers). */
1694 if (IS_CONF_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1695 vty_out(vty
, "debug ospf%s ism\n", str
);
1697 if (IS_CONF_DEBUG_OSPF(ism
, ISM_STATUS
))
1698 vty_out(vty
, "debug ospf%s ism status\n", str
);
1699 if (IS_CONF_DEBUG_OSPF(ism
, ISM_EVENTS
))
1700 vty_out(vty
, "debug ospf%s ism event\n", str
);
1701 if (IS_CONF_DEBUG_OSPF(ism
, ISM_TIMERS
))
1702 vty_out(vty
, "debug ospf%s ism timer\n", str
);
1705 /* debug ospf nsm (status|events|timers). */
1706 if (IS_CONF_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1707 vty_out(vty
, "debug ospf%s nsm\n", str
);
1709 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_STATUS
))
1710 vty_out(vty
, "debug ospf%s nsm status\n", str
);
1711 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1712 vty_out(vty
, "debug ospf%s nsm event\n", str
);
1713 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1714 vty_out(vty
, "debug ospf%s nsm timer\n", str
);
1717 /* debug ospf lsa (generate|flooding|install|refresh). */
1718 if (IS_CONF_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1719 vty_out(vty
, "debug ospf%s lsa\n", str
);
1721 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1722 vty_out(vty
, "debug ospf%s lsa generate\n", str
);
1723 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1724 vty_out(vty
, "debug ospf%s lsa flooding\n", str
);
1725 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1726 vty_out(vty
, "debug ospf%s lsa install\n", str
);
1727 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1728 vty_out(vty
, "debug ospf%s lsa refresh\n", str
);
1733 /* debug ospf zebra (interface|redistribute). */
1734 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1735 vty_out(vty
, "debug ospf%s zebra\n", str
);
1737 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1738 vty_out(vty
, "debug ospf%s zebra interface\n", str
);
1739 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1740 vty_out(vty
, "debug ospf%s zebra redistribute\n", str
);
1745 /* debug ospf event. */
1746 if (IS_CONF_DEBUG_OSPF(event
, EVENT
) == OSPF_DEBUG_EVENT
) {
1747 vty_out(vty
, "debug ospf%s event\n", str
);
1751 /* debug ospf nssa. */
1752 if (IS_CONF_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
) {
1753 vty_out(vty
, "debug ospf%s nssa\n", str
);
1757 /* debug ospf packet all detail. */
1758 r
= OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
;
1759 for (i
= 0; i
< 5; i
++)
1760 r
&= conf_debug_ospf_packet
[i
]
1761 & (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
);
1762 if (r
== (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
)) {
1763 vty_out(vty
, "debug ospf%s packet all detail\n", str
);
1767 /* debug ospf packet all. */
1768 r
= OSPF_DEBUG_SEND_RECV
;
1769 for (i
= 0; i
< 5; i
++)
1770 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
1771 if (r
== OSPF_DEBUG_SEND_RECV
) {
1772 vty_out(vty
, "debug ospf%s packet all\n", str
);
1773 for (i
= 0; i
< 5; i
++)
1774 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
1775 vty_out(vty
, "debug ospf%s packet %s detail\n",
1780 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1781 (send|recv) (detail). */
1782 for (i
= 0; i
< 5; i
++) {
1783 if (conf_debug_ospf_packet
[i
] == 0)
1786 vty_out(vty
, "debug ospf%s packet %s%s\n", str
, type_str
[i
],
1787 detail_str
[conf_debug_ospf_packet
[i
]]);
1792 if (IS_CONF_DEBUG_OSPF(te
, TE
) == OSPF_DEBUG_TE
) {
1793 vty_out(vty
, "debug ospf%s te\n", str
);
1798 if (IS_CONF_DEBUG_OSPF(sr
, SR
) == OSPF_DEBUG_SR
) {
1799 vty_out(vty
, "debug ospf%s sr\n", str
);
1806 /* Initialize debug commands. */
1809 install_node(&debug_node
, config_write_debug
);
1811 install_element(ENABLE_NODE
, &show_debugging_ospf_cmd
);
1812 install_element(ENABLE_NODE
, &debug_ospf_ism_cmd
);
1813 install_element(ENABLE_NODE
, &debug_ospf_nsm_cmd
);
1814 install_element(ENABLE_NODE
, &debug_ospf_lsa_cmd
);
1815 install_element(ENABLE_NODE
, &debug_ospf_zebra_cmd
);
1816 install_element(ENABLE_NODE
, &debug_ospf_event_cmd
);
1817 install_element(ENABLE_NODE
, &debug_ospf_nssa_cmd
);
1818 install_element(ENABLE_NODE
, &debug_ospf_te_cmd
);
1819 install_element(ENABLE_NODE
, &debug_ospf_sr_cmd
);
1820 install_element(ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
1821 install_element(ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
1822 install_element(ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
1823 install_element(ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
1824 install_element(ENABLE_NODE
, &no_debug_ospf_event_cmd
);
1825 install_element(ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
1826 install_element(ENABLE_NODE
, &no_debug_ospf_te_cmd
);
1827 install_element(ENABLE_NODE
, &no_debug_ospf_sr_cmd
);
1829 install_element(ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
1830 install_element(ENABLE_NODE
, &debug_ospf_packet_cmd
);
1831 install_element(ENABLE_NODE
, &no_debug_ospf_packet_cmd
);
1833 install_element(ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
1834 install_element(ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
1835 install_element(ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
1836 install_element(ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
1837 install_element(ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
1838 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1839 install_element(ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1840 install_element(ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1841 install_element(ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
1842 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1843 install_element(ENABLE_NODE
, &no_debug_ospf_cmd
);
1845 install_element(CONFIG_NODE
, &debug_ospf_packet_cmd
);
1846 install_element(CONFIG_NODE
, &no_debug_ospf_packet_cmd
);
1847 install_element(CONFIG_NODE
, &debug_ospf_ism_cmd
);
1848 install_element(CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
1850 install_element(CONFIG_NODE
, &debug_ospf_nsm_cmd
);
1851 install_element(CONFIG_NODE
, &debug_ospf_lsa_cmd
);
1852 install_element(CONFIG_NODE
, &debug_ospf_zebra_cmd
);
1853 install_element(CONFIG_NODE
, &debug_ospf_event_cmd
);
1854 install_element(CONFIG_NODE
, &debug_ospf_nssa_cmd
);
1855 install_element(CONFIG_NODE
, &debug_ospf_te_cmd
);
1856 install_element(CONFIG_NODE
, &debug_ospf_sr_cmd
);
1857 install_element(CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
1858 install_element(CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
1859 install_element(CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
1860 install_element(CONFIG_NODE
, &no_debug_ospf_event_cmd
);
1861 install_element(CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
1862 install_element(CONFIG_NODE
, &no_debug_ospf_te_cmd
);
1863 install_element(CONFIG_NODE
, &no_debug_ospf_sr_cmd
);
1865 install_element(CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
1866 install_element(CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
1867 install_element(CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
1868 install_element(CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
1869 install_element(CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
1870 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1871 install_element(CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1872 install_element(CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1873 install_element(CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
1874 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1875 install_element(CONFIG_NODE
, &no_debug_ospf_cmd
);