]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_debug.c
Merge pull request #549 from qlyoung/fix-poll-eof
[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 along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <zebra.h>
23 #include "command.h"
24 #include "ripngd/ripng_debug.h"
25
26 /* For debug statement. */
27 unsigned long ripng_debug_event = 0;
28 unsigned long ripng_debug_packet = 0;
29 unsigned long ripng_debug_zebra = 0;
30
31 DEFUN (show_debugging_ripng,
32 show_debugging_ripng_cmd,
33 "show debugging ripng",
34 SHOW_STR
35 DEBUG_STR
36 "RIPng configuration\n")
37 {
38 vty_out (vty, "RIPng debugging status:%s", VTY_NEWLINE);
39
40 if (IS_RIPNG_DEBUG_EVENT)
41 vty_out (vty, " RIPng event debugging is on%s", VTY_NEWLINE);
42
43 if (IS_RIPNG_DEBUG_PACKET)
44 {
45 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV)
46 {
47 vty_out (vty, " RIPng packet debugging is on%s",
48 VTY_NEWLINE);
49 }
50 else
51 {
52 if (IS_RIPNG_DEBUG_SEND)
53 vty_out (vty, " RIPng packet send debugging is on%s",
54 VTY_NEWLINE);
55 else
56 vty_out (vty, " RIPng packet receive debugging is on%s",
57 VTY_NEWLINE);
58 }
59 }
60
61 if (IS_RIPNG_DEBUG_ZEBRA)
62 vty_out (vty, " RIPng zebra debugging is on%s", VTY_NEWLINE);
63
64 return CMD_SUCCESS;
65 }
66
67 DEFUN (debug_ripng_events,
68 debug_ripng_events_cmd,
69 "debug ripng events",
70 DEBUG_STR
71 "RIPng configuration\n"
72 "Debug option set for ripng events\n")
73 {
74 ripng_debug_event = RIPNG_DEBUG_EVENT;
75 return CMD_WARNING;
76 }
77
78 DEFUN (debug_ripng_packet,
79 debug_ripng_packet_cmd,
80 "debug ripng packet",
81 DEBUG_STR
82 "RIPng configuration\n"
83 "Debug option set for ripng packet\n")
84 {
85 ripng_debug_packet = RIPNG_DEBUG_PACKET;
86 ripng_debug_packet |= RIPNG_DEBUG_SEND;
87 ripng_debug_packet |= RIPNG_DEBUG_RECV;
88 return CMD_SUCCESS;
89 }
90
91 DEFUN (debug_ripng_packet_direct,
92 debug_ripng_packet_direct_cmd,
93 "debug ripng packet <recv|send>",
94 DEBUG_STR
95 "RIPng configuration\n"
96 "Debug option set for ripng packet\n"
97 "Debug option set for receive packet\n"
98 "Debug option set for send packet\n")
99 {
100 int idx_recv_send = 3;
101 ripng_debug_packet |= RIPNG_DEBUG_PACKET;
102 if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
103 ripng_debug_packet |= RIPNG_DEBUG_SEND;
104 if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->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 int idx_recv_send = 4;
156 if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
157 {
158 if (IS_RIPNG_DEBUG_RECV)
159 ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
160 else
161 ripng_debug_packet = 0;
162 }
163 else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
164 {
165 if (IS_RIPNG_DEBUG_SEND)
166 ripng_debug_packet &= ~RIPNG_DEBUG_RECV;
167 else
168 ripng_debug_packet = 0;
169 }
170 return CMD_SUCCESS;
171 }
172
173 DEFUN (no_debug_ripng_zebra,
174 no_debug_ripng_zebra_cmd,
175 "no debug ripng zebra",
176 NO_STR
177 DEBUG_STR
178 "RIPng configuration\n"
179 "Debug option set for ripng and zebra communication\n")
180 {
181 ripng_debug_zebra = 0;
182 return CMD_WARNING;
183 }
184
185 /* Debug node. */
186 static struct cmd_node debug_node =
187 {
188 DEBUG_NODE,
189 "", /* Debug node has no interface. */
190 1 /* VTYSH */
191 };
192
193 static int
194 config_write_debug (struct vty *vty)
195 {
196 int write = 0;
197
198 if (IS_RIPNG_DEBUG_EVENT)
199 {
200 vty_out (vty, "debug ripng events%s", VTY_NEWLINE);
201 write++;
202 }
203 if (IS_RIPNG_DEBUG_PACKET)
204 {
205 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV)
206 {
207 vty_out (vty, "debug ripng packet%s",
208 VTY_NEWLINE);
209 write++;
210 }
211 else
212 {
213 if (IS_RIPNG_DEBUG_SEND)
214 vty_out (vty, "debug ripng packet send%s",
215 VTY_NEWLINE);
216 else
217 vty_out (vty, "debug ripng packet recv%s",
218 VTY_NEWLINE);
219 write++;
220 }
221 }
222 if (IS_RIPNG_DEBUG_ZEBRA)
223 {
224 vty_out (vty, "debug ripng zebra%s", VTY_NEWLINE);
225 write++;
226 }
227 return write;
228 }
229
230 void
231 ripng_debug_reset ()
232 {
233 ripng_debug_event = 0;
234 ripng_debug_packet = 0;
235 ripng_debug_zebra = 0;
236 }
237
238 void
239 ripng_debug_init ()
240 {
241 ripng_debug_event = 0;
242 ripng_debug_packet = 0;
243 ripng_debug_zebra = 0;
244
245 install_node (&debug_node, config_write_debug);
246
247 install_element (VIEW_NODE, &show_debugging_ripng_cmd);
248
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 }