From: Vic Lee Date: Fri, 7 Nov 2014 08:18:49 +0000 (+0800) Subject: libfreerdp-core: support continuous auto-detection. X-Git-Tag: 2.0.0-beta1+android10~742^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8eaeeebecc90e38fe2f0ac71b4cfea9b7a6b776e;p=platform%2Fupstream%2Ffreerdp.git libfreerdp-core: support continuous auto-detection. --- diff --git a/include/freerdp/autodetect.h b/include/freerdp/autodetect.h index 40bff71..3f69f92 100644 --- a/include/freerdp/autodetect.h +++ b/include/freerdp/autodetect.h @@ -43,7 +43,8 @@ struct rdp_autodetect ALIGN64 UINT32 netCharBandwidth; /* 5 */ ALIGN64 UINT32 netCharBaseRTT; /* 6 */ ALIGN64 UINT32 netCharAverageRTT; /* 7 */ - UINT64 paddingA[16 - 8]; /* 8 */ + ALIGN64 BOOL bandwidthMeasureStarted; /* 8 */ + UINT64 paddingA[16 - 9]; /* 9 */ ALIGN64 pRTTMeasureRequest RTTMeasureRequest; /* 16 */ ALIGN64 pRTTMeasureResponse RTTMeasureResponse; /* 17 */ diff --git a/libfreerdp/core/autodetect.c b/libfreerdp/core/autodetect.c index 7dca1e9..c636778 100644 --- a/libfreerdp/core/autodetect.c +++ b/libfreerdp/core/autodetect.c @@ -322,6 +322,12 @@ static BOOL autodetect_recv_bandwidth_measure_start(rdpRdp* rdp, wStream* s, AUT rdp->autodetect->bandwidthMeasureStartTime = GetTickCount(); rdp->autodetect->bandwidthMeasureByteCount = 0; + /* Continuous Auto-Detection: mark the start of the measurement */ + if (autodetectReqPdu->requestType == 0x0014) + { + rdp->autodetect->bandwidthMeasureStarted = TRUE; + } + return TRUE; } @@ -373,6 +379,12 @@ static BOOL autodetect_recv_bandwidth_measure_stop(rdpRdp* rdp, wStream* s, AUTO /* Add the payload length to the bandwidth measurement parameters */ rdp->autodetect->bandwidthMeasureByteCount += payloadLength; + /* Continuous Auto-Detection: mark the stop of the measurement */ + if (autodetectReqPdu->requestType == 0x0429) + { + rdp->autodetect->bandwidthMeasureStarted = FALSE; + } + /* Send a response the server */ responseType = autodetectReqPdu->requestType == 0x002B ? 0x0003 : 0x000B; diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 914140b..3b2bb62 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -1001,6 +1001,11 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) if (rdp->disconnect) return 0; + if (rdp->autodetect->bandwidthMeasureStarted) + { + rdp->autodetect->bandwidthMeasureByteCount += length; + } + if (rdp->settings->DisableEncryption) { if (!rdp_read_security_header(s, &securityFlags)) @@ -1096,6 +1101,11 @@ static int rdp_recv_fastpath_pdu(rdpRdp* rdp, wStream* s) return -1; } + if (rdp->autodetect->bandwidthMeasureStarted) + { + rdp->autodetect->bandwidthMeasureByteCount += length; + } + if (fastpath->encryptionFlags & FASTPATH_OUTPUT_ENCRYPTED) { UINT16 flags = (fastpath->encryptionFlags & FASTPATH_OUTPUT_SECURE_CHECKSUM) ? SEC_SECURE_CHECKSUM : 0;