2 * RIPng debug output routines
3 * Copyright (C) 1998 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "ripngd/ripng_debug.h"
26 /* For debug statement. */
27 unsigned long ripng_debug_event
= 0;
28 unsigned long ripng_debug_packet
= 0;
29 unsigned long ripng_debug_zebra
= 0;
31 DEFUN_NOSH (show_debugging_ripng
,
32 show_debugging_ripng_cmd
,
33 "show debugging [ripng]",
36 "RIPng configuration\n")
38 vty_out(vty
, "RIPng debugging status:\n");
40 if (IS_RIPNG_DEBUG_EVENT
)
41 vty_out(vty
, " RIPng event debugging is on\n");
43 if (IS_RIPNG_DEBUG_PACKET
) {
44 if (IS_RIPNG_DEBUG_SEND
&& IS_RIPNG_DEBUG_RECV
) {
45 vty_out(vty
, " RIPng packet debugging is on\n");
47 if (IS_RIPNG_DEBUG_SEND
)
49 " RIPng packet send debugging is on\n");
52 " RIPng packet receive debugging is on\n");
56 if (IS_RIPNG_DEBUG_ZEBRA
)
57 vty_out(vty
, " RIPng zebra debugging is on\n");
62 DEFUN (debug_ripng_events
,
63 debug_ripng_events_cmd
,
66 "RIPng configuration\n"
67 "Debug option set for ripng events\n")
69 ripng_debug_event
= RIPNG_DEBUG_EVENT
;
73 DEFUN (debug_ripng_packet
,
74 debug_ripng_packet_cmd
,
77 "RIPng configuration\n"
78 "Debug option set for ripng packet\n")
80 ripng_debug_packet
= RIPNG_DEBUG_PACKET
;
81 ripng_debug_packet
|= RIPNG_DEBUG_SEND
;
82 ripng_debug_packet
|= RIPNG_DEBUG_RECV
;
86 DEFUN (debug_ripng_packet_direct
,
87 debug_ripng_packet_direct_cmd
,
88 "debug ripng packet <recv|send>",
90 "RIPng configuration\n"
91 "Debug option set for ripng packet\n"
92 "Debug option set for receive packet\n"
93 "Debug option set for send packet\n")
95 int idx_recv_send
= 3;
96 ripng_debug_packet
|= RIPNG_DEBUG_PACKET
;
97 if (strcmp("send", argv
[idx_recv_send
]->text
) == 0)
98 ripng_debug_packet
|= RIPNG_DEBUG_SEND
;
99 if (strcmp("recv", argv
[idx_recv_send
]->text
) == 0)
100 ripng_debug_packet
|= RIPNG_DEBUG_RECV
;
105 DEFUN (debug_ripng_zebra
,
106 debug_ripng_zebra_cmd
,
109 "RIPng configuration\n"
110 "Debug option set for ripng and zebra communication\n")
112 ripng_debug_zebra
= RIPNG_DEBUG_ZEBRA
;
116 DEFUN (no_debug_ripng_events
,
117 no_debug_ripng_events_cmd
,
118 "no debug ripng events",
121 "RIPng configuration\n"
122 "Debug option set for ripng events\n")
124 ripng_debug_event
= 0;
128 DEFUN (no_debug_ripng_packet
,
129 no_debug_ripng_packet_cmd
,
130 "no debug ripng packet",
133 "RIPng configuration\n"
134 "Debug option set for ripng packet\n")
136 ripng_debug_packet
= 0;
140 DEFUN (no_debug_ripng_packet_direct
,
141 no_debug_ripng_packet_direct_cmd
,
142 "no debug ripng packet <recv|send>",
145 "RIPng configuration\n"
146 "Debug option set for ripng packet\n"
147 "Debug option set for receive packet\n"
148 "Debug 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_RIPNG_DEBUG_RECV
)
153 ripng_debug_packet
&= ~RIPNG_DEBUG_SEND
;
155 ripng_debug_packet
= 0;
156 } else if (strcmp("recv", argv
[idx_recv_send
]->text
) == 0) {
157 if (IS_RIPNG_DEBUG_SEND
)
158 ripng_debug_packet
&= ~RIPNG_DEBUG_RECV
;
160 ripng_debug_packet
= 0;
165 DEFUN (no_debug_ripng_zebra
,
166 no_debug_ripng_zebra_cmd
,
167 "no debug ripng zebra",
170 "RIPng configuration\n"
171 "Debug option set for ripng and zebra communication\n")
173 ripng_debug_zebra
= 0;
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_RIPNG_DEBUG_EVENT
) {
191 vty_out(vty
, "debug ripng events\n");
194 if (IS_RIPNG_DEBUG_PACKET
) {
195 if (IS_RIPNG_DEBUG_SEND
&& IS_RIPNG_DEBUG_RECV
) {
196 vty_out(vty
, "debug ripng packet\n");
199 if (IS_RIPNG_DEBUG_SEND
)
200 vty_out(vty
, "debug ripng packet send\n");
202 vty_out(vty
, "debug ripng packet recv\n");
206 if (IS_RIPNG_DEBUG_ZEBRA
) {
207 vty_out(vty
, "debug ripng zebra\n");
213 void ripng_debug_init(void)
215 ripng_debug_event
= 0;
216 ripng_debug_packet
= 0;
217 ripng_debug_zebra
= 0;
219 install_node(&debug_node
);
221 install_element(VIEW_NODE
, &show_debugging_ripng_cmd
);
223 install_element(ENABLE_NODE
, &debug_ripng_events_cmd
);
224 install_element(ENABLE_NODE
, &debug_ripng_packet_cmd
);
225 install_element(ENABLE_NODE
, &debug_ripng_packet_direct_cmd
);
226 install_element(ENABLE_NODE
, &debug_ripng_zebra_cmd
);
227 install_element(ENABLE_NODE
, &no_debug_ripng_events_cmd
);
228 install_element(ENABLE_NODE
, &no_debug_ripng_packet_cmd
);
229 install_element(ENABLE_NODE
, &no_debug_ripng_packet_direct_cmd
);
230 install_element(ENABLE_NODE
, &no_debug_ripng_zebra_cmd
);
232 install_element(CONFIG_NODE
, &debug_ripng_events_cmd
);
233 install_element(CONFIG_NODE
, &debug_ripng_packet_cmd
);
234 install_element(CONFIG_NODE
, &debug_ripng_packet_direct_cmd
);
235 install_element(CONFIG_NODE
, &debug_ripng_zebra_cmd
);
236 install_element(CONFIG_NODE
, &no_debug_ripng_events_cmd
);
237 install_element(CONFIG_NODE
, &no_debug_ripng_packet_cmd
);
238 install_element(CONFIG_NODE
, &no_debug_ripng_packet_direct_cmd
);
239 install_element(CONFIG_NODE
, &no_debug_ripng_zebra_cmd
);