mirror of https://github.com/FreeRDP/FreeRDP
libfreerdp-core: TSG reassembly refactoring
This commit is contained in:
parent
d3e0537d0d
commit
387a152299
|
@ -278,5 +278,7 @@ void ntlm_http_free(rdpNtlmHttp* ntlm_http)
|
|||
{
|
||||
ntlm_free(ntlm_http->ntlm);
|
||||
http_context_free(ntlm_http->context);
|
||||
|
||||
free(ntlm_http);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,6 +235,11 @@ BOOL ntlm_authenticate(rdpNtlm* ntlm)
|
|||
status = SEC_I_CONTINUE_NEEDED;
|
||||
}
|
||||
|
||||
if (ntlm->haveInputBuffer)
|
||||
{
|
||||
free(ntlm->inputBuffer.pvBuffer);
|
||||
}
|
||||
|
||||
ntlm->haveInputBuffer = TRUE;
|
||||
ntlm->haveContext = TRUE;
|
||||
|
||||
|
|
|
@ -540,12 +540,8 @@ rdpRpc* rpc_new(rdpTransport* transport)
|
|||
|
||||
rpc->PipeCallId = 0;
|
||||
|
||||
rpc->StubOffset = 0;
|
||||
rpc->StubBufferSize = 20;
|
||||
rpc->StubLength = 0;
|
||||
rpc->StubFragCount = 0;
|
||||
rpc->StubBuffer = (BYTE*) malloc(0x0FF8);
|
||||
rpc->StubCallId = 0;
|
||||
rpc->StubFragCount = 0;
|
||||
|
||||
rpc->rpc_vers = 5;
|
||||
rpc->rpc_vers_minor = 0;
|
||||
|
@ -560,6 +556,7 @@ rdpRpc* rpc_new(rdpTransport* transport)
|
|||
rpc->max_recv_frag = 0x0FF8;
|
||||
|
||||
rpc->pdu = (RPC_PDU*) malloc(sizeof(RPC_PDU));
|
||||
rpc->pdu->s = Stream_New(NULL, rpc->max_recv_frag);
|
||||
|
||||
rpc->RecvFrag = Stream_New(NULL, rpc->max_recv_frag);
|
||||
|
||||
|
|
|
@ -55,9 +55,7 @@ typedef struct
|
|||
|
||||
typedef struct _RPC_PDU
|
||||
{
|
||||
BYTE* Buffer;
|
||||
UINT32 Size;
|
||||
UINT32 Length;
|
||||
wStream* s;
|
||||
DWORD Flags;
|
||||
DWORD CallId;
|
||||
} RPC_PDU, *PRPC_PDU;
|
||||
|
@ -741,12 +739,8 @@ struct rdp_rpc
|
|||
|
||||
RPC_PDU* pdu;
|
||||
|
||||
BYTE* StubBuffer;
|
||||
UINT32 StubBufferSize;
|
||||
UINT32 StubLength;
|
||||
UINT32 StubOffset;
|
||||
UINT32 StubFragCount;
|
||||
UINT32 StubCallId;
|
||||
UINT32 StubFragCount;
|
||||
|
||||
BYTE rpc_vers;
|
||||
BYTE rpc_vers_minor;
|
||||
|
|
|
@ -353,7 +353,7 @@ int rpc_secure_bind(rdpRpc* rpc)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (rpc_recv_bind_ack_pdu(rpc, pdu->Buffer, pdu->Length) <= 0)
|
||||
if (rpc_recv_bind_ack_pdu(rpc, Stream_Buffer(pdu->s), Stream_Length(pdu->s)) <= 0)
|
||||
{
|
||||
printf("rpc_secure_bind: error receiving bind ack pdu!\n");
|
||||
return -1;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/print.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/thread.h>
|
||||
#include <winpr/stream.h>
|
||||
|
@ -63,13 +64,14 @@ RPC_PDU* rpc_client_receive_pool_take(rdpRpc* rpc)
|
|||
if (!pdu)
|
||||
{
|
||||
pdu = (RPC_PDU*) malloc(sizeof(RPC_PDU));
|
||||
pdu->Buffer = (BYTE*) malloc(rpc->max_recv_frag);
|
||||
pdu->Size = rpc->max_recv_frag;
|
||||
pdu->s = Stream_New(NULL, rpc->max_recv_frag);
|
||||
}
|
||||
|
||||
pdu->CallId = 0;
|
||||
pdu->Flags = 0;
|
||||
pdu->Length = 0;
|
||||
|
||||
Stream_Length(pdu->s) = 0;
|
||||
Stream_SetPosition(pdu->s, 0);
|
||||
|
||||
return pdu;
|
||||
}
|
||||
|
@ -93,17 +95,14 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc)
|
|||
buffer = (BYTE*) Stream_Buffer(fragment);
|
||||
header = (rpcconn_hdr_t*) Stream_Buffer(fragment);
|
||||
|
||||
//rpc_pdu_header_print(header);
|
||||
|
||||
if (rpc->State < RPC_CLIENT_STATE_CONTEXT_NEGOTIATED)
|
||||
{
|
||||
rpc->pdu->Flags = 0;
|
||||
rpc->pdu->Size = Stream_Length(fragment);
|
||||
rpc->pdu->Length = Stream_Length(fragment);
|
||||
rpc->pdu->CallId = header->common.call_id;
|
||||
|
||||
rpc->pdu->Buffer = malloc(rpc->pdu->Size);
|
||||
CopyMemory(rpc->pdu->Buffer, buffer, rpc->pdu->Size);
|
||||
Stream_EnsureCapacity(rpc->pdu->s, Stream_Length(fragment));
|
||||
Stream_Write(rpc->pdu->s, buffer, Stream_Length(fragment));
|
||||
Stream_Length(rpc->pdu->s) = Stream_Position(rpc->pdu->s);
|
||||
|
||||
rpc_client_fragment_pool_return(rpc, fragment);
|
||||
|
||||
|
@ -158,11 +157,9 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (header->response.alloc_hint > rpc->StubBufferSize)
|
||||
{
|
||||
rpc->StubBufferSize = header->response.alloc_hint;
|
||||
rpc->StubBuffer = (BYTE*) realloc(rpc->StubBuffer, rpc->StubBufferSize);
|
||||
}
|
||||
Stream_EnsureCapacity(rpc->pdu->s, header->response.alloc_hint);
|
||||
buffer = (BYTE*) Stream_Buffer(fragment);
|
||||
header = (rpcconn_hdr_t*) Stream_Buffer(fragment);
|
||||
|
||||
if (rpc->StubFragCount == 0)
|
||||
rpc->StubCallId = header->common.call_id;
|
||||
|
@ -173,8 +170,7 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc)
|
|||
rpc->StubCallId, header->common.call_id, rpc->StubFragCount);
|
||||
}
|
||||
|
||||
CopyMemory(&rpc->StubBuffer[rpc->StubOffset], &buffer[StubOffset], StubLength);
|
||||
rpc->StubOffset += StubLength;
|
||||
Stream_Write(rpc->pdu->s, &buffer[StubOffset], StubLength);
|
||||
rpc->StubFragCount++;
|
||||
|
||||
rpc_client_fragment_pool_return(rpc, fragment);
|
||||
|
@ -193,20 +189,13 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc)
|
|||
|
||||
if ((header->response.alloc_hint == StubLength))
|
||||
{
|
||||
rpc->pdu->CallId = rpc->StubCallId;
|
||||
rpc->StubLength = rpc->StubOffset;
|
||||
|
||||
rpc->StubOffset = 0;
|
||||
rpc->StubFragCount = 0;
|
||||
rpc->StubCallId = 0;
|
||||
rpc->StubFragCount = 0;
|
||||
|
||||
rpc->pdu->Flags = RPC_PDU_FLAG_STUB;
|
||||
rpc->pdu->Buffer = rpc->StubBuffer;
|
||||
rpc->pdu->Size = rpc->StubBufferSize;
|
||||
rpc->pdu->Length = rpc->StubLength;
|
||||
rpc->pdu->CallId = rpc->StubCallId;
|
||||
|
||||
rpc->StubBufferSize = rpc->max_recv_frag;
|
||||
rpc->StubBuffer = (BYTE*) malloc(rpc->StubBufferSize);
|
||||
Stream_Length(rpc->pdu->s) = Stream_Position(rpc->pdu->s);
|
||||
|
||||
Queue_Enqueue(rpc->client->ReceiveQueue, rpc->pdu);
|
||||
rpc->pdu = rpc_client_receive_pool_take(rpc);
|
||||
|
@ -345,8 +334,7 @@ int rpc_send_enqueue_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
|||
RPC_PDU* pdu;
|
||||
|
||||
pdu = (RPC_PDU*) malloc(sizeof(RPC_PDU));
|
||||
pdu->Buffer = buffer;
|
||||
pdu->Length = length;
|
||||
pdu->s = Stream_New(buffer, length);
|
||||
|
||||
Queue_Enqueue(rpc->client->SendQueue, pdu);
|
||||
|
||||
|
@ -373,9 +361,9 @@ int rpc_send_dequeue_pdu(rdpRpc* rpc)
|
|||
|
||||
WaitForSingleObject(rpc->VirtualConnection->DefaultInChannel->Mutex, INFINITE);
|
||||
|
||||
status = rpc_in_write(rpc, pdu->Buffer, pdu->Length);
|
||||
status = rpc_in_write(rpc, Stream_Buffer(pdu->s), Stream_Length(pdu->s));
|
||||
|
||||
header = (rpcconn_common_hdr_t*) pdu->Buffer;
|
||||
header = (rpcconn_common_hdr_t*) Stream_Buffer(pdu->s);
|
||||
clientCall = rpc_client_call_find_by_id(rpc, header->call_id);
|
||||
clientCall->State = RPC_CLIENT_CALL_STATE_DISPATCHED;
|
||||
|
||||
|
@ -390,7 +378,7 @@ int rpc_send_dequeue_pdu(rdpRpc* rpc)
|
|||
rpc->VirtualConnection->DefaultInChannel->BytesSent += status;
|
||||
rpc->VirtualConnection->DefaultInChannel->SenderAvailableWindow -= status;
|
||||
|
||||
free(pdu->Buffer);
|
||||
Stream_Free(pdu->s, TRUE);
|
||||
free(pdu);
|
||||
|
||||
if (rpc->client->SynchronousSend)
|
||||
|
@ -463,7 +451,7 @@ static void* rpc_client_thread(void* arg)
|
|||
|
||||
static void rpc_pdu_free(RPC_PDU* pdu)
|
||||
{
|
||||
free(pdu->Buffer);
|
||||
Stream_Free(pdu->s, TRUE);
|
||||
free(pdu);
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ BOOL rts_connect(rdpRpc* rpc)
|
|||
if (!pdu)
|
||||
return FALSE;
|
||||
|
||||
rts = (rpcconn_rts_hdr_t*) pdu->Buffer;
|
||||
rts = (rpcconn_rts_hdr_t*) Stream_Buffer(pdu->s);
|
||||
|
||||
if (!rts_match_pdu_signature(rpc, &RTS_PDU_CONN_A3_SIGNATURE, rts))
|
||||
{
|
||||
|
@ -192,7 +192,7 @@ BOOL rts_connect(rdpRpc* rpc)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
rts_recv_CONN_A3_pdu(rpc, pdu->Buffer, pdu->Size);
|
||||
rts_recv_CONN_A3_pdu(rpc, Stream_Buffer(pdu->s), Stream_Length(pdu->s));
|
||||
|
||||
rpc_client_receive_pool_return(rpc, pdu);
|
||||
|
||||
|
@ -225,7 +225,7 @@ BOOL rts_connect(rdpRpc* rpc)
|
|||
if (!pdu)
|
||||
return FALSE;
|
||||
|
||||
rts = (rpcconn_rts_hdr_t*) pdu->Buffer;
|
||||
rts = (rpcconn_rts_hdr_t*) Stream_Buffer(pdu->s);
|
||||
|
||||
if (!rts_match_pdu_signature(rpc, &RTS_PDU_CONN_C2_SIGNATURE, rts))
|
||||
{
|
||||
|
@ -233,7 +233,7 @@ BOOL rts_connect(rdpRpc* rpc)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
rts_recv_CONN_C2_pdu(rpc, pdu->Buffer, pdu->Size);
|
||||
rts_recv_CONN_C2_pdu(rpc, Stream_Buffer(pdu->s), Stream_Length(pdu->s));
|
||||
|
||||
rpc_client_receive_pool_return(rpc, pdu);
|
||||
|
||||
|
|
|
@ -219,8 +219,8 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg)
|
|||
if (!pdu)
|
||||
return FALSE;
|
||||
|
||||
length = pdu->Length;
|
||||
buffer = pdu->Buffer;
|
||||
length = Stream_Length(pdu->s);
|
||||
buffer = Stream_Buffer(pdu->s);
|
||||
|
||||
if (!(pdu->Flags & RPC_PDU_FLAG_STUB))
|
||||
buffer = &buffer[24];
|
||||
|
@ -571,8 +571,8 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg)
|
|||
if (!pdu)
|
||||
return FALSE;
|
||||
|
||||
length = pdu->Length;
|
||||
buffer = pdu->Buffer;
|
||||
length = Stream_Length(pdu->s);
|
||||
buffer = Stream_Buffer(pdu->s);
|
||||
|
||||
if (!(pdu->Flags & RPC_PDU_FLAG_STUB))
|
||||
buffer = &buffer[24];
|
||||
|
@ -809,8 +809,8 @@ BOOL TsProxyCreateChannelReadResponse(rdpTsg* tsg)
|
|||
if (!pdu)
|
||||
return FALSE;
|
||||
|
||||
length = pdu->Length;
|
||||
buffer = pdu->Buffer;
|
||||
length = Stream_Length(pdu->s);
|
||||
buffer = Stream_Buffer(pdu->s);
|
||||
|
||||
if (!(pdu->Flags & RPC_PDU_FLAG_STUB))
|
||||
buffer = &buffer[24];
|
||||
|
@ -1115,7 +1115,7 @@ int tsg_read(rdpTsg* tsg, BYTE* data, UINT32 length)
|
|||
{
|
||||
CopyLength = (length < tsg->BytesAvailable) ? length : tsg->BytesAvailable;
|
||||
|
||||
CopyMemory(data, &tsg->pdu->Buffer[tsg->BytesRead], CopyLength);
|
||||
CopyMemory(data, &tsg->pdu->s->buffer[tsg->BytesRead], CopyLength);
|
||||
tsg->BytesAvailable -= CopyLength;
|
||||
tsg->BytesRead += CopyLength;
|
||||
|
||||
|
@ -1140,12 +1140,12 @@ int tsg_read(rdpTsg* tsg, BYTE* data, UINT32 length)
|
|||
}
|
||||
|
||||
tsg->PendingPdu = TRUE;
|
||||
tsg->BytesAvailable = tsg->pdu->Length;
|
||||
tsg->BytesAvailable = Stream_Length(tsg->pdu->s);
|
||||
tsg->BytesRead = 0;
|
||||
|
||||
CopyLength = (length < tsg->BytesAvailable) ? length : tsg->BytesAvailable;
|
||||
|
||||
CopyMemory(data, &tsg->pdu->Buffer[tsg->BytesRead], CopyLength);
|
||||
CopyMemory(data, &tsg->pdu->s->buffer[tsg->BytesRead], CopyLength);
|
||||
tsg->BytesAvailable -= CopyLength;
|
||||
tsg->BytesRead += CopyLength;
|
||||
|
||||
|
|
|
@ -68,6 +68,9 @@ STREAM* transport_send_stream_init(rdpTransport* transport, int size)
|
|||
void transport_attach(rdpTransport* transport, int sockfd)
|
||||
{
|
||||
transport->TcpIn->sockfd = sockfd;
|
||||
|
||||
transport->SplitInputOutput = FALSE;
|
||||
transport->TcpOut = transport->TcpIn;
|
||||
}
|
||||
|
||||
BOOL transport_disconnect(rdpTransport* transport)
|
||||
|
@ -223,6 +226,9 @@ BOOL transport_accept_tls(rdpTransport* transport)
|
|||
if (transport->TlsIn == NULL)
|
||||
transport->TlsIn = tls_new(transport->settings);
|
||||
|
||||
if (transport->TlsOut == NULL)
|
||||
transport->TlsOut = transport->TlsIn;
|
||||
|
||||
transport->layer = TRANSPORT_LAYER_TLS;
|
||||
transport->TlsIn->sockfd = transport->TcpIn->sockfd;
|
||||
|
||||
|
|
|
@ -207,6 +207,8 @@ BOOL tls_accept(rdpTls* tls, const char* cert_file, const char* privatekey_file)
|
|||
|
||||
SSL_CTX_set_options(tls->ctx, options);
|
||||
|
||||
printf("private key file: %s\n", privatekey_file);
|
||||
|
||||
if (SSL_CTX_use_RSAPrivateKey_file(tls->ctx, privatekey_file, SSL_FILETYPE_PEM) <= 0)
|
||||
{
|
||||
printf("SSL_CTX_use_RSAPrivateKey_file failed\n");
|
||||
|
|
|
@ -181,7 +181,7 @@ xfInfo* xf_info_init()
|
|||
xfi = (xfInfo*) malloc(sizeof(xfInfo));
|
||||
ZeroMemory(xfi, sizeof(xfInfo));
|
||||
|
||||
//xfi->use_xshm = TRUE;
|
||||
xfi->use_xshm = TRUE;
|
||||
xfi->display = XOpenDisplay(NULL);
|
||||
|
||||
XInitThreads();
|
||||
|
@ -633,10 +633,6 @@ void* xf_peer_main_loop(void* arg)
|
|||
settings->CertificateFile = freerdp_construct_path(server_file_path, "server.crt");
|
||||
settings->PrivateKeyFile = freerdp_construct_path(server_file_path, "server.key");
|
||||
|
||||
settings->NlaSecurity = TRUE;
|
||||
settings->TlsSecurity = FALSE;
|
||||
settings->RdpSecurity = FALSE;
|
||||
|
||||
settings->RemoteFxCodec = TRUE;
|
||||
|
||||
client->Capabilities = xf_peer_capabilities;
|
||||
|
|
Loading…
Reference in New Issue