1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
8 #include "ripd/rip_debug.h"
10 /* For debug statement. */
11 unsigned long rip_debug_event
= 0;
12 unsigned long rip_debug_packet
= 0;
13 unsigned long rip_debug_zebra
= 0;
15 DEFUN_NOSH (show_debugging_rip
,
16 show_debugging_rip_cmd
,
17 "show debugging [rip]",
22 vty_out(vty
, "RIP debugging status:\n");
24 if (IS_RIP_DEBUG_EVENT
)
25 vty_out(vty
, " RIP event debugging is on\n");
27 if (IS_RIP_DEBUG_PACKET
) {
28 if (IS_RIP_DEBUG_SEND
&& IS_RIP_DEBUG_RECV
) {
29 vty_out(vty
, " RIP packet debugging is on\n");
31 if (IS_RIP_DEBUG_SEND
)
33 " RIP packet send debugging is on\n");
36 " RIP packet receive debugging is on\n");
40 if (IS_RIP_DEBUG_ZEBRA
)
41 vty_out(vty
, " RIP zebra debugging is on\n");
43 cmd_show_lib_debugs(vty
);
48 DEFUN (debug_rip_events
,
55 rip_debug_event
= RIP_DEBUG_EVENT
;
59 DEFUN (debug_rip_packet
,
66 rip_debug_packet
= RIP_DEBUG_PACKET
;
67 rip_debug_packet
|= RIP_DEBUG_SEND
;
68 rip_debug_packet
|= RIP_DEBUG_RECV
;
72 DEFUN (debug_rip_packet_direct
,
73 debug_rip_packet_direct_cmd
,
74 "debug rip packet <recv|send>",
78 "RIP receive packet\n"
81 int idx_recv_send
= 3;
82 rip_debug_packet
|= RIP_DEBUG_PACKET
;
83 if (strcmp("send", argv
[idx_recv_send
]->text
) == 0)
84 rip_debug_packet
|= RIP_DEBUG_SEND
;
85 if (strcmp("recv", argv
[idx_recv_send
]->text
) == 0)
86 rip_debug_packet
|= RIP_DEBUG_RECV
;
90 DEFUN (debug_rip_zebra
,
95 "RIP and ZEBRA communication\n")
97 rip_debug_zebra
= RIP_DEBUG_ZEBRA
;
101 DEFUN (no_debug_rip_events
,
102 no_debug_rip_events_cmd
,
103 "no debug rip events",
113 DEFUN (no_debug_rip_packet
,
114 no_debug_rip_packet_cmd
,
115 "no debug rip packet",
121 rip_debug_packet
= 0;
125 DEFUN (no_debug_rip_packet_direct
,
126 no_debug_rip_packet_direct_cmd
,
127 "no debug rip packet <recv|send>",
132 "RIP option set for receive packet\n"
133 "RIP option set for send packet\n")
135 int idx_recv_send
= 4;
136 if (strcmp("send", argv
[idx_recv_send
]->text
) == 0) {
137 if (IS_RIP_DEBUG_RECV
)
138 rip_debug_packet
&= ~RIP_DEBUG_SEND
;
140 rip_debug_packet
= 0;
141 } else if (strcmp("recv", argv
[idx_recv_send
]->text
) == 0) {
142 if (IS_RIP_DEBUG_SEND
)
143 rip_debug_packet
&= ~RIP_DEBUG_RECV
;
145 rip_debug_packet
= 0;
150 DEFUN (no_debug_rip_zebra
,
151 no_debug_rip_zebra_cmd
,
152 "no debug rip zebra",
156 "RIP and ZEBRA communication\n")
162 static int config_write_debug(struct vty
*vty
);
164 static struct cmd_node debug_node
= {
168 .config_write
= config_write_debug
,
171 static int config_write_debug(struct vty
*vty
)
175 if (IS_RIP_DEBUG_EVENT
) {
176 vty_out(vty
, "debug rip events\n");
179 if (IS_RIP_DEBUG_PACKET
) {
180 if (IS_RIP_DEBUG_SEND
&& IS_RIP_DEBUG_RECV
) {
181 vty_out(vty
, "debug rip packet\n");
184 if (IS_RIP_DEBUG_SEND
)
185 vty_out(vty
, "debug rip packet send\n");
187 vty_out(vty
, "debug rip packet recv\n");
191 if (IS_RIP_DEBUG_ZEBRA
) {
192 vty_out(vty
, "debug rip zebra\n");
198 void rip_debug_init(void)
201 rip_debug_packet
= 0;
204 install_node(&debug_node
);
206 install_element(ENABLE_NODE
, &show_debugging_rip_cmd
);
207 install_element(ENABLE_NODE
, &debug_rip_events_cmd
);
208 install_element(ENABLE_NODE
, &debug_rip_packet_cmd
);
209 install_element(ENABLE_NODE
, &debug_rip_packet_direct_cmd
);
210 install_element(ENABLE_NODE
, &debug_rip_zebra_cmd
);
211 install_element(ENABLE_NODE
, &no_debug_rip_events_cmd
);
212 install_element(ENABLE_NODE
, &no_debug_rip_packet_cmd
);
213 install_element(ENABLE_NODE
, &no_debug_rip_packet_direct_cmd
);
214 install_element(ENABLE_NODE
, &no_debug_rip_zebra_cmd
);
216 install_element(CONFIG_NODE
, &debug_rip_events_cmd
);
217 install_element(CONFIG_NODE
, &debug_rip_packet_cmd
);
218 install_element(CONFIG_NODE
, &debug_rip_packet_direct_cmd
);
219 install_element(CONFIG_NODE
, &debug_rip_zebra_cmd
);
220 install_element(CONFIG_NODE
, &no_debug_rip_events_cmd
);
221 install_element(CONFIG_NODE
, &no_debug_rip_packet_cmd
);
222 install_element(CONFIG_NODE
, &no_debug_rip_packet_direct_cmd
);
223 install_element(CONFIG_NODE
, &no_debug_rip_zebra_cmd
);