[core,settings] refactor /network

* add CONNECTION_TYPE_INVALID
* default to CONNECTION_TYPE_AUTODETECT
* allow /network:invalid and /network:0 to disable
This commit is contained in:
akallabeth 2024-05-13 12:25:38 +02:00
parent a1d8754f1f
commit 1efefceb5c
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
4 changed files with 17 additions and 21 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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

View File

@ -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) ||