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(unsigned 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
, sizeof(buf
), "%d.%d.%d.%d", (area_id
>> 24) & 0xff,
86 (area_id
>> 16) & 0xff, (area_id
>> 8) & 0xff, area_id
& 0xff);
90 #define OSPF_AREA_DESC_STRING_MAXLEN 23
91 const char *ospf_area_desc_string(struct ospf_area
*area
)
93 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
97 return "(incomplete)";
99 type
= area
->external_routing
;
102 snprintf(buf
, sizeof(buf
), "%s [NSSA]",
103 ospf_area_name_string(area
));
106 snprintf(buf
, sizeof(buf
), "%s [Stub]",
107 ospf_area_name_string(area
));
110 return ospf_area_name_string(area
);
116 #define OSPF_IF_STRING_MAXLEN 40
117 const char *ospf_if_name_string(struct ospf_interface
*oi
)
119 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
122 if (!oi
|| !oi
->address
)
125 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
126 return oi
->ifp
->name
;
128 ifaddr
= ntohl(oi
->address
->u
.prefix4
.s_addr
);
129 snprintf(buf
, sizeof(buf
), "%s:%d.%d.%d.%d", oi
->ifp
->name
,
130 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
131 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
136 void ospf_nbr_state_message(struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
139 struct ospf_interface
*oi
= nbr
->oi
;
141 if (IPV4_ADDR_SAME(&DR(oi
), &nbr
->address
.u
.prefix4
))
143 else if (IPV4_ADDR_SAME(&BDR(oi
), &nbr
->address
.u
.prefix4
))
148 snprintf(buf
, size
, "%s/%s",
149 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
),
150 lookup_msg(ospf_ism_state_msg
, state
, NULL
));
153 const char *ospf_timeval_dump(struct timeval
*t
, char *buf
, size_t size
)
155 /* Making formatted timer strings. */
156 #define MINUTE_IN_SECONDS 60
157 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
158 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
159 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
160 unsigned long w
, d
, h
, m
, ms
, us
;
165 w
= d
= h
= m
= ms
= 0;
166 memset(buf
, 0, size
);
172 (void)us
; /* unused */
176 t
->tv_sec
+= ms
/ 1000;
180 if (t
->tv_sec
> WEEK_IN_SECONDS
) {
181 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
182 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
185 if (t
->tv_sec
> DAY_IN_SECONDS
) {
186 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
187 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
190 if (t
->tv_sec
>= HOUR_IN_SECONDS
) {
191 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
192 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
195 if (t
->tv_sec
>= MINUTE_IN_SECONDS
) {
196 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
197 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
201 snprintf(buf
, size
, "%luw%1lud", w
, d
);
203 snprintf(buf
, size
, "%luw%1lud%02luh", w
, d
, h
);
205 snprintf(buf
, size
, "%1lud%02luh%02lum", d
, h
, m
);
207 snprintf(buf
, size
, "%luh%02lum%02lds", h
, m
, (long)t
->tv_sec
);
209 snprintf(buf
, size
, "%lum%02lds", m
, (long)t
->tv_sec
);
211 snprintf(buf
, size
, "%ld.%03lus", (long)t
->tv_sec
, ms
);
213 snprintf(buf
, size
, "%ld usecs", (long)t
->tv_usec
);
218 const char *ospf_timer_dump(struct thread
*t
, char *buf
, size_t size
)
220 struct timeval result
;
224 monotime_until(&t
->u
.sands
, &result
);
225 return ospf_timeval_dump(&result
, buf
, size
);
228 static void ospf_packet_hello_dump(struct stream
*s
, uint16_t length
)
230 struct ospf_hello
*hello
;
233 hello
= (struct ospf_hello
*)stream_pnt(s
);
236 zlog_debug(" NetworkMask %s", inet_ntoa(hello
->network_mask
));
237 zlog_debug(" HelloInterval %d", ntohs(hello
->hello_interval
));
238 zlog_debug(" Options %d (%s)", hello
->options
,
239 ospf_options_dump(hello
->options
));
240 zlog_debug(" RtrPriority %d", hello
->priority
);
241 zlog_debug(" RtrDeadInterval %ld",
242 (unsigned long)ntohl(hello
->dead_interval
));
243 zlog_debug(" DRouter %s", inet_ntoa(hello
->d_router
));
244 zlog_debug(" BDRouter %s", inet_ntoa(hello
->bd_router
));
246 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
247 zlog_debug(" # Neighbors %d", length
/ 4);
248 for (i
= 0; length
> 0; i
++, length
-= sizeof(struct in_addr
))
249 zlog_debug(" Neighbor %s", inet_ntoa(hello
->neighbors
[i
]));
252 static char *ospf_dd_flags_dump(uint8_t flags
, char *buf
, size_t size
)
254 snprintf(buf
, size
, "%s|%s|%s", (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
255 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
256 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
261 static char *ospf_router_lsa_flags_dump(uint8_t flags
, char *buf
, size_t size
)
263 snprintf(buf
, size
, "%s|%s|%s",
264 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
265 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
266 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
271 static void ospf_router_lsa_dump(struct stream
*s
, uint16_t length
)
274 struct router_lsa
*rl
;
277 rl
= (struct router_lsa
*)stream_pnt(s
);
279 zlog_debug(" Router-LSA");
280 zlog_debug(" flags %s",
281 ospf_router_lsa_flags_dump(rl
->flags
, buf
, BUFSIZ
));
282 zlog_debug(" # links %d", ntohs(rl
->links
));
284 len
= ntohs(rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
285 for (i
= 0; len
> 0; i
++) {
286 zlog_debug(" Link ID %s", inet_ntoa(rl
->link
[i
].link_id
));
287 zlog_debug(" Link Data %s",
288 inet_ntoa(rl
->link
[i
].link_data
));
289 zlog_debug(" Type %d", (uint8_t)rl
->link
[i
].type
);
290 zlog_debug(" TOS %d", (uint8_t)rl
->link
[i
].tos
);
291 zlog_debug(" metric %d", ntohs(rl
->link
[i
].metric
));
297 static void ospf_network_lsa_dump(struct stream
*s
, uint16_t length
)
299 struct network_lsa
*nl
;
302 nl
= (struct network_lsa
*)stream_pnt(s
);
303 cnt
= (ntohs(nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
305 zlog_debug(" Network-LSA");
307 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
308 zlog_debug ("Network-LSA size %d",
309 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
311 zlog_debug(" Network Mask %s", inet_ntoa(nl
->mask
));
312 zlog_debug(" # Attached Routers %d", cnt
);
313 for (i
= 0; i
< cnt
; i
++)
314 zlog_debug(" Attached Router %s",
315 inet_ntoa(nl
->routers
[i
]));
318 static void ospf_summary_lsa_dump(struct stream
*s
, uint16_t length
)
320 struct summary_lsa
*sl
;
324 sl
= (struct summary_lsa
*)stream_pnt(s
);
326 zlog_debug(" Summary-LSA");
327 zlog_debug(" Network Mask %s", inet_ntoa(sl
->mask
));
329 size
= ntohs(sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
330 for (i
= 0; size
> 0; size
-= 4, i
++)
331 zlog_debug(" TOS=%d metric %d", sl
->tos
,
332 GET_METRIC(sl
->metric
));
335 static void ospf_as_external_lsa_dump(struct stream
*s
, uint16_t length
)
337 struct as_external_lsa
*al
;
341 al
= (struct as_external_lsa
*)stream_pnt(s
);
342 zlog_debug(" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
343 zlog_debug(" Network Mask %s", inet_ntoa(al
->mask
));
345 size
= ntohs(al
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
346 for (i
= 0; size
> 0; size
-= 12, i
++) {
347 zlog_debug(" bit %s TOS=%d metric %d",
348 IS_EXTERNAL_METRIC(al
->e
[i
].tos
) ? "E" : "-",
349 al
->e
[i
].tos
& 0x7f, GET_METRIC(al
->e
[i
].metric
));
350 zlog_debug(" Forwarding address %s",
351 inet_ntoa(al
->e
[i
].fwd_addr
));
352 zlog_debug(" External Route Tag %" ROUTE_TAG_PRI
,
357 static void ospf_lsa_header_list_dump(struct stream
*s
, uint16_t length
)
359 struct lsa_header
*lsa
;
361 zlog_debug(" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
365 lsa
= (struct lsa_header
*)stream_pnt(s
);
366 ospf_lsa_header_dump(lsa
);
368 stream_forward_getp(s
, OSPF_LSA_HEADER_SIZE
);
369 length
-= OSPF_LSA_HEADER_SIZE
;
373 static void ospf_packet_db_desc_dump(struct stream
*s
, uint16_t length
)
375 struct ospf_db_desc
*dd
;
380 gp
= stream_get_getp(s
);
381 dd
= (struct ospf_db_desc
*)stream_pnt(s
);
383 zlog_debug("Database Description");
384 zlog_debug(" Interface MTU %d", ntohs(dd
->mtu
));
385 zlog_debug(" Options %d (%s)", dd
->options
,
386 ospf_options_dump(dd
->options
));
387 zlog_debug(" Flags %d (%s)", dd
->flags
,
388 ospf_dd_flags_dump(dd
->flags
, dd_flags
, sizeof(dd_flags
)));
389 zlog_debug(" Sequence Number 0x%08lx",
390 (unsigned long)ntohl(dd
->dd_seqnum
));
392 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
394 stream_forward_getp(s
, OSPF_DB_DESC_MIN_SIZE
);
396 ospf_lsa_header_list_dump(s
, length
);
398 stream_set_getp(s
, gp
);
401 static void ospf_packet_ls_req_dump(struct stream
*s
, uint16_t length
)
405 struct in_addr ls_id
;
406 struct in_addr adv_router
;
408 sp
= stream_get_getp(s
);
410 length
-= OSPF_HEADER_SIZE
;
412 zlog_debug("Link State Request");
413 zlog_debug(" # Requests %d", length
/ 12);
415 for (; length
> 0; length
-= 12) {
416 ls_type
= stream_getl(s
);
417 ls_id
.s_addr
= stream_get_ipv4(s
);
418 adv_router
.s_addr
= stream_get_ipv4(s
);
420 zlog_debug(" LS type %d", ls_type
);
421 zlog_debug(" Link State ID %s", inet_ntoa(ls_id
));
422 zlog_debug(" Advertising Router %s", inet_ntoa(adv_router
));
425 stream_set_getp(s
, sp
);
428 static void ospf_packet_ls_upd_dump(struct stream
*s
, uint16_t length
)
431 struct lsa_header
*lsa
;
435 length
-= OSPF_HEADER_SIZE
;
437 sp
= stream_get_getp(s
);
439 count
= stream_getl(s
);
442 zlog_debug("Link State Update");
443 zlog_debug(" # LSAs %d", count
);
445 while (length
> 0 && count
> 0) {
446 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0) {
447 zlog_debug(" Remaining %d bytes; Incorrect length.",
452 lsa
= (struct lsa_header
*)stream_pnt(s
);
453 lsa_len
= ntohs(lsa
->length
);
454 ospf_lsa_header_dump(lsa
);
457 case OSPF_ROUTER_LSA
:
458 ospf_router_lsa_dump(s
, length
);
460 case OSPF_NETWORK_LSA
:
461 ospf_network_lsa_dump(s
, length
);
463 case OSPF_SUMMARY_LSA
:
464 case OSPF_ASBR_SUMMARY_LSA
:
465 ospf_summary_lsa_dump(s
, length
);
467 case OSPF_AS_EXTERNAL_LSA
:
468 ospf_as_external_lsa_dump(s
, length
);
470 case OSPF_AS_NSSA_LSA
:
471 ospf_as_external_lsa_dump(s
, length
);
473 case OSPF_OPAQUE_LINK_LSA
:
474 case OSPF_OPAQUE_AREA_LSA
:
475 case OSPF_OPAQUE_AS_LSA
:
476 ospf_opaque_lsa_dump(s
, length
);
482 stream_forward_getp(s
, lsa_len
);
487 stream_set_getp(s
, sp
);
490 static void ospf_packet_ls_ack_dump(struct stream
*s
, uint16_t length
)
494 length
-= OSPF_HEADER_SIZE
;
495 sp
= stream_get_getp(s
);
497 zlog_debug("Link State Acknowledgment");
498 ospf_lsa_header_list_dump(s
, length
);
500 stream_set_getp(s
, sp
);
503 static void ospf_header_dump(struct ospf_header
*ospfh
)
506 uint16_t auth_type
= ntohs(ospfh
->auth_type
);
508 zlog_debug("Header");
509 zlog_debug(" Version %d", ospfh
->version
);
510 zlog_debug(" Type %d (%s)", ospfh
->type
,
511 lookup_msg(ospf_packet_type_str
, ospfh
->type
, NULL
));
512 zlog_debug(" Packet Len %d", ntohs(ospfh
->length
));
513 zlog_debug(" Router ID %s", inet_ntoa(ospfh
->router_id
));
514 zlog_debug(" Area ID %s", inet_ntoa(ospfh
->area_id
));
515 zlog_debug(" Checksum 0x%x", ntohs(ospfh
->checksum
));
516 zlog_debug(" AuType %s",
517 lookup_msg(ospf_auth_type_str
, auth_type
, NULL
));
522 case OSPF_AUTH_SIMPLE
:
523 strlcpy(buf
, (char *)ospfh
->u
.auth_data
, sizeof(buf
));
524 zlog_debug(" Simple Password %s", buf
);
526 case OSPF_AUTH_CRYPTOGRAPHIC
:
527 zlog_debug(" Cryptographic Authentication");
528 zlog_debug(" Key ID %d", ospfh
->u
.crypt
.key_id
);
529 zlog_debug(" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
530 zlog_debug(" Sequence number %ld",
531 (unsigned long)ntohl(ospfh
->u
.crypt
.crypt_seqnum
));
534 zlog_debug("* This is not supported authentication type");
539 void ospf_packet_dump(struct stream
*s
)
541 struct ospf_header
*ospfh
;
544 /* Preserve pointer. */
545 gp
= stream_get_getp(s
);
547 /* OSPF Header dump. */
548 ospfh
= (struct ospf_header
*)stream_pnt(s
);
550 /* Until detail flag is set, return. */
551 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
554 /* Show OSPF header detail. */
555 ospf_header_dump(ospfh
);
556 stream_forward_getp(s
, OSPF_HEADER_SIZE
);
558 switch (ospfh
->type
) {
560 ospf_packet_hello_dump(s
, ntohs(ospfh
->length
));
562 case OSPF_MSG_DB_DESC
:
563 ospf_packet_db_desc_dump(s
, ntohs(ospfh
->length
));
565 case OSPF_MSG_LS_REQ
:
566 ospf_packet_ls_req_dump(s
, ntohs(ospfh
->length
));
568 case OSPF_MSG_LS_UPD
:
569 ospf_packet_ls_upd_dump(s
, ntohs(ospfh
->length
));
571 case OSPF_MSG_LS_ACK
:
572 ospf_packet_ls_ack_dump(s
, ntohs(ospfh
->length
));
578 stream_set_getp(s
, gp
);
581 DEFUN (debug_ospf_packet
,
582 debug_ospf_packet_cmd
,
583 "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
589 "OSPF Database Description\n"
590 "OSPF Link State Request\n"
591 "OSPF Link State Update\n"
592 "OSPF Link State Acknowledgment\n"
595 "Detail Information\n"
597 "Detail Information\n"
598 "Detail Information\n")
600 int inst
= (argv
[2]->type
== RANGE_TKN
) ? 1 : 0;
601 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
602 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
603 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
604 char *packet
= argv
[3 + inst
]->text
;
606 if (inst
) // user passed instance ID
608 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
609 return CMD_NOT_MY_INSTANCE
;
616 /* Check packet type. */
617 if (strmatch(packet
, "hello"))
618 type
= OSPF_DEBUG_HELLO
;
619 else if (strmatch(packet
, "dd"))
620 type
= OSPF_DEBUG_DB_DESC
;
621 else if (strmatch(packet
, "ls-request"))
622 type
= OSPF_DEBUG_LS_REQ
;
623 else if (strmatch(packet
, "ls-update"))
624 type
= OSPF_DEBUG_LS_UPD
;
625 else if (strmatch(packet
, "ls-ack"))
626 type
= OSPF_DEBUG_LS_ACK
;
627 else if (strmatch(packet
, "all"))
628 type
= OSPF_DEBUG_ALL
;
631 * (none) = send + recv
632 * detail = send + recv + detail
635 * recv detail = recv + detail
636 * send detail = send + detail
641 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
642 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
643 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
645 for (i
= 0; i
< 5; i
++)
646 if (type
& (0x01 << i
)) {
647 if (vty
->node
== CONFIG_NODE
)
648 DEBUG_PACKET_ON(i
, flag
);
650 TERM_DEBUG_PACKET_ON(i
, flag
);
656 DEFUN (no_debug_ospf_packet
,
657 no_debug_ospf_packet_cmd
,
658 "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
665 "OSPF Database Description\n"
666 "OSPF Link State Request\n"
667 "OSPF Link State Update\n"
668 "OSPF Link State Acknowledgment\n"
671 "Detail Information\n"
673 "Detail Information\n"
674 "Detail Information\n")
676 int inst
= (argv
[3]->type
== RANGE_TKN
) ? 1 : 0;
677 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
678 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
679 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
680 char *packet
= argv
[4 + inst
]->text
;
682 if (inst
) // user passed instance ID
684 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
685 return CMD_NOT_MY_INSTANCE
;
692 /* Check packet type. */
693 if (strmatch(packet
, "hello"))
694 type
= OSPF_DEBUG_HELLO
;
695 else if (strmatch(packet
, "dd"))
696 type
= OSPF_DEBUG_DB_DESC
;
697 else if (strmatch(packet
, "ls-request"))
698 type
= OSPF_DEBUG_LS_REQ
;
699 else if (strmatch(packet
, "ls-update"))
700 type
= OSPF_DEBUG_LS_UPD
;
701 else if (strmatch(packet
, "ls-ack"))
702 type
= OSPF_DEBUG_LS_ACK
;
703 else if (strmatch(packet
, "all"))
704 type
= OSPF_DEBUG_ALL
;
707 * (none) = send + recv
708 * detail = send + recv + detail
711 * recv detail = recv + detail
712 * send detail = send + detail
717 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
718 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
719 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
721 for (i
= 0; i
< 5; i
++)
722 if (type
& (0x01 << i
)) {
723 if (vty
->node
== CONFIG_NODE
)
724 DEBUG_PACKET_OFF(i
, flag
);
726 TERM_DEBUG_PACKET_OFF(i
, flag
);
731 for (i = 0; i < 5; i++)
732 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
739 DEFUN (debug_ospf_ism
,
741 "debug ospf [(1-65535)] ism [<status|events|timers>]",
745 "OSPF Interface State Machine\n"
746 "ISM Status Information\n"
747 "ISM Event Information\n"
748 "ISM TImer Information\n")
750 int inst
= (argv
[2]->type
== RANGE_TKN
);
751 char *dbgparam
= (argc
== 4 + inst
) ? argv
[argc
- 1]->text
: NULL
;
753 if (inst
) // user passed instance ID
755 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
756 return CMD_NOT_MY_INSTANCE
;
759 if (vty
->node
== CONFIG_NODE
) {
763 if (strmatch(dbgparam
, "status"))
764 DEBUG_ON(ism
, ISM_STATUS
);
765 else if (strmatch(dbgparam
, "events"))
766 DEBUG_ON(ism
, ISM_EVENTS
);
767 else if (strmatch(dbgparam
, "timers"))
768 DEBUG_ON(ism
, ISM_TIMERS
);
776 TERM_DEBUG_ON(ism
, ISM
);
778 if (strmatch(dbgparam
, "status"))
779 TERM_DEBUG_ON(ism
, ISM_STATUS
);
780 else if (strmatch(dbgparam
, "events"))
781 TERM_DEBUG_ON(ism
, ISM_EVENTS
);
782 else if (strmatch(dbgparam
, "timers"))
783 TERM_DEBUG_ON(ism
, ISM_TIMERS
);
789 DEFUN (no_debug_ospf_ism
,
790 no_debug_ospf_ism_cmd
,
791 "no debug ospf [(1-65535)] ism [<status|events|timers>]",
796 "OSPF Interface State Machine\n"
797 "ISM Status Information\n"
798 "ISM Event Information\n"
799 "ISM TImer Information\n")
801 int inst
= (argv
[3]->type
== RANGE_TKN
);
802 char *dbgparam
= (argc
== 5 + inst
) ? argv
[argc
- 1]->text
: NULL
;
804 if (inst
) // user passed instance ID
806 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
807 return CMD_NOT_MY_INSTANCE
;
810 if (vty
->node
== CONFIG_NODE
) {
814 if (strmatch(dbgparam
, "status"))
815 DEBUG_OFF(ism
, ISM_STATUS
);
816 else if (strmatch(dbgparam
, "events"))
817 DEBUG_OFF(ism
, ISM_EVENTS
);
818 else if (strmatch(dbgparam
, "timers"))
819 DEBUG_OFF(ism
, ISM_TIMERS
);
827 TERM_DEBUG_OFF(ism
, ISM
);
829 if (strmatch(dbgparam
, "status"))
830 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
831 else if (strmatch(dbgparam
, "events"))
832 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
833 else if (strmatch(dbgparam
, "timers"))
834 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
840 static int debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
841 struct cmd_token
**argv
)
843 if (vty
->node
== CONFIG_NODE
) {
844 if (argc
== arg_base
+ 0)
846 else if (argc
== arg_base
+ 1) {
847 if (strmatch(argv
[arg_base
]->text
, "status"))
848 DEBUG_ON(nsm
, NSM_STATUS
);
849 else if (strmatch(argv
[arg_base
]->text
, "events"))
850 DEBUG_ON(nsm
, NSM_EVENTS
);
851 else if (strmatch(argv
[arg_base
]->text
, "timers"))
852 DEBUG_ON(nsm
, NSM_TIMERS
);
859 if (argc
== arg_base
+ 0)
860 TERM_DEBUG_ON(nsm
, NSM
);
861 else if (argc
== arg_base
+ 1) {
862 if (strmatch(argv
[arg_base
]->text
, "status"))
863 TERM_DEBUG_ON(nsm
, NSM_STATUS
);
864 else if (strmatch(argv
[arg_base
]->text
, "events"))
865 TERM_DEBUG_ON(nsm
, NSM_EVENTS
);
866 else if (strmatch(argv
[arg_base
]->text
, "timers"))
867 TERM_DEBUG_ON(nsm
, NSM_TIMERS
);
873 DEFUN (debug_ospf_nsm
,
875 "debug ospf nsm [<status|events|timers>]",
878 "OSPF Neighbor State Machine\n"
879 "NSM Status Information\n"
880 "NSM Event Information\n"
881 "NSM Timer Information\n")
883 return debug_ospf_nsm_common(vty
, 3, argc
, argv
);
886 DEFUN (debug_ospf_instance_nsm
,
887 debug_ospf_instance_nsm_cmd
,
888 "debug ospf (1-65535) nsm [<status|events|timers>]",
892 "OSPF Neighbor State Machine\n"
893 "NSM Status Information\n"
894 "NSM Event Information\n"
895 "NSM Timer Information\n")
898 unsigned short instance
= 0;
900 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
901 if (!ospf_lookup_instance(instance
))
904 return debug_ospf_nsm_common(vty
, 4, argc
, argv
);
908 static int no_debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
909 struct cmd_token
**argv
)
912 if (vty
->node
== CONFIG_NODE
) {
913 if (argc
== arg_base
+ 0)
915 else if (argc
== arg_base
+ 1) {
916 if (strmatch(argv
[arg_base
]->text
, "status"))
917 DEBUG_OFF(nsm
, NSM_STATUS
);
918 else if (strmatch(argv
[arg_base
]->text
, "events"))
919 DEBUG_OFF(nsm
, NSM_EVENTS
);
920 else if (strmatch(argv
[arg_base
]->text
, "timers"))
921 DEBUG_OFF(nsm
, NSM_TIMERS
);
928 if (argc
== arg_base
+ 0)
929 TERM_DEBUG_OFF(nsm
, NSM
);
930 else if (argc
== arg_base
+ 1) {
931 if (strmatch(argv
[arg_base
]->text
, "status"))
932 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
933 else if (strmatch(argv
[arg_base
]->text
, "events"))
934 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
935 else if (strmatch(argv
[arg_base
]->text
, "timers"))
936 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
942 DEFUN (no_debug_ospf_nsm
,
943 no_debug_ospf_nsm_cmd
,
944 "no debug ospf nsm [<status|events|timers>]",
948 "OSPF Neighbor State Machine\n"
949 "NSM Status Information\n"
950 "NSM Event Information\n"
951 "NSM Timer Information\n")
953 return no_debug_ospf_nsm_common(vty
, 4, argc
, argv
);
957 DEFUN (no_debug_ospf_instance_nsm
,
958 no_debug_ospf_instance_nsm_cmd
,
959 "no debug ospf (1-65535) nsm [<status|events|timers>]",
964 "OSPF Neighbor State Machine\n"
965 "NSM Status Information\n"
966 "NSM Event Information\n"
967 "NSM Timer Information\n")
970 unsigned short instance
= 0;
972 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
973 if (!ospf_lookup_instance(instance
))
974 return CMD_NOT_MY_INSTANCE
;
976 return no_debug_ospf_nsm_common(vty
, 5, argc
, argv
);
980 static int debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
981 struct cmd_token
**argv
)
983 if (vty
->node
== CONFIG_NODE
) {
984 if (argc
== arg_base
+ 0)
986 else if (argc
== arg_base
+ 1) {
987 if (strmatch(argv
[arg_base
]->text
, "generate"))
988 DEBUG_ON(lsa
, LSA_GENERATE
);
989 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
990 DEBUG_ON(lsa
, LSA_FLOODING
);
991 else if (strmatch(argv
[arg_base
]->text
, "install"))
992 DEBUG_ON(lsa
, LSA_INSTALL
);
993 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
994 DEBUG_ON(lsa
, LSA_REFRESH
);
1001 if (argc
== arg_base
+ 0)
1002 TERM_DEBUG_ON(lsa
, LSA
);
1003 else if (argc
== arg_base
+ 1) {
1004 if (strmatch(argv
[arg_base
]->text
, "generate"))
1005 TERM_DEBUG_ON(lsa
, LSA_GENERATE
);
1006 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1007 TERM_DEBUG_ON(lsa
, LSA_FLOODING
);
1008 else if (strmatch(argv
[arg_base
]->text
, "install"))
1009 TERM_DEBUG_ON(lsa
, LSA_INSTALL
);
1010 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1011 TERM_DEBUG_ON(lsa
, LSA_REFRESH
);
1017 DEFUN (debug_ospf_lsa
,
1019 "debug ospf lsa [<generate|flooding|install|refresh>]",
1022 "OSPF Link State Advertisement\n"
1025 "LSA Install/Delete\n"
1028 return debug_ospf_lsa_common(vty
, 3, argc
, argv
);
1031 DEFUN (debug_ospf_instance_lsa
,
1032 debug_ospf_instance_lsa_cmd
,
1033 "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1037 "OSPF Link State Advertisement\n"
1040 "LSA Install/Delete\n"
1044 unsigned short instance
= 0;
1046 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1047 if (!ospf_lookup_instance(instance
))
1048 return CMD_NOT_MY_INSTANCE
;
1050 return debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1054 static int no_debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
1055 struct cmd_token
**argv
)
1057 if (vty
->node
== CONFIG_NODE
) {
1058 if (argc
== arg_base
+ 0)
1059 DEBUG_OFF(lsa
, LSA
);
1060 else if (argc
== arg_base
+ 1) {
1061 if (strmatch(argv
[arg_base
]->text
, "generate"))
1062 DEBUG_OFF(lsa
, LSA_GENERATE
);
1063 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1064 DEBUG_OFF(lsa
, LSA_FLOODING
);
1065 else if (strmatch(argv
[arg_base
]->text
, "install"))
1066 DEBUG_OFF(lsa
, LSA_INSTALL
);
1067 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1068 DEBUG_OFF(lsa
, LSA_REFRESH
);
1075 if (argc
== arg_base
+ 0)
1076 TERM_DEBUG_OFF(lsa
, LSA
);
1077 else if (argc
== arg_base
+ 1) {
1078 if (strmatch(argv
[arg_base
]->text
, "generate"))
1079 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1080 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1081 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1082 else if (strmatch(argv
[arg_base
]->text
, "install"))
1083 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1084 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1085 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1091 DEFUN (no_debug_ospf_lsa
,
1092 no_debug_ospf_lsa_cmd
,
1093 "no debug ospf lsa [<generate|flooding|install|refresh>]",
1097 "OSPF Link State Advertisement\n"
1100 "LSA Install/Delete\n"
1103 return no_debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1106 DEFUN (no_debug_ospf_instance_lsa
,
1107 no_debug_ospf_instance_lsa_cmd
,
1108 "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1113 "OSPF Link State Advertisement\n"
1116 "LSA Install/Delete\n"
1120 unsigned short instance
= 0;
1122 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1123 if (!ospf_lookup_instance(instance
))
1124 return CMD_NOT_MY_INSTANCE
;
1126 return no_debug_ospf_lsa_common(vty
, 5, argc
, argv
);
1130 static int debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1131 struct cmd_token
**argv
)
1133 if (vty
->node
== CONFIG_NODE
) {
1134 if (argc
== arg_base
+ 0)
1135 DEBUG_ON(zebra
, ZEBRA
);
1136 else if (argc
== arg_base
+ 1) {
1137 if (strmatch(argv
[arg_base
]->text
, "interface"))
1138 DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1139 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1140 DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1147 if (argc
== arg_base
+ 0)
1148 TERM_DEBUG_ON(zebra
, ZEBRA
);
1149 else if (argc
== arg_base
+ 1) {
1150 if (strmatch(argv
[arg_base
]->text
, "interface"))
1151 TERM_DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1152 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1153 TERM_DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1159 DEFUN (debug_ospf_zebra
,
1160 debug_ospf_zebra_cmd
,
1161 "debug ospf zebra [<interface|redistribute>]",
1166 "Zebra redistribute\n")
1168 return debug_ospf_zebra_common(vty
, 3, argc
, argv
);
1171 DEFUN (debug_ospf_instance_zebra
,
1172 debug_ospf_instance_zebra_cmd
,
1173 "debug ospf (1-65535) zebra [<interface|redistribute>]",
1179 "Zebra redistribute\n")
1182 unsigned short instance
= 0;
1184 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1185 if (!ospf_lookup_instance(instance
))
1186 return CMD_NOT_MY_INSTANCE
;
1188 return debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1192 static int no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1193 struct cmd_token
**argv
)
1195 if (vty
->node
== CONFIG_NODE
) {
1196 if (argc
== arg_base
+ 0)
1197 DEBUG_OFF(zebra
, ZEBRA
);
1198 else if (argc
== arg_base
+ 1) {
1199 if (strmatch(argv
[arg_base
]->text
, "interface"))
1200 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1201 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1202 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1209 if (argc
== arg_base
+ 0)
1210 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1211 else if (argc
== arg_base
+ 1) {
1212 if (strmatch(argv
[arg_base
]->text
, "interface"))
1213 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1214 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1215 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1221 DEFUN (no_debug_ospf_zebra
,
1222 no_debug_ospf_zebra_cmd
,
1223 "no debug ospf zebra [<interface|redistribute>]",
1229 "Zebra redistribute\n")
1231 return no_debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1234 DEFUN (no_debug_ospf_instance_zebra
,
1235 no_debug_ospf_instance_zebra_cmd
,
1236 "no debug ospf (1-65535) zebra [<interface|redistribute>]",
1243 "Zebra redistribute\n")
1246 unsigned short instance
= 0;
1248 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1249 if (!ospf_lookup_instance(instance
))
1252 return no_debug_ospf_zebra_common(vty
, 5, argc
, argv
);
1256 DEFUN (debug_ospf_event
,
1257 debug_ospf_event_cmd
,
1261 "OSPF event information\n")
1263 if (vty
->node
== CONFIG_NODE
)
1264 CONF_DEBUG_ON(event
, EVENT
);
1265 TERM_DEBUG_ON(event
, EVENT
);
1269 DEFUN (no_debug_ospf_event
,
1270 no_debug_ospf_event_cmd
,
1271 "no debug ospf event",
1275 "OSPF event information\n")
1277 if (vty
->node
== CONFIG_NODE
)
1278 CONF_DEBUG_OFF(event
, EVENT
);
1279 TERM_DEBUG_OFF(event
, EVENT
);
1283 DEFUN (debug_ospf_instance_event
,
1284 debug_ospf_instance_event_cmd
,
1285 "debug ospf (1-65535) event",
1289 "OSPF event information\n")
1292 unsigned short instance
= 0;
1294 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1295 if (!ospf_lookup_instance(instance
))
1298 if (vty
->node
== CONFIG_NODE
)
1299 CONF_DEBUG_ON(event
, EVENT
);
1300 TERM_DEBUG_ON(event
, EVENT
);
1304 DEFUN (no_debug_ospf_instance_event
,
1305 no_debug_ospf_instance_event_cmd
,
1306 "no debug ospf (1-65535) event",
1311 "OSPF event information\n")
1314 unsigned short instance
= 0;
1316 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1317 if (!ospf_lookup_instance(instance
))
1320 if (vty
->node
== CONFIG_NODE
)
1321 CONF_DEBUG_OFF(event
, EVENT
);
1322 TERM_DEBUG_OFF(event
, EVENT
);
1326 DEFUN (debug_ospf_nssa
,
1327 debug_ospf_nssa_cmd
,
1331 "OSPF nssa information\n")
1333 if (vty
->node
== CONFIG_NODE
)
1334 CONF_DEBUG_ON(nssa
, NSSA
);
1335 TERM_DEBUG_ON(nssa
, NSSA
);
1339 DEFUN (no_debug_ospf_nssa
,
1340 no_debug_ospf_nssa_cmd
,
1341 "no debug ospf nssa",
1345 "OSPF nssa information\n")
1347 if (vty
->node
== CONFIG_NODE
)
1348 CONF_DEBUG_OFF(nssa
, NSSA
);
1349 TERM_DEBUG_OFF(nssa
, NSSA
);
1353 DEFUN (debug_ospf_instance_nssa
,
1354 debug_ospf_instance_nssa_cmd
,
1355 "debug ospf (1-65535) nssa",
1359 "OSPF nssa information\n")
1362 unsigned short instance
= 0;
1364 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1365 if (!ospf_lookup_instance(instance
))
1368 if (vty
->node
== CONFIG_NODE
)
1369 CONF_DEBUG_ON(nssa
, NSSA
);
1370 TERM_DEBUG_ON(nssa
, NSSA
);
1374 DEFUN (no_debug_ospf_instance_nssa
,
1375 no_debug_ospf_instance_nssa_cmd
,
1376 "no debug ospf (1-65535) nssa",
1381 "OSPF nssa information\n")
1384 unsigned short instance
= 0;
1386 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1387 if (!ospf_lookup_instance(instance
))
1390 if (vty
->node
== CONFIG_NODE
)
1391 CONF_DEBUG_OFF(nssa
, NSSA
);
1392 TERM_DEBUG_OFF(nssa
, NSSA
);
1396 DEFUN (debug_ospf_te
,
1401 "OSPF-TE information\n")
1403 if (vty
->node
== CONFIG_NODE
)
1404 CONF_DEBUG_ON(te
, TE
);
1405 TERM_DEBUG_ON(te
, TE
);
1409 DEFUN (no_debug_ospf_te
,
1410 no_debug_ospf_te_cmd
,
1415 "OSPF-TE information\n")
1417 if (vty
->node
== CONFIG_NODE
)
1418 CONF_DEBUG_OFF(te
, TE
);
1419 TERM_DEBUG_OFF(te
, TE
);
1423 DEFUN (debug_ospf_sr
,
1428 "OSPF-SR information\n")
1430 if (vty
->node
== CONFIG_NODE
)
1431 CONF_DEBUG_ON(sr
, SR
);
1432 TERM_DEBUG_ON(sr
, SR
);
1436 DEFUN (no_debug_ospf_sr
,
1437 no_debug_ospf_sr_cmd
,
1442 "OSPF-SR information\n")
1444 if (vty
->node
== CONFIG_NODE
)
1445 CONF_DEBUG_OFF(sr
, SR
);
1446 TERM_DEBUG_OFF(sr
, SR
);
1450 DEFUN (no_debug_ospf
,
1457 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1460 if (vty
->node
== CONFIG_NODE
) {
1461 CONF_DEBUG_OFF(event
, EVENT
);
1462 CONF_DEBUG_OFF(nssa
, NSSA
);
1463 DEBUG_OFF(ism
, ISM_EVENTS
);
1464 DEBUG_OFF(ism
, ISM_STATUS
);
1465 DEBUG_OFF(ism
, ISM_TIMERS
);
1466 DEBUG_OFF(lsa
, LSA
);
1467 DEBUG_OFF(lsa
, LSA_FLOODING
);
1468 DEBUG_OFF(lsa
, LSA_GENERATE
);
1469 DEBUG_OFF(lsa
, LSA_INSTALL
);
1470 DEBUG_OFF(lsa
, LSA_REFRESH
);
1471 DEBUG_OFF(nsm
, NSM
);
1472 DEBUG_OFF(nsm
, NSM_EVENTS
);
1473 DEBUG_OFF(nsm
, NSM_STATUS
);
1474 DEBUG_OFF(nsm
, NSM_TIMERS
);
1475 DEBUG_OFF(zebra
, ZEBRA
);
1476 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1477 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1479 for (i
= 0; i
< 5; i
++)
1480 DEBUG_PACKET_OFF(i
, flag
);
1483 for (i
= 0; i
< 5; i
++)
1484 TERM_DEBUG_PACKET_OFF(i
, flag
);
1486 TERM_DEBUG_OFF(event
, EVENT
);
1487 TERM_DEBUG_OFF(ism
, ISM
);
1488 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
1489 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
1490 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
1491 TERM_DEBUG_OFF(lsa
, LSA
);
1492 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1493 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1494 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1495 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1496 TERM_DEBUG_OFF(nsm
, NSM
);
1497 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
1498 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
1499 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
1500 TERM_DEBUG_OFF(nssa
, NSSA
);
1501 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1502 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1503 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1508 static int show_debugging_ospf_common(struct vty
*vty
, struct ospf
*ospf
)
1513 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
1515 vty_out(vty
, "OSPF debugging status:\n");
1517 /* Show debug status for events. */
1518 if (IS_DEBUG_OSPF(event
, EVENT
))
1519 vty_out(vty
, " OSPF event debugging is on\n");
1521 /* Show debug status for ISM. */
1522 if (IS_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1523 vty_out(vty
, " OSPF ISM debugging is on\n");
1525 if (IS_DEBUG_OSPF(ism
, ISM_STATUS
))
1526 vty_out(vty
, " OSPF ISM status debugging is on\n");
1527 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
1528 vty_out(vty
, " OSPF ISM event debugging is on\n");
1529 if (IS_DEBUG_OSPF(ism
, ISM_TIMERS
))
1530 vty_out(vty
, " OSPF ISM timer debugging is on\n");
1533 /* Show debug status for NSM. */
1534 if (IS_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1535 vty_out(vty
, " OSPF NSM debugging is on\n");
1537 if (IS_DEBUG_OSPF(nsm
, NSM_STATUS
))
1538 vty_out(vty
, " OSPF NSM status debugging is on\n");
1539 if (IS_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1540 vty_out(vty
, " OSPF NSM event debugging is on\n");
1541 if (IS_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1542 vty_out(vty
, " OSPF NSM timer debugging is on\n");
1545 /* Show debug status for OSPF Packets. */
1546 for (i
= 0; i
< 5; i
++)
1547 if (IS_DEBUG_OSPF_PACKET(i
, SEND
)
1548 && IS_DEBUG_OSPF_PACKET(i
, RECV
)) {
1549 vty_out(vty
, " OSPF packet %s%s debugging is on\n",
1550 lookup_msg(ospf_packet_type_str
, i
+ 1, NULL
),
1551 IS_DEBUG_OSPF_PACKET(i
, DETAIL
) ? " detail"
1554 if (IS_DEBUG_OSPF_PACKET(i
, SEND
))
1556 " OSPF packet %s send%s debugging is on\n",
1557 lookup_msg(ospf_packet_type_str
, i
+ 1,
1559 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1562 if (IS_DEBUG_OSPF_PACKET(i
, RECV
))
1564 " OSPF packet %s receive%s debugging is on\n",
1565 lookup_msg(ospf_packet_type_str
, i
+ 1,
1567 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1572 /* Show debug status for OSPF LSAs. */
1573 if (IS_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1574 vty_out(vty
, " OSPF LSA debugging is on\n");
1576 if (IS_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1577 vty_out(vty
, " OSPF LSA generation debugging is on\n");
1578 if (IS_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1579 vty_out(vty
, " OSPF LSA flooding debugging is on\n");
1580 if (IS_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1581 vty_out(vty
, " OSPF LSA install debugging is on\n");
1582 if (IS_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1583 vty_out(vty
, " OSPF LSA refresh debugging is on\n");
1586 /* Show debug status for Zebra. */
1587 if (IS_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1588 vty_out(vty
, " OSPF Zebra debugging is on\n");
1590 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1592 " OSPF Zebra interface debugging is on\n");
1593 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1595 " OSPF Zebra redistribute debugging is on\n");
1598 /* Show debug status for NSSA. */
1599 if (IS_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1600 vty_out(vty
, " OSPF NSSA debugging is on\n");
1607 DEFUN_NOSH (show_debugging_ospf
,
1608 show_debugging_ospf_cmd
,
1609 "show debugging [ospf]",
1614 struct ospf
*ospf
= NULL
;
1616 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1620 return show_debugging_ospf_common(vty
, ospf
);
1623 DEFUN_NOSH (show_debugging_ospf_instance
,
1624 show_debugging_ospf_instance_cmd
,
1625 "show debugging ospf (1-65535)",
1633 unsigned short instance
= 0;
1635 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1636 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
)
1639 return show_debugging_ospf_common(vty
, ospf
);
1642 static int config_write_debug(struct vty
*vty
);
1644 static struct cmd_node debug_node
= {
1648 .config_write
= config_write_debug
,
1651 static int config_write_debug(struct vty
*vty
)
1656 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update",
1658 const char *detail_str
[] = {
1659 "", " send", " recv", "",
1660 " detail", " send detail", " recv detail", " detail"};
1666 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1671 snprintf(str
, sizeof(str
), " %u", ospf
->instance
);
1673 /* debug ospf ism (status|events|timers). */
1674 if (IS_CONF_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1675 vty_out(vty
, "debug ospf%s ism\n", str
);
1677 if (IS_CONF_DEBUG_OSPF(ism
, ISM_STATUS
))
1678 vty_out(vty
, "debug ospf%s ism status\n", str
);
1679 if (IS_CONF_DEBUG_OSPF(ism
, ISM_EVENTS
))
1680 vty_out(vty
, "debug ospf%s ism event\n", str
);
1681 if (IS_CONF_DEBUG_OSPF(ism
, ISM_TIMERS
))
1682 vty_out(vty
, "debug ospf%s ism timer\n", str
);
1685 /* debug ospf nsm (status|events|timers). */
1686 if (IS_CONF_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1687 vty_out(vty
, "debug ospf%s nsm\n", str
);
1689 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_STATUS
))
1690 vty_out(vty
, "debug ospf%s nsm status\n", str
);
1691 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1692 vty_out(vty
, "debug ospf%s nsm event\n", str
);
1693 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1694 vty_out(vty
, "debug ospf%s nsm timer\n", str
);
1697 /* debug ospf lsa (generate|flooding|install|refresh). */
1698 if (IS_CONF_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1699 vty_out(vty
, "debug ospf%s lsa\n", str
);
1701 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1702 vty_out(vty
, "debug ospf%s lsa generate\n", str
);
1703 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1704 vty_out(vty
, "debug ospf%s lsa flooding\n", str
);
1705 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1706 vty_out(vty
, "debug ospf%s lsa install\n", str
);
1707 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1708 vty_out(vty
, "debug ospf%s lsa refresh\n", str
);
1713 /* debug ospf zebra (interface|redistribute). */
1714 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1715 vty_out(vty
, "debug ospf%s zebra\n", str
);
1717 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1718 vty_out(vty
, "debug ospf%s zebra interface\n", str
);
1719 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1720 vty_out(vty
, "debug ospf%s zebra redistribute\n", str
);
1725 /* debug ospf event. */
1726 if (IS_CONF_DEBUG_OSPF(event
, EVENT
) == OSPF_DEBUG_EVENT
) {
1727 vty_out(vty
, "debug ospf%s event\n", str
);
1731 /* debug ospf nssa. */
1732 if (IS_CONF_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
) {
1733 vty_out(vty
, "debug ospf%s nssa\n", str
);
1737 /* debug ospf packet all detail. */
1738 r
= OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
;
1739 for (i
= 0; i
< 5; i
++)
1740 r
&= conf_debug_ospf_packet
[i
]
1741 & (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
);
1742 if (r
== (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
)) {
1743 vty_out(vty
, "debug ospf%s packet all detail\n", str
);
1747 /* debug ospf packet all. */
1748 r
= OSPF_DEBUG_SEND_RECV
;
1749 for (i
= 0; i
< 5; i
++)
1750 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
1751 if (r
== OSPF_DEBUG_SEND_RECV
) {
1752 vty_out(vty
, "debug ospf%s packet all\n", str
);
1753 for (i
= 0; i
< 5; i
++)
1754 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
1755 vty_out(vty
, "debug ospf%s packet %s detail\n",
1760 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1761 (send|recv) (detail). */
1762 for (i
= 0; i
< 5; i
++) {
1763 if (conf_debug_ospf_packet
[i
] == 0)
1766 vty_out(vty
, "debug ospf%s packet %s%s\n", str
, type_str
[i
],
1767 detail_str
[conf_debug_ospf_packet
[i
]]);
1772 if (IS_CONF_DEBUG_OSPF(te
, TE
) == OSPF_DEBUG_TE
) {
1773 vty_out(vty
, "debug ospf%s te\n", str
);
1778 if (IS_CONF_DEBUG_OSPF(sr
, SR
) == OSPF_DEBUG_SR
) {
1779 vty_out(vty
, "debug ospf%s sr\n", str
);
1786 /* Initialize debug commands. */
1787 void ospf_debug_init(void)
1789 install_node(&debug_node
);
1791 install_element(ENABLE_NODE
, &show_debugging_ospf_cmd
);
1792 install_element(ENABLE_NODE
, &debug_ospf_ism_cmd
);
1793 install_element(ENABLE_NODE
, &debug_ospf_nsm_cmd
);
1794 install_element(ENABLE_NODE
, &debug_ospf_lsa_cmd
);
1795 install_element(ENABLE_NODE
, &debug_ospf_zebra_cmd
);
1796 install_element(ENABLE_NODE
, &debug_ospf_event_cmd
);
1797 install_element(ENABLE_NODE
, &debug_ospf_nssa_cmd
);
1798 install_element(ENABLE_NODE
, &debug_ospf_te_cmd
);
1799 install_element(ENABLE_NODE
, &debug_ospf_sr_cmd
);
1800 install_element(ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
1801 install_element(ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
1802 install_element(ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
1803 install_element(ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
1804 install_element(ENABLE_NODE
, &no_debug_ospf_event_cmd
);
1805 install_element(ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
1806 install_element(ENABLE_NODE
, &no_debug_ospf_te_cmd
);
1807 install_element(ENABLE_NODE
, &no_debug_ospf_sr_cmd
);
1809 install_element(ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
1810 install_element(ENABLE_NODE
, &debug_ospf_packet_cmd
);
1811 install_element(ENABLE_NODE
, &no_debug_ospf_packet_cmd
);
1813 install_element(ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
1814 install_element(ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
1815 install_element(ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
1816 install_element(ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
1817 install_element(ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
1818 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1819 install_element(ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1820 install_element(ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1821 install_element(ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
1822 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1823 install_element(ENABLE_NODE
, &no_debug_ospf_cmd
);
1825 install_element(CONFIG_NODE
, &debug_ospf_packet_cmd
);
1826 install_element(CONFIG_NODE
, &no_debug_ospf_packet_cmd
);
1827 install_element(CONFIG_NODE
, &debug_ospf_ism_cmd
);
1828 install_element(CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
1830 install_element(CONFIG_NODE
, &debug_ospf_nsm_cmd
);
1831 install_element(CONFIG_NODE
, &debug_ospf_lsa_cmd
);
1832 install_element(CONFIG_NODE
, &debug_ospf_zebra_cmd
);
1833 install_element(CONFIG_NODE
, &debug_ospf_event_cmd
);
1834 install_element(CONFIG_NODE
, &debug_ospf_nssa_cmd
);
1835 install_element(CONFIG_NODE
, &debug_ospf_te_cmd
);
1836 install_element(CONFIG_NODE
, &debug_ospf_sr_cmd
);
1837 install_element(CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
1838 install_element(CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
1839 install_element(CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
1840 install_element(CONFIG_NODE
, &no_debug_ospf_event_cmd
);
1841 install_element(CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
1842 install_element(CONFIG_NODE
, &no_debug_ospf_te_cmd
);
1843 install_element(CONFIG_NODE
, &no_debug_ospf_sr_cmd
);
1845 install_element(CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
1846 install_element(CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
1847 install_element(CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
1848 install_element(CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
1849 install_element(CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
1850 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1851 install_element(CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1852 install_element(CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1853 install_element(CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
1854 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1855 install_element(CONFIG_NODE
, &no_debug_ospf_cmd
);