]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_debug.c
Merge pull request #8647 from sworleys/DVNI-Config-Changes
[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 cmd_show_lib_debugs(vty);
60
61 return CMD_SUCCESS;
62 }
63
64 DEFUN (debug_ripng_events,
65 debug_ripng_events_cmd,
66 "debug ripng events",
67 DEBUG_STR
68 "RIPng configuration\n"
69 "Debug option set for ripng events\n")
70 {
71 ripng_debug_event = RIPNG_DEBUG_EVENT;
72 return CMD_SUCCESS;
73 }
74
75 DEFUN (debug_ripng_packet,
76 debug_ripng_packet_cmd,
77 "debug ripng packet",
78 DEBUG_STR
79 "RIPng configuration\n"
80 "Debug option set for ripng packet\n")
81 {
82 ripng_debug_packet = RIPNG_DEBUG_PACKET;
83 ripng_debug_packet |= RIPNG_DEBUG_SEND;
84 ripng_debug_packet |= RIPNG_DEBUG_RECV;
85 return CMD_SUCCESS;
86 }
87
88 DEFUN (debug_ripng_packet_direct,
89 debug_ripng_packet_direct_cmd,
90 "debug ripng packet <recv|send>",
91 DEBUG_STR
92 "RIPng configuration\n"
93 "Debug option set for ripng packet\n"
94 "Debug option set for receive packet\n"
95 "Debug option set for send packet\n")
96 {
97 int idx_recv_send = 3;
98 ripng_debug_packet |= RIPNG_DEBUG_PACKET;
99 if (strcmp("send", argv[idx_recv_send]->text) == 0)
100 ripng_debug_packet |= RIPNG_DEBUG_SEND;
101 if (strcmp("recv", argv[idx_recv_send]->text) == 0)
102 ripng_debug_packet |= RIPNG_DEBUG_RECV;
103
104 return CMD_SUCCESS;
105 }
106
107 DEFUN (debug_ripng_zebra,
108 debug_ripng_zebra_cmd,
109 "debug ripng zebra",
110 DEBUG_STR
111 "RIPng configuration\n"
112 "Debug option set for ripng and zebra communication\n")
113 {
114 ripng_debug_zebra = RIPNG_DEBUG_ZEBRA;
115 return CMD_SUCCESS;
116 }
117
118 DEFUN (no_debug_ripng_events,
119 no_debug_ripng_events_cmd,
120 "no debug ripng events",
121 NO_STR
122 DEBUG_STR
123 "RIPng configuration\n"
124 "Debug option set for ripng events\n")
125 {
126 ripng_debug_event = 0;
127 return CMD_SUCCESS;
128 }
129
130 DEFUN (no_debug_ripng_packet,
131 no_debug_ripng_packet_cmd,
132 "no debug ripng packet",
133 NO_STR
134 DEBUG_STR
135 "RIPng configuration\n"
136 "Debug option set for ripng packet\n")
137 {
138 ripng_debug_packet = 0;
139 return CMD_SUCCESS;
140 }
141
142 DEFUN (no_debug_ripng_packet_direct,
143 no_debug_ripng_packet_direct_cmd,
144 "no debug ripng packet <recv|send>",
145 NO_STR
146 DEBUG_STR
147 "RIPng configuration\n"
148 "Debug option set for ripng packet\n"
149 "Debug option set for receive packet\n"
150 "Debug option set for send packet\n")
151 {
152 int idx_recv_send = 4;
153 if (strcmp("send", argv[idx_recv_send]->text) == 0) {
154 if (IS_RIPNG_DEBUG_RECV)
155 ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
156 else
157 ripng_debug_packet = 0;
158 } else if (strcmp("recv", argv[idx_recv_send]->text) == 0) {
159 if (IS_RIPNG_DEBUG_SEND)
160 ripng_debug_packet &= ~RIPNG_DEBUG_RECV;
161 else
162 ripng_debug_packet = 0;
163 }
164 return CMD_SUCCESS;
165 }
166
167 DEFUN (no_debug_ripng_zebra,
168 no_debug_ripng_zebra_cmd,
169 "no debug ripng zebra",
170 NO_STR
171 DEBUG_STR
172 "RIPng configuration\n"
173 "Debug option set for ripng and zebra communication\n")
174 {
175 ripng_debug_zebra = 0;
176 return CMD_SUCCESS;
177 }
178
179 static int config_write_debug(struct vty *vty);
180 /* Debug node. */
181 static struct cmd_node debug_node = {
182 .name = "debug",
183 .node = DEBUG_NODE,
184 .prompt = "",
185 .config_write = config_write_debug,
186 };
187
188 static int config_write_debug(struct vty *vty)
189 {
190 int write = 0;
191
192 if (IS_RIPNG_DEBUG_EVENT) {
193 vty_out(vty, "debug ripng events\n");
194 write++;
195 }
196 if (IS_RIPNG_DEBUG_PACKET) {
197 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) {
198 vty_out(vty, "debug ripng packet\n");
199 write++;
200 } else {
201 if (IS_RIPNG_DEBUG_SEND)
202 vty_out(vty, "debug ripng packet send\n");
203 else
204 vty_out(vty, "debug ripng packet recv\n");
205 write++;
206 }
207 }
208 if (IS_RIPNG_DEBUG_ZEBRA) {
209 vty_out(vty, "debug ripng zebra\n");
210 write++;
211 }
212 return write;
213 }
214
215 void ripng_debug_init(void)
216 {
217 ripng_debug_event = 0;
218 ripng_debug_packet = 0;
219 ripng_debug_zebra = 0;
220
221 install_node(&debug_node);
222
223 install_element(ENABLE_NODE, &show_debugging_ripng_cmd);
224
225 install_element(ENABLE_NODE, &debug_ripng_events_cmd);
226 install_element(ENABLE_NODE, &debug_ripng_packet_cmd);
227 install_element(ENABLE_NODE, &debug_ripng_packet_direct_cmd);
228 install_element(ENABLE_NODE, &debug_ripng_zebra_cmd);
229 install_element(ENABLE_NODE, &no_debug_ripng_events_cmd);
230 install_element(ENABLE_NODE, &no_debug_ripng_packet_cmd);
231 install_element(ENABLE_NODE, &no_debug_ripng_packet_direct_cmd);
232 install_element(ENABLE_NODE, &no_debug_ripng_zebra_cmd);
233
234 install_element(CONFIG_NODE, &debug_ripng_events_cmd);
235 install_element(CONFIG_NODE, &debug_ripng_packet_cmd);
236 install_element(CONFIG_NODE, &debug_ripng_packet_direct_cmd);
237 install_element(CONFIG_NODE, &debug_ripng_zebra_cmd);
238 install_element(CONFIG_NODE, &no_debug_ripng_events_cmd);
239 install_element(CONFIG_NODE, &no_debug_ripng_packet_cmd);
240 install_element(CONFIG_NODE, &no_debug_ripng_packet_direct_cmd);
241 install_element(CONFIG_NODE, &no_debug_ripng_zebra_cmd);
242 }