summaryrefslogtreecommitdiff
path: root/dbutil.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2015-02-13 23:47:53 +0800
committerMatt Johnston <matt@ucc.asn.au>2015-02-13 23:47:53 +0800
commitec6ccd02c663e7b31f3d3ae17c0c6bcd23c66fac (patch)
tree09efa7d2e423e21e8e55c1fac3c4453e254f08f8 /dbutil.c
parent1374903f3e511b86a62e25b0682e780cf400f6af (diff)
downloaddropbear-ec6ccd02c663e7b31f3d3ae17c0c6bcd23c66fac.tar.gz
Add envirnonment variable for debug timestamps to roughly match
network timestamps (in tshark)
Diffstat (limited to 'dbutil.c')
-rw-r--r--dbutil.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/dbutil.c b/dbutil.c
index 2d40903..923327b 100644
--- a/dbutil.c
+++ b/dbutil.c
@@ -151,19 +151,32 @@ void dropbear_log(int priority, const char* format, ...) {
#ifdef DEBUG_TRACE
+static double debug_start_time = -1;
+
+void debug_start_net()
+{
+ if (getenv("DROPBEAR_DEBUG_NET_TIMESTAMP"))
+ {
+ /* Timestamps start from first network activity */
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ debug_start_time = tv.tv_sec + (tv.tv_usec / 1000000.0);
+ TRACE(("Resetting Dropbear TRACE timestamps"))
+ }
+}
+
static double time_since_start()
{
- static double start_time = -1;
double nowf;
struct timeval tv;
gettimeofday(&tv, NULL);
nowf = tv.tv_sec + (tv.tv_usec / 1000000.0);
- if (start_time < 0)
+ if (debug_start_time < 0)
{
- start_time = nowf;
+ debug_start_time = nowf;
return 0;
}
- return nowf - start_time;
+ return nowf - debug_start_time;
}
void dropbear_trace(const char* format, ...) {