Commit 79e0bff4 authored by bdbai's avatar bdbai
Browse files

ossl320, ossl330, quic

parent 1b4c9b0e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -71,6 +71,9 @@ pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&
    } else {
        let openssl_version = openssl_version.unwrap();

        if openssl_version >= 0x3_03_00_00_0 {
            cfgs.push("ossl330");
        }
        if openssl_version >= 0x3_02_00_00_0 {
            cfgs.push("ossl320");
        }
+1 −0
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ fn main() {
    println!("cargo:rustc-check-cfg=cfg(ossl300)");
    println!("cargo:rustc-check-cfg=cfg(ossl310)");
    println!("cargo:rustc-check-cfg=cfg(ossl320)");
    println!("cargo:rustc-check-cfg=cfg(ossl330)");

    check_ssl_kind();

+8 −1
Original line number Diff line number Diff line
@@ -56,6 +56,10 @@ const INCLUDES: &str = "
#include <openssl/provider.h>
#endif

#if OPENSSL_VERSION_NUMBER >= 0x30200000
#include <openssl/quic.h>
#endif

#if defined(LIBRESSL_VERSION_NUMBER) || defined(OPENSSL_IS_BORINGSSL)
#include <openssl/poly1305.h>
#endif
@@ -70,8 +74,9 @@ pub fn run(include_dirs: &[PathBuf]) {
        .rust_target(RustTarget::Stable_1_47)
        .ctypes_prefix("::libc")
        .raw_line("use libc::*;")
        .raw_line("#[cfg(windows)] use std::os::windows::raw::HANDLE;")
        .raw_line("type evp_pkey_st = EVP_PKEY;")
        .allowlist_file(".*/openssl/[^/]+\\.h")
        .allowlist_file(".*[/\\\\]openssl/[^/\\\\]+\\.h")
        .allowlist_recursively(false)
        // libc is missing pthread_once_t on macOS
        .blocklist_type("CRYPTO_ONCE")
@@ -85,6 +90,8 @@ pub fn run(include_dirs: &[PathBuf]) {
        .blocklist_type("OSSL_FUNC_core_vset_error_fn")
        .blocklist_type("OSSL_FUNC_BIO_vprintf_fn")
        .blocklist_type("OSSL_FUNC_BIO_vsnprintf_fn")
        // struct hostent * does not exist on Windows
        .blocklist_function("BIO_gethostbyname")
        // Maintain compatibility for existing enum definitions
        .rustified_enum("point_conversion_form_t")
        // Maintain compatibility for pre-union definitions
+44 −0
Original line number Diff line number Diff line
@@ -70,3 +70,47 @@ extern "C" {
        destroy: unsafe extern "C" fn(*mut BIO) -> c_int,
    ) -> c_int;
}

cfg_if! {
    if #[cfg(ossl320)] {
        use std::ptr;

        pub const BIO_CTRL_DGRAM_GET_MTU: c_int = 41;
        pub const BIO_CTRL_DGRAM_SET_MTU: c_int = 42;
        pub const BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP: c_int = 82;
        pub const BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE: c_int = 83;
        pub const BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE: c_int = 84;
        pub const BIO_CTRL_DGRAM_GET_CAPS: c_int = 86;
        pub const BIO_CTRL_DGRAM_SET_CAPS: c_int = 87;
        pub const BIO_CTRL_DGRAM_GET_NO_TRUNC: c_int = 88;
        pub const BIO_CTRL_DGRAM_SET_NO_TRUNC: c_int = 89;

        pub unsafe fn BIO_dgram_get_no_trunc(bio: *mut BIO) -> c_int {
            BIO_ctrl(bio, BIO_CTRL_DGRAM_GET_NO_TRUNC, 0, ptr::null_mut()) as c_int
        }
        pub unsafe fn BIO_dgram_set_no_trunc(bio: *mut BIO, enable: c_int) -> c_int {
            BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_NO_TRUNC, enable, ptr::null_mut()) as c_int
        }
        pub unsafe fn BIO_dgram_get_cap(bio: *mut BIO) -> u32 {
            BIO_ctrl(bio, BIO_CTRL_DGRAM_GET_CAPS, 0, ptr::null_mut()) as u32
        }
        pub unsafe fn BIO_dgram_set_cap(bio: *mut BIO, cap: u32) -> c_int {
            BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_CAPS, cap as c_long, ptr::null_mut()) as c_int
        }
        pub unsafe fn BIO_dgram_get_local_addr_cap(bio: *mut BIO) -> c_int {
            BIO_ctrl(bio, BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP, 0, ptr::null_mut()) as c_int
        }
        pub unsafe fn BIO_dgram_get_local_addr_enable(bio: *mut BIO, enable: *mut c_int) -> c_int {
            BIO_ctrl(bio, BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE, 0, enable as *mut c_void) as c_int
        }
        pub unsafe fn BIO_dgram_set_local_addr_enable(bio: *mut BIO, enable: c_int) -> c_int {
            BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE, enable as c_long, ptr::null_mut()) as c_int
        }
        pub unsafe fn BIO_dgram_get_mtu(bio: *mut BIO) -> c_uint {
            BIO_ctrl(bio, BIO_CTRL_DGRAM_GET_MTU, 0, ptr::null_mut()) as c_uint
        }
        pub unsafe fn BIO_dgram_set_mtu(bio: *mut BIO, mtu: c_uint) -> c_int {
            BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_MTU, mtu as c_long, ptr::null_mut()) as c_int
        }
    }
}
+57 −0
Original line number Diff line number Diff line
@@ -106,3 +106,60 @@ extern "C" {
        destroy: Option<unsafe extern "C" fn(*mut BIO) -> c_int>,
    ) -> c_int;
}

