MiniDLNA update: 1.0.19.1 to 1.0.20
[tomato.git] / release / src / router / zebra / ripd / rip_debug.c
blob3f4c389efd7778e677cfae805d06811afce1b3da
1 /* RIP debug routines
2 * Copyright (C) 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
22 #include <zebra.h>
23 #include "command.h"
24 #include "ripd/rip_debug.h"
26 /* For debug statement. */
27 unsigned long rip_debug_event = 0;
28 unsigned long rip_debug_packet = 0;
29 unsigned long rip_debug_zebra = 0;
31 DEFUN (debug_rip_events,
32 debug_rip_events_cmd,
33 "debug rip events",
34 DEBUG_STR
35 RIP_STR
36 "RIP events\n")
38 rip_debug_event = RIP_DEBUG_EVENT;
39 return CMD_WARNING;
42 DEFUN (debug_rip_packet,
43 debug_rip_packet_cmd,
44 "debug rip packet",
45 DEBUG_STR
46 RIP_STR
47 "RIP packet\n")
49 rip_debug_packet = RIP_DEBUG_PACKET;
50 rip_debug_packet |= RIP_DEBUG_SEND;
51 rip_debug_packet |= RIP_DEBUG_RECV;
52 return CMD_SUCCESS;
55 DEFUN (debug_rip_packet_direct,
56 debug_rip_packet_direct_cmd,
57 "debug rip packet (recv|send)",
58 DEBUG_STR
59 RIP_STR
60 "RIP packet\n"
61 "RIP receive packet\n"
62 "RIP send packet\n")
64 rip_debug_packet |= RIP_DEBUG_PACKET;
65 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
66 rip_debug_packet |= RIP_DEBUG_SEND;
67 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
68 rip_debug_packet |= RIP_DEBUG_RECV;
69 rip_debug_packet &= ~RIP_DEBUG_DETAIL;
70 return CMD_SUCCESS;
73 DEFUN (debug_rip_packet_detail,
74 debug_rip_packet_detail_cmd,
75 "debug rip packet (recv|send) detail",
76 DEBUG_STR
77 RIP_STR
78 "RIP packet\n"
79 "RIP receive packet\n"
80 "RIP send packet\n"
81 "Detailed information display\n")
83 rip_debug_packet |= RIP_DEBUG_PACKET;
84 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
85 rip_debug_packet |= RIP_DEBUG_SEND;
86 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
87 rip_debug_packet |= RIP_DEBUG_RECV;
88 rip_debug_packet |= RIP_DEBUG_DETAIL;
89 return CMD_SUCCESS;
92 DEFUN (debug_rip_zebra,
93 debug_rip_zebra_cmd,
94 "debug rip zebra",
95 DEBUG_STR
96 RIP_STR
97 "RIP and ZEBRA communication\n")
99 rip_debug_zebra = RIP_DEBUG_ZEBRA;
100 return CMD_WARNING;
103 DEFUN (no_debug_rip_events,
104 no_debug_rip_events_cmd,
105 "no debug rip events",
106 NO_STR
107 DEBUG_STR
108 RIP_STR
109 "RIP events\n")
111 rip_debug_event = 0;
112 return CMD_SUCCESS;
115 DEFUN (no_debug_rip_packet,
116 no_debug_rip_packet_cmd,
117 "no debug rip packet",
118 NO_STR
119 DEBUG_STR
120 RIP_STR
121 "RIP packet\n")
123 rip_debug_packet = 0;
124 return CMD_SUCCESS;
127 DEFUN (no_debug_rip_packet_direct,
128 no_debug_rip_packet_direct_cmd,
129 "no debug rip packet (recv|send)",
130 NO_STR
131 DEBUG_STR
132 RIP_STR
133 "RIP packet\n"
134 "RIP option set for receive packet\n"
135 "RIP option set for send packet\n")
137 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
139 if (IS_RIP_DEBUG_RECV)
140 rip_debug_packet &= ~RIP_DEBUG_SEND;
141 else
142 rip_debug_packet = 0;
144 else if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
146 if (IS_RIP_DEBUG_SEND)
147 rip_debug_packet &= ~RIP_DEBUG_RECV;
148 else
149 rip_debug_packet = 0;
151 return CMD_SUCCESS;
154 DEFUN (no_debug_rip_zebra,
155 no_debug_rip_zebra_cmd,
156 "no debug rip zebra",
157 NO_STR
158 DEBUG_STR
159 RIP_STR
160 "RIP and ZEBRA communication\n")
162 rip_debug_zebra = 0;
163 return CMD_WARNING;
166 DEFUN (show_debugging_rip,
167 show_debugging_rip_cmd,
168 "show debugging rip",
169 SHOW_STR
170 DEBUG_STR
171 RIP_STR)
173 vty_out (vty, "Zebra debugging status:%s", VTY_NEWLINE);
175 if (IS_RIP_DEBUG_EVENT)
176 vty_out (vty, " RIP event debugging is on%s", VTY_NEWLINE);
178 if (IS_RIP_DEBUG_PACKET)
180 if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV)
182 vty_out (vty, " RIP packet%s debugging is on%s",
183 IS_RIP_DEBUG_DETAIL ? " detail" : "",
184 VTY_NEWLINE);
186 else
188 if (IS_RIP_DEBUG_SEND)
189 vty_out (vty, " RIP packet send%s debugging is on%s",
190 IS_RIP_DEBUG_DETAIL ? " detail" : "",
191 VTY_NEWLINE);
192 else
193 vty_out (vty, " RIP packet receive%s debugging is on%s",
194 IS_RIP_DEBUG_DETAIL ? " detail" : "",
195 VTY_NEWLINE);
199 if (IS_RIP_DEBUG_ZEBRA)
200 vty_out (vty, " RIP zebra debugging is on%s", VTY_NEWLINE);
202 return CMD_SUCCESS;
205 /* Debug node. */
206 struct cmd_node debug_node =
208 DEBUG_NODE,
209 "", /* Debug node has no interface. */
214 config_write_debug (struct vty *vty)
216 int write = 0;
218 if (IS_RIP_DEBUG_EVENT)
220 vty_out (vty, "debug rip events%s", VTY_NEWLINE);
221 write++;
223 if (IS_RIP_DEBUG_PACKET)
225 if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV)
227 vty_out (vty, "debug rip packet%s%s",
228 IS_RIP_DEBUG_DETAIL ? " detail" : "",
229 VTY_NEWLINE);
230 write++;
232 else
234 if (IS_RIP_DEBUG_SEND)
235 vty_out (vty, "debug rip packet send%s%s",
236 IS_RIP_DEBUG_DETAIL ? " detail" : "",
237 VTY_NEWLINE);
238 else
239 vty_out (vty, "debug rip packet recv%s%s",
240 IS_RIP_DEBUG_DETAIL ? " detail" : "",
241 VTY_NEWLINE);
242 write++;
245 if (IS_RIP_DEBUG_ZEBRA)
247 vty_out (vty, "debug rip zebra%s", VTY_NEWLINE);
248 write++;
250 return write;
253 void
254 rip_debug_reset ()
256 rip_debug_event = 0;
257 rip_debug_packet = 0;
258 rip_debug_zebra = 0;
261 void
262 rip_debug_init ()
264 rip_debug_event = 0;
265 rip_debug_packet = 0;
266 rip_debug_zebra = 0;
268 install_node (&debug_node, config_write_debug);
270 install_element (ENABLE_NODE, &debug_rip_events_cmd);
271 install_element (ENABLE_NODE, &debug_rip_packet_cmd);
272 install_element (ENABLE_NODE, &debug_rip_packet_direct_cmd);
273 install_element (ENABLE_NODE, &debug_rip_packet_detail_cmd);
274 install_element (ENABLE_NODE, &debug_rip_zebra_cmd);
275 install_element (ENABLE_NODE, &no_debug_rip_events_cmd);
276 install_element (ENABLE_NODE, &no_debug_rip_packet_cmd);
277 install_element (ENABLE_NODE, &no_debug_rip_packet_direct_cmd);
278 install_element (ENABLE_NODE, &no_debug_rip_zebra_cmd);
280 install_element (CONFIG_NODE, &debug_rip_events_cmd);
281 install_element (CONFIG_NODE, &debug_rip_packet_cmd);
282 install_element (CONFIG_NODE, &debug_rip_packet_direct_cmd);
283 install_element (CONFIG_NODE, &debug_rip_packet_detail_cmd);
284 install_element (CONFIG_NODE, &debug_rip_zebra_cmd);
285 install_element (CONFIG_NODE, &no_debug_rip_events_cmd);
286 install_element (CONFIG_NODE, &no_debug_rip_packet_cmd);
287 install_element (CONFIG_NODE, &no_debug_rip_packet_direct_cmd);
288 install_element (CONFIG_NODE, &no_debug_rip_zebra_cmd);
290 install_element (ENABLE_NODE, &show_debugging_rip_cmd);