]>
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 | |
87f6dc50 DS |
30 | DEFUN_NOSH (show_debugging_rip, |
31 | show_debugging_rip_cmd, | |
32 | "show debugging [rip]", | |
33 | SHOW_STR | |
34 | DEBUG_STR | |
35 | RIP_STR) | |
718e3744 | 36 | { |
d62a17ae | 37 | vty_out(vty, "RIP debugging status:\n"); |
38 | ||
39 | if (IS_RIP_DEBUG_EVENT) | |
40 | vty_out(vty, " RIP event debugging is on\n"); | |
41 | ||
42 | if (IS_RIP_DEBUG_PACKET) { | |
43 | if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) { | |
44 | vty_out(vty, " RIP packet debugging is on\n"); | |
45 | } else { | |
46 | if (IS_RIP_DEBUG_SEND) | |
47 | vty_out(vty, | |
48 | " RIP packet send debugging is on\n"); | |
49 | else | |
50 | vty_out(vty, | |
51 | " RIP packet receive debugging is on\n"); | |
52 | } | |
718e3744 | 53 | } |
718e3744 | 54 | |
d62a17ae | 55 | if (IS_RIP_DEBUG_ZEBRA) |
56 | vty_out(vty, " RIP zebra debugging is on\n"); | |
718e3744 | 57 | |
d62a17ae | 58 | return CMD_SUCCESS; |
718e3744 | 59 | } |
60 | ||
61 | DEFUN (debug_rip_events, | |
62 | debug_rip_events_cmd, | |
63 | "debug rip events", | |
64 | DEBUG_STR | |
65 | RIP_STR | |
66 | "RIP events\n") | |
67 | { | |
d62a17ae | 68 | rip_debug_event = RIP_DEBUG_EVENT; |
9c9d843b | 69 | return CMD_SUCCESS; |
718e3744 | 70 | } |
71 | ||
72 | DEFUN (debug_rip_packet, | |
73 | debug_rip_packet_cmd, | |
74 | "debug rip packet", | |
75 | DEBUG_STR | |
76 | RIP_STR | |
77 | "RIP packet\n") | |
78 | { | |
d62a17ae | 79 | rip_debug_packet = RIP_DEBUG_PACKET; |
80 | rip_debug_packet |= RIP_DEBUG_SEND; | |
81 | rip_debug_packet |= RIP_DEBUG_RECV; | |
82 | return CMD_SUCCESS; | |
718e3744 | 83 | } |
84 | ||
85 | DEFUN (debug_rip_packet_direct, | |
86 | debug_rip_packet_direct_cmd, | |
6147e2c6 | 87 | "debug rip packet <recv|send>", |
718e3744 | 88 | DEBUG_STR |
89 | RIP_STR | |
90 | "RIP packet\n" | |
91 | "RIP receive packet\n" | |
92 | "RIP send packet\n") | |
93 | { | |
d62a17ae | 94 | int idx_recv_send = 3; |
95 | rip_debug_packet |= RIP_DEBUG_PACKET; | |
8034beff | 96 | if (strcmp("send", argv[idx_recv_send]->text) == 0) |
d62a17ae | 97 | rip_debug_packet |= RIP_DEBUG_SEND; |
8034beff | 98 | if (strcmp("recv", argv[idx_recv_send]->text) == 0) |
d62a17ae | 99 | rip_debug_packet |= RIP_DEBUG_RECV; |
100 | return CMD_SUCCESS; | |
718e3744 | 101 | } |
102 | ||
718e3744 | 103 | DEFUN (debug_rip_zebra, |
104 | debug_rip_zebra_cmd, | |
105 | "debug rip zebra", | |
106 | DEBUG_STR | |
107 | RIP_STR | |
108 | "RIP and ZEBRA communication\n") | |
109 | { | |
d62a17ae | 110 | rip_debug_zebra = RIP_DEBUG_ZEBRA; |
9c9d843b | 111 | return CMD_SUCCESS; |
718e3744 | 112 | } |
113 | ||
114 | DEFUN (no_debug_rip_events, | |
115 | no_debug_rip_events_cmd, | |
116 | "no debug rip events", | |
117 | NO_STR | |
118 | DEBUG_STR | |
119 | RIP_STR | |
120 | "RIP events\n") | |
121 | { | |
d62a17ae | 122 | rip_debug_event = 0; |
123 | return CMD_SUCCESS; | |
718e3744 | 124 | } |
125 | ||
126 | DEFUN (no_debug_rip_packet, | |
127 | no_debug_rip_packet_cmd, | |
128 | "no debug rip packet", | |
129 | NO_STR | |
130 | DEBUG_STR | |
131 | RIP_STR | |
132 | "RIP packet\n") | |
133 | { | |
d62a17ae | 134 | rip_debug_packet = 0; |
135 | return CMD_SUCCESS; | |
718e3744 | 136 | } |
137 | ||
138 | DEFUN (no_debug_rip_packet_direct, | |
139 | no_debug_rip_packet_direct_cmd, | |
6147e2c6 | 140 | "no debug rip packet <recv|send>", |
718e3744 | 141 | NO_STR |
142 | DEBUG_STR | |
143 | RIP_STR | |
144 | "RIP packet\n" | |
145 | "RIP option set for receive packet\n" | |
146 | "RIP option set for send packet\n") | |
147 | { | |
d62a17ae | 148 | int idx_recv_send = 4; |
8034beff | 149 | if (strcmp("send", argv[idx_recv_send]->text) == 0) { |
d62a17ae | 150 | if (IS_RIP_DEBUG_RECV) |
151 | rip_debug_packet &= ~RIP_DEBUG_SEND; | |
152 | else | |
153 | rip_debug_packet = 0; | |
8034beff | 154 | } else if (strcmp("recv", argv[idx_recv_send]->text) == 0) { |
d62a17ae | 155 | if (IS_RIP_DEBUG_SEND) |
156 | rip_debug_packet &= ~RIP_DEBUG_RECV; | |
157 | else | |
158 | rip_debug_packet = 0; | |
159 | } | |
160 | return CMD_SUCCESS; | |
718e3744 | 161 | } |
162 | ||
163 | DEFUN (no_debug_rip_zebra, | |
164 | no_debug_rip_zebra_cmd, | |
165 | "no debug rip zebra", | |
166 | NO_STR | |
167 | DEBUG_STR | |
168 | RIP_STR | |
169 | "RIP and ZEBRA communication\n") | |
170 | { | |
d62a17ae | 171 | rip_debug_zebra = 0; |
9c9d843b | 172 | return CMD_SUCCESS; |
718e3744 | 173 | } |
174 | ||
175 | /* Debug node. */ | |
d62a17ae | 176 | static struct cmd_node debug_node = {DEBUG_NODE, |
177 | "", /* Debug node has no interface. */ | |
178 | 1}; | |
718e3744 | 179 | |
d62a17ae | 180 | static int config_write_debug(struct vty *vty) |
718e3744 | 181 | { |
d62a17ae | 182 | int write = 0; |
718e3744 | 183 | |
d62a17ae | 184 | if (IS_RIP_DEBUG_EVENT) { |
185 | vty_out(vty, "debug rip events\n"); | |
186 | write++; | |
718e3744 | 187 | } |
d62a17ae | 188 | if (IS_RIP_DEBUG_PACKET) { |
189 | if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) { | |
190 | vty_out(vty, "debug rip packet\n"); | |
191 | write++; | |
192 | } else { | |
193 | if (IS_RIP_DEBUG_SEND) | |
194 | vty_out(vty, "debug rip packet send\n"); | |
195 | else | |
196 | vty_out(vty, "debug rip packet recv\n"); | |
197 | write++; | |
198 | } | |
718e3744 | 199 | } |
d62a17ae | 200 | if (IS_RIP_DEBUG_ZEBRA) { |
201 | vty_out(vty, "debug rip zebra\n"); | |
202 | write++; | |
203 | } | |
204 | return write; | |
718e3744 | 205 | } |
206 | ||
d62a17ae | 207 | void rip_debug_reset(void) |
718e3744 | 208 | { |
d62a17ae | 209 | rip_debug_event = 0; |
210 | rip_debug_packet = 0; | |
211 | rip_debug_zebra = 0; | |
718e3744 | 212 | } |
213 | ||
d62a17ae | 214 | void rip_debug_init(void) |
718e3744 | 215 | { |
d62a17ae | 216 | rip_debug_event = 0; |
217 | rip_debug_packet = 0; | |
218 | rip_debug_zebra = 0; | |
219 | ||
220 | install_node(&debug_node, config_write_debug); | |
221 | ||
222 | install_element(ENABLE_NODE, &show_debugging_rip_cmd); | |
223 | install_element(ENABLE_NODE, &debug_rip_events_cmd); | |
224 | install_element(ENABLE_NODE, &debug_rip_packet_cmd); | |
225 | install_element(ENABLE_NODE, &debug_rip_packet_direct_cmd); | |
226 | install_element(ENABLE_NODE, &debug_rip_zebra_cmd); | |
227 | install_element(ENABLE_NODE, &no_debug_rip_events_cmd); | |
228 | install_element(ENABLE_NODE, &no_debug_rip_packet_cmd); | |
229 | install_element(ENABLE_NODE, &no_debug_rip_packet_direct_cmd); | |
230 | install_element(ENABLE_NODE, &no_debug_rip_zebra_cmd); | |
231 | ||
232 | install_element(CONFIG_NODE, &debug_rip_events_cmd); | |
233 | install_element(CONFIG_NODE, &debug_rip_packet_cmd); | |
234 | install_element(CONFIG_NODE, &debug_rip_packet_direct_cmd); | |
235 | install_element(CONFIG_NODE, &debug_rip_zebra_cmd); | |
236 | install_element(CONFIG_NODE, &no_debug_rip_events_cmd); | |
237 | install_element(CONFIG_NODE, &no_debug_rip_packet_cmd); | |
238 | install_element(CONFIG_NODE, &no_debug_rip_packet_direct_cmd); | |
239 | install_element(CONFIG_NODE, &no_debug_rip_zebra_cmd); | |
718e3744 | 240 | } |