diff dbutil.c @ 1021:24135c8e1d46

Add envirnonment variable for debug timestamps to roughly match network timestamps (in tshark)
author Matt Johnston <matt@ucc.asn.au>
date Fri, 13 Feb 2015 23:47:53 +0800
parents cb148f8d3d22
children 4121ca987e6a
line wrap: on
line diff
--- a/dbutil.c	Fri Feb 13 23:17:23 2015 +0800
+++ b/dbutil.c	Fri Feb 13 23:47:53 2015 +0800
@@ -151,19 +151,32 @@
 
 #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, ...) {