1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
/*
*
* Copyright 2016, LabN Consulting, L.L.C.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "lib/zebra.h"
#include <lib/version.h>
#include "lib/prefix.h"
#include "lib/linklist.h"
#include "lib/stream.h"
#include "lib/command.h"
#include "lib/log.h"
#include "bgpd/rfapi/vnc_debug.h"
/*
* debug state storage
*/
unsigned long conf_vnc_debug;
unsigned long term_vnc_debug;
struct vnc_debug {
unsigned long bit;
const char *name;
};
struct vnc_debug vncdebug[] =
{
{VNC_DEBUG_RFAPI_QUERY, "rfapi-query"},
{VNC_DEBUG_IMPORT_BI_ATTACH, "import-bi-attach"},
{VNC_DEBUG_IMPORT_DEL_REMOTE, "import-del-remote"},
{VNC_DEBUG_EXPORT_BGP_GETCE, "export-bgp-getce"},
{VNC_DEBUG_EXPORT_BGP_DIRECT_ADD, "export-bgp-direct-add"},
{VNC_DEBUG_IMPORT_BGP_ADD_ROUTE, "import-bgp-add-route"},
};
#define VNC_STR "VNC information\n"
/***********************************************************************
* debug bgp vnc <foo>
***********************************************************************/
DEFUN (debug_bgp_vnc,
debug_bgp_vnc_cmd,
"debug bgp vnc (rfapi-query|import-bi-attach|import-del-remote)",
DEBUG_STR
BGP_STR
VNC_STR
"rfapi query handling\n"
"import BI atachment\n"
"import delete remote routes\n")
{
size_t i;
for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i)
{
if (!strcmp(argv[0], vncdebug[i].name))
{
if (vty->node == CONFIG_NODE)
{
conf_vnc_debug |= vncdebug[i].bit;
term_vnc_debug |= vncdebug[i].bit;
}
else
{
term_vnc_debug |= vncdebug[i].bit;
vty_out (vty, "BGP vnc %s debugging is on%s",
vncdebug[i].name, VTY_NEWLINE);
}
return CMD_SUCCESS;
}
}
vty_out (vty, "Unknown debug flag: %s%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
DEFUN (no_debug_bgp_vnc,
no_debug_bgp_vnc_cmd,
"no debug bgp vnc (rfapi-query|import-bi-attach|import-del-remote)",
NO_STR
DEBUG_STR
BGP_STR
VNC_STR
"rfapi query handling\n"
"import BI atachment\n"
"import delete remote routes\n")
{
size_t i;
for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i)
{
if (!strcmp(argv[0], vncdebug[i].name))
{
if (vty->node == CONFIG_NODE)
{
conf_vnc_debug &= ~vncdebug[i].bit;
term_vnc_debug &= ~vncdebug[i].bit;
}
else
{
term_vnc_debug &= ~vncdebug[i].bit;
vty_out (vty, "BGP vnc %s debugging is off%s",
vncdebug[i].name, VTY_NEWLINE);
}
return CMD_SUCCESS;
}
}
vty_out (vty, "Unknown debug flag: %s%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
ALIAS (no_debug_bgp_vnc,
undebug_bgp_vnc_cmd,
"undebug bgp vnc (rfapi-query|import-bi-attach|import-del-remote)",
UNDEBUG_STR
BGP_STR
VNC_STR
"rfapi query handling\n"
"import BI atachment\n"
"import delete remote routes\n")
/***********************************************************************
* no debug bgp vnc all
***********************************************************************/
DEFUN (no_debug_bgp_vnc_all,
no_debug_bgp_vnc_all_cmd,
"no debug all bgp vnc",
NO_STR
DEBUG_STR
"Disable all VNC debugging\n"
BGP_STR
VNC_STR)
{
term_vnc_debug = 0;
vty_out (vty, "All possible VNC debugging has been turned off%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
ALIAS (no_debug_bgp_vnc_all,
undebug_bgp_vnc_all_cmd,
"undebug all bgp vnc",
UNDEBUG_STR
"Disable all VNC debugging\n"
BGP_STR
VNC_STR)
/***********************************************************************
* show/save
***********************************************************************/
DEFUN (show_debugging_bgp_vnc,
show_debugging_bgp_vnc_cmd,
"show debugging bgp vnc",
SHOW_STR
DEBUG_STR
BGP_STR
VNC_STR)
{
size_t i;
vty_out (vty, "BGP VNC debugging status:%s", VTY_NEWLINE);
for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i)
{
if (term_vnc_debug & vncdebug[i].bit)
{
vty_out (vty, " BGP VNC %s debugging is on%s",
vncdebug[i].name, VTY_NEWLINE);
}
}
vty_out (vty, "%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
static int
bgp_vnc_config_write_debug (struct vty *vty)
{
int write = 0;
size_t i;
for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i)
{
if (conf_vnc_debug & vncdebug[i].bit)
{
vty_out (vty, "debug bgp vnc %s%s", vncdebug[i].name, VTY_NEWLINE);
write++;
}
}
return write;
}
static struct cmd_node debug_node =
{
DEBUG_VNC_NODE,
"",
1
};
void
vnc_debug_init (void)
{
install_node (&debug_node, bgp_vnc_config_write_debug);
install_element (ENABLE_NODE, &show_debugging_bgp_vnc_cmd);
install_element (ENABLE_NODE, &debug_bgp_vnc_cmd);
install_element (CONFIG_NODE, &debug_bgp_vnc_cmd);
install_element (ENABLE_NODE, &no_debug_bgp_vnc_cmd);
install_element (ENABLE_NODE, &undebug_bgp_vnc_cmd);
install_element (ENABLE_NODE, &no_debug_bgp_vnc_all_cmd);
install_element (ENABLE_NODE, &undebug_bgp_vnc_all_cmd);
}
|