blob: 859e3bc972432649e840fd7ca6c93e84163025ba [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 {
paulea4ffc92005-10-21 20:04:41 +0000252 t->tv_sec += ms / 1000;
253 ms %= 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;
pauld24f6e22005-10-21 09:23:12 +0000300 if (!t)
301 return "inactive";
302
paulc8c15212005-11-04 12:31:39 +0000303 result = tv_sub (t->u.sands, recent_time);
pauld24f6e22005-10-21 09:23:12 +0000304 return ospf_timeval_dump (&result, buf, size);
305}
306
paul718e3742002-12-13 20:15:29 +0000307#define OSPF_OPTION_STR_MAXLEN 24
308
309char *
310ospf_options_dump (u_char options)
311{
312 static char buf[OSPF_OPTION_STR_MAXLEN];
313
314 snprintf (buf, OSPF_OPTION_STR_MAXLEN, "*|%s|%s|%s|%s|%s|%s|*",
315 (options & OSPF_OPTION_O) ? "O" : "-",
316 (options & OSPF_OPTION_DC) ? "DC" : "-",
317 (options & OSPF_OPTION_EA) ? "EA" : "-",
318 (options & OSPF_OPTION_NP) ? "N/P" : "-",
319 (options & OSPF_OPTION_MC) ? "MC" : "-",
320 (options & OSPF_OPTION_E) ? "E" : "-");
321
322 return buf;
323}
324
paul4dadc292005-05-06 21:37:42 +0000325static void
paul718e3742002-12-13 20:15:29 +0000326ospf_packet_hello_dump (struct stream *s, u_int16_t length)
327{
328 struct ospf_hello *hello;
329 int i;
330
331 hello = (struct ospf_hello *) STREAM_PNT (s);
332
ajs60925302004-12-08 17:45:02 +0000333 zlog_debug ("Hello");
334 zlog_debug (" NetworkMask %s", inet_ntoa (hello->network_mask));
335 zlog_debug (" HelloInterval %d", ntohs (hello->hello_interval));
336 zlog_debug (" Options %d (%s)", hello->options,
paul718e3742002-12-13 20:15:29 +0000337 ospf_options_dump (hello->options));
ajs60925302004-12-08 17:45:02 +0000338 zlog_debug (" RtrPriority %d", hello->priority);
339 zlog_debug (" RtrDeadInterval %ld", (u_long)ntohl (hello->dead_interval));
340 zlog_debug (" DRouter %s", inet_ntoa (hello->d_router));
341 zlog_debug (" BDRouter %s", inet_ntoa (hello->bd_router));
paul718e3742002-12-13 20:15:29 +0000342
343 length -= OSPF_HEADER_SIZE + OSPF_HELLO_MIN_SIZE;
ajs60925302004-12-08 17:45:02 +0000344 zlog_debug (" # Neighbors %d", length / 4);
paul718e3742002-12-13 20:15:29 +0000345 for (i = 0; length > 0; i++, length -= sizeof (struct in_addr))
ajs60925302004-12-08 17:45:02 +0000346 zlog_debug (" Neighbor %s", inet_ntoa (hello->neighbors[i]));
paul718e3742002-12-13 20:15:29 +0000347}
348
paul4dadc292005-05-06 21:37:42 +0000349static char *
paul718e3742002-12-13 20:15:29 +0000350ospf_dd_flags_dump (u_char flags, char *buf, size_t size)
351{
352 memset (buf, 0, size);
353
354 snprintf (buf, size, "%s|%s|%s",
355 (flags & OSPF_DD_FLAG_I) ? "I" : "-",
356 (flags & OSPF_DD_FLAG_M) ? "M" : "-",
357 (flags & OSPF_DD_FLAG_MS) ? "MS" : "-");
358
359 return buf;
360}
361
362void
363ospf_lsa_header_dump (struct lsa_header *lsah)
364{
hassoeb1ce602004-10-08 08:17:22 +0000365 const char *lsah_type = LOOKUP (ospf_lsa_type_msg, lsah->type);
paul0c2be262004-05-31 14:16:54 +0000366
ajs60925302004-12-08 17:45:02 +0000367 zlog_debug (" LSA Header");
368 zlog_debug (" LS age %d", ntohs (lsah->ls_age));
369 zlog_debug (" Options %d (%s)", lsah->options,
paul718e3742002-12-13 20:15:29 +0000370 ospf_options_dump (lsah->options));
ajs60925302004-12-08 17:45:02 +0000371 zlog_debug (" LS type %d (%s)", lsah->type,
paul553ff112004-06-06 09:41:00 +0000372 (lsah->type ? lsah_type : "unknown type"));
ajs60925302004-12-08 17:45:02 +0000373 zlog_debug (" Link State ID %s", inet_ntoa (lsah->id));
374 zlog_debug (" Advertising Router %s", inet_ntoa (lsah->adv_router));
375 zlog_debug (" LS sequence number 0x%lx", (u_long)ntohl (lsah->ls_seqnum));
376 zlog_debug (" LS checksum 0x%x", ntohs (lsah->checksum));
377 zlog_debug (" length %d", ntohs (lsah->length));
paul718e3742002-12-13 20:15:29 +0000378}
379
paul4dadc292005-05-06 21:37:42 +0000380static char *
paul718e3742002-12-13 20:15:29 +0000381ospf_router_lsa_flags_dump (u_char flags, char *buf, size_t size)
382{
383 memset (buf, 0, size);
384
385 snprintf (buf, size, "%s|%s|%s",
386 (flags & ROUTER_LSA_VIRTUAL) ? "V" : "-",
387 (flags & ROUTER_LSA_EXTERNAL) ? "E" : "-",
388 (flags & ROUTER_LSA_BORDER) ? "B" : "-");
389
390 return buf;
391}
392
paul4dadc292005-05-06 21:37:42 +0000393static void
paul718e3742002-12-13 20:15:29 +0000394ospf_router_lsa_dump (struct stream *s, u_int16_t length)
395{
396 char buf[BUFSIZ];
397 struct router_lsa *rl;
398 int i, len;
399
400 rl = (struct router_lsa *) STREAM_PNT (s);
401
ajs60925302004-12-08 17:45:02 +0000402 zlog_debug (" Router-LSA");
403 zlog_debug (" flags %s",
paul718e3742002-12-13 20:15:29 +0000404 ospf_router_lsa_flags_dump (rl->flags, buf, BUFSIZ));
ajs60925302004-12-08 17:45:02 +0000405 zlog_debug (" # links %d", ntohs (rl->links));
paul718e3742002-12-13 20:15:29 +0000406
407 len = ntohs (rl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
408 for (i = 0; len > 0; i++)
409 {
ajs60925302004-12-08 17:45:02 +0000410 zlog_debug (" Link ID %s", inet_ntoa (rl->link[i].link_id));
411 zlog_debug (" Link Data %s", inet_ntoa (rl->link[i].link_data));
412 zlog_debug (" Type %d", (u_char) rl->link[i].type);
413 zlog_debug (" TOS %d", (u_char) rl->link[i].tos);
414 zlog_debug (" metric %d", ntohs (rl->link[i].metric));
paul718e3742002-12-13 20:15:29 +0000415
416 len -= 12;
417 }
418}
419
paul4dadc292005-05-06 21:37:42 +0000420static void
paul718e3742002-12-13 20:15:29 +0000421ospf_network_lsa_dump (struct stream *s, u_int16_t length)
422{
423 struct network_lsa *nl;
424 int i, cnt;
425
426 nl = (struct network_lsa *) STREAM_PNT (s);
427 cnt = (ntohs (nl->header.length) - (OSPF_LSA_HEADER_SIZE + 4)) / 4;
428
ajs60925302004-12-08 17:45:02 +0000429 zlog_debug (" Network-LSA");
paul718e3742002-12-13 20:15:29 +0000430 /*
ajs60925302004-12-08 17:45:02 +0000431 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
432 zlog_debug ("Network-LSA size %d",
paul718e3742002-12-13 20:15:29 +0000433 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
434 */
ajs60925302004-12-08 17:45:02 +0000435 zlog_debug (" Network Mask %s", inet_ntoa (nl->mask));
436 zlog_debug (" # Attached Routers %d", cnt);
paul718e3742002-12-13 20:15:29 +0000437 for (i = 0; i < cnt; i++)
ajs60925302004-12-08 17:45:02 +0000438 zlog_debug (" Attached Router %s", inet_ntoa (nl->routers[i]));
paul718e3742002-12-13 20:15:29 +0000439}
440
paul4dadc292005-05-06 21:37:42 +0000441static void
paul718e3742002-12-13 20:15:29 +0000442ospf_summary_lsa_dump (struct stream *s, u_int16_t length)
443{
444 struct summary_lsa *sl;
445 int size;
446 int i;
447
448 sl = (struct summary_lsa *) STREAM_PNT (s);
449
ajs60925302004-12-08 17:45:02 +0000450 zlog_debug (" Summary-LSA");
451 zlog_debug (" Network Mask %s", inet_ntoa (sl->mask));
paul718e3742002-12-13 20:15:29 +0000452
453 size = ntohs (sl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
454 for (i = 0; size > 0; size -= 4, i++)
ajs60925302004-12-08 17:45:02 +0000455 zlog_debug (" TOS=%d metric %d", sl->tos,
paul718e3742002-12-13 20:15:29 +0000456 GET_METRIC (sl->metric));
457}
458
paul4dadc292005-05-06 21:37:42 +0000459static void
paul718e3742002-12-13 20:15:29 +0000460ospf_as_external_lsa_dump (struct stream *s, u_int16_t length)
461{
462 struct as_external_lsa *al;
463 int size;
464 int i;
465
466 al = (struct as_external_lsa *) STREAM_PNT (s);
ajs60925302004-12-08 17:45:02 +0000467 zlog_debug (" %s", ospf_lsa_type_msg[al->header.type].str);
468 zlog_debug (" Network Mask %s", inet_ntoa (al->mask));
paul718e3742002-12-13 20:15:29 +0000469
470 size = ntohs (al->header.length) - OSPF_LSA_HEADER_SIZE -4;
471 for (i = 0; size > 0; size -= 12, i++)
472 {
ajs60925302004-12-08 17:45:02 +0000473 zlog_debug (" bit %s TOS=%d metric %d",
paul718e3742002-12-13 20:15:29 +0000474 IS_EXTERNAL_METRIC (al->e[i].tos) ? "E" : "-",
475 al->e[i].tos & 0x7f, GET_METRIC (al->e[i].metric));
ajs60925302004-12-08 17:45:02 +0000476 zlog_debug (" Forwarding address %s", inet_ntoa (al->e[i].fwd_addr));
477 zlog_debug (" External Route Tag %d", al->e[i].route_tag);
paul718e3742002-12-13 20:15:29 +0000478 }
479}
480
paul4dadc292005-05-06 21:37:42 +0000481static void
paul718e3742002-12-13 20:15:29 +0000482ospf_lsa_header_list_dump (struct stream *s, u_int16_t length)
483{
484 struct lsa_header *lsa;
485
ajs60925302004-12-08 17:45:02 +0000486 zlog_debug (" # LSA Headers %d", length / OSPF_LSA_HEADER_SIZE);
paul718e3742002-12-13 20:15:29 +0000487
488 /* LSA Headers. */
489 while (length > 0)
490 {
491 lsa = (struct lsa_header *) STREAM_PNT (s);
492 ospf_lsa_header_dump (lsa);
493
paul9985f832005-02-09 15:51:56 +0000494 stream_forward_getp (s, OSPF_LSA_HEADER_SIZE);
paul718e3742002-12-13 20:15:29 +0000495 length -= OSPF_LSA_HEADER_SIZE;
496 }
497}
498
paul4dadc292005-05-06 21:37:42 +0000499static void
paul718e3742002-12-13 20:15:29 +0000500ospf_packet_db_desc_dump (struct stream *s, u_int16_t length)
501{
502 struct ospf_db_desc *dd;
503 char dd_flags[8];
504
505 u_int32_t gp;
506
507 gp = stream_get_getp (s);
508 dd = (struct ospf_db_desc *) STREAM_PNT (s);
509
ajs60925302004-12-08 17:45:02 +0000510 zlog_debug ("Database Description");
511 zlog_debug (" Interface MTU %d", ntohs (dd->mtu));
512 zlog_debug (" Options %d (%s)", dd->options,
paul718e3742002-12-13 20:15:29 +0000513 ospf_options_dump (dd->options));
ajs60925302004-12-08 17:45:02 +0000514 zlog_debug (" Flags %d (%s)", dd->flags,
paul718e3742002-12-13 20:15:29 +0000515 ospf_dd_flags_dump (dd->flags, dd_flags, sizeof dd_flags));
ajs60925302004-12-08 17:45:02 +0000516 zlog_debug (" Sequence Number 0x%08lx", (u_long)ntohl (dd->dd_seqnum));
paul718e3742002-12-13 20:15:29 +0000517
518 length -= OSPF_HEADER_SIZE + OSPF_DB_DESC_MIN_SIZE;
519
paul9985f832005-02-09 15:51:56 +0000520 stream_forward_getp (s, OSPF_DB_DESC_MIN_SIZE);
paul718e3742002-12-13 20:15:29 +0000521
522 ospf_lsa_header_list_dump (s, length);
523
524 stream_set_getp (s, gp);
525}
526
paul4dadc292005-05-06 21:37:42 +0000527static void
paul718e3742002-12-13 20:15:29 +0000528ospf_packet_ls_req_dump (struct stream *s, u_int16_t length)
529{
530 u_int32_t sp;
531 u_int32_t ls_type;
532 struct in_addr ls_id;
533 struct in_addr adv_router;
534
535 sp = stream_get_getp (s);
536
537 length -= OSPF_HEADER_SIZE;
538
ajs60925302004-12-08 17:45:02 +0000539 zlog_debug ("Link State Request");
540 zlog_debug (" # Requests %d", length / 12);
paul718e3742002-12-13 20:15:29 +0000541
542 for (; length > 0; length -= 12)
543 {
544 ls_type = stream_getl (s);
545 ls_id.s_addr = stream_get_ipv4 (s);
546 adv_router.s_addr = stream_get_ipv4 (s);
547
ajs60925302004-12-08 17:45:02 +0000548 zlog_debug (" LS type %d", ls_type);
549 zlog_debug (" Link State ID %s", inet_ntoa (ls_id));
550 zlog_debug (" Advertising Router %s",
paul718e3742002-12-13 20:15:29 +0000551 inet_ntoa (adv_router));
552 }
553
554 stream_set_getp (s, sp);
555}
556
paul4dadc292005-05-06 21:37:42 +0000557static void
paul718e3742002-12-13 20:15:29 +0000558ospf_packet_ls_upd_dump (struct stream *s, u_int16_t length)
559{
560 u_int32_t sp;
561 struct lsa_header *lsa;
562 int lsa_len;
563 u_int32_t count;
564
565 length -= OSPF_HEADER_SIZE;
566
567 sp = stream_get_getp (s);
568
569 count = stream_getl (s);
570 length -= 4;
571
ajs60925302004-12-08 17:45:02 +0000572 zlog_debug ("Link State Update");
573 zlog_debug (" # LSAs %d", count);
paul718e3742002-12-13 20:15:29 +0000574
575 while (length > 0 && count > 0)
576 {
577 if (length < OSPF_HEADER_SIZE || length % 4 != 0)
578 {
ajs60925302004-12-08 17:45:02 +0000579 zlog_debug (" Remaining %d bytes; Incorrect length.", length);
paul718e3742002-12-13 20:15:29 +0000580 break;
581 }
582
583 lsa = (struct lsa_header *) STREAM_PNT (s);
584 lsa_len = ntohs (lsa->length);
585 ospf_lsa_header_dump (lsa);
586
587 switch (lsa->type)
588 {
589 case OSPF_ROUTER_LSA:
590 ospf_router_lsa_dump (s, length);
591 break;
592 case OSPF_NETWORK_LSA:
593 ospf_network_lsa_dump (s, length);
594 break;
595 case OSPF_SUMMARY_LSA:
596 case OSPF_ASBR_SUMMARY_LSA:
597 ospf_summary_lsa_dump (s, length);
598 break;
599 case OSPF_AS_EXTERNAL_LSA:
600 ospf_as_external_lsa_dump (s, length);
601 break;
paul718e3742002-12-13 20:15:29 +0000602 case OSPF_AS_NSSA_LSA:
pauld4a53d52003-07-12 21:30:57 +0000603 ospf_as_external_lsa_dump (s, length);
paul718e3742002-12-13 20:15:29 +0000604 break;
paul718e3742002-12-13 20:15:29 +0000605#ifdef HAVE_OPAQUE_LSA
606 case OSPF_OPAQUE_LINK_LSA:
607 case OSPF_OPAQUE_AREA_LSA:
608 case OSPF_OPAQUE_AS_LSA:
609 ospf_opaque_lsa_dump (s, length);
610 break;
611#endif /* HAVE_OPAQUE_LSA */
612 default:
613 break;
614 }
615
paul9985f832005-02-09 15:51:56 +0000616 stream_forward_getp (s, lsa_len);
paul718e3742002-12-13 20:15:29 +0000617 length -= lsa_len;
618 count--;
619 }
620
621 stream_set_getp (s, sp);
622}
623
paul4dadc292005-05-06 21:37:42 +0000624static void
paul718e3742002-12-13 20:15:29 +0000625ospf_packet_ls_ack_dump (struct stream *s, u_int16_t length)
626{
627 u_int32_t sp;
628
629 length -= OSPF_HEADER_SIZE;
630 sp = stream_get_getp (s);
631
ajs60925302004-12-08 17:45:02 +0000632 zlog_debug ("Link State Acknowledgment");
paul718e3742002-12-13 20:15:29 +0000633 ospf_lsa_header_list_dump (s, length);
634
635 stream_set_getp (s, sp);
636}
637
paul6b333612004-10-11 10:11:25 +0000638/* Expects header to be in host order */
paul718e3742002-12-13 20:15:29 +0000639void
paul6b333612004-10-11 10:11:25 +0000640ospf_ip_header_dump (struct ip *iph)
paul718e3742002-12-13 20:15:29 +0000641{
paul718e3742002-12-13 20:15:29 +0000642 /* IP Header dump. */
ajs60925302004-12-08 17:45:02 +0000643 zlog_debug ("ip_v %d", iph->ip_v);
644 zlog_debug ("ip_hl %d", iph->ip_hl);
645 zlog_debug ("ip_tos %d", iph->ip_tos);
646 zlog_debug ("ip_len %d", iph->ip_len);
647 zlog_debug ("ip_id %u", (u_int32_t) iph->ip_id);
648 zlog_debug ("ip_off %u", (u_int32_t) iph->ip_off);
649 zlog_debug ("ip_ttl %d", iph->ip_ttl);
650 zlog_debug ("ip_p %d", iph->ip_p);
651 zlog_debug ("ip_sum 0x%x", (u_int32_t) iph->ip_sum);
652 zlog_debug ("ip_src %s", inet_ntoa (iph->ip_src));
653 zlog_debug ("ip_dst %s", inet_ntoa (iph->ip_dst));
paul718e3742002-12-13 20:15:29 +0000654}
655
paul4dadc292005-05-06 21:37:42 +0000656static void
paul718e3742002-12-13 20:15:29 +0000657ospf_header_dump (struct ospf_header *ospfh)
658{
659 char buf[9];
660
ajs60925302004-12-08 17:45:02 +0000661 zlog_debug ("Header");
662 zlog_debug (" Version %d", ospfh->version);
663 zlog_debug (" Type %d (%s)", ospfh->type,
paul718e3742002-12-13 20:15:29 +0000664 ospf_packet_type_str[ospfh->type]);
ajs60925302004-12-08 17:45:02 +0000665 zlog_debug (" Packet Len %d", ntohs (ospfh->length));
666 zlog_debug (" Router ID %s", inet_ntoa (ospfh->router_id));
667 zlog_debug (" Area ID %s", inet_ntoa (ospfh->area_id));
668 zlog_debug (" Checksum 0x%x", ntohs (ospfh->checksum));
669 zlog_debug (" AuType %d", ntohs (ospfh->auth_type));
paul718e3742002-12-13 20:15:29 +0000670
671 switch (ntohs (ospfh->auth_type))
672 {
673 case OSPF_AUTH_NULL:
674 break;
675 case OSPF_AUTH_SIMPLE:
676 memset (buf, 0, 9);
hassoc9e52be2004-09-26 16:09:34 +0000677 strncpy (buf, (char *) ospfh->u.auth_data, 8);
ajs60925302004-12-08 17:45:02 +0000678 zlog_debug (" Simple Password %s", buf);
paul718e3742002-12-13 20:15:29 +0000679 break;
680 case OSPF_AUTH_CRYPTOGRAPHIC:
ajs60925302004-12-08 17:45:02 +0000681 zlog_debug (" Cryptographic Authentication");
682 zlog_debug (" Key ID %d", ospfh->u.crypt.key_id);
683 zlog_debug (" Auth Data Len %d", ospfh->u.crypt.auth_data_len);
684 zlog_debug (" Sequence number %ld",
paul718e3742002-12-13 20:15:29 +0000685 (u_long)ntohl (ospfh->u.crypt.crypt_seqnum));
686 break;
687 default:
ajs60925302004-12-08 17:45:02 +0000688 zlog_debug ("* This is not supported authentication type");
paul718e3742002-12-13 20:15:29 +0000689 break;
690 }
691
692}
693
694void
695ospf_packet_dump (struct stream *s)
696{
697 struct ospf_header *ospfh;
698 unsigned long gp;
699
700 /* Preserve pointer. */
701 gp = stream_get_getp (s);
702
703 /* OSPF Header dump. */
704 ospfh = (struct ospf_header *) STREAM_PNT (s);
705
706 /* Until detail flag is set, return. */
707 if (!(term_debug_ospf_packet[ospfh->type - 1] & OSPF_DEBUG_DETAIL))
708 return;
709
710 /* Show OSPF header detail. */
711 ospf_header_dump (ospfh);
paul9985f832005-02-09 15:51:56 +0000712 stream_forward_getp (s, OSPF_HEADER_SIZE);
paul718e3742002-12-13 20:15:29 +0000713
714 switch (ospfh->type)
715 {
716 case OSPF_MSG_HELLO:
717 ospf_packet_hello_dump (s, ntohs (ospfh->length));
718 break;
719 case OSPF_MSG_DB_DESC:
720 ospf_packet_db_desc_dump (s, ntohs (ospfh->length));
721 break;
722 case OSPF_MSG_LS_REQ:
723 ospf_packet_ls_req_dump (s, ntohs (ospfh->length));
724 break;
725 case OSPF_MSG_LS_UPD:
726 ospf_packet_ls_upd_dump (s, ntohs (ospfh->length));
727 break;
728 case OSPF_MSG_LS_ACK:
729 ospf_packet_ls_ack_dump (s, ntohs (ospfh->length));
730 break;
731 default:
732 break;
733 }
734
735 stream_set_getp (s, gp);
736}
737
738
739/*
740 [no] debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)
741 [send|recv [detail]]
742*/
743DEFUN (debug_ospf_packet,
744 debug_ospf_packet_all_cmd,
745 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
746 DEBUG_STR
747 OSPF_STR
748 "OSPF packets\n"
749 "OSPF Hello\n"
750 "OSPF Database Description\n"
751 "OSPF Link State Request\n"
752 "OSPF Link State Update\n"
753 "OSPF Link State Acknowledgment\n"
754 "OSPF all packets\n")
755{
756 int type = 0;
757 int flag = 0;
758 int i;
759
760 assert (argc > 0);
761
762 /* Check packet type. */
763 if (strncmp (argv[0], "h", 1) == 0)
764 type = OSPF_DEBUG_HELLO;
765 else if (strncmp (argv[0], "d", 1) == 0)
766 type = OSPF_DEBUG_DB_DESC;
767 else if (strncmp (argv[0], "ls-r", 4) == 0)
768 type = OSPF_DEBUG_LS_REQ;
769 else if (strncmp (argv[0], "ls-u", 4) == 0)
770 type = OSPF_DEBUG_LS_UPD;
771 else if (strncmp (argv[0], "ls-a", 4) == 0)
772 type = OSPF_DEBUG_LS_ACK;
773 else if (strncmp (argv[0], "a", 1) == 0)
774 type = OSPF_DEBUG_ALL;
775
776 /* Default, both send and recv. */
777 if (argc == 1)
778 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV;
779
780 /* send or recv. */
781 if (argc >= 2)
782 {
783 if (strncmp (argv[1], "s", 1) == 0)
784 flag = OSPF_DEBUG_SEND;
785 else if (strncmp (argv[1], "r", 1) == 0)
786 flag = OSPF_DEBUG_RECV;
787 else if (strncmp (argv[1], "d", 1) == 0)
788 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
789 }
790
791 /* detail. */
792 if (argc == 3)
793 if (strncmp (argv[2], "d", 1) == 0)
794 flag |= OSPF_DEBUG_DETAIL;
795
796 for (i = 0; i < 5; i++)
797 if (type & (0x01 << i))
798 {
799 if (vty->node == CONFIG_NODE)
800 DEBUG_PACKET_ON (i, flag);
801 else
802 TERM_DEBUG_PACKET_ON (i, flag);
803 }
804
805 return CMD_SUCCESS;
806}
807
808ALIAS (debug_ospf_packet,
809 debug_ospf_packet_send_recv_cmd,
810 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
811 "Debugging functions\n"
812 "OSPF information\n"
813 "OSPF packets\n"
814 "OSPF Hello\n"
815 "OSPF Database Description\n"
816 "OSPF Link State Request\n"
817 "OSPF Link State Update\n"
818 "OSPF Link State Acknowledgment\n"
819 "OSPF all packets\n"
820 "Packet sent\n"
821 "Packet received\n"
822 "Detail information\n")
823
824ALIAS (debug_ospf_packet,
825 debug_ospf_packet_send_recv_detail_cmd,
826 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
827 "Debugging functions\n"
828 "OSPF information\n"
829 "OSPF packets\n"
830 "OSPF Hello\n"
831 "OSPF Database Description\n"
832 "OSPF Link State Request\n"
833 "OSPF Link State Update\n"
834 "OSPF Link State Acknowledgment\n"
835 "OSPF all packets\n"
836 "Packet sent\n"
837 "Packet received\n"
838 "Detail Information\n")
839
840
841DEFUN (no_debug_ospf_packet,
842 no_debug_ospf_packet_all_cmd,
843 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
844 NO_STR
845 DEBUG_STR
846 OSPF_STR
847 "OSPF packets\n"
848 "OSPF Hello\n"
849 "OSPF Database Description\n"
850 "OSPF Link State Request\n"
851 "OSPF Link State Update\n"
852 "OSPF Link State Acknowledgment\n"
853 "OSPF all packets\n")
854{
855 int type = 0;
856 int flag = 0;
857 int i;
858
859 assert (argc > 0);
860
861 /* Check packet type. */
862 if (strncmp (argv[0], "h", 1) == 0)
863 type = OSPF_DEBUG_HELLO;
864 else if (strncmp (argv[0], "d", 1) == 0)
865 type = OSPF_DEBUG_DB_DESC;
866 else if (strncmp (argv[0], "ls-r", 4) == 0)
867 type = OSPF_DEBUG_LS_REQ;
868 else if (strncmp (argv[0], "ls-u", 4) == 0)
869 type = OSPF_DEBUG_LS_UPD;
870 else if (strncmp (argv[0], "ls-a", 4) == 0)
871 type = OSPF_DEBUG_LS_ACK;
872 else if (strncmp (argv[0], "a", 1) == 0)
873 type = OSPF_DEBUG_ALL;
874
875 /* Default, both send and recv. */
876 if (argc == 1)
877 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL ;
878
879 /* send or recv. */
880 if (argc == 2)
881 {
882 if (strncmp (argv[1], "s", 1) == 0)
883 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_DETAIL;
884 else if (strncmp (argv[1], "r", 1) == 0)
885 flag = OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
886 else if (strncmp (argv[1], "d", 1) == 0)
887 flag = OSPF_DEBUG_DETAIL;
888 }
889
890 /* detail. */
891 if (argc == 3)
892 if (strncmp (argv[2], "d", 1) == 0)
893 flag = OSPF_DEBUG_DETAIL;
894
895 for (i = 0; i < 5; i++)
896 if (type & (0x01 << i))
897 {
898 if (vty->node == CONFIG_NODE)
899 DEBUG_PACKET_OFF (i, flag);
900 else
901 TERM_DEBUG_PACKET_OFF (i, flag);
902 }
903
904#ifdef DEBUG
jardin6638c1a2005-10-01 00:08:54 +0000905 /*
paul718e3742002-12-13 20:15:29 +0000906 for (i = 0; i < 5; i++)
ajs60925302004-12-08 17:45:02 +0000907 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
jardin6638c1a2005-10-01 00:08:54 +0000908 */
paul718e3742002-12-13 20:15:29 +0000909#endif /* DEBUG */
910
911 return CMD_SUCCESS;
912}
913
914ALIAS (no_debug_ospf_packet,
915 no_debug_ospf_packet_send_recv_cmd,
916 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
917 NO_STR
918 "Debugging functions\n"
919 "OSPF information\n"
920 "OSPF packets\n"
921 "OSPF Hello\n"
922 "OSPF Database Description\n"
923 "OSPF Link State Request\n"
924 "OSPF Link State Update\n"
925 "OSPF Link State Acknowledgment\n"
926 "OSPF all packets\n"
927 "Packet sent\n"
928 "Packet received\n"
929 "Detail Information\n")
930
931ALIAS (no_debug_ospf_packet,
932 no_debug_ospf_packet_send_recv_detail_cmd,
933 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
934 NO_STR
935 "Debugging functions\n"
936 "OSPF information\n"
937 "OSPF packets\n"
938 "OSPF Hello\n"
939 "OSPF Database Description\n"
940 "OSPF Link State Request\n"
941 "OSPF Link State Update\n"
942 "OSPF Link State Acknowledgment\n"
943 "OSPF all packets\n"
944 "Packet sent\n"
945 "Packet received\n"
946 "Detail Information\n")
947
948
949DEFUN (debug_ospf_ism,
950 debug_ospf_ism_cmd,
951 "debug ospf ism",
952 DEBUG_STR
953 OSPF_STR
954 "OSPF Interface State Machine\n")
955{
956 if (vty->node == CONFIG_NODE)
957 {
958 if (argc == 0)
959 DEBUG_ON (ism, ISM);
960 else if (argc == 1)
961 {
962 if (strncmp (argv[0], "s", 1) == 0)
963 DEBUG_ON (ism, ISM_STATUS);
964 else if (strncmp (argv[0], "e", 1) == 0)
965 DEBUG_ON (ism, ISM_EVENTS);
966 else if (strncmp (argv[0], "t", 1) == 0)
967 DEBUG_ON (ism, ISM_TIMERS);
968 }
969
970 return CMD_SUCCESS;
971 }
972
973 /* ENABLE_NODE. */
974 if (argc == 0)
975 TERM_DEBUG_ON (ism, ISM);
976 else if (argc == 1)
977 {
978 if (strncmp (argv[0], "s", 1) == 0)
979 TERM_DEBUG_ON (ism, ISM_STATUS);
980 else if (strncmp (argv[0], "e", 1) == 0)
981 TERM_DEBUG_ON (ism, ISM_EVENTS);
982 else if (strncmp (argv[0], "t", 1) == 0)
983 TERM_DEBUG_ON (ism, ISM_TIMERS);
984 }
985
986 return CMD_SUCCESS;
987}
988
989ALIAS (debug_ospf_ism,
990 debug_ospf_ism_sub_cmd,
991 "debug ospf ism (status|events|timers)",
992 DEBUG_STR
993 OSPF_STR
994 "OSPF Interface State Machine\n"
995 "ISM Status Information\n"
996 "ISM Event Information\n"
997 "ISM TImer Information\n")
998
999DEFUN (no_debug_ospf_ism,
1000 no_debug_ospf_ism_cmd,
1001 "no debug ospf ism",
1002 NO_STR
1003 DEBUG_STR
1004 OSPF_STR
1005 "OSPF Interface State Machine")
1006{
1007 if (vty->node == CONFIG_NODE)
1008 {
1009 if (argc == 0)
1010 DEBUG_OFF (ism, ISM);
1011 else if (argc == 1)
1012 {
1013 if (strncmp (argv[0], "s", 1) == 0)
1014 DEBUG_OFF (ism, ISM_STATUS);
1015 else if (strncmp (argv[0], "e", 1) == 0)
1016 DEBUG_OFF (ism, ISM_EVENTS);
1017 else if (strncmp (argv[0], "t", 1) == 0)
1018 DEBUG_OFF (ism, ISM_TIMERS);
1019 }
1020 return CMD_SUCCESS;
1021 }
1022
1023 /* ENABLE_NODE. */
1024 if (argc == 0)
1025 TERM_DEBUG_OFF (ism, ISM);
1026 else if (argc == 1)
1027 {
1028 if (strncmp (argv[0], "s", 1) == 0)
1029 TERM_DEBUG_OFF (ism, ISM_STATUS);
1030 else if (strncmp (argv[0], "e", 1) == 0)
1031 TERM_DEBUG_OFF (ism, ISM_EVENTS);
1032 else if (strncmp (argv[0], "t", 1) == 0)
1033 TERM_DEBUG_OFF (ism, ISM_TIMERS);
1034 }
1035
1036 return CMD_SUCCESS;
1037}
1038
1039ALIAS (no_debug_ospf_ism,
1040 no_debug_ospf_ism_sub_cmd,
1041 "no debug ospf ism (status|events|timers)",
1042 NO_STR
1043 "Debugging functions\n"
1044 "OSPF information\n"
1045 "OSPF Interface State Machine\n"
1046 "ISM Status Information\n"
1047 "ISM Event Information\n"
1048 "ISM Timer Information\n")
1049
1050
1051DEFUN (debug_ospf_nsm,
1052 debug_ospf_nsm_cmd,
1053 "debug ospf nsm",
1054 DEBUG_STR
1055 OSPF_STR
1056 "OSPF Neighbor State Machine\n")
1057{
1058 if (vty->node == CONFIG_NODE)
1059 {
1060 if (argc == 0)
1061 DEBUG_ON (nsm, NSM);
1062 else if (argc == 1)
1063 {
1064 if (strncmp (argv[0], "s", 1) == 0)
1065 DEBUG_ON (nsm, NSM_STATUS);
1066 else if (strncmp (argv[0], "e", 1) == 0)
1067 DEBUG_ON (nsm, NSM_EVENTS);
1068 else if (strncmp (argv[0], "t", 1) == 0)
1069 DEBUG_ON (nsm, NSM_TIMERS);
1070 }
1071
1072 return CMD_SUCCESS;
1073 }
1074
1075 /* ENABLE_NODE. */
1076 if (argc == 0)
1077 TERM_DEBUG_ON (nsm, NSM);
1078 else if (argc == 1)
1079 {
1080 if (strncmp (argv[0], "s", 1) == 0)
1081 TERM_DEBUG_ON (nsm, NSM_STATUS);
1082 else if (strncmp (argv[0], "e", 1) == 0)
1083 TERM_DEBUG_ON (nsm, NSM_EVENTS);
1084 else if (strncmp (argv[0], "t", 1) == 0)
1085 TERM_DEBUG_ON (nsm, NSM_TIMERS);
1086 }
1087
1088 return CMD_SUCCESS;
1089}
1090
1091ALIAS (debug_ospf_nsm,
1092 debug_ospf_nsm_sub_cmd,
1093 "debug ospf nsm (status|events|timers)",
1094 DEBUG_STR
1095 OSPF_STR
1096 "OSPF Neighbor State Machine\n"
1097 "NSM Status Information\n"
1098 "NSM Event Information\n"
1099 "NSM Timer Information\n")
1100
1101DEFUN (no_debug_ospf_nsm,
1102 no_debug_ospf_nsm_cmd,
1103 "no debug ospf nsm",
1104 NO_STR
1105 DEBUG_STR
1106 OSPF_STR
1107 "OSPF Neighbor State Machine")
1108{
1109 if (vty->node == CONFIG_NODE)
1110 {
1111 if (argc == 0)
1112 DEBUG_OFF (nsm, NSM);
1113 else if (argc == 1)
1114 {
1115 if (strncmp (argv[0], "s", 1) == 0)
1116 DEBUG_OFF (nsm, NSM_STATUS);
1117 else if (strncmp (argv[0], "e", 1) == 0)
1118 DEBUG_OFF (nsm, NSM_EVENTS);
1119 else if (strncmp (argv[0], "t", 1) == 0)
1120 DEBUG_OFF (nsm, NSM_TIMERS);
1121 }
1122
1123 return CMD_SUCCESS;
1124 }
1125
1126 /* ENABLE_NODE. */
1127 if (argc == 0)
1128 TERM_DEBUG_OFF (nsm, NSM);
1129 else if (argc == 1)
1130 {
1131 if (strncmp (argv[0], "s", 1) == 0)
1132 TERM_DEBUG_OFF (nsm, NSM_STATUS);
1133 else if (strncmp (argv[0], "e", 1) == 0)
1134 TERM_DEBUG_OFF (nsm, NSM_EVENTS);
1135 else if (strncmp (argv[0], "t", 1) == 0)
1136 TERM_DEBUG_OFF (nsm, NSM_TIMERS);
1137 }
1138
1139 return CMD_SUCCESS;
1140}
1141
1142ALIAS (no_debug_ospf_nsm,
1143 no_debug_ospf_nsm_sub_cmd,
1144 "no debug ospf nsm (status|events|timers)",
1145 NO_STR
1146 "Debugging functions\n"
1147 "OSPF information\n"
1148 "OSPF Interface State Machine\n"
1149 "NSM Status Information\n"
1150 "NSM Event Information\n"
1151 "NSM Timer Information\n")
1152
1153
1154DEFUN (debug_ospf_lsa,
1155 debug_ospf_lsa_cmd,
1156 "debug ospf lsa",
1157 DEBUG_STR
1158 OSPF_STR
1159 "OSPF Link State Advertisement\n")
1160{
1161 if (vty->node == CONFIG_NODE)
1162 {
1163 if (argc == 0)
1164 DEBUG_ON (lsa, LSA);
1165 else if (argc == 1)
1166 {
1167 if (strncmp (argv[0], "g", 1) == 0)
1168 DEBUG_ON (lsa, LSA_GENERATE);
1169 else if (strncmp (argv[0], "f", 1) == 0)
1170 DEBUG_ON (lsa, LSA_FLOODING);
1171 else if (strncmp (argv[0], "i", 1) == 0)
1172 DEBUG_ON (lsa, LSA_INSTALL);
1173 else if (strncmp (argv[0], "r", 1) == 0)
1174 DEBUG_ON (lsa, LSA_REFRESH);
1175 }
1176
1177 return CMD_SUCCESS;
1178 }
1179
1180 /* ENABLE_NODE. */
1181 if (argc == 0)
1182 TERM_DEBUG_ON (lsa, LSA);
1183 else if (argc == 1)
1184 {
1185 if (strncmp (argv[0], "g", 1) == 0)
1186 TERM_DEBUG_ON (lsa, LSA_GENERATE);
1187 else if (strncmp (argv[0], "f", 1) == 0)
1188 TERM_DEBUG_ON (lsa, LSA_FLOODING);
1189 else if (strncmp (argv[0], "i", 1) == 0)
1190 TERM_DEBUG_ON (lsa, LSA_INSTALL);
1191 else if (strncmp (argv[0], "r", 1) == 0)
1192 TERM_DEBUG_ON (lsa, LSA_REFRESH);
1193 }
1194
1195 return CMD_SUCCESS;
1196}
1197
1198ALIAS (debug_ospf_lsa,
1199 debug_ospf_lsa_sub_cmd,
1200 "debug ospf lsa (generate|flooding|install|refresh)",
1201 DEBUG_STR
1202 OSPF_STR
1203 "OSPF Link State Advertisement\n"
1204 "LSA Generation\n"
1205 "LSA Flooding\n"
1206 "LSA Install/Delete\n"
1207 "LSA Refresh\n")
1208
1209DEFUN (no_debug_ospf_lsa,
1210 no_debug_ospf_lsa_cmd,
1211 "no debug ospf lsa",
1212 NO_STR
1213 DEBUG_STR
1214 OSPF_STR
1215 "OSPF Link State Advertisement\n")
1216{
1217 if (vty->node == CONFIG_NODE)
1218 {
1219 if (argc == 0)
1220 DEBUG_OFF (lsa, LSA);
1221 else if (argc == 1)
1222 {
1223 if (strncmp (argv[0], "g", 1) == 0)
1224 DEBUG_OFF (lsa, LSA_GENERATE);
1225 else if (strncmp (argv[0], "f", 1) == 0)
1226 DEBUG_OFF (lsa, LSA_FLOODING);
1227 else if (strncmp (argv[0], "i", 1) == 0)
1228 DEBUG_OFF (lsa, LSA_INSTALL);
1229 else if (strncmp (argv[0], "r", 1) == 0)
1230 DEBUG_OFF (lsa, LSA_REFRESH);
1231 }
1232
1233 return CMD_SUCCESS;
1234 }
1235
1236 /* ENABLE_NODE. */
1237 if (argc == 0)
1238 TERM_DEBUG_OFF (lsa, LSA);
1239 else if (argc == 1)
1240 {
1241 if (strncmp (argv[0], "g", 1) == 0)
1242 TERM_DEBUG_OFF (lsa, LSA_GENERATE);
1243 else if (strncmp (argv[0], "f", 1) == 0)
1244 TERM_DEBUG_OFF (lsa, LSA_FLOODING);
1245 else if (strncmp (argv[0], "i", 1) == 0)
1246 TERM_DEBUG_OFF (lsa, LSA_INSTALL);
1247 else if (strncmp (argv[0], "r", 1) == 0)
1248 TERM_DEBUG_OFF (lsa, LSA_REFRESH);
1249 }
1250
1251 return CMD_SUCCESS;
1252}
1253
1254ALIAS (no_debug_ospf_lsa,
1255 no_debug_ospf_lsa_sub_cmd,
1256 "no debug ospf lsa (generate|flooding|install|refresh)",
1257 NO_STR
1258 DEBUG_STR
1259 OSPF_STR
1260 "OSPF Link State Advertisement\n"
1261 "LSA Generation\n"
1262 "LSA Flooding\n"
1263 "LSA Install/Delete\n"
1264 "LSA Refres\n")
1265
1266
1267DEFUN (debug_ospf_zebra,
1268 debug_ospf_zebra_cmd,
1269 "debug ospf zebra",
1270 DEBUG_STR
1271 OSPF_STR
1272 "OSPF Zebra information\n")
1273{
1274 if (vty->node == CONFIG_NODE)
1275 {
1276 if (argc == 0)
1277 DEBUG_ON (zebra, ZEBRA);
1278 else if (argc == 1)
1279 {
1280 if (strncmp (argv[0], "i", 1) == 0)
1281 DEBUG_ON (zebra, ZEBRA_INTERFACE);
1282 else if (strncmp (argv[0], "r", 1) == 0)
1283 DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
1284 }
1285
1286 return CMD_SUCCESS;
1287 }
1288
1289 /* ENABLE_NODE. */
1290 if (argc == 0)
1291 TERM_DEBUG_ON (zebra, ZEBRA);
1292 else if (argc == 1)
1293 {
1294 if (strncmp (argv[0], "i", 1) == 0)
1295 TERM_DEBUG_ON (zebra, ZEBRA_INTERFACE);
1296 else if (strncmp (argv[0], "r", 1) == 0)
1297 TERM_DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
1298 }
1299
1300 return CMD_SUCCESS;
1301}
1302
1303ALIAS (debug_ospf_zebra,
1304 debug_ospf_zebra_sub_cmd,
1305 "debug ospf zebra (interface|redistribute)",
1306 DEBUG_STR
1307 OSPF_STR
1308 "OSPF Zebra information\n"
1309 "Zebra interface\n"
1310 "Zebra redistribute\n")
1311
1312DEFUN (no_debug_ospf_zebra,
1313 no_debug_ospf_zebra_cmd,
1314 "no debug ospf zebra",
1315 NO_STR
1316 DEBUG_STR
1317 OSPF_STR
1318 "OSPF Zebra information\n")
1319{
1320 if (vty->node == CONFIG_NODE)
1321 {
1322 if (argc == 0)
1323 DEBUG_OFF (zebra, ZEBRA);
1324 else if (argc == 1)
1325 {
1326 if (strncmp (argv[0], "i", 1) == 0)
1327 DEBUG_OFF (zebra, ZEBRA_INTERFACE);
1328 else if (strncmp (argv[0], "r", 1) == 0)
1329 DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
1330 }
1331
1332 return CMD_SUCCESS;
1333 }
1334
1335 /* ENABLE_NODE. */
1336 if (argc == 0)
1337 TERM_DEBUG_OFF (zebra, ZEBRA);
1338 else if (argc == 1)
1339 {
1340 if (strncmp (argv[0], "i", 1) == 0)
1341 TERM_DEBUG_OFF (zebra, ZEBRA_INTERFACE);
1342 else if (strncmp (argv[0], "r", 1) == 0)
1343 TERM_DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
1344 }
1345
1346 return CMD_SUCCESS;
1347}
1348
1349ALIAS (no_debug_ospf_zebra,
1350 no_debug_ospf_zebra_sub_cmd,
1351 "no debug ospf zebra (interface|redistribute)",
1352 NO_STR
1353 DEBUG_STR
1354 OSPF_STR
1355 "OSPF Zebra information\n"
1356 "Zebra interface\n"
1357 "Zebra redistribute\n")
1358
1359DEFUN (debug_ospf_event,
1360 debug_ospf_event_cmd,
1361 "debug ospf event",
1362 DEBUG_STR
1363 OSPF_STR
1364 "OSPF event information\n")
1365{
1366 if (vty->node == CONFIG_NODE)
1367 CONF_DEBUG_ON (event, EVENT);
1368 TERM_DEBUG_ON (event, EVENT);
1369 return CMD_SUCCESS;
1370}
1371
1372DEFUN (no_debug_ospf_event,
1373 no_debug_ospf_event_cmd,
1374 "no debug ospf event",
1375 NO_STR
1376 DEBUG_STR
1377 OSPF_STR
1378 "OSPF event information\n")
1379{
1380 if (vty->node == CONFIG_NODE)
1381 CONF_DEBUG_OFF (event, EVENT);
1382 TERM_DEBUG_OFF (event, EVENT);
1383 return CMD_SUCCESS;
1384}
1385
1386DEFUN (debug_ospf_nssa,
1387 debug_ospf_nssa_cmd,
1388 "debug ospf nssa",
1389 DEBUG_STR
1390 OSPF_STR
1391 "OSPF nssa information\n")
1392{
1393 if (vty->node == CONFIG_NODE)
1394 CONF_DEBUG_ON (nssa, NSSA);
1395 TERM_DEBUG_ON (nssa, NSSA);
1396 return CMD_SUCCESS;
1397}
1398
1399DEFUN (no_debug_ospf_nssa,
1400 no_debug_ospf_nssa_cmd,
1401 "no debug ospf nssa",
1402 NO_STR
1403 DEBUG_STR
1404 OSPF_STR
1405 "OSPF nssa information\n")
1406{
1407 if (vty->node == CONFIG_NODE)
1408 CONF_DEBUG_OFF (nssa, NSSA);
1409 TERM_DEBUG_OFF (nssa, NSSA);
1410 return CMD_SUCCESS;
1411}
1412
1413
1414DEFUN (show_debugging_ospf,
1415 show_debugging_ospf_cmd,
1416 "show debugging ospf",
1417 SHOW_STR
1418 DEBUG_STR
1419 OSPF_STR)
1420{
1421 int i;
1422
hassodf43a132004-08-31 12:04:33 +00001423 vty_out (vty, "OSPF debugging status:%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001424
ajsaca72fd2005-03-31 15:18:21 +00001425 /* Show debug status for events. */
1426 if (IS_DEBUG_OSPF(event,EVENT))
1427 vty_out (vty, " OSPF event debugging is on%s", VTY_NEWLINE);
1428
paul718e3742002-12-13 20:15:29 +00001429 /* Show debug status for ISM. */
1430 if (IS_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
1431 vty_out (vty, " OSPF ISM debugging is on%s", VTY_NEWLINE);
1432 else
1433 {
1434 if (IS_DEBUG_OSPF (ism, ISM_STATUS))
1435 vty_out (vty, " OSPF ISM status debugging is on%s", VTY_NEWLINE);
1436 if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
1437 vty_out (vty, " OSPF ISM event debugging is on%s", VTY_NEWLINE);
1438 if (IS_DEBUG_OSPF (ism, ISM_TIMERS))
1439 vty_out (vty, " OSPF ISM timer debugging is on%s", VTY_NEWLINE);
1440 }
1441
1442 /* Show debug status for NSM. */
1443 if (IS_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
1444 vty_out (vty, " OSPF NSM debugging is on%s", VTY_NEWLINE);
1445 else
1446 {
1447 if (IS_DEBUG_OSPF (nsm, NSM_STATUS))
1448 vty_out (vty, " OSPF NSM status debugging is on%s", VTY_NEWLINE);
1449 if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
1450 vty_out (vty, " OSPF NSM event debugging is on%s", VTY_NEWLINE);
1451 if (IS_DEBUG_OSPF (nsm, NSM_TIMERS))
1452 vty_out (vty, " OSPF NSM timer debugging is on%s", VTY_NEWLINE);
1453 }
1454
1455 /* Show debug status for OSPF Packets. */
1456 for (i = 0; i < 5; i++)
1457 if (IS_DEBUG_OSPF_PACKET (i, SEND) && IS_DEBUG_OSPF_PACKET (i, RECV))
1458 {
1459 vty_out (vty, " OSPF packet %s%s debugging is on%s",
1460 ospf_packet_type_str[i + 1],
1461 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1462 VTY_NEWLINE);
1463 }
1464 else
1465 {
1466 if (IS_DEBUG_OSPF_PACKET (i, SEND))
1467 vty_out (vty, " OSPF packet %s send%s debugging is on%s",
1468 ospf_packet_type_str[i + 1],
1469 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1470 VTY_NEWLINE);
1471 if (IS_DEBUG_OSPF_PACKET (i, RECV))
1472 vty_out (vty, " OSPF packet %s receive%s debugging is on%s",
1473 ospf_packet_type_str[i + 1],
1474 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1475 VTY_NEWLINE);
1476 }
1477
1478 /* Show debug status for OSPF LSAs. */
1479 if (IS_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
1480 vty_out (vty, " OSPF LSA debugging is on%s", VTY_NEWLINE);
1481 else
1482 {
1483 if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
1484 vty_out (vty, " OSPF LSA generation debugging is on%s", VTY_NEWLINE);
1485 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
1486 vty_out (vty, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE);
1487 if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
1488 vty_out (vty, " OSPF LSA install debugging is on%s", VTY_NEWLINE);
1489 if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
1490 vty_out (vty, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE);
1491 }
1492
1493 /* Show debug status for Zebra. */
1494 if (IS_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
1495 vty_out (vty, " OSPF Zebra debugging is on%s", VTY_NEWLINE);
1496 else
1497 {
1498 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
1499 vty_out (vty, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE);
1500 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
1501 vty_out (vty, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE);
1502 }
ajsaca72fd2005-03-31 15:18:21 +00001503
1504 /* Show debug status for NSSA. */
paulead687e2003-04-07 17:12:12 +00001505 if (IS_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
1506 vty_out (vty, " OSPF NSSA debugging is on%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001507
1508 return CMD_SUCCESS;
1509}
1510
1511/* Debug node. */
1512struct cmd_node debug_node =
1513{
1514 DEBUG_NODE,
hasso1d806282004-12-22 09:43:20 +00001515 "",
1516 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001517};
1518
paul4dadc292005-05-06 21:37:42 +00001519static int
paul718e3742002-12-13 20:15:29 +00001520config_write_debug (struct vty *vty)
1521{
1522 int write = 0;
1523 int i, r;
1524
hassoeb1ce602004-10-08 08:17:22 +00001525 const char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
1526 const char *detail_str[] = {"", " send", " recv", "", " detail",
paul718e3742002-12-13 20:15:29 +00001527 " send detail", " recv detail", " detail"};
1528
1529 /* debug ospf ism (status|events|timers). */
1530 if (IS_CONF_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
1531 vty_out (vty, "debug ospf ism%s", VTY_NEWLINE);
1532 else
1533 {
1534 if (IS_CONF_DEBUG_OSPF (ism, ISM_STATUS))
1535 vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE);
1536 if (IS_CONF_DEBUG_OSPF (ism, ISM_EVENTS))
1537 vty_out (vty, "debug ospf ism event%s", VTY_NEWLINE);
1538 if (IS_CONF_DEBUG_OSPF (ism, ISM_TIMERS))
1539 vty_out (vty, "debug ospf ism timer%s", VTY_NEWLINE);
1540 }
1541
1542 /* debug ospf nsm (status|events|timers). */
1543 if (IS_CONF_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
1544 vty_out (vty, "debug ospf nsm%s", VTY_NEWLINE);
1545 else
1546 {
1547 if (IS_CONF_DEBUG_OSPF (nsm, NSM_STATUS))
1548 vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE);
1549 if (IS_CONF_DEBUG_OSPF (nsm, NSM_EVENTS))
1550 vty_out (vty, "debug ospf nsm event%s", VTY_NEWLINE);
1551 if (IS_CONF_DEBUG_OSPF (nsm, NSM_TIMERS))
1552 vty_out (vty, "debug ospf nsm timer%s", VTY_NEWLINE);
1553 }
1554
1555 /* debug ospf lsa (generate|flooding|install|refresh). */
1556 if (IS_CONF_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
1557 vty_out (vty, "debug ospf lsa%s", VTY_NEWLINE);
1558 else
1559 {
1560 if (IS_CONF_DEBUG_OSPF (lsa, LSA_GENERATE))
1561 vty_out (vty, "debug ospf lsa generate%s", VTY_NEWLINE);
1562 if (IS_CONF_DEBUG_OSPF (lsa, LSA_FLOODING))
1563 vty_out (vty, "debug ospf lsa flooding%s", VTY_NEWLINE);
1564 if (IS_CONF_DEBUG_OSPF (lsa, LSA_INSTALL))
1565 vty_out (vty, "debug ospf lsa install%s", VTY_NEWLINE);
1566 if (IS_CONF_DEBUG_OSPF (lsa, LSA_REFRESH))
1567 vty_out (vty, "debug ospf lsa refresh%s", VTY_NEWLINE);
1568
1569 write = 1;
1570 }
1571
1572 /* debug ospf zebra (interface|redistribute). */
1573 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
1574 vty_out (vty, "debug ospf zebra%s", VTY_NEWLINE);
1575 else
1576 {
1577 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
1578 vty_out (vty, "debug ospf zebra interface%s", VTY_NEWLINE);
1579 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
1580 vty_out (vty, "debug ospf zebra redistribute%s", VTY_NEWLINE);
1581
1582 write = 1;
1583 }
1584
1585 /* debug ospf event. */
1586 if (IS_CONF_DEBUG_OSPF (event, EVENT) == OSPF_DEBUG_EVENT)
1587 {
1588 vty_out (vty, "debug ospf event%s", VTY_NEWLINE);
1589 write = 1;
1590 }
1591
1592 /* debug ospf nssa. */
1593 if (IS_CONF_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
1594 {
1595 vty_out (vty, "debug ospf nssa%s", VTY_NEWLINE);
1596 write = 1;
1597 }
1598
1599 /* debug ospf packet all detail. */
1600 r = OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL;
1601 for (i = 0; i < 5; i++)
1602 r &= conf_debug_ospf_packet[i] & (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL);
1603 if (r == (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL))
1604 {
1605 vty_out (vty, "debug ospf packet all detail%s", VTY_NEWLINE);
1606 return 1;
1607 }
1608
1609 /* debug ospf packet all. */
1610 r = OSPF_DEBUG_SEND_RECV;
1611 for (i = 0; i < 5; i++)
1612 r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV;
1613 if (r == OSPF_DEBUG_SEND_RECV)
1614 {
1615 vty_out (vty, "debug ospf packet all%s", VTY_NEWLINE);
1616 for (i = 0; i < 5; i++)
1617 if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL)
1618 vty_out (vty, "debug ospf packet %s detail%s",
1619 type_str[i],
1620 VTY_NEWLINE);
1621 return 1;
1622 }
1623
1624 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1625 (send|recv) (detail). */
1626 for (i = 0; i < 5; i++)
1627 {
1628 if (conf_debug_ospf_packet[i] == 0)
1629 continue;
1630
1631 vty_out (vty, "debug ospf packet %s%s%s",
1632 type_str[i], detail_str[conf_debug_ospf_packet[i]],
1633 VTY_NEWLINE);
1634 write = 1;
1635 }
1636
1637 return write;
1638}
1639
1640/* Initialize debug commands. */
1641void
1642debug_init ()
1643{
1644 install_node (&debug_node, config_write_debug);
1645
1646 install_element (ENABLE_NODE, &show_debugging_ospf_cmd);
1647 install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_detail_cmd);
1648 install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_cmd);
1649 install_element (ENABLE_NODE, &debug_ospf_packet_all_cmd);
1650 install_element (ENABLE_NODE, &debug_ospf_ism_sub_cmd);
1651 install_element (ENABLE_NODE, &debug_ospf_ism_cmd);
1652 install_element (ENABLE_NODE, &debug_ospf_nsm_sub_cmd);
1653 install_element (ENABLE_NODE, &debug_ospf_nsm_cmd);
1654 install_element (ENABLE_NODE, &debug_ospf_lsa_sub_cmd);
1655 install_element (ENABLE_NODE, &debug_ospf_lsa_cmd);
1656 install_element (ENABLE_NODE, &debug_ospf_zebra_sub_cmd);
1657 install_element (ENABLE_NODE, &debug_ospf_zebra_cmd);
1658 install_element (ENABLE_NODE, &debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001659 install_element (ENABLE_NODE, &debug_ospf_nssa_cmd);
paul718e3742002-12-13 20:15:29 +00001660 install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
1661 install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_cmd);
1662 install_element (ENABLE_NODE, &no_debug_ospf_packet_all_cmd);
1663 install_element (ENABLE_NODE, &no_debug_ospf_ism_sub_cmd);
1664 install_element (ENABLE_NODE, &no_debug_ospf_ism_cmd);
1665 install_element (ENABLE_NODE, &no_debug_ospf_nsm_sub_cmd);
1666 install_element (ENABLE_NODE, &no_debug_ospf_nsm_cmd);
1667 install_element (ENABLE_NODE, &no_debug_ospf_lsa_sub_cmd);
1668 install_element (ENABLE_NODE, &no_debug_ospf_lsa_cmd);
1669 install_element (ENABLE_NODE, &no_debug_ospf_zebra_sub_cmd);
1670 install_element (ENABLE_NODE, &no_debug_ospf_zebra_cmd);
1671 install_element (ENABLE_NODE, &no_debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001672 install_element (ENABLE_NODE, &no_debug_ospf_nssa_cmd);
paul718e3742002-12-13 20:15:29 +00001673
1674 install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_detail_cmd);
1675 install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_cmd);
1676 install_element (CONFIG_NODE, &debug_ospf_packet_all_cmd);
1677 install_element (CONFIG_NODE, &debug_ospf_ism_sub_cmd);
1678 install_element (CONFIG_NODE, &debug_ospf_ism_cmd);
1679 install_element (CONFIG_NODE, &debug_ospf_nsm_sub_cmd);
1680 install_element (CONFIG_NODE, &debug_ospf_nsm_cmd);
1681 install_element (CONFIG_NODE, &debug_ospf_lsa_sub_cmd);
1682 install_element (CONFIG_NODE, &debug_ospf_lsa_cmd);
1683 install_element (CONFIG_NODE, &debug_ospf_zebra_sub_cmd);
1684 install_element (CONFIG_NODE, &debug_ospf_zebra_cmd);
1685 install_element (CONFIG_NODE, &debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001686 install_element (CONFIG_NODE, &debug_ospf_nssa_cmd);
paul718e3742002-12-13 20:15:29 +00001687 install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
1688 install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_cmd);
1689 install_element (CONFIG_NODE, &no_debug_ospf_packet_all_cmd);
1690 install_element (CONFIG_NODE, &no_debug_ospf_ism_sub_cmd);
1691 install_element (CONFIG_NODE, &no_debug_ospf_ism_cmd);
1692 install_element (CONFIG_NODE, &no_debug_ospf_nsm_sub_cmd);
1693 install_element (CONFIG_NODE, &no_debug_ospf_nsm_cmd);
1694 install_element (CONFIG_NODE, &no_debug_ospf_lsa_sub_cmd);
1695 install_element (CONFIG_NODE, &no_debug_ospf_lsa_cmd);
1696 install_element (CONFIG_NODE, &no_debug_ospf_zebra_sub_cmd);
1697 install_element (CONFIG_NODE, &no_debug_ospf_zebra_cmd);
1698 install_element (CONFIG_NODE, &no_debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001699 install_element (CONFIG_NODE, &no_debug_ospf_nssa_cmd);
paul718e3742002-12-13 20:15:29 +00001700}