blob: 9ae87a61e7568f07fe294d46929b3594d58c728a [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
2 * OSPFd dump routine.
3 * Copyright (C) 1999, 2000 Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
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
10 * later version.
11 *
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.
16 *
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.
21 */
22
23#include <zebra.h>
24
25#include "linklist.h"
26#include "thread.h"
27#include "prefix.h"
28#include "command.h"
29#include "stream.h"
30#include "log.h"
paulaa20c6f2004-10-07 14:19:36 +000031#include "sockopt.h"
paul718e3742002-12-13 20:15:29 +000032
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"
44
45struct message ospf_ism_state_msg[] =
46{
47 { ISM_DependUpon, "DependUpon" },
48 { ISM_Down, "Down" },
49 { ISM_Loopback, "Loopback" },
50 { ISM_Waiting, "Waiting" },
51 { ISM_PointToPoint, "Point-To-Point" },
52 { ISM_DROther, "DROther" },
53 { ISM_Backup, "Backup" },
54 { ISM_DR, "DR" },
55};
56int ospf_ism_state_msg_max = OSPF_ISM_STATE_MAX;
57
58struct message ospf_nsm_state_msg[] =
59{
60 { NSM_DependUpon, "DependUpon" },
61 { NSM_Down, "Down" },
62 { NSM_Attempt, "Attempt" },
63 { NSM_Init, "Init" },
64 { NSM_TwoWay, "2-Way" },
65 { NSM_ExStart, "ExStart" },
66 { NSM_Exchange, "Exchange" },
67 { NSM_Loading, "Loading" },
68 { NSM_Full, "Full" },
69};
70int ospf_nsm_state_msg_max = OSPF_NSM_STATE_MAX;
71
72struct message ospf_lsa_type_msg[] =
73{
74 { OSPF_UNKNOWN_LSA, "unknown" },
75 { OSPF_ROUTER_LSA, "router-LSA" },
76 { OSPF_NETWORK_LSA, "network-LSA" },
77 { OSPF_SUMMARY_LSA, "summary-LSA" },
78 { OSPF_ASBR_SUMMARY_LSA, "summary-LSA" },
79 { OSPF_AS_EXTERNAL_LSA, "AS-external-LSA" },
80 { OSPF_GROUP_MEMBER_LSA, "GROUP MEMBER LSA" },
81 { OSPF_AS_NSSA_LSA, "NSSA-LSA" },
82 { 8, "Type-8 LSA" },
83 { OSPF_OPAQUE_LINK_LSA, "Link-Local Opaque-LSA" },
84 { OSPF_OPAQUE_AREA_LSA, "Area-Local Opaque-LSA" },
85 { OSPF_OPAQUE_AS_LSA, "AS-external Opaque-LSA" },
86};
87int ospf_lsa_type_msg_max = OSPF_MAX_LSA;
88
89struct message ospf_link_state_id_type_msg[] =
90{
91 { OSPF_UNKNOWN_LSA, "(unknown)" },
92 { OSPF_ROUTER_LSA, "" },
93 { OSPF_NETWORK_LSA, "(address of Designated Router)" },
94 { OSPF_SUMMARY_LSA, "(summary Network Number)" },
95 { OSPF_ASBR_SUMMARY_LSA, "(AS Boundary Router address)" },
96 { OSPF_AS_EXTERNAL_LSA, "(External Network Number)" },
97 { OSPF_GROUP_MEMBER_LSA, "(Group membership information)" },
98 { OSPF_AS_NSSA_LSA, "(External Network Number for NSSA)" },
99 { 8, "(Type-8 LSID)" },
100 { OSPF_OPAQUE_LINK_LSA, "(Link-Local Opaque-Type/ID)" },
101 { OSPF_OPAQUE_AREA_LSA, "(Area-Local Opaque-Type/ID)" },
102 { OSPF_OPAQUE_AS_LSA, "(AS-external Opaque-Type/ID)" },
103};
104int ospf_link_state_id_type_msg_max = OSPF_MAX_LSA;
105
paul718e3742002-12-13 20:15:29 +0000106struct message ospf_network_type_msg[] =
107{
108 { OSPF_IFTYPE_NONE, "NONE" },
109 { OSPF_IFTYPE_POINTOPOINT, "Point-to-Point" },
110 { OSPF_IFTYPE_BROADCAST, "Broadcast" },
111 { OSPF_IFTYPE_NBMA, "NBMA" },
112 { OSPF_IFTYPE_POINTOMULTIPOINT, "Point-to-MultiPoint" },
113 { OSPF_IFTYPE_VIRTUALLINK, "Virtual-Link" },
114};
115int ospf_network_type_msg_max = OSPF_IFTYPE_MAX;
116
117/* Configuration debug option variables. */
118unsigned long conf_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
119unsigned long conf_debug_ospf_event = 0;
120unsigned long conf_debug_ospf_ism = 0;
121unsigned long conf_debug_ospf_nsm = 0;
122unsigned long conf_debug_ospf_lsa = 0;
123unsigned long conf_debug_ospf_zebra = 0;
124unsigned long conf_debug_ospf_nssa = 0;
125
126/* Enable debug option variables -- valid only session. */
127unsigned long term_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
128unsigned long term_debug_ospf_event = 0;
129unsigned long term_debug_ospf_ism = 0;
130unsigned long term_debug_ospf_nsm = 0;
131unsigned long term_debug_ospf_lsa = 0;
132unsigned long term_debug_ospf_zebra = 0;
133unsigned long term_debug_ospf_nssa = 0;
134
135
ajsf52d13c2005-10-01 17:38:06 +0000136
137const char *
138ospf_redist_string(u_int route_type)
139{
140 return (route_type == ZEBRA_ROUTE_MAX) ?
141 "Default" : zebra_route_string(route_type);
142}
143
paul718e3742002-12-13 20:15:29 +0000144#define OSPF_AREA_STRING_MAXLEN 16
hassoeb1ce602004-10-08 08:17:22 +0000145const char *
paul718e3742002-12-13 20:15:29 +0000146ospf_area_name_string (struct ospf_area *area)
147{
148 static char buf[OSPF_AREA_STRING_MAXLEN] = "";
149 u_int32_t area_id;
150
151 if (!area)
152 return "-";
153
154 area_id = ntohl (area->area_id.s_addr);
155 snprintf (buf, OSPF_AREA_STRING_MAXLEN, "%d.%d.%d.%d",
156 (area_id >> 24) & 0xff, (area_id >> 16) & 0xff,
157 (area_id >> 8) & 0xff, area_id & 0xff);
158 return buf;
159}
160
161#define OSPF_AREA_DESC_STRING_MAXLEN 23
hassoeb1ce602004-10-08 08:17:22 +0000162const char *
paul718e3742002-12-13 20:15:29 +0000163ospf_area_desc_string (struct ospf_area *area)
164{
165 static char buf[OSPF_AREA_DESC_STRING_MAXLEN] = "";
166 u_char type;
167
168 if (!area)
169 return "(incomplete)";
170
171 type = area->external_routing;
172 switch (type)
173 {
174 case OSPF_AREA_NSSA:
175 snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [NSSA]",
176 ospf_area_name_string (area));
177 break;
178 case OSPF_AREA_STUB:
179 snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [Stub]",
180 ospf_area_name_string (area));
181 break;
182 default:
183 return ospf_area_name_string (area);
184 break;
185 }
186
187 return buf;
188}
189
190#define OSPF_IF_STRING_MAXLEN 40
hassoeb1ce602004-10-08 08:17:22 +0000191const char *
paul718e3742002-12-13 20:15:29 +0000192ospf_if_name_string (struct ospf_interface *oi)
193{
194 static char buf[OSPF_IF_STRING_MAXLEN] = "";
195 u_int32_t ifaddr;
196
197 if (!oi)
198 return "inactive";
199
200 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
201 return oi->ifp->name;
202
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);
208 return buf;
209}
210
211
212void
213ospf_nbr_state_message (struct ospf_neighbor *nbr, char *buf, size_t size)
214{
215 int state;
216 struct ospf_interface *oi = nbr->oi;
217
218 if (IPV4_ADDR_SAME (&DR (oi), &nbr->address.u.prefix4))
219 state = ISM_DR;
220 else if (IPV4_ADDR_SAME (&BDR (oi), &nbr->address.u.prefix4))
221 state = ISM_Backup;
222 else
223 state = ISM_DROther;
224
225 memset (buf, 0, size);
226
227 snprintf (buf, size, "%s/%s",
228 LOOKUP (ospf_nsm_state_msg, nbr->state),
229 LOOKUP (ospf_ism_state_msg, state));
230}
231
hassoeb1ce602004-10-08 08:17:22 +0000232const char *
pauld24f6e22005-10-21 09:23:12 +0000233ospf_timeval_dump (struct timeval *t, char *buf, size_t size)
paul718e3742002-12-13 20:15:29 +0000234{
pauld24f6e22005-10-21 09:23:12 +0000235 /* 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;
241
paul718e3742002-12-13 20:15:29 +0000242 if (!t)
243 return "inactive";
pauld24f6e22005-10-21 09:23:12 +0000244
245 w = d = h = m = s = ms = 0;
paul718e3742002-12-13 20:15:29 +0000246 memset (buf, 0, size);
paulf9ad9372005-10-21 00:45:17 +0000247
pauld24f6e22005-10-21 09:23:12 +0000248 ms = t->tv_usec / 1000;
paulf9ad9372005-10-21 00:45:17 +0000249
250 if (ms >= 1000)
paul718e3742002-12-13 20:15:29 +0000251 {
pauld24f6e22005-10-21 09:23:12 +0000252 t->tv_sec = ms / 1000;
253 ms =- t->tv_sec * 1000;
paulf9ad9372005-10-21 00:45:17 +0000254 }
pauld24f6e22005-10-21 09:23:12 +0000255
256 if (t->tv_sec > WEEK_IN_SECONDS)
paulf9ad9372005-10-21 00:45:17 +0000257 {
pauld24f6e22005-10-21 09:23:12 +0000258 w = t->tv_sec / WEEK_IN_SECONDS;
259 t->tv_sec -= w * WEEK_IN_SECONDS;
paul718e3742002-12-13 20:15:29 +0000260 }
pauld24f6e22005-10-21 09:23:12 +0000261
262 if (t->tv_sec > DAY_IN_SECONDS)
paul718e3742002-12-13 20:15:29 +0000263 {
pauld24f6e22005-10-21 09:23:12 +0000264 d = t->tv_sec / DAY_IN_SECONDS;
265 t->tv_sec -= d * DAY_IN_SECONDS;
paul718e3742002-12-13 20:15:29 +0000266 }
pauld24f6e22005-10-21 09:23:12 +0000267
268 if (t->tv_sec >= HOUR_IN_SECONDS)
269 {
270 h = t->tv_sec / HOUR_IN_SECONDS;
271 t->tv_sec -= h * HOUR_IN_SECONDS;
272 }
273
274 if (t->tv_sec >= MINUTE_IN_SECONDS)
275 {
276 m = t->tv_sec / MINUTE_IN_SECONDS;
277 t->tv_sec -= m * MINUTE_IN_SECONDS;
278 }
279
280 if (w > 99)
281 snprintf (buf, size, "%ldw%1ldd", w, d);
282 else if (w)
283 snprintf (buf, size, "%ldw%1ldd%02ldh", w, d, h);
284 else if (d)
285 snprintf (buf, size, "%1ldd%02ldh%02ldm", d, h, m);
286 else if (h)
287 snprintf (buf, size, "%ldh%02ldm%02lds", h, m, t->tv_sec);
288 else if (m)
289 snprintf (buf, size, "%ldm%02lds", m, t->tv_sec);
290 else
291 snprintf (buf, size, "%ld.%03lds", t->tv_sec, ms);
292
paul718e3742002-12-13 20:15:29 +0000293 return buf;
294}
295
pauld24f6e22005-10-21 09:23:12 +0000296const char *
297ospf_timer_dump (struct thread *t, char *buf, size_t size)
298{
299 struct timeval result;
300
301 if (!t)
302 return "inactive";
303
304 timersub (&t->u.sands, &recent_time, &result);
305
306 return ospf_timeval_dump (&result, buf, size);
307}
308
paul718e3742002-12-13 20:15:29 +0000309#define OSPF_OPTION_STR_MAXLEN 24
310
311char *
312ospf_options_dump (u_char options)
313{
314 static char buf[OSPF_OPTION_STR_MAXLEN];
315
316 snprintf (buf, OSPF_OPTION_STR_MAXLEN, "*|%s|%s|%s|%s|%s|%s|*",
317 (options & OSPF_OPTION_O) ? "O" : "-",
318 (options & OSPF_OPTION_DC) ? "DC" : "-",
319 (options & OSPF_OPTION_EA) ? "EA" : "-",
320 (options & OSPF_OPTION_NP) ? "N/P" : "-",
321 (options & OSPF_OPTION_MC) ? "MC" : "-",
322 (options & OSPF_OPTION_E) ? "E" : "-");
323
324 return buf;
325}
326
paul4dadc292005-05-06 21:37:42 +0000327static void
paul718e3742002-12-13 20:15:29 +0000328ospf_packet_hello_dump (struct stream *s, u_int16_t length)
329{
330 struct ospf_hello *hello;
331 int i;
332
333 hello = (struct ospf_hello *) STREAM_PNT (s);
334
ajs60925302004-12-08 17:45:02 +0000335 zlog_debug ("Hello");
336 zlog_debug (" NetworkMask %s", inet_ntoa (hello->network_mask));
337 zlog_debug (" HelloInterval %d", ntohs (hello->hello_interval));
338 zlog_debug (" Options %d (%s)", hello->options,
paul718e3742002-12-13 20:15:29 +0000339 ospf_options_dump (hello->options));
ajs60925302004-12-08 17:45:02 +0000340 zlog_debug (" RtrPriority %d", hello->priority);
341 zlog_debug (" RtrDeadInterval %ld", (u_long)ntohl (hello->dead_interval));
342 zlog_debug (" DRouter %s", inet_ntoa (hello->d_router));
343 zlog_debug (" BDRouter %s", inet_ntoa (hello->bd_router));
paul718e3742002-12-13 20:15:29 +0000344
345 length -= OSPF_HEADER_SIZE + OSPF_HELLO_MIN_SIZE;
ajs60925302004-12-08 17:45:02 +0000346 zlog_debug (" # Neighbors %d", length / 4);
paul718e3742002-12-13 20:15:29 +0000347 for (i = 0; length > 0; i++, length -= sizeof (struct in_addr))
ajs60925302004-12-08 17:45:02 +0000348 zlog_debug (" Neighbor %s", inet_ntoa (hello->neighbors[i]));
paul718e3742002-12-13 20:15:29 +0000349}
350
paul4dadc292005-05-06 21:37:42 +0000351static char *
paul718e3742002-12-13 20:15:29 +0000352ospf_dd_flags_dump (u_char flags, char *buf, size_t size)
353{
354 memset (buf, 0, size);
355
356 snprintf (buf, size, "%s|%s|%s",
357 (flags & OSPF_DD_FLAG_I) ? "I" : "-",
358 (flags & OSPF_DD_FLAG_M) ? "M" : "-",
359 (flags & OSPF_DD_FLAG_MS) ? "MS" : "-");
360
361 return buf;
362}
363
364void
365ospf_lsa_header_dump (struct lsa_header *lsah)
366{
hassoeb1ce602004-10-08 08:17:22 +0000367 const char *lsah_type = LOOKUP (ospf_lsa_type_msg, lsah->type);
paul0c2be262004-05-31 14:16:54 +0000368
ajs60925302004-12-08 17:45:02 +0000369 zlog_debug (" LSA Header");
370 zlog_debug (" LS age %d", ntohs (lsah->ls_age));
371 zlog_debug (" Options %d (%s)", lsah->options,
paul718e3742002-12-13 20:15:29 +0000372 ospf_options_dump (lsah->options));
ajs60925302004-12-08 17:45:02 +0000373 zlog_debug (" LS type %d (%s)", lsah->type,
paul553ff112004-06-06 09:41:00 +0000374 (lsah->type ? lsah_type : "unknown type"));
ajs60925302004-12-08 17:45:02 +0000375 zlog_debug (" Link State ID %s", inet_ntoa (lsah->id));
376 zlog_debug (" Advertising Router %s", inet_ntoa (lsah->adv_router));
377 zlog_debug (" LS sequence number 0x%lx", (u_long)ntohl (lsah->ls_seqnum));
378 zlog_debug (" LS checksum 0x%x", ntohs (lsah->checksum));
379 zlog_debug (" length %d", ntohs (lsah->length));
paul718e3742002-12-13 20:15:29 +0000380}
381
paul4dadc292005-05-06 21:37:42 +0000382static char *
paul718e3742002-12-13 20:15:29 +0000383ospf_router_lsa_flags_dump (u_char flags, char *buf, size_t size)
384{
385 memset (buf, 0, size);
386
387 snprintf (buf, size, "%s|%s|%s",
388 (flags & ROUTER_LSA_VIRTUAL) ? "V" : "-",
389 (flags & ROUTER_LSA_EXTERNAL) ? "E" : "-",
390 (flags & ROUTER_LSA_BORDER) ? "B" : "-");
391
392 return buf;
393}
394
paul4dadc292005-05-06 21:37:42 +0000395static void
paul718e3742002-12-13 20:15:29 +0000396ospf_router_lsa_dump (struct stream *s, u_int16_t length)
397{
398 char buf[BUFSIZ];
399 struct router_lsa *rl;
400 int i, len;
401
402 rl = (struct router_lsa *) STREAM_PNT (s);
403
ajs60925302004-12-08 17:45:02 +0000404 zlog_debug (" Router-LSA");
405 zlog_debug (" flags %s",
paul718e3742002-12-13 20:15:29 +0000406 ospf_router_lsa_flags_dump (rl->flags, buf, BUFSIZ));
ajs60925302004-12-08 17:45:02 +0000407 zlog_debug (" # links %d", ntohs (rl->links));
paul718e3742002-12-13 20:15:29 +0000408
409 len = ntohs (rl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
410 for (i = 0; len > 0; i++)
411 {
ajs60925302004-12-08 17:45:02 +0000412 zlog_debug (" Link ID %s", inet_ntoa (rl->link[i].link_id));
413 zlog_debug (" Link Data %s", inet_ntoa (rl->link[i].link_data));
414 zlog_debug (" Type %d", (u_char) rl->link[i].type);
415 zlog_debug (" TOS %d", (u_char) rl->link[i].tos);
416 zlog_debug (" metric %d", ntohs (rl->link[i].metric));
paul718e3742002-12-13 20:15:29 +0000417
418 len -= 12;
419 }
420}
421
paul4dadc292005-05-06 21:37:42 +0000422static void
paul718e3742002-12-13 20:15:29 +0000423ospf_network_lsa_dump (struct stream *s, u_int16_t length)
424{
425 struct network_lsa *nl;
426 int i, cnt;
427
428 nl = (struct network_lsa *) STREAM_PNT (s);
429 cnt = (ntohs (nl->header.length) - (OSPF_LSA_HEADER_SIZE + 4)) / 4;
430
ajs60925302004-12-08 17:45:02 +0000431 zlog_debug (" Network-LSA");
paul718e3742002-12-13 20:15:29 +0000432 /*
ajs60925302004-12-08 17:45:02 +0000433 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
434 zlog_debug ("Network-LSA size %d",
paul718e3742002-12-13 20:15:29 +0000435 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
436 */
ajs60925302004-12-08 17:45:02 +0000437 zlog_debug (" Network Mask %s", inet_ntoa (nl->mask));
438 zlog_debug (" # Attached Routers %d", cnt);
paul718e3742002-12-13 20:15:29 +0000439 for (i = 0; i < cnt; i++)
ajs60925302004-12-08 17:45:02 +0000440 zlog_debug (" Attached Router %s", inet_ntoa (nl->routers[i]));
paul718e3742002-12-13 20:15:29 +0000441}
442
paul4dadc292005-05-06 21:37:42 +0000443static void
paul718e3742002-12-13 20:15:29 +0000444ospf_summary_lsa_dump (struct stream *s, u_int16_t length)
445{
446 struct summary_lsa *sl;
447 int size;
448 int i;
449
450 sl = (struct summary_lsa *) STREAM_PNT (s);
451
ajs60925302004-12-08 17:45:02 +0000452 zlog_debug (" Summary-LSA");
453 zlog_debug (" Network Mask %s", inet_ntoa (sl->mask));
paul718e3742002-12-13 20:15:29 +0000454
455 size = ntohs (sl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
456 for (i = 0; size > 0; size -= 4, i++)
ajs60925302004-12-08 17:45:02 +0000457 zlog_debug (" TOS=%d metric %d", sl->tos,
paul718e3742002-12-13 20:15:29 +0000458 GET_METRIC (sl->metric));
459}
460
paul4dadc292005-05-06 21:37:42 +0000461static void
paul718e3742002-12-13 20:15:29 +0000462ospf_as_external_lsa_dump (struct stream *s, u_int16_t length)
463{
464 struct as_external_lsa *al;
465 int size;
466 int i;
467
468 al = (struct as_external_lsa *) STREAM_PNT (s);
ajs60925302004-12-08 17:45:02 +0000469 zlog_debug (" %s", ospf_lsa_type_msg[al->header.type].str);
470 zlog_debug (" Network Mask %s", inet_ntoa (al->mask));
paul718e3742002-12-13 20:15:29 +0000471
472 size = ntohs (al->header.length) - OSPF_LSA_HEADER_SIZE -4;
473 for (i = 0; size > 0; size -= 12, i++)
474 {
ajs60925302004-12-08 17:45:02 +0000475 zlog_debug (" bit %s TOS=%d metric %d",
paul718e3742002-12-13 20:15:29 +0000476 IS_EXTERNAL_METRIC (al->e[i].tos) ? "E" : "-",
477 al->e[i].tos & 0x7f, GET_METRIC (al->e[i].metric));
ajs60925302004-12-08 17:45:02 +0000478 zlog_debug (" Forwarding address %s", inet_ntoa (al->e[i].fwd_addr));
479 zlog_debug (" External Route Tag %d", al->e[i].route_tag);
paul718e3742002-12-13 20:15:29 +0000480 }
481}
482
paul4dadc292005-05-06 21:37:42 +0000483static void
paul718e3742002-12-13 20:15:29 +0000484ospf_lsa_header_list_dump (struct stream *s, u_int16_t length)
485{
486 struct lsa_header *lsa;
487
ajs60925302004-12-08 17:45:02 +0000488 zlog_debug (" # LSA Headers %d", length / OSPF_LSA_HEADER_SIZE);
paul718e3742002-12-13 20:15:29 +0000489
490 /* LSA Headers. */
491 while (length > 0)
492 {
493 lsa = (struct lsa_header *) STREAM_PNT (s);
494 ospf_lsa_header_dump (lsa);
495
paul9985f832005-02-09 15:51:56 +0000496 stream_forward_getp (s, OSPF_LSA_HEADER_SIZE);
paul718e3742002-12-13 20:15:29 +0000497 length -= OSPF_LSA_HEADER_SIZE;
498 }
499}
500
paul4dadc292005-05-06 21:37:42 +0000501static void
paul718e3742002-12-13 20:15:29 +0000502ospf_packet_db_desc_dump (struct stream *s, u_int16_t length)
503{
504 struct ospf_db_desc *dd;
505 char dd_flags[8];
506
507 u_int32_t gp;
508
509 gp = stream_get_getp (s);
510 dd = (struct ospf_db_desc *) STREAM_PNT (s);
511
ajs60925302004-12-08 17:45:02 +0000512 zlog_debug ("Database Description");
513 zlog_debug (" Interface MTU %d", ntohs (dd->mtu));
514 zlog_debug (" Options %d (%s)", dd->options,
paul718e3742002-12-13 20:15:29 +0000515 ospf_options_dump (dd->options));
ajs60925302004-12-08 17:45:02 +0000516 zlog_debug (" Flags %d (%s)", dd->flags,
paul718e3742002-12-13 20:15:29 +0000517 ospf_dd_flags_dump (dd->flags, dd_flags, sizeof dd_flags));
ajs60925302004-12-08 17:45:02 +0000518 zlog_debug (" Sequence Number 0x%08lx", (u_long)ntohl (dd->dd_seqnum));
paul718e3742002-12-13 20:15:29 +0000519
520 length -= OSPF_HEADER_SIZE + OSPF_DB_DESC_MIN_SIZE;
521
paul9985f832005-02-09 15:51:56 +0000522 stream_forward_getp (s, OSPF_DB_DESC_MIN_SIZE);
paul718e3742002-12-13 20:15:29 +0000523
524 ospf_lsa_header_list_dump (s, length);
525
526 stream_set_getp (s, gp);
527}
528
paul4dadc292005-05-06 21:37:42 +0000529static void
paul718e3742002-12-13 20:15:29 +0000530ospf_packet_ls_req_dump (struct stream *s, u_int16_t length)
531{
532 u_int32_t sp;
533 u_int32_t ls_type;
534 struct in_addr ls_id;
535 struct in_addr adv_router;
536
537 sp = stream_get_getp (s);
538
539 length -= OSPF_HEADER_SIZE;
540
ajs60925302004-12-08 17:45:02 +0000541 zlog_debug ("Link State Request");
542 zlog_debug (" # Requests %d", length / 12);
paul718e3742002-12-13 20:15:29 +0000543
544 for (; length > 0; length -= 12)
545 {
546 ls_type = stream_getl (s);
547 ls_id.s_addr = stream_get_ipv4 (s);
548 adv_router.s_addr = stream_get_ipv4 (s);
549
ajs60925302004-12-08 17:45:02 +0000550 zlog_debug (" LS type %d", ls_type);
551 zlog_debug (" Link State ID %s", inet_ntoa (ls_id));
552 zlog_debug (" Advertising Router %s",
paul718e3742002-12-13 20:15:29 +0000553 inet_ntoa (adv_router));
554 }
555
556 stream_set_getp (s, sp);
557}
558
paul4dadc292005-05-06 21:37:42 +0000559static void
paul718e3742002-12-13 20:15:29 +0000560ospf_packet_ls_upd_dump (struct stream *s, u_int16_t length)
561{
562 u_int32_t sp;
563 struct lsa_header *lsa;
564 int lsa_len;
565 u_int32_t count;
566
567 length -= OSPF_HEADER_SIZE;
568
569 sp = stream_get_getp (s);
570
571 count = stream_getl (s);
572 length -= 4;
573
ajs60925302004-12-08 17:45:02 +0000574 zlog_debug ("Link State Update");
575 zlog_debug (" # LSAs %d", count);
paul718e3742002-12-13 20:15:29 +0000576
577 while (length > 0 && count > 0)
578 {
579 if (length < OSPF_HEADER_SIZE || length % 4 != 0)
580 {
ajs60925302004-12-08 17:45:02 +0000581 zlog_debug (" Remaining %d bytes; Incorrect length.", length);
paul718e3742002-12-13 20:15:29 +0000582 break;
583 }
584
585 lsa = (struct lsa_header *) STREAM_PNT (s);
586 lsa_len = ntohs (lsa->length);
587 ospf_lsa_header_dump (lsa);
588
589 switch (lsa->type)
590 {
591 case OSPF_ROUTER_LSA:
592 ospf_router_lsa_dump (s, length);
593 break;
594 case OSPF_NETWORK_LSA:
595 ospf_network_lsa_dump (s, length);
596 break;
597 case OSPF_SUMMARY_LSA:
598 case OSPF_ASBR_SUMMARY_LSA:
599 ospf_summary_lsa_dump (s, length);
600 break;
601 case OSPF_AS_EXTERNAL_LSA:
602 ospf_as_external_lsa_dump (s, length);
603 break;
paul718e3742002-12-13 20:15:29 +0000604 case OSPF_AS_NSSA_LSA:
pauld4a53d52003-07-12 21:30:57 +0000605 ospf_as_external_lsa_dump (s, length);
paul718e3742002-12-13 20:15:29 +0000606 break;
paul718e3742002-12-13 20:15:29 +0000607#ifdef HAVE_OPAQUE_LSA
608 case OSPF_OPAQUE_LINK_LSA:
609 case OSPF_OPAQUE_AREA_LSA:
610 case OSPF_OPAQUE_AS_LSA:
611 ospf_opaque_lsa_dump (s, length);
612 break;
613#endif /* HAVE_OPAQUE_LSA */
614 default:
615 break;
616 }
617
paul9985f832005-02-09 15:51:56 +0000618 stream_forward_getp (s, lsa_len);
paul718e3742002-12-13 20:15:29 +0000619 length -= lsa_len;
620 count--;
621 }
622
623 stream_set_getp (s, sp);
624}
625
paul4dadc292005-05-06 21:37:42 +0000626static void
paul718e3742002-12-13 20:15:29 +0000627ospf_packet_ls_ack_dump (struct stream *s, u_int16_t length)
628{
629 u_int32_t sp;
630
631 length -= OSPF_HEADER_SIZE;
632 sp = stream_get_getp (s);
633
ajs60925302004-12-08 17:45:02 +0000634 zlog_debug ("Link State Acknowledgment");
paul718e3742002-12-13 20:15:29 +0000635 ospf_lsa_header_list_dump (s, length);
636
637 stream_set_getp (s, sp);
638}
639
paul6b333612004-10-11 10:11:25 +0000640/* Expects header to be in host order */
paul718e3742002-12-13 20:15:29 +0000641void
paul6b333612004-10-11 10:11:25 +0000642ospf_ip_header_dump (struct ip *iph)
paul718e3742002-12-13 20:15:29 +0000643{
paul718e3742002-12-13 20:15:29 +0000644 /* IP Header dump. */
ajs60925302004-12-08 17:45:02 +0000645 zlog_debug ("ip_v %d", iph->ip_v);
646 zlog_debug ("ip_hl %d", iph->ip_hl);
647 zlog_debug ("ip_tos %d", iph->ip_tos);
648 zlog_debug ("ip_len %d", iph->ip_len);
649 zlog_debug ("ip_id %u", (u_int32_t) iph->ip_id);
650 zlog_debug ("ip_off %u", (u_int32_t) iph->ip_off);
651 zlog_debug ("ip_ttl %d", iph->ip_ttl);
652 zlog_debug ("ip_p %d", iph->ip_p);
653 zlog_debug ("ip_sum 0x%x", (u_int32_t) iph->ip_sum);
654 zlog_debug ("ip_src %s", inet_ntoa (iph->ip_src));
655 zlog_debug ("ip_dst %s", inet_ntoa (iph->ip_dst));
paul718e3742002-12-13 20:15:29 +0000656}
657
paul4dadc292005-05-06 21:37:42 +0000658static void
paul718e3742002-12-13 20:15:29 +0000659ospf_header_dump (struct ospf_header *ospfh)
660{
661 char buf[9];
662
ajs60925302004-12-08 17:45:02 +0000663 zlog_debug ("Header");
664 zlog_debug (" Version %d", ospfh->version);
665 zlog_debug (" Type %d (%s)", ospfh->type,
paul718e3742002-12-13 20:15:29 +0000666 ospf_packet_type_str[ospfh->type]);
ajs60925302004-12-08 17:45:02 +0000667 zlog_debug (" Packet Len %d", ntohs (ospfh->length));
668 zlog_debug (" Router ID %s", inet_ntoa (ospfh->router_id));
669 zlog_debug (" Area ID %s", inet_ntoa (ospfh->area_id));
670 zlog_debug (" Checksum 0x%x", ntohs (ospfh->checksum));
671 zlog_debug (" AuType %d", ntohs (ospfh->auth_type));
paul718e3742002-12-13 20:15:29 +0000672
673 switch (ntohs (ospfh->auth_type))
674 {
675 case OSPF_AUTH_NULL:
676 break;
677 case OSPF_AUTH_SIMPLE:
678 memset (buf, 0, 9);
hassoc9e52be2004-09-26 16:09:34 +0000679 strncpy (buf, (char *) ospfh->u.auth_data, 8);
ajs60925302004-12-08 17:45:02 +0000680 zlog_debug (" Simple Password %s", buf);
paul718e3742002-12-13 20:15:29 +0000681 break;
682 case OSPF_AUTH_CRYPTOGRAPHIC:
ajs60925302004-12-08 17:45:02 +0000683 zlog_debug (" Cryptographic Authentication");
684 zlog_debug (" Key ID %d", ospfh->u.crypt.key_id);
685 zlog_debug (" Auth Data Len %d", ospfh->u.crypt.auth_data_len);
686 zlog_debug (" Sequence number %ld",
paul718e3742002-12-13 20:15:29 +0000687 (u_long)ntohl (ospfh->u.crypt.crypt_seqnum));
688 break;
689 default:
ajs60925302004-12-08 17:45:02 +0000690 zlog_debug ("* This is not supported authentication type");
paul718e3742002-12-13 20:15:29 +0000691 break;
692 }
693
694}
695
696void
697ospf_packet_dump (struct stream *s)
698{
699 struct ospf_header *ospfh;
700 unsigned long gp;
701
702 /* Preserve pointer. */
703 gp = stream_get_getp (s);
704
705 /* OSPF Header dump. */
706 ospfh = (struct ospf_header *) STREAM_PNT (s);
707
708 /* Until detail flag is set, return. */
709 if (!(term_debug_ospf_packet[ospfh->type - 1] & OSPF_DEBUG_DETAIL))
710 return;
711
712 /* Show OSPF header detail. */
713 ospf_header_dump (ospfh);
paul9985f832005-02-09 15:51:56 +0000714 stream_forward_getp (s, OSPF_HEADER_SIZE);
paul718e3742002-12-13 20:15:29 +0000715
716 switch (ospfh->type)
717 {
718 case OSPF_MSG_HELLO:
719 ospf_packet_hello_dump (s, ntohs (ospfh->length));
720 break;
721 case OSPF_MSG_DB_DESC:
722 ospf_packet_db_desc_dump (s, ntohs (ospfh->length));
723 break;
724 case OSPF_MSG_LS_REQ:
725 ospf_packet_ls_req_dump (s, ntohs (ospfh->length));
726 break;
727 case OSPF_MSG_LS_UPD:
728 ospf_packet_ls_upd_dump (s, ntohs (ospfh->length));
729 break;
730 case OSPF_MSG_LS_ACK:
731 ospf_packet_ls_ack_dump (s, ntohs (ospfh->length));
732 break;
733 default:
734 break;
735 }
736
737 stream_set_getp (s, gp);
738}
739
740
741/*
742 [no] debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)
743 [send|recv [detail]]
744*/
745DEFUN (debug_ospf_packet,
746 debug_ospf_packet_all_cmd,
747 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
748 DEBUG_STR
749 OSPF_STR
750 "OSPF packets\n"
751 "OSPF Hello\n"
752 "OSPF Database Description\n"
753 "OSPF Link State Request\n"
754 "OSPF Link State Update\n"
755 "OSPF Link State Acknowledgment\n"
756 "OSPF all packets\n")
757{
758 int type = 0;
759 int flag = 0;
760 int i;
761
762 assert (argc > 0);
763
764 /* Check packet type. */
765 if (strncmp (argv[0], "h", 1) == 0)
766 type = OSPF_DEBUG_HELLO;
767 else if (strncmp (argv[0], "d", 1) == 0)
768 type = OSPF_DEBUG_DB_DESC;
769 else if (strncmp (argv[0], "ls-r", 4) == 0)
770 type = OSPF_DEBUG_LS_REQ;
771 else if (strncmp (argv[0], "ls-u", 4) == 0)
772 type = OSPF_DEBUG_LS_UPD;
773 else if (strncmp (argv[0], "ls-a", 4) == 0)
774 type = OSPF_DEBUG_LS_ACK;
775 else if (strncmp (argv[0], "a", 1) == 0)
776 type = OSPF_DEBUG_ALL;
777
778 /* Default, both send and recv. */
779 if (argc == 1)
780 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV;
781
782 /* send or recv. */
783 if (argc >= 2)
784 {
785 if (strncmp (argv[1], "s", 1) == 0)
786 flag = OSPF_DEBUG_SEND;
787 else if (strncmp (argv[1], "r", 1) == 0)
788 flag = OSPF_DEBUG_RECV;
789 else if (strncmp (argv[1], "d", 1) == 0)
790 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
791 }
792
793 /* detail. */
794 if (argc == 3)
795 if (strncmp (argv[2], "d", 1) == 0)
796 flag |= OSPF_DEBUG_DETAIL;
797
798 for (i = 0; i < 5; i++)
799 if (type & (0x01 << i))
800 {
801 if (vty->node == CONFIG_NODE)
802 DEBUG_PACKET_ON (i, flag);
803 else
804 TERM_DEBUG_PACKET_ON (i, flag);
805 }
806
807 return CMD_SUCCESS;
808}
809
810ALIAS (debug_ospf_packet,
811 debug_ospf_packet_send_recv_cmd,
812 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
813 "Debugging functions\n"
814 "OSPF information\n"
815 "OSPF packets\n"
816 "OSPF Hello\n"
817 "OSPF Database Description\n"
818 "OSPF Link State Request\n"
819 "OSPF Link State Update\n"
820 "OSPF Link State Acknowledgment\n"
821 "OSPF all packets\n"
822 "Packet sent\n"
823 "Packet received\n"
824 "Detail information\n")
825
826ALIAS (debug_ospf_packet,
827 debug_ospf_packet_send_recv_detail_cmd,
828 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
829 "Debugging functions\n"
830 "OSPF information\n"
831 "OSPF packets\n"
832 "OSPF Hello\n"
833 "OSPF Database Description\n"
834 "OSPF Link State Request\n"
835 "OSPF Link State Update\n"
836 "OSPF Link State Acknowledgment\n"
837 "OSPF all packets\n"
838 "Packet sent\n"
839 "Packet received\n"
840 "Detail Information\n")
841
842
843DEFUN (no_debug_ospf_packet,
844 no_debug_ospf_packet_all_cmd,
845 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
846 NO_STR
847 DEBUG_STR
848 OSPF_STR
849 "OSPF packets\n"
850 "OSPF Hello\n"
851 "OSPF Database Description\n"
852 "OSPF Link State Request\n"
853 "OSPF Link State Update\n"
854 "OSPF Link State Acknowledgment\n"
855 "OSPF all packets\n")
856{
857 int type = 0;
858 int flag = 0;
859 int i;
860
861 assert (argc > 0);
862
863 /* Check packet type. */
864 if (strncmp (argv[0], "h", 1) == 0)
865 type = OSPF_DEBUG_HELLO;
866 else if (strncmp (argv[0], "d", 1) == 0)
867 type = OSPF_DEBUG_DB_DESC;
868 else if (strncmp (argv[0], "ls-r", 4) == 0)
869 type = OSPF_DEBUG_LS_REQ;
870 else if (strncmp (argv[0], "ls-u", 4) == 0)
871 type = OSPF_DEBUG_LS_UPD;
872 else if (strncmp (argv[0], "ls-a", 4) == 0)
873 type = OSPF_DEBUG_LS_ACK;
874 else if (strncmp (argv[0], "a", 1) == 0)
875 type = OSPF_DEBUG_ALL;
876
877 /* Default, both send and recv. */
878 if (argc == 1)
879 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL ;
880
881 /* send or recv. */
882 if (argc == 2)
883 {
884 if (strncmp (argv[1], "s", 1) == 0)
885 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_DETAIL;
886 else if (strncmp (argv[1], "r", 1) == 0)
887 flag = OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
888 else if (strncmp (argv[1], "d", 1) == 0)
889 flag = OSPF_DEBUG_DETAIL;
890 }
891
892 /* detail. */
893 if (argc == 3)
894 if (strncmp (argv[2], "d", 1) == 0)
895 flag = OSPF_DEBUG_DETAIL;
896
897 for (i = 0; i < 5; i++)
898 if (type & (0x01 << i))
899 {
900 if (vty->node == CONFIG_NODE)
901 DEBUG_PACKET_OFF (i, flag);
902 else
903 TERM_DEBUG_PACKET_OFF (i, flag);
904 }
905
906#ifdef DEBUG
jardin6638c1a2005-10-01 00:08:54 +0000907 /*
paul718e3742002-12-13 20:15:29 +0000908 for (i = 0; i < 5; i++)
ajs60925302004-12-08 17:45:02 +0000909 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
jardin6638c1a2005-10-01 00:08:54 +0000910 */
paul718e3742002-12-13 20:15:29 +0000911#endif /* DEBUG */
912
913 return CMD_SUCCESS;
914}
915
916ALIAS (no_debug_ospf_packet,
917 no_debug_ospf_packet_send_recv_cmd,
918 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
919 NO_STR
920 "Debugging functions\n"
921 "OSPF information\n"
922 "OSPF packets\n"
923 "OSPF Hello\n"
924 "OSPF Database Description\n"
925 "OSPF Link State Request\n"
926 "OSPF Link State Update\n"
927 "OSPF Link State Acknowledgment\n"
928 "OSPF all packets\n"
929 "Packet sent\n"
930 "Packet received\n"
931 "Detail Information\n")
932
933ALIAS (no_debug_ospf_packet,
934 no_debug_ospf_packet_send_recv_detail_cmd,
935 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
936 NO_STR
937 "Debugging functions\n"
938 "OSPF information\n"
939 "OSPF packets\n"
940 "OSPF Hello\n"
941 "OSPF Database Description\n"
942 "OSPF Link State Request\n"
943 "OSPF Link State Update\n"
944 "OSPF Link State Acknowledgment\n"
945 "OSPF all packets\n"
946 "Packet sent\n"
947 "Packet received\n"
948 "Detail Information\n")
949
950
951DEFUN (debug_ospf_ism,
952 debug_ospf_ism_cmd,
953 "debug ospf ism",
954 DEBUG_STR
955 OSPF_STR
956 "OSPF Interface State Machine\n")
957{
958 if (vty->node == CONFIG_NODE)
959 {
960 if (argc == 0)
961 DEBUG_ON (ism, ISM);
962 else if (argc == 1)
963 {
964 if (strncmp (argv[0], "s", 1) == 0)
965 DEBUG_ON (ism, ISM_STATUS);
966 else if (strncmp (argv[0], "e", 1) == 0)
967 DEBUG_ON (ism, ISM_EVENTS);
968 else if (strncmp (argv[0], "t", 1) == 0)
969 DEBUG_ON (ism, ISM_TIMERS);
970 }
971
972 return CMD_SUCCESS;
973 }
974
975 /* ENABLE_NODE. */
976 if (argc == 0)
977 TERM_DEBUG_ON (ism, ISM);
978 else if (argc == 1)
979 {
980 if (strncmp (argv[0], "s", 1) == 0)
981 TERM_DEBUG_ON (ism, ISM_STATUS);
982 else if (strncmp (argv[0], "e", 1) == 0)
983 TERM_DEBUG_ON (ism, ISM_EVENTS);
984 else if (strncmp (argv[0], "t", 1) == 0)
985 TERM_DEBUG_ON (ism, ISM_TIMERS);
986 }
987
988 return CMD_SUCCESS;
989}
990
991ALIAS (debug_ospf_ism,
992 debug_ospf_ism_sub_cmd,
993 "debug ospf ism (status|events|timers)",
994 DEBUG_STR
995 OSPF_STR
996 "OSPF Interface State Machine\n"
997 "ISM Status Information\n"
998 "ISM Event Information\n"
999 "ISM TImer Information\n")
1000
1001DEFUN (no_debug_ospf_ism,
1002 no_debug_ospf_ism_cmd,
1003 "no debug ospf ism",
1004 NO_STR
1005 DEBUG_STR
1006 OSPF_STR
1007 "OSPF Interface State Machine")
1008{
1009 if (vty->node == CONFIG_NODE)
1010 {
1011 if (argc == 0)
1012 DEBUG_OFF (ism, ISM);
1013 else if (argc == 1)
1014 {
1015 if (strncmp (argv[0], "s", 1) == 0)
1016 DEBUG_OFF (ism, ISM_STATUS);
1017 else if (strncmp (argv[0], "e", 1) == 0)
1018 DEBUG_OFF (ism, ISM_EVENTS);
1019 else if (strncmp (argv[0], "t", 1) == 0)
1020 DEBUG_OFF (ism, ISM_TIMERS);
1021 }
1022 return CMD_SUCCESS;
1023 }
1024
1025 /* ENABLE_NODE. */
1026 if (argc == 0)
1027 TERM_DEBUG_OFF (ism, ISM);
1028 else if (argc == 1)
1029 {
1030 if (strncmp (argv[0], "s", 1) == 0)
1031 TERM_DEBUG_OFF (ism, ISM_STATUS);
1032 else if (strncmp (argv[0], "e", 1) == 0)
1033 TERM_DEBUG_OFF (ism, ISM_EVENTS);
1034 else if (strncmp (argv[0], "t", 1) == 0)
1035 TERM_DEBUG_OFF (ism, ISM_TIMERS);
1036 }
1037
1038 return CMD_SUCCESS;
1039}
1040
1041ALIAS (no_debug_ospf_ism,
1042 no_debug_ospf_ism_sub_cmd,
1043 "no debug ospf ism (status|events|timers)",
1044 NO_STR
1045 "Debugging functions\n"
1046 "OSPF information\n"
1047 "OSPF Interface State Machine\n"
1048 "ISM Status Information\n"
1049 "ISM Event Information\n"
1050 "ISM Timer Information\n")
1051
1052
1053DEFUN (debug_ospf_nsm,
1054 debug_ospf_nsm_cmd,
1055 "debug ospf nsm",
1056 DEBUG_STR
1057 OSPF_STR
1058 "OSPF Neighbor State Machine\n")
1059{
1060 if (vty->node == CONFIG_NODE)
1061 {
1062 if (argc == 0)
1063 DEBUG_ON (nsm, NSM);
1064 else if (argc == 1)
1065 {
1066 if (strncmp (argv[0], "s", 1) == 0)
1067 DEBUG_ON (nsm, NSM_STATUS);
1068 else if (strncmp (argv[0], "e", 1) == 0)
1069 DEBUG_ON (nsm, NSM_EVENTS);
1070 else if (strncmp (argv[0], "t", 1) == 0)
1071 DEBUG_ON (nsm, NSM_TIMERS);
1072 }
1073
1074 return CMD_SUCCESS;
1075 }
1076
1077 /* ENABLE_NODE. */
1078 if (argc == 0)
1079 TERM_DEBUG_ON (nsm, NSM);
1080 else if (argc == 1)
1081 {
1082 if (strncmp (argv[0], "s", 1) == 0)
1083 TERM_DEBUG_ON (nsm, NSM_STATUS);
1084 else if (strncmp (argv[0], "e", 1) == 0)
1085 TERM_DEBUG_ON (nsm, NSM_EVENTS);
1086 else if (strncmp (argv[0], "t", 1) == 0)
1087 TERM_DEBUG_ON (nsm, NSM_TIMERS);
1088 }
1089
1090 return CMD_SUCCESS;
1091}
1092
1093ALIAS (debug_ospf_nsm,
1094 debug_ospf_nsm_sub_cmd,
1095 "debug ospf nsm (status|events|timers)",
1096 DEBUG_STR
1097 OSPF_STR
1098 "OSPF Neighbor State Machine\n"
1099 "NSM Status Information\n"
1100 "NSM Event Information\n"
1101 "NSM Timer Information\n")
1102
1103DEFUN (no_debug_ospf_nsm,
1104 no_debug_ospf_nsm_cmd,
1105 "no debug ospf nsm",
1106 NO_STR
1107 DEBUG_STR
1108 OSPF_STR
1109 "OSPF Neighbor State Machine")
1110{
1111 if (vty->node == CONFIG_NODE)
1112 {
1113 if (argc == 0)
1114 DEBUG_OFF (nsm, NSM);
1115 else if (argc == 1)
1116 {
1117 if (strncmp (argv[0], "s", 1) == 0)
1118 DEBUG_OFF (nsm, NSM_STATUS);
1119 else if (strncmp (argv[0], "e", 1) == 0)
1120 DEBUG_OFF (nsm, NSM_EVENTS);
1121 else if (strncmp (argv[0], "t", 1) == 0)
1122 DEBUG_OFF (nsm, NSM_TIMERS);
1123 }
1124
1125 return CMD_SUCCESS;
1126 }
1127
1128 /* ENABLE_NODE. */
1129 if (argc == 0)
1130 TERM_DEBUG_OFF (nsm, NSM);
1131 else if (argc == 1)
1132 {
1133 if (strncmp (argv[0], "s", 1) == 0)
1134 TERM_DEBUG_OFF (nsm, NSM_STATUS);
1135 else if (strncmp (argv[0], "e", 1) == 0)
1136 TERM_DEBUG_OFF (nsm, NSM_EVENTS);
1137 else if (strncmp (argv[0], "t", 1) == 0)
1138 TERM_DEBUG_OFF (nsm, NSM_TIMERS);
1139 }
1140
1141 return CMD_SUCCESS;
1142}
1143
1144ALIAS (no_debug_ospf_nsm,
1145 no_debug_ospf_nsm_sub_cmd,
1146 "no debug ospf nsm (status|events|timers)",
1147 NO_STR
1148 "Debugging functions\n"
1149 "OSPF information\n"
1150 "OSPF Interface State Machine\n"
1151 "NSM Status Information\n"
1152 "NSM Event Information\n"
1153 "NSM Timer Information\n")
1154
1155
1156DEFUN (debug_ospf_lsa,
1157 debug_ospf_lsa_cmd,
1158 "debug ospf lsa",
1159 DEBUG_STR
1160 OSPF_STR
1161 "OSPF Link State Advertisement\n")
1162{
1163 if (vty->node == CONFIG_NODE)
1164 {
1165 if (argc == 0)
1166 DEBUG_ON (lsa, LSA);
1167 else if (argc == 1)
1168 {
1169 if (strncmp (argv[0], "g", 1) == 0)
1170 DEBUG_ON (lsa, LSA_GENERATE);
1171 else if (strncmp (argv[0], "f", 1) == 0)
1172 DEBUG_ON (lsa, LSA_FLOODING);
1173 else if (strncmp (argv[0], "i", 1) == 0)
1174 DEBUG_ON (lsa, LSA_INSTALL);
1175 else if (strncmp (argv[0], "r", 1) == 0)
1176 DEBUG_ON (lsa, LSA_REFRESH);
1177 }
1178
1179 return CMD_SUCCESS;
1180 }
1181
1182 /* ENABLE_NODE. */
1183 if (argc == 0)
1184 TERM_DEBUG_ON (lsa, LSA);
1185 else if (argc == 1)
1186 {
1187 if (strncmp (argv[0], "g", 1) == 0)
1188 TERM_DEBUG_ON (lsa, LSA_GENERATE);
1189 else if (strncmp (argv[0], "f", 1) == 0)
1190 TERM_DEBUG_ON (lsa, LSA_FLOODING);
1191 else if (strncmp (argv[0], "i", 1) == 0)
1192 TERM_DEBUG_ON (lsa, LSA_INSTALL);
1193 else if (strncmp (argv[0], "r", 1) == 0)
1194 TERM_DEBUG_ON (lsa, LSA_REFRESH);
1195 }
1196
1197 return CMD_SUCCESS;
1198}
1199
1200ALIAS (debug_ospf_lsa,
1201 debug_ospf_lsa_sub_cmd,
1202 "debug ospf lsa (generate|flooding|install|refresh)",
1203 DEBUG_STR
1204 OSPF_STR
1205 "OSPF Link State Advertisement\n"
1206 "LSA Generation\n"
1207 "LSA Flooding\n"
1208 "LSA Install/Delete\n"
1209 "LSA Refresh\n")
1210
1211DEFUN (no_debug_ospf_lsa,
1212 no_debug_ospf_lsa_cmd,
1213 "no debug ospf lsa",
1214 NO_STR
1215 DEBUG_STR
1216 OSPF_STR
1217 "OSPF Link State Advertisement\n")
1218{
1219 if (vty->node == CONFIG_NODE)
1220 {
1221 if (argc == 0)
1222 DEBUG_OFF (lsa, LSA);
1223 else if (argc == 1)
1224 {
1225 if (strncmp (argv[0], "g", 1) == 0)
1226 DEBUG_OFF (lsa, LSA_GENERATE);
1227 else if (strncmp (argv[0], "f", 1) == 0)
1228 DEBUG_OFF (lsa, LSA_FLOODING);
1229 else if (strncmp (argv[0], "i", 1) == 0)
1230 DEBUG_OFF (lsa, LSA_INSTALL);
1231 else if (strncmp (argv[0], "r", 1) == 0)
1232 DEBUG_OFF (lsa, LSA_REFRESH);
1233 }
1234
1235 return CMD_SUCCESS;
1236 }
1237
1238 /* ENABLE_NODE. */
1239 if (argc == 0)
1240 TERM_DEBUG_OFF (lsa, LSA);
1241 else if (argc == 1)
1242 {
1243 if (strncmp (argv[0], "g", 1) == 0)
1244 TERM_DEBUG_OFF (lsa, LSA_GENERATE);
1245 else if (strncmp (argv[0], "f", 1) == 0)
1246 TERM_DEBUG_OFF (lsa, LSA_FLOODING);
1247 else if (strncmp (argv[0], "i", 1) == 0)
1248 TERM_DEBUG_OFF (lsa, LSA_INSTALL);
1249 else if (strncmp (argv[0], "r", 1) == 0)
1250 TERM_DEBUG_OFF (lsa, LSA_REFRESH);
1251 }
1252
1253 return CMD_SUCCESS;
1254}
1255
1256ALIAS (no_debug_ospf_lsa,
1257 no_debug_ospf_lsa_sub_cmd,
1258 "no debug ospf lsa (generate|flooding|install|refresh)",
1259 NO_STR
1260 DEBUG_STR
1261 OSPF_STR
1262 "OSPF Link State Advertisement\n"
1263 "LSA Generation\n"
1264 "LSA Flooding\n"
1265 "LSA Install/Delete\n"
1266 "LSA Refres\n")
1267
1268
1269DEFUN (debug_ospf_zebra,
1270 debug_ospf_zebra_cmd,
1271 "debug ospf zebra",
1272 DEBUG_STR
1273 OSPF_STR
1274 "OSPF Zebra information\n")
1275{
1276 if (vty->node == CONFIG_NODE)
1277 {
1278 if (argc == 0)
1279 DEBUG_ON (zebra, ZEBRA);
1280 else if (argc == 1)
1281 {
1282 if (strncmp (argv[0], "i", 1) == 0)
1283 DEBUG_ON (zebra, ZEBRA_INTERFACE);
1284 else if (strncmp (argv[0], "r", 1) == 0)
1285 DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
1286 }
1287
1288 return CMD_SUCCESS;
1289 }
1290
1291 /* ENABLE_NODE. */
1292 if (argc == 0)
1293 TERM_DEBUG_ON (zebra, ZEBRA);
1294 else if (argc == 1)
1295 {
1296 if (strncmp (argv[0], "i", 1) == 0)
1297 TERM_DEBUG_ON (zebra, ZEBRA_INTERFACE);
1298 else if (strncmp (argv[0], "r", 1) == 0)
1299 TERM_DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
1300 }
1301
1302 return CMD_SUCCESS;
1303}
1304
1305ALIAS (debug_ospf_zebra,
1306 debug_ospf_zebra_sub_cmd,
1307 "debug ospf zebra (interface|redistribute)",
1308 DEBUG_STR
1309 OSPF_STR
1310 "OSPF Zebra information\n"
1311 "Zebra interface\n"
1312 "Zebra redistribute\n")
1313
1314DEFUN (no_debug_ospf_zebra,
1315 no_debug_ospf_zebra_cmd,
1316 "no debug ospf zebra",
1317 NO_STR
1318 DEBUG_STR
1319 OSPF_STR
1320 "OSPF Zebra information\n")
1321{
1322 if (vty->node == CONFIG_NODE)
1323 {
1324 if (argc == 0)
1325 DEBUG_OFF (zebra, ZEBRA);
1326 else if (argc == 1)
1327 {
1328 if (strncmp (argv[0], "i", 1) == 0)
1329 DEBUG_OFF (zebra, ZEBRA_INTERFACE);
1330 else if (strncmp (argv[0], "r", 1) == 0)
1331 DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
1332 }
1333
1334 return CMD_SUCCESS;
1335 }
1336
1337 /* ENABLE_NODE. */
1338 if (argc == 0)
1339 TERM_DEBUG_OFF (zebra, ZEBRA);
1340 else if (argc == 1)
1341 {
1342 if (strncmp (argv[0], "i", 1) == 0)
1343 TERM_DEBUG_OFF (zebra, ZEBRA_INTERFACE);
1344 else if (strncmp (argv[0], "r", 1) == 0)
1345 TERM_DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
1346 }
1347
1348 return CMD_SUCCESS;
1349}
1350
1351ALIAS (no_debug_ospf_zebra,
1352 no_debug_ospf_zebra_sub_cmd,
1353 "no debug ospf zebra (interface|redistribute)",
1354 NO_STR
1355 DEBUG_STR
1356 OSPF_STR
1357 "OSPF Zebra information\n"
1358 "Zebra interface\n"
1359 "Zebra redistribute\n")
1360
1361DEFUN (debug_ospf_event,
1362 debug_ospf_event_cmd,
1363 "debug ospf event",
1364 DEBUG_STR
1365 OSPF_STR
1366 "OSPF event information\n")
1367{
1368 if (vty->node == CONFIG_NODE)
1369 CONF_DEBUG_ON (event, EVENT);
1370 TERM_DEBUG_ON (event, EVENT);
1371 return CMD_SUCCESS;
1372}
1373
1374DEFUN (no_debug_ospf_event,
1375 no_debug_ospf_event_cmd,
1376 "no debug ospf event",
1377 NO_STR
1378 DEBUG_STR
1379 OSPF_STR
1380 "OSPF event information\n")
1381{
1382 if (vty->node == CONFIG_NODE)
1383 CONF_DEBUG_OFF (event, EVENT);
1384 TERM_DEBUG_OFF (event, EVENT);
1385 return CMD_SUCCESS;
1386}
1387
1388DEFUN (debug_ospf_nssa,
1389 debug_ospf_nssa_cmd,
1390 "debug ospf nssa",
1391 DEBUG_STR
1392 OSPF_STR
1393 "OSPF nssa information\n")
1394{
1395 if (vty->node == CONFIG_NODE)
1396 CONF_DEBUG_ON (nssa, NSSA);
1397 TERM_DEBUG_ON (nssa, NSSA);
1398 return CMD_SUCCESS;
1399}
1400
1401DEFUN (no_debug_ospf_nssa,
1402 no_debug_ospf_nssa_cmd,
1403 "no debug ospf nssa",
1404 NO_STR
1405 DEBUG_STR
1406 OSPF_STR
1407 "OSPF nssa information\n")
1408{
1409 if (vty->node == CONFIG_NODE)
1410 CONF_DEBUG_OFF (nssa, NSSA);
1411 TERM_DEBUG_OFF (nssa, NSSA);
1412 return CMD_SUCCESS;
1413}
1414
1415
1416DEFUN (show_debugging_ospf,
1417 show_debugging_ospf_cmd,
1418 "show debugging ospf",
1419 SHOW_STR
1420 DEBUG_STR
1421 OSPF_STR)
1422{
1423 int i;
1424
hassodf43a132004-08-31 12:04:33 +00001425 vty_out (vty, "OSPF debugging status:%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001426
ajsaca72fd2005-03-31 15:18:21 +00001427 /* Show debug status for events. */
1428 if (IS_DEBUG_OSPF(event,EVENT))
1429 vty_out (vty, " OSPF event debugging is on%s", VTY_NEWLINE);
1430
paul718e3742002-12-13 20:15:29 +00001431 /* Show debug status for ISM. */
1432 if (IS_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
1433 vty_out (vty, " OSPF ISM debugging is on%s", VTY_NEWLINE);
1434 else
1435 {
1436 if (IS_DEBUG_OSPF (ism, ISM_STATUS))
1437 vty_out (vty, " OSPF ISM status debugging is on%s", VTY_NEWLINE);
1438 if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
1439 vty_out (vty, " OSPF ISM event debugging is on%s", VTY_NEWLINE);
1440 if (IS_DEBUG_OSPF (ism, ISM_TIMERS))
1441 vty_out (vty, " OSPF ISM timer debugging is on%s", VTY_NEWLINE);
1442 }
1443
1444 /* Show debug status for NSM. */
1445 if (IS_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
1446 vty_out (vty, " OSPF NSM debugging is on%s", VTY_NEWLINE);
1447 else
1448 {
1449 if (IS_DEBUG_OSPF (nsm, NSM_STATUS))
1450 vty_out (vty, " OSPF NSM status debugging is on%s", VTY_NEWLINE);
1451 if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
1452 vty_out (vty, " OSPF NSM event debugging is on%s", VTY_NEWLINE);
1453 if (IS_DEBUG_OSPF (nsm, NSM_TIMERS))
1454 vty_out (vty, " OSPF NSM timer debugging is on%s", VTY_NEWLINE);
1455 }
1456
1457 /* Show debug status for OSPF Packets. */
1458 for (i = 0; i < 5; i++)
1459 if (IS_DEBUG_OSPF_PACKET (i, SEND) && IS_DEBUG_OSPF_PACKET (i, RECV))
1460 {
1461 vty_out (vty, " OSPF packet %s%s debugging is on%s",
1462 ospf_packet_type_str[i + 1],
1463 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1464 VTY_NEWLINE);
1465 }
1466 else
1467 {
1468 if (IS_DEBUG_OSPF_PACKET (i, SEND))
1469 vty_out (vty, " OSPF packet %s send%s debugging is on%s",
1470 ospf_packet_type_str[i + 1],
1471 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1472 VTY_NEWLINE);
1473 if (IS_DEBUG_OSPF_PACKET (i, RECV))
1474 vty_out (vty, " OSPF packet %s receive%s debugging is on%s",
1475 ospf_packet_type_str[i + 1],
1476 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1477 VTY_NEWLINE);
1478 }
1479
1480 /* Show debug status for OSPF LSAs. */
1481 if (IS_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
1482 vty_out (vty, " OSPF LSA debugging is on%s", VTY_NEWLINE);
1483 else
1484 {
1485 if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
1486 vty_out (vty, " OSPF LSA generation debugging is on%s", VTY_NEWLINE);
1487 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
1488 vty_out (vty, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE);
1489 if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
1490 vty_out (vty, " OSPF LSA install debugging is on%s", VTY_NEWLINE);
1491 if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
1492 vty_out (vty, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE);
1493 }
1494
1495 /* Show debug status for Zebra. */
1496 if (IS_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
1497 vty_out (vty, " OSPF Zebra debugging is on%s", VTY_NEWLINE);
1498 else
1499 {
1500 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
1501 vty_out (vty, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE);
1502 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
1503 vty_out (vty, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE);
1504 }
ajsaca72fd2005-03-31 15:18:21 +00001505
1506 /* Show debug status for NSSA. */
paulead687e2003-04-07 17:12:12 +00001507 if (IS_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
1508 vty_out (vty, " OSPF NSSA debugging is on%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001509
1510 return CMD_SUCCESS;
1511}
1512
1513/* Debug node. */
1514struct cmd_node debug_node =
1515{
1516 DEBUG_NODE,
hasso1d806282004-12-22 09:43:20 +00001517 "",
1518 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001519};
1520
paul4dadc292005-05-06 21:37:42 +00001521static int
paul718e3742002-12-13 20:15:29 +00001522config_write_debug (struct vty *vty)
1523{
1524 int write = 0;
1525 int i, r;
1526
hassoeb1ce602004-10-08 08:17:22 +00001527 const char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
1528 const char *detail_str[] = {"", " send", " recv", "", " detail",
paul718e3742002-12-13 20:15:29 +00001529 " send detail", " recv detail", " detail"};
1530
1531 /* debug ospf ism (status|events|timers). */
1532 if (IS_CONF_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
1533 vty_out (vty, "debug ospf ism%s", VTY_NEWLINE);
1534 else
1535 {
1536 if (IS_CONF_DEBUG_OSPF (ism, ISM_STATUS))
1537 vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE);
1538 if (IS_CONF_DEBUG_OSPF (ism, ISM_EVENTS))
1539 vty_out (vty, "debug ospf ism event%s", VTY_NEWLINE);
1540 if (IS_CONF_DEBUG_OSPF (ism, ISM_TIMERS))
1541 vty_out (vty, "debug ospf ism timer%s", VTY_NEWLINE);
1542 }
1543
1544 /* debug ospf nsm (status|events|timers). */
1545 if (IS_CONF_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
1546 vty_out (vty, "debug ospf nsm%s", VTY_NEWLINE);
1547 else
1548 {
1549 if (IS_CONF_DEBUG_OSPF (nsm, NSM_STATUS))
1550 vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE);
1551 if (IS_CONF_DEBUG_OSPF (nsm, NSM_EVENTS))
1552 vty_out (vty, "debug ospf nsm event%s", VTY_NEWLINE);
1553 if (IS_CONF_DEBUG_OSPF (nsm, NSM_TIMERS))
1554 vty_out (vty, "debug ospf nsm timer%s", VTY_NEWLINE);
1555 }
1556
1557 /* debug ospf lsa (generate|flooding|install|refresh). */
1558 if (IS_CONF_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
1559 vty_out (vty, "debug ospf lsa%s", VTY_NEWLINE);
1560 else
1561 {
1562 if (IS_CONF_DEBUG_OSPF (lsa, LSA_GENERATE))
1563 vty_out (vty, "debug ospf lsa generate%s", VTY_NEWLINE);
1564 if (IS_CONF_DEBUG_OSPF (lsa, LSA_FLOODING))
1565 vty_out (vty, "debug ospf lsa flooding%s", VTY_NEWLINE);
1566 if (IS_CONF_DEBUG_OSPF (lsa, LSA_INSTALL))
1567 vty_out (vty, "debug ospf lsa install%s", VTY_NEWLINE);
1568 if (IS_CONF_DEBUG_OSPF (lsa, LSA_REFRESH))
1569 vty_out (vty, "debug ospf lsa refresh%s", VTY_NEWLINE);
1570
1571 write = 1;
1572 }
1573
1574 /* debug ospf zebra (interface|redistribute). */
1575 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
1576 vty_out (vty, "debug ospf zebra%s", VTY_NEWLINE);
1577 else
1578 {
1579 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
1580 vty_out (vty, "debug ospf zebra interface%s", VTY_NEWLINE);
1581 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
1582 vty_out (vty, "debug ospf zebra redistribute%s", VTY_NEWLINE);
1583
1584 write = 1;
1585 }
1586
1587 /* debug ospf event. */
1588 if (IS_CONF_DEBUG_OSPF (event, EVENT) == OSPF_DEBUG_EVENT)
1589 {
1590 vty_out (vty, "debug ospf event%s", VTY_NEWLINE);
1591 write = 1;
1592 }
1593
1594 /* debug ospf nssa. */
1595 if (IS_CONF_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
1596 {
1597 vty_out (vty, "debug ospf nssa%s", VTY_NEWLINE);
1598 write = 1;
1599 }
1600
1601 /* debug ospf packet all detail. */
1602 r = OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL;
1603 for (i = 0; i < 5; i++)
1604 r &= conf_debug_ospf_packet[i] & (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL);
1605 if (r == (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL))
1606 {
1607 vty_out (vty, "debug ospf packet all detail%s", VTY_NEWLINE);
1608 return 1;
1609 }
1610
1611 /* debug ospf packet all. */
1612 r = OSPF_DEBUG_SEND_RECV;
1613 for (i = 0; i < 5; i++)
1614 r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV;
1615 if (r == OSPF_DEBUG_SEND_RECV)
1616 {
1617 vty_out (vty, "debug ospf packet all%s", VTY_NEWLINE);
1618 for (i = 0; i < 5; i++)
1619 if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL)
1620 vty_out (vty, "debug ospf packet %s detail%s",
1621 type_str[i],
1622 VTY_NEWLINE);
1623 return 1;
1624 }
1625
1626 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1627 (send|recv) (detail). */
1628 for (i = 0; i < 5; i++)
1629 {
1630 if (conf_debug_ospf_packet[i] == 0)
1631 continue;
1632
1633 vty_out (vty, "debug ospf packet %s%s%s",
1634 type_str[i], detail_str[conf_debug_ospf_packet[i]],
1635 VTY_NEWLINE);
1636 write = 1;
1637 }
1638
1639 return write;
1640}
1641
1642/* Initialize debug commands. */
1643void
1644debug_init ()
1645{
1646 install_node (&debug_node, config_write_debug);
1647
1648 install_element (ENABLE_NODE, &show_debugging_ospf_cmd);
1649 install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_detail_cmd);
1650 install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_cmd);
1651 install_element (ENABLE_NODE, &debug_ospf_packet_all_cmd);
1652 install_element (ENABLE_NODE, &debug_ospf_ism_sub_cmd);
1653 install_element (ENABLE_NODE, &debug_ospf_ism_cmd);
1654 install_element (ENABLE_NODE, &debug_ospf_nsm_sub_cmd);
1655 install_element (ENABLE_NODE, &debug_ospf_nsm_cmd);
1656 install_element (ENABLE_NODE, &debug_ospf_lsa_sub_cmd);
1657 install_element (ENABLE_NODE, &debug_ospf_lsa_cmd);
1658 install_element (ENABLE_NODE, &debug_ospf_zebra_sub_cmd);
1659 install_element (ENABLE_NODE, &debug_ospf_zebra_cmd);
1660 install_element (ENABLE_NODE, &debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001661 install_element (ENABLE_NODE, &debug_ospf_nssa_cmd);
paul718e3742002-12-13 20:15:29 +00001662 install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
1663 install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_cmd);
1664 install_element (ENABLE_NODE, &no_debug_ospf_packet_all_cmd);
1665 install_element (ENABLE_NODE, &no_debug_ospf_ism_sub_cmd);
1666 install_element (ENABLE_NODE, &no_debug_ospf_ism_cmd);
1667 install_element (ENABLE_NODE, &no_debug_ospf_nsm_sub_cmd);
1668 install_element (ENABLE_NODE, &no_debug_ospf_nsm_cmd);
1669 install_element (ENABLE_NODE, &no_debug_ospf_lsa_sub_cmd);
1670 install_element (ENABLE_NODE, &no_debug_ospf_lsa_cmd);
1671 install_element (ENABLE_NODE, &no_debug_ospf_zebra_sub_cmd);
1672 install_element (ENABLE_NODE, &no_debug_ospf_zebra_cmd);
1673 install_element (ENABLE_NODE, &no_debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001674 install_element (ENABLE_NODE, &no_debug_ospf_nssa_cmd);
paul718e3742002-12-13 20:15:29 +00001675
1676 install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_detail_cmd);
1677 install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_cmd);
1678 install_element (CONFIG_NODE, &debug_ospf_packet_all_cmd);
1679 install_element (CONFIG_NODE, &debug_ospf_ism_sub_cmd);
1680 install_element (CONFIG_NODE, &debug_ospf_ism_cmd);
1681 install_element (CONFIG_NODE, &debug_ospf_nsm_sub_cmd);
1682 install_element (CONFIG_NODE, &debug_ospf_nsm_cmd);
1683 install_element (CONFIG_NODE, &debug_ospf_lsa_sub_cmd);
1684 install_element (CONFIG_NODE, &debug_ospf_lsa_cmd);
1685 install_element (CONFIG_NODE, &debug_ospf_zebra_sub_cmd);
1686 install_element (CONFIG_NODE, &debug_ospf_zebra_cmd);
1687 install_element (CONFIG_NODE, &debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001688 install_element (CONFIG_NODE, &debug_ospf_nssa_cmd);
paul718e3742002-12-13 20:15:29 +00001689 install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
1690 install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_cmd);
1691 install_element (CONFIG_NODE, &no_debug_ospf_packet_all_cmd);
1692 install_element (CONFIG_NODE, &no_debug_ospf_ism_sub_cmd);
1693 install_element (CONFIG_NODE, &no_debug_ospf_ism_cmd);
1694 install_element (CONFIG_NODE, &no_debug_ospf_nsm_sub_cmd);
1695 install_element (CONFIG_NODE, &no_debug_ospf_nsm_cmd);
1696 install_element (CONFIG_NODE, &no_debug_ospf_lsa_sub_cmd);
1697 install_element (CONFIG_NODE, &no_debug_ospf_lsa_cmd);
1698 install_element (CONFIG_NODE, &no_debug_ospf_zebra_sub_cmd);
1699 install_element (CONFIG_NODE, &no_debug_ospf_zebra_cmd);
1700 install_element (CONFIG_NODE, &no_debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001701 install_element (CONFIG_NODE, &no_debug_ospf_nssa_cmd);
paul718e3742002-12-13 20:15:29 +00001702}