summaryrefslogtreecommitdiffstats
path: root/src/vat
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-01-20 19:50:09 -0500
committerDamjan Marion <dmarion.lists@gmail.com>2017-01-23 15:17:25 +0000
commitfe6bdfd84573cd8813a211f9094ee734f088ce16 (patch)
tree68c109d579ebbcb64c2a0e9af379aaf0522c0c0b /src/vat
parent675a69cdf6eb1a8e60613bef4a918fe1b354c276 (diff)
binary-api debug CLI works with plugins
Change-Id: I81f33f5153d5afac94b66b5a8cb91da77463af79 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vat')
-rw-r--r--src/vat/api_format.c95
-rw-r--r--src/vat/vat.h33
2 files changed, 44 insertions, 84 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 1babaf406f5..653cf79f3db 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -70,6 +70,46 @@
#include <vpp/api/vpe_all_api_h.h>
#undef vl_printfun
+#include <vlibapi/vat_helper_macros.h>
+
+f64
+vat_time_now (vat_main_t * vam)
+{
+#if VPP_API_TEST_BUILTIN
+ return vlib_time_now (vam->vlib_main);
+#else
+ return clib_time_now (&vam->clib_time);
+#endif
+}
+
+void
+errmsg (char *fmt, ...)
+{
+ vat_main_t *vam = &vat_main;
+ va_list va;
+ u8 *s;
+
+ va_start (va, fmt);
+ s = va_format (0, fmt, &va);
+ va_end (va);
+
+ vec_add1 (s, 0);
+
+#if VPP_API_TEST_BUILTIN
+ vlib_cli_output (vam->vlib_main, (char *) s);
+#else
+ {
+ if (vam->ifp != stdin)
+ fformat (vam->ofp, "%s(%d): \n", vam->current_file,
+ vam->input_line_number);
+ fformat (vam->ofp, (char *) s);
+ fflush (vam->ofp);
+ }
+#endif
+
+ vec_free (s);
+}
+
static uword
api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
{
@@ -88,8 +128,6 @@ api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
return 1;
}
-void vat_suspend (vlib_main_t * vm, f64 interval);
-
#if VPP_API_TEST_BUILTIN == 0
/* Parse an IP4 address %d.%d.%d.%d. */
uword
@@ -3867,59 +3905,6 @@ _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
sw_interface_set_dpdk_hqos_tctbl_reply)
#endif
-/* M: construct, but don't yet send a message */
-
-#define M(T,t) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-#define M2(T,t,n) \
-do { \
- vam->result_ready = 0; \
- mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)+(n)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T); \
- mp->client_index = vam->my_client_index; \
-} while(0);
-
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- return (vam->retval); \
- } \
- vat_suspend (vam->vlib_main, 1e-3); \
- } \
- return -99; \
-} while(0);
-
-/* W2: wait for results, with timeout */
-#define W2(body) \
-do { \
- timeout = vat_time_now (vam) + 1.0; \
- \
- while (vat_time_now (vam) < timeout) { \
- if (vam->result_ready == 1) { \
- (body); \
- return (vam->retval); \
- } \
- vat_suspend (vam->vlib_main, 1e-3); \
- } \
- return -99; \
-} while(0);
-
typedef struct
{
u8 *name;
diff --git a/src/vat/vat.h b/src/vat/vat.h
index 64be2f7f97f..3d7d96ae566 100644
--- a/src/vat/vat.h
+++ b/src/vat/vat.h
@@ -190,36 +190,11 @@ typedef struct
vlib_main_t *vlib_main;
} vat_main_t;
-vat_main_t vat_main;
-
-static inline f64
-vat_time_now (vat_main_t * vam)
-{
-#if VPP_API_TEST_BUILTIN
- return vlib_time_now (vam->vlib_main);
-#else
- return clib_time_now (&vam->clib_time);
-#endif
-}
-
-#if VPP_API_TEST_BUILTIN
-#define errmsg(fmt,args...) \
-do { \
- vat_main_t *__vam = &vat_main; \
- vlib_cli_output (__vam->vlib_main, fmt, ##args); \
- } while(0);
-#else
-#define errmsg(fmt,args...) \
-do { \
- vat_main_t *__vam = &vat_main; \
- if(__vam->ifp != stdin) \
- fformat(__vam->ofp,"%s(%d): \n", __vam->current_file, \
- __vam->input_line_number); \
- fformat(__vam->ofp, fmt "\n", ##args); \
- fflush(__vam->ofp); \
-} while(0);
-#endif
+extern vat_main_t vat_main;
+void vat_suspend (vlib_main_t * vm, f64 interval);
+f64 vat_time_now (vat_main_t * vam);
+void errmsg (char *fmt, ...);
void vat_api_hookup (vat_main_t * vam);
int api_sw_interface_dump (vat_main_t * vam);
void do_one_file (vat_main_t * vam);