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
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, 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 struct message ospf_ism_state_msg
[] =
47 { ISM_DependUpon
, "DependUpon" },
49 { ISM_Loopback
, "Loopback" },
50 { ISM_Waiting
, "Waiting" },
51 { ISM_PointToPoint
, "Point-To-Point" },
52 { ISM_DROther
, "DROther" },
53 { ISM_Backup
, "Backup" },
56 int ospf_ism_state_msg_max
= OSPF_ISM_STATE_MAX
;
58 struct message ospf_nsm_state_msg
[] =
60 { NSM_DependUpon
, "DependUpon" },
61 { NSM_Deleted
, "Deleted" },
63 { NSM_Attempt
, "Attempt" },
65 { NSM_TwoWay
, "2-Way" },
66 { NSM_ExStart
, "ExStart" },
67 { NSM_Exchange
, "Exchange" },
68 { NSM_Loading
, "Loading" },
71 int ospf_nsm_state_msg_max
= OSPF_NSM_STATE_MAX
;
73 struct message ospf_lsa_type_msg
[] =
75 { OSPF_UNKNOWN_LSA
, "unknown" },
76 { OSPF_ROUTER_LSA
, "router-LSA" },
77 { OSPF_NETWORK_LSA
, "network-LSA" },
78 { OSPF_SUMMARY_LSA
, "summary-LSA" },
79 { OSPF_ASBR_SUMMARY_LSA
, "summary-LSA" },
80 { OSPF_AS_EXTERNAL_LSA
, "AS-external-LSA" },
81 { OSPF_GROUP_MEMBER_LSA
, "GROUP MEMBER LSA" },
82 { OSPF_AS_NSSA_LSA
, "NSSA-LSA" },
84 { OSPF_OPAQUE_LINK_LSA
, "Link-Local Opaque-LSA" },
85 { OSPF_OPAQUE_AREA_LSA
, "Area-Local Opaque-LSA" },
86 { OSPF_OPAQUE_AS_LSA
, "AS-external Opaque-LSA" },
88 int ospf_lsa_type_msg_max
= OSPF_MAX_LSA
;
90 struct message ospf_link_state_id_type_msg
[] =
92 { OSPF_UNKNOWN_LSA
, "(unknown)" },
93 { OSPF_ROUTER_LSA
, "" },
94 { OSPF_NETWORK_LSA
, "(address of Designated Router)" },
95 { OSPF_SUMMARY_LSA
, "(summary Network Number)" },
96 { OSPF_ASBR_SUMMARY_LSA
, "(AS Boundary Router address)" },
97 { OSPF_AS_EXTERNAL_LSA
, "(External Network Number)" },
98 { OSPF_GROUP_MEMBER_LSA
, "(Group membership information)" },
99 { OSPF_AS_NSSA_LSA
, "(External Network Number for NSSA)" },
100 { 8, "(Type-8 LSID)" },
101 { OSPF_OPAQUE_LINK_LSA
, "(Link-Local Opaque-Type/ID)" },
102 { OSPF_OPAQUE_AREA_LSA
, "(Area-Local Opaque-Type/ID)" },
103 { OSPF_OPAQUE_AS_LSA
, "(AS-external Opaque-Type/ID)" },
105 int ospf_link_state_id_type_msg_max
= OSPF_MAX_LSA
;
107 struct message ospf_network_type_msg
[] =
109 { OSPF_IFTYPE_NONE
, "NONE" },
110 { OSPF_IFTYPE_POINTOPOINT
, "Point-to-Point" },
111 { OSPF_IFTYPE_BROADCAST
, "Broadcast" },
112 { OSPF_IFTYPE_NBMA
, "NBMA" },
113 { OSPF_IFTYPE_POINTOMULTIPOINT
, "Point-to-MultiPoint" },
114 { OSPF_IFTYPE_VIRTUALLINK
, "Virtual-Link" },
116 int ospf_network_type_msg_max
= OSPF_IFTYPE_MAX
;
118 /* Configuration debug option variables. */
119 unsigned long conf_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
120 unsigned long conf_debug_ospf_event
= 0;
121 unsigned long conf_debug_ospf_ism
= 0;
122 unsigned long conf_debug_ospf_nsm
= 0;
123 unsigned long conf_debug_ospf_lsa
= 0;
124 unsigned long conf_debug_ospf_zebra
= 0;
125 unsigned long conf_debug_ospf_nssa
= 0;
127 /* Enable debug option variables -- valid only session. */
128 unsigned long term_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
129 unsigned long term_debug_ospf_event
= 0;
130 unsigned long term_debug_ospf_ism
= 0;
131 unsigned long term_debug_ospf_nsm
= 0;
132 unsigned long term_debug_ospf_lsa
= 0;
133 unsigned long term_debug_ospf_zebra
= 0;
134 unsigned long term_debug_ospf_nssa
= 0;
139 ospf_redist_string(u_int route_type
)
141 return (route_type
== ZEBRA_ROUTE_MAX
) ?
142 "Default" : zebra_route_string(route_type
);
145 #define OSPF_AREA_STRING_MAXLEN 16
147 ospf_area_name_string (struct ospf_area
*area
)
149 static char buf
[OSPF_AREA_STRING_MAXLEN
] = "";
155 area_id
= ntohl (area
->area_id
.s_addr
);
156 snprintf (buf
, OSPF_AREA_STRING_MAXLEN
, "%d.%d.%d.%d",
157 (area_id
>> 24) & 0xff, (area_id
>> 16) & 0xff,
158 (area_id
>> 8) & 0xff, area_id
& 0xff);
162 #define OSPF_AREA_DESC_STRING_MAXLEN 23
164 ospf_area_desc_string (struct ospf_area
*area
)
166 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
170 return "(incomplete)";
172 type
= area
->external_routing
;
176 snprintf (buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [NSSA]",
177 ospf_area_name_string (area
));
180 snprintf (buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [Stub]",
181 ospf_area_name_string (area
));
184 return ospf_area_name_string (area
);
190 #define OSPF_IF_STRING_MAXLEN 40
192 ospf_if_name_string (struct ospf_interface
*oi
)
194 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
200 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
201 return oi
->ifp
->name
;
203 ifaddr
= ntohl (oi
->address
->u
.prefix4
.s_addr
);
204 snprintf (buf
, OSPF_IF_STRING_MAXLEN
,
205 "%s:%d.%d.%d.%d", oi
->ifp
->name
,
206 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
207 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
213 ospf_nbr_state_message (struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
216 struct ospf_interface
*oi
= nbr
->oi
;
218 if (IPV4_ADDR_SAME (&DR (oi
), &nbr
->address
.u
.prefix4
))
220 else if (IPV4_ADDR_SAME (&BDR (oi
), &nbr
->address
.u
.prefix4
))
225 memset (buf
, 0, size
);
227 snprintf (buf
, size
, "%s/%s",
228 LOOKUP (ospf_nsm_state_msg
, nbr
->state
),
229 LOOKUP (ospf_ism_state_msg
, state
));
233 ospf_timeval_dump (struct timeval
*t
, char *buf
, size_t size
)
235 /* Making formatted timer strings. */
236 #define MINUTE_IN_SECONDS 60
237 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
238 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
239 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
240 unsigned long w
, d
, h
, m
, s
, ms
;
245 w
= d
= h
= m
= s
= ms
= 0;
246 memset (buf
, 0, size
);
248 ms
= t
->tv_usec
/ 1000;
252 t
->tv_sec
+= ms
/ 1000;
256 if (t
->tv_sec
> WEEK_IN_SECONDS
)
258 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
259 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
262 if (t
->tv_sec
> DAY_IN_SECONDS
)
264 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
265 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
268 if (t
->tv_sec
>= HOUR_IN_SECONDS
)
270 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
271 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
274 if (t
->tv_sec
>= MINUTE_IN_SECONDS
)
276 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
277 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
281 snprintf (buf
, size
, "%ldw%1ldd", w
, d
);
283 snprintf (buf
, size
, "%ldw%1ldd%02ldh", w
, d
, h
);
285 snprintf (buf
, size
, "%1ldd%02ldh%02ldm", d
, h
, m
);
287 snprintf (buf
, size
, "%ldh%02ldm%02lds", h
, m
, t
->tv_sec
);
289 snprintf (buf
, size
, "%ldm%02lds", m
, t
->tv_sec
);
291 snprintf (buf
, size
, "%ld.%03lds", t
->tv_sec
, ms
);
297 ospf_timer_dump (struct thread
*t
, char *buf
, size_t size
)
299 struct timeval result
;
303 result
= tv_sub (t
->u
.sands
, recent_relative_time());
304 return ospf_timeval_dump (&result
, buf
, size
);
307 #define OSPF_OPTION_STR_MAXLEN 24
310 ospf_options_dump (u_char options
)
312 static char buf
[OSPF_OPTION_STR_MAXLEN
];
314 snprintf (buf
, OSPF_OPTION_STR_MAXLEN
, "*|%s|%s|%s|%s|%s|%s|*",
315 (options
& OSPF_OPTION_O
) ? "O" : "-",
316 (options
& OSPF_OPTION_DC
) ? "DC" : "-",
317 (options
& OSPF_OPTION_EA
) ? "EA" : "-",
318 (options
& OSPF_OPTION_NP
) ? "N/P" : "-",
319 (options
& OSPF_OPTION_MC
) ? "MC" : "-",
320 (options
& OSPF_OPTION_E
) ? "E" : "-");
326 ospf_packet_hello_dump (struct stream
*s
, u_int16_t length
)
328 struct ospf_hello
*hello
;
331 hello
= (struct ospf_hello
*) STREAM_PNT (s
);
333 zlog_debug ("Hello");
334 zlog_debug (" NetworkMask %s", inet_ntoa (hello
->network_mask
));
335 zlog_debug (" HelloInterval %d", ntohs (hello
->hello_interval
));
336 zlog_debug (" Options %d (%s)", hello
->options
,
337 ospf_options_dump (hello
->options
));
338 zlog_debug (" RtrPriority %d", hello
->priority
);
339 zlog_debug (" RtrDeadInterval %ld", (u_long
)ntohl (hello
->dead_interval
));
340 zlog_debug (" DRouter %s", inet_ntoa (hello
->d_router
));
341 zlog_debug (" BDRouter %s", inet_ntoa (hello
->bd_router
));
343 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
344 zlog_debug (" # Neighbors %d", length
/ 4);
345 for (i
= 0; length
> 0; i
++, length
-= sizeof (struct in_addr
))
346 zlog_debug (" Neighbor %s", inet_ntoa (hello
->neighbors
[i
]));
350 ospf_dd_flags_dump (u_char flags
, char *buf
, size_t size
)
352 memset (buf
, 0, size
);
354 snprintf (buf
, size
, "%s|%s|%s",
355 (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
356 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
357 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
363 ospf_lsa_header_dump (struct lsa_header
*lsah
)
365 const char *lsah_type
= LOOKUP (ospf_lsa_type_msg
, lsah
->type
);
367 zlog_debug (" LSA Header");
368 zlog_debug (" LS age %d", ntohs (lsah
->ls_age
));
369 zlog_debug (" Options %d (%s)", lsah
->options
,
370 ospf_options_dump (lsah
->options
));
371 zlog_debug (" LS type %d (%s)", lsah
->type
,
372 (lsah
->type
? lsah_type
: "unknown type"));
373 zlog_debug (" Link State ID %s", inet_ntoa (lsah
->id
));
374 zlog_debug (" Advertising Router %s", inet_ntoa (lsah
->adv_router
));
375 zlog_debug (" LS sequence number 0x%lx", (u_long
)ntohl (lsah
->ls_seqnum
));
376 zlog_debug (" LS checksum 0x%x", ntohs (lsah
->checksum
));
377 zlog_debug (" length %d", ntohs (lsah
->length
));
381 ospf_router_lsa_flags_dump (u_char flags
, char *buf
, size_t size
)
383 memset (buf
, 0, size
);
385 snprintf (buf
, size
, "%s|%s|%s",
386 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
387 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
388 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
394 ospf_router_lsa_dump (struct stream
*s
, u_int16_t length
)
397 struct router_lsa
*rl
;
400 rl
= (struct router_lsa
*) STREAM_PNT (s
);
402 zlog_debug (" Router-LSA");
403 zlog_debug (" flags %s",
404 ospf_router_lsa_flags_dump (rl
->flags
, buf
, BUFSIZ
));
405 zlog_debug (" # links %d", ntohs (rl
->links
));
407 len
= ntohs (rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
408 for (i
= 0; len
> 0; i
++)
410 zlog_debug (" Link ID %s", inet_ntoa (rl
->link
[i
].link_id
));
411 zlog_debug (" Link Data %s", inet_ntoa (rl
->link
[i
].link_data
));
412 zlog_debug (" Type %d", (u_char
) rl
->link
[i
].type
);
413 zlog_debug (" TOS %d", (u_char
) rl
->link
[i
].tos
);
414 zlog_debug (" metric %d", ntohs (rl
->link
[i
].metric
));
421 ospf_network_lsa_dump (struct stream
*s
, u_int16_t length
)
423 struct network_lsa
*nl
;
426 nl
= (struct network_lsa
*) STREAM_PNT (s
);
427 cnt
= (ntohs (nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
429 zlog_debug (" Network-LSA");
431 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
432 zlog_debug ("Network-LSA size %d",
433 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
435 zlog_debug (" Network Mask %s", inet_ntoa (nl
->mask
));
436 zlog_debug (" # Attached Routers %d", cnt
);
437 for (i
= 0; i
< cnt
; i
++)
438 zlog_debug (" Attached Router %s", inet_ntoa (nl
->routers
[i
]));
442 ospf_summary_lsa_dump (struct stream
*s
, u_int16_t length
)
444 struct summary_lsa
*sl
;
448 sl
= (struct summary_lsa
*) STREAM_PNT (s
);
450 zlog_debug (" Summary-LSA");
451 zlog_debug (" Network Mask %s", inet_ntoa (sl
->mask
));
453 size
= ntohs (sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
454 for (i
= 0; size
> 0; size
-= 4, i
++)
455 zlog_debug (" TOS=%d metric %d", sl
->tos
,
456 GET_METRIC (sl
->metric
));
460 ospf_as_external_lsa_dump (struct stream
*s
, u_int16_t length
)
462 struct as_external_lsa
*al
;
466 al
= (struct as_external_lsa
*) STREAM_PNT (s
);
467 zlog_debug (" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
468 zlog_debug (" Network Mask %s", inet_ntoa (al
->mask
));
470 size
= ntohs (al
->header
.length
) - OSPF_LSA_HEADER_SIZE
-4;
471 for (i
= 0; size
> 0; size
-= 12, i
++)
473 zlog_debug (" bit %s TOS=%d metric %d",
474 IS_EXTERNAL_METRIC (al
->e
[i
].tos
) ? "E" : "-",
475 al
->e
[i
].tos
& 0x7f, GET_METRIC (al
->e
[i
].metric
));
476 zlog_debug (" Forwarding address %s", inet_ntoa (al
->e
[i
].fwd_addr
));
477 zlog_debug (" External Route Tag %d", al
->e
[i
].route_tag
);
482 ospf_lsa_header_list_dump (struct stream
*s
, u_int16_t length
)
484 struct lsa_header
*lsa
;
486 zlog_debug (" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
491 lsa
= (struct lsa_header
*) STREAM_PNT (s
);
492 ospf_lsa_header_dump (lsa
);
494 stream_forward_getp (s
, OSPF_LSA_HEADER_SIZE
);
495 length
-= OSPF_LSA_HEADER_SIZE
;
500 ospf_packet_db_desc_dump (struct stream
*s
, u_int16_t length
)
502 struct ospf_db_desc
*dd
;
507 gp
= stream_get_getp (s
);
508 dd
= (struct ospf_db_desc
*) STREAM_PNT (s
);
510 zlog_debug ("Database Description");
511 zlog_debug (" Interface MTU %d", ntohs (dd
->mtu
));
512 zlog_debug (" Options %d (%s)", dd
->options
,
513 ospf_options_dump (dd
->options
));
514 zlog_debug (" Flags %d (%s)", dd
->flags
,
515 ospf_dd_flags_dump (dd
->flags
, dd_flags
, sizeof dd_flags
));
516 zlog_debug (" Sequence Number 0x%08lx", (u_long
)ntohl (dd
->dd_seqnum
));
518 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
520 stream_forward_getp (s
, OSPF_DB_DESC_MIN_SIZE
);
522 ospf_lsa_header_list_dump (s
, length
);
524 stream_set_getp (s
, gp
);
528 ospf_packet_ls_req_dump (struct stream
*s
, u_int16_t length
)
532 struct in_addr ls_id
;
533 struct in_addr adv_router
;
535 sp
= stream_get_getp (s
);
537 length
-= OSPF_HEADER_SIZE
;
539 zlog_debug ("Link State Request");
540 zlog_debug (" # Requests %d", length
/ 12);
542 for (; length
> 0; length
-= 12)
544 ls_type
= stream_getl (s
);
545 ls_id
.s_addr
= stream_get_ipv4 (s
);
546 adv_router
.s_addr
= stream_get_ipv4 (s
);
548 zlog_debug (" LS type %d", ls_type
);
549 zlog_debug (" Link State ID %s", inet_ntoa (ls_id
));
550 zlog_debug (" Advertising Router %s",
551 inet_ntoa (adv_router
));
554 stream_set_getp (s
, sp
);
558 ospf_packet_ls_upd_dump (struct stream
*s
, u_int16_t length
)
561 struct lsa_header
*lsa
;
565 length
-= OSPF_HEADER_SIZE
;
567 sp
= stream_get_getp (s
);
569 count
= stream_getl (s
);
572 zlog_debug ("Link State Update");
573 zlog_debug (" # LSAs %d", count
);
575 while (length
> 0 && count
> 0)
577 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0)
579 zlog_debug (" Remaining %d bytes; Incorrect length.", length
);
583 lsa
= (struct lsa_header
*) STREAM_PNT (s
);
584 lsa_len
= ntohs (lsa
->length
);
585 ospf_lsa_header_dump (lsa
);
589 case OSPF_ROUTER_LSA
:
590 ospf_router_lsa_dump (s
, length
);
592 case OSPF_NETWORK_LSA
:
593 ospf_network_lsa_dump (s
, length
);
595 case OSPF_SUMMARY_LSA
:
596 case OSPF_ASBR_SUMMARY_LSA
:
597 ospf_summary_lsa_dump (s
, length
);
599 case OSPF_AS_EXTERNAL_LSA
:
600 ospf_as_external_lsa_dump (s
, length
);
602 case OSPF_AS_NSSA_LSA
:
603 ospf_as_external_lsa_dump (s
, length
);
605 #ifdef HAVE_OPAQUE_LSA
606 case OSPF_OPAQUE_LINK_LSA
:
607 case OSPF_OPAQUE_AREA_LSA
:
608 case OSPF_OPAQUE_AS_LSA
:
609 ospf_opaque_lsa_dump (s
, length
);
611 #endif /* HAVE_OPAQUE_LSA */
616 stream_forward_getp (s
, lsa_len
);
621 stream_set_getp (s
, sp
);
625 ospf_packet_ls_ack_dump (struct stream
*s
, u_int16_t length
)
629 length
-= OSPF_HEADER_SIZE
;
630 sp
= stream_get_getp (s
);
632 zlog_debug ("Link State Acknowledgment");
633 ospf_lsa_header_list_dump (s
, length
);
635 stream_set_getp (s
, sp
);
638 /* Expects header to be in host order */
640 ospf_ip_header_dump (struct ip
*iph
)
642 /* IP Header dump. */
643 zlog_debug ("ip_v %d", iph
->ip_v
);
644 zlog_debug ("ip_hl %d", iph
->ip_hl
);
645 zlog_debug ("ip_tos %d", iph
->ip_tos
);
646 zlog_debug ("ip_len %d", iph
->ip_len
);
647 zlog_debug ("ip_id %u", (u_int32_t
) iph
->ip_id
);
648 zlog_debug ("ip_off %u", (u_int32_t
) iph
->ip_off
);
649 zlog_debug ("ip_ttl %d", iph
->ip_ttl
);
650 zlog_debug ("ip_p %d", iph
->ip_p
);
651 zlog_debug ("ip_sum 0x%x", (u_int32_t
) iph
->ip_sum
);
652 zlog_debug ("ip_src %s", inet_ntoa (iph
->ip_src
));
653 zlog_debug ("ip_dst %s", inet_ntoa (iph
->ip_dst
));
657 ospf_header_dump (struct ospf_header
*ospfh
)
661 zlog_debug ("Header");
662 zlog_debug (" Version %d", ospfh
->version
);
663 zlog_debug (" Type %d (%s)", ospfh
->type
,
664 ospf_packet_type_str
[ospfh
->type
]);
665 zlog_debug (" Packet Len %d", ntohs (ospfh
->length
));
666 zlog_debug (" Router ID %s", inet_ntoa (ospfh
->router_id
));
667 zlog_debug (" Area ID %s", inet_ntoa (ospfh
->area_id
));
668 zlog_debug (" Checksum 0x%x", ntohs (ospfh
->checksum
));
669 zlog_debug (" AuType %d", ntohs (ospfh
->auth_type
));
671 switch (ntohs (ospfh
->auth_type
))
675 case OSPF_AUTH_SIMPLE
:
677 strncpy (buf
, (char *) ospfh
->u
.auth_data
, 8);
678 zlog_debug (" Simple Password %s", buf
);
680 case OSPF_AUTH_CRYPTOGRAPHIC
:
681 zlog_debug (" Cryptographic Authentication");
682 zlog_debug (" Key ID %d", ospfh
->u
.crypt
.key_id
);
683 zlog_debug (" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
684 zlog_debug (" Sequence number %ld",
685 (u_long
)ntohl (ospfh
->u
.crypt
.crypt_seqnum
));
688 zlog_debug ("* This is not supported authentication type");
695 ospf_packet_dump (struct stream
*s
)
697 struct ospf_header
*ospfh
;
700 /* Preserve pointer. */
701 gp
= stream_get_getp (s
);
703 /* OSPF Header dump. */
704 ospfh
= (struct ospf_header
*) STREAM_PNT (s
);
706 /* Until detail flag is set, return. */
707 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
710 /* Show OSPF header detail. */
711 ospf_header_dump (ospfh
);
712 stream_forward_getp (s
, OSPF_HEADER_SIZE
);
717 ospf_packet_hello_dump (s
, ntohs (ospfh
->length
));
719 case OSPF_MSG_DB_DESC
:
720 ospf_packet_db_desc_dump (s
, ntohs (ospfh
->length
));
722 case OSPF_MSG_LS_REQ
:
723 ospf_packet_ls_req_dump (s
, ntohs (ospfh
->length
));
725 case OSPF_MSG_LS_UPD
:
726 ospf_packet_ls_upd_dump (s
, ntohs (ospfh
->length
));
728 case OSPF_MSG_LS_ACK
:
729 ospf_packet_ls_ack_dump (s
, ntohs (ospfh
->length
));
735 stream_set_getp (s
, gp
);
740 [no] debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)
743 DEFUN (debug_ospf_packet
,
744 debug_ospf_packet_all_cmd
,
745 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
750 "OSPF Database Description\n"
751 "OSPF Link State Request\n"
752 "OSPF Link State Update\n"
753 "OSPF Link State Acknowledgment\n"
754 "OSPF all packets\n")
762 /* Check packet type. */
763 if (strncmp (argv
[0], "h", 1) == 0)
764 type
= OSPF_DEBUG_HELLO
;
765 else if (strncmp (argv
[0], "d", 1) == 0)
766 type
= OSPF_DEBUG_DB_DESC
;
767 else if (strncmp (argv
[0], "ls-r", 4) == 0)
768 type
= OSPF_DEBUG_LS_REQ
;
769 else if (strncmp (argv
[0], "ls-u", 4) == 0)
770 type
= OSPF_DEBUG_LS_UPD
;
771 else if (strncmp (argv
[0], "ls-a", 4) == 0)
772 type
= OSPF_DEBUG_LS_ACK
;
773 else if (strncmp (argv
[0], "a", 1) == 0)
774 type
= OSPF_DEBUG_ALL
;
776 /* Default, both send and recv. */
778 flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
;
783 if (strncmp (argv
[1], "s", 1) == 0)
784 flag
= OSPF_DEBUG_SEND
;
785 else if (strncmp (argv
[1], "r", 1) == 0)
786 flag
= OSPF_DEBUG_RECV
;
787 else if (strncmp (argv
[1], "d", 1) == 0)
788 flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
793 if (strncmp (argv
[2], "d", 1) == 0)
794 flag
|= OSPF_DEBUG_DETAIL
;
796 for (i
= 0; i
< 5; i
++)
797 if (type
& (0x01 << i
))
799 if (vty
->node
== CONFIG_NODE
)
800 DEBUG_PACKET_ON (i
, flag
);
802 TERM_DEBUG_PACKET_ON (i
, flag
);
808 ALIAS (debug_ospf_packet
,
809 debug_ospf_packet_send_recv_cmd
,
810 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
811 "Debugging functions\n"
815 "OSPF Database Description\n"
816 "OSPF Link State Request\n"
817 "OSPF Link State Update\n"
818 "OSPF Link State Acknowledgment\n"
822 "Detail information\n")
824 ALIAS (debug_ospf_packet
,
825 debug_ospf_packet_send_recv_detail_cmd
,
826 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
827 "Debugging functions\n"
831 "OSPF Database Description\n"
832 "OSPF Link State Request\n"
833 "OSPF Link State Update\n"
834 "OSPF Link State Acknowledgment\n"
838 "Detail Information\n")
841 DEFUN (no_debug_ospf_packet
,
842 no_debug_ospf_packet_all_cmd
,
843 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
849 "OSPF Database Description\n"
850 "OSPF Link State Request\n"
851 "OSPF Link State Update\n"
852 "OSPF Link State Acknowledgment\n"
853 "OSPF all packets\n")
861 /* Check packet type. */
862 if (strncmp (argv
[0], "h", 1) == 0)
863 type
= OSPF_DEBUG_HELLO
;
864 else if (strncmp (argv
[0], "d", 1) == 0)
865 type
= OSPF_DEBUG_DB_DESC
;
866 else if (strncmp (argv
[0], "ls-r", 4) == 0)
867 type
= OSPF_DEBUG_LS_REQ
;
868 else if (strncmp (argv
[0], "ls-u", 4) == 0)
869 type
= OSPF_DEBUG_LS_UPD
;
870 else if (strncmp (argv
[0], "ls-a", 4) == 0)
871 type
= OSPF_DEBUG_LS_ACK
;
872 else if (strncmp (argv
[0], "a", 1) == 0)
873 type
= OSPF_DEBUG_ALL
;
875 /* Default, both send and recv. */
877 flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
882 if (strncmp (argv
[1], "s", 1) == 0)
883 flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_DETAIL
;
884 else if (strncmp (argv
[1], "r", 1) == 0)
885 flag
= OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
886 else if (strncmp (argv
[1], "d", 1) == 0)
887 flag
= OSPF_DEBUG_DETAIL
;
892 if (strncmp (argv
[2], "d", 1) == 0)
893 flag
= OSPF_DEBUG_DETAIL
;
895 for (i
= 0; i
< 5; i
++)
896 if (type
& (0x01 << i
))
898 if (vty
->node
== CONFIG_NODE
)
899 DEBUG_PACKET_OFF (i
, flag
);
901 TERM_DEBUG_PACKET_OFF (i
, flag
);
906 for (i = 0; i < 5; i++)
907 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
914 ALIAS (no_debug_ospf_packet
,
915 no_debug_ospf_packet_send_recv_cmd
,
916 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
918 "Debugging functions\n"
922 "OSPF Database Description\n"
923 "OSPF Link State Request\n"
924 "OSPF Link State Update\n"
925 "OSPF Link State Acknowledgment\n"
929 "Detail Information\n")
931 ALIAS (no_debug_ospf_packet
,
932 no_debug_ospf_packet_send_recv_detail_cmd
,
933 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
935 "Debugging functions\n"
939 "OSPF Database Description\n"
940 "OSPF Link State Request\n"
941 "OSPF Link State Update\n"
942 "OSPF Link State Acknowledgment\n"
946 "Detail Information\n")
949 DEFUN (debug_ospf_ism
,
954 "OSPF Interface State Machine\n")
956 if (vty
->node
== CONFIG_NODE
)
962 if (strncmp (argv
[0], "s", 1) == 0)
963 DEBUG_ON (ism
, ISM_STATUS
);
964 else if (strncmp (argv
[0], "e", 1) == 0)
965 DEBUG_ON (ism
, ISM_EVENTS
);
966 else if (strncmp (argv
[0], "t", 1) == 0)
967 DEBUG_ON (ism
, ISM_TIMERS
);
975 TERM_DEBUG_ON (ism
, ISM
);
978 if (strncmp (argv
[0], "s", 1) == 0)
979 TERM_DEBUG_ON (ism
, ISM_STATUS
);
980 else if (strncmp (argv
[0], "e", 1) == 0)
981 TERM_DEBUG_ON (ism
, ISM_EVENTS
);
982 else if (strncmp (argv
[0], "t", 1) == 0)
983 TERM_DEBUG_ON (ism
, ISM_TIMERS
);
989 ALIAS (debug_ospf_ism
,
990 debug_ospf_ism_sub_cmd
,
991 "debug ospf ism (status|events|timers)",
994 "OSPF Interface State Machine\n"
995 "ISM Status Information\n"
996 "ISM Event Information\n"
997 "ISM TImer Information\n")
999 DEFUN (no_debug_ospf_ism
,
1000 no_debug_ospf_ism_cmd
,
1001 "no debug ospf ism",
1005 "OSPF Interface State Machine")
1007 if (vty
->node
== CONFIG_NODE
)
1010 DEBUG_OFF (ism
, ISM
);
1013 if (strncmp (argv
[0], "s", 1) == 0)
1014 DEBUG_OFF (ism
, ISM_STATUS
);
1015 else if (strncmp (argv
[0], "e", 1) == 0)
1016 DEBUG_OFF (ism
, ISM_EVENTS
);
1017 else if (strncmp (argv
[0], "t", 1) == 0)
1018 DEBUG_OFF (ism
, ISM_TIMERS
);
1025 TERM_DEBUG_OFF (ism
, ISM
);
1028 if (strncmp (argv
[0], "s", 1) == 0)
1029 TERM_DEBUG_OFF (ism
, ISM_STATUS
);
1030 else if (strncmp (argv
[0], "e", 1) == 0)
1031 TERM_DEBUG_OFF (ism
, ISM_EVENTS
);
1032 else if (strncmp (argv
[0], "t", 1) == 0)
1033 TERM_DEBUG_OFF (ism
, ISM_TIMERS
);
1039 ALIAS (no_debug_ospf_ism
,
1040 no_debug_ospf_ism_sub_cmd
,
1041 "no debug ospf ism (status|events|timers)",
1043 "Debugging functions\n"
1044 "OSPF information\n"
1045 "OSPF Interface State Machine\n"
1046 "ISM Status Information\n"
1047 "ISM Event Information\n"
1048 "ISM Timer Information\n")
1051 DEFUN (debug_ospf_nsm
,
1056 "OSPF Neighbor State Machine\n")
1058 if (vty
->node
== CONFIG_NODE
)
1061 DEBUG_ON (nsm
, NSM
);
1064 if (strncmp (argv
[0], "s", 1) == 0)
1065 DEBUG_ON (nsm
, NSM_STATUS
);
1066 else if (strncmp (argv
[0], "e", 1) == 0)
1067 DEBUG_ON (nsm
, NSM_EVENTS
);
1068 else if (strncmp (argv
[0], "t", 1) == 0)
1069 DEBUG_ON (nsm
, NSM_TIMERS
);
1077 TERM_DEBUG_ON (nsm
, NSM
);
1080 if (strncmp (argv
[0], "s", 1) == 0)
1081 TERM_DEBUG_ON (nsm
, NSM_STATUS
);
1082 else if (strncmp (argv
[0], "e", 1) == 0)
1083 TERM_DEBUG_ON (nsm
, NSM_EVENTS
);
1084 else if (strncmp (argv
[0], "t", 1) == 0)
1085 TERM_DEBUG_ON (nsm
, NSM_TIMERS
);
1091 ALIAS (debug_ospf_nsm
,
1092 debug_ospf_nsm_sub_cmd
,
1093 "debug ospf nsm (status|events|timers)",
1096 "OSPF Neighbor State Machine\n"
1097 "NSM Status Information\n"
1098 "NSM Event Information\n"
1099 "NSM Timer Information\n")
1101 DEFUN (no_debug_ospf_nsm
,
1102 no_debug_ospf_nsm_cmd
,
1103 "no debug ospf nsm",
1107 "OSPF Neighbor State Machine")
1109 if (vty
->node
== CONFIG_NODE
)
1112 DEBUG_OFF (nsm
, NSM
);
1115 if (strncmp (argv
[0], "s", 1) == 0)
1116 DEBUG_OFF (nsm
, NSM_STATUS
);
1117 else if (strncmp (argv
[0], "e", 1) == 0)
1118 DEBUG_OFF (nsm
, NSM_EVENTS
);
1119 else if (strncmp (argv
[0], "t", 1) == 0)
1120 DEBUG_OFF (nsm
, NSM_TIMERS
);
1128 TERM_DEBUG_OFF (nsm
, NSM
);
1131 if (strncmp (argv
[0], "s", 1) == 0)
1132 TERM_DEBUG_OFF (nsm
, NSM_STATUS
);
1133 else if (strncmp (argv
[0], "e", 1) == 0)
1134 TERM_DEBUG_OFF (nsm
, NSM_EVENTS
);
1135 else if (strncmp (argv
[0], "t", 1) == 0)
1136 TERM_DEBUG_OFF (nsm
, NSM_TIMERS
);
1142 ALIAS (no_debug_ospf_nsm
,
1143 no_debug_ospf_nsm_sub_cmd
,
1144 "no debug ospf nsm (status|events|timers)",
1146 "Debugging functions\n"
1147 "OSPF information\n"
1148 "OSPF Interface State Machine\n"
1149 "NSM Status Information\n"
1150 "NSM Event Information\n"
1151 "NSM Timer Information\n")
1154 DEFUN (debug_ospf_lsa
,
1159 "OSPF Link State Advertisement\n")
1161 if (vty
->node
== CONFIG_NODE
)
1164 DEBUG_ON (lsa
, LSA
);
1167 if (strncmp (argv
[0], "g", 1) == 0)
1168 DEBUG_ON (lsa
, LSA_GENERATE
);
1169 else if (strncmp (argv
[0], "f", 1) == 0)
1170 DEBUG_ON (lsa
, LSA_FLOODING
);
1171 else if (strncmp (argv
[0], "i", 1) == 0)
1172 DEBUG_ON (lsa
, LSA_INSTALL
);
1173 else if (strncmp (argv
[0], "r", 1) == 0)
1174 DEBUG_ON (lsa
, LSA_REFRESH
);
1182 TERM_DEBUG_ON (lsa
, LSA
);
1185 if (strncmp (argv
[0], "g", 1) == 0)
1186 TERM_DEBUG_ON (lsa
, LSA_GENERATE
);
1187 else if (strncmp (argv
[0], "f", 1) == 0)
1188 TERM_DEBUG_ON (lsa
, LSA_FLOODING
);
1189 else if (strncmp (argv
[0], "i", 1) == 0)
1190 TERM_DEBUG_ON (lsa
, LSA_INSTALL
);
1191 else if (strncmp (argv
[0], "r", 1) == 0)
1192 TERM_DEBUG_ON (lsa
, LSA_REFRESH
);
1198 ALIAS (debug_ospf_lsa
,
1199 debug_ospf_lsa_sub_cmd
,
1200 "debug ospf lsa (generate|flooding|install|refresh)",
1203 "OSPF Link State Advertisement\n"
1206 "LSA Install/Delete\n"
1209 DEFUN (no_debug_ospf_lsa
,
1210 no_debug_ospf_lsa_cmd
,
1211 "no debug ospf lsa",
1215 "OSPF Link State Advertisement\n")
1217 if (vty
->node
== CONFIG_NODE
)
1220 DEBUG_OFF (lsa
, LSA
);
1223 if (strncmp (argv
[0], "g", 1) == 0)
1224 DEBUG_OFF (lsa
, LSA_GENERATE
);
1225 else if (strncmp (argv
[0], "f", 1) == 0)
1226 DEBUG_OFF (lsa
, LSA_FLOODING
);
1227 else if (strncmp (argv
[0], "i", 1) == 0)
1228 DEBUG_OFF (lsa
, LSA_INSTALL
);
1229 else if (strncmp (argv
[0], "r", 1) == 0)
1230 DEBUG_OFF (lsa
, LSA_REFRESH
);
1238 TERM_DEBUG_OFF (lsa
, LSA
);
1241 if (strncmp (argv
[0], "g", 1) == 0)
1242 TERM_DEBUG_OFF (lsa
, LSA_GENERATE
);
1243 else if (strncmp (argv
[0], "f", 1) == 0)
1244 TERM_DEBUG_OFF (lsa
, LSA_FLOODING
);
1245 else if (strncmp (argv
[0], "i", 1) == 0)
1246 TERM_DEBUG_OFF (lsa
, LSA_INSTALL
);
1247 else if (strncmp (argv
[0], "r", 1) == 0)
1248 TERM_DEBUG_OFF (lsa
, LSA_REFRESH
);
1254 ALIAS (no_debug_ospf_lsa
,
1255 no_debug_ospf_lsa_sub_cmd
,
1256 "no debug ospf lsa (generate|flooding|install|refresh)",
1260 "OSPF Link State Advertisement\n"
1263 "LSA Install/Delete\n"
1267 DEFUN (debug_ospf_zebra
,
1268 debug_ospf_zebra_cmd
,
1272 "OSPF Zebra information\n")
1274 if (vty
->node
== CONFIG_NODE
)
1277 DEBUG_ON (zebra
, ZEBRA
);
1280 if (strncmp (argv
[0], "i", 1) == 0)
1281 DEBUG_ON (zebra
, ZEBRA_INTERFACE
);
1282 else if (strncmp (argv
[0], "r", 1) == 0)
1283 DEBUG_ON (zebra
, ZEBRA_REDISTRIBUTE
);
1291 TERM_DEBUG_ON (zebra
, ZEBRA
);
1294 if (strncmp (argv
[0], "i", 1) == 0)
1295 TERM_DEBUG_ON (zebra
, ZEBRA_INTERFACE
);
1296 else if (strncmp (argv
[0], "r", 1) == 0)
1297 TERM_DEBUG_ON (zebra
, ZEBRA_REDISTRIBUTE
);
1303 ALIAS (debug_ospf_zebra
,
1304 debug_ospf_zebra_sub_cmd
,
1305 "debug ospf zebra (interface|redistribute)",
1308 "OSPF Zebra information\n"
1310 "Zebra redistribute\n")
1312 DEFUN (no_debug_ospf_zebra
,
1313 no_debug_ospf_zebra_cmd
,
1314 "no debug ospf zebra",
1318 "OSPF Zebra information\n")
1320 if (vty
->node
== CONFIG_NODE
)
1323 DEBUG_OFF (zebra
, ZEBRA
);
1326 if (strncmp (argv
[0], "i", 1) == 0)
1327 DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1328 else if (strncmp (argv
[0], "r", 1) == 0)
1329 DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1337 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1340 if (strncmp (argv
[0], "i", 1) == 0)
1341 TERM_DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1342 else if (strncmp (argv
[0], "r", 1) == 0)
1343 TERM_DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1349 ALIAS (no_debug_ospf_zebra
,
1350 no_debug_ospf_zebra_sub_cmd
,
1351 "no debug ospf zebra (interface|redistribute)",
1355 "OSPF Zebra information\n"
1357 "Zebra redistribute\n")
1359 DEFUN (debug_ospf_event
,
1360 debug_ospf_event_cmd
,
1364 "OSPF event information\n")
1366 if (vty
->node
== CONFIG_NODE
)
1367 CONF_DEBUG_ON (event
, EVENT
);
1368 TERM_DEBUG_ON (event
, EVENT
);
1372 DEFUN (no_debug_ospf_event
,
1373 no_debug_ospf_event_cmd
,
1374 "no debug ospf event",
1378 "OSPF event information\n")
1380 if (vty
->node
== CONFIG_NODE
)
1381 CONF_DEBUG_OFF (event
, EVENT
);
1382 TERM_DEBUG_OFF (event
, EVENT
);
1386 DEFUN (debug_ospf_nssa
,
1387 debug_ospf_nssa_cmd
,
1391 "OSPF nssa information\n")
1393 if (vty
->node
== CONFIG_NODE
)
1394 CONF_DEBUG_ON (nssa
, NSSA
);
1395 TERM_DEBUG_ON (nssa
, NSSA
);
1399 DEFUN (no_debug_ospf_nssa
,
1400 no_debug_ospf_nssa_cmd
,
1401 "no debug ospf nssa",
1405 "OSPF nssa information\n")
1407 if (vty
->node
== CONFIG_NODE
)
1408 CONF_DEBUG_OFF (nssa
, NSSA
);
1409 TERM_DEBUG_OFF (nssa
, NSSA
);
1414 DEFUN (show_debugging_ospf
,
1415 show_debugging_ospf_cmd
,
1416 "show debugging ospf",
1423 vty_out (vty
, "OSPF debugging status:%s", VTY_NEWLINE
);
1425 /* Show debug status for events. */
1426 if (IS_DEBUG_OSPF(event
,EVENT
))
1427 vty_out (vty
, " OSPF event debugging is on%s", VTY_NEWLINE
);
1429 /* Show debug status for ISM. */
1430 if (IS_DEBUG_OSPF (ism
, ISM
) == OSPF_DEBUG_ISM
)
1431 vty_out (vty
, " OSPF ISM debugging is on%s", VTY_NEWLINE
);
1434 if (IS_DEBUG_OSPF (ism
, ISM_STATUS
))
1435 vty_out (vty
, " OSPF ISM status debugging is on%s", VTY_NEWLINE
);
1436 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
1437 vty_out (vty
, " OSPF ISM event debugging is on%s", VTY_NEWLINE
);
1438 if (IS_DEBUG_OSPF (ism
, ISM_TIMERS
))
1439 vty_out (vty
, " OSPF ISM timer debugging is on%s", VTY_NEWLINE
);
1442 /* Show debug status for NSM. */
1443 if (IS_DEBUG_OSPF (nsm
, NSM
) == OSPF_DEBUG_NSM
)
1444 vty_out (vty
, " OSPF NSM debugging is on%s", VTY_NEWLINE
);
1447 if (IS_DEBUG_OSPF (nsm
, NSM_STATUS
))
1448 vty_out (vty
, " OSPF NSM status debugging is on%s", VTY_NEWLINE
);
1449 if (IS_DEBUG_OSPF (nsm
, NSM_EVENTS
))
1450 vty_out (vty
, " OSPF NSM event debugging is on%s", VTY_NEWLINE
);
1451 if (IS_DEBUG_OSPF (nsm
, NSM_TIMERS
))
1452 vty_out (vty
, " OSPF NSM timer debugging is on%s", VTY_NEWLINE
);
1455 /* Show debug status for OSPF Packets. */
1456 for (i
= 0; i
< 5; i
++)
1457 if (IS_DEBUG_OSPF_PACKET (i
, SEND
) && IS_DEBUG_OSPF_PACKET (i
, RECV
))
1459 vty_out (vty
, " OSPF packet %s%s debugging is on%s",
1460 ospf_packet_type_str
[i
+ 1],
1461 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
1466 if (IS_DEBUG_OSPF_PACKET (i
, SEND
))
1467 vty_out (vty
, " OSPF packet %s send%s debugging is on%s",
1468 ospf_packet_type_str
[i
+ 1],
1469 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
1471 if (IS_DEBUG_OSPF_PACKET (i
, RECV
))
1472 vty_out (vty
, " OSPF packet %s receive%s debugging is on%s",
1473 ospf_packet_type_str
[i
+ 1],
1474 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
1478 /* Show debug status for OSPF LSAs. */
1479 if (IS_DEBUG_OSPF (lsa
, LSA
) == OSPF_DEBUG_LSA
)
1480 vty_out (vty
, " OSPF LSA debugging is on%s", VTY_NEWLINE
);
1483 if (IS_DEBUG_OSPF (lsa
, LSA_GENERATE
))
1484 vty_out (vty
, " OSPF LSA generation debugging is on%s", VTY_NEWLINE
);
1485 if (IS_DEBUG_OSPF (lsa
, LSA_FLOODING
))
1486 vty_out (vty
, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE
);
1487 if (IS_DEBUG_OSPF (lsa
, LSA_INSTALL
))
1488 vty_out (vty
, " OSPF LSA install debugging is on%s", VTY_NEWLINE
);
1489 if (IS_DEBUG_OSPF (lsa
, LSA_REFRESH
))
1490 vty_out (vty
, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE
);
1493 /* Show debug status for Zebra. */
1494 if (IS_DEBUG_OSPF (zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1495 vty_out (vty
, " OSPF Zebra debugging is on%s", VTY_NEWLINE
);
1498 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
1499 vty_out (vty
, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE
);
1500 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
1501 vty_out (vty
, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE
);
1504 /* Show debug status for NSSA. */
1505 if (IS_DEBUG_OSPF (nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1506 vty_out (vty
, " OSPF NSSA debugging is on%s", VTY_NEWLINE
);
1512 struct cmd_node debug_node
=
1520 config_write_debug (struct vty
*vty
)
1525 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
1526 const char *detail_str
[] = {"", " send", " recv", "", " detail",
1527 " send detail", " recv detail", " detail"};
1529 /* debug ospf ism (status|events|timers). */
1530 if (IS_CONF_DEBUG_OSPF (ism
, ISM
) == OSPF_DEBUG_ISM
)
1531 vty_out (vty
, "debug ospf ism%s", VTY_NEWLINE
);
1534 if (IS_CONF_DEBUG_OSPF (ism
, ISM_STATUS
))
1535 vty_out (vty
, "debug ospf ism status%s", VTY_NEWLINE
);
1536 if (IS_CONF_DEBUG_OSPF (ism
, ISM_EVENTS
))
1537 vty_out (vty
, "debug ospf ism event%s", VTY_NEWLINE
);
1538 if (IS_CONF_DEBUG_OSPF (ism
, ISM_TIMERS
))
1539 vty_out (vty
, "debug ospf ism timer%s", VTY_NEWLINE
);
1542 /* debug ospf nsm (status|events|timers). */
1543 if (IS_CONF_DEBUG_OSPF (nsm
, NSM
) == OSPF_DEBUG_NSM
)
1544 vty_out (vty
, "debug ospf nsm%s", VTY_NEWLINE
);
1547 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_STATUS
))
1548 vty_out (vty
, "debug ospf nsm status%s", VTY_NEWLINE
);
1549 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_EVENTS
))
1550 vty_out (vty
, "debug ospf nsm event%s", VTY_NEWLINE
);
1551 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_TIMERS
))
1552 vty_out (vty
, "debug ospf nsm timer%s", VTY_NEWLINE
);
1555 /* debug ospf lsa (generate|flooding|install|refresh). */
1556 if (IS_CONF_DEBUG_OSPF (lsa
, LSA
) == OSPF_DEBUG_LSA
)
1557 vty_out (vty
, "debug ospf lsa%s", VTY_NEWLINE
);
1560 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_GENERATE
))
1561 vty_out (vty
, "debug ospf lsa generate%s", VTY_NEWLINE
);
1562 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_FLOODING
))
1563 vty_out (vty
, "debug ospf lsa flooding%s", VTY_NEWLINE
);
1564 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_INSTALL
))
1565 vty_out (vty
, "debug ospf lsa install%s", VTY_NEWLINE
);
1566 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_REFRESH
))
1567 vty_out (vty
, "debug ospf lsa refresh%s", VTY_NEWLINE
);
1572 /* debug ospf zebra (interface|redistribute). */
1573 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
1574 vty_out (vty
, "debug ospf zebra%s", VTY_NEWLINE
);
1577 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
1578 vty_out (vty
, "debug ospf zebra interface%s", VTY_NEWLINE
);
1579 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
1580 vty_out (vty
, "debug ospf zebra redistribute%s", VTY_NEWLINE
);
1585 /* debug ospf event. */
1586 if (IS_CONF_DEBUG_OSPF (event
, EVENT
) == OSPF_DEBUG_EVENT
)
1588 vty_out (vty
, "debug ospf event%s", VTY_NEWLINE
);
1592 /* debug ospf nssa. */
1593 if (IS_CONF_DEBUG_OSPF (nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
1595 vty_out (vty
, "debug ospf nssa%s", VTY_NEWLINE
);
1599 /* debug ospf packet all detail. */
1600 r
= OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
;
1601 for (i
= 0; i
< 5; i
++)
1602 r
&= conf_debug_ospf_packet
[i
] & (OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
);
1603 if (r
== (OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
))
1605 vty_out (vty
, "debug ospf packet all detail%s", VTY_NEWLINE
);
1609 /* debug ospf packet all. */
1610 r
= OSPF_DEBUG_SEND_RECV
;
1611 for (i
= 0; i
< 5; i
++)
1612 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
1613 if (r
== OSPF_DEBUG_SEND_RECV
)
1615 vty_out (vty
, "debug ospf packet all%s", VTY_NEWLINE
);
1616 for (i
= 0; i
< 5; i
++)
1617 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
1618 vty_out (vty
, "debug ospf packet %s detail%s",
1624 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1625 (send|recv) (detail). */
1626 for (i
= 0; i
< 5; i
++)
1628 if (conf_debug_ospf_packet
[i
] == 0)
1631 vty_out (vty
, "debug ospf packet %s%s%s",
1632 type_str
[i
], detail_str
[conf_debug_ospf_packet
[i
]],
1640 /* Initialize debug commands. */
1644 install_node (&debug_node
, config_write_debug
);
1646 install_element (ENABLE_NODE
, &show_debugging_ospf_cmd
);
1647 install_element (ENABLE_NODE
, &debug_ospf_packet_send_recv_detail_cmd
);
1648 install_element (ENABLE_NODE
, &debug_ospf_packet_send_recv_cmd
);
1649 install_element (ENABLE_NODE
, &debug_ospf_packet_all_cmd
);
1650 install_element (ENABLE_NODE
, &debug_ospf_ism_sub_cmd
);
1651 install_element (ENABLE_NODE
, &debug_ospf_ism_cmd
);
1652 install_element (ENABLE_NODE
, &debug_ospf_nsm_sub_cmd
);
1653 install_element (ENABLE_NODE
, &debug_ospf_nsm_cmd
);
1654 install_element (ENABLE_NODE
, &debug_ospf_lsa_sub_cmd
);
1655 install_element (ENABLE_NODE
, &debug_ospf_lsa_cmd
);
1656 install_element (ENABLE_NODE
, &debug_ospf_zebra_sub_cmd
);
1657 install_element (ENABLE_NODE
, &debug_ospf_zebra_cmd
);
1658 install_element (ENABLE_NODE
, &debug_ospf_event_cmd
);
1659 install_element (ENABLE_NODE
, &debug_ospf_nssa_cmd
);
1660 install_element (ENABLE_NODE
, &no_debug_ospf_packet_send_recv_detail_cmd
);
1661 install_element (ENABLE_NODE
, &no_debug_ospf_packet_send_recv_cmd
);
1662 install_element (ENABLE_NODE
, &no_debug_ospf_packet_all_cmd
);
1663 install_element (ENABLE_NODE
, &no_debug_ospf_ism_sub_cmd
);
1664 install_element (ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
1665 install_element (ENABLE_NODE
, &no_debug_ospf_nsm_sub_cmd
);
1666 install_element (ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
1667 install_element (ENABLE_NODE
, &no_debug_ospf_lsa_sub_cmd
);
1668 install_element (ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
1669 install_element (ENABLE_NODE
, &no_debug_ospf_zebra_sub_cmd
);
1670 install_element (ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
1671 install_element (ENABLE_NODE
, &no_debug_ospf_event_cmd
);
1672 install_element (ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
1674 install_element (CONFIG_NODE
, &debug_ospf_packet_send_recv_detail_cmd
);
1675 install_element (CONFIG_NODE
, &debug_ospf_packet_send_recv_cmd
);
1676 install_element (CONFIG_NODE
, &debug_ospf_packet_all_cmd
);
1677 install_element (CONFIG_NODE
, &debug_ospf_ism_sub_cmd
);
1678 install_element (CONFIG_NODE
, &debug_ospf_ism_cmd
);
1679 install_element (CONFIG_NODE
, &debug_ospf_nsm_sub_cmd
);
1680 install_element (CONFIG_NODE
, &debug_ospf_nsm_cmd
);
1681 install_element (CONFIG_NODE
, &debug_ospf_lsa_sub_cmd
);
1682 install_element (CONFIG_NODE
, &debug_ospf_lsa_cmd
);
1683 install_element (CONFIG_NODE
, &debug_ospf_zebra_sub_cmd
);
1684 install_element (CONFIG_NODE
, &debug_ospf_zebra_cmd
);
1685 install_element (CONFIG_NODE
, &debug_ospf_event_cmd
);
1686 install_element (CONFIG_NODE
, &debug_ospf_nssa_cmd
);
1687 install_element (CONFIG_NODE
, &no_debug_ospf_packet_send_recv_detail_cmd
);
1688 install_element (CONFIG_NODE
, &no_debug_ospf_packet_send_recv_cmd
);
1689 install_element (CONFIG_NODE
, &no_debug_ospf_packet_all_cmd
);
1690 install_element (CONFIG_NODE
, &no_debug_ospf_ism_sub_cmd
);
1691 install_element (CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
1692 install_element (CONFIG_NODE
, &no_debug_ospf_nsm_sub_cmd
);
1693 install_element (CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
1694 install_element (CONFIG_NODE
, &no_debug_ospf_lsa_sub_cmd
);
1695 install_element (CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
1696 install_element (CONFIG_NODE
, &no_debug_ospf_zebra_sub_cmd
);
1697 install_element (CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
1698 install_element (CONFIG_NODE
, &no_debug_ospf_event_cmd
);
1699 install_element (CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);