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