Merge pull request #2401 from metalefty/codec_guid
Record codec GUID to identify unknown codec
This commit is contained in:
commit
cc43061ed4
5
.gitignore
vendored
5
.gitignore
vendored
@ -48,11 +48,14 @@ stamp-h1
|
||||
tap-driver.sh
|
||||
test-driver
|
||||
tests/common/test_common
|
||||
tests/libipm/test_libipm
|
||||
tests/libxrdp/test_libxrdp
|
||||
tests/memtest/memtest
|
||||
tests/xrdp/test_xrdp
|
||||
tools/devel/tcp_proxy/tcp_proxy
|
||||
*.trs
|
||||
xrdp/xrdp
|
||||
xrdp/xrdp.ini
|
||||
xrdp_configure_options.h
|
||||
xrdpapi/xrdp-xrdpapi-simple
|
||||
.vscode/*
|
||||
.vscode/*
|
||||
|
@ -65,8 +65,20 @@ guid_is_set(const struct guid *guid)
|
||||
|
||||
}
|
||||
|
||||
const char *guid_to_str(const struct guid *guid, char *str)
|
||||
const char *guid_to_str(const struct guid *src, char *dest)
|
||||
{
|
||||
g_bytes_to_hexstr(guid->g, GUID_SIZE, str, GUID_STR_SIZE);
|
||||
return str;
|
||||
const unsigned char *guid = (const unsigned char *)src->g;
|
||||
|
||||
/*
|
||||
* Flipping integers into little-endian
|
||||
* See also: https://devblogs.microsoft.com/oldnewthing/20220928-00/?p=107221
|
||||
*/
|
||||
g_sprintf(dest, "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||
guid[3], guid[2], guid[1], guid[0],
|
||||
guid[5], guid[4],
|
||||
guid[7], guid[6],
|
||||
guid[8], guid[9],
|
||||
guid[10], guid[11], guid[12], guid[13], guid[14], guid[15]);
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
@ -28,7 +28,8 @@
|
||||
#include "arch.h"
|
||||
|
||||
#define GUID_SIZE 16 /* bytes */
|
||||
#define GUID_STR_SIZE (GUID_SIZE * 2 + 1) /* Size for string representation */
|
||||
#define GUID_STR_SIZE (GUID_SIZE * 2 + 4 + 1) /* w/ 4 hyphens + null terminator */
|
||||
|
||||
|
||||
/**
|
||||
* Use a struct for the guid so we can easily copy by assignment
|
||||
@ -66,10 +67,11 @@ guid_is_set(const struct guid *guid);
|
||||
* Converts a GUID to a string representation
|
||||
*
|
||||
* @param guid GUID to represent
|
||||
* @param str pointer to at least GUID_STR_SIZE bytes to store the
|
||||
* representation
|
||||
* @return str is returned for convenience
|
||||
* @param dest destionation pointer to at least GUID_STR_SIZE
|
||||
* bytes to store the representation
|
||||
* @return dest is returned for convenience
|
||||
*/
|
||||
const char *guid_to_str(const struct guid *guid, char *str);
|
||||
const char *guid_to_str(const struct guid *guid, char *dest);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -372,11 +372,11 @@
|
||||
|
||||
/* Bitmap Codec: codecGUID (2.2.7.2.10.1.1) */
|
||||
|
||||
/* CODEC_GUID_NSCODEC CA8D1BB9-000F-154F-589FAE2D1A87E2D6 */
|
||||
/* CODEC_GUID_NSCODEC CA8D1BB9-000F-154F-589F-AE2D1A87E2D6 */
|
||||
#define XR_CODEC_GUID_NSCODEC \
|
||||
"\xb9\x1b\x8d\xca\x0f\x00\x4f\x15\x58\x9f\xae\x2d\x1a\x87\xe2\xd6"
|
||||
|
||||
/* CODEC_GUID_REMOTEFX 76772F12-BD72-4463-AFB3B73C9C6F7886 */
|
||||
/* CODEC_GUID_REMOTEFX 76772F12-BD72-4463-AFB3-B73C9C6F7886 */
|
||||
#define XR_CODEC_GUID_REMOTEFX \
|
||||
"\x12\x2F\x77\x76\x72\xBD\x63\x44\xAF\xB3\xB7\x3C\x9C\x6F\x78\x86"
|
||||
|
||||
@ -384,18 +384,22 @@
|
||||
#define XR_CODEC_GUID_IMAGE_REMOTEFX \
|
||||
"\xD4\xCC\x44\x27\x8A\x9D\x74\x4E\x80\x3C\x0E\xCB\xEE\xA1\x9C\x54"
|
||||
|
||||
/* MFVideoFormat_H264 0x34363248-0000-0010-800000AA00389B71 */
|
||||
/* MFVideoFormat_H264 34363248-0000-0010-8000-00AA00389B71 */
|
||||
#define XR_CODEC_GUID_H264 \
|
||||
"\x48\x32\x36\x34\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71"
|
||||
|
||||
/* CODEC_GUID_JPEG 1BAF4CE6-9EED-430C-869ACB8B37B66237 */
|
||||
/* CODEC_GUID_JPEG 1BAF4CE6-9EED-430C-869A-CB8B37B66237 */
|
||||
#define XR_CODEC_GUID_JPEG \
|
||||
"\xE6\x4C\xAF\x1B\xED\x9E\x0C\x43\x86\x9A\xCB\x8B\x37\xB6\x62\x37"
|
||||
|
||||
/* CODEC_GUID_PNG 0E0C858D-28E0-45DB-ADAA0F83E57CC560 */
|
||||
/* CODEC_GUID_PNG 0E0C858D-28E0-45DB-ADAA-0F83E57CC560 */
|
||||
#define XR_CODEC_GUID_PNG \
|
||||
"\x8D\x85\x0C\x0E\xE0\x28\xDB\x45\xAD\xAA\x0F\x83\xE5\x7C\xC5\x60"
|
||||
|
||||
/* CODEC_GUID_IGNORE 0C4351A6-3535-42AE-910C-CDFCE5760B58 */
|
||||
#define XR_CODEC_GUID_IGNORE \
|
||||
"\xA6\x51\x43\x0C\x35\x35\xAE\x42\x91\x0C\xCD\xFC\xE5\x76\x0B\x58"
|
||||
|
||||
/* PDU Types (2.2.8.1.1.1.1) */
|
||||
#define PDUTYPE_DEMANDACTIVEPDU 0x1
|
||||
#define PDUTYPE_CONFIRMACTIVEPDU 0x3
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "guid.h"
|
||||
#include "libxrdp.h"
|
||||
#include "ms-rdpbcgr.h"
|
||||
#include "ms-rdperp.h"
|
||||
@ -521,6 +522,10 @@ xrdp_caps_process_codecs(struct xrdp_rdp *self, struct stream *s, int len)
|
||||
int i1;
|
||||
char *codec_guid;
|
||||
char *next_guid;
|
||||
struct guid guid;
|
||||
char codec_guid_str[GUID_STR_SIZE];
|
||||
|
||||
guid_clear(&guid);
|
||||
|
||||
if (len < 1)
|
||||
{
|
||||
@ -533,6 +538,10 @@ xrdp_caps_process_codecs(struct xrdp_rdp *self, struct stream *s, int len)
|
||||
for (index = 0; index < codec_count; index++)
|
||||
{
|
||||
codec_guid = s->p;
|
||||
|
||||
g_memcpy(guid.g, s->p, GUID_SIZE);
|
||||
guid_to_str(&guid, codec_guid_str);
|
||||
|
||||
if (len < 16 + 1 + 2)
|
||||
{
|
||||
LOG(LOG_LEVEL_ERROR, "xrdp_caps_process_codecs: error");
|
||||
@ -552,8 +561,8 @@ xrdp_caps_process_codecs(struct xrdp_rdp *self, struct stream *s, int len)
|
||||
|
||||
if (g_memcmp(codec_guid, XR_CODEC_GUID_NSCODEC, 16) == 0)
|
||||
{
|
||||
LOG(LOG_LEVEL_INFO, "xrdp_caps_process_codecs: nscodec, codec id %d, properties len %d",
|
||||
codec_id, codec_properties_length);
|
||||
LOG(LOG_LEVEL_INFO, "xrdp_caps_process_codecs: NSCodec(%s), codec id [%d], properties len [%d]",
|
||||
codec_guid_str, codec_id, codec_properties_length);
|
||||
self->client_info.ns_codec_id = codec_id;
|
||||
i1 = MIN(64, codec_properties_length);
|
||||
g_memcpy(self->client_info.ns_prop, s->p, i1);
|
||||
@ -561,8 +570,8 @@ xrdp_caps_process_codecs(struct xrdp_rdp *self, struct stream *s, int len)
|
||||
}
|
||||
else if (g_memcmp(codec_guid, XR_CODEC_GUID_REMOTEFX, 16) == 0)
|
||||
{
|
||||
LOG(LOG_LEVEL_INFO, "xrdp_caps_process_codecs: RemoteFX, codec id %d, properties len %d",
|
||||
codec_id, codec_properties_length);
|
||||
LOG(LOG_LEVEL_INFO, "xrdp_caps_process_codecs: RemoteFX(%s), codec id [%d], properties len [%d]",
|
||||
codec_guid_str, codec_id, codec_properties_length);
|
||||
self->client_info.rfx_codec_id = codec_id;
|
||||
i1 = MIN(64, codec_properties_length);
|
||||
g_memcpy(self->client_info.rfx_prop, s->p, i1);
|
||||
@ -570,8 +579,8 @@ xrdp_caps_process_codecs(struct xrdp_rdp *self, struct stream *s, int len)
|
||||
}
|
||||
else if (g_memcmp(codec_guid, XR_CODEC_GUID_JPEG, 16) == 0)
|
||||
{
|
||||
LOG(LOG_LEVEL_INFO, "xrdp_caps_process_codecs: jpeg, codec id %d, properties len %d",
|
||||
codec_id, codec_properties_length);
|
||||
LOG(LOG_LEVEL_INFO, "xrdp_caps_process_codecs: JPEG(%s), codec id [%d], properties len [%d]",
|
||||
codec_guid_str, codec_id, codec_properties_length);
|
||||
self->client_info.jpeg_codec_id = codec_id;
|
||||
i1 = MIN(64, codec_properties_length);
|
||||
g_memcpy(self->client_info.jpeg_prop, s->p, i1);
|
||||
@ -587,8 +596,8 @@ xrdp_caps_process_codecs(struct xrdp_rdp *self, struct stream *s, int len)
|
||||
}
|
||||
else if (g_memcmp(codec_guid, XR_CODEC_GUID_H264, 16) == 0)
|
||||
{
|
||||
LOG(LOG_LEVEL_INFO, "xrdp_caps_process_codecs: h264, codec id %d, properties len %d",
|
||||
codec_id, codec_properties_length);
|
||||
LOG(LOG_LEVEL_INFO, "xrdp_caps_process_codecs: H264(%s), codec id [%d], properties len [%d]",
|
||||
codec_guid_str, codec_id, codec_properties_length);
|
||||
self->client_info.h264_codec_id = codec_id;
|
||||
i1 = MIN(64, codec_properties_length);
|
||||
g_memcpy(self->client_info.h264_prop, s->p, i1);
|
||||
@ -596,7 +605,8 @@ xrdp_caps_process_codecs(struct xrdp_rdp *self, struct stream *s, int len)
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(LOG_LEVEL_WARNING, "xrdp_caps_process_codecs: unknown codec id %d", codec_id);
|
||||
LOG(LOG_LEVEL_WARNING, "xrdp_caps_process_codecs: unknown(%s), codec id [%d], properties len [%d]",
|
||||
codec_guid_str, codec_id, codec_properties_length);
|
||||
}
|
||||
|
||||
s->p = next_guid;
|
||||
|
@ -17,7 +17,8 @@ test_common_SOURCES = \
|
||||
test_string_calls.c \
|
||||
test_os_calls.c \
|
||||
test_ssl_calls.c \
|
||||
test_base64.c
|
||||
test_base64.c \
|
||||
test_guid.c
|
||||
|
||||
test_common_CFLAGS = \
|
||||
@CHECK_CFLAGS@ \
|
||||
|
@ -11,5 +11,6 @@ Suite *make_suite_test_string(void);
|
||||
Suite *make_suite_test_os_calls(void);
|
||||
Suite *make_suite_test_ssl_calls(void);
|
||||
Suite *make_suite_test_base64(void);
|
||||
Suite *make_suite_test_guid(void);
|
||||
|
||||
#endif /* TEST_COMMON_H */
|
||||
|
@ -49,6 +49,7 @@ int main (void)
|
||||
srunner_add_suite(sr, make_suite_test_os_calls());
|
||||
srunner_add_suite(sr, make_suite_test_ssl_calls());
|
||||
srunner_add_suite(sr, make_suite_test_base64());
|
||||
srunner_add_suite(sr, make_suite_test_guid());
|
||||
// srunner_add_suite(sr, make_list_suite());
|
||||
|
||||
srunner_set_tap(sr, "-");
|
||||
|
77
tests/common/test_guid.c
Normal file
77
tests/common/test_guid.c
Normal file
@ -0,0 +1,77 @@
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config_ac.h"
|
||||
#endif
|
||||
|
||||
#include "guid.h"
|
||||
#include "ms-rdpbcgr.h"
|
||||
#include "os_calls.h"
|
||||
|
||||
#include "test_common.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
START_TEST(test_guid_to_str_remotefx)
|
||||
{
|
||||
/* setup */
|
||||
char dest[GUID_STR_SIZE];
|
||||
struct guid guid;
|
||||
g_memcpy(guid.g, XR_CODEC_GUID_REMOTEFX, GUID_SIZE);
|
||||
|
||||
/* test */
|
||||
guid_to_str(&guid, dest);
|
||||
|
||||
/* verify */
|
||||
ck_assert_str_eq(dest, "76772F12-BD72-4463-AFB3-B73C9C6F7886");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_guid_to_str_nscodec)
|
||||
{
|
||||
|
||||
/* setup */
|
||||
char dest[GUID_STR_SIZE];
|
||||
struct guid guid;
|
||||
g_memcpy(guid.g, XR_CODEC_GUID_NSCODEC, GUID_SIZE);
|
||||
|
||||
/* test */
|
||||
guid_to_str(&guid, dest);
|
||||
|
||||
/* verify */
|
||||
ck_assert_str_eq(dest, "CA8D1BB9-000F-154F-589F-AE2D1A87E2D6");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_guid_to_str_ignore)
|
||||
{
|
||||
/* setup */
|
||||
char dest[GUID_STR_SIZE];
|
||||
struct guid guid;
|
||||
g_memcpy(guid.g, XR_CODEC_GUID_IGNORE, GUID_SIZE);
|
||||
|
||||
/* test */
|
||||
guid_to_str(&guid, dest);
|
||||
|
||||
/* verify */
|
||||
ck_assert_str_eq(dest, "0C4351A6-3535-42AE-910C-CDFCE5760B58");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
Suite *
|
||||
make_suite_test_guid(void)
|
||||
{
|
||||
Suite *s;
|
||||
TCase *tc_guid;
|
||||
|
||||
s = suite_create("GUID");
|
||||
|
||||
tc_guid = tcase_create("guid_to_str");
|
||||
suite_add_tcase(s, tc_guid);
|
||||
tcase_add_test(tc_guid, test_guid_to_str_remotefx);
|
||||
tcase_add_test(tc_guid, test_guid_to_str_nscodec);
|
||||
tcase_add_test(tc_guid, test_guid_to_str_ignore);
|
||||
|
||||
return s;
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
#endif
|
||||
|
||||
#include "string_calls.h"
|
||||
#include "ms-rdpbcgr.h"
|
||||
|
||||
#include "test_common.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user