~ubuntu-branches/ubuntu/warty/quagga/warty

« back to all changes in this revision

Viewing changes to ospfd/ospf_dump.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabio M. Di Nitto
  • Date: 2004-06-29 09:50:59 UTC
  • Revision ID: james.westby@ubuntu.com-20040629095059-px1m2m108z4qw1mr
Tags: upstream-0.96.5
ImportĀ upstreamĀ versionĀ 0.96.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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"
 
31
 
 
32
#include "ospfd/ospfd.h"
 
33
#include "ospfd/ospf_interface.h"
 
34
#include "ospfd/ospf_ism.h"
 
35
#include "ospfd/ospf_asbr.h"
 
36
#include "ospfd/ospf_lsa.h"
 
37
#include "ospfd/ospf_lsdb.h"
 
38
#include "ospfd/ospf_neighbor.h"
 
39
#include "ospfd/ospf_nsm.h"
 
40
#include "ospfd/ospf_dump.h"
 
41
#include "ospfd/ospf_packet.h"
 
42
#include "ospfd/ospf_network.h"
 
43
 
 
44
struct message ospf_ism_state_msg[] =
 
45
{
 
46
  { ISM_DependUpon,   "DependUpon" },
 
47
  { ISM_Down,         "Down" },
 
48
  { ISM_Loopback,     "Loopback" },
 
49
  { ISM_Waiting,      "Waiting" },
 
50
  { ISM_PointToPoint, "Point-To-Point" },
 
51
  { ISM_DROther,      "DROther" },
 
52
  { ISM_Backup,       "Backup" },
 
53
  { ISM_DR,           "DR" },
 
54
};
 
55
int ospf_ism_state_msg_max = OSPF_ISM_STATE_MAX;
 
56
 
 
57
struct message ospf_nsm_state_msg[] =
 
58
{
 
59
  { NSM_DependUpon, "DependUpon" },
 
60
  { NSM_Down,       "Down" },
 
61
  { NSM_Attempt,    "Attempt" },
 
62
  { NSM_Init,       "Init" },
 
63
  { NSM_TwoWay,     "2-Way" },
 
64
  { NSM_ExStart,    "ExStart" },
 
65
  { NSM_Exchange,   "Exchange" },
 
66
  { NSM_Loading,    "Loading" },
 
67
  { NSM_Full,       "Full" },
 
68
};
 
69
int ospf_nsm_state_msg_max = OSPF_NSM_STATE_MAX;
 
70
 
 
71
struct message ospf_lsa_type_msg[] =
 
72
{
 
73
  { OSPF_UNKNOWN_LSA,      "unknown" },
 
74
  { OSPF_ROUTER_LSA,       "router-LSA" },
 
75
  { OSPF_NETWORK_LSA,      "network-LSA" },
 
76
  { OSPF_SUMMARY_LSA,      "summary-LSA" },
 
77
  { OSPF_ASBR_SUMMARY_LSA, "summary-LSA" },
 
78
  { OSPF_AS_EXTERNAL_LSA,  "AS-external-LSA" },
 
79
  { OSPF_GROUP_MEMBER_LSA, "GROUP MEMBER LSA" },
 
80
  { OSPF_AS_NSSA_LSA,      "NSSA-LSA" },
 
81
  { 8,                     "Type-8 LSA" },
 
82
  { OSPF_OPAQUE_LINK_LSA,  "Link-Local Opaque-LSA" },
 
83
  { OSPF_OPAQUE_AREA_LSA,  "Area-Local Opaque-LSA" },
 
84
  { OSPF_OPAQUE_AS_LSA,    "AS-external Opaque-LSA" },
 
85
};
 
86
int ospf_lsa_type_msg_max = OSPF_MAX_LSA;
 
87
 
 
88
struct message ospf_link_state_id_type_msg[] =
 
89
{
 
90
  { OSPF_UNKNOWN_LSA,      "(unknown)" },
 
91
  { OSPF_ROUTER_LSA,       "" },
 
92
  { OSPF_NETWORK_LSA,      "(address of Designated Router)" },
 
93
  { OSPF_SUMMARY_LSA,      "(summary Network Number)" },
 
94
  { OSPF_ASBR_SUMMARY_LSA, "(AS Boundary Router address)" },
 
95
  { OSPF_AS_EXTERNAL_LSA,  "(External Network Number)" },
 
96
  { OSPF_GROUP_MEMBER_LSA, "(Group membership information)" },
 
97
  { OSPF_AS_NSSA_LSA,      "(External Network Number for NSSA)" },
 
98
  { 8,                     "(Type-8 LSID)" },
 
99
  { OSPF_OPAQUE_LINK_LSA,  "(Link-Local Opaque-Type/ID)" },
 
100
  { OSPF_OPAQUE_AREA_LSA,  "(Area-Local Opaque-Type/ID)" },
 
101
  { OSPF_OPAQUE_AS_LSA,    "(AS-external Opaque-Type/ID)" },
 
102
};
 
103
int ospf_link_state_id_type_msg_max = OSPF_MAX_LSA;
 
104
 
 
105
struct message ospf_redistributed_proto[] =
 
106
{
 
107
  { ZEBRA_ROUTE_SYSTEM,   "System" },
 
108
  { ZEBRA_ROUTE_KERNEL,   "Kernel" },
 
109
  { ZEBRA_ROUTE_CONNECT,  "Connected" },
 
110
  { ZEBRA_ROUTE_STATIC,   "Static" },
 
111
  { ZEBRA_ROUTE_RIP,      "RIP" },
 
112
  { ZEBRA_ROUTE_RIPNG,    "RIPng" },
 
113
  { ZEBRA_ROUTE_OSPF,     "OSPF" },
 
114
  { ZEBRA_ROUTE_OSPF6,    "OSPFv3" },
 
115
  { ZEBRA_ROUTE_BGP,      "BGP" },
 
116
  { ZEBRA_ROUTE_MAX,      "Default" },
 
117
};
 
118
int ospf_redistributed_proto_max = ZEBRA_ROUTE_MAX + 1;
 
119
 
 
120
struct message ospf_network_type_msg[] =
 
121
{
 
122
  { OSPF_IFTYPE_NONE,             "NONE" },
 
123
  { OSPF_IFTYPE_POINTOPOINT,      "Point-to-Point" },
 
124
  { OSPF_IFTYPE_BROADCAST,        "Broadcast" },
 
125
  { OSPF_IFTYPE_NBMA,             "NBMA" },
 
126
  { OSPF_IFTYPE_POINTOMULTIPOINT, "Point-to-MultiPoint" },
 
127
  { OSPF_IFTYPE_VIRTUALLINK,      "Virtual-Link" },
 
128
};
 
129
int ospf_network_type_msg_max = OSPF_IFTYPE_MAX;
 
130
 
 
131
/* Configuration debug option variables. */
 
132
unsigned long conf_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
 
133
unsigned long conf_debug_ospf_event = 0;
 
134
unsigned long conf_debug_ospf_ism = 0;
 
135
unsigned long conf_debug_ospf_nsm = 0;
 
136
unsigned long conf_debug_ospf_lsa = 0;
 
137
unsigned long conf_debug_ospf_zebra = 0;
 
138
unsigned long conf_debug_ospf_nssa = 0;
 
139
 
 
140
/* Enable debug option variables -- valid only session. */
 
141
unsigned long term_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
 
142
unsigned long term_debug_ospf_event = 0;
 
143
unsigned long term_debug_ospf_ism = 0;
 
144
unsigned long term_debug_ospf_nsm = 0;
 
145
unsigned long term_debug_ospf_lsa = 0;
 
146
unsigned long term_debug_ospf_zebra = 0;
 
147
unsigned long term_debug_ospf_nssa = 0;
 
148
 
 
149
 
 
150
#define OSPF_AREA_STRING_MAXLEN  16
 
151
char *
 
152
ospf_area_name_string (struct ospf_area *area)
 
153
{
 
154
  static char buf[OSPF_AREA_STRING_MAXLEN] = "";
 
155
  u_int32_t area_id;
 
156
 
 
157
  if (!area)
 
158
    return "-";
 
159
 
 
160
  area_id = ntohl (area->area_id.s_addr);
 
161
  snprintf (buf, OSPF_AREA_STRING_MAXLEN, "%d.%d.%d.%d",
 
162
            (area_id >> 24) & 0xff, (area_id >> 16) & 0xff,
 
163
            (area_id >> 8) & 0xff, area_id & 0xff);
 
164
  return buf;
 
165
}
 
166
 
 
167
#define OSPF_AREA_DESC_STRING_MAXLEN  23
 
168
char *
 
169
ospf_area_desc_string (struct ospf_area *area)
 
170
{
 
171
  static char buf[OSPF_AREA_DESC_STRING_MAXLEN] = "";
 
172
  u_char type;
 
173
 
 
174
  if (!area)
 
175
    return "(incomplete)";
 
176
 
 
177
  type = area->external_routing;
 
178
  switch (type)
 
179
    {
 
180
    case OSPF_AREA_NSSA:
 
181
      snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [NSSA]",
 
182
                ospf_area_name_string (area));
 
183
      break;
 
184
    case OSPF_AREA_STUB:
 
185
      snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [Stub]",
 
186
                ospf_area_name_string (area));
 
187
      break;
 
188
    default:
 
189
      return ospf_area_name_string (area);
 
190
      break;
 
191
    }
 
192
 
 
193
  return buf;
 
194
}
 
195
 
 
196
#define OSPF_IF_STRING_MAXLEN  40
 
197
char *
 
198
ospf_if_name_string (struct ospf_interface *oi)
 
