2 * Copyright (C) 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "ripd/rip_debug.h"
25 /* For debug statement. */
26 unsigned long rip_debug_event
= 0;
27 unsigned long rip_debug_packet
= 0;
28 unsigned long rip_debug_zebra
= 0;
30 DEFUN_NOSH (show_debugging_rip
,
31 show_debugging_rip_cmd
,
32 "show debugging [rip]",
37 vty_out(vty
, "RIP debugging status:\n");
39 if (IS_RIP_DEBUG_EVENT
)
40 vty_out(vty
, " RIP event debugging is on\n");
42 if (IS_RIP_DEBUG_PACKET
) {
43 if (IS_RIP_DEBUG_SEND
&& IS_RIP_DEBUG_RECV
) {
44 vty_out(vty
, " RIP packet debugging is on\n");
46 if (IS_RIP_DEBUG_SEND
)
48 " RIP packet send debugging is on\n");
51 " RIP packet receive debugging is on\n");
55 if (IS_RIP_DEBUG_ZEBRA
)
56 vty_out(vty
, " RIP zebra debugging is on\n");
58 cmd_show_lib_debugs(vty
);
63 DEFUN (debug_rip_events
,
70 rip_debug_event
= RIP_DEBUG_EVENT
;
74 DEFUN (debug_rip_packet
,
81 rip_debug_packet
= RIP_DEBUG_PACKET
;
82 rip_debug_packet
|= RIP_DEBUG_SEND
;
83 rip_debug_packet
|= RIP_DEBUG_RECV
;
87 DEFUN (debug_rip_packet_direct
,
88 debug_rip_packet_direct_cmd
,
89 "debug rip packet <recv|send>",
93 "RIP receive packet\n"
96 int idx_recv_send
= 3;
97 rip_debug_packet
|= RIP_DEBUG_PACKET
;
98 if (strcmp("send", argv
[idx_recv_send
]->text
) == 0)
99 rip_debug_packet
|= RIP_DEBUG_SEND
;
100 if (strcmp("recv", argv
[idx_recv_send
]->text
) == 0)
101 rip_debug_packet
|= RIP_DEBUG_RECV
;
105 DEFUN (debug_rip_zebra
,
110 "RIP and ZEBRA communication\n")
112 rip_debug_zebra
= RIP_DEBUG_ZEBRA
;
116 DEFUN (no_debug_rip_events
,
117 no_debug_rip_events_cmd
,
118 "no debug rip events",
128 DEFUN (no_debug_rip_packet
,
129 no_debug_rip_packet_cmd
,
130 "no debug rip packet",
136 rip_debug_packet
= 0;
140 DEFUN (no_debug_rip_packet_direct
,
141 no_debug_rip_packet_direct_cmd
,
142 "no debug rip packet <recv|send>",
147 "RIP option set for receive packet\n"
148 "RIP option set for send packet\n")
150 int idx_recv_send
= 4;
151 if (strcmp("send", argv
[idx_recv_send
]->text
) == 0) {
152 if (IS_RIP_DEBUG_RECV
)
153 rip_debug_packet
&= ~RIP_DEBUG_SEND
;
155 rip_debug_packet
= 0;
156 } else if (strcmp("recv", argv
[idx_recv_send
]->text
) == 0) {
157 if (IS_RIP_DEBUG_SEND
)
158 rip_debug_packet
&= ~RIP_DEBUG_RECV
;
160 rip_debug_packet
= 0;
165 DEFUN (no_debug_rip_zebra
,
166 no_debug_rip_zebra_cmd
,
167 "no debug rip zebra",
171 "RIP and ZEBRA communication\n")
177 static int config_write_debug(struct vty
*vty
);
179 static struct cmd_node debug_node
= {
183 .config_write
= config_write_debug
,
186 static int config_write_debug(struct vty
*vty
)
190 if (IS_RIP_DEBUG_EVENT
) {
191 vty_out(vty
, "debug rip events\n");
194 if (IS_RIP_DEBUG_PACKET
) {
195 if (IS_RIP_DEBUG_SEND
&& IS_RIP_DEBUG_RECV
) {
196 vty_out(vty
, "debug rip packet\n");
199 if (IS_RIP_DEBUG_SEND
)
200 vty_out(vty
, "debug rip packet send\n");
202 vty_out(vty
, "debug rip packet recv\n");
206 if (IS_RIP_DEBUG_ZEBRA
) {
207 vty_out(vty
, "debug rip zebra\n");
213 void rip_debug_init(void)
216 rip_debug_packet
= 0;
219 install_node(&debug_node
);
221 install_element(ENABLE_NODE
, &show_debugging_rip_cmd
);
222 install_element(ENABLE_NODE
, &debug_rip_events_cmd
);
223 install_element(ENABLE_NODE
, &debug_rip_packet_cmd
);
224 install_element(ENABLE_NODE
, &debug_rip_packet_direct_cmd
);
225 install_element(ENABLE_NODE
, &debug_rip_zebra_cmd
);
226 install_element(ENABLE_NODE
, &no_debug_rip_events_cmd
);
227 install_element(ENABLE_NODE
, &no_debug_rip_packet_cmd
);
228 install_element(ENABLE_NODE
, &no_debug_rip_packet_direct_cmd
);
229 install_element(ENABLE_NODE
, &no_debug_rip_zebra_cmd
);
231 install_element(CONFIG_NODE
, &debug_rip_events_cmd
);
232 install_element(CONFIG_NODE
, &debug_rip_packet_cmd
);
233 install_element(CONFIG_NODE
, &debug_rip_packet_direct_cmd
);
234 install_element(CONFIG_NODE
, &debug_rip_zebra_cmd
);
235 install_element(CONFIG_NODE
, &no_debug_rip_events_cmd
);
236 install_element(CONFIG_NODE
, &no_debug_rip_packet_cmd
);
237 install_element(CONFIG_NODE
, &no_debug_rip_packet_direct_cmd
);
238 install_element(CONFIG_NODE
, &no_debug_rip_zebra_cmd
);