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
, OSPF_AREA_STRING_MAXLEN
, "%d.%d.%d.%d",
86 (area_id
>> 24) & 0xff, (area_id
>> 16) & 0xff,
87 (area_id
>> 8) & 0xff, area_id
& 0xff);
91 #define OSPF_AREA_DESC_STRING_MAXLEN 23
92 const char *ospf_area_desc_string(struct ospf_area
*area
)
94 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
98 return "(incomplete)";
100 type
= area
->external_routing
;
103 snprintf(buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [NSSA]",
104 ospf_area_name_string(area
));
107 snprintf(buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [Stub]",
108 ospf_area_name_string(area
));
111 return ospf_area_name_string(area
);
117 #define OSPF_IF_STRING_MAXLEN 40
118 const char *ospf_if_name_string(struct ospf_interface
*oi
)
120 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
123 if (!oi
|| !oi
->address
)
126 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
127 return oi
->ifp
->name
;
129 ifaddr
= ntohl(oi
->address
->u
.prefix4
.s_addr
);
130 snprintf(buf
, OSPF_IF_STRING_MAXLEN
, "%s:%d.%d.%d.%d", oi
->ifp
->name
,
131 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
132 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
137 void ospf_nbr_state_message(struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
140 struct ospf_interface
*oi
= nbr
->oi
;
142 if (IPV4_ADDR_SAME(&DR(oi
), &nbr
->address
.u
.prefix4
))
144 else if (IPV4_ADDR_SAME(&BDR(oi
), &nbr
->address
.u
.prefix4
))
149 memset(buf
, 0, size
);
151 snprintf(buf
, size
, "%s/%s",
152 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
),
153 lookup_msg(ospf_ism_state_msg
, state
, NULL
));
156 const char *ospf_timeval_dump(struct timeval
*t
, char *buf
, size_t size
)
158 /* Making formatted timer strings. */
159 #define MINUTE_IN_SECONDS 60
160 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
161 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
162 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
163 unsigned long w
, d
, h
, m
, s
, ms
, us
;
168 w
= d
= h
= m
= s
= ms
= us
= 0;
169 memset(buf
, 0, size
);
175 (void)us
; /* unused */
179 t
->tv_sec
+= ms
/ 1000;
183 if (t
->tv_sec
> WEEK_IN_SECONDS
) {
184 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
185 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
188 if (t
->tv_sec
> DAY_IN_SECONDS
) {
189 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
190 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
193 if (t
->tv_sec
>= HOUR_IN_SECONDS
) {
194 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
195 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
198 if (t
->tv_sec
>= MINUTE_IN_SECONDS
) {
199 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
200 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
204 snprintf(buf
, size
, "%ldw%1ldd", w
, d
);
206 snprintf(buf
, size
, "%ldw%1ldd%02ldh", w
, d
, h
);
208 snprintf(buf
, size
, "%1ldd%02ldh%02ldm", d
, h
, m
);
210 snprintf(buf
, size
, "%ldh%02ldm%02lds", h
, m
, (long)t
->tv_sec
);
212 snprintf(buf
, size
, "%ldm%02lds", m
, (long)t
->tv_sec
);
214 snprintf(buf
, size
, "%ld.%03lds", (long)t
->tv_sec
, ms
);
216 snprintf(buf
, size
, "%ld usecs", (long)t
->tv_usec
);
221 const char *ospf_timer_dump(struct thread
*t
, char *buf
, size_t size
)
223 struct timeval result
;
227 monotime_until(&t
->u
.sands
, &result
);
228 return ospf_timeval_dump(&result
, buf
, size
);
231 static void ospf_packet_hello_dump(struct stream
*s
, uint16_t length
)
233 struct ospf_hello
*hello
;
236 hello
= (struct ospf_hello
*)stream_pnt(s
);
239 zlog_debug(" NetworkMask %s", inet_ntoa(hello
->network_mask
));
240 zlog_debug(" HelloInterval %d", ntohs(hello
->hello_interval
));
241 zlog_debug(" Options %d (%s)", hello
->options
,
242 ospf_options_dump(hello
->options
));
243 zlog_debug(" RtrPriority %d", hello
->priority
);
244 zlog_debug(" RtrDeadInterval %ld",
245 (unsigned long)ntohl(hello
->dead_interval
));
246 zlog_debug(" DRouter %s", inet_ntoa(hello
->d_router
));
247 zlog_debug(" BDRouter %s", inet_ntoa(hello
->bd_router
));
249 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
250 zlog_debug(" # Neighbors %d", length
/ 4);
251 for (i
= 0; length
> 0; i
++, length
-= sizeof(struct in_addr
))
252 zlog_debug(" Neighbor %s", inet_ntoa(hello
->neighbors
[i
]));
255 static char *ospf_dd_flags_dump(uint8_t flags
, char *buf
, size_t size
)
257 memset(buf
, 0, size
);
259 snprintf(buf
, size
, "%s|%s|%s", (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
260 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
261 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
266 static char *ospf_router_lsa_flags_dump(uint8_t flags
, char *buf
, size_t size
)
268 memset(buf
, 0, size
);
270 snprintf(buf
, size
, "%s|%s|%s",
271 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
272 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
273 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
278 static void ospf_router_lsa_dump(struct stream
*s
, uint16_t length
)
281 struct router_lsa
*rl
;
284 rl
= (struct router_lsa
*)stream_pnt(s
);
286 zlog_debug(" Router-LSA");
287 zlog_debug(" flags %s",
288 ospf_router_lsa_flags_dump(rl
->flags
, buf
, BUFSIZ
));
289 zlog_debug(" # links %d", ntohs(rl
->links
));
291 len
= ntohs(rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
292 for (i
= 0; len
> 0; i
++) {
293 zlog_debug(" Link ID %s", inet_ntoa(rl
->link
[i
].link_id
));
294 zlog_debug(" Link Data %s",
295 inet_ntoa(rl
->link
[i
].link_data
));
296 zlog_debug(" Type %d", (uint8_t)rl
->link
[i
].type
);
297 zlog_debug(" TOS %d", (uint8_t)rl
->link
[i
].tos
);
298 zlog_debug(" metric %d", ntohs(rl
->link
[i
].metric
));
304 static void ospf_network_lsa_dump(struct stream
*s
, uint16_t length
)
306 struct network_lsa
*nl
;
309 nl
= (struct network_lsa
*)stream_pnt(s
);
310 cnt
= (ntohs(nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
312 zlog_debug(" Network-LSA");
314 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
315 zlog_debug ("Network-LSA size %d",
316 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
318 zlog_debug(" Network Mask %s", inet_ntoa(nl
->mask
));
319 zlog_debug(" # Attached Routers %d", cnt
);
320 for (i
= 0; i
< cnt
; i
++)
321 zlog_debug(" Attached Router %s",
322 inet_ntoa(nl
->routers
[i
]));
325 static void ospf_summary_lsa_dump(struct stream
*s
, uint16_t length
)
327 struct summary_lsa
*sl
;
331 sl
= (struct summary_lsa
*)stream_pnt(s
);
333 zlog_debug(" Summary-LSA");
334 zlog_debug(" Network Mask %s", inet_ntoa(sl
->mask
));
336 size
= ntohs(sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
337 for (i
= 0; size
> 0; size
-= 4, i
++)
338 zlog_debug(" TOS=%d metric %d", sl
->tos
,
339 GET_METRIC(sl
->metric
));
342 static void ospf_as_external_lsa_dump(struct stream
*s
, uint16_t length
)
344 struct as_external_lsa
*al
;
348 al
= (struct as_external_lsa
*)stream_pnt(s
);
349 zlog_debug(" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
350 zlog_debug(" Network Mask %s", inet_ntoa(al
->mask
));
352 size
= ntohs(al
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
353 for (i
= 0; size
> 0; size
-= 12, i
++) {
354 zlog_debug(" bit %s TOS=%d metric %d",
355 IS_EXTERNAL_METRIC(al
->e
[i
].tos
) ? "E" : "-",
356 al
->e
[i
].tos
& 0x7f, GET_METRIC(al
->e
[i
].metric
));
357 zlog_debug(" Forwarding address %s",
358 inet_ntoa(al
->e
[i
].fwd_addr
));
359 zlog_debug(" External Route Tag %" ROUTE_TAG_PRI
,
364 static void ospf_lsa_header_list_dump(struct stream
*s
, uint16_t length
)
366 struct lsa_header
*lsa
;
368 zlog_debug(" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
372 lsa
= (struct lsa_header
*)stream_pnt(s
);
373 ospf_lsa_header_dump(lsa
);
375 stream_forward_getp(s
, OSPF_LSA_HEADER_SIZE
);
376 length
-= OSPF_LSA_HEADER_SIZE
;
380 static void ospf_packet_db_desc_dump(struct stream
*s
, uint16_t length
)
382 struct ospf_db_desc
*dd
;
387 gp
= stream_get_getp(s
);
388 dd
= (struct ospf_db_desc
*)stream_pnt(s
);
390 zlog_debug("Database Description");
391 zlog_debug(" Interface MTU %d", ntohs(dd
->mtu
));
392 zlog_debug(" Options %d (%s)", dd
->options
,
393 ospf_options_dump(dd
->options
));
394 zlog_debug(" Flags %d (%s)", dd
->flags
,
395 ospf_dd_flags_dump(dd
->flags
, dd_flags
, sizeof dd_flags
));
396 zlog_debug(" Sequence Number 0x%08lx",
397 (unsigned long)ntohl(dd
->dd_seqnum
));
399 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
401 stream_forward_getp(s
, OSPF_DB_DESC_MIN_SIZE
);
403 ospf_lsa_header_list_dump(s
, length
);
405 stream_set_getp(s
, gp
);
408 static void ospf_packet_ls_req_dump(struct stream
*s
, uint16_t length
)
412 struct in_addr ls_id
;
413 struct in_addr adv_router
;
415 sp
= stream_get_getp(s
);
417 length
-= OSPF_HEADER_SIZE
;
419 zlog_debug("Link State Request");
420 zlog_debug(" # Requests %d", length
/ 12);
422 for (; length
> 0; length
-= 12) {
423 ls_type
= stream_getl(s
);
424 ls_id
.s_addr
= stream_get_ipv4(s
);
425 adv_router
.s_addr
= stream_get_ipv4(s
);
427 zlog_debug(" LS type %d", ls_type
);
428 zlog_debug(" Link State ID %s", inet_ntoa(ls_id
));
429 zlog_debug(" Advertising Router %s", inet_ntoa(adv_router
));
432 stream_set_getp(s
, sp
);
435 static void ospf_packet_ls_upd_dump(struct stream
*s
, uint16_t length
)
438 struct lsa_header
*lsa
;
442 length
-= OSPF_HEADER_SIZE
;
444 sp
= stream_get_getp(s
);
446 count
= stream_getl(s
);
449 zlog_debug("Link State Update");
450 zlog_debug(" # LSAs %d", count
);
452 while (length
> 0 && count
> 0) {
453 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0) {
454 zlog_debug(" Remaining %d bytes; Incorrect length.",
459 lsa
= (struct lsa_header
*)stream_pnt(s
);
460 lsa_len
= ntohs(lsa
->length
);
461 ospf_lsa_header_dump(lsa
);
464 case OSPF_ROUTER_LSA
:
465 ospf_router_lsa_dump(s
, length
);
467 case OSPF_NETWORK_LSA
:
468 ospf_network_lsa_dump(s
, length
);
470 case OSPF_SUMMARY_LSA
:
471 case OSPF_ASBR_SUMMARY_LSA
:
472 ospf_summary_lsa_dump(s
, length
);
474 case OSPF_AS_EXTERNAL_LSA
:
475 ospf_as_external_lsa_dump(s
, length
);
477 case OSPF_AS_NSSA_LSA
:
478 ospf_as_external_lsa_dump(s
, length
);
480 case OSPF_OPAQUE_LINK_LSA
:
481 case OSPF_OPAQUE_AREA_LSA
:
482 case OSPF_OPAQUE_AS_LSA
:
483 ospf_opaque_lsa_dump(s
, length
);
489 stream_forward_getp(s
, lsa_len
);
494 stream_set_getp(s
, sp
);
497 static void ospf_packet_ls_ack_dump(struct stream
*s
, uint16_t length
)
501 length
-= OSPF_HEADER_SIZE
;
502 sp
= stream_get_getp(s
);
504 zlog_debug("Link State Acknowledgment");
505 ospf_lsa_header_list_dump(s
, length
);
507 stream_set_getp(s
, sp
);
510 /* Expects header to be in host order */
511 void ospf_ip_header_dump(struct ip
*iph
)
513 /* IP Header dump. */
514 zlog_debug("ip_v %d", iph
->ip_v
);
515 zlog_debug("ip_hl %d", iph
->ip_hl
);
516 zlog_debug("ip_tos %d", iph
->ip_tos
);
517 zlog_debug("ip_len %d", iph
->ip_len
);
518 zlog_debug("ip_id %u", (uint32_t)iph
->ip_id
);
519 zlog_debug("ip_off %u", (uint32_t)iph
->ip_off
);
520 zlog_debug("ip_ttl %d", iph
->ip_ttl
);
521 zlog_debug("ip_p %d", iph
->ip_p
);
522 zlog_debug("ip_sum 0x%x", (uint32_t)iph
->ip_sum
);
523 zlog_debug("ip_src %s", inet_ntoa(iph
->ip_src
));
524 zlog_debug("ip_dst %s", inet_ntoa(iph
->ip_dst
));
527 static void ospf_header_dump(struct ospf_header
*ospfh
)
530 uint16_t auth_type
= ntohs(ospfh
->auth_type
);
532 zlog_debug("Header");
533 zlog_debug(" Version %d", ospfh
->version
);
534 zlog_debug(" Type %d (%s)", ospfh
->type
,
535 lookup_msg(ospf_packet_type_str
, ospfh
->type
, NULL
));
536 zlog_debug(" Packet Len %d", ntohs(ospfh
->length
));
537 zlog_debug(" Router ID %s", inet_ntoa(ospfh
->router_id
));
538 zlog_debug(" Area ID %s", inet_ntoa(ospfh
->area_id
));
539 zlog_debug(" Checksum 0x%x", ntohs(ospfh
->checksum
));
540 zlog_debug(" AuType %s",
541 lookup_msg(ospf_auth_type_str
, auth_type
, NULL
));
546 case OSPF_AUTH_SIMPLE
:
548 strncpy(buf
, (char *)ospfh
->u
.auth_data
, 8);
549 zlog_debug(" Simple Password %s", buf
);
551 case OSPF_AUTH_CRYPTOGRAPHIC
:
552 zlog_debug(" Cryptographic Authentication");
553 zlog_debug(" Key ID %d", ospfh
->u
.crypt
.key_id
);
554 zlog_debug(" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
555 zlog_debug(" Sequence number %ld",
556 (unsigned long)ntohl(ospfh
->u
.crypt
.crypt_seqnum
));
559 zlog_debug("* This is not supported authentication type");
564 void ospf_packet_dump(struct stream
*s
)
566 struct ospf_header
*ospfh
;
569 /* Preserve pointer. */
570 gp
= stream_get_getp(s
);
572 /* OSPF Header dump. */
573 ospfh
= (struct ospf_header
*)stream_pnt(s
);
575 /* Until detail flag is set, return. */
576 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
579 /* Show OSPF header detail. */
580 ospf_header_dump(ospfh
);
581 stream_forward_getp(s
, OSPF_HEADER_SIZE
);
583 switch (ospfh
->type
) {
585 ospf_packet_hello_dump(s
, ntohs(ospfh
->length
));
587 case OSPF_MSG_DB_DESC
:
588 ospf_packet_db_desc_dump(s
, ntohs(ospfh
->length
));
590 case OSPF_MSG_LS_REQ
:
591 ospf_packet_ls_req_dump(s
, ntohs(ospfh
->length
));
593 case OSPF_MSG_LS_UPD
:
594 ospf_packet_ls_upd_dump(s
, ntohs(ospfh
->length
));
596 case OSPF_MSG_LS_ACK
:
597 ospf_packet_ls_ack_dump(s
, ntohs(ospfh
->length
));
603 stream_set_getp(s
, gp
);
606 DEFUN (debug_ospf_packet
,
607 debug_ospf_packet_cmd
,
608 "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
614 "OSPF Database Description\n"
615 "OSPF Link State Request\n"
616 "OSPF Link State Update\n"
617 "OSPF Link State Acknowledgment\n"
620 "Detail Information\n"
622 "Detail Information\n"
623 "Detail Information\n")
625 int inst
= (argv
[2]->type
== RANGE_TKN
) ? 1 : 0;
626 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
627 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
628 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
629 char *packet
= argv
[3 + inst
]->text
;
631 if (inst
) // user passed instance ID
633 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
634 return CMD_NOT_MY_INSTANCE
;
641 /* Check packet type. */
642 if (strmatch(packet
, "hello"))
643 type
= OSPF_DEBUG_HELLO
;
644 else if (strmatch(packet
, "dd"))
645 type
= OSPF_DEBUG_DB_DESC
;
646 else if (strmatch(packet
, "ls-request"))
647 type
= OSPF_DEBUG_LS_REQ
;
648 else if (strmatch(packet
, "ls-update"))
649 type
= OSPF_DEBUG_LS_UPD
;
650 else if (strmatch(packet
, "ls-ack"))
651 type
= OSPF_DEBUG_LS_ACK
;
652 else if (strmatch(packet
, "all"))
653 type
= OSPF_DEBUG_ALL
;
656 * (none) = send + recv
657 * detail = send + recv + detail
660 * recv detail = recv + detail
661 * send detail = send + detail
666 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
667 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
668 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
670 for (i
= 0; i
< 5; i
++)
671 if (type
& (0x01 << i
)) {
672 if (vty
->node
== CONFIG_NODE
)
673 DEBUG_PACKET_ON(i
, flag
);
675 TERM_DEBUG_PACKET_ON(i
, flag
);
681 DEFUN (no_debug_ospf_packet
,
682 no_debug_ospf_packet_cmd
,
683 "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
690 "OSPF Database Description\n"
691 "OSPF Link State Request\n"
692 "OSPF Link State Update\n"
693 "OSPF Link State Acknowledgment\n"
696 "Detail Information\n"
698 "Detail Information\n"
699 "Detail Information\n")
701 int inst
= (argv
[3]->type
== RANGE_TKN
) ? 1 : 0;
702 int detail
= strmatch(argv
[argc
- 1]->text
, "detail");
703 int send
= strmatch(argv
[argc
- (1 + detail
)]->text
, "send");
704 int recv
= strmatch(argv
[argc
- (1 + detail
)]->text
, "recv");
705 char *packet
= argv
[4 + inst
]->text
;
707 if (inst
) // user passed instance ID
709 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
710 return CMD_NOT_MY_INSTANCE
;
717 /* Check packet type. */
718 if (strmatch(packet
, "hello"))
719 type
= OSPF_DEBUG_HELLO
;
720 else if (strmatch(packet
, "dd"))
721 type
= OSPF_DEBUG_DB_DESC
;
722 else if (strmatch(packet
, "ls-request"))
723 type
= OSPF_DEBUG_LS_REQ
;
724 else if (strmatch(packet
, "ls-update"))
725 type
= OSPF_DEBUG_LS_UPD
;
726 else if (strmatch(packet
, "ls-ack"))
727 type
= OSPF_DEBUG_LS_ACK
;
728 else if (strmatch(packet
, "all"))
729 type
= OSPF_DEBUG_ALL
;
732 * (none) = send + recv
733 * detail = send + recv + detail
736 * recv detail = recv + detail
737 * send detail = send + detail
742 flag
|= (send
) ? OSPF_DEBUG_SEND
: 0;
743 flag
|= (recv
) ? OSPF_DEBUG_RECV
: 0;
744 flag
|= (detail
) ? OSPF_DEBUG_DETAIL
: 0;
746 for (i
= 0; i
< 5; i
++)
747 if (type
& (0x01 << i
)) {
748 if (vty
->node
== CONFIG_NODE
)
749 DEBUG_PACKET_OFF(i
, flag
);
751 TERM_DEBUG_PACKET_OFF(i
, flag
);
756 for (i = 0; i < 5; i++)
757 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
764 DEFUN (debug_ospf_ism
,
766 "debug ospf [(1-65535)] ism [<status|events|timers>]",
770 "OSPF Interface State Machine\n"
771 "ISM Status Information\n"
772 "ISM Event Information\n"
773 "ISM TImer Information\n")
775 int inst
= (argv
[2]->type
== RANGE_TKN
);
776 char *dbgparam
= (argc
== 4 + inst
) ? argv
[argc
- 1]->text
: NULL
;
778 if (inst
) // user passed instance ID
780 if (!ospf_lookup_instance(strtoul(argv
[2]->arg
, NULL
, 10)))
781 return CMD_NOT_MY_INSTANCE
;
784 if (vty
->node
== CONFIG_NODE
) {
788 if (strmatch(dbgparam
, "status"))
789 DEBUG_ON(ism
, ISM_STATUS
);
790 else if (strmatch(dbgparam
, "events"))
791 DEBUG_ON(ism
, ISM_EVENTS
);
792 else if (strmatch(dbgparam
, "timers"))
793 DEBUG_ON(ism
, ISM_TIMERS
);
801 TERM_DEBUG_ON(ism
, ISM
);
803 if (strmatch(dbgparam
, "status"))
804 TERM_DEBUG_ON(ism
, ISM_STATUS
);
805 else if (strmatch(dbgparam
, "events"))
806 TERM_DEBUG_ON(ism
, ISM_EVENTS
);
807 else if (strmatch(dbgparam
, "timers"))
808 TERM_DEBUG_ON(ism
, ISM_TIMERS
);
814 DEFUN (no_debug_ospf_ism
,
815 no_debug_ospf_ism_cmd
,
816 "no debug ospf [(1-65535)] ism [<status|events|timers>]",
821 "OSPF Interface State Machine\n"
822 "ISM Status Information\n"
823 "ISM Event Information\n"
824 "ISM TImer Information\n")
826 int inst
= (argv
[3]->type
== RANGE_TKN
);
827 char *dbgparam
= (argc
== 5 + inst
) ? argv
[argc
- 1]->text
: NULL
;
829 if (inst
) // user passed instance ID
831 if (!ospf_lookup_instance(strtoul(argv
[3]->arg
, NULL
, 10)))
832 return CMD_NOT_MY_INSTANCE
;
835 if (vty
->node
== CONFIG_NODE
) {
839 if (strmatch(dbgparam
, "status"))
840 DEBUG_OFF(ism
, ISM_STATUS
);
841 else if (strmatch(dbgparam
, "events"))
842 DEBUG_OFF(ism
, ISM_EVENTS
);
843 else if (strmatch(dbgparam
, "timers"))
844 DEBUG_OFF(ism
, ISM_TIMERS
);
852 TERM_DEBUG_OFF(ism
, ISM
);
854 if (strmatch(dbgparam
, "status"))
855 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
856 else if (strmatch(dbgparam
, "events"))
857 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
858 else if (strmatch(dbgparam
, "timers"))
859 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
865 static int debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
866 struct cmd_token
**argv
)
868 if (vty
->node
== CONFIG_NODE
) {
869 if (argc
== arg_base
+ 0)
871 else if (argc
== arg_base
+ 1) {
872 if (strmatch(argv
[arg_base
]->text
, "status"))
873 DEBUG_ON(nsm
, NSM_STATUS
);
874 else if (strmatch(argv
[arg_base
]->text
, "events"))
875 DEBUG_ON(nsm
, NSM_EVENTS
);
876 else if (strmatch(argv
[arg_base
]->text
, "timers"))
877 DEBUG_ON(nsm
, NSM_TIMERS
);
884 if (argc
== arg_base
+ 0)
885 TERM_DEBUG_ON(nsm
, NSM
);
886 else if (argc
== arg_base
+ 1) {
887 if (strmatch(argv
[arg_base
]->text
, "status"))
888 TERM_DEBUG_ON(nsm
, NSM_STATUS
);
889 else if (strmatch(argv
[arg_base
]->text
, "events"))
890 TERM_DEBUG_ON(nsm
, NSM_EVENTS
);
891 else if (strmatch(argv
[arg_base
]->text
, "timers"))
892 TERM_DEBUG_ON(nsm
, NSM_TIMERS
);
898 DEFUN (debug_ospf_nsm
,
900 "debug ospf nsm [<status|events|timers>]",
903 "OSPF Neighbor State Machine\n"
904 "NSM Status Information\n"
905 "NSM Event Information\n"
906 "NSM Timer Information\n")
908 return debug_ospf_nsm_common(vty
, 3, argc
, argv
);
911 DEFUN (debug_ospf_instance_nsm
,
912 debug_ospf_instance_nsm_cmd
,
913 "debug ospf (1-65535) nsm [<status|events|timers>]",
917 "OSPF Neighbor State Machine\n"
918 "NSM Status Information\n"
919 "NSM Event Information\n"
920 "NSM Timer Information\n")
923 unsigned short instance
= 0;
925 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
926 if (!ospf_lookup_instance(instance
))
929 return debug_ospf_nsm_common(vty
, 4, argc
, argv
);
933 static int no_debug_ospf_nsm_common(struct vty
*vty
, int arg_base
, int argc
,
934 struct cmd_token
**argv
)
937 if (vty
->node
== CONFIG_NODE
) {
938 if (argc
== arg_base
+ 0)
940 else if (argc
== arg_base
+ 1) {
941 if (strmatch(argv
[arg_base
]->text
, "status"))
942 DEBUG_OFF(nsm
, NSM_STATUS
);
943 else if (strmatch(argv
[arg_base
]->text
, "events"))
944 DEBUG_OFF(nsm
, NSM_EVENTS
);
945 else if (strmatch(argv
[arg_base
]->text
, "timers"))
946 DEBUG_OFF(nsm
, NSM_TIMERS
);
953 if (argc
== arg_base
+ 0)
954 TERM_DEBUG_OFF(nsm
, NSM
);
955 else if (argc
== arg_base
+ 1) {
956 if (strmatch(argv
[arg_base
]->text
, "status"))
957 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
958 else if (strmatch(argv
[arg_base
]->text
, "events"))
959 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
960 else if (strmatch(argv
[arg_base
]->text
, "timers"))
961 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
967 DEFUN (no_debug_ospf_nsm
,
968 no_debug_ospf_nsm_cmd
,
969 "no debug ospf nsm [<status|events|timers>]",
973 "OSPF Neighbor State Machine\n"
974 "NSM Status Information\n"
975 "NSM Event Information\n"
976 "NSM Timer Information\n")
978 return no_debug_ospf_nsm_common(vty
, 4, argc
, argv
);
982 DEFUN (no_debug_ospf_instance_nsm
,
983 no_debug_ospf_instance_nsm_cmd
,
984 "no debug ospf (1-65535) nsm [<status|events|timers>]",
989 "OSPF Neighbor State Machine\n"
990 "NSM Status Information\n"
991 "NSM Event Information\n"
992 "NSM Timer Information\n")
995 unsigned short instance
= 0;
997 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
998 if (!ospf_lookup_instance(instance
))
999 return CMD_NOT_MY_INSTANCE
;
1001 return no_debug_ospf_nsm_common(vty
, 5, argc
, argv
);
1005 static int debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
1006 struct cmd_token
**argv
)
1008 if (vty
->node
== CONFIG_NODE
) {
1009 if (argc
== arg_base
+ 0)
1011 else if (argc
== arg_base
+ 1) {
1012 if (strmatch(argv
[arg_base
]->text
, "generate"))
1013 DEBUG_ON(lsa
, LSA_GENERATE
);
1014 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1015 DEBUG_ON(lsa
, LSA_FLOODING
);
1016 else if (strmatch(argv
[arg_base
]->text
, "install"))
1017 DEBUG_ON(lsa
, LSA_INSTALL
);
1018 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1019 DEBUG_ON(lsa
, LSA_REFRESH
);
1026 if (argc
== arg_base
+ 0)
1027 TERM_DEBUG_ON(lsa
, LSA
);
1028 else if (argc
== arg_base
+ 1) {
1029 if (strmatch(argv
[arg_base
]->text
, "generate"))
1030 TERM_DEBUG_ON(lsa
, LSA_GENERATE
);
1031 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1032 TERM_DEBUG_ON(lsa
, LSA_FLOODING
);
1033 else if (strmatch(argv
[arg_base
]->text
, "install"))
1034 TERM_DEBUG_ON(lsa
, LSA_INSTALL
);
1035 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1036 TERM_DEBUG_ON(lsa
, LSA_REFRESH
);
1042 DEFUN (debug_ospf_lsa
,
1044 "debug ospf lsa [<generate|flooding|install|refresh>]",
1047 "OSPF Link State Advertisement\n"
1050 "LSA Install/Delete\n"
1053 return debug_ospf_lsa_common(vty
, 3, argc
, argv
);
1056 DEFUN (debug_ospf_instance_lsa
,
1057 debug_ospf_instance_lsa_cmd
,
1058 "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1062 "OSPF Link State Advertisement\n"
1065 "LSA Install/Delete\n"
1069 unsigned short instance
= 0;
1071 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1072 if (!ospf_lookup_instance(instance
))
1073 return CMD_NOT_MY_INSTANCE
;
1075 return debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1079 static int no_debug_ospf_lsa_common(struct vty
*vty
, int arg_base
, int argc
,
1080 struct cmd_token
**argv
)
1082 if (vty
->node
== CONFIG_NODE
) {
1083 if (argc
== arg_base
+ 0)
1084 DEBUG_OFF(lsa
, LSA
);
1085 else if (argc
== arg_base
+ 1) {
1086 if (strmatch(argv
[arg_base
]->text
, "generate"))
1087 DEBUG_OFF(lsa
, LSA_GENERATE
);
1088 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1089 DEBUG_OFF(lsa
, LSA_FLOODING
);
1090 else if (strmatch(argv
[arg_base
]->text
, "install"))
1091 DEBUG_OFF(lsa
, LSA_INSTALL
);
1092 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1093 DEBUG_OFF(lsa
, LSA_REFRESH
);
1100 if (argc
== arg_base
+ 0)
1101 TERM_DEBUG_OFF(lsa
, LSA
);
1102 else if (argc
== arg_base
+ 1) {
1103 if (strmatch(argv
[arg_base
]->text
, "generate"))
1104 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1105 else if (strmatch(argv
[arg_base
]->text
, "flooding"))
1106 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1107 else if (strmatch(argv
[arg_base
]->text
, "install"))
1108 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1109 else if (strmatch(argv
[arg_base
]->text
, "refresh"))
1110 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1116 DEFUN (no_debug_ospf_lsa
,
1117 no_debug_ospf_lsa_cmd
,
1118 "no debug ospf lsa [<generate|flooding|install|refresh>]",
1122 "OSPF Link State Advertisement\n"
1125 "LSA Install/Delete\n"
1128 return no_debug_ospf_lsa_common(vty
, 4, argc
, argv
);
1131 DEFUN (no_debug_ospf_instance_lsa
,
1132 no_debug_ospf_instance_lsa_cmd
,
1133 "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1138 "OSPF Link State Advertisement\n"
1141 "LSA Install/Delete\n"
1145 unsigned short instance
= 0;
1147 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1148 if (!ospf_lookup_instance(instance
))
1149 return CMD_NOT_MY_INSTANCE
;
1151 return no_debug_ospf_lsa_common(vty
, 5, argc
, argv
);
1155 static int debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1156 struct cmd_token
**argv
)
1158 if (vty
->node
== CONFIG_NODE
) {
1159 if (argc
== arg_base
+ 0)
1160 DEBUG_ON(zebra
, ZEBRA
);
1161 else if (argc
== arg_base
+ 1) {
1162 if (strmatch(argv
[arg_base
]->text
, "interface"))
1163 DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1164 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1165 DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1172 if (argc
== arg_base
+ 0)
1173 TERM_DEBUG_ON(zebra
, ZEBRA
);
1174 else if (argc
== arg_base
+ 1) {
1175 if (strmatch(argv
[arg_base
]->text
, "interface"))
1176 TERM_DEBUG_ON(zebra
, ZEBRA_INTERFACE
);
1177 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1178 TERM_DEBUG_ON(zebra
, ZEBRA_REDISTRIBUTE
);
1184 DEFUN (debug_ospf_zebra
,
1185 debug_ospf_zebra_cmd
,
1186 "debug ospf zebra [<interface|redistribute>]",
1191 "Zebra redistribute\n")
1193 return debug_ospf_zebra_common(vty
, 3, argc
, argv
);
1196 DEFUN (debug_ospf_instance_zebra
,
1197 debug_ospf_instance_zebra_cmd
,
1198 "debug ospf (1-65535) zebra [<interface|redistribute>]",
1204 "Zebra redistribute\n")
1207 unsigned short instance
= 0;
1209 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1210 if (!ospf_lookup_instance(instance
))
1211 return CMD_NOT_MY_INSTANCE
;
1213 return debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1217 static int no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1218 struct cmd_token
**argv
)
1220 if (vty
->node
== CONFIG_NODE
) {
1221 if (argc
== arg_base
+ 0)
1222 DEBUG_OFF(zebra
, ZEBRA
);
1223 else if (argc
== arg_base
+ 1) {
1224 if (strmatch(argv
[arg_base
]->text
, "interface"))
1225 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1226 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1227 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1234 if (argc
== arg_base
+ 0)
1235 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1236 else if (argc
== arg_base
+ 1) {
1237 if (strmatch(argv
[arg_base
]->text
, "interface"))
1238 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1239 else if (strmatch(argv
[arg_base
]->text
, "redistribute"))
1240 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1246 DEFUN (no_debug_ospf_zebra
,
1247 no_debug_ospf_zebra_cmd
,
1248 "no debug ospf zebra [<interface|redistribute>]",
1254 "Zebra redistribute\n")
1256 return no_debug_ospf_zebra_common(vty
, 4, argc
, argv
);
1259 DEFUN (no_debug_ospf_instance_zebra
,
1260 no_debug_ospf_instance_zebra_cmd
,
1261 "no debug ospf (1-65535) zebra [<interface|redistribute>]",
1268 "Zebra redistribute\n")
1271 unsigned short instance
= 0;
1273 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1274 if (!ospf_lookup_instance(instance
))
1277 return no_debug_ospf_zebra_common(vty
, 5, argc
, argv
);
1281 DEFUN (debug_ospf_event
,
1282 debug_ospf_event_cmd
,
1286 "OSPF event information\n")
1288 if (vty
->node
== CONFIG_NODE
)
1289 CONF_DEBUG_ON(event
, EVENT
);
1290 TERM_DEBUG_ON(event
, EVENT
);
1294 DEFUN (no_debug_ospf_event
,
1295 no_debug_ospf_event_cmd
,
1296 "no debug ospf event",
1300 "OSPF event information\n")
1302 if (vty
->node
== CONFIG_NODE
)
1303 CONF_DEBUG_OFF(event
, EVENT
);
1304 TERM_DEBUG_OFF(event
, EVENT
);
1308 DEFUN (debug_ospf_instance_event
,
1309 debug_ospf_instance_event_cmd
,
1310 "debug ospf (1-65535) event",
1314 "OSPF event information\n")
1317 unsigned short instance
= 0;
1319 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1320 if (!ospf_lookup_instance(instance
))
1323 if (vty
->node
== CONFIG_NODE
)
1324 CONF_DEBUG_ON(event
, EVENT
);
1325 TERM_DEBUG_ON(event
, EVENT
);
1329 DEFUN (no_debug_ospf_instance_event
,
1330 no_debug_ospf_instance_event_cmd
,
1331 "no debug ospf (1-65535) event",
1336 "OSPF event information\n")
1339 unsigned short instance
= 0;
1341 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1342 if (!ospf_lookup_instance(instance
))
1345 if (vty
->node
== CONFIG_NODE
)
1346 CONF_DEBUG_OFF(event
, EVENT
);
1347 TERM_DEBUG_OFF(event
, EVENT
);
1351 DEFUN (debug_ospf_nssa
,
1352 debug_ospf_nssa_cmd
,
1356 "OSPF nssa information\n")
1358 if (vty
->node
== CONFIG_NODE
)
1359 CONF_DEBUG_ON(nssa
, NSSA
);
1360 TERM_DEBUG_ON(nssa
, NSSA
);
1364 DEFUN (no_debug_ospf_nssa
,
1365 no_debug_ospf_nssa_cmd
,
1366 "no debug ospf nssa",
1370 "OSPF nssa information\n")
1372 if (vty
->node
== CONFIG_NODE
)
1373 CONF_DEBUG_OFF(nssa
, NSSA
);
1374 TERM_DEBUG_OFF(nssa
, NSSA
);
1378 DEFUN (debug_ospf_instance_nssa
,
1379 debug_ospf_instance_nssa_cmd
,
1380 "debug ospf (1-65535) nssa",
1384 "OSPF nssa information\n")
1387 unsigned short instance
= 0;
1389 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1390 if (!ospf_lookup_instance(instance
))
1393 if (vty
->node
== CONFIG_NODE
)
1394 CONF_DEBUG_ON(nssa
, NSSA
);
1395 TERM_DEBUG_ON(nssa
, NSSA
);
1399 DEFUN (no_debug_ospf_instance_nssa
,
1400 no_debug_ospf_instance_nssa_cmd
,
1401 "no debug ospf (1-65535) nssa",
1406 "OSPF nssa information\n")
1409 unsigned short instance
= 0;
1411 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1412 if (!ospf_lookup_instance(instance
))
1415 if (vty
->node
== CONFIG_NODE
)
1416 CONF_DEBUG_OFF(nssa
, NSSA
);
1417 TERM_DEBUG_OFF(nssa
, NSSA
);
1421 DEFUN (debug_ospf_te
,
1426 "OSPF-TE information\n")
1428 if (vty
->node
== CONFIG_NODE
)
1429 CONF_DEBUG_ON(te
, TE
);
1430 TERM_DEBUG_ON(te
, TE
);
1434 DEFUN (no_debug_ospf_te
,
1435 no_debug_ospf_te_cmd
,
1440 "OSPF-TE information\n")
1442 if (vty
->node
== CONFIG_NODE
)
1443 CONF_DEBUG_OFF(te
, TE
);
1444 TERM_DEBUG_OFF(te
, TE
);
1448 DEFUN (debug_ospf_sr
,
1453 "OSPF-SR information\n")
1455 if (vty
->node
== CONFIG_NODE
)
1456 CONF_DEBUG_ON(sr
, SR
);
1457 TERM_DEBUG_ON(sr
, SR
);
1461 DEFUN (no_debug_ospf_sr
,
1462 no_debug_ospf_sr_cmd
,
1467 "OSPF-SR information\n")
1469 if (vty
->node
== CONFIG_NODE
)
1470 CONF_DEBUG_OFF(sr
, SR
);
1471 TERM_DEBUG_OFF(sr
, SR
);
1475 DEFUN (no_debug_ospf
,
1482 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1485 if (vty
->node
== CONFIG_NODE
) {
1486 CONF_DEBUG_OFF(event
, EVENT
);
1487 CONF_DEBUG_OFF(nssa
, NSSA
);
1488 DEBUG_OFF(ism
, ISM_EVENTS
);
1489 DEBUG_OFF(ism
, ISM_STATUS
);
1490 DEBUG_OFF(ism
, ISM_TIMERS
);
1491 DEBUG_OFF(lsa
, LSA
);
1492 DEBUG_OFF(lsa
, LSA_FLOODING
);
1493 DEBUG_OFF(lsa
, LSA_GENERATE
);
1494 DEBUG_OFF(lsa
, LSA_INSTALL
);
1495 DEBUG_OFF(lsa
, LSA_REFRESH
);
1496 DEBUG_OFF(nsm
, NSM
);
1497 DEBUG_OFF(nsm
, NSM_EVENTS
);
1498 DEBUG_OFF(nsm
, NSM_STATUS
);
1499 DEBUG_OFF(nsm
, NSM_TIMERS
);
1500 DEBUG_OFF(zebra
, ZEBRA
);
1501 DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1502 DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1504 for (i
= 0; i
< 5; i
++)
1505 DEBUG_PACKET_OFF(i
, flag
);
1508 for (i
= 0; i
< 5; i
++)
1509 TERM_DEBUG_PACKET_OFF(i
, flag
);
1511 TERM_DEBUG_OFF(event
, EVENT
);
1512 TERM_DEBUG_OFF(ism
, ISM
);
1513 TERM_DEBUG_OFF(ism
, ISM_EVENTS
);
1514 TERM_DEBUG_OFF(ism
, ISM_STATUS
);
1515 TERM_DEBUG_OFF(ism
, ISM_TIMERS
);
1516 TERM_DEBUG_OFF(lsa
, LSA
);
1517 TERM_DEBUG_OFF(lsa
, LSA_FLOODING
);
1518 TERM_DEBUG_OFF(lsa
, LSA_GENERATE
);
1519 TERM_DEBUG_OFF(lsa
, LSA_INSTALL
);
1520 TERM_DEBUG_OFF(lsa
, LSA_REFRESH
);
1521 TERM_DEBUG_OFF(nsm
, NSM
);
1522 TERM_DEBUG_OFF(nsm
, NSM_EVENTS
);
1523 TERM_DEBUG_OFF(nsm
, NSM_STATUS
);
1524 TERM_DEBUG_OFF(nsm
, NSM_TIMERS
);
1525 TERM_DEBUG_OFF(nssa
, NSSA
);
1526 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1527 TERM_DEBUG_OFF(zebra
, ZEBRA_INTERFACE
);
1528 TERM_DEBUG_OFF(zebra
, ZEBRA_REDISTRIBUTE
);
1533 static int show_debugging_ospf_common(struct vty
*vty
, struct ospf
*ospf
)
1538 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
1540 vty_out(vty
, "OSPF debugging status:\n");
1542 /* Show debug status for events. */
1543 if (IS_DEBUG_OSPF(event
, EVENT
))
1544 vty_out(vty
, " OSPF event debugging is on\n");
1546 /* Show debug status for ISM. */
1547 if (IS_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1548 vty_out(vty
, " OSPF ISM debugging is on\n");
1550 if (IS_DEBUG_OSPF(ism
, ISM_STATUS
))
1551 vty_out(vty
, " OSPF ISM status debugging is on\n");
1552 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
1553 vty_out(vty
, " OSPF ISM event debugging is on\n");
1554 if (IS_DEBUG_OSPF(ism
, ISM_TIMERS
))
1555 vty_out(vty
, " OSPF ISM timer debugging is on\n");
1558 /* Show debug status for NSM. */
1559 if (IS_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1560 vty_out(vty
, " OSPF NSM debugging is on\n");
1562 if (IS_DEBUG_OSPF(nsm
, NSM_STATUS
))
1563 vty_out(vty
, " OSPF NSM status debugging is on\n");
1564 if (IS_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1565 vty_out(vty
, " OSPF NSM event debugging is on\n");
1566 if (IS_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1567 vty_out(vty
, " OSPF NSM timer debugging is on\n");
1570 /* Show debug status for OSPF Packets. */
1571 for (i
= 0; i
< 5; i
++)
1572 if (IS_DEBUG_OSPF_PACKET(i
, SEND
)
1573 && IS_DEBUG_OSPF_PACKET(i
, RECV
)) {
1574 vty_out(vty
, " OSPF packet %s%s debugging is on\n",
1575 lookup_msg(ospf_packet_type_str
, i
+ 1, NULL
),
1576 IS_DEBUG_OSPF_PACKET(i
, DETAIL
) ? " detail"
1579 if (IS_DEBUG_OSPF_PACKET(i
, SEND
))
1581 " OSPF packet %s send%s debugging is on\n",
1582 lookup_msg(ospf_packet_type_str
, i
+ 1,
1584 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1587 if (IS_DEBUG_OSPF_PACKET(i
, RECV
))
1589 " OSPF packet %s receive%s debugging is on\n",
1590 lookup_msg(ospf_packet_type_str
, i
+ 1,
1592 IS_DEBUG_OSPF_PACKET(i
, DETAIL
)
1597 /* Show debug status for OSPF LSAs. */
1598 if (IS_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1599 vty_out(vty
, " OSPF LSA debugging is on\n");
1601 if (IS_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1602 vty_out(vty
, " OSPF LSA generation debugging is on\n");
1603 if (IS_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1604 vty_out(vty
, " OSPF LSA flooding debugging is on\n");
1605 if (IS_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1606 vty_out(vty
, " OSPF LSA install debugging is on\n");
1607 if (IS_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1608 vty_out(vty
, " OSPF LSA refresh debugging is on\n");
1611 /* Show debug status for Zebra. */
1612 if (IS_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1613 vty_out(vty
, " OSPF Zebra debugging is on\n");
1615 if (IS_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1617 " OSPF Zebra interface debugging is on\n");
1618 if (IS_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1620 " OSPF Zebra redistribute debugging is on\n");
1623 /* Show debug status for NSSA. */
1624 if (IS_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1625 vty_out(vty
, " OSPF NSSA debugging is on\n");
1632 DEFUN_NOSH (show_debugging_ospf
,
1633 show_debugging_ospf_cmd
,
1634 "show debugging [ospf]",
1639 struct ospf
*ospf
= NULL
;
1641 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1645 return show_debugging_ospf_common(vty
, ospf
);
1648 DEFUN_NOSH (show_debugging_ospf_instance
,
1649 show_debugging_ospf_instance_cmd
,
1650 "show debugging ospf (1-65535)",
1658 unsigned short instance
= 0;
1660 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1661 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
)
1664 return show_debugging_ospf_common(vty
, ospf
);
1668 static struct cmd_node debug_node
= {
1669 DEBUG_NODE
, "", 1 /* VTYSH */
1672 static int config_write_debug(struct vty
*vty
)
1677 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update",
1679 const char *detail_str
[] = {
1680 "", " send", " recv", "",
1681 " detail", " send detail", " recv detail", " detail"};
1687 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
1692 sprintf(str
, " %d", ospf
->instance
);
1694 /* debug ospf ism (status|events|timers). */
1695 if (IS_CONF_DEBUG_OSPF(ism
, ISM
) == OSPF_DEBUG_ISM
)
1696 vty_out(vty
, "debug ospf%s ism\n", str
);
1698 if (IS_CONF_DEBUG_OSPF(ism
, ISM_STATUS
))
1699 vty_out(vty
, "debug ospf%s ism status\n", str
);
1700 if (IS_CONF_DEBUG_OSPF(ism
, ISM_EVENTS
))
1701 vty_out(vty
, "debug ospf%s ism event\n", str
);
1702 if (IS_CONF_DEBUG_OSPF(ism
, ISM_TIMERS
))
1703 vty_out(vty
, "debug ospf%s ism timer\n", str
);
1706 /* debug ospf nsm (status|events|timers). */
1707 if (IS_CONF_DEBUG_OSPF(nsm
, NSM
) == OSPF_DEBUG_NSM
)
1708 vty_out(vty
, "debug ospf%s nsm\n", str
);
1710 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_STATUS
))
1711 vty_out(vty
, "debug ospf%s nsm status\n", str
);
1712 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_EVENTS
))
1713 vty_out(vty
, "debug ospf%s nsm event\n", str
);
1714 if (IS_CONF_DEBUG_OSPF(nsm
, NSM_TIMERS
))
1715 vty_out(vty
, "debug ospf%s nsm timer\n", str
);
1718 /* debug ospf lsa (generate|flooding|install|refresh). */
1719 if (IS_CONF_DEBUG_OSPF(lsa
, LSA
) == OSPF_DEBUG_LSA
)
1720 vty_out(vty
, "debug ospf%s lsa\n", str
);
1722 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_GENERATE
))
1723 vty_out(vty
, "debug ospf%s lsa generate\n", str
);
1724 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_FLOODING
))
1725 vty_out(vty
, "debug ospf%s lsa flooding\n", str
);
1726 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_INSTALL
))
1727 vty_out(vty
, "debug ospf%s lsa install\n", str
);
1728 if (IS_CONF_DEBUG_OSPF(lsa
, LSA_REFRESH
))
1729 vty_out(vty
, "debug ospf%s lsa refresh\n", str
);
1734 /* debug ospf zebra (interface|redistribute). */
1735 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1736 vty_out(vty
, "debug ospf%s zebra\n", str
);
1738 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_INTERFACE
))
1739 vty_out(vty
, "debug ospf%s zebra interface\n", str
);
1740 if (IS_CONF_DEBUG_OSPF(zebra
, ZEBRA_REDISTRIBUTE
))
1741 vty_out(vty
, "debug ospf%s zebra redistribute\n", str
);
1746 /* debug ospf event. */
1747 if (IS_CONF_DEBUG_OSPF(event
, EVENT
) == OSPF_DEBUG_EVENT
) {
1748 vty_out(vty
, "debug ospf%s event\n", str
);
1752 /* debug ospf nssa. */
1753 if (IS_CONF_DEBUG_OSPF(nssa
, NSSA
) == OSPF_DEBUG_NSSA
) {
1754 vty_out(vty
, "debug ospf%s nssa\n", str
);
1758 /* debug ospf packet all detail. */
1759 r
= OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
;
1760 for (i
= 0; i
< 5; i
++)
1761 r
&= conf_debug_ospf_packet
[i
]
1762 & (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
);
1763 if (r
== (OSPF_DEBUG_SEND_RECV
| OSPF_DEBUG_DETAIL
)) {
1764 vty_out(vty
, "debug ospf%s packet all detail\n", str
);
1768 /* debug ospf packet all. */
1769 r
= OSPF_DEBUG_SEND_RECV
;
1770 for (i
= 0; i
< 5; i
++)
1771 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
1772 if (r
== OSPF_DEBUG_SEND_RECV
) {
1773 vty_out(vty
, "debug ospf%s packet all\n", str
);
1774 for (i
= 0; i
< 5; i
++)
1775 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
1776 vty_out(vty
, "debug ospf%s packet %s detail\n",
1781 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1782 (send|recv) (detail). */
1783 for (i
= 0; i
< 5; i
++) {
1784 if (conf_debug_ospf_packet
[i
] == 0)
1787 vty_out(vty
, "debug ospf%s packet %s%s\n", str
, type_str
[i
],
1788 detail_str
[conf_debug_ospf_packet
[i
]]);
1793 if (IS_CONF_DEBUG_OSPF(te
, TE
) == OSPF_DEBUG_TE
) {
1794 vty_out(vty
, "debug ospf%s te\n", str
);
1799 if (IS_CONF_DEBUG_OSPF(sr
, SR
) == OSPF_DEBUG_SR
) {
1800 vty_out(vty
, "debug ospf%s sr\n", str
);
1807 /* Initialize debug commands. */
1810 install_node(&debug_node
, config_write_debug
);
1812 install_element(ENABLE_NODE
, &show_debugging_ospf_cmd
);
1813 install_element(ENABLE_NODE
, &debug_ospf_ism_cmd
);
1814 install_element(ENABLE_NODE
, &debug_ospf_nsm_cmd
);
1815 install_element(ENABLE_NODE
, &debug_ospf_lsa_cmd
);
1816 install_element(ENABLE_NODE
, &debug_ospf_zebra_cmd
);
1817 install_element(ENABLE_NODE
, &debug_ospf_event_cmd
);
1818 install_element(ENABLE_NODE
, &debug_ospf_nssa_cmd
);
1819 install_element(ENABLE_NODE
, &debug_ospf_te_cmd
);
1820 install_element(ENABLE_NODE
, &debug_ospf_sr_cmd
);
1821 install_element(ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
1822 install_element(ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
1823 install_element(ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
1824 install_element(ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
1825 install_element(ENABLE_NODE
, &no_debug_ospf_event_cmd
);
1826 install_element(ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
1827 install_element(ENABLE_NODE
, &no_debug_ospf_te_cmd
);
1828 install_element(ENABLE_NODE
, &no_debug_ospf_sr_cmd
);
1830 install_element(ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
1831 install_element(ENABLE_NODE
, &debug_ospf_packet_cmd
);
1832 install_element(ENABLE_NODE
, &no_debug_ospf_packet_cmd
);
1834 install_element(ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
1835 install_element(ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
1836 install_element(ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
1837 install_element(ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
1838 install_element(ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
1839 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1840 install_element(ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1841 install_element(ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1842 install_element(ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
1843 install_element(ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1844 install_element(ENABLE_NODE
, &no_debug_ospf_cmd
);
1846 install_element(CONFIG_NODE
, &debug_ospf_packet_cmd
);
1847 install_element(CONFIG_NODE
, &no_debug_ospf_packet_cmd
);
1848 install_element(CONFIG_NODE
, &debug_ospf_ism_cmd
);
1849 install_element(CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
1851 install_element(CONFIG_NODE
, &debug_ospf_nsm_cmd
);
1852 install_element(CONFIG_NODE
, &debug_ospf_lsa_cmd
);
1853 install_element(CONFIG_NODE
, &debug_ospf_zebra_cmd
);
1854 install_element(CONFIG_NODE
, &debug_ospf_event_cmd
);
1855 install_element(CONFIG_NODE
, &debug_ospf_nssa_cmd
);
1856 install_element(CONFIG_NODE
, &debug_ospf_te_cmd
);
1857 install_element(CONFIG_NODE
, &debug_ospf_sr_cmd
);
1858 install_element(CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
1859 install_element(CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
1860 install_element(CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
1861 install_element(CONFIG_NODE
, &no_debug_ospf_event_cmd
);
1862 install_element(CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
1863 install_element(CONFIG_NODE
, &no_debug_ospf_te_cmd
);
1864 install_element(CONFIG_NODE
, &no_debug_ospf_sr_cmd
);
1866 install_element(CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
1867 install_element(CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
1868 install_element(CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
1869 install_element(CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
1870 install_element(CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
1871 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
1872 install_element(CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
1873 install_element(CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
1874 install_element(CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
1875 install_element(CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
1876 install_element(CONFIG_NODE
, &no_debug_ospf_cmd
);