]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_debug.c
Merge pull request #13517 from Keelan10/ospf_ti_lfa-memory-leak
[mirror_frr.git] / ripngd / ripng_debug.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * RIPng debug output routines
4 * Copyright (C) 1998 Kunihiro Ishiguro
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;
15
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")
22 {
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 }
39 }
40
41 if (IS_RIPNG_DEBUG_ZEBRA)
42 vty_out(vty, " RIPng zebra debugging is on\n");
43
44 cmd_show_lib_debugs(vty);
45
46 return CMD_SUCCESS;
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 {
56 ripng_debug_event = RIPNG_DEBUG_EVENT;
57 return CMD_SUCCESS;
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 {
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;
71 }
72
73 DEFUN (debug_ripng_packet_direct,
74 debug_ripng_packet_direct_cmd,
75 "debug ripng packet <recv|send>",
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 {
82 int idx_recv_send = 3;
83 ripng_debug_packet |= RIPNG_DEBUG_PACKET;
84 if (strcmp("send", argv[idx_recv_send]->text) == 0)
85 ripng_debug_packet |= RIPNG_DEBUG_SEND;
86 if (strcmp("recv", argv[idx_recv_send]->text) == 0)
87 ripng_debug_packet |= RIPNG_DEBUG_RECV;
88
89 return CMD_SUCCESS;
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 {
99 ripng_debug_zebra = RIPNG_DEBUG_ZEBRA;
100 return CMD_SUCCESS;
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 {
111 ripng_debug_event = 0;
112 return CMD_SUCCESS;
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 {
123 ripng_debug_packet = 0;
124 return CMD_SUCCESS;
125 }
126
127 DEFUN (no_debug_ripng_packet_direct,
128 no_debug_ripng_packet_direct_cmd,
129 "no debug ripng packet <recv|send>",
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 {
137 int idx_recv_send = 4;
138 if (strcmp("send", argv[idx_recv_send]->text) == 0) {
139 if (IS_RIPNG_DEBUG_RECV)
140 ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
141 else
142 ripng_debug_packet = 0;
143 } else if (strcmp("recv", argv[idx_recv_send]->text) == 0) {
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;
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 {
160 ripng_debug_zebra = 0;
161 return CMD_SUCCESS;
162 }
163
164 static int config_write_debug(struct vty *vty);
165 /* Debug node. */
166 static struct cmd_node debug_node = {
167 .name = "debug",
168 .node = DEBUG_NODE,
169 .prompt = "",
170 .config_write = config_write_debug,
171 };
172
173 static int config_write_debug(struct vty *vty)
174 {
175 int write = 0;
176
177 if (IS_RIPNG_DEBUG_EVENT) {
178 vty_out(vty, "debug ripng events\n");
179 write++;
180 }
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 }
192 }
193 if (IS_RIPNG_DEBUG_ZEBRA) {
194 vty_out(vty, "debug ripng zebra\n");
195 write++;
196 }
197 return write;
198 }
199
200 void ripng_debug_init(void)
201 {
202 ripng_debug_event = 0;
203 ripng_debug_packet = 0;
204 ripng_debug_zebra = 0;
205
206 install_node(&debug_node);
207
208 install_element(ENABLE_NODE, &show_debugging_ripng_cmd);
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);
227 }