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
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 #include "ripd/rip_debug.h"
26 /* For debug statement. */
27 unsigned long rip_debug_event
= 0;
28 unsigned long rip_debug_packet
= 0;
29 unsigned long rip_debug_zebra
= 0;
31 DEFUN (show_debugging_rip
,
32 show_debugging_rip_cmd
,
38 vty_out(vty
, "RIP debugging status:%s", VTY_NEWLINE
);
40 if (IS_RIP_DEBUG_EVENT
)
41 vty_out(vty
, " RIP event debugging is on%s", VTY_NEWLINE
);
43 if (IS_RIP_DEBUG_PACKET
) {
44 if (IS_RIP_DEBUG_SEND
&& IS_RIP_DEBUG_RECV
) {
45 vty_out(vty
, " RIP packet debugging is on%s",
48 if (IS_RIP_DEBUG_SEND
)
50 " RIP packet send debugging is on%s",
54 " RIP packet receive debugging is on%s",
59 if (IS_RIP_DEBUG_ZEBRA
)
60 vty_out(vty
, " RIP zebra debugging is on%s", VTY_NEWLINE
);
65 DEFUN (debug_rip_events
,
72 rip_debug_event
= RIP_DEBUG_EVENT
;
76 DEFUN (debug_rip_packet
,
83 rip_debug_packet
= RIP_DEBUG_PACKET
;
84 rip_debug_packet
|= RIP_DEBUG_SEND
;
85 rip_debug_packet
|= RIP_DEBUG_RECV
;
89 DEFUN (debug_rip_packet_direct
,
90 debug_rip_packet_direct_cmd
,
91 "debug rip packet <recv|send>",
95 "RIP receive packet\n"
98 int idx_recv_send
= 3;
99 rip_debug_packet
|= RIP_DEBUG_PACKET
;
100 if (strncmp("send", argv
[idx_recv_send
]->arg
,
101 strlen(argv
[idx_recv_send
]->arg
))
103 rip_debug_packet
|= RIP_DEBUG_SEND
;
104 if (strncmp("recv", argv
[idx_recv_send
]->arg
,
105 strlen(argv
[idx_recv_send
]->arg
))
107 rip_debug_packet
|= RIP_DEBUG_RECV
;
111 DEFUN (debug_rip_zebra
,
116 "RIP and ZEBRA communication\n")
118 rip_debug_zebra
= RIP_DEBUG_ZEBRA
;
122 DEFUN (no_debug_rip_events
,
123 no_debug_rip_events_cmd
,
124 "no debug rip events",
134 DEFUN (no_debug_rip_packet
,
135 no_debug_rip_packet_cmd
,
136 "no debug rip packet",
142 rip_debug_packet
= 0;
146 DEFUN (no_debug_rip_packet_direct
,
147 no_debug_rip_packet_direct_cmd
,
148 "no debug rip packet <recv|send>",
153 "RIP option set for receive packet\n"
154 "RIP option set for send packet\n")
156 int idx_recv_send
= 4;
157 if (strncmp("send", argv
[idx_recv_send
]->arg
,
158 strlen(argv
[idx_recv_send
]->arg
))
160 if (IS_RIP_DEBUG_RECV
)
161 rip_debug_packet
&= ~RIP_DEBUG_SEND
;
163 rip_debug_packet
= 0;
164 } else if (strncmp("recv", argv
[idx_recv_send
]->arg
,
165 strlen(argv
[idx_recv_send
]->arg
))
167 if (IS_RIP_DEBUG_SEND
)
168 rip_debug_packet
&= ~RIP_DEBUG_RECV
;
170 rip_debug_packet
= 0;
175 DEFUN (no_debug_rip_zebra
,
176 no_debug_rip_zebra_cmd
,
177 "no debug rip zebra",
181 "RIP and ZEBRA communication\n")
188 static struct cmd_node debug_node
= {DEBUG_NODE
,
189 "", /* Debug node has no interface. */
192 static int config_write_debug(struct vty
*vty
)
196 if (IS_RIP_DEBUG_EVENT
) {
197 vty_out(vty
, "debug rip events%s", VTY_NEWLINE
);
200 if (IS_RIP_DEBUG_PACKET
) {
201 if (IS_RIP_DEBUG_SEND
&& IS_RIP_DEBUG_RECV
) {
202 vty_out(vty
, "debug rip packet%s", VTY_NEWLINE
);
205 if (IS_RIP_DEBUG_SEND
)
206 vty_out(vty
, "debug rip packet send%s",
209 vty_out(vty
, "debug rip packet recv%s",
214 if (IS_RIP_DEBUG_ZEBRA
) {
215 vty_out(vty
, "debug rip zebra%s", VTY_NEWLINE
);
221 void rip_debug_reset(void)
224 rip_debug_packet
= 0;
228 void rip_debug_init(void)
231 rip_debug_packet
= 0;
234 install_node(&debug_node
, config_write_debug
);
236 install_element(ENABLE_NODE
, &show_debugging_rip_cmd
);
237 install_element(ENABLE_NODE
, &debug_rip_events_cmd
);
238 install_element(ENABLE_NODE
, &debug_rip_packet_cmd
);
239 install_element(ENABLE_NODE
, &debug_rip_packet_direct_cmd
);
240 install_element(ENABLE_NODE
, &debug_rip_zebra_cmd
);
241 install_element(ENABLE_NODE
, &no_debug_rip_events_cmd
);
242 install_element(ENABLE_NODE
, &no_debug_rip_packet_cmd
);
243 install_element(ENABLE_NODE
, &no_debug_rip_packet_direct_cmd
);
244 install_element(ENABLE_NODE
, &no_debug_rip_zebra_cmd
);
246 install_element(CONFIG_NODE
, &debug_rip_events_cmd
);
247 install_element(CONFIG_NODE
, &debug_rip_packet_cmd
);
248 install_element(CONFIG_NODE
, &debug_rip_packet_direct_cmd
);
249 install_element(CONFIG_NODE
, &debug_rip_zebra_cmd
);
250 install_element(CONFIG_NODE
, &no_debug_rip_events_cmd
);
251 install_element(CONFIG_NODE
, &no_debug_rip_packet_cmd
);
252 install_element(CONFIG_NODE
, &no_debug_rip_packet_direct_cmd
);
253 install_element(CONFIG_NODE
, &no_debug_rip_zebra_cmd
);