]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* RIP debug routines |
2 | * Copyright (C) 1999 Kunihiro Ishiguro <kunihiro@zebra.org> | |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with GNU Zebra; see the file COPYING. If not, write to the Free | |
18 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 | * 02111-1307, USA. | |
20 | */ | |
21 | ||
22 | #include <zebra.h> | |
23 | #include "command.h" | |
24 | #include "ripd/rip_debug.h" | |
25 | ||
26 | /* For debug statement. */ | |
27 | unsigned long rip_debug_event = 0; | |
28 | unsigned long rip_debug_packet = 0; | |
29 | unsigned long rip_debug_zebra = 0; | |
6b0655a2 | 30 | |
718e3744 | 31 | DEFUN (show_debugging_rip, |
32 | show_debugging_rip_cmd, | |
33 | "show debugging rip", | |
34 | SHOW_STR | |
35 | DEBUG_STR | |
36 | RIP_STR) | |
37 | { | |
df43a137 | 38 | vty_out (vty, "RIP debugging status:%s", VTY_NEWLINE); |
718e3744 | 39 | |
40 | if (IS_RIP_DEBUG_EVENT) | |
41 | vty_out (vty, " RIP event debugging is on%s", VTY_NEWLINE); | |
42 | ||
43 | if (IS_RIP_DEBUG_PACKET) | |
44 | { | |
45 | if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) | |
46 | { | |
0fa03353 | 47 | vty_out (vty, " RIP packet debugging is on%s", |
718e3744 | 48 | VTY_NEWLINE); |
49 | } | |
50 | else | |
51 | { | |
52 | if (IS_RIP_DEBUG_SEND) | |
0fa03353 | 53 | vty_out (vty, " RIP packet send debugging is on%s", |
718e3744 | 54 | VTY_NEWLINE); |
55 | else | |
0fa03353 | 56 | vty_out (vty, " RIP packet receive debugging is on%s", |
718e3744 | 57 | VTY_NEWLINE); |
58 | } | |
59 | } | |
60 | ||
61 | if (IS_RIP_DEBUG_ZEBRA) | |
62 | vty_out (vty, " RIP zebra debugging is on%s", VTY_NEWLINE); | |
63 | ||
64 | return CMD_SUCCESS; | |
65 | } | |
66 | ||
67 | DEFUN (debug_rip_events, | |
68 | debug_rip_events_cmd, | |
69 | "debug rip events", | |
70 | DEBUG_STR | |
71 | RIP_STR | |
72 | "RIP events\n") | |
73 | { | |
74 | rip_debug_event = RIP_DEBUG_EVENT; | |
75 | return CMD_WARNING; | |
76 | } | |
77 | ||
78 | DEFUN (debug_rip_packet, | |
79 | debug_rip_packet_cmd, | |
80 | "debug rip packet", | |
81 | DEBUG_STR | |
82 | RIP_STR | |
83 | "RIP packet\n") | |
84 | { | |
85 | rip_debug_packet = RIP_DEBUG_PACKET; | |
86 | rip_debug_packet |= RIP_DEBUG_SEND; | |
87 | rip_debug_packet |= RIP_DEBUG_RECV; | |
88 | return CMD_SUCCESS; | |
89 | } | |
90 | ||
91 | DEFUN (debug_rip_packet_direct, | |
92 | debug_rip_packet_direct_cmd, | |
6147e2c6 | 93 | "debug rip packet <recv|send>", |
718e3744 | 94 | DEBUG_STR |
95 | RIP_STR | |
96 | "RIP packet\n" | |
97 | "RIP receive packet\n" | |
98 | "RIP send packet\n") | |
99 | { | |
80fa0c69 | 100 | int idx_recv_send = 3; |
718e3744 | 101 | rip_debug_packet |= RIP_DEBUG_PACKET; |
80fa0c69 | 102 | if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) |
718e3744 | 103 | rip_debug_packet |= RIP_DEBUG_SEND; |
80fa0c69 | 104 | if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) |
718e3744 | 105 | rip_debug_packet |= RIP_DEBUG_RECV; |
718e3744 | 106 | return CMD_SUCCESS; |
107 | } | |
108 | ||
718e3744 | 109 | DEFUN (debug_rip_zebra, |
110 | debug_rip_zebra_cmd, | |
111 | "debug rip zebra", | |
112 | DEBUG_STR | |
113 | RIP_STR | |
114 | "RIP and ZEBRA communication\n") | |
115 | { | |
116 | rip_debug_zebra = RIP_DEBUG_ZEBRA; | |
117 | return CMD_WARNING; | |
118 | } | |
119 | ||
120 | DEFUN (no_debug_rip_events, | |
121 | no_debug_rip_events_cmd, | |
122 | "no debug rip events", | |
123 | NO_STR | |
124 | DEBUG_STR | |
125 | RIP_STR | |
126 | "RIP events\n") | |
127 | { | |
128 | rip_debug_event = 0; | |
129 | return CMD_SUCCESS; | |
130 | } | |
131 | ||
132 | DEFUN (no_debug_rip_packet, | |
133 | no_debug_rip_packet_cmd, | |
134 | "no debug rip packet", | |
135 | NO_STR | |
136 | DEBUG_STR | |
137 | RIP_STR | |
138 | "RIP packet\n") | |
139 | { | |
140 | rip_debug_packet = 0; | |
141 | return CMD_SUCCESS; | |
142 | } | |
143 | ||
144 | DEFUN (no_debug_rip_packet_direct, | |
145 | no_debug_rip_packet_direct_cmd, | |
6147e2c6 | 146 | "no debug rip packet <recv|send>", |
718e3744 | 147 | NO_STR |
148 | DEBUG_STR | |
149 | RIP_STR | |
150 | "RIP packet\n" | |
151 | "RIP option set for receive packet\n" | |
152 | "RIP option set for send packet\n") | |
153 | { | |
80fa0c69 DW |
154 | int idx_recv_send = 4; |
155 | if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) | |
718e3744 | 156 | { |
157 | if (IS_RIP_DEBUG_RECV) | |
158 | rip_debug_packet &= ~RIP_DEBUG_SEND; | |
159 | else | |
160 | rip_debug_packet = 0; | |
161 | } | |
80fa0c69 | 162 | else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) |
718e3744 | 163 | { |
164 | if (IS_RIP_DEBUG_SEND) | |
165 | rip_debug_packet &= ~RIP_DEBUG_RECV; | |
166 | else | |
167 | rip_debug_packet = 0; | |
168 | } | |
169 | return CMD_SUCCESS; | |
170 | } | |
171 | ||
172 | DEFUN (no_debug_rip_zebra, | |
173 | no_debug_rip_zebra_cmd, | |
174 | "no debug rip zebra", | |
175 | NO_STR | |
176 | DEBUG_STR | |
177 | RIP_STR | |
178 | "RIP and ZEBRA communication\n") | |
179 | { | |
180 | rip_debug_zebra = 0; | |
181 | return CMD_WARNING; | |
182 | } | |
183 | ||
184 | /* Debug node. */ | |
7fc626de | 185 | static struct cmd_node debug_node = |
718e3744 | 186 | { |
187 | DEBUG_NODE, | |
188 | "", /* Debug node has no interface. */ | |
189 | 1 | |
190 | }; | |
191 | ||
dc63bfd4 | 192 | static int |
718e3744 | 193 | config_write_debug (struct vty *vty) |
194 | { | |
195 | int write = 0; | |
196 | ||
197 | if (IS_RIP_DEBUG_EVENT) | |
198 | { | |
199 | vty_out (vty, "debug rip events%s", VTY_NEWLINE); | |
200 | write++; | |
201 | } | |
202 | if (IS_RIP_DEBUG_PACKET) | |
203 | { | |
204 | if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) | |
205 | { | |
0fa03353 | 206 | vty_out (vty, "debug rip packet%s", |
718e3744 | 207 | VTY_NEWLINE); |
208 | write++; | |
209 | } | |
210 | else | |
211 | { | |
212 | if (IS_RIP_DEBUG_SEND) | |
0fa03353 | 213 | vty_out (vty, "debug rip packet send%s", |
718e3744 | 214 | VTY_NEWLINE); |
215 | else | |
0fa03353 | 216 | vty_out (vty, "debug rip packet recv%s", |
718e3744 | 217 | VTY_NEWLINE); |
218 | write++; | |
219 | } | |
220 | } | |
221 | if (IS_RIP_DEBUG_ZEBRA) | |
222 | { | |
223 | vty_out (vty, "debug rip zebra%s", VTY_NEWLINE); | |
224 | write++; | |
225 | } | |
226 | return write; | |
227 | } | |
228 | ||
229 | void | |
dc63bfd4 | 230 | rip_debug_reset (void) |
718e3744 | 231 | { |
232 | rip_debug_event = 0; | |
233 | rip_debug_packet = 0; | |
234 | rip_debug_zebra = 0; | |
235 | } | |
236 | ||
237 | void | |
dc63bfd4 | 238 | rip_debug_init (void) |
718e3744 | 239 | { |
240 | rip_debug_event = 0; | |
241 | rip_debug_packet = 0; | |
242 | rip_debug_zebra = 0; | |
243 | ||
244 | install_node (&debug_node, config_write_debug); | |
245 | ||
246 | install_element (ENABLE_NODE, &show_debugging_rip_cmd); | |
247 | install_element (ENABLE_NODE, &debug_rip_events_cmd); | |
248 | install_element (ENABLE_NODE, &debug_rip_packet_cmd); | |
249 | install_element (ENABLE_NODE, &debug_rip_packet_direct_cmd); | |
718e3744 | 250 | install_element (ENABLE_NODE, &debug_rip_zebra_cmd); |
251 | install_element (ENABLE_NODE, &no_debug_rip_events_cmd); | |
252 | install_element (ENABLE_NODE, &no_debug_rip_packet_cmd); | |
253 | install_element (ENABLE_NODE, &no_debug_rip_packet_direct_cmd); | |
254 | install_element (ENABLE_NODE, &no_debug_rip_zebra_cmd); | |
255 | ||
256 | install_element (CONFIG_NODE, &debug_rip_events_cmd); | |
257 | install_element (CONFIG_NODE, &debug_rip_packet_cmd); | |
258 | install_element (CONFIG_NODE, &debug_rip_packet_direct_cmd); | |
718e3744 | 259 | install_element (CONFIG_NODE, &debug_rip_zebra_cmd); |
260 | install_element (CONFIG_NODE, &no_debug_rip_events_cmd); | |
261 | install_element (CONFIG_NODE, &no_debug_rip_packet_cmd); | |
262 | install_element (CONFIG_NODE, &no_debug_rip_packet_direct_cmd); | |
263 | install_element (CONFIG_NODE, &no_debug_rip_zebra_cmd); | |
264 | } |