Skip to content

Commit

Permalink
ffi: add missing config APIs
Browse files Browse the repository at this point in the history
Motivation:

set_disable_dcid_reuse(...) and quiche_config_set_ticket_key(...) are not exposed via the c API.

Modifications:

Add FFI implementation and add functions to c header file.

Result:

Add missing config methods
  • Loading branch information
normanmaurer authored Dec 11, 2023
1 parent 665d459 commit 3d54e05
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions quiche/include/quiche.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ void quiche_config_set_active_connection_id_limit(quiche_config *config, uint64_
// Sets the initial stateless reset token. |v| must contain 16 bytes, otherwise the behaviour is undefined.
void quiche_config_set_stateless_reset_token(quiche_config *config, const uint8_t *v);

// Sets whether the QUIC connection should avoid reusing DCIDs over different paths.
void quiche_config_set_disable_dcid_reuse(quiche_config *config, bool v);

// Configures the session ticket key material.
int quiche_config_set_ticket_key(quiche_config *config, const uint8_t *key, size_t key_len);

// Frees the config object.
void quiche_config_free(quiche_config *config);

Expand Down
18 changes: 18 additions & 0 deletions quiche/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,24 @@ pub extern fn quiche_config_set_stateless_reset_token(
config.set_stateless_reset_token(Some(reset_token));
}

#[no_mangle]
pub extern fn quiche_config_set_disable_dcid_reuse(config: &mut Config, v: bool) {
config.set_disable_dcid_reuse(v);
}

#[no_mangle]
pub extern fn quiche_config_set_ticket_key(
config: &mut Config, key: *const u8, key_len: size_t,
) -> c_int {
let key = unsafe { slice::from_raw_parts(key, key_len) };

match config.set_ticket_key(key) {
Ok(_) => 0,

Err(e) => e.to_c() as c_int,
}
}

#[no_mangle]
pub extern fn quiche_config_free(config: *mut Config) {
drop(unsafe { Box::from_raw(config) });
Expand Down

0 comments on commit 3d54e05

Please sign in to comment.