memset (bmp, 0, sizeof (*bmp));
bmp->_vl_msg_id = ntohs (VL_API_SESSION_ENABLE_DISABLE);
- bmp->client_index = wrk->bapi_client_index;
+ bmp->client_index = wrk->api_client_handle;
bmp->context = htonl (0xfeedface);
bmp->is_enable = is_enable;
vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & bmp);
memset (bmp, 0, sizeof (*bmp));
bmp->_vl_msg_id = ntohs (VL_API_APP_ATTACH);
- bmp->client_index = wrk->bapi_client_index;
+ bmp->client_index = wrk->api_client_handle;
bmp->context = htonl (0xfeedface);
bmp->options[APP_OPTIONS_FLAGS] =
APP_OPTIONS_FLAGS_ACCEPT_REDIRECT | APP_OPTIONS_FLAGS_ADD_SEGMENT |
memset (bmp, 0, sizeof (*bmp));
bmp->_vl_msg_id = ntohs (VL_API_APPLICATION_DETACH);
- bmp->client_index = wrk->bapi_client_index;
+ bmp->client_index = wrk->api_client_handle;
bmp->context = htonl (0xfeedface);
vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & bmp);
}
memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_APP_WORKER_ADD_DEL);
- mp->client_index = wrk->bapi_client_index;
+ mp->client_index = wrk->api_client_handle;
mp->app_index = clib_host_to_net_u32 (vcm->app_index);
mp->context = wrk->wrk_index;
mp->is_add = is_add;
memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_APP_WORKER_ADD_DEL);
- mp->client_index = wrk->bapi_client_index;
+ mp->client_index = wrk->api_client_handle;
mp->app_index = clib_host_to_net_u32 (vcm->app_index);
mp->context = wrk->wrk_index;
mp->is_add = 0;
cert_mp = vl_msg_api_alloc (sizeof (*cert_mp) + cert_len);
clib_memset (cert_mp, 0, sizeof (*cert_mp));
cert_mp->_vl_msg_id = ntohs (VL_API_APPLICATION_TLS_CERT_ADD);
- cert_mp->client_index = wrk->bapi_client_index;
+ cert_mp->client_index = wrk->api_client_handle;
cert_mp->context = session->session_index;
cert_mp->cert_len = clib_host_to_net_u16 (cert_len);
clib_memcpy_fast (cert_mp->cert, cert, cert_len);
key_mp = vl_msg_api_alloc (sizeof (*key_mp) + key_len);
clib_memset (key_mp, 0, sizeof (*key_mp));
key_mp->_vl_msg_id = ntohs (VL_API_APPLICATION_TLS_KEY_ADD);
- key_mp->client_index = wrk->bapi_client_index;
+ key_mp->client_index = wrk->api_client_handle;
key_mp->context = session->session_index;
key_mp->key_len = clib_host_to_net_u16 (key_len);
clib_memcpy_fast (key_mp->key, key, key_len);
am = vlibapi_get_main ();
wrk->vl_input_queue = am->shmem_hdr->vl_input_queue;
- wrk->bapi_client_index = (u32) am->my_client_index;
+ wrk->api_client_handle = (u32) am->my_client_index;
VDBG (0, "app (%s) is connected to VPP!", wrk_name);
vcl_evt (VCL_EVT_INIT, vcm);
if (vcm->workers[i].current_pid == wrk->current_pid)
{
wrk->vl_input_queue = vcm->workers[i].vl_input_queue;
- wrk->bapi_client_index = vcm->workers[i].bapi_client_index;
+ wrk->api_client_handle = vcm->workers[i].api_client_handle;
return 0;
}
}
/** Worker index in vpp*/
u32 vpp_wrk_index;
- /** VPP bapi client handle */
- u32 bapi_client_index;
+ /**
+ * Generic api client handle. When binary api is in used, it stores
+ * the "client_index" and when socket api is use, it stores the sapi
+ * client handle */
+ u32 api_client_handle;
/** VPP binary api input queue */
svm_queue_t *vl_input_queue;
goto failed;
}
- wrk->bapi_client_index = mp->api_client_handle;
+ wrk->api_client_handle = mp->api_client_handle;
wrk->app_event_queue = uword_to_pointer (mp->app_mq, svm_msg_q_t *);
ctrl_mq = uword_to_pointer (mp->vpp_ctrl_mq, svm_msg_q_t *);
vec_validate (wrk->vpp_event_queues, mp->vpp_ctrl_mq_thread);
goto failed;
wrk = vcl_worker_get_current ();
+ wrk->api_client_handle = mp->api_client_handle;
wrk->vpp_wrk_index = mp->wrk_index;
wrk->app_event_queue = uword_to_pointer (mp->app_event_queue_address,
svm_msg_q_t *);
app_alloc_ctrl_evt_to_vpp (mq, app_evt, SESSION_CTRL_EVT_LISTEN);
mp = (session_listen_msg_t *) app_evt->evt->data;
memset (mp, 0, sizeof (*mp));
- mp->client_index = wrk->bapi_client_index;
+ mp->client_index = wrk->api_client_handle;
mp->context = s->session_index;
mp->wrk_index = wrk->vpp_wrk_index;
mp->is_ip4 = s->transport.is_ip4;
app_alloc_ctrl_evt_to_vpp (mq, app_evt, SESSION_CTRL_EVT_CONNECT);
mp = (session_connect_msg_t *) app_evt->evt->data;
memset (mp, 0, sizeof (*mp));
- mp->client_index = wrk->bapi_client_index;
+ mp->client_index = wrk->api_client_handle;
mp->context = s->session_index;
mp->wrk_index = wrk->vpp_wrk_index;
mp->is_ip4 = s->transport.is_ip4;
app_alloc_ctrl_evt_to_vpp (mq, app_evt, SESSION_CTRL_EVT_UNLISTEN);
mp = (session_unlisten_msg_t *) app_evt->evt->data;
memset (mp, 0, sizeof (*mp));
- mp->client_index = wrk->bapi_client_index;
+ mp->client_index = wrk->api_client_handle;
mp->wrk_index = wrk->vpp_wrk_index;
mp->handle = s->vpp_handle;
mp->context = wrk->wrk_index;
app_alloc_ctrl_evt_to_vpp (mq, app_evt, SESSION_CTRL_EVT_DISCONNECT);
mp = (session_disconnect_msg_t *) app_evt->evt->data;
memset (mp, 0, sizeof (*mp));
- mp->client_index = wrk->bapi_client_index;
+ mp->client_index = wrk->api_client_handle;
mp->handle = s->vpp_handle;
app_send_ctrl_evt_to_vpp (mq, app_evt);
}
app_alloc_ctrl_evt_to_vpp (mq, app_evt, SESSION_CTRL_EVT_APP_DETACH);
mp = (session_app_detach_msg_t *) app_evt->evt->data;
memset (mp, 0, sizeof (*mp));
- mp->client_index = wrk->bapi_client_index;
+ mp->client_index = wrk->api_client_handle;
app_send_ctrl_evt_to_vpp (mq, app_evt);
}
mq = vcl_session_vpp_evt_q (wrk, s);
app_alloc_ctrl_evt_to_vpp (mq, app_evt, SESSION_CTRL_EVT_WORKER_UPDATE);
mp = (session_worker_update_msg_t *) app_evt->evt->data;
- mp->client_index = wrk->bapi_client_index;
+ mp->client_index = wrk->api_client_handle;
mp->handle = s->vpp_handle;
mp->req_wrk_index = wrk->vpp_wrk_index;
mp->wrk_index = wrk_index;
mq = vcl_worker_ctrl_mq (wrk);
app_alloc_ctrl_evt_to_vpp (mq, app_evt, SESSION_CTRL_EVT_APP_WRK_RPC);
mp = (session_app_wrk_rpc_msg_t *) app_evt->evt->data;
- mp->client_index = wrk->bapi_client_index;
+ mp->client_index = wrk->api_client_handle;
mp->wrk_index = dst_wrk->vpp_wrk_index;
clib_memcpy (mp->data, data, data_len);
app_send_ctrl_evt_to_vpp (mq, app_evt);
if (state & STATE_VPP_CLOSING)
{
vpp_evt_q = vcl_session_vpp_evt_q (wrk, session);
- vcl_send_session_disconnected_reply (vpp_evt_q, wrk->bapi_client_index,
+ vcl_send_session_disconnected_reply (vpp_evt_q, wrk->api_client_handle,
vpp_handle, 0);
VDBG (1, "session %u [0x%llx]: sending disconnect REPLY...",
session->session_index, vpp_handle);
return rv;
VDBG (0, "app_name '%s', my_client_index %d (0x%x)", app_name,
- vcm->workers[0].bapi_client_index, vcm->workers[0].bapi_client_index);
+ vcm->workers[0].api_client_handle, vcm->workers[0].api_client_handle);
return VPPCOM_OK;
}
else if (state == STATE_DISCONNECT)
{
svm_msg_q_t *mq = vcl_session_vpp_evt_q (wrk, session);
- vcl_send_session_reset_reply (mq, wrk->bapi_client_index,
+ vcl_send_session_reset_reply (mq, wrk->api_client_handle,
session->vpp_handle, 0);
}
else if (state == STATE_DETACHED)
u32 wrk_index;
u64 app_event_queue_address;
u64 segment_handle;
+ u32 api_client_handle;
u8 n_fds;
u8 fd_flags;
u8 is_add;
app_ns_api_handle_t *handle;
app_sapi_msg_t msg = { 0 };
app_worker_t *app_wrk;
+ u32 sapi_handle = -1;
application_t *app;
- u32 sapi_handle;
u8 fd_flags = 0;
app = application_get_if_valid (mp->app_index);
rmp = &msg.worker_add_del_reply;
rmp->retval = rv;
rmp->is_add = mp->is_add;
+ rmp->api_client_handle = sapi_handle;
rmp->wrk_index = args.wrk_map_index;
rmp->segment_handle = args.segment_handle;
if (!rv && mp->is_add)