comparison 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
comparison
equal deleted inserted replaced
1020:363c0feca5d4 1021:24135c8e1d46
149 } 149 }
150 150
151 151
152 #ifdef DEBUG_TRACE 152 #ifdef DEBUG_TRACE
153 153
154 static double debug_start_time = -1;
155
156 void debug_start_net()
157 {
158 if (getenv("DROPBEAR_DEBUG_NET_TIMESTAMP"))
159 {
160 /* Timestamps start from first network activity */
161 struct timeval tv;
162 gettimeofday(&tv, NULL);
163 debug_start_time = tv.tv_sec + (tv.tv_usec / 1000000.0);
164 TRACE(("Resetting Dropbear TRACE timestamps"))
165 }
166 }
167
154 static double time_since_start() 168 static double time_since_start()
155 { 169 {
156 static double start_time = -1;
157 double nowf; 170 double nowf;
158 struct timeval tv; 171 struct timeval tv;
159 gettimeofday(&tv, NULL); 172 gettimeofday(&tv, NULL);
160 nowf = tv.tv_sec + (tv.tv_usec / 1000000.0); 173 nowf = tv.tv_sec + (tv.tv_usec / 1000000.0);
161 if (start_time < 0) 174 if (debug_start_time < 0)
162 { 175 {
163 start_time = nowf; 176 debug_start_time = nowf;
164 return 0; 177 return 0;
165 } 178 }
166 return nowf - start_time; 179 return nowf - debug_start_time;
167 } 180 }
168 181
169 void dropbear_trace(const char* format, ...) { 182 void dropbear_trace(const char* format, ...) {
170 va_list param; 183 va_list param;
171 184