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