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