+ u32 program_len = strnlen_s ("vpe", 32);
+ u32 version_len = strnlen_s (vpe_api_get_version (), 32);
+ u32 build_date_len = strnlen_s (vpe_api_get_build_date (), 32);
+ u32 build_directory_len = strnlen_s (vpe_api_get_build_directory (), 256);
+
+ u32 n = program_len + version_len + build_date_len + build_directory_len;
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO3(VL_API_SHOW_VERSION_REPLY, n,
+ ({
+ char *p = (char *)&rmp->program;
+ p += vl_api_to_api_string(program_len, "vpe", (vl_api_string_t *)p);
+ p += vl_api_to_api_string(version_len, vpe_api_get_version(), (vl_api_string_t *)p);
+ p += vl_api_to_api_string(build_date_len, vpe_api_get_build_date(), (vl_api_string_t *)p);
+ vl_api_to_api_string(build_directory_len, vpe_api_get_build_directory(), (vl_api_string_t *)p);
+ }));
+ /* *INDENT-ON* */
+}
+
+static void
+get_thread_data (vl_api_thread_data_t * td, int index)
+{
+ vlib_worker_thread_t *w = vlib_worker_threads + index;
+ td->id = htonl (index);
+ if (w->name)
+ strncpy ((char *) td->name, (char *) w->name, ARRAY_LEN (td->name) - 1);
+ if (w->registration)
+ strncpy ((char *) td->type, (char *) w->registration->name,
+ ARRAY_LEN (td->type) - 1);
+ td->pid = htonl (w->lwp);
+ td->cpu_id = htonl (w->cpu_id);
+ td->core = htonl (w->core_id);
+ td->cpu_socket = htonl (w->socket_id);
+}
+
+static void
+vl_api_show_threads_t_handler (vl_api_show_threads_t * mp)
+{
+ int count = 0;
+
+#if !defined(__powerpc64__)
+ vl_api_registration_t *reg;
+ vl_api_show_threads_reply_t *rmp;
+ vl_api_thread_data_t *td;
+ int i, msg_size = 0;
+ count = vec_len (vlib_worker_threads);
+ if (!count)
+ return;
+
+ msg_size = sizeof (*rmp) + sizeof (rmp->thread_data[0]) * count;
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ rmp = vl_msg_api_alloc (msg_size);
+ clib_memset (rmp, 0, msg_size);
+ rmp->_vl_msg_id = htons (VL_API_SHOW_THREADS_REPLY);
+ rmp->context = mp->context;
+ rmp->count = htonl (count);
+ td = rmp->thread_data;
+
+ for (i = 0; i < count; i++)
+ {
+ get_thread_data (&td[i], i);
+ }
+
+ vl_api_send_msg (reg, (u8 *) rmp);
+#else
+
+ /* unimplemented support */
+ rv = -9;
+ clib_warning ("power pc does not support show threads api");