+static void
+show_log_details (vl_api_registration_t * reg, u32 context,
+ f64 timestamp,
+ vl_api_log_level_t * level, u8 * msg_class, u8 * message)
+{
+ u32 msg_size;
+
+ vl_api_log_details_t *rmp;
+ int class_len =
+ clib_min (vec_len (msg_class) + 1, ARRAY_LEN (rmp->msg_class));
+ int message_len =
+ clib_min (vec_len (message) + 1, ARRAY_LEN (rmp->message));
+ msg_size = sizeof (*rmp) + class_len + message_len;
+
+ rmp = vl_msg_api_alloc (msg_size);
+ clib_memset (rmp, 0, msg_size);
+ rmp->_vl_msg_id = ntohs (VL_API_LOG_DETAILS);
+
+ rmp->context = context;
+ rmp->timestamp = clib_host_to_net_f64 (timestamp);
+ rmp->level = htonl (*level);
+
+ memcpy (rmp->msg_class, msg_class, class_len - 1);
+ memcpy (rmp->message, message, message_len - 1);
+ /* enforced by memset() above */
+ ASSERT (0 == rmp->msg_class[class_len - 1]);
+ ASSERT (0 == rmp->message[message_len - 1]);
+
+ vl_api_send_msg (reg, (u8 *) rmp);
+}
+
+static void
+vl_api_log_dump_t_handler (vl_api_log_dump_t * mp)
+{
+
+ /* from log.c */
+ vlib_log_main_t *lm = &log_main;
+ vlib_log_entry_t *e;
+ int i = last_log_entry ();
+ int count = lm->count;
+ f64 time_offset, start_time;
+ vl_api_registration_t *reg;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (reg == 0)
+ return;
+
+ start_time = clib_net_to_host_f64 (mp->start_timestamp);
+
+ time_offset = (f64) lm->time_zero_timeval.tv_sec
+ + (((f64) lm->time_zero_timeval.tv_usec) * 1e-6) - lm->time_zero;
+
+ while (count--)
+ {
+ e = vec_elt_at_index (lm->entries, i);
+ if (start_time <= e->timestamp + time_offset)
+ show_log_details (reg, mp->context, e->timestamp + time_offset,
+ (vl_api_log_level_t *) & e->level,
+ format (0, "%U", format_vlib_log_class, e->class),
+ e->string);
+ i = (i + 1) % lm->size;
+ }
+
+}
+
+static void
+vl_api_show_vpe_system_time_t_handler (vl_api_show_vpe_system_time_t * mp)
+{
+ int rv = 0;
+ vl_api_show_vpe_system_time_reply_t *rmp;
+ /* *INDENT-OFF* */
+ REPLY_MACRO2(VL_API_SHOW_VPE_SYSTEM_TIME_REPLY,
+ ({
+ rmp->vpe_system_time = clib_host_to_net_f64 (unix_time_now ());
+ }));
+ /* *INDENT-ON* */
+}
+
+static void
+vl_api_get_f64_endian_value_t_handler (vl_api_get_f64_endian_value_t * mp)
+{
+ int rv = 0;
+ f64 one = 1.0;
+ vl_api_get_f64_endian_value_reply_t *rmp;
+ if (1.0 != clib_net_to_host_f64 (mp->f64_one))
+ rv = VNET_API_ERROR_API_ENDIAN_FAILED;
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO2(VL_API_GET_F64_ENDIAN_VALUE_REPLY,
+ ({
+ rmp->f64_one_result = clib_host_to_net_f64 (one);
+ }));
+ /* *INDENT-ON* */
+}
+
+static void
+vl_api_get_f64_increment_by_one_t_handler (vl_api_get_f64_increment_by_one_t *
+ mp)
+{
+ int rv = 0;
+ vl_api_get_f64_increment_by_one_reply_t *rmp;
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO2(VL_API_GET_F64_INCREMENT_BY_ONE_REPLY,
+ ({
+ rmp->f64_value = clib_host_to_net_f64 (clib_net_to_host_f64(mp->f64_value) + 1.0);
+ }));
+ /* *INDENT-ON* */
+}
+