diff options
-rw-r--r-- | include/quiche.h | 6 | ||||
-rw-r--r-- | src/ffi.rs | 27 |
2 files changed, 33 insertions, 0 deletions
diff --git a/include/quiche.h b/include/quiche.h index a49f37a1..e8c46b58 100644 --- a/include/quiche.h +++ b/include/quiche.h @@ -256,6 +256,9 @@ bool quiche_conn_set_qlog_path(quiche_conn *conn, const char *path, void quiche_conn_set_qlog_fd(quiche_conn *conn, int fd, const char *log_title, const char *log_desc); +// Configures the given session for resumption. +int quiche_conn_set_session(quiche_conn *conn, const uint8_t *buf, size_t buf_len); + // Processes QUIC packets received from the peer. ssize_t quiche_conn_recv(quiche_conn *conn, uint8_t *buf, size_t buf_len); @@ -321,6 +324,9 @@ void quiche_conn_trace_id(quiche_conn *conn, const uint8_t **out, size_t *out_le void quiche_conn_application_proto(quiche_conn *conn, const uint8_t **out, size_t *out_len); +// Returns the serialized cryptographic session for the connection. +void quiche_conn_session(quiche_conn *conn, const uint8_t **out, size_t *out_len); + // Returns true if the connection handshake is complete. bool quiche_conn_is_established(quiche_conn *conn); @@ -540,6 +540,19 @@ pub extern fn quiche_conn_set_qlog_fd( } #[no_mangle] +pub extern fn quiche_conn_set_session( + conn: &mut Connection, buf: *const u8, buf_len: size_t, +) -> c_int { + let buf = unsafe { slice::from_raw_parts(buf, buf_len) }; + + match conn.set_session(buf) { + Ok(_) => 0, + + Err(e) => e.to_c() as c_int, + } +} + +#[no_mangle] pub extern fn quiche_conn_recv( conn: &mut Connection, buf: *mut u8, buf_len: size_t, ) -> ssize_t { @@ -764,6 +777,20 @@ pub extern fn quiche_conn_application_proto( } #[no_mangle] +pub extern fn quiche_conn_session( + conn: &mut Connection, out: &mut *const u8, out_len: &mut size_t, +) { + match conn.session() { + Some(session) => { + *out = session.as_ptr(); + *out_len = session.len(); + }, + + None => *out_len = 0, + } +} + +#[no_mangle] pub extern fn quiche_conn_is_established(conn: &mut Connection) -> bool { conn.is_established() } |