From 0bba16602066c0dc04651762d00d1a8ba3e02861 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 26 Feb 2019 15:29:30 +0100 Subject: [PATCH] Force close channel, use defines instead of magic numbers * When senging a close request for a dynamic channel close the channel immediately. A response from the server is not guaranteed. * Use the *_PDU defines instead of magic numbers when creating dynamic channel messages. --- channels/drdynvc/client/drdynvc_main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index b8520da6c..31e0e0351 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -768,14 +768,17 @@ static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, if (dataSize == 0) { Stream_SetPosition(data_out, 0); - Stream_Write_UINT8(data_out, 0x40 | cbChId); + Stream_Write_UINT8(data_out, (CLOSE_REQUEST_PDU << 4) | cbChId); Stream_SetPosition(data_out, pos); status = drdynvc_send(drdynvc, data_out); + /* Remove the channel from the active client channel list. + * The server MAY send a response, but that is not guaranteed. */ + dvcman_close_channel(drdynvc->channel_mgr, ChannelId); } else if (dataSize <= CHANNEL_CHUNK_LENGTH - pos) { Stream_SetPosition(data_out, 0); - Stream_Write_UINT8(data_out, 0x30 | cbChId); + Stream_Write_UINT8(data_out, (DATA_PDU << 4) | cbChId); Stream_SetPosition(data_out, pos); Stream_Write(data_out, data, dataSize); status = drdynvc_send(drdynvc, data_out); @@ -786,7 +789,7 @@ static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, cbLen = drdynvc_write_variable_uint(data_out, dataSize); pos = Stream_GetPosition(data_out); Stream_SetPosition(data_out, 0); - Stream_Write_UINT8(data_out, (UINT8)(0x20 | cbChId | (cbLen << 2))); + Stream_Write_UINT8(data_out, (DATA_FIRST_PDU << 4) | cbChId | (cbLen << 2)); Stream_SetPosition(data_out, pos); chunkLength = CHANNEL_CHUNK_LENGTH - pos; Stream_Write(data_out, data, chunkLength); @@ -808,7 +811,7 @@ static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, cbChId = drdynvc_write_variable_uint(data_out, ChannelId); pos = Stream_GetPosition(data_out); Stream_SetPosition(data_out, 0); - Stream_Write_UINT8(data_out, 0x30 | cbChId); + Stream_Write_UINT8(data_out, (DATA_PDU << 4) | cbChId); Stream_SetPosition(data_out, pos); chunkLength = dataSize; @@ -1004,7 +1007,7 @@ static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, return CHANNEL_RC_NO_MEMORY; } - Stream_Write_UINT8(data_out, (UINT8)(0x10 | cbChId)); + Stream_Write_UINT8(data_out, (CREATE_REQUEST_PDU << 4) | cbChId); Stream_SetPosition(s, 1); Stream_Copy(s, data_out, pos - 1);