]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
718e3744 | 2 | /* |
3 | * RIPng debug output routines | |
4 | * Copyright (C) 1998 Kunihiro Ishiguro | |
718e3744 | 5 | */ |
6 | ||
7 | #include <zebra.h> | |
8 | #include "command.h" | |
9 | #include "ripngd/ripng_debug.h" | |
10 | ||
11 | /* For debug statement. */ | |
12 | unsigned long ripng_debug_event = 0; | |
13 | unsigned long ripng_debug_packet = 0; | |
14 | unsigned long ripng_debug_zebra = 0; | |
6b0655a2 | 15 | |
87f6dc50 DS |
16 | DEFUN_NOSH (show_debugging_ripng, |
17 | show_debugging_ripng_cmd, | |
18 | "show debugging [ripng]", | |
19 | SHOW_STR | |
20 | DEBUG_STR | |
21 | "RIPng configuration\n") | |
718e3744 | 22 | { |
d62a17ae | 23 | vty_out(vty, "RIPng debugging status:\n"); |
24 | ||
25 | if (IS_RIPNG_DEBUG_EVENT) | |
26 | vty_out(vty, " RIPng event debugging is on\n"); | |
27 | ||
28 | if (IS_RIPNG_DEBUG_PACKET) { | |
29 | if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) { | |
30 | vty_out(vty, " RIPng packet debugging is on\n"); | |
31 | } else { | |
32 | if (IS_RIPNG_DEBUG_SEND) | |
33 | vty_out(vty, | |
34 | " RIPng packet send debugging is on\n"); | |
35 | else | |
36 | vty_out(vty, | |
37 | " RIPng packet receive debugging is on\n"); | |
38 | } | |
718e3744 | 39 | } |
718e3744 | 40 | |
d62a17ae | 41 | if (IS_RIPNG_DEBUG_ZEBRA) |
42 | vty_out(vty, " RIPng zebra debugging is on\n"); | |
718e3744 | 43 | |
cf00164b DS |
44 | cmd_show_lib_debugs(vty); |
45 | ||
d62a17ae | 46 | return CMD_SUCCESS; |
718e3744 | 47 | } |
48 | ||
49 | DEFUN (debug_ripng_events, | |
50 | debug_ripng_events_cmd, | |
51 | "debug ripng events", | |
52 | DEBUG_STR | |
53 | "RIPng configuration\n" | |
54 | "Debug option set for ripng events\n") | |
55 | { | |
d62a17ae | 56 | ripng_debug_event = RIPNG_DEBUG_EVENT; |
40e344cc | 57 | return CMD_SUCCESS; |
718e3744 | 58 | } |
59 | ||
60 | DEFUN (debug_ripng_packet, | |
61 | debug_ripng_packet_cmd, | |
62 | "debug ripng packet", | |
63 | DEBUG_STR | |
64 | "RIPng configuration\n" | |
65 | "Debug option set for ripng packet\n") | |
66 | { | |
d62a17ae | 67 | ripng_debug_packet = RIPNG_DEBUG_PACKET; |
68 | ripng_debug_packet |= RIPNG_DEBUG_SEND; | |
69 | ripng_debug_packet |= RIPNG_DEBUG_RECV; | |
70 | return CMD_SUCCESS; | |
718e3744 | 71 | } |
72 | ||
73 | DEFUN (debug_ripng_packet_direct, | |
74 | debug_ripng_packet_direct_cmd, | |
6147e2c6 | 75 | "debug ripng packet <recv|send>", |
718e3744 | 76 | DEBUG_STR |
77 | "RIPng configuration\n" | |
78 | "Debug option set for ripng packet\n" | |
79 | "Debug option set for receive packet\n" | |
80 | "Debug option set for send packet\n") | |
81 | { | |
d62a17ae | 82 | int idx_recv_send = 3; |
83 | ripng_debug_packet |= RIPNG_DEBUG_PACKET; | |
8034beff | 84 | if (strcmp("send", argv[idx_recv_send]->text) == 0) |
d62a17ae | 85 | ripng_debug_packet |= RIPNG_DEBUG_SEND; |
8034beff | 86 | if (strcmp("recv", argv[idx_recv_send]->text) == 0) |
d62a17ae | 87 | ripng_debug_packet |= RIPNG_DEBUG_RECV; |
88 | ||
89 | return CMD_SUCCESS; | |
718e3744 | 90 | } |
91 | ||
92 | DEFUN (debug_ripng_zebra, | |
93 | debug_ripng_zebra_cmd, | |
94 | "debug ripng zebra", | |
95 | DEBUG_STR | |
96 | "RIPng configuration\n" | |
97 | "Debug option set for ripng and zebra communication\n") | |
98 | { | |
d62a17ae | 99 | ripng_debug_zebra = RIPNG_DEBUG_ZEBRA; |
40e344cc | 100 | return CMD_SUCCESS; |
718e3744 | 101 | } |
102 | ||
103 | DEFUN (no_debug_ripng_events, | |
104 | no_debug_ripng_events_cmd, | |
105 | "no debug ripng events", | |
106 | NO_STR | |
107 | DEBUG_STR | |
108 | "RIPng configuration\n" | |
109 | "Debug option set for ripng events\n") | |
110 | { | |
d62a17ae | 111 | ripng_debug_event = 0; |
112 | return CMD_SUCCESS; | |
718e3744 | 113 | } |
114 | ||
115 | DEFUN (no_debug_ripng_packet, | |
116 | no_debug_ripng_packet_cmd, | |
117 | "no debug ripng packet", | |
118 | NO_STR | |
119 | DEBUG_STR | |
120 | "RIPng configuration\n" | |
121 | "Debug option set for ripng packet\n") | |
122 | { | |
d62a17ae | 123 | ripng_debug_packet = 0; |
124 | return CMD_SUCCESS; | |
718e3744 | 125 | } |
126 | ||
127 | DEFUN (no_debug_ripng_packet_direct, | |
128 | no_debug_ripng_packet_direct_cmd, | |
6147e2c6 | 129 | "no debug ripng packet <recv|send>", |
718e3744 | 130 | NO_STR |
131 | DEBUG_STR | |
132 | "RIPng configuration\n" | |
133 | "Debug option set for ripng packet\n" | |
134 | "Debug option set for receive packet\n" | |
135 | "Debug option set for send packet\n") | |
136 | { | |
d62a17ae | 137 | int idx_recv_send = 4; |
8034beff | 138 | if (strcmp("send", argv[idx_recv_send]->text) == 0) { |
d62a17ae | 139 | if (IS_RIPNG_DEBUG_RECV) |
140 | ripng_debug_packet &= ~RIPNG_DEBUG_SEND; | |
141 | else | |
142 | ripng_debug_packet = 0; | |
8034beff | 143 | } else if (strcmp("recv", argv[idx_recv_send]->text) == 0) { |
d62a17ae | 144 | if (IS_RIPNG_DEBUG_SEND) |
145 | ripng_debug_packet &= ~RIPNG_DEBUG_RECV; | |
146 | else | |
147 | ripng_debug_packet = 0; | |
148 | } | |
149 | return CMD_SUCCESS; | |
718e3744 | 150 | } |
151 | ||
152 | DEFUN (no_debug_ripng_zebra, | |
153 | no_debug_ripng_zebra_cmd, | |
154 | "no debug ripng zebra", | |
155 | NO_STR | |
156 | DEBUG_STR | |
157 | "RIPng configuration\n" | |
158 | "Debug option set for ripng and zebra communication\n") | |
159 | { | |
d62a17ae | 160 | ripng_debug_zebra = 0; |
40e344cc | 161 | return CMD_SUCCESS; |
718e3744 | 162 | } |
163 | ||
612c2c15 | 164 | static int config_write_debug(struct vty *vty); |
718e3744 | 165 | /* Debug node. */ |
d62a17ae | 166 | static struct cmd_node debug_node = { |
f4b8291f | 167 | .name = "debug", |
62b346ee DL |
168 | .node = DEBUG_NODE, |
169 | .prompt = "", | |
612c2c15 | 170 | .config_write = config_write_debug, |
718e3744 | 171 | }; |
172 | ||
d62a17ae | 173 | static int config_write_debug(struct vty *vty) |
718e3744 | 174 | { |
d62a17ae | 175 | int write = 0; |
718e3744 | 176 | |
d62a17ae | 177 | if (IS_RIPNG_DEBUG_EVENT) { |
178 | vty_out(vty, "debug ripng events\n"); | |
179 | write++; | |
718e3744 | 180 | } |
d62a17ae | 181 | if (IS_RIPNG_DEBUG_PACKET) { |
182 | if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) { | |
183 | vty_out(vty, "debug ripng packet\n"); | |
184 | write++; | |
185 | } else { | |
186 | if (IS_RIPNG_DEBUG_SEND) | |
187 | vty_out(vty, "debug ripng packet send\n"); | |
188 | else | |
189 | vty_out(vty, "debug ripng packet recv\n"); | |
190 | write++; | |
191 | } | |
718e3744 | 192 | } |
d62a17ae | 193 | if (IS_RIPNG_DEBUG_ZEBRA) { |
194 | vty_out(vty, "debug ripng zebra\n"); | |
195 | write++; | |
196 | } | |
197 | return write; | |
718e3744 | 198 | } |
199 | ||
4d762f26 | 200 | void ripng_debug_init(void) |
718e3744 | 201 | { |
d62a17ae | 202 | ripng_debug_event = 0; |
203 | ripng_debug_packet = 0; | |
204 | ripng_debug_zebra = 0; | |
205 | ||
612c2c15 | 206 | install_node(&debug_node); |
d62a17ae | 207 | |
dd73744d | 208 | install_element(ENABLE_NODE, &show_debugging_ripng_cmd); |
d62a17ae | 209 | |
210 | install_element(ENABLE_NODE, &debug_ripng_events_cmd); | |
211 | install_element(ENABLE_NODE, &debug_ripng_packet_cmd); | |
212 | install_element(ENABLE_NODE, &debug_ripng_packet_direct_cmd); | |
213 | install_element(ENABLE_NODE, &debug_ripng_zebra_cmd); | |
214 | install_element(ENABLE_NODE, &no_debug_ripng_events_cmd); | |
215 | install_element(ENABLE_NODE, &no_debug_ripng_packet_cmd); | |
216 | install_element(ENABLE_NODE, &no_debug_ripng_packet_direct_cmd); | |
217 | install_element(ENABLE_NODE, &no_debug_ripng_zebra_cmd); | |
218 | ||
219 | install_element(CONFIG_NODE, &debug_ripng_events_cmd); | |
220 | install_element(CONFIG_NODE, &debug_ripng_packet_cmd); | |
221 | install_element(CONFIG_NODE, &debug_ripng_packet_direct_cmd); | |
222 | install_element(CONFIG_NODE, &debug_ripng_zebra_cmd); | |
223 | install_element(CONFIG_NODE, &no_debug_ripng_events_cmd); | |
224 | install_element(CONFIG_NODE, &no_debug_ripng_packet_cmd); | |
225 | install_element(CONFIG_NODE, &no_debug_ripng_packet_direct_cmd); | |
226 | install_element(CONFIG_NODE, &no_debug_ripng_zebra_cmd); | |
718e3744 | 227 | } |