Skip to content

Commit

Permalink
Expose functions related to client side connection migration via c API
Browse files Browse the repository at this point in the history
Motivation:

Quiche didnt expose all methods via c functions that are required to start connection migration.

Modifications:

Add missing ffi implementatins and add functions to c header file.

Result:

Be able to do connection migration on the client side.
  • Loading branch information
normanmaurer committed Nov 27, 2023
1 parent 5796adc commit 8d86720
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
14 changes: 14 additions & 0 deletions quiche/include/quiche.h
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,20 @@ uint64_t quiche_conn_new_scid(quiche_conn *conn,
const uint8_t *scid, size_t scid_len,
const uint8_t *reset_token, bool retire_if_needed);

// Requests the stack to perform path validation of the proposed 4-tuple.
uint64_t quiche_conn_probe_path(quiche_conn *conn,
const struct sockaddr *local, socklen_t local_len,
const struct sockaddr *peer, socklen_t peer_len);

// Migrates the connection to a new local address.
uint64_t quiche_conn_migrate_source(quiche_conn *conn, const struct sockaddr *local, socklen_t local_len);

// Migrates the connection over the given network path between "local"
// and "peer".
uint64_t quiche_conn_migrate(quiche_conn *conn,
const struct sockaddr *local, socklen_t local_len,
const struct sockaddr *peer, socklen_t peer_len);

enum quiche_path_event_type {
QUICHE_PATH_EVENT_NEW,
QUICHE_PATH_EVENT_VALIDATED,
Expand Down
37 changes: 37 additions & 0 deletions quiche/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,43 @@ pub extern fn quiche_conn_retired_scid_next(
}
}

#[no_mangle]
pub extern fn quiche_conn_probe_path(
conn: &mut Connection, local: &sockaddr, local_len: socklen_t,
peer: &sockaddr, peer_len: socklen_t,
) -> u64 {
let local = std_addr_from_c(local, local_len);
let peer = std_addr_from_c(peer, peer_len);
match conn.probe_path(local, peer) {
Ok(v) => v,
Err(e) => e.to_c() as u64,
}
}

#[no_mangle]
pub extern fn quiche_conn_migrate_source(
conn: &mut Connection, local: &sockaddr, local_len: socklen_t,
) -> u64 {
let local = std_addr_from_c(local, local_len);
match conn.migrate_source(local) {
Ok(v) => v,
Err(e) => e.to_c() as u64,
}
}

#[no_mangle]
pub extern fn quiche_conn_migrate(
conn: &mut Connection, local: &sockaddr, local_len: socklen_t,
peer: &sockaddr, peer_len: socklen_t,
) -> u64 {
let local = std_addr_from_c(local, local_len);
let peer = std_addr_from_c(peer, peer_len);
match conn.migrate(local, peer) {
Ok(v) => v,
Err(e) => e.to_c() as u64,
}
}

#[no_mangle]
pub extern fn quiche_conn_path_event_next(
conn: &mut Connection,
Expand Down

0 comments on commit 8d86720

Please sign in to comment.