commit
a211ca3c1a
@ -67,6 +67,7 @@
|
||||
|
||||
freerdp_sem g_sem;
|
||||
static int g_thread_count = 0;
|
||||
static uint8 g_disconnect_reason = 0;
|
||||
|
||||
static long xv_port = 0;
|
||||
const size_t password_size = 512;
|
||||
@ -424,7 +425,7 @@ boolean xf_pre_connect(freerdp* instance)
|
||||
xf_process_plugin_args, instance->context->channels, xf_process_client_args, xfi) < 0)
|
||||
{
|
||||
printf("failed to parse arguments.\n");
|
||||
exit(0);
|
||||
exit(XF_EXIT_PARSE_ARGUMENTS);
|
||||
}
|
||||
|
||||
settings = instance->settings;
|
||||
@ -866,12 +867,13 @@ int xfreerdp_run(freerdp* instance)
|
||||
fd_set rfds_set;
|
||||
fd_set wfds_set;
|
||||
rdpChannels* channels;
|
||||
int ret = 0;
|
||||
|
||||
memset(rfds, 0, sizeof(rfds));
|
||||
memset(wfds, 0, sizeof(wfds));
|
||||
|
||||
if (!freerdp_connect(instance))
|
||||
return 0;
|
||||
return XF_EXIT_CONN_FAILED;
|
||||
|
||||
xfi = ((xfContext*) instance->context)->xfi;
|
||||
channels = instance->context->channels;
|
||||
@ -884,16 +886,19 @@ int xfreerdp_run(freerdp* instance)
|
||||
if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != True)
|
||||
{
|
||||
printf("Failed to get FreeRDP file descriptor\n");
|
||||
ret = XF_EXIT_CONN_FAILED;
|
||||
break;
|
||||
}
|
||||
if (freerdp_channels_get_fds(channels, instance, rfds, &rcount, wfds, &wcount) != True)
|
||||
{
|
||||
printf("Failed to get channel manager file descriptor\n");
|
||||
ret = XF_EXIT_CONN_FAILED;
|
||||
break;
|
||||
}
|
||||
if (xf_get_fds(instance, rfds, &rcount, wfds, &wcount) != True)
|
||||
{
|
||||
printf("Failed to get xfreerdp file descriptor\n");
|
||||
ret = XF_EXIT_CONN_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -945,6 +950,9 @@ int xfreerdp_run(freerdp* instance)
|
||||
xf_process_channel_event(channels, instance);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
ret = freerdp_error_info(instance);
|
||||
|
||||
freerdp_channels_close(channels, instance);
|
||||
freerdp_channels_free(channels);
|
||||
freerdp_disconnect(instance);
|
||||
@ -952,7 +960,7 @@ int xfreerdp_run(freerdp* instance)
|
||||
freerdp_free(instance);
|
||||
xf_free(xfi);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void* thread_func(void* param)
|
||||
@ -960,7 +968,7 @@ void* thread_func(void* param)
|
||||
struct thread_data* data;
|
||||
data = (struct thread_data*) param;
|
||||
|
||||
xfreerdp_run(data->instance);
|
||||
g_disconnect_reason = xfreerdp_run(data->instance);
|
||||
|
||||
xfree(data);
|
||||
|
||||
@ -974,6 +982,27 @@ void* thread_func(void* param)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uint8 exit_code_from_disconnect_reason(uint32 reason)
|
||||
{
|
||||
if (reason == 0 ||
|
||||
(reason >= XF_EXIT_PARSE_ARGUMENTS && reason <= XF_EXIT_CONN_FAILED))
|
||||
return reason;
|
||||
|
||||
/* Licence error set */
|
||||
else if (reason >= 0x100 && reason <= 0x10A)
|
||||
reason -= 0x100 + XF_EXIT_LICENSE_INTERNAL;
|
||||
|
||||
/* RDP protocol error set */
|
||||
else if (reason >= 0x10c9 && reason <= 0x1193)
|
||||
reason = XF_EXIT_RDP;
|
||||
|
||||
/* There's no need to test protocol-independent codes: they match */
|
||||
else if (!(reason <= 0xB))
|
||||
reason = XF_EXIT_UNKNOWN;
|
||||
|
||||
return reason;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
pthread_t thread;
|
||||
@ -1022,5 +1051,5 @@ int main(int argc, char* argv[])
|
||||
|
||||
freerdp_channels_global_uninit();
|
||||
|
||||
return 0;
|
||||
return exit_code_from_disconnect_reason(g_disconnect_reason);
|
||||
}
|
||||
|
@ -147,6 +147,47 @@ struct xf_info
|
||||
void xf_toggle_fullscreen(xfInfo* xfi);
|
||||
boolean xf_post_connect(freerdp* instance);
|
||||
|
||||
enum XF_EXIT_CODE
|
||||
{
|
||||
/* section 0-15: protocol-independent codes */
|
||||
XF_EXIT_SUCCESS = 0,
|
||||
XF_EXIT_DISCONNECT = 1,
|
||||
XF_EXIT_LOGOFF = 2,
|
||||
XF_EXIT_IDLE_TIMEOUT = 3,
|
||||
XF_EXIT_LOGON_TIMEOUT = 4,
|
||||
XF_EXIT_CONN_REPLACED = 5,
|
||||
XF_EXIT_OUT_OF_MEMORY = 6,
|
||||
XF_EXIT_CONN_DENIED = 7,
|
||||
XF_EXIT_CONN_DENIED_FIPS = 8,
|
||||
XF_EXIT_USER_PRIVILEGES = 9,
|
||||
XF_EXIT_FRESH_CREDENTIALS_REQUIRED = 10,
|
||||
XF_EXIT_DISCONNECT_BY_USER = 11,
|
||||
|
||||
/* section 16-31: license error set */
|
||||
XF_EXIT_LICENSE_INTERNAL = 16,
|
||||
XF_EXIT_LICENSE_NO_LICENSE_SERVER = 17,
|
||||
XF_EXIT_LICENSE_NO_LICENSE = 18,
|
||||
XF_EXIT_LICENSE_BAD_CLIENT_MSG = 19,
|
||||
XF_EXIT_LICENSE_HWID_DOESNT_MATCH = 20,
|
||||
XF_EXIT_LICENSE_BAD_CLIENT = 21,
|
||||
XF_EXIT_LICENSE_CANT_FINISH_PROTOCOL = 22,
|
||||
XF_EXIT_LICENSE_CLIENT_ENDED_PROTOCOL = 23,
|
||||
XF_EXIT_LICENSE_BAD_CLIENT_ENCRYPTION = 24,
|
||||
XF_EXIT_LICENSE_CANT_UPGRADE = 25,
|
||||
XF_EXIT_LICENSE_NO_REMOTE_CONNECTIONS = 26,
|
||||
|
||||
/* section 32-127: RDP protocol error set */
|
||||
XF_EXIT_RDP = 32,
|
||||
|
||||
/* section 128-254: xfreerdp specific exit codes */
|
||||
XF_EXIT_PARSE_ARGUMENTS = 128,
|
||||
XF_EXIT_MEMORY = 129,
|
||||
XF_EXIT_PROTOCOL = 130,
|
||||
XF_EXIT_CONN_FAILED = 131,
|
||||
|
||||
XF_EXIT_UNKNOWN = 255,
|
||||
};
|
||||
|
||||
#ifdef WITH_DEBUG_X11
|
||||
#define DEBUG_X11(fmt, ...) DEBUG_CLASS(X11, fmt, ## __VA_ARGS__)
|
||||
#else
|
||||
|
@ -100,6 +100,8 @@ FREERDP_API boolean freerdp_disconnect(freerdp* instance);
|
||||
FREERDP_API boolean freerdp_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount);
|
||||
FREERDP_API boolean freerdp_check_fds(freerdp* instance);
|
||||
|
||||
FREERDP_API uint32 freerdp_error_info(freerdp* instance);
|
||||
|
||||
FREERDP_API freerdp* freerdp_new();
|
||||
FREERDP_API void freerdp_free(freerdp* instance);
|
||||
|
||||
|
@ -151,6 +151,11 @@ void freerdp_context_free(freerdp* instance)
|
||||
IFCALL(instance->ContextFree, instance, instance->context);
|
||||
}
|
||||
|
||||
uint32 freerdp_error_info(freerdp* instance)
|
||||
{
|
||||
return instance->context->rdp->errorInfo;
|
||||
}
|
||||
|
||||
freerdp* freerdp_new()
|
||||
{
|
||||
freerdp* instance;
|
||||
|
@ -425,14 +425,12 @@ boolean rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint8 type, uint16 channel_id)
|
||||
return True;
|
||||
}
|
||||
|
||||
void rdp_recv_set_error_info_data_pdu(STREAM* s)
|
||||
void rdp_recv_set_error_info_data_pdu(rdpRdp* rdp, STREAM* s)
|
||||
{
|
||||
uint32 errorInfo;
|
||||
stream_read_uint32(s, rdp->errorInfo); /* errorInfo (4 bytes) */
|
||||
|
||||
stream_read_uint32(s, errorInfo); /* errorInfo (4 bytes) */
|
||||
|
||||
if (errorInfo != ERRINFO_SUCCESS)
|
||||
rdp_print_errinfo(errorInfo);
|
||||
if (rdp->errorInfo != ERRINFO_SUCCESS)
|
||||
rdp_print_errinfo(rdp->errorInfo);
|
||||
}
|
||||
|
||||
void rdp_recv_data_pdu(rdpRdp* rdp, STREAM* s)
|
||||
@ -514,7 +512,7 @@ void rdp_recv_data_pdu(rdpRdp* rdp, STREAM* s)
|
||||
break;
|
||||
|
||||
case DATA_PDU_TYPE_SET_ERROR_INFO:
|
||||
rdp_recv_set_error_info_data_pdu(s);
|
||||
rdp_recv_set_error_info_data_pdu(rdp, s);
|
||||
break;
|
||||
|
||||
case DATA_PDU_TYPE_DRAW_NINEGRID_ERROR:
|
||||
|
@ -144,6 +144,7 @@ struct rdp_rdp
|
||||
uint8 fips_sign_key[20];
|
||||
uint8 fips_encrypt_key[24];
|
||||
uint8 fips_decrypt_key[24];
|
||||
uint32 errorInfo;
|
||||
};
|
||||
|
||||
void rdp_read_security_header(STREAM* s, uint16* flags);
|
||||
|
Loading…
Reference in New Issue
Block a user