more debug

This commit is contained in:
Dan Bungert 2013-10-25 15:29:46 -06:00
parent f13c8a0be7
commit cefcac3414
5 changed files with 62 additions and 13 deletions

View File

@ -42,6 +42,8 @@ int main(int argc, char* argv[])
rdpSettings* settings;
RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
setvbuf(stderr, NULL, _IONBF, 0);
ZeroMemory(&clientEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
clientEntryPoints.Size = sizeof(RDP_CLIENT_ENTRY_POINTS);
clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION;

View File

@ -43,6 +43,8 @@
#include "rpc.h"
#include "lwd.h"
/* Security Verification Trailer Signature */
rpc_sec_verification_trailer RPC_SEC_VERIFICATION_TRAILER =
@ -316,8 +318,12 @@ int rpc_out_read(rdpRpc* rpc, BYTE* data, int length)
{
int status;
LWD("len %d", length);
status = tls_read(rpc->TlsOut, data, length);
LWD("status %d", status);
return status;
}
@ -325,8 +331,12 @@ int rpc_out_write(rdpRpc* rpc, BYTE* data, int length)
{
int status;
LWD("len %d", length);
status = tls_write_all(rpc->TlsOut, data, length);
LWD("status %d", status);
return status;
}
@ -342,9 +352,13 @@ int rpc_in_write(rdpRpc* rpc, BYTE* data, int length)
fprintf(stderr, "\n");
*/
#endif
LWD("len %d", length);
status = tls_write_all(rpc->TlsIn, data, length);
LWD("status %d", status);
return status;
}
@ -362,9 +376,12 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
ntlm = rpc->ntlm;
LWD("len %d", length);
if (ntlm->table->QueryContextAttributes(&ntlm->context, SECPKG_ATTR_SIZES, &ntlm->ContextSizes) != SEC_E_OK)
{
fprintf(stderr, "QueryContextAttributes SECPKG_ATTR_SIZES failure\n");
LWD("status -1 query context");
return -1;
}
@ -436,6 +453,7 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
{
fprintf(stderr, "EncryptMessage status: 0x%08X\n", encrypt_status);
free(request_pdu);
LWD("status -1 encrypt_status fail");
return -1;
}
@ -446,6 +464,8 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
rpc_send_enqueue_pdu(rpc, buffer, request_pdu->frag_length);
free(request_pdu);
LWD("status %d", length);
return length;
}

View File

