HttpContext* http_context_new()
{
- return (HttpContext*)calloc(1, sizeof(HttpContext));
+ return (HttpContext*) calloc(1, sizeof(HttpContext));
}
-void http_context_set_method(HttpContext* http_context, char* method)
+BOOL http_context_set_method(HttpContext* context, const char* Method)
{
- if (http_context->Method)
- free(http_context->Method);
+ free(context->Method);
+ context->Method = _strdup(Method);
- http_context->Method = _strdup(method);
- // TODO: check result
+ if (!context->Method)
+ return FALSE;
+
+ return TRUE;
}
-void http_context_set_uri(HttpContext* http_context, char* uri)
+BOOL http_context_set_uri(HttpContext* context, const char* URI)
{
- if (http_context->URI)
- free(http_context->URI);
+ free(context->URI);
+ context->URI = _strdup(URI);
- http_context->URI = _strdup(uri);
- // TODO: check result
+ if (!context->URI)
+ return FALSE;
+
+ return TRUE;
}
-void http_context_set_user_agent(HttpContext* http_context, char* user_agent)
+BOOL http_context_set_user_agent(HttpContext* context, const char* UserAgent)
{
- if (http_context->UserAgent)
- free(http_context->UserAgent);
+ free(context->UserAgent);
+ context->UserAgent = _strdup(UserAgent);
- http_context->UserAgent = _strdup(user_agent);
- // TODO: check result
+ if (!context->UserAgent)
+ return FALSE;
+
+ return TRUE;
}
-void http_context_set_host(HttpContext* http_context, char* host)
+BOOL http_context_set_host(HttpContext* context, const char* Host)
{
- if (http_context->Host)
- free(http_context->Host);
+ free(context->Host);
+ context->Host = _strdup(Host);
+
+ if (!context->Host)
+ return FALSE;
- http_context->Host = _strdup(host);
- // TODO: check result
+ return TRUE;
}
-void http_context_set_accept(HttpContext* http_context, char* accept)
+BOOL http_context_set_accept(HttpContext* context, const char* Accept)
{
- if (http_context->Accept)
- free(http_context->Accept);
+ free(context->Accept);
+ context->Accept = _strdup(Accept);
+
+ if (!context->Accept)
+ return FALSE;
- http_context->Accept = _strdup(accept);
- // TODO: check result
+ return TRUE;
}
-void http_context_set_cache_control(HttpContext* http_context, char* cache_control)
+BOOL http_context_set_cache_control(HttpContext* context, const char* CacheControl)
{
- if (http_context->CacheControl)
- free(http_context->CacheControl);
+ free(context->CacheControl);
+ context->CacheControl = _strdup(CacheControl);
+
+ if (!context->CacheControl)
+ return FALSE;
- http_context->CacheControl = _strdup(cache_control);
- // TODO: check result
+ return TRUE;
}
-void http_context_set_connection(HttpContext* http_context, char* connection)
+BOOL http_context_set_connection(HttpContext* context, const char* Connection)
{
- if (http_context->Connection)
- free(http_context->Connection);
+ free(context->Connection);
+ context->Connection = _strdup(Connection);
+
+ if (!context->Connection)
+ return FALSE;
- http_context->Connection = _strdup(connection);
- // TODO: check result
+ return TRUE;
}
-void http_context_set_pragma(HttpContext* http_context, char* pragma)
+BOOL http_context_set_pragma(HttpContext* context, const char* Pragma)
{
- if (http_context->Pragma)
- free(http_context->Pragma);
+ free(context->Pragma);
+ context->Pragma = _strdup(Pragma);
+
+ if (!context->Pragma)
+ return FALSE;
- http_context->Pragma = _strdup(pragma);
- // TODO: check result
+ return TRUE;
}
-void http_context_free(HttpContext* http_context)
+void http_context_free(HttpContext* context)
{
- if (http_context != NULL)
+ if (context)
{
- free(http_context->UserAgent);
- free(http_context->Host);
- free(http_context->URI);
- free(http_context->Accept);
- free(http_context->Method);
- free(http_context->CacheControl);
- free(http_context->Connection);
- free(http_context->Pragma);
- free(http_context);
+ free(context->UserAgent);
+ free(context->Host);
+ free(context->URI);
+ free(context->Accept);
+ free(context->Method);
+ free(context->CacheControl);
+ free(context->Connection);
+ free(context->Pragma);
+ free(context);
}
}
-void http_request_set_method(HttpRequest* http_request, char* method)
+BOOL http_request_set_method(HttpRequest* request, const char* Method)
{
- if (http_request->Method)
- free(http_request->Method);
+ free(request->Method);
+ request->Method = _strdup(Method);
+
+ if (!request->Method)
+ return FALSE;
- http_request->Method = _strdup(method);
- // TODO: check result
+ return TRUE;
}
-void http_request_set_uri(HttpRequest* http_request, char* uri)
+BOOL http_request_set_uri(HttpRequest* request, const char* URI)
{
- if (http_request->URI)
- free(http_request->URI);
+ free(request->URI);
+ request->URI = _strdup(URI);
- http_request->URI = _strdup(uri);
- // TODO: check result
+ if (!request->URI)
+ return FALSE;
+
+ return TRUE;
}
-void http_request_set_auth_scheme(HttpRequest* http_request, char* auth_scheme)
+BOOL http_request_set_auth_scheme(HttpRequest* request, const char* AuthScheme)
{
- if (http_request->AuthScheme)
- free(http_request->AuthScheme);
+ free(request->AuthScheme);
+ request->AuthScheme = _strdup(AuthScheme);
- http_request->AuthScheme = _strdup(auth_scheme);
- // TODO: check result
+ if (!request->AuthScheme)
+ return FALSE;
+
+ return TRUE;
}
-void http_request_set_auth_param(HttpRequest* http_request, char* auth_param)
+BOOL http_request_set_auth_param(HttpRequest* request, const char* AuthParam)
{
- if (http_request->AuthParam)
- free(http_request->AuthParam);
+ free(request->AuthParam);
+ request->AuthParam = _strdup(AuthParam);
- http_request->AuthParam = _strdup(auth_param);
- // TODO: check result
+ if (!request->AuthParam)
+ return FALSE;
+
+ return TRUE;
}
char* http_encode_body_line(char* param, char* value)
{
char* line;
int length;
+
length = strlen(param) + strlen(value) + 2;
line = (char*) malloc(length + 1);
char* line;
int length;
char str[32];
+
_itoa_s(ContentLength, str, sizeof(str), 10);
length = strlen("Content-Length") + strlen(str) + 2;
- line = (char*)malloc(length + 1);
+ line = (char*) malloc(length + 1);
if (!line)
return NULL;
{
char* line;
int length;
+
length = strlen("HTTP/1.1") + strlen(Method) + strlen(URI) + 2;
line = (char*)malloc(length + 1);
{
char* line;
int length;
+
length = strlen("Authorization") + strlen(AuthScheme) + strlen(AuthParam) + 3;
line = (char*) malloc(length + 1);
return line;
}
-wStream* http_request_write(HttpContext* http_context, HttpRequest* http_request)
+wStream* http_request_write(HttpContext* context, HttpRequest* request)
{
+ wStream* s;
int i, count;
char** lines;
- wStream* s;
int length = 0;
count = 0;
if (!lines)
return NULL;
- lines[count++] = http_encode_header_line(http_request->Method, http_request->URI);
- lines[count++] = http_encode_body_line("Cache-Control", http_context->CacheControl);
- lines[count++] = http_encode_body_line("Connection", http_context->Connection);
- lines[count++] = http_encode_body_line("Pragma", http_context->Pragma);
- lines[count++] = http_encode_body_line("Accept", http_context->Accept);
- lines[count++] = http_encode_body_line("User-Agent", http_context->UserAgent);
- lines[count++] = http_encode_content_length_line(http_request->ContentLength);
- lines[count++] = http_encode_body_line("Host", http_context->Host);
+ lines[count++] = http_encode_header_line(request->Method, request->URI);
+ lines[count++] = http_encode_body_line("Cache-Control", context->CacheControl);
+ lines[count++] = http_encode_body_line("Connection", context->Connection);
+ lines[count++] = http_encode_body_line("Pragma", context->Pragma);
+ lines[count++] = http_encode_body_line("Accept", context->Accept);
+ lines[count++] = http_encode_body_line("User-Agent", context->UserAgent);
+ lines[count++] = http_encode_content_length_line(request->ContentLength);
+ lines[count++] = http_encode_body_line("Host", context->Host);
/* check that everything went well */
for (i = 0; i < count; i++)
goto out_free;
}
- if (http_request->Authorization)
+ if (request->Authorization)
{
- lines[count] = http_encode_body_line("Authorization", http_request->Authorization);
+ lines[count] = http_encode_body_line("Authorization", request->Authorization);
if (!lines[count])
goto out_free;
count++;
}
- else if (http_request->AuthScheme && http_request->AuthParam)
+ else if (request->AuthScheme && request->AuthParam)
{
- lines[count] = http_encode_authorization_line(http_request->AuthScheme, http_request->AuthParam);
+ lines[count] = http_encode_authorization_line(request->AuthScheme, request->AuthParam);
if (!lines[count])
goto out_free;
return (HttpRequest*) calloc(1, sizeof(HttpRequest));
}
-void http_request_free(HttpRequest* http_request)
+void http_request_free(HttpRequest* request)
{
- if (!http_request)
+ if (!request)
return;
- if (http_request->AuthParam)
- free(http_request->AuthParam);
+ if (request->AuthParam)
+ free(request->AuthParam);
- if (http_request->AuthScheme)
- free(http_request->AuthScheme);
+ if (request->AuthScheme)
+ free(request->AuthScheme);
- if (http_request->Authorization)
- free(http_request->Authorization);
+ if (request->Authorization)
+ free(request->Authorization);
- free(http_request->Content);
- free(http_request->Method);
- free(http_request->URI);
- free(http_request);
+ free(request->Content);
+ free(request->Method);
+ free(request->URI);
+ free(request);
}
-BOOL http_response_parse_header_status_line(HttpResponse* http_response, char* status_line)
+BOOL http_response_parse_header_status_line(HttpResponse* response, char* status_line)
{
char* separator = NULL;
char* status_code;
reason_phrase = separator + 1;
*separator = '\0';
- http_response->StatusCode = atoi(status_code);
- http_response->ReasonPhrase = _strdup(reason_phrase);
+ response->StatusCode = atoi(status_code);
+ response->ReasonPhrase = _strdup(reason_phrase);
- if (!http_response->ReasonPhrase)
+ if (!response->ReasonPhrase)
return FALSE;
*separator = ' ';
return TRUE;
}
-BOOL http_response_parse_header_field(HttpResponse* http_response, char* name, char* value)
+BOOL http_response_parse_header_field(HttpResponse* response, char* name, char* value)
{
BOOL status = TRUE;
if (_stricmp(name, "Content-Length") == 0)
{
- http_response->ContentLength = atoi(value);
+ response->ContentLength = atoi(value);
}
else if (_stricmp(name, "WWW-Authenticate") == 0)
{
authValue = NULL;
}
- status = ListDictionary_Add(http_response->Authenticates, authScheme, authValue);
+ status = ListDictionary_Add(response->Authenticates, authScheme, authValue);
}
return status;
}
-BOOL http_response_parse_header(HttpResponse* http_response)
+BOOL http_response_parse_header(HttpResponse* response)
{
int count;
char* line;
char end_of_header_char;
char c;
- if (!http_response)
+ if (!response)
return FALSE;
- if (!http_response->lines)
+ if (!response->lines)
return FALSE;
- if (!http_response_parse_header_status_line(http_response, http_response->lines[0]))
+ if (!http_response_parse_header_status_line(response, response->lines[0]))
return FALSE;
- for (count = 1; count < http_response->count; count++)
+ for (count = 1; count < response->count; count++)
{
- line = http_response->lines[count];
+ line = response->lines[count];
/**
* name end_of_header
* | |
break;
}
- if (!http_response_parse_header_field(http_response, name, value))
+ if (!http_response_parse_header_field(response, name, value))
return FALSE;
*end_of_header = end_of_header_char;
return TRUE;
}
-void http_response_print(HttpResponse* http_response)
+void http_response_print(HttpResponse* response)
{
int i;
- for (i = 0; i < http_response->count; i++)
+ for (i = 0; i < response->count; i++)
{
- WLog_ERR(TAG, "%s", http_response->lines[i]);
+ WLog_ERR(TAG, "%s", response->lines[i]);
}
}
HttpResponse* http_response_recv(rdpTls* tls)
{
- BYTE* p;
int nbytes;
int length;
int status;
BYTE* buffer;
char* content;
char* header_end;
- HttpResponse* http_response;
+ HttpResponse* response;
nbytes = 0;
length = 10000;
if (!buffer)
return NULL;
- http_response = http_response_new();
+ response = http_response_new();
- if (!http_response)
+ if (!response)
goto out_free;
- p = buffer;
- http_response->ContentLength = 0;
+ response->ContentLength = 0;
while (TRUE)
{
while (nbytes < 5)
{
- status = BIO_read(tls->bio, p, length - nbytes);
+ status = BIO_read(tls->bio, &buffer[nbytes], length - nbytes);
if (status <= 0)
{
VALGRIND_MAKE_MEM_DEFINED(p, status);
#endif
nbytes += status;
- p = (BYTE*) &buffer[nbytes];
}
header_end = strstr((char*) buffer, "\r\n\r\n");
count++;
}
- http_response->count = count;
+ response->count = count;
if (count)
{
- http_response->lines = (char**) calloc(http_response->count, sizeof(char*));
+ response->lines = (char**) calloc(response->count, sizeof(char*));
- if (!http_response->lines)
+ if (!response->lines)
goto out_error;
}
count = 0;
line = strtok((char*) buffer, "\r\n");
- while (line && http_response->lines)
+ while (line && response->lines)
{
- http_response->lines[count] = _strdup(line);
+ response->lines[count] = _strdup(line);
- if (!http_response->lines[count])
+ if (!response->lines[count])
goto out_error;
line = strtok(NULL, "\r\n");
count++;
}
- if (!http_response_parse_header(http_response))
+ if (!http_response_parse_header(response))
goto out_error;
- http_response->bodyLen = nbytes - (content - (char*)buffer);
+ response->BodyLength = nbytes - (content - (char*) buffer);
- if (http_response->bodyLen > 0)
+ if (response->BodyLength > 0)
{
- http_response->BodyContent = (BYTE*) malloc(http_response->bodyLen);
+ response->BodyContent = (BYTE*) malloc(response->BodyLength);
- if (!http_response->BodyContent)
+ if (!response->BodyContent)
goto out_error;
- CopyMemory(http_response->BodyContent, content, http_response->bodyLen);
+ CopyMemory(response->BodyContent, content, response->BodyLength);
}
break;
{
length *= 2;
buffer = realloc(buffer, length);
- p = (BYTE*) &buffer[nbytes];
}
}
free(buffer);
- return http_response;
+ return response;
out_error:
- http_response_free(http_response);
+ http_response_free(response);
out_free:
free(buffer);
return NULL;
HttpResponse* http_response_new()
{
- HttpResponse* ret = (HttpResponse*) calloc(1, sizeof(HttpResponse));
+ HttpResponse* response = (HttpResponse*) calloc(1, sizeof(HttpResponse));
- if (!ret)
+ if (!response)
return NULL;
- ret->Authenticates = ListDictionary_New(FALSE);
+ response->Authenticates = ListDictionary_New(FALSE);
- ListDictionary_KeyObject(ret->Authenticates)->fnObjectEquals = strings_equals_nocase;
- ListDictionary_KeyObject(ret->Authenticates)->fnObjectFree = string_free;
+ ListDictionary_KeyObject(response->Authenticates)->fnObjectEquals = strings_equals_nocase;
+ ListDictionary_KeyObject(response->Authenticates)->fnObjectFree = string_free;
- ListDictionary_ValueObject(ret->Authenticates)->fnObjectEquals = strings_equals_nocase;
- ListDictionary_ValueObject(ret->Authenticates)->fnObjectFree = string_free;
+ ListDictionary_ValueObject(response->Authenticates)->fnObjectEquals = strings_equals_nocase;
+ ListDictionary_ValueObject(response->Authenticates)->fnObjectFree = string_free;
- return ret;
+ return response;
}
-void http_response_free(HttpResponse* http_response)
+void http_response_free(HttpResponse* response)
{
int i;
- if (!http_response)
+ if (!response)
return;
- for (i = 0; i < http_response->count; i++)
+ for (i = 0; i < response->count; i++)
{
- if (http_response->lines && http_response->lines[i])
- free(http_response->lines[i]);
+ if (response->lines && response->lines[i])
+ free(response->lines[i]);
}
- free(http_response->lines);
- free(http_response->ReasonPhrase);
+ free(response->lines);
+ free(response->ReasonPhrase);
- ListDictionary_Free(http_response->Authenticates);
+ ListDictionary_Free(response->Authenticates);
- if (http_response->ContentLength > 0)
- free(http_response->BodyContent);
+ if (response->ContentLength > 0)
+ free(response->BodyContent);
- free(http_response);
+ free(response);
}
char* Pragma;
};
-void http_context_set_method(HttpContext* http_context, char* method);
-void http_context_set_uri(HttpContext* http_context, char* uri);
-void http_context_set_user_agent(HttpContext* http_context, char* user_agent);
-void http_context_set_host(HttpContext* http_context, char* host);
-void http_context_set_accept(HttpContext* http_context, char* accept);
-void http_context_set_cache_control(HttpContext* http_context, char* cache_control);
-void http_context_set_connection(HttpContext* http_context, char* connection);
-void http_context_set_pragma(HttpContext* http_context, char* pragma);
+BOOL http_context_set_method(HttpContext* context, const char* Method);
+BOOL http_context_set_uri(HttpContext* context, const char* URI);
+BOOL http_context_set_user_agent(HttpContext* context, const char* UserAgent);
+BOOL http_context_set_host(HttpContext* context, const char* Host);
+BOOL http_context_set_accept(HttpContext* context, const char* Accept);
+BOOL http_context_set_cache_control(HttpContext* context, const char* CacheControl);
+BOOL http_context_set_connection(HttpContext* context, const char* Connection);
+BOOL http_context_set_pragma(HttpContext* context, const char* Pragma);
HttpContext* http_context_new(void);
-void http_context_free(HttpContext* http_context);
+void http_context_free(HttpContext* context);
struct _http_request
{
char* Content;
};
-void http_request_set_method(HttpRequest* http_request, char* method);
-void http_request_set_uri(HttpRequest* http_request, char* uri);
-void http_request_set_auth_scheme(HttpRequest* http_request, char* auth_scheme);
-void http_request_set_auth_param(HttpRequest* http_request, char* auth_param);
+BOOL http_request_set_method(HttpRequest* request, const char* Method);
+BOOL http_request_set_uri(HttpRequest* request, const char* URI);
+BOOL http_request_set_auth_scheme(HttpRequest* request, const char* AuthScheme);
+BOOL http_request_set_auth_param(HttpRequest* request, const char* AuthParam);
-wStream* http_request_write(HttpContext* http_context, HttpRequest* http_request);
+wStream* http_request_write(HttpContext* context, HttpRequest* request);
HttpRequest* http_request_new(void);
-void http_request_free(HttpRequest* http_request);
+void http_request_free(HttpRequest* request);
struct _http_response
{
int StatusCode;
char* ReasonPhrase;
- wListDictionary *Authenticates;
int ContentLength;
- BYTE *BodyContent;
- int bodyLen;
+
+ int BodyLength;
+ BYTE* BodyContent;
+
+ wListDictionary* Authenticates;
};
-void http_response_print(HttpResponse* http_response);
+void http_response_print(HttpResponse* response);
HttpResponse* http_response_recv(rdpTls* tls);
HttpResponse* http_response_new(void);
-void http_response_free(HttpResponse* http_response);
+void http_response_free(HttpResponse* response);
#endif /* FREERDP_CORE_HTTP_H */
int rpc_ncacn_http_send_in_channel_request(rdpRpc* rpc)
{
wStream* s;
- int content_length;
- BOOL continue_needed;
+ int status;
+ int contentLength;
+ BOOL continueNeeded;
rdpNtlm* ntlm = rpc->NtlmHttpIn->ntlm;
- continue_needed = ntlm_authenticate(ntlm);
+ continueNeeded = ntlm_authenticate(ntlm);
+
+ contentLength = (continueNeeded) ? 0 : 0x40000000;
- content_length = (continue_needed) ? 0 : 0x40000000;
+ s = rpc_ntlm_http_request(rpc, &ntlm->outputBuffer[0], contentLength, TSG_CHANNEL_IN);
- s = rpc_ntlm_http_request(rpc, &ntlm->outputBuffer[0], content_length, TSG_CHANNEL_IN);
+ if (!s)
+ return -1;
WLog_DBG(TAG, "\n%s", Stream_Buffer(s));
- rpc_in_write(rpc, Stream_Buffer(s), Stream_Length(s));
+
+ status = rpc_in_write(rpc, Stream_Buffer(s), Stream_Length(s));
Stream_Free(s, TRUE);
- return 0;
+ return (status > 0) ? 1 : -1;
}
int rpc_ncacn_http_recv_in_channel_response(rdpRpc* rpc)
ntlm->inputBuffer[0].cbBuffer = ntlm_token_length;
http_response_free(http_response);
- return 0;
+ return 1;
}
int rpc_ncacn_http_ntlm_init(rdpRpc* rpc, TSG_CHANNEL channel)
}
if (!ntlm_client_init(ntlm, TRUE, settings->GatewayUsername,
- settings->GatewayDomain, settings->GatewayPassword,
- rpc->TlsIn->Bindings))
+ settings->GatewayDomain, settings->GatewayPassword, rpc->TlsIn->Bindings))
{
return 0;
}
BOOL rpc_ntlm_http_in_connect(rdpRpc* rpc)
{
- BOOL success = FALSE;
+ BOOL status = FALSE;
rdpNtlm* ntlm = rpc->NtlmHttpIn->ntlm;
- if (rpc_ncacn_http_ntlm_init(rpc, TSG_CHANNEL_IN) == 1)
- {
- success = TRUE;
+ if (rpc_ncacn_http_ntlm_init(rpc, TSG_CHANNEL_IN) <= 0)
+ goto out;
- /* Send IN Channel Request */
+ /* Send IN Channel Request */
- rpc_ncacn_http_send_in_channel_request(rpc);
+ if (rpc_ncacn_http_send_in_channel_request(rpc) <= 0)
+ goto out;
- /* Receive IN Channel Response */
+ /* Receive IN Channel Response */
- rpc_ncacn_http_recv_in_channel_response(rpc);
+ if (rpc_ncacn_http_recv_in_channel_response(rpc) <= 0)
+ goto out;
- /* Send IN Channel Request */
+ /* Send IN Channel Request */
- rpc_ncacn_http_send_in_channel_request(rpc);
+ if (rpc_ncacn_http_send_in_channel_request(rpc) <= 0)
+ goto out;
- ntlm_client_uninit(ntlm);
- }
+ status = TRUE;
+out:
+ ntlm_client_uninit(ntlm);
ntlm_free(ntlm);
-
rpc->NtlmHttpIn->ntlm = NULL;
- return success;
+ return status;
}
int rpc_ncacn_http_send_out_channel_request(rdpRpc* rpc)
{
wStream* s;
+ int status;
int content_length;
BOOL continue_needed;
rdpNtlm* ntlm = rpc->NtlmHttpOut->ntlm;
s = rpc_ntlm_http_request(rpc, &ntlm->outputBuffer[0], content_length, TSG_CHANNEL_OUT);
+ if (!s)
+ return -1;
+
WLog_DBG(TAG, "\n%s", Stream_Buffer(s));
- rpc_out_write(rpc, Stream_Buffer(s), Stream_Length(s));
+
+ status = rpc_out_write(rpc, Stream_Buffer(s), Stream_Length(s));
Stream_Free(s, TRUE);
- return 0;
+ return (status > 0) ? 1 : -1;
}
int rpc_ncacn_http_recv_out_channel_response(rdpRpc* rpc)
if (ListDictionary_Contains(http_response->Authenticates, "NTLM"))
{
token64 = ListDictionary_GetItemValue(http_response->Authenticates, "NTLM");
+
+ if (!token64)
+ goto out;
+
crypto_base64_decode(token64, strlen(token64), &ntlm_token_data, &ntlm_token_length);
}
+out:
ntlm->inputBuffer[0].pvBuffer = ntlm_token_data;
ntlm->inputBuffer[0].cbBuffer = ntlm_token_length;
-
http_response_free(http_response);
- return 0;
+ return 1;
}
int rpc_http_send_replacement_out_channel_request(rdpRpc* rpc)
BOOL rpc_ntlm_http_out_connect(rdpRpc* rpc)
{
+ BOOL status = FALSE;
rdpNtlm* ntlm = rpc->NtlmHttpOut->ntlm;
- BOOL success = FALSE;
- if (rpc_ncacn_http_ntlm_init(rpc, TSG_CHANNEL_OUT) == 1)
- {
- success = TRUE;
+ if (rpc_ncacn_http_ntlm_init(rpc, TSG_CHANNEL_OUT) <= 0)
+ goto out;
- /* Send OUT Channel Request */
- rpc_ncacn_http_send_out_channel_request(rpc);
+ /* Send OUT Channel Request */
+ if (rpc_ncacn_http_send_out_channel_request(rpc) <= 0)
+ goto out;
- /* Receive OUT Channel Response */
- rpc_ncacn_http_recv_out_channel_response(rpc);
+ /* Receive OUT Channel Response */
+ if (rpc_ncacn_http_recv_out_channel_response(rpc) <= 0)
+ goto out;
- /* Send OUT Channel Request */
- rpc_ncacn_http_send_out_channel_request(rpc);
+ /* Send OUT Channel Request */
+ if (rpc_ncacn_http_send_out_channel_request(rpc) <= 0)
+ goto out;
- ntlm_client_uninit(ntlm);
- }
+ status = TRUE;
+out:
+ ntlm_client_uninit(ntlm);
ntlm_free(ntlm);
-
rpc->NtlmHttpOut->ntlm = NULL;
- return success;
+ return status;
}
void rpc_ntlm_http_init_channel(rdpRpc* rpc, rdpNtlmHttp* ntlm_http, TSG_CHANNEL channel)
int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
{
- BYTE* buffer = NULL;
UINT32 offset;
- rdpNtlm* ntlm;
+ BYTE* buffer = NULL;
UINT32 stub_data_pad;
SecBuffer Buffers[2];
SecBufferDesc Message;
RpcClientCall* clientCall;
SECURITY_STATUS encrypt_status;
rpcconn_request_hdr_t* request_pdu = NULL;
- ntlm = rpc->ntlm;
+ rdpNtlm* ntlm = rpc->ntlm;
if (!ntlm || !ntlm->table)
{
request_pdu->auth_verifier.auth_context_id = 0x00000000;
offset += (8 + request_pdu->auth_length);
request_pdu->frag_length = offset;
+
buffer = (BYTE*) calloc(1, request_pdu->frag_length);
if (!buffer)
Buffers[1].pvBuffer = calloc(1, Buffers[1].cbBuffer);
if (!Buffers[1].pvBuffer)
- {
goto out_free_pdu;
- }
Message.cBuffers = 2;
Message.ulVersion = SECBUFFER_VERSION;
offset += Buffers[1].cbBuffer;
free(Buffers[1].pvBuffer);
- if (rpc_send_enqueue_pdu(rpc, buffer, request_pdu->frag_length) < 0)
+ if (rpc_send_pdu(rpc, buffer, request_pdu->frag_length) < 0)
length = -1;
free(request_pdu);
out_free_clientCall:
rpc_client_call_free(clientCall);
out_free_pdu:
- free (buffer);
- free (Buffers[1].pvBuffer);
+ free(buffer);
+ free(Buffers[1].pvBuffer);
free(request_pdu);
return -1;
}
int rpc_check(rdpRpc* rpc)
{
RPC_PDU* pdu;
+ rpcconn_rts_hdr_t* rts;
+
+ if (rpc->State < RPC_CLIENT_STATE_ESTABLISHED)
+ {
+ switch (rpc->VirtualConnection->State)
+ {
+ case VIRTUAL_CONNECTION_STATE_INITIAL:
+ break;
+
+ case VIRTUAL_CONNECTION_STATE_OUT_CHANNEL_WAIT:
+ break;
+
+ case VIRTUAL_CONNECTION_STATE_WAIT_A3W:
+
+ pdu = rpc_recv_dequeue_pdu(rpc, TRUE);
+
+ if (!pdu)
+ return -1;
+
+ rts = (rpcconn_rts_hdr_t*) Stream_Buffer(pdu->s);
+
+ if (!rts_match_pdu_signature(rpc, &RTS_PDU_CONN_A3_SIGNATURE, rts))
+ {
+ WLog_ERR(TAG, "unexpected RTS PDU: Expected CONN/A3");
+ return -1;
+ }
+
+ rts_recv_CONN_A3_pdu(rpc, Stream_Buffer(pdu->s), Stream_Length(pdu->s));
+
+ rpc_client_receive_pool_return(rpc, pdu);
+
+ rpc->VirtualConnection->State = VIRTUAL_CONNECTION_STATE_WAIT_C2;
+ WLog_DBG(TAG, "VIRTUAL_CONNECTION_STATE_WAIT_C2");
+
+ break;
+
+ case VIRTUAL_CONNECTION_STATE_WAIT_C2:
+
+ pdu = rpc_recv_dequeue_pdu(rpc, TRUE);
+
+ if (!pdu)
+ return FALSE;
+
+ rts = (rpcconn_rts_hdr_t*) Stream_Buffer(pdu->s);
+
+ if (!rts_match_pdu_signature(rpc, &RTS_PDU_CONN_C2_SIGNATURE, rts))
+ {
+ WLog_ERR(TAG, "unexpected RTS PDU: Expected CONN/C2");
+ return FALSE;
+ }
+
+ rts_recv_CONN_C2_pdu(rpc, Stream_Buffer(pdu->s), Stream_Length(pdu->s));
+
+ rpc_client_receive_pool_return(rpc, pdu);
+
+ rpc->VirtualConnection->State = VIRTUAL_CONNECTION_STATE_OPENED;
+ WLog_DBG(TAG, "VIRTUAL_CONNECTION_STATE_OPENED");
+
+ rpc->State = RPC_CLIENT_STATE_ESTABLISHED;
+
+ break;
+
+ case VIRTUAL_CONNECTION_STATE_OPENED:
+ break;
+
+ case VIRTUAL_CONNECTION_STATE_FINAL:
+ break;
+ }
+
+ return 1;
+ }
if (rpc->State == RPC_CLIENT_STATE_ESTABLISHED)
{
return -1;
}
+ rpc_client_start(rpc);
+
while (rpc->State != RPC_CLIENT_STATE_CONTEXT_NEGOTIATED)
{
if (rpc_check(rpc) < 0)
if (rpc_client_new(rpc) < 0)
goto out_free_virtualConnectionCookieTable;
- rpc->client->SynchronousSend = TRUE;
rpc->client->SynchronousReceive = TRUE;
return rpc;
out_free_virtualConnectionCookieTable:
HANDLE Thread;
HANDLE StopEvent;
- wQueue* SendQueue;
-
RPC_PDU* pdu;
wQueue* ReceivePool;
wQueue* ReceiveQueue;
wArrayList* ClientCallList;
- HANDLE PduSentEvent;
-
- BOOL SynchronousSend;
BOOL SynchronousReceive;
};
typedef struct rpc_client RpcClient;
int rpc_send_bind_pdu(rdpRpc* rpc)
{
+ int status;
BYTE* buffer;
UINT32 offset;
UINT32 length;
return -1;
}
- if (rpc_send_enqueue_pdu(rpc, buffer, length) != 0)
- length = -1;
+ status = rpc_send_pdu(rpc, buffer, length);
free(bind_pdu->p_context_elem.p_cont_elem[0].transfer_syntaxes);
free(bind_pdu->p_context_elem.p_cont_elem[1].transfer_syntaxes);
free(bind_pdu->p_context_elem.p_cont_elem);
free(bind_pdu);
- return length;
+ return status;
}
/**
int status;
BYTE* buffer;
UINT32 offset;
+ UINT32 length;
RpcClientCall* clientCall;
rpcconn_rpc_auth_3_hdr_t* auth_3_pdu;
CopyMemory(&buffer[offset + 8], auth_3_pdu->auth_verifier.auth_value, auth_3_pdu->auth_length);
offset += (8 + auth_3_pdu->auth_length);
- status = (int) auth_3_pdu->frag_length;
+ length = auth_3_pdu->frag_length;
clientCall = rpc_client_call_new(auth_3_pdu->call_id, 0);
ArrayList_Add(rpc->client->ClientCallList, clientCall);
- if (rpc_send_enqueue_pdu(rpc, buffer, (UINT32) status) != 0)
- status = -1;
+ status = rpc_send_pdu(rpc, buffer, length);
free(auth_3_pdu);
#define SYNCHRONOUS_TIMEOUT 5000
-RPC_PDU* rpc_client_receive_pool_take(rdpRpc* rpc)
+RPC_PDU* rpc_pdu_new()
{
- RPC_PDU* pdu = NULL;
+ RPC_PDU* pdu;
- if (WaitForSingleObject(Queue_Event(rpc->client->ReceivePool), 0) == WAIT_OBJECT_0)
- pdu = Queue_Dequeue(rpc->client->ReceivePool);
+ pdu = (RPC_PDU*) malloc(sizeof(RPC_PDU));
if (!pdu)
- {
- pdu = (RPC_PDU*) malloc(sizeof(RPC_PDU));
-
- if (!pdu)
- return NULL;
+ return NULL;
- pdu->s = Stream_New(NULL, rpc->max_recv_frag);
+ pdu->s = Stream_New(NULL, 4096);
- if (!pdu->s)
- {
- free(pdu);
- return NULL;
- }
+ if (!pdu->s)
+ {
+ free(pdu);
+ return NULL;
}
+ pdu->Type = 0;
+ pdu->Flags = 0;
pdu->CallId = 0;
+
+ return pdu;
+}
+
+static void rpc_pdu_free(RPC_PDU* pdu)
+{
+ if (!pdu)
+ return;
+
+ Stream_Free(pdu->s, TRUE);
+ free(pdu);
+}
+
+RPC_PDU* rpc_client_receive_pool_take(rdpRpc* rpc)
+{
+ RPC_PDU* pdu = NULL;
+
+ if (WaitForSingleObject(Queue_Event(rpc->client->ReceivePool), 0) == WAIT_OBJECT_0)
+ pdu = Queue_Dequeue(rpc->client->ReceivePool);
+
+ if (!pdu)
+ pdu = rpc_pdu_new();
+
+ pdu->Type = 0;
pdu->Flags = 0;
- Stream_Length(pdu->s) = 0;
+ pdu->CallId = 0;
+
Stream_SetPosition(pdu->s, 0);
+
return pdu;
}
return status;
}
-int rpc_client_on_pdu_received(rdpRpc* rpc, RPC_PDU* pdu)
+int rpc_client_recv_pdu(rdpRpc* rpc, RPC_PDU* pdu)
{
Queue_Enqueue(rpc->client->ReceiveQueue, pdu);
return 1;
}
-int rpc_client_on_fragment_received(rdpRpc* rpc, wStream* fragment)
+int rpc_client_recv_fragment(rdpRpc* rpc, wStream* fragment)
{
BYTE* buffer;
RPC_PDU* pdu;
pdu->Type = PTYPE_RESPONSE;
pdu->CallId = rpc->StubCallId;
Stream_SealLength(pdu->s);
- rpc_client_on_pdu_received(rpc, pdu);
+ rpc_client_recv_pdu(rpc, pdu);
rpc->client->pdu = NULL;
rpc->StubFragCount = 0;
rpc->StubCallId = 0;
Stream_EnsureCapacity(pdu->s, Stream_Length(fragment));
Stream_Write(pdu->s, buffer, Stream_Length(fragment));
Stream_SealLength(pdu->s);
- rpc_client_on_pdu_received(rpc, pdu);
+ rpc_client_recv_pdu(rpc, pdu);
rpc->client->pdu = NULL;
return 0;
}
Stream_EnsureCapacity(pdu->s, Stream_Length(fragment));
Stream_Write(pdu->s, buffer, Stream_Length(fragment));
Stream_SealLength(pdu->s);
- rpc_client_on_pdu_received(rpc, pdu);
+ rpc_client_recv_pdu(rpc, pdu);
rpc->client->pdu = NULL;
return 0;
}
return 0;
}
-int rpc_client_on_read(rdpRpc* rpc)
+int rpc_client_recv(rdpRpc* rpc)
{
int position;
int status = -1;
Stream_SealLength(rpc->client->ReceiveFragment);
Stream_SetPosition(rpc->client->ReceiveFragment, 0);
- status = rpc_client_on_fragment_received(rpc, rpc->client->ReceiveFragment);
+ status = rpc_client_recv_fragment(rpc, rpc->client->ReceiveFragment);
if (status < 0)
return status;
free(clientCall);
}
-int rpc_send_enqueue_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length)
+int rpc_send_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length)
{
int status;
- RPC_PDU* pdu;
-
- pdu = (RPC_PDU*) malloc(sizeof(RPC_PDU));
-
- if (!pdu)
- {
- free(buffer);
- return -1;
- }
-
- pdu->s = Stream_New(buffer, length);
-
- if (!pdu->s)
- goto out_free;
-
- if (!Queue_Enqueue(rpc->client->SendQueue, pdu))
- goto out_free_stream;
-
- if (rpc->client->SynchronousSend)
- {
- status = WaitForSingleObject(rpc->client->PduSentEvent, SYNCHRONOUS_TIMEOUT);
-
- if (status == WAIT_TIMEOUT)
- {
- WLog_ERR(TAG, "timed out waiting for pdu sent event %p", rpc->client->PduSentEvent);
- return -1;
- }
-
- ResetEvent(rpc->client->PduSentEvent);
- }
-
- return 0;
-out_free_stream:
- Stream_Free(pdu->s, TRUE);
-out_free:
- free(pdu);
- WLog_ERR(TAG, "rpc_send_enqueue_pdu failure");
- return -1;
-}
-
-int rpc_send_dequeue_pdu(rdpRpc* rpc)
-{
- int status;
- RPC_PDU* pdu;
+ RpcInChannel* inChannel;
RpcClientCall* clientCall;
rpcconn_common_hdr_t* header;
- RpcInChannel* inChannel;
- pdu = (RPC_PDU*) Queue_Dequeue(rpc->client->SendQueue);
+ inChannel = rpc->VirtualConnection->DefaultInChannel;
- if (!pdu)
- return 0;
+ status = rpc_in_write(rpc, buffer, length);
- inChannel = rpc->VirtualConnection->DefaultInChannel;
- status = rpc_in_write(rpc, Stream_Buffer(pdu->s), Stream_Length(pdu->s));
- header = (rpcconn_common_hdr_t*) Stream_Buffer(pdu->s);
+ header = (rpcconn_common_hdr_t*) buffer;
clientCall = rpc_client_call_find_by_id(rpc, header->call_id);
clientCall->State = RPC_CLIENT_CALL_STATE_DISPATCHED;
inChannel->SenderAvailableWindow -= status;
}
- Stream_Free(pdu->s, TRUE);
- free(pdu);
-
- if (rpc->client->SynchronousSend)
- SetEvent(rpc->client->PduSentEvent);
+ free(buffer);
return status;
}
nCount = 0;
events[nCount++] = rpc->client->StopEvent;
- events[nCount++] = Queue_Event(rpc->client->SendQueue);
events[nCount++] = ReadEvent;
/*
* the problem for now.
*/
- if (rpc_client_on_read(rpc) < 0)
+ if (rpc_client_recv(rpc) < 0)
{
rpc->transport->layer = TRANSPORT_LAYER_CLOSED;
return NULL;
if (WaitForSingleObject(ReadEvent, 0) == WAIT_OBJECT_0)
{
- if (rpc_client_on_read(rpc) < 0)
+ if (rpc_client_recv(rpc) < 0)
{
rpc->transport->layer = TRANSPORT_LAYER_CLOSED;
break;
}
}
-
- if (WaitForSingleObject(Queue_Event(rpc->client->SendQueue), 0) == WAIT_OBJECT_0)
- {
- rpc_send_dequeue_pdu(rpc);
- }
}
return NULL;
}
-static void rpc_pdu_free(RPC_PDU* pdu)
-{
- if (!pdu)
- return;
-
- Stream_Free(pdu->s, TRUE);
- free(pdu);
-}
-
int rpc_client_new(rdpRpc* rpc)
{
RpcClient* client;
if (!client->StopEvent)
return -1;
- client->PduSentEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
-
- if (!client->PduSentEvent)
- return -1;
-
- client->SendQueue = Queue_New(TRUE, -1, -1);
-
- if (!client->SendQueue)
- return -1;
-
- Queue_Object(client->SendQueue)->fnObjectFree = (OBJECT_FREE_FN) rpc_pdu_free;
-
client->pdu = NULL;
client->ReceivePool = Queue_New(TRUE, -1, -1);
rpc_client_stop(rpc);
- if (client->SendQueue)
- Queue_Free(client->SendQueue);
-
if (client->ReceiveFragment)
Stream_Free(client->ReceiveFragment, TRUE);
if (client->StopEvent)
CloseHandle(client->StopEvent);
- if (client->PduSentEvent)
- CloseHandle(client->PduSentEvent);
-
if (client->Thread)
CloseHandle(client->Thread);
RpcClientCall* rpc_client_call_new(UINT32 CallId, UINT32 OpNum);
void rpc_client_call_free(RpcClientCall* client_call);
+int rpc_send_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length);
int rpc_send_enqueue_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length);
int rpc_send_dequeue_pdu(rdpRpc* rpc);
BOOL rts_connect(rdpRpc* rpc)
{
- RPC_PDU* pdu;
- rpcconn_rts_hdr_t* rts;
- HttpResponse* httpResponse;
+ HttpResponse* response;
freerdp* instance = (freerdp*) rpc->settings->instance;
rdpContext* context = instance->context;
- /**
- * Connection Opening
- *
- * When opening a virtual connection to the server, an implementation of this protocol MUST perform
- * the following sequence of steps:
- *
- * 1. Send an IN channel request as specified in section 2.1.2.1.1, containing the connection timeout,
- * ResourceType UUID, and Session UUID values, if any, supplied by the higher-layer protocol or application.
- *
- * 2. Send an OUT channel request as specified in section 2.1.2.1.2.
- *
- * 3. Send a CONN/A1 RTS PDU as specified in section 2.2.4.2
- *
- * 4. Send a CONN/B1 RTS PDU as specified in section 2.2.4.5
- *
- * 5. Wait for the connection establishment protocol sequence as specified in 3.2.1.5.3.1 to complete
- *
- * An implementation MAY execute steps 1 and 2 in parallel. An implementation SHOULD execute steps
- * 3 and 4 in parallel. An implementation MUST execute step 3 after completion of step 1 and execute
- * step 4 after completion of step 2.
- *
- */
-
rpc->VirtualConnection->State = VIRTUAL_CONNECTION_STATE_INITIAL;
WLog_DBG(TAG, "VIRTUAL_CONNECTION_STATE_INITIAL");
return FALSE;
}
- if (rts_send_CONN_A1_pdu(rpc) != 0)
+ if (rts_send_CONN_A1_pdu(rpc) < 0)
{
WLog_ERR(TAG, "rpc_send_CONN_A1_pdu error!");
return FALSE;
rpc->VirtualConnection->State = VIRTUAL_CONNECTION_STATE_OUT_CHANNEL_WAIT;
WLog_DBG(TAG, "VIRTUAL_CONNECTION_STATE_OUT_CHANNEL_WAIT");
- /**
- * Receive OUT Channel Response
- *
- * A client implementation MUST NOT accept the OUT channel HTTP response in any state other than
- * Out Channel Wait. If received in any other state, this HTTP response is a protocol error. Therefore,
- * the client MUST consider the virtual connection opening a failure and indicate this to higher layers
- * in an implementation-specific way. The Microsoft Windows implementation returns
- * RPC_S_PROTOCOL_ERROR, as specified in [MS-ERREF], to higher-layer protocols.
- *
- * If this HTTP response is received in Out Channel Wait state, the client MUST process the fields of
- * this response as defined in this section.
- *
- * First, the client MUST determine whether the response indicates a success or a failure. If the status
- * code is set to 200, the client MUST interpret this as a success, and it MUST do the following:
- *
- * 1. Ignore the values of all other header fields.
- *
- * 2. Transition to Wait_A3W state.
- *
- * 3. Wait for network events.
- *
- * 4. Skip the rest of the processing in this section.
- *
- * If the status code is not set to 200, the client MUST interpret this as a failure and follow the same
- * processing rules as specified in section 3.2.2.5.6.
- *
- */
-
- httpResponse = http_response_recv(rpc->TlsOut);
+ response = http_response_recv(rpc->TlsOut);
- if (!httpResponse)
+ if (!response)
{
WLog_ERR(TAG, "unable to retrieve OUT Channel Response!");
return FALSE;
}
- if (httpResponse->StatusCode != HTTP_STATUS_OK)
+ if (response->StatusCode != HTTP_STATUS_OK)
{
- WLog_ERR(TAG, "error! Status Code: %d", httpResponse->StatusCode);
- http_response_print(httpResponse);
- http_response_free(httpResponse);
+ WLog_ERR(TAG, "error! Status Code: %d", response->StatusCode);
+ http_response_print(response);
+ http_response_free(response);
- if (httpResponse->StatusCode == HTTP_STATUS_DENIED)
+ if (response->StatusCode == HTTP_STATUS_DENIED)
{
if (!connectErrorCode)
{
return FALSE;
}
- http_response_free(httpResponse);
+ http_response_free(response);
rpc->VirtualConnection->State = VIRTUAL_CONNECTION_STATE_WAIT_A3W;
WLog_DBG(TAG, "VIRTUAL_CONNECTION_STATE_WAIT_A3W");
- /**
- * Receive CONN_A3 RTS PDU
- *
- * A client implementation MUST NOT accept the CONN/A3 RTS PDU in any state other than
- * Wait_A3W. If received in any other state, this PDU is a protocol error and the client
- * MUST consider the virtual connection opening a failure and indicate this to higher
- * layers in an implementation-specific way.
- *
- * Set the ConnectionTimeout in the Ping Originator of the Client's IN Channel to the
- * ConnectionTimeout in the CONN/A3 PDU.
- *
- * If this RTS PDU is received in Wait_A3W state, the client MUST transition the state
- * machine to Wait_C2 state and wait for network events.
- *
- */
-
- rpc_client_start(rpc);
-
- pdu = rpc_recv_dequeue_pdu(rpc, TRUE);
-
- if (!pdu)
- return FALSE;
-
- rts = (rpcconn_rts_hdr_t*) Stream_Buffer(pdu->s);
-
- if (!rts_match_pdu_signature(rpc, &RTS_PDU_CONN_A3_SIGNATURE, rts))
- {
- WLog_ERR(TAG, "unexpected RTS PDU: Expected CONN/A3");
- return FALSE;
- }
-
- rts_recv_CONN_A3_pdu(rpc, Stream_Buffer(pdu->s), Stream_Length(pdu->s));
-
- rpc_client_receive_pool_return(rpc, pdu);
-
- rpc->VirtualConnection->State = VIRTUAL_CONNECTION_STATE_WAIT_C2;
- WLog_DBG(TAG, "VIRTUAL_CONNECTION_STATE_WAIT_C2");
-
- /**
- * Receive CONN_C2 RTS PDU
- *
- * A client implementation MUST NOT accept the CONN/C2 RTS PDU in any state other than Wait_C2.
- * If received in any other state, this PDU is a protocol error and the client MUST consider the virtual
- * connection opening a failure and indicate this to higher layers in an implementation-specific way.
- *
- * If this RTS PDU is received in Wait_C2 state, the client implementation MUST do the following:
- *
- * 1. Transition the state machine to opened state.
- *
- * 2. Set the connection time-out protocol variable to the value of the ConnectionTimeout field from
- * the CONN/C2 RTS PDU.
- *
- * 3. Set the PeerReceiveWindow value in the SendingChannel of the Client IN Channel to the
- * ReceiveWindowSize value in the CONN/C2 PDU.
- *
- * 4. Indicate to higher-layer protocols that the virtual connection opening is a success.
- *
- */
-
- pdu = rpc_recv_dequeue_pdu(rpc, TRUE);
-
- if (!pdu)
- return FALSE;
-
- rts = (rpcconn_rts_hdr_t*) Stream_Buffer(pdu->s);
-
- if (!rts_match_pdu_signature(rpc, &RTS_PDU_CONN_C2_SIGNATURE, rts))
- {
- WLog_ERR(TAG, "unexpected RTS PDU: Expected CONN/C2");
- return FALSE;
- }
-
- rts_recv_CONN_C2_pdu(rpc, Stream_Buffer(pdu->s), Stream_Length(pdu->s));
-
- rpc_client_receive_pool_return(rpc, pdu);
-
- rpc->VirtualConnection->State = VIRTUAL_CONNECTION_STATE_OPENED;
- WLog_DBG(TAG, "VIRTUAL_CONNECTION_STATE_OPENED");
-
- rpc->State = RPC_CLIENT_STATE_ESTABLISHED;
-
return TRUE;
}
ReceiveWindowSize = rpc->VirtualConnection->DefaultOutChannel->ReceiveWindow;
buffer = (BYTE*) malloc(header.frag_length);
+
if (!buffer)
return -1;
int rts_send_CONN_B1_pdu(rdpRpc* rpc)
{
+ int status;
BYTE* buffer;
UINT32 length;
rpcconn_rts_hdr_t header;
BYTE* INChannelCookie;
BYTE* AssociationGroupId;
BYTE* VirtualConnectionCookie;
- int status;
rts_pdu_header_init(&header);
header.frag_length = 104;
AssociationGroupId = (BYTE*) &(rpc->VirtualConnection->AssociationGroupId);
buffer = (BYTE*) malloc(header.frag_length);
+
if (!buffer)
return -1;
WLog_DBG(TAG, "Sending Keep-Alive RTS PDU");
buffer = (BYTE*) malloc(header.frag_length);
+
if (!buffer)
return -1;
+
CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */
rts_client_keepalive_command_write(&buffer[20], rpc->CurrentKeepAliveInterval); /* ClientKeepAlive (8 bytes) */
BOOL tsg_set_blocking_mode(rdpTsg* tsg, BOOL blocking)
{
- tsg->rpc->client->SynchronousSend = TRUE;
tsg->rpc->client->SynchronousReceive = blocking;
tsg->transport->GatewayEvent = tsg->rpc->client->PipeEvent;
return TRUE;