libfreerdp-core: fix RemoteFX/autodetect incompatibility issue with 2008 R2

This commit is contained in:
Marc-André Moreau 2014-09-24 17:23:12 -04:00
parent 255bd6f7a2
commit 72fff184dd
7 changed files with 45 additions and 38 deletions

View File

@ -865,6 +865,7 @@ int freerdp_parse_hostname(char* hostname, char** host, int* port)
int freerdp_set_connection_type(rdpSettings* settings, int type)
{
settings->ConnectionType = type;
if (type == CONNECTION_TYPE_MODEM)
{
settings->DisableWallpaper = TRUE;
@ -1592,8 +1593,12 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
type = CONNECTION_TYPE_WAN;
else if (_stricmp(arg->Value, "lan") == 0)
type = CONNECTION_TYPE_LAN;
else if (_stricmp(arg->Value, "auto") == 0)
else if ((_stricmp(arg->Value, "autodetect") == 0) ||
(_stricmp(arg->Value, "auto") == 0) ||
(_stricmp(arg->Value, "detect") == 0))
{
type = CONNECTION_TYPE_AUTODETECT;
}
}
freerdp_set_connection_type(settings, type);

View File

@ -41,10 +41,10 @@ static BOOL autodetect_send_rtt_measure_response(rdpRdp* rdp, UINT16 sequenceNum
s = rdp_message_channel_pdu_init(rdp);
if (s == NULL)
if (!s)
return FALSE;
DEBUG_AUTODETECT("sending RTT Measure Response PDU");
WLog_DBG(AUTODETECT_TAG, "sending RTT Measure Response PDU");
Stream_Write_UINT8(s, 0x06); /* headerLength (1 byte) */
Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_RESPONSE); /* headerTypeId (1 byte) */
@ -56,8 +56,8 @@ static BOOL autodetect_send_rtt_measure_response(rdpRdp* rdp, UINT16 sequenceNum
static BOOL autodetect_send_bandwidth_measure_results(rdpRdp* rdp, UINT16 responseType, UINT16 sequenceNumber)
{
UINT32 timeDelta;
wStream* s;
UINT32 timeDelta;
/* Compute the total time */
timeDelta = GetTickCount() - rdp->autodetect->bandwidthMeasureStartTime;
@ -66,10 +66,10 @@ static BOOL autodetect_send_bandwidth_measure_results(rdpRdp* rdp, UINT16 respon
s = rdp_message_channel_pdu_init(rdp);
if (s == NULL)
if (!s)
return FALSE;
DEBUG_AUTODETECT("sending Bandwidth Measure Results PDU -> timeDelta=%u, byteCount=%u", timeDelta, rdp->autodetect->bandwidthMeasureByteCount);
WLog_DBG(AUTODETECT_TAG, "sending Bandwidth Measure Results PDU -> timeDelta=%u, byteCount=%u", timeDelta, rdp->autodetect->bandwidthMeasureByteCount);
Stream_Write_UINT8(s, 0x0E); /* headerLength (1 byte) */
Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_RESPONSE); /* headerTypeId (1 byte) */
@ -89,10 +89,10 @@ BOOL autodetect_send_netchar_sync(rdpRdp* rdp, UINT16 sequenceNumber)
s = rdp_message_channel_pdu_init(rdp);
if (s == NULL)
if (!s)
return FALSE;
DEBUG_AUTODETECT("sending Network Characteristics Sync PDU -> bandwidth=%u, rtt=%u", rdp->autodetect->netCharBandwidth, rdp->autodetect->netCharAverageRTT);
WLog_DBG(AUTODETECT_TAG, "sending Network Characteristics Sync PDU -> bandwidth=%u, rtt=%u", rdp->autodetect->netCharBandwidth, rdp->autodetect->netCharAverageRTT);
Stream_Write_UINT8(s, 0x0E); /* headerLength (1 byte) */
Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_RESPONSE); /* headerTypeId (1 byte) */
@ -109,7 +109,7 @@ static BOOL autodetect_recv_rtt_measure_request(rdpRdp* rdp, wStream* s, AUTODET
if (autodetectReqPdu->headerLength != 0x06)
return FALSE;
DEBUG_AUTODETECT("received RTT Measure Request PDU");
WLog_DBG(AUTODETECT_TAG, "received RTT Measure Request PDU");
/* Send a response to the server */
return autodetect_send_rtt_measure_response(rdp, autodetectReqPdu->sequenceNumber);
@ -120,7 +120,7 @@ static BOOL autodetect_recv_bandwidth_measure_start(rdpRdp* rdp, wStream* s, AUT
if (autodetectReqPdu->headerLength != 0x06)
return FALSE;
DEBUG_AUTODETECT("received Bandwidth Measure Start PDU - time=%lu", GetTickCount());
WLog_DBG(AUTODETECT_TAG, "received Bandwidth Measure Start PDU - time=%lu", GetTickCount());
/* Initialize bandwidth measurement parameters */
rdp->autodetect->bandwidthMeasureStartTime = GetTickCount();
@ -141,7 +141,7 @@ static BOOL autodetect_recv_bandwidth_measure_payload(rdpRdp* rdp, wStream* s, A
Stream_Read_UINT16(s, payloadLength); /* payloadLength (2 bytes) */
DEBUG_AUTODETECT("received Bandwidth Measure Payload PDU -> payloadLength=%u", payloadLength);
WLog_DBG(AUTODETECT_TAG, "received Bandwidth Measure Payload PDU -> payloadLength=%u", payloadLength);
/* Add the payload length to the bandwidth measurement parameters */
rdp->autodetect->bandwidthMeasureByteCount += payloadLength;
@ -172,7 +172,7 @@ static BOOL autodetect_recv_bandwidth_measure_stop(rdpRdp* rdp, wStream* s, AUTO
payloadLength = 0;
}
DEBUG_AUTODETECT("received Bandwidth Measure Stop PDU -> payloadLength=%u", payloadLength);
WLog_DBG(AUTODETECT_TAG, "received Bandwidth Measure Stop PDU -> payloadLength=%u", payloadLength);
/* Add the payload length to the bandwidth measurement parameters */
rdp->autodetect->bandwidthMeasureByteCount += payloadLength;
@ -213,7 +213,7 @@ static BOOL autodetect_recv_netchar_result(rdpRdp* rdp, wStream* s, AUTODETECT_R
break;
}
DEBUG_AUTODETECT("received Network Characteristics Result PDU -> baseRTT=%u, bandwidth=%u, averageRTT=%u", rdp->autodetect->netCharBaseRTT, rdp->autodetect->netCharBandwidth, rdp->autodetect->netCharAverageRTT);
WLog_DBG(AUTODETECT_TAG, "received Network Characteristics Result PDU -> baseRTT=%u, bandwidth=%u, averageRTT=%u", rdp->autodetect->netCharBaseRTT, rdp->autodetect->netCharBandwidth, rdp->autodetect->netCharAverageRTT);
return TRUE;
}
@ -231,7 +231,7 @@ int rdp_recv_autodetect_packet(rdpRdp* rdp, wStream* s)
Stream_Read_UINT16(s, autodetectReqPdu.sequenceNumber); /* sequenceNumber (2 bytes) */
Stream_Read_UINT16(s, autodetectReqPdu.requestType); /* requestType (2 bytes) */
DEBUG_AUTODETECT(
WLog_DBG(AUTODETECT_TAG,
"rdp_recv_autodetect_packet: headerLength=%u, headerTypeId=%u, sequenceNumber=%u, requestType=%04x",
autodetectReqPdu.headerLength, autodetectReqPdu.headerTypeId,
autodetectReqPdu.sequenceNumber, autodetectReqPdu.requestType);
@ -282,11 +282,11 @@ int rdp_recv_autodetect_packet(rdpRdp* rdp, wStream* s)
rdpAutoDetect* autodetect_new(void)
{
rdpAutoDetect* autoDetect = (rdpAutoDetect*) malloc(sizeof(rdpAutoDetect));
rdpAutoDetect* autoDetect = (rdpAutoDetect*) calloc(1, sizeof(rdpAutoDetect));
if (autoDetect)
{
ZeroMemory(autoDetect, sizeof(rdpAutoDetect));
}
return autoDetect;

View File

@ -51,10 +51,5 @@ rdpAutoDetect* autodetect_new(void);
void autodetect_free(rdpAutoDetect* autodetect);
#define AUTODETECT_TAG FREERDP_TAG("core.autodetect")
#ifdef WITH_DEBUG_AUTODETECT
#define DEBUG_AUTODETECT(fmt, ...) WLog_DBG(AUTODETECT_TAG, fmt, ## __VA_ARGS__)
#else
#define DEBUG_AUTODETECT(fmt, ...) do { } while (0)
#endif
#endif /* __AUTODETECT_H */

View File

@ -832,11 +832,15 @@ void gcc_write_client_core_data(wStream* s, rdpMcs* mcs)
RNS_UD_16BPP_SUPPORT |
RNS_UD_15BPP_SUPPORT;
connectionType = settings->ConnectionType;
earlyCapabilityFlags = RNS_UD_CS_SUPPORT_ERRINFO_PDU;
if (settings->RemoteFxCodec)
connectionType = CONNECTION_TYPE_LAN;
if (settings->NetworkAutoDetect)
settings->ConnectionType = CONNECTION_TYPE_AUTODETECT;
if (settings->RemoteFxCodec && !settings->NetworkAutoDetect)
settings->ConnectionType = CONNECTION_TYPE_LAN;
connectionType = settings->ConnectionType;
if (connectionType)
earlyCapabilityFlags |= RNS_UD_CS_VALID_CONNECTION_TYPE;

View File

@ -40,17 +40,18 @@ int rdp_recv_heartbeat_packet(rdpRdp* rdp, wStream* s)
Stream_Read_UINT8(s, count1); /* count1 (1 byte) */
Stream_Read_UINT8(s, count2); /* count2 (1 byte) */
DEBUG_HEARTBEAT("received Heartbeat PDU -> period=%u, count1=%u, count2=%u", period, count1, count2);
WLog_DBG(HEARTBEAT_TAG, "received Heartbeat PDU -> period=%u, count1=%u, count2=%u", period, count1, count2);
return 0;
}
rdpHeartbeat* heartbeat_new(void)
{
rdpHeartbeat* heartbeat = (rdpHeartbeat*)malloc(sizeof(rdpHeartbeat));
rdpHeartbeat* heartbeat = (rdpHeartbeat*) calloc(1, sizeof(rdpHeartbeat));
if (heartbeat)
{
ZeroMemory(heartbeat, sizeof(rdpHeartbeat));
}
return heartbeat;

View File

@ -40,10 +40,5 @@ rdpHeartbeat* heartbeat_new(void);
void heartbeat_free(rdpHeartbeat* heartbeat);
#define HEARTBEAT_TAG FREERDP_TAG("core.heartbeat")
#ifdef WITH_DEBUG_HEARTBEAT
#define DEBUG_HEARTBEAT(fmt, ...) WLog_DBG(HEARTBEAT_TAG, fmt, ## __VA_ARGS__)
#else
#define DEBUG_HEARTBEAT(fmt, ...) do { } while (0)
#endif
#endif /* __HEARTBEAT_H */

View File

@ -72,6 +72,8 @@ BOOL nego_security_connect(rdpNego* nego);
BOOL nego_connect(rdpNego* nego)
{
rdpSettings* settings = nego->transport->settings;
if (nego->state == NEGO_STATE_INITIAL)
{
if (nego->enabled_protocols[PROTOCOL_EXT])
@ -156,15 +158,15 @@ BOOL nego_connect(rdpNego* nego)
DEBUG_NEGO("Negotiated %s security", PROTOCOL_SECURITY_STRINGS[nego->selected_protocol]);
/* update settings with negotiated protocol security */
nego->transport->settings->RequestedProtocols = nego->requested_protocols;
nego->transport->settings->SelectedProtocol = nego->selected_protocol;
nego->transport->settings->NegotiationFlags = nego->flags;
settings->RequestedProtocols = nego->requested_protocols;
settings->SelectedProtocol = nego->selected_protocol;
settings->NegotiationFlags = nego->flags;
if (nego->selected_protocol == PROTOCOL_RDP)
{
nego->transport->settings->DisableEncryption = TRUE;
nego->transport->settings->EncryptionMethods = ENCRYPTION_METHOD_40BIT | ENCRYPTION_METHOD_56BIT | ENCRYPTION_METHOD_128BIT | ENCRYPTION_METHOD_FIPS;
nego->transport->settings->EncryptionLevel = ENCRYPTION_LEVEL_CLIENT_COMPATIBLE;
settings->DisableEncryption = TRUE;
settings->EncryptionMethods = ENCRYPTION_METHOD_40BIT | ENCRYPTION_METHOD_56BIT | ENCRYPTION_METHOD_128BIT | ENCRYPTION_METHOD_FIPS;
settings->EncryptionLevel = ENCRYPTION_LEVEL_CLIENT_COMPATIBLE;
}
/* finally connect security layer (if not already done) */
@ -174,6 +176,9 @@ BOOL nego_connect(rdpNego* nego)
return FALSE;
}
if (!(nego->flags & DYNVC_GFX_PROTOCOL_SUPPORTED))
settings->NetworkAutoDetect = FALSE;
return TRUE;
}
@ -506,10 +511,12 @@ BOOL nego_recv_response(rdpNego* nego)
wStream* s;
s = Stream_New(NULL, 1024);
if (!s)
return FALSE;
status = transport_read_pdu(nego->transport, s);
if (status < 0)
{
Stream_Free(s, TRUE);