X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvpp-api%2Fvapi%2Fvapi.h;h=46666293e4bbe18500574d29da98a3ffb09e5358;hb=d1c75063daf9466a7ef10beed9c9e58245d3380e;hp=2a401c21189560cf9681ff042aa037c93a69779a;hpb=dab732a18c39d13af1770b55d7cef2359ea66412;p=vpp.git diff --git a/src/vpp-api/vapi/vapi.h b/src/vpp-api/vapi/vapi.h index 2a401c21189..46666293e4b 100644 --- a/src/vpp-api/vapi/vapi.h +++ b/src/vpp-api/vapi/vapi.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -43,7 +44,7 @@ extern "C" * process). It's not recommended to mix the higher and lower level APIs. Due * to version issues, the higher-level APIs are not part of the shared library. */ - typedef struct vapi_ctx_s *vapi_ctx_t; +typedef struct vapi_ctx_s *vapi_ctx_t; /** * @brief allocate vapi message of given size @@ -55,7 +56,7 @@ extern "C" * * @return pointer to message or NULL if out of memory */ - void *vapi_msg_alloc (vapi_ctx_t ctx, size_t size); +void *vapi_msg_alloc (vapi_ctx_t ctx, size_t size); /** * @brief free a vapi message @@ -65,7 +66,7 @@ extern "C" * @param ctx opaque vapi context * @param msg message to be freed */ - void vapi_msg_free (vapi_ctx_t ctx, void *msg); +void vapi_msg_free (vapi_ctx_t ctx, void *msg); /** * @brief allocate vapi context @@ -74,18 +75,18 @@ extern "C" * * @return VAPI_OK on success, other error code on error */ - vapi_error_e vapi_ctx_alloc (vapi_ctx_t * result); +vapi_error_e vapi_ctx_alloc (vapi_ctx_t *result); /** * @brief free vapi context */ - void vapi_ctx_free (vapi_ctx_t ctx); +void vapi_ctx_free (vapi_ctx_t ctx); /** * @brief check if message identified by it's message id is known by the vpp to * which the connection is open */ - bool vapi_is_msg_available (vapi_ctx_t ctx, vapi_msg_id_t type); +bool vapi_is_msg_available (vapi_ctx_t ctx, vapi_msg_id_t type); /** * @brief connect to vpp @@ -100,11 +101,30 @@ extern "C" * * @return VAPI_OK on success, other error code on error */ - vapi_error_e vapi_connect (vapi_ctx_t ctx, const char *name, - const char *chroot_prefix, - int max_outstanding_requests, - int response_queue_size, vapi_mode_e mode, - bool handle_keepalives); +vapi_error_e vapi_connect (vapi_ctx_t ctx, const char *name, + const char *chroot_prefix, + int max_outstanding_requests, + int response_queue_size, vapi_mode_e mode, + bool handle_keepalives); + +/** + * @brief connect to vpp from a client in same process + * @remark This MUST be called from a separate thread. If called + * from the main thread, it will deadlock. + * + * @param ctx opaque vapi context, must be allocated using vapi_ctx_alloc first + * @param name application name + * @param max_outstanding_requests max number of outstanding requests queued + * @param response_queue_size size of the response queue + * @param mode mode of operation - blocking or nonblocking + * @param handle_keepalives - if true, automatically handle memclnt_keepalive + * + * @return VAPI_OK on success, other error code on error + */ +vapi_error_e vapi_connect_from_vpp (vapi_ctx_t ctx, const char *name, + int max_outstanding_requests, + int response_queue_size, vapi_mode_e mode, + bool handle_keepalives); /** * @brief disconnect from vpp @@ -113,7 +133,8 @@ extern "C" * * @return VAPI_OK on success, other error code on error */ - vapi_error_e vapi_disconnect (vapi_ctx_t ctx); +vapi_error_e vapi_disconnect (vapi_ctx_t ctx); +vapi_error_e vapi_disconnect_from_vpp (vapi_ctx_t ctx); /** * @brief get event file descriptor @@ -126,7 +147,7 @@ extern "C" * * @return VAPI_OK on success, other error code on error */ - vapi_error_e vapi_get_fd (vapi_ctx_t ctx, int *fd); +vapi_error_e vapi_get_fd (vapi_ctx_t ctx, int *fd); /** * @brief low-level api for sending messages to vpp @@ -139,7 +160,7 @@ extern "C" * * @return VAPI_OK on success, other error code on error */ - vapi_error_e vapi_send (vapi_ctx_t ctx, void *msg); +vapi_error_e vapi_send (vapi_ctx_t ctx, void *msg); /** * @brief low-level api for atomically sending two messages to vpp - either