Skip to content

Commit

Permalink
ffi: expose Server Name Indication to FFI
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne authored and ghedo committed Jan 22, 2025
1 parent ced0d07 commit 659a49e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions quiche/include/quiche.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ void quiche_conn_peer_cert(const quiche_conn *conn, const uint8_t **out, size_t
// Returns the serialized cryptographic session for the connection.
void quiche_conn_session(const quiche_conn *conn, const uint8_t **out, size_t *out_len);

// Returns the server name requested by the client.
void quiche_conn_server_name(const quiche_conn *conn, const uint8_t **out, size_t *out_len);

// Returns true if the connection handshake is complete.
bool quiche_conn_is_established(const quiche_conn *conn);

Expand Down
14 changes: 14 additions & 0 deletions quiche/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,20 @@ pub extern "C" fn quiche_conn_session(
}
}

#[no_mangle]
pub extern "C" fn quiche_conn_server_name(
conn: &Connection, out: &mut *const u8, out_len: &mut size_t,
) {
match conn.server_name() {
Some(server_name) => {
*out = server_name.as_ptr();
*out_len = server_name.len();
},

None => *out_len = 0,
}
}

#[no_mangle]
pub extern "C" fn quiche_conn_is_established(conn: &Connection) -> bool {
conn.is_established()
Expand Down

0 comments on commit 659a49e

Please sign in to comment.