]>
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 | * | |
896014f4 DL |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 19 | */ |
20 | ||
21 | #include <zebra.h> | |
22 | #include "command.h" | |
23 | #include "ripd/rip_debug.h" | |
24 | ||
25 | /* For debug statement. */ | |
26 | unsigned long rip_debug_event = 0; | |
27 | unsigned long rip_debug_packet = 0; | |
28 | unsigned long rip_debug_zebra = 0; | |
6b0655a2 | 29 | |
718e3744 | 30 | DEFUN (show_debugging_rip, |
31 | show_debugging_rip_cmd, | |
32 | "show debugging rip", | |
33 | SHOW_STR | |
34 | DEBUG_STR | |
35 | RIP_STR) | |
36 | { | |
5c7571d4 | 37 | vty_out (vty, "RIP debugging status:\n"); |
718e3744 | 38 | |
39 | if (IS_RIP_DEBUG_EVENT) | |
5c7571d4 | 40 | vty_out (vty, " RIP event debugging is on\n"); |
718e3744 | 41 | |
42 | if (IS_RIP_DEBUG_PACKET) | |
43 | { | |
44 | if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) | |
45 | { | |
5c7571d4 | 46 | vty_out (vty," RIP packet debugging is on\n"); |
718e3744 | 47 | } |
48 | else | |
49 | { | |
50 | if (IS_RIP_DEBUG_SEND) | |
5c7571d4 | 51 | vty_out (vty," RIP packet send debugging is on\n"); |
718e3744 | 52 | else |
5c7571d4 | 53 | vty_out (vty," RIP packet receive debugging is on\n"); |
718e3744 | 54 | } |
55 | } | |
56 | ||
57 | if (IS_RIP_DEBUG_ZEBRA) | |
5c7571d4 | 58 | vty_out (vty, " RIP zebra debugging is on\n"); |
718e3744 | 59 | |
60 | return CMD_SUCCESS; | |
61 | } | |
62 | ||
63 | DEFUN (debug_rip_events, | |
64 | debug_rip_events_cmd, | |
65 | "debug rip events", | |
66 | DEBUG_STR | |
67 | RIP_STR | |
68 | "RIP events\n") | |
69 | { | |
70 | rip_debug_event = RIP_DEBUG_EVENT; | |
f1a05de9 | 71 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 72 | } |
73 | ||
74 | DEFUN (debug_rip_packet, | |
75 | debug_rip_packet_cmd, | |
76 | "debug rip packet", | |
77 | DEBUG_STR | |
78 | RIP_STR | |
79 | "RIP packet\n") | |
80 | { | |
81 | rip_debug_packet = RIP_DEBUG_PACKET; | |
82 | rip_debug_packet |= RIP_DEBUG_SEND; | |
83 | rip_debug_packet |= RIP_DEBUG_RECV; | |
84 | return CMD_SUCCESS; | |
85 | } | |
86 | ||
87 | DEFUN (debug_rip_packet_direct, | |
88 | debug_rip_packet_direct_cmd, | |
6147e2c6 | 89 | "debug rip packet <recv|send>", |
718e3744 | 90 | DEBUG_STR |
91 | RIP_STR | |
92 | "RIP packet\n" | |
93 | "RIP receive packet\n" | |
94 | "RIP send packet\n") | |
95 | { | |
80fa0c69 | 96 | int idx_recv_send = 3; |
718e3744 | 97 | rip_debug_packet |= RIP_DEBUG_PACKET; |
80fa0c69 | 98 | if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) |
718e3744 | 99 | rip_debug_packet |= RIP_DEBUG_SEND; |
80fa0c69 | 100 | if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) |
718e3744 | 101 | rip_debug_packet |= RIP_DEBUG_RECV; |
718e3744 | 102 | return CMD_SUCCESS; |
103 | } | |
104 | ||
718e3744 | 105 | DEFUN (debug_rip_zebra, |
106 | debug_rip_zebra_cmd, | |
107 | "debug rip zebra", | |
108 | DEBUG_STR | |
109 | RIP_STR | |
110 | "RIP and ZEBRA communication\n") | |
111 | { | |
112 | rip_debug_zebra = RIP_DEBUG_ZEBRA; | |
f1a05de9 | 113 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 114 | } |
115 | ||
116 | DEFUN (no_debug_rip_events, | |
117 | no_debug_rip_events_cmd, | |
118 | "no debug rip events", | |
119 | NO_STR | |
120 | DEBUG_STR | |
121 | RIP_STR | |
122 | "RIP events\n") | |
123 | { | |
124 | rip_debug_event = 0; | |
125 | return CMD_SUCCESS; | |
126 | } | |
127 | ||
128 | DEFUN (no_debug_rip_packet, | |
129 | no_debug_rip_packet_cmd, | |
130 | "no debug rip packet", | |
131 | NO_STR | |
132 | DEBUG_STR | |
133 | RIP_STR | |
134 | "RIP packet\n") | |
135 | { | |
136 | rip_debug_packet = 0; | |
137 | return CMD_SUCCESS; | |
138 | } | |
139 | ||
140 | DEFUN (no_debug_rip_packet_direct, | |
141 | no_debug_rip_packet_direct_cmd, | |
6147e2c6 | 142 | "no debug rip packet <recv|send>", |
718e3744 | 143 | NO_STR |
144 | DEBUG_STR | |
145 | RIP_STR | |
146 | "RIP packet\n" | |
147 | "RIP option set for receive packet\n" | |
148 | "RIP option set for send packet\n") | |
149 | { | |
80fa0c69 DW |
150 | int idx_recv_send = 4; |
151 | if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) | |
718e3744 | 152 | { |
153 | if (IS_RIP_DEBUG_RECV) | |
154 | rip_debug_packet &= ~RIP_DEBUG_SEND; | |
155 | else | |
156 | rip_debug_packet = 0; | |
157 | } | |
80fa0c69 | 158 | else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) |
718e3744 | 159 | { |
160 | if (IS_RIP_DEBUG_SEND) | |
161 | rip_debug_packet &= ~RIP_DEBUG_RECV; | |
162 | else | |
163 | rip_debug_packet = 0; | |
164 | } | |
165 | return CMD_SUCCESS; | |
166 | } | |
167 | ||
168 | DEFUN (no_debug_rip_zebra, | |
169 | no_debug_rip_zebra_cmd, | |
170 | "no debug rip zebra", | |
171 | NO_STR | |
172 | DEBUG_STR | |
173 | RIP_STR | |
174 | "RIP and ZEBRA communication\n") | |
175 | { | |
176 | rip_debug_zebra = 0; | |
f1a05de9 | 177 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 178 | } |
179 | ||
180 | /* Debug node. */ | |
7fc626de | 181 | static struct cmd_node debug_node = |
718e3744 | 182 | { |
183 | DEBUG_NODE, | |
184 | "", /* Debug node has no interface. */ | |
185 | 1 | |
186 | }; | |
187 | ||
dc63bfd4 | 188 | static int |
718e3744 | 189 | config_write_debug (struct vty *vty) |
190 | { | |
191 | int write = 0; | |
192 | ||
193 | if (IS_RIP_DEBUG_EVENT) | |
194 | { | |
5c7571d4 | 195 | vty_out (vty, "debug rip events\n"); |
718e3744 | 196 | write++; |
197 | } | |
198 | if (IS_RIP_DEBUG_PACKET) | |
199 | { | |
200 | if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) | |
201 | { | |
5c7571d4 | 202 | vty_out (vty,"debug rip packet\n"); |
718e3744 | 203 | write++; |
204 | } | |
205 | else | |
206 | { | |
207 | if (IS_RIP_DEBUG_SEND) | |
5c7571d4 | 208 | vty_out (vty,"debug rip packet send\n"); |
718e3744 | 209 | else |
5c7571d4 | 210 | vty_out (vty,"debug rip packet recv\n"); |
718e3744 | 211 | write++; |
212 | } | |
213 | } | |
214 | if (IS_RIP_DEBUG_ZEBRA) | |
215 | { | |
5c7571d4 | 216 | vty_out (vty, "debug rip zebra\n"); |
718e3744 | 217 | write++; |
218 | } | |
219 | return write; | |
220 | } | |
221 | ||
222 | void | |
dc63bfd4 | 223 | rip_debug_reset (void) |
718e3744 | 224 | { |
225 | rip_debug_event = 0; | |
226 | rip_debug_packet = 0; | |
227 | rip_debug_zebra = 0; | |
228 | } | |
229 | ||
230 | void | |
dc63bfd4 | 231 | rip_debug_init (void) |
718e3744 | 232 | { |
233 | rip_debug_event = 0; | |
234 | rip_debug_packet = 0; | |
235 | rip_debug_zebra = 0; | |
236 | ||
237 | install_node (&debug_node, config_write_debug); | |
238 | ||
239 | install_element (ENABLE_NODE, &show_debugging_rip_cmd); | |
240 | install_element (ENABLE_NODE, &debug_rip_events_cmd); | |
241 | install_element (ENABLE_NODE, &debug_rip_packet_cmd); | |
242 | install_element (ENABLE_NODE, &debug_rip_packet_direct_cmd); | |
718e3744 | 243 | install_element (ENABLE_NODE, &debug_rip_zebra_cmd); |
244 | install_element (ENABLE_NODE, &no_debug_rip_events_cmd); | |
245 | install_element (ENABLE_NODE, &no_debug_rip_packet_cmd); | |
246 | install_element (ENABLE_NODE, &no_debug_rip_packet_direct_cmd); | |
247 | install_element (ENABLE_NODE, &no_debug_rip_zebra_cmd); | |
248 | ||
249 | install_element (CONFIG_NODE, &debug_rip_events_cmd); | |
250 | install_element (CONFIG_NODE, &debug_rip_packet_cmd); | |
251 | install_element (CONFIG_NODE, &debug_rip_packet_direct_cmd); | |
718e3744 | 252 | install_element (CONFIG_NODE, &debug_rip_zebra_cmd); |
253 | install_element (CONFIG_NODE, &no_debug_rip_events_cmd); | |
254 | install_element (CONFIG_NODE, &no_debug_rip_packet_cmd); | |
255 | install_element (CONFIG_NODE, &no_debug_rip_packet_direct_cmd); | |
256 | install_element (CONFIG_NODE, &no_debug_rip_zebra_cmd); | |
257 | } |