blob: be9fa2a75b5c7adf7bb78eb63204da0aaabf203d [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
Stephen Hemminger7ba82f72009-05-15 10:47:45 -070045const struct message ospf_ism_state_msg[] =
paul718e3742002-12-13 20:15:29 +000046{
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};
Stephen Hemminger7ba82f72009-05-15 10:47:45 -070056const int ospf_ism_state_msg_max = OSPF_ISM_STATE_MAX;
paul718e3742002-12-13 20:15:29 +000057
Stephen Hemminger7ba82f72009-05-15 10:47:45 -070058const struct message ospf_nsm_state_msg[] =
paul718e3742002-12-13 20:15:29 +000059{
60 { NSM_DependUpon, "DependUpon" },
Paul Jakma1f2c2742006-07-10 07:45:13 +000061 { NSM_Deleted, "Deleted" },
paul718e3742002-12-13 20:15:29 +000062 { NSM_Down, "Down" },
63 { NSM_Attempt, "Attempt" },
64 { NSM_Init, "Init" },
65 { NSM_TwoWay, "2-Way" },
66 { NSM_ExStart, "ExStart" },
67 { NSM_Exchange, "Exchange" },
68 { NSM_Loading, "Loading" },
69 { NSM_Full, "Full" },
70};
Stephen Hemminger7ba82f72009-05-15 10:47:45 -070071const int ospf_nsm_state_msg_max = OSPF_NSM_STATE_MAX;
paul718e3742002-12-13 20:15:29 +000072
Stephen Hemminger7ba82f72009-05-15 10:47:45 -070073const struct message ospf_lsa_type_msg[] =
paul718e3742002-12-13 20:15:29 +000074{
75 { OSPF_UNKNOWN_LSA, "unknown" },
76 { OSPF_ROUTER_LSA, "router-LSA" },
77 { OSPF_NETWORK_LSA, "network-LSA" },
78 { OSPF_SUMMARY_LSA, "summary-LSA" },
79 { OSPF_ASBR_SUMMARY_LSA, "summary-LSA" },
80 { OSPF_AS_EXTERNAL_LSA, "AS-external-LSA" },
81 { OSPF_GROUP_MEMBER_LSA, "GROUP MEMBER LSA" },
82 { OSPF_AS_NSSA_LSA, "NSSA-LSA" },
83 { 8, "Type-8 LSA" },
84 { OSPF_OPAQUE_LINK_LSA, "Link-Local Opaque-LSA" },
85 { OSPF_OPAQUE_AREA_LSA, "Area-Local Opaque-LSA" },
86 { OSPF_OPAQUE_AS_LSA, "AS-external Opaque-LSA" },
87};
Stephen Hemminger7ba82f72009-05-15 10:47:45 -070088const int ospf_lsa_type_msg_max = OSPF_MAX_LSA;
paul718e3742002-12-13 20:15:29 +000089
Stephen Hemminger7ba82f72009-05-15 10:47:45 -070090const struct message ospf_link_state_id_type_msg[] =
paul718e3742002-12-13 20:15:29 +000091{
92 { OSPF_UNKNOWN_LSA, "(unknown)" },
93 { OSPF_ROUTER_LSA, "" },
94 { OSPF_NETWORK_LSA, "(address of Designated Router)" },
95 { OSPF_SUMMARY_LSA, "(summary Network Number)" },
96 { OSPF_ASBR_SUMMARY_LSA, "(AS Boundary Router address)" },
97 { OSPF_AS_EXTERNAL_LSA, "(External Network Number)" },
98 { OSPF_GROUP_MEMBER_LSA, "(Group membership information)" },
99 { OSPF_AS_NSSA_LSA, "(External Network Number for NSSA)" },
100 { 8, "(Type-8 LSID)" },
101 { OSPF_OPAQUE_LINK_LSA, "(Link-Local Opaque-Type/ID)" },
102 { OSPF_OPAQUE_AREA_LSA, "(Area-Local Opaque-Type/ID)" },
103 { OSPF_OPAQUE_AS_LSA, "(AS-external Opaque-Type/ID)" },
104};
Stephen Hemminger7ba82f72009-05-15 10:47:45 -0700105const int ospf_link_state_id_type_msg_max = OSPF_MAX_LSA;
paul718e3742002-12-13 20:15:29 +0000106
Stephen Hemminger7ba82f72009-05-15 10:47:45 -0700107const struct message ospf_network_type_msg[] =
paul718e3742002-12-13 20:15:29 +0000108{
109 { OSPF_IFTYPE_NONE, "NONE" },
110 { OSPF_IFTYPE_POINTOPOINT, "Point-to-Point" },
111 { OSPF_IFTYPE_BROADCAST, "Broadcast" },
112 { OSPF_IFTYPE_NBMA, "NBMA" },
113 { OSPF_IFTYPE_POINTOMULTIPOINT, "Point-to-MultiPoint" },
114 { OSPF_IFTYPE_VIRTUALLINK, "Virtual-Link" },
115};
Stephen Hemminger7ba82f72009-05-15 10:47:45 -0700116const int ospf_network_type_msg_max = OSPF_IFTYPE_MAX;
paul718e3742002-12-13 20:15:29 +0000117
Denis Ovsienkoef1b78c2012-02-26 17:00:57 +0400118/* AuType */
119const struct message ospf_auth_type_str[] =
120{
121 { OSPF_AUTH_NULL, "Null" },
122 { OSPF_AUTH_SIMPLE, "Simple" },
123 { OSPF_AUTH_CRYPTOGRAPHIC, "Cryptographic" },
124};
125const size_t ospf_auth_type_str_max = sizeof (ospf_auth_type_str) /
126 sizeof (ospf_auth_type_str[0]);
127
paul718e3742002-12-13 20:15:29 +0000128/* Configuration debug option variables. */
129unsigned long conf_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
130unsigned long conf_debug_ospf_event = 0;
131unsigned long conf_debug_ospf_ism = 0;
132unsigned long conf_debug_ospf_nsm = 0;
133unsigned long conf_debug_ospf_lsa = 0;
134unsigned long conf_debug_ospf_zebra = 0;
135unsigned long conf_debug_ospf_nssa = 0;
Olivier Dugeon29a14012016-04-19 18:42:40 +0200136unsigned long conf_debug_ospf_te = 0;
paul718e3742002-12-13 20:15:29 +0000137
138/* Enable debug option variables -- valid only session. */
139unsigned long term_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
140unsigned long term_debug_ospf_event = 0;
141unsigned long term_debug_ospf_ism = 0;
142unsigned long term_debug_ospf_nsm = 0;
143unsigned long term_debug_ospf_lsa = 0;
144unsigned long term_debug_ospf_zebra = 0;
145unsigned long term_debug_ospf_nssa = 0;
Olivier Dugeon29a14012016-04-19 18:42:40 +0200146unsigned long term_debug_ospf_te = 0;
David Lamparter6b0655a2014-06-04 06:53:35 +0200147
ajsf52d13c2005-10-01 17:38:06 +0000148
149const char *
150ospf_redist_string(u_int route_type)
151{
152 return (route_type == ZEBRA_ROUTE_MAX) ?
153 "Default" : zebra_route_string(route_type);
154}
155
paul718e3742002-12-13 20:15:29 +0000156#define OSPF_AREA_STRING_MAXLEN 16
hassoeb1ce602004-10-08 08:17:22 +0000157const char *
paul718e3742002-12-13 20:15:29 +0000158ospf_area_name_string (struct ospf_area *area)
159{
160 static char buf[OSPF_AREA_STRING_MAXLEN] = "";
161 u_int32_t area_id;
162
163 if (!area)
164 return "-";
165
166 area_id = ntohl (area->area_id.s_addr);
167 snprintf (buf, OSPF_AREA_STRING_MAXLEN, "%d.%d.%d.%d",
168 (area_id >> 24) & 0xff, (area_id >> 16) & 0xff,
169 (area_id >> 8) & 0xff, area_id & 0xff);
170 return buf;
171}
172
173#define OSPF_AREA_DESC_STRING_MAXLEN 23
hassoeb1ce602004-10-08 08:17:22 +0000174const char *
paul718e3742002-12-13 20:15:29 +0000175ospf_area_desc_string (struct ospf_area *area)
176{
177 static char buf[OSPF_AREA_DESC_STRING_MAXLEN] = "";
178 u_char type;
179
180 if (!area)
181 return "(incomplete)";
182
183 type = area->external_routing;
184 switch (type)
185 {
186 case OSPF_AREA_NSSA:
187 snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [NSSA]",
188 ospf_area_name_string (area));
189 break;
190 case OSPF_AREA_STUB:
191 snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [Stub]",
192 ospf_area_name_string (area));
193 break;
194 default:
195 return ospf_area_name_string (area);
paul718e3742002-12-13 20:15:29 +0000196 }
197
198 return buf;
199}
200
201#define OSPF_IF_STRING_MAXLEN 40
hassoeb1ce602004-10-08 08:17:22 +0000202const char *
paul718e3742002-12-13 20:15:29 +0000203ospf_if_name_string (struct ospf_interface *oi)
204{
205 static char buf[OSPF_IF_STRING_MAXLEN] = "";
206 u_int32_t ifaddr;
207
208 if (!oi)
209 return "inactive";
210
211 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
212 return oi->ifp->name;
213
214 ifaddr = ntohl (oi->address->u.prefix4.s_addr);
215 snprintf (buf, OSPF_IF_STRING_MAXLEN,
216 "%s:%d.%d.%d.%d", oi->ifp->name,
217 (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
218 (ifaddr >> 8) & 0xff, ifaddr & 0xff);
219 return buf;
220}
221
David Lamparter6b0655a2014-06-04 06:53:35 +0200222
paul718e3742002-12-13 20:15:29 +0000223void
224ospf_nbr_state_message (struct ospf_neighbor *nbr, char *buf, size_t size)
225{
226 int state;
227 struct ospf_interface *oi = nbr->oi;
228
229 if (IPV4_ADDR_SAME (&DR (oi), &nbr->address.u.prefix4))
230 state = ISM_DR;
231 else if (IPV4_ADDR_SAME (&BDR (oi), &nbr->address.u.prefix4))
232 state = ISM_Backup;
233 else
234 state = ISM_DROther;
235
236 memset (buf, 0, size);
237
238 snprintf (buf, size, "%s/%s",
239 LOOKUP (ospf_nsm_state_msg, nbr->state),
240 LOOKUP (ospf_ism_state_msg, state));
241}
242
hassoeb1ce602004-10-08 08:17:22 +0000243const char *
pauld24f6e22005-10-21 09:23:12 +0000244ospf_timeval_dump (struct timeval *t, char *buf, size_t size)
paul718e3742002-12-13 20:15:29 +0000245{
pauld24f6e22005-10-21 09:23:12 +0000246 /* Making formatted timer strings. */
247#define MINUTE_IN_SECONDS 60
248#define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
249#define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
250#define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
Dinesh G Dutt50f38b32014-09-30 12:53:28 -0700251 unsigned long w, d, h, m, s, ms, us;
pauld24f6e22005-10-21 09:23:12 +0000252
paul718e3742002-12-13 20:15:29 +0000253 if (!t)
254 return "inactive";
pauld24f6e22005-10-21 09:23:12 +0000255
Dinesh G Dutt50f38b32014-09-30 12:53:28 -0700256 w = d = h = m = s = ms = us = 0;
paul718e3742002-12-13 20:15:29 +0000257 memset (buf, 0, size);
Dinesh G Dutt50f38b32014-09-30 12:53:28 -0700258
259 us = t->tv_usec;
260 if (us >= 1000)
261 {
262 ms = us / 1000;
263 us %= 1000;
264 }
265
paulf9ad9372005-10-21 00:45:17 +0000266 if (ms >= 1000)
paul718e3742002-12-13 20:15:29 +0000267 {
paulea4ffc92005-10-21 20:04:41 +0000268 t->tv_sec += ms / 1000;
269 ms %= 1000;
paulf9ad9372005-10-21 00:45:17 +0000270 }
pauld24f6e22005-10-21 09:23:12 +0000271
272 if (t->tv_sec > WEEK_IN_SECONDS)
paulf9ad9372005-10-21 00:45:17 +0000273 {
pauld24f6e22005-10-21 09:23:12 +0000274 w = t->tv_sec / WEEK_IN_SECONDS;
275 t->tv_sec -= w * WEEK_IN_SECONDS;
paul718e3742002-12-13 20:15:29 +0000276 }
pauld24f6e22005-10-21 09:23:12 +0000277
278 if (t->tv_sec > DAY_IN_SECONDS)
paul718e3742002-12-13 20:15:29 +0000279 {
pauld24f6e22005-10-21 09:23:12 +0000280 d = t->tv_sec / DAY_IN_SECONDS;
281 t->tv_sec -= d * DAY_IN_SECONDS;
paul718e3742002-12-13 20:15:29 +0000282 }
pauld24f6e22005-10-21 09:23:12 +0000283
284 if (t->tv_sec >= HOUR_IN_SECONDS)
285 {
286 h = t->tv_sec / HOUR_IN_SECONDS;
287 t->tv_sec -= h * HOUR_IN_SECONDS;
288 }
289
290 if (t->tv_sec >= MINUTE_IN_SECONDS)
291 {
292 m = t->tv_sec / MINUTE_IN_SECONDS;
293 t->tv_sec -= m * MINUTE_IN_SECONDS;
294 }
295
296 if (w > 99)
297 snprintf (buf, size, "%ldw%1ldd", w, d);
298 else if (w)
299 snprintf (buf, size, "%ldw%1ldd%02ldh", w, d, h);
300 else if (d)
301 snprintf (buf, size, "%1ldd%02ldh%02ldm", d, h, m);
302 else if (h)
David Lamparteref008d22015-03-03 08:48:11 +0100303 snprintf (buf, size, "%ldh%02ldm%02lds", h, m, (long)t->tv_sec);
pauld24f6e22005-10-21 09:23:12 +0000304 else if (m)
David Lamparteref008d22015-03-03 08:48:11 +0100305 snprintf (buf, size, "%ldm%02lds", m, (long)t->tv_sec);
Dinesh G Dutt50f38b32014-09-30 12:53:28 -0700306 else if (ms)
David Lamparteref008d22015-03-03 08:48:11 +0100307 snprintf (buf, size, "%ld.%03lds", (long)t->tv_sec, ms);
Dinesh G Dutt50f38b32014-09-30 12:53:28 -0700308 else
David Lamparteref008d22015-03-03 08:48:11 +0100309 snprintf (buf, size, "%ld usecs", (long)t->tv_usec);
Dinesh G Dutt50f38b32014-09-30 12:53:28 -0700310
paul718e3742002-12-13 20:15:29 +0000311 return buf;
312}
313
pauld24f6e22005-10-21 09:23:12 +0000314const char *
315ospf_timer_dump (struct thread *t, char *buf, size_t size)
316{
317 struct timeval result;
pauld24f6e22005-10-21 09:23:12 +0000318 if (!t)
319 return "inactive";
320
Paul Jakma2518efd2006-08-27 06:49:29 +0000321 result = tv_sub (t->u.sands, recent_relative_time());
pauld24f6e22005-10-21 09:23:12 +0000322 return ospf_timeval_dump (&result, buf, size);
323}
324
paul718e3742002-12-13 20:15:29 +0000325#define OSPF_OPTION_STR_MAXLEN 24
326
327char *
328ospf_options_dump (u_char options)
329{
330 static char buf[OSPF_OPTION_STR_MAXLEN];
331
Olivier Dugeon29a14012016-04-19 18:42:40 +0200332 snprintf (buf, OSPF_OPTION_STR_MAXLEN, "*|%s|%s|%s|%s|%s|%s|%s",
paul718e3742002-12-13 20:15:29 +0000333 (options & OSPF_OPTION_O) ? "O" : "-",
334 (options & OSPF_OPTION_DC) ? "DC" : "-",
335 (options & OSPF_OPTION_EA) ? "EA" : "-",
336 (options & OSPF_OPTION_NP) ? "N/P" : "-",
337 (options & OSPF_OPTION_MC) ? "MC" : "-",
Olivier Dugeon29a14012016-04-19 18:42:40 +0200338 (options & OSPF_OPTION_E) ? "E" : "-",
339 (options & OSPF_OPTION_MT) ? "M/T" : "-");
paul718e3742002-12-13 20:15:29 +0000340
341 return buf;
342}
343
paul4dadc292005-05-06 21:37:42 +0000344static void
paul718e3742002-12-13 20:15:29 +0000345ospf_packet_hello_dump (struct stream *s, u_int16_t length)
346{
347 struct ospf_hello *hello;
348 int i;
349
350 hello = (struct ospf_hello *) STREAM_PNT (s);
351
ajs60925302004-12-08 17:45:02 +0000352 zlog_debug ("Hello");
353 zlog_debug (" NetworkMask %s", inet_ntoa (hello->network_mask));
354 zlog_debug (" HelloInterval %d", ntohs (hello->hello_interval));
355 zlog_debug (" Options %d (%s)", hello->options,
paul718e3742002-12-13 20:15:29 +0000356 ospf_options_dump (hello->options));
ajs60925302004-12-08 17:45:02 +0000357 zlog_debug (" RtrPriority %d", hello->priority);
358 zlog_debug (" RtrDeadInterval %ld", (u_long)ntohl (hello->dead_interval));
359 zlog_debug (" DRouter %s", inet_ntoa (hello->d_router));
360 zlog_debug (" BDRouter %s", inet_ntoa (hello->bd_router));
paul718e3742002-12-13 20:15:29 +0000361
362 length -= OSPF_HEADER_SIZE + OSPF_HELLO_MIN_SIZE;
ajs60925302004-12-08 17:45:02 +0000363 zlog_debug (" # Neighbors %d", length / 4);
paul718e3742002-12-13 20:15:29 +0000364 for (i = 0; length > 0; i++, length -= sizeof (struct in_addr))
ajs60925302004-12-08 17:45:02 +0000365 zlog_debug (" Neighbor %s", inet_ntoa (hello->neighbors[i]));
paul718e3742002-12-13 20:15:29 +0000366}
367
paul4dadc292005-05-06 21:37:42 +0000368static char *
paul718e3742002-12-13 20:15:29 +0000369ospf_dd_flags_dump (u_char flags, char *buf, size_t size)
370{
371 memset (buf, 0, size);
372
373 snprintf (buf, size, "%s|%s|%s",
374 (flags & OSPF_DD_FLAG_I) ? "I" : "-",
375 (flags & OSPF_DD_FLAG_M) ? "M" : "-",
376 (flags & OSPF_DD_FLAG_MS) ? "MS" : "-");
377
378 return buf;
379}
380
381void
382ospf_lsa_header_dump (struct lsa_header *lsah)
383{
hassoeb1ce602004-10-08 08:17:22 +0000384 const char *lsah_type = LOOKUP (ospf_lsa_type_msg, lsah->type);
paul0c2be262004-05-31 14:16:54 +0000385
ajs60925302004-12-08 17:45:02 +0000386 zlog_debug (" LSA Header");
387 zlog_debug (" LS age %d", ntohs (lsah->ls_age));
388 zlog_debug (" Options %d (%s)", lsah->options,
paul718e3742002-12-13 20:15:29 +0000389 ospf_options_dump (lsah->options));
ajs60925302004-12-08 17:45:02 +0000390 zlog_debug (" LS type %d (%s)", lsah->type,
paul553ff112004-06-06 09:41:00 +0000391 (lsah->type ? lsah_type : "unknown type"));
ajs60925302004-12-08 17:45:02 +0000392 zlog_debug (" Link State ID %s", inet_ntoa (lsah->id));
393 zlog_debug (" Advertising Router %s", inet_ntoa (lsah->adv_router));
394 zlog_debug (" LS sequence number 0x%lx", (u_long)ntohl (lsah->ls_seqnum));
395 zlog_debug (" LS checksum 0x%x", ntohs (lsah->checksum));
396 zlog_debug (" length %d", ntohs (lsah->length));
paul718e3742002-12-13 20:15:29 +0000397}
398
paul4dadc292005-05-06 21:37:42 +0000399static char *
paul718e3742002-12-13 20:15:29 +0000400ospf_router_lsa_flags_dump (u_char flags, char *buf, size_t size)
401{
402 memset (buf, 0, size);
403
404 snprintf (buf, size, "%s|%s|%s",
405 (flags & ROUTER_LSA_VIRTUAL) ? "V" : "-",
406 (flags & ROUTER_LSA_EXTERNAL) ? "E" : "-",
407 (flags & ROUTER_LSA_BORDER) ? "B" : "-");
408
409 return buf;
410}
411
paul4dadc292005-05-06 21:37:42 +0000412static void
paul718e3742002-12-13 20:15:29 +0000413ospf_router_lsa_dump (struct stream *s, u_int16_t length)
414{
415 char buf[BUFSIZ];
416 struct router_lsa *rl;
417 int i, len;
418
419 rl = (struct router_lsa *) STREAM_PNT (s);
420
ajs60925302004-12-08 17:45:02 +0000421 zlog_debug (" Router-LSA");
422 zlog_debug (" flags %s",
paul718e3742002-12-13 20:15:29 +0000423 ospf_router_lsa_flags_dump (rl->flags, buf, BUFSIZ));
ajs60925302004-12-08 17:45:02 +0000424 zlog_debug (" # links %d", ntohs (rl->links));
paul718e3742002-12-13 20:15:29 +0000425
426 len = ntohs (rl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
427 for (i = 0; len > 0; i++)
428 {
ajs60925302004-12-08 17:45:02 +0000429 zlog_debug (" Link ID %s", inet_ntoa (rl->link[i].link_id));
430 zlog_debug (" Link Data %s", inet_ntoa (rl->link[i].link_data));
431 zlog_debug (" Type %d", (u_char) rl->link[i].type);
432 zlog_debug (" TOS %d", (u_char) rl->link[i].tos);
433 zlog_debug (" metric %d", ntohs (rl->link[i].metric));
paul718e3742002-12-13 20:15:29 +0000434
435 len -= 12;
436 }
437}
438
paul4dadc292005-05-06 21:37:42 +0000439static void
paul718e3742002-12-13 20:15:29 +0000440ospf_network_lsa_dump (struct stream *s, u_int16_t length)
441{
442 struct network_lsa *nl;
443 int i, cnt;
444
445 nl = (struct network_lsa *) STREAM_PNT (s);
446 cnt = (ntohs (nl->header.length) - (OSPF_LSA_HEADER_SIZE + 4)) / 4;
447
ajs60925302004-12-08 17:45:02 +0000448 zlog_debug (" Network-LSA");
paul718e3742002-12-13 20:15:29 +0000449 /*
ajs60925302004-12-08 17:45:02 +0000450 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
451 zlog_debug ("Network-LSA size %d",
paul718e3742002-12-13 20:15:29 +0000452 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
453 */
ajs60925302004-12-08 17:45:02 +0000454 zlog_debug (" Network Mask %s", inet_ntoa (nl->mask));
455 zlog_debug (" # Attached Routers %d", cnt);
paul718e3742002-12-13 20:15:29 +0000456 for (i = 0; i < cnt; i++)
ajs60925302004-12-08 17:45:02 +0000457 zlog_debug (" Attached Router %s", inet_ntoa (nl->routers[i]));
paul718e3742002-12-13 20:15:29 +0000458}
459
paul4dadc292005-05-06 21:37:42 +0000460static void
paul718e3742002-12-13 20:15:29 +0000461ospf_summary_lsa_dump (struct stream *s, u_int16_t length)
462{
463 struct summary_lsa *sl;
464 int size;
465 int i;
466
467 sl = (struct summary_lsa *) STREAM_PNT (s);
468
ajs60925302004-12-08 17:45:02 +0000469 zlog_debug (" Summary-LSA");
470 zlog_debug (" Network Mask %s", inet_ntoa (sl->mask));
paul718e3742002-12-13 20:15:29 +0000471
472 size = ntohs (sl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
473 for (i = 0; size > 0; size -= 4, i++)
ajs60925302004-12-08 17:45:02 +0000474 zlog_debug (" TOS=%d metric %d", sl->tos,
paul718e3742002-12-13 20:15:29 +0000475 GET_METRIC (sl->metric));
476}
477
paul4dadc292005-05-06 21:37:42 +0000478static void
paul718e3742002-12-13 20:15:29 +0000479ospf_as_external_lsa_dump (struct stream *s, u_int16_t length)
480{
481 struct as_external_lsa *al;
482 int size;
483 int i;
484
485 al = (struct as_external_lsa *) STREAM_PNT (s);
ajs60925302004-12-08 17:45:02 +0000486 zlog_debug (" %s", ospf_lsa_type_msg[al->header.type].str);
487 zlog_debug (" Network Mask %s", inet_ntoa (al->mask));
paul718e3742002-12-13 20:15:29 +0000488
489 size = ntohs (al->header.length) - OSPF_LSA_HEADER_SIZE -4;
490 for (i = 0; size > 0; size -= 12, i++)
491 {
ajs60925302004-12-08 17:45:02 +0000492 zlog_debug (" bit %s TOS=%d metric %d",
paul718e3742002-12-13 20:15:29 +0000493 IS_EXTERNAL_METRIC (al->e[i].tos) ? "E" : "-",
494 al->e[i].tos & 0x7f, GET_METRIC (al->e[i].metric));
ajs60925302004-12-08 17:45:02 +0000495 zlog_debug (" Forwarding address %s", inet_ntoa (al->e[i].fwd_addr));
Christian Frankeddc160c2016-10-01 20:42:34 +0200496 zlog_debug (" External Route Tag %u", al->e[i].route_tag);
paul718e3742002-12-13 20:15:29 +0000497 }
498}
499
paul4dadc292005-05-06 21:37:42 +0000500static void
paul718e3742002-12-13 20:15:29 +0000501ospf_lsa_header_list_dump (struct stream *s, u_int16_t length)
502{
503 struct lsa_header *lsa;
504
ajs60925302004-12-08 17:45:02 +0000505 zlog_debug (" # LSA Headers %d", length / OSPF_LSA_HEADER_SIZE);
paul718e3742002-12-13 20:15:29 +0000506
507 /* LSA Headers. */
508 while (length > 0)
509 {
510 lsa = (struct lsa_header *) STREAM_PNT (s);
511 ospf_lsa_header_dump (lsa);
512
paul9985f832005-02-09 15:51:56 +0000513 stream_forward_getp (s, OSPF_LSA_HEADER_SIZE);
paul718e3742002-12-13 20:15:29 +0000514 length -= OSPF_LSA_HEADER_SIZE;
515 }
516}
517
paul4dadc292005-05-06 21:37:42 +0000518static void
paul718e3742002-12-13 20:15:29 +0000519ospf_packet_db_desc_dump (struct stream *s, u_int16_t length)
520{
521 struct ospf_db_desc *dd;
522 char dd_flags[8];
523
524 u_int32_t gp;
525
526 gp = stream_get_getp (s);
527 dd = (struct ospf_db_desc *) STREAM_PNT (s);
528
ajs60925302004-12-08 17:45:02 +0000529 zlog_debug ("Database Description");
530 zlog_debug (" Interface MTU %d", ntohs (dd->mtu));
531 zlog_debug (" Options %d (%s)", dd->options,
paul718e3742002-12-13 20:15:29 +0000532 ospf_options_dump (dd->options));
ajs60925302004-12-08 17:45:02 +0000533 zlog_debug (" Flags %d (%s)", dd->flags,
paul718e3742002-12-13 20:15:29 +0000534 ospf_dd_flags_dump (dd->flags, dd_flags, sizeof dd_flags));
ajs60925302004-12-08 17:45:02 +0000535 zlog_debug (" Sequence Number 0x%08lx", (u_long)ntohl (dd->dd_seqnum));
paul718e3742002-12-13 20:15:29 +0000536
537 length -= OSPF_HEADER_SIZE + OSPF_DB_DESC_MIN_SIZE;
538
paul9985f832005-02-09 15:51:56 +0000539 stream_forward_getp (s, OSPF_DB_DESC_MIN_SIZE);
paul718e3742002-12-13 20:15:29 +0000540
541 ospf_lsa_header_list_dump (s, length);
542
543 stream_set_getp (s, gp);
544}
545
paul4dadc292005-05-06 21:37:42 +0000546static void
paul718e3742002-12-13 20:15:29 +0000547ospf_packet_ls_req_dump (struct stream *s, u_int16_t length)
548{
549 u_int32_t sp;
550 u_int32_t ls_type;
551 struct in_addr ls_id;
552 struct in_addr adv_router;
553
554 sp = stream_get_getp (s);
555
556 length -= OSPF_HEADER_SIZE;
557
ajs60925302004-12-08 17:45:02 +0000558 zlog_debug ("Link State Request");
559 zlog_debug (" # Requests %d", length / 12);
paul718e3742002-12-13 20:15:29 +0000560
561 for (; length > 0; length -= 12)
562 {
563 ls_type = stream_getl (s);
564 ls_id.s_addr = stream_get_ipv4 (s);
565 adv_router.s_addr = stream_get_ipv4 (s);
566
ajs60925302004-12-08 17:45:02 +0000567 zlog_debug (" LS type %d", ls_type);
568 zlog_debug (" Link State ID %s", inet_ntoa (ls_id));
569 zlog_debug (" Advertising Router %s",
paul718e3742002-12-13 20:15:29 +0000570 inet_ntoa (adv_router));
571 }
572
573 stream_set_getp (s, sp);
574}
575
paul4dadc292005-05-06 21:37:42 +0000576static void
paul718e3742002-12-13 20:15:29 +0000577ospf_packet_ls_upd_dump (struct stream *s, u_int16_t length)
578{
579 u_int32_t sp;
580 struct lsa_header *lsa;
581 int lsa_len;
582 u_int32_t count;
583
584 length -= OSPF_HEADER_SIZE;
585
586 sp = stream_get_getp (s);
587
588 count = stream_getl (s);
589 length -= 4;
590
ajs60925302004-12-08 17:45:02 +0000591 zlog_debug ("Link State Update");
592 zlog_debug (" # LSAs %d", count);
paul718e3742002-12-13 20:15:29 +0000593
594 while (length > 0 && count > 0)
595 {
596 if (length < OSPF_HEADER_SIZE || length % 4 != 0)
597 {
ajs60925302004-12-08 17:45:02 +0000598 zlog_debug (" Remaining %d bytes; Incorrect length.", length);
paul718e3742002-12-13 20:15:29 +0000599 break;
600 }
601
602 lsa = (struct lsa_header *) STREAM_PNT (s);
603 lsa_len = ntohs (lsa->length);
604 ospf_lsa_header_dump (lsa);
605
606 switch (lsa->type)
607 {
608 case OSPF_ROUTER_LSA:
609 ospf_router_lsa_dump (s, length);
610 break;
611 case OSPF_NETWORK_LSA:
612 ospf_network_lsa_dump (s, length);
613 break;
614 case OSPF_SUMMARY_LSA:
615 case OSPF_ASBR_SUMMARY_LSA:
616 ospf_summary_lsa_dump (s, length);
617 break;
618 case OSPF_AS_EXTERNAL_LSA:
619 ospf_as_external_lsa_dump (s, length);
620 break;
paul718e3742002-12-13 20:15:29 +0000621 case OSPF_AS_NSSA_LSA:
pauld4a53d52003-07-12 21:30:57 +0000622 ospf_as_external_lsa_dump (s, length);
paul718e3742002-12-13 20:15:29 +0000623 break;
paul718e3742002-12-13 20:15:29 +0000624 case OSPF_OPAQUE_LINK_LSA:
625 case OSPF_OPAQUE_AREA_LSA:
626 case OSPF_OPAQUE_AS_LSA:
627 ospf_opaque_lsa_dump (s, length);
628 break;
paul718e3742002-12-13 20:15:29 +0000629 default:
630 break;
631 }
632
paul9985f832005-02-09 15:51:56 +0000633 stream_forward_getp (s, lsa_len);
paul718e3742002-12-13 20:15:29 +0000634 length -= lsa_len;
635 count--;
636 }
637
638 stream_set_getp (s, sp);
639}
640
paul4dadc292005-05-06 21:37:42 +0000641static void
paul718e3742002-12-13 20:15:29 +0000642ospf_packet_ls_ack_dump (struct stream *s, u_int16_t length)
643{
644 u_int32_t sp;
645
646 length -= OSPF_HEADER_SIZE;
647 sp = stream_get_getp (s);
648
ajs60925302004-12-08 17:45:02 +0000649 zlog_debug ("Link State Acknowledgment");
paul718e3742002-12-13 20:15:29 +0000650 ospf_lsa_header_list_dump (s, length);
651
652 stream_set_getp (s, sp);
653}
654
paul6b333612004-10-11 10:11:25 +0000655/* Expects header to be in host order */
paul718e3742002-12-13 20:15:29 +0000656void
paul6b333612004-10-11 10:11:25 +0000657ospf_ip_header_dump (struct ip *iph)
paul718e3742002-12-13 20:15:29 +0000658{
paul718e3742002-12-13 20:15:29 +0000659 /* IP Header dump. */
ajs60925302004-12-08 17:45:02 +0000660 zlog_debug ("ip_v %d", iph->ip_v);
661 zlog_debug ("ip_hl %d", iph->ip_hl);
662 zlog_debug ("ip_tos %d", iph->ip_tos);
663 zlog_debug ("ip_len %d", iph->ip_len);
664 zlog_debug ("ip_id %u", (u_int32_t) iph->ip_id);
665 zlog_debug ("ip_off %u", (u_int32_t) iph->ip_off);
666 zlog_debug ("ip_ttl %d", iph->ip_ttl);
667 zlog_debug ("ip_p %d", iph->ip_p);
668 zlog_debug ("ip_sum 0x%x", (u_int32_t) iph->ip_sum);
669 zlog_debug ("ip_src %s", inet_ntoa (iph->ip_src));
670 zlog_debug ("ip_dst %s", inet_ntoa (iph->ip_dst));
paul718e3742002-12-13 20:15:29 +0000671}
672
paul4dadc292005-05-06 21:37:42 +0000673static void
paul718e3742002-12-13 20:15:29 +0000674ospf_header_dump (struct ospf_header *ospfh)
675{
676 char buf[9];
Denis Ovsienkoef1b78c2012-02-26 17:00:57 +0400677 u_int16_t auth_type = ntohs (ospfh->auth_type);
paul718e3742002-12-13 20:15:29 +0000678
ajs60925302004-12-08 17:45:02 +0000679 zlog_debug ("Header");
680 zlog_debug (" Version %d", ospfh->version);
681 zlog_debug (" Type %d (%s)", ospfh->type,
Denis Ovsienko272ca1e2012-01-15 19:12:19 +0400682 LOOKUP (ospf_packet_type_str, ospfh->type));
ajs60925302004-12-08 17:45:02 +0000683 zlog_debug (" Packet Len %d", ntohs (ospfh->length));
684 zlog_debug (" Router ID %s", inet_ntoa (ospfh->router_id));
685 zlog_debug (" Area ID %s", inet_ntoa (ospfh->area_id));
686 zlog_debug (" Checksum 0x%x", ntohs (ospfh->checksum));
Denis Ovsienkoef1b78c2012-02-26 17:00:57 +0400687 zlog_debug (" AuType %s", LOOKUP (ospf_auth_type_str, auth_type));
paul718e3742002-12-13 20:15:29 +0000688
Denis Ovsienkoef1b78c2012-02-26 17:00:57 +0400689 switch (auth_type)
paul718e3742002-12-13 20:15:29 +0000690 {
691 case OSPF_AUTH_NULL:
692 break;
693 case OSPF_AUTH_SIMPLE:
694 memset (buf, 0, 9);
hassoc9e52be2004-09-26 16:09:34 +0000695 strncpy (buf, (char *) ospfh->u.auth_data, 8);
ajs60925302004-12-08 17:45:02 +0000696 zlog_debug (" Simple Password %s", buf);
paul718e3742002-12-13 20:15:29 +0000697 break;
698 case OSPF_AUTH_CRYPTOGRAPHIC:
ajs60925302004-12-08 17:45:02 +0000699 zlog_debug (" Cryptographic Authentication");
700 zlog_debug (" Key ID %d", ospfh->u.crypt.key_id);
701 zlog_debug (" Auth Data Len %d", ospfh->u.crypt.auth_data_len);
702 zlog_debug (" Sequence number %ld",
paul718e3742002-12-13 20:15:29 +0000703 (u_long)ntohl (ospfh->u.crypt.crypt_seqnum));
704 break;
705 default:
ajs60925302004-12-08 17:45:02 +0000706 zlog_debug ("* This is not supported authentication type");
paul718e3742002-12-13 20:15:29 +0000707 break;
708 }
709
710}
711
712void
713ospf_packet_dump (struct stream *s)
714{
715 struct ospf_header *ospfh;
716 unsigned long gp;
717
718 /* Preserve pointer. */
719 gp = stream_get_getp (s);
720
721 /* OSPF Header dump. */
722 ospfh = (struct ospf_header *) STREAM_PNT (s);
723
724 /* Until detail flag is set, return. */
725 if (!(term_debug_ospf_packet[ospfh->type - 1] & OSPF_DEBUG_DETAIL))
726 return;
727
728 /* Show OSPF header detail. */
729 ospf_header_dump (ospfh);
paul9985f832005-02-09 15:51:56 +0000730 stream_forward_getp (s, OSPF_HEADER_SIZE);
paul718e3742002-12-13 20:15:29 +0000731
732 switch (ospfh->type)
733 {
734 case OSPF_MSG_HELLO:
735 ospf_packet_hello_dump (s, ntohs (ospfh->length));
736 break;
737 case OSPF_MSG_DB_DESC:
738 ospf_packet_db_desc_dump (s, ntohs (ospfh->length));
739 break;
740 case OSPF_MSG_LS_REQ:
741 ospf_packet_ls_req_dump (s, ntohs (ospfh->length));
742 break;
743 case OSPF_MSG_LS_UPD:
744 ospf_packet_ls_upd_dump (s, ntohs (ospfh->length));
745 break;
746 case OSPF_MSG_LS_ACK:
747 ospf_packet_ls_ack_dump (s, ntohs (ospfh->length));
748 break;
749 default:
750 break;
751 }
752
753 stream_set_getp (s, gp);
754}
755
David Lamparter6b0655a2014-06-04 06:53:35 +0200756
paul718e3742002-12-13 20:15:29 +0000757/*
758 [no] debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)
759 [send|recv [detail]]
760*/
761DEFUN (debug_ospf_packet,
762 debug_ospf_packet_all_cmd,
763 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
764 DEBUG_STR
765 OSPF_STR
766 "OSPF packets\n"
767 "OSPF Hello\n"
768 "OSPF Database Description\n"
769 "OSPF Link State Request\n"
770 "OSPF Link State Update\n"
771 "OSPF Link State Acknowledgment\n"
772 "OSPF all packets\n")
773{
774 int type = 0;
775 int flag = 0;
776 int i;
777
778 assert (argc > 0);
779
780 /* Check packet type. */
781 if (strncmp (argv[0], "h", 1) == 0)
782 type = OSPF_DEBUG_HELLO;
783 else if (strncmp (argv[0], "d", 1) == 0)
784 type = OSPF_DEBUG_DB_DESC;
785 else if (strncmp (argv[0], "ls-r", 4) == 0)
786 type = OSPF_DEBUG_LS_REQ;
787 else if (strncmp (argv[0], "ls-u", 4) == 0)
788 type = OSPF_DEBUG_LS_UPD;
789 else if (strncmp (argv[0], "ls-a", 4) == 0)
790 type = OSPF_DEBUG_LS_ACK;
791 else if (strncmp (argv[0], "a", 1) == 0)
792 type = OSPF_DEBUG_ALL;
793
794 /* Default, both send and recv. */
795 if (argc == 1)
796 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV;
797
798 /* send or recv. */
799 if (argc >= 2)
800 {
801 if (strncmp (argv[1], "s", 1) == 0)
802 flag = OSPF_DEBUG_SEND;
803 else if (strncmp (argv[1], "r", 1) == 0)
804 flag = OSPF_DEBUG_RECV;
805 else if (strncmp (argv[1], "d", 1) == 0)
806 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
807 }
808
809 /* detail. */
810 if (argc == 3)
811 if (strncmp (argv[2], "d", 1) == 0)
812 flag |= OSPF_DEBUG_DETAIL;
813
814 for (i = 0; i < 5; i++)
815 if (type & (0x01 << i))
816 {
817 if (vty->node == CONFIG_NODE)
818 DEBUG_PACKET_ON (i, flag);
819 else
820 TERM_DEBUG_PACKET_ON (i, flag);
821 }
822
823 return CMD_SUCCESS;
824}
825
826ALIAS (debug_ospf_packet,
827 debug_ospf_packet_send_recv_cmd,
828 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
829 "Debugging functions\n"
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
842ALIAS (debug_ospf_packet,
843 debug_ospf_packet_send_recv_detail_cmd,
844 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
845 "Debugging functions\n"
846 "OSPF information\n"
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 "Packet sent\n"
855 "Packet received\n"
856 "Detail Information\n")
857
858
859DEFUN (no_debug_ospf_packet,
860 no_debug_ospf_packet_all_cmd,
861 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
862 NO_STR
863 DEBUG_STR
864 OSPF_STR
865 "OSPF packets\n"
866 "OSPF Hello\n"
867 "OSPF Database Description\n"
868 "OSPF Link State Request\n"
869 "OSPF Link State Update\n"
870 "OSPF Link State Acknowledgment\n"
871 "OSPF all packets\n")
872{
873 int type = 0;
874 int flag = 0;
875 int i;
876
877 assert (argc > 0);
878
879 /* Check packet type. */
880 if (strncmp (argv[0], "h", 1) == 0)
881 type = OSPF_DEBUG_HELLO;
882 else if (strncmp (argv[0], "d", 1) == 0)
883 type = OSPF_DEBUG_DB_DESC;
884 else if (strncmp (argv[0], "ls-r", 4) == 0)
885 type = OSPF_DEBUG_LS_REQ;
886 else if (strncmp (argv[0], "ls-u", 4) == 0)
887 type = OSPF_DEBUG_LS_UPD;
888 else if (strncmp (argv[0], "ls-a", 4) == 0)
889 type = OSPF_DEBUG_LS_ACK;
890 else if (strncmp (argv[0], "a", 1) == 0)
891 type = OSPF_DEBUG_ALL;
892
893 /* Default, both send and recv. */
894 if (argc == 1)
895 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL ;
896
897 /* send or recv. */
898 if (argc == 2)
899 {
900 if (strncmp (argv[1], "s", 1) == 0)
901 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_DETAIL;
902 else if (strncmp (argv[1], "r", 1) == 0)
903 flag = OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
904 else if (strncmp (argv[1], "d", 1) == 0)
Vystoropskyi, Sergiib075e872015-08-16 13:25:36 +0000905 flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
paul718e3742002-12-13 20:15:29 +0000906 }
907
908 /* detail. */
909 if (argc == 3)
910 if (strncmp (argv[2], "d", 1) == 0)
911 flag = OSPF_DEBUG_DETAIL;
912
913 for (i = 0; i < 5; i++)
914 if (type & (0x01 << i))
915 {
916 if (vty->node == CONFIG_NODE)
917 DEBUG_PACKET_OFF (i, flag);
918 else
919 TERM_DEBUG_PACKET_OFF (i, flag);
920 }
921
922#ifdef DEBUG
jardin6638c1a2005-10-01 00:08:54 +0000923 /*
paul718e3742002-12-13 20:15:29 +0000924 for (i = 0; i < 5; i++)
ajs60925302004-12-08 17:45:02 +0000925 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
jardin6638c1a2005-10-01 00:08:54 +0000926 */
paul718e3742002-12-13 20:15:29 +0000927#endif /* DEBUG */
928
929 return CMD_SUCCESS;
930}
931
932ALIAS (no_debug_ospf_packet,
933 no_debug_ospf_packet_send_recv_cmd,
934 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
935 NO_STR
936 "Debugging functions\n"
937 "OSPF information\n"
938 "OSPF packets\n"
939 "OSPF Hello\n"
940 "OSPF Database Description\n"
941 "OSPF Link State Request\n"
942 "OSPF Link State Update\n"
943 "OSPF Link State Acknowledgment\n"
944 "OSPF all packets\n"
945 "Packet sent\n"
946 "Packet received\n"
947 "Detail Information\n")
948
949ALIAS (no_debug_ospf_packet,
950 no_debug_ospf_packet_send_recv_detail_cmd,
951 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
952 NO_STR
953 "Debugging functions\n"
954 "OSPF information\n"
955 "OSPF packets\n"
956 "OSPF Hello\n"
957 "OSPF Database Description\n"
958 "OSPF Link State Request\n"
959 "OSPF Link State Update\n"
960 "OSPF Link State Acknowledgment\n"
961 "OSPF all packets\n"
962 "Packet sent\n"
963 "Packet received\n"
964 "Detail Information\n")
965
David Lamparter6b0655a2014-06-04 06:53:35 +0200966
paul718e3742002-12-13 20:15:29 +0000967DEFUN (debug_ospf_ism,
968 debug_ospf_ism_cmd,
969 "debug ospf ism",
970 DEBUG_STR
971 OSPF_STR
972 "OSPF Interface State Machine\n")
973{
974 if (vty->node == CONFIG_NODE)
975 {
976 if (argc == 0)
977 DEBUG_ON (ism, ISM);
978 else if (argc == 1)
979 {
980 if (strncmp (argv[0], "s", 1) == 0)
981 DEBUG_ON (ism, ISM_STATUS);
982 else if (strncmp (argv[0], "e", 1) == 0)
983 DEBUG_ON (ism, ISM_EVENTS);
984 else if (strncmp (argv[0], "t", 1) == 0)
985 DEBUG_ON (ism, ISM_TIMERS);
986 }
987
988 return CMD_SUCCESS;
989 }
990
991 /* ENABLE_NODE. */
992 if (argc == 0)
993 TERM_DEBUG_ON (ism, ISM);
994 else if (argc == 1)
995 {
996 if (strncmp (argv[0], "s", 1) == 0)
997 TERM_DEBUG_ON (ism, ISM_STATUS);
998 else if (strncmp (argv[0], "e", 1) == 0)
999 TERM_DEBUG_ON (ism, ISM_EVENTS);
1000 else if (strncmp (argv[0], "t", 1) == 0)
1001 TERM_DEBUG_ON (ism, ISM_TIMERS);
1002 }
1003
1004 return CMD_SUCCESS;
1005}
1006
1007ALIAS (debug_ospf_ism,
1008 debug_ospf_ism_sub_cmd,
1009 "debug ospf ism (status|events|timers)",
1010 DEBUG_STR
1011 OSPF_STR
1012 "OSPF Interface State Machine\n"
1013 "ISM Status Information\n"
1014 "ISM Event Information\n"
1015 "ISM TImer Information\n")
1016
1017DEFUN (no_debug_ospf_ism,
1018 no_debug_ospf_ism_cmd,
1019 "no debug ospf ism",
1020 NO_STR
1021 DEBUG_STR
1022 OSPF_STR
1023 "OSPF Interface State Machine")
1024{
1025 if (vty->node == CONFIG_NODE)
1026 {
1027 if (argc == 0)
1028 DEBUG_OFF (ism, ISM);
1029 else if (argc == 1)
1030 {
1031 if (strncmp (argv[0], "s", 1) == 0)
1032 DEBUG_OFF (ism, ISM_STATUS);
1033 else if (strncmp (argv[0], "e", 1) == 0)
1034 DEBUG_OFF (ism, ISM_EVENTS);
1035 else if (strncmp (argv[0], "t", 1) == 0)
1036 DEBUG_OFF (ism, ISM_TIMERS);
1037 }
1038 return CMD_SUCCESS;
1039 }
1040
1041 /* ENABLE_NODE. */
1042 if (argc == 0)
1043 TERM_DEBUG_OFF (ism, ISM);
1044 else if (argc == 1)
1045 {
1046 if (strncmp (argv[0], "s", 1) == 0)
1047 TERM_DEBUG_OFF (ism, ISM_STATUS);
1048 else if (strncmp (argv[0], "e", 1) == 0)
1049 TERM_DEBUG_OFF (ism, ISM_EVENTS);
1050 else if (strncmp (argv[0], "t", 1) == 0)
1051 TERM_DEBUG_OFF (ism, ISM_TIMERS);
1052 }
1053
1054 return CMD_SUCCESS;
1055}
1056
1057ALIAS (no_debug_ospf_ism,
1058 no_debug_ospf_ism_sub_cmd,
1059 "no debug ospf ism (status|events|timers)",
1060 NO_STR
1061 "Debugging functions\n"
1062 "OSPF information\n"
1063 "OSPF Interface State Machine\n"
1064 "ISM Status Information\n"
1065 "ISM Event Information\n"
1066 "ISM Timer Information\n")
1067
David Lamparter6b0655a2014-06-04 06:53:35 +02001068
paul718e3742002-12-13 20:15:29 +00001069DEFUN (debug_ospf_nsm,
1070 debug_ospf_nsm_cmd,
1071 "debug ospf nsm",
1072 DEBUG_STR
1073 OSPF_STR
1074 "OSPF Neighbor State Machine\n")
1075{
1076 if (vty->node == CONFIG_NODE)
1077 {
1078 if (argc == 0)
1079 DEBUG_ON (nsm, NSM);
1080 else if (argc == 1)
1081 {
1082 if (strncmp (argv[0], "s", 1) == 0)
1083 DEBUG_ON (nsm, NSM_STATUS);
1084 else if (strncmp (argv[0], "e", 1) == 0)
1085 DEBUG_ON (nsm, NSM_EVENTS);
1086 else if (strncmp (argv[0], "t", 1) == 0)
1087 DEBUG_ON (nsm, NSM_TIMERS);
1088 }
1089
1090 return CMD_SUCCESS;
1091 }
1092
1093 /* ENABLE_NODE. */
1094 if (argc == 0)
1095 TERM_DEBUG_ON (nsm, NSM);
1096 else if (argc == 1)
1097 {
1098 if (strncmp (argv[0], "s", 1) == 0)
1099 TERM_DEBUG_ON (nsm, NSM_STATUS);
1100 else if (strncmp (argv[0], "e", 1) == 0)
1101 TERM_DEBUG_ON (nsm, NSM_EVENTS);
1102 else if (strncmp (argv[0], "t", 1) == 0)
1103 TERM_DEBUG_ON (nsm, NSM_TIMERS);
1104 }
1105
1106 return CMD_SUCCESS;
1107}
1108
1109ALIAS (debug_ospf_nsm,
1110 debug_ospf_nsm_sub_cmd,
1111 "debug ospf nsm (status|events|timers)",
1112 DEBUG_STR
1113 OSPF_STR
1114 "OSPF Neighbor State Machine\n"
1115 "NSM Status Information\n"
1116 "NSM Event Information\n"
1117 "NSM Timer Information\n")
1118
1119DEFUN (no_debug_ospf_nsm,
1120 no_debug_ospf_nsm_cmd,
1121 "no debug ospf nsm",
1122 NO_STR
1123 DEBUG_STR
1124 OSPF_STR
1125 "OSPF Neighbor State Machine")
1126{
1127 if (vty->node == CONFIG_NODE)
1128 {
1129 if (argc == 0)
1130 DEBUG_OFF (nsm, NSM);
1131 else if (argc == 1)
1132 {
1133 if (strncmp (argv[0], "s", 1) == 0)
1134 DEBUG_OFF (nsm, NSM_STATUS);
1135 else if (strncmp (argv[0], "e", 1) == 0)
1136 DEBUG_OFF (nsm, NSM_EVENTS);
1137 else if (strncmp (argv[0], "t", 1) == 0)
1138 DEBUG_OFF (nsm, NSM_TIMERS);
1139 }
1140
1141 return CMD_SUCCESS;
1142 }
1143
1144 /* ENABLE_NODE. */
1145 if (argc == 0)
1146 TERM_DEBUG_OFF (nsm, NSM);
1147 else if (argc == 1)
1148 {
1149 if (strncmp (argv[0], "s", 1) == 0)
1150 TERM_DEBUG_OFF (nsm, NSM_STATUS);
1151 else if (strncmp (argv[0], "e", 1) == 0)
1152 TERM_DEBUG_OFF (nsm, NSM_EVENTS);
1153 else if (strncmp (argv[0], "t", 1) == 0)
1154 TERM_DEBUG_OFF (nsm, NSM_TIMERS);
1155 }
1156
1157 return CMD_SUCCESS;
1158}
1159
1160ALIAS (no_debug_ospf_nsm,
1161 no_debug_ospf_nsm_sub_cmd,
1162 "no debug ospf nsm (status|events|timers)",
1163 NO_STR
1164 "Debugging functions\n"
1165 "OSPF information\n"
1166 "OSPF Interface State Machine\n"
1167 "NSM Status Information\n"
1168 "NSM Event Information\n"
1169 "NSM Timer Information\n")
1170
David Lamparter6b0655a2014-06-04 06:53:35 +02001171
paul718e3742002-12-13 20:15:29 +00001172DEFUN (debug_ospf_lsa,
1173 debug_ospf_lsa_cmd,
1174 "debug ospf lsa",
1175 DEBUG_STR
1176 OSPF_STR
1177 "OSPF Link State Advertisement\n")
1178{
1179 if (vty->node == CONFIG_NODE)
1180 {
1181 if (argc == 0)
1182 DEBUG_ON (lsa, LSA);
1183 else if (argc == 1)
1184 {
1185 if (strncmp (argv[0], "g", 1) == 0)
1186 DEBUG_ON (lsa, LSA_GENERATE);
1187 else if (strncmp (argv[0], "f", 1) == 0)
1188 DEBUG_ON (lsa, LSA_FLOODING);
1189 else if (strncmp (argv[0], "i", 1) == 0)
1190 DEBUG_ON (lsa, LSA_INSTALL);
1191 else if (strncmp (argv[0], "r", 1) == 0)
1192 DEBUG_ON (lsa, LSA_REFRESH);
1193 }
1194
1195 return CMD_SUCCESS;
1196 }
1197
1198 /* ENABLE_NODE. */
1199 if (argc == 0)
1200 TERM_DEBUG_ON (lsa, LSA);
1201 else if (argc == 1)
1202 {
1203 if (strncmp (argv[0], "g", 1) == 0)
1204 TERM_DEBUG_ON (lsa, LSA_GENERATE);
1205 else if (strncmp (argv[0], "f", 1) == 0)
1206 TERM_DEBUG_ON (lsa, LSA_FLOODING);
1207 else if (strncmp (argv[0], "i", 1) == 0)
1208 TERM_DEBUG_ON (lsa, LSA_INSTALL);
1209 else if (strncmp (argv[0], "r", 1) == 0)
1210 TERM_DEBUG_ON (lsa, LSA_REFRESH);
1211 }
1212
1213 return CMD_SUCCESS;
1214}
1215
1216ALIAS (debug_ospf_lsa,
1217 debug_ospf_lsa_sub_cmd,
1218 "debug ospf lsa (generate|flooding|install|refresh)",
1219 DEBUG_STR
1220 OSPF_STR
1221 "OSPF Link State Advertisement\n"
1222 "LSA Generation\n"
1223 "LSA Flooding\n"
1224 "LSA Install/Delete\n"
1225 "LSA Refresh\n")
1226
1227DEFUN (no_debug_ospf_lsa,
1228 no_debug_ospf_lsa_cmd,
1229 "no debug ospf lsa",
1230 NO_STR
1231 DEBUG_STR
1232 OSPF_STR
1233 "OSPF Link State Advertisement\n")
1234{
1235 if (vty->node == CONFIG_NODE)
1236 {
1237 if (argc == 0)
1238 DEBUG_OFF (lsa, LSA);
1239 else if (argc == 1)
1240 {
1241 if (strncmp (argv[0], "g", 1) == 0)
1242 DEBUG_OFF (lsa, LSA_GENERATE);
1243 else if (strncmp (argv[0], "f", 1) == 0)
1244 DEBUG_OFF (lsa, LSA_FLOODING);
1245 else if (strncmp (argv[0], "i", 1) == 0)
1246 DEBUG_OFF (lsa, LSA_INSTALL);
1247 else if (strncmp (argv[0], "r", 1) == 0)
1248 DEBUG_OFF (lsa, LSA_REFRESH);
1249 }
1250
1251 return CMD_SUCCESS;
1252 }
1253
1254 /* ENABLE_NODE. */
1255 if (argc == 0)
1256 TERM_DEBUG_OFF (lsa, LSA);
1257 else if (argc == 1)
1258 {
1259 if (strncmp (argv[0], "g", 1) == 0)
1260 TERM_DEBUG_OFF (lsa, LSA_GENERATE);
1261 else if (strncmp (argv[0], "f", 1) == 0)
1262 TERM_DEBUG_OFF (lsa, LSA_FLOODING);
1263 else if (strncmp (argv[0], "i", 1) == 0)
1264 TERM_DEBUG_OFF (lsa, LSA_INSTALL);
1265 else if (strncmp (argv[0], "r", 1) == 0)
1266 TERM_DEBUG_OFF (lsa, LSA_REFRESH);
1267 }
1268
1269 return CMD_SUCCESS;
1270}
1271
1272ALIAS (no_debug_ospf_lsa,
1273 no_debug_ospf_lsa_sub_cmd,
1274 "no debug ospf lsa (generate|flooding|install|refresh)",
1275 NO_STR
1276 DEBUG_STR
1277 OSPF_STR
1278 "OSPF Link State Advertisement\n"
1279 "LSA Generation\n"
1280 "LSA Flooding\n"
1281 "LSA Install/Delete\n"
1282 "LSA Refres\n")
1283
David Lamparter6b0655a2014-06-04 06:53:35 +02001284
paul718e3742002-12-13 20:15:29 +00001285DEFUN (debug_ospf_zebra,
1286 debug_ospf_zebra_cmd,
1287 "debug ospf zebra",
1288 DEBUG_STR
1289 OSPF_STR
1290 "OSPF Zebra information\n")
1291{
1292 if (vty->node == CONFIG_NODE)
1293 {
1294 if (argc == 0)
1295 DEBUG_ON (zebra, ZEBRA);
1296 else if (argc == 1)
1297 {
1298 if (strncmp (argv[0], "i", 1) == 0)
1299 DEBUG_ON (zebra, ZEBRA_INTERFACE);
1300 else if (strncmp (argv[0], "r", 1) == 0)
1301 DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
1302 }
1303
1304 return CMD_SUCCESS;
1305 }
1306
1307 /* ENABLE_NODE. */
1308 if (argc == 0)
1309 TERM_DEBUG_ON (zebra, ZEBRA);
1310 else if (argc == 1)
1311 {
1312 if (strncmp (argv[0], "i", 1) == 0)
1313 TERM_DEBUG_ON (zebra, ZEBRA_INTERFACE);
1314 else if (strncmp (argv[0], "r", 1) == 0)
1315 TERM_DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
1316 }
1317
1318 return CMD_SUCCESS;
1319}
1320
1321ALIAS (debug_ospf_zebra,
1322 debug_ospf_zebra_sub_cmd,
1323 "debug ospf zebra (interface|redistribute)",
1324 DEBUG_STR
1325 OSPF_STR
1326 "OSPF Zebra information\n"
1327 "Zebra interface\n"
1328 "Zebra redistribute\n")
1329
1330DEFUN (no_debug_ospf_zebra,
1331 no_debug_ospf_zebra_cmd,
1332 "no debug ospf zebra",
1333 NO_STR
1334 DEBUG_STR
1335 OSPF_STR
1336 "OSPF Zebra information\n")
1337{
1338 if (vty->node == CONFIG_NODE)
1339 {
1340 if (argc == 0)
1341 DEBUG_OFF (zebra, ZEBRA);
1342 else if (argc == 1)
1343 {
1344 if (strncmp (argv[0], "i", 1) == 0)
1345 DEBUG_OFF (zebra, ZEBRA_INTERFACE);
1346 else if (strncmp (argv[0], "r", 1) == 0)
1347 DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
1348 }
1349
1350 return CMD_SUCCESS;
1351 }
1352
1353 /* ENABLE_NODE. */
1354 if (argc == 0)
1355 TERM_DEBUG_OFF (zebra, ZEBRA);
1356 else if (argc == 1)
1357 {
1358 if (strncmp (argv[0], "i", 1) == 0)
1359 TERM_DEBUG_OFF (zebra, ZEBRA_INTERFACE);
1360 else if (strncmp (argv[0], "r", 1) == 0)
1361 TERM_DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
1362 }
1363
1364 return CMD_SUCCESS;
1365}
1366
1367ALIAS (no_debug_ospf_zebra,
1368 no_debug_ospf_zebra_sub_cmd,
1369 "no debug ospf zebra (interface|redistribute)",
1370 NO_STR
1371 DEBUG_STR
1372 OSPF_STR
1373 "OSPF Zebra information\n"
1374 "Zebra interface\n"
1375 "Zebra redistribute\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02001376
paul718e3742002-12-13 20:15:29 +00001377DEFUN (debug_ospf_event,
1378 debug_ospf_event_cmd,
1379 "debug ospf event",
1380 DEBUG_STR
1381 OSPF_STR
1382 "OSPF event information\n")
1383{
1384 if (vty->node == CONFIG_NODE)
1385 CONF_DEBUG_ON (event, EVENT);
1386 TERM_DEBUG_ON (event, EVENT);
1387 return CMD_SUCCESS;
1388}
1389
1390DEFUN (no_debug_ospf_event,
1391 no_debug_ospf_event_cmd,
1392 "no debug ospf event",
1393 NO_STR
1394 DEBUG_STR
1395 OSPF_STR
1396 "OSPF event information\n")
1397{
1398 if (vty->node == CONFIG_NODE)
1399 CONF_DEBUG_OFF (event, EVENT);
1400 TERM_DEBUG_OFF (event, EVENT);
1401 return CMD_SUCCESS;
1402}
1403
1404DEFUN (debug_ospf_nssa,
1405 debug_ospf_nssa_cmd,
1406 "debug ospf nssa",
1407 DEBUG_STR
1408 OSPF_STR
1409 "OSPF nssa information\n")
1410{
1411 if (vty->node == CONFIG_NODE)
1412 CONF_DEBUG_ON (nssa, NSSA);
1413 TERM_DEBUG_ON (nssa, NSSA);
1414 return CMD_SUCCESS;
1415}
1416
1417DEFUN (no_debug_ospf_nssa,
1418 no_debug_ospf_nssa_cmd,
1419 "no debug ospf nssa",
1420 NO_STR
1421 DEBUG_STR
1422 OSPF_STR
1423 "OSPF nssa information\n")
1424{
1425 if (vty->node == CONFIG_NODE)
1426 CONF_DEBUG_OFF (nssa, NSSA);
1427 TERM_DEBUG_OFF (nssa, NSSA);
1428 return CMD_SUCCESS;
1429}
1430
Olivier Dugeon29a14012016-04-19 18:42:40 +02001431DEFUN (debug_ospf_te,
1432 debug_ospf_te_cmd,
1433 "debug ospf te",
1434 DEBUG_STR
1435 OSPF_STR
1436 "OSPF-TE information\n")
1437{
1438 if (vty->node == CONFIG_NODE)
1439 CONF_DEBUG_ON (te, TE);
1440 TERM_DEBUG_ON (te, TE);
1441 return CMD_SUCCESS;
1442}
1443
1444DEFUN (no_debug_ospf_te,
1445 no_debug_ospf_te_cmd,
1446 "no debug ospf te",
1447 NO_STR
1448 DEBUG_STR
1449 OSPF_STR
1450 "OSPF-TE information\n")
1451{
1452 if (vty->node == CONFIG_NODE)
1453 CONF_DEBUG_OFF (te, TE);
1454 TERM_DEBUG_OFF (te, TE);
1455 return CMD_SUCCESS;
1456}
David Lamparter6b0655a2014-06-04 06:53:35 +02001457
paul718e3742002-12-13 20:15:29 +00001458DEFUN (show_debugging_ospf,
1459 show_debugging_ospf_cmd,
1460 "show debugging ospf",
1461 SHOW_STR
1462 DEBUG_STR
1463 OSPF_STR)
1464{
1465 int i;
1466
hassodf43a132004-08-31 12:04:33 +00001467 vty_out (vty, "OSPF debugging status:%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001468
ajsaca72fd2005-03-31 15:18:21 +00001469 /* Show debug status for events. */
1470 if (IS_DEBUG_OSPF(event,EVENT))
1471 vty_out (vty, " OSPF event debugging is on%s", VTY_NEWLINE);
1472
paul718e3742002-12-13 20:15:29 +00001473 /* Show debug status for ISM. */
1474 if (IS_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
1475 vty_out (vty, " OSPF ISM debugging is on%s", VTY_NEWLINE);
1476 else
1477 {
1478 if (IS_DEBUG_OSPF (ism, ISM_STATUS))
1479 vty_out (vty, " OSPF ISM status debugging is on%s", VTY_NEWLINE);
1480 if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
1481 vty_out (vty, " OSPF ISM event debugging is on%s", VTY_NEWLINE);
1482 if (IS_DEBUG_OSPF (ism, ISM_TIMERS))
1483 vty_out (vty, " OSPF ISM timer debugging is on%s", VTY_NEWLINE);
1484 }
1485
1486 /* Show debug status for NSM. */
1487 if (IS_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
1488 vty_out (vty, " OSPF NSM debugging is on%s", VTY_NEWLINE);
1489 else
1490 {
1491 if (IS_DEBUG_OSPF (nsm, NSM_STATUS))
1492 vty_out (vty, " OSPF NSM status debugging is on%s", VTY_NEWLINE);
1493 if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
1494 vty_out (vty, " OSPF NSM event debugging is on%s", VTY_NEWLINE);
1495 if (IS_DEBUG_OSPF (nsm, NSM_TIMERS))
1496 vty_out (vty, " OSPF NSM timer debugging is on%s", VTY_NEWLINE);
1497 }
1498
1499 /* Show debug status for OSPF Packets. */
1500 for (i = 0; i < 5; i++)
1501 if (IS_DEBUG_OSPF_PACKET (i, SEND) && IS_DEBUG_OSPF_PACKET (i, RECV))
1502 {
1503 vty_out (vty, " OSPF packet %s%s debugging is on%s",
Denis Ovsienko272ca1e2012-01-15 19:12:19 +04001504 LOOKUP (ospf_packet_type_str, i + 1),
paul718e3742002-12-13 20:15:29 +00001505 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1506 VTY_NEWLINE);
1507 }
1508 else
1509 {
1510 if (IS_DEBUG_OSPF_PACKET (i, SEND))
1511 vty_out (vty, " OSPF packet %s send%s debugging is on%s",
Denis Ovsienko272ca1e2012-01-15 19:12:19 +04001512 LOOKUP (ospf_packet_type_str, i + 1),
paul718e3742002-12-13 20:15:29 +00001513 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1514 VTY_NEWLINE);
1515 if (IS_DEBUG_OSPF_PACKET (i, RECV))
1516 vty_out (vty, " OSPF packet %s receive%s debugging is on%s",
Denis Ovsienko272ca1e2012-01-15 19:12:19 +04001517 LOOKUP (ospf_packet_type_str, i + 1),
paul718e3742002-12-13 20:15:29 +00001518 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
1519 VTY_NEWLINE);
1520 }
1521
1522 /* Show debug status for OSPF LSAs. */
1523 if (IS_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
1524 vty_out (vty, " OSPF LSA debugging is on%s", VTY_NEWLINE);
1525 else
1526 {
1527 if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
1528 vty_out (vty, " OSPF LSA generation debugging is on%s", VTY_NEWLINE);
1529 if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
1530 vty_out (vty, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE);
1531 if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
1532 vty_out (vty, " OSPF LSA install debugging is on%s", VTY_NEWLINE);
1533 if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
1534 vty_out (vty, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE);
1535 }
1536
1537 /* Show debug status for Zebra. */
1538 if (IS_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
1539 vty_out (vty, " OSPF Zebra debugging is on%s", VTY_NEWLINE);
1540 else
1541 {
1542 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
1543 vty_out (vty, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE);
1544 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
1545 vty_out (vty, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE);
1546 }
ajsaca72fd2005-03-31 15:18:21 +00001547
1548 /* Show debug status for NSSA. */
paulead687e2003-04-07 17:12:12 +00001549 if (IS_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
1550 vty_out (vty, " OSPF NSSA debugging is on%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001551
1552 return CMD_SUCCESS;
1553}
1554
1555/* Debug node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001556static struct cmd_node debug_node =
paul718e3742002-12-13 20:15:29 +00001557{
1558 DEBUG_NODE,
hasso1d806282004-12-22 09:43:20 +00001559 "",
1560 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001561};
1562
paul4dadc292005-05-06 21:37:42 +00001563static int
paul718e3742002-12-13 20:15:29 +00001564config_write_debug (struct vty *vty)
1565{
1566 int write = 0;
1567 int i, r;
1568
hassoeb1ce602004-10-08 08:17:22 +00001569 const char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
1570 const char *detail_str[] = {"", " send", " recv", "", " detail",
paul718e3742002-12-13 20:15:29 +00001571 " send detail", " recv detail", " detail"};
1572
1573 /* debug ospf ism (status|events|timers). */
1574 if (IS_CONF_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
1575 vty_out (vty, "debug ospf ism%s", VTY_NEWLINE);
1576 else
1577 {
1578 if (IS_CONF_DEBUG_OSPF (ism, ISM_STATUS))
1579 vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE);
1580 if (IS_CONF_DEBUG_OSPF (ism, ISM_EVENTS))
1581 vty_out (vty, "debug ospf ism event%s", VTY_NEWLINE);
1582 if (IS_CONF_DEBUG_OSPF (ism, ISM_TIMERS))
1583 vty_out (vty, "debug ospf ism timer%s", VTY_NEWLINE);
1584 }
1585
1586 /* debug ospf nsm (status|events|timers). */
1587 if (IS_CONF_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
1588 vty_out (vty, "debug ospf nsm%s", VTY_NEWLINE);
1589 else
1590 {
1591 if (IS_CONF_DEBUG_OSPF (nsm, NSM_STATUS))
Andrew J. Schorr0ffb7092006-06-24 19:40:13 +00001592 vty_out (vty, "debug ospf nsm status%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001593 if (IS_CONF_DEBUG_OSPF (nsm, NSM_EVENTS))
1594 vty_out (vty, "debug ospf nsm event%s", VTY_NEWLINE);
1595 if (IS_CONF_DEBUG_OSPF (nsm, NSM_TIMERS))
1596 vty_out (vty, "debug ospf nsm timer%s", VTY_NEWLINE);
1597 }
1598
1599 /* debug ospf lsa (generate|flooding|install|refresh). */
1600 if (IS_CONF_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
1601 vty_out (vty, "debug ospf lsa%s", VTY_NEWLINE);
1602 else
1603 {
1604 if (IS_CONF_DEBUG_OSPF (lsa, LSA_GENERATE))
1605 vty_out (vty, "debug ospf lsa generate%s", VTY_NEWLINE);
1606 if (IS_CONF_DEBUG_OSPF (lsa, LSA_FLOODING))
1607 vty_out (vty, "debug ospf lsa flooding%s", VTY_NEWLINE);
1608 if (IS_CONF_DEBUG_OSPF (lsa, LSA_INSTALL))
1609 vty_out (vty, "debug ospf lsa install%s", VTY_NEWLINE);
1610 if (IS_CONF_DEBUG_OSPF (lsa, LSA_REFRESH))
1611 vty_out (vty, "debug ospf lsa refresh%s", VTY_NEWLINE);
1612
1613 write = 1;
1614 }
1615
1616 /* debug ospf zebra (interface|redistribute). */
1617 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
1618 vty_out (vty, "debug ospf zebra%s", VTY_NEWLINE);
1619 else
1620 {
1621 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
1622 vty_out (vty, "debug ospf zebra interface%s", VTY_NEWLINE);
1623 if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
1624 vty_out (vty, "debug ospf zebra redistribute%s", VTY_NEWLINE);
1625
1626 write = 1;
1627 }
1628
1629 /* debug ospf event. */
1630 if (IS_CONF_DEBUG_OSPF (event, EVENT) == OSPF_DEBUG_EVENT)
1631 {
1632 vty_out (vty, "debug ospf event%s", VTY_NEWLINE);
1633 write = 1;
1634 }
1635
1636 /* debug ospf nssa. */
1637 if (IS_CONF_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
1638 {
1639 vty_out (vty, "debug ospf nssa%s", VTY_NEWLINE);
1640 write = 1;
1641 }
1642
1643 /* debug ospf packet all detail. */
1644 r = OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL;
1645 for (i = 0; i < 5; i++)
1646 r &= conf_debug_ospf_packet[i] & (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL);
1647 if (r == (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL))
1648 {
1649 vty_out (vty, "debug ospf packet all detail%s", VTY_NEWLINE);
1650 return 1;
1651 }
1652
1653 /* debug ospf packet all. */
1654 r = OSPF_DEBUG_SEND_RECV;
1655 for (i = 0; i < 5; i++)
1656 r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV;
1657 if (r == OSPF_DEBUG_SEND_RECV)
1658 {
1659 vty_out (vty, "debug ospf packet all%s", VTY_NEWLINE);
1660 for (i = 0; i < 5; i++)
1661 if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL)
1662 vty_out (vty, "debug ospf packet %s detail%s",
1663 type_str[i],
1664 VTY_NEWLINE);
1665 return 1;
1666 }
1667
1668 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1669 (send|recv) (detail). */
1670 for (i = 0; i < 5; i++)
1671 {
1672 if (conf_debug_ospf_packet[i] == 0)
1673 continue;
1674
1675 vty_out (vty, "debug ospf packet %s%s%s",
1676 type_str[i], detail_str[conf_debug_ospf_packet[i]],
1677 VTY_NEWLINE);
1678 write = 1;
1679 }
1680
1681 return write;
1682}
1683
1684/* Initialize debug commands. */
1685void
1686debug_init ()
1687{
1688 install_node (&debug_node, config_write_debug);
1689
1690 install_element (ENABLE_NODE, &show_debugging_ospf_cmd);
1691 install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_detail_cmd);
1692 install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_cmd);
1693 install_element (ENABLE_NODE, &debug_ospf_packet_all_cmd);
1694 install_element (ENABLE_NODE, &debug_ospf_ism_sub_cmd);
1695 install_element (ENABLE_NODE, &debug_ospf_ism_cmd);
1696 install_element (ENABLE_NODE, &debug_ospf_nsm_sub_cmd);
1697 install_element (ENABLE_NODE, &debug_ospf_nsm_cmd);
1698 install_element (ENABLE_NODE, &debug_ospf_lsa_sub_cmd);
1699 install_element (ENABLE_NODE, &debug_ospf_lsa_cmd);
1700 install_element (ENABLE_NODE, &debug_ospf_zebra_sub_cmd);
1701 install_element (ENABLE_NODE, &debug_ospf_zebra_cmd);
1702 install_element (ENABLE_NODE, &debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001703 install_element (ENABLE_NODE, &debug_ospf_nssa_cmd);
Olivier Dugeon29a14012016-04-19 18:42:40 +02001704 install_element (ENABLE_NODE, &debug_ospf_te_cmd);
paul718e3742002-12-13 20:15:29 +00001705 install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
1706 install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_cmd);
1707 install_element (ENABLE_NODE, &no_debug_ospf_packet_all_cmd);
1708 install_element (ENABLE_NODE, &no_debug_ospf_ism_sub_cmd);
1709 install_element (ENABLE_NODE, &no_debug_ospf_ism_cmd);
1710 install_element (ENABLE_NODE, &no_debug_ospf_nsm_sub_cmd);
1711 install_element (ENABLE_NODE, &no_debug_ospf_nsm_cmd);
1712 install_element (ENABLE_NODE, &no_debug_ospf_lsa_sub_cmd);
1713 install_element (ENABLE_NODE, &no_debug_ospf_lsa_cmd);
1714 install_element (ENABLE_NODE, &no_debug_ospf_zebra_sub_cmd);
1715 install_element (ENABLE_NODE, &no_debug_ospf_zebra_cmd);
1716 install_element (ENABLE_NODE, &no_debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001717 install_element (ENABLE_NODE, &no_debug_ospf_nssa_cmd);
Olivier Dugeon29a14012016-04-19 18:42:40 +02001718 install_element (ENABLE_NODE, &no_debug_ospf_te_cmd);
paul718e3742002-12-13 20:15:29 +00001719
1720 install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_detail_cmd);
1721 install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_cmd);
1722 install_element (CONFIG_NODE, &debug_ospf_packet_all_cmd);
1723 install_element (CONFIG_NODE, &debug_ospf_ism_sub_cmd);
1724 install_element (CONFIG_NODE, &debug_ospf_ism_cmd);
1725 install_element (CONFIG_NODE, &debug_ospf_nsm_sub_cmd);
1726 install_element (CONFIG_NODE, &debug_ospf_nsm_cmd);
1727 install_element (CONFIG_NODE, &debug_ospf_lsa_sub_cmd);
1728 install_element (CONFIG_NODE, &debug_ospf_lsa_cmd);
1729 install_element (CONFIG_NODE, &debug_ospf_zebra_sub_cmd);
1730 install_element (CONFIG_NODE, &debug_ospf_zebra_cmd);
1731 install_element (CONFIG_NODE, &debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001732 install_element (CONFIG_NODE, &debug_ospf_nssa_cmd);
Olivier Dugeon29a14012016-04-19 18:42:40 +02001733 install_element (CONFIG_NODE, &debug_ospf_te_cmd);
paul718e3742002-12-13 20:15:29 +00001734 install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
1735 install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_cmd);
1736 install_element (CONFIG_NODE, &no_debug_ospf_packet_all_cmd);
1737 install_element (CONFIG_NODE, &no_debug_ospf_ism_sub_cmd);
1738 install_element (CONFIG_NODE, &no_debug_ospf_ism_cmd);
1739 install_element (CONFIG_NODE, &no_debug_ospf_nsm_sub_cmd);
1740 install_element (CONFIG_NODE, &no_debug_ospf_nsm_cmd);
1741 install_element (CONFIG_NODE, &no_debug_ospf_lsa_sub_cmd);
1742 install_element (CONFIG_NODE, &no_debug_ospf_lsa_cmd);
1743 install_element (CONFIG_NODE, &no_debug_ospf_zebra_sub_cmd);
1744 install_element (CONFIG_NODE, &no_debug_ospf_zebra_cmd);
1745 install_element (CONFIG_NODE, &no_debug_ospf_event_cmd);
paul718e3742002-12-13 20:15:29 +00001746 install_element (CONFIG_NODE, &no_debug_ospf_nssa_cmd);
Olivier Dugeon29a14012016-04-19 18:42:40 +02001747 install_element (CONFIG_NODE, &no_debug_ospf_te_cmd);
paul718e3742002-12-13 20:15:29 +00001748}