@ -223,6 +223,7 @@ BOOL transport_connect_tls(rdpTransport* transport)
if (transport->layer == TRANSPORT_LAYER_TSG)
{
transport->TsgTls = tls_new(transport->settings);
LWD("create TsgTls");
sprintf(transport->TsgTls->desc, "TsgTls");
transport->TsgTls->methods = BIO_s_tsg();
@ -247,6 +248,7 @@ BOOL transport_connect_tls(rdpTransport* transport)
if (transport->TlsIn == NULL) {
transport->TlsIn = tls_new(transport->settings);
LWD("create TlsIn");
sprintf(transport->TlsIn->desc, "TlsIn");
}
@ -324,6 +326,7 @@ BOOL transport_tsg_connect(rdpTransport* transport, const char* hostname, UINT16
if (transport->TlsIn == NULL) {
transport->TlsIn = tls_new(transport->settings);
LWD("create TlsIn");
sprintf(transport->TlsIn->desc, "TlsIn");
}
@ -331,6 +334,7 @@ BOOL transport_tsg_connect(rdpTransport* transport, const char* hostname, UINT16
if (transport->TlsOut == NULL) {
transport->TlsOut = tls_new(transport->settings);
LWD("create TlsOut");
sprintf(transport->TlsOut->desc, "TlsOut");
}
@ -398,6 +402,7 @@ BOOL transport_accept_tls(rdpTransport* transport)
{
if (transport->TlsIn == NULL) {
transport->TlsIn = tls_new(transport->settings);
LWD("create TlsIn");
sprintf(transport->TlsIn->desc, "TlsIn");
}
@ -418,13 +423,14 @@ BOOL transport_accept_nla(rdpTransport* transport)
freerdp* instance;
rdpSettings* settings;
if (transport->TlsIn == NULL)
if (transport->TlsIn == NULL) {
transport->TlsIn = tls_new(transport->settings);
if (transport->TlsOut == NULL) {
transport->TlsOut = transport->TlsIn;
LWD("create TlsIn");
sprintf(transport->TlsIn->desc, "TlsIn");
}
if (transport->TlsOut == NULL)
transport->TlsOut = transport->TlsIn;
transport->layer = TRANSPORT_LAYER_TLS;
transport->TlsIn->sockfd = transport->TcpIn->sockfd;
@ -518,6 +524,24 @@ UINT32 nla_header_length(wStream* s)
return length;
}
char *want(rdpTls *tls)
{
int what = SSL_want(tls->ssl);
switch(what)
{
case SSL_NOTHING:
return "NOTHING";
case SSL_WRITING:
return "WRITING";
case SSL_READING:
return "READING";
case SSL_X509_LOOKUP:
return "X509_LOOKUP";
default:
return "UNKNOWN";
}
}
int transport_read_layer(rdpTransport* transport, UINT8* data, int bytes)
{
int read = 0;
@ -543,8 +567,12 @@ int transport_read_layer(rdpTransport* transport, UINT8* data, int bytes)
status = tcp_read(transport->TcpIn, data + read, bytes - read);
else if (transport->layer == TRANSPORT_LAYER_TSG)
status = tsg_read(transport->tsg, data + read, bytes - read);
else if (transport->layer == TRANSPORT_LAYER_TSG_TLS)
else if (transport->layer == TRANSPORT_LAYER_TSG_TLS) {
LWD("TlsIn SSL pending %d want %s", SSL_pending(transport->TlsIn->ssl), want(transport->TlsIn));
LWD("TlsOut SSL pending %d want %s", SSL_pending(transport->TlsOut->ssl), want(transport->TlsOut));
LWD("TsgTls SSL pending %d want %s", SSL_pending(transport->TsgTls->ssl), want(transport->TsgTls));
status = tls_read(transport->TsgTls, data + read, bytes - read);
}
/* blocking means that we can't continue until this is read */

View File

@ -375,7 +375,7 @@ int tls_read(rdpTls* tls, BYTE* data, int length)
int error;
int status;
LWD("length %d", length);
LWD("tls %s length %d", tls->desc, length);
status = SSL_read(tls->ssl, data, length);
@ -415,7 +415,7 @@ int tls_read(rdpTls* tls, BYTE* data, int length)
}
}
LWD("ret %d", status);
LWD("tls %s ret %d", tls->desc, status);
return status;
}
@ -440,7 +440,7 @@ int tls_write(rdpTls* tls, BYTE* data, int length)
int error;
int status;
LWD("length %d", length);
LWD("tls %s length %d", tls->desc, length);
status = SSL_write(tls->ssl, data, length);
@ -479,7 +479,7 @@ int tls_write(rdpTls* tls, BYTE* data, int length)
}
}
LWD("ret %d", status);
LWD("tls %s ret %d", tls->desc, status);
return status;
}

7
lwd.h
View File

@ -10,13 +10,12 @@
time_t tod = time(NULL); \
char buf[25]; \
struct tm* tm_info = localtime(&tod); \
strftime(buf, 25, "%Y:%m:%d %H:%M:%S", tm_info); \
fprintf(stderr, "%s [%s] ", __FUNCTION__, buf); \
strftime(buf, 25, "%H:%M:%S", tm_info); \
fprintf(stderr, "%20.20s [%s] ", __FUNCTION__, buf); \
fprintf(stderr, fmt, ## __VA_ARGS__); \
fprintf(stderr, "\n"); \
fflush(stderr); \
} while( 0 )
// fflush(stderr);
#endif