2424#endif
2525
2626#include < cstdint>
27+ // #include <vector>
28+ // #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
2729
2830namespace stgw {
2931class TnetRequestFront ;
@@ -34,6 +36,7 @@ struct TnetStats {
3436 bool is_quic; // if it is quic, else it is tcp.
3537 bool is_0rtt; // Only valid if it is quic.
3638 bool is_conn_reuse; // if reuse an exist quic connection.
39+ bool is_multipath_;
3740 std::uint64_t connect_ms; // connect cost in millionseconds.
3841 std::uint64_t ttfb_ms; // first byte cost from send request in millionseconds.
3942
@@ -48,21 +51,35 @@ struct TnetStats {
4851 std::uint64_t packets_lost; // Number of packets be lost when sent data.
4952 std::uint64_t packets_received; // Total packets received
5053 std::uint64_t bytes_received; // Total bytes received including packet format.
51- std::uint64_t stream_bytes_received; // Total bytes received including duplicated data.
54+ std::uint64_t stream_bytes_sent; // Non-retransmitted bytes sent in a stream frame.
55+ std::uint64_t stream_bytes_received; // Bytes received in a stream frame.
5256 std::uint64_t dns_ms;
53- std::uint64_t cancel_duration_ms;
54- std::uint64_t shlo_duration_ms;
55- std::uint64_t preprocess_duration_ms;
57+ std::uint32_t cancel_duration_ms;
58+ std::uint32_t shlo_duration_ms;
59+ std::uint32_t preprocess_duration_ms;
60+ std::uint32_t mp_nego_ms;
61+ std::uint32_t mp_succ_ms;
62+ std::uint32_t ma_st_rcv;
63+ std::uint32_t mp_st_rcv;
64+ std::uint32_t pre_strcv1;
65+ std::uint32_t pre_strcv2;
66+ std::int32_t mp_ft_offset;
67+ std::int32_t mp_tot_ms;
68+ int stream_error;
5669 int dns_code;
70+ int error_code;
5771 bool is_default_ip;
5872 char remote_ip[64 ];
59- char conn_id[32 ];
73+ char conn_id[64 ];
6074 int engine_type; // only used if ConnectAndSend
6175 int sock_bind_type; // only used if ConnectAndSend
6276 int migration_count;
6377 int sock_avail_type;
6478 int multi_request_type;
6579 int avail_request_type;
80+ int detect_result;
81+ int persist_result;
82+ char detect_str[16 ];
6683};
6784
6885enum CongestionType {
@@ -83,6 +100,7 @@ class TNET_EXPORT TnetConfig {
83100 public:
84101 TnetConfig ();
85102 TnetConfig (const TnetConfig& c);
103+ ~TnetConfig ();
86104 // The max receive window for a whole session.
87105 // unit is bytes, default is 15 MB, max is 24 MB
88106 // The window size of session must be larger than
@@ -122,7 +140,7 @@ class TNET_EXPORT TnetConfig {
122140 // 4000 milliseconds defaultly before handshake complete.
123141 // 600 seconds defaultly after handshake.
124142 int idle_timeout_millisec_;
125- // Specify quic version, only support quic 39-46 , it is 43 defaultly.
143+ // Specify quic version, only support quic 43-80 , it is 43 defaultly.
126144 int quic_version_;
127145
128146 // default is false.
@@ -131,15 +149,31 @@ class TNET_EXPORT TnetConfig {
131149 // default is false.
132150 bool force_zero_rtt_;
133151
152+ // ConnectWithDomain get ipv6 ip if true, false defaultly.
153+ bool support_v6_;
154+
155+ bool isCongetionOptimizationEnabled_;
156+
134157 bool debug_use_1rtt_;
158+ int mp_strategy_;
159+ // The following parameters with debug_* is used for testing.
160+ // number of active connection id provided by client. if not set, default is 8.
161+ int debug_active_connection_id_num_;
162+ // number of path when multipath is enable. if not set, dafault is 2.
163+ int debug_multipath_num_;
164+ // Client IP address bind to each path, when multipath is enable.
165+ // std::vector<quic::QuicSocketAddress> debug_client_addresses_;
135166};
136167
168+
137169class TNET_EXPORT TnetRequestDelegate {
138170 public:
139171 TnetRequestDelegate () {}
140172 virtual ~TnetRequestDelegate () {}
141173 // Called when the handshake with server compeleted.
142174 virtual void OnConnect (int error_code) = 0;
175+ // Represents that network is linkable.
176+ virtual void OnNetworkLinked () {}
143177 // Called when data is available.
144178 virtual void OnDataRecv (const char * buf,
145179 const int buf_len) = 0;
@@ -176,10 +210,17 @@ class TNET_EXPORT TnetQuicRequest {
176210 // only for quic.
177211 void ConnectWithDomain (const char * host,
178212 const int port);
179-
213+
214+ void ConnAndReq (const char * host,
215+ const int port,
216+ const char * direct_ip,
217+ const char * body,
218+ const int body_len);
219+
180220 // only for quic, is fin directly
181221 void ConnectAndSend (const char * host,
182222 const int port,
223+ const char * default_ip,
183224 const char * body,
184225 const int body_len,
185226 bool fin);
@@ -192,7 +233,8 @@ class TNET_EXPORT TnetQuicRequest {
192233 Other headers can set as usual format.
193234 */
194235 void AddHeaders (const char * key,
195- const char * value);
236+ const char * value,
237+ const bool is_covered = true );
196238 // Return true if the handshake with server is compeleted.
197239 bool IsConnected ();
198240
@@ -211,6 +253,8 @@ class TNET_EXPORT TnetQuicRequest {
211253 // Get statistics for the last request.
212254 TnetStats GetTnetStates ();
213255
256+ void SetAlpn (const char * alpn_);
257+
214258 private:
215259 TnetQuicRequest ();
216260 stgw::TnetRequestFront* front_;
@@ -225,20 +269,36 @@ extern "C" {
225269// and create a new file.
226270// if delete_old_file = false, log would be append to exist file,
227271// if file not exist, then create a new file.
272+ // log_level value:
273+ // * verbose : -1
274+ // * info: 0
275+ // * warning: 1
276+ // * error: 2
277+ // * fatal: 3
228278#if defined(WIN32)
229- TNET_EXPORT void SetTquicLog (const wchar_t * filepath, bool delete_old_file);
279+ TNET_EXPORT void SetTquicLog (const wchar_t * filepath,
280+ bool delete_old_file,
281+ int log_level = 1 );
230282#else
231- TNET_EXPORT void SetTquicLog (const char * filepath, bool delete_old_file);
283+ TNET_EXPORT void SetTquicLog (const char * filepath,
284+ bool delete_old_file,
285+ int log_level = 1 );
232286#endif
233287
234- // Get tquic-sdk version, should be 1.3.9.0
288+ // Get tquic-sdk version, should be 1.4.48
235289TNET_EXPORT const char * GetTquicVersion ();
236290
237291// only for quic
238292TNET_EXPORT void TquicPreconnect (const char * domain,
239293 const char * default_ip,
240294 const int port);
241295
296+ TNET_EXPORT void TquicCleanDns ();
297+
298+
299+ // For splash ad experiment
300+ TNET_EXPORT void set_tquic_expid (int exp_id);
301+
242302#ifdef __cplusplus
243303}
244304#endif
0 commit comments