]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_debug.c
build: Quagga 0.99.23-rc1
[mirror_frr.git] / ripngd / ripng_debug.c
1 /*
2 * RIPng debug output routines
3 * Copyright (C) 1998 Kunihiro Ishiguro
4 *
5 * This file is part of GNU Zebra.
6 *
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
10 * later version.
11 *
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.
16 *
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 Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23 #include <zebra.h>
24 #include "command.h"
25 #include "ripngd/ripng_debug.h"
26
27 /* For debug statement. */
28 unsigned long ripng_debug_event = 0;
29 unsigned long ripng_debug_packet = 0;
30 unsigned long ripng_debug_zebra = 0;
31 \f
32 DEFUN (show_debugging_ripng,
33 show_debugging_ripng_cmd,
34 "show debugging ripng",
35 SHOW_STR
36 DEBUG_STR
37 "RIPng configuration\n")
38 {
39 vty_out (vty, "RIPng debugging status:%s", VTY_NEWLINE);
40
41 if (IS_RIPNG_DEBUG_EVENT)
42 vty_out (vty, " RIPng event debugging is on%s", VTY_NEWLINE);
43
44 if (IS_RIPNG_DEBUG_PACKET)
45 {
46 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV)
47 {
48 vty_out (vty, " RIPng packet debugging is on%s",
49 VTY_NEWLINE);
50 }
51 else
52 {
53 if (IS_RIPNG_DEBUG_SEND)
54 vty_out (vty, " RIPng packet send debugging is on%s",
55 VTY_NEWLINE);
56 else
57 vty_out (vty, " RIPng packet receive debugging is on%s",
58 VTY_NEWLINE);
59 }
60 }
61
62 if (IS_RIPNG_DEBUG_ZEBRA)
63 vty_out (vty, " RIPng zebra debugging is on%s", VTY_NEWLINE);
64
65 return CMD_SUCCESS;
66 }
67
68 DEFUN (debug_ripng_events,
69 debug_ripng_events_cmd,
70 "debug ripng events",
71 DEBUG_STR
72 "RIPng configuration\n"
73 "Debug option set for ripng events\n")
74 {
75 ripng_debug_event = RIPNG_DEBUG_EVENT;
76 return CMD_WARNING;
77 }
78
79 DEFUN (debug_ripng_packet,
80 debug_ripng_packet_cmd,
81 "debug ripng packet",
82 DEBUG_STR
83 "RIPng configuration\n"
84 "Debug option set for ripng packet\n")
85 {
86 ripng_debug_packet = RIPNG_DEBUG_PACKET;
87 ripng_debug_packet |= RIPNG_DEBUG_SEND;
88 ripng_debug_packet |= RIPNG_DEBUG_RECV;
89 return CMD_SUCCESS;
90 }
91
92 DEFUN (debug_ripng_packet_direct,
93 debug_ripng_packet_direct_cmd,
94 "debug ripng packet (recv|send)",
95 DEBUG_STR
96 "RIPng configuration\n"
97 "Debug option set for ripng packet\n"
98 "Debug option set for receive packet\n"
99 "Debug option set for send packet\n")
100 {
101 ripng_debug_packet |= RIPNG_DEBUG_PACKET;
102 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
103 ripng_debug_packet |= RIPNG_DEBUG_SEND;
104 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
105 ripng_debug_packet |= RIPNG_DEBUG_RECV;
106
107 return CMD_SUCCESS;
108 }
109
110 /* N.B. the "detail" modifier is a no-op. we leave this command
111 for legacy compatibility. */
112 DEFUN_DEPRECATED (debug_ripng_packet_detail,
113 debug_ripng_packet_detail_cmd,
114 "debug ripng packet (recv|send) detail",
115 DEBUG_STR
116 "RIPng configuration\n"
117 "Debug option set for ripng packet\n"
118 "Debug option set for receive packet\n"
119 "Debug option set for send packet\n"
120 "Debug option set detaied information\n")
121 {
122 ripng_debug_packet |= RIPNG_DEBUG_PACKET;
123 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
124 ripng_debug_packet |= RIPNG_DEBUG_SEND;
125 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
126 ripng_debug_packet |= RIPNG_DEBUG_RECV;
127
128 return CMD_SUCCESS;
129 }
130
131 DEFUN (debug_ripng_zebra,
132 debug_ripng_zebra_cmd,
133 "debug ripng zebra",
134 DEBUG_STR
135 "RIPng configuration\n"
136 "Debug option set for ripng and zebra communication\n")
137 {
138 ripng_debug_zebra = RIPNG_DEBUG_ZEBRA;
139 return CMD_WARNING;
140 }
141
142 DEFUN (no_debug_ripng_events,
143 no_debug_ripng_events_cmd,
144 "no debug ripng events",
145 NO_STR
146 DEBUG_STR
147 "RIPng configuration\n"
148 "Debug option set for ripng events\n")
149 {
150 ripng_debug_event = 0;
151 return CMD_SUCCESS;
152 }
153
154 DEFUN (no_debug_ripng_packet,
155 no_debug_ripng_packet_cmd,
156 "no debug ripng packet",
157 NO_STR
158 DEBUG_STR
159 "RIPng configuration\n"
160 "Debug option set for ripng packet\n")
161 {
162 ripng_debug_packet = 0;
163 return CMD_SUCCESS;
164 }
165
166 DEFUN (no_debug_ripng_packet_direct,
167 no_debug_ripng_packet_direct_cmd,
168 "no debug ripng packet (recv|send)",
169 NO_STR
170 DEBUG_STR
171 "RIPng configuration\n"
172 "Debug option set for ripng packet\n"
173 "Debug option set for receive packet\n"
174 "Debug option set for send packet\n")
175 {
176 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
177 {
178 if (IS_RIPNG_DEBUG_RECV)
179 ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
180 else
181 ripng_debug_packet = 0;
182 }
183 else if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
184 {
185 if (IS_RIPNG_DEBUG_SEND)
186 ripng_debug_packet &= ~RIPNG_DEBUG_RECV;
187 else
188 ripng_debug_packet = 0;
189 }
190 return CMD_SUCCESS;
191 }
192
193 DEFUN (no_debug_ripng_zebra,
194 no_debug_ripng_zebra_cmd,
195 "no debug ripng zebra",
196 NO_STR
197 DEBUG_STR
198 "RIPng configuration\n"
199 "Debug option set for ripng and zebra communication\n")
200 {
201 ripng_debug_zebra = 0;
202 return CMD_WARNING;
203 }
204
205 /* Debug node. */
206 static struct cmd_node debug_node =
207 {
208 DEBUG_NODE,
209 "", /* Debug node has no interface. */
210 1 /* VTYSH */
211 };
212
213 static int
214 config_write_debug (struct vty *vty)
215 {
216 int write = 0;
217
218 if (IS_RIPNG_DEBUG_EVENT)
219 {
220 vty_out (vty, "debug ripng events%s", VTY_NEWLINE);
221 write++;
222 }
223 if (IS_RIPNG_DEBUG_PACKET)
224 {
225 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV)
226 {
227 vty_out (vty, "debug ripng packet%s",
228 VTY_NEWLINE);
229 write++;
230 }
231 else
232 {
233 if (IS_RIPNG_DEBUG_SEND)
234 vty_out (vty, "debug ripng packet send%s",
235 VTY_NEWLINE);
236 else
237 vty_out (vty, "debug ripng packet recv%s",
238 VTY_NEWLINE);
239 write++;
240 }
241 }
242 if (IS_RIPNG_DEBUG_ZEBRA)
243 {
244 vty_out (vty, "debug ripng zebra%s", VTY_NEWLINE);
245 write++;
246 }
247 return write;
248 }
249
250 void
251 ripng_debug_reset ()
252 {
253 ripng_debug_event = 0;
254 ripng_debug_packet = 0;
255 ripng_debug_zebra = 0;
256 }
257
258 void
259 ripng_debug_init ()
260 {
261 ripng_debug_event = 0;
262 ripng_debug_packet = 0;
263 ripng_debug_zebra = 0;
264
265 install_node (&debug_node, config_write_debug);
266
267 install_element (VIEW_NODE, &show_debugging_ripng_cmd);
268
269 install_element (ENABLE_NODE, &show_debugging_ripng_cmd);
270 install_element (ENABLE_NODE, &debug_ripng_events_cmd);
271 install_element (ENABLE_NODE, &debug_ripng_packet_cmd);
272 install_element (ENABLE_NODE, &debug_ripng_packet_direct_cmd);
273 install_element (ENABLE_NODE, &debug_ripng_packet_detail_cmd);
274 install_element (ENABLE_NODE, &debug_ripng_zebra_cmd);
275 install_element (ENABLE_NODE, &no_debug_ripng_events_cmd);
276 install_element (ENABLE_NODE, &no_debug_ripng_packet_cmd);
277 install_element (ENABLE_NODE, &no_debug_ripng_packet_direct_cmd);
278 install_element (ENABLE_NODE, &no_debug_ripng_zebra_cmd);
279
280 install_element (CONFIG_NODE, &debug_ripng_events_cmd);
281 install_element (CONFIG_NODE, &debug_ripng_packet_cmd);
282 install_element (CONFIG_NODE, &debug_ripng_packet_direct_cmd);
283 install_element (CONFIG_NODE, &debug_ripng_packet_detail_cmd);
284 install_element (CONFIG_NODE, &debug_ripng_zebra_cmd);
285 install_element (CONFIG_NODE, &no_debug_ripng_events_cmd);
286 install_element (CONFIG_NODE, &no_debug_ripng_packet_cmd);
287 install_element (CONFIG_NODE, &no_debug_ripng_packet_direct_cmd);
288 install_element (CONFIG_NODE, &no_debug_ripng_zebra_cmd);
289 }