]> git.proxmox.com Git - mirror_frr.git/blame - ripd/rip_debug.c
Merge pull request #13484 from sri-mohan1/srib-ldpd
[mirror_frr.git] / ripd / rip_debug.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
718e3744 2/* RIP debug routines
3 * Copyright (C) 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
718e3744 4 */
5
6#include <zebra.h>
7#include "command.h"
8#include "ripd/rip_debug.h"
9
10/* For debug statement. */
11unsigned long rip_debug_event = 0;
12unsigned long rip_debug_packet = 0;
13unsigned long rip_debug_zebra = 0;
6b0655a2 14
87f6dc50
DS
15DEFUN_NOSH (show_debugging_rip,
16 show_debugging_rip_cmd,
17 "show debugging [rip]",
18 SHOW_STR
19 DEBUG_STR
20 RIP_STR)
718e3744 21{
d62a17ae 22 vty_out(vty, "RIP debugging status:\n");
23
24 if (IS_RIP_DEBUG_EVENT)
25 vty_out(vty, " RIP event debugging is on\n");
26
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");
30 } else {
31 if (IS_RIP_DEBUG_SEND)
32 vty_out(vty,
33 " RIP packet send debugging is on\n");
34 else
35 vty_out(vty,
36 " RIP packet receive debugging is on\n");
37 }
718e3744 38 }
718e3744 39
d62a17ae 40 if (IS_RIP_DEBUG_ZEBRA)
41 vty_out(vty, " RIP zebra debugging is on\n");
718e3744 42
cf00164b
DS
43 cmd_show_lib_debugs(vty);
44
d62a17ae 45 return CMD_SUCCESS;
718e3744 46}
47
48DEFUN (debug_rip_events,
49 debug_rip_events_cmd,
50 "debug rip events",
51 DEBUG_STR
52 RIP_STR
53 "RIP events\n")
54{
d62a17ae 55 rip_debug_event = RIP_DEBUG_EVENT;
9c9d843b 56 return CMD_SUCCESS;
718e3744 57}
58
59DEFUN (debug_rip_packet,
60 debug_rip_packet_cmd,
61 "debug rip packet",
62 DEBUG_STR
63 RIP_STR
64 "RIP packet\n")
65{
d62a17ae 66 rip_debug_packet = RIP_DEBUG_PACKET;
67 rip_debug_packet |= RIP_DEBUG_SEND;
68 rip_debug_packet |= RIP_DEBUG_RECV;
69 return CMD_SUCCESS;
718e3744 70}
71
72DEFUN (debug_rip_packet_direct,
73 debug_rip_packet_direct_cmd,
6147e2c6 74 "debug rip packet <recv|send>",
718e3744 75 DEBUG_STR
76 RIP_STR
77 "RIP packet\n"
78 "RIP receive packet\n"
79 "RIP send packet\n")
80{
d62a17ae 81 int idx_recv_send = 3;
82 rip_debug_packet |= RIP_DEBUG_PACKET;
8034beff 83 if (strcmp("send", argv[idx_recv_send]->text) == 0)
d62a17ae 84 rip_debug_packet |= RIP_DEBUG_SEND;
8034beff 85 if (strcmp("recv", argv[idx_recv_send]->text) == 0)
d62a17ae 86 rip_debug_packet |= RIP_DEBUG_RECV;
87 return CMD_SUCCESS;
718e3744 88}
89
718e3744 90DEFUN (debug_rip_zebra,
91 debug_rip_zebra_cmd,
92 "debug rip zebra",
93 DEBUG_STR
94 RIP_STR
95 "RIP and ZEBRA communication\n")
96{
d62a17ae 97 rip_debug_zebra = RIP_DEBUG_ZEBRA;
9c9d843b 98 return CMD_SUCCESS;
718e3744 99}
100
101DEFUN (no_debug_rip_events,
102 no_debug_rip_events_cmd,
103 "no debug rip events",
104 NO_STR
105 DEBUG_STR
106 RIP_STR
107 "RIP events\n")
108{
d62a17ae 109 rip_debug_event = 0;
110 return CMD_SUCCESS;
718e3744 111}
112
113DEFUN (no_debug_rip_packet,
114 no_debug_rip_packet_cmd,
115 "no debug rip packet",
116 NO_STR
117 DEBUG_STR
118 RIP_STR
119 "RIP packet\n")
120{
d62a17ae 121 rip_debug_packet = 0;
122 return CMD_SUCCESS;
718e3744 123}
124
125DEFUN (no_debug_rip_packet_direct,
126 no_debug_rip_packet_direct_cmd,
6147e2c6 127 "no debug rip packet <recv|send>",
718e3744 128 NO_STR
129 DEBUG_STR
130 RIP_STR
131 "RIP packet\n"
132 "RIP option set for receive packet\n"
133 "RIP option set for send packet\n")
134{
d62a17ae 135 int idx_recv_send = 4;
8034beff 136 if (strcmp("send", argv[idx_recv_send]->text) == 0) {
d62a17ae 137 if (IS_RIP_DEBUG_RECV)
138 rip_debug_packet &= ~RIP_DEBUG_SEND;
139 else
140 rip_debug_packet = 0;
8034beff 141 } else if (strcmp("recv", argv[idx_recv_send]->text) == 0) {
d62a17ae 142 if (IS_RIP_DEBUG_SEND)
143 rip_debug_packet &= ~RIP_DEBUG_RECV;
144 else
145 rip_debug_packet = 0;
146 }
147 return CMD_SUCCESS;
718e3744 148}
149
150DEFUN (no_debug_rip_zebra,
151 no_debug_rip_zebra_cmd,
152 "no debug rip zebra",
153 NO_STR
154 DEBUG_STR
155 RIP_STR
156 "RIP and ZEBRA communication\n")
157{
d62a17ae 158 rip_debug_zebra = 0;
9c9d843b 159 return CMD_SUCCESS;
718e3744 160}
161
612c2c15 162static int config_write_debug(struct vty *vty);
718e3744 163/* Debug node. */
62b346ee 164static struct cmd_node debug_node = {
f4b8291f 165 .name = "debug",
62b346ee
DL
166 .node = DEBUG_NODE,
167 .prompt = "",
612c2c15 168 .config_write = config_write_debug,
62b346ee 169};
718e3744 170
d62a17ae 171static int config_write_debug(struct vty *vty)
718e3744 172{
d62a17ae 173 int write = 0;
718e3744 174
d62a17ae 175 if (IS_RIP_DEBUG_EVENT) {
176 vty_out(vty, "debug rip events\n");
177 write++;
718e3744 178 }
d62a17ae 179 if (IS_RIP_DEBUG_PACKET) {
180 if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) {
181 vty_out(vty, "debug rip packet\n");
182 write++;
183 } else {
184 if (IS_RIP_DEBUG_SEND)
185 vty_out(vty, "debug rip packet send\n");
186 else
187 vty_out(vty, "debug rip packet recv\n");
188 write++;
189 }
718e3744 190 }
d62a17ae 191 if (IS_RIP_DEBUG_ZEBRA) {
192 vty_out(vty, "debug rip zebra\n");
193 write++;
194 }
195 return write;
718e3744 196}
197
d62a17ae 198void rip_debug_init(void)
718e3744 199{
d62a17ae 200 rip_debug_event = 0;
201 rip_debug_packet = 0;
202 rip_debug_zebra = 0;
203
612c2c15 204 install_node(&debug_node);
d62a17ae 205
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);
215
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);
718e3744 224}