3 * Copyright (C) 1999, 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 #include "ospfd/ospfd.h"
34 #include "ospfd/ospf_interface.h"
35 #include "ospfd/ospf_ism.h"
36 #include "ospfd/ospf_asbr.h"
37 #include "ospfd/ospf_lsa.h"
38 #include "ospfd/ospf_lsdb.h"
39 #include "ospfd/ospf_neighbor.h"
40 #include "ospfd/ospf_nsm.h"
41 #include "ospfd/ospf_dump.h"
42 #include "ospfd/ospf_packet.h"
43 #include "ospfd/ospf_network.h"
45 /* Configuration debug option variables. */
46 unsigned long conf_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
47 unsigned long conf_debug_ospf_event
= 0;
48 unsigned long conf_debug_ospf_ism
= 0;
49 unsigned long conf_debug_ospf_nsm
= 0;
50 unsigned long conf_debug_ospf_lsa
= 0;
51 unsigned long conf_debug_ospf_zebra
= 0;
52 unsigned long conf_debug_ospf_nssa
= 0;
53 unsigned long conf_debug_ospf_te
= 0;
54 unsigned long conf_debug_ospf_ext
= 0;
55 unsigned long conf_debug_ospf_sr
= 0;
56 unsigned long conf_debug_ospf_defaultinfo
= 0;
57 unsigned long conf_debug_ospf_ldp_sync
= 0;
59 /* Enable debug option variables -- valid only session. */
60 unsigned long term_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
61 unsigned long term_debug_ospf_event
;
62 unsigned long term_debug_ospf_ism
= 0;
63 unsigned long term_debug_ospf_nsm
= 0;
64 unsigned long term_debug_ospf_lsa
= 0;
65 unsigned long term_debug_ospf_zebra
= 0;
66 unsigned long term_debug_ospf_nssa
= 0;
67 unsigned long term_debug_ospf_te
= 0;
68 unsigned long term_debug_ospf_ext
= 0;
69 unsigned long term_debug_ospf_sr
= 0;
70 unsigned long term_debug_ospf_defaultinfo
;
71 unsigned long term_debug_ospf_ldp_sync
;
73 const char *ospf_redist_string(unsigned int route_type
)
75 return (route_type
== ZEBRA_ROUTE_MAX
) ? "Default"
76 : zebra_route_string(route_type
);
79 #define OSPF_AREA_STRING_MAXLEN 16
80 const char *ospf_area_name_string(struct ospf_area
*area
)
82 static char buf
[OSPF_AREA_STRING_MAXLEN
] = "";
88 area_id
= ntohl(area
->area_id
.s_addr
);
89 snprintf(buf
, sizeof(buf
), "%d.%d.%d.%d", (area_id
>> 24) & 0xff,
90 (area_id
>> 16) & 0xff, (area_id
>> 8) & 0xff, area_id
& 0xff);
94 #define OSPF_AREA_DESC_STRING_MAXLEN 23
95 const char *ospf_area_desc_string(struct ospf_area
*area
)
97 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
101 return "(incomplete)";
103 type
= area
->external_routing
;
106 snprintf(buf
, sizeof(buf
), "%s [NSSA]",
107 ospf_area_name_string(area
));
110 snprintf(buf
, sizeof(buf
), "%s [Stub]",
111 ospf_area_name_string(area
));
114 return ospf_area_name_string(area
);
120 #define OSPF_IF_STRING_MAXLEN 40
121 const char *ospf_if_name_string(struct ospf_interface
*oi
)
123 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
126 if (!oi
|| !oi
->address
)
129 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
130 return oi
->ifp
->name
;
132 ifaddr
= ntohl(oi
->address
->u
.prefix4
.s_addr
);
133 snprintf(buf
, sizeof(buf
), "%s:%d.%d.%d.%d", oi
->ifp
->name
,
134 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
135 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
140 void ospf_nbr_state_message(struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
143 struct ospf_interface
*oi
= nbr
->oi
;
145 if (IPV4_ADDR_SAME(&DR(oi
), &nbr
->address
.u
.prefix4
))
147 else if (IPV4_ADDR_SAME(&BDR(oi
), &nbr
->address
.u
.prefix4
))
152 snprintf(buf
, size
, "%s/%s",
153 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
),
154 lookup_msg(ospf_ism_state_msg
, state
, NULL
));
157 const char *ospf_timeval_dump(struct timeval
*t
, char *buf
, size_t size
)
159 /* Making formatted timer strings. */
160 #define MINUTE_IN_SECONDS 60
161 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
162 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
163 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
164 unsigned long w
, d
, h
, m
, ms
, us
;
169 w
= d
= h
= m
= ms
= 0;
170 memset(buf
, 0, size
);
176 (void)us
; /* unused */
180 t
->tv_sec
+= ms
/ 1000;
184 if (t
->tv_sec
> WEEK_IN_SECONDS
) {
185 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
186 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
189 if (t
->tv_sec
> DAY_IN_SECONDS
) {
190 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
191 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
194 if (t
->tv_sec
>= HOUR_IN_SECONDS
) {
195 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
196 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
199 if (t
->tv_sec
>= MINUTE_IN_SECONDS
) {
200 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
201 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
205 snprintf(buf
, size
, "%luw%1lud", w
, d
);
207 snprintf(buf
, size
, "%luw%1lud%02luh", w
, d
, h
);
209 snprintf(buf
, size
, "%1lud%02luh%02lum", d
, h
, m
);
211 snprintf(buf
, size
, "%luh%02lum%02lds", h
, m
, (long)t
->tv_sec
);
213 snprintf(buf
, size
, "%lum%02lds", m
, (long)t
->tv_sec
);
215 snprintf(buf
, size
, "%ld.%03lus", (long)t
->tv_sec
, ms
);
217 snprintf(buf
, size
, "%ld usecs", (long)t
->tv_usec
);
222 const char *ospf_timer_dump(struct thread
*t
, char *buf
, size_t size
)
224 struct timeval result
;
228 monotime_until(&t
->u
.sands
, &result
);
229 return ospf_timeval_dump(&result
, buf
, size
);
232 static void ospf_packet_hello_dump(struct stream
*s
, uint16_t length
)
234 struct ospf_hello
*hello
;
237 hello
= (struct ospf_hello
*)stream_pnt(s
);
240 zlog_debug(" NetworkMask %s", inet_ntoa(hello
->network_mask
));
241 zlog_debug(" HelloInterval %d", ntohs(hello
->hello_interval
));
242 zlog_debug(" Options %d (%s)", hello
->options
,
243 ospf_options_dump(hello
->options
));
244 zlog_debug(" RtrPriority %d", hello
->priority
);
245 zlog_debug(" RtrDeadInterval %ld",
246 (unsigned long)ntohl(hello
->dead_interval
));
247 zlog_debug(" DRouter %s", inet_ntoa(hello
->d_router
));
248 zlog_debug(" BDRouter %s", inet_ntoa(hello
->bd_router
));
250 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
251 zlog_debug(" # Neighbors %d", length
/ 4);
252 for (i
= 0; length
> 0; i
++, length
-= sizeof(struct in_addr
))
253 zlog_debug(" Neighbor %s", inet_ntoa(hello
->neighbors
[i
]));
256 static char *ospf_dd_flags_dump(uint8_t flags
, char *buf
, size_t size
)
258 snprintf(buf
, size
, "%s|%s|%s", (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
259 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
260 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
265 static char *ospf_router_lsa_flags_dump(uint8_t flags
, char *buf
, size_t size
)
267 snprintf(buf
, size
, "%s|%s|%s",
268 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
269 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
270 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
275 static void ospf_router_lsa_dump(struct stream
*s
, uint16_t length
)
278 struct router_lsa
*rl
;
281 rl
= (struct router_lsa
*)stream_pnt(s
);
283 zlog_debug(" Router-LSA");
284 zlog_debug(" flags %s",
285 ospf_router_lsa_flags_dump(rl
->flags
, buf
, BUFSIZ
));
286 zlog_debug(" # links %d", ntohs(rl
->links
));
288 len
= ntohs(rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
289 for (i
= 0; len
> 0; i
++) {
290 zlog_debug(" Link ID %s", inet_ntoa(rl
->link
[i
].link_id
));
291 zlog_debug(" Link Data %s",
292 inet_ntoa(rl
->link
[i
].link_data
));
293 zlog_debug(" Type %d", (uint8_t)rl
->link
[i
].type
);
294 zlog_debug(" TOS %d", (uint8_t)rl
->link
[i
].tos
);
295 zlog_debug(" metric %d", ntohs(rl
->link
[i
].metric
));
301 static void ospf_network_lsa_dump(struct stream
*s
, uint16_t length
)
303 struct network_lsa
*nl
;
306 nl
= (struct network_lsa
*)stream_pnt(s
);
307 cnt
= (ntohs(nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
309 zlog_debug(" Network-LSA");
311 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
312 zlog_debug ("Network-LSA size %d",
313 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
315 zlog_debug(" Network Mask %s", inet_ntoa(nl
->mask
));
316 zlog_debug(" # Attached Routers %d", cnt
);
317 for (i
= 0; i
< cnt
; i
++)
318 zlog_debug(" Attached Router %s",
319 inet_ntoa(nl
->routers
[i
]));
322 static void ospf_summary_lsa_dump(struct stream
*s
, uint16_t length
)
324 struct summary_lsa
*sl
;
328 sl
= (struct summary_lsa
*)stream_pnt(s
);
330 zlog_debug(" Summary-LSA");
331 zlog_debug(" Network Mask %s", inet_ntoa(sl
->mask
));
333 size
= ntohs(sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
334 for (i
= 0; size
> 0; size
-= 4, i
++)
335 zlog_debug(" TOS=%d metric %d", sl
->tos
,
336 GET_METRIC(sl
->metric
));
339 static void ospf_as_external_lsa_dump(struct stream
*s
, uint16_t length
)
341 struct as_external_lsa
*al
;
345 al
= (struct as_external_lsa
*)stream_pnt(s
);
346 zlog_debug(" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
347 zlog_debug(" Network Mask %s", inet_ntoa(al
->mask
));
349 size
= ntohs(al
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
350 for (i
= 0; size
> 0; size
-= 12, i
++) {
351 zlog_debug(" bit %s TOS=%d metric %d",
352 IS_EXTERNAL_METRIC(al
->e
[i
].tos
) ? "E" : "-",
353 al
->e
[i
].tos
& 0x7f, GET_METRIC(al
->e
[i
].metric
));
354 zlog_debug(" Forwarding address %s",
355 inet_ntoa(al
->e
[i
].fwd_addr
));
356 zlog_debug(" External Route Tag %" ROUTE_TAG_PRI
,
361 static void ospf_lsa_header_list_dump(struct stream
*s
, uint16_t length
)
363 struct lsa_header
*lsa
;
365 zlog_debug(" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
369 lsa
= (struct lsa_header
*)stream_pnt(s
);
370 ospf_lsa_header_dump(lsa
);
372 stream_forward_getp(s
, OSPF_LSA_HEADER_SIZE
);
373 length
-= OSPF_LSA_HEADER_SIZE
;
377 static void ospf_packet_db_desc_dump(struct stream
*s
, uint16_t length
)
379 struct ospf_db_desc
*dd
;
384 gp
= stream_get_getp(s
);
385 dd
= (struct ospf_db_desc
*)stream_pnt(s
);
387 zlog_debug("Database Description");
388 zlog_debug(" Interface MTU %d", ntohs(dd
->mtu
));
389 zlog_debug(" Options %d (%s)", dd
->options
,
390 ospf_options_dump(dd
->options
));
391 zlog_debug(" Flags %d (%s)", dd
->flags
,
392 ospf_dd_flags_dump(dd
->flags
, dd_flags
, sizeof(dd_flags
)));
393 zlog_debug(" Sequence Number 0x%08lx",
394 (unsigned long)ntohl(dd
->dd_seqnum
));
396 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
398 stream_forward_getp(s
, OSPF_DB_DESC_MIN_SIZE
);
400 ospf_lsa_header_list_dump(s
, length
);
402 stream_set_getp(s
, gp
);
405 static void ospf_packet_ls_req_dump(struct stream
*s
, uint16_t length
)
409 struct in_addr ls_id
;
410 struct in_addr adv_router
;
412 sp
= stream_get_getp(s
);
414 length
-= OSPF_HEADER_SIZE
;
416 zlog_debug("Link State Request");
417 zlog_debug(" # Requests %d", length
/ 12);
419 for (; length
> 0; length
-= 12) {
420 ls_type
= stream_getl(s
);
421 ls_id
.s_addr
= stream_get_ipv4(s
);
422 adv_router
.s_addr
= stream_get_ipv4(s
);
424 zlog_debug(" LS type %d", ls_type
);
425 zlog_debug(" Link State ID %s", inet_ntoa(ls_id
));
426 zlog_debug(" Advertising Router %s", inet_ntoa(adv_router
));
429 stream_set_getp(s
, sp
);
432 static void ospf_packet_ls_upd_dump(struct stream
*s
, uint16_t length
)
435 struct lsa_header
*lsa
;
439 length
-= OSPF_HEADER_SIZE
;
441 sp
= stream_get_getp(s
);
443 count
= stream_getl(s
);
446 zlog_debug("Link State Update");
447 zlog_debug(" # LSAs %d", count
);
449 while (length
> 0 && count
> 0) {
450 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0) {
451 zlog_debug(" Remaining %d bytes; Incorrect length.",
456 lsa
= (struct lsa_header
*)stream_pnt(s
);
457 lsa_len
= ntohs(lsa
->length
);
458 ospf_lsa_header_dump(lsa
);
461 case OSPF_ROUTER_LSA
:
462 ospf_router_lsa_dump(s
, length
);
464 case OSPF_NETWORK_LSA
:
465 ospf_network_lsa_dump(s
, length
);
467 case OSPF_SUMMARY_LSA
:
468 case OSPF_ASBR_SUMMARY_LSA
:
469 ospf_summary_lsa_dump(s
, length
);
471 case OSPF_AS_EXTERNAL_LSA
:
472 ospf_as_external_lsa_dump(s
, length
);
474 case OSPF_AS_NSSA_LSA
:
475 ospf_as_external_lsa_dump(s
, length
);
477 case OSPF_OPAQUE_LINK_LSA
:
478 case OSPF_OPAQUE_AREA_LSA
:
479 case OSPF_OPAQUE_AS_LSA
:
480 ospf_opaque_lsa_dump(s
, length
);
486 stream_forward_getp(s
, lsa_len
);
491 stream_set_getp(s
, sp
);
494 static void ospf_packet_ls_ack_dump(struct stream
*s
, uint16_t length
)
498 length
-= OSPF_HEADER_SIZE
;
499 sp
= stream_get_getp(s
);
501 zlog_debug("Link State Acknowledgment");
502 ospf_lsa_header_list_dump(s
, length
);
504 stream_set_getp(s
, sp
);
507 static void ospf_header_dump(struct ospf_header
*ospfh
)
510 uint16_t auth_type
= ntohs(ospfh
->auth_type
);
512 zlog_debug("Header");
513 zlog_debug(" Version %d", ospfh
->version
);
514 zlog_debug(" Type %d (%s)", ospfh
->type
,
515 lookup_msg(ospf_packet_type_str
, ospfh
->type
, NULL
));
516 zlog_debug(" Packet Len %d", ntohs(ospfh
->length
));
517 zlog_debug(" Router ID %s", inet_ntoa(ospfh
->router_id
));
518 zlog_debug(" Area ID %s", inet_ntoa(ospfh
->area_id
));
519 zlog_debug(" Checksum 0x%x", ntohs(ospfh
->checksum
));
520 zlog_debug(" AuType %s",
521 lookup_msg(ospf_auth_type_str
, auth_type
, NULL
));
526 case OSPF_AUTH_SIMPLE
:
527 strlcpy(buf
, (char *)ospfh
->u
.auth_data
, sizeof(buf
));
528 zlog_debug(" Simple Password %s", buf
);
530 case OSPF_AUTH_CRYPTOGRAPHIC
:
531 zlog_debug(" Cryptographic Authentication");
532 zlog_debug(" Key ID %d", ospfh
->u
.crypt
.key_id
);
533 zlog_debug(" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
534 zlog_debug(" Sequence number %ld",
535 (unsigned long)ntohl(ospfh
->u
.crypt
.crypt_seqnum
));
538 zlog_debug("* This is not supported authentication type");
543 void ospf_packet_dump(struct stream
*s
)
545 struct ospf_header
*ospfh
;
548 /* Preserve pointer. */
549 gp
= stream_get_getp(s
);
551 /* OSPF Header dump. */
552 ospfh
= (struct ospf_header
*)stream_pnt(s
);
554 /* Until detail flag is set, return. */
555 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
558 /* Show OSPF header detail. */
559 ospf_header_dump(ospfh
);
560 stream_forward_getp(s
, OSPF_HEADER_SIZE
);
562 switch (ospfh
->type
) {
564 ospf_packet_hello_dump(s
, ntohs(ospfh
->length
));
566 case OSPF_MSG_DB_DESC
:
567 ospf_packet_db_desc_dump(s
, ntohs(ospfh
->length
));
569 case OSPF_MSG_LS_REQ
:
570 ospf_packet_ls_req_dump(s
, ntohs(ospfh
->length
));
572 case OSPF_MSG_LS_UPD
:
573 ospf_packet_ls_upd_dump(s
, ntohs(ospfh
->length
));
575 case OSPF_MSG_LS_ACK
:
576 ospf_packet_ls_ack_dump(s
, ntohs(ospfh
->length
));
582 stream_set_getp(s
, gp
);
585 DEFUN (debug_ospf_packet
,
586 debug_ospf_packet_cmd
,
587 "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
593 "OSPF Database Description\n"
594 "OSPF Link State Request\n"
595 "OSPF Link State Update\n"
596 "OSPF Link State Acknowledgment\n"
599 "Detail Information\n"
601 "Detail Information\n"
602 "Detail Information\n")
604 int inst
= (argv
[2]->type
== RANGE_TKN
) ? 1 : 0;
605 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
606 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
607 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
608 char *packet
= argv
[3 + inst
]->text
;
610 if (inst
) // user passed instance ID
612 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
613 return CMD_NOT_MY_INSTANCE
;
620 /* Check packet type. */
621 if (strmatch(packet
, "hello"))
622 type
= OSPF_DEBUG_HELLO
;
623 else if (strmatch(packet
, "dd"))
624 type
= OSPF_DEBUG_DB_DESC
;
625 else if (strmatch(packet
, "ls-request"))
626 type
= OSPF_DEBUG_LS_REQ
;
627 else if (strmatch(packet
, "ls-update"))
628 type
= OSPF_DEBUG_LS_UPD
;
629 else if (strmatch(packet
, "ls-ack"))
630 type
= OSPF_DEBUG_LS_ACK
;
631 else if (strmatch(packet
, "all"))
632 type
= OSPF_DEBUG_ALL
;
635 * (none) = send + recv
636 * detail = send + recv + detail
639 * recv detail = recv + detail
640 * send detail = send + detail
645 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
646 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
647 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
649 for (i
= 0; i
< 5; i
++)
650 if (type
& (0x01 << i
)) {
651 if (vty
->node
== CONFIG_NODE
)
652 DEBUG_PACKET_ON(i
, flag
);
654 TERM_DEBUG_PACKET_ON(i
, flag
);
660 DEFUN (no_debug_ospf_packet
,
661 no_debug_ospf_packet_cmd
,
662 "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
669 "OSPF Database Description\n"
670 "OSPF Link State Request\n"
671 "OSPF Link State Update\n"
672 "OSPF Link State Acknowledgment\n"
675 "Detail Information\n"
677 "Detail Information\n"
678 "Detail Information\n")
680 int inst
= (argv
[3]->type
== RANGE_TKN
) ? 1 : 0;
681 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
682 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
683 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
684 char *packet
= argv
[4 + inst
]->text
;
686 if (inst
) // user passed instance ID
688 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
689 return CMD_NOT_MY_INSTANCE
;
696 /* Check packet type. */
697 if (strmatch(packet
, "hello"))
698 type
= OSPF_DEBUG_HELLO
;
699 else if (strmatch(packet
, "dd"))
700 type
= OSPF_DEBUG_DB_DESC
;
701 else if (strmatch(packet
, "ls-request"))
702 type
= OSPF_DEBUG_LS_REQ
;
703 else if (strmatch(packet
, "ls-update"))
704 type
= OSPF_DEBUG_LS_UPD
;
705 else if (strmatch(packet
, "ls-ack"))
706 type
= OSPF_DEBUG_LS_ACK
;
707 else if (strmatch(packet
, "all"))
708 type
= OSPF_DEBUG_ALL
;
711 * (none) = send + recv
712 * detail = send + recv + detail
715 * recv detail = recv + detail
716 * send detail = send + detail
721 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
722 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
723 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
725 for (i
= 0; i
< 5; i
++)
726 if (type
& (0x01 << i
)) {
727 if (vty
->node
== CONFIG_NODE
)
728 DEBUG_PACKET_OFF(i
, flag
);
730 TERM_DEBUG_PACKET_OFF(i
, flag
);
735 for (i = 0; i < 5; i++)
736 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
743 DEFUN (debug_ospf_ism
,
745 "debug ospf [(1-65535)] ism [<status|events|timers>]",
749 "OSPF Interface State Machine\n"
750 "ISM Status Information\n"
751 "ISM Event Information\n"
752 "ISM TImer Information\n")
754 int inst
= (argv
[2]->type
== RANGE_TKN
);
755 char *dbgparam
= (argc
== 4 + inst
) ? argv
[argc
- 1]->text
: NULL
;
757 if (inst
) // user passed instance ID
759 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
760 return CMD_NOT_MY_INSTANCE
;
763 if (vty
->node
== CONFIG_NODE
) {
767 if (strmatch(dbgparam
, "status"))
768 DEBUG_ON(ism
, ISM_STATUS
);
769 else if (strmatch(dbgparam
, "events"))
770 DEBUG_ON(ism
, ISM_EVENTS
);
771 else if (strmatch(dbgparam
, "timers"))
772 DEBUG_ON(ism
, ISM_TIMERS
);
780 TERM_DEBUG_ON(ism
, ISM
);
782 if (strmatch(dbgparam
, "status"))
783 TERM_DEBUG_ON(ism
, ISM_STATUS
);
784 else if (strmatch(dbgparam
, "events"))
785 TERM_DEBUG_ON(ism
, ISM_EVENTS
);
786 else if (strmatch(dbgparam
, "timers"))
787 TERM_DEBUG_ON(ism
, ISM_TIMERS
);
793 DEFUN (no_debug_ospf_ism
,
794 no_debug_ospf_ism_cmd
,
795 "no debug ospf [(1-65535)] ism [<status|events|timers>]",
800 "OSPF Interface State Machine\n"
801 "ISM Status Information\n"
802 "ISM Event Information\n"
803 "ISM TImer Information\n")
805 int inst
= (argv
[3]->type
== RANGE_TKN
);
806 char *dbgparam
= (argc
== 5 + inst
) ? argv
[argc
- 1]->text
: NULL
;
808 if (inst
) // user passed instance ID
810 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
811 return CMD_NOT_MY_INSTANCE
;
814 if (vty
->node
== CONFIG_NODE
) {
818 if (strmatch(dbgparam
, "status"))
819 DEBUG_OFF(ism
, ISM_STATUS
);
820 else if (strmatch(dbgparam
, "events"))
821 DEBUG_OFF(ism
, ISM_EVENTS
);
822 else if (strmatch(dbgparam
, "timers"))
823 DEBUG_OFF(ism
, ISM_TIMERS
);
831 TERM_DEBUG_OFF(ism
, ISM
);
833 if (strmatch(dbgparam
, "status"))
834 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
835 else if (strmatch(dbgparam
, "events"))
836 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
837 else if (strmatch(dbgparam
, "timers"))
838 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
844 static int debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
845 struct cmd_token
**argv
)
847 if (vty
->node
== CONFIG_NODE
) {
848 if (argc
== arg_base
+ 0)
850 else if (argc
== arg_base
+ 1) {
851 if (strmatch(argv
[arg_base
]->text
, "status"))
852 DEBUG_ON(nsm
, NSM_STATUS
);
853 else if (strmatch(argv
[arg_base
]->text
, "events"))
854 DEBUG_ON(nsm
, NSM_EVENTS
);
855 else if (strmatch(argv
[arg_base
]->text
, "timers"))
856 DEBUG_ON(nsm
, NSM_TIMERS
);
863 if (argc
== arg_base
+ 0)
864 TERM_DEBUG_ON(nsm
, NSM
);
865 else if (argc
== arg_base
+ 1) {
866 if (strmatch(argv
[arg_base
]->text
, "status"))
867 TERM_DEBUG_ON(nsm
, NSM_STATUS
);
868 else if (strmatch(argv
[arg_base
]->text
, "events"))
869 TERM_DEBUG_ON(nsm
, NSM_EVENTS
);
870 else if (strmatch(argv
[arg_base
]->text
, "timers"))
871 TERM_DEBUG_ON(nsm
, NSM_TIMERS
);
877 DEFUN (debug_ospf_nsm
,
879 "debug ospf nsm [<status|events|timers>]",
882 "OSPF Neighbor State Machine\n"
883 "NSM Status Information\n"
884 "NSM Event Information\n"
885 "NSM Timer Information\n")
887 return debug_ospf_nsm_common(vty
, 3, argc
, argv
);
890 DEFUN (debug_ospf_instance_nsm
,
891 debug_ospf_instance_nsm_cmd
,
892 "debug ospf (1-65535) nsm [<status|events|timers>]",
896 "OSPF Neighbor State Machine\n"
897 "NSM Status Information\n"
898 "NSM Event Information\n"
899 "NSM Timer Information\n")
902 unsigned short instance
= 0;
904 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
905 if (!ospf_lookup_instance(instance
))
908 return debug_ospf_nsm_common(vty
, 4, argc
, argv
);
912 static int no_debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
913 struct cmd_token
**argv
)
916 if (vty
->node
== CONFIG_NODE
) {
917 if (argc
== arg_base
+ 0)
919 else if (argc
== arg_base
+ 1) {
920 if (strmatch(argv
[arg_base
]->text
, "status"))
921 DEBUG_OFF(nsm
, NSM_STATUS
);
922 else if (strmatch(argv
[arg_base
]->text
, "events"))
923 DEBUG_OFF(nsm
, NSM_EVENTS
);
924 else if (strmatch(argv
[arg_base
]->text
, "timers"))
925 DEBUG_OFF(nsm
, NSM_TIMERS
);
932 if (argc
== arg_base
+ 0)
933 TERM_DEBUG_OFF(nsm
, NSM
);
934 else if (argc
== arg_base
+ 1) {
935 if (strmatch(argv
[arg_base
]->text
, "status"))
936 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
937 else if (strmatch(argv
[arg_base
]->text
, "events"))
938 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
939 else if (strmatch(argv
[arg_base
]->text
, "timers"))
940 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
946 DEFUN (no_debug_ospf_nsm
,
947 no_debug_ospf_nsm_cmd
,
948 "no debug ospf nsm [<status|events|timers>]",
952 "OSPF Neighbor State Machine\n"
953 "NSM Status Information\n"
954 "NSM Event Information\n"
955 "NSM Timer Information\n")
957 return no_debug_ospf_nsm_common(vty
, 4, argc
, argv
);
961 DEFUN (no_debug_ospf_instance_nsm
,
962 no_debug_ospf_instance_nsm_cmd
,
963 "no debug ospf (1-65535) nsm [<status|events|timers>]",
968 "OSPF Neighbor State Machine\n"
969 "NSM Status Information\n"
970 "NSM Event Information\n"
971 "NSM Timer Information\n")
974 unsigned short instance
= 0;
976 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
977 if (!ospf_lookup_instance(instance
))
978 return CMD_NOT_MY_INSTANCE
;
980 return no_debug_ospf_nsm_common(vty
, 5, argc
, argv
);
984 static int debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
985 struct cmd_token
**argv
)
987 if (vty
->node
== CONFIG_NODE
) {
988 if (argc
== arg_base
+ 0)
990 else if (argc
== arg_base
+ 1) {
991 if (strmatch(argv
[arg_base
]->text
, "generate"))
992 DEBUG_ON(lsa
, LSA_GENERATE
);
993 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
994 DEBUG_ON(lsa
, LSA_FLOODING
);
995 else if (strmatch(argv
[arg_base
]->text
, "install"))
996 DEBUG_ON(lsa
, LSA_INSTALL
);
997 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
998 DEBUG_ON(lsa
, LSA_REFRESH
);
1005 if (argc
== arg_base
+ 0)
1006 TERM_DEBUG_ON(lsa
, LSA
);
1007 else if (argc
== arg_base
+ 1) {
1008 if (strmatch(argv
[arg_base
]->text
, "generate"))
1009 TERM_DEBUG_ON(lsa
, LSA_GENERATE
);
1010 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1011 TERM_DEBUG_ON(lsa
, LSA_FLOODING
);
1012 else if (strmatch(argv
[arg_base
]->text
, "install"))
1013 TERM_DEBUG_ON(lsa
, LSA_INSTALL
);
1014 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1015 TERM_DEBUG_ON(lsa
, LSA_REFRESH
);
1021 DEFUN (debug_ospf_lsa
,
1023 "debug ospf lsa [<generate|flooding|install|refresh>]",
1026 "OSPF Link State Advertisement\n"
1029 "LSA Install/Delete\n"
1032 return debug_ospf_lsa_common(vty
, 3, argc
, argv
);
1035 DEFUN (debug_ospf_instance_lsa
,
1036 debug_ospf_instance_lsa_cmd
,
1037 "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1041 "OSPF Link State Advertisement\n"
1044 "LSA Install/Delete\n"
1048 unsigned short instance
= 0;
1050 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1051 if (!ospf_lookup_instance(instance
))
1052 return CMD_NOT_MY_INSTANCE
;
1054 return debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1058 static int no_debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
1059 struct cmd_token
**argv
)
1061 if (vty
->node
== CONFIG_NODE
) {
1062 if (argc
== arg_base
+ 0)
1063 DEBUG_OFF(lsa
, LSA
);
1064 else if (argc
== arg_base
+ 1) {
1065 if (strmatch(argv
[arg_base
]->text
, "generate"))
1066 DEBUG_OFF(lsa
, LSA_GENERATE
);
1067 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1068 DEBUG_OFF(lsa
, LSA_FLOODING
);
1069 else if (strmatch(argv
[arg_base
]->text
, "install"))
1070 DEBUG_OFF(lsa
, LSA_INSTALL
);
1071 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1072 DEBUG_OFF(lsa
, LSA_REFRESH
);
1079 if (argc
== arg_base
+ 0)
1080 TERM_DEBUG_OFF(lsa
, LSA
);
1081 else if (argc
== arg_base
+ 1) {
1082 if (strmatch(argv
[arg_base
]->text
, "generate"))
1083 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1084 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1085 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1086 else if (strmatch(argv
[arg_base
]->text
, "install"))
1087 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1088 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1089 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1095 DEFUN (no_debug_ospf_lsa
,
1096 no_debug_ospf_lsa_cmd
,
1097 "no debug ospf lsa [<generate|flooding|install|refresh>]",
1101 "OSPF Link State Advertisement\n"
1104 "LSA Install/Delete\n"
1107 return no_debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1110 DEFUN (no_debug_ospf_instance_lsa
,
1111 no_debug_ospf_instance_lsa_cmd
,
1112 "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1117 "OSPF Link State Advertisement\n"
1120 "LSA Install/Delete\n"
1124 unsigned short instance
= 0;
1126 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1127 if (!ospf_lookup_instance(instance
))
1128 return CMD_NOT_MY_INSTANCE
;
1130 return no_debug_ospf_lsa_common(vty
, 5, argc
, argv
);
1134 static int debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1135 struct cmd_token
**argv
)
1137 if (vty
->node
== CONFIG_NODE
) {
1138 if (argc
== arg_base
+ 0)
1139 DEBUG_ON(zebra
, ZEBRA
);
1140 else if (argc
== arg_base
+ 1) {
1141 if (strmatch(argv
[arg_base
]->text
, "interface"))
1142 DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1143 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1144 DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1151 if (argc
== arg_base
+ 0)
1152 TERM_DEBUG_ON(zebra
, ZEBRA
);
1153 else if (argc
== arg_base
+ 1) {
1154 if (strmatch(argv
[arg_base
]->text
, "interface"))
1155 TERM_DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1156 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1157 TERM_DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1163 DEFUN (debug_ospf_zebra
,
1164 debug_ospf_zebra_cmd
,
1165 "debug ospf zebra [<interface|redistribute>]",
1170 "Zebra redistribute\n")
1172 return debug_ospf_zebra_common(vty
, 3, argc
, argv
);
1175 DEFUN (debug_ospf_instance_zebra
,
1176 debug_ospf_instance_zebra_cmd
,
1177 "debug ospf (1-65535) zebra [<interface|redistribute>]",
1183 "Zebra redistribute\n")
1186 unsigned short instance
= 0;
1188 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1189 if (!ospf_lookup_instance(instance
))
1190 return CMD_NOT_MY_INSTANCE
;
1192 return debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1196 static int no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1197 struct cmd_token
**argv
)
1199 if (vty
->node
== CONFIG_NODE
) {
1200 if (argc
== arg_base
+ 0)
1201 DEBUG_OFF(zebra
, ZEBRA
);
1202 else if (argc
== arg_base
+ 1) {
1203 if (strmatch(argv
[arg_base
]->text
, "interface"))
1204 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1205 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1206 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1213 if (argc
== arg_base
+ 0)
1214 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1215 else if (argc
== arg_base
+ 1) {
1216 if (strmatch(argv
[arg_base
]->text
, "interface"))
1217 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1218 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1219 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1225 DEFUN (no_debug_ospf_zebra
,
1226 no_debug_ospf_zebra_cmd
,
1227 "no debug ospf zebra [<interface|redistribute>]",
1233 "Zebra redistribute\n")
1235 return no_debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1238 DEFUN (no_debug_ospf_instance_zebra
,
1239 no_debug_ospf_instance_zebra_cmd
,
1240 "no debug ospf (1-65535) zebra [<interface|redistribute>]",
1247 "Zebra redistribute\n")
1250 unsigned short instance
= 0;
1252 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1253 if (!ospf_lookup_instance(instance
))
1256 return no_debug_ospf_zebra_common(vty
, 5, argc
, argv
);
1260 DEFUN (debug_ospf_event
,
1261 debug_ospf_event_cmd
,
1265 "OSPF event information\n")
1267 if (vty
->node
== CONFIG_NODE
)
1268 CONF_DEBUG_ON(event
, EVENT
);
1269 TERM_DEBUG_ON(event
, EVENT
);
1273 DEFUN (no_debug_ospf_event
,
1274 no_debug_ospf_event_cmd
,
1275 "no debug ospf event",
1279 "OSPF event information\n")
1281 if (vty
->node
== CONFIG_NODE
)
1282 CONF_DEBUG_OFF(event
, EVENT
);
1283 TERM_DEBUG_OFF(event
, EVENT
);
1287 DEFUN (debug_ospf_instance_event
,
1288 debug_ospf_instance_event_cmd
,
1289 "debug ospf (1-65535) event",
1293 "OSPF event information\n")
1296 unsigned short instance
= 0;
1298 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1299 if (!ospf_lookup_instance(instance
))
1302 if (vty
->node
== CONFIG_NODE
)
1303 CONF_DEBUG_ON(event
, EVENT
);
1304 TERM_DEBUG_ON(event
, EVENT
);
1308 DEFUN (no_debug_ospf_instance_event
,
1309 no_debug_ospf_instance_event_cmd
,
1310 "no debug ospf (1-65535) event",
1315 "OSPF event information\n")
1318 unsigned short instance
= 0;
1320 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1321 if (!ospf_lookup_instance(instance
))
1324 if (vty
->node
== CONFIG_NODE
)
1325 CONF_DEBUG_OFF(event
, EVENT
);
1326 TERM_DEBUG_OFF(event
, EVENT
);
1330 DEFUN (debug_ospf_nssa
,
1331 debug_ospf_nssa_cmd
,
1335 "OSPF nssa information\n")
1337 if (vty
->node
== CONFIG_NODE
)
1338 CONF_DEBUG_ON(nssa
, NSSA
);
1339 TERM_DEBUG_ON(nssa
, NSSA
);
1343 DEFUN (no_debug_ospf_nssa
,
1344 no_debug_ospf_nssa_cmd
,
1345 "no debug ospf nssa",
1349 "OSPF nssa information\n")
1351 if (vty
->node
== CONFIG_NODE
)
1352 CONF_DEBUG_OFF(nssa
, NSSA
);
1353 TERM_DEBUG_OFF(nssa
, NSSA
);
1357 DEFUN (debug_ospf_instance_nssa
,
1358 debug_ospf_instance_nssa_cmd
,
1359 "debug ospf (1-65535) nssa",
1363 "OSPF nssa information\n")
1366 unsigned short instance
= 0;
1368 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1369 if (!ospf_lookup_instance(instance
))
1372 if (vty
->node
== CONFIG_NODE
)
1373 CONF_DEBUG_ON(nssa
, NSSA
);
1374 TERM_DEBUG_ON(nssa
, NSSA
);
1378 DEFUN (no_debug_ospf_instance_nssa
,
1379 no_debug_ospf_instance_nssa_cmd
,
1380 "no debug ospf (1-65535) nssa",
1385 "OSPF nssa information\n")
1388 unsigned short instance
= 0;
1390 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1391 if (!ospf_lookup_instance(instance
))
1394 if (vty
->node
== CONFIG_NODE
)
1395 CONF_DEBUG_OFF(nssa
, NSSA
);
1396 TERM_DEBUG_OFF(nssa
, NSSA
);
1400 DEFUN (debug_ospf_te
,
1405 "OSPF-TE information\n")
1407 if (vty
->node
== CONFIG_NODE
)
1408 CONF_DEBUG_ON(te
, TE
);
1409 TERM_DEBUG_ON(te
, TE
);
1413 DEFUN (no_debug_ospf_te
,
1414 no_debug_ospf_te_cmd
,
1419 "OSPF-TE information\n")
1421 if (vty
->node
== CONFIG_NODE
)
1422 CONF_DEBUG_OFF(te
, TE
);
1423 TERM_DEBUG_OFF(te
, TE
);
1427 DEFUN (debug_ospf_sr
,
1432 "OSPF-SR information\n")
1434 if (vty
->node
== CONFIG_NODE
)
1435 CONF_DEBUG_ON(sr
, SR
);
1436 TERM_DEBUG_ON(sr
, SR
);
1440 DEFUN (no_debug_ospf_sr
,
1441 no_debug_ospf_sr_cmd
,
1446 "OSPF-SR information\n")
1448 if (vty
->node
== CONFIG_NODE
)
1449 CONF_DEBUG_OFF(sr
, SR
);
1450 TERM_DEBUG_OFF(sr
, SR
);
1454 DEFUN (debug_ospf_default_info
,
1455 debug_ospf_default_info_cmd
,
1456 "debug ospf default-information",
1459 "OSPF default information\n")
1461 if (vty
->node
== CONFIG_NODE
)
1462 CONF_DEBUG_ON(defaultinfo
, DEFAULTINFO
);
1463 TERM_DEBUG_ON(defaultinfo
, DEFAULTINFO
);
1467 DEFUN (no_debug_ospf_default_info
,
1468 no_debug_ospf_default_info_cmd
,
1469 "no debug ospf default-information",
1473 "OSPF default information\n")
1475 if (vty
->node
== CONFIG_NODE
)
1476 CONF_DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1477 TERM_DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1481 DEFUN(debug_ospf_ldp_sync
,
1482 debug_ospf_ldp_sync_cmd
,
1483 "debug ospf ldp-sync",
1485 "OSPF LDP-Sync information\n")
1487 if (vty
->node
== CONFIG_NODE
)
1488 CONF_DEBUG_ON(ldp_sync
, LDP_SYNC
);
1489 TERM_DEBUG_ON(ldp_sync
, LDP_SYNC
);
1493 DEFUN(no_debug_ospf_ldp_sync
,
1494 no_debug_ospf_ldp_sync_cmd
,
1495 "no debug ospf ldp-sync",
1499 "OSPF LDP-Sync information\n")
1501 if (vty
->node
== CONFIG_NODE
)
1502 CONF_DEBUG_OFF(ldp_sync
, LDP_SYNC
);
1503 TERM_DEBUG_OFF(ldp_sync
, LDP_SYNC
);
1507 DEFUN (no_debug_ospf
,
1514 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1517 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
);
1535 DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1536 DEBUG_OFF(ldp_sync
, LDP_SYNC
);
1538 for (i
= 0; i
< 5; i
++)
1539 DEBUG_PACKET_OFF(i
, flag
);
1542 for (i
= 0; i
< 5; i
++)
1543 TERM_DEBUG_PACKET_OFF(i
, flag
);
1545 TERM_DEBUG_OFF(event
, EVENT
);
1546 TERM_DEBUG_OFF(ism
, ISM
);
1547 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
1548 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
1549 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
1550 TERM_DEBUG_OFF(lsa
, LSA
);
1551 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1552 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1553 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1554 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1555 TERM_DEBUG_OFF(nsm
, NSM
);
1556 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
1557 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
1558 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
1559 TERM_DEBUG_OFF(nssa
, NSSA
);
1560 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1561 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1562 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1563 TERM_DEBUG_OFF(defaultinfo
, DEFAULTINFO
);
1564 TERM_DEBUG_OFF(ldp_sync
, LDP_SYNC
);
1569 static int show_debugging_ospf_common(struct vty
*vty
, struct ospf
*ospf
)
1574 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
1576 vty_out(vty
, "OSPF debugging status:\n");
1578 /* Show debug status for events. */
1579 if (IS_DEBUG_OSPF(event
, EVENT
))
1580 vty_out(vty
, " OSPF event debugging is on\n");
1582 /* Show debug status for ISM. */
1583 if (IS_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1584 vty_out(vty
, " OSPF ISM debugging is on\n");
1586 if (IS_DEBUG_OSPF(ism
, ISM_STATUS
))
1587 vty_out(vty
, " OSPF ISM status debugging is on\n");
1588 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
1589 vty_out(vty
, " OSPF ISM event debugging is on\n");
1590 if (IS_DEBUG_OSPF(ism
, ISM_TIMERS
))
1591 vty_out(vty
, " OSPF ISM timer debugging is on\n");
1594 /* Show debug status for NSM. */
1595 if (IS_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1596 vty_out(vty
, " OSPF NSM debugging is on\n");
1598 if (IS_DEBUG_OSPF(nsm
, NSM_STATUS
))
1599 vty_out(vty
, " OSPF NSM status debugging is on\n");
1600 if (IS_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1601 vty_out(vty
, " OSPF NSM event debugging is on\n");
1602 if (IS_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1603 vty_out(vty
, " OSPF NSM timer debugging is on\n");
1606 /* Show debug status for OSPF Packets. */
1607 for (i
= 0; i
< 5; i
++)
1608 if (IS_DEBUG_OSPF_PACKET(i
, SEND
)
1609 && IS_DEBUG_OSPF_PACKET(i
, RECV
)) {
1610 vty_out(vty
, " OSPF packet %s%s debugging is on\n",
1611 lookup_msg(ospf_packet_type_str
, i
+ 1, NULL
),
1612 IS_DEBUG_OSPF_PACKET(i
, DETAIL
) ? " detail"
1615 if (IS_DEBUG_OSPF_PACKET(i
, SEND
))
1617 " OSPF packet %s send%s debugging is on\n",
1618 lookup_msg(ospf_packet_type_str
, i
+ 1,
1620 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1623 if (IS_DEBUG_OSPF_PACKET(i
, RECV
))
1625 " OSPF packet %s receive%s debugging is on\n",
1626 lookup_msg(ospf_packet_type_str
, i
+ 1,
1628 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1633 /* Show debug status for OSPF LSAs. */
1634 if (IS_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1635 vty_out(vty
, " OSPF LSA debugging is on\n");
1637 if (IS_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1638 vty_out(vty
, " OSPF LSA generation debugging is on\n");
1639 if (IS_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1640 vty_out(vty
, " OSPF LSA flooding debugging is on\n");
1641 if (IS_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1642 vty_out(vty
, " OSPF LSA install debugging is on\n");
1643 if (IS_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1644 vty_out(vty
, " OSPF LSA refresh debugging is on\n");
1647 /* Show debug status for Zebra. */
1648 if (IS_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1649 vty_out(vty
, " OSPF Zebra debugging is on\n");
1651 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1653 " OSPF Zebra interface debugging is on\n");
1654 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1656 " OSPF Zebra redistribute debugging is on\n");
1659 if (IS_DEBUG_OSPF(defaultinfo
, DEFAULTINFO
) == OSPF_DEBUG_DEFAULTINFO
)
1660 vty_out(vty
, "OSPF default information is on\n");
1662 /* Show debug status for NSSA. */
1663 if (IS_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1664 vty_out(vty
, " OSPF NSSA debugging is on\n");
1666 /* Show debug status for LDP-SYNC. */
1667 if (IS_DEBUG_OSPF(ldp_sync
, LDP_SYNC
) == OSPF_DEBUG_LDP_SYNC
)
1668 vty_out(vty
, " OSPF ldp-sync debugging is on\n");
1675 DEFUN_NOSH (show_debugging_ospf
,
1676 show_debugging_ospf_cmd
,
1677 "show debugging [ospf]",
1682 struct ospf
*ospf
= NULL
;
1684 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1688 return show_debugging_ospf_common(vty
, ospf
);
1691 DEFUN_NOSH (show_debugging_ospf_instance
,
1692 show_debugging_ospf_instance_cmd
,
1693 "show debugging ospf (1-65535)",
1701 unsigned short instance
= 0;
1703 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1704 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
)
1707 return show_debugging_ospf_common(vty
, ospf
);
1710 static int config_write_debug(struct vty
*vty
);
1712 static struct cmd_node debug_node
= {
1716 .config_write
= config_write_debug
,
1719 static int config_write_debug(struct vty
*vty
)
1724 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update",
1726 const char *detail_str
[] = {
1727 "", " send", " recv", "",
1728 " detail", " send detail", " recv detail", " detail"};
1734 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1739 snprintf(str
, sizeof(str
), " %u", ospf
->instance
);
1741 /* debug ospf ism (status|events|timers). */
1742 if (IS_CONF_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1743 vty_out(vty
, "debug ospf%s ism\n", str
);
1745 if (IS_CONF_DEBUG_OSPF(ism
, ISM_STATUS
))
1746 vty_out(vty
, "debug ospf%s ism status\n", str
);
1747 if (IS_CONF_DEBUG_OSPF(ism
, ISM_EVENTS
))
1748 vty_out(vty
, "debug ospf%s ism event\n", str
);
1749 if (IS_CONF_DEBUG_OSPF(ism
, ISM_TIMERS
))
1750 vty_out(vty
, "debug ospf%s ism timer\n", str
);
1753 /* debug ospf nsm (status|events|timers). */
1754 if (IS_CONF_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1755 vty_out(vty
, "debug ospf%s nsm\n", str
);
1757 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_STATUS
))
1758 vty_out(vty
, "debug ospf%s nsm status\n", str
);
1759 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1760 vty_out(vty
, "debug ospf%s nsm event\n", str
);
1761 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1762 vty_out(vty
, "debug ospf%s nsm timer\n", str
);
1765 /* debug ospf lsa (generate|flooding|install|refresh). */
1766 if (IS_CONF_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1767 vty_out(vty
, "debug ospf%s lsa\n", str
);
1769 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1770 vty_out(vty
, "debug ospf%s lsa generate\n", str
);
1771 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1772 vty_out(vty
, "debug ospf%s lsa flooding\n", str
);
1773 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1774 vty_out(vty
, "debug ospf%s lsa install\n", str
);
1775 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1776 vty_out(vty
, "debug ospf%s lsa refresh\n", str
);
1781 /* debug ospf zebra (interface|redistribute). */
1782 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1783 vty_out(vty
, "debug ospf%s zebra\n", str
);
1785 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1786 vty_out(vty
, "debug ospf%s zebra interface\n", str
);
1787 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1788 vty_out(vty
, "debug ospf%s zebra redistribute\n", str
);
1793 /* debug ospf event. */
1794 if (IS_CONF_DEBUG_OSPF(event
, EVENT
) == OSPF_DEBUG_EVENT
) {
1795 vty_out(vty
, "debug ospf%s event\n", str
);
1799 /* debug ospf nssa. */
1800 if (IS_CONF_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
) {
1801 vty_out(vty
, "debug ospf%s nssa\n", str
);
1805 /* debug ospf packet all detail. */
1806 r
= OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
;
1807 for (i
= 0; i
< 5; i
++)
1808 r
&= conf_debug_ospf_packet
[i
]
1809 & (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
);
1810 if (r
== (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
)) {
1811 vty_out(vty
, "debug ospf%s packet all detail\n", str
);
1815 /* debug ospf packet all. */
1816 r
= OSPF_DEBUG_SEND_RECV
;
1817 for (i
= 0; i
< 5; i
++)
1818 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
1819 if (r
== OSPF_DEBUG_SEND_RECV
) {
1820 vty_out(vty
, "debug ospf%s packet all\n", str
);
1821 for (i
= 0; i
< 5; i
++)
1822 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
1823 vty_out(vty
, "debug ospf%s packet %s detail\n",
1828 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1829 (send|recv) (detail). */
1830 for (i
= 0; i
< 5; i
++) {
1831 if (conf_debug_ospf_packet
[i
] == 0)
1834 vty_out(vty
, "debug ospf%s packet %s%s\n", str
, type_str
[i
],
1835 detail_str
[conf_debug_ospf_packet
[i
]]);
1840 if (IS_CONF_DEBUG_OSPF(te
, TE
) == OSPF_DEBUG_TE
) {
1841 vty_out(vty
, "debug ospf%s te\n", str
);
1846 if (IS_CONF_DEBUG_OSPF(sr
, SR
) == OSPF_DEBUG_SR
) {
1847 vty_out(vty
, "debug ospf%s sr\n", str
);
1851 /* debug ospf ldp-sync */
1852 if (IS_CONF_DEBUG_OSPF(ldp_sync
, LDP_SYNC
) == OSPF_DEBUG_LDP_SYNC
) {
1853 vty_out(vty
, "debug ospf%s ldp-sync\n", str
);
1859 /* Initialize debug commands. */
1860 void ospf_debug_init(void)
1862 install_node(&debug_node
);
1864 install_element(ENABLE_NODE
, &show_debugging_ospf_cmd
);
1865 install_element(ENABLE_NODE
, &debug_ospf_ism_cmd
);
1866 install_element(ENABLE_NODE
, &debug_ospf_nsm_cmd
);
1867 install_element(ENABLE_NODE
, &debug_ospf_lsa_cmd
);
1868 install_element(ENABLE_NODE
, &debug_ospf_zebra_cmd
);
1869 install_element(ENABLE_NODE
, &debug_ospf_event_cmd
);
1870 install_element(ENABLE_NODE
, &debug_ospf_nssa_cmd
);
1871 install_element(ENABLE_NODE
, &debug_ospf_te_cmd
);
1872 install_element(ENABLE_NODE
, &debug_ospf_sr_cmd
);
1873 install_element(ENABLE_NODE
, &debug_ospf_default_info_cmd
);
1874 install_element(ENABLE_NODE
, &debug_ospf_ldp_sync_cmd
);
1875 install_element(ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
1876 install_element(ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
1877 install_element(ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
1878 install_element(ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
1879 install_element(ENABLE_NODE
, &no_debug_ospf_event_cmd
);
1880 install_element(ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
1881 install_element(ENABLE_NODE
, &no_debug_ospf_te_cmd
);
1882 install_element(ENABLE_NODE
, &no_debug_ospf_sr_cmd
);
1883 install_element(ENABLE_NODE
, &no_debug_ospf_default_info_cmd
);
1884 install_element(ENABLE_NODE
, &no_debug_ospf_ldp_sync_cmd
);
1886 install_element(ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
1887 install_element(ENABLE_NODE
, &debug_ospf_packet_cmd
);
1888 install_element(ENABLE_NODE
, &no_debug_ospf_packet_cmd
);
1890 install_element(ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
1891 install_element(ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
1892 install_element(ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
1893 install_element(ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
1894 install_element(ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
1895 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1896 install_element(ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1897 install_element(ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1898 install_element(ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
1899 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1900 install_element(ENABLE_NODE
, &no_debug_ospf_cmd
);
1902 install_element(CONFIG_NODE
, &debug_ospf_packet_cmd
);
1903 install_element(CONFIG_NODE
, &no_debug_ospf_packet_cmd
);
1904 install_element(CONFIG_NODE
, &debug_ospf_ism_cmd
);
1905 install_element(CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
1907 install_element(CONFIG_NODE
, &debug_ospf_nsm_cmd
);
1908 install_element(CONFIG_NODE
, &debug_ospf_lsa_cmd
);
1909 install_element(CONFIG_NODE
, &debug_ospf_zebra_cmd
);
1910 install_element(CONFIG_NODE
, &debug_ospf_event_cmd
);
1911 install_element(CONFIG_NODE
, &debug_ospf_nssa_cmd
);
1912 install_element(CONFIG_NODE
, &debug_ospf_te_cmd
);
1913 install_element(CONFIG_NODE
, &debug_ospf_sr_cmd
);
1914 install_element(CONFIG_NODE
, &debug_ospf_default_info_cmd
);
1915 install_element(CONFIG_NODE
, &debug_ospf_ldp_sync_cmd
);
1916 install_element(CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
1917 install_element(CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
1918 install_element(CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
1919 install_element(CONFIG_NODE
, &no_debug_ospf_event_cmd
);
1920 install_element(CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
1921 install_element(CONFIG_NODE
, &no_debug_ospf_te_cmd
);
1922 install_element(CONFIG_NODE
, &no_debug_ospf_sr_cmd
);
1923 install_element(CONFIG_NODE
, &no_debug_ospf_default_info_cmd
);
1924 install_element(CONFIG_NODE
, &no_debug_ospf_ldp_sync_cmd
);
1926 install_element(CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
1927 install_element(CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
1928 install_element(CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
1929 install_element(CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
1930 install_element(CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
1931 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1932 install_element(CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1933 install_element(CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1934 install_element(CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
1935 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1936 install_element(CONFIG_NODE
, &no_debug_ospf_cmd
);