-vl_api_accept_session_t_handler (vl_api_accept_session_t * mp)
-{
- udp_echo_main_t *utm = &udp_echo_main;
- vl_api_accept_session_reply_t *rmp;
- svm_fifo_t *rx_fifo, *tx_fifo;
- app_session_t *session;
- static f64 start_time;
- u32 session_index;
- int rv = 0;
-
- if (start_time == 0.0)
- start_time = clib_time_now (&utm->clib_time);
-
- utm->vpp_event_queue = uword_to_pointer (mp->vpp_event_queue_address,
- svm_msg_q_t *);
- rx_fifo = uword_to_pointer (mp->server_rx_fifo, svm_fifo_t *);
- tx_fifo = uword_to_pointer (mp->server_tx_fifo, svm_fifo_t *);
-
- pool_get (utm->sessions, session);
- memset (session, 0, sizeof (*session));
- session_index = session - utm->sessions;
-
- /* Cut-through case */
- if (mp->server_event_queue_address)
- {
- clib_warning ("cut-through session");
- utm->our_event_queue = uword_to_pointer (mp->server_event_queue_address,
- svm_msg_q_t *);
- rx_fifo->master_session_index = session_index;
- tx_fifo->master_session_index = session_index;
- utm->cut_through_session_index = session_index;
- session->rx_fifo = rx_fifo;
- session->tx_fifo = tx_fifo;
-
- rv = pthread_create (&utm->cut_through_thread_handle,
- NULL /*attr */ , cut_through_thread_fn, 0);
- if (rv)
- {
- clib_warning ("pthread_create returned %d", rv);
- rv = VNET_API_ERROR_SYSCALL_ERROR_1;
- }
- utm->do_echo = 1;
- }
- else
- {
- rx_fifo->client_session_index = session_index;
- tx_fifo->client_session_index = session_index;
- session->rx_fifo = rx_fifo;
- session->tx_fifo = tx_fifo;
- clib_memcpy (&session->transport.rmt_ip, mp->ip,
- sizeof (ip46_address_t));
- session->transport.is_ip4 = mp->is_ip4;
- session->transport.rmt_port = mp->port;
- }
-
- hash_set (utm->session_index_by_vpp_handles, mp->handle, session_index);
- if (pool_elts (utm->sessions) && (pool_elts (utm->sessions) % 20000) == 0)
- {
- f64 now = clib_time_now (&utm->clib_time);
- fformat (stdout, "%d active sessions in %.2f seconds, %.2f/sec...\n",
- pool_elts (utm->sessions), now - start_time,
- (f64) pool_elts (utm->sessions) / (now - start_time));
- }
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_ACCEPT_SESSION_REPLY);
- rmp->handle = mp->handle;
- rmp->context = mp->context;
- rmp->retval = rv;
- vl_msg_api_send_shmem (utm->vl_input_queue, (u8 *) & rmp);
-
- CLIB_MEMORY_BARRIER ();
- utm->state = STATE_READY;
-}
-
-static void
-vl_api_disconnect_session_t_handler (vl_api_disconnect_session_t * mp)
-{
- udp_echo_main_t *utm = &udp_echo_main;
- app_session_t *session;
- vl_api_disconnect_session_reply_t *rmp;
- uword *p;
- int rv = 0;
-
- p = hash_get (utm->session_index_by_vpp_handles, mp->handle);
-
- if (p)
- {
- session = pool_elt_at_index (utm->sessions, p[0]);
- hash_unset (utm->session_index_by_vpp_handles, mp->handle);
- pool_put (utm->sessions, session);
- }
- else
- {
- clib_warning ("couldn't find session key %llx", mp->handle);
- rv = -11;
- }
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_DISCONNECT_SESSION_REPLY);
- rmp->retval = rv;
- rmp->handle = mp->handle;
- rmp->context = mp->context;
- vl_msg_api_send_shmem (utm->vl_input_queue, (u8 *) & rmp);
-}
-
-static void
-vl_api_connect_session_reply_t_handler (vl_api_connect_session_reply_t * mp)