blob: c1eb39ba2484a351abfcb4253065087110eaa30f [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
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. */
28unsigned long ripng_debug_event = 0;
29unsigned long ripng_debug_packet = 0;
30unsigned long ripng_debug_zebra = 0;
David Lamparter6b0655a2014-06-04 06:53:35 +020031
paul718e3742002-12-13 20:15:29 +000032DEFUN (show_debugging_ripng,
33 show_debugging_ripng_cmd,
34 "show debugging ripng",
35 SHOW_STR
hasso8dceb822004-10-26 06:39:56 +000036 DEBUG_STR
37 "RIPng configuration\n")
paul718e3742002-12-13 20:15:29 +000038{
hassodf43a132004-08-31 12:04:33 +000039 vty_out (vty, "RIPng debugging status:%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000040
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 {
Stephen Hemmingerb016e9d2011-03-13 01:14:08 +030048 vty_out (vty, " RIPng packet debugging is on%s",
paul718e3742002-12-13 20:15:29 +000049 VTY_NEWLINE);
50 }
51 else
52 {
53 if (IS_RIPNG_DEBUG_SEND)
Stephen Hemmingerb016e9d2011-03-13 01:14:08 +030054 vty_out (vty, " RIPng packet send debugging is on%s",
paul718e3742002-12-13 20:15:29 +000055 VTY_NEWLINE);
56 else
Stephen Hemmingerb016e9d2011-03-13 01:14:08 +030057 vty_out (vty, " RIPng packet receive debugging is on%s",
paul718e3742002-12-13 20:15:29 +000058 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
68DEFUN (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
79DEFUN (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
92DEFUN (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;
Stephen Hemmingerb016e9d2011-03-13 01:14:08 +0300106
paul718e3742002-12-13 20:15:29 +0000107 return CMD_SUCCESS;
108}
109
Stephen Hemmingerb016e9d2011-03-13 01:14:08 +0300110/* N.B. the "detail" modifier is a no-op. we leave this command
111 for legacy compatibility. */
112DEFUN_DEPRECATED (debug_ripng_packet_detail,
paul718e3742002-12-13 20:15:29 +0000113 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;
Stephen Hemmingerb016e9d2011-03-13 01:14:08 +0300127
paul718e3742002-12-13 20:15:29 +0000128 return CMD_SUCCESS;
129}
130
131DEFUN (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
142DEFUN (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
154DEFUN (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
166DEFUN (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
193DEFUN (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. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800206static struct cmd_node debug_node =
paul718e3742002-12-13 20:15:29 +0000207{
208 DEBUG_NODE,
hassoa94434b2003-05-25 17:10:12 +0000209 "", /* Debug node has no interface. */
210 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +0000211};
212
Paul Jakma6ac29a52008-08-15 13:45:30 +0100213static int
paul718e3742002-12-13 20:15:29 +0000214config_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 {
Stephen Hemmingerb016e9d2011-03-13 01:14:08 +0300227 vty_out (vty, "debug ripng packet%s",
paul718e3742002-12-13 20:15:29 +0000228 VTY_NEWLINE);
229 write++;
230 }
231 else
232 {
233 if (IS_RIPNG_DEBUG_SEND)
Stephen Hemmingerb016e9d2011-03-13 01:14:08 +0300234 vty_out (vty, "debug ripng packet send%s",
paul718e3742002-12-13 20:15:29 +0000235 VTY_NEWLINE);
236 else
Stephen Hemmingerb016e9d2011-03-13 01:14:08 +0300237 vty_out (vty, "debug ripng packet recv%s",
paul718e3742002-12-13 20:15:29 +0000238 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
250void
251ripng_debug_reset ()
252{
253 ripng_debug_event = 0;
254 ripng_debug_packet = 0;
255 ripng_debug_zebra = 0;
256}
257
258void
259ripng_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}