libfreerdp-core: add support for token-based server redirection

This commit is contained in:
Marc-André Moreau 2011-09-03 18:21:21 -04:00
parent bca678dd61
commit d53bd1cafa
5 changed files with 36 additions and 22 deletions

View File

@ -128,8 +128,13 @@ boolean rdp_client_redirect(rdpRdp* rdp)
rdp->transport->layer = TRANSPORT_LAYER_TCP;
settings->redirected_session_id = redirection->sessionID;
if (redirection->flags & LB_LOAD_BALANCE_INFO)
nego_set_routing_token(rdp->nego, &redirection->loadBalanceInfo);
if (redirection->flags & LB_TARGET_NET_ADDRESS)
settings->hostname = redirection->targetNetAddress.ascii;
else if (redirection->flags & LB_TARGET_NETBIOS_NAME)
settings->hostname = redirection->targetNetBiosName.ascii;
if (redirection->flags & LB_USERNAME)
settings->username = redirection->username.ascii;

View File

@ -359,7 +359,12 @@ void nego_send_negotiation_request(rdpNego* nego)
stream_get_mark(s, bm);
stream_seek(s, length);
if (nego->cookie)
if (nego->routing_token != NULL)
{
stream_write(s, nego->routing_token->data, nego->routing_token->length);
length += nego->routing_token->length;
}
else
{
int cookie_length = strlen(nego->cookie);
stream_write(s, "Cookie: mstshash=", 17);
@ -368,12 +373,6 @@ void nego_send_negotiation_request(rdpNego* nego)
stream_write_uint8(s, 0x0A); /* LF */
length += cookie_length + 19;
}
else if (nego->routing_token)
{
int routing_token_length = strlen(nego->routing_token);
stream_write(s, nego->routing_token, routing_token_length);
length += routing_token_length;
}
if (nego->requested_protocols > PROTOCOL_RDP)
{
@ -613,7 +612,7 @@ void nego_enable_nla(rdpNego* nego, boolean enable_nla)
* @param routing_token
*/
void nego_set_routing_token(rdpNego* nego, char* routing_token)
void nego_set_routing_token(rdpNego* nego, rdpBlob* routing_token)
{
nego->routing_token = routing_token;
}

View File

@ -23,6 +23,7 @@
#include "transport.h"
#include <freerdp/types.h>
#include <freerdp/settings.h>
#include <freerdp/utils/blob.h>
#include <freerdp/utils/debug.h>
#include <freerdp/utils/stream.h>
@ -75,9 +76,9 @@ struct rdp_nego
int port;
char* hostname;
char* cookie;
char* routing_token;
NEGO_STATE state;
int tcp_connected;
rdpBlob* routing_token;
uint32 selected_protocol;
uint32 requested_protocols;
uint8 enabled_protocols[3];
@ -109,7 +110,7 @@ void nego_set_target(rdpNego* nego, char* hostname, int port);
void nego_enable_rdp(rdpNego* nego, boolean enable_rdp);
void nego_enable_nla(rdpNego* nego, boolean enable_nla);
void nego_enable_tls(rdpNego* nego, boolean enable_tls);
void nego_set_routing_token(rdpNego* nego, char* routing_token);
void nego_set_routing_token(rdpNego* nego, rdpBlob* routing_token);
void nego_set_cookie(rdpNego* nego, char* cookie);
#ifdef WITH_DEBUG_NEGO

View File

@ -80,8 +80,14 @@ boolean rdp_recv_server_redirection_pdu(rdpRdp* rdp, STREAM* s)
if (redirection->flags & LB_LOAD_BALANCE_INFO)
{
freerdp_string_read_length32(s, &redirection->loadBalanceInfo, rdp->settings->uniconv);
DEBUG_REDIR("loadBalanceInfo: %s", redirection->loadBalanceInfo.ascii);
uint32 loadBalanceInfoLength;
stream_read_uint32(s, loadBalanceInfoLength);
freerdp_blob_alloc(&redirection->loadBalanceInfo, loadBalanceInfoLength);
stream_read(s, redirection->loadBalanceInfo.data, loadBalanceInfoLength);
#ifdef WITH_DEBUG_REDIR
DEBUG_REDIR("loadBalanceInfo:");
freerdp_hexdump(redirection->loadBalanceInfo.data, redirection->loadBalanceInfo.length);
#endif
}
if (redirection->flags & LB_USERNAME)
@ -169,6 +175,16 @@ rdpRedirection* redirection_new()
redirection = (rdpRedirection*) xzalloc(sizeof(rdpRedirection));
if (redirection != NULL)
{
}
return redirection;
}
void redirection_free(rdpRedirection* redirection)
{
if (redirection != NULL)
{
freerdp_string_free(&redirection->tsvUrl);
@ -176,9 +192,9 @@ rdpRedirection* redirection_new()
freerdp_string_free(&redirection->domain);
freerdp_string_free(&redirection->password);
freerdp_string_free(&redirection->targetFQDN);
freerdp_string_free(&redirection->loadBalanceInfo);
freerdp_string_free(&redirection->targetNetBiosName);
freerdp_string_free(&redirection->targetNetAddress);
freerdp_blob_free(&redirection->loadBalanceInfo);
if (redirection->targetNetAddresses != NULL)
{
@ -189,15 +205,7 @@ rdpRedirection* redirection_new()
xfree(redirection->targetNetAddresses);
}
}
return redirection;
}
void redirection_free(rdpRedirection* redirection)
{
if (redirection != NULL)
{
xfree(redirection);
}
}

View File

@ -23,6 +23,7 @@
#include "rdp.h"
#include <freerdp/freerdp.h>
#include <freerdp/utils/blob.h>
#include <freerdp/utils/debug.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/string.h>
@ -51,7 +52,7 @@ struct rdp_redirection
rdpString domain;
rdpString password;
rdpString targetFQDN;
rdpString loadBalanceInfo;
rdpBlob loadBalanceInfo;
rdpString targetNetBiosName;
rdpString targetNetAddress;
uint32 targetNetAddressesCount;