]>
Commit | Line | Data |
---|---|---|
718e3744 | 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 | "RIPng configuration\n" | |
37 | "Debugging information\n") | |
38 | { | |
39 | vty_out (vty, "Zebra 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%s debugging is on%s", | |
49 | IS_RIPNG_DEBUG_DETAIL ? " detail" : "", | |
50 | VTY_NEWLINE); | |
51 | } | |
52 | else | |
53 | { | |
54 | if (IS_RIPNG_DEBUG_SEND) | |
55 | vty_out (vty, " RIPng packet send%s debugging is on%s", | |
56 | IS_RIPNG_DEBUG_DETAIL ? " detail" : "", | |
57 | VTY_NEWLINE); | |
58 | else | |
59 | vty_out (vty, " RIPng packet receive%s debugging is on%s", | |
60 | IS_RIPNG_DEBUG_DETAIL ? " detail" : "", | |
61 | VTY_NEWLINE); | |
62 | } | |
63 | } | |
64 | ||
65 | if (IS_RIPNG_DEBUG_ZEBRA) | |
66 | vty_out (vty, " RIPng zebra debugging is on%s", VTY_NEWLINE); | |
67 | ||
68 | return CMD_SUCCESS; | |
69 | } | |
70 | ||
71 | DEFUN (debug_ripng_events, | |
72 | debug_ripng_events_cmd, | |
73 | "debug ripng events", | |
74 | DEBUG_STR | |
75 | "RIPng configuration\n" | |
76 | "Debug option set for ripng events\n") | |
77 | { | |
78 | ripng_debug_event = RIPNG_DEBUG_EVENT; | |
79 | return CMD_WARNING; | |
80 | } | |
81 | ||
82 | DEFUN (debug_ripng_packet, | |
83 | debug_ripng_packet_cmd, | |
84 | "debug ripng packet", | |
85 | DEBUG_STR | |
86 | "RIPng configuration\n" | |
87 | "Debug option set for ripng packet\n") | |
88 | { | |
89 | ripng_debug_packet = RIPNG_DEBUG_PACKET; | |
90 | ripng_debug_packet |= RIPNG_DEBUG_SEND; | |
91 | ripng_debug_packet |= RIPNG_DEBUG_RECV; | |
92 | return CMD_SUCCESS; | |
93 | } | |
94 | ||
95 | DEFUN (debug_ripng_packet_direct, | |
96 | debug_ripng_packet_direct_cmd, | |
97 | "debug ripng packet (recv|send)", | |
98 | DEBUG_STR | |
99 | "RIPng configuration\n" | |
100 | "Debug option set for ripng packet\n" | |
101 | "Debug option set for receive packet\n" | |
102 | "Debug option set for send packet\n") | |
103 | { | |
104 | ripng_debug_packet |= RIPNG_DEBUG_PACKET; | |
105 | if (strncmp ("send", argv[0], strlen (argv[0])) == 0) | |
106 | ripng_debug_packet |= RIPNG_DEBUG_SEND; | |
107 | if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) | |
108 | ripng_debug_packet |= RIPNG_DEBUG_RECV; | |
109 | ripng_debug_packet &= ~RIPNG_DEBUG_DETAIL; | |
110 | return CMD_SUCCESS; | |
111 | } | |
112 | ||
113 | DEFUN (debug_ripng_packet_detail, | |
114 | debug_ripng_packet_detail_cmd, | |
115 | "debug ripng packet (recv|send) detail", | |
116 | DEBUG_STR | |
117 | "RIPng configuration\n" | |
118 | "Debug option set for ripng packet\n" | |
119 | "Debug option set for receive packet\n" | |
120 | "Debug option set for send packet\n" | |
121 | "Debug option set detaied information\n") | |
122 | { | |
123 | ripng_debug_packet |= RIPNG_DEBUG_PACKET; | |
124 | if (strncmp ("send", argv[0], strlen (argv[0])) == 0) | |
125 | ripng_debug_packet |= RIPNG_DEBUG_SEND; | |
126 | if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) | |
127 | ripng_debug_packet |= RIPNG_DEBUG_RECV; | |
128 | ripng_debug_packet |= RIPNG_DEBUG_DETAIL; | |
129 | return CMD_SUCCESS; | |
130 | } | |
131 | ||
132 | DEFUN (debug_ripng_zebra, | |
133 | debug_ripng_zebra_cmd, | |
134 | "debug ripng zebra", | |
135 | DEBUG_STR | |
136 | "RIPng configuration\n" | |
137 | "Debug option set for ripng and zebra communication\n") | |
138 | { | |
139 | ripng_debug_zebra = RIPNG_DEBUG_ZEBRA; | |
140 | return CMD_WARNING; | |
141 | } | |
142 | ||
143 | DEFUN (no_debug_ripng_events, | |
144 | no_debug_ripng_events_cmd, | |
145 | "no debug ripng events", | |
146 | NO_STR | |
147 | DEBUG_STR | |
148 | "RIPng configuration\n" | |
149 | "Debug option set for ripng events\n") | |
150 | { | |
151 | ripng_debug_event = 0; | |
152 | return CMD_SUCCESS; | |
153 | } | |
154 | ||
155 | DEFUN (no_debug_ripng_packet, | |
156 | no_debug_ripng_packet_cmd, | |
157 | "no debug ripng packet", | |
158 | NO_STR | |
159 | DEBUG_STR | |
160 | "RIPng configuration\n" | |
161 | "Debug option set for ripng packet\n") | |
162 | { | |
163 | ripng_debug_packet = 0; | |
164 | return CMD_SUCCESS; | |
165 | } | |
166 | ||
167 | DEFUN (no_debug_ripng_packet_direct, | |
168 | no_debug_ripng_packet_direct_cmd, | |
169 | "no debug ripng packet (recv|send)", | |
170 | NO_STR | |
171 | DEBUG_STR | |
172 | "RIPng configuration\n" | |
173 | "Debug option set for ripng packet\n" | |
174 | "Debug option set for receive packet\n" | |
175 | "Debug option set for send packet\n") | |
176 | { | |
177 | if (strncmp ("send", argv[0], strlen (argv[0])) == 0) | |
178 | { | |
179 | if (IS_RIPNG_DEBUG_RECV) | |
180 | ripng_debug_packet &= ~RIPNG_DEBUG_SEND; | |
181 | else | |
182 | ripng_debug_packet = 0; | |
183 | } | |
184 | else if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) | |
185 | { | |
186 | if (IS_RIPNG_DEBUG_SEND) | |
187 | ripng_debug_packet &= ~RIPNG_DEBUG_RECV; | |
188 | else | |
189 | ripng_debug_packet = 0; | |
190 | } | |
191 | return CMD_SUCCESS; | |
192 | } | |
193 | ||
194 | DEFUN (no_debug_ripng_zebra, | |
195 | no_debug_ripng_zebra_cmd, | |
196 | "no debug ripng zebra", | |
197 | NO_STR | |
198 | DEBUG_STR | |
199 | "RIPng configuration\n" | |
200 | "Debug option set for ripng and zebra communication\n") | |
201 | { | |
202 | ripng_debug_zebra = 0; | |
203 | return CMD_WARNING; | |
204 | } | |
205 | ||
206 | /* Debug node. */ | |
207 | struct cmd_node debug_node = | |
208 | { | |
209 | DEBUG_NODE, | |
a94434b6 | 210 | "", /* Debug node has no interface. */ |
211 | 1 /* VTYSH */ | |
718e3744 | 212 | }; |
213 | ||
214 | int | |
215 | config_write_debug (struct vty *vty) | |
216 | { | |
217 | int write = 0; | |
218 | ||
219 | if (IS_RIPNG_DEBUG_EVENT) | |
220 | { | |
221 | vty_out (vty, "debug ripng events%s", VTY_NEWLINE); | |
222 | write++; | |
223 | } | |
224 | if (IS_RIPNG_DEBUG_PACKET) | |
225 | { | |
226 | if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) | |
227 | { | |
228 | vty_out (vty, "debug ripng packet%s%s", | |
229 | IS_RIPNG_DEBUG_DETAIL ? " detail" : "", | |
230 | VTY_NEWLINE); | |
231 | write++; | |
232 | } | |
233 | else | |
234 | { | |
235 | if (IS_RIPNG_DEBUG_SEND) | |
236 | vty_out (vty, "debug ripng packet send%s%s", | |
237 | IS_RIPNG_DEBUG_DETAIL ? " detail" : "", | |
238 | VTY_NEWLINE); | |
239 | else | |
240 | vty_out (vty, "debug ripng packet recv%s%s", | |
241 | IS_RIPNG_DEBUG_DETAIL ? " detail" : "", | |
242 | VTY_NEWLINE); | |
243 | write++; | |
244 | } | |
245 | } | |
246 | if (IS_RIPNG_DEBUG_ZEBRA) | |
247 | { | |
248 | vty_out (vty, "debug ripng zebra%s", VTY_NEWLINE); | |
249 | write++; | |
250 | } | |
251 | return write; | |
252 | } | |
253 | ||
254 | void | |
255 | ripng_debug_reset () | |
256 | { | |
257 | ripng_debug_event = 0; | |
258 | ripng_debug_packet = 0; | |
259 | ripng_debug_zebra = 0; | |
260 | } | |
261 | ||
262 | void | |
263 | ripng_debug_init () | |
264 | { | |
265 | ripng_debug_event = 0; | |
266 | ripng_debug_packet = 0; | |
267 | ripng_debug_zebra = 0; | |
268 | ||
269 | install_node (&debug_node, config_write_debug); | |
270 | ||
271 | install_element (VIEW_NODE, &show_debugging_ripng_cmd); | |
272 | ||
273 | install_element (ENABLE_NODE, &show_debugging_ripng_cmd); | |
274 | install_element (ENABLE_NODE, &debug_ripng_events_cmd); | |
275 | install_element (ENABLE_NODE, &debug_ripng_packet_cmd); | |
276 | install_element (ENABLE_NODE, &debug_ripng_packet_direct_cmd); | |
277 | install_element (ENABLE_NODE, &debug_ripng_packet_detail_cmd); | |
278 | install_element (ENABLE_NODE, &debug_ripng_zebra_cmd); | |
279 | install_element (ENABLE_NODE, &no_debug_ripng_events_cmd); | |
280 | install_element (ENABLE_NODE, &no_debug_ripng_packet_cmd); | |
281 | install_element (ENABLE_NODE, &no_debug_ripng_packet_direct_cmd); | |
282 | install_element (ENABLE_NODE, &no_debug_ripng_zebra_cmd); | |
283 | ||
284 | install_element (CONFIG_NODE, &debug_ripng_events_cmd); | |
285 | install_element (CONFIG_NODE, &debug_ripng_packet_cmd); | |
286 | install_element (CONFIG_NODE, &debug_ripng_packet_direct_cmd); | |
287 | install_element (CONFIG_NODE, &debug_ripng_packet_detail_cmd); | |
288 | install_element (CONFIG_NODE, &debug_ripng_zebra_cmd); | |
289 | install_element (CONFIG_NODE, &no_debug_ripng_events_cmd); | |
290 | install_element (CONFIG_NODE, &no_debug_ripng_packet_cmd); | |
291 | install_element (CONFIG_NODE, &no_debug_ripng_packet_direct_cmd); | |
292 | install_element (CONFIG_NODE, &no_debug_ripng_zebra_cmd); | |
293 | } |