mirror of https://github.com/FreeRDP/FreeRDP
libfreerdp-core: TSG cleanup
This commit is contained in:
parent
85b023bb08
commit
b53bdba143
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <winpr/crt.h>
|
#include <winpr/crt.h>
|
||||||
#include <winpr/print.h>
|
#include <winpr/print.h>
|
||||||
|
#include <winpr/stream.h>
|
||||||
|
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
|
||||||
|
@ -200,10 +201,10 @@ char* http_encode_authorization_line(char* AuthScheme, char* AuthParam)
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
STREAM* http_request_write(HttpContext* http_context, HttpRequest* http_request)
|
wStream* http_request_write(HttpContext* http_context, HttpRequest* http_request)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
STREAM* s;
|
wStream* s;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
|
||||||
http_request->count = 9;
|
http_request->count = 9;
|
||||||
|
@ -234,21 +235,21 @@ STREAM* http_request_write(HttpContext* http_context, HttpRequest* http_request)
|
||||||
length += 2; /* empty line "\r\n" at end of header */
|
length += 2; /* empty line "\r\n" at end of header */
|
||||||
length += 1; /* null terminator */
|
length += 1; /* null terminator */
|
||||||
|
|
||||||
s = stream_new(length);
|
s = Stream_New(NULL, length);
|
||||||
|
|
||||||
for (i = 0; i < http_request->count; i++)
|
for (i = 0; i < http_request->count; i++)
|
||||||
{
|
{
|
||||||
stream_write(s, http_request->lines[i], strlen(http_request->lines[i]));
|
Stream_Write(s, http_request->lines[i], strlen(http_request->lines[i]));
|
||||||
stream_write(s, "\r\n", 2);
|
Stream_Write(s, "\r\n", 2);
|
||||||
free(http_request->lines[i]);
|
free(http_request->lines[i]);
|
||||||
}
|
}
|
||||||
stream_write(s, "\r\n", 2);
|
Stream_Write(s, "\r\n", 2);
|
||||||
|
|
||||||
free(http_request->lines);
|
free(http_request->lines);
|
||||||
|
|
||||||
stream_write(s, "\0", 1); /* append null terminator */
|
Stream_Write(s, "\0", 1); /* append null terminator */
|
||||||
stream_rewind(s, 1); /* don't include null terminator in length */
|
Stream_Rewind(s, 1); /* don't include null terminator in length */
|
||||||
stream_seal(s);
|
Stream_Length(s) = Stream_Position(s);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ typedef struct _http_response HttpResponse;
|
||||||
|
|
||||||
#include <freerdp/types.h>
|
#include <freerdp/types.h>
|
||||||
#include <freerdp/crypto/tls.h>
|
#include <freerdp/crypto/tls.h>
|
||||||
#include <freerdp/utils/stream.h>
|
|
||||||
|
#include <winpr/stream.h>
|
||||||
|
|
||||||
struct _http_context
|
struct _http_context
|
||||||
{
|
{
|
||||||
|
@ -71,7 +72,7 @@ void http_request_set_uri(HttpRequest* http_request, char* uri);
|
||||||
void http_request_set_auth_scheme(HttpRequest* http_request, char* auth_scheme);
|
void http_request_set_auth_scheme(HttpRequest* http_request, char* auth_scheme);
|
||||||
void http_request_set_auth_param(HttpRequest* http_request, char* auth_param);
|
void http_request_set_auth_param(HttpRequest* http_request, char* auth_param);
|
||||||
|
|
||||||
STREAM* http_request_write(HttpContext* http_context, HttpRequest* http_request);
|
wStream* http_request_write(HttpContext* http_context, HttpRequest* http_request);
|
||||||
|
|
||||||
HttpRequest* http_request_new();
|
HttpRequest* http_request_new();
|
||||||
void http_request_free(HttpRequest* http_request);
|
void http_request_free(HttpRequest* http_request);
|
||||||
|
|
|
@ -25,13 +25,14 @@
|
||||||
|
|
||||||
#include <winpr/crt.h>
|
#include <winpr/crt.h>
|
||||||
#include <winpr/tchar.h>
|
#include <winpr/tchar.h>
|
||||||
|
#include <winpr/stream.h>
|
||||||
#include <winpr/dsparse.h>
|
#include <winpr/dsparse.h>
|
||||||
|
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
STREAM* rpc_ntlm_http_request(rdpRpc* rpc, SecBuffer* ntlm_token, int content_length, TSG_CHANNEL channel)
|
wStream* rpc_ntlm_http_request(rdpRpc* rpc, SecBuffer* ntlm_token, int content_length, TSG_CHANNEL channel)
|
||||||
{
|
{
|
||||||
STREAM* s;
|
wStream* s;
|
||||||
char* base64_ntlm_token;
|
char* base64_ntlm_token;
|
||||||
HttpContext* http_context;
|
HttpContext* http_context;
|
||||||
HttpRequest* http_request;
|
HttpRequest* http_request;
|
||||||
|
@ -70,7 +71,7 @@ STREAM* rpc_ntlm_http_request(rdpRpc* rpc, SecBuffer* ntlm_token, int content_le
|
||||||
|
|
||||||
int rpc_ncacn_http_send_in_channel_request(rdpRpc* rpc)
|
int rpc_ncacn_http_send_in_channel_request(rdpRpc* rpc)
|
||||||
{
|
{
|
||||||
STREAM* s;
|
wStream* s;
|
||||||
int content_length;
|
int content_length;
|
||||||
BOOL continue_needed;
|
BOOL continue_needed;
|
||||||
rdpNtlm* ntlm = rpc->NtlmHttpIn->ntlm;
|
rdpNtlm* ntlm = rpc->NtlmHttpIn->ntlm;
|
||||||
|
@ -81,9 +82,9 @@ int rpc_ncacn_http_send_in_channel_request(rdpRpc* rpc)
|
||||||
|
|
||||||
s = rpc_ntlm_http_request(rpc, &ntlm->outputBuffer, content_length, TSG_CHANNEL_IN);
|
s = rpc_ntlm_http_request(rpc, &ntlm->outputBuffer, content_length, TSG_CHANNEL_IN);
|
||||||
|
|
||||||
DEBUG_RPC("\n%s", s->data);
|
DEBUG_RPC("\n%s", Stream_Buffer(s));
|
||||||
rpc_in_write(rpc, s->data, s->size);
|
rpc_in_write(rpc, Stream_Buffer(s), Stream_Length(s));
|
||||||
stream_free(s);
|
Stream_Free(s, TRUE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +167,7 @@ BOOL rpc_ntlm_http_in_connect(rdpRpc* rpc)
|
||||||
|
|
||||||
int rpc_ncacn_http_send_out_channel_request(rdpRpc* rpc)
|
int rpc_ncacn_http_send_out_channel_request(rdpRpc* rpc)
|
||||||
{
|
{
|
||||||
STREAM* s;
|
wStream* s;
|
||||||
int content_length;
|
int content_length;
|
||||||
BOOL continue_needed;
|
BOOL continue_needed;
|
||||||
rdpNtlm* ntlm = rpc->NtlmHttpOut->ntlm;
|
rdpNtlm* ntlm = rpc->NtlmHttpOut->ntlm;
|
||||||
|
@ -177,9 +178,9 @@ int rpc_ncacn_http_send_out_channel_request(rdpRpc* rpc)
|
||||||
|
|
||||||
s = rpc_ntlm_http_request(rpc, &ntlm->outputBuffer, content_length, TSG_CHANNEL_OUT);
|
s = rpc_ntlm_http_request(rpc, &ntlm->outputBuffer, content_length, TSG_CHANNEL_OUT);
|
||||||
|
|
||||||
DEBUG_RPC("\n%s", s->data);
|
DEBUG_RPC("\n%s", Stream_Buffer(s));
|
||||||
rpc_out_write(rpc, s->data, s->size);
|
rpc_out_write(rpc, Stream_Buffer(s), Stream_Length(s));
|
||||||
stream_free(s);
|
Stream_Free(s, TRUE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,12 @@
|
||||||
|
|
||||||
#include <freerdp/types.h>
|
#include <freerdp/types.h>
|
||||||
#include <freerdp/settings.h>
|
#include <freerdp/settings.h>
|
||||||
|
|
||||||
#include <freerdp/crypto/tls.h>
|
#include <freerdp/crypto/tls.h>
|
||||||
#include <freerdp/crypto/crypto.h>
|
#include <freerdp/crypto/crypto.h>
|
||||||
#include <freerdp/utils/sleep.h>
|
|
||||||
#include <freerdp/utils/debug.h>
|
#include <freerdp/utils/debug.h>
|
||||||
#include <freerdp/utils/stream.h>
|
#include <freerdp/utils/stream.h>
|
||||||
#include <freerdp/utils/hexdump.h>
|
|
||||||
|
|
||||||
#include "rpc.h"
|
#include "rpc.h"
|
||||||
|
|
||||||
|
|
|
@ -26,14 +26,13 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <freerdp/utils/sleep.h>
|
|
||||||
#include <freerdp/utils/stream.h>
|
|
||||||
#include <freerdp/utils/hexdump.h>
|
|
||||||
#include <freerdp/utils/unicode.h>
|
#include <freerdp/utils/unicode.h>
|
||||||
|
|
||||||
#include <winpr/crt.h>
|
#include <winpr/crt.h>
|
||||||
#include <winpr/ndr.h>
|
#include <winpr/ndr.h>
|
||||||
#include <winpr/error.h>
|
#include <winpr/error.h>
|
||||||
|
#include <winpr/print.h>
|
||||||
|
#include <winpr/stream.h>
|
||||||
|
|
||||||
#include "rpc_client.h"
|
#include "rpc_client.h"
|
||||||
|
|
||||||
|
@ -57,10 +56,11 @@ BYTE TsProxyCreateTunnelUnknownTrailerBytes[60] =
|
||||||
|
|
||||||
DWORD TsProxySendToServer(handle_t IDL_handle, byte pRpcMessage[], UINT32 count, UINT32* lengths)
|
DWORD TsProxySendToServer(handle_t IDL_handle, byte pRpcMessage[], UINT32 count, UINT32* lengths)
|
||||||
{
|
{
|
||||||
STREAM* s;
|
wStream* s;
|
||||||
int status;
|
int status;
|
||||||
int length;
|
|
||||||
rdpTsg* tsg;
|
rdpTsg* tsg;
|
||||||
|
BYTE* buffer;
|
||||||
|
UINT32 length;
|
||||||
byte* buffer1 = NULL;
|
byte* buffer1 = NULL;
|
||||||
byte* buffer2 = NULL;
|
byte* buffer2 = NULL;
|
||||||
byte* buffer3 = NULL;
|
byte* buffer3 = NULL;
|
||||||
|
@ -97,35 +97,37 @@ DWORD TsProxySendToServer(handle_t IDL_handle, byte pRpcMessage[], UINT32 count,
|
||||||
totalDataBytes += lengths[2] + 4;
|
totalDataBytes += lengths[2] + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = stream_new(28 + totalDataBytes);
|
length = 28 + totalDataBytes;
|
||||||
|
buffer = (BYTE*) malloc(length);
|
||||||
|
|
||||||
|
s = Stream_New(buffer, length);
|
||||||
|
|
||||||
/* PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE_NR (20 bytes) */
|
/* PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE_NR (20 bytes) */
|
||||||
stream_write(s, &tsg->ChannelContext.ContextType, 4); /* ContextType (4 bytes) */
|
Stream_Write(s, &tsg->ChannelContext.ContextType, 4); /* ContextType (4 bytes) */
|
||||||
stream_write(s, tsg->ChannelContext.ContextUuid, 16); /* ContextUuid (16 bytes) */
|
Stream_Write(s, tsg->ChannelContext.ContextUuid, 16); /* ContextUuid (16 bytes) */
|
||||||
|
|
||||||
stream_write_UINT32_be(s, totalDataBytes); /* totalDataBytes (4 bytes) */
|
Stream_Write_UINT32_BE(s, totalDataBytes); /* totalDataBytes (4 bytes) */
|
||||||
stream_write_UINT32_be(s, numBuffers); /* numBuffers (4 bytes) */
|
Stream_Write_UINT32_BE(s, numBuffers); /* numBuffers (4 bytes) */
|
||||||
|
|
||||||
if (buffer1Length > 0)
|
if (buffer1Length > 0)
|
||||||
stream_write_UINT32_be(s, buffer1Length); /* buffer1Length (4 bytes) */
|
Stream_Write_UINT32_BE(s, buffer1Length); /* buffer1Length (4 bytes) */
|
||||||
if (buffer2Length > 0)
|
if (buffer2Length > 0)
|
||||||
stream_write_UINT32_be(s, buffer2Length); /* buffer2Length (4 bytes) */
|
Stream_Write_UINT32_BE(s, buffer2Length); /* buffer2Length (4 bytes) */
|
||||||
if (buffer3Length > 0)
|
if (buffer3Length > 0)
|
||||||
stream_write_UINT32_be(s, buffer3Length); /* buffer3Length (4 bytes) */
|
Stream_Write_UINT32_BE(s, buffer3Length); /* buffer3Length (4 bytes) */
|
||||||
|
|
||||||
if (buffer1Length > 0)
|
if (buffer1Length > 0)
|
||||||
stream_write(s, buffer1, buffer1Length); /* buffer1 (variable) */
|
Stream_Write(s, buffer1, buffer1Length); /* buffer1 (variable) */
|
||||||
if (buffer2Length > 0)
|
if (buffer2Length > 0)
|
||||||
stream_write(s, buffer2, buffer2Length); /* buffer2 (variable) */
|
Stream_Write(s, buffer2, buffer2Length); /* buffer2 (variable) */
|
||||||
if (buffer3Length > 0)
|
if (buffer3Length > 0)
|
||||||
stream_write(s, buffer3, buffer3Length); /* buffer3 (variable) */
|
Stream_Write(s, buffer3, buffer3Length); /* buffer3 (variable) */
|
||||||
|
|
||||||
stream_seal(s);
|
Stream_Length(s) = Stream_Position(s);
|
||||||
|
|
||||||
length = s->size;
|
status = rpc_write(tsg->rpc, Stream_Buffer(s), Stream_Length(s), TsProxySendToServerOpnum);
|
||||||
status = rpc_write(tsg->rpc, s->data, s->size, TsProxySendToServerOpnum);
|
|
||||||
|
|
||||||
stream_free(s);
|
Stream_Free(s, TRUE);
|
||||||
|
|
||||||
if (status <= 0)
|
if (status <= 0)
|
||||||
{
|
{
|
||||||
|
@ -248,7 +250,7 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg)
|
||||||
Pointer = *((UINT32*) &buffer[offset]); /* Ptr */
|
Pointer = *((UINT32*) &buffer[offset]); /* Ptr */
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
|
||||||
if (Pointer == 0x0002000C)
|
if ((Pointer == 0x0002000C) || (Pointer == 0x00020008))
|
||||||
{
|
{
|
||||||
/* Not sure exactly what this is */
|
/* Not sure exactly what this is */
|
||||||
offset += 4; /* 0x00000001 (4 bytes) */
|
offset += 4; /* 0x00000001 (4 bytes) */
|
||||||
|
@ -257,7 +259,7 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg)
|
||||||
offset += 4; /* 0x00000001 (4 bytes) */
|
offset += 4; /* 0x00000001 (4 bytes) */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packetCapsResponse->pktQuarEncResponse.certChainLen)
|
if (packetCapsResponse->pktQuarEncResponse.certChainLen > 0)
|
||||||
{
|
{
|
||||||
Pointer = *((UINT32*) &buffer[offset]); /* Ptr (4 bytes): 0x00020014 */
|
Pointer = *((UINT32*) &buffer[offset]); /* Ptr (4 bytes): 0x00020014 */
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
@ -267,12 +269,10 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg)
|
||||||
count = *((UINT32*) &buffer[offset]); /* ActualCount (4 bytes) */
|
count = *((UINT32*) &buffer[offset]); /* ActualCount (4 bytes) */
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
|
||||||
freerdp_hexdump(&buffer[offset], (count * 2));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CertChainData is a wide character string, and the count is
|
* CertChainData is a wide character string, and the count is
|
||||||
* given in characters excluding the null terminator, therefore:
|
* given in characters excluding the null terminator, therefore:
|
||||||
* size = ((count + 1) * 2)
|
* size = (count * 2)
|
||||||
*/
|
*/
|
||||||
offset += (count * 2); /* CertChainData */
|
offset += (count * 2); /* CertChainData */
|
||||||
|
|
||||||
|
@ -338,11 +338,9 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg)
|
||||||
CopyMemory(tsg->TunnelContext.ContextUuid, &buffer[offset + 4], 16); /* ContextUuid */
|
CopyMemory(tsg->TunnelContext.ContextUuid, &buffer[offset + 4], 16); /* ContextUuid */
|
||||||
offset += 20;
|
offset += 20;
|
||||||
|
|
||||||
/* TODO: trailing bytes */
|
|
||||||
|
|
||||||
#ifdef WITH_DEBUG_TSG
|
#ifdef WITH_DEBUG_TSG
|
||||||
printf("TSG TunnelContext:\n");
|
printf("TSG TunnelContext:\n");
|
||||||
freerdp_hexdump((void*) &tsg->TunnelContext, 20);
|
winpr_HexDump((void*) &tsg->TunnelContext, 20);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -376,7 +374,7 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg)
|
||||||
/*
|
/*
|
||||||
* CertChainData is a wide character string, and the count is
|
* CertChainData is a wide character string, and the count is
|
||||||
* given in characters excluding the null terminator, therefore:
|
* given in characters excluding the null terminator, therefore:
|
||||||
* size = ((count + 1) * 2)
|
* size = (count * 2)
|
||||||
*/
|
*/
|
||||||
offset += (count * 2); /* CertChainData */
|
offset += (count * 2); /* CertChainData */
|
||||||
|
|
||||||
|
@ -425,11 +423,9 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg)
|
||||||
CopyMemory(tsg->TunnelContext.ContextUuid, &buffer[offset + 4], 16); /* ContextUuid */
|
CopyMemory(tsg->TunnelContext.ContextUuid, &buffer[offset + 4], 16); /* ContextUuid */
|
||||||
offset += 20;
|
offset += 20;
|
||||||
|
|
||||||
/* TODO: trailing bytes */
|
|
||||||
|
|
||||||
#ifdef WITH_DEBUG_TSG
|
#ifdef WITH_DEBUG_TSG
|
||||||
printf("TSG TunnelContext:\n");
|
printf("TSG TunnelContext:\n");
|
||||||
freerdp_hexdump((void*) &tsg->TunnelContext, 20);
|
winpr_HexDump((void*) &tsg->TunnelContext, 20);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -480,7 +476,7 @@ BOOL TsProxyCreateTunnel(rdpTsg* tsg, PTSG_PACKET tsgPacket, PTSG_PACKET* tsgPac
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL TsProxyAuthorizeTunnelWriteRequest(rdpTsg* tsg)
|
BOOL TsProxyAuthorizeTunnelWriteRequest(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext)
|
||||||
{
|
{
|
||||||
UINT32 pad;
|
UINT32 pad;
|
||||||
int status;
|
int status;
|
||||||
|
@ -488,6 +484,7 @@ BOOL TsProxyAuthorizeTunnelWriteRequest(rdpTsg* tsg)
|
||||||
UINT32 count;
|
UINT32 count;
|
||||||
UINT32 length;
|
UINT32 length;
|
||||||
UINT32 offset;
|
UINT32 offset;
|
||||||
|
CONTEXT_HANDLE* handle;
|
||||||
rdpRpc* rpc = tsg->rpc;
|
rdpRpc* rpc = tsg->rpc;
|
||||||
|
|
||||||
count = _wcslen(tsg->MachineName) + 1;
|
count = _wcslen(tsg->MachineName) + 1;
|
||||||
|
@ -500,8 +497,9 @@ BOOL TsProxyAuthorizeTunnelWriteRequest(rdpTsg* tsg)
|
||||||
buffer = (BYTE*) malloc(length);
|
buffer = (BYTE*) malloc(length);
|
||||||
|
|
||||||
/* TunnelContext */
|
/* TunnelContext */
|
||||||
CopyMemory(&buffer[0], &tsg->TunnelContext.ContextType, 4); /* ContextType */
|
handle = (CONTEXT_HANDLE*) tunnelContext;
|
||||||
CopyMemory(&buffer[4], tsg->TunnelContext.ContextUuid, 16); /* ContextUuid */
|
CopyMemory(&buffer[0], &handle->ContextType, 4); /* ContextType */
|
||||||
|
CopyMemory(&buffer[4], handle->ContextUuid, 16); /* ContextUuid */
|
||||||
|
|
||||||
/* 4-byte alignment */
|
/* 4-byte alignment */
|
||||||
|
|
||||||
|
@ -620,8 +618,6 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg)
|
||||||
|
|
||||||
offset += SizeValue; /* ResponseData */
|
offset += SizeValue; /* ResponseData */
|
||||||
|
|
||||||
/* TODO: trailing bytes */
|
|
||||||
|
|
||||||
rpc_client_receive_pool_return(rpc, pdu);
|
rpc_client_receive_pool_return(rpc, pdu);
|
||||||
free(packetResponse);
|
free(packetResponse);
|
||||||
free(packet);
|
free(packet);
|
||||||
|
@ -645,7 +641,7 @@ BOOL TsProxyAuthorizeTunnel(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunn
|
||||||
|
|
||||||
DEBUG_TSG("TsProxyAuthorizeTunnel");
|
DEBUG_TSG("TsProxyAuthorizeTunnel");
|
||||||
|
|
||||||
if (!TsProxyAuthorizeTunnelWriteRequest(tsg))
|
if (!TsProxyAuthorizeTunnelWriteRequest(tsg, tunnelContext))
|
||||||
{
|
{
|
||||||
printf("TsProxyAuthorizeTunnel: error writing request\n");
|
printf("TsProxyAuthorizeTunnel: error writing request\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -660,19 +656,21 @@ BOOL TsProxyAuthorizeTunnel(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunn
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL TsProxyMakeTunnelCallWriteRequest(rdpTsg* tsg, unsigned long procId)
|
BOOL TsProxyMakeTunnelCallWriteRequest(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext, unsigned long procId)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
BYTE* buffer;
|
BYTE* buffer;
|
||||||
UINT32 length;
|
UINT32 length;
|
||||||
|
CONTEXT_HANDLE* handle;
|
||||||
rdpRpc* rpc = tsg->rpc;
|
rdpRpc* rpc = tsg->rpc;
|
||||||
|
|
||||||
length = 40;
|
length = 40;
|
||||||
buffer = (BYTE*) malloc(length);
|
buffer = (BYTE*) malloc(length);
|
||||||
|
|
||||||
/* TunnelContext */
|
/* TunnelContext */
|
||||||
CopyMemory(&buffer[0], &tsg->TunnelContext.ContextType, 4); /* ContextType */
|
handle = (CONTEXT_HANDLE*) tunnelContext;
|
||||||
CopyMemory(&buffer[4], tsg->TunnelContext.ContextUuid, 16); /* ContextUuid */
|
CopyMemory(&buffer[0], &handle->ContextType, 4); /* ContextType */
|
||||||
|
CopyMemory(&buffer[4], handle->ContextUuid, 16); /* ContextUuid */
|
||||||
|
|
||||||
*((UINT32*) &buffer[20]) = procId; /* ProcId */
|
*((UINT32*) &buffer[20]) = procId; /* ProcId */
|
||||||
|
|
||||||
|
@ -718,7 +716,7 @@ BOOL TsProxyMakeTunnelCall(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunne
|
||||||
|
|
||||||
DEBUG_TSG("TsProxyMakeTunnelCall");
|
DEBUG_TSG("TsProxyMakeTunnelCall");
|
||||||
|
|
||||||
if (!TsProxyMakeTunnelCallWriteRequest(tsg, procId))
|
if (!TsProxyMakeTunnelCallWriteRequest(tsg, tunnelContext, procId))
|
||||||
{
|
{
|
||||||
printf("TsProxyMakeTunnelCall: error writing request\n");
|
printf("TsProxyMakeTunnelCall: error writing request\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -733,19 +731,20 @@ BOOL TsProxyMakeTunnelCall(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunne
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL TsProxyCreateChannelWriteRequest(rdpTsg* tsg)
|
BOOL TsProxyCreateChannelWriteRequest(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
UINT32 count;
|
UINT32 count;
|
||||||
BYTE* buffer;
|
BYTE* buffer;
|
||||||
UINT32 length;
|
UINT32 length;
|
||||||
|
CONTEXT_HANDLE* handle;
|
||||||
rdpRpc* rpc = tsg->rpc;
|
rdpRpc* rpc = tsg->rpc;
|
||||||
|
|
||||||
count = _wcslen(tsg->Hostname) + 1;
|
count = _wcslen(tsg->Hostname) + 1;
|
||||||
|
|
||||||
#ifdef WITH_DEBUG_TSG
|
#ifdef WITH_DEBUG_TSG
|
||||||
printf("ResourceName:\n");
|
printf("ResourceName:\n");
|
||||||
freerdp_hexdump((BYTE*) tsg->Hostname, (count - 1) * 2);
|
winpr_HexDump((BYTE*) tsg->Hostname, (count - 1) * 2);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -754,8 +753,9 @@ BOOL TsProxyCreateChannelWriteRequest(rdpTsg* tsg)
|
||||||
buffer = (BYTE*) malloc(length);
|
buffer = (BYTE*) malloc(length);
|
||||||
|
|
||||||
/* TunnelContext */
|
/* TunnelContext */
|
||||||
CopyMemory(&buffer[0], &tsg->TunnelContext.ContextType, 4); /* ContextType */
|
handle = (CONTEXT_HANDLE*) tunnelContext;
|
||||||
CopyMemory(&buffer[4], tsg->TunnelContext.ContextUuid, 16); /* ContextUuid */
|
CopyMemory(&buffer[0], &handle->ContextType, 4); /* ContextType */
|
||||||
|
CopyMemory(&buffer[4], handle->ContextUuid, 16); /* ContextUuid */
|
||||||
|
|
||||||
/* TSENDPOINTINFO */
|
/* TSENDPOINTINFO */
|
||||||
|
|
||||||
|
@ -811,11 +811,9 @@ BOOL TsProxyCreateChannelReadResponse(rdpTsg* tsg)
|
||||||
CopyMemory(&tsg->ChannelContext.ContextType, &buffer[offset], 4); /* ContextType (4 bytes) */
|
CopyMemory(&tsg->ChannelContext.ContextType, &buffer[offset], 4); /* ContextType (4 bytes) */
|
||||||
CopyMemory(tsg->ChannelContext.ContextUuid, &buffer[offset + 4], 16); /* ContextUuid (16 bytes) */
|
CopyMemory(tsg->ChannelContext.ContextUuid, &buffer[offset + 4], 16); /* ContextUuid (16 bytes) */
|
||||||
|
|
||||||
/* TODO: trailing bytes */
|
|
||||||
|
|
||||||
#ifdef WITH_DEBUG_TSG
|
#ifdef WITH_DEBUG_TSG
|
||||||
printf("ChannelContext:\n");
|
printf("ChannelContext:\n");
|
||||||
freerdp_hexdump((void*) &tsg->ChannelContext, 20);
|
winpr_HexDump((void*) &tsg->ChannelContext, 20);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -840,7 +838,7 @@ BOOL TsProxyCreateChannel(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnel
|
||||||
|
|
||||||
DEBUG_TSG("TsProxyCreateChannel");
|
DEBUG_TSG("TsProxyCreateChannel");
|
||||||
|
|
||||||
if (!TsProxyCreateChannelWriteRequest(tsg))
|
if (!TsProxyCreateChannelWriteRequest(tsg, tunnelContext))
|
||||||
{
|
{
|
||||||
printf("TsProxyCreateChannel: error writing request\n");
|
printf("TsProxyCreateChannel: error writing request\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -907,6 +905,12 @@ BOOL TsProxyCloseChannelReadResponse(rdpTsg* tsg)
|
||||||
|
|
||||||
HRESULT TsProxyCloseChannel(rdpTsg* tsg, PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE* context)
|
HRESULT TsProxyCloseChannel(rdpTsg* tsg, PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE* context)
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* HRESULT TsProxyCloseChannel(
|
||||||
|
* [in, out] PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE* context
|
||||||
|
* );
|
||||||
|
*/
|
||||||
|
|
||||||
DEBUG_TSG("TsProxyCloseChannel");
|
DEBUG_TSG("TsProxyCloseChannel");
|
||||||
|
|
||||||
if (!TsProxyCloseChannelWriteRequest(tsg, context))
|
if (!TsProxyCloseChannelWriteRequest(tsg, context))
|
||||||
|
@ -976,6 +980,12 @@ BOOL TsProxyCloseTunnelReadResponse(rdpTsg* tsg)
|
||||||
|
|
||||||
HRESULT TsProxyCloseTunnel(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_SERIALIZE* context)
|
HRESULT TsProxyCloseTunnel(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_SERIALIZE* context)
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* HRESULT TsProxyCloseTunnel(
|
||||||
|
* [in, out] PTUNNEL_CONTEXT_HANDLE_SERIALIZE* context
|
||||||
|
* );
|
||||||
|
*/
|
||||||
|
|
||||||
DEBUG_TSG("TsProxyCloseTunnel");
|
DEBUG_TSG("TsProxyCloseTunnel");
|
||||||
|
|
||||||
if (!TsProxyCloseTunnelWriteRequest(tsg, context))
|
if (!TsProxyCloseTunnelWriteRequest(tsg, context))
|
||||||
|
@ -1156,7 +1166,7 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port)
|
||||||
* section 3.6.2.1.1 and SHOULD end the protocol when the connection has been idle for the specified Idle Timeout Value.
|
* section 3.6.2.1.1 and SHOULD end the protocol when the connection has been idle for the specified Idle Timeout Value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!TsProxyAuthorizeTunnel(tsg, NULL, NULL, NULL))
|
if (!TsProxyAuthorizeTunnel(tsg, &tsg->TunnelContext, NULL, NULL))
|
||||||
{
|
{
|
||||||
tsg->state = TSG_STATE_TUNNEL_CLOSE_PENDING;
|
tsg->state = TSG_STATE_TUNNEL_CLOSE_PENDING;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1172,7 +1182,7 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!TsProxyMakeTunnelCall(tsg, NULL, TSG_TUNNEL_CALL_ASYNC_MSG_REQUEST, NULL, NULL))
|
if (!TsProxyMakeTunnelCall(tsg, &tsg->TunnelContext, TSG_TUNNEL_CALL_ASYNC_MSG_REQUEST, NULL, NULL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1191,7 +1201,7 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port)
|
||||||
* out parameter. This Channel Context Handle is used for subsequent channel-related calls.
|
* out parameter. This Channel Context Handle is used for subsequent channel-related calls.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!TsProxyCreateChannel(tsg, NULL, NULL, NULL, NULL))
|
if (!TsProxyCreateChannel(tsg, &tsg->TunnelContext, NULL, NULL, NULL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
tsg->state = TSG_STATE_CHANNEL_CREATED;
|
tsg->state = TSG_STATE_CHANNEL_CREATED;
|
||||||
|
@ -1249,7 +1259,7 @@ BOOL tsg_disconnect(rdpTsg* tsg)
|
||||||
if (!TsProxyCloseChannel(tsg, NULL))
|
if (!TsProxyCloseChannel(tsg, NULL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!TsProxyMakeTunnelCall(tsg, NULL, TSG_TUNNEL_CANCEL_ASYNC_MSG_REQUEST, NULL, NULL))
|
if (!TsProxyMakeTunnelCall(tsg, &tsg->TunnelContext, TSG_TUNNEL_CANCEL_ASYNC_MSG_REQUEST, NULL, NULL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!TsProxyCloseTunnel(tsg, NULL))
|
if (!TsProxyCloseTunnel(tsg, NULL))
|
||||||
|
|
|
@ -37,7 +37,6 @@ typedef struct rdp_tsg rdpTsg;
|
||||||
#include <freerdp/types.h>
|
#include <freerdp/types.h>
|
||||||
#include <freerdp/settings.h>
|
#include <freerdp/settings.h>
|
||||||
|
|
||||||
#include <freerdp/utils/stream.h>
|
|
||||||
#include <freerdp/utils/debug.h>
|
#include <freerdp/utils/debug.h>
|
||||||
|
|
||||||
enum _TSG_STATE
|
enum _TSG_STATE
|
||||||
|
|
Loading…
Reference in New Issue