-static void vl_api_mpls_gre_tunnel_details_t_handler
- (vl_api_mpls_gre_tunnel_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 i;
- i32 len = ntohl (mp->nlabels);
-
- if (mp->l2_only == 0)
- {
- fformat (vam->ofp, "[%d]: src %U, dst %U, adj %U/%d, labels ",
- ntohl (mp->tunnel_index),
- format_ip4_address, &mp->tunnel_src,
- format_ip4_address, &mp->tunnel_dst,
- format_ip4_address, &mp->intfc_address,
- ntohl (mp->mask_width));
- for (i = 0; i < len; i++)
- {
- fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
- }
- fformat (vam->ofp, "\n");
- fformat (vam->ofp, " inner fib index %d, outer fib index %d\n",
- ntohl (mp->inner_fib_index), ntohl (mp->outer_fib_index));
- }
- else
- {
- fformat (vam->ofp, "[%d]: src %U, dst %U, key %U, labels ",
- ntohl (mp->tunnel_index),
- format_ip4_address, &mp->tunnel_src,
- format_ip4_address, &mp->tunnel_dst,
- format_ip4_address, &mp->intfc_address);
- for (i = 0; i < len; i++)
- {
- fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
- }
- fformat (vam->ofp, "\n");
- fformat (vam->ofp, " l2 interface %d, outer fib index %d\n",
- ntohl (mp->hw_if_index), ntohl (mp->outer_fib_index));
- }
-}
-
-static void vl_api_mpls_gre_tunnel_details_t_handler_json
- (vl_api_mpls_gre_tunnel_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
- struct in_addr ip4;
- i32 i;
- i32 len = ntohl (mp->nlabels);
-
- 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, "tunnel_index", ntohl (mp->tunnel_index));
- clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
- vat_json_object_add_ip4 (node, "intfc_address", ip4);
- vat_json_object_add_uint (node, "inner_fib_index",
- ntohl (mp->inner_fib_index));
- vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
- vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
- vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
- vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
- clib_memcpy (&ip4, &(mp->tunnel_src), sizeof (ip4));
- vat_json_object_add_ip4 (node, "tunnel_src", ip4);
- clib_memcpy (&ip4, &(mp->tunnel_dst), sizeof (ip4));
- vat_json_object_add_ip4 (node, "tunnel_dst", ip4);
- vat_json_object_add_uint (node, "outer_fib_index",
- ntohl (mp->outer_fib_index));
- vat_json_object_add_uint (node, "label_count", len);
- for (i = 0; i < len; i++)
- {
- vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
- }
-}
-
-static int
-api_mpls_gre_tunnel_dump (vat_main_t * vam)
-{
- vl_api_mpls_gre_tunnel_dump_t *mp;
- f64 timeout;
- i32 index = -1;
-
- /* Parse args required to build the message */
- while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
- {
- if (!unformat (vam->input, "tunnel_index %d", &index))
- {
- index = -1;
- break;
- }
- }
-
- fformat (vam->ofp, " tunnel_index %d\n", index);
-
- M (MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump);
- mp->tunnel_index = htonl (index);
- S;
-
- /* Use a control ping for synchronization */
- {
- vl_api_control_ping_t *mp;
- M (CONTROL_PING, control_ping);
- S;
- }
- W;
-}
-