aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_format.py9
-rw-r--r--src/vpp/api/api.c24
-rw-r--r--src/vpp/api/vpe.api31
-rw-r--r--src/vpp/api/vpe_types.api29
4 files changed, 56 insertions, 37 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_format.py b/src/vpp-api/python/vpp_papi/vpp_format.py
index b58dad3c1b5..7d2dcba491a 100644
--- a/src/vpp-api/python/vpp_papi/vpp_format.py
+++ b/src/vpp-api/python/vpp_papi/vpp_format.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
+import datetime
from socket import inet_pton, AF_INET6, AF_INET
import socket
import ipaddress
@@ -117,6 +117,11 @@ conversion_table = {
'MACAddress': lambda o: o.packed,
'str': lambda s: macaddress.mac_pton(s)
},
+ 'vl_api_timestamp_t':
+ {
+ 'datetime.datetime': lambda o:
+ (o - datetime.datetime(1970, 1, 1)).total_seconds()
+ }
}
@@ -142,4 +147,6 @@ conversion_unpacker_table = {
'vl_api_address_t': lambda o: unformat_api_address_t(o),
'vl_api_prefix_t': lambda o: unformat_api_prefix_t(o),
'vl_api_mac_address_t': lambda o: macaddress.MACAddress(o),
+ 'vl_api_timestamp_t': lambda o: datetime.datetime.fromtimestamp(o),
+ 'vl_api_timedelta_t': lambda o: datetime.timedelta(seconds=o),
}
diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c
index 9ae027dab9b..801cf186904 100644
--- a/src/vpp/api/api.c
+++ b/src/vpp/api/api.c
@@ -86,7 +86,7 @@ _(SHOW_THREADS, show_threads) \
_(GET_NODE_GRAPH, get_node_graph) \
_(GET_NEXT_INDEX, get_next_index) \
_(LOG_DUMP, log_dump) \
-_(SHOW_VPE_SYSTEM_TIME_TICKS, show_vpe_system_time_ticks) \
+_(SHOW_VPE_SYSTEM_TIME, show_vpe_system_time) \
_(GET_F64_ENDIAN_VALUE, get_f64_endian_value) \
_(GET_F64_INCREMENT_BY_ONE, get_f64_increment_by_one) \
@@ -480,26 +480,23 @@ vl_api_get_node_graph_t_handler (vl_api_get_node_graph_t * mp)
static void
show_log_details (vl_api_registration_t * reg, u32 context,
- f64 timestamp_ticks, u8 * timestamp,
+ f64 timestamp,
vl_api_log_level_t * level, u8 * msg_class, u8 * message)
{
u32 msg_size;
vl_api_log_details_t *rmp;
- msg_size =
- sizeof (*rmp) + vec_len (timestamp) + vec_len (msg_class) +
- vec_len (message);
+ msg_size = sizeof (*rmp) + vec_len (msg_class) + vec_len (message);
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_ticks = clib_host_to_net_f64 (timestamp_ticks);
+ rmp->timestamp = clib_host_to_net_f64 (timestamp);
rmp->level = htonl (*level);
- char *p = (char *) &rmp->timestamp;
+ char *p = (char *) &rmp->msg_class;
- p += vl_api_vec_to_api_string (timestamp, (vl_api_string_t *) p);
p += vl_api_vec_to_api_string (msg_class, (vl_api_string_t *) p);
p += vl_api_vec_to_api_string (message, (vl_api_string_t *) p);
@@ -532,8 +529,6 @@ vl_api_log_dump_t_handler (vl_api_log_dump_t * mp)
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,
- format (0, "%U", format_time_float, 0,
- e->timestamp + time_offset),
(vl_api_log_level_t *) & e->level,
format (0, "%U", format_vlib_log_class, e->class),
e->string);
@@ -543,15 +538,14 @@ vl_api_log_dump_t_handler (vl_api_log_dump_t * mp)
}
static void
- vl_api_show_vpe_system_time_ticks_t_handler
- (vl_api_show_vpe_system_time_ticks_t * mp)
+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_ticks_reply_t *rmp;
+ vl_api_show_vpe_system_time_reply_t *rmp;
/* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_SHOW_VPE_SYSTEM_TIME_TICKS_REPLY,
+ REPLY_MACRO2(VL_API_SHOW_VPE_SYSTEM_TIME_REPLY,
({
- rmp->vpe_system_time_ticks = clib_host_to_net_f64 (unix_time_now ());
+ rmp->vpe_system_time = clib_host_to_net_f64 (unix_time_now ());
}));
/* *INDENT-ON* */
}
diff --git a/src/vpp/api/vpe.api b/src/vpp/api/vpe.api
index 7c466b9a7a4..9531ea5643d 100644
--- a/src/vpp/api/vpe.api
+++ b/src/vpp/api/vpe.api
@@ -19,7 +19,9 @@
called through a shared memory interface.
*/
-option version = "1.4.0";
+option version = "1.5.0";
+
+import "vpp/api/vpe_types.api";
/*
* Note: API placement cleanup in progress
@@ -283,29 +285,16 @@ define get_next_index_reply
u32 next_index;
};
-enum log_level {
- VPE_API_LOG_LEVEL_EMERG = 0, /* emerg */
- VPE_API_LOG_LEVEL_ALERT = 1, /* alert */
- VPE_API_LOG_LEVEL_CRIT = 2, /* crit */
- VPE_API_LOG_LEVEL_ERR = 3, /* err */
- VPE_API_LOG_LEVEL_WARNING = 4, /* warn */
- VPE_API_LOG_LEVEL_NOTICE = 5, /* notice */
- VPE_API_LOG_LEVEL_INFO = 6, /* info */
- VPE_API_LOG_LEVEL_DEBUG = 7, /* debug */
- VPE_API_LOG_LEVEL_DISABLED = 8, /* disabled */
-};
-
define log_dump {
u32 client_index;
u32 context;
- f64 start_timestamp;
+ vl_api_timestamp_t start_timestamp;
};
define log_details {
u32 context;
- f64 timestamp_ticks;
+ vl_api_timestamp_t timestamp;
vl_api_log_level_t level;
- string timestamp [limit=24];
string msg_class [limit=32];
string message [limit=256];
};
@@ -314,22 +303,22 @@ define log_details {
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
*/
-define show_vpe_system_time_ticks
+define show_vpe_system_time
{
u32 client_index;
u32 context;
};
-/** \brief Reply for show vpe system time ticks.
+/** \brief Reply for show vpe system time.
@param context - sender context which was passed in the request
@param retval - return value
- @param vpe_system_time_ticks - the time in ticks of the host system.
+ @param vpe_system_time - the time in seconds since epoch of the host system.
*/
-define show_vpe_system_time_ticks_reply
+define show_vpe_system_time_reply
{
u32 context;
i32 retval;
- f64 vpe_system_time_ticks;
+ vl_api_timestamp_t vpe_system_time;
};
/** \brief f64 types are not standardized across the wire. Sense wire format in each direction by sending the f64 value 1.0.
diff --git a/src/vpp/api/vpe_types.api b/src/vpp/api/vpe_types.api
index f1d6e5456cd..7bd4b29e846 100644
--- a/src/vpp/api/vpe_types.api
+++ b/src/vpp/api/vpe_types.api
@@ -1,3 +1,18 @@
+/*
+ * Copyright (c) 2015-2016 Cisco and/or its affiliates.
+ * Copyright (c) 2019 Vinci Consulting Corp. All Rights Reserved.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
typeonly define version
{
@@ -11,3 +26,17 @@ typeonly define version
u8 build_metadata[17]; /* 16 + "\0" */
};
+ typedef f64 timestamp;
+ typedef f64 timedelta;
+
+ enum log_level {
+ VPE_API_LOG_LEVEL_EMERG = 0, /* emerg */
+ VPE_API_LOG_LEVEL_ALERT = 1, /* alert */
+ VPE_API_LOG_LEVEL_CRIT = 2, /* crit */
+ VPE_API_LOG_LEVEL_ERR = 3, /* err */
+ VPE_API_LOG_LEVEL_WARNING = 4, /* warn */
+ VPE_API_LOG_LEVEL_NOTICE = 5, /* notice */
+ VPE_API_LOG_LEVEL_INFO = 6, /* info */
+ VPE_API_LOG_LEVEL_DEBUG = 7, /* debug */
+ VPE_API_LOG_LEVEL_DISABLED = 8, /* disabled */
+};