X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvpp-api%2Fclient%2Fclient.c;h=668461aad6c447b55159fd64242a65c5f405e398;hb=59b2565cd91a67ced650739f36129650830211ac;hp=8bdcda01c4d15d34a2b31be9a0fbb7567f897cf5;hpb=35ffa3e8f6b032f6e324234d495f769049d8feea;p=vpp.git diff --git a/src/vpp-api/client/client.c b/src/vpp-api/client/client.c index 8bdcda01c4d..668461aad6c 100644 --- a/src/vpp-api/client/client.c +++ b/src/vpp-api/client/client.c @@ -133,8 +133,11 @@ static void * vac_rx_thread_fn (void *arg) { unix_shared_memory_queue_t *q; + vl_api_memclnt_keepalive_t *mp; + vl_api_memclnt_keepalive_reply_t *rmp; vac_main_t *pm = &vac_main; api_main_t *am = &api_main; + vl_shmem_hdr_t *shmem_hdr; uword msg; q = am->vl_input_queue; @@ -169,6 +172,17 @@ vac_rx_thread_fn (void *arg) vl_msg_api_free((void *) msg); break; + case VL_API_MEMCLNT_KEEPALIVE: + mp = (void *)msg; + rmp = vl_msg_api_alloc (sizeof (*rmp)); + memset (rmp, 0, sizeof (*rmp)); + rmp->_vl_msg_id = ntohs(VL_API_MEMCLNT_KEEPALIVE_REPLY); + rmp->context = mp->context; + shmem_hdr = am->shmem_hdr; + vl_msg_api_send_shmem(shmem_hdr->vl_input_queue, (u8 *)&rmp); + vl_msg_api_free((void *) msg); + break; + default: vac_api_handler((void *)msg); } @@ -370,8 +384,12 @@ vac_read (char **p, int *l, u16 timeout) unix_shared_memory_queue_t *q; api_main_t *am = &api_main; vac_main_t *pm = &vac_main; + vl_api_memclnt_keepalive_t *mp; + vl_api_memclnt_keepalive_reply_t *rmp; uword msg; msgbuf_t *msgbuf; + int rv; + vl_shmem_hdr_t *shmem_hdr; if (!pm->connected_to_vlib) return -1; @@ -384,7 +402,9 @@ vac_read (char **p, int *l, u16 timeout) set_timeout(timeout); q = am->vl_input_queue; - int rv = unix_shared_memory_queue_sub(q, (u8 *)&msg, 0); + + again: + rv = unix_shared_memory_queue_sub(q, (u8 *)&msg, 0); if (rv == 0) { u16 msg_id = ntohs(*((u16 *)msg)); switch (msg_id) { @@ -397,6 +417,21 @@ vac_read (char **p, int *l, u16 timeout) case VL_API_MEMCLNT_READ_TIMEOUT: printf("Received read timeout %ds\n", timeout); goto error; + case VL_API_MEMCLNT_KEEPALIVE: + /* Handle an alive-check ping from vpp. */ + mp = (void *)msg; + rmp = vl_msg_api_alloc (sizeof (*rmp)); + memset (rmp, 0, sizeof (*rmp)); + rmp->_vl_msg_id = ntohs(VL_API_MEMCLNT_KEEPALIVE_REPLY); + rmp->context = mp->context; + shmem_hdr = am->shmem_hdr; + vl_msg_api_send_shmem(shmem_hdr->vl_input_queue, (u8 *)&rmp); + vl_msg_api_free((void *) msg); + /* + * Python code is blissfully unaware of these pings, so + * act as if it never happened... + */ + goto again; default: msgbuf = (msgbuf_t *)(((u8 *)msg) - offsetof(msgbuf_t, data));