api: API trace improvements
[vpp.git] / src / vpp-api / client / client.c
index 20adc95..7a30792 100644 (file)
@@ -30,7 +30,8 @@
 #include <vlibapi/api.h>
 #include <vlibmemory/api.h>
 
-#include <vpp/api/vpe_msg_enum.h>
+#include <vlibmemory/memclnt.api_enum.h>
+#include <vlibmemory/memclnt.api_types.h>
 
 #include "vppapiclient.h"
 
@@ -48,17 +49,6 @@ bool rx_thread_done;
  *  vac_read() -> resumes RX thread
  */
 
-#define vl_typedefs             /* define message structures */
-#include <vpp/api/vpe_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun             /* define message structures */
-#include <vpp/api/vpe_all_api_h.h>
-#undef vl_endianfun
-
-vlib_main_t vlib_global_main;
-vlib_main_t **vlib_mains;
-
 typedef struct {
   u8 connected_to_vlib;
   pthread_t rx_thread_handle;
@@ -111,14 +101,6 @@ cleanup (void)
   clib_memset(pm, 0, sizeof(*pm));
 }
 
-/*
- * Satisfy external references when -lvlib is not available.
- */
-void vlib_cli_output (struct vlib_main_t * vm, char * fmt, ...)
-{
-  clib_warning ("vlib_cli_output called...");
-}
-
 void
 vac_free (void * msg)
 {
@@ -423,12 +405,14 @@ vac_read (char **p, int *l, u16 timeout)
   vl_shmem_hdr_t *shmem_hdr;
 
   /* svm_queue_sub(below) returns {-1, -2} */
-  if (!pm->connected_to_vlib) return -3;
+  if (!pm->connected_to_vlib)
+    return VAC_NOT_CONNECTED;
 
   *l = 0;
 
   /* svm_queue_sub(below) returns {-1, -2} */
-  if (am->our_pid == 0) return (-4);
+  if (am->our_pid == 0)
+    return (VAC_SHM_NOT_READY);
 
   /* Poke timeout thread */
   if (timeout)
@@ -492,16 +476,17 @@ vac_read (char **p, int *l, u16 timeout)
   vl_msg_api_free((void *) msg);
   /* Client might forget to resume RX thread on failure */
   vac_rx_resume ();
-  return -1;
+  return VAC_TIMEOUT;
 }
 
 /*
  * XXX: Makes the assumption that client_index is the first member
  */
-typedef VL_API_PACKED(struct _vl_api_header {
+typedef struct _vl_api_header
+{
   u16 _vl_msg_id;
   u32 client_index;
-}) vl_api_header_t;
+} __attribute__ ((packed)) vl_api_header_t;
 
 static u32
 vac_client_index (void)
@@ -518,7 +503,8 @@ vac_write (char *p, int l)
   svm_queue_t *q;
   vac_main_t *pm = &vac_main;
 
-  if (!pm->connected_to_vlib) return -1;
+  if (!pm->connected_to_vlib)
+    return VAC_NOT_CONNECTED;
   if (!mp) return (-1);
 
   memcpy(mp, p, l);