rwebtransport 0.2.2 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +523 -140
- package/Cargo.toml +5 -5
- package/README.md +8 -4
- package/crates/echo-server/src/bin/gen-test-cert.rs +1 -1
- package/crates/native/Cargo.toml +2 -0
- package/crates/native/src/config.rs +69 -8
- package/crates/native/src/driver.rs +253 -90
- package/crates/native/src/lib.rs +80 -57
- package/crates/native/src/parser_memory.rs +203 -0
- package/crates/native/src/server.rs +215 -183
- package/crates/native/src/session.rs +1341 -243
- package/crates/native/src/test_support.rs +119 -0
- package/crates/wtcore/Cargo.toml +1 -0
- package/crates/wtcore/src/h3.rs +250 -46
- package/dist/index.js +218 -75
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +214 -69
- package/dist/index.mjs.map +7 -1
- package/dist/native.d.ts +10 -4
- package/dist/server.d.ts +1 -0
- package/package.json +84 -78
- package/prebuilds/darwin-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-x64/rwebtransport.node +0 -0
- package/prebuilds/win32-x64/rwebtransport.node +0 -0
- package/scripts/build-linux-prebuilt.sh +46 -0
- package/scripts/build-ts.js +41 -0
- package/scripts/build.js +10 -3
- package/vendor/quiche/AGENTS.md +10 -0
- package/vendor/quiche/Cargo.lock +239 -248
- package/vendor/quiche/Cargo.toml +23 -10
- package/vendor/quiche/examples/Makefile +4 -4
- package/vendor/quiche/examples/client.rs +10 -28
- package/vendor/quiche/examples/http3-client.rs +20 -34
- package/vendor/quiche/examples/http3-server.rs +47 -78
- package/vendor/quiche/examples/server.rs +19 -49
- package/vendor/quiche/include/quiche.h +35 -4
- package/vendor/quiche/src/build.rs +17 -0
- package/vendor/quiche/src/cid.rs +129 -61
- package/vendor/quiche/src/crypto/boringssl.rs +98 -86
- package/vendor/quiche/src/crypto/mod.rs +64 -77
- package/vendor/quiche/src/dgram.rs +2 -3
- package/vendor/quiche/src/error.rs +22 -20
- package/vendor/quiche/src/ffi.rs +558 -280
- package/vendor/quiche/src/flowcontrol.rs +0 -7
- package/vendor/quiche/src/frame.rs +134 -135
- package/vendor/quiche/src/h3/ffi.rs +73 -60
- package/vendor/quiche/src/h3/frame.rs +70 -90
- package/vendor/quiche/src/h3/mod.rs +1024 -593
- package/vendor/quiche/src/h3/qpack/decoder.rs +248 -34
- package/vendor/quiche/src/h3/qpack/dynamic_table.rs +859 -0
- package/vendor/quiche/src/h3/qpack/encoder.rs +14 -17
- package/vendor/quiche/src/h3/qpack/mod.rs +48 -0
- package/vendor/quiche/src/h3/qpack/static_table.rs +86 -73
- package/vendor/quiche/src/h3/stream.rs +1009 -194
- package/vendor/quiche/src/lib.rs +1361 -1195
- package/vendor/quiche/src/minmax.rs +2 -6
- package/vendor/quiche/src/packet.rs +420 -552
- package/vendor/quiche/src/path.rs +202 -72
- package/vendor/quiche/src/pmtud.rs +18 -16
- package/vendor/quiche/src/ranges.rs +184 -82
- package/vendor/quiche/src/recovery/AGENTS.md +5 -2
- package/vendor/quiche/src/recovery/bandwidth.rs +59 -40
- package/vendor/quiche/src/recovery/bytes_in_flight.rs +2 -2
- package/vendor/quiche/src/recovery/congestion/cubic.rs +38 -47
- package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +54 -60
- package/vendor/quiche/src/recovery/congestion/hystart.rs +6 -10
- package/vendor/quiche/src/recovery/congestion/mod.rs +110 -42
- package/vendor/quiche/src/recovery/congestion/prr.rs +4 -1
- package/vendor/quiche/src/recovery/congestion/recovery.rs +91 -95
- package/vendor/quiche/src/recovery/congestion/reno.rs +17 -12
- package/vendor/quiche/src/recovery/congestion/test_sender.rs +8 -27
- package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +159 -247
- package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +9 -14
- package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +18 -15
- package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +43 -28
- package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +349 -76
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +147 -195
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +29 -27
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min.rs +180 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min_tests.rs +221 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm.rs +395 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm_tests.rs +473 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/mod.rs +175 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +33 -26
- package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +107 -60
- package/vendor/quiche/src/recovery/gcongestion/mod.rs +64 -11
- package/vendor/quiche/src/recovery/gcongestion/pacer.rs +34 -25
- package/vendor/quiche/src/recovery/gcongestion/recovery.rs +81 -86
- package/vendor/quiche/src/recovery/mod.rs +414 -173
- package/vendor/quiche/src/recovery/rtt.rs +8 -5
- package/vendor/quiche/src/stream/mod.rs +864 -133
- package/vendor/quiche/src/stream/recv_buf.rs +476 -172
- package/vendor/quiche/src/stream/send_buf.rs +343 -81
- package/vendor/quiche/src/test_utils.rs +78 -64
- package/vendor/quiche/src/tests.rs +2559 -1335
- package/vendor/quiche/src/tls/boringssl.rs +60 -63
- package/vendor/quiche/src/tls/mod.rs +146 -193
- package/vendor/quiche/src/transport_params.rs +87 -103
package/vendor/quiche/src/ffi.rs
CHANGED
|
@@ -33,6 +33,7 @@ use std::net::Ipv4Addr;
|
|
|
33
33
|
use std::net::Ipv6Addr;
|
|
34
34
|
use std::net::SocketAddrV4;
|
|
35
35
|
use std::net::SocketAddrV6;
|
|
36
|
+
use std::num::NonZeroUsize;
|
|
36
37
|
|
|
37
38
|
#[cfg(unix)]
|
|
38
39
|
use std::os::unix::io::FromRawFd;
|
|
@@ -125,7 +126,8 @@ impl log::Log for Logger {
|
|
|
125
126
|
|
|
126
127
|
#[no_mangle]
|
|
127
128
|
pub extern "C" fn quiche_enable_debug_logging(
|
|
128
|
-
cb: extern "C" fn(line: *const u8, argp: *mut c_void),
|
|
129
|
+
cb: extern "C" fn(line: *const u8, argp: *mut c_void),
|
|
130
|
+
argp: *mut c_void,
|
|
129
131
|
) -> c_int {
|
|
130
132
|
let argp = atomic::AtomicPtr::new(argp);
|
|
131
133
|
let logger = Box::new(Logger { cb, argp });
|
|
@@ -150,7 +152,8 @@ pub extern "C" fn quiche_config_new(version: u32) -> *mut Config {
|
|
|
150
152
|
|
|
151
153
|
#[no_mangle]
|
|
152
154
|
pub extern "C" fn quiche_config_load_cert_chain_from_pem_file(
|
|
153
|
-
config: &mut Config,
|
|
155
|
+
config: &mut Config,
|
|
156
|
+
path: *const c_char,
|
|
154
157
|
) -> c_int {
|
|
155
158
|
let path = unsafe { ffi::CStr::from_ptr(path).to_str().unwrap() };
|
|
156
159
|
|
|
@@ -163,7 +166,8 @@ pub extern "C" fn quiche_config_load_cert_chain_from_pem_file(
|
|
|
163
166
|
|
|
164
167
|
#[no_mangle]
|
|
165
168
|
pub extern "C" fn quiche_config_load_priv_key_from_pem_file(
|
|
166
|
-
config: &mut Config,
|
|
169
|
+
config: &mut Config,
|
|
170
|
+
path: *const c_char,
|
|
167
171
|
) -> c_int {
|
|
168
172
|
let path = unsafe { ffi::CStr::from_ptr(path).to_str().unwrap() };
|
|
169
173
|
|
|
@@ -176,7 +180,8 @@ pub extern "C" fn quiche_config_load_priv_key_from_pem_file(
|
|
|
176
180
|
|
|
177
181
|
#[no_mangle]
|
|
178
182
|
pub extern "C" fn quiche_config_load_verify_locations_from_file(
|
|
179
|
-
config: &mut Config,
|
|
183
|
+
config: &mut Config,
|
|
184
|
+
path: *const c_char,
|
|
180
185
|
) -> c_int {
|
|
181
186
|
let path = unsafe { ffi::CStr::from_ptr(path).to_str().unwrap() };
|
|
182
187
|
|
|
@@ -189,7 +194,8 @@ pub extern "C" fn quiche_config_load_verify_locations_from_file(
|
|
|
189
194
|
|
|
190
195
|
#[no_mangle]
|
|
191
196
|
pub extern "C" fn quiche_config_load_verify_locations_from_directory(
|
|
192
|
-
config: &mut Config,
|
|
197
|
+
config: &mut Config,
|
|
198
|
+
path: *const c_char,
|
|
193
199
|
) -> c_int {
|
|
194
200
|
let path = unsafe { ffi::CStr::from_ptr(path).to_str().unwrap() };
|
|
195
201
|
|
|
@@ -200,6 +206,20 @@ pub extern "C" fn quiche_config_load_verify_locations_from_directory(
|
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
208
|
|
|
209
|
+
#[no_mangle]
|
|
210
|
+
pub extern "C" fn quiche_config_set_curves_list(
|
|
211
|
+
config: &mut Config,
|
|
212
|
+
curves: *const c_char,
|
|
213
|
+
) -> c_int {
|
|
214
|
+
let curves = unsafe { ffi::CStr::from_ptr(curves).to_str().unwrap() };
|
|
215
|
+
|
|
216
|
+
match config.set_curves_list(curves) {
|
|
217
|
+
Ok(_) => 0,
|
|
218
|
+
|
|
219
|
+
Err(e) => e.to_c() as c_int,
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
203
223
|
#[no_mangle]
|
|
204
224
|
pub extern "C" fn quiche_config_verify_peer(config: &mut Config, v: bool) {
|
|
205
225
|
config.verify_peer(v);
|
|
@@ -216,9 +236,7 @@ pub extern "C" fn quiche_config_discover_pmtu(config: &mut Config, v: bool) {
|
|
|
216
236
|
}
|
|
217
237
|
|
|
218
238
|
#[no_mangle]
|
|
219
|
-
pub extern "C" fn quiche_config_set_pmtud_max_probes(
|
|
220
|
-
config: &mut Config, max_probes: u8,
|
|
221
|
-
) {
|
|
239
|
+
pub extern "C" fn quiche_config_set_pmtud_max_probes(config: &mut Config, max_probes: u8) {
|
|
222
240
|
config.set_pmtud_max_probes(max_probes);
|
|
223
241
|
}
|
|
224
242
|
|
|
@@ -236,7 +254,9 @@ pub extern "C" fn quiche_config_enable_early_data(config: &mut Config) {
|
|
|
236
254
|
/// Corresponds to the `Config::set_application_protos_wire_format` Rust
|
|
237
255
|
/// function.
|
|
238
256
|
pub extern "C" fn quiche_config_set_application_protos(
|
|
239
|
-
config: &mut Config,
|
|
257
|
+
config: &mut Config,
|
|
258
|
+
protos: *const u8,
|
|
259
|
+
protos_len: size_t,
|
|
240
260
|
) -> c_int {
|
|
241
261
|
let protos = unsafe { slice::from_raw_parts(protos, protos_len) };
|
|
242
262
|
|
|
@@ -248,72 +268,58 @@ pub extern "C" fn quiche_config_set_application_protos(
|
|
|
248
268
|
}
|
|
249
269
|
|
|
250
270
|
#[no_mangle]
|
|
251
|
-
pub extern "C" fn quiche_config_set_max_amplification_factor(
|
|
252
|
-
config: &mut Config, v: usize,
|
|
253
|
-
) {
|
|
271
|
+
pub extern "C" fn quiche_config_set_max_amplification_factor(config: &mut Config, v: usize) {
|
|
254
272
|
config.set_max_amplification_factor(v);
|
|
255
273
|
}
|
|
256
274
|
|
|
257
275
|
#[no_mangle]
|
|
258
|
-
pub extern "C" fn quiche_config_set_max_idle_timeout(
|
|
259
|
-
config: &mut Config, v: u64,
|
|
260
|
-
) {
|
|
276
|
+
pub extern "C" fn quiche_config_set_max_idle_timeout(config: &mut Config, v: u64) {
|
|
261
277
|
config.set_max_idle_timeout(v);
|
|
262
278
|
}
|
|
263
279
|
|
|
264
280
|
#[no_mangle]
|
|
265
|
-
pub extern "C" fn quiche_config_set_max_recv_udp_payload_size(
|
|
266
|
-
config: &mut Config, v: size_t,
|
|
267
|
-
) {
|
|
281
|
+
pub extern "C" fn quiche_config_set_max_recv_udp_payload_size(config: &mut Config, v: size_t) {
|
|
268
282
|
config.set_max_recv_udp_payload_size(v);
|
|
269
283
|
}
|
|
270
284
|
|
|
271
285
|
#[no_mangle]
|
|
272
|
-
pub extern "C" fn quiche_config_set_initial_max_data(
|
|
273
|
-
config: &mut Config, v: u64,
|
|
274
|
-
) {
|
|
286
|
+
pub extern "C" fn quiche_config_set_initial_max_data(config: &mut Config, v: u64) {
|
|
275
287
|
config.set_initial_max_data(v);
|
|
276
288
|
}
|
|
277
289
|
|
|
278
290
|
#[no_mangle]
|
|
279
291
|
pub extern "C" fn quiche_config_set_initial_max_stream_data_bidi_local(
|
|
280
|
-
config: &mut Config,
|
|
292
|
+
config: &mut Config,
|
|
293
|
+
v: u64,
|
|
281
294
|
) {
|
|
282
295
|
config.set_initial_max_stream_data_bidi_local(v);
|
|
283
296
|
}
|
|
284
297
|
|
|
285
298
|
#[no_mangle]
|
|
286
299
|
pub extern "C" fn quiche_config_set_initial_max_stream_data_bidi_remote(
|
|
287
|
-
config: &mut Config,
|
|
300
|
+
config: &mut Config,
|
|
301
|
+
v: u64,
|
|
288
302
|
) {
|
|
289
303
|
config.set_initial_max_stream_data_bidi_remote(v);
|
|
290
304
|
}
|
|
291
305
|
|
|
292
306
|
#[no_mangle]
|
|
293
|
-
pub extern "C" fn quiche_config_set_initial_max_stream_data_uni(
|
|
294
|
-
config: &mut Config, v: u64,
|
|
295
|
-
) {
|
|
307
|
+
pub extern "C" fn quiche_config_set_initial_max_stream_data_uni(config: &mut Config, v: u64) {
|
|
296
308
|
config.set_initial_max_stream_data_uni(v);
|
|
297
309
|
}
|
|
298
310
|
|
|
299
311
|
#[no_mangle]
|
|
300
|
-
pub extern "C" fn quiche_config_set_initial_max_streams_bidi(
|
|
301
|
-
config: &mut Config, v: u64,
|
|
302
|
-
) {
|
|
312
|
+
pub extern "C" fn quiche_config_set_initial_max_streams_bidi(config: &mut Config, v: u64) {
|
|
303
313
|
config.set_initial_max_streams_bidi(v);
|
|
304
314
|
}
|
|
305
315
|
|
|
306
316
|
#[no_mangle]
|
|
307
|
-
pub extern "C" fn quiche_config_set_initial_max_streams_uni(
|
|
308
|
-
config: &mut Config, v: u64,
|
|
309
|
-
) {
|
|
317
|
+
pub extern "C" fn quiche_config_set_initial_max_streams_uni(config: &mut Config, v: u64) {
|
|
310
318
|
config.set_initial_max_streams_uni(v);
|
|
311
319
|
}
|
|
312
320
|
|
|
313
321
|
#[no_mangle]
|
|
314
|
-
pub extern "C" fn quiche_config_set_ack_delay_exponent(
|
|
315
|
-
config: &mut Config, v: u64,
|
|
316
|
-
) {
|
|
322
|
+
pub extern "C" fn quiche_config_set_ack_delay_exponent(config: &mut Config, v: u64) {
|
|
317
323
|
config.set_ack_delay_exponent(v);
|
|
318
324
|
}
|
|
319
325
|
|
|
@@ -323,15 +329,14 @@ pub extern "C" fn quiche_config_set_max_ack_delay(config: &mut Config, v: u64) {
|
|
|
323
329
|
}
|
|
324
330
|
|
|
325
331
|
#[no_mangle]
|
|
326
|
-
pub extern "C" fn quiche_config_set_disable_active_migration(
|
|
327
|
-
config: &mut Config, v: bool,
|
|
328
|
-
) {
|
|
332
|
+
pub extern "C" fn quiche_config_set_disable_active_migration(config: &mut Config, v: bool) {
|
|
329
333
|
config.set_disable_active_migration(v);
|
|
330
334
|
}
|
|
331
335
|
|
|
332
336
|
#[no_mangle]
|
|
333
337
|
pub extern "C" fn quiche_config_set_cc_algorithm_name(
|
|
334
|
-
config: &mut Config,
|
|
338
|
+
config: &mut Config,
|
|
339
|
+
name: *const c_char,
|
|
335
340
|
) -> c_int {
|
|
336
341
|
let name = unsafe { ffi::CStr::from_ptr(name).to_str().unwrap() };
|
|
337
342
|
match config.set_cc_algorithm_name(name) {
|
|
@@ -343,18 +348,40 @@ pub extern "C" fn quiche_config_set_cc_algorithm_name(
|
|
|
343
348
|
|
|
344
349
|
#[no_mangle]
|
|
345
350
|
pub extern "C" fn quiche_config_set_cc_algorithm(
|
|
346
|
-
config: &mut Config,
|
|
351
|
+
config: &mut Config,
|
|
352
|
+
algo: CongestionControlAlgorithm,
|
|
347
353
|
) {
|
|
348
354
|
config.set_cc_algorithm(algo);
|
|
349
355
|
}
|
|
350
356
|
|
|
351
357
|
#[no_mangle]
|
|
352
358
|
pub extern "C" fn quiche_config_set_initial_congestion_window_packets(
|
|
353
|
-
config: &mut Config,
|
|
359
|
+
config: &mut Config,
|
|
360
|
+
packets: size_t,
|
|
354
361
|
) {
|
|
355
362
|
config.set_initial_congestion_window_packets(packets);
|
|
356
363
|
}
|
|
357
364
|
|
|
365
|
+
/// Sets the fixed congestion window in bytes for `congestion_window_unchecked`.
|
|
366
|
+
///
|
|
367
|
+
/// Defaults to `usize::MAX`. Other congestion control algorithms are unchanged.
|
|
368
|
+
/// Recovery probes can bypass the fixed window.
|
|
369
|
+
#[no_mangle]
|
|
370
|
+
pub extern "C" fn quiche_config_set_unchecked_congestion_window(
|
|
371
|
+
config: &mut Config,
|
|
372
|
+
window: size_t,
|
|
373
|
+
) {
|
|
374
|
+
config.set_unchecked_congestion_window(window);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
#[no_mangle]
|
|
378
|
+
pub extern "C" fn quiche_config_set_max_outstanding_sent_packets(
|
|
379
|
+
config: &mut Config,
|
|
380
|
+
max_packets: size_t,
|
|
381
|
+
) {
|
|
382
|
+
config.set_max_outstanding_sent_packets(NonZeroUsize::new(max_packets));
|
|
383
|
+
}
|
|
384
|
+
|
|
358
385
|
#[no_mangle]
|
|
359
386
|
pub extern "C" fn quiche_config_enable_hystart(config: &mut Config, v: bool) {
|
|
360
387
|
config.enable_hystart(v);
|
|
@@ -366,17 +393,16 @@ pub extern "C" fn quiche_config_enable_pacing(config: &mut Config, v: bool) {
|
|
|
366
393
|
}
|
|
367
394
|
|
|
368
395
|
#[no_mangle]
|
|
369
|
-
pub extern "C" fn quiche_config_set_enable_cubic_idle_restart_fix(
|
|
370
|
-
config: &mut Config, v: bool,
|
|
371
|
-
) {
|
|
396
|
+
pub extern "C" fn quiche_config_set_enable_cubic_idle_restart_fix(config: &mut Config, v: bool) {
|
|
372
397
|
config.set_enable_cubic_idle_restart_fix(v);
|
|
373
398
|
}
|
|
374
399
|
|
|
400
|
+
/// Deprecated: this is now always enabled and this function is a no-op.
|
|
375
401
|
#[no_mangle]
|
|
376
402
|
pub extern "C" fn quiche_config_set_use_initial_max_data_as_flow_control_win(
|
|
377
|
-
|
|
403
|
+
_config: &mut Config,
|
|
404
|
+
_v: bool,
|
|
378
405
|
) {
|
|
379
|
-
config.set_use_initial_max_data_as_flow_control_win(v);
|
|
380
406
|
}
|
|
381
407
|
|
|
382
408
|
#[no_mangle]
|
|
@@ -386,44 +412,36 @@ pub extern "C" fn quiche_config_set_max_pacing_rate(config: &mut Config, v: u64)
|
|
|
386
412
|
|
|
387
413
|
#[no_mangle]
|
|
388
414
|
pub extern "C" fn quiche_config_enable_dgram(
|
|
389
|
-
config: &mut Config,
|
|
415
|
+
config: &mut Config,
|
|
416
|
+
enabled: bool,
|
|
417
|
+
recv_queue_len: size_t,
|
|
390
418
|
send_queue_len: size_t,
|
|
391
419
|
) {
|
|
392
420
|
config.enable_dgram(enabled, recv_queue_len, send_queue_len);
|
|
393
421
|
}
|
|
394
422
|
|
|
395
423
|
#[no_mangle]
|
|
396
|
-
pub extern "C" fn quiche_config_set_max_send_udp_payload_size(
|
|
397
|
-
config: &mut Config, v: size_t,
|
|
398
|
-
) {
|
|
424
|
+
pub extern "C" fn quiche_config_set_max_send_udp_payload_size(config: &mut Config, v: size_t) {
|
|
399
425
|
config.set_max_send_udp_payload_size(v);
|
|
400
426
|
}
|
|
401
427
|
|
|
402
428
|
#[no_mangle]
|
|
403
|
-
pub extern "C" fn quiche_config_set_max_connection_window(
|
|
404
|
-
config: &mut Config, v: u64,
|
|
405
|
-
) {
|
|
429
|
+
pub extern "C" fn quiche_config_set_max_connection_window(config: &mut Config, v: u64) {
|
|
406
430
|
config.set_max_connection_window(v);
|
|
407
431
|
}
|
|
408
432
|
|
|
409
433
|
#[no_mangle]
|
|
410
|
-
pub extern "C" fn quiche_config_set_max_stream_window(
|
|
411
|
-
config: &mut Config, v: u64,
|
|
412
|
-
) {
|
|
434
|
+
pub extern "C" fn quiche_config_set_max_stream_window(config: &mut Config, v: u64) {
|
|
413
435
|
config.set_max_stream_window(v);
|
|
414
436
|
}
|
|
415
437
|
|
|
416
438
|
#[no_mangle]
|
|
417
|
-
pub extern "C" fn quiche_config_set_active_connection_id_limit(
|
|
418
|
-
config: &mut Config, v: u64,
|
|
419
|
-
) {
|
|
439
|
+
pub extern "C" fn quiche_config_set_active_connection_id_limit(config: &mut Config, v: u64) {
|
|
420
440
|
config.set_active_connection_id_limit(v);
|
|
421
441
|
}
|
|
422
442
|
|
|
423
443
|
#[no_mangle]
|
|
424
|
-
pub extern "C" fn quiche_config_set_stateless_reset_token(
|
|
425
|
-
config: &mut Config, v: *const u8,
|
|
426
|
-
) {
|
|
444
|
+
pub extern "C" fn quiche_config_set_stateless_reset_token(config: &mut Config, v: *const u8) {
|
|
427
445
|
let reset_token = unsafe { slice::from_raw_parts(v, 16) };
|
|
428
446
|
let reset_token = match reset_token.try_into() {
|
|
429
447
|
Ok(rt) => rt,
|
|
@@ -434,15 +452,15 @@ pub extern "C" fn quiche_config_set_stateless_reset_token(
|
|
|
434
452
|
}
|
|
435
453
|
|
|
436
454
|
#[no_mangle]
|
|
437
|
-
pub extern "C" fn quiche_config_set_disable_dcid_reuse(
|
|
438
|
-
config: &mut Config, v: bool,
|
|
439
|
-
) {
|
|
455
|
+
pub extern "C" fn quiche_config_set_disable_dcid_reuse(config: &mut Config, v: bool) {
|
|
440
456
|
config.set_disable_dcid_reuse(v);
|
|
441
457
|
}
|
|
442
458
|
|
|
443
459
|
#[no_mangle]
|
|
444
460
|
pub extern "C" fn quiche_config_set_ticket_key(
|
|
445
|
-
config: &mut Config,
|
|
461
|
+
config: &mut Config,
|
|
462
|
+
key: *const u8,
|
|
463
|
+
key_len: size_t,
|
|
446
464
|
) -> c_int {
|
|
447
465
|
let key = unsafe { slice::from_raw_parts(key, key_len) };
|
|
448
466
|
|
|
@@ -462,9 +480,17 @@ pub extern "C" fn quiche_config_free(config: *mut Config) {
|
|
|
462
480
|
|
|
463
481
|
#[no_mangle]
|
|
464
482
|
pub extern "C" fn quiche_header_info(
|
|
465
|
-
buf: *mut u8,
|
|
466
|
-
|
|
467
|
-
|
|
483
|
+
buf: *mut u8,
|
|
484
|
+
buf_len: size_t,
|
|
485
|
+
dcil: size_t,
|
|
486
|
+
version: *mut u32,
|
|
487
|
+
ty: *mut u8,
|
|
488
|
+
scid: *mut u8,
|
|
489
|
+
scid_len: *mut size_t,
|
|
490
|
+
dcid: *mut u8,
|
|
491
|
+
dcid_len: *mut size_t,
|
|
492
|
+
token: *mut u8,
|
|
493
|
+
token_len: *mut size_t,
|
|
468
494
|
) -> c_int {
|
|
469
495
|
let buf = unsafe { slice::from_raw_parts_mut(buf, buf_len) };
|
|
470
496
|
let hdr = match Header::from_slice(buf, dcil) {
|
|
@@ -516,7 +542,7 @@ pub extern "C" fn quiche_header_info(
|
|
|
516
542
|
token.copy_from_slice(&tok);
|
|
517
543
|
|
|
518
544
|
*token_len = tok.len();
|
|
519
|
-
}
|
|
545
|
+
}
|
|
520
546
|
|
|
521
547
|
None => *token_len = 0,
|
|
522
548
|
}
|
|
@@ -527,8 +553,14 @@ pub extern "C" fn quiche_header_info(
|
|
|
527
553
|
|
|
528
554
|
#[no_mangle]
|
|
529
555
|
pub extern "C" fn quiche_accept(
|
|
530
|
-
scid: *const u8,
|
|
531
|
-
|
|
556
|
+
scid: *const u8,
|
|
557
|
+
scid_len: size_t,
|
|
558
|
+
odcid: *const u8,
|
|
559
|
+
odcid_len: size_t,
|
|
560
|
+
local: &sockaddr,
|
|
561
|
+
local_len: socklen_t,
|
|
562
|
+
peer: &sockaddr,
|
|
563
|
+
peer_len: socklen_t,
|
|
532
564
|
config: &mut Config,
|
|
533
565
|
) -> *mut Connection {
|
|
534
566
|
let scid = unsafe { slice::from_raw_parts(scid, scid_len) };
|
|
@@ -554,8 +586,13 @@ pub extern "C" fn quiche_accept(
|
|
|
554
586
|
|
|
555
587
|
#[no_mangle]
|
|
556
588
|
pub extern "C" fn quiche_connect(
|
|
557
|
-
server_name: *const c_char,
|
|
558
|
-
|
|
589
|
+
server_name: *const c_char,
|
|
590
|
+
scid: *const u8,
|
|
591
|
+
scid_len: size_t,
|
|
592
|
+
local: &sockaddr,
|
|
593
|
+
local_len: socklen_t,
|
|
594
|
+
peer: &sockaddr,
|
|
595
|
+
peer_len: socklen_t,
|
|
559
596
|
config: &mut Config,
|
|
560
597
|
) -> *mut Connection {
|
|
561
598
|
let server_name = if server_name.is_null() {
|
|
@@ -579,8 +616,12 @@ pub extern "C" fn quiche_connect(
|
|
|
579
616
|
|
|
580
617
|
#[no_mangle]
|
|
581
618
|
pub extern "C" fn quiche_negotiate_version(
|
|
582
|
-
scid: *const u8,
|
|
583
|
-
|
|
619
|
+
scid: *const u8,
|
|
620
|
+
scid_len: size_t,
|
|
621
|
+
dcid: *const u8,
|
|
622
|
+
dcid_len: size_t,
|
|
623
|
+
out: *mut u8,
|
|
624
|
+
out_len: size_t,
|
|
584
625
|
) -> ssize_t {
|
|
585
626
|
let scid = unsafe { slice::from_raw_parts(scid, scid_len) };
|
|
586
627
|
let scid = ConnectionId::from_ref(scid);
|
|
@@ -604,9 +645,17 @@ pub extern "C" fn quiche_version_is_supported(version: u32) -> bool {
|
|
|
604
645
|
|
|
605
646
|
#[no_mangle]
|
|
606
647
|
pub extern "C" fn quiche_retry(
|
|
607
|
-
scid: *const u8,
|
|
608
|
-
|
|
609
|
-
|
|
648
|
+
scid: *const u8,
|
|
649
|
+
scid_len: size_t,
|
|
650
|
+
dcid: *const u8,
|
|
651
|
+
dcid_len: size_t,
|
|
652
|
+
new_scid: *const u8,
|
|
653
|
+
new_scid_len: size_t,
|
|
654
|
+
token: *const u8,
|
|
655
|
+
token_len: size_t,
|
|
656
|
+
version: u32,
|
|
657
|
+
out: *mut u8,
|
|
658
|
+
out_len: size_t,
|
|
610
659
|
) -> ssize_t {
|
|
611
660
|
let scid = unsafe { slice::from_raw_parts(scid, scid_len) };
|
|
612
661
|
let scid = ConnectionId::from_ref(scid);
|
|
@@ -630,9 +679,16 @@ pub extern "C" fn quiche_retry(
|
|
|
630
679
|
#[no_mangle]
|
|
631
680
|
#[cfg(feature = "custom-client-dcid")]
|
|
632
681
|
pub extern "C" fn quiche_conn_new_with_tls_and_client_dcid(
|
|
633
|
-
scid: *const u8,
|
|
634
|
-
|
|
635
|
-
|
|
682
|
+
scid: *const u8,
|
|
683
|
+
scid_len: size_t,
|
|
684
|
+
dcid: *const u8,
|
|
685
|
+
dcid_len: size_t,
|
|
686
|
+
local: &sockaddr,
|
|
687
|
+
local_len: socklen_t,
|
|
688
|
+
peer: &sockaddr,
|
|
689
|
+
peer_len: socklen_t,
|
|
690
|
+
config: &Config,
|
|
691
|
+
ssl: *mut c_void,
|
|
636
692
|
) -> *mut Connection {
|
|
637
693
|
{
|
|
638
694
|
let scid = unsafe { slice::from_raw_parts(scid, scid_len) };
|
|
@@ -649,7 +705,11 @@ pub extern "C" fn quiche_conn_new_with_tls_and_client_dcid(
|
|
|
649
705
|
let local = std_addr_from_c(local, local_len);
|
|
650
706
|
let peer = std_addr_from_c(peer, peer_len);
|
|
651
707
|
|
|
652
|
-
let tls = unsafe { tls::Handshake::from_ptr(ssl) }
|
|
708
|
+
let tls = match unsafe { tls::Handshake::from_ptr(ssl) } {
|
|
709
|
+
Ok(v) => v,
|
|
710
|
+
|
|
711
|
+
Err(_) => return ptr::null_mut(),
|
|
712
|
+
};
|
|
653
713
|
|
|
654
714
|
match Connection::with_tls(
|
|
655
715
|
&scid,
|
|
@@ -672,9 +732,16 @@ pub extern "C" fn quiche_conn_new_with_tls_and_client_dcid(
|
|
|
672
732
|
#[cfg(not(feature = "custom-client-dcid"))]
|
|
673
733
|
#[allow(unused_variables)]
|
|
674
734
|
pub extern "C" fn quiche_conn_new_with_tls_and_client_dcid(
|
|
675
|
-
scid: *const u8,
|
|
676
|
-
|
|
677
|
-
|
|
735
|
+
scid: *const u8,
|
|
736
|
+
scid_len: size_t,
|
|
737
|
+
dcid: *const u8,
|
|
738
|
+
dcid_len: size_t,
|
|
739
|
+
local: &sockaddr,
|
|
740
|
+
local_len: socklen_t,
|
|
741
|
+
peer: &sockaddr,
|
|
742
|
+
peer_len: socklen_t,
|
|
743
|
+
config: &Config,
|
|
744
|
+
ssl: *mut c_void,
|
|
678
745
|
) -> *mut Connection {
|
|
679
746
|
// It's always an error to call this function without the custom-client-dcid
|
|
680
747
|
// feature enabled.
|
|
@@ -683,9 +750,17 @@ pub extern "C" fn quiche_conn_new_with_tls_and_client_dcid(
|
|
|
683
750
|
|
|
684
751
|
#[no_mangle]
|
|
685
752
|
pub extern "C" fn quiche_conn_new_with_tls(
|
|
686
|
-
scid: *const u8,
|
|
687
|
-
|
|
688
|
-
|
|
753
|
+
scid: *const u8,
|
|
754
|
+
scid_len: size_t,
|
|
755
|
+
odcid: *const u8,
|
|
756
|
+
odcid_len: size_t,
|
|
757
|
+
local: &sockaddr,
|
|
758
|
+
local_len: socklen_t,
|
|
759
|
+
peer: &sockaddr,
|
|
760
|
+
peer_len: socklen_t,
|
|
761
|
+
config: &Config,
|
|
762
|
+
ssl: *mut c_void,
|
|
763
|
+
is_server: bool,
|
|
689
764
|
) -> *mut Connection {
|
|
690
765
|
let scid = unsafe { slice::from_raw_parts(scid, scid_len) };
|
|
691
766
|
let scid = ConnectionId::from_ref(scid);
|
|
@@ -706,11 +781,13 @@ pub extern "C" fn quiche_conn_new_with_tls(
|
|
|
706
781
|
let local = std_addr_from_c(local, local_len);
|
|
707
782
|
let peer = std_addr_from_c(peer, peer_len);
|
|
708
783
|
|
|
709
|
-
let tls = unsafe { tls::Handshake::from_ptr(ssl) }
|
|
784
|
+
let tls = match unsafe { tls::Handshake::from_ptr(ssl) } {
|
|
785
|
+
Ok(v) => v,
|
|
786
|
+
|
|
787
|
+
Err(_) => return ptr::null_mut(),
|
|
788
|
+
};
|
|
710
789
|
|
|
711
|
-
match Connection::with_tls(
|
|
712
|
-
&scid, retry_cids, None, local, peer, config, tls, is_server,
|
|
713
|
-
) {
|
|
790
|
+
match Connection::with_tls(&scid, retry_cids, None, local, peer, config, tls, is_server) {
|
|
714
791
|
Ok(c) => Box::into_raw(Box::new(c)),
|
|
715
792
|
|
|
716
793
|
Err(_) => ptr::null_mut(),
|
|
@@ -718,9 +795,7 @@ pub extern "C" fn quiche_conn_new_with_tls(
|
|
|
718
795
|
}
|
|
719
796
|
|
|
720
797
|
#[no_mangle]
|
|
721
|
-
pub extern "C" fn quiche_conn_set_keylog_path(
|
|
722
|
-
conn: &mut Connection, path: *const c_char,
|
|
723
|
-
) -> bool {
|
|
798
|
+
pub extern "C" fn quiche_conn_set_keylog_path(conn: &mut Connection, path: *const c_char) -> bool {
|
|
724
799
|
let filename = unsafe { ffi::CStr::from_ptr(path).to_str().unwrap() };
|
|
725
800
|
|
|
726
801
|
let file = std::fs::OpenOptions::new()
|
|
@@ -751,7 +826,9 @@ pub extern "C" fn quiche_conn_set_keylog_fd(conn: &mut Connection, fd: c_int) {
|
|
|
751
826
|
#[no_mangle]
|
|
752
827
|
#[cfg(feature = "qlog")]
|
|
753
828
|
pub extern "C" fn quiche_conn_set_qlog_path(
|
|
754
|
-
conn: &mut Connection,
|
|
829
|
+
conn: &mut Connection,
|
|
830
|
+
path: *const c_char,
|
|
831
|
+
log_title: *const c_char,
|
|
755
832
|
log_desc: *const c_char,
|
|
756
833
|
) -> bool {
|
|
757
834
|
let filename = unsafe { ffi::CStr::from_ptr(path).to_str().unwrap() };
|
|
@@ -782,7 +859,9 @@ pub extern "C" fn quiche_conn_set_qlog_path(
|
|
|
782
859
|
#[no_mangle]
|
|
783
860
|
#[cfg(all(unix, feature = "qlog"))]
|
|
784
861
|
pub extern "C" fn quiche_conn_set_qlog_fd(
|
|
785
|
-
conn: &mut Connection,
|
|
862
|
+
conn: &mut Connection,
|
|
863
|
+
fd: c_int,
|
|
864
|
+
log_title: *const c_char,
|
|
786
865
|
log_desc: *const c_char,
|
|
787
866
|
) {
|
|
788
867
|
let f = unsafe { std::fs::File::from_raw_fd(fd) };
|
|
@@ -800,7 +879,9 @@ pub extern "C" fn quiche_conn_set_qlog_fd(
|
|
|
800
879
|
|
|
801
880
|
#[no_mangle]
|
|
802
881
|
pub extern "C" fn quiche_conn_set_session(
|
|
803
|
-
conn: &mut Connection,
|
|
882
|
+
conn: &mut Connection,
|
|
883
|
+
buf: *const u8,
|
|
884
|
+
buf_len: size_t,
|
|
804
885
|
) -> c_int {
|
|
805
886
|
let buf = unsafe { slice::from_raw_parts(buf, buf_len) };
|
|
806
887
|
|
|
@@ -812,9 +893,7 @@ pub extern "C" fn quiche_conn_set_session(
|
|
|
812
893
|
}
|
|
813
894
|
|
|
814
895
|
#[no_mangle]
|
|
815
|
-
pub extern "C" fn quiche_conn_set_max_idle_timeout(
|
|
816
|
-
conn: &mut Connection, v: u64,
|
|
817
|
-
) -> c_int {
|
|
896
|
+
pub extern "C" fn quiche_conn_set_max_idle_timeout(conn: &mut Connection, v: u64) -> c_int {
|
|
818
897
|
match conn.set_max_idle_timeout(v) {
|
|
819
898
|
Ok(()) => 0,
|
|
820
899
|
|
|
@@ -841,7 +920,10 @@ impl From<&RecvInfo<'_>> for crate::RecvInfo {
|
|
|
841
920
|
|
|
842
921
|
#[no_mangle]
|
|
843
922
|
pub extern "C" fn quiche_conn_recv(
|
|
844
|
-
conn: &mut Connection,
|
|
923
|
+
conn: &mut Connection,
|
|
924
|
+
buf: *mut u8,
|
|
925
|
+
buf_len: size_t,
|
|
926
|
+
info: &RecvInfo,
|
|
845
927
|
) -> ssize_t {
|
|
846
928
|
if buf_len > <ssize_t>::MAX as usize {
|
|
847
929
|
panic!("The provided buffer is too large");
|
|
@@ -868,7 +950,10 @@ pub struct SendInfo {
|
|
|
868
950
|
|
|
869
951
|
#[no_mangle]
|
|
870
952
|
pub extern "C" fn quiche_conn_send(
|
|
871
|
-
conn: &mut Connection,
|
|
953
|
+
conn: &mut Connection,
|
|
954
|
+
out: *mut u8,
|
|
955
|
+
out_len: size_t,
|
|
956
|
+
out_info: &mut SendInfo,
|
|
872
957
|
) -> ssize_t {
|
|
873
958
|
if out_len > <ssize_t>::MAX as usize {
|
|
874
959
|
panic!("The provided buffer is too large");
|
|
@@ -884,7 +969,7 @@ pub extern "C" fn quiche_conn_send(
|
|
|
884
969
|
std_time_to_c(&info.at, &mut out_info.at);
|
|
885
970
|
|
|
886
971
|
v as ssize_t
|
|
887
|
-
}
|
|
972
|
+
}
|
|
888
973
|
|
|
889
974
|
Err(e) => e.to_c(),
|
|
890
975
|
}
|
|
@@ -892,8 +977,13 @@ pub extern "C" fn quiche_conn_send(
|
|
|
892
977
|
|
|
893
978
|
#[no_mangle]
|
|
894
979
|
pub extern "C" fn quiche_conn_send_on_path(
|
|
895
|
-
conn: &mut Connection,
|
|
896
|
-
|
|
980
|
+
conn: &mut Connection,
|
|
981
|
+
out: *mut u8,
|
|
982
|
+
out_len: size_t,
|
|
983
|
+
from: *const sockaddr,
|
|
984
|
+
from_len: socklen_t,
|
|
985
|
+
to: *const sockaddr,
|
|
986
|
+
to_len: socklen_t,
|
|
897
987
|
out_info: &mut SendInfo,
|
|
898
988
|
) -> ssize_t {
|
|
899
989
|
if out_len > <ssize_t>::MAX as usize {
|
|
@@ -912,7 +1002,7 @@ pub extern "C" fn quiche_conn_send_on_path(
|
|
|
912
1002
|
std_time_to_c(&info.at, &mut out_info.at);
|
|
913
1003
|
|
|
914
1004
|
v as ssize_t
|
|
915
|
-
}
|
|
1005
|
+
}
|
|
916
1006
|
|
|
917
1007
|
Err(e) => e.to_c(),
|
|
918
1008
|
}
|
|
@@ -920,8 +1010,12 @@ pub extern "C" fn quiche_conn_send_on_path(
|
|
|
920
1010
|
|
|
921
1011
|
#[no_mangle]
|
|
922
1012
|
pub extern "C" fn quiche_conn_stream_recv(
|
|
923
|
-
conn: &mut Connection,
|
|
924
|
-
|
|
1013
|
+
conn: &mut Connection,
|
|
1014
|
+
stream_id: u64,
|
|
1015
|
+
out: *mut u8,
|
|
1016
|
+
out_len: size_t,
|
|
1017
|
+
fin: &mut bool,
|
|
1018
|
+
out_error_code: &mut u64,
|
|
925
1019
|
) -> ssize_t {
|
|
926
1020
|
if out_len > <ssize_t>::MAX as usize {
|
|
927
1021
|
panic!("The provided buffer is too large");
|
|
@@ -936,10 +1030,10 @@ pub extern "C" fn quiche_conn_stream_recv(
|
|
|
936
1030
|
match e {
|
|
937
1031
|
Error::StreamReset(error) => *out_error_code = error,
|
|
938
1032
|
Error::StreamStopped(error) => *out_error_code = error,
|
|
939
|
-
_ => {}
|
|
1033
|
+
_ => {}
|
|
940
1034
|
}
|
|
941
1035
|
return e.to_c();
|
|
942
|
-
}
|
|
1036
|
+
}
|
|
943
1037
|
};
|
|
944
1038
|
|
|
945
1039
|
*fin = out_fin;
|
|
@@ -949,8 +1043,12 @@ pub extern "C" fn quiche_conn_stream_recv(
|
|
|
949
1043
|
|
|
950
1044
|
#[no_mangle]
|
|
951
1045
|
pub extern "C" fn quiche_conn_stream_send(
|
|
952
|
-
conn: &mut Connection,
|
|
953
|
-
|
|
1046
|
+
conn: &mut Connection,
|
|
1047
|
+
stream_id: u64,
|
|
1048
|
+
buf: *const u8,
|
|
1049
|
+
buf_len: size_t,
|
|
1050
|
+
fin: bool,
|
|
1051
|
+
out_error_code: &mut u64,
|
|
954
1052
|
) -> ssize_t {
|
|
955
1053
|
if buf_len > <ssize_t>::MAX as usize {
|
|
956
1054
|
panic!("The provided buffer is too large");
|
|
@@ -970,16 +1068,19 @@ pub extern "C" fn quiche_conn_stream_send(
|
|
|
970
1068
|
match e {
|
|
971
1069
|
Error::StreamReset(error) => *out_error_code = error,
|
|
972
1070
|
Error::StreamStopped(error) => *out_error_code = error,
|
|
973
|
-
_ => {}
|
|
1071
|
+
_ => {}
|
|
974
1072
|
}
|
|
975
1073
|
e.to_c()
|
|
976
|
-
}
|
|
1074
|
+
}
|
|
977
1075
|
}
|
|
978
1076
|
}
|
|
979
1077
|
|
|
980
1078
|
#[no_mangle]
|
|
981
1079
|
pub extern "C" fn quiche_conn_stream_priority(
|
|
982
|
-
conn: &mut Connection,
|
|
1080
|
+
conn: &mut Connection,
|
|
1081
|
+
stream_id: u64,
|
|
1082
|
+
urgency: u8,
|
|
1083
|
+
incremental: bool,
|
|
983
1084
|
) -> c_int {
|
|
984
1085
|
match conn.stream_priority(stream_id, urgency, incremental) {
|
|
985
1086
|
Ok(_) => 0,
|
|
@@ -990,7 +1091,10 @@ pub extern "C" fn quiche_conn_stream_priority(
|
|
|
990
1091
|
|
|
991
1092
|
#[no_mangle]
|
|
992
1093
|
pub extern "C" fn quiche_conn_stream_shutdown(
|
|
993
|
-
conn: &mut Connection,
|
|
1094
|
+
conn: &mut Connection,
|
|
1095
|
+
stream_id: u64,
|
|
1096
|
+
direction: Shutdown,
|
|
1097
|
+
err: u64,
|
|
994
1098
|
) -> c_int {
|
|
995
1099
|
match conn.stream_shutdown(stream_id, direction, err) {
|
|
996
1100
|
Ok(_) => 0,
|
|
@@ -1000,9 +1104,7 @@ pub extern "C" fn quiche_conn_stream_shutdown(
|
|
|
1000
1104
|
}
|
|
1001
1105
|
|
|
1002
1106
|
#[no_mangle]
|
|
1003
|
-
pub extern "C" fn quiche_conn_stream_capacity(
|
|
1004
|
-
conn: &mut Connection, stream_id: u64,
|
|
1005
|
-
) -> ssize_t {
|
|
1107
|
+
pub extern "C" fn quiche_conn_stream_capacity(conn: &mut Connection, stream_id: u64) -> ssize_t {
|
|
1006
1108
|
match conn.stream_capacity(stream_id) {
|
|
1007
1109
|
Ok(v) => v as ssize_t,
|
|
1008
1110
|
|
|
@@ -1011,9 +1113,7 @@ pub extern "C" fn quiche_conn_stream_capacity(
|
|
|
1011
1113
|
}
|
|
1012
1114
|
|
|
1013
1115
|
#[no_mangle]
|
|
1014
|
-
pub extern "C" fn quiche_conn_stream_readable(
|
|
1015
|
-
conn: &Connection, stream_id: u64,
|
|
1016
|
-
) -> bool {
|
|
1116
|
+
pub extern "C" fn quiche_conn_stream_readable(conn: &Connection, stream_id: u64) -> bool {
|
|
1017
1117
|
conn.stream_readable(stream_id)
|
|
1018
1118
|
}
|
|
1019
1119
|
|
|
@@ -1024,7 +1124,9 @@ pub extern "C" fn quiche_conn_stream_readable_next(conn: &mut Connection) -> i64
|
|
|
1024
1124
|
|
|
1025
1125
|
#[no_mangle]
|
|
1026
1126
|
pub extern "C" fn quiche_conn_stream_writable(
|
|
1027
|
-
conn: &mut Connection,
|
|
1127
|
+
conn: &mut Connection,
|
|
1128
|
+
stream_id: u64,
|
|
1129
|
+
len: usize,
|
|
1028
1130
|
) -> c_int {
|
|
1029
1131
|
match conn.stream_writable(stream_id, len) {
|
|
1030
1132
|
Ok(true) => 1,
|
|
@@ -1041,9 +1143,7 @@ pub extern "C" fn quiche_conn_stream_writable_next(conn: &mut Connection) -> i64
|
|
|
1041
1143
|
}
|
|
1042
1144
|
|
|
1043
1145
|
#[no_mangle]
|
|
1044
|
-
pub extern "C" fn quiche_conn_stream_finished(
|
|
1045
|
-
conn: &Connection, stream_id: u64,
|
|
1046
|
-
) -> bool {
|
|
1146
|
+
pub extern "C" fn quiche_conn_stream_finished(conn: &Connection, stream_id: u64) -> bool {
|
|
1047
1147
|
conn.stream_finished(stream_id)
|
|
1048
1148
|
}
|
|
1049
1149
|
|
|
@@ -1058,9 +1158,7 @@ pub extern "C" fn quiche_conn_writable(conn: &Connection) -> *mut StreamIter {
|
|
|
1058
1158
|
}
|
|
1059
1159
|
|
|
1060
1160
|
#[no_mangle]
|
|
1061
|
-
pub extern "C" fn quiche_conn_max_send_udp_payload_size(
|
|
1062
|
-
conn: &Connection,
|
|
1063
|
-
) -> usize {
|
|
1161
|
+
pub extern "C" fn quiche_conn_max_send_udp_payload_size(conn: &Connection) -> usize {
|
|
1064
1162
|
conn.max_send_udp_payload_size()
|
|
1065
1163
|
}
|
|
1066
1164
|
|
|
@@ -1071,7 +1169,10 @@ pub extern "C" fn quiche_conn_is_readable(conn: &Connection) -> bool {
|
|
|
1071
1169
|
|
|
1072
1170
|
#[no_mangle]
|
|
1073
1171
|
pub extern "C" fn quiche_conn_close(
|
|
1074
|
-
conn: &mut Connection,
|
|
1172
|
+
conn: &mut Connection,
|
|
1173
|
+
app: bool,
|
|
1174
|
+
err: u64,
|
|
1175
|
+
reason: *const u8,
|
|
1075
1176
|
reason_len: size_t,
|
|
1076
1177
|
) -> c_int {
|
|
1077
1178
|
let reason = if reason.is_null() {
|
|
@@ -1113,7 +1214,9 @@ pub extern "C" fn quiche_conn_on_timeout(conn: &mut Connection) {
|
|
|
1113
1214
|
|
|
1114
1215
|
#[no_mangle]
|
|
1115
1216
|
pub extern "C" fn quiche_conn_trace_id(
|
|
1116
|
-
conn: &Connection,
|
|
1217
|
+
conn: &Connection,
|
|
1218
|
+
out: &mut *const u8,
|
|
1219
|
+
out_len: &mut size_t,
|
|
1117
1220
|
) {
|
|
1118
1221
|
let trace_id = conn.trace_id();
|
|
1119
1222
|
|
|
@@ -1128,21 +1231,8 @@ pub struct ConnectionIdIter<'a> {
|
|
|
1128
1231
|
index: usize,
|
|
1129
1232
|
}
|
|
1130
1233
|
|
|
1131
|
-
impl<'a> Iterator for ConnectionIdIter<'a> {
|
|
1132
|
-
type Item = ConnectionId<'a>;
|
|
1133
|
-
|
|
1134
|
-
#[inline]
|
|
1135
|
-
fn next(&mut self) -> Option<Self::Item> {
|
|
1136
|
-
let v = self.cids.get(self.index)?;
|
|
1137
|
-
self.index += 1;
|
|
1138
|
-
Some(v.clone())
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
1234
|
#[no_mangle]
|
|
1143
|
-
pub extern "C" fn quiche_conn_source_ids(
|
|
1144
|
-
conn: &Connection,
|
|
1145
|
-
) -> *mut ConnectionIdIter<'_> {
|
|
1235
|
+
pub extern "C" fn quiche_conn_source_ids(conn: &Connection) -> *mut ConnectionIdIter<'_> {
|
|
1146
1236
|
let vec = conn.source_ids().cloned().collect();
|
|
1147
1237
|
Box::into_raw(Box::new(ConnectionIdIter {
|
|
1148
1238
|
cids: vec,
|
|
@@ -1152,12 +1242,15 @@ pub extern "C" fn quiche_conn_source_ids(
|
|
|
1152
1242
|
|
|
1153
1243
|
#[no_mangle]
|
|
1154
1244
|
pub extern "C" fn quiche_connection_id_iter_next(
|
|
1155
|
-
iter: &mut ConnectionIdIter,
|
|
1245
|
+
iter: &mut ConnectionIdIter,
|
|
1246
|
+
out: &mut *const u8,
|
|
1247
|
+
out_len: &mut size_t,
|
|
1156
1248
|
) -> bool {
|
|
1157
|
-
if let Some(conn_id) = iter.
|
|
1249
|
+
if let Some(conn_id) = iter.cids.get(iter.index) {
|
|
1158
1250
|
let id = conn_id.as_ref();
|
|
1159
1251
|
*out = id.as_ptr();
|
|
1160
1252
|
*out_len = id.len();
|
|
1253
|
+
iter.index += 1;
|
|
1161
1254
|
return true;
|
|
1162
1255
|
}
|
|
1163
1256
|
|
|
@@ -1173,7 +1266,9 @@ pub extern "C" fn quiche_connection_id_iter_free(iter: *mut ConnectionIdIter) {
|
|
|
1173
1266
|
|
|
1174
1267
|
#[no_mangle]
|
|
1175
1268
|
pub extern "C" fn quiche_conn_source_id(
|
|
1176
|
-
conn: &Connection,
|
|
1269
|
+
conn: &Connection,
|
|
1270
|
+
out: &mut *const u8,
|
|
1271
|
+
out_len: &mut size_t,
|
|
1177
1272
|
) {
|
|
1178
1273
|
let conn_id = conn.source_id();
|
|
1179
1274
|
let id = conn_id.as_ref();
|
|
@@ -1183,7 +1278,9 @@ pub extern "C" fn quiche_conn_source_id(
|
|
|
1183
1278
|
|
|
1184
1279
|
#[no_mangle]
|
|
1185
1280
|
pub extern "C" fn quiche_conn_destination_id(
|
|
1186
|
-
conn: &Connection,
|
|
1281
|
+
conn: &Connection,
|
|
1282
|
+
out: &mut *const u8,
|
|
1283
|
+
out_len: &mut size_t,
|
|
1187
1284
|
) {
|
|
1188
1285
|
let conn_id = conn.destination_id();
|
|
1189
1286
|
let id = conn_id.as_ref();
|
|
@@ -1194,7 +1291,9 @@ pub extern "C" fn quiche_conn_destination_id(
|
|
|
1194
1291
|
|
|
1195
1292
|
#[no_mangle]
|
|
1196
1293
|
pub extern "C" fn quiche_conn_application_proto(
|
|
1197
|
-
conn: &Connection,
|
|
1294
|
+
conn: &Connection,
|
|
1295
|
+
out: &mut *const u8,
|
|
1296
|
+
out_len: &mut size_t,
|
|
1198
1297
|
) {
|
|
1199
1298
|
let proto = conn.application_proto();
|
|
1200
1299
|
|
|
@@ -1204,13 +1303,15 @@ pub extern "C" fn quiche_conn_application_proto(
|
|
|
1204
1303
|
|
|
1205
1304
|
#[no_mangle]
|
|
1206
1305
|
pub extern "C" fn quiche_conn_peer_cert(
|
|
1207
|
-
conn: &Connection,
|
|
1306
|
+
conn: &Connection,
|
|
1307
|
+
out: &mut *const u8,
|
|
1308
|
+
out_len: &mut size_t,
|
|
1208
1309
|
) {
|
|
1209
1310
|
match conn.peer_cert() {
|
|
1210
1311
|
Some(peer_cert) => {
|
|
1211
1312
|
*out = peer_cert.as_ptr();
|
|
1212
1313
|
*out_len = peer_cert.len();
|
|
1213
|
-
}
|
|
1314
|
+
}
|
|
1214
1315
|
|
|
1215
1316
|
None => *out_len = 0,
|
|
1216
1317
|
}
|
|
@@ -1218,13 +1319,15 @@ pub extern "C" fn quiche_conn_peer_cert(
|
|
|
1218
1319
|
|
|
1219
1320
|
#[no_mangle]
|
|
1220
1321
|
pub extern "C" fn quiche_conn_session(
|
|
1221
|
-
conn: &Connection,
|
|
1322
|
+
conn: &Connection,
|
|
1323
|
+
out: &mut *const u8,
|
|
1324
|
+
out_len: &mut size_t,
|
|
1222
1325
|
) {
|
|
1223
1326
|
match conn.session() {
|
|
1224
1327
|
Some(session) => {
|
|
1225
1328
|
*out = session.as_ptr();
|
|
1226
1329
|
*out_len = session.len();
|
|
1227
|
-
}
|
|
1330
|
+
}
|
|
1228
1331
|
|
|
1229
1332
|
None => *out_len = 0,
|
|
1230
1333
|
}
|
|
@@ -1232,13 +1335,15 @@ pub extern "C" fn quiche_conn_session(
|
|
|
1232
1335
|
|
|
1233
1336
|
#[no_mangle]
|
|
1234
1337
|
pub extern "C" fn quiche_conn_server_name(
|
|
1235
|
-
conn: &Connection,
|
|
1338
|
+
conn: &Connection,
|
|
1339
|
+
out: &mut *const u8,
|
|
1340
|
+
out_len: &mut size_t,
|
|
1236
1341
|
) {
|
|
1237
1342
|
match conn.server_name() {
|
|
1238
1343
|
Some(server_name) => {
|
|
1239
1344
|
*out = server_name.as_ptr();
|
|
1240
1345
|
*out_len = server_name.len();
|
|
1241
|
-
}
|
|
1346
|
+
}
|
|
1242
1347
|
|
|
1243
1348
|
None => *out_len = 0,
|
|
1244
1349
|
}
|
|
@@ -1276,8 +1381,11 @@ pub extern "C" fn quiche_conn_is_timed_out(conn: &Connection) -> bool {
|
|
|
1276
1381
|
|
|
1277
1382
|
#[no_mangle]
|
|
1278
1383
|
pub extern "C" fn quiche_conn_peer_error(
|
|
1279
|
-
conn: &Connection,
|
|
1280
|
-
|
|
1384
|
+
conn: &Connection,
|
|
1385
|
+
is_app: *mut bool,
|
|
1386
|
+
error_code: *mut u64,
|
|
1387
|
+
reason: &mut *const u8,
|
|
1388
|
+
reason_len: &mut size_t,
|
|
1281
1389
|
) -> bool {
|
|
1282
1390
|
match &conn.peer_error {
|
|
1283
1391
|
Some(conn_err) => unsafe {
|
|
@@ -1295,8 +1403,11 @@ pub extern "C" fn quiche_conn_peer_error(
|
|
|
1295
1403
|
|
|
1296
1404
|
#[no_mangle]
|
|
1297
1405
|
pub extern "C" fn quiche_conn_local_error(
|
|
1298
|
-
conn: &Connection,
|
|
1299
|
-
|
|
1406
|
+
conn: &Connection,
|
|
1407
|
+
is_app: *mut bool,
|
|
1408
|
+
error_code: *mut u64,
|
|
1409
|
+
reason: &mut *const u8,
|
|
1410
|
+
reason_len: &mut size_t,
|
|
1300
1411
|
) -> bool {
|
|
1301
1412
|
match &conn.local_error {
|
|
1302
1413
|
Some(conn_err) => unsafe {
|
|
@@ -1313,9 +1424,7 @@ pub extern "C" fn quiche_conn_local_error(
|
|
|
1313
1424
|
}
|
|
1314
1425
|
|
|
1315
1426
|
#[no_mangle]
|
|
1316
|
-
pub extern "C" fn quiche_stream_iter_next(
|
|
1317
|
-
iter: &mut StreamIter, stream_id: *mut u64,
|
|
1318
|
-
) -> bool {
|
|
1427
|
+
pub extern "C" fn quiche_stream_iter_next(iter: &mut StreamIter, stream_id: *mut u64) -> bool {
|
|
1319
1428
|
if let Some(v) = iter.next() {
|
|
1320
1429
|
unsafe { *stream_id = v };
|
|
1321
1430
|
return true;
|
|
@@ -1405,15 +1514,14 @@ pub extern "C" fn quiche_conn_stats(conn: &Connection, out: &mut Stats) {
|
|
|
1405
1514
|
out.streams_blocked_bidi_recv_count = stats.streams_blocked_bidi_recv_count;
|
|
1406
1515
|
out.streams_blocked_uni_recv_count = stats.streams_blocked_uni_recv_count;
|
|
1407
1516
|
out.path_challenge_rx_count = stats.path_challenge_rx_count;
|
|
1408
|
-
out.bytes_in_flight_duration_msec =
|
|
1409
|
-
|
|
1410
|
-
out.tx_buffered_inconsistent =
|
|
1411
|
-
stats.tx_buffered_state != TxBufferTrackingState::Ok;
|
|
1517
|
+
out.bytes_in_flight_duration_msec = stats.bytes_in_flight_duration.as_millis() as u64;
|
|
1518
|
+
out.tx_buffered_inconsistent = stats.tx_buffered_state != TxBufferTrackingState::Ok;
|
|
1412
1519
|
}
|
|
1413
1520
|
|
|
1414
1521
|
#[no_mangle]
|
|
1415
1522
|
pub extern "C" fn quiche_conn_peer_transport_params(
|
|
1416
|
-
conn: &Connection,
|
|
1523
|
+
conn: &Connection,
|
|
1524
|
+
out: &mut TransportParams,
|
|
1417
1525
|
) -> bool {
|
|
1418
1526
|
let tps = match conn.peer_transport_params() {
|
|
1419
1527
|
Some(v) => v,
|
|
@@ -1423,10 +1531,8 @@ pub extern "C" fn quiche_conn_peer_transport_params(
|
|
|
1423
1531
|
out.max_idle_timeout = tps.max_idle_timeout;
|
|
1424
1532
|
out.max_udp_payload_size = tps.max_udp_payload_size;
|
|
1425
1533
|
out.initial_max_data = tps.initial_max_data;
|
|
1426
|
-
out.initial_max_stream_data_bidi_local =
|
|
1427
|
-
|
|
1428
|
-
out.initial_max_stream_data_bidi_remote =
|
|
1429
|
-
tps.initial_max_stream_data_bidi_remote;
|
|
1534
|
+
out.initial_max_stream_data_bidi_local = tps.initial_max_stream_data_bidi_local;
|
|
1535
|
+
out.initial_max_stream_data_bidi_remote = tps.initial_max_stream_data_bidi_remote;
|
|
1430
1536
|
out.initial_max_stream_data_uni = tps.initial_max_stream_data_uni;
|
|
1431
1537
|
out.initial_max_streams_bidi = tps.initial_max_streams_bidi;
|
|
1432
1538
|
out.initial_max_streams_uni = tps.initial_max_streams_uni;
|
|
@@ -1475,7 +1581,9 @@ pub struct PathStats {
|
|
|
1475
1581
|
|
|
1476
1582
|
#[no_mangle]
|
|
1477
1583
|
pub extern "C" fn quiche_conn_path_stats(
|
|
1478
|
-
conn: &Connection,
|
|
1584
|
+
conn: &Connection,
|
|
1585
|
+
idx: usize,
|
|
1586
|
+
out: &mut PathStats,
|
|
1479
1587
|
) -> c_int {
|
|
1480
1588
|
let stats = match conn.path_stats().nth(idx) {
|
|
1481
1589
|
Some(p) => p,
|
|
@@ -1495,6 +1603,7 @@ pub extern "C" fn quiche_conn_path_stats(
|
|
|
1495
1603
|
out.dgram_sent = stats.dgram_sent;
|
|
1496
1604
|
out.rtt = stats.rtt.as_nanos() as u64;
|
|
1497
1605
|
out.min_rtt = stats.min_rtt.unwrap_or_default().as_nanos() as u64;
|
|
1606
|
+
out.max_rtt = stats.max_rtt.unwrap_or_default().as_nanos() as u64;
|
|
1498
1607
|
out.rttvar = stats.rttvar.as_nanos() as u64;
|
|
1499
1608
|
out.cwnd = stats.cwnd;
|
|
1500
1609
|
out.sent_bytes = stats.sent_bytes;
|
|
@@ -1504,8 +1613,7 @@ pub extern "C" fn quiche_conn_path_stats(
|
|
|
1504
1613
|
out.pmtu = stats.pmtu;
|
|
1505
1614
|
out.delivery_rate = stats.delivery_rate;
|
|
1506
1615
|
out.max_bandwidth = stats.max_bandwidth.unwrap_or(0);
|
|
1507
|
-
out.startup_exit_cwnd =
|
|
1508
|
-
stats.startup_exit.map(|s| s.cwnd as u64).unwrap_or(0);
|
|
1616
|
+
out.startup_exit_cwnd = stats.startup_exit.map(|s| s.cwnd as u64).unwrap_or(0);
|
|
1509
1617
|
|
|
1510
1618
|
0
|
|
1511
1619
|
}
|
|
@@ -1516,9 +1624,7 @@ pub extern "C" fn quiche_conn_is_server(conn: &Connection) -> bool {
|
|
|
1516
1624
|
}
|
|
1517
1625
|
|
|
1518
1626
|
#[no_mangle]
|
|
1519
|
-
pub extern "C" fn quiche_conn_dgram_max_writable_len(
|
|
1520
|
-
conn: &Connection,
|
|
1521
|
-
) -> ssize_t {
|
|
1627
|
+
pub extern "C" fn quiche_conn_dgram_max_writable_len(conn: &Connection) -> ssize_t {
|
|
1522
1628
|
match conn.dgram_max_writable_len() {
|
|
1523
1629
|
None => Error::Done.to_c(),
|
|
1524
1630
|
|
|
@@ -1541,9 +1647,7 @@ pub extern "C" fn quiche_conn_dgram_recv_queue_len(conn: &Connection) -> ssize_t
|
|
|
1541
1647
|
}
|
|
1542
1648
|
|
|
1543
1649
|
#[no_mangle]
|
|
1544
|
-
pub extern "C" fn quiche_conn_dgram_recv_queue_byte_size(
|
|
1545
|
-
conn: &Connection,
|
|
1546
|
-
) -> ssize_t {
|
|
1650
|
+
pub extern "C" fn quiche_conn_dgram_recv_queue_byte_size(conn: &Connection) -> ssize_t {
|
|
1547
1651
|
conn.dgram_recv_queue_byte_size() as ssize_t
|
|
1548
1652
|
}
|
|
1549
1653
|
|
|
@@ -1553,15 +1657,15 @@ pub extern "C" fn quiche_conn_dgram_send_queue_len(conn: &Connection) -> ssize_t
|
|
|
1553
1657
|
}
|
|
1554
1658
|
|
|
1555
1659
|
#[no_mangle]
|
|
1556
|
-
pub extern "C" fn quiche_conn_dgram_send_queue_byte_size(
|
|
1557
|
-
conn: &Connection,
|
|
1558
|
-
) -> ssize_t {
|
|
1660
|
+
pub extern "C" fn quiche_conn_dgram_send_queue_byte_size(conn: &Connection) -> ssize_t {
|
|
1559
1661
|
conn.dgram_send_queue_byte_size() as ssize_t
|
|
1560
1662
|
}
|
|
1561
1663
|
|
|
1562
1664
|
#[no_mangle]
|
|
1563
1665
|
pub extern "C" fn quiche_conn_dgram_send(
|
|
1564
|
-
conn: &mut Connection,
|
|
1666
|
+
conn: &mut Connection,
|
|
1667
|
+
buf: *const u8,
|
|
1668
|
+
buf_len: size_t,
|
|
1565
1669
|
) -> ssize_t {
|
|
1566
1670
|
if buf_len > <ssize_t>::MAX as usize {
|
|
1567
1671
|
panic!("The provided buffer is too large");
|
|
@@ -1578,7 +1682,9 @@ pub extern "C" fn quiche_conn_dgram_send(
|
|
|
1578
1682
|
|
|
1579
1683
|
#[no_mangle]
|
|
1580
1684
|
pub extern "C" fn quiche_conn_dgram_recv(
|
|
1581
|
-
conn: &mut Connection,
|
|
1685
|
+
conn: &mut Connection,
|
|
1686
|
+
out: *mut u8,
|
|
1687
|
+
out_len: size_t,
|
|
1582
1688
|
) -> ssize_t {
|
|
1583
1689
|
if out_len > <ssize_t>::MAX as usize {
|
|
1584
1690
|
panic!("The provided buffer is too large");
|
|
@@ -1597,7 +1703,8 @@ pub extern "C" fn quiche_conn_dgram_recv(
|
|
|
1597
1703
|
|
|
1598
1704
|
#[no_mangle]
|
|
1599
1705
|
pub extern "C" fn quiche_conn_dgram_purge_outgoing(
|
|
1600
|
-
conn: &mut Connection,
|
|
1706
|
+
conn: &mut Connection,
|
|
1707
|
+
f: extern "C" fn(*const u8, size_t) -> bool,
|
|
1601
1708
|
) {
|
|
1602
1709
|
conn.dgram_purge_outgoing(|d: &[u8]| -> bool {
|
|
1603
1710
|
let ptr: *const u8 = d.as_ptr();
|
|
@@ -1608,23 +1715,17 @@ pub extern "C" fn quiche_conn_dgram_purge_outgoing(
|
|
|
1608
1715
|
}
|
|
1609
1716
|
|
|
1610
1717
|
#[no_mangle]
|
|
1611
|
-
pub extern "C" fn quiche_conn_is_dgram_send_queue_full(
|
|
1612
|
-
conn: &Connection,
|
|
1613
|
-
) -> bool {
|
|
1718
|
+
pub extern "C" fn quiche_conn_is_dgram_send_queue_full(conn: &Connection) -> bool {
|
|
1614
1719
|
conn.is_dgram_send_queue_full()
|
|
1615
1720
|
}
|
|
1616
1721
|
|
|
1617
1722
|
#[no_mangle]
|
|
1618
|
-
pub extern "C" fn quiche_conn_is_dgram_recv_queue_full(
|
|
1619
|
-
conn: &Connection,
|
|
1620
|
-
) -> bool {
|
|
1723
|
+
pub extern "C" fn quiche_conn_is_dgram_recv_queue_full(conn: &Connection) -> bool {
|
|
1621
1724
|
conn.is_dgram_recv_queue_full()
|
|
1622
1725
|
}
|
|
1623
1726
|
|
|
1624
1727
|
#[no_mangle]
|
|
1625
|
-
pub extern "C" fn quiche_conn_send_ack_eliciting(
|
|
1626
|
-
conn: &mut Connection,
|
|
1627
|
-
) -> ssize_t {
|
|
1728
|
+
pub extern "C" fn quiche_conn_send_ack_eliciting(conn: &mut Connection) -> ssize_t {
|
|
1628
1729
|
match conn.send_ack_eliciting() {
|
|
1629
1730
|
Ok(()) => 0,
|
|
1630
1731
|
Err(e) => e.to_c(),
|
|
@@ -1633,8 +1734,11 @@ pub extern "C" fn quiche_conn_send_ack_eliciting(
|
|
|
1633
1734
|
|
|
1634
1735
|
#[no_mangle]
|
|
1635
1736
|
pub extern "C" fn quiche_conn_send_ack_eliciting_on_path(
|
|
1636
|
-
conn: &mut Connection,
|
|
1637
|
-
|
|
1737
|
+
conn: &mut Connection,
|
|
1738
|
+
local: &sockaddr,
|
|
1739
|
+
local_len: socklen_t,
|
|
1740
|
+
peer: &sockaddr,
|
|
1741
|
+
peer_len: socklen_t,
|
|
1638
1742
|
) -> ssize_t {
|
|
1639
1743
|
let local = std_addr_from_c(local, local_len);
|
|
1640
1744
|
let peer = std_addr_from_c(peer, peer_len);
|
|
@@ -1678,8 +1782,12 @@ pub extern "C" fn quiche_conn_scids_left(conn: &Connection) -> size_t {
|
|
|
1678
1782
|
|
|
1679
1783
|
#[no_mangle]
|
|
1680
1784
|
pub extern "C" fn quiche_conn_new_scid(
|
|
1681
|
-
conn: &mut Connection,
|
|
1682
|
-
|
|
1785
|
+
conn: &mut Connection,
|
|
1786
|
+
scid: *const u8,
|
|
1787
|
+
scid_len: size_t,
|
|
1788
|
+
reset_token: *const u8,
|
|
1789
|
+
retire_if_needed: bool,
|
|
1790
|
+
scid_seq: *mut u64,
|
|
1683
1791
|
) -> c_int {
|
|
1684
1792
|
let scid = unsafe { slice::from_raw_parts(scid, scid_len) };
|
|
1685
1793
|
let scid = ConnectionId::from_ref(scid);
|
|
@@ -1695,15 +1803,13 @@ pub extern "C" fn quiche_conn_new_scid(
|
|
|
1695
1803
|
Ok(c) => {
|
|
1696
1804
|
unsafe { *scid_seq = c }
|
|
1697
1805
|
0
|
|
1698
|
-
}
|
|
1806
|
+
}
|
|
1699
1807
|
Err(e) => e.to_c() as c_int,
|
|
1700
1808
|
}
|
|
1701
1809
|
}
|
|
1702
1810
|
|
|
1703
1811
|
#[no_mangle]
|
|
1704
|
-
pub extern "C" fn quiche_conn_retire_dcid(
|
|
1705
|
-
conn: &mut Connection, dcid_seq: u64,
|
|
1706
|
-
) -> c_int {
|
|
1812
|
+
pub extern "C" fn quiche_conn_retire_dcid(conn: &mut Connection, dcid_seq: u64) -> c_int {
|
|
1707
1813
|
match conn.retire_dcid(dcid_seq) {
|
|
1708
1814
|
Ok(_) => 0,
|
|
1709
1815
|
Err(e) => e.to_c() as c_int,
|
|
@@ -1721,24 +1827,22 @@ pub extern "C" fn quiche_conn_retired_scids(conn: &Connection) -> size_t {
|
|
|
1721
1827
|
}
|
|
1722
1828
|
|
|
1723
1829
|
#[no_mangle]
|
|
1724
|
-
pub extern "C" fn
|
|
1725
|
-
conn: &mut Connection,
|
|
1726
|
-
) ->
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
Some(conn_id) => {
|
|
1731
|
-
let id = conn_id.as_ref();
|
|
1732
|
-
*out = id.as_ptr();
|
|
1733
|
-
*out_len = id.len();
|
|
1734
|
-
true
|
|
1735
|
-
},
|
|
1830
|
+
pub extern "C" fn quiche_conn_retired_scid_iter(
|
|
1831
|
+
conn: &mut Connection,
|
|
1832
|
+
) -> *mut ConnectionIdIter<'_> {
|
|
1833
|
+
let mut cids = Vec::with_capacity(conn.retired_scids());
|
|
1834
|
+
while let Some(cid) = conn.retired_scid_next() {
|
|
1835
|
+
cids.push(cid);
|
|
1736
1836
|
}
|
|
1837
|
+
Box::into_raw(Box::new(ConnectionIdIter { cids, index: 0 }))
|
|
1737
1838
|
}
|
|
1738
1839
|
|
|
1739
1840
|
#[no_mangle]
|
|
1740
1841
|
pub extern "C" fn quiche_conn_send_quantum_on_path(
|
|
1741
|
-
conn: &Connection,
|
|
1842
|
+
conn: &Connection,
|
|
1843
|
+
local: &sockaddr,
|
|
1844
|
+
local_len: socklen_t,
|
|
1845
|
+
peer: &sockaddr,
|
|
1742
1846
|
peer_len: socklen_t,
|
|
1743
1847
|
) -> size_t {
|
|
1744
1848
|
let local = std_addr_from_c(local, local_len);
|
|
@@ -1749,7 +1853,9 @@ pub extern "C" fn quiche_conn_send_quantum_on_path(
|
|
|
1749
1853
|
|
|
1750
1854
|
#[no_mangle]
|
|
1751
1855
|
pub extern "C" fn quiche_conn_paths_iter(
|
|
1752
|
-
conn: &Connection,
|
|
1856
|
+
conn: &Connection,
|
|
1857
|
+
from: &sockaddr,
|
|
1858
|
+
from_len: socklen_t,
|
|
1753
1859
|
) -> *mut SocketAddrIter {
|
|
1754
1860
|
let addr = std_addr_from_c(from, from_len);
|
|
1755
1861
|
|
|
@@ -1758,7 +1864,8 @@ pub extern "C" fn quiche_conn_paths_iter(
|
|
|
1758
1864
|
|
|
1759
1865
|
#[no_mangle]
|
|
1760
1866
|
pub extern "C" fn quiche_socket_addr_iter_next(
|
|
1761
|
-
iter: &mut SocketAddrIter,
|
|
1867
|
+
iter: &mut SocketAddrIter,
|
|
1868
|
+
peer: &mut sockaddr_storage,
|
|
1762
1869
|
peer_len: *mut socklen_t,
|
|
1763
1870
|
) -> bool {
|
|
1764
1871
|
if let Some(v) = iter.next() {
|
|
@@ -1778,7 +1885,10 @@ pub extern "C" fn quiche_socket_addr_iter_free(iter: *mut SocketAddrIter) {
|
|
|
1778
1885
|
|
|
1779
1886
|
#[no_mangle]
|
|
1780
1887
|
pub extern "C" fn quiche_conn_is_path_validated(
|
|
1781
|
-
conn: &Connection,
|
|
1888
|
+
conn: &Connection,
|
|
1889
|
+
from: &sockaddr,
|
|
1890
|
+
from_len: socklen_t,
|
|
1891
|
+
to: &sockaddr,
|
|
1782
1892
|
to_len: socklen_t,
|
|
1783
1893
|
) -> c_int {
|
|
1784
1894
|
let from = std_addr_from_c(from, from_len);
|
|
@@ -1791,8 +1901,12 @@ pub extern "C" fn quiche_conn_is_path_validated(
|
|
|
1791
1901
|
|
|
1792
1902
|
#[no_mangle]
|
|
1793
1903
|
pub extern "C" fn quiche_conn_probe_path(
|
|
1794
|
-
conn: &mut Connection,
|
|
1795
|
-
|
|
1904
|
+
conn: &mut Connection,
|
|
1905
|
+
local: &sockaddr,
|
|
1906
|
+
local_len: socklen_t,
|
|
1907
|
+
peer: &sockaddr,
|
|
1908
|
+
peer_len: socklen_t,
|
|
1909
|
+
seq: *mut u64,
|
|
1796
1910
|
) -> c_int {
|
|
1797
1911
|
let local = std_addr_from_c(local, local_len);
|
|
1798
1912
|
let peer = std_addr_from_c(peer, peer_len);
|
|
@@ -1800,29 +1914,36 @@ pub extern "C" fn quiche_conn_probe_path(
|
|
|
1800
1914
|
Ok(v) => {
|
|
1801
1915
|
unsafe { *seq = v }
|
|
1802
1916
|
0
|
|
1803
|
-
}
|
|
1917
|
+
}
|
|
1804
1918
|
Err(e) => e.to_c() as c_int,
|
|
1805
1919
|
}
|
|
1806
1920
|
}
|
|
1807
1921
|
|
|
1808
1922
|
#[no_mangle]
|
|
1809
1923
|
pub extern "C" fn quiche_conn_migrate_source(
|
|
1810
|
-
conn: &mut Connection,
|
|
1924
|
+
conn: &mut Connection,
|
|
1925
|
+
local: &sockaddr,
|
|
1926
|
+
local_len: socklen_t,
|
|
1927
|
+
seq: *mut u64,
|
|
1811
1928
|
) -> c_int {
|
|
1812
1929
|
let local = std_addr_from_c(local, local_len);
|
|
1813
1930
|
match conn.migrate_source(local) {
|
|
1814
1931
|
Ok(v) => {
|
|
1815
1932
|
unsafe { *seq = v }
|
|
1816
1933
|
0
|
|
1817
|
-
}
|
|
1934
|
+
}
|
|
1818
1935
|
Err(e) => e.to_c() as c_int,
|
|
1819
1936
|
}
|
|
1820
1937
|
}
|
|
1821
1938
|
|
|
1822
1939
|
#[no_mangle]
|
|
1823
1940
|
pub extern "C" fn quiche_conn_migrate(
|
|
1824
|
-
conn: &mut Connection,
|
|
1825
|
-
|
|
1941
|
+
conn: &mut Connection,
|
|
1942
|
+
local: &sockaddr,
|
|
1943
|
+
local_len: socklen_t,
|
|
1944
|
+
peer: &sockaddr,
|
|
1945
|
+
peer_len: socklen_t,
|
|
1946
|
+
seq: *mut u64,
|
|
1826
1947
|
) -> c_int {
|
|
1827
1948
|
let local = std_addr_from_c(local, local_len);
|
|
1828
1949
|
let peer = std_addr_from_c(peer, peer_len);
|
|
@@ -1830,15 +1951,13 @@ pub extern "C" fn quiche_conn_migrate(
|
|
|
1830
1951
|
Ok(v) => {
|
|
1831
1952
|
unsafe { *seq = v }
|
|
1832
1953
|
0
|
|
1833
|
-
}
|
|
1954
|
+
}
|
|
1834
1955
|
Err(e) => e.to_c() as c_int,
|
|
1835
1956
|
}
|
|
1836
1957
|
}
|
|
1837
1958
|
|
|
1838
1959
|
#[no_mangle]
|
|
1839
|
-
pub extern "C" fn quiche_conn_path_event_next(
|
|
1840
|
-
conn: &mut Connection,
|
|
1841
|
-
) -> *mut PathEvent {
|
|
1960
|
+
pub extern "C" fn quiche_conn_path_event_next(conn: &mut Connection) -> *mut PathEvent {
|
|
1842
1961
|
match conn.path_event_next() {
|
|
1843
1962
|
Some(v) => Box::into_raw(Box::new(v)),
|
|
1844
1963
|
None => ptr::null_mut(),
|
|
@@ -1859,20 +1978,24 @@ pub extern "C" fn quiche_path_event_type(ev: &PathEvent) -> u32 {
|
|
|
1859
1978
|
PathEvent::ReusedSourceConnectionId { .. } => 4,
|
|
1860
1979
|
|
|
1861
1980
|
PathEvent::PeerMigrated { .. } => 5,
|
|
1981
|
+
|
|
1982
|
+
PathEvent::PmtuUpdated { .. } => 6,
|
|
1862
1983
|
}
|
|
1863
1984
|
}
|
|
1864
1985
|
|
|
1865
1986
|
#[no_mangle]
|
|
1866
1987
|
pub extern "C" fn quiche_path_event_new(
|
|
1867
|
-
ev: &PathEvent,
|
|
1868
|
-
|
|
1988
|
+
ev: &PathEvent,
|
|
1989
|
+
local_addr: &mut sockaddr_storage,
|
|
1990
|
+
local_addr_len: &mut socklen_t,
|
|
1991
|
+
peer_addr: &mut sockaddr_storage,
|
|
1869
1992
|
peer_addr_len: &mut socklen_t,
|
|
1870
1993
|
) {
|
|
1871
1994
|
match ev {
|
|
1872
1995
|
PathEvent::New(local, peer) => {
|
|
1873
1996
|
*local_addr_len = std_addr_to_c(local, local_addr);
|
|
1874
1997
|
*peer_addr_len = std_addr_to_c(peer, peer_addr)
|
|
1875
|
-
}
|
|
1998
|
+
}
|
|
1876
1999
|
|
|
1877
2000
|
_ => unreachable!(),
|
|
1878
2001
|
}
|
|
@@ -1880,15 +2003,17 @@ pub extern "C" fn quiche_path_event_new(
|
|
|
1880
2003
|
|
|
1881
2004
|
#[no_mangle]
|
|
1882
2005
|
pub extern "C" fn quiche_path_event_validated(
|
|
1883
|
-
ev: &PathEvent,
|
|
1884
|
-
|
|
2006
|
+
ev: &PathEvent,
|
|
2007
|
+
local_addr: &mut sockaddr_storage,
|
|
2008
|
+
local_addr_len: &mut socklen_t,
|
|
2009
|
+
peer_addr: &mut sockaddr_storage,
|
|
1885
2010
|
peer_addr_len: &mut socklen_t,
|
|
1886
2011
|
) {
|
|
1887
2012
|
match ev {
|
|
1888
2013
|
PathEvent::Validated(local, peer) => {
|
|
1889
2014
|
*local_addr_len = std_addr_to_c(local, local_addr);
|
|
1890
2015
|
*peer_addr_len = std_addr_to_c(peer, peer_addr)
|
|
1891
|
-
}
|
|
2016
|
+
}
|
|
1892
2017
|
|
|
1893
2018
|
_ => unreachable!(),
|
|
1894
2019
|
}
|
|
@@ -1896,15 +2021,17 @@ pub extern "C" fn quiche_path_event_validated(
|
|
|
1896
2021
|
|
|
1897
2022
|
#[no_mangle]
|
|
1898
2023
|
pub extern "C" fn quiche_path_event_failed_validation(
|
|
1899
|
-
ev: &PathEvent,
|
|
1900
|
-
|
|
2024
|
+
ev: &PathEvent,
|
|
2025
|
+
local_addr: &mut sockaddr_storage,
|
|
2026
|
+
local_addr_len: &mut socklen_t,
|
|
2027
|
+
peer_addr: &mut sockaddr_storage,
|
|
1901
2028
|
peer_addr_len: &mut socklen_t,
|
|
1902
2029
|
) {
|
|
1903
2030
|
match ev {
|
|
1904
2031
|
PathEvent::FailedValidation(local, peer) => {
|
|
1905
2032
|
*local_addr_len = std_addr_to_c(local, local_addr);
|
|
1906
2033
|
*peer_addr_len = std_addr_to_c(peer, peer_addr)
|
|
1907
|
-
}
|
|
2034
|
+
}
|
|
1908
2035
|
|
|
1909
2036
|
_ => unreachable!(),
|
|
1910
2037
|
}
|
|
@@ -1912,15 +2039,17 @@ pub extern "C" fn quiche_path_event_failed_validation(
|
|
|
1912
2039
|
|
|
1913
2040
|
#[no_mangle]
|
|
1914
2041
|
pub extern "C" fn quiche_path_event_closed(
|
|
1915
|
-
ev: &PathEvent,
|
|
1916
|
-
|
|
2042
|
+
ev: &PathEvent,
|
|
2043
|
+
local_addr: &mut sockaddr_storage,
|
|
2044
|
+
local_addr_len: &mut socklen_t,
|
|
2045
|
+
peer_addr: &mut sockaddr_storage,
|
|
1917
2046
|
peer_addr_len: &mut socklen_t,
|
|
1918
2047
|
) {
|
|
1919
2048
|
match ev {
|
|
1920
2049
|
PathEvent::Closed(local, peer) => {
|
|
1921
2050
|
*local_addr_len = std_addr_to_c(local, local_addr);
|
|
1922
2051
|
*peer_addr_len = std_addr_to_c(peer, peer_addr)
|
|
1923
|
-
}
|
|
2052
|
+
}
|
|
1924
2053
|
|
|
1925
2054
|
_ => unreachable!(),
|
|
1926
2055
|
}
|
|
@@ -1928,11 +2057,16 @@ pub extern "C" fn quiche_path_event_closed(
|
|
|
1928
2057
|
|
|
1929
2058
|
#[no_mangle]
|
|
1930
2059
|
pub extern "C" fn quiche_path_event_reused_source_connection_id(
|
|
1931
|
-
ev: &PathEvent,
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
2060
|
+
ev: &PathEvent,
|
|
2061
|
+
cid_sequence_number: &mut u64,
|
|
2062
|
+
old_local_addr: &mut sockaddr_storage,
|
|
2063
|
+
old_local_addr_len: &mut socklen_t,
|
|
2064
|
+
old_peer_addr: &mut sockaddr_storage,
|
|
2065
|
+
old_peer_addr_len: &mut socklen_t,
|
|
2066
|
+
local_addr: &mut sockaddr_storage,
|
|
2067
|
+
local_addr_len: &mut socklen_t,
|
|
2068
|
+
peer_addr: &mut sockaddr_storage,
|
|
2069
|
+
peer_addr_len: &mut socklen_t,
|
|
1936
2070
|
) {
|
|
1937
2071
|
match ev {
|
|
1938
2072
|
PathEvent::ReusedSourceConnectionId(id, old, new) => {
|
|
@@ -1942,7 +2076,7 @@ pub extern "C" fn quiche_path_event_reused_source_connection_id(
|
|
|
1942
2076
|
|
|
1943
2077
|
*local_addr_len = std_addr_to_c(&new.0, local_addr);
|
|
1944
2078
|
*peer_addr_len = std_addr_to_c(&new.1, peer_addr)
|
|
1945
|
-
}
|
|
2079
|
+
}
|
|
1946
2080
|
|
|
1947
2081
|
_ => unreachable!(),
|
|
1948
2082
|
}
|
|
@@ -1950,15 +2084,41 @@ pub extern "C" fn quiche_path_event_reused_source_connection_id(
|
|
|
1950
2084
|
|
|
1951
2085
|
#[no_mangle]
|
|
1952
2086
|
pub extern "C" fn quiche_path_event_peer_migrated(
|
|
1953
|
-
ev: &PathEvent,
|
|
1954
|
-
|
|
2087
|
+
ev: &PathEvent,
|
|
2088
|
+
local_addr: &mut sockaddr_storage,
|
|
2089
|
+
local_addr_len: &mut socklen_t,
|
|
2090
|
+
peer_addr: &mut sockaddr_storage,
|
|
1955
2091
|
peer_addr_len: &mut socklen_t,
|
|
1956
2092
|
) {
|
|
1957
2093
|
match ev {
|
|
1958
2094
|
PathEvent::PeerMigrated(local, peer) => {
|
|
1959
2095
|
*local_addr_len = std_addr_to_c(local, local_addr);
|
|
1960
2096
|
*peer_addr_len = std_addr_to_c(peer, peer_addr);
|
|
1961
|
-
}
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
_ => unreachable!(),
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
#[no_mangle]
|
|
2104
|
+
pub extern "C" fn quiche_path_event_pmtu_updated(
|
|
2105
|
+
ev: &PathEvent,
|
|
2106
|
+
local_addr: &mut sockaddr_storage,
|
|
2107
|
+
local_addr_len: &mut socklen_t,
|
|
2108
|
+
peer_addr: &mut sockaddr_storage,
|
|
2109
|
+
peer_addr_len: &mut socklen_t,
|
|
2110
|
+
pmtu: &mut size_t,
|
|
2111
|
+
) {
|
|
2112
|
+
match ev {
|
|
2113
|
+
PathEvent::PmtuUpdated {
|
|
2114
|
+
local,
|
|
2115
|
+
peer,
|
|
2116
|
+
pmtu: value,
|
|
2117
|
+
} => {
|
|
2118
|
+
*local_addr_len = std_addr_to_c(local, local_addr);
|
|
2119
|
+
*peer_addr_len = std_addr_to_c(peer, peer_addr);
|
|
2120
|
+
*pmtu = *value;
|
|
2121
|
+
}
|
|
1962
2122
|
|
|
1963
2123
|
_ => unreachable!(),
|
|
1964
2124
|
}
|
|
@@ -1972,9 +2132,7 @@ pub extern "C" fn quiche_path_event_free(ev: *mut PathEvent) {
|
|
|
1972
2132
|
}
|
|
1973
2133
|
|
|
1974
2134
|
#[no_mangle]
|
|
1975
|
-
pub extern "C" fn quiche_put_varint(
|
|
1976
|
-
buf: *mut u8, buf_len: size_t, val: u64,
|
|
1977
|
-
) -> c_int {
|
|
2135
|
+
pub extern "C" fn quiche_put_varint(buf: *mut u8, buf_len: size_t, val: u64) -> c_int {
|
|
1978
2136
|
let buf = unsafe { slice::from_raw_parts_mut(buf, buf_len) };
|
|
1979
2137
|
|
|
1980
2138
|
let mut b = octets::OctetsMut::with_slice(buf);
|
|
@@ -1984,14 +2142,12 @@ pub extern "C" fn quiche_put_varint(
|
|
|
1984
2142
|
Err(e) => {
|
|
1985
2143
|
let err: Error = e.into();
|
|
1986
2144
|
err.to_c() as c_int
|
|
1987
|
-
}
|
|
2145
|
+
}
|
|
1988
2146
|
}
|
|
1989
2147
|
}
|
|
1990
2148
|
|
|
1991
2149
|
#[no_mangle]
|
|
1992
|
-
pub extern "C" fn quiche_get_varint(
|
|
1993
|
-
buf: *const u8, buf_len: size_t, val: *mut u64,
|
|
1994
|
-
) -> ssize_t {
|
|
2150
|
+
pub extern "C" fn quiche_get_varint(buf: *const u8, buf_len: size_t, val: *mut u64) -> ssize_t {
|
|
1995
2151
|
let buf = unsafe { slice::from_raw_parts(buf, buf_len) };
|
|
1996
2152
|
|
|
1997
2153
|
let mut b = octets::Octets::with_slice(buf);
|
|
@@ -2001,15 +2157,13 @@ pub extern "C" fn quiche_get_varint(
|
|
|
2001
2157
|
Err(e) => {
|
|
2002
2158
|
let err: Error = e.into();
|
|
2003
2159
|
return err.to_c();
|
|
2004
|
-
}
|
|
2160
|
+
}
|
|
2005
2161
|
};
|
|
2006
2162
|
|
|
2007
2163
|
b.off() as ssize_t
|
|
2008
2164
|
}
|
|
2009
2165
|
|
|
2010
|
-
fn optional_std_addr_from_c(
|
|
2011
|
-
addr: *const sockaddr, addr_len: socklen_t,
|
|
2012
|
-
) -> Option<SocketAddr> {
|
|
2166
|
+
fn optional_std_addr_from_c(addr: *const sockaddr, addr_len: socklen_t) -> Option<SocketAddr> {
|
|
2013
2167
|
if addr.is_null() || addr_len == 0 {
|
|
2014
2168
|
return None;
|
|
2015
2169
|
}
|
|
@@ -2030,12 +2184,7 @@ fn std_addr_from_c(addr: &sockaddr, addr_len: socklen_t) -> SocketAddr {
|
|
|
2030
2184
|
let ip_addr = {
|
|
2031
2185
|
let ip_bytes = unsafe { in4.sin_addr.S_un.S_un_b };
|
|
2032
2186
|
|
|
2033
|
-
Ipv4Addr::from([
|
|
2034
|
-
ip_bytes.s_b1,
|
|
2035
|
-
ip_bytes.s_b2,
|
|
2036
|
-
ip_bytes.s_b3,
|
|
2037
|
-
ip_bytes.s_b4,
|
|
2038
|
-
])
|
|
2187
|
+
Ipv4Addr::from([ip_bytes.s_b1, ip_bytes.s_b2, ip_bytes.s_b3, ip_bytes.s_b4])
|
|
2039
2188
|
};
|
|
2040
2189
|
|
|
2041
2190
|
let port = u16::from_be(in4.sin_port);
|
|
@@ -2043,7 +2192,7 @@ fn std_addr_from_c(addr: &sockaddr, addr_len: socklen_t) -> SocketAddr {
|
|
|
2043
2192
|
let out = SocketAddrV4::new(ip_addr, port);
|
|
2044
2193
|
|
|
2045
2194
|
out.into()
|
|
2046
|
-
}
|
|
2195
|
+
}
|
|
2047
2196
|
|
|
2048
2197
|
AF_INET6 => {
|
|
2049
2198
|
assert!(addr_len as usize == size_of::<sockaddr_in6>());
|
|
@@ -2066,11 +2215,10 @@ fn std_addr_from_c(addr: &sockaddr, addr_len: socklen_t) -> SocketAddr {
|
|
|
2066
2215
|
#[cfg(windows)]
|
|
2067
2216
|
let scope_id = unsafe { in6.Anonymous.sin6_scope_id };
|
|
2068
2217
|
|
|
2069
|
-
let out =
|
|
2070
|
-
SocketAddrV6::new(ip_addr, port, in6.sin6_flowinfo, scope_id);
|
|
2218
|
+
let out = SocketAddrV6::new(ip_addr, port, in6.sin6_flowinfo, scope_id);
|
|
2071
2219
|
|
|
2072
2220
|
out.into()
|
|
2073
|
-
}
|
|
2221
|
+
}
|
|
2074
2222
|
|
|
2075
2223
|
_ => unimplemented!("unsupported address type"),
|
|
2076
2224
|
}
|
|
@@ -2167,8 +2315,7 @@ fn std_addr_to_c(addr: &SocketAddr, out: &mut sockaddr_storage) -> socklen_t {
|
|
|
2167
2315
|
|
|
2168
2316
|
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "windows")))]
|
|
2169
2317
|
fn std_time_to_c(time: &Instant, out: &mut timespec) {
|
|
2170
|
-
const INSTANT_ZERO: Instant =
|
|
2171
|
-
unsafe { std::mem::transmute(std::time::UNIX_EPOCH) };
|
|
2318
|
+
const INSTANT_ZERO: Instant = unsafe { std::mem::transmute(std::time::UNIX_EPOCH) };
|
|
2172
2319
|
|
|
2173
2320
|
let raw_time = time.duration_since(INSTANT_ZERO);
|
|
2174
2321
|
|
|
@@ -2191,6 +2338,43 @@ mod tests {
|
|
|
2191
2338
|
#[cfg(windows)]
|
|
2192
2339
|
use windows_sys::Win32::Networking::WinSock::inet_ntop;
|
|
2193
2340
|
|
|
2341
|
+
#[test]
|
|
2342
|
+
fn pmtu_updated_path_event() {
|
|
2343
|
+
let local = "127.0.0.1:8080".parse().unwrap();
|
|
2344
|
+
let peer = "127.0.0.2:443".parse().unwrap();
|
|
2345
|
+
|
|
2346
|
+
let event = PathEvent::PmtuUpdated {
|
|
2347
|
+
local,
|
|
2348
|
+
peer,
|
|
2349
|
+
pmtu: 1400,
|
|
2350
|
+
};
|
|
2351
|
+
assert_eq!(quiche_path_event_type(&event), 6);
|
|
2352
|
+
|
|
2353
|
+
let mut local_out: sockaddr_storage = unsafe { std::mem::zeroed() };
|
|
2354
|
+
let mut peer_out: sockaddr_storage = unsafe { std::mem::zeroed() };
|
|
2355
|
+
let mut local_len = 0;
|
|
2356
|
+
let mut peer_len = 0;
|
|
2357
|
+
let mut pmtu = usize::MAX;
|
|
2358
|
+
|
|
2359
|
+
quiche_path_event_pmtu_updated(
|
|
2360
|
+
&event,
|
|
2361
|
+
&mut local_out,
|
|
2362
|
+
&mut local_len,
|
|
2363
|
+
&mut peer_out,
|
|
2364
|
+
&mut peer_len,
|
|
2365
|
+
&mut pmtu,
|
|
2366
|
+
);
|
|
2367
|
+
assert_eq!(pmtu, 1400);
|
|
2368
|
+
assert_eq!(
|
|
2369
|
+
unsafe { std_addr_from_c(&*(&local_out as *const _ as *const sockaddr), local_len,) },
|
|
2370
|
+
local
|
|
2371
|
+
);
|
|
2372
|
+
assert_eq!(
|
|
2373
|
+
unsafe { std_addr_from_c(&*(&peer_out as *const _ as *const sockaddr), peer_len,) },
|
|
2374
|
+
peer
|
|
2375
|
+
);
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2194
2378
|
#[test]
|
|
2195
2379
|
fn addr_v4() {
|
|
2196
2380
|
let addr = "127.0.0.1:8080".parse().unwrap();
|
|
@@ -2245,8 +2429,7 @@ mod tests {
|
|
|
2245
2429
|
size_of::<sockaddr_in6>() as socklen_t
|
|
2246
2430
|
);
|
|
2247
2431
|
|
|
2248
|
-
let s =
|
|
2249
|
-
ffi::CString::new("dddd:dddd:dddd:dddd:dddd:dddd:dddd:dddd").unwrap();
|
|
2432
|
+
let s = ffi::CString::new("dddd:dddd:dddd:dddd:dddd:dddd:dddd:dddd").unwrap();
|
|
2250
2433
|
|
|
2251
2434
|
let s = unsafe {
|
|
2252
2435
|
let in6_addr = &out as *const _ as *const sockaddr_in6;
|
|
@@ -2281,10 +2464,105 @@ mod tests {
|
|
|
2281
2464
|
);
|
|
2282
2465
|
}
|
|
2283
2466
|
|
|
2467
|
+
#[test]
|
|
2468
|
+
fn connection_id_iter_next() {
|
|
2469
|
+
let cids = vec![
|
|
2470
|
+
ConnectionId::from_vec(vec![1, 2, 3, 4]),
|
|
2471
|
+
ConnectionId::from_vec(vec![5, 6]),
|
|
2472
|
+
];
|
|
2473
|
+
|
|
2474
|
+
let mut iter = ConnectionIdIter { cids, index: 0 };
|
|
2475
|
+
|
|
2476
|
+
let mut out: *const u8 = ptr::null();
|
|
2477
|
+
let mut out_len: size_t = 0;
|
|
2478
|
+
|
|
2479
|
+
// First CID.
|
|
2480
|
+
assert!(quiche_connection_id_iter_next(
|
|
2481
|
+
&mut iter,
|
|
2482
|
+
&mut out,
|
|
2483
|
+
&mut out_len
|
|
2484
|
+
));
|
|
2485
|
+
assert_eq!(out_len, 4);
|
|
2486
|
+
let slice = unsafe { slice::from_raw_parts(out, out_len) };
|
|
2487
|
+
assert_eq!(slice, &[1, 2, 3, 4]);
|
|
2488
|
+
|
|
2489
|
+
// Second CID.
|
|
2490
|
+
assert!(quiche_connection_id_iter_next(
|
|
2491
|
+
&mut iter,
|
|
2492
|
+
&mut out,
|
|
2493
|
+
&mut out_len
|
|
2494
|
+
));
|
|
2495
|
+
assert_eq!(out_len, 2);
|
|
2496
|
+
let slice = unsafe { slice::from_raw_parts(out, out_len) };
|
|
2497
|
+
assert_eq!(slice, &[5, 6]);
|
|
2498
|
+
|
|
2499
|
+
// Exhausted.
|
|
2500
|
+
assert!(!quiche_connection_id_iter_next(
|
|
2501
|
+
&mut iter,
|
|
2502
|
+
&mut out,
|
|
2503
|
+
&mut out_len
|
|
2504
|
+
));
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
#[test]
|
|
2508
|
+
fn retired_scid_iter() {
|
|
2509
|
+
let mut config = Config::new(PROTOCOL_VERSION).unwrap();
|
|
2510
|
+
config
|
|
2511
|
+
.load_cert_chain_from_pem_file("examples/cert.crt")
|
|
2512
|
+
.unwrap();
|
|
2513
|
+
config
|
|
2514
|
+
.load_priv_key_from_pem_file("examples/cert.key")
|
|
2515
|
+
.unwrap();
|
|
2516
|
+
config
|
|
2517
|
+
.set_application_protos(&[b"proto1", b"proto2"])
|
|
2518
|
+
.unwrap();
|
|
2519
|
+
config.verify_peer(false);
|
|
2520
|
+
config.set_active_connection_id_limit(2);
|
|
2521
|
+
|
|
2522
|
+
let mut pipe = test_utils::Pipe::with_config(&mut config).unwrap();
|
|
2523
|
+
assert_eq!(pipe.handshake(), Ok(()));
|
|
2524
|
+
|
|
2525
|
+
let scid = pipe.client.source_id().into_owned();
|
|
2526
|
+
|
|
2527
|
+
let (scid_1, reset_token_1) = test_utils::create_cid_and_reset_token(16);
|
|
2528
|
+
assert_eq!(pipe.client.new_scid(&scid_1, reset_token_1, false), Ok(1));
|
|
2529
|
+
assert_eq!(pipe.advance(), Ok(()));
|
|
2530
|
+
|
|
2531
|
+
// Retire the initial SCID by advertising a new one with
|
|
2532
|
+
// retire_prior_to.
|
|
2533
|
+
let (scid_2, reset_token_2) = test_utils::create_cid_and_reset_token(16);
|
|
2534
|
+
assert_eq!(pipe.client.new_scid(&scid_2, reset_token_2, true), Ok(2));
|
|
2535
|
+
assert_eq!(pipe.advance(), Ok(()));
|
|
2536
|
+
|
|
2537
|
+
// Use the FFI iterator to collect retired SCIDs.
|
|
2538
|
+
let iter = quiche_conn_retired_scid_iter(&mut pipe.client);
|
|
2539
|
+
let iter = unsafe { &mut *iter };
|
|
2540
|
+
|
|
2541
|
+
let mut out: *const u8 = ptr::null();
|
|
2542
|
+
let mut out_len: size_t = 0;
|
|
2543
|
+
|
|
2544
|
+
// The initial SCID should have been retired.
|
|
2545
|
+
assert!(quiche_connection_id_iter_next(iter, &mut out, &mut out_len));
|
|
2546
|
+
let slice = unsafe { slice::from_raw_parts(out, out_len) };
|
|
2547
|
+
assert_eq!(slice, scid.as_ref());
|
|
2548
|
+
|
|
2549
|
+
// No more retired SCIDs.
|
|
2550
|
+
assert!(!quiche_connection_id_iter_next(
|
|
2551
|
+
iter,
|
|
2552
|
+
&mut out,
|
|
2553
|
+
&mut out_len
|
|
2554
|
+
));
|
|
2555
|
+
|
|
2556
|
+
quiche_connection_id_iter_free(iter);
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2284
2559
|
#[cfg(not(windows))]
|
|
2285
2560
|
extern "C" {
|
|
2286
2561
|
fn inet_ntop(
|
|
2287
|
-
af: c_int,
|
|
2562
|
+
af: c_int,
|
|
2563
|
+
src: *const c_void,
|
|
2564
|
+
dst: *mut c_char,
|
|
2565
|
+
size: socklen_t,
|
|
2288
2566
|
) -> *mut c_char;
|
|
2289
2567
|
}
|
|
2290
2568
|
}
|