Added rail_get_order_type_string_full for better debug logs

This commit is contained in:
akallabeth 2022-06-29 08:58:43 +02:00 committed by akallabeth
parent 40ae6731c9
commit e956a0e155
4 changed files with 23 additions and 11 deletions

View File

@ -37,6 +37,7 @@
*/
UINT rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType)
{
char buffer[128] = { 0 };
UINT16 orderLength;
if (!rail || !s)
@ -47,7 +48,7 @@ UINT rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType)
rail_write_pdu_header(s, orderType, orderLength);
Stream_SetPosition(s, orderLength);
WLog_Print(rail->log, WLOG_DEBUG, "Sending %s PDU, length: %" PRIu16 "",
rail_get_order_type_string(orderType), orderLength);
rail_get_order_type_string_full(orderType, buffer, sizeof(buffer)), orderLength);
return rail_send_channel_data(rail, s);
}
@ -876,6 +877,7 @@ static UINT rail_recv_get_application_id_extended_response_order(railPlugin* rai
*/
UINT rail_order_recv(LPVOID userdata, wStream* s)
{
char buffer[128] = { 0 };
railPlugin* rail = userdata;
UINT16 orderType;
UINT16 orderLength;
@ -891,7 +893,7 @@ UINT rail_order_recv(LPVOID userdata, wStream* s)
}
WLog_Print(rail->log, WLOG_DEBUG, "Received %s PDU, length:%" PRIu16 "",
rail_get_order_type_string(orderType), orderLength);
rail_get_order_type_string_full(orderType, buffer, sizeof(buffer)), orderLength);
switch (orderType)
{
@ -948,14 +950,16 @@ UINT rail_order_recv(LPVOID userdata, wStream* s)
break;
default:
WLog_ERR(TAG, "Unknown RAIL PDU order 0x%08" PRIx32 " received.", orderType);
WLog_ERR(TAG, "Unknown RAIL PDU %s received.",
rail_get_order_type_string_full(orderType, buffer, sizeof(buffer)));
return ERROR_INVALID_DATA;
}
if (error != CHANNEL_RC_OK)
{
char buffer[128] = { 0 };
WLog_Print(rail->log, WLOG_ERROR, "Failed to process rail %s PDU, length:%" PRIu16 "",
rail_get_order_type_string(orderType), orderLength);
rail_get_order_type_string_full(orderType, buffer, sizeof(buffer)), orderLength);
}
Stream_Free(s, TRUE);

View File

@ -29,7 +29,6 @@
const char* rail_get_order_type_string(UINT16 orderType)
{
static char buffer[64] = { 0 };
switch (orderType)
{
case TS_RAIL_ORDER_EXEC:
@ -81,11 +80,17 @@ const char* rail_get_order_type_string(UINT16 orderType)
case TS_RAIL_ORDER_EXEC_RESULT:
return "TS_RAIL_ORDER_EXEC_RESULT";
default:
_snprintf(buffer, sizeof(buffer), "UNKNOWN [0x%08" PRIx32 "]", orderType);
return buffer;
return "TS_RAIL_ORDER_UNKNOWN";
}
}
const char* rail_get_order_type_string_full(UINT16 orderType, char* buffer, size_t length)
{
_snprintf(buffer, length, "%s[0x%04" PRIx16 "]", rail_get_order_type_string(orderType),
orderType);
return buffer;
}
/**
* Function description
*

View File

@ -71,5 +71,6 @@ UINT rail_write_sysparam_order(wStream* s, const RAIL_SYSPARAM_ORDER* sysparam,
BOOL extendedSpiSupported);
BOOL rail_is_extended_spi_supported(UINT32 channelsFlags);
const char* rail_get_order_type_string(UINT16 orderType);
const char* rail_get_order_type_string_full(UINT16 orderType, char* buffer, size_t length);
#endif /* FREERDP_CHANNEL_RAIL_COMMON_H */

View File

@ -62,6 +62,7 @@ static UINT rail_send(RailServerContext* context, wStream* s, ULONG length)
*/
static UINT rail_server_send_pdu(RailServerContext* context, wStream* s, UINT16 orderType)
{
char buffer[128] = { 0 };
UINT16 orderLength;
if (!context || !s)
@ -71,8 +72,8 @@ static UINT rail_server_send_pdu(RailServerContext* context, wStream* s, UINT16
Stream_SetPosition(s, 0);
rail_write_pdu_header(s, orderType, orderLength);
Stream_SetPosition(s, orderLength);
WLog_DBG(TAG, "Sending %s PDU, length: %" PRIu16 "", rail_get_order_type_string(orderType),
orderLength);
WLog_DBG(TAG, "Sending %s PDU, length: %" PRIu16 "",
rail_get_order_type_string_full(orderType, buffer, sizeof(buffer)), orderLength);
return rail_send(context, s, orderLength);
}
@ -1535,6 +1536,7 @@ void rail_server_set_handshake_ex_flags(RailServerContext* context, DWORD flags)
UINT rail_server_handle_messages(RailServerContext* context)
{
char buffer[128] = { 0 };
UINT status = CHANNEL_RC_OK;
DWORD bytesReturned;
UINT16 orderType;
@ -1584,8 +1586,8 @@ UINT rail_server_handle_messages(RailServerContext* context)
return ERROR_INTERNAL_ERROR;
}
WLog_DBG(TAG, "Received %s PDU, length:%" PRIu16 "", rail_get_order_type_string(orderType),
orderLength);
WLog_DBG(TAG, "Received %s PDU, length:%" PRIu16 "",
rail_get_order_type_string_full(orderType, buffer, sizeof(buffer)), orderLength);
switch (orderType)
{