3 * Copyright (C) 1999, 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
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
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.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
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"
45 const struct message ospf_ism_state_msg
[] =
47 { ISM_DependUpon
, "DependUpon" },
49 { ISM_Loopback
, "Loopback" },
50 { ISM_Waiting
, "Waiting" },
51 { ISM_PointToPoint
, "Point-To-Point" },
52 { ISM_DROther
, "DROther" },
53 { ISM_Backup
, "Backup" },
56 const int ospf_ism_state_msg_max
= OSPF_ISM_STATE_MAX
;
58 const struct message ospf_nsm_state_msg
[] =
60 { NSM_DependUpon
, "DependUpon" },
61 { NSM_Deleted
, "Deleted" },
63 { NSM_Attempt
, "Attempt" },
65 { NSM_TwoWay
, "2-Way" },
66 { NSM_ExStart
, "ExStart" },
67 { NSM_Exchange
, "Exchange" },
68 { NSM_Loading
, "Loading" },
71 const int ospf_nsm_state_msg_max
= OSPF_NSM_STATE_MAX
;
73 const struct message ospf_lsa_type_msg
[] =
75 { OSPF_UNKNOWN_LSA
, "unknown" },
76 { OSPF_ROUTER_LSA
, "router-LSA" },
77 { OSPF_NETWORK_LSA
, "network-LSA" },
78 { OSPF_SUMMARY_LSA
, "summary-LSA" },
79 { OSPF_ASBR_SUMMARY_LSA
, "summary-LSA" },
80 { OSPF_AS_EXTERNAL_LSA
, "AS-external-LSA" },
81 { OSPF_GROUP_MEMBER_LSA
, "GROUP MEMBER LSA" },
82 { OSPF_AS_NSSA_LSA
, "NSSA-LSA" },
84 { OSPF_OPAQUE_LINK_LSA
, "Link-Local Opaque-LSA" },
85 { OSPF_OPAQUE_AREA_LSA
, "Area-Local Opaque-LSA" },
86 { OSPF_OPAQUE_AS_LSA
, "AS-external Opaque-LSA" },
88 const int ospf_lsa_type_msg_max
= OSPF_MAX_LSA
;
90 const struct message ospf_link_state_id_type_msg
[] =
92 { OSPF_UNKNOWN_LSA
, "(unknown)" },
93 { OSPF_ROUTER_LSA
, "" },
94 { OSPF_NETWORK_LSA
, "(address of Designated Router)" },
95 { OSPF_SUMMARY_LSA
, "(summary Network Number)" },
96 { OSPF_ASBR_SUMMARY_LSA
, "(AS Boundary Router address)" },
97 { OSPF_AS_EXTERNAL_LSA
, "(External Network Number)" },
98 { OSPF_GROUP_MEMBER_LSA
, "(Group membership information)" },
99 { OSPF_AS_NSSA_LSA
, "(External Network Number for NSSA)" },
100 { 8, "(Type-8 LSID)" },
101 { OSPF_OPAQUE_LINK_LSA
, "(Link-Local Opaque-Type/ID)" },
102 { OSPF_OPAQUE_AREA_LSA
, "(Area-Local Opaque-Type/ID)" },
103 { OSPF_OPAQUE_AS_LSA
, "(AS-external Opaque-Type/ID)" },
105 const int ospf_link_state_id_type_msg_max
= OSPF_MAX_LSA
;
107 const struct message ospf_network_type_msg
[] =
109 { OSPF_IFTYPE_NONE
, "NONE" },
110 { OSPF_IFTYPE_POINTOPOINT
, "Point-to-Point" },
111 { OSPF_IFTYPE_BROADCAST
, "Broadcast" },
112 { OSPF_IFTYPE_NBMA
, "NBMA" },
113 { OSPF_IFTYPE_POINTOMULTIPOINT
, "Point-to-MultiPoint" },
114 { OSPF_IFTYPE_VIRTUALLINK
, "Virtual-Link" },
116 const int ospf_network_type_msg_max
= OSPF_IFTYPE_MAX
;
119 const struct message ospf_auth_type_str
[] =
121 { OSPF_AUTH_NULL
, "Null" },
122 { OSPF_AUTH_SIMPLE
, "Simple" },
123 { OSPF_AUTH_CRYPTOGRAPHIC
, "Cryptographic" },
125 const size_t ospf_auth_type_str_max
= sizeof (ospf_auth_type_str
) /
126 sizeof (ospf_auth_type_str
[0]);
128 /* Configuration debug option variables. */
129 unsigned long conf_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
130 unsigned long conf_debug_ospf_event
= 0;
131 unsigned long conf_debug_ospf_ism
= 0;
132 unsigned long conf_debug_ospf_nsm
= 0;
133 unsigned long conf_debug_ospf_lsa
= 0;
134 unsigned long conf_debug_ospf_zebra
= 0;
135 unsigned long conf_debug_ospf_nssa
= 0;
137 /* Enable debug option variables -- valid only session. */
138 unsigned long term_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
139 unsigned long term_debug_ospf_event
= 0;
140 unsigned long term_debug_ospf_ism
= 0;
141 unsigned long term_debug_ospf_nsm
= 0;
142 unsigned long term_debug_ospf_lsa
= 0;
143 unsigned long term_debug_ospf_zebra
= 0;
144 unsigned long term_debug_ospf_nssa
= 0;
149 ospf_redist_string(u_int route_type
)
151 return (route_type
== ZEBRA_ROUTE_MAX
) ?
152 "Default" : zebra_route_string(route_type
);
155 #define OSPF_AREA_STRING_MAXLEN 16
157 ospf_area_name_string (struct ospf_area
*area
)
159 static char buf
[OSPF_AREA_STRING_MAXLEN
] = "";
165 area_id
= ntohl (area
->area_id
.s_addr
);
166 snprintf (buf
, OSPF_AREA_STRING_MAXLEN
, "%d.%d.%d.%d",
167 (area_id
>> 24) & 0xff, (area_id
>> 16) & 0xff,
168 (area_id
>> 8) & 0xff, area_id
& 0xff);
172 #define OSPF_AREA_DESC_STRING_MAXLEN 23
174 ospf_area_desc_string (struct ospf_area
*area
)
176 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
180 return "(incomplete)";
182 type
= area
->external_routing
;
186 snprintf (buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [NSSA]",
187 ospf_area_name_string (area
));
190 snprintf (buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [Stub]",
191 ospf_area_name_string (area
));
194 return ospf_area_name_string (area
);
200 #define OSPF_IF_STRING_MAXLEN 40
202 ospf_if_name_string (struct ospf_interface
*oi
)
204 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
207 if (!oi
|| !oi
->address
)
210 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
211 return oi
->ifp
->name
;
213 ifaddr
= ntohl (oi
->address
->u
.prefix4
.s_addr
);
214 snprintf (buf
, OSPF_IF_STRING_MAXLEN
,
215 "%s:%d.%d.%d.%d", oi
->ifp
->name
,
216 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
217 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
223 ospf_nbr_state_message (struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
226 struct ospf_interface
*oi
= nbr
->oi
;
228 if (IPV4_ADDR_SAME (&DR (oi
), &nbr
->address
.u
.prefix4
))
230 else if (IPV4_ADDR_SAME (&BDR (oi
), &nbr
->address
.u
.prefix4
))
235 memset (buf
, 0, size
);
237 snprintf (buf
, size
, "%s/%s",
238 LOOKUP (ospf_nsm_state_msg
, nbr
->state
),
239 LOOKUP (ospf_ism_state_msg
, state
));
243 ospf_timeval_dump (struct timeval
*t
, char *buf
, size_t size
)
245 /* Making formatted timer strings. */
246 #define MINUTE_IN_SECONDS 60
247 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
248 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
249 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
250 unsigned long w
, d
, h
, m
, s
, ms
, us
;
255 w
= d
= h
= m
= s
= ms
= us
= 0;
256 memset (buf
, 0, size
);
267 t
->tv_sec
+= ms
/ 1000;
271 if (t
->tv_sec
> WEEK_IN_SECONDS
)
273 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
274 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
277 if (t
->tv_sec
> DAY_IN_SECONDS
)
279 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
280 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
283 if (t
->tv_sec
>= HOUR_IN_SECONDS
)
285 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
286 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
289 if (t
->tv_sec
>= MINUTE_IN_SECONDS
)
291 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
292 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
296 snprintf (buf
, size
, "%ldw%1ldd", w
, d
);
298 snprintf (buf
, size
, "%ldw%1ldd%02ldh", w
, d
, h
);
300 snprintf (buf
, size
, "%1ldd%02ldh%02ldm", d
, h
, m
);
302 snprintf (buf
, size
, "%ldh%02ldm%02lds", h
, m
, (long)t
->tv_sec
);
304 snprintf (buf
, size
, "%ldm%02lds", m
, (long)t
->tv_sec
);
306 snprintf (buf
, size
, "%ld.%03lds", (long)t
->tv_sec
, ms
);
308 snprintf (buf
, size
, "%ld usecs", (long)t
->tv_usec
);
314 ospf_timer_dump (struct thread
*t
, char *buf
, size_t size
)
316 struct timeval result
;
320 result
= tv_sub (t
->u
.sands
, recent_relative_time());
321 return ospf_timeval_dump (&result
, buf
, size
);
324 #define OSPF_OPTION_STR_MAXLEN 24
327 ospf_options_dump (u_char options
)
329 static char buf
[OSPF_OPTION_STR_MAXLEN
];
331 snprintf (buf
, OSPF_OPTION_STR_MAXLEN
, "*|%s|%s|%s|%s|%s|%s|*",
332 (options
& OSPF_OPTION_O
) ? "O" : "-",
333 (options
& OSPF_OPTION_DC
) ? "DC" : "-",
334 (options
& OSPF_OPTION_EA
) ? "EA" : "-",
335 (options
& OSPF_OPTION_NP
) ? "N/P" : "-",
336 (options
& OSPF_OPTION_MC
) ? "MC" : "-",
337 (options
& OSPF_OPTION_E
) ? "E" : "-");
343 ospf_packet_hello_dump (struct stream
*s
, u_int16_t length
)
345 struct ospf_hello
*hello
;
348 hello
= (struct ospf_hello
*) STREAM_PNT (s
);
350 zlog_debug ("Hello");
351 zlog_debug (" NetworkMask %s", inet_ntoa (hello
->network_mask
));
352 zlog_debug (" HelloInterval %d", ntohs (hello
->hello_interval
));
353 zlog_debug (" Options %d (%s)", hello
->options
,
354 ospf_options_dump (hello
->options
));
355 zlog_debug (" RtrPriority %d", hello
->priority
);
356 zlog_debug (" RtrDeadInterval %ld", (u_long
)ntohl (hello
->dead_interval
));
357 zlog_debug (" DRouter %s", inet_ntoa (hello
->d_router
));
358 zlog_debug (" BDRouter %s", inet_ntoa (hello
->bd_router
));
360 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
361 zlog_debug (" # Neighbors %d", length
/ 4);
362 for (i
= 0; length
> 0; i
++, length
-= sizeof (struct in_addr
))
363 zlog_debug (" Neighbor %s", inet_ntoa (hello
->neighbors
[i
]));
367 ospf_dd_flags_dump (u_char flags
, char *buf
, size_t size
)
369 memset (buf
, 0, size
);
371 snprintf (buf
, size
, "%s|%s|%s",
372 (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
373 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
374 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
380 ospf_lsa_header_dump (struct lsa_header
*lsah
)
382 const char *lsah_type
= LOOKUP (ospf_lsa_type_msg
, lsah
->type
);
384 zlog_debug (" LSA Header");
385 zlog_debug (" LS age %d", ntohs (lsah
->ls_age
));
386 zlog_debug (" Options %d (%s)", lsah
->options
,
387 ospf_options_dump (lsah
->options
));
388 zlog_debug (" LS type %d (%s)", lsah
->type
,
389 (lsah
->type
? lsah_type
: "unknown type"));
390 zlog_debug (" Link State ID %s", inet_ntoa (lsah
->id
));
391 zlog_debug (" Advertising Router %s", inet_ntoa (lsah
->adv_router
));
392 zlog_debug (" LS sequence number 0x%lx", (u_long
)ntohl (lsah
->ls_seqnum
));
393 zlog_debug (" LS checksum 0x%x", ntohs (lsah
->checksum
));
394 zlog_debug (" length %d", ntohs (lsah
->length
));
398 ospf_router_lsa_flags_dump (u_char flags
, char *buf
, size_t size
)
400 memset (buf
, 0, size
);
402 snprintf (buf
, size
, "%s|%s|%s",
403 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
404 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
405 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
411 ospf_router_lsa_dump (struct stream
*s
, u_int16_t length
)
414 struct router_lsa
*rl
;
417 rl
= (struct router_lsa
*) STREAM_PNT (s
);
419 zlog_debug (" Router-LSA");
420 zlog_debug (" flags %s",
421 ospf_router_lsa_flags_dump (rl
->flags
, buf
, BUFSIZ
));
422 zlog_debug (" # links %d", ntohs (rl
->links
));
424 len
= ntohs (rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
425 for (i
= 0; len
> 0; i
++)
427 zlog_debug (" Link ID %s", inet_ntoa (rl
->link
[i
].link_id
));
428 zlog_debug (" Link Data %s", inet_ntoa (rl
->link
[i
].link_data
));
429 zlog_debug (" Type %d", (u_char
) rl
->link
[i
].type
);
430 zlog_debug (" TOS %d", (u_char
) rl
->link
[i
].tos
);
431 zlog_debug (" metric %d", ntohs (rl
->link
[i
].metric
));
438 ospf_network_lsa_dump (struct stream
*s
, u_int16_t length
)
440 struct network_lsa
*nl
;
443 nl
= (struct network_lsa
*) STREAM_PNT (s
);
444 cnt
= (ntohs (nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
446 zlog_debug (" Network-LSA");
448 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
449 zlog_debug ("Network-LSA size %d",
450 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
452 zlog_debug (" Network Mask %s", inet_ntoa (nl
->mask
));
453 zlog_debug (" # Attached Routers %d", cnt
);
454 for (i
= 0; i
< cnt
; i
++)
455 zlog_debug (" Attached Router %s", inet_ntoa (nl
->routers
[i
]));
459 ospf_summary_lsa_dump (struct stream
*s
, u_int16_t length
)
461 struct summary_lsa
*sl
;
465 sl
= (struct summary_lsa
*) STREAM_PNT (s
);
467 zlog_debug (" Summary-LSA");
468 zlog_debug (" Network Mask %s", inet_ntoa (sl
->mask
));
470 size
= ntohs (sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
471 for (i
= 0; size
> 0; size
-= 4, i
++)
472 zlog_debug (" TOS=%d metric %d", sl
->tos
,
473 GET_METRIC (sl
->metric
));
477 ospf_as_external_lsa_dump (struct stream
*s
, u_int16_t length
)
479 struct as_external_lsa
*al
;
483 al
= (struct as_external_lsa
*) STREAM_PNT (s
);
484 zlog_debug (" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
485 zlog_debug (" Network Mask %s", inet_ntoa (al
->mask
));
487 size
= ntohs (al
->header
.length
) - OSPF_LSA_HEADER_SIZE
-4;
488 for (i
= 0; size
> 0; size
-= 12, i
++)
490 zlog_debug (" bit %s TOS=%d metric %d",
491 IS_EXTERNAL_METRIC (al
->e
[i
].tos
) ? "E" : "-",
492 al
->e
[i
].tos
& 0x7f, GET_METRIC (al
->e
[i
].metric
));
493 zlog_debug (" Forwarding address %s", inet_ntoa (al
->e
[i
].fwd_addr
));
494 zlog_debug (" External Route Tag %d", al
->e
[i
].route_tag
);
499 ospf_lsa_header_list_dump (struct stream
*s
, u_int16_t length
)
501 struct lsa_header
*lsa
;
503 zlog_debug (" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
508 lsa
= (struct lsa_header
*) STREAM_PNT (s
);
509 ospf_lsa_header_dump (lsa
);
511 stream_forward_getp (s
, OSPF_LSA_HEADER_SIZE
);
512 length
-= OSPF_LSA_HEADER_SIZE
;
517 ospf_packet_db_desc_dump (struct stream
*s
, u_int16_t length
)
519 struct ospf_db_desc
*dd
;
524 gp
= stream_get_getp (s
);
525 dd
= (struct ospf_db_desc
*) STREAM_PNT (s
);
527 zlog_debug ("Database Description");
528 zlog_debug (" Interface MTU %d", ntohs (dd
->mtu
));
529 zlog_debug (" Options %d (%s)", dd
->options
,
530 ospf_options_dump (dd
->options
));
531 zlog_debug (" Flags %d (%s)", dd
->flags
,
532 ospf_dd_flags_dump (dd
->flags
, dd_flags
, sizeof dd_flags
));
533 zlog_debug (" Sequence Number 0x%08lx", (u_long
)ntohl (dd
->dd_seqnum
));
535 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
537 stream_forward_getp (s
, OSPF_DB_DESC_MIN_SIZE
);
539 ospf_lsa_header_list_dump (s
, length
);
541 stream_set_getp (s
, gp
);
545 ospf_packet_ls_req_dump (struct stream
*s
, u_int16_t length
)
549 struct in_addr ls_id
;
550 struct in_addr adv_router
;
552 sp
= stream_get_getp (s
);
554 length
-= OSPF_HEADER_SIZE
;
556 zlog_debug ("Link State Request");
557 zlog_debug (" # Requests %d", length
/ 12);
559 for (; length
> 0; length
-= 12)
561 ls_type
= stream_getl (s
);
562 ls_id
.s_addr
= stream_get_ipv4 (s
);
563 adv_router
.s_addr
= stream_get_ipv4 (s
);
565 zlog_debug (" LS type %d", ls_type
);
566 zlog_debug (" Link State ID %s", inet_ntoa (ls_id
));
567 zlog_debug (" Advertising Router %s",
568 inet_ntoa (adv_router
));
571 stream_set_getp (s
, sp
);
575 ospf_packet_ls_upd_dump (struct stream
*s
, u_int16_t length
)
578 struct lsa_header
*lsa
;
582 length
-= OSPF_HEADER_SIZE
;
584 sp
= stream_get_getp (s
);
586 count
= stream_getl (s
);
589 zlog_debug ("Link State Update");
590 zlog_debug (" # LSAs %d", count
);
592 while (length
> 0 && count
> 0)
594 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0)
596 zlog_debug (" Remaining %d bytes; Incorrect length.", length
);
600 lsa
= (struct lsa_header
*) STREAM_PNT (s
);
601 lsa_len
= ntohs (lsa
->length
);
602 ospf_lsa_header_dump (lsa
);
606 case OSPF_ROUTER_LSA
:
607 ospf_router_lsa_dump (s
, length
);
609 case OSPF_NETWORK_LSA
:
610 ospf_network_lsa_dump (s
, length
);
612 case OSPF_SUMMARY_LSA
:
613 case OSPF_ASBR_SUMMARY_LSA
:
614 ospf_summary_lsa_dump (s
, length
);
616 case OSPF_AS_EXTERNAL_LSA
:
617 ospf_as_external_lsa_dump (s
, length
);
619 case OSPF_AS_NSSA_LSA
:
620 ospf_as_external_lsa_dump (s
, length
);
622 #ifdef HAVE_OPAQUE_LSA
623 case OSPF_OPAQUE_LINK_LSA
:
624 case OSPF_OPAQUE_AREA_LSA
:
625 case OSPF_OPAQUE_AS_LSA
:
626 ospf_opaque_lsa_dump (s
, length
);
628 #endif /* HAVE_OPAQUE_LSA */
633 stream_forward_getp (s
, lsa_len
);
638 stream_set_getp (s
, sp
);
642 ospf_packet_ls_ack_dump (struct stream
*s
, u_int16_t length
)
646 length
-= OSPF_HEADER_SIZE
;
647 sp
= stream_get_getp (s
);
649 zlog_debug ("Link State Acknowledgment");
650 ospf_lsa_header_list_dump (s
, length
);
652 stream_set_getp (s
, sp
);
655 /* Expects header to be in host order */
657 ospf_ip_header_dump (struct ip
*iph
)
659 /* IP Header dump. */
660 zlog_debug ("ip_v %d", iph
->ip_v
);
661 zlog_debug ("ip_hl %d", iph
->ip_hl
);
662 zlog_debug ("ip_tos %d", iph
->ip_tos
);
663 zlog_debug ("ip_len %d", iph
->ip_len
);
664 zlog_debug ("ip_id %u", (u_int32_t
) iph
->ip_id
);
665 zlog_debug ("ip_off %u", (u_int32_t
) iph
->ip_off
);
666 zlog_debug ("ip_ttl %d", iph
->ip_ttl
);
667 zlog_debug ("ip_p %d", iph
->ip_p
);
668 zlog_debug ("ip_sum 0x%x", (u_int32_t
) iph
->ip_sum
);
669 zlog_debug ("ip_src %s", inet_ntoa (iph
->ip_src
));
670 zlog_debug ("ip_dst %s", inet_ntoa (iph
->ip_dst
));
674 ospf_header_dump (struct ospf_header
*ospfh
)
677 u_int16_t auth_type
= ntohs (ospfh
->auth_type
);
679 zlog_debug ("Header");
680 zlog_debug (" Version %d", ospfh
->version
);
681 zlog_debug (" Type %d (%s)", ospfh
->type
,
682 LOOKUP (ospf_packet_type_str
, ospfh
->type
));
683 zlog_debug (" Packet Len %d", ntohs (ospfh
->length
));
684 zlog_debug (" Router ID %s", inet_ntoa (ospfh
->router_id
));
685 zlog_debug (" Area ID %s", inet_ntoa (ospfh
->area_id
));
686 zlog_debug (" Checksum 0x%x", ntohs (ospfh
->checksum
));
687 zlog_debug (" AuType %s", LOOKUP (ospf_auth_type_str
, auth_type
));
693 case OSPF_AUTH_SIMPLE
:
695 strncpy (buf
, (char *) ospfh
->u
.auth_data
, 8);
696 zlog_debug (" Simple Password %s", buf
);
698 case OSPF_AUTH_CRYPTOGRAPHIC
:
699 zlog_debug (" Cryptographic Authentication");
700 zlog_debug (" Key ID %d", ospfh
->u
.crypt
.key_id
);
701 zlog_debug (" Auth Data Len %d", ospfh
->u
.crypt
.auth_data_len
);
702 zlog_debug (" Sequence number %ld",
703 (u_long
)ntohl (ospfh
->u
.crypt
.crypt_seqnum
));
706 zlog_debug ("* This is not supported authentication type");
713 ospf_packet_dump (struct stream
*s
)
715 struct ospf_header
*ospfh
;
718 /* Preserve pointer. */
719 gp
= stream_get_getp (s
);
721 /* OSPF Header dump. */
722 ospfh
= (struct ospf_header
*) STREAM_PNT (s
);
724 /* Until detail flag is set, return. */
725 if (!(term_debug_ospf_packet
[ospfh
->type
- 1] & OSPF_DEBUG_DETAIL
))
728 /* Show OSPF header detail. */
729 ospf_header_dump (ospfh
);
730 stream_forward_getp (s
, OSPF_HEADER_SIZE
);
735 ospf_packet_hello_dump (s
, ntohs (ospfh
->length
));
737 case OSPF_MSG_DB_DESC
:
738 ospf_packet_db_desc_dump (s
, ntohs (ospfh
->length
));
740 case OSPF_MSG_LS_REQ
:
741 ospf_packet_ls_req_dump (s
, ntohs (ospfh
->length
));
743 case OSPF_MSG_LS_UPD
:
744 ospf_packet_ls_upd_dump (s
, ntohs (ospfh
->length
));
746 case OSPF_MSG_LS_ACK
:
747 ospf_packet_ls_ack_dump (s
, ntohs (ospfh
->length
));
753 stream_set_getp (s
, gp
);
758 [no] debug ospf [<1-65535>] packet (hello|dd|ls-request|ls-update|ls-ack|all)
762 debug_ospf_packet_common (struct vty
*vty
, int arg_base
, int argc
,
769 assert (argc
> arg_base
+ 0);
771 /* Check packet type. */
772 if (strncmp (argv
[arg_base
+ 0], "h", 1) == 0)
773 type
= OSPF_DEBUG_HELLO
;
774 else if (strncmp (argv
[arg_base
+ 0], "d", 1) == 0)
775 type
= OSPF_DEBUG_DB_DESC
;
776 else if (strncmp (argv
[arg_base
+ 0], "ls-r", 4) == 0)
777 type
= OSPF_DEBUG_LS_REQ
;
778 else if (strncmp (argv
[arg_base
+ 0], "ls-u", 4) == 0)
779 type
= OSPF_DEBUG_LS_UPD
;
780 else if (strncmp (argv
[arg_base
+ 0], "ls-a", 4) == 0)
781 type
= OSPF_DEBUG_LS_ACK
;
782 else if (strncmp (argv
[arg_base
+ 0], "a", 1) == 0)
783 type
= OSPF_DEBUG_ALL
;
785 /* Default, both send and recv. */
786 if (argc
== arg_base
+ 1)
787 flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
;
790 if (argc
>= arg_base
+ 2)
792 if (strncmp (argv
[arg_base
+ 1], "s", 1) == 0)
793 flag
= OSPF_DEBUG_SEND
;
794 else if (strncmp (argv
[arg_base
+ 1], "r", 1) == 0)
795 flag
= OSPF_DEBUG_RECV
;
796 else if (strncmp (argv
[arg_base
+ 1], "d", 1) == 0)
797 flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
801 if (argc
== arg_base
+ 3)
802 if (strncmp (argv
[arg_base
+ 2], "d", 1) == 0)
803 flag
|= OSPF_DEBUG_DETAIL
;
805 for (i
= 0; i
< 5; i
++)
806 if (type
& (0x01 << i
))
808 if (vty
->node
== CONFIG_NODE
)
809 DEBUG_PACKET_ON (i
, flag
);
811 TERM_DEBUG_PACKET_ON (i
, flag
);
817 DEFUN (debug_ospf_packet
,
818 debug_ospf_packet_all_cmd
,
819 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
824 "OSPF Database Description\n"
825 "OSPF Link State Request\n"
826 "OSPF Link State Update\n"
827 "OSPF Link State Acknowledgment\n"
828 "OSPF all packets\n")
830 return (debug_ospf_packet_common(vty
, 0, argc
, argv
));
833 ALIAS (debug_ospf_packet
,
834 debug_ospf_packet_send_recv_cmd
,
835 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
836 "Debugging functions\n"
840 "OSPF Database Description\n"
841 "OSPF Link State Request\n"
842 "OSPF Link State Update\n"
843 "OSPF Link State Acknowledgment\n"
847 "Detail information\n")
849 ALIAS (debug_ospf_packet
,
850 debug_ospf_packet_send_recv_detail_cmd
,
851 "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
852 "Debugging functions\n"
856 "OSPF Database Description\n"
857 "OSPF Link State Request\n"
858 "OSPF Link State Update\n"
859 "OSPF Link State Acknowledgment\n"
863 "Detail Information\n")
865 DEFUN (debug_ospf_instance_packet
,
866 debug_ospf_instance_packet_all_cmd
,
867 "debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all)",
873 "OSPF Database Description\n"
874 "OSPF Link State Request\n"
875 "OSPF Link State Update\n"
876 "OSPF Link State Acknowledgment\n"
877 "OSPF all packets\n")
879 u_short instance
= 0;
881 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
882 if (!ospf_lookup_instance (instance
))
885 return (debug_ospf_packet_common(vty
, 1, argc
, argv
));
888 ALIAS (debug_ospf_instance_packet
,
889 debug_ospf_instance_packet_send_recv_cmd
,
890 "debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
891 "Debugging functions\n"
896 "OSPF Database Description\n"
897 "OSPF Link State Request\n"
898 "OSPF Link State Update\n"
899 "OSPF Link State Acknowledgment\n"
903 "Detail information\n")
905 ALIAS (debug_ospf_instance_packet
,
906 debug_ospf_instance_packet_send_recv_detail_cmd
,
907 "debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
908 "Debugging functions\n"
913 "OSPF Database Description\n"
914 "OSPF Link State Request\n"
915 "OSPF Link State Update\n"
916 "OSPF Link State Acknowledgment\n"
920 "Detail Information\n")
923 no_debug_ospf_packet_common (struct vty
*vty
, int arg_base
, int argc
,
930 assert (argc
> arg_base
+ 0);
932 /* Check packet type. */
933 if (strncmp (argv
[arg_base
+ 0], "h", 1) == 0)
934 type
= OSPF_DEBUG_HELLO
;
935 else if (strncmp (argv
[arg_base
+ 0], "d", 1) == 0)
936 type
= OSPF_DEBUG_DB_DESC
;
937 else if (strncmp (argv
[arg_base
+ 0], "ls-r", 4) == 0)
938 type
= OSPF_DEBUG_LS_REQ
;
939 else if (strncmp (argv
[arg_base
+ 0], "ls-u", 4) == 0)
940 type
= OSPF_DEBUG_LS_UPD
;
941 else if (strncmp (argv
[arg_base
+ 0], "ls-a", 4) == 0)
942 type
= OSPF_DEBUG_LS_ACK
;
943 else if (strncmp (argv
[arg_base
+ 0], "a", 1) == 0)
944 type
= OSPF_DEBUG_ALL
;
946 /* Default, both send and recv. */
947 if (argc
== arg_base
+ 1)
948 flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
951 if (argc
== arg_base
+ 2)
953 if (strncmp (argv
[arg_base
+ 1], "s", 1) == 0)
954 flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_DETAIL
;
955 else if (strncmp (argv
[arg_base
+ 1], "r", 1) == 0)
956 flag
= OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
957 else if (strncmp (argv
[arg_base
+ 1], "d", 1) == 0)
958 flag
= OSPF_DEBUG_DETAIL
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
962 if (argc
== arg_base
+ 3)
963 if (strncmp (argv
[arg_base
+ 2], "d", 1) == 0)
964 flag
= OSPF_DEBUG_DETAIL
;
966 for (i
= 0; i
< 5; i
++)
967 if (type
& (0x01 << i
))
969 if (vty
->node
== CONFIG_NODE
)
970 DEBUG_PACKET_OFF (i
, flag
);
972 TERM_DEBUG_PACKET_OFF (i
, flag
);
977 for (i = 0; i < 5; i++)
978 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
985 DEFUN (no_debug_ospf_packet
,
986 no_debug_ospf_packet_all_cmd
,
987 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
993 "OSPF Database Description\n"
994 "OSPF Link State Request\n"
995 "OSPF Link State Update\n"
996 "OSPF Link State Acknowledgment\n"
997 "OSPF all packets\n")
999 return no_debug_ospf_packet_common(vty
, 0, argc
, argv
);
1002 ALIAS (no_debug_ospf_packet
,
1003 no_debug_ospf_packet_send_recv_cmd
,
1004 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
1006 "Debugging functions\n"
1007 "OSPF information\n"
1010 "OSPF Database Description\n"
1011 "OSPF Link State Request\n"
1012 "OSPF Link State Update\n"
1013 "OSPF Link State Acknowledgment\n"
1014 "OSPF all packets\n"
1017 "Detail Information\n")
1019 ALIAS (no_debug_ospf_packet
,
1020 no_debug_ospf_packet_send_recv_detail_cmd
,
1021 "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
1023 "Debugging functions\n"
1024 "OSPF information\n"
1027 "OSPF Database Description\n"
1028 "OSPF Link State Request\n"
1029 "OSPF Link State Update\n"
1030 "OSPF Link State Acknowledgment\n"
1031 "OSPF all packets\n"
1034 "Detail Information\n")
1036 DEFUN (no_debug_ospf_instance_packet
,
1037 no_debug_ospf_instance_packet_all_cmd
,
1038 "no debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all)",
1045 "OSPF Database Description\n"
1046 "OSPF Link State Request\n"
1047 "OSPF Link State Update\n"
1048 "OSPF Link State Acknowledgment\n"
1049 "OSPF all packets\n")
1051 u_short instance
= 0;
1053 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1054 if (!ospf_lookup_instance (instance
))
1057 return (no_debug_ospf_packet_common(vty
, 1, argc
, argv
));
1060 ALIAS (no_debug_ospf_instance_packet
,
1061 no_debug_ospf_instance_packet_send_recv_cmd
,
1062 "no debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
1064 "Debugging functions\n"
1065 "OSPF information\n"
1069 "OSPF Database Description\n"
1070 "OSPF Link State Request\n"
1071 "OSPF Link State Update\n"
1072 "OSPF Link State Acknowledgment\n"
1073 "OSPF all packets\n"
1076 "Detail Information\n")
1078 ALIAS (no_debug_ospf_instance_packet
,
1079 no_debug_ospf_instance_packet_send_recv_detail_cmd
,
1080 "no debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
1082 "Debugging functions\n"
1083 "OSPF information\n"
1087 "OSPF Database Description\n"
1088 "OSPF Link State Request\n"
1089 "OSPF Link State Update\n"
1090 "OSPF Link State Acknowledgment\n"
1091 "OSPF all packets\n"
1094 "Detail Information\n")
1098 debug_ospf_ism_common (struct vty
*vty
, int arg_base
, int argc
, const char **argv
)
1100 if (vty
->node
== CONFIG_NODE
)
1102 if (argc
== arg_base
+ 0)
1103 DEBUG_ON (ism
, ISM
);
1104 else if (argc
== arg_base
+ 1)
1106 if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
1107 DEBUG_ON (ism
, ISM_STATUS
);
1108 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
1109 DEBUG_ON (ism
, ISM_EVENTS
);
1110 else if (strncmp (argv
[arg_base
+ 0], "t", 1) == 0)
1111 DEBUG_ON (ism
, ISM_TIMERS
);
1118 if (argc
== arg_base
+ 0)
1119 TERM_DEBUG_ON (ism
, ISM
);
1120 else if (argc
== arg_base
+ 1)
1122 if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
1123 TERM_DEBUG_ON (ism
, ISM_STATUS
);
1124 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
1125 TERM_DEBUG_ON (ism
, ISM_EVENTS
);
1126 else if (strncmp (argv
[arg_base
+ 0], "t", 1) == 0)
1127 TERM_DEBUG_ON (ism
, ISM_TIMERS
);
1133 DEFUN (debug_ospf_ism
,
1138 "OSPF Interface State Machine\n")
1140 return debug_ospf_ism_common(vty
, 0, argc
, argv
);
1143 ALIAS (debug_ospf_ism
,
1144 debug_ospf_ism_sub_cmd
,
1145 "debug ospf ism (status|events|timers)",
1148 "OSPF Interface State Machine\n"
1149 "ISM Status Information\n"
1150 "ISM Event Information\n"
1151 "ISM TImer Information\n")
1153 DEFUN (debug_ospf_instance_ism
,
1154 debug_ospf_instance_ism_cmd
,
1155 "debug ospf <1-65535> ism",
1159 "OSPF Interface State Machine\n")
1161 u_short instance
= 0;
1163 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1164 if (!ospf_lookup_instance (instance
))
1167 return debug_ospf_ism_common(vty
, 1, argc
, argv
);
1170 ALIAS (debug_ospf_instance_ism
,
1171 debug_ospf_instance_ism_sub_cmd
,
1172 "debug ospf <1-65535> ism (status|events|timers)",
1176 "OSPF Interface State Machine\n"
1177 "ISM Status Information\n"
1178 "ISM Event Information\n"
1179 "ISM TImer Information\n")
1182 no_debug_ospf_ism_common(struct vty
*vty
, int arg_base
, int argc
,
1185 if (vty
->node
== CONFIG_NODE
)
1187 if (argc
== arg_base
+ 0)
1188 DEBUG_OFF (ism
, ISM
);
1189 else if (argc
== arg_base
+ 1)
1191 if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
1192 DEBUG_OFF (ism
, ISM_STATUS
);
1193 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
1194 DEBUG_OFF (ism
, ISM_EVENTS
);
1195 else if (strncmp (argv
[arg_base
+ 0], "t", 1) == 0)
1196 DEBUG_OFF (ism
, ISM_TIMERS
);
1202 if (argc
== arg_base
+ 0)
1203 TERM_DEBUG_OFF (ism
, ISM
);
1204 else if (argc
== arg_base
+ 1)
1206 if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
1207 TERM_DEBUG_OFF (ism
, ISM_STATUS
);
1208 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
1209 TERM_DEBUG_OFF (ism
, ISM_EVENTS
);
1210 else if (strncmp (argv
[arg_base
+ 0], "t", 1) == 0)
1211 TERM_DEBUG_OFF (ism
, ISM_TIMERS
);
1217 DEFUN (no_debug_ospf_ism
,
1218 no_debug_ospf_ism_cmd
,
1219 "no debug ospf ism",
1223 "OSPF Interface State Machine")
1225 return no_debug_ospf_ism_common(vty
, 0, argc
, argv
);
1228 ALIAS (no_debug_ospf_ism
,
1229 no_debug_ospf_ism_sub_cmd
,
1230 "no debug ospf ism (status|events|timers)",
1232 "Debugging functions\n"
1233 "OSPF information\n"
1234 "OSPF Interface State Machine\n"
1235 "ISM Status Information\n"
1236 "ISM Event Information\n"
1237 "ISM Timer Information\n")
1239 DEFUN (no_debug_ospf_instance_ism
,
1240 no_debug_ospf_instance_ism_cmd
,
1241 "no debug ospf <1-65535> ism",
1246 "OSPF Interface State Machine")
1248 u_short instance
= 0;
1250 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1251 if (!ospf_lookup_instance (instance
))
1254 return no_debug_ospf_ism_common(vty
, 1, argc
, argv
);
1257 ALIAS (no_debug_ospf_instance_ism
,
1258 no_debug_ospf_instance_ism_sub_cmd
,
1259 "no debug ospf <1-65535> ism (status|events|timers)",
1261 "Debugging functions\n"
1262 "OSPF information\n"
1264 "OSPF Interface State Machine\n"
1265 "ISM Status Information\n"
1266 "ISM Event Information\n"
1267 "ISM Timer Information\n")
1270 debug_ospf_nsm_common (struct vty
*vty
, int arg_base
, int argc
, const char **argv
)
1272 if (vty
->node
== CONFIG_NODE
)
1274 if (argc
== arg_base
+ 0)
1275 DEBUG_ON (nsm
, NSM
);
1276 else if (argc
== arg_base
+ 1)
1278 if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
1279 DEBUG_ON (nsm
, NSM_STATUS
);
1280 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
1281 DEBUG_ON (nsm
, NSM_EVENTS
);
1282 else if (strncmp (argv
[arg_base
+ 0], "t", 1) == 0)
1283 DEBUG_ON (nsm
, NSM_TIMERS
);
1290 if (argc
== arg_base
+ 0)
1291 TERM_DEBUG_ON (nsm
, NSM
);
1292 else if (argc
== arg_base
+ 1)
1294 if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
1295 TERM_DEBUG_ON (nsm
, NSM_STATUS
);
1296 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
1297 TERM_DEBUG_ON (nsm
, NSM_EVENTS
);
1298 else if (strncmp (argv
[arg_base
+ 0], "t", 1) == 0)
1299 TERM_DEBUG_ON (nsm
, NSM_TIMERS
);
1305 DEFUN (debug_ospf_nsm
,
1310 "OSPF Neighbor State Machine\n")
1312 return debug_ospf_nsm_common (vty
, 0, argc
, argv
);
1315 ALIAS (debug_ospf_nsm
,
1316 debug_ospf_nsm_sub_cmd
,
1317 "debug ospf nsm (status|events|timers)",
1320 "OSPF Neighbor State Machine\n"
1321 "NSM Status Information\n"
1322 "NSM Event Information\n"
1323 "NSM Timer Information\n")
1325 DEFUN (debug_ospf_instance_nsm
,
1326 debug_ospf_instance_nsm_cmd
,
1327 "debug ospf <1-65535> nsm",
1331 "OSPF Neighbor State Machine\n")
1333 u_short instance
= 0;
1335 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1336 if (!ospf_lookup_instance (instance
))
1339 return debug_ospf_nsm_common (vty
, 1, argc
, argv
);
1342 ALIAS (debug_ospf_instance_nsm
,
1343 debug_ospf_instance_nsm_sub_cmd
,
1344 "debug ospf <1-65535> nsm (status|events|timers)",
1348 "OSPF Neighbor State Machine\n"
1349 "NSM Status Information\n"
1350 "NSM Event Information\n"
1351 "NSM Timer Information\n")
1354 no_debug_ospf_nsm_common (struct vty
*vty
, int arg_base
, int argc
, const char **argv
)
1356 if (vty
->node
== CONFIG_NODE
)
1358 if (argc
== arg_base
+ 0)
1359 DEBUG_OFF (nsm
, NSM
);
1360 else if (argc
== arg_base
+ 1)
1362 if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
1363 DEBUG_OFF (nsm
, NSM_STATUS
);
1364 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
1365 DEBUG_OFF (nsm
, NSM_EVENTS
);
1366 else if (strncmp (argv
[arg_base
+ 0], "t", 1) == 0)
1367 DEBUG_OFF (nsm
, NSM_TIMERS
);
1374 if (argc
== arg_base
+ 0)
1375 TERM_DEBUG_OFF (nsm
, NSM
);
1376 else if (argc
== arg_base
+ 1)
1378 if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
1379 TERM_DEBUG_OFF (nsm
, NSM_STATUS
);
1380 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
1381 TERM_DEBUG_OFF (nsm
, NSM_EVENTS
);
1382 else if (strncmp (argv
[arg_base
+ 0], "t", 1) == 0)
1383 TERM_DEBUG_OFF (nsm
, NSM_TIMERS
);
1389 DEFUN (no_debug_ospf_nsm
,
1390 no_debug_ospf_nsm_cmd
,
1391 "no debug ospf nsm",
1395 "OSPF Neighbor State Machine")
1397 return no_debug_ospf_nsm_common(vty
, 0, argc
, argv
);
1400 ALIAS (no_debug_ospf_nsm
,
1401 no_debug_ospf_nsm_sub_cmd
,
1402 "no debug ospf nsm (status|events|timers)",
1404 "Debugging functions\n"
1405 "OSPF information\n"
1406 "OSPF Interface State Machine\n"
1407 "NSM Status Information\n"
1408 "NSM Event Information\n"
1409 "NSM Timer Information\n")
1411 DEFUN (no_debug_ospf_instance_nsm
,
1412 no_debug_ospf_instance_nsm_cmd
,
1413 "no debug ospf <1-65535> nsm",
1418 "OSPF Neighbor State Machine")
1420 u_short instance
= 0;
1422 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1423 if (!ospf_lookup_instance (instance
))
1426 return no_debug_ospf_nsm_common(vty
, 1, argc
, argv
);
1429 ALIAS (no_debug_ospf_instance_nsm
,
1430 no_debug_ospf_instance_nsm_sub_cmd
,
1431 "no debug ospf <1-65535> nsm (status|events|timers)",
1433 "Debugging functions\n"
1434 "OSPF information\n"
1436 "OSPF Interface State Machine\n"
1437 "NSM Status Information\n"
1438 "NSM Event Information\n"
1439 "NSM Timer Information\n")
1443 debug_ospf_lsa_common (struct vty
*vty
, int arg_base
, int argc
, const char **argv
)
1445 if (vty
->node
== CONFIG_NODE
)
1447 if (argc
== arg_base
+ 0)
1448 DEBUG_ON (lsa
, LSA
);
1449 else if (argc
== arg_base
+ 1)
1451 if (strncmp (argv
[arg_base
+ 0], "g", 1) == 0)
1452 DEBUG_ON (lsa
, LSA_GENERATE
);
1453 else if (strncmp (argv
[arg_base
+ 0], "f", 1) == 0)
1454 DEBUG_ON (lsa
, LSA_FLOODING
);
1455 else if (strncmp (argv
[arg_base
+ 0], "i", 1) == 0)
1456 DEBUG_ON (lsa
, LSA_INSTALL
);
1457 else if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
1458 DEBUG_ON (lsa
, LSA_REFRESH
);
1465 if (argc
== arg_base
+ 0)
1466 TERM_DEBUG_ON (lsa
, LSA
);
1467 else if (argc
== arg_base
+ 1)
1469 if (strncmp (argv
[arg_base
+ 0], "g", 1) == 0)
1470 TERM_DEBUG_ON (lsa
, LSA_GENERATE
);
1471 else if (strncmp (argv
[arg_base
+ 0], "f", 1) == 0)
1472 TERM_DEBUG_ON (lsa
, LSA_FLOODING
);
1473 else if (strncmp (argv
[arg_base
+ 0], "i", 1) == 0)
1474 TERM_DEBUG_ON (lsa
, LSA_INSTALL
);
1475 else if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
1476 TERM_DEBUG_ON (lsa
, LSA_REFRESH
);
1482 DEFUN (debug_ospf_lsa
,
1487 "OSPF Link State Advertisement\n")
1489 return debug_ospf_lsa_common(vty
, 0, argc
, argv
);
1492 ALIAS (debug_ospf_lsa
,
1493 debug_ospf_lsa_sub_cmd
,
1494 "debug ospf lsa (generate|flooding|install|refresh)",
1497 "OSPF Link State Advertisement\n"
1500 "LSA Install/Delete\n"
1503 DEFUN (debug_ospf_instance_lsa
,
1504 debug_ospf_instance_lsa_cmd
,
1505 "debug ospf <1-65535> lsa",
1509 "OSPF Link State Advertisement\n")
1511 u_short instance
= 0;
1513 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1514 if (!ospf_lookup_instance (instance
))
1517 return debug_ospf_lsa_common(vty
, 1, argc
, argv
);
1520 ALIAS (debug_ospf_instance_lsa
,
1521 debug_ospf_instance_lsa_sub_cmd
,
1522 "debug ospf <1-65535> lsa (generate|flooding|install|refresh)",
1526 "OSPF Link State Advertisement\n"
1529 "LSA Install/Delete\n"
1533 no_debug_ospf_lsa_common (struct vty
*vty
, int arg_base
, int argc
, const char **argv
)
1535 if (vty
->node
== CONFIG_NODE
)
1537 if (argc
== arg_base
+ 0)
1538 DEBUG_OFF (lsa
, LSA
);
1539 else if (argc
== arg_base
+ 1)
1541 if (strncmp (argv
[arg_base
+ 0], "g", 1) == 0)
1542 DEBUG_OFF (lsa
, LSA_GENERATE
);
1543 else if (strncmp (argv
[arg_base
+ 0], "f", 1) == 0)
1544 DEBUG_OFF (lsa
, LSA_FLOODING
);
1545 else if (strncmp (argv
[arg_base
+ 0], "i", 1) == 0)
1546 DEBUG_OFF (lsa
, LSA_INSTALL
);
1547 else if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
1548 DEBUG_OFF (lsa
, LSA_REFRESH
);
1555 if (argc
== arg_base
+ 0)
1556 TERM_DEBUG_OFF (lsa
, LSA
);
1557 else if (argc
== arg_base
+ 1)
1559 if (strncmp (argv
[arg_base
+ 0], "g", 1) == 0)
1560 TERM_DEBUG_OFF (lsa
, LSA_GENERATE
);
1561 else if (strncmp (argv
[arg_base
+ 0], "f", 1) == 0)
1562 TERM_DEBUG_OFF (lsa
, LSA_FLOODING
);
1563 else if (strncmp (argv
[arg_base
+ 0], "i", 1) == 0)
1564 TERM_DEBUG_OFF (lsa
, LSA_INSTALL
);
1565 else if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
1566 TERM_DEBUG_OFF (lsa
, LSA_REFRESH
);
1572 DEFUN (no_debug_ospf_lsa
,
1573 no_debug_ospf_lsa_cmd
,
1574 "no debug ospf lsa",
1578 "OSPF Link State Advertisement\n")
1580 return no_debug_ospf_lsa_common (vty
, 0, argc
, argv
);
1583 ALIAS (no_debug_ospf_lsa
,
1584 no_debug_ospf_lsa_sub_cmd
,
1585 "no debug ospf lsa (generate|flooding|install|refresh)",
1589 "OSPF Link State Advertisement\n"
1592 "LSA Install/Delete\n"
1595 DEFUN (no_debug_ospf_instance_lsa
,
1596 no_debug_ospf_instance_lsa_cmd
,
1597 "no debug ospf <1-65535> lsa",
1602 "OSPF Link State Advertisement\n")
1604 u_short instance
= 0;
1606 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1607 if (!ospf_lookup_instance (instance
))
1610 return no_debug_ospf_lsa_common (vty
, 1, argc
, argv
);
1613 ALIAS (no_debug_ospf_instance_lsa
,
1614 no_debug_ospf_instance_lsa_sub_cmd
,
1615 "no debug ospf <1-65535> lsa (generate|flooding|install|refresh)",
1620 "OSPF Link State Advertisement\n"
1623 "LSA Install/Delete\n"
1628 debug_ospf_zebra_common (struct vty
*vty
, int arg_base
, int argc
, const char **argv
)
1630 if (vty
->node
== CONFIG_NODE
)
1632 if (argc
== arg_base
+ 0)
1633 DEBUG_ON (zebra
, ZEBRA
);
1634 else if (argc
== arg_base
+ 1)
1636 if (strncmp (argv
[arg_base
+ 0], "i", 1) == 0)
1637 DEBUG_ON (zebra
, ZEBRA_INTERFACE
);
1638 else if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
1639 DEBUG_ON (zebra
, ZEBRA_REDISTRIBUTE
);
1646 if (argc
== arg_base
+ 0)
1647 TERM_DEBUG_ON (zebra
, ZEBRA
);
1648 else if (argc
== arg_base
+ 1)
1650 if (strncmp (argv
[arg_base
+ 0], "i", 1) == 0)
1651 TERM_DEBUG_ON (zebra
, ZEBRA_INTERFACE
);
1652 else if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
1653 TERM_DEBUG_ON (zebra
, ZEBRA_REDISTRIBUTE
);
1659 DEFUN (debug_ospf_zebra
,
1660 debug_ospf_zebra_cmd
,
1664 "OSPF Zebra information\n")
1666 return debug_ospf_zebra_common(vty
, 0, argc
, argv
);
1669 ALIAS (debug_ospf_zebra
,
1670 debug_ospf_zebra_sub_cmd
,
1671 "debug ospf zebra (interface|redistribute)",
1674 "OSPF Zebra information\n"
1676 "Zebra redistribute\n")
1678 DEFUN (debug_ospf_instance_zebra
,
1679 debug_ospf_instance_zebra_cmd
,
1680 "debug ospf <1-65535> zebra",
1684 "OSPF Zebra information\n")
1686 u_short instance
= 0;
1688 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1689 if (!ospf_lookup_instance (instance
))
1692 return debug_ospf_zebra_common(vty
, 1, argc
, argv
);
1695 ALIAS (debug_ospf_instance_zebra
,
1696 debug_ospf_instance_zebra_sub_cmd
,
1697 "debug ospf <1-65535> zebra (interface|redistribute)",
1701 "OSPF Zebra information\n"
1703 "Zebra redistribute\n")
1706 no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1709 if (vty
->node
== CONFIG_NODE
)
1711 if (argc
== arg_base
+ 0)
1712 DEBUG_OFF (zebra
, ZEBRA
);
1713 else if (argc
== arg_base
+ 1)
1715 if (strncmp (argv
[arg_base
+ 0], "i", 1) == 0)
1716 DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1717 else if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
1718 DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1725 if (argc
== arg_base
+ 0)
1726 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1727 else if (argc
== arg_base
+ 1)
1729 if (strncmp (argv
[arg_base
+ 0], "i", 1) == 0)
1730 TERM_DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1731 else if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
1732 TERM_DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1738 DEFUN (no_debug_ospf_zebra
,
1739 no_debug_ospf_zebra_cmd
,
1740 "no debug ospf zebra",
1744 "OSPF Zebra information\n")
1746 return no_debug_ospf_zebra_common(vty
, 0, argc
, argv
);
1749 ALIAS (no_debug_ospf_zebra
,
1750 no_debug_ospf_zebra_sub_cmd
,
1751 "no debug ospf zebra (interface|redistribute)",
1755 "OSPF Zebra information\n"
1757 "Zebra redistribute\n")
1759 DEFUN (no_debug_ospf_instance_zebra
,
1760 no_debug_ospf_instance_zebra_cmd
,
1761 "no debug ospf <1-65535> zebra",
1766 "OSPF Zebra information\n")
1768 u_short instance
= 0;
1770 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1771 if (!ospf_lookup_instance (instance
))
1774 return no_debug_ospf_zebra_common(vty
, 1, argc
, argv
);
1777 ALIAS (no_debug_ospf_instance_zebra
,
1778 no_debug_ospf_instance_zebra_sub_cmd
,
1779 "no debug ospf <1-65535> zebra (interface|redistribute)",
1784 "OSPF Zebra information\n"
1786 "Zebra redistribute\n")
1789 DEFUN (debug_ospf_event
,
1790 debug_ospf_event_cmd
,
1794 "OSPF event information\n")
1796 if (vty
->node
== CONFIG_NODE
)
1797 CONF_DEBUG_ON (event
, EVENT
);
1798 TERM_DEBUG_ON (event
, EVENT
);
1802 DEFUN (no_debug_ospf_event
,
1803 no_debug_ospf_event_cmd
,
1804 "no debug ospf event",
1808 "OSPF event information\n")
1810 if (vty
->node
== CONFIG_NODE
)
1811 CONF_DEBUG_OFF (event
, EVENT
);
1812 TERM_DEBUG_OFF (event
, EVENT
);
1816 DEFUN (debug_ospf_instance_event
,
1817 debug_ospf_instance_event_cmd
,
1818 "debug ospf <1-65535> event",
1822 "OSPF event information\n")
1824 u_short instance
= 0;
1826 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1827 if (!ospf_lookup_instance (instance
))
1830 if (vty
->node
== CONFIG_NODE
)
1831 CONF_DEBUG_ON (event
, EVENT
);
1832 TERM_DEBUG_ON (event
, EVENT
);
1836 DEFUN (no_debug_ospf_instance_event
,
1837 no_debug_ospf_instance_event_cmd
,
1838 "no debug ospf <1-65535> event",
1843 "OSPF event information\n")
1845 u_short instance
= 0;
1847 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1848 if (!ospf_lookup_instance (instance
))
1851 if (vty
->node
== CONFIG_NODE
)
1852 CONF_DEBUG_OFF (event
, EVENT
);
1853 TERM_DEBUG_OFF (event
, EVENT
);
1857 DEFUN (debug_ospf_nssa
,
1858 debug_ospf_nssa_cmd
,
1862 "OSPF nssa information\n")
1864 if (vty
->node
== CONFIG_NODE
)
1865 CONF_DEBUG_ON (nssa
, NSSA
);
1866 TERM_DEBUG_ON (nssa
, NSSA
);
1870 DEFUN (no_debug_ospf_nssa
,
1871 no_debug_ospf_nssa_cmd
,
1872 "no debug ospf nssa",
1876 "OSPF nssa information\n")
1878 if (vty
->node
== CONFIG_NODE
)
1879 CONF_DEBUG_OFF (nssa
, NSSA
);
1880 TERM_DEBUG_OFF (nssa
, NSSA
);
1884 DEFUN (debug_ospf_instance_nssa
,
1885 debug_ospf_instance_nssa_cmd
,
1886 "debug ospf <1-65535> nssa",
1890 "OSPF nssa information\n")
1892 u_short instance
= 0;
1894 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1895 if (!ospf_lookup_instance (instance
))
1898 if (vty
->node
== CONFIG_NODE
)
1899 CONF_DEBUG_ON (nssa
, NSSA
);
1900 TERM_DEBUG_ON (nssa
, NSSA
);
1904 DEFUN (no_debug_ospf_instance_nssa
,
1905 no_debug_ospf_instance_nssa_cmd
,
1906 "no debug ospf <1-65535> nssa",
1911 "OSPF nssa information\n")
1913 u_short instance
= 0;
1915 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
1916 if (!ospf_lookup_instance (instance
))
1919 if (vty
->node
== CONFIG_NODE
)
1920 CONF_DEBUG_OFF (nssa
, NSSA
);
1921 TERM_DEBUG_OFF (nssa
, NSSA
);
1925 DEFUN (no_debug_ospf
,
1932 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1935 if (vty
->node
== CONFIG_NODE
)
1937 CONF_DEBUG_OFF (event
, EVENT
);
1938 CONF_DEBUG_OFF (nssa
, NSSA
);
1939 DEBUG_OFF (ism
, ISM_EVENTS
);
1940 DEBUG_OFF (ism
, ISM_STATUS
);
1941 DEBUG_OFF (ism
, ISM_TIMERS
);
1942 DEBUG_OFF (lsa
, LSA
);
1943 DEBUG_OFF (lsa
, LSA_FLOODING
);
1944 DEBUG_OFF (lsa
, LSA_GENERATE
);
1945 DEBUG_OFF (lsa
, LSA_INSTALL
);
1946 DEBUG_OFF (lsa
, LSA_REFRESH
);
1947 DEBUG_OFF (nsm
, NSM
);
1948 DEBUG_OFF (nsm
, NSM_EVENTS
);
1949 DEBUG_OFF (nsm
, NSM_STATUS
);
1950 DEBUG_OFF (nsm
, NSM_TIMERS
);
1951 DEBUG_OFF (zebra
, ZEBRA
);
1952 DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1953 DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1955 for (i
= 0; i
< 5; i
++)
1956 DEBUG_PACKET_OFF (i
, flag
);
1959 for (i
= 0; i
< 5; i
++)
1960 TERM_DEBUG_PACKET_OFF (i
, flag
);
1962 TERM_DEBUG_OFF (event
, EVENT
);
1963 TERM_DEBUG_OFF (ism
, ISM
);
1964 TERM_DEBUG_OFF (ism
, ISM_EVENTS
);
1965 TERM_DEBUG_OFF (ism
, ISM_STATUS
);
1966 TERM_DEBUG_OFF (ism
, ISM_TIMERS
);
1967 TERM_DEBUG_OFF (lsa
, LSA
);
1968 TERM_DEBUG_OFF (lsa
, LSA_FLOODING
);
1969 TERM_DEBUG_OFF (lsa
, LSA_GENERATE
);
1970 TERM_DEBUG_OFF (lsa
, LSA_INSTALL
);
1971 TERM_DEBUG_OFF (lsa
, LSA_REFRESH
);
1972 TERM_DEBUG_OFF (nsm
, NSM
);
1973 TERM_DEBUG_OFF (nsm
, NSM_EVENTS
);
1974 TERM_DEBUG_OFF (nsm
, NSM_STATUS
);
1975 TERM_DEBUG_OFF (nsm
, NSM_TIMERS
);
1976 TERM_DEBUG_OFF (nssa
, NSSA
);
1977 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1978 TERM_DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1979 TERM_DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1985 show_debugging_ospf_common (struct vty
*vty
, struct ospf
*ospf
)
1990 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
1991 VTY_NEWLINE
, VTY_NEWLINE
);
1993 vty_out (vty
, "OSPF debugging status:%s", VTY_NEWLINE
);
1995 /* Show debug status for events. */
1996 if (IS_DEBUG_OSPF(event
,EVENT
))
1997 vty_out (vty
, " OSPF event debugging is on%s", VTY_NEWLINE
);
1999 /* Show debug status for ISM. */
2000 if (IS_DEBUG_OSPF (ism
, ISM
) == OSPF_DEBUG_ISM
)
2001 vty_out (vty
, " OSPF ISM debugging is on%s", VTY_NEWLINE
);
2004 if (IS_DEBUG_OSPF (ism
, ISM_STATUS
))
2005 vty_out (vty
, " OSPF ISM status debugging is on%s", VTY_NEWLINE
);
2006 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
2007 vty_out (vty
, " OSPF ISM event debugging is on%s", VTY_NEWLINE
);
2008 if (IS_DEBUG_OSPF (ism
, ISM_TIMERS
))
2009 vty_out (vty
, " OSPF ISM timer debugging is on%s", VTY_NEWLINE
);
2012 /* Show debug status for NSM. */
2013 if (IS_DEBUG_OSPF (nsm
, NSM
) == OSPF_DEBUG_NSM
)
2014 vty_out (vty
, " OSPF NSM debugging is on%s", VTY_NEWLINE
);
2017 if (IS_DEBUG_OSPF (nsm
, NSM_STATUS
))
2018 vty_out (vty
, " OSPF NSM status debugging is on%s", VTY_NEWLINE
);
2019 if (IS_DEBUG_OSPF (nsm
, NSM_EVENTS
))
2020 vty_out (vty
, " OSPF NSM event debugging is on%s", VTY_NEWLINE
);
2021 if (IS_DEBUG_OSPF (nsm
, NSM_TIMERS
))
2022 vty_out (vty
, " OSPF NSM timer debugging is on%s", VTY_NEWLINE
);
2025 /* Show debug status for OSPF Packets. */
2026 for (i
= 0; i
< 5; i
++)
2027 if (IS_DEBUG_OSPF_PACKET (i
, SEND
) && IS_DEBUG_OSPF_PACKET (i
, RECV
))
2029 vty_out (vty
, " OSPF packet %s%s debugging is on%s",
2030 LOOKUP (ospf_packet_type_str
, i
+ 1),
2031 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
2036 if (IS_DEBUG_OSPF_PACKET (i
, SEND
))
2037 vty_out (vty
, " OSPF packet %s send%s debugging is on%s",
2038 LOOKUP (ospf_packet_type_str
, i
+ 1),
2039 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
2041 if (IS_DEBUG_OSPF_PACKET (i
, RECV
))
2042 vty_out (vty
, " OSPF packet %s receive%s debugging is on%s",
2043 LOOKUP (ospf_packet_type_str
, i
+ 1),
2044 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
2048 /* Show debug status for OSPF LSAs. */
2049 if (IS_DEBUG_OSPF (lsa
, LSA
) == OSPF_DEBUG_LSA
)
2050 vty_out (vty
, " OSPF LSA debugging is on%s", VTY_NEWLINE
);
2053 if (IS_DEBUG_OSPF (lsa
, LSA_GENERATE
))
2054 vty_out (vty
, " OSPF LSA generation debugging is on%s", VTY_NEWLINE
);
2055 if (IS_DEBUG_OSPF (lsa
, LSA_FLOODING
))
2056 vty_out (vty
, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE
);
2057 if (IS_DEBUG_OSPF (lsa
, LSA_INSTALL
))
2058 vty_out (vty
, " OSPF LSA install debugging is on%s", VTY_NEWLINE
);
2059 if (IS_DEBUG_OSPF (lsa
, LSA_REFRESH
))
2060 vty_out (vty
, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE
);
2063 /* Show debug status for Zebra. */
2064 if (IS_DEBUG_OSPF (zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
2065 vty_out (vty
, " OSPF Zebra debugging is on%s", VTY_NEWLINE
);
2068 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
2069 vty_out (vty
, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE
);
2070 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
2071 vty_out (vty
, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE
);
2074 /* Show debug status for NSSA. */
2075 if (IS_DEBUG_OSPF (nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
2076 vty_out (vty
, " OSPF NSSA debugging is on%s", VTY_NEWLINE
);
2078 vty_out (vty
, "%s", VTY_NEWLINE
);
2083 DEFUN (show_debugging_ospf
,
2084 show_debugging_ospf_cmd
,
2085 "show debugging ospf",
2092 if ((ospf
= ospf_lookup()) == NULL
)
2095 return show_debugging_ospf_common(vty
, ospf
);
2098 DEFUN (show_debugging_ospf_instance
,
2099 show_debugging_ospf_instance_cmd
,
2100 "show debugging ospf <1-65535>",
2107 u_short instance
= 0;
2109 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
2110 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
2113 return show_debugging_ospf_common(vty
, ospf
);
2117 static struct cmd_node debug_node
=
2125 config_write_debug (struct vty
*vty
)
2130 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
2131 const char *detail_str
[] = {"", " send", " recv", "", " detail",
2132 " send detail", " recv detail", " detail"};
2137 if ((ospf
= ospf_lookup()) == NULL
)
2141 sprintf(str
, " %d", ospf
->instance
);
2143 /* debug ospf ism (status|events|timers). */
2144 if (IS_CONF_DEBUG_OSPF (ism
, ISM
) == OSPF_DEBUG_ISM
)
2145 vty_out (vty
, "debug ospf%s ism%s", str
, VTY_NEWLINE
);
2148 if (IS_CONF_DEBUG_OSPF (ism
, ISM_STATUS
))
2149 vty_out (vty
, "debug ospf%s ism status%s", str
, VTY_NEWLINE
);
2150 if (IS_CONF_DEBUG_OSPF (ism
, ISM_EVENTS
))
2151 vty_out (vty
, "debug ospf%s ism event%s", str
, VTY_NEWLINE
);
2152 if (IS_CONF_DEBUG_OSPF (ism
, ISM_TIMERS
))
2153 vty_out (vty
, "debug ospf%s ism timer%s", str
, VTY_NEWLINE
);
2156 /* debug ospf nsm (status|events|timers). */
2157 if (IS_CONF_DEBUG_OSPF (nsm
, NSM
) == OSPF_DEBUG_NSM
)
2158 vty_out (vty
, "debug ospf%s nsm%s", str
, VTY_NEWLINE
);
2161 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_STATUS
))
2162 vty_out (vty
, "debug ospf%s nsm status%s", str
, VTY_NEWLINE
);
2163 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_EVENTS
))
2164 vty_out (vty
, "debug ospf%s nsm event%s", str
, VTY_NEWLINE
);
2165 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_TIMERS
))
2166 vty_out (vty
, "debug ospf%s nsm timer%s", str
, VTY_NEWLINE
);
2169 /* debug ospf lsa (generate|flooding|install|refresh). */
2170 if (IS_CONF_DEBUG_OSPF (lsa
, LSA
) == OSPF_DEBUG_LSA
)
2171 vty_out (vty
, "debug ospf%s lsa%s", str
, VTY_NEWLINE
);
2174 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_GENERATE
))
2175 vty_out (vty
, "debug ospf%s lsa generate%s", str
, VTY_NEWLINE
);
2176 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_FLOODING
))
2177 vty_out (vty
, "debug ospf%s lsa flooding%s", str
, VTY_NEWLINE
);
2178 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_INSTALL
))
2179 vty_out (vty
, "debug ospf%s lsa install%s", str
, VTY_NEWLINE
);
2180 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_REFRESH
))
2181 vty_out (vty
, "debug ospf%s lsa refresh%s", str
, VTY_NEWLINE
);
2186 /* debug ospf zebra (interface|redistribute). */
2187 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
2188 vty_out (vty
, "debug ospf%s zebra%s", str
, VTY_NEWLINE
);
2191 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
2192 vty_out (vty
, "debug ospf%s zebra interface%s", str
, VTY_NEWLINE
);
2193 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
2194 vty_out (vty
, "debug ospf%s zebra redistribute%s", str
, VTY_NEWLINE
);
2199 /* debug ospf event. */
2200 if (IS_CONF_DEBUG_OSPF (event
, EVENT
) == OSPF_DEBUG_EVENT
)
2202 vty_out (vty
, "debug ospf%s event%s", str
, VTY_NEWLINE
);
2206 /* debug ospf nssa. */
2207 if (IS_CONF_DEBUG_OSPF (nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
2209 vty_out (vty
, "debug ospf%s nssa%s", str
, VTY_NEWLINE
);
2213 /* debug ospf packet all detail. */
2214 r
= OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
;
2215 for (i
= 0; i
< 5; i
++)
2216 r
&= conf_debug_ospf_packet
[i
] & (OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
);
2217 if (r
== (OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
))
2219 vty_out (vty
, "debug ospf%s packet all detail%s", str
, VTY_NEWLINE
);
2223 /* debug ospf packet all. */
2224 r
= OSPF_DEBUG_SEND_RECV
;
2225 for (i
= 0; i
< 5; i
++)
2226 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
2227 if (r
== OSPF_DEBUG_SEND_RECV
)
2229 vty_out (vty
, "debug ospf%s packet all%s", str
, VTY_NEWLINE
);
2230 for (i
= 0; i
< 5; i
++)
2231 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
2232 vty_out (vty
, "debug ospf%s packet %s detail%s", str
,
2238 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
2239 (send|recv) (detail). */
2240 for (i
= 0; i
< 5; i
++)
2242 if (conf_debug_ospf_packet
[i
] == 0)
2245 vty_out (vty
, "debug ospf%s packet %s%s%s", str
,
2246 type_str
[i
], detail_str
[conf_debug_ospf_packet
[i
]],
2254 /* Initialize debug commands. */
2258 install_node (&debug_node
, config_write_debug
);
2260 install_element (ENABLE_NODE
, &show_debugging_ospf_cmd
);
2261 install_element (ENABLE_NODE
, &debug_ospf_packet_send_recv_detail_cmd
);
2262 install_element (ENABLE_NODE
, &debug_ospf_packet_send_recv_cmd
);
2263 install_element (ENABLE_NODE
, &debug_ospf_packet_all_cmd
);
2264 install_element (ENABLE_NODE
, &debug_ospf_ism_sub_cmd
);
2265 install_element (ENABLE_NODE
, &debug_ospf_ism_cmd
);
2266 install_element (ENABLE_NODE
, &debug_ospf_nsm_sub_cmd
);
2267 install_element (ENABLE_NODE
, &debug_ospf_nsm_cmd
);
2268 install_element (ENABLE_NODE
, &debug_ospf_lsa_sub_cmd
);
2269 install_element (ENABLE_NODE
, &debug_ospf_lsa_cmd
);
2270 install_element (ENABLE_NODE
, &debug_ospf_zebra_sub_cmd
);
2271 install_element (ENABLE_NODE
, &debug_ospf_zebra_cmd
);
2272 install_element (ENABLE_NODE
, &debug_ospf_event_cmd
);
2273 install_element (ENABLE_NODE
, &debug_ospf_nssa_cmd
);
2274 install_element (ENABLE_NODE
, &no_debug_ospf_packet_send_recv_detail_cmd
);
2275 install_element (ENABLE_NODE
, &no_debug_ospf_packet_send_recv_cmd
);
2276 install_element (ENABLE_NODE
, &no_debug_ospf_packet_all_cmd
);
2277 install_element (ENABLE_NODE
, &no_debug_ospf_ism_sub_cmd
);
2278 install_element (ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
2279 install_element (ENABLE_NODE
, &no_debug_ospf_nsm_sub_cmd
);
2280 install_element (ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
2281 install_element (ENABLE_NODE
, &no_debug_ospf_lsa_sub_cmd
);
2282 install_element (ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
2283 install_element (ENABLE_NODE
, &no_debug_ospf_zebra_sub_cmd
);
2284 install_element (ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
2285 install_element (ENABLE_NODE
, &no_debug_ospf_event_cmd
);
2286 install_element (ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
2288 install_element (ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
2289 install_element (ENABLE_NODE
, &debug_ospf_instance_packet_send_recv_detail_cmd
);
2290 install_element (ENABLE_NODE
, &debug_ospf_instance_packet_send_recv_cmd
);
2291 install_element (ENABLE_NODE
, &debug_ospf_instance_packet_all_cmd
);
2292 install_element (ENABLE_NODE
, &debug_ospf_instance_ism_sub_cmd
);
2293 install_element (ENABLE_NODE
, &debug_ospf_instance_ism_cmd
);
2294 install_element (ENABLE_NODE
, &debug_ospf_instance_nsm_sub_cmd
);
2295 install_element (ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
2296 install_element (ENABLE_NODE
, &debug_ospf_instance_lsa_sub_cmd
);
2297 install_element (ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
2298 install_element (ENABLE_NODE
, &debug_ospf_instance_zebra_sub_cmd
);
2299 install_element (ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
2300 install_element (ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
2301 install_element (ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
2302 install_element (ENABLE_NODE
, &no_debug_ospf_instance_packet_send_recv_detail_cmd
);
2303 install_element (ENABLE_NODE
, &no_debug_ospf_instance_packet_send_recv_cmd
);
2304 install_element (ENABLE_NODE
, &no_debug_ospf_instance_packet_all_cmd
);
2305 install_element (ENABLE_NODE
, &no_debug_ospf_instance_ism_sub_cmd
);
2306 install_element (ENABLE_NODE
, &no_debug_ospf_instance_ism_cmd
);
2307 install_element (ENABLE_NODE
, &no_debug_ospf_instance_nsm_sub_cmd
);
2308 install_element (ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
2309 install_element (ENABLE_NODE
, &no_debug_ospf_instance_lsa_sub_cmd
);
2310 install_element (ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
2311 install_element (ENABLE_NODE
, &no_debug_ospf_instance_zebra_sub_cmd
);
2312 install_element (ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
2313 install_element (ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
2314 install_element (ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
2315 install_element (ENABLE_NODE
, &no_debug_ospf_cmd
);
2317 install_element (CONFIG_NODE
, &debug_ospf_packet_send_recv_detail_cmd
);
2318 install_element (CONFIG_NODE
, &debug_ospf_packet_send_recv_cmd
);
2319 install_element (CONFIG_NODE
, &debug_ospf_packet_all_cmd
);
2320 install_element (CONFIG_NODE
, &debug_ospf_ism_sub_cmd
);
2321 install_element (CONFIG_NODE
, &debug_ospf_ism_cmd
);
2322 install_element (CONFIG_NODE
, &debug_ospf_nsm_sub_cmd
);
2323 install_element (CONFIG_NODE
, &debug_ospf_nsm_cmd
);
2324 install_element (CONFIG_NODE
, &debug_ospf_lsa_sub_cmd
);
2325 install_element (CONFIG_NODE
, &debug_ospf_lsa_cmd
);
2326 install_element (CONFIG_NODE
, &debug_ospf_zebra_sub_cmd
);
2327 install_element (CONFIG_NODE
, &debug_ospf_zebra_cmd
);
2328 install_element (CONFIG_NODE
, &debug_ospf_event_cmd
);
2329 install_element (CONFIG_NODE
, &debug_ospf_nssa_cmd
);
2330 install_element (CONFIG_NODE
, &no_debug_ospf_packet_send_recv_detail_cmd
);
2331 install_element (CONFIG_NODE
, &no_debug_ospf_packet_send_recv_cmd
);
2332 install_element (CONFIG_NODE
, &no_debug_ospf_packet_all_cmd
);
2333 install_element (CONFIG_NODE
, &no_debug_ospf_ism_sub_cmd
);
2334 install_element (CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
2335 install_element (CONFIG_NODE
, &no_debug_ospf_nsm_sub_cmd
);
2336 install_element (CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
2337 install_element (CONFIG_NODE
, &no_debug_ospf_lsa_sub_cmd
);
2338 install_element (CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
2339 install_element (CONFIG_NODE
, &no_debug_ospf_zebra_sub_cmd
);
2340 install_element (CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
2341 install_element (CONFIG_NODE
, &no_debug_ospf_event_cmd
);
2342 install_element (CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
2344 install_element (CONFIG_NODE
, &debug_ospf_instance_packet_send_recv_detail_cmd
);
2345 install_element (CONFIG_NODE
, &debug_ospf_instance_packet_send_recv_cmd
);
2346 install_element (CONFIG_NODE
, &debug_ospf_instance_packet_all_cmd
);
2347 install_element (CONFIG_NODE
, &debug_ospf_instance_ism_sub_cmd
);
2348 install_element (CONFIG_NODE
, &debug_ospf_instance_ism_cmd
);
2349 install_element (CONFIG_NODE
, &debug_ospf_instance_nsm_sub_cmd
);
2350 install_element (CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
2351 install_element (CONFIG_NODE
, &debug_ospf_instance_lsa_sub_cmd
);
2352 install_element (CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
2353 install_element (CONFIG_NODE
, &debug_ospf_instance_zebra_sub_cmd
);
2354 install_element (CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
2355 install_element (CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
2356 install_element (CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
2357 install_element (CONFIG_NODE
, &no_debug_ospf_instance_packet_send_recv_detail_cmd
);
2358 install_element (CONFIG_NODE
, &no_debug_ospf_instance_packet_send_recv_cmd
);
2359 install_element (CONFIG_NODE
, &no_debug_ospf_instance_packet_all_cmd
);
2360 install_element (CONFIG_NODE
, &no_debug_ospf_instance_ism_sub_cmd
);
2361 install_element (CONFIG_NODE
, &no_debug_ospf_instance_ism_cmd
);
2362 install_element (CONFIG_NODE
, &no_debug_ospf_instance_nsm_sub_cmd
);
2363 install_element (CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
2364 install_element (CONFIG_NODE
, &no_debug_ospf_instance_lsa_sub_cmd
);
2365 install_element (CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
2366 install_element (CONFIG_NODE
, &no_debug_ospf_instance_zebra_sub_cmd
);
2367 install_element (CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
2368 install_element (CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
2369 install_element (CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
2370 install_element (CONFIG_NODE
, &no_debug_ospf_cmd
);