typedef BOOL (*psPeerInitialize)(freerdp_peer* peer);
typedef BOOL (*psPeerGetFileDescriptor)(freerdp_peer* peer, void** rfds, int* rcount);
-typedef HANDLE (*psPeerGetEventHandle)(freerdp_peer* peer);
-typedef HANDLE (*psPeerGetReceiveEventHandle)(freerdp_peer* peer);
+typedef HANDLE(*psPeerGetEventHandle)(freerdp_peer* peer);
+typedef HANDLE(*psPeerGetReceiveEventHandle)(freerdp_peer* peer);
typedef BOOL (*psPeerCheckFileDescriptor)(freerdp_peer* peer);
typedef BOOL (*psPeerIsWriteBlocked)(freerdp_peer* peer);
typedef int (*psPeerDrainOutputBuffer)(freerdp_peer* peer);
typedef BOOL (*psPeerLogon)(freerdp_peer* peer, SEC_WINNT_AUTH_IDENTITY* identity, BOOL automatic);
typedef int (*psPeerSendChannelData)(freerdp_peer* peer, UINT16 channelId, BYTE* data, int size);
-typedef int (*psPeerReceiveChannelData)(freerdp_peer* peer, UINT16 channelId, BYTE* data, int size, int flags, int totalSize);
+typedef int (*psPeerReceiveChannelData)(freerdp_peer* peer, UINT16 channelId, BYTE* data, int size,
+ int flags, int totalSize);
-typedef HANDLE (*psPeerVirtualChannelOpen)(freerdp_peer* peer, const char* name, UINT32 flags);
+typedef HANDLE(*psPeerVirtualChannelOpen)(freerdp_peer* peer, const char* name, UINT32 flags);
typedef BOOL (*psPeerVirtualChannelClose)(freerdp_peer* peer, HANDLE hChannel);
-typedef int (*psPeerVirtualChannelRead)(freerdp_peer* peer, HANDLE hChannel, BYTE* buffer, UINT32 length);
-typedef int (*psPeerVirtualChannelWrite)(freerdp_peer* peer, HANDLE hChannel, BYTE* buffer, UINT32 length);
+typedef int (*psPeerVirtualChannelRead)(freerdp_peer* peer, HANDLE hChannel, BYTE* buffer,
+ UINT32 length);
+typedef int (*psPeerVirtualChannelWrite)(freerdp_peer* peer, HANDLE hChannel, BYTE* buffer,
+ UINT32 length);
typedef void* (*psPeerVirtualChannelGetData)(freerdp_peer* peer, HANDLE hChannel);
typedef int (*psPeerVirtualChannelSetData)(freerdp_peer* peer, HANDLE hChannel, void* data);
ALIGN64 rdpRsaKey* RdpServerRsaKey; /* 1413 */
ALIGN64 rdpCertificate* RdpServerCertificate; /* 1414 */
ALIGN64 BOOL ExternalCertificateManagement; /* 1415 */
- ALIGN64 char *CertificateContent; /* 1416 */
- ALIGN64 char *PrivateKeyContent; /* 1417 */
+ ALIGN64 char* CertificateContent; /* 1416 */
+ ALIGN64 char* PrivateKeyContent; /* 1417 */
ALIGN64 char* RdpKeyContent; /* 1418 */
ALIGN64 BOOL AutoAcceptCertificate; /* 1419 */
UINT64 padding1472[1472 - 1420]; /* 1420 */
ALIGN64 int num_extensions; /* */
ALIGN64 struct rdp_ext_set extensions[16]; /* */
- ALIGN64 BYTE* SettingsModified; /* byte array marking fields that have been modified from their default value */
+ ALIGN64 BYTE*
+ SettingsModified; /* byte array marking fields that have been modified from their default value */
};
typedef struct rdp_settings rdpSettings;
FREERDP_API int freerdp_addin_set_argument(ADDIN_ARGV* args, char* argument);
FREERDP_API int freerdp_addin_replace_argument(ADDIN_ARGV* args, char* previous, char* argument);
FREERDP_API int freerdp_addin_set_argument_value(ADDIN_ARGV* args, char* option, char* value);
-FREERDP_API int freerdp_addin_replace_argument_value(ADDIN_ARGV* args, char* previous, char* option, char* value);
+FREERDP_API int freerdp_addin_replace_argument_value(ADDIN_ARGV* args, char* previous, char* option,
+ char* value);
FREERDP_API BOOL freerdp_device_collection_add(rdpSettings* settings, RDPDR_DEVICE* device);
FREERDP_API RDPDR_DEVICE* freerdp_device_collection_find(rdpSettings* settings, const char* name);
FREERDP_API void freerdp_device_collection_free(rdpSettings* settings);
FREERDP_API BOOL freerdp_static_channel_collection_add(rdpSettings* settings, ADDIN_ARGV* channel);
-FREERDP_API ADDIN_ARGV* freerdp_static_channel_collection_find(rdpSettings* settings, const char* name);
+FREERDP_API ADDIN_ARGV* freerdp_static_channel_collection_find(rdpSettings* settings,
+ const char* name);
FREERDP_API ADDIN_ARGV* freerdp_static_channel_clone(ADDIN_ARGV* channel);
FREERDP_API void freerdp_static_channel_collection_free(rdpSettings* settings);
FREERDP_API BOOL freerdp_dynamic_channel_collection_add(rdpSettings* settings, ADDIN_ARGV* channel);
-FREERDP_API ADDIN_ARGV* freerdp_dynamic_channel_collection_find(rdpSettings* settings, const char* name);
+FREERDP_API ADDIN_ARGV* freerdp_dynamic_channel_collection_find(rdpSettings* settings,
+ const char* name);
FREERDP_API ADDIN_ARGV* freerdp_dynamic_channel_clone(ADDIN_ARGV* channel);
FREERDP_API void freerdp_dynamic_channel_collection_free(rdpSettings* settings);
FREERDP_API void freerdp_performance_flags_split(rdpSettings* settings);
FREERDP_API void freerdp_set_gateway_usage_method(rdpSettings* settings, UINT32 GatewayUsageMethod);
-FREERDP_API void freerdp_update_gateway_usage_method(rdpSettings* settings, UINT32 GatewayEnabled, UINT32 GatewayBypassLocal);
+FREERDP_API void freerdp_update_gateway_usage_method(rdpSettings* settings, UINT32 GatewayEnabled,
+ UINT32 GatewayBypassLocal);
FREERDP_API BOOL freerdp_get_param_bool(rdpSettings* settings, int id);
FREERDP_API int freerdp_set_param_bool(rdpSettings* settings, int id, BOOL param);
extern const char* DATA_PDU_TYPE_STRINGS[80];
#endif
-static HANDLE freerdp_peer_virtual_channel_open(freerdp_peer* client, const char* name, UINT32 flags)
+static HANDLE freerdp_peer_virtual_channel_open(freerdp_peer* client, const char* name,
+ UINT32 flags)
{
int length;
UINT32 index;
peerChannel = (rdpPeerChannel*) hChannel;
mcsChannel = peerChannel->mcsChannel;
-
mcsChannel->handle = NULL;
free(peerChannel);
-
return TRUE;
}
-int freerdp_peer_virtual_channel_read(freerdp_peer* client, HANDLE hChannel, BYTE* buffer, UINT32 length)
+int freerdp_peer_virtual_channel_read(freerdp_peer* client, HANDLE hChannel, BYTE* buffer,
+ UINT32 length)
{
return 0; /* this needs to be implemented by the server application */
}
-static int freerdp_peer_virtual_channel_write(freerdp_peer* client, HANDLE hChannel, BYTE* buffer, UINT32 length)
+static int freerdp_peer_virtual_channel_write(freerdp_peer* client, HANDLE hChannel, BYTE* buffer,
+ UINT32 length)
{
wStream* s;
UINT32 flags;
return -1; /* not yet supported */
maxChunkSize = rdp->settings->VirtualChannelChunkSize;
-
totalLength = length;
flags = CHANNEL_FLAG_FIRST;
while (length > 0)
{
s = rdp_send_stream_init(rdp);
+
if (!s)
return -1;
Stream_Write_UINT32(s, totalLength);
Stream_Write_UINT32(s, flags);
+
if (!Stream_EnsureRemainingCapacity(s, chunkSize))
{
Stream_Release(s);
return -1;
}
+
Stream_Write(s, buffer, chunkSize);
if (!rdp_send(rdp, s, peerChannel->channelId))
return -1;
peerChannel->extra = data;
-
return 1;
}
{
rdpRdp* rdp = client->context->rdp;
rdpSettings* settings = rdp->settings;
-
settings->ServerMode = TRUE;
settings->FrameAcknowledge = 0;
settings->LocalConnection = client->local;
if (settings->RdpKeyFile)
{
settings->RdpServerRsaKey = key_new(settings->RdpKeyFile);
+
if (!settings->RdpServerRsaKey)
{
WLog_ERR(TAG, "invalid RDP key file %s", settings->RdpKeyFile);
else if (settings->RdpKeyContent)
{
settings->RdpServerRsaKey = key_new_from_content(settings->RdpKeyContent, NULL);
+
if (!settings->RdpServerRsaKey)
{
WLog_ERR(TAG, "invalid RDP key content");
static BOOL freerdp_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount)
{
rdpTransport* transport = client->context->rdp->transport;
-
rfds[*rcount] = (void*)(long)(BIO_get_fd(transport->frontBio, NULL));
(*rcount)++;
-
return TRUE;
}
{
HANDLE hEvent = NULL;
rdpTransport* transport = client->context->rdp->transport;
-
BIO_get_event(transport->frontBio, &hEvent);
-
return hEvent;
}
{
int status;
rdpRdp* rdp;
-
rdp = peer->context->rdp;
-
status = rdp_check_fds(rdp);
if (status < 0)
#ifdef WITH_DEBUG_RDP
WLog_DBG(TAG, "recv %s Data PDU (0x%02X), length: %d",
- type < ARRAYSIZE(DATA_PDU_TYPE_STRINGS) ? DATA_PDU_TYPE_STRINGS[type] : "???", type, length);
+ type < ARRAYSIZE(DATA_PDU_TYPE_STRINGS) ? DATA_PDU_TYPE_STRINGS[type] : "???", type, length);
#endif
switch (type)
case DATA_PDU_TYPE_SYNCHRONIZE:
if (!rdp_recv_client_synchronize_pdu(client->context->rdp, s))
return FALSE;
+
break;
case DATA_PDU_TYPE_CONTROL:
if (!rdp_server_accept_client_control_pdu(client->context->rdp, s))
return FALSE;
+
break;
case DATA_PDU_TYPE_INPUT:
if (!input_recv(client->context->rdp->input, s))
return FALSE;
+
break;
case DATA_PDU_TYPE_BITMAP_CACHE_PERSISTENT_LIST:
break;
case DATA_PDU_TYPE_FONT_LIST:
-
if (!rdp_server_accept_client_font_list_pdu(client->context->rdp, s))
return FALSE;
case DATA_PDU_TYPE_FRAME_ACKNOWLEDGE:
if (Stream_GetRemainingLength(s) < 4)
return FALSE;
+
Stream_Read_UINT32(s, client->ack_frame_id);
IFCALL(client->update->SurfaceFrameAcknowledge, client->update->context, client->ack_frame_id);
break;
case DATA_PDU_TYPE_REFRESH_RECT:
if (!update_read_refresh_rect(client->update, s))
return FALSE;
+
break;
case DATA_PDU_TYPE_SUPPRESS_OUTPUT:
if (!update_read_suppress_output(client->update, s))
return FALSE;
+
break;
default:
UINT16 pduSource;
UINT16 channelId;
UINT16 securityFlags;
-
rdp = client->context->rdp;
if (!rdp_read_header(rdp, s, &length, &channelId))
if (freerdp_shall_disconnect(rdp->instance))
return 0;
-
+
if (rdp->settings->UseRdpSecurityLayer)
{
if (!rdp_read_security_header(s, &securityFlags))
case PDU_TYPE_DATA:
if (!peer_recv_data_pdu(client, s))
return -1;
+
break;
case PDU_TYPE_CONFIRM_ACTIVE:
if (!rdp_server_accept_confirm_active(rdp, s))
return -1;
+
break;
case PDU_TYPE_FLOW_RESPONSE:
rdpRdp* rdp;
UINT16 length;
rdpFastPath* fastpath;
-
rdp = client->context->rdp;
fastpath = rdp->fastpath;
-
fastpath_read_header_rdp(fastpath, s, &length);
if ((length == 0) || (length > Stream_GetRemainingLength(s)))
if (fastpath->encryptionFlags & FASTPATH_OUTPUT_ENCRYPTED)
{
- if (!rdp_decrypt(rdp, s, length, (fastpath->encryptionFlags & FASTPATH_OUTPUT_SECURE_CHECKSUM) ? SEC_SECURE_CHECKSUM : 0))
+ if (!rdp_decrypt(rdp, s, length,
+ (fastpath->encryptionFlags & FASTPATH_OUTPUT_SECURE_CHECKSUM) ? SEC_SECURE_CHECKSUM : 0))
return -1;
}
case CONNECTION_STATE_NEGO:
if (!rdp_server_accept_mcs_connect_initial(rdp, s))
{
- WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_NEGO - rdp_server_accept_mcs_connect_initial() fail");
+ WLog_ERR(TAG,
+ "peer_recv_callback: CONNECTION_STATE_NEGO - rdp_server_accept_mcs_connect_initial() fail");
return -1;
}
+
break;
case CONNECTION_STATE_MCS_CONNECT:
if (!rdp_server_accept_mcs_erect_domain_request(rdp, s))
{
- WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_MCS_CONNECT - rdp_server_accept_mcs_erect_domain_request() fail");
+ WLog_ERR(TAG,
+ "peer_recv_callback: CONNECTION_STATE_MCS_CONNECT - rdp_server_accept_mcs_erect_domain_request() fail");
return -1;
}
+
break;
case CONNECTION_STATE_MCS_ERECT_DOMAIN:
if (!rdp_server_accept_mcs_attach_user_request(rdp, s))
{
- WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_MCS_ERECT_DOMAIN - rdp_server_accept_mcs_attach_user_request() fail");
+ WLog_ERR(TAG,
+ "peer_recv_callback: CONNECTION_STATE_MCS_ERECT_DOMAIN - rdp_server_accept_mcs_attach_user_request() fail");
return -1;
}
+
break;
case CONNECTION_STATE_MCS_ATTACH_USER:
if (!rdp_server_accept_mcs_channel_join_request(rdp, s))
{
- WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_MCS_ATTACH_USER - rdp_server_accept_mcs_channel_join_request() fail");
+ WLog_ERR(TAG,
+ "peer_recv_callback: CONNECTION_STATE_MCS_ATTACH_USER - rdp_server_accept_mcs_channel_join_request() fail");
return -1;
}
+
break;
case CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT:
{
if (!rdp_server_establish_keys(rdp, s))
{
- WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT - rdp_server_establish_keys() fail");
+ WLog_ERR(TAG,
+ "peer_recv_callback: CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT - rdp_server_establish_keys() fail");
return -1;
}
}
rdp_server_transition_to_state(rdp, CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE);
+
if (Stream_GetRemainingLength(s) > 0)
return peer_recv_callback(transport, s, extra);
+
break;
case CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE:
if (!rdp_recv_client_info(rdp, s))
{
- WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE - rdp_recv_client_info() fail");
+ WLog_ERR(TAG,
+ "peer_recv_callback: CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE - rdp_recv_client_info() fail");
return -1;
}
rdp_server_transition_to_state(rdp, CONNECTION_STATE_LICENSING);
return peer_recv_callback(transport, NULL, extra);
-
break;
case CONNECTION_STATE_LICENSING:
if (!license_send_valid_client_error_packet(rdp->license))
{
- WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_LICENSING - license_send_valid_client_error_packet() fail");
+ WLog_ERR(TAG,
+ "peer_recv_callback: CONNECTION_STATE_LICENSING - license_send_valid_client_error_packet() fail");
return FALSE;
}
rdp_server_transition_to_state(rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE);
return peer_recv_callback(transport, NULL, extra);
-
break;
case CONNECTION_STATE_CAPABILITIES_EXCHANGE:
-
if (!rdp->AwaitCapabilities)
{
IFCALL(client->Capabilities, client);
if (!rdp_send_demand_active(rdp))
{
- WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_CAPABILITIES_EXCHANGE - rdp_send_demand_active() fail");
+ WLog_ERR(TAG,
+ "peer_recv_callback: CONNECTION_STATE_CAPABILITIES_EXCHANGE - rdp_send_demand_active() fail");
return -1;
}
* During reactivation sequence the client might sent some input or channel data
* before receiving the Deactivate All PDU. We need to process them as usual.
*/
-
if (peer_recv_pdu(client, s) < 0)
{
WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_CAPABILITIES_EXCHANGE - peer_recv_pdu() fail");
WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_FINALIZATION - peer_recv_pdu() fail");
return -1;
}
+
break;
case CONNECTION_STATE_ACTIVE:
WLog_ERR(TAG, "peer_recv_callback: CONNECTION_STATE_ACTIVE - peer_recv_pdu() fail");
return -1;
}
+
break;
default:
if (!rdp_send_deactivate_all(client->context->rdp))
return FALSE;
- if (freerdp_get_param_bool(client->settings, FreeRDP_SupportErrorInfoPdu) ) {
+ if (freerdp_get_param_bool(client->settings, FreeRDP_SupportErrorInfoPdu))
+ {
rdp_send_error_info(client->context->rdp);
}
transport_disconnect(transport);
}
-static int freerdp_peer_send_channel_data(freerdp_peer* client, UINT16 channelId, BYTE* data, int size)
+static int freerdp_peer_send_channel_data(freerdp_peer* client, UINT16 channelId, BYTE* data,
+ int size)
{
return rdp_send_channel_data(client->context->rdp, channelId, data, size);
}
return transport_drain_output_buffer(transport);
}
-static BOOL freerdp_peer_has_more_to_read(freerdp_peer* peer) {
+static BOOL freerdp_peer_has_more_to_read(freerdp_peer* peer)
+{
return peer->context->rdp->transport->haveMoreBytesToRead;
}
goto fail_context;
client->context = context;
-
context->peer = client;
context->ServerMode = TRUE;
context->settings = client->settings;
client->update = rdp->update;
client->settings = rdp->settings;
client->autodetect = rdp->autodetect;
-
context->rdp = rdp;
context->input = client->input;
context->update = client->update;
context->settings = client->settings;
context->autodetect = client->autodetect;
-
client->update->context = context;
client->input->context = context;
client->autodetect->context = context;
-
update_register_server_callbacks(client->update);
autodetect_register_server_callbacks(client->autodetect);
rdp->transport->ReceiveCallback = peer_recv_callback;
rdp->transport->ReceiveExtra = client;
transport_set_blocking_mode(rdp->transport, FALSE);
-
client->IsWriteBlocked = freerdp_peer_is_write_blocked;
client->DrainOutputBuffer = freerdp_peer_drain_output_buffer;
client->HasMoreToRead = freerdp_peer_has_more_to_read;
-
IFCALLRET(client->ContextNew, ret, client, client->context);
if (ret)
return TRUE;
WLog_ERR(TAG, "ContextNew callback failed");
-
fail_transport_attach:
free(context->errorDescription);
fail_error_description:
free(client->context);
fail_context:
client->context = NULL;
-
WLog_ERR(TAG, "Failed to create new peer context");
return FALSE;
}
{
free(client->context->errorDescription);
client->context->errorDescription = NULL;
-
rdp_free(client->context->rdp);
client->context->rdp = NULL;
-
metrics_free(client->context->metrics);
client->context->metrics = NULL;
-
free(client->context);
client->context = NULL;
}
UINT32 option_value;
socklen_t option_len;
freerdp_peer* client;
-
client = (freerdp_peer*) calloc(1, sizeof(freerdp_peer));
if (!client)
option_value = TRUE;
option_len = sizeof(option_value);
-
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (void*) &option_value, option_len);
if (client)
static int runInstance(int argc, char* argv[], freerdp** inst)
{
int rc = -1;
-
freerdp* instance = freerdp_new();
+
if (!instance)
goto finish;
}
rc = 1;
+
if (!freerdp_connect(instance))
goto finish;
rc = 2;
+
if (!freerdp_disconnect(instance))
goto finish;
rc = 0;
-
finish:
freerdp_context_free(instance);
freerdp_free(instance);
-
return rc;
}
"/v:192.0.2.1:XXXXX",
NULL
};
-
int rc;
-
snprintf(arg1, 18, "/v:192.0.2.1:%d", port);
argv[1] = arg1;
start = GetTickCount();
return -1;
diff = end - start;
+
if (diff > 16000)
return -1;
return 0;
}
-struct testThreadArgs {
+struct testThreadArgs
+{
int port;
freerdp** arg;
};
"/v:192.0.2.1:XXXXX",
NULL
};
-
int rc;
- struct testThreadArgs *args = arg;
+ struct testThreadArgs* args = arg;
snprintf(arg1, 18, "/v:192.0.2.1:%d", args->port);
argv[1] = arg1;
-
rc = runInstance(2, argv, args->arg);
if (rc != 1)
HANDLE thread;
struct testThreadArgs args;
freerdp* instance = NULL;
-
s_sync = CreateEvent(NULL, TRUE, FALSE, NULL);
+
if (!s_sync)
return -1;
args.arg = &instance;
start = GetTickCount();
thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)testThread,
- &args, 0, NULL);
+ &args, 0, NULL);
+
if (!thread)
{
CloseHandle(s_sync);
WaitForSingleObject(s_sync, INFINITE);
freerdp_abort_connect(instance);
status = WaitForSingleObject(instance->context->abortEvent, 0);
+
if (status != WAIT_OBJECT_0)
{
CloseHandle(s_sync);
status = WaitForSingleObject(thread, 20000);
end = GetTickCount();
-
CloseHandle(s_sync);
CloseHandle(thread);
s_sync = NULL;
-
diff = end - start;
+
if (diff > 1000)
return -1;
"/rfx",
NULL
};
- char *commandLine;
+ char* commandLine;
int commandLineLen;
-
int argc = 4;
char* path = TESTING_OUTPUT_DIRECTORY;
char* wpath = TESTING_SRC_DIRECTORY;
char* exe = GetCombinedPath(path, "server");
char* wexe = GetCombinedPath(wpath, "server");
-
snprintf(arg1, 18, "/v:127.0.0.1:%d", port);
clientArgs[1] = arg1;
printf("Sample Server: %s\n", exe);
printf("Workspace: %s\n", wpath);
+
if (!PathFileExistsA(exe))
{
free(path);
// Start sample server locally.
commandLineLen = strlen(exe) + strlen(" --port=XXXXX") + 1;
commandLine = malloc(commandLineLen);
+
if (!commandLine)
{
free(path);
free(exe);
return -2;
}
- snprintf(commandLine, commandLineLen, "%s --port=%d", exe, port);
+ snprintf(commandLine, commandLineLen, "%s --port=%d", exe, port);
memset(&si, 0, sizeof(si));
- si.cb = sizeof(si);
+ si.cb = sizeof(si);
if (!CreateProcessA(exe, commandLine, NULL, NULL, FALSE, 0, NULL,
- wpath, &si, &process))
+ wpath, &si, &process))
{
free(exe);
free(path);
free(path);
free(wpath);
free(commandLine);
-
Sleep(1 * 1000); /* let the server start */
rc = runInstance(argc, clientArgs, NULL);
WaitForSingleObject(process.hProcess, INFINITE);
CloseHandle(process.hProcess);
CloseHandle(process.hThread);
-
printf("%s: returned %d!\n", __FUNCTION__, rc);
+
if (rc)
return -1;
int TestConnect(int argc, char* argv[])
{
int randomPort;
-
randomPort = 3389 + (random() % 200);
/* Test connect to not existing server,
if (!transport->GatewayEnabled)
{
nCount++;
+
if (events)
{
if (nCount > count)
{
WLog_ERR(TAG, "%s: provided handles array is too small (count=%d nCount=%d)",
- __FUNCTION__, count, nCount);
+ __FUNCTION__, count, nCount);
return 0;
}
ResetEvent(transport->rereadEvent);
}
- while(!freerdp_shall_disconnect(transport->context->instance) && (now < dueDate))
+ while (!freerdp_shall_disconnect(transport->context->instance) && (now < dueDate))
{
/**
* Note: transport_read_pdu tries to read one PDU from
SetEvent(transport->rereadEvent);
transport->haveMoreBytesToRead = TRUE;
}
+
return 0;
}
goto out_free_receivebuffer;
transport->rereadEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+
if (!transport->rereadEvent || transport->rereadEvent == INVALID_HANDLE_VALUE)
goto out_free_connectedEvent;
goto fail_rfx_context;
if (!rfx_context_reset(context->rfx_context, SAMPLE_SERVER_DEFAULT_WIDTH,
- SAMPLE_SERVER_DEFAULT_HEIGHT))
+ SAMPLE_SERVER_DEFAULT_HEIGHT))
goto fail_rfx_context;
context->rfx_context->mode = RLGR3;
if (client->settings->RemoteFxCodec)
{
if (!rfx_compose_message(context->rfx_context, s,
- &rect, 1, rgb_data, rect.width, rect.height, rect.width * 3))
+ &rect, 1, rgb_data, rect.width, rect.height, rect.width * 3))
{
goto out;
}
else
{
nsc_compose_message(context->nsc_context, s,
- rgb_data, rect.width, rect.height, rect.width * 3);
+ rgb_data, rect.width, rect.height, rect.width * 3);
cmd->codecID = client->settings->NSCodecId;
}
/* background with same size, which will be used to erase the icon from old position */
if (!(context->bg_data = malloc(context->icon_width * context->icon_height *
- 3)))
+ 3)))
goto out_fail;
memset(context->bg_data, 0xA0, context->icon_width * context->icon_height * 3);
if (client->settings->RemoteFxCodec)
{
rfx_compose_message(context->rfx_context, s,
- &rect, 1, context->bg_data, rect.width, rect.height, rect.width * 3);
+ &rect, 1, context->bg_data, rect.width, rect.height, rect.width * 3);
cmd->codecID = client->settings->RemoteFxCodecId;
}
else
{
nsc_compose_message(context->nsc_context, s,
- context->bg_data, rect.width, rect.height, rect.width * 3);
+ context->bg_data, rect.width, rect.height, rect.width * 3);
cmd->codecID = client->settings->NSCodecId;
}
if (client->settings->RemoteFxCodec)
{
rfx_compose_message(context->rfx_context, s,
- &rect, 1, context->icon_data, rect.width, rect.height, rect.width * 3);
+ &rect, 1, context->icon_data, rect.width, rect.height, rect.width * 3);
cmd->codecID = client->settings->RemoteFxCodecId;
}
else
{
nsc_compose_message(context->nsc_context, s,
- context->icon_data, rect.width, rect.height, rect.width * 3);
+ context->icon_data, rect.width, rect.height, rect.width * 3);
cmd->codecID = client->settings->NSCodecId;
}
}
static BOOL test_sleep_tsdiff(UINT32* old_sec, UINT32* old_usec, UINT32 new_sec,
- UINT32 new_usec)
+ UINT32 new_usec)
{
INT32 sec, usec;
if (test_dump_rfx_realtime
&& test_sleep_tsdiff(&prev_seconds, &prev_useconds, record.header.ts_sec,
- record.header.ts_usec) == FALSE)
+ record.header.ts_usec) == FALSE)
break;
update->SurfaceCommand(update->context, s);
testPeerContext* context = (testPeerContext*) arg;
if (WTSVirtualChannelQuery(context->debug_channel, WTSVirtualFileHandle,
- &buffer, &BytesReturned) == TRUE)
+ &buffer, &BytesReturned) == TRUE)
{
fd = *((void**) buffer);
WTSFreeMemory(buffer);
Stream_SetPosition(s, 0);
if (WTSVirtualChannelRead(context->debug_channel, 0, (PCHAR) Stream_Buffer(s),
- Stream_Capacity(s), &BytesReturned) == FALSE)
+ Stream_Capacity(s), &BytesReturned) == FALSE)
{
if (BytesReturned == 0)
break;
Stream_EnsureRemainingCapacity(s, BytesReturned);
if (WTSVirtualChannelRead(context->debug_channel, 0, (PCHAR) Stream_Buffer(s),
- Stream_Capacity(s), &BytesReturned) == FALSE)
+ Stream_Capacity(s), &BytesReturned) == FALSE)
{
/* should not happen */
break;
* callback returns.
*/
WLog_DBG(TAG, "Client %s is activated (osMajorType %d osMinorType %d)",
- client->local ? "(local)" : client->hostname,
- client->settings->OsMajorType, client->settings->OsMinorType);
+ client->local ? "(local)" : client->hostname,
+ client->settings->OsMajorType, client->settings->OsMinorType);
if (client->settings->AutoLogonEnabled)
{
WLog_DBG(TAG, " and wants to login automatically as %s\\%s",
- client->settings->Domain ? client->settings->Domain : "",
- client->settings->Username);
+ client->settings->Domain ? client->settings->Domain : "",
+ client->settings->Username);
/* A real server may perform OS login here if NLA is not executed previously. */
}
WLog_DBG(TAG, "");
WLog_DBG(TAG, "Client requested desktop: %dx%dx%d",
- client->settings->DesktopWidth, client->settings->DesktopHeight,
- client->settings->ColorDepth);
+ client->settings->DesktopWidth, client->settings->DesktopHeight,
+ client->settings->ColorDepth);
#if (SAMPLE_SERVER_USE_CLIENT_RESOLUTION == 1)
if (!rfx_context_reset(context->rfx_context, client->settings->DesktopWidth,
- client->settings->DesktopHeight))
+ client->settings->DesktopHeight))
return FALSE;
WLog_DBG(TAG, "Using resolution requested by client.");
client->settings->DesktopWidth = context->rfx_context->width;
client->settings->DesktopHeight = context->rfx_context->height;
WLog_DBG(TAG, "Resizing client to %dx%d", client->settings->DesktopWidth,
- client->settings->DesktopHeight);
+ client->settings->DesktopHeight);
client->update->DesktopResize(client->update->context);
#endif
if (WTSVirtualChannelManagerIsChannelJoined(context->vcm, "rdpdbg"))
{
context->debug_channel = WTSVirtualChannelOpen(context->vcm,
- WTS_CURRENT_SESSION, "rdpdbg");
+ WTS_CURRENT_SESSION, "rdpdbg");
if (context->debug_channel != NULL)
{
}
if (!(context->debug_channel_thread = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE) tf_debug_channel_thread_func, (void*) context, 0,
- NULL)))
+ (LPTHREAD_START_ROUTINE) tf_debug_channel_thread_func, (void*) context, 0,
+ NULL)))
{
WLog_ERR(TAG, "Failed to create debug channel thread");
CloseHandle(context->stopEvent);
rdpUpdate* update = client->update;
testPeerContext* context = (testPeerContext*) input->context;
WLog_DBG(TAG, "Client sent a keyboard event (flags:0x%X code:0x%X)", flags,
- code);
+ code);
if ((flags & 0x4000) && code == 0x22) /* 'g' key */
{
}
if (!rfx_context_reset(context->rfx_context, client->settings->DesktopWidth,
- client->settings->DesktopHeight))
+ client->settings->DesktopHeight))
return FALSE;
update->DesktopResize(update->context);
BOOL tf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{
WLog_DBG(TAG, "Client sent a unicode keyboard event (flags:0x%X code:0x%X)",
- flags, code);
+ flags, code);
return TRUE;
}
}
BOOL tf_peer_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x,
- UINT16 y)
+ UINT16 y)
{
//WLog_DBG(TAG, "Client sent an extended mouse event (flags:0x%X pos:%d,%d)", flags, x, y);
return TRUE;
}
static BOOL tf_peer_refresh_rect(rdpContext* context, BYTE count,
- const RECTANGLE_16* areas)
+ const RECTANGLE_16* areas)
{
BYTE i;
WLog_DBG(TAG, "Client requested to refresh:");
for (i = 0; i < count; i++)
{
WLog_DBG(TAG, " (%d, %d) (%d, %d)", areas[i].left, areas[i].top,
- areas[i].right, areas[i].bottom);
+ areas[i].right, areas[i].bottom);
}
return TRUE;
}
static BOOL tf_peer_suppress_output(rdpContext* context, BYTE allow,
- const RECTANGLE_16* area)
+ const RECTANGLE_16* area)
{
if (allow > 0)
{
WLog_DBG(TAG, "Client restore output (%d, %d) (%d, %d).", area->left, area->top,
- area->right, area->bottom);
+ area->right, area->bottom);
}
else
{
client->Initialize(client);
context = (testPeerContext*) client->context;
WLog_INFO(TAG, "We've got a client %s",
- client->local ? "(local)" : client->hostname);
+ client->local ? "(local)" : client->hostname);
while (1)
{
}
WLog_INFO(TAG, "Client %s disconnected.",
- client->local ? "(local)" : client->hostname);
+ client->local ? "(local)" : client->hostname);
client->Disconnect(client);
freerdp_peer_context_free(client);
freerdp_peer_free(client);
HANDLE hThread;
if (!(hThread = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE) test_peer_mainloop, (void*) client, 0, NULL)))
+ (LPTHREAD_START_ROUTINE) test_peer_mainloop, (void*) client, 0, NULL)))
return FALSE;
CloseHandle(hThread);
}
if ((localOnly || instance->Open(instance, NULL, port)) &&
- instance->OpenLocal(instance, file))
+ instance->OpenLocal(instance, file))
{
/* Entering the server main loop. In a real server the listener can be run in its own thread. */
test_server_mainloop(instance);