Added data_pdu_type_to_string
authorakallabeth <akallabeth@posteo.net>
Thu, 19 Nov 2020 12:42:28 +0000 (13:42 +0100)
committerakallabeth <akallabeth@users.noreply.github.com>
Thu, 25 Feb 2021 08:51:41 +0000 (09:51 +0100)
(cherry picked from commit b6b8d74521364bcf9c3ba2296d43e9fd3413e429)

libfreerdp/core/peer.c
libfreerdp/core/rdp.c
libfreerdp/core/rdp.h

index 9a69900..824d7da 100644 (file)
@@ -276,8 +276,7 @@ static BOOL peer_recv_data_pdu(freerdp_peer* client, wStream* s, UINT16 totalLen
 
 #ifdef WITH_DEBUG_RDP
        WLog_DBG(TAG, "recv %s Data PDU (0x%02" PRIX8 "), length: %" PRIu16 "",
-                type < ARRAYSIZE(DATA_PDU_TYPE_STRINGS) ? DATA_PDU_TYPE_STRINGS[type] : "???", type,
-                length);
+                data_pdu_type_to_string(type), type, length);
 #endif
 
        switch (type)
index 1c8990e..4dac507 100644 (file)
@@ -34,7 +34,7 @@
 
 #define TAG FREERDP_TAG("core.rdp")
 
-const char* DATA_PDU_TYPE_STRINGS[80] = {
+static const char* DATA_PDU_TYPE_STRINGS[80] = {
        "?",
        "?",      /* 0x00 - 0x01 */
        "Update", /* 0x02 */
@@ -102,6 +102,13 @@ const char* DATA_PDU_TYPE_STRINGS[80] = {
        "?" /* 0x41 - 0x46 */
 };
 
+const char* data_pdu_type_to_string(UINT8 type)
+{
+       if (type > ARRAYSIZE(DATA_PDU_TYPE_STRINGS))
+               return "???";
+       return DATA_PDU_TYPE_STRINGS[type];
+}
+
 static BOOL rdp_read_flow_control_pdu(wStream* s, UINT16* type, UINT16* channel_id);
 static void rdp_write_share_control_header(wStream* s, UINT16 length, UINT16 type,
                                            UINT16 channel_id);
@@ -920,8 +927,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s)
        }
 
        WLog_DBG(TAG, "recv %s Data PDU (0x%02" PRIX8 "), length: %" PRIu16 "",
-                type < ARRAYSIZE(DATA_PDU_TYPE_STRINGS) ? DATA_PDU_TYPE_STRINGS[type] : "???", type,
-                length);
+                data_pdu_type_to_string(type), type, length);
 
        switch (type)
        {
index 47281d6..b6cd3a0 100644 (file)
@@ -227,7 +227,7 @@ FREERDP_LOCAL void rdp_free(rdpRdp* rdp);
 #define RDP_TAG FREERDP_TAG("core.rdp")
 #ifdef WITH_DEBUG_RDP
 #define DEBUG_RDP(...) WLog_DBG(RDP_TAG, __VA_ARGS__)
-extern const char* DATA_PDU_TYPE_STRINGS[80];
+const char* data_pdu_type_to_string(UINT8 type);
 #else
 #define DEBUG_RDP(...) \
        do                 \