]> git.proxmox.com Git - mirror_frr.git/blame - ripngd/ripng_debug.c
Merge pull request #3502 from donaldsharp/socket_to_me_baby
[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
87f6dc50
DS
31DEFUN_NOSH (show_debugging_ripng,
32 show_debugging_ripng_cmd,
33 "show debugging [ripng]",
34 SHOW_STR
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;
40e344cc 70 return CMD_SUCCESS;
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;
8034beff 97 if (strcmp("send", argv[idx_recv_send]->text) == 0)
d62a17ae 98 ripng_debug_packet |= RIPNG_DEBUG_SEND;
8034beff 99 if (strcmp("recv", argv[idx_recv_send]->text) == 0)
d62a17ae 100 ripng_debug_packet |= RIPNG_DEBUG_RECV;
101
102 return CMD_SUCCESS;
718e3744 103}
104
105DEFUN (debug_ripng_zebra,
106 debug_ripng_zebra_cmd,
107 "debug ripng zebra",
108 DEBUG_STR
109 "RIPng configuration\n"
110 "Debug option set for ripng and zebra communication\n")
111{
d62a17ae 112 ripng_debug_zebra = RIPNG_DEBUG_ZEBRA;
40e344cc 113 return CMD_SUCCESS;
718e3744 114}
115
116DEFUN (no_debug_ripng_events,
117 no_debug_ripng_events_cmd,
118 "no debug ripng events",
119 NO_STR
120 DEBUG_STR
121 "RIPng configuration\n"
122 "Debug option set for ripng events\n")
123{
d62a17ae 124 ripng_debug_event = 0;
125 return CMD_SUCCESS;
718e3744 126}
127
128DEFUN (no_debug_ripng_packet,
129 no_debug_ripng_packet_cmd,
130 "no debug ripng packet",
131 NO_STR
132 DEBUG_STR
133 "RIPng configuration\n"
134 "Debug option set for ripng packet\n")
135{
d62a17ae 136 ripng_debug_packet = 0;
137 return CMD_SUCCESS;
718e3744 138}
139
140DEFUN (no_debug_ripng_packet_direct,
141 no_debug_ripng_packet_direct_cmd,
6147e2c6 142 "no debug ripng packet <recv|send>",
718e3744 143 NO_STR
144 DEBUG_STR
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")
149{
d62a17ae 150 int idx_recv_send = 4;
8034beff 151 if (strcmp("send", argv[idx_recv_send]->text) == 0) {
d62a17ae 152 if (IS_RIPNG_DEBUG_RECV)
153 ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
154 else
155 ripng_debug_packet = 0;
8034beff 156 } else if (strcmp("recv", argv[idx_recv_send]->text) == 0) {
d62a17ae 157 if (IS_RIPNG_DEBUG_SEND)
158 ripng_debug_packet &= ~RIPNG_DEBUG_RECV;
159 else
160 ripng_debug_packet = 0;
161 }
162 return CMD_SUCCESS;
718e3744 163}
164
165DEFUN (no_debug_ripng_zebra,
166 no_debug_ripng_zebra_cmd,
167 "no debug ripng zebra",
168 NO_STR
169 DEBUG_STR
170 "RIPng configuration\n"
171 "Debug option set for ripng and zebra communication\n")
172{
d62a17ae 173 ripng_debug_zebra = 0;
40e344cc 174 return CMD_SUCCESS;
718e3744 175}
176
177/* Debug node. */
d62a17ae 178static struct cmd_node debug_node = {
179 DEBUG_NODE, "", /* Debug node has no interface. */
180 1 /* VTYSH */
718e3744 181};
182
d62a17ae 183static int config_write_debug(struct vty *vty)
718e3744 184{
d62a17ae 185 int write = 0;
718e3744 186
d62a17ae 187 if (IS_RIPNG_DEBUG_EVENT) {
188 vty_out(vty, "debug ripng events\n");
189 write++;
718e3744 190 }
d62a17ae 191 if (IS_RIPNG_DEBUG_PACKET) {
192 if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) {
193 vty_out(vty, "debug ripng packet\n");
194 write++;
195 } else {
196 if (IS_RIPNG_DEBUG_SEND)
197 vty_out(vty, "debug ripng packet send\n");
198 else
199 vty_out(vty, "debug ripng packet recv\n");
200 write++;
201 }
718e3744 202 }
d62a17ae 203 if (IS_RIPNG_DEBUG_ZEBRA) {
204 vty_out(vty, "debug ripng zebra\n");
205 write++;
206 }
207 return write;
718e3744 208}
209
d62a17ae 210void ripng_debug_init()
718e3744 211{
d62a17ae 212 ripng_debug_event = 0;
213 ripng_debug_packet = 0;
214 ripng_debug_zebra = 0;
215
216 install_node(&debug_node, config_write_debug);
217
218 install_element(VIEW_NODE, &show_debugging_ripng_cmd);
219
220 install_element(ENABLE_NODE, &debug_ripng_events_cmd);
221 install_element(ENABLE_NODE, &debug_ripng_packet_cmd);
222 install_element(ENABLE_NODE, &debug_ripng_packet_direct_cmd);
223 install_element(ENABLE_NODE, &debug_ripng_zebra_cmd);
224 install_element(ENABLE_NODE, &no_debug_ripng_events_cmd);
225 install_element(ENABLE_NODE, &no_debug_ripng_packet_cmd);
226 install_element(ENABLE_NODE, &no_debug_ripng_packet_direct_cmd);
227 install_element(ENABLE_NODE, &no_debug_ripng_zebra_cmd);
228
229 install_element(CONFIG_NODE, &debug_ripng_events_cmd);
230 install_element(CONFIG_NODE, &debug_ripng_packet_cmd);
231 install_element(CONFIG_NODE, &debug_ripng_packet_direct_cmd);
232 install_element(CONFIG_NODE, &debug_ripng_zebra_cmd);
233 install_element(CONFIG_NODE, &no_debug_ripng_events_cmd);
234 install_element(CONFIG_NODE, &no_debug_ripng_packet_cmd);
235 install_element(CONFIG_NODE, &no_debug_ripng_packet_direct_cmd);
236 install_element(CONFIG_NODE, &no_debug_ripng_zebra_cmd);
718e3744 237}