-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
-
-#if DPDK > 0 && DPDK_VHOST_USER
- rv = dpdk_vhost_user_dump_ifs (vnm, vm, &ifaces);
-#else
- rv = vhost_user_dump_ifs (vnm, vm, &ifaces);
-#endif
- if (rv)
- return;
-
- vec_foreach (vuid, ifaces)
- {
- send_sw_interface_vhost_user_details (am, q, vuid, mp->context);
- }
- vec_free (ifaces);
-}
-
-static void
-send_sw_if_l2tpv3_tunnel_details (vpe_api_main_t * am,
- unix_shared_memory_queue_t * q,
- l2t_session_t * s,
- l2t_main_t * lm, u32 context)
-{
- vl_api_sw_if_l2tpv3_tunnel_details_t *mp;
- u8 *if_name = NULL;
- vnet_sw_interface_t *si = NULL;
-
- si = vnet_get_hw_sw_interface (lm->vnet_main, s->hw_if_index);
-
- if_name = format (if_name, "%U",
- format_vnet_sw_interface_name, lm->vnet_main, si);
-
- mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_SW_IF_L2TPV3_TUNNEL_DETAILS);
- strncpy ((char *) mp->interface_name,
- (char *) if_name, ARRAY_LEN (mp->interface_name) - 1);
- mp->sw_if_index = ntohl (si->sw_if_index);
- mp->local_session_id = s->local_session_id;
- mp->remote_session_id = s->remote_session_id;
- mp->local_cookie[0] = s->local_cookie[0];
- mp->local_cookie[1] = s->local_cookie[1];
- mp->remote_cookie = s->remote_cookie;
- clib_memcpy (mp->client_address, &s->client_address,
- sizeof (s->client_address));
- clib_memcpy (mp->our_address, &s->our_address, sizeof (s->our_address));
- mp->l2_sublayer_present = s->l2_sublayer_present;
- mp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & mp);
-}
-
-static void
-send_ip_address_details (vpe_api_main_t * am,
- unix_shared_memory_queue_t * q,
- u8 * ip, u16 prefix_length, u8 is_ipv6, u32 context)
-{
- vl_api_ip_address_details_t *mp;
-
- mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_ADDRESS_DETAILS);
-
- if (is_ipv6)
- {
- clib_memcpy (&mp->ip, ip, sizeof (mp->ip));
- }
- else
- {
- u32 *tp = (u32 *) mp->ip;
- *tp = ntohl (*(u32 *) ip);
- }
- mp->prefix_length = prefix_length;
- mp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & mp);
-}
-
-static void
-vl_api_ip_address_dump_t_handler (vl_api_ip_address_dump_t * mp)
-{
- vpe_api_main_t *am = &vpe_api_main;
- unix_shared_memory_queue_t *q;
- ip6_address_t *r6;
- ip4_address_t *r4;
- ip6_main_t *im6 = &ip6_main;
- ip4_main_t *im4 = &ip4_main;
- ip_lookup_main_t *lm6 = &im6->lookup_main;
- ip_lookup_main_t *lm4 = &im4->lookup_main;
- ip_interface_address_t *ia = 0;
- u32 sw_if_index = ~0;
- int rv __attribute__ ((unused)) = 0;
-
- VALIDATE_SW_IF_INDEX (mp);
-
- sw_if_index = ntohl (mp->sw_if_index);
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
-
- if (mp->is_ipv6)
- {
- /* *INDENT-OFF* */
- foreach_ip_interface_address (lm6, ia, sw_if_index,
- 1 /* honor unnumbered */,
- ({
- r6 = ip_interface_address_get_address (lm6, ia);
- u16 prefix_length = ia->address_length;
- send_ip_address_details(am, q, (u8*)r6, prefix_length, 1, mp->context);
- }));
- /* *INDENT-ON* */
- }
- else
- {
- /* *INDENT-OFF* */
- foreach_ip_interface_address (lm4, ia, sw_if_index,
- 1 /* honor unnumbered */,
- ({
- r4 = ip_interface_address_get_address (lm4, ia);
- u16 prefix_length = ia->address_length;
- send_ip_address_details(am, q, (u8*)r4, prefix_length, 0, mp->context);
- }));
- /* *INDENT-ON* */
- }
- BAD_SW_IF_INDEX_LABEL;
-}
-
-static void
-send_ip_details (vpe_api_main_t * am,
- unix_shared_memory_queue_t * q, u32 sw_if_index, u32 context)
-{
- vl_api_ip_details_t *mp;
-
- mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_IP_DETAILS);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & mp);
-}
-
-static void
-vl_api_sw_if_l2tpv3_tunnel_dump_t_handler (vl_api_sw_if_l2tpv3_tunnel_dump_t *
- mp)
-{
- vpe_api_main_t *am = &vpe_api_main;
- l2t_main_t *lm = &l2t_main;
- unix_shared_memory_queue_t *q;
- l2t_session_t *session;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
-
- /* *INDENT-OFF* */
- pool_foreach (session, lm->sessions,
- ({
- send_sw_if_l2tpv3_tunnel_details (am, q, session, lm, mp->context);
- }));
- /* *INDENT-ON* */
-}
-
-
-static void
-send_sw_interface_tap_details (vpe_api_main_t * am,
- unix_shared_memory_queue_t * q,
- tapcli_interface_details_t * tap_if,
- u32 context)
-{
- vl_api_sw_interface_tap_details_t *mp;
- mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_TAP_DETAILS);
- mp->sw_if_index = ntohl (tap_if->sw_if_index);
- strncpy ((char *) mp->dev_name,
- (char *) tap_if->dev_name, ARRAY_LEN (mp->dev_name) - 1);
- mp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & mp);
-}
-
-static void
-vl_api_sw_interface_tap_dump_t_handler (vl_api_sw_interface_tap_dump_t * mp)
-{
- int rv = 0;
- vpe_api_main_t *am = &vpe_api_main;
- unix_shared_memory_queue_t *q;
- tapcli_interface_details_t *tapifs = NULL;
- tapcli_interface_details_t *tap_if = NULL;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
-
- rv = vnet_tap_dump_ifs (&tapifs);
- if (rv)
- return;
-
- vec_foreach (tap_if, tapifs)
- {
- send_sw_interface_tap_details (am, q, tap_if, mp->context);
- }
-
- vec_free (tapifs);
-}
-
-static void
-vl_api_ip_dump_t_handler (vl_api_ip_dump_t * mp)
-{
- vpe_api_main_t *am = &vpe_api_main;
- vnet_main_t *vnm = vnet_get_main ();
- vlib_main_t *vm = vlib_get_main ();
- vnet_interface_main_t *im = &vnm->interface_main;
- unix_shared_memory_queue_t *q;
- vnet_sw_interface_t *si, *sorted_sis;
- u32 sw_if_index = ~0;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
-
- /* Gather interfaces. */
- sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
- _vec_len (sorted_sis) = 0;
- /* *INDENT-OFF* */
- pool_foreach (si, im->sw_interfaces,
- ({
- vec_add1 (sorted_sis, si[0]);
- }));
- /* *INDENT-ON* */
-
- vec_foreach (si, sorted_sis)
- {
- if (!(si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED))
- {
- if (mp->is_ipv6 && !ip6_interface_enabled (vm, si->sw_if_index))
- {
- continue;
- }
- sw_if_index = si->sw_if_index;
- send_ip_details (am, q, sw_if_index, mp->context);
- }
- }
-}
-
-static void
-vl_api_l2_fib_table_entry_t_handler (vl_api_l2_fib_table_entry_t * mp)
-{
- clib_warning ("BUG");
-}
-
-static void
-send_l2fib_table_entry (vpe_api_main_t * am,
- unix_shared_memory_queue_t * q,
- l2fib_entry_key_t * l2fe_key,
- l2fib_entry_result_t * l2fe_res, u32 context)
-{
- vl_api_l2_fib_table_entry_t *mp;
-
- mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_L2_FIB_TABLE_ENTRY);
-
- mp->bd_id =
- ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
-
- mp->mac = l2fib_make_key (l2fe_key->fields.mac, 0);
- mp->sw_if_index = ntohl (l2fe_res->fields.sw_if_index);
- mp->static_mac = l2fe_res->fields.static_mac;
- mp->filter_mac = l2fe_res->fields.filter;
- mp->bvi_mac = l2fe_res->fields.bvi;
- mp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & mp);
-}
-
-static void
-vl_api_l2_fib_table_dump_t_handler (vl_api_l2_fib_table_dump_t * mp)
-{
- vpe_api_main_t *am = &vpe_api_main;
- bd_main_t *bdm = &bd_main;
- l2fib_entry_key_t *l2fe_key = NULL;
- l2fib_entry_result_t *l2fe_res = NULL;
- u32 ni, bd_id = ntohl (mp->bd_id);
- u32 bd_index;
- unix_shared_memory_queue_t *q;
- uword *p;