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 const 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 const int ospf_ism_state_msg_max = OSPF_ISM_STATE_MAX;
58 const 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 const int ospf_nsm_state_msg_max = OSPF_NSM_STATE_MAX;
73 const 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 const int ospf_lsa_type_msg_max = OSPF_MAX_LSA;
90 const 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 const int ospf_link_state_id_type_msg_max = OSPF_MAX_LSA;
107 const 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 const int ospf_network_type_msg_max = OSPF_IFTYPE_MAX;
119 const struct message ospf_auth_type_str[] =
121 { OSPF_AUTH_NULL, "Null" },
122 { OSPF_AUTH_SIMPLE, "Simple" },
123 { OSPF_AUTH_CRYPTOGRAPHIC, "Cryptographic" },
125 const size_t ospf_auth_type_str_max = sizeof (ospf_auth_type_str) /
126 sizeof (ospf_auth_type_str[0]);
128 /* Configuration debug option variables. */
129 unsigned long conf_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
130 unsigned long conf_debug_ospf_event = 0;
131 unsigned long conf_debug_ospf_ism = 0;
132 unsigned long conf_debug_ospf_nsm = 0;
133 unsigned long conf_debug_ospf_lsa = 0;
134 unsigned long conf_debug_ospf_zebra = 0;
135 unsigned long conf_debug_ospf_nssa = 0;
136 unsigned long conf_debug_ospf_te = 0;
138 /* Enable debug option variables -- valid only session. */
139 unsigned long term_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
140 unsigned long term_debug_ospf_event = 0;
141 unsigned long term_debug_ospf_ism = 0;
142 unsigned long term_debug_ospf_nsm = 0;
143 unsigned long term_debug_ospf_lsa = 0;
144 unsigned long term_debug_ospf_zebra = 0;
145 unsigned long term_debug_ospf_nssa = 0;
146 unsigned long term_debug_ospf_te = 0;
150 ospf_redist_string(u_int route_type)
152 return (route_type == ZEBRA_ROUTE_MAX) ?
153 "Default" : zebra_route_string(route_type);
156 #define OSPF_AREA_STRING_MAXLEN 16
158 ospf_area_name_string (struct ospf_area *area)
160 static char buf[OSPF_AREA_STRING_MAXLEN] = "";
166 area_id = ntohl (area->area_id.s_addr);
167 snprintf (buf, OSPF_AREA_STRING_MAXLEN, "%d.%d.%d.%d",
168 (area_id >> 24) & 0xff, (area_id >> 16) & 0xff,
169 (area_id >> 8) & 0xff, area_id & 0xff);
173 #define OSPF_AREA_DESC_STRING_MAXLEN 23
175 ospf_area_desc_string (struct ospf_area *area)
177 static char buf[OSPF_AREA_DESC_STRING_MAXLEN] = "";
181 return "(incomplete)";
183 type = area->external_routing;
187 snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [NSSA]",
188 ospf_area_name_string (area));
191 snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [Stub]",
192 ospf_area_name_string (area));
195 return ospf_area_name_string (area);
201 #define OSPF_IF_STRING_MAXLEN 40
203 ospf_if_name_string (struct ospf_interface *oi)
205 static char buf[OSPF_IF_STRING_MAXLEN] = "";
211 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
212 return oi->ifp->name;
214 ifaddr = ntohl (oi->address->u.prefix4.s_addr);
215 snprintf (buf, OSPF_IF_STRING_MAXLEN,
216 "%s:%d.%d.%d.%d", oi->ifp->name,
217 (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
218 (ifaddr >> 8) & 0xff, ifaddr & 0xff);
224 ospf_nbr_state_message (struct ospf_neighbor *nbr, char *buf, size_t size)
227 struct ospf_interface *oi = nbr->oi;
229 if (IPV4_ADDR_SAME (&DR (oi), &nbr->address.u.prefix4))
231 else if (IPV4_ADDR_SAME (&BDR (oi), &nbr->address.u.prefix4))
236 memset (buf, 0, size);
238 snprintf (buf, size, "%s/%s",
239 LOOKUP (ospf_nsm_state_msg, nbr->state),
240 LOOKUP (ospf_ism_state_msg, state));
244 ospf_timeval_dump (struct timeval *t, char *buf, size_t size)
246 /* Making formatted timer strings. */
247 #define MINUTE_IN_SECONDS 60
248 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
249 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
250 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
251 unsigned long w, d, h, m, s, ms, us;
256 w = d = h = m = s = ms = us = 0;
257 memset (buf, 0, size);
268 t->tv_sec += ms / 1000;
272 if (t->tv_sec > WEEK_IN_SECONDS)
274 w = t->tv_sec / WEEK_IN_SECONDS;
275 t->tv_sec -= w * WEEK_IN_SECONDS;
278 if (t->tv_sec > DAY_IN_SECONDS)
280 d = t->tv_sec / DAY_IN_SECONDS;
281 t->tv_sec -= d * DAY_IN_SECONDS;
284 if (t->tv_sec >= HOUR_IN_SECONDS)
286 h = t->tv_sec / HOUR_IN_SECONDS;
287 t->tv_sec -= h * HOUR_IN_SECONDS;
290 if (t->tv_sec >= MINUTE_IN_SECONDS)
292 m = t->tv_sec / MINUTE_IN_SECONDS;
293 t->tv_sec -= m * MINUTE_IN_SECONDS;
297 snprintf (buf, size, "%ldw%1ldd", w, d);
299 snprintf (buf, size, "%ldw%1ldd%02ldh", w, d, h);
301 snprintf (buf, size, "%1ldd%02ldh%02ldm", d, h, m);
303 snprintf (buf, size, "%ldh%02ldm%02lds", h, m, (long)t->tv_sec);
305 snprintf (buf, size, "%ldm%02lds", m, (long)t->tv_sec);
307 snprintf (buf, size, "%ld.%03lds", (long)t->tv_sec, ms);
309 snprintf (buf, size, "%ld usecs", (long)t->tv_usec);
315 ospf_timer_dump (struct thread *t, char *buf, size_t size)
317 struct timeval result;
321 result = tv_sub (t->u.sands, recent_relative_time());
322 return ospf_timeval_dump (&result, buf, size);
325 #define OSPF_OPTION_STR_MAXLEN 24
328 ospf_options_dump (u_char options)
330 static char buf[OSPF_OPTION_STR_MAXLEN];
332 snprintf (buf, OSPF_OPTION_STR_MAXLEN, "*|%s|%s|%s|%s|%s|%s|%s",
333 (options & OSPF_OPTION_O) ? "O" : "-",
334 (options & OSPF_OPTION_DC) ? "DC" : "-",
335 (options & OSPF_OPTION_EA) ? "EA" : "-",
336 (options & OSPF_OPTION_NP) ? "N/P" : "-",
337 (options & OSPF_OPTION_MC) ? "MC" : "-",
338 (options & OSPF_OPTION_E) ? "E" : "-",
339 (options & OSPF_OPTION_MT) ? "M/T" : "-");
345 ospf_packet_hello_dump (struct stream *s, u_int16_t length)
347 struct ospf_hello *hello;
350 hello = (struct ospf_hello *) STREAM_PNT (s);
352 zlog_debug ("Hello");
353 zlog_debug (" NetworkMask %s", inet_ntoa (hello->network_mask));
354 zlog_debug (" HelloInterval %d", ntohs (hello->hello_interval));
355 zlog_debug (" Options %d (%s)", hello->options,
356 ospf_options_dump (hello->options));
357 zlog_debug (" RtrPriority %d", hello->priority);
358 zlog_debug (" RtrDeadInterval %ld", (u_long)ntohl (hello->dead_interval));
359 zlog_debug (" DRouter %s", inet_ntoa (hello->d_router));
360 zlog_debug (" BDRouter %s", inet_ntoa (hello->bd_router));
362 length -= OSPF_HEADER_SIZE + OSPF_HELLO_MIN_SIZE;
363 zlog_debug (" # Neighbors %d", length / 4);
364 for (i = 0; length > 0; i++, length -= sizeof (struct in_addr))
365 zlog_debug (" Neighbor %s", inet_ntoa (hello->neighbors[i]));
369 ospf_dd_flags_dump (u_char flags, char *buf, size_t size)
371 memset (buf, 0, size);
373 snprintf (buf, size, "%s|%s|%s",
374 (flags & OSPF_DD_FLAG_I) ? "I" : "-",
375 (flags & OSPF_DD_FLAG_M) ? "M" : "-",
376 (flags & OSPF_DD_FLAG_MS) ? "MS" : "-");
382 ospf_lsa_header_dump (struct lsa_header *lsah)
384 const char *lsah_type = LOOKUP (ospf_lsa_type_msg, lsah->type);
386 zlog_debug (" LSA Header");
387 zlog_debug (" LS age %d", ntohs (lsah->ls_age));
388 zlog_debug (" Options %d (%s)", lsah->options,
389 ospf_options_dump (lsah->options));
390 zlog_debug (" LS type %d (%s)", lsah->type,
391 (lsah->type ? lsah_type : "unknown type"));
392 zlog_debug (" Link State ID %s", inet_ntoa (lsah->id));
393 zlog_debug (" Advertising Router %s", inet_ntoa (lsah->adv_router));
394 zlog_debug (" LS sequence number 0x%lx", (u_long)ntohl (lsah->ls_seqnum));
395 zlog_debug (" LS checksum 0x%x", ntohs (lsah->checksum));
396 zlog_debug (" length %d", ntohs (lsah->length));
400 ospf_router_lsa_flags_dump (u_char flags, char *buf, size_t size)
402 memset (buf, 0, size);
404 snprintf (buf, size, "%s|%s|%s",
405 (flags & ROUTER_LSA_VIRTUAL) ? "V" : "-",
406 (flags & ROUTER_LSA_EXTERNAL) ? "E" : "-",
407 (flags & ROUTER_LSA_BORDER) ? "B" : "-");
413 ospf_router_lsa_dump (struct stream *s, u_int16_t length)
416 struct router_lsa *rl;
419 rl = (struct router_lsa *) STREAM_PNT (s);
421 zlog_debug (" Router-LSA");
422 zlog_debug (" flags %s",
423 ospf_router_lsa_flags_dump (rl->flags, buf, BUFSIZ));
424 zlog_debug (" # links %d", ntohs (rl->links));
426 len = ntohs (rl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
427 for (i = 0; len > 0; i++)
429 zlog_debug (" Link ID %s", inet_ntoa (rl->link[i].link_id));
430 zlog_debug (" Link Data %s", inet_ntoa (rl->link[i].link_data));
431 zlog_debug (" Type %d", (u_char) rl->link[i].type);
432 zlog_debug (" TOS %d", (u_char) rl->link[i].tos);
433 zlog_debug (" metric %d", ntohs (rl->link[i].metric));
440 ospf_network_lsa_dump (struct stream *s, u_int16_t length)
442 struct network_lsa *nl;
445 nl = (struct network_lsa *) STREAM_PNT (s);
446 cnt = (ntohs (nl->header.length) - (OSPF_LSA_HEADER_SIZE + 4)) / 4;
448 zlog_debug (" Network-LSA");
450 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
451 zlog_debug ("Network-LSA size %d",
452 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
454 zlog_debug (" Network Mask %s", inet_ntoa (nl->mask));
455 zlog_debug (" # Attached Routers %d", cnt);
456 for (i = 0; i < cnt; i++)
457 zlog_debug (" Attached Router %s", inet_ntoa (nl->routers[i]));
461 ospf_summary_lsa_dump (struct stream *s, u_int16_t length)
463 struct summary_lsa *sl;
467 sl = (struct summary_lsa *) STREAM_PNT (s);
469 zlog_debug (" Summary-LSA");
470 zlog_debug (" Network Mask %s", inet_ntoa (sl->mask));
472 size = ntohs (sl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
473 for (i = 0; size > 0; size -= 4, i++)
474 zlog_debug (" TOS=%d metric %d", sl->tos,
475 GET_METRIC (sl->metric));
479 ospf_as_external_lsa_dump (struct stream *s, u_int16_t length)
481 struct as_external_lsa *al;
485 al = (struct as_external_lsa *) STREAM_PNT (s);
486 zlog_debug (" %s", ospf_lsa_type_msg[al->header.type].str);
487 zlog_debug (" Network Mask %s", inet_ntoa (al->mask));
489 size = ntohs (al->header.length) - OSPF_LSA_HEADER_SIZE -4;
490 for (i = 0; size > 0; size -= 12, i++)
492 zlog_debug (" bit %s TOS=%d metric %d",
493 IS_EXTERNAL_METRIC (al->e[i].tos) ? "E" : "-",
494 al->e[i].tos & 0x7f, GET_METRIC (al->e[i].metric));
495 zlog_debug (" Forwarding address %s", inet_ntoa (al->e[i].fwd_addr));
496 zlog_debug (" External Route Tag %u", al->e[i].route_tag);
501 ospf_lsa_header_list_dump (struct stream *s, u_int16_t length)
503 struct lsa_header *lsa;
505 zlog_debug (" # LSA Headers %d", length / OSPF_LSA_HEADER_SIZE);
510 lsa = (struct lsa_header *) STREAM_PNT (s);
511 ospf_lsa_header_dump (lsa);
513 stream_forward_getp (s, OSPF_LSA_HEADER_SIZE);
514 length -= OSPF_LSA_HEADER_SIZE;
519 ospf_packet_db_desc_dump (struct stream *s, u_int16_t length)
521 struct ospf_db_desc *dd;
526 gp = stream_get_getp (s);
527 dd = (struct ospf_db_desc *) STREAM_PNT (s);
529 zlog_debug ("Database Description");
530 zlog_debug (" Interface MTU %d", ntohs (dd->mtu));
531 zlog_debug (" Options %d (%s)", dd->options,
532 ospf_options_dump (dd->options));
533 zlog_debug (" Flags %d (%s)", dd->flags,
534 ospf_dd_flags_dump (dd->flags, dd_flags, sizeof dd_flags));
535 zlog_debug (" Sequence Number 0x%08lx", (u_long)ntohl (dd->dd_seqnum));
537 length -= OSPF_HEADER_SIZE + OSPF_DB_DESC_MIN_SIZE;
539 stream_forward_getp (s, OSPF_DB_DESC_MIN_SIZE);
541 ospf_lsa_header_list_dump (s, length);
543 stream_set_getp (s, gp);
547 ospf_packet_ls_req_dump (struct stream *s, u_int16_t length)
551 struct in_addr ls_id;
552 struct in_addr adv_router;
554 sp = stream_get_getp (s);
556 length -= OSPF_HEADER_SIZE;
558 zlog_debug ("Link State Request");
559 zlog_debug (" # Requests %d", length / 12);
561 for (; length > 0; length -= 12)
563 ls_type = stream_getl (s);
564 ls_id.s_addr = stream_get_ipv4 (s);
565 adv_router.s_addr = stream_get_ipv4 (s);
567 zlog_debug (" LS type %d", ls_type);
568 zlog_debug (" Link State ID %s", inet_ntoa (ls_id));
569 zlog_debug (" Advertising Router %s",
570 inet_ntoa (adv_router));
573 stream_set_getp (s, sp);
577 ospf_packet_ls_upd_dump (struct stream *s, u_int16_t length)
580 struct lsa_header *lsa;
584 length -= OSPF_HEADER_SIZE;
586 sp = stream_get_getp (s);
588 count = stream_getl (s);
591 zlog_debug ("Link State Update");
592 zlog_debug (" # LSAs %d", count);
594 while (length > 0 && count > 0)
596 if (length < OSPF_HEADER_SIZE || length % 4 != 0)
598 zlog_debug (" Remaining %d bytes; Incorrect length.", length);
602 lsa = (struct lsa_header *) STREAM_PNT (s);
603 lsa_len = ntohs (lsa->length);
604 ospf_lsa_header_dump (lsa);
608 case OSPF_ROUTER_LSA:
609 ospf_router_lsa_dump (s, length);
611 case OSPF_NETWORK_LSA:
612 ospf_network_lsa_dump (s, length);
614 case OSPF_SUMMARY_LSA:
615 case OSPF_ASBR_SUMMARY_LSA:
616 ospf_summary_lsa_dump (s, length);
618 case OSPF_AS_EXTERNAL_LSA:
619 ospf_as_external_lsa_dump (s, length);
621 case OSPF_AS_NSSA_LSA:
622 ospf_as_external_lsa_dump (s, length);
624 case OSPF_OPAQUE_LINK_LSA:
625 case OSPF_OPAQUE_AREA_LSA:
626 case OSPF_OPAQUE_AS_LSA:
627 ospf_opaque_lsa_dump (s, length);
633 stream_forward_getp (s, lsa_len);
638 stream_set_getp (s, sp);
642 ospf_packet_ls_ack_dump (struct stream *s, u_int16_t length)
646 length -= OSPF_HEADER_SIZE;
647 sp = stream_get_getp (s);
649 zlog_debug ("Link State Acknowledgment");
650 ospf_lsa_header_list_dump (s, length);
652 stream_set_getp (s, sp);
655 /* Expects header to be in host order */
657 ospf_ip_header_dump (struct ip *iph)
659 /* IP Header dump. */
660 zlog_debug ("ip_v %d", iph->ip_v);
661 zlog_debug ("ip_hl %d", iph->ip_hl);
662 zlog_debug ("ip_tos %d", iph->ip_tos);
663 zlog_debug ("ip_len %d", iph->ip_len);
664 zlog_debug ("ip_id %u", (u_int32_t) iph->ip_id);
665 zlog_debug ("ip_off %u", (u_int32_t) iph->ip_off);
666 zlog_debug ("ip_ttl %d", iph->ip_ttl);
667 zlog_debug ("ip_p %d", iph->ip_p);
668 zlog_debug ("ip_sum 0x%x", (u_int32_t) iph->ip_sum);
669 zlog_debug ("ip_src %s", inet_ntoa (iph->ip_src));
670 zlog_debug ("ip_dst %s", inet_ntoa (iph->ip_dst));
674 ospf_header_dump (struct ospf_header *ospfh)
677 u_int16_t auth_type = ntohs (ospfh->auth_type);
679 zlog_debug ("Header");
680 zlog_debug (" Version %d", ospfh->version);
681 zlog_debug (" Type %d (%s)", ospfh->type,
682 LOOKUP (ospf_packet_type_str, ospfh->type));
683 zlog_debug (" Packet Len %d", ntohs (ospfh->length));
684 zlog_debug (" Router ID %s", inet_ntoa (ospfh->router_id));
685 zlog_debug (" Area ID %s", inet_ntoa (ospfh->area_id));
686 zlog_debug (" Checksum 0x%x", ntohs (ospfh->checksum));
687 zlog_debug (" AuType %s", LOOKUP (ospf_auth_type_str, auth_type));
693 case OSPF_AUTH_SIMPLE:
695 strncpy (buf, (char *) ospfh->u.auth_data, 8);
696 zlog_debug (" Simple Password %s", buf);
698 case OSPF_AUTH_CRYPTOGRAPHIC:
699 zlog_debug (" Cryptographic Authentication");
700 zlog_debug (" Key ID %d", ospfh->u.crypt.key_id);
701 zlog_debug (" Auth Data Len %d", ospfh->u.crypt.auth_data_len);
702 zlog_debug (" Sequence number %ld",
703 (u_long)ntohl (ospfh->u.crypt.crypt_seqnum));
706 zlog_debug ("* This is not supported authentication type");
713 ospf_packet_dump (struct stream *s)
715 struct ospf_header *ospfh;
718 /* Preserve pointer. */
719 gp = stream_get_getp (s);
721 /* OSPF Header dump. */
722 ospfh = (struct ospf_header *) STREAM_PNT (s);
724 /* Until detail flag is set, return. */
725 if (!(term_debug_ospf_packet[ospfh->type - 1] & OSPF_DEBUG_DETAIL))
728 /* Show OSPF header detail. */
729 ospf_header_dump (ospfh);
730 stream_forward_getp (s, OSPF_HEADER_SIZE);
735 ospf_packet_hello_dump (s, ntohs (ospfh->length));
737 case OSPF_MSG_DB_DESC:
738 ospf_packet_db_desc_dump (s, ntohs (ospfh->length));
740 case OSPF_MSG_LS_REQ:
741 ospf_packet_ls_req_dump (s, ntohs (ospfh->length));
743 case OSPF_MSG_LS_UPD:
744 ospf_packet_ls_upd_dump (s, ntohs (ospfh->length));
746 case OSPF_MSG_LS_ACK:
747 ospf_packet_ls_ack_dump (s, ntohs (ospfh->length));
753 stream_set_getp (s, gp);
758 [no] debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)
761 DEFUN (debug_ospf_packet,
762 debug_ospf_packet_all_cmd,
763 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
768 "OSPF Database Description\n"
769 "OSPF Link State Request\n"
770 "OSPF Link State Update\n"
771 "OSPF Link State Acknowledgment\n"
772 "OSPF all packets\n")
780 /* Check packet type. */
781 if (strncmp (argv[0], "h", 1) == 0)
782 type = OSPF_DEBUG_HELLO;
783 else if (strncmp (argv[0], "d", 1) == 0)
784 type = OSPF_DEBUG_DB_DESC;
785 else if (strncmp (argv[0], "ls-r", 4) == 0)
786 type = OSPF_DEBUG_LS_REQ;
787 else if (strncmp (argv[0], "ls-u", 4) == 0)
788 type = OSPF_DEBUG_LS_UPD;
789 else if (strncmp (argv[0], "ls-a", 4) == 0)
790 type = OSPF_DEBUG_LS_ACK;
791 else if (strncmp (argv[0], "a", 1) == 0)
792 type = OSPF_DEBUG_ALL;
794 /* Default, both send and recv. */
796 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV;
801 if (strncmp (argv[1], "s", 1) == 0)
802 flag = OSPF_DEBUG_SEND;
803 else if (strncmp (argv[1], "r", 1) == 0)
804 flag = OSPF_DEBUG_RECV;
805 else if (strncmp (argv[1], "d", 1) == 0)
806 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
811 if (strncmp (argv[2], "d", 1) == 0)
812 flag |= OSPF_DEBUG_DETAIL;
814 for (i = 0; i < 5; i++)
815 if (type & (0x01 << i))
817 if (vty->node == CONFIG_NODE)
818 DEBUG_PACKET_ON (i, flag);
820 TERM_DEBUG_PACKET_ON (i, flag);
826 ALIAS (debug_ospf_packet,
827 debug_ospf_packet_send_recv_cmd,
828 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
829 "Debugging functions\n"
833 "OSPF Database Description\n"
834 "OSPF Link State Request\n"
835 "OSPF Link State Update\n"
836 "OSPF Link State Acknowledgment\n"
840 "Detail information\n")
842 ALIAS (debug_ospf_packet,
843 debug_ospf_packet_send_recv_detail_cmd,
844 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
845 "Debugging functions\n"
849 "OSPF Database Description\n"
850 "OSPF Link State Request\n"
851 "OSPF Link State Update\n"
852 "OSPF Link State Acknowledgment\n"
856 "Detail Information\n")
859 DEFUN (no_debug_ospf_packet,
860 no_debug_ospf_packet_all_cmd,
861 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
867 "OSPF Database Description\n"
868 "OSPF Link State Request\n"
869 "OSPF Link State Update\n"
870 "OSPF Link State Acknowledgment\n"
871 "OSPF all packets\n")
879 /* Check packet type. */
880 if (strncmp (argv[0], "h", 1) == 0)
881 type = OSPF_DEBUG_HELLO;
882 else if (strncmp (argv[0], "d", 1) == 0)
883 type = OSPF_DEBUG_DB_DESC;
884 else if (strncmp (argv[0], "ls-r", 4) == 0)
885 type = OSPF_DEBUG_LS_REQ;
886 else if (strncmp (argv[0], "ls-u", 4) == 0)
887 type = OSPF_DEBUG_LS_UPD;
888 else if (strncmp (argv[0], "ls-a", 4) == 0)
889 type = OSPF_DEBUG_LS_ACK;
890 else if (strncmp (argv[0], "a", 1) == 0)
891 type = OSPF_DEBUG_ALL;
893 /* Default, both send and recv. */
895 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL ;
900 if (strncmp (argv[1], "s", 1) == 0)
901 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_DETAIL;
902 else if (strncmp (argv[1], "r", 1) == 0)
903 flag = OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
904 else if (strncmp (argv[1], "d", 1) == 0)
905 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
910 if (strncmp (argv[2], "d", 1) == 0)
911 flag = OSPF_DEBUG_DETAIL;
913 for (i = 0; i < 5; i++)
914 if (type & (0x01 << i))
916 if (vty->node == CONFIG_NODE)
917 DEBUG_PACKET_OFF (i, flag);
919 TERM_DEBUG_PACKET_OFF (i, flag);
924 for (i = 0; i < 5; i++)
925 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
932 ALIAS (no_debug_ospf_packet,
933 no_debug_ospf_packet_send_recv_cmd,
934 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
936 "Debugging functions\n"
940 "OSPF Database Description\n"
941 "OSPF Link State Request\n"
942 "OSPF Link State Update\n"
943 "OSPF Link State Acknowledgment\n"
947 "Detail Information\n")
949 ALIAS (no_debug_ospf_packet,
950 no_debug_ospf_packet_send_recv_detail_cmd,
951 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
953 "Debugging functions\n"
957 "OSPF Database Description\n"
958 "OSPF Link State Request\n"
959 "OSPF Link State Update\n"
960 "OSPF Link State Acknowledgment\n"
964 "Detail Information\n")
967 DEFUN (debug_ospf_ism,
972 "OSPF Interface State Machine\n")
974 if (vty->node == CONFIG_NODE)
980 if (strncmp (argv[0], "s", 1) == 0)
981 DEBUG_ON (ism, ISM_STATUS);
982 else if (strncmp (argv[0], "e", 1) == 0)
983 DEBUG_ON (ism, ISM_EVENTS);
984 else if (strncmp (argv[0], "t", 1) == 0)
985 DEBUG_ON (ism, ISM_TIMERS);
993 TERM_DEBUG_ON (ism, ISM);
996 if (strncmp (argv[0], "s", 1) == 0)
997 TERM_DEBUG_ON (ism, ISM_STATUS);
998 else if (strncmp (argv[0], "e", 1) == 0)
999 TERM_DEBUG_ON (ism, ISM_EVENTS);
1000 else if (strncmp (argv[0], "t", 1) == 0)
1001 TERM_DEBUG_ON (ism, ISM_TIMERS);
1007 ALIAS (debug_ospf_ism,
1008 debug_ospf_ism_sub_cmd,
1009 "debug ospf ism (status|events|timers)",
1012 "OSPF Interface State Machine\n"
1013 "ISM Status Information\n"
1014 "ISM Event Information\n"
1015 "ISM TImer Information\n")
1017 DEFUN (no_debug_ospf_ism,
1018 no_debug_ospf_ism_cmd,
1019 "no debug ospf ism",
1023 "OSPF Interface State Machine")
1025 if (vty->node == CONFIG_NODE)
1028 DEBUG_OFF (ism, ISM);
1031 if (strncmp (argv[0], "s", 1) == 0)
1032 DEBUG_OFF (ism, ISM_STATUS);
1033 else if (strncmp (argv[0], "e", 1) == 0)
1034 DEBUG_OFF (ism, ISM_EVENTS);
1035 else if (strncmp (argv[0], "t", 1) == 0)
1036 DEBUG_OFF (ism, ISM_TIMERS);
1043 TERM_DEBUG_OFF (ism, ISM);
1046 if (strncmp (argv[0], "s", 1) == 0)
1047 TERM_DEBUG_OFF (ism, ISM_STATUS);
1048 else if (strncmp (argv[0], "e", 1) == 0)
1049 TERM_DEBUG_OFF (ism, ISM_EVENTS);
1050 else if (strncmp (argv[0], "t", 1) == 0)
1051 TERM_DEBUG_OFF (ism, ISM_TIMERS);
1057 ALIAS (no_debug_ospf_ism,
1058 no_debug_ospf_ism_sub_cmd,
1059 "no debug ospf ism (status|events|timers)",
1061 "Debugging functions\n"
1062 "OSPF information\n"
1063 "OSPF Interface State Machine\n"
1064 "ISM Status Information\n"
1065 "ISM Event Information\n"
1066 "ISM Timer Information\n")
1069 DEFUN (debug_ospf_nsm,
1074 "OSPF Neighbor State Machine\n")
1076 if (vty->node == CONFIG_NODE)
1079 DEBUG_ON (nsm, NSM);
1082 if (strncmp (argv[0], "s", 1) == 0)
1083 DEBUG_ON (nsm, NSM_STATUS);
1084 else if (strncmp (argv[0], "e", 1) == 0)
1085 DEBUG_ON (nsm, NSM_EVENTS);
1086 else if (strncmp (argv[0], "t", 1) == 0)
1087 DEBUG_ON (nsm, NSM_TIMERS);
1095 TERM_DEBUG_ON (nsm, NSM);
1098 if (strncmp (argv[0], "s", 1) == 0)
1099 TERM_DEBUG_ON (nsm, NSM_STATUS);
1100 else if (strncmp (argv[0], "e", 1) == 0)
1101 TERM_DEBUG_ON (nsm, NSM_EVENTS);
1102 else if (strncmp (argv[0], "t", 1) == 0)
1103 TERM_DEBUG_ON (nsm, NSM_TIMERS);
1109 ALIAS (debug_ospf_nsm,
1110 debug_ospf_nsm_sub_cmd,
1111 "debug ospf nsm (status|events|timers)",
1114 "OSPF Neighbor State Machine\n"
1115 "NSM Status Information\n"
1116 "NSM Event Information\n"
1117 "NSM Timer Information\n")
1119 DEFUN (no_debug_ospf_nsm,
1120 no_debug_ospf_nsm_cmd,
1121 "no debug ospf nsm",
1125 "OSPF Neighbor State Machine")
1127 if (vty->node == CONFIG_NODE)
1130 DEBUG_OFF (nsm, NSM);
1133 if (strncmp (argv[0], "s", 1) == 0)
1134 DEBUG_OFF (nsm, NSM_STATUS);
1135 else if (strncmp (argv[0], "e", 1) == 0)
1136 DEBUG_OFF (nsm, NSM_EVENTS);
1137 else if (strncmp (argv[0], "t", 1) == 0)
1138 DEBUG_OFF (nsm, NSM_TIMERS);
1146 TERM_DEBUG_OFF (nsm, NSM);
1149 if (strncmp (argv[0], "s", 1) == 0)
1150 TERM_DEBUG_OFF (nsm, NSM_STATUS);
1151 else if (strncmp (argv[0], "e", 1) == 0)
1152 TERM_DEBUG_OFF (nsm, NSM_EVENTS);
1153 else if (strncmp (argv[0], "t", 1) == 0)
1154 TERM_DEBUG_OFF (nsm, NSM_TIMERS);
1160 ALIAS (no_debug_ospf_nsm,
1161 no_debug_ospf_nsm_sub_cmd,
1162 "no debug ospf nsm (status|events|timers)",
1164 "Debugging functions\n"
1165 "OSPF information\n"
1166 "OSPF Interface State Machine\n"
1167 "NSM Status Information\n"
1168 "NSM Event Information\n"
1169 "NSM Timer Information\n")
1172 DEFUN (debug_ospf_lsa,
1177 "OSPF Link State Advertisement\n")
1179 if (vty->node == CONFIG_NODE)
1182 DEBUG_ON (lsa, LSA);
1185 if (strncmp (argv[0], "g", 1) == 0)
1186 DEBUG_ON (lsa, LSA_GENERATE);
1187 else if (strncmp (argv[0], "f", 1) == 0)
1188 DEBUG_ON (lsa, LSA_FLOODING);
1189 else if (strncmp (argv[0], "i", 1) == 0)
1190 DEBUG_ON (lsa, LSA_INSTALL);
1191 else if (strncmp (argv[0], "r", 1) == 0)
1192 DEBUG_ON (lsa, LSA_REFRESH);
1200 TERM_DEBUG_ON (lsa, LSA);
1203 if (strncmp (argv[0], "g", 1) == 0)
1204 TERM_DEBUG_ON (lsa, LSA_GENERATE);
1205 else if (strncmp (argv[0], "f", 1) == 0)
1206 TERM_DEBUG_ON (lsa, LSA_FLOODING);
1207 else if (strncmp (argv[0], "i", 1) == 0)
1208 TERM_DEBUG_ON (lsa, LSA_INSTALL);
1209 else if (strncmp (argv[0], "r", 1) == 0)
1210 TERM_DEBUG_ON (lsa, LSA_REFRESH);
1216 ALIAS (debug_ospf_lsa,
1217 debug_ospf_lsa_sub_cmd,
1218 "debug ospf lsa (generate|flooding|install|refresh)",
1221 "OSPF Link State Advertisement\n"
1224 "LSA Install/Delete\n"
1227 DEFUN (no_debug_ospf_lsa,
1228 no_debug_ospf_lsa_cmd,
1229 "no debug ospf lsa",
1233 "OSPF Link State Advertisement\n")
1235 if (vty->node == CONFIG_NODE)
1238 DEBUG_OFF (lsa, LSA);
1241 if (strncmp (argv[0], "g", 1) == 0)
1242 DEBUG_OFF (lsa, LSA_GENERATE);
1243 else if (strncmp (argv[0], "f", 1) == 0)
1244 DEBUG_OFF (lsa, LSA_FLOODING);
1245 else if (strncmp (argv[0], "i", 1) == 0)
1246 DEBUG_OFF (lsa, LSA_INSTALL);
1247 else if (strncmp (argv[0], "r", 1) == 0)
1248 DEBUG_OFF (lsa, LSA_REFRESH);
1256 TERM_DEBUG_OFF (lsa, LSA);
1259 if (strncmp (argv[0], "g", 1) == 0)
1260 TERM_DEBUG_OFF (lsa, LSA_GENERATE);
1261 else if (strncmp (argv[0], "f", 1) == 0)
1262 TERM_DEBUG_OFF (lsa, LSA_FLOODING);
1263 else if (strncmp (argv[0], "i", 1) == 0)
1264 TERM_DEBUG_OFF (lsa, LSA_INSTALL);
1265 else if (strncmp (argv[0], "r", 1) == 0)
1266 TERM_DEBUG_OFF (lsa, LSA_REFRESH);
1272 ALIAS (no_debug_ospf_lsa,
1273 no_debug_ospf_lsa_sub_cmd,
1274 "no debug ospf lsa (generate|flooding|install|refresh)",
1278 "OSPF Link State Advertisement\n"
1281 "LSA Install/Delete\n"
1285 DEFUN (debug_ospf_zebra,
1286 debug_ospf_zebra_cmd,
1290 "OSPF Zebra information\n")
1292 if (vty->node == CONFIG_NODE)
1295 DEBUG_ON (zebra, ZEBRA);
1298 if (strncmp (argv[0], "i", 1) == 0)
1299 DEBUG_ON (zebra, ZEBRA_INTERFACE);
1300 else if (strncmp (argv[0], "r", 1) == 0)
1301 DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
1309 TERM_DEBUG_ON (zebra, ZEBRA);
1312 if (strncmp (argv[0], "i", 1) == 0)
1313 TERM_DEBUG_ON (zebra, ZEBRA_INTERFACE);
1314 else if (strncmp (argv[0], "r", 1) == 0)
1315 TERM_DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
1321 ALIAS (debug_ospf_zebra,
1322 debug_ospf_zebra_sub_cmd,
1323 "debug ospf zebra (interface|redistribute)",
1326 "OSPF Zebra information\n"
1328 "Zebra redistribute\n")
1330 DEFUN (no_debug_ospf_zebra,
1331 no_debug_ospf_zebra_cmd,
1332 "no debug ospf zebra",
1336 "OSPF Zebra information\n")
1338 if (vty->node == CONFIG_NODE)
1341 DEBUG_OFF (zebra, ZEBRA);
1344 if (strncmp (argv[0], "i", 1) == 0)
1345 DEBUG_OFF (zebra, ZEBRA_INTERFACE);
1346 else if (strncmp (argv[0], "r", 1) == 0)
1347 DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
1355 TERM_DEBUG_OFF (zebra, ZEBRA);
1358 if (strncmp (argv[0], "i", 1) == 0)
1359 TERM_DEBUG_OFF (zebra, ZEBRA_INTERFACE);
1360 else if (strncmp (argv[0], "r", 1) == 0)
1361 TERM_DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
1367 ALIAS (no_debug_ospf_zebra,
1368 no_debug_ospf_zebra_sub_cmd,
1369 "no debug ospf zebra (interface|redistribute)",
1373 "OSPF Zebra information\n"
1375 "Zebra redistribute\n")
1377 DEFUN (debug_ospf_event,
1378 debug_ospf_event_cmd,
1382 "OSPF event information\n")
1384 if (vty->node == CONFIG_NODE)
1385 CONF_DEBUG_ON (event, EVENT);
1386 TERM_DEBUG_ON (event, EVENT);
1390 DEFUN (no_debug_ospf_event,
1391 no_debug_ospf_event_cmd,
1392 "no debug ospf event",
1396 "OSPF event information\n")
1398 if (vty->node == CONFIG_NODE)
1399 CONF_DEBUG_OFF (event, EVENT);
1400 TERM_DEBUG_OFF (event, EVENT);
1404 DEFUN (debug_ospf_nssa,
1405 debug_ospf_nssa_cmd,
1409 "OSPF nssa information\n")
1411 if (vty->node == CONFIG_NODE)
1412 CONF_DEBUG_ON (nssa, NSSA);
1413 TERM_DEBUG_ON (nssa, NSSA);
1417 DEFUN (no_debug_ospf_nssa,
1418 no_debug_ospf_nssa_cmd,
1419 "no debug ospf nssa",
1423 "OSPF nssa information\n")
1425 if (vty->node == CONFIG_NODE)
1426 CONF_DEBUG_OFF (nssa, NSSA);
1427 TERM_DEBUG_OFF (nssa, NSSA);
1431 DEFUN (debug_ospf_te,
1436 "OSPF-TE information\n")
1438 if (vty->node == CONFIG_NODE)
1439 CONF_DEBUG_ON (te, TE);
1440 TERM_DEBUG_ON (te, TE);
1444 DEFUN (no_debug_ospf_te,
1445 no_debug_ospf_te_cmd,
1450 "OSPF-TE information\n")
1452 if (vty->node == CONFIG_NODE)
1453 CONF_DEBUG_OFF (te, TE);
1454 TERM_DEBUG_OFF (te, TE);
1458 DEFUN (show_debugging_ospf,
1459 show_debugging_ospf_cmd,
1460 "show debugging ospf",
1467 vty_out (vty, "OSPF debugging status:%s", VTY_NEWLINE);
1469 /* Show debug status for events. */
1470 if (IS_DEBUG_OSPF(event,EVENT))
1471 vty_out (vty, " OSPF event debugging is on%s", VTY_NEWLINE);
1473 /* Show debug status for ISM. */
1474 if (IS_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
1475 vty_out (vty, " OSPF ISM debugging is on%s", VTY_NEWLINE);
1478 if (IS_DEBUG_OSPF (ism, ISM_STATUS))
1479 vty_out (vty, " OSPF ISM status debugging is on%s", VTY_NEWLINE);
1480 if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
1481 vty_out (vty, " OSPF ISM event debugging is on%s", VTY_NEWLINE);
1482 if (IS_DEBUG_OSPF (ism, ISM_TIMERS))
1483 vty_out (vty, " OSPF ISM timer debugging is on%s", VTY_NEWLINE);
1486 /* Show debug status for NSM. */
1487 if (IS_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
1488 vty_out (vty, " OSPF NSM debugging is on%s", VTY_NEWLINE);
1491 if (IS_DEBUG_OSPF (nsm, NSM_STATUS))
1492 vty_out (vty, " OSPF NSM status debugging is on%s", VTY_NEWLINE);
1493 if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
1494 vty_out (vty, " OSPF NSM event debugging is on%s", VTY_NEWLINE);
1495 if (IS_DEBUG_OSPF (nsm, NSM_TIMERS))
1496 vty_out (vty, " OSPF NSM timer debugging is on%s", VTY_NEWLINE);
1499 /* Show debug status for OSPF Packets. */
1500 for (i = 0; i < 5; i++)
1501 if (IS_DEBUG_OSPF_PACKET (i, SEND) && IS_DEBUG_OSPF_PACKET (i, RECV))
1503 vty_out (vty, " OSPF packet %s%s debugging is on%s",
1504 LOOKUP (ospf_packet_type_str, i + 1),
1505 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1510 if (IS_DEBUG_OSPF_PACKET (i, SEND))
1511 vty_out (vty, " OSPF packet %s send%s debugging is on%s",
1512 LOOKUP (ospf_packet_type_str, i + 1),
1513 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1515 if (IS_DEBUG_OSPF_PACKET (i, RECV))
1516 vty_out (vty, " OSPF packet %s receive%s debugging is on%s",
1517 LOOKUP (ospf_packet_type_str, i + 1),
1518 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1522 /* Show debug status for OSPF LSAs. */
1523 if (IS_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
1524 vty_out (vty, " OSPF LSA debugging is on%s", VTY_NEWLINE);
1527 if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
1528 vty_out (vty, " OSPF LSA generation debugging is on%s", VTY_NEWLINE);
1529 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
1530 vty_out (vty, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE);
1531 if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
1532 vty_out (vty, " OSPF LSA install debugging is on%s", VTY_NEWLINE);
1533 if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
1534 vty_out (vty, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE);
1537 /* Show debug status for Zebra. */
1538 if (IS_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
1539 vty_out (vty, " OSPF Zebra debugging is on%s", VTY_NEWLINE);
1542 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
1543 vty_out (vty, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE);
1544 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
1545 vty_out (vty, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE);
1548 /* Show debug status for NSSA. */
1549 if (IS_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
1550 vty_out (vty, " OSPF NSSA debugging is on%s", VTY_NEWLINE);
1556 static struct cmd_node debug_node =
1564 config_write_debug (struct vty *vty)
1569 const char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
1570 const char *detail_str[] = {"", " send", " recv", "", " detail",
1571 " send detail", " recv detail", " detail"};
1573 /* debug ospf ism (status|events|timers). */
1574 if (IS_CONF_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
1575 vty_out (vty, "debug ospf ism%s", VTY_NEWLINE);
1578 if (IS_CONF_DEBUG_OSPF (ism, ISM_STATUS))
1579 vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE);
1580 if (IS_CONF_DEBUG_OSPF (ism, ISM_EVENTS))
1581 vty_out (vty, "debug ospf ism event%s", VTY_NEWLINE);
1582 if (IS_CONF_DEBUG_OSPF (ism, ISM_TIMERS))
1583 vty_out (vty, "debug ospf ism timer%s", VTY_NEWLINE);
1586 /* debug ospf nsm (status|events|timers). */
1587 if (IS_CONF_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
1588 vty_out (vty, "debug ospf nsm%s", VTY_NEWLINE);
1591 if (IS_CONF_DEBUG_OSPF (nsm, NSM_STATUS))
1592 vty_out (vty, "debug ospf nsm status%s", VTY_NEWLINE);
1593 if (IS_CONF_DEBUG_OSPF (nsm, NSM_EVENTS))
1594 vty_out (vty, "debug ospf nsm event%s", VTY_NEWLINE);
1595 if (IS_CONF_DEBUG_OSPF (nsm, NSM_TIMERS))
1596 vty_out (vty, "debug ospf nsm timer%s", VTY_NEWLINE);
1599 /* debug ospf lsa (generate|flooding|install|refresh). */
1600 if (IS_CONF_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
1601 vty_out (vty, "debug ospf lsa%s", VTY_NEWLINE);
1604 if (IS_CONF_DEBUG_OSPF (lsa, LSA_GENERATE))
1605 vty_out (vty, "debug ospf lsa generate%s", VTY_NEWLINE);
1606 if (IS_CONF_DEBUG_OSPF (lsa, LSA_FLOODING))
1607 vty_out (vty, "debug ospf lsa flooding%s", VTY_NEWLINE);
1608 if (IS_CONF_DEBUG_OSPF (lsa, LSA_INSTALL))
1609 vty_out (vty, "debug ospf lsa install%s", VTY_NEWLINE);
1610 if (IS_CONF_DEBUG_OSPF (lsa, LSA_REFRESH))
1611 vty_out (vty, "debug ospf lsa refresh%s", VTY_NEWLINE);
1616 /* debug ospf zebra (interface|redistribute). */
1617 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
1618 vty_out (vty, "debug ospf zebra%s", VTY_NEWLINE);
1621 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
1622 vty_out (vty, "debug ospf zebra interface%s", VTY_NEWLINE);
1623 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
1624 vty_out (vty, "debug ospf zebra redistribute%s", VTY_NEWLINE);
1629 /* debug ospf event. */
1630 if (IS_CONF_DEBUG_OSPF (event, EVENT) == OSPF_DEBUG_EVENT)
1632 vty_out (vty, "debug ospf event%s", VTY_NEWLINE);
1636 /* debug ospf nssa. */
1637 if (IS_CONF_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
1639 vty_out (vty, "debug ospf nssa%s", VTY_NEWLINE);
1643 /* debug ospf packet all detail. */
1644 r = OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL;
1645 for (i = 0; i < 5; i++)
1646 r &= conf_debug_ospf_packet[i] & (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL);
1647 if (r == (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL))
1649 vty_out (vty, "debug ospf packet all detail%s", VTY_NEWLINE);
1653 /* debug ospf packet all. */
1654 r = OSPF_DEBUG_SEND_RECV;
1655 for (i = 0; i < 5; i++)
1656 r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV;
1657 if (r == OSPF_DEBUG_SEND_RECV)
1659 vty_out (vty, "debug ospf packet all%s", VTY_NEWLINE);
1660 for (i = 0; i < 5; i++)
1661 if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL)
1662 vty_out (vty, "debug ospf packet %s detail%s",
1668 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1669 (send|recv) (detail). */
1670 for (i = 0; i < 5; i++)
1672 if (conf_debug_ospf_packet[i] == 0)
1675 vty_out (vty, "debug ospf packet %s%s%s",
1676 type_str[i], detail_str[conf_debug_ospf_packet[i]],
1684 /* Initialize debug commands. */
1688 install_node (&debug_node, config_write_debug);
1690 install_element (ENABLE_NODE, &show_debugging_ospf_cmd);
1691 install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_detail_cmd);
1692 install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_cmd);
1693 install_element (ENABLE_NODE, &debug_ospf_packet_all_cmd);
1694 install_element (ENABLE_NODE, &debug_ospf_ism_sub_cmd);
1695 install_element (ENABLE_NODE, &debug_ospf_ism_cmd);
1696 install_element (ENABLE_NODE, &debug_ospf_nsm_sub_cmd);
1697 install_element (ENABLE_NODE, &debug_ospf_nsm_cmd);
1698 install_element (ENABLE_NODE, &debug_ospf_lsa_sub_cmd);
1699 install_element (ENABLE_NODE, &debug_ospf_lsa_cmd);
1700 install_element (ENABLE_NODE, &debug_ospf_zebra_sub_cmd);
1701 install_element (ENABLE_NODE, &debug_ospf_zebra_cmd);
1702 install_element (ENABLE_NODE, &debug_ospf_event_cmd);
1703 install_element (ENABLE_NODE, &debug_ospf_nssa_cmd);
1704 install_element (ENABLE_NODE, &debug_ospf_te_cmd);
1705 install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
1706 install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_cmd);
1707 install_element (ENABLE_NODE, &no_debug_ospf_packet_all_cmd);
1708 install_element (ENABLE_NODE, &no_debug_ospf_ism_sub_cmd);
1709 install_element (ENABLE_NODE, &no_debug_ospf_ism_cmd);
1710 install_element (ENABLE_NODE, &no_debug_ospf_nsm_sub_cmd);
1711 install_element (ENABLE_NODE, &no_debug_ospf_nsm_cmd);
1712 install_element (ENABLE_NODE, &no_debug_ospf_lsa_sub_cmd);
1713 install_element (ENABLE_NODE, &no_debug_ospf_lsa_cmd);
1714 install_element (ENABLE_NODE, &no_debug_ospf_zebra_sub_cmd);
1715 install_element (ENABLE_NODE, &no_debug_ospf_zebra_cmd);
1716 install_element (ENABLE_NODE, &no_debug_ospf_event_cmd);
1717 install_element (ENABLE_NODE, &no_debug_ospf_nssa_cmd);
1718 install_element (ENABLE_NODE, &no_debug_ospf_te_cmd);
1720 install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_detail_cmd);
1721 install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_cmd);
1722 install_element (CONFIG_NODE, &debug_ospf_packet_all_cmd);
1723 install_element (CONFIG_NODE, &debug_ospf_ism_sub_cmd);
1724 install_element (CONFIG_NODE, &debug_ospf_ism_cmd);
1725 install_element (CONFIG_NODE, &debug_ospf_nsm_sub_cmd);
1726 install_element (CONFIG_NODE, &debug_ospf_nsm_cmd);
1727 install_element (CONFIG_NODE, &debug_ospf_lsa_sub_cmd);
1728 install_element (CONFIG_NODE, &debug_ospf_lsa_cmd);
1729 install_element (CONFIG_NODE, &debug_ospf_zebra_sub_cmd);
1730 install_element (CONFIG_NODE, &debug_ospf_zebra_cmd);
1731 install_element (CONFIG_NODE, &debug_ospf_event_cmd);
1732 install_element (CONFIG_NODE, &debug_ospf_nssa_cmd);
1733 install_element (CONFIG_NODE, &debug_ospf_te_cmd);
1734 install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
1735 install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_cmd);
1736 install_element (CONFIG_NODE, &no_debug_ospf_packet_all_cmd);
1737 install_element (CONFIG_NODE, &no_debug_ospf_ism_sub_cmd);
1738 install_element (CONFIG_NODE, &no_debug_ospf_ism_cmd);
1739 install_element (CONFIG_NODE, &no_debug_ospf_nsm_sub_cmd);
1740 install_element (CONFIG_NODE, &no_debug_ospf_nsm_cmd);
1741 install_element (CONFIG_NODE, &no_debug_ospf_lsa_sub_cmd);
1742 install_element (CONFIG_NODE, &no_debug_ospf_lsa_cmd);
1743 install_element (CONFIG_NODE, &no_debug_ospf_zebra_sub_cmd);
1744 install_element (CONFIG_NODE, &no_debug_ospf_zebra_cmd);
1745 install_element (CONFIG_NODE, &no_debug_ospf_event_cmd);
1746 install_element (CONFIG_NODE, &no_debug_ospf_nssa_cmd);
1747 install_element (CONFIG_NODE, &no_debug_ospf_te_cmd);