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 (show_debugging_rip
,
31 show_debugging_rip_cmd
,
37 vty_out (vty
, "RIP debugging status:%s", VTY_NEWLINE
);
39 if (IS_RIP_DEBUG_EVENT
)
40 vty_out (vty
, " RIP event debugging is on%s", VTY_NEWLINE
);
42 if (IS_RIP_DEBUG_PACKET
)
44 if (IS_RIP_DEBUG_SEND
&& IS_RIP_DEBUG_RECV
)
46 vty_out (vty
, " RIP packet debugging is on%s",
51 if (IS_RIP_DEBUG_SEND
)
52 vty_out (vty
, " RIP packet send debugging is on%s",
55 vty_out (vty
, " RIP packet receive debugging is on%s",
60 if (IS_RIP_DEBUG_ZEBRA
)
61 vty_out (vty
, " RIP zebra debugging is on%s", VTY_NEWLINE
);
66 DEFUN (debug_rip_events
,
73 rip_debug_event
= RIP_DEBUG_EVENT
;
77 DEFUN (debug_rip_packet
,
84 rip_debug_packet
= RIP_DEBUG_PACKET
;
85 rip_debug_packet
|= RIP_DEBUG_SEND
;
86 rip_debug_packet
|= RIP_DEBUG_RECV
;
90 DEFUN (debug_rip_packet_direct
,
91 debug_rip_packet_direct_cmd
,
92 "debug rip packet <recv|send>",
96 "RIP receive packet\n"
99 int idx_recv_send
= 3;
100 rip_debug_packet
|= RIP_DEBUG_PACKET
;
101 if (strncmp ("send", argv
[idx_recv_send
]->arg
, strlen (argv
[idx_recv_send
]->arg
)) == 0)
102 rip_debug_packet
|= RIP_DEBUG_SEND
;
103 if (strncmp ("recv", argv
[idx_recv_send
]->arg
, strlen (argv
[idx_recv_send
]->arg
)) == 0)
104 rip_debug_packet
|= RIP_DEBUG_RECV
;
108 DEFUN (debug_rip_zebra
,
113 "RIP and ZEBRA communication\n")
115 rip_debug_zebra
= RIP_DEBUG_ZEBRA
;
119 DEFUN (no_debug_rip_events
,
120 no_debug_rip_events_cmd
,
121 "no debug rip events",
131 DEFUN (no_debug_rip_packet
,
132 no_debug_rip_packet_cmd
,
133 "no debug rip packet",
139 rip_debug_packet
= 0;
143 DEFUN (no_debug_rip_packet_direct
,
144 no_debug_rip_packet_direct_cmd
,
145 "no debug rip packet <recv|send>",
150 "RIP option set for receive packet\n"
151 "RIP option set for send packet\n")
153 int idx_recv_send
= 4;
154 if (strncmp ("send", argv
[idx_recv_send
]->arg
, strlen (argv
[idx_recv_send
]->arg
)) == 0)
156 if (IS_RIP_DEBUG_RECV
)
157 rip_debug_packet
&= ~RIP_DEBUG_SEND
;
159 rip_debug_packet
= 0;
161 else if (strncmp ("recv", argv
[idx_recv_send
]->arg
, strlen (argv
[idx_recv_send
]->arg
)) == 0)
163 if (IS_RIP_DEBUG_SEND
)
164 rip_debug_packet
&= ~RIP_DEBUG_RECV
;
166 rip_debug_packet
= 0;
171 DEFUN (no_debug_rip_zebra
,
172 no_debug_rip_zebra_cmd
,
173 "no debug rip zebra",
177 "RIP and ZEBRA communication\n")
184 static struct cmd_node debug_node
=
187 "", /* Debug node has no interface. */
192 config_write_debug (struct vty
*vty
)
196 if (IS_RIP_DEBUG_EVENT
)
198 vty_out (vty
, "debug rip events%s", VTY_NEWLINE
);
201 if (IS_RIP_DEBUG_PACKET
)
203 if (IS_RIP_DEBUG_SEND
&& IS_RIP_DEBUG_RECV
)
205 vty_out (vty
, "debug rip packet%s",
211 if (IS_RIP_DEBUG_SEND
)
212 vty_out (vty
, "debug rip packet send%s",
215 vty_out (vty
, "debug rip packet recv%s",
220 if (IS_RIP_DEBUG_ZEBRA
)
222 vty_out (vty
, "debug rip zebra%s", VTY_NEWLINE
);
229 rip_debug_reset (void)
232 rip_debug_packet
= 0;
237 rip_debug_init (void)
240 rip_debug_packet
= 0;
243 install_node (&debug_node
, config_write_debug
);
245 install_element (ENABLE_NODE
, &show_debugging_rip_cmd
);
246 install_element (ENABLE_NODE
, &debug_rip_events_cmd
);
247 install_element (ENABLE_NODE
, &debug_rip_packet_cmd
);
248 install_element (ENABLE_NODE
, &debug_rip_packet_direct_cmd
);
249 install_element (ENABLE_NODE
, &debug_rip_zebra_cmd
);
250 install_element (ENABLE_NODE
, &no_debug_rip_events_cmd
);
251 install_element (ENABLE_NODE
, &no_debug_rip_packet_cmd
);
252 install_element (ENABLE_NODE
, &no_debug_rip_packet_direct_cmd
);
253 install_element (ENABLE_NODE
, &no_debug_rip_zebra_cmd
);
255 install_element (CONFIG_NODE
, &debug_rip_events_cmd
);
256 install_element (CONFIG_NODE
, &debug_rip_packet_cmd
);
257 install_element (CONFIG_NODE
, &debug_rip_packet_direct_cmd
);
258 install_element (CONFIG_NODE
, &debug_rip_zebra_cmd
);
259 install_element (CONFIG_NODE
, &no_debug_rip_events_cmd
);
260 install_element (CONFIG_NODE
, &no_debug_rip_packet_cmd
);
261 install_element (CONFIG_NODE
, &no_debug_rip_packet_direct_cmd
);
262 install_element (CONFIG_NODE
, &no_debug_rip_zebra_cmd
);