#[cfg(ossl320)]
extern "C" {
    pub fn BIO_meth_set_sendmmsg(
        biom: *mut BIO_METHOD,
        f: Option<
            unsafe extern "C" fn(
                arg1: *mut BIO,
                arg2: *mut BIO_MSG,
                arg3: usize,
                arg4: usize,
                arg5: u64,
                arg6: *mut usize,
            ) -> c_int,
        >,
    ) -> c_int;
    pub fn BIO_meth_set_recvmmsg(
        biom: *mut BIO_METHOD,
        f: Option<
            unsafe extern "C" fn(
                arg1: *mut BIO,
                arg2: *mut BIO_MSG,
                arg3: usize,
                arg4: usize,
                arg5: u64,
                arg6: *mut usize,
            ) -> c_int,
        >,
    ) -> c_int;
    pub fn BIO_new_bio_dgram_pair(
        bio1: *mut *mut BIO,
        writebuf1: usize,
        bio2: *mut *mut BIO,
        writebuf2: usize,
    ) -> c_int;
    pub fn BIO_s_dgram_pair() -> *const BIO_METHOD;
    pub fn BIO_s_datagram() -> *const BIO_METHOD;
    pub fn BIO_get_rpoll_descriptor(b: *mut BIO, desc: *mut BIO_POLL_DESCRIPTOR) -> c_int;
    pub fn BIO_get_wpoll_descriptor(b: *mut BIO, desc: *mut BIO_POLL_DESCRIPTOR) -> c_int;
    pub fn BIO_sendmmsg(
        b: *mut BIO,
        msg: *mut BIO_MSG,
        stride: usize,
        num_msg: usize,
        flags: u64,
        msgs_processed: *mut usize,
    ) -> c_int;
    pub fn BIO_recvmmsg(
        b: *mut BIO,
        msg: *mut BIO_MSG,
        stride: usize,
        num_msg: usize,
        flags: u64,
        msgs_processed: *mut usize,
    ) -> c_int;
    pub fn BIO_err_is_non_fatal(errcode: c_uint) -> c_int;
}
Loading