]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_debug.c
Merge branch 'master' into dev-master
[mirror_frr.git] / ripngd / ripng_debug.c
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 along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <zebra.h>
23 #include "command.h"
24 #include "ripngd/ripng_debug.h"
25
26 /* For debug statement. */
27 unsigned long ripng_debug_event = 0;
28 unsigned long ripng_debug_packet = 0;
29 unsigned long ripng_debug_zebra = 0;
30
31 DEFUN_NOSH (show_debugging_ripng,
32 show_debugging_ripng_cmd,
33 "show debugging [ripng]",
34 SHOW_STR
35 DEBUG_STR
36 "RIPng configuration\n")
37 {
38 vty_out(vty, "RIPng debugging status:\n");
39
40 if (IS_RIPNG_DEBUG_EVENT)
41 vty_out(vty, " RIPng event debugging is on\n");
42
43 if (IS_RIPNG_DEBUG_PACKET) {
44 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) {
45 vty_out(vty, " RIPng packet debugging is on\n");
46 } else {
47 if (IS_RIPNG_DEBUG_SEND)
48 vty_out(vty,
49 " RIPng packet send debugging is on\n");
50 else
51 vty_out(vty,
52 " RIPng packet receive debugging is on\n");
53 }
54 }
55
56 if (IS_RIPNG_DEBUG_ZEBRA)
57 vty_out(vty, " RIPng zebra debugging is on\n");
58
59 return CMD_SUCCESS;
60 }
61
62 DEFUN (debug_ripng_events,
63 debug_ripng_events_cmd,
64 "debug ripng events",
65 DEBUG_STR
66 "RIPng configuration\n"
67 "Debug option set for ripng events\n")
68 {
69 ripng_debug_event = RIPNG_DEBUG_EVENT;
70 return CMD_SUCCESS;
71 }
72
73 DEFUN (debug_ripng_packet,
74 debug_ripng_packet_cmd,
75 "debug ripng packet",
76 DEBUG_STR
77 "RIPng configuration\n"
78 "Debug option set for ripng packet\n")
79 {
80 ripng_debug_packet = RIPNG_DEBUG_PACKET;
81 ripng_debug_packet |= RIPNG_DEBUG_SEND;
82 ripng_debug_packet |= RIPNG_DEBUG_RECV;
83 return CMD_SUCCESS;
84 }
85
86 DEFUN (debug_ripng_packet_direct,
87 debug_ripng_packet_direct_cmd,
88 "debug ripng packet <recv|send>",
89 DEBUG_STR
90 "RIPng configuration\n"
91 "Debug option set for ripng packet\n"
92 "Debug option set for receive packet\n"
93 "Debug option set for send packet\n")
94 {
95 int idx_recv_send = 3;
96 ripng_debug_packet |= RIPNG_DEBUG_PACKET;
97 if (strncmp("send", argv[idx_recv_send]->arg,
98 strlen(argv[idx_recv_send]->arg))
99 == 0)
100 ripng_debug_packet |= RIPNG_DEBUG_SEND;
101 if (strncmp("recv", argv[idx_recv_send]->arg,
102 strlen(argv[idx_recv_send]->arg))
103 == 0)
104 ripng_debug_packet |= RIPNG_DEBUG_RECV;
105
106 return CMD_SUCCESS;
107 }
108
109 DEFUN (debug_ripng_zebra,
110 debug_ripng_zebra_cmd,
111 "debug ripng zebra",
112 DEBUG_STR
113 "RIPng configuration\n"
114 "Debug option set for ripng and zebra communication\n")
115 {
116 ripng_debug_zebra = RIPNG_DEBUG_ZEBRA;
117 return CMD_SUCCESS;
118 }
119
120 DEFUN (no_debug_ripng_events,
121 no_debug_ripng_events_cmd,
122 "no debug ripng events",
123 NO_STR
124 DEBUG_STR
125 "RIPng configuration\n"
126 "Debug option set for ripng events\n")
127 {
128 ripng_debug_event = 0;
129 return CMD_SUCCESS;
130 }
131
132 DEFUN (no_debug_ripng_packet,
133 no_debug_ripng_packet_cmd,
134 "no debug ripng packet",
135 NO_STR
136 DEBUG_STR
137 "RIPng configuration\n"
138 "Debug option set for ripng packet\n")
139 {
140 ripng_debug_packet = 0;
141 return CMD_SUCCESS;
142 }
143
144 DEFUN (no_debug_ripng_packet_direct,
145 no_debug_ripng_packet_direct_cmd,
146 "no debug ripng packet <recv|send>",
147 NO_STR
148 DEBUG_STR
149 "RIPng configuration\n"
150 "Debug option set for ripng packet\n"
151 "Debug option set for receive packet\n"
152 "Debug option set for send packet\n")
153 {
154 int idx_recv_send = 4;
155 if (strncmp("send", argv[idx_recv_send]->arg,
156 strlen(argv[idx_recv_send]->arg))
157 == 0) {
158 if (IS_RIPNG_DEBUG_RECV)
159 ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
160 else
161 ripng_debug_packet = 0;
162 } else if (strncmp("recv", argv[idx_recv_send]->arg,
163 strlen(argv[idx_recv_send]->arg))
164 == 0) {
165 if (IS_RIPNG_DEBUG_SEND)
166 ripng_debug_packet &= ~RIPNG_DEBUG_RECV;
167 else
168 ripng_debug_packet = 0;
169 }
170 return CMD_SUCCESS;
171 }
172
173 DEFUN (no_debug_ripng_zebra,
174 no_debug_ripng_zebra_cmd,
175 "no debug ripng zebra",
176 NO_STR
177 DEBUG_STR
178 "RIPng configuration\n"
179 "Debug option set for ripng and zebra communication\n")
180 {
181 ripng_debug_zebra = 0;
182 return CMD_SUCCESS;
183 }
184
185 /* Debug node. */
186 static struct cmd_node debug_node = {
187 DEBUG_NODE, "", /* Debug node has no interface. */
188 1 /* VTYSH */
189 };
190
191 static int config_write_debug(struct vty *vty)
192 {
193 int write = 0;
194
195 if (IS_RIPNG_DEBUG_EVENT) {
196 vty_out(vty, "debug ripng events\n");
197 write++;
198 }
199 if (IS_RIPNG_DEBUG_PACKET) {
200 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) {
201 vty_out(vty, "debug ripng packet\n");
202 write++;
203 } else {
204 if (IS_RIPNG_DEBUG_SEND)
205 vty_out(vty, "debug ripng packet send\n");
206 else
207 vty_out(vty, "debug ripng packet recv\n");
208 write++;
209 }
210 }
211 if (IS_RIPNG_DEBUG_ZEBRA) {
212 vty_out(vty, "debug ripng zebra\n");
213 write++;
214 }
215 return write;
216 }
217
218 void ripng_debug_reset()
219 {
220 ripng_debug_event = 0;
221 ripng_debug_packet = 0;
222 ripng_debug_zebra = 0;
223 }
224
225 void ripng_debug_init()
226 {
227 ripng_debug_event = 0;
228 ripng_debug_packet = 0;
229 ripng_debug_zebra = 0;
230
231 install_node(&debug_node, config_write_debug);
232
233 install_element(VIEW_NODE, &show_debugging_ripng_cmd);
234
235 install_element(ENABLE_NODE, &debug_ripng_events_cmd);
236 install_element(ENABLE_NODE, &debug_ripng_packet_cmd);
237 install_element(ENABLE_NODE, &debug_ripng_packet_direct_cmd);
238 install_element(ENABLE_NODE, &debug_ripng_zebra_cmd);
239 install_element(ENABLE_NODE, &no_debug_ripng_events_cmd);
240 install_element(ENABLE_NODE, &no_debug_ripng_packet_cmd);
241 install_element(ENABLE_NODE, &no_debug_ripng_packet_direct_cmd);
242 install_element(ENABLE_NODE, &no_debug_ripng_zebra_cmd);
243
244 install_element(CONFIG_NODE, &debug_ripng_events_cmd);
245 install_element(CONFIG_NODE, &debug_ripng_packet_cmd);
246 install_element(CONFIG_NODE, &debug_ripng_packet_direct_cmd);
247 install_element(CONFIG_NODE, &debug_ripng_zebra_cmd);
248 install_element(CONFIG_NODE, &no_debug_ripng_events_cmd);
249 install_element(CONFIG_NODE, &no_debug_ripng_packet_cmd);
250 install_element(CONFIG_NODE, &no_debug_ripng_packet_direct_cmd);
251 install_element(CONFIG_NODE, &no_debug_ripng_zebra_cmd);
252 }