]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_debug.c
convert <1-255> to (1-255), ()s to <>s, etc
[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
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[3]->arg, strlen (argv[3]->arg)) == 0)
103 ripng_debug_packet |= RIPNG_DEBUG_SEND;
104 if (strncmp ("recv", argv[3]->arg, strlen (argv[3]->arg)) == 0)
105 ripng_debug_packet |= RIPNG_DEBUG_RECV;
106
107 return CMD_SUCCESS;
108 }
109
110 DEFUN (debug_ripng_zebra,
111 debug_ripng_zebra_cmd,
112 "debug ripng zebra",
113 DEBUG_STR
114 "RIPng configuration\n"
115 "Debug option set for ripng and zebra communication\n")
116 {
117 ripng_debug_zebra = RIPNG_DEBUG_ZEBRA;
118 return CMD_WARNING;
119 }
120
121 DEFUN (no_debug_ripng_events,
122 no_debug_ripng_events_cmd,
123 "no debug ripng events",
124 NO_STR
125 DEBUG_STR
126 "RIPng configuration\n"
127 "Debug option set for ripng events\n")
128 {
129 ripng_debug_event = 0;
130 return CMD_SUCCESS;
131 }
132
133 DEFUN (no_debug_ripng_packet,
134 no_debug_ripng_packet_cmd,
135 "no debug ripng packet",
136 NO_STR
137 DEBUG_STR
138 "RIPng configuration\n"
139 "Debug option set for ripng packet\n")
140 {
141 ripng_debug_packet = 0;
142 return CMD_SUCCESS;
143 }
144
145 DEFUN (no_debug_ripng_packet_direct,
146 no_debug_ripng_packet_direct_cmd,
147 "no debug ripng packet <recv|send>",
148 NO_STR
149 DEBUG_STR
150 "RIPng configuration\n"
151 "Debug option set for ripng packet\n"
152 "Debug option set for receive packet\n"
153 "Debug option set for send packet\n")
154 {
155 if (strncmp ("send", argv[4]->arg, strlen (argv[4]->arg)) == 0)
156 {
157 if (IS_RIPNG_DEBUG_RECV)
158 ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
159 else
160 ripng_debug_packet = 0;
161 }
162 else if (strncmp ("recv", argv[4]->arg, strlen (argv[4]->arg)) == 0)
163 {
164 if (IS_RIPNG_DEBUG_SEND)
165 ripng_debug_packet &= ~RIPNG_DEBUG_RECV;
166 else
167 ripng_debug_packet = 0;
168 }
169 return CMD_SUCCESS;
170 }
171
172 DEFUN (no_debug_ripng_zebra,
173 no_debug_ripng_zebra_cmd,
174 "no debug ripng zebra",
175 NO_STR
176 DEBUG_STR
177 "RIPng configuration\n"
178 "Debug option set for ripng and zebra communication\n")
179 {
180 ripng_debug_zebra = 0;
181 return CMD_WARNING;
182 }
183
184 /* Debug node. */
185 static struct cmd_node debug_node =
186 {
187 DEBUG_NODE,
188 "", /* Debug node has no interface. */
189 1 /* VTYSH */
190 };
191
192 static int
193 config_write_debug (struct vty *vty)
194 {
195 int write = 0;
196
197 if (IS_RIPNG_DEBUG_EVENT)
198 {
199 vty_out (vty, "debug ripng events%s", VTY_NEWLINE);
200 write++;
201 }
202 if (IS_RIPNG_DEBUG_PACKET)
203 {
204 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV)
205 {
206 vty_out (vty, "debug ripng packet%s",
207 VTY_NEWLINE);
208 write++;
209 }
210 else
211 {
212 if (IS_RIPNG_DEBUG_SEND)
213 vty_out (vty, "debug ripng packet send%s",
214 VTY_NEWLINE);
215 else
216 vty_out (vty, "debug ripng packet recv%s",
217 VTY_NEWLINE);
218 write++;
219 }
220 }
221 if (IS_RIPNG_DEBUG_ZEBRA)
222 {
223 vty_out (vty, "debug ripng zebra%s", VTY_NEWLINE);
224 write++;
225 }
226 return write;
227 }
228
229 void
230 ripng_debug_reset ()
231 {
232 ripng_debug_event = 0;
233 ripng_debug_packet = 0;
234 ripng_debug_zebra = 0;
235 }
236
237 void
238 ripng_debug_init ()
239 {
240 ripng_debug_event = 0;
241 ripng_debug_packet = 0;
242 ripng_debug_zebra = 0;
243
244 install_node (&debug_node, config_write_debug);
245
246 install_element (VIEW_NODE, &show_debugging_ripng_cmd);
247
248 install_element (ENABLE_NODE, &show_debugging_ripng_cmd);
249 install_element (ENABLE_NODE, &debug_ripng_events_cmd);
250 install_element (ENABLE_NODE, &debug_ripng_packet_cmd);
251 install_element (ENABLE_NODE, &debug_ripng_packet_direct_cmd);
252 install_element (ENABLE_NODE, &debug_ripng_zebra_cmd);
253 install_element (ENABLE_NODE, &no_debug_ripng_events_cmd);
254 install_element (ENABLE_NODE, &no_debug_ripng_packet_cmd);
255 install_element (ENABLE_NODE, &no_debug_ripng_packet_direct_cmd);
256 install_element (ENABLE_NODE, &no_debug_ripng_zebra_cmd);
257
258 install_element (CONFIG_NODE, &debug_ripng_events_cmd);
259 install_element (CONFIG_NODE, &debug_ripng_packet_cmd);
260 install_element (CONFIG_NODE, &debug_ripng_packet_direct_cmd);
261 install_element (CONFIG_NODE, &debug_ripng_zebra_cmd);
262 install_element (CONFIG_NODE, &no_debug_ripng_events_cmd);
263 install_element (CONFIG_NODE, &no_debug_ripng_packet_cmd);
264 install_element (CONFIG_NODE, &no_debug_ripng_packet_direct_cmd);
265 install_element (CONFIG_NODE, &no_debug_ripng_zebra_cmd);
266 }