diff --git a/openthread-sys/gen/builder.rs b/openthread-sys/gen/builder.rs index f02b063..1b16ead 100644 --- a/openthread-sys/gen/builder.rs +++ b/openthread-sys/gen/builder.rs @@ -95,14 +95,8 @@ impl OpenThreadBuilder { .derive_debug(false) .derive_default(true) .layout_tests(false) - .blocklist_function("strtold") - .blocklist_function("_strtold_r") - .blocklist_function("v.*printf") - .blocklist_function("v.*scanf") - .blocklist_function("_v.*printf_r") - .blocklist_function("_v.*scanf_r") - .blocklist_function("q.*cvt") - .blocklist_function("q.*cvt_r") + .allowlist_item("ot.*") + .allowlist_item("OT_.*") .header( self.crate_root_path .join("gen") diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libeverest.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libeverest.a index 48d2594..d7b8995 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libeverest.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libeverest.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedcrypto.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedcrypto.a index d1e6f24..300e5c4 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedcrypto.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedcrypto.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedtls.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedtls.a index b33234d..bd92117 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedtls.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedtls.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedx509.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedx509.a index c4f055e..a75cf82 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedx509.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libmbedx509.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-cli-mtd.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-cli-mtd.a index fad25ee..97327f1 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-cli-mtd.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-cli-mtd.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-hdlc.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-hdlc.a index db653ea..04bad17 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-hdlc.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-hdlc.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-mtd.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-mtd.a index b7f7de3..4ab90ad 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-mtd.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-mtd.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-ncp-mtd.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-ncp-mtd.a index 89cd623..92ca87d 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-ncp-mtd.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-ncp-mtd.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-platform-utils-static.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-platform-utils-static.a index b67510b..36808a6 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-platform-utils-static.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-platform-utils-static.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-platform.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-platform.a index 250a77d..5b6bd4b 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-platform.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-platform.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-radio-spinel.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-radio-spinel.a index d1eb1dc..211e5ac 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-radio-spinel.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-radio-spinel.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-spinel-ncp.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-spinel-ncp.a index 857965c..bee0d5b 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-spinel-ncp.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-spinel-ncp.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-spinel-rcp.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-spinel-rcp.a index 5ad690a..87e368d 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-spinel-rcp.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libopenthread-spinel-rcp.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libp256m.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libp256m.a index 3deb6f5..9078448 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libp256m.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libp256m.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libsupport.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libsupport.a index 5ac7c88..14a665a 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libsupport.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libsupport.a differ diff --git a/openthread-sys/libs/riscv32imac-unknown-none-elf/libtcplp-mtd.a b/openthread-sys/libs/riscv32imac-unknown-none-elf/libtcplp-mtd.a index 00a3d58..e0aad99 100644 Binary files a/openthread-sys/libs/riscv32imac-unknown-none-elf/libtcplp-mtd.a and b/openthread-sys/libs/riscv32imac-unknown-none-elf/libtcplp-mtd.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libeverest.a b/openthread-sys/libs/thumbv6m-none-eabi/libeverest.a index 3c42672..b1719fd 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libeverest.a and b/openthread-sys/libs/thumbv6m-none-eabi/libeverest.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libmbedcrypto.a b/openthread-sys/libs/thumbv6m-none-eabi/libmbedcrypto.a index bcc782b..ad46d75 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libmbedcrypto.a and b/openthread-sys/libs/thumbv6m-none-eabi/libmbedcrypto.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libmbedtls.a b/openthread-sys/libs/thumbv6m-none-eabi/libmbedtls.a index f1018fd..a7f87aa 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libmbedtls.a and b/openthread-sys/libs/thumbv6m-none-eabi/libmbedtls.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libmbedx509.a b/openthread-sys/libs/thumbv6m-none-eabi/libmbedx509.a index 5e6ef10..3b0db1d 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libmbedx509.a and b/openthread-sys/libs/thumbv6m-none-eabi/libmbedx509.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-cli-mtd.a b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-cli-mtd.a index 98388fb..e97092a 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-cli-mtd.a and b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-cli-mtd.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-hdlc.a b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-hdlc.a index f1cdce0..547745e 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-hdlc.a and b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-hdlc.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-mtd.a b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-mtd.a index 9c87f3f..bb58a54 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-mtd.a and b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-mtd.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-ncp-mtd.a b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-ncp-mtd.a index 43e5d80..54fe167 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-ncp-mtd.a and b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-ncp-mtd.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-platform-utils-static.a b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-platform-utils-static.a index 3325d90..de69b3b 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-platform-utils-static.a and b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-platform-utils-static.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-platform.a b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-platform.a index 651c33b..824205f 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-platform.a and b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-platform.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-radio-spinel.a b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-radio-spinel.a index c8b6456..75d84e6 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-radio-spinel.a and b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-radio-spinel.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-spinel-ncp.a b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-spinel-ncp.a index 44a75c5..fcadbb8 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-spinel-ncp.a and b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-spinel-ncp.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-spinel-rcp.a b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-spinel-rcp.a index 4e3ff5c..230c458 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-spinel-rcp.a and b/openthread-sys/libs/thumbv6m-none-eabi/libopenthread-spinel-rcp.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libp256m.a b/openthread-sys/libs/thumbv6m-none-eabi/libp256m.a index cd7d2a8..6dd0fc4 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libp256m.a and b/openthread-sys/libs/thumbv6m-none-eabi/libp256m.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libsupport.a b/openthread-sys/libs/thumbv6m-none-eabi/libsupport.a index 07ada7b..f60826d 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libsupport.a and b/openthread-sys/libs/thumbv6m-none-eabi/libsupport.a differ diff --git a/openthread-sys/libs/thumbv6m-none-eabi/libtcplp-mtd.a b/openthread-sys/libs/thumbv6m-none-eabi/libtcplp-mtd.a index 3e06f2c..5665f6e 100644 Binary files a/openthread-sys/libs/thumbv6m-none-eabi/libtcplp-mtd.a and b/openthread-sys/libs/thumbv6m-none-eabi/libtcplp-mtd.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libeverest.a b/openthread-sys/libs/thumbv7em-none-eabi/libeverest.a index 3c6a187..4c3c255 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libeverest.a and b/openthread-sys/libs/thumbv7em-none-eabi/libeverest.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libmbedcrypto.a b/openthread-sys/libs/thumbv7em-none-eabi/libmbedcrypto.a index 7ef47be..d45da1f 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libmbedcrypto.a and b/openthread-sys/libs/thumbv7em-none-eabi/libmbedcrypto.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libmbedtls.a b/openthread-sys/libs/thumbv7em-none-eabi/libmbedtls.a index a7c605c..98d5e27 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libmbedtls.a and b/openthread-sys/libs/thumbv7em-none-eabi/libmbedtls.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libmbedx509.a b/openthread-sys/libs/thumbv7em-none-eabi/libmbedx509.a index 0bc3fa6..33b30ee 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libmbedx509.a and b/openthread-sys/libs/thumbv7em-none-eabi/libmbedx509.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-cli-mtd.a b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-cli-mtd.a index e3a9c67..6f517b4 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-cli-mtd.a and b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-cli-mtd.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-hdlc.a b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-hdlc.a index 339a232..12f58f3 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-hdlc.a and b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-hdlc.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-mtd.a b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-mtd.a index 206eb54..5a31633 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-mtd.a and b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-mtd.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-ncp-mtd.a b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-ncp-mtd.a index 12a1902..dbfc6b2 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-ncp-mtd.a and b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-ncp-mtd.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-platform-utils-static.a b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-platform-utils-static.a index e6a757a..b2cd8bb 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-platform-utils-static.a and b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-platform-utils-static.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-platform.a b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-platform.a index ffcedab..fccc29f 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-platform.a and b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-platform.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-radio-spinel.a b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-radio-spinel.a index 220f4fb..89a8834 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-radio-spinel.a and b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-radio-spinel.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-spinel-ncp.a b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-spinel-ncp.a index 595e790..24a104f 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-spinel-ncp.a and b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-spinel-ncp.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-spinel-rcp.a b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-spinel-rcp.a index 050dbc8..a670c71 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-spinel-rcp.a and b/openthread-sys/libs/thumbv7em-none-eabi/libopenthread-spinel-rcp.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libp256m.a b/openthread-sys/libs/thumbv7em-none-eabi/libp256m.a index eb0b366..7ec9db7 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libp256m.a and b/openthread-sys/libs/thumbv7em-none-eabi/libp256m.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libsupport.a b/openthread-sys/libs/thumbv7em-none-eabi/libsupport.a index 88f2d9a..d0861df 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libsupport.a and b/openthread-sys/libs/thumbv7em-none-eabi/libsupport.a differ diff --git a/openthread-sys/libs/thumbv7em-none-eabi/libtcplp-mtd.a b/openthread-sys/libs/thumbv7em-none-eabi/libtcplp-mtd.a index 86791dc..b003bbc 100644 Binary files a/openthread-sys/libs/thumbv7em-none-eabi/libtcplp-mtd.a and b/openthread-sys/libs/thumbv7em-none-eabi/libtcplp-mtd.a differ diff --git a/openthread-sys/src/include/riscv32imac-unknown-none-elf.rs b/openthread-sys/src/include/riscv32imac-unknown-none-elf.rs index 800c34b..6fbdfa2 100644 --- a/openthread-sys/src/include/riscv32imac-unknown-none-elf.rs +++ b/openthread-sys/src/include/riscv32imac-unknown-none-elf.rs @@ -137,127 +137,6 @@ where } } } -pub const __bool_true_false_are_defined: u32 = 1; -pub const true_: u32 = 1; -pub const false_: u32 = 0; -pub const _NEWLIB_VERSION_H__: u32 = 1; -pub const _NEWLIB_VERSION: &[u8; 6] = b"4.5.0\0"; -pub const __NEWLIB__: u32 = 4; -pub const __NEWLIB_MINOR__: u32 = 5; -pub const __NEWLIB_PATCHLEVEL__: u32 = 0; -pub const _DEFAULT_SOURCE: u32 = 1; -pub const _POSIX_SOURCE: u32 = 1; -pub const _POSIX_C_SOURCE: u32 = 200809; -pub const _ATFILE_SOURCE: u32 = 1; -pub const __ATFILE_VISIBLE: u32 = 1; -pub const __BSD_VISIBLE: u32 = 1; -pub const __GNU_VISIBLE: u32 = 0; -pub const __ISO_C_VISIBLE: u32 = 2011; -pub const __LARGEFILE_VISIBLE: u32 = 0; -pub const __MISC_VISIBLE: u32 = 1; -pub const __POSIX_VISIBLE: u32 = 200809; -pub const __SVID_VISIBLE: u32 = 1; -pub const __XSI_VISIBLE: u32 = 0; -pub const __SSP_FORTIFY_LEVEL: u32 = 0; -pub const _POSIX_THREADS: u32 = 1; -pub const _POSIX_TIMEOUTS: u32 = 1; -pub const _POSIX_TIMERS: u32 = 1; -pub const _POSIX_MONOTONIC_CLOCK: u32 = 200112; -pub const _POSIX_CLOCK_SELECTION: u32 = 200112; -pub const _UNIX98_THREAD_MUTEX_ATTRIBUTES: u32 = 1; -pub const _POSIX_READER_WRITER_LOCKS: u32 = 200112; -pub const __have_longlong64: u32 = 1; -pub const __have_long32: u32 = 1; -pub const ___int8_t_defined: u32 = 1; -pub const ___int16_t_defined: u32 = 1; -pub const ___int32_t_defined: u32 = 1; -pub const ___int64_t_defined: u32 = 1; -pub const ___int_least8_t_defined: u32 = 1; -pub const ___int_least16_t_defined: u32 = 1; -pub const ___int_least32_t_defined: u32 = 1; -pub const ___int_least64_t_defined: u32 = 1; -pub const __int20: u32 = 2; -pub const __int20__: u32 = 2; -pub const __INT8: &[u8; 3] = b"hh\0"; -pub const __INT16: &[u8; 2] = b"h\0"; -pub const __INT64: &[u8; 3] = b"ll\0"; -pub const __FAST8: &[u8; 3] = b"hh\0"; -pub const __FAST16: &[u8; 2] = b"h\0"; -pub const __FAST64: &[u8; 3] = b"ll\0"; -pub const __LEAST8: &[u8; 3] = b"hh\0"; -pub const __LEAST16: &[u8; 2] = b"h\0"; -pub const __LEAST64: &[u8; 3] = b"ll\0"; -pub const __int8_t_defined: u32 = 1; -pub const __int16_t_defined: u32 = 1; -pub const __int32_t_defined: u32 = 1; -pub const __int64_t_defined: u32 = 1; -pub const __int_least8_t_defined: u32 = 1; -pub const __int_least16_t_defined: u32 = 1; -pub const __int_least32_t_defined: u32 = 1; -pub const __int_least64_t_defined: u32 = 1; -pub const __int_fast8_t_defined: u32 = 1; -pub const __int_fast16_t_defined: u32 = 1; -pub const __int_fast32_t_defined: u32 = 1; -pub const __int_fast64_t_defined: u32 = 1; -pub const WINT_MIN: u32 = 0; -pub const __OBSOLETE_MATH_DEFAULT: u32 = 1; -pub const __OBSOLETE_MATH: u32 = 1; -pub const __NEWLIB_H__: u32 = 1; -pub const _ATEXIT_DYNAMIC_ALLOC: u32 = 1; -pub const _FSEEK_OPTIMIZATION: u32 = 1; -pub const _FVWRITE_IN_STREAMIO: u32 = 1; -pub const _HAVE_CC_INHIBIT_LOOP_TO_LIBCALL: u32 = 1; -pub const _HAVE_HW_MISALIGNED_ACCESS: u32 = 1; -pub const _HAVE_INITFINI_ARRAY: u32 = 1; -pub const _HAVE_LONG_DOUBLE: u32 = 1; -pub const _ICONV_ENABLED: u32 = 1; -pub const _MB_LEN_MAX: u32 = 1; -pub const _NANO_MALLOC: u32 = 1; -pub const _REENT_CHECK_VERIFY: u32 = 1; -pub const _RETARGETABLE_LOCKING: u32 = 1; -pub const _UNBUF_STREAM_OPT: u32 = 1; -pub const _WANT_IO_C99_FORMATS: u32 = 1; -pub const _WANT_IO_LONG_LONG: u32 = 1; -pub const _WANT_IO_POS_ARGS: u32 = 1; -pub const _WANT_REENT_BACKWARD_BINARY_COMPAT: u32 = 1; -pub const _WANT_REENT_SMALL: u32 = 1; -pub const _WANT_USE_GDTOA: u32 = 1; -pub const __BUFSIZ__: u32 = 128; -pub const __RAND_MAX: u32 = 2147483647; -pub const __GNUCLIKE_ASM: u32 = 3; -pub const __GNUCLIKE___TYPEOF: u32 = 1; -pub const __GNUCLIKE___SECTION: u32 = 1; -pub const __GNUCLIKE_CTOR_SECTION_HANDLING: u32 = 1; -pub const __GNUCLIKE_BUILTIN_CONSTANT_P: u32 = 1; -pub const __GNUCLIKE_BUILTIN_VARARGS: u32 = 1; -pub const __GNUCLIKE_BUILTIN_STDARG: u32 = 1; -pub const __GNUCLIKE_BUILTIN_VAALIST: u32 = 1; -pub const __GNUC_VA_LIST_COMPATIBILITY: u32 = 1; -pub const __GNUCLIKE_BUILTIN_NEXT_ARG: u32 = 1; -pub const __GNUCLIKE_BUILTIN_MEMCPY: u32 = 1; -pub const __CC_SUPPORTS_INLINE: u32 = 1; -pub const __CC_SUPPORTS___INLINE: u32 = 1; -pub const __CC_SUPPORTS___INLINE__: u32 = 1; -pub const __CC_SUPPORTS___FUNC__: u32 = 1; -pub const __CC_SUPPORTS_WARNING: u32 = 1; -pub const __CC_SUPPORTS_VARADIC_XXX: u32 = 1; -pub const __CC_SUPPORTS_DYNAMIC_ARRAY_INIT: u32 = 1; -pub const _NULL: u32 = 0; -pub const _ATEXIT_SIZE: u32 = 32; -pub const _RAND48_SEED_0: u32 = 13070; -pub const _RAND48_SEED_1: u32 = 43981; -pub const _RAND48_SEED_2: u32 = 4660; -pub const _RAND48_MULT_0: u32 = 58989; -pub const _RAND48_MULT_1: u32 = 57068; -pub const _RAND48_MULT_2: u32 = 5; -pub const _RAND48_ADD: u32 = 11; -pub const _REENT_EMERGENCY_SIZE: u32 = 25; -pub const _REENT_ASCTIME_SIZE: u32 = 26; -pub const _REENT_SIGNAL_SIZE: u32 = 24; -pub const EXIT_FAILURE: u32 = 1; -pub const EXIT_SUCCESS: u32 = 0; -pub const RAND_MAX: u32 = 2147483647; -pub const OPENTHREAD_API_VERSION: u32 = 512; pub const OT_UPTIME_STRING_SIZE: u32 = 24; pub const OT_CHANGED_IP6_ADDRESS_ADDED: u32 = 1; pub const OT_CHANGED_IP6_ADDRESS_REMOVED: u32 = 2; @@ -309,8 +188,6 @@ pub const OT_CRYPTO_ECDSA_SIGNATURE_SIZE: u32 = 64; pub const OT_CRYPTO_PBDKF2_MAX_SALT_SIZE: u32 = 30; pub const OT_PANID_BROADCAST: u32 = 65535; pub const OT_EXT_ADDRESS_SIZE: u32 = 8; -pub const CSL_IE_HEADER_BYTES_LO: u32 = 4; -pub const CSL_IE_HEADER_BYTES_HI: u32 = 13; pub const OT_MAC_KEY_SIZE: u32 = 16; pub const OT_NETWORK_KEY_SIZE: u32 = 16; pub const OT_NETWORK_NAME_MAX_SIZE: u32 = 16; @@ -381,1076 +258,6 @@ pub const OT_DNS_MAX_LABEL_SIZE: u32 = 64; pub const OT_DNS_TXT_KEY_MIN_LENGTH: u32 = 1; pub const OT_DNS_TXT_KEY_MAX_LENGTH: u32 = 9; pub const OT_DNS_TXT_KEY_ITER_MAX_LENGTH: u32 = 64; -pub const OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE: u32 = 1; -pub type __int8_t = ::core::ffi::c_schar; -pub type __uint8_t = ::core::ffi::c_uchar; -pub type __int16_t = ::core::ffi::c_short; -pub type __uint16_t = ::core::ffi::c_ushort; -pub type __int32_t = ::core::ffi::c_int; -pub type __uint32_t = ::core::ffi::c_uint; -pub type __int64_t = ::core::ffi::c_longlong; -pub type __uint64_t = ::core::ffi::c_ulonglong; -pub type __int_least8_t = ::core::ffi::c_schar; -pub type __uint_least8_t = ::core::ffi::c_uchar; -pub type __int_least16_t = ::core::ffi::c_short; -pub type __uint_least16_t = ::core::ffi::c_ushort; -pub type __int_least32_t = ::core::ffi::c_int; -pub type __uint_least32_t = ::core::ffi::c_uint; -pub type __int_least64_t = ::core::ffi::c_longlong; -pub type __uint_least64_t = ::core::ffi::c_ulonglong; -pub type __intmax_t = ::core::ffi::c_longlong; -pub type __uintmax_t = ::core::ffi::c_ulonglong; -pub type __intptr_t = ::core::ffi::c_int; -pub type __uintptr_t = ::core::ffi::c_uint; -pub type intmax_t = __intmax_t; -pub type uintmax_t = __uintmax_t; -pub type int_least8_t = __int_least8_t; -pub type uint_least8_t = __uint_least8_t; -pub type int_least16_t = __int_least16_t; -pub type uint_least16_t = __uint_least16_t; -pub type int_least32_t = __int_least32_t; -pub type uint_least32_t = __uint_least32_t; -pub type int_least64_t = __int_least64_t; -pub type uint_least64_t = __uint_least64_t; -pub type int_fast8_t = ::core::ffi::c_schar; -pub type uint_fast8_t = ::core::ffi::c_uchar; -pub type int_fast16_t = ::core::ffi::c_short; -pub type uint_fast16_t = ::core::ffi::c_ushort; -pub type int_fast32_t = ::core::ffi::c_int; -pub type uint_fast32_t = ::core::ffi::c_uint; -pub type int_fast64_t = ::core::ffi::c_longlong; -pub type uint_fast64_t = ::core::ffi::c_ulonglong; -pub type wchar_t = ::core::ffi::c_int; -#[repr(C)] -#[repr(align(16))] -#[derive(Default, Copy, Clone)] -pub struct max_align_t { - pub __clang_max_align_nonce1: ::core::ffi::c_longlong, - pub __bindgen_padding_0: u64, - pub __clang_max_align_nonce2: u128, -} -pub type wint_t = ::core::ffi::c_uint; -pub type __blkcnt_t = ::core::ffi::c_long; -pub type __blksize_t = ::core::ffi::c_long; -pub type __fsblkcnt_t = __uint64_t; -pub type __fsfilcnt_t = __uint32_t; -pub type _off_t = ::core::ffi::c_long; -pub type __pid_t = ::core::ffi::c_int; -pub type __dev_t = ::core::ffi::c_short; -pub type __uid_t = ::core::ffi::c_ushort; -pub type __gid_t = ::core::ffi::c_ushort; -pub type __id_t = __uint32_t; -pub type __ino_t = ::core::ffi::c_ushort; -pub type __mode_t = __uint32_t; -pub type _off64_t = ::core::ffi::c_longlong; -pub type __off_t = _off_t; -pub type __loff_t = _off64_t; -pub type __key_t = ::core::ffi::c_long; -pub type _fpos_t = ::core::ffi::c_long; -pub type __size_t = ::core::ffi::c_uint; -pub type _ssize_t = ::core::ffi::c_int; -pub type __ssize_t = _ssize_t; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _mbstate_t { - pub __count: ::core::ffi::c_int, - pub __value: _mbstate_t__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union _mbstate_t__bindgen_ty_1 { - pub __wch: wint_t, - pub __wchb: [::core::ffi::c_uchar; 4usize], -} -impl Default for _mbstate_t__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -impl Default for _mbstate_t { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -pub type _iconv_t = *mut ::core::ffi::c_void; -pub type __clock_t = ::core::ffi::c_ulong; -pub type __time_t = __int_least64_t; -pub type __clockid_t = ::core::ffi::c_ulong; -pub type __daddr_t = ::core::ffi::c_long; -pub type __timer_t = ::core::ffi::c_ulong; -pub type __sa_family_t = __uint8_t; -pub type __socklen_t = __uint32_t; -pub type __nl_item = ::core::ffi::c_int; -pub type __nlink_t = ::core::ffi::c_ushort; -pub type __suseconds_t = ::core::ffi::c_long; -pub type __useconds_t = ::core::ffi::c_ulong; -pub type __va_list = __builtin_va_list; -pub type __ULong = ::core::ffi::c_ulong; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __lock { - _unused: [u8; 0], -} -pub type _LOCK_T = *mut __lock; -unsafe extern "C" { - pub fn __retarget_lock_init(lock: *mut _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_init_recursive(lock: *mut _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_close(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_close_recursive(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_acquire(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_acquire_recursive(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_try_acquire(lock: _LOCK_T) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __retarget_lock_try_acquire_recursive(lock: _LOCK_T) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __retarget_lock_release(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_release_recursive(lock: _LOCK_T); -} -pub type _flock_t = _LOCK_T; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __locale_t { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _Bigint { - pub _next: *mut _Bigint, - pub _k: ::core::ffi::c_int, - pub _maxwds: ::core::ffi::c_int, - pub _sign: ::core::ffi::c_int, - pub _wds: ::core::ffi::c_int, - pub _x: [__ULong; 1usize], -} -impl Default for _Bigint { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct __tm { - pub __tm_sec: ::core::ffi::c_int, - pub __tm_min: ::core::ffi::c_int, - pub __tm_hour: ::core::ffi::c_int, - pub __tm_mday: ::core::ffi::c_int, - pub __tm_mon: ::core::ffi::c_int, - pub __tm_year: ::core::ffi::c_int, - pub __tm_wday: ::core::ffi::c_int, - pub __tm_yday: ::core::ffi::c_int, - pub __tm_isdst: ::core::ffi::c_int, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _on_exit_args { - pub _fnargs: [*mut ::core::ffi::c_void; 32usize], - pub _dso_handle: [*mut ::core::ffi::c_void; 32usize], - pub _fntypes: __ULong, - pub _is_cxa: __ULong, -} -impl Default for _on_exit_args { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _atexit { - pub _next: *mut _atexit, - pub _ind: ::core::ffi::c_int, - pub _fns: [::core::option::Option; 32usize], - pub _on_exit_args_ptr: *mut _on_exit_args, -} -impl Default for _atexit { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __sbuf { - pub _base: *mut ::core::ffi::c_uchar, - pub _size: ::core::ffi::c_int, -} -impl Default for __sbuf { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __sFILE { - pub _p: *mut ::core::ffi::c_uchar, - pub _r: ::core::ffi::c_int, - pub _w: ::core::ffi::c_int, - pub _flags: ::core::ffi::c_short, - pub _file: ::core::ffi::c_short, - pub _bf: __sbuf, - pub _lbfsize: ::core::ffi::c_int, - pub _data: *mut _reent, - pub _cookie: *mut ::core::ffi::c_void, - pub _read: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: *mut ::core::ffi::c_char, - arg4: ::core::ffi::c_int, - ) -> _ssize_t, - >, - pub _write: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: *const ::core::ffi::c_char, - arg4: ::core::ffi::c_int, - ) -> _ssize_t, - >, - pub _seek: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: _fpos_t, - arg4: ::core::ffi::c_int, - ) -> _fpos_t, - >, - pub _close: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - ) -> ::core::ffi::c_int, - >, - pub _ub: __sbuf, - pub _up: *mut ::core::ffi::c_uchar, - pub _ur: ::core::ffi::c_int, - pub _ubuf: [::core::ffi::c_uchar; 3usize], - pub _nbuf: [::core::ffi::c_uchar; 1usize], - pub _lb: __sbuf, - pub _blksize: ::core::ffi::c_int, - pub _offset: _off_t, - pub _lock: _flock_t, - pub _mbstate: _mbstate_t, - pub _flags2: ::core::ffi::c_int, -} -impl Default for __sFILE { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -pub type __FILE = __sFILE; -unsafe extern "C" { - pub static mut __sf: [__FILE; 3usize]; -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _glue { - pub _next: *mut _glue, - pub _niobs: ::core::ffi::c_int, - pub _iobs: *mut __FILE, -} -impl Default for _glue { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -unsafe extern "C" { - pub static mut __sglue: _glue; -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct _rand48 { - pub _seed: [::core::ffi::c_ushort; 3usize], - pub _mult: [::core::ffi::c_ushort; 3usize], - pub _add: ::core::ffi::c_ushort, - pub _rand_next: ::core::ffi::c_ulonglong, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _mprec { - pub _result: *mut _Bigint, - pub _result_k: ::core::ffi::c_int, - pub _p5s: *mut _Bigint, - pub _freelist: *mut *mut _Bigint, -} -impl Default for _mprec { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _misc_reent { - pub _strtok_last: *mut ::core::ffi::c_char, - pub _mblen_state: _mbstate_t, - pub _wctomb_state: _mbstate_t, - pub _mbtowc_state: _mbstate_t, - pub _l64a_buf: [::core::ffi::c_char; 8usize], - pub _getdate_err: ::core::ffi::c_int, - pub _mbrlen_state: _mbstate_t, - pub _mbrtowc_state: _mbstate_t, - pub _mbsrtowcs_state: _mbstate_t, - pub _wcrtomb_state: _mbstate_t, - pub _wcsrtombs_state: _mbstate_t, -} -impl Default for _misc_reent { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _reent { - pub _errno: ::core::ffi::c_int, - pub _stdin: *mut __FILE, - pub _stdout: *mut __FILE, - pub _stderr: *mut __FILE, - pub _inc: ::core::ffi::c_int, - pub _emergency: *mut ::core::ffi::c_char, - pub _reserved_0: ::core::ffi::c_int, - pub _reserved_1: ::core::ffi::c_int, - pub _locale: *mut __locale_t, - pub _mp: *mut _mprec, - pub __cleanup: ::core::option::Option, - pub _gamma_signgam: ::core::ffi::c_int, - pub _cvtlen: ::core::ffi::c_int, - pub _cvtbuf: *mut ::core::ffi::c_char, - pub _r48: *mut _rand48, - pub _localtime_buf: *mut __tm, - pub _asctime_buf: *mut ::core::ffi::c_char, - pub _sig_func: *mut ::core::option::Option, - pub _reserved_6: *mut _atexit, - pub _reserved_7: _atexit, - pub _reserved_8: _glue, - pub __sf: *mut __FILE, - pub _misc: *mut _misc_reent, - pub _signal_buf: *mut ::core::ffi::c_char, -} -impl Default for _reent { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -unsafe extern "C" { - pub fn __assert( - arg1: *const ::core::ffi::c_char, - arg2: ::core::ffi::c_int, - arg3: *const ::core::ffi::c_char, - ) -> !; -} -unsafe extern "C" { - pub fn __assert_func( - arg1: *const ::core::ffi::c_char, - arg2: ::core::ffi::c_int, - arg3: *const ::core::ffi::c_char, - arg4: *const ::core::ffi::c_char, - ) -> !; -} -unsafe extern "C" { - pub static mut _impure_ptr: *mut _reent; -} -unsafe extern "C" { - pub static mut _impure_data: _reent; -} -unsafe extern "C" { - pub fn __getreent() -> *mut _reent; -} -unsafe extern "C" { - pub static mut __atexit: *mut _atexit; -} -unsafe extern "C" { - pub static mut __atexit0: _atexit; -} -unsafe extern "C" { - pub static mut __stdio_exit_handler: ::core::option::Option; -} -unsafe extern "C" { - pub fn _reclaim_reent(arg1: *mut _reent); -} -unsafe extern "C" { - pub fn _fwalk_sglue( - arg1: *mut _reent, - arg2: ::core::option::Option< - unsafe extern "C" fn(arg1: *mut _reent, arg2: *mut __FILE) -> ::core::ffi::c_int, - >, - arg3: *mut _glue, - ) -> ::core::ffi::c_int; -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct div_t { - pub quot: ::core::ffi::c_int, - pub rem: ::core::ffi::c_int, -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct ldiv_t { - pub quot: ::core::ffi::c_long, - pub rem: ::core::ffi::c_long, -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct lldiv_t { - pub quot: ::core::ffi::c_longlong, - pub rem: ::core::ffi::c_longlong, -} -pub type __compar_fn_t = ::core::option::Option< - unsafe extern "C" fn( - arg1: *const ::core::ffi::c_void, - arg2: *const ::core::ffi::c_void, - ) -> ::core::ffi::c_int, ->; -unsafe extern "C" { - pub fn __locale_mb_cur_max() -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn abort() -> !; -} -unsafe extern "C" { - pub fn abs(arg1: ::core::ffi::c_int) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn arc4random() -> __uint32_t; -} -unsafe extern "C" { - pub fn arc4random_uniform(arg1: __uint32_t) -> __uint32_t; -} -unsafe extern "C" { - pub fn arc4random_buf(arg1: *mut ::core::ffi::c_void, arg2: usize); -} -unsafe extern "C" { - pub fn atexit(__func: ::core::option::Option) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn atof(__nptr: *const ::core::ffi::c_char) -> f64; -} -unsafe extern "C" { - pub fn atoff(__nptr: *const ::core::ffi::c_char) -> f32; -} -unsafe extern "C" { - pub fn atoi(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _atoi_r(arg1: *mut _reent, __nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn atol(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _atol_r(arg1: *mut _reent, __nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn bsearch( - __key: *const ::core::ffi::c_void, - __base: *const ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - _compar: __compar_fn_t, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - #[must_use] - pub fn calloc(arg1: ::core::ffi::c_uint, arg2: ::core::ffi::c_uint) - -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn div(__numer: ::core::ffi::c_int, __denom: ::core::ffi::c_int) -> div_t; -} -unsafe extern "C" { - pub fn exit(__status: ::core::ffi::c_int) -> !; -} -unsafe extern "C" { - pub fn free(arg1: *mut ::core::ffi::c_void); -} -unsafe extern "C" { - pub fn getenv(__string: *const ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _getenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _findenv( - arg1: *const ::core::ffi::c_char, - arg2: *mut ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _findenv_r( - arg1: *mut _reent, - arg2: *const ::core::ffi::c_char, - arg3: *mut ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub static mut suboptarg: *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn getsubopt( - arg1: *mut *mut ::core::ffi::c_char, - arg2: *const *mut ::core::ffi::c_char, - arg3: *mut *mut ::core::ffi::c_char, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn labs(arg1: ::core::ffi::c_long) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn ldiv(__numer: ::core::ffi::c_long, __denom: ::core::ffi::c_long) -> ldiv_t; -} -unsafe extern "C" { - #[must_use] - pub fn malloc(arg1: ::core::ffi::c_uint) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn mblen(arg1: *const ::core::ffi::c_char, arg2: usize) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mblen_r( - arg1: *mut _reent, - arg2: *const ::core::ffi::c_char, - arg3: usize, - arg4: *mut _mbstate_t, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mbtowc( - arg1: *mut wchar_t, - arg2: *const ::core::ffi::c_char, - arg3: usize, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mbtowc_r( - arg1: *mut _reent, - arg2: *mut wchar_t, - arg3: *const ::core::ffi::c_char, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn wctomb(arg1: *mut ::core::ffi::c_char, arg2: wchar_t) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _wctomb_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: wchar_t, - arg4: *mut _mbstate_t, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mbstowcs(arg1: *mut wchar_t, arg2: *const ::core::ffi::c_char, arg3: usize) -> usize; -} -unsafe extern "C" { - pub fn _mbstowcs_r( - arg1: *mut _reent, - arg2: *mut wchar_t, - arg3: *const ::core::ffi::c_char, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> usize; -} -unsafe extern "C" { - pub fn wcstombs(arg1: *mut ::core::ffi::c_char, arg2: *const wchar_t, arg3: usize) -> usize; -} -unsafe extern "C" { - pub fn _wcstombs_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: *const wchar_t, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> usize; -} -unsafe extern "C" { - pub fn mkdtemp(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn mkstemp(arg1: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mkstemps(arg1: *mut ::core::ffi::c_char, arg2: ::core::ffi::c_int) - -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mktemp(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _mkdtemp_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _mkostemp_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkostemps_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - arg4: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkstemp_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkstemps_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mktemp_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char) - -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn qsort( - __base: *mut ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - _compar: __compar_fn_t, - ); -} -unsafe extern "C" { - pub fn rand() -> ::core::ffi::c_int; -} -unsafe extern "C" { - #[must_use] - pub fn realloc( - arg1: *mut ::core::ffi::c_void, - arg2: ::core::ffi::c_uint, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - #[must_use] - pub fn reallocarray( - arg1: *mut ::core::ffi::c_void, - arg2: usize, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - #[must_use] - pub fn reallocf(arg1: *mut ::core::ffi::c_void, arg2: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn realpath( - path: *const ::core::ffi::c_char, - resolved_path: *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn rpmatch(response: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn srand(__seed: ::core::ffi::c_uint); -} -unsafe extern "C" { - pub fn strtod(__n: *const ::core::ffi::c_char, __end_PTR: *mut *mut ::core::ffi::c_char) - -> f64; -} -unsafe extern "C" { - pub fn _strtod_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - ) -> f64; -} -unsafe extern "C" { - pub fn strtof(__n: *const ::core::ffi::c_char, __end_PTR: *mut *mut ::core::ffi::c_char) - -> f32; -} -unsafe extern "C" { - pub fn strtol( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _strtol_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn strtoul( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulong; -} -unsafe extern "C" { - pub fn _strtoul_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulong; -} -unsafe extern "C" { - pub fn system(__string: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn a64l(__input: *const ::core::ffi::c_char) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn l64a(__input: ::core::ffi::c_long) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _l64a_r(arg1: *mut _reent, __input: ::core::ffi::c_long) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn on_exit( - __func: ::core::option::Option< - unsafe extern "C" fn(arg1: ::core::ffi::c_int, arg2: *mut ::core::ffi::c_void), - >, - __arg: *mut ::core::ffi::c_void, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _Exit(__status: ::core::ffi::c_int) -> !; -} -unsafe extern "C" { - pub fn putenv(__string: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _putenv_r(arg1: *mut _reent, __string: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _reallocf_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn setenv( - __string: *const ::core::ffi::c_char, - __value: *const ::core::ffi::c_char, - __overwrite: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _setenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - __value: *const ::core::ffi::c_char, - __overwrite: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __itoa( - arg1: ::core::ffi::c_int, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn __utoa( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn itoa( - arg1: ::core::ffi::c_int, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn utoa( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn rand_r(__seed: *mut ::core::ffi::c_uint) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn drand48() -> f64; -} -unsafe extern "C" { - pub fn _drand48_r(arg1: *mut _reent) -> f64; -} -unsafe extern "C" { - pub fn erand48(arg1: *mut ::core::ffi::c_ushort) -> f64; -} -unsafe extern "C" { - pub fn _erand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> f64; -} -unsafe extern "C" { - pub fn jrand48(arg1: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _jrand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn lcong48(arg1: *mut ::core::ffi::c_ushort); -} -unsafe extern "C" { - pub fn _lcong48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort); -} -unsafe extern "C" { - pub fn lrand48() -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _lrand48_r(arg1: *mut _reent) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn mrand48() -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _mrand48_r(arg1: *mut _reent) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn nrand48(arg1: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _nrand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn seed48(arg1: *mut ::core::ffi::c_ushort) -> *mut ::core::ffi::c_ushort; -} -unsafe extern "C" { - pub fn _seed48_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_ushort, - ) -> *mut ::core::ffi::c_ushort; -} -unsafe extern "C" { - pub fn srand48(arg1: ::core::ffi::c_long); -} -unsafe extern "C" { - pub fn _srand48_r(arg1: *mut _reent, arg2: ::core::ffi::c_long); -} -unsafe extern "C" { - pub fn initstate( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: usize, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn random() -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn setstate(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn srandom(arg1: ::core::ffi::c_uint); -} -unsafe extern "C" { - pub fn atoll(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn _atoll_r( - arg1: *mut _reent, - __nptr: *const ::core::ffi::c_char, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn llabs(arg1: ::core::ffi::c_longlong) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn lldiv(__numer: ::core::ffi::c_longlong, __denom: ::core::ffi::c_longlong) -> lldiv_t; -} -unsafe extern "C" { - pub fn strtoll( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn _strtoll_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn strtoull( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulonglong; -} -unsafe extern "C" { - pub fn _strtoull_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulonglong; -} -unsafe extern "C" { - pub fn cfree(arg1: *mut ::core::ffi::c_void); -} -unsafe extern "C" { - pub fn unsetenv(__string: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _unsetenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - #[must_use] - pub fn posix_memalign( - arg1: *mut *mut ::core::ffi::c_void, - arg2: usize, - arg3: usize, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _dtoa_r( - arg1: *mut _reent, - arg2: f64, - arg3: ::core::ffi::c_int, - arg4: ::core::ffi::c_int, - arg5: *mut ::core::ffi::c_int, - arg6: *mut ::core::ffi::c_int, - arg7: *mut *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _malloc_r(arg1: *mut _reent, arg2: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _calloc_r(arg1: *mut _reent, arg2: usize, arg3: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _free_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_void); -} -unsafe extern "C" { - pub fn _realloc_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _mstats_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char); -} -unsafe extern "C" { - pub fn _system_r(arg1: *mut _reent, arg2: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __eprintf( - arg1: *const ::core::ffi::c_char, - arg2: *const ::core::ffi::c_char, - arg3: ::core::ffi::c_uint, - arg4: *const ::core::ffi::c_char, - ); -} -unsafe extern "C" { - #[link_name = "\u{1}__bsd_qsort_r"] - pub fn qsort_r( - __base: *mut ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - __thunk: *mut ::core::ffi::c_void, - _compar: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut ::core::ffi::c_void, - arg2: *const ::core::ffi::c_void, - arg3: *const ::core::ffi::c_void, - ) -> ::core::ffi::c_int, - >, - ); -} -unsafe extern "C" { - #[must_use] - pub fn aligned_alloc( - arg1: ::core::ffi::c_uint, - arg2: ::core::ffi::c_uint, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn at_quick_exit( - arg1: ::core::option::Option, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn quick_exit(arg1: ::core::ffi::c_int) -> !; -} /// No error. pub const otError_OT_ERROR_NONE: otError = 0; /// Operational failed. @@ -13819,4 +12626,3 @@ unsafe extern "C" { aArrayLength: *mut u16, ) -> *mut *const ::core::ffi::c_char; } -pub type __builtin_va_list = *mut ::core::ffi::c_void; diff --git a/openthread-sys/src/include/riscv32imc-unknown-none-elf.rs b/openthread-sys/src/include/riscv32imc-unknown-none-elf.rs index 41259c9..6fbdfa2 100644 --- a/openthread-sys/src/include/riscv32imc-unknown-none-elf.rs +++ b/openthread-sys/src/include/riscv32imc-unknown-none-elf.rs @@ -137,132 +137,6 @@ where } } } -pub const __OBSOLETE_MATH_DEFAULT: u32 = 1; -pub const __OBSOLETE_MATH: u32 = 1; -pub const __NEWLIB_H__: u32 = 1; -pub const _NEWLIB_VERSION_H__: u32 = 1; -pub const _NEWLIB_VERSION: &[u8; 6] = b"4.3.0\0"; -pub const __NEWLIB__: u32 = 4; -pub const __NEWLIB_MINOR__: u32 = 3; -pub const __NEWLIB_PATCHLEVEL__: u32 = 0; -pub const _ATEXIT_DYNAMIC_ALLOC: u32 = 1; -pub const _FSEEK_OPTIMIZATION: u32 = 1; -pub const _FVWRITE_IN_STREAMIO: u32 = 1; -pub const _HAVE_CC_INHIBIT_LOOP_TO_LIBCALL: u32 = 1; -pub const _HAVE_INITFINI_ARRAY: u32 = 1; -pub const _HAVE_LONG_DOUBLE: u32 = 1; -pub const _ICONV_ENABLED: u32 = 1; -pub const _MB_LEN_MAX: u32 = 1; -pub const _NANO_MALLOC: u32 = 1; -pub const _REENT_CHECK_VERIFY: u32 = 1; -pub const _RETARGETABLE_LOCKING: u32 = 1; -pub const _UNBUF_STREAM_OPT: u32 = 1; -pub const _WANT_IO_C99_FORMATS: u32 = 1; -pub const _WANT_IO_LONG_LONG: u32 = 1; -pub const _WANT_IO_POS_ARGS: u32 = 1; -pub const _WANT_REENT_BACKWARD_BINARY_COMPAT: u32 = 1; -pub const _WANT_REENT_SMALL: u32 = 1; -pub const _WANT_USE_GDTOA: u32 = 1; -pub const _DEFAULT_SOURCE: u32 = 1; -pub const _POSIX_SOURCE: u32 = 1; -pub const _POSIX_C_SOURCE: u32 = 200809; -pub const _ATFILE_SOURCE: u32 = 1; -pub const __ATFILE_VISIBLE: u32 = 1; -pub const __BSD_VISIBLE: u32 = 1; -pub const __GNU_VISIBLE: u32 = 0; -pub const __ISO_C_VISIBLE: u32 = 2011; -pub const __LARGEFILE_VISIBLE: u32 = 0; -pub const __MISC_VISIBLE: u32 = 1; -pub const __POSIX_VISIBLE: u32 = 200809; -pub const __SVID_VISIBLE: u32 = 1; -pub const __XSI_VISIBLE: u32 = 0; -pub const __SSP_FORTIFY_LEVEL: u32 = 0; -pub const _POSIX_THREADS: u32 = 1; -pub const _POSIX_TIMEOUTS: u32 = 1; -pub const _POSIX_TIMERS: u32 = 1; -pub const _POSIX_MONOTONIC_CLOCK: u32 = 200112; -pub const _POSIX_CLOCK_SELECTION: u32 = 200112; -pub const _UNIX98_THREAD_MUTEX_ATTRIBUTES: u32 = 1; -pub const _POSIX_READER_WRITER_LOCKS: u32 = 200112; -pub const __BUFSIZ__: u32 = 128; -pub const __RAND_MAX: u32 = 2147483647; -pub const __have_longlong64: u32 = 1; -pub const __have_long32: u32 = 1; -pub const ___int8_t_defined: u32 = 1; -pub const ___int16_t_defined: u32 = 1; -pub const ___int32_t_defined: u32 = 1; -pub const ___int64_t_defined: u32 = 1; -pub const ___int_least8_t_defined: u32 = 1; -pub const ___int_least16_t_defined: u32 = 1; -pub const ___int_least32_t_defined: u32 = 1; -pub const ___int_least64_t_defined: u32 = 1; -pub const _NULL: u32 = 0; -pub const _ATEXIT_SIZE: u32 = 32; -pub const _RAND48_SEED_0: u32 = 13070; -pub const _RAND48_SEED_1: u32 = 43981; -pub const _RAND48_SEED_2: u32 = 4660; -pub const _RAND48_MULT_0: u32 = 58989; -pub const _RAND48_MULT_1: u32 = 57068; -pub const _RAND48_MULT_2: u32 = 5; -pub const _RAND48_ADD: u32 = 11; -pub const _REENT_EMERGENCY_SIZE: u32 = 25; -pub const _REENT_ASCTIME_SIZE: u32 = 26; -pub const _REENT_SIGNAL_SIZE: u32 = 24; -pub const __GNUCLIKE_ASM: u32 = 3; -pub const __GNUCLIKE___TYPEOF: u32 = 1; -pub const __GNUCLIKE___SECTION: u32 = 1; -pub const __GNUCLIKE_CTOR_SECTION_HANDLING: u32 = 1; -pub const __GNUCLIKE_BUILTIN_CONSTANT_P: u32 = 1; -pub const __GNUCLIKE_BUILTIN_VARARGS: u32 = 1; -pub const __GNUCLIKE_BUILTIN_STDARG: u32 = 1; -pub const __GNUCLIKE_BUILTIN_VAALIST: u32 = 1; -pub const __GNUC_VA_LIST_COMPATIBILITY: u32 = 1; -pub const __GNUCLIKE_BUILTIN_NEXT_ARG: u32 = 1; -pub const __GNUCLIKE_BUILTIN_MEMCPY: u32 = 1; -pub const __CC_SUPPORTS_INLINE: u32 = 1; -pub const __CC_SUPPORTS___INLINE: u32 = 1; -pub const __CC_SUPPORTS___INLINE__: u32 = 1; -pub const __CC_SUPPORTS___FUNC__: u32 = 1; -pub const __CC_SUPPORTS_WARNING: u32 = 1; -pub const __CC_SUPPORTS_VARADIC_XXX: u32 = 1; -pub const __CC_SUPPORTS_DYNAMIC_ARRAY_INIT: u32 = 1; -pub const EXIT_FAILURE: u32 = 1; -pub const EXIT_SUCCESS: u32 = 0; -pub const RAND_MAX: u32 = 2147483647; -pub const __bool_true_false_are_defined: u32 = 1; -pub const true_: u32 = 1; -pub const false_: u32 = 0; -pub const __int20: u32 = 2; -pub const __int20__: u32 = 2; -pub const __INT8: &[u8; 3] = b"hh\0"; -pub const __INT16: &[u8; 2] = b"h\0"; -pub const __INT64: &[u8; 3] = b"ll\0"; -pub const __FAST8: &[u8; 3] = b"hh\0"; -pub const __FAST16: &[u8; 2] = b"h\0"; -pub const __FAST64: &[u8; 3] = b"ll\0"; -pub const __LEAST8: &[u8; 3] = b"hh\0"; -pub const __LEAST16: &[u8; 2] = b"h\0"; -pub const __LEAST64: &[u8; 3] = b"ll\0"; -pub const __int8_t_defined: u32 = 1; -pub const __int16_t_defined: u32 = 1; -pub const __int32_t_defined: u32 = 1; -pub const __int64_t_defined: u32 = 1; -pub const __int_least8_t_defined: u32 = 1; -pub const __int_least16_t_defined: u32 = 1; -pub const __int_least32_t_defined: u32 = 1; -pub const __int_least64_t_defined: u32 = 1; -pub const __int_fast8_t_defined: u32 = 1; -pub const __int_fast16_t_defined: u32 = 1; -pub const __int_fast32_t_defined: u32 = 1; -pub const __int_fast64_t_defined: u32 = 1; -pub const WINT_MIN: u32 = 0; -pub const OT_LOG_LEVEL_NONE: u32 = 0; -pub const OT_LOG_LEVEL_CRIT: u32 = 1; -pub const OT_LOG_LEVEL_WARN: u32 = 2; -pub const OT_LOG_LEVEL_NOTE: u32 = 3; -pub const OT_LOG_LEVEL_INFO: u32 = 4; -pub const OT_LOG_LEVEL_DEBG: u32 = 5; -pub const OPENTHREAD_API_VERSION: u32 = 450; pub const OT_UPTIME_STRING_SIZE: u32 = 24; pub const OT_CHANGED_IP6_ADDRESS_ADDED: u32 = 1; pub const OT_CHANGED_IP6_ADDRESS_REMOVED: u32 = 2; @@ -296,16 +170,6 @@ pub const OT_CHANGED_ACTIVE_DATASET: u32 = 268435456; pub const OT_CHANGED_PENDING_DATASET: u32 = 536870912; pub const OT_CHANGED_NAT64_TRANSLATOR_STATE: u32 = 1073741824; pub const OT_CHANGED_PARENT_LINK_QUALITY: u32 = 2147483648; -pub const OT_CRYPTO_SHA256_HASH_SIZE: u32 = 32; -pub const OT_CRYPTO_ECDSA_MAX_DER_SIZE: u32 = 125; -pub const OT_CRYPTO_ECDSA_PUBLIC_KEY_SIZE: u32 = 64; -pub const OT_CRYPTO_ECDSA_SIGNATURE_SIZE: u32 = 64; -pub const OT_CRYPTO_PBDKF2_MAX_SALT_SIZE: u32 = 30; -pub const OT_PANID_BROADCAST: u32 = 65535; -pub const OT_EXT_ADDRESS_SIZE: u32 = 8; -pub const CSL_IE_HEADER_BYTES_LO: u32 = 4; -pub const CSL_IE_HEADER_BYTES_HI: u32 = 13; -pub const OT_MAC_KEY_SIZE: u32 = 16; pub const OT_IP6_PREFIX_SIZE: u32 = 8; pub const OT_IP6_PREFIX_BITSIZE: u32 = 64; pub const OT_IP6_IID_SIZE: u32 = 8; @@ -317,6 +181,14 @@ pub const OT_IP6_ADDRESS_STRING_SIZE: u32 = 40; pub const OT_IP6_SOCK_ADDR_STRING_SIZE: u32 = 48; pub const OT_IP6_PREFIX_STRING_SIZE: u32 = 45; pub const OT_IP6_MAX_MLR_ADDRESSES: u32 = 15; +pub const OT_CRYPTO_SHA256_HASH_SIZE: u32 = 32; +pub const OT_CRYPTO_ECDSA_MAX_DER_SIZE: u32 = 125; +pub const OT_CRYPTO_ECDSA_PUBLIC_KEY_SIZE: u32 = 64; +pub const OT_CRYPTO_ECDSA_SIGNATURE_SIZE: u32 = 64; +pub const OT_CRYPTO_PBDKF2_MAX_SALT_SIZE: u32 = 30; +pub const OT_PANID_BROADCAST: u32 = 65535; +pub const OT_EXT_ADDRESS_SIZE: u32 = 8; +pub const OT_MAC_KEY_SIZE: u32 = 16; pub const OT_NETWORK_KEY_SIZE: u32 = 16; pub const OT_NETWORK_NAME_MAX_SIZE: u32 = 16; pub const OT_EXT_PAN_ID_SIZE: u32 = 8; @@ -369,2864 +241,1815 @@ pub const OT_NETWORK_MAX_ROUTER_ID: u32 = 62; pub const OT_NEIGHBOR_INFO_ITERATOR_INIT: u32 = 0; pub const OT_JOINER_ADVDATA_MAX_LENGTH: u32 = 64; pub const OT_DURATION_STRING_SIZE: u32 = 21; +pub const OT_IP4_ADDRESS_SIZE: u32 = 4; +pub const OT_IP4_ADDRESS_STRING_SIZE: u32 = 17; +pub const OT_IP4_CIDR_STRING_SIZE: u32 = 20; +pub const OT_NETWORK_DATA_ITERATOR_INIT: u32 = 0; +pub const OT_SERVICE_DATA_MAX_SIZE: u32 = 252; +pub const OT_SERVER_DATA_MAX_SIZE: u32 = 248; +pub const OT_LOG_LEVEL_NONE: u32 = 0; +pub const OT_LOG_LEVEL_CRIT: u32 = 1; +pub const OT_LOG_LEVEL_WARN: u32 = 2; +pub const OT_LOG_LEVEL_NOTE: u32 = 3; +pub const OT_LOG_LEVEL_INFO: u32 = 4; +pub const OT_LOG_LEVEL_DEBG: u32 = 5; pub const OT_DNS_MAX_NAME_SIZE: u32 = 255; pub const OT_DNS_MAX_LABEL_SIZE: u32 = 64; pub const OT_DNS_TXT_KEY_MIN_LENGTH: u32 = 1; pub const OT_DNS_TXT_KEY_MAX_LENGTH: u32 = 9; pub const OT_DNS_TXT_KEY_ITER_MAX_LENGTH: u32 = 64; -pub const OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE: u32 = 1; -pub type wchar_t = ::core::ffi::c_int; -#[repr(C)] -#[repr(align(16))] -#[derive(Copy, Clone)] -pub struct max_align_t { - pub __clang_max_align_nonce1: ::core::ffi::c_longlong, - pub __bindgen_padding_0: u64, - pub __clang_max_align_nonce2: u128, -} -pub type wint_t = ::core::ffi::c_uint; -pub type __int8_t = ::core::ffi::c_schar; -pub type __uint8_t = ::core::ffi::c_uchar; -pub type __int16_t = ::core::ffi::c_short; -pub type __uint16_t = ::core::ffi::c_ushort; -pub type __int32_t = ::core::ffi::c_int; -pub type __uint32_t = ::core::ffi::c_uint; -pub type __int64_t = ::core::ffi::c_longlong; -pub type __uint64_t = ::core::ffi::c_ulonglong; -pub type __int_least8_t = ::core::ffi::c_schar; -pub type __uint_least8_t = ::core::ffi::c_uchar; -pub type __int_least16_t = ::core::ffi::c_short; -pub type __uint_least16_t = ::core::ffi::c_ushort; -pub type __int_least32_t = ::core::ffi::c_int; -pub type __uint_least32_t = ::core::ffi::c_uint; -pub type __int_least64_t = ::core::ffi::c_longlong; -pub type __uint_least64_t = ::core::ffi::c_ulonglong; -pub type __intmax_t = ::core::ffi::c_longlong; -pub type __uintmax_t = ::core::ffi::c_ulonglong; -pub type __intptr_t = ::core::ffi::c_int; -pub type __uintptr_t = ::core::ffi::c_uint; -pub type __blkcnt_t = ::core::ffi::c_long; -pub type __blksize_t = ::core::ffi::c_long; -pub type __fsblkcnt_t = __uint64_t; -pub type __fsfilcnt_t = __uint32_t; -pub type _off_t = ::core::ffi::c_long; -pub type __pid_t = ::core::ffi::c_int; -pub type __dev_t = ::core::ffi::c_short; -pub type __uid_t = ::core::ffi::c_ushort; -pub type __gid_t = ::core::ffi::c_ushort; -pub type __id_t = __uint32_t; -pub type __ino_t = ::core::ffi::c_ushort; -pub type __mode_t = __uint32_t; -pub type _off64_t = ::core::ffi::c_longlong; -pub type __off_t = _off_t; -pub type __loff_t = _off64_t; -pub type __key_t = ::core::ffi::c_long; -pub type _fpos_t = ::core::ffi::c_long; -pub type __size_t = ::core::ffi::c_uint; -pub type _ssize_t = ::core::ffi::c_int; -pub type __ssize_t = _ssize_t; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _mbstate_t { - pub __count: ::core::ffi::c_int, - pub __value: _mbstate_t__bindgen_ty_1, +/// No error. +pub const otError_OT_ERROR_NONE: otError = 0; +/// Operational failed. +pub const otError_OT_ERROR_FAILED: otError = 1; +/// Message was dropped. +pub const otError_OT_ERROR_DROP: otError = 2; +/// Insufficient buffers. +pub const otError_OT_ERROR_NO_BUFS: otError = 3; +/// No route available. +pub const otError_OT_ERROR_NO_ROUTE: otError = 4; +/// Service is busy and could not service the operation. +pub const otError_OT_ERROR_BUSY: otError = 5; +/// Failed to parse message. +pub const otError_OT_ERROR_PARSE: otError = 6; +/// Input arguments are invalid. +pub const otError_OT_ERROR_INVALID_ARGS: otError = 7; +/// Security checks failed. +pub const otError_OT_ERROR_SECURITY: otError = 8; +/// Address resolution requires an address query operation. +pub const otError_OT_ERROR_ADDRESS_QUERY: otError = 9; +/// Address is not in the source match table. +pub const otError_OT_ERROR_NO_ADDRESS: otError = 10; +/// Operation was aborted. +pub const otError_OT_ERROR_ABORT: otError = 11; +/// Function or method is not implemented. +pub const otError_OT_ERROR_NOT_IMPLEMENTED: otError = 12; +/// Cannot complete due to invalid state. +pub const otError_OT_ERROR_INVALID_STATE: otError = 13; +/// No acknowledgment was received after macMaxFrameRetries (IEEE 802.15.4-2006). +pub const otError_OT_ERROR_NO_ACK: otError = 14; +/// A transmission could not take place due to activity on the channel, i.e., the CSMA-CA mechanism has failed +/// (IEEE 802.15.4-2006). +pub const otError_OT_ERROR_CHANNEL_ACCESS_FAILURE: otError = 15; +/// Not currently attached to a Thread Partition. +pub const otError_OT_ERROR_DETACHED: otError = 16; +/// FCS check failure while receiving. +pub const otError_OT_ERROR_FCS: otError = 17; +/// No frame received. +pub const otError_OT_ERROR_NO_FRAME_RECEIVED: otError = 18; +/// Received a frame from an unknown neighbor. +pub const otError_OT_ERROR_UNKNOWN_NEIGHBOR: otError = 19; +/// Received a frame from an invalid source address. +pub const otError_OT_ERROR_INVALID_SOURCE_ADDRESS: otError = 20; +/// Received a frame filtered by the address filter (allowlisted or denylisted). +pub const otError_OT_ERROR_ADDRESS_FILTERED: otError = 21; +/// Received a frame filtered by the destination address check. +pub const otError_OT_ERROR_DESTINATION_ADDRESS_FILTERED: otError = 22; +/// The requested item could not be found. +pub const otError_OT_ERROR_NOT_FOUND: otError = 23; +/// The operation is already in progress. +pub const otError_OT_ERROR_ALREADY: otError = 24; +/// The creation of IPv6 address failed. +pub const otError_OT_ERROR_IP6_ADDRESS_CREATION_FAILURE: otError = 26; +/// Operation prevented by mode flags +pub const otError_OT_ERROR_NOT_CAPABLE: otError = 27; +/// Coap response or acknowledgment or DNS, SNTP response not received. +pub const otError_OT_ERROR_RESPONSE_TIMEOUT: otError = 28; +/// Received a duplicated frame. +pub const otError_OT_ERROR_DUPLICATED: otError = 29; +/// Message is being dropped from reassembly list due to timeout. +pub const otError_OT_ERROR_REASSEMBLY_TIMEOUT: otError = 30; +/// Message is not a TMF Message. +pub const otError_OT_ERROR_NOT_TMF: otError = 31; +/// Received a non-lowpan data frame. +pub const otError_OT_ERROR_NOT_LOWPAN_DATA_FRAME: otError = 32; +/// The link margin was too low. +pub const otError_OT_ERROR_LINK_MARGIN_LOW: otError = 34; +/// Input (CLI) command is invalid. +pub const otError_OT_ERROR_INVALID_COMMAND: otError = 35; +/// Special error code used to indicate success/error status is pending and not yet known. +pub const otError_OT_ERROR_PENDING: otError = 36; +/// Request rejected. +pub const otError_OT_ERROR_REJECTED: otError = 37; +/// The number of defined errors. +pub const otError_OT_NUM_ERRORS: otError = 38; +/// Generic error (should not use). +pub const otError_OT_ERROR_GENERIC: otError = 255; +/// Represents error codes used throughout OpenThread. +pub type otError = ::core::ffi::c_uint; +unsafe extern "C" { + /// Converts an otError enum into a string. + /// + /// @param[in] aError An otError enum. + /// + /// @returns A string representation of an otError. + pub fn otThreadErrorToString(aError: otError) -> *const ::core::ffi::c_char; } #[repr(C)] #[derive(Copy, Clone)] -pub union _mbstate_t__bindgen_ty_1 { - pub __wch: wint_t, - pub __wchb: [::core::ffi::c_uchar; 4usize], -} -pub type _iconv_t = *mut ::core::ffi::c_void; -pub type __clock_t = ::core::ffi::c_ulong; -pub type __time_t = __int_least64_t; -pub type __clockid_t = ::core::ffi::c_ulong; -pub type __daddr_t = ::core::ffi::c_long; -pub type __timer_t = ::core::ffi::c_ulong; -pub type __sa_family_t = __uint8_t; -pub type __socklen_t = __uint32_t; -pub type __nl_item = ::core::ffi::c_int; -pub type __nlink_t = ::core::ffi::c_ushort; -pub type __suseconds_t = ::core::ffi::c_long; -pub type __useconds_t = ::core::ffi::c_ulong; -pub type __va_list = __builtin_va_list; -pub type __ULong = ::core::ffi::c_ulong; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __lock { +pub struct otInstance { _unused: [u8; 0], } -pub type _LOCK_T = *mut __lock; unsafe extern "C" { - pub fn __retarget_lock_init(lock: *mut _LOCK_T); + /// Initializes the OpenThread library. + /// + /// Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be + /// called before any other calls to OpenThread. + /// + /// Is available and can only be used when support for multiple OpenThread instances is enabled. + /// + /// @param[in] aInstanceBuffer The buffer for OpenThread to use for allocating the otInstance structure. + /// @param[in,out] aInstanceBufferSize On input, the size of aInstanceBuffer. On output, if not enough space for + /// otInstance, the number of bytes required for otInstance. + /// + /// @returns A pointer to the new OpenThread instance. + /// + /// @sa otInstanceFinalize + pub fn otInstanceInit( + aInstanceBuffer: *mut ::core::ffi::c_void, + aInstanceBufferSize: *mut usize, + ) -> *mut otInstance; } unsafe extern "C" { - pub fn __retarget_lock_init_recursive(lock: *mut _LOCK_T); + /// Initializes the static single instance of the OpenThread library. + /// + /// Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be + /// called before any other calls to OpenThread. + /// + /// Is available and can only be used when support for multiple OpenThread instances is disabled. + /// + /// @returns A pointer to the single OpenThread instance. + pub fn otInstanceInitSingle() -> *mut otInstance; } unsafe extern "C" { - pub fn __retarget_lock_close(lock: _LOCK_T); + /// Initializes the OpenThread instance. + /// + /// This function initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be + /// called before any other calls to OpenThread. This method utilizes static buffer to initialize the OpenThread + /// instance. + /// + /// This function is available and can only be used when support for multiple OpenThread static instances is + /// enabled (`OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE`) + /// + /// @param[in] aIdx The index of the OpenThread instance to initialize. + /// + /// @returns A pointer to the new OpenThread instance. + pub fn otInstanceInitMultiple(aIdx: u8) -> *mut otInstance; } unsafe extern "C" { - pub fn __retarget_lock_close_recursive(lock: _LOCK_T); + /// Gets the index of the OpenThread instance when multiple instance is in use. + /// + /// This function is available when both `OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE` and + /// `OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE` are enabled. + /// + /// @param[in] aInstance The reference of the OpenThread instance to get index. + /// + /// @returns The index of the OpenThread instance. + pub fn otInstanceGetIndex(aInstance: *mut otInstance) -> u8; } unsafe extern "C" { - pub fn __retarget_lock_acquire(lock: _LOCK_T); + /// Gets the instance identifier. + /// + /// The instance identifier is set to a random value when the instance is constructed, and then its value will not + /// change after initialization. + /// + /// @returns The instance identifier. + pub fn otInstanceGetId(aInstance: *mut otInstance) -> u32; } unsafe extern "C" { - pub fn __retarget_lock_acquire_recursive(lock: _LOCK_T); + /// Indicates whether or not the instance is valid/initialized. + /// + /// The instance is considered valid if it is acquired and initialized using either `otInstanceInitSingle()` (in single + /// instance case) or `otInstanceInit()` (in multi instance case). A subsequent call to `otInstanceFinalize()` causes + /// the instance to be considered as uninitialized. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns TRUE if the given instance is valid/initialized, FALSE otherwise. + pub fn otInstanceIsInitialized(aInstance: *mut otInstance) -> bool; } unsafe extern "C" { - pub fn __retarget_lock_try_acquire(lock: _LOCK_T) -> ::core::ffi::c_int; + /// Disables the OpenThread library. + /// + /// Call this function when OpenThread is no longer in use. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otInstanceFinalize(aInstance: *mut otInstance); } unsafe extern "C" { - pub fn __retarget_lock_try_acquire_recursive(lock: _LOCK_T) -> ::core::ffi::c_int; + /// Returns the current instance uptime (in msec). + /// + /// Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. + /// + /// The uptime is given as number of milliseconds since OpenThread instance was initialized. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The uptime (number of milliseconds). + pub fn otInstanceGetUptime(aInstance: *mut otInstance) -> u64; } unsafe extern "C" { - pub fn __retarget_lock_release(lock: _LOCK_T); + /// Returns the current instance uptime as a human-readable string. + /// + /// Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. + /// + /// The string follows the format "::." for hours, minutes, seconds and millisecond (if uptime is + /// shorter than one day) or "
d.::." (if longer than a day). + /// + /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated + /// but the outputted string is always null-terminated. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aBuffer A pointer to a char array to output the string. + /// @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_UPTIME_STRING_SIZE`. + pub fn otInstanceGetUptimeAsString( + aInstance: *mut otInstance, + aBuffer: *mut ::core::ffi::c_char, + aSize: u16, + ); } +/// Represents a bit-field indicating specific state/configuration that has changed. See `OT_CHANGED_*` +/// definitions. +pub type otChangedFlags = u32; +/// Pointer is called to notify certain configuration or state changes within OpenThread. +/// +/// @param[in] aFlags A bit-field indicating specific state that has changed. See `OT_CHANGED_*` definitions. +/// @param[in] aContext A pointer to application-specific context. +pub type otStateChangedCallback = ::core::option::Option< + unsafe extern "C" fn(aFlags: otChangedFlags, aContext: *mut ::core::ffi::c_void), +>; unsafe extern "C" { - pub fn __retarget_lock_release_recursive(lock: _LOCK_T); -} -pub type _flock_t = _LOCK_T; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __locale_t { - _unused: [u8; 0], + /// Registers a callback to indicate when certain configuration or state changes within OpenThread. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aCallback A pointer to a function that is called with certain configuration or state changes. + /// @param[in] aContext A pointer to application-specific context. + /// + /// @retval OT_ERROR_NONE Added the callback to the list of callbacks. + /// @retval OT_ERROR_ALREADY The callback was already registered. + /// @retval OT_ERROR_NO_BUFS Could not add the callback due to resource constraints. + pub fn otSetStateChangedCallback( + aInstance: *mut otInstance, + aCallback: otStateChangedCallback, + aContext: *mut ::core::ffi::c_void, + ) -> otError; } -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _Bigint { - pub _next: *mut _Bigint, - pub _k: ::core::ffi::c_int, - pub _maxwds: ::core::ffi::c_int, - pub _sign: ::core::ffi::c_int, - pub _wds: ::core::ffi::c_int, - pub _x: [__ULong; 1usize], -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __tm { - pub __tm_sec: ::core::ffi::c_int, - pub __tm_min: ::core::ffi::c_int, - pub __tm_hour: ::core::ffi::c_int, - pub __tm_mday: ::core::ffi::c_int, - pub __tm_mon: ::core::ffi::c_int, - pub __tm_year: ::core::ffi::c_int, - pub __tm_wday: ::core::ffi::c_int, - pub __tm_yday: ::core::ffi::c_int, - pub __tm_isdst: ::core::ffi::c_int, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _on_exit_args { - pub _fnargs: [*mut ::core::ffi::c_void; 32usize], - pub _dso_handle: [*mut ::core::ffi::c_void; 32usize], - pub _fntypes: __ULong, - pub _is_cxa: __ULong, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _atexit { - pub _next: *mut _atexit, - pub _ind: ::core::ffi::c_int, - pub _fns: [::core::option::Option; 32usize], - pub _on_exit_args_ptr: *mut _on_exit_args, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __sbuf { - pub _base: *mut ::core::ffi::c_uchar, - pub _size: ::core::ffi::c_int, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __sFILE { - pub _p: *mut ::core::ffi::c_uchar, - pub _r: ::core::ffi::c_int, - pub _w: ::core::ffi::c_int, - pub _flags: ::core::ffi::c_short, - pub _file: ::core::ffi::c_short, - pub _bf: __sbuf, - pub _lbfsize: ::core::ffi::c_int, - pub _data: *mut _reent, - pub _cookie: *mut ::core::ffi::c_void, - pub _read: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: *mut ::core::ffi::c_char, - arg4: ::core::ffi::c_int, - ) -> _ssize_t, - >, - pub _write: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: *const ::core::ffi::c_char, - arg4: ::core::ffi::c_int, - ) -> _ssize_t, - >, - pub _seek: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: _fpos_t, - arg4: ::core::ffi::c_int, - ) -> _fpos_t, - >, - pub _close: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - ) -> ::core::ffi::c_int, - >, - pub _ub: __sbuf, - pub _up: *mut ::core::ffi::c_uchar, - pub _ur: ::core::ffi::c_int, - pub _ubuf: [::core::ffi::c_uchar; 3usize], - pub _nbuf: [::core::ffi::c_uchar; 1usize], - pub _lb: __sbuf, - pub _blksize: ::core::ffi::c_int, - pub _offset: _off_t, - pub _lock: _flock_t, - pub _mbstate: _mbstate_t, - pub _flags2: ::core::ffi::c_int, -} -pub type __FILE = __sFILE; -unsafe extern "C" { - pub static mut __sf: [__FILE; 3usize]; -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _glue { - pub _next: *mut _glue, - pub _niobs: ::core::ffi::c_int, - pub _iobs: *mut __FILE, -} -unsafe extern "C" { - pub static mut __sglue: _glue; -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _rand48 { - pub _seed: [::core::ffi::c_ushort; 3usize], - pub _mult: [::core::ffi::c_ushort; 3usize], - pub _add: ::core::ffi::c_ushort, - pub _rand_next: ::core::ffi::c_ulonglong, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _mprec { - pub _result: *mut _Bigint, - pub _result_k: ::core::ffi::c_int, - pub _p5s: *mut _Bigint, - pub _freelist: *mut *mut _Bigint, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _misc_reent { - pub _strtok_last: *mut ::core::ffi::c_char, - pub _mblen_state: _mbstate_t, - pub _wctomb_state: _mbstate_t, - pub _mbtowc_state: _mbstate_t, - pub _l64a_buf: [::core::ffi::c_char; 8usize], - pub _getdate_err: ::core::ffi::c_int, - pub _mbrlen_state: _mbstate_t, - pub _mbrtowc_state: _mbstate_t, - pub _mbsrtowcs_state: _mbstate_t, - pub _wcrtomb_state: _mbstate_t, - pub _wcsrtombs_state: _mbstate_t, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _reent { - pub _errno: ::core::ffi::c_int, - pub _stdin: *mut __FILE, - pub _stdout: *mut __FILE, - pub _stderr: *mut __FILE, - pub _inc: ::core::ffi::c_int, - pub _emergency: *mut ::core::ffi::c_char, - pub _reserved_0: ::core::ffi::c_int, - pub _reserved_1: ::core::ffi::c_int, - pub _locale: *mut __locale_t, - pub _mp: *mut _mprec, - pub __cleanup: ::core::option::Option, - pub _gamma_signgam: ::core::ffi::c_int, - pub _cvtlen: ::core::ffi::c_int, - pub _cvtbuf: *mut ::core::ffi::c_char, - pub _r48: *mut _rand48, - pub _localtime_buf: *mut __tm, - pub _asctime_buf: *mut ::core::ffi::c_char, - pub _sig_func: *mut ::core::option::Option, - pub _reserved_6: *mut _atexit, - pub _reserved_7: _atexit, - pub _reserved_8: _glue, - pub __sf: *mut __FILE, - pub _misc: *mut _misc_reent, - pub _signal_buf: *mut ::core::ffi::c_char, +unsafe extern "C" { + /// Removes a callback to indicate when certain configuration or state changes within OpenThread. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aCallback A pointer to a function that is called with certain configuration or state changes. + /// @param[in] aContext A pointer to application-specific context. + pub fn otRemoveStateChangeCallback( + aInstance: *mut otInstance, + aCallback: otStateChangedCallback, + aContext: *mut ::core::ffi::c_void, + ); } unsafe extern "C" { - pub fn __assert( - arg1: *const ::core::ffi::c_char, - arg2: ::core::ffi::c_int, - arg3: *const ::core::ffi::c_char, - ) -> !; -} -unsafe extern "C" { - pub fn __assert_func( - arg1: *const ::core::ffi::c_char, - arg2: ::core::ffi::c_int, - arg3: *const ::core::ffi::c_char, - arg4: *const ::core::ffi::c_char, - ) -> !; -} -unsafe extern "C" { - pub static mut _impure_ptr: *mut _reent; -} -unsafe extern "C" { - pub static mut _impure_data: _reent; + /// Triggers a platform reset. + /// + /// The reset process ensures that all the OpenThread state/info (stored in volatile memory) is erased. Note that the + /// `otPlatformReset` does not erase any persistent state/info saved in non-volatile memory. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otInstanceReset(aInstance: *mut otInstance); } unsafe extern "C" { - pub fn __getreent() -> *mut _reent; + /// Triggers a platform reset to bootloader mode, if supported. + /// + /// Requires `OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE`. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @retval OT_ERROR_NONE Reset to bootloader successfully. + /// @retval OT_ERROR_BUSY Failed due to another operation is ongoing. + /// @retval OT_ERROR_NOT_CAPABLE Not capable of resetting to bootloader. + pub fn otInstanceResetToBootloader(aInstance: *mut otInstance) -> otError; } unsafe extern "C" { - pub static mut __atexit: *mut _atexit; + /// Deletes all the settings stored on non-volatile memory, and then triggers a platform reset. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otInstanceFactoryReset(aInstance: *mut otInstance); } unsafe extern "C" { - pub static mut __atexit0: _atexit; + /// Resets the internal states of the OpenThread radio stack. + /// + /// Callbacks and configurations are preserved. + /// + /// This API is only available under radio builds (`OPENTHREAD_RADIO = 1`). + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otInstanceResetRadioStack(aInstance: *mut otInstance); } unsafe extern "C" { - pub static mut __stdio_exit_handler: ::core::option::Option; + /// Erases all the OpenThread persistent info (network settings) stored on non-volatile memory. + /// Erase is successful only if the device is in `disabled` state/role. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @retval OT_ERROR_NONE All persistent info/state was erased successfully. + /// @retval OT_ERROR_INVALID_STATE Device is not in `disabled` state/role. + pub fn otInstanceErasePersistentInfo(aInstance: *mut otInstance) -> otError; } unsafe extern "C" { - pub fn _reclaim_reent(arg1: *mut _reent); + /// Gets the OpenThread version string. + /// + /// @returns A pointer to the OpenThread version. + pub fn otGetVersionString() -> *const ::core::ffi::c_char; } unsafe extern "C" { - pub fn _fwalk_sglue( - arg1: *mut _reent, - arg2: ::core::option::Option< - unsafe extern "C" fn(arg1: *mut _reent, arg2: *mut __FILE) -> ::core::ffi::c_int, - >, - arg3: *mut _glue, - ) -> ::core::ffi::c_int; + /// Gets the OpenThread radio version string. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to the OpenThread radio version. + pub fn otGetRadioVersionString(aInstance: *mut otInstance) -> *const ::core::ffi::c_char; } #[repr(C)] #[derive(Copy, Clone)] -pub struct div_t { - pub quot: ::core::ffi::c_int, - pub rem: ::core::ffi::c_int, +pub struct otMessage { + _unused: [u8; 0], } +///< Low priority level. +pub const otMessagePriority_OT_MESSAGE_PRIORITY_LOW: otMessagePriority = 0; +///< Normal priority level. +pub const otMessagePriority_OT_MESSAGE_PRIORITY_NORMAL: otMessagePriority = 1; +///< High priority level. +pub const otMessagePriority_OT_MESSAGE_PRIORITY_HIGH: otMessagePriority = 2; +/// Defines the OpenThread message priority levels. +pub type otMessagePriority = ::core::ffi::c_uint; +///< Message from Thread Netif. +pub const otMessageOrigin_OT_MESSAGE_ORIGIN_THREAD_NETIF: otMessageOrigin = 0; +///< Message from a trusted source on host. +pub const otMessageOrigin_OT_MESSAGE_ORIGIN_HOST_TRUSTED: otMessageOrigin = 1; +///< Message from an untrusted source on host. +pub const otMessageOrigin_OT_MESSAGE_ORIGIN_HOST_UNTRUSTED: otMessageOrigin = 2; +/// Defines the OpenThread message origins. +pub type otMessageOrigin = ::core::ffi::c_uint; +/// Represents a message settings. #[repr(C)] -#[derive(Copy, Clone)] -pub struct ldiv_t { - pub quot: ::core::ffi::c_long, - pub rem: ::core::ffi::c_long, +#[derive(Default, Copy, Clone)] +pub struct otMessageSettings { + ///< TRUE if the message should be secured at Layer 2. + pub mLinkSecurityEnabled: bool, + ///< Priority level (MUST be a `OT_MESSAGE_PRIORITY_*` from `otMessagePriority`). + pub mPriority: u8, } +/// Represents link-specific information for messages received from the Thread radio. #[repr(C)] -#[derive(Copy, Clone)] -pub struct lldiv_t { - pub quot: ::core::ffi::c_longlong, - pub rem: ::core::ffi::c_longlong, -} -pub type __compar_fn_t = ::core::option::Option< - unsafe extern "C" fn( - arg1: *const ::core::ffi::c_void, - arg2: *const ::core::ffi::c_void, - ) -> ::core::ffi::c_int, ->; -unsafe extern "C" { - pub fn __locale_mb_cur_max() -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn abort() -> !; -} -unsafe extern "C" { - pub fn abs(arg1: ::core::ffi::c_int) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn arc4random() -> __uint32_t; -} -unsafe extern "C" { - pub fn arc4random_uniform(arg1: __uint32_t) -> __uint32_t; -} -unsafe extern "C" { - pub fn arc4random_buf(arg1: *mut ::core::ffi::c_void, arg2: usize); +#[derive(Default, Copy, Clone)] +pub struct otThreadLinkInfo { + ///< Source PAN ID + pub mPanId: u16, + ///< 802.15.4 Channel + pub mChannel: u8, + ///< Received Signal Strength in dBm (averaged over fragments) + pub mRss: i8, + ///< Average Link Quality Indicator (averaged over fragments) + pub mLqi: u8, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + ///< The time sync sequence. + pub mTimeSyncSeq: u8, + ///< The time offset to the Thread network time, in microseconds. + pub mNetworkTimeOffset: i64, + ///< Radio link type. + pub mRadioType: u8, } -unsafe extern "C" { - pub fn atexit(__func: ::core::option::Option) -> ::core::ffi::c_int; +impl otThreadLinkInfo { + #[inline] + pub fn mLinkSecurity(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_mLinkSecurity(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mLinkSecurity_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 0usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mLinkSecurity_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mIsDstPanIdBroadcast(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mIsDstPanIdBroadcast(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mIsDstPanIdBroadcast_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 1usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mIsDstPanIdBroadcast_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 1usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn new_bitfield_1( + mLinkSecurity: bool, + mIsDstPanIdBroadcast: bool, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let mLinkSecurity: u8 = unsafe { ::core::mem::transmute(mLinkSecurity) }; + mLinkSecurity as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mIsDstPanIdBroadcast: u8 = unsafe { ::core::mem::transmute(mIsDstPanIdBroadcast) }; + mIsDstPanIdBroadcast as u64 + }); + __bindgen_bitfield_unit + } } unsafe extern "C" { - pub fn atof(__nptr: *const ::core::ffi::c_char) -> f64; + /// Free an allocated message buffer. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// + /// @sa otMessageAppend + /// @sa otMessageGetLength + /// @sa otMessageSetLength + /// @sa otMessageGetOffset + /// @sa otMessageSetOffset + /// @sa otMessageRead + /// @sa otMessageWrite + pub fn otMessageFree(aMessage: *mut otMessage); } unsafe extern "C" { - pub fn atoff(__nptr: *const ::core::ffi::c_char) -> f32; + /// Get the message length in bytes. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// + /// @returns The message length in bytes. + /// + /// @sa otMessageFree + /// @sa otMessageAppend + /// @sa otMessageSetLength + /// @sa otMessageGetOffset + /// @sa otMessageSetOffset + /// @sa otMessageRead + /// @sa otMessageWrite + /// @sa otMessageSetLength + pub fn otMessageGetLength(aMessage: *const otMessage) -> u16; } unsafe extern "C" { - pub fn atoi(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _atoi_r(arg1: *mut _reent, __nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_int; + /// Set the message length in bytes. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// @param[in] aLength A length in bytes. + /// + /// @retval OT_ERROR_NONE Successfully set the message length. + /// @retval OT_ERROR_NO_BUFS No available buffers to grow the message. + /// + /// @sa otMessageFree + /// @sa otMessageAppend + /// @sa otMessageGetLength + /// @sa otMessageGetOffset + /// @sa otMessageSetOffset + /// @sa otMessageRead + /// @sa otMessageWrite + pub fn otMessageSetLength(aMessage: *mut otMessage, aLength: u16) -> otError; } unsafe extern "C" { - pub fn atol(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_long; + /// Get the message offset in bytes. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// + /// @returns The message offset value. + /// + /// @sa otMessageFree + /// @sa otMessageAppend + /// @sa otMessageGetLength + /// @sa otMessageSetLength + /// @sa otMessageSetOffset + /// @sa otMessageRead + /// @sa otMessageWrite + pub fn otMessageGetOffset(aMessage: *const otMessage) -> u16; } unsafe extern "C" { - pub fn _atol_r(arg1: *mut _reent, __nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_long; + /// Set the message offset in bytes. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// @param[in] aOffset An offset in bytes. + /// + /// @sa otMessageFree + /// @sa otMessageAppend + /// @sa otMessageGetLength + /// @sa otMessageSetLength + /// @sa otMessageGetOffset + /// @sa otMessageRead + /// @sa otMessageWrite + pub fn otMessageSetOffset(aMessage: *mut otMessage, aOffset: u16); } unsafe extern "C" { - pub fn bsearch( - __key: *const ::core::ffi::c_void, - __base: *const ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - _compar: __compar_fn_t, - ) -> *mut ::core::ffi::c_void; + /// Indicates whether or not link security is enabled for the message. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// + /// @retval TRUE If link security is enabled. + /// @retval FALSE If link security is not enabled. + pub fn otMessageIsLinkSecurityEnabled(aMessage: *const otMessage) -> bool; } unsafe extern "C" { - #[must_use] - pub fn calloc(arg1: ::core::ffi::c_uint, arg2: ::core::ffi::c_uint) - -> *mut ::core::ffi::c_void; + /// Indicates whether or not the message is allowed to be looped back to host. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// + /// @retval TRUE If the message is allowed to be looped back to host. + /// @retval FALSE If the message is not allowed to be looped back to host. + pub fn otMessageIsLoopbackToHostAllowed(aMessage: *const otMessage) -> bool; } unsafe extern "C" { - pub fn div(__numer: ::core::ffi::c_int, __denom: ::core::ffi::c_int) -> div_t; + /// Sets whether or not the message is allowed to be looped back to host. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// @param[in] aAllowLoopbackToHost Whether to allow the message to be looped back to host. + pub fn otMessageSetLoopbackToHostAllowed(aMessage: *mut otMessage, aAllowLoopbackToHost: bool); } unsafe extern "C" { - pub fn exit(__status: ::core::ffi::c_int) -> !; + /// Indicates whether the given message may be looped back in a case of a multicast destination address. + /// + /// If @p aMessage is used along with an `otMessageInfo`, the `mMulticastLoop` field from `otMessageInfo` structure + /// takes precedence and will be used instead of the the value set on @p aMessage. + /// + /// This API is mainly intended for use along with `otIp6Send()` which expects an already prepared IPv6 message. + /// + /// @param[in] aMessage A pointer to the message. + pub fn otMessageIsMulticastLoopEnabled(aMessage: *mut otMessage) -> bool; } unsafe extern "C" { - pub fn free(arg1: *mut ::core::ffi::c_void); + /// Controls whether the given message may be looped back in a case of a multicast destination address. + /// + /// @param[in] aMessage A pointer to the message. + /// @param[in] aEnabled The configuration value. + pub fn otMessageSetMulticastLoopEnabled(aMessage: *mut otMessage, aEnabled: bool); } unsafe extern "C" { - pub fn getenv(__string: *const ::core::ffi::c_char) -> *mut ::core::ffi::c_char; + /// Gets the message origin. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// + /// @returns The message origin. + pub fn otMessageGetOrigin(aMessage: *const otMessage) -> otMessageOrigin; } unsafe extern "C" { - pub fn _getenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; + /// Sets the message origin. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// @param[in] aOrigin The message origin. + pub fn otMessageSetOrigin(aMessage: *mut otMessage, aOrigin: otMessageOrigin); } unsafe extern "C" { - pub fn _findenv( - arg1: *const ::core::ffi::c_char, - arg2: *mut ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; + /// Sets/forces the message to be forwarded using direct transmission. + /// Default setting for a new message is `false`. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// @param[in] aEnabled If `true`, the message is forced to use direct transmission. If `false`, the message follows + /// the normal procedure. + pub fn otMessageSetDirectTransmission(aMessage: *mut otMessage, aEnabled: bool); } unsafe extern "C" { - pub fn _findenv_r( - arg1: *mut _reent, - arg2: *const ::core::ffi::c_char, - arg3: *mut ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; + /// Returns the average RSS (received signal strength) associated with the message. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// + /// @returns The average RSS value (in dBm) or OT_RADIO_RSSI_INVALID if no average RSS is available. + pub fn otMessageGetRss(aMessage: *const otMessage) -> i8; } unsafe extern "C" { - pub static mut suboptarg: *mut ::core::ffi::c_char; + /// Retrieves the link-specific information for a message received over Thread radio. + /// + /// @param[in] aMessage The message from which to retrieve `otThreadLinkInfo`. + /// @pram[out] aLinkInfo A pointer to an `otThreadLinkInfo` to populate. + /// + /// @retval OT_ERROR_NONE Successfully retrieved the link info, @p `aLinkInfo` is updated. + /// @retval OT_ERROR_NOT_FOUND Message origin is not `OT_MESSAGE_ORIGIN_THREAD_NETIF`. + pub fn otMessageGetThreadLinkInfo( + aMessage: *const otMessage, + aLinkInfo: *mut otThreadLinkInfo, + ) -> otError; } unsafe extern "C" { - pub fn getsubopt( - arg1: *mut *mut ::core::ffi::c_char, - arg2: *const *mut ::core::ffi::c_char, - arg3: *mut *mut ::core::ffi::c_char, - ) -> ::core::ffi::c_int; + /// Append bytes to a message. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// @param[in] aBuf A pointer to the data to append. + /// @param[in] aLength Number of bytes to append. + /// + /// @retval OT_ERROR_NONE Successfully appended to the message + /// @retval OT_ERROR_NO_BUFS No available buffers to grow the message. + /// + /// @sa otMessageFree + /// @sa otMessageGetLength + /// @sa otMessageSetLength + /// @sa otMessageGetOffset + /// @sa otMessageSetOffset + /// @sa otMessageRead + /// @sa otMessageWrite + pub fn otMessageAppend( + aMessage: *mut otMessage, + aBuf: *const ::core::ffi::c_void, + aLength: u16, + ) -> otError; } unsafe extern "C" { - pub fn labs(arg1: ::core::ffi::c_long) -> ::core::ffi::c_long; + /// Read bytes from a message. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// @param[in] aOffset An offset in bytes. + /// @param[in] aBuf A pointer to a buffer that message bytes are read to. + /// @param[in] aLength Number of bytes to read. + /// + /// @returns The number of bytes read. + /// + /// @sa otMessageFree + /// @sa otMessageAppend + /// @sa otMessageGetLength + /// @sa otMessageSetLength + /// @sa otMessageGetOffset + /// @sa otMessageSetOffset + /// @sa otMessageWrite + pub fn otMessageRead( + aMessage: *const otMessage, + aOffset: u16, + aBuf: *mut ::core::ffi::c_void, + aLength: u16, + ) -> u16; } unsafe extern "C" { - pub fn ldiv(__numer: ::core::ffi::c_long, __denom: ::core::ffi::c_long) -> ldiv_t; + /// Write bytes to a message. + /// + /// @param[in] aMessage A pointer to a message buffer. + /// @param[in] aOffset An offset in bytes. + /// @param[in] aBuf A pointer to a buffer that message bytes are written from. + /// @param[in] aLength Number of bytes to write. + /// + /// @returns The number of bytes written. + /// + /// @sa otMessageFree + /// @sa otMessageAppend + /// @sa otMessageGetLength + /// @sa otMessageSetLength + /// @sa otMessageGetOffset + /// @sa otMessageSetOffset + /// @sa otMessageRead + pub fn otMessageWrite( + aMessage: *mut otMessage, + aOffset: u16, + aBuf: *const ::core::ffi::c_void, + aLength: u16, + ) -> ::core::ffi::c_int; } -unsafe extern "C" { - #[must_use] - pub fn malloc(arg1: ::core::ffi::c_uint) -> *mut ::core::ffi::c_void; +/// Represents an OpenThread message queue. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otMessageQueue { + ///< Opaque data used by the implementation. + pub mData: *mut ::core::ffi::c_void, } -unsafe extern "C" { - pub fn mblen(arg1: *const ::core::ffi::c_char, arg2: usize) -> ::core::ffi::c_int; +impl Default for otMessageQueue { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - pub fn _mblen_r( - arg1: *mut _reent, - arg2: *const ::core::ffi::c_char, - arg3: usize, - arg4: *mut _mbstate_t, - ) -> ::core::ffi::c_int; +/// Represents information about a message queue. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otMessageQueueInfo { + ///< Number of messages in the queue. + pub mNumMessages: u16, + ///< Number of data buffers used by messages in the queue. + pub mNumBuffers: u16, + ///< Total number of bytes used by all messages in the queue. + pub mTotalBytes: u32, } -unsafe extern "C" { - pub fn mbtowc( - arg1: *mut wchar_t, - arg2: *const ::core::ffi::c_char, - arg3: usize, - ) -> ::core::ffi::c_int; +/// Represents the message buffer information for different queues used by OpenThread stack. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otBufferInfo { + ///< The total number of buffers in the messages pool (0xffff if unknown). + pub mTotalBuffers: u16, + ///< The number of free buffers (0xffff if unknown). + pub mFreeBuffers: u16, + /// The maximum number of used buffers at the same time since OT stack initialization or last call to + /// `otMessageResetBufferInfo()`. + pub mMaxUsedBuffers: u16, + ///< Info about 6LoWPAN send queue. + pub m6loSendQueue: otMessageQueueInfo, + ///< Info about 6LoWPAN reassembly queue. + pub m6loReassemblyQueue: otMessageQueueInfo, + ///< Info about IPv6 send queue. + pub mIp6Queue: otMessageQueueInfo, + ///< Info about MPL send queue. + pub mMplQueue: otMessageQueueInfo, + ///< Info about MLE delayed message queue. + pub mMleQueue: otMessageQueueInfo, + ///< Info about CoAP/TMF send queue. + pub mCoapQueue: otMessageQueueInfo, + ///< Info about CoAP secure send queue. + pub mCoapSecureQueue: otMessageQueueInfo, + ///< Info about application CoAP send queue. + pub mApplicationCoapQueue: otMessageQueueInfo, } unsafe extern "C" { - pub fn _mbtowc_r( - arg1: *mut _reent, - arg2: *mut wchar_t, - arg3: *const ::core::ffi::c_char, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> ::core::ffi::c_int; + /// Initialize the message queue. + /// + /// MUST be called once and only once for a `otMessageQueue` instance before any other `otMessageQueue` + /// functions. The behavior is undefined if other queue APIs are used with an `otMessageQueue` before it being + /// initialized or if it is initialized more than once. + /// + /// @param[in] aQueue A pointer to a message queue. + pub fn otMessageQueueInit(aQueue: *mut otMessageQueue); } unsafe extern "C" { - pub fn wctomb(arg1: *mut ::core::ffi::c_char, arg2: wchar_t) -> ::core::ffi::c_int; + /// Adds a message to the end of the given message queue. + /// + /// @param[in] aQueue A pointer to the message queue. + /// @param[in] aMessage The message to add. + pub fn otMessageQueueEnqueue(aQueue: *mut otMessageQueue, aMessage: *mut otMessage); } unsafe extern "C" { - pub fn _wctomb_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: wchar_t, - arg4: *mut _mbstate_t, - ) -> ::core::ffi::c_int; + /// Adds a message at the head/front of the given message queue. + /// + /// @param[in] aQueue A pointer to the message queue. + /// @param[in] aMessage The message to add. + pub fn otMessageQueueEnqueueAtHead(aQueue: *mut otMessageQueue, aMessage: *mut otMessage); } unsafe extern "C" { - pub fn mbstowcs(arg1: *mut wchar_t, arg2: *const ::core::ffi::c_char, arg3: usize) -> usize; + /// Removes a message from the given message queue. + /// + /// @param[in] aQueue A pointer to the message queue. + /// @param[in] aMessage The message to remove. + pub fn otMessageQueueDequeue(aQueue: *mut otMessageQueue, aMessage: *mut otMessage); } unsafe extern "C" { - pub fn _mbstowcs_r( - arg1: *mut _reent, - arg2: *mut wchar_t, - arg3: *const ::core::ffi::c_char, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> usize; -} -unsafe extern "C" { - pub fn wcstombs(arg1: *mut ::core::ffi::c_char, arg2: *const wchar_t, arg3: usize) -> usize; -} -unsafe extern "C" { - pub fn _wcstombs_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: *const wchar_t, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> usize; -} -unsafe extern "C" { - pub fn mkdtemp(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn mkstemp(arg1: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mkstemps(arg1: *mut ::core::ffi::c_char, arg2: ::core::ffi::c_int) - -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mktemp(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _mkdtemp_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _mkostemp_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkostemps_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - arg4: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkstemp_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkstemps_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mktemp_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char) - -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn qsort( - __base: *mut ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - _compar: __compar_fn_t, - ); -} -unsafe extern "C" { - pub fn rand() -> ::core::ffi::c_int; -} -unsafe extern "C" { - #[must_use] - pub fn realloc( - arg1: *mut ::core::ffi::c_void, - arg2: ::core::ffi::c_uint, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - #[must_use] - pub fn reallocarray( - arg1: *mut ::core::ffi::c_void, - arg2: usize, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - #[must_use] - pub fn reallocf(arg1: *mut ::core::ffi::c_void, arg2: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn realpath( - path: *const ::core::ffi::c_char, - resolved_path: *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn rpmatch(response: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn srand(__seed: ::core::ffi::c_uint); -} -unsafe extern "C" { - pub fn strtod(__n: *const ::core::ffi::c_char, __end_PTR: *mut *mut ::core::ffi::c_char) - -> f64; -} -unsafe extern "C" { - pub fn _strtod_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - ) -> f64; -} -unsafe extern "C" { - pub fn strtof(__n: *const ::core::ffi::c_char, __end_PTR: *mut *mut ::core::ffi::c_char) - -> f32; -} -unsafe extern "C" { - pub fn strtol( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _strtol_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn strtoul( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulong; -} -unsafe extern "C" { - pub fn _strtoul_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulong; -} -unsafe extern "C" { - pub fn system(__string: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn a64l(__input: *const ::core::ffi::c_char) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn l64a(__input: ::core::ffi::c_long) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _l64a_r(arg1: *mut _reent, __input: ::core::ffi::c_long) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn on_exit( - __func: ::core::option::Option< - unsafe extern "C" fn(arg1: ::core::ffi::c_int, arg2: *mut ::core::ffi::c_void), - >, - __arg: *mut ::core::ffi::c_void, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _Exit(__status: ::core::ffi::c_int) -> !; -} -unsafe extern "C" { - pub fn putenv(__string: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _putenv_r(arg1: *mut _reent, __string: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _reallocf_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn setenv( - __string: *const ::core::ffi::c_char, - __value: *const ::core::ffi::c_char, - __overwrite: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _setenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - __value: *const ::core::ffi::c_char, - __overwrite: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __itoa( - arg1: ::core::ffi::c_int, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn __utoa( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn itoa( - arg1: ::core::ffi::c_int, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn utoa( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn rand_r(__seed: *mut ::core::ffi::c_uint) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn drand48() -> f64; -} -unsafe extern "C" { - pub fn _drand48_r(arg1: *mut _reent) -> f64; -} -unsafe extern "C" { - pub fn erand48(arg1: *mut ::core::ffi::c_ushort) -> f64; -} -unsafe extern "C" { - pub fn _erand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> f64; + /// Returns a pointer to the message at the head of the queue. + /// + /// @param[in] aQueue A pointer to a message queue. + /// + /// @returns A pointer to the message at the head of queue or NULL if queue is empty. + pub fn otMessageQueueGetHead(aQueue: *mut otMessageQueue) -> *mut otMessage; } unsafe extern "C" { - pub fn jrand48(arg1: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; + /// Returns a pointer to the next message in the queue by iterating forward (from head to tail). + /// + /// @param[in] aQueue A pointer to a message queue. + /// @param[in] aMessage A pointer to current message buffer. + /// + /// @returns A pointer to the next message in the queue after `aMessage` or NULL if `aMessage is the tail of queue. + /// NULL is returned if `aMessage` is not in the queue `aQueue`. + pub fn otMessageQueueGetNext( + aQueue: *mut otMessageQueue, + aMessage: *const otMessage, + ) -> *mut otMessage; } unsafe extern "C" { - pub fn _jrand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; + /// Get the Message Buffer information. + /// + /// @param[in] aInstance A pointer to the OpenThread instance. + /// @param[out] aBufferInfo A pointer where the message buffer information is written. + pub fn otMessageGetBufferInfo(aInstance: *mut otInstance, aBufferInfo: *mut otBufferInfo); } unsafe extern "C" { - pub fn lcong48(arg1: *mut ::core::ffi::c_ushort); + /// Reset the Message Buffer information counter tracking the maximum number buffers in use at the same time. + /// + /// This resets `mMaxUsedBuffers` in `otBufferInfo`. + /// + /// @param[in] aInstance A pointer to the OpenThread instance. + pub fn otMessageResetBufferInfo(aInstance: *mut otInstance); } -unsafe extern "C" { - pub fn _lcong48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort); +/// @struct otIp6InterfaceIdentifier +/// +/// Represents the Interface Identifier of an IPv6 address. +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub struct otIp6InterfaceIdentifier { + ///< The Interface Identifier accessor fields + pub mFields: otIp6InterfaceIdentifier__bindgen_ty_1, } -unsafe extern "C" { - pub fn lrand48() -> ::core::ffi::c_long; +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub union otIp6InterfaceIdentifier__bindgen_ty_1 { + ///< 8-bit fields + pub m8: [u8; 8usize], + ///< 16-bit fields + pub m16: [u16; 4usize], + ///< 32-bit fields + pub m32: [u32; 2usize], } -unsafe extern "C" { - pub fn _lrand48_r(arg1: *mut _reent) -> ::core::ffi::c_long; +impl Default for otIp6InterfaceIdentifier__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - pub fn mrand48() -> ::core::ffi::c_long; +impl Default for otIp6InterfaceIdentifier { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - pub fn _mrand48_r(arg1: *mut _reent) -> ::core::ffi::c_long; +/// @struct otIp6NetworkPrefix +/// +/// Represents the Network Prefix of an IPv6 address (most significant 64 bits of the address). +#[repr(C, packed)] +#[derive(Default, Copy, Clone)] +pub struct otIp6NetworkPrefix { + ///< The Network Prefix. + pub m8: [u8; 8usize], } -unsafe extern "C" { - pub fn nrand48(arg1: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; +/// @struct otIp6AddressComponents +/// +/// Represents the components of an IPv6 address. +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub struct otIp6AddressComponents { + ///< The Network Prefix (most significant 64 bits of the address) + pub mNetworkPrefix: otIp6NetworkPrefix, + ///< The Interface Identifier (least significant 64 bits of the address) + pub mIid: otIp6InterfaceIdentifier, } -unsafe extern "C" { - pub fn _nrand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; +impl Default for otIp6AddressComponents { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - pub fn seed48(arg1: *mut ::core::ffi::c_ushort) -> *mut ::core::ffi::c_ushort; +/// @struct otIp6Address +/// +/// Represents an IPv6 address. +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub struct otIp6Address { + ///< IPv6 accessor fields + pub mFields: otIp6Address__bindgen_ty_1, } -unsafe extern "C" { - pub fn _seed48_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_ushort, - ) -> *mut ::core::ffi::c_ushort; +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub union otIp6Address__bindgen_ty_1 { + ///< 8-bit fields + pub m8: [u8; 16usize], + ///< 16-bit fields + pub m16: [u16; 8usize], + ///< 32-bit fields + pub m32: [u32; 4usize], + ///< IPv6 address components + pub mComponents: otIp6AddressComponents, } -unsafe extern "C" { - pub fn srand48(arg1: ::core::ffi::c_long); +impl Default for otIp6Address__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - pub fn _srand48_r(arg1: *mut _reent, arg2: ::core::ffi::c_long); +impl Default for otIp6Address { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - pub fn initstate( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: usize, - ) -> *mut ::core::ffi::c_char; +/// @struct otIp6Prefix +/// +/// Represents an IPv6 prefix. +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub struct otIp6Prefix { + ///< The IPv6 prefix. + pub mPrefix: otIp6Address, + ///< The IPv6 prefix length (in bits). + pub mLength: u8, } -unsafe extern "C" { - pub fn random() -> ::core::ffi::c_long; +impl Default for otIp6Prefix { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - pub fn setstate(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; +///< Thread assigned address (ALOC, RLOC, MLEID, etc) +pub const OT_ADDRESS_ORIGIN_THREAD: _bindgen_ty_1 = 0; +///< SLAAC assigned address +pub const OT_ADDRESS_ORIGIN_SLAAC: _bindgen_ty_1 = 1; +///< DHCPv6 assigned address +pub const OT_ADDRESS_ORIGIN_DHCPV6: _bindgen_ty_1 = 2; +///< Manually assigned address +pub const OT_ADDRESS_ORIGIN_MANUAL: _bindgen_ty_1 = 3; +/// IPv6 Address origins +pub type _bindgen_ty_1 = ::core::ffi::c_uint; +/// Represents an IPv6 network interface unicast address. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otNetifAddress { + ///< The IPv6 unicast address. + pub mAddress: otIp6Address, + ///< The Prefix length (in bits). + pub mPrefixLength: u8, + ///< The IPv6 address origin. + pub mAddressOrigin: u8, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + ///< A pointer to the next network interface address. + pub mNext: *const otNetifAddress, } -unsafe extern "C" { - pub fn srandom(arg1: ::core::ffi::c_uint); +impl Default for otNetifAddress { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - pub fn atoll(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn _atoll_r( - arg1: *mut _reent, - __nptr: *const ::core::ffi::c_char, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn llabs(arg1: ::core::ffi::c_longlong) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn lldiv(__numer: ::core::ffi::c_longlong, __denom: ::core::ffi::c_longlong) -> lldiv_t; -} -unsafe extern "C" { - pub fn strtoll( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn _strtoll_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn strtoull( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulonglong; -} -unsafe extern "C" { - pub fn _strtoull_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulonglong; -} -unsafe extern "C" { - pub fn cfree(arg1: *mut ::core::ffi::c_void); -} -unsafe extern "C" { - pub fn unsetenv(__string: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _unsetenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - #[must_use] - pub fn posix_memalign( - arg1: *mut *mut ::core::ffi::c_void, - arg2: usize, - arg3: usize, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _dtoa_r( - arg1: *mut _reent, - arg2: f64, - arg3: ::core::ffi::c_int, - arg4: ::core::ffi::c_int, - arg5: *mut ::core::ffi::c_int, - arg6: *mut ::core::ffi::c_int, - arg7: *mut *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _malloc_r(arg1: *mut _reent, arg2: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _calloc_r(arg1: *mut _reent, arg2: usize, arg3: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _free_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_void); -} -unsafe extern "C" { - pub fn _realloc_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _mstats_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char); -} -unsafe extern "C" { - pub fn _system_r(arg1: *mut _reent, arg2: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __eprintf( - arg1: *const ::core::ffi::c_char, - arg2: *const ::core::ffi::c_char, - arg3: ::core::ffi::c_uint, - arg4: *const ::core::ffi::c_char, - ); -} -unsafe extern "C" { - #[link_name = "\u{1}__bsd_qsort_r"] - pub fn qsort_r( - __base: *mut ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - __thunk: *mut ::core::ffi::c_void, - _compar: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut ::core::ffi::c_void, - arg2: *const ::core::ffi::c_void, - arg3: *const ::core::ffi::c_void, - ) -> ::core::ffi::c_int, - >, - ); -} -unsafe extern "C" { - #[must_use] - pub fn aligned_alloc( - arg1: ::core::ffi::c_uint, - arg2: ::core::ffi::c_uint, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn at_quick_exit( - arg1: ::core::option::Option, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn quick_exit(arg1: ::core::ffi::c_int) -> !; -} -pub type intmax_t = __intmax_t; -pub type uintmax_t = __uintmax_t; -pub type int_least8_t = __int_least8_t; -pub type uint_least8_t = __uint_least8_t; -pub type int_least16_t = __int_least16_t; -pub type uint_least16_t = __uint_least16_t; -pub type int_least32_t = __int_least32_t; -pub type uint_least32_t = __uint_least32_t; -pub type int_least64_t = __int_least64_t; -pub type uint_least64_t = __uint_least64_t; -pub type int_fast8_t = ::core::ffi::c_schar; -pub type uint_fast8_t = ::core::ffi::c_uchar; -pub type int_fast16_t = ::core::ffi::c_short; -pub type uint_fast16_t = ::core::ffi::c_ushort; -pub type int_fast32_t = ::core::ffi::c_int; -pub type uint_fast32_t = ::core::ffi::c_uint; -pub type int_fast64_t = ::core::ffi::c_longlong; -pub type uint_fast64_t = ::core::ffi::c_ulonglong; -/// No error. -pub const otError_OT_ERROR_NONE: otError = 0; -/// Operational failed. -pub const otError_OT_ERROR_FAILED: otError = 1; -/// Message was dropped. -pub const otError_OT_ERROR_DROP: otError = 2; -/// Insufficient buffers. -pub const otError_OT_ERROR_NO_BUFS: otError = 3; -/// No route available. -pub const otError_OT_ERROR_NO_ROUTE: otError = 4; -/// Service is busy and could not service the operation. -pub const otError_OT_ERROR_BUSY: otError = 5; -/// Failed to parse message. -pub const otError_OT_ERROR_PARSE: otError = 6; -/// Input arguments are invalid. -pub const otError_OT_ERROR_INVALID_ARGS: otError = 7; -/// Security checks failed. -pub const otError_OT_ERROR_SECURITY: otError = 8; -/// Address resolution requires an address query operation. -pub const otError_OT_ERROR_ADDRESS_QUERY: otError = 9; -/// Address is not in the source match table. -pub const otError_OT_ERROR_NO_ADDRESS: otError = 10; -/// Operation was aborted. -pub const otError_OT_ERROR_ABORT: otError = 11; -/// Function or method is not implemented. -pub const otError_OT_ERROR_NOT_IMPLEMENTED: otError = 12; -/// Cannot complete due to invalid state. -pub const otError_OT_ERROR_INVALID_STATE: otError = 13; -/// No acknowledgment was received after macMaxFrameRetries (IEEE 802.15.4-2006). -pub const otError_OT_ERROR_NO_ACK: otError = 14; -/// A transmission could not take place due to activity on the channel, i.e., the CSMA-CA mechanism has failed -/// (IEEE 802.15.4-2006). -pub const otError_OT_ERROR_CHANNEL_ACCESS_FAILURE: otError = 15; -/// Not currently attached to a Thread Partition. -pub const otError_OT_ERROR_DETACHED: otError = 16; -/// FCS check failure while receiving. -pub const otError_OT_ERROR_FCS: otError = 17; -/// No frame received. -pub const otError_OT_ERROR_NO_FRAME_RECEIVED: otError = 18; -/// Received a frame from an unknown neighbor. -pub const otError_OT_ERROR_UNKNOWN_NEIGHBOR: otError = 19; -/// Received a frame from an invalid source address. -pub const otError_OT_ERROR_INVALID_SOURCE_ADDRESS: otError = 20; -/// Received a frame filtered by the address filter (allowlisted or denylisted). -pub const otError_OT_ERROR_ADDRESS_FILTERED: otError = 21; -/// Received a frame filtered by the destination address check. -pub const otError_OT_ERROR_DESTINATION_ADDRESS_FILTERED: otError = 22; -/// The requested item could not be found. -pub const otError_OT_ERROR_NOT_FOUND: otError = 23; -/// The operation is already in progress. -pub const otError_OT_ERROR_ALREADY: otError = 24; -/// The creation of IPv6 address failed. -pub const otError_OT_ERROR_IP6_ADDRESS_CREATION_FAILURE: otError = 26; -/// Operation prevented by mode flags -pub const otError_OT_ERROR_NOT_CAPABLE: otError = 27; -/// Coap response or acknowledgment or DNS, SNTP response not received. -pub const otError_OT_ERROR_RESPONSE_TIMEOUT: otError = 28; -/// Received a duplicated frame. -pub const otError_OT_ERROR_DUPLICATED: otError = 29; -/// Message is being dropped from reassembly list due to timeout. -pub const otError_OT_ERROR_REASSEMBLY_TIMEOUT: otError = 30; -/// Message is not a TMF Message. -pub const otError_OT_ERROR_NOT_TMF: otError = 31; -/// Received a non-lowpan data frame. -pub const otError_OT_ERROR_NOT_LOWPAN_DATA_FRAME: otError = 32; -/// The link margin was too low. -pub const otError_OT_ERROR_LINK_MARGIN_LOW: otError = 34; -/// Input (CLI) command is invalid. -pub const otError_OT_ERROR_INVALID_COMMAND: otError = 35; -/// Special error code used to indicate success/error status is pending and not yet known. -pub const otError_OT_ERROR_PENDING: otError = 36; -/// Request rejected. -pub const otError_OT_ERROR_REJECTED: otError = 37; -/// The number of defined errors. -pub const otError_OT_NUM_ERRORS: otError = 38; -/// Generic error (should not use). -pub const otError_OT_ERROR_GENERIC: otError = 255; -/// Represents error codes used throughout OpenThread. -pub type otError = ::core::ffi::c_uint; -unsafe extern "C" { - /// Converts an otError enum into a string. - /// - /// @param[in] aError An otError enum. - /// - /// @returns A string representation of an otError. - pub fn otThreadErrorToString(aError: otError) -> *const ::core::ffi::c_char; -} -pub type __gnuc_va_list = __builtin_va_list; -pub type va_list = __builtin_va_list; -/// Represents the log level. -pub type otLogLevel = ::core::ffi::c_int; -///< OpenThread API -pub const otLogRegion_OT_LOG_REGION_API: otLogRegion = 1; -///< MLE -pub const otLogRegion_OT_LOG_REGION_MLE: otLogRegion = 2; -///< EID-to-RLOC mapping. -pub const otLogRegion_OT_LOG_REGION_ARP: otLogRegion = 3; -///< Network Data -pub const otLogRegion_OT_LOG_REGION_NET_DATA: otLogRegion = 4; -///< ICMPv6 -pub const otLogRegion_OT_LOG_REGION_ICMP: otLogRegion = 5; -///< IPv6 -pub const otLogRegion_OT_LOG_REGION_IP6: otLogRegion = 6; -///< TCP -pub const otLogRegion_OT_LOG_REGION_TCP: otLogRegion = 7; -///< IEEE 802.15.4 MAC -pub const otLogRegion_OT_LOG_REGION_MAC: otLogRegion = 8; -///< Memory -pub const otLogRegion_OT_LOG_REGION_MEM: otLogRegion = 9; -///< NCP -pub const otLogRegion_OT_LOG_REGION_NCP: otLogRegion = 10; -///< Mesh Commissioning Protocol -pub const otLogRegion_OT_LOG_REGION_MESH_COP: otLogRegion = 11; -///< Network Diagnostic -pub const otLogRegion_OT_LOG_REGION_NET_DIAG: otLogRegion = 12; -///< Platform -pub const otLogRegion_OT_LOG_REGION_PLATFORM: otLogRegion = 13; -///< CoAP -pub const otLogRegion_OT_LOG_REGION_COAP: otLogRegion = 14; -///< CLI -pub const otLogRegion_OT_LOG_REGION_CLI: otLogRegion = 15; -///< OpenThread Core -pub const otLogRegion_OT_LOG_REGION_CORE: otLogRegion = 16; -///< Utility module -pub const otLogRegion_OT_LOG_REGION_UTIL: otLogRegion = 17; -///< Backbone Router (available since Thread 1.2) -pub const otLogRegion_OT_LOG_REGION_BBR: otLogRegion = 18; -///< Multicast Listener Registration (available since Thread 1.2) -pub const otLogRegion_OT_LOG_REGION_MLR: otLogRegion = 19; -///< Domain Unicast Address (available since Thread 1.2) -pub const otLogRegion_OT_LOG_REGION_DUA: otLogRegion = 20; -///< Border Router -pub const otLogRegion_OT_LOG_REGION_BR: otLogRegion = 21; -///< Service Registration Protocol (SRP) -pub const otLogRegion_OT_LOG_REGION_SRP: otLogRegion = 22; -///< DNS -pub const otLogRegion_OT_LOG_REGION_DNS: otLogRegion = 23; -/// Represents log regions. -/// -/// The support for log region is removed and instead each core module can define its own name to appended to the logs. -/// However, the `otLogRegion` enumeration is still defined as before to help with platforms which we may be using it -/// in their `otPlatLog()` implementation. The OT core will always emit all logs with `OT_LOG_REGION_CORE`. -pub type otLogRegion = ::core::ffi::c_uint; -unsafe extern "C" { - /// Outputs logs. - /// - /// Note that the support for log region is removed. The OT core will always emit all logs with `OT_LOG_REGION_CORE` - /// as @p aLogRegion. - /// - /// @param[in] aLogLevel The log level. - /// @param[in] aLogRegion The log region. - /// @param[in] aFormat A pointer to the format string. - /// @param[in] ... Arguments for the format specification. - pub fn otPlatLog( - aLogLevel: otLogLevel, - aLogRegion: otLogRegion, - aFormat: *const ::core::ffi::c_char, - ... - ); -} -unsafe extern "C" { - /// Handles OpenThread log level changes. - /// - /// This platform function is called whenever the OpenThread log level changes. - /// This platform function is optional since an empty weak implementation has been provided. - /// - /// @note Only applicable when `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1`. - /// - /// @param[in] aLogLevel The new OpenThread log level. - pub fn otPlatLogHandleLevelChanged(aLogLevel: otLogLevel); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otInstance { - _unused: [u8; 0], -} -unsafe extern "C" { - /// Initializes the OpenThread library. - /// - /// Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be - /// called before any other calls to OpenThread. - /// - /// Is available and can only be used when support for multiple OpenThread instances is enabled. - /// - /// @param[in] aInstanceBuffer The buffer for OpenThread to use for allocating the otInstance structure. - /// @param[in,out] aInstanceBufferSize On input, the size of aInstanceBuffer. On output, if not enough space for - /// otInstance, the number of bytes required for otInstance. - /// - /// @returns A pointer to the new OpenThread instance. - /// - /// @sa otInstanceFinalize - pub fn otInstanceInit( - aInstanceBuffer: *mut ::core::ffi::c_void, - aInstanceBufferSize: *mut usize, - ) -> *mut otInstance; -} -unsafe extern "C" { - /// Initializes the static single instance of the OpenThread library. - /// - /// Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be - /// called before any other calls to OpenThread. - /// - /// Is available and can only be used when support for multiple OpenThread instances is disabled. - /// - /// @returns A pointer to the single OpenThread instance. - pub fn otInstanceInitSingle() -> *mut otInstance; -} -unsafe extern "C" { - /// Initializes the OpenThread instance. - /// - /// This function initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be - /// called before any other calls to OpenThread. This method utilizes static buffer to initialize the OpenThread - /// instance. - /// - /// This function is available and can only be used when support for multiple OpenThread static instances is - /// enabled (`OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE`) - /// - /// @param[in] aIdx The index of the OpenThread instance to initialize. - /// - /// @returns A pointer to the new OpenThread instance. - pub fn otInstanceInitMultiple(aIdx: u8) -> *mut otInstance; -} -unsafe extern "C" { - /// Gets the instance identifier. - /// - /// The instance identifier is set to a random value when the instance is constructed, and then its value will not - /// change after initialization. - /// - /// @returns The instance identifier. - pub fn otInstanceGetId(aInstance: *mut otInstance) -> u32; -} -unsafe extern "C" { - /// Indicates whether or not the instance is valid/initialized. - /// - /// The instance is considered valid if it is acquired and initialized using either `otInstanceInitSingle()` (in single - /// instance case) or `otInstanceInit()` (in multi instance case). A subsequent call to `otInstanceFinalize()` causes - /// the instance to be considered as uninitialized. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @returns TRUE if the given instance is valid/initialized, FALSE otherwise. - pub fn otInstanceIsInitialized(aInstance: *mut otInstance) -> bool; -} -unsafe extern "C" { - /// Disables the OpenThread library. - /// - /// Call this function when OpenThread is no longer in use. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otInstanceFinalize(aInstance: *mut otInstance); -} -unsafe extern "C" { - /// Returns the current instance uptime (in msec). - /// - /// Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. - /// - /// The uptime is given as number of milliseconds since OpenThread instance was initialized. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @returns The uptime (number of milliseconds). - pub fn otInstanceGetUptime(aInstance: *mut otInstance) -> u64; -} -unsafe extern "C" { - /// Returns the current instance uptime as a human-readable string. - /// - /// Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. - /// - /// The string follows the format "::." for hours, minutes, seconds and millisecond (if uptime is - /// shorter than one day) or "
d.::." (if longer than a day). - /// - /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated - /// but the outputted string is always null-terminated. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[out] aBuffer A pointer to a char array to output the string. - /// @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_UPTIME_STRING_SIZE`. - pub fn otInstanceGetUptimeAsString( - aInstance: *mut otInstance, - aBuffer: *mut ::core::ffi::c_char, - aSize: u16, - ); -} -/// Represents a bit-field indicating specific state/configuration that has changed. See `OT_CHANGED_*` -/// definitions. -pub type otChangedFlags = u32; -/// Pointer is called to notify certain configuration or state changes within OpenThread. -/// -/// @param[in] aFlags A bit-field indicating specific state that has changed. See `OT_CHANGED_*` definitions. -/// @param[in] aContext A pointer to application-specific context. -pub type otStateChangedCallback = ::core::option::Option< - unsafe extern "C" fn(aFlags: otChangedFlags, aContext: *mut ::core::ffi::c_void), ->; -unsafe extern "C" { - /// Registers a callback to indicate when certain configuration or state changes within OpenThread. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aCallback A pointer to a function that is called with certain configuration or state changes. - /// @param[in] aContext A pointer to application-specific context. - /// - /// @retval OT_ERROR_NONE Added the callback to the list of callbacks. - /// @retval OT_ERROR_ALREADY The callback was already registered. - /// @retval OT_ERROR_NO_BUFS Could not add the callback due to resource constraints. - pub fn otSetStateChangedCallback( - aInstance: *mut otInstance, - aCallback: otStateChangedCallback, - aContext: *mut ::core::ffi::c_void, - ) -> otError; -} -unsafe extern "C" { - /// Removes a callback to indicate when certain configuration or state changes within OpenThread. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aCallback A pointer to a function that is called with certain configuration or state changes. - /// @param[in] aContext A pointer to application-specific context. - pub fn otRemoveStateChangeCallback( - aInstance: *mut otInstance, - aCallback: otStateChangedCallback, - aContext: *mut ::core::ffi::c_void, - ); -} -unsafe extern "C" { - /// Triggers a platform reset. - /// - /// The reset process ensures that all the OpenThread state/info (stored in volatile memory) is erased. Note that the - /// `otPlatformReset` does not erase any persistent state/info saved in non-volatile memory. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otInstanceReset(aInstance: *mut otInstance); -} -unsafe extern "C" { - /// Triggers a platform reset to bootloader mode, if supported. - /// - /// Requires `OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE`. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @retval OT_ERROR_NONE Reset to bootloader successfully. - /// @retval OT_ERROR_BUSY Failed due to another operation is ongoing. - /// @retval OT_ERROR_NOT_CAPABLE Not capable of resetting to bootloader. - pub fn otInstanceResetToBootloader(aInstance: *mut otInstance) -> otError; -} -unsafe extern "C" { - /// Deletes all the settings stored on non-volatile memory, and then triggers a platform reset. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otInstanceFactoryReset(aInstance: *mut otInstance); -} -unsafe extern "C" { - /// Resets the internal states of the OpenThread radio stack. - /// - /// Callbacks and configurations are preserved. - /// - /// This API is only available under radio builds (`OPENTHREAD_RADIO = 1`). - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otInstanceResetRadioStack(aInstance: *mut otInstance); -} -unsafe extern "C" { - /// Erases all the OpenThread persistent info (network settings) stored on non-volatile memory. - /// Erase is successful only if the device is in `disabled` state/role. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @retval OT_ERROR_NONE All persistent info/state was erased successfully. - /// @retval OT_ERROR_INVALID_STATE Device is not in `disabled` state/role. - pub fn otInstanceErasePersistentInfo(aInstance: *mut otInstance) -> otError; -} -unsafe extern "C" { - /// Gets the OpenThread version string. - /// - /// @returns A pointer to the OpenThread version. - pub fn otGetVersionString() -> *const ::core::ffi::c_char; -} -unsafe extern "C" { - /// Gets the OpenThread radio version string. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @returns A pointer to the OpenThread radio version. - pub fn otGetRadioVersionString(aInstance: *mut otInstance) -> *const ::core::ffi::c_char; -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otMessage { - _unused: [u8; 0], -} -///< Low priority level. -pub const otMessagePriority_OT_MESSAGE_PRIORITY_LOW: otMessagePriority = 0; -///< Normal priority level. -pub const otMessagePriority_OT_MESSAGE_PRIORITY_NORMAL: otMessagePriority = 1; -///< High priority level. -pub const otMessagePriority_OT_MESSAGE_PRIORITY_HIGH: otMessagePriority = 2; -/// Defines the OpenThread message priority levels. -pub type otMessagePriority = ::core::ffi::c_uint; -///< Message from Thread Netif. -pub const otMessageOrigin_OT_MESSAGE_ORIGIN_THREAD_NETIF: otMessageOrigin = 0; -///< Message from a trusted source on host. -pub const otMessageOrigin_OT_MESSAGE_ORIGIN_HOST_TRUSTED: otMessageOrigin = 1; -///< Message from an untrusted source on host. -pub const otMessageOrigin_OT_MESSAGE_ORIGIN_HOST_UNTRUSTED: otMessageOrigin = 2; -/// Defines the OpenThread message origins. -pub type otMessageOrigin = ::core::ffi::c_uint; -/// Represents a message settings. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otMessageSettings { - ///< TRUE if the message should be secured at Layer 2. - pub mLinkSecurityEnabled: bool, - ///< Priority level (MUST be a `OT_MESSAGE_PRIORITY_*` from `otMessagePriority`). - pub mPriority: u8, -} -/// Represents link-specific information for messages received from the Thread radio. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otThreadLinkInfo { - ///< Source PAN ID - pub mPanId: u16, - ///< 802.15.4 Channel - pub mChannel: u8, - ///< Received Signal Strength in dBm (averaged over fragments) - pub mRss: i8, - ///< Average Link Quality Indicator (averaged over fragments) - pub mLqi: u8, - pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, - ///< The time sync sequence. - pub mTimeSyncSeq: u8, - ///< The time offset to the Thread network time, in microseconds. - pub mNetworkTimeOffset: i64, - ///< Radio link type. - pub mRadioType: u8, -} -impl otThreadLinkInfo { - #[inline] - pub fn mLinkSecurity(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } - } - #[inline] - pub fn set_mLinkSecurity(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(0usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mLinkSecurity_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 0usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mLinkSecurity_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 0usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn mIsDstPanIdBroadcast(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } - } - #[inline] - pub fn set_mIsDstPanIdBroadcast(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(1usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mIsDstPanIdBroadcast_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 1usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mIsDstPanIdBroadcast_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 1usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn new_bitfield_1( - mLinkSecurity: bool, - mIsDstPanIdBroadcast: bool, - ) -> __BindgenBitfieldUnit<[u8; 1usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); - __bindgen_bitfield_unit.set(0usize, 1u8, { - let mLinkSecurity: u8 = unsafe { ::core::mem::transmute(mLinkSecurity) }; - mLinkSecurity as u64 - }); - __bindgen_bitfield_unit.set(1usize, 1u8, { - let mIsDstPanIdBroadcast: u8 = unsafe { ::core::mem::transmute(mIsDstPanIdBroadcast) }; - mIsDstPanIdBroadcast as u64 - }); - __bindgen_bitfield_unit - } -} -unsafe extern "C" { - /// Free an allocated message buffer. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// - /// @sa otMessageAppend - /// @sa otMessageGetLength - /// @sa otMessageSetLength - /// @sa otMessageGetOffset - /// @sa otMessageSetOffset - /// @sa otMessageRead - /// @sa otMessageWrite - pub fn otMessageFree(aMessage: *mut otMessage); -} -unsafe extern "C" { - /// Get the message length in bytes. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// - /// @returns The message length in bytes. - /// - /// @sa otMessageFree - /// @sa otMessageAppend - /// @sa otMessageSetLength - /// @sa otMessageGetOffset - /// @sa otMessageSetOffset - /// @sa otMessageRead - /// @sa otMessageWrite - /// @sa otMessageSetLength - pub fn otMessageGetLength(aMessage: *const otMessage) -> u16; -} -unsafe extern "C" { - /// Set the message length in bytes. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// @param[in] aLength A length in bytes. - /// - /// @retval OT_ERROR_NONE Successfully set the message length. - /// @retval OT_ERROR_NO_BUFS No available buffers to grow the message. - /// - /// @sa otMessageFree - /// @sa otMessageAppend - /// @sa otMessageGetLength - /// @sa otMessageGetOffset - /// @sa otMessageSetOffset - /// @sa otMessageRead - /// @sa otMessageWrite - pub fn otMessageSetLength(aMessage: *mut otMessage, aLength: u16) -> otError; -} -unsafe extern "C" { - /// Get the message offset in bytes. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// - /// @returns The message offset value. - /// - /// @sa otMessageFree - /// @sa otMessageAppend - /// @sa otMessageGetLength - /// @sa otMessageSetLength - /// @sa otMessageSetOffset - /// @sa otMessageRead - /// @sa otMessageWrite - pub fn otMessageGetOffset(aMessage: *const otMessage) -> u16; -} -unsafe extern "C" { - /// Set the message offset in bytes. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// @param[in] aOffset An offset in bytes. - /// - /// @sa otMessageFree - /// @sa otMessageAppend - /// @sa otMessageGetLength - /// @sa otMessageSetLength - /// @sa otMessageGetOffset - /// @sa otMessageRead - /// @sa otMessageWrite - pub fn otMessageSetOffset(aMessage: *mut otMessage, aOffset: u16); -} -unsafe extern "C" { - /// Indicates whether or not link security is enabled for the message. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// - /// @retval TRUE If link security is enabled. - /// @retval FALSE If link security is not enabled. - pub fn otMessageIsLinkSecurityEnabled(aMessage: *const otMessage) -> bool; -} -unsafe extern "C" { - /// Indicates whether or not the message is allowed to be looped back to host. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// - /// @retval TRUE If the message is allowed to be looped back to host. - /// @retval FALSE If the message is not allowed to be looped back to host. - pub fn otMessageIsLoopbackToHostAllowed(aMessage: *const otMessage) -> bool; -} -unsafe extern "C" { - /// Sets whether or not the message is allowed to be looped back to host. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// @param[in] aAllowLoopbackToHost Whether to allow the message to be looped back to host. - pub fn otMessageSetLoopbackToHostAllowed(aMessage: *mut otMessage, aAllowLoopbackToHost: bool); -} -unsafe extern "C" { - /// Indicates whether the given message may be looped back in a case of a multicast destination address. - /// - /// If @p aMessage is used along with an `otMessageInfo`, the `mMulticastLoop` field from `otMessageInfo` structure - /// takes precedence and will be used instead of the the value set on @p aMessage. - /// - /// This API is mainly intended for use along with `otIp6Send()` which expects an already prepared IPv6 message. - /// - /// @param[in] aMessage A pointer to the message. - pub fn otMessageIsMulticastLoopEnabled(aMessage: *mut otMessage) -> bool; -} -unsafe extern "C" { - /// Controls whether the given message may be looped back in a case of a multicast destination address. - /// - /// @param[in] aMessage A pointer to the message. - /// @param[in] aEnabled The configuration value. - pub fn otMessageSetMulticastLoopEnabled(aMessage: *mut otMessage, aEnabled: bool); -} -unsafe extern "C" { - /// Gets the message origin. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// - /// @returns The message origin. - pub fn otMessageGetOrigin(aMessage: *const otMessage) -> otMessageOrigin; -} -unsafe extern "C" { - /// Sets the message origin. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// @param[in] aOrigin The message origin. - pub fn otMessageSetOrigin(aMessage: *mut otMessage, aOrigin: otMessageOrigin); -} -unsafe extern "C" { - /// Sets/forces the message to be forwarded using direct transmission. - /// Default setting for a new message is `false`. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// @param[in] aEnabled If `true`, the message is forced to use direct transmission. If `false`, the message follows - /// the normal procedure. - pub fn otMessageSetDirectTransmission(aMessage: *mut otMessage, aEnabled: bool); -} -unsafe extern "C" { - /// Returns the average RSS (received signal strength) associated with the message. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// - /// @returns The average RSS value (in dBm) or OT_RADIO_RSSI_INVALID if no average RSS is available. - pub fn otMessageGetRss(aMessage: *const otMessage) -> i8; -} -unsafe extern "C" { - /// Retrieves the link-specific information for a message received over Thread radio. - /// - /// @param[in] aMessage The message from which to retrieve `otThreadLinkInfo`. - /// @pram[out] aLinkInfo A pointer to an `otThreadLinkInfo` to populate. - /// - /// @retval OT_ERROR_NONE Successfully retrieved the link info, @p `aLinkInfo` is updated. - /// @retval OT_ERROR_NOT_FOUND Message origin is not `OT_MESSAGE_ORIGIN_THREAD_NETIF`. - pub fn otMessageGetThreadLinkInfo( - aMessage: *const otMessage, - aLinkInfo: *mut otThreadLinkInfo, - ) -> otError; -} -unsafe extern "C" { - /// Append bytes to a message. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// @param[in] aBuf A pointer to the data to append. - /// @param[in] aLength Number of bytes to append. - /// - /// @retval OT_ERROR_NONE Successfully appended to the message - /// @retval OT_ERROR_NO_BUFS No available buffers to grow the message. - /// - /// @sa otMessageFree - /// @sa otMessageGetLength - /// @sa otMessageSetLength - /// @sa otMessageGetOffset - /// @sa otMessageSetOffset - /// @sa otMessageRead - /// @sa otMessageWrite - pub fn otMessageAppend( - aMessage: *mut otMessage, - aBuf: *const ::core::ffi::c_void, - aLength: u16, - ) -> otError; -} -unsafe extern "C" { - /// Read bytes from a message. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// @param[in] aOffset An offset in bytes. - /// @param[in] aBuf A pointer to a buffer that message bytes are read to. - /// @param[in] aLength Number of bytes to read. - /// - /// @returns The number of bytes read. - /// - /// @sa otMessageFree - /// @sa otMessageAppend - /// @sa otMessageGetLength - /// @sa otMessageSetLength - /// @sa otMessageGetOffset - /// @sa otMessageSetOffset - /// @sa otMessageWrite - pub fn otMessageRead( - aMessage: *const otMessage, - aOffset: u16, - aBuf: *mut ::core::ffi::c_void, - aLength: u16, - ) -> u16; -} -unsafe extern "C" { - /// Write bytes to a message. - /// - /// @param[in] aMessage A pointer to a message buffer. - /// @param[in] aOffset An offset in bytes. - /// @param[in] aBuf A pointer to a buffer that message bytes are written from. - /// @param[in] aLength Number of bytes to write. - /// - /// @returns The number of bytes written. - /// - /// @sa otMessageFree - /// @sa otMessageAppend - /// @sa otMessageGetLength - /// @sa otMessageSetLength - /// @sa otMessageGetOffset - /// @sa otMessageSetOffset - /// @sa otMessageRead - pub fn otMessageWrite( - aMessage: *mut otMessage, - aOffset: u16, - aBuf: *const ::core::ffi::c_void, - aLength: u16, - ) -> ::core::ffi::c_int; -} -/// Represents an OpenThread message queue. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otMessageQueue { - ///< Opaque data used by the implementation. - pub mData: *mut ::core::ffi::c_void, -} -/// Represents information about a message queue. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otMessageQueueInfo { - ///< Number of messages in the queue. - pub mNumMessages: u16, - ///< Number of data buffers used by messages in the queue. - pub mNumBuffers: u16, - ///< Total number of bytes used by all messages in the queue. - pub mTotalBytes: u32, -} -/// Represents the message buffer information for different queues used by OpenThread stack. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otBufferInfo { - ///< The total number of buffers in the messages pool (0xffff if unknown). - pub mTotalBuffers: u16, - ///< The number of free buffers (0xffff if unknown). - pub mFreeBuffers: u16, - /// The maximum number of used buffers at the same time since OT stack initialization or last call to - /// `otMessageResetBufferInfo()`. - pub mMaxUsedBuffers: u16, - ///< Info about 6LoWPAN send queue. - pub m6loSendQueue: otMessageQueueInfo, - ///< Info about 6LoWPAN reassembly queue. - pub m6loReassemblyQueue: otMessageQueueInfo, - ///< Info about IPv6 send queue. - pub mIp6Queue: otMessageQueueInfo, - ///< Info about MPL send queue. - pub mMplQueue: otMessageQueueInfo, - ///< Info about MLE delayed message queue. - pub mMleQueue: otMessageQueueInfo, - ///< Info about CoAP/TMF send queue. - pub mCoapQueue: otMessageQueueInfo, - ///< Info about CoAP secure send queue. - pub mCoapSecureQueue: otMessageQueueInfo, - ///< Info about application CoAP send queue. - pub mApplicationCoapQueue: otMessageQueueInfo, -} -unsafe extern "C" { - /// Initialize the message queue. - /// - /// MUST be called once and only once for a `otMessageQueue` instance before any other `otMessageQueue` - /// functions. The behavior is undefined if other queue APIs are used with an `otMessageQueue` before it being - /// initialized or if it is initialized more than once. - /// - /// @param[in] aQueue A pointer to a message queue. - pub fn otMessageQueueInit(aQueue: *mut otMessageQueue); -} -unsafe extern "C" { - /// Adds a message to the end of the given message queue. - /// - /// @param[in] aQueue A pointer to the message queue. - /// @param[in] aMessage The message to add. - pub fn otMessageQueueEnqueue(aQueue: *mut otMessageQueue, aMessage: *mut otMessage); -} -unsafe extern "C" { - /// Adds a message at the head/front of the given message queue. - /// - /// @param[in] aQueue A pointer to the message queue. - /// @param[in] aMessage The message to add. - pub fn otMessageQueueEnqueueAtHead(aQueue: *mut otMessageQueue, aMessage: *mut otMessage); -} -unsafe extern "C" { - /// Removes a message from the given message queue. - /// - /// @param[in] aQueue A pointer to the message queue. - /// @param[in] aMessage The message to remove. - pub fn otMessageQueueDequeue(aQueue: *mut otMessageQueue, aMessage: *mut otMessage); -} -unsafe extern "C" { - /// Returns a pointer to the message at the head of the queue. - /// - /// @param[in] aQueue A pointer to a message queue. - /// - /// @returns A pointer to the message at the head of queue or NULL if queue is empty. - pub fn otMessageQueueGetHead(aQueue: *mut otMessageQueue) -> *mut otMessage; -} -unsafe extern "C" { - /// Returns a pointer to the next message in the queue by iterating forward (from head to tail). - /// - /// @param[in] aQueue A pointer to a message queue. - /// @param[in] aMessage A pointer to current message buffer. - /// - /// @returns A pointer to the next message in the queue after `aMessage` or NULL if `aMessage is the tail of queue. - /// NULL is returned if `aMessage` is not in the queue `aQueue`. - pub fn otMessageQueueGetNext( - aQueue: *mut otMessageQueue, - aMessage: *const otMessage, - ) -> *mut otMessage; -} -unsafe extern "C" { - /// Get the Message Buffer information. - /// - /// @param[in] aInstance A pointer to the OpenThread instance. - /// @param[out] aBufferInfo A pointer where the message buffer information is written. - pub fn otMessageGetBufferInfo(aInstance: *mut otInstance, aBufferInfo: *mut otBufferInfo); -} -unsafe extern "C" { - /// Reset the Message Buffer information counter tracking the maximum number buffers in use at the same time. - /// - /// This resets `mMaxUsedBuffers` in `otBufferInfo`. - /// - /// @param[in] aInstance A pointer to the OpenThread instance. - pub fn otMessageResetBufferInfo(aInstance: *mut otInstance); -} -///< Key Type: Raw Data. -pub const otCryptoKeyType_OT_CRYPTO_KEY_TYPE_RAW: otCryptoKeyType = 0; -///< Key Type: AES. -pub const otCryptoKeyType_OT_CRYPTO_KEY_TYPE_AES: otCryptoKeyType = 1; -///< Key Type: HMAC. -pub const otCryptoKeyType_OT_CRYPTO_KEY_TYPE_HMAC: otCryptoKeyType = 2; -///< Key Type: ECDSA. -pub const otCryptoKeyType_OT_CRYPTO_KEY_TYPE_ECDSA: otCryptoKeyType = 3; -/// Defines the key types. -pub type otCryptoKeyType = ::core::ffi::c_uint; -///< Key Algorithm: Vendor Defined. -pub const otCryptoKeyAlgorithm_OT_CRYPTO_KEY_ALG_VENDOR: otCryptoKeyAlgorithm = 0; -///< Key Algorithm: AES ECB. -pub const otCryptoKeyAlgorithm_OT_CRYPTO_KEY_ALG_AES_ECB: otCryptoKeyAlgorithm = 1; -///< Key Algorithm: HMAC SHA-256. -pub const otCryptoKeyAlgorithm_OT_CRYPTO_KEY_ALG_HMAC_SHA_256: otCryptoKeyAlgorithm = 2; -///< Key Algorithm: ECDSA. -pub const otCryptoKeyAlgorithm_OT_CRYPTO_KEY_ALG_ECDSA: otCryptoKeyAlgorithm = 3; -/// Defines the key algorithms. -pub type otCryptoKeyAlgorithm = ::core::ffi::c_uint; -///< Key Usage: Key Usage is empty. -pub const OT_CRYPTO_KEY_USAGE_NONE: _bindgen_ty_1 = 0; -///< Key Usage: Key can be exported. -pub const OT_CRYPTO_KEY_USAGE_EXPORT: _bindgen_ty_1 = 1; -///< Key Usage: Encryption (vendor defined). -pub const OT_CRYPTO_KEY_USAGE_ENCRYPT: _bindgen_ty_1 = 2; -///< Key Usage: AES ECB. -pub const OT_CRYPTO_KEY_USAGE_DECRYPT: _bindgen_ty_1 = 4; -///< Key Usage: Sign Hash. -pub const OT_CRYPTO_KEY_USAGE_SIGN_HASH: _bindgen_ty_1 = 8; -///< Key Usage: Verify Hash. -pub const OT_CRYPTO_KEY_USAGE_VERIFY_HASH: _bindgen_ty_1 = 16; -/// Defines the key usage flags. -pub type _bindgen_ty_1 = ::core::ffi::c_uint; -///< Key Persistence: Key is volatile. -pub const otCryptoKeyStorage_OT_CRYPTO_KEY_STORAGE_VOLATILE: otCryptoKeyStorage = 0; -///< Key Persistence: Key is persistent. -pub const otCryptoKeyStorage_OT_CRYPTO_KEY_STORAGE_PERSISTENT: otCryptoKeyStorage = 1; -/// Defines the key storage types. -pub type otCryptoKeyStorage = ::core::ffi::c_uint; -/// This datatype represents the key reference. -pub type otCryptoKeyRef = u32; -/// @struct otCryptoKey -/// -/// Represents the Key Material required for Crypto operations. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otCryptoKey { - ///< Pointer to the buffer containing key. NULL indicates to use `mKeyRef`. - pub mKey: *const u8, - ///< The key length in bytes (applicable when `mKey` is not NULL). - pub mKeyLength: u16, - ///< The PSA key ref (requires `mKey` to be NULL). - pub mKeyRef: u32, -} -/// @struct otCryptoContext -/// -/// Stores the context object for platform APIs. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otCryptoContext { - ///< Pointer to the context. - pub mContext: *mut ::core::ffi::c_void, - ///< The length of the context in bytes. - pub mContextSize: u16, -} -/// @struct otPlatCryptoSha256Hash -/// -/// Represents a SHA-256 hash. -#[repr(C, packed)] -#[derive(Copy, Clone)] -pub struct otPlatCryptoSha256Hash { - ///< Hash bytes. - pub m8: [u8; 32usize], -} -/// @struct otPlatCryptoEcdsaKeyPair -/// -/// Represents an ECDSA key pair (public and private keys). -/// -/// The key pair is stored using Distinguished Encoding Rules (DER) format (per RFC 5915). -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otPlatCryptoEcdsaKeyPair { - pub mDerBytes: [u8; 125usize], - pub mDerLength: u8, -} -/// @struct otPlatCryptoEcdsaPublicKey -/// -/// Represents a ECDSA public key. -/// -/// The public key is stored as a byte sequence representation of an uncompressed curve point (RFC 6605 - sec 4). -#[repr(C, packed)] -#[derive(Copy, Clone)] -pub struct otPlatCryptoEcdsaPublicKey { - pub m8: [u8; 64usize], -} -/// @struct otPlatCryptoEcdsaSignature -/// -/// Represents an ECDSA signature. -/// -/// The signature is encoded as the concatenated binary representation of two MPIs `r` and `s` which are calculated -/// during signing (RFC 6605 - section 4). -#[repr(C, packed)] -#[derive(Copy, Clone)] -pub struct otPlatCryptoEcdsaSignature { - pub m8: [u8; 64usize], -} -unsafe extern "C" { - /// Initialize the Crypto module. - pub fn otPlatCryptoInit(); -} -unsafe extern "C" { - /// Import a key into PSA ITS. - /// - /// @param[in,out] aKeyRef Pointer to the key ref to be used for crypto operations. - /// @param[in] aKeyType Key Type encoding for the key. - /// @param[in] aKeyAlgorithm Key algorithm encoding for the key. - /// @param[in] aKeyUsage Key Usage encoding for the key (combinations of `OT_CRYPTO_KEY_USAGE_*`). - /// @param[in] aKeyPersistence Key Persistence for this key - /// @param[in] aKey Actual key to be imported. - /// @param[in] aKeyLen Length of the key to be imported. - /// - /// @retval OT_ERROR_NONE Successfully imported the key. - /// @retval OT_ERROR_FAILED Failed to import the key. - /// @retval OT_ERROR_INVALID_ARGS @p aKey was set to NULL. - /// - /// @note If OT_CRYPTO_KEY_STORAGE_PERSISTENT is passed for aKeyPersistence then @p aKeyRef is input and platform - /// should use the given aKeyRef and MUST not change it. - /// - /// If OT_CRYPTO_KEY_STORAGE_VOLATILE is passed for aKeyPersistence then @p aKeyRef is output, the initial - /// value does not matter and platform API MUST update it to return the new key ref. - /// - /// This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. - pub fn otPlatCryptoImportKey( - aKeyRef: *mut otCryptoKeyRef, - aKeyType: otCryptoKeyType, - aKeyAlgorithm: otCryptoKeyAlgorithm, - aKeyUsage: ::core::ffi::c_int, - aKeyPersistence: otCryptoKeyStorage, - aKey: *const u8, - aKeyLen: usize, - ) -> otError; -} -unsafe extern "C" { - /// Export a key stored in PSA ITS. - /// - /// @param[in] aKeyRef The key ref to be used for crypto operations. - /// @param[out] aBuffer Pointer to the buffer where key needs to be exported. - /// @param[in] aBufferLen Length of the buffer passed to store the exported key. - /// @param[out] aKeyLen Pointer to return the length of the exported key. - /// - /// @retval OT_ERROR_NONE Successfully exported @p aKeyRef. - /// @retval OT_ERROR_FAILED Failed to export @p aKeyRef. - /// @retval OT_ERROR_INVALID_ARGS @p aBuffer was NULL - /// - /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. - pub fn otPlatCryptoExportKey( - aKeyRef: otCryptoKeyRef, - aBuffer: *mut u8, - aBufferLen: usize, - aKeyLen: *mut usize, - ) -> otError; -} -unsafe extern "C" { - /// Destroy a key stored in PSA ITS. - /// - /// @param[in] aKeyRef The key ref to be destroyed - /// - /// @retval OT_ERROR_NONE Successfully destroyed the key. - /// @retval OT_ERROR_FAILED Failed to destroy the key. - /// - /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. - pub fn otPlatCryptoDestroyKey(aKeyRef: otCryptoKeyRef) -> otError; -} -unsafe extern "C" { - /// Check if the key ref passed has an associated key in PSA ITS. - /// - /// @param[in] aKeyRef The Key Ref to check. - /// - /// @retval TRUE There is an associated key with @p aKeyRef. - /// @retval FALSE There is no associated key with @p aKeyRef. - /// - /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. - pub fn otPlatCryptoHasKey(aKeyRef: otCryptoKeyRef) -> bool; -} -unsafe extern "C" { - /// Initialize the HMAC operation. - /// - /// @param[in] aContext Context for HMAC operation. - /// - /// @retval OT_ERROR_NONE Successfully initialized HMAC operation. - /// @retval OT_ERROR_FAILED Failed to initialize HMAC operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL - /// - /// @note The platform driver shall point the context to the correct object such as psa_mac_operation_t or - /// mbedtls_md_context_t. - pub fn otPlatCryptoHmacSha256Init(aContext: *mut otCryptoContext) -> otError; -} -unsafe extern "C" { - /// Uninitialize the HMAC operation. - /// - /// @param[in] aContext Context for HMAC operation. - /// - /// @retval OT_ERROR_NONE Successfully uninitialized HMAC operation. - /// @retval OT_ERROR_FAILED Failed to uninitialized HMAC operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL - pub fn otPlatCryptoHmacSha256Deinit(aContext: *mut otCryptoContext) -> otError; -} -unsafe extern "C" { - /// Start HMAC operation. - /// - /// @param[in] aContext Context for HMAC operation. - /// @param[in] aKey Key material to be used for HMAC operation. - /// - /// @retval OT_ERROR_NONE Successfully started HMAC operation. - /// @retval OT_ERROR_FAILED Failed to start HMAC operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey was NULL - pub fn otPlatCryptoHmacSha256Start( - aContext: *mut otCryptoContext, - aKey: *const otCryptoKey, - ) -> otError; -} -unsafe extern "C" { - /// Update the HMAC operation with new input. - /// - /// @param[in] aContext Context for HMAC operation. - /// @param[in] aBuf A pointer to the input buffer. - /// @param[in] aBufLength The length of @p aBuf in bytes. - /// - /// @retval OT_ERROR_NONE Successfully updated HMAC with new input operation. - /// @retval OT_ERROR_FAILED Failed to update HMAC operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL - pub fn otPlatCryptoHmacSha256Update( - aContext: *mut otCryptoContext, - aBuf: *const ::core::ffi::c_void, - aBufLength: u16, - ) -> otError; -} -unsafe extern "C" { - /// Complete the HMAC operation. - /// - /// @param[in] aContext Context for HMAC operation. - /// @param[out] aBuf A pointer to the output buffer. - /// @param[in] aBufLength The length of @p aBuf in bytes. - /// - /// @retval OT_ERROR_NONE Successfully completed HMAC operation. - /// @retval OT_ERROR_FAILED Failed to complete HMAC operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL - pub fn otPlatCryptoHmacSha256Finish( - aContext: *mut otCryptoContext, - aBuf: *mut u8, - aBufLength: usize, - ) -> otError; -} -unsafe extern "C" { - /// Initialise the AES operation. - /// - /// @param[in] aContext Context for AES operation. - /// - /// @retval OT_ERROR_NONE Successfully Initialised AES operation. - /// @retval OT_ERROR_FAILED Failed to Initialise AES operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL - /// @retval OT_ERROR_NO_BUFS Cannot allocate the context. - /// - /// @note The platform driver shall point the context to the correct object such as psa_key_id - /// or mbedtls_aes_context_t. - pub fn otPlatCryptoAesInit(aContext: *mut otCryptoContext) -> otError; -} -unsafe extern "C" { - /// Set the key for AES operation. - /// - /// @param[in] aContext Context for AES operation. - /// @param[out] aKey Key to use for AES operation. - /// - /// @retval OT_ERROR_NONE Successfully set the key for AES operation. - /// @retval OT_ERROR_FAILED Failed to set the key for AES operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey was NULL - pub fn otPlatCryptoAesSetKey( - aContext: *mut otCryptoContext, - aKey: *const otCryptoKey, - ) -> otError; -} -unsafe extern "C" { - /// Encrypt the given data. - /// - /// @param[in] aContext Context for AES operation. - /// @param[in] aInput Pointer to the input buffer. - /// @param[in] aOutput Pointer to the output buffer. - /// - /// @retval OT_ERROR_NONE Successfully encrypted @p aInput. - /// @retval OT_ERROR_FAILED Failed to encrypt @p aInput. - /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey or @p aOutput were NULL - pub fn otPlatCryptoAesEncrypt( - aContext: *mut otCryptoContext, - aInput: *const u8, - aOutput: *mut u8, - ) -> otError; -} -unsafe extern "C" { - /// Free the AES context. - /// - /// @param[in] aContext Context for AES operation. - /// - /// @retval OT_ERROR_NONE Successfully freed AES context. - /// @retval OT_ERROR_FAILED Failed to free AES context. - /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL - pub fn otPlatCryptoAesFree(aContext: *mut otCryptoContext) -> otError; -} -unsafe extern "C" { - /// Initialise the HKDF context. - /// - /// @param[in] aContext Context for HKDF operation. - /// - /// @retval OT_ERROR_NONE Successfully Initialised AES operation. - /// @retval OT_ERROR_FAILED Failed to Initialise AES operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL - /// - /// @note The platform driver shall point the context to the correct object such as psa_key_derivation_operation_t - /// or HmacSha256::Hash - pub fn otPlatCryptoHkdfInit(aContext: *mut otCryptoContext) -> otError; -} -unsafe extern "C" { - /// Perform HKDF Expand step. - /// - /// @param[in] aContext Operation context for HKDF operation. - /// @param[in] aInfo Pointer to the Info sequence. - /// @param[in] aInfoLength Length of the Info sequence. - /// @param[out] aOutputKey Pointer to the output Key. - /// @param[in] aOutputKeyLength Size of the output key buffer. - /// - /// @retval OT_ERROR_NONE HKDF Expand was successful. - /// @retval OT_ERROR_FAILED HKDF Expand failed. - /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL - pub fn otPlatCryptoHkdfExpand( - aContext: *mut otCryptoContext, - aInfo: *const u8, - aInfoLength: u16, - aOutputKey: *mut u8, - aOutputKeyLength: u16, - ) -> otError; -} -unsafe extern "C" { - /// Perform HKDF Extract step. - /// - /// @param[in] aContext Operation context for HKDF operation. - /// @param[in] aSalt Pointer to the Salt for HKDF. - /// @param[in] aSaltLength Length of Salt. - /// @param[in] aInputKey Pointer to the input key. - /// - /// @retval OT_ERROR_NONE HKDF Extract was successful. - /// @retval OT_ERROR_FAILED HKDF Extract failed. - pub fn otPlatCryptoHkdfExtract( - aContext: *mut otCryptoContext, - aSalt: *const u8, - aSaltLength: u16, - aInputKey: *const otCryptoKey, - ) -> otError; -} -unsafe extern "C" { - /// Uninitialize the HKDF context. - /// - /// @param[in] aContext Context for HKDF operation. - /// - /// @retval OT_ERROR_NONE Successfully un-initialised HKDF operation. - /// @retval OT_ERROR_FAILED Failed to un-initialised HKDF operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL - pub fn otPlatCryptoHkdfDeinit(aContext: *mut otCryptoContext) -> otError; -} -unsafe extern "C" { - /// Initialise the SHA-256 operation. - /// - /// @param[in] aContext Context for SHA-256 operation. - /// - /// @retval OT_ERROR_NONE Successfully initialised SHA-256 operation. - /// @retval OT_ERROR_FAILED Failed to initialise SHA-256 operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL - /// - /// - /// @note The platform driver shall point the context to the correct object such as psa_hash_operation_t - /// or mbedtls_sha256_context. - pub fn otPlatCryptoSha256Init(aContext: *mut otCryptoContext) -> otError; -} -unsafe extern "C" { - /// Uninitialize the SHA-256 operation. - /// - /// @param[in] aContext Context for SHA-256 operation. - /// - /// @retval OT_ERROR_NONE Successfully un-initialised SHA-256 operation. - /// @retval OT_ERROR_FAILED Failed to un-initialised SHA-256 operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL - pub fn otPlatCryptoSha256Deinit(aContext: *mut otCryptoContext) -> otError; -} -unsafe extern "C" { - /// Start SHA-256 operation. - /// - /// @param[in] aContext Context for SHA-256 operation. - /// - /// @retval OT_ERROR_NONE Successfully started SHA-256 operation. - /// @retval OT_ERROR_FAILED Failed to start SHA-256 operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL - pub fn otPlatCryptoSha256Start(aContext: *mut otCryptoContext) -> otError; -} -unsafe extern "C" { - /// Update SHA-256 operation with new input. - /// - /// @param[in] aContext Context for SHA-256 operation. - /// @param[in] aBuf A pointer to the input buffer. - /// @param[in] aBufLength The length of @p aBuf in bytes. - /// - /// @retval OT_ERROR_NONE Successfully updated SHA-256 with new input operation. - /// @retval OT_ERROR_FAILED Failed to update SHA-256 operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL - pub fn otPlatCryptoSha256Update( - aContext: *mut otCryptoContext, - aBuf: *const ::core::ffi::c_void, - aBufLength: u16, - ) -> otError; -} -unsafe extern "C" { - /// Finish SHA-256 operation. - /// - /// @param[in] aContext Context for SHA-256 operation. - /// @param[in] aHash A pointer to the output buffer, where hash needs to be stored. - /// @param[in] aHashSize The length of @p aHash in bytes. - /// - /// @retval OT_ERROR_NONE Successfully completed the SHA-256 operation. - /// @retval OT_ERROR_FAILED Failed to complete SHA-256 operation. - /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aHash was NULL - pub fn otPlatCryptoSha256Finish( - aContext: *mut otCryptoContext, - aHash: *mut u8, - aHashSize: u16, - ) -> otError; -} -unsafe extern "C" { - /// Initialize cryptographically-secure pseudorandom number generator (CSPRNG). - pub fn otPlatCryptoRandomInit(); -} -unsafe extern "C" { - /// Deinitialize cryptographically-secure pseudorandom number generator (CSPRNG). - pub fn otPlatCryptoRandomDeinit(); -} -unsafe extern "C" { - /// Fills a given buffer with cryptographically secure random bytes. - /// - /// @param[out] aBuffer A pointer to a buffer to fill with the random bytes. - /// @param[in] aSize Size of buffer (number of bytes to fill). - /// - /// @retval OT_ERROR_NONE Successfully filled buffer with random values. - /// @retval OT_ERROR_FAILED Operation failed. - pub fn otPlatCryptoRandomGet(aBuffer: *mut u8, aSize: u16) -> otError; -} -unsafe extern "C" { - /// Generate and populate the output buffer with a new ECDSA key-pair. - /// - /// @param[out] aKeyPair A pointer to an ECDSA key-pair structure to store the generated key-pair. - /// - /// @retval OT_ERROR_NONE A new key-pair was generated successfully. - /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation. - /// @retval OT_ERROR_NOT_CAPABLE Feature not supported. - /// @retval OT_ERROR_FAILED Failed to generate key-pair. - pub fn otPlatCryptoEcdsaGenerateKey(aKeyPair: *mut otPlatCryptoEcdsaKeyPair) -> otError; -} -unsafe extern "C" { - /// Get the associated public key from the input context. - /// - /// @param[in] aKeyPair A pointer to an ECDSA key-pair structure where the key-pair is stored. - /// @param[out] aPublicKey A pointer to an ECDSA public key structure to store the public key. - /// - /// @retval OT_ERROR_NONE Public key was retrieved successfully, and @p aBuffer is updated. - /// @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). - /// @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. - pub fn otPlatCryptoEcdsaGetPublicKey( - aKeyPair: *const otPlatCryptoEcdsaKeyPair, - aPublicKey: *mut otPlatCryptoEcdsaPublicKey, - ) -> otError; -} -unsafe extern "C" { - /// Calculate the ECDSA signature for a hashed message using the private key from the input context. - /// - /// Uses the deterministic digital signature generation procedure from RFC 6979. - /// - /// @param[in] aKeyPair A pointer to an ECDSA key-pair structure where the key-pair is stored. - /// @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature calculation - /// is stored. - /// @param[out] aSignature A pointer to an ECDSA signature structure to output the calculated signature. - /// - /// @retval OT_ERROR_NONE The signature was calculated successfully, @p aSignature was updated. - /// @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). - /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature calculation. - /// @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. - pub fn otPlatCryptoEcdsaSign( - aKeyPair: *const otPlatCryptoEcdsaKeyPair, - aHash: *const otPlatCryptoSha256Hash, - aSignature: *mut otPlatCryptoEcdsaSignature, - ) -> otError; -} -unsafe extern "C" { - /// Use the key from the input context to verify the ECDSA signature of a hashed message. - /// - /// @param[in] aPublicKey A pointer to an ECDSA public key structure where the public key for signature - /// verification is stored. - /// @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature verification - /// is stored. - /// @param[in] aSignature A pointer to an ECDSA signature structure where the signature value to be verified is - /// stored. - /// - /// @retval OT_ERROR_NONE The signature was verified successfully. - /// @retval OT_ERROR_SECURITY The signature is invalid. - /// @retval OT_ERROR_INVALID_ARGS The key or hash is invalid. - /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature verification. - pub fn otPlatCryptoEcdsaVerify( - aPublicKey: *const otPlatCryptoEcdsaPublicKey, - aHash: *const otPlatCryptoSha256Hash, - aSignature: *const otPlatCryptoEcdsaSignature, - ) -> otError; -} -unsafe extern "C" { - /// Calculate the ECDSA signature for a hashed message using the Key reference passed. - /// - /// Uses the deterministic digital signature generation procedure from RFC 6979. - /// - /// @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. - /// @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature calculation - /// is stored. - /// @param[out] aSignature A pointer to an ECDSA signature structure to output the calculated signature. - /// - /// @retval OT_ERROR_NONE The signature was calculated successfully, @p aSignature was updated. - /// @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). - /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature calculation. - /// @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. - /// - /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. - pub fn otPlatCryptoEcdsaSignUsingKeyRef( - aKeyRef: otCryptoKeyRef, - aHash: *const otPlatCryptoSha256Hash, - aSignature: *mut otPlatCryptoEcdsaSignature, - ) -> otError; -} -unsafe extern "C" { - /// Get the associated public key from the key reference passed. - /// - /// The public key is stored differently depending on the crypto backend library being used - /// (OPENTHREAD_CONFIG_CRYPTO_LIB). - /// - /// This API must make sure to return the public key as a byte sequence representation of an - /// uncompressed curve point (RFC 6605 - sec 4) - /// - /// @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. - /// @param[out] aPublicKey A pointer to an ECDSA public key structure to store the public key. - /// - /// @retval OT_ERROR_NONE Public key was retrieved successfully, and @p aBuffer is updated. - /// @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). - /// @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. - /// - /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. - pub fn otPlatCryptoEcdsaExportPublicKey( - aKeyRef: otCryptoKeyRef, - aPublicKey: *mut otPlatCryptoEcdsaPublicKey, - ) -> otError; -} -unsafe extern "C" { - /// Generate and import a new ECDSA key-pair at reference passed. - /// - /// @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. - /// - /// @retval OT_ERROR_NONE A new key-pair was generated successfully. - /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation. - /// @retval OT_ERROR_NOT_CAPABLE Feature not supported. - /// @retval OT_ERROR_FAILED Failed to generate key-pair. - /// - /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. - pub fn otPlatCryptoEcdsaGenerateAndImportKey(aKeyRef: otCryptoKeyRef) -> otError; -} -unsafe extern "C" { - /// Use the keyref to verify the ECDSA signature of a hashed message. - /// - /// @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. - /// @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature verification - /// is stored. - /// @param[in] aSignature A pointer to an ECDSA signature structure where the signature value to be verified is - /// stored. - /// - /// @retval OT_ERROR_NONE The signature was verified successfully. - /// @retval OT_ERROR_SECURITY The signature is invalid. - /// @retval OT_ERROR_INVALID_ARGS The key or hash is invalid. - /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature verification. - /// - /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. - pub fn otPlatCryptoEcdsaVerifyUsingKeyRef( - aKeyRef: otCryptoKeyRef, - aHash: *const otPlatCryptoSha256Hash, - aSignature: *const otPlatCryptoEcdsaSignature, - ) -> otError; -} -unsafe extern "C" { - /// Perform PKCS#5 PBKDF2 using CMAC (AES-CMAC-PRF-128). - /// - /// @param[in] aPassword Password to use when generating key. - /// @param[in] aPasswordLen Length of password. - /// @param[in] aSalt Salt to use when generating key. - /// @param[in] aSaltLen Length of salt. - /// @param[in] aIterationCounter Iteration count. - /// @param[in] aKeyLen Length of generated key in bytes. - /// @param[out] aKey A pointer to the generated key. - /// - /// @retval OT_ERROR_NONE A new key-pair was generated successfully. - /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation. - /// @retval OT_ERROR_NOT_CAPABLE Feature not supported. - /// @retval OT_ERROR_FAILED Failed to generate key. - pub fn otPlatCryptoPbkdf2GenerateKey( - aPassword: *const u8, - aPasswordLen: u16, - aSalt: *const u8, - aSaltLen: u16, - aIterationCounter: u32, - aKeyLen: u16, - aKey: *mut u8, - ) -> otError; -} -///< aMaxPHYPacketSize (IEEE 802.15.4-2006) -pub const OT_RADIO_FRAME_MAX_SIZE: _bindgen_ty_2 = 127; -///< Minimal size of frame FCS + CONTROL -pub const OT_RADIO_FRAME_MIN_SIZE: _bindgen_ty_2 = 3; -///< 2.4 GHz IEEE 802.15.4-2006 -pub const OT_RADIO_SYMBOLS_PER_OCTET: _bindgen_ty_2 = 2; -///< 2.4 GHz IEEE 802.15.4 (bits per second) -pub const OT_RADIO_BIT_RATE: _bindgen_ty_2 = 250000; -///< Number of bits per octet -pub const OT_RADIO_BITS_PER_OCTET: _bindgen_ty_2 = 8; -///< The O-QPSK PHY symbol rate when operating in the 780MHz, 915MHz, 2380MHz, 2450MHz -pub const OT_RADIO_SYMBOL_RATE: _bindgen_ty_2 = 62500; -///< Symbol duration time in unit of microseconds -pub const OT_RADIO_SYMBOL_TIME: _bindgen_ty_2 = 16; -///< Time for 10 symbols in unit of microseconds -pub const OT_RADIO_TEN_SYMBOLS_TIME: _bindgen_ty_2 = 160; -///< LQI measurement not supported -pub const OT_RADIO_LQI_NONE: _bindgen_ty_2 = 0; -///< Invalid or unknown RSSI value -pub const OT_RADIO_RSSI_INVALID: _bindgen_ty_2 = 127; -///< Invalid or unknown power value -pub const OT_RADIO_POWER_INVALID: _bindgen_ty_2 = 127; -/// @defgroup radio-types Radio Types -/// -/// @brief -/// This module includes the platform abstraction for a radio frame. -/// -/// @{ -pub type _bindgen_ty_2 = ::core::ffi::c_uint; -///< 2.4 GHz IEEE 802.15.4-2006 -pub const OT_RADIO_CHANNEL_PAGE_0: _bindgen_ty_3 = 0; -///< 2.4 GHz IEEE 802.15.4-2006 -pub const OT_RADIO_CHANNEL_PAGE_0_MASK: _bindgen_ty_3 = 1; -///< 915 MHz IEEE 802.15.4-2006 -pub const OT_RADIO_CHANNEL_PAGE_2: _bindgen_ty_3 = 2; -///< 915 MHz IEEE 802.15.4-2006 -pub const OT_RADIO_CHANNEL_PAGE_2_MASK: _bindgen_ty_3 = 4; -/// Defines the channel page. -pub type _bindgen_ty_3 = ::core::ffi::c_uint; -///< 915 MHz IEEE 802.15.4-2006 -pub const OT_RADIO_915MHZ_OQPSK_CHANNEL_MIN: _bindgen_ty_4 = 1; -///< 915 MHz IEEE 802.15.4-2006 -pub const OT_RADIO_915MHZ_OQPSK_CHANNEL_MAX: _bindgen_ty_4 = 10; -///< 915 MHz IEEE 802.15.4-2006 -pub const OT_RADIO_915MHZ_OQPSK_CHANNEL_MASK: _bindgen_ty_4 = 2046; -///< 2.4 GHz IEEE 802.15.4-2006 -pub const OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MIN: _bindgen_ty_4 = 11; -///< 2.4 GHz IEEE 802.15.4-2006 -pub const OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MAX: _bindgen_ty_4 = 26; -///< 2.4 GHz IEEE 802.15.4-2006 -pub const OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MASK: _bindgen_ty_4 = 134215680; -/// Defines the frequency band channel range. -pub type _bindgen_ty_4 = ::core::ffi::c_uint; -/// Represents radio capabilities. -/// -/// The value is a bit-field indicating the capabilities supported by the radio. See `OT_RADIO_CAPS_*` definitions. -pub type otRadioCaps = u16; -///< Radio supports no capability. -pub const OT_RADIO_CAPS_NONE: _bindgen_ty_5 = 0; -///< Radio supports AckTime event. -pub const OT_RADIO_CAPS_ACK_TIMEOUT: _bindgen_ty_5 = 1; -///< Radio supports Energy Scans. -pub const OT_RADIO_CAPS_ENERGY_SCAN: _bindgen_ty_5 = 2; -///< Radio supports tx retry logic with collision avoidance (CSMA). -pub const OT_RADIO_CAPS_TRANSMIT_RETRIES: _bindgen_ty_5 = 4; -///< Radio supports CSMA backoff for frame transmission (but no retry). -pub const OT_RADIO_CAPS_CSMA_BACKOFF: _bindgen_ty_5 = 8; -///< Radio supports direct transition from sleep to TX with CSMA. -pub const OT_RADIO_CAPS_SLEEP_TO_TX: _bindgen_ty_5 = 16; -///< Radio supports tx security. -pub const OT_RADIO_CAPS_TRANSMIT_SEC: _bindgen_ty_5 = 32; -///< Radio supports tx at specific time. -pub const OT_RADIO_CAPS_TRANSMIT_TIMING: _bindgen_ty_5 = 64; -///< Radio supports rx at specific time. -pub const OT_RADIO_CAPS_RECEIVE_TIMING: _bindgen_ty_5 = 128; -///< Radio supports RxOnWhenIdle handling. -pub const OT_RADIO_CAPS_RX_ON_WHEN_IDLE: _bindgen_ty_5 = 256; -///< Radio supports setting per-frame transmit power. -pub const OT_RADIO_CAPS_TRANSMIT_FRAME_POWER: _bindgen_ty_5 = 512; -/// Defines constants that are used to indicate different radio capabilities. See `otRadioCaps`. -pub type _bindgen_ty_5 = ::core::ffi::c_uint; -/// Represents the IEEE 802.15.4 PAN ID. -pub type otPanId = u16; -/// Represents the IEEE 802.15.4 Short Address. -pub type otShortAddress = u16; -///< Size of IE header in bytes. -pub const OT_IE_HEADER_SIZE: _bindgen_ty_6 = 2; -///< Size of CSL IE content in bytes. -pub const OT_CSL_IE_SIZE: _bindgen_ty_6 = 4; -///< Max length for header IE in ACK. -pub const OT_ACK_IE_MAX_SIZE: _bindgen_ty_6 = 16; -///< Max length of Link Metrics data in Vendor-Specific IE. -pub const OT_ENH_PROBING_IE_DATA_MAX_SIZE: _bindgen_ty_6 = 2; -/// Defines constants about size of header IE in ACK. -pub type _bindgen_ty_6 = ::core::ffi::c_uint; -/// @struct otExtAddress -/// -/// Represents the IEEE 802.15.4 Extended Address. -#[repr(C, packed)] -#[derive(Copy, Clone)] -pub struct otExtAddress { - ///< IEEE 802.15.4 Extended Address bytes - pub m8: [u8; 8usize], -} -/// @struct otMacKey -/// -/// Represents a MAC Key. -#[repr(C, packed)] -#[derive(Copy, Clone)] -pub struct otMacKey { - ///< MAC Key bytes. - pub m8: [u8; 16usize], -} -/// Represents a MAC Key Ref used by PSA. -pub type otMacKeyRef = otCryptoKeyRef; -/// @struct otMacKeyMaterial -/// -/// Represents a MAC Key. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otMacKeyMaterial { - pub mKeyMaterial: otMacKeyMaterial__bindgen_ty_1, +impl otNetifAddress { + #[inline] + pub fn mPreferred(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_mPreferred(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mPreferred_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 0usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mPreferred_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mValid(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mValid(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mValid_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 1usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mValid_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 1usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mScopeOverrideValid(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mScopeOverrideValid(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mScopeOverrideValid_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 2usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mScopeOverrideValid_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 2usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mScopeOverride(&self) -> ::core::ffi::c_uint { + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 4u8) as u32) } + } + #[inline] + pub fn set_mScopeOverride(&mut self, val: ::core::ffi::c_uint) { + unsafe { + let val: u32 = ::core::mem::transmute(val); + self._bitfield_1.set(3usize, 4u8, val as u64) + } + } + #[inline] + pub unsafe fn mScopeOverride_raw(this: *const Self) -> ::core::ffi::c_uint { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 3usize, + 4u8, + ) as u32) + } + } + #[inline] + pub unsafe fn set_mScopeOverride_raw(this: *mut Self, val: ::core::ffi::c_uint) { + unsafe { + let val: u32 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 3usize, + 4u8, + val as u64, + ) + } + } + #[inline] + pub fn mRloc(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u8) } + } + #[inline] + pub fn set_mRloc(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mRloc_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 7usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mRloc_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 7usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mMeshLocal(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u8) } + } + #[inline] + pub fn set_mMeshLocal(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(8usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mMeshLocal_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 8usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mMeshLocal_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 8usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mSrpRegistered(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u8) } + } + #[inline] + pub fn set_mSrpRegistered(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(9usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mSrpRegistered_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 9usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mSrpRegistered_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 9usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn new_bitfield_1( + mPreferred: bool, + mValid: bool, + mScopeOverrideValid: bool, + mScopeOverride: ::core::ffi::c_uint, + mRloc: bool, + mMeshLocal: bool, + mSrpRegistered: bool, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let mPreferred: u8 = unsafe { ::core::mem::transmute(mPreferred) }; + mPreferred as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mValid: u8 = unsafe { ::core::mem::transmute(mValid) }; + mValid as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mScopeOverrideValid: u8 = unsafe { ::core::mem::transmute(mScopeOverrideValid) }; + mScopeOverrideValid as u64 + }); + __bindgen_bitfield_unit.set(3usize, 4u8, { + let mScopeOverride: u32 = unsafe { ::core::mem::transmute(mScopeOverride) }; + mScopeOverride as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let mRloc: u8 = unsafe { ::core::mem::transmute(mRloc) }; + mRloc as u64 + }); + __bindgen_bitfield_unit.set(8usize, 1u8, { + let mMeshLocal: u8 = unsafe { ::core::mem::transmute(mMeshLocal) }; + mMeshLocal as u64 + }); + __bindgen_bitfield_unit.set(9usize, 1u8, { + let mSrpRegistered: u8 = unsafe { ::core::mem::transmute(mSrpRegistered) }; + mSrpRegistered as u64 + }); + __bindgen_bitfield_unit + } } +/// Represents an IPv6 network interface multicast address. #[repr(C)] #[derive(Copy, Clone)] -pub union otMacKeyMaterial__bindgen_ty_1 { - ///< Reference to the key stored. - pub mKeyRef: otMacKeyRef, - ///< Key stored as literal. - pub mKey: otMacKey, +pub struct otNetifMulticastAddress { + ///< The IPv6 multicast address. + pub mAddress: otIp6Address, + ///< A pointer to the next network interface multicast address. + pub mNext: *const otNetifMulticastAddress, } -///< Use Literal Keys. -pub const otRadioKeyType_OT_KEY_TYPE_LITERAL_KEY: otRadioKeyType = 0; -///< Use Reference to Key. -pub const otRadioKeyType_OT_KEY_TYPE_KEY_REF: otRadioKeyType = 1; -/// Defines constants about key types. -pub type otRadioKeyType = ::core::ffi::c_uint; -/// Represents the IEEE 802.15.4 Header IE (Information Element) related information of a radio frame. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otRadioIeInfo { - ///< The time offset to the Thread network time. - pub mNetworkTimeOffset: i64, - ///< The Time IE offset from the start of PSDU. - pub mTimeIeOffset: u8, - ///< The Time sync sequence. - pub mTimeSyncSeq: u8, +impl Default for otNetifMulticastAddress { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -/// Represents an IEEE 802.15.4 radio frame. +/// Represents an IPv6 socket address. #[repr(C)] #[derive(Copy, Clone)] -pub struct otRadioFrame { - ///< The PSDU. - pub mPsdu: *mut u8, - ///< Length of the PSDU. - pub mLength: u16, - ///< Channel used to transmit/receive the frame. - pub mChannel: u8, - ///< Radio link type - should be ignored by radio driver. - pub mRadioType: u8, - pub mInfo: otRadioFrame__bindgen_ty_1, +pub struct otSockAddr { + ///< An IPv6 address. + pub mAddress: otIp6Address, + ///< A transport-layer port. + pub mPort: u16, } -/// The union of transmit and receive information for a radio frame. -#[repr(C)] -#[derive(Copy, Clone)] -pub union otRadioFrame__bindgen_ty_1 { - pub mTxInfo: otRadioFrame__bindgen_ty_1__bindgen_ty_1, - pub mRxInfo: otRadioFrame__bindgen_ty_1__bindgen_ty_2, +impl Default for otSockAddr { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -/// Structure representing radio frame transmit information. +///< Non-ECT +pub const OT_ECN_NOT_CAPABLE: _bindgen_ty_2 = 0; +///< ECT(0) +pub const OT_ECN_CAPABLE_0: _bindgen_ty_2 = 2; +///< ECT(1) +pub const OT_ECN_CAPABLE_1: _bindgen_ty_2 = 1; +///< Congestion encountered (CE) +pub const OT_ECN_MARKED: _bindgen_ty_2 = 3; +/// ECN statuses, represented as in the IP header. +pub type _bindgen_ty_2 = ::core::ffi::c_uint; +/// Represents the local and peer IPv6 socket addresses. #[repr(C)] #[derive(Copy, Clone)] -pub struct otRadioFrame__bindgen_ty_1__bindgen_ty_1 { - ///< The key material used for AES-CCM frame security. - pub mAesKey: *const otMacKeyMaterial, - ///< The pointer to the Header IE(s) related information. - pub mIeInfo: *mut otRadioIeInfo, - /// The base time in microseconds for scheduled transmissions - /// relative to the local radio clock, see `otPlatRadioGetNow` and - /// `mTxDelay`. - pub mTxDelayBaseTime: u32, - /// The delay time in microseconds for this transmission referenced - /// to `mTxDelayBaseTime`. - /// - /// Note: `mTxDelayBaseTime` + `mTxDelay` SHALL point to the point in - /// time when the end of the SFD will be present at the local - /// antenna, relative to the local radio clock. - pub mTxDelay: u32, - ///< Maximum number of backoffs attempts before declaring CCA failure. - pub mMaxCsmaBackoffs: u8, - ///< Maximum number of retries allowed after a transmission failure. - pub mMaxFrameRetries: u8, - /// The RX channel after frame TX is done (after all frame retries - ack received, or timeout, or abort). - /// - /// Radio platforms can choose to fully ignore this. OT stack will make sure to call `otPlatRadioReceive()` - /// with the desired RX channel after a frame TX is done and signaled in `otPlatRadioTxDone()` callback. - /// Radio platforms that don't provide `OT_RADIO_CAPS_TRANSMIT_RETRIES` must always ignore this. - /// - /// This is intended for situations where there may be delay in interactions between OT stack and radio, as - /// an example this is used in RCP/host architecture to make sure RCP switches to PAN channel more quickly. - /// In particular, this can help with CSL tx to a sleepy child, where the child may use a different channel - /// for CSL than the PAN channel. After frame tx, we want the radio/RCP to go back to the PAN channel - /// quickly to ensure that parent does not miss tx from child afterwards, e.g., child responding to the - /// earlier CSL transmitted frame from parent using PAN channel while radio still staying on CSL channel. - /// - /// The switch to the RX channel MUST happen after the frame TX is fully done, i.e., after all retries and - /// when ack is received (when "Ack Request" flag is set on the TX frame) or ack timeout. Note that ack is - /// expected on the same channel that frame is sent on. - pub mRxChannelAfterTxDone: u8, - /// The transmit power in dBm. - /// - /// If the platform layer does not provide `OT_RADIO_CAPS_TRANSMIT_FRAME_POWER` capability, it can ignore - /// this value. - /// - /// If the value is OT_RADIO_POWER_INVALID, then the platform should ignore this value and transmit the frame - /// with its default transmit power. - /// - /// Otherwise, the platform should transmit this frame with the maximum power no larger than minimal of the - /// following values: - /// 1. mTxPower, - /// 2. The power limit set by otPlatRadioSetChannelTargetPower(), - /// 3. The power limit set by otPlatRadioSetChannelMaxTransmitPower(), - /// 4. The power limit set by otPlatRadioSetRegion(). - pub mTxPower: i8, +pub struct otMessageInfo { + ///< The local IPv6 address. + pub mSockAddr: otIp6Address, + ///< The peer IPv6 address. + pub mPeerAddr: otIp6Address, + ///< The local transport-layer port. + pub mSockPort: u16, + ///< The peer transport-layer port. + pub mPeerPort: u16, + ///< The IPv6 Hop Limit value. Only applies if `mAllowZeroHopLimit` is FALSE. + ///< If `0`, IPv6 Hop Limit is default value `OPENTHREAD_CONFIG_IP6_HOP_LIMIT_DEFAULT`. + ///< Otherwise, specifies the IPv6 Hop Limit. + pub mHopLimit: u8, pub _bitfield_align_1: [u8; 0], pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, - /// The time of the local radio clock in microseconds when the end of - /// the SFD was present at the local antenna. - /// - /// The platform should update this field before otPlatRadioTxStarted() is fired for each transmit attempt. - pub mTimestamp: u64, } -impl otRadioFrame__bindgen_ty_1__bindgen_ty_1 { +impl Default for otMessageInfo { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl otMessageInfo { #[inline] - pub fn mIsHeaderUpdated(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + pub fn mEcn(&self) -> u8 { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u8) } + } + #[inline] + pub fn set_mEcn(&mut self, val: u8) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub unsafe fn mEcn_raw(this: *const Self) -> u8 { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 0usize, + 2u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mEcn_raw(this: *mut Self, val: u8) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 2u8, + val as u64, + ) + } + } + #[inline] + pub fn mIsHostInterface(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mIsHostInterface(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mIsHostInterface_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 2usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mIsHostInterface_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 2usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mAllowZeroHopLimit(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } } #[inline] - pub fn set_mIsHeaderUpdated(&mut self, val: bool) { + pub fn set_mAllowZeroHopLimit(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(0usize, 1u8, val as u64) + self._bitfield_1.set(3usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mIsHeaderUpdated_raw(this: *const Self) -> bool { + pub unsafe fn mAllowZeroHopLimit_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 0usize, + 3usize, 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mIsHeaderUpdated_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mAllowZeroHopLimit_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 0usize, + 3usize, 1u8, val as u64, ) } } #[inline] - pub fn mIsARetx(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + pub fn mMulticastLoop(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } } #[inline] - pub fn set_mIsARetx(&mut self, val: bool) { + pub fn set_mMulticastLoop(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(1usize, 1u8, val as u64) + self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mIsARetx_raw(this: *const Self) -> bool { + pub unsafe fn mMulticastLoop_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 1usize, + 4usize, 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mIsARetx_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mMulticastLoop_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 4usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn new_bitfield_1( + mEcn: u8, + mIsHostInterface: bool, + mAllowZeroHopLimit: bool, + mMulticastLoop: bool, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let mEcn: u8 = unsafe { ::core::mem::transmute(mEcn) }; + mEcn as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mIsHostInterface: u8 = unsafe { ::core::mem::transmute(mIsHostInterface) }; + mIsHostInterface as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let mAllowZeroHopLimit: u8 = unsafe { ::core::mem::transmute(mAllowZeroHopLimit) }; + mAllowZeroHopLimit as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let mMulticastLoop: u8 = unsafe { ::core::mem::transmute(mMulticastLoop) }; + mMulticastLoop as u64 + }); + __bindgen_bitfield_unit + } +} +///< IPv6 Hop-by-Hop Option +pub const OT_IP6_PROTO_HOP_OPTS: _bindgen_ty_3 = 0; +///< Transmission Control Protocol +pub const OT_IP6_PROTO_TCP: _bindgen_ty_3 = 6; +///< User Datagram +pub const OT_IP6_PROTO_UDP: _bindgen_ty_3 = 17; +///< IPv6 encapsulation +pub const OT_IP6_PROTO_IP6: _bindgen_ty_3 = 41; +///< Routing Header for IPv6 +pub const OT_IP6_PROTO_ROUTING: _bindgen_ty_3 = 43; +///< Fragment Header for IPv6 +pub const OT_IP6_PROTO_FRAGMENT: _bindgen_ty_3 = 44; +///< ICMP for IPv6 +pub const OT_IP6_PROTO_ICMP6: _bindgen_ty_3 = 58; +///< No Next Header for IPv6 +pub const OT_IP6_PROTO_NONE: _bindgen_ty_3 = 59; +///< Destination Options for IPv6 +pub const OT_IP6_PROTO_DST_OPTS: _bindgen_ty_3 = 60; +/// Internet Protocol Numbers. +pub type _bindgen_ty_3 = ::core::ffi::c_uint; +unsafe extern "C" { + /// Brings the IPv6 interface up or down. + /// + /// Call this to enable or disable IPv6 communication. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aEnabled TRUE to enable IPv6, FALSE otherwise. + /// + /// @retval OT_ERROR_NONE Successfully brought the IPv6 interface up/down. + /// @retval OT_ERROR_INVALID_STATE IPv6 interface is not available since device is operating in raw-link mode + /// (applicable only when `OPENTHREAD_CONFIG_LINK_RAW_ENABLE` feature is enabled). + pub fn otIp6SetEnabled(aInstance: *mut otInstance, aEnabled: bool) -> otError; +} +unsafe extern "C" { + /// Indicates whether or not the IPv6 interface is up. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @retval TRUE The IPv6 interface is enabled. + /// @retval FALSE The IPv6 interface is disabled. + pub fn otIp6IsEnabled(aInstance: *mut otInstance) -> bool; +} +unsafe extern "C" { + /// Adds a Network Interface Address to the Thread interface. + /// + /// The passed-in instance @p aAddress is copied by the Thread interface. The Thread interface only + /// supports a fixed number of externally added unicast addresses. See `OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS`. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aAddress A pointer to a Network Interface Address. + /// + /// @retval OT_ERROR_NONE Successfully added (or updated) the Network Interface Address. + /// @retval OT_ERROR_INVALID_ARGS The IP Address indicated by @p aAddress is an internal address. + /// @retval OT_ERROR_NO_BUFS The Network Interface is already storing the maximum allowed external addresses. + pub fn otIp6AddUnicastAddress( + aInstance: *mut otInstance, + aAddress: *const otNetifAddress, + ) -> otError; +} +unsafe extern "C" { + /// Removes a Network Interface Address from the Thread interface. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aAddress A pointer to an IP Address. + /// + /// @retval OT_ERROR_NONE Successfully removed the Network Interface Address. + /// @retval OT_ERROR_INVALID_ARGS The IP Address indicated by @p aAddress is an internal address. + /// @retval OT_ERROR_NOT_FOUND The IP Address indicated by @p aAddress was not found. + pub fn otIp6RemoveUnicastAddress( + aInstance: *mut otInstance, + aAddress: *const otIp6Address, + ) -> otError; +} +unsafe extern "C" { + /// Gets the list of IPv6 addresses assigned to the Thread interface. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to the first Network Interface Address. + pub fn otIp6GetUnicastAddresses(aInstance: *mut otInstance) -> *const otNetifAddress; +} +unsafe extern "C" { + /// Indicates whether or not a unicast IPv6 address is assigned to the Thread interface. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aAddress A pointer to the unicast address. + /// + /// @retval TRUE If @p aAddress is assigned to the Thread interface. + /// @retval FALSE If @p aAddress is not assigned to the Thread interface. + pub fn otIp6HasUnicastAddress( + aInstance: *mut otInstance, + aAddress: *const otIp6Address, + ) -> bool; +} +unsafe extern "C" { + /// Subscribes the Thread interface to a Network Interface Multicast Address. + /// + /// The passed in instance @p aAddress will be copied by the Thread interface. The Thread interface only + /// supports a fixed number of externally added multicast addresses. See `OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS`. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aAddress A pointer to an IP Address. + /// + /// @retval OT_ERROR_NONE Successfully subscribed to the Network Interface Multicast Address. + /// @retval OT_ERROR_ALREADY The multicast address is already subscribed. + /// @retval OT_ERROR_INVALID_ARGS The IP Address indicated by @p aAddress is an invalid multicast address. + /// @retval OT_ERROR_REJECTED The IP Address indicated by @p aAddress is an internal multicast address. + /// @retval OT_ERROR_NO_BUFS The Network Interface is already storing the maximum allowed external multicast + /// addresses. + pub fn otIp6SubscribeMulticastAddress( + aInstance: *mut otInstance, + aAddress: *const otIp6Address, + ) -> otError; +} +unsafe extern "C" { + /// Unsubscribes the Thread interface to a Network Interface Multicast Address. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aAddress A pointer to an IP Address. + /// + /// @retval OT_ERROR_NONE Successfully unsubscribed to the Network Interface Multicast Address. + /// @retval OT_ERROR_REJECTED The IP Address indicated by @p aAddress is an internal address. + /// @retval OT_ERROR_NOT_FOUND The IP Address indicated by @p aAddress was not found. + pub fn otIp6UnsubscribeMulticastAddress( + aInstance: *mut otInstance, + aAddress: *const otIp6Address, + ) -> otError; +} +unsafe extern "C" { + /// Gets the list of IPv6 multicast addresses subscribed to the Thread interface. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to the first Network Interface Multicast Address. + pub fn otIp6GetMulticastAddresses(aInstance: *mut otInstance) + -> *const otNetifMulticastAddress; +} +unsafe extern "C" { + /// Allocate a new message buffer for sending an IPv6 message. + /// + /// @note If @p aSettings is 'NULL', the link layer security is enabled and the message priority is set to + /// OT_MESSAGE_PRIORITY_NORMAL by default. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aSettings A pointer to the message settings or NULL to set default settings. + /// + /// @returns A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid. + /// + /// @sa otMessageFree + pub fn otIp6NewMessage( + aInstance: *mut otInstance, + aSettings: *const otMessageSettings, + ) -> *mut otMessage; +} +unsafe extern "C" { + /// Allocate a new message buffer and write the IPv6 datagram to the message buffer for sending an IPv6 message. + /// + /// @note If @p aSettings is NULL, the link layer security is enabled and the message priority is obtained from IPv6 + /// message itself. + /// If @p aSettings is not NULL, the @p aSetting->mPriority is ignored and obtained from IPv6 message itself. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aData A pointer to the IPv6 datagram buffer. + /// @param[in] aDataLength The size of the IPv6 datagram buffer pointed by @p aData. + /// @param[in] aSettings A pointer to the message settings or NULL to set default settings. + /// + /// @returns A pointer to the message or NULL if malformed IPv6 header or insufficient message buffers are available. + /// + /// @sa otMessageFree + pub fn otIp6NewMessageFromBuffer( + aInstance: *mut otInstance, + aData: *const u8, + aDataLength: u16, + aSettings: *const otMessageSettings, + ) -> *mut otMessage; +} +/// Pointer is called when an IPv6 datagram is received. +/// +/// @param[in] aMessage A pointer to the message buffer containing the received IPv6 datagram. This function transfers +/// the ownership of the @p aMessage to the receiver of the callback. The message should be +/// freed by the receiver of the callback after it is processed (see otMessageFree()). +/// @param[in] aContext A pointer to application-specific context. +pub type otIp6ReceiveCallback = ::core::option::Option< + unsafe extern "C" fn(aMessage: *mut otMessage, aContext: *mut ::core::ffi::c_void), +>; +unsafe extern "C" { + /// Registers a callback to provide received IPv6 datagrams. + /// + /// By default, this callback does not pass Thread control traffic. See otIp6SetReceiveFilterEnabled() to + /// change the Thread control traffic filter setting. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aCallback A pointer to a function that is called when an IPv6 datagram is received or + /// NULL to disable the callback. + /// @param[in] aCallbackContext A pointer to application-specific context. + /// + /// @sa otIp6IsReceiveFilterEnabled + /// @sa otIp6SetReceiveFilterEnabled + pub fn otIp6SetReceiveCallback( + aInstance: *mut otInstance, + aCallback: otIp6ReceiveCallback, + aCallbackContext: *mut ::core::ffi::c_void, + ); +} +/// Represents IPv6 address information. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otIp6AddressInfo { + ///< A pointer to the IPv6 address. + pub mAddress: *const otIp6Address, + ///< The prefix length of mAddress if it is a unicast address. + pub mPrefixLength: u8, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: u16, +} +impl Default for otIp6AddressInfo { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 1usize, - 1u8, - val as u64, - ) + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() } } +} +impl otIp6AddressInfo { #[inline] - pub fn mCsmaCaEnabled(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + pub fn mScope(&self) -> u8 { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } } #[inline] - pub fn set_mCsmaCaEnabled(&mut self, val: bool) { + pub fn set_mScope(&mut self, val: u8) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(2usize, 1u8, val as u64) + self._bitfield_1.set(0usize, 4u8, val as u64) } } #[inline] - pub unsafe fn mCsmaCaEnabled_raw(this: *const Self) -> bool { + pub unsafe fn mScope_raw(this: *const Self) -> u8 { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 2usize, - 1u8, + 0usize, + 4u8, ) as u8) } } #[inline] - pub unsafe fn set_mCsmaCaEnabled_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mScope_raw(this: *mut Self, val: u8) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 2usize, - 1u8, + 0usize, + 4u8, val as u64, ) } } #[inline] - pub fn mCslPresent(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + pub fn mPreferred(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } } #[inline] - pub fn set_mCslPresent(&mut self, val: bool) { + pub fn set_mPreferred(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(3usize, 1u8, val as u64) + self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mCslPresent_raw(this: *const Self) -> bool { + pub unsafe fn mPreferred_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 3usize, + 4usize, 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mCslPresent_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mPreferred_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 3usize, + 4usize, 1u8, val as u64, ) } } #[inline] - pub fn mIsSecurityProcessed(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + pub fn mMeshLocal(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } } #[inline] - pub fn set_mIsSecurityProcessed(&mut self, val: bool) { + pub fn set_mMeshLocal(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(4usize, 1u8, val as u64) + self._bitfield_1.set(5usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mIsSecurityProcessed_raw(this: *const Self) -> bool { + pub unsafe fn mMeshLocal_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 4usize, + 5usize, 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mIsSecurityProcessed_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mMeshLocal_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 4usize, + 5usize, 1u8, val as u64, ) @@ -3234,1388 +2057,1714 @@ impl otRadioFrame__bindgen_ty_1__bindgen_ty_1 { } #[inline] pub fn new_bitfield_1( - mIsHeaderUpdated: bool, - mIsARetx: bool, - mCsmaCaEnabled: bool, - mCslPresent: bool, - mIsSecurityProcessed: bool, + mScope: u8, + mPreferred: bool, + mMeshLocal: bool, ) -> __BindgenBitfieldUnit<[u8; 1usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); - __bindgen_bitfield_unit.set(0usize, 1u8, { - let mIsHeaderUpdated: u8 = unsafe { ::core::mem::transmute(mIsHeaderUpdated) }; - mIsHeaderUpdated as u64 - }); - __bindgen_bitfield_unit.set(1usize, 1u8, { - let mIsARetx: u8 = unsafe { ::core::mem::transmute(mIsARetx) }; - mIsARetx as u64 - }); - __bindgen_bitfield_unit.set(2usize, 1u8, { - let mCsmaCaEnabled: u8 = unsafe { ::core::mem::transmute(mCsmaCaEnabled) }; - mCsmaCaEnabled as u64 - }); - __bindgen_bitfield_unit.set(3usize, 1u8, { - let mCslPresent: u8 = unsafe { ::core::mem::transmute(mCslPresent) }; - mCslPresent as u64 + __bindgen_bitfield_unit.set(0usize, 4u8, { + let mScope: u8 = unsafe { ::core::mem::transmute(mScope) }; + mScope as u64 }); __bindgen_bitfield_unit.set(4usize, 1u8, { - let mIsSecurityProcessed: u8 = unsafe { ::core::mem::transmute(mIsSecurityProcessed) }; - mIsSecurityProcessed as u64 + let mPreferred: u8 = unsafe { ::core::mem::transmute(mPreferred) }; + mPreferred as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let mMeshLocal: u8 = unsafe { ::core::mem::transmute(mMeshLocal) }; + mMeshLocal as u64 }); __bindgen_bitfield_unit } } -/// Structure representing radio frame receive information. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otRadioFrame__bindgen_ty_1__bindgen_ty_2 { - /// The time of the local radio clock in microseconds when the end of - /// the SFD was present at the local antenna. - pub mTimestamp: u64, - ///< ACK security frame counter (applicable when `mAckedWithSecEnhAck` is set). - pub mAckFrameCounter: u32, - ///< ACK security key index (applicable when `mAckedWithSecEnhAck` is set). - pub mAckKeyId: u8, - ///< Received signal strength indicator in dBm for received frames. - pub mRssi: i8, - ///< Link Quality Indicator for received frames. - pub mLqi: u8, - pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +/// Pointer is called when an internal IPv6 address is added or removed. +/// +/// @param[in] aAddressInfo A pointer to the IPv6 address information. +/// @param[in] aIsAdded TRUE if the @p aAddress was added, FALSE if @p aAddress was removed. +/// @param[in] aContext A pointer to application-specific context. +pub type otIp6AddressCallback = ::core::option::Option< + unsafe extern "C" fn( + aAddressInfo: *const otIp6AddressInfo, + aIsAdded: bool, + aContext: *mut ::core::ffi::c_void, + ), +>; +unsafe extern "C" { + /// Registers a callback to notify internal IPv6 address changes. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aCallback A pointer to a function that is called when an internal IPv6 address is added or + /// removed. NULL to disable the callback. + /// @param[in] aCallbackContext A pointer to application-specific context. + pub fn otIp6SetAddressCallback( + aInstance: *mut otInstance, + aCallback: otIp6AddressCallback, + aCallbackContext: *mut ::core::ffi::c_void, + ); +} +unsafe extern "C" { + /// Indicates whether or not Thread control traffic is filtered out when delivering IPv6 datagrams + /// via the callback specified in otIp6SetReceiveCallback(). + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns TRUE if Thread control traffic is filtered out, FALSE otherwise. + /// + /// @sa otIp6SetReceiveCallback + /// @sa otIp6SetReceiveFilterEnabled + pub fn otIp6IsReceiveFilterEnabled(aInstance: *mut otInstance) -> bool; +} +unsafe extern "C" { + /// Sets whether or not Thread control traffic is filtered out when delivering IPv6 datagrams + /// via the callback specified in otIp6SetReceiveCallback(). + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aEnabled TRUE if Thread control traffic is filtered out, FALSE otherwise. + /// + /// @sa otIp6SetReceiveCallback + /// @sa otIsReceiveIp6FilterEnabled + pub fn otIp6SetReceiveFilterEnabled(aInstance: *mut otInstance, aEnabled: bool); +} +unsafe extern "C" { + /// Sends an IPv6 datagram via the Thread interface. + /// + /// The caller transfers ownership of @p aMessage when making this call. OpenThread will free @p aMessage when + /// processing is complete, including when a value other than `OT_ERROR_NONE` is returned. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aMessage A pointer to the message buffer containing the IPv6 datagram. + /// + /// @retval OT_ERROR_NONE Successfully processed the message. + /// @retval OT_ERROR_DROP Message was well-formed but not fully processed due to packet processing + /// rules. + /// @retval OT_ERROR_NO_BUFS Could not allocate necessary message buffers when processing the datagram. + /// @retval OT_ERROR_NO_ROUTE No route to host. + /// @retval OT_ERROR_INVALID_SOURCE_ADDRESS Source address is invalid, e.g. an anycast address or a multicast address. + /// @retval OT_ERROR_PARSE Encountered a malformed header when processing the message. + /// @retval OT_ERROR_INVALID_ARGS The message's metadata is invalid, e.g. the message uses + /// `OT_MESSAGE_ORIGIN_THREAD_NETIF` as the origin. + pub fn otIp6Send(aInstance: *mut otInstance, aMessage: *mut otMessage) -> otError; +} +unsafe extern "C" { + /// Adds a port to the allowed unsecured port list. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aPort The port value. + /// + /// @retval OT_ERROR_NONE The port was successfully added to the allowed unsecure port list. + /// @retval OT_ERROR_INVALID_ARGS The port is invalid (value 0 is reserved for internal use). + /// @retval OT_ERROR_NO_BUFS The unsecure port list is full. + pub fn otIp6AddUnsecurePort(aInstance: *mut otInstance, aPort: u16) -> otError; +} +unsafe extern "C" { + /// Removes a port from the allowed unsecure port list. + /// + /// @note This function removes @p aPort by overwriting @p aPort with the element after @p aPort in the internal port + /// list. Be careful when calling otIp6GetUnsecurePorts() followed by otIp6RemoveUnsecurePort() to remove unsecure + /// ports. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aPort The port value. + /// + /// @retval OT_ERROR_NONE The port was successfully removed from the allowed unsecure port list. + /// @retval OT_ERROR_INVALID_ARGS The port is invalid (value 0 is reserved for internal use). + /// @retval OT_ERROR_NOT_FOUND The port was not found in the unsecure port list. + pub fn otIp6RemoveUnsecurePort(aInstance: *mut otInstance, aPort: u16) -> otError; +} +unsafe extern "C" { + /// Removes all ports from the allowed unsecure port list. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otIp6RemoveAllUnsecurePorts(aInstance: *mut otInstance); +} +unsafe extern "C" { + /// Returns a pointer to the unsecure port list. + /// + /// @note Port value 0 is used to indicate an invalid entry. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aNumEntries The number of entries in the list. + /// + /// @returns A pointer to the unsecure port list. + pub fn otIp6GetUnsecurePorts(aInstance: *mut otInstance, aNumEntries: *mut u8) -> *const u16; +} +unsafe extern "C" { + /// Test if two IPv6 addresses are the same. + /// + /// @param[in] aFirst A pointer to the first IPv6 address to compare. + /// @param[in] aSecond A pointer to the second IPv6 address to compare. + /// + /// @retval TRUE The two IPv6 addresses are the same. + /// @retval FALSE The two IPv6 addresses are not the same. + pub fn otIp6IsAddressEqual(aFirst: *const otIp6Address, aSecond: *const otIp6Address) -> bool; +} +unsafe extern "C" { + /// Test if two IPv6 prefixes are the same. + /// + /// @param[in] aFirst A pointer to the first IPv6 prefix to compare. + /// @param[in] aSecond A pointer to the second IPv6 prefix to compare. + /// + /// @retval TRUE The two IPv6 prefixes are the same. + /// @retval FALSE The two IPv6 prefixes are not the same. + pub fn otIp6ArePrefixesEqual(aFirst: *const otIp6Prefix, aSecond: *const otIp6Prefix) -> bool; +} +unsafe extern "C" { + /// Converts a human-readable IPv6 address string into a binary representation. + /// + /// @param[in] aString A pointer to a NULL-terminated string. + /// @param[out] aAddress A pointer to an IPv6 address. + /// + /// @retval OT_ERROR_NONE Successfully parsed @p aString and updated @p aAddress. + /// @retval OT_ERROR_PARSE Failed to parse @p aString as an IPv6 address. + pub fn otIp6AddressFromString( + aString: *const ::core::ffi::c_char, + aAddress: *mut otIp6Address, + ) -> otError; +} +unsafe extern "C" { + /// Converts a human-readable IPv6 prefix string into a binary representation. + /// + /// The @p aString parameter should be a string in the format "
/", where `
` is an IPv6 + /// address and `` is a prefix length. + /// + /// @param[in] aString A pointer to a NULL-terminated string. + /// @param[out] aPrefix A pointer to an IPv6 prefix. + /// + /// @retval OT_ERROR_NONE Successfully parsed the string as an IPv6 prefix and updated @p aPrefix. + /// @retval OT_ERROR_PARSE Failed to parse @p aString as an IPv6 prefix. + pub fn otIp6PrefixFromString( + aString: *const ::core::ffi::c_char, + aPrefix: *mut otIp6Prefix, + ) -> otError; +} +unsafe extern "C" { + /// Converts a given IPv6 address to a human-readable string. + /// + /// The IPv6 address string is formatted as 16 hex values separated by ':' (i.e., "%x:%x:%x:...:%x"). + /// + /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated + /// but the outputted string is always null-terminated. + /// + /// @param[in] aAddress A pointer to an IPv6 address (MUST NOT be NULL). + /// @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL). + /// @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_IP6_ADDRESS_STRING_SIZE`. + pub fn otIp6AddressToString( + aAddress: *const otIp6Address, + aBuffer: *mut ::core::ffi::c_char, + aSize: u16, + ); } -impl otRadioFrame__bindgen_ty_1__bindgen_ty_2 { - #[inline] - pub fn mAckedWithFramePending(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } - } - #[inline] - pub fn set_mAckedWithFramePending(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(0usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mAckedWithFramePending_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 0usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mAckedWithFramePending_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 0usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn mAckedWithSecEnhAck(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } - } - #[inline] - pub fn set_mAckedWithSecEnhAck(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(1usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mAckedWithSecEnhAck_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 1usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mAckedWithSecEnhAck_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 1usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn new_bitfield_1( - mAckedWithFramePending: bool, - mAckedWithSecEnhAck: bool, - ) -> __BindgenBitfieldUnit<[u8; 1usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); - __bindgen_bitfield_unit.set(0usize, 1u8, { - let mAckedWithFramePending: u8 = - unsafe { ::core::mem::transmute(mAckedWithFramePending) }; - mAckedWithFramePending as u64 - }); - __bindgen_bitfield_unit.set(1usize, 1u8, { - let mAckedWithSecEnhAck: u8 = unsafe { ::core::mem::transmute(mAckedWithSecEnhAck) }; - mAckedWithSecEnhAck as u64 - }); - __bindgen_bitfield_unit - } +unsafe extern "C" { + /// Converts a given IPv6 socket address to a human-readable string. + /// + /// The IPv6 socket address string is formatted as [`address`]:`port` where `address` is shown + /// as 16 hex values separated by `:` and `port` is the port number in decimal format, + /// for example "[%x:%x:...:%x]:%u". + /// + /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated + /// but the outputted string is always null-terminated. + /// + /// @param[in] aSockAddr A pointer to an IPv6 socket address (MUST NOT be NULL). + /// @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL). + /// @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_IP6_SOCK_ADDR_STRING_SIZE`. + pub fn otIp6SockAddrToString( + aSockAddr: *const otSockAddr, + aBuffer: *mut ::core::ffi::c_char, + aSize: u16, + ); } -pub const otRadioState_OT_RADIO_STATE_DISABLED: otRadioState = 0; -pub const otRadioState_OT_RADIO_STATE_SLEEP: otRadioState = 1; -pub const otRadioState_OT_RADIO_STATE_RECEIVE: otRadioState = 2; -pub const otRadioState_OT_RADIO_STATE_TRANSMIT: otRadioState = 3; -pub const otRadioState_OT_RADIO_STATE_INVALID: otRadioState = 255; -/// Represents the state of a radio. -/// Initially, a radio is in the Disabled state. -pub type otRadioState = ::core::ffi::c_uint; -/// Represents radio coexistence metrics. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otRadioCoexMetrics { - ///< Number of grant glitches. - pub mNumGrantGlitch: u32, - ///< Number of tx requests. - pub mNumTxRequest: u32, - ///< Number of tx requests while grant was active. - pub mNumTxGrantImmediate: u32, - ///< Number of tx requests while grant was inactive. - pub mNumTxGrantWait: u32, - ///< Number of tx requests while grant was inactive that were ultimately granted. - pub mNumTxGrantWaitActivated: u32, - ///< Number of tx requests while grant was inactive that timed out. - pub mNumTxGrantWaitTimeout: u32, - ///< Number of tx that were in progress when grant was deactivated. - pub mNumTxGrantDeactivatedDuringRequest: u32, - ///< Number of tx requests that were not granted within 50us. - pub mNumTxDelayedGrant: u32, - ///< Average time in usec from tx request to grant. - pub mAvgTxRequestToGrantTime: u32, - ///< Number of rx requests. - pub mNumRxRequest: u32, - ///< Number of rx requests while grant was active. - pub mNumRxGrantImmediate: u32, - ///< Number of rx requests while grant was inactive. - pub mNumRxGrantWait: u32, - ///< Number of rx requests while grant was inactive that were ultimately granted. - pub mNumRxGrantWaitActivated: u32, - ///< Number of rx requests while grant was inactive that timed out. - pub mNumRxGrantWaitTimeout: u32, - ///< Number of rx that were in progress when grant was deactivated. - pub mNumRxGrantDeactivatedDuringRequest: u32, - ///< Number of rx requests that were not granted within 50us. - pub mNumRxDelayedGrant: u32, - ///< Average time in usec from rx request to grant. - pub mAvgRxRequestToGrantTime: u32, - ///< Number of rx requests that completed without receiving grant. - pub mNumRxGrantNone: u32, - ///< Stats collection stopped due to saturation. - pub mStopped: bool, +unsafe extern "C" { + /// Converts a given IPv6 prefix to a human-readable string. + /// + /// The IPv6 address string is formatted as "%x:%x:%x:...[::]/plen". + /// + /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated + /// but the outputted string is always null-terminated. + /// + /// @param[in] aPrefix A pointer to an IPv6 prefix (MUST NOT be NULL). + /// @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL). + /// @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_IP6_PREFIX_STRING_SIZE`. + pub fn otIp6PrefixToString( + aPrefix: *const otIp6Prefix, + aBuffer: *mut ::core::ffi::c_char, + aSize: u16, + ); +} +unsafe extern "C" { + /// Returns the prefix match length (bits) for two IPv6 addresses. + /// + /// @param[in] aFirst A pointer to the first IPv6 address. + /// @param[in] aSecond A pointer to the second IPv6 address. + /// + /// @returns The prefix match length in bits. + pub fn otIp6PrefixMatch(aFirst: *const otIp6Address, aSecond: *const otIp6Address) -> u8; +} +unsafe extern "C" { + /// Gets a prefix with @p aLength from @p aAddress. + /// + /// @param[in] aAddress A pointer to an IPv6 address. + /// @param[in] aLength The length of prefix in bits. + /// @param[out] aPrefix A pointer to output the IPv6 prefix. + pub fn otIp6GetPrefix(aAddress: *const otIp6Address, aLength: u8, aPrefix: *mut otIp6Prefix); +} +unsafe extern "C" { + /// Indicates whether or not a given IPv6 address is the Unspecified Address. + /// + /// @param[in] aAddress A pointer to an IPv6 address. + /// + /// @retval TRUE If the IPv6 address is the Unspecified Address. + /// @retval FALSE If the IPv6 address is not the Unspecified Address. + pub fn otIp6IsAddressUnspecified(aAddress: *const otIp6Address) -> bool; +} +unsafe extern "C" { + /// Perform OpenThread source address selection. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in,out] aMessageInfo A pointer to the message information. + /// + /// @retval OT_ERROR_NONE Found a source address and is filled into mSockAddr of @p aMessageInfo. + /// @retval OT_ERROR_NOT_FOUND No source address was found and @p aMessageInfo is unchanged. + pub fn otIp6SelectSourceAddress( + aInstance: *mut otInstance, + aMessageInfo: *mut otMessageInfo, + ) -> otError; +} +unsafe extern "C" { + /// Indicates whether the SLAAC module is enabled or not. + /// + /// `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled. + /// + /// @retval TRUE SLAAC module is enabled. + /// @retval FALSE SLAAC module is disabled. + pub fn otIp6IsSlaacEnabled(aInstance: *mut otInstance) -> bool; } -/// Represents what metrics are specified to query. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otLinkMetrics { - pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +unsafe extern "C" { + /// Enables/disables the SLAAC module. + /// + /// `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled. + /// + /// When SLAAC module is enabled, SLAAC addresses (based on on-mesh prefixes in Network Data) are added to the interface. + /// When SLAAC module is disabled any previously added SLAAC address is removed. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aEnabled TRUE to enable, FALSE to disable. + pub fn otIp6SetSlaacEnabled(aInstance: *mut otInstance, aEnabled: bool); } -impl otLinkMetrics { - #[inline] - pub fn mPduCount(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } - } - #[inline] - pub fn set_mPduCount(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(0usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mPduCount_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 0usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mPduCount_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 0usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn mLqi(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } - } - #[inline] - pub fn set_mLqi(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(1usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mLqi_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 1usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mLqi_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 1usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn mLinkMargin(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } - } - #[inline] - pub fn set_mLinkMargin(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(2usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mLinkMargin_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 2usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mLinkMargin_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 2usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn mRssi(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } - } - #[inline] - pub fn set_mRssi(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(3usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mRssi_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 3usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mRssi_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 3usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn mReserved(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } - } - #[inline] - pub fn set_mReserved(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(4usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mReserved_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 4usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mReserved_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 4usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn new_bitfield_1( - mPduCount: bool, - mLqi: bool, - mLinkMargin: bool, - mRssi: bool, - mReserved: bool, - ) -> __BindgenBitfieldUnit<[u8; 1usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); - __bindgen_bitfield_unit.set(0usize, 1u8, { - let mPduCount: u8 = unsafe { ::core::mem::transmute(mPduCount) }; - mPduCount as u64 - }); - __bindgen_bitfield_unit.set(1usize, 1u8, { - let mLqi: u8 = unsafe { ::core::mem::transmute(mLqi) }; - mLqi as u64 - }); - __bindgen_bitfield_unit.set(2usize, 1u8, { - let mLinkMargin: u8 = unsafe { ::core::mem::transmute(mLinkMargin) }; - mLinkMargin as u64 - }); - __bindgen_bitfield_unit.set(3usize, 1u8, { - let mRssi: u8 = unsafe { ::core::mem::transmute(mRssi) }; - mRssi as u64 - }); - __bindgen_bitfield_unit.set(4usize, 1u8, { - let mReserved: u8 = unsafe { ::core::mem::transmute(mReserved) }; - mReserved as u64 - }); - __bindgen_bitfield_unit - } +/// Pointer allows user to filter prefixes and not allow an SLAAC address based on a prefix to be added. +/// +/// `otIp6SetSlaacPrefixFilter()` can be used to set the filter handler. The filter handler is invoked by SLAAC module +/// when it is about to add a SLAAC address based on a prefix. Its boolean return value determines whether the address +/// is filtered (not added) or not. +/// +/// @param[in] aInstance A pointer to an OpenThread instance. +/// @param[in] aPrefix A pointer to prefix for which SLAAC address is about to be added. +/// +/// @retval TRUE Indicates that the SLAAC address based on the prefix should be filtered and NOT added. +/// @retval FALSE Indicates that the SLAAC address based on the prefix should be added. +pub type otIp6SlaacPrefixFilter = ::core::option::Option< + unsafe extern "C" fn(aInstance: *mut otInstance, aPrefix: *const otIp6Prefix) -> bool, +>; +unsafe extern "C" { + /// Sets the SLAAC module filter handler. + /// + /// `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled. + /// + /// The filter handler is called by SLAAC module when it is about to add a SLAAC address based on a prefix to decide + /// whether the address should be added or not. + /// + /// A NULL filter handler disables filtering and allows all SLAAC addresses to be added. + /// + /// If this function is not called, the default filter used by SLAAC module will be NULL (filtering is disabled). + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aFilter A pointer to SLAAC prefix filter handler, or NULL to disable filtering. + pub fn otIp6SetSlaacPrefixFilter(aInstance: *mut otInstance, aFilter: otIp6SlaacPrefixFilter); } +/// Pointer is called with results of `otIp6RegisterMulticastListeners`. +/// +/// @param[in] aContext A pointer to the user context. +/// @param[in] aError OT_ERROR_NONE when successfully sent MLR.req and received MLR.rsp, +/// OT_ERROR_RESPONSE_TIMEOUT when failed to receive MLR.rsp, +/// OT_ERROR_PARSE when failed to parse MLR.rsp. +/// @param[in] aMlrStatus The Multicast Listener Registration status when @p aError is OT_ERROR_NONE. +/// @param[in] aFailedAddresses A pointer to the failed IPv6 addresses when @p aError is OT_ERROR_NONE. +/// @param[in] aFailedAddressNum The number of failed IPv6 addresses when @p aError is OT_ERROR_NONE. +/// +/// @sa otIp6RegisterMulticastListeners +pub type otIp6RegisterMulticastListenersCallback = ::core::option::Option< + unsafe extern "C" fn( + aContext: *mut ::core::ffi::c_void, + aError: otError, + aMlrStatus: u8, + aFailedAddresses: *const otIp6Address, + aFailedAddressNum: u8, + ), +>; unsafe extern "C" { - /// Get the radio capabilities. + /// Registers Multicast Listeners to Primary Backbone Router. /// - /// @param[in] aInstance The OpenThread instance structure. + /// `OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE` and `OPENTHREAD_CONFIG_COMMISSIONER_ENABLE` + /// must be enabled. /// - /// @returns The radio capability bit vector (see `OT_RADIO_CAP_*` definitions). - pub fn otPlatRadioGetCaps(aInstance: *mut otInstance) -> otRadioCaps; + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aAddresses A Multicast Address Array to register. + /// @param[in] aAddressNum The number of Multicast Address to register (0 if @p aAddresses is NULL). + /// @param[in] aTimeout A pointer to the timeout value (in seconds) to be included in MLR.req. A timeout value of 0 + /// removes the corresponding Multicast Listener. If NULL, MLR.req would have no Timeout Tlv by + /// default. + /// @param[in] aCallback A pointer to the callback function. + /// @param[in] aContext A pointer to the user context. + /// + /// @retval OT_ERROR_NONE Successfully sent MLR.req. The @p aCallback will be called iff this method + /// returns OT_ERROR_NONE. + /// @retval OT_ERROR_BUSY If a previous registration was ongoing. + /// @retval OT_ERROR_INVALID_ARGS If one or more arguments are invalid. + /// @retval OT_ERROR_INVALID_STATE If the device was not in a valid state to send MLR.req (e.g. Commissioner not + /// started, Primary Backbone Router not found). + /// @retval OT_ERROR_NO_BUFS If insufficient message buffers available. + /// + /// @sa otIp6RegisterMulticastListenersCallback + pub fn otIp6RegisterMulticastListeners( + aInstance: *mut otInstance, + aAddresses: *const otIp6Address, + aAddressNum: u8, + aTimeout: *const u32, + aCallback: otIp6RegisterMulticastListenersCallback, + aContext: *mut ::core::ffi::c_void, + ) -> otError; } unsafe extern "C" { - /// Get the radio version string. + /// Sets the Mesh Local IID (for test purpose). /// - /// This is an optional radio driver platform function. If not provided by platform radio driver, OpenThread uses - /// the OpenThread version instead (@sa otGetVersionString()). + /// Requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`. /// - /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aIid A pointer to the Mesh Local IID to set. /// - /// @returns A pointer to the OpenThread radio version. - pub fn otPlatRadioGetVersionString(aInstance: *mut otInstance) -> *const ::core::ffi::c_char; + /// @retval OT_ERROR_NONE Successfully set the Mesh Local IID. + /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + pub fn otIp6SetMeshLocalIid( + aInstance: *mut otInstance, + aIid: *const otIp6InterfaceIdentifier, + ) -> otError; } unsafe extern "C" { - /// Get the radio receive sensitivity value. + /// Converts a given IP protocol number to a human-readable string. /// - /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aIpProto An IP protocol number (`OT_IP6_PROTO_*` enumeration). /// - /// @returns The radio receive sensitivity value in dBm. - pub fn otPlatRadioGetReceiveSensitivity(aInstance: *mut otInstance) -> i8; + /// @returns A string representing @p aIpProto. + pub fn otIp6ProtoToString(aIpProto: u8) -> *const ::core::ffi::c_char; +} +/// Represents the counters for packets and bytes. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otPacketsAndBytes { + ///< The number of packets. + pub mPackets: u64, + ///< The number of bytes. + pub mBytes: u64, +} +/// Represents the counters of packets forwarded via Border Routing. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otBorderRoutingCounters { + ///< The counters for inbound unicast. + pub mInboundUnicast: otPacketsAndBytes, + ///< The counters for inbound multicast. + pub mInboundMulticast: otPacketsAndBytes, + ///< The counters for outbound unicast. + pub mOutboundUnicast: otPacketsAndBytes, + ///< The counters for outbound multicast. + pub mOutboundMulticast: otPacketsAndBytes, + ///< The counters for inbound Internet when DHCPv6 PD enabled. + pub mInboundInternet: otPacketsAndBytes, + ///< The counters for outbound Internet when DHCPv6 PD enabled. + pub mOutboundInternet: otPacketsAndBytes, + ///< The number of received RA packets. + pub mRaRx: u32, + ///< The number of RA packets successfully transmitted. + pub mRaTxSuccess: u32, + ///< The number of RA packets failed to transmit. + pub mRaTxFailure: u32, + ///< The number of received RS packets. + pub mRsRx: u32, + ///< The number of RS packets successfully transmitted. + pub mRsTxSuccess: u32, + ///< The number of RS packets failed to transmit. + pub mRsTxFailure: u32, } unsafe extern "C" { - /// Gets the factory-assigned IEEE EUI-64 for this interface. + /// Gets the Border Routing counters. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[out] aIeeeEui64 A pointer to the factory-assigned IEEE EUI-64. - pub fn otPlatRadioGetIeeeEui64(aInstance: *mut otInstance, aIeeeEui64: *mut u8); + /// `OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE` build-time feature must be enabled. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to the Border Routing counters. + pub fn otIp6GetBorderRoutingCounters( + aInstance: *mut otInstance, + ) -> *const otBorderRoutingCounters; } unsafe extern "C" { - /// Set the PAN ID for address filtering. + /// Resets the Border Routing counters. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aPanId The IEEE 802.15.4 PAN ID. - pub fn otPlatRadioSetPanId(aInstance: *mut otInstance, aPanId: otPanId); + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otIp6ResetBorderRoutingCounters(aInstance: *mut otInstance); +} +/// This callback allows OpenThread to provide specific handlers for certain UDP messages. +/// +/// @retval true The message is handled by this receiver and should not be further processed. +/// @retval false The message is not handled by this receiver. +pub type otUdpHandler = ::core::option::Option< + unsafe extern "C" fn( + aContext: *mut ::core::ffi::c_void, + aMessage: *const otMessage, + aMessageInfo: *const otMessageInfo, + ) -> bool, +>; +/// Represents a UDP receiver. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otUdpReceiver { + ///< A pointer to the next UDP receiver (internal use only). + pub mNext: *mut otUdpReceiver, + ///< A function pointer to the receiver callback. + pub mHandler: otUdpHandler, + ///< A pointer to application-specific context. + pub mContext: *mut ::core::ffi::c_void, +} +impl Default for otUdpReceiver { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } unsafe extern "C" { - /// Set the Extended Address for address filtering. + /// Adds a UDP receiver. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aExtAddress A pointer to the IEEE 802.15.4 Extended Address stored in little-endian byte order. - pub fn otPlatRadioSetExtendedAddress( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aUdpReceiver A pointer to the UDP receiver. + /// + /// @retval OT_ERROR_NONE The receiver is successfully added. + /// @retval OT_ERROR_ALREADY The UDP receiver was already added. + pub fn otUdpAddReceiver( aInstance: *mut otInstance, - aExtAddress: *const otExtAddress, - ); + aUdpReceiver: *mut otUdpReceiver, + ) -> otError; } unsafe extern "C" { - /// Set the Short Address for address filtering. + /// Removes a UDP receiver. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aShortAddress The IEEE 802.15.4 Short Address. - pub fn otPlatRadioSetShortAddress(aInstance: *mut otInstance, aShortAddress: otShortAddress); + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aUdpReceiver A pointer to the UDP receiver. + /// + /// @retval OT_ERROR_NONE The receiver is successfully removed. + /// @retval OT_ERROR_NOT_FOUND The UDP receiver was not added. + pub fn otUdpRemoveReceiver( + aInstance: *mut otInstance, + aUdpReceiver: *mut otUdpReceiver, + ) -> otError; } unsafe extern "C" { - /// Get the radio's transmit power in dBm. - /// - /// @note The transmit power returned will be no larger than the power specified in the max power table for - /// the current channel. + /// Sends a UDP message without socket. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[out] aPower The transmit power in dBm. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aMessage A pointer to a message without UDP header. + /// @param[in] aMessageInfo A pointer to a message info associated with @p aMessage. /// - /// @retval OT_ERROR_NONE Successfully retrieved the transmit power. - /// @retval OT_ERROR_INVALID_ARGS @p aPower was NULL. - /// @retval OT_ERROR_NOT_IMPLEMENTED Transmit power configuration via dBm is not implemented. - pub fn otPlatRadioGetTransmitPower(aInstance: *mut otInstance, aPower: *mut i8) -> otError; + /// @retval OT_ERROR_NONE Successfully enqueued the message into an output interface. + /// @retval OT_ERROR_NO_BUFS Insufficient available buffer to add the IPv6 headers. + /// @retval OT_ERROR_INVALID_ARGS Invalid arguments are given. + pub fn otUdpSendDatagram( + aInstance: *mut otInstance, + aMessage: *mut otMessage, + aMessageInfo: *mut otMessageInfo, + ) -> otError; +} +/// This callback allows OpenThread to inform the application of a received UDP message. +pub type otUdpReceive = ::core::option::Option< + unsafe extern "C" fn( + aContext: *mut ::core::ffi::c_void, + aMessage: *mut otMessage, + aMessageInfo: *const otMessageInfo, + ), +>; +///< Unspecified network interface. +pub const otNetifIdentifier_OT_NETIF_UNSPECIFIED: otNetifIdentifier = 0; +///< The host Thread interface - allow use of platform UDP. +pub const otNetifIdentifier_OT_NETIF_THREAD_HOST: otNetifIdentifier = 1; +///< The internal Thread interface (within OpenThread) - do not use platform UDP. +pub const otNetifIdentifier_OT_NETIF_THREAD_INTERNAL: otNetifIdentifier = 2; +///< The Backbone interface. +pub const otNetifIdentifier_OT_NETIF_BACKBONE: otNetifIdentifier = 3; +/// Defines the OpenThread network interface identifiers. +pub type otNetifIdentifier = ::core::ffi::c_uint; +/// Represents a UDP socket. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otUdpSocket { + ///< The local IPv6 socket address. + pub mSockName: otSockAddr, + ///< The peer IPv6 socket address. + pub mPeerName: otSockAddr, + ///< A function pointer to the application callback. + pub mHandler: otUdpReceive, + ///< A pointer to application-specific context. + pub mContext: *mut ::core::ffi::c_void, + ///< A handle to platform's UDP. + pub mHandle: *mut ::core::ffi::c_void, + ///< A pointer to the next UDP socket (internal use only). + pub mNext: *mut otUdpSocket, + ///< The network interface identifier. + pub mNetifId: otNetifIdentifier, +} +impl Default for otUdpSocket { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } unsafe extern "C" { - /// Set the radio's transmit power in dBm. - /// - /// @note The real transmit power will be no larger than the power specified in the max power table for - /// the current channel. + /// Allocate a new message buffer for sending a UDP message. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aPower The transmit power in dBm. + /// @note If @p aSettings is 'NULL', the link layer security is enabled and the message priority is set to + /// OT_MESSAGE_PRIORITY_NORMAL by default. /// - /// @retval OT_ERROR_NONE Successfully set the transmit power. - /// @retval OT_ERROR_NOT_IMPLEMENTED Transmit power configuration via dBm is not implemented. - pub fn otPlatRadioSetTransmitPower(aInstance: *mut otInstance, aPower: i8) -> otError; -} -unsafe extern "C" { - /// Get the radio's CCA ED threshold in dBm measured at antenna connector per IEEE 802.15.4 - 2015 section 10.1.4. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aSettings A pointer to the message settings or NULL to use default settings. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[out] aThreshold The CCA ED threshold in dBm. + /// @returns A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid. /// - /// @retval OT_ERROR_NONE Successfully retrieved the CCA ED threshold. - /// @retval OT_ERROR_INVALID_ARGS @p aThreshold was NULL. - /// @retval OT_ERROR_NOT_IMPLEMENTED CCA ED threshold configuration via dBm is not implemented. - pub fn otPlatRadioGetCcaEnergyDetectThreshold( + /// @sa otMessageFree + pub fn otUdpNewMessage( aInstance: *mut otInstance, - aThreshold: *mut i8, - ) -> otError; + aSettings: *const otMessageSettings, + ) -> *mut otMessage; } unsafe extern "C" { - /// Set the radio's CCA ED threshold in dBm measured at antenna connector per IEEE 802.15.4 - 2015 section 10.1.4. + /// Open a UDP/IPv6 socket. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aThreshold The CCA ED threshold in dBm. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aSocket A pointer to a UDP socket structure. + /// @param[in] aCallback A pointer to the application callback function. + /// @param[in] aContext A pointer to application-specific context. /// - /// @retval OT_ERROR_NONE Successfully set the transmit power. - /// @retval OT_ERROR_INVALID_ARGS Given threshold is out of range. - /// @retval OT_ERROR_NOT_IMPLEMENTED CCA ED threshold configuration via dBm is not implemented. - pub fn otPlatRadioSetCcaEnergyDetectThreshold( + /// @retval OT_ERROR_NONE Successfully opened the socket. + /// @retval OT_ERROR_FAILED Failed to open the socket. + pub fn otUdpOpen( aInstance: *mut otInstance, - aThreshold: i8, + aSocket: *mut otUdpSocket, + aCallback: otUdpReceive, + aContext: *mut ::core::ffi::c_void, ) -> otError; } unsafe extern "C" { - /// Gets the external FEM's Rx LNA gain in dBm. + /// Check if a UDP socket is open. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[out] aGain The external FEM's Rx LNA gain in dBm. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aSocket A pointer to a UDP socket structure. /// - /// @retval OT_ERROR_NONE Successfully retrieved the external FEM's LNA gain. - /// @retval OT_ERROR_INVALID_ARGS @p aGain was NULL. - /// @retval OT_ERROR_NOT_IMPLEMENTED External FEM's LNA setting is not implemented. - pub fn otPlatRadioGetFemLnaGain(aInstance: *mut otInstance, aGain: *mut i8) -> otError; + /// @returns Whether the UDP socket is open. + pub fn otUdpIsOpen(aInstance: *mut otInstance, aSocket: *const otUdpSocket) -> bool; } unsafe extern "C" { - /// Sets the external FEM's Rx LNA gain in dBm. + /// Close a UDP/IPv6 socket. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aGain The external FEM's Rx LNA gain in dBm. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aSocket A pointer to a UDP socket structure. /// - /// @retval OT_ERROR_NONE Successfully set the external FEM's LNA gain. - /// @retval OT_ERROR_NOT_IMPLEMENTED External FEM's LNA gain setting is not implemented. - pub fn otPlatRadioSetFemLnaGain(aInstance: *mut otInstance, aGain: i8) -> otError; + /// @retval OT_ERROR_NONE Successfully closed the socket. + /// @retval OT_ERROR_FAILED Failed to close UDP Socket. + pub fn otUdpClose(aInstance: *mut otInstance, aSocket: *mut otUdpSocket) -> otError; } unsafe extern "C" { - /// Get the status of promiscuous mode. + /// Bind a UDP/IPv6 socket. /// - /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aSocket A pointer to a UDP socket structure. + /// @param[in] aSockName A pointer to an IPv6 socket address structure. + /// @param[in] aNetif The network interface to bind. /// - /// @retval TRUE Promiscuous mode is enabled. - /// @retval FALSE Promiscuous mode is disabled. - pub fn otPlatRadioGetPromiscuous(aInstance: *mut otInstance) -> bool; + /// @retval OT_ERROR_NONE Bind operation was successful. + /// @retval OT_ERROR_FAILED Failed to bind UDP socket. + pub fn otUdpBind( + aInstance: *mut otInstance, + aSocket: *mut otUdpSocket, + aSockName: *const otSockAddr, + aNetif: otNetifIdentifier, + ) -> otError; } unsafe extern "C" { - /// Enable or disable promiscuous mode. + /// Connect a UDP/IPv6 socket. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aEnable TRUE to enable or FALSE to disable promiscuous mode. - pub fn otPlatRadioSetPromiscuous(aInstance: *mut otInstance, aEnable: bool); + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aSocket A pointer to a UDP socket structure. + /// @param[in] aSockName A pointer to an IPv6 socket address structure. + /// + /// @retval OT_ERROR_NONE Connect operation was successful. + /// @retval OT_ERROR_FAILED Failed to connect UDP socket. + pub fn otUdpConnect( + aInstance: *mut otInstance, + aSocket: *mut otUdpSocket, + aSockName: *const otSockAddr, + ) -> otError; } unsafe extern "C" { - /// Sets the rx-on-when-idle state to the radio platform. + /// Send a UDP/IPv6 message. /// - /// There are a few situations that the radio can enter sleep state if the device is in rx-off-when-idle state but - /// it's hard and costly for the SubMac to identify these situations and instruct the radio to enter sleep: + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aSocket A pointer to a UDP socket structure. + /// @param[in] aMessage A pointer to a message buffer. + /// @param[in] aMessageInfo A pointer to a message info structure. /// - /// - Finalization of a regular frame reception task, provided that: - /// - The frame is received without errors and passes the filtering and it's not an spurious ACK. - /// - ACK is not requested or transmission of ACK is not possible due to internal conditions. - /// - Finalization of a frame transmission or transmission of an ACK frame, when ACK is not requested in the transmitted - /// frame. - /// - Finalization of the reception operation of a requested ACK due to: - /// - ACK timeout expiration. - /// - Reception of an invalid ACK or not an ACK frame. - /// - Reception of the proper ACK, unless the transmitted frame was a Data Request Command and the frame pending bit - /// on the received ACK is set to true. In this case the radio platform implementation SHOULD keep the receiver on - /// until a determined timeout which triggers an idle period start.`OPENTHREAD_CONFIG_MAC_DATA_POLL_TIMEOUT` can be - /// taken as a reference for this. - /// - Finalization of a stand alone CCA task. - /// - Finalization of a CCA operation with busy result during CSMA/CA procedure. - /// - Finalization of an Energy Detection task. - /// - Finalization of a radio reception window scheduled with `otPlatRadioReceiveAt`. + /// If the return value is OT_ERROR_NONE, OpenThread takes ownership of @p aMessage, and the caller should no longer + /// reference @p aMessage. If the return value is not OT_ERROR_NONE, the caller retains ownership of @p aMessage, + /// including freeing @p aMessage if the message buffer is no longer needed. /// - /// If a platform supports `OT_RADIO_CAPS_RX_ON_WHEN_IDLE` it must also support `OT_RADIO_CAPS_CSMA_BACKOFF` and handle - /// idle periods after CCA as described above. + /// @retval OT_ERROR_NONE The message is successfully scheduled for sending. + /// @retval OT_ERROR_INVALID_ARGS Invalid arguments are given. + /// @retval OT_ERROR_NO_BUFS Insufficient available buffer to add the UDP and IPv6 headers. + pub fn otUdpSend( + aInstance: *mut otInstance, + aSocket: *mut otUdpSocket, + aMessage: *mut otMessage, + aMessageInfo: *const otMessageInfo, + ) -> otError; +} +unsafe extern "C" { + /// Gets the head of linked list of UDP Sockets. /// - /// Upon the transition of the "RxOnWhenIdle" flag from TRUE to FALSE, the radio platform should enter sleep mode. - /// If the radio is currently in receive mode, it should enter sleep mode immediately. Otherwise, it should enter sleep - /// mode after the current operation is completed. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aEnable TRUE to keep radio in Receive state, FALSE to put to Sleep state during idle periods. - pub fn otPlatRadioSetRxOnWhenIdle(aInstance: *mut otInstance, aEnable: bool); + /// @returns A pointer to the head of UDP Socket linked list. + pub fn otUdpGetSockets(aInstance: *mut otInstance) -> *mut otUdpSocket; } +/// Pointer delivers the UDP packet to host and host should send the packet through its own network stack. +/// +/// @param[in] aMessage A pointer to the UDP Message. +/// @param[in] aPeerPort The destination UDP port. +/// @param[in] aPeerAddr A pointer to the destination IPv6 address. +/// @param[in] aSockPort The source UDP port. +/// @param[in] aContext A pointer to application-specific context. +pub type otUdpForwarder = ::core::option::Option< + unsafe extern "C" fn( + aMessage: *mut otMessage, + aPeerPort: u16, + aPeerAddr: *mut otIp6Address, + aSockPort: u16, + aContext: *mut ::core::ffi::c_void, + ), +>; unsafe extern "C" { - /// Update MAC keys and key index - /// - /// Is used when radio provides OT_RADIO_CAPS_TRANSMIT_SEC capability. + /// Set UDP forward callback to deliver UDP packets to host. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aKeyIdMode The key ID mode. - /// @param[in] aKeyId Current MAC key index. - /// @param[in] aPrevKey A pointer to the previous MAC key. - /// @param[in] aCurrKey A pointer to the current MAC key. - /// @param[in] aNextKey A pointer to the next MAC key. - /// @param[in] aKeyType Key Type used. - pub fn otPlatRadioSetMacKey( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aForwarder A pointer to a function called to forward UDP packet to host. + /// @param[in] aContext A pointer to application-specific context. + pub fn otUdpForwardSetForwarder( aInstance: *mut otInstance, - aKeyIdMode: u8, - aKeyId: u8, - aPrevKey: *const otMacKeyMaterial, - aCurrKey: *const otMacKeyMaterial, - aNextKey: *const otMacKeyMaterial, - aKeyType: otRadioKeyType, + aForwarder: otUdpForwarder, + aContext: *mut ::core::ffi::c_void, ); } unsafe extern "C" { - /// Sets the current MAC frame counter value. + /// Handle a UDP packet received from host. /// - /// Is used when radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aMessage A pointer to the UDP Message. + /// @param[in] aPeerPort The source UDP port. + /// @param[in] aPeerAddr A pointer to the source address. + /// @param[in] aSockPort The destination UDP port. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aMacFrameCounter The MAC frame counter value. - pub fn otPlatRadioSetMacFrameCounter(aInstance: *mut otInstance, aMacFrameCounter: u32); + /// @warning No matter the call success or fail, the message is freed. + pub fn otUdpForwardReceive( + aInstance: *mut otInstance, + aMessage: *mut otMessage, + aPeerPort: u16, + aPeerAddr: *const otIp6Address, + aSockPort: u16, + ); } unsafe extern "C" { - /// Sets the current MAC frame counter value only if the new given value is larger than the current value. + /// Determines if the given UDP port is exclusively opened by OpenThread API. /// - /// Is used when radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] port UDP port number to verify. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aMacFrameCounter The MAC frame counter value. - pub fn otPlatRadioSetMacFrameCounterIfLarger(aInstance: *mut otInstance, aMacFrameCounter: u32); + /// @retval true The port is being used exclusively by OpenThread. + /// @retval false The port is not used by any of the OpenThread API or is shared (e.g. is Backbone socket). + pub fn otUdpIsPortInUse(aInstance: *mut otInstance, port: u16) -> bool; +} +///< Key Type: Raw Data. +pub const otCryptoKeyType_OT_CRYPTO_KEY_TYPE_RAW: otCryptoKeyType = 0; +///< Key Type: AES. +pub const otCryptoKeyType_OT_CRYPTO_KEY_TYPE_AES: otCryptoKeyType = 1; +///< Key Type: HMAC. +pub const otCryptoKeyType_OT_CRYPTO_KEY_TYPE_HMAC: otCryptoKeyType = 2; +///< Key Type: ECDSA. +pub const otCryptoKeyType_OT_CRYPTO_KEY_TYPE_ECDSA: otCryptoKeyType = 3; +/// Defines the key types. +pub type otCryptoKeyType = ::core::ffi::c_uint; +///< Key Algorithm: Vendor Defined. +pub const otCryptoKeyAlgorithm_OT_CRYPTO_KEY_ALG_VENDOR: otCryptoKeyAlgorithm = 0; +///< Key Algorithm: AES ECB. +pub const otCryptoKeyAlgorithm_OT_CRYPTO_KEY_ALG_AES_ECB: otCryptoKeyAlgorithm = 1; +///< Key Algorithm: HMAC SHA-256. +pub const otCryptoKeyAlgorithm_OT_CRYPTO_KEY_ALG_HMAC_SHA_256: otCryptoKeyAlgorithm = 2; +///< Key Algorithm: ECDSA. +pub const otCryptoKeyAlgorithm_OT_CRYPTO_KEY_ALG_ECDSA: otCryptoKeyAlgorithm = 3; +/// Defines the key algorithms. +pub type otCryptoKeyAlgorithm = ::core::ffi::c_uint; +///< Key Usage: Key Usage is empty. +pub const OT_CRYPTO_KEY_USAGE_NONE: _bindgen_ty_4 = 0; +///< Key Usage: Key can be exported. +pub const OT_CRYPTO_KEY_USAGE_EXPORT: _bindgen_ty_4 = 1; +///< Key Usage: Encryption (vendor defined). +pub const OT_CRYPTO_KEY_USAGE_ENCRYPT: _bindgen_ty_4 = 2; +///< Key Usage: AES ECB. +pub const OT_CRYPTO_KEY_USAGE_DECRYPT: _bindgen_ty_4 = 4; +///< Key Usage: Sign Hash. +pub const OT_CRYPTO_KEY_USAGE_SIGN_HASH: _bindgen_ty_4 = 8; +///< Key Usage: Verify Hash. +pub const OT_CRYPTO_KEY_USAGE_VERIFY_HASH: _bindgen_ty_4 = 16; +/// Defines the key usage flags. +pub type _bindgen_ty_4 = ::core::ffi::c_uint; +///< Key Persistence: Key is volatile. +pub const otCryptoKeyStorage_OT_CRYPTO_KEY_STORAGE_VOLATILE: otCryptoKeyStorage = 0; +///< Key Persistence: Key is persistent. +pub const otCryptoKeyStorage_OT_CRYPTO_KEY_STORAGE_PERSISTENT: otCryptoKeyStorage = 1; +/// Defines the key storage types. +pub type otCryptoKeyStorage = ::core::ffi::c_uint; +/// This datatype represents the key reference. +pub type otCryptoKeyRef = u32; +/// @struct otCryptoKey +/// +/// Represents the Key Material required for Crypto operations. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otCryptoKey { + ///< Pointer to the buffer containing key. NULL indicates to use `mKeyRef`. + pub mKey: *const u8, + ///< The key length in bytes (applicable when `mKey` is not NULL). + pub mKeyLength: u16, + ///< The PSA key ref (requires `mKey` to be NULL). + pub mKeyRef: u32, } -unsafe extern "C" { - /// Get the current time in microseconds referenced to a continuous monotonic - /// local radio clock (64 bits width). - /// - /// The radio clock SHALL NOT wrap during the device's uptime. Implementations - /// SHALL therefore identify and compensate for internal counter overflows. The - /// clock does not have a defined epoch and it SHALL NOT introduce any continuous - /// or discontinuous adjustments (e.g. leap seconds). Implementations SHALL - /// compensate for any sleep times of the device. - /// - /// Implementations MAY choose to discipline the radio clock and compensate for - /// sleep times by any means (e.g. by combining a high precision/low power RTC - /// with a high resolution counter) as long as the exposed combined clock - /// provides continuous monotonic microsecond resolution ticks within the - /// accuracy limits announced by @ref otPlatRadioGetCslAccuracy. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @returns The current time in microseconds. UINT64_MAX when platform does not - /// support or radio time is not ready. - pub fn otPlatRadioGetNow(aInstance: *mut otInstance) -> u64; +impl Default for otCryptoKey { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - /// Get the bus speed in bits/second between the host and the radio chip. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @returns The bus speed in bits/second between the host and the radio chip. - /// Return 0 when the MAC and above layer and Radio layer resides on the same chip. - pub fn otPlatRadioGetBusSpeed(aInstance: *mut otInstance) -> u32; +/// @struct otCryptoContext +/// +/// Stores the context object for platform APIs. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otCryptoContext { + ///< Pointer to the context. + pub mContext: *mut ::core::ffi::c_void, + ///< The length of the context in bytes. + pub mContextSize: u16, } -unsafe extern "C" { - /// Get the bus latency in microseconds between the host and the radio chip. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @returns The bus latency in microseconds between the host and the radio chip. - /// Return 0 when the MAC and above layer and Radio layer resides on the same chip. - pub fn otPlatRadioGetBusLatency(aInstance: *mut otInstance) -> u32; +impl Default for otCryptoContext { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - /// Get current state of the radio. - /// - /// Is not required by OpenThread. It may be used for debugging and/or application-specific purposes. - /// - /// @note This function may be not implemented. It does not affect OpenThread. - /// - /// @param[in] aInstance The OpenThread instance structure. - /// - /// @return Current state of the radio. - pub fn otPlatRadioGetState(aInstance: *mut otInstance) -> otRadioState; +/// @struct otPlatCryptoSha256Hash +/// +/// Represents a SHA-256 hash. +#[repr(C, packed)] +#[derive(Default, Copy, Clone)] +pub struct otPlatCryptoSha256Hash { + ///< Hash bytes. + pub m8: [u8; 32usize], } -unsafe extern "C" { - /// Enable the radio. - /// - /// @param[in] aInstance The OpenThread instance structure. - /// - /// @retval OT_ERROR_NONE Successfully enabled. - /// @retval OT_ERROR_FAILED The radio could not be enabled. - pub fn otPlatRadioEnable(aInstance: *mut otInstance) -> otError; +/// @struct otPlatCryptoEcdsaKeyPair +/// +/// Represents an ECDSA key pair (public and private keys). +/// +/// The key pair is stored using Distinguished Encoding Rules (DER) format (per RFC 5915). +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otPlatCryptoEcdsaKeyPair { + pub mDerBytes: [u8; 125usize], + pub mDerLength: u8, } -unsafe extern "C" { - /// Disable the radio. - /// - /// @param[in] aInstance The OpenThread instance structure. - /// - /// @retval OT_ERROR_NONE Successfully transitioned to Disabled. - /// @retval OT_ERROR_INVALID_STATE The radio was not in sleep state. - pub fn otPlatRadioDisable(aInstance: *mut otInstance) -> otError; +impl Default for otPlatCryptoEcdsaKeyPair { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - /// Check whether radio is enabled or not. - /// - /// @param[in] aInstance The OpenThread instance structure. - /// - /// @returns TRUE if the radio is enabled, FALSE otherwise. - pub fn otPlatRadioIsEnabled(aInstance: *mut otInstance) -> bool; +/// @struct otPlatCryptoEcdsaPublicKey +/// +/// Represents a ECDSA public key. +/// +/// The public key is stored as a byte sequence representation of an uncompressed curve point (RFC 6605 - sec 4). +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub struct otPlatCryptoEcdsaPublicKey { + pub m8: [u8; 64usize], } -unsafe extern "C" { - /// Transition the radio from Receive to Sleep (turn off the radio). - /// - /// @param[in] aInstance The OpenThread instance structure. - /// - /// @retval OT_ERROR_NONE Successfully transitioned to Sleep. - /// @retval OT_ERROR_BUSY The radio was transmitting. - /// @retval OT_ERROR_INVALID_STATE The radio was disabled. - pub fn otPlatRadioSleep(aInstance: *mut otInstance) -> otError; +impl Default for otPlatCryptoEcdsaPublicKey { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -unsafe extern "C" { - /// Transition the radio from Sleep to Receive (turn on the radio). - /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aChannel The channel to use for receiving. - /// - /// @retval OT_ERROR_NONE Successfully transitioned to Receive. - /// @retval OT_ERROR_INVALID_STATE The radio was disabled or transmitting. - pub fn otPlatRadioReceive(aInstance: *mut otInstance, aChannel: u8) -> otError; +/// @struct otPlatCryptoEcdsaSignature +/// +/// Represents an ECDSA signature. +/// +/// The signature is encoded as the concatenated binary representation of two MPIs `r` and `s` which are calculated +/// during signing (RFC 6605 - section 4). +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub struct otPlatCryptoEcdsaSignature { + pub m8: [u8; 64usize], } -unsafe extern "C" { - /// Schedule a radio reception window at a specific time and duration. - /// - /// @param[in] aChannel The radio channel on which to receive. - /// @param[in] aStart The receive window start time relative to the local - /// radio clock, see `otPlatRadioGetNow`. The radio - /// receiver SHALL be on and ready to receive the first - /// symbol of a frame's SHR at the window start time. - /// @param[in] aDuration The receive window duration, in microseconds, as - /// measured by the local radio clock. The radio SHOULD be - /// turned off (or switched to TX mode if an ACK frame - /// needs to be sent) after that duration unless it is - /// still actively receiving a frame. In the latter case - /// the radio SHALL be kept in reception mode until frame - /// reception has either succeeded or failed. - /// - /// @retval OT_ERROR_NONE Successfully scheduled receive window. - /// @retval OT_ERROR_FAILED The receive window could not be scheduled. - pub fn otPlatRadioReceiveAt( - aInstance: *mut otInstance, - aChannel: u8, - aStart: u32, - aDuration: u32, - ) -> otError; +impl Default for otPlatCryptoEcdsaSignature { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } unsafe extern "C" { - /// The radio driver calls this method to notify OpenThread of a received frame. - /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aFrame A pointer to the received frame or NULL if the receive operation failed. - /// @param[in] aError OT_ERROR_NONE when successfully received a frame, - /// OT_ERROR_ABORT when reception was aborted and a frame was not received, - /// OT_ERROR_NO_BUFS when a frame could not be received due to lack of rx buffer space. - pub fn otPlatRadioReceiveDone( - aInstance: *mut otInstance, - aFrame: *mut otRadioFrame, - aError: otError, - ); + /// Initialize the Crypto module. + pub fn otPlatCryptoInit(); } unsafe extern "C" { - /// The radio driver calls this method to notify OpenThread diagnostics module of a received frame. + /// Import a key into PSA ITS. /// - /// Is used when diagnostics is enabled. + /// @param[in,out] aKeyRef Pointer to the key ref to be used for crypto operations. + /// @param[in] aKeyType Key Type encoding for the key. + /// @param[in] aKeyAlgorithm Key algorithm encoding for the key. + /// @param[in] aKeyUsage Key Usage encoding for the key (combinations of `OT_CRYPTO_KEY_USAGE_*`). + /// @param[in] aKeyPersistence Key Persistence for this key + /// @param[in] aKey Actual key to be imported. + /// @param[in] aKeyLen Length of the key to be imported. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aFrame A pointer to the received frame or NULL if the receive operation failed. - /// @param[in] aError OT_ERROR_NONE when successfully received a frame, - /// OT_ERROR_ABORT when reception was aborted and a frame was not received, - /// OT_ERROR_NO_BUFS when a frame could not be received due to lack of rx buffer space. - pub fn otPlatDiagRadioReceiveDone( - aInstance: *mut otInstance, - aFrame: *mut otRadioFrame, - aError: otError, - ); -} -unsafe extern "C" { - /// Get the radio transmit frame buffer. + /// @retval OT_ERROR_NONE Successfully imported the key. + /// @retval OT_ERROR_FAILED Failed to import the key. + /// @retval OT_ERROR_INVALID_ARGS @p aKey was set to NULL. /// - /// OpenThread forms the IEEE 802.15.4 frame in this buffer then calls `otPlatRadioTransmit()` to request transmission. + /// @note If OT_CRYPTO_KEY_STORAGE_PERSISTENT is passed for aKeyPersistence then @p aKeyRef is input and platform + /// should use the given aKeyRef and MUST not change it. /// - /// @param[in] aInstance The OpenThread instance structure. + /// If OT_CRYPTO_KEY_STORAGE_VOLATILE is passed for aKeyPersistence then @p aKeyRef is output, the initial + /// value does not matter and platform API MUST update it to return the new key ref. /// - /// @returns A pointer to the transmit frame buffer. - pub fn otPlatRadioGetTransmitBuffer(aInstance: *mut otInstance) -> *mut otRadioFrame; + /// This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + pub fn otPlatCryptoImportKey( + aKeyRef: *mut otCryptoKeyRef, + aKeyType: otCryptoKeyType, + aKeyAlgorithm: otCryptoKeyAlgorithm, + aKeyUsage: ::core::ffi::c_int, + aKeyPersistence: otCryptoKeyStorage, + aKey: *const u8, + aKeyLen: usize, + ) -> otError; } unsafe extern "C" { - /// Begin the transmit sequence on the radio. - /// - /// The caller must form the IEEE 802.15.4 frame in the buffer provided by `otPlatRadioGetTransmitBuffer()` before - /// requesting transmission. The channel and transmit power are also included in the otRadioFrame structure. + /// Export a key stored in PSA ITS. /// - /// The transmit sequence consists of: - /// 1. Transitioning the radio to Transmit from one of the following states: - /// - Receive if RX is on when the device is idle or OT_RADIO_CAPS_SLEEP_TO_TX is not supported - /// - Sleep if RX is off when the device is idle and OT_RADIO_CAPS_SLEEP_TO_TX is supported. - /// 2. Transmits the psdu on the given channel and at the given transmit power. + /// @param[in] aKeyRef The key ref to be used for crypto operations. + /// @param[out] aBuffer Pointer to the buffer where key needs to be exported. + /// @param[in] aBufferLen Length of the buffer passed to store the exported key. + /// @param[out] aKeyLen Pointer to return the length of the exported key. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aFrame A pointer to the frame to be transmitted. + /// @retval OT_ERROR_NONE Successfully exported @p aKeyRef. + /// @retval OT_ERROR_FAILED Failed to export @p aKeyRef. + /// @retval OT_ERROR_INVALID_ARGS @p aBuffer was NULL /// - /// @retval OT_ERROR_NONE Successfully transitioned to Transmit. - /// @retval OT_ERROR_INVALID_STATE The radio was not in the Receive state. - pub fn otPlatRadioTransmit(aInstance: *mut otInstance, aFrame: *mut otRadioFrame) -> otError; + /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + pub fn otPlatCryptoExportKey( + aKeyRef: otCryptoKeyRef, + aBuffer: *mut u8, + aBufferLen: usize, + aKeyLen: *mut usize, + ) -> otError; } unsafe extern "C" { - /// The radio driver calls this method to notify OpenThread that the transmission has started. + /// Destroy a key stored in PSA ITS. /// - /// @note This function should be called by the same thread that executes all of the other OpenThread code. It should - /// not be called by ISR or any other task. + /// @param[in] aKeyRef The key ref to be destroyed /// - /// @param[in] aInstance A pointer to the OpenThread instance structure. - /// @param[in] aFrame A pointer to the frame that is being transmitted. - pub fn otPlatRadioTxStarted(aInstance: *mut otInstance, aFrame: *mut otRadioFrame); + /// @retval OT_ERROR_NONE Successfully destroyed the key. + /// @retval OT_ERROR_FAILED Failed to destroy the key. + /// + /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + pub fn otPlatCryptoDestroyKey(aKeyRef: otCryptoKeyRef) -> otError; } unsafe extern "C" { - /// The radio driver calls this function to notify OpenThread that the transmit operation has completed, - /// providing both the transmitted frame and, if applicable, the received ack frame. + /// Check if the key ref passed has an associated key in PSA ITS. /// - /// When radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability, radio platform layer updates @p aFrame - /// with the security frame counter and key index values maintained by the radio. + /// @param[in] aKeyRef The Key Ref to check. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aFrame A pointer to the frame that was transmitted. - /// @param[in] aAckFrame A pointer to the ACK frame, NULL if no ACK was received. - /// @param[in] aError OT_ERROR_NONE when the frame was transmitted, - /// OT_ERROR_NO_ACK when the frame was transmitted but no ACK was received, - /// OT_ERROR_CHANNEL_ACCESS_FAILURE tx could not take place due to activity on the channel, - /// OT_ERROR_ABORT when transmission was aborted for other reasons. - pub fn otPlatRadioTxDone( - aInstance: *mut otInstance, - aFrame: *mut otRadioFrame, - aAckFrame: *mut otRadioFrame, - aError: otError, - ); + /// @retval TRUE There is an associated key with @p aKeyRef. + /// @retval FALSE There is no associated key with @p aKeyRef. + /// + /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + pub fn otPlatCryptoHasKey(aKeyRef: otCryptoKeyRef) -> bool; } unsafe extern "C" { - /// The radio driver calls this method to notify OpenThread diagnostics module that the transmission has completed. + /// Initialize the HMAC operation. /// - /// Is used when diagnostics is enabled. + /// @param[in] aContext Context for HMAC operation. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aFrame A pointer to the frame that was transmitted. - /// @param[in] aError OT_ERROR_NONE when the frame was transmitted, - /// OT_ERROR_CHANNEL_ACCESS_FAILURE tx could not take place due to activity on the channel, - /// OT_ERROR_ABORT when transmission was aborted for other reasons. - pub fn otPlatDiagRadioTransmitDone( - aInstance: *mut otInstance, - aFrame: *mut otRadioFrame, - aError: otError, - ); + /// @retval OT_ERROR_NONE Successfully initialized HMAC operation. + /// @retval OT_ERROR_FAILED Failed to initialize HMAC operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + /// + /// @note The platform driver shall point the context to the correct object such as psa_mac_operation_t or + /// mbedtls_md_context_t. + pub fn otPlatCryptoHmacSha256Init(aContext: *mut otCryptoContext) -> otError; } unsafe extern "C" { - /// Get the most recent RSSI measurement. + /// Uninitialize the HMAC operation. /// - /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aContext Context for HMAC operation. /// - /// @returns The RSSI in dBm when it is valid. 127 when RSSI is invalid. - pub fn otPlatRadioGetRssi(aInstance: *mut otInstance) -> i8; + /// @retval OT_ERROR_NONE Successfully uninitialized HMAC operation. + /// @retval OT_ERROR_FAILED Failed to uninitialized HMAC operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + pub fn otPlatCryptoHmacSha256Deinit(aContext: *mut otCryptoContext) -> otError; } unsafe extern "C" { - /// Begin the energy scan sequence on the radio. - /// - /// Is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. + /// Start HMAC operation. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aScanChannel The channel to perform the energy scan on. - /// @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned. + /// @param[in] aContext Context for HMAC operation. + /// @param[in] aKey Key material to be used for HMAC operation. /// - /// @retval OT_ERROR_NONE Successfully started scanning the channel. - /// @retval OT_ERROR_BUSY The radio is performing energy scanning. - /// @retval OT_ERROR_NOT_IMPLEMENTED The radio doesn't support energy scanning. - pub fn otPlatRadioEnergyScan( - aInstance: *mut otInstance, - aScanChannel: u8, - aScanDuration: u16, + /// @retval OT_ERROR_NONE Successfully started HMAC operation. + /// @retval OT_ERROR_FAILED Failed to start HMAC operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey was NULL + pub fn otPlatCryptoHmacSha256Start( + aContext: *mut otCryptoContext, + aKey: *const otCryptoKey, ) -> otError; } unsafe extern "C" { - /// The radio driver calls this method to notify OpenThread that the energy scan is complete. + /// Update the HMAC operation with new input. /// - /// Is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. + /// @param[in] aContext Context for HMAC operation. + /// @param[in] aBuf A pointer to the input buffer. + /// @param[in] aBufLength The length of @p aBuf in bytes. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aEnergyScanMaxRssi The maximum RSSI encountered on the scanned channel. - pub fn otPlatRadioEnergyScanDone(aInstance: *mut otInstance, aEnergyScanMaxRssi: i8); + /// @retval OT_ERROR_NONE Successfully updated HMAC with new input operation. + /// @retval OT_ERROR_FAILED Failed to update HMAC operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL + pub fn otPlatCryptoHmacSha256Update( + aContext: *mut otCryptoContext, + aBuf: *const ::core::ffi::c_void, + aBufLength: u16, + ) -> otError; } unsafe extern "C" { - /// The radio driver calls this method to notify OpenThread that the spinel bus latency has been changed. + /// Complete the HMAC operation. /// - /// @param[in] aInstance The OpenThread instance structure. - pub fn otPlatRadioBusLatencyChanged(aInstance: *mut otInstance); + /// @param[in] aContext Context for HMAC operation. + /// @param[out] aBuf A pointer to the output buffer. + /// @param[in] aBufLength The length of @p aBuf in bytes. + /// + /// @retval OT_ERROR_NONE Successfully completed HMAC operation. + /// @retval OT_ERROR_FAILED Failed to complete HMAC operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL + pub fn otPlatCryptoHmacSha256Finish( + aContext: *mut otCryptoContext, + aBuf: *mut u8, + aBufLength: usize, + ) -> otError; } unsafe extern "C" { - /// Enable/Disable source address match feature. - /// - /// The source address match feature controls how the radio layer decides the "frame pending" bit for acks sent in - /// response to data request commands from children. - /// - /// If disabled, the radio layer must set the "frame pending" on all acks to data request commands. + /// Initialise the AES operation. /// - /// If enabled, the radio layer uses the source address match table to determine whether to set or clear the "frame - /// pending" bit in an ack to a data request command. + /// @param[in] aContext Context for AES operation. /// - /// The source address match table provides the list of children for which there is a pending frame. Either a short - /// address or an extended/long address can be added to the source address match table. + /// @retval OT_ERROR_NONE Successfully Initialised AES operation. + /// @retval OT_ERROR_FAILED Failed to Initialise AES operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + /// @retval OT_ERROR_NO_BUFS Cannot allocate the context. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aEnable Enable/disable source address match feature. - pub fn otPlatRadioEnableSrcMatch(aInstance: *mut otInstance, aEnable: bool); + /// @note The platform driver shall point the context to the correct object such as psa_key_id + /// or mbedtls_aes_context_t. + pub fn otPlatCryptoAesInit(aContext: *mut otCryptoContext) -> otError; } unsafe extern "C" { - /// Add a short address to the source address match table. + /// Set the key for AES operation. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aShortAddress The short address to be added. + /// @param[in] aContext Context for AES operation. + /// @param[out] aKey Key to use for AES operation. /// - /// @retval OT_ERROR_NONE Successfully added short address to the source match table. - /// @retval OT_ERROR_NO_BUFS No available entry in the source match table. - pub fn otPlatRadioAddSrcMatchShortEntry( - aInstance: *mut otInstance, - aShortAddress: otShortAddress, + /// @retval OT_ERROR_NONE Successfully set the key for AES operation. + /// @retval OT_ERROR_FAILED Failed to set the key for AES operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey was NULL + pub fn otPlatCryptoAesSetKey( + aContext: *mut otCryptoContext, + aKey: *const otCryptoKey, ) -> otError; } unsafe extern "C" { - /// Add an extended address to the source address match table. + /// Encrypt the given data. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aExtAddress The extended address to be added stored in little-endian byte order. + /// @param[in] aContext Context for AES operation. + /// @param[in] aInput Pointer to the input buffer. + /// @param[in] aOutput Pointer to the output buffer. /// - /// @retval OT_ERROR_NONE Successfully added extended address to the source match table. - /// @retval OT_ERROR_NO_BUFS No available entry in the source match table. - pub fn otPlatRadioAddSrcMatchExtEntry( - aInstance: *mut otInstance, - aExtAddress: *const otExtAddress, + /// @retval OT_ERROR_NONE Successfully encrypted @p aInput. + /// @retval OT_ERROR_FAILED Failed to encrypt @p aInput. + /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey or @p aOutput were NULL + pub fn otPlatCryptoAesEncrypt( + aContext: *mut otCryptoContext, + aInput: *const u8, + aOutput: *mut u8, ) -> otError; } unsafe extern "C" { - /// Remove a short address from the source address match table. + /// Free the AES context. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aShortAddress The short address to be removed. + /// @param[in] aContext Context for AES operation. /// - /// @retval OT_ERROR_NONE Successfully removed short address from the source match table. - /// @retval OT_ERROR_NO_ADDRESS The short address is not in source address match table. - pub fn otPlatRadioClearSrcMatchShortEntry( - aInstance: *mut otInstance, - aShortAddress: otShortAddress, - ) -> otError; + /// @retval OT_ERROR_NONE Successfully freed AES context. + /// @retval OT_ERROR_FAILED Failed to free AES context. + /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + pub fn otPlatCryptoAesFree(aContext: *mut otCryptoContext) -> otError; } unsafe extern "C" { - /// Remove an extended address from the source address match table. + /// Initialise the HKDF context. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aExtAddress The extended address to be removed stored in little-endian byte order. + /// @param[in] aContext Context for HKDF operation. /// - /// @retval OT_ERROR_NONE Successfully removed the extended address from the source match table. - /// @retval OT_ERROR_NO_ADDRESS The extended address is not in source address match table. - pub fn otPlatRadioClearSrcMatchExtEntry( - aInstance: *mut otInstance, - aExtAddress: *const otExtAddress, - ) -> otError; + /// @retval OT_ERROR_NONE Successfully Initialised AES operation. + /// @retval OT_ERROR_FAILED Failed to Initialise AES operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + /// + /// @note The platform driver shall point the context to the correct object such as psa_key_derivation_operation_t + /// or HmacSha256::Hash + pub fn otPlatCryptoHkdfInit(aContext: *mut otCryptoContext) -> otError; } unsafe extern "C" { - /// Clear all short addresses from the source address match table. + /// Perform HKDF Expand step. /// - /// @param[in] aInstance The OpenThread instance structure. - pub fn otPlatRadioClearSrcMatchShortEntries(aInstance: *mut otInstance); + /// @param[in] aContext Operation context for HKDF operation. + /// @param[in] aInfo Pointer to the Info sequence. + /// @param[in] aInfoLength Length of the Info sequence. + /// @param[out] aOutputKey Pointer to the output Key. + /// @param[in] aOutputKeyLength Size of the output key buffer. + /// + /// @retval OT_ERROR_NONE HKDF Expand was successful. + /// @retval OT_ERROR_FAILED HKDF Expand failed. + /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + pub fn otPlatCryptoHkdfExpand( + aContext: *mut otCryptoContext, + aInfo: *const u8, + aInfoLength: u16, + aOutputKey: *mut u8, + aOutputKeyLength: u16, + ) -> otError; } unsafe extern "C" { - /// Clear all the extended/long addresses from source address match table. + /// Perform HKDF Extract step. /// - /// @param[in] aInstance The OpenThread instance structure. - pub fn otPlatRadioClearSrcMatchExtEntries(aInstance: *mut otInstance); + /// @param[in] aContext Operation context for HKDF operation. + /// @param[in] aSalt Pointer to the Salt for HKDF. + /// @param[in] aSaltLength Length of Salt. + /// @param[in] aInputKey Pointer to the input key. + /// + /// @retval OT_ERROR_NONE HKDF Extract was successful. + /// @retval OT_ERROR_FAILED HKDF Extract failed. + pub fn otPlatCryptoHkdfExtract( + aContext: *mut otCryptoContext, + aSalt: *const u8, + aSaltLength: u16, + aInputKey: *const otCryptoKey, + ) -> otError; } unsafe extern "C" { - /// Get the radio supported channel mask that the device is allowed to be on. + /// Uninitialize the HKDF context. /// - /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aContext Context for HKDF operation. /// - /// @returns The radio supported channel mask. - pub fn otPlatRadioGetSupportedChannelMask(aInstance: *mut otInstance) -> u32; + /// @retval OT_ERROR_NONE Successfully un-initialised HKDF operation. + /// @retval OT_ERROR_FAILED Failed to un-initialised HKDF operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + pub fn otPlatCryptoHkdfDeinit(aContext: *mut otCryptoContext) -> otError; } unsafe extern "C" { - /// Gets the radio preferred channel mask that the device prefers to form on. + /// Initialise the SHA-256 operation. /// - /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aContext Context for SHA-256 operation. /// - /// @returns The radio preferred channel mask. - pub fn otPlatRadioGetPreferredChannelMask(aInstance: *mut otInstance) -> u32; + /// @retval OT_ERROR_NONE Successfully initialised SHA-256 operation. + /// @retval OT_ERROR_FAILED Failed to initialise SHA-256 operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + /// + /// + /// @note The platform driver shall point the context to the correct object such as psa_hash_operation_t + /// or mbedtls_sha256_context. + pub fn otPlatCryptoSha256Init(aContext: *mut otCryptoContext) -> otError; } unsafe extern "C" { - /// Enable the radio coex. - /// - /// Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. + /// Uninitialize the SHA-256 operation. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aEnabled TRUE to enable the radio coex, FALSE otherwise. + /// @param[in] aContext Context for SHA-256 operation. /// - /// @retval OT_ERROR_NONE Successfully enabled. - /// @retval OT_ERROR_FAILED The radio coex could not be enabled. - pub fn otPlatRadioSetCoexEnabled(aInstance: *mut otInstance, aEnabled: bool) -> otError; + /// @retval OT_ERROR_NONE Successfully un-initialised SHA-256 operation. + /// @retval OT_ERROR_FAILED Failed to un-initialised SHA-256 operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + pub fn otPlatCryptoSha256Deinit(aContext: *mut otCryptoContext) -> otError; } unsafe extern "C" { - /// Check whether radio coex is enabled or not. - /// - /// Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. + /// Start SHA-256 operation. /// - /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aContext Context for SHA-256 operation. /// - /// @returns TRUE if the radio coex is enabled, FALSE otherwise. - pub fn otPlatRadioIsCoexEnabled(aInstance: *mut otInstance) -> bool; + /// @retval OT_ERROR_NONE Successfully started SHA-256 operation. + /// @retval OT_ERROR_FAILED Failed to start SHA-256 operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + pub fn otPlatCryptoSha256Start(aContext: *mut otCryptoContext) -> otError; } unsafe extern "C" { - /// Get the radio coexistence metrics. - /// - /// Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. + /// Update SHA-256 operation with new input. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[out] aCoexMetrics A pointer to the coexistence metrics structure. + /// @param[in] aContext Context for SHA-256 operation. + /// @param[in] aBuf A pointer to the input buffer. + /// @param[in] aBufLength The length of @p aBuf in bytes. /// - /// @retval OT_ERROR_NONE Successfully retrieved the coex metrics. - /// @retval OT_ERROR_INVALID_ARGS @p aCoexMetrics was NULL. - pub fn otPlatRadioGetCoexMetrics( - aInstance: *mut otInstance, - aCoexMetrics: *mut otRadioCoexMetrics, + /// @retval OT_ERROR_NONE Successfully updated SHA-256 with new input operation. + /// @retval OT_ERROR_FAILED Failed to update SHA-256 operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL + pub fn otPlatCryptoSha256Update( + aContext: *mut otCryptoContext, + aBuf: *const ::core::ffi::c_void, + aBufLength: u16, ) -> otError; } unsafe extern "C" { - /// Enable or disable CSL receiver. - /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aCslPeriod CSL period, 0 for disabling CSL. CSL period is in unit of 10 symbols. - /// @param[in] aShortAddr The short source address of CSL receiver's peer. - /// @param[in] aExtAddr The extended source address of CSL receiver's peer. + /// Finish SHA-256 operation. /// - /// @note Platforms should use CSL peer addresses to include CSL IE when generating enhanced acks. + /// @param[in] aContext Context for SHA-256 operation. + /// @param[in] aHash A pointer to the output buffer, where hash needs to be stored. + /// @param[in] aHashSize The length of @p aHash in bytes. /// - /// @retval OT_ERROR_NOT_IMPLEMENTED Radio driver doesn't support CSL. - /// @retval OT_ERROR_FAILED Other platform specific errors. - /// @retval OT_ERROR_NONE Successfully enabled or disabled CSL. - pub fn otPlatRadioEnableCsl( - aInstance: *mut otInstance, - aCslPeriod: u32, - aShortAddr: otShortAddress, - aExtAddr: *const otExtAddress, + /// @retval OT_ERROR_NONE Successfully completed the SHA-256 operation. + /// @retval OT_ERROR_FAILED Failed to complete SHA-256 operation. + /// @retval OT_ERROR_INVALID_ARGS @p aContext or @p aHash was NULL + pub fn otPlatCryptoSha256Finish( + aContext: *mut otCryptoContext, + aHash: *mut u8, + aHashSize: u16, ) -> otError; } unsafe extern "C" { - /// Reset CSL receiver in the platform. - /// - /// @note Defaults to `otPlatRadioEnableCsl(aInstance,0, Mac::kShortAddrInvalid, nullptr);` - /// - /// @param[in] aInstance The OpenThread instance structure. - /// - /// @retval OT_ERROR_NOT_IMPLEMENTED Radio driver doesn't support CSL. - /// @retval OT_ERROR_FAILED Other platform specific errors. - /// @retval OT_ERROR_NONE Successfully disabled CSL. - pub fn otPlatRadioResetCsl(aInstance: *mut otInstance) -> otError; + /// Initialize cryptographically-secure pseudorandom number generator (CSPRNG). + pub fn otPlatCryptoRandomInit(); } unsafe extern "C" { - /// Update CSL sample time in radio driver. - /// - /// Sample time is stored in radio driver as a copy to calculate phase when - /// sending ACK with CSL IE. The CSL sample (window) of the CSL receiver extends - /// before and after the sample time. The CSL sample time marks a timestamp in - /// the CSL sample window when a frame should be received in "ideal conditions" - /// if there would be no inaccuracy/clock-drift. - /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aCslSampleTime The next sample time, in microseconds. It is - /// the time when the first symbol of the MHR of - /// the frame is expected. - pub fn otPlatRadioUpdateCslSampleTime(aInstance: *mut otInstance, aCslSampleTime: u32); + /// Deinitialize cryptographically-secure pseudorandom number generator (CSPRNG). + pub fn otPlatCryptoRandomDeinit(); } unsafe extern "C" { - /// Get the current estimated worst case accuracy (maximum ± deviation from the - /// nominal frequency) of the local radio clock in units of PPM. This is the - /// clock used to schedule CSL operations. - /// - /// @note Implementations MAY estimate this value based on current operating - /// conditions (e.g. temperature). - /// - /// In case the implementation does not estimate the current value but returns a - /// fixed value, this value MUST be the worst-case accuracy over all possible - /// foreseen operating conditions (temperature, pressure, etc) of the - /// implementation. + /// Fills a given buffer with cryptographically secure random bytes. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aBuffer A pointer to a buffer to fill with the random bytes. + /// @param[in] aSize Size of buffer (number of bytes to fill). /// - /// @returns The current CSL rx/tx scheduling drift, in PPM. - pub fn otPlatRadioGetCslAccuracy(aInstance: *mut otInstance) -> u8; + /// @retval OT_ERROR_NONE Successfully filled buffer with random values. + /// @retval OT_ERROR_FAILED Operation failed. + pub fn otPlatCryptoRandomGet(aBuffer: *mut u8, aSize: u16) -> otError; } unsafe extern "C" { - /// The fixed uncertainty (i.e. random jitter) of the arrival time of CSL - /// transmissions received by this device in units of 10 microseconds. - /// - /// This designates the worst case constant positive or negative deviation of - /// the actual arrival time of a transmission from the transmission time - /// calculated relative to the local radio clock independent of elapsed time. In - /// addition to uncertainty accumulated over elapsed time, the CSL channel sample - /// ("RX window") must be extended by twice this deviation such that an actual - /// transmission is guaranteed to be detected by the local receiver in the - /// presence of random arrival time jitter. + /// Generate and populate the output buffer with a new ECDSA key-pair. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aKeyPair A pointer to an ECDSA key-pair structure to store the generated key-pair. /// - /// @returns The CSL Uncertainty in units of 10 us. - pub fn otPlatRadioGetCslUncertainty(aInstance: *mut otInstance) -> u8; + /// @retval OT_ERROR_NONE A new key-pair was generated successfully. + /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation. + /// @retval OT_ERROR_NOT_CAPABLE Feature not supported. + /// @retval OT_ERROR_FAILED Failed to generate key-pair. + pub fn otPlatCryptoEcdsaGenerateKey(aKeyPair: *mut otPlatCryptoEcdsaKeyPair) -> otError; } unsafe extern "C" { - /// Set the max transmit power for a specific channel. + /// Get the associated public key from the input context. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aChannel The radio channel. - /// @param[in] aMaxPower The max power in dBm, passing OT_RADIO_RSSI_INVALID will disable this channel. + /// @param[in] aKeyPair A pointer to an ECDSA key-pair structure where the key-pair is stored. + /// @param[out] aPublicKey A pointer to an ECDSA public key structure to store the public key. /// - /// @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented - /// @retval OT_ERROR_INVALID_ARGS The specified channel is not valid. - /// @retval OT_ERROR_FAILED Other platform specific errors. - /// @retval OT_ERROR_NONE Successfully set max transmit power. - pub fn otPlatRadioSetChannelMaxTransmitPower( - aInstance: *mut otInstance, - aChannel: u8, - aMaxPower: i8, + /// @retval OT_ERROR_NONE Public key was retrieved successfully, and @p aBuffer is updated. + /// @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). + /// @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. + pub fn otPlatCryptoEcdsaGetPublicKey( + aKeyPair: *const otPlatCryptoEcdsaKeyPair, + aPublicKey: *mut otPlatCryptoEcdsaPublicKey, ) -> otError; } unsafe extern "C" { - /// Set the region code. + /// Calculate the ECDSA signature for a hashed message using the private key from the input context. /// - /// The radio region format is the 2-bytes ascii representation of the - /// ISO 3166 alpha-2 code. + /// Uses the deterministic digital signature generation procedure from RFC 6979. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aRegionCode The radio region code. The `aRegionCode >> 8` is first ascii char - /// and the `aRegionCode & 0xff` is the second ascii char. + /// @param[in] aKeyPair A pointer to an ECDSA key-pair structure where the key-pair is stored. + /// @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature calculation + /// is stored. + /// @param[out] aSignature A pointer to an ECDSA signature structure to output the calculated signature. /// - /// @retval OT_ERROR_FAILED Other platform specific errors. - /// @retval OT_ERROR_NONE Successfully set region code. - /// @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. - pub fn otPlatRadioSetRegion(aInstance: *mut otInstance, aRegionCode: u16) -> otError; + /// @retval OT_ERROR_NONE The signature was calculated successfully, @p aSignature was updated. + /// @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). + /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature calculation. + /// @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. + pub fn otPlatCryptoEcdsaSign( + aKeyPair: *const otPlatCryptoEcdsaKeyPair, + aHash: *const otPlatCryptoSha256Hash, + aSignature: *mut otPlatCryptoEcdsaSignature, + ) -> otError; } unsafe extern "C" { - /// Get the region code. - /// - /// The radio region format is the 2-bytes ascii representation of the - /// ISO 3166 alpha-2 code. + /// Use the key from the input context to verify the ECDSA signature of a hashed message. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[out] aRegionCode The radio region. + /// @param[in] aPublicKey A pointer to an ECDSA public key structure where the public key for signature + /// verification is stored. + /// @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature verification + /// is stored. + /// @param[in] aSignature A pointer to an ECDSA signature structure where the signature value to be verified is + /// stored. /// - /// @retval OT_ERROR_INVALID_ARGS @p aRegionCode is nullptr. - /// @retval OT_ERROR_FAILED Other platform specific errors. - /// @retval OT_ERROR_NONE Successfully got region code. - /// @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. - pub fn otPlatRadioGetRegion(aInstance: *mut otInstance, aRegionCode: *mut u16) -> otError; + /// @retval OT_ERROR_NONE The signature was verified successfully. + /// @retval OT_ERROR_SECURITY The signature is invalid. + /// @retval OT_ERROR_INVALID_ARGS The key or hash is invalid. + /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature verification. + pub fn otPlatCryptoEcdsaVerify( + aPublicKey: *const otPlatCryptoEcdsaPublicKey, + aHash: *const otPlatCryptoSha256Hash, + aSignature: *const otPlatCryptoEcdsaSignature, + ) -> otError; } unsafe extern "C" { - /// Enable/disable or update Enhanced-ACK Based Probing in radio for a specific Initiator. + /// Calculate the ECDSA signature for a hashed message using the Key reference passed. /// - /// After Enhanced-ACK Based Probing is configured by a specific Probing Initiator, the Enhanced-ACK sent to that - /// node should include Vendor-Specific IE containing Link Metrics data. This method informs the radio to start/stop to - /// collect Link Metrics data and include Vendor-Specific IE that containing the data in Enhanced-ACK sent to that - /// Probing Initiator. + /// Uses the deterministic digital signature generation procedure from RFC 6979. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aLinkMetrics This parameter specifies what metrics to query. Per spec 4.11.3.4.4.6, at most 2 metrics - /// can be specified. The probing would be disabled if @p `aLinkMetrics` is bitwise 0. - /// @param[in] aShortAddress The short address of the Probing Initiator. - /// @param[in] aExtAddress The extended source address of the Probing Initiator. @p aExtAddr MUST NOT be `NULL`. + /// @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. + /// @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature calculation + /// is stored. + /// @param[out] aSignature A pointer to an ECDSA signature structure to output the calculated signature. /// - /// @retval OT_ERROR_NONE Successfully configured the Enhanced-ACK Based Probing. - /// @retval OT_ERROR_INVALID_ARGS @p aExtAddress is `NULL`. - /// @retval OT_ERROR_NOT_FOUND The Initiator indicated by @p aShortAddress is not found when trying to clear. - /// @retval OT_ERROR_NO_BUFS No more Initiator can be supported. - /// @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. - pub fn otPlatRadioConfigureEnhAckProbing( - aInstance: *mut otInstance, - aLinkMetrics: otLinkMetrics, - aShortAddress: otShortAddress, - aExtAddress: *const otExtAddress, + /// @retval OT_ERROR_NONE The signature was calculated successfully, @p aSignature was updated. + /// @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). + /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature calculation. + /// @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. + /// + /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + pub fn otPlatCryptoEcdsaSignUsingKeyRef( + aKeyRef: otCryptoKeyRef, + aHash: *const otPlatCryptoSha256Hash, + aSignature: *mut otPlatCryptoEcdsaSignature, ) -> otError; } unsafe extern "C" { - /// Add a calibrated power of the specified channel to the power calibration table. + /// Get the associated public key from the key reference passed. /// - /// @note This API is an optional radio platform API. It's up to the platform layer to implement it. + /// The public key is stored differently depending on the crypto backend library being used + /// (OPENTHREAD_CONFIG_CRYPTO_LIB). /// - /// The @p aActualPower is the actual measured output power when the parameters of the radio hardware modules - /// are set to the @p aRawPowerSetting. + /// This API must make sure to return the public key as a byte sequence representation of an + /// uncompressed curve point (RFC 6605 - sec 4) /// - /// The raw power setting is an opaque byte array. OpenThread doesn't define the format of the raw power setting. - /// Its format is radio hardware related and it should be defined by the developers in the platform radio driver. - /// For example, if the radio hardware contains both the radio chip and the FEM chip, the raw power setting can be - /// a combination of the radio power register and the FEM gain value. + /// @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. + /// @param[out] aPublicKey A pointer to an ECDSA public key structure to store the public key. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aChannel The radio channel. - /// @param[in] aActualPower The actual power in 0.01dBm. - /// @param[in] aRawPowerSetting A pointer to the raw power setting byte array. - /// @param[in] aRawPowerSettingLength The length of the @p aRawPowerSetting. + /// @retval OT_ERROR_NONE Public key was retrieved successfully, and @p aBuffer is updated. + /// @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). + /// @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. /// - /// @retval OT_ERROR_NONE Successfully added the calibrated power to the power calibration table. - /// @retval OT_ERROR_NO_BUFS No available entry in the power calibration table. - /// @retval OT_ERROR_INVALID_ARGS The @p aChannel, @p aActualPower or @p aRawPowerSetting is invalid or the - /// @p aActualPower already exists in the power calibration table. - /// @retval OT_ERROR_NOT_IMPLEMENTED This feature is not implemented. - pub fn otPlatRadioAddCalibratedPower( - aInstance: *mut otInstance, - aChannel: u8, - aActualPower: i16, - aRawPowerSetting: *const u8, - aRawPowerSettingLength: u16, + /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + pub fn otPlatCryptoEcdsaExportPublicKey( + aKeyRef: otCryptoKeyRef, + aPublicKey: *mut otPlatCryptoEcdsaPublicKey, ) -> otError; } unsafe extern "C" { - /// Clear all calibrated powers from the power calibration table. + /// Generate and import a new ECDSA key-pair at reference passed. /// - /// @note This API is an optional radio platform API. It's up to the platform layer to implement it. + /// @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. /// - /// @param[in] aInstance The OpenThread instance structure. + /// @retval OT_ERROR_NONE A new key-pair was generated successfully. + /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation. + /// @retval OT_ERROR_NOT_CAPABLE Feature not supported. + /// @retval OT_ERROR_FAILED Failed to generate key-pair. /// - /// @retval OT_ERROR_NONE Successfully cleared all calibrated powers from the power calibration table. - /// @retval OT_ERROR_NOT_IMPLEMENTED This feature is not implemented. - pub fn otPlatRadioClearCalibratedPowers(aInstance: *mut otInstance) -> otError; + /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + pub fn otPlatCryptoEcdsaGenerateAndImportKey(aKeyRef: otCryptoKeyRef) -> otError; } unsafe extern "C" { - /// Set the target power for the given channel. - /// - /// @note This API is an optional radio platform API. It's up to the platform layer to implement it. - /// If this API is implemented, the function `otPlatRadioSetTransmitPower()` should be disabled. + /// Use the keyref to verify the ECDSA signature of a hashed message. /// - /// The radio driver should set the actual output power to be less than or equal to the @p aTargetPower and as close - /// as possible to the @p aTargetPower. If the @p aTargetPower is lower than the minimum output power supported - /// by the platform, the output power should be set to the minimum output power supported by the platform. If the - /// @p aTargetPower is higher than the maximum output power supported by the platform, the output power should be - /// set to the maximum output power supported by the platform. If the @p aTargetPower is set to `INT16_MAX`, the - /// corresponding channel is disabled. + /// @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. + /// @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature verification + /// is stored. + /// @param[in] aSignature A pointer to an ECDSA signature structure where the signature value to be verified is + /// stored. /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aChannel The radio channel. - /// @param[in] aTargetPower The target power in 0.01dBm. + /// @retval OT_ERROR_NONE The signature was verified successfully. + /// @retval OT_ERROR_SECURITY The signature is invalid. + /// @retval OT_ERROR_INVALID_ARGS The key or hash is invalid. + /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature verification. /// - /// @retval OT_ERROR_NONE Successfully set the target power. - /// @retval OT_ERROR_INVALID_ARGS The @p aChannel is invalid. - /// @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. - pub fn otPlatRadioSetChannelTargetPower( - aInstance: *mut otInstance, - aChannel: u8, - aTargetPower: i16, + /// @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + pub fn otPlatCryptoEcdsaVerifyUsingKeyRef( + aKeyRef: otCryptoKeyRef, + aHash: *const otPlatCryptoSha256Hash, + aSignature: *const otPlatCryptoEcdsaSignature, ) -> otError; } unsafe extern "C" { - /// Get the raw power setting for the given channel. - /// - /// @note OpenThread `src/core/utils` implements a default implementation of the API `otPlatRadioAddCalibratedPower()`, - /// `otPlatRadioClearCalibratedPowers()` and `otPlatRadioSetChannelTargetPower()`. This API is provided by - /// the default implementation to get the raw power setting for the given channel. If the platform doesn't - /// use the default implementation, it can ignore this API. - /// - /// Platform radio layer should parse the raw power setting based on the radio layer defined format and set the - /// parameters of each radio hardware module. + /// Perform PKCS#5 PBKDF2 using CMAC (AES-CMAC-PRF-128). /// - /// @param[in] aInstance The OpenThread instance structure. - /// @param[in] aChannel The radio channel. - /// @param[out] aRawPowerSetting A pointer to the raw power setting byte array. - /// @param[in,out] aRawPowerSettingLength On input, a pointer to the size of @p aRawPowerSetting. - /// On output, a pointer to the length of the raw power setting data. + /// @param[in] aPassword Password to use when generating key. + /// @param[in] aPasswordLen Length of password. + /// @param[in] aSalt Salt to use when generating key. + /// @param[in] aSaltLen Length of salt. + /// @param[in] aIterationCounter Iteration count. + /// @param[in] aKeyLen Length of generated key in bytes. + /// @param[out] aKey A pointer to the generated key. /// - /// @retval OT_ERROR_NONE Successfully got the target power. - /// @retval OT_ERROR_INVALID_ARGS The @p aChannel is invalid, @p aRawPowerSetting or @p aRawPowerSettingLength is NULL - /// or @aRawPowerSettingLength is too short. - /// @retval OT_ERROR_NOT_FOUND The raw power setting for the @p aChannel was not found. - pub fn otPlatRadioGetRawPowerSetting( - aInstance: *mut otInstance, - aChannel: u8, - aRawPowerSetting: *mut u8, - aRawPowerSettingLength: *mut u16, + /// @retval OT_ERROR_NONE A new key-pair was generated successfully. + /// @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation. + /// @retval OT_ERROR_NOT_CAPABLE Feature not supported. + /// @retval OT_ERROR_FAILED Failed to generate key. + pub fn otPlatCryptoPbkdf2GenerateKey( + aPassword: *const u8, + aPasswordLen: u16, + aSalt: *const u8, + aSaltLen: u16, + aIterationCounter: u32, + aKeyLen: u16, + aKey: *mut u8, ) -> otError; } -/// @struct otIp6InterfaceIdentifier +///< aMaxPHYPacketSize (IEEE 802.15.4-2006) +pub const OT_RADIO_FRAME_MAX_SIZE: _bindgen_ty_5 = 127; +///< Minimal size of frame FCS + CONTROL +pub const OT_RADIO_FRAME_MIN_SIZE: _bindgen_ty_5 = 3; +///< 2.4 GHz IEEE 802.15.4-2006 +pub const OT_RADIO_SYMBOLS_PER_OCTET: _bindgen_ty_5 = 2; +///< 2.4 GHz IEEE 802.15.4 (bits per second) +pub const OT_RADIO_BIT_RATE: _bindgen_ty_5 = 250000; +///< Number of bits per octet +pub const OT_RADIO_BITS_PER_OCTET: _bindgen_ty_5 = 8; +///< The O-QPSK PHY symbol rate when operating in the 780MHz, 915MHz, 2380MHz, 2450MHz +pub const OT_RADIO_SYMBOL_RATE: _bindgen_ty_5 = 62500; +///< Symbol duration time in unit of microseconds +pub const OT_RADIO_SYMBOL_TIME: _bindgen_ty_5 = 16; +///< Time for 10 symbols in unit of microseconds +pub const OT_RADIO_TEN_SYMBOLS_TIME: _bindgen_ty_5 = 160; +///< LQI measurement not supported +pub const OT_RADIO_LQI_NONE: _bindgen_ty_5 = 0; +///< Invalid or unknown RSSI value +pub const OT_RADIO_RSSI_INVALID: _bindgen_ty_5 = 127; +///< Invalid or unknown power value +pub const OT_RADIO_POWER_INVALID: _bindgen_ty_5 = 127; +///< Invalid short address. +pub const OT_RADIO_INVALID_SHORT_ADDR: _bindgen_ty_5 = 65534; +///< Broadcast short address. +pub const OT_RADIO_BROADCAST_SHORT_ADDR: _bindgen_ty_5 = 65535; +/// @defgroup radio-types Radio Types /// -/// Represents the Interface Identifier of an IPv6 address. -#[repr(C, packed)] -#[derive(Copy, Clone)] -pub struct otIp6InterfaceIdentifier { - ///< The Interface Identifier accessor fields - pub mFields: otIp6InterfaceIdentifier__bindgen_ty_1, -} +/// @brief +/// This module includes the platform abstraction for a radio frame. +/// +/// @{ +pub type _bindgen_ty_5 = ::core::ffi::c_uint; +///< 2.4 GHz IEEE 802.15.4-2006 +pub const OT_RADIO_CHANNEL_PAGE_0: _bindgen_ty_6 = 0; +///< 2.4 GHz IEEE 802.15.4-2006 +pub const OT_RADIO_CHANNEL_PAGE_0_MASK: _bindgen_ty_6 = 1; +///< 915 MHz IEEE 802.15.4-2006 +pub const OT_RADIO_CHANNEL_PAGE_2: _bindgen_ty_6 = 2; +///< 915 MHz IEEE 802.15.4-2006 +pub const OT_RADIO_CHANNEL_PAGE_2_MASK: _bindgen_ty_6 = 4; +/// Defines the channel page. +pub type _bindgen_ty_6 = ::core::ffi::c_uint; +///< 915 MHz IEEE 802.15.4-2006 +pub const OT_RADIO_915MHZ_OQPSK_CHANNEL_MIN: _bindgen_ty_7 = 1; +///< 915 MHz IEEE 802.15.4-2006 +pub const OT_RADIO_915MHZ_OQPSK_CHANNEL_MAX: _bindgen_ty_7 = 10; +///< 915 MHz IEEE 802.15.4-2006 +pub const OT_RADIO_915MHZ_OQPSK_CHANNEL_MASK: _bindgen_ty_7 = 2046; +///< 2.4 GHz IEEE 802.15.4-2006 +pub const OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MIN: _bindgen_ty_7 = 11; +///< 2.4 GHz IEEE 802.15.4-2006 +pub const OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MAX: _bindgen_ty_7 = 26; +///< 2.4 GHz IEEE 802.15.4-2006 +pub const OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MASK: _bindgen_ty_7 = 134215680; +/// Defines the frequency band channel range. +pub type _bindgen_ty_7 = ::core::ffi::c_uint; +/// Represents radio capabilities. +/// +/// The value is a bit-field indicating the capabilities supported by the radio. See `OT_RADIO_CAPS_*` definitions. +pub type otRadioCaps = u16; +///< Radio supports no capability. +pub const OT_RADIO_CAPS_NONE: _bindgen_ty_8 = 0; +///< Radio supports AckTime event. +pub const OT_RADIO_CAPS_ACK_TIMEOUT: _bindgen_ty_8 = 1; +///< Radio supports Energy Scans. +pub const OT_RADIO_CAPS_ENERGY_SCAN: _bindgen_ty_8 = 2; +///< Radio supports tx retry logic with collision avoidance (CSMA). +pub const OT_RADIO_CAPS_TRANSMIT_RETRIES: _bindgen_ty_8 = 4; +///< Radio supports CSMA backoff for frame tx (but no retry). +pub const OT_RADIO_CAPS_CSMA_BACKOFF: _bindgen_ty_8 = 8; +///< Radio supports direct transition from sleep to TX with CSMA. +pub const OT_RADIO_CAPS_SLEEP_TO_TX: _bindgen_ty_8 = 16; +///< Radio supports tx security. +pub const OT_RADIO_CAPS_TRANSMIT_SEC: _bindgen_ty_8 = 32; +///< Radio supports tx at specific time. +pub const OT_RADIO_CAPS_TRANSMIT_TIMING: _bindgen_ty_8 = 64; +///< Radio supports rx at specific time. +pub const OT_RADIO_CAPS_RECEIVE_TIMING: _bindgen_ty_8 = 128; +///< Radio supports RxOnWhenIdle handling. +pub const OT_RADIO_CAPS_RX_ON_WHEN_IDLE: _bindgen_ty_8 = 256; +///< Radio supports setting per-frame transmit power. +pub const OT_RADIO_CAPS_TRANSMIT_FRAME_POWER: _bindgen_ty_8 = 512; +///< Radio supports setting alternate short address. +pub const OT_RADIO_CAPS_ALT_SHORT_ADDR: _bindgen_ty_8 = 1024; +/// Defines constants that are used to indicate different radio capabilities. See `otRadioCaps`. +pub type _bindgen_ty_8 = ::core::ffi::c_uint; +/// Represents the IEEE 802.15.4 PAN ID. +pub type otPanId = u16; +/// Represents the IEEE 802.15.4 Short Address. +pub type otShortAddress = u16; +///< Size of IE header in bytes. +pub const OT_IE_HEADER_SIZE: _bindgen_ty_9 = 2; +///< Size of CSL IE content in bytes. +pub const OT_CSL_IE_SIZE: _bindgen_ty_9 = 4; +///< Max length for header IE in ACK. +pub const OT_ACK_IE_MAX_SIZE: _bindgen_ty_9 = 16; +///< Max length of Link Metrics data in Vendor-Specific IE. +pub const OT_ENH_PROBING_IE_DATA_MAX_SIZE: _bindgen_ty_9 = 2; +/// Defines constants about size of header IE in ACK. +pub type _bindgen_ty_9 = ::core::ffi::c_uint; +/// @struct otExtAddress +/// +/// Represents the IEEE 802.15.4 Extended Address. #[repr(C, packed)] -#[derive(Copy, Clone)] -pub union otIp6InterfaceIdentifier__bindgen_ty_1 { - ///< 8-bit fields +#[derive(Default, Copy, Clone)] +pub struct otExtAddress { + ///< IEEE 802.15.4 Extended Address bytes pub m8: [u8; 8usize], - ///< 16-bit fields - pub m16: [u16; 4usize], - ///< 32-bit fields - pub m32: [u32; 2usize], } -/// @struct otIp6NetworkPrefix +/// @struct otMacKey /// -/// Represents the Network Prefix of an IPv6 address (most significant 64 bits of the address). +/// Represents a MAC Key. #[repr(C, packed)] -#[derive(Copy, Clone)] -pub struct otIp6NetworkPrefix { - ///< The Network Prefix. - pub m8: [u8; 8usize], +#[derive(Default, Copy, Clone)] +pub struct otMacKey { + ///< MAC Key bytes. + pub m8: [u8; 16usize], } -/// @struct otIp6AddressComponents +/// Represents a MAC Key Ref used by PSA. +pub type otMacKeyRef = otCryptoKeyRef; +/// @struct otMacKeyMaterial /// -/// Represents the components of an IPv6 address. -#[repr(C, packed)] +/// Represents a MAC Key. +#[repr(C)] #[derive(Copy, Clone)] -pub struct otIp6AddressComponents { - ///< The Network Prefix (most significant 64 bits of the address) - pub mNetworkPrefix: otIp6NetworkPrefix, - ///< The Interface Identifier (least significant 64 bits of the address) - pub mIid: otIp6InterfaceIdentifier, +pub struct otMacKeyMaterial { + pub mKeyMaterial: otMacKeyMaterial__bindgen_ty_1, } -/// @struct otIp6Address -/// -/// Represents an IPv6 address. -#[repr(C, packed)] +#[repr(C)] #[derive(Copy, Clone)] -pub struct otIp6Address { - ///< IPv6 accessor fields - pub mFields: otIp6Address__bindgen_ty_1, +pub union otMacKeyMaterial__bindgen_ty_1 { + ///< Reference to the key stored. + pub mKeyRef: otMacKeyRef, + ///< Key stored as literal. + pub mKey: otMacKey, +} +impl Default for otMacKeyMaterial__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl Default for otMacKeyMaterial { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -#[repr(C, packed)] +///< Use Literal Keys. +pub const otRadioKeyType_OT_KEY_TYPE_LITERAL_KEY: otRadioKeyType = 0; +///< Use Reference to Key. +pub const otRadioKeyType_OT_KEY_TYPE_KEY_REF: otRadioKeyType = 1; +/// Defines constants about key types. +pub type otRadioKeyType = ::core::ffi::c_uint; +/// Represents the IEEE 802.15.4 Header IE (Information Element) related information of a radio frame. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otRadioIeInfo { + ///< The time offset to the Thread network time. + pub mNetworkTimeOffset: i64, + ///< The Time IE offset from the start of PSDU. + pub mTimeIeOffset: u8, + ///< The Time sync sequence. + pub mTimeSyncSeq: u8, +} +/// Represents an IEEE 802.15.4 radio frame. +#[repr(C)] #[derive(Copy, Clone)] -pub union otIp6Address__bindgen_ty_1 { - ///< 8-bit fields - pub m8: [u8; 16usize], - ///< 16-bit fields - pub m16: [u16; 8usize], - ///< 32-bit fields - pub m32: [u32; 4usize], - ///< IPv6 address components - pub mComponents: otIp6AddressComponents, +pub struct otRadioFrame { + ///< The PSDU. + pub mPsdu: *mut u8, + ///< Length of the PSDU. + pub mLength: u16, + ///< Channel used to transmit/receive the frame. + pub mChannel: u8, + ///< Radio link type - should be ignored by radio driver. + pub mRadioType: u8, + pub mInfo: otRadioFrame__bindgen_ty_1, } -/// @struct otIp6Prefix -/// -/// Represents an IPv6 prefix. -#[repr(C, packed)] +/// The union of transmit and receive information for a radio frame. +#[repr(C)] #[derive(Copy, Clone)] -pub struct otIp6Prefix { - ///< The IPv6 prefix. - pub mPrefix: otIp6Address, - ///< The IPv6 prefix length (in bits). - pub mLength: u8, +pub union otRadioFrame__bindgen_ty_1 { + pub mTxInfo: otRadioFrame__bindgen_ty_1__bindgen_ty_1, + pub mRxInfo: otRadioFrame__bindgen_ty_1__bindgen_ty_2, } -///< Thread assigned address (ALOC, RLOC, MLEID, etc) -pub const OT_ADDRESS_ORIGIN_THREAD: _bindgen_ty_7 = 0; -///< SLAAC assigned address -pub const OT_ADDRESS_ORIGIN_SLAAC: _bindgen_ty_7 = 1; -///< DHCPv6 assigned address -pub const OT_ADDRESS_ORIGIN_DHCPV6: _bindgen_ty_7 = 2; -///< Manually assigned address -pub const OT_ADDRESS_ORIGIN_MANUAL: _bindgen_ty_7 = 3; -/// IPv6 Address origins -pub type _bindgen_ty_7 = ::core::ffi::c_uint; -/// Represents an IPv6 network interface unicast address. +/// Structure representing radio frame transmit information. #[repr(C)] #[derive(Copy, Clone)] -pub struct otNetifAddress { - ///< The IPv6 unicast address. - pub mAddress: otIp6Address, - ///< The Prefix length (in bits). - pub mPrefixLength: u8, - ///< The IPv6 address origin. - pub mAddressOrigin: u8, +pub struct otRadioFrame__bindgen_ty_1__bindgen_ty_1 { + ///< The key material used for AES-CCM frame security. + pub mAesKey: *const otMacKeyMaterial, + ///< The pointer to the Header IE(s) related information. + pub mIeInfo: *mut otRadioIeInfo, + /// The base time in microseconds for scheduled transmissions + /// relative to the local radio clock, see `otPlatRadioGetNow` and + /// `mTxDelay`. + /// + /// If this field is non-zero, `mMaxCsmaBackoffs` should be ignored. + /// + /// This field does not affect CCA behavior which is controlled by `mCsmaCaEnabled`. + pub mTxDelayBaseTime: u32, + /// The delay time in microseconds for this transmission referenced + /// to `mTxDelayBaseTime`. + /// + /// Note: `mTxDelayBaseTime` + `mTxDelay` SHALL point to the point in + /// time when the end of the SFD will be present at the local + /// antenna, relative to the local radio clock. + /// + /// If this field is non-zero, `mMaxCsmaBackoffs` should be ignored. + /// + /// This field does not affect CCA behavior which is controlled by `mCsmaCaEnabled`. + pub mTxDelay: u32, + /// Maximum number of CSMA backoff attempts before declaring channel access failure. + /// + /// This is applicable and MUST be used when radio platform provides the `OT_RADIO_CAPS_CSMA_BACKOFF` and/or + /// `OT_RADIO_CAPS_TRANSMIT_RETRIES`. + /// + /// This field MUST be ignored if `mCsmaCaEnabled` is set to `false` (CCA is disabled) or + /// either `mTxDelayBaseTime` or `mTxDelay` is non-zero (frame transmission is expected at a specific time). + /// + /// It can be set to `0` to skip backoff mechanism (note that CCA MUST still be performed assuming + /// `mCsmaCaEnabled` is `true`). + pub mMaxCsmaBackoffs: u8, + ///< Maximum number of retries allowed after a transmission failure. + pub mMaxFrameRetries: u8, + /// The RX channel after frame TX is done (after all frame retries - ack received, or timeout, or abort). + /// + /// Radio platforms can choose to fully ignore this. OT stack will make sure to call `otPlatRadioReceive()` + /// with the desired RX channel after a frame TX is done and signaled in `otPlatRadioTxDone()` callback. + /// Radio platforms that don't provide `OT_RADIO_CAPS_TRANSMIT_RETRIES` must always ignore this. + /// + /// This is intended for situations where there may be delay in interactions between OT stack and radio, as + /// an example this is used in RCP/host architecture to make sure RCP switches to PAN channel more quickly. + /// In particular, this can help with CSL tx to a sleepy child, where the child may use a different channel + /// for CSL than the PAN channel. After frame tx, we want the radio/RCP to go back to the PAN channel + /// quickly to ensure that parent does not miss tx from child afterwards, e.g., child responding to the + /// earlier CSL transmitted frame from parent using PAN channel while radio still staying on CSL channel. + /// + /// The switch to the RX channel MUST happen after the frame TX is fully done, i.e., after all retries and + /// when ack is received (when "Ack Request" flag is set on the TX frame) or ack timeout. Note that ack is + /// expected on the same channel that frame is sent on. + pub mRxChannelAfterTxDone: u8, + /// The transmit power in dBm. + /// + /// If the platform layer does not provide `OT_RADIO_CAPS_TRANSMIT_FRAME_POWER` capability, it can ignore + /// this value. + /// + /// If the value is OT_RADIO_POWER_INVALID, then the platform should ignore this value and transmit the frame + /// with its default transmit power. + /// + /// Otherwise, the platform should transmit this frame with the maximum power no larger than minimal of the + /// following values: + /// 1. mTxPower, + /// 2. The power limit set by otPlatRadioSetChannelTargetPower(), + /// 3. The power limit set by otPlatRadioSetChannelMaxTransmitPower(), + /// 4. The power limit set by otPlatRadioSetRegion(). + pub mTxPower: i8, pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, - ///< A pointer to the next network interface address. - pub mNext: *const otNetifAddress, + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + /// The time of the local radio clock in microseconds when the end of + /// the SFD was present at the local antenna. + /// + /// The platform should update this field before otPlatRadioTxStarted() is fired for each transmit attempt. + pub mTimestamp: u64, } -impl otNetifAddress { +impl Default for otRadioFrame__bindgen_ty_1__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl otRadioFrame__bindgen_ty_1__bindgen_ty_1 { #[inline] - pub fn mPreferred(&self) -> bool { + pub fn mIsHeaderUpdated(&self) -> bool { unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } } #[inline] - pub fn set_mPreferred(&mut self, val: bool) { + pub fn set_mIsHeaderUpdated(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(0usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mPreferred_raw(this: *const Self) -> bool { + pub unsafe fn mIsHeaderUpdated_raw(this: *const Self) -> bool { unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), 0usize, 1u8, @@ -4623,10 +3772,10 @@ impl otNetifAddress { } } #[inline] - pub unsafe fn set_mPreferred_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mIsHeaderUpdated_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), 0usize, 1u8, @@ -4635,20 +3784,20 @@ impl otNetifAddress { } } #[inline] - pub fn mValid(&self) -> bool { + pub fn mIsARetx(&self) -> bool { unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } } #[inline] - pub fn set_mValid(&mut self, val: bool) { + pub fn set_mIsARetx(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(1usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mValid_raw(this: *const Self) -> bool { + pub unsafe fn mIsARetx_raw(this: *const Self) -> bool { unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), 1usize, 1u8, @@ -4656,10 +3805,10 @@ impl otNetifAddress { } } #[inline] - pub unsafe fn set_mValid_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mIsARetx_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), 1usize, 1u8, @@ -4668,20 +3817,20 @@ impl otNetifAddress { } } #[inline] - pub fn mScopeOverrideValid(&self) -> bool { + pub fn mCsmaCaEnabled(&self) -> bool { unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } } #[inline] - pub fn set_mScopeOverrideValid(&mut self, val: bool) { + pub fn set_mCsmaCaEnabled(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(2usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mScopeOverrideValid_raw(this: *const Self) -> bool { + pub unsafe fn mCsmaCaEnabled_raw(this: *const Self) -> bool { unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), 2usize, 1u8, @@ -4689,10 +3838,10 @@ impl otNetifAddress { } } #[inline] - pub unsafe fn set_mScopeOverrideValid_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mCsmaCaEnabled_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), 2usize, 1u8, @@ -4701,132 +3850,66 @@ impl otNetifAddress { } } #[inline] - pub fn mScopeOverride(&self) -> ::core::ffi::c_uint { - unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 4u8) as u32) } - } - #[inline] - pub fn set_mScopeOverride(&mut self, val: ::core::ffi::c_uint) { - unsafe { - let val: u32 = ::core::mem::transmute(val); - self._bitfield_1.set(3usize, 4u8, val as u64) - } - } - #[inline] - pub unsafe fn mScopeOverride_raw(this: *const Self) -> ::core::ffi::c_uint { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 3usize, - 4u8, - ) as u32) - } - } - #[inline] - pub unsafe fn set_mScopeOverride_raw(this: *mut Self, val: ::core::ffi::c_uint) { - unsafe { - let val: u32 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 3usize, - 4u8, - val as u64, - ) - } - } - #[inline] - pub fn mRloc(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u8) } - } - #[inline] - pub fn set_mRloc(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(7usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mRloc_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 7usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mRloc_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 7usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn mMeshLocal(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u8) } + pub fn mCslPresent(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } } #[inline] - pub fn set_mMeshLocal(&mut self, val: bool) { + pub fn set_mCslPresent(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(8usize, 1u8, val as u64) + self._bitfield_1.set(3usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mMeshLocal_raw(this: *const Self) -> bool { + pub unsafe fn mCslPresent_raw(this: *const Self) -> bool { unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 8usize, + 3usize, 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mMeshLocal_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mCslPresent_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 8usize, + 3usize, 1u8, val as u64, ) } } #[inline] - pub fn mSrpRegistered(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u8) } + pub fn mIsSecurityProcessed(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } } #[inline] - pub fn set_mSrpRegistered(&mut self, val: bool) { + pub fn set_mIsSecurityProcessed(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(9usize, 1u8, val as u64) + self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mSrpRegistered_raw(this: *const Self) -> bool { + pub unsafe fn mIsSecurityProcessed_raw(this: *const Self) -> bool { unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 9usize, + 4usize, 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mSrpRegistered_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mIsSecurityProcessed_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 9usize, + 4usize, 1u8, val as u64, ) @@ -4834,564 +3917,376 @@ impl otNetifAddress { } #[inline] pub fn new_bitfield_1( - mPreferred: bool, - mValid: bool, - mScopeOverrideValid: bool, - mScopeOverride: ::core::ffi::c_uint, - mRloc: bool, - mMeshLocal: bool, - mSrpRegistered: bool, - ) -> __BindgenBitfieldUnit<[u8; 2usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + mIsHeaderUpdated: bool, + mIsARetx: bool, + mCsmaCaEnabled: bool, + mCslPresent: bool, + mIsSecurityProcessed: bool, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let mPreferred: u8 = unsafe { ::core::mem::transmute(mPreferred) }; - mPreferred as u64 + let mIsHeaderUpdated: u8 = unsafe { ::core::mem::transmute(mIsHeaderUpdated) }; + mIsHeaderUpdated as u64 }); __bindgen_bitfield_unit.set(1usize, 1u8, { - let mValid: u8 = unsafe { ::core::mem::transmute(mValid) }; - mValid as u64 + let mIsARetx: u8 = unsafe { ::core::mem::transmute(mIsARetx) }; + mIsARetx as u64 }); __bindgen_bitfield_unit.set(2usize, 1u8, { - let mScopeOverrideValid: u8 = unsafe { ::core::mem::transmute(mScopeOverrideValid) }; - mScopeOverrideValid as u64 - }); - __bindgen_bitfield_unit.set(3usize, 4u8, { - let mScopeOverride: u32 = unsafe { ::core::mem::transmute(mScopeOverride) }; - mScopeOverride as u64 - }); - __bindgen_bitfield_unit.set(7usize, 1u8, { - let mRloc: u8 = unsafe { ::core::mem::transmute(mRloc) }; - mRloc as u64 + let mCsmaCaEnabled: u8 = unsafe { ::core::mem::transmute(mCsmaCaEnabled) }; + mCsmaCaEnabled as u64 }); - __bindgen_bitfield_unit.set(8usize, 1u8, { - let mMeshLocal: u8 = unsafe { ::core::mem::transmute(mMeshLocal) }; - mMeshLocal as u64 + __bindgen_bitfield_unit.set(3usize, 1u8, { + let mCslPresent: u8 = unsafe { ::core::mem::transmute(mCslPresent) }; + mCslPresent as u64 }); - __bindgen_bitfield_unit.set(9usize, 1u8, { - let mSrpRegistered: u8 = unsafe { ::core::mem::transmute(mSrpRegistered) }; - mSrpRegistered as u64 + __bindgen_bitfield_unit.set(4usize, 1u8, { + let mIsSecurityProcessed: u8 = unsafe { ::core::mem::transmute(mIsSecurityProcessed) }; + mIsSecurityProcessed as u64 }); __bindgen_bitfield_unit } } -/// Represents an IPv6 network interface multicast address. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otNetifMulticastAddress { - ///< The IPv6 multicast address. - pub mAddress: otIp6Address, - ///< A pointer to the next network interface multicast address. - pub mNext: *const otNetifMulticastAddress, -} -/// Represents an IPv6 socket address. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otSockAddr { - ///< An IPv6 address. - pub mAddress: otIp6Address, - ///< A transport-layer port. - pub mPort: u16, -} -///< Non-ECT -pub const OT_ECN_NOT_CAPABLE: _bindgen_ty_8 = 0; -///< ECT(0) -pub const OT_ECN_CAPABLE_0: _bindgen_ty_8 = 2; -///< ECT(1) -pub const OT_ECN_CAPABLE_1: _bindgen_ty_8 = 1; -///< Congestion encountered (CE) -pub const OT_ECN_MARKED: _bindgen_ty_8 = 3; -/// ECN statuses, represented as in the IP header. -pub type _bindgen_ty_8 = ::core::ffi::c_uint; -/// Represents the local and peer IPv6 socket addresses. +/// Structure representing radio frame receive information. #[repr(C)] -#[derive(Copy, Clone)] -pub struct otMessageInfo { - ///< The local IPv6 address. - pub mSockAddr: otIp6Address, - ///< The peer IPv6 address. - pub mPeerAddr: otIp6Address, - ///< The local transport-layer port. - pub mSockPort: u16, - ///< The peer transport-layer port. - pub mPeerPort: u16, - ///< The IPv6 Hop Limit value. Only applies if `mAllowZeroHopLimit` is FALSE. - ///< If `0`, IPv6 Hop Limit is default value `OPENTHREAD_CONFIG_IP6_HOP_LIMIT_DEFAULT`. - ///< Otherwise, specifies the IPv6 Hop Limit. - pub mHopLimit: u8, +#[derive(Default, Copy, Clone)] +pub struct otRadioFrame__bindgen_ty_1__bindgen_ty_2 { + /// The time of the local radio clock in microseconds when the end of + /// the SFD was present at the local antenna. + pub mTimestamp: u64, + ///< ACK security frame counter (applicable when `mAckedWithSecEnhAck` is set). + pub mAckFrameCounter: u32, + ///< ACK security key index (applicable when `mAckedWithSecEnhAck` is set). + pub mAckKeyId: u8, + ///< Received signal strength indicator in dBm for received frames. + pub mRssi: i8, + ///< Link Quality Indicator for received frames. + pub mLqi: u8, pub _bitfield_align_1: [u8; 0], pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, } -impl otMessageInfo { +impl otRadioFrame__bindgen_ty_1__bindgen_ty_2 { #[inline] - pub fn mEcn(&self) -> u8 { - unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u8) } + pub fn mAckedWithFramePending(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } } #[inline] - pub fn set_mEcn(&mut self, val: u8) { + pub fn set_mAckedWithFramePending(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(0usize, 2u8, val as u64) + self._bitfield_1.set(0usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mEcn_raw(this: *const Self) -> u8 { + pub unsafe fn mAckedWithFramePending_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), 0usize, - 2u8, + 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mEcn_raw(this: *mut Self, val: u8) { + pub unsafe fn set_mAckedWithFramePending_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), 0usize, - 2u8, + 1u8, val as u64, ) } } #[inline] - pub fn mIsHostInterface(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + pub fn mAckedWithSecEnhAck(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } } #[inline] - pub fn set_mIsHostInterface(&mut self, val: bool) { + pub fn set_mAckedWithSecEnhAck(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(2usize, 1u8, val as u64) + self._bitfield_1.set(1usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mIsHostInterface_raw(this: *const Self) -> bool { + pub unsafe fn mAckedWithSecEnhAck_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 2usize, + 1usize, 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mIsHostInterface_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mAckedWithSecEnhAck_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 2usize, + 1usize, 1u8, val as u64, ) } } #[inline] - pub fn mAllowZeroHopLimit(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } - } - #[inline] - pub fn set_mAllowZeroHopLimit(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(3usize, 1u8, val as u64) - } + pub fn new_bitfield_1( + mAckedWithFramePending: bool, + mAckedWithSecEnhAck: bool, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let mAckedWithFramePending: u8 = + unsafe { ::core::mem::transmute(mAckedWithFramePending) }; + mAckedWithFramePending as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mAckedWithSecEnhAck: u8 = unsafe { ::core::mem::transmute(mAckedWithSecEnhAck) }; + mAckedWithSecEnhAck as u64 + }); + __bindgen_bitfield_unit } - #[inline] - pub unsafe fn mAllowZeroHopLimit_raw(this: *const Self) -> bool { +} +impl Default for otRadioFrame__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 3usize, - 1u8, - ) as u8) + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() } } - #[inline] - pub unsafe fn set_mAllowZeroHopLimit_raw(this: *mut Self, val: bool) { +} +impl Default for otRadioFrame { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 3usize, - 1u8, - val as u64, - ) + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() } } +} +pub const otRadioState_OT_RADIO_STATE_DISABLED: otRadioState = 0; +pub const otRadioState_OT_RADIO_STATE_SLEEP: otRadioState = 1; +pub const otRadioState_OT_RADIO_STATE_RECEIVE: otRadioState = 2; +pub const otRadioState_OT_RADIO_STATE_TRANSMIT: otRadioState = 3; +pub const otRadioState_OT_RADIO_STATE_INVALID: otRadioState = 255; +/// Represents the state of a radio. +/// Initially, a radio is in the Disabled state. +pub type otRadioState = ::core::ffi::c_uint; +/// Represents radio coexistence metrics. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otRadioCoexMetrics { + ///< Number of grant glitches. + pub mNumGrantGlitch: u32, + ///< Number of tx requests. + pub mNumTxRequest: u32, + ///< Number of tx requests while grant was active. + pub mNumTxGrantImmediate: u32, + ///< Number of tx requests while grant was inactive. + pub mNumTxGrantWait: u32, + ///< Number of tx requests while grant was inactive that were ultimately granted. + pub mNumTxGrantWaitActivated: u32, + ///< Number of tx requests while grant was inactive that timed out. + pub mNumTxGrantWaitTimeout: u32, + ///< Number of tx that were in progress when grant was deactivated. + pub mNumTxGrantDeactivatedDuringRequest: u32, + ///< Number of tx requests that were not granted within 50us. + pub mNumTxDelayedGrant: u32, + ///< Average time in usec from tx request to grant. + pub mAvgTxRequestToGrantTime: u32, + ///< Number of rx requests. + pub mNumRxRequest: u32, + ///< Number of rx requests while grant was active. + pub mNumRxGrantImmediate: u32, + ///< Number of rx requests while grant was inactive. + pub mNumRxGrantWait: u32, + ///< Number of rx requests while grant was inactive that were ultimately granted. + pub mNumRxGrantWaitActivated: u32, + ///< Number of rx requests while grant was inactive that timed out. + pub mNumRxGrantWaitTimeout: u32, + ///< Number of rx that were in progress when grant was deactivated. + pub mNumRxGrantDeactivatedDuringRequest: u32, + ///< Number of rx requests that were not granted within 50us. + pub mNumRxDelayedGrant: u32, + ///< Average time in usec from rx request to grant. + pub mAvgRxRequestToGrantTime: u32, + ///< Number of rx requests that completed without receiving grant. + pub mNumRxGrantNone: u32, + ///< Stats collection stopped due to saturation. + pub mStopped: bool, +} +/// Represents what metrics are specified to query. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otLinkMetrics { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl otLinkMetrics { #[inline] - pub fn mMulticastLoop(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + pub fn mPduCount(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } } #[inline] - pub fn set_mMulticastLoop(&mut self, val: bool) { + pub fn set_mPduCount(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(4usize, 1u8, val as u64) + self._bitfield_1.set(0usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mMulticastLoop_raw(this: *const Self) -> bool { + pub unsafe fn mPduCount_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 4usize, + 0usize, 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mMulticastLoop_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mPduCount_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 4usize, + 0usize, 1u8, val as u64, ) } } #[inline] - pub fn new_bitfield_1( - mEcn: u8, - mIsHostInterface: bool, - mAllowZeroHopLimit: bool, - mMulticastLoop: bool, - ) -> __BindgenBitfieldUnit<[u8; 1usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); - __bindgen_bitfield_unit.set(0usize, 2u8, { - let mEcn: u8 = unsafe { ::core::mem::transmute(mEcn) }; - mEcn as u64 - }); - __bindgen_bitfield_unit.set(2usize, 1u8, { - let mIsHostInterface: u8 = unsafe { ::core::mem::transmute(mIsHostInterface) }; - mIsHostInterface as u64 - }); - __bindgen_bitfield_unit.set(3usize, 1u8, { - let mAllowZeroHopLimit: u8 = unsafe { ::core::mem::transmute(mAllowZeroHopLimit) }; - mAllowZeroHopLimit as u64 - }); - __bindgen_bitfield_unit.set(4usize, 1u8, { - let mMulticastLoop: u8 = unsafe { ::core::mem::transmute(mMulticastLoop) }; - mMulticastLoop as u64 - }); - __bindgen_bitfield_unit + pub fn mLqi(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mLqi(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } } -} -///< IPv6 Hop-by-Hop Option -pub const OT_IP6_PROTO_HOP_OPTS: _bindgen_ty_9 = 0; -///< Transmission Control Protocol -pub const OT_IP6_PROTO_TCP: _bindgen_ty_9 = 6; -///< User Datagram -pub const OT_IP6_PROTO_UDP: _bindgen_ty_9 = 17; -///< IPv6 encapsulation -pub const OT_IP6_PROTO_IP6: _bindgen_ty_9 = 41; -///< Routing Header for IPv6 -pub const OT_IP6_PROTO_ROUTING: _bindgen_ty_9 = 43; -///< Fragment Header for IPv6 -pub const OT_IP6_PROTO_FRAGMENT: _bindgen_ty_9 = 44; -///< ICMP for IPv6 -pub const OT_IP6_PROTO_ICMP6: _bindgen_ty_9 = 58; -///< No Next Header for IPv6 -pub const OT_IP6_PROTO_NONE: _bindgen_ty_9 = 59; -///< Destination Options for IPv6 -pub const OT_IP6_PROTO_DST_OPTS: _bindgen_ty_9 = 60; -/// Internet Protocol Numbers. -pub type _bindgen_ty_9 = ::core::ffi::c_uint; -unsafe extern "C" { - /// Brings the IPv6 interface up or down. - /// - /// Call this to enable or disable IPv6 communication. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aEnabled TRUE to enable IPv6, FALSE otherwise. - /// - /// @retval OT_ERROR_NONE Successfully brought the IPv6 interface up/down. - /// @retval OT_ERROR_INVALID_STATE IPv6 interface is not available since device is operating in raw-link mode - /// (applicable only when `OPENTHREAD_CONFIG_LINK_RAW_ENABLE` feature is enabled). - pub fn otIp6SetEnabled(aInstance: *mut otInstance, aEnabled: bool) -> otError; -} -unsafe extern "C" { - /// Indicates whether or not the IPv6 interface is up. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @retval TRUE The IPv6 interface is enabled. - /// @retval FALSE The IPv6 interface is disabled. - pub fn otIp6IsEnabled(aInstance: *mut otInstance) -> bool; -} -unsafe extern "C" { - /// Adds a Network Interface Address to the Thread interface. - /// - /// The passed-in instance @p aAddress is copied by the Thread interface. The Thread interface only - /// supports a fixed number of externally added unicast addresses. See `OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS`. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aAddress A pointer to a Network Interface Address. - /// - /// @retval OT_ERROR_NONE Successfully added (or updated) the Network Interface Address. - /// @retval OT_ERROR_INVALID_ARGS The IP Address indicated by @p aAddress is an internal address. - /// @retval OT_ERROR_NO_BUFS The Network Interface is already storing the maximum allowed external addresses. - pub fn otIp6AddUnicastAddress( - aInstance: *mut otInstance, - aAddress: *const otNetifAddress, - ) -> otError; -} -unsafe extern "C" { - /// Removes a Network Interface Address from the Thread interface. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aAddress A pointer to an IP Address. - /// - /// @retval OT_ERROR_NONE Successfully removed the Network Interface Address. - /// @retval OT_ERROR_INVALID_ARGS The IP Address indicated by @p aAddress is an internal address. - /// @retval OT_ERROR_NOT_FOUND The IP Address indicated by @p aAddress was not found. - pub fn otIp6RemoveUnicastAddress( - aInstance: *mut otInstance, - aAddress: *const otIp6Address, - ) -> otError; -} -unsafe extern "C" { - /// Gets the list of IPv6 addresses assigned to the Thread interface. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @returns A pointer to the first Network Interface Address. - pub fn otIp6GetUnicastAddresses(aInstance: *mut otInstance) -> *const otNetifAddress; -} -unsafe extern "C" { - /// Indicates whether or not a unicast IPv6 address is assigned to the Thread interface. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aAddress A pointer to the unicast address. - /// - /// @retval TRUE If @p aAddress is assigned to the Thread interface. - /// @retval FALSE If @p aAddress is not assigned to the Thread interface. - pub fn otIp6HasUnicastAddress( - aInstance: *mut otInstance, - aAddress: *const otIp6Address, - ) -> bool; -} -unsafe extern "C" { - /// Subscribes the Thread interface to a Network Interface Multicast Address. - /// - /// The passed in instance @p aAddress will be copied by the Thread interface. The Thread interface only - /// supports a fixed number of externally added multicast addresses. See `OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS`. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aAddress A pointer to an IP Address. - /// - /// @retval OT_ERROR_NONE Successfully subscribed to the Network Interface Multicast Address. - /// @retval OT_ERROR_ALREADY The multicast address is already subscribed. - /// @retval OT_ERROR_INVALID_ARGS The IP Address indicated by @p aAddress is an invalid multicast address. - /// @retval OT_ERROR_REJECTED The IP Address indicated by @p aAddress is an internal multicast address. - /// @retval OT_ERROR_NO_BUFS The Network Interface is already storing the maximum allowed external multicast - /// addresses. - pub fn otIp6SubscribeMulticastAddress( - aInstance: *mut otInstance, - aAddress: *const otIp6Address, - ) -> otError; -} -unsafe extern "C" { - /// Unsubscribes the Thread interface to a Network Interface Multicast Address. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aAddress A pointer to an IP Address. - /// - /// @retval OT_ERROR_NONE Successfully unsubscribed to the Network Interface Multicast Address. - /// @retval OT_ERROR_REJECTED The IP Address indicated by @p aAddress is an internal address. - /// @retval OT_ERROR_NOT_FOUND The IP Address indicated by @p aAddress was not found. - pub fn otIp6UnsubscribeMulticastAddress( - aInstance: *mut otInstance, - aAddress: *const otIp6Address, - ) -> otError; -} -unsafe extern "C" { - /// Gets the list of IPv6 multicast addresses subscribed to the Thread interface. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @returns A pointer to the first Network Interface Multicast Address. - pub fn otIp6GetMulticastAddresses(aInstance: *mut otInstance) - -> *const otNetifMulticastAddress; -} -unsafe extern "C" { - /// Allocate a new message buffer for sending an IPv6 message. - /// - /// @note If @p aSettings is 'NULL', the link layer security is enabled and the message priority is set to - /// OT_MESSAGE_PRIORITY_NORMAL by default. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aSettings A pointer to the message settings or NULL to set default settings. - /// - /// @returns A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid. - /// - /// @sa otMessageFree - pub fn otIp6NewMessage( - aInstance: *mut otInstance, - aSettings: *const otMessageSettings, - ) -> *mut otMessage; -} -unsafe extern "C" { - /// Allocate a new message buffer and write the IPv6 datagram to the message buffer for sending an IPv6 message. - /// - /// @note If @p aSettings is NULL, the link layer security is enabled and the message priority is obtained from IPv6 - /// message itself. - /// If @p aSettings is not NULL, the @p aSetting->mPriority is ignored and obtained from IPv6 message itself. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aData A pointer to the IPv6 datagram buffer. - /// @param[in] aDataLength The size of the IPv6 datagram buffer pointed by @p aData. - /// @param[in] aSettings A pointer to the message settings or NULL to set default settings. - /// - /// @returns A pointer to the message or NULL if malformed IPv6 header or insufficient message buffers are available. - /// - /// @sa otMessageFree - pub fn otIp6NewMessageFromBuffer( - aInstance: *mut otInstance, - aData: *const u8, - aDataLength: u16, - aSettings: *const otMessageSettings, - ) -> *mut otMessage; -} -/// Pointer is called when an IPv6 datagram is received. -/// -/// @param[in] aMessage A pointer to the message buffer containing the received IPv6 datagram. This function transfers -/// the ownership of the @p aMessage to the receiver of the callback. The message should be -/// freed by the receiver of the callback after it is processed (see otMessageFree()). -/// @param[in] aContext A pointer to application-specific context. -pub type otIp6ReceiveCallback = ::core::option::Option< - unsafe extern "C" fn(aMessage: *mut otMessage, aContext: *mut ::core::ffi::c_void), ->; -unsafe extern "C" { - /// Registers a callback to provide received IPv6 datagrams. - /// - /// By default, this callback does not pass Thread control traffic. See otIp6SetReceiveFilterEnabled() to - /// change the Thread control traffic filter setting. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aCallback A pointer to a function that is called when an IPv6 datagram is received or - /// NULL to disable the callback. - /// @param[in] aCallbackContext A pointer to application-specific context. - /// - /// @sa otIp6IsReceiveFilterEnabled - /// @sa otIp6SetReceiveFilterEnabled - pub fn otIp6SetReceiveCallback( - aInstance: *mut otInstance, - aCallback: otIp6ReceiveCallback, - aCallbackContext: *mut ::core::ffi::c_void, - ); -} -/// Represents IPv6 address information. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otIp6AddressInfo { - ///< A pointer to the IPv6 address. - pub mAddress: *const otIp6Address, - ///< The prefix length of mAddress if it is a unicast address. - pub mPrefixLength: u8, - pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, - pub __bindgen_padding_0: u16, -} -impl otIp6AddressInfo { #[inline] - pub fn mScope(&self) -> u8 { - unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } + pub unsafe fn mLqi_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 1usize, + 1u8, + ) as u8) + } } #[inline] - pub fn set_mScope(&mut self, val: u8) { + pub unsafe fn set_mLqi_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(0usize, 4u8, val as u64) + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 1usize, + 1u8, + val as u64, + ) } } #[inline] - pub unsafe fn mScope_raw(this: *const Self) -> u8 { + pub fn mLinkMargin(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mLinkMargin(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mLinkMargin_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 0usize, - 4u8, + 2usize, + 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mScope_raw(this: *mut Self, val: u8) { + pub unsafe fn set_mLinkMargin_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 0usize, - 4u8, + 2usize, + 1u8, val as u64, ) } } #[inline] - pub fn mPreferred(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + pub fn mRssi(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } } #[inline] - pub fn set_mPreferred(&mut self, val: bool) { + pub fn set_mRssi(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(4usize, 1u8, val as u64) + self._bitfield_1.set(3usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mPreferred_raw(this: *const Self) -> bool { + pub unsafe fn mRssi_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 4usize, + 3usize, 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mPreferred_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mRssi_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 4usize, + 3usize, 1u8, val as u64, ) } } #[inline] - pub fn mMeshLocal(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + pub fn mReserved(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } } #[inline] - pub fn set_mMeshLocal(&mut self, val: bool) { + pub fn set_mReserved(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(5usize, 1u8, val as u64) + self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mMeshLocal_raw(this: *const Self) -> bool { + pub unsafe fn mReserved_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), - 5usize, + 4usize, 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mMeshLocal_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mReserved_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 5usize, + 4usize, 1u8, val as u64, ) @@ -5399,734 +4294,977 @@ impl otIp6AddressInfo { } #[inline] pub fn new_bitfield_1( - mScope: u8, - mPreferred: bool, - mMeshLocal: bool, + mPduCount: bool, + mLqi: bool, + mLinkMargin: bool, + mRssi: bool, + mReserved: bool, ) -> __BindgenBitfieldUnit<[u8; 1usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); - __bindgen_bitfield_unit.set(0usize, 4u8, { - let mScope: u8 = unsafe { ::core::mem::transmute(mScope) }; - mScope as u64 + __bindgen_bitfield_unit.set(0usize, 1u8, { + let mPduCount: u8 = unsafe { ::core::mem::transmute(mPduCount) }; + mPduCount as u64 }); - __bindgen_bitfield_unit.set(4usize, 1u8, { - let mPreferred: u8 = unsafe { ::core::mem::transmute(mPreferred) }; - mPreferred as u64 + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mLqi: u8 = unsafe { ::core::mem::transmute(mLqi) }; + mLqi as u64 }); - __bindgen_bitfield_unit.set(5usize, 1u8, { - let mMeshLocal: u8 = unsafe { ::core::mem::transmute(mMeshLocal) }; - mMeshLocal as u64 + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mLinkMargin: u8 = unsafe { ::core::mem::transmute(mLinkMargin) }; + mLinkMargin as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let mRssi: u8 = unsafe { ::core::mem::transmute(mRssi) }; + mRssi as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let mReserved: u8 = unsafe { ::core::mem::transmute(mReserved) }; + mReserved as u64 }); __bindgen_bitfield_unit } } -/// Pointer is called when an internal IPv6 address is added or removed. -/// -/// @param[in] aAddressInfo A pointer to the IPv6 address information. -/// @param[in] aIsAdded TRUE if the @p aAddress was added, FALSE if @p aAddress was removed. -/// @param[in] aContext A pointer to application-specific context. -pub type otIp6AddressCallback = ::core::option::Option< - unsafe extern "C" fn( - aAddressInfo: *const otIp6AddressInfo, - aIsAdded: bool, - aContext: *mut ::core::ffi::c_void, - ), ->; unsafe extern "C" { - /// Registers a callback to notify internal IPv6 address changes. + /// Get the radio capabilities. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// + /// @returns The radio capability bit vector (see `OT_RADIO_CAP_*` definitions). + pub fn otPlatRadioGetCaps(aInstance: *mut otInstance) -> otRadioCaps; +} +unsafe extern "C" { + /// Get the radio version string. + /// + /// This is an optional radio driver platform function. If not provided by platform radio driver, OpenThread uses + /// the OpenThread version instead (@sa otGetVersionString()). + /// + /// @param[in] aInstance The OpenThread instance structure. + /// + /// @returns A pointer to the OpenThread radio version. + pub fn otPlatRadioGetVersionString(aInstance: *mut otInstance) -> *const ::core::ffi::c_char; +} +unsafe extern "C" { + /// Get the radio receive sensitivity value. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// + /// @returns The radio receive sensitivity value in dBm. + pub fn otPlatRadioGetReceiveSensitivity(aInstance: *mut otInstance) -> i8; +} +unsafe extern "C" { + /// Gets the factory-assigned IEEE EUI-64 for this interface. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[out] aIeeeEui64 A pointer to the factory-assigned IEEE EUI-64. + pub fn otPlatRadioGetIeeeEui64(aInstance: *mut otInstance, aIeeeEui64: *mut u8); +} +unsafe extern "C" { + /// Set the PAN ID for address filtering. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aPanId The IEEE 802.15.4 PAN ID. + pub fn otPlatRadioSetPanId(aInstance: *mut otInstance, aPanId: otPanId); +} +unsafe extern "C" { + /// Set the Extended Address for address filtering. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aExtAddress A pointer to the IEEE 802.15.4 Extended Address stored in little-endian byte order. + pub fn otPlatRadioSetExtendedAddress( + aInstance: *mut otInstance, + aExtAddress: *const otExtAddress, + ); +} +unsafe extern "C" { + /// Set the Short Address for address filtering. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aShortAddress The IEEE 802.15.4 Short Address. + pub fn otPlatRadioSetShortAddress(aInstance: *mut otInstance, aShortAddress: otShortAddress); +} +unsafe extern "C" { + /// Set the alternate short address. + /// + /// This is an optional radio platform API. The radio platform MUST indicate support for this API by including the + /// capability `OT_RADIO_CAPS_ALT_SHORT_ADDR` in `otPlatRadioGetCaps()`. + /// + /// When supported, the radio should accept received frames destined to the specified alternate short address in + /// addition to the short address provided in `otPlatRadioSetShortAddress()`. + /// + /// The @p aShortAddress can be set to `OT_RADIO_INVALID_SHORT_ADDR` (0xfffe) to clear any previously set alternate + /// short address. + /// + /// This function is used by OpenThread stack during child-to-router role transitions, allowing the device to continue + /// receiving frames addressed to its previous short address for a short period. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aShortAddress The alternate IEEE 802.15.4 short address. `OT_RADIO_INVALID_SHORT_ADDR` to clear. + pub fn otPlatRadioSetAlternateShortAddress( + aInstance: *mut otInstance, + aShortAddress: otShortAddress, + ); +} +unsafe extern "C" { + /// Get the radio's transmit power in dBm. + /// + /// @note The transmit power returned will be no larger than the power specified in the max power table for + /// the current channel. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[out] aPower The transmit power in dBm. + /// + /// @retval OT_ERROR_NONE Successfully retrieved the transmit power. + /// @retval OT_ERROR_INVALID_ARGS @p aPower was NULL. + /// @retval OT_ERROR_NOT_IMPLEMENTED Transmit power configuration via dBm is not implemented. + pub fn otPlatRadioGetTransmitPower(aInstance: *mut otInstance, aPower: *mut i8) -> otError; +} +unsafe extern "C" { + /// Set the radio's transmit power in dBm for all channels. + /// + /// @note The real transmit power will be no larger than the power specified in the max power table for + /// the current channel that was configured by `otPlatRadioSetChannelMaxTransmitPower()`. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aPower The transmit power in dBm. + /// + /// @retval OT_ERROR_NONE Successfully set the transmit power. + /// @retval OT_ERROR_NOT_IMPLEMENTED Transmit power configuration via dBm is not implemented. + pub fn otPlatRadioSetTransmitPower(aInstance: *mut otInstance, aPower: i8) -> otError; +} +unsafe extern "C" { + /// Get the radio's CCA ED threshold in dBm measured at antenna connector per IEEE 802.15.4 - 2015 section 10.1.4. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[out] aThreshold The CCA ED threshold in dBm. + /// + /// @retval OT_ERROR_NONE Successfully retrieved the CCA ED threshold. + /// @retval OT_ERROR_INVALID_ARGS @p aThreshold was NULL. + /// @retval OT_ERROR_NOT_IMPLEMENTED CCA ED threshold configuration via dBm is not implemented. + pub fn otPlatRadioGetCcaEnergyDetectThreshold( + aInstance: *mut otInstance, + aThreshold: *mut i8, + ) -> otError; +} +unsafe extern "C" { + /// Set the radio's CCA ED threshold in dBm measured at antenna connector per IEEE 802.15.4 - 2015 section 10.1.4. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aThreshold The CCA ED threshold in dBm. + /// + /// @retval OT_ERROR_NONE Successfully set the transmit power. + /// @retval OT_ERROR_INVALID_ARGS Given threshold is out of range. + /// @retval OT_ERROR_NOT_IMPLEMENTED CCA ED threshold configuration via dBm is not implemented. + pub fn otPlatRadioSetCcaEnergyDetectThreshold( + aInstance: *mut otInstance, + aThreshold: i8, + ) -> otError; +} +unsafe extern "C" { + /// Gets the external FEM's Rx LNA gain in dBm. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[out] aGain The external FEM's Rx LNA gain in dBm. + /// + /// @retval OT_ERROR_NONE Successfully retrieved the external FEM's LNA gain. + /// @retval OT_ERROR_INVALID_ARGS @p aGain was NULL. + /// @retval OT_ERROR_NOT_IMPLEMENTED External FEM's LNA setting is not implemented. + pub fn otPlatRadioGetFemLnaGain(aInstance: *mut otInstance, aGain: *mut i8) -> otError; +} +unsafe extern "C" { + /// Sets the external FEM's Rx LNA gain in dBm. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aGain The external FEM's Rx LNA gain in dBm. + /// + /// @retval OT_ERROR_NONE Successfully set the external FEM's LNA gain. + /// @retval OT_ERROR_NOT_IMPLEMENTED External FEM's LNA gain setting is not implemented. + pub fn otPlatRadioSetFemLnaGain(aInstance: *mut otInstance, aGain: i8) -> otError; +} +unsafe extern "C" { + /// Get the status of promiscuous mode. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aCallback A pointer to a function that is called when an internal IPv6 address is added or - /// removed. NULL to disable the callback. - /// @param[in] aCallbackContext A pointer to application-specific context. - pub fn otIp6SetAddressCallback( + /// @param[in] aInstance The OpenThread instance structure. + /// + /// @retval TRUE Promiscuous mode is enabled. + /// @retval FALSE Promiscuous mode is disabled. + pub fn otPlatRadioGetPromiscuous(aInstance: *mut otInstance) -> bool; +} +unsafe extern "C" { + /// Enable or disable promiscuous mode. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aEnable TRUE to enable or FALSE to disable promiscuous mode. + pub fn otPlatRadioSetPromiscuous(aInstance: *mut otInstance, aEnable: bool); +} +unsafe extern "C" { + /// Sets the rx-on-when-idle state to the radio platform. + /// + /// There are a few situations that the radio can enter sleep state if the device is in rx-off-when-idle state but + /// it's hard and costly for the SubMac to identify these situations and instruct the radio to enter sleep: + /// + /// - Finalization of a regular frame reception task, provided that: + /// - The frame is received without errors and passes the filtering and it's not an spurious ACK. + /// - ACK is not requested or transmission of ACK is not possible due to internal conditions. + /// - Finalization of a frame transmission or transmission of an ACK frame, when ACK is not requested in the transmitted + /// frame. + /// - Finalization of the reception operation of a requested ACK due to: + /// - ACK timeout expiration. + /// - Reception of an invalid ACK or not an ACK frame. + /// - Reception of the proper ACK, unless the transmitted frame was a Data Request Command and the frame pending bit + /// on the received ACK is set to true. In this case the radio platform implementation SHOULD keep the receiver on + /// until a determined timeout which triggers an idle period start.`OPENTHREAD_CONFIG_MAC_DATA_POLL_TIMEOUT` can be + /// taken as a reference for this. + /// - Finalization of a stand alone CCA task. + /// - Finalization of a CCA operation with busy result during CSMA/CA procedure. + /// - Finalization of an Energy Detection task. + /// - Finalization of a radio reception window scheduled with `otPlatRadioReceiveAt`. + /// + /// If a platform supports `OT_RADIO_CAPS_RX_ON_WHEN_IDLE` it must also support `OT_RADIO_CAPS_CSMA_BACKOFF` and handle + /// idle periods after CCA as described above. + /// + /// Upon the transition of the "RxOnWhenIdle" flag from TRUE to FALSE, the radio platform should enter sleep mode. + /// If the radio is currently in receive mode, it should enter sleep mode immediately. Otherwise, it should enter sleep + /// mode after the current operation is completed. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aEnable TRUE to keep radio in Receive state, FALSE to put to Sleep state during idle periods. + pub fn otPlatRadioSetRxOnWhenIdle(aInstance: *mut otInstance, aEnable: bool); +} +unsafe extern "C" { + /// Update MAC keys and key index + /// + /// Is used when radio provides OT_RADIO_CAPS_TRANSMIT_SEC capability. + /// + /// The radio platform should reset the current security MAC frame counter tracked by the radio on this call. While this + /// is highly recommended, the OpenThread stack, as a safeguard, will also reset the frame counter using the + /// `otPlatRadioSetMacFrameCounter()` before calling this API. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aKeyIdMode The key ID mode. + /// @param[in] aKeyId Current MAC key index. + /// @param[in] aPrevKey A pointer to the previous MAC key. + /// @param[in] aCurrKey A pointer to the current MAC key. + /// @param[in] aNextKey A pointer to the next MAC key. + /// @param[in] aKeyType Key Type used. + pub fn otPlatRadioSetMacKey( aInstance: *mut otInstance, - aCallback: otIp6AddressCallback, - aCallbackContext: *mut ::core::ffi::c_void, + aKeyIdMode: u8, + aKeyId: u8, + aPrevKey: *const otMacKeyMaterial, + aCurrKey: *const otMacKeyMaterial, + aNextKey: *const otMacKeyMaterial, + aKeyType: otRadioKeyType, ); } unsafe extern "C" { - /// Indicates whether or not Thread control traffic is filtered out when delivering IPv6 datagrams - /// via the callback specified in otIp6SetReceiveCallback(). + /// Sets the current MAC frame counter value. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// Is used when radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability. /// - /// @returns TRUE if Thread control traffic is filtered out, FALSE otherwise. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aMacFrameCounter The MAC frame counter value. + pub fn otPlatRadioSetMacFrameCounter(aInstance: *mut otInstance, aMacFrameCounter: u32); +} +unsafe extern "C" { + /// Sets the current MAC frame counter value only if the new given value is larger than the current value. /// - /// @sa otIp6SetReceiveCallback - /// @sa otIp6SetReceiveFilterEnabled - pub fn otIp6IsReceiveFilterEnabled(aInstance: *mut otInstance) -> bool; + /// Is used when radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aMacFrameCounter The MAC frame counter value. + pub fn otPlatRadioSetMacFrameCounterIfLarger(aInstance: *mut otInstance, aMacFrameCounter: u32); } unsafe extern "C" { - /// Sets whether or not Thread control traffic is filtered out when delivering IPv6 datagrams - /// via the callback specified in otIp6SetReceiveCallback(). + /// Get the current time in microseconds referenced to a continuous monotonic + /// local radio clock (64 bits width). /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aEnabled TRUE if Thread control traffic is filtered out, FALSE otherwise. + /// The radio clock SHALL NOT wrap during the device's uptime. Implementations + /// SHALL therefore identify and compensate for internal counter overflows. The + /// clock does not have a defined epoch and it SHALL NOT introduce any continuous + /// or discontinuous adjustments (e.g. leap seconds). Implementations SHALL + /// compensate for any sleep times of the device. /// - /// @sa otIp6SetReceiveCallback - /// @sa otIsReceiveIp6FilterEnabled - pub fn otIp6SetReceiveFilterEnabled(aInstance: *mut otInstance, aEnabled: bool); + /// Implementations MAY choose to discipline the radio clock and compensate for + /// sleep times by any means (e.g. by combining a high precision/low power RTC + /// with a high resolution counter) as long as the exposed combined clock + /// provides continuous monotonic microsecond resolution ticks within the + /// accuracy limits announced by @ref otPlatRadioGetCslAccuracy. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The current time in microseconds. UINT64_MAX when platform does not + /// support or radio time is not ready. + pub fn otPlatRadioGetNow(aInstance: *mut otInstance) -> u64; } unsafe extern "C" { - /// Sends an IPv6 datagram via the Thread interface. + /// Get the bus speed in bits/second between the host and the radio chip. /// - /// The caller transfers ownership of @p aMessage when making this call. OpenThread will free @p aMessage when - /// processing is complete, including when a value other than `OT_ERROR_NONE` is returned. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aMessage A pointer to the message buffer containing the IPv6 datagram. + /// @returns The bus speed in bits/second between the host and the radio chip. + /// Return 0 when the MAC and above layer and Radio layer resides on the same chip. + pub fn otPlatRadioGetBusSpeed(aInstance: *mut otInstance) -> u32; +} +unsafe extern "C" { + /// Get the bus latency in microseconds between the host and the radio chip. /// - /// @retval OT_ERROR_NONE Successfully processed the message. - /// @retval OT_ERROR_DROP Message was well-formed but not fully processed due to packet processing - /// rules. - /// @retval OT_ERROR_NO_BUFS Could not allocate necessary message buffers when processing the datagram. - /// @retval OT_ERROR_NO_ROUTE No route to host. - /// @retval OT_ERROR_INVALID_SOURCE_ADDRESS Source address is invalid, e.g. an anycast address or a multicast address. - /// @retval OT_ERROR_PARSE Encountered a malformed header when processing the message. - /// @retval OT_ERROR_INVALID_ARGS The message's metadata is invalid, e.g. the message uses - /// `OT_MESSAGE_ORIGIN_THREAD_NETIF` as the origin. - pub fn otIp6Send(aInstance: *mut otInstance, aMessage: *mut otMessage) -> otError; + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The bus latency in microseconds between the host and the radio chip. + /// Return 0 when the MAC and above layer and Radio layer resides on the same chip. + pub fn otPlatRadioGetBusLatency(aInstance: *mut otInstance) -> u32; } unsafe extern "C" { - /// Adds a port to the allowed unsecured port list. + /// Get current state of the radio. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aPort The port value. + /// Is not required by OpenThread. It may be used for debugging and/or application-specific purposes. /// - /// @retval OT_ERROR_NONE The port was successfully added to the allowed unsecure port list. - /// @retval OT_ERROR_INVALID_ARGS The port is invalid (value 0 is reserved for internal use). - /// @retval OT_ERROR_NO_BUFS The unsecure port list is full. - pub fn otIp6AddUnsecurePort(aInstance: *mut otInstance, aPort: u16) -> otError; + /// @note This function may be not implemented. It does not affect OpenThread. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// + /// @return Current state of the radio. + pub fn otPlatRadioGetState(aInstance: *mut otInstance) -> otRadioState; } unsafe extern "C" { - /// Removes a port from the allowed unsecure port list. + /// Enable the radio. /// - /// @note This function removes @p aPort by overwriting @p aPort with the element after @p aPort in the internal port - /// list. Be careful when calling otIp6GetUnsecurePorts() followed by otIp6RemoveUnsecurePort() to remove unsecure - /// ports. + /// @param[in] aInstance The OpenThread instance structure. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aPort The port value. + /// @retval OT_ERROR_NONE Successfully enabled. + /// @retval OT_ERROR_FAILED The radio could not be enabled. + pub fn otPlatRadioEnable(aInstance: *mut otInstance) -> otError; +} +unsafe extern "C" { + /// Disable the radio. /// - /// @retval OT_ERROR_NONE The port was successfully removed from the allowed unsecure port list. - /// @retval OT_ERROR_INVALID_ARGS The port is invalid (value 0 is reserved for internal use). - /// @retval OT_ERROR_NOT_FOUND The port was not found in the unsecure port list. - pub fn otIp6RemoveUnsecurePort(aInstance: *mut otInstance, aPort: u16) -> otError; + /// @param[in] aInstance The OpenThread instance structure. + /// + /// @retval OT_ERROR_NONE Successfully transitioned to Disabled. + /// @retval OT_ERROR_INVALID_STATE The radio was not in sleep state. + pub fn otPlatRadioDisable(aInstance: *mut otInstance) -> otError; } unsafe extern "C" { - /// Removes all ports from the allowed unsecure port list. + /// Check whether radio is enabled or not. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otIp6RemoveAllUnsecurePorts(aInstance: *mut otInstance); + /// @param[in] aInstance The OpenThread instance structure. + /// + /// @returns TRUE if the radio is enabled, FALSE otherwise. + pub fn otPlatRadioIsEnabled(aInstance: *mut otInstance) -> bool; } unsafe extern "C" { - /// Returns a pointer to the unsecure port list. + /// Transition the radio from Receive to Sleep (turn off the radio). /// - /// @note Port value 0 is used to indicate an invalid entry. + /// @param[in] aInstance The OpenThread instance structure. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[out] aNumEntries The number of entries in the list. + /// @retval OT_ERROR_NONE Successfully transitioned to Sleep. + /// @retval OT_ERROR_BUSY The radio was transmitting. + /// @retval OT_ERROR_INVALID_STATE The radio was disabled. + pub fn otPlatRadioSleep(aInstance: *mut otInstance) -> otError; +} +unsafe extern "C" { + /// Transition the radio from Sleep to Receive (turn on the radio). /// - /// @returns A pointer to the unsecure port list. - pub fn otIp6GetUnsecurePorts(aInstance: *mut otInstance, aNumEntries: *mut u8) -> *const u16; + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aChannel The channel to use for receiving. + /// + /// @retval OT_ERROR_NONE Successfully transitioned to Receive. + /// @retval OT_ERROR_INVALID_STATE The radio was disabled or transmitting. + pub fn otPlatRadioReceive(aInstance: *mut otInstance, aChannel: u8) -> otError; +} +unsafe extern "C" { + /// Schedule a radio reception window at a specific time and duration. + /// + /// After a radio reception is successfully scheduled for a future time and duration, a subsequent call to this + /// function MUST be handled as follows: + /// + /// - If the start time of the previously scheduled reception window has not yet been reached, the new call to + /// `otPlatRadioReceiveAt()` MUST cancel the previous schedule, effectively replacing it. + /// + /// - If the start of the previous window has already passed, the previous receive schedule is already being executed + /// by the radio and MUST NOT be replaced or impacted. The new call to `otPlatRadioReceiveAt()` would then schedule + /// a new future receive window. In particular, if the new `otPlatRadioReceiveAt()` call occurs after the start + /// but while still within the previous reception window, the ongoing reception window MUST NOT be impacted. + /// + /// @param[in] aChannel The radio channel on which to receive. + /// @param[in] aStart The receive window start time relative to the local + /// radio clock, see `otPlatRadioGetNow`. The radio + /// receiver SHALL be on and ready to receive the first + /// symbol of a frame's SHR at the window start time. + /// @param[in] aDuration The receive window duration, in microseconds, as + /// measured by the local radio clock. The radio SHOULD be + /// turned off (or switched to TX mode if an ACK frame + /// needs to be sent) after that duration unless it is + /// still actively receiving a frame. In the latter case + /// the radio SHALL be kept in reception mode until frame + /// reception has either succeeded or failed. + /// + /// @retval OT_ERROR_NONE Successfully scheduled receive window. + /// @retval OT_ERROR_FAILED The receive window could not be scheduled. For example, if @p aStart is in the past. + pub fn otPlatRadioReceiveAt( + aInstance: *mut otInstance, + aChannel: u8, + aStart: u32, + aDuration: u32, + ) -> otError; } unsafe extern "C" { - /// Test if two IPv6 addresses are the same. - /// - /// @param[in] aFirst A pointer to the first IPv6 address to compare. - /// @param[in] aSecond A pointer to the second IPv6 address to compare. + /// The radio driver calls this function to notify OpenThread of a received frame. /// - /// @retval TRUE The two IPv6 addresses are the same. - /// @retval FALSE The two IPv6 addresses are not the same. - pub fn otIp6IsAddressEqual(aFirst: *const otIp6Address, aSecond: *const otIp6Address) -> bool; + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aFrame A pointer to the received frame or NULL if the receive operation failed. + /// @param[in] aError OT_ERROR_NONE when successfully received a frame, + /// OT_ERROR_ABORT when reception was aborted and a frame was not received, + /// OT_ERROR_NO_BUFS when a frame could not be received due to lack of rx buffer space. + pub fn otPlatRadioReceiveDone( + aInstance: *mut otInstance, + aFrame: *mut otRadioFrame, + aError: otError, + ); } unsafe extern "C" { - /// Test if two IPv6 prefixes are the same. + /// The radio driver calls this function to notify OpenThread diagnostics module of a received frame. /// - /// @param[in] aFirst A pointer to the first IPv6 prefix to compare. - /// @param[in] aSecond A pointer to the second IPv6 prefix to compare. + /// Is used when diagnostics is enabled. /// - /// @retval TRUE The two IPv6 prefixes are the same. - /// @retval FALSE The two IPv6 prefixes are not the same. - pub fn otIp6ArePrefixesEqual(aFirst: *const otIp6Prefix, aSecond: *const otIp6Prefix) -> bool; + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aFrame A pointer to the received frame or NULL if the receive operation failed. + /// @param[in] aError OT_ERROR_NONE when successfully received a frame, + /// OT_ERROR_ABORT when reception was aborted and a frame was not received, + /// OT_ERROR_NO_BUFS when a frame could not be received due to lack of rx buffer space. + pub fn otPlatDiagRadioReceiveDone( + aInstance: *mut otInstance, + aFrame: *mut otRadioFrame, + aError: otError, + ); } unsafe extern "C" { - /// Converts a human-readable IPv6 address string into a binary representation. + /// Get the radio transmit frame buffer. /// - /// @param[in] aString A pointer to a NULL-terminated string. - /// @param[out] aAddress A pointer to an IPv6 address. + /// OpenThread forms the IEEE 802.15.4 frame in this buffer then calls `otPlatRadioTransmit()` to request transmission. /// - /// @retval OT_ERROR_NONE Successfully parsed @p aString and updated @p aAddress. - /// @retval OT_ERROR_PARSE Failed to parse @p aString as an IPv6 address. - pub fn otIp6AddressFromString( - aString: *const ::core::ffi::c_char, - aAddress: *mut otIp6Address, - ) -> otError; + /// @param[in] aInstance The OpenThread instance structure. + /// + /// @returns A pointer to the transmit frame buffer. + pub fn otPlatRadioGetTransmitBuffer(aInstance: *mut otInstance) -> *mut otRadioFrame; } unsafe extern "C" { - /// Converts a human-readable IPv6 prefix string into a binary representation. + /// Begin the transmit sequence on the radio. /// - /// The @p aString parameter should be a string in the format "
/", where `
` is an IPv6 - /// address and `` is a prefix length. + /// The caller must form the IEEE 802.15.4 frame in the buffer provided by `otPlatRadioGetTransmitBuffer()` before + /// requesting transmission. The channel and transmit power are also included in the otRadioFrame structure. /// - /// @param[in] aString A pointer to a NULL-terminated string. - /// @param[out] aPrefix A pointer to an IPv6 prefix. + /// The transmit sequence consists of: + /// 1. Transitioning the radio to Transmit from one of the following states: + /// - Receive if RX is on when the device is idle or OT_RADIO_CAPS_SLEEP_TO_TX is not supported + /// - Sleep if RX is off when the device is idle and OT_RADIO_CAPS_SLEEP_TO_TX is supported. + /// 2. Transmits the psdu on the given channel and at the given transmit power. /// - /// @retval OT_ERROR_NONE Successfully parsed the string as an IPv6 prefix and updated @p aPrefix. - /// @retval OT_ERROR_PARSE Failed to parse @p aString as an IPv6 prefix. - pub fn otIp6PrefixFromString( - aString: *const ::core::ffi::c_char, - aPrefix: *mut otIp6Prefix, - ) -> otError; + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aFrame A pointer to the frame to be transmitted. + /// + /// @retval OT_ERROR_NONE Successfully transitioned to Transmit. + /// @retval OT_ERROR_INVALID_STATE The radio was not in the Receive state. + pub fn otPlatRadioTransmit(aInstance: *mut otInstance, aFrame: *mut otRadioFrame) -> otError; } unsafe extern "C" { - /// Converts a given IPv6 address to a human-readable string. - /// - /// The IPv6 address string is formatted as 16 hex values separated by ':' (i.e., "%x:%x:%x:...:%x"). + /// The radio driver calls this function to notify OpenThread that the transmission has started. /// - /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated - /// but the outputted string is always null-terminated. + /// @note This function should be called by the same thread that executes all of the other OpenThread code. It should + /// not be called by ISR or any other task. /// - /// @param[in] aAddress A pointer to an IPv6 address (MUST NOT be NULL). - /// @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL). - /// @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_IP6_ADDRESS_STRING_SIZE`. - pub fn otIp6AddressToString( - aAddress: *const otIp6Address, - aBuffer: *mut ::core::ffi::c_char, - aSize: u16, - ); + /// @param[in] aInstance A pointer to the OpenThread instance structure. + /// @param[in] aFrame A pointer to the frame that is being transmitted. + pub fn otPlatRadioTxStarted(aInstance: *mut otInstance, aFrame: *mut otRadioFrame); } unsafe extern "C" { - /// Converts a given IPv6 socket address to a human-readable string. - /// - /// The IPv6 socket address string is formatted as [`address`]:`port` where `address` is shown - /// as 16 hex values separated by `:` and `port` is the port number in decimal format, - /// for example "[%x:%x:...:%x]:%u". + /// The radio driver calls this function to notify OpenThread that the transmit operation has completed, + /// providing both the transmitted frame and, if applicable, the received ack frame. /// - /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated - /// but the outputted string is always null-terminated. + /// When radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability, radio platform layer updates @p aFrame + /// with the security frame counter and key index values maintained by the radio. /// - /// @param[in] aSockAddr A pointer to an IPv6 socket address (MUST NOT be NULL). - /// @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL). - /// @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_IP6_SOCK_ADDR_STRING_SIZE`. - pub fn otIp6SockAddrToString( - aSockAddr: *const otSockAddr, - aBuffer: *mut ::core::ffi::c_char, - aSize: u16, + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aFrame A pointer to the frame that was transmitted. + /// @param[in] aAckFrame A pointer to the ACK frame, NULL if no ACK was received. + /// @param[in] aError OT_ERROR_NONE when the frame was transmitted, + /// OT_ERROR_NO_ACK when the frame was transmitted but no ACK was received, + /// OT_ERROR_CHANNEL_ACCESS_FAILURE tx could not take place due to activity on the channel, + /// OT_ERROR_ABORT when transmission was aborted for other reasons. + pub fn otPlatRadioTxDone( + aInstance: *mut otInstance, + aFrame: *mut otRadioFrame, + aAckFrame: *mut otRadioFrame, + aError: otError, ); } unsafe extern "C" { - /// Converts a given IPv6 prefix to a human-readable string. - /// - /// The IPv6 address string is formatted as "%x:%x:%x:...[::]/plen". + /// The radio driver calls this function to notify OpenThread diagnostics module that the transmission has completed. /// - /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated - /// but the outputted string is always null-terminated. + /// Is used when diagnostics is enabled. /// - /// @param[in] aPrefix A pointer to an IPv6 prefix (MUST NOT be NULL). - /// @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL). - /// @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_IP6_PREFIX_STRING_SIZE`. - pub fn otIp6PrefixToString( - aPrefix: *const otIp6Prefix, - aBuffer: *mut ::core::ffi::c_char, - aSize: u16, + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aFrame A pointer to the frame that was transmitted. + /// @param[in] aError OT_ERROR_NONE when the frame was transmitted, + /// OT_ERROR_CHANNEL_ACCESS_FAILURE tx could not take place due to activity on the channel, + /// OT_ERROR_ABORT when transmission was aborted for other reasons. + pub fn otPlatDiagRadioTransmitDone( + aInstance: *mut otInstance, + aFrame: *mut otRadioFrame, + aError: otError, ); } unsafe extern "C" { - /// Returns the prefix match length (bits) for two IPv6 addresses. + /// Return a recent RSSI measurement when the radio is in receive state. /// - /// @param[in] aFirst A pointer to the first IPv6 address. - /// @param[in] aSecond A pointer to the second IPv6 address. + /// If the radio is not in receive state, then `OT_RADIO_RSSI_INVALID` MUST be returned. If the radio is in receive + /// state, then a single RSSI measurement is taken on the current receive channel and returned. /// - /// @returns The prefix match length in bits. - pub fn otIp6PrefixMatch(aFirst: *const otIp6Address, aSecond: *const otIp6Address) -> u8; -} -unsafe extern "C" { - /// Gets a prefix with @p aLength from @p aAddress. + /// @param[in] aInstance The OpenThread instance structure. /// - /// @param[in] aAddress A pointer to an IPv6 address. - /// @param[in] aLength The length of prefix in bits. - /// @param[out] aPrefix A pointer to output the IPv6 prefix. - pub fn otIp6GetPrefix(aAddress: *const otIp6Address, aLength: u8, aPrefix: *mut otIp6Prefix); + /// @returns The RSSI in dBm when it is valid. `OT_RADIO_RSSI_INVALID` when RSSI is invalid. + pub fn otPlatRadioGetRssi(aInstance: *mut otInstance) -> i8; } unsafe extern "C" { - /// Indicates whether or not a given IPv6 address is the Unspecified Address. - /// - /// @param[in] aAddress A pointer to an IPv6 address. + /// Begin the energy scan sequence on the radio. /// - /// @retval TRUE If the IPv6 address is the Unspecified Address. - /// @retval FALSE If the IPv6 address is not the Unspecified Address. - pub fn otIp6IsAddressUnspecified(aAddress: *const otIp6Address) -> bool; -} -unsafe extern "C" { - /// Perform OpenThread source address selection. + /// Is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in,out] aMessageInfo A pointer to the message information. + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aScanChannel The channel to perform the energy scan on. + /// @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned. /// - /// @retval OT_ERROR_NONE Found a source address and is filled into mSockAddr of @p aMessageInfo. - /// @retval OT_ERROR_NOT_FOUND No source address was found and @p aMessageInfo is unchanged. - pub fn otIp6SelectSourceAddress( + /// @retval OT_ERROR_NONE Successfully started scanning the channel. + /// @retval OT_ERROR_BUSY The radio is performing energy scanning. + /// @retval OT_ERROR_NOT_IMPLEMENTED The radio doesn't support energy scanning. + pub fn otPlatRadioEnergyScan( aInstance: *mut otInstance, - aMessageInfo: *mut otMessageInfo, + aScanChannel: u8, + aScanDuration: u16, ) -> otError; } unsafe extern "C" { - /// Indicates whether the SLAAC module is enabled or not. + /// The radio driver calls this function to notify OpenThread that the energy scan is complete. /// - /// `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled. + /// Is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. /// - /// @retval TRUE SLAAC module is enabled. - /// @retval FALSE SLAAC module is disabled. - pub fn otIp6IsSlaacEnabled(aInstance: *mut otInstance) -> bool; + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aEnergyScanMaxRssi The maximum RSSI encountered on the scanned channel. + pub fn otPlatRadioEnergyScanDone(aInstance: *mut otInstance, aEnergyScanMaxRssi: i8); } unsafe extern "C" { - /// Enables/disables the SLAAC module. - /// - /// `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled. - /// - /// When SLAAC module is enabled, SLAAC addresses (based on on-mesh prefixes in Network Data) are added to the interface. - /// When SLAAC module is disabled any previously added SLAAC address is removed. + /// The radio driver calls this function to notify OpenThread that the spinel bus latency has been changed. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aEnabled TRUE to enable, FALSE to disable. - pub fn otIp6SetSlaacEnabled(aInstance: *mut otInstance, aEnabled: bool); + /// @param[in] aInstance The OpenThread instance structure. + pub fn otPlatRadioBusLatencyChanged(aInstance: *mut otInstance); } -/// Pointer allows user to filter prefixes and not allow an SLAAC address based on a prefix to be added. -/// -/// `otIp6SetSlaacPrefixFilter()` can be used to set the filter handler. The filter handler is invoked by SLAAC module -/// when it is about to add a SLAAC address based on a prefix. Its boolean return value determines whether the address -/// is filtered (not added) or not. -/// -/// @param[in] aInstance A pointer to an OpenThread instance. -/// @param[in] aPrefix A pointer to prefix for which SLAAC address is about to be added. -/// -/// @retval TRUE Indicates that the SLAAC address based on the prefix should be filtered and NOT added. -/// @retval FALSE Indicates that the SLAAC address based on the prefix should be added. -pub type otIp6SlaacPrefixFilter = ::core::option::Option< - unsafe extern "C" fn(aInstance: *mut otInstance, aPrefix: *const otIp6Prefix) -> bool, ->; unsafe extern "C" { - /// Sets the SLAAC module filter handler. - /// - /// `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled. - /// - /// The filter handler is called by SLAAC module when it is about to add a SLAAC address based on a prefix to decide - /// whether the address should be added or not. + /// Enable/Disable source address match feature. /// - /// A NULL filter handler disables filtering and allows all SLAAC addresses to be added. + /// The source address match feature controls how the radio layer decides the "frame pending" bit for acks sent in + /// response to data request commands from children. /// - /// If this function is not called, the default filter used by SLAAC module will be NULL (filtering is disabled). + /// If disabled, the radio layer must set the "frame pending" on all acks to data request commands. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aFilter A pointer to SLAAC prefix filter handler, or NULL to disable filtering. - pub fn otIp6SetSlaacPrefixFilter(aInstance: *mut otInstance, aFilter: otIp6SlaacPrefixFilter); -} -/// Pointer is called with results of `otIp6RegisterMulticastListeners`. -/// -/// @param[in] aContext A pointer to the user context. -/// @param[in] aError OT_ERROR_NONE when successfully sent MLR.req and received MLR.rsp, -/// OT_ERROR_RESPONSE_TIMEOUT when failed to receive MLR.rsp, -/// OT_ERROR_PARSE when failed to parse MLR.rsp. -/// @param[in] aMlrStatus The Multicast Listener Registration status when @p aError is OT_ERROR_NONE. -/// @param[in] aFailedAddresses A pointer to the failed IPv6 addresses when @p aError is OT_ERROR_NONE. -/// @param[in] aFailedAddressNum The number of failed IPv6 addresses when @p aError is OT_ERROR_NONE. -/// -/// @sa otIp6RegisterMulticastListeners -pub type otIp6RegisterMulticastListenersCallback = ::core::option::Option< - unsafe extern "C" fn( - aContext: *mut ::core::ffi::c_void, - aError: otError, - aMlrStatus: u8, - aFailedAddresses: *const otIp6Address, - aFailedAddressNum: u8, - ), ->; -unsafe extern "C" { - /// Registers Multicast Listeners to Primary Backbone Router. + /// If enabled, the radio layer uses the source address match table to determine whether to set or clear the "frame + /// pending" bit in an ack to a data request command. /// - /// `OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE` and `OPENTHREAD_CONFIG_COMMISSIONER_ENABLE` - /// must be enabled. + /// The source address match table provides the list of children for which there is a pending frame. Either a short + /// address or an extended/long address can be added to the source address match table. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aAddresses A Multicast Address Array to register. - /// @param[in] aAddressNum The number of Multicast Address to register (0 if @p aAddresses is NULL). - /// @param[in] aTimeout A pointer to the timeout value (in seconds) to be included in MLR.req. A timeout value of 0 - /// removes the corresponding Multicast Listener. If NULL, MLR.req would have no Timeout Tlv by - /// default. - /// @param[in] aCallback A pointer to the callback function. - /// @param[in] aContext A pointer to the user context. + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aEnable Enable/disable source address match feature. + pub fn otPlatRadioEnableSrcMatch(aInstance: *mut otInstance, aEnable: bool); +} +unsafe extern "C" { + /// Add a short address to the source address match table. /// - /// @retval OT_ERROR_NONE Successfully sent MLR.req. The @p aCallback will be called iff this method - /// returns OT_ERROR_NONE. - /// @retval OT_ERROR_BUSY If a previous registration was ongoing. - /// @retval OT_ERROR_INVALID_ARGS If one or more arguments are invalid. - /// @retval OT_ERROR_INVALID_STATE If the device was not in a valid state to send MLR.req (e.g. Commissioner not - /// started, Primary Backbone Router not found). - /// @retval OT_ERROR_NO_BUFS If insufficient message buffers available. + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aShortAddress The short address to be added. /// - /// @sa otIp6RegisterMulticastListenersCallback - pub fn otIp6RegisterMulticastListeners( + /// @retval OT_ERROR_NONE Successfully added short address to the source match table. + /// @retval OT_ERROR_NO_BUFS No available entry in the source match table. + pub fn otPlatRadioAddSrcMatchShortEntry( aInstance: *mut otInstance, - aAddresses: *const otIp6Address, - aAddressNum: u8, - aTimeout: *const u32, - aCallback: otIp6RegisterMulticastListenersCallback, - aContext: *mut ::core::ffi::c_void, + aShortAddress: otShortAddress, ) -> otError; } unsafe extern "C" { - /// Sets the Mesh Local IID (for test purpose). - /// - /// Requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`. + /// Add an extended address to the source address match table. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aIid A pointer to the Mesh Local IID to set. + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aExtAddress The extended address to be added stored in little-endian byte order. /// - /// @retval OT_ERROR_NONE Successfully set the Mesh Local IID. - /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. - pub fn otIp6SetMeshLocalIid( + /// @retval OT_ERROR_NONE Successfully added extended address to the source match table. + /// @retval OT_ERROR_NO_BUFS No available entry in the source match table. + pub fn otPlatRadioAddSrcMatchExtEntry( aInstance: *mut otInstance, - aIid: *const otIp6InterfaceIdentifier, + aExtAddress: *const otExtAddress, ) -> otError; } unsafe extern "C" { - /// Converts a given IP protocol number to a human-readable string. + /// Remove a short address from the source address match table. /// - /// @param[in] aIpProto An IP protocol number (`OT_IP6_PROTO_*` enumeration). + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aShortAddress The short address to be removed. /// - /// @returns A string representing @p aIpProto. - pub fn otIp6ProtoToString(aIpProto: u8) -> *const ::core::ffi::c_char; + /// @retval OT_ERROR_NONE Successfully removed short address from the source match table. + /// @retval OT_ERROR_NO_ADDRESS The short address is not in source address match table. + pub fn otPlatRadioClearSrcMatchShortEntry( + aInstance: *mut otInstance, + aShortAddress: otShortAddress, + ) -> otError; } -/// Represents the counters for packets and bytes. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otPacketsAndBytes { - ///< The number of packets. - pub mPackets: u64, - ///< The number of bytes. - pub mBytes: u64, +unsafe extern "C" { + /// Remove an extended address from the source address match table. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aExtAddress The extended address to be removed stored in little-endian byte order. + /// + /// @retval OT_ERROR_NONE Successfully removed the extended address from the source match table. + /// @retval OT_ERROR_NO_ADDRESS The extended address is not in source address match table. + pub fn otPlatRadioClearSrcMatchExtEntry( + aInstance: *mut otInstance, + aExtAddress: *const otExtAddress, + ) -> otError; } -/// Represents the counters of packets forwarded via Border Routing. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otBorderRoutingCounters { - ///< The counters for inbound unicast. - pub mInboundUnicast: otPacketsAndBytes, - ///< The counters for inbound multicast. - pub mInboundMulticast: otPacketsAndBytes, - ///< The counters for outbound unicast. - pub mOutboundUnicast: otPacketsAndBytes, - ///< The counters for outbound multicast. - pub mOutboundMulticast: otPacketsAndBytes, - ///< The counters for inbound Internet when DHCPv6 PD enabled. - pub mInboundInternet: otPacketsAndBytes, - ///< The counters for outbound Internet when DHCPv6 PD enabled. - pub mOutboundInternet: otPacketsAndBytes, - ///< The number of received RA packets. - pub mRaRx: u32, - ///< The number of RA packets successfully transmitted. - pub mRaTxSuccess: u32, - ///< The number of RA packets failed to transmit. - pub mRaTxFailure: u32, - ///< The number of received RS packets. - pub mRsRx: u32, - ///< The number of RS packets successfully transmitted. - pub mRsTxSuccess: u32, - ///< The number of RS packets failed to transmit. - pub mRsTxFailure: u32, +unsafe extern "C" { + /// Clear all short addresses from the source address match table. + /// + /// @param[in] aInstance The OpenThread instance structure. + pub fn otPlatRadioClearSrcMatchShortEntries(aInstance: *mut otInstance); } unsafe extern "C" { - /// Gets the Border Routing counters. + /// Clear all the extended/long addresses from source address match table. /// - /// `OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE` build-time feature must be enabled. + /// @param[in] aInstance The OpenThread instance structure. + pub fn otPlatRadioClearSrcMatchExtEntries(aInstance: *mut otInstance); +} +unsafe extern "C" { + /// Get the radio supported channel mask that the device is allowed to be on. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aInstance The OpenThread instance structure. /// - /// @returns A pointer to the Border Routing counters. - pub fn otIp6GetBorderRoutingCounters( - aInstance: *mut otInstance, - ) -> *const otBorderRoutingCounters; + /// @returns The radio supported channel mask. + pub fn otPlatRadioGetSupportedChannelMask(aInstance: *mut otInstance) -> u32; } unsafe extern "C" { - /// Resets the Border Routing counters. + /// Gets the radio preferred channel mask that the device prefers to form on. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otIp6ResetBorderRoutingCounters(aInstance: *mut otInstance); + /// @param[in] aInstance The OpenThread instance structure. + /// + /// @returns The radio preferred channel mask. + pub fn otPlatRadioGetPreferredChannelMask(aInstance: *mut otInstance) -> u32; } -/// This callback allows OpenThread to provide specific handlers for certain UDP messages. -/// -/// @retval true The message is handled by this receiver and should not be further processed. -/// @retval false The message is not handled by this receiver. -pub type otUdpHandler = ::core::option::Option< - unsafe extern "C" fn( - aContext: *mut ::core::ffi::c_void, - aMessage: *const otMessage, - aMessageInfo: *const otMessageInfo, - ) -> bool, ->; -/// Represents a UDP receiver. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otUdpReceiver { - ///< A pointer to the next UDP receiver (internal use only). - pub mNext: *mut otUdpReceiver, - ///< A function pointer to the receiver callback. - pub mHandler: otUdpHandler, - ///< A pointer to application-specific context. - pub mContext: *mut ::core::ffi::c_void, +unsafe extern "C" { + /// Enable the radio coex. + /// + /// Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aEnabled TRUE to enable the radio coex, FALSE otherwise. + /// + /// @retval OT_ERROR_NONE Successfully enabled. + /// @retval OT_ERROR_FAILED The radio coex could not be enabled. + pub fn otPlatRadioSetCoexEnabled(aInstance: *mut otInstance, aEnabled: bool) -> otError; } unsafe extern "C" { - /// Adds a UDP receiver. + /// Check whether radio coex is enabled or not. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aUdpReceiver A pointer to the UDP receiver. + /// Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. /// - /// @retval OT_ERROR_NONE The receiver is successfully added. - /// @retval OT_ERROR_ALREADY The UDP receiver was already added. - pub fn otUdpAddReceiver( - aInstance: *mut otInstance, - aUdpReceiver: *mut otUdpReceiver, - ) -> otError; + /// @param[in] aInstance The OpenThread instance structure. + /// + /// @returns TRUE if the radio coex is enabled, FALSE otherwise. + pub fn otPlatRadioIsCoexEnabled(aInstance: *mut otInstance) -> bool; } unsafe extern "C" { - /// Removes a UDP receiver. + /// Get the radio coexistence metrics. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aUdpReceiver A pointer to the UDP receiver. + /// Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. /// - /// @retval OT_ERROR_NONE The receiver is successfully removed. - /// @retval OT_ERROR_NOT_FOUND The UDP receiver was not added. - pub fn otUdpRemoveReceiver( + /// @param[in] aInstance The OpenThread instance structure. + /// @param[out] aCoexMetrics A pointer to the coexistence metrics structure. + /// + /// @retval OT_ERROR_NONE Successfully retrieved the coex metrics. + /// @retval OT_ERROR_INVALID_ARGS @p aCoexMetrics was NULL. + pub fn otPlatRadioGetCoexMetrics( aInstance: *mut otInstance, - aUdpReceiver: *mut otUdpReceiver, + aCoexMetrics: *mut otRadioCoexMetrics, ) -> otError; } unsafe extern "C" { - /// Sends a UDP message without socket. + /// Enable or disable CSL receiver. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aMessage A pointer to a message without UDP header. - /// @param[in] aMessageInfo A pointer to a message info associated with @p aMessage. + /// Regarding @p aExtAddr, this function assumes big-endian byte order. Note that this differs from + /// `otPlatRadioSetExtendedAddress()`, `otPlatRadioAddSrcMatchExtEntry()`, and `otPlatRadioClearSrcMatchExtEntry()`, + /// which use little-endian byte order for the Extended MAC address. /// - /// @retval OT_ERROR_NONE Successfully enqueued the message into an output interface. - /// @retval OT_ERROR_NO_BUFS Insufficient available buffer to add the IPv6 headers. - /// @retval OT_ERROR_INVALID_ARGS Invalid arguments are given. - pub fn otUdpSendDatagram( + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aCslPeriod CSL period, 0 for disabling CSL. CSL period is in unit of 10 symbols. + /// @param[in] aShortAddr The short source address of CSL receiver's peer. + /// @param[in] aExtAddr The extended source address of CSL receiver's peer. The @p aExtAddr assumes big-endian + /// byte order. + /// + /// @note Platforms should use CSL peer addresses to include CSL IE when generating enhanced acks. + /// + /// @retval OT_ERROR_NOT_IMPLEMENTED Radio driver doesn't support CSL. + /// @retval OT_ERROR_FAILED Other platform specific errors. + /// @retval OT_ERROR_NONE Successfully enabled or disabled CSL. + pub fn otPlatRadioEnableCsl( aInstance: *mut otInstance, - aMessage: *mut otMessage, - aMessageInfo: *mut otMessageInfo, - ) -> otError; -} -/// This callback allows OpenThread to inform the application of a received UDP message. -pub type otUdpReceive = ::core::option::Option< - unsafe extern "C" fn( - aContext: *mut ::core::ffi::c_void, - aMessage: *mut otMessage, - aMessageInfo: *const otMessageInfo, - ), ->; -/// Represents a UDP socket. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otUdpSocket { - ///< The local IPv6 socket address. - pub mSockName: otSockAddr, - ///< The peer IPv6 socket address. - pub mPeerName: otSockAddr, - ///< A function pointer to the application callback. - pub mHandler: otUdpReceive, - ///< A pointer to application-specific context. - pub mContext: *mut ::core::ffi::c_void, - ///< A handle to platform's UDP. - pub mHandle: *mut ::core::ffi::c_void, - ///< A pointer to the next UDP socket (internal use only). - pub mNext: *mut otUdpSocket, + aCslPeriod: u32, + aShortAddr: otShortAddress, + aExtAddr: *const otExtAddress, + ) -> otError; } -///< Unspecified network interface. -pub const otNetifIdentifier_OT_NETIF_UNSPECIFIED: otNetifIdentifier = 0; -///< The Thread interface. -pub const otNetifIdentifier_OT_NETIF_THREAD: otNetifIdentifier = 1; -///< The Backbone interface. -pub const otNetifIdentifier_OT_NETIF_BACKBONE: otNetifIdentifier = 2; -/// Defines the OpenThread network interface identifiers. -pub type otNetifIdentifier = ::core::ffi::c_uint; unsafe extern "C" { - /// Allocate a new message buffer for sending a UDP message. - /// - /// @note If @p aSettings is 'NULL', the link layer security is enabled and the message priority is set to - /// OT_MESSAGE_PRIORITY_NORMAL by default. + /// Reset CSL receiver in the platform. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aSettings A pointer to the message settings or NULL to use default settings. + /// @note Defaults to `otPlatRadioEnableCsl(aInstance,0, Mac::kShortAddrInvalid, NULL);` /// - /// @returns A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid. + /// @param[in] aInstance The OpenThread instance structure. /// - /// @sa otMessageFree - pub fn otUdpNewMessage( - aInstance: *mut otInstance, - aSettings: *const otMessageSettings, - ) -> *mut otMessage; + /// @retval OT_ERROR_NOT_IMPLEMENTED Radio driver doesn't support CSL. + /// @retval OT_ERROR_FAILED Other platform specific errors. + /// @retval OT_ERROR_NONE Successfully disabled CSL. + pub fn otPlatRadioResetCsl(aInstance: *mut otInstance) -> otError; } unsafe extern "C" { - /// Open a UDP/IPv6 socket. + /// Update CSL sample time in radio driver. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aSocket A pointer to a UDP socket structure. - /// @param[in] aCallback A pointer to the application callback function. - /// @param[in] aContext A pointer to application-specific context. + /// Sample time is stored in radio driver as a copy to calculate phase when + /// sending ACK with CSL IE. The CSL sample (window) of the CSL receiver extends + /// before and after the sample time. The CSL sample time marks a timestamp in + /// the CSL sample window when a frame should be received in "ideal conditions" + /// if there would be no inaccuracy/clock-drift. /// - /// @retval OT_ERROR_NONE Successfully opened the socket. - /// @retval OT_ERROR_FAILED Failed to open the socket. - pub fn otUdpOpen( - aInstance: *mut otInstance, - aSocket: *mut otUdpSocket, - aCallback: otUdpReceive, - aContext: *mut ::core::ffi::c_void, - ) -> otError; + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aCslSampleTime The next sample time, in microseconds. It is + /// the time when the first symbol of the MHR of + /// the frame is expected. + pub fn otPlatRadioUpdateCslSampleTime(aInstance: *mut otInstance, aCslSampleTime: u32); } unsafe extern "C" { - /// Check if a UDP socket is open. + /// Get the current estimated worst case accuracy (maximum ± deviation from the + /// nominal frequency) of the local radio clock in units of PPM. This is the + /// clock used to schedule CSL operations. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aSocket A pointer to a UDP socket structure. + /// @note Implementations MAY estimate this value based on current operating + /// conditions (e.g. temperature). /// - /// @returns Whether the UDP socket is open. - pub fn otUdpIsOpen(aInstance: *mut otInstance, aSocket: *const otUdpSocket) -> bool; + /// In case the implementation does not estimate the current value but returns a + /// fixed value, this value MUST be the worst-case accuracy over all possible + /// foreseen operating conditions (temperature, pressure, etc) of the + /// implementation. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The current CSL rx/tx scheduling drift, in PPM. + pub fn otPlatRadioGetCslAccuracy(aInstance: *mut otInstance) -> u8; } unsafe extern "C" { - /// Close a UDP/IPv6 socket. + /// The fixed uncertainty (i.e. random jitter) of the arrival time of CSL + /// transmissions received by this device in units of 10 microseconds. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aSocket A pointer to a UDP socket structure. + /// This designates the worst case constant positive or negative deviation of + /// the actual arrival time of a transmission from the transmission time + /// calculated relative to the local radio clock independent of elapsed time. In + /// addition to uncertainty accumulated over elapsed time, the CSL channel sample + /// ("RX window") must be extended by twice this deviation such that an actual + /// transmission is guaranteed to be detected by the local receiver in the + /// presence of random arrival time jitter. /// - /// @retval OT_ERROR_NONE Successfully closed the socket. - /// @retval OT_ERROR_FAILED Failed to close UDP Socket. - pub fn otUdpClose(aInstance: *mut otInstance, aSocket: *mut otUdpSocket) -> otError; + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The CSL Uncertainty in units of 10 us. + pub fn otPlatRadioGetCslUncertainty(aInstance: *mut otInstance) -> u8; } unsafe extern "C" { - /// Bind a UDP/IPv6 socket. + /// Set the max transmit power for a specific channel. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aSocket A pointer to a UDP socket structure. - /// @param[in] aSockName A pointer to an IPv6 socket address structure. - /// @param[in] aNetif The network interface to bind. + /// @note This function will be deprecated in October 2027. It is recommended to use the function + /// `otPlatRadioSetChannelTargetPower()`. /// - /// @retval OT_ERROR_NONE Bind operation was successful. - /// @retval OT_ERROR_FAILED Failed to bind UDP socket. - pub fn otUdpBind( + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aChannel The radio channel. + /// @param[in] aMaxPower The max power in dBm, passing OT_RADIO_RSSI_INVALID will disable this channel. + /// + /// @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented + /// @retval OT_ERROR_INVALID_ARGS The specified channel is not valid. + /// @retval OT_ERROR_FAILED Other platform specific errors. + /// @retval OT_ERROR_NONE Successfully set max transmit power. + pub fn otPlatRadioSetChannelMaxTransmitPower( aInstance: *mut otInstance, - aSocket: *mut otUdpSocket, - aSockName: *const otSockAddr, - aNetif: otNetifIdentifier, + aChannel: u8, + aMaxPower: i8, ) -> otError; } unsafe extern "C" { - /// Connect a UDP/IPv6 socket. + /// Set the region code. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aSocket A pointer to a UDP socket structure. - /// @param[in] aSockName A pointer to an IPv6 socket address structure. + /// The radio region format is the 2-bytes ascii representation of the + /// ISO 3166 alpha-2 code. /// - /// @retval OT_ERROR_NONE Connect operation was successful. - /// @retval OT_ERROR_FAILED Failed to connect UDP socket. - pub fn otUdpConnect( - aInstance: *mut otInstance, - aSocket: *mut otUdpSocket, - aSockName: *const otSockAddr, - ) -> otError; + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aRegionCode The radio region code. The `aRegionCode >> 8` is first ascii char + /// and the `aRegionCode & 0xff` is the second ascii char. + /// + /// @retval OT_ERROR_FAILED Other platform specific errors. + /// @retval OT_ERROR_NONE Successfully set region code. + /// @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. + pub fn otPlatRadioSetRegion(aInstance: *mut otInstance, aRegionCode: u16) -> otError; } unsafe extern "C" { - /// Send a UDP/IPv6 message. + /// Get the region code. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aSocket A pointer to a UDP socket structure. - /// @param[in] aMessage A pointer to a message buffer. - /// @param[in] aMessageInfo A pointer to a message info structure. + /// The radio region format is the 2-bytes ascii representation of the + /// ISO 3166 alpha-2 code. /// - /// If the return value is OT_ERROR_NONE, OpenThread takes ownership of @p aMessage, and the caller should no longer - /// reference @p aMessage. If the return value is not OT_ERROR_NONE, the caller retains ownership of @p aMessage, - /// including freeing @p aMessage if the message buffer is no longer needed. + /// @param[in] aInstance The OpenThread instance structure. + /// @param[out] aRegionCode The radio region. /// - /// @retval OT_ERROR_NONE The message is successfully scheduled for sending. - /// @retval OT_ERROR_INVALID_ARGS Invalid arguments are given. - /// @retval OT_ERROR_NO_BUFS Insufficient available buffer to add the UDP and IPv6 headers. - pub fn otUdpSend( + /// @retval OT_ERROR_INVALID_ARGS @p aRegionCode is NULL. + /// @retval OT_ERROR_FAILED Other platform specific errors. + /// @retval OT_ERROR_NONE Successfully got region code. + /// @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. + pub fn otPlatRadioGetRegion(aInstance: *mut otInstance, aRegionCode: *mut u16) -> otError; +} +unsafe extern "C" { + /// Enable/disable or update Enhanced-ACK Based Probing in radio for a specific Initiator. + /// + /// After Enhanced-ACK Based Probing is configured by a specific Probing Initiator, the Enhanced-ACK sent to that + /// node should include Vendor-Specific IE containing Link Metrics data. This function informs the radio to start/stop to + /// collect Link Metrics data and include Vendor-Specific IE that containing the data in Enhanced-ACK sent to that + /// Probing Initiator. + /// + /// Regarding @p aExtAddress, this function assumes big-endian byte order. Note that this differs from + /// `otPlatRadioSetExtendedAddress()`, `otPlatRadioAddSrcMatchExtEntry()`, and `otPlatRadioClearSrcMatchExtEntry()`, + /// which use little-endian byte order for the Extended MAC address. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aLinkMetrics This parameter specifies what metrics to query. Per spec 4.11.3.4.4.6, at most 2 metrics + /// can be specified. The probing would be disabled if @p `aLinkMetrics` is bitwise 0. + /// @param[in] aShortAddress The short address of the Probing Initiator. + /// @param[in] aExtAddress The extended source address of the Probing Initiator. @p aExtAddress MUST NOT be `NULL`. + /// The @p aExtAddress assumes big-endian byte order. + /// + /// @retval OT_ERROR_NONE Successfully configured the Enhanced-ACK Based Probing. + /// @retval OT_ERROR_INVALID_ARGS @p aExtAddress is `NULL`. + /// @retval OT_ERROR_NOT_FOUND The Initiator indicated by @p aShortAddress is not found when trying to clear. + /// @retval OT_ERROR_NO_BUFS No more Initiator can be supported. + /// @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. + pub fn otPlatRadioConfigureEnhAckProbing( aInstance: *mut otInstance, - aSocket: *mut otUdpSocket, - aMessage: *mut otMessage, - aMessageInfo: *const otMessageInfo, + aLinkMetrics: otLinkMetrics, + aShortAddress: otShortAddress, + aExtAddress: *const otExtAddress, ) -> otError; } unsafe extern "C" { - /// Gets the head of linked list of UDP Sockets. + /// Add a calibrated power of the specified channel to the power calibration table. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @note This API is an optional radio platform API. It's up to the platform layer to implement it. /// - /// @returns A pointer to the head of UDP Socket linked list. - pub fn otUdpGetSockets(aInstance: *mut otInstance) -> *mut otUdpSocket; + /// The @p aActualPower is the actual measured output power when the parameters of the radio hardware modules + /// are set to the @p aRawPowerSetting. + /// + /// The raw power setting is an opaque byte array. OpenThread doesn't define the format of the raw power setting. + /// Its format is radio hardware related and it should be defined by the developers in the platform radio driver. + /// For example, if the radio hardware contains both the radio chip and the FEM chip, the raw power setting can be + /// a combination of the radio power register and the FEM gain value. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aChannel The radio channel. + /// @param[in] aActualPower The actual power in 0.01dBm. + /// @param[in] aRawPowerSetting A pointer to the raw power setting byte array. + /// @param[in] aRawPowerSettingLength The length of the @p aRawPowerSetting. + /// + /// @retval OT_ERROR_NONE Successfully added the calibrated power to the power calibration table. + /// @retval OT_ERROR_NO_BUFS No available entry in the power calibration table. + /// @retval OT_ERROR_INVALID_ARGS The @p aChannel, @p aActualPower or @p aRawPowerSetting is invalid or the + /// @p aActualPower already exists in the power calibration table. + /// @retval OT_ERROR_NOT_IMPLEMENTED This feature is not implemented. + pub fn otPlatRadioAddCalibratedPower( + aInstance: *mut otInstance, + aChannel: u8, + aActualPower: i16, + aRawPowerSetting: *const u8, + aRawPowerSettingLength: u16, + ) -> otError; } -/// Pointer delivers the UDP packet to host and host should send the packet through its own network stack. -/// -/// @param[in] aMessage A pointer to the UDP Message. -/// @param[in] aPeerPort The destination UDP port. -/// @param[in] aPeerAddr A pointer to the destination IPv6 address. -/// @param[in] aSockPort The source UDP port. -/// @param[in] aContext A pointer to application-specific context. -pub type otUdpForwarder = ::core::option::Option< - unsafe extern "C" fn( - aMessage: *mut otMessage, - aPeerPort: u16, - aPeerAddr: *mut otIp6Address, - aSockPort: u16, - aContext: *mut ::core::ffi::c_void, - ), ->; unsafe extern "C" { - /// Set UDP forward callback to deliver UDP packets to host. + /// Clear all calibrated powers from the power calibration table. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aForwarder A pointer to a function called to forward UDP packet to host. - /// @param[in] aContext A pointer to application-specific context. - pub fn otUdpForwardSetForwarder( - aInstance: *mut otInstance, - aForwarder: otUdpForwarder, - aContext: *mut ::core::ffi::c_void, - ); + /// @note This API is an optional radio platform API. It's up to the platform layer to implement it. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// + /// @retval OT_ERROR_NONE Successfully cleared all calibrated powers from the power calibration table. + /// @retval OT_ERROR_NOT_IMPLEMENTED This feature is not implemented. + pub fn otPlatRadioClearCalibratedPowers(aInstance: *mut otInstance) -> otError; } unsafe extern "C" { - /// Handle a UDP packet received from host. + /// Set the target power for the given channel. + /// + /// @note This API is an optional radio platform API. It's up to the platform layer to implement it. + /// If this function and `otPlatRadioSetTransmitPower()` are implemented at the same time: + /// - If neither of these two functions is called, the radio outputs the platform-defined default power. + /// - If both functions are called, the last one to be called takes effect. + /// + /// The radio driver should set the actual output power to be less than or equal to the @p aTargetPower and as close + /// as possible to the @p aTargetPower. If the @p aTargetPower is lower than the minimum output power supported + /// by the platform, the output power should be set to the minimum output power supported by the platform. If the + /// @p aTargetPower is higher than the maximum output power supported by the platform, the output power should be + /// set to the maximum output power supported by the platform. If the @p aTargetPower is set to `INT16_MAX`, the + /// corresponding channel is disabled. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aMessage A pointer to the UDP Message. - /// @param[in] aPeerPort The source UDP port. - /// @param[in] aPeerAddr A pointer to the source address. - /// @param[in] aSockPort The destination UDP port. + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aChannel The radio channel. + /// @param[in] aTargetPower The target power in 0.01dBm. /// - /// @warning No matter the call success or fail, the message is freed. - pub fn otUdpForwardReceive( + /// @retval OT_ERROR_NONE Successfully set the target power. + /// @retval OT_ERROR_INVALID_ARGS The @p aChannel is invalid. + /// @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. + pub fn otPlatRadioSetChannelTargetPower( aInstance: *mut otInstance, - aMessage: *mut otMessage, - aPeerPort: u16, - aPeerAddr: *const otIp6Address, - aSockPort: u16, - ); + aChannel: u8, + aTargetPower: i16, + ) -> otError; } unsafe extern "C" { - /// Determines if the given UDP port is exclusively opened by OpenThread API. + /// Get the raw power setting for the given channel. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] port UDP port number to verify. + /// @note OpenThread `src/core/utils` implements a default implementation of the API `otPlatRadioAddCalibratedPower()`, + /// `otPlatRadioClearCalibratedPowers()` and `otPlatRadioSetChannelTargetPower()`. This API is provided by + /// the default implementation to get the raw power setting for the given channel. If the platform doesn't + /// use the default implementation, it can ignore this API. /// - /// @retval true The port is being used exclusively by OpenThread. - /// @retval false The port is not used by any of the OpenThread API or is shared (e.g. is Backbone socket). - pub fn otUdpIsPortInUse(aInstance: *mut otInstance, port: u16) -> bool; + /// Platform radio layer should parse the raw power setting based on the radio layer defined format and set the + /// parameters of each radio hardware module. + /// + /// @param[in] aInstance The OpenThread instance structure. + /// @param[in] aChannel The radio channel. + /// @param[out] aRawPowerSetting A pointer to the raw power setting byte array. + /// @param[in,out] aRawPowerSettingLength On input, a pointer to the size of @p aRawPowerSetting. + /// On output, a pointer to the length of the raw power setting data. + /// + /// @retval OT_ERROR_NONE Successfully got the target power. + /// @retval OT_ERROR_INVALID_ARGS The @p aChannel is invalid, @p aRawPowerSetting or @p aRawPowerSettingLength is NULL + /// or @aRawPowerSettingLength is too short. + /// @retval OT_ERROR_NOT_FOUND The raw power setting for the @p aChannel was not found. + pub fn otPlatRadioGetRawPowerSetting( + aInstance: *mut otInstance, + aChannel: u8, + aRawPowerSetting: *mut u8, + aRawPowerSettingLength: *mut u16, + ) -> otError; } /// @struct otNetworkKey /// /// Represents a Thread Network Key. #[repr(C, packed)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otNetworkKey { ///< Byte values pub m8: [u8; 16usize], @@ -6137,14 +5275,14 @@ pub type otNetworkKeyRef = otCryptoKeyRef; /// /// The `otNetworkName` is a null terminated C string (i.e., `m8` char array MUST end with null char `\0`). #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otNetworkName { ///< Byte values. The `+ 1` is for null char. pub m8: [::core::ffi::c_char; 17usize], } /// Represents an Extended PAN ID. #[repr(C, packed)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otExtendedPanId { ///< Byte values pub m8: [u8; 8usize], @@ -6153,7 +5291,7 @@ pub struct otExtendedPanId { pub type otMeshLocalPrefix = otIp6NetworkPrefix; /// Represents PSKc. #[repr(C, packed)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otPskc { ///< Byte values pub m8: [u8; 16usize], @@ -6162,7 +5300,7 @@ pub struct otPskc { pub type otPskcRef = otCryptoKeyRef; /// Represent Security Policy. #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otSecurityPolicy { ///< The value for thrKeyRotation in units of hours. pub mRotationTime: u16, @@ -6565,11 +5703,13 @@ impl otSecurityPolicy { __bindgen_bitfield_unit } } -/// Represents Channel Mask. +/// Represents a Channel Mask. +/// +/// The least significant bit (LSB), also referred to as bit 0, corresponds to channel number 0, and so on. pub type otChannelMask = u32; /// Represents presence of different components in Active or Pending Operational Dataset. #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otOperationalDatasetComponents { ///< TRUE if Active Timestamp is present, FALSE otherwise. pub mIsActiveTimestampPresent: bool, @@ -6600,7 +5740,7 @@ pub struct otOperationalDatasetComponents { } /// Represents a Thread Dataset timestamp component. #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otTimestamp { pub mSeconds: u64, pub mTicks: u16, @@ -6610,7 +5750,7 @@ pub struct otTimestamp { /// /// Components in Dataset are optional. `mComponents` structure specifies which components are present in the Dataset. #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otOperationalDataset { ///< Active Timestamp pub mActiveTimestamp: otTimestamp, @@ -6652,6 +5792,15 @@ pub struct otOperationalDatasetTlvs { ///< Size of Operational Dataset in bytes. pub mLength: u8, } +impl Default for otOperationalDatasetTlvs { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} ///< meshcop Channel TLV pub const otMeshcopTlvType_OT_MESHCOP_TLV_CHANNEL: otMeshcopTlvType = 0; ///< meshcop Pan Id TLV @@ -7063,7 +6212,7 @@ pub const otJoinerState_OT_JOINER_STATE_JOINED: otJoinerState = 5; pub type otJoinerState = ::core::ffi::c_uint; /// Represents a Joiner Discerner. #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otJoinerDiscerner { ///< Discerner value (the lowest `mLength` bits specify the discerner). pub mValue: u64, @@ -7187,7 +6336,7 @@ pub const otCommissionerJoinerEvent_OT_COMMISSIONER_JOINER_REMOVED: otCommission pub type otCommissionerJoinerEvent = ::core::ffi::c_uint; /// Represents the steering data. #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otSteeringData { ///< Length of steering data (bytes) pub mLength: u8, @@ -7196,7 +6345,7 @@ pub struct otSteeringData { } /// Represents a Commissioning Dataset. #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otCommissioningDataset { ///< Border Router RLOC16 pub mLocator: u16, @@ -7415,6 +6564,15 @@ pub struct otJoinerPskd { ///< Char string array (must be null terminated - +1 is for null char). pub m8: [::core::ffi::c_char; 33usize], } +impl Default for otJoinerPskd { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} ///< Accept any Joiner (no EUI64 or Discerner is specified). pub const otJoinerInfoType_OT_JOINER_INFO_TYPE_ANY: otJoinerInfoType = 0; ///< Joiner EUI-64 is specified (`mSharedId.mEui64` in `otJoinerInfo`). @@ -7444,6 +6602,24 @@ pub union otJoinerInfo__bindgen_ty_1 { ///< Joiner Discerner (when `mType` is `OT_JOINER_INFO_TYPE_DISCERNER`) pub mDiscerner: otJoinerDiscerner, } +impl Default for otJoinerInfo__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl Default for otJoinerInfo { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} /// Pointer is called whenever the commissioner state changes. /// /// @param[in] aState The Commissioner state. @@ -7787,7 +6963,7 @@ pub const otMacFilterAddressMode_OT_MAC_FILTER_ADDRESS_MODE_DENYLIST: otMacFilte pub type otMacFilterAddressMode = ::core::ffi::c_uint; /// Represents a Mac Filter entry. #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otMacFilterEntry { ///< IEEE 802.15.4 Extended Address pub mExtAddress: otExtAddress, @@ -7796,7 +6972,7 @@ pub struct otMacFilterEntry { } /// Represents the MAC layer counters. #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otMacCounters { /// The total number of unique MAC frame transmission requests. /// @@ -7926,7 +7102,7 @@ pub struct otMacCounters { /// Represents a received IEEE 802.15.4 Beacon. #[repr(C)] #[repr(align(4))] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otActiveScanResult { ///< IEEE 802.15.4 Extended Address pub mExtAddress: otExtAddress, @@ -8112,7 +7288,7 @@ impl otActiveScanResult { } /// Represents an energy scan result. #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Default, Copy, Clone)] pub struct otEnergyScanResult { ///< IEEE 802.15.4 Channel pub mChannel: u8, @@ -8350,9 +7526,17 @@ unsafe extern "C" { /// /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @returns A pointer to the IEEE 802.15.4 Short Address. + /// @returns The IEEE 802.15.4 Short Address. pub fn otLinkGetShortAddress(aInstance: *mut otInstance) -> otShortAddress; } +unsafe extern "C" { + /// Get the IEEE 802.15.4 alternate short address. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The alternate short address, or `OT_RADIO_INVALID_SHORT_ADDR` (0xfffe) if there is no alternate address. + pub fn otLinkGetAlternateShortAddress(aInstance: *mut otInstance) -> otShortAddress; +} unsafe extern "C" { /// Returns the maximum number of frame retries during direct transmission. /// @@ -8836,7 +8020,7 @@ unsafe extern "C" { /// @param[out] aRegionCode The radio region code. The `aRegionCode >> 8` is first ascii char /// and the `aRegionCode & 0xff` is the second ascii char. /// - /// @retval OT_ERROR_INVALID_ARGS @p aRegionCode is nullptr. + /// @retval OT_ERROR_INVALID_ARGS @p aRegionCode is NULL. /// @retval OT_ERROR_FAILED Other platform specific errors. /// @retval OT_ERROR_NONE Successfully got region code. /// @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. @@ -8866,26 +8050,250 @@ unsafe extern "C" { /// @retval OT_ERROR_INVALID_ARGS Invalid @p aChannel. pub fn otLinkSetWakeupChannel(aInstance: *mut otInstance, aChannel: u8) -> otError; } -///< The Thread stack is disabled. -pub const otDeviceRole_OT_DEVICE_ROLE_DISABLED: otDeviceRole = 0; -///< Not currently participating in a Thread network/partition. -pub const otDeviceRole_OT_DEVICE_ROLE_DETACHED: otDeviceRole = 1; -///< The Thread Child role. -pub const otDeviceRole_OT_DEVICE_ROLE_CHILD: otDeviceRole = 2; -///< The Thread Router role. -pub const otDeviceRole_OT_DEVICE_ROLE_ROUTER: otDeviceRole = 3; -///< The Thread Leader role. -pub const otDeviceRole_OT_DEVICE_ROLE_LEADER: otDeviceRole = 4; -/// Represents a Thread device role. -pub type otDeviceRole = ::core::ffi::c_uint; -/// Represents an MLE Link Mode configuration. +unsafe extern "C" { + /// Enables or disables listening for wake-up frames. + /// + /// Requires `OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE`. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aEnable true to enable listening for wake-up frames, or false otherwise. + /// + /// @retval OT_ERROR_NONE Successfully enabled / disabled the listening for wake-up frames. + /// @retval OT_ERROR_INVALID_ARGS The listen duration is greater than the listen interval. + /// @retval OT_ERROR_INVALID_STATE Could not enable listening for wake-up frames due to bad configuration. + pub fn otLinkSetWakeUpListenEnabled(aInstance: *mut otInstance, aEnable: bool) -> otError; +} +unsafe extern "C" { + /// Returns whether listening for wake-up frames is enabled. + /// + /// Requires `OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE`. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @retval TRUE If listening for wake-up frames is enabled. + /// @retval FALSE If listening for wake-up frames is not enabled. + pub fn otLinkIsWakeupListenEnabled(aInstance: *mut otInstance) -> bool; +} +unsafe extern "C" { + /// Get the wake-up listen parameters. + /// + /// Requires `OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE`. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aInterval A pointer to return the wake-up listen interval in microseconds. + /// @param[out] aDuration A pointer to return the wake-up listen duration in microseconds. + pub fn otLinkGetWakeupListenParameters( + aInstance: *mut otInstance, + aInterval: *mut u32, + aDuration: *mut u32, + ); +} +unsafe extern "C" { + /// Set the wake-up listen parameters. + /// + /// The listen interval must be greater than the listen duration. + /// The listen duration must be greater or equal than the minimum supported. + /// + /// Requires `OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE`. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aInterval The wake-up listen interval in microseconds. + /// @param[in] aDuration The wake-up listen duration in microseconds. + /// + /// @retval OT_ERROR_NONE Successfully set the wake-up listen parameters. + /// @retval OT_ERROR_INVALID_ARGS Invalid wake-up listen parameters. + pub fn otLinkSetWakeupListenParameters( + aInstance: *mut otInstance, + aInterval: u32, + aDuration: u32, + ) -> otError; +} +unsafe extern "C" { + /// Sets the rx-on-when-idle state. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aRxOnWhenIdle TRUE to keep radio in Receive state, FALSE to put to Sleep state during idle periods. + /// + /// @retval OT_ERROR_NONE If successful. + /// @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled. + pub fn otLinkSetRxOnWhenIdle(aInstance: *mut otInstance, aRxOnWhenIdle: bool) -> otError; +} +///< The Thread stack is disabled. +pub const otDeviceRole_OT_DEVICE_ROLE_DISABLED: otDeviceRole = 0; +///< Not currently participating in a Thread network/partition. +pub const otDeviceRole_OT_DEVICE_ROLE_DETACHED: otDeviceRole = 1; +///< The Thread Child role. +pub const otDeviceRole_OT_DEVICE_ROLE_CHILD: otDeviceRole = 2; +///< The Thread Router role. +pub const otDeviceRole_OT_DEVICE_ROLE_ROUTER: otDeviceRole = 3; +///< The Thread Leader role. +pub const otDeviceRole_OT_DEVICE_ROLE_LEADER: otDeviceRole = 4; +/// Represents a Thread device role. +pub type otDeviceRole = ::core::ffi::c_uint; +/// Represents an MLE Link Mode configuration. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otLinkModeConfig { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl otLinkModeConfig { + #[inline] + pub fn mRxOnWhenIdle(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_mRxOnWhenIdle(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mRxOnWhenIdle_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 0usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mRxOnWhenIdle_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mDeviceType(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mDeviceType(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mDeviceType_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 1usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mDeviceType_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 1usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mNetworkData(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mNetworkData(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mNetworkData_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 2usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mNetworkData_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 2usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn new_bitfield_1( + mRxOnWhenIdle: bool, + mDeviceType: bool, + mNetworkData: bool, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let mRxOnWhenIdle: u8 = unsafe { ::core::mem::transmute(mRxOnWhenIdle) }; + mRxOnWhenIdle as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mDeviceType: u8 = unsafe { ::core::mem::transmute(mDeviceType) }; + mDeviceType as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mNetworkData: u8 = unsafe { ::core::mem::transmute(mNetworkData) }; + mNetworkData as u64 + }); + __bindgen_bitfield_unit + } +} +/// Holds diagnostic information for a neighboring Thread node #[repr(C)] -#[derive(Copy, Clone)] -pub struct otLinkModeConfig { +#[derive(Default, Copy, Clone)] +pub struct otNeighborInfo { + ///< IEEE 802.15.4 Extended Address + pub mExtAddress: otExtAddress, + ///< Seconds since last heard + pub mAge: u32, + ///< Seconds since link establishment (requires `CONFIG_UPTIME_ENABLE`) + pub mConnectionTime: u32, + ///< RLOC16 + pub mRloc16: u16, + ///< Link Frame Counter + pub mLinkFrameCounter: u32, + ///< MLE Frame Counter + pub mMleFrameCounter: u32, + ///< Link Quality In + pub mLinkQualityIn: u8, + ///< Average RSSI + pub mAverageRssi: i8, + ///< Last observed RSSI + pub mLastRssi: i8, + ///< Link Margin + pub mLinkMargin: u8, + ///< Frame error rate (0xffff->100%). Requires error tracking feature. + pub mFrameErrorRate: u16, + ///< (IPv6) msg error rate (0xffff->100%). Requires error tracking feature. + pub mMessageErrorRate: u16, + ///< Thread version of the neighbor + pub mVersion: u16, pub _bitfield_align_1: [u8; 0], pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: u8, } -impl otLinkModeConfig { +impl otNeighborInfo { #[inline] pub fn mRxOnWhenIdle(&self) -> bool { unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } @@ -8898,7 +8306,212 @@ impl otLinkModeConfig { } } #[inline] - pub unsafe fn mRxOnWhenIdle_raw(this: *const Self) -> bool { + pub unsafe fn mRxOnWhenIdle_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 0usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mRxOnWhenIdle_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mFullThreadDevice(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mFullThreadDevice(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mFullThreadDevice_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 1usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mFullThreadDevice_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 1usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mFullNetworkData(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mFullNetworkData(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mFullNetworkData_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 2usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mFullNetworkData_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 2usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mIsChild(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_mIsChild(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mIsChild_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 3usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mIsChild_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 3usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn new_bitfield_1( + mRxOnWhenIdle: bool, + mFullThreadDevice: bool, + mFullNetworkData: bool, + mIsChild: bool, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let mRxOnWhenIdle: u8 = unsafe { ::core::mem::transmute(mRxOnWhenIdle) }; + mRxOnWhenIdle as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mFullThreadDevice: u8 = unsafe { ::core::mem::transmute(mFullThreadDevice) }; + mFullThreadDevice as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mFullNetworkData: u8 = unsafe { ::core::mem::transmute(mFullNetworkData) }; + mFullNetworkData as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let mIsChild: u8 = unsafe { ::core::mem::transmute(mIsChild) }; + mIsChild as u64 + }); + __bindgen_bitfield_unit + } +} +pub type otNeighborInfoIterator = i16; +/// Represents the Thread Leader Data. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otLeaderData { + ///< Partition ID + pub mPartitionId: u32, + ///< Leader Weight + pub mWeighting: u8, + ///< Full Network Data Version + pub mDataVersion: u8, + ///< Stable Network Data Version + pub mStableDataVersion: u8, + ///< Leader Router ID + pub mLeaderRouterId: u8, +} +/// Holds diagnostic information for a Thread Router +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otRouterInfo { + ///< IEEE 802.15.4 Extended Address + pub mExtAddress: otExtAddress, + ///< RLOC16 + pub mRloc16: u16, + ///< Router ID + pub mRouterId: u8, + ///< Next hop to router + pub mNextHop: u8, + ///< Path cost to router + pub mPathCost: u8, + ///< Link Quality In + pub mLinkQualityIn: u8, + ///< Link Quality Out + pub mLinkQualityOut: u8, + ///< Time last heard + pub mAge: u8, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + ///< Thread version + pub mVersion: u8, + ///< CSL clock accuracy, in ± ppm + pub mCslClockAccuracy: u8, + ///< CSL uncertainty, in ±10 us + pub mCslUncertainty: u8, +} +impl otRouterInfo { + #[inline] + pub fn mAllocated(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_mAllocated(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mAllocated_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), @@ -8908,7 +8521,7 @@ impl otLinkModeConfig { } } #[inline] - pub unsafe fn set_mRxOnWhenIdle_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mAllocated_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( @@ -8920,18 +8533,18 @@ impl otLinkModeConfig { } } #[inline] - pub fn mDeviceType(&self) -> bool { + pub fn mLinkEstablished(&self) -> bool { unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } } #[inline] - pub fn set_mDeviceType(&mut self, val: bool) { + pub fn set_mLinkEstablished(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(1usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mDeviceType_raw(this: *const Self) -> bool { + pub unsafe fn mLinkEstablished_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), @@ -8941,7 +8554,7 @@ impl otLinkModeConfig { } } #[inline] - pub unsafe fn set_mDeviceType_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mLinkEstablished_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( @@ -8953,1236 +8566,2308 @@ impl otLinkModeConfig { } } #[inline] - pub fn mNetworkData(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } - } - #[inline] - pub fn set_mNetworkData(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(2usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mNetworkData_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 2usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mNetworkData_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 2usize, - 1u8, - val as u64, - ) - } - } - #[inline] pub fn new_bitfield_1( - mRxOnWhenIdle: bool, - mDeviceType: bool, - mNetworkData: bool, + mAllocated: bool, + mLinkEstablished: bool, ) -> __BindgenBitfieldUnit<[u8; 1usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 1u8, { - let mRxOnWhenIdle: u8 = unsafe { ::core::mem::transmute(mRxOnWhenIdle) }; - mRxOnWhenIdle as u64 + let mAllocated: u8 = unsafe { ::core::mem::transmute(mAllocated) }; + mAllocated as u64 }); __bindgen_bitfield_unit.set(1usize, 1u8, { - let mDeviceType: u8 = unsafe { ::core::mem::transmute(mDeviceType) }; - mDeviceType as u64 - }); - __bindgen_bitfield_unit.set(2usize, 1u8, { - let mNetworkData: u8 = unsafe { ::core::mem::transmute(mNetworkData) }; - mNetworkData as u64 + let mLinkEstablished: u8 = unsafe { ::core::mem::transmute(mLinkEstablished) }; + mLinkEstablished as u64 }); __bindgen_bitfield_unit } } -/// Holds diagnostic information for a neighboring Thread node -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otNeighborInfo { - ///< IEEE 802.15.4 Extended Address - pub mExtAddress: otExtAddress, - ///< Seconds since last heard - pub mAge: u32, - ///< Seconds since link establishment (requires `CONFIG_UPTIME_ENABLE`) - pub mConnectionTime: u32, - ///< RLOC16 - pub mRloc16: u16, - ///< Link Frame Counter - pub mLinkFrameCounter: u32, - ///< MLE Frame Counter - pub mMleFrameCounter: u32, - ///< Link Quality In - pub mLinkQualityIn: u8, - ///< Average RSSI - pub mAverageRssi: i8, - ///< Last observed RSSI - pub mLastRssi: i8, - ///< Link Margin - pub mLinkMargin: u8, - ///< Frame error rate (0xffff->100%). Requires error tracking feature. - pub mFrameErrorRate: u16, - ///< (IPv6) msg error rate (0xffff->100%). Requires error tracking feature. - pub mMessageErrorRate: u16, - ///< Thread version of the neighbor - pub mVersion: u16, - pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, - pub __bindgen_padding_0: u8, +/// Represents the IP level counters. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otIpCounters { + ///< The number of IPv6 packets successfully transmitted. + pub mTxSuccess: u32, + ///< The number of IPv6 packets successfully received. + pub mRxSuccess: u32, + ///< The number of IPv6 packets failed to transmit. + pub mTxFailure: u32, + ///< The number of IPv6 packets failed to receive. + pub mRxFailure: u32, +} +/// Represents the Thread MLE counters. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otMleCounters { + ///< Number of times device entered OT_DEVICE_ROLE_DISABLED role. + pub mDisabledRole: u16, + ///< Number of times device entered OT_DEVICE_ROLE_DETACHED role. + pub mDetachedRole: u16, + ///< Number of times device entered OT_DEVICE_ROLE_CHILD role. + pub mChildRole: u16, + ///< Number of times device entered OT_DEVICE_ROLE_ROUTER role. + pub mRouterRole: u16, + ///< Number of times device entered OT_DEVICE_ROLE_LEADER role. + pub mLeaderRole: u16, + ///< Number of attach attempts while device was detached. + pub mAttachAttempts: u16, + ///< Number of changes to partition ID. + pub mPartitionIdChanges: u16, + ///< Number of attempts to attach to a better partition. + pub mBetterPartitionAttachAttempts: u16, + ///< Number of attempts to attach to find a better parent (parent search). + pub mBetterParentAttachAttempts: u16, + ///< Number of milliseconds device has been in OT_DEVICE_ROLE_DISABLED role. + pub mDisabledTime: u64, + ///< Number of milliseconds device has been in OT_DEVICE_ROLE_DETACHED role. + pub mDetachedTime: u64, + ///< Number of milliseconds device has been in OT_DEVICE_ROLE_CHILD role. + pub mChildTime: u64, + ///< Number of milliseconds device has been in OT_DEVICE_ROLE_ROUTER role. + pub mRouterTime: u64, + ///< Number of milliseconds device has been in OT_DEVICE_ROLE_LEADER role. + pub mLeaderTime: u64, + ///< Number of milliseconds tracked by previous counters. + pub mTrackedTime: u64, + /// Number of times device changed its parent. + /// + /// A parent change can happen if device detaches from its current parent and attaches to a different one, or even + /// while device is attached when the periodic parent search feature is enabled (please see option + /// OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE). + pub mParentChanges: u16, +} +/// Represents the MLE Parent Response data. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otThreadParentResponseInfo { + ///< IEEE 802.15.4 Extended Address of the Parent + pub mExtAddr: otExtAddress, + ///< Short address of the Parent + pub mRloc16: u16, + ///< Rssi of the Parent + pub mRssi: i8, + ///< Parent priority + pub mPriority: i8, + ///< Parent Link Quality 3 + pub mLinkQuality3: u8, + ///< Parent Link Quality 2 + pub mLinkQuality2: u8, + ///< Parent Link Quality 1 + pub mLinkQuality1: u8, + ///< Is the node receiving parent response attached + pub mIsAttached: bool, +} +/// This callback informs the application that the detaching process has finished. +/// +/// @param[in] aContext A pointer to application-specific context. +pub type otDetachGracefullyCallback = + ::core::option::Option; +/// Informs the application about the result of waking a Wake-up End Device. +/// +/// @param[in] aError OT_ERROR_NONE Indicates that the Wake-up End Device has been added as a neighbor. +/// OT_ERROR_FAILED Indicates that the Wake-up End Device has not received a wake-up frame, or it +/// has failed the MLE procedure. +/// @param[in] aContext A pointer to application-specific context. +pub type otWakeupCallback = ::core::option::Option< + unsafe extern "C" fn(aError: otError, aContext: *mut ::core::ffi::c_void), +>; +unsafe extern "C" { + /// Starts Thread protocol operation. + /// + /// The interface must be up when calling this function. + /// + /// Calling this function with @p aEnabled set to FALSE stops any ongoing processes of detaching started by + /// otThreadDetachGracefully(). Its callback will be called. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aEnabled TRUE if Thread is enabled, FALSE otherwise. + /// + /// @retval OT_ERROR_NONE Successfully started Thread protocol operation. + /// @retval OT_ERROR_INVALID_STATE The network interface was not up. + pub fn otThreadSetEnabled(aInstance: *mut otInstance, aEnabled: bool) -> otError; +} +unsafe extern "C" { + /// Gets the Thread protocol version. + /// + /// The constants `OT_THREAD_VERSION_*` define the numerical version values. + /// + /// @returns the Thread protocol version. + pub fn otThreadGetVersion() -> u16; +} +unsafe extern "C" { + /// Indicates whether a node is the only router on the network. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @retval TRUE It is the only router in the network. + /// @retval FALSE It is a child or is not a single router in the network. + pub fn otThreadIsSingleton(aInstance: *mut otInstance) -> bool; +} +unsafe extern "C" { + /// Starts a Thread Discovery scan. + /// + /// @note A successful call to this function enables the rx-on-when-idle mode for the entire scan procedure. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aScanChannels A bit vector indicating which channels to scan (e.g. OT_CHANNEL_11_MASK). + /// @param[in] aPanId The PAN ID filter (set to Broadcast PAN to disable filter). + /// @param[in] aJoiner Value of the Joiner Flag in the Discovery Request TLV. + /// @param[in] aEnableEui64Filtering TRUE to filter responses on EUI-64, FALSE otherwise. + /// @param[in] aCallback A pointer to a function called on receiving an MLE Discovery Response or + /// scan completes. + /// @param[in] aCallbackContext A pointer to application-specific context. + /// + /// @retval OT_ERROR_NONE Successfully started a Thread Discovery Scan. + /// @retval OT_ERROR_INVALID_STATE The IPv6 interface is not enabled (netif is not up). + /// @retval OT_ERROR_NO_BUFS Could not allocate message for Discovery Request. + /// @retval OT_ERROR_BUSY Thread Discovery Scan is already in progress. + pub fn otThreadDiscover( + aInstance: *mut otInstance, + aScanChannels: u32, + aPanId: u16, + aJoiner: bool, + aEnableEui64Filtering: bool, + aCallback: otHandleActiveScanResult, + aCallbackContext: *mut ::core::ffi::c_void, + ) -> otError; +} +unsafe extern "C" { + /// Determines if an MLE Thread Discovery is currently in progress. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otThreadIsDiscoverInProgress(aInstance: *mut otInstance) -> bool; +} +unsafe extern "C" { + /// Sets the Thread Joiner Advertisement when discovering Thread network. + /// + /// Thread Joiner Advertisement is used to allow a Joiner to advertise its own application-specific information + /// (such as Vendor ID, Product ID, Discriminator, etc.) via a newly-proposed Joiner Advertisement TLV, + /// and to make this information available to Commissioners or Commissioner Candidates without human interaction. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aOui The Vendor IEEE OUI value that will be included in the Joiner Advertisement. Only the + /// least significant 3 bytes will be used, and the most significant byte will be ignored. + /// @param[in] aAdvData A pointer to the AdvData that will be included in the Joiner Advertisement. + /// @param[in] aAdvDataLength The length of AdvData in bytes. + /// + /// @retval OT_ERROR_NONE Successfully set Joiner Advertisement. + /// @retval OT_ERROR_INVALID_ARGS Invalid AdvData. + pub fn otThreadSetJoinerAdvertisement( + aInstance: *mut otInstance, + aOui: u32, + aAdvData: *const u8, + aAdvDataLength: u8, + ) -> otError; +} +unsafe extern "C" { + /// Gets the Thread Child Timeout (in seconds) used when operating in the Child role. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The Thread Child Timeout value in seconds. + /// + /// @sa otThreadSetChildTimeout + pub fn otThreadGetChildTimeout(aInstance: *mut otInstance) -> u32; +} +unsafe extern "C" { + /// Sets the Thread Child Timeout (in seconds) used when operating in the Child role. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aTimeout The timeout value in seconds. + /// + /// @sa otThreadGetChildTimeout + pub fn otThreadSetChildTimeout(aInstance: *mut otInstance, aTimeout: u32); +} +unsafe extern "C" { + /// Gets the IEEE 802.15.4 Extended PAN ID. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to the IEEE 802.15.4 Extended PAN ID. + /// + /// @sa otThreadSetExtendedPanId + pub fn otThreadGetExtendedPanId(aInstance: *mut otInstance) -> *const otExtendedPanId; +} +unsafe extern "C" { + /// Sets the IEEE 802.15.4 Extended PAN ID. + /// + /// @note Can only be called while Thread protocols are disabled. A successful + /// call to this function invalidates the Active and Pending Operational Datasets in + /// non-volatile memory. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aExtendedPanId A pointer to the IEEE 802.15.4 Extended PAN ID. + /// + /// @retval OT_ERROR_NONE Successfully set the Extended PAN ID. + /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + /// + /// @sa otThreadGetExtendedPanId + pub fn otThreadSetExtendedPanId( + aInstance: *mut otInstance, + aExtendedPanId: *const otExtendedPanId, + ) -> otError; } -impl otNeighborInfo { - #[inline] - pub fn mRxOnWhenIdle(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } - } - #[inline] - pub fn set_mRxOnWhenIdle(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(0usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mRxOnWhenIdle_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 0usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mRxOnWhenIdle_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 0usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn mFullThreadDevice(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } - } - #[inline] - pub fn set_mFullThreadDevice(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(1usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mFullThreadDevice_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 1usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mFullThreadDevice_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 1usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn mFullNetworkData(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } - } - #[inline] - pub fn set_mFullNetworkData(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(2usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mFullNetworkData_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 2usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mFullNetworkData_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 2usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn mIsChild(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } - } - #[inline] - pub fn set_mIsChild(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(3usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mIsChild_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 3usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mIsChild_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 3usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn new_bitfield_1( - mRxOnWhenIdle: bool, - mFullThreadDevice: bool, - mFullNetworkData: bool, - mIsChild: bool, - ) -> __BindgenBitfieldUnit<[u8; 1usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); - __bindgen_bitfield_unit.set(0usize, 1u8, { - let mRxOnWhenIdle: u8 = unsafe { ::core::mem::transmute(mRxOnWhenIdle) }; - mRxOnWhenIdle as u64 - }); - __bindgen_bitfield_unit.set(1usize, 1u8, { - let mFullThreadDevice: u8 = unsafe { ::core::mem::transmute(mFullThreadDevice) }; - mFullThreadDevice as u64 - }); - __bindgen_bitfield_unit.set(2usize, 1u8, { - let mFullNetworkData: u8 = unsafe { ::core::mem::transmute(mFullNetworkData) }; - mFullNetworkData as u64 - }); - __bindgen_bitfield_unit.set(3usize, 1u8, { - let mIsChild: u8 = unsafe { ::core::mem::transmute(mIsChild) }; - mIsChild as u64 - }); - __bindgen_bitfield_unit - } +unsafe extern "C" { + /// Returns a pointer to the Leader's RLOC. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aLeaderRloc A pointer to the Leader's RLOC. + /// + /// @retval OT_ERROR_NONE The Leader's RLOC was successfully written to @p aLeaderRloc. + /// @retval OT_ERROR_INVALID_ARGS @p aLeaderRloc was NULL. + /// @retval OT_ERROR_DETACHED Not currently attached to a Thread Partition. + pub fn otThreadGetLeaderRloc( + aInstance: *mut otInstance, + aLeaderRloc: *mut otIp6Address, + ) -> otError; +} +unsafe extern "C" { + /// Get the MLE Link Mode configuration. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The MLE Link Mode configuration. + /// + /// @sa otThreadSetLinkMode + pub fn otThreadGetLinkMode(aInstance: *mut otInstance) -> otLinkModeConfig; +} +unsafe extern "C" { + /// Set the MLE Link Mode configuration. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aConfig A pointer to the Link Mode configuration. + /// + /// @retval OT_ERROR_NONE Successfully set the MLE Link Mode configuration. + /// + /// @sa otThreadGetLinkMode + pub fn otThreadSetLinkMode(aInstance: *mut otInstance, aConfig: otLinkModeConfig) -> otError; +} +unsafe extern "C" { + /// Get the Thread Network Key. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aNetworkKey A pointer to an `otNetworkKey` to return the Thread Network Key. + /// + /// @sa otThreadSetNetworkKey + pub fn otThreadGetNetworkKey(aInstance: *mut otInstance, aNetworkKey: *mut otNetworkKey); +} +unsafe extern "C" { + /// Get the `otNetworkKeyRef` for Thread Network Key. + /// + /// Requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns Reference to the Thread Network Key stored in memory. + /// + /// @sa otThreadSetNetworkKeyRef + pub fn otThreadGetNetworkKeyRef(aInstance: *mut otInstance) -> otNetworkKeyRef; } -pub type otNeighborInfoIterator = i16; -/// Represents the Thread Leader Data. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otLeaderData { - ///< Partition ID - pub mPartitionId: u32, - ///< Leader Weight - pub mWeighting: u8, - ///< Full Network Data Version - pub mDataVersion: u8, - ///< Stable Network Data Version - pub mStableDataVersion: u8, - ///< Leader Router ID - pub mLeaderRouterId: u8, +unsafe extern "C" { + /// Set the Thread Network Key. + /// + /// Succeeds only when Thread protocols are disabled. A successful + /// call to this function invalidates the Active and Pending Operational Datasets in + /// non-volatile memory. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aKey A pointer to a buffer containing the Thread Network Key. + /// + /// @retval OT_ERROR_NONE Successfully set the Thread Network Key. + /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + /// + /// @sa otThreadGetNetworkKey + pub fn otThreadSetNetworkKey(aInstance: *mut otInstance, aKey: *const otNetworkKey) -> otError; } -/// Holds diagnostic information for a Thread Router -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otRouterInfo { - ///< IEEE 802.15.4 Extended Address - pub mExtAddress: otExtAddress, - ///< RLOC16 - pub mRloc16: u16, - ///< Router ID - pub mRouterId: u8, - ///< Next hop to router - pub mNextHop: u8, - ///< Path cost to router - pub mPathCost: u8, - ///< Link Quality In - pub mLinkQualityIn: u8, - ///< Link Quality Out - pub mLinkQualityOut: u8, - ///< Time last heard - pub mAge: u8, - pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, - ///< Thread version - pub mVersion: u8, - ///< CSL clock accuracy, in ± ppm - pub mCslClockAccuracy: u8, - ///< CSL uncertainty, in ±10 us - pub mCslUncertainty: u8, +unsafe extern "C" { + /// Set the Thread Network Key as a `otNetworkKeyRef`. + /// + /// Succeeds only when Thread protocols are disabled. A successful + /// call to this function invalidates the Active and Pending Operational Datasets in + /// non-volatile memory. + /// + /// Requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aKeyRef Reference to the Thread Network Key. + /// + /// @retval OT_ERROR_NONE Successfully set the Thread Network Key. + /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + /// + /// @sa otThreadGetNetworkKeyRef + pub fn otThreadSetNetworkKeyRef( + aInstance: *mut otInstance, + aKeyRef: otNetworkKeyRef, + ) -> otError; } -impl otRouterInfo { - #[inline] - pub fn mAllocated(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } - } - #[inline] - pub fn set_mAllocated(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(0usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mAllocated_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 0usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mAllocated_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 0usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn mLinkEstablished(&self) -> bool { - unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } - } - #[inline] - pub fn set_mLinkEstablished(&mut self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(1usize, 1u8, val as u64) - } - } - #[inline] - pub unsafe fn mLinkEstablished_raw(this: *const Self) -> bool { - unsafe { - ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( - ::core::ptr::addr_of!((*this)._bitfield_1), - 1usize, - 1u8, - ) as u8) - } - } - #[inline] - pub unsafe fn set_mLinkEstablished_raw(this: *mut Self, val: bool) { - unsafe { - let val: u8 = ::core::mem::transmute(val); - <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( - ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 1usize, - 1u8, - val as u64, - ) - } - } - #[inline] - pub fn new_bitfield_1( - mAllocated: bool, - mLinkEstablished: bool, - ) -> __BindgenBitfieldUnit<[u8; 1usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); - __bindgen_bitfield_unit.set(0usize, 1u8, { - let mAllocated: u8 = unsafe { ::core::mem::transmute(mAllocated) }; - mAllocated as u64 - }); - __bindgen_bitfield_unit.set(1usize, 1u8, { - let mLinkEstablished: u8 = unsafe { ::core::mem::transmute(mLinkEstablished) }; - mLinkEstablished as u64 - }); - __bindgen_bitfield_unit - } +unsafe extern "C" { + /// Gets the Thread Routing Locator (RLOC) address. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to the Thread Routing Locator (RLOC) address. + pub fn otThreadGetRloc(aInstance: *mut otInstance) -> *const otIp6Address; +} +unsafe extern "C" { + /// Gets the Mesh Local EID address. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to the Mesh Local EID address. + pub fn otThreadGetMeshLocalEid(aInstance: *mut otInstance) -> *const otIp6Address; +} +unsafe extern "C" { + /// Returns a pointer to the Mesh Local Prefix. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to the Mesh Local Prefix. + pub fn otThreadGetMeshLocalPrefix(aInstance: *mut otInstance) -> *const otMeshLocalPrefix; +} +unsafe extern "C" { + /// Sets the Mesh Local Prefix. + /// + /// Succeeds only when Thread protocols are disabled. A successful + /// call to this function invalidates the Active and Pending Operational Datasets in + /// non-volatile memory. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aMeshLocalPrefix A pointer to the Mesh Local Prefix. + /// + /// @retval OT_ERROR_NONE Successfully set the Mesh Local Prefix. + /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + pub fn otThreadSetMeshLocalPrefix( + aInstance: *mut otInstance, + aMeshLocalPrefix: *const otMeshLocalPrefix, + ) -> otError; +} +unsafe extern "C" { + /// Gets the Thread link-local IPv6 address. + /// + /// The Thread link local address is derived using IEEE802.15.4 Extended Address as Interface Identifier. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to Thread link-local IPv6 address. + pub fn otThreadGetLinkLocalIp6Address(aInstance: *mut otInstance) -> *const otIp6Address; +} +unsafe extern "C" { + /// Gets the Thread Link-Local All Thread Nodes multicast address. + /// + /// The address is a link-local Unicast Prefix-Based Multicast Address [RFC 3306], with: + /// - flgs set to 3 (P = 1 and T = 1) + /// - scop set to 2 + /// - plen set to 64 + /// - network prefix set to the Mesh Local Prefix + /// - group ID set to 1 + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to Thread Link-Local All Thread Nodes multicast address. + pub fn otThreadGetLinkLocalAllThreadNodesMulticastAddress( + aInstance: *mut otInstance, + ) -> *const otIp6Address; +} +unsafe extern "C" { + /// Gets the Thread Realm-Local All Thread Nodes multicast address. + /// + /// The address is a realm-local Unicast Prefix-Based Multicast Address [RFC 3306], with: + /// - flgs set to 3 (P = 1 and T = 1) + /// - scop set to 3 + /// - plen set to 64 + /// - network prefix set to the Mesh Local Prefix + /// - group ID set to 1 + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to Thread Realm-Local All Thread Nodes multicast address. + pub fn otThreadGetRealmLocalAllThreadNodesMulticastAddress( + aInstance: *mut otInstance, + ) -> *const otIp6Address; } -/// Represents the IP level counters. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otIpCounters { - ///< The number of IPv6 packets successfully transmitted. - pub mTxSuccess: u32, - ///< The number of IPv6 packets successfully received. - pub mRxSuccess: u32, - ///< The number of IPv6 packets failed to transmit. - pub mTxFailure: u32, - ///< The number of IPv6 packets failed to receive. - pub mRxFailure: u32, +unsafe extern "C" { + /// Retrieves the Service ALOC for given Service ID. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aServiceId Service ID to get ALOC for. + /// @param[out] aServiceAloc A pointer to output the Service ALOC. MUST NOT BE NULL. + /// + /// @retval OT_ERROR_NONE Successfully retrieved the Service ALOC. + /// @retval OT_ERROR_DETACHED The Thread interface is not currently attached to a Thread Partition. + pub fn otThreadGetServiceAloc( + aInstance: *mut otInstance, + aServiceId: u8, + aServiceAloc: *mut otIp6Address, + ) -> otError; } -/// Represents the Thread MLE counters. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otMleCounters { - ///< Number of times device entered OT_DEVICE_ROLE_DISABLED role. - pub mDisabledRole: u16, - ///< Number of times device entered OT_DEVICE_ROLE_DETACHED role. - pub mDetachedRole: u16, - ///< Number of times device entered OT_DEVICE_ROLE_CHILD role. - pub mChildRole: u16, - ///< Number of times device entered OT_DEVICE_ROLE_ROUTER role. - pub mRouterRole: u16, - ///< Number of times device entered OT_DEVICE_ROLE_LEADER role. - pub mLeaderRole: u16, - ///< Number of attach attempts while device was detached. - pub mAttachAttempts: u16, - ///< Number of changes to partition ID. - pub mPartitionIdChanges: u16, - ///< Number of attempts to attach to a better partition. - pub mBetterPartitionAttachAttempts: u16, - ///< Number of milliseconds device has been in OT_DEVICE_ROLE_DISABLED role. - pub mDisabledTime: u64, - ///< Number of milliseconds device has been in OT_DEVICE_ROLE_DETACHED role. - pub mDetachedTime: u64, - ///< Number of milliseconds device has been in OT_DEVICE_ROLE_CHILD role. - pub mChildTime: u64, - ///< Number of milliseconds device has been in OT_DEVICE_ROLE_ROUTER role. - pub mRouterTime: u64, - ///< Number of milliseconds device has been in OT_DEVICE_ROLE_LEADER role. - pub mLeaderTime: u64, - ///< Number of milliseconds tracked by previous counters. - pub mTrackedTime: u64, - /// Number of times device changed its parent. +unsafe extern "C" { + /// Get the Thread Network Name. /// - /// A parent change can happen if device detaches from its current parent and attaches to a different one, or even - /// while device is attached when the periodic parent search feature is enabled (please see option - /// OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE). - pub mParentChanges: u16, + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to the Thread Network Name. + /// + /// @sa otThreadSetNetworkName + pub fn otThreadGetNetworkName(aInstance: *mut otInstance) -> *const ::core::ffi::c_char; } -/// Represents the MLE Parent Response data. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct otThreadParentResponseInfo { - ///< IEEE 802.15.4 Extended Address of the Parent - pub mExtAddr: otExtAddress, - ///< Short address of the Parent - pub mRloc16: u16, - ///< Rssi of the Parent - pub mRssi: i8, - ///< Parent priority - pub mPriority: i8, - ///< Parent Link Quality 3 - pub mLinkQuality3: u8, - ///< Parent Link Quality 2 - pub mLinkQuality2: u8, - ///< Parent Link Quality 1 - pub mLinkQuality1: u8, - ///< Is the node receiving parent response attached - pub mIsAttached: bool, +unsafe extern "C" { + /// Set the Thread Network Name. + /// + /// Succeeds only when Thread protocols are disabled. A successful + /// call to this function invalidates the Active and Pending Operational Datasets in + /// non-volatile memory. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aNetworkName A pointer to the Thread Network Name. + /// + /// @retval OT_ERROR_NONE Successfully set the Thread Network Name. + /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + /// + /// @sa otThreadGetNetworkName + pub fn otThreadSetNetworkName( + aInstance: *mut otInstance, + aNetworkName: *const ::core::ffi::c_char, + ) -> otError; } -/// This callback informs the application that the detaching process has finished. -/// -/// @param[in] aContext A pointer to application-specific context. -pub type otDetachGracefullyCallback = - ::core::option::Option; unsafe extern "C" { - /// Starts Thread protocol operation. + /// Gets the Thread Domain Name. /// - /// The interface must be up when calling this function. + /// @note Available since Thread 1.2. /// - /// Calling this function with @p aEnabled set to FALSE stops any ongoing processes of detaching started by - /// otThreadDetachGracefully(). Its callback will be called. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aEnabled TRUE if Thread is enabled, FALSE otherwise. + /// @returns A pointer to the Thread Domain Name. /// - /// @retval OT_ERROR_NONE Successfully started Thread protocol operation. - /// @retval OT_ERROR_INVALID_STATE The network interface was not up. - pub fn otThreadSetEnabled(aInstance: *mut otInstance, aEnabled: bool) -> otError; + /// @sa otThreadSetDomainName + pub fn otThreadGetDomainName(aInstance: *mut otInstance) -> *const ::core::ffi::c_char; } unsafe extern "C" { - /// Gets the Thread protocol version. + /// Sets the Thread Domain Name. Only succeeds when Thread protocols are disabled. /// - /// The constants `OT_THREAD_VERSION_*` define the numerical version values. + /// @note Available since Thread 1.2. /// - /// @returns the Thread protocol version. - pub fn otThreadGetVersion() -> u16; + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aDomainName A pointer to the Thread Domain Name. + /// + /// @retval OT_ERROR_NONE Successfully set the Thread Domain Name. + /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + /// + /// @sa otThreadGetDomainName + pub fn otThreadSetDomainName( + aInstance: *mut otInstance, + aDomainName: *const ::core::ffi::c_char, + ) -> otError; } unsafe extern "C" { - /// Indicates whether a node is the only router on the network. + /// Sets or clears the Interface Identifier manually specified for the Thread Domain Unicast Address. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// Available when `OPENTHREAD_CONFIG_DUA_ENABLE` is enabled. /// - /// @retval TRUE It is the only router in the network. - /// @retval FALSE It is a child or is not a single router in the network. - pub fn otThreadIsSingleton(aInstance: *mut otInstance) -> bool; + /// @note Only available since Thread 1.2. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aIid A pointer to the Interface Identifier to set or NULL to clear. + /// + /// @retval OT_ERROR_NONE Successfully set/cleared the Interface Identifier. + /// @retval OT_ERROR_INVALID_ARGS The specified Interface Identifier is reserved. + /// + /// @sa otThreadGetFixedDuaInterfaceIdentifier + pub fn otThreadSetFixedDuaInterfaceIdentifier( + aInstance: *mut otInstance, + aIid: *const otIp6InterfaceIdentifier, + ) -> otError; } unsafe extern "C" { - /// Starts a Thread Discovery scan. + /// Gets the Interface Identifier manually specified for the Thread Domain Unicast Address. /// - /// @note A successful call to this function enables the rx-on-when-idle mode for the entire scan procedure. + /// Available when `OPENTHREAD_CONFIG_DUA_ENABLE` is enabled. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aScanChannels A bit vector indicating which channels to scan (e.g. OT_CHANNEL_11_MASK). - /// @param[in] aPanId The PAN ID filter (set to Broadcast PAN to disable filter). - /// @param[in] aJoiner Value of the Joiner Flag in the Discovery Request TLV. - /// @param[in] aEnableEui64Filtering TRUE to filter responses on EUI-64, FALSE otherwise. - /// @param[in] aCallback A pointer to a function called on receiving an MLE Discovery Response or - /// scan completes. - /// @param[in] aCallbackContext A pointer to application-specific context. + /// @note Only available since Thread 1.2. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns A pointer to the Interface Identifier which was set manually, or NULL if none was set. + /// + /// @sa otThreadSetFixedDuaInterfaceIdentifier + pub fn otThreadGetFixedDuaInterfaceIdentifier( + aInstance: *mut otInstance, + ) -> *const otIp6InterfaceIdentifier; +} +unsafe extern "C" { + /// Gets the thrKeySequenceCounter. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The thrKeySequenceCounter value. + /// + /// @sa otThreadSetKeySequenceCounter + pub fn otThreadGetKeySequenceCounter(aInstance: *mut otInstance) -> u32; +} +unsafe extern "C" { + /// Sets the thrKeySequenceCounter. + /// + /// @note This API is reserved for testing and demo purposes only. Changing settings with + /// this API will render a production application non-compliant with the Thread Specification. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aKeySequenceCounter The thrKeySequenceCounter value. + /// + /// @sa otThreadGetKeySequenceCounter + pub fn otThreadSetKeySequenceCounter(aInstance: *mut otInstance, aKeySequenceCounter: u32); +} +unsafe extern "C" { + /// Gets the thrKeySwitchGuardTime (in hours). + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The thrKeySwitchGuardTime value (in hours). + /// + /// @sa otThreadSetKeySwitchGuardTime + pub fn otThreadGetKeySwitchGuardTime(aInstance: *mut otInstance) -> u16; +} +unsafe extern "C" { + /// Sets the thrKeySwitchGuardTime (in hours). + /// + /// @note This API is reserved for testing and demo purposes only. Changing settings with + /// this API will render a production application non-compliant with the Thread Specification. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aKeySwitchGuardTime The thrKeySwitchGuardTime value (in hours). + /// + /// @sa otThreadGetKeySwitchGuardTime + pub fn otThreadSetKeySwitchGuardTime(aInstance: *mut otInstance, aKeySwitchGuardTime: u16); +} +unsafe extern "C" { + /// Detach from the Thread network. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @retval OT_ERROR_NONE Successfully detached from the Thread network. + /// @retval OT_ERROR_INVALID_STATE Thread is disabled. + pub fn otThreadBecomeDetached(aInstance: *mut otInstance) -> otError; +} +unsafe extern "C" { + /// Attempt to reattach as a child. + /// + /// @note This API is reserved for testing and demo purposes only. Changing settings with + /// this API will render a production application non-compliant with the Thread Specification. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @retval OT_ERROR_NONE Successfully begin attempt to become a child. + /// @retval OT_ERROR_INVALID_STATE Thread is disabled. + pub fn otThreadBecomeChild(aInstance: *mut otInstance) -> otError; +} +unsafe extern "C" { + /// Gets the next neighbor information. It is used to go through the entries of + /// the neighbor table. /// - /// @retval OT_ERROR_NONE Successfully started a Thread Discovery Scan. - /// @retval OT_ERROR_INVALID_STATE The IPv6 interface is not enabled (netif is not up). - /// @retval OT_ERROR_NO_BUFS Could not allocate message for Discovery Request. - /// @retval OT_ERROR_BUSY Thread Discovery Scan is already in progress. - pub fn otThreadDiscover( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in,out] aIterator A pointer to the iterator context. To get the first neighbor entry + ///it should be set to OT_NEIGHBOR_INFO_ITERATOR_INIT. + /// @param[out] aInfo A pointer to the neighbor information. + /// + /// @retval OT_ERROR_NONE Successfully found the next neighbor entry in table. + /// @retval OT_ERROR_NOT_FOUND No subsequent neighbor entry exists in the table. + /// @retval OT_ERROR_INVALID_ARGS @p aIterator or @p aInfo was NULL. + pub fn otThreadGetNextNeighborInfo( aInstance: *mut otInstance, - aScanChannels: u32, - aPanId: u16, - aJoiner: bool, - aEnableEui64Filtering: bool, - aCallback: otHandleActiveScanResult, - aCallbackContext: *mut ::core::ffi::c_void, + aIterator: *mut otNeighborInfoIterator, + aInfo: *mut otNeighborInfo, ) -> otError; } unsafe extern "C" { - /// Determines if an MLE Thread Discovery is currently in progress. + /// Get the device role. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otThreadIsDiscoverInProgress(aInstance: *mut otInstance) -> bool; + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @retval OT_DEVICE_ROLE_DISABLED The Thread stack is disabled. + /// @retval OT_DEVICE_ROLE_DETACHED The device is not currently participating in a Thread network/partition. + /// @retval OT_DEVICE_ROLE_CHILD The device is currently operating as a Thread Child. + /// @retval OT_DEVICE_ROLE_ROUTER The device is currently operating as a Thread Router. + /// @retval OT_DEVICE_ROLE_LEADER The device is currently operating as a Thread Leader. + pub fn otThreadGetDeviceRole(aInstance: *mut otInstance) -> otDeviceRole; } unsafe extern "C" { - /// Sets the Thread Joiner Advertisement when discovering Thread network. + /// Convert the device role to human-readable string. /// - /// Thread Joiner Advertisement is used to allow a Joiner to advertise its own application-specific information - /// (such as Vendor ID, Product ID, Discriminator, etc.) via a newly-proposed Joiner Advertisement TLV, - /// and to make this information available to Commissioners or Commissioner Candidates without human interaction. + /// @param[in] aRole The device role to convert. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aOui The Vendor IEEE OUI value that will be included in the Joiner Advertisement. Only the - /// least significant 3 bytes will be used, and the most significant byte will be ignored. - /// @param[in] aAdvData A pointer to the AdvData that will be included in the Joiner Advertisement. - /// @param[in] aAdvDataLength The length of AdvData in bytes. + /// @returns A string representing @p aRole. + pub fn otThreadDeviceRoleToString(aRole: otDeviceRole) -> *const ::core::ffi::c_char; +} +unsafe extern "C" { + /// Get the Thread Leader Data. /// - /// @retval OT_ERROR_NONE Successfully set Joiner Advertisement. - /// @retval OT_ERROR_INVALID_ARGS Invalid AdvData. - pub fn otThreadSetJoinerAdvertisement( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aLeaderData A pointer to where the leader data is placed. + /// + /// @retval OT_ERROR_NONE Successfully retrieved the leader data. + /// @retval OT_ERROR_DETACHED Not currently attached. + pub fn otThreadGetLeaderData( aInstance: *mut otInstance, - aOui: u32, - aAdvData: *const u8, - aAdvDataLength: u8, + aLeaderData: *mut otLeaderData, ) -> otError; } unsafe extern "C" { - /// Gets the Thread Child Timeout (in seconds) used when operating in the Child role. + /// Get the Leader's Router ID. /// /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @returns The Thread Child Timeout value in seconds. - /// - /// @sa otThreadSetChildTimeout - pub fn otThreadGetChildTimeout(aInstance: *mut otInstance) -> u32; + /// @returns The Leader's Router ID. + pub fn otThreadGetLeaderRouterId(aInstance: *mut otInstance) -> u8; } unsafe extern "C" { - /// Sets the Thread Child Timeout (in seconds) used when operating in the Child role. + /// Get the Leader's Weight. /// /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aTimeout The timeout value in seconds. /// - /// @sa otThreadGetChildTimeout - pub fn otThreadSetChildTimeout(aInstance: *mut otInstance, aTimeout: u32); + /// @returns The Leader's Weight. + pub fn otThreadGetLeaderWeight(aInstance: *mut otInstance) -> u8; } unsafe extern "C" { - /// Gets the IEEE 802.15.4 Extended PAN ID. + /// Get the Partition ID. /// /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @returns A pointer to the IEEE 802.15.4 Extended PAN ID. - /// - /// @sa otThreadSetExtendedPanId - pub fn otThreadGetExtendedPanId(aInstance: *mut otInstance) -> *const otExtendedPanId; + /// @returns The Partition ID. + pub fn otThreadGetPartitionId(aInstance: *mut otInstance) -> u32; } unsafe extern "C" { - /// Sets the IEEE 802.15.4 Extended PAN ID. - /// - /// @note Can only be called while Thread protocols are disabled. A successful - /// call to this function invalidates the Active and Pending Operational Datasets in - /// non-volatile memory. + /// Get the RLOC16. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aExtendedPanId A pointer to the IEEE 802.15.4 Extended PAN ID. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @retval OT_ERROR_NONE Successfully set the Extended PAN ID. - /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + /// @returns The RLOC16. + pub fn otThreadGetRloc16(aInstance: *mut otInstance) -> u16; +} +unsafe extern "C" { + /// The function retrieves diagnostic information for a Thread Router as parent. /// - /// @sa otThreadGetExtendedPanId - pub fn otThreadSetExtendedPanId( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aParentInfo A pointer to where the parent router information is placed. + pub fn otThreadGetParentInfo( aInstance: *mut otInstance, - aExtendedPanId: *const otExtendedPanId, + aParentInfo: *mut otRouterInfo, ) -> otError; } unsafe extern "C" { - /// Returns a pointer to the Leader's RLOC. + /// The function retrieves the average RSSI for the Thread Parent. /// /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[out] aLeaderRloc A pointer to the Leader's RLOC. - /// - /// @retval OT_ERROR_NONE The Leader's RLOC was successfully written to @p aLeaderRloc. - /// @retval OT_ERROR_INVALID_ARGS @p aLeaderRloc was NULL. - /// @retval OT_ERROR_DETACHED Not currently attached to a Thread Partition. - pub fn otThreadGetLeaderRloc( + /// @param[out] aParentRssi A pointer to where the parent RSSI should be placed. + pub fn otThreadGetParentAverageRssi( aInstance: *mut otInstance, - aLeaderRloc: *mut otIp6Address, + aParentRssi: *mut i8, ) -> otError; } unsafe extern "C" { - /// Get the MLE Link Mode configuration. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// The function retrieves the RSSI of the last packet from the Thread Parent. /// - /// @returns The MLE Link Mode configuration. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aLastRssi A pointer to where the last RSSI should be placed. /// - /// @sa otThreadSetLinkMode - pub fn otThreadGetLinkMode(aInstance: *mut otInstance) -> otLinkModeConfig; + /// @retval OT_ERROR_NONE Successfully retrieved the RSSI data. + /// @retval OT_ERROR_FAILED Unable to get RSSI data. + /// @retval OT_ERROR_INVALID_ARGS @p aLastRssi is NULL. + pub fn otThreadGetParentLastRssi(aInstance: *mut otInstance, aLastRssi: *mut i8) -> otError; } unsafe extern "C" { - /// Set the MLE Link Mode configuration. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aConfig A pointer to the Link Mode configuration. + /// Starts the process for child to search for a better parent while staying attached to its current parent. /// - /// @retval OT_ERROR_NONE Successfully set the MLE Link Mode configuration. + /// Must be used when device is attached as a child. /// - /// @sa otThreadGetLinkMode - pub fn otThreadSetLinkMode(aInstance: *mut otInstance, aConfig: otLinkModeConfig) -> otError; + /// @retval OT_ERROR_NONE Successfully started the process to search for a better parent. + /// @retval OT_ERROR_INVALID_STATE Device role is not child. + pub fn otThreadSearchForBetterParent(aInstance: *mut otInstance) -> otError; } unsafe extern "C" { - /// Get the Thread Network Key. + /// Gets the IPv6 counters. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[out] aNetworkKey A pointer to an `otNetworkKey` to return the Thread Network Key. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @sa otThreadSetNetworkKey - pub fn otThreadGetNetworkKey(aInstance: *mut otInstance, aNetworkKey: *mut otNetworkKey); + /// @returns A pointer to the IPv6 counters. + pub fn otThreadGetIp6Counters(aInstance: *mut otInstance) -> *const otIpCounters; } unsafe extern "C" { - /// Get the `otNetworkKeyRef` for Thread Network Key. + /// Resets the IPv6 counters. /// - /// Requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otThreadResetIp6Counters(aInstance: *mut otInstance); +} +unsafe extern "C" { + /// Gets the time-in-queue histogram for messages in the TX queue. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// Requires `OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE`. /// - /// @returns Reference to the Thread Network Key stored in memory. + /// Histogram of the time-in-queue of messages in the transmit queue is collected. The time-in-queue is tracked for + /// direct transmissions only and is measured as the duration from when a message is added to the transmit queue until + /// it is passed to the MAC layer for transmission or dropped. /// - /// @sa otThreadSetNetworkKeyRef - pub fn otThreadGetNetworkKeyRef(aInstance: *mut otInstance) -> otNetworkKeyRef; + /// The histogram is returned as an array of `uint32_t` values with `aNumBins` entries. The first entry in the array + /// (at index 0) represents the number of messages with a time-in-queue less than `aBinInterval`. The second entry + /// represents the number of messages with a time-in-queue greater than or equal to `aBinInterval`, but less than + /// `2 * aBinInterval`. And so on. The last entry represents the number of messages with time-in-queue greater than or + /// equal to `(aNumBins - 1) * aBinInterval`. + /// + /// The collected statistics can be reset by calling `otThreadResetTimeInQueueStat()`. The histogram information is + /// collected since the OpenThread instance was initialized or since the last time statistics collection was reset by + /// calling the `otThreadResetTimeInQueueStat()`. + /// + /// Pointers @p aNumBins and @p aBinInterval MUST NOT be NULL. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aNumBins Pointer to return the number of bins in histogram (array length). + /// @param[out] aBinInterval Pointer to return the histogram bin interval length in milliseconds. + /// + /// @returns A pointer to an array of @p aNumBins entries representing the collected histogram info. + pub fn otThreadGetTimeInQueueHistogram( + aInstance: *mut otInstance, + aNumBins: *mut u16, + aBinInterval: *mut u32, + ) -> *const u32; } unsafe extern "C" { - /// Set the Thread Network Key. + /// Gets the maximum time-in-queue for messages in the TX queue. /// - /// Succeeds only when Thread protocols are disabled. A successful - /// call to this function invalidates the Active and Pending Operational Datasets in - /// non-volatile memory. + /// Requires `OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE`. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aKey A pointer to a buffer containing the Thread Network Key. + /// The time-in-queue is tracked for direct transmissions only and is measured as the duration from when a message is + /// added to the transmit queue until it is passed to the MAC layer for transmission or dropped. /// - /// @retval OT_ERROR_NONE Successfully set the Thread Network Key. - /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + /// The collected statistics can be reset by calling `otThreadResetTimeInQueueStat()`. /// - /// @sa otThreadGetNetworkKey - pub fn otThreadSetNetworkKey(aInstance: *mut otInstance, aKey: *const otNetworkKey) -> otError; + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The maximum time-in-queue in milliseconds for all messages in the TX queue (so far). + pub fn otThreadGetMaxTimeInQueue(aInstance: *mut otInstance) -> u32; } unsafe extern "C" { - /// Set the Thread Network Key as a `otNetworkKeyRef`. + /// Resets the TX queue time-in-queue statistics. /// - /// Succeeds only when Thread protocols are disabled. A successful - /// call to this function invalidates the Active and Pending Operational Datasets in - /// non-volatile memory. + /// Requires `OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE`. /// - /// Requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otThreadResetTimeInQueueStat(aInstance: *mut otInstance); +} +unsafe extern "C" { + /// Gets the Thread MLE counters. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aKeyRef Reference to the Thread Network Key. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @retval OT_ERROR_NONE Successfully set the Thread Network Key. - /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + /// @returns A pointer to the Thread MLE counters. + pub fn otThreadGetMleCounters(aInstance: *mut otInstance) -> *const otMleCounters; +} +unsafe extern "C" { + /// Resets the Thread MLE counters. /// - /// @sa otThreadGetNetworkKeyRef - pub fn otThreadSetNetworkKeyRef( - aInstance: *mut otInstance, - aKeyRef: otNetworkKeyRef, - ) -> otError; + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otThreadResetMleCounters(aInstance: *mut otInstance); } unsafe extern "C" { - /// Gets the Thread Routing Locator (RLOC) address. + /// Gets the current attach duration (number of seconds since the device last attached). /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// If the device is not currently attached, zero will be returned. /// - /// @returns A pointer to the Thread Routing Locator (RLOC) address. - pub fn otThreadGetRloc(aInstance: *mut otInstance) -> *const otIp6Address; + /// Unlike the role-tracking variables in `otMleCounters`, which track the cumulative time the device is in each role, + /// this function tracks the time since the last successful attachment, indicating how long the device has been + /// connected to the Thread mesh (regardless of its role, whether acting as a child, router, or leader). + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The number of seconds since last attached. + pub fn otThreadGetCurrentAttachDuration(aInstance: *mut otInstance) -> u32; } +/// Pointer is called every time an MLE Parent Response message is received. +/// +/// This is used in `otThreadRegisterParentResponseCallback()`. +/// +/// @param[in] aInfo A pointer to a location on stack holding the stats data. +/// @param[in] aContext A pointer to callback client-specific context. +pub type otThreadParentResponseCallback = ::core::option::Option< + unsafe extern "C" fn( + aInfo: *mut otThreadParentResponseInfo, + aContext: *mut ::core::ffi::c_void, + ), +>; unsafe extern "C" { - /// Gets the Mesh Local EID address. + /// Registers a callback to receive MLE Parent Response data. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// Requires `OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE`. /// - /// @returns A pointer to the Mesh Local EID address. - pub fn otThreadGetMeshLocalEid(aInstance: *mut otInstance) -> *const otIp6Address; + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aCallback A pointer to a function that is called upon receiving an MLE Parent Response message. + /// @param[in] aContext A pointer to callback client-specific context. + pub fn otThreadRegisterParentResponseCallback( + aInstance: *mut otInstance, + aCallback: otThreadParentResponseCallback, + aContext: *mut ::core::ffi::c_void, + ); +} +/// Represents the Thread Discovery Request data. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otThreadDiscoveryRequestInfo { + ///< IEEE 802.15.4 Extended Address of the requester + pub mExtAddress: otExtAddress, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl otThreadDiscoveryRequestInfo { + #[inline] + pub fn mVersion(&self) -> u8 { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } + } + #[inline] + pub fn set_mVersion(&mut self, val: u8) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(0usize, 4u8, val as u64) + } + } + #[inline] + pub unsafe fn mVersion_raw(this: *const Self) -> u8 { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 0usize, + 4u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mVersion_raw(this: *mut Self, val: u8) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 4u8, + val as u64, + ) + } + } + #[inline] + pub fn mIsJoiner(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_mIsJoiner(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mIsJoiner_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 4usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mIsJoiner_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 4usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn new_bitfield_1(mVersion: u8, mIsJoiner: bool) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 4u8, { + let mVersion: u8 = unsafe { ::core::mem::transmute(mVersion) }; + mVersion as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let mIsJoiner: u8 = unsafe { ::core::mem::transmute(mIsJoiner) }; + mIsJoiner as u64 + }); + __bindgen_bitfield_unit + } } +/// Pointer is called every time an MLE Discovery Request message is received. +/// +/// @param[in] aInfo A pointer to the Discovery Request info data. +/// @param[in] aContext A pointer to callback application-specific context. +pub type otThreadDiscoveryRequestCallback = ::core::option::Option< + unsafe extern "C" fn( + aInfo: *const otThreadDiscoveryRequestInfo, + aContext: *mut ::core::ffi::c_void, + ), +>; unsafe extern "C" { - /// Returns a pointer to the Mesh Local Prefix. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// Sets a callback to receive MLE Discovery Request data. /// - /// @returns A pointer to the Mesh Local Prefix. - pub fn otThreadGetMeshLocalPrefix(aInstance: *mut otInstance) -> *const otMeshLocalPrefix; + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aCallback A pointer to a function that is called upon receiving an MLE Discovery Request message. + /// @param[in] aContext A pointer to callback application-specific context. + pub fn otThreadSetDiscoveryRequestCallback( + aInstance: *mut otInstance, + aCallback: otThreadDiscoveryRequestCallback, + aContext: *mut ::core::ffi::c_void, + ); } +/// Pointer type defines the callback to notify the outcome of a `otThreadLocateAnycastDestination()` +/// request. +/// +/// @param[in] aContext A pointer to an arbitrary context (provided when callback is registered). +/// @param[in] aError The error when handling the request. OT_ERROR_NONE indicates success. +/// OT_ERROR_RESPONSE_TIMEOUT indicates a destination could not be found. +/// OT_ERROR_ABORT indicates the request was aborted. +/// @param[in] aMeshLocalAddress A pointer to the mesh-local EID of the closest destination of the anycast address +/// when @p aError is OT_ERROR_NONE, NULL otherwise. +/// @param[in] aRloc16 The RLOC16 of the destination if found, otherwise invalid RLOC16 (0xfffe). +pub type otThreadAnycastLocatorCallback = ::core::option::Option< + unsafe extern "C" fn( + aContext: *mut ::core::ffi::c_void, + aError: otError, + aMeshLocalAddress: *const otIp6Address, + aRloc16: u16, + ), +>; unsafe extern "C" { - /// Sets the Mesh Local Prefix. + /// Requests the closest destination of a given anycast address to be located. /// - /// Succeeds only when Thread protocols are disabled. A successful - /// call to this function invalidates the Active and Pending Operational Datasets in - /// non-volatile memory. + /// Is only available when `OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE` is enabled. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aMeshLocalPrefix A pointer to the Mesh Local Prefix. + /// If a previous request is ongoing, a subsequent call to this function will cancel and replace the earlier request. /// - /// @retval OT_ERROR_NONE Successfully set the Mesh Local Prefix. - /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. - pub fn otThreadSetMeshLocalPrefix( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aAnycastAddress The anycast address to locate. MUST NOT be NULL. + /// @param[in] aCallback The callback function to report the result. + /// @param[in] aContext An arbitrary context used with @p aCallback. + /// + /// @retval OT_ERROR_NONE The request started successfully. @p aCallback will be invoked to report the result. + /// @retval OT_ERROR_INVALID_ARGS The @p aAnycastAddress is not a valid anycast address or @p aCallback is NULL. + /// @retval OT_ERROR_NO_BUFS Out of buffer to prepare and send the request message. + pub fn otThreadLocateAnycastDestination( aInstance: *mut otInstance, - aMeshLocalPrefix: *const otMeshLocalPrefix, + aAnycastAddress: *const otIp6Address, + aCallback: otThreadAnycastLocatorCallback, + aContext: *mut ::core::ffi::c_void, ) -> otError; } unsafe extern "C" { - /// Gets the Thread link-local IPv6 address. + /// Indicates whether an anycast locate request is currently in progress. /// - /// The Thread link local address is derived using IEEE802.15.4 Extended Address as Interface Identifier. + /// Is only available when `OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE` is enabled. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @returns A pointer to Thread link-local IPv6 address. - pub fn otThreadGetLinkLocalIp6Address(aInstance: *mut otInstance) -> *const otIp6Address; + /// @returns TRUE if an anycast locate request is currently in progress, FALSE otherwise. + pub fn otThreadIsAnycastLocateInProgress(aInstance: *mut otInstance) -> bool; } unsafe extern "C" { - /// Gets the Thread Link-Local All Thread Nodes multicast address. - /// - /// The address is a link-local Unicast Prefix-Based Multicast Address [RFC 3306], with: - /// - flgs set to 3 (P = 1 and T = 1) - /// - scop set to 2 - /// - plen set to 64 - /// - network prefix set to the Mesh Local Prefix - /// - group ID set to 1 + /// Sends a Proactive Address Notification (ADDR_NTF.ntf) message. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// Is only available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. /// - /// @returns A pointer to Thread Link-Local All Thread Nodes multicast address. - pub fn otThreadGetLinkLocalAllThreadNodesMulticastAddress( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aDestination The destination to send the ADDR_NTF.ntf message. + /// @param[in] aTarget The target address of the ADDR_NTF.ntf message. + /// @param[in] aMlIid The ML-IID of the ADDR_NTF.ntf message. + pub fn otThreadSendAddressNotification( aInstance: *mut otInstance, - ) -> *const otIp6Address; + aDestination: *mut otIp6Address, + aTarget: *mut otIp6Address, + aMlIid: *mut otIp6InterfaceIdentifier, + ); } unsafe extern "C" { - /// Gets the Thread Realm-Local All Thread Nodes multicast address. + /// Sends a Proactive Backbone Notification (PRO_BB.ntf) message on the Backbone link. /// - /// The address is a realm-local Unicast Prefix-Based Multicast Address [RFC 3306], with: - /// - flgs set to 3 (P = 1 and T = 1) - /// - scop set to 3 - /// - plen set to 64 - /// - network prefix set to the Mesh Local Prefix - /// - group ID set to 1 + /// Is only available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aTarget The target address of the PRO_BB.ntf message. + /// @param[in] aMlIid The ML-IID of the PRO_BB.ntf message. + /// @param[in] aTimeSinceLastTransaction Time since last transaction (in seconds). /// - /// @returns A pointer to Thread Realm-Local All Thread Nodes multicast address. - pub fn otThreadGetRealmLocalAllThreadNodesMulticastAddress( + /// @retval OT_ERROR_NONE Successfully sent PRO_BB.ntf on backbone link. + /// @retval OT_ERROR_NO_BUFS If insufficient message buffers available. + pub fn otThreadSendProactiveBackboneNotification( aInstance: *mut otInstance, - ) -> *const otIp6Address; + aTarget: *mut otIp6Address, + aMlIid: *mut otIp6InterfaceIdentifier, + aTimeSinceLastTransaction: u32, + ) -> otError; } unsafe extern "C" { - /// Retrieves the Service ALOC for given Service ID. + /// Notifies other nodes in the network (if any) and then stops Thread protocol operation. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aServiceId Service ID to get ALOC for. - /// @param[out] aServiceAloc A pointer to output the Service ALOC. MUST NOT BE NULL. + /// It sends an Address Release if it's a router, or sets its child timeout to 0 if it's a child. /// - /// @retval OT_ERROR_NONE Successfully retrieved the Service ALOC. - /// @retval OT_ERROR_DETACHED The Thread interface is not currently attached to a Thread Partition. - pub fn otThreadGetServiceAloc( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aCallback A pointer to a function that is called upon finishing detaching. + /// @param[in] aContext A pointer to callback application-specific context. + /// + /// @retval OT_ERROR_NONE Successfully started detaching. + /// @retval OT_ERROR_BUSY Detaching is already in progress. + pub fn otThreadDetachGracefully( aInstance: *mut otInstance, - aServiceId: u8, - aServiceAloc: *mut otIp6Address, + aCallback: otDetachGracefullyCallback, + aContext: *mut ::core::ffi::c_void, ) -> otError; } unsafe extern "C" { - /// Get the Thread Network Name. + /// Converts an `uint32_t` duration (in seconds) to a human-readable string. + /// + /// Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// The string follows the format "::" for hours, minutes, seconds (if duration is shorter than one day) or + /// "
d.::" (if longer than a day). /// - /// @returns A pointer to the Thread Network Name. + /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated + /// but the outputted string is always null-terminated. /// - /// @sa otThreadSetNetworkName - pub fn otThreadGetNetworkName(aInstance: *mut otInstance) -> *const ::core::ffi::c_char; + /// Is intended for use with `mAge` or `mConnectionTime` in `otNeighborInfo` or `otChildInfo` structures. + /// + /// @param[in] aDuration A duration interval in seconds. + /// @param[out] aBuffer A pointer to a char array to output the string. + /// @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_DURATION_STRING_SIZE`. + pub fn otConvertDurationInSecondsToString( + aDuration: u32, + aBuffer: *mut ::core::ffi::c_char, + aSize: u16, + ); } unsafe extern "C" { - /// Set the Thread Network Name. - /// - /// Succeeds only when Thread protocols are disabled. A successful - /// call to this function invalidates the Active and Pending Operational Datasets in - /// non-volatile memory. + /// Sets the store frame counter ahead. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aNetworkName A pointer to the Thread Network Name. + /// Requires `OPENTHREAD_CONFIG_DYNAMIC_STORE_FRAME_AHEAD_COUNTER_ENABLE` to be enabled. /// - /// @retval OT_ERROR_NONE Successfully set the Thread Network Name. - /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + /// The OpenThread stack stores the MLE and MAC security frame counter values in non-volatile storage, + /// ensuring they persist across device resets. These saved values are set to be ahead of their current + /// values by the "frame counter ahead" value. /// - /// @sa otThreadGetNetworkName - pub fn otThreadSetNetworkName( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aStoreFrameCounterAhead The store frame counter ahead to set. + pub fn otThreadSetStoreFrameCounterAhead( aInstance: *mut otInstance, - aNetworkName: *const ::core::ffi::c_char, - ) -> otError; + aStoreFrameCounterAhead: u32, + ); } unsafe extern "C" { - /// Gets the Thread Domain Name. - /// - /// @note Available since Thread 1.2. + /// Gets the store frame counter ahead. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// Requires `OPENTHREAD_CONFIG_DYNAMIC_STORE_FRAME_AHEAD_COUNTER_ENABLE` to be enabled. /// - /// @returns A pointer to the Thread Domain Name. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @sa otThreadSetDomainName - pub fn otThreadGetDomainName(aInstance: *mut otInstance) -> *const ::core::ffi::c_char; + /// @returns The current store frame counter ahead. + pub fn otThreadGetStoreFrameCounterAhead(aInstance: *mut otInstance) -> u32; } unsafe extern "C" { - /// Sets the Thread Domain Name. Only succeeds when Thread protocols are disabled. + /// Attempts to wake a Wake-up End Device. /// - /// @note Available since Thread 1.2. + /// Requires `OPENTHREAD_CONFIG_WAKEUP_COORDINATOR_ENABLE` to be enabled. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aDomainName A pointer to the Thread Domain Name. + /// The wake-up starts with transmitting a wake-up frame sequence to the Wake-up End Device. + /// During the wake-up sequence, and for a short time after the last wake-up frame is sent, the Wake-up Coordinator keeps + /// its receiver on to be able to receive an initial mesh link establishment message from the WED. /// - /// @retval OT_ERROR_NONE Successfully set the Thread Domain Name. - /// @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. + /// @warning The functionality implemented by this function is still in the design phase. + /// Consequently, the prototype and semantics of this function are subject to change. /// - /// @sa otThreadGetDomainName - pub fn otThreadSetDomainName( - aInstance: *mut otInstance, - aDomainName: *const ::core::ffi::c_char, + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aWedAddress The extended address of the Wake-up End Device. + /// @param[in] aWakeupIntervalUs An interval between consecutive wake-up frames (in microseconds). + /// @param[in] aWakeupDurationMs Duration of the wake-up sequence (in milliseconds). + /// @param[in] aCallback A pointer to function that is called when the wake-up succeeds or fails. + /// @param[in] aCallbackContext A pointer to callback application-specific context. + /// + /// @retval OT_ERROR_NONE Successfully started the wake-up. + /// @retval OT_ERROR_INVALID_STATE Another attachment request is still in progress. + /// @retval OT_ERROR_INVALID_ARGS The wake-up interval or duration are invalid. + pub fn otThreadWakeup( + aInstance: *mut otInstance, + aWedAddress: *const otExtAddress, + aWakeupIntervalUs: u16, + aWakeupDurationMs: u16, + aCallback: otWakeupCallback, + aCallbackContext: *mut ::core::ffi::c_void, ) -> otError; } unsafe extern "C" { - /// Sets or clears the Interface Identifier manually specified for the Thread Domain Unicast Address. - /// - /// Available when `OPENTHREAD_CONFIG_DUA_ENABLE` is enabled. + /// Run all queued OpenThread tasklets at the time this is called. /// - /// @note Only available since Thread 1.2. + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otTaskletsProcess(aInstance: *mut otInstance); +} +unsafe extern "C" { + /// Indicates whether or not OpenThread has tasklets pending. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aIid A pointer to the Interface Identifier to set or NULL to clear. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @retval OT_ERROR_NONE Successfully set/cleared the Interface Identifier. - /// @retval OT_ERROR_INVALID_ARGS The specified Interface Identifier is reserved. + /// @retval TRUE If there are tasklets pending. + /// @retval FALSE If there are no tasklets pending. + pub fn otTaskletsArePending(aInstance: *mut otInstance) -> bool; +} +unsafe extern "C" { + /// OpenThread calls this function when the tasklet queue transitions from empty to non-empty. /// - /// @sa otThreadGetFixedDuaInterfaceIdentifier - pub fn otThreadSetFixedDuaInterfaceIdentifier( - aInstance: *mut otInstance, - aIid: *const otIp6InterfaceIdentifier, - ) -> otError; + /// @param[in] aInstance A pointer to an OpenThread instance. + pub fn otTaskletsSignalPending(aInstance: *mut otInstance); +} +/// @struct otIp4Address +/// +/// Represents an IPv4 address. +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub struct otIp4Address { + pub mFields: otIp4Address__bindgen_ty_1, +} +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub union otIp4Address__bindgen_ty_1 { + ///< 8-bit fields + pub m8: [u8; 4usize], + ///< 32-bit representation + pub m32: u32, +} +impl Default for otIp4Address__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl Default for otIp4Address { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +/// @struct otIp4Cidr +/// +/// Represents an IPv4 CIDR block. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otIp4Cidr { + pub mAddress: otIp4Address, + pub mLength: u8, +} +impl Default for otIp4Cidr { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +/// Represents the counters for NAT64. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otNat64Counters { + ///< Number of packets translated from IPv4 to IPv6. + pub m4To6Packets: u64, + ///< Sum of size of packets translated from IPv4 to IPv6. + pub m4To6Bytes: u64, + ///< Number of packets translated from IPv6 to IPv4. + pub m6To4Packets: u64, + ///< Sum of size of packets translated from IPv6 to IPv4. + pub m6To4Bytes: u64, +} +/// Represents the counters for the protocols supported by NAT64. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otNat64ProtocolCounters { + ///< Counters for sum of all protocols. + pub mTotal: otNat64Counters, + ///< Counters for ICMP and ICMPv6. + pub mIcmp: otNat64Counters, + ///< Counters for UDP. + pub mUdp: otNat64Counters, + ///< Counters for TCP. + pub mTcp: otNat64Counters, +} +///< Packet drop for unknown reasons. +pub const otNat64DropReason_OT_NAT64_DROP_REASON_UNKNOWN: otNat64DropReason = 0; +///< Packet drop due to failed to parse the datagram. +pub const otNat64DropReason_OT_NAT64_DROP_REASON_ILLEGAL_PACKET: otNat64DropReason = 1; +///< Packet drop due to unsupported IP protocol. +pub const otNat64DropReason_OT_NAT64_DROP_REASON_UNSUPPORTED_PROTO: otNat64DropReason = 2; +///< Packet drop due to no mappings found or mapping pool exhausted. +pub const otNat64DropReason_OT_NAT64_DROP_REASON_NO_MAPPING: otNat64DropReason = 3; +pub const otNat64DropReason_OT_NAT64_DROP_REASON_COUNT: otNat64DropReason = 4; +/// Packet drop reasons. +pub type otNat64DropReason = ::core::ffi::c_uint; +/// Represents the counters of dropped packets due to errors when handling NAT64 packets. +#[repr(C)] +#[derive(Default, Copy, Clone)] +pub struct otNat64ErrorCounters { + ///< Errors translating IPv4 packets. + pub mCount4To6: [u64; 4usize], + ///< Errors translating IPv6 packets. + pub mCount6To4: [u64; 4usize], } unsafe extern "C" { - /// Gets the Interface Identifier manually specified for the Thread Domain Unicast Address. + /// Gets NAT64 translator counters. /// - /// Available when `OPENTHREAD_CONFIG_DUA_ENABLE` is enabled. + /// The counter is counted since the instance initialized. /// - /// @note Only available since Thread 1.2. + /// Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled. /// /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aCounters A pointer to an `otNat64Counters` where the counters of NAT64 translator will be placed. + pub fn otNat64GetCounters(aInstance: *mut otInstance, aCounters: *mut otNat64ProtocolCounters); +} +unsafe extern "C" { + /// Gets the NAT64 translator error counters. /// - /// @returns A pointer to the Interface Identifier which was set manually, or NULL if none was set. + /// The counters are initialized to zero when the OpenThread instance is initialized. /// - /// @sa otThreadSetFixedDuaInterfaceIdentifier - pub fn otThreadGetFixedDuaInterfaceIdentifier( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aCounters A pointer to an `otNat64Counters` where the counters of NAT64 translator will be placed. + pub fn otNat64GetErrorCounters( aInstance: *mut otInstance, - ) -> *const otIp6InterfaceIdentifier; + aCounters: *mut otNat64ErrorCounters, + ); +} +/// Represents an address mapping record for NAT64. +/// +/// @note The counters will be reset for each mapping session even for the same address pair. Applications can use `mId` +/// to identify different sessions to calculate the packets correctly. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otNat64AddressMapping { + ///< The unique id for a mapping session. + pub mId: u64, + ///< The IPv4 address of the mapping. + pub mIp4: otIp4Address, + ///< The IPv6 address of the mapping. + pub mIp6: otIp6Address, + /// The source port or ICMP ID of the mapping. Used when + /// OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE is true. + pub mSrcPortOrId: u16, + /// The translated port or ICMP ID of the mapping. Used when + /// OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE is true. + pub mTranslatedPortOrId: u16, + ///< Remaining time before expiry in milliseconds. + pub mRemainingTimeMs: u32, + pub mCounters: otNat64ProtocolCounters, +} +impl Default for otNat64AddressMapping { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +/// Used to iterate through NAT64 address mappings. +/// +/// The fields in this type are opaque (intended for use by OpenThread core only) and therefore should not be +/// accessed or used by caller. +/// +/// Before using an iterator, it MUST be initialized using `otNat64AddressMappingIteratorInit()`. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otNat64AddressMappingIterator { + pub mPtr: *mut ::core::ffi::c_void, +} +impl Default for otNat64AddressMappingIterator { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } unsafe extern "C" { - /// Gets the thrKeySequenceCounter. + /// Initializes an `otNat64AddressMappingIterator`. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// An iterator MUST be initialized before it is used. /// - /// @returns The thrKeySequenceCounter value. + /// An iterator can be initialized again to restart from the beginning of the mapping info. /// - /// @sa otThreadSetKeySequenceCounter - pub fn otThreadGetKeySequenceCounter(aInstance: *mut otInstance) -> u32; + /// @param[in] aInstance The OpenThread instance. + /// @param[out] aIterator A pointer to the iterator to initialize. + pub fn otNat64InitAddressMappingIterator( + aInstance: *mut otInstance, + aIterator: *mut otNat64AddressMappingIterator, + ); } unsafe extern "C" { - /// Sets the thrKeySequenceCounter. + /// Gets the next AddressMapping info (using an iterator). /// - /// @note This API is reserved for testing and demo purposes only. Changing settings with - /// this API will render a production application non-compliant with the Thread Specification. + /// Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aKeySequenceCounter The thrKeySequenceCounter value. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in,out] aIterator A pointer to the iterator. On success the iterator will be updated to point to next + /// NAT64 address mapping record. To get the first entry the iterator should be set to + /// OT_NAT64_ADDRESS_MAPPING_ITERATOR_INIT. + /// @param[out] aMapping A pointer to an `otNat64AddressMapping` where information of next NAT64 address + /// mapping record is placed (on success). /// - /// @sa otThreadGetKeySequenceCounter - pub fn otThreadSetKeySequenceCounter(aInstance: *mut otInstance, aKeySequenceCounter: u32); + /// @retval OT_ERROR_NONE Successfully found the next NAT64 address mapping info (@p aMapping was successfully + /// updated). + /// @retval OT_ERROR_NOT_FOUND No subsequent NAT64 address mapping info was found. + pub fn otNat64GetNextAddressMapping( + aInstance: *mut otInstance, + aIterator: *mut otNat64AddressMappingIterator, + aMapping: *mut otNat64AddressMapping, + ) -> otError; } +///< NAT64 is disabled. +pub const otNat64State_OT_NAT64_STATE_DISABLED: otNat64State = 0; +///< NAT64 is enabled, but one or more dependencies of NAT64 are not running. +pub const otNat64State_OT_NAT64_STATE_NOT_RUNNING: otNat64State = 1; +///< NAT64 is enabled, but this BR is not an active NAT64 BR. +pub const otNat64State_OT_NAT64_STATE_IDLE: otNat64State = 2; +///< The BR is publishing a NAT64 prefix and/or translating packets. +pub const otNat64State_OT_NAT64_STATE_ACTIVE: otNat64State = 3; +/// States of NAT64. +pub type otNat64State = ::core::ffi::c_uint; unsafe extern "C" { - /// Gets the thrKeySwitchGuardTime (in hours). + /// Gets the state of NAT64 translator. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled. /// - /// @returns The thrKeySwitchGuardTime value (in hours). + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @sa otThreadSetKeySwitchGuardTime - pub fn otThreadGetKeySwitchGuardTime(aInstance: *mut otInstance) -> u16; + /// @retval OT_NAT64_STATE_DISABLED NAT64 translator is disabled. + /// @retval OT_NAT64_STATE_NOT_RUNNING NAT64 translator is enabled, but the translator is not configured with a valid + /// NAT64 prefix and a CIDR. + /// @retval OT_NAT64_STATE_ACTIVE NAT64 translator is enabled, and is translating packets. + pub fn otNat64GetTranslatorState(aInstance: *mut otInstance) -> otNat64State; } unsafe extern "C" { - /// Sets the thrKeySwitchGuardTime (in hours). + /// Gets the state of NAT64 prefix manager. /// - /// @note This API is reserved for testing and demo purposes only. Changing settings with - /// this API will render a production application non-compliant with the Thread Specification. + /// Available when `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is enabled. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aKeySwitchGuardTime The thrKeySwitchGuardTime value (in hours). + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @sa otThreadGetKeySwitchGuardTime - pub fn otThreadSetKeySwitchGuardTime(aInstance: *mut otInstance, aKeySwitchGuardTime: u16); + /// @retval OT_NAT64_STATE_DISABLED NAT64 prefix manager is disabled. + /// @retval OT_NAT64_STATE_NOT_RUNNING NAT64 prefix manager is enabled, but is not running (because the routing manager + /// is not running). + /// @retval OT_NAT64_STATE_IDLE NAT64 prefix manager is enabled, but is not publishing a NAT64 prefix. Usually + /// when there is another border router publishing a NAT64 prefix with higher + /// priority. + /// @retval OT_NAT64_STATE_ACTIVE NAT64 prefix manager is enabled, and is publishing NAT64 prefix to the Thread + /// network. + pub fn otNat64GetPrefixManagerState(aInstance: *mut otInstance) -> otNat64State; } unsafe extern "C" { - /// Detach from the Thread network. + /// Enable or disable NAT64 functions. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// Note: This includes the NAT64 Translator (when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled) and the NAT64 + /// Prefix Manager (when `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is enabled). /// - /// @retval OT_ERROR_NONE Successfully detached from the Thread network. - /// @retval OT_ERROR_INVALID_STATE Thread is disabled. - pub fn otThreadBecomeDetached(aInstance: *mut otInstance) -> otError; -} -unsafe extern "C" { - /// Attempt to reattach as a child. + /// When `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled, setting disabled to true resets the + /// mapping table in the translator. /// - /// @note This API is reserved for testing and demo purposes only. Changing settings with - /// this API will render a production application non-compliant with the Thread Specification. + /// Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` or `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is + /// enabled. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aEnabled A boolean to enable/disable the NAT64 functions /// - /// @retval OT_ERROR_NONE Successfully begin attempt to become a child. - /// @retval OT_ERROR_INVALID_STATE Thread is disabled. - pub fn otThreadBecomeChild(aInstance: *mut otInstance) -> otError; + /// @sa otNat64GetTranslatorState + /// @sa otNat64GetPrefixManagerState + pub fn otNat64SetEnabled(aInstance: *mut otInstance, aEnabled: bool); } unsafe extern "C" { - /// Gets the next neighbor information. It is used to go through the entries of - /// the neighbor table. + /// Allocate a new message buffer for sending an IPv4 message to the NAT64 translator. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in,out] aIterator A pointer to the iterator context. To get the first neighbor entry - ///it should be set to OT_NEIGHBOR_INFO_ITERATOR_INIT. - /// @param[out] aInfo A pointer to the neighbor information. + /// Message buffers allocated by this function will have 20 bytes (difference between the size of IPv6 headers + /// and IPv4 header sizes) reserved. /// - /// @retval OT_ERROR_NONE Successfully found the next neighbor entry in table. - /// @retval OT_ERROR_NOT_FOUND No subsequent neighbor entry exists in the table. - /// @retval OT_ERROR_INVALID_ARGS @p aIterator or @p aInfo was NULL. - pub fn otThreadGetNextNeighborInfo( - aInstance: *mut otInstance, - aIterator: *mut otNeighborInfoIterator, - aInfo: *mut otNeighborInfo, - ) -> otError; -} -unsafe extern "C" { - /// Get the device role. + /// Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @note If @p aSettings is `NULL`, the link layer security is enabled and the message priority is set to + /// OT_MESSAGE_PRIORITY_NORMAL by default. /// - /// @retval OT_DEVICE_ROLE_DISABLED The Thread stack is disabled. - /// @retval OT_DEVICE_ROLE_DETACHED The device is not currently participating in a Thread network/partition. - /// @retval OT_DEVICE_ROLE_CHILD The device is currently operating as a Thread Child. - /// @retval OT_DEVICE_ROLE_ROUTER The device is currently operating as a Thread Router. - /// @retval OT_DEVICE_ROLE_LEADER The device is currently operating as a Thread Leader. - pub fn otThreadGetDeviceRole(aInstance: *mut otInstance) -> otDeviceRole; -} -unsafe extern "C" { - /// Convert the device role to human-readable string. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aSettings A pointer to the message settings or NULL to set default settings. /// - /// @param[in] aRole The device role to convert. + /// @returns A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid. /// - /// @returns A string representing @p aRole. - pub fn otThreadDeviceRoleToString(aRole: otDeviceRole) -> *const ::core::ffi::c_char; + /// @sa otNat64Send + pub fn otIp4NewMessage( + aInstance: *mut otInstance, + aSettings: *const otMessageSettings, + ) -> *mut otMessage; } unsafe extern "C" { - /// Get the Thread Leader Data. + /// Sets the CIDR used when setting the source address of the outgoing translated IPv4 packets. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[out] aLeaderData A pointer to where the leader data is placed. + /// Is available only when OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE is enabled. /// - /// @retval OT_ERROR_NONE Successfully retrieved the leader data. - /// @retval OT_ERROR_DETACHED Not currently attached. - pub fn otThreadGetLeaderData( - aInstance: *mut otInstance, - aLeaderData: *mut otLeaderData, - ) -> otError; -} -unsafe extern "C" { - /// Get the Leader's Router ID. + /// @note A valid CIDR must have a non-zero prefix length. The actual addresses pool is limited by the size of the + /// mapping pool and the number of addresses available in the CIDR block. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @note This function can be called at any time, but the NAT64 translator will be reset and all existing sessions will + /// be expired when updating the configured CIDR. /// - /// @returns The Leader's Router ID. - pub fn otThreadGetLeaderRouterId(aInstance: *mut otInstance) -> u8; -} -unsafe extern "C" { - /// Get the Leader's Weight. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aCidr A pointer to an otIp4Cidr for the IPv4 CIDR block for NAT64. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @retval OT_ERROR_INVALID_ARGS The given CIDR is not a valid IPv4 CIDR for NAT64. + /// @retval OT_ERROR_NONE Successfully set the CIDR for NAT64. /// - /// @returns The Leader's Weight. - pub fn otThreadGetLeaderWeight(aInstance: *mut otInstance) -> u8; + /// @sa otNat64Send + /// @sa otNat64SetReceiveIp4Callback + pub fn otNat64SetIp4Cidr(aInstance: *mut otInstance, aCidr: *const otIp4Cidr) -> otError; } unsafe extern "C" { - /// Get the Partition ID. + /// Clears the CIDR used when setting the source address of the outgoing translated IPv4 packets. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// Is available only when OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE is enabled. /// - /// @returns The Partition ID. - pub fn otThreadGetPartitionId(aInstance: *mut otInstance) -> u32; + /// @note This function can be called at any time, but the NAT64 translator will be reset and all existing sessions + /// will be expired when clearing the configured CIDR. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @sa otNat64SetIp4Cidr + pub fn otNat64ClearIp4Cidr(aInstance: *mut otInstance); } unsafe extern "C" { - /// Get the RLOC16. + /// Translates an IPv4 datagram to an IPv6 datagram and sends via the Thread interface. + /// + /// The caller transfers ownership of @p aMessage when making this call. OpenThread will free @p aMessage when + /// processing is complete, including when a value other than `OT_ERROR_NONE` is returned. /// /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aMessage A pointer to the message buffer containing the IPv4 datagram. /// - /// @returns The RLOC16. - pub fn otThreadGetRloc16(aInstance: *mut otInstance) -> u16; + /// @retval OT_ERROR_NONE Successfully processed the message. + /// @retval OT_ERROR_DROP Message was well-formed but not fully processed due to packet processing + /// rules. + /// @retval OT_ERROR_NO_BUFS Could not allocate necessary message buffers when processing the datagram. + /// @retval OT_ERROR_NO_ROUTE No route to host. + /// @retval OT_ERROR_INVALID_SOURCE_ADDRESS Source address is invalid, e.g. an anycast address or a multicast address. + /// @retval OT_ERROR_PARSE Encountered a malformed header when processing the message. + pub fn otNat64Send(aInstance: *mut otInstance, aMessage: *mut otMessage) -> otError; } +/// Pointer is called when an IPv4 datagram (translated by NAT64 translator) is received. +/// +/// @param[in] aMessage A pointer to the message buffer containing the received IPv6 datagram. This function transfers +/// the ownership of the @p aMessage to the receiver of the callback. The message should be +/// freed by the receiver of the callback after it is processed. +/// @param[in] aContext A pointer to application-specific context. +pub type otNat64ReceiveIp4Callback = ::core::option::Option< + unsafe extern "C" fn(aMessage: *mut otMessage, aContext: *mut ::core::ffi::c_void), +>; unsafe extern "C" { - /// The function retrieves diagnostic information for a Thread Router as parent. + /// Registers a callback to provide received IPv4 datagrams. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[out] aParentInfo A pointer to where the parent router information is placed. - pub fn otThreadGetParentInfo( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aCallback A pointer to a function that is called when an IPv4 datagram is received or + /// NULL to disable the callback. + /// @param[in] aContext A pointer to application-specific context. + pub fn otNat64SetReceiveIp4Callback( aInstance: *mut otInstance, - aParentInfo: *mut otRouterInfo, - ) -> otError; + aCallback: otNat64ReceiveIp4Callback, + aContext: *mut ::core::ffi::c_void, + ); } unsafe extern "C" { - /// The function retrieves the average RSSI for the Thread Parent. + /// Gets the IPv4 CIDR configured in the NAT64 translator. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[out] aParentRssi A pointer to where the parent RSSI should be placed. - pub fn otThreadGetParentAverageRssi( - aInstance: *mut otInstance, - aParentRssi: *mut i8, - ) -> otError; + /// Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled. + /// + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[out] aCidr A pointer to an otIp4Cidr. Where the CIDR will be filled. + pub fn otNat64GetCidr(aInstance: *mut otInstance, aCidr: *mut otIp4Cidr) -> otError; } unsafe extern "C" { - /// The function retrieves the RSSI of the last packet from the Thread Parent. + /// Test if two IPv4 addresses are the same. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[out] aLastRssi A pointer to where the last RSSI should be placed. + /// @param[in] aFirst A pointer to the first IPv4 address to compare. + /// @param[in] aSecond A pointer to the second IPv4 address to compare. /// - /// @retval OT_ERROR_NONE Successfully retrieved the RSSI data. - /// @retval OT_ERROR_FAILED Unable to get RSSI data. - /// @retval OT_ERROR_INVALID_ARGS @p aLastRssi is NULL. - pub fn otThreadGetParentLastRssi(aInstance: *mut otInstance, aLastRssi: *mut i8) -> otError; + /// @retval TRUE The two IPv4 addresses are the same. + /// @retval FALSE The two IPv4 addresses are not the same. + pub fn otIp4IsAddressEqual(aFirst: *const otIp4Address, aSecond: *const otIp4Address) -> bool; } unsafe extern "C" { - /// Starts the process for child to search for a better parent while staying attached to its current parent. + /// Set @p aIp4Address by performing NAT64 address translation from @p aIp6Address as specified + /// in RFC 6052. /// - /// Must be used when device is attached as a child. + /// The NAT64 @p aPrefixLength MUST be one of the following values: 32, 40, 48, 56, 64, or 96, otherwise the behavior + /// of this method is undefined. /// - /// @retval OT_ERROR_NONE Successfully started the process to search for a better parent. - /// @retval OT_ERROR_INVALID_STATE Device role is not child. - pub fn otThreadSearchForBetterParent(aInstance: *mut otInstance) -> otError; + /// @param[in] aPrefixLength The prefix length to use for IPv4/IPv6 translation. + /// @param[in] aIp6Address A pointer to an IPv6 address. + /// @param[out] aIp4Address A pointer to output the IPv4 address. + pub fn otIp4ExtractFromIp6Address( + aPrefixLength: u8, + aIp6Address: *const otIp6Address, + aIp4Address: *mut otIp4Address, + ); } unsafe extern "C" { - /// Gets the IPv6 counters. + /// Extracts the IPv4 address from a given IPv4-mapped IPv6 address. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// An IPv4-mapped IPv6 address consists of an 80-bit prefix of zeros, the next 16 bits set to ones, and the remaining, + /// least-significant 32 bits contain the IPv4 address, e.g., `::ffff:192.0.2.128` representing `192.0.2.128`. /// - /// @returns A pointer to the IPv6 counters. - pub fn otThreadGetIp6Counters(aInstance: *mut otInstance) -> *const otIpCounters; + /// @param[in] aIp6Address An IPv6 address to extract IPv4 from. + /// @param[out] aIp4Address An IPv4 address to output the extracted address. + /// + /// @retval OT_ERROR_NONE Extracted the IPv4 address successfully. @p aIp4Address is updated. + /// @retval OT_ERROR_PARSE The @p aIp6Address does not follow the IPv4-mapped IPv6 address format. + pub fn otIp4FromIp4MappedIp6Address( + aIp6Address: *const otIp6Address, + aIp4Address: *mut otIp4Address, + ) -> otError; } unsafe extern "C" { - /// Resets the IPv6 counters. + /// Converts a given IP4 address to an IPv6 address following the IPv4-mapped IPv6 address format. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otThreadResetIp6Counters(aInstance: *mut otInstance); + /// @param[in] aIp4Address An IPv4 address to convert. + /// @param[out] aIp6Address An IPv6 address to set. + pub fn otIp4ToIp4MappedIp6Address( + aIp4Address: *const otIp4Address, + aIp6Address: *mut otIp6Address, + ); } unsafe extern "C" { - /// Gets the time-in-queue histogram for messages in the TX queue. - /// - /// Requires `OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE`. + /// Converts the address to a string. /// - /// Histogram of the time-in-queue of messages in the transmit queue is collected. The time-in-queue is tracked for - /// direct transmissions only and is measured as the duration from when a message is added to the transmit queue until - /// it is passed to the MAC layer for transmission or dropped. - /// - /// The histogram is returned as an array of `uint32_t` values with `aNumBins` entries. The first entry in the array - /// (at index 0) represents the number of messages with a time-in-queue less than `aBinInterval`. The second entry - /// represents the number of messages with a time-in-queue greater than or equal to `aBinInterval`, but less than - /// `2 * aBinInterval`. And so on. The last entry represents the number of messages with time-in-queue greater than or - /// equal to `(aNumBins - 1) * aBinInterval`. + /// The string format uses quad-dotted notation of four bytes in the address (e.g., "127.0.0.1"). /// - /// The collected statistics can be reset by calling `otThreadResetTimeInQueueStat()`. The histogram information is - /// collected since the OpenThread instance was initialized or since the last time statistics collection was reset by - /// calling the `otThreadResetTimeInQueueStat()`. + /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be + /// truncated but the outputted string is always null-terminated. /// - /// Pointers @p aNumBins and @p aBinInterval MUST NOT be NULL. + /// @param[in] aAddress A pointer to an IPv4 address (MUST NOT be NULL). + /// @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL). + /// @param[in] aSize The size of @p aBuffer (in bytes). + pub fn otIp4AddressToString( + aAddress: *const otIp4Address, + aBuffer: *mut ::core::ffi::c_char, + aSize: u16, + ); +} +unsafe extern "C" { + /// Converts a human-readable IPv4 CIDR string into a binary representation. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[out] aNumBins Pointer to return the number of bins in histogram (array length). - /// @param[out] aBinInterval Pointer to return the histogram bin interval length in milliseconds. + /// @param[in] aString A pointer to a NULL-terminated string. + /// @param[out] aCidr A pointer to an IPv4 CIDR. /// - /// @returns A pointer to an array of @p aNumBins entries representing the collected histogram info. - pub fn otThreadGetTimeInQueueHistogram( - aInstance: *mut otInstance, - aNumBins: *mut u16, - aBinInterval: *mut u32, - ) -> *const u32; + /// @retval OT_ERROR_NONE Successfully parsed the string. + /// @retval OT_ERROR_INVALID_ARGS Failed to parse the string. + pub fn otIp4CidrFromString( + aString: *const ::core::ffi::c_char, + aCidr: *mut otIp4Cidr, + ) -> otError; } unsafe extern "C" { - /// Gets the maximum time-in-queue for messages in the TX queue. + /// Converts the IPv4 CIDR to a string. /// - /// Requires `OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE`. + /// The string format uses quad-dotted notation of four bytes in the address with the length of prefix (e.g., + /// "127.0.0.1/32"). /// - /// The time-in-queue is tracked for direct transmissions only and is measured as the duration from when a message is - /// added to the transmit queue until it is passed to the MAC layer for transmission or dropped. + /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be + /// truncated but the outputted string is always null-terminated. /// - /// The collected statistics can be reset by calling `otThreadResetTimeInQueueStat()`. + /// @param[in] aCidr A pointer to an IPv4 CIDR (MUST NOT be NULL). + /// @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be NULL). + /// @param[in] aSize The size of @p aBuffer (in bytes). + pub fn otIp4CidrToString( + aCidr: *const otIp4Cidr, + aBuffer: *mut ::core::ffi::c_char, + aSize: u16, + ); +} +unsafe extern "C" { + /// Converts a human-readable IPv4 address string into a binary representation. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aString A pointer to a NULL-terminated string. + /// @param[out] aAddress A pointer to an IPv4 address. /// - /// @returns The maximum time-in-queue in milliseconds for all messages in the TX queue (so far). - pub fn otThreadGetMaxTimeInQueue(aInstance: *mut otInstance) -> u32; + /// @retval OT_ERROR_NONE Successfully parsed the string. + /// @retval OT_ERROR_INVALID_ARGS Failed to parse the string. + pub fn otIp4AddressFromString( + aString: *const ::core::ffi::c_char, + aAddress: *mut otIp4Address, + ) -> otError; } unsafe extern "C" { - /// Resets the TX queue time-in-queue statistics. + /// Sets the IPv6 address by performing NAT64 address translation from the preferred NAT64 prefix and the given IPv4 + /// address as specified in RFC 6052. /// - /// Requires `OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE`. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aIp4Address A pointer to the IPv4 address to translate to IPv6. + /// @param[out] aIp6Address A pointer to the synthesized IPv6 address. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otThreadResetTimeInQueueStat(aInstance: *mut otInstance); + /// @returns OT_ERROR_NONE Successfully synthesized the IPv6 address from NAT64 prefix and IPv4 address. + /// @returns OT_ERROR_INVALID_STATE No valid NAT64 prefix in the network data. + pub fn otNat64SynthesizeIp6Address( + aInstance: *mut otInstance, + aIp4Address: *const otIp4Address, + aIp6Address: *mut otIp6Address, + ) -> otError; +} +pub type otNetworkDataIterator = u32; +/// Represents a Border Router configuration. +#[repr(C)] +#[repr(align(4))] +#[derive(Copy, Clone)] +pub struct otBorderRouterConfig { + ///< The IPv6 prefix. + pub mPrefix: otIp6Prefix, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + ///< The border router's RLOC16 (value ignored on config add). + pub mRloc16: u16, +} +impl Default for otBorderRouterConfig { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl otBorderRouterConfig { + #[inline] + pub fn mPreference(&self) -> ::core::ffi::c_int { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) } + } + #[inline] + pub fn set_mPreference(&mut self, val: ::core::ffi::c_int) { + unsafe { + let val: u32 = ::core::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub unsafe fn mPreference_raw(this: *const Self) -> ::core::ffi::c_int { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 0usize, + 2u8, + ) as u32) + } + } + #[inline] + pub unsafe fn set_mPreference_raw(this: *mut Self, val: ::core::ffi::c_int) { + unsafe { + let val: u32 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 2u8, + val as u64, + ) + } + } + #[inline] + pub fn mPreferred(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mPreferred(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mPreferred_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 2usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mPreferred_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 2usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mSlaac(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_mSlaac(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mSlaac_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 3usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mSlaac_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 3usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mDhcp(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_mDhcp(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mDhcp_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 4usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mDhcp_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 4usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mConfigure(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_mConfigure(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mConfigure_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 5usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mConfigure_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 5usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mDefaultRoute(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_mDefaultRoute(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mDefaultRoute_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 6usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mDefaultRoute_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 6usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mOnMesh(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u8) } + } + #[inline] + pub fn set_mOnMesh(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mOnMesh_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 7usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mOnMesh_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 7usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mStable(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u8) } + } + #[inline] + pub fn set_mStable(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(8usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mStable_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 8usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mStable_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 8usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mNdDns(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u8) } + } + #[inline] + pub fn set_mNdDns(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(9usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mNdDns_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 9usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mNdDns_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 9usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mDp(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u8) } + } + #[inline] + pub fn set_mDp(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(10usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mDp_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 2usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 10usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mDp_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 2usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 10usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn new_bitfield_1( + mPreference: ::core::ffi::c_int, + mPreferred: bool, + mSlaac: bool, + mDhcp: bool, + mConfigure: bool, + mDefaultRoute: bool, + mOnMesh: bool, + mStable: bool, + mNdDns: bool, + mDp: bool, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let mPreference: u32 = unsafe { ::core::mem::transmute(mPreference) }; + mPreference as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mPreferred: u8 = unsafe { ::core::mem::transmute(mPreferred) }; + mPreferred as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let mSlaac: u8 = unsafe { ::core::mem::transmute(mSlaac) }; + mSlaac as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let mDhcp: u8 = unsafe { ::core::mem::transmute(mDhcp) }; + mDhcp as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let mConfigure: u8 = unsafe { ::core::mem::transmute(mConfigure) }; + mConfigure as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let mDefaultRoute: u8 = unsafe { ::core::mem::transmute(mDefaultRoute) }; + mDefaultRoute as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let mOnMesh: u8 = unsafe { ::core::mem::transmute(mOnMesh) }; + mOnMesh as u64 + }); + __bindgen_bitfield_unit.set(8usize, 1u8, { + let mStable: u8 = unsafe { ::core::mem::transmute(mStable) }; + mStable as u64 + }); + __bindgen_bitfield_unit.set(9usize, 1u8, { + let mNdDns: u8 = unsafe { ::core::mem::transmute(mNdDns) }; + mNdDns as u64 + }); + __bindgen_bitfield_unit.set(10usize, 1u8, { + let mDp: u8 = unsafe { ::core::mem::transmute(mDp) }; + mDp as u64 + }); + __bindgen_bitfield_unit + } } -unsafe extern "C" { - /// Gets the Thread MLE counters. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// - /// @returns A pointer to the Thread MLE counters. - pub fn otThreadGetMleCounters(aInstance: *mut otInstance) -> *const otMleCounters; +/// Represents 6LoWPAN Context ID information associated with a prefix in Network Data. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otLowpanContextInfo { + ///< The 6LoWPAN Context ID. + pub mContextId: u8, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + ///< The associated IPv6 prefix. + pub mPrefix: otIp6Prefix, } -unsafe extern "C" { - /// Resets the Thread MLE counters. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otThreadResetMleCounters(aInstance: *mut otInstance); +impl Default for otLowpanContextInfo { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -/// Pointer is called every time an MLE Parent Response message is received. -/// -/// This is used in `otThreadRegisterParentResponseCallback()`. -/// -/// @param[in] aInfo A pointer to a location on stack holding the stats data. -/// @param[in] aContext A pointer to callback client-specific context. -pub type otThreadParentResponseCallback = ::core::option::Option< - unsafe extern "C" fn( - aInfo: *mut otThreadParentResponseInfo, - aContext: *mut ::core::ffi::c_void, - ), ->; -unsafe extern "C" { - /// Registers a callback to receive MLE Parent Response data. - /// - /// Requires `OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE`. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aCallback A pointer to a function that is called upon receiving an MLE Parent Response message. - /// @param[in] aContext A pointer to callback client-specific context. - pub fn otThreadRegisterParentResponseCallback( - aInstance: *mut otInstance, - aCallback: otThreadParentResponseCallback, - aContext: *mut ::core::ffi::c_void, - ); +impl otLowpanContextInfo { + #[inline] + pub fn mCompressFlag(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_mCompressFlag(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mCompressFlag_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 0usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mCompressFlag_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mStable(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mStable(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mStable_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 1usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mStable_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 1usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn new_bitfield_1( + mCompressFlag: bool, + mStable: bool, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let mCompressFlag: u8 = unsafe { ::core::mem::transmute(mCompressFlag) }; + mCompressFlag as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mStable: u8 = unsafe { ::core::mem::transmute(mStable) }; + mStable as u64 + }); + __bindgen_bitfield_unit + } } -/// Represents the Thread Discovery Request data. +/// Represents an External Route configuration. #[repr(C)] +#[repr(align(4))] #[derive(Copy, Clone)] -pub struct otThreadDiscoveryRequestInfo { - ///< IEEE 802.15.4 Extended Address of the requester - pub mExtAddress: otExtAddress, +pub struct otExternalRouteConfig { + ///< The IPv6 prefix. + pub mPrefix: otIp6Prefix, + ///< The border router's RLOC16 (value ignored on config add). + pub mRloc16: u16, pub _bitfield_align_1: [u8; 0], pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], } -impl otThreadDiscoveryRequestInfo { +impl Default for otExternalRouteConfig { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl otExternalRouteConfig { #[inline] - pub fn mVersion(&self) -> u8 { - unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u8) } + pub fn mPreference(&self) -> ::core::ffi::c_int { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) } } #[inline] - pub fn set_mVersion(&mut self, val: u8) { + pub fn set_mPreference(&mut self, val: ::core::ffi::c_int) { unsafe { - let val: u8 = ::core::mem::transmute(val); - self._bitfield_1.set(0usize, 4u8, val as u64) + let val: u32 = ::core::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) } } #[inline] - pub unsafe fn mVersion_raw(this: *const Self) -> u8 { + pub unsafe fn mPreference_raw(this: *const Self) -> ::core::ffi::c_int { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), 0usize, - 4u8, + 2u8, + ) as u32) + } + } + #[inline] + pub unsafe fn set_mPreference_raw(this: *mut Self, val: ::core::ffi::c_int) { + unsafe { + let val: u32 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 2u8, + val as u64, + ) + } + } + #[inline] + pub fn mNat64(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mNat64(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mNat64_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 2usize, + 1u8, ) as u8) } } #[inline] - pub unsafe fn set_mVersion_raw(this: *mut Self, val: u8) { + pub unsafe fn set_mNat64_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( ::core::ptr::addr_of_mut!((*this)._bitfield_1), - 0usize, - 4u8, + 2usize, + 1u8, val as u64, ) } } #[inline] - pub fn mIsJoiner(&self) -> bool { + pub fn mStable(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_mStable(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mStable_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 3usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mStable_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 3usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn mNextHopIsThisDevice(&self) -> bool { unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } } #[inline] - pub fn set_mIsJoiner(&mut self, val: bool) { + pub fn set_mNextHopIsThisDevice(&mut self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 1u8, val as u64) } } #[inline] - pub unsafe fn mIsJoiner_raw(this: *const Self) -> bool { + pub unsafe fn mNextHopIsThisDevice_raw(this: *const Self) -> bool { unsafe { ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( ::core::ptr::addr_of!((*this)._bitfield_1), @@ -10192,7 +10877,7 @@ impl otThreadDiscoveryRequestInfo { } } #[inline] - pub unsafe fn set_mIsJoiner_raw(this: *mut Self, val: bool) { + pub unsafe fn set_mNextHopIsThisDevice_raw(this: *mut Self, val: bool) { unsafe { let val: u8 = ::core::mem::transmute(val); <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( @@ -10204,211 +10889,342 @@ impl otThreadDiscoveryRequestInfo { } } #[inline] - pub fn new_bitfield_1(mVersion: u8, mIsJoiner: bool) -> __BindgenBitfieldUnit<[u8; 1usize]> { + pub fn mAdvPio(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_mAdvPio(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mAdvPio_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 5usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mAdvPio_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 5usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn new_bitfield_1( + mPreference: ::core::ffi::c_int, + mNat64: bool, + mStable: bool, + mNextHopIsThisDevice: bool, + mAdvPio: bool, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); - __bindgen_bitfield_unit.set(0usize, 4u8, { - let mVersion: u8 = unsafe { ::core::mem::transmute(mVersion) }; - mVersion as u64 + __bindgen_bitfield_unit.set(0usize, 2u8, { + let mPreference: u32 = unsafe { ::core::mem::transmute(mPreference) }; + mPreference as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mNat64: u8 = unsafe { ::core::mem::transmute(mNat64) }; + mNat64 as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let mStable: u8 = unsafe { ::core::mem::transmute(mStable) }; + mStable as u64 }); __bindgen_bitfield_unit.set(4usize, 1u8, { - let mIsJoiner: u8 = unsafe { ::core::mem::transmute(mIsJoiner) }; - mIsJoiner as u64 + let mNextHopIsThisDevice: u8 = unsafe { ::core::mem::transmute(mNextHopIsThisDevice) }; + mNextHopIsThisDevice as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let mAdvPio: u8 = unsafe { ::core::mem::transmute(mAdvPio) }; + mAdvPio as u64 }); __bindgen_bitfield_unit } } -/// Pointer is called every time an MLE Discovery Request message is received. -/// -/// @param[in] aInfo A pointer to the Discovery Request info data. -/// @param[in] aContext A pointer to callback application-specific context. -pub type otThreadDiscoveryRequestCallback = ::core::option::Option< - unsafe extern "C" fn( - aInfo: *const otThreadDiscoveryRequestInfo, - aContext: *mut ::core::ffi::c_void, - ), ->; -unsafe extern "C" { - /// Sets a callback to receive MLE Discovery Request data. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aCallback A pointer to a function that is called upon receiving an MLE Discovery Request message. - /// @param[in] aContext A pointer to callback application-specific context. - pub fn otThreadSetDiscoveryRequestCallback( - aInstance: *mut otInstance, - aCallback: otThreadDiscoveryRequestCallback, - aContext: *mut ::core::ffi::c_void, - ); +///< Low route preference. +pub const otRoutePreference_OT_ROUTE_PREFERENCE_LOW: otRoutePreference = -1; +///< Medium route preference. +pub const otRoutePreference_OT_ROUTE_PREFERENCE_MED: otRoutePreference = 0; +///< High route preference. +pub const otRoutePreference_OT_ROUTE_PREFERENCE_HIGH: otRoutePreference = 1; +/// Defines valid values for `mPreference` in `otExternalRouteConfig` and `otBorderRouterConfig`. +pub type otRoutePreference = ::core::ffi::c_int; +/// Represents a Server configuration. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otServerConfig { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + ///< Length of server data. + pub mServerDataLength: u8, + ///< Server data bytes. + pub mServerData: [u8; 248usize], + ///< The Server RLOC16. + pub mRloc16: u16, +} +impl Default for otServerConfig { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl otServerConfig { + #[inline] + pub fn mStable(&self) -> bool { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_mStable(&mut self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub unsafe fn mStable_raw(this: *const Self) -> bool { + unsafe { + ::core::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get( + ::core::ptr::addr_of!((*this)._bitfield_1), + 0usize, + 1u8, + ) as u8) + } + } + #[inline] + pub unsafe fn set_mStable_raw(this: *mut Self, val: bool) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set( + ::core::ptr::addr_of_mut!((*this)._bitfield_1), + 0usize, + 1u8, + val as u64, + ) + } + } + #[inline] + pub fn new_bitfield_1(mStable: bool) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let mStable: u8 = unsafe { ::core::mem::transmute(mStable) }; + mStable as u64 + }); + __bindgen_bitfield_unit + } +} +/// Represents a Service configuration. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct otServiceConfig { + ///< Service ID (when iterating over the Network Data). + pub mServiceId: u8, + ///< IANA Enterprise Number. + pub mEnterpriseNumber: u32, + ///< Length of service data. + pub mServiceDataLength: u8, + ///< Service data bytes. + pub mServiceData: [u8; 252usize], + ///< The Server configuration. + pub mServerConfig: otServerConfig, +} +impl Default for otServiceConfig { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -/// Pointer type defines the callback to notify the outcome of a `otThreadLocateAnycastDestination()` -/// request. -/// -/// @param[in] aContext A pointer to an arbitrary context (provided when callback is registered). -/// @param[in] aError The error when handling the request. OT_ERROR_NONE indicates success. -/// OT_ERROR_RESPONSE_TIMEOUT indicates a destination could not be found. -/// OT_ERROR_ABORT indicates the request was aborted. -/// @param[in] aMeshLocalAddress A pointer to the mesh-local EID of the closest destination of the anycast address -/// when @p aError is OT_ERROR_NONE, NULL otherwise. -/// @param[in] aRloc16 The RLOC16 of the destination if found, otherwise invalid RLOC16 (0xfffe). -pub type otThreadAnycastLocatorCallback = ::core::option::Option< - unsafe extern "C" fn( - aContext: *mut ::core::ffi::c_void, - aError: otError, - aMeshLocalAddress: *const otIp6Address, - aRloc16: u16, - ), ->; unsafe extern "C" { - /// Requests the closest destination of a given anycast address to be located. - /// - /// Is only available when `OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE` is enabled. + /// Provide full or stable copy of the Partition's Thread Network Data. /// - /// If a previous request is ongoing, a subsequent call to this function will cancel and replace the earlier request. - /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aAnycastAddress The anycast address to locate. MUST NOT be NULL. - /// @param[in] aCallback The callback function to report the result. - /// @param[in] aContext An arbitrary context used with @p aCallback. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aStable TRUE when copying the stable version, FALSE when copying the full version. + /// @param[out] aData A pointer to the data buffer. + /// @param[in,out] aDataLength On entry, size of the data buffer pointed to by @p aData. + /// On exit, number of copied bytes. /// - /// @retval OT_ERROR_NONE The request started successfully. @p aCallback will be invoked to report the result. - /// @retval OT_ERROR_INVALID_ARGS The @p aAnycastAddress is not a valid anycast address or @p aCallback is NULL. - /// @retval OT_ERROR_NO_BUFS Out of buffer to prepare and send the request message. - pub fn otThreadLocateAnycastDestination( + /// @retval OT_ERROR_NONE Successfully copied the Thread Network Data into @p aData and updated @p aDataLength. + /// @retval OT_ERROR_NO_BUFS Not enough space in @p aData to fully copy the Thread Network Data. + pub fn otNetDataGet( aInstance: *mut otInstance, - aAnycastAddress: *const otIp6Address, - aCallback: otThreadAnycastLocatorCallback, - aContext: *mut ::core::ffi::c_void, + aStable: bool, + aData: *mut u8, + aDataLength: *mut u8, ) -> otError; } unsafe extern "C" { - /// Indicates whether an anycast locate request is currently in progress. - /// - /// Is only available when `OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE` is enabled. + /// Get the current length (number of bytes) of Partition's Thread Network Data. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @returns TRUE if an anycast locate request is currently in progress, FALSE otherwise. - pub fn otThreadIsAnycastLocateInProgress(aInstance: *mut otInstance) -> bool; + /// @return The length of the Network Data. + pub fn otNetDataGetLength(aInstance: *mut otInstance) -> u8; } unsafe extern "C" { - /// Sends a Proactive Address Notification (ADDR_NTF.ntf) message. + /// Get the maximum observed length of the Thread Network Data since OT stack initialization or since the last call to + /// `otNetDataResetMaxLength()`. /// - /// Is only available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aDestination The destination to send the ADDR_NTF.ntf message. - /// @param[in] aTarget The target address of the ADDR_NTF.ntf message. - /// @param[in] aMlIid The ML-IID of the ADDR_NTF.ntf message. - pub fn otThreadSendAddressNotification( - aInstance: *mut otInstance, - aDestination: *mut otIp6Address, - aTarget: *mut otIp6Address, - aMlIid: *mut otIp6InterfaceIdentifier, - ); + /// @return The maximum length of the Network Data (high water mark for Network Data length). + pub fn otNetDataGetMaxLength(aInstance: *mut otInstance) -> u8; } unsafe extern "C" { - /// Sends a Proactive Backbone Notification (PRO_BB.ntf) message on the Backbone link. + /// Reset the tracked maximum length of the Thread Network Data. /// - /// Is only available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aTarget The target address of the PRO_BB.ntf message. - /// @param[in] aMlIid The ML-IID of the PRO_BB.ntf message. - /// @param[in] aTimeSinceLastTransaction Time since last transaction (in seconds). + /// @sa otNetDataGetMaxLength + pub fn otNetDataResetMaxLength(aInstance: *mut otInstance); +} +unsafe extern "C" { + /// Get the next On Mesh Prefix in the partition's Network Data. /// - /// @retval OT_ERROR_NONE Successfully sent PRO_BB.ntf on backbone link. - /// @retval OT_ERROR_NO_BUFS If insufficient message buffers available. - pub fn otThreadSendProactiveBackboneNotification( + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first on-mesh entry + ///it should be set to OT_NETWORK_DATA_ITERATOR_INIT. + /// @param[out] aConfig A pointer to where the On Mesh Prefix information will be placed. + /// + /// @retval OT_ERROR_NONE Successfully found the next On Mesh prefix. + /// @retval OT_ERROR_NOT_FOUND No subsequent On Mesh prefix exists in the Thread Network Data. + pub fn otNetDataGetNextOnMeshPrefix( aInstance: *mut otInstance, - aTarget: *mut otIp6Address, - aMlIid: *mut otIp6InterfaceIdentifier, - aTimeSinceLastTransaction: u32, + aIterator: *mut otNetworkDataIterator, + aConfig: *mut otBorderRouterConfig, ) -> otError; } unsafe extern "C" { - /// Notifies other nodes in the network (if any) and then stops Thread protocol operation. - /// - /// It sends an Address Release if it's a router, or sets its child timeout to 0 if it's a child. + /// Get the next external route in the partition's Network Data. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aCallback A pointer to a function that is called upon finishing detaching. - /// @param[in] aContext A pointer to callback application-specific context. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first external route entry + ///it should be set to OT_NETWORK_DATA_ITERATOR_INIT. + /// @param[out] aConfig A pointer to where the External Route information will be placed. /// - /// @retval OT_ERROR_NONE Successfully started detaching. - /// @retval OT_ERROR_BUSY Detaching is already in progress. - pub fn otThreadDetachGracefully( + /// @retval OT_ERROR_NONE Successfully found the next External Route. + /// @retval OT_ERROR_NOT_FOUND No subsequent external route entry exists in the Thread Network Data. + pub fn otNetDataGetNextRoute( aInstance: *mut otInstance, - aCallback: otDetachGracefullyCallback, - aContext: *mut ::core::ffi::c_void, + aIterator: *mut otNetworkDataIterator, + aConfig: *mut otExternalRouteConfig, ) -> otError; } unsafe extern "C" { - /// Converts an `uint32_t` duration (in seconds) to a human-readable string. - /// - /// Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. - /// - /// The string follows the format "::" for hours, minutes, seconds (if duration is shorter than one day) or - /// "
d.::" (if longer than a day). + /// Get the next service in the partition's Network Data. /// - /// If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated - /// but the outputted string is always null-terminated. - /// - /// Is intended for use with `mAge` or `mConnectionTime` in `otNeighborInfo` or `otChildInfo` structures. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first service entry + ///it should be set to OT_NETWORK_DATA_ITERATOR_INIT. + /// @param[out] aConfig A pointer to where the service information will be placed. /// - /// @param[in] aDuration A duration interval in seconds. - /// @param[out] aBuffer A pointer to a char array to output the string. - /// @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_DURATION_STRING_SIZE`. - pub fn otConvertDurationInSecondsToString( - aDuration: u32, - aBuffer: *mut ::core::ffi::c_char, - aSize: u16, - ); + /// @retval OT_ERROR_NONE Successfully found the next service. + /// @retval OT_ERROR_NOT_FOUND No subsequent service exists in the partition's Network Data. + pub fn otNetDataGetNextService( + aInstance: *mut otInstance, + aIterator: *mut otNetworkDataIterator, + aConfig: *mut otServiceConfig, + ) -> otError; } unsafe extern "C" { - /// Sets the store frame counter ahead. + /// Get the next 6LoWPAN Context ID info in the partition's Network Data. /// - /// Requires `OPENTHREAD_CONFIG_DYNAMIC_STORE_FRAME_AHEAD_COUNTER_ENABLE` to be enabled. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in,out] aIterator A pointer to the Network Data iterator. To get the first service entry + ///it should be set to OT_NETWORK_DATA_ITERATOR_INIT. + /// @param[out] aContextInfo A pointer to where the retrieved 6LoWPAN Context ID information will be placed. /// - /// The OpenThread stack stores the MLE and MAC security frame counter values in non-volatile storage, - /// ensuring they persist across device resets. These saved values are set to be ahead of their current - /// values by the "frame counter ahead" value. + /// @retval OT_ERROR_NONE Successfully found the next 6LoWPAN Context ID info. + /// @retval OT_ERROR_NOT_FOUND No subsequent 6LoWPAN Context info exists in the partition's Network Data. + pub fn otNetDataGetNextLowpanContextInfo( + aInstance: *mut otInstance, + aIterator: *mut otNetworkDataIterator, + aContextInfo: *mut otLowpanContextInfo, + ) -> otError; +} +unsafe extern "C" { + /// Gets the Commissioning Dataset from the partition's Network Data. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - /// @param[in] aStoreFrameCounterAhead The store frame counter ahead to set. - pub fn otThreadSetStoreFrameCounterAhead( + /// @param[in] aInstance A pointer to the OpenThread instance. + /// @param[out] aDataset A pointer to a `otCommissioningDataset` to populate. + pub fn otNetDataGetCommissioningDataset( aInstance: *mut otInstance, - aStoreFrameCounterAhead: u32, + aDataset: *mut otCommissioningDataset, ); } unsafe extern "C" { - /// Gets the store frame counter ahead. + /// Get the Network Data Version. /// - /// Requires `OPENTHREAD_CONFIG_DYNAMIC_STORE_FRAME_AHEAD_COUNTER_ENABLE` to be enabled. + /// @param[in] aInstance A pointer to an OpenThread instance. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @returns The Network Data Version. + pub fn otNetDataGetVersion(aInstance: *mut otInstance) -> u8; +} +unsafe extern "C" { + /// Get the Stable Network Data Version. /// - /// @returns The current store frame counter ahead. - pub fn otThreadGetStoreFrameCounterAhead(aInstance: *mut otInstance) -> u32; + /// @param[in] aInstance A pointer to an OpenThread instance. + /// + /// @returns The Stable Network Data Version. + pub fn otNetDataGetStableVersion(aInstance: *mut otInstance) -> u8; } unsafe extern "C" { - /// Run all queued OpenThread tasklets at the time this is called. + /// Check if the steering data includes a Joiner. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otTaskletsProcess(aInstance: *mut otInstance); + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64. + /// + /// @retval OT_ERROR_NONE @p aEui64 is included in the steering data. + /// @retval OT_ERROR_INVALID_STATE No steering data present. + /// @retval OT_ERROR_NOT_FOUND @p aEui64 is not included in the steering data. + pub fn otNetDataSteeringDataCheckJoiner( + aInstance: *mut otInstance, + aEui64: *const otExtAddress, + ) -> otError; } unsafe extern "C" { - /// Indicates whether or not OpenThread has tasklets pending. + /// Check if the steering data includes a Joiner with a given discerner value. /// - /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aDiscerner A pointer to the Joiner Discerner. /// - /// @retval TRUE If there are tasklets pending. - /// @retval FALSE If there are no tasklets pending. - pub fn otTaskletsArePending(aInstance: *mut otInstance) -> bool; + /// @retval OT_ERROR_NONE @p aDiscerner is included in the steering data. + /// @retval OT_ERROR_INVALID_STATE No steering data present. + /// @retval OT_ERROR_NOT_FOUND @p aDiscerner is not included in the steering data. + pub fn otNetDataSteeringDataCheckJoinerWithDiscerner( + aInstance: *mut otInstance, + aDiscerner: *const otJoinerDiscerner, + ) -> otError; } unsafe extern "C" { - /// OpenThread calls this function when the tasklet queue transitions from empty to non-empty. + /// Check whether a given Prefix can act as a valid OMR prefix and also the Leader's Network Data contains this prefix. /// - /// @param[in] aInstance A pointer to an OpenThread instance. - pub fn otTaskletsSignalPending(aInstance: *mut otInstance); + /// @param[in] aInstance A pointer to an OpenThread instance. + /// @param[in] aPrefix A pointer to the IPv6 prefix. + /// + /// @returns Whether @p aPrefix is a valid OMR prefix and Leader's Network Data contains the OMR prefix @p aPrefix. + /// + /// @note This API is only available when `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` is used. + pub fn otNetDataContainsOmrPrefix( + aInstance: *mut otInstance, + aPrefix: *const otIp6Prefix, + ) -> bool; } unsafe extern "C" { /// Set the alarm to fire at @p aDt milliseconds after @p aT0. @@ -10615,6 +11431,8 @@ pub const OT_SETTINGS_KEY_BR_ULA_PREFIX: _bindgen_ty_10 = 15; pub const OT_SETTINGS_KEY_BR_ON_LINK_PREFIXES: _bindgen_ty_10 = 16; ///< Unique Border Agent/Router ID. pub const OT_SETTINGS_KEY_BORDER_AGENT_ID: _bindgen_ty_10 = 17; +///< TCAT Commissioner certificate +pub const OT_SETTINGS_KEY_TCAT_COMMR_CERT: _bindgen_ty_10 = 18; pub const OT_SETTINGS_KEY_VENDOR_RESERVED_MIN: _bindgen_ty_10 = 32768; pub const OT_SETTINGS_KEY_VENDOR_RESERVED_MAX: _bindgen_ty_10 = 65535; /// Defines the keys of settings. @@ -10793,6 +11611,88 @@ unsafe extern "C" { /// @param[in] aInstance The OpenThread instance structure. pub fn otPlatSettingsWipe(aInstance: *mut otInstance); } +/// Represents the log level. +pub type otLogLevel = ::core::ffi::c_int; +///< OpenThread API +pub const otLogRegion_OT_LOG_REGION_API: otLogRegion = 1; +///< MLE +pub const otLogRegion_OT_LOG_REGION_MLE: otLogRegion = 2; +///< EID-to-RLOC mapping. +pub const otLogRegion_OT_LOG_REGION_ARP: otLogRegion = 3; +///< Network Data +pub const otLogRegion_OT_LOG_REGION_NET_DATA: otLogRegion = 4; +///< ICMPv6 +pub const otLogRegion_OT_LOG_REGION_ICMP: otLogRegion = 5; +///< IPv6 +pub const otLogRegion_OT_LOG_REGION_IP6: otLogRegion = 6; +///< TCP +pub const otLogRegion_OT_LOG_REGION_TCP: otLogRegion = 7; +///< IEEE 802.15.4 MAC +pub const otLogRegion_OT_LOG_REGION_MAC: otLogRegion = 8; +///< Memory +pub const otLogRegion_OT_LOG_REGION_MEM: otLogRegion = 9; +///< NCP +pub const otLogRegion_OT_LOG_REGION_NCP: otLogRegion = 10; +///< Mesh Commissioning Protocol +pub const otLogRegion_OT_LOG_REGION_MESH_COP: otLogRegion = 11; +///< Network Diagnostic +pub const otLogRegion_OT_LOG_REGION_NET_DIAG: otLogRegion = 12; +///< Platform +pub const otLogRegion_OT_LOG_REGION_PLATFORM: otLogRegion = 13; +///< CoAP +pub const otLogRegion_OT_LOG_REGION_COAP: otLogRegion = 14; +///< CLI +pub const otLogRegion_OT_LOG_REGION_CLI: otLogRegion = 15; +///< OpenThread Core +pub const otLogRegion_OT_LOG_REGION_CORE: otLogRegion = 16; +///< Utility module +pub const otLogRegion_OT_LOG_REGION_UTIL: otLogRegion = 17; +///< Backbone Router (available since Thread 1.2) +pub const otLogRegion_OT_LOG_REGION_BBR: otLogRegion = 18; +///< Multicast Listener Registration (available since Thread 1.2) +pub const otLogRegion_OT_LOG_REGION_MLR: otLogRegion = 19; +///< Domain Unicast Address (available since Thread 1.2) +pub const otLogRegion_OT_LOG_REGION_DUA: otLogRegion = 20; +///< Border Router +pub const otLogRegion_OT_LOG_REGION_BR: otLogRegion = 21; +///< Service Registration Protocol (SRP) +pub const otLogRegion_OT_LOG_REGION_SRP: otLogRegion = 22; +///< DNS +pub const otLogRegion_OT_LOG_REGION_DNS: otLogRegion = 23; +/// Represents log regions. +/// +/// The support for log region is removed and instead each core module can define its own name to appended to the logs. +/// However, the `otLogRegion` enumeration is still defined as before to help with platforms which we may be using it +/// in their `otPlatLog()` implementation. The OT core will always emit all logs with `OT_LOG_REGION_CORE`. +pub type otLogRegion = ::core::ffi::c_uint; +unsafe extern "C" { + /// Outputs logs. + /// + /// Note that the support for log region is removed. The OT core will always emit all logs with `OT_LOG_REGION_CORE` + /// as @p aLogRegion. + /// + /// @param[in] aLogLevel The log level. + /// @param[in] aLogRegion The log region. + /// @param[in] aFormat A pointer to the format string. + /// @param[in] ... Arguments for the format specification. + pub fn otPlatLog( + aLogLevel: otLogLevel, + aLogRegion: otLogRegion, + aFormat: *const ::core::ffi::c_char, + ... + ); +} +unsafe extern "C" { + /// Handles OpenThread log level changes. + /// + /// This platform function is called whenever the OpenThread log level changes. + /// This platform function is optional since an empty weak implementation has been provided. + /// + /// @note Only applicable when `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1`. + /// + /// @param[in] aLogLevel The new OpenThread log level. + pub fn otPlatLogHandleLevelChanged(aLogLevel: otLogLevel); +} /// Represents a TXT record entry representing a key/value pair (RFC 6763 - section 6.3). /// /// The string buffers pointed to by `mKey` and `mValue` MUST persist and remain unchanged after an instance of such @@ -10821,6 +11721,15 @@ pub struct otDnsTxtEntry { ///< Number of bytes in `mValue` buffer. pub mValueLength: u16, } +impl Default for otDnsTxtEntry { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} /// Represents an iterator for TXT record entries (key/value pairs). /// /// The data fields in this structure are intended for use by OpenThread core and caller should not read or change them. @@ -10831,6 +11740,15 @@ pub struct otDnsTxtEntryIterator { pub mData: [u16; 2usize], pub mChar: [::core::ffi::c_char; 65usize], } +impl Default for otDnsTxtEntryIterator { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} unsafe extern "C" { /// Initializes a TXT record iterator. /// @@ -10941,6 +11859,15 @@ pub struct otSrpClientHostInfo { ///< Host info state. pub mState: otSrpClientItemState, } +impl Default for otSrpClientHostInfo { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} /// Represents an SRP client service. /// /// The values in this structure, including the string buffers for the names and the TXT record entries, MUST persist @@ -10988,6 +11915,15 @@ pub struct otSrpClientService { ///< Desired key lease interval in sec - zero to use default. pub mKeyLease: u32, } +impl Default for otSrpClientService { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} /// Pointer type defines the callback used by SRP client to notify user of changes/events/errors. /// /// This callback is invoked on a successful registration of an update (i.e., add/remove of host-info and/or some @@ -11560,6 +12496,15 @@ pub struct otSrpClientBuffersServiceEntry { ///< The SRP client TXT entry. pub mTxtEntry: otDnsTxtEntry, } +impl Default for otSrpClientBuffersServiceEntry { + fn default() -> Self { + let mut s = ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} unsafe extern "C" { /// Gets the string buffer to use for SRP client host name. /// @@ -11681,4 +12626,3 @@ unsafe extern "C" { aArrayLength: *mut u16, ) -> *mut *const ::core::ffi::c_char; } -pub type __builtin_va_list = *mut ::core::ffi::c_void; diff --git a/openthread-sys/src/include/thumbv6m-none-eabi.rs b/openthread-sys/src/include/thumbv6m-none-eabi.rs index a3ddb18..bb4fc9c 100644 --- a/openthread-sys/src/include/thumbv6m-none-eabi.rs +++ b/openthread-sys/src/include/thumbv6m-none-eabi.rs @@ -137,117 +137,6 @@ where } } } -pub const __bool_true_false_are_defined: u32 = 1; -pub const true_: u32 = 1; -pub const false_: u32 = 0; -pub const _NEWLIB_VERSION_H__: u32 = 1; -pub const _NEWLIB_VERSION: &[u8; 6] = b"3.3.0\0"; -pub const __NEWLIB__: u32 = 3; -pub const __NEWLIB_MINOR__: u32 = 3; -pub const __NEWLIB_PATCHLEVEL__: u32 = 0; -pub const _DEFAULT_SOURCE: u32 = 1; -pub const _POSIX_SOURCE: u32 = 1; -pub const _POSIX_C_SOURCE: u32 = 200809; -pub const _ATFILE_SOURCE: u32 = 1; -pub const __ATFILE_VISIBLE: u32 = 1; -pub const __BSD_VISIBLE: u32 = 1; -pub const __GNU_VISIBLE: u32 = 0; -pub const __ISO_C_VISIBLE: u32 = 2011; -pub const __LARGEFILE_VISIBLE: u32 = 0; -pub const __MISC_VISIBLE: u32 = 1; -pub const __POSIX_VISIBLE: u32 = 200809; -pub const __SVID_VISIBLE: u32 = 1; -pub const __XSI_VISIBLE: u32 = 0; -pub const __SSP_FORTIFY_LEVEL: u32 = 0; -pub const __have_longlong64: u32 = 1; -pub const __have_long32: u32 = 1; -pub const ___int8_t_defined: u32 = 1; -pub const ___int16_t_defined: u32 = 1; -pub const ___int32_t_defined: u32 = 1; -pub const ___int64_t_defined: u32 = 1; -pub const ___int_least8_t_defined: u32 = 1; -pub const ___int_least16_t_defined: u32 = 1; -pub const ___int_least32_t_defined: u32 = 1; -pub const ___int_least64_t_defined: u32 = 1; -pub const __int20: u32 = 2; -pub const __int20__: u32 = 2; -pub const __INT8: &[u8; 3] = b"hh\0"; -pub const __INT16: &[u8; 2] = b"h\0"; -pub const __INT64: &[u8; 3] = b"ll\0"; -pub const __FAST8: &[u8; 3] = b"hh\0"; -pub const __FAST16: &[u8; 2] = b"h\0"; -pub const __FAST64: &[u8; 3] = b"ll\0"; -pub const __LEAST8: &[u8; 3] = b"hh\0"; -pub const __LEAST16: &[u8; 2] = b"h\0"; -pub const __LEAST64: &[u8; 3] = b"ll\0"; -pub const __int8_t_defined: u32 = 1; -pub const __int16_t_defined: u32 = 1; -pub const __int32_t_defined: u32 = 1; -pub const __int64_t_defined: u32 = 1; -pub const __int_least8_t_defined: u32 = 1; -pub const __int_least16_t_defined: u32 = 1; -pub const __int_least32_t_defined: u32 = 1; -pub const __int_least64_t_defined: u32 = 1; -pub const __int_fast8_t_defined: u32 = 1; -pub const __int_fast16_t_defined: u32 = 1; -pub const __int_fast32_t_defined: u32 = 1; -pub const __int_fast64_t_defined: u32 = 1; -pub const WINT_MIN: u32 = 0; -pub const __OBSOLETE_MATH_DEFAULT: u32 = 1; -pub const __OBSOLETE_MATH: u32 = 1; -pub const __NEWLIB_H__: u32 = 1; -pub const _WANT_IO_C99_FORMATS: u32 = 1; -pub const _WANT_IO_LONG_LONG: u32 = 1; -pub const _WANT_REGISTER_FINI: u32 = 1; -pub const _REENT_CHECK_VERIFY: u32 = 1; -pub const _MB_LEN_MAX: u32 = 1; -pub const HAVE_INITFINI_ARRAY: u32 = 1; -pub const _ATEXIT_DYNAMIC_ALLOC: u32 = 1; -pub const _HAVE_LONG_DOUBLE: u32 = 1; -pub const _HAVE_CC_INHIBIT_LOOP_TO_LIBCALL: u32 = 1; -pub const _LDBL_EQ_DBL: u32 = 1; -pub const _FVWRITE_IN_STREAMIO: u32 = 1; -pub const _FSEEK_OPTIMIZATION: u32 = 1; -pub const _WIDE_ORIENT: u32 = 1; -pub const _UNBUF_STREAM_OPT: u32 = 1; -pub const _RETARGETABLE_LOCKING: u32 = 1; -pub const __RAND_MAX: u32 = 2147483647; -pub const _NULL: u32 = 0; -pub const _ATEXIT_SIZE: u32 = 32; -pub const _RAND48_SEED_0: u32 = 13070; -pub const _RAND48_SEED_1: u32 = 43981; -pub const _RAND48_SEED_2: u32 = 4660; -pub const _RAND48_MULT_0: u32 = 58989; -pub const _RAND48_MULT_1: u32 = 57068; -pub const _RAND48_MULT_2: u32 = 5; -pub const _RAND48_ADD: u32 = 11; -pub const _REENT_EMERGENCY_SIZE: u32 = 25; -pub const _REENT_ASCTIME_SIZE: u32 = 26; -pub const _REENT_SIGNAL_SIZE: u32 = 24; -pub const _N_LISTS: u32 = 30; -pub const __GNUCLIKE_ASM: u32 = 3; -pub const __GNUCLIKE___TYPEOF: u32 = 1; -pub const __GNUCLIKE___OFFSETOF: u32 = 1; -pub const __GNUCLIKE___SECTION: u32 = 1; -pub const __GNUCLIKE_CTOR_SECTION_HANDLING: u32 = 1; -pub const __GNUCLIKE_BUILTIN_CONSTANT_P: u32 = 1; -pub const __GNUCLIKE_BUILTIN_VARARGS: u32 = 1; -pub const __GNUCLIKE_BUILTIN_STDARG: u32 = 1; -pub const __GNUCLIKE_BUILTIN_VAALIST: u32 = 1; -pub const __GNUC_VA_LIST_COMPATIBILITY: u32 = 1; -pub const __GNUCLIKE_BUILTIN_NEXT_ARG: u32 = 1; -pub const __GNUCLIKE_BUILTIN_MEMCPY: u32 = 1; -pub const __CC_SUPPORTS_INLINE: u32 = 1; -pub const __CC_SUPPORTS___INLINE: u32 = 1; -pub const __CC_SUPPORTS___INLINE__: u32 = 1; -pub const __CC_SUPPORTS___FUNC__: u32 = 1; -pub const __CC_SUPPORTS_WARNING: u32 = 1; -pub const __CC_SUPPORTS_VARADIC_XXX: u32 = 1; -pub const __CC_SUPPORTS_DYNAMIC_ARRAY_INIT: u32 = 1; -pub const EXIT_FAILURE: u32 = 1; -pub const EXIT_SUCCESS: u32 = 0; -pub const RAND_MAX: u32 = 2147483647; -pub const OPENTHREAD_API_VERSION: u32 = 512; pub const OT_UPTIME_STRING_SIZE: u32 = 24; pub const OT_CHANGED_IP6_ADDRESS_ADDED: u32 = 1; pub const OT_CHANGED_IP6_ADDRESS_REMOVED: u32 = 2; @@ -299,8 +188,6 @@ pub const OT_CRYPTO_ECDSA_SIGNATURE_SIZE: u32 = 64; pub const OT_CRYPTO_PBDKF2_MAX_SALT_SIZE: u32 = 30; pub const OT_PANID_BROADCAST: u32 = 65535; pub const OT_EXT_ADDRESS_SIZE: u32 = 8; -pub const CSL_IE_HEADER_BYTES_LO: u32 = 4; -pub const CSL_IE_HEADER_BYTES_HI: u32 = 13; pub const OT_MAC_KEY_SIZE: u32 = 16; pub const OT_NETWORK_KEY_SIZE: u32 = 16; pub const OT_NETWORK_NAME_MAX_SIZE: u32 = 16; @@ -371,1049 +258,6 @@ pub const OT_DNS_MAX_LABEL_SIZE: u32 = 64; pub const OT_DNS_TXT_KEY_MIN_LENGTH: u32 = 1; pub const OT_DNS_TXT_KEY_MAX_LENGTH: u32 = 9; pub const OT_DNS_TXT_KEY_ITER_MAX_LENGTH: u32 = 64; -pub const OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE: u32 = 1; -pub type __int8_t = ::core::ffi::c_schar; -pub type __uint8_t = ::core::ffi::c_uchar; -pub type __int16_t = ::core::ffi::c_short; -pub type __uint16_t = ::core::ffi::c_ushort; -pub type __int32_t = ::core::ffi::c_int; -pub type __uint32_t = ::core::ffi::c_uint; -pub type __int64_t = ::core::ffi::c_longlong; -pub type __uint64_t = ::core::ffi::c_ulonglong; -pub type __int_least8_t = ::core::ffi::c_schar; -pub type __uint_least8_t = ::core::ffi::c_uchar; -pub type __int_least16_t = ::core::ffi::c_short; -pub type __uint_least16_t = ::core::ffi::c_ushort; -pub type __int_least32_t = ::core::ffi::c_int; -pub type __uint_least32_t = ::core::ffi::c_uint; -pub type __int_least64_t = ::core::ffi::c_longlong; -pub type __uint_least64_t = ::core::ffi::c_ulonglong; -pub type __intmax_t = ::core::ffi::c_longlong; -pub type __uintmax_t = ::core::ffi::c_ulonglong; -pub type __intptr_t = ::core::ffi::c_int; -pub type __uintptr_t = ::core::ffi::c_uint; -pub type intmax_t = __intmax_t; -pub type uintmax_t = __uintmax_t; -pub type int_least8_t = __int_least8_t; -pub type uint_least8_t = __uint_least8_t; -pub type int_least16_t = __int_least16_t; -pub type uint_least16_t = __uint_least16_t; -pub type int_least32_t = __int_least32_t; -pub type uint_least32_t = __uint_least32_t; -pub type int_least64_t = __int_least64_t; -pub type uint_least64_t = __uint_least64_t; -pub type int_fast8_t = ::core::ffi::c_schar; -pub type uint_fast8_t = ::core::ffi::c_uchar; -pub type int_fast16_t = ::core::ffi::c_short; -pub type uint_fast16_t = ::core::ffi::c_ushort; -pub type int_fast32_t = ::core::ffi::c_int; -pub type uint_fast32_t = ::core::ffi::c_uint; -pub type int_fast64_t = ::core::ffi::c_longlong; -pub type uint_fast64_t = ::core::ffi::c_ulonglong; -pub type wchar_t = ::core::ffi::c_uint; -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct max_align_t { - pub __clang_max_align_nonce1: ::core::ffi::c_longlong, - pub __clang_max_align_nonce2: f64, -} -pub type wint_t = ::core::ffi::c_int; -pub type __blkcnt_t = ::core::ffi::c_long; -pub type __blksize_t = ::core::ffi::c_long; -pub type __fsblkcnt_t = __uint64_t; -pub type __fsfilcnt_t = __uint32_t; -pub type _off_t = ::core::ffi::c_long; -pub type __pid_t = ::core::ffi::c_int; -pub type __dev_t = ::core::ffi::c_short; -pub type __uid_t = ::core::ffi::c_ushort; -pub type __gid_t = ::core::ffi::c_ushort; -pub type __id_t = __uint32_t; -pub type __ino_t = ::core::ffi::c_ushort; -pub type __mode_t = __uint32_t; -pub type _off64_t = ::core::ffi::c_longlong; -pub type __off_t = _off_t; -pub type __loff_t = _off64_t; -pub type __key_t = ::core::ffi::c_long; -pub type _fpos_t = ::core::ffi::c_long; -pub type __size_t = ::core::ffi::c_uint; -pub type _ssize_t = ::core::ffi::c_int; -pub type __ssize_t = _ssize_t; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _mbstate_t { - pub __count: ::core::ffi::c_int, - pub __value: _mbstate_t__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union _mbstate_t__bindgen_ty_1 { - pub __wch: wint_t, - pub __wchb: [::core::ffi::c_uchar; 4usize], -} -impl Default for _mbstate_t__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -impl Default for _mbstate_t { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -pub type _iconv_t = *mut ::core::ffi::c_void; -pub type __clock_t = ::core::ffi::c_ulong; -pub type __time_t = __int_least64_t; -pub type __clockid_t = ::core::ffi::c_ulong; -pub type __timer_t = ::core::ffi::c_ulong; -pub type __sa_family_t = __uint8_t; -pub type __socklen_t = __uint32_t; -pub type __nl_item = ::core::ffi::c_int; -pub type __nlink_t = ::core::ffi::c_ushort; -pub type __suseconds_t = ::core::ffi::c_long; -pub type __useconds_t = ::core::ffi::c_ulong; -pub type __va_list = u32; -pub type __ULong = ::core::ffi::c_ulong; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __lock { - _unused: [u8; 0], -} -pub type _LOCK_T = *mut __lock; -unsafe extern "C" { - pub fn __retarget_lock_init(lock: *mut _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_init_recursive(lock: *mut _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_close(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_close_recursive(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_acquire(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_acquire_recursive(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_try_acquire(lock: _LOCK_T) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __retarget_lock_try_acquire_recursive(lock: _LOCK_T) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __retarget_lock_release(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_release_recursive(lock: _LOCK_T); -} -pub type _flock_t = _LOCK_T; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __locale_t { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _Bigint { - pub _next: *mut _Bigint, - pub _k: ::core::ffi::c_int, - pub _maxwds: ::core::ffi::c_int, - pub _sign: ::core::ffi::c_int, - pub _wds: ::core::ffi::c_int, - pub _x: [__ULong; 1usize], -} -impl Default for _Bigint { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct __tm { - pub __tm_sec: ::core::ffi::c_int, - pub __tm_min: ::core::ffi::c_int, - pub __tm_hour: ::core::ffi::c_int, - pub __tm_mday: ::core::ffi::c_int, - pub __tm_mon: ::core::ffi::c_int, - pub __tm_year: ::core::ffi::c_int, - pub __tm_wday: ::core::ffi::c_int, - pub __tm_yday: ::core::ffi::c_int, - pub __tm_isdst: ::core::ffi::c_int, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _on_exit_args { - pub _fnargs: [*mut ::core::ffi::c_void; 32usize], - pub _dso_handle: [*mut ::core::ffi::c_void; 32usize], - pub _fntypes: __ULong, - pub _is_cxa: __ULong, -} -impl Default for _on_exit_args { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _atexit { - pub _next: *mut _atexit, - pub _ind: ::core::ffi::c_int, - pub _fns: [::core::option::Option; 32usize], - pub _on_exit_args: _on_exit_args, -} -impl Default for _atexit { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __sbuf { - pub _base: *mut ::core::ffi::c_uchar, - pub _size: ::core::ffi::c_int, -} -impl Default for __sbuf { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __sFILE { - pub _p: *mut ::core::ffi::c_uchar, - pub _r: ::core::ffi::c_int, - pub _w: ::core::ffi::c_int, - pub _flags: ::core::ffi::c_short, - pub _file: ::core::ffi::c_short, - pub _bf: __sbuf, - pub _lbfsize: ::core::ffi::c_int, - pub _cookie: *mut ::core::ffi::c_void, - pub _read: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: *mut ::core::ffi::c_char, - arg4: ::core::ffi::c_int, - ) -> ::core::ffi::c_int, - >, - pub _write: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: *const ::core::ffi::c_char, - arg4: ::core::ffi::c_int, - ) -> ::core::ffi::c_int, - >, - pub _seek: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: _fpos_t, - arg4: ::core::ffi::c_int, - ) -> _fpos_t, - >, - pub _close: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - ) -> ::core::ffi::c_int, - >, - pub _ub: __sbuf, - pub _up: *mut ::core::ffi::c_uchar, - pub _ur: ::core::ffi::c_int, - pub _ubuf: [::core::ffi::c_uchar; 3usize], - pub _nbuf: [::core::ffi::c_uchar; 1usize], - pub _lb: __sbuf, - pub _blksize: ::core::ffi::c_int, - pub _offset: _off_t, - pub _data: *mut _reent, - pub _lock: _flock_t, - pub _mbstate: _mbstate_t, - pub _flags2: ::core::ffi::c_int, -} -impl Default for __sFILE { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -pub type __FILE = __sFILE; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _glue { - pub _next: *mut _glue, - pub _niobs: ::core::ffi::c_int, - pub _iobs: *mut __FILE, -} -impl Default for _glue { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct _rand48 { - pub _seed: [::core::ffi::c_ushort; 3usize], - pub _mult: [::core::ffi::c_ushort; 3usize], - pub _add: ::core::ffi::c_ushort, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _reent { - pub _errno: ::core::ffi::c_int, - pub _stdin: *mut __FILE, - pub _stdout: *mut __FILE, - pub _stderr: *mut __FILE, - pub _inc: ::core::ffi::c_int, - pub _emergency: [::core::ffi::c_char; 25usize], - pub _unspecified_locale_info: ::core::ffi::c_int, - pub _locale: *mut __locale_t, - pub __sdidinit: ::core::ffi::c_int, - pub __cleanup: ::core::option::Option, - pub _result: *mut _Bigint, - pub _result_k: ::core::ffi::c_int, - pub _p5s: *mut _Bigint, - pub _freelist: *mut *mut _Bigint, - pub _cvtlen: ::core::ffi::c_int, - pub _cvtbuf: *mut ::core::ffi::c_char, - pub _new: _reent__bindgen_ty_1, - pub _atexit: *mut _atexit, - pub _atexit0: _atexit, - pub _sig_func: *mut ::core::option::Option, - pub __sglue: _glue, - pub __sf: [__FILE; 3usize], -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union _reent__bindgen_ty_1 { - pub _reent: _reent__bindgen_ty_1__bindgen_ty_1, - pub _unused: _reent__bindgen_ty_1__bindgen_ty_2, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _reent__bindgen_ty_1__bindgen_ty_1 { - pub _unused_rand: ::core::ffi::c_uint, - pub _strtok_last: *mut ::core::ffi::c_char, - pub _asctime_buf: [::core::ffi::c_char; 26usize], - pub _localtime_buf: __tm, - pub _gamma_signgam: ::core::ffi::c_int, - pub _rand_next: ::core::ffi::c_ulonglong, - pub _r48: _rand48, - pub _mblen_state: _mbstate_t, - pub _mbtowc_state: _mbstate_t, - pub _wctomb_state: _mbstate_t, - pub _l64a_buf: [::core::ffi::c_char; 8usize], - pub _signal_buf: [::core::ffi::c_char; 24usize], - pub _getdate_err: ::core::ffi::c_int, - pub _mbrlen_state: _mbstate_t, - pub _mbrtowc_state: _mbstate_t, - pub _mbsrtowcs_state: _mbstate_t, - pub _wcrtomb_state: _mbstate_t, - pub _wcsrtombs_state: _mbstate_t, - pub _h_errno: ::core::ffi::c_int, -} -impl Default for _reent__bindgen_ty_1__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _reent__bindgen_ty_1__bindgen_ty_2 { - pub _nextf: [*mut ::core::ffi::c_uchar; 30usize], - pub _nmalloc: [::core::ffi::c_uint; 30usize], -} -impl Default for _reent__bindgen_ty_1__bindgen_ty_2 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -impl Default for _reent__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -impl Default for _reent { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -unsafe extern "C" { - pub static mut _impure_ptr: *mut _reent; -} -unsafe extern "C" { - pub static _global_impure_ptr: *mut _reent; -} -unsafe extern "C" { - pub fn _reclaim_reent(arg1: *mut _reent); -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct div_t { - pub quot: ::core::ffi::c_int, - pub rem: ::core::ffi::c_int, -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct ldiv_t { - pub quot: ::core::ffi::c_long, - pub rem: ::core::ffi::c_long, -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct lldiv_t { - pub quot: ::core::ffi::c_longlong, - pub rem: ::core::ffi::c_longlong, -} -pub type __compar_fn_t = ::core::option::Option< - unsafe extern "C" fn( - arg1: *const ::core::ffi::c_void, - arg2: *const ::core::ffi::c_void, - ) -> ::core::ffi::c_int, ->; -unsafe extern "C" { - pub fn __locale_mb_cur_max() -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn abort() -> !; -} -unsafe extern "C" { - pub fn abs(arg1: ::core::ffi::c_int) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn arc4random() -> __uint32_t; -} -unsafe extern "C" { - pub fn arc4random_uniform(arg1: __uint32_t) -> __uint32_t; -} -unsafe extern "C" { - pub fn arc4random_buf(arg1: *mut ::core::ffi::c_void, arg2: usize); -} -unsafe extern "C" { - pub fn atexit(__func: ::core::option::Option) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn atof(__nptr: *const ::core::ffi::c_char) -> f64; -} -unsafe extern "C" { - pub fn atoff(__nptr: *const ::core::ffi::c_char) -> f32; -} -unsafe extern "C" { - pub fn atoi(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _atoi_r(arg1: *mut _reent, __nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn atol(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _atol_r(arg1: *mut _reent, __nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn bsearch( - __key: *const ::core::ffi::c_void, - __base: *const ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - _compar: __compar_fn_t, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - #[must_use] - pub fn calloc(arg1: ::core::ffi::c_uint, arg2: ::core::ffi::c_uint) - -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn div(__numer: ::core::ffi::c_int, __denom: ::core::ffi::c_int) -> div_t; -} -unsafe extern "C" { - pub fn exit(__status: ::core::ffi::c_int) -> !; -} -unsafe extern "C" { - pub fn free(arg1: *mut ::core::ffi::c_void); -} -unsafe extern "C" { - pub fn getenv(__string: *const ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _getenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _findenv( - arg1: *const ::core::ffi::c_char, - arg2: *mut ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _findenv_r( - arg1: *mut _reent, - arg2: *const ::core::ffi::c_char, - arg3: *mut ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub static mut suboptarg: *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn getsubopt( - arg1: *mut *mut ::core::ffi::c_char, - arg2: *const *mut ::core::ffi::c_char, - arg3: *mut *mut ::core::ffi::c_char, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn labs(arg1: ::core::ffi::c_long) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn ldiv(__numer: ::core::ffi::c_long, __denom: ::core::ffi::c_long) -> ldiv_t; -} -unsafe extern "C" { - #[must_use] - pub fn malloc(arg1: ::core::ffi::c_uint) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn mblen(arg1: *const ::core::ffi::c_char, arg2: usize) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mblen_r( - arg1: *mut _reent, - arg2: *const ::core::ffi::c_char, - arg3: usize, - arg4: *mut _mbstate_t, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mbtowc( - arg1: *mut wchar_t, - arg2: *const ::core::ffi::c_char, - arg3: usize, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mbtowc_r( - arg1: *mut _reent, - arg2: *mut wchar_t, - arg3: *const ::core::ffi::c_char, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn wctomb(arg1: *mut ::core::ffi::c_char, arg2: wchar_t) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _wctomb_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: wchar_t, - arg4: *mut _mbstate_t, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mbstowcs(arg1: *mut wchar_t, arg2: *const ::core::ffi::c_char, arg3: usize) -> usize; -} -unsafe extern "C" { - pub fn _mbstowcs_r( - arg1: *mut _reent, - arg2: *mut wchar_t, - arg3: *const ::core::ffi::c_char, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> usize; -} -unsafe extern "C" { - pub fn wcstombs(arg1: *mut ::core::ffi::c_char, arg2: *const wchar_t, arg3: usize) -> usize; -} -unsafe extern "C" { - pub fn _wcstombs_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: *const wchar_t, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> usize; -} -unsafe extern "C" { - pub fn mkdtemp(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn mkstemp(arg1: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mkstemps(arg1: *mut ::core::ffi::c_char, arg2: ::core::ffi::c_int) - -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mktemp(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _mkdtemp_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _mkostemp_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkostemps_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - arg4: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkstemp_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkstemps_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mktemp_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char) - -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn qsort( - __base: *mut ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - _compar: __compar_fn_t, - ); -} -unsafe extern "C" { - pub fn rand() -> ::core::ffi::c_int; -} -unsafe extern "C" { - #[must_use] - pub fn realloc( - arg1: *mut ::core::ffi::c_void, - arg2: ::core::ffi::c_uint, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - #[must_use] - pub fn reallocarray( - arg1: *mut ::core::ffi::c_void, - arg2: usize, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - #[must_use] - pub fn reallocf(arg1: *mut ::core::ffi::c_void, arg2: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn realpath( - path: *const ::core::ffi::c_char, - resolved_path: *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn rpmatch(response: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn srand(__seed: ::core::ffi::c_uint); -} -unsafe extern "C" { - pub fn strtod(__n: *const ::core::ffi::c_char, __end_PTR: *mut *mut ::core::ffi::c_char) - -> f64; -} -unsafe extern "C" { - pub fn _strtod_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - ) -> f64; -} -unsafe extern "C" { - pub fn strtof(__n: *const ::core::ffi::c_char, __end_PTR: *mut *mut ::core::ffi::c_char) - -> f32; -} -unsafe extern "C" { - pub fn strtol( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _strtol_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn strtoul( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulong; -} -unsafe extern "C" { - pub fn _strtoul_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulong; -} -unsafe extern "C" { - pub fn system(__string: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn a64l(__input: *const ::core::ffi::c_char) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn l64a(__input: ::core::ffi::c_long) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _l64a_r(arg1: *mut _reent, __input: ::core::ffi::c_long) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn on_exit( - __func: ::core::option::Option< - unsafe extern "C" fn(arg1: ::core::ffi::c_int, arg2: *mut ::core::ffi::c_void), - >, - __arg: *mut ::core::ffi::c_void, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _Exit(__status: ::core::ffi::c_int) -> !; -} -unsafe extern "C" { - pub fn putenv(__string: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _putenv_r(arg1: *mut _reent, __string: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _reallocf_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn setenv( - __string: *const ::core::ffi::c_char, - __value: *const ::core::ffi::c_char, - __overwrite: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _setenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - __value: *const ::core::ffi::c_char, - __overwrite: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __itoa( - arg1: ::core::ffi::c_int, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn __utoa( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn itoa( - arg1: ::core::ffi::c_int, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn utoa( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn rand_r(__seed: *mut ::core::ffi::c_uint) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn drand48() -> f64; -} -unsafe extern "C" { - pub fn _drand48_r(arg1: *mut _reent) -> f64; -} -unsafe extern "C" { - pub fn erand48(arg1: *mut ::core::ffi::c_ushort) -> f64; -} -unsafe extern "C" { - pub fn _erand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> f64; -} -unsafe extern "C" { - pub fn jrand48(arg1: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _jrand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn lcong48(arg1: *mut ::core::ffi::c_ushort); -} -unsafe extern "C" { - pub fn _lcong48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort); -} -unsafe extern "C" { - pub fn lrand48() -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _lrand48_r(arg1: *mut _reent) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn mrand48() -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _mrand48_r(arg1: *mut _reent) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn nrand48(arg1: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _nrand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn seed48(arg1: *mut ::core::ffi::c_ushort) -> *mut ::core::ffi::c_ushort; -} -unsafe extern "C" { - pub fn _seed48_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_ushort, - ) -> *mut ::core::ffi::c_ushort; -} -unsafe extern "C" { - pub fn srand48(arg1: ::core::ffi::c_long); -} -unsafe extern "C" { - pub fn _srand48_r(arg1: *mut _reent, arg2: ::core::ffi::c_long); -} -unsafe extern "C" { - pub fn initstate( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: usize, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn random() -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn setstate(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn srandom(arg1: ::core::ffi::c_uint); -} -unsafe extern "C" { - pub fn atoll(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn _atoll_r( - arg1: *mut _reent, - __nptr: *const ::core::ffi::c_char, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn llabs(arg1: ::core::ffi::c_longlong) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn lldiv(__numer: ::core::ffi::c_longlong, __denom: ::core::ffi::c_longlong) -> lldiv_t; -} -unsafe extern "C" { - pub fn strtoll( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn _strtoll_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn strtoull( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulonglong; -} -unsafe extern "C" { - pub fn _strtoull_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulonglong; -} -unsafe extern "C" { - pub fn cfree(arg1: *mut ::core::ffi::c_void); -} -unsafe extern "C" { - pub fn unsetenv(__string: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _unsetenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - #[must_use] - pub fn posix_memalign( - arg1: *mut *mut ::core::ffi::c_void, - arg2: usize, - arg3: usize, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _dtoa_r( - arg1: *mut _reent, - arg2: f64, - arg3: ::core::ffi::c_int, - arg4: ::core::ffi::c_int, - arg5: *mut ::core::ffi::c_int, - arg6: *mut ::core::ffi::c_int, - arg7: *mut *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _malloc_r(arg1: *mut _reent, arg2: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _calloc_r(arg1: *mut _reent, arg2: usize, arg3: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _free_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_void); -} -unsafe extern "C" { - pub fn _realloc_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _mstats_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char); -} -unsafe extern "C" { - pub fn _system_r(arg1: *mut _reent, arg2: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __eprintf( - arg1: *const ::core::ffi::c_char, - arg2: *const ::core::ffi::c_char, - arg3: ::core::ffi::c_uint, - arg4: *const ::core::ffi::c_char, - ); -} -unsafe extern "C" { - #[link_name = "\u{1}__bsd_qsort_r"] - pub fn qsort_r( - __base: *mut ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - __thunk: *mut ::core::ffi::c_void, - _compar: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut ::core::ffi::c_void, - arg2: *const ::core::ffi::c_void, - arg3: *const ::core::ffi::c_void, - ) -> ::core::ffi::c_int, - >, - ); -} -unsafe extern "C" { - #[must_use] - pub fn aligned_alloc( - arg1: ::core::ffi::c_uint, - arg2: ::core::ffi::c_uint, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn at_quick_exit( - arg1: ::core::option::Option, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn quick_exit(arg1: ::core::ffi::c_int) -> !; -} /// No error. pub const otError_OT_ERROR_NONE: otError = 0; /// Operational failed. diff --git a/openthread-sys/src/include/thumbv7em-none-eabi.rs b/openthread-sys/src/include/thumbv7em-none-eabi.rs index a3ddb18..bb4fc9c 100644 --- a/openthread-sys/src/include/thumbv7em-none-eabi.rs +++ b/openthread-sys/src/include/thumbv7em-none-eabi.rs @@ -137,117 +137,6 @@ where } } } -pub const __bool_true_false_are_defined: u32 = 1; -pub const true_: u32 = 1; -pub const false_: u32 = 0; -pub const _NEWLIB_VERSION_H__: u32 = 1; -pub const _NEWLIB_VERSION: &[u8; 6] = b"3.3.0\0"; -pub const __NEWLIB__: u32 = 3; -pub const __NEWLIB_MINOR__: u32 = 3; -pub const __NEWLIB_PATCHLEVEL__: u32 = 0; -pub const _DEFAULT_SOURCE: u32 = 1; -pub const _POSIX_SOURCE: u32 = 1; -pub const _POSIX_C_SOURCE: u32 = 200809; -pub const _ATFILE_SOURCE: u32 = 1; -pub const __ATFILE_VISIBLE: u32 = 1; -pub const __BSD_VISIBLE: u32 = 1; -pub const __GNU_VISIBLE: u32 = 0; -pub const __ISO_C_VISIBLE: u32 = 2011; -pub const __LARGEFILE_VISIBLE: u32 = 0; -pub const __MISC_VISIBLE: u32 = 1; -pub const __POSIX_VISIBLE: u32 = 200809; -pub const __SVID_VISIBLE: u32 = 1; -pub const __XSI_VISIBLE: u32 = 0; -pub const __SSP_FORTIFY_LEVEL: u32 = 0; -pub const __have_longlong64: u32 = 1; -pub const __have_long32: u32 = 1; -pub const ___int8_t_defined: u32 = 1; -pub const ___int16_t_defined: u32 = 1; -pub const ___int32_t_defined: u32 = 1; -pub const ___int64_t_defined: u32 = 1; -pub const ___int_least8_t_defined: u32 = 1; -pub const ___int_least16_t_defined: u32 = 1; -pub const ___int_least32_t_defined: u32 = 1; -pub const ___int_least64_t_defined: u32 = 1; -pub const __int20: u32 = 2; -pub const __int20__: u32 = 2; -pub const __INT8: &[u8; 3] = b"hh\0"; -pub const __INT16: &[u8; 2] = b"h\0"; -pub const __INT64: &[u8; 3] = b"ll\0"; -pub const __FAST8: &[u8; 3] = b"hh\0"; -pub const __FAST16: &[u8; 2] = b"h\0"; -pub const __FAST64: &[u8; 3] = b"ll\0"; -pub const __LEAST8: &[u8; 3] = b"hh\0"; -pub const __LEAST16: &[u8; 2] = b"h\0"; -pub const __LEAST64: &[u8; 3] = b"ll\0"; -pub const __int8_t_defined: u32 = 1; -pub const __int16_t_defined: u32 = 1; -pub const __int32_t_defined: u32 = 1; -pub const __int64_t_defined: u32 = 1; -pub const __int_least8_t_defined: u32 = 1; -pub const __int_least16_t_defined: u32 = 1; -pub const __int_least32_t_defined: u32 = 1; -pub const __int_least64_t_defined: u32 = 1; -pub const __int_fast8_t_defined: u32 = 1; -pub const __int_fast16_t_defined: u32 = 1; -pub const __int_fast32_t_defined: u32 = 1; -pub const __int_fast64_t_defined: u32 = 1; -pub const WINT_MIN: u32 = 0; -pub const __OBSOLETE_MATH_DEFAULT: u32 = 1; -pub const __OBSOLETE_MATH: u32 = 1; -pub const __NEWLIB_H__: u32 = 1; -pub const _WANT_IO_C99_FORMATS: u32 = 1; -pub const _WANT_IO_LONG_LONG: u32 = 1; -pub const _WANT_REGISTER_FINI: u32 = 1; -pub const _REENT_CHECK_VERIFY: u32 = 1; -pub const _MB_LEN_MAX: u32 = 1; -pub const HAVE_INITFINI_ARRAY: u32 = 1; -pub const _ATEXIT_DYNAMIC_ALLOC: u32 = 1; -pub const _HAVE_LONG_DOUBLE: u32 = 1; -pub const _HAVE_CC_INHIBIT_LOOP_TO_LIBCALL: u32 = 1; -pub const _LDBL_EQ_DBL: u32 = 1; -pub const _FVWRITE_IN_STREAMIO: u32 = 1; -pub const _FSEEK_OPTIMIZATION: u32 = 1; -pub const _WIDE_ORIENT: u32 = 1; -pub const _UNBUF_STREAM_OPT: u32 = 1; -pub const _RETARGETABLE_LOCKING: u32 = 1; -pub const __RAND_MAX: u32 = 2147483647; -pub const _NULL: u32 = 0; -pub const _ATEXIT_SIZE: u32 = 32; -pub const _RAND48_SEED_0: u32 = 13070; -pub const _RAND48_SEED_1: u32 = 43981; -pub const _RAND48_SEED_2: u32 = 4660; -pub const _RAND48_MULT_0: u32 = 58989; -pub const _RAND48_MULT_1: u32 = 57068; -pub const _RAND48_MULT_2: u32 = 5; -pub const _RAND48_ADD: u32 = 11; -pub const _REENT_EMERGENCY_SIZE: u32 = 25; -pub const _REENT_ASCTIME_SIZE: u32 = 26; -pub const _REENT_SIGNAL_SIZE: u32 = 24; -pub const _N_LISTS: u32 = 30; -pub const __GNUCLIKE_ASM: u32 = 3; -pub const __GNUCLIKE___TYPEOF: u32 = 1; -pub const __GNUCLIKE___OFFSETOF: u32 = 1; -pub const __GNUCLIKE___SECTION: u32 = 1; -pub const __GNUCLIKE_CTOR_SECTION_HANDLING: u32 = 1; -pub const __GNUCLIKE_BUILTIN_CONSTANT_P: u32 = 1; -pub const __GNUCLIKE_BUILTIN_VARARGS: u32 = 1; -pub const __GNUCLIKE_BUILTIN_STDARG: u32 = 1; -pub const __GNUCLIKE_BUILTIN_VAALIST: u32 = 1; -pub const __GNUC_VA_LIST_COMPATIBILITY: u32 = 1; -pub const __GNUCLIKE_BUILTIN_NEXT_ARG: u32 = 1; -pub const __GNUCLIKE_BUILTIN_MEMCPY: u32 = 1; -pub const __CC_SUPPORTS_INLINE: u32 = 1; -pub const __CC_SUPPORTS___INLINE: u32 = 1; -pub const __CC_SUPPORTS___INLINE__: u32 = 1; -pub const __CC_SUPPORTS___FUNC__: u32 = 1; -pub const __CC_SUPPORTS_WARNING: u32 = 1; -pub const __CC_SUPPORTS_VARADIC_XXX: u32 = 1; -pub const __CC_SUPPORTS_DYNAMIC_ARRAY_INIT: u32 = 1; -pub const EXIT_FAILURE: u32 = 1; -pub const EXIT_SUCCESS: u32 = 0; -pub const RAND_MAX: u32 = 2147483647; -pub const OPENTHREAD_API_VERSION: u32 = 512; pub const OT_UPTIME_STRING_SIZE: u32 = 24; pub const OT_CHANGED_IP6_ADDRESS_ADDED: u32 = 1; pub const OT_CHANGED_IP6_ADDRESS_REMOVED: u32 = 2; @@ -299,8 +188,6 @@ pub const OT_CRYPTO_ECDSA_SIGNATURE_SIZE: u32 = 64; pub const OT_CRYPTO_PBDKF2_MAX_SALT_SIZE: u32 = 30; pub const OT_PANID_BROADCAST: u32 = 65535; pub const OT_EXT_ADDRESS_SIZE: u32 = 8; -pub const CSL_IE_HEADER_BYTES_LO: u32 = 4; -pub const CSL_IE_HEADER_BYTES_HI: u32 = 13; pub const OT_MAC_KEY_SIZE: u32 = 16; pub const OT_NETWORK_KEY_SIZE: u32 = 16; pub const OT_NETWORK_NAME_MAX_SIZE: u32 = 16; @@ -371,1049 +258,6 @@ pub const OT_DNS_MAX_LABEL_SIZE: u32 = 64; pub const OT_DNS_TXT_KEY_MIN_LENGTH: u32 = 1; pub const OT_DNS_TXT_KEY_MAX_LENGTH: u32 = 9; pub const OT_DNS_TXT_KEY_ITER_MAX_LENGTH: u32 = 64; -pub const OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE: u32 = 1; -pub type __int8_t = ::core::ffi::c_schar; -pub type __uint8_t = ::core::ffi::c_uchar; -pub type __int16_t = ::core::ffi::c_short; -pub type __uint16_t = ::core::ffi::c_ushort; -pub type __int32_t = ::core::ffi::c_int; -pub type __uint32_t = ::core::ffi::c_uint; -pub type __int64_t = ::core::ffi::c_longlong; -pub type __uint64_t = ::core::ffi::c_ulonglong; -pub type __int_least8_t = ::core::ffi::c_schar; -pub type __uint_least8_t = ::core::ffi::c_uchar; -pub type __int_least16_t = ::core::ffi::c_short; -pub type __uint_least16_t = ::core::ffi::c_ushort; -pub type __int_least32_t = ::core::ffi::c_int; -pub type __uint_least32_t = ::core::ffi::c_uint; -pub type __int_least64_t = ::core::ffi::c_longlong; -pub type __uint_least64_t = ::core::ffi::c_ulonglong; -pub type __intmax_t = ::core::ffi::c_longlong; -pub type __uintmax_t = ::core::ffi::c_ulonglong; -pub type __intptr_t = ::core::ffi::c_int; -pub type __uintptr_t = ::core::ffi::c_uint; -pub type intmax_t = __intmax_t; -pub type uintmax_t = __uintmax_t; -pub type int_least8_t = __int_least8_t; -pub type uint_least8_t = __uint_least8_t; -pub type int_least16_t = __int_least16_t; -pub type uint_least16_t = __uint_least16_t; -pub type int_least32_t = __int_least32_t; -pub type uint_least32_t = __uint_least32_t; -pub type int_least64_t = __int_least64_t; -pub type uint_least64_t = __uint_least64_t; -pub type int_fast8_t = ::core::ffi::c_schar; -pub type uint_fast8_t = ::core::ffi::c_uchar; -pub type int_fast16_t = ::core::ffi::c_short; -pub type uint_fast16_t = ::core::ffi::c_ushort; -pub type int_fast32_t = ::core::ffi::c_int; -pub type uint_fast32_t = ::core::ffi::c_uint; -pub type int_fast64_t = ::core::ffi::c_longlong; -pub type uint_fast64_t = ::core::ffi::c_ulonglong; -pub type wchar_t = ::core::ffi::c_uint; -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct max_align_t { - pub __clang_max_align_nonce1: ::core::ffi::c_longlong, - pub __clang_max_align_nonce2: f64, -} -pub type wint_t = ::core::ffi::c_int; -pub type __blkcnt_t = ::core::ffi::c_long; -pub type __blksize_t = ::core::ffi::c_long; -pub type __fsblkcnt_t = __uint64_t; -pub type __fsfilcnt_t = __uint32_t; -pub type _off_t = ::core::ffi::c_long; -pub type __pid_t = ::core::ffi::c_int; -pub type __dev_t = ::core::ffi::c_short; -pub type __uid_t = ::core::ffi::c_ushort; -pub type __gid_t = ::core::ffi::c_ushort; -pub type __id_t = __uint32_t; -pub type __ino_t = ::core::ffi::c_ushort; -pub type __mode_t = __uint32_t; -pub type _off64_t = ::core::ffi::c_longlong; -pub type __off_t = _off_t; -pub type __loff_t = _off64_t; -pub type __key_t = ::core::ffi::c_long; -pub type _fpos_t = ::core::ffi::c_long; -pub type __size_t = ::core::ffi::c_uint; -pub type _ssize_t = ::core::ffi::c_int; -pub type __ssize_t = _ssize_t; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _mbstate_t { - pub __count: ::core::ffi::c_int, - pub __value: _mbstate_t__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union _mbstate_t__bindgen_ty_1 { - pub __wch: wint_t, - pub __wchb: [::core::ffi::c_uchar; 4usize], -} -impl Default for _mbstate_t__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -impl Default for _mbstate_t { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -pub type _iconv_t = *mut ::core::ffi::c_void; -pub type __clock_t = ::core::ffi::c_ulong; -pub type __time_t = __int_least64_t; -pub type __clockid_t = ::core::ffi::c_ulong; -pub type __timer_t = ::core::ffi::c_ulong; -pub type __sa_family_t = __uint8_t; -pub type __socklen_t = __uint32_t; -pub type __nl_item = ::core::ffi::c_int; -pub type __nlink_t = ::core::ffi::c_ushort; -pub type __suseconds_t = ::core::ffi::c_long; -pub type __useconds_t = ::core::ffi::c_ulong; -pub type __va_list = u32; -pub type __ULong = ::core::ffi::c_ulong; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __lock { - _unused: [u8; 0], -} -pub type _LOCK_T = *mut __lock; -unsafe extern "C" { - pub fn __retarget_lock_init(lock: *mut _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_init_recursive(lock: *mut _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_close(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_close_recursive(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_acquire(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_acquire_recursive(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_try_acquire(lock: _LOCK_T) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __retarget_lock_try_acquire_recursive(lock: _LOCK_T) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __retarget_lock_release(lock: _LOCK_T); -} -unsafe extern "C" { - pub fn __retarget_lock_release_recursive(lock: _LOCK_T); -} -pub type _flock_t = _LOCK_T; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __locale_t { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _Bigint { - pub _next: *mut _Bigint, - pub _k: ::core::ffi::c_int, - pub _maxwds: ::core::ffi::c_int, - pub _sign: ::core::ffi::c_int, - pub _wds: ::core::ffi::c_int, - pub _x: [__ULong; 1usize], -} -impl Default for _Bigint { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct __tm { - pub __tm_sec: ::core::ffi::c_int, - pub __tm_min: ::core::ffi::c_int, - pub __tm_hour: ::core::ffi::c_int, - pub __tm_mday: ::core::ffi::c_int, - pub __tm_mon: ::core::ffi::c_int, - pub __tm_year: ::core::ffi::c_int, - pub __tm_wday: ::core::ffi::c_int, - pub __tm_yday: ::core::ffi::c_int, - pub __tm_isdst: ::core::ffi::c_int, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _on_exit_args { - pub _fnargs: [*mut ::core::ffi::c_void; 32usize], - pub _dso_handle: [*mut ::core::ffi::c_void; 32usize], - pub _fntypes: __ULong, - pub _is_cxa: __ULong, -} -impl Default for _on_exit_args { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _atexit { - pub _next: *mut _atexit, - pub _ind: ::core::ffi::c_int, - pub _fns: [::core::option::Option; 32usize], - pub _on_exit_args: _on_exit_args, -} -impl Default for _atexit { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __sbuf { - pub _base: *mut ::core::ffi::c_uchar, - pub _size: ::core::ffi::c_int, -} -impl Default for __sbuf { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __sFILE { - pub _p: *mut ::core::ffi::c_uchar, - pub _r: ::core::ffi::c_int, - pub _w: ::core::ffi::c_int, - pub _flags: ::core::ffi::c_short, - pub _file: ::core::ffi::c_short, - pub _bf: __sbuf, - pub _lbfsize: ::core::ffi::c_int, - pub _cookie: *mut ::core::ffi::c_void, - pub _read: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: *mut ::core::ffi::c_char, - arg4: ::core::ffi::c_int, - ) -> ::core::ffi::c_int, - >, - pub _write: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: *const ::core::ffi::c_char, - arg4: ::core::ffi::c_int, - ) -> ::core::ffi::c_int, - >, - pub _seek: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: _fpos_t, - arg4: ::core::ffi::c_int, - ) -> _fpos_t, - >, - pub _close: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - ) -> ::core::ffi::c_int, - >, - pub _ub: __sbuf, - pub _up: *mut ::core::ffi::c_uchar, - pub _ur: ::core::ffi::c_int, - pub _ubuf: [::core::ffi::c_uchar; 3usize], - pub _nbuf: [::core::ffi::c_uchar; 1usize], - pub _lb: __sbuf, - pub _blksize: ::core::ffi::c_int, - pub _offset: _off_t, - pub _data: *mut _reent, - pub _lock: _flock_t, - pub _mbstate: _mbstate_t, - pub _flags2: ::core::ffi::c_int, -} -impl Default for __sFILE { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -pub type __FILE = __sFILE; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _glue { - pub _next: *mut _glue, - pub _niobs: ::core::ffi::c_int, - pub _iobs: *mut __FILE, -} -impl Default for _glue { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct _rand48 { - pub _seed: [::core::ffi::c_ushort; 3usize], - pub _mult: [::core::ffi::c_ushort; 3usize], - pub _add: ::core::ffi::c_ushort, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _reent { - pub _errno: ::core::ffi::c_int, - pub _stdin: *mut __FILE, - pub _stdout: *mut __FILE, - pub _stderr: *mut __FILE, - pub _inc: ::core::ffi::c_int, - pub _emergency: [::core::ffi::c_char; 25usize], - pub _unspecified_locale_info: ::core::ffi::c_int, - pub _locale: *mut __locale_t, - pub __sdidinit: ::core::ffi::c_int, - pub __cleanup: ::core::option::Option, - pub _result: *mut _Bigint, - pub _result_k: ::core::ffi::c_int, - pub _p5s: *mut _Bigint, - pub _freelist: *mut *mut _Bigint, - pub _cvtlen: ::core::ffi::c_int, - pub _cvtbuf: *mut ::core::ffi::c_char, - pub _new: _reent__bindgen_ty_1, - pub _atexit: *mut _atexit, - pub _atexit0: _atexit, - pub _sig_func: *mut ::core::option::Option, - pub __sglue: _glue, - pub __sf: [__FILE; 3usize], -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union _reent__bindgen_ty_1 { - pub _reent: _reent__bindgen_ty_1__bindgen_ty_1, - pub _unused: _reent__bindgen_ty_1__bindgen_ty_2, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _reent__bindgen_ty_1__bindgen_ty_1 { - pub _unused_rand: ::core::ffi::c_uint, - pub _strtok_last: *mut ::core::ffi::c_char, - pub _asctime_buf: [::core::ffi::c_char; 26usize], - pub _localtime_buf: __tm, - pub _gamma_signgam: ::core::ffi::c_int, - pub _rand_next: ::core::ffi::c_ulonglong, - pub _r48: _rand48, - pub _mblen_state: _mbstate_t, - pub _mbtowc_state: _mbstate_t, - pub _wctomb_state: _mbstate_t, - pub _l64a_buf: [::core::ffi::c_char; 8usize], - pub _signal_buf: [::core::ffi::c_char; 24usize], - pub _getdate_err: ::core::ffi::c_int, - pub _mbrlen_state: _mbstate_t, - pub _mbrtowc_state: _mbstate_t, - pub _mbsrtowcs_state: _mbstate_t, - pub _wcrtomb_state: _mbstate_t, - pub _wcsrtombs_state: _mbstate_t, - pub _h_errno: ::core::ffi::c_int, -} -impl Default for _reent__bindgen_ty_1__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _reent__bindgen_ty_1__bindgen_ty_2 { - pub _nextf: [*mut ::core::ffi::c_uchar; 30usize], - pub _nmalloc: [::core::ffi::c_uint; 30usize], -} -impl Default for _reent__bindgen_ty_1__bindgen_ty_2 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -impl Default for _reent__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -impl Default for _reent { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -unsafe extern "C" { - pub static mut _impure_ptr: *mut _reent; -} -unsafe extern "C" { - pub static _global_impure_ptr: *mut _reent; -} -unsafe extern "C" { - pub fn _reclaim_reent(arg1: *mut _reent); -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct div_t { - pub quot: ::core::ffi::c_int, - pub rem: ::core::ffi::c_int, -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct ldiv_t { - pub quot: ::core::ffi::c_long, - pub rem: ::core::ffi::c_long, -} -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct lldiv_t { - pub quot: ::core::ffi::c_longlong, - pub rem: ::core::ffi::c_longlong, -} -pub type __compar_fn_t = ::core::option::Option< - unsafe extern "C" fn( - arg1: *const ::core::ffi::c_void, - arg2: *const ::core::ffi::c_void, - ) -> ::core::ffi::c_int, ->; -unsafe extern "C" { - pub fn __locale_mb_cur_max() -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn abort() -> !; -} -unsafe extern "C" { - pub fn abs(arg1: ::core::ffi::c_int) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn arc4random() -> __uint32_t; -} -unsafe extern "C" { - pub fn arc4random_uniform(arg1: __uint32_t) -> __uint32_t; -} -unsafe extern "C" { - pub fn arc4random_buf(arg1: *mut ::core::ffi::c_void, arg2: usize); -} -unsafe extern "C" { - pub fn atexit(__func: ::core::option::Option) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn atof(__nptr: *const ::core::ffi::c_char) -> f64; -} -unsafe extern "C" { - pub fn atoff(__nptr: *const ::core::ffi::c_char) -> f32; -} -unsafe extern "C" { - pub fn atoi(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _atoi_r(arg1: *mut _reent, __nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn atol(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _atol_r(arg1: *mut _reent, __nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn bsearch( - __key: *const ::core::ffi::c_void, - __base: *const ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - _compar: __compar_fn_t, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - #[must_use] - pub fn calloc(arg1: ::core::ffi::c_uint, arg2: ::core::ffi::c_uint) - -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn div(__numer: ::core::ffi::c_int, __denom: ::core::ffi::c_int) -> div_t; -} -unsafe extern "C" { - pub fn exit(__status: ::core::ffi::c_int) -> !; -} -unsafe extern "C" { - pub fn free(arg1: *mut ::core::ffi::c_void); -} -unsafe extern "C" { - pub fn getenv(__string: *const ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _getenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _findenv( - arg1: *const ::core::ffi::c_char, - arg2: *mut ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _findenv_r( - arg1: *mut _reent, - arg2: *const ::core::ffi::c_char, - arg3: *mut ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub static mut suboptarg: *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn getsubopt( - arg1: *mut *mut ::core::ffi::c_char, - arg2: *const *mut ::core::ffi::c_char, - arg3: *mut *mut ::core::ffi::c_char, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn labs(arg1: ::core::ffi::c_long) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn ldiv(__numer: ::core::ffi::c_long, __denom: ::core::ffi::c_long) -> ldiv_t; -} -unsafe extern "C" { - #[must_use] - pub fn malloc(arg1: ::core::ffi::c_uint) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn mblen(arg1: *const ::core::ffi::c_char, arg2: usize) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mblen_r( - arg1: *mut _reent, - arg2: *const ::core::ffi::c_char, - arg3: usize, - arg4: *mut _mbstate_t, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mbtowc( - arg1: *mut wchar_t, - arg2: *const ::core::ffi::c_char, - arg3: usize, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mbtowc_r( - arg1: *mut _reent, - arg2: *mut wchar_t, - arg3: *const ::core::ffi::c_char, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn wctomb(arg1: *mut ::core::ffi::c_char, arg2: wchar_t) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _wctomb_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: wchar_t, - arg4: *mut _mbstate_t, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mbstowcs(arg1: *mut wchar_t, arg2: *const ::core::ffi::c_char, arg3: usize) -> usize; -} -unsafe extern "C" { - pub fn _mbstowcs_r( - arg1: *mut _reent, - arg2: *mut wchar_t, - arg3: *const ::core::ffi::c_char, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> usize; -} -unsafe extern "C" { - pub fn wcstombs(arg1: *mut ::core::ffi::c_char, arg2: *const wchar_t, arg3: usize) -> usize; -} -unsafe extern "C" { - pub fn _wcstombs_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: *const wchar_t, - arg4: usize, - arg5: *mut _mbstate_t, - ) -> usize; -} -unsafe extern "C" { - pub fn mkdtemp(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn mkstemp(arg1: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mkstemps(arg1: *mut ::core::ffi::c_char, arg2: ::core::ffi::c_int) - -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn mktemp(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _mkdtemp_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _mkostemp_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkostemps_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - arg4: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkstemp_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mkstemps_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _mktemp_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char) - -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn qsort( - __base: *mut ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - _compar: __compar_fn_t, - ); -} -unsafe extern "C" { - pub fn rand() -> ::core::ffi::c_int; -} -unsafe extern "C" { - #[must_use] - pub fn realloc( - arg1: *mut ::core::ffi::c_void, - arg2: ::core::ffi::c_uint, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - #[must_use] - pub fn reallocarray( - arg1: *mut ::core::ffi::c_void, - arg2: usize, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - #[must_use] - pub fn reallocf(arg1: *mut ::core::ffi::c_void, arg2: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn realpath( - path: *const ::core::ffi::c_char, - resolved_path: *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn rpmatch(response: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn srand(__seed: ::core::ffi::c_uint); -} -unsafe extern "C" { - pub fn strtod(__n: *const ::core::ffi::c_char, __end_PTR: *mut *mut ::core::ffi::c_char) - -> f64; -} -unsafe extern "C" { - pub fn _strtod_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - ) -> f64; -} -unsafe extern "C" { - pub fn strtof(__n: *const ::core::ffi::c_char, __end_PTR: *mut *mut ::core::ffi::c_char) - -> f32; -} -unsafe extern "C" { - pub fn strtol( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _strtol_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn strtoul( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulong; -} -unsafe extern "C" { - pub fn _strtoul_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulong; -} -unsafe extern "C" { - pub fn system(__string: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn a64l(__input: *const ::core::ffi::c_char) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn l64a(__input: ::core::ffi::c_long) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _l64a_r(arg1: *mut _reent, __input: ::core::ffi::c_long) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn on_exit( - __func: ::core::option::Option< - unsafe extern "C" fn(arg1: ::core::ffi::c_int, arg2: *mut ::core::ffi::c_void), - >, - __arg: *mut ::core::ffi::c_void, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _Exit(__status: ::core::ffi::c_int) -> !; -} -unsafe extern "C" { - pub fn putenv(__string: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _putenv_r(arg1: *mut _reent, __string: *mut ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _reallocf_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn setenv( - __string: *const ::core::ffi::c_char, - __value: *const ::core::ffi::c_char, - __overwrite: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _setenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - __value: *const ::core::ffi::c_char, - __overwrite: ::core::ffi::c_int, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __itoa( - arg1: ::core::ffi::c_int, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn __utoa( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn itoa( - arg1: ::core::ffi::c_int, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn utoa( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: ::core::ffi::c_int, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn rand_r(__seed: *mut ::core::ffi::c_uint) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn drand48() -> f64; -} -unsafe extern "C" { - pub fn _drand48_r(arg1: *mut _reent) -> f64; -} -unsafe extern "C" { - pub fn erand48(arg1: *mut ::core::ffi::c_ushort) -> f64; -} -unsafe extern "C" { - pub fn _erand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> f64; -} -unsafe extern "C" { - pub fn jrand48(arg1: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _jrand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn lcong48(arg1: *mut ::core::ffi::c_ushort); -} -unsafe extern "C" { - pub fn _lcong48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort); -} -unsafe extern "C" { - pub fn lrand48() -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _lrand48_r(arg1: *mut _reent) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn mrand48() -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _mrand48_r(arg1: *mut _reent) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn nrand48(arg1: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn _nrand48_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_ushort) -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn seed48(arg1: *mut ::core::ffi::c_ushort) -> *mut ::core::ffi::c_ushort; -} -unsafe extern "C" { - pub fn _seed48_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_ushort, - ) -> *mut ::core::ffi::c_ushort; -} -unsafe extern "C" { - pub fn srand48(arg1: ::core::ffi::c_long); -} -unsafe extern "C" { - pub fn _srand48_r(arg1: *mut _reent, arg2: ::core::ffi::c_long); -} -unsafe extern "C" { - pub fn initstate( - arg1: ::core::ffi::c_uint, - arg2: *mut ::core::ffi::c_char, - arg3: usize, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn random() -> ::core::ffi::c_long; -} -unsafe extern "C" { - pub fn setstate(arg1: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn srandom(arg1: ::core::ffi::c_uint); -} -unsafe extern "C" { - pub fn atoll(__nptr: *const ::core::ffi::c_char) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn _atoll_r( - arg1: *mut _reent, - __nptr: *const ::core::ffi::c_char, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn llabs(arg1: ::core::ffi::c_longlong) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn lldiv(__numer: ::core::ffi::c_longlong, __denom: ::core::ffi::c_longlong) -> lldiv_t; -} -unsafe extern "C" { - pub fn strtoll( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn _strtoll_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_longlong; -} -unsafe extern "C" { - pub fn strtoull( - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulonglong; -} -unsafe extern "C" { - pub fn _strtoull_r( - arg1: *mut _reent, - __n: *const ::core::ffi::c_char, - __end_PTR: *mut *mut ::core::ffi::c_char, - __base: ::core::ffi::c_int, - ) -> ::core::ffi::c_ulonglong; -} -unsafe extern "C" { - pub fn cfree(arg1: *mut ::core::ffi::c_void); -} -unsafe extern "C" { - pub fn unsetenv(__string: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _unsetenv_r( - arg1: *mut _reent, - __string: *const ::core::ffi::c_char, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - #[must_use] - pub fn posix_memalign( - arg1: *mut *mut ::core::ffi::c_void, - arg2: usize, - arg3: usize, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn _dtoa_r( - arg1: *mut _reent, - arg2: f64, - arg3: ::core::ffi::c_int, - arg4: ::core::ffi::c_int, - arg5: *mut ::core::ffi::c_int, - arg6: *mut ::core::ffi::c_int, - arg7: *mut *mut ::core::ffi::c_char, - ) -> *mut ::core::ffi::c_char; -} -unsafe extern "C" { - pub fn _malloc_r(arg1: *mut _reent, arg2: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _calloc_r(arg1: *mut _reent, arg2: usize, arg3: usize) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _free_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_void); -} -unsafe extern "C" { - pub fn _realloc_r( - arg1: *mut _reent, - arg2: *mut ::core::ffi::c_void, - arg3: usize, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn _mstats_r(arg1: *mut _reent, arg2: *mut ::core::ffi::c_char); -} -unsafe extern "C" { - pub fn _system_r(arg1: *mut _reent, arg2: *const ::core::ffi::c_char) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn __eprintf( - arg1: *const ::core::ffi::c_char, - arg2: *const ::core::ffi::c_char, - arg3: ::core::ffi::c_uint, - arg4: *const ::core::ffi::c_char, - ); -} -unsafe extern "C" { - #[link_name = "\u{1}__bsd_qsort_r"] - pub fn qsort_r( - __base: *mut ::core::ffi::c_void, - __nmemb: usize, - __size: usize, - __thunk: *mut ::core::ffi::c_void, - _compar: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut ::core::ffi::c_void, - arg2: *const ::core::ffi::c_void, - arg3: *const ::core::ffi::c_void, - ) -> ::core::ffi::c_int, - >, - ); -} -unsafe extern "C" { - #[must_use] - pub fn aligned_alloc( - arg1: ::core::ffi::c_uint, - arg2: ::core::ffi::c_uint, - ) -> *mut ::core::ffi::c_void; -} -unsafe extern "C" { - pub fn at_quick_exit( - arg1: ::core::option::Option, - ) -> ::core::ffi::c_int; -} -unsafe extern "C" { - pub fn quick_exit(arg1: ::core::ffi::c_int) -> !; -} /// No error. pub const otError_OT_ERROR_NONE: otError = 0; /// Operational failed. diff --git a/openthread-sys/src/lib.rs b/openthread-sys/src/lib.rs index d5191f0..e288c8b 100644 --- a/openthread-sys/src/lib.rs +++ b/openthread-sys/src/lib.rs @@ -44,7 +44,7 @@ pub use bindings::*; unnecessary_transmutes, clippy::all )] -pub mod bindings { +mod bindings { #[cfg(not(target_os = "espidf"))] include!(env!("OPENTHREAD_SYS_BINDINGS_FILE"));