]> git.proxmox.com Git - mirror_frr.git/blob - ripd/rip_debug.c
Merge branch 'frr/pull/569'
[mirror_frr.git] / ripd / rip_debug.c
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 along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <zebra.h>
22 #include "command.h"
23 #include "ripd/rip_debug.h"
24
25 /* For debug statement. */
26 unsigned long rip_debug_event = 0;
27 unsigned long rip_debug_packet = 0;
28 unsigned long rip_debug_zebra = 0;
29
30 DEFUN (show_debugging_rip,
31 show_debugging_rip_cmd,
32 "show debugging rip",
33 SHOW_STR
34 DEBUG_STR
35 RIP_STR)
36 {
37 vty_out (vty, "RIP debugging status:%s", VTY_NEWLINE);
38
39 if (IS_RIP_DEBUG_EVENT)
40 vty_out (vty, " RIP event debugging is on%s", VTY_NEWLINE);
41
42 if (IS_RIP_DEBUG_PACKET)
43 {
44 if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV)
45 {
46 vty_out (vty, " RIP packet debugging is on%s",
47 VTY_NEWLINE);
48 }
49 else
50 {
51 if (IS_RIP_DEBUG_SEND)
52 vty_out (vty, " RIP packet send debugging is on%s",
53 VTY_NEWLINE);
54 else
55 vty_out (vty, " RIP packet receive debugging is on%s",
56 VTY_NEWLINE);
57 }
58 }
59
60 if (IS_RIP_DEBUG_ZEBRA)
61 vty_out (vty, " RIP zebra debugging is on%s", VTY_NEWLINE);
62
63 return CMD_SUCCESS;
64 }
65
66 DEFUN (debug_rip_events,
67 debug_rip_events_cmd,
68 "debug rip events",
69 DEBUG_STR
70 RIP_STR
71 "RIP events\n")
72 {
73 rip_debug_event = RIP_DEBUG_EVENT;
74 return CMD_WARNING;
75 }
76
77 DEFUN (debug_rip_packet,
78 debug_rip_packet_cmd,
79 "debug rip packet",
80 DEBUG_STR
81 RIP_STR
82 "RIP packet\n")
83 {
84 rip_debug_packet = RIP_DEBUG_PACKET;
85 rip_debug_packet |= RIP_DEBUG_SEND;
86 rip_debug_packet |= RIP_DEBUG_RECV;
87 return CMD_SUCCESS;
88 }
89
90 DEFUN (debug_rip_packet_direct,
91 debug_rip_packet_direct_cmd,
92 "debug rip packet <recv|send>",
93 DEBUG_STR
94 RIP_STR
95 "RIP packet\n"
96 "RIP receive packet\n"
97 "RIP send packet\n")
98 {
99 int idx_recv_send = 3;
100 rip_debug_packet |= RIP_DEBUG_PACKET;
101 if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
102 rip_debug_packet |= RIP_DEBUG_SEND;
103 if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
104 rip_debug_packet |= RIP_DEBUG_RECV;
105 return CMD_SUCCESS;
106 }
107
108 DEFUN (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
119 DEFUN (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
131 DEFUN (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
143 DEFUN (no_debug_rip_packet_direct,
144 no_debug_rip_packet_direct_cmd,
145 "no debug rip packet <recv|send>",
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 {
153 int idx_recv_send = 4;
154 if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
155 {
156 if (IS_RIP_DEBUG_RECV)
157 rip_debug_packet &= ~RIP_DEBUG_SEND;
158 else
159 rip_debug_packet = 0;
160 }
161 else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
162 {
163 if (IS_RIP_DEBUG_SEND)
164 rip_debug_packet &= ~RIP_DEBUG_RECV;
165 else
166 rip_debug_packet = 0;
167 }
168 return CMD_SUCCESS;
169 }
170
171 DEFUN (no_debug_rip_zebra,
172 no_debug_rip_zebra_cmd,
173 "no debug rip zebra",
174 NO_STR
175 DEBUG_STR
176 RIP_STR
177 "RIP and ZEBRA communication\n")
178 {
179 rip_debug_zebra = 0;
180 return CMD_WARNING;
181 }
182
183 /* Debug node. */
184 static struct cmd_node debug_node =
185 {
186 DEBUG_NODE,
187 "", /* Debug node has no interface. */
188 1
189 };
190
191 static int
192 config_write_debug (struct vty *vty)
193 {
194 int write = 0;
195
196 if (IS_RIP_DEBUG_EVENT)
197 {
198 vty_out (vty, "debug rip events%s", VTY_NEWLINE);
199 write++;
200 }
201 if (IS_RIP_DEBUG_PACKET)
202 {
203 if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV)
204 {
205 vty_out (vty, "debug rip packet%s",
206 VTY_NEWLINE);
207 write++;
208 }
209 else
210 {
211 if (IS_RIP_DEBUG_SEND)
212 vty_out (vty, "debug rip packet send%s",
213 VTY_NEWLINE);
214 else
215 vty_out (vty, "debug rip packet recv%s",
216 VTY_NEWLINE);
217 write++;
218 }
219 }
220 if (IS_RIP_DEBUG_ZEBRA)
221 {
222 vty_out (vty, "debug rip zebra%s", VTY_NEWLINE);
223 write++;
224 }
225 return write;
226 }
227
228 void
229 rip_debug_reset (void)
230 {
231 rip_debug_event = 0;
232 rip_debug_packet = 0;
233 rip_debug_zebra = 0;
234 }
235
236 void
237 rip_debug_init (void)
238 {
239 rip_debug_event = 0;
240 rip_debug_packet = 0;
241 rip_debug_zebra = 0;
242
243 install_node (&debug_node, config_write_debug);
244
245 install_element (ENABLE_NODE, &show_debugging_rip_cmd);
246 install_element (ENABLE_NODE, &debug_rip_events_cmd);
247 install_element (ENABLE_NODE, &debug_rip_packet_cmd);
248 install_element (ENABLE_NODE, &debug_rip_packet_direct_cmd);
249 install_element (ENABLE_NODE, &debug_rip_zebra_cmd);
250 install_element (ENABLE_NODE, &no_debug_rip_events_cmd);
251 install_element (ENABLE_NODE, &no_debug_rip_packet_cmd);
252 install_element (ENABLE_NODE, &no_debug_rip_packet_direct_cmd);
253 install_element (ENABLE_NODE, &no_debug_rip_zebra_cmd);
254
255 install_element (CONFIG_NODE, &debug_rip_events_cmd);
256 install_element (CONFIG_NODE, &debug_rip_packet_cmd);
257 install_element (CONFIG_NODE, &debug_rip_packet_direct_cmd);
258 install_element (CONFIG_NODE, &debug_rip_zebra_cmd);
259 install_element (CONFIG_NODE, &no_debug_rip_events_cmd);
260 install_element (CONFIG_NODE, &no_debug_rip_packet_cmd);
261 install_element (CONFIG_NODE, &no_debug_rip_packet_direct_cmd);
262 install_element (CONFIG_NODE, &no_debug_rip_zebra_cmd);
263 }