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