FreeRDP
include/freerdp/autodetect.h
1 
21 #ifndef FREERDP_AUTODETECT_H
22 #define FREERDP_AUTODETECT_H
23 
24 #include <freerdp/api.h>
25 #include <freerdp/types.h>
26 
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31 
32  typedef enum
33  {
34  FREERDP_AUTODETECT_STATE_INITIAL,
35  FREERDP_AUTODETECT_STATE_REQUEST,
36  FREERDP_AUTODETECT_STATE_RESPONSE,
37  FREERDP_AUTODETECT_STATE_COMPLETE,
38  FREERDP_AUTODETECT_STATE_FAIL
39  } FREERDP_AUTODETECT_STATE;
40 
41  typedef enum
42  {
43  RDP_NETCHAR_RESERVED = 0x0000U,
44  /* The baseRTT and averageRTT fields are valid */
45  RDP_NETCHAR_RESULT_TYPE_BASE_RTT_AVG_RTT = 0x0840U,
46  /* The bandwidth and averageRTT fields are valid */
47  RDP_NETCHAR_RESULT_TYPE_BW_AVG_RTT = 0x0880U,
48  /* The baseRTT, bandwidth and averageRTT fields are valid */
49  RDP_NETCHAR_RESULT_TYPE_BASE_RTT_BW_AVG_RTT = 0x08C0U
50  } RDP_NETCHAR_RESULT_TYPE;
51 
52  typedef enum
53  {
54  RDP_BW_RESULTS_RESPONSE_TYPE_CONNECTTIME = 0x0003,
55  RDP_BW_RESULTS_RESPONSE_TYPE_CONTINUOUS = 0x000B
56  } RDP_BW_RESULTS_RESPONSE_TYPE;
57 
58  typedef struct rdp_autodetect rdpAutoDetect;
59  typedef struct rdp_network_characteristics_result rdpNetworkCharacteristicsResult;
60 
61  typedef BOOL (*pRTTMeasureRequest)(rdpAutoDetect* autodetect, RDP_TRANSPORT_TYPE transport,
62  UINT16 sequenceNumber);
63  typedef BOOL (*pRTTMeasureResponse)(rdpAutoDetect* autodetect, RDP_TRANSPORT_TYPE transport,
64  UINT16 sequenceNumber);
65  typedef BOOL (*pBandwidthMeasureStart)(rdpAutoDetect* autodetect, RDP_TRANSPORT_TYPE transport,
66  UINT16 sequenceNumber);
67  typedef BOOL (*pBandwidthMeasurePayload)(rdpAutoDetect* autodetect,
68  RDP_TRANSPORT_TYPE transport, UINT16 sequenceNumber,
69  UINT16 payloadLength);
70  typedef BOOL (*pBandwidthMeasureStop)(rdpAutoDetect* autodetect, RDP_TRANSPORT_TYPE transport,
71  UINT16 sequenceNumber, UINT16 payloadLength);
72  typedef BOOL (*pBandwidthMeasureResults)(rdpAutoDetect* autodetect,
73  RDP_TRANSPORT_TYPE transport, UINT16 sequenceNumber,
74  UINT16 responseType, UINT32 timeDelta,
75  UINT32 byteCount);
76  typedef BOOL (*pNetworkCharacteristicsResult)(rdpAutoDetect* autodetect,
77  RDP_TRANSPORT_TYPE transport,
78  UINT16 sequenceNumber,
79  const rdpNetworkCharacteristicsResult* result);
80  typedef BOOL (*pClientBandwidthMeasureResult)(rdpAutoDetect* autodetect,
81  RDP_TRANSPORT_TYPE transport, UINT16 responseType,
82  UINT16 sequenceNumber, UINT32 timeDelta,
83  UINT32 byteCount);
84  typedef BOOL (*pNetworkCharacteristicsSync)(rdpAutoDetect* autodetect,
85  RDP_TRANSPORT_TYPE transport, UINT16 sequenceNumber,
86  UINT32 bandwidth, UINT32 rtt);
87  typedef BOOL (*pRxTxReceived)(rdpAutoDetect* autodetect, RDP_TRANSPORT_TYPE transport,
88  UINT16 requestType, UINT16 sequenceNumber);
89  typedef FREERDP_AUTODETECT_STATE (*pOnConnectTimeAutoDetect)(rdpAutoDetect* autodetect);
90 
92  {
93  /* Specifies, which fields are valid */
94  RDP_NETCHAR_RESULT_TYPE type;
95 
96  /* Lowest detected round-trip time in milliseconds. */
97  UINT32 baseRTT;
98  /* Current average round-trip time in milliseconds. */
99  UINT32 averageRTT;
100  /* Current bandwidth in kilobits per second. */
101  UINT32 bandwidth;
102  };
103 
105  {
106  ALIGN64 rdpContext* context; /* 0 */
107  /* RTT measurement */
108  ALIGN64 UINT64 rttMeasureStartTime; /* 1 */
109  /* Bandwidth measurement */
110  ALIGN64 UINT64 bandwidthMeasureStartTime; /* 2 */
111  ALIGN64 UINT64 bandwidthMeasureTimeDelta; /* 3 */
112  ALIGN64 UINT32 bandwidthMeasureByteCount; /* 4 */
113  /* Network characteristics (as reported by server) */
114  ALIGN64 UINT32 netCharBandwidth; /* 5 */
115  ALIGN64 UINT32 netCharBaseRTT; /* 6 */
116  ALIGN64 UINT32 netCharAverageRTT; /* 7 */
117  ALIGN64 BOOL bandwidthMeasureStarted; /* 8 */
118  ALIGN64 FREERDP_AUTODETECT_STATE state; /* 9 */
119  ALIGN64 void* custom; /* 10 */
120  ALIGN64 wLog* log; /* 11 */
121  UINT64 paddingA[16 - 12]; /* 12 */
122 
123  ALIGN64 pRTTMeasureRequest RTTMeasureRequest; /* 16 */
124  ALIGN64 pRTTMeasureResponse RTTMeasureResponse; /* 17 */
125  ALIGN64 pBandwidthMeasureStart BandwidthMeasureStart; /* 18 */
126  ALIGN64 pBandwidthMeasurePayload BandwidthMeasurePayload; /* 19 */
127  ALIGN64 pBandwidthMeasureStop BandwidthMeasureStop; /* 20 */
128  ALIGN64 pBandwidthMeasureResults BandwidthMeasureResults; /* 21 */
129  ALIGN64 pNetworkCharacteristicsResult NetworkCharacteristicsResult; /* 22 */
130  ALIGN64 pClientBandwidthMeasureResult ClientBandwidthMeasureResult; /* 23 */
131  ALIGN64 pNetworkCharacteristicsSync NetworkCharacteristicsSync; /* 24 */
132  ALIGN64 pRxTxReceived RequestReceived; /* 25 */
133  ALIGN64 pRxTxReceived ResponseReceived; /* 26 */
134  ALIGN64 pOnConnectTimeAutoDetect OnConnectTimeAutoDetectBegin; /* 27 */
135  ALIGN64 pOnConnectTimeAutoDetect OnConnectTimeAutoDetectProgress; /* 28 */
136  UINT64 paddingB[32 - 29]; /* 29 */
137  };
138  FREERDP_API rdpAutoDetect* autodetect_get(rdpContext* context);
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* FREERDP_AUTODETECT_H */