2 * tracedump.c - tracedump vpp-api-test plug-in
4 * Copyright (c) <current-year> <your-organization>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <vlibapi/api.h>
19 #include <vlibmemory/api.h>
20 #include <vppinfra/error.h>
21 #include <vnet/api_errno.h>
24 #define __plugin_msg_base tracedump_test_main.msg_id_base
25 #include <vlibapi/vat_helper_macros.h>
27 /* Declare message IDs */
28 #include <tracedump/tracedump.api_enum.h>
29 #include <tracedump/tracedump.api_types.h>
33 /* API message ID base */
36 } tracedump_test_main_t;
38 tracedump_test_main_t tracedump_test_main;
41 vl_api_trace_details_t_handler (vl_api_trace_details_t * dmp)
43 u32 thread_id, position;
45 thread_id = clib_net_to_host_u32 (dmp->thread_id);
46 position = clib_net_to_host_u32 (dmp->position);
49 "thread %d position %d more_this_thread %d more_threads %d done %d\n",
50 thread_id, position, (u32) dmp->more_this_thread,
51 (u32) dmp->more_threads, (u32) dmp->done);
52 fformat (stdout, " %U\n", vl_api_format_string, (&dmp->trace_data));
57 vl_api_trace_dump_reply_t_handler (vl_api_trace_dump_reply_t * rmp)
59 tracedump_test_main_t *ttm = &tracedump_test_main;
60 vat_main_t *vam = ttm->vat_main;
61 vl_api_trace_dump_t *mp;
62 i32 retval = (i32) clib_net_to_host_u32 (rmp->retval);
63 u32 thread_id, position;
65 if (retval != 0 || rmp->done)
67 vam->result_ready = 1;
71 if (retval == 0 && rmp->flush_only == 0)
75 mp->thread_id = 0xFFFFFFFF;
76 mp->position = 0xFFFFFFFF;
82 /* Figure out where the next batch starts */
83 thread_id = clib_host_to_net_u32 (rmp->last_thread_id);
84 position = clib_host_to_net_u32 (rmp->last_position);
86 if (rmp->more_threads)
96 mp->thread_id = clib_host_to_net_u32 (thread_id);
97 mp->position = clib_host_to_net_u32 (position);
98 mp->max_records = clib_host_to_net_u32 (10);
103 api_trace_dump (vat_main_t * vam)
105 vl_api_trace_dump_t *mp;
112 mp->max_records = clib_host_to_net_u32 (10);
120 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
122 #include <tracedump/tracedump.api.h>
125 #include <tracedump/tracedump.api.h>
129 manual_setup_message_id_table (vat_main_t * vam)
131 vl_msg_api_set_handlers (VL_API_TRACE_DETAILS
132 + tracedump_test_main.msg_id_base, "trace_details",
133 vl_api_trace_details_t_handler, vl_noop_handler,
134 vl_api_trace_details_t_endian,
135 vl_api_trace_details_t_print,
136 sizeof (vl_api_trace_details_t), 1);
139 #define VL_API_LOCAL_SETUP_MESSAGE_ID_TABLE manual_setup_message_id_table
140 #define VL_API_TRACE_DUMP_REPLY_T_HANDLER
142 #include <tracedump/tracedump.api_test.c>
145 * fd.io coding-style-patch-verification: ON
148 * eval: (c-set-style "gnu")