]> git.proxmox.com Git - mirror_frr.git/blame - ripd/rip_debug.c
convert <1-255> to (1-255), ()s to <>s, etc
[mirror_frr.git] / ripd / rip_debug.c
CommitLineData
718e3744 1/* RIP debug routines
2 * Copyright (C) 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
3 *
4 * This file is part of GNU Zebra.
5 *
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.
10 *
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.
15 *
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.
20 */
21
22#include <zebra.h>
23#include "command.h"
24#include "ripd/rip_debug.h"
25
26/* For debug statement. */
27unsigned long rip_debug_event = 0;
28unsigned long rip_debug_packet = 0;
29unsigned long rip_debug_zebra = 0;
6b0655a2 30
718e3744 31DEFUN (show_debugging_rip,
32 show_debugging_rip_cmd,
33 "show debugging rip",
34 SHOW_STR
35 DEBUG_STR
36 RIP_STR)
37{
df43a137 38 vty_out (vty, "RIP debugging status:%s", VTY_NEWLINE);
718e3744 39
40 if (IS_RIP_DEBUG_EVENT)
41 vty_out (vty, " RIP event debugging is on%s", VTY_NEWLINE);
42
43 if (IS_RIP_DEBUG_PACKET)
44 {
45 if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV)
46 {
0fa03353 47 vty_out (vty, " RIP packet debugging is on%s",
718e3744 48 VTY_NEWLINE);
49 }
50 else
51 {
52 if (IS_RIP_DEBUG_SEND)
0fa03353 53 vty_out (vty, " RIP packet send debugging is on%s",
718e3744 54 VTY_NEWLINE);
55 else
0fa03353 56 vty_out (vty, " RIP packet receive debugging is on%s",
718e3744 57 VTY_NEWLINE);
58 }
59 }
60
61 if (IS_RIP_DEBUG_ZEBRA)
62 vty_out (vty, " RIP zebra debugging is on%s", VTY_NEWLINE);
63
64 return CMD_SUCCESS;
65}
66
67DEFUN (debug_rip_events,
68 debug_rip_events_cmd,
69 "debug rip events",
70 DEBUG_STR
71 RIP_STR
72 "RIP events\n")
73{
74 rip_debug_event = RIP_DEBUG_EVENT;
75 return CMD_WARNING;
76}
77
78DEFUN (debug_rip_packet,
79 debug_rip_packet_cmd,
80 "debug rip packet",
81 DEBUG_STR
82 RIP_STR
83 "RIP packet\n")
84{
85 rip_debug_packet = RIP_DEBUG_PACKET;
86 rip_debug_packet |= RIP_DEBUG_SEND;
87 rip_debug_packet |= RIP_DEBUG_RECV;
88 return CMD_SUCCESS;
89}
90
91DEFUN (debug_rip_packet_direct,
92 debug_rip_packet_direct_cmd,
6147e2c6 93 "debug rip packet <recv|send>",
718e3744 94 DEBUG_STR
95 RIP_STR
96 "RIP packet\n"
97 "RIP receive packet\n"
98 "RIP send packet\n")
99{
100 rip_debug_packet |= RIP_DEBUG_PACKET;
558e4c28 101 if (strncmp ("send", argv[3]->arg, strlen (argv[3]->arg)) == 0)
718e3744 102 rip_debug_packet |= RIP_DEBUG_SEND;
558e4c28 103 if (strncmp ("recv", argv[3]->arg, strlen (argv[3]->arg)) == 0)
718e3744 104 rip_debug_packet |= RIP_DEBUG_RECV;
718e3744 105 return CMD_SUCCESS;
106}
107
718e3744 108DEFUN (debug_rip_zebra,
109 debug_rip_zebra_cmd,
110 "debug rip zebra",
111 DEBUG_STR
112 RIP_STR
113 "RIP and ZEBRA communication\n")
114{
115 rip_debug_zebra = RIP_DEBUG_ZEBRA;
116 return CMD_WARNING;
117}
118
119DEFUN (no_debug_rip_events,
120 no_debug_rip_events_cmd,
121 "no debug rip events",
122 NO_STR
123 DEBUG_STR
124 RIP_STR
125 "RIP events\n")
126{
127 rip_debug_event = 0;
128 return CMD_SUCCESS;
129}
130
131DEFUN (no_debug_rip_packet,
132 no_debug_rip_packet_cmd,
133 "no debug rip packet",
134 NO_STR
135 DEBUG_STR
136 RIP_STR
137 "RIP packet\n")
138{
139 rip_debug_packet = 0;
140 return CMD_SUCCESS;
141}
142
143DEFUN (no_debug_rip_packet_direct,
144 no_debug_rip_packet_direct_cmd,
6147e2c6 145 "no debug rip packet <recv|send>",
718e3744 146 NO_STR
147 DEBUG_STR
148 RIP_STR
149 "RIP packet\n"
150 "RIP option set for receive packet\n"
151 "RIP option set for send packet\n")
152{
558e4c28 153 if (strncmp ("send", argv[4]->arg, strlen (argv[4]->arg)) == 0)
718e3744 154 {
155 if (IS_RIP_DEBUG_RECV)
156 rip_debug_packet &= ~RIP_DEBUG_SEND;
157 else
158 rip_debug_packet = 0;
159 }
558e4c28 160 else if (strncmp ("recv", argv[4]->arg, strlen (argv[4]->arg)) == 0)
718e3744 161 {
162 if (IS_RIP_DEBUG_SEND)
163 rip_debug_packet &= ~RIP_DEBUG_RECV;
164 else
165 rip_debug_packet = 0;
166 }
167 return CMD_SUCCESS;
168}
169
170DEFUN (no_debug_rip_zebra,
171 no_debug_rip_zebra_cmd,
172 "no debug rip zebra",
173 NO_STR
174 DEBUG_STR
175 RIP_STR
176 "RIP and ZEBRA communication\n")
177{
178 rip_debug_zebra = 0;
179 return CMD_WARNING;
180}
181
182/* Debug node. */
7fc626de 183static struct cmd_node debug_node =
718e3744 184{
185 DEBUG_NODE,
186 "", /* Debug node has no interface. */
187 1
188};
189
dc63bfd4 190static int
718e3744 191config_write_debug (struct vty *vty)
192{
193 int write = 0;
194
195 if (IS_RIP_DEBUG_EVENT)
196 {
197 vty_out (vty, "debug rip events%s", VTY_NEWLINE);
198 write++;
199 }
200 if (IS_RIP_DEBUG_PACKET)
201 {
202 if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV)
203 {
0fa03353 204 vty_out (vty, "debug rip packet%s",
718e3744 205 VTY_NEWLINE);
206 write++;
207 }
208 else
209 {
210 if (IS_RIP_DEBUG_SEND)
0fa03353 211 vty_out (vty, "debug rip packet send%s",
718e3744 212 VTY_NEWLINE);
213 else
0fa03353 214 vty_out (vty, "debug rip packet recv%s",
718e3744 215 VTY_NEWLINE);
216 write++;
217 }
218 }
219 if (IS_RIP_DEBUG_ZEBRA)
220 {
221 vty_out (vty, "debug rip zebra%s", VTY_NEWLINE);
222 write++;
223 }
224 return write;
225}
226
227void
dc63bfd4 228rip_debug_reset (void)
718e3744 229{
230 rip_debug_event = 0;
231 rip_debug_packet = 0;
232 rip_debug_zebra = 0;
233}
234
235void
dc63bfd4 236rip_debug_init (void)
718e3744 237{
238 rip_debug_event = 0;
239 rip_debug_packet = 0;
240 rip_debug_zebra = 0;
241
242 install_node (&debug_node, config_write_debug);
243
244 install_element (ENABLE_NODE, &show_debugging_rip_cmd);
245 install_element (ENABLE_NODE, &debug_rip_events_cmd);
246 install_element (ENABLE_NODE, &debug_rip_packet_cmd);
247 install_element (ENABLE_NODE, &debug_rip_packet_direct_cmd);
718e3744 248 install_element (ENABLE_NODE, &debug_rip_zebra_cmd);
249 install_element (ENABLE_NODE, &no_debug_rip_events_cmd);
250 install_element (ENABLE_NODE, &no_debug_rip_packet_cmd);
251 install_element (ENABLE_NODE, &no_debug_rip_packet_direct_cmd);
252 install_element (ENABLE_NODE, &no_debug_rip_zebra_cmd);
253
254 install_element (CONFIG_NODE, &debug_rip_events_cmd);
255 install_element (CONFIG_NODE, &debug_rip_packet_cmd);
256 install_element (CONFIG_NODE, &debug_rip_packet_direct_cmd);
718e3744 257 install_element (CONFIG_NODE, &debug_rip_zebra_cmd);
258 install_element (CONFIG_NODE, &no_debug_rip_events_cmd);
259 install_element (CONFIG_NODE, &no_debug_rip_packet_cmd);
260 install_element (CONFIG_NODE, &no_debug_rip_packet_direct_cmd);
261 install_element (CONFIG_NODE, &no_debug_rip_zebra_cmd);
262}