hsa: add support for SAPI in vpp_echo
[vpp.git] / src / plugins / hs_apps / sapi / vpp_echo_bapi.c
index 38fb522..e38559c 100644 (file)
@@ -103,6 +103,19 @@ echo_send_del_cert_key (echo_main_t * em)
   vl_msg_api_send_shmem (em->vl_input_queue, (u8 *) & bmp);
 }
 
+int
+echo_bapi_recv_fd (echo_main_t *em, int *fds, int n_fds)
+{
+  clib_error_t *err;
+  err = vl_socket_client_recv_fd_msg (fds, n_fds, 5);
+  if (err)
+    {
+      clib_error_report (err);
+      return -1;
+    }
+  return 0;
+}
+
 static u8
 echo_transport_needs_crypto (transport_proto_t proto)
 {
@@ -265,11 +278,11 @@ echo_segment_lookup (u64 segment_handle)
   clib_spinlock_lock (&em->segment_handles_lock);
   segment_idxp = hash_get (em->shared_segment_handles, segment_handle);
   clib_spinlock_unlock (&em->segment_handles_lock);
-  if (!segment_idxp)
-    return ~0;
+  if (segment_idxp)
+    return ((u32) *segment_idxp);
 
   ECHO_LOG (2, "Segment not mapped (0x%lx)", segment_handle);
-  return ((u32) *segment_idxp);
+  return ~0;
 }
 
 void
@@ -548,6 +561,10 @@ _(APP_DEL_CERT_KEY_PAIR_REPLY, app_del_cert_key_pair_reply)
 #include <vnet/session/session.api.h>
 #undef vl_endianfun
 
+#define vl_calcsizefun
+#include <vnet/session/session.api.h>
+#undef vl_calcsizefun
+
 #define vl_printfun
 #include <vnet/session/session.api.h>
 #undef vl_printfun
@@ -569,10 +586,12 @@ echo_api_hookup (echo_main_t * em)
     return;
 
 #define _(N, n)                                                               \
-  vl_msg_api_set_handlers (REPLY_MSG_ID_BASE + VL_API_##N, #n,                \
-                          vl_api_##n##_t_handler, vl_noop_handler,           \
-                          vl_api_##n##_t_endian, vl_api_##n##_t_print,       \
-                          sizeof (vl_api_##n##_t), 1);
+  vl_msg_api_set_handlers (                                                   \
+    REPLY_MSG_ID_BASE + VL_API_##N, #n, vl_api_##n##_t_handler,               \
+    vl_noop_handler, vl_api_##n##_t_endian, vl_api_##n##_t_print,             \
+    sizeof (vl_api_##n##_t), 1, vl_api_##n##_t_print_json,                    \
+    vl_api_##n##_t_tojson, vl_api_##n##_t_fromjson,                           \
+    vl_api_##n##_t_calc_size);
   foreach_quic_echo_msg;
 #undef _
 }