Skip to content
Snippets Groups Projects
Commit 2c35f1c8 authored by Matt Johnston's avatar Matt Johnston
Browse files

Add envirnonment variable for debug timestamps to roughly match

network timestamps (in tshark)
parent 13618825
Branches
Tags
No related merge requests found
...@@ -53,6 +53,10 @@ int exitflag = 0; /* GLOBAL */ ...@@ -53,6 +53,10 @@ int exitflag = 0; /* GLOBAL */
void common_session_init(int sock_in, int sock_out) { void common_session_init(int sock_in, int sock_out) {
time_t now; time_t now;
#ifdef DEBUG_TRACE
debug_start_net();
#endif
TRACE(("enter session_init")) TRACE(("enter session_init"))
ses.sock_in = sock_in; ses.sock_in = sock_in;
......
...@@ -151,19 +151,32 @@ void dropbear_log(int priority, const char* format, ...) { ...@@ -151,19 +151,32 @@ void dropbear_log(int priority, const char* format, ...) {
#ifdef DEBUG_TRACE #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 time_since_start()
{ {
static double start_time = -1;
double nowf; double nowf;
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
nowf = tv.tv_sec + (tv.tv_usec / 1000000.0); 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 0;
} }
return nowf - start_time; return nowf - debug_start_time;
} }
void dropbear_trace(const char* format, ...) { void dropbear_trace(const char* format, ...) {
......
...@@ -58,6 +58,7 @@ void dropbear_trace(const char* format, ...) ATTRIB_PRINTF(1,2); ...@@ -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 dropbear_trace2(const char* format, ...) ATTRIB_PRINTF(1,2);
void printhex(const char * label, const unsigned char * buf, int len); void printhex(const char * label, const unsigned char * buf, int len);
void printmpint(const char *label, mp_int *mp); void printmpint(const char *label, mp_int *mp);
void debug_start_net();
extern int debug_trace; extern int debug_trace;
#endif #endif
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment