Updated RDP_VERSION definitions.
authorArmin Novak <armin.novak@thincast.com>
Wed, 14 Nov 2018 09:14:48 +0000 (10:14 +0100)
committerArmin Novak <armin.novak@thincast.com>
Wed, 14 Nov 2018 09:14:48 +0000 (10:14 +0100)
include/freerdp/settings.h
libfreerdp/core/capabilities.c
libfreerdp/core/gcc.c
libfreerdp/core/info.c
libfreerdp/core/settings.c

index fefad60..a8be3f8 100644 (file)
 #define SC_MCS_MSGCHANNEL      0x0C04
 #define SC_MULTITRANSPORT      0x0C08
 
-/* RDP version */
-#define RDP_VERSION_4          0x00080001
-#define RDP_VERSION_5_PLUS     0x00080004
+/* RDP versions, see
+ * [MS-RDPBCGR] 2.2.1.3.2 Client Core Data (TS_UD_CS_CORE)
+ * [MS-RDPBCGR] 2.2.1.4.2 Server Core Data (TS_UD_SC_CORE)
+ */
+typedef enum
+{
+       RDP_VERSION_4           = 0x00080001,
+       RDP_VERSION_5_PLUS      = 0x00080004,
+       RDP_VERSION_10_0        = 0x00800005,
+       RDP_VERSION_10_1        = 0x00800006,
+       RDP_VERSION_10_2        = 0x00800007,
+       RDP_VERSION_10_3        = 0x00800008,
+       RDP_VERSION_10_4        = 0x00800009,
+       RDP_VERSION_10_5        = 0x0080000a,
+       RDP_VERSION_10_6        = 0x0080000b,
+}
+RDP_VERSION;
 
 /* Color depth */
 #define RNS_UD_COLOR_4BPP      0xCA00
index 5571c0a..a811160 100644 (file)
@@ -415,7 +415,7 @@ static BOOL rdp_write_bitmap_capability_set(wStream* s, rdpSettings* settings)
         * appears consistent in its use.
         */
 
-       if (settings->RdpVersion > 5)
+       if (settings->RdpVersion >= RDP_VERSION_5_PLUS)
                preferredBitsPerPixel = settings->ColorDepth;
        else
                preferredBitsPerPixel = 8;
@@ -4072,7 +4072,7 @@ BOOL rdp_write_confirm_active(wStream* s, rdpSettings* settings)
            !rdp_write_order_capability_set(s, settings))
                return FALSE;
 
-       if (settings->RdpVersion >= 5)
+       if (settings->RdpVersion >= RDP_VERSION_5_PLUS)
                ret = rdp_write_bitmap_cache_v2_capability_set(s, settings);
        else
                ret = rdp_write_bitmap_cache_capability_set(s, settings);
index 80a9faf..15ca767 100644 (file)
 
 #define TAG FREERDP_TAG("core.gcc")
 
+static DWORD rdp_version_common(DWORD serverVersion, DWORD clientVersion)
+{
+       DWORD version = MIN(serverVersion, clientVersion);
+
+       switch (version)
+       {
+               case RDP_VERSION_4:
+               case RDP_VERSION_5_PLUS:
+               case RDP_VERSION_10_0:
+               case RDP_VERSION_10_1:
+               case RDP_VERSION_10_2:
+               case RDP_VERSION_10_3:
+               case RDP_VERSION_10_4:
+               case RDP_VERSION_10_5:
+               case RDP_VERSION_10_6:
+                       return version;
+
+               default:
+                       WLog_ERR(TAG, "Invalid client [%"PRId32"] and server [%"PRId32"] versions",
+                                serverVersion, clientVersion);
+                       return version;
+       }
+}
 
 /**
  * T.124 GCC is defined in:
@@ -606,7 +629,7 @@ BOOL gcc_read_client_core_data(wStream* s, rdpMcs* mcs, UINT16 blockLength)
                return FALSE;
 
        Stream_Read_UINT32(s, version); /* version (4 bytes) */
-       settings->RdpVersion = (version == RDP_VERSION_4 ? 4 : 7);
+       settings->RdpVersion = rdp_version_common(version, settings->RdpVersion);
        Stream_Read_UINT16(s, settings->DesktopWidth); /* DesktopWidth (2 bytes) */
        Stream_Read_UINT16(s, settings->DesktopHeight); /* DesktopHeight (2 bytes) */
        Stream_Read_UINT16(s, colorDepth); /* ColorDepth (2 bytes) */
@@ -857,7 +880,6 @@ BOOL gcc_read_client_core_data(wStream* s, rdpMcs* mcs, UINT16 blockLength)
 
 void gcc_write_client_core_data(wStream* s, rdpMcs* mcs)
 {
-       UINT32 version;
        WCHAR* clientName = NULL;
        int clientNameLength;
        BYTE connectionType;
@@ -868,12 +890,11 @@ void gcc_write_client_core_data(wStream* s, rdpMcs* mcs)
        int clientDigProductIdLength;
        rdpSettings* settings = mcs->settings;
        gcc_write_user_data_header(s, CS_CORE, 234);
-       version = settings->RdpVersion >= 5 ? RDP_VERSION_5_PLUS : RDP_VERSION_4;
        clientNameLength = ConvertToUnicode(CP_UTF8, 0, settings->ClientHostname, -1,
                                            &clientName, 0);
        clientDigProductIdLength = ConvertToUnicode(CP_UTF8, 0,
                                   settings->ClientProductId, -1, &clientDigProductId, 0);
-       Stream_Write_UINT32(s, version); /* Version */
+       Stream_Write_UINT32(s, settings->RdpVersion); /* Version */
        Stream_Write_UINT16(s, settings->DesktopWidth); /* DesktopWidth */
        Stream_Write_UINT16(s, settings->DesktopHeight); /* DesktopHeight */
        Stream_Write_UINT16(s,
@@ -971,7 +992,7 @@ void gcc_write_client_core_data(wStream* s, rdpMcs* mcs)
 
 BOOL gcc_read_server_core_data(wStream* s, rdpMcs* mcs)
 {
-       UINT32 version;
+       UINT32 serverVersion;
        UINT32 clientRequestedProtocols;
        UINT32 earlyCapabilityFlags;
        rdpSettings* settings = mcs->settings;
@@ -979,12 +1000,8 @@ BOOL gcc_read_server_core_data(wStream* s, rdpMcs* mcs)
        if (Stream_GetRemainingLength(s) < 4)
                return FALSE;
 
-       Stream_Read_UINT32(s, version); /* version */
-
-       if (version == RDP_VERSION_4 && settings->RdpVersion > 4)
-               settings->RdpVersion = 4;
-       else if (version == RDP_VERSION_5_PLUS && settings->RdpVersion < 5)
-               settings->RdpVersion = 7;
+       Stream_Read_UINT32(s, serverVersion); /* version */
+       settings->RdpVersion = rdp_version_common(serverVersion, settings->RdpVersion);
 
        if (Stream_GetRemainingLength(s) >= 4)
        {
@@ -1001,7 +1018,6 @@ BOOL gcc_read_server_core_data(wStream* s, rdpMcs* mcs)
 
 BOOL gcc_write_server_core_data(wStream* s, rdpMcs* mcs)
 {
-       UINT32 version;
        UINT32 earlyCapabilityFlags = 0;
        rdpSettings* settings = mcs->settings;
 
@@ -1009,12 +1025,11 @@ BOOL gcc_write_server_core_data(wStream* s, rdpMcs* mcs)
                return FALSE;
 
        gcc_write_user_data_header(s, SC_CORE, 16);
-       version = settings->RdpVersion == 4 ? RDP_VERSION_4 : RDP_VERSION_5_PLUS;
 
        if (settings->SupportDynamicTimeZone)
                earlyCapabilityFlags |= RNS_UD_SC_DYNAMIC_DST_SUPPORTED;
 
-       Stream_Write_UINT32(s, version); /* version (4 bytes) */
+       Stream_Write_UINT32(s, settings->RdpVersion); /* version (4 bytes) */
        Stream_Write_UINT32(s,
                            settings->RequestedProtocols); /* clientRequestedProtocols (4 bytes) */
        Stream_Write_UINT32(s,
index 0e64366..e76af13 100644 (file)
@@ -676,7 +676,7 @@ static BOOL rdp_read_info_packet(rdpRdp* rdp, wStream* s)
 
        Stream_Seek(s, 2);
 
-       if (settings->RdpVersion >= 5)
+       if (settings->RdpVersion >= RDP_VERSION_5_PLUS)
                return rdp_read_extended_info_packet(rdp, s); /* extraInfo */
 
        return TRUE;
@@ -873,7 +873,7 @@ static void rdp_write_info_packet(rdpRdp* rdp, wStream* s)
        if (!usedPasswordCookie)
                free(passwordW);
 
-       if (settings->RdpVersion >= 5)
+       if (settings->RdpVersion >= RDP_VERSION_5_PLUS)
                rdp_write_extended_info_packet(rdp, s); /* extraInfo */
 }
 
index 4f013ab..e779845 100644 (file)
@@ -298,7 +298,7 @@ rdpSettings* freerdp_settings_new(DWORD flags)
        settings->Fullscreen = FALSE;
        settings->GrabKeyboard = TRUE;
        settings->Decorations = TRUE;
-       settings->RdpVersion = 7;
+       settings->RdpVersion = RDP_VERSION_5_PLUS;
        settings->ColorDepth = 16;
        settings->ExtSecurity = FALSE;
        settings->NlaSecurity = TRUE;