32 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 39 #define foreach_session_api_msg \ 40 _(MAP_ANOTHER_SEGMENT_REPLY, map_another_segment_reply) \ 41 _(BIND_URI, bind_uri) \ 42 _(UNBIND_URI, unbind_uri) \ 43 _(CONNECT_URI, connect_uri) \ 44 _(DISCONNECT_SESSION, disconnect_session) \ 45 _(DISCONNECT_SESSION_REPLY, disconnect_session_reply) \ 46 _(ACCEPT_SESSION_REPLY, accept_session_reply) \ 47 _(RESET_SESSION_REPLY, reset_session_reply) \ 48 _(BIND_SOCK, bind_sock) \ 49 _(UNBIND_SOCK, unbind_sock) \ 50 _(CONNECT_SOCK, connect_sock) \ 51 _(DISCONNECT_SOCK, disconnect_sock) \ 52 _(DISCONNECT_SOCK_REPLY, disconnect_sock_reply) \ 53 _(ACCEPT_SOCK_REPLY, accept_sock_reply) \ 54 _(RESET_SOCK_REPLY, reset_sock_reply) \ 55 _(SESSION_ENABLE_DISABLE, session_enable_disable) \ 71 memset (mp, 0,
sizeof (*mp));
72 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MAP_ANOTHER_SEGMENT);
74 strncpy ((
char *) mp->
segment_name, (
char *) segment_name,
96 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_ACCEPT_SESSION);
125 memset (mp, 0,
sizeof (*mp));
126 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_DISCONNECT_SESSION);
146 memset (mp, 0,
sizeof (*mp));
147 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_RESET_SESSION);
170 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_CONNECT_URI_REPLY);
171 mp->
context = app->api_context;
192 mp->
retval = VNET_API_ERROR_SESSION_CONNECT_FAIL;
228 rv = VNET_API_ERROR_INVALID_VALUE;
235 rv = VNET_API_ERROR_INVALID_VALUE_2;
263 rv = VNET_API_ERROR_QUEUE_FULL;
276 return (
u64) s->session_index << 32 | (
u64) s->thread_index;
293 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_ACCEPT_SOCK);
323 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_CONNECT_SOCK_REPLY);
324 mp->
context = app->api_context;
364 memset (mp, 0,
sizeof (*mp));
365 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_DISCONNECT_SOCK);
384 memset (mp, 0,
sizeof (*mp));
385 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_RESET_SOCK);
409 rv = VNET_API_ERROR_INVALID_VALUE;
416 rv = VNET_API_ERROR_INVALID_VALUE_2;
444 rv = VNET_API_ERROR_QUEUE_FULL;
478 if (thread_index >=
vec_len (smm->sessions))
479 return VNET_API_ERROR_INVALID_VALUE;
481 pool = smm->sessions[thread_index];
484 return VNET_API_ERROR_INVALID_VALUE_2;
505 char segment_name[128];
506 u32 segment_name_length;
511 "Out of options, fix api message definition");
513 segment_name_length =
ARRAY_LEN (segment_name);
515 memset (a, 0,
sizeof (*a));
517 a->uri = (
char *) mp->
uri;
520 a->segment_name = segment_name;
521 a->segment_name_length = segment_name_length;
536 if (segment_name_length)
538 memcpy (rmp->
segment_name, segment_name, segment_name_length);
565 a->uri = (
char *) mp->
uri;
680 char segment_name[128];
681 u32 segment_name_length;
686 "Out of options, fix api message definition");
688 segment_name_length =
ARRAY_LEN (segment_name);
690 memset (a, 0,
sizeof (*a));
695 a->tep.is_ip4 = mp->
is_ip4;
696 a->tep.port = mp->
port;
697 a->tep.vrf = mp->
vrf;
701 a->segment_name = segment_name;
702 a->segment_name_length = segment_name_length;
714 if (segment_name_length)
716 memcpy(rmp->
segment_name, segment_name, segment_name_length);
750 a->tep.is_ip4 = mp->
is_ip4;
751 a->tep.port = mp->
port;
752 a->tep.vrf = mp->
vrf;
808 u32 session_index, thread_index;
834 u32 session_index, thread_index;
853 #define vl_msg_name_crc_list 855 #undef vl_msg_name_crc_list 860 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); 861 foreach_vl_msg_name_crc_session;
878 vl_msg_api_set_handlers(VL_API_##N, #n, \ 879 vl_api_##n##_t_handler, \ 881 vl_api_##n##_t_endian, \ 882 vl_api_##n##_t_print, \ 883 sizeof(vl_api_##n##_t), 1);
static void vl_api_disconnect_session_reply_t_handler(vl_api_disconnect_session_reply_t *mp)
static int send_session_connected_callback(u32 api_client_index, stream_session_t *s, u8 is_fail)
static clib_error_t * session_api_hookup(vlib_main_t *vm)
vpp->client reset session API
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
struct _vnet_connect_args vnet_connect_args_t
int vnet_bind_uri(vnet_bind_args_t *a)
static void vl_api_accept_sock_reply_t_handler(vl_api_accept_sock_reply_t *mp)
int vnet_unbind_uri(char *uri, u32 api_client_index)
#define REPLY_MACRO2(t, body)
static f64 vlib_time_now(vlib_main_t *vm)
static void vl_api_map_another_segment_reply_t_handler(vl_api_map_another_segment_reply_t *mp)
int vnet_disconnect_session(u32 session_index, u32 thread_index)
Bind to an ip:port pair for a given transport protocol.
client->vpp, reply to an accept message
application_t * application_lookup(u32 api_client_index)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
static void vl_api_unbind_sock_t_handler(vl_api_unbind_sock_t *mp)
#define foreach_session_api_msg
static void vl_api_disconnect_sock_reply_t_handler(vl_api_disconnect_sock_reply_t *mp)
struct _stream_session_t stream_session_t
static int send_session_connected_uri_callback(u32 api_client_index, stream_session_t *s, u8 is_fail)
#define VNET_CONNECT_REDIRECTED
static stream_session_t * stream_session_get(u64 si, u32 thread_index)
static void vl_api_connect_uri_t_handler(vl_api_connect_uri_t *mp)
void session_manager_get_segment_info(u32 index, u8 **name, u32 *size)
static void vl_api_session_enable_disable_t_handler(vl_api_session_enable_disable_t *mp)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
void vl_msg_api_free(void *)
static void send_session_reset_callback(stream_session_t *s)
struct _stream_session_cb_vft session_cb_vft_t
struct _vnet_unbind_args_t vnet_unbind_args_t
void stream_session_cleanup(stream_session_t *s)
Cleanup transport and session state.
u64 client_event_queue_address
int unix_shared_memory_queue_add(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
static session_cb_vft_t session_cb_vft
static session_manager_main_t * vnet_get_session_manager_main()
static session_cb_vft_t uri_session_cb_vft
static void vl_api_accept_session_reply_t_handler(vl_api_accept_session_reply_t *mp)
static void vl_api_disconnect_session_t_handler(vl_api_disconnect_session_t *mp)
u64 server_event_queue_address
Reply for session enable/disable.
struct _session_manager_main session_manager_main_t
u64 client_event_queue_address
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
u64 vpp_event_queue_address
vpp->client, accept this session
static int send_session_accept_callback(stream_session_t *s)
static unix_shared_memory_queue_t * session_manager_get_vpp_event_queue(u32 thread_index)
int vnet_disconnect(vnet_disconnect_args_t *a)
void * vl_msg_api_alloc(int nbytes)
vpp->client reset session API
static void send_session_disconnect_uri_callback(stream_session_t *s)
static int redirect_connect_uri_callback(u32 server_api_client_index, void *mp_arg)
Redirect a connect_uri message to the indicated server.
vpp->client, connect reply
#define clib_warning(format, args...)
static int redirect_connect_callback(u32 server_api_client_index, void *mp_arg)
Redirect a connect_uri message to the indicated server.
#define clib_memcpy(a, b, c)
vpp->client, accept this session
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
struct _application application_t
static int api_session_not_valid(u32 session_index, u32 thread_index)
int api_parse_session_handle(u64 handle, u32 *session_index, u32 *thread_index)
bidirectional disconnect API
enable/disable session layer
static void vl_api_connect_sock_t_handler(vl_api_connect_sock_t *mp)
bidirectional disconnect reply API
static void send_session_reset_uri_callback(stream_session_t *s)
static void vl_api_bind_sock_t_handler(vl_api_bind_sock_t *mp)
vpp->client, please map an additional shared memory segment
u64 vpp_event_queue_address
void application_del(application_t *app)
void stream_session_disconnect(stream_session_t *s)
Disconnect session and propagate to transport.
u64 server_event_queue_address
Connect to a remote peer.
static vlib_main_t * vlib_get_main(void)
u64 vpp_event_queue_address
static void setup_message_id_table(api_main_t *am)
bidirectional disconnect API
static u64 make_session_handle(stream_session_t *s)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define STATIC_ASSERT(truth,...)
application_t * application_get(u32 index)
int vnet_connect(vnet_connect_args_t *a)
int vnet_unbind(vnet_unbind_args_t *a)
VLIB_API_INIT_FUNCTION(session_api_hookup)
static int send_add_segment_callback(u32 api_client_index, const u8 *segment_name, u32 segment_size)
static void send_session_disconnect_callback(stream_session_t *s)
vpp/server->client, connect reply
client->vpp reset session reply
client->vpp, reply to an accept message
u64 vpp_event_queue_address
static int send_session_accept_uri_callback(stream_session_t *s)
bidirectional disconnect reply API
int vnet_connect_uri(vnet_connect_args_t *a)
client->vpp reset session reply
static void vl_api_disconnect_sock_t_handler(vl_api_disconnect_sock_t *mp)
struct _vnet_bind_args_t vnet_bind_args_t
static void vl_api_reset_sock_reply_t_handler(vl_api_reset_sock_reply_t *mp)
static void vl_api_bind_uri_t_handler(vl_api_bind_uri_t *mp)
static void vl_api_reset_session_reply_t_handler(vl_api_reset_session_reply_t *mp)
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static void vl_api_unbind_uri_t_handler(vl_api_unbind_uri_t *mp)