/* automatically generated by rust-bindgen 0.69.5 */
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#![allow(unused_imports, non_camel_case_types)]
use crate::api::*;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct s2n_event_handshake {
#[doc = " The negotiated protocol version\n\n This will be one of the protocol version constants defined in s2n.h"]
pub protocol_version: ::libc::c_int,
pub cipher: *const ::libc::c_char,
pub group: *const ::libc::c_char,
pub security_policy_label: *const ::libc::c_char,
pub handshake_time_ns: u64,
#[doc = " The start of the handshake. This is not an interpretable time, and only has\n meaning in reference to handshake_end_ns.\n\n This is also used as a flag to ensure that the same event isn't emitted\n twice. After the event has been emitted this is set to HANDSHAKE_EVENT_SENT"]
pub handshake_start_ns: u64,
pub handshake_end_ns: u64,
#[doc = " If the handshake failed, this contains the error code.\n 0 indicates no error (successful handshake).\n The error name can be retrieved via s2n_strerror_name(error_code)."]
pub error_code: ::libc::c_int,
}
#[test]
fn bindgen_test_layout_s2n_event_handshake() {
const UNINIT: ::core::mem::MaybeUninit<s2n_event_handshake> =
::core::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::core::mem::size_of::<s2n_event_handshake>(),
64usize,
concat!("Size of: ", stringify!(s2n_event_handshake))
);
assert_eq!(
::core::mem::align_of::<s2n_event_handshake>(),
8usize,
concat!("Alignment of ", stringify!(s2n_event_handshake))
);
assert_eq!(
unsafe { ::core::ptr::addr_of!((*ptr).protocol_version) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(s2n_event_handshake),
"::",
stringify!(protocol_version)
)
);
assert_eq!(
unsafe { ::core::ptr::addr_of!((*ptr).cipher) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(s2n_event_handshake),
"::",
stringify!(cipher)
)
);
assert_eq!(
unsafe { ::core::ptr::addr_of!((*ptr).group) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(s2n_event_handshake),
"::",
stringify!(group)
)
);
assert_eq!(
unsafe { ::core::ptr::addr_of!((*ptr).security_policy_label) as usize - ptr as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(s2n_event_handshake),
"::",
stringify!(security_policy_label)
)
);
assert_eq!(
unsafe { ::core::ptr::addr_of!((*ptr).handshake_time_ns) as usize - ptr as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(s2n_event_handshake),
"::",
stringify!(handshake_time_ns)
)
);
assert_eq!(
unsafe { ::core::ptr::addr_of!((*ptr).handshake_start_ns) as usize - ptr as usize },
40usize,
concat!(
"Offset of field: ",
stringify!(s2n_event_handshake),
"::",
stringify!(handshake_start_ns)
)
);
assert_eq!(
unsafe { ::core::ptr::addr_of!((*ptr).handshake_end_ns) as usize - ptr as usize },
48usize,
concat!(
"Offset of field: ",
stringify!(s2n_event_handshake),
"::",
stringify!(handshake_end_ns)
)
);
assert_eq!(
unsafe { ::core::ptr::addr_of!((*ptr).error_code) as usize - ptr as usize },
56usize,
concat!(
"Offset of field: ",
stringify!(s2n_event_handshake),
"::",
stringify!(error_code)
)
);
}
pub type s2n_event_on_handshake_cb = ::core::option::Option<
unsafe extern "C" fn(
conn: *mut s2n_connection,
subscriber: *mut ::libc::c_void,
event: *mut s2n_event_handshake,
),
>;
extern "C" {
pub fn s2n_config_set_subscriber(
config: *mut s2n_config,
subscriber: *mut ::libc::c_void,
) -> ::libc::c_int;
}
extern "C" {
#[doc = " Set a callback to receive a handshake event.\n\n The `struct s2n_event_handshake *event` is only valid over the lifetime of the\n callbacks, and must not be referenced after the callback returned.\n\n An event is emitted both on success and failure. On failure, the event's\n error_code field will be set with the relevant error information."]
pub fn s2n_config_set_handshake_event(
config: *mut s2n_config,
callback: s2n_event_on_handshake_cb,
) -> ::libc::c_int;
}
#[doc = " Per-message timing checkpoint emitted once when each handshake message\n handler finishes. Consumers reconstruct per-message durations by computing\n the delta between consecutive checkpoint timestamps.\n\n Checkpoints fire from the shared handshake dispatch loop, so they are emitted\n for every negotiated protocol version. The message names reflect whichever\n version was negotiated.\n\n The pointer passed to the callback is valid only for the duration of the\n callback invocation. Callers must copy any fields they want to retain."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct s2n_timing_checkpoint {
pub name: *const ::libc::c_char,
pub role: u8,
pub timestamp_ns: u64,
}
#[test]
fn bindgen_test_layout_s2n_timing_checkpoint() {
const UNINIT: ::core::mem::MaybeUninit<s2n_timing_checkpoint> =
::core::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::core::mem::size_of::<s2n_timing_checkpoint>(),
24usize,
concat!("Size of: ", stringify!(s2n_timing_checkpoint))
);
assert_eq!(
::core::mem::align_of::<s2n_timing_checkpoint>(),
8usize,
concat!("Alignment of ", stringify!(s2n_timing_checkpoint))
);
assert_eq!(
unsafe { ::core::ptr::addr_of!((*ptr).name) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(s2n_timing_checkpoint),
"::",
stringify!(name)
)
);
assert_eq!(
unsafe { ::core::ptr::addr_of!((*ptr).role) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(s2n_timing_checkpoint),
"::",
stringify!(role)
)
);
assert_eq!(
unsafe { ::core::ptr::addr_of!((*ptr).timestamp_ns) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(s2n_timing_checkpoint),
"::",
stringify!(timestamp_ns)
)
);
}
pub type s2n_event_on_timing_checkpoint_cb = ::core::option::Option<
unsafe extern "C" fn(
conn: *mut s2n_connection,
subscriber: *mut ::libc::c_void,
checkpoint: *mut s2n_timing_checkpoint,
),
>;
extern "C" {
#[doc = " Register a per-message timing checkpoint callback on a config.\n\n The callback fires once after each TLS handshake message handler completes,\n with a single monotonic timestamp. The consumer reconstructs per-message\n durations by computing deltas between consecutive checkpoint timestamps.\n\n The same `subscriber` pointer set via s2n_config_set_subscriber is passed\n as the second argument to the callback. If no subscriber has been set,\n NULL is passed.\n\n Note: On a server using SNI-based config swap (s2n_connection_set_config\n called from the client hello callback), NEGOTIATE_START fires before the\n swap occurs. To receive NEGOTIATE_START, register this callback on the\n initial/default config, not only on the SNI-selected config.\n\n Returns S2N_SUCCESS on success.\n Returns S2N_FAILURE with S2N_ERR_NULL if config or callback is NULL."]
pub fn s2n_config_set_timing_checkpoint_cb(
config: *mut s2n_config,
callback: s2n_event_on_timing_checkpoint_cb,
) -> ::libc::c_int;
}