-static void vl_api_ipsec_gre_tunnel_details_t_handler
- (vl_api_ipsec_gre_tunnel_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp, "%11d%15U%15U%14d%14d",
- ntohl (mp->tunnel.sw_if_index),
- format_vl_api_ip4_address, mp->tunnel.src,
- format_vl_api_ip4_address, mp->tunnel.dst,
- ntohl (mp->tunnel.local_sa_id), ntohl (mp->tunnel.remote_sa_id));
-}
-
-static void
-vat_json_object_add_vl_api_ip4 (vat_json_node_t * node,
- const char *name,
- const vl_api_ip4_address_t addr)
-{
- struct in_addr ip4;
-
- clib_memcpy (&ip4, addr, sizeof (ip4));
- vat_json_object_add_ip4 (node, name, ip4);
-}
-
-static void vl_api_ipsec_gre_tunnel_details_t_handler_json
- (vl_api_ipsec_gre_tunnel_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "sw_if_index",
- ntohl (mp->tunnel.sw_if_index));
- vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.src);
- vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.dst);
- vat_json_object_add_uint (node, "local_sa_id",
- ntohl (mp->tunnel.local_sa_id));
- vat_json_object_add_uint (node, "remote_sa_id",
- ntohl (mp->tunnel.remote_sa_id));
-}
-
-static int
-api_ipsec_gre_tunnel_dump (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ipsec_gre_tunnel_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- sw_if_index = ~0;
- }
-
- if (!vam->json_output)
- {
- print (vam->ofp, "%11s%15s%15s%14s%14s",
- "sw_if_index", "src_address", "dst_address",
- "local_sa_id", "remote_sa_id");
- }
-
- /* Get list of gre-tunnel interfaces */
- M (IPSEC_GRE_TUNNEL_DUMP, mp);
-
- mp->sw_if_index = htonl (sw_if_index);
-
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-