199
{
 
200
  static char buf[OSPF_IF_STRING_MAXLEN] = "";
 
201
  u_int32_t ifaddr;
 
202
 
 
203
  if (!oi)
 
204
    return "inactive";
 
205
 
 
206
  if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
 
207
    return oi->ifp->name;
 
208
 
 
209
  ifaddr = ntohl (oi->address->u.prefix4.s_addr);
 
210
  snprintf (buf, OSPF_IF_STRING_MAXLEN,
 
211
            "%s:%d.%d.%d.%d", oi->ifp->name,
 
212
            (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
 
213
            (ifaddr >> 8) & 0xff, ifaddr & 0xff);
 
214
  return buf;
 
215
}
 
216
 
 
217
 
 
218
void
 
219
ospf_nbr_state_message (struct ospf_neighbor *nbr, char *buf, size_t size)
 
220
{
 
221
  int state;
 
222
  struct ospf_interface *oi = nbr->oi;
 
223
 
 
224
  if (IPV4_ADDR_SAME (&DR (oi), &nbr->address.u.prefix4))
 
225
    state = ISM_DR;
 
226
  else if (IPV4_ADDR_SAME (&BDR (oi), &nbr->address.u.prefix4))
 
227
    state = ISM_Backup;
 
228
  else
 
229
    state = ISM_DROther;
 
230
 
 
231
  memset (buf, 0, size);
 
232
 
 
233
  snprintf (buf, size, "%s/%s",
 
234
            LOOKUP (ospf_nsm_state_msg, nbr->state),
 
235
            LOOKUP (ospf_ism_state_msg, state));
 
236
}
 
237
 
 
238
char *
 
239
ospf_timer_dump (struct thread *t, char *buf, size_t size)
 
240
{
 
241
  struct timeval now;
 
242
  unsigned long h, m, s;
 
243
 
 
244
  if (!t)
 
245
    return "inactive";
 
246
 
 
247
  h = m = s = 0;
 
248
  memset (buf, 0, size);
 
249
 
 
250
  gettimeofday (&now, NULL);
 
251
 
 
252
  s = t->u.sands.tv_sec - now.tv_sec;
 
253
  if (s >= 3600)
 
254
    {
 
255
      h = s / 3600;
 
256
      s -= h * 3600;
 
257
    }
 
258
 
 
259
  if (s >= 60)
 
260
    {
 
261
      m = s / 60;
 
262
      s -= m * 60;
 
263
    }
 
264
 
 
265
  snprintf (buf, size, "%02ld:%02ld:%02ld", h, m, s);
 
266
 
 
267
  return buf;
 
268
}
 
269
 
 
270
#define OSPF_OPTION_STR_MAXLEN          24
 
271
 
 
272
char *
 
273
ospf_options_dump (u_char options)
 
274
{
 
275
  static char buf[OSPF_OPTION_STR_MAXLEN];
 
276
 
 
277
  snprintf (buf, OSPF_OPTION_STR_MAXLEN, "*|%s|%s|%s|%s|%s|%s|*",
 
278
            (options & OSPF_OPTION_O) ? "O" : "-",
 
279
            (options & OSPF_OPTION_DC) ? "DC" : "-",
 
280
            (options & OSPF_OPTION_EA) ? "EA" : "-",
 
281
            (options & OSPF_OPTION_NP) ? "N/P" : "-",
 
282
            (options & OSPF_OPTION_MC) ? "MC" : "-",
 
283
            (options & OSPF_OPTION_E) ? "E" : "-");
 
284
 
 
285
  return buf;
 
286
}
 
287
 
 
288
void
 
289
ospf_packet_hello_dump (struct stream *s, u_int16_t length)
 
290
{
 
291
  struct ospf_hello *hello;
 
292
  int i;
 
293
 
 
294
  hello = (struct ospf_hello *) STREAM_PNT (s);
 
295
 
 
296
  zlog_info ("Hello");
 
297
  zlog_info ("  NetworkMask %s", inet_ntoa (hello->network_mask));
 
298
  zlog_info ("  HelloInterval %d", ntohs (hello->hello_interval));
 
299
  zlog_info ("  Options %d (%s)", hello->options,
 
300
             ospf_options_dump (hello->options));
 
301
  zlog_info ("  RtrPriority %d", hello->priority);
 
302
  zlog_info ("  RtrDeadInterval %ld", (u_long)ntohl (hello->dead_interval));
 
303
  zlog_info ("  DRouter %s", inet_ntoa (hello->d_router));
 
304
  zlog_info ("  BDRouter %s", inet_ntoa (hello->bd_router));
 
305
 
 
306
  length -= OSPF_HEADER_SIZE + OSPF_HELLO_MIN_SIZE;
 
307
  zlog_info ("  # Neighbors %d", length / 4);
 
308
  for (i = 0; length > 0; i++, length -= sizeof (struct in_addr))
 
309
    zlog_info ("    Neighbor %s", inet_ntoa (hello->neighbors[i]));
 
310
}
 
311
 
 
312
char *
 
313
ospf_dd_flags_dump (u_char flags, char *buf, size_t size)
 
314
{
 
315
  memset (buf, 0, size);
 
316
 
 
317
  snprintf (buf, size, "%s|%s|%s",
 
318
            (flags & OSPF_DD_FLAG_I) ? "I" : "-",
 
319
            (flags & OSPF_DD_FLAG_M) ? "M" : "-",
 
320
            (flags & OSPF_DD_FLAG_MS) ? "MS" : "-");
 
321
 
 
322
  return buf;
 
323
}
 
324
 
 
325
void
 
326
ospf_lsa_header_dump (struct lsa_header *lsah)
 
327
{
 
328
  zlog_info ("  LSA Header");
 
329
  zlog_info ("    LS age %d", ntohs (lsah->ls_age));
 
330
  zlog_info ("    Options %d (%s)", lsah->options,
 
331
             ospf_options_dump (lsah->options));
 
332
  zlog_info ("    LS type %d (%s)", lsah->type,
 
333
             LOOKUP (ospf_lsa_type_msg, lsah->type));
 
334
  zlog_info ("    Link State ID %s", inet_ntoa (lsah->id));
 
335
  zlog_info ("    Advertising Router %s", inet_ntoa (lsah->adv_router));
 
336
  zlog_info ("    LS sequence number 0x%lx", (u_long)ntohl (lsah->ls_seqnum));
 
337
  zlog_info ("    LS checksum 0x%x", ntohs (lsah->checksum));
 
338
  zlog_info ("    length %d", ntohs (lsah->length));
 
339
}
 
340
 
 
341
char *
 
342
ospf_router_lsa_flags_dump (u_char flags, char *buf, size_t size)
 
343
{
 
344
  memset (buf, 0, size);
 
345
 
 
346
  snprintf (buf, size, "%s|%s|%s",
 
347
            (flags & ROUTER_LSA_VIRTUAL) ? "V" : "-",
 
348
            (flags & ROUTER_LSA_EXTERNAL) ? "E" : "-",
 
349
            (flags & ROUTER_LSA_BORDER) ? "B" : "-");
 
350
 
 
351
  return buf;
 
352
}
 
353
 
 
354
void
 
355
ospf_router_lsa_dump (struct stream *s, u_int16_t length)
 
356
{
 
357
  char buf[BUFSIZ];
 
358
  struct router_lsa *rl;
 
359
  int i, len;
 
360
 
 
361
  rl = (struct router_lsa *) STREAM_PNT (s);
 
362
 
 
363
  zlog_info ("  Router-LSA");
 
364
  zlog_info ("    flags %s", 
 
365
             ospf_router_lsa_flags_dump (rl->flags, buf, BUFSIZ));
 
366
  zlog_info ("    # links %d", ntohs (rl->links));
 
367
 
 
368
  len = ntohs (rl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
 
369
  for (i = 0; len > 0; i++)
 
370
    {
 
371
      zlog_info ("    Link ID %s", inet_ntoa (rl->link[i].link_id));
 
372
      zlog_info ("    Link Data %s", inet_ntoa (rl->link[i].link_data));
 
373
      zlog_info ("    Type %d", (u_char) rl->link[i].type);
 
374
      zlog_info ("    TOS %d", (u_char) rl->link[i].tos);
 
375
      zlog_info ("    metric %d", ntohs (rl->link[i].metric));
 
376
 
 
377
      len -= 12;
 
378
    }
 
379
}
 
380
 
 
381
void
 
382
ospf_network_lsa_dump (struct stream *s, u_int16_t length)
 
383
{
 
384
  struct network_lsa *nl;
 
385
  int i, cnt;
 
386
 
 
387
  nl = (struct network_lsa *) STREAM_PNT (s);
 
388
  cnt = (ntohs (nl->header.length) - (OSPF_LSA_HEADER_SIZE + 4)) / 4;
 
389
  
 
390
  zlog_info ("  Network-LSA");
 
391
  /*
 
392
  zlog_info ("LSA total size %d", ntohs (nl->header.length));
 
393
  zlog_info ("Network-LSA size %d", 
 
394
  ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
 
395
  */
 
396
  zlog_info ("    Network Mask %s", inet_ntoa (nl->mask));
 
397
  zlog_info ("    # Attached Routers %d", cnt);
 
398
  for (i = 0; i < cnt; i++)
 
399
    zlog_info ("      Attached Router %s", inet_ntoa (nl->routers[i]));
 
400
}
 
401
 
 
402
void
 
403
ospf_summary_lsa_dump (struct stream *s, u_int16_t length)
 
404
{
 
405
  struct summary_lsa *sl;
 
406
  int size;
 
407
  int i;
 
408
 
 
409
  sl = (struct summary_lsa *) STREAM_PNT (s);
 
410
 
 
411
  zlog_info ("  Summary-LSA");
 
412
  zlog_info ("    Network Mask %s", inet_ntoa (sl->mask));
 
413
 
 
414
  size = ntohs (sl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
 
415
  for (i = 0; size > 0; size -= 4, i++)
 
416
    zlog_info ("    TOS=%d metric %d", sl->tos,
 
417
               GET_METRIC (sl->metric));
 
418
}
 
419
 
 
420
void
 
421
ospf_as_external_lsa_dump (struct stream *s, u_int16_t length)
 
422
{
 
423
  struct as_external_lsa *al;
 
424
  int size;
 
425
  int i;
 
426
 
 
427
  al = (struct as_external_lsa *) STREAM_PNT (s);
 
428
  zlog_info ("  %s", ospf_lsa_type_msg[al->header.type].str);
 
429
  zlog_info ("    Network Mask %s", inet_ntoa (al->mask));
 
430
 
 
431
  size = ntohs (al->header.length) - OSPF_LSA_HEADER_SIZE -4;
 
432
  for (i = 0; size > 0; size -= 12, i++)
 
433
    {
 
434
      zlog_info ("    bit %s TOS=%d metric %d",
 
435
                 IS_EXTERNAL_METRIC (al->e[i].tos) ? "E" : "-",
 
436
                 al->e[i].tos & 0x7f, GET_METRIC (al->e[i].metric));
 
437
      zlog_info ("    Forwarding address %s", inet_ntoa (al->e[i].fwd_addr));
 
438
      zlog_info ("    External Route Tag %d", al->e[i].route_tag);
 
439
    }
 
440
}
 
441
 
 
442
void
 
443
ospf_lsa_header_list_dump (struct stream *s, u_int16_t length)
 
444
{
 
445
  struct lsa_header *lsa;
 
446
 
 
447
  zlog_info ("  # LSA Headers %d", length / OSPF_LSA_HEADER_SIZE);
 
448
 
 
449
  /* LSA Headers. */
 
450
  while (length > 0)
 
451
    {
 
452
      lsa = (struct lsa_header *) STREAM_PNT (s);
 
453
      ospf_lsa_header_dump (lsa);
 
454
 
 
455
      stream_forward (s, OSPF_LSA_HEADER_SIZE);
 
456
      length -= OSPF_LSA_HEADER_SIZE;
 
457
    }
 
458
}
 
459
 
 
460
void
 
461
ospf_packet_db_desc_dump (struct stream *s, u_int16_t length)
 
462
{
 
463
  struct ospf_db_desc *dd;
 
464
  char dd_flags[8];
 
465
 
 
466
  u_int32_t gp;
 
467
 
 
468
  gp = stream_get_getp (s);
 
469
  dd = (struct ospf_db_desc *) STREAM_PNT (s);
 
470
 
 
471
  zlog_info ("Database Description");
 
472
  zlog_info ("  Interface MTU %d", ntohs (dd->mtu));
 
473
  zlog_info ("  Options %d (%s)", dd->options,
 
474
             ospf_options_dump (dd->options));
 
475
  zlog_info ("  Flags %d (%s)", dd->flags,
 
476
             ospf_dd_flags_dump (dd->flags, dd_flags, sizeof dd_flags));
 
477
  zlog_info ("  Sequence Number 0x%08lx", (u_long)ntohl (dd->dd_seqnum));
 
478
 
 
479
  length -= OSPF_HEADER_SIZE + OSPF_DB_DESC_MIN_SIZE;
 
480
 
 
481
  stream_forward (s, OSPF_DB_DESC_MIN_SIZE);
 
482
 
 
483
  ospf_lsa_header_list_dump (s, length);
 
484
 
 
485
  stream_set_getp (s, gp);
 
486
}
 
487
 
 
488
void
 
489
ospf_packet_ls_req_dump (struct stream *s, u_int16_t length)
 
490
{
 
491
  u_int32_t sp;
 
492
  u_int32_t ls_type;
 
493
  struct in_addr ls_id;
 
494
  struct in_addr adv_router;
 
495
 
 
496
  sp = stream_get_getp (s);
 
497
 
 
498
  length -= OSPF_HEADER_SIZE;
 
499
 
 
500
  zlog_info ("Link State Request");
 
501
  zlog_info ("  # Requests %d", length / 12);
 
502
 
 
503
  for (; length > 0; length -= 12)
 
504
    {
 
505
      ls_type = stream_getl (s);
 
506
      ls_id.s_addr = stream_get_ipv4 (s);
 
507
      adv_router.s_addr = stream_get_ipv4 (s);
 
508
 
 
509
      zlog_info ("  LS type %d", ls_type);
 
510
      zlog_info ("  Link State ID %s", inet_ntoa (ls_id));
 
511
      zlog_info ("  Advertising Router %s",
 
512
                 inet_ntoa (adv_router));
 
513
    }
 
514
 
 
515
  stream_set_getp (s, sp);
 
516
}
 
517
 
 
518
void
 
519
ospf_packet_ls_upd_dump (struct stream *s, u_int16_t length)
 
520
{
 
521
  u_int32_t sp;
 
522
  struct lsa_header *lsa;
 
523
  int lsa_len;
 
524
  u_int32_t count;
 
525
 
 
526
  length -= OSPF_HEADER_SIZE;
 
527
 
 
528
  sp = stream_get_getp (s);
 
529
 
 
530
  count = stream_getl (s);
 
531
  length -= 4;
 
532
 
 
533
  zlog_info ("Link State Update");
 
534
  zlog_info ("  # LSAs %d", count);
 
535
 
 
536
  while (length > 0 && count > 0)
 
537
    {
 
538
      if (length < OSPF_HEADER_SIZE || length % 4 != 0)
 
539
        {
 
540
          zlog_info ("  Remaining %d bytes; Incorrect length.", length);
 
541
          break;
 
542
        }
 
543
 
 
544
      lsa = (struct lsa_header *) STREAM_PNT (s);
 
545
      lsa_len = ntohs (lsa->length);
 
546
      ospf_lsa_header_dump (lsa);
 
547
 
 
548
      switch (lsa->type)
 
549
        {
 
550
        case OSPF_ROUTER_LSA:
 
551
          ospf_router_lsa_dump (s, length);
 
552
          break;
 
553
        case OSPF_NETWORK_LSA:
 
554
          ospf_network_lsa_dump (s, length);
 
555
          break;
 
556
        case OSPF_SUMMARY_LSA:
 
557
        case OSPF_ASBR_SUMMARY_LSA:
 
558
          ospf_summary_lsa_dump (s, length);
 
559
          break;
 
560
        case OSPF_AS_EXTERNAL_LSA:
 
561
          ospf_as_external_lsa_dump (s, length);
 
562
          break;
 
563
#ifdef HAVE_NSSA
 
564
        case OSPF_AS_NSSA_LSA:
 
565
          ospf_as_external_lsa_dump (s, length);
 
566
          break;
 
567
#endif /* HAVE_NSSA */
 
568
#ifdef HAVE_OPAQUE_LSA
 
569
        case OSPF_OPAQUE_LINK_LSA:
 
570
        case OSPF_OPAQUE_AREA_LSA:
 
571
        case OSPF_OPAQUE_AS_LSA:
 
572
          ospf_opaque_lsa_dump (s, length);
 
573
          break;
 
574
#endif /* HAVE_OPAQUE_LSA */
 
575
        default:
 
576
          break;
 
577
        }
 
578
 
 
579
      stream_forward (s, lsa_len);
 
580
      length -= lsa_len;
 
581
      count--;
 
582
    }
 
583
 
 
584
  stream_set_getp (s, sp);
 
585
}
 
586
 
 
587
void
 
588
ospf_packet_ls_ack_dump (struct stream *s, u_int16_t length)
 
589
{
 
590
  u_int32_t sp;
 
591
 
 
592
  length -= OSPF_HEADER_SIZE;
 
593
  sp = stream_get_getp (s);
 
594
 
 
595
  zlog_info ("Link State Acknowledgment");
 
596
  ospf_lsa_header_list_dump (s, length);
 
597
 
 
598
  stream_set_getp (s, sp);
 
599
}
 
600
 
 
601
void
 
602
ospf_ip_header_dump (struct stream *s)
 
603
{
 
604
  u_int16_t length;
 
605
  struct ip *iph;
 
606
 
 
607
  iph = (struct ip *) STREAM_PNT (s);
 
608
 
 
609
#ifdef GNU_LINUX
 
610
  length = ntohs (iph->ip_len);
 
611
#else /* GNU_LINUX */
 
612
  length = iph->ip_len;
 
613
#endif /* GNU_LINUX */
 
614
 
 
615
  /* IP Header dump. */
 
616
  zlog_info ("ip_v %d", iph->ip_v);
 
617
  zlog_info ("ip_hl %d", iph->ip_hl);
 
618
  zlog_info ("ip_tos %d", iph->ip_tos);
 
619
  zlog_info ("ip_len %d", length);
 
620
  zlog_info ("ip_id %u", (u_int32_t) iph->ip_id);
 
621
  zlog_info ("ip_off %u", (u_int32_t) iph->ip_off);
 
622
  zlog_info ("ip_ttl %d", iph->ip_ttl);
 
623
  zlog_info ("ip_p %d", iph->ip_p);
 
624
  /* There is a report that Linux 2.0.37 does not have ip_sum.  But
 
625
     I'm not sure.  Temporary commented out by kunihiro. */
 
626
  /* zlog_info ("ip_sum 0x%x", (u_int32_t) ntohs (iph->ip_sum)); */
 
627
  zlog_info ("ip_src %s",  inet_ntoa (iph->ip_src));
 
628
  zlog_info ("ip_dst %s", inet_ntoa (iph->ip_dst));
 
629
}
 
630
 
 
631
void
 
632
ospf_header_dump (struct ospf_header *ospfh)
 
633
{
 
634
  char buf[9];
 
635
 
 
636
  zlog_info ("Header");
 
637
  zlog_info ("  Version %d", ospfh->version);
 
638
  zlog_info ("  Type %d (%s)", ospfh->type,
 
639
             ospf_packet_type_str[ospfh->type]);
 
640
  zlog_info ("  Packet Len %d", ntohs (ospfh->length));
 
641
  zlog_info ("  Router ID %s", inet_ntoa (ospfh->router_id));
 
642
  zlog_info ("  Area ID %s", inet_ntoa (ospfh->area_id));
 
643
  zlog_info ("  Checksum 0x%x", ntohs (ospfh->checksum));
 
644
  zlog_info ("  AuType %d", ntohs (ospfh->auth_type));
 
645
 
 
646
  switch (ntohs (ospfh->auth_type))
 
647
    {
 
648
    case OSPF_AUTH_NULL:
 
649
      break;
 
650
    case OSPF_AUTH_SIMPLE:
 
651
      memset (buf, 0, 9);
 
652
      strncpy (buf, ospfh->u.auth_data, 8);
 
653
      zlog_info ("  Simple Password %s", buf);
 
654
      break;
 
655
    case OSPF_AUTH_CRYPTOGRAPHIC:
 
656
      zlog_info ("  Cryptographic Authentication");
 
657
      zlog_info ("  Key ID %d", ospfh->u.crypt.key_id);
 
658
      zlog_info ("  Auth Data Len %d", ospfh->u.crypt.auth_data_len);
 
659
      zlog_info ("  Sequence number %ld",
 
660
                 (u_long)ntohl (ospfh->u.crypt.crypt_seqnum));
 
661
      break;
 
662
    default:
 
663
      zlog_info ("* This is not supported authentication type");
 
664
      break;
 
665
    }
 
666
    
 
667
}
 
668
 
 
669
void
 
670
ospf_packet_dump (struct stream *s)
 
671
{
 
672
  struct ospf_header *ospfh;
 
673
  unsigned long gp;
 
674
 
 
675
  /* Preserve pointer. */
 
676
  gp = stream_get_getp (s);
 
677
 
 
678
  /* OSPF Header dump. */
 
679
  ospfh = (struct ospf_header *) STREAM_PNT (s);
 
680
 
 
681
  /* Until detail flag is set, return. */
 
682
  if (!(term_debug_ospf_packet[ospfh->type - 1] & OSPF_DEBUG_DETAIL))
 
683
    return;
 
684
 
 
685
  /* Show OSPF header detail. */
 
686
  ospf_header_dump (ospfh);
 
687
  stream_forward (s, OSPF_HEADER_SIZE);
 
688
 
 
689
  switch (ospfh->type)
 
690
    {
 
691
    case OSPF_MSG_HELLO:
 
692
      ospf_packet_hello_dump (s, ntohs (ospfh->length));
 
693
      break;
 
694
    case OSPF_MSG_DB_DESC:
 
695
      ospf_packet_db_desc_dump (s, ntohs (ospfh->length));
 
696
      break;
 
697
    case OSPF_MSG_LS_REQ:
 
698
      ospf_packet_ls_req_dump (s, ntohs (ospfh->length));
 
699
      break;
 
700
    case OSPF_MSG_LS_UPD:
 
701
      ospf_packet_ls_upd_dump (s, ntohs (ospfh->length));
 
702
      break;
 
703
    case OSPF_MSG_LS_ACK:
 
704
      ospf_packet_ls_ack_dump (s, ntohs (ospfh->length));
 
705
      break;
 
706
    default:
 
707
      break;
 
708
    }
 
709
 
 
710
  stream_set_getp (s, gp);
 
711
}
 
712
 
 
713
 
 
714
/*
 
715
   [no] debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)
 
716
                          [send|recv [detail]]
 
717
*/
 
718
DEFUN (debug_ospf_packet,
 
719
       debug_ospf_packet_all_cmd,
 
720
       "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
 
721
       DEBUG_STR
 
722
       OSPF_STR
 
723
       "OSPF packets\n"
 
724
       "OSPF Hello\n"
 
725
       "OSPF Database Description\n"
 
726
       "OSPF Link State Request\n"
 
727
       "OSPF Link State Update\n"
 
728
       "OSPF Link State Acknowledgment\n"
 
729
       "OSPF all packets\n")
 
730
{
 
731
  int type = 0;
 
732
  int flag = 0;
 
733
  int i;
 
734
 
 
735
  assert (argc > 0);
 
736
 
 
737
  /* Check packet type. */
 
738
  if (strncmp (argv[0], "h", 1) == 0)
 
739
    type = OSPF_DEBUG_HELLO;
 
740
  else if (strncmp (argv[0], "d", 1) == 0)
 
741
    type = OSPF_DEBUG_DB_DESC;
 
742
  else if (strncmp (argv[0], "ls-r", 4) == 0)
 
743
    type = OSPF_DEBUG_LS_REQ;
 
744
  else if (strncmp (argv[0], "ls-u", 4) == 0)
 
745
    type = OSPF_DEBUG_LS_UPD;
 
746
  else if (strncmp (argv[0], "ls-a", 4) == 0)
 
747
    type = OSPF_DEBUG_LS_ACK;
 
748
  else if (strncmp (argv[0], "a", 1) == 0)
 
749
    type = OSPF_DEBUG_ALL;
 
750
 
 
751
  /* Default, both send and recv. */
 
752
  if (argc == 1)
 
753
    flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV;
 
754
 
 
755
  /* send or recv. */
 
756
  if (argc >= 2)
 
757
    {
 
758
      if (strncmp (argv[1], "s", 1) == 0)
 
759
        flag = OSPF_DEBUG_SEND;
 
760
      else if (strncmp (argv[1], "r", 1) == 0)
 
761
        flag = OSPF_DEBUG_RECV;
 
762
      else if (strncmp (argv[1], "d", 1) == 0)
 
763
        flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
 
764
    }
 
765
 
 
766
  /* detail. */
 
767
  if (argc == 3)
 
768
    if (strncmp (argv[2], "d", 1) == 0)
 
769
      flag |= OSPF_DEBUG_DETAIL;
 
770
 
 
771
  for (i = 0; i < 5; i++)
 
772
    if (type & (0x01 << i))
 
773
      {
 
774
        if (vty->node == CONFIG_NODE)
 
775
          DEBUG_PACKET_ON (i, flag);
 
776
        else
 
777
          TERM_DEBUG_PACKET_ON (i, flag);
 
778
      }
 
779
 
 
780
  return CMD_SUCCESS;
 
781
}
 
782
 
 
783
ALIAS (debug_ospf_packet,
 
784
       debug_ospf_packet_send_recv_cmd,
 
785
       "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
 
786
       "Debugging functions\n"
 
787
       "OSPF information\n"
 
788
       "OSPF packets\n"
 
789
       "OSPF Hello\n"
 
790
       "OSPF Database Description\n"
 
791
       "OSPF Link State Request\n"
 
792
       "OSPF Link State Update\n"
 
793
       "OSPF Link State Acknowledgment\n"
 
794
       "OSPF all packets\n"
 
795
       "Packet sent\n"
 
796
       "Packet received\n"
 
797
       "Detail information\n")
 
798
 
 
799
ALIAS (debug_ospf_packet,
 
800
       debug_ospf_packet_send_recv_detail_cmd,
 
801
       "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
 
802
       "Debugging functions\n"
 
803
       "OSPF information\n"
 
804
       "OSPF packets\n"
 
805
       "OSPF Hello\n"
 
806
       "OSPF Database Description\n"
 
807
       "OSPF Link State Request\n"
 
808
       "OSPF Link State Update\n"
 
809
       "OSPF Link State Acknowledgment\n"
 
810
       "OSPF all packets\n"
 
811
       "Packet sent\n"
 
812
       "Packet received\n"
 
813
       "Detail Information\n")
 
814
       
 
815
 
 
816
DEFUN (no_debug_ospf_packet,
 
817
       no_debug_ospf_packet_all_cmd,
 
818
       "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
 
819
       NO_STR
 
820
       DEBUG_STR
 
821
       OSPF_STR
 
822
       "OSPF packets\n"
 
823
       "OSPF Hello\n"
 
824
       "OSPF Database Description\n"
 
825
       "OSPF Link State Request\n"
 
826
       "OSPF Link State Update\n"
 
827
       "OSPF Link State Acknowledgment\n"
 
828
       "OSPF all packets\n")
 
829
{
 
830
  int type = 0;
 
831
  int flag = 0;
 
832
  int i;
 
833
 
 
834
  assert (argc > 0);
 
835
 
 
836
  /* Check packet type. */
 
837
  if (strncmp (argv[0], "h", 1) == 0)
 
838
    type = OSPF_DEBUG_HELLO;
 
839
  else if (strncmp (argv[0], "d", 1) == 0)
 
840
    type = OSPF_DEBUG_DB_DESC;
 
841
  else if (strncmp (argv[0], "ls-r", 4) == 0)
 
842
    type = OSPF_DEBUG_LS_REQ;
 
843
  else if (strncmp (argv[0], "ls-u", 4) == 0)
 
844
    type = OSPF_DEBUG_LS_UPD;
 
845
  else if (strncmp (argv[0], "ls-a", 4) == 0)
 
846
    type = OSPF_DEBUG_LS_ACK;
 
847
  else if (strncmp (argv[0], "a", 1) == 0)
 
848
    type = OSPF_DEBUG_ALL;
 
849
 
 
850
  /* Default, both send and recv. */
 
851
  if (argc == 1)
 
852
    flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL ;
 
853
 
 
854
  /* send or recv. */
 
855
  if (argc == 2)
 
856
    {
 
857
      if (strncmp (argv[1], "s", 1) == 0)
 
858
        flag = OSPF_DEBUG_SEND | OSPF_DEBUG_DETAIL;
 
859
      else if (strncmp (argv[1], "r", 1) == 0)
 
860
        flag = OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
 
861
      else if (strncmp (argv[1], "d", 1) == 0)
 
862
        flag = OSPF_DEBUG_DETAIL;
 
863
    }
 
864
 
 
865
  /* detail. */
 
866
  if (argc == 3)
 
867
    if (strncmp (argv[2], "d", 1) == 0)
 
868
      flag = OSPF_DEBUG_DETAIL;
 
869
 
 
870
  for (i = 0; i < 5; i++)
 
871
    if (type & (0x01 << i))
 
872
      {
 
873
        if (vty->node == CONFIG_NODE)
 
874
          DEBUG_PACKET_OFF (i, flag);
 
875
        else
 
876
          TERM_DEBUG_PACKET_OFF (i, flag);
 
877
      }
 
878
 
 
879
#ifdef DEBUG
 
880
  for (i = 0; i < 5; i++)
 
881
    zlog_info ("flag[%d] = %d", i, ospf_debug_packet[i]);
 
882
#endif /* DEBUG */
 
883
 
 
884
  return CMD_SUCCESS;
 
885
}
 
886
 
 
887
ALIAS (no_debug_ospf_packet,
 
888
       no_debug_ospf_packet_send_recv_cmd,
 
889
       "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
 
890
       NO_STR
 
891
       "Debugging functions\n"
 
892
       "OSPF information\n"
 
893
       "OSPF packets\n"
 
894
       "OSPF Hello\n"
 
895
       "OSPF Database Description\n"
 
896
       "OSPF Link State Request\n"
 
897
       "OSPF Link State Update\n"
 
898
       "OSPF Link State Acknowledgment\n"
 
899
       "OSPF all packets\n"
 
900
       "Packet sent\n"
 
901
       "Packet received\n"
 
902
       "Detail Information\n")
 
903
 
 
904
ALIAS (no_debug_ospf_packet,
 
905
       no_debug_ospf_packet_send_recv_detail_cmd,
 
906
       "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
 
907
       NO_STR
 
908
       "Debugging functions\n"
 
909
       "OSPF information\n"
 
910
       "OSPF packets\n"
 
911
       "OSPF Hello\n"
 
912
       "OSPF Database Description\n"
 
913
       "OSPF Link State Request\n"
 
914
       "OSPF Link State Update\n"
 
915
       "OSPF Link State Acknowledgment\n"
 
916
       "OSPF all packets\n"
 
917
       "Packet sent\n"
 
918
       "Packet received\n"
 
919
       "Detail Information\n")
 
920
 
 
921
 
 
922
DEFUN (debug_ospf_ism,
 
923
       debug_ospf_ism_cmd,
 
924
       "debug ospf ism",
 
925
       DEBUG_STR
 
926
       OSPF_STR
 
927
       "OSPF Interface State Machine\n")
 
928
{
 
929
  if (vty->node == CONFIG_NODE)
 
930
    {
 
931
      if (argc == 0)
 
932
        DEBUG_ON (ism, ISM);
 
933
      else if (argc == 1)
 
934
        {
 
935
          if (strncmp (argv[0], "s", 1) == 0)
 
936
            DEBUG_ON (ism, ISM_STATUS);
 
937
          else if (strncmp (argv[0], "e", 1) == 0)
 
938
            DEBUG_ON (ism, ISM_EVENTS);
 
939
          else if (strncmp (argv[0], "t", 1) == 0)
 
940
            DEBUG_ON (ism, ISM_TIMERS);
 
941
        }
 
942
 
 
943
      return CMD_SUCCESS;
 
944
    }
 
945
 
 
946
  /* ENABLE_NODE. */
 
947
  if (argc == 0)
 
948
    TERM_DEBUG_ON (ism, ISM);
 
949
  else if (argc == 1)
 
950
    {
 
951
      if (strncmp (argv[0], "s", 1) == 0)
 
952
        TERM_DEBUG_ON (ism, ISM_STATUS);
 
953
      else if (strncmp (argv[0], "e", 1) == 0)
 
954
        TERM_DEBUG_ON (ism, ISM_EVENTS);
 
955
      else if (strncmp (argv[0], "t", 1) == 0)
 
956
        TERM_DEBUG_ON (ism, ISM_TIMERS);
 
957
    }
 
958
 
 
959
  return CMD_SUCCESS;
 
960
}
 
961
 
 
962
ALIAS (debug_ospf_ism,
 
963
       debug_ospf_ism_sub_cmd,
 
964
       "debug ospf ism (status|events|timers)",
 
965
       DEBUG_STR
 
966
       OSPF_STR
 
967
       "OSPF Interface State Machine\n"
 
968
       "ISM Status Information\n"
 
969
       "ISM Event Information\n"
 
970
       "ISM TImer Information\n")
 
971
 
 
972
DEFUN (no_debug_ospf_ism,
 
973
       no_debug_ospf_ism_cmd,
 
974
       "no debug ospf ism",
 
975
       NO_STR
 
976
       DEBUG_STR
 
977
       OSPF_STR
 
978
       "OSPF Interface State Machine")
 
979
{
 
980
  if (vty->node == CONFIG_NODE)
 
981
    {
 
982
      if (argc == 0)
 
983
        DEBUG_OFF (ism, ISM);
 
984
      else if (argc == 1)
 
985
        {
 
986
          if (strncmp (argv[0], "s", 1) == 0)
 
987
            DEBUG_OFF (ism, ISM_STATUS);
 
988
          else if (strncmp (argv[0], "e", 1) == 0)
 
989
            DEBUG_OFF (ism, ISM_EVENTS);
 
990
          else if (strncmp (argv[0], "t", 1) == 0)
 
991
            DEBUG_OFF (ism, ISM_TIMERS);
 
992
        }
 
993
      return CMD_SUCCESS;
 
994
    }
 
995
 
 
996
  /* ENABLE_NODE. */
 
997
  if (argc == 0)
 
998
    TERM_DEBUG_OFF (ism, ISM);
 
999
  else if (argc == 1)
 
1000
    {
 
1001
      if (strncmp (argv[0], "s", 1) == 0)
 
1002
        TERM_DEBUG_OFF (ism, ISM_STATUS);
 
1003
      else if (strncmp (argv[0], "e", 1) == 0)
 
1004
        TERM_DEBUG_OFF (ism, ISM_EVENTS);
 
1005
      else if (strncmp (argv[0], "t", 1) == 0)
 
1006
        TERM_DEBUG_OFF (ism, ISM_TIMERS);
 
1007
    }
 
1008
 
 
1009
  return CMD_SUCCESS;
 
1010
}
 
1011
 
 
1012
ALIAS (no_debug_ospf_ism,
 
1013
       no_debug_ospf_ism_sub_cmd,
 
1014
       "no debug ospf ism (status|events|timers)",
 
1015
       NO_STR
 
1016
       "Debugging functions\n"
 
1017
       "OSPF information\n"
 
1018
       "OSPF Interface State Machine\n"
 
1019
       "ISM Status Information\n"
 
1020
       "ISM Event Information\n"
 
1021
       "ISM Timer Information\n")
 
1022
 
 
1023
 
 
1024
DEFUN (debug_ospf_nsm,
 
1025
       debug_ospf_nsm_cmd,
 
1026
       "debug ospf nsm",
 
1027
       DEBUG_STR
 
1028
       OSPF_STR
 
1029
       "OSPF Neighbor State Machine\n")
 
1030
{
 
1031
  if (vty->node == CONFIG_NODE)
 
1032
    {
 
1033
      if (argc == 0)
 
1034
        DEBUG_ON (nsm, NSM);
 
1035
      else if (argc == 1)
 
1036
        {
 
1037
          if (strncmp (argv[0], "s", 1) == 0)
 
1038
            DEBUG_ON (nsm, NSM_STATUS);
 
1039
          else if (strncmp (argv[0], "e", 1) == 0)
 
1040
            DEBUG_ON (nsm, NSM_EVENTS);
 
1041
          else if (strncmp (argv[0], "t", 1) == 0)
 
1042
            DEBUG_ON (nsm, NSM_TIMERS);
 
1043
        }
 
1044
 
 
1045
      return CMD_SUCCESS;
 
1046
    }
 
1047
 
 
1048
  /* ENABLE_NODE. */
 
1049
  if (argc == 0)
 
1050
    TERM_DEBUG_ON (nsm, NSM);
 
1051
  else if (argc == 1)
 
1052
    {
 
1053
      if (strncmp (argv[0], "s", 1) == 0)
 
1054
        TERM_DEBUG_ON (nsm, NSM_STATUS);
 
1055
      else if (strncmp (argv[0], "e", 1) == 0)
 
1056
        TERM_DEBUG_ON (nsm, NSM_EVENTS);
 
1057
      else if (strncmp (argv[0], "t", 1) == 0)
 
1058
        TERM_DEBUG_ON (nsm, NSM_TIMERS);
 
1059
    }
 
1060
 
 
1061
  return CMD_SUCCESS;
 
1062
}
 
1063
 
 
1064
ALIAS (debug_ospf_nsm,
 
1065
       debug_ospf_nsm_sub_cmd,
 
1066
       "debug ospf nsm (status|events|timers)",
 
1067
       DEBUG_STR
 
1068
       OSPF_STR
 
1069
       "OSPF Neighbor State Machine\n"
 
1070
       "NSM Status Information\n"
 
1071
       "NSM Event Information\n"
 
1072
       "NSM Timer Information\n")
 
1073
 
 
1074
DEFUN (no_debug_ospf_nsm,
 
1075
       no_debug_ospf_nsm_cmd,
 
1076
       "no debug ospf nsm",
 
1077
       NO_STR
 
1078
       DEBUG_STR
 
1079
       OSPF_STR
 
1080
       "OSPF Neighbor State Machine")
 
1081
{
 
1082
  if (vty->node == CONFIG_NODE)
 
1083
    {
 
1084
      if (argc == 0)
 
1085
        DEBUG_OFF (nsm, NSM);
 
1086
      else if (argc == 1)
 
1087
        {
 
1088
          if (strncmp (argv[0], "s", 1) == 0)
 
1089
            DEBUG_OFF (nsm, NSM_STATUS);
 
1090
          else if (strncmp (argv[0], "e", 1) == 0)
 
1091
            DEBUG_OFF (nsm, NSM_EVENTS);
 
1092
          else if (strncmp (argv[0], "t", 1) == 0)
 
1093
            DEBUG_OFF (nsm, NSM_TIMERS);
 
1094
        }
 
1095
 
 
1096
      return CMD_SUCCESS;
 
1097
    }
 
1098
 
 
1099
  /* ENABLE_NODE. */
 
1100
  if (argc == 0)
 
1101
    TERM_DEBUG_OFF (nsm, NSM);
 
1102
  else if (argc == 1)
 
1103
    {
 
1104
      if (strncmp (argv[0], "s", 1) == 0)
 
1105
        TERM_DEBUG_OFF (nsm, NSM_STATUS);
 
1106
      else if (strncmp (argv[0], "e", 1) == 0)
 
1107
        TERM_DEBUG_OFF (nsm, NSM_EVENTS);
 
1108
      else if (strncmp (argv[0], "t", 1) == 0)
 
1109
        TERM_DEBUG_OFF (nsm, NSM_TIMERS);
 
1110
    }
 
1111
 
 
1112
  return CMD_SUCCESS;
 
1113
}
 
1114
 
 
1115
ALIAS (no_debug_ospf_nsm,
 
1116
       no_debug_ospf_nsm_sub_cmd,
 
1117
       "no debug ospf nsm (status|events|timers)",
 
1118
       NO_STR
 
1119
       "Debugging functions\n"
 
1120
       "OSPF information\n"
 
1121
       "OSPF Interface State Machine\n"
 
1122
       "NSM Status Information\n"
 
1123
       "NSM Event Information\n"
 
1124
       "NSM Timer Information\n")
 
1125
 
 
1126
 
 
1127
DEFUN (debug_ospf_lsa,
 
1128
       debug_ospf_lsa_cmd,
 
1129
       "debug ospf lsa",
 
1130
       DEBUG_STR
 
1131
       OSPF_STR
 
1132
       "OSPF Link State Advertisement\n")
 
1133
{
 
1134
  if (vty->node == CONFIG_NODE)
 
1135
    {
 
1136
      if (argc == 0)
 
1137
        DEBUG_ON (lsa, LSA);
 
1138
      else if (argc == 1)
 
1139
        {
 
1140
          if (strncmp (argv[0], "g", 1) == 0)
 
1141
            DEBUG_ON (lsa, LSA_GENERATE);
 
1142
          else if (strncmp (argv[0], "f", 1) == 0)
 
1143
            DEBUG_ON (lsa, LSA_FLOODING);
 
1144
          else if (strncmp (argv[0], "i", 1) == 0)
 
1145
            DEBUG_ON (lsa, LSA_INSTALL);
 
1146
          else if (strncmp (argv[0], "r", 1) == 0)
 
1147
            DEBUG_ON (lsa, LSA_REFRESH);
 
1148
        }
 
1149
 
 
1150
      return CMD_SUCCESS;
 
1151
    }
 
1152
 
 
1153
  /* ENABLE_NODE. */
 
1154
  if (argc == 0)
 
1155
    TERM_DEBUG_ON (lsa, LSA);
 
1156
  else if (argc == 1)
 
1157
    {
 
1158
      if (strncmp (argv[0], "g", 1) == 0)
 
1159
        TERM_DEBUG_ON (lsa, LSA_GENERATE);
 
1160
      else if (strncmp (argv[0], "f", 1) == 0)
 
1161
        TERM_DEBUG_ON (lsa, LSA_FLOODING);
 
1162
      else if (strncmp (argv[0], "i", 1) == 0)
 
1163
        TERM_DEBUG_ON (lsa, LSA_INSTALL);
 
1164
      else if (strncmp (argv[0], "r", 1) == 0)
 
1165
        TERM_DEBUG_ON (lsa, LSA_REFRESH);
 
1166
    }
 
1167
 
 
1168
  return CMD_SUCCESS;
 
1169
}
 
1170
 
 
1171
ALIAS (debug_ospf_lsa,
 
1172
       debug_ospf_lsa_sub_cmd,
 
1173
       "debug ospf lsa (generate|flooding|install|refresh)",
 
1174
       DEBUG_STR
 
1175
       OSPF_STR
 
1176
       "OSPF Link State Advertisement\n"
 
1177
       "LSA Generation\n"
 
1178
       "LSA Flooding\n"
 
1179
       "LSA Install/Delete\n"
 
1180
       "LSA Refresh\n")
 
1181
 
 
1182
DEFUN (no_debug_ospf_lsa,
 
1183
       no_debug_ospf_lsa_cmd,
 
1184
       "no debug ospf lsa",
 
1185
       NO_STR
 
1186
       DEBUG_STR
 
1187
       OSPF_STR
 
1188
       "OSPF Link State Advertisement\n")
 
1189
{
 
1190
  if (vty->node == CONFIG_NODE)
 
1191
    {
 
1192
      if (argc == 0)
 
1193
        DEBUG_OFF (lsa, LSA);
 
1194
      else if (argc == 1)
 
1195
        {
 
1196
          if (strncmp (argv[0], "g", 1) == 0)
 
1197
            DEBUG_OFF (lsa, LSA_GENERATE);
 
1198
          else if (strncmp (argv[0], "f", 1) == 0)
 
1199
            DEBUG_OFF (lsa, LSA_FLOODING);
 
1200
          else if (strncmp (argv[0], "i", 1) == 0)
 
1201
            DEBUG_OFF (lsa, LSA_INSTALL);
 
1202
          else if (strncmp (argv[0], "r", 1) == 0)
 
1203
            DEBUG_OFF (lsa, LSA_REFRESH);
 
1204
        }
 
1205
 
 
1206
      return CMD_SUCCESS;
 
1207
    }
 
1208
 
 
1209
  /* ENABLE_NODE. */
 
1210
  if (argc == 0)
 
1211
    TERM_DEBUG_OFF (lsa, LSA);
 
1212
  else if (argc == 1)
 
1213
    {
 
1214
      if (strncmp (argv[0], "g", 1) == 0)
 
1215
        TERM_DEBUG_OFF (lsa, LSA_GENERATE);
 
1216
      else if (strncmp (argv[0], "f", 1) == 0)
 
1217
        TERM_DEBUG_OFF (lsa, LSA_FLOODING);
 
1218
      else if (strncmp (argv[0], "i", 1) == 0)
 
1219
        TERM_DEBUG_OFF (lsa, LSA_INSTALL);
 
1220
      else if (strncmp (argv[0], "r", 1) == 0)
 
1221
        TERM_DEBUG_OFF (lsa, LSA_REFRESH);
 
1222
    }
 
1223
 
 
1224
  return CMD_SUCCESS;
 
1225
}
 
1226
 
 
1227
ALIAS (no_debug_ospf_lsa,
 
1228
       no_debug_ospf_lsa_sub_cmd,
 
1229
       "no debug ospf lsa (generate|flooding|install|refresh)",
 
1230
       NO_STR
 
1231
       DEBUG_STR
 
1232
       OSPF_STR
 
1233
       "OSPF Link State Advertisement\n"
 
1234
       "LSA Generation\n"
 
1235
       "LSA Flooding\n"
 
1236
       "LSA Install/Delete\n"
 
1237
       "LSA Refres\n")
 
1238
 
 
1239
 
 
1240
DEFUN (debug_ospf_zebra,
 
1241
       debug_ospf_zebra_cmd,
 
1242
       "debug ospf zebra",
 
1243
       DEBUG_STR
 
1244
       OSPF_STR
 
1245
       "OSPF Zebra information\n")
 
1246
{
 
1247
  if (vty->node == CONFIG_NODE)
 
1248
    {
 
1249
      if (argc == 0)
 
1250
        DEBUG_ON (zebra, ZEBRA);
 
1251
      else if (argc == 1)
 
1252
        {
 
1253
          if (strncmp (argv[0], "i", 1) == 0)
 
1254
            DEBUG_ON (zebra, ZEBRA_INTERFACE);
 
1255
          else if (strncmp (argv[0], "r", 1) == 0)
 
1256
            DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
 
1257
        }
 
1258
 
 
1259
      return CMD_SUCCESS;
 
1260
    }
 
1261
 
 
1262
  /* ENABLE_NODE. */
 
1263
  if (argc == 0)
 
1264
    TERM_DEBUG_ON (zebra, ZEBRA);
 
1265
  else if (argc == 1)
 
1266
    {
 
1267
      if (strncmp (argv[0], "i", 1) == 0)
 
1268
        TERM_DEBUG_ON (zebra, ZEBRA_INTERFACE);
 
1269
      else if (strncmp (argv[0], "r", 1) == 0)
 
1270
        TERM_DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
 
1271
    }
 
1272
 
 
1273
  return CMD_SUCCESS;
 
1274
}
 
1275
 
 
1276
ALIAS (debug_ospf_zebra,
 
1277
       debug_ospf_zebra_sub_cmd,
 
1278
       "debug ospf zebra (interface|redistribute)",
 
1279
       DEBUG_STR
 
1280
       OSPF_STR
 
1281
       "OSPF Zebra information\n"
 
1282
       "Zebra interface\n"
 
1283
       "Zebra redistribute\n")
 
1284
 
 
1285
DEFUN (no_debug_ospf_zebra,
 
1286
       no_debug_ospf_zebra_cmd,
 
1287
       "no debug ospf zebra",
 
1288
       NO_STR
 
1289
       DEBUG_STR
 
1290
       OSPF_STR
 
1291
       "OSPF Zebra information\n")
 
1292
{
 
1293
  if (vty->node == CONFIG_NODE)
 
1294
    {
 
1295
      if (argc == 0)
 
1296
        DEBUG_OFF (zebra, ZEBRA);
 
1297
      else if (argc == 1)
 
1298
        {
 
1299
          if (strncmp (argv[0], "i", 1) == 0)
 
1300
            DEBUG_OFF (zebra, ZEBRA_INTERFACE);
 
1301
          else if (strncmp (argv[0], "r", 1) == 0)
 
1302
            DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
 
1303
        }
 
1304
 
 
1305
      return CMD_SUCCESS;
 
1306
    }
 
1307
 
 
1308
  /* ENABLE_NODE. */
 
1309
  if (argc == 0)
 
1310
    TERM_DEBUG_OFF (zebra, ZEBRA);
 
1311
  else if (argc == 1)
 
1312
    {
 
1313
      if (strncmp (argv[0], "i", 1) == 0)
 
1314
        TERM_DEBUG_OFF (zebra, ZEBRA_INTERFACE);
 
1315
      else if (strncmp (argv[0], "r", 1) == 0)
 
1316
        TERM_DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
 
1317
    }
 
1318
 
 
1319
  return CMD_SUCCESS;
 
1320
}
 
1321
 
 
1322
ALIAS (no_debug_ospf_zebra,
 
1323
       no_debug_ospf_zebra_sub_cmd,
 
1324
       "no debug ospf zebra (interface|redistribute)",
 
1325
       NO_STR
 
1326
       DEBUG_STR
 
1327
       OSPF_STR
 
1328
       "OSPF Zebra information\n"
 
1329
       "Zebra interface\n"
 
1330
       "Zebra redistribute\n")
 
1331
 
 
1332
DEFUN (debug_ospf_event,
 
1333
       debug_ospf_event_cmd,
 
1334
       "debug ospf event",
 
1335
       DEBUG_STR
 
1336
       OSPF_STR
 
1337
       "OSPF event information\n")
 
1338
{
 
1339
  if (vty->node == CONFIG_NODE)
 
1340
    CONF_DEBUG_ON (event, EVENT);
 
1341
  TERM_DEBUG_ON (event, EVENT);
 
1342
  return CMD_SUCCESS;
 
1343
}
 
1344
 
 
1345
DEFUN (no_debug_ospf_event,
 
1346
       no_debug_ospf_event_cmd,
 
1347
       "no debug ospf event",
 
1348
       NO_STR
 
1349
       DEBUG_STR
 
1350
       OSPF_STR
 
1351
       "OSPF event information\n")
 
1352
{
 
1353
  if (vty->node == CONFIG_NODE)
 
1354
    CONF_DEBUG_OFF (event, EVENT);
 
1355
  TERM_DEBUG_OFF (event, EVENT);
 
1356
  return CMD_SUCCESS;
 
1357
}
 
1358
 
 
1359
DEFUN (debug_ospf_nssa,
 
1360
       debug_ospf_nssa_cmd,
 
1361
       "debug ospf nssa",
 
1362
       DEBUG_STR
 
1363
       OSPF_STR
 
1364
       "OSPF nssa information\n")
 
1365
{
 
1366
  if (vty->node == CONFIG_NODE)
 
1367
    CONF_DEBUG_ON (nssa, NSSA);
 
1368
  TERM_DEBUG_ON (nssa, NSSA);
 
1369
  return CMD_SUCCESS;
 
1370
}
 
1371
 
 
1372
DEFUN (no_debug_ospf_nssa,
 
1373
       no_debug_ospf_nssa_cmd,
 
1374
       "no debug ospf nssa",
 
1375
       NO_STR
 
1376
       DEBUG_STR
 
1377
       OSPF_STR
 
1378
       "OSPF nssa information\n")
 
1379
{
 
1380
  if (vty->node == CONFIG_NODE)
 
1381
    CONF_DEBUG_OFF (nssa, NSSA);
 
1382
  TERM_DEBUG_OFF (nssa, NSSA);
 
1383
  return CMD_SUCCESS;
 
1384
}
 
1385
 
 
1386
 
 
1387
DEFUN (show_debugging_ospf,
 
1388
       show_debugging_ospf_cmd,
 
1389
       "show debugging ospf",
 
1390
       SHOW_STR
 
1391
       DEBUG_STR
 
1392
       OSPF_STR)
 
1393
{
 
1394
  int i;
 
1395
 
 
1396
  vty_out (vty, "Zebra debugging status:%s", VTY_NEWLINE);
 
1397
 
 
1398
  /* Show debug status for ISM. */
 
1399
  if (IS_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
 
1400
    vty_out (vty, "  OSPF ISM debugging is on%s", VTY_NEWLINE);
 
1401
  else
 
1402
    {
 
1403
      if (IS_DEBUG_OSPF (ism, ISM_STATUS))
 
1404
        vty_out (vty, "  OSPF ISM status debugging is on%s", VTY_NEWLINE);
 
1405
      if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
 
1406
        vty_out (vty, "  OSPF ISM event debugging is on%s", VTY_NEWLINE);
 
1407
      if (IS_DEBUG_OSPF (ism, ISM_TIMERS))
 
1408
        vty_out (vty, "  OSPF ISM timer debugging is on%s", VTY_NEWLINE);
 
1409
    }
 
1410
 
 
1411
  /* Show debug status for NSM. */
 
1412
  if (IS_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
 
1413
    vty_out (vty, "  OSPF NSM debugging is on%s", VTY_NEWLINE);
 
1414
  else
 
1415
    {
 
1416
      if (IS_DEBUG_OSPF (nsm, NSM_STATUS))
 
1417
        vty_out (vty, "  OSPF NSM status debugging is on%s", VTY_NEWLINE);
 
1418
      if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
 
1419
        vty_out (vty, "  OSPF NSM event debugging is on%s", VTY_NEWLINE);
 
1420
      if (IS_DEBUG_OSPF (nsm, NSM_TIMERS))
 
1421
        vty_out (vty, "  OSPF NSM timer debugging is on%s", VTY_NEWLINE);
 
1422
    }
 
1423
 
 
1424
  /* Show debug status for OSPF Packets. */
 
1425
  for (i = 0; i < 5; i++)
 
1426
    if (IS_DEBUG_OSPF_PACKET (i, SEND) && IS_DEBUG_OSPF_PACKET (i, RECV))
 
1427
      {
 
1428
        vty_out (vty, "  OSPF packet %s%s debugging is on%s",
 
1429
                 ospf_packet_type_str[i + 1],
 
1430
                 IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
 
1431
                 VTY_NEWLINE);
 
1432
      }
 
1433
    else
 
1434
      {
 
1435
        if (IS_DEBUG_OSPF_PACKET (i, SEND))
 
1436
          vty_out (vty, "  OSPF packet %s send%s debugging is on%s",
 
1437
                   ospf_packet_type_str[i + 1],
 
1438
                   IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
 
1439
                   VTY_NEWLINE);
 
1440
        if (IS_DEBUG_OSPF_PACKET (i, RECV))
 
1441
          vty_out (vty, "  OSPF packet %s receive%s debugging is on%s",
 
1442
                   ospf_packet_type_str[i + 1],
 
1443
                   IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
 
1444
                   VTY_NEWLINE);
 
1445
      }
 
1446
 
 
1447
  /* Show debug status for OSPF LSAs. */
 
1448
  if (IS_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
 
1449
    vty_out (vty, "  OSPF LSA debugging is on%s", VTY_NEWLINE);
 
1450
  else
 
1451
    {
 
1452
      if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
 
1453
        vty_out (vty, "  OSPF LSA generation debugging is on%s", VTY_NEWLINE);
 
1454
      if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
 
1455
        vty_out (vty, "  OSPF LSA flooding debugging is on%s", VTY_NEWLINE);
 
1456
      if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
 
1457
        vty_out (vty, "  OSPF LSA install debugging is on%s", VTY_NEWLINE);
 
1458
      if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
 
1459
        vty_out (vty, "  OSPF LSA refresh debugging is on%s", VTY_NEWLINE);
 
1460
    }
 
1461
 
 
1462
  /* Show debug status for Zebra. */
 
1463
  if (IS_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
 
1464
    vty_out (vty, "  OSPF Zebra debugging is on%s", VTY_NEWLINE);
 
1465
  else
 
1466
    {
 
1467
      if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
 
1468
        vty_out (vty, "  OSPF Zebra interface debugging is on%s", VTY_NEWLINE);
 
1469
      if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
 
1470
        vty_out (vty, "  OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE);
 
1471
    }
 
1472
  if (IS_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
 
1473
    vty_out (vty, "  OSPF NSSA debugging is on%s", VTY_NEWLINE);
 
1474
 
 
1475
  return CMD_SUCCESS;
 
1476
}
 
1477
 
 
1478
/* Debug node. */
 
1479
struct cmd_node debug_node =
 
1480
{
 
1481
  DEBUG_NODE,
 
1482
  ""
 
1483
};
 
1484
 
 
1485
int
 
1486
config_write_debug (struct vty *vty)
 
1487
{
 
1488
  int write = 0;
 
1489
  int i, r;
 
1490
 
 
1491
  char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
 
1492
  char *detail_str[] = {"", " send", " recv", "", " detail",
 
1493
                        " send detail", " recv detail", " detail"};
 
1494
 
 
1495
  /* debug ospf ism (status|events|timers). */
 
1496
  if (IS_CONF_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
 
1497
    vty_out (vty, "debug ospf ism%s", VTY_NEWLINE);
 
1498
  else
 
1499
    {
 
1500
      if (IS_CONF_DEBUG_OSPF (ism, ISM_STATUS))
 
1501
        vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE);
 
1502
      if (IS_CONF_DEBUG_OSPF (ism, ISM_EVENTS))
 
1503
        vty_out (vty, "debug ospf ism event%s", VTY_NEWLINE);
 
1504
      if (IS_CONF_DEBUG_OSPF (ism, ISM_TIMERS))
 
1505
        vty_out (vty, "debug ospf ism timer%s", VTY_NEWLINE);
 
1506
    }
 
1507
 
 
1508
  /* debug ospf nsm (status|events|timers). */
 
1509
  if (IS_CONF_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
 
1510
    vty_out (vty, "debug ospf nsm%s", VTY_NEWLINE);
 
1511
  else
 
1512
    {
 
1513
      if (IS_CONF_DEBUG_OSPF (nsm, NSM_STATUS))
 
1514
        vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE);
 
1515
      if (IS_CONF_DEBUG_OSPF (nsm, NSM_EVENTS))
 
1516
        vty_out (vty, "debug ospf nsm event%s", VTY_NEWLINE);
 
1517
      if (IS_CONF_DEBUG_OSPF (nsm, NSM_TIMERS))
 
1518
        vty_out (vty, "debug ospf nsm timer%s", VTY_NEWLINE);
 
1519
    }
 
1520
 
 
1521
  /* debug ospf lsa (generate|flooding|install|refresh). */
 
1522
  if (IS_CONF_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
 
1523
    vty_out (vty, "debug ospf lsa%s", VTY_NEWLINE);
 
1524
  else
 
1525
    {
 
1526
      if (IS_CONF_DEBUG_OSPF (lsa, LSA_GENERATE))
 
1527
        vty_out (vty, "debug ospf lsa generate%s", VTY_NEWLINE);
 
1528
      if (IS_CONF_DEBUG_OSPF (lsa, LSA_FLOODING))
 
1529
        vty_out (vty, "debug ospf lsa flooding%s", VTY_NEWLINE);
 
1530
      if (IS_CONF_DEBUG_OSPF (lsa, LSA_INSTALL))
 
1531
        vty_out (vty, "debug ospf lsa install%s", VTY_NEWLINE);
 
1532
      if (IS_CONF_DEBUG_OSPF (lsa, LSA_REFRESH))
 
1533
        vty_out (vty, "debug ospf lsa refresh%s", VTY_NEWLINE);
 
1534
 
 
1535
      write = 1;
 
1536
    }
 
1537
 
 
1538
  /* debug ospf zebra (interface|redistribute). */
 
1539
  if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
 
1540
    vty_out (vty, "debug ospf zebra%s", VTY_NEWLINE);
 
1541
  else
 
1542
    {
 
1543
      if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
 
1544
        vty_out (vty, "debug ospf zebra interface%s", VTY_NEWLINE);
 
1545
      if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
 
1546
        vty_out (vty, "debug ospf zebra redistribute%s", VTY_NEWLINE);
 
1547
 
 
1548
      write = 1;
 
1549
    }
 
1550
 
 
1551
  /* debug ospf event. */
 
1552
  if (IS_CONF_DEBUG_OSPF (event, EVENT) == OSPF_DEBUG_EVENT)
 
1553
    {
 
1554
      vty_out (vty, "debug ospf event%s", VTY_NEWLINE);
 
1555
      write = 1;
 
1556
    }
 
1557
 
 
1558
  /* debug ospf nssa. */
 
1559
  if (IS_CONF_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
 
1560
    {
 
1561
      vty_out (vty, "debug ospf nssa%s", VTY_NEWLINE);
 
1562
      write = 1;
 
1563
    }
 
1564
  
 
1565
  /* debug ospf packet all detail. */
 
1566
  r = OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL;
 
1567
  for (i = 0; i < 5; i++)
 
1568
    r &= conf_debug_ospf_packet[i] & (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL);
 
1569
  if (r == (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL))
 
1570
    {
 
1571
      vty_out (vty, "debug ospf packet all detail%s", VTY_NEWLINE);
 
1572
      return 1;
 
1573
    }
 
1574
 
 
1575
  /* debug ospf packet all. */
 
1576
  r = OSPF_DEBUG_SEND_RECV;
 
1577
  for (i = 0; i < 5; i++)
 
1578
    r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV;
 
1579
  if (r == OSPF_DEBUG_SEND_RECV)
 
1580
    {
 
1581
      vty_out (vty, "debug ospf packet all%s", VTY_NEWLINE);
 
1582
      for (i = 0; i < 5; i++)
 
1583
        if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL)
 
1584
          vty_out (vty, "debug ospf packet %s detail%s",
 
1585
                   type_str[i],
 
1586
                   VTY_NEWLINE);
 
1587
      return 1;
 
1588
    }
 
1589
 
 
1590
  /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
 
1591
     (send|recv) (detail). */
 
1592
  for (i = 0; i < 5; i++)
 
1593
    {
 
1594
      if (conf_debug_ospf_packet[i] == 0)
 
1595
        continue;
 
1596
      
 
1597
      vty_out (vty, "debug ospf packet %s%s%s",
 
1598
               type_str[i], detail_str[conf_debug_ospf_packet[i]],
 
1599
               VTY_NEWLINE);
 
1600
      write = 1;
 
1601
    }
 
1602
 
 
1603
  return write;
 
1604
}
 
1605
 
 
1606
/* Initialize debug commands. */
 
1607
void
 
1608
debug_init ()
 
1609
{
 
1610
  install_node (&debug_node, config_write_debug);
 
1611
 
 
1612
  install_element (ENABLE_NODE, &show_debugging_ospf_cmd);
 
1613
  install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_detail_cmd);
 
1614
  install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_cmd);
 
1615
  install_element (ENABLE_NODE, &debug_ospf_packet_all_cmd);
 
1616
  install_element (ENABLE_NODE, &debug_ospf_ism_sub_cmd);
 
1617
  install_element (ENABLE_NODE, &debug_ospf_ism_cmd);
 
1618
  install_element (ENABLE_NODE, &debug_ospf_nsm_sub_cmd);
 
1619
  install_element (ENABLE_NODE, &debug_ospf_nsm_cmd);
 
1620
  install_element (ENABLE_NODE, &debug_ospf_lsa_sub_cmd);
 
1621
  install_element (ENABLE_NODE, &debug_ospf_lsa_cmd);
 
1622
  install_element (ENABLE_NODE, &debug_ospf_zebra_sub_cmd);
 
1623
  install_element (ENABLE_NODE, &debug_ospf_zebra_cmd);
 
1624
  install_element (ENABLE_NODE, &debug_ospf_event_cmd);
 
1625
#ifdef HAVE_NSSA
 
1626
  install_element (ENABLE_NODE, &debug_ospf_nssa_cmd);
 
1627
#endif /* HAVE_NSSA */
 
1628
  install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
 
1629
  install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_cmd);
 
1630
  install_element (ENABLE_NODE, &no_debug_ospf_packet_all_cmd);
 
1631
  install_element (ENABLE_NODE, &no_debug_ospf_ism_sub_cmd);
 
1632
  install_element (ENABLE_NODE, &no_debug_ospf_ism_cmd);
 
1633
  install_element (ENABLE_NODE, &no_debug_ospf_nsm_sub_cmd);
 
1634
  install_element (ENABLE_NODE, &no_debug_ospf_nsm_cmd);
 
1635
  install_element (ENABLE_NODE, &no_debug_ospf_lsa_sub_cmd);
 
1636
  install_element (ENABLE_NODE, &no_debug_ospf_lsa_cmd);
 
1637
  install_element (ENABLE_NODE, &no_debug_ospf_zebra_sub_cmd);
 
1638
  install_element (ENABLE_NODE, &no_debug_ospf_zebra_cmd);
 
1639
  install_element (ENABLE_NODE, &no_debug_ospf_event_cmd);
 
1640
#ifdef HAVE_NSSA
 
1641
  install_element (ENABLE_NODE, &no_debug_ospf_nssa_cmd);
 
1642
#endif /* HAVE_NSSA */
 
1643
 
 
1644
  install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_detail_cmd);
 
1645
  install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_cmd);
 
1646
  install_element (CONFIG_NODE, &debug_ospf_packet_all_cmd);
 
1647
  install_element (CONFIG_NODE, &debug_ospf_ism_sub_cmd);
 
1648
  install_element (CONFIG_NODE, &debug_ospf_ism_cmd);
 
1649
  install_element (CONFIG_NODE, &debug_ospf_nsm_sub_cmd);
 
1650
  install_element (CONFIG_NODE, &debug_ospf_nsm_cmd);
 
1651
  install_element (CONFIG_NODE, &debug_ospf_lsa_sub_cmd);
 
1652
  install_element (CONFIG_NODE, &debug_ospf_lsa_cmd);
 
1653
  install_element (CONFIG_NODE, &debug_ospf_zebra_sub_cmd);
 
1654
  install_element (CONFIG_NODE, &debug_ospf_zebra_cmd);
 
1655
  install_element (CONFIG_NODE, &debug_ospf_event_cmd);
 
1656
#ifdef HAVE_NSSA
 
1657
  install_element (CONFIG_NODE, &debug_ospf_nssa_cmd);
 
1658
#endif /* HAVE_NSSA */
 
1659
  install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
 
1660
  install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_cmd);
 
1661
  install_element (CONFIG_NODE, &no_debug_ospf_packet_all_cmd);
 
1662
  install_element (CONFIG_NODE, &no_debug_ospf_ism_sub_cmd);
 
1663
  install_element (CONFIG_NODE, &no_debug_ospf_ism_cmd);
 
1664
  install_element (CONFIG_NODE, &no_debug_ospf_nsm_sub_cmd);
 
1665
  install_element (CONFIG_NODE, &no_debug_ospf_nsm_cmd);
 
1666
  install_element (CONFIG_NODE, &no_debug_ospf_lsa_sub_cmd);
 
1667
  install_element (CONFIG_NODE, &no_debug_ospf_lsa_cmd);
 
1668
  install_element (CONFIG_NODE, &no_debug_ospf_zebra_sub_cmd);
 
1669
  install_element (CONFIG_NODE, &no_debug_ospf_zebra_cmd);
 
1670
  install_element (CONFIG_NODE, &no_debug_ospf_event_cmd);
 
1671
#ifdef HAVE_NSSA
 
1672
  install_element (CONFIG_NODE, &no_debug_ospf_nssa_cmd);
 
1673
#endif /* HAVE_NSSA */
 
1674
}