libfreerdp-core: set TSG non-blocking mode

This commit is contained in:
Marc-André Moreau 2012-12-06 16:49:50 -05:00
parent b92d2cf30f
commit 98c4cb56a1
4 changed files with 26 additions and 1 deletions

View File

@ -54,7 +54,6 @@ typedef struct
typedef struct _RPC_PDU
{
SLIST_ENTRY ItemEntry;
BYTE* Buffer;
UINT32 Size;
UINT32 Length;

View File

@ -1083,6 +1083,8 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port)
rpc->client->SynchronousSend = TRUE;
rpc->client->SynchronousReceive = TRUE;
printf("TS Gateway Connection Success\n");
return TRUE;
}
@ -1097,6 +1099,9 @@ int tsg_read(rdpTsg* tsg, BYTE* data, UINT32 length)
{
CopyLength = (tsg->BytesAvailable > length) ? length : tsg->BytesAvailable;
//printf("Reading from the same PDU: copy: %d length: %d avail: %d\n",
// CopyLength, length, tsg->BytesAvailable);
CopyMemory(data, &tsg->pdu->Buffer[tsg->BytesRead], CopyLength);
tsg->BytesAvailable -= CopyLength;
tsg->BytesRead += CopyLength;
@ -1110,6 +1115,9 @@ int tsg_read(rdpTsg* tsg, BYTE* data, UINT32 length)
{
tsg->pdu = rpc_recv_dequeue_pdu(rpc);
if (!tsg->pdu)
return 0;
if ((tsg->pdu->Flags & RPC_PDU_FLAG_STUB) && (tsg->pdu->Length == 4))
{
DEBUG_TSG("Ignoring TsProxySetupReceivePipe Response");
@ -1123,6 +1131,9 @@ int tsg_read(rdpTsg* tsg, BYTE* data, UINT32 length)
CopyLength = (tsg->BytesAvailable > length) ? length : tsg->BytesAvailable;
//printf("Reading new PDU: copy: %d length: %d avail: %d\n",
// CopyLength, length, tsg->BytesAvailable);
CopyMemory(data, &tsg->pdu->Buffer[tsg->BytesRead], CopyLength);
tsg->BytesAvailable -= CopyLength;
tsg->BytesRead += CopyLength;
@ -1139,6 +1150,14 @@ int tsg_write(rdpTsg* tsg, BYTE* data, UINT32 length)
return TsProxySendToServer((handle_t) tsg, data, 1, &length);
}
BOOL tsg_set_blocking_mode(rdpTsg* tsg, BOOL blocking)
{
tsg->rpc->client->SynchronousSend = TRUE;
tsg->rpc->client->SynchronousReceive = blocking;
return TRUE;
}
rdpTsg* tsg_new(rdpTransport* transport)
{
rdpTsg* tsg;

View File

@ -307,6 +307,8 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port);
int tsg_write(rdpTsg* tsg, BYTE* data, UINT32 length);
int tsg_read(rdpTsg* tsg, BYTE* data, UINT32 length);
BOOL tsg_set_blocking_mode(rdpTsg* tsg, BOOL blocking);
rdpTsg* tsg_new(rdpTransport* transport);
void tsg_free(rdpTsg* tsg);

View File

@ -532,6 +532,11 @@ BOOL transport_set_blocking_mode(rdpTransport* transport, BOOL blocking)
status &= tcp_set_blocking_mode(transport->TcpIn, blocking);
}
if (transport->layer == TRANSPORT_LAYER_TSG)
{
tsg_set_blocking_mode(transport->tsg, blocking);
}
return status;
}