2 * Zebra debug related function
3 * Copyright (C) 1999 Kunihiro Ishiguro
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.
27 /* For debug statement. */
28 unsigned long zebra_debug_event
;
29 unsigned long zebra_debug_packet
;
30 unsigned long zebra_debug_kernel
;
31 unsigned long zebra_debug_rib
;
33 DEFUN (show_debugging_zebra
,
34 show_debugging_zebra_cmd
,
35 "show debugging zebra",
37 "Zebra configuration\n"
38 "Debugging information\n")
40 vty_out (vty
, "Zebra debugging status:%s", VTY_NEWLINE
);
42 if (IS_ZEBRA_DEBUG_EVENT
)
43 vty_out (vty
, " Zebra event debugging is on%s", VTY_NEWLINE
);
45 if (IS_ZEBRA_DEBUG_PACKET
)
47 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
)
49 vty_out (vty
, " Zebra packet%s debugging is on%s",
50 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
55 if (IS_ZEBRA_DEBUG_SEND
)
56 vty_out (vty
, " Zebra packet send%s debugging is on%s",
57 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
60 vty_out (vty
, " Zebra packet receive%s debugging is on%s",
61 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
66 if (IS_ZEBRA_DEBUG_KERNEL
)
67 vty_out (vty
, " Zebra kernel debugging is on%s", VTY_NEWLINE
);
69 if (IS_ZEBRA_DEBUG_RIB
)
70 vty_out (vty
, " Zebra RIB debugging is on%s", VTY_NEWLINE
);
71 if (IS_ZEBRA_DEBUG_RIB_Q
)
72 vty_out (vty
, " Zebra RIB queue debugging is on%s", VTY_NEWLINE
);
77 DEFUN (debug_zebra_events
,
78 debug_zebra_events_cmd
,
81 "Zebra configuration\n"
82 "Debug option set for zebra events\n")
84 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
88 DEFUN (debug_zebra_packet
,
89 debug_zebra_packet_cmd
,
92 "Zebra configuration\n"
93 "Debug option set for zebra packet\n")
95 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
96 zebra_debug_packet
|= ZEBRA_DEBUG_SEND
;
97 zebra_debug_packet
|= ZEBRA_DEBUG_RECV
;
101 DEFUN (debug_zebra_packet_direct
,
102 debug_zebra_packet_direct_cmd
,
103 "debug zebra packet (recv|send)",
105 "Zebra configuration\n"
106 "Debug option set for zebra packet\n"
107 "Debug option set for receive packet\n"
108 "Debug option set for send packet\n")
110 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
111 if (strncmp ("send", argv
[0], strlen (argv
[0])) == 0)
112 zebra_debug_packet
|= ZEBRA_DEBUG_SEND
;
113 if (strncmp ("recv", argv
[0], strlen (argv
[0])) == 0)
114 zebra_debug_packet
|= ZEBRA_DEBUG_RECV
;
115 zebra_debug_packet
&= ~ZEBRA_DEBUG_DETAIL
;
119 DEFUN (debug_zebra_packet_detail
,
120 debug_zebra_packet_detail_cmd
,
121 "debug zebra packet (recv|send) detail",
123 "Zebra configuration\n"
124 "Debug option set for zebra packet\n"
125 "Debug option set for receive packet\n"
126 "Debug option set for send packet\n"
127 "Debug option set detaied information\n")
129 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
130 if (strncmp ("send", argv
[0], strlen (argv
[0])) == 0)
131 zebra_debug_packet
|= ZEBRA_DEBUG_SEND
;
132 if (strncmp ("recv", argv
[0], strlen (argv
[0])) == 0)
133 zebra_debug_packet
|= ZEBRA_DEBUG_RECV
;
134 zebra_debug_packet
|= ZEBRA_DEBUG_DETAIL
;
138 DEFUN (debug_zebra_kernel
,
139 debug_zebra_kernel_cmd
,
140 "debug zebra kernel",
142 "Zebra configuration\n"
143 "Debug option set for zebra between kernel interface\n")
145 zebra_debug_kernel
= ZEBRA_DEBUG_KERNEL
;
149 DEFUN (debug_zebra_rib
,
153 "Zebra configuration\n"
154 "Debug RIB events\n")
156 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
160 DEFUN (debug_zebra_rib_q
,
161 debug_zebra_rib_q_cmd
,
162 "debug zebra rib queue",
164 "Zebra configuration\n"
166 "Debug RIB queueing\n")
168 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_Q
);
172 DEFUN (no_debug_zebra_events
,
173 no_debug_zebra_events_cmd
,
174 "no debug zebra events",
177 "Zebra configuration\n"
178 "Debug option set for zebra events\n")
180 zebra_debug_event
= 0;
184 DEFUN (no_debug_zebra_packet
,
185 no_debug_zebra_packet_cmd
,
186 "no debug zebra packet",
189 "Zebra configuration\n"
190 "Debug option set for zebra packet\n")
192 zebra_debug_packet
= 0;
196 DEFUN (no_debug_zebra_packet_direct
,
197 no_debug_zebra_packet_direct_cmd
,
198 "no debug zebra packet (recv|send)",
201 "Zebra configuration\n"
202 "Debug option set for zebra packet\n"
203 "Debug option set for receive packet\n"
204 "Debug option set for send packet\n")
206 if (strncmp ("send", argv
[0], strlen (argv
[0])) == 0)
207 zebra_debug_packet
&= ~ZEBRA_DEBUG_SEND
;
208 if (strncmp ("recv", argv
[0], strlen (argv
[0])) == 0)
209 zebra_debug_packet
&= ~ZEBRA_DEBUG_RECV
;
213 DEFUN (no_debug_zebra_kernel
,
214 no_debug_zebra_kernel_cmd
,
215 "no debug zebra kernel",
218 "Zebra configuration\n"
219 "Debug option set for zebra between kernel interface\n")
221 zebra_debug_kernel
= 0;
225 DEFUN (no_debug_zebra_rib
,
226 no_debug_zebra_rib_cmd
,
227 "no debug zebra rib",
230 "Zebra configuration\n"
237 DEFUN (no_debug_zebra_rib_q
,
238 no_debug_zebra_rib_q_cmd
,
239 "no debug zebra rib queue",
242 "Zebra configuration\n"
244 "Debug RIB queueing\n")
246 UNSET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_Q
);
251 struct cmd_node debug_node
=
254 "", /* Debug node has no interface. */
259 config_write_debug (struct vty
*vty
)
263 if (IS_ZEBRA_DEBUG_EVENT
)
265 vty_out (vty
, "debug zebra events%s", VTY_NEWLINE
);
268 if (IS_ZEBRA_DEBUG_PACKET
)
270 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
)
272 vty_out (vty
, "debug zebra packet%s%s",
273 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
279 if (IS_ZEBRA_DEBUG_SEND
)
280 vty_out (vty
, "debug zebra packet send%s%s",
281 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
284 vty_out (vty
, "debug zebra packet recv%s%s",
285 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
290 if (IS_ZEBRA_DEBUG_KERNEL
)
292 vty_out (vty
, "debug zebra kernel%s", VTY_NEWLINE
);
295 if (IS_ZEBRA_DEBUG_RIB
)
297 vty_out (vty
, "debug zebra rib%s", VTY_NEWLINE
);
300 if (IS_ZEBRA_DEBUG_RIB_Q
)
302 vty_out (vty
, "debug zebra rib queue%s", VTY_NEWLINE
);
309 zebra_debug_init (void)
311 zebra_debug_event
= 0;
312 zebra_debug_packet
= 0;
313 zebra_debug_kernel
= 0;
316 install_node (&debug_node
, config_write_debug
);
318 install_element (VIEW_NODE
, &show_debugging_zebra_cmd
);
320 install_element (ENABLE_NODE
, &show_debugging_zebra_cmd
);
321 install_element (ENABLE_NODE
, &debug_zebra_events_cmd
);
322 install_element (ENABLE_NODE
, &debug_zebra_packet_cmd
);
323 install_element (ENABLE_NODE
, &debug_zebra_packet_direct_cmd
);
324 install_element (ENABLE_NODE
, &debug_zebra_packet_detail_cmd
);
325 install_element (ENABLE_NODE
, &debug_zebra_kernel_cmd
);
326 install_element (ENABLE_NODE
, &debug_zebra_rib_cmd
);
327 install_element (ENABLE_NODE
, &debug_zebra_rib_q_cmd
);
328 install_element (ENABLE_NODE
, &no_debug_zebra_events_cmd
);
329 install_element (ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
330 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
331 install_element (ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
332 install_element (ENABLE_NODE
, &no_debug_zebra_rib_q_cmd
);
334 install_element (CONFIG_NODE
, &debug_zebra_events_cmd
);
335 install_element (CONFIG_NODE
, &debug_zebra_packet_cmd
);
336 install_element (CONFIG_NODE
, &debug_zebra_packet_direct_cmd
);
337 install_element (CONFIG_NODE
, &debug_zebra_packet_detail_cmd
);
338 install_element (CONFIG_NODE
, &debug_zebra_kernel_cmd
);
339 install_element (CONFIG_NODE
, &debug_zebra_rib_cmd
);
340 install_element (CONFIG_NODE
, &debug_zebra_rib_q_cmd
);
341 install_element (CONFIG_NODE
, &no_debug_zebra_events_cmd
);
342 install_element (CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
343 install_element (CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
344 install_element (CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
345 install_element (CONFIG_NODE
, &no_debug_zebra_rib_q_cmd
);