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