void transport_free(rdpTransport* transport) { if (transport != NULL) { if (transport->ReceiveBuffer) stream_free(transport->ReceiveBuffer); stream_free(transport->ReceiveStream); stream_free(transport->SendStream); CloseHandle(transport->ReceiveEvent); if (transport->TlsIn) tls_free(transport->TlsIn); if (transport->TlsOut != transport->TlsIn) tls_free(transport->TlsOut); tcp_free(transport->TcpIn); if (transport->TcpOut != transport->TcpIn) tcp_free(transport->TcpOut); tsg_free(transport->tsg); Queue_Free(transport->ReceivePool); Queue_Free(transport->ReceiveQueue); free(transport); } }
BOOL transport_disconnect(rdpTransport* transport) { BOOL status = TRUE; if (!transport) return FALSE; if (transport->tls) { tls_free(transport->tls); transport->tls = NULL; } else { if (transport->frontBio) BIO_free_all(transport->frontBio); } if (transport->tsg) { tsg_free(transport->tsg); transport->tsg = NULL; } if (transport->rdg) { rdg_free(transport->rdg); transport->rdg = NULL; } transport->frontBio = NULL; transport->layer = TRANSPORT_LAYER_TCP; return status; }
void transport_free(rdpTransport* transport) { if (transport != NULL) { SetEvent(transport->stopEvent); if (transport->ReceiveBuffer) Stream_Release(transport->ReceiveBuffer); StreamPool_Free(transport->ReceivePool); CloseHandle(transport->ReceiveEvent); CloseHandle(transport->connectedEvent); if (transport->TlsIn) tls_free(transport->TlsIn); if (transport->TlsOut != transport->TlsIn) tls_free(transport->TlsOut); tcp_free(transport->TcpIn); if (transport->TcpOut != transport->TcpIn) tcp_free(transport->TcpOut); tsg_free(transport->tsg); CloseHandle(transport->ReadMutex); CloseHandle(transport->WriteMutex); free(transport); } }
void transport_free(rdpTransport* transport) { if (transport != NULL) { if (transport->ReceiveBuffer) Stream_Release(transport->ReceiveBuffer); if (transport->ReceiveStream) Stream_Release(transport->ReceiveStream); StreamPool_Free(transport->ReceivePool); Stream_Free(transport->SendStream, TRUE); CloseHandle(transport->ReceiveEvent); CloseHandle(transport->connectedEvent); if (transport->TlsIn) tls_free(transport->TlsIn); if (transport->TlsOut != transport->TlsIn) tls_free(transport->TlsOut); tcp_free(transport->TcpIn); if (transport->TcpOut != transport->TcpIn) tcp_free(transport->TcpOut); tsg_free(transport->tsg); free(transport); } }
void transport_free(rdpTransport* transport) { if (transport) { if (transport->async) { if (transport->stopEvent) { SetEvent(transport->stopEvent); WaitForSingleObject(transport->thread, INFINITE); CloseHandle(transport->thread); CloseHandle(transport->stopEvent); transport->thread = NULL; transport->stopEvent = NULL; } } if (transport->ReceiveBuffer) Stream_Release(transport->ReceiveBuffer); StreamPool_Free(transport->ReceivePool); CloseHandle(transport->ReceiveEvent); CloseHandle(transport->connectedEvent); if (transport->TlsIn) tls_free(transport->TlsIn); if (transport->TlsOut != transport->TlsIn) tls_free(transport->TlsOut); transport->TlsIn = NULL; transport->TlsOut = NULL; if (transport->TcpIn) tcp_free(transport->TcpIn); if (transport->TcpOut != transport->TcpIn) tcp_free(transport->TcpOut); transport->TcpIn = NULL; transport->TcpOut = NULL; tsg_free(transport->tsg); transport->tsg = NULL; DeleteCriticalSection(&(transport->ReadLock)); DeleteCriticalSection(&(transport->WriteLock)); free(transport); } }
void transport_free(rdpTransport* transport) { if (transport) { if (transport->async) { assert(!transport->thread); assert(!transport->stopEvent); } if (transport->ReceiveBuffer) Stream_Release(transport->ReceiveBuffer); StreamPool_Free(transport->ReceivePool); CloseHandle(transport->ReceiveEvent); CloseHandle(transport->connectedEvent); if (transport->TlsIn) tls_free(transport->TlsIn); if (transport->TlsOut != transport->TlsIn) tls_free(transport->TlsOut); transport->TlsIn = NULL; transport->TlsOut = NULL; if (transport->TcpIn) tcp_free(transport->TcpIn); if (transport->TcpOut != transport->TcpIn) tcp_free(transport->TcpOut); transport->TcpIn = NULL; transport->TcpOut = NULL; tsg_free(transport->tsg); transport->tsg = NULL; CloseHandle(transport->ReadMutex); CloseHandle(transport->WriteMutex); free(transport); } }
BOOL transport_disconnect(rdpTransport* transport) { BOOL status = TRUE; if (!transport) return FALSE; transport_stop(transport); if (transport->frontBio) { BIO_free_all(transport->frontBio); transport->frontBio = NULL; } if (transport->TlsIn) tls_free(transport->TlsIn); if (transport->TlsOut != transport->TlsIn) tls_free(transport->TlsOut); transport->TlsIn = NULL; transport->TlsOut = NULL; if (transport->tsg) { tsg_free(transport->tsg); transport->tsg = NULL; } if (transport->TcpOut != transport->TcpIn) freerdp_tcp_free(transport->TcpOut); transport->TcpOut = NULL; if (transport->TsgTls) { tls_free(transport->TsgTls); transport->TsgTls = NULL; } transport->layer = TRANSPORT_LAYER_TCP; return status; }
void transport_free(rdpTransport* transport) { if (transport != NULL) { stream_free(transport->recv_buffer); stream_free(transport->recv_stream); stream_free(transport->send_stream); wait_obj_free(transport->recv_event); if (transport->tls) tls_free(transport->tls); tcp_free(transport->tcp); tcp_free(transport->tcp_in); tsg_free(transport->tsg); xfree(transport); } }
void transport_free(rdpTransport* transport) { if (!transport) return; transport_stop(transport); if (transport->ReceiveBuffer) Stream_Release(transport->ReceiveBuffer); StreamPool_Free(transport->ReceivePool); CloseHandle(transport->ReceiveEvent); CloseHandle(transport->connectedEvent); if (transport->TlsIn) tls_free(transport->TlsIn); if (transport->TlsOut != transport->TlsIn) tls_free(transport->TlsOut); transport->TlsIn = NULL; transport->TlsOut = NULL; if (transport->TcpIn) tcp_free(transport->TcpIn); if (transport->TcpOut != transport->TcpIn) tcp_free(transport->TcpOut); transport->TcpIn = NULL; transport->TcpOut = NULL; tsg_free(transport->tsg); transport->tsg = NULL; DeleteCriticalSection(&(transport->ReadLock)); DeleteCriticalSection(&(transport->WriteLock)); free(transport); }
BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 port, int timeout) { int sockfd; BOOL status = FALSE; rdpSettings* settings = transport->settings; rdpContext* context = transport->context; transport->async = settings->AsyncTransport; if (transport->GatewayEnabled) { if (!status && settings->GatewayHttpTransport) { transport->rdg = rdg_new(transport); if (!transport->rdg) return FALSE; status = rdg_connect(transport->rdg, hostname, port, timeout); if (status) { transport->frontBio = transport->rdg->frontBio; BIO_set_nonblock(transport->frontBio, 0); transport->layer = TRANSPORT_LAYER_TSG; status = TRUE; } else { rdg_free(transport->rdg); transport->rdg = NULL; } } if (!status && settings->GatewayRpcTransport) { transport->tsg = tsg_new(transport); if (!transport->tsg) return FALSE; status = tsg_connect(transport->tsg, hostname, port, timeout); if (status) { transport->frontBio = transport->tsg->bio; transport->layer = TRANSPORT_LAYER_TSG; status = TRUE; } else { tsg_free(transport->tsg); transport->tsg = NULL; } } } else { sockfd = freerdp_tcp_connect(context, settings, hostname, port, timeout); if (sockfd < 1) return FALSE; if (!transport_attach(transport, sockfd)) return FALSE; status = TRUE; } if (status) { if (transport->async) { if (!(transport->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) { WLog_ERR(TAG, "Failed to create transport stop event"); return FALSE; } if (!(transport->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) transport_client_thread, transport, 0, NULL))) { WLog_ERR(TAG, "Failed to create transport client thread"); CloseHandle(transport->stopEvent); transport->stopEvent = NULL; return FALSE; } } } return status; }
BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 port, int timeout) { int sockfd; BOOL status = FALSE; rdpSettings* settings = transport->settings; rdpContext* context = transport->context; BOOL rpcFallback = !settings->GatewayHttpTransport; if (transport->GatewayEnabled) { if (!status && settings->GatewayHttpTransport) { transport->rdg = rdg_new(transport); if (!transport->rdg) return FALSE; status = rdg_connect(transport->rdg, timeout, &rpcFallback); if (status) { transport->frontBio = transport->rdg->frontBio; BIO_set_nonblock(transport->frontBio, 0); transport->layer = TRANSPORT_LAYER_TSG; status = TRUE; } else { rdg_free(transport->rdg); transport->rdg = NULL; } } if (!status && settings->GatewayRpcTransport && rpcFallback) { transport->tsg = tsg_new(transport); if (!transport->tsg) return FALSE; status = tsg_connect(transport->tsg, hostname, port, timeout); if (status) { transport->frontBio = tsg_get_bio(transport->tsg); transport->layer = TRANSPORT_LAYER_TSG; status = TRUE; } else { tsg_free(transport->tsg); transport->tsg = NULL; } } } else { UINT16 peerPort; const char* proxyHostname, *proxyUsername, *proxyPassword; BOOL isProxyConnection = proxy_prepare(settings, &proxyHostname, &peerPort, &proxyUsername, &proxyPassword); if (isProxyConnection) sockfd = freerdp_tcp_connect(context, settings, proxyHostname, peerPort, timeout); else sockfd = freerdp_tcp_connect(context, settings, hostname, port, timeout); if (sockfd < 0) return FALSE; if (!transport_attach(transport, sockfd)) return FALSE; if (isProxyConnection) { if (!proxy_connect(settings, transport->frontBio, proxyUsername, proxyPassword, hostname, port)) return FALSE; } status = TRUE; } return status; }