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

ffi: expose Server Name Indication to FFI #1895

Merged
merged 1 commit into from
Jan 22, 2025
Merged
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
3 changes: 3 additions & 0 deletions quiche/include/quiche.h
Original file line number Diff line number Diff line change
@@ -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);

14 changes: 14 additions & 0 deletions quiche/src/ffi.rs
Original file line number Diff line number Diff line change
@@ -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()

Unchanged files with check annotations Beta

/// * [`send_body()`] with same `stream_id`.
///
/// Additional headers can only be sent during certain phases of an HTTP/3
/// message exchange, see [Section 4.1 of RFC 9114]. The [`FrameUnexpected`]

Check warning on line 1169 in quiche/src/h3/mod.rs

GitHub Actions / quiche

unresolved link to `FrameUnexpected`
/// error is returned if this method, or [`send_response_with_priority()`],
/// are called multiple times with the same `stream_id` value.
///
/// suites which depend heavily on h3i.
///
/// The specific CONNECTION_CLOSE frame can be customized by passing a
/// [`ConnectionError`] to [`Self::new_with_close`]. h3i will send an

Check warning on line 324 in h3i/src/client/connection_summary.rs

GitHub Actions / quiche

unresolved link to `Self::new_with_close`
/// application CONNECTION_CLOSE frame with error code 0x100 if this struct is
/// constructed with the [`Self::new`] constructor.
#[derive(Clone, Serialize, Debug)]
/// For Headers variants, this [`CloseTriggerFrame`] is equivalent to the
/// incoming [`H3iFrame`] if the [`H3iFrame`] contains all [`Header`]s
/// in _this_ frame. In other words, `this` can be considered equivalent
/// to `other` if `other` contains a superset of `this`'s [`Headers`].

Check warning on line 493 in h3i/src/frame.rs

GitHub Actions / quiche

unresolved link to `Headers`
///
/// This allows users for fuzzy-matching on header frames without needing to
/// supply every individual header on the frame.
/// The ID for an HTTP/3 control stream type.
///
/// See https://datatracker.ietf.org/doc/html/rfc9114#name-control-streams.

Check warning on line 166 in h3i/src/lib.rs

GitHub Actions / quiche

this URL is not a hyperlink
pub const HTTP3_CONTROL_STREAM_TYPE_ID: u64 = 0x0;
/// The ID for an HTTP/3 push stream type.
///
/// See https://datatracker.ietf.org/doc/html/rfc9114#name-push-streams.

Check warning on line 171 in h3i/src/lib.rs

GitHub Actions / quiche

this URL is not a hyperlink
pub const HTTP3_PUSH_STREAM_TYPE_ID: u64 = 0x1;
/// The ID for a QPACK encoder stream type.
///
/// See https://datatracker.ietf.org/doc/html/rfc9204#section-4.2-2.1.

Check warning on line 176 in h3i/src/lib.rs

GitHub Actions / quiche

this URL is not a hyperlink
pub const QPACK_ENCODER_STREAM_TYPE_ID: u64 = 0x2;
/// The ID for a QPACK decoder stream type.
///
/// See https://datatracker.ietf.org/doc/html/rfc9204#section-4.2-2.2.

Check warning on line 181 in h3i/src/lib.rs

GitHub Actions / quiche

this URL is not a hyperlink
pub const QPACK_DECODER_STREAM_TYPE_ID: u64 = 0x3;
#[derive(Default)]