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 committed Jan 7, 2025
1 parent 57915e6 commit 73e8059
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 @@ -485,6 +485,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 @@ -1117,6 +1117,20 @@ pub extern fn quiche_conn_session(
}
}

#[no_mangle]
pub extern 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 fn quiche_conn_is_established(conn: &Connection) -> bool {
conn.is_established()
Expand Down

0 comments on commit 73e8059

Please sign in to comment.