Skip to content

Commit 7068342

Browse files
committed
librustls: add rustls_connection_get_tls13_tickets_received()
This is FFI for `ClientConnection::tls13_tickets_received()`.
1 parent 0b3478c commit 7068342

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

librustls/src/connection.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,21 @@ impl rustls_connection {
491491
}
492492
}
493493

494+
/// Retrieves the number of TLS 1.3 tickets that have been received by a client connection.
495+
///
496+
/// This returns 0 if the `conn` is `NULL`, or a server connection.
497+
#[no_mangle]
498+
pub extern "C" fn rustls_connection_get_tls13_tickets_received(
499+
conn: *const rustls_connection,
500+
) -> u32 {
501+
ffi_panic_boundary! {
502+
try_ref_from_ptr!(conn)
503+
.as_client()
504+
.map(|cc| cc.tls13_tickets_received())
505+
.unwrap_or_default()
506+
}
507+
}
508+
494509
/// Write up to `count` plaintext bytes from `buf` into the `rustls_connection`.
495510
/// This will increase the number of output bytes available to
496511
/// `rustls_connection_write_tls`.

librustls/src/panic.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ pub(crate) trait Defaultable: Default {}
3030

3131
impl Defaultable for u16 {}
3232

33+
impl Defaultable for u32 {}
34+
3335
impl Defaultable for usize {}
3436

3537
impl Defaultable for bool {}

librustls/src/rustls.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,13 @@ uint16_t rustls_connection_get_negotiated_key_exchange_group(const struct rustls
18461846
*/
18471847
struct rustls_str rustls_connection_get_negotiated_key_exchange_group_name(const struct rustls_connection *conn);
18481848

1849+
/**
1850+
* Retrieves the number of TLS 1.3 tickets that have been received by a client connection.
1851+
*
1852+
* This returns 0 if the `conn` is `NULL`, or a server connection.
1853+
*/
1854+
uint32_t rustls_connection_get_tls13_tickets_received(const struct rustls_connection *conn);
1855+
18491856
/**
18501857
* Write up to `count` plaintext bytes from `buf` into the `rustls_connection`.
18511858
* This will increase the number of output bytes available to

0 commit comments

Comments
 (0)