From 629858b67662add7f08737f601fc70e8bc352d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 30 May 2014 12:31:26 -0400 Subject: [PATCH] libfreerdp-core: add gateway-usage-method command line option, avoid resetting BIO flags we shouldn't reset --- client/common/cmdline.c | 27 ++++++++++++++++++++++++--- libfreerdp/core/freerdp.c | 11 ++++++++--- libfreerdp/core/settings.c | 1 - libfreerdp/core/tcp.c | 4 ++-- libfreerdp/core/transport.c | 6 ++++-- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 5e633c4e8..34d300d9c 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -73,6 +73,7 @@ COMMAND_LINE_ARGUMENT_A args[] = { "gu", COMMAND_LINE_VALUE_REQUIRED, "[\\] or [@]", NULL, NULL, -1, NULL, "Gateway username" }, { "gp", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Gateway password" }, { "gd", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Gateway domain" }, + { "gateway-usage-method", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Gateway usage method" }, { "load-balance-info", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Load balance info" }, { "app", COMMAND_LINE_VALUE_REQUIRED, " or <||alias>", NULL, NULL, -1, NULL, "Remote application program" }, { "app-name", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Remote application name for user interface" }, @@ -1384,11 +1385,10 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, settings->GatewayHostname = _strdup(settings->ServerHostname); } + settings->GatewayEnabled = TRUE; settings->GatewayUseSameCredentials = TRUE; - settings->GatewayUsageMethod = TSC_PROXY_MODE_DETECT; - settings->GatewayEnabled = TRUE; - settings->GatewayBypassLocal = TRUE; + freerdp_set_gateway_usage_method(settings, TSC_PROXY_MODE_DETECT); } CommandLineSwitchCase(arg, "gu") { @@ -1412,6 +1412,27 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, settings->GatewayPassword = _strdup(arg->Value); settings->GatewayUseSameCredentials = FALSE; } + CommandLineSwitchCase(arg, "gateway-usage-method") + { + int type; + char* pEnd; + + type = strtol(arg->Value, &pEnd, 10); + + if (type == 0) + { + if (_stricmp(arg->Value, "none") == 0) + type = TSC_PROXY_MODE_NONE_DIRECT; + else if (_stricmp(arg->Value, "direct") == 0) + type = TSC_PROXY_MODE_DIRECT; + else if (_stricmp(arg->Value, "detect") == 0) + type = TSC_PROXY_MODE_DETECT; + else if (_stricmp(arg->Value, "default") == 0) + type = TSC_PROXY_MODE_DEFAULT; + } + + freerdp_set_gateway_usage_method(settings, (UINT32) type); + } CommandLineSwitchCase(arg, "app") { settings->RemoteApplicationProgram = _strdup(arg->Value); diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 94deaae30..9a780eca5 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -212,9 +212,14 @@ BOOL freerdp_check_fds(freerdp* instance) int status; rdpRdp* rdp; - assert(instance); - assert(instance->context); - assert(instance->context->rdp); + if (!instance) + return FALSE; + + if (!instance->context) + return FALSE; + + if (!instance->context->rdp) + return FALSE; rdp = instance->context->rdp; diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index ce8e720d9..6c0de1e7f 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -236,7 +236,6 @@ rdpSettings* freerdp_settings_new(DWORD flags) settings->SaltedChecksum = TRUE; settings->ServerPort = 3389; settings->GatewayPort = 443; - settings->GatewayBypassLocal = TRUE; settings->DesktopResize = TRUE; settings->ToggleFullscreen = TRUE; settings->DesktopPosX = 0; diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index f869c4c71..1f44289ca 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -79,7 +79,7 @@ static int transport_bio_buffered_write(BIO* bio, const char* buf, int num) DataChunk chunks[2]; ret = num; - BIO_clear_retry_flags(bio); + BIO_clear_flags(bio, (BIO_FLAGS_WRITE | BIO_FLAGS_SHOULD_RETRY | BIO_FLAGS_IO_SPECIAL)); tcp->writeBlocked = FALSE; /* we directly append extra bytes in the xmit buffer, this could be prevented @@ -132,7 +132,7 @@ static int transport_bio_buffered_read(BIO* bio, char* buf, int size) rdpTcp *tcp = (rdpTcp *)bio->ptr; tcp->readBlocked = FALSE; - BIO_clear_retry_flags(bio); + BIO_clear_flags(bio, (BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY | BIO_FLAGS_IO_SPECIAL)); status = BIO_read(bio->next_bio, buf, size); /*fprintf(stderr, "%s: size=%d status=%d shouldRetry=%d\n", __FUNCTION__, size, status, BIO_should_retry(bio->next_bio)); */ diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index bb455a927..bf58ceff4 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -133,8 +133,10 @@ static int transport_bio_tsg_write(BIO* bio, const char* buf, int num) tsg = (rdpTsg*) bio->ptr; - BIO_clear_retry_flags(bio); + BIO_clear_flags(bio, (BIO_FLAGS_WRITE | BIO_FLAGS_SHOULD_RETRY | BIO_FLAGS_IO_SPECIAL)); + status = tsg_write(tsg, (BYTE*) buf, num); + if (status > 0) return status; @@ -152,7 +154,7 @@ static int transport_bio_tsg_read(BIO* bio, char* buf, int size) tsg = (rdpTsg*) bio->ptr; status = tsg_read(bio->ptr, (BYTE*) buf, size); - BIO_clear_retry_flags(bio); + BIO_clear_flags(bio, (BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY | BIO_FLAGS_IO_SPECIAL)); if (status == 0) {