Use __attribute__((weak)) references where necessary
[vpp.git] / src / vpp / api / api.c
index d2b06ff..6c06ab4 100644 (file)
@@ -72,6 +72,7 @@
 #include <vpp/api/vpe_all_api_h.h>
 #undef vl_printfun
 #include <vlibapi/api_helper_macros.h>
+
 #define foreach_vpe_api_msg                                             \
 _(CONTROL_PING, control_ping)                                           \
 _(CLI, cli)                                                             \
@@ -84,6 +85,7 @@ _(GET_NEXT_INDEX, get_next_index)                                       \
 
 #define QUOTE_(x) #x
 #define QUOTE(x) QUOTE_(x)
+
 typedef enum
 {
   RESOLVE_IP4_ADD_DEL_ROUTE = 1,
@@ -162,16 +164,16 @@ static void
 vl_api_cli_t_handler (vl_api_cli_t * mp)
 {
   vl_api_cli_reply_t *rp;
-  unix_shared_memory_queue_t *q;
+  vl_api_registration_t *reg;
   vlib_main_t *vm = vlib_get_main ();
   api_main_t *am = &api_main;
   unformat_input_t input;
   u8 *shmem_vec = 0;
   void *oldheap;
 
-  q = vl_api_client_index_to_input_queue (mp->client_index);
-  if (!q)
-    return;
+  reg = vl_api_client_index_to_registration (mp->client_index);
+  if (!reg)
+    return;;
 
   rp = vl_msg_api_alloc (sizeof (*rp));
   rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
@@ -191,7 +193,7 @@ vl_api_cli_t_handler (vl_api_cli_t * mp)
 
   rp->reply_in_shmem = (uword) shmem_vec;
 
-  vl_msg_api_send_shmem (q, (u8 *) & rp);
+  vl_api_send_msg (reg, (u8 *) rp);
 }
 
 static void
@@ -365,6 +367,8 @@ vl_api_get_node_graph_t_handler (vl_api_get_node_graph_t * mp)
   vlib_main_t *vm = vlib_get_main ();
   void *oldheap;
   vl_api_get_node_graph_reply_t *rmp;
+  static vlib_node_t ***node_dups;
+  static vlib_main_t **stat_vms;
 
   pthread_mutex_lock (&am->vlib_rp->mutex);
   oldheap = svm_push_data_heap (am->vlib_rp);
@@ -375,10 +379,11 @@ vl_api_get_node_graph_t_handler (vl_api_get_node_graph_t * mp)
   vec_validate (vector, 16384);
   vec_reset_length (vector);
 
-  /* $$$$ FIXME */
-  vector = vlib_node_serialize (&vm->node_main, vector,
-                               (u32) ~ 0 /* all threads */ ,
-                               1 /* include nexts */ ,
+  vlib_node_get_nodes (vm, 0 /* main threads */ ,
+                      0 /* include stats */ ,
+                      1 /* barrier sync */ ,
+                      &node_dups, &stat_vms);
+  vector = vlib_node_serialize (vm, node_dups, vector, 1 /* include nexts */ ,
                                1 /* include stats */ );
 
   svm_pop_heap (oldheap);
@@ -398,7 +403,7 @@ static void vl_api_##nn##_t_handler (                                   \
 {                                                                       \
     vpe_client_registration_t *reg;                                     \
     vpe_api_main_t * vam = &vpe_api_main;                               \
-    unix_shared_memory_queue_t * q;                                     \
+    svm_queue_t * q;                                     \
                                                                         \
     /* One registration only... */                                      \
     pool_foreach(reg, vam->nn##_registrations,                          \
@@ -469,7 +474,7 @@ vpe_api_hookup (vlib_main_t * vm)
 
 VLIB_API_INIT_FUNCTION (vpe_api_hookup);
 
-static clib_error_t *
+clib_error_t *
 vpe_api_init (vlib_main_t * vm)
 {
   vpe_api_main_t *am = &vpe_api_main;
@@ -482,14 +487,11 @@ vpe_api_init (vlib_main_t * vm)
 #undef _
 
   vl_set_memory_region_name ("/vpe-api");
-  vl_enable_disable_memory_api (vm, 1 /* enable it */ );
+  vl_mem_api_enable_disable (vm, 1 /* enable it */ );
 
   return 0;
 }
 
-VLIB_INIT_FUNCTION (vpe_api_init);
-
-
 static clib_error_t *
 api_segment_config (vlib_main_t * vm, unformat_input_t * input)
 {