]> git.proxmox.com Git - mirror_frr.git/blame - ripngd/ripng_debug.c
*: fix git-reindent-branch.py reversing order
[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{
d62a17ae 38 vty_out(vty, "RIPng debugging status:\n");
39
40 if (IS_RIPNG_DEBUG_EVENT)
41 vty_out(vty, " RIPng event debugging is on\n");
42
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");
46 } else {
47 if (IS_RIPNG_DEBUG_SEND)
48 vty_out(vty,
49 " RIPng packet send debugging is on\n");
50 else
51 vty_out(vty,
52 " RIPng packet receive debugging is on\n");
53 }
718e3744 54 }
718e3744 55
d62a17ae 56 if (IS_RIPNG_DEBUG_ZEBRA)
57 vty_out(vty, " RIPng zebra debugging is on\n");
718e3744 58
d62a17ae 59 return CMD_SUCCESS;
718e3744 60}
61
62DEFUN (debug_ripng_events,
63 debug_ripng_events_cmd,
64 "debug ripng events",
65 DEBUG_STR
66 "RIPng configuration\n"
67 "Debug option set for ripng events\n")
68{
d62a17ae 69 ripng_debug_event = RIPNG_DEBUG_EVENT;
70 return CMD_WARNING_CONFIG_FAILED;
718e3744 71}
72
73DEFUN (debug_ripng_packet,
74 debug_ripng_packet_cmd,
75 "debug ripng packet",
76 DEBUG_STR
77 "RIPng configuration\n"
78 "Debug option set for ripng packet\n")
79{
d62a17ae 80 ripng_debug_packet = RIPNG_DEBUG_PACKET;
81 ripng_debug_packet |= RIPNG_DEBUG_SEND;
82 ripng_debug_packet |= RIPNG_DEBUG_RECV;
83 return CMD_SUCCESS;
718e3744 84}
85
86DEFUN (debug_ripng_packet_direct,
87 debug_ripng_packet_direct_cmd,
6147e2c6 88 "debug ripng packet <recv|send>",
718e3744 89 DEBUG_STR
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")
94{
d62a17ae 95 int idx_recv_send = 3;
96 ripng_debug_packet |= RIPNG_DEBUG_PACKET;
97 if (strncmp("send", argv[idx_recv_send]->arg,
98 strlen(argv[idx_recv_send]->arg))
99 == 0)
100 ripng_debug_packet |= RIPNG_DEBUG_SEND;
101 if (strncmp("recv", argv[idx_recv_send]->arg,
102 strlen(argv[idx_recv_send]->arg))
103 == 0)
104 ripng_debug_packet |= RIPNG_DEBUG_RECV;
105
106 return CMD_SUCCESS;
718e3744 107}
108
109DEFUN (debug_ripng_zebra,
110 debug_ripng_zebra_cmd,
111 "debug ripng zebra",
112 DEBUG_STR
113 "RIPng configuration\n"
114 "Debug option set for ripng and zebra communication\n")
115{
d62a17ae 116 ripng_debug_zebra = RIPNG_DEBUG_ZEBRA;
117 return CMD_WARNING_CONFIG_FAILED;
718e3744 118}
119
120DEFUN (no_debug_ripng_events,
121 no_debug_ripng_events_cmd,
122 "no debug ripng events",
123 NO_STR
124 DEBUG_STR
125 "RIPng configuration\n"
126 "Debug option set for ripng events\n")
127{
d62a17ae 128 ripng_debug_event = 0;
129 return CMD_SUCCESS;
718e3744 130}
131
132DEFUN (no_debug_ripng_packet,
133 no_debug_ripng_packet_cmd,
134 "no debug ripng packet",
135 NO_STR
136 DEBUG_STR
137 "RIPng configuration\n"
138 "Debug option set for ripng packet\n")
139{
d62a17ae 140 ripng_debug_packet = 0;
141 return CMD_SUCCESS;
718e3744 142}
143
144DEFUN (no_debug_ripng_packet_direct,
145 no_debug_ripng_packet_direct_cmd,
6147e2c6 146 "no debug ripng packet <recv|send>",
718e3744 147 NO_STR
148 DEBUG_STR
149 "RIPng configuration\n"
150 "Debug option set for ripng packet\n"
151 "Debug option set for receive packet\n"
152 "Debug option set for send packet\n")
153{
d62a17ae 154 int idx_recv_send = 4;
155 if (strncmp("send", argv[idx_recv_send]->arg,
156 strlen(argv[idx_recv_send]->arg))
157 == 0) {
158 if (IS_RIPNG_DEBUG_RECV)
159 ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
160 else
161 ripng_debug_packet = 0;
162 } else if (strncmp("recv", argv[idx_recv_send]->arg,
163 strlen(argv[idx_recv_send]->arg))
164 == 0) {
165 if (IS_RIPNG_DEBUG_SEND)
166 ripng_debug_packet &= ~RIPNG_DEBUG_RECV;
167 else
168 ripng_debug_packet = 0;
169 }
170 return CMD_SUCCESS;
718e3744 171}
172
173DEFUN (no_debug_ripng_zebra,
174 no_debug_ripng_zebra_cmd,
175 "no debug ripng zebra",
176 NO_STR
177 DEBUG_STR
178 "RIPng configuration\n"
179 "Debug option set for ripng and zebra communication\n")
180{
d62a17ae 181 ripng_debug_zebra = 0;
182 return CMD_WARNING_CONFIG_FAILED;
718e3744 183}
184
185/* Debug node. */
d62a17ae 186static struct cmd_node debug_node = {
187 DEBUG_NODE, "", /* Debug node has no interface. */
188 1 /* VTYSH */
718e3744 189};
190
d62a17ae 191static int config_write_debug(struct vty *vty)
718e3744 192{
d62a17ae 193 int write = 0;
718e3744 194
d62a17ae 195 if (IS_RIPNG_DEBUG_EVENT) {
196 vty_out(vty, "debug ripng events\n");
197 write++;
718e3744 198 }
d62a17ae 199 if (IS_RIPNG_DEBUG_PACKET) {
200 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) {
201 vty_out(vty, "debug ripng packet\n");
202 write++;
203 } else {
204 if (IS_RIPNG_DEBUG_SEND)
205 vty_out(vty, "debug ripng packet send\n");
206 else
207 vty_out(vty, "debug ripng packet recv\n");
208 write++;
209 }
718e3744 210 }
d62a17ae 211 if (IS_RIPNG_DEBUG_ZEBRA) {
212 vty_out(vty, "debug ripng zebra\n");
213 write++;
214 }
215 return write;
718e3744 216}
217
d62a17ae 218void ripng_debug_reset()
718e3744 219{
d62a17ae 220 ripng_debug_event = 0;
221 ripng_debug_packet = 0;
222 ripng_debug_zebra = 0;
718e3744 223}
224
d62a17ae 225void ripng_debug_init()
718e3744 226{
d62a17ae 227 ripng_debug_event = 0;
228 ripng_debug_packet = 0;
229 ripng_debug_zebra = 0;
230
231 install_node(&debug_node, config_write_debug);
232
233 install_element(VIEW_NODE, &show_debugging_ripng_cmd);
234
235 install_element(ENABLE_NODE, &debug_ripng_events_cmd);
236 install_element(ENABLE_NODE, &debug_ripng_packet_cmd);
237 install_element(ENABLE_NODE, &debug_ripng_packet_direct_cmd);
238 install_element(ENABLE_NODE, &debug_ripng_zebra_cmd);
239 install_element(ENABLE_NODE, &no_debug_ripng_events_cmd);
240 install_element(ENABLE_NODE, &no_debug_ripng_packet_cmd);
241 install_element(ENABLE_NODE, &no_debug_ripng_packet_direct_cmd);
242 install_element(ENABLE_NODE, &no_debug_ripng_zebra_cmd);
243
244 install_element(CONFIG_NODE, &debug_ripng_events_cmd);
245 install_element(CONFIG_NODE, &debug_ripng_packet_cmd);
246 install_element(CONFIG_NODE, &debug_ripng_packet_direct_cmd);
247 install_element(CONFIG_NODE, &debug_ripng_zebra_cmd);
248 install_element(CONFIG_NODE, &no_debug_ripng_events_cmd);
249 install_element(CONFIG_NODE, &no_debug_ripng_packet_cmd);
250 install_element(CONFIG_NODE, &no_debug_ripng_packet_direct_cmd);
251 install_element(CONFIG_NODE, &no_debug_ripng_zebra_cmd);
718e3744 252}