mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Merge pull request #4364 from akallabeth/gateway_refactor
Gateway refactor
This commit is contained in:
@@ -38,6 +38,8 @@
|
||||
|
||||
#define TAG FREERDP_TAG("core.gateway.http")
|
||||
|
||||
#define RESPONSE_SIZE_LIMIT 64 * 1024 * 1024
|
||||
|
||||
static char* string_strnstr(const char* str1, const char* str2, size_t slen)
|
||||
{
|
||||
char c, sc;
|
||||
@@ -75,12 +77,7 @@ static BOOL strings_equals_nocase(void* obj1, void* obj2)
|
||||
return _stricmp(obj1, obj2) == 0;
|
||||
}
|
||||
|
||||
static void string_free(void* obj1)
|
||||
{
|
||||
free(obj1);
|
||||
}
|
||||
|
||||
HttpContext* http_context_new()
|
||||
HttpContext* http_context_new(void)
|
||||
{
|
||||
return (HttpContext*) calloc(1, sizeof(HttpContext));
|
||||
}
|
||||
@@ -256,7 +253,7 @@ BOOL http_request_set_transfer_encoding(HttpRequest* request, const char* Transf
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char* http_encode_body_line(char* param, char* value)
|
||||
static char* http_encode_body_line(const char* param, const char* value)
|
||||
{
|
||||
char* line;
|
||||
int length;
|
||||
@@ -270,47 +267,50 @@ char* http_encode_body_line(char* param, char* value)
|
||||
return line;
|
||||
}
|
||||
|
||||
char* http_encode_content_length_line(int ContentLength)
|
||||
static char* http_encode_content_length_line(int ContentLength)
|
||||
{
|
||||
const char* key = "Content-Length:";
|
||||
char* line;
|
||||
int length;
|
||||
char str[32];
|
||||
_itoa_s(ContentLength, str, sizeof(str), 10);
|
||||
length = strlen("Content-Length") + strlen(str) + 2;
|
||||
length = strlen(key) + strlen(str) + 2;
|
||||
line = (char*) malloc(length + 1);
|
||||
|
||||
if (!line)
|
||||
return NULL;
|
||||
|
||||
sprintf_s(line, length + 1, "Content-Length: %s", str);
|
||||
sprintf_s(line, length + 1, "%s %s", key, str);
|
||||
return line;
|
||||
}
|
||||
|
||||
char* http_encode_header_line(char* Method, char* URI)
|
||||
static char* http_encode_header_line(const char* Method, const char* URI)
|
||||
{
|
||||
const char* key = "HTTP/1.1";
|
||||
char* line;
|
||||
int length;
|
||||
length = strlen("HTTP/1.1") + strlen(Method) + strlen(URI) + 2;
|
||||
length = strlen(key) + strlen(Method) + strlen(URI) + 2;
|
||||
line = (char*)malloc(length + 1);
|
||||
|
||||
if (!line)
|
||||
return NULL;
|
||||
|
||||
sprintf_s(line, length + 1, "%s %s HTTP/1.1", Method, URI);
|
||||
sprintf_s(line, length + 1, "%s %s %s", Method, URI, key);
|
||||
return line;
|
||||
}
|
||||
|
||||
char* http_encode_authorization_line(char* AuthScheme, char* AuthParam)
|
||||
static char* http_encode_authorization_line(const char* AuthScheme, const char* AuthParam)
|
||||
{
|
||||
const char* key = "Authorization:";
|
||||
char* line;
|
||||
int length;
|
||||
length = strlen("Authorization") + strlen(AuthScheme) + strlen(AuthParam) + 3;
|
||||
length = strlen(key) + strlen(AuthScheme) + strlen(AuthParam) + 3;
|
||||
line = (char*) malloc(length + 1);
|
||||
|
||||
if (!line)
|
||||
return NULL;
|
||||
|
||||
sprintf_s(line, length + 1, "Authorization: %s %s", AuthScheme, AuthParam);
|
||||
sprintf_s(line, length + 1, "%s %s %s", key, AuthScheme, AuthParam);
|
||||
return line;
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ out_free:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HttpRequest* http_request_new()
|
||||
HttpRequest* http_request_new(void)
|
||||
{
|
||||
return (HttpRequest*) calloc(1, sizeof(HttpRequest));
|
||||
}
|
||||
@@ -435,7 +435,7 @@ void http_request_free(HttpRequest* request)
|
||||
free(request);
|
||||
}
|
||||
|
||||
BOOL http_response_parse_header_status_line(HttpResponse* response, char* status_line)
|
||||
static BOOL http_response_parse_header_status_line(HttpResponse* response, char* status_line)
|
||||
{
|
||||
char* separator = NULL;
|
||||
char* status_code;
|
||||
@@ -464,7 +464,7 @@ BOOL http_response_parse_header_status_line(HttpResponse* response, char* status
|
||||
|
||||
response->StatusCode = strtol(status_code, NULL, 0);
|
||||
}
|
||||
response->ReasonPhrase = _strdup(reason_phrase);
|
||||
response->ReasonPhrase = reason_phrase;
|
||||
|
||||
if (!response->ReasonPhrase)
|
||||
return FALSE;
|
||||
@@ -473,15 +473,16 @@ BOOL http_response_parse_header_status_line(HttpResponse* response, char* status
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL http_response_parse_header_field(HttpResponse* response, char* name, char* value)
|
||||
static BOOL http_response_parse_header_field(HttpResponse* response, const char* name,
|
||||
const char* value)
|
||||
{
|
||||
BOOL status = TRUE;
|
||||
|
||||
if (_stricmp(name, "Content-Length") == 0)
|
||||
{
|
||||
long val;
|
||||
unsigned long long val;
|
||||
errno = 0;
|
||||
val = strtol(value, NULL, 0);
|
||||
val = _strtoui64(value, NULL, 0);
|
||||
|
||||
if ((errno != 0) || (val < 0) || (val > INT32_MAX))
|
||||
return FALSE;
|
||||
@@ -490,7 +491,7 @@ BOOL http_response_parse_header_field(HttpResponse* response, char* name, char*
|
||||
}
|
||||
else if (_stricmp(name, "Content-Type") == 0)
|
||||
{
|
||||
response->ContentType = _strdup(value);
|
||||
response->ContentType = value;
|
||||
|
||||
if (!response->ContentType)
|
||||
return FALSE;
|
||||
@@ -498,8 +499,8 @@ BOOL http_response_parse_header_field(HttpResponse* response, char* name, char*
|
||||
else if (_stricmp(name, "WWW-Authenticate") == 0)
|
||||
{
|
||||
char* separator = NULL;
|
||||
char* authScheme = NULL;
|
||||
char* authValue = NULL;
|
||||
const char* authScheme = NULL;
|
||||
const char* authValue = NULL;
|
||||
separator = strchr(value, ' ');
|
||||
|
||||
if (separator)
|
||||
@@ -511,21 +512,17 @@ BOOL http_response_parse_header_field(HttpResponse* response, char* name, char*
|
||||
* opaque="5ccc069c403ebaf9f0171e9517f40e41"
|
||||
*/
|
||||
*separator = '\0';
|
||||
authScheme = _strdup(value);
|
||||
authValue = _strdup(separator + 1);
|
||||
authScheme = value;
|
||||
authValue = separator + 1;
|
||||
|
||||
if (!authScheme || !authValue)
|
||||
{
|
||||
free(authScheme);
|
||||
free(authValue);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*separator = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
authScheme = _strdup(value);
|
||||
authScheme = value;
|
||||
|
||||
if (!authScheme)
|
||||
return FALSE;
|
||||
@@ -533,16 +530,16 @@ BOOL http_response_parse_header_field(HttpResponse* response, char* name, char*
|
||||
authValue = NULL;
|
||||
}
|
||||
|
||||
status = ListDictionary_Add(response->Authenticates, authScheme, authValue);
|
||||
status = ListDictionary_Add(response->Authenticates, (void*)authScheme, (void*)authValue);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
BOOL http_response_parse_header(HttpResponse* response)
|
||||
static BOOL http_response_parse_header(HttpResponse* response)
|
||||
{
|
||||
char c;
|
||||
int count;
|
||||
size_t count;
|
||||
char* line;
|
||||
char* name;
|
||||
char* value;
|
||||
@@ -624,39 +621,134 @@ void http_response_print(HttpResponse* response)
|
||||
|
||||
HttpResponse* http_response_recv(rdpTls* tls)
|
||||
{
|
||||
wStream* s;
|
||||
int size;
|
||||
int count;
|
||||
int status;
|
||||
size_t size;
|
||||
size_t position;
|
||||
char* line;
|
||||
char* buffer;
|
||||
char* header = NULL;
|
||||
char* payload;
|
||||
int bodyLength;
|
||||
int payloadOffset;
|
||||
size_t bodyLength;
|
||||
size_t payloadOffset;
|
||||
HttpResponse* response;
|
||||
size = 2048;
|
||||
payload = NULL;
|
||||
payloadOffset = 0;
|
||||
s = Stream_New(NULL, size);
|
||||
|
||||
if (!s)
|
||||
goto out_free;
|
||||
|
||||
buffer = (char*) Stream_Buffer(s);
|
||||
response = http_response_new();
|
||||
|
||||
if (!response)
|
||||
goto out_free;
|
||||
return NULL;
|
||||
|
||||
response->ContentLength = 0;
|
||||
|
||||
while (TRUE)
|
||||
while (!payloadOffset)
|
||||
{
|
||||
while (!payloadOffset)
|
||||
int status = BIO_read(tls->bio, Stream_Pointer(response->data),
|
||||
Stream_Capacity(response->data) - Stream_GetPosition(response->data));
|
||||
|
||||
if (status <= 0)
|
||||
{
|
||||
status = BIO_read(tls->bio, Stream_Pointer(s), Stream_Capacity(s) - Stream_GetPosition(s));
|
||||
if (!BIO_should_retry(tls->bio))
|
||||
goto out_error;
|
||||
|
||||
USleep(100);
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef HAVE_VALGRIND_MEMCHECK_H
|
||||
VALGRIND_MAKE_MEM_DEFINED(Stream_Pointer(s), status);
|
||||
#endif
|
||||
Stream_Seek(response->data, status);
|
||||
|
||||
if (Stream_GetRemainingLength(response->data) < 1024)
|
||||
{
|
||||
if (!Stream_EnsureRemainingCapacity(response->data, 1024))
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
position = Stream_GetPosition(response->data);
|
||||
|
||||
if (position > RESPONSE_SIZE_LIMIT)
|
||||
{
|
||||
WLog_ERR(TAG, "Request header too large! (%"PRIdz" bytes) Aborting!", bodyLength);
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
if (position >= 4)
|
||||
{
|
||||
char* buffer = Stream_Buffer(response->data);
|
||||
const char* line = string_strnstr(buffer, "\r\n\r\n", position);
|
||||
|
||||
if (line)
|
||||
payloadOffset = (line - buffer) + 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (payloadOffset)
|
||||
{
|
||||
size_t count = 0;
|
||||
char* buffer = Stream_Buffer(response->data);
|
||||
char* line = Stream_Buffer(response->data);
|
||||
|
||||
while ((line = string_strnstr(line, "\r\n", payloadOffset - (line - buffer) - 2)))
|
||||
{
|
||||
line += 2;
|
||||
count++;
|
||||
}
|
||||
|
||||
response->count = count;
|
||||
|
||||
if (count)
|
||||
{
|
||||
response->lines = (char**) calloc(response->count, sizeof(char*));
|
||||
|
||||
if (!response->lines)
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
buffer[payloadOffset - 1] = '\0';
|
||||
buffer[payloadOffset - 2] = '\0';
|
||||
count = 0;
|
||||
line = strtok(buffer, "\r\n");
|
||||
|
||||
while (line && response->lines)
|
||||
{
|
||||
response->lines[count] = line;
|
||||
|
||||
if (!response->lines[count])
|
||||
goto out_error;
|
||||
|
||||
line = strtok(NULL, "\r\n");
|
||||
count++;
|
||||
}
|
||||
|
||||
if (!http_response_parse_header(response))
|
||||
goto out_error;
|
||||
|
||||
response->BodyLength = Stream_GetPosition(response->data) - payloadOffset;
|
||||
bodyLength = 0; /* expected body length */
|
||||
|
||||
if (response->ContentType)
|
||||
{
|
||||
if (_stricmp(response->ContentType, "application/rpc") != 0)
|
||||
bodyLength = response->ContentLength;
|
||||
else if (_stricmp(response->ContentType, "text/plain") == 0)
|
||||
bodyLength = response->ContentLength;
|
||||
else if (_stricmp(response->ContentType, "text/html") == 0)
|
||||
bodyLength = response->ContentLength;
|
||||
}
|
||||
else
|
||||
bodyLength = response->BodyLength;
|
||||
|
||||
if (bodyLength > RESPONSE_SIZE_LIMIT)
|
||||
{
|
||||
WLog_ERR(TAG, "Expected request body too large! (%"PRIdz" bytes) Aborting!", bodyLength);
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
/* Fetch remaining body! */
|
||||
while (response->BodyLength < bodyLength)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(response->data, bodyLength - response->BodyLength))
|
||||
goto out_error;
|
||||
|
||||
status = BIO_read(tls->bio, Stream_Pointer(response->data), bodyLength - response->BodyLength);
|
||||
|
||||
if (status <= 0)
|
||||
{
|
||||
@@ -667,161 +759,36 @@ HttpResponse* http_response_recv(rdpTls* tls)
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef HAVE_VALGRIND_MEMCHECK_H
|
||||
VALGRIND_MAKE_MEM_DEFINED(Stream_Pointer(s), status);
|
||||
#endif
|
||||
Stream_Seek(s, status);
|
||||
Stream_Seek(response->data, status);
|
||||
response->BodyLength += status;
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 1024)
|
||||
if (response->BodyLength > RESPONSE_SIZE_LIMIT)
|
||||
{
|
||||
if (!Stream_EnsureRemainingCapacity(s, 1024))
|
||||
goto out_error;
|
||||
|
||||
buffer = (char*) Stream_Buffer(s);
|
||||
payload = &buffer[payloadOffset];
|
||||
}
|
||||
|
||||
position = Stream_GetPosition(s);
|
||||
|
||||
if (position >= 4)
|
||||
{
|
||||
line = string_strnstr(buffer, "\r\n\r\n", position);
|
||||
|
||||
if (line)
|
||||
{
|
||||
payloadOffset = (line - buffer) + 4;
|
||||
payload = &buffer[payloadOffset];
|
||||
}
|
||||
WLog_ERR(TAG, "Request body too large! (%"PRIdz" bytes) Aborting!", response->BodyLength);
|
||||
goto out_error;
|
||||
}
|
||||
}
|
||||
|
||||
if (payloadOffset)
|
||||
if (response->BodyLength > 0)
|
||||
{
|
||||
count = 0;
|
||||
line = buffer;
|
||||
position = Stream_GetPosition(s);
|
||||
|
||||
while ((line = string_strnstr(line, "\r\n", payloadOffset - (line - buffer) - 2)))
|
||||
{
|
||||
line += 2;
|
||||
count++;
|
||||
}
|
||||
|
||||
response->count = count;
|
||||
|
||||
if (count)
|
||||
{
|
||||
response->lines = (char**) calloc(response->count, sizeof(char*));
|
||||
|
||||
if (!response->lines)
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
header = (char*) malloc(payloadOffset);
|
||||
|
||||
if (!header)
|
||||
goto out_error;
|
||||
|
||||
CopyMemory(header, buffer, payloadOffset);
|
||||
header[payloadOffset - 1] = '\0';
|
||||
header[payloadOffset - 2] = '\0';
|
||||
count = 0;
|
||||
line = strtok(header, "\r\n");
|
||||
|
||||
while (line && response->lines)
|
||||
{
|
||||
response->lines[count] = _strdup(line);
|
||||
|
||||
if (!response->lines[count])
|
||||
goto out_error;
|
||||
|
||||
line = strtok(NULL, "\r\n");
|
||||
count++;
|
||||
}
|
||||
|
||||
if (!http_response_parse_header(response))
|
||||
goto out_error;
|
||||
|
||||
response->BodyLength = Stream_GetPosition(s) - payloadOffset;
|
||||
bodyLength = 0; /* expected body length */
|
||||
|
||||
if (response->ContentType)
|
||||
{
|
||||
if (_stricmp(response->ContentType, "application/rpc") != 0)
|
||||
bodyLength = response->ContentLength;
|
||||
else if (_stricmp(response->ContentType, "text/plain") == 0)
|
||||
bodyLength = response->ContentLength;
|
||||
else if (_stricmp(response->ContentType, "text/html") == 0)
|
||||
bodyLength = response->ContentLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
bodyLength = response->BodyLength;
|
||||
}
|
||||
|
||||
// Fetch remaining body!
|
||||
while (response->BodyLength < bodyLength)
|
||||
{
|
||||
if (!Stream_EnsureRemainingCapacity(s, bodyLength - response->BodyLength))
|
||||
goto out_error;
|
||||
|
||||
status = BIO_read(tls->bio, Stream_Pointer(s), bodyLength - response->BodyLength);
|
||||
|
||||
if (status <= 0)
|
||||
{
|
||||
if (!BIO_should_retry(tls->bio))
|
||||
goto out_error;
|
||||
|
||||
USleep(100);
|
||||
continue;
|
||||
}
|
||||
|
||||
Stream_Seek(s, status);
|
||||
response->BodyLength += status;
|
||||
}
|
||||
|
||||
if (response->BodyLength > 0)
|
||||
{
|
||||
response->BodyContent = (BYTE*) malloc(response->BodyLength);
|
||||
|
||||
if (!response->BodyContent)
|
||||
goto out_error;
|
||||
|
||||
CopyMemory(response->BodyContent, payload, response->BodyLength);
|
||||
response->BodyLength = bodyLength;
|
||||
}
|
||||
|
||||
if (bodyLength != response->BodyLength)
|
||||
{
|
||||
WLog_WARN(TAG, "http_response_recv: %s unexpected body length: actual: %d, expected: %d",
|
||||
response->ContentType, bodyLength, response->BodyLength);
|
||||
}
|
||||
|
||||
break;
|
||||
response->BodyContent = &(Stream_Buffer(response->data))[payloadOffset];
|
||||
response->BodyLength = bodyLength;
|
||||
}
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 1024)
|
||||
if (bodyLength != response->BodyLength)
|
||||
{
|
||||
if (!Stream_EnsureRemainingCapacity(s, 1024))
|
||||
goto out_error;
|
||||
|
||||
buffer = (char*) Stream_Buffer(s);
|
||||
payload = &buffer[payloadOffset];
|
||||
WLog_WARN(TAG, "http_response_recv: %s unexpected body length: actual: %d, expected: %d",
|
||||
response->ContentType, bodyLength, response->BodyLength);
|
||||
}
|
||||
}
|
||||
|
||||
free(header);
|
||||
Stream_Free(s, TRUE);
|
||||
return response;
|
||||
out_error:
|
||||
http_response_free(response);
|
||||
free(header);
|
||||
out_free:
|
||||
Stream_Free(s, TRUE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HttpResponse* http_response_new()
|
||||
HttpResponse* http_response_new(void)
|
||||
{
|
||||
HttpResponse* response = (HttpResponse*) calloc(1, sizeof(HttpResponse));
|
||||
|
||||
@@ -831,39 +798,28 @@ HttpResponse* http_response_new()
|
||||
response->Authenticates = ListDictionary_New(FALSE);
|
||||
|
||||
if (!response->Authenticates)
|
||||
{
|
||||
free(response);
|
||||
return NULL;
|
||||
}
|
||||
goto fail;
|
||||
|
||||
response->data = Stream_New(NULL, 2048);
|
||||
|
||||
if (!response->data)
|
||||
goto fail;
|
||||
|
||||
ListDictionary_KeyObject(response->Authenticates)->fnObjectEquals = strings_equals_nocase;
|
||||
ListDictionary_KeyObject(response->Authenticates)->fnObjectFree = string_free;
|
||||
ListDictionary_ValueObject(response->Authenticates)->fnObjectEquals = strings_equals_nocase;
|
||||
ListDictionary_ValueObject(response->Authenticates)->fnObjectFree = string_free;
|
||||
return response;
|
||||
fail:
|
||||
http_response_free(response);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void http_response_free(HttpResponse* response)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!response)
|
||||
return;
|
||||
|
||||
if (response->lines)
|
||||
for (i = 0; i < response->count; i++)
|
||||
free(response->lines[i]);
|
||||
|
||||
free(response->lines);
|
||||
free(response->ReasonPhrase);
|
||||
free(response->ContentType);
|
||||
ListDictionary_Free(response->Authenticates);
|
||||
|
||||
if (response->BodyContent)
|
||||
{
|
||||
free(response->BodyContent);
|
||||
response->BodyContent = NULL;
|
||||
}
|
||||
|
||||
Stream_Free(response->data, TRUE);
|
||||
free(response);
|
||||
}
|
||||
|
||||
@@ -95,19 +95,20 @@ FREERDP_LOCAL void http_request_free(HttpRequest* request);
|
||||
|
||||
struct _http_response
|
||||
{
|
||||
int count;
|
||||
size_t count;
|
||||
char** lines;
|
||||
|
||||
int StatusCode;
|
||||
char* ReasonPhrase;
|
||||
long StatusCode;
|
||||
const char* ReasonPhrase;
|
||||
|
||||
int ContentLength;
|
||||
char* ContentType;
|
||||
size_t ContentLength;
|
||||
const char* ContentType;
|
||||
|
||||
int BodyLength;
|
||||
size_t BodyLength;
|
||||
BYTE* BodyContent;
|
||||
|
||||
wListDictionary* Authenticates;
|
||||
wStream* data;
|
||||
};
|
||||
|
||||
FREERDP_LOCAL void http_response_print(HttpResponse* response);
|
||||
|
||||
@@ -31,19 +31,18 @@
|
||||
|
||||
#define TAG FREERDP_TAG("core.gateway.ntlm")
|
||||
|
||||
wStream* rpc_ntlm_http_request(rdpRpc* rpc, HttpContext* http, const char* method, int contentLength, SecBuffer* ntlmToken)
|
||||
static wStream* rpc_ntlm_http_request(rdpRpc* rpc, HttpContext* http, const char* method,
|
||||
int contentLength, SecBuffer* ntlmToken)
|
||||
{
|
||||
wStream* s;
|
||||
HttpRequest* request;
|
||||
char* base64NtlmToken = NULL;
|
||||
|
||||
request = http_request_new();
|
||||
|
||||
if (ntlmToken)
|
||||
base64NtlmToken = crypto_base64_encode(ntlmToken->pvBuffer, ntlmToken->cbBuffer);
|
||||
|
||||
http_request_set_method(request, method);
|
||||
|
||||
request->ContentLength = contentLength;
|
||||
http_request_set_uri(request, http->URI);
|
||||
|
||||
@@ -55,9 +54,7 @@ wStream* rpc_ntlm_http_request(rdpRpc* rpc, HttpContext* http, const char* metho
|
||||
|
||||
s = http_request_write(http, request);
|
||||
http_request_free(request);
|
||||
|
||||
free(base64NtlmToken);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -69,24 +66,20 @@ int rpc_ncacn_http_send_in_channel_request(rdpRpc* rpc, RpcInChannel* inChannel)
|
||||
BOOL continueNeeded;
|
||||
rdpNtlm* ntlm = inChannel->ntlm;
|
||||
HttpContext* http = inChannel->http;
|
||||
|
||||
continueNeeded = ntlm_authenticate(ntlm);
|
||||
|
||||
contentLength = (continueNeeded) ? 0 : 0x40000000;
|
||||
|
||||
s = rpc_ntlm_http_request(rpc, http, "RPC_IN_DATA", contentLength, &ntlm->outputBuffer[0]);
|
||||
|
||||
if (!s)
|
||||
return -1;
|
||||
|
||||
status = rpc_in_channel_write(inChannel, Stream_Buffer(s), Stream_Length(s));
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
return (status > 0) ? 1 : -1;
|
||||
}
|
||||
|
||||
int rpc_ncacn_http_recv_in_channel_response(rdpRpc* rpc, RpcInChannel* inChannel, HttpResponse* response)
|
||||
int rpc_ncacn_http_recv_in_channel_response(rdpRpc* rpc, RpcInChannel* inChannel,
|
||||
HttpResponse* response)
|
||||
{
|
||||
char* token64 = NULL;
|
||||
int ntlmTokenLength = 0;
|
||||
@@ -121,12 +114,12 @@ int rpc_ncacn_http_ntlm_init(rdpRpc* rpc, RpcChannel* channel)
|
||||
freerdp* instance = context->instance;
|
||||
|
||||
if (!settings->GatewayPassword || !settings->GatewayUsername ||
|
||||
!strlen(settings->GatewayPassword) || !strlen(settings->GatewayUsername))
|
||||
!strlen(settings->GatewayPassword) || !strlen(settings->GatewayUsername))
|
||||
{
|
||||
if (instance->GatewayAuthenticate)
|
||||
{
|
||||
BOOL proceed = instance->GatewayAuthenticate(instance, &settings->GatewayUsername,
|
||||
&settings->GatewayPassword, &settings->GatewayDomain);
|
||||
&settings->GatewayPassword, &settings->GatewayDomain);
|
||||
|
||||
if (!proceed)
|
||||
{
|
||||
@@ -139,18 +132,23 @@ int rpc_ncacn_http_ntlm_init(rdpRpc* rpc, RpcChannel* channel)
|
||||
if (settings->GatewayUsername)
|
||||
{
|
||||
free(settings->Username);
|
||||
|
||||
if (!(settings->Username = _strdup(settings->GatewayUsername)))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (settings->GatewayDomain)
|
||||
{
|
||||
free(settings->Domain);
|
||||
|
||||
if (!(settings->Domain = _strdup(settings->GatewayDomain)))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (settings->GatewayPassword)
|
||||
{
|
||||
free(settings->Password);
|
||||
|
||||
if (!(settings->Password = _strdup(settings->GatewayPassword)))
|
||||
return -1;
|
||||
}
|
||||
@@ -159,7 +157,7 @@ int rpc_ncacn_http_ntlm_init(rdpRpc* rpc, RpcChannel* channel)
|
||||
}
|
||||
|
||||
if (!ntlm_client_init(ntlm, TRUE, settings->GatewayUsername,
|
||||
settings->GatewayDomain, settings->GatewayPassword, tls->Bindings))
|
||||
settings->GatewayDomain, settings->GatewayPassword, tls->Bindings))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -179,7 +177,8 @@ void rpc_ncacn_http_ntlm_uninit(rdpRpc* rpc, RpcChannel* channel)
|
||||
channel->ntlm = NULL;
|
||||
}
|
||||
|
||||
int rpc_ncacn_http_send_out_channel_request(rdpRpc* rpc, RpcOutChannel* outChannel, BOOL replacement)
|
||||
int rpc_ncacn_http_send_out_channel_request(rdpRpc* rpc, RpcOutChannel* outChannel,
|
||||
BOOL replacement)
|
||||
{
|
||||
wStream* s;
|
||||
int status;
|
||||
@@ -187,7 +186,6 @@ int rpc_ncacn_http_send_out_channel_request(rdpRpc* rpc, RpcOutChannel* outChann
|
||||
BOOL continueNeeded;
|
||||
rdpNtlm* ntlm = outChannel->ntlm;
|
||||
HttpContext* http = outChannel->http;
|
||||
|
||||
continueNeeded = ntlm_authenticate(ntlm);
|
||||
|
||||
if (!replacement)
|
||||
@@ -201,13 +199,12 @@ int rpc_ncacn_http_send_out_channel_request(rdpRpc* rpc, RpcOutChannel* outChann
|
||||
return -1;
|
||||
|
||||
status = rpc_out_channel_write(outChannel, Stream_Buffer(s), Stream_Length(s));
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
return (status > 0) ? 1 : -1;
|
||||
}
|
||||
|
||||
int rpc_ncacn_http_recv_out_channel_response(rdpRpc* rpc, RpcOutChannel* outChannel, HttpResponse* response)
|
||||
int rpc_ncacn_http_recv_out_channel_response(rdpRpc* rpc, RpcOutChannel* outChannel,
|
||||
HttpResponse* response)
|
||||
{
|
||||
char* token64 = NULL;
|
||||
int ntlmTokenLength = 0;
|
||||
|
||||
@@ -314,7 +314,7 @@ void ntlm_client_uninit(rdpNtlm* ntlm)
|
||||
}
|
||||
}
|
||||
|
||||
rdpNtlm* ntlm_new()
|
||||
rdpNtlm* ntlm_new(void)
|
||||
{
|
||||
rdpNtlm* ntlm;
|
||||
ntlm = (rdpNtlm*) calloc(1, sizeof(rdpNtlm));
|
||||
|
||||
@@ -51,12 +51,11 @@ typedef struct rdg_packet_header
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
BOOL rdg_write_packet(rdpRdg* rdg, wStream* sPacket)
|
||||
static BOOL rdg_write_packet(rdpRdg* rdg, wStream* sPacket)
|
||||
{
|
||||
int status;
|
||||
wStream* sChunk;
|
||||
char chunkSize[11];
|
||||
|
||||
sprintf_s(chunkSize, sizeof(chunkSize), "%"PRIXz"\r\n", Stream_Length(sPacket));
|
||||
sChunk = Stream_New(NULL, strlen(chunkSize) + Stream_Length(sPacket) + 2);
|
||||
|
||||
@@ -67,7 +66,6 @@ BOOL rdg_write_packet(rdpRdg* rdg, wStream* sPacket)
|
||||
Stream_Write(sChunk, Stream_Buffer(sPacket), Stream_Length(sPacket));
|
||||
Stream_Write(sChunk, "\r\n", 2);
|
||||
Stream_SealLength(sChunk);
|
||||
|
||||
status = tls_write_all(rdg->tlsIn, Stream_Buffer(sChunk), Stream_Length(sChunk));
|
||||
Stream_Free(sChunk, TRUE);
|
||||
|
||||
@@ -77,13 +75,12 @@ BOOL rdg_write_packet(rdpRdg* rdg, wStream* sPacket)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wStream* rdg_receive_packet(rdpRdg* rdg)
|
||||
static wStream* rdg_receive_packet(rdpRdg* rdg)
|
||||
{
|
||||
int status;
|
||||
wStream* s;
|
||||
RdgPacketHeader* packet;
|
||||
UINT32 readCount = 0;
|
||||
|
||||
s = Stream_New(NULL, 1024);
|
||||
|
||||
if (!s)
|
||||
@@ -111,6 +108,7 @@ wStream* rdg_receive_packet(rdpRdg* rdg)
|
||||
Stream_Free(s, TRUE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
packet = (RdgPacketHeader*) Stream_Buffer(s);
|
||||
}
|
||||
|
||||
@@ -128,15 +126,13 @@ wStream* rdg_receive_packet(rdpRdg* rdg)
|
||||
}
|
||||
|
||||
Stream_SealLength(s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
BOOL rdg_send_handshake(rdpRdg* rdg)
|
||||
static BOOL rdg_send_handshake(rdpRdg* rdg)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL status;
|
||||
|
||||
s = Stream_New(NULL, 14);
|
||||
|
||||
if (!s)
|
||||
@@ -145,14 +141,11 @@ BOOL rdg_send_handshake(rdpRdg* rdg)
|
||||
Stream_Write_UINT16(s, PKT_TYPE_HANDSHAKE_REQUEST); /* Type (2 bytes) */
|
||||
Stream_Write_UINT16(s, 0); /* Reserved (2 bytes) */
|
||||
Stream_Write_UINT32(s, 14); /* PacketLength (4 bytes) */
|
||||
|
||||
Stream_Write_UINT8(s, 1); /* VersionMajor (1 byte) */
|
||||
Stream_Write_UINT8(s, 0); /* VersionMinor (1 byte) */
|
||||
Stream_Write_UINT16(s, 0); /* ClientVersion (2 bytes), must be 0 */
|
||||
Stream_Write_UINT16(s, 0); /* ExtendedAuthentication (2 bytes) */
|
||||
|
||||
Stream_SealLength(s);
|
||||
|
||||
status = rdg_write_packet(rdg, s);
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
@@ -164,11 +157,10 @@ BOOL rdg_send_handshake(rdpRdg* rdg)
|
||||
return status;
|
||||
}
|
||||
|
||||
BOOL rdg_send_tunnel_request(rdpRdg* rdg)
|
||||
static BOOL rdg_send_tunnel_request(rdpRdg* rdg)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL status;
|
||||
|
||||
s = Stream_New(NULL, 16);
|
||||
|
||||
if (!s)
|
||||
@@ -177,13 +169,10 @@ BOOL rdg_send_tunnel_request(rdpRdg* rdg)
|
||||
Stream_Write_UINT16(s, PKT_TYPE_TUNNEL_CREATE); /* Type (2 bytes) */
|
||||
Stream_Write_UINT16(s, 0); /* Reserved (2 bytes) */
|
||||
Stream_Write_UINT32(s, 16); /* PacketLength (4 bytes) */
|
||||
|
||||
Stream_Write_UINT32(s, HTTP_CAPABILITY_TYPE_QUAR_SOH); /* CapabilityFlags (4 bytes) */
|
||||
Stream_Write_UINT16(s, 0); /* FieldsPresent (2 bytes) */
|
||||
Stream_Write_UINT16(s, 0); /* Reserved (2 bytes), must be 0 */
|
||||
|
||||
Stream_SealLength(s);
|
||||
|
||||
status = rdg_write_packet(rdg, s);
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
@@ -195,7 +184,7 @@ BOOL rdg_send_tunnel_request(rdpRdg* rdg)
|
||||
return status;
|
||||
}
|
||||
|
||||
BOOL rdg_send_tunnel_authorization(rdpRdg* rdg)
|
||||
static BOOL rdg_send_tunnel_authorization(rdpRdg* rdg)
|
||||
{
|
||||
int i;
|
||||
wStream* s;
|
||||
@@ -203,8 +192,8 @@ BOOL rdg_send_tunnel_authorization(rdpRdg* rdg)
|
||||
WCHAR* clientName = NULL;
|
||||
UINT16 clientNameLen;
|
||||
UINT32 packetSize;
|
||||
|
||||
clientNameLen = ConvertToUnicode(CP_UTF8, 0, rdg->settings->ClientHostname, -1, &clientName, 0);
|
||||
|
||||
if (!clientName)
|
||||
return FALSE;
|
||||
|
||||
@@ -220,7 +209,6 @@ BOOL rdg_send_tunnel_authorization(rdpRdg* rdg)
|
||||
Stream_Write_UINT16(s, PKT_TYPE_TUNNEL_AUTH); /* Type (2 bytes) */
|
||||
Stream_Write_UINT16(s, 0); /* Reserved (2 bytes) */
|
||||
Stream_Write_UINT32(s, packetSize); /* PacketLength (4 bytes) */
|
||||
|
||||
Stream_Write_UINT16(s, 0); /* FieldsPresent (2 bytes) */
|
||||
Stream_Write_UINT16(s, clientNameLen * 2); /* Client name string length */
|
||||
|
||||
@@ -228,9 +216,7 @@ BOOL rdg_send_tunnel_authorization(rdpRdg* rdg)
|
||||
Stream_Write_UINT16(s, clientName[i]);
|
||||
|
||||
Stream_SealLength(s);
|
||||
|
||||
status = rdg_write_packet(rdg, s);
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
free(clientName);
|
||||
|
||||
@@ -242,7 +228,7 @@ BOOL rdg_send_tunnel_authorization(rdpRdg* rdg)
|
||||
return status;
|
||||
}
|
||||
|
||||
BOOL rdg_send_channel_create(rdpRdg* rdg)
|
||||
static BOOL rdg_send_channel_create(rdpRdg* rdg)
|
||||
{
|
||||
int i;
|
||||
wStream* s;
|
||||
@@ -250,7 +236,6 @@ BOOL rdg_send_channel_create(rdpRdg* rdg)
|
||||
char* serverName = rdg->settings->ServerHostname;
|
||||
UINT16 serverNameLen = strlen(serverName) + 1;
|
||||
UINT32 packetSize = 16 + serverNameLen * 2;
|
||||
|
||||
s = Stream_New(NULL, packetSize);
|
||||
|
||||
if (!s)
|
||||
@@ -259,7 +244,6 @@ BOOL rdg_send_channel_create(rdpRdg* rdg)
|
||||
Stream_Write_UINT16(s, PKT_TYPE_CHANNEL_CREATE); /* Type (2 bytes) */
|
||||
Stream_Write_UINT16(s, 0); /* Reserved (2 bytes) */
|
||||
Stream_Write_UINT32(s, packetSize); /* PacketLength (4 bytes) */
|
||||
|
||||
Stream_Write_UINT8(s, 1); /* Number of resources. (1 byte) */
|
||||
Stream_Write_UINT8(s, 0); /* Number of alternative resources (1 byte) */
|
||||
Stream_Write_UINT16(s, rdg->settings->ServerPort); /* Resource port (2 bytes) */
|
||||
@@ -272,9 +256,7 @@ BOOL rdg_send_channel_create(rdpRdg* rdg)
|
||||
}
|
||||
|
||||
Stream_SealLength(s);
|
||||
|
||||
status = rdg_write_packet(rdg, s);
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
if (status)
|
||||
@@ -285,15 +267,13 @@ BOOL rdg_send_channel_create(rdpRdg* rdg)
|
||||
return status;
|
||||
}
|
||||
|
||||
wStream* rdg_build_http_request(rdpRdg* rdg, char* method)
|
||||
static wStream* rdg_build_http_request(rdpRdg* rdg, char* method)
|
||||
{
|
||||
wStream* s;
|
||||
HttpRequest* request = NULL;
|
||||
SecBuffer* ntlmToken = NULL;
|
||||
char* base64NtlmToken = NULL;
|
||||
|
||||
assert(method != NULL);
|
||||
|
||||
request = http_request_new();
|
||||
|
||||
if (!request)
|
||||
@@ -316,7 +296,6 @@ wStream* rdg_build_http_request(rdpRdg* rdg, char* method)
|
||||
{
|
||||
http_request_set_auth_scheme(request, "NTLM");
|
||||
http_request_set_auth_param(request, base64NtlmToken);
|
||||
|
||||
free(base64NtlmToken);
|
||||
|
||||
if (!request->AuthScheme || !request->AuthParam)
|
||||
@@ -338,7 +317,7 @@ wStream* rdg_build_http_request(rdpRdg* rdg, char* method)
|
||||
return s;
|
||||
}
|
||||
|
||||
BOOL rdg_process_out_channel_response(rdpRdg* rdg, HttpResponse* response)
|
||||
static BOOL rdg_process_out_channel_response(rdpRdg* rdg, HttpResponse* response)
|
||||
{
|
||||
int status;
|
||||
wStream* s;
|
||||
@@ -375,16 +354,13 @@ BOOL rdg_process_out_channel_response(rdpRdg* rdg, HttpResponse* response)
|
||||
}
|
||||
|
||||
ntlm_authenticate(ntlm);
|
||||
|
||||
s = rdg_build_http_request(rdg, "RDG_OUT_DATA");
|
||||
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
status = tls_write_all(rdg->tlsOut, Stream_Buffer(s), Stream_Length(s));
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
ntlm_free(rdg->ntlm);
|
||||
rdg->ntlm = NULL;
|
||||
|
||||
@@ -392,11 +368,10 @@ BOOL rdg_process_out_channel_response(rdpRdg* rdg, HttpResponse* response)
|
||||
return FALSE;
|
||||
|
||||
rdg->state = RDG_CLIENT_STATE_OUT_CHANNEL_AUTHORIZE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_process_out_channel_authorization(rdpRdg* rdg, HttpResponse* response)
|
||||
static BOOL rdg_process_out_channel_authorization(rdpRdg* rdg, HttpResponse* response)
|
||||
{
|
||||
if (response->StatusCode != HTTP_STATUS_OK)
|
||||
{
|
||||
@@ -406,11 +381,10 @@ BOOL rdg_process_out_channel_authorization(rdpRdg* rdg, HttpResponse* response)
|
||||
|
||||
WLog_DBG(TAG, "Out Channel authorization complete");
|
||||
rdg->state = RDG_CLIENT_STATE_OUT_CHANNEL_AUTHORIZED;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_process_in_channel_response(rdpRdg* rdg, HttpResponse* response)
|
||||
static BOOL rdg_process_in_channel_response(rdpRdg* rdg, HttpResponse* response)
|
||||
{
|
||||
int status;
|
||||
wStream* s;
|
||||
@@ -418,7 +392,6 @@ BOOL rdg_process_in_channel_response(rdpRdg* rdg, HttpResponse* response)
|
||||
int ntlmTokenLength = 0;
|
||||
BYTE* ntlmTokenData = NULL;
|
||||
rdpNtlm* ntlm = rdg->ntlm;
|
||||
|
||||
WLog_DBG(TAG, "In Channel authorization required");
|
||||
|
||||
if (ListDictionary_Contains(response->Authenticates, "NTLM"))
|
||||
@@ -440,16 +413,13 @@ BOOL rdg_process_in_channel_response(rdpRdg* rdg, HttpResponse* response)
|
||||
}
|
||||
|
||||
ntlm_authenticate(ntlm);
|
||||
|
||||
s = rdg_build_http_request(rdg, "RDG_IN_DATA");
|
||||
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
status = tls_write_all(rdg->tlsIn, Stream_Buffer(s), Stream_Length(s));
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
ntlm_free(rdg->ntlm);
|
||||
rdg->ntlm = NULL;
|
||||
|
||||
@@ -457,11 +427,10 @@ BOOL rdg_process_in_channel_response(rdpRdg* rdg, HttpResponse* response)
|
||||
return FALSE;
|
||||
|
||||
rdg->state = RDG_CLIENT_STATE_IN_CHANNEL_AUTHORIZE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_process_in_channel_authorization(rdpRdg* rdg, HttpResponse* response)
|
||||
static BOOL rdg_process_in_channel_authorization(rdpRdg* rdg, HttpResponse* response)
|
||||
{
|
||||
wStream* s;
|
||||
int status;
|
||||
@@ -474,14 +443,12 @@ BOOL rdg_process_in_channel_authorization(rdpRdg* rdg, HttpResponse* response)
|
||||
|
||||
WLog_DBG(TAG, "In Channel authorization complete");
|
||||
rdg->state = RDG_CLIENT_STATE_IN_CHANNEL_AUTHORIZED;
|
||||
|
||||
s = rdg_build_http_request(rdg, "RDG_IN_DATA");
|
||||
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
status = tls_write_all(rdg->tlsIn, Stream_Buffer(s), Stream_Length(s));
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
if (status <= 0)
|
||||
@@ -490,10 +457,9 @@ BOOL rdg_process_in_channel_authorization(rdpRdg* rdg, HttpResponse* response)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_process_handshake_response(rdpRdg* rdg, wStream* s)
|
||||
static BOOL rdg_process_handshake_response(rdpRdg* rdg, wStream* s)
|
||||
{
|
||||
HRESULT errorCode;
|
||||
|
||||
WLog_DBG(TAG, "Handshake response received");
|
||||
|
||||
if (rdg->state != RDG_CLIENT_STATE_HANDSHAKE)
|
||||
@@ -516,10 +482,9 @@ BOOL rdg_process_handshake_response(rdpRdg* rdg, wStream* s)
|
||||
return rdg_send_tunnel_request(rdg);
|
||||
}
|
||||
|
||||
BOOL rdg_process_tunnel_response(rdpRdg* rdg, wStream* s)
|
||||
static BOOL rdg_process_tunnel_response(rdpRdg* rdg, wStream* s)
|
||||
{
|
||||
HRESULT errorCode;
|
||||
|
||||
WLog_DBG(TAG, "Tunnel response received");
|
||||
|
||||
if (rdg->state != RDG_CLIENT_STATE_TUNNEL_CREATE)
|
||||
@@ -542,10 +507,9 @@ BOOL rdg_process_tunnel_response(rdpRdg* rdg, wStream* s)
|
||||
return rdg_send_tunnel_authorization(rdg);
|
||||
}
|
||||
|
||||
BOOL rdg_process_tunnel_authorization_response(rdpRdg* rdg, wStream* s)
|
||||
static BOOL rdg_process_tunnel_authorization_response(rdpRdg* rdg, wStream* s)
|
||||
{
|
||||
HRESULT errorCode;
|
||||
|
||||
WLog_DBG(TAG, "Tunnel authorization received");
|
||||
|
||||
if (rdg->state != RDG_CLIENT_STATE_TUNNEL_AUTHORIZE)
|
||||
@@ -568,10 +532,9 @@ BOOL rdg_process_tunnel_authorization_response(rdpRdg* rdg, wStream* s)
|
||||
return rdg_send_channel_create(rdg);
|
||||
}
|
||||
|
||||
BOOL rdg_process_channel_response(rdpRdg* rdg, wStream* s)
|
||||
static BOOL rdg_process_channel_response(rdpRdg* rdg, wStream* s)
|
||||
{
|
||||
HRESULT errorCode;
|
||||
|
||||
WLog_DBG(TAG, "Channel response received");
|
||||
|
||||
if (rdg->state != RDG_CLIENT_STATE_CHANNEL_CREATE)
|
||||
@@ -592,15 +555,13 @@ BOOL rdg_process_channel_response(rdpRdg* rdg, wStream* s)
|
||||
}
|
||||
|
||||
rdg->state = RDG_CLIENT_STATE_OPENED;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_process_packet(rdpRdg* rdg, wStream* s)
|
||||
static BOOL rdg_process_packet(rdpRdg* rdg, wStream* s)
|
||||
{
|
||||
BOOL status = TRUE;
|
||||
UINT16 type;
|
||||
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
@@ -634,8 +595,7 @@ BOOL rdg_process_packet(rdpRdg* rdg, wStream* s)
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
BOOL rdg_out_channel_recv(rdpRdg* rdg)
|
||||
static BOOL rdg_out_channel_recv(rdpRdg* rdg)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL status = TRUE;
|
||||
@@ -645,26 +605,27 @@ BOOL rdg_out_channel_recv(rdpRdg* rdg)
|
||||
{
|
||||
case RDG_CLIENT_STATE_OUT_CHANNEL_REQUEST:
|
||||
response = http_response_recv(rdg->tlsOut);
|
||||
|
||||
if (!response)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
status = rdg_process_out_channel_response(rdg, response);
|
||||
http_response_free(response);
|
||||
break;
|
||||
|
||||
case RDG_CLIENT_STATE_OUT_CHANNEL_AUTHORIZE:
|
||||
response = http_response_recv(rdg->tlsOut);
|
||||
|
||||
if (!response)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
status = rdg_process_out_channel_authorization(rdg, response);
|
||||
http_response_free(response);
|
||||
break;
|
||||
|
||||
default:
|
||||
s = rdg_receive_packet(rdg);
|
||||
|
||||
if (s)
|
||||
{
|
||||
status = rdg_process_packet(rdg, s);
|
||||
@@ -675,7 +636,7 @@ BOOL rdg_out_channel_recv(rdpRdg* rdg)
|
||||
return status;
|
||||
}
|
||||
|
||||
BOOL rdg_in_channel_recv(rdpRdg* rdg)
|
||||
static BOOL rdg_in_channel_recv(rdpRdg* rdg)
|
||||
{
|
||||
BOOL status = TRUE;
|
||||
HttpResponse* response = NULL;
|
||||
@@ -709,7 +670,6 @@ BOOL rdg_in_channel_recv(rdpRdg* rdg)
|
||||
DWORD rdg_get_event_handles(rdpRdg* rdg, HANDLE* events, DWORD count)
|
||||
{
|
||||
DWORD nCount = 0;
|
||||
|
||||
assert(rdg != NULL);
|
||||
|
||||
if (events && (nCount < count))
|
||||
@@ -742,12 +702,10 @@ DWORD rdg_get_event_handles(rdpRdg* rdg, HANDLE* events, DWORD count)
|
||||
return nCount;
|
||||
}
|
||||
|
||||
BOOL rdg_check_event_handles(rdpRdg* rdg)
|
||||
static BOOL rdg_check_event_handles(rdpRdg* rdg)
|
||||
{
|
||||
HANDLE event = NULL;
|
||||
|
||||
assert(rdg != NULL);
|
||||
|
||||
BIO_get_event(rdg->tlsOut->bio, &event);
|
||||
|
||||
if (WaitForSingleObject(event, 0) == WAIT_OBJECT_0)
|
||||
@@ -765,18 +723,20 @@ BOOL rdg_check_event_handles(rdpRdg* rdg)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_ncacn_http_ntlm_init(rdpRdg* rdg, rdpTls* tls)
|
||||
static BOOL rdg_ncacn_http_ntlm_init(rdpRdg* rdg, rdpTls* tls)
|
||||
{
|
||||
rdpNtlm* ntlm = rdg->ntlm;
|
||||
rdpContext* context = rdg->context;
|
||||
rdpSettings* settings = context->settings;
|
||||
freerdp* instance = context->instance;
|
||||
|
||||
if (!settings->GatewayPassword || !settings->GatewayUsername || !strlen(settings->GatewayPassword) || !strlen(settings->GatewayUsername))
|
||||
if (!settings->GatewayPassword || !settings->GatewayUsername ||
|
||||
!strlen(settings->GatewayPassword) || !strlen(settings->GatewayUsername))
|
||||
{
|
||||
if (instance->GatewayAuthenticate)
|
||||
{
|
||||
BOOL proceed = instance->GatewayAuthenticate(instance, &settings->GatewayUsername, &settings->GatewayPassword, &settings->GatewayDomain);
|
||||
BOOL proceed = instance->GatewayAuthenticate(instance, &settings->GatewayUsername,
|
||||
&settings->GatewayPassword, &settings->GatewayDomain);
|
||||
|
||||
if (!proceed)
|
||||
{
|
||||
@@ -789,18 +749,23 @@ BOOL rdg_ncacn_http_ntlm_init(rdpRdg* rdg, rdpTls* tls)
|
||||
if (settings->GatewayUsername)
|
||||
{
|
||||
free(settings->Username);
|
||||
|
||||
if (!(settings->Username = _strdup(settings->GatewayUsername)))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (settings->GatewayDomain)
|
||||
{
|
||||
free(settings->Domain);
|
||||
|
||||
if (!(settings->Domain = _strdup(settings->GatewayDomain)))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (settings->GatewayPassword)
|
||||
{
|
||||
free(settings->Password);
|
||||
|
||||
if (!(settings->Password = _strdup(settings->GatewayPassword)))
|
||||
return FALSE;
|
||||
}
|
||||
@@ -808,7 +773,8 @@ BOOL rdg_ncacn_http_ntlm_init(rdpRdg* rdg, rdpTls* tls)
|
||||
}
|
||||
}
|
||||
|
||||
if (!ntlm_client_init(ntlm, TRUE, settings->GatewayUsername, settings->GatewayDomain, settings->GatewayPassword, tls->Bindings))
|
||||
if (!ntlm_client_init(ntlm, TRUE, settings->GatewayUsername, settings->GatewayDomain,
|
||||
settings->GatewayPassword, tls->Bindings))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -821,11 +787,10 @@ BOOL rdg_ncacn_http_ntlm_init(rdpRdg* rdg, rdpTls* tls)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_send_out_channel_request(rdpRdg*rdg)
|
||||
static BOOL rdg_send_out_channel_request(rdpRdg* rdg)
|
||||
{
|
||||
wStream* s = NULL;
|
||||
int status;
|
||||
|
||||
rdg->ntlm = ntlm_new();
|
||||
|
||||
if (!rdg->ntlm)
|
||||
@@ -847,22 +812,19 @@ BOOL rdg_send_out_channel_request(rdpRdg*rdg)
|
||||
return FALSE;
|
||||
|
||||
status = tls_write_all(rdg->tlsOut, Stream_Buffer(s), Stream_Length(s));
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
if (status < 0)
|
||||
return FALSE;
|
||||
|
||||
rdg->state = RDG_CLIENT_STATE_OUT_CHANNEL_REQUEST;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_send_in_channel_request(rdpRdg*rdg)
|
||||
static BOOL rdg_send_in_channel_request(rdpRdg* rdg)
|
||||
{
|
||||
int status;
|
||||
wStream* s = NULL;
|
||||
|
||||
rdg->ntlm = ntlm_new();
|
||||
|
||||
if (!rdg->ntlm)
|
||||
@@ -884,32 +846,28 @@ BOOL rdg_send_in_channel_request(rdpRdg*rdg)
|
||||
return FALSE;
|
||||
|
||||
status = tls_write_all(rdg->tlsIn, Stream_Buffer(s), Stream_Length(s));
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
if (status < 0)
|
||||
return FALSE;
|
||||
|
||||
rdg->state = RDG_CLIENT_STATE_IN_CHANNEL_REQUEST;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_tls_out_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
|
||||
static BOOL rdg_tls_out_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
|
||||
{
|
||||
int sockfd = 0;
|
||||
int status = 0;
|
||||
BIO* socketBio = NULL;
|
||||
BIO* bufferedBio = NULL;
|
||||
rdpSettings* settings = rdg->settings;
|
||||
const char *peerHostname = settings->GatewayHostname;
|
||||
const char* peerHostname = settings->GatewayHostname;
|
||||
UINT16 peerPort = settings->GatewayPort;
|
||||
BOOL isProxyConnection = proxy_prepare(settings, &peerHostname, &peerPort, TRUE);
|
||||
|
||||
assert(hostname != NULL);
|
||||
|
||||
sockfd = freerdp_tcp_connect(rdg->context, settings, peerHostname,
|
||||
peerPort, timeout);
|
||||
peerPort, timeout);
|
||||
|
||||
if (sockfd < 1)
|
||||
{
|
||||
@@ -936,7 +894,8 @@ BOOL rdg_tls_out_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int tim
|
||||
bufferedBio = BIO_push(bufferedBio, socketBio);
|
||||
status = BIO_set_nonblock(bufferedBio, TRUE);
|
||||
|
||||
if (isProxyConnection) {
|
||||
if (isProxyConnection)
|
||||
{
|
||||
if (!proxy_connect(settings, bufferedBio, settings->GatewayHostname, settings->GatewayPort))
|
||||
return FALSE;
|
||||
}
|
||||
@@ -960,27 +919,27 @@ BOOL rdg_tls_out_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int tim
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_tls_in_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
|
||||
static BOOL rdg_tls_in_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
|
||||
{
|
||||
int sockfd = 0;
|
||||
int status = 0;
|
||||
BIO* socketBio = NULL;
|
||||
BIO* bufferedBio = NULL;
|
||||
rdpSettings* settings = rdg->settings;
|
||||
const char *peerHostname = settings->GatewayHostname;
|
||||
const char* peerHostname = settings->GatewayHostname;
|
||||
int peerPort = settings->GatewayPort;
|
||||
BOOL isProxyConnection = FALSE;
|
||||
|
||||
assert(hostname != NULL);
|
||||
|
||||
if (settings->ProxyType) {
|
||||
if (settings->ProxyType)
|
||||
{
|
||||
peerHostname = settings->ProxyHostname;
|
||||
peerPort = settings->ProxyPort;
|
||||
isProxyConnection = TRUE;
|
||||
}
|
||||
|
||||
sockfd = freerdp_tcp_connect(rdg->context, settings, peerHostname,
|
||||
peerPort, timeout);
|
||||
peerPort, timeout);
|
||||
|
||||
if (sockfd < 1)
|
||||
return FALSE;
|
||||
@@ -1024,14 +983,12 @@ BOOL rdg_tls_in_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int time
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_out_channel_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
|
||||
static BOOL rdg_out_channel_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
|
||||
{
|
||||
BOOL status;
|
||||
DWORD nCount;
|
||||
HANDLE events[8];
|
||||
|
||||
assert(hostname != NULL);
|
||||
|
||||
status = rdg_tls_out_connect(rdg, hostname, port, timeout);
|
||||
|
||||
if (!status)
|
||||
@@ -1062,14 +1019,12 @@ BOOL rdg_out_channel_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_in_channel_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
|
||||
static BOOL rdg_in_channel_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
|
||||
{
|
||||
BOOL status;
|
||||
DWORD nCount;
|
||||
HANDLE events[8];
|
||||
|
||||
assert(hostname != NULL);
|
||||
|
||||
status = rdg_tls_in_connect(rdg, hostname, port, timeout);
|
||||
|
||||
if (!status)
|
||||
@@ -1100,14 +1055,12 @@ BOOL rdg_in_channel_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_tunnel_connect(rdpRdg* rdg)
|
||||
static BOOL rdg_tunnel_connect(rdpRdg* rdg)
|
||||
{
|
||||
BOOL status;
|
||||
DWORD nCount;
|
||||
HANDLE events[8];
|
||||
|
||||
rdg_send_handshake(rdg);
|
||||
|
||||
nCount = rdg_get_event_handles(rdg, events, 8);
|
||||
|
||||
if (nCount == 0)
|
||||
@@ -1131,9 +1084,7 @@ BOOL rdg_tunnel_connect(rdpRdg* rdg)
|
||||
BOOL rdg_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
|
||||
{
|
||||
BOOL status;
|
||||
|
||||
assert(rdg != NULL);
|
||||
|
||||
status = rdg_out_channel_connect(rdg, hostname, port, timeout);
|
||||
|
||||
if (!status)
|
||||
@@ -1152,7 +1103,7 @@ BOOL rdg_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int rdg_write_data_packet(rdpRdg* rdg, BYTE* buf, int size)
|
||||
static int rdg_write_data_packet(rdpRdg* rdg, BYTE* buf, int size)
|
||||
{
|
||||
int status;
|
||||
wStream* sChunk;
|
||||
@@ -1163,24 +1114,19 @@ int rdg_write_data_packet(rdpRdg* rdg, BYTE* buf, int size)
|
||||
return 0;
|
||||
|
||||
sprintf_s(chunkSize, sizeof(chunkSize), "%X\r\n", packetSize);
|
||||
|
||||
sChunk = Stream_New(NULL, strlen(chunkSize) + packetSize + 2);
|
||||
|
||||
if (!sChunk)
|
||||
return -1;
|
||||
|
||||
Stream_Write(sChunk, chunkSize, strlen(chunkSize));
|
||||
|
||||
Stream_Write_UINT16(sChunk, PKT_TYPE_DATA); /* Type */
|
||||
Stream_Write_UINT16(sChunk, 0); /* Reserved */
|
||||
Stream_Write_UINT32(sChunk, packetSize); /* Packet length */
|
||||
|
||||
Stream_Write_UINT16(sChunk, size); /* Data size */
|
||||
Stream_Write(sChunk, buf, size); /* Data */
|
||||
|
||||
Stream_Write(sChunk, "\r\n", 2);
|
||||
Stream_SealLength(sChunk);
|
||||
|
||||
status = tls_write_all(rdg->tlsIn, Stream_Buffer(sChunk), Stream_Length(sChunk));
|
||||
Stream_Free(sChunk, TRUE);
|
||||
|
||||
@@ -1190,79 +1136,65 @@ int rdg_write_data_packet(rdpRdg* rdg, BYTE* buf, int size)
|
||||
return size;
|
||||
}
|
||||
|
||||
BOOL rdg_process_close_packet(rdpRdg* rdg)
|
||||
static BOOL rdg_process_close_packet(rdpRdg* rdg)
|
||||
{
|
||||
int status;
|
||||
wStream* sChunk;
|
||||
int packetSize = 12;
|
||||
char chunkSize[11];
|
||||
|
||||
sprintf_s(chunkSize, sizeof(chunkSize), "%X\r\n", packetSize);
|
||||
|
||||
sChunk = Stream_New(NULL, strlen(chunkSize) + packetSize + 2);
|
||||
|
||||
|
||||
if (!sChunk)
|
||||
return FALSE;
|
||||
|
||||
|
||||
Stream_Write(sChunk, chunkSize, strlen(chunkSize));
|
||||
|
||||
Stream_Write_UINT16(sChunk, PKT_TYPE_CLOSE_CHANNEL_RESPONSE); /* Type */
|
||||
Stream_Write_UINT16(sChunk, 0); /* Reserved */
|
||||
Stream_Write_UINT32(sChunk, packetSize); /* Packet length */
|
||||
|
||||
Stream_Write_UINT32(sChunk, 0); /* Status code */
|
||||
|
||||
Stream_Write(sChunk, "\r\n", 2);
|
||||
Stream_SealLength(sChunk);
|
||||
|
||||
status = tls_write_all(rdg->tlsIn, Stream_Buffer(sChunk), Stream_Length(sChunk));
|
||||
Stream_Free(sChunk, TRUE);
|
||||
|
||||
return (status < 0 ? FALSE : TRUE);
|
||||
}
|
||||
|
||||
BOOL rdg_process_keep_alive_packet(rdpRdg* rdg)
|
||||
static BOOL rdg_process_keep_alive_packet(rdpRdg* rdg)
|
||||
{
|
||||
int status;
|
||||
wStream* sChunk;
|
||||
int packetSize = 8;
|
||||
char chunkSize[11];
|
||||
|
||||
sprintf_s(chunkSize, sizeof(chunkSize), "%X\r\n", packetSize);
|
||||
|
||||
sChunk = Stream_New(NULL, strlen(chunkSize) + packetSize + 2);
|
||||
|
||||
|
||||
if (!sChunk)
|
||||
return FALSE;
|
||||
|
||||
|
||||
Stream_Write(sChunk, chunkSize, strlen(chunkSize));
|
||||
|
||||
Stream_Write_UINT16(sChunk, PKT_TYPE_KEEPALIVE); /* Type */
|
||||
Stream_Write_UINT16(sChunk, 0); /* Reserved */
|
||||
Stream_Write_UINT32(sChunk, packetSize); /* Packet length */
|
||||
|
||||
Stream_Write(sChunk, "\r\n", 2);
|
||||
Stream_SealLength(sChunk);
|
||||
|
||||
status = tls_write_all(rdg->tlsIn, Stream_Buffer(sChunk), Stream_Length(sChunk));
|
||||
Stream_Free(sChunk, TRUE);
|
||||
|
||||
return (status < 0 ? FALSE : TRUE);
|
||||
}
|
||||
|
||||
BOOL rdg_process_unknown_packet(rdpRdg* rdg, int type)
|
||||
static BOOL rdg_process_unknown_packet(rdpRdg* rdg, int type)
|
||||
{
|
||||
WLog_WARN(TAG, "Unknown Control Packet received: %X", type);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdg_process_control_packet(rdpRdg* rdg, int type, int packetLength)
|
||||
static BOOL rdg_process_control_packet(rdpRdg* rdg, int type, size_t packetLength)
|
||||
{
|
||||
wStream* s = NULL;
|
||||
int readCount = 0;
|
||||
size_t readCount = 0;
|
||||
int status;
|
||||
int payloadSize = packetLength - sizeof(RdgPacketHeader);
|
||||
size_t payloadSize = packetLength - sizeof(RdgPacketHeader);
|
||||
|
||||
if (payloadSize)
|
||||
{
|
||||
@@ -1282,6 +1214,7 @@ BOOL rdg_process_control_packet(rdpRdg* rdg, int type, int packetLength)
|
||||
Stream_Free(s, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1303,21 +1236,20 @@ BOOL rdg_process_control_packet(rdpRdg* rdg, int type, int packetLength)
|
||||
status = rdg_process_keep_alive_packet(rdg);
|
||||
LeaveCriticalSection(&rdg->writeSection);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
status = rdg_process_unknown_packet(rdg, type);
|
||||
break;
|
||||
}
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size)
|
||||
static int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size)
|
||||
{
|
||||
RdgPacketHeader header;
|
||||
int readCount = 0;
|
||||
size_t readCount = 0;
|
||||
int readSize;
|
||||
int status;
|
||||
int pending;
|
||||
@@ -1326,18 +1258,17 @@ int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size)
|
||||
{
|
||||
while (readCount < sizeof(RdgPacketHeader))
|
||||
{
|
||||
status = BIO_read(rdg->tlsOut->bio, (BYTE*)(&header) + readCount, sizeof(RdgPacketHeader) - readCount);
|
||||
status = BIO_read(rdg->tlsOut->bio, (BYTE*)(&header) + readCount,
|
||||
sizeof(RdgPacketHeader) - readCount);
|
||||
|
||||
if (status <= 0)
|
||||
{
|
||||
if (!BIO_should_retry(rdg->tlsOut->bio))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!readCount)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BIO_wait_read(rdg->tlsOut->bio, 50);
|
||||
continue;
|
||||
}
|
||||
@@ -1348,10 +1279,10 @@ int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size)
|
||||
if (header.type != PKT_TYPE_DATA)
|
||||
{
|
||||
status = rdg_process_control_packet(rdg, header.type, header.packetLength);
|
||||
|
||||
if (!status)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1364,9 +1295,8 @@ int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size)
|
||||
if (status < 0)
|
||||
{
|
||||
if (!BIO_should_retry(rdg->tlsOut->bio))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
BIO_wait_read(rdg->tlsOut->bio, 50);
|
||||
continue;
|
||||
}
|
||||
@@ -1376,7 +1306,6 @@ int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size)
|
||||
}
|
||||
|
||||
readSize = (rdg->packetRemainingCount < size ? rdg->packetRemainingCount : size);
|
||||
|
||||
status = BIO_read(rdg->tlsOut->bio, buffer, readSize);
|
||||
|
||||
if (status <= 0)
|
||||
@@ -1385,11 +1314,11 @@ int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
rdg->packetRemainingCount -= status;
|
||||
|
||||
pending = BIO_pending(rdg->tlsOut->bio);
|
||||
|
||||
if (pending > 0)
|
||||
@@ -1400,18 +1329,11 @@ int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size)
|
||||
return status;
|
||||
}
|
||||
|
||||
long rdg_bio_callback(BIO* bio, int mode, const char* argp, int argi, long argl, long ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int rdg_bio_write(BIO* bio, const char* buf, int num)
|
||||
{
|
||||
int status;
|
||||
rdpRdg* rdg = (rdpRdg*) BIO_get_data(bio);
|
||||
|
||||
BIO_clear_flags(bio, BIO_FLAGS_WRITE);
|
||||
|
||||
EnterCriticalSection(&rdg->writeSection);
|
||||
status = rdg_write_data_packet(rdg, (BYTE*) buf, num);
|
||||
LeaveCriticalSection(&rdg->writeSection);
|
||||
@@ -1438,7 +1360,6 @@ static int rdg_bio_read(BIO* bio, char* buf, int size)
|
||||
{
|
||||
int status;
|
||||
rdpRdg* rdg = (rdpRdg*) BIO_get_data(bio);
|
||||
|
||||
status = rdg_read_data_packet(rdg, (BYTE*) buf, size);
|
||||
|
||||
if (status < 0)
|
||||
@@ -1545,7 +1466,7 @@ static int rdg_bio_free(BIO* bio)
|
||||
return 1;
|
||||
}
|
||||
|
||||
BIO_METHOD* BIO_s_rdg(void)
|
||||
static BIO_METHOD* BIO_s_rdg(void)
|
||||
{
|
||||
static BIO_METHOD* bio_methods = NULL;
|
||||
|
||||
@@ -1572,9 +1493,7 @@ rdpRdg* rdg_new(rdpTransport* transport)
|
||||
RPC_CSTR stringUuid;
|
||||
char bracedUuid[40];
|
||||
RPC_STATUS rpcStatus;
|
||||
|
||||
assert(transport != NULL);
|
||||
|
||||
rdg = (rdpRdg*) calloc(1, sizeof(rdpRdg));
|
||||
|
||||
if (rdg)
|
||||
@@ -1582,9 +1501,7 @@ rdpRdg* rdg_new(rdpTransport* transport)
|
||||
rdg->state = RDG_CLIENT_STATE_INITIAL;
|
||||
rdg->context = transport->context;
|
||||
rdg->settings = rdg->context->settings;
|
||||
|
||||
UuidCreate(&rdg->guid);
|
||||
|
||||
rpcStatus = UuidToStringA(&rdg->guid, &stringUuid);
|
||||
|
||||
if (rpcStatus == RPC_S_OUT_OF_MEMORY)
|
||||
@@ -1592,7 +1509,6 @@ rdpRdg* rdg_new(rdpTransport* transport)
|
||||
|
||||
sprintf_s(bracedUuid, sizeof(bracedUuid), "{%s}", stringUuid);
|
||||
RpcStringFreeA(&stringUuid);
|
||||
|
||||
rdg->tlsOut = tls_new(rdg->settings);
|
||||
|
||||
if (!rdg->tlsOut)
|
||||
@@ -1618,8 +1534,8 @@ rdpRdg* rdg_new(rdpTransport* transport)
|
||||
http_context_set_rdg_connection_id(rdg->http, bracedUuid);
|
||||
|
||||
if (!rdg->http->URI || !rdg->http->Accept || !rdg->http->CacheControl ||
|
||||
!rdg->http->Pragma || !rdg->http->Connection || !rdg->http->UserAgent
|
||||
|| !rdg->http->Host || !rdg->http->RdgConnectionId)
|
||||
!rdg->http->Pragma || !rdg->http->Connection || !rdg->http->UserAgent
|
||||
|| !rdg->http->Host || !rdg->http->RdgConnectionId)
|
||||
{
|
||||
goto rdg_alloc_error;
|
||||
}
|
||||
@@ -1630,17 +1546,15 @@ rdpRdg* rdg_new(rdpTransport* transport)
|
||||
goto rdg_alloc_error;
|
||||
|
||||
BIO_set_data(rdg->frontBio, rdg);
|
||||
|
||||
rdg->readEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
if (!rdg->readEvent)
|
||||
goto rdg_alloc_error;
|
||||
|
||||
|
||||
InitializeCriticalSection(&rdg->writeSection);
|
||||
}
|
||||
|
||||
return rdg;
|
||||
|
||||
rdg_alloc_error:
|
||||
rdg_free(rdg);
|
||||
return NULL;
|
||||
@@ -1680,8 +1594,7 @@ void rdg_free(rdpRdg* rdg)
|
||||
CloseHandle(rdg->readEvent);
|
||||
rdg->readEvent = NULL;
|
||||
}
|
||||
|
||||
DeleteCriticalSection(&rdg->writeSection);
|
||||
|
||||
DeleteCriticalSection(&rdg->writeSection);
|
||||
free(rdg);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,6 @@ FREERDP_LOCAL BOOL rdg_connect(rdpRdg* rdg, const char* hostname, UINT16 port,
|
||||
int timeout);
|
||||
FREERDP_LOCAL DWORD rdg_get_event_handles(rdpRdg* rdg, HANDLE* events,
|
||||
DWORD count);
|
||||
FREERDP_LOCAL BOOL rdg_check_event_handles(rdpRdg* rdg);
|
||||
|
||||
|
||||
#endif /* FREERDP_LIB_CORE_GATEWAY_RDG_H */
|
||||
|
||||
@@ -51,10 +51,10 @@
|
||||
|
||||
/* Security Verification Trailer Signature */
|
||||
|
||||
rpc_sec_verification_trailer RPC_SEC_VERIFICATION_TRAILER =
|
||||
static const rpc_sec_verification_trailer RPC_SEC_VERIFICATION_TRAILER =
|
||||
{ { 0x8a, 0xe3, 0x13, 0x71, 0x02, 0xf4, 0x36, 0x71 } };
|
||||
|
||||
static char* PTYPE_STRINGS[] =
|
||||
static const char* PTYPE_STRINGS[] =
|
||||
{
|
||||
"PTYPE_REQUEST",
|
||||
"PTYPE_PING",
|
||||
@@ -80,7 +80,7 @@ static char* PTYPE_STRINGS[] =
|
||||
""
|
||||
};
|
||||
|
||||
const RPC_SECURITY_PROVIDER_INFO RPC_SECURITY_PROVIDER_INFO_TABLE[] =
|
||||
static const RPC_SECURITY_PROVIDER_INFO RPC_SECURITY_PROVIDER_INFO_TABLE[] =
|
||||
{
|
||||
{ RPC_C_AUTHN_NONE, TRUE, -1 },
|
||||
{ RPC_C_AUTHN_GSS_NEGOTIATE, TRUE, -1 },
|
||||
@@ -153,8 +153,8 @@ void rpc_pdu_header_print(rpcconn_hdr_t* header)
|
||||
|
||||
WLog_INFO(TAG, " }");
|
||||
WLog_INFO(TAG, "packed_drep[4]: %02"PRIX8" %02"PRIX8" %02"PRIX8" %02"PRIX8"",
|
||||
header->common.packed_drep[0], header->common.packed_drep[1],
|
||||
header->common.packed_drep[2], header->common.packed_drep[3]);
|
||||
header->common.packed_drep[0], header->common.packed_drep[1],
|
||||
header->common.packed_drep[2], header->common.packed_drep[3]);
|
||||
WLog_INFO(TAG, "frag_length: %"PRIu16"", header->common.frag_length);
|
||||
WLog_INFO(TAG, "auth_length: %"PRIu16"", header->common.auth_length);
|
||||
WLog_INFO(TAG, "call_id: %"PRIu32"", header->common.call_id);
|
||||
@@ -277,7 +277,6 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l
|
||||
UINT32 auth_pad_length;
|
||||
UINT32 sec_trailer_offset;
|
||||
rpc_sec_trailer* sec_trailer;
|
||||
|
||||
*offset = RPC_COMMON_FIELDS_LENGTH;
|
||||
header = ((rpcconn_hdr_t*) buffer);
|
||||
|
||||
@@ -320,12 +319,12 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l
|
||||
sec_trailer_offset = frag_length - auth_length - 8;
|
||||
sec_trailer = (rpc_sec_trailer*) &buffer[sec_trailer_offset];
|
||||
auth_pad_length = sec_trailer->auth_pad_length;
|
||||
|
||||
#if 0
|
||||
WLog_DBG(TAG, "sec_trailer: type: %"PRIu8" level: %"PRIu8" pad_length: %"PRIu8" reserved: %"PRIu8" context_id: %"PRIu32"",
|
||||
sec_trailer->auth_type, sec_trailer->auth_level,
|
||||
sec_trailer->auth_pad_length, sec_trailer->auth_reserved,
|
||||
sec_trailer->auth_context_id);
|
||||
WLog_DBG(TAG,
|
||||
"sec_trailer: type: %"PRIu8" level: %"PRIu8" pad_length: %"PRIu8" reserved: %"PRIu8" context_id: %"PRIu32"",
|
||||
sec_trailer->auth_type, sec_trailer->auth_level,
|
||||
sec_trailer->auth_pad_length, sec_trailer->auth_reserved,
|
||||
sec_trailer->auth_context_id);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -337,7 +336,7 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l
|
||||
if ((frag_length - (sec_trailer_offset + 8)) != auth_length)
|
||||
{
|
||||
WLog_ERR(TAG, "invalid auth_length: actual: %"PRIu32", expected: %"PRIu32"", auth_length,
|
||||
(frag_length - (sec_trailer_offset + 8)));
|
||||
(frag_length - (sec_trailer_offset + 8)));
|
||||
}
|
||||
|
||||
*length = frag_length - auth_length - 24 - 8 - auth_pad_length;
|
||||
@@ -347,7 +346,6 @@ BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* buffer, UINT32* offset, UINT32* l
|
||||
int rpc_out_channel_read(RpcOutChannel* outChannel, BYTE* data, int length)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = BIO_read(outChannel->tls->bio, data, length);
|
||||
|
||||
if (status > 0)
|
||||
@@ -367,18 +365,14 @@ int rpc_out_channel_read(RpcOutChannel* outChannel, BYTE* data, int length)
|
||||
int rpc_in_channel_write(RpcInChannel* inChannel, const BYTE* data, int length)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = tls_write_all(inChannel->tls, data, length);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int rpc_out_channel_write(RpcOutChannel* outChannel, const BYTE* data, int length)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = tls_write_all(outChannel->tls, data, length);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -420,14 +414,12 @@ int rpc_in_channel_transition_to_state(RpcInChannel* inChannel, CLIENT_IN_CHANNE
|
||||
|
||||
inChannel->State = state;
|
||||
WLog_DBG(TAG, "%s", str);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int rpc_in_channel_rpch_init(rdpRpc* rpc, RpcInChannel* inChannel)
|
||||
static int rpc_in_channel_rpch_init(rdpRpc* rpc, RpcInChannel* inChannel)
|
||||
{
|
||||
HttpContext* http;
|
||||
|
||||
inChannel->ntlm = ntlm_new();
|
||||
|
||||
if (!inChannel->ntlm)
|
||||
@@ -439,25 +431,20 @@ int rpc_in_channel_rpch_init(rdpRpc* rpc, RpcInChannel* inChannel)
|
||||
return -1;
|
||||
|
||||
http = inChannel->http;
|
||||
|
||||
http_context_set_method(http, "RPC_IN_DATA");
|
||||
|
||||
http_context_set_uri(http, "/rpc/rpcproxy.dll?localhost:3388");
|
||||
http_context_set_accept(http, "application/rpc");
|
||||
http_context_set_cache_control(http, "no-cache");
|
||||
http_context_set_connection(http, "Keep-Alive");
|
||||
http_context_set_user_agent(http, "MSRPC");
|
||||
http_context_set_host(http, rpc->settings->GatewayHostname);
|
||||
|
||||
http_context_set_pragma(http, "ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rpc_in_channel_init(rdpRpc* rpc, RpcInChannel* inChannel)
|
||||
static int rpc_in_channel_init(rdpRpc* rpc, RpcInChannel* inChannel)
|
||||
{
|
||||
rts_generate_cookie((BYTE*) &inChannel->Cookie);
|
||||
|
||||
inChannel->rpc = rpc;
|
||||
inChannel->State = CLIENT_IN_CHANNEL_STATE_INITIAL;
|
||||
inChannel->BytesSent = 0;
|
||||
@@ -471,7 +458,7 @@ int rpc_in_channel_init(rdpRpc* rpc, RpcInChannel* inChannel)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void rpc_in_channel_rpch_uninit(RpcInChannel* inChannel)
|
||||
static void rpc_in_channel_rpch_uninit(RpcInChannel* inChannel)
|
||||
{
|
||||
if (inChannel->ntlm)
|
||||
{
|
||||
@@ -486,10 +473,9 @@ void rpc_in_channel_rpch_uninit(RpcInChannel* inChannel)
|
||||
}
|
||||
}
|
||||
|
||||
RpcInChannel* rpc_in_channel_new(rdpRpc* rpc)
|
||||
static RpcInChannel* rpc_in_channel_new(rdpRpc* rpc)
|
||||
{
|
||||
RpcInChannel* inChannel = NULL;
|
||||
|
||||
inChannel = (RpcInChannel*) calloc(1, sizeof(RpcInChannel));
|
||||
|
||||
if (inChannel)
|
||||
@@ -500,7 +486,7 @@ RpcInChannel* rpc_in_channel_new(rdpRpc* rpc)
|
||||
return inChannel;
|
||||
}
|
||||
|
||||
void rpc_in_channel_free(RpcInChannel* inChannel)
|
||||
static void rpc_in_channel_free(RpcInChannel* inChannel)
|
||||
{
|
||||
if (!inChannel)
|
||||
return;
|
||||
@@ -566,14 +552,12 @@ int rpc_out_channel_transition_to_state(RpcOutChannel* outChannel, CLIENT_OUT_CH
|
||||
|
||||
outChannel->State = state;
|
||||
WLog_DBG(TAG, "%s", str);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int rpc_out_channel_rpch_init(rdpRpc* rpc, RpcOutChannel* outChannel)
|
||||
static int rpc_out_channel_rpch_init(rdpRpc* rpc, RpcOutChannel* outChannel)
|
||||
{
|
||||
HttpContext* http;
|
||||
|
||||
outChannel->ntlm = ntlm_new();
|
||||
|
||||
if (!outChannel->ntlm)
|
||||
@@ -585,27 +569,22 @@ int rpc_out_channel_rpch_init(rdpRpc* rpc, RpcOutChannel* outChannel)
|
||||
return -1;
|
||||
|
||||
http = outChannel->http;
|
||||
|
||||
http_context_set_method(http, "RPC_OUT_DATA");
|
||||
|
||||
http_context_set_uri(http, "/rpc/rpcproxy.dll?localhost:3388");
|
||||
http_context_set_accept(http, "application/rpc");
|
||||
http_context_set_cache_control(http, "no-cache");
|
||||
http_context_set_connection(http, "Keep-Alive");
|
||||
http_context_set_user_agent(http, "MSRPC");
|
||||
http_context_set_host(http, rpc->settings->GatewayHostname);
|
||||
|
||||
http_context_set_pragma(http,
|
||||
"ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729, "
|
||||
"SessionId=fbd9c34f-397d-471d-a109-1b08cc554624");
|
||||
|
||||
"ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729, "
|
||||
"SessionId=fbd9c34f-397d-471d-a109-1b08cc554624");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rpc_out_channel_init(rdpRpc* rpc, RpcOutChannel* outChannel)
|
||||
static int rpc_out_channel_init(rdpRpc* rpc, RpcOutChannel* outChannel)
|
||||
{
|
||||
rts_generate_cookie((BYTE*) &outChannel->Cookie);
|
||||
|
||||
outChannel->rpc = rpc;
|
||||
outChannel->State = CLIENT_OUT_CHANNEL_STATE_INITIAL;
|
||||
outChannel->BytesReceived = 0;
|
||||
@@ -620,7 +599,7 @@ int rpc_out_channel_init(rdpRpc* rpc, RpcOutChannel* outChannel)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void rpc_out_channel_rpch_uninit(RpcOutChannel* outChannel)
|
||||
static void rpc_out_channel_rpch_uninit(RpcOutChannel* outChannel)
|
||||
{
|
||||
if (outChannel->ntlm)
|
||||
{
|
||||
@@ -638,7 +617,6 @@ void rpc_out_channel_rpch_uninit(RpcOutChannel* outChannel)
|
||||
RpcOutChannel* rpc_out_channel_new(rdpRpc* rpc)
|
||||
{
|
||||
RpcOutChannel* outChannel = NULL;
|
||||
|
||||
outChannel = (RpcOutChannel*) calloc(1, sizeof(RpcOutChannel));
|
||||
|
||||
if (outChannel)
|
||||
@@ -666,7 +644,7 @@ void rpc_out_channel_free(RpcOutChannel* outChannel)
|
||||
}
|
||||
|
||||
int rpc_virtual_connection_transition_to_state(rdpRpc* rpc,
|
||||
RpcVirtualConnection* connection, VIRTUAL_CONNECTION_STATE state)
|
||||
RpcVirtualConnection* connection, VIRTUAL_CONNECTION_STATE state)
|
||||
{
|
||||
int status = 1;
|
||||
const char* str = "VIRTUAL_CONNECTION_STATE_UNKNOWN";
|
||||
@@ -700,24 +678,20 @@ int rpc_virtual_connection_transition_to_state(rdpRpc* rpc,
|
||||
|
||||
connection->State = state;
|
||||
WLog_DBG(TAG, "%s", str);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
RpcVirtualConnection* rpc_virtual_connection_new(rdpRpc* rpc)
|
||||
static RpcVirtualConnection* rpc_virtual_connection_new(rdpRpc* rpc)
|
||||
{
|
||||
RpcVirtualConnection* connection;
|
||||
|
||||
connection = (RpcVirtualConnection*) calloc(1, sizeof(RpcVirtualConnection));
|
||||
|
||||
if (!connection)
|
||||
return NULL;
|
||||
|
||||
rts_generate_cookie((BYTE*) &(connection->Cookie));
|
||||
rts_generate_cookie((BYTE*) &(connection->AssociationGroupId));
|
||||
|
||||
rts_generate_cookie((BYTE*) & (connection->Cookie));
|
||||
rts_generate_cookie((BYTE*) & (connection->AssociationGroupId));
|
||||
connection->State = VIRTUAL_CONNECTION_STATE_INITIAL;
|
||||
|
||||
connection->DefaultInChannel = rpc_in_channel_new(rpc);
|
||||
|
||||
if (!connection->DefaultInChannel)
|
||||
@@ -736,21 +710,19 @@ out_free:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void rpc_virtual_connection_free(RpcVirtualConnection* connection)
|
||||
static void rpc_virtual_connection_free(RpcVirtualConnection* connection)
|
||||
{
|
||||
if (!connection)
|
||||
return;
|
||||
|
||||
rpc_in_channel_free(connection->DefaultInChannel);
|
||||
rpc_in_channel_free(connection->NonDefaultInChannel);
|
||||
|
||||
rpc_out_channel_free(connection->DefaultOutChannel);
|
||||
rpc_out_channel_free(connection->NonDefaultOutChannel);
|
||||
|
||||
free(connection);
|
||||
}
|
||||
|
||||
int rpc_channel_tls_connect(RpcChannel* channel, int timeout)
|
||||
static int rpc_channel_tls_connect(RpcChannel* channel, int timeout)
|
||||
{
|
||||
int sockfd;
|
||||
rdpTls* tls;
|
||||
@@ -760,12 +732,11 @@ int rpc_channel_tls_connect(RpcChannel* channel, int timeout)
|
||||
rdpRpc* rpc = channel->rpc;
|
||||
rdpContext* context = rpc->context;
|
||||
rdpSettings* settings = context->settings;
|
||||
const char *peerHostname = settings->GatewayHostname;
|
||||
const char* peerHostname = settings->GatewayHostname;
|
||||
UINT16 peerPort = settings->GatewayPort;
|
||||
BOOL isProxyConnection = proxy_prepare(settings, &peerHostname, &peerPort, TRUE);
|
||||
|
||||
sockfd = freerdp_tcp_connect(context, settings, peerHostname,
|
||||
peerPort, timeout);
|
||||
peerPort, timeout);
|
||||
|
||||
if (sockfd < 1)
|
||||
return -1;
|
||||
@@ -776,7 +747,6 @@ int rpc_channel_tls_connect(RpcChannel* channel, int timeout)
|
||||
return FALSE;
|
||||
|
||||
BIO_set_fd(socketBio, sockfd, BIO_CLOSE);
|
||||
|
||||
bufferedBio = BIO_new(BIO_s_buffered_socket());
|
||||
|
||||
if (!bufferedBio)
|
||||
@@ -787,13 +757,13 @@ int rpc_channel_tls_connect(RpcChannel* channel, int timeout)
|
||||
if (!BIO_set_nonblock(bufferedBio, TRUE))
|
||||
return -1;
|
||||
|
||||
if (isProxyConnection) {
|
||||
if (isProxyConnection)
|
||||
{
|
||||
if (!proxy_connect(settings, bufferedBio, settings->GatewayHostname, settings->GatewayPort))
|
||||
return -1;
|
||||
}
|
||||
|
||||
channel->bio = bufferedBio;
|
||||
|
||||
tls = channel->tls = tls_new(settings);
|
||||
|
||||
if (!tls)
|
||||
@@ -802,7 +772,6 @@ int rpc_channel_tls_connect(RpcChannel* channel, int timeout)
|
||||
tls->hostname = settings->GatewayHostname;
|
||||
tls->port = settings->GatewayPort;
|
||||
tls->isGatewayTransport = TRUE;
|
||||
|
||||
tlsStatus = tls_connect(tls, bufferedBio);
|
||||
|
||||
if (tlsStatus < 1)
|
||||
@@ -824,7 +793,7 @@ int rpc_channel_tls_connect(RpcChannel* channel, int timeout)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rpc_in_channel_connect(RpcInChannel* inChannel, int timeout)
|
||||
static int rpc_in_channel_connect(RpcInChannel* inChannel, int timeout)
|
||||
{
|
||||
rdpRpc* rpc = inChannel->rpc;
|
||||
|
||||
@@ -847,11 +816,10 @@ int rpc_in_channel_connect(RpcInChannel* inChannel, int timeout)
|
||||
}
|
||||
|
||||
rpc_in_channel_transition_to_state(inChannel, CLIENT_IN_CHANNEL_STATE_SECURITY);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rpc_out_channel_connect(RpcOutChannel* outChannel, int timeout)
|
||||
static int rpc_out_channel_connect(RpcOutChannel* outChannel, int timeout)
|
||||
{
|
||||
rdpRpc* rpc = outChannel->rpc;
|
||||
|
||||
@@ -874,7 +842,6 @@ int rpc_out_channel_connect(RpcOutChannel* outChannel, int timeout)
|
||||
}
|
||||
|
||||
rpc_out_channel_transition_to_state(outChannel, CLIENT_OUT_CHANNEL_STATE_SECURITY);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -901,7 +868,6 @@ int rpc_out_channel_replacement_connect(RpcOutChannel* outChannel, int timeout)
|
||||
}
|
||||
|
||||
rpc_out_channel_transition_to_state(outChannel, CLIENT_OUT_CHANNEL_STATE_SECURITY);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -910,7 +876,6 @@ BOOL rpc_connect(rdpRpc* rpc, int timeout)
|
||||
RpcInChannel* inChannel;
|
||||
RpcOutChannel* outChannel;
|
||||
RpcVirtualConnection* connection;
|
||||
|
||||
rpc->VirtualConnection = rpc_virtual_connection_new(rpc);
|
||||
|
||||
if (!rpc->VirtualConnection)
|
||||
@@ -919,7 +884,6 @@ BOOL rpc_connect(rdpRpc* rpc, int timeout)
|
||||
connection = rpc->VirtualConnection;
|
||||
inChannel = connection->DefaultInChannel;
|
||||
outChannel = connection->DefaultOutChannel;
|
||||
|
||||
rpc_virtual_connection_transition_to_state(rpc, connection, VIRTUAL_CONNECTION_STATE_INITIAL);
|
||||
|
||||
if (rpc_in_channel_connect(inChannel, timeout) < 0)
|
||||
@@ -939,13 +903,10 @@ rdpRpc* rpc_new(rdpTransport* transport)
|
||||
return NULL;
|
||||
|
||||
rpc->State = RPC_CLIENT_STATE_INITIAL;
|
||||
|
||||
rpc->transport = transport;
|
||||
rpc->settings = transport->settings;
|
||||
rpc->context = transport->context;
|
||||
|
||||
rpc->SendSeqNum = 0;
|
||||
|
||||
rpc->ntlm = ntlm_new();
|
||||
|
||||
if (!rpc->ntlm)
|
||||
@@ -956,7 +917,6 @@ rdpRpc* rpc_new(rdpTransport* transport)
|
||||
rpc->StubFragCount = 0;
|
||||
rpc->rpc_vers = 5;
|
||||
rpc->rpc_vers_minor = 0;
|
||||
|
||||
/* little-endian data representation */
|
||||
rpc->packed_drep[0] = 0x10;
|
||||
rpc->packed_drep[1] = 0x00;
|
||||
@@ -964,13 +924,11 @@ rdpRpc* rpc_new(rdpTransport* transport)
|
||||
rpc->packed_drep[3] = 0x00;
|
||||
rpc->max_xmit_frag = 0x0FF8;
|
||||
rpc->max_recv_frag = 0x0FF8;
|
||||
|
||||
rpc->ReceiveWindow = 0x00010000;
|
||||
rpc->ChannelLifetime = 0x40000000;
|
||||
rpc->KeepAliveInterval = 300000;
|
||||
rpc->CurrentKeepAliveInterval = rpc->KeepAliveInterval;
|
||||
rpc->CurrentKeepAliveTime = 0;
|
||||
|
||||
rpc->CallId = 2;
|
||||
|
||||
if (rpc_client_new(rpc) < 0)
|
||||
|
||||
@@ -715,7 +715,7 @@ struct rpc_virtual_connection_cookie_entry
|
||||
RpcVirtualConnection* Reference;
|
||||
};
|
||||
typedef struct rpc_virtual_connection_cookie_entry
|
||||
RpcVirtualConnectionCookieEntry;
|
||||
RpcVirtualConnectionCookieEntry;
|
||||
|
||||
struct rpc_client
|
||||
{
|
||||
@@ -782,9 +782,6 @@ FREERDP_LOCAL int rpc_out_channel_read(RpcOutChannel* outChannel, BYTE* data,
|
||||
FREERDP_LOCAL int rpc_out_channel_write(RpcOutChannel* outChannel,
|
||||
const BYTE* data, int length);
|
||||
|
||||
FREERDP_LOCAL RpcInChannel* rpc_client_in_channel_new(rdpRpc* rpc);
|
||||
FREERDP_LOCAL void rpc_in_channel_free(RpcInChannel* inChannel);
|
||||
|
||||
FREERDP_LOCAL RpcOutChannel* rpc_out_channel_new(rdpRpc* rpc);
|
||||
FREERDP_LOCAL int rpc_out_channel_replacement_connect(RpcOutChannel* outChannel,
|
||||
int timeout);
|
||||
|
||||
@@ -47,7 +47,7 @@ static void rpc_pdu_reset(RPC_PDU* pdu)
|
||||
Stream_SetPosition(pdu->s, 0);
|
||||
}
|
||||
|
||||
RPC_PDU* rpc_pdu_new()
|
||||
static RPC_PDU* rpc_pdu_new(void)
|
||||
{
|
||||
RPC_PDU* pdu;
|
||||
pdu = (RPC_PDU*) malloc(sizeof(RPC_PDU));
|
||||
@@ -76,7 +76,7 @@ static void rpc_pdu_free(RPC_PDU* pdu)
|
||||
free(pdu);
|
||||
}
|
||||
|
||||
int rpc_client_receive_pipe_write(rdpRpc* rpc, const BYTE* buffer, size_t length)
|
||||
static int rpc_client_receive_pipe_write(rdpRpc* rpc, const BYTE* buffer, size_t length)
|
||||
{
|
||||
int status = 0;
|
||||
RpcClient* client = rpc->client;
|
||||
@@ -118,7 +118,7 @@ int rpc_client_receive_pipe_read(rdpRpc* rpc, BYTE* buffer, size_t length)
|
||||
return status;
|
||||
}
|
||||
|
||||
int rpc_client_transition_to_state(rdpRpc* rpc, RPC_CLIENT_STATE state)
|
||||
static int rpc_client_transition_to_state(rdpRpc* rpc, RPC_CLIENT_STATE state)
|
||||
{
|
||||
int status = 1;
|
||||
const char* str = "RPC_CLIENT_STATE_UNKNOWN";
|
||||
@@ -163,7 +163,7 @@ int rpc_client_transition_to_state(rdpRpc* rpc, RPC_CLIENT_STATE state)
|
||||
return status;
|
||||
}
|
||||
|
||||
int rpc_client_recv_pdu(rdpRpc* rpc, RPC_PDU* pdu)
|
||||
static int rpc_client_recv_pdu(rdpRpc* rpc, RPC_PDU* pdu)
|
||||
{
|
||||
int status = -1;
|
||||
rpcconn_rts_hdr_t* rts;
|
||||
@@ -287,7 +287,7 @@ int rpc_client_recv_pdu(rdpRpc* rpc, RPC_PDU* pdu)
|
||||
return status;
|
||||
}
|
||||
|
||||
int rpc_client_recv_fragment(rdpRpc* rpc, wStream* fragment)
|
||||
static int rpc_client_recv_fragment(rdpRpc* rpc, wStream* fragment)
|
||||
{
|
||||
BYTE* buffer;
|
||||
RPC_PDU* pdu;
|
||||
@@ -448,7 +448,7 @@ int rpc_client_recv_fragment(rdpRpc* rpc, wStream* fragment)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rpc_client_default_out_channel_recv(rdpRpc* rpc)
|
||||
static int rpc_client_default_out_channel_recv(rdpRpc* rpc)
|
||||
{
|
||||
int status = -1;
|
||||
UINT32 statusCode;
|
||||
@@ -539,6 +539,7 @@ int rpc_client_default_out_channel_recv(rdpRpc* rpc)
|
||||
freerdp_set_last_error(rpc->context, FREERDP_ERROR_AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
http_response_free(response);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -632,7 +633,7 @@ int rpc_client_default_out_channel_recv(rdpRpc* rpc)
|
||||
return status;
|
||||
}
|
||||
|
||||
int rpc_client_nondefault_out_channel_recv(rdpRpc* rpc)
|
||||
static int rpc_client_nondefault_out_channel_recv(rdpRpc* rpc)
|
||||
{
|
||||
int status = -1;
|
||||
HttpResponse* response;
|
||||
@@ -738,6 +739,7 @@ int rpc_client_in_channel_recv(rdpRpc* rpc)
|
||||
if (rpc_ncacn_http_recv_in_channel_response(rpc, inChannel, response) < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "rpc_ncacn_http_recv_in_channel_response failure");
|
||||
http_response_free(response);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -746,6 +748,7 @@ int rpc_client_in_channel_recv(rdpRpc* rpc)
|
||||
if (rpc_ncacn_http_send_in_channel_request(rpc, inChannel) < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "rpc_ncacn_http_send_in_channel_request failure");
|
||||
http_response_free(response);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -758,6 +761,7 @@ int rpc_client_in_channel_recv(rdpRpc* rpc)
|
||||
if (rts_send_CONN_B1_pdu(rpc) < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "rpc_send_CONN_B1_pdu error!");
|
||||
http_response_free(response);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,7 @@
|
||||
|
||||
#define TAG FREERDP_TAG("core.gateway.rpc")
|
||||
|
||||
extern const RPC_FAULT_CODE RPC_TSG_FAULT_CODES[];
|
||||
|
||||
const RPC_FAULT_CODE RPC_FAULT_CODES[] =
|
||||
static const RPC_FAULT_CODE RPC_FAULT_CODES[] =
|
||||
{
|
||||
DEFINE_RPC_FAULT_CODE(nca_s_fault_object_not_found)
|
||||
DEFINE_RPC_FAULT_CODE(nca_s_fault_cancel)
|
||||
@@ -156,10 +154,12 @@ const RPC_FAULT_CODE RPC_FAULT_CODES[] =
|
||||
DEFINE_RPC_FAULT_CODE(RPC_S_GROUP_MEMBER_NOT_FOUND)
|
||||
DEFINE_RPC_FAULT_CODE(EPT_S_CANT_CREATE)
|
||||
DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_OBJECT)
|
||||
{ 0, NULL }
|
||||
{
|
||||
0, NULL
|
||||
}
|
||||
};
|
||||
|
||||
const RPC_FAULT_CODE RPC_TSG_FAULT_CODES[] =
|
||||
static const RPC_FAULT_CODE RPC_TSG_FAULT_CODES[] =
|
||||
{
|
||||
DEFINE_RPC_FAULT_CODE(RPC_S_OK)
|
||||
DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_ARG)
|
||||
@@ -209,7 +209,9 @@ const RPC_FAULT_CODE RPC_TSG_FAULT_CODES[] =
|
||||
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_CONNECTIONABORTED))
|
||||
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_NOCERTAVAILABLE))
|
||||
DEFINE_RPC_FAULT_CODE(__HRESULT_FROM_WIN32(RPC_S_CALL_CANCELLED))
|
||||
{ 0, NULL }
|
||||
{
|
||||
0, NULL
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -217,96 +219,139 @@ const RPC_FAULT_CODE RPC_TSG_FAULT_CODES[] =
|
||||
* http://msdn.microsoft.com/en-us/library/ee442005/
|
||||
*/
|
||||
|
||||
UINT32 rpc_map_status_code_to_win32_error_code(UINT32 code)
|
||||
static UINT32 rpc_map_status_code_to_win32_error_code(UINT32 code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case nca_s_comm_failure:
|
||||
return RPC_S_COMM_FAILURE;
|
||||
|
||||
case nca_s_op_rng_error:
|
||||
return RPC_S_PROCNUM_OUT_OF_RANGE;
|
||||
|
||||
case nca_s_unk_if:
|
||||
return RPC_S_UNKNOWN_IF;
|
||||
|
||||
case nca_s_wrong_boot_time:
|
||||
return nca_s_wrong_boot_time;
|
||||
|
||||
case nca_s_you_crashed:
|
||||
return RPC_S_CALL_FAILED;
|
||||
|
||||
case nca_s_proto_error:
|
||||
return RPC_S_PROTOCOL_ERROR;
|
||||
|
||||
case nca_s_out_args_too_big:
|
||||
return RPC_S_SERVER_OUT_OF_MEMORY;
|
||||
|
||||
case nca_s_server_too_busy:
|
||||
return RPC_S_SERVER_TOO_BUSY;
|
||||
|
||||
case nca_s_unsupported_type:
|
||||
return RPC_S_UNSUPPORTED_TYPE;
|
||||
|
||||
case nca_s_fault_int_div_by_zero:
|
||||
return RPC_S_ZERO_DIVIDE;
|
||||
|
||||
case nca_s_fault_addr_error:
|
||||
return RPC_S_ADDRESS_ERROR;
|
||||
|
||||
case nca_s_fault_fp_div_zero:
|
||||
return RPC_S_FP_DIV_ZERO;
|
||||
|
||||
case nca_s_fault_fp_underflow:
|
||||
return RPC_S_FP_UNDERFLOW;
|
||||
|
||||
case nca_s_fault_fp_overflow:
|
||||
return RPC_S_FP_OVERFLOW;
|
||||
|
||||
case nca_s_fault_invalid_tag:
|
||||
return RPC_S_INVALID_TAG;
|
||||
|
||||
case nca_s_fault_invalid_bound:
|
||||
return RPC_S_INVALID_BOUND;
|
||||
|
||||
case nca_s_rpc_version_mismatch:
|
||||
return RPC_S_PROTOCOL_ERROR;
|
||||
|
||||
case nca_s_unspec_reject:
|
||||
return RPC_S_CALL_FAILED;
|
||||
|
||||
case nca_s_bad_actid:
|
||||
return RPC_S_CALL_FAILED_DNE;
|
||||
|
||||
case nca_s_who_are_you_failed:
|
||||
return RPC_S_CALL_FAILED;
|
||||
|
||||
case nca_s_manager_not_entered:
|
||||
return RPC_S_CALL_FAILED_DNE;
|
||||
|
||||
case nca_s_fault_cancel:
|
||||
return RPC_S_CALL_CANCELLED;
|
||||
|
||||
case nca_s_fault_ill_inst:
|
||||
return RPC_S_ADDRESS_ERROR;
|
||||
|
||||
case nca_s_fault_fp_error:
|
||||
return RPC_S_FP_OVERFLOW;
|
||||
|
||||
case nca_s_fault_int_overflow:
|
||||
return RPC_S_ADDRESS_ERROR;
|
||||
|
||||
case nca_s_fault_unspec:
|
||||
return RPC_S_CALL_FAILED;
|
||||
|
||||
case nca_s_fault_remote_comm_failure:
|
||||
return nca_s_fault_remote_comm_failure;
|
||||
|
||||
case nca_s_fault_pipe_empty:
|
||||
return RPC_X_PIPE_EMPTY;
|
||||
|
||||
case nca_s_fault_pipe_closed:
|
||||
return RPC_X_PIPE_CLOSED;
|
||||
|
||||
case nca_s_fault_pipe_order:
|
||||
return RPC_X_WRONG_PIPE_ORDER;
|
||||
|
||||
case nca_s_fault_pipe_discipline:
|
||||
return RPC_X_PIPE_DISCIPLINE_ERROR;
|
||||
|
||||
case nca_s_fault_pipe_comm_error:
|
||||
return RPC_S_COMM_FAILURE;
|
||||
|
||||
case nca_s_fault_pipe_memory:
|
||||
return RPC_S_OUT_OF_MEMORY;
|
||||
|
||||
case nca_s_fault_context_mismatch:
|
||||
return RPC_X_SS_CONTEXT_MISMATCH;
|
||||
|
||||
case nca_s_fault_remote_no_memory:
|
||||
return RPC_S_SERVER_OUT_OF_MEMORY;
|
||||
|
||||
case nca_s_invalid_pres_context_id:
|
||||
return RPC_S_PROTOCOL_ERROR;
|
||||
|
||||
case nca_s_unsupported_authn_level:
|
||||
return RPC_S_UNSUPPORTED_AUTHN_LEVEL;
|
||||
|
||||
case nca_s_invalid_checksum:
|
||||
return RPC_S_CALL_FAILED_DNE;
|
||||
|
||||
case nca_s_invalid_crc:
|
||||
return RPC_S_CALL_FAILED_DNE;
|
||||
|
||||
case nca_s_fault_user_defined:
|
||||
return nca_s_fault_user_defined;
|
||||
|
||||
case nca_s_fault_tx_open_failed:
|
||||
return nca_s_fault_tx_open_failed;
|
||||
|
||||
case nca_s_fault_codeset_conv_error:
|
||||
return nca_s_fault_codeset_conv_error;
|
||||
|
||||
case nca_s_fault_object_not_found:
|
||||
return nca_s_fault_object_not_found;
|
||||
|
||||
case nca_s_fault_no_client_stub:
|
||||
return nca_s_fault_no_client_stub;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,5 @@
|
||||
#include <freerdp/api.h>
|
||||
|
||||
FREERDP_LOCAL int rpc_recv_fault_pdu(rpcconn_hdr_t* header);
|
||||
FREERDP_LOCAL UINT32 rpc_map_status_code_to_win32_error_code(UINT32 code);
|
||||
|
||||
#endif /* FREERDP_LIB_CORE_GATEWAY_RPC_FAULT_H */
|
||||
|
||||
@@ -99,7 +99,7 @@ static void rts_pdu_header_init(rpcconn_rts_hdr_t* header)
|
||||
header->call_id = 0;
|
||||
}
|
||||
|
||||
int rts_receive_window_size_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length,
|
||||
static int rts_receive_window_size_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length,
|
||||
UINT32* ReceiveWindowSize)
|
||||
{
|
||||
if (ReceiveWindowSize)
|
||||
@@ -108,7 +108,7 @@ int rts_receive_window_size_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 lengt
|
||||
return 4;
|
||||
}
|
||||
|
||||
int rts_receive_window_size_command_write(BYTE* buffer, UINT32 ReceiveWindowSize)
|
||||
static int rts_receive_window_size_command_write(BYTE* buffer, UINT32 ReceiveWindowSize)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -119,8 +119,8 @@ int rts_receive_window_size_command_write(BYTE* buffer, UINT32 ReceiveWindowSize
|
||||
return 8;
|
||||
}
|
||||
|
||||
int rts_flow_control_ack_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length,
|
||||
UINT32* BytesReceived, UINT32* AvailableWindow, BYTE* ChannelCookie)
|
||||
static int rts_flow_control_ack_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length,
|
||||
UINT32* BytesReceived, UINT32* AvailableWindow, BYTE* ChannelCookie)
|
||||
{
|
||||
/* Ack (24 bytes) */
|
||||
if (BytesReceived)
|
||||
@@ -135,8 +135,9 @@ int rts_flow_control_ack_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length,
|
||||
return 24;
|
||||
}
|
||||
|
||||
int rts_flow_control_ack_command_write(BYTE* buffer, UINT32 BytesReceived, UINT32 AvailableWindow,
|
||||
BYTE* ChannelCookie)
|
||||
static int rts_flow_control_ack_command_write(BYTE* buffer, UINT32 BytesReceived,
|
||||
UINT32 AvailableWindow,
|
||||
BYTE* ChannelCookie)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -150,8 +151,8 @@ int rts_flow_control_ack_command_write(BYTE* buffer, UINT32 BytesReceived, UINT3
|
||||
return 28;
|
||||
}
|
||||
|
||||
int rts_connection_timeout_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length,
|
||||
UINT32* ConnectionTimeout)
|
||||
static int rts_connection_timeout_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length,
|
||||
UINT32* ConnectionTimeout)
|
||||
{
|
||||
if (ConnectionTimeout)
|
||||
*ConnectionTimeout = *((UINT32*) &buffer[0]); /* ConnectionTimeout (4 bytes) */
|
||||
@@ -159,7 +160,7 @@ int rts_connection_timeout_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length
|
||||
return 4;
|
||||
}
|
||||
|
||||
int rts_connection_timeout_command_write(BYTE* buffer, UINT32 ConnectionTimeout)
|
||||
static int rts_connection_timeout_command_write(BYTE* buffer, UINT32 ConnectionTimeout)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -170,13 +171,13 @@ int rts_connection_timeout_command_write(BYTE* buffer, UINT32 ConnectionTimeout)
|
||||
return 8;
|
||||
}
|
||||
|
||||
int rts_cookie_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
static int rts_cookie_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
/* Cookie (16 bytes) */
|
||||
return 16;
|
||||
}
|
||||
|
||||
int rts_cookie_command_write(BYTE* buffer, BYTE* Cookie)
|
||||
static int rts_cookie_command_write(BYTE* buffer, BYTE* Cookie)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -187,13 +188,13 @@ int rts_cookie_command_write(BYTE* buffer, BYTE* Cookie)
|
||||
return 20;
|
||||
}
|
||||
|
||||
int rts_channel_lifetime_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
static int rts_channel_lifetime_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
/* ChannelLifetime (4 bytes) */
|
||||
return 4;
|
||||
}
|
||||
|
||||
int rts_channel_lifetime_command_write(BYTE* buffer, UINT32 ChannelLifetime)
|
||||
static int rts_channel_lifetime_command_write(BYTE* buffer, UINT32 ChannelLifetime)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -204,13 +205,13 @@ int rts_channel_lifetime_command_write(BYTE* buffer, UINT32 ChannelLifetime)
|
||||
return 8;
|
||||
}
|
||||
|
||||
int rts_client_keepalive_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
static int rts_client_keepalive_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
/* ClientKeepalive (4 bytes) */
|
||||
return 4;
|
||||
}
|
||||
|
||||
int rts_client_keepalive_command_write(BYTE* buffer, UINT32 ClientKeepalive)
|
||||
static int rts_client_keepalive_command_write(BYTE* buffer, UINT32 ClientKeepalive)
|
||||
{
|
||||
/**
|
||||
* An unsigned integer that specifies the keep-alive interval, in milliseconds,
|
||||
@@ -226,13 +227,13 @@ int rts_client_keepalive_command_write(BYTE* buffer, UINT32 ClientKeepalive)
|
||||
return 8;
|
||||
}
|
||||
|
||||
int rts_version_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
static int rts_version_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
/* Version (4 bytes) */
|
||||
return 4;
|
||||
}
|
||||
|
||||
int rts_version_command_write(BYTE* buffer)
|
||||
static int rts_version_command_write(BYTE* buffer)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -243,12 +244,12 @@ int rts_version_command_write(BYTE* buffer)
|
||||
return 8;
|
||||
}
|
||||
|
||||
int rts_empty_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
static int rts_empty_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rts_empty_command_write(BYTE* buffer)
|
||||
static int rts_empty_command_write(BYTE* buffer)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -258,7 +259,7 @@ int rts_empty_command_write(BYTE* buffer)
|
||||
return 4;
|
||||
}
|
||||
|
||||
int rts_padding_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
static int rts_padding_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
UINT32 ConformanceCount;
|
||||
ConformanceCount = *((UINT32*) &buffer[0]); /* ConformanceCount (4 bytes) */
|
||||
@@ -266,7 +267,7 @@ int rts_padding_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
return ConformanceCount + 4;
|
||||
}
|
||||
|
||||
int rts_padding_command_write(BYTE* buffer, UINT32 ConformanceCount)
|
||||
static int rts_padding_command_write(BYTE* buffer, UINT32 ConformanceCount)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -278,12 +279,12 @@ int rts_padding_command_write(BYTE* buffer, UINT32 ConformanceCount)
|
||||
return 8 + ConformanceCount;
|
||||
}
|
||||
|
||||
int rts_negative_ance_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
static int rts_negative_ance_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rts_negative_ance_command_write(BYTE* buffer)
|
||||
static int rts_negative_ance_command_write(BYTE* buffer)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -293,12 +294,12 @@ int rts_negative_ance_command_write(BYTE* buffer)
|
||||
return 4;
|
||||
}
|
||||
|
||||
int rts_ance_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
static int rts_ance_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rts_ance_command_write(BYTE* buffer)
|
||||
static int rts_ance_command_write(BYTE* buffer)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -308,7 +309,7 @@ int rts_ance_command_write(BYTE* buffer)
|
||||
return 4;
|
||||
}
|
||||
|
||||
int rts_client_address_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
static int rts_client_address_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
UINT32 AddressType;
|
||||
AddressType = *((UINT32*) &buffer[0]); /* AddressType (4 bytes) */
|
||||
@@ -327,7 +328,7 @@ int rts_client_address_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
}
|
||||
}
|
||||
|
||||
int rts_client_address_command_write(BYTE* buffer, UINT32 AddressType, BYTE* ClientAddress)
|
||||
static int rts_client_address_command_write(BYTE* buffer, UINT32 AddressType, BYTE* ClientAddress)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -357,13 +358,13 @@ int rts_client_address_command_write(BYTE* buffer, UINT32 AddressType, BYTE* Cli
|
||||
}
|
||||
}
|
||||
|
||||
int rts_association_group_id_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
static int rts_association_group_id_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
/* AssociationGroupId (16 bytes) */
|
||||
return 16;
|
||||
}
|
||||
|
||||
int rts_association_group_id_command_write(BYTE* buffer, BYTE* AssociationGroupId)
|
||||
static int rts_association_group_id_command_write(BYTE* buffer, BYTE* AssociationGroupId)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -374,7 +375,8 @@ int rts_association_group_id_command_write(BYTE* buffer, BYTE* AssociationGroupI
|
||||
return 20;
|
||||
}
|
||||
|
||||
int rts_destination_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length, UINT32* Destination)
|
||||
static int rts_destination_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length,
|
||||
UINT32* Destination)
|
||||
{
|
||||
if (Destination)
|
||||
*Destination = *((UINT32*) &buffer[0]); /* Destination (4 bytes) */
|
||||
@@ -382,7 +384,7 @@ int rts_destination_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length, UINT3
|
||||
return 4;
|
||||
}
|
||||
|
||||
int rts_destination_command_write(BYTE* buffer, UINT32 Destination)
|
||||
static int rts_destination_command_write(BYTE* buffer, UINT32 Destination)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -393,13 +395,13 @@ int rts_destination_command_write(BYTE* buffer, UINT32 Destination)
|
||||
return 8;
|
||||
}
|
||||
|
||||
int rts_ping_traffic_sent_notify_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
static int rts_ping_traffic_sent_notify_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
/* PingTrafficSent (4 bytes) */
|
||||
return 4;
|
||||
}
|
||||
|
||||
int rts_ping_traffic_sent_notify_command_write(BYTE* buffer, UINT32 PingTrafficSent)
|
||||
static int rts_ping_traffic_sent_notify_command_write(BYTE* buffer, UINT32 PingTrafficSent)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
@@ -432,8 +434,8 @@ int rts_send_CONN_A1_pdu(rdpRpc* rpc)
|
||||
header.Flags = RTS_FLAG_NONE;
|
||||
header.NumberOfCommands = 4;
|
||||
WLog_DBG(TAG, "Sending CONN/A1 RTS PDU");
|
||||
VirtualConnectionCookie = (BYTE*) &(connection->Cookie);
|
||||
OUTChannelCookie = (BYTE*) &(outChannel->Cookie);
|
||||
VirtualConnectionCookie = (BYTE*) & (connection->Cookie);
|
||||
OUTChannelCookie = (BYTE*) & (outChannel->Cookie);
|
||||
ReceiveWindowSize = outChannel->ReceiveWindow;
|
||||
buffer = (BYTE*) malloc(header.frag_length);
|
||||
|
||||
@@ -479,9 +481,9 @@ int rts_send_CONN_B1_pdu(rdpRpc* rpc)
|
||||
header.Flags = RTS_FLAG_NONE;
|
||||
header.NumberOfCommands = 6;
|
||||
WLog_DBG(TAG, "Sending CONN/B1 RTS PDU");
|
||||
VirtualConnectionCookie = (BYTE*) &(connection->Cookie);
|
||||
INChannelCookie = (BYTE*) &(inChannel->Cookie);
|
||||
AssociationGroupId = (BYTE*) &(connection->AssociationGroupId);
|
||||
VirtualConnectionCookie = (BYTE*) & (connection->Cookie);
|
||||
INChannelCookie = (BYTE*) & (inChannel->Cookie);
|
||||
AssociationGroupId = (BYTE*) & (connection->AssociationGroupId);
|
||||
buffer = (BYTE*) malloc(header.frag_length);
|
||||
|
||||
if (!buffer)
|
||||
@@ -527,7 +529,7 @@ int rts_recv_CONN_C2_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
|
||||
/* Out-of-Sequence PDUs */
|
||||
|
||||
int rts_send_keep_alive_pdu(rdpRpc* rpc)
|
||||
static int rts_send_keep_alive_pdu(rdpRpc* rpc)
|
||||
{
|
||||
int status;
|
||||
BYTE* buffer;
|
||||
@@ -572,7 +574,7 @@ int rts_send_flow_control_ack_pdu(rdpRpc* rpc)
|
||||
WLog_DBG(TAG, "Sending FlowControlAck RTS PDU");
|
||||
BytesReceived = outChannel->BytesReceived;
|
||||
AvailableWindow = outChannel->AvailableWindowAdvertised;
|
||||
ChannelCookie = (BYTE*) &(outChannel->Cookie);
|
||||
ChannelCookie = (BYTE*) & (outChannel->Cookie);
|
||||
outChannel->ReceiverAvailableWindow = outChannel->AvailableWindowAdvertised;
|
||||
buffer = (BYTE*) malloc(header.frag_length);
|
||||
|
||||
@@ -640,7 +642,7 @@ static int rts_recv_flow_control_ack_with_destination_pdu(rdpRpc* rpc, BYTE* buf
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rts_send_ping_pdu(rdpRpc* rpc)
|
||||
static int rts_send_ping_pdu(rdpRpc* rpc)
|
||||
{
|
||||
int status;
|
||||
BYTE* buffer;
|
||||
@@ -752,7 +754,7 @@ static int rts_send_OUT_R2_A7_pdu(rdpRpc* rpc)
|
||||
header.Flags = RTS_FLAG_OUT_CHANNEL;
|
||||
header.NumberOfCommands = 3;
|
||||
WLog_DBG(TAG, "Sending OUT_R2/A7 RTS PDU");
|
||||
SuccessorChannelCookie = (BYTE*) &(nextOutChannel->Cookie);
|
||||
SuccessorChannelCookie = (BYTE*) & (nextOutChannel->Cookie);
|
||||
buffer = (BYTE*) malloc(header.frag_length);
|
||||
|
||||
if (!buffer)
|
||||
@@ -808,9 +810,9 @@ int rts_send_OUT_R1_A3_pdu(rdpRpc* rpc)
|
||||
header.Flags = RTS_FLAG_RECYCLE_CHANNEL;
|
||||
header.NumberOfCommands = 5;
|
||||
WLog_DBG(TAG, "Sending OUT_R1/A3 RTS PDU");
|
||||
VirtualConnectionCookie = (BYTE*) &(connection->Cookie);
|
||||
PredecessorChannelCookie = (BYTE*) &(outChannel->Cookie);
|
||||
SuccessorChannelCookie = (BYTE*) &(nextOutChannel->Cookie);
|
||||
VirtualConnectionCookie = (BYTE*) & (connection->Cookie);
|
||||
PredecessorChannelCookie = (BYTE*) & (outChannel->Cookie);
|
||||
SuccessorChannelCookie = (BYTE*) & (nextOutChannel->Cookie);
|
||||
ReceiveWindowSize = outChannel->ReceiveWindow;
|
||||
buffer = (BYTE*) malloc(header.frag_length);
|
||||
|
||||
|
||||
@@ -81,78 +81,6 @@ FREERDP_LOCAL void rts_generate_cookie(BYTE* cookie);
|
||||
|
||||
FREERDP_LOCAL int rts_command_length(rdpRpc* rpc, UINT32 CommandType,
|
||||
BYTE* buffer, UINT32 length);
|
||||
FREERDP_LOCAL int rts_recv_pdu_commands(rdpRpc* rpc, rpcconn_rts_hdr_t* rts);
|
||||
|
||||
FREERDP_LOCAL int rts_receive_window_size_command_read(rdpRpc* rpc,
|
||||
BYTE* buffer, UINT32 length, UINT32* ReceiveWindowSize);
|
||||
FREERDP_LOCAL int rts_receive_window_size_command_write(BYTE* buffer,
|
||||
UINT32 ReceiveWindowSize);
|
||||
|
||||
FREERDP_LOCAL int rts_flow_control_ack_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length,
|
||||
UINT32* BytesReceived, UINT32* AvailableWindow, BYTE* ChannelCookie);
|
||||
FREERDP_LOCAL int rts_flow_control_ack_command_write(BYTE* buffer,
|
||||
UINT32 BytesReceived, UINT32 AvailableWindow, BYTE* ChannelCookie);
|
||||
|
||||
FREERDP_LOCAL int rts_connection_timeout_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length, UINT32* ConnectionTimeout);
|
||||
FREERDP_LOCAL int rts_connection_timeout_command_write(BYTE* buffer,
|
||||
UINT32 ConnectionTimeout);
|
||||
|
||||
FREERDP_LOCAL int rts_cookie_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length);
|
||||
FREERDP_LOCAL int rts_cookie_command_write(BYTE* buffer, BYTE* Cookie);
|
||||
|
||||
FREERDP_LOCAL int rts_channel_lifetime_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length);
|
||||
FREERDP_LOCAL int rts_channel_lifetime_command_write(BYTE* buffer,
|
||||
UINT32 ChannelLifetime);
|
||||
|
||||
FREERDP_LOCAL int rts_client_keepalive_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length);
|
||||
FREERDP_LOCAL int rts_client_keepalive_command_write(BYTE* buffer,
|
||||
UINT32 ClientKeepalive);
|
||||
|
||||
FREERDP_LOCAL int rts_version_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length);
|
||||
FREERDP_LOCAL int rts_version_command_write(BYTE* buffer);
|
||||
|
||||
FREERDP_LOCAL int rts_empty_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length);
|
||||
FREERDP_LOCAL int rts_empty_command_write(BYTE* buffer);
|
||||
|
||||
FREERDP_LOCAL int rts_padding_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length);
|
||||
FREERDP_LOCAL int rts_padding_command_write(BYTE* buffer,
|
||||
UINT32 ConformanceCount);
|
||||
|
||||
FREERDP_LOCAL int rts_negative_ance_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length);
|
||||
FREERDP_LOCAL int rts_negative_ance_command_write(BYTE* buffer);
|
||||
|
||||
FREERDP_LOCAL int rts_ance_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length);
|
||||
FREERDP_LOCAL int rts_ance_command_write(BYTE* buffer);
|
||||
|
||||
FREERDP_LOCAL int rts_client_address_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length);
|
||||
FREERDP_LOCAL int rts_client_address_command_write(BYTE* buffer,
|
||||
UINT32 AddressType, BYTE* ClientAddress);
|
||||
|
||||
FREERDP_LOCAL int rts_association_group_id_command_read(rdpRpc* rpc,
|
||||
BYTE* buffer, UINT32 length);
|
||||
FREERDP_LOCAL int rts_association_group_id_command_write(BYTE* buffer,
|
||||
BYTE* AssociationGroupId);
|
||||
|
||||
FREERDP_LOCAL int rts_destination_command_read(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length, UINT32* Destination);
|
||||
FREERDP_LOCAL int rts_destination_command_write(BYTE* buffer,
|
||||
UINT32 Destination);
|
||||
|
||||
FREERDP_LOCAL int rts_ping_traffic_sent_notify_command_read(rdpRpc* rpc,
|
||||
BYTE* buffer, UINT32 length);
|
||||
FREERDP_LOCAL int rts_ping_traffic_sent_notify_command_write(BYTE* buffer,
|
||||
UINT32 PingTrafficSent);
|
||||
|
||||
FREERDP_LOCAL int rts_send_CONN_A1_pdu(rdpRpc* rpc);
|
||||
FREERDP_LOCAL int rts_recv_CONN_A3_pdu(rdpRpc* rpc, BYTE* buffer,
|
||||
@@ -165,9 +93,7 @@ FREERDP_LOCAL int rts_recv_CONN_C2_pdu(rdpRpc* rpc, BYTE* buffer,
|
||||
|
||||
FREERDP_LOCAL int rts_send_OUT_R1_A3_pdu(rdpRpc* rpc);
|
||||
|
||||
FREERDP_LOCAL int rts_send_keep_alive_pdu(rdpRpc* rpc);
|
||||
FREERDP_LOCAL int rts_send_flow_control_ack_pdu(rdpRpc* rpc);
|
||||
FREERDP_LOCAL int rts_send_ping_pdu(rdpRpc* rpc);
|
||||
|
||||
FREERDP_LOCAL int rts_recv_out_of_sequence_pdu(rdpRpc* rpc, BYTE* buffer,
|
||||
UINT32 length);
|
||||
|
||||
@@ -24,126 +24,194 @@
|
||||
#define TAG FREERDP_TAG("core.gateway.rts")
|
||||
|
||||
RtsPduSignature RTS_PDU_CONN_A1_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_CONN_A2_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 5,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0 } };
|
||||
{
|
||||
RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0
|
||||
}
|
||||
};
|
||||
RtsPduSignature RTS_PDU_CONN_A3_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
RtsPduSignature RTS_PDU_CONN_B1_SIGNATURE = { RTS_FLAG_NONE, 6,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_CLIENT_KEEPALIVE, RTS_CMD_ASSOCIATION_GROUP_ID, 0, 0 } };
|
||||
{
|
||||
RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_CLIENT_KEEPALIVE, RTS_CMD_ASSOCIATION_GROUP_ID, 0, 0
|
||||
}
|
||||
};
|
||||
RtsPduSignature RTS_PDU_CONN_B2_SIGNATURE = { RTS_FLAG_IN_CHANNEL, 7,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, RTS_CMD_ASSOCIATION_GROUP_ID, RTS_CMD_CLIENT_ADDRESS, 0 } };
|
||||
{
|
||||
RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, RTS_CMD_ASSOCIATION_GROUP_ID, RTS_CMD_CLIENT_ADDRESS, 0
|
||||
}
|
||||
};
|
||||
RtsPduSignature RTS_PDU_CONN_B3_SIGNATURE = { RTS_FLAG_NONE, 2,
|
||||
{ RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_VERSION, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_VERSION, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
RtsPduSignature RTS_PDU_CONN_C1_SIGNATURE = { RTS_FLAG_NONE, 3,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_CONN_C2_SIGNATURE = { RTS_FLAG_NONE, 3,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
RtsPduSignature RTS_PDU_IN_R1_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_IN_R1_A2_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0 } };
|
||||
{
|
||||
RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0
|
||||
}
|
||||
};
|
||||
RtsPduSignature RTS_PDU_IN_R1_A3_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0 } };
|
||||
{
|
||||
RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0
|
||||
}
|
||||
};
|
||||
RtsPduSignature RTS_PDU_IN_R1_A4_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0 } };
|
||||
{
|
||||
RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0
|
||||
}
|
||||
};
|
||||
RtsPduSignature RTS_PDU_IN_R1_A5_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_IN_R1_A6_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
RtsPduSignature RTS_PDU_IN_R1_B1_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_EMPTY, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_EMPTY, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_IN_R1_B2_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
RtsPduSignature RTS_PDU_IN_R2_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_IN_R2_A2_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_IN_R2_A3_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_IN_R2_A4_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_IN_R2_A5_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A2_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A3_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 5,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0 } };
|
||||
{
|
||||
RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0
|
||||
}
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A4_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL | RTS_FLAG_OUT_CHANNEL, 7,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0 } };
|
||||
{
|
||||
RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0
|
||||
}
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A5_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 3,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A6_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 3,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A7_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A8_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A9_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A10_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A11_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A2_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A3_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 5,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0 } };
|
||||
{
|
||||
RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0
|
||||
}
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A4_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A5_SIGNATURE = { RTS_FLAG_NONE, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A6_SIGNATURE = { RTS_FLAG_NONE, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A7_SIGNATURE = { RTS_FLAG_NONE, 3,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, RTS_CMD_VERSION, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, RTS_CMD_VERSION, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A8_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
RtsPduSignature RTS_PDU_OUT_R2_B1_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R2_B2_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_NEGATIVE_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_NEGATIVE_ANCE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_OUT_R2_B3_SIGNATURE = { RTS_FLAG_EOF, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
RtsPduSignature RTS_PDU_OUT_R2_C1_SIGNATURE = { RTS_FLAG_PING, 1,
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
RtsPduSignature RTS_PDU_KEEP_ALIVE_SIGNATURE = { RTS_FLAG_OTHER_CMD, 1,
|
||||
{ RTS_CMD_CLIENT_KEEPALIVE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_CLIENT_KEEPALIVE, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_PING_TRAFFIC_SENT_NOTIFY_SIGNATURE = { RTS_FLAG_OTHER_CMD, 1,
|
||||
{ RTS_CMD_PING_TRAFFIC_SENT_NOTIFY, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_PING_TRAFFIC_SENT_NOTIFY, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_ECHO_SIGNATURE = { RTS_FLAG_ECHO, 0,
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_PING_SIGNATURE = { RTS_FLAG_PING, 0,
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_FLOW_CONTROL_ACK_SIGNATURE = { RTS_FLAG_OTHER_CMD, 1,
|
||||
{ RTS_CMD_FLOW_CONTROL_ACK, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_FLOW_CONTROL_ACK, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
RtsPduSignature RTS_PDU_FLOW_CONTROL_ACK_WITH_DESTINATION_SIGNATURE = { RTS_FLAG_OTHER_CMD, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_FLOW_CONTROL_ACK, 0, 0, 0, 0, 0, 0 } };
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_FLOW_CONTROL_ACK, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
RTS_PDU_SIGNATURE_ENTRY RTS_PDU_SIGNATURE_TABLE[] =
|
||||
static const RTS_PDU_SIGNATURE_ENTRY RTS_PDU_SIGNATURE_TABLE[] =
|
||||
{
|
||||
{ RTS_PDU_CONN_A1, FALSE, &RTS_PDU_CONN_A1_SIGNATURE, "CONN/A1" },
|
||||
{ RTS_PDU_CONN_A2, FALSE, &RTS_PDU_CONN_A2_SIGNATURE, "CONN/A2" },
|
||||
@@ -238,12 +306,12 @@ BOOL rts_match_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, rpcconn_rt
|
||||
return FALSE;
|
||||
|
||||
status = rts_command_length(rpc, CommandType, &buffer[offset], length);
|
||||
|
||||
if (status < 0)
|
||||
return FALSE;
|
||||
|
||||
CommandLength = (UINT32) status;
|
||||
offset += CommandLength;
|
||||
|
||||
length = rts->frag_length - offset;
|
||||
}
|
||||
|
||||
@@ -259,10 +327,8 @@ int rts_extract_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, rpcconn_r
|
||||
UINT32 offset;
|
||||
UINT32 CommandType;
|
||||
UINT32 CommandLength;
|
||||
|
||||
signature->Flags = rts->Flags;
|
||||
signature->NumberOfCommands = rts->NumberOfCommands;
|
||||
|
||||
buffer = (BYTE*) rts;
|
||||
offset = RTS_PDU_HEADER_LENGTH;
|
||||
length = rts->frag_length - offset;
|
||||
@@ -271,23 +337,22 @@ int rts_extract_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, rpcconn_r
|
||||
{
|
||||
CommandType = *((UINT32*) &buffer[offset]); /* CommandType (4 bytes) */
|
||||
offset += 4;
|
||||
|
||||
signature->CommandTypes[i] = CommandType;
|
||||
|
||||
status = rts_command_length(rpc, CommandType, &buffer[offset], length);
|
||||
|
||||
if (status < 0)
|
||||
return FALSE;
|
||||
|
||||
CommandLength = (UINT32) status;
|
||||
offset += CommandLength;
|
||||
|
||||
length = rts->frag_length - offset;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 rts_identify_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, RTS_PDU_SIGNATURE_ENTRY** entry)
|
||||
UINT32 rts_identify_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature,
|
||||
RTS_PDU_SIGNATURE_ENTRY** entry)
|
||||
{
|
||||
int i, j;
|
||||
RtsPduSignature* pSignature;
|
||||
@@ -325,7 +390,7 @@ int rts_print_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature)
|
||||
UINT32 SignatureId;
|
||||
RTS_PDU_SIGNATURE_ENTRY* entry;
|
||||
WLog_INFO(TAG, "RTS PDU Signature: Flags: 0x%04"PRIX16" NumberOfCommands: %"PRIu16"",
|
||||
signature->Flags, signature->NumberOfCommands);
|
||||
signature->Flags, signature->NumberOfCommands);
|
||||
SignatureId = rts_identify_pdu_signature(rpc, signature, &entry);
|
||||
|
||||
if (SignatureId)
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#define TAG FREERDP_TAG("core.gateway.tsg")
|
||||
|
||||
static BIO_METHOD* BIO_s_tsg(void);
|
||||
/**
|
||||
* RPC Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa378623/
|
||||
* Remote Procedure Call: http://msdn.microsoft.com/en-us/library/windows/desktop/aa378651/
|
||||
@@ -75,7 +76,8 @@
|
||||
* TsProxySendToServerRequest(ChannelContext)
|
||||
*/
|
||||
|
||||
DWORD TsProxySendToServer(handle_t IDL_handle, byte pRpcMessage[], UINT32 count, UINT32* lengths)
|
||||
static DWORD TsProxySendToServer(handle_t IDL_handle, byte pRpcMessage[], UINT32 count,
|
||||
UINT32* lengths)
|
||||
{
|
||||
wStream* s;
|
||||
int status;
|
||||
@@ -353,9 +355,9 @@ static BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu,
|
||||
packet->tsgPacket.packetCapsResponse = packetCapsResponse;
|
||||
/* PacketQuarResponsePtr (4 bytes) */
|
||||
packetCapsResponse->pktQuarEncResponse.flags = *((UINT32*) &buffer[offset +
|
||||
12]); /* Flags (4 bytes) */
|
||||
12]); /* Flags (4 bytes) */
|
||||
packetCapsResponse->pktQuarEncResponse.certChainLen = *((UINT32*) &buffer[offset +
|
||||
16]); /* CertChainLength (4 bytes) */
|
||||
16]); /* CertChainLength (4 bytes) */
|
||||
/* CertChainDataPtr (4 bytes) */
|
||||
CopyMemory(&packetCapsResponse->pktQuarEncResponse.nonce, &buffer[offset + 24],
|
||||
16); /* Nonce (16 bytes) */
|
||||
@@ -425,7 +427,7 @@ static BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu,
|
||||
versionCaps->majorVersion = *((UINT16*) &buffer[offset + 8]); /* MajorVersion (2 bytes) */
|
||||
versionCaps->minorVersion = *((UINT16*) &buffer[offset + 10]); /* MinorVersion (2 bytes) */
|
||||
versionCaps->quarantineCapabilities = *((UINT16*) &buffer[offset +
|
||||
12]); /* QuarantineCapabilities (2 bytes) */
|
||||
12]); /* QuarantineCapabilities (2 bytes) */
|
||||
offset += 14;
|
||||
/* 4-byte alignment */
|
||||
rpc_offset_align(&offset, 4);
|
||||
@@ -533,7 +535,7 @@ static BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu,
|
||||
/* PacketQuarResponsePtr (4 bytes) */
|
||||
packetQuarEncResponse->flags = *((UINT32*) &buffer[offset + 12]); /* Flags (4 bytes) */
|
||||
packetQuarEncResponse->certChainLen = *((UINT32*) &buffer[offset +
|
||||
16]); /* CertChainLength (4 bytes) */
|
||||
16]); /* CertChainLength (4 bytes) */
|
||||
/* CertChainDataPtr (4 bytes) */
|
||||
CopyMemory(&packetQuarEncResponse->nonce, &buffer[offset + 24], 16); /* Nonce (16 bytes) */
|
||||
offset += 40;
|
||||
@@ -590,7 +592,7 @@ static BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu,
|
||||
versionCaps->majorVersion = *((UINT16*) &buffer[offset + 8]); /* MajorVersion (2 bytes) */
|
||||
versionCaps->majorVersion = *((UINT16*) &buffer[offset + 10]); /* MinorVersion (2 bytes) */
|
||||
versionCaps->quarantineCapabilities = *((UINT16*) &buffer[offset +
|
||||
12]); /* QuarantineCapabilities (2 bytes) */
|
||||
12]); /* QuarantineCapabilities (2 bytes) */
|
||||
offset += 14;
|
||||
/* 4-byte alignment */
|
||||
rpc_offset_align(&offset, 4);
|
||||
@@ -753,23 +755,23 @@ static BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
|
||||
/* Reserved (4 bytes) */
|
||||
Pointer = *((UINT32*) &buffer[offset + 20]); /* ResponseDataPtr (4 bytes) */
|
||||
packetResponse->responseDataLen = *((UINT32*) &buffer[offset +
|
||||
24]); /* ResponseDataLength (4 bytes) */
|
||||
24]); /* ResponseDataLength (4 bytes) */
|
||||
packetResponse->redirectionFlags.enableAllRedirections = *((UINT32*) &buffer[offset +
|
||||
28]); /* EnableAllRedirections (4 bytes) */
|
||||
28]); /* EnableAllRedirections (4 bytes) */
|
||||
packetResponse->redirectionFlags.disableAllRedirections = *((UINT32*) &buffer[offset +
|
||||
32]); /* DisableAllRedirections (4 bytes) */
|
||||
32]); /* DisableAllRedirections (4 bytes) */
|
||||
packetResponse->redirectionFlags.driveRedirectionDisabled = *((UINT32*) &buffer[offset +
|
||||
36]); /* DriveRedirectionDisabled (4 bytes) */
|
||||
36]); /* DriveRedirectionDisabled (4 bytes) */
|
||||
packetResponse->redirectionFlags.printerRedirectionDisabled = *((UINT32*) &buffer[offset +
|
||||
40]); /* PrinterRedirectionDisabled (4 bytes) */
|
||||
40]); /* PrinterRedirectionDisabled (4 bytes) */
|
||||
packetResponse->redirectionFlags.portRedirectionDisabled = *((UINT32*) &buffer[offset +
|
||||
44]); /* PortRedirectionDisabled (4 bytes) */
|
||||
44]); /* PortRedirectionDisabled (4 bytes) */
|
||||
packetResponse->redirectionFlags.reserved = *((UINT32*) &buffer[offset +
|
||||
48]); /* Reserved (4 bytes) */
|
||||
48]); /* Reserved (4 bytes) */
|
||||
packetResponse->redirectionFlags.clipboardRedirectionDisabled = *((UINT32*) &buffer[offset +
|
||||
52]); /* ClipboardRedirectionDisabled (4 bytes) */
|
||||
52]); /* ClipboardRedirectionDisabled (4 bytes) */
|
||||
packetResponse->redirectionFlags.pnpRedirectionDisabled = *((UINT32*) &buffer[offset +
|
||||
56]); /* PnpRedirectionDisabled (4 bytes) */
|
||||
56]); /* PnpRedirectionDisabled (4 bytes) */
|
||||
offset += 60;
|
||||
SizeValue = *((UINT32*) &buffer[offset]); /* (4 bytes) */
|
||||
offset += 4;
|
||||
@@ -916,9 +918,9 @@ static BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
|
||||
packetMsgResponse->messagePacket.consentMessage = packetStringMessage;
|
||||
Pointer = *((UINT32*) &buffer[offset + 28]); /* ConsentMessagePtr (4 bytes) */
|
||||
packetStringMessage->isDisplayMandatory = *((INT32*) &buffer[offset +
|
||||
32]); /* IsDisplayMandatory (4 bytes) */
|
||||
32]); /* IsDisplayMandatory (4 bytes) */
|
||||
packetStringMessage->isConsentMandatory = *((INT32*) &buffer[offset +
|
||||
36]); /* IsConsentMandatory (4 bytes) */
|
||||
36]); /* IsConsentMandatory (4 bytes) */
|
||||
packetStringMessage->msgBytes = *((UINT32*) &buffer[offset + 40]); /* MsgBytes (4 bytes) */
|
||||
Pointer = *((UINT32*) &buffer[offset + 44]); /* MsgPtr (4 bytes) */
|
||||
MaxCount = *((UINT32*) &buffer[offset + 48]); /* MaxCount (4 bytes) */
|
||||
@@ -942,9 +944,9 @@ static BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
|
||||
packetMsgResponse->messagePacket.serviceMessage = packetStringMessage;
|
||||
Pointer = *((UINT32*) &buffer[offset + 28]); /* ServiceMessagePtr (4 bytes) */
|
||||
packetStringMessage->isDisplayMandatory = *((INT32*) &buffer[offset +
|
||||
32]); /* IsDisplayMandatory (4 bytes) */
|
||||
32]); /* IsDisplayMandatory (4 bytes) */
|
||||
packetStringMessage->isConsentMandatory = *((INT32*) &buffer[offset +
|
||||
36]); /* IsConsentMandatory (4 bytes) */
|
||||
36]); /* IsConsentMandatory (4 bytes) */
|
||||
packetStringMessage->msgBytes = *((UINT32*) &buffer[offset + 40]); /* MsgBytes (4 bytes) */
|
||||
Pointer = *((UINT32*) &buffer[offset + 44]); /* MsgPtr (4 bytes) */
|
||||
MaxCount = *((UINT32*) &buffer[offset + 48]); /* MaxCount (4 bytes) */
|
||||
@@ -969,7 +971,7 @@ static BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
|
||||
Pointer = *((UINT32*) &buffer[offset + 28]); /* ReauthMessagePtr (4 bytes) */
|
||||
/* alignment pad (4 bytes) */
|
||||
packetReauthMessage->tunnelContext = *((UINT64*) &buffer[offset +
|
||||
36]); /* TunnelContext (8 bytes) */
|
||||
36]); /* TunnelContext (8 bytes) */
|
||||
/* ReturnValue (4 bytes) */
|
||||
tsg->ReauthTunnelContext = packetReauthMessage->tunnelContext;
|
||||
break;
|
||||
@@ -1215,7 +1217,7 @@ static BOOL TsProxySetupReceivePipeWriteRequest(rdpTsg* tsg, CONTEXT_HANDLE* cha
|
||||
}
|
||||
|
||||
|
||||
int tsg_transition_to_state(rdpTsg* tsg, TSG_STATE state)
|
||||
static int tsg_transition_to_state(rdpTsg* tsg, TSG_STATE state)
|
||||
{
|
||||
const char* str = "TSG_STATE_UNKNOWN";
|
||||
|
||||
@@ -1301,7 +1303,7 @@ int tsg_proxy_begin(rdpTsg* tsg)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int tsg_proxy_reauth(rdpTsg* tsg)
|
||||
static int tsg_proxy_reauth(rdpTsg* tsg)
|
||||
{
|
||||
TSG_PACKET tsgPacket;
|
||||
PTSG_PACKET_REAUTH packetReauth;
|
||||
|
||||
@@ -310,12 +310,6 @@ struct rdp_tsg
|
||||
};
|
||||
|
||||
FREERDP_LOCAL int tsg_proxy_begin(rdpTsg* tsg);
|
||||
FREERDP_LOCAL int tsg_proxy_reauth(rdpTsg* tsg);
|
||||
|
||||
FREERDP_LOCAL DWORD TsProxySendToServer(handle_t IDL_handle, BYTE pRpcMessage[],
|
||||
UINT32 count, UINT32* lengths);
|
||||
|
||||
FREERDP_LOCAL int tsg_transition_to_state(rdpTsg* tsg, TSG_STATE state);
|
||||
|
||||
FREERDP_LOCAL BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port,
|
||||
int timeout);
|
||||
@@ -330,6 +324,4 @@ FREERDP_LOCAL DWORD tsg_get_event_handles(rdpTsg* tsg, HANDLE* events,
|
||||
FREERDP_LOCAL rdpTsg* tsg_new(rdpTransport* transport);
|
||||
FREERDP_LOCAL void tsg_free(rdpTsg* tsg);
|
||||
|
||||
FREERDP_LOCAL BIO_METHOD* BIO_s_tsg(void);
|
||||
|
||||
#endif /* FREERDP_LIB_CORE_GATEWAY_TSG_H */
|
||||
|
||||
@@ -78,8 +78,8 @@ struct _BIO_RDP_TLS
|
||||
};
|
||||
typedef struct _BIO_RDP_TLS BIO_RDP_TLS;
|
||||
|
||||
long bio_rdp_tls_callback(BIO* bio, int mode, const char* argp, int argi,
|
||||
long argl, long ret)
|
||||
static long bio_rdp_tls_callback(BIO* bio, int mode, const char* argp, int argi,
|
||||
long argl, long ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -508,7 +508,7 @@ static long bio_rdp_tls_callback_ctrl(BIO* bio, int cmd, bio_info_cb* fp)
|
||||
|
||||
#define BIO_TYPE_RDP_TLS 68
|
||||
|
||||
BIO_METHOD* BIO_s_rdp_tls(void)
|
||||
static BIO_METHOD* BIO_s_rdp_tls(void)
|
||||
{
|
||||
static BIO_METHOD* bio_methods = NULL;
|
||||
|
||||
@@ -530,7 +530,7 @@ BIO_METHOD* BIO_s_rdp_tls(void)
|
||||
return bio_methods;
|
||||
}
|
||||
|
||||
BIO* BIO_new_rdp_tls(SSL_CTX* ctx, int client)
|
||||
static BIO* BIO_new_rdp_tls(SSL_CTX* ctx, int client)
|
||||
{
|
||||
BIO* bio;
|
||||
SSL* ssl;
|
||||
@@ -596,7 +596,7 @@ static void tls_free_certificate(CryptoCert cert)
|
||||
|
||||
#define TLS_SERVER_END_POINT "tls-server-end-point:"
|
||||
|
||||
SecPkgContext_Bindings* tls_get_channel_bindings(X509* cert)
|
||||
static SecPkgContext_Bindings* tls_get_channel_bindings(X509* cert)
|
||||
{
|
||||
int PrefixLength;
|
||||
BYTE CertificateHash[32];
|
||||
@@ -681,7 +681,7 @@ static BOOL tls_prepare(rdpTls* tls, BIO* underlying, SSL_METHOD* method,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int tls_do_handshake(rdpTls* tls, BOOL clientMode)
|
||||
static int tls_do_handshake(rdpTls* tls, BOOL clientMode)
|
||||
{
|
||||
CryptoCert cert;
|
||||
int verify_status;
|
||||
@@ -1052,7 +1052,7 @@ BOOL tls_send_alert(rdpTls* tls)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BIO* findBufferedBio(BIO* front)
|
||||
static BIO* findBufferedBio(BIO* front)
|
||||
{
|
||||
BIO* ret = front;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user