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;
136 unsigned long conf_debug_ospf_te
= 0;
138 /* Enable debug option variables -- valid only session. */
139 unsigned long term_debug_ospf_packet
[5] = {0, 0, 0, 0, 0};
140 unsigned long term_debug_ospf_event
= 0;
141 unsigned long term_debug_ospf_ism
= 0;
142 unsigned long term_debug_ospf_nsm
= 0;
143 unsigned long term_debug_ospf_lsa
= 0;
144 unsigned long term_debug_ospf_zebra
= 0;
145 unsigned long term_debug_ospf_nssa
= 0;
146 unsigned long term_debug_ospf_te
= 0;
150 ospf_redist_string(u_int route_type
)
152 return (route_type
== ZEBRA_ROUTE_MAX
) ?
153 "Default" : zebra_route_string(route_type
);
156 #define OSPF_AREA_STRING_MAXLEN 16
158 ospf_area_name_string (struct ospf_area
*area
)
160 static char buf
[OSPF_AREA_STRING_MAXLEN
] = "";
166 area_id
= ntohl (area
->area_id
.s_addr
);
167 snprintf (buf
, OSPF_AREA_STRING_MAXLEN
, "%d.%d.%d.%d",
168 (area_id
>> 24) & 0xff, (area_id
>> 16) & 0xff,
169 (area_id
>> 8) & 0xff, area_id
& 0xff);
173 #define OSPF_AREA_DESC_STRING_MAXLEN 23
175 ospf_area_desc_string (struct ospf_area
*area
)
177 static char buf
[OSPF_AREA_DESC_STRING_MAXLEN
] = "";
181 return "(incomplete)";
183 type
= area
->external_routing
;
187 snprintf (buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [NSSA]",
188 ospf_area_name_string (area
));
191 snprintf (buf
, OSPF_AREA_DESC_STRING_MAXLEN
, "%s [Stub]",
192 ospf_area_name_string (area
));
195 return ospf_area_name_string (area
);
201 #define OSPF_IF_STRING_MAXLEN 40
203 ospf_if_name_string (struct ospf_interface
*oi
)
205 static char buf
[OSPF_IF_STRING_MAXLEN
] = "";
208 if (!oi
|| !oi
->address
)
211 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
212 return oi
->ifp
->name
;
214 ifaddr
= ntohl (oi
->address
->u
.prefix4
.s_addr
);
215 snprintf (buf
, OSPF_IF_STRING_MAXLEN
,
216 "%s:%d.%d.%d.%d", oi
->ifp
->name
,
217 (ifaddr
>> 24) & 0xff, (ifaddr
>> 16) & 0xff,
218 (ifaddr
>> 8) & 0xff, ifaddr
& 0xff);
224 ospf_nbr_state_message (struct ospf_neighbor
*nbr
, char *buf
, size_t size
)
227 struct ospf_interface
*oi
= nbr
->oi
;
229 if (IPV4_ADDR_SAME (&DR (oi
), &nbr
->address
.u
.prefix4
))
231 else if (IPV4_ADDR_SAME (&BDR (oi
), &nbr
->address
.u
.prefix4
))
236 memset (buf
, 0, size
);
238 snprintf (buf
, size
, "%s/%s",
239 LOOKUP (ospf_nsm_state_msg
, nbr
->state
),
240 LOOKUP (ospf_ism_state_msg
, state
));
244 ospf_timeval_dump (struct timeval
*t
, char *buf
, size_t size
)
246 /* Making formatted timer strings. */
247 #define MINUTE_IN_SECONDS 60
248 #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
249 #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
250 #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
251 unsigned long w
, d
, h
, m
, s
, ms
, us
;
256 w
= d
= h
= m
= s
= ms
= us
= 0;
257 memset (buf
, 0, size
);
268 t
->tv_sec
+= ms
/ 1000;
272 if (t
->tv_sec
> WEEK_IN_SECONDS
)
274 w
= t
->tv_sec
/ WEEK_IN_SECONDS
;
275 t
->tv_sec
-= w
* WEEK_IN_SECONDS
;
278 if (t
->tv_sec
> DAY_IN_SECONDS
)
280 d
= t
->tv_sec
/ DAY_IN_SECONDS
;
281 t
->tv_sec
-= d
* DAY_IN_SECONDS
;
284 if (t
->tv_sec
>= HOUR_IN_SECONDS
)
286 h
= t
->tv_sec
/ HOUR_IN_SECONDS
;
287 t
->tv_sec
-= h
* HOUR_IN_SECONDS
;
290 if (t
->tv_sec
>= MINUTE_IN_SECONDS
)
292 m
= t
->tv_sec
/ MINUTE_IN_SECONDS
;
293 t
->tv_sec
-= m
* MINUTE_IN_SECONDS
;
297 snprintf (buf
, size
, "%ldw%1ldd", w
, d
);
299 snprintf (buf
, size
, "%ldw%1ldd%02ldh", w
, d
, h
);
301 snprintf (buf
, size
, "%1ldd%02ldh%02ldm", d
, h
, m
);
303 snprintf (buf
, size
, "%ldh%02ldm%02lds", h
, m
, (long)t
->tv_sec
);
305 snprintf (buf
, size
, "%ldm%02lds", m
, (long)t
->tv_sec
);
307 snprintf (buf
, size
, "%ld.%03lds", (long)t
->tv_sec
, ms
);
309 snprintf (buf
, size
, "%ld usecs", (long)t
->tv_usec
);
315 ospf_timer_dump (struct thread
*t
, char *buf
, size_t size
)
317 struct timeval result
;
321 result
= tv_sub (t
->u
.sands
, recent_relative_time());
322 return ospf_timeval_dump (&result
, buf
, size
);
325 #define OSPF_OPTION_STR_MAXLEN 24
328 ospf_options_dump (u_char options
)
330 static char buf
[OSPF_OPTION_STR_MAXLEN
];
332 snprintf (buf
, OSPF_OPTION_STR_MAXLEN
, "*|%s|%s|%s|%s|%s|%s|%s",
333 (options
& OSPF_OPTION_O
) ? "O" : "-",
334 (options
& OSPF_OPTION_DC
) ? "DC" : "-",
335 (options
& OSPF_OPTION_EA
) ? "EA" : "-",
336 (options
& OSPF_OPTION_NP
) ? "N/P" : "-",
337 (options
& OSPF_OPTION_MC
) ? "MC" : "-",
338 (options
& OSPF_OPTION_E
) ? "E" : "-",
339 (options
& OSPF_OPTION_MT
) ? "M/T" : "-");
345 ospf_packet_hello_dump (struct stream
*s
, u_int16_t length
)
347 struct ospf_hello
*hello
;
350 hello
= (struct ospf_hello
*) STREAM_PNT (s
);
352 zlog_debug ("Hello");
353 zlog_debug (" NetworkMask %s", inet_ntoa (hello
->network_mask
));
354 zlog_debug (" HelloInterval %d", ntohs (hello
->hello_interval
));
355 zlog_debug (" Options %d (%s)", hello
->options
,
356 ospf_options_dump (hello
->options
));
357 zlog_debug (" RtrPriority %d", hello
->priority
);
358 zlog_debug (" RtrDeadInterval %ld", (u_long
)ntohl (hello
->dead_interval
));
359 zlog_debug (" DRouter %s", inet_ntoa (hello
->d_router
));
360 zlog_debug (" BDRouter %s", inet_ntoa (hello
->bd_router
));
362 length
-= OSPF_HEADER_SIZE
+ OSPF_HELLO_MIN_SIZE
;
363 zlog_debug (" # Neighbors %d", length
/ 4);
364 for (i
= 0; length
> 0; i
++, length
-= sizeof (struct in_addr
))
365 zlog_debug (" Neighbor %s", inet_ntoa (hello
->neighbors
[i
]));
369 ospf_dd_flags_dump (u_char flags
, char *buf
, size_t size
)
371 memset (buf
, 0, size
);
373 snprintf (buf
, size
, "%s|%s|%s",
374 (flags
& OSPF_DD_FLAG_I
) ? "I" : "-",
375 (flags
& OSPF_DD_FLAG_M
) ? "M" : "-",
376 (flags
& OSPF_DD_FLAG_MS
) ? "MS" : "-");
382 ospf_lsa_header_dump (struct lsa_header
*lsah
)
384 const char *lsah_type
= LOOKUP (ospf_lsa_type_msg
, lsah
->type
);
386 zlog_debug (" LSA Header");
387 zlog_debug (" LS age %d", ntohs (lsah
->ls_age
));
388 zlog_debug (" Options %d (%s)", lsah
->options
,
389 ospf_options_dump (lsah
->options
));
390 zlog_debug (" LS type %d (%s)", lsah
->type
,
391 (lsah
->type
? lsah_type
: "unknown type"));
392 zlog_debug (" Link State ID %s", inet_ntoa (lsah
->id
));
393 zlog_debug (" Advertising Router %s", inet_ntoa (lsah
->adv_router
));
394 zlog_debug (" LS sequence number 0x%lx", (u_long
)ntohl (lsah
->ls_seqnum
));
395 zlog_debug (" LS checksum 0x%x", ntohs (lsah
->checksum
));
396 zlog_debug (" length %d", ntohs (lsah
->length
));
400 ospf_router_lsa_flags_dump (u_char flags
, char *buf
, size_t size
)
402 memset (buf
, 0, size
);
404 snprintf (buf
, size
, "%s|%s|%s",
405 (flags
& ROUTER_LSA_VIRTUAL
) ? "V" : "-",
406 (flags
& ROUTER_LSA_EXTERNAL
) ? "E" : "-",
407 (flags
& ROUTER_LSA_BORDER
) ? "B" : "-");
413 ospf_router_lsa_dump (struct stream
*s
, u_int16_t length
)
416 struct router_lsa
*rl
;
419 rl
= (struct router_lsa
*) STREAM_PNT (s
);
421 zlog_debug (" Router-LSA");
422 zlog_debug (" flags %s",
423 ospf_router_lsa_flags_dump (rl
->flags
, buf
, BUFSIZ
));
424 zlog_debug (" # links %d", ntohs (rl
->links
));
426 len
= ntohs (rl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
427 for (i
= 0; len
> 0; i
++)
429 zlog_debug (" Link ID %s", inet_ntoa (rl
->link
[i
].link_id
));
430 zlog_debug (" Link Data %s", inet_ntoa (rl
->link
[i
].link_data
));
431 zlog_debug (" Type %d", (u_char
) rl
->link
[i
].type
);
432 zlog_debug (" TOS %d", (u_char
) rl
->link
[i
].tos
);
433 zlog_debug (" metric %d", ntohs (rl
->link
[i
].metric
));
440 ospf_network_lsa_dump (struct stream
*s
, u_int16_t length
)
442 struct network_lsa
*nl
;
445 nl
= (struct network_lsa
*) STREAM_PNT (s
);
446 cnt
= (ntohs (nl
->header
.length
) - (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
448 zlog_debug (" Network-LSA");
450 zlog_debug ("LSA total size %d", ntohs (nl->header.length));
451 zlog_debug ("Network-LSA size %d",
452 ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
454 zlog_debug (" Network Mask %s", inet_ntoa (nl
->mask
));
455 zlog_debug (" # Attached Routers %d", cnt
);
456 for (i
= 0; i
< cnt
; i
++)
457 zlog_debug (" Attached Router %s", inet_ntoa (nl
->routers
[i
]));
461 ospf_summary_lsa_dump (struct stream
*s
, u_int16_t length
)
463 struct summary_lsa
*sl
;
467 sl
= (struct summary_lsa
*) STREAM_PNT (s
);
469 zlog_debug (" Summary-LSA");
470 zlog_debug (" Network Mask %s", inet_ntoa (sl
->mask
));
472 size
= ntohs (sl
->header
.length
) - OSPF_LSA_HEADER_SIZE
- 4;
473 for (i
= 0; size
> 0; size
-= 4, i
++)
474 zlog_debug (" TOS=%d metric %d", sl
->tos
,
475 GET_METRIC (sl
->metric
));
479 ospf_as_external_lsa_dump (struct stream
*s
, u_int16_t length
)
481 struct as_external_lsa
*al
;
485 al
= (struct as_external_lsa
*) STREAM_PNT (s
);
486 zlog_debug (" %s", ospf_lsa_type_msg
[al
->header
.type
].str
);
487 zlog_debug (" Network Mask %s", inet_ntoa (al
->mask
));
489 size
= ntohs (al
->header
.length
) - OSPF_LSA_HEADER_SIZE
-4;
490 for (i
= 0; size
> 0; size
-= 12, i
++)
492 zlog_debug (" bit %s TOS=%d metric %d",
493 IS_EXTERNAL_METRIC (al
->e
[i
].tos
) ? "E" : "-",
494 al
->e
[i
].tos
& 0x7f, GET_METRIC (al
->e
[i
].metric
));
495 zlog_debug (" Forwarding address %s", inet_ntoa (al
->e
[i
].fwd_addr
));
496 zlog_debug (" External Route Tag %d", al
->e
[i
].route_tag
);
501 ospf_lsa_header_list_dump (struct stream
*s
, u_int16_t length
)
503 struct lsa_header
*lsa
;
505 zlog_debug (" # LSA Headers %d", length
/ OSPF_LSA_HEADER_SIZE
);
510 lsa
= (struct lsa_header
*) STREAM_PNT (s
);
511 ospf_lsa_header_dump (lsa
);
513 stream_forward_getp (s
, OSPF_LSA_HEADER_SIZE
);
514 length
-= OSPF_LSA_HEADER_SIZE
;
519 ospf_packet_db_desc_dump (struct stream
*s
, u_int16_t length
)
521 struct ospf_db_desc
*dd
;
526 gp
= stream_get_getp (s
);
527 dd
= (struct ospf_db_desc
*) STREAM_PNT (s
);
529 zlog_debug ("Database Description");
530 zlog_debug (" Interface MTU %d", ntohs (dd
->mtu
));
531 zlog_debug (" Options %d (%s)", dd
->options
,
532 ospf_options_dump (dd
->options
));
533 zlog_debug (" Flags %d (%s)", dd
->flags
,
534 ospf_dd_flags_dump (dd
->flags
, dd_flags
, sizeof dd_flags
));
535 zlog_debug (" Sequence Number 0x%08lx", (u_long
)ntohl (dd
->dd_seqnum
));
537 length
-= OSPF_HEADER_SIZE
+ OSPF_DB_DESC_MIN_SIZE
;
539 stream_forward_getp (s
, OSPF_DB_DESC_MIN_SIZE
);
541 ospf_lsa_header_list_dump (s
, length
);
543 stream_set_getp (s
, gp
);
547 ospf_packet_ls_req_dump (struct stream
*s
, u_int16_t length
)
551 struct in_addr ls_id
;
552 struct in_addr adv_router
;
554 sp
= stream_get_getp (s
);
556 length
-= OSPF_HEADER_SIZE
;
558 zlog_debug ("Link State Request");
559 zlog_debug (" # Requests %d", length
/ 12);
561 for (; length
> 0; length
-= 12)
563 ls_type
= stream_getl (s
);
564 ls_id
.s_addr
= stream_get_ipv4 (s
);
565 adv_router
.s_addr
= stream_get_ipv4 (s
);
567 zlog_debug (" LS type %d", ls_type
);
568 zlog_debug (" Link State ID %s", inet_ntoa (ls_id
));
569 zlog_debug (" Advertising Router %s",
570 inet_ntoa (adv_router
));
573 stream_set_getp (s
, sp
);
577 ospf_packet_ls_upd_dump (struct stream
*s
, u_int16_t length
)
580 struct lsa_header
*lsa
;
584 length
-= OSPF_HEADER_SIZE
;
586 sp
= stream_get_getp (s
);
588 count
= stream_getl (s
);
591 zlog_debug ("Link State Update");
592 zlog_debug (" # LSAs %d", count
);
594 while (length
> 0 && count
> 0)
596 if (length
< OSPF_HEADER_SIZE
|| length
% 4 != 0)
598 zlog_debug (" Remaining %d bytes; Incorrect length.", length
);
602 lsa
= (struct lsa_header
*) STREAM_PNT (s
);
603 lsa_len
= ntohs (lsa
->length
);
604 ospf_lsa_header_dump (lsa
);
608 case OSPF_ROUTER_LSA
:
609 ospf_router_lsa_dump (s
, length
);
611 case OSPF_NETWORK_LSA
:
612 ospf_network_lsa_dump (s
, length
);
614 case OSPF_SUMMARY_LSA
:
615 case OSPF_ASBR_SUMMARY_LSA
:
616 ospf_summary_lsa_dump (s
, length
);
618 case OSPF_AS_EXTERNAL_LSA
:
619 ospf_as_external_lsa_dump (s
, length
);
621 case OSPF_AS_NSSA_LSA
:
622 ospf_as_external_lsa_dump (s
, length
);
624 case OSPF_OPAQUE_LINK_LSA
:
625 case OSPF_OPAQUE_AREA_LSA
:
626 case OSPF_OPAQUE_AS_LSA
:
627 ospf_opaque_lsa_dump (s
, length
);
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
,
763 struct cmd_token
**argv
)
769 assert (argc
> arg_base
+ 0);
771 /* Check packet type. */
772 if (strncmp (argv
[arg_base
+ 0]->arg
, "h", 1) == 0)
773 type
= OSPF_DEBUG_HELLO
;
774 else if (strncmp (argv
[arg_base
+ 0]->arg
, "d", 1) == 0)
775 type
= OSPF_DEBUG_DB_DESC
;
776 else if (strncmp (argv
[arg_base
+ 0]->arg
, "ls-r", 4) == 0)
777 type
= OSPF_DEBUG_LS_REQ
;
778 else if (strncmp (argv
[arg_base
+ 0]->arg
, "ls-u", 4) == 0)
779 type
= OSPF_DEBUG_LS_UPD
;
780 else if (strncmp (argv
[arg_base
+ 0]->arg
, "ls-a", 4) == 0)
781 type
= OSPF_DEBUG_LS_ACK
;
782 else if (strncmp (argv
[arg_base
+ 0]->arg
, "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]->arg
, "s", 1) == 0)
793 flag
= OSPF_DEBUG_SEND
;
794 else if (strncmp (argv
[arg_base
+ 1]->arg
, "r", 1) == 0)
795 flag
= OSPF_DEBUG_RECV
;
796 else if (strncmp (argv
[arg_base
+ 1]->arg
, "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]->arg
, "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
);
818 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
819 * "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
820 * "Debugging functions\n"
821 * "OSPF information\n"
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 * "Packet received\n"
831 * "Detail Information\n"
833 * "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
834 * "Debugging functions\n"
835 * "OSPF information\n"
838 * "OSPF Database Description\n"
839 * "OSPF Link State Request\n"
840 * "OSPF Link State Update\n"
841 * "OSPF Link State Acknowledgment\n"
842 * "OSPF all packets\n"
844 * "Packet received\n"
845 * "Detail information\n"
848 DEFUN (debug_ospf_packet
,
849 debug_ospf_packet_all_cmd
,
850 "debug ospf packet <hello|dd|ls-request|ls-update|ls-ack|all>",
855 "OSPF Database Description\n"
856 "OSPF Link State Request\n"
857 "OSPF Link State Update\n"
858 "OSPF Link State Acknowledgment\n"
859 "OSPF all packets\n")
861 return (debug_ospf_packet_common(vty
, 0, argc
, argv
));
867 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
868 * "debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
869 * "Debugging functions\n"
870 * "OSPF information\n"
874 * "OSPF Database Description\n"
875 * "OSPF Link State Request\n"
876 * "OSPF Link State Update\n"
877 * "OSPF Link State Acknowledgment\n"
878 * "OSPF all packets\n"
880 * "Packet received\n"
881 * "Detail information\n"
883 * "debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
884 * "Debugging functions\n"
885 * "OSPF information\n"
889 * "OSPF Database Description\n"
890 * "OSPF Link State Request\n"
891 * "OSPF Link State Update\n"
892 * "OSPF Link State Acknowledgment\n"
893 * "OSPF all packets\n"
895 * "Packet received\n"
896 * "Detail Information\n"
899 DEFUN (debug_ospf_instance_packet
,
900 debug_ospf_instance_packet_all_cmd
,
901 "debug ospf (1-65535) packet <hello|dd|ls-request|ls-update|ls-ack|all>",
907 "OSPF Database Description\n"
908 "OSPF Link State Request\n"
909 "OSPF Link State Update\n"
910 "OSPF Link State Acknowledgment\n"
911 "OSPF all packets\n")
913 u_short instance
= 0;
915 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
916 if (!ospf_lookup_instance (instance
))
919 return (debug_ospf_packet_common(vty
, 1, argc
, argv
));
925 no_debug_ospf_packet_common (struct vty
*vty
, int arg_base
, int argc
,
926 struct cmd_token
**argv
)
932 assert (argc
> arg_base
+ 0);
934 /* Check packet type. */
935 if (strncmp (argv
[arg_base
+ 0]->arg
, "h", 1) == 0)
936 type
= OSPF_DEBUG_HELLO
;
937 else if (strncmp (argv
[arg_base
+ 0]->arg
, "d", 1) == 0)
938 type
= OSPF_DEBUG_DB_DESC
;
939 else if (strncmp (argv
[arg_base
+ 0]->arg
, "ls-r", 4) == 0)
940 type
= OSPF_DEBUG_LS_REQ
;
941 else if (strncmp (argv
[arg_base
+ 0]->arg
, "ls-u", 4) == 0)
942 type
= OSPF_DEBUG_LS_UPD
;
943 else if (strncmp (argv
[arg_base
+ 0]->arg
, "ls-a", 4) == 0)
944 type
= OSPF_DEBUG_LS_ACK
;
945 else if (strncmp (argv
[arg_base
+ 0]->arg
, "a", 1) == 0)
946 type
= OSPF_DEBUG_ALL
;
948 /* Default, both send and recv. */
949 if (argc
== arg_base
+ 1)
950 flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
953 if (argc
== arg_base
+ 2)
955 if (strncmp (argv
[arg_base
+ 1]->arg
, "s", 1) == 0)
956 flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_DETAIL
;
957 else if (strncmp (argv
[arg_base
+ 1]->arg
, "r", 1) == 0)
958 flag
= OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
959 else if (strncmp (argv
[arg_base
+ 1]->arg
, "d", 1) == 0)
960 flag
= OSPF_DEBUG_DETAIL
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
964 if (argc
== arg_base
+ 3)
965 if (strncmp (argv
[arg_base
+ 2]->arg
, "d", 1) == 0)
966 flag
= OSPF_DEBUG_DETAIL
;
968 for (i
= 0; i
< 5; i
++)
969 if (type
& (0x01 << i
))
971 if (vty
->node
== CONFIG_NODE
)
972 DEBUG_PACKET_OFF (i
, flag
);
974 TERM_DEBUG_PACKET_OFF (i
, flag
);
979 for (i = 0; i < 5; i++)
980 zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
988 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
989 * "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
991 * "Debugging functions\n"
992 * "OSPF information\n"
995 * "OSPF Database Description\n"
996 * "OSPF Link State Request\n"
997 * "OSPF Link State Update\n"
998 * "OSPF Link State Acknowledgment\n"
999 * "OSPF all packets\n"
1001 * "Packet received\n"
1002 * "Detail Information\n"
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"
1016 * "Packet received\n"
1017 * "Detail Information\n"
1020 DEFUN (no_debug_ospf_packet
,
1021 no_debug_ospf_packet_all_cmd
,
1022 "no debug ospf packet <hello|dd|ls-request|ls-update|ls-ack|all>",
1028 "OSPF Database Description\n"
1029 "OSPF Link State Request\n"
1030 "OSPF Link State Update\n"
1031 "OSPF Link State Acknowledgment\n"
1032 "OSPF all packets\n")
1034 return no_debug_ospf_packet_common(vty
, 0, argc
, argv
);
1040 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1041 * "no debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
1043 * "Debugging functions\n"
1044 * "OSPF information\n"
1048 * "OSPF Database Description\n"
1049 * "OSPF Link State Request\n"
1050 * "OSPF Link State Update\n"
1051 * "OSPF Link State Acknowledgment\n"
1052 * "OSPF all packets\n"
1054 * "Packet received\n"
1055 * "Detail Information\n"
1057 * "no debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
1059 * "Debugging functions\n"
1060 * "OSPF information\n"
1064 * "OSPF Database Description\n"
1065 * "OSPF Link State Request\n"
1066 * "OSPF Link State Update\n"
1067 * "OSPF Link State Acknowledgment\n"
1068 * "OSPF all packets\n"
1070 * "Packet received\n"
1071 * "Detail Information\n"
1074 DEFUN (no_debug_ospf_instance_packet
,
1075 no_debug_ospf_instance_packet_all_cmd
,
1076 "no debug ospf (1-65535) packet <hello|dd|ls-request|ls-update|ls-ack|all>",
1083 "OSPF Database Description\n"
1084 "OSPF Link State Request\n"
1085 "OSPF Link State Update\n"
1086 "OSPF Link State Acknowledgment\n"
1087 "OSPF all packets\n")
1089 u_short instance
= 0;
1091 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
1092 if (!ospf_lookup_instance (instance
))
1095 return (no_debug_ospf_packet_common(vty
, 1, argc
, argv
));
1102 debug_ospf_ism_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1104 if (vty
->node
== CONFIG_NODE
)
1106 if (argc
== arg_base
+ 0)
1107 DEBUG_ON (ism
, ISM
);
1108 else if (argc
== arg_base
+ 1)
1110 if (strncmp (argv
[arg_base
+ 0]->arg
, "s", 1) == 0)
1111 DEBUG_ON (ism
, ISM_STATUS
);
1112 else if (strncmp (argv
[arg_base
+ 0]->arg
, "e", 1) == 0)
1113 DEBUG_ON (ism
, ISM_EVENTS
);
1114 else if (strncmp (argv
[arg_base
+ 0]->arg
, "t", 1) == 0)
1115 DEBUG_ON (ism
, ISM_TIMERS
);
1122 if (argc
== arg_base
+ 0)
1123 TERM_DEBUG_ON (ism
, ISM
);
1124 else if (argc
== arg_base
+ 1)
1126 if (strncmp (argv
[arg_base
+ 0]->arg
, "s", 1) == 0)
1127 TERM_DEBUG_ON (ism
, ISM_STATUS
);
1128 else if (strncmp (argv
[arg_base
+ 0]->arg
, "e", 1) == 0)
1129 TERM_DEBUG_ON (ism
, ISM_EVENTS
);
1130 else if (strncmp (argv
[arg_base
+ 0]->arg
, "t", 1) == 0)
1131 TERM_DEBUG_ON (ism
, ISM_TIMERS
);
1138 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1139 * "debug ospf ism (status|events|timers)",
1142 * "OSPF Interface State Machine\n"
1143 * "ISM Status Information\n"
1144 * "ISM Event Information\n"
1145 * "ISM TImer Information\n"
1148 DEFUN (debug_ospf_ism
,
1153 "OSPF Interface State Machine\n")
1155 return debug_ospf_ism_common(vty
, 0, argc
, argv
);
1160 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1161 * "debug ospf <1-65535> ism (status|events|timers)",
1165 * "OSPF Interface State Machine\n"
1166 * "ISM Status Information\n"
1167 * "ISM Event Information\n"
1168 * "ISM TImer Information\n"
1171 DEFUN (debug_ospf_instance_ism
,
1172 debug_ospf_instance_ism_cmd
,
1173 "debug ospf (1-65535) ism",
1177 "OSPF Interface State Machine\n")
1179 u_short instance
= 0;
1181 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
1182 if (!ospf_lookup_instance (instance
))
1185 return debug_ospf_ism_common(vty
, 1, argc
, argv
);
1190 no_debug_ospf_ism_common(struct vty
*vty
, int arg_base
, int argc
,
1191 struct cmd_token
**argv
)
1193 if (vty
->node
== CONFIG_NODE
)
1195 if (argc
== arg_base
+ 0)
1196 DEBUG_OFF (ism
, ISM
);
1197 else if (argc
== arg_base
+ 1)
1199 if (strncmp (argv
[arg_base
+ 0]->arg
, "s", 1) == 0)
1200 DEBUG_OFF (ism
, ISM_STATUS
);
1201 else if (strncmp (argv
[arg_base
+ 0]->arg
, "e", 1) == 0)
1202 DEBUG_OFF (ism
, ISM_EVENTS
);
1203 else if (strncmp (argv
[arg_base
+ 0]->arg
, "t", 1) == 0)
1204 DEBUG_OFF (ism
, ISM_TIMERS
);
1210 if (argc
== arg_base
+ 0)
1211 TERM_DEBUG_OFF (ism
, ISM
);
1212 else if (argc
== arg_base
+ 1)
1214 if (strncmp (argv
[arg_base
+ 0]->arg
, "s", 1) == 0)
1215 TERM_DEBUG_OFF (ism
, ISM_STATUS
);
1216 else if (strncmp (argv
[arg_base
+ 0]->arg
, "e", 1) == 0)
1217 TERM_DEBUG_OFF (ism
, ISM_EVENTS
);
1218 else if (strncmp (argv
[arg_base
+ 0]->arg
, "t", 1) == 0)
1219 TERM_DEBUG_OFF (ism
, ISM_TIMERS
);
1226 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1227 * "no debug ospf ism (status|events|timers)",
1229 * "Debugging functions\n"
1230 * "OSPF information\n"
1231 * "OSPF Interface State Machine\n"
1232 * "ISM Status Information\n"
1233 * "ISM Event Information\n"
1234 * "ISM Timer Information\n"
1237 DEFUN (no_debug_ospf_ism
,
1238 no_debug_ospf_ism_cmd
,
1239 "no debug ospf ism",
1243 "OSPF Interface State Machine")
1245 return no_debug_ospf_ism_common(vty
, 0, argc
, argv
);
1250 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1251 * "no debug ospf <1-65535> ism (status|events|timers)",
1253 * "Debugging functions\n"
1254 * "OSPF information\n"
1256 * "OSPF Interface State Machine\n"
1257 * "ISM Status Information\n"
1258 * "ISM Event Information\n"
1259 * "ISM Timer Information\n"
1262 DEFUN (no_debug_ospf_instance_ism
,
1263 no_debug_ospf_instance_ism_cmd
,
1264 "no debug ospf (1-65535) ism",
1269 "OSPF Interface State Machine")
1271 u_short instance
= 0;
1273 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
1274 if (!ospf_lookup_instance (instance
))
1277 return no_debug_ospf_ism_common(vty
, 1, argc
, argv
);
1282 debug_ospf_nsm_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1284 if (vty
->node
== CONFIG_NODE
)
1286 if (argc
== arg_base
+ 0)
1287 DEBUG_ON (nsm
, NSM
);
1288 else if (argc
== arg_base
+ 1)
1290 if (strncmp (argv
[arg_base
+ 0]->arg
, "s", 1) == 0)
1291 DEBUG_ON (nsm
, NSM_STATUS
);
1292 else if (strncmp (argv
[arg_base
+ 0]->arg
, "e", 1) == 0)
1293 DEBUG_ON (nsm
, NSM_EVENTS
);
1294 else if (strncmp (argv
[arg_base
+ 0]->arg
, "t", 1) == 0)
1295 DEBUG_ON (nsm
, NSM_TIMERS
);
1302 if (argc
== arg_base
+ 0)
1303 TERM_DEBUG_ON (nsm
, NSM
);
1304 else if (argc
== arg_base
+ 1)
1306 if (strncmp (argv
[arg_base
+ 0]->arg
, "s", 1) == 0)
1307 TERM_DEBUG_ON (nsm
, NSM_STATUS
);
1308 else if (strncmp (argv
[arg_base
+ 0]->arg
, "e", 1) == 0)
1309 TERM_DEBUG_ON (nsm
, NSM_EVENTS
);
1310 else if (strncmp (argv
[arg_base
+ 0]->arg
, "t", 1) == 0)
1311 TERM_DEBUG_ON (nsm
, NSM_TIMERS
);
1318 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1319 * "debug ospf nsm (status|events|timers)",
1322 * "OSPF Neighbor State Machine\n"
1323 * "NSM Status Information\n"
1324 * "NSM Event Information\n"
1325 * "NSM Timer Information\n"
1328 DEFUN (debug_ospf_nsm
,
1333 "OSPF Neighbor State Machine\n")
1335 return debug_ospf_nsm_common (vty
, 0, argc
, argv
);
1340 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1341 * "debug ospf <1-65535> nsm (status|events|timers)",
1345 * "OSPF Neighbor State Machine\n"
1346 * "NSM Status Information\n"
1347 * "NSM Event Information\n"
1348 * "NSM Timer Information\n"
1351 DEFUN (debug_ospf_instance_nsm
,
1352 debug_ospf_instance_nsm_cmd
,
1353 "debug ospf (1-65535) nsm",
1357 "OSPF Neighbor State Machine\n")
1359 u_short instance
= 0;
1361 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
1362 if (!ospf_lookup_instance (instance
))
1365 return debug_ospf_nsm_common (vty
, 1, argc
, argv
);
1370 no_debug_ospf_nsm_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1372 if (vty
->node
== CONFIG_NODE
)
1374 if (argc
== arg_base
+ 0)
1375 DEBUG_OFF (nsm
, NSM
);
1376 else if (argc
== arg_base
+ 1)
1378 if (strncmp (argv
[arg_base
+ 0]->arg
, "s", 1) == 0)
1379 DEBUG_OFF (nsm
, NSM_STATUS
);
1380 else if (strncmp (argv
[arg_base
+ 0]->arg
, "e", 1) == 0)
1381 DEBUG_OFF (nsm
, NSM_EVENTS
);
1382 else if (strncmp (argv
[arg_base
+ 0]->arg
, "t", 1) == 0)
1383 DEBUG_OFF (nsm
, NSM_TIMERS
);
1390 if (argc
== arg_base
+ 0)
1391 TERM_DEBUG_OFF (nsm
, NSM
);
1392 else if (argc
== arg_base
+ 1)
1394 if (strncmp (argv
[arg_base
+ 0]->arg
, "s", 1) == 0)
1395 TERM_DEBUG_OFF (nsm
, NSM_STATUS
);
1396 else if (strncmp (argv
[arg_base
+ 0]->arg
, "e", 1) == 0)
1397 TERM_DEBUG_OFF (nsm
, NSM_EVENTS
);
1398 else if (strncmp (argv
[arg_base
+ 0]->arg
, "t", 1) == 0)
1399 TERM_DEBUG_OFF (nsm
, NSM_TIMERS
);
1406 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1407 * "no debug ospf nsm (status|events|timers)",
1409 * "Debugging functions\n"
1410 * "OSPF information\n"
1411 * "OSPF Interface State Machine\n"
1412 * "NSM Status Information\n"
1413 * "NSM Event Information\n"
1414 * "NSM Timer Information\n"
1417 DEFUN (no_debug_ospf_nsm
,
1418 no_debug_ospf_nsm_cmd
,
1419 "no debug ospf nsm",
1423 "OSPF Neighbor State Machine")
1425 return no_debug_ospf_nsm_common(vty
, 0, argc
, argv
);
1430 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
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"
1442 DEFUN (no_debug_ospf_instance_nsm
,
1443 no_debug_ospf_instance_nsm_cmd
,
1444 "no debug ospf (1-65535) nsm",
1449 "OSPF Neighbor State Machine")
1451 u_short instance
= 0;
1453 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
1454 if (!ospf_lookup_instance (instance
))
1457 return no_debug_ospf_nsm_common(vty
, 1, argc
, argv
);
1463 debug_ospf_lsa_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1465 if (vty
->node
== CONFIG_NODE
)
1467 if (argc
== arg_base
+ 0)
1468 DEBUG_ON (lsa
, LSA
);
1469 else if (argc
== arg_base
+ 1)
1471 if (strncmp (argv
[arg_base
+ 0]->arg
, "g", 1) == 0)
1472 DEBUG_ON (lsa
, LSA_GENERATE
);
1473 else if (strncmp (argv
[arg_base
+ 0]->arg
, "f", 1) == 0)
1474 DEBUG_ON (lsa
, LSA_FLOODING
);
1475 else if (strncmp (argv
[arg_base
+ 0]->arg
, "i", 1) == 0)
1476 DEBUG_ON (lsa
, LSA_INSTALL
);
1477 else if (strncmp (argv
[arg_base
+ 0]->arg
, "r", 1) == 0)
1478 DEBUG_ON (lsa
, LSA_REFRESH
);
1485 if (argc
== arg_base
+ 0)
1486 TERM_DEBUG_ON (lsa
, LSA
);
1487 else if (argc
== arg_base
+ 1)
1489 if (strncmp (argv
[arg_base
+ 0]->arg
, "g", 1) == 0)
1490 TERM_DEBUG_ON (lsa
, LSA_GENERATE
);
1491 else if (strncmp (argv
[arg_base
+ 0]->arg
, "f", 1) == 0)
1492 TERM_DEBUG_ON (lsa
, LSA_FLOODING
);
1493 else if (strncmp (argv
[arg_base
+ 0]->arg
, "i", 1) == 0)
1494 TERM_DEBUG_ON (lsa
, LSA_INSTALL
);
1495 else if (strncmp (argv
[arg_base
+ 0]->arg
, "r", 1) == 0)
1496 TERM_DEBUG_ON (lsa
, LSA_REFRESH
);
1503 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1504 * "debug ospf lsa (generate|flooding|install|refresh)",
1507 * "OSPF Link State Advertisement\n"
1508 * "LSA Generation\n"
1510 * "LSA Install/Delete\n"
1514 DEFUN (debug_ospf_lsa
,
1519 "OSPF Link State Advertisement\n")
1521 return debug_ospf_lsa_common(vty
, 0, argc
, argv
);
1526 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1527 * "debug ospf <1-65535> lsa (generate|flooding|install|refresh)",
1531 * "OSPF Link State Advertisement\n"
1532 * "LSA Generation\n"
1534 * "LSA Install/Delete\n"
1538 DEFUN (debug_ospf_instance_lsa
,
1539 debug_ospf_instance_lsa_cmd
,
1540 "debug ospf (1-65535) lsa",
1544 "OSPF Link State Advertisement\n")
1546 u_short instance
= 0;
1548 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
1549 if (!ospf_lookup_instance (instance
))
1552 return debug_ospf_lsa_common(vty
, 1, argc
, argv
);
1557 no_debug_ospf_lsa_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1559 if (vty
->node
== CONFIG_NODE
)
1561 if (argc
== arg_base
+ 0)
1562 DEBUG_OFF (lsa
, LSA
);
1563 else if (argc
== arg_base
+ 1)
1565 if (strncmp (argv
[arg_base
+ 0]->arg
, "g", 1) == 0)
1566 DEBUG_OFF (lsa
, LSA_GENERATE
);
1567 else if (strncmp (argv
[arg_base
+ 0]->arg
, "f", 1) == 0)
1568 DEBUG_OFF (lsa
, LSA_FLOODING
);
1569 else if (strncmp (argv
[arg_base
+ 0]->arg
, "i", 1) == 0)
1570 DEBUG_OFF (lsa
, LSA_INSTALL
);
1571 else if (strncmp (argv
[arg_base
+ 0]->arg
, "r", 1) == 0)
1572 DEBUG_OFF (lsa
, LSA_REFRESH
);
1579 if (argc
== arg_base
+ 0)
1580 TERM_DEBUG_OFF (lsa
, LSA
);
1581 else if (argc
== arg_base
+ 1)
1583 if (strncmp (argv
[arg_base
+ 0]->arg
, "g", 1) == 0)
1584 TERM_DEBUG_OFF (lsa
, LSA_GENERATE
);
1585 else if (strncmp (argv
[arg_base
+ 0]->arg
, "f", 1) == 0)
1586 TERM_DEBUG_OFF (lsa
, LSA_FLOODING
);
1587 else if (strncmp (argv
[arg_base
+ 0]->arg
, "i", 1) == 0)
1588 TERM_DEBUG_OFF (lsa
, LSA_INSTALL
);
1589 else if (strncmp (argv
[arg_base
+ 0]->arg
, "r", 1) == 0)
1590 TERM_DEBUG_OFF (lsa
, LSA_REFRESH
);
1597 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1598 * "no debug ospf lsa (generate|flooding|install|refresh)",
1602 * "OSPF Link State Advertisement\n"
1603 * "LSA Generation\n"
1605 * "LSA Install/Delete\n"
1609 DEFUN (no_debug_ospf_lsa
,
1610 no_debug_ospf_lsa_cmd
,
1611 "no debug ospf lsa",
1615 "OSPF Link State Advertisement\n")
1617 return no_debug_ospf_lsa_common (vty
, 0, argc
, argv
);
1622 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1623 * "no debug ospf <1-65535> lsa (generate|flooding|install|refresh)",
1628 * "OSPF Link State Advertisement\n"
1629 * "LSA Generation\n"
1631 * "LSA Install/Delete\n"
1635 DEFUN (no_debug_ospf_instance_lsa
,
1636 no_debug_ospf_instance_lsa_cmd
,
1637 "no debug ospf (1-65535) lsa",
1642 "OSPF Link State Advertisement\n")
1644 u_short instance
= 0;
1646 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
1647 if (!ospf_lookup_instance (instance
))
1650 return no_debug_ospf_lsa_common (vty
, 1, argc
, argv
);
1656 debug_ospf_zebra_common (struct vty
*vty
, int arg_base
, int argc
, struct cmd_token
**argv
)
1658 if (vty
->node
== CONFIG_NODE
)
1660 if (argc
== arg_base
+ 0)
1661 DEBUG_ON (zebra
, ZEBRA
);
1662 else if (argc
== arg_base
+ 1)
1664 if (strncmp (argv
[arg_base
+ 0]->arg
, "i", 1) == 0)
1665 DEBUG_ON (zebra
, ZEBRA_INTERFACE
);
1666 else if (strncmp (argv
[arg_base
+ 0]->arg
, "r", 1) == 0)
1667 DEBUG_ON (zebra
, ZEBRA_REDISTRIBUTE
);
1674 if (argc
== arg_base
+ 0)
1675 TERM_DEBUG_ON (zebra
, ZEBRA
);
1676 else if (argc
== arg_base
+ 1)
1678 if (strncmp (argv
[arg_base
+ 0]->arg
, "i", 1) == 0)
1679 TERM_DEBUG_ON (zebra
, ZEBRA_INTERFACE
);
1680 else if (strncmp (argv
[arg_base
+ 0]->arg
, "r", 1) == 0)
1681 TERM_DEBUG_ON (zebra
, ZEBRA_REDISTRIBUTE
);
1688 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1689 * "debug ospf zebra (interface|redistribute)",
1692 * "OSPF Zebra information\n"
1693 * "Zebra interface\n"
1694 * "Zebra redistribute\n"
1697 DEFUN (debug_ospf_zebra
,
1698 debug_ospf_zebra_cmd
,
1702 "OSPF Zebra information\n")
1704 return debug_ospf_zebra_common(vty
, 0, argc
, argv
);
1709 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1710 * "debug ospf <1-65535> zebra (interface|redistribute)",
1714 * "OSPF Zebra information\n"
1715 * "Zebra interface\n"
1716 * "Zebra redistribute\n"
1719 DEFUN (debug_ospf_instance_zebra
,
1720 debug_ospf_instance_zebra_cmd
,
1721 "debug ospf (1-65535) zebra",
1725 "OSPF Zebra information\n")
1727 u_short instance
= 0;
1729 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
1730 if (!ospf_lookup_instance (instance
))
1733 return debug_ospf_zebra_common(vty
, 1, argc
, argv
);
1738 no_debug_ospf_zebra_common(struct vty
*vty
, int arg_base
, int argc
,
1739 struct cmd_token
**argv
)
1741 if (vty
->node
== CONFIG_NODE
)
1743 if (argc
== arg_base
+ 0)
1744 DEBUG_OFF (zebra
, ZEBRA
);
1745 else if (argc
== arg_base
+ 1)
1747 if (strncmp (argv
[arg_base
+ 0]->arg
, "i", 1) == 0)
1748 DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1749 else if (strncmp (argv
[arg_base
+ 0]->arg
, "r", 1) == 0)
1750 DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1757 if (argc
== arg_base
+ 0)
1758 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1759 else if (argc
== arg_base
+ 1)
1761 if (strncmp (argv
[arg_base
+ 0]->arg
, "i", 1) == 0)
1762 TERM_DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
1763 else if (strncmp (argv
[arg_base
+ 0]->arg
, "r", 1) == 0)
1764 TERM_DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
1771 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1772 * "no debug ospf zebra (interface|redistribute)",
1776 * "OSPF Zebra information\n"
1777 * "Zebra interface\n"
1778 * "Zebra redistribute\n"
1781 DEFUN (no_debug_ospf_zebra
,
1782 no_debug_ospf_zebra_cmd
,
1783 "no debug ospf zebra",
1787 "OSPF Zebra information\n")
1789 return no_debug_ospf_zebra_common(vty
, 0, argc
, argv
);
1794 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
1795 * "no debug ospf <1-65535> zebra (interface|redistribute)",
1800 * "OSPF Zebra information\n"
1801 * "Zebra interface\n"
1802 * "Zebra redistribute\n"
1805 DEFUN (no_debug_ospf_instance_zebra
,
1806 no_debug_ospf_instance_zebra_cmd
,
1807 "no debug ospf (1-65535) zebra",
1812 "OSPF Zebra information\n")
1814 u_short instance
= 0;
1816 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
1817 if (!ospf_lookup_instance (instance
))
1820 return no_debug_ospf_zebra_common(vty
, 1, argc
, argv
);
1825 DEFUN (debug_ospf_event
,
1826 debug_ospf_event_cmd
,
1830 "OSPF event information\n")
1832 if (vty
->node
== CONFIG_NODE
)
1833 CONF_DEBUG_ON (event
, EVENT
);
1834 TERM_DEBUG_ON (event
, EVENT
);
1838 DEFUN (no_debug_ospf_event
,
1839 no_debug_ospf_event_cmd
,
1840 "no debug ospf event",
1844 "OSPF event information\n")
1846 if (vty
->node
== CONFIG_NODE
)
1847 CONF_DEBUG_OFF (event
, EVENT
);
1848 TERM_DEBUG_OFF (event
, EVENT
);
1852 DEFUN (debug_ospf_instance_event
,
1853 debug_ospf_instance_event_cmd
,
1854 "debug ospf (1-65535) event",
1858 "OSPF event information\n")
1860 u_short instance
= 0;
1862 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
1863 if (!ospf_lookup_instance (instance
))
1866 if (vty
->node
== CONFIG_NODE
)
1867 CONF_DEBUG_ON (event
, EVENT
);
1868 TERM_DEBUG_ON (event
, EVENT
);
1872 DEFUN (no_debug_ospf_instance_event
,
1873 no_debug_ospf_instance_event_cmd
,
1874 "no debug ospf (1-65535) event",
1879 "OSPF event information\n")
1881 u_short instance
= 0;
1883 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
1884 if (!ospf_lookup_instance (instance
))
1887 if (vty
->node
== CONFIG_NODE
)
1888 CONF_DEBUG_OFF (event
, EVENT
);
1889 TERM_DEBUG_OFF (event
, EVENT
);
1893 DEFUN (debug_ospf_nssa
,
1894 debug_ospf_nssa_cmd
,
1898 "OSPF nssa information\n")
1900 if (vty
->node
== CONFIG_NODE
)
1901 CONF_DEBUG_ON (nssa
, NSSA
);
1902 TERM_DEBUG_ON (nssa
, NSSA
);
1906 DEFUN (no_debug_ospf_nssa
,
1907 no_debug_ospf_nssa_cmd
,
1908 "no debug ospf nssa",
1912 "OSPF nssa information\n")
1914 if (vty
->node
== CONFIG_NODE
)
1915 CONF_DEBUG_OFF (nssa
, NSSA
);
1916 TERM_DEBUG_OFF (nssa
, NSSA
);
1920 DEFUN (debug_ospf_instance_nssa
,
1921 debug_ospf_instance_nssa_cmd
,
1922 "debug ospf (1-65535) nssa",
1926 "OSPF nssa information\n")
1928 u_short instance
= 0;
1930 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
1931 if (!ospf_lookup_instance (instance
))
1934 if (vty
->node
== CONFIG_NODE
)
1935 CONF_DEBUG_ON (nssa
, NSSA
);
1936 TERM_DEBUG_ON (nssa
, NSSA
);
1940 DEFUN (no_debug_ospf_instance_nssa
,
1941 no_debug_ospf_instance_nssa_cmd
,
1942 "no debug ospf (1-65535) nssa",
1947 "OSPF nssa information\n")
1949 u_short instance
= 0;
1951 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
1952 if (!ospf_lookup_instance (instance
))
1955 if (vty
->node
== CONFIG_NODE
)
1956 CONF_DEBUG_OFF (nssa
, NSSA
);
1957 TERM_DEBUG_OFF (nssa
, NSSA
);
1961 DEFUN (debug_ospf_te
,
1966 "OSPF-TE information\n")
1968 if (vty
->node
== CONFIG_NODE
)
1969 CONF_DEBUG_ON (te
, TE
);
1970 TERM_DEBUG_ON (te
, TE
);
1974 DEFUN (no_debug_ospf_te
,
1975 no_debug_ospf_te_cmd
,
1980 "OSPF-TE information\n")
1982 if (vty
->node
== CONFIG_NODE
)
1983 CONF_DEBUG_OFF (te
, TE
);
1984 TERM_DEBUG_OFF (te
, TE
);
1988 DEFUN (no_debug_ospf
,
1995 int flag
= OSPF_DEBUG_SEND
| OSPF_DEBUG_RECV
| OSPF_DEBUG_DETAIL
;
1998 if (vty
->node
== CONFIG_NODE
)
2000 CONF_DEBUG_OFF (event
, EVENT
);
2001 CONF_DEBUG_OFF (nssa
, NSSA
);
2002 DEBUG_OFF (ism
, ISM_EVENTS
);
2003 DEBUG_OFF (ism
, ISM_STATUS
);
2004 DEBUG_OFF (ism
, ISM_TIMERS
);
2005 DEBUG_OFF (lsa
, LSA
);
2006 DEBUG_OFF (lsa
, LSA_FLOODING
);
2007 DEBUG_OFF (lsa
, LSA_GENERATE
);
2008 DEBUG_OFF (lsa
, LSA_INSTALL
);
2009 DEBUG_OFF (lsa
, LSA_REFRESH
);
2010 DEBUG_OFF (nsm
, NSM
);
2011 DEBUG_OFF (nsm
, NSM_EVENTS
);
2012 DEBUG_OFF (nsm
, NSM_STATUS
);
2013 DEBUG_OFF (nsm
, NSM_TIMERS
);
2014 DEBUG_OFF (zebra
, ZEBRA
);
2015 DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
2016 DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
2018 for (i
= 0; i
< 5; i
++)
2019 DEBUG_PACKET_OFF (i
, flag
);
2022 for (i
= 0; i
< 5; i
++)
2023 TERM_DEBUG_PACKET_OFF (i
, flag
);
2025 TERM_DEBUG_OFF (event
, EVENT
);
2026 TERM_DEBUG_OFF (ism
, ISM
);
2027 TERM_DEBUG_OFF (ism
, ISM_EVENTS
);
2028 TERM_DEBUG_OFF (ism
, ISM_STATUS
);
2029 TERM_DEBUG_OFF (ism
, ISM_TIMERS
);
2030 TERM_DEBUG_OFF (lsa
, LSA
);
2031 TERM_DEBUG_OFF (lsa
, LSA_FLOODING
);
2032 TERM_DEBUG_OFF (lsa
, LSA_GENERATE
);
2033 TERM_DEBUG_OFF (lsa
, LSA_INSTALL
);
2034 TERM_DEBUG_OFF (lsa
, LSA_REFRESH
);
2035 TERM_DEBUG_OFF (nsm
, NSM
);
2036 TERM_DEBUG_OFF (nsm
, NSM_EVENTS
);
2037 TERM_DEBUG_OFF (nsm
, NSM_STATUS
);
2038 TERM_DEBUG_OFF (nsm
, NSM_TIMERS
);
2039 TERM_DEBUG_OFF (nssa
, NSSA
);
2040 TERM_DEBUG_OFF (zebra
, ZEBRA
);
2041 TERM_DEBUG_OFF (zebra
, ZEBRA_INTERFACE
);
2042 TERM_DEBUG_OFF (zebra
, ZEBRA_REDISTRIBUTE
);
2048 show_debugging_ospf_common (struct vty
*vty
, struct ospf
*ospf
)
2053 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
2054 VTY_NEWLINE
, VTY_NEWLINE
);
2056 vty_out (vty
, "OSPF debugging status:%s", VTY_NEWLINE
);
2058 /* Show debug status for events. */
2059 if (IS_DEBUG_OSPF(event
,EVENT
))
2060 vty_out (vty
, " OSPF event debugging is on%s", VTY_NEWLINE
);
2062 /* Show debug status for ISM. */
2063 if (IS_DEBUG_OSPF (ism
, ISM
) == OSPF_DEBUG_ISM
)
2064 vty_out (vty
, " OSPF ISM debugging is on%s", VTY_NEWLINE
);
2067 if (IS_DEBUG_OSPF (ism
, ISM_STATUS
))
2068 vty_out (vty
, " OSPF ISM status debugging is on%s", VTY_NEWLINE
);
2069 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
2070 vty_out (vty
, " OSPF ISM event debugging is on%s", VTY_NEWLINE
);
2071 if (IS_DEBUG_OSPF (ism
, ISM_TIMERS
))
2072 vty_out (vty
, " OSPF ISM timer debugging is on%s", VTY_NEWLINE
);
2075 /* Show debug status for NSM. */
2076 if (IS_DEBUG_OSPF (nsm
, NSM
) == OSPF_DEBUG_NSM
)
2077 vty_out (vty
, " OSPF NSM debugging is on%s", VTY_NEWLINE
);
2080 if (IS_DEBUG_OSPF (nsm
, NSM_STATUS
))
2081 vty_out (vty
, " OSPF NSM status debugging is on%s", VTY_NEWLINE
);
2082 if (IS_DEBUG_OSPF (nsm
, NSM_EVENTS
))
2083 vty_out (vty
, " OSPF NSM event debugging is on%s", VTY_NEWLINE
);
2084 if (IS_DEBUG_OSPF (nsm
, NSM_TIMERS
))
2085 vty_out (vty
, " OSPF NSM timer debugging is on%s", VTY_NEWLINE
);
2088 /* Show debug status for OSPF Packets. */
2089 for (i
= 0; i
< 5; i
++)
2090 if (IS_DEBUG_OSPF_PACKET (i
, SEND
) && IS_DEBUG_OSPF_PACKET (i
, RECV
))
2092 vty_out (vty
, " OSPF packet %s%s debugging is on%s",
2093 LOOKUP (ospf_packet_type_str
, i
+ 1),
2094 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
2099 if (IS_DEBUG_OSPF_PACKET (i
, SEND
))
2100 vty_out (vty
, " OSPF packet %s send%s debugging is on%s",
2101 LOOKUP (ospf_packet_type_str
, i
+ 1),
2102 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
2104 if (IS_DEBUG_OSPF_PACKET (i
, RECV
))
2105 vty_out (vty
, " OSPF packet %s receive%s debugging is on%s",
2106 LOOKUP (ospf_packet_type_str
, i
+ 1),
2107 IS_DEBUG_OSPF_PACKET (i
, DETAIL
) ? " detail" : "",
2111 /* Show debug status for OSPF LSAs. */
2112 if (IS_DEBUG_OSPF (lsa
, LSA
) == OSPF_DEBUG_LSA
)
2113 vty_out (vty
, " OSPF LSA debugging is on%s", VTY_NEWLINE
);
2116 if (IS_DEBUG_OSPF (lsa
, LSA_GENERATE
))
2117 vty_out (vty
, " OSPF LSA generation debugging is on%s", VTY_NEWLINE
);
2118 if (IS_DEBUG_OSPF (lsa
, LSA_FLOODING
))
2119 vty_out (vty
, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE
);
2120 if (IS_DEBUG_OSPF (lsa
, LSA_INSTALL
))
2121 vty_out (vty
, " OSPF LSA install debugging is on%s", VTY_NEWLINE
);
2122 if (IS_DEBUG_OSPF (lsa
, LSA_REFRESH
))
2123 vty_out (vty
, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE
);
2126 /* Show debug status for Zebra. */
2127 if (IS_DEBUG_OSPF (zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
2128 vty_out (vty
, " OSPF Zebra debugging is on%s", VTY_NEWLINE
);
2131 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
2132 vty_out (vty
, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE
);
2133 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
2134 vty_out (vty
, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE
);
2137 /* Show debug status for NSSA. */
2138 if (IS_DEBUG_OSPF (nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
2139 vty_out (vty
, " OSPF NSSA debugging is on%s", VTY_NEWLINE
);
2141 vty_out (vty
, "%s", VTY_NEWLINE
);
2146 DEFUN (show_debugging_ospf
,
2147 show_debugging_ospf_cmd
,
2148 "show debugging ospf",
2155 if ((ospf
= ospf_lookup()) == NULL
)
2158 return show_debugging_ospf_common(vty
, ospf
);
2161 DEFUN (show_debugging_ospf_instance
,
2162 show_debugging_ospf_instance_cmd
,
2163 "show debugging ospf (1-65535)",
2170 u_short instance
= 0;
2172 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
2173 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
2176 return show_debugging_ospf_common(vty
, ospf
);
2180 static struct cmd_node debug_node
=
2188 config_write_debug (struct vty
*vty
)
2193 const char *type_str
[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
2194 const char *detail_str
[] = {"", " send", " recv", "", " detail",
2195 " send detail", " recv detail", " detail"};
2199 memset (str
, 0, 16);
2201 if ((ospf
= ospf_lookup()) == NULL
)
2205 sprintf(str
, " %d", ospf
->instance
);
2207 /* debug ospf ism (status|events|timers). */
2208 if (IS_CONF_DEBUG_OSPF (ism
, ISM
) == OSPF_DEBUG_ISM
)
2209 vty_out (vty
, "debug ospf%s ism%s", str
, VTY_NEWLINE
);
2212 if (IS_CONF_DEBUG_OSPF (ism
, ISM_STATUS
))
2213 vty_out (vty
, "debug ospf%s ism status%s", str
, VTY_NEWLINE
);
2214 if (IS_CONF_DEBUG_OSPF (ism
, ISM_EVENTS
))
2215 vty_out (vty
, "debug ospf%s ism event%s", str
, VTY_NEWLINE
);
2216 if (IS_CONF_DEBUG_OSPF (ism
, ISM_TIMERS
))
2217 vty_out (vty
, "debug ospf%s ism timer%s", str
, VTY_NEWLINE
);
2220 /* debug ospf nsm (status|events|timers). */
2221 if (IS_CONF_DEBUG_OSPF (nsm
, NSM
) == OSPF_DEBUG_NSM
)
2222 vty_out (vty
, "debug ospf%s nsm%s", str
, VTY_NEWLINE
);
2225 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_STATUS
))
2226 vty_out (vty
, "debug ospf%s nsm status%s", str
, VTY_NEWLINE
);
2227 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_EVENTS
))
2228 vty_out (vty
, "debug ospf%s nsm event%s", str
, VTY_NEWLINE
);
2229 if (IS_CONF_DEBUG_OSPF (nsm
, NSM_TIMERS
))
2230 vty_out (vty
, "debug ospf%s nsm timer%s", str
, VTY_NEWLINE
);
2233 /* debug ospf lsa (generate|flooding|install|refresh). */
2234 if (IS_CONF_DEBUG_OSPF (lsa
, LSA
) == OSPF_DEBUG_LSA
)
2235 vty_out (vty
, "debug ospf%s lsa%s", str
, VTY_NEWLINE
);
2238 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_GENERATE
))
2239 vty_out (vty
, "debug ospf%s lsa generate%s", str
, VTY_NEWLINE
);
2240 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_FLOODING
))
2241 vty_out (vty
, "debug ospf%s lsa flooding%s", str
, VTY_NEWLINE
);
2242 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_INSTALL
))
2243 vty_out (vty
, "debug ospf%s lsa install%s", str
, VTY_NEWLINE
);
2244 if (IS_CONF_DEBUG_OSPF (lsa
, LSA_REFRESH
))
2245 vty_out (vty
, "debug ospf%s lsa refresh%s", str
, VTY_NEWLINE
);
2250 /* debug ospf zebra (interface|redistribute). */
2251 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA
) == OSPF_DEBUG_ZEBRA
)
2252 vty_out (vty
, "debug ospf%s zebra%s", str
, VTY_NEWLINE
);
2255 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
2256 vty_out (vty
, "debug ospf%s zebra interface%s", str
, VTY_NEWLINE
);
2257 if (IS_CONF_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
2258 vty_out (vty
, "debug ospf%s zebra redistribute%s", str
, VTY_NEWLINE
);
2263 /* debug ospf event. */
2264 if (IS_CONF_DEBUG_OSPF (event
, EVENT
) == OSPF_DEBUG_EVENT
)
2266 vty_out (vty
, "debug ospf%s event%s", str
, VTY_NEWLINE
);
2270 /* debug ospf nssa. */
2271 if (IS_CONF_DEBUG_OSPF (nssa
, NSSA
) == OSPF_DEBUG_NSSA
)
2273 vty_out (vty
, "debug ospf%s nssa%s", str
, VTY_NEWLINE
);
2277 /* debug ospf packet all detail. */
2278 r
= OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
;
2279 for (i
= 0; i
< 5; i
++)
2280 r
&= conf_debug_ospf_packet
[i
] & (OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
);
2281 if (r
== (OSPF_DEBUG_SEND_RECV
|OSPF_DEBUG_DETAIL
))
2283 vty_out (vty
, "debug ospf%s packet all detail%s", str
, VTY_NEWLINE
);
2287 /* debug ospf packet all. */
2288 r
= OSPF_DEBUG_SEND_RECV
;
2289 for (i
= 0; i
< 5; i
++)
2290 r
&= conf_debug_ospf_packet
[i
] & OSPF_DEBUG_SEND_RECV
;
2291 if (r
== OSPF_DEBUG_SEND_RECV
)
2293 vty_out (vty
, "debug ospf%s packet all%s", str
, VTY_NEWLINE
);
2294 for (i
= 0; i
< 5; i
++)
2295 if (conf_debug_ospf_packet
[i
] & OSPF_DEBUG_DETAIL
)
2296 vty_out (vty
, "debug ospf%s packet %s detail%s", str
,
2302 /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
2303 (send|recv) (detail). */
2304 for (i
= 0; i
< 5; i
++)
2306 if (conf_debug_ospf_packet
[i
] == 0)
2309 vty_out (vty
, "debug ospf%s packet %s%s%s", str
,
2310 type_str
[i
], detail_str
[conf_debug_ospf_packet
[i
]],
2318 /* Initialize debug commands. */
2322 install_node (&debug_node
, config_write_debug
);
2324 install_element (ENABLE_NODE
, &show_debugging_ospf_cmd
);
2325 install_element (ENABLE_NODE
, &debug_ospf_packet_all_cmd
);
2326 install_element (ENABLE_NODE
, &debug_ospf_ism_cmd
);
2327 install_element (ENABLE_NODE
, &debug_ospf_nsm_cmd
);
2328 install_element (ENABLE_NODE
, &debug_ospf_lsa_cmd
);
2329 install_element (ENABLE_NODE
, &debug_ospf_zebra_cmd
);
2330 install_element (ENABLE_NODE
, &debug_ospf_event_cmd
);
2331 install_element (ENABLE_NODE
, &debug_ospf_nssa_cmd
);
2332 install_element (ENABLE_NODE
, &debug_ospf_te_cmd
);
2333 install_element (ENABLE_NODE
, &no_debug_ospf_packet_all_cmd
);
2334 install_element (ENABLE_NODE
, &no_debug_ospf_ism_cmd
);
2335 install_element (ENABLE_NODE
, &no_debug_ospf_nsm_cmd
);
2336 install_element (ENABLE_NODE
, &no_debug_ospf_lsa_cmd
);
2337 install_element (ENABLE_NODE
, &no_debug_ospf_zebra_cmd
);
2338 install_element (ENABLE_NODE
, &no_debug_ospf_event_cmd
);
2339 install_element (ENABLE_NODE
, &no_debug_ospf_nssa_cmd
);
2340 install_element (ENABLE_NODE
, &no_debug_ospf_te_cmd
);
2342 install_element (ENABLE_NODE
, &show_debugging_ospf_instance_cmd
);
2343 install_element (ENABLE_NODE
, &debug_ospf_instance_packet_all_cmd
);
2344 install_element (ENABLE_NODE
, &debug_ospf_instance_ism_cmd
);
2345 install_element (ENABLE_NODE
, &debug_ospf_instance_nsm_cmd
);
2346 install_element (ENABLE_NODE
, &debug_ospf_instance_lsa_cmd
);
2347 install_element (ENABLE_NODE
, &debug_ospf_instance_zebra_cmd
);
2348 install_element (ENABLE_NODE
, &debug_ospf_instance_event_cmd
);
2349 install_element (ENABLE_NODE
, &debug_ospf_instance_nssa_cmd
);
2350 install_element (ENABLE_NODE
, &no_debug_ospf_instance_packet_all_cmd
);
2351 install_element (ENABLE_NODE
, &no_debug_ospf_instance_ism_cmd
);
2352 install_element (ENABLE_NODE
, &no_debug_ospf_instance_nsm_cmd
);
2353 install_element (ENABLE_NODE
, &no_debug_ospf_instance_lsa_cmd
);
2354 install_element (ENABLE_NODE
, &no_debug_ospf_instance_zebra_cmd
);
2355 install_element (ENABLE_NODE
, &no_debug_ospf_instance_event_cmd
);
2356 install_element (ENABLE_NODE
, &no_debug_ospf_instance_nssa_cmd
);
2357 install_element (ENABLE_NODE
, &no_debug_ospf_cmd
);
2359 install_element (CONFIG_NODE
, &debug_ospf_packet_all_cmd
);
2360 install_element (CONFIG_NODE
, &debug_ospf_ism_cmd
);
2361 install_element (CONFIG_NODE
, &debug_ospf_nsm_cmd
);
2362 install_element (CONFIG_NODE
, &debug_ospf_lsa_cmd
);
2363 install_element (CONFIG_NODE
, &debug_ospf_zebra_cmd
);
2364 install_element (CONFIG_NODE
, &debug_ospf_event_cmd
);
2365 install_element (CONFIG_NODE
, &debug_ospf_nssa_cmd
);
2366 install_element (CONFIG_NODE
, &debug_ospf_te_cmd
);
2367 install_element (CONFIG_NODE
, &no_debug_ospf_packet_all_cmd
);
2368 install_element (CONFIG_NODE
, &no_debug_ospf_ism_cmd
);
2369 install_element (CONFIG_NODE
, &no_debug_ospf_nsm_cmd
);
2370 install_element (CONFIG_NODE
, &no_debug_ospf_lsa_cmd
);
2371 install_element (CONFIG_NODE
, &no_debug_ospf_zebra_cmd
);
2372 install_element (CONFIG_NODE
, &no_debug_ospf_event_cmd
);
2373 install_element (CONFIG_NODE
, &no_debug_ospf_nssa_cmd
);
2374 install_element (CONFIG_NODE
, &no_debug_ospf_te_cmd
);
2376 install_element (CONFIG_NODE
, &debug_ospf_instance_packet_all_cmd
);
2377 install_element (CONFIG_NODE
, &debug_ospf_instance_ism_cmd
);
2378 install_element (CONFIG_NODE
, &debug_ospf_instance_nsm_cmd
);
2379 install_element (CONFIG_NODE
, &debug_ospf_instance_lsa_cmd
);
2380 install_element (CONFIG_NODE
, &debug_ospf_instance_zebra_cmd
);
2381 install_element (CONFIG_NODE
, &debug_ospf_instance_event_cmd
);
2382 install_element (CONFIG_NODE
, &debug_ospf_instance_nssa_cmd
);
2383 install_element (CONFIG_NODE
, &no_debug_ospf_instance_packet_all_cmd
);
2384 install_element (CONFIG_NODE
, &no_debug_ospf_instance_ism_cmd
);
2385 install_element (CONFIG_NODE
, &no_debug_ospf_instance_nsm_cmd
);
2386 install_element (CONFIG_NODE
, &no_debug_ospf_instance_lsa_cmd
);
2387 install_element (CONFIG_NODE
, &no_debug_ospf_instance_zebra_cmd
);
2388 install_element (CONFIG_NODE
, &no_debug_ospf_instance_event_cmd
);
2389 install_element (CONFIG_NODE
, &no_debug_ospf_instance_nssa_cmd
);
2390 install_element (CONFIG_NODE
, &no_debug_ospf_cmd
);