diff --git a/src/lib3270/telnet.c b/src/lib3270/telnet.c index a6c0f81..a471e29 100644 --- a/src/lib3270/telnet.c +++ b/src/lib3270/telnet.c @@ -2711,31 +2711,6 @@ opt(unsigned char c) void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, int len) { - // IS DS trace ON? - if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_DS_TRACE)) - { - int offset; - struct timeval ts; - double tdiff; - - (void) gettimeofday(&ts, (struct timezone *)NULL); - if (IN_3270) - { - tdiff = ((1.0e6 * (double)(ts.tv_sec - hSession->ds_ts.tv_sec)) + - (double)(ts.tv_usec - hSession->ds_ts.tv_usec)) / 1.0e6; - trace_dsn(hSession,"%c +%gs\n", direction, tdiff); - } - - hSession->ds_ts = ts; - for (offset = 0; offset < len; offset++) - { - if (!(offset % LINEDUMP_MAX)) - trace_dsn(hSession,"%s%c 0x%-3x ",(offset ? "\n" : ""), direction, offset); - trace_dsn(hSession,"%02x", buf[offset]); - } - trace_dsn(hSession,"\n"); - } - if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_NETWORK_TRACE)) { char l1[82]; @@ -2745,6 +2720,12 @@ void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, in int offset; int col = 0; + time_t ltime; + + time(<ime); + strftime(l1, 81, "%x %X", localtime(<ime)); + lib3270_write_nettrace(hSession,"%c %s %s data len=%d\n\n",direction,l1,direction == '>' ? "outbound" : "inbound", len); + for (offset = 0; offset < len; offset++) { unsigned char text[4]; @@ -2759,7 +2740,7 @@ void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, in if(++col >= 80) { l1[col] = l2[col] = l3[col] = 0; - lib3270_write_nettrace(hSession,"%c\t%s\n\t%s\n\t%s\n",direction,l1,l2,l3); + lib3270_write_nettrace(hSession,"\t%s\n\t%s\n\t%s\n\n",l1,l2,l3); col = 0; } } @@ -2767,9 +2748,32 @@ void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, in if(col) { l1[col] = l2[col] = l3[col] = 0; - lib3270_write_nettrace(hSession,"%c\t%s\n\t%s\n\t%s\n",direction,l1,l2,l3); + lib3270_write_nettrace(hSession,"\t%s\n\t%s\n\t%s\n\n",l1,l2,l3); + } + + } + else if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_DS_TRACE)) + { + int offset; + struct timeval ts; + double tdiff; + + (void) gettimeofday(&ts, (struct timezone *)NULL); + if (IN_3270) + { + tdiff = ((1.0e6 * (double)(ts.tv_sec - hSession->ds_ts.tv_sec)) + + (double)(ts.tv_usec - hSession->ds_ts.tv_usec)) / 1.0e6; + trace_dsn(hSession,"%c +%gs\n", direction, tdiff); } + hSession->ds_ts = ts; + for (offset = 0; offset < len; offset++) + { + if (!(offset % LINEDUMP_MAX)) + trace_dsn(hSession,"%s%c 0x%-3x ",(offset ? "\n" : ""), direction, offset); + trace_dsn(hSession,"%02x", buf[offset]); + } + trace_dsn(hSession,"\n"); } } -- libgit2 0.21.2