1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * RIPng debug output routines
4 * Copyright (C) 1998 Kunihiro Ishiguro
9 #include "ripngd/ripng_debug.h"
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;
16 DEFUN_NOSH (show_debugging_ripng
,
17 show_debugging_ripng_cmd
,
18 "show debugging [ripng]",
21 "RIPng configuration\n")
23 vty_out(vty
, "RIPng debugging status:\n");
25 if (IS_RIPNG_DEBUG_EVENT
)
26 vty_out(vty
, " RIPng event debugging is on\n");
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");
32 if (IS_RIPNG_DEBUG_SEND
)
34 " RIPng packet send debugging is on\n");
37 " RIPng packet receive debugging is on\n");
41 if (IS_RIPNG_DEBUG_ZEBRA
)
42 vty_out(vty
, " RIPng zebra debugging is on\n");
44 cmd_show_lib_debugs(vty
);
49 DEFUN (debug_ripng_events
,
50 debug_ripng_events_cmd
,
53 "RIPng configuration\n"
54 "Debug option set for ripng events\n")
56 ripng_debug_event
= RIPNG_DEBUG_EVENT
;
60 DEFUN (debug_ripng_packet
,
61 debug_ripng_packet_cmd
,
64 "RIPng configuration\n"
65 "Debug option set for ripng packet\n")
67 ripng_debug_packet
= RIPNG_DEBUG_PACKET
;
68 ripng_debug_packet
|= RIPNG_DEBUG_SEND
;
69 ripng_debug_packet
|= RIPNG_DEBUG_RECV
;
73 DEFUN (debug_ripng_packet_direct
,
74 debug_ripng_packet_direct_cmd
,
75 "debug ripng packet <recv|send>",
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")
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
;
92 DEFUN (debug_ripng_zebra
,
93 debug_ripng_zebra_cmd
,
96 "RIPng configuration\n"
97 "Debug option set for ripng and zebra communication\n")
99 ripng_debug_zebra
= RIPNG_DEBUG_ZEBRA
;
103 DEFUN (no_debug_ripng_events
,
104 no_debug_ripng_events_cmd
,
105 "no debug ripng events",
108 "RIPng configuration\n"
109 "Debug option set for ripng events\n")
111 ripng_debug_event
= 0;
115 DEFUN (no_debug_ripng_packet
,
116 no_debug_ripng_packet_cmd
,
117 "no debug ripng packet",
120 "RIPng configuration\n"
121 "Debug option set for ripng packet\n")
123 ripng_debug_packet
= 0;
127 DEFUN (no_debug_ripng_packet_direct
,
128 no_debug_ripng_packet_direct_cmd
,
129 "no debug ripng packet <recv|send>",
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")
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
;
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
;
147 ripng_debug_packet
= 0;
152 DEFUN (no_debug_ripng_zebra
,
153 no_debug_ripng_zebra_cmd
,
154 "no debug ripng zebra",
157 "RIPng configuration\n"
158 "Debug option set for ripng and zebra communication\n")
160 ripng_debug_zebra
= 0;
164 static int config_write_debug(struct vty
*vty
);
166 static struct cmd_node debug_node
= {
170 .config_write
= config_write_debug
,
173 static int config_write_debug(struct vty
*vty
)
177 if (IS_RIPNG_DEBUG_EVENT
) {
178 vty_out(vty
, "debug ripng events\n");
181 if (IS_RIPNG_DEBUG_PACKET
) {
182 if (IS_RIPNG_DEBUG_SEND
&& IS_RIPNG_DEBUG_RECV
) {
183 vty_out(vty
, "debug ripng packet\n");
186 if (IS_RIPNG_DEBUG_SEND
)
187 vty_out(vty
, "debug ripng packet send\n");
189 vty_out(vty
, "debug ripng packet recv\n");
193 if (IS_RIPNG_DEBUG_ZEBRA
) {
194 vty_out(vty
, "debug ripng zebra\n");
200 void ripng_debug_init(void)
202 ripng_debug_event
= 0;
203 ripng_debug_packet
= 0;
204 ripng_debug_zebra
= 0;
206 install_node(&debug_node
);
208 install_element(ENABLE_NODE
, &show_debugging_ripng_cmd
);
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
);
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
);