3 * Copyright 2016, LabN Consulting, L.L.C.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "lib/zebra.h"
22 #include <lib/version.h>
23 #include "lib/prefix.h"
24 #include "lib/linklist.h"
25 #include "lib/stream.h"
26 #include "lib/command.h"
28 #include "bgpd/rfapi/vnc_debug.h"
33 unsigned long conf_vnc_debug
;
34 unsigned long term_vnc_debug
;
41 static const struct vnc_debug vncdebug
[] = {
42 {VNC_DEBUG_RFAPI_QUERY
, "rfapi-query"},
43 {VNC_DEBUG_IMPORT_BI_ATTACH
, "import-bi-attach"},
44 {VNC_DEBUG_IMPORT_DEL_REMOTE
, "import-del-remote"},
45 {VNC_DEBUG_EXPORT_BGP_GETCE
, "export-bgp-getce"},
46 {VNC_DEBUG_EXPORT_BGP_DIRECT_ADD
, "export-bgp-direct-add"},
47 {VNC_DEBUG_IMPORT_BGP_ADD_ROUTE
, "import-bgp-add-route"},
48 {VNC_DEBUG_VERBOSE
, "verbose"},
51 #define VNC_STR "VNC information\n"
53 /***********************************************************************
55 ***********************************************************************/
58 "debug bgp vnc <rfapi-query|import-bi-attach|import-del-remote|verbose>",
62 "rfapi query handling\n"
63 "import BI atachment\n"
64 "import delete remote routes\n"
69 for (i
= 0; i
< (sizeof(vncdebug
) / sizeof(struct vnc_debug
)); ++i
) {
70 if (strmatch(argv
[3]->text
, vncdebug
[i
].name
)) {
71 if (vty
->node
== CONFIG_NODE
) {
72 conf_vnc_debug
|= vncdebug
[i
].bit
;
73 term_vnc_debug
|= vncdebug
[i
].bit
;
75 term_vnc_debug
|= vncdebug
[i
].bit
;
76 vty_out(vty
, "BGP vnc %s debugging is on\n",
82 vty_out(vty
, "Unknown debug flag: %s\n", argv
[3]->arg
);
83 return CMD_WARNING_CONFIG_FAILED
;
86 DEFUN (no_debug_bgp_vnc
,
88 "no debug bgp vnc <rfapi-query|import-bi-attach|import-del-remote|verbose>",
93 "rfapi query handling\n"
94 "import BI atachment\n"
95 "import delete remote routes\n"
100 for (i
= 0; i
< (sizeof(vncdebug
) / sizeof(struct vnc_debug
)); ++i
) {
101 if (strmatch(argv
[argc
- 1]->text
, vncdebug
[i
].name
)) {
102 if (vty
->node
== CONFIG_NODE
) {
103 conf_vnc_debug
&= ~vncdebug
[i
].bit
;
104 term_vnc_debug
&= ~vncdebug
[i
].bit
;
106 term_vnc_debug
&= ~vncdebug
[i
].bit
;
107 vty_out(vty
, "BGP vnc %s debugging is off\n",
113 vty_out(vty
, "Unknown debug flag: %s\n", argv
[3]->arg
);
114 return CMD_WARNING_CONFIG_FAILED
;
117 /***********************************************************************
118 * no debug bgp vnc all
119 ***********************************************************************/
121 DEFUN (no_debug_bgp_vnc_all
,
122 no_debug_bgp_vnc_all_cmd
,
123 "no debug all bgp vnc",
126 "Disable all VNC debugging\n"
131 vty_out(vty
, "All possible VNC debugging has been turned off\n");
136 /***********************************************************************
138 ***********************************************************************/
140 DEFUN_NOSH (show_debugging_bgp_vnc
,
141 show_debugging_bgp_vnc_cmd
,
142 "show debugging bgp vnc",
150 vty_out(vty
, "BGP VNC debugging status:\n");
152 for (i
= 0; i
< (sizeof(vncdebug
) / sizeof(struct vnc_debug
)); ++i
) {
153 if (term_vnc_debug
& vncdebug
[i
].bit
) {
154 vty_out(vty
, " BGP VNC %s debugging is on\n",
162 static int bgp_vnc_config_write_debug(struct vty
*vty
)
167 for (i
= 0; i
< array_size(vncdebug
); ++i
) {
168 if (conf_vnc_debug
& vncdebug
[i
].bit
) {
169 vty_out(vty
, "debug bgp vnc %s\n", vncdebug
[i
].name
);
176 static struct cmd_node debug_node
= {DEBUG_VNC_NODE
, "", 1};
178 void vnc_debug_init(void)
180 install_node(&debug_node
, bgp_vnc_config_write_debug
);
181 install_element(ENABLE_NODE
, &show_debugging_bgp_vnc_cmd
);
183 install_element(ENABLE_NODE
, &debug_bgp_vnc_cmd
);
184 install_element(CONFIG_NODE
, &debug_bgp_vnc_cmd
);
185 install_element(ENABLE_NODE
, &no_debug_bgp_vnc_cmd
);
186 install_element(CONFIG_NODE
, &no_debug_bgp_vnc_cmd
);
188 install_element(ENABLE_NODE
, &no_debug_bgp_vnc_all_cmd
);
189 install_element(CONFIG_NODE
, &no_debug_bgp_vnc_all_cmd
);