Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quiche_conn_new_scid(...) implementation #1670

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions quiche/include/quiche.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,10 @@ size_t quiche_conn_scids_left(quiche_conn *conn);
size_t quiche_conn_active_scids(quiche_conn *conn);

// Provides additional source Connection IDs that the peer can use to reach
// this host.
uint64_t quiche_conn_new_scid(quiche_conn *conn,
// this host. Writes the sequence number to "scid_seq" and returns 0.
int quiche_conn_new_scid(quiche_conn *conn,
const uint8_t *scid, size_t scid_len,
const uint8_t *reset_token, bool retire_if_needed);
const uint8_t *reset_token, bool retire_if_needed, uint64_t *scid_seq);

enum quiche_path_event_type {
QUICHE_PATH_EVENT_NEW,
Expand Down
12 changes: 7 additions & 5 deletions quiche/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,8 +1410,8 @@ pub extern fn quiche_conn_scids_left(conn: &Connection) -> size_t {
#[no_mangle]
pub extern fn quiche_conn_new_scid(
conn: &mut Connection, scid: *const u8, scid_len: size_t,
reset_token: *const u8, retire_if_needed: bool,
) -> u64 {
reset_token: *const u8, retire_if_needed: bool, scid_seq: *mut u64,
) -> c_int {
let scid = unsafe { slice::from_raw_parts(scid, scid_len) };
let scid = ConnectionId::from_ref(scid);

Expand All @@ -1423,9 +1423,11 @@ pub extern fn quiche_conn_new_scid(
let reset_token = u128::from_be_bytes(reset_token);

match conn.new_scid(&scid, reset_token, retire_if_needed) {
Ok(c) => c,

Err(e) => e.to_c() as u64,
Ok(c) => {
unsafe { *scid_seq = c }
0
},
Err(e) => e.to_c() as c_int,
}
}

Expand Down
Loading