]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_dump.c
Merge pull request #6746 from opensourcerouting/topotests-wtf
[mirror_frr.git] / ospfd / ospf_dump.c
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 along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <zebra.h>
23
24 #include "monotime.h"
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 #include "sockopt.h"
32
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
45 /* Configuration debug option variables. */
46 unsigned long conf_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
47 unsigned long conf_debug_ospf_event = 0;
48 unsigned long conf_debug_ospf_ism = 0;
49 unsigned long conf_debug_ospf_nsm = 0;
50 unsigned long conf_debug_ospf_lsa = 0;
51 unsigned long conf_debug_ospf_zebra = 0;
52 unsigned long conf_debug_ospf_nssa = 0;
53 unsigned long conf_debug_ospf_te = 0;
54 unsigned long conf_debug_ospf_ext = 0;
55 unsigned long conf_debug_ospf_sr = 0;
56 unsigned long conf_debug_ospf_defaultinfo = 0;
57
58 /* Enable debug option variables -- valid only session. */
59 unsigned long term_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
60 unsigned long term_debug_ospf_event;
61 unsigned long term_debug_ospf_ism = 0;
62 unsigned long term_debug_ospf_nsm = 0;
63 unsigned long term_debug_ospf_lsa = 0;
64 unsigned long term_debug_ospf_zebra = 0;
65 unsigned long term_debug_ospf_nssa = 0;
66 unsigned long term_debug_ospf_te = 0;
67 unsigned long term_debug_ospf_ext = 0;
68 unsigned long term_debug_ospf_sr = 0;
69 unsigned long term_debug_ospf_defaultinfo;
70
71 const char *ospf_redist_string(unsigned int route_type)
72 {
73 return (route_type == ZEBRA_ROUTE_MAX) ? "Default"
74 : zebra_route_string(route_type);
75 }
76
77 #define OSPF_AREA_STRING_MAXLEN 16
78 const char *ospf_area_name_string(struct ospf_area *area)
79 {
80 static char buf[OSPF_AREA_STRING_MAXLEN] = "";
81 uint32_t area_id;
82
83 if (!area)
84 return "-";
85
86 area_id = ntohl(area->area_id.s_addr);
87 snprintf(buf, sizeof(buf), "%d.%d.%d.%d", (area_id >> 24) & 0xff,
88 (area_id >> 16) & 0xff, (area_id >> 8) & 0xff, area_id & 0xff);
89 return buf;
90 }
91
92 #define OSPF_AREA_DESC_STRING_MAXLEN 23
93 const char *ospf_area_desc_string(struct ospf_area *area)
94 {
95 static char buf[OSPF_AREA_DESC_STRING_MAXLEN] = "";
96 uint8_t type;
97
98 if (!area)
99 return "(incomplete)";
100
101 type = area->external_routing;
102 switch (type) {
103 case OSPF_AREA_NSSA:
104 snprintf(buf, sizeof(buf), "%s [NSSA]",
105 ospf_area_name_string(area));
106 break;
107 case OSPF_AREA_STUB:
108 snprintf(buf, sizeof(buf), "%s [Stub]",
109 ospf_area_name_string(area));
110 break;
111 default:
112 return ospf_area_name_string(area);
113 }
114
115 return buf;
116 }
117
118 #define OSPF_IF_STRING_MAXLEN 40
119 const char *ospf_if_name_string(struct ospf_interface *oi)
120 {
121 static char buf[OSPF_IF_STRING_MAXLEN] = "";
122 uint32_t ifaddr;
123
124 if (!oi || !oi->address)
125 return "inactive";
126
127 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
128 return oi->ifp->name;
129
130 ifaddr = ntohl(oi->address->u.prefix4.s_addr);
131 snprintf(buf, sizeof(buf), "%s:%d.%d.%d.%d", oi->ifp->name,
132 (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
133 (ifaddr >> 8) & 0xff, ifaddr & 0xff);
134 return buf;
135 }
136
137
138 void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size)
139 {
140 int state;
141 struct ospf_interface *oi = nbr->oi;
142
143 if (IPV4_ADDR_SAME(&DR(oi), &nbr->address.u.prefix4))
144 state = ISM_DR;
145 else if (IPV4_ADDR_SAME(&BDR(oi), &nbr->address.u.prefix4))
146 state = ISM_Backup;
147 else
148 state = ISM_DROther;
149
150 snprintf(buf, size, "%s/%s",
151 lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
152 lookup_msg(ospf_ism_state_msg, state, NULL));
153 }
154
155 const char *ospf_timeval_dump(struct timeval *t, char *buf, size_t size)
156 {
157 /* Making formatted timer strings. */
158 #define MINUTE_IN_SECONDS 60
159 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
160 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
161 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
162 unsigned long w, d, h, m, ms, us;
163
164 if (!t)
165 return "inactive";
166
167 w = d = h = m = ms = 0;
168 memset(buf, 0, size);
169
170 us = t->tv_usec;
171 if (us >= 1000) {
172 ms = us / 1000;
173 us %= 1000;
174 (void)us; /* unused */
175 }
176
177 if (ms >= 1000) {
178 t->tv_sec += ms / 1000;
179 ms %= 1000;
180 }
181
182 if (t->tv_sec > WEEK_IN_SECONDS) {
183 w = t->tv_sec / WEEK_IN_SECONDS;
184 t->tv_sec -= w * WEEK_IN_SECONDS;
185 }
186
187 if (t->tv_sec > DAY_IN_SECONDS) {
188 d = t->tv_sec / DAY_IN_SECONDS;
189 t->tv_sec -= d * DAY_IN_SECONDS;
190 }
191
192 if (t->tv_sec >= HOUR_IN_SECONDS) {
193 h = t->tv_sec / HOUR_IN_SECONDS;
194 t->tv_sec -= h * HOUR_IN_SECONDS;
195 }
196
197 if (t->tv_sec >= MINUTE_IN_SECONDS) {
198 m = t->tv_sec / MINUTE_IN_SECONDS;
199 t->tv_sec -= m * MINUTE_IN_SECONDS;
200 }
201
202 if (w > 99)
203 snprintf(buf, size, "%luw%1lud", w, d);
204 else if (w)
205 snprintf(buf, size, "%luw%1lud%02luh", w, d, h);
206 else if (d)
207 snprintf(buf, size, "%1lud%02luh%02lum", d, h, m);
208 else if (h)
209 snprintf(buf, size, "%luh%02lum%02lds", h, m, (long)t->tv_sec);
210 else if (m)
211 snprintf(buf, size, "%lum%02lds", m, (long)t->tv_sec);
212 else if (ms)
213 snprintf(buf, size, "%ld.%03lus", (long)t->tv_sec, ms);
214 else
215 snprintf(buf, size, "%ld usecs", (long)t->tv_usec);
216
217 return buf;
218 }
219
220 const char *ospf_timer_dump(struct thread *t, char *buf, size_t size)
221 {
222 struct timeval result;
223 if (!t)
224 return "inactive";
225
226 monotime_until(&t->u.sands, &result);
227 return ospf_timeval_dump(&result, buf, size);
228 }
229
230 static void ospf_packet_hello_dump(struct stream *s, uint16_t length)
231 {
232 struct ospf_hello *hello;
233 int i;
234
235 hello = (struct ospf_hello *)stream_pnt(s);
236
237 zlog_debug("Hello");
238 zlog_debug(" NetworkMask %s", inet_ntoa(hello->network_mask));
239 zlog_debug(" HelloInterval %d", ntohs(hello->hello_interval));
240 zlog_debug(" Options %d (%s)", hello->options,
241 ospf_options_dump(hello->options));
242 zlog_debug(" RtrPriority %d", hello->priority);
243 zlog_debug(" RtrDeadInterval %ld",
244 (unsigned long)ntohl(hello->dead_interval));
245 zlog_debug(" DRouter %s", inet_ntoa(hello->d_router));
246 zlog_debug(" BDRouter %s", inet_ntoa(hello->bd_router));
247
248 length -= OSPF_HEADER_SIZE + OSPF_HELLO_MIN_SIZE;
249 zlog_debug(" # Neighbors %d", length / 4);
250 for (i = 0; length > 0; i++, length -= sizeof(struct in_addr))
251 zlog_debug(" Neighbor %s", inet_ntoa(hello->neighbors[i]));
252 }
253
254 static char *ospf_dd_flags_dump(uint8_t flags, char *buf, size_t size)
255 {
256 snprintf(buf, size, "%s|%s|%s", (flags & OSPF_DD_FLAG_I) ? "I" : "-",
257 (flags & OSPF_DD_FLAG_M) ? "M" : "-",
258 (flags & OSPF_DD_FLAG_MS) ? "MS" : "-");
259
260 return buf;
261 }
262
263 static char *ospf_router_lsa_flags_dump(uint8_t flags, char *buf, size_t size)
264 {
265 snprintf(buf, size, "%s|%s|%s",
266 (flags & ROUTER_LSA_VIRTUAL) ? "V" : "-",
267 (flags & ROUTER_LSA_EXTERNAL) ? "E" : "-",
268 (flags & ROUTER_LSA_BORDER) ? "B" : "-");
269
270 return buf;
271 }
272
273 static void ospf_router_lsa_dump(struct stream *s, uint16_t length)
274 {
275 char buf[BUFSIZ];
276 struct router_lsa *rl;
277 int i, len;
278
279 rl = (struct router_lsa *)stream_pnt(s);
280
281 zlog_debug(" Router-LSA");
282 zlog_debug(" flags %s",
283 ospf_router_lsa_flags_dump(rl->flags, buf, BUFSIZ));
284 zlog_debug(" # links %d", ntohs(rl->links));
285
286 len = ntohs(rl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
287 for (i = 0; len > 0; i++) {
288 zlog_debug(" Link ID %s", inet_ntoa(rl->link[i].link_id));
289 zlog_debug(" Link Data %s",
290 inet_ntoa(rl->link[i].link_data));
291 zlog_debug(" Type %d", (uint8_t)rl->link[i].type);
292 zlog_debug(" TOS %d", (uint8_t)rl->link[i].tos);
293 zlog_debug(" metric %d", ntohs(rl->link[i].metric));
294
295 len -= 12;
296 }
297 }
298
299 static void ospf_network_lsa_dump(struct stream *s, uint16_t length)
300 {
301 struct network_lsa *nl;
302 int i, cnt;
303
304 nl = (struct network_lsa *)stream_pnt(s);
305 cnt = (ntohs(nl->header.length) - (OSPF_LSA_HEADER_SIZE + 4)) / 4;
306
307 zlog_debug(" Network-LSA");
308 /*
309 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
310 zlog_debug ("Network-LSA size %d",
311 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
312 */
313 zlog_debug(" Network Mask %s", inet_ntoa(nl->mask));
314 zlog_debug(" # Attached Routers %d", cnt);
315 for (i = 0; i < cnt; i++)
316 zlog_debug(" Attached Router %s",
317 inet_ntoa(nl->routers[i]));
318 }
319
320 static void ospf_summary_lsa_dump(struct stream *s, uint16_t length)
321 {
322 struct summary_lsa *sl;
323 int size;
324 int i;
325
326 sl = (struct summary_lsa *)stream_pnt(s);
327
328 zlog_debug(" Summary-LSA");
329 zlog_debug(" Network Mask %s", inet_ntoa(sl->mask));
330
331 size = ntohs(sl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
332 for (i = 0; size > 0; size -= 4, i++)
333 zlog_debug(" TOS=%d metric %d", sl->tos,
334 GET_METRIC(sl->metric));
335 }
336
337 static void ospf_as_external_lsa_dump(struct stream *s, uint16_t length)
338 {
339 struct as_external_lsa *al;
340 int size;
341 int i;
342
343 al = (struct as_external_lsa *)stream_pnt(s);
344 zlog_debug(" %s", ospf_lsa_type_msg[al->header.type].str);
345 zlog_debug(" Network Mask %s", inet_ntoa(al->mask));
346
347 size = ntohs(al->header.length) - OSPF_LSA_HEADER_SIZE - 4;
348 for (i = 0; size > 0; size -= 12, i++) {
349 zlog_debug(" bit %s TOS=%d metric %d",
350 IS_EXTERNAL_METRIC(al->e[i].tos) ? "E" : "-",
351 al->e[i].tos & 0x7f, GET_METRIC(al->e[i].metric));
352 zlog_debug(" Forwarding address %s",
353 inet_ntoa(al->e[i].fwd_addr));
354 zlog_debug(" External Route Tag %" ROUTE_TAG_PRI,
355 al->e[i].route_tag);
356 }
357 }
358
359 static void ospf_lsa_header_list_dump(struct stream *s, uint16_t length)
360 {
361 struct lsa_header *lsa;
362
363 zlog_debug(" # LSA Headers %d", length / OSPF_LSA_HEADER_SIZE);
364
365 /* LSA Headers. */
366 while (length > 0) {
367 lsa = (struct lsa_header *)stream_pnt(s);
368 ospf_lsa_header_dump(lsa);
369
370 stream_forward_getp(s, OSPF_LSA_HEADER_SIZE);
371 length -= OSPF_LSA_HEADER_SIZE;
372 }
373 }
374
375 static void ospf_packet_db_desc_dump(struct stream *s, uint16_t length)
376 {
377 struct ospf_db_desc *dd;
378 char dd_flags[8];
379
380 uint32_t gp;
381
382 gp = stream_get_getp(s);
383 dd = (struct ospf_db_desc *)stream_pnt(s);
384
385 zlog_debug("Database Description");
386 zlog_debug(" Interface MTU %d", ntohs(dd->mtu));
387 zlog_debug(" Options %d (%s)", dd->options,
388 ospf_options_dump(dd->options));
389 zlog_debug(" Flags %d (%s)", dd->flags,
390 ospf_dd_flags_dump(dd->flags, dd_flags, sizeof(dd_flags)));
391 zlog_debug(" Sequence Number 0x%08lx",
392 (unsigned long)ntohl(dd->dd_seqnum));
393
394 length -= OSPF_HEADER_SIZE + OSPF_DB_DESC_MIN_SIZE;
395
396 stream_forward_getp(s, OSPF_DB_DESC_MIN_SIZE);
397
398 ospf_lsa_header_list_dump(s, length);
399
400 stream_set_getp(s, gp);
401 }
402
403 static void ospf_packet_ls_req_dump(struct stream *s, uint16_t length)
404 {
405 uint32_t sp;
406 uint32_t ls_type;
407 struct in_addr ls_id;
408 struct in_addr adv_router;
409
410 sp = stream_get_getp(s);
411
412 length -= OSPF_HEADER_SIZE;
413
414 zlog_debug("Link State Request");
415 zlog_debug(" # Requests %d", length / 12);
416
417 for (; length > 0; length -= 12) {
418 ls_type = stream_getl(s);
419 ls_id.s_addr = stream_get_ipv4(s);
420 adv_router.s_addr = stream_get_ipv4(s);
421
422 zlog_debug(" LS type %d", ls_type);
423 zlog_debug(" Link State ID %s", inet_ntoa(ls_id));
424 zlog_debug(" Advertising Router %s", inet_ntoa(adv_router));
425 }
426
427 stream_set_getp(s, sp);
428 }
429
430 static void ospf_packet_ls_upd_dump(struct stream *s, uint16_t length)
431 {
432 uint32_t sp;
433 struct lsa_header *lsa;
434 int lsa_len;
435 uint32_t count;
436
437 length -= OSPF_HEADER_SIZE;
438
439 sp = stream_get_getp(s);
440
441 count = stream_getl(s);
442 length -= 4;
443
444 zlog_debug("Link State Update");
445 zlog_debug(" # LSAs %d", count);
446
447 while (length > 0 && count > 0) {
448 if (length < OSPF_HEADER_SIZE || length % 4 != 0) {
449 zlog_debug(" Remaining %d bytes; Incorrect length.",
450 length);
451 break;
452 }
453
454 lsa = (struct lsa_header *)stream_pnt(s);
455 lsa_len = ntohs(lsa->length);
456 ospf_lsa_header_dump(lsa);
457
458 switch (lsa->type) {
459 case OSPF_ROUTER_LSA:
460 ospf_router_lsa_dump(s, length);
461 break;
462 case OSPF_NETWORK_LSA:
463 ospf_network_lsa_dump(s, length);
464 break;
465 case OSPF_SUMMARY_LSA:
466 case OSPF_ASBR_SUMMARY_LSA:
467 ospf_summary_lsa_dump(s, length);
468 break;
469 case OSPF_AS_EXTERNAL_LSA:
470 ospf_as_external_lsa_dump(s, length);
471 break;
472 case OSPF_AS_NSSA_LSA:
473 ospf_as_external_lsa_dump(s, length);
474 break;
475 case OSPF_OPAQUE_LINK_LSA:
476 case OSPF_OPAQUE_AREA_LSA:
477 case OSPF_OPAQUE_AS_LSA:
478 ospf_opaque_lsa_dump(s, length);
479 break;
480 default:
481 break;
482 }
483
484 stream_forward_getp(s, lsa_len);
485 length -= lsa_len;
486 count--;
487 }
488
489 stream_set_getp(s, sp);
490 }
491
492 static void ospf_packet_ls_ack_dump(struct stream *s, uint16_t length)
493 {
494 uint32_t sp;
495
496 length -= OSPF_HEADER_SIZE;
497 sp = stream_get_getp(s);
498
499 zlog_debug("Link State Acknowledgment");
500 ospf_lsa_header_list_dump(s, length);
501
502 stream_set_getp(s, sp);
503 }
504
505 static void ospf_header_dump(struct ospf_header *ospfh)
506 {
507 char buf[9];
508 uint16_t auth_type = ntohs(ospfh->auth_type);
509
510 zlog_debug("Header");
511 zlog_debug(" Version %d", ospfh->version);
512 zlog_debug(" Type %d (%s)", ospfh->type,
513 lookup_msg(ospf_packet_type_str, ospfh->type, NULL));
514 zlog_debug(" Packet Len %d", ntohs(ospfh->length));
515 zlog_debug(" Router ID %s", inet_ntoa(ospfh->router_id));
516 zlog_debug(" Area ID %s", inet_ntoa(ospfh->area_id));
517 zlog_debug(" Checksum 0x%x", ntohs(ospfh->checksum));
518 zlog_debug(" AuType %s",
519 lookup_msg(ospf_auth_type_str, auth_type, NULL));
520
521 switch (auth_type) {
522 case OSPF_AUTH_NULL:
523 break;
524 case OSPF_AUTH_SIMPLE:
525 strlcpy(buf, (char *)ospfh->u.auth_data, sizeof(buf));
526 zlog_debug(" Simple Password %s", buf);
527 break;
528 case OSPF_AUTH_CRYPTOGRAPHIC:
529 zlog_debug(" Cryptographic Authentication");
530 zlog_debug(" Key ID %d", ospfh->u.crypt.key_id);
531 zlog_debug(" Auth Data Len %d", ospfh->u.crypt.auth_data_len);
532 zlog_debug(" Sequence number %ld",
533 (unsigned long)ntohl(ospfh->u.crypt.crypt_seqnum));
534 break;
535 default:
536 zlog_debug("* This is not supported authentication type");
537 break;
538 }
539 }
540
541 void ospf_packet_dump(struct stream *s)
542 {
543 struct ospf_header *ospfh;
544 unsigned long gp;
545
546 /* Preserve pointer. */
547 gp = stream_get_getp(s);
548
549 /* OSPF Header dump. */
550 ospfh = (struct ospf_header *)stream_pnt(s);
551
552 /* Until detail flag is set, return. */
553 if (!(term_debug_ospf_packet[ospfh->type - 1] & OSPF_DEBUG_DETAIL))
554 return;
555
556 /* Show OSPF header detail. */
557 ospf_header_dump(ospfh);
558 stream_forward_getp(s, OSPF_HEADER_SIZE);
559
560 switch (ospfh->type) {
561 case OSPF_MSG_HELLO:
562 ospf_packet_hello_dump(s, ntohs(ospfh->length));
563 break;
564 case OSPF_MSG_DB_DESC:
565 ospf_packet_db_desc_dump(s, ntohs(ospfh->length));
566 break;
567 case OSPF_MSG_LS_REQ:
568 ospf_packet_ls_req_dump(s, ntohs(ospfh->length));
569 break;
570 case OSPF_MSG_LS_UPD:
571 ospf_packet_ls_upd_dump(s, ntohs(ospfh->length));
572 break;
573 case OSPF_MSG_LS_ACK:
574 ospf_packet_ls_ack_dump(s, ntohs(ospfh->length));
575 break;
576 default:
577 break;
578 }
579
580 stream_set_getp(s, gp);
581 }
582
583 DEFUN (debug_ospf_packet,
584 debug_ospf_packet_cmd,
585 "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
586 DEBUG_STR
587 OSPF_STR
588 "Instance ID\n"
589 "OSPF packets\n"
590 "OSPF Hello\n"
591 "OSPF Database Description\n"
592 "OSPF Link State Request\n"
593 "OSPF Link State Update\n"
594 "OSPF Link State Acknowledgment\n"
595 "OSPF all packets\n"
596 "Packet sent\n"
597 "Detail Information\n"
598 "Packet received\n"
599 "Detail Information\n"
600 "Detail Information\n")
601 {
602 int inst = (argv[2]->type == RANGE_TKN) ? 1 : 0;
603 int detail = strmatch(argv[argc - 1]->text, "detail");
604 int send = strmatch(argv[argc - (1 + detail)]->text, "send");
605 int recv = strmatch(argv[argc - (1 + detail)]->text, "recv");
606 char *packet = argv[3 + inst]->text;
607
608 if (inst) // user passed instance ID
609 {
610 if (!ospf_lookup_instance(strtoul(argv[2]->arg, NULL, 10)))
611 return CMD_NOT_MY_INSTANCE;
612 }
613
614 int type = 0;
615 int flag = 0;
616 int i;
617
618 /* Check packet type. */
619 if (strmatch(packet, "hello"))
620 type = OSPF_DEBUG_HELLO;
621 else if (strmatch(packet, "dd"))
622 type = OSPF_DEBUG_DB_DESC;
623 else if (strmatch(packet, "ls-request"))
624 type = OSPF_DEBUG_LS_REQ;
625 else if (strmatch(packet, "ls-update"))
626 type = OSPF_DEBUG_LS_UPD;
627 else if (strmatch(packet, "ls-ack"))
628 type = OSPF_DEBUG_LS_ACK;
629 else if (strmatch(packet, "all"))
630 type = OSPF_DEBUG_ALL;
631
632 /* Cases:
633 * (none) = send + recv
634 * detail = send + recv + detail
635 * recv = recv
636 * send = send
637 * recv detail = recv + detail
638 * send detail = send + detail
639 */
640 if (!send && !recv)
641 send = recv = 1;
642
643 flag |= (send) ? OSPF_DEBUG_SEND : 0;
644 flag |= (recv) ? OSPF_DEBUG_RECV : 0;
645 flag |= (detail) ? OSPF_DEBUG_DETAIL : 0;
646
647 for (i = 0; i < 5; i++)
648 if (type & (0x01 << i)) {
649 if (vty->node == CONFIG_NODE)
650 DEBUG_PACKET_ON(i, flag);
651 else
652 TERM_DEBUG_PACKET_ON(i, flag);
653 }
654
655 return CMD_SUCCESS;
656 }
657
658 DEFUN (no_debug_ospf_packet,
659 no_debug_ospf_packet_cmd,
660 "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]",
661 NO_STR
662 DEBUG_STR
663 OSPF_STR
664 "Instance ID\n"
665 "OSPF packets\n"
666 "OSPF Hello\n"
667 "OSPF Database Description\n"
668 "OSPF Link State Request\n"
669 "OSPF Link State Update\n"
670 "OSPF Link State Acknowledgment\n"
671 "OSPF all packets\n"
672 "Packet sent\n"
673 "Detail Information\n"
674 "Packet received\n"
675 "Detail Information\n"
676 "Detail Information\n")
677 {
678 int inst = (argv[3]->type == RANGE_TKN) ? 1 : 0;
679 int detail = strmatch(argv[argc - 1]->text, "detail");
680 int send = strmatch(argv[argc - (1 + detail)]->text, "send");
681 int recv = strmatch(argv[argc - (1 + detail)]->text, "recv");
682 char *packet = argv[4 + inst]->text;
683
684 if (inst) // user passed instance ID
685 {
686 if (!ospf_lookup_instance(strtoul(argv[3]->arg, NULL, 10)))
687 return CMD_NOT_MY_INSTANCE;
688 }
689
690 int type = 0;
691 int flag = 0;
692 int i;
693
694 /* Check packet type. */
695 if (strmatch(packet, "hello"))
696 type = OSPF_DEBUG_HELLO;
697 else if (strmatch(packet, "dd"))
698 type = OSPF_DEBUG_DB_DESC;
699 else if (strmatch(packet, "ls-request"))
700 type = OSPF_DEBUG_LS_REQ;
701 else if (strmatch(packet, "ls-update"))
702 type = OSPF_DEBUG_LS_UPD;
703 else if (strmatch(packet, "ls-ack"))
704 type = OSPF_DEBUG_LS_ACK;
705 else if (strmatch(packet, "all"))
706 type = OSPF_DEBUG_ALL;
707
708 /* Cases:
709 * (none) = send + recv
710 * detail = send + recv + detail
711 * recv = recv
712 * send = send
713 * recv detail = recv + detail
714 * send detail = send + detail
715 */
716 if (!send && !recv)
717 send = recv = 1;
718
719 flag |= (send) ? OSPF_DEBUG_SEND : 0;
720 flag |= (recv) ? OSPF_DEBUG_RECV : 0;
721 flag |= (detail) ? OSPF_DEBUG_DETAIL : 0;
722
723 for (i = 0; i < 5; i++)
724 if (type & (0x01 << i)) {
725 if (vty->node == CONFIG_NODE)
726 DEBUG_PACKET_OFF(i, flag);
727 else
728 TERM_DEBUG_PACKET_OFF(i, flag);
729 }
730
731 #ifdef DEBUG
732 /*
733 for (i = 0; i < 5; i++)
734 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
735 */
736 #endif /* DEBUG */
737
738 return CMD_SUCCESS;
739 }
740
741 DEFUN (debug_ospf_ism,
742 debug_ospf_ism_cmd,
743 "debug ospf [(1-65535)] ism [<status|events|timers>]",
744 DEBUG_STR
745 OSPF_STR
746 "Instance ID\n"
747 "OSPF Interface State Machine\n"
748 "ISM Status Information\n"
749 "ISM Event Information\n"
750 "ISM TImer Information\n")
751 {
752 int inst = (argv[2]->type == RANGE_TKN);
753 char *dbgparam = (argc == 4 + inst) ? argv[argc - 1]->text : NULL;
754
755 if (inst) // user passed instance ID
756 {
757 if (!ospf_lookup_instance(strtoul(argv[2]->arg, NULL, 10)))
758 return CMD_NOT_MY_INSTANCE;
759 }
760
761 if (vty->node == CONFIG_NODE) {
762 if (!dbgparam)
763 DEBUG_ON(ism, ISM);
764 else {
765 if (strmatch(dbgparam, "status"))
766 DEBUG_ON(ism, ISM_STATUS);
767 else if (strmatch(dbgparam, "events"))
768 DEBUG_ON(ism, ISM_EVENTS);
769 else if (strmatch(dbgparam, "timers"))
770 DEBUG_ON(ism, ISM_TIMERS);
771 }
772
773 return CMD_SUCCESS;
774 }
775
776 /* ENABLE_NODE. */
777 if (!dbgparam)
778 TERM_DEBUG_ON(ism, ISM);
779 else {
780 if (strmatch(dbgparam, "status"))
781 TERM_DEBUG_ON(ism, ISM_STATUS);
782 else if (strmatch(dbgparam, "events"))
783 TERM_DEBUG_ON(ism, ISM_EVENTS);
784 else if (strmatch(dbgparam, "timers"))
785 TERM_DEBUG_ON(ism, ISM_TIMERS);
786 }
787
788 return CMD_SUCCESS;
789 }
790
791 DEFUN (no_debug_ospf_ism,
792 no_debug_ospf_ism_cmd,
793 "no debug ospf [(1-65535)] ism [<status|events|timers>]",
794 NO_STR
795 DEBUG_STR
796 OSPF_STR
797 "Instance ID\n"
798 "OSPF Interface State Machine\n"
799 "ISM Status Information\n"
800 "ISM Event Information\n"
801 "ISM TImer Information\n")
802 {
803 int inst = (argv[3]->type == RANGE_TKN);
804 char *dbgparam = (argc == 5 + inst) ? argv[argc - 1]->text : NULL;
805
806 if (inst) // user passed instance ID
807 {
808 if (!ospf_lookup_instance(strtoul(argv[3]->arg, NULL, 10)))
809 return CMD_NOT_MY_INSTANCE;
810 }
811
812 if (vty->node == CONFIG_NODE) {
813 if (!dbgparam)
814 DEBUG_OFF(ism, ISM);
815 else {
816 if (strmatch(dbgparam, "status"))
817 DEBUG_OFF(ism, ISM_STATUS);
818 else if (strmatch(dbgparam, "events"))
819 DEBUG_OFF(ism, ISM_EVENTS);
820 else if (strmatch(dbgparam, "timers"))
821 DEBUG_OFF(ism, ISM_TIMERS);
822 }
823
824 return CMD_SUCCESS;
825 }
826
827 /* ENABLE_NODE. */
828 if (!dbgparam)
829 TERM_DEBUG_OFF(ism, ISM);
830 else {
831 if (strmatch(dbgparam, "status"))
832 TERM_DEBUG_OFF(ism, ISM_STATUS);
833 else if (strmatch(dbgparam, "events"))
834 TERM_DEBUG_OFF(ism, ISM_EVENTS);
835 else if (strmatch(dbgparam, "timers"))
836 TERM_DEBUG_OFF(ism, ISM_TIMERS);
837 }
838
839 return CMD_SUCCESS;
840 }
841
842 static int debug_ospf_nsm_common(struct vty *vty, int arg_base, int argc,
843 struct cmd_token **argv)
844 {
845 if (vty->node == CONFIG_NODE) {
846 if (argc == arg_base + 0)
847 DEBUG_ON(nsm, NSM);
848 else if (argc == arg_base + 1) {
849 if (strmatch(argv[arg_base]->text, "status"))
850 DEBUG_ON(nsm, NSM_STATUS);
851 else if (strmatch(argv[arg_base]->text, "events"))
852 DEBUG_ON(nsm, NSM_EVENTS);
853 else if (strmatch(argv[arg_base]->text, "timers"))
854 DEBUG_ON(nsm, NSM_TIMERS);
855 }
856
857 return CMD_SUCCESS;
858 }
859
860 /* ENABLE_NODE. */
861 if (argc == arg_base + 0)
862 TERM_DEBUG_ON(nsm, NSM);
863 else if (argc == arg_base + 1) {
864 if (strmatch(argv[arg_base]->text, "status"))
865 TERM_DEBUG_ON(nsm, NSM_STATUS);
866 else if (strmatch(argv[arg_base]->text, "events"))
867 TERM_DEBUG_ON(nsm, NSM_EVENTS);
868 else if (strmatch(argv[arg_base]->text, "timers"))
869 TERM_DEBUG_ON(nsm, NSM_TIMERS);
870 }
871
872 return CMD_SUCCESS;
873 }
874
875 DEFUN (debug_ospf_nsm,
876 debug_ospf_nsm_cmd,
877 "debug ospf nsm [<status|events|timers>]",
878 DEBUG_STR
879 OSPF_STR
880 "OSPF Neighbor State Machine\n"
881 "NSM Status Information\n"
882 "NSM Event Information\n"
883 "NSM Timer Information\n")
884 {
885 return debug_ospf_nsm_common(vty, 3, argc, argv);
886 }
887
888 DEFUN (debug_ospf_instance_nsm,
889 debug_ospf_instance_nsm_cmd,
890 "debug ospf (1-65535) nsm [<status|events|timers>]",
891 DEBUG_STR
892 OSPF_STR
893 "Instance ID\n"
894 "OSPF Neighbor State Machine\n"
895 "NSM Status Information\n"
896 "NSM Event Information\n"
897 "NSM Timer Information\n")
898 {
899 int idx_number = 2;
900 unsigned short instance = 0;
901
902 instance = strtoul(argv[idx_number]->arg, NULL, 10);
903 if (!ospf_lookup_instance(instance))
904 return CMD_SUCCESS;
905
906 return debug_ospf_nsm_common(vty, 4, argc, argv);
907 }
908
909
910 static int no_debug_ospf_nsm_common(struct vty *vty, int arg_base, int argc,
911 struct cmd_token **argv)
912 {
913 /* XXX qlyoung */
914 if (vty->node == CONFIG_NODE) {
915 if (argc == arg_base + 0)
916 DEBUG_OFF(nsm, NSM);
917 else if (argc == arg_base + 1) {
918 if (strmatch(argv[arg_base]->text, "status"))
919 DEBUG_OFF(nsm, NSM_STATUS);
920 else if (strmatch(argv[arg_base]->text, "events"))
921 DEBUG_OFF(nsm, NSM_EVENTS);
922 else if (strmatch(argv[arg_base]->text, "timers"))
923 DEBUG_OFF(nsm, NSM_TIMERS);
924 }
925
926 return CMD_SUCCESS;
927 }
928
929 /* ENABLE_NODE. */
930 if (argc == arg_base + 0)
931 TERM_DEBUG_OFF(nsm, NSM);
932 else if (argc == arg_base + 1) {
933 if (strmatch(argv[arg_base]->text, "status"))
934 TERM_DEBUG_OFF(nsm, NSM_STATUS);
935 else if (strmatch(argv[arg_base]->text, "events"))
936 TERM_DEBUG_OFF(nsm, NSM_EVENTS);
937 else if (strmatch(argv[arg_base]->text, "timers"))
938 TERM_DEBUG_OFF(nsm, NSM_TIMERS);
939 }
940
941 return CMD_SUCCESS;
942 }
943
944 DEFUN (no_debug_ospf_nsm,
945 no_debug_ospf_nsm_cmd,
946 "no debug ospf nsm [<status|events|timers>]",
947 NO_STR
948 DEBUG_STR
949 OSPF_STR
950 "OSPF Neighbor State Machine\n"
951 "NSM Status Information\n"
952 "NSM Event Information\n"
953 "NSM Timer Information\n")
954 {
955 return no_debug_ospf_nsm_common(vty, 4, argc, argv);
956 }
957
958
959 DEFUN (no_debug_ospf_instance_nsm,
960 no_debug_ospf_instance_nsm_cmd,
961 "no debug ospf (1-65535) nsm [<status|events|timers>]",
962 NO_STR
963 DEBUG_STR
964 OSPF_STR
965 "Instance ID\n"
966 "OSPF Neighbor State Machine\n"
967 "NSM Status Information\n"
968 "NSM Event Information\n"
969 "NSM Timer Information\n")
970 {
971 int idx_number = 3;
972 unsigned short instance = 0;
973
974 instance = strtoul(argv[idx_number]->arg, NULL, 10);
975 if (!ospf_lookup_instance(instance))
976 return CMD_NOT_MY_INSTANCE;
977
978 return no_debug_ospf_nsm_common(vty, 5, argc, argv);
979 }
980
981
982 static int debug_ospf_lsa_common(struct vty *vty, int arg_base, int argc,
983 struct cmd_token **argv)
984 {
985 if (vty->node == CONFIG_NODE) {
986 if (argc == arg_base + 0)
987 DEBUG_ON(lsa, LSA);
988 else if (argc == arg_base + 1) {
989 if (strmatch(argv[arg_base]->text, "generate"))
990 DEBUG_ON(lsa, LSA_GENERATE);
991 else if (strmatch(argv[arg_base]->text, "flooding"))
992 DEBUG_ON(lsa, LSA_FLOODING);
993 else if (strmatch(argv[arg_base]->text, "install"))
994 DEBUG_ON(lsa, LSA_INSTALL);
995 else if (strmatch(argv[arg_base]->text, "refresh"))
996 DEBUG_ON(lsa, LSA_REFRESH);
997 }
998
999 return CMD_SUCCESS;
1000 }
1001
1002 /* ENABLE_NODE. */
1003 if (argc == arg_base + 0)
1004 TERM_DEBUG_ON(lsa, LSA);
1005 else if (argc == arg_base + 1) {
1006 if (strmatch(argv[arg_base]->text, "generate"))
1007 TERM_DEBUG_ON(lsa, LSA_GENERATE);
1008 else if (strmatch(argv[arg_base]->text, "flooding"))
1009 TERM_DEBUG_ON(lsa, LSA_FLOODING);
1010 else if (strmatch(argv[arg_base]->text, "install"))
1011 TERM_DEBUG_ON(lsa, LSA_INSTALL);
1012 else if (strmatch(argv[arg_base]->text, "refresh"))
1013 TERM_DEBUG_ON(lsa, LSA_REFRESH);
1014 }
1015
1016 return CMD_SUCCESS;
1017 }
1018
1019 DEFUN (debug_ospf_lsa,
1020 debug_ospf_lsa_cmd,
1021 "debug ospf lsa [<generate|flooding|install|refresh>]",
1022 DEBUG_STR
1023 OSPF_STR
1024 "OSPF Link State Advertisement\n"
1025 "LSA Generation\n"
1026 "LSA Flooding\n"
1027 "LSA Install/Delete\n"
1028 "LSA Refresh\n")
1029 {
1030 return debug_ospf_lsa_common(vty, 3, argc, argv);
1031 }
1032
1033 DEFUN (debug_ospf_instance_lsa,
1034 debug_ospf_instance_lsa_cmd,
1035 "debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1036 DEBUG_STR
1037 OSPF_STR
1038 "Instance ID\n"
1039 "OSPF Link State Advertisement\n"
1040 "LSA Generation\n"
1041 "LSA Flooding\n"
1042 "LSA Install/Delete\n"
1043 "LSA Refresh\n")
1044 {
1045 int idx_number = 2;
1046 unsigned short instance = 0;
1047
1048 instance = strtoul(argv[idx_number]->arg, NULL, 10);
1049 if (!ospf_lookup_instance(instance))
1050 return CMD_NOT_MY_INSTANCE;
1051
1052 return debug_ospf_lsa_common(vty, 4, argc, argv);
1053 }
1054
1055
1056 static int no_debug_ospf_lsa_common(struct vty *vty, int arg_base, int argc,
1057 struct cmd_token **argv)
1058 {
1059 if (vty->node == CONFIG_NODE) {
1060 if (argc == arg_base + 0)
1061 DEBUG_OFF(lsa, LSA);
1062 else if (argc == arg_base + 1) {
1063 if (strmatch(argv[arg_base]->text, "generate"))
1064 DEBUG_OFF(lsa, LSA_GENERATE);
1065 else if (strmatch(argv[arg_base]->text, "flooding"))
1066 DEBUG_OFF(lsa, LSA_FLOODING);
1067 else if (strmatch(argv[arg_base]->text, "install"))
1068 DEBUG_OFF(lsa, LSA_INSTALL);
1069 else if (strmatch(argv[arg_base]->text, "refresh"))
1070 DEBUG_OFF(lsa, LSA_REFRESH);
1071 }
1072
1073 return CMD_SUCCESS;
1074 }
1075
1076 /* ENABLE_NODE. */
1077 if (argc == arg_base + 0)
1078 TERM_DEBUG_OFF(lsa, LSA);
1079 else if (argc == arg_base + 1) {
1080 if (strmatch(argv[arg_base]->text, "generate"))
1081 TERM_DEBUG_OFF(lsa, LSA_GENERATE);
1082 else if (strmatch(argv[arg_base]->text, "flooding"))
1083 TERM_DEBUG_OFF(lsa, LSA_FLOODING);
1084 else if (strmatch(argv[arg_base]->text, "install"))
1085 TERM_DEBUG_OFF(lsa, LSA_INSTALL);
1086 else if (strmatch(argv[arg_base]->text, "refresh"))
1087 TERM_DEBUG_OFF(lsa, LSA_REFRESH);
1088 }
1089
1090 return CMD_SUCCESS;
1091 }
1092
1093 DEFUN (no_debug_ospf_lsa,
1094 no_debug_ospf_lsa_cmd,
1095 "no debug ospf lsa [<generate|flooding|install|refresh>]",
1096 NO_STR
1097 DEBUG_STR
1098 OSPF_STR
1099 "OSPF Link State Advertisement\n"
1100 "LSA Generation\n"
1101 "LSA Flooding\n"
1102 "LSA Install/Delete\n"
1103 "LSA Refres\n")
1104 {
1105 return no_debug_ospf_lsa_common(vty, 4, argc, argv);
1106 }
1107
1108 DEFUN (no_debug_ospf_instance_lsa,
1109 no_debug_ospf_instance_lsa_cmd,
1110 "no debug ospf (1-65535) lsa [<generate|flooding|install|refresh>]",
1111 NO_STR
1112 DEBUG_STR
1113 OSPF_STR
1114 "Instance ID\n"
1115 "OSPF Link State Advertisement\n"
1116 "LSA Generation\n"
1117 "LSA Flooding\n"
1118 "LSA Install/Delete\n"
1119 "LSA Refres\n")
1120 {
1121 int idx_number = 3;
1122 unsigned short instance = 0;
1123
1124 instance = strtoul(argv[idx_number]->arg, NULL, 10);
1125 if (!ospf_lookup_instance(instance))
1126 return CMD_NOT_MY_INSTANCE;
1127
1128 return no_debug_ospf_lsa_common(vty, 5, argc, argv);
1129 }
1130
1131
1132 static int debug_ospf_zebra_common(struct vty *vty, int arg_base, int argc,
1133 struct cmd_token **argv)
1134 {
1135 if (vty->node == CONFIG_NODE) {
1136 if (argc == arg_base + 0)
1137 DEBUG_ON(zebra, ZEBRA);
1138 else if (argc == arg_base + 1) {
1139 if (strmatch(argv[arg_base]->text, "interface"))
1140 DEBUG_ON(zebra, ZEBRA_INTERFACE);
1141 else if (strmatch(argv[arg_base]->text, "redistribute"))
1142 DEBUG_ON(zebra, ZEBRA_REDISTRIBUTE);
1143 }
1144
1145 return CMD_SUCCESS;
1146 }
1147
1148 /* ENABLE_NODE. */
1149 if (argc == arg_base + 0)
1150 TERM_DEBUG_ON(zebra, ZEBRA);
1151 else if (argc == arg_base + 1) {
1152 if (strmatch(argv[arg_base]->text, "interface"))
1153 TERM_DEBUG_ON(zebra, ZEBRA_INTERFACE);
1154 else if (strmatch(argv[arg_base]->text, "redistribute"))
1155 TERM_DEBUG_ON(zebra, ZEBRA_REDISTRIBUTE);
1156 }
1157
1158 return CMD_SUCCESS;
1159 }
1160
1161 DEFUN (debug_ospf_zebra,
1162 debug_ospf_zebra_cmd,
1163 "debug ospf zebra [<interface|redistribute>]",
1164 DEBUG_STR
1165 OSPF_STR
1166 ZEBRA_STR
1167 "Zebra interface\n"
1168 "Zebra redistribute\n")
1169 {
1170 return debug_ospf_zebra_common(vty, 3, argc, argv);
1171 }
1172
1173 DEFUN (debug_ospf_instance_zebra,
1174 debug_ospf_instance_zebra_cmd,
1175 "debug ospf (1-65535) zebra [<interface|redistribute>]",
1176 DEBUG_STR
1177 OSPF_STR
1178 "Instance ID\n"
1179 ZEBRA_STR
1180 "Zebra interface\n"
1181 "Zebra redistribute\n")
1182 {
1183 int idx_number = 2;
1184 unsigned short instance = 0;
1185
1186 instance = strtoul(argv[idx_number]->arg, NULL, 10);
1187 if (!ospf_lookup_instance(instance))
1188 return CMD_NOT_MY_INSTANCE;
1189
1190 return debug_ospf_zebra_common(vty, 4, argc, argv);
1191 }
1192
1193
1194 static int no_debug_ospf_zebra_common(struct vty *vty, int arg_base, int argc,
1195 struct cmd_token **argv)
1196 {
1197 if (vty->node == CONFIG_NODE) {
1198 if (argc == arg_base + 0)
1199 DEBUG_OFF(zebra, ZEBRA);
1200 else if (argc == arg_base + 1) {
1201 if (strmatch(argv[arg_base]->text, "interface"))
1202 DEBUG_OFF(zebra, ZEBRA_INTERFACE);
1203 else if (strmatch(argv[arg_base]->text, "redistribute"))
1204 DEBUG_OFF(zebra, ZEBRA_REDISTRIBUTE);
1205 }
1206
1207 return CMD_SUCCESS;
1208 }
1209
1210 /* ENABLE_NODE. */
1211 if (argc == arg_base + 0)
1212 TERM_DEBUG_OFF(zebra, ZEBRA);
1213 else if (argc == arg_base + 1) {
1214 if (strmatch(argv[arg_base]->text, "interface"))
1215 TERM_DEBUG_OFF(zebra, ZEBRA_INTERFACE);
1216 else if (strmatch(argv[arg_base]->text, "redistribute"))
1217 TERM_DEBUG_OFF(zebra, ZEBRA_REDISTRIBUTE);
1218 }
1219
1220 return CMD_SUCCESS;
1221 }
1222
1223 DEFUN (no_debug_ospf_zebra,
1224 no_debug_ospf_zebra_cmd,
1225 "no debug ospf zebra [<interface|redistribute>]",
1226 NO_STR
1227 DEBUG_STR
1228 OSPF_STR
1229 ZEBRA_STR
1230 "Zebra interface\n"
1231 "Zebra redistribute\n")
1232 {
1233 return no_debug_ospf_zebra_common(vty, 4, argc, argv);
1234 }
1235
1236 DEFUN (no_debug_ospf_instance_zebra,
1237 no_debug_ospf_instance_zebra_cmd,
1238 "no debug ospf (1-65535) zebra [<interface|redistribute>]",
1239 NO_STR
1240 DEBUG_STR
1241 OSPF_STR
1242 "Instance ID\n"
1243 ZEBRA_STR
1244 "Zebra interface\n"
1245 "Zebra redistribute\n")
1246 {
1247 int idx_number = 3;
1248 unsigned short instance = 0;
1249
1250 instance = strtoul(argv[idx_number]->arg, NULL, 10);
1251 if (!ospf_lookup_instance(instance))
1252 return CMD_SUCCESS;
1253
1254 return no_debug_ospf_zebra_common(vty, 5, argc, argv);
1255 }
1256
1257
1258 DEFUN (debug_ospf_event,
1259 debug_ospf_event_cmd,
1260 "debug ospf event",
1261 DEBUG_STR
1262 OSPF_STR
1263 "OSPF event information\n")
1264 {
1265 if (vty->node == CONFIG_NODE)
1266 CONF_DEBUG_ON(event, EVENT);
1267 TERM_DEBUG_ON(event, EVENT);
1268 return CMD_SUCCESS;
1269 }
1270
1271 DEFUN (no_debug_ospf_event,
1272 no_debug_ospf_event_cmd,
1273 "no debug ospf event",
1274 NO_STR
1275 DEBUG_STR
1276 OSPF_STR
1277 "OSPF event information\n")
1278 {
1279 if (vty->node == CONFIG_NODE)
1280 CONF_DEBUG_OFF(event, EVENT);
1281 TERM_DEBUG_OFF(event, EVENT);
1282 return CMD_SUCCESS;
1283 }
1284
1285 DEFUN (debug_ospf_instance_event,
1286 debug_ospf_instance_event_cmd,
1287 "debug ospf (1-65535) event",
1288 DEBUG_STR
1289 OSPF_STR
1290 "Instance ID\n"
1291 "OSPF event information\n")
1292 {
1293 int idx_number = 2;
1294 unsigned short instance = 0;
1295
1296 instance = strtoul(argv[idx_number]->arg, NULL, 10);
1297 if (!ospf_lookup_instance(instance))
1298 return CMD_SUCCESS;
1299
1300 if (vty->node == CONFIG_NODE)
1301 CONF_DEBUG_ON(event, EVENT);
1302 TERM_DEBUG_ON(event, EVENT);
1303 return CMD_SUCCESS;
1304 }
1305
1306 DEFUN (no_debug_ospf_instance_event,
1307 no_debug_ospf_instance_event_cmd,
1308 "no debug ospf (1-65535) event",
1309 NO_STR
1310 DEBUG_STR
1311 OSPF_STR
1312 "Instance ID\n"
1313 "OSPF event information\n")
1314 {
1315 int idx_number = 3;
1316 unsigned short instance = 0;
1317
1318 instance = strtoul(argv[idx_number]->arg, NULL, 10);
1319 if (!ospf_lookup_instance(instance))
1320 return CMD_SUCCESS;
1321
1322 if (vty->node == CONFIG_NODE)
1323 CONF_DEBUG_OFF(event, EVENT);
1324 TERM_DEBUG_OFF(event, EVENT);
1325 return CMD_SUCCESS;
1326 }
1327
1328 DEFUN (debug_ospf_nssa,
1329 debug_ospf_nssa_cmd,
1330 "debug ospf nssa",
1331 DEBUG_STR
1332 OSPF_STR
1333 "OSPF nssa information\n")
1334 {
1335 if (vty->node == CONFIG_NODE)
1336 CONF_DEBUG_ON(nssa, NSSA);
1337 TERM_DEBUG_ON(nssa, NSSA);
1338 return CMD_SUCCESS;
1339 }
1340
1341 DEFUN (no_debug_ospf_nssa,
1342 no_debug_ospf_nssa_cmd,
1343 "no debug ospf nssa",
1344 NO_STR
1345 DEBUG_STR
1346 OSPF_STR
1347 "OSPF nssa information\n")
1348 {
1349 if (vty->node == CONFIG_NODE)
1350 CONF_DEBUG_OFF(nssa, NSSA);
1351 TERM_DEBUG_OFF(nssa, NSSA);
1352 return CMD_SUCCESS;
1353 }
1354
1355 DEFUN (debug_ospf_instance_nssa,
1356 debug_ospf_instance_nssa_cmd,
1357 "debug ospf (1-65535) nssa",
1358 DEBUG_STR
1359 OSPF_STR
1360 "Instance ID\n"
1361 "OSPF nssa information\n")
1362 {
1363 int idx_number = 2;
1364 unsigned short instance = 0;
1365
1366 instance = strtoul(argv[idx_number]->arg, NULL, 10);
1367 if (!ospf_lookup_instance(instance))
1368 return CMD_SUCCESS;
1369
1370 if (vty->node == CONFIG_NODE)
1371 CONF_DEBUG_ON(nssa, NSSA);
1372 TERM_DEBUG_ON(nssa, NSSA);
1373 return CMD_SUCCESS;
1374 }
1375
1376 DEFUN (no_debug_ospf_instance_nssa,
1377 no_debug_ospf_instance_nssa_cmd,
1378 "no debug ospf (1-65535) nssa",
1379 NO_STR
1380 DEBUG_STR
1381 OSPF_STR
1382 "Instance ID\n"
1383 "OSPF nssa information\n")
1384 {
1385 int idx_number = 3;
1386 unsigned short instance = 0;
1387
1388 instance = strtoul(argv[idx_number]->arg, NULL, 10);
1389 if (!ospf_lookup_instance(instance))
1390 return CMD_SUCCESS;
1391
1392 if (vty->node == CONFIG_NODE)
1393 CONF_DEBUG_OFF(nssa, NSSA);
1394 TERM_DEBUG_OFF(nssa, NSSA);
1395 return CMD_SUCCESS;
1396 }
1397
1398 DEFUN (debug_ospf_te,
1399 debug_ospf_te_cmd,
1400 "debug ospf te",
1401 DEBUG_STR
1402 OSPF_STR
1403 "OSPF-TE information\n")
1404 {
1405 if (vty->node == CONFIG_NODE)
1406 CONF_DEBUG_ON(te, TE);
1407 TERM_DEBUG_ON(te, TE);
1408 return CMD_SUCCESS;
1409 }
1410
1411 DEFUN (no_debug_ospf_te,
1412 no_debug_ospf_te_cmd,
1413 "no debug ospf te",
1414 NO_STR
1415 DEBUG_STR
1416 OSPF_STR
1417 "OSPF-TE information\n")
1418 {
1419 if (vty->node == CONFIG_NODE)
1420 CONF_DEBUG_OFF(te, TE);
1421 TERM_DEBUG_OFF(te, TE);
1422 return CMD_SUCCESS;
1423 }
1424
1425 DEFUN (debug_ospf_sr,
1426 debug_ospf_sr_cmd,
1427 "debug ospf sr",
1428 DEBUG_STR
1429 OSPF_STR
1430 "OSPF-SR information\n")
1431 {
1432 if (vty->node == CONFIG_NODE)
1433 CONF_DEBUG_ON(sr, SR);
1434 TERM_DEBUG_ON(sr, SR);
1435 return CMD_SUCCESS;
1436 }
1437
1438 DEFUN (no_debug_ospf_sr,
1439 no_debug_ospf_sr_cmd,
1440 "no debug ospf sr",
1441 NO_STR
1442 DEBUG_STR
1443 OSPF_STR
1444 "OSPF-SR information\n")
1445 {
1446 if (vty->node == CONFIG_NODE)
1447 CONF_DEBUG_OFF(sr, SR);
1448 TERM_DEBUG_OFF(sr, SR);
1449 return CMD_SUCCESS;
1450 }
1451
1452 DEFUN (debug_ospf_default_info,
1453 debug_ospf_default_info_cmd,
1454 "debug ospf default-information",
1455 DEBUG_STR
1456 OSPF_STR
1457 "OSPF default information\n")
1458 {
1459 if (vty->node == CONFIG_NODE)
1460 CONF_DEBUG_ON(defaultinfo, DEFAULTINFO);
1461 TERM_DEBUG_ON(defaultinfo, DEFAULTINFO);
1462 return CMD_SUCCESS;
1463 }
1464
1465 DEFUN (no_debug_ospf_default_info,
1466 no_debug_ospf_default_info_cmd,
1467 "no debug ospf default-information",
1468 NO_STR
1469 DEBUG_STR
1470 OSPF_STR
1471 "OSPF default information\n")
1472 {
1473 if (vty->node == CONFIG_NODE)
1474 CONF_DEBUG_OFF(defaultinfo, DEFAULTINFO);
1475 TERM_DEBUG_OFF(defaultinfo, DEFAULTINFO);
1476 return CMD_SUCCESS;
1477 }
1478
1479 DEFUN (no_debug_ospf,
1480 no_debug_ospf_cmd,
1481 "no debug ospf",
1482 NO_STR
1483 DEBUG_STR
1484 OSPF_STR)
1485 {
1486 int flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
1487 int i;
1488
1489 if (vty->node == CONFIG_NODE) {
1490 CONF_DEBUG_OFF(event, EVENT);
1491 CONF_DEBUG_OFF(nssa, NSSA);
1492 DEBUG_OFF(ism, ISM_EVENTS);
1493 DEBUG_OFF(ism, ISM_STATUS);
1494 DEBUG_OFF(ism, ISM_TIMERS);
1495 DEBUG_OFF(lsa, LSA);
1496 DEBUG_OFF(lsa, LSA_FLOODING);
1497 DEBUG_OFF(lsa, LSA_GENERATE);
1498 DEBUG_OFF(lsa, LSA_INSTALL);
1499 DEBUG_OFF(lsa, LSA_REFRESH);
1500 DEBUG_OFF(nsm, NSM);
1501 DEBUG_OFF(nsm, NSM_EVENTS);
1502 DEBUG_OFF(nsm, NSM_STATUS);
1503 DEBUG_OFF(nsm, NSM_TIMERS);
1504 DEBUG_OFF(zebra, ZEBRA);
1505 DEBUG_OFF(zebra, ZEBRA_INTERFACE);
1506 DEBUG_OFF(zebra, ZEBRA_REDISTRIBUTE);
1507 DEBUG_OFF(defaultinfo, DEFAULTINFO);
1508
1509 for (i = 0; i < 5; i++)
1510 DEBUG_PACKET_OFF(i, flag);
1511 }
1512
1513 for (i = 0; i < 5; i++)
1514 TERM_DEBUG_PACKET_OFF(i, flag);
1515
1516 TERM_DEBUG_OFF(event, EVENT);
1517 TERM_DEBUG_OFF(ism, ISM);
1518 TERM_DEBUG_OFF(ism, ISM_EVENTS);
1519 TERM_DEBUG_OFF(ism, ISM_STATUS);
1520 TERM_DEBUG_OFF(ism, ISM_TIMERS);
1521 TERM_DEBUG_OFF(lsa, LSA);
1522 TERM_DEBUG_OFF(lsa, LSA_FLOODING);
1523 TERM_DEBUG_OFF(lsa, LSA_GENERATE);
1524 TERM_DEBUG_OFF(lsa, LSA_INSTALL);
1525 TERM_DEBUG_OFF(lsa, LSA_REFRESH);
1526 TERM_DEBUG_OFF(nsm, NSM);
1527 TERM_DEBUG_OFF(nsm, NSM_EVENTS);
1528 TERM_DEBUG_OFF(nsm, NSM_STATUS);
1529 TERM_DEBUG_OFF(nsm, NSM_TIMERS);
1530 TERM_DEBUG_OFF(nssa, NSSA);
1531 TERM_DEBUG_OFF(zebra, ZEBRA);
1532 TERM_DEBUG_OFF(zebra, ZEBRA_INTERFACE);
1533 TERM_DEBUG_OFF(zebra, ZEBRA_REDISTRIBUTE);
1534 TERM_DEBUG_OFF(defaultinfo, DEFAULTINFO);
1535
1536 return CMD_SUCCESS;
1537 }
1538
1539 static int show_debugging_ospf_common(struct vty *vty, struct ospf *ospf)
1540 {
1541 int i;
1542
1543 if (ospf->instance)
1544 vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance);
1545
1546 vty_out(vty, "OSPF debugging status:\n");
1547
1548 /* Show debug status for events. */
1549 if (IS_DEBUG_OSPF(event, EVENT))
1550 vty_out(vty, " OSPF event debugging is on\n");
1551
1552 /* Show debug status for ISM. */
1553 if (IS_DEBUG_OSPF(ism, ISM) == OSPF_DEBUG_ISM)
1554 vty_out(vty, " OSPF ISM debugging is on\n");
1555 else {
1556 if (IS_DEBUG_OSPF(ism, ISM_STATUS))
1557 vty_out(vty, " OSPF ISM status debugging is on\n");
1558 if (IS_DEBUG_OSPF(ism, ISM_EVENTS))
1559 vty_out(vty, " OSPF ISM event debugging is on\n");
1560 if (IS_DEBUG_OSPF(ism, ISM_TIMERS))
1561 vty_out(vty, " OSPF ISM timer debugging is on\n");
1562 }
1563
1564 /* Show debug status for NSM. */
1565 if (IS_DEBUG_OSPF(nsm, NSM) == OSPF_DEBUG_NSM)
1566 vty_out(vty, " OSPF NSM debugging is on\n");
1567 else {
1568 if (IS_DEBUG_OSPF(nsm, NSM_STATUS))
1569 vty_out(vty, " OSPF NSM status debugging is on\n");
1570 if (IS_DEBUG_OSPF(nsm, NSM_EVENTS))
1571 vty_out(vty, " OSPF NSM event debugging is on\n");
1572 if (IS_DEBUG_OSPF(nsm, NSM_TIMERS))
1573 vty_out(vty, " OSPF NSM timer debugging is on\n");
1574 }
1575
1576 /* Show debug status for OSPF Packets. */
1577 for (i = 0; i < 5; i++)
1578 if (IS_DEBUG_OSPF_PACKET(i, SEND)
1579 && IS_DEBUG_OSPF_PACKET(i, RECV)) {
1580 vty_out(vty, " OSPF packet %s%s debugging is on\n",
1581 lookup_msg(ospf_packet_type_str, i + 1, NULL),
1582 IS_DEBUG_OSPF_PACKET(i, DETAIL) ? " detail"
1583 : "");
1584 } else {
1585 if (IS_DEBUG_OSPF_PACKET(i, SEND))
1586 vty_out(vty,
1587 " OSPF packet %s send%s debugging is on\n",
1588 lookup_msg(ospf_packet_type_str, i + 1,
1589 NULL),
1590 IS_DEBUG_OSPF_PACKET(i, DETAIL)
1591 ? " detail"
1592 : "");
1593 if (IS_DEBUG_OSPF_PACKET(i, RECV))
1594 vty_out(vty,
1595 " OSPF packet %s receive%s debugging is on\n",
1596 lookup_msg(ospf_packet_type_str, i + 1,
1597 NULL),
1598 IS_DEBUG_OSPF_PACKET(i, DETAIL)
1599 ? " detail"
1600 : "");
1601 }
1602
1603 /* Show debug status for OSPF LSAs. */
1604 if (IS_DEBUG_OSPF(lsa, LSA) == OSPF_DEBUG_LSA)
1605 vty_out(vty, " OSPF LSA debugging is on\n");
1606 else {
1607 if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
1608 vty_out(vty, " OSPF LSA generation debugging is on\n");
1609 if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
1610 vty_out(vty, " OSPF LSA flooding debugging is on\n");
1611 if (IS_DEBUG_OSPF(lsa, LSA_INSTALL))
1612 vty_out(vty, " OSPF LSA install debugging is on\n");
1613 if (IS_DEBUG_OSPF(lsa, LSA_REFRESH))
1614 vty_out(vty, " OSPF LSA refresh debugging is on\n");
1615 }
1616
1617 /* Show debug status for Zebra. */
1618 if (IS_DEBUG_OSPF(zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
1619 vty_out(vty, " OSPF Zebra debugging is on\n");
1620 else {
1621 if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
1622 vty_out(vty,
1623 " OSPF Zebra interface debugging is on\n");
1624 if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
1625 vty_out(vty,
1626 " OSPF Zebra redistribute debugging is on\n");
1627 }
1628
1629 if (IS_DEBUG_OSPF(defaultinfo, DEFAULTINFO) == OSPF_DEBUG_DEFAULTINFO)
1630 vty_out(vty, "OSPF default information is on\n");
1631
1632 /* Show debug status for NSSA. */
1633 if (IS_DEBUG_OSPF(nssa, NSSA) == OSPF_DEBUG_NSSA)
1634 vty_out(vty, " OSPF NSSA debugging is on\n");
1635
1636 vty_out(vty, "\n");
1637
1638 return CMD_SUCCESS;
1639 }
1640
1641 DEFUN_NOSH (show_debugging_ospf,
1642 show_debugging_ospf_cmd,
1643 "show debugging [ospf]",
1644 SHOW_STR
1645 DEBUG_STR
1646 OSPF_STR)
1647 {
1648 struct ospf *ospf = NULL;
1649
1650 ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
1651 if (ospf == NULL)
1652 return CMD_SUCCESS;
1653
1654 return show_debugging_ospf_common(vty, ospf);
1655 }
1656
1657 DEFUN_NOSH (show_debugging_ospf_instance,
1658 show_debugging_ospf_instance_cmd,
1659 "show debugging ospf (1-65535)",
1660 SHOW_STR
1661 DEBUG_STR
1662 OSPF_STR
1663 "Instance ID\n")
1664 {
1665 int idx_number = 3;
1666 struct ospf *ospf;
1667 unsigned short instance = 0;
1668
1669 instance = strtoul(argv[idx_number]->arg, NULL, 10);
1670 if ((ospf = ospf_lookup_instance(instance)) == NULL)
1671 return CMD_SUCCESS;
1672
1673 return show_debugging_ospf_common(vty, ospf);
1674 }
1675
1676 static int config_write_debug(struct vty *vty);
1677 /* Debug node. */
1678 static struct cmd_node debug_node = {
1679 .name = "debug",
1680 .node = DEBUG_NODE,
1681 .prompt = "",
1682 .config_write = config_write_debug,
1683 };
1684
1685 static int config_write_debug(struct vty *vty)
1686 {
1687 int write = 0;
1688 int i, r;
1689
1690 const char *type_str[] = {"hello", "dd", "ls-request", "ls-update",
1691 "ls-ack"};
1692 const char *detail_str[] = {
1693 "", " send", " recv", "",
1694 " detail", " send detail", " recv detail", " detail"};
1695
1696 struct ospf *ospf;
1697 char str[16];
1698 memset(str, 0, 16);
1699
1700 ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
1701 if (ospf == NULL)
1702 return CMD_SUCCESS;
1703
1704 if (ospf->instance)
1705 snprintf(str, sizeof(str), " %u", ospf->instance);
1706
1707 /* debug ospf ism (status|events|timers). */
1708 if (IS_CONF_DEBUG_OSPF(ism, ISM) == OSPF_DEBUG_ISM)
1709 vty_out(vty, "debug ospf%s ism\n", str);
1710 else {
1711 if (IS_CONF_DEBUG_OSPF(ism, ISM_STATUS))
1712 vty_out(vty, "debug ospf%s ism status\n", str);
1713 if (IS_CONF_DEBUG_OSPF(ism, ISM_EVENTS))
1714 vty_out(vty, "debug ospf%s ism event\n", str);
1715 if (IS_CONF_DEBUG_OSPF(ism, ISM_TIMERS))
1716 vty_out(vty, "debug ospf%s ism timer\n", str);
1717 }
1718
1719 /* debug ospf nsm (status|events|timers). */
1720 if (IS_CONF_DEBUG_OSPF(nsm, NSM) == OSPF_DEBUG_NSM)
1721 vty_out(vty, "debug ospf%s nsm\n", str);
1722 else {
1723 if (IS_CONF_DEBUG_OSPF(nsm, NSM_STATUS))
1724 vty_out(vty, "debug ospf%s nsm status\n", str);
1725 if (IS_CONF_DEBUG_OSPF(nsm, NSM_EVENTS))
1726 vty_out(vty, "debug ospf%s nsm event\n", str);
1727 if (IS_CONF_DEBUG_OSPF(nsm, NSM_TIMERS))
1728 vty_out(vty, "debug ospf%s nsm timer\n", str);
1729 }
1730
1731 /* debug ospf lsa (generate|flooding|install|refresh). */
1732 if (IS_CONF_DEBUG_OSPF(lsa, LSA) == OSPF_DEBUG_LSA)
1733 vty_out(vty, "debug ospf%s lsa\n", str);
1734 else {
1735 if (IS_CONF_DEBUG_OSPF(lsa, LSA_GENERATE))
1736 vty_out(vty, "debug ospf%s lsa generate\n", str);
1737 if (IS_CONF_DEBUG_OSPF(lsa, LSA_FLOODING))
1738 vty_out(vty, "debug ospf%s lsa flooding\n", str);
1739 if (IS_CONF_DEBUG_OSPF(lsa, LSA_INSTALL))
1740 vty_out(vty, "debug ospf%s lsa install\n", str);
1741 if (IS_CONF_DEBUG_OSPF(lsa, LSA_REFRESH))
1742 vty_out(vty, "debug ospf%s lsa refresh\n", str);
1743
1744 write = 1;
1745 }
1746
1747 /* debug ospf zebra (interface|redistribute). */
1748 if (IS_CONF_DEBUG_OSPF(zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
1749 vty_out(vty, "debug ospf%s zebra\n", str);
1750 else {
1751 if (IS_CONF_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
1752 vty_out(vty, "debug ospf%s zebra interface\n", str);
1753 if (IS_CONF_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
1754 vty_out(vty, "debug ospf%s zebra redistribute\n", str);
1755
1756 write = 1;
1757 }
1758
1759 /* debug ospf event. */
1760 if (IS_CONF_DEBUG_OSPF(event, EVENT) == OSPF_DEBUG_EVENT) {
1761 vty_out(vty, "debug ospf%s event\n", str);
1762 write = 1;
1763 }
1764
1765 /* debug ospf nssa. */
1766 if (IS_CONF_DEBUG_OSPF(nssa, NSSA) == OSPF_DEBUG_NSSA) {
1767 vty_out(vty, "debug ospf%s nssa\n", str);
1768 write = 1;
1769 }
1770
1771 /* debug ospf packet all detail. */
1772 r = OSPF_DEBUG_SEND_RECV | OSPF_DEBUG_DETAIL;
1773 for (i = 0; i < 5; i++)
1774 r &= conf_debug_ospf_packet[i]
1775 & (OSPF_DEBUG_SEND_RECV | OSPF_DEBUG_DETAIL);
1776 if (r == (OSPF_DEBUG_SEND_RECV | OSPF_DEBUG_DETAIL)) {
1777 vty_out(vty, "debug ospf%s packet all detail\n", str);
1778 return 1;
1779 }
1780
1781 /* debug ospf packet all. */
1782 r = OSPF_DEBUG_SEND_RECV;
1783 for (i = 0; i < 5; i++)
1784 r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV;
1785 if (r == OSPF_DEBUG_SEND_RECV) {
1786 vty_out(vty, "debug ospf%s packet all\n", str);
1787 for (i = 0; i < 5; i++)
1788 if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL)
1789 vty_out(vty, "debug ospf%s packet %s detail\n",
1790 str, type_str[i]);
1791 return 1;
1792 }
1793
1794 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
1795 (send|recv) (detail). */
1796 for (i = 0; i < 5; i++) {
1797 if (conf_debug_ospf_packet[i] == 0)
1798 continue;
1799
1800 vty_out(vty, "debug ospf%s packet %s%s\n", str, type_str[i],
1801 detail_str[conf_debug_ospf_packet[i]]);
1802 write = 1;
1803 }
1804
1805 /* debug ospf te */
1806 if (IS_CONF_DEBUG_OSPF(te, TE) == OSPF_DEBUG_TE) {
1807 vty_out(vty, "debug ospf%s te\n", str);
1808 write = 1;
1809 }
1810
1811 /* debug ospf sr */
1812 if (IS_CONF_DEBUG_OSPF(sr, SR) == OSPF_DEBUG_SR) {
1813 vty_out(vty, "debug ospf%s sr\n", str);
1814 write = 1;
1815 }
1816
1817 return write;
1818 }
1819
1820 /* Initialize debug commands. */
1821 void ospf_debug_init(void)
1822 {
1823 install_node(&debug_node);
1824
1825 install_element(ENABLE_NODE, &show_debugging_ospf_cmd);
1826 install_element(ENABLE_NODE, &debug_ospf_ism_cmd);
1827 install_element(ENABLE_NODE, &debug_ospf_nsm_cmd);
1828 install_element(ENABLE_NODE, &debug_ospf_lsa_cmd);
1829 install_element(ENABLE_NODE, &debug_ospf_zebra_cmd);
1830 install_element(ENABLE_NODE, &debug_ospf_event_cmd);
1831 install_element(ENABLE_NODE, &debug_ospf_nssa_cmd);
1832 install_element(ENABLE_NODE, &debug_ospf_te_cmd);
1833 install_element(ENABLE_NODE, &debug_ospf_sr_cmd);
1834 install_element(ENABLE_NODE, &debug_ospf_default_info_cmd);
1835 install_element(ENABLE_NODE, &no_debug_ospf_ism_cmd);
1836 install_element(ENABLE_NODE, &no_debug_ospf_nsm_cmd);
1837 install_element(ENABLE_NODE, &no_debug_ospf_lsa_cmd);
1838 install_element(ENABLE_NODE, &no_debug_ospf_zebra_cmd);
1839 install_element(ENABLE_NODE, &no_debug_ospf_event_cmd);
1840 install_element(ENABLE_NODE, &no_debug_ospf_nssa_cmd);
1841 install_element(ENABLE_NODE, &no_debug_ospf_te_cmd);
1842 install_element(ENABLE_NODE, &no_debug_ospf_sr_cmd);
1843 install_element(ENABLE_NODE, &no_debug_ospf_default_info_cmd);
1844
1845 install_element(ENABLE_NODE, &show_debugging_ospf_instance_cmd);
1846 install_element(ENABLE_NODE, &debug_ospf_packet_cmd);
1847 install_element(ENABLE_NODE, &no_debug_ospf_packet_cmd);
1848
1849 install_element(ENABLE_NODE, &debug_ospf_instance_nsm_cmd);
1850 install_element(ENABLE_NODE, &debug_ospf_instance_lsa_cmd);
1851 install_element(ENABLE_NODE, &debug_ospf_instance_zebra_cmd);
1852 install_element(ENABLE_NODE, &debug_ospf_instance_event_cmd);
1853 install_element(ENABLE_NODE, &debug_ospf_instance_nssa_cmd);
1854 install_element(ENABLE_NODE, &no_debug_ospf_instance_nsm_cmd);
1855 install_element(ENABLE_NODE, &no_debug_ospf_instance_lsa_cmd);
1856 install_element(ENABLE_NODE, &no_debug_ospf_instance_zebra_cmd);
1857 install_element(ENABLE_NODE, &no_debug_ospf_instance_event_cmd);
1858 install_element(ENABLE_NODE, &no_debug_ospf_instance_nssa_cmd);
1859 install_element(ENABLE_NODE, &no_debug_ospf_cmd);
1860
1861 install_element(CONFIG_NODE, &debug_ospf_packet_cmd);
1862 install_element(CONFIG_NODE, &no_debug_ospf_packet_cmd);
1863 install_element(CONFIG_NODE, &debug_ospf_ism_cmd);
1864 install_element(CONFIG_NODE, &no_debug_ospf_ism_cmd);
1865
1866 install_element(CONFIG_NODE, &debug_ospf_nsm_cmd);
1867 install_element(CONFIG_NODE, &debug_ospf_lsa_cmd);
1868 install_element(CONFIG_NODE, &debug_ospf_zebra_cmd);
1869 install_element(CONFIG_NODE, &debug_ospf_event_cmd);
1870 install_element(CONFIG_NODE, &debug_ospf_nssa_cmd);
1871 install_element(CONFIG_NODE, &debug_ospf_te_cmd);
1872 install_element(CONFIG_NODE, &debug_ospf_sr_cmd);
1873 install_element(CONFIG_NODE, &debug_ospf_default_info_cmd);
1874 install_element(CONFIG_NODE, &no_debug_ospf_nsm_cmd);
1875 install_element(CONFIG_NODE, &no_debug_ospf_lsa_cmd);
1876 install_element(CONFIG_NODE, &no_debug_ospf_zebra_cmd);
1877 install_element(CONFIG_NODE, &no_debug_ospf_event_cmd);
1878 install_element(CONFIG_NODE, &no_debug_ospf_nssa_cmd);
1879 install_element(CONFIG_NODE, &no_debug_ospf_te_cmd);
1880 install_element(CONFIG_NODE, &no_debug_ospf_sr_cmd);
1881 install_element(CONFIG_NODE, &no_debug_ospf_default_info_cmd);
1882
1883 install_element(CONFIG_NODE, &debug_ospf_instance_nsm_cmd);
1884 install_element(CONFIG_NODE, &debug_ospf_instance_lsa_cmd);
1885 install_element(CONFIG_NODE, &debug_ospf_instance_zebra_cmd);
1886 install_element(CONFIG_NODE, &debug_ospf_instance_event_cmd);
1887 install_element(CONFIG_NODE, &debug_ospf_instance_nssa_cmd);
1888 install_element(CONFIG_NODE, &no_debug_ospf_instance_nsm_cmd);
1889 install_element(CONFIG_NODE, &no_debug_ospf_instance_lsa_cmd);
1890 install_element(CONFIG_NODE, &no_debug_ospf_instance_zebra_cmd);
1891 install_element(CONFIG_NODE, &no_debug_ospf_instance_event_cmd);
1892 install_element(CONFIG_NODE, &no_debug_ospf_instance_nssa_cmd);
1893 install_element(CONFIG_NODE, &no_debug_ospf_cmd);
1894 }