From bba342a6be1b827bb88967ebc8a289bf080378f0 Mon Sep 17 00:00:00 2001 From: Martin Haimberger Date: Tue, 13 Jan 2015 08:09:36 -0800 Subject: [PATCH] added set_error_info function if an error_info is set, a TS_SET_ERROR_INFO_PDU will be sent to the client on disconnect with the error_info --- include/freerdp/freerdp.h | 3 +++ libfreerdp/core/freerdp.c | 7 ++++++- libfreerdp/core/gcc.c | 3 +++ libfreerdp/core/peer.c | 5 +++++ libfreerdp/core/rdp.c | 18 ++++++++++++++++++ libfreerdp/core/rdp.h | 2 ++ 6 files changed, 37 insertions(+), 1 deletion(-) diff --git a/include/freerdp/freerdp.h b/include/freerdp/freerdp.h index fef980b17..85b97121b 100644 --- a/include/freerdp/freerdp.h +++ b/include/freerdp/freerdp.h @@ -3,6 +3,8 @@ * FreeRDP Interface * * Copyright 2009-2011 Jay Sorg + * Copyright 2014 DI (FH) Martin Haimberger + * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -252,6 +254,7 @@ FREERDP_API int freerdp_message_queue_process_message(freerdp* instance, DWORD i FREERDP_API int freerdp_message_queue_process_pending_messages(freerdp* instance, DWORD id); FREERDP_API UINT32 freerdp_error_info(freerdp* instance); +FREERDP_API void freerdp_set_error_info(rdpRdp* rdp, UINT32 error); FREERDP_API void freerdp_get_version(int* major, int* minor, int* revision); diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index a08702456..e5a2eb5d9 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -1,8 +1,9 @@ -/* +/** * FreeRDP: A Remote Desktop Protocol Implementation * FreeRDP Core * * Copyright 2011 Marc-Andre Moreau + * Copyright 2014 DI (FH) Martin Haimberger * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -491,6 +492,10 @@ UINT32 freerdp_error_info(freerdp* instance) return instance->context->rdp->errorInfo; } +void freerdp_set_error_info(rdpRdp* rdp, UINT32 error) { + rdp->errorInfo = error; +} + UINT32 freerdp_get_last_error(rdpContext* context) { return context->LastError; diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index cff7de49f..74b6a28e1 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -4,6 +4,7 @@ * * Copyright 2011 Marc-Andre Moreau * Copyright 2014 Norbert Federa + * Copyright 2014 DI (FH) Martin Haimberger * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -766,6 +767,8 @@ BOOL gcc_read_client_core_data(wStream* s, rdpMcs* mcs, UINT16 blockLength) if (!(earlyCapabilityFlags & RNS_UD_CS_VALID_CONNECTION_TYPE)) connectionType = 0; + settings->SupportErrorInfoPdu = earlyCapabilityFlags & RNS_UD_CS_SUPPORT_ERRINFO_PDU; + settings->ConnectionType = connectionType; return TRUE; diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index 652e0ef86..453a4679b 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -3,6 +3,7 @@ * RDP Server Peer * * Copyright 2011 Vic Lee + * Copyright 2014 DI (FH) Martin Haimberger * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -574,6 +575,10 @@ static BOOL freerdp_peer_close(freerdp_peer* client) if (!rdp_send_deactivate_all(client->context->rdp)) return FALSE; + if (freerdp_get_param_bool(client->settings, FreeRDP_SupportErrorInfoPdu) ) { + rdp_send_error_info(client->context->rdp); + } + return mcs_send_disconnect_provider_ultimatum(client->context->rdp->mcs); } diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 77a650502..b4471684a 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -3,6 +3,7 @@ * RDP Core * * Copyright 2011 Marc-Andre Moreau + * Copyright 2014 DI (FH) Martin Haimberger * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1235,6 +1236,23 @@ int rdp_send_channel_data(rdpRdp* rdp, UINT16 channelId, BYTE* data, int size) return freerdp_channel_send(rdp, channelId, data, size); } +BOOL rdp_send_error_info(rdpRdp* rdp) +{ + wStream* s; + BOOL status; + + if (rdp->errorInfo == ERRINFO_SUCCESS) + return TRUE; + + s = rdp_data_pdu_init(rdp); + + Stream_Write_UINT32(s, rdp->errorInfo); /* error id (4 bytes) */ + + status = rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SET_ERROR_INFO, 0); + + return status; +} + /** * Set non-blocking mode information. * @param rdp RDP module diff --git a/libfreerdp/core/rdp.h b/libfreerdp/core/rdp.h index 4b6a84781..fb8531b01 100644 --- a/libfreerdp/core/rdp.h +++ b/libfreerdp/core/rdp.h @@ -3,6 +3,7 @@ * RDP Core * * Copyright 2011 Marc-Andre Moreau + * Copyright 2014 DI (FH) Martin Haimberger * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -229,5 +230,6 @@ void rdp_free(rdpRdp* rdp); BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags); BOOL rdp_set_error_info(rdpRdp* rdp, UINT32 errorInfo); +BOOL rdp_send_error_info(rdpRdp* rdp); #endif /* __RDP_H */