- /* No need to keep the socket API connection open */
- close (sm->socket_client_main->socket_fd);
-}
-
-#define foreach_api_reply_msg \
-_(MAP_STATS_SEGMENT_REPLY, map_stats_segment_reply)
-
-static void
-vpp_api_hookup (void)
-{
-#define _(N,n) \
- vl_msg_api_set_handlers(VL_API_##N, #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_api_reply_msg;
-#undef _
-}
-
-static int
-connect_to_vpp (stat_client_main_t * sm)
-{
- int rv;
- vl_api_map_stats_segment_t *mp;
- api_main_t *am = &api_main;
-
- sm->socket_client_main = &socket_client_main;
-
- rv = vl_socket_client_connect ((char *) sm->socket_name,
- "stat_client",
- 0 /* default socket rx, tx buffer */ );
- if (rv)
- {
- fformat (stderr, "Error connecting to vpp...\n");
- exit (1);
- }
-
- /* Hook up reply handler */
- vpp_api_hookup ();
-
- /* Map the stats segment */
- mp = vl_socket_client_msg_alloc (sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_MAP_STATS_SEGMENT);
- mp->client_index = am->my_client_index;
- mp->context = 0xdeaddabe;
-
- /* Send the message */
- vl_socket_client_write ();
-
- /* Wait for a reply, process it.. */
- vl_socket_client_read (5 /* timeout in seconds */ );
-