summaryrefslogtreecommitdiffhomepage
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
commit2c35f1c8fd7ded63a1e0a14fce01032697dac352 (patch)
tree16f82cb62f9dffe42b596a46b1ee1b14dc8ef20f
parent136188259e415b51b0ad1b84a08bed950aa4707b (diff)
Add envirnonment variable for debug timestamps to roughly match
network timestamps (in tshark)
-rw-r--r--common-session.c4
-rw-r--r--dbutil.c21
-rw-r--r--dbutil.h1
3 files changed, 22 insertions, 4 deletions
diff --git a/common-session.c b/common-session.c
index bbcd9ca..26ef147 100644
--- a/common-session.c
+++ b/common-session.c
@@ -53,6 +53,10 @@ int exitflag = 0; /* GLOBAL */
void common_session_init(int sock_in, int sock_out) {
time_t now;
+#ifdef DEBUG_TRACE
+ debug_start_net();
+#endif
+
TRACE(("enter session_init"))
ses.sock_in = sock_in;
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, ...) {
diff --git a/dbutil.h b/dbutil.h
index cdad9bc..a13c15f 100644
--- a/dbutil.h
+++ b/dbutil.h
@@ -58,6 +58,7 @@ void dropbear_trace(const char* format, ...) ATTRIB_PRINTF(1,2);
void dropbear_trace2(const char* format, ...) ATTRIB_PRINTF(1,2);
void printhex(const char * label, const unsigned char * buf, int len);
void printmpint(const char *label, mp_int *mp);
+void debug_start_net();
extern int debug_trace;
#endif