From 1efefceb5c8a3b0a2222e3ca2c5516e15c8f7ae6 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 13 May 2024 12:25:38 +0200 Subject: [PATCH] [core,settings] refactor /network * add CONNECTION_TYPE_INVALID * default to CONNECTION_TYPE_AUTODETECT * allow /network:invalid and /network:0 to disable --- client/common/cmdline.c | 30 +++++++++++------------------- client/common/cmdline.h | 2 +- include/freerdp/settings_types.h | 3 +++ libfreerdp/core/settings.c | 3 ++- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/client/common/cmdline.c b/client/common/cmdline.c index b934b20bb..0df29a924 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -1319,6 +1319,9 @@ static BOOL freerdp_apply_connection_type(rdpSettings* settings, UINT32 type) switch (type) { + case CONNECTION_TYPE_INVALID: + return TRUE; + case CONNECTION_TYPE_MODEM: case CONNECTION_TYPE_BROADBAND_LOW: case CONNECTION_TYPE_BROADBAND_HIGH: @@ -1328,7 +1331,7 @@ static BOOL freerdp_apply_connection_type(rdpSettings* settings, UINT32 type) case CONNECTION_TYPE_AUTODETECT: break; default: - WLog_WARN(TAG, "Invalid ConnectionType %" PRIu32 ", aborting", type); + WLog_WARN(TAG, "Unknown ConnectionType %" PRIu32 ", aborting", type); return FALSE; } @@ -1349,26 +1352,12 @@ BOOL freerdp_set_connection_type(rdpSettings* settings, UINT32 type) switch (type) { + case CONNECTION_TYPE_INVALID: case CONNECTION_TYPE_MODEM: - if (!freerdp_apply_connection_type(settings, type)) - return FALSE; - break; case CONNECTION_TYPE_BROADBAND_LOW: - if (!freerdp_apply_connection_type(settings, type)) - return FALSE; - break; case CONNECTION_TYPE_SATELLITE: - if (!freerdp_apply_connection_type(settings, type)) - return FALSE; - break; case CONNECTION_TYPE_BROADBAND_HIGH: - if (!freerdp_apply_connection_type(settings, type)) - return FALSE; - break; case CONNECTION_TYPE_WAN: - if (!freerdp_apply_connection_type(settings, type)) - return FALSE; - break; case CONNECTION_TYPE_LAN: if (!freerdp_apply_connection_type(settings, type)) return FALSE; @@ -1388,6 +1377,7 @@ BOOL freerdp_set_connection_type(rdpSettings* settings, UINT32 type) return FALSE; break; default: + WLog_WARN(TAG, "Unknown ConnectionType %" PRIu32 ", aborting", type); return FALSE; } @@ -3078,9 +3068,11 @@ static int parse_network_options(rdpSettings* settings, const COMMAND_LINE_ARGUM WINPR_ASSERT(settings); WINPR_ASSERT(arg); - UINT32 type = 0; + UINT32 type = CONNECTION_TYPE_INVALID; - if (option_equals(arg->Value, "modem")) + if (option_equals(arg->Value, "invalid")) + type = CONNECTION_TYPE_INVALID; + else if (option_equals(arg->Value, "modem")) type = CONNECTION_TYPE_MODEM; else if (option_equals(arg->Value, "broadband")) type = CONNECTION_TYPE_BROADBAND_HIGH; @@ -3101,7 +3093,7 @@ static int parse_network_options(rdpSettings* settings, const COMMAND_LINE_ARGUM { LONGLONG val = 0; - if (!value_to_int(arg->Value, &val, 1, 7)) + if (!value_to_int(arg->Value, &val, 0, 7)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; type = (UINT32)val; diff --git a/client/common/cmdline.h b/client/common/cmdline.h index 3afddb1f0..3b7f222dc 100644 --- a/client/common/cmdline.h +++ b/client/common/cmdline.h @@ -341,7 +341,7 @@ static const COMMAND_LINE_ARGUMENT_A global_cmd_args[] = { { "nego", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "protocol security negotiation" }, { "network", COMMAND_LINE_VALUE_REQUIRED, - "[modem|broadband|broadband-low|broadband-high|wan|lan|auto]", NULL, NULL, -1, NULL, + "[invalid|modem|broadband|broadband-low|broadband-high|wan|lan|auto]", NULL, NULL, -1, NULL, "Network connection type" }, { "nsc", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "nscodec", "NSCodec support" }, #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE) diff --git a/include/freerdp/settings_types.h b/include/freerdp/settings_types.h index cf4780252..4eb9c64c2 100644 --- a/include/freerdp/settings_types.h +++ b/include/freerdp/settings_types.h @@ -85,6 +85,9 @@ extern "C" #define PERF_ENABLE_DESKTOP_COMPOSITION 0x00000100 /* Connection Types */ +#define CONNECTION_TYPE_INVALID \ + 0x00 /* synthetic, removes RNS_UD_CS_VALID_CONNECTION_TYPE from ConnectionType in \ + EarlyCapabilityFlags */ #define CONNECTION_TYPE_MODEM 0x01 #define CONNECTION_TYPE_BROADBAND_LOW 0x02 #define CONNECTION_TYPE_SATELLITE 0x03 diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index fd95c7cb8..3cfbecfdd 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -448,7 +448,8 @@ rdpSettings* freerdp_settings_new(DWORD flags) !freerdp_settings_set_bool(settings, FreeRDP_DisableFullWindowDrag, TRUE) || !freerdp_settings_set_bool(settings, FreeRDP_DisableMenuAnims, TRUE) || !freerdp_settings_set_bool(settings, FreeRDP_DisableThemes, FALSE) || - !freerdp_settings_set_uint32(settings, FreeRDP_ConnectionType, CONNECTION_TYPE_LAN) || + !freerdp_settings_set_uint32(settings, FreeRDP_ConnectionType, + CONNECTION_TYPE_AUTODETECT) || !freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect, TRUE) || !freerdp_settings_set_uint32(settings, FreeRDP_EncryptionMethods, ENCRYPTION_METHOD_NONE) || !freerdp_settings_set_uint32(settings, FreeRDP_EncryptionLevel, ENCRYPTION_LEVEL_NONE) ||