18 #include <sys/types.h> 19 #include <sys/socket.h> 22 #include <netinet/in.h> 79 memset(pm, 0,
sizeof(*pm));
100 memset (pm, 0,
sizeof (*pm));
120 u16 id = ntohs(*((
u16 *)msg));
124 clib_warning(
"Message ID %d has wrong length: %d\n",
id, l);
145 u16 id = ntohs(*((
u16 *)msg));
147 case VL_API_RX_THREAD_EXIT:
157 case VL_API_MEMCLNT_RX_THREAD_SUSPEND:
167 case VL_API_MEMCLNT_READ_TIMEOUT:
168 clib_warning(
"Received read timeout in async thread\n");
195 gettimeofday(&tv,
NULL);
196 ts.tv_sec = tv.tv_sec + timeout;
204 ep->_vl_msg_id = ntohs(VL_API_MEMCLNT_READ_TIMEOUT);
223 ep->_vl_msg_id = ntohs(VL_API_MEMCLNT_RX_THREAD_SUSPEND);
227 rx_is_running =
false;
238 if (rx_is_running)
goto unlock;
240 rx_is_running =
true;
267 if (chroot_prefix !=
NULL)
289 rx_is_running =
true;
318 ep->_vl_msg_id = ntohs(VL_API_RX_THREAD_EXIT);
324 gettimeofday(&tv,
NULL);
325 ts.tv_sec = tv.tv_sec + 5;
353 read_timeout = timeout;
380 if (am->
our_pid == 0)
return (-1);
389 u16 msg_id = ntohs(*((
u16 *)msg));
391 case VL_API_RX_THREAD_EXIT:
392 printf(
"Received thread exit\n");
394 case VL_API_MEMCLNT_RX_THREAD_SUSPEND:
395 printf(
"Received thread suspend\n");
397 case VL_API_MEMCLNT_READ_TIMEOUT:
398 printf(
"Received read timeout %ds\n", timeout);
405 printf(
"Unregistered API message: %d\n", msg_id);
415 printf(
"Read failed with %d\n", rv);
435 pneum_client_index (
void)
450 if (!mp)
return (-1);
453 mp->client_index = pneum_client_index();
478 if (hp->
value[0] > max)
pthread_t rx_thread_handle
pthread_cond_t timeout_cancel_cv
pthread_cond_t suspend_cv
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
unix_shared_memory_queue_t * vl_input_queue
void pneum_rx_suspend(void)
int pneum_get_msg_index(unsigned char *name)
void clib_error_register_handler(clib_error_handler_func_t func, void *arg)
vlib_main_t ** vlib_mains
static void cleanup(void)
unix_shared_memory_queue_t * vl_input_queue
static void * pneum_rx_thread_fn(void *arg)
void vl_msg_api_free(void *)
int pneum_connect(char *name, char *chroot_prefix, pneum_callback_t cb, int rx_qlen)
pthread_mutex_t queue_lock
struct vl_shmem_hdr_ * shmem_hdr
void pneum_rx_resume(void)
vlib_main_t vlib_global_main
int unix_shared_memory_queue_add(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
int vl_client_api_map(char *region_name)
void vl_set_memory_root_path(char *root_path)
void(* pneum_callback_t)(unsigned char *data, int len)
int pneum_read(char **p, int *l, u16 timeout)
static void * pneum_timeout_thread_fn(void *arg)
int pneum_disconnect(void)
pthread_t timeout_thread_handle
int unix_shared_memory_queue_sub(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
void * vl_msg_api_alloc(int nbytes)
static uword * pneum_msg_table_get_hash(void)
void(* pneum_error_callback_t)(void *, unsigned char *, int)
static void pneum_api_handler(void *msg)
#define clib_warning(format, args...)
void vlib_cli_output(struct vlib_main_t *vm, char *fmt,...)
u32 vl_api_get_msg_index(u8 *name_and_crc)
int vl_client_connect(char *name, int ctx_quota, int input_queue_size)
static uword hash_elts(void *v)
void pneum_set_error_handler(pneum_error_callback_t cb)
void pneum_free(void *msg)
static void set_timeout(unsigned short timeout)
void vl_client_disconnect(void)
void vl_client_api_unmap(void)
typedef VL_API_PACKED(struct _vl_api_header{u16 _vl_msg_id;u32 client_index;})
pneum_callback_t pneum_callback
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
int pneum_msg_table_max_index(void)
pthread_cond_t terminate_cv
pthread_mutex_t timeout_lock
int pneum_msg_table_size(void)
uword * msg_index_by_name_and_crc
pthread_cond_t timeout_cv
int pneum_write(char *p, int l)
static void unset_timeout(void)
struct _unix_shared_memory_queue unix_shared_memory_queue_t