Commit 7eb746485d47d43bd640a13ae41568b585f950e1
1 parent
2e3024e1
Exists in
master
and in
5 other branches
trace_netdata passa a receber um handle de sessão
Showing
5 changed files
with
88 additions
and
66 deletions
Show diff stats
src/lib3270/html.c
@@ -208,7 +208,7 @@ | @@ -208,7 +208,7 @@ | ||
208 | if(info->mode == HTML_MODE_TEXT) | 208 | if(info->mode == HTML_MODE_TEXT) |
209 | return; | 209 | return; |
210 | 210 | ||
211 | - trace("maxlength=%d",info->maxlength); | 211 | +// trace("maxlength=%d",info->maxlength); |
212 | 212 | ||
213 | if(info->maxlength < 1) | 213 | if(info->maxlength < 1) |
214 | { | 214 | { |
src/lib3270/iocalls.c
@@ -570,13 +570,21 @@ void RemoveTimeOut(void * timer) | @@ -570,13 +570,21 @@ void RemoveTimeOut(void * timer) | ||
570 | return remove_timeout(timer); | 570 | return remove_timeout(timer); |
571 | } | 571 | } |
572 | 572 | ||
573 | +#ifdef WIN32 | ||
573 | void * AddInput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | 574 | void * AddInput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) |
575 | +#else | ||
576 | +void * AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) | ||
577 | +#endif // WIN32 | ||
574 | { | 578 | { |
575 | CHECK_SESSION_HANDLE(session); | 579 | CHECK_SESSION_HANDLE(session); |
576 | return add_input(source,session,fn); | 580 | return add_input(source,session,fn); |
577 | } | 581 | } |
578 | 582 | ||
583 | +#ifdef WIN32 | ||
579 | void * AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | 584 | void * AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) |
585 | +#else | ||
586 | +void * AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) | ||
587 | +#endif // WIN32 | ||
580 | { | 588 | { |
581 | CHECK_SESSION_HANDLE(session); | 589 | CHECK_SESSION_HANDLE(session); |
582 | return add_except(source,session,fn); | 590 | return add_except(source,session,fn); |
src/lib3270/proxy.c
@@ -341,8 +341,7 @@ proxy_negotiate(int type, int fd, char *host, unsigned short port) | @@ -341,8 +341,7 @@ proxy_negotiate(int type, int fd, char *host, unsigned short port) | ||
341 | } | 341 | } |
342 | 342 | ||
343 | /* Sun PASSTHRU proxy. */ | 343 | /* Sun PASSTHRU proxy. */ |
344 | -static int | ||
345 | -proxy_passthru(int fd, char *host, unsigned short port) | 344 | +static int proxy_passthru(int fd, char *host, unsigned short port) |
346 | { | 345 | { |
347 | char *buf; | 346 | char *buf; |
348 | 347 | ||
@@ -351,11 +350,12 @@ proxy_passthru(int fd, char *host, unsigned short port) | @@ -351,11 +350,12 @@ proxy_passthru(int fd, char *host, unsigned short port) | ||
351 | 350 | ||
352 | #if defined(X3270_TRACE) /*[*/ | 351 | #if defined(X3270_TRACE) /*[*/ |
353 | trace_dsn("Passthru Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf); | 352 | trace_dsn("Passthru Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf); |
354 | - trace_netdata('>', (unsigned char *)buf, (int) strlen(buf)); | 353 | + trace_netdata(&h3270,'>', (unsigned char *)buf, (int) strlen(buf)); |
355 | #endif /*]*/ | 354 | #endif /*]*/ |
356 | 355 | ||
357 | - if (send(fd, buf, strlen(buf), 0) < 0) { | ||
358 | - popup_a_sockerr(NULL,"Passthru Proxy: send error"); | 356 | + if (send(fd, buf, strlen(buf), 0) < 0) |
357 | + { | ||
358 | + popup_a_sockerr(NULL,"Passthru Proxy: send error"); | ||
359 | lib3270_free(buf); | 359 | lib3270_free(buf); |
360 | return -1; | 360 | return -1; |
361 | } | 361 | } |
@@ -386,7 +386,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -386,7 +386,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
386 | 386 | ||
387 | #if defined(X3270_TRACE) /*[*/ | 387 | #if defined(X3270_TRACE) /*[*/ |
388 | trace_dsn("HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf); | 388 | trace_dsn("HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf); |
389 | - trace_netdata('>', (unsigned char *)buf, (int) strlen(buf)); | 389 | + trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf)); |
390 | #endif /*]*/ | 390 | #endif /*]*/ |
391 | 391 | ||
392 | if (send(fd, buf, strlen(buf), 0) < 0) { | 392 | if (send(fd, buf, strlen(buf), 0) < 0) { |
@@ -403,7 +403,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -403,7 +403,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
403 | 403 | ||
404 | #if defined(X3270_TRACE) /*[*/ | 404 | #if defined(X3270_TRACE) /*[*/ |
405 | trace_dsn("HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf); | 405 | trace_dsn("HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf); |
406 | - trace_netdata('>', (unsigned char *)buf, (int) strlen(buf)); | 406 | + trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf)); |
407 | #endif /*]*/ | 407 | #endif /*]*/ |
408 | 408 | ||
409 | if (send(fd, buf, strlen(buf), 0) < 0) { | 409 | if (send(fd, buf, strlen(buf), 0) < 0) { |
@@ -415,7 +415,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -415,7 +415,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
415 | strcpy(buf, "\r\n"); | 415 | strcpy(buf, "\r\n"); |
416 | #if defined(X3270_TRACE) /*[*/ | 416 | #if defined(X3270_TRACE) /*[*/ |
417 | trace_dsn("HTTP Proxy: xmit ''\n"); | 417 | trace_dsn("HTTP Proxy: xmit ''\n"); |
418 | - trace_netdata('>', (unsigned char *)buf, strlen(buf)); | 418 | + trace_netdata(&h3270, '>', (unsigned char *)buf, strlen(buf)); |
419 | #endif /*]*/ | 419 | #endif /*]*/ |
420 | 420 | ||
421 | if (send(fd, buf, strlen(buf), 0) < 0) { | 421 | if (send(fd, buf, strlen(buf), 0) < 0) { |
@@ -441,7 +441,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -441,7 +441,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
441 | popup_an_error(NULL,"HTTP Proxy: server timeout"); | 441 | popup_an_error(NULL,"HTTP Proxy: server timeout"); |
442 | #if defined(X3270_TRACE) /*[*/ | 442 | #if defined(X3270_TRACE) /*[*/ |
443 | if (nread) | 443 | if (nread) |
444 | - trace_netdata('<', (unsigned char *)rbuf, nread); | 444 | + trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread); |
445 | #endif /*]*/ | 445 | #endif /*]*/ |
446 | return -1; | 446 | return -1; |
447 | } | 447 | } |
@@ -451,14 +451,14 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -451,14 +451,14 @@ proxy_http(int fd, char *host, unsigned short port) | ||
451 | popup_a_sockerr(NULL,"HTTP Proxy: receive error"); | 451 | popup_a_sockerr(NULL,"HTTP Proxy: receive error"); |
452 | #if defined(X3270_TRACE) /*[*/ | 452 | #if defined(X3270_TRACE) /*[*/ |
453 | if (nread) | 453 | if (nread) |
454 | - trace_netdata('<', (unsigned char *)rbuf, nread); | 454 | + trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread); |
455 | #endif /*]*/ | 455 | #endif /*]*/ |
456 | return -1; | 456 | return -1; |
457 | } | 457 | } |
458 | if (nr == 0) { | 458 | if (nr == 0) { |
459 | #if defined(X3270_TRACE) /*[*/ | 459 | #if defined(X3270_TRACE) /*[*/ |
460 | if (nread) | 460 | if (nread) |
461 | - trace_netdata('<', (unsigned char *)rbuf, nread); | 461 | + trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread); |
462 | #endif /*]*/ | 462 | #endif /*]*/ |
463 | popup_an_error(NULL,"HTTP Proxy: unexpected EOF"); | 463 | popup_an_error(NULL,"HTTP Proxy: unexpected EOF"); |
464 | return -1; | 464 | return -1; |
@@ -475,7 +475,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -475,7 +475,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
475 | rbuf[nread] = '\0'; | 475 | rbuf[nread] = '\0'; |
476 | 476 | ||
477 | #if defined(X3270_TRACE) /*[*/ | 477 | #if defined(X3270_TRACE) /*[*/ |
478 | - trace_netdata('<', (unsigned char *)rbuf, nread); | 478 | + trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread); |
479 | trace_dsn("HTTP Proxy: recv '%s'\n", rbuf); | 479 | trace_dsn("HTTP Proxy: recv '%s'\n", rbuf); |
480 | #endif /*]*/ | 480 | #endif /*]*/ |
481 | 481 | ||
@@ -502,7 +502,7 @@ proxy_telnet(int fd, char *host, unsigned short port) | @@ -502,7 +502,7 @@ proxy_telnet(int fd, char *host, unsigned short port) | ||
502 | 502 | ||
503 | #if defined(X3270_TRACE) /*[*/ | 503 | #if defined(X3270_TRACE) /*[*/ |
504 | trace_dsn("TELNET Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf); | 504 | trace_dsn("TELNET Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf); |
505 | - trace_netdata('>', (unsigned char *)buf, (int) strlen(buf)); | 505 | + trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf)); |
506 | #endif /*]*/ | 506 | #endif /*]*/ |
507 | 507 | ||
508 | if (send(fd, buf, strlen(buf), 0) < 0) { | 508 | if (send(fd, buf, strlen(buf), 0) < 0) { |
@@ -735,7 +735,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -735,7 +735,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
735 | strcpy((char *)rbuf, "\005\001\000"); | 735 | strcpy((char *)rbuf, "\005\001\000"); |
736 | #if defined(X3270_TRACE) /*[*/ | 736 | #if defined(X3270_TRACE) /*[*/ |
737 | trace_dsn("SOCKS5 Proxy: xmit version 5 nmethods 1 (no auth)\n"); | 737 | trace_dsn("SOCKS5 Proxy: xmit version 5 nmethods 1 (no auth)\n"); |
738 | - trace_netdata('>', rbuf, 3); | 738 | + trace_netdata(&h3270, '>', rbuf, 3); |
739 | #endif /*]*/ | 739 | #endif /*]*/ |
740 | if (send(fd, (const char *) rbuf, 3, 0) < 0) { | 740 | if (send(fd, (const char *) rbuf, 3, 0) < 0) { |
741 | popup_a_sockerr(NULL,"SOCKS5 Proxy: send error"); | 741 | popup_a_sockerr(NULL,"SOCKS5 Proxy: send error"); |
@@ -755,29 +755,32 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -755,29 +755,32 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
755 | FD_SET(fd, &rfds); | 755 | FD_SET(fd, &rfds); |
756 | tv.tv_sec = 15; | 756 | tv.tv_sec = 15; |
757 | tv.tv_usec = 0; | 757 | tv.tv_usec = 0; |
758 | - if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { | ||
759 | - popup_an_error(NULL,"SOCKS5 Proxy: server timeout"); | 758 | + if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) |
759 | + { | ||
760 | + popup_an_error(&h3270,"SOCKS5 Proxy: server timeout"); | ||
760 | #if defined(X3270_TRACE) /*[*/ | 761 | #if defined(X3270_TRACE) /*[*/ |
761 | - if (nread) | ||
762 | - trace_netdata('<', rbuf, nread); | 762 | + if (nread) |
763 | + trace_netdata(&h3270, '<', rbuf, nread); | ||
763 | #endif /*]*/ | 764 | #endif /*]*/ |
764 | return -1; | 765 | return -1; |
765 | } | 766 | } |
766 | 767 | ||
767 | nr = recv(fd, (char *) &rbuf[nread], 1, 0); | 768 | nr = recv(fd, (char *) &rbuf[nread], 1, 0); |
768 | - if (nr < 0) { | ||
769 | - popup_a_sockerr(NULL,"SOCKS5 Proxy: receive error"); | 769 | + if (nr < 0) |
770 | + { | ||
771 | + popup_a_sockerr(&h3270,"SOCKS5 Proxy: receive error"); | ||
770 | #if defined(X3270_TRACE) /*[*/ | 772 | #if defined(X3270_TRACE) /*[*/ |
771 | - if (nread) | ||
772 | - trace_netdata('<', rbuf, nread); | 773 | + if (nread) |
774 | + trace_netdata(&h3270, '<', rbuf, nread); | ||
773 | #endif /*]*/ | 775 | #endif /*]*/ |
774 | return -1; | 776 | return -1; |
775 | } | 777 | } |
776 | - if (nr == 0) { | 778 | + if (nr == 0) |
779 | + { | ||
777 | popup_a_sockerr(NULL,"SOCKS5 Proxy: unexpected EOF"); | 780 | popup_a_sockerr(NULL,"SOCKS5 Proxy: unexpected EOF"); |
778 | #if defined(X3270_TRACE) /*[*/ | 781 | #if defined(X3270_TRACE) /*[*/ |
779 | - if (nread) | ||
780 | - trace_netdata('<', rbuf, nread); | 782 | + if (nread) |
783 | + trace_netdata(&h3270, '<', rbuf, nread); | ||
781 | #endif /*]*/ | 784 | #endif /*]*/ |
782 | return -1; | 785 | return -1; |
783 | } | 786 | } |
@@ -786,17 +789,17 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -786,17 +789,17 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
786 | } | 789 | } |
787 | 790 | ||
788 | #if defined(X3270_TRACE) /*[*/ | 791 | #if defined(X3270_TRACE) /*[*/ |
789 | - trace_netdata('<', rbuf, nread); | 792 | + trace_netdata(&h3270, '<', rbuf, nread); |
790 | #endif /*]*/ | 793 | #endif /*]*/ |
791 | 794 | ||
792 | - if (rbuf[0] != 0x05 || (rbuf[1] != 0 && rbuf[1] != 0xff)) { | ||
793 | - popup_an_error(NULL,"SOCKS5 Proxy: bad authentication response"); | 795 | + if (rbuf[0] != 0x05 || (rbuf[1] != 0 && rbuf[1] != 0xff)) |
796 | + { | ||
797 | + popup_an_error(NULL,"SOCKS5 Proxy: bad authentication response"); | ||
794 | return -1; | 798 | return -1; |
795 | } | 799 | } |
796 | 800 | ||
797 | #if defined(X3270_TRACE) /*[*/ | 801 | #if defined(X3270_TRACE) /*[*/ |
798 | - trace_dsn("SOCKS5 Proxy: recv version %d method %d\n", rbuf[0], | ||
799 | - rbuf[1]); | 802 | + trace_dsn("SOCKS5 Proxy: recv version %d method %d\n", rbuf[0],rbuf[1]); |
800 | #endif /*]*/ | 803 | #endif /*]*/ |
801 | 804 | ||
802 | if (rbuf[1] == 0xff) { | 805 | if (rbuf[1] == 0xff) { |
@@ -836,7 +839,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -836,7 +839,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
836 | ((ha.sa.sa_family == AF_INET)? "IPv4": "IPv6"), | 839 | ((ha.sa.sa_family == AF_INET)? "IPv4": "IPv6"), |
837 | use_name? host: nbuf, | 840 | use_name? host: nbuf, |
838 | port); | 841 | port); |
839 | - trace_netdata('>', (unsigned char *)buf, s - buf); | 842 | + trace_netdata(&h3270, '>', (unsigned char *)buf, s - buf); |
840 | #endif /*]*/ | 843 | #endif /*]*/ |
841 | 844 | ||
842 | if (send(fd, buf, s - buf, 0) < 0) { | 845 | if (send(fd, buf, s - buf, 0) < 0) { |
@@ -869,19 +872,21 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -869,19 +872,21 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
869 | } | 872 | } |
870 | 873 | ||
871 | nr = recv(fd, (char *) &r, 1, 0); | 874 | nr = recv(fd, (char *) &r, 1, 0); |
872 | - if (nr < 0) { | 875 | + if (nr < 0) |
876 | + { | ||
873 | popup_a_sockerr(NULL,"SOCKS5 Proxy: receive error"); | 877 | popup_a_sockerr(NULL,"SOCKS5 Proxy: receive error"); |
874 | #if defined(X3270_TRACE) /*[*/ | 878 | #if defined(X3270_TRACE) /*[*/ |
875 | - if (nread) | ||
876 | - trace_netdata('<', (unsigned char *)buf, nread); | 879 | + if (nread) |
880 | + trace_netdata(&h3270, '<', (unsigned char *)buf, nread); | ||
877 | #endif /*]*/ | 881 | #endif /*]*/ |
878 | return -1; | 882 | return -1; |
879 | } | 883 | } |
880 | - if (nr == 0) { | ||
881 | - popup_an_error(NULL,"SOCKS5 Proxy: unexpected EOF"); | 884 | + if (nr == 0) |
885 | + { | ||
886 | + popup_an_error(&h3270, "SOCKS5 Proxy: unexpected EOF"); | ||
882 | #if defined(X3270_TRACE) /*[*/ | 887 | #if defined(X3270_TRACE) /*[*/ |
883 | - if (nread) | ||
884 | - trace_netdata('<', (unsigned char *)buf, nread); | 888 | + if (nread) |
889 | + trace_netdata(&h3270, '<', (unsigned char *)buf, nread); | ||
885 | #endif /*]*/ | 890 | #endif /*]*/ |
886 | return -1; | 891 | return -1; |
887 | } | 892 | } |
@@ -891,12 +896,12 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -891,12 +896,12 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
891 | 896 | ||
892 | switch (nread++) { | 897 | switch (nread++) { |
893 | case 0: | 898 | case 0: |
894 | - if (r != 0x05) { | ||
895 | - popup_an_error(NULL,"SOCKS5 Proxy: incorrect " | ||
896 | - "reply version 0x%02x", r); | 899 | + if (r != 0x05) |
900 | + { | ||
901 | + popup_an_error(&h3270, "SOCKS5 Proxy: incorrect reply version 0x%02x", r); | ||
897 | #if defined(X3270_TRACE) /*[*/ | 902 | #if defined(X3270_TRACE) /*[*/ |
898 | if (nread) | 903 | if (nread) |
899 | - trace_netdata('<', (unsigned char *)buf, nread); | 904 | + trace_netdata(&h3270, '<', (unsigned char *)buf, nread); |
900 | #endif /*]*/ | 905 | #endif /*]*/ |
901 | return -1; | 906 | return -1; |
902 | } | 907 | } |
@@ -904,17 +909,16 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -904,17 +909,16 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
904 | case 1: | 909 | case 1: |
905 | #if defined(X3270_TRACE) /*[*/ | 910 | #if defined(X3270_TRACE) /*[*/ |
906 | if (r != 0x00) | 911 | if (r != 0x00) |
907 | - trace_netdata('<', (unsigned char *)buf, nread); | 912 | + trace_netdata(&h3270, '<', (unsigned char *)buf, nread); |
908 | #endif /*]*/ | 913 | #endif /*]*/ |
909 | switch (r) { | 914 | switch (r) { |
910 | case 0x00: | 915 | case 0x00: |
911 | break; | 916 | break; |
912 | case 0x01: | 917 | case 0x01: |
913 | - popup_an_error(NULL,"SOCKS5 Proxy: server failure"); | 918 | + popup_an_error(&h3270, "SOCKS5 Proxy: server failure"); |
914 | return -1; | 919 | return -1; |
915 | case 0x02: | 920 | case 0x02: |
916 | - popup_an_error(NULL,"SOCKS5 Proxy: connection not " | ||
917 | - "allowed"); | 921 | + popup_an_error(&h3270, "SOCKS5 Proxy: connection not allowed"); |
918 | return -1; | 922 | return -1; |
919 | case 0x03: | 923 | case 0x03: |
920 | popup_an_error(NULL,"SOCKS5 Proxy: network " | 924 | popup_an_error(NULL,"SOCKS5 Proxy: network " |
@@ -961,11 +965,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -961,11 +965,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
961 | break; | 965 | break; |
962 | #endif /*]*/ | 966 | #endif /*]*/ |
963 | default: | 967 | default: |
964 | - popup_an_error(NULL,"SOCKS5 Proxy: unknown server " | ||
965 | - "address type 0x%02x", r); | 968 | + popup_an_error(&h3270, "SOCKS5 Proxy: unknown server address type 0x%02x", r); |
966 | #if defined(X3270_TRACE) /*[*/ | 969 | #if defined(X3270_TRACE) /*[*/ |
967 | if (nread) | 970 | if (nread) |
968 | - trace_netdata('<', (unsigned char *)buf, nread); | 971 | + trace_netdata(&h3270, '<', (unsigned char *)buf, nread); |
969 | #endif /*]*/ | 972 | #endif /*]*/ |
970 | return -1; | 973 | return -1; |
971 | } | 974 | } |
@@ -980,7 +983,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -980,7 +983,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
980 | } | 983 | } |
981 | 984 | ||
982 | #if defined(X3270_TRACE) /*[*/ | 985 | #if defined(X3270_TRACE) /*[*/ |
983 | - trace_netdata('<', (unsigned char *)buf, nread); | 986 | + trace_netdata(&h3270, '<', (unsigned char *)buf, nread); |
984 | switch (buf[3]) { | 987 | switch (buf[3]) { |
985 | case 0x01: /* IPv4 */ | 988 | case 0x01: /* IPv4 */ |
986 | memcpy(&ha.sin.sin_addr, &buf[4], 4); | 989 | memcpy(&ha.sin.sin_addr, &buf[4], 4); |
src/lib3270/telnet.c
@@ -210,7 +210,7 @@ static char vlnext; | @@ -210,7 +210,7 @@ static char vlnext; | ||
210 | // static unsigned short proxy_port = 0; | 210 | // static unsigned short proxy_port = 0; |
211 | 211 | ||
212 | static int telnet_fsm(H3270 *session, unsigned char c); | 212 | static int telnet_fsm(H3270 *session, unsigned char c); |
213 | -static void net_rawout(H3270 *session, unsigned const char *buf, int len); | 213 | +static void net_rawout(H3270 *session, unsigned const char *buf, size_t len); |
214 | static void check_in3270(H3270 *session); | 214 | static void check_in3270(H3270 *session); |
215 | static void store3270in(H3270 *hSession, unsigned char c); | 215 | static void store3270in(H3270 *hSession, unsigned char c); |
216 | static void check_linemode(H3270 *hSession, Boolean init); | 216 | static void check_linemode(H3270 *hSession, Boolean init); |
@@ -992,7 +992,9 @@ LIB3270_EXPORT void lib3270_data_recv(H3270 *hSession, size_t nr, const unsigned | @@ -992,7 +992,9 @@ LIB3270_EXPORT void lib3270_data_recv(H3270 *hSession, size_t nr, const unsigned | ||
992 | { | 992 | { |
993 | register const unsigned char * cp; | 993 | register const unsigned char * cp; |
994 | 994 | ||
995 | - trace_netdata('<', netrbuf, nr); | 995 | + trace("%s: nr=%d",__FUNCTION__,nr); |
996 | + | ||
997 | + trace_netdata(hSession, '<', netrbuf, nr); | ||
996 | 998 | ||
997 | hSession->ns_brcvd += nr; | 999 | hSession->ns_brcvd += nr; |
998 | for (cp = netrbuf; cp < (netrbuf + nr); cp++) | 1000 | for (cp = netrbuf; cp < (netrbuf + nr); cp++) |
@@ -2096,15 +2098,20 @@ LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf | @@ -2096,15 +2098,20 @@ LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf | ||
2096 | return -1; | 2098 | return -1; |
2097 | } | 2099 | } |
2098 | 2100 | ||
2099 | -/* | ||
2100 | - * net_rawout | ||
2101 | - * Send out raw telnet data. We assume that there will always be enough | ||
2102 | - * space to buffer what we want to transmit, so we don't handle EAGAIN or | ||
2103 | - * EWOULDBLOCK. | 2101 | +/** |
2102 | + * Send out raw telnet data. | ||
2103 | + * | ||
2104 | + * We assume that there will always be enough space to buffer what we want to transmit, | ||
2105 | + * so we don't handle EAGAIN or EWOULDBLOCK. | ||
2106 | + * | ||
2107 | + * @param hSession Session handle. | ||
2108 | + * @param buf Buffer to send. | ||
2109 | + * @param len Buffer length | ||
2110 | + * | ||
2104 | */ | 2111 | */ |
2105 | -static void net_rawout(H3270 *hSession, unsigned const char *buf, int len) | 2112 | +static void net_rawout(H3270 *hSession, unsigned const char *buf, size_t len) |
2106 | { | 2113 | { |
2107 | - trace_netdata('>', buf, len); | 2114 | + trace_netdata(hSession, '>', buf, len); |
2108 | 2115 | ||
2109 | while (len) | 2116 | while (len) |
2110 | { | 2117 | { |
@@ -2669,22 +2676,26 @@ opt(unsigned char c) | @@ -2669,22 +2676,26 @@ opt(unsigned char c) | ||
2669 | 2676 | ||
2670 | #define LINEDUMP_MAX 32 | 2677 | #define LINEDUMP_MAX 32 |
2671 | 2678 | ||
2672 | -void trace_netdata(char direction, unsigned const char *buf, int len) | 2679 | +void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, int len) |
2673 | { | 2680 | { |
2674 | int offset; | 2681 | int offset; |
2675 | struct timeval ts; | 2682 | struct timeval ts; |
2676 | double tdiff; | 2683 | double tdiff; |
2677 | 2684 | ||
2678 | - if (!lib3270_get_toggle(&h3270,LIB3270_TOGGLE_DS_TRACE)) | 2685 | + if (!lib3270_get_toggle(hSession,LIB3270_TOGGLE_DS_TRACE)) |
2679 | return; | 2686 | return; |
2687 | + | ||
2680 | (void) gettimeofday(&ts, (struct timezone *)NULL); | 2688 | (void) gettimeofday(&ts, (struct timezone *)NULL); |
2681 | - if (IN_3270) { | 2689 | + if (IN_3270) |
2690 | + { | ||
2682 | tdiff = ((1.0e6 * (double)(ts.tv_sec - h3270.ds_ts.tv_sec)) + | 2691 | tdiff = ((1.0e6 * (double)(ts.tv_sec - h3270.ds_ts.tv_sec)) + |
2683 | (double)(ts.tv_usec - h3270.ds_ts.tv_usec)) / 1.0e6; | 2692 | (double)(ts.tv_usec - h3270.ds_ts.tv_usec)) / 1.0e6; |
2684 | trace_dsn("%c +%gs\n", direction, tdiff); | 2693 | trace_dsn("%c +%gs\n", direction, tdiff); |
2685 | } | 2694 | } |
2686 | - h3270.ds_ts = ts; | ||
2687 | - for (offset = 0; offset < len; offset++) { | 2695 | + |
2696 | + hSession->ds_ts = ts; | ||
2697 | + for (offset = 0; offset < len; offset++) | ||
2698 | + { | ||
2688 | if (!(offset % LINEDUMP_MAX)) | 2699 | if (!(offset % LINEDUMP_MAX)) |
2689 | trace_dsn("%s%c 0x%-3x ", | 2700 | trace_dsn("%s%c 0x%-3x ", |
2690 | (offset ? "\n" : ""), direction, offset); | 2701 | (offset ? "\n" : ""), direction, offset); |
src/lib3270/telnetc.h
@@ -60,7 +60,7 @@ LIB3270_INTERNAL void space3270out(H3270 *hSession, int n); | @@ -60,7 +60,7 @@ LIB3270_INTERNAL void space3270out(H3270 *hSession, int n); | ||
60 | // LIB3270_INTERNAL char *net_proxy_port(void); | 60 | // LIB3270_INTERNAL char *net_proxy_port(void); |
61 | 61 | ||
62 | #if defined(X3270_TRACE) | 62 | #if defined(X3270_TRACE) |
63 | - LIB3270_INTERNAL void trace_netdata(char direction, unsigned const char *buf, int len); | 63 | + LIB3270_INTERNAL void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, int len); |
64 | #else | 64 | #else |
65 | #define trace_netdata(direction, buf, len) /* */ | 65 | #define trace_netdata(direction, buf, len) /* */ |
66 | #endif // X3270_TRACE | 66 | #endif // X3270_TRACE |