Commit b6be0002a03b6623388780f5942c51178040188f
1 parent
c0b0e40b
Exists in
master
and in
5 other branches
Iniciando implementação de trace da comunicação de rede
Showing
7 changed files
with
90 additions
and
49 deletions
Show diff stats
src/include/lib3270.h
@@ -117,6 +117,8 @@ | @@ -117,6 +117,8 @@ | ||
117 | LIB3270_TOGGLE_VIEW_FIELD, /**< View Field attribute */ | 117 | LIB3270_TOGGLE_VIEW_FIELD, /**< View Field attribute */ |
118 | LIB3270_TOGGLE_ALTSCREEN, /**< auto resize on altscreen */ | 118 | LIB3270_TOGGLE_ALTSCREEN, /**< auto resize on altscreen */ |
119 | LIB3270_TOGGLE_KEEP_ALIVE, /**< Enable network keep-alive with SO_KEEPALIVE */ | 119 | LIB3270_TOGGLE_KEEP_ALIVE, /**< Enable network keep-alive with SO_KEEPALIVE */ |
120 | + LIB3270_TOGGLE_NETWORK_TRACE, /**< Enable network in/out trace */ | ||
121 | + | ||
120 | 122 | ||
121 | // LIB3270_TOGGLE_ALT_CURSOR, | 123 | // LIB3270_TOGGLE_ALT_CURSOR, |
122 | // LIB3270_TOGGLE_AID_WAIT, | 124 | // LIB3270_TOGGLE_AID_WAIT, |
src/include/lib3270/trace.h
@@ -64,6 +64,17 @@ | @@ -64,6 +64,17 @@ | ||
64 | /** | 64 | /** |
65 | * Write on trace file. | 65 | * Write on trace file. |
66 | * | 66 | * |
67 | + * Write text on trace file, if network trace is enabled. | ||
68 | + * | ||
69 | + * @param fmt String format. | ||
70 | + * @param ... Arguments. | ||
71 | + * | ||
72 | + */ | ||
73 | + LIB3270_EXPORT void lib3270_write_nettrace(H3270 *session, const char *fmt, ...); | ||
74 | + | ||
75 | + /** | ||
76 | + * Write on trace file. | ||
77 | + * | ||
67 | * Write text on trace file, if event is enabled. | 78 | * Write text on trace file, if event is enabled. |
68 | * | 79 | * |
69 | * @param fmt String format. | 80 | * @param fmt String format. |
src/lib3270/telnet.c
@@ -102,6 +102,7 @@ | @@ -102,6 +102,7 @@ | ||
102 | #include "screen.h" | 102 | #include "screen.h" |
103 | 103 | ||
104 | #include <lib3270/internals.h> | 104 | #include <lib3270/internals.h> |
105 | +#include <lib3270/trace.h> | ||
105 | 106 | ||
106 | #if !defined(TELOPT_NAWS) /*[*/ | 107 | #if !defined(TELOPT_NAWS) /*[*/ |
107 | #define TELOPT_NAWS 31 | 108 | #define TELOPT_NAWS 31 |
@@ -1202,33 +1203,6 @@ void net_input(H3270 *hSession) | @@ -1202,33 +1203,6 @@ void net_input(H3270 *hSession) | ||
1202 | 1203 | ||
1203 | lib3270_data_recv(hSession, nr, buffer); | 1204 | lib3270_data_recv(hSession, nr, buffer); |
1204 | 1205 | ||
1205 | -/* | ||
1206 | - trace_netdata('<', session->netrbuf, nr); | ||
1207 | - | ||
1208 | - session->ns_brcvd += nr; | ||
1209 | - for (cp = session->netrbuf; cp < (session->netrbuf + nr); cp++) | ||
1210 | - { | ||
1211 | - if (telnet_fsm(session,*cp)) | ||
1212 | - { | ||
1213 | - (void) ctlr_dbcs_postprocess(hSession); | ||
1214 | - host_disconnect(session,True); | ||
1215 | - return; | ||
1216 | - } | ||
1217 | - } | ||
1218 | - | ||
1219 | -#if defined(X3270_ANSI) | ||
1220 | - if (IN_ANSI) | ||
1221 | - { | ||
1222 | - (void) ctlr_dbcs_postprocess(hSession); | ||
1223 | - } | ||
1224 | - | ||
1225 | - if (session->ansi_data) | ||
1226 | - { | ||
1227 | - trace_dsn(session,"\n"); | ||
1228 | - session->ansi_data = 0; | ||
1229 | - } | ||
1230 | -#endif // X3270_ANSI | ||
1231 | -*/ | ||
1232 | } | 1206 | } |
1233 | 1207 | ||
1234 | } | 1208 | } |
@@ -2736,29 +2710,68 @@ opt(unsigned char c) | @@ -2736,29 +2710,68 @@ opt(unsigned char c) | ||
2736 | 2710 | ||
2737 | void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, int len) | 2711 | void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, int len) |
2738 | { | 2712 | { |
2739 | - int offset; | ||
2740 | - struct timeval ts; | ||
2741 | - double tdiff; | ||
2742 | - | ||
2743 | - if (!lib3270_get_toggle(hSession,LIB3270_TOGGLE_DS_TRACE)) | ||
2744 | - return; | ||
2745 | 2713 | ||
2746 | - (void) gettimeofday(&ts, (struct timezone *)NULL); | ||
2747 | - if (IN_3270) | 2714 | + // IS DS trace ON? |
2715 | + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_DS_TRACE)) | ||
2748 | { | 2716 | { |
2749 | - tdiff = ((1.0e6 * (double)(ts.tv_sec - hSession->ds_ts.tv_sec)) + | ||
2750 | - (double)(ts.tv_usec - hSession->ds_ts.tv_usec)) / 1.0e6; | ||
2751 | - trace_dsn(hSession,"%c +%gs\n", direction, tdiff); | 2717 | + int offset; |
2718 | + struct timeval ts; | ||
2719 | + double tdiff; | ||
2720 | + | ||
2721 | + (void) gettimeofday(&ts, (struct timezone *)NULL); | ||
2722 | + if (IN_3270) | ||
2723 | + { | ||
2724 | + tdiff = ((1.0e6 * (double)(ts.tv_sec - hSession->ds_ts.tv_sec)) + | ||
2725 | + (double)(ts.tv_usec - hSession->ds_ts.tv_usec)) / 1.0e6; | ||
2726 | + trace_dsn(hSession,"%c +%gs\n", direction, tdiff); | ||
2727 | + } | ||
2728 | + | ||
2729 | + hSession->ds_ts = ts; | ||
2730 | + for (offset = 0; offset < len; offset++) | ||
2731 | + { | ||
2732 | + if (!(offset % LINEDUMP_MAX)) | ||
2733 | + trace_dsn(hSession,"%s%c 0x%-3x ",(offset ? "\n" : ""), direction, offset); | ||
2734 | + trace_dsn(hSession,"%02x", buf[offset]); | ||
2735 | + } | ||
2736 | + trace_dsn(hSession,"\n"); | ||
2752 | } | 2737 | } |
2753 | 2738 | ||
2754 | - hSession->ds_ts = ts; | ||
2755 | - for (offset = 0; offset < len; offset++) | 2739 | + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_NETWORK_TRACE)) |
2756 | { | 2740 | { |
2757 | - if (!(offset % LINEDUMP_MAX)) | ||
2758 | - trace_dsn(hSession,"%s%c 0x%-3x ",(offset ? "\n" : ""), direction, offset); | ||
2759 | - trace_dsn(hSession,"%02x", buf[offset]); | 2741 | + char l1[82]; |
2742 | + char l2[82]; | ||
2743 | + char l3[82]; | ||
2744 | + | ||
2745 | + int offset; | ||
2746 | + int col = 0; | ||
2747 | + | ||
2748 | + for (offset = 0; offset < len; offset++) | ||
2749 | + { | ||
2750 | + unsigned char text[4]; | ||
2751 | + | ||
2752 | + text[0] = hSession->charset.ebc2asc[buf[offset]]; | ||
2753 | + l1[col] = (text[0] >= ' ' ? text[0] : '.'); | ||
2754 | + | ||
2755 | + snprintf((char *) text,4,"%02x",buf[offset]); | ||
2756 | + l2[col] = text[0]; | ||
2757 | + l3[col] = text[1]; | ||
2758 | + | ||
2759 | + if(++col >= 80) | ||
2760 | + { | ||
2761 | + l1[col] = l2[col] = l3[col] = 0; | ||
2762 | + lib3270_write_nettrace(hSession,"%c\t%s\n\t%s\n\t%s\n",direction,l1,l2,l3); | ||
2763 | + col = 0; | ||
2764 | + } | ||
2765 | + } | ||
2766 | + | ||
2767 | + if(col) | ||
2768 | + { | ||
2769 | + l1[col] = l2[col] = l3[col] = 0; | ||
2770 | + lib3270_write_nettrace(hSession,"%c\t%s\n\t%s\n\t%s\n",direction,l1,l2,l3); | ||
2771 | + } | ||
2772 | + | ||
2760 | } | 2773 | } |
2761 | - trace_dsn(hSession,"\n"); | 2774 | + |
2762 | } | 2775 | } |
2763 | #endif // X3270_TRACE | 2776 | #endif // X3270_TRACE |
2764 | 2777 |
src/lib3270/toggles.c
@@ -82,7 +82,7 @@ static const char *toggle_names[LIB3270_TOGGLE_COUNT] = | @@ -82,7 +82,7 @@ static const char *toggle_names[LIB3270_TOGGLE_COUNT] = | ||
82 | "fieldattr", /**< View Field attribute */ | 82 | "fieldattr", /**< View Field attribute */ |
83 | "altscreen", /**< auto resize on altscreen */ | 83 | "altscreen", /**< auto resize on altscreen */ |
84 | "keepalive", /**< Enable network keep-alive with SO_KEEPALIVE */ | 84 | "keepalive", /**< Enable network keep-alive with SO_KEEPALIVE */ |
85 | - | 85 | + "nettrace", /**< Enable network in/out trace */ |
86 | 86 | ||
87 | }; | 87 | }; |
88 | 88 |
src/lib3270/trace_ds.c
@@ -214,6 +214,19 @@ LIB3270_EXPORT void lib3270_write_dstrace(H3270 *session, const char *fmt, ...) | @@ -214,6 +214,19 @@ LIB3270_EXPORT void lib3270_write_dstrace(H3270 *session, const char *fmt, ...) | ||
214 | va_end(args); | 214 | va_end(args); |
215 | } | 215 | } |
216 | 216 | ||
217 | +LIB3270_EXPORT void lib3270_write_nettrace(H3270 *session, const char *fmt, ...) | ||
218 | +{ | ||
219 | + va_list args; | ||
220 | + | ||
221 | + if(!lib3270_get_toggle(session,LIB3270_TOGGLE_NETWORK_TRACE)) | ||
222 | + return; | ||
223 | + | ||
224 | + va_start(args, fmt); | ||
225 | + vwtrace(session,fmt, args); | ||
226 | + va_end(args); | ||
227 | +} | ||
228 | + | ||
229 | + | ||
217 | LIB3270_EXPORT void lib3270_trace_event(H3270 *session, const char *fmt, ...) | 230 | LIB3270_EXPORT void lib3270_trace_event(H3270 *session, const char *fmt, ...) |
218 | { | 231 | { |
219 | va_list args; | 232 | va_list args; |
src/pw3270/main.c
@@ -266,6 +266,7 @@ static void trace_window_destroy(GtkWidget *widget, H3270 *hSession) | @@ -266,6 +266,7 @@ static void trace_window_destroy(GtkWidget *widget, H3270 *hSession) | ||
266 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_DS_TRACE,0); | 266 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_DS_TRACE,0); |
267 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_SCREEN_TRACE,0); | 267 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_SCREEN_TRACE,0); |
268 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_EVENT_TRACE,0); | 268 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_EVENT_TRACE,0); |
269 | + lib3270_set_toggle(hSession,LIB3270_TOGGLE_NETWORK_TRACE,0); | ||
269 | trace_window = NULL; | 270 | trace_window = NULL; |
270 | } | 271 | } |
271 | 272 |
ui/99debug.xml
@@ -37,10 +37,11 @@ | @@ -37,10 +37,11 @@ | ||
37 | 37 | ||
38 | <menu name='View' > | 38 | <menu name='View' > |
39 | <menu name='TraceOptions' label='Trace' > | 39 | <menu name='TraceOptions' label='Trace' > |
40 | - <menuitem action='toggle' id='dstrace' label='DS Trace' /> | ||
41 | - <menuitem action='toggle' id='screentrace' label='Screen Trace' /> | ||
42 | - <menuitem action='toggle' id='eventtrace' label='Event Trace' /> | ||
43 | - <menuitem action='toggle' id='fieldattr' label='View Field Delimiters' /> | 40 | + <menuitem action='toggle' id='dstrace' label='DS Trace' /> |
41 | + <menuitem action='toggle' id='screentrace' label='Screen Trace' /> | ||
42 | + <menuitem action='toggle' id='nettrace' label='Network Trace' /> | ||
43 | + <menuitem action='toggle' id='eventtrace' label='Event Trace' /> | ||
44 | + <menuitem action='toggle' id='fieldattr' label='View Field Delimiters' /> | ||
44 | </menu> | 45 | </menu> |
45 | </menu> | 46 | </menu> |
46 | 47 |