]> git.proxmox.com Git - mirror_frr.git/blame - ripngd/ripng_debug.c
*: add indent control files
[mirror_frr.git] / ripngd / ripng_debug.c
CommitLineData
718e3744 1/*
2 * RIPng debug output routines
3 * Copyright (C) 1998 Kunihiro Ishiguro
4 *
5 * This file is part of GNU Zebra.
6 *
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
10 * later version.
11 *
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.
16 *
896014f4
DL
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
718e3744 20 */
21
22#include <zebra.h>
23#include "command.h"
24#include "ripngd/ripng_debug.h"
25
26/* For debug statement. */
27unsigned long ripng_debug_event = 0;
28unsigned long ripng_debug_packet = 0;
29unsigned long ripng_debug_zebra = 0;
6b0655a2 30
718e3744 31DEFUN (show_debugging_ripng,
32 show_debugging_ripng_cmd,
33 "show debugging ripng",
34 SHOW_STR
8dceb820 35 DEBUG_STR
36 "RIPng configuration\n")
718e3744 37{
5c7571d4 38 vty_out (vty, "RIPng debugging status:\n");
718e3744 39
40 if (IS_RIPNG_DEBUG_EVENT)
5c7571d4 41 vty_out (vty, " RIPng event debugging is on\n");
718e3744 42
43 if (IS_RIPNG_DEBUG_PACKET)
44 {
45 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV)
46 {
5c7571d4 47 vty_out (vty," RIPng packet debugging is on\n");
718e3744 48 }
49 else
50 {
51 if (IS_RIPNG_DEBUG_SEND)
5c7571d4 52 vty_out (vty," RIPng packet send debugging is on\n");
718e3744 53 else
5c7571d4 54 vty_out (vty," RIPng packet receive debugging is on\n");
718e3744 55 }
56 }
57
58 if (IS_RIPNG_DEBUG_ZEBRA)
5c7571d4 59 vty_out (vty, " RIPng zebra debugging is on\n");
718e3744 60
61 return CMD_SUCCESS;
62}
63
64DEFUN (debug_ripng_events,
65 debug_ripng_events_cmd,
66 "debug ripng events",
67 DEBUG_STR
68 "RIPng configuration\n"
69 "Debug option set for ripng events\n")
70{
71 ripng_debug_event = RIPNG_DEBUG_EVENT;
f1a05de9 72 return CMD_WARNING_CONFIG_FAILED;
718e3744 73}
74
75DEFUN (debug_ripng_packet,
76 debug_ripng_packet_cmd,
77 "debug ripng packet",
78 DEBUG_STR
79 "RIPng configuration\n"
80 "Debug option set for ripng packet\n")
81{
82 ripng_debug_packet = RIPNG_DEBUG_PACKET;
83 ripng_debug_packet |= RIPNG_DEBUG_SEND;
84 ripng_debug_packet |= RIPNG_DEBUG_RECV;
85 return CMD_SUCCESS;
86}
87
88DEFUN (debug_ripng_packet_direct,
89 debug_ripng_packet_direct_cmd,
6147e2c6 90 "debug ripng packet <recv|send>",
718e3744 91 DEBUG_STR
92 "RIPng configuration\n"
93 "Debug option set for ripng packet\n"
94 "Debug option set for receive packet\n"
95 "Debug option set for send packet\n")
96{
ab34a28a 97 int idx_recv_send = 3;
718e3744 98 ripng_debug_packet |= RIPNG_DEBUG_PACKET;
ab34a28a 99 if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
718e3744 100 ripng_debug_packet |= RIPNG_DEBUG_SEND;
ab34a28a 101 if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
718e3744 102 ripng_debug_packet |= RIPNG_DEBUG_RECV;
b016e9de 103
718e3744 104 return CMD_SUCCESS;
105}
106
107DEFUN (debug_ripng_zebra,
108 debug_ripng_zebra_cmd,
109 "debug ripng zebra",
110 DEBUG_STR
111 "RIPng configuration\n"
112 "Debug option set for ripng and zebra communication\n")
113{
114 ripng_debug_zebra = RIPNG_DEBUG_ZEBRA;
f1a05de9 115 return CMD_WARNING_CONFIG_FAILED;
718e3744 116}
117
118DEFUN (no_debug_ripng_events,
119 no_debug_ripng_events_cmd,
120 "no debug ripng events",
121 NO_STR
122 DEBUG_STR
123 "RIPng configuration\n"
124 "Debug option set for ripng events\n")
125{
126 ripng_debug_event = 0;
127 return CMD_SUCCESS;
128}
129
130DEFUN (no_debug_ripng_packet,
131 no_debug_ripng_packet_cmd,
132 "no debug ripng packet",
133 NO_STR
134 DEBUG_STR
135 "RIPng configuration\n"
136 "Debug option set for ripng packet\n")
137{
138 ripng_debug_packet = 0;
139 return CMD_SUCCESS;
140}
141
142DEFUN (no_debug_ripng_packet_direct,
143 no_debug_ripng_packet_direct_cmd,
6147e2c6 144 "no debug ripng packet <recv|send>",
718e3744 145 NO_STR
146 DEBUG_STR
147 "RIPng configuration\n"
148 "Debug option set for ripng packet\n"
149 "Debug option set for receive packet\n"
150 "Debug option set for send packet\n")
151{
ab34a28a
DW
152 int idx_recv_send = 4;
153 if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
718e3744 154 {
155 if (IS_RIPNG_DEBUG_RECV)
156 ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
157 else
158 ripng_debug_packet = 0;
159 }
ab34a28a 160 else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
718e3744 161 {
162 if (IS_RIPNG_DEBUG_SEND)
163 ripng_debug_packet &= ~RIPNG_DEBUG_RECV;
164 else
165 ripng_debug_packet = 0;
166 }
167 return CMD_SUCCESS;
168}
169
170DEFUN (no_debug_ripng_zebra,
171 no_debug_ripng_zebra_cmd,
172 "no debug ripng zebra",
173 NO_STR
174 DEBUG_STR
175 "RIPng configuration\n"
176 "Debug option set for ripng and zebra communication\n")
177{
178 ripng_debug_zebra = 0;
f1a05de9 179 return CMD_WARNING_CONFIG_FAILED;
718e3744 180}
181
182/* Debug node. */
7fc626de 183static struct cmd_node debug_node =
718e3744 184{
185 DEBUG_NODE,
a94434b6 186 "", /* Debug node has no interface. */
187 1 /* VTYSH */
718e3744 188};
189
6ac29a51 190static int
718e3744 191config_write_debug (struct vty *vty)
192{
193 int write = 0;
194
195 if (IS_RIPNG_DEBUG_EVENT)
196 {
5c7571d4 197 vty_out (vty, "debug ripng events\n");
718e3744 198 write++;
199 }
200 if (IS_RIPNG_DEBUG_PACKET)
201 {
202 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV)
203 {
5c7571d4 204 vty_out (vty,"debug ripng packet\n");
718e3744 205 write++;
206 }
207 else
208 {
209 if (IS_RIPNG_DEBUG_SEND)
5c7571d4 210 vty_out (vty,"debug ripng packet send\n");
718e3744 211 else
5c7571d4 212 vty_out (vty,"debug ripng packet recv\n");
718e3744 213 write++;
214 }
215 }
216 if (IS_RIPNG_DEBUG_ZEBRA)
217 {
5c7571d4 218 vty_out (vty, "debug ripng zebra\n");
718e3744 219 write++;
220 }
221 return write;
222}
223
224void
225ripng_debug_reset ()
226{
227 ripng_debug_event = 0;
228 ripng_debug_packet = 0;
229 ripng_debug_zebra = 0;
230}
231
232void
233ripng_debug_init ()
234{
235 ripng_debug_event = 0;
236 ripng_debug_packet = 0;
237 ripng_debug_zebra = 0;
238
239 install_node (&debug_node, config_write_debug);
240
241 install_element (VIEW_NODE, &show_debugging_ripng_cmd);
242
718e3744 243 install_element (ENABLE_NODE, &debug_ripng_events_cmd);
244 install_element (ENABLE_NODE, &debug_ripng_packet_cmd);
245 install_element (ENABLE_NODE, &debug_ripng_packet_direct_cmd);
718e3744 246 install_element (ENABLE_NODE, &debug_ripng_zebra_cmd);
247 install_element (ENABLE_NODE, &no_debug_ripng_events_cmd);
248 install_element (ENABLE_NODE, &no_debug_ripng_packet_cmd);
249 install_element (ENABLE_NODE, &no_debug_ripng_packet_direct_cmd);
250 install_element (ENABLE_NODE, &no_debug_ripng_zebra_cmd);
251
252 install_element (CONFIG_NODE, &debug_ripng_events_cmd);
253 install_element (CONFIG_NODE, &debug_ripng_packet_cmd);
254 install_element (CONFIG_NODE, &debug_ripng_packet_direct_cmd);
718e3744 255 install_element (CONFIG_NODE, &debug_ripng_zebra_cmd);
256 install_element (CONFIG_NODE, &no_debug_ripng_events_cmd);
257 install_element (CONFIG_NODE, &no_debug_ripng_packet_cmd);
258 install_element (CONFIG_NODE, &no_debug_ripng_packet_direct_cmd);
259 install_element (CONFIG_NODE, &no_debug_ripng_zebra_cmd);
260}