commit cdf5441c410ec1f94ab8b38a6ad0889739487c28 Author: Robin Mueller Date: Wed May 29 00:25:05 2024 +0200 Initial version of libcsp-rust diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..9dce705 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,4 @@ +[env] +# This is set for this repository so it does not always have to be set in the command line. +# It is required for building libcsp-rust. +CSP_CONFIG_DIR = { value = "examples", relative = true } diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..54e0a14 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,172 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "cc" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libcsp" +version = "0.1.0" +dependencies = [ + "bitflags", + "libc", + "libcsp-sys", + "num_enum", +] + +[[package]] +name = "libcsp-cargo-build" +version = "0.1.0" +dependencies = [ + "cc", +] + +[[package]] +name = "libcsp-rust-examples" +version = "0.1.0" +dependencies = [ + "libcsp", + "libcsp-cargo-build", +] + +[[package]] +name = "libcsp-sys" +version = "0.1.0" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "num_enum" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "2.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..5b3c604 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "libcsp-cargo-build", "libcsp", "libcsp-sys", "examples" +] +resolver = "2" diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..717a583 --- /dev/null +++ b/NOTICE @@ -0,0 +1 @@ +This software contains code developed at the University of Stuttgart's Institute of Space Systems. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c9347b0 --- /dev/null +++ b/README.md @@ -0,0 +1,95 @@ +libcsp-rust +========= + +This project aims to provide libraries and tools to build and use +the [`libcsp`](https://github.com/libcsp/libcsp) C library in your Rust project. + +It provides 3 crates for this: + +- [`libcsp`](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/libcsp-rust) + provides a safe and ergonomic Rust interface on top of the `libcsp-sys` crate. +- [`libcsp-sys`](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/libcsp-sys) + provides the Rust bindings to [`libcsp`](https://github.com/libcsp/libcsp). +- [`libcsp-cargo-build`](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/libcsp-cargo-build) + provides an API to build the `libcsp` using `cargo` with the [`cc`](https://docs.rs/cc/latest/cc/) crate. + +In addition, it provides a workspace to allow updating the `libcsp` C sources and the corresponding +bindings more easily inside the `clib` directory. Some of the examples `libcsp` provides were ported +to Rust and are showcased in the `examples` directory. + +Please note that this is early-stage/experimental software. Important features might be missing. +PRs and improvement suggestions are welcome! This project was primarily tested on a Linux/POSIX +system so far. + +## How it works + +We assume that cargo should also take care of building the library. + +1. Add the `libcsp-cargo-build` as a build dependency inside your `Cargo.toml`. +2. Add the `libcsp` as a regular dependency inside your `Cargo.toml`. +3. Create a custom `build.rs` script which takes care of building the `libcsp` C library using the + API provided by `libcsp-cargo-build`. You have to provide the source code for `libcsp` inside + some directory and pass the directory path to the builder API. +4. You can now write regular Rust code and use the Rust API provided by the `libcsp` crate to use + the `libcsp` C library. + +It is recommended to have a look at the [example build script](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/examples/build.rs) +which should give you a general idea of how a build script which does the 4 steps above might look +like. + +## Running the example + +The example uses both the builder crate and the bindings and API crate and implements the +[server/client example](https://github.com/libcsp/libcsp/blob/develop/examples/csp_server_client.c) +in Rust. You can run the example using the following steps: + +1. Clone/Copy `libcsp` into the `lib` folder, for example by using the provided `lib/clone-csp.sh` + script or adding `libcsp` as a git submodule. +2. You can now use `cargo run -p libcsp-rust-examples` to run the server/client example. + +## Compile-time configuration of the `libcsp-sys` library + +The `libcsp-sys` requires some compile-time configuration file to be included to work +properly. You can see an example version of the file for the workspace +[here](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/examples/autoconfig.rs). +The user has to provide the path to a directory containing this `autoconfig.rs` file using the +`CSP_CONFIG_DIR` environmental variable. + +You can automatically generate this file when using `libcsp-cargo-build` by using the +[`generate_autoconf_rust_file`](here be link soon) method of the Builder object as done in the +example build script. + +In this workspace, the `CSP_CONFIG_DIR` variable is hardcoded using the following `.cargo/config.toml` +configuration: + +```toml +[env] +CSP_CONFIG_DIR = { value = "examples", relative = true } +``` + +## Generating and update the bindings using the `clib` folder + +The `lib` folder in this repository serves as the staging directory for the `libcsp` library to +build. However, it can also be used to update the bindings provided in `libcsp-sys` by providing +some tools and helpers to auto-generate and update the bindings file `bindings.rs`. + +If you want to do this, you should install `bindgen-cli` first: + +```sh +cargo install bindgen-cli --locked +``` + +`bindgen` needs some additional information provided by the user to generate the bindings: +An `autoconfig.h` file which is used to configure `libcsp`. Normally, this file is generated +by the C build system. This file is located at `clib/cfg/csp` and is also updated automatically +when running the example application. + +After cloning the repository, you can now run the following command to re-generate the bindings +file: + +```sh +bindgen --use-core wrapper.h -- "-I./libcsp/include" "-I./cfg" "-I./libcsp/src" > bindings.rs +``` + +With the bindings file, you can now manually update the FFI bindings provided in +`libcsp-sys/src/lib.rs` or in your own CSP library. diff --git a/clib/.gitignore b/clib/.gitignore new file mode 100644 index 0000000..5946b3d --- /dev/null +++ b/clib/.gitignore @@ -0,0 +1 @@ +/libcsp diff --git a/clib/bindings.rs b/clib/bindings.rs new file mode 100644 index 0000000..7d0ff16 --- /dev/null +++ b/clib/bindings.rs @@ -0,0 +1,7538 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +#[repr(C)] +#[derive(Default)] +pub struct __IncompleteArrayField(::core::marker::PhantomData, [T; 0]); +impl __IncompleteArrayField { + #[inline] + pub const fn new() -> Self { + __IncompleteArrayField(::core::marker::PhantomData, []) + } + #[inline] + pub fn as_ptr(&self) -> *const T { + self as *const _ as *const T + } + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self as *mut _ as *mut T + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::core::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::core::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } +} +impl ::core::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } +} +pub const CSP_ERR_NONE: u32 = 0; +pub const CSP_ERR_NOMEM: i32 = -1; +pub const CSP_ERR_INVAL: i32 = -2; +pub const CSP_ERR_TIMEDOUT: i32 = -3; +pub const CSP_ERR_USED: i32 = -4; +pub const CSP_ERR_NOTSUP: i32 = -5; +pub const CSP_ERR_BUSY: i32 = -6; +pub const CSP_ERR_ALREADY: i32 = -7; +pub const CSP_ERR_RESET: i32 = -8; +pub const CSP_ERR_NOBUFS: i32 = -9; +pub const CSP_ERR_TX: i32 = -10; +pub const CSP_ERR_DRIVER: i32 = -11; +pub const CSP_ERR_AGAIN: i32 = -12; +pub const CSP_ERR_NOSYS: i32 = -38; +pub const CSP_ERR_HMAC: i32 = -100; +pub const CSP_ERR_CRC32: i32 = -102; +pub const CSP_ERR_SFP: i32 = -103; +pub const CSP_POSIX: u32 = 1; +pub const CSP_ZEPHYR: u32 = 0; +pub const CSP_HAVE_STDIO: u32 = 1; +pub const CSP_ENABLE_CSP_PRINT: u32 = 1; +pub const CSP_PRINT_STDIO: u32 = 1; +pub const CSP_REPRODUCIBLE_BUILDS: u32 = 0; +pub const CSP_QFIFO_LEN: u32 = 16; +pub const CSP_PORT_MAX_BIND: u32 = 16; +pub const CSP_CONN_RXQUEUE_LEN: u32 = 16; +pub const CSP_CONN_MAX: u32 = 8; +pub const CSP_BUFFER_SIZE: u32 = 256; +pub const CSP_BUFFER_COUNT: u32 = 15; +pub const CSP_RDP_MAX_WINDOW: u32 = 5; +pub const CSP_RTABLE_SIZE: u32 = 10; +pub const CSP_USE_RDP: u32 = 1; +pub const CSP_USE_HMAC: u32 = 1; +pub const CSP_USE_PROMISC: u32 = 1; +pub const CSP_USE_RTABLE: u32 = 0; +pub const CSP_HAVE_LIBSOCKETCAN: u32 = 0; +pub const CSP_HAVE_LIBZMQ: u32 = 0; +pub const _INTTYPES_H: u32 = 1; +pub const _FEATURES_H: u32 = 1; +pub const _DEFAULT_SOURCE: u32 = 1; +pub const __GLIBC_USE_ISOC2X: u32 = 0; +pub const __USE_ISOC11: u32 = 1; +pub const __USE_ISOC99: u32 = 1; +pub const __USE_ISOC95: u32 = 1; +pub const __USE_POSIX_IMPLICITLY: u32 = 1; +pub const _POSIX_SOURCE: u32 = 1; +pub const _POSIX_C_SOURCE: u32 = 200809; +pub const __USE_POSIX: u32 = 1; +pub const __USE_POSIX2: u32 = 1; +pub const __USE_POSIX199309: u32 = 1; +pub const __USE_POSIX199506: u32 = 1; +pub const __USE_XOPEN2K: u32 = 1; +pub const __USE_XOPEN2K8: u32 = 1; +pub const _ATFILE_SOURCE: u32 = 1; +pub const __WORDSIZE: u32 = 64; +pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; +pub const __SYSCALL_WORDSIZE: u32 = 64; +pub const __TIMESIZE: u32 = 64; +pub const __USE_MISC: u32 = 1; +pub const __USE_ATFILE: u32 = 1; +pub const __USE_FORTIFY_LEVEL: u32 = 0; +pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; +pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0; +pub const _STDC_PREDEF_H: u32 = 1; +pub const __STDC_IEC_559__: u32 = 1; +pub const __STDC_IEC_60559_BFP__: u32 = 201404; +pub const __STDC_IEC_559_COMPLEX__: u32 = 1; +pub const __STDC_IEC_60559_COMPLEX__: u32 = 201404; +pub const __STDC_ISO_10646__: u32 = 201706; +pub const __GNU_LIBRARY__: u32 = 6; +pub const __GLIBC__: u32 = 2; +pub const __GLIBC_MINOR__: u32 = 35; +pub const _SYS_CDEFS_H: u32 = 1; +pub const __glibc_c99_flexarr_available: u32 = 1; +pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI: u32 = 0; +pub const __HAVE_GENERIC_SELECTION: u32 = 1; +pub const _STDINT_H: u32 = 1; +pub const __GLIBC_USE_LIB_EXT2: u32 = 0; +pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_BFP_EXT_C2X: u32 = 0; +pub const __GLIBC_USE_IEC_60559_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X: u32 = 0; +pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; +pub const _BITS_TYPES_H: u32 = 1; +pub const _BITS_TYPESIZES_H: u32 = 1; +pub const __OFF_T_MATCHES_OFF64_T: u32 = 1; +pub const __INO_T_MATCHES_INO64_T: u32 = 1; +pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1; +pub const __STATFS_MATCHES_STATFS64: u32 = 1; +pub const __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64: u32 = 1; +pub const __FD_SETSIZE: u32 = 1024; +pub const _BITS_TIME64_H: u32 = 1; +pub const _BITS_WCHAR_H: u32 = 1; +pub const _BITS_STDINT_INTN_H: u32 = 1; +pub const _BITS_STDINT_UINTN_H: u32 = 1; +pub const INT8_MIN: i32 = -128; +pub const INT16_MIN: i32 = -32768; +pub const INT32_MIN: i32 = -2147483648; +pub const INT8_MAX: u32 = 127; +pub const INT16_MAX: u32 = 32767; +pub const INT32_MAX: u32 = 2147483647; +pub const UINT8_MAX: u32 = 255; +pub const UINT16_MAX: u32 = 65535; +pub const UINT32_MAX: u32 = 4294967295; +pub const INT_LEAST8_MIN: i32 = -128; +pub const INT_LEAST16_MIN: i32 = -32768; +pub const INT_LEAST32_MIN: i32 = -2147483648; +pub const INT_LEAST8_MAX: u32 = 127; +pub const INT_LEAST16_MAX: u32 = 32767; +pub const INT_LEAST32_MAX: u32 = 2147483647; +pub const UINT_LEAST8_MAX: u32 = 255; +pub const UINT_LEAST16_MAX: u32 = 65535; +pub const UINT_LEAST32_MAX: u32 = 4294967295; +pub const INT_FAST8_MIN: i32 = -128; +pub const INT_FAST16_MIN: i64 = -9223372036854775808; +pub const INT_FAST32_MIN: i64 = -9223372036854775808; +pub const INT_FAST8_MAX: u32 = 127; +pub const INT_FAST16_MAX: u64 = 9223372036854775807; +pub const INT_FAST32_MAX: u64 = 9223372036854775807; +pub const UINT_FAST8_MAX: u32 = 255; +pub const UINT_FAST16_MAX: i32 = -1; +pub const UINT_FAST32_MAX: i32 = -1; +pub const INTPTR_MIN: i64 = -9223372036854775808; +pub const INTPTR_MAX: u64 = 9223372036854775807; +pub const UINTPTR_MAX: i32 = -1; +pub const PTRDIFF_MIN: i64 = -9223372036854775808; +pub const PTRDIFF_MAX: u64 = 9223372036854775807; +pub const SIG_ATOMIC_MIN: i32 = -2147483648; +pub const SIG_ATOMIC_MAX: u32 = 2147483647; +pub const SIZE_MAX: i32 = -1; +pub const WINT_MIN: u32 = 0; +pub const WINT_MAX: u32 = 4294967295; +pub const ____gwchar_t_defined: u32 = 1; +pub const __PRI64_PREFIX: &[u8; 2] = b"l\0"; +pub const __PRIPTR_PREFIX: &[u8; 2] = b"l\0"; +pub const PRId8: &[u8; 2] = b"d\0"; +pub const PRId16: &[u8; 2] = b"d\0"; +pub const PRId32: &[u8; 2] = b"d\0"; +pub const PRId64: &[u8; 3] = b"ld\0"; +pub const PRIdLEAST8: &[u8; 2] = b"d\0"; +pub const PRIdLEAST16: &[u8; 2] = b"d\0"; +pub const PRIdLEAST32: &[u8; 2] = b"d\0"; +pub const PRIdLEAST64: &[u8; 3] = b"ld\0"; +pub const PRIdFAST8: &[u8; 2] = b"d\0"; +pub const PRIdFAST16: &[u8; 3] = b"ld\0"; +pub const PRIdFAST32: &[u8; 3] = b"ld\0"; +pub const PRIdFAST64: &[u8; 3] = b"ld\0"; +pub const PRIi8: &[u8; 2] = b"i\0"; +pub const PRIi16: &[u8; 2] = b"i\0"; +pub const PRIi32: &[u8; 2] = b"i\0"; +pub const PRIi64: &[u8; 3] = b"li\0"; +pub const PRIiLEAST8: &[u8; 2] = b"i\0"; +pub const PRIiLEAST16: &[u8; 2] = b"i\0"; +pub const PRIiLEAST32: &[u8; 2] = b"i\0"; +pub const PRIiLEAST64: &[u8; 3] = b"li\0"; +pub const PRIiFAST8: &[u8; 2] = b"i\0"; +pub const PRIiFAST16: &[u8; 3] = b"li\0"; +pub const PRIiFAST32: &[u8; 3] = b"li\0"; +pub const PRIiFAST64: &[u8; 3] = b"li\0"; +pub const PRIo8: &[u8; 2] = b"o\0"; +pub const PRIo16: &[u8; 2] = b"o\0"; +pub const PRIo32: &[u8; 2] = b"o\0"; +pub const PRIo64: &[u8; 3] = b"lo\0"; +pub const PRIoLEAST8: &[u8; 2] = b"o\0"; +pub const PRIoLEAST16: &[u8; 2] = b"o\0"; +pub const PRIoLEAST32: &[u8; 2] = b"o\0"; +pub const PRIoLEAST64: &[u8; 3] = b"lo\0"; +pub const PRIoFAST8: &[u8; 2] = b"o\0"; +pub const PRIoFAST16: &[u8; 3] = b"lo\0"; +pub const PRIoFAST32: &[u8; 3] = b"lo\0"; +pub const PRIoFAST64: &[u8; 3] = b"lo\0"; +pub const PRIu8: &[u8; 2] = b"u\0"; +pub const PRIu16: &[u8; 2] = b"u\0"; +pub const PRIu32: &[u8; 2] = b"u\0"; +pub const PRIu64: &[u8; 3] = b"lu\0"; +pub const PRIuLEAST8: &[u8; 2] = b"u\0"; +pub const PRIuLEAST16: &[u8; 2] = b"u\0"; +pub const PRIuLEAST32: &[u8; 2] = b"u\0"; +pub const PRIuLEAST64: &[u8; 3] = b"lu\0"; +pub const PRIuFAST8: &[u8; 2] = b"u\0"; +pub const PRIuFAST16: &[u8; 3] = b"lu\0"; +pub const PRIuFAST32: &[u8; 3] = b"lu\0"; +pub const PRIuFAST64: &[u8; 3] = b"lu\0"; +pub const PRIx8: &[u8; 2] = b"x\0"; +pub const PRIx16: &[u8; 2] = b"x\0"; +pub const PRIx32: &[u8; 2] = b"x\0"; +pub const PRIx64: &[u8; 3] = b"lx\0"; +pub const PRIxLEAST8: &[u8; 2] = b"x\0"; +pub const PRIxLEAST16: &[u8; 2] = b"x\0"; +pub const PRIxLEAST32: &[u8; 2] = b"x\0"; +pub const PRIxLEAST64: &[u8; 3] = b"lx\0"; +pub const PRIxFAST8: &[u8; 2] = b"x\0"; +pub const PRIxFAST16: &[u8; 3] = b"lx\0"; +pub const PRIxFAST32: &[u8; 3] = b"lx\0"; +pub const PRIxFAST64: &[u8; 3] = b"lx\0"; +pub const PRIX8: &[u8; 2] = b"X\0"; +pub const PRIX16: &[u8; 2] = b"X\0"; +pub const PRIX32: &[u8; 2] = b"X\0"; +pub const PRIX64: &[u8; 3] = b"lX\0"; +pub const PRIXLEAST8: &[u8; 2] = b"X\0"; +pub const PRIXLEAST16: &[u8; 2] = b"X\0"; +pub const PRIXLEAST32: &[u8; 2] = b"X\0"; +pub const PRIXLEAST64: &[u8; 3] = b"lX\0"; +pub const PRIXFAST8: &[u8; 2] = b"X\0"; +pub const PRIXFAST16: &[u8; 3] = b"lX\0"; +pub const PRIXFAST32: &[u8; 3] = b"lX\0"; +pub const PRIXFAST64: &[u8; 3] = b"lX\0"; +pub const PRIdMAX: &[u8; 3] = b"ld\0"; +pub const PRIiMAX: &[u8; 3] = b"li\0"; +pub const PRIoMAX: &[u8; 3] = b"lo\0"; +pub const PRIuMAX: &[u8; 3] = b"lu\0"; +pub const PRIxMAX: &[u8; 3] = b"lx\0"; +pub const PRIXMAX: &[u8; 3] = b"lX\0"; +pub const PRIdPTR: &[u8; 3] = b"ld\0"; +pub const PRIiPTR: &[u8; 3] = b"li\0"; +pub const PRIoPTR: &[u8; 3] = b"lo\0"; +pub const PRIuPTR: &[u8; 3] = b"lu\0"; +pub const PRIxPTR: &[u8; 3] = b"lx\0"; +pub const PRIXPTR: &[u8; 3] = b"lX\0"; +pub const SCNd8: &[u8; 4] = b"hhd\0"; +pub const SCNd16: &[u8; 3] = b"hd\0"; +pub const SCNd32: &[u8; 2] = b"d\0"; +pub const SCNd64: &[u8; 3] = b"ld\0"; +pub const SCNdLEAST8: &[u8; 4] = b"hhd\0"; +pub const SCNdLEAST16: &[u8; 3] = b"hd\0"; +pub const SCNdLEAST32: &[u8; 2] = b"d\0"; +pub const SCNdLEAST64: &[u8; 3] = b"ld\0"; +pub const SCNdFAST8: &[u8; 4] = b"hhd\0"; +pub const SCNdFAST16: &[u8; 3] = b"ld\0"; +pub const SCNdFAST32: &[u8; 3] = b"ld\0"; +pub const SCNdFAST64: &[u8; 3] = b"ld\0"; +pub const SCNi8: &[u8; 4] = b"hhi\0"; +pub const SCNi16: &[u8; 3] = b"hi\0"; +pub const SCNi32: &[u8; 2] = b"i\0"; +pub const SCNi64: &[u8; 3] = b"li\0"; +pub const SCNiLEAST8: &[u8; 4] = b"hhi\0"; +pub const SCNiLEAST16: &[u8; 3] = b"hi\0"; +pub const SCNiLEAST32: &[u8; 2] = b"i\0"; +pub const SCNiLEAST64: &[u8; 3] = b"li\0"; +pub const SCNiFAST8: &[u8; 4] = b"hhi\0"; +pub const SCNiFAST16: &[u8; 3] = b"li\0"; +pub const SCNiFAST32: &[u8; 3] = b"li\0"; +pub const SCNiFAST64: &[u8; 3] = b"li\0"; +pub const SCNu8: &[u8; 4] = b"hhu\0"; +pub const SCNu16: &[u8; 3] = b"hu\0"; +pub const SCNu32: &[u8; 2] = b"u\0"; +pub const SCNu64: &[u8; 3] = b"lu\0"; +pub const SCNuLEAST8: &[u8; 4] = b"hhu\0"; +pub const SCNuLEAST16: &[u8; 3] = b"hu\0"; +pub const SCNuLEAST32: &[u8; 2] = b"u\0"; +pub const SCNuLEAST64: &[u8; 3] = b"lu\0"; +pub const SCNuFAST8: &[u8; 4] = b"hhu\0"; +pub const SCNuFAST16: &[u8; 3] = b"lu\0"; +pub const SCNuFAST32: &[u8; 3] = b"lu\0"; +pub const SCNuFAST64: &[u8; 3] = b"lu\0"; +pub const SCNo8: &[u8; 4] = b"hho\0"; +pub const SCNo16: &[u8; 3] = b"ho\0"; +pub const SCNo32: &[u8; 2] = b"o\0"; +pub const SCNo64: &[u8; 3] = b"lo\0"; +pub const SCNoLEAST8: &[u8; 4] = b"hho\0"; +pub const SCNoLEAST16: &[u8; 3] = b"ho\0"; +pub const SCNoLEAST32: &[u8; 2] = b"o\0"; +pub const SCNoLEAST64: &[u8; 3] = b"lo\0"; +pub const SCNoFAST8: &[u8; 4] = b"hho\0"; +pub const SCNoFAST16: &[u8; 3] = b"lo\0"; +pub const SCNoFAST32: &[u8; 3] = b"lo\0"; +pub const SCNoFAST64: &[u8; 3] = b"lo\0"; +pub const SCNx8: &[u8; 4] = b"hhx\0"; +pub const SCNx16: &[u8; 3] = b"hx\0"; +pub const SCNx32: &[u8; 2] = b"x\0"; +pub const SCNx64: &[u8; 3] = b"lx\0"; +pub const SCNxLEAST8: &[u8; 4] = b"hhx\0"; +pub const SCNxLEAST16: &[u8; 3] = b"hx\0"; +pub const SCNxLEAST32: &[u8; 2] = b"x\0"; +pub const SCNxLEAST64: &[u8; 3] = b"lx\0"; +pub const SCNxFAST8: &[u8; 4] = b"hhx\0"; +pub const SCNxFAST16: &[u8; 3] = b"lx\0"; +pub const SCNxFAST32: &[u8; 3] = b"lx\0"; +pub const SCNxFAST64: &[u8; 3] = b"lx\0"; +pub const SCNdMAX: &[u8; 3] = b"ld\0"; +pub const SCNiMAX: &[u8; 3] = b"li\0"; +pub const SCNoMAX: &[u8; 3] = b"lo\0"; +pub const SCNuMAX: &[u8; 3] = b"lu\0"; +pub const SCNxMAX: &[u8; 3] = b"lx\0"; +pub const SCNdPTR: &[u8; 3] = b"ld\0"; +pub const SCNiPTR: &[u8; 3] = b"li\0"; +pub const SCNoPTR: &[u8; 3] = b"lo\0"; +pub const SCNuPTR: &[u8; 3] = b"lu\0"; +pub const SCNxPTR: &[u8; 3] = b"lx\0"; +pub const CSP_DBG_ERR_CORRUPT_BUFFER: u32 = 1; +pub const CSP_DBG_ERR_MTU_EXCEEDED: u32 = 2; +pub const CSP_DBG_ERR_ALREADY_FREE: u32 = 3; +pub const CSP_DBG_ERR_REFCOUNT: u32 = 4; +pub const CSP_DBG_ERR_INVALID_RTABLE_ENTRY: u32 = 6; +pub const CSP_DBG_ERR_UNSUPPORTED: u32 = 7; +pub const CSP_DBG_ERR_INVALID_BIND_PORT: u32 = 8; +pub const CSP_DBG_ERR_PORT_ALREADY_IN_USE: u32 = 9; +pub const CSP_DBG_ERR_ALREADY_CLOSED: u32 = 10; +pub const CSP_DBG_ERR_INVALID_POINTER: u32 = 11; +pub const CSP_DBG_ERR_CLOCK_SET_FAIL: u32 = 12; +pub const CSP_DBG_CAN_ERR_FRAME_LOST: u32 = 1; +pub const CSP_DBG_CAN_ERR_RX_OVF: u32 = 2; +pub const CSP_DBG_CAN_ERR_RX_OUT: u32 = 3; +pub const CSP_DBG_CAN_ERR_SHORT_BEGIN: u32 = 4; +pub const CSP_DBG_CAN_ERR_INCOMPLETE: u32 = 5; +pub const CSP_DBG_CAN_ERR_UNKNOWN: u32 = 6; +pub const CSP_DBG_ETH_ERR_FRAME_LOST: u32 = 1; +pub const CSP_DBG_ETH_ERR_RX_OVF: u32 = 2; +pub const CSP_DBG_ETH_ERR_RX_OUT: u32 = 3; +pub const CSP_DBG_ETH_ERR_SHORT_BEGIN: u32 = 4; +pub const CSP_DBG_ETH_ERR_INCOMPLETE: u32 = 5; +pub const CSP_DBG_ETH_ERR_UNKNOWN: u32 = 6; +pub const true_: u32 = 1; +pub const false_: u32 = 0; +pub const __bool_true_false_are_defined: u32 = 1; +pub const CSP_QUEUE_OK: u32 = 0; +pub const CSP_QUEUE_ERROR: i32 = -1; +pub const CSP_ANY: u32 = 255; +pub const CSP_FRES1: u32 = 128; +pub const CSP_FRES2: u32 = 64; +pub const CSP_FRES3: u32 = 32; +pub const CSP_FFRAG: u32 = 16; +pub const CSP_FHMAC: u32 = 8; +pub const CSP_FRDP: u32 = 2; +pub const CSP_FCRC32: u32 = 1; +pub const CSP_SO_NONE: u32 = 0; +pub const CSP_SO_RDPREQ: u32 = 1; +pub const CSP_SO_RDPPROHIB: u32 = 2; +pub const CSP_SO_HMACREQ: u32 = 4; +pub const CSP_SO_HMACPROHIB: u32 = 8; +pub const CSP_SO_CRC32REQ: u32 = 64; +pub const CSP_SO_CRC32PROHIB: u32 = 128; +pub const CSP_SO_CONN_LESS: u32 = 256; +pub const CSP_SO_SAME: u32 = 32768; +pub const CSP_O_NONE: u32 = 0; +pub const CSP_O_RDP: u32 = 1; +pub const CSP_O_NORDP: u32 = 2; +pub const CSP_O_HMAC: u32 = 4; +pub const CSP_O_NOHMAC: u32 = 8; +pub const CSP_O_CRC32: u32 = 64; +pub const CSP_O_NOCRC32: u32 = 128; +pub const CSP_O_SAME: u32 = 32768; +pub const CSP_PACKET_PADDING_BYTES: u32 = 8; +pub const CSP_RDP_HEADER_SIZE: u32 = 5; +pub const CSP_HOSTNAME_LEN: u32 = 20; +pub const CSP_MODEL_LEN: u32 = 30; +pub const CSP_REBOOT_MAGIC: u32 = 2147975175; +pub const CSP_REBOOT_SHUTDOWN_MAGIC: u32 = 3521467034; +pub const CSP_IFLIST_NAME_MAX: u32 = 10; +pub const CSP_NO_VIA_ADDRESS: u32 = 65535; +pub const _STRING_H: u32 = 1; +pub const _BITS_TYPES_LOCALE_T_H: u32 = 1; +pub const _BITS_TYPES___LOCALE_T_H: u32 = 1; +pub const _STRINGS_H: u32 = 1; +pub const CSP_MAX_TIMEOUT: u32 = 4294967295; +pub const CSP_MAX_DELAY: u32 = 4294967295; +pub const CSP_INFINITY: u32 = 4294967295; +pub const CSP_SEMAPHORE_OK: u32 = 0; +pub const CSP_SEMAPHORE_ERROR: i32 = -1; +pub const _SEMAPHORE_H: u32 = 1; +pub const _SYS_TYPES_H: u32 = 1; +pub const __clock_t_defined: u32 = 1; +pub const __clockid_t_defined: u32 = 1; +pub const __time_t_defined: u32 = 1; +pub const __timer_t_defined: u32 = 1; +pub const __BIT_TYPES_DEFINED__: u32 = 1; +pub const _ENDIAN_H: u32 = 1; +pub const _BITS_ENDIAN_H: u32 = 1; +pub const __LITTLE_ENDIAN: u32 = 1234; +pub const __BIG_ENDIAN: u32 = 4321; +pub const __PDP_ENDIAN: u32 = 3412; +pub const _BITS_ENDIANNESS_H: u32 = 1; +pub const __BYTE_ORDER: u32 = 1234; +pub const __FLOAT_WORD_ORDER: u32 = 1234; +pub const LITTLE_ENDIAN: u32 = 1234; +pub const BIG_ENDIAN: u32 = 4321; +pub const PDP_ENDIAN: u32 = 3412; +pub const BYTE_ORDER: u32 = 1234; +pub const _BITS_BYTESWAP_H: u32 = 1; +pub const _BITS_UINTN_IDENTITY_H: u32 = 1; +pub const _SYS_SELECT_H: u32 = 1; +pub const __sigset_t_defined: u32 = 1; +pub const __timeval_defined: u32 = 1; +pub const _STRUCT_TIMESPEC: u32 = 1; +pub const FD_SETSIZE: u32 = 1024; +pub const _BITS_PTHREADTYPES_COMMON_H: u32 = 1; +pub const _THREAD_SHARED_TYPES_H: u32 = 1; +pub const _BITS_PTHREADTYPES_ARCH_H: u32 = 1; +pub const __SIZEOF_PTHREAD_MUTEX_T: u32 = 40; +pub const __SIZEOF_PTHREAD_ATTR_T: u32 = 56; +pub const __SIZEOF_PTHREAD_RWLOCK_T: u32 = 56; +pub const __SIZEOF_PTHREAD_BARRIER_T: u32 = 32; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: u32 = 4; +pub const __SIZEOF_PTHREAD_COND_T: u32 = 48; +pub const __SIZEOF_PTHREAD_CONDATTR_T: u32 = 4; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: u32 = 8; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: u32 = 4; +pub const _THREAD_MUTEX_INTERNAL_H: u32 = 1; +pub const __PTHREAD_MUTEX_HAVE_PREV: u32 = 1; +pub const __have_pthread_attr_t: u32 = 1; +pub const __SIZEOF_SEM_T: u32 = 32; +pub const CSP_RDP_CLOSED_BY_USERSPACE: u32 = 1; +pub const CSP_RDP_CLOSED_BY_PROTOCOL: u32 = 2; +pub const CSP_RDP_CLOSED_BY_TIMEOUT: u32 = 4; +pub const CSP_RDP_CLOSED_BY_ALL: u32 = 7; +pub const CSP_IF_LOOPBACK_NAME: &[u8; 5] = b"LOOP\0"; +pub const _PTHREAD_H: u32 = 1; +pub const _SCHED_H: u32 = 1; +pub const _BITS_SCHED_H: u32 = 1; +pub const SCHED_OTHER: u32 = 0; +pub const SCHED_FIFO: u32 = 1; +pub const SCHED_RR: u32 = 2; +pub const _BITS_TYPES_STRUCT_SCHED_PARAM: u32 = 1; +pub const _BITS_CPU_SET_H: u32 = 1; +pub const __CPU_SETSIZE: u32 = 1024; +pub const _TIME_H: u32 = 1; +pub const _BITS_TIME_H: u32 = 1; +pub const CLOCK_REALTIME: u32 = 0; +pub const CLOCK_MONOTONIC: u32 = 1; +pub const CLOCK_PROCESS_CPUTIME_ID: u32 = 2; +pub const CLOCK_THREAD_CPUTIME_ID: u32 = 3; +pub const CLOCK_MONOTONIC_RAW: u32 = 4; +pub const CLOCK_REALTIME_COARSE: u32 = 5; +pub const CLOCK_MONOTONIC_COARSE: u32 = 6; +pub const CLOCK_BOOTTIME: u32 = 7; +pub const CLOCK_REALTIME_ALARM: u32 = 8; +pub const CLOCK_BOOTTIME_ALARM: u32 = 9; +pub const CLOCK_TAI: u32 = 11; +pub const TIMER_ABSTIME: u32 = 1; +pub const __struct_tm_defined: u32 = 1; +pub const __itimerspec_defined: u32 = 1; +pub const TIME_UTC: u32 = 1; +pub const _BITS_SETJMP_H: u32 = 1; +pub const __jmp_buf_tag_defined: u32 = 1; +pub const PTHREAD_STACK_MIN: u32 = 16384; +pub const PTHREAD_ONCE_INIT: u32 = 0; +pub const PTHREAD_BARRIER_SERIAL_THREAD: i32 = -1; +pub const _NETINET_IN_H: u32 = 1; +pub const _SYS_SOCKET_H: u32 = 1; +pub const __iovec_defined: u32 = 1; +pub const PF_UNSPEC: u32 = 0; +pub const PF_LOCAL: u32 = 1; +pub const PF_UNIX: u32 = 1; +pub const PF_FILE: u32 = 1; +pub const PF_INET: u32 = 2; +pub const PF_AX25: u32 = 3; +pub const PF_IPX: u32 = 4; +pub const PF_APPLETALK: u32 = 5; +pub const PF_NETROM: u32 = 6; +pub const PF_BRIDGE: u32 = 7; +pub const PF_ATMPVC: u32 = 8; +pub const PF_X25: u32 = 9; +pub const PF_INET6: u32 = 10; +pub const PF_ROSE: u32 = 11; +pub const PF_DECnet: u32 = 12; +pub const PF_NETBEUI: u32 = 13; +pub const PF_SECURITY: u32 = 14; +pub const PF_KEY: u32 = 15; +pub const PF_NETLINK: u32 = 16; +pub const PF_ROUTE: u32 = 16; +pub const PF_PACKET: u32 = 17; +pub const PF_ASH: u32 = 18; +pub const PF_ECONET: u32 = 19; +pub const PF_ATMSVC: u32 = 20; +pub const PF_RDS: u32 = 21; +pub const PF_SNA: u32 = 22; +pub const PF_IRDA: u32 = 23; +pub const PF_PPPOX: u32 = 24; +pub const PF_WANPIPE: u32 = 25; +pub const PF_LLC: u32 = 26; +pub const PF_IB: u32 = 27; +pub const PF_MPLS: u32 = 28; +pub const PF_CAN: u32 = 29; +pub const PF_TIPC: u32 = 30; +pub const PF_BLUETOOTH: u32 = 31; +pub const PF_IUCV: u32 = 32; +pub const PF_RXRPC: u32 = 33; +pub const PF_ISDN: u32 = 34; +pub const PF_PHONET: u32 = 35; +pub const PF_IEEE802154: u32 = 36; +pub const PF_CAIF: u32 = 37; +pub const PF_ALG: u32 = 38; +pub const PF_NFC: u32 = 39; +pub const PF_VSOCK: u32 = 40; +pub const PF_KCM: u32 = 41; +pub const PF_QIPCRTR: u32 = 42; +pub const PF_SMC: u32 = 43; +pub const PF_XDP: u32 = 44; +pub const PF_MCTP: u32 = 45; +pub const PF_MAX: u32 = 46; +pub const AF_UNSPEC: u32 = 0; +pub const AF_LOCAL: u32 = 1; +pub const AF_UNIX: u32 = 1; +pub const AF_FILE: u32 = 1; +pub const AF_INET: u32 = 2; +pub const AF_AX25: u32 = 3; +pub const AF_IPX: u32 = 4; +pub const AF_APPLETALK: u32 = 5; +pub const AF_NETROM: u32 = 6; +pub const AF_BRIDGE: u32 = 7; +pub const AF_ATMPVC: u32 = 8; +pub const AF_X25: u32 = 9; +pub const AF_INET6: u32 = 10; +pub const AF_ROSE: u32 = 11; +pub const AF_DECnet: u32 = 12; +pub const AF_NETBEUI: u32 = 13; +pub const AF_SECURITY: u32 = 14; +pub const AF_KEY: u32 = 15; +pub const AF_NETLINK: u32 = 16; +pub const AF_ROUTE: u32 = 16; +pub const AF_PACKET: u32 = 17; +pub const AF_ASH: u32 = 18; +pub const AF_ECONET: u32 = 19; +pub const AF_ATMSVC: u32 = 20; +pub const AF_RDS: u32 = 21; +pub const AF_SNA: u32 = 22; +pub const AF_IRDA: u32 = 23; +pub const AF_PPPOX: u32 = 24; +pub const AF_WANPIPE: u32 = 25; +pub const AF_LLC: u32 = 26; +pub const AF_IB: u32 = 27; +pub const AF_MPLS: u32 = 28; +pub const AF_CAN: u32 = 29; +pub const AF_TIPC: u32 = 30; +pub const AF_BLUETOOTH: u32 = 31; +pub const AF_IUCV: u32 = 32; +pub const AF_RXRPC: u32 = 33; +pub const AF_ISDN: u32 = 34; +pub const AF_PHONET: u32 = 35; +pub const AF_IEEE802154: u32 = 36; +pub const AF_CAIF: u32 = 37; +pub const AF_ALG: u32 = 38; +pub const AF_NFC: u32 = 39; +pub const AF_VSOCK: u32 = 40; +pub const AF_KCM: u32 = 41; +pub const AF_QIPCRTR: u32 = 42; +pub const AF_SMC: u32 = 43; +pub const AF_XDP: u32 = 44; +pub const AF_MCTP: u32 = 45; +pub const AF_MAX: u32 = 46; +pub const SOL_RAW: u32 = 255; +pub const SOL_DECNET: u32 = 261; +pub const SOL_X25: u32 = 262; +pub const SOL_PACKET: u32 = 263; +pub const SOL_ATM: u32 = 264; +pub const SOL_AAL: u32 = 265; +pub const SOL_IRDA: u32 = 266; +pub const SOL_NETBEUI: u32 = 267; +pub const SOL_LLC: u32 = 268; +pub const SOL_DCCP: u32 = 269; +pub const SOL_NETLINK: u32 = 270; +pub const SOL_TIPC: u32 = 271; +pub const SOL_RXRPC: u32 = 272; +pub const SOL_PPPOL2TP: u32 = 273; +pub const SOL_BLUETOOTH: u32 = 274; +pub const SOL_PNPIPE: u32 = 275; +pub const SOL_RDS: u32 = 276; +pub const SOL_IUCV: u32 = 277; +pub const SOL_CAIF: u32 = 278; +pub const SOL_ALG: u32 = 279; +pub const SOL_NFC: u32 = 280; +pub const SOL_KCM: u32 = 281; +pub const SOL_TLS: u32 = 282; +pub const SOL_XDP: u32 = 283; +pub const SOMAXCONN: u32 = 4096; +pub const _BITS_SOCKADDR_H: u32 = 1; +pub const _SS_SIZE: u32 = 128; +pub const __BITS_PER_LONG: u32 = 64; +pub const FIOSETOWN: u32 = 35073; +pub const SIOCSPGRP: u32 = 35074; +pub const FIOGETOWN: u32 = 35075; +pub const SIOCGPGRP: u32 = 35076; +pub const SIOCATMARK: u32 = 35077; +pub const SIOCGSTAMP_OLD: u32 = 35078; +pub const SIOCGSTAMPNS_OLD: u32 = 35079; +pub const SOL_SOCKET: u32 = 1; +pub const SO_DEBUG: u32 = 1; +pub const SO_REUSEADDR: u32 = 2; +pub const SO_TYPE: u32 = 3; +pub const SO_ERROR: u32 = 4; +pub const SO_DONTROUTE: u32 = 5; +pub const SO_BROADCAST: u32 = 6; +pub const SO_SNDBUF: u32 = 7; +pub const SO_RCVBUF: u32 = 8; +pub const SO_SNDBUFFORCE: u32 = 32; +pub const SO_RCVBUFFORCE: u32 = 33; +pub const SO_KEEPALIVE: u32 = 9; +pub const SO_OOBINLINE: u32 = 10; +pub const SO_NO_CHECK: u32 = 11; +pub const SO_PRIORITY: u32 = 12; +pub const SO_LINGER: u32 = 13; +pub const SO_BSDCOMPAT: u32 = 14; +pub const SO_REUSEPORT: u32 = 15; +pub const SO_PASSCRED: u32 = 16; +pub const SO_PEERCRED: u32 = 17; +pub const SO_RCVLOWAT: u32 = 18; +pub const SO_SNDLOWAT: u32 = 19; +pub const SO_RCVTIMEO_OLD: u32 = 20; +pub const SO_SNDTIMEO_OLD: u32 = 21; +pub const SO_SECURITY_AUTHENTICATION: u32 = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: u32 = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: u32 = 24; +pub const SO_BINDTODEVICE: u32 = 25; +pub const SO_ATTACH_FILTER: u32 = 26; +pub const SO_DETACH_FILTER: u32 = 27; +pub const SO_GET_FILTER: u32 = 26; +pub const SO_PEERNAME: u32 = 28; +pub const SO_ACCEPTCONN: u32 = 30; +pub const SO_PEERSEC: u32 = 31; +pub const SO_PASSSEC: u32 = 34; +pub const SO_MARK: u32 = 36; +pub const SO_PROTOCOL: u32 = 38; +pub const SO_DOMAIN: u32 = 39; +pub const SO_RXQ_OVFL: u32 = 40; +pub const SO_WIFI_STATUS: u32 = 41; +pub const SCM_WIFI_STATUS: u32 = 41; +pub const SO_PEEK_OFF: u32 = 42; +pub const SO_NOFCS: u32 = 43; +pub const SO_LOCK_FILTER: u32 = 44; +pub const SO_SELECT_ERR_QUEUE: u32 = 45; +pub const SO_BUSY_POLL: u32 = 46; +pub const SO_MAX_PACING_RATE: u32 = 47; +pub const SO_BPF_EXTENSIONS: u32 = 48; +pub const SO_INCOMING_CPU: u32 = 49; +pub const SO_ATTACH_BPF: u32 = 50; +pub const SO_DETACH_BPF: u32 = 27; +pub const SO_ATTACH_REUSEPORT_CBPF: u32 = 51; +pub const SO_ATTACH_REUSEPORT_EBPF: u32 = 52; +pub const SO_CNX_ADVICE: u32 = 53; +pub const SCM_TIMESTAMPING_OPT_STATS: u32 = 54; +pub const SO_MEMINFO: u32 = 55; +pub const SO_INCOMING_NAPI_ID: u32 = 56; +pub const SO_COOKIE: u32 = 57; +pub const SCM_TIMESTAMPING_PKTINFO: u32 = 58; +pub const SO_PEERGROUPS: u32 = 59; +pub const SO_ZEROCOPY: u32 = 60; +pub const SO_TXTIME: u32 = 61; +pub const SCM_TXTIME: u32 = 61; +pub const SO_BINDTOIFINDEX: u32 = 62; +pub const SO_TIMESTAMP_OLD: u32 = 29; +pub const SO_TIMESTAMPNS_OLD: u32 = 35; +pub const SO_TIMESTAMPING_OLD: u32 = 37; +pub const SO_TIMESTAMP_NEW: u32 = 63; +pub const SO_TIMESTAMPNS_NEW: u32 = 64; +pub const SO_TIMESTAMPING_NEW: u32 = 65; +pub const SO_RCVTIMEO_NEW: u32 = 66; +pub const SO_SNDTIMEO_NEW: u32 = 67; +pub const SO_DETACH_REUSEPORT_BPF: u32 = 68; +pub const SO_PREFER_BUSY_POLL: u32 = 69; +pub const SO_BUSY_POLL_BUDGET: u32 = 70; +pub const SO_NETNS_COOKIE: u32 = 71; +pub const SO_BUF_LOCK: u32 = 72; +pub const SO_TIMESTAMP: u32 = 29; +pub const SO_TIMESTAMPNS: u32 = 35; +pub const SO_TIMESTAMPING: u32 = 37; +pub const SO_RCVTIMEO: u32 = 20; +pub const SO_SNDTIMEO: u32 = 21; +pub const SCM_TIMESTAMP: u32 = 29; +pub const SCM_TIMESTAMPNS: u32 = 35; +pub const SCM_TIMESTAMPING: u32 = 37; +pub const __osockaddr_defined: u32 = 1; +pub const __USE_KERNEL_IPV6_DEFS: u32 = 0; +pub const IP_OPTIONS: u32 = 4; +pub const IP_HDRINCL: u32 = 3; +pub const IP_TOS: u32 = 1; +pub const IP_TTL: u32 = 2; +pub const IP_RECVOPTS: u32 = 6; +pub const IP_RETOPTS: u32 = 7; +pub const IP_MULTICAST_IF: u32 = 32; +pub const IP_MULTICAST_TTL: u32 = 33; +pub const IP_MULTICAST_LOOP: u32 = 34; +pub const IP_ADD_MEMBERSHIP: u32 = 35; +pub const IP_DROP_MEMBERSHIP: u32 = 36; +pub const IP_UNBLOCK_SOURCE: u32 = 37; +pub const IP_BLOCK_SOURCE: u32 = 38; +pub const IP_ADD_SOURCE_MEMBERSHIP: u32 = 39; +pub const IP_DROP_SOURCE_MEMBERSHIP: u32 = 40; +pub const IP_MSFILTER: u32 = 41; +pub const MCAST_JOIN_GROUP: u32 = 42; +pub const MCAST_BLOCK_SOURCE: u32 = 43; +pub const MCAST_UNBLOCK_SOURCE: u32 = 44; +pub const MCAST_LEAVE_GROUP: u32 = 45; +pub const MCAST_JOIN_SOURCE_GROUP: u32 = 46; +pub const MCAST_LEAVE_SOURCE_GROUP: u32 = 47; +pub const MCAST_MSFILTER: u32 = 48; +pub const IP_MULTICAST_ALL: u32 = 49; +pub const IP_UNICAST_IF: u32 = 50; +pub const MCAST_EXCLUDE: u32 = 0; +pub const MCAST_INCLUDE: u32 = 1; +pub const IP_ROUTER_ALERT: u32 = 5; +pub const IP_PKTINFO: u32 = 8; +pub const IP_PKTOPTIONS: u32 = 9; +pub const IP_PMTUDISC: u32 = 10; +pub const IP_MTU_DISCOVER: u32 = 10; +pub const IP_RECVERR: u32 = 11; +pub const IP_RECVTTL: u32 = 12; +pub const IP_RECVTOS: u32 = 13; +pub const IP_MTU: u32 = 14; +pub const IP_FREEBIND: u32 = 15; +pub const IP_IPSEC_POLICY: u32 = 16; +pub const IP_XFRM_POLICY: u32 = 17; +pub const IP_PASSSEC: u32 = 18; +pub const IP_TRANSPARENT: u32 = 19; +pub const IP_ORIGDSTADDR: u32 = 20; +pub const IP_RECVORIGDSTADDR: u32 = 20; +pub const IP_MINTTL: u32 = 21; +pub const IP_NODEFRAG: u32 = 22; +pub const IP_CHECKSUM: u32 = 23; +pub const IP_BIND_ADDRESS_NO_PORT: u32 = 24; +pub const IP_RECVFRAGSIZE: u32 = 25; +pub const IP_RECVERR_RFC4884: u32 = 26; +pub const IP_PMTUDISC_DONT: u32 = 0; +pub const IP_PMTUDISC_WANT: u32 = 1; +pub const IP_PMTUDISC_DO: u32 = 2; +pub const IP_PMTUDISC_PROBE: u32 = 3; +pub const IP_PMTUDISC_INTERFACE: u32 = 4; +pub const IP_PMTUDISC_OMIT: u32 = 5; +pub const SOL_IP: u32 = 0; +pub const IP_DEFAULT_MULTICAST_TTL: u32 = 1; +pub const IP_DEFAULT_MULTICAST_LOOP: u32 = 1; +pub const IP_MAX_MEMBERSHIPS: u32 = 20; +pub const IPV6_ADDRFORM: u32 = 1; +pub const IPV6_2292PKTINFO: u32 = 2; +pub const IPV6_2292HOPOPTS: u32 = 3; +pub const IPV6_2292DSTOPTS: u32 = 4; +pub const IPV6_2292RTHDR: u32 = 5; +pub const IPV6_2292PKTOPTIONS: u32 = 6; +pub const IPV6_CHECKSUM: u32 = 7; +pub const IPV6_2292HOPLIMIT: u32 = 8; +pub const IPV6_NEXTHOP: u32 = 9; +pub const IPV6_AUTHHDR: u32 = 10; +pub const IPV6_UNICAST_HOPS: u32 = 16; +pub const IPV6_MULTICAST_IF: u32 = 17; +pub const IPV6_MULTICAST_HOPS: u32 = 18; +pub const IPV6_MULTICAST_LOOP: u32 = 19; +pub const IPV6_JOIN_GROUP: u32 = 20; +pub const IPV6_LEAVE_GROUP: u32 = 21; +pub const IPV6_ROUTER_ALERT: u32 = 22; +pub const IPV6_MTU_DISCOVER: u32 = 23; +pub const IPV6_MTU: u32 = 24; +pub const IPV6_RECVERR: u32 = 25; +pub const IPV6_V6ONLY: u32 = 26; +pub const IPV6_JOIN_ANYCAST: u32 = 27; +pub const IPV6_LEAVE_ANYCAST: u32 = 28; +pub const IPV6_MULTICAST_ALL: u32 = 29; +pub const IPV6_ROUTER_ALERT_ISOLATE: u32 = 30; +pub const IPV6_RECVERR_RFC4884: u32 = 31; +pub const IPV6_IPSEC_POLICY: u32 = 34; +pub const IPV6_XFRM_POLICY: u32 = 35; +pub const IPV6_HDRINCL: u32 = 36; +pub const IPV6_RECVPKTINFO: u32 = 49; +pub const IPV6_PKTINFO: u32 = 50; +pub const IPV6_RECVHOPLIMIT: u32 = 51; +pub const IPV6_HOPLIMIT: u32 = 52; +pub const IPV6_RECVHOPOPTS: u32 = 53; +pub const IPV6_HOPOPTS: u32 = 54; +pub const IPV6_RTHDRDSTOPTS: u32 = 55; +pub const IPV6_RECVRTHDR: u32 = 56; +pub const IPV6_RTHDR: u32 = 57; +pub const IPV6_RECVDSTOPTS: u32 = 58; +pub const IPV6_DSTOPTS: u32 = 59; +pub const IPV6_RECVPATHMTU: u32 = 60; +pub const IPV6_PATHMTU: u32 = 61; +pub const IPV6_DONTFRAG: u32 = 62; +pub const IPV6_RECVTCLASS: u32 = 66; +pub const IPV6_TCLASS: u32 = 67; +pub const IPV6_AUTOFLOWLABEL: u32 = 70; +pub const IPV6_ADDR_PREFERENCES: u32 = 72; +pub const IPV6_MINHOPCOUNT: u32 = 73; +pub const IPV6_ORIGDSTADDR: u32 = 74; +pub const IPV6_RECVORIGDSTADDR: u32 = 74; +pub const IPV6_TRANSPARENT: u32 = 75; +pub const IPV6_UNICAST_IF: u32 = 76; +pub const IPV6_RECVFRAGSIZE: u32 = 77; +pub const IPV6_FREEBIND: u32 = 78; +pub const IPV6_ADD_MEMBERSHIP: u32 = 20; +pub const IPV6_DROP_MEMBERSHIP: u32 = 21; +pub const IPV6_RXHOPOPTS: u32 = 54; +pub const IPV6_RXDSTOPTS: u32 = 59; +pub const IPV6_PMTUDISC_DONT: u32 = 0; +pub const IPV6_PMTUDISC_WANT: u32 = 1; +pub const IPV6_PMTUDISC_DO: u32 = 2; +pub const IPV6_PMTUDISC_PROBE: u32 = 3; +pub const IPV6_PMTUDISC_INTERFACE: u32 = 4; +pub const IPV6_PMTUDISC_OMIT: u32 = 5; +pub const SOL_IPV6: u32 = 41; +pub const SOL_ICMPV6: u32 = 58; +pub const IPV6_RTHDR_LOOSE: u32 = 0; +pub const IPV6_RTHDR_STRICT: u32 = 1; +pub const IPV6_RTHDR_TYPE_0: u32 = 0; +pub const IN_CLASSA_NET: u32 = 4278190080; +pub const IN_CLASSA_NSHIFT: u32 = 24; +pub const IN_CLASSA_HOST: u32 = 16777215; +pub const IN_CLASSA_MAX: u32 = 128; +pub const IN_CLASSB_NET: u32 = 4294901760; +pub const IN_CLASSB_NSHIFT: u32 = 16; +pub const IN_CLASSB_HOST: u32 = 65535; +pub const IN_CLASSB_MAX: u32 = 65536; +pub const IN_CLASSC_NET: u32 = 4294967040; +pub const IN_CLASSC_NSHIFT: u32 = 8; +pub const IN_CLASSC_HOST: u32 = 255; +pub const IN_LOOPBACKNET: u32 = 127; +pub const INET_ADDRSTRLEN: u32 = 16; +pub const INET6_ADDRSTRLEN: u32 = 46; +pub type __u_char = ::core::ffi::c_uchar; +pub type __u_short = ::core::ffi::c_ushort; +pub type __u_int = ::core::ffi::c_uint; +pub type __u_long = ::core::ffi::c_ulong; +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_long; +pub type __uint64_t = ::core::ffi::c_ulong; +pub type __int_least8_t = __int8_t; +pub type __uint_least8_t = __uint8_t; +pub type __int_least16_t = __int16_t; +pub type __uint_least16_t = __uint16_t; +pub type __int_least32_t = __int32_t; +pub type __uint_least32_t = __uint32_t; +pub type __int_least64_t = __int64_t; +pub type __uint_least64_t = __uint64_t; +pub type __quad_t = ::core::ffi::c_long; +pub type __u_quad_t = ::core::ffi::c_ulong; +pub type __intmax_t = ::core::ffi::c_long; +pub type __uintmax_t = ::core::ffi::c_ulong; +pub type __dev_t = ::core::ffi::c_ulong; +pub type __uid_t = ::core::ffi::c_uint; +pub type __gid_t = ::core::ffi::c_uint; +pub type __ino_t = ::core::ffi::c_ulong; +pub type __ino64_t = ::core::ffi::c_ulong; +pub type __mode_t = ::core::ffi::c_uint; +pub type __nlink_t = ::core::ffi::c_ulong; +pub type __off_t = ::core::ffi::c_long; +pub type __off64_t = ::core::ffi::c_long; +pub type __pid_t = ::core::ffi::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __fsid_t { + pub __val: [::core::ffi::c_int; 2usize], +} +#[test] +fn bindgen_test_layout___fsid_t() { + const UNINIT: ::core::mem::MaybeUninit<__fsid_t> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__fsid_t>(), + 8usize, + concat!("Size of: ", stringify!(__fsid_t)) + ); + assert_eq!( + ::core::mem::align_of::<__fsid_t>(), + 4usize, + concat!("Alignment of ", stringify!(__fsid_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__val) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__fsid_t), + "::", + stringify!(__val) + ) + ); +} +pub type __clock_t = ::core::ffi::c_long; +pub type __rlim_t = ::core::ffi::c_ulong; +pub type __rlim64_t = ::core::ffi::c_ulong; +pub type __id_t = ::core::ffi::c_uint; +pub type __time_t = ::core::ffi::c_long; +pub type __useconds_t = ::core::ffi::c_uint; +pub type __suseconds_t = ::core::ffi::c_long; +pub type __suseconds64_t = ::core::ffi::c_long; +pub type __daddr_t = ::core::ffi::c_int; +pub type __key_t = ::core::ffi::c_int; +pub type __clockid_t = ::core::ffi::c_int; +pub type __timer_t = *mut ::core::ffi::c_void; +pub type __blksize_t = ::core::ffi::c_long; +pub type __blkcnt_t = ::core::ffi::c_long; +pub type __blkcnt64_t = ::core::ffi::c_long; +pub type __fsblkcnt_t = ::core::ffi::c_ulong; +pub type __fsblkcnt64_t = ::core::ffi::c_ulong; +pub type __fsfilcnt_t = ::core::ffi::c_ulong; +pub type __fsfilcnt64_t = ::core::ffi::c_ulong; +pub type __fsword_t = ::core::ffi::c_long; +pub type __ssize_t = ::core::ffi::c_long; +pub type __syscall_slong_t = ::core::ffi::c_long; +pub type __syscall_ulong_t = ::core::ffi::c_ulong; +pub type __loff_t = __off64_t; +pub type __caddr_t = *mut ::core::ffi::c_char; +pub type __intptr_t = ::core::ffi::c_long; +pub type __socklen_t = ::core::ffi::c_uint; +pub type __sig_atomic_t = ::core::ffi::c_int; +pub type int_least8_t = __int_least8_t; +pub type int_least16_t = __int_least16_t; +pub type int_least32_t = __int_least32_t; +pub type int_least64_t = __int_least64_t; +pub type uint_least8_t = __uint_least8_t; +pub type uint_least16_t = __uint_least16_t; +pub type uint_least32_t = __uint_least32_t; +pub type uint_least64_t = __uint_least64_t; +pub type int_fast8_t = ::core::ffi::c_schar; +pub type int_fast16_t = ::core::ffi::c_long; +pub type int_fast32_t = ::core::ffi::c_long; +pub type int_fast64_t = ::core::ffi::c_long; +pub type uint_fast8_t = ::core::ffi::c_uchar; +pub type uint_fast16_t = ::core::ffi::c_ulong; +pub type uint_fast32_t = ::core::ffi::c_ulong; +pub type uint_fast64_t = ::core::ffi::c_ulong; +pub type intmax_t = __intmax_t; +pub type uintmax_t = __uintmax_t; +pub type __gwchar_t = ::core::ffi::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct imaxdiv_t { + pub quot: ::core::ffi::c_long, + pub rem: ::core::ffi::c_long, +} +#[test] +fn bindgen_test_layout_imaxdiv_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(imaxdiv_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(imaxdiv_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).quot) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(imaxdiv_t), + "::", + stringify!(quot) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rem) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(imaxdiv_t), + "::", + stringify!(rem) + ) + ); +} +extern "C" { + pub fn imaxabs(__n: intmax_t) -> intmax_t; +} +extern "C" { + pub fn imaxdiv(__numer: intmax_t, __denom: intmax_t) -> imaxdiv_t; +} +extern "C" { + pub fn strtoimax( + __nptr: *const ::core::ffi::c_char, + __endptr: *mut *mut ::core::ffi::c_char, + __base: ::core::ffi::c_int, + ) -> intmax_t; +} +extern "C" { + pub fn strtoumax( + __nptr: *const ::core::ffi::c_char, + __endptr: *mut *mut ::core::ffi::c_char, + __base: ::core::ffi::c_int, + ) -> uintmax_t; +} +extern "C" { + pub fn wcstoimax( + __nptr: *const __gwchar_t, + __endptr: *mut *mut __gwchar_t, + __base: ::core::ffi::c_int, + ) -> intmax_t; +} +extern "C" { + pub fn wcstoumax( + __nptr: *const __gwchar_t, + __endptr: *mut *mut __gwchar_t, + __base: ::core::ffi::c_int, + ) -> uintmax_t; +} +extern "C" { + #[doc = " Error counters"] + pub static mut csp_dbg_buffer_out: u8; +} +extern "C" { + pub static mut csp_dbg_conn_out: u8; +} +extern "C" { + pub static mut csp_dbg_conn_ovf: u8; +} +extern "C" { + pub static mut csp_dbg_conn_noroute: u8; +} +extern "C" { + pub static mut csp_dbg_inval_reply: u8; +} +extern "C" { + pub static mut csp_dbg_errno: u8; +} +extern "C" { + pub static mut csp_dbg_can_errno: u8; +} +extern "C" { + pub static mut csp_dbg_eth_errno: u8; +} +extern "C" { + pub static mut csp_dbg_rdp_print: u8; +} +extern "C" { + pub static mut csp_dbg_packet_print: u8; +} +extern "C" { + pub fn csp_print_func(fmt: *const ::core::ffi::c_char, ...); +} +pub type wchar_t = ::core::ffi::c_int; +#[repr(C)] +#[repr(align(16))] +#[derive(Debug, 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, +} +#[test] +fn bindgen_test_layout_max_align_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(max_align_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 16usize, + concat!("Alignment of ", stringify!(max_align_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__clang_max_align_nonce1) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(max_align_t), + "::", + stringify!(__clang_max_align_nonce1) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__clang_max_align_nonce2) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(max_align_t), + "::", + stringify!(__clang_max_align_nonce2) + ) + ); +} +pub type csp_queue_handle_t = *mut ::core::ffi::c_void; +pub type csp_static_queue_t = *mut ::core::ffi::c_void; +extern "C" { + pub fn csp_queue_create_static( + length: ::core::ffi::c_int, + item_size: usize, + buffer: *mut ::core::ffi::c_char, + queue: *mut csp_static_queue_t, + ) -> csp_queue_handle_t; +} +extern "C" { + #[doc = " Enqueue (back) value.\n\n @param[in] handle queue.\n @param[in] value value to add (by copy)\n @param[in] timeout timeout, time to wait for free space\n @return #CSP_QUEUE_OK on success, otherwise a queue error code."] + pub fn csp_queue_enqueue( + handle: csp_queue_handle_t, + value: *const ::core::ffi::c_void, + timeout: u32, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Enqueue (back) value from ISR.\n\n @param[in] handle queue.\n @param[in] value value to add (by copy)\n @param[out] pxTaskWoken Valid reference if called from ISR, otherwise NULL!\n @return #CSP_QUEUE_OK on success, otherwise a queue error code."] + pub fn csp_queue_enqueue_isr( + handle: csp_queue_handle_t, + value: *const ::core::ffi::c_void, + pxTaskWoken: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Dequeue value (front).\n\n @param[in] handle queue.\n @param[out] buf extracted element (by copy).\n @param[in] timeout timeout, time to wait for element in queue.\n @return #CSP_QUEUE_OK on success, otherwise a queue error code."] + pub fn csp_queue_dequeue( + handle: csp_queue_handle_t, + buf: *mut ::core::ffi::c_void, + timeout: u32, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Dequeue value (front) from ISR.\n\n @param[in] handle queue.\n @param[out] buf extracted element (by copy).\n @param[out] pxTaskWoken Valid reference if called from ISR, otherwise NULL!\n @return #CSP_QUEUE_OK on success, otherwise a queue error code."] + pub fn csp_queue_dequeue_isr( + handle: csp_queue_handle_t, + buf: *mut ::core::ffi::c_void, + pxTaskWoken: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Queue size.\n\n @param[in] handle handle queue.\n @return Number of elements in the queue."] + pub fn csp_queue_size(handle: csp_queue_handle_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Queue size from ISR.\n\n @param[in] handle handle queue.\n @return Number of elements in the queue."] + pub fn csp_queue_size_isr(handle: csp_queue_handle_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Free queue object (handle).\n\n @param[in] handle handle queue."] + pub fn csp_queue_free(handle: csp_queue_handle_t) -> ::core::ffi::c_int; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_timestamp_t { + pub tv_sec: u32, + pub tv_nsec: u32, +} +#[test] +fn bindgen_test_layout_csp_timestamp_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(csp_timestamp_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(csp_timestamp_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_timestamp_t), + "::", + stringify!(tv_sec) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tv_nsec) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_timestamp_t), + "::", + stringify!(tv_nsec) + ) + ); +} +pub const csp_service_port_t_CSP_CMP: csp_service_port_t = 0; +pub const csp_service_port_t_CSP_PING: csp_service_port_t = 1; +pub const csp_service_port_t_CSP_PS: csp_service_port_t = 2; +pub const csp_service_port_t_CSP_MEMFREE: csp_service_port_t = 3; +pub const csp_service_port_t_CSP_REBOOT: csp_service_port_t = 4; +pub const csp_service_port_t_CSP_BUF_FREE: csp_service_port_t = 5; +pub const csp_service_port_t_CSP_UPTIME: csp_service_port_t = 6; +#[doc = " Reserved ports for CSP services."] +pub type csp_service_port_t = ::core::ffi::c_uint; +#[doc = "!< Critical"] +pub const csp_prio_t_CSP_PRIO_CRITICAL: csp_prio_t = 0; +#[doc = "!< High"] +pub const csp_prio_t_CSP_PRIO_HIGH: csp_prio_t = 1; +#[doc = "!< Normal (default)"] +pub const csp_prio_t_CSP_PRIO_NORM: csp_prio_t = 2; +#[doc = "!< Low"] +pub const csp_prio_t_CSP_PRIO_LOW: csp_prio_t = 3; +#[doc = "Message priority."] +pub type csp_prio_t = ::core::ffi::c_uint; +#[doc = "CSP identifier/header."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __packed { + pub pri: u8, + pub flags: u8, + pub src: u16, + pub dst: u16, + pub dport: u8, + pub sport: u8, +} +#[test] +fn bindgen_test_layout___packed() { + const UNINIT: ::core::mem::MaybeUninit<__packed> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__packed>(), + 8usize, + concat!("Size of: ", stringify!(__packed)) + ); + assert_eq!( + ::core::mem::align_of::<__packed>(), + 2usize, + concat!("Alignment of ", stringify!(__packed)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).pri) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(pri) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).src) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(src) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).dst) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(dst) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).dport) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(dport) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sport) as usize - ptr as usize }, + 7usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(sport) + ) + ); +} +#[doc = "CSP identifier/header."] +pub type csp_id_t = __packed; +#[doc = " CSP Packet.\n\n This structure is constructed to fit with all interface and protocols to prevent the\n need to copy data (zero copy).\n\n .. note:: In most cases a CSP packet cannot be reused in case of send failure, because the\n \t\t\t lower layers may add additional data causing increased length (e.g. CRC32), convert\n \t\t\t the CSP id to different endian (e.g. I2C), etc.\n"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct csp_packet_s { + pub __bindgen_anon_1: csp_packet_s__bindgen_ty_1, + pub length: u16, + pub id: csp_id_t, + pub next: *mut csp_packet_s, + #[doc = " Additional header bytes, to prepend packed data before transmission\n This must be minimum 6 bytes to accomodate CSP 2.0. But some implementations\n require much more scratch working area for encryption for example.\n\n Ultimately after csp_id_pack() this area will be filled with the CSP header"] + pub header: [u8; 8usize], + pub __bindgen_anon_2: csp_packet_s__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union csp_packet_s__bindgen_ty_1 { + pub __bindgen_anon_1: csp_packet_s__bindgen_ty_1__bindgen_ty_1, + pub __bindgen_anon_2: csp_packet_s__bindgen_ty_1__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_packet_s__bindgen_ty_1__bindgen_ty_1 { + pub rdp_quarantine: u32, + pub timestamp_tx: u32, + pub timestamp_rx: u32, + pub conn: *mut csp_conn_s, +} +#[test] +fn bindgen_test_layout_csp_packet_s__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 24usize, + concat!( + "Size of: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rdp_quarantine) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(rdp_quarantine) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).timestamp_tx) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(timestamp_tx) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).timestamp_rx) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(timestamp_rx) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).conn) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(conn) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_packet_s__bindgen_ty_1__bindgen_ty_2 { + pub rx_count: u16, + pub remain: u16, + pub cfpid: u32, + pub last_used: u32, + pub frame_begin: *mut u8, + pub frame_length: u16, +} +#[test] +fn bindgen_test_layout_csp_packet_s__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 32usize, + concat!( + "Size of: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_count) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(rx_count) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).remain) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(remain) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).cfpid) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(cfpid) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).last_used) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(last_used) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).frame_begin) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(frame_begin) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).frame_length) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(frame_length) + ) + ); +} +#[test] +fn bindgen_test_layout_csp_packet_s__bindgen_ty_1() { + assert_eq!( + ::core::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(csp_packet_s__bindgen_ty_1)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_packet_s__bindgen_ty_1)) + ); +} +#[doc = " Data part of packet:"] +#[repr(C)] +#[derive(Copy, Clone)] +pub union csp_packet_s__bindgen_ty_2 { + pub data: [u8; 256usize], + pub data16: [u16; 128usize], + pub data32: [u32; 64usize], +} +#[test] +fn bindgen_test_layout_csp_packet_s__bindgen_ty_2() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 256usize, + concat!("Size of: ", stringify!(csp_packet_s__bindgen_ty_2)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(csp_packet_s__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_2), + "::", + stringify!(data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).data16) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_2), + "::", + stringify!(data16) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).data32) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_2), + "::", + stringify!(data32) + ) + ); +} +#[test] +fn bindgen_test_layout_csp_packet_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 320usize, + concat!("Size of: ", stringify!(csp_packet_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_packet_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(length) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 34usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(id) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(next) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).header) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(header) + ) + ); +} +#[doc = " CSP Packet.\n\n This structure is constructed to fit with all interface and protocols to prevent the\n need to copy data (zero copy).\n\n .. note:: In most cases a CSP packet cannot be reused in case of send failure, because the\n \t\t\t lower layers may add additional data causing increased length (e.g. CRC32), convert\n \t\t\t the CSP id to different endian (e.g. I2C), etc.\n"] +pub type csp_packet_t = csp_packet_s; +#[doc = " Forward declaration of CSP interface, see #csp_iface_s for details."] +pub type csp_iface_t = csp_iface_s; +pub type csp_callback_t = ::core::option::Option; +#[doc = " @brief Connection struct"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_socket_s { + pub rx_queue: csp_queue_handle_t, + pub rx_queue_static: csp_static_queue_t, + pub rx_queue_static_data: [::core::ffi::c_char; 128usize], + pub opts: u32, +} +#[test] +fn bindgen_test_layout_csp_socket_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 152usize, + concat!("Size of: ", stringify!(csp_socket_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_socket_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(rx_queue) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue_static) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(rx_queue_static) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue_static_data) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(rx_queue_static_data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).opts) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(opts) + ) + ); +} +#[doc = " Forward declaration of socket structure"] +pub type csp_socket_t = csp_socket_s; +#[doc = " Forward declaration of connection structure"] +pub type csp_conn_t = csp_conn_s; +#[doc = " Memory pointer"] +pub type csp_memptr_t = *mut ::core::ffi::c_void; +#[doc = " Const memory pointer"] +pub type csp_const_memptr_t = *const ::core::ffi::c_void; +#[doc = " Platform specific memory copy function."] +pub type csp_memcpy_fnc_t = ::core::option::Option< + unsafe extern "C" fn(arg1: csp_memptr_t, arg2: csp_const_memptr_t, arg3: usize) -> csp_memptr_t, +>; +extern "C" { + #[doc = " Get free buffer from task context.\n\n @param[in] unused OBSOLETE ignored field, csp packets have a fixed size now\n @return Buffer pointer to #csp_packet_t or NULL if no buffers available"] + pub fn csp_buffer_get(unused: usize) -> *mut csp_packet_t; +} +extern "C" { + #[doc = " Get free buffer (from ISR context).\n\n @param[in] unused OBSOLETE ignored field, csp packets have a fixed size now\n @return Buffer pointer to #csp_packet_t or NULL if no buffers available"] + pub fn csp_buffer_get_isr(unused: usize) -> *mut csp_packet_t; +} +extern "C" { + #[doc = " Free buffer (from task context).\n\n @param[in] buffer buffer to free. NULL is handled gracefully."] + pub fn csp_buffer_free(buffer: *mut ::core::ffi::c_void); +} +extern "C" { + #[doc = " Free buffer (from ISR context).\n\n @param[in] buffer buffer to free. NULL is handled gracefully."] + pub fn csp_buffer_free_isr(buffer: *mut ::core::ffi::c_void); +} +extern "C" { + #[doc = " Clone an existing buffer.\n The existing \\a buffer content is copied to the new buffer.\n\n @param[in] buffer buffer to clone.\n @return cloned buffer on success, or NULL on failure."] + pub fn csp_buffer_clone(buffer: *mut ::core::ffi::c_void) -> *mut ::core::ffi::c_void; +} +extern "C" { + #[doc = " Return number of remaining/free buffers.\n The number of buffers is set by csp_init().\n\n @return number of remaining/free buffers"] + pub fn csp_buffer_remaining() -> ::core::ffi::c_int; +} +extern "C" { + pub fn csp_buffer_init(); +} +extern "C" { + #[doc = " Increase reference counter of buffer.\n Use csp_buffer_free() to decrement\n @param[in] buffer buffer to increment. NULL is handled gracefully."] + pub fn csp_buffer_refc_inc(buffer: *mut ::core::ffi::c_void); +} +#[doc = " Interface Tx function.\n\n @return #CSP_ERR_NONE on success, otherwise an error code."] +pub type nexthop_t = ::core::option::Option< + unsafe extern "C" fn( + iface: *mut csp_iface_t, + via: u16, + packet: *mut csp_packet_t, + from_me: ::core::ffi::c_int, + ) -> ::core::ffi::c_int, +>; +#[doc = " This struct is referenced in documentation.\n Update doc when you change this."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_iface_s { + #[doc = "< Host address on this subnet"] + pub addr: u16, + #[doc = "< Subnet mask"] + pub netmask: u16, + #[doc = "< Name, max compare length is #CSP_IFLIST_NAME_MAX"] + pub name: *const ::core::ffi::c_char, + #[doc = "< Interface data, only known/used by the interface layer, e.g. state information."] + pub interface_data: *mut ::core::ffi::c_void, + #[doc = "< Driver data, only known/used by the driver layer, e.g. device/channel references."] + pub driver_data: *mut ::core::ffi::c_void, + #[doc = "< Next hop (Tx) function"] + pub nexthop: nexthop_t, + #[doc = "< Set default IF flag (CSP supports multiple defaults)"] + pub is_default: u8, + #[doc = "< Successfully transmitted packets"] + pub tx: u32, + #[doc = "< Successfully received packets"] + pub rx: u32, + #[doc = "< Transmit errors (packets)"] + pub tx_error: u32, + #[doc = "< Receive errors, e.g. too large message"] + pub rx_error: u32, + #[doc = "< Dropped packets"] + pub drop: u32, + #[doc = "< Authentication errors (packets)"] + pub autherr: u32, + #[doc = "< Frame format errors (packets)"] + pub frame: u32, + #[doc = "< Transmitted bytes"] + pub txbytes: u32, + #[doc = "< Received bytes"] + pub rxbytes: u32, + #[doc = "< Interrupts"] + pub irq: u32, + pub next: *mut csp_iface_s, +} +#[test] +fn bindgen_test_layout_csp_iface_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 96usize, + concat!("Size of: ", stringify!(csp_iface_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_iface_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).netmask) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(netmask) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).name) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(name) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).interface_data) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(interface_data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).driver_data) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(driver_data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).nexthop) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(nexthop) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).is_default) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(is_default) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tx) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(tx) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(rx) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tx_error) as usize - ptr as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(tx_error) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_error) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(rx_error) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).drop) as usize - ptr as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(drop) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).autherr) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(autherr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).frame) as usize - ptr as usize }, + 68usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(frame) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).txbytes) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(txbytes) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rxbytes) as usize - ptr as usize }, + 76usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(rxbytes) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).irq) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(irq) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(next) + ) + ); +} +extern "C" { + #[doc = " Inputs a new packet into the system.\n\n This function can be called from interface drivers (ISR) or tasks, to route and accept packets.\n\n .. note:: EXTREMELY IMPORTANT: \\a pxTaskWoken must ALWAYS be NULL if called from task, and ALWAYS\n\t\t\t be NON NULL if called from ISR. If this condition is met, this call is completely thread-safe\n\n This function is fire and forget, it returns void, meaning that the \\a packet will always be\n either accepted or dropped, so the memory will always be freed.\n\n @param[in] packet A pointer to the incoming packet\n @param[in] iface A pointer to the incoming interface TX function.\n @param[in] pxTaskWoken Valid reference if called from ISR, otherwise NULL!\n"] + pub fn csp_qfifo_write( + packet: *mut csp_packet_t, + iface: *mut csp_iface_t, + pxTaskWoken: *mut ::core::ffi::c_void, + ); +} +extern "C" { + #[doc = " Add interface to the list.\n\n @param[in] iface The interface must remain valid as long as the application is running.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_iflist_add(iface: *mut csp_iface_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Remove interface from the list.\n\n @param[in] ifc Interface to remove. NULL will be gracefully handled."] + pub fn csp_iflist_remove(ifc: *mut csp_iface_t); +} +extern "C" { + pub fn csp_iflist_get_by_name(name: *const ::core::ffi::c_char) -> *mut csp_iface_t; +} +extern "C" { + pub fn csp_iflist_get_by_addr(addr: u16) -> *mut csp_iface_t; +} +extern "C" { + pub fn csp_iflist_get_by_subnet(addr: u16, from: *mut csp_iface_t) -> *mut csp_iface_t; +} +extern "C" { + pub fn csp_iflist_get_by_isdfl(ifc: *mut csp_iface_t) -> *mut csp_iface_t; +} +extern "C" { + pub fn csp_iflist_get_by_index(idx: ::core::ffi::c_int) -> *mut csp_iface_t; +} +extern "C" { + pub fn csp_iflist_is_within_subnet(addr: u16, ifc: *mut csp_iface_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn csp_iflist_get() -> *mut csp_iface_t; +} +extern "C" { + #[doc = " Convert bytes to readable string"] + pub fn csp_bytesize( + bytes: ::core::ffi::c_ulong, + postfix: *mut ::core::ffi::c_char, + ) -> ::core::ffi::c_ulong; +} +extern "C" { + #[doc = " Runs over the list of interfaces, and if no default interface is found\n set default on ALL interfaces"] + pub fn csp_iflist_check_dfl(); +} +extern "C" { + pub fn csp_iflist_print(); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_route_s { + pub address: u16, + pub netmask: u16, + pub via: u16, + pub iface: *mut csp_iface_t, +} +#[test] +fn bindgen_test_layout_csp_route_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(csp_route_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_route_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).address) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_route_s), + "::", + stringify!(address) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).netmask) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(csp_route_s), + "::", + stringify!(netmask) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).via) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_route_s), + "::", + stringify!(via) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).iface) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_route_s), + "::", + stringify!(iface) + ) + ); +} +pub type csp_route_t = csp_route_s; +extern "C" { + #[doc = " Loop through routes backwards and find routes that match on addr and mask from start_route"] + pub fn csp_rtable_search_backward(start_route: *mut csp_route_t) -> *mut csp_route_t; +} +extern "C" { + pub fn csp_rtable_find_route(dest_address: u16) -> *mut csp_route_t; +} +extern "C" { + #[doc = " Set route to destination address/node.\n\n @param[in] dest_address destination address.\n @param[in]mask number of bits in netmask (set to -1 for maximum number of bits)\n @param[in] ifc interface.\n @param[in] via assosicated via address.\n @return #CSP_ERR_NONE on success, or an error code."] + pub fn csp_rtable_set( + dest_address: u16, + netmask: ::core::ffi::c_int, + ifc: *mut csp_iface_t, + via: u16, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Save routing table as a string (readable format).\n @see csp_rtable_load() for additional information, e.g. format.\n\n @param[out] buffer user supplied buffer.\n @param[in] buffer_size size of \\a buffer.\n @return #CSP_ERR_NONE on success, or an error code."] + pub fn csp_rtable_save( + buffer: *mut ::core::ffi::c_char, + buffer_size: usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Load routing table from a string.\n Table will be loaded on-top of existing routes, possibly overwriting existing entries.\n Format: \\[/mask] \\ [via][, next entry]\n Example: \"0/0 CAN, 8 KISS, 10 I2C 10\", same as \"0/0 CAN, 8/5 KISS, 10/5 I2C 10\".\n @see csp_rtable_save(), csp_rtable_clear(), csp_rtable_free()\n\n @param[in] rtable routing table (nul terminated)\n @return CSP_ERR or number of entries."] + pub fn csp_rtable_load(rtable: *const ::core::ffi::c_char) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Check string for valid routing elements.\n\n @param[in] rtable routing table (nul terminated)\n @return CSP_ERR or number of entries."] + pub fn csp_rtable_check(rtable: *const ::core::ffi::c_char) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Clear routing table and add loopback route.\n @see csp_rtable_free()"] + pub fn csp_rtable_clear(); +} +extern "C" { + #[doc = " Clear/free all entries in the routing table."] + pub fn csp_rtable_free(); +} +#[doc = " Iterator for looping through the routing table."] +pub type csp_rtable_iterator_t = ::core::option::Option< + unsafe extern "C" fn(ctx: *mut ::core::ffi::c_void, route: *mut csp_route_t) -> bool, +>; +extern "C" { + #[doc = " Iterate routing table."] + pub fn csp_rtable_iterate(iter: csp_rtable_iterator_t, ctx: *mut ::core::ffi::c_void); +} +extern "C" { + #[doc = " Print routing table"] + pub fn csp_rtable_print(); +} +extern "C" { + pub fn memcpy( + __dest: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_void; +} +extern "C" { + pub fn memmove( + __dest: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_void; +} +extern "C" { + pub fn memccpy( + __dest: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_void; +} +extern "C" { + pub fn memset( + __s: *mut ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_void; +} +extern "C" { + pub fn memcmp( + __s1: *const ::core::ffi::c_void, + __s2: *const ::core::ffi::c_void, + __n: ::core::ffi::c_ulong, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn __memcmpeq( + __s1: *const ::core::ffi::c_void, + __s2: *const ::core::ffi::c_void, + __n: usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn memchr( + __s: *const ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_void; +} +extern "C" { + pub fn strcpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strncpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strcat( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strncat( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strcmp( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strncmp( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strcoll( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strxfrm( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> ::core::ffi::c_ulong; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __locale_struct { + pub __locales: [*mut __locale_data; 13usize], + pub __ctype_b: *const ::core::ffi::c_ushort, + pub __ctype_tolower: *const ::core::ffi::c_int, + pub __ctype_toupper: *const ::core::ffi::c_int, + pub __names: [*const ::core::ffi::c_char; 13usize], +} +#[test] +fn bindgen_test_layout___locale_struct() { + const UNINIT: ::core::mem::MaybeUninit<__locale_struct> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__locale_struct>(), + 232usize, + concat!("Size of: ", stringify!(__locale_struct)) + ); + assert_eq!( + ::core::mem::align_of::<__locale_struct>(), + 8usize, + concat!("Alignment of ", stringify!(__locale_struct)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__locales) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__locale_struct), + "::", + stringify!(__locales) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__ctype_b) as usize - ptr as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(__locale_struct), + "::", + stringify!(__ctype_b) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__ctype_tolower) as usize - ptr as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(__locale_struct), + "::", + stringify!(__ctype_tolower) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__ctype_toupper) as usize - ptr as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(__locale_struct), + "::", + stringify!(__ctype_toupper) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__names) as usize - ptr as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(__locale_struct), + "::", + stringify!(__names) + ) + ); +} +pub type __locale_t = *mut __locale_struct; +pub type locale_t = __locale_t; +extern "C" { + pub fn strcoll_l( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + __l: locale_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strxfrm_l( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: usize, + __l: locale_t, + ) -> usize; +} +extern "C" { + pub fn strdup(__s: *const ::core::ffi::c_char) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strndup( + __string: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strchr( + __s: *const ::core::ffi::c_char, + __c: ::core::ffi::c_int, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strrchr( + __s: *const ::core::ffi::c_char, + __c: ::core::ffi::c_int, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strcspn( + __s: *const ::core::ffi::c_char, + __reject: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_ulong; +} +extern "C" { + pub fn strspn( + __s: *const ::core::ffi::c_char, + __accept: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_ulong; +} +extern "C" { + pub fn strpbrk( + __s: *const ::core::ffi::c_char, + __accept: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strstr( + __haystack: *const ::core::ffi::c_char, + __needle: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strtok( + __s: *mut ::core::ffi::c_char, + __delim: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn __strtok_r( + __s: *mut ::core::ffi::c_char, + __delim: *const ::core::ffi::c_char, + __save_ptr: *mut *mut ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strtok_r( + __s: *mut ::core::ffi::c_char, + __delim: *const ::core::ffi::c_char, + __save_ptr: *mut *mut ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strlen(__s: *const ::core::ffi::c_char) -> ::core::ffi::c_ulong; +} +extern "C" { + pub fn strnlen(__string: *const ::core::ffi::c_char, __maxlen: usize) -> usize; +} +extern "C" { + pub fn strerror(__errnum: ::core::ffi::c_int) -> *mut ::core::ffi::c_char; +} +extern "C" { + #[link_name = "\u{1}__xpg_strerror_r"] + pub fn strerror_r( + __errnum: ::core::ffi::c_int, + __buf: *mut ::core::ffi::c_char, + __buflen: usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strerror_l(__errnum: ::core::ffi::c_int, __l: locale_t) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn bcmp( + __s1: *const ::core::ffi::c_void, + __s2: *const ::core::ffi::c_void, + __n: ::core::ffi::c_ulong, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn bcopy(__src: *const ::core::ffi::c_void, __dest: *mut ::core::ffi::c_void, __n: usize); +} +extern "C" { + pub fn bzero(__s: *mut ::core::ffi::c_void, __n: ::core::ffi::c_ulong); +} +extern "C" { + pub fn index( + __s: *const ::core::ffi::c_char, + __c: ::core::ffi::c_int, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn rindex( + __s: *const ::core::ffi::c_char, + __c: ::core::ffi::c_int, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn ffs(__i: ::core::ffi::c_int) -> ::core::ffi::c_int; +} +extern "C" { + pub fn ffsl(__l: ::core::ffi::c_long) -> ::core::ffi::c_int; +} +extern "C" { + pub fn ffsll(__ll: ::core::ffi::c_longlong) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strcasecmp( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strncasecmp( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strcasecmp_l( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + __loc: locale_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strncasecmp_l( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + __n: usize, + __loc: locale_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn explicit_bzero(__s: *mut ::core::ffi::c_void, __n: usize); +} +extern "C" { + pub fn strsep( + __stringp: *mut *mut ::core::ffi::c_char, + __delim: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strsignal(__sig: ::core::ffi::c_int) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn __stpcpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn stpcpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn __stpncpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: usize, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn stpncpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + #[doc = " Send data over a CSP connection.\n\n Data will be send in chunks of \\a mtu bytes. The MTU must be small enough to fit\n into a CSP packat + SFP header + other transport headers.\n\n csp_sfp_recv() or csp_sfp_recv_fp() can be used at the other end to receive data.\n\n This is usefull if you wish to send data stored in flash memory or another location, where standard memcpy() doesn't work.\n\n @param[in] conn established connection for sending SFP packets.\n @param[in] data data to send\n @param[in] datasize tsize of \\a data\n @param[in] mtu maximum transfer unit (bytes), max data chunk to send.\n @param[in] timeout unused as of CSP version 1.6\n @param[in] memcpyfcn memory copy function.\n @return #CSP_ERR_NONE on success, otherwise an error."] + pub fn csp_sfp_send_own_memcpy( + conn: *mut csp_conn_t, + data: *const ::core::ffi::c_void, + datasize: ::core::ffi::c_uint, + mtu: ::core::ffi::c_uint, + timeout: u32, + memcpyfcn: csp_memcpy_fnc_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Receive data over a CSP connection.\n\n This is the counterpart to the csp_sfp_send() and csp_sfp_send_own_memcpy().\n\n @param[in] conn established connection for receiving SFP packets.\n @param[out] dataout received data on success. Allocated with malloc(), so\n \t\t\t should be freed with free(). The pointer will be NULL on failure.\n @param[out] datasize size of received data.\n @param[in] timeout timeout in ms to wait for csp_read()\n @param[in] first_packet First packet of a SFP transfer.\n \t\t\t Use NULL to receive first packet on the connection.\n @return #CSP_ERR_NONE on success, otherwise an error."] + pub fn csp_sfp_recv_fp( + conn: *mut csp_conn_t, + dataout: *mut *mut ::core::ffi::c_void, + datasize: *mut ::core::ffi::c_int, + timeout: u32, + first_packet: *mut csp_packet_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Enable promiscuous packet queue.\n\n @param[in]queue_size: Size (max length) of queue for incoming packets.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_promisc_enable(queue_size: ::core::ffi::c_uint) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Disable promiscuous mode."] + pub fn csp_promisc_disable(); +} +extern "C" { + #[doc = " Get/dequeue packet from promiscuous packet queue.\n\n Returns the first packet from the promiscuous packet queue.\n\n @param[in] timeout Timeout in ms to wait for a packet.\n @return Packet (free with csp_buffer_free() or re-use packet), NULL on error or timeout."] + pub fn csp_promisc_read(timeout: u32) -> *mut csp_packet_t; +} +#[doc = "< Deduplication off"] +pub const csp_dedup_types_CSP_DEDUP_OFF: csp_dedup_types = 0; +#[doc = "< Deduplication on forwarding only"] +pub const csp_dedup_types_CSP_DEDUP_FWD: csp_dedup_types = 1; +#[doc = "< Deduplication on incomfing only"] +pub const csp_dedup_types_CSP_DEDUP_INCOMING: csp_dedup_types = 2; +#[doc = "< Deduplication on incoming and forwarding"] +pub const csp_dedup_types_CSP_DEDUP_ALL: csp_dedup_types = 3; +#[doc = " CSP Debug Types"] +pub type csp_dedup_types = ::core::ffi::c_uint; +#[doc = " CSP configuration."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_conf_s { + #[doc = "< Protocol version to use (either 1 or 2)"] + pub version: u8, + #[doc = "< Host name, returned by the #CSP_CMP_IDENT request"] + pub hostname: *const ::core::ffi::c_char, + #[doc = "< Model, returned by the #CSP_CMP_IDENT request"] + pub model: *const ::core::ffi::c_char, + #[doc = "< Revision, returned by the #CSP_CMP_IDENT request"] + pub revision: *const ::core::ffi::c_char, + #[doc = "< Default connection options. Options will always be or'ed onto new connections, see csp_connect()"] + pub conn_dfl_so: u32, + #[doc = "< Enable CSP deduplication. 0 = off, 1 = always on, 2 = only on forwarded packets,"] + pub dedup: u8, +} +#[test] +fn bindgen_test_layout_csp_conf_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(csp_conf_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_conf_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(version) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).hostname) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(hostname) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).model) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(model) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).revision) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(revision) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).conn_dfl_so) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(conn_dfl_so) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).dedup) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(dedup) + ) + ); +} +#[doc = " CSP configuration."] +pub type csp_conf_t = csp_conf_s; +extern "C" { + pub static mut csp_conf: csp_conf_t; +} +extern "C" { + #[doc = " Initialize CSP.\n This will configure basic structures."] + pub fn csp_init(); +} +extern "C" { + #[doc = " Free allocated resorces in CSP.\n This is intended for testing of CSP, in order to be able re-initialize CSP by calling csp_init() again."] + pub fn csp_free_resources(); +} +extern "C" { + #[doc = " Get a \\a read-only reference to the active CSP configuration.\n\n @return Active CSP configuration (read-only)."] + pub fn csp_get_conf() -> *const csp_conf_t; +} +extern "C" { + #[doc = " Copy csp id fields from source to target object"] + pub fn csp_id_copy(target: *mut csp_id_t, source: *const csp_id_t); +} +extern "C" { + #[doc = " Wait/accept a new connection.\n\n @param[in] socket socket to accept connections on, created by calling csp_socket().\n @param[in] timeout timeout in mS to wait for a connection, use CSP_MAX_TIMEOUT for infinite timeout.\n @return New connection on success, NULL on failure or timeout."] + pub fn csp_accept(socket: *mut csp_socket_t, timeout: u32) -> *mut csp_conn_t; +} +extern "C" { + #[doc = " Read packet from a connection.\n This fuction will wait on the connection's RX queue for the specified timeout.\n\n @param[in] conn connection\n @param[in] timeout timeout in mS to wait for a packet, use CSP_MAX_TIMEOUT for infinite timeout.\n @return Packet or NULL in case of failure or timeout."] + pub fn csp_read(conn: *mut csp_conn_t, timeout: u32) -> *mut csp_packet_t; +} +extern "C" { + #[doc = " Send packet on a connection.\n The packet buffer is automatically freed, and cannot be used after the call to csp_send()\n\n @param[in] conn connection\n @param[in] packet packet to send"] + pub fn csp_send(conn: *mut csp_conn_t, packet: *mut csp_packet_t); +} +extern "C" { + #[doc = " Change the default priority of the connection and send a packet.\n\n .. note:: The priority of the connection will be changed.\n If you need to change it back, call csp_send_prio() again.\n\n @param[in] prio priority to set on the connection\n @param[in] conn connection\n @param[in] packet packet to send"] + pub fn csp_send_prio(prio: u8, conn: *mut csp_conn_t, packet: *mut csp_packet_t); +} +extern "C" { + #[doc = " Perform an entire request & reply transaction.\n Creates a connection, send \\a outbuf, wait for reply, copy reply to \\a inbuf and close the connection.\n\n @param[in] prio priority, see #csp_prio_t\n @param[in] dst destination address\n @param[in] dst_port destination port\n @param[in] timeout timeout in mS to wait for a reply\n @param[in] outbuf outgoing data (request)\n @param[in] outlen length of data in \\a outbuf (request)\n @param[out] inbuf user provided buffer for receiving data (reply)\n @param[in] inlen length of expected reply, -1 for unknown size (inbuf MUST be large enough), 0 for no reply.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n\n Returns:\n int: 1 or reply size on success, 0 on failure (error, incoming length does not match, timeout)"] + pub fn csp_transaction_w_opts( + prio: u8, + dst: u16, + dst_port: u8, + timeout: u32, + outbuf: *const ::core::ffi::c_void, + outlen: ::core::ffi::c_int, + inbuf: *mut ::core::ffi::c_void, + inlen: ::core::ffi::c_int, + opts: u32, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Perform an entire request & reply transaction on an existing connection.\n Send \\a outbuf, wait for reply and copy reply to \\a inbuf.\n\n @param[in] conn connection\n @param[in] timeout timeout in mS to wait for a reply\n @param[in] outbuf outgoing data (request)\n @param[in] outlen length of data in \\a outbuf (request)\n @param[out] inbuf user provided buffer for receiving data (reply)\n @param[in] inlen length of expected reply, -1 for unknown size (inbuf MUST be large enough), 0 for no reply.\n @return 1 or reply size on success, 0 on failure (error, incoming length does not match, timeout)"] + pub fn csp_transaction_persistent( + conn: *mut csp_conn_t, + timeout: u32, + outbuf: *const ::core::ffi::c_void, + outlen: ::core::ffi::c_int, + inbuf: *mut ::core::ffi::c_void, + inlen: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Read data from a connection-less server socket.\n\n @param[in] socket connection-less socket.\n @param[in] timeout timeout in mS to wait for a packet, use #CSP_MAX_TIMEOUT for infinite timeout.\n @return Packet on success, or NULL on failure or timeout."] + pub fn csp_recvfrom(socket: *mut csp_socket_t, timeout: u32) -> *mut csp_packet_t; +} +extern "C" { + #[doc = " Send a packet (without connection).\n\n @param[in] prio packet priority, see #csp_prio_t\n @param[in] dst destination address\n @param[in] dst_port destination port\n @param[in] src_port source port\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n @param[in] packet packet to send"] + pub fn csp_sendto( + prio: u8, + dst: u16, + dst_port: u8, + src_port: u8, + opts: u32, + packet: *mut csp_packet_t, + ); +} +extern "C" { + #[doc = " Send a packet as a reply to a request (without a connection).\n Calls csp_sendto() with the source address and port from the request.\n\n @param[in] request incoming request\n @param[out] reply reply packet\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS."] + pub fn csp_sendto_reply(request: *const csp_packet_t, reply: *mut csp_packet_t, opts: u32); +} +extern "C" { + #[doc = " Establish outgoing connection.\n The call will return immediately, unless it is a RDP connection (#CSP_O_RDP) in which case it will wait until the other\n end acknowleges the connection (timeout is determined by the current connection timeout set by csp_rdp_set_opt()).\n\n @param[in] prio priority, see #csp_prio_t\n @param[in] dst Destination address\n @param[in] dst_port Destination port\n @param[in] timeout unused.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n @return Established connection or NULL on failure (no free connections, timeout)."] + pub fn csp_connect( + prio: u8, + dst: u16, + dst_port: u8, + timeout: u32, + opts: u32, + ) -> *mut csp_conn_t; +} +extern "C" { + #[doc = " Close an open connection.\n Any packets in the RX queue will be freed.\n\n @param[in] conn connection. Closing a NULL connection is acceptable.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_close(conn: *mut csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Close a socket, freeing it's RX queue and unbinding it from the associated\n port.\n\n @param[in] sock Socket\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_socket_close(sock: *mut csp_socket_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Return destination port of connection.\n\n @param[in] conn connection\n @return destination port of an incoming connection"] + pub fn csp_conn_dport(conn: *const csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Return source port of connection.\n\n @param[in] conn connection\n @return source port of an incoming connection"] + pub fn csp_conn_sport(conn: *const csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Return destination address of connection.\n\n @param[in] conn connection\n @return destination address of an incoming connection"] + pub fn csp_conn_dst(conn: *const csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Return source address of connection.\n\n @param[in] conn connection\n @return source address of an incoming connection"] + pub fn csp_conn_src(conn: *const csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Return flags of connection.\n\n @param[in] conn connection\n @return flags of an incoming connection, see @ref CSP_HEADER_FLAGS"] + pub fn csp_conn_flags(conn: *const csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Set socket to listen for incoming connections.\n\n @param[in] socket socket\n @param[in] backlog max length of backlog queue. The backlog queue holds incoming connections, waiting to be returned by call to csp_accept().\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_listen(socket: *mut csp_socket_t, backlog: usize) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Bind port to socket.\n\n @param[in] socket socket to bind port to\n @param[in] port port number to bind, use #CSP_ANY for all ports. Bindnig to a specific will take precedence over #CSP_ANY.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_bind(socket: *mut csp_socket_t, port: u8) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Bind port to callback function.\n\n @param[in] callback pointer to callback function\n @param[in] port port number to bind, use #CSP_ANY for all ports. Bindnig to a specific will take precedence over #CSP_ANY.\n @return 0 on success, otherwise an error code."] + pub fn csp_bind_callback(callback: csp_callback_t, port: u8) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Route packet from the incoming router queue and check RDP timeouts.\n In order for incoming packets to routed and RDP timeouts to be checked, this function must be called reguarly.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_route_work() -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Set the bridge interfaces.\n\n @param[in] if_a CSP Interface `A`\n @param[in] if_b CSP Interface `B`"] + pub fn csp_bridge_set_interfaces(if_a: *mut csp_iface_t, if_b: *mut csp_iface_t); +} +extern "C" { + #[doc = " Bridge packet from an interface to the other."] + pub fn csp_bridge_work(); +} +extern "C" { + #[doc = " Handle CSP service request.\n If the given packet is a service-request (the destination port matches one of CSP service ports #csp_service_port_t),\n the packet will be processed by the specific CSP service handler.\n The packet will either process it or free it, so this function is typically called in the last \"default\" clause of\n a switch/case statement in a CSP listener task.\n In order to listen to csp service ports, bind your listener to the specific services ports #csp_service_port_t or\n use #CSP_ANY to all ports.\n\n @param[in] packet first packet, obtained by using csp_read()"] + pub fn csp_service_handler(packet: *mut csp_packet_t); +} +extern "C" { + #[doc = " Send a single ping/echo packet.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in ms to wait for reply.\n @param[in] size payload size in bytes.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n @return >=0 echo time in mS on success, otherwise -1 for error."] + pub fn csp_ping( + node: u16, + timeout: u32, + size: ::core::ffi::c_uint, + opts: u8, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Send a single ping/echo packet without waiting for reply.\n Payload is 1 byte.\n\n @param[in] node address of subsystem."] + pub fn csp_ping_noreply(node: u16); +} +extern "C" { + #[doc = " Request process list.\n\n .. note:: This is currently only supported on FreeRTOS systems.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for replies. The function will not return until the timeout occurrs."] + pub fn csp_ps(node: u16, timeout: u32); +} +extern "C" { + #[doc = " Request free memory.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] size free memory on subsystem.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_get_memfree(node: u16, timeout: u32, size: *mut u32) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Request free memory and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply."] + pub fn csp_memfree(node: u16, timeout: u32); +} +extern "C" { + #[doc = " Request free buffers.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] size free buffers.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_get_buf_free(node: u16, timeout: u32, size: *mut u32) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Request free buffers and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply."] + pub fn csp_buf_free(node: u16, timeout: u32); +} +extern "C" { + #[doc = " Reboot subsystem.\n If handled by the standard CSP service handler, the reboot handler set by csp_sys_set_reboot() on the subsystem, will be invoked.\n\n @param[in] node address of subsystem.\n"] + pub fn csp_reboot(node: u16); +} +extern "C" { + #[doc = " Shutdown subsystem.\n If handled by the standard CSP service handler, the shutdown handler set by csp_sys_set_shutdown() on the subsystem, will be invoked.\n\n @param[in] node address of subsystem.\n"] + pub fn csp_shutdown(node: u16); +} +extern "C" { + #[doc = " Request uptime and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n"] + pub fn csp_uptime(node: u16, timeout: u32); +} +extern "C" { + #[doc = " Request uptime\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] uptime uptime in seconds.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_get_uptime(node: u16, timeout: u32, uptime: *mut u32) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Set RDP options.\n The RDP options are used from the connecting/client side. When a RDP connection\n is established, the client tranmits the options to the server.\n\n @param[in] window_size window size\n @param[in] conn_timeout_ms connection timeout in mS\n @param[in] packet_timeout_ms packet timeout in mS.\n @param[in] delayed_acks enable/disable delayed acknowledgements.\n @param[in] ack_timeout acknowledgement timeout when delayed ACKs is enabled\n @param[in] ack_delay_count send acknowledgement for every ack_delay_count packets.\n"] + pub fn csp_rdp_set_opt( + window_size: ::core::ffi::c_uint, + conn_timeout_ms: ::core::ffi::c_uint, + packet_timeout_ms: ::core::ffi::c_uint, + delayed_acks: ::core::ffi::c_uint, + ack_timeout: ::core::ffi::c_uint, + ack_delay_count: ::core::ffi::c_uint, + ); +} +extern "C" { + #[doc = " Get RDP options. @see csp_rdp_set_opt()\n\n @param[out] window_size Window size\n @param[out] conn_timeout_ms connection timeout in ms\n @param[out] packet_timeout_ms packet timeout in ms\n @param[out] delayed_acks enable/disable delayed acknowledgements\n @param[out] ack_timeout acknowledgement timeout when delayed ACKs is enabled\n @param[out] ack_delay_count send acknowledgement for every ack_delay_count packets"] + pub fn csp_rdp_get_opt( + window_size: *mut ::core::ffi::c_uint, + conn_timeout_ms: *mut ::core::ffi::c_uint, + packet_timeout_ms: *mut ::core::ffi::c_uint, + delayed_acks: *mut ::core::ffi::c_uint, + ack_timeout: *mut ::core::ffi::c_uint, + ack_delay_count: *mut ::core::ffi::c_uint, + ); +} +extern "C" { + #[doc = " Set platform specific memory copy function."] + pub fn csp_cmp_set_memcpy(fnc: csp_memcpy_fnc_t); +} +extern "C" { + #[doc = " Print connection table to stdout."] + pub fn csp_conn_print_table(); +} +extern "C" { + #[doc = " Hex dump memory to stdout.\n\n @param[in] desc description printed on first line.\n @param[in] addr memory address.\n @param[in] len number of bytes to dump, starting from \\a addr.\n"] + pub fn csp_hex_dump( + desc: *const ::core::ffi::c_char, + addr: *mut ::core::ffi::c_void, + len: ::core::ffi::c_int, + ); +} +extern "C" { + #[doc = " Print connection table to string."] + pub fn csp_conn_print_table_str( + str_buf: *mut ::core::ffi::c_char, + str_size: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn csp_output_hook( + idout: *mut csp_id_t, + packet: *mut csp_packet_t, + iface: *mut csp_iface_t, + via: u16, + from_me: ::core::ffi::c_int, + ); +} +extern "C" { + pub fn csp_input_hook(iface: *mut csp_iface_t, packet: *mut csp_packet_t); +} +extern "C" { + pub fn csp_reboot_hook(); +} +extern "C" { + pub fn csp_shutdown_hook(); +} +extern "C" { + pub fn csp_memfree_hook() -> u32; +} +extern "C" { + pub fn csp_ps_hook(packet: *mut csp_packet_t) -> ::core::ffi::c_uint; +} +extern "C" { + #[doc = " Implement these, if you use csp_if_tun"] + pub fn csp_crypto_decrypt( + ciphertext_in: *mut u8, + ciphertext_len: u8, + msg_out: *mut u8, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn csp_crypto_encrypt( + msg_begin: *mut u8, + msg_len: u8, + ciphertext_out: *mut u8, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn csp_clock_get_time(time: *mut csp_timestamp_t); +} +extern "C" { + pub fn csp_clock_set_time(time: *const csp_timestamp_t) -> ::core::ffi::c_int; +} +pub const memory_order_memory_order_relaxed: memory_order = 0; +pub const memory_order_memory_order_consume: memory_order = 1; +pub const memory_order_memory_order_acquire: memory_order = 2; +pub const memory_order_memory_order_release: memory_order = 3; +pub const memory_order_memory_order_acq_rel: memory_order = 4; +pub const memory_order_memory_order_seq_cst: memory_order = 5; +pub type memory_order = ::core::ffi::c_uint; +extern "C" { + pub fn atomic_thread_fence(arg1: memory_order); +} +extern "C" { + pub fn atomic_signal_fence(arg1: memory_order); +} +pub type atomic_bool = u8; +pub type atomic_char = u8; +pub type atomic_schar = u8; +pub type atomic_uchar = u8; +pub type atomic_short = u16; +pub type atomic_ushort = u16; +pub type atomic_int = u32; +pub type atomic_uint = u32; +pub type atomic_long = u64; +pub type atomic_ulong = u64; +pub type atomic_llong = u64; +pub type atomic_ullong = u64; +pub type atomic_char16_t = u16; +pub type atomic_char32_t = u32; +pub type atomic_wchar_t = u32; +pub type atomic_int_least8_t = u8; +pub type atomic_uint_least8_t = u8; +pub type atomic_int_least16_t = u16; +pub type atomic_uint_least16_t = u16; +pub type atomic_int_least32_t = u32; +pub type atomic_uint_least32_t = u32; +pub type atomic_int_least64_t = u64; +pub type atomic_uint_least64_t = u64; +pub type atomic_int_fast8_t = u8; +pub type atomic_uint_fast8_t = u8; +pub type atomic_int_fast16_t = u64; +pub type atomic_uint_fast16_t = u64; +pub type atomic_int_fast32_t = u64; +pub type atomic_uint_fast32_t = u64; +pub type atomic_int_fast64_t = u64; +pub type atomic_uint_fast64_t = u64; +pub type atomic_intptr_t = u64; +pub type atomic_uintptr_t = u64; +pub type atomic_size_t = u64; +pub type atomic_ptrdiff_t = u64; +pub type atomic_intmax_t = u64; +pub type atomic_uintmax_t = u64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct atomic_flag { + pub _Value: atomic_bool, +} +#[test] +fn bindgen_test_layout_atomic_flag() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(atomic_flag)) + ); + assert_eq!( + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(atomic_flag)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr)._Value) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(atomic_flag), + "::", + stringify!(_Value) + ) + ); +} +extern "C" { + pub fn atomic_flag_test_and_set(arg1: *mut atomic_flag) -> bool; +} +extern "C" { + pub fn atomic_flag_test_and_set_explicit(arg1: *mut atomic_flag, arg2: memory_order) -> bool; +} +extern "C" { + pub fn atomic_flag_clear(arg1: *mut atomic_flag); +} +extern "C" { + pub fn atomic_flag_clear_explicit(arg1: *mut atomic_flag, arg2: memory_order); +} +pub type u_char = __u_char; +pub type u_short = __u_short; +pub type u_int = __u_int; +pub type u_long = __u_long; +pub type quad_t = __quad_t; +pub type u_quad_t = __u_quad_t; +pub type fsid_t = __fsid_t; +pub type loff_t = __loff_t; +pub type ino_t = __ino_t; +pub type dev_t = __dev_t; +pub type gid_t = __gid_t; +pub type mode_t = __mode_t; +pub type nlink_t = __nlink_t; +pub type uid_t = __uid_t; +pub type off_t = __off_t; +pub type pid_t = __pid_t; +pub type id_t = __id_t; +pub type daddr_t = __daddr_t; +pub type caddr_t = __caddr_t; +pub type key_t = __key_t; +pub type clock_t = __clock_t; +pub type clockid_t = __clockid_t; +pub type time_t = __time_t; +pub type timer_t = __timer_t; +pub type ulong = ::core::ffi::c_ulong; +pub type ushort = ::core::ffi::c_ushort; +pub type uint = ::core::ffi::c_uint; +pub type u_int8_t = __uint8_t; +pub type u_int16_t = __uint16_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; +pub type register_t = ::core::ffi::c_long; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __sigset_t { + pub __val: [::core::ffi::c_ulong; 16usize], +} +#[test] +fn bindgen_test_layout___sigset_t() { + const UNINIT: ::core::mem::MaybeUninit<__sigset_t> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__sigset_t>(), + 128usize, + concat!("Size of: ", stringify!(__sigset_t)) + ); + assert_eq!( + ::core::mem::align_of::<__sigset_t>(), + 8usize, + concat!("Alignment of ", stringify!(__sigset_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__val) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__sigset_t), + "::", + stringify!(__val) + ) + ); +} +pub type sigset_t = __sigset_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct timeval { + pub tv_sec: __time_t, + pub tv_usec: __suseconds_t, +} +#[test] +fn bindgen_test_layout_timeval() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(timeval)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(timeval)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(timeval), + "::", + stringify!(tv_sec) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tv_usec) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(timeval), + "::", + stringify!(tv_usec) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct timespec { + pub tv_sec: __time_t, + pub tv_nsec: __syscall_slong_t, +} +#[test] +fn bindgen_test_layout_timespec() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(timespec)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(timespec)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(timespec), + "::", + stringify!(tv_sec) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tv_nsec) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(timespec), + "::", + stringify!(tv_nsec) + ) + ); +} +pub type suseconds_t = __suseconds_t; +pub type __fd_mask = ::core::ffi::c_long; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct fd_set { + pub __fds_bits: [__fd_mask; 16usize], +} +#[test] +fn bindgen_test_layout_fd_set() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 128usize, + concat!("Size of: ", stringify!(fd_set)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(fd_set)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__fds_bits) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(fd_set), + "::", + stringify!(__fds_bits) + ) + ); +} +pub type fd_mask = __fd_mask; +extern "C" { + pub fn select( + __nfds: ::core::ffi::c_int, + __readfds: *mut fd_set, + __writefds: *mut fd_set, + __exceptfds: *mut fd_set, + __timeout: *mut timeval, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pselect( + __nfds: ::core::ffi::c_int, + __readfds: *mut fd_set, + __writefds: *mut fd_set, + __exceptfds: *mut fd_set, + __timeout: *const timespec, + __sigmask: *const __sigset_t, + ) -> ::core::ffi::c_int; +} +pub type blksize_t = __blksize_t; +pub type blkcnt_t = __blkcnt_t; +pub type fsblkcnt_t = __fsblkcnt_t; +pub type fsfilcnt_t = __fsfilcnt_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __atomic_wide_counter { + pub __value64: ::core::ffi::c_ulonglong, + pub __value32: __atomic_wide_counter__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __atomic_wide_counter__bindgen_ty_1 { + pub __low: ::core::ffi::c_uint, + pub __high: ::core::ffi::c_uint, +} +#[test] +fn bindgen_test_layout___atomic_wide_counter__bindgen_ty_1() { + const UNINIT: ::core::mem::MaybeUninit<__atomic_wide_counter__bindgen_ty_1> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__atomic_wide_counter__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(__atomic_wide_counter__bindgen_ty_1)) + ); + assert_eq!( + ::core::mem::align_of::<__atomic_wide_counter__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(__atomic_wide_counter__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__low) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__atomic_wide_counter__bindgen_ty_1), + "::", + stringify!(__low) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__high) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__atomic_wide_counter__bindgen_ty_1), + "::", + stringify!(__high) + ) + ); +} +#[test] +fn bindgen_test_layout___atomic_wide_counter() { + const UNINIT: ::core::mem::MaybeUninit<__atomic_wide_counter> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__atomic_wide_counter>(), + 8usize, + concat!("Size of: ", stringify!(__atomic_wide_counter)) + ); + assert_eq!( + ::core::mem::align_of::<__atomic_wide_counter>(), + 8usize, + concat!("Alignment of ", stringify!(__atomic_wide_counter)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__value64) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__atomic_wide_counter), + "::", + stringify!(__value64) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__value32) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__atomic_wide_counter), + "::", + stringify!(__value32) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +#[test] +fn bindgen_test_layout___pthread_internal_list() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_internal_list> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__pthread_internal_list>(), + 16usize, + concat!("Size of: ", stringify!(__pthread_internal_list)) + ); + assert_eq!( + ::core::mem::align_of::<__pthread_internal_list>(), + 8usize, + concat!("Alignment of ", stringify!(__pthread_internal_list)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__prev) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__pthread_internal_list), + "::", + stringify!(__prev) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__next) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(__pthread_internal_list), + "::", + stringify!(__next) + ) + ); +} +pub type __pthread_list_t = __pthread_internal_list; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_internal_slist { + pub __next: *mut __pthread_internal_slist, +} +#[test] +fn bindgen_test_layout___pthread_internal_slist() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_internal_slist> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__pthread_internal_slist>(), + 8usize, + concat!("Size of: ", stringify!(__pthread_internal_slist)) + ); + assert_eq!( + ::core::mem::align_of::<__pthread_internal_slist>(), + 8usize, + concat!("Alignment of ", stringify!(__pthread_internal_slist)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__pthread_internal_slist), + "::", + stringify!(__next) + ) + ); +} +pub type __pthread_slist_t = __pthread_internal_slist; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_mutex_s { + pub __lock: ::core::ffi::c_int, + pub __count: ::core::ffi::c_uint, + pub __owner: ::core::ffi::c_int, + pub __nusers: ::core::ffi::c_uint, + pub __kind: ::core::ffi::c_int, + pub __spins: ::core::ffi::c_short, + pub __elision: ::core::ffi::c_short, + pub __list: __pthread_list_t, +} +#[test] +fn bindgen_test_layout___pthread_mutex_s() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_mutex_s> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__pthread_mutex_s>(), + 40usize, + concat!("Size of: ", stringify!(__pthread_mutex_s)) + ); + assert_eq!( + ::core::mem::align_of::<__pthread_mutex_s>(), + 8usize, + concat!("Alignment of ", stringify!(__pthread_mutex_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__lock) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__pthread_mutex_s), + "::", + stringify!(__lock) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__count) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__pthread_mutex_s), + "::", + stringify!(__count) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__owner) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(__pthread_mutex_s), + "::", + stringify!(__owner) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__nusers) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(__pthread_mutex_s), + "::", + stringify!(__nusers) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__kind) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(__pthread_mutex_s), + "::", + stringify!(__kind) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__spins) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(__pthread_mutex_s), + "::", + stringify!(__spins) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__elision) as usize - ptr as usize }, + 22usize, + concat!( + "Offset of field: ", + stringify!(__pthread_mutex_s), + "::", + stringify!(__elision) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__list) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(__pthread_mutex_s), + "::", + stringify!(__list) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_rwlock_arch_t { + pub __readers: ::core::ffi::c_uint, + pub __writers: ::core::ffi::c_uint, + pub __wrphase_futex: ::core::ffi::c_uint, + pub __writers_futex: ::core::ffi::c_uint, + pub __pad3: ::core::ffi::c_uint, + pub __pad4: ::core::ffi::c_uint, + pub __cur_writer: ::core::ffi::c_int, + pub __shared: ::core::ffi::c_int, + pub __rwelision: ::core::ffi::c_schar, + pub __pad1: [::core::ffi::c_uchar; 7usize], + pub __pad2: ::core::ffi::c_ulong, + pub __flags: ::core::ffi::c_uint, +} +#[test] +fn bindgen_test_layout___pthread_rwlock_arch_t() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_rwlock_arch_t> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__pthread_rwlock_arch_t>(), + 56usize, + concat!("Size of: ", stringify!(__pthread_rwlock_arch_t)) + ); + assert_eq!( + ::core::mem::align_of::<__pthread_rwlock_arch_t>(), + 8usize, + concat!("Alignment of ", stringify!(__pthread_rwlock_arch_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__readers) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__readers) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__writers) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__writers) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__wrphase_futex) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__wrphase_futex) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__writers_futex) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__writers_futex) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__pad3) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__pad3) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__pad4) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__pad4) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__cur_writer) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__cur_writer) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__shared) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__shared) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__rwelision) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__rwelision) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__pad1) as usize - ptr as usize }, + 33usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__pad1) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__pad2) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__pad2) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__flags) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(__pthread_rwlock_arch_t), + "::", + stringify!(__flags) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct __pthread_cond_s { + pub __wseq: __atomic_wide_counter, + pub __g1_start: __atomic_wide_counter, + pub __g_refs: [::core::ffi::c_uint; 2usize], + pub __g_size: [::core::ffi::c_uint; 2usize], + pub __g1_orig_size: ::core::ffi::c_uint, + pub __wrefs: ::core::ffi::c_uint, + pub __g_signals: [::core::ffi::c_uint; 2usize], +} +#[test] +fn bindgen_test_layout___pthread_cond_s() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_cond_s> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__pthread_cond_s>(), + 48usize, + concat!("Size of: ", stringify!(__pthread_cond_s)) + ); + assert_eq!( + ::core::mem::align_of::<__pthread_cond_s>(), + 8usize, + concat!("Alignment of ", stringify!(__pthread_cond_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__wseq) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s), + "::", + stringify!(__wseq) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__g1_start) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s), + "::", + stringify!(__g1_start) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__g_refs) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s), + "::", + stringify!(__g_refs) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__g_size) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s), + "::", + stringify!(__g_size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__g1_orig_size) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s), + "::", + stringify!(__g1_orig_size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__wrefs) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s), + "::", + stringify!(__wrefs) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__g_signals) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cond_s), + "::", + stringify!(__g_signals) + ) + ); +} +pub type __tss_t = ::core::ffi::c_uint; +pub type __thrd_t = ::core::ffi::c_ulong; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __once_flag { + pub __data: ::core::ffi::c_int, +} +#[test] +fn bindgen_test_layout___once_flag() { + const UNINIT: ::core::mem::MaybeUninit<__once_flag> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__once_flag>(), + 4usize, + concat!("Size of: ", stringify!(__once_flag)) + ); + assert_eq!( + ::core::mem::align_of::<__once_flag>(), + 4usize, + concat!("Alignment of ", stringify!(__once_flag)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__data) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__once_flag), + "::", + stringify!(__data) + ) + ); +} +pub type pthread_t = ::core::ffi::c_ulong; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_mutexattr_t { + pub __size: [::core::ffi::c_char; 4usize], + pub __align: ::core::ffi::c_int, +} +#[test] +fn bindgen_test_layout_pthread_mutexattr_t() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(pthread_mutexattr_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pthread_mutexattr_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_mutexattr_t), + "::", + stringify!(__size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__align) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_mutexattr_t), + "::", + stringify!(__align) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_condattr_t { + pub __size: [::core::ffi::c_char; 4usize], + pub __align: ::core::ffi::c_int, +} +#[test] +fn bindgen_test_layout_pthread_condattr_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(pthread_condattr_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pthread_condattr_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_condattr_t), + "::", + stringify!(__size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__align) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_condattr_t), + "::", + stringify!(__align) + ) + ); +} +pub type pthread_key_t = ::core::ffi::c_uint; +pub type pthread_once_t = ::core::ffi::c_int; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_attr_t { + pub __size: [::core::ffi::c_char; 56usize], + pub __align: ::core::ffi::c_long, +} +#[test] +fn bindgen_test_layout_pthread_attr_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(pthread_attr_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pthread_attr_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_attr_t), + "::", + stringify!(__size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__align) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_attr_t), + "::", + stringify!(__align) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [::core::ffi::c_char; 40usize], + pub __align: ::core::ffi::c_long, +} +#[test] +fn bindgen_test_layout_pthread_mutex_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(pthread_mutex_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pthread_mutex_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__data) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_mutex_t), + "::", + stringify!(__data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_mutex_t), + "::", + stringify!(__size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__align) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_mutex_t), + "::", + stringify!(__align) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_cond_t { + pub __data: __pthread_cond_s, + pub __size: [::core::ffi::c_char; 48usize], + pub __align: ::core::ffi::c_longlong, +} +#[test] +fn bindgen_test_layout_pthread_cond_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(pthread_cond_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pthread_cond_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__data) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_cond_t), + "::", + stringify!(__data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_cond_t), + "::", + stringify!(__size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__align) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_cond_t), + "::", + stringify!(__align) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_rwlock_t { + pub __data: __pthread_rwlock_arch_t, + pub __size: [::core::ffi::c_char; 56usize], + pub __align: ::core::ffi::c_long, +} +#[test] +fn bindgen_test_layout_pthread_rwlock_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(pthread_rwlock_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pthread_rwlock_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__data) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_rwlock_t), + "::", + stringify!(__data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_rwlock_t), + "::", + stringify!(__size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__align) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_rwlock_t), + "::", + stringify!(__align) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_rwlockattr_t { + pub __size: [::core::ffi::c_char; 8usize], + pub __align: ::core::ffi::c_long, +} +#[test] +fn bindgen_test_layout_pthread_rwlockattr_t() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pthread_rwlockattr_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pthread_rwlockattr_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_rwlockattr_t), + "::", + stringify!(__size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__align) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_rwlockattr_t), + "::", + stringify!(__align) + ) + ); +} +pub type pthread_spinlock_t = ::core::ffi::c_int; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_barrier_t { + pub __size: [::core::ffi::c_char; 32usize], + pub __align: ::core::ffi::c_long, +} +#[test] +fn bindgen_test_layout_pthread_barrier_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(pthread_barrier_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pthread_barrier_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_barrier_t), + "::", + stringify!(__size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__align) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_barrier_t), + "::", + stringify!(__align) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_barrierattr_t { + pub __size: [::core::ffi::c_char; 4usize], + pub __align: ::core::ffi::c_int, +} +#[test] +fn bindgen_test_layout_pthread_barrierattr_t() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(pthread_barrierattr_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pthread_barrierattr_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_barrierattr_t), + "::", + stringify!(__size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__align) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_barrierattr_t), + "::", + stringify!(__align) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sem_t { + pub __size: [::core::ffi::c_char; 32usize], + pub __align: ::core::ffi::c_long, +} +#[test] +fn bindgen_test_layout_sem_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(sem_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(sem_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sem_t), + "::", + stringify!(__size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__align) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sem_t), + "::", + stringify!(__align) + ) + ); +} +extern "C" { + pub fn sem_init( + __sem: *mut sem_t, + __pshared: ::core::ffi::c_int, + __value: ::core::ffi::c_uint, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sem_destroy(__sem: *mut sem_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sem_open( + __name: *const ::core::ffi::c_char, + __oflag: ::core::ffi::c_int, + ... + ) -> *mut sem_t; +} +extern "C" { + pub fn sem_close(__sem: *mut sem_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sem_unlink(__name: *const ::core::ffi::c_char) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sem_wait(__sem: *mut sem_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sem_timedwait(__sem: *mut sem_t, __abstime: *const timespec) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sem_trywait(__sem: *mut sem_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sem_post(__sem: *mut sem_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sem_getvalue(__sem: *mut sem_t, __sval: *mut ::core::ffi::c_int) -> ::core::ffi::c_int; +} +pub type csp_bin_sem_t = sem_t; +extern "C" { + #[doc = " initialize a binary semaphore with static storage\n The semaphore is created in state \\a unlocked (value 1).\n On platforms supporting max values, the semaphore is created with a max value of 1, hence the naming \\a binary."] + pub fn csp_bin_sem_init(sem: *mut csp_bin_sem_t); +} +extern "C" { + #[doc = " Wait/lock semaphore\n @param[in] timeout timeout in mS. Use #CSP_MAX_TIMEOUT for no timeout, e.g. wait forever until locked.\n @return #CSP_SEMAPHORE_OK on success, otherwise #CSP_SEMAPHORE_ERROR"] + pub fn csp_bin_sem_wait( + sem: *mut csp_bin_sem_t, + timeout: ::core::ffi::c_uint, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Signal/unlock semaphore\n @return #CSP_SEMAPHORE_OK on success, otherwise #CSP_SEMAPHORE_ERROR"] + pub fn csp_bin_sem_post(sem: *mut csp_bin_sem_t) -> ::core::ffi::c_int; +} +pub const csp_conn_state_t_CONN_CLOSED: csp_conn_state_t = 0; +pub const csp_conn_state_t_CONN_OPEN: csp_conn_state_t = 1; +#[doc = " Connection states"] +pub type csp_conn_state_t = ::core::ffi::c_uint; +pub const csp_conn_type_t_CONN_CLIENT: csp_conn_type_t = 0; +pub const csp_conn_type_t_CONN_SERVER: csp_conn_type_t = 1; +#[doc = " Connection types"] +pub type csp_conn_type_t = ::core::ffi::c_uint; +pub const csp_rdp_state_t_RDP_CLOSED: csp_rdp_state_t = 0; +pub const csp_rdp_state_t_RDP_SYN_SENT: csp_rdp_state_t = 1; +pub const csp_rdp_state_t_RDP_SYN_RCVD: csp_rdp_state_t = 2; +pub const csp_rdp_state_t_RDP_OPEN: csp_rdp_state_t = 3; +pub const csp_rdp_state_t_RDP_CLOSE_WAIT: csp_rdp_state_t = 4; +#[doc = " RDP Connection states"] +pub type csp_rdp_state_t = ::core::ffi::c_uint; +#[doc = " RDP Connection"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct csp_rdp_t { + #[doc = "< Connection state"] + pub state: csp_rdp_state_t, + #[doc = "< Tracks 'who' have closed the RDP connection"] + pub closed_by: u8, + #[doc = "< The sequence number of the next segment that is to be sent"] + pub snd_nxt: u16, + #[doc = "< The sequence number of the oldest unacknowledged segment"] + pub snd_una: u16, + #[doc = "< The initial send sequence number"] + pub snd_iss: u16, + #[doc = "< The sequence number of the last segment received correctly and in sequence"] + pub rcv_cur: u16, + #[doc = "< The initial receive sequence number"] + pub rcv_irs: u16, + #[doc = "< The last sequence number acknowledged by the receiver"] + pub rcv_lsa: u16, + pub window_size: u32, + pub conn_timeout: u32, + pub packet_timeout: u32, + pub delayed_acks: u32, + pub ack_timeout: u32, + pub ack_delay_count: u32, + pub ack_timestamp: u32, + pub tx_wait: csp_bin_sem_t, +} +#[test] +fn bindgen_test_layout_csp_rdp_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 80usize, + concat!("Size of: ", stringify!(csp_rdp_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_rdp_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(state) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).closed_by) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(closed_by) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).snd_nxt) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(snd_nxt) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).snd_una) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(snd_una) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).snd_iss) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(snd_iss) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rcv_cur) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(rcv_cur) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rcv_irs) as usize - ptr as usize }, + 14usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(rcv_irs) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rcv_lsa) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(rcv_lsa) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).window_size) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(window_size) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).conn_timeout) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(conn_timeout) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).packet_timeout) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(packet_timeout) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).delayed_acks) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(delayed_acks) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ack_timeout) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(ack_timeout) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ack_delay_count) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(ack_delay_count) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ack_timestamp) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(ack_timestamp) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tx_wait) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(csp_rdp_t), + "::", + stringify!(tx_wait) + ) + ); +} +#[doc = " @brief Connection struct"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct csp_conn_s { + pub type_: atomic_int, + pub state: atomic_int, + pub idin: csp_id_t, + pub idout: csp_id_t, + pub sport_outgoing: u8, + pub rx_queue: csp_queue_handle_t, + pub rx_queue_static: csp_static_queue_t, + pub rx_queue_static_data: [::core::ffi::c_char; 128usize], + pub callback: ::core::option::Option, + pub dest_socket: *mut csp_socket_t, + pub timestamp: u32, + pub opts: u32, + pub rdp: csp_rdp_t, +} +#[test] +fn bindgen_test_layout_csp_conn_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 280usize, + concat!("Size of: ", stringify!(csp_conn_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_conn_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(state) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).idin) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(idin) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).idout) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(idout) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sport_outgoing) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(sport_outgoing) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(rx_queue) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue_static) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(rx_queue_static) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue_static_data) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(rx_queue_static_data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).callback) as usize - ptr as usize }, + 176usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(callback) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).dest_socket) as usize - ptr as usize }, + 184usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(dest_socket) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).timestamp) as usize - ptr as usize }, + 192usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(timestamp) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).opts) as usize - ptr as usize }, + 196usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(opts) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rdp) as usize - ptr as usize }, + 200usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(rdp) + ) + ); +} +extern "C" { + pub fn csp_conn_enqueue_packet( + conn: *mut csp_conn_t, + packet: *mut csp_packet_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn csp_conn_init(); +} +extern "C" { + pub fn csp_conn_allocate(type_: csp_conn_type_t) -> *mut csp_conn_t; +} +extern "C" { + pub fn csp_conn_find_existing(id: *mut csp_id_t) -> *mut csp_conn_t; +} +extern "C" { + pub fn csp_conn_find_dport(dport: ::core::ffi::c_uint) -> *mut csp_conn_t; +} +extern "C" { + pub fn csp_conn_new(idin: csp_id_t, idout: csp_id_t, type_: csp_conn_type_t) + -> *mut csp_conn_t; +} +extern "C" { + pub fn csp_conn_check_timeouts(); +} +extern "C" { + pub fn csp_conn_get_rxq(prio: ::core::ffi::c_int) -> ::core::ffi::c_int; +} +extern "C" { + pub fn csp_conn_close(conn: *mut csp_conn_t, closed_by: u8) -> ::core::ffi::c_int; +} +extern "C" { + pub fn csp_conn_get_array(size: *mut usize) -> *const csp_conn_t; +} +extern "C" { + #[doc = " Loopback interface."] + pub static mut csp_if_lo: csp_iface_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sched_param { + pub sched_priority: ::core::ffi::c_int, +} +#[test] +fn bindgen_test_layout_sched_param() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(sched_param)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(sched_param)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sched_priority) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sched_param), + "::", + stringify!(sched_priority) + ) + ); +} +pub type __cpu_mask = ::core::ffi::c_ulong; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct cpu_set_t { + pub __bits: [__cpu_mask; 16usize], +} +#[test] +fn bindgen_test_layout_cpu_set_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 128usize, + concat!("Size of: ", stringify!(cpu_set_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(cpu_set_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__bits) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(cpu_set_t), + "::", + stringify!(__bits) + ) + ); +} +extern "C" { + pub fn __sched_cpucount(__setsize: usize, __setp: *const cpu_set_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn __sched_cpualloc(__count: usize) -> *mut cpu_set_t; +} +extern "C" { + pub fn __sched_cpufree(__set: *mut cpu_set_t); +} +extern "C" { + pub fn sched_setparam(__pid: __pid_t, __param: *const sched_param) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sched_getparam(__pid: __pid_t, __param: *mut sched_param) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sched_setscheduler( + __pid: __pid_t, + __policy: ::core::ffi::c_int, + __param: *const sched_param, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sched_getscheduler(__pid: __pid_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sched_yield() -> ::core::ffi::c_int; +} +extern "C" { + pub fn sched_get_priority_max(__algorithm: ::core::ffi::c_int) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sched_get_priority_min(__algorithm: ::core::ffi::c_int) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sched_rr_get_interval(__pid: __pid_t, __t: *mut timespec) -> ::core::ffi::c_int; +} +#[repr(C)] +#[derive(Debug, 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, + pub tm_gmtoff: ::core::ffi::c_long, + pub tm_zone: *const ::core::ffi::c_char, +} +#[test] +fn bindgen_test_layout_tm() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(tm)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tm)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tm_sec) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_sec) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tm_min) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_min) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tm_hour) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_hour) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tm_mday) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_mday) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tm_mon) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_mon) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tm_year) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_year) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tm_wday) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_wday) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tm_yday) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_yday) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tm_isdst) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_isdst) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tm_gmtoff) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_gmtoff) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tm_zone) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_zone) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct itimerspec { + pub it_interval: timespec, + pub it_value: timespec, +} +#[test] +fn bindgen_test_layout_itimerspec() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(itimerspec)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(itimerspec)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).it_interval) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(itimerspec), + "::", + stringify!(it_interval) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).it_value) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(itimerspec), + "::", + stringify!(it_value) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sigevent { + _unused: [u8; 0], +} +extern "C" { + pub fn clock() -> clock_t; +} +extern "C" { + pub fn time(__timer: *mut time_t) -> time_t; +} +extern "C" { + pub fn difftime(__time1: time_t, __time0: time_t) -> f64; +} +extern "C" { + pub fn mktime(__tp: *mut tm) -> time_t; +} +extern "C" { + pub fn strftime( + __s: *mut ::core::ffi::c_char, + __maxsize: usize, + __format: *const ::core::ffi::c_char, + __tp: *const tm, + ) -> usize; +} +extern "C" { + pub fn strftime_l( + __s: *mut ::core::ffi::c_char, + __maxsize: usize, + __format: *const ::core::ffi::c_char, + __tp: *const tm, + __loc: locale_t, + ) -> usize; +} +extern "C" { + pub fn gmtime(__timer: *const time_t) -> *mut tm; +} +extern "C" { + pub fn localtime(__timer: *const time_t) -> *mut tm; +} +extern "C" { + pub fn gmtime_r(__timer: *const time_t, __tp: *mut tm) -> *mut tm; +} +extern "C" { + pub fn localtime_r(__timer: *const time_t, __tp: *mut tm) -> *mut tm; +} +extern "C" { + pub fn asctime(__tp: *const tm) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn ctime(__timer: *const time_t) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn asctime_r(__tp: *const tm, __buf: *mut ::core::ffi::c_char) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn ctime_r( + __timer: *const time_t, + __buf: *mut ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub static mut __tzname: [*mut ::core::ffi::c_char; 2usize]; +} +extern "C" { + pub static mut __daylight: ::core::ffi::c_int; +} +extern "C" { + pub static mut __timezone: ::core::ffi::c_long; +} +extern "C" { + pub static mut tzname: [*mut ::core::ffi::c_char; 2usize]; +} +extern "C" { + pub fn tzset(); +} +extern "C" { + pub static mut daylight: ::core::ffi::c_int; +} +extern "C" { + pub static mut timezone: ::core::ffi::c_long; +} +extern "C" { + pub fn timegm(__tp: *mut tm) -> time_t; +} +extern "C" { + pub fn timelocal(__tp: *mut tm) -> time_t; +} +extern "C" { + pub fn dysize(__year: ::core::ffi::c_int) -> ::core::ffi::c_int; +} +extern "C" { + pub fn nanosleep( + __requested_time: *const timespec, + __remaining: *mut timespec, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn clock_getres(__clock_id: clockid_t, __res: *mut timespec) -> ::core::ffi::c_int; +} +extern "C" { + pub fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> ::core::ffi::c_int; +} +extern "C" { + pub fn clock_settime(__clock_id: clockid_t, __tp: *const timespec) -> ::core::ffi::c_int; +} +extern "C" { + pub fn clock_nanosleep( + __clock_id: clockid_t, + __flags: ::core::ffi::c_int, + __req: *const timespec, + __rem: *mut timespec, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn clock_getcpuclockid(__pid: pid_t, __clock_id: *mut clockid_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn timer_create( + __clock_id: clockid_t, + __evp: *mut sigevent, + __timerid: *mut timer_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn timer_delete(__timerid: timer_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn timer_settime( + __timerid: timer_t, + __flags: ::core::ffi::c_int, + __value: *const itimerspec, + __ovalue: *mut itimerspec, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn timer_gettime(__timerid: timer_t, __value: *mut itimerspec) -> ::core::ffi::c_int; +} +extern "C" { + pub fn timer_getoverrun(__timerid: timer_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn timespec_get(__ts: *mut timespec, __base: ::core::ffi::c_int) -> ::core::ffi::c_int; +} +pub type __jmp_buf = [::core::ffi::c_long; 8usize]; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __jmp_buf_tag { + pub __jmpbuf: __jmp_buf, + pub __mask_was_saved: ::core::ffi::c_int, + pub __saved_mask: __sigset_t, +} +#[test] +fn bindgen_test_layout___jmp_buf_tag() { + const UNINIT: ::core::mem::MaybeUninit<__jmp_buf_tag> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__jmp_buf_tag>(), + 200usize, + concat!("Size of: ", stringify!(__jmp_buf_tag)) + ); + assert_eq!( + ::core::mem::align_of::<__jmp_buf_tag>(), + 8usize, + concat!("Alignment of ", stringify!(__jmp_buf_tag)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__jmpbuf) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__jmp_buf_tag), + "::", + stringify!(__jmpbuf) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__mask_was_saved) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(__jmp_buf_tag), + "::", + stringify!(__mask_was_saved) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__saved_mask) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(__jmp_buf_tag), + "::", + stringify!(__saved_mask) + ) + ); +} +pub const PTHREAD_CREATE_JOINABLE: _bindgen_ty_1 = 0; +pub const PTHREAD_CREATE_DETACHED: _bindgen_ty_1 = 1; +pub type _bindgen_ty_1 = ::core::ffi::c_uint; +pub const PTHREAD_MUTEX_TIMED_NP: _bindgen_ty_2 = 0; +pub const PTHREAD_MUTEX_RECURSIVE_NP: _bindgen_ty_2 = 1; +pub const PTHREAD_MUTEX_ERRORCHECK_NP: _bindgen_ty_2 = 2; +pub const PTHREAD_MUTEX_ADAPTIVE_NP: _bindgen_ty_2 = 3; +pub const PTHREAD_MUTEX_NORMAL: _bindgen_ty_2 = 0; +pub const PTHREAD_MUTEX_RECURSIVE: _bindgen_ty_2 = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: _bindgen_ty_2 = 2; +pub const PTHREAD_MUTEX_DEFAULT: _bindgen_ty_2 = 0; +pub type _bindgen_ty_2 = ::core::ffi::c_uint; +pub const PTHREAD_MUTEX_STALLED: _bindgen_ty_3 = 0; +pub const PTHREAD_MUTEX_STALLED_NP: _bindgen_ty_3 = 0; +pub const PTHREAD_MUTEX_ROBUST: _bindgen_ty_3 = 1; +pub const PTHREAD_MUTEX_ROBUST_NP: _bindgen_ty_3 = 1; +pub type _bindgen_ty_3 = ::core::ffi::c_uint; +pub const PTHREAD_PRIO_NONE: _bindgen_ty_4 = 0; +pub const PTHREAD_PRIO_INHERIT: _bindgen_ty_4 = 1; +pub const PTHREAD_PRIO_PROTECT: _bindgen_ty_4 = 2; +pub type _bindgen_ty_4 = ::core::ffi::c_uint; +pub const PTHREAD_RWLOCK_PREFER_READER_NP: _bindgen_ty_5 = 0; +pub const PTHREAD_RWLOCK_PREFER_WRITER_NP: _bindgen_ty_5 = 1; +pub const PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP: _bindgen_ty_5 = 2; +pub const PTHREAD_RWLOCK_DEFAULT_NP: _bindgen_ty_5 = 0; +pub type _bindgen_ty_5 = ::core::ffi::c_uint; +pub const PTHREAD_INHERIT_SCHED: _bindgen_ty_6 = 0; +pub const PTHREAD_EXPLICIT_SCHED: _bindgen_ty_6 = 1; +pub type _bindgen_ty_6 = ::core::ffi::c_uint; +pub const PTHREAD_SCOPE_SYSTEM: _bindgen_ty_7 = 0; +pub const PTHREAD_SCOPE_PROCESS: _bindgen_ty_7 = 1; +pub type _bindgen_ty_7 = ::core::ffi::c_uint; +pub const PTHREAD_PROCESS_PRIVATE: _bindgen_ty_8 = 0; +pub const PTHREAD_PROCESS_SHARED: _bindgen_ty_8 = 1; +pub type _bindgen_ty_8 = ::core::ffi::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _pthread_cleanup_buffer { + pub __routine: ::core::option::Option, + pub __arg: *mut ::core::ffi::c_void, + pub __canceltype: ::core::ffi::c_int, + pub __prev: *mut _pthread_cleanup_buffer, +} +#[test] +fn bindgen_test_layout__pthread_cleanup_buffer() { + const UNINIT: ::core::mem::MaybeUninit<_pthread_cleanup_buffer> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<_pthread_cleanup_buffer>(), + 32usize, + concat!("Size of: ", stringify!(_pthread_cleanup_buffer)) + ); + assert_eq!( + ::core::mem::align_of::<_pthread_cleanup_buffer>(), + 8usize, + concat!("Alignment of ", stringify!(_pthread_cleanup_buffer)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__routine) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_pthread_cleanup_buffer), + "::", + stringify!(__routine) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__arg) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_pthread_cleanup_buffer), + "::", + stringify!(__arg) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__canceltype) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_pthread_cleanup_buffer), + "::", + stringify!(__canceltype) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__prev) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_pthread_cleanup_buffer), + "::", + stringify!(__prev) + ) + ); +} +pub const PTHREAD_CANCEL_ENABLE: _bindgen_ty_9 = 0; +pub const PTHREAD_CANCEL_DISABLE: _bindgen_ty_9 = 1; +pub type _bindgen_ty_9 = ::core::ffi::c_uint; +pub const PTHREAD_CANCEL_DEFERRED: _bindgen_ty_10 = 0; +pub const PTHREAD_CANCEL_ASYNCHRONOUS: _bindgen_ty_10 = 1; +pub type _bindgen_ty_10 = ::core::ffi::c_uint; +extern "C" { + pub fn pthread_create( + __newthread: *mut pthread_t, + __attr: *const pthread_attr_t, + __start_routine: ::core::option::Option< + unsafe extern "C" fn(arg1: *mut ::core::ffi::c_void) -> *mut ::core::ffi::c_void, + >, + __arg: *mut ::core::ffi::c_void, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_exit(__retval: *mut ::core::ffi::c_void) -> !; +} +extern "C" { + pub fn pthread_join( + __th: pthread_t, + __thread_return: *mut *mut ::core::ffi::c_void, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_detach(__th: pthread_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_self() -> pthread_t; +} +extern "C" { + pub fn pthread_equal(__thread1: pthread_t, __thread2: pthread_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_init(__attr: *mut pthread_attr_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_destroy(__attr: *mut pthread_attr_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_getdetachstate( + __attr: *const pthread_attr_t, + __detachstate: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_setdetachstate( + __attr: *mut pthread_attr_t, + __detachstate: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_getguardsize( + __attr: *const pthread_attr_t, + __guardsize: *mut usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_setguardsize( + __attr: *mut pthread_attr_t, + __guardsize: usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_getschedparam( + __attr: *const pthread_attr_t, + __param: *mut sched_param, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_setschedparam( + __attr: *mut pthread_attr_t, + __param: *const sched_param, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_getschedpolicy( + __attr: *const pthread_attr_t, + __policy: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_setschedpolicy( + __attr: *mut pthread_attr_t, + __policy: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_getinheritsched( + __attr: *const pthread_attr_t, + __inherit: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_setinheritsched( + __attr: *mut pthread_attr_t, + __inherit: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_getscope( + __attr: *const pthread_attr_t, + __scope: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_setscope( + __attr: *mut pthread_attr_t, + __scope: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_getstackaddr( + __attr: *const pthread_attr_t, + __stackaddr: *mut *mut ::core::ffi::c_void, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_setstackaddr( + __attr: *mut pthread_attr_t, + __stackaddr: *mut ::core::ffi::c_void, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_getstacksize( + __attr: *const pthread_attr_t, + __stacksize: *mut usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_setstacksize( + __attr: *mut pthread_attr_t, + __stacksize: usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_getstack( + __attr: *const pthread_attr_t, + __stackaddr: *mut *mut ::core::ffi::c_void, + __stacksize: *mut usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_attr_setstack( + __attr: *mut pthread_attr_t, + __stackaddr: *mut ::core::ffi::c_void, + __stacksize: usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_setschedparam( + __target_thread: pthread_t, + __policy: ::core::ffi::c_int, + __param: *const sched_param, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_getschedparam( + __target_thread: pthread_t, + __policy: *mut ::core::ffi::c_int, + __param: *mut sched_param, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_setschedprio( + __target_thread: pthread_t, + __prio: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_once( + __once_control: *mut pthread_once_t, + __init_routine: ::core::option::Option, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_setcancelstate( + __state: ::core::ffi::c_int, + __oldstate: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_setcanceltype( + __type: ::core::ffi::c_int, + __oldtype: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_cancel(__th: pthread_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_testcancel(); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __cancel_jmp_buf_tag { + pub __cancel_jmp_buf: __jmp_buf, + pub __mask_was_saved: ::core::ffi::c_int, +} +#[test] +fn bindgen_test_layout___cancel_jmp_buf_tag() { + const UNINIT: ::core::mem::MaybeUninit<__cancel_jmp_buf_tag> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__cancel_jmp_buf_tag>(), + 72usize, + concat!("Size of: ", stringify!(__cancel_jmp_buf_tag)) + ); + assert_eq!( + ::core::mem::align_of::<__cancel_jmp_buf_tag>(), + 8usize, + concat!("Alignment of ", stringify!(__cancel_jmp_buf_tag)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__cancel_jmp_buf) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__cancel_jmp_buf_tag), + "::", + stringify!(__cancel_jmp_buf) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__mask_was_saved) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(__cancel_jmp_buf_tag), + "::", + stringify!(__mask_was_saved) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_unwind_buf_t { + pub __cancel_jmp_buf: [__cancel_jmp_buf_tag; 1usize], + pub __pad: [*mut ::core::ffi::c_void; 4usize], +} +#[test] +fn bindgen_test_layout___pthread_unwind_buf_t() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_unwind_buf_t> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__pthread_unwind_buf_t>(), + 104usize, + concat!("Size of: ", stringify!(__pthread_unwind_buf_t)) + ); + assert_eq!( + ::core::mem::align_of::<__pthread_unwind_buf_t>(), + 8usize, + concat!("Alignment of ", stringify!(__pthread_unwind_buf_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__cancel_jmp_buf) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__pthread_unwind_buf_t), + "::", + stringify!(__cancel_jmp_buf) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__pad) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(__pthread_unwind_buf_t), + "::", + stringify!(__pad) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_cleanup_frame { + pub __cancel_routine: + ::core::option::Option, + pub __cancel_arg: *mut ::core::ffi::c_void, + pub __do_it: ::core::ffi::c_int, + pub __cancel_type: ::core::ffi::c_int, +} +#[test] +fn bindgen_test_layout___pthread_cleanup_frame() { + const UNINIT: ::core::mem::MaybeUninit<__pthread_cleanup_frame> = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__pthread_cleanup_frame>(), + 24usize, + concat!("Size of: ", stringify!(__pthread_cleanup_frame)) + ); + assert_eq!( + ::core::mem::align_of::<__pthread_cleanup_frame>(), + 8usize, + concat!("Alignment of ", stringify!(__pthread_cleanup_frame)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__cancel_routine) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cleanup_frame), + "::", + stringify!(__cancel_routine) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__cancel_arg) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cleanup_frame), + "::", + stringify!(__cancel_arg) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__do_it) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cleanup_frame), + "::", + stringify!(__do_it) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__cancel_type) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(__pthread_cleanup_frame), + "::", + stringify!(__cancel_type) + ) + ); +} +extern "C" { + pub fn __pthread_register_cancel(__buf: *mut __pthread_unwind_buf_t); +} +extern "C" { + pub fn __pthread_unregister_cancel(__buf: *mut __pthread_unwind_buf_t); +} +extern "C" { + pub fn __pthread_unwind_next(__buf: *mut __pthread_unwind_buf_t) -> !; +} +extern "C" { + pub fn __sigsetjmp( + __env: *mut __jmp_buf_tag, + __savemask: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutex_init( + __mutex: *mut pthread_mutex_t, + __mutexattr: *const pthread_mutexattr_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutex_destroy(__mutex: *mut pthread_mutex_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutex_trylock(__mutex: *mut pthread_mutex_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutex_timedlock( + __mutex: *mut pthread_mutex_t, + __abstime: *const timespec, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutex_getprioceiling( + __mutex: *const pthread_mutex_t, + __prioceiling: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutex_setprioceiling( + __mutex: *mut pthread_mutex_t, + __prioceiling: ::core::ffi::c_int, + __old_ceiling: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutex_consistent(__mutex: *mut pthread_mutex_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_init(__attr: *mut pthread_mutexattr_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_destroy(__attr: *mut pthread_mutexattr_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_getpshared( + __attr: *const pthread_mutexattr_t, + __pshared: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_setpshared( + __attr: *mut pthread_mutexattr_t, + __pshared: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_gettype( + __attr: *const pthread_mutexattr_t, + __kind: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_settype( + __attr: *mut pthread_mutexattr_t, + __kind: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_getprotocol( + __attr: *const pthread_mutexattr_t, + __protocol: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_setprotocol( + __attr: *mut pthread_mutexattr_t, + __protocol: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_getprioceiling( + __attr: *const pthread_mutexattr_t, + __prioceiling: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_setprioceiling( + __attr: *mut pthread_mutexattr_t, + __prioceiling: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_getrobust( + __attr: *const pthread_mutexattr_t, + __robustness: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_mutexattr_setrobust( + __attr: *mut pthread_mutexattr_t, + __robustness: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlock_init( + __rwlock: *mut pthread_rwlock_t, + __attr: *const pthread_rwlockattr_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlock_destroy(__rwlock: *mut pthread_rwlock_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlock_rdlock(__rwlock: *mut pthread_rwlock_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlock_tryrdlock(__rwlock: *mut pthread_rwlock_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlock_timedrdlock( + __rwlock: *mut pthread_rwlock_t, + __abstime: *const timespec, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlock_wrlock(__rwlock: *mut pthread_rwlock_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlock_trywrlock(__rwlock: *mut pthread_rwlock_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlock_timedwrlock( + __rwlock: *mut pthread_rwlock_t, + __abstime: *const timespec, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlock_unlock(__rwlock: *mut pthread_rwlock_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlockattr_init(__attr: *mut pthread_rwlockattr_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlockattr_destroy(__attr: *mut pthread_rwlockattr_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlockattr_getpshared( + __attr: *const pthread_rwlockattr_t, + __pshared: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlockattr_setpshared( + __attr: *mut pthread_rwlockattr_t, + __pshared: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlockattr_getkind_np( + __attr: *const pthread_rwlockattr_t, + __pref: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_rwlockattr_setkind_np( + __attr: *mut pthread_rwlockattr_t, + __pref: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_cond_init( + __cond: *mut pthread_cond_t, + __cond_attr: *const pthread_condattr_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_cond_destroy(__cond: *mut pthread_cond_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_cond_signal(__cond: *mut pthread_cond_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_cond_broadcast(__cond: *mut pthread_cond_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_cond_wait( + __cond: *mut pthread_cond_t, + __mutex: *mut pthread_mutex_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_cond_timedwait( + __cond: *mut pthread_cond_t, + __mutex: *mut pthread_mutex_t, + __abstime: *const timespec, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_condattr_init(__attr: *mut pthread_condattr_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_condattr_destroy(__attr: *mut pthread_condattr_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_condattr_getpshared( + __attr: *const pthread_condattr_t, + __pshared: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_condattr_setpshared( + __attr: *mut pthread_condattr_t, + __pshared: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_condattr_getclock( + __attr: *const pthread_condattr_t, + __clock_id: *mut __clockid_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_condattr_setclock( + __attr: *mut pthread_condattr_t, + __clock_id: __clockid_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_spin_init( + __lock: *mut pthread_spinlock_t, + __pshared: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_spin_destroy(__lock: *mut pthread_spinlock_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_spin_lock(__lock: *mut pthread_spinlock_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_spin_trylock(__lock: *mut pthread_spinlock_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_spin_unlock(__lock: *mut pthread_spinlock_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_barrier_init( + __barrier: *mut pthread_barrier_t, + __attr: *const pthread_barrierattr_t, + __count: ::core::ffi::c_uint, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_barrier_destroy(__barrier: *mut pthread_barrier_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_barrier_wait(__barrier: *mut pthread_barrier_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_barrierattr_init(__attr: *mut pthread_barrierattr_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_barrierattr_destroy(__attr: *mut pthread_barrierattr_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_barrierattr_getpshared( + __attr: *const pthread_barrierattr_t, + __pshared: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_barrierattr_setpshared( + __attr: *mut pthread_barrierattr_t, + __pshared: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_key_create( + __key: *mut pthread_key_t, + __destr_function: ::core::option::Option< + unsafe extern "C" fn(arg1: *mut ::core::ffi::c_void), + >, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_key_delete(__key: pthread_key_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_getspecific(__key: pthread_key_t) -> *mut ::core::ffi::c_void; +} +extern "C" { + pub fn pthread_setspecific( + __key: pthread_key_t, + __pointer: *const ::core::ffi::c_void, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_getcpuclockid( + __thread_id: pthread_t, + __clock_id: *mut __clockid_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn pthread_atfork( + __prepare: ::core::option::Option, + __parent: ::core::option::Option, + __child: ::core::option::Option, + ) -> ::core::ffi::c_int; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct iovec { + pub iov_base: *mut ::core::ffi::c_void, + pub iov_len: usize, +} +#[test] +fn bindgen_test_layout_iovec() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(iovec)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(iovec)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).iov_base) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(iovec), + "::", + stringify!(iov_base) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).iov_len) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(iovec), + "::", + stringify!(iov_len) + ) + ); +} +pub type socklen_t = __socklen_t; +pub const __socket_type_SOCK_STREAM: __socket_type = 1; +pub const __socket_type_SOCK_DGRAM: __socket_type = 2; +pub const __socket_type_SOCK_RAW: __socket_type = 3; +pub const __socket_type_SOCK_RDM: __socket_type = 4; +pub const __socket_type_SOCK_SEQPACKET: __socket_type = 5; +pub const __socket_type_SOCK_DCCP: __socket_type = 6; +pub const __socket_type_SOCK_PACKET: __socket_type = 10; +pub const __socket_type_SOCK_CLOEXEC: __socket_type = 524288; +pub const __socket_type_SOCK_NONBLOCK: __socket_type = 2048; +pub type __socket_type = ::core::ffi::c_uint; +pub type sa_family_t = ::core::ffi::c_ushort; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [::core::ffi::c_char; 14usize], +} +#[test] +fn bindgen_test_layout_sockaddr() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(sockaddr)) + ); + assert_eq!( + ::core::mem::align_of::(), + 2usize, + concat!("Alignment of ", stringify!(sockaddr)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sa_family) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr), + "::", + stringify!(sa_family) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sa_data) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr), + "::", + stringify!(sa_data) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr_storage { + pub ss_family: sa_family_t, + pub __ss_padding: [::core::ffi::c_char; 118usize], + pub __ss_align: ::core::ffi::c_ulong, +} +#[test] +fn bindgen_test_layout_sockaddr_storage() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 128usize, + concat!("Size of: ", stringify!(sockaddr_storage)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(sockaddr_storage)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ss_family) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_storage), + "::", + stringify!(ss_family) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__ss_padding) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_storage), + "::", + stringify!(__ss_padding) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__ss_align) as usize - ptr as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_storage), + "::", + stringify!(__ss_align) + ) + ); +} +pub const MSG_OOB: _bindgen_ty_11 = 1; +pub const MSG_PEEK: _bindgen_ty_11 = 2; +pub const MSG_DONTROUTE: _bindgen_ty_11 = 4; +pub const MSG_CTRUNC: _bindgen_ty_11 = 8; +pub const MSG_PROXY: _bindgen_ty_11 = 16; +pub const MSG_TRUNC: _bindgen_ty_11 = 32; +pub const MSG_DONTWAIT: _bindgen_ty_11 = 64; +pub const MSG_EOR: _bindgen_ty_11 = 128; +pub const MSG_WAITALL: _bindgen_ty_11 = 256; +pub const MSG_FIN: _bindgen_ty_11 = 512; +pub const MSG_SYN: _bindgen_ty_11 = 1024; +pub const MSG_CONFIRM: _bindgen_ty_11 = 2048; +pub const MSG_RST: _bindgen_ty_11 = 4096; +pub const MSG_ERRQUEUE: _bindgen_ty_11 = 8192; +pub const MSG_NOSIGNAL: _bindgen_ty_11 = 16384; +pub const MSG_MORE: _bindgen_ty_11 = 32768; +pub const MSG_WAITFORONE: _bindgen_ty_11 = 65536; +pub const MSG_BATCH: _bindgen_ty_11 = 262144; +pub const MSG_ZEROCOPY: _bindgen_ty_11 = 67108864; +pub const MSG_FASTOPEN: _bindgen_ty_11 = 536870912; +pub const MSG_CMSG_CLOEXEC: _bindgen_ty_11 = 1073741824; +pub type _bindgen_ty_11 = ::core::ffi::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct msghdr { + pub msg_name: *mut ::core::ffi::c_void, + pub msg_namelen: socklen_t, + pub msg_iov: *mut iovec, + pub msg_iovlen: usize, + pub msg_control: *mut ::core::ffi::c_void, + pub msg_controllen: usize, + pub msg_flags: ::core::ffi::c_int, +} +#[test] +fn bindgen_test_layout_msghdr() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(msghdr)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(msghdr)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).msg_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_name) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).msg_namelen) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_namelen) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).msg_iov) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_iov) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).msg_iovlen) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_iovlen) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).msg_control) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_control) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).msg_controllen) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_controllen) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).msg_flags) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_flags) + ) + ); +} +#[repr(C)] +#[derive(Debug)] +pub struct cmsghdr { + pub cmsg_len: usize, + pub cmsg_level: ::core::ffi::c_int, + pub cmsg_type: ::core::ffi::c_int, + pub __cmsg_data: __IncompleteArrayField<::core::ffi::c_uchar>, +} +#[test] +fn bindgen_test_layout_cmsghdr() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(cmsghdr)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(cmsghdr)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).cmsg_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(cmsghdr), + "::", + stringify!(cmsg_len) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).cmsg_level) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(cmsghdr), + "::", + stringify!(cmsg_level) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).cmsg_type) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(cmsghdr), + "::", + stringify!(cmsg_type) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__cmsg_data) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(cmsghdr), + "::", + stringify!(__cmsg_data) + ) + ); +} +extern "C" { + pub fn __cmsg_nxthdr(__mhdr: *mut msghdr, __cmsg: *mut cmsghdr) -> *mut cmsghdr; +} +pub const SCM_RIGHTS: _bindgen_ty_12 = 1; +pub type _bindgen_ty_12 = ::core::ffi::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __kernel_fd_set { + pub fds_bits: [::core::ffi::c_ulong; 16usize], +} +#[test] +fn bindgen_test_layout___kernel_fd_set() { + const UNINIT: ::core::mem::MaybeUninit<__kernel_fd_set> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__kernel_fd_set>(), + 128usize, + concat!("Size of: ", stringify!(__kernel_fd_set)) + ); + assert_eq!( + ::core::mem::align_of::<__kernel_fd_set>(), + 8usize, + concat!("Alignment of ", stringify!(__kernel_fd_set)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).fds_bits) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__kernel_fd_set), + "::", + stringify!(fds_bits) + ) + ); +} +pub type __kernel_sighandler_t = + ::core::option::Option; +pub type __kernel_key_t = ::core::ffi::c_int; +pub type __kernel_mqd_t = ::core::ffi::c_int; +pub type __kernel_old_uid_t = ::core::ffi::c_ushort; +pub type __kernel_old_gid_t = ::core::ffi::c_ushort; +pub type __kernel_old_dev_t = ::core::ffi::c_ulong; +pub type __kernel_long_t = ::core::ffi::c_long; +pub type __kernel_ulong_t = ::core::ffi::c_ulong; +pub type __kernel_ino_t = __kernel_ulong_t; +pub type __kernel_mode_t = ::core::ffi::c_uint; +pub type __kernel_pid_t = ::core::ffi::c_int; +pub type __kernel_ipc_pid_t = ::core::ffi::c_int; +pub type __kernel_uid_t = ::core::ffi::c_uint; +pub type __kernel_gid_t = ::core::ffi::c_uint; +pub type __kernel_suseconds_t = __kernel_long_t; +pub type __kernel_daddr_t = ::core::ffi::c_int; +pub type __kernel_uid32_t = ::core::ffi::c_uint; +pub type __kernel_gid32_t = ::core::ffi::c_uint; +pub type __kernel_size_t = __kernel_ulong_t; +pub type __kernel_ssize_t = __kernel_long_t; +pub type __kernel_ptrdiff_t = __kernel_long_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __kernel_fsid_t { + pub val: [::core::ffi::c_int; 2usize], +} +#[test] +fn bindgen_test_layout___kernel_fsid_t() { + const UNINIT: ::core::mem::MaybeUninit<__kernel_fsid_t> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__kernel_fsid_t>(), + 8usize, + concat!("Size of: ", stringify!(__kernel_fsid_t)) + ); + assert_eq!( + ::core::mem::align_of::<__kernel_fsid_t>(), + 4usize, + concat!("Alignment of ", stringify!(__kernel_fsid_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).val) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__kernel_fsid_t), + "::", + stringify!(val) + ) + ); +} +pub type __kernel_off_t = __kernel_long_t; +pub type __kernel_loff_t = ::core::ffi::c_longlong; +pub type __kernel_old_time_t = __kernel_long_t; +pub type __kernel_time_t = __kernel_long_t; +pub type __kernel_time64_t = ::core::ffi::c_longlong; +pub type __kernel_clock_t = __kernel_long_t; +pub type __kernel_timer_t = ::core::ffi::c_int; +pub type __kernel_clockid_t = ::core::ffi::c_int; +pub type __kernel_caddr_t = *mut ::core::ffi::c_char; +pub type __kernel_uid16_t = ::core::ffi::c_ushort; +pub type __kernel_gid16_t = ::core::ffi::c_ushort; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct linger { + pub l_onoff: ::core::ffi::c_int, + pub l_linger: ::core::ffi::c_int, +} +#[test] +fn bindgen_test_layout_linger() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(linger)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(linger)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).l_onoff) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(linger), + "::", + stringify!(l_onoff) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).l_linger) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(linger), + "::", + stringify!(l_linger) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct osockaddr { + pub sa_family: ::core::ffi::c_ushort, + pub sa_data: [::core::ffi::c_uchar; 14usize], +} +#[test] +fn bindgen_test_layout_osockaddr() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(osockaddr)) + ); + assert_eq!( + ::core::mem::align_of::(), + 2usize, + concat!("Alignment of ", stringify!(osockaddr)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sa_family) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(osockaddr), + "::", + stringify!(sa_family) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sa_data) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(osockaddr), + "::", + stringify!(sa_data) + ) + ); +} +pub const SHUT_RD: _bindgen_ty_13 = 0; +pub const SHUT_WR: _bindgen_ty_13 = 1; +pub const SHUT_RDWR: _bindgen_ty_13 = 2; +pub type _bindgen_ty_13 = ::core::ffi::c_uint; +extern "C" { + pub fn socket( + __domain: ::core::ffi::c_int, + __type: ::core::ffi::c_int, + __protocol: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn socketpair( + __domain: ::core::ffi::c_int, + __type: ::core::ffi::c_int, + __protocol: ::core::ffi::c_int, + __fds: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn bind( + __fd: ::core::ffi::c_int, + __addr: *const sockaddr, + __len: socklen_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn getsockname( + __fd: ::core::ffi::c_int, + __addr: *mut sockaddr, + __len: *mut socklen_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn connect( + __fd: ::core::ffi::c_int, + __addr: *const sockaddr, + __len: socklen_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn getpeername( + __fd: ::core::ffi::c_int, + __addr: *mut sockaddr, + __len: *mut socklen_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn send( + __fd: ::core::ffi::c_int, + __buf: *const ::core::ffi::c_void, + __n: usize, + __flags: ::core::ffi::c_int, + ) -> isize; +} +extern "C" { + pub fn recv( + __fd: ::core::ffi::c_int, + __buf: *mut ::core::ffi::c_void, + __n: usize, + __flags: ::core::ffi::c_int, + ) -> isize; +} +extern "C" { + pub fn sendto( + __fd: ::core::ffi::c_int, + __buf: *const ::core::ffi::c_void, + __n: usize, + __flags: ::core::ffi::c_int, + __addr: *const sockaddr, + __addr_len: socklen_t, + ) -> isize; +} +extern "C" { + pub fn recvfrom( + __fd: ::core::ffi::c_int, + __buf: *mut ::core::ffi::c_void, + __n: usize, + __flags: ::core::ffi::c_int, + __addr: *mut sockaddr, + __addr_len: *mut socklen_t, + ) -> isize; +} +extern "C" { + pub fn sendmsg( + __fd: ::core::ffi::c_int, + __message: *const msghdr, + __flags: ::core::ffi::c_int, + ) -> isize; +} +extern "C" { + pub fn recvmsg( + __fd: ::core::ffi::c_int, + __message: *mut msghdr, + __flags: ::core::ffi::c_int, + ) -> isize; +} +extern "C" { + pub fn getsockopt( + __fd: ::core::ffi::c_int, + __level: ::core::ffi::c_int, + __optname: ::core::ffi::c_int, + __optval: *mut ::core::ffi::c_void, + __optlen: *mut socklen_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn setsockopt( + __fd: ::core::ffi::c_int, + __level: ::core::ffi::c_int, + __optname: ::core::ffi::c_int, + __optval: *const ::core::ffi::c_void, + __optlen: socklen_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn listen(__fd: ::core::ffi::c_int, __n: ::core::ffi::c_int) -> ::core::ffi::c_int; +} +extern "C" { + pub fn accept( + __fd: ::core::ffi::c_int, + __addr: *mut sockaddr, + __addr_len: *mut socklen_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn shutdown(__fd: ::core::ffi::c_int, __how: ::core::ffi::c_int) -> ::core::ffi::c_int; +} +extern "C" { + pub fn sockatmark(__fd: ::core::ffi::c_int) -> ::core::ffi::c_int; +} +extern "C" { + pub fn isfdtype(__fd: ::core::ffi::c_int, __fdtype: ::core::ffi::c_int) -> ::core::ffi::c_int; +} +pub type in_addr_t = u32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct in_addr { + pub s_addr: in_addr_t, +} +#[test] +fn bindgen_test_layout_in_addr() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(in_addr)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(in_addr)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).s_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in_addr), + "::", + stringify!(s_addr) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ip_opts { + pub ip_dst: in_addr, + pub ip_opts: [::core::ffi::c_char; 40usize], +} +#[test] +fn bindgen_test_layout_ip_opts() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 44usize, + concat!("Size of: ", stringify!(ip_opts)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ip_opts)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ip_dst) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ip_opts), + "::", + stringify!(ip_dst) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ip_opts) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(ip_opts), + "::", + stringify!(ip_opts) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: ::core::ffi::c_int, +} +#[test] +fn bindgen_test_layout_ip_mreqn() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(ip_mreqn)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ip_mreqn)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imr_multiaddr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ip_mreqn), + "::", + stringify!(imr_multiaddr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imr_address) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(ip_mreqn), + "::", + stringify!(imr_address) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imr_ifindex) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ip_mreqn), + "::", + stringify!(imr_ifindex) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct in_pktinfo { + pub ipi_ifindex: ::core::ffi::c_int, + pub ipi_spec_dst: in_addr, + pub ipi_addr: in_addr, +} +#[test] +fn bindgen_test_layout_in_pktinfo() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(in_pktinfo)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(in_pktinfo)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ipi_ifindex) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in_pktinfo), + "::", + stringify!(ipi_ifindex) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ipi_spec_dst) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(in_pktinfo), + "::", + stringify!(ipi_spec_dst) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ipi_addr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(in_pktinfo), + "::", + stringify!(ipi_addr) + ) + ); +} +pub const IPPROTO_IP: _bindgen_ty_14 = 0; +pub const IPPROTO_ICMP: _bindgen_ty_14 = 1; +pub const IPPROTO_IGMP: _bindgen_ty_14 = 2; +pub const IPPROTO_IPIP: _bindgen_ty_14 = 4; +pub const IPPROTO_TCP: _bindgen_ty_14 = 6; +pub const IPPROTO_EGP: _bindgen_ty_14 = 8; +pub const IPPROTO_PUP: _bindgen_ty_14 = 12; +pub const IPPROTO_UDP: _bindgen_ty_14 = 17; +pub const IPPROTO_IDP: _bindgen_ty_14 = 22; +pub const IPPROTO_TP: _bindgen_ty_14 = 29; +pub const IPPROTO_DCCP: _bindgen_ty_14 = 33; +pub const IPPROTO_IPV6: _bindgen_ty_14 = 41; +pub const IPPROTO_RSVP: _bindgen_ty_14 = 46; +pub const IPPROTO_GRE: _bindgen_ty_14 = 47; +pub const IPPROTO_ESP: _bindgen_ty_14 = 50; +pub const IPPROTO_AH: _bindgen_ty_14 = 51; +pub const IPPROTO_MTP: _bindgen_ty_14 = 92; +pub const IPPROTO_BEETPH: _bindgen_ty_14 = 94; +pub const IPPROTO_ENCAP: _bindgen_ty_14 = 98; +pub const IPPROTO_PIM: _bindgen_ty_14 = 103; +pub const IPPROTO_COMP: _bindgen_ty_14 = 108; +pub const IPPROTO_SCTP: _bindgen_ty_14 = 132; +pub const IPPROTO_UDPLITE: _bindgen_ty_14 = 136; +pub const IPPROTO_MPLS: _bindgen_ty_14 = 137; +pub const IPPROTO_ETHERNET: _bindgen_ty_14 = 143; +pub const IPPROTO_RAW: _bindgen_ty_14 = 255; +pub const IPPROTO_MPTCP: _bindgen_ty_14 = 262; +pub const IPPROTO_MAX: _bindgen_ty_14 = 263; +pub type _bindgen_ty_14 = ::core::ffi::c_uint; +pub const IPPROTO_HOPOPTS: _bindgen_ty_15 = 0; +pub const IPPROTO_ROUTING: _bindgen_ty_15 = 43; +pub const IPPROTO_FRAGMENT: _bindgen_ty_15 = 44; +pub const IPPROTO_ICMPV6: _bindgen_ty_15 = 58; +pub const IPPROTO_NONE: _bindgen_ty_15 = 59; +pub const IPPROTO_DSTOPTS: _bindgen_ty_15 = 60; +pub const IPPROTO_MH: _bindgen_ty_15 = 135; +pub type _bindgen_ty_15 = ::core::ffi::c_uint; +pub type in_port_t = u16; +pub const IPPORT_ECHO: _bindgen_ty_16 = 7; +pub const IPPORT_DISCARD: _bindgen_ty_16 = 9; +pub const IPPORT_SYSTAT: _bindgen_ty_16 = 11; +pub const IPPORT_DAYTIME: _bindgen_ty_16 = 13; +pub const IPPORT_NETSTAT: _bindgen_ty_16 = 15; +pub const IPPORT_FTP: _bindgen_ty_16 = 21; +pub const IPPORT_TELNET: _bindgen_ty_16 = 23; +pub const IPPORT_SMTP: _bindgen_ty_16 = 25; +pub const IPPORT_TIMESERVER: _bindgen_ty_16 = 37; +pub const IPPORT_NAMESERVER: _bindgen_ty_16 = 42; +pub const IPPORT_WHOIS: _bindgen_ty_16 = 43; +pub const IPPORT_MTP: _bindgen_ty_16 = 57; +pub const IPPORT_TFTP: _bindgen_ty_16 = 69; +pub const IPPORT_RJE: _bindgen_ty_16 = 77; +pub const IPPORT_FINGER: _bindgen_ty_16 = 79; +pub const IPPORT_TTYLINK: _bindgen_ty_16 = 87; +pub const IPPORT_SUPDUP: _bindgen_ty_16 = 95; +pub const IPPORT_EXECSERVER: _bindgen_ty_16 = 512; +pub const IPPORT_LOGINSERVER: _bindgen_ty_16 = 513; +pub const IPPORT_CMDSERVER: _bindgen_ty_16 = 514; +pub const IPPORT_EFSSERVER: _bindgen_ty_16 = 520; +pub const IPPORT_BIFFUDP: _bindgen_ty_16 = 512; +pub const IPPORT_WHOSERVER: _bindgen_ty_16 = 513; +pub const IPPORT_ROUTESERVER: _bindgen_ty_16 = 520; +pub const IPPORT_RESERVED: _bindgen_ty_16 = 1024; +pub const IPPORT_USERRESERVED: _bindgen_ty_16 = 5000; +pub type _bindgen_ty_16 = ::core::ffi::c_uint; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct in6_addr { + pub __in6_u: in6_addr__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union in6_addr__bindgen_ty_1 { + pub __u6_addr8: [u8; 16usize], + pub __u6_addr16: [u16; 8usize], + pub __u6_addr32: [u32; 4usize], +} +#[test] +fn bindgen_test_layout_in6_addr__bindgen_ty_1() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(in6_addr__bindgen_ty_1)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(in6_addr__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__u6_addr8) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in6_addr__bindgen_ty_1), + "::", + stringify!(__u6_addr8) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__u6_addr16) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in6_addr__bindgen_ty_1), + "::", + stringify!(__u6_addr16) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__u6_addr32) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in6_addr__bindgen_ty_1), + "::", + stringify!(__u6_addr32) + ) + ); +} +#[test] +fn bindgen_test_layout_in6_addr() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(in6_addr)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(in6_addr)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__in6_u) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in6_addr), + "::", + stringify!(__in6_u) + ) + ); +} +extern "C" { + pub static in6addr_any: in6_addr; +} +extern "C" { + pub static in6addr_loopback: in6_addr; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [::core::ffi::c_uchar; 8usize], +} +#[test] +fn bindgen_test_layout_sockaddr_in() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(sockaddr_in)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(sockaddr_in)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sin_family) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_family) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sin_port) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_port) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sin_addr) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_addr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sin_zero) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_zero) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, +} +#[test] +fn bindgen_test_layout_sockaddr_in6() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 28usize, + concat!("Size of: ", stringify!(sockaddr_in6)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(sockaddr_in6)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sin6_family) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in6), + "::", + stringify!(sin6_family) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sin6_port) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in6), + "::", + stringify!(sin6_port) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sin6_flowinfo) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in6), + "::", + stringify!(sin6_flowinfo) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sin6_addr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in6), + "::", + stringify!(sin6_addr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sin6_scope_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in6), + "::", + stringify!(sin6_scope_id) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, +} +#[test] +fn bindgen_test_layout_ip_mreq() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(ip_mreq)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ip_mreq)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imr_multiaddr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ip_mreq), + "::", + stringify!(imr_multiaddr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imr_interface) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(ip_mreq), + "::", + stringify!(imr_interface) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + pub imr_sourceaddr: in_addr, +} +#[test] +fn bindgen_test_layout_ip_mreq_source() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(ip_mreq_source)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ip_mreq_source)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imr_multiaddr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ip_mreq_source), + "::", + stringify!(imr_multiaddr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imr_interface) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(ip_mreq_source), + "::", + stringify!(imr_interface) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imr_sourceaddr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ip_mreq_source), + "::", + stringify!(imr_sourceaddr) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: ::core::ffi::c_uint, +} +#[test] +fn bindgen_test_layout_ipv6_mreq() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(ipv6_mreq)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ipv6_mreq)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ipv6mr_multiaddr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ipv6_mreq), + "::", + stringify!(ipv6mr_multiaddr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ipv6mr_interface) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ipv6_mreq), + "::", + stringify!(ipv6mr_interface) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct group_req { + pub gr_interface: u32, + pub gr_group: sockaddr_storage, +} +#[test] +fn bindgen_test_layout_group_req() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 136usize, + concat!("Size of: ", stringify!(group_req)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(group_req)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).gr_interface) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(group_req), + "::", + stringify!(gr_interface) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).gr_group) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(group_req), + "::", + stringify!(gr_group) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct group_source_req { + pub gsr_interface: u32, + pub gsr_group: sockaddr_storage, + pub gsr_source: sockaddr_storage, +} +#[test] +fn bindgen_test_layout_group_source_req() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 264usize, + concat!("Size of: ", stringify!(group_source_req)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(group_source_req)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).gsr_interface) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(group_source_req), + "::", + stringify!(gsr_interface) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).gsr_group) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(group_source_req), + "::", + stringify!(gsr_group) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).gsr_source) as usize - ptr as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(group_source_req), + "::", + stringify!(gsr_source) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ip_msfilter { + pub imsf_multiaddr: in_addr, + pub imsf_interface: in_addr, + pub imsf_fmode: u32, + pub imsf_numsrc: u32, + pub imsf_slist: [in_addr; 1usize], +} +#[test] +fn bindgen_test_layout_ip_msfilter() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(ip_msfilter)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ip_msfilter)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imsf_multiaddr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ip_msfilter), + "::", + stringify!(imsf_multiaddr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imsf_interface) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(ip_msfilter), + "::", + stringify!(imsf_interface) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imsf_fmode) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ip_msfilter), + "::", + stringify!(imsf_fmode) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imsf_numsrc) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(ip_msfilter), + "::", + stringify!(imsf_numsrc) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).imsf_slist) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ip_msfilter), + "::", + stringify!(imsf_slist) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct group_filter { + pub gf_interface: u32, + pub gf_group: sockaddr_storage, + pub gf_fmode: u32, + pub gf_numsrc: u32, + pub gf_slist: [sockaddr_storage; 1usize], +} +#[test] +fn bindgen_test_layout_group_filter() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 272usize, + concat!("Size of: ", stringify!(group_filter)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(group_filter)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).gf_interface) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(group_filter), + "::", + stringify!(gf_interface) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).gf_group) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(group_filter), + "::", + stringify!(gf_group) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).gf_fmode) as usize - ptr as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(group_filter), + "::", + stringify!(gf_fmode) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).gf_numsrc) as usize - ptr as usize }, + 140usize, + concat!( + "Offset of field: ", + stringify!(group_filter), + "::", + stringify!(gf_numsrc) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).gf_slist) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(group_filter), + "::", + stringify!(gf_slist) + ) + ); +} +extern "C" { + pub fn ntohl(__netlong: u32) -> u32; +} +extern "C" { + pub fn ntohs(__netshort: u16) -> u16; +} +extern "C" { + pub fn htonl(__hostlong: u32) -> u32; +} +extern "C" { + pub fn htons(__hostshort: u16) -> u16; +} +extern "C" { + pub fn bindresvport( + __sockfd: ::core::ffi::c_int, + __sock_in: *mut sockaddr_in, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn bindresvport6( + __sockfd: ::core::ffi::c_int, + __sock_in: *mut sockaddr_in6, + ) -> ::core::ffi::c_int; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_if_udp_conf_t { + pub host: *mut ::core::ffi::c_char, + pub lport: ::core::ffi::c_int, + pub rport: ::core::ffi::c_int, + pub server_handle: pthread_t, + pub peer_addr: sockaddr_in, + pub sockfd: ::core::ffi::c_int, +} +#[test] +fn bindgen_test_layout_csp_if_udp_conf_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(csp_if_udp_conf_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_if_udp_conf_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).host) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(host) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).lport) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(lport) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rport) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(rport) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).server_handle) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(server_handle) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).peer_addr) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(peer_addr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sockfd) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(sockfd) + ) + ); +} +extern "C" { + #[doc = " Setup UDP peer\n\n RX task:\n A server task will attempt at binding to ip 0.0.0.0 port 9600\n If this fails, it is because another udp server is already running.\n The server task will continue attemting the bind and will not exit before the application is closed.\n\n TX peer:\n Outgoing CSP packets will be transferred to the peer specified by the host argument"] + pub fn csp_if_udp_init(iface: *mut csp_iface_t, ifconf: *mut csp_if_udp_conf_t); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __locale_data { + pub _address: u8, +} diff --git a/clib/bindings.sh b/clib/bindings.sh new file mode 100644 index 0000000..3e143b8 --- /dev/null +++ b/clib/bindings.sh @@ -0,0 +1,2418 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +pub const CSP_ERR_NONE: u32 = 0; +pub const CSP_ERR_NOMEM: i32 = -1; +pub const CSP_ERR_INVAL: i32 = -2; +pub const CSP_ERR_TIMEDOUT: i32 = -3; +pub const CSP_ERR_USED: i32 = -4; +pub const CSP_ERR_NOTSUP: i32 = -5; +pub const CSP_ERR_BUSY: i32 = -6; +pub const CSP_ERR_ALREADY: i32 = -7; +pub const CSP_ERR_RESET: i32 = -8; +pub const CSP_ERR_NOBUFS: i32 = -9; +pub const CSP_ERR_TX: i32 = -10; +pub const CSP_ERR_DRIVER: i32 = -11; +pub const CSP_ERR_AGAIN: i32 = -12; +pub const CSP_ERR_NOSYS: i32 = -38; +pub const CSP_ERR_HMAC: i32 = -100; +pub const CSP_ERR_CRC32: i32 = -102; +pub const CSP_ERR_SFP: i32 = -103; +pub const CSP_POSIX: u32 = 1; +pub const CSP_ZEPHYR: u32 = 0; +pub const CSP_HAVE_STDIO: u32 = 1; +pub const CSP_ENABLE_CSP_PRINT: u32 = 1; +pub const CSP_PRINT_STDIO: u32 = 1; +pub const CSP_REPRODUCIBLE_BUILDS: u32 = 0; +pub const CSP_QFIFO_LEN: u32 = 15; +pub const CSP_PORT_MAX_BIND: u32 = 16; +pub const CSP_CONN_RXQUEUE_LEN: u32 = 16; +pub const CSP_CONN_MAX: u32 = 8; +pub const CSP_BUFFER_SIZE: u32 = 256; +pub const CSP_BUFFER_COUNT: u32 = 15; +pub const CSP_RDP_MAX_WINDOW: u32 = 5; +pub const CSP_RTABLE_SIZE: u32 = 10; +pub const CSP_USE_RDP: u32 = 1; +pub const CSP_USE_HMAC: u32 = 1; +pub const CSP_USE_PROMISC: u32 = 1; +pub const CSP_USE_RTABLE: u32 = 1; +pub const CSP_HAVE_LIBSOCKETCAN: u32 = 0; +pub const CSP_HAVE_LIBZMQ: u32 = 1; +pub const _INTTYPES_H: u32 = 1; +pub const _FEATURES_H: u32 = 1; +pub const _DEFAULT_SOURCE: u32 = 1; +pub const __GLIBC_USE_ISOC2X: u32 = 0; +pub const __USE_ISOC11: u32 = 1; +pub const __USE_ISOC99: u32 = 1; +pub const __USE_ISOC95: u32 = 1; +pub const __USE_POSIX_IMPLICITLY: u32 = 1; +pub const _POSIX_SOURCE: u32 = 1; +pub const _POSIX_C_SOURCE: u32 = 200809; +pub const __USE_POSIX: u32 = 1; +pub const __USE_POSIX2: u32 = 1; +pub const __USE_POSIX199309: u32 = 1; +pub const __USE_POSIX199506: u32 = 1; +pub const __USE_XOPEN2K: u32 = 1; +pub const __USE_XOPEN2K8: u32 = 1; +pub const _ATFILE_SOURCE: u32 = 1; +pub const __WORDSIZE: u32 = 64; +pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; +pub const __SYSCALL_WORDSIZE: u32 = 64; +pub const __TIMESIZE: u32 = 64; +pub const __USE_MISC: u32 = 1; +pub const __USE_ATFILE: u32 = 1; +pub const __USE_FORTIFY_LEVEL: u32 = 0; +pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; +pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0; +pub const _STDC_PREDEF_H: u32 = 1; +pub const __STDC_IEC_559__: u32 = 1; +pub const __STDC_IEC_60559_BFP__: u32 = 201404; +pub const __STDC_IEC_559_COMPLEX__: u32 = 1; +pub const __STDC_IEC_60559_COMPLEX__: u32 = 201404; +pub const __STDC_ISO_10646__: u32 = 201706; +pub const __GNU_LIBRARY__: u32 = 6; +pub const __GLIBC__: u32 = 2; +pub const __GLIBC_MINOR__: u32 = 35; +pub const _SYS_CDEFS_H: u32 = 1; +pub const __glibc_c99_flexarr_available: u32 = 1; +pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI: u32 = 0; +pub const __HAVE_GENERIC_SELECTION: u32 = 1; +pub const _STDINT_H: u32 = 1; +pub const __GLIBC_USE_LIB_EXT2: u32 = 0; +pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_BFP_EXT_C2X: u32 = 0; +pub const __GLIBC_USE_IEC_60559_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X: u32 = 0; +pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; +pub const _BITS_TYPES_H: u32 = 1; +pub const _BITS_TYPESIZES_H: u32 = 1; +pub const __OFF_T_MATCHES_OFF64_T: u32 = 1; +pub const __INO_T_MATCHES_INO64_T: u32 = 1; +pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1; +pub const __STATFS_MATCHES_STATFS64: u32 = 1; +pub const __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64: u32 = 1; +pub const __FD_SETSIZE: u32 = 1024; +pub const _BITS_TIME64_H: u32 = 1; +pub const _BITS_WCHAR_H: u32 = 1; +pub const _BITS_STDINT_INTN_H: u32 = 1; +pub const _BITS_STDINT_UINTN_H: u32 = 1; +pub const INT8_MIN: i32 = -128; +pub const INT16_MIN: i32 = -32768; +pub const INT32_MIN: i32 = -2147483648; +pub const INT8_MAX: u32 = 127; +pub const INT16_MAX: u32 = 32767; +pub const INT32_MAX: u32 = 2147483647; +pub const UINT8_MAX: u32 = 255; +pub const UINT16_MAX: u32 = 65535; +pub const UINT32_MAX: u32 = 4294967295; +pub const INT_LEAST8_MIN: i32 = -128; +pub const INT_LEAST16_MIN: i32 = -32768; +pub const INT_LEAST32_MIN: i32 = -2147483648; +pub const INT_LEAST8_MAX: u32 = 127; +pub const INT_LEAST16_MAX: u32 = 32767; +pub const INT_LEAST32_MAX: u32 = 2147483647; +pub const UINT_LEAST8_MAX: u32 = 255; +pub const UINT_LEAST16_MAX: u32 = 65535; +pub const UINT_LEAST32_MAX: u32 = 4294967295; +pub const INT_FAST8_MIN: i32 = -128; +pub const INT_FAST16_MIN: i64 = -9223372036854775808; +pub const INT_FAST32_MIN: i64 = -9223372036854775808; +pub const INT_FAST8_MAX: u32 = 127; +pub const INT_FAST16_MAX: u64 = 9223372036854775807; +pub const INT_FAST32_MAX: u64 = 9223372036854775807; +pub const UINT_FAST8_MAX: u32 = 255; +pub const UINT_FAST16_MAX: i32 = -1; +pub const UINT_FAST32_MAX: i32 = -1; +pub const INTPTR_MIN: i64 = -9223372036854775808; +pub const INTPTR_MAX: u64 = 9223372036854775807; +pub const UINTPTR_MAX: i32 = -1; +pub const PTRDIFF_MIN: i64 = -9223372036854775808; +pub const PTRDIFF_MAX: u64 = 9223372036854775807; +pub const SIG_ATOMIC_MIN: i32 = -2147483648; +pub const SIG_ATOMIC_MAX: u32 = 2147483647; +pub const SIZE_MAX: i32 = -1; +pub const WINT_MIN: u32 = 0; +pub const WINT_MAX: u32 = 4294967295; +pub const ____gwchar_t_defined: u32 = 1; +pub const __PRI64_PREFIX: &[u8; 2] = b"l\0"; +pub const __PRIPTR_PREFIX: &[u8; 2] = b"l\0"; +pub const PRId8: &[u8; 2] = b"d\0"; +pub const PRId16: &[u8; 2] = b"d\0"; +pub const PRId32: &[u8; 2] = b"d\0"; +pub const PRId64: &[u8; 3] = b"ld\0"; +pub const PRIdLEAST8: &[u8; 2] = b"d\0"; +pub const PRIdLEAST16: &[u8; 2] = b"d\0"; +pub const PRIdLEAST32: &[u8; 2] = b"d\0"; +pub const PRIdLEAST64: &[u8; 3] = b"ld\0"; +pub const PRIdFAST8: &[u8; 2] = b"d\0"; +pub const PRIdFAST16: &[u8; 3] = b"ld\0"; +pub const PRIdFAST32: &[u8; 3] = b"ld\0"; +pub const PRIdFAST64: &[u8; 3] = b"ld\0"; +pub const PRIi8: &[u8; 2] = b"i\0"; +pub const PRIi16: &[u8; 2] = b"i\0"; +pub const PRIi32: &[u8; 2] = b"i\0"; +pub const PRIi64: &[u8; 3] = b"li\0"; +pub const PRIiLEAST8: &[u8; 2] = b"i\0"; +pub const PRIiLEAST16: &[u8; 2] = b"i\0"; +pub const PRIiLEAST32: &[u8; 2] = b"i\0"; +pub const PRIiLEAST64: &[u8; 3] = b"li\0"; +pub const PRIiFAST8: &[u8; 2] = b"i\0"; +pub const PRIiFAST16: &[u8; 3] = b"li\0"; +pub const PRIiFAST32: &[u8; 3] = b"li\0"; +pub const PRIiFAST64: &[u8; 3] = b"li\0"; +pub const PRIo8: &[u8; 2] = b"o\0"; +pub const PRIo16: &[u8; 2] = b"o\0"; +pub const PRIo32: &[u8; 2] = b"o\0"; +pub const PRIo64: &[u8; 3] = b"lo\0"; +pub const PRIoLEAST8: &[u8; 2] = b"o\0"; +pub const PRIoLEAST16: &[u8; 2] = b"o\0"; +pub const PRIoLEAST32: &[u8; 2] = b"o\0"; +pub const PRIoLEAST64: &[u8; 3] = b"lo\0"; +pub const PRIoFAST8: &[u8; 2] = b"o\0"; +pub const PRIoFAST16: &[u8; 3] = b"lo\0"; +pub const PRIoFAST32: &[u8; 3] = b"lo\0"; +pub const PRIoFAST64: &[u8; 3] = b"lo\0"; +pub const PRIu8: &[u8; 2] = b"u\0"; +pub const PRIu16: &[u8; 2] = b"u\0"; +pub const PRIu32: &[u8; 2] = b"u\0"; +pub const PRIu64: &[u8; 3] = b"lu\0"; +pub const PRIuLEAST8: &[u8; 2] = b"u\0"; +pub const PRIuLEAST16: &[u8; 2] = b"u\0"; +pub const PRIuLEAST32: &[u8; 2] = b"u\0"; +pub const PRIuLEAST64: &[u8; 3] = b"lu\0"; +pub const PRIuFAST8: &[u8; 2] = b"u\0"; +pub const PRIuFAST16: &[u8; 3] = b"lu\0"; +pub const PRIuFAST32: &[u8; 3] = b"lu\0"; +pub const PRIuFAST64: &[u8; 3] = b"lu\0"; +pub const PRIx8: &[u8; 2] = b"x\0"; +pub const PRIx16: &[u8; 2] = b"x\0"; +pub const PRIx32: &[u8; 2] = b"x\0"; +pub const PRIx64: &[u8; 3] = b"lx\0"; +pub const PRIxLEAST8: &[u8; 2] = b"x\0"; +pub const PRIxLEAST16: &[u8; 2] = b"x\0"; +pub const PRIxLEAST32: &[u8; 2] = b"x\0"; +pub const PRIxLEAST64: &[u8; 3] = b"lx\0"; +pub const PRIxFAST8: &[u8; 2] = b"x\0"; +pub const PRIxFAST16: &[u8; 3] = b"lx\0"; +pub const PRIxFAST32: &[u8; 3] = b"lx\0"; +pub const PRIxFAST64: &[u8; 3] = b"lx\0"; +pub const PRIX8: &[u8; 2] = b"X\0"; +pub const PRIX16: &[u8; 2] = b"X\0"; +pub const PRIX32: &[u8; 2] = b"X\0"; +pub const PRIX64: &[u8; 3] = b"lX\0"; +pub const PRIXLEAST8: &[u8; 2] = b"X\0"; +pub const PRIXLEAST16: &[u8; 2] = b"X\0"; +pub const PRIXLEAST32: &[u8; 2] = b"X\0"; +pub const PRIXLEAST64: &[u8; 3] = b"lX\0"; +pub const PRIXFAST8: &[u8; 2] = b"X\0"; +pub const PRIXFAST16: &[u8; 3] = b"lX\0"; +pub const PRIXFAST32: &[u8; 3] = b"lX\0"; +pub const PRIXFAST64: &[u8; 3] = b"lX\0"; +pub const PRIdMAX: &[u8; 3] = b"ld\0"; +pub const PRIiMAX: &[u8; 3] = b"li\0"; +pub const PRIoMAX: &[u8; 3] = b"lo\0"; +pub const PRIuMAX: &[u8; 3] = b"lu\0"; +pub const PRIxMAX: &[u8; 3] = b"lx\0"; +pub const PRIXMAX: &[u8; 3] = b"lX\0"; +pub const PRIdPTR: &[u8; 3] = b"ld\0"; +pub const PRIiPTR: &[u8; 3] = b"li\0"; +pub const PRIoPTR: &[u8; 3] = b"lo\0"; +pub const PRIuPTR: &[u8; 3] = b"lu\0"; +pub const PRIxPTR: &[u8; 3] = b"lx\0"; +pub const PRIXPTR: &[u8; 3] = b"lX\0"; +pub const SCNd8: &[u8; 4] = b"hhd\0"; +pub const SCNd16: &[u8; 3] = b"hd\0"; +pub const SCNd32: &[u8; 2] = b"d\0"; +pub const SCNd64: &[u8; 3] = b"ld\0"; +pub const SCNdLEAST8: &[u8; 4] = b"hhd\0"; +pub const SCNdLEAST16: &[u8; 3] = b"hd\0"; +pub const SCNdLEAST32: &[u8; 2] = b"d\0"; +pub const SCNdLEAST64: &[u8; 3] = b"ld\0"; +pub const SCNdFAST8: &[u8; 4] = b"hhd\0"; +pub const SCNdFAST16: &[u8; 3] = b"ld\0"; +pub const SCNdFAST32: &[u8; 3] = b"ld\0"; +pub const SCNdFAST64: &[u8; 3] = b"ld\0"; +pub const SCNi8: &[u8; 4] = b"hhi\0"; +pub const SCNi16: &[u8; 3] = b"hi\0"; +pub const SCNi32: &[u8; 2] = b"i\0"; +pub const SCNi64: &[u8; 3] = b"li\0"; +pub const SCNiLEAST8: &[u8; 4] = b"hhi\0"; +pub const SCNiLEAST16: &[u8; 3] = b"hi\0"; +pub const SCNiLEAST32: &[u8; 2] = b"i\0"; +pub const SCNiLEAST64: &[u8; 3] = b"li\0"; +pub const SCNiFAST8: &[u8; 4] = b"hhi\0"; +pub const SCNiFAST16: &[u8; 3] = b"li\0"; +pub const SCNiFAST32: &[u8; 3] = b"li\0"; +pub const SCNiFAST64: &[u8; 3] = b"li\0"; +pub const SCNu8: &[u8; 4] = b"hhu\0"; +pub const SCNu16: &[u8; 3] = b"hu\0"; +pub const SCNu32: &[u8; 2] = b"u\0"; +pub const SCNu64: &[u8; 3] = b"lu\0"; +pub const SCNuLEAST8: &[u8; 4] = b"hhu\0"; +pub const SCNuLEAST16: &[u8; 3] = b"hu\0"; +pub const SCNuLEAST32: &[u8; 2] = b"u\0"; +pub const SCNuLEAST64: &[u8; 3] = b"lu\0"; +pub const SCNuFAST8: &[u8; 4] = b"hhu\0"; +pub const SCNuFAST16: &[u8; 3] = b"lu\0"; +pub const SCNuFAST32: &[u8; 3] = b"lu\0"; +pub const SCNuFAST64: &[u8; 3] = b"lu\0"; +pub const SCNo8: &[u8; 4] = b"hho\0"; +pub const SCNo16: &[u8; 3] = b"ho\0"; +pub const SCNo32: &[u8; 2] = b"o\0"; +pub const SCNo64: &[u8; 3] = b"lo\0"; +pub const SCNoLEAST8: &[u8; 4] = b"hho\0"; +pub const SCNoLEAST16: &[u8; 3] = b"ho\0"; +pub const SCNoLEAST32: &[u8; 2] = b"o\0"; +pub const SCNoLEAST64: &[u8; 3] = b"lo\0"; +pub const SCNoFAST8: &[u8; 4] = b"hho\0"; +pub const SCNoFAST16: &[u8; 3] = b"lo\0"; +pub const SCNoFAST32: &[u8; 3] = b"lo\0"; +pub const SCNoFAST64: &[u8; 3] = b"lo\0"; +pub const SCNx8: &[u8; 4] = b"hhx\0"; +pub const SCNx16: &[u8; 3] = b"hx\0"; +pub const SCNx32: &[u8; 2] = b"x\0"; +pub const SCNx64: &[u8; 3] = b"lx\0"; +pub const SCNxLEAST8: &[u8; 4] = b"hhx\0"; +pub const SCNxLEAST16: &[u8; 3] = b"hx\0"; +pub const SCNxLEAST32: &[u8; 2] = b"x\0"; +pub const SCNxLEAST64: &[u8; 3] = b"lx\0"; +pub const SCNxFAST8: &[u8; 4] = b"hhx\0"; +pub const SCNxFAST16: &[u8; 3] = b"lx\0"; +pub const SCNxFAST32: &[u8; 3] = b"lx\0"; +pub const SCNxFAST64: &[u8; 3] = b"lx\0"; +pub const SCNdMAX: &[u8; 3] = b"ld\0"; +pub const SCNiMAX: &[u8; 3] = b"li\0"; +pub const SCNoMAX: &[u8; 3] = b"lo\0"; +pub const SCNuMAX: &[u8; 3] = b"lu\0"; +pub const SCNxMAX: &[u8; 3] = b"lx\0"; +pub const SCNdPTR: &[u8; 3] = b"ld\0"; +pub const SCNiPTR: &[u8; 3] = b"li\0"; +pub const SCNoPTR: &[u8; 3] = b"lo\0"; +pub const SCNuPTR: &[u8; 3] = b"lu\0"; +pub const SCNxPTR: &[u8; 3] = b"lx\0"; +pub const CSP_DBG_ERR_CORRUPT_BUFFER: u32 = 1; +pub const CSP_DBG_ERR_MTU_EXCEEDED: u32 = 2; +pub const CSP_DBG_ERR_ALREADY_FREE: u32 = 3; +pub const CSP_DBG_ERR_REFCOUNT: u32 = 4; +pub const CSP_DBG_ERR_INVALID_RTABLE_ENTRY: u32 = 6; +pub const CSP_DBG_ERR_UNSUPPORTED: u32 = 7; +pub const CSP_DBG_ERR_INVALID_BIND_PORT: u32 = 8; +pub const CSP_DBG_ERR_PORT_ALREADY_IN_USE: u32 = 9; +pub const CSP_DBG_ERR_ALREADY_CLOSED: u32 = 10; +pub const CSP_DBG_ERR_INVALID_POINTER: u32 = 11; +pub const CSP_DBG_ERR_CLOCK_SET_FAIL: u32 = 12; +pub const CSP_DBG_CAN_ERR_FRAME_LOST: u32 = 1; +pub const CSP_DBG_CAN_ERR_RX_OVF: u32 = 2; +pub const CSP_DBG_CAN_ERR_RX_OUT: u32 = 3; +pub const CSP_DBG_CAN_ERR_SHORT_BEGIN: u32 = 4; +pub const CSP_DBG_CAN_ERR_INCOMPLETE: u32 = 5; +pub const CSP_DBG_CAN_ERR_UNKNOWN: u32 = 6; +pub const CSP_DBG_ETH_ERR_FRAME_LOST: u32 = 1; +pub const CSP_DBG_ETH_ERR_RX_OVF: u32 = 2; +pub const CSP_DBG_ETH_ERR_RX_OUT: u32 = 3; +pub const CSP_DBG_ETH_ERR_SHORT_BEGIN: u32 = 4; +pub const CSP_DBG_ETH_ERR_INCOMPLETE: u32 = 5; +pub const CSP_DBG_ETH_ERR_UNKNOWN: u32 = 6; +pub const __bool_true_false_are_defined: u32 = 1; +pub const true_: u32 = 1; +pub const false_: u32 = 0; +pub const CSP_QUEUE_OK: u32 = 0; +pub const CSP_QUEUE_ERROR: i32 = -1; +pub const CSP_ANY: u32 = 255; +pub const CSP_FRES1: u32 = 128; +pub const CSP_FRES2: u32 = 64; +pub const CSP_FRES3: u32 = 32; +pub const CSP_FFRAG: u32 = 16; +pub const CSP_FHMAC: u32 = 8; +pub const CSP_FRDP: u32 = 2; +pub const CSP_FCRC32: u32 = 1; +pub const CSP_SO_NONE: u32 = 0; +pub const CSP_SO_RDPREQ: u32 = 1; +pub const CSP_SO_RDPPROHIB: u32 = 2; +pub const CSP_SO_HMACREQ: u32 = 4; +pub const CSP_SO_HMACPROHIB: u32 = 8; +pub const CSP_SO_CRC32REQ: u32 = 64; +pub const CSP_SO_CRC32PROHIB: u32 = 128; +pub const CSP_SO_CONN_LESS: u32 = 256; +pub const CSP_SO_SAME: u32 = 32768; +pub const CSP_O_NONE: u32 = 0; +pub const CSP_O_RDP: u32 = 1; +pub const CSP_O_NORDP: u32 = 2; +pub const CSP_O_HMAC: u32 = 4; +pub const CSP_O_NOHMAC: u32 = 8; +pub const CSP_O_CRC32: u32 = 64; +pub const CSP_O_NOCRC32: u32 = 128; +pub const CSP_O_SAME: u32 = 32768; +pub const CSP_PACKET_PADDING_BYTES: u32 = 8; +pub const CSP_RDP_HEADER_SIZE: u32 = 5; +pub const CSP_HOSTNAME_LEN: u32 = 20; +pub const CSP_MODEL_LEN: u32 = 30; +pub const CSP_REBOOT_MAGIC: u32 = 2147975175; +pub const CSP_REBOOT_SHUTDOWN_MAGIC: u32 = 3521467034; +pub const CSP_IFLIST_NAME_MAX: u32 = 10; +pub const CSP_NO_VIA_ADDRESS: u32 = 65535; +pub const _STRING_H: u32 = 1; +pub const _BITS_TYPES_LOCALE_T_H: u32 = 1; +pub const _BITS_TYPES___LOCALE_T_H: u32 = 1; +pub const _STRINGS_H: u32 = 1; +pub const CSP_MAX_TIMEOUT: u32 = 4294967295; +pub const CSP_MAX_DELAY: u32 = 4294967295; +pub const CSP_INFINITY: u32 = 4294967295; +pub type __u_char = ::core::ffi::c_uchar; +pub type __u_short = ::core::ffi::c_ushort; +pub type __u_int = ::core::ffi::c_uint; +pub type __u_long = ::core::ffi::c_ulong; +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_long; +pub type __uint64_t = ::core::ffi::c_ulong; +pub type __int_least8_t = __int8_t; +pub type __uint_least8_t = __uint8_t; +pub type __int_least16_t = __int16_t; +pub type __uint_least16_t = __uint16_t; +pub type __int_least32_t = __int32_t; +pub type __uint_least32_t = __uint32_t; +pub type __int_least64_t = __int64_t; +pub type __uint_least64_t = __uint64_t; +pub type __quad_t = ::core::ffi::c_long; +pub type __u_quad_t = ::core::ffi::c_ulong; +pub type __intmax_t = ::core::ffi::c_long; +pub type __uintmax_t = ::core::ffi::c_ulong; +pub type __dev_t = ::core::ffi::c_ulong; +pub type __uid_t = ::core::ffi::c_uint; +pub type __gid_t = ::core::ffi::c_uint; +pub type __ino_t = ::core::ffi::c_ulong; +pub type __ino64_t = ::core::ffi::c_ulong; +pub type __mode_t = ::core::ffi::c_uint; +pub type __nlink_t = ::core::ffi::c_ulong; +pub type __off_t = ::core::ffi::c_long; +pub type __off64_t = ::core::ffi::c_long; +pub type __pid_t = ::core::ffi::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __fsid_t { + pub __val: [::core::ffi::c_int; 2usize], +} +#[test] +fn bindgen_test_layout___fsid_t() { + const UNINIT: ::core::mem::MaybeUninit<__fsid_t> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__fsid_t>(), + 8usize, + concat!("Size of: ", stringify!(__fsid_t)) + ); + assert_eq!( + ::core::mem::align_of::<__fsid_t>(), + 4usize, + concat!("Alignment of ", stringify!(__fsid_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__val) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__fsid_t), + "::", + stringify!(__val) + ) + ); +} +pub type __clock_t = ::core::ffi::c_long; +pub type __rlim_t = ::core::ffi::c_ulong; +pub type __rlim64_t = ::core::ffi::c_ulong; +pub type __id_t = ::core::ffi::c_uint; +pub type __time_t = ::core::ffi::c_long; +pub type __useconds_t = ::core::ffi::c_uint; +pub type __suseconds_t = ::core::ffi::c_long; +pub type __suseconds64_t = ::core::ffi::c_long; +pub type __daddr_t = ::core::ffi::c_int; +pub type __key_t = ::core::ffi::c_int; +pub type __clockid_t = ::core::ffi::c_int; +pub type __timer_t = *mut ::core::ffi::c_void; +pub type __blksize_t = ::core::ffi::c_long; +pub type __blkcnt_t = ::core::ffi::c_long; +pub type __blkcnt64_t = ::core::ffi::c_long; +pub type __fsblkcnt_t = ::core::ffi::c_ulong; +pub type __fsblkcnt64_t = ::core::ffi::c_ulong; +pub type __fsfilcnt_t = ::core::ffi::c_ulong; +pub type __fsfilcnt64_t = ::core::ffi::c_ulong; +pub type __fsword_t = ::core::ffi::c_long; +pub type __ssize_t = ::core::ffi::c_long; +pub type __syscall_slong_t = ::core::ffi::c_long; +pub type __syscall_ulong_t = ::core::ffi::c_ulong; +pub type __loff_t = __off64_t; +pub type __caddr_t = *mut ::core::ffi::c_char; +pub type __intptr_t = ::core::ffi::c_long; +pub type __socklen_t = ::core::ffi::c_uint; +pub type __sig_atomic_t = ::core::ffi::c_int; +pub type int_least8_t = __int_least8_t; +pub type int_least16_t = __int_least16_t; +pub type int_least32_t = __int_least32_t; +pub type int_least64_t = __int_least64_t; +pub type uint_least8_t = __uint_least8_t; +pub type uint_least16_t = __uint_least16_t; +pub type uint_least32_t = __uint_least32_t; +pub type uint_least64_t = __uint_least64_t; +pub type int_fast8_t = ::core::ffi::c_schar; +pub type int_fast16_t = ::core::ffi::c_long; +pub type int_fast32_t = ::core::ffi::c_long; +pub type int_fast64_t = ::core::ffi::c_long; +pub type uint_fast8_t = ::core::ffi::c_uchar; +pub type uint_fast16_t = ::core::ffi::c_ulong; +pub type uint_fast32_t = ::core::ffi::c_ulong; +pub type uint_fast64_t = ::core::ffi::c_ulong; +pub type intmax_t = __intmax_t; +pub type uintmax_t = __uintmax_t; +pub type __gwchar_t = ::core::ffi::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct imaxdiv_t { + pub quot: ::core::ffi::c_long, + pub rem: ::core::ffi::c_long, +} +#[test] +fn bindgen_test_layout_imaxdiv_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(imaxdiv_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(imaxdiv_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).quot) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(imaxdiv_t), + "::", + stringify!(quot) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rem) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(imaxdiv_t), + "::", + stringify!(rem) + ) + ); +} +extern "C" { + pub fn imaxabs(__n: intmax_t) -> intmax_t; +} +extern "C" { + pub fn imaxdiv(__numer: intmax_t, __denom: intmax_t) -> imaxdiv_t; +} +extern "C" { + pub fn strtoimax( + __nptr: *const ::core::ffi::c_char, + __endptr: *mut *mut ::core::ffi::c_char, + __base: ::core::ffi::c_int, + ) -> intmax_t; +} +extern "C" { + pub fn strtoumax( + __nptr: *const ::core::ffi::c_char, + __endptr: *mut *mut ::core::ffi::c_char, + __base: ::core::ffi::c_int, + ) -> uintmax_t; +} +extern "C" { + pub fn wcstoimax( + __nptr: *const __gwchar_t, + __endptr: *mut *mut __gwchar_t, + __base: ::core::ffi::c_int, + ) -> intmax_t; +} +extern "C" { + pub fn wcstoumax( + __nptr: *const __gwchar_t, + __endptr: *mut *mut __gwchar_t, + __base: ::core::ffi::c_int, + ) -> uintmax_t; +} +extern "C" { + #[doc = " Error counters"] + pub static mut csp_dbg_buffer_out: u8; +} +extern "C" { + pub static mut csp_dbg_conn_out: u8; +} +extern "C" { + pub static mut csp_dbg_conn_ovf: u8; +} +extern "C" { + pub static mut csp_dbg_conn_noroute: u8; +} +extern "C" { + pub static mut csp_dbg_inval_reply: u8; +} +extern "C" { + pub static mut csp_dbg_errno: u8; +} +extern "C" { + pub static mut csp_dbg_can_errno: u8; +} +extern "C" { + pub static mut csp_dbg_eth_errno: u8; +} +extern "C" { + pub static mut csp_dbg_rdp_print: u8; +} +extern "C" { + pub static mut csp_dbg_packet_print: u8; +} +extern "C" { + pub fn csp_print_func(fmt: *const ::core::ffi::c_char, ...); +} +pub type wchar_t = ::core::ffi::c_int; +#[repr(C)] +#[repr(align(16))] +#[derive(Debug, 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, +} +#[test] +fn bindgen_test_layout_max_align_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(max_align_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 16usize, + concat!("Alignment of ", stringify!(max_align_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__clang_max_align_nonce1) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(max_align_t), + "::", + stringify!(__clang_max_align_nonce1) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__clang_max_align_nonce2) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(max_align_t), + "::", + stringify!(__clang_max_align_nonce2) + ) + ); +} +pub type csp_queue_handle_t = *mut ::core::ffi::c_void; +pub type csp_static_queue_t = *mut ::core::ffi::c_void; +extern "C" { + pub fn csp_queue_create_static( + length: ::core::ffi::c_int, + item_size: usize, + buffer: *mut ::core::ffi::c_char, + queue: *mut csp_static_queue_t, + ) -> csp_queue_handle_t; +} +extern "C" { + #[doc = " Enqueue (back) value.\n\n @param[in] handle queue.\n @param[in] value value to add (by copy)\n @param[in] timeout timeout, time to wait for free space\n @return #CSP_QUEUE_OK on success, otherwise a queue error code."] + pub fn csp_queue_enqueue( + handle: csp_queue_handle_t, + value: *const ::core::ffi::c_void, + timeout: u32, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Enqueue (back) value from ISR.\n\n @param[in] handle queue.\n @param[in] value value to add (by copy)\n @param[out] pxTaskWoken Valid reference if called from ISR, otherwise NULL!\n @return #CSP_QUEUE_OK on success, otherwise a queue error code."] + pub fn csp_queue_enqueue_isr( + handle: csp_queue_handle_t, + value: *const ::core::ffi::c_void, + pxTaskWoken: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Dequeue value (front).\n\n @param[in] handle queue.\n @param[out] buf extracted element (by copy).\n @param[in] timeout timeout, time to wait for element in queue.\n @return #CSP_QUEUE_OK on success, otherwise a queue error code."] + pub fn csp_queue_dequeue( + handle: csp_queue_handle_t, + buf: *mut ::core::ffi::c_void, + timeout: u32, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Dequeue value (front) from ISR.\n\n @param[in] handle queue.\n @param[out] buf extracted element (by copy).\n @param[out] pxTaskWoken Valid reference if called from ISR, otherwise NULL!\n @return #CSP_QUEUE_OK on success, otherwise a queue error code."] + pub fn csp_queue_dequeue_isr( + handle: csp_queue_handle_t, + buf: *mut ::core::ffi::c_void, + pxTaskWoken: *mut ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Queue size.\n\n @param[in] handle handle queue.\n @return Number of elements in the queue."] + pub fn csp_queue_size(handle: csp_queue_handle_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Queue size from ISR.\n\n @param[in] handle handle queue.\n @return Number of elements in the queue."] + pub fn csp_queue_size_isr(handle: csp_queue_handle_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Free queue object (handle).\n\n @param[in] handle handle queue."] + pub fn csp_queue_free(handle: csp_queue_handle_t) -> ::core::ffi::c_int; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_timestamp_t { + pub tv_sec: u32, + pub tv_nsec: u32, +} +#[test] +fn bindgen_test_layout_csp_timestamp_t() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(csp_timestamp_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(csp_timestamp_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_timestamp_t), + "::", + stringify!(tv_sec) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tv_nsec) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_timestamp_t), + "::", + stringify!(tv_nsec) + ) + ); +} +pub const csp_service_port_t_CSP_CMP: csp_service_port_t = 0; +pub const csp_service_port_t_CSP_PING: csp_service_port_t = 1; +pub const csp_service_port_t_CSP_PS: csp_service_port_t = 2; +pub const csp_service_port_t_CSP_MEMFREE: csp_service_port_t = 3; +pub const csp_service_port_t_CSP_REBOOT: csp_service_port_t = 4; +pub const csp_service_port_t_CSP_BUF_FREE: csp_service_port_t = 5; +pub const csp_service_port_t_CSP_UPTIME: csp_service_port_t = 6; +#[doc = " Reserved ports for CSP services."] +pub type csp_service_port_t = ::core::ffi::c_uint; +#[doc = "!< Critical"] +pub const csp_prio_t_CSP_PRIO_CRITICAL: csp_prio_t = 0; +#[doc = "!< High"] +pub const csp_prio_t_CSP_PRIO_HIGH: csp_prio_t = 1; +#[doc = "!< Normal (default)"] +pub const csp_prio_t_CSP_PRIO_NORM: csp_prio_t = 2; +#[doc = "!< Low"] +pub const csp_prio_t_CSP_PRIO_LOW: csp_prio_t = 3; +#[doc = "Message priority."] +pub type csp_prio_t = ::core::ffi::c_uint; +#[doc = "CSP identifier/header."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __packed { + pub pri: u8, + pub flags: u8, + pub src: u16, + pub dst: u16, + pub dport: u8, + pub sport: u8, +} +#[test] +fn bindgen_test_layout___packed() { + const UNINIT: ::core::mem::MaybeUninit<__packed> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__packed>(), + 8usize, + concat!("Size of: ", stringify!(__packed)) + ); + assert_eq!( + ::core::mem::align_of::<__packed>(), + 2usize, + concat!("Alignment of ", stringify!(__packed)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).pri) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(pri) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).src) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(src) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).dst) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(dst) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).dport) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(dport) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sport) as usize - ptr as usize }, + 7usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(sport) + ) + ); +} +#[doc = "CSP identifier/header."] +pub type csp_id_t = __packed; +#[doc = " CSP Packet.\n\n This structure is constructed to fit with all interface and protocols to prevent the\n need to copy data (zero copy).\n\n .. note:: In most cases a CSP packet cannot be reused in case of send failure, because the\n \t\t\t lower layers may add additional data causing increased length (e.g. CRC32), convert\n \t\t\t the CSP id to different endian (e.g. I2C), etc.\n"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct csp_packet_s { + pub __bindgen_anon_1: csp_packet_s__bindgen_ty_1, + pub length: u16, + pub id: csp_id_t, + pub next: *mut csp_packet_s, + #[doc = " Additional header bytes, to prepend packed data before transmission\n This must be minimum 6 bytes to accomodate CSP 2.0. But some implementations\n require much more scratch working area for encryption for example.\n\n Ultimately after csp_id_pack() this area will be filled with the CSP header"] + pub header: [u8; 8usize], + pub __bindgen_anon_2: csp_packet_s__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union csp_packet_s__bindgen_ty_1 { + pub __bindgen_anon_1: csp_packet_s__bindgen_ty_1__bindgen_ty_1, + pub __bindgen_anon_2: csp_packet_s__bindgen_ty_1__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_packet_s__bindgen_ty_1__bindgen_ty_1 { + pub rdp_quarantine: u32, + pub timestamp_tx: u32, + pub timestamp_rx: u32, + pub conn: *mut csp_conn_s, +} +#[test] +fn bindgen_test_layout_csp_packet_s__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 24usize, + concat!( + "Size of: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rdp_quarantine) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(rdp_quarantine) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).timestamp_tx) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(timestamp_tx) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).timestamp_rx) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(timestamp_rx) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).conn) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(conn) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_packet_s__bindgen_ty_1__bindgen_ty_2 { + pub rx_count: u16, + pub remain: u16, + pub cfpid: u32, + pub last_used: u32, + pub frame_begin: *mut u8, + pub frame_length: u16, +} +#[test] +fn bindgen_test_layout_csp_packet_s__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 32usize, + concat!( + "Size of: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_count) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(rx_count) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).remain) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(remain) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).cfpid) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(cfpid) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).last_used) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(last_used) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).frame_begin) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(frame_begin) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).frame_length) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(frame_length) + ) + ); +} +#[test] +fn bindgen_test_layout_csp_packet_s__bindgen_ty_1() { + assert_eq!( + ::core::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(csp_packet_s__bindgen_ty_1)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_packet_s__bindgen_ty_1)) + ); +} +#[doc = " Data part of packet:"] +#[repr(C)] +#[derive(Copy, Clone)] +pub union csp_packet_s__bindgen_ty_2 { + pub data: [u8; 256usize], + pub data16: [u16; 128usize], + pub data32: [u32; 64usize], +} +#[test] +fn bindgen_test_layout_csp_packet_s__bindgen_ty_2() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 256usize, + concat!("Size of: ", stringify!(csp_packet_s__bindgen_ty_2)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(csp_packet_s__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_2), + "::", + stringify!(data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).data16) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_2), + "::", + stringify!(data16) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).data32) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_2), + "::", + stringify!(data32) + ) + ); +} +#[test] +fn bindgen_test_layout_csp_packet_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 320usize, + concat!("Size of: ", stringify!(csp_packet_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_packet_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(length) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 34usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(id) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(next) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).header) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(header) + ) + ); +} +#[doc = " CSP Packet.\n\n This structure is constructed to fit with all interface and protocols to prevent the\n need to copy data (zero copy).\n\n .. note:: In most cases a CSP packet cannot be reused in case of send failure, because the\n \t\t\t lower layers may add additional data causing increased length (e.g. CRC32), convert\n \t\t\t the CSP id to different endian (e.g. I2C), etc.\n"] +pub type csp_packet_t = csp_packet_s; +#[doc = " Forward declaration of CSP interface, see #csp_iface_s for details."] +pub type csp_iface_t = csp_iface_s; +pub type csp_callback_t = ::core::option::Option; +#[doc = " @brief Connection struct"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_socket_s { + pub rx_queue: csp_queue_handle_t, + pub rx_queue_static: csp_static_queue_t, + pub rx_queue_static_data: [::core::ffi::c_char; 128usize], + pub opts: u32, +} +#[test] +fn bindgen_test_layout_csp_socket_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 152usize, + concat!("Size of: ", stringify!(csp_socket_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_socket_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(rx_queue) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue_static) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(rx_queue_static) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue_static_data) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(rx_queue_static_data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).opts) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(opts) + ) + ); +} +#[doc = " Forward declaration of socket structure"] +pub type csp_socket_t = csp_socket_s; +#[doc = " Forward declaration of connection structure"] +pub type csp_conn_t = csp_conn_s; +#[doc = " Memory pointer"] +pub type csp_memptr_t = *mut ::core::ffi::c_void; +#[doc = " Const memory pointer"] +pub type csp_const_memptr_t = *const ::core::ffi::c_void; +#[doc = " Platform specific memory copy function."] +pub type csp_memcpy_fnc_t = ::core::option::Option< + unsafe extern "C" fn(arg1: csp_memptr_t, arg2: csp_const_memptr_t, arg3: usize) -> csp_memptr_t, +>; +extern "C" { + #[doc = " Get free buffer from task context.\n\n @param[in] unused OBSOLETE ignored field, csp packets have a fixed size now\n @return Buffer pointer to #csp_packet_t or NULL if no buffers available"] + pub fn csp_buffer_get(unused: usize) -> *mut csp_packet_t; +} +extern "C" { + #[doc = " Get free buffer (from ISR context).\n\n @param[in] unused OBSOLETE ignored field, csp packets have a fixed size now\n @return Buffer pointer to #csp_packet_t or NULL if no buffers available"] + pub fn csp_buffer_get_isr(unused: usize) -> *mut csp_packet_t; +} +extern "C" { + #[doc = " Free buffer (from task context).\n\n @param[in] buffer buffer to free. NULL is handled gracefully."] + pub fn csp_buffer_free(buffer: *mut ::core::ffi::c_void); +} +extern "C" { + #[doc = " Free buffer (from ISR context).\n\n @param[in] buffer buffer to free. NULL is handled gracefully."] + pub fn csp_buffer_free_isr(buffer: *mut ::core::ffi::c_void); +} +extern "C" { + #[doc = " Clone an existing buffer.\n The existing \\a buffer content is copied to the new buffer.\n\n @param[in] buffer buffer to clone.\n @return cloned buffer on success, or NULL on failure."] + pub fn csp_buffer_clone(buffer: *mut ::core::ffi::c_void) -> *mut ::core::ffi::c_void; +} +extern "C" { + #[doc = " Return number of remaining/free buffers.\n The number of buffers is set by csp_init().\n\n @return number of remaining/free buffers"] + pub fn csp_buffer_remaining() -> ::core::ffi::c_int; +} +extern "C" { + pub fn csp_buffer_init(); +} +extern "C" { + #[doc = " Increase reference counter of buffer.\n Use csp_buffer_free() to decrement\n @param[in] buffer buffer to increment. NULL is handled gracefully."] + pub fn csp_buffer_refc_inc(buffer: *mut ::core::ffi::c_void); +} +#[doc = " Interface Tx function.\n\n @return #CSP_ERR_NONE on success, otherwise an error code."] +pub type nexthop_t = ::core::option::Option< + unsafe extern "C" fn( + iface: *mut csp_iface_t, + via: u16, + packet: *mut csp_packet_t, + from_me: ::core::ffi::c_int, + ) -> ::core::ffi::c_int, +>; +#[doc = " This struct is referenced in documentation.\n Update doc when you change this."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_iface_s { + #[doc = "< Host address on this subnet"] + pub addr: u16, + #[doc = "< Subnet mask"] + pub netmask: u16, + #[doc = "< Name, max compare length is #CSP_IFLIST_NAME_MAX"] + pub name: *const ::core::ffi::c_char, + #[doc = "< Interface data, only known/used by the interface layer, e.g. state information."] + pub interface_data: *mut ::core::ffi::c_void, + #[doc = "< Driver data, only known/used by the driver layer, e.g. device/channel references."] + pub driver_data: *mut ::core::ffi::c_void, + #[doc = "< Next hop (Tx) function"] + pub nexthop: nexthop_t, + #[doc = "< Set default IF flag (CSP supports multiple defaults)"] + pub is_default: u8, + #[doc = "< Successfully transmitted packets"] + pub tx: u32, + #[doc = "< Successfully received packets"] + pub rx: u32, + #[doc = "< Transmit errors (packets)"] + pub tx_error: u32, + #[doc = "< Receive errors, e.g. too large message"] + pub rx_error: u32, + #[doc = "< Dropped packets"] + pub drop: u32, + #[doc = "< Authentication errors (packets)"] + pub autherr: u32, + #[doc = "< Frame format errors (packets)"] + pub frame: u32, + #[doc = "< Transmitted bytes"] + pub txbytes: u32, + #[doc = "< Received bytes"] + pub rxbytes: u32, + #[doc = "< Interrupts"] + pub irq: u32, + pub next: *mut csp_iface_s, +} +#[test] +fn bindgen_test_layout_csp_iface_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 96usize, + concat!("Size of: ", stringify!(csp_iface_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_iface_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).netmask) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(netmask) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).name) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(name) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).interface_data) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(interface_data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).driver_data) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(driver_data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).nexthop) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(nexthop) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).is_default) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(is_default) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tx) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(tx) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(rx) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tx_error) as usize - ptr as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(tx_error) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_error) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(rx_error) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).drop) as usize - ptr as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(drop) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).autherr) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(autherr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).frame) as usize - ptr as usize }, + 68usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(frame) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).txbytes) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(txbytes) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rxbytes) as usize - ptr as usize }, + 76usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(rxbytes) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).irq) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(irq) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(next) + ) + ); +} +extern "C" { + #[doc = " Inputs a new packet into the system.\n\n This function can be called from interface drivers (ISR) or tasks, to route and accept packets.\n\n .. note:: EXTREMELY IMPORTANT: \\a pxTaskWoken must ALWAYS be NULL if called from task, and ALWAYS\n\t\t\t be NON NULL if called from ISR. If this condition is met, this call is completely thread-safe\n\n This function is fire and forget, it returns void, meaning that the \\a packet will always be\n either accepted or dropped, so the memory will always be freed.\n\n @param[in] packet A pointer to the incoming packet\n @param[in] iface A pointer to the incoming interface TX function.\n @param[in] pxTaskWoken Valid reference if called from ISR, otherwise NULL!\n"] + pub fn csp_qfifo_write( + packet: *mut csp_packet_t, + iface: *mut csp_iface_t, + pxTaskWoken: *mut ::core::ffi::c_void, + ); +} +extern "C" { + #[doc = " Add interface to the list.\n\n @param[in] iface The interface must remain valid as long as the application is running.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_iflist_add(iface: *mut csp_iface_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Remove interface from the list.\n\n @param[in] ifc Interface to remove. NULL will be gracefully handled."] + pub fn csp_iflist_remove(ifc: *mut csp_iface_t); +} +extern "C" { + pub fn csp_iflist_get_by_name(name: *const ::core::ffi::c_char) -> *mut csp_iface_t; +} +extern "C" { + pub fn csp_iflist_get_by_addr(addr: u16) -> *mut csp_iface_t; +} +extern "C" { + pub fn csp_iflist_get_by_subnet(addr: u16, from: *mut csp_iface_t) -> *mut csp_iface_t; +} +extern "C" { + pub fn csp_iflist_get_by_isdfl(ifc: *mut csp_iface_t) -> *mut csp_iface_t; +} +extern "C" { + pub fn csp_iflist_get_by_index(idx: ::core::ffi::c_int) -> *mut csp_iface_t; +} +extern "C" { + pub fn csp_iflist_is_within_subnet(addr: u16, ifc: *mut csp_iface_t) -> ::core::ffi::c_int; +} +extern "C" { + pub fn csp_iflist_get() -> *mut csp_iface_t; +} +extern "C" { + #[doc = " Convert bytes to readable string"] + pub fn csp_bytesize( + bytes: ::core::ffi::c_ulong, + postfix: *mut ::core::ffi::c_char, + ) -> ::core::ffi::c_ulong; +} +extern "C" { + #[doc = " Runs over the list of interfaces, and if no default interface is found\n set default on ALL interfaces"] + pub fn csp_iflist_check_dfl(); +} +extern "C" { + pub fn csp_iflist_print(); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_route_s { + pub address: u16, + pub netmask: u16, + pub via: u16, + pub iface: *mut csp_iface_t, +} +#[test] +fn bindgen_test_layout_csp_route_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(csp_route_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_route_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).address) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_route_s), + "::", + stringify!(address) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).netmask) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(csp_route_s), + "::", + stringify!(netmask) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).via) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_route_s), + "::", + stringify!(via) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).iface) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_route_s), + "::", + stringify!(iface) + ) + ); +} +pub type csp_route_t = csp_route_s; +extern "C" { + #[doc = " Loop through routes backwards and find routes that match on addr and mask from start_route"] + pub fn csp_rtable_search_backward(start_route: *mut csp_route_t) -> *mut csp_route_t; +} +extern "C" { + pub fn csp_rtable_find_route(dest_address: u16) -> *mut csp_route_t; +} +extern "C" { + #[doc = " Set route to destination address/node.\n\n @param[in] dest_address destination address.\n @param[in]mask number of bits in netmask (set to -1 for maximum number of bits)\n @param[in] ifc interface.\n @param[in] via assosicated via address.\n @return #CSP_ERR_NONE on success, or an error code."] + pub fn csp_rtable_set( + dest_address: u16, + netmask: ::core::ffi::c_int, + ifc: *mut csp_iface_t, + via: u16, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Save routing table as a string (readable format).\n @see csp_rtable_load() for additional information, e.g. format.\n\n @param[out] buffer user supplied buffer.\n @param[in] buffer_size size of \\a buffer.\n @return #CSP_ERR_NONE on success, or an error code."] + pub fn csp_rtable_save( + buffer: *mut ::core::ffi::c_char, + buffer_size: usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Load routing table from a string.\n Table will be loaded on-top of existing routes, possibly overwriting existing entries.\n Format: \\[/mask] \\ [via][, next entry]\n Example: \"0/0 CAN, 8 KISS, 10 I2C 10\", same as \"0/0 CAN, 8/5 KISS, 10/5 I2C 10\".\n @see csp_rtable_save(), csp_rtable_clear(), csp_rtable_free()\n\n @param[in] rtable routing table (nul terminated)\n @return CSP_ERR or number of entries."] + pub fn csp_rtable_load(rtable: *const ::core::ffi::c_char) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Check string for valid routing elements.\n\n @param[in] rtable routing table (nul terminated)\n @return CSP_ERR or number of entries."] + pub fn csp_rtable_check(rtable: *const ::core::ffi::c_char) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Clear routing table and add loopback route.\n @see csp_rtable_free()"] + pub fn csp_rtable_clear(); +} +extern "C" { + #[doc = " Clear/free all entries in the routing table."] + pub fn csp_rtable_free(); +} +#[doc = " Iterator for looping through the routing table."] +pub type csp_rtable_iterator_t = ::core::option::Option< + unsafe extern "C" fn(ctx: *mut ::core::ffi::c_void, route: *mut csp_route_t) -> bool, +>; +extern "C" { + #[doc = " Iterate routing table."] + pub fn csp_rtable_iterate(iter: csp_rtable_iterator_t, ctx: *mut ::core::ffi::c_void); +} +extern "C" { + #[doc = " Print routing table"] + pub fn csp_rtable_print(); +} +extern "C" { + pub fn memcpy( + __dest: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_void; +} +extern "C" { + pub fn memmove( + __dest: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_void; +} +extern "C" { + pub fn memccpy( + __dest: *mut ::core::ffi::c_void, + __src: *const ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_void; +} +extern "C" { + pub fn memset( + __s: *mut ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_void; +} +extern "C" { + pub fn memcmp( + __s1: *const ::core::ffi::c_void, + __s2: *const ::core::ffi::c_void, + __n: ::core::ffi::c_ulong, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn __memcmpeq( + __s1: *const ::core::ffi::c_void, + __s2: *const ::core::ffi::c_void, + __n: usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn memchr( + __s: *const ::core::ffi::c_void, + __c: ::core::ffi::c_int, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_void; +} +extern "C" { + pub fn strcpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strncpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strcat( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strncat( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strcmp( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strncmp( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strcoll( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strxfrm( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> ::core::ffi::c_ulong; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __locale_struct { + pub __locales: [*mut __locale_data; 13usize], + pub __ctype_b: *const ::core::ffi::c_ushort, + pub __ctype_tolower: *const ::core::ffi::c_int, + pub __ctype_toupper: *const ::core::ffi::c_int, + pub __names: [*const ::core::ffi::c_char; 13usize], +} +#[test] +fn bindgen_test_layout___locale_struct() { + const UNINIT: ::core::mem::MaybeUninit<__locale_struct> = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::<__locale_struct>(), + 232usize, + concat!("Size of: ", stringify!(__locale_struct)) + ); + assert_eq!( + ::core::mem::align_of::<__locale_struct>(), + 8usize, + concat!("Alignment of ", stringify!(__locale_struct)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__locales) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__locale_struct), + "::", + stringify!(__locales) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__ctype_b) as usize - ptr as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(__locale_struct), + "::", + stringify!(__ctype_b) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__ctype_tolower) as usize - ptr as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(__locale_struct), + "::", + stringify!(__ctype_tolower) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__ctype_toupper) as usize - ptr as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(__locale_struct), + "::", + stringify!(__ctype_toupper) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).__names) as usize - ptr as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(__locale_struct), + "::", + stringify!(__names) + ) + ); +} +pub type __locale_t = *mut __locale_struct; +pub type locale_t = __locale_t; +extern "C" { + pub fn strcoll_l( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + __l: locale_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strxfrm_l( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: usize, + __l: locale_t, + ) -> usize; +} +extern "C" { + pub fn strdup(__s: *const ::core::ffi::c_char) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strndup( + __string: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strchr( + __s: *const ::core::ffi::c_char, + __c: ::core::ffi::c_int, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strrchr( + __s: *const ::core::ffi::c_char, + __c: ::core::ffi::c_int, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strcspn( + __s: *const ::core::ffi::c_char, + __reject: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_ulong; +} +extern "C" { + pub fn strspn( + __s: *const ::core::ffi::c_char, + __accept: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_ulong; +} +extern "C" { + pub fn strpbrk( + __s: *const ::core::ffi::c_char, + __accept: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strstr( + __haystack: *const ::core::ffi::c_char, + __needle: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strtok( + __s: *mut ::core::ffi::c_char, + __delim: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn __strtok_r( + __s: *mut ::core::ffi::c_char, + __delim: *const ::core::ffi::c_char, + __save_ptr: *mut *mut ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strtok_r( + __s: *mut ::core::ffi::c_char, + __delim: *const ::core::ffi::c_char, + __save_ptr: *mut *mut ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strlen(__s: *const ::core::ffi::c_char) -> ::core::ffi::c_ulong; +} +extern "C" { + pub fn strnlen(__string: *const ::core::ffi::c_char, __maxlen: usize) -> usize; +} +extern "C" { + pub fn strerror(__errnum: ::core::ffi::c_int) -> *mut ::core::ffi::c_char; +} +extern "C" { + #[link_name = "\u{1}__xpg_strerror_r"] + pub fn strerror_r( + __errnum: ::core::ffi::c_int, + __buf: *mut ::core::ffi::c_char, + __buflen: usize, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strerror_l(__errnum: ::core::ffi::c_int, __l: locale_t) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn bcmp( + __s1: *const ::core::ffi::c_void, + __s2: *const ::core::ffi::c_void, + __n: ::core::ffi::c_ulong, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn bcopy( + __src: *const ::core::ffi::c_void, + __dest: *mut ::core::ffi::c_void, + __n: ::core::ffi::c_ulong, + ); +} +extern "C" { + pub fn bzero(__s: *mut ::core::ffi::c_void, __n: ::core::ffi::c_ulong); +} +extern "C" { + pub fn index( + __s: *const ::core::ffi::c_char, + __c: ::core::ffi::c_int, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn rindex( + __s: *const ::core::ffi::c_char, + __c: ::core::ffi::c_int, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn ffs(__i: ::core::ffi::c_int) -> ::core::ffi::c_int; +} +extern "C" { + pub fn ffsl(__l: ::core::ffi::c_long) -> ::core::ffi::c_int; +} +extern "C" { + pub fn ffsll(__ll: ::core::ffi::c_longlong) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strcasecmp( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strncasecmp( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strcasecmp_l( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + __loc: locale_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn strncasecmp_l( + __s1: *const ::core::ffi::c_char, + __s2: *const ::core::ffi::c_char, + __n: usize, + __loc: locale_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + pub fn explicit_bzero(__s: *mut ::core::ffi::c_void, __n: usize); +} +extern "C" { + pub fn strsep( + __stringp: *mut *mut ::core::ffi::c_char, + __delim: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn strsignal(__sig: ::core::ffi::c_int) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn __stpcpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn stpcpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn __stpncpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: usize, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + pub fn stpncpy( + __dest: *mut ::core::ffi::c_char, + __src: *const ::core::ffi::c_char, + __n: ::core::ffi::c_ulong, + ) -> *mut ::core::ffi::c_char; +} +extern "C" { + #[doc = " Send data over a CSP connection.\n\n Data will be send in chunks of \\a mtu bytes. The MTU must be small enough to fit\n into a CSP packat + SFP header + other transport headers.\n\n csp_sfp_recv() or csp_sfp_recv_fp() can be used at the other end to receive data.\n\n This is usefull if you wish to send data stored in flash memory or another location, where standard memcpy() doesn't work.\n\n @param[in] conn established connection for sending SFP packets.\n @param[in] data data to send\n @param[in] datasize tsize of \\a data\n @param[in] mtu maximum transfer unit (bytes), max data chunk to send.\n @param[in] timeout unused as of CSP version 1.6\n @param[in] memcpyfcn memory copy function.\n @return #CSP_ERR_NONE on success, otherwise an error."] + pub fn csp_sfp_send_own_memcpy( + conn: *mut csp_conn_t, + data: *const ::core::ffi::c_void, + datasize: ::core::ffi::c_uint, + mtu: ::core::ffi::c_uint, + timeout: u32, + memcpyfcn: csp_memcpy_fnc_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Receive data over a CSP connection.\n\n This is the counterpart to the csp_sfp_send() and csp_sfp_send_own_memcpy().\n\n @param[in] conn established connection for receiving SFP packets.\n @param[out] dataout received data on success. Allocated with malloc(), so\n \t\t\t should be freed with free(). The pointer will be NULL on failure.\n @param[out] datasize size of received data.\n @param[in] timeout timeout in ms to wait for csp_read()\n @param[in] first_packet First packet of a SFP transfer.\n \t\t\t Use NULL to receive first packet on the connection.\n @return #CSP_ERR_NONE on success, otherwise an error."] + pub fn csp_sfp_recv_fp( + conn: *mut csp_conn_t, + dataout: *mut *mut ::core::ffi::c_void, + datasize: *mut ::core::ffi::c_int, + timeout: u32, + first_packet: *mut csp_packet_t, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Enable promiscuous packet queue.\n\n @param[in]queue_size: Size (max length) of queue for incoming packets.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_promisc_enable(queue_size: ::core::ffi::c_uint) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Disable promiscuous mode."] + pub fn csp_promisc_disable(); +} +extern "C" { + #[doc = " Get/dequeue packet from promiscuous packet queue.\n\n Returns the first packet from the promiscuous packet queue.\n\n @param[in] timeout Timeout in ms to wait for a packet.\n @return Packet (free with csp_buffer_free() or re-use packet), NULL on error or timeout."] + pub fn csp_promisc_read(timeout: u32) -> *mut csp_packet_t; +} +#[doc = "< Deduplication off"] +pub const csp_dedup_types_CSP_DEDUP_OFF: csp_dedup_types = 0; +#[doc = "< Deduplication on forwarding only"] +pub const csp_dedup_types_CSP_DEDUP_FWD: csp_dedup_types = 1; +#[doc = "< Deduplication on incomfing only"] +pub const csp_dedup_types_CSP_DEDUP_INCOMING: csp_dedup_types = 2; +#[doc = "< Deduplication on incoming and forwarding"] +pub const csp_dedup_types_CSP_DEDUP_ALL: csp_dedup_types = 3; +#[doc = " CSP Debug Types"] +pub type csp_dedup_types = ::core::ffi::c_uint; +#[doc = " CSP configuration."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_conf_s { + #[doc = "< Protocol version to use (either 1 or 2)"] + pub version: u8, + #[doc = "< Host name, returned by the #CSP_CMP_IDENT request"] + pub hostname: *const ::core::ffi::c_char, + #[doc = "< Model, returned by the #CSP_CMP_IDENT request"] + pub model: *const ::core::ffi::c_char, + #[doc = "< Revision, returned by the #CSP_CMP_IDENT request"] + pub revision: *const ::core::ffi::c_char, + #[doc = "< Default connection options. Options will always be or'ed onto new connections, see csp_connect()"] + pub conn_dfl_so: u32, + #[doc = "< Enable CSP deduplication. 0 = off, 1 = always on, 2 = only on forwarded packets,"] + pub dedup: u8, +} +#[test] +fn bindgen_test_layout_csp_conf_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(csp_conf_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_conf_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(version) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).hostname) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(hostname) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).model) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(model) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).revision) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(revision) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).conn_dfl_so) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(conn_dfl_so) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).dedup) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(csp_conf_s), + "::", + stringify!(dedup) + ) + ); +} +#[doc = " CSP configuration."] +pub type csp_conf_t = csp_conf_s; +extern "C" { + pub static mut csp_conf: csp_conf_t; +} +extern "C" { + #[doc = " Initialize CSP.\n This will configure basic structures."] + pub fn csp_init(); +} +extern "C" { + #[doc = " Free allocated resorces in CSP.\n This is intended for testing of CSP, in order to be able re-initialize CSP by calling csp_init() again."] + pub fn csp_free_resources(); +} +extern "C" { + #[doc = " Get a \\a read-only reference to the active CSP configuration.\n\n @return Active CSP configuration (read-only)."] + pub fn csp_get_conf() -> *const csp_conf_t; +} +extern "C" { + #[doc = " Copy csp id fields from source to target object"] + pub fn csp_id_copy(target: *mut csp_id_t, source: *mut csp_id_t); +} +extern "C" { + #[doc = " Wait/accept a new connection.\n\n @param[in] socket socket to accept connections on, created by calling csp_socket().\n @param[in] timeout timeout in mS to wait for a connection, use CSP_MAX_TIMEOUT for infinite timeout.\n @return New connection on success, NULL on failure or timeout."] + pub fn csp_accept(socket: *mut csp_socket_t, timeout: u32) -> *mut csp_conn_t; +} +extern "C" { + #[doc = " Read packet from a connection.\n This fuction will wait on the connection's RX queue for the specified timeout.\n\n @param[in] conn connection\n @param[in] timeout timeout in mS to wait for a packet, use CSP_MAX_TIMEOUT for infinite timeout.\n @return Packet or NULL in case of failure or timeout."] + pub fn csp_read(conn: *mut csp_conn_t, timeout: u32) -> *mut csp_packet_t; +} +extern "C" { + #[doc = " Send packet on a connection.\n The packet buffer is automatically freed, and cannot be used after the call to csp_send()\n\n @param[in] conn connection\n @param[in] packet packet to send"] + pub fn csp_send(conn: *mut csp_conn_t, packet: *mut csp_packet_t); +} +extern "C" { + #[doc = " Change the default priority of the connection and send a packet.\n\n .. note:: The priority of the connection will be changed.\n If you need to change it back, call csp_send_prio() again.\n\n @param[in] prio priority to set on the connection\n @param[in] conn connection\n @param[in] packet packet to send"] + pub fn csp_send_prio(prio: u8, conn: *mut csp_conn_t, packet: *mut csp_packet_t); +} +extern "C" { + #[doc = " Perform an entire request & reply transaction.\n Creates a connection, send \\a outbuf, wait for reply, copy reply to \\a inbuf and close the connection.\n\n @param[in] prio priority, see #csp_prio_t\n @param[in] dst destination address\n @param[in] dst_port destination port\n @param[in] timeout timeout in mS to wait for a reply\n @param[in] outbuf outgoing data (request)\n @param[in] outlen length of data in \\a outbuf (request)\n @param[out] inbuf user provided buffer for receiving data (reply)\n @param[in] inlen length of expected reply, -1 for unknown size (inbuf MUST be large enough), 0 for no reply.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n\n Returns:\n int: 1 or reply size on success, 0 on failure (error, incoming length does not match, timeout)"] + pub fn csp_transaction_w_opts( + prio: u8, + dst: u16, + dst_port: u8, + timeout: u32, + outbuf: *mut ::core::ffi::c_void, + outlen: ::core::ffi::c_int, + inbuf: *mut ::core::ffi::c_void, + inlen: ::core::ffi::c_int, + opts: u32, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Perform an entire request & reply transaction on an existing connection.\n Send \\a outbuf, wait for reply and copy reply to \\a inbuf.\n\n @param[in] conn connection\n @param[in] timeout timeout in mS to wait for a reply\n @param[in] outbuf outgoing data (request)\n @param[in] outlen length of data in \\a outbuf (request)\n @param[out] inbuf user provided buffer for receiving data (reply)\n @param[in] inlen length of expected reply, -1 for unknown size (inbuf MUST be large enough), 0 for no reply.\n @return 1 or reply size on success, 0 on failure (error, incoming length does not match, timeout)"] + pub fn csp_transaction_persistent( + conn: *mut csp_conn_t, + timeout: u32, + outbuf: *mut ::core::ffi::c_void, + outlen: ::core::ffi::c_int, + inbuf: *mut ::core::ffi::c_void, + inlen: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Read data from a connection-less server socket.\n\n @param[in] socket connection-less socket.\n @param[in] timeout timeout in mS to wait for a packet, use #CSP_MAX_TIMEOUT for infinite timeout.\n @return Packet on success, or NULL on failure or timeout."] + pub fn csp_recvfrom(socket: *mut csp_socket_t, timeout: u32) -> *mut csp_packet_t; +} +extern "C" { + #[doc = " Send a packet (without connection).\n\n @param[in] prio packet priority, see #csp_prio_t\n @param[in] dst destination address\n @param[in] dst_port destination port\n @param[in] src_port source port\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n @param[in] packet packet to send"] + pub fn csp_sendto( + prio: u8, + dst: u16, + dst_port: u8, + src_port: u8, + opts: u32, + packet: *mut csp_packet_t, + ); +} +extern "C" { + #[doc = " Send a packet as a reply to a request (without a connection).\n Calls csp_sendto() with the source address and port from the request.\n\n @param[in] request incoming request\n @param[out] reply reply packet\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS."] + pub fn csp_sendto_reply(request: *const csp_packet_t, reply: *mut csp_packet_t, opts: u32); +} +extern "C" { + #[doc = " Establish outgoing connection.\n The call will return immediately, unless it is a RDP connection (#CSP_O_RDP) in which case it will wait until the other\n end acknowleges the connection (timeout is determined by the current connection timeout set by csp_rdp_set_opt()).\n\n @param[in] prio priority, see #csp_prio_t\n @param[in] dst Destination address\n @param[in] dst_port Destination port\n @param[in] timeout unused.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n @return Established connection or NULL on failure (no free connections, timeout)."] + pub fn csp_connect( + prio: u8, + dst: u16, + dst_port: u8, + timeout: u32, + opts: u32, + ) -> *mut csp_conn_t; +} +extern "C" { + #[doc = " Close an open connection.\n Any packets in the RX queue will be freed.\n\n @param[in] conn connection. Closing a NULL connection is acceptable.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_close(conn: *mut csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Close a socket, freeing it's RX queue and unbinding it from the associated\n port.\n\n @param[in] sock Socket\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_socket_close(sock: *mut csp_socket_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Return destination port of connection.\n\n @param[in] conn connection\n @return destination port of an incoming connection"] + pub fn csp_conn_dport(conn: *mut csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Return source port of connection.\n\n @param[in] conn connection\n @return source port of an incoming connection"] + pub fn csp_conn_sport(conn: *mut csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Return destination address of connection.\n\n @param[in] conn connection\n @return destination address of an incoming connection"] + pub fn csp_conn_dst(conn: *mut csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Return source address of connection.\n\n @param[in] conn connection\n @return source address of an incoming connection"] + pub fn csp_conn_src(conn: *mut csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Return flags of connection.\n\n @param[in] conn connection\n @return flags of an incoming connection, see @ref CSP_HEADER_FLAGS"] + pub fn csp_conn_flags(conn: *mut csp_conn_t) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Set socket to listen for incoming connections.\n\n @param[in] socket socket\n @param[in] backlog max length of backlog queue. The backlog queue holds incoming connections, waiting to be returned by call to csp_accept().\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_listen(socket: *mut csp_socket_t, backlog: usize) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Bind port to socket.\n\n @param[in] socket socket to bind port to\n @param[in] port port number to bind, use #CSP_ANY for all ports. Bindnig to a specific will take precedence over #CSP_ANY.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_bind(socket: *mut csp_socket_t, port: u8) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Bind port to callback function.\n\n @param[in] callback pointer to callback function\n @param[in] port port number to bind, use #CSP_ANY for all ports. Bindnig to a specific will take precedence over #CSP_ANY.\n @return 0 on success, otherwise an error code."] + pub fn csp_bind_callback(callback: csp_callback_t, port: u8) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Route packet from the incoming router queue and check RDP timeouts.\n In order for incoming packets to routed and RDP timeouts to be checked, this function must be called reguarly.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_route_work() -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Set the bridge interfaces.\n\n @param[in] if_a CSP Interface `A`\n @param[in] if_b CSP Interface `B`"] + pub fn csp_bridge_set_interfaces(if_a: *mut csp_iface_t, if_b: *mut csp_iface_t); +} +extern "C" { + #[doc = " Bridge packet from an interface to the other."] + pub fn csp_bridge_work(); +} +extern "C" { + #[doc = " Handle CSP service request.\n If the given packet is a service-request (the destination port matches one of CSP service ports #csp_service_port_t),\n the packet will be processed by the specific CSP service handler.\n The packet will either process it or free it, so this function is typically called in the last \"default\" clause of\n a switch/case statement in a CSP listener task.\n In order to listen to csp service ports, bind your listener to the specific services ports #csp_service_port_t or\n use #CSP_ANY to all ports.\n\n @param[in] packet first packet, obtained by using csp_read()"] + pub fn csp_service_handler(packet: *mut csp_packet_t); +} +extern "C" { + #[doc = " Send a single ping/echo packet.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in ms to wait for reply.\n @param[in] size payload size in bytes.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n @return >=0 echo time in mS on success, otherwise -1 for error."] + pub fn csp_ping( + node: u16, + timeout: u32, + size: ::core::ffi::c_uint, + opts: u8, + ) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Send a single ping/echo packet without waiting for reply.\n Payload is 1 byte.\n\n @param[in] node address of subsystem."] + pub fn csp_ping_noreply(node: u16); +} +extern "C" { + #[doc = " Request process list.\n\n .. note:: This is currently only supported on FreeRTOS systems.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for replies. The function will not return until the timeout occurrs."] + pub fn csp_ps(node: u16, timeout: u32); +} +extern "C" { + #[doc = " Request free memory.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] size free memory on subsystem.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_get_memfree(node: u16, timeout: u32, size: *mut u32) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Request free memory and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply."] + pub fn csp_memfree(node: u16, timeout: u32); +} +extern "C" { + #[doc = " Request free buffers.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] size free buffers.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_get_buf_free(node: u16, timeout: u32, size: *mut u32) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Request free buffers and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply."] + pub fn csp_buf_free(node: u16, timeout: u32); +} +extern "C" { + #[doc = " Reboot subsystem.\n If handled by the standard CSP service handler, the reboot handler set by csp_sys_set_reboot() on the subsystem, will be invoked.\n\n @param[in] node address of subsystem.\n"] + pub fn csp_reboot(node: u16); +} +extern "C" { + #[doc = " Shutdown subsystem.\n If handled by the standard CSP service handler, the shutdown handler set by csp_sys_set_shutdown() on the subsystem, will be invoked.\n\n @param[in] node address of subsystem.\n"] + pub fn csp_shutdown(node: u16); +} +extern "C" { + #[doc = " Request uptime and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n"] + pub fn csp_uptime(node: u16, timeout: u32); +} +extern "C" { + #[doc = " Request uptime\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] uptime uptime in seconds.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_get_uptime(node: u16, timeout: u32, uptime: *mut u32) -> ::core::ffi::c_int; +} +extern "C" { + #[doc = " Set RDP options.\n The RDP options are used from the connecting/client side. When a RDP connection\n is established, the client tranmits the options to the server.\n\n @param[in] window_size window size\n @param[in] conn_timeout_ms connection timeout in mS\n @param[in] packet_timeout_ms packet timeout in mS.\n @param[in] delayed_acks enable/disable delayed acknowledgements.\n @param[in] ack_timeout acknowledgement timeout when delayed ACKs is enabled\n @param[in] ack_delay_count send acknowledgement for every ack_delay_count packets.\n"] + pub fn csp_rdp_set_opt( + window_size: ::core::ffi::c_uint, + conn_timeout_ms: ::core::ffi::c_uint, + packet_timeout_ms: ::core::ffi::c_uint, + delayed_acks: ::core::ffi::c_uint, + ack_timeout: ::core::ffi::c_uint, + ack_delay_count: ::core::ffi::c_uint, + ); +} +extern "C" { + #[doc = " Get RDP options. @see csp_rdp_set_opt()\n\n @param[out] window_size Window size\n @param[out] conn_timeout_ms connection timeout in ms\n @param[out] packet_timeout_ms packet timeout in ms\n @param[out] delayed_acks enable/disable delayed acknowledgements\n @param[out] ack_timeout acknowledgement timeout when delayed ACKs is enabled\n @param[out] ack_delay_count send acknowledgement for every ack_delay_count packets"] + pub fn csp_rdp_get_opt( + window_size: *mut ::core::ffi::c_uint, + conn_timeout_ms: *mut ::core::ffi::c_uint, + packet_timeout_ms: *mut ::core::ffi::c_uint, + delayed_acks: *mut ::core::ffi::c_uint, + ack_timeout: *mut ::core::ffi::c_uint, + ack_delay_count: *mut ::core::ffi::c_uint, + ); +} +extern "C" { + #[doc = " Set platform specific memory copy function."] + pub fn csp_cmp_set_memcpy(fnc: csp_memcpy_fnc_t); +} +extern "C" { + #[doc = " Print connection table to stdout."] + pub fn csp_conn_print_table(); +} +extern "C" { + #[doc = " Hex dump memory to stdout.\n\n @param[in] desc description printed on first line.\n @param[in] addr memory address.\n @param[in] len number of bytes to dump, starting from \\a addr.\n"] + pub fn csp_hex_dump( + desc: *const ::core::ffi::c_char, + addr: *mut ::core::ffi::c_void, + len: ::core::ffi::c_int, + ); +} +extern "C" { + #[doc = " Print connection table to string."] + pub fn csp_conn_print_table_str( + str_buf: *mut ::core::ffi::c_char, + str_size: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_conn_s { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __locale_data { + pub _address: u8, +} diff --git a/clib/cfg/csp/autoconfig.h b/clib/cfg/csp/autoconfig.h new file mode 100644 index 0000000..2eadec9 --- /dev/null +++ b/clib/cfg/csp/autoconfig.h @@ -0,0 +1,25 @@ +// This file was auto-generated by libcsp-cargo-build v0.1.0 +#define CSP_POSIX 1 +#define CSP_ZEPHYR 0 + +#define CSP_HAVE_STDIO 1 +#define CSP_ENABLE_CSP_PRINT 1 +#define CSP_PRINT_STDIO 1 +#define CSP_REPRODUCIBLE_BUILDS 0 + +#define CSP_QFIFO_LEN 16 +#define CSP_PORT_MAX_BIND 16 +#define CSP_CONN_RXQUEUE_LEN 16 +#define CSP_CONN_MAX 8 +#define CSP_BUFFER_SIZE 256 +#define CSP_BUFFER_COUNT 15 +#define CSP_RDP_MAX_WINDOW 5 +#define CSP_RTABLE_SIZE 10 + +#define CSP_USE_RDP 1 +#define CSP_USE_HMAC 1 +#define CSP_USE_PROMISC 1 +#define CSP_USE_RTABLE 0 + +#define CSP_HAVE_LIBSOCKETCAN 0 +#define CSP_HAVE_LIBZMQ 0 diff --git a/clib/clone-csp.sh b/clib/clone-csp.sh new file mode 100755 index 0000000..e0b42bb --- /dev/null +++ b/clib/clone-csp.sh @@ -0,0 +1,3 @@ +#!/bin/bash +git clone https://github.com/us-irs/libcsp.git +git checkout const-correctness diff --git a/clib/gen-bindings.sh b/clib/gen-bindings.sh new file mode 100755 index 0000000..c0cfb0f --- /dev/null +++ b/clib/gen-bindings.sh @@ -0,0 +1,4 @@ +#!/bin/bash +bindgen_cmd="bindgen --use-core wrapper.h -- '-I./libcsp/include' '-I./cfg' '-I./libcsp/src' > bindings.rs" +echo "Running: $bindgen_cmd" +eval $bindgen_cmd diff --git a/clib/wrapper.h b/clib/wrapper.h new file mode 100644 index 0000000..727cc32 --- /dev/null +++ b/clib/wrapper.h @@ -0,0 +1,6 @@ +#include "csp/csp.h" +#include "csp/csp_hooks.h" +#include "csp_conn.h" + +#include "csp/interfaces/csp_if_lo.h" +#include "csp/interfaces/csp_if_udp.h" diff --git a/examples/.gitignore b/examples/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/examples/.gitignore @@ -0,0 +1 @@ +/target diff --git a/examples/Cargo.toml b/examples/Cargo.toml new file mode 100644 index 0000000..b065fb0 --- /dev/null +++ b/examples/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "libcsp-rust-examples" +version = "0.1.0" +edition = "2021" + +[dependencies] +libcsp = { path = "../libcsp" } + +[build-dependencies] +libcsp-cargo-build = { path = "../libcsp-cargo-build" } diff --git a/examples/autoconfig.h b/examples/autoconfig.h new file mode 100644 index 0000000..2eadec9 --- /dev/null +++ b/examples/autoconfig.h @@ -0,0 +1,25 @@ +// This file was auto-generated by libcsp-cargo-build v0.1.0 +#define CSP_POSIX 1 +#define CSP_ZEPHYR 0 + +#define CSP_HAVE_STDIO 1 +#define CSP_ENABLE_CSP_PRINT 1 +#define CSP_PRINT_STDIO 1 +#define CSP_REPRODUCIBLE_BUILDS 0 + +#define CSP_QFIFO_LEN 16 +#define CSP_PORT_MAX_BIND 16 +#define CSP_CONN_RXQUEUE_LEN 16 +#define CSP_CONN_MAX 8 +#define CSP_BUFFER_SIZE 256 +#define CSP_BUFFER_COUNT 15 +#define CSP_RDP_MAX_WINDOW 5 +#define CSP_RTABLE_SIZE 10 + +#define CSP_USE_RDP 1 +#define CSP_USE_HMAC 1 +#define CSP_USE_PROMISC 1 +#define CSP_USE_RTABLE 0 + +#define CSP_HAVE_LIBSOCKETCAN 0 +#define CSP_HAVE_LIBZMQ 0 diff --git a/examples/autoconfig.rs b/examples/autoconfig.rs new file mode 100644 index 0000000..0477874 --- /dev/null +++ b/examples/autoconfig.rs @@ -0,0 +1,8 @@ +// This file was auto-generated by libcsp-cargo-build v0.1.0 +pub const CSP_CONN_RXQUEUE_LEN: usize = 16; +pub const CSP_QFIFO_LEN: usize = 16; +pub const CSP_PORT_MAX_BIND: usize = 16; +pub const CSP_CONN_MAX: usize = 8; +pub const CSP_BUFFER_SIZE: usize = 256; +pub const CSP_RDP_MAX_WINDOW: usize = 5; +pub const CSP_RTABLE_SIZE: usize = 10; diff --git a/examples/build.rs b/examples/build.rs new file mode 100644 index 0000000..6d53417 --- /dev/null +++ b/examples/build.rs @@ -0,0 +1,38 @@ +use std::{env, path::PathBuf}; + +use libcsp_cargo_build::{generate_autoconf_header_file, Builder}; + +fn main() { + let out_dir = env::var("OUT_DIR").unwrap_or_default(); + let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap_or_default(); + let manifest_path = PathBuf::from(&manifest_dir); + let lib_cfg_dir = "../clib/cfg/csp"; + let libcsp_path = "../clib/libcsp"; + + // This helper structure will take care of the majority of work to compile libcsp using the + // cc crate. + let mut csp_builder = Builder::new(PathBuf::from(libcsp_path), PathBuf::from(&out_dir)); + // A lot of spam we are not interested in usually. + csp_builder.compiler_warnings = false; + + // We always re-generate the header file. + generate_autoconf_header_file(manifest_path.clone(), &csp_builder.cfg) + .expect("generating header file failed"); + + // Copy the file to lib/csp/cfg as well for binding generation. + std::fs::copy( + manifest_path.join("autoconfig.h"), + PathBuf::from(&lib_cfg_dir).join("autoconfig.h"), + ) + .expect("copying autoconfig.h failed"); + + // This file is required for the compile-time configuration of libcsp-rust. + csp_builder + .generate_autoconf_rust_file(manifest_path) + .expect("generating autoconfig.rs failed"); + + csp_builder.compile().expect("compiling libcsp failed"); + + // If we change the libcsp build configuration, we need to re-run the build. + println!("cargo::rerun-if-changed=build.rs"); +} diff --git a/examples/src/main.rs b/examples/src/main.rs new file mode 100644 index 0000000..1d5828c --- /dev/null +++ b/examples/src/main.rs @@ -0,0 +1,205 @@ +use std::{ + ffi::CStr, + sync::{ + atomic::{AtomicBool, AtomicU32}, + Arc, + }, + thread, + time::Duration, +}; + +use libcsp::{ + csp_accept_guarded, csp_bind, csp_buffer_get, csp_conn_dport, csp_conn_print_table, + csp_connect_guarded, csp_init, csp_listen, csp_ping, csp_read_guarded, csp_reboot, + csp_route_work, csp_send, csp_service_handler, iflist::csp_iflist_print, ConnectOpts, CspError, + CspSocket, MsgPriority, SocketFlags, CSP_ANY, CSP_LOOPBACK, +}; + +const MY_SERVER_PORT: i32 = 10; +const TEST_MODE: bool = false; +const RUN_DURATION_IN_SECS: u32 = 3; + +fn main() -> Result<(), u32> { + println!("CSP client/server example"); + + // SAFETY: We only call this once. + unsafe { csp_init() }; + + let stop_signal = Arc::new(AtomicBool::new(false)); + let stop_signal_server = stop_signal.clone(); + let stop_signal_client = stop_signal.clone(); + let stop_signal_router = stop_signal.clone(); + let server_received = Arc::new(AtomicU32::new(0)); + let server_recv_copy = server_received.clone(); + + let csp_router_jh = thread::spawn(move || loop { + if stop_signal_router.load(std::sync::atomic::Ordering::Relaxed) { + break; + } + if let Err(e) = csp_route_work() { + match e { + CspError::TimedOut => continue, + e => { + println!("CSP router error: {:?}", e); + break; + } + } + } + }); + + let csp_server_jh = thread::spawn(move || { + server(server_received, stop_signal_server); + }); + + let csp_client_jh = thread::spawn(move || { + client(stop_signal_client); + }); + + println!("CSP connection table"); + csp_conn_print_table(); + + println!("CSP interfaces"); + csp_iflist_print(); + let mut app_result = Ok(()); + // Wait for execution to end (ctrl+c) + loop { + std::thread::sleep(Duration::from_secs(RUN_DURATION_IN_SECS as u64)); + + if TEST_MODE { + // Test mode is intended for checking that host & client can exchange packets over loopback + let received_count = server_recv_copy.load(std::sync::atomic::Ordering::Relaxed); + println!("CSP: Server received {} packets", received_count); + if received_count < 5 { + app_result = Err(1); + } + stop_signal.store(true, std::sync::atomic::Ordering::Relaxed); + break; + } + } + + csp_router_jh.join().unwrap(); + csp_server_jh.join().unwrap(); + csp_client_jh.join().unwrap(); + app_result +} + +fn server(server_received: Arc, stop_signal: Arc) { + println!("server task started"); + + // Create socket with no specific socket options, e.g. accepts CRC32, HMAC, etc. if enabled + // during compilation + let mut csp_socket = CspSocket::default(); + + // Bind socket to all ports, e.g. all incoming connections will be handled here + csp_bind(&mut csp_socket, CSP_ANY); + + // Create a backlog of 10 connections, i.e. up to 10 new connections can be queued + csp_listen(&mut csp_socket, 10); + + // Wait for connections and then process packets on the connection + loop { + if stop_signal.load(std::sync::atomic::Ordering::Relaxed) { + break; + } + + // Wait for a new connection, 10000 mS timeout + let conn = csp_accept_guarded(&mut csp_socket, Duration::from_millis(10000)); + if conn.is_none() { + continue; + } + let mut conn = conn.unwrap(); + + // Read packets on connection, timout is 100 mS + loop { + if stop_signal.load(std::sync::atomic::Ordering::Relaxed) { + break; + } + + // Guarded packet is cleaned up automatically. + let packet = csp_read_guarded(&mut conn.0, Duration::from_millis(100)); + if packet.is_none() { + break; + } + let packet = packet.unwrap(); + match csp_conn_dport(&conn.0) { + MY_SERVER_PORT => { + server_received.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + let cstr = CStr::from_bytes_with_nul(packet.as_ref().packet_data()) + .expect("invalid packet data format, is not C string"); + // Process packet here. + println!("packet received on MY_SERVER_PORT: {:?}", cstr); + } + _ => { + csp_service_handler(packet.take()); + } + }; + } + // No need to close, we accepted the connection with a guard. + } +} + +fn client(stop_signal: Arc) { + println!("client task started"); + let mut current_letter = 'A'; + + loop { + if stop_signal.load(std::sync::atomic::Ordering::Relaxed) { + break; + } + if TEST_MODE { + thread::sleep(Duration::from_millis(20)); + } else { + thread::sleep(Duration::from_millis(100)); + } + + // Send ping to server, timeout 1000 mS, ping size 20 bytes + if let Err(e) = csp_ping( + CSP_LOOPBACK, + Duration::from_millis(1000), + 20, + SocketFlags::NONE, + ) { + println!("ping error: {:?}", e); + } + + // Send reboot request to server, the server has no actual implementation of + // csp_sys_reboot() and fails to reboot. + csp_reboot(CSP_LOOPBACK); + + // Send data packet (string) to server + + // 1. Connect to host on 'server_address', port MY_SERVER_PORT with regular UDP-like + // protocol and 1000 ms timeout. + let conn = csp_connect_guarded( + MsgPriority::Normal, + CSP_LOOPBACK, + MY_SERVER_PORT as u8, + Duration::from_millis(1000), + ConnectOpts::NONE, + ); + if conn.is_none() { + println!("CSP client: connection failed"); + return; + } + let mut conn = conn.unwrap(); + + // 2. Get packet buffer for message/data. + let packet_ref = csp_buffer_get(); + if packet_ref.is_none() { + println!("CSP client: failed to get CSP buffer"); + return; + } + let mut packet_mut = packet_ref.unwrap(); + + // 3. Copy data to packet. + let mut string_to_set = String::from("Hello world"); + string_to_set.push(' '); + string_to_set.push(current_letter); + current_letter = (current_letter as u8 + 1) as char; + string_to_set.push('\0'); + packet_mut.set_data(string_to_set.as_bytes()); + + // 4. Send data. + csp_send(&mut conn.0, packet_mut); + } +} diff --git a/libcsp-cargo-build/.gitignore b/libcsp-cargo-build/.gitignore new file mode 100644 index 0000000..4fffb2f --- /dev/null +++ b/libcsp-cargo-build/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/libcsp-cargo-build/CHANGELOG.md b/libcsp-cargo-build/CHANGELOG.md new file mode 100644 index 0000000..fd4480e --- /dev/null +++ b/libcsp-cargo-build/CHANGELOG.md @@ -0,0 +1,13 @@ +Change Log +======= + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +# [unreleased] + +# [v0.1.0] 2024-06-01 + +Initial release diff --git a/libcsp-cargo-build/Cargo.toml b/libcsp-cargo-build/Cargo.toml new file mode 100644 index 0000000..c96deec --- /dev/null +++ b/libcsp-cargo-build/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "libcsp-cargo-build" +version = "0.1.0" +edition = "2021" +description = "Tools to build libcsp using cargo" +homepage = "https://egit.irs.uni-stuttgart.de/rust/libcsp-rust" +repository = "https://egit.irs.uni-stuttgart.de/rust/libcsp-rust" +license = "Apache-2.0" +keywords = ["no-std", "space", "aerospace", "ffi", "csp"] +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +categories = ["aerospace", "external-ffi-bindings", "no-std", "hardware-support", "embedded"] + +[dependencies] +cc = "1" diff --git a/libcsp-cargo-build/LICENSE-APACHE b/libcsp-cargo-build/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/libcsp-cargo-build/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/libcsp-cargo-build/NOTICE b/libcsp-cargo-build/NOTICE new file mode 100644 index 0000000..717a583 --- /dev/null +++ b/libcsp-cargo-build/NOTICE @@ -0,0 +1 @@ +This software contains code developed at the University of Stuttgart's Institute of Space Systems. diff --git a/libcsp-cargo-build/README.md b/libcsp-cargo-build/README.md new file mode 100644 index 0000000..cf840f4 --- /dev/null +++ b/libcsp-cargo-build/README.md @@ -0,0 +1,9 @@ +libcsp-cargo-build +======== + +This crate provides a library to allow building the [`libcsp`](https://github.com/libcsp/libcsp) +with cargo. You can find some more high-level information and examples in the +[main workspace](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust). + +The API documentation should provide all additional advanced information you might require to tweak +the `libcsp` build. diff --git a/libcsp-cargo-build/src/lib.rs b/libcsp-cargo-build/src/lib.rs new file mode 100644 index 0000000..ecd2e2f --- /dev/null +++ b/libcsp-cargo-build/src/lib.rs @@ -0,0 +1,409 @@ +//! This crate provides a library to allow building the [`libcsp`](https://github.com/libcsp/libcsp) +//! C library with cargo. You can find some more high-level information and examples in the +//! [main repository](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust). +use std::{ + io::{self, Write}, + path::{Path, PathBuf}, +}; + +pub mod cfg_keys { + pub const POSIX: &str = "CSP_POSIX"; + pub const ZEPHYR: &str = "CSP_ZEPHYR"; + + pub const HAVE_STDIO: &str = "CSP_HAVE_STDIO"; + pub const ENABLE_CSP_PRINT: &str = "CSP_ENABLE_CSP_PRINT"; + pub const PRINT_STDIO: &str = "CSP_PRINT_STDIO"; + + pub const REPRODUCIBLE_BUILDS: &str = "CSP_REPRODUCIBLE_BUILDS"; + + pub const QFIFO_LEN: &str = "CSP_QFIFO_LEN"; + pub const PORT_MAX_BIND: &str = "CSP_PORT_MAX_BIND"; + pub const CONN_RXQUEUE_LEN: &str = "CSP_CONN_RXQUEUE_LEN"; + pub const CONN_MAX: &str = "CSP_CONN_MAX"; + pub const BUFFER_SIZE: &str = "CSP_BUFFER_SIZE"; + pub const BUFFER_COUNT: &str = "CSP_BUFFER_COUNT"; + pub const RDP_MAX_WINDOW: &str = "CSP_RDP_MAX_WINDOW"; + pub const RTABLE_SIZE: &str = "CSP_RTABLE_SIZE"; + + pub const USE_RDP: &str = "CSP_USE_RDP"; + pub const USE_HMAC: &str = "CSP_USE_HMAC"; + pub const USE_PROMISC: &str = "CSP_USE_PROMISC"; + pub const USE_RTABLE: &str = "CSP_USE_RTABLE"; + pub const HAVE_LIBSOCKETCAN: &str = "CSP_HAVE_LIBSOCKETCAN"; + pub const HAVE_LIBZMQ: &str = "CSP_HAVE_LIBZMQ"; +} + +const SRCS_LIST: &[&str] = &[ + "csp_bridge.c", + "csp_buffer.c", + "csp_crc32.c", + "csp_debug.c", + "csp_id.c", + "csp_iflist.c", + "csp_conn.c", + "csp_init.c", + "csp_io.c", + "csp_port.c", + "csp_promisc.c", + "csp_qfifo.c", + "csp_port.c", + "csp_route.c", + "csp_dedup.c", + "csp_services.c", + "csp_service_handler.c", + "interfaces/csp_if_lo.c", + "interfaces/csp_if_kiss.c", + "interfaces/csp_if_tun.c", + "interfaces/csp_if_udp.c", + "crypto/csp_hmac.c", + "crypto/csp_sha1.c", +]; + +const ARCH_SRCS_UNIX: &[&str] = &[ + "arch/posix/csp_clock.c", + "arch/posix/csp_semaphore.c", + "arch/posix/csp_system.c", + "arch/posix/csp_time.c", + "arch/posix/csp_queue.c", + "arch/posix/pthread_queue.c", +]; + +pub struct Config { + pub have_stdio: bool, + pub print_stdio: bool, + pub reproducible_builds: bool, + pub qfifo_len: u32, + pub port_max_bind: u32, + pub conn_rx_queue_len: u32, + pub conn_max: u32, + pub buffer_size: u32, + pub buffer_count: u32, + pub rdp_max_window: u32, + pub rtable_size: u32, + pub hmac: bool, + pub rtable: bool, + pub csp_print: bool, + pub promisc: bool, + pub rdp: bool, + pub yaml: bool, +} + +impl Default for Config { + fn default() -> Self { + Self { + have_stdio: true, + print_stdio: true, + reproducible_builds: false, + qfifo_len: 16, + port_max_bind: 16, + conn_rx_queue_len: 16, + conn_max: 8, + buffer_size: 256, + buffer_count: 15, + rdp_max_window: 5, + rtable_size: 10, + hmac: true, + rtable: false, + csp_print: true, + promisc: true, + rdp: true, + yaml: false, + } + } +} + +/// Primary builder structure used to compile the `libcsp` C library. +/// +/// The [Self::cfg] field can be used to configure the library build. The will also take care +/// of generating the autoconfig.h file required for the library configuration automatically based +/// on the build [Config]. An API is also provided to generate the autoconfig.rs file required +/// for compiling the [`libcsp-sys`](https://crates.io/crates/libcp-sys) Rust FFI bindings crate. +/// +/// ## Example +/// +/// The [example buildscript](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/examples/build.rs) +/// uses this builder structure to compile the library. +pub struct Builder { + generate_autoconf_file: bool, + libcsp_path: PathBuf, + libcsp_src_path_base: PathBuf, + out_dir: PathBuf, + pub cfg: Config, + pub compiler_warnings: bool, + build: cc::Build, +} + +impl Builder { + /// Create a new builder instance. + pub fn new(libcsp_path: PathBuf, out_dir: PathBuf) -> Self { + let mut libcsp_src_path_base = libcsp_path.clone(); + libcsp_src_path_base.push("src"); + Self { + generate_autoconf_file: true, + libcsp_path, + libcsp_src_path_base, + out_dir, + cfg: Default::default(), + compiler_warnings: true, + build: Default::default(), + } + } + + /// Access to the underlying [cc::Build] builder object. + pub fn cc(&mut self) -> &cc::Build { + &self.build + } + + /// Mutable access to the underlying [cc::Build] builder object. + pub fn cc_mut(&mut self) -> &mut cc::Build { + &mut self.build + } + + pub fn compile(&mut self) -> io::Result<()> { + if self.generate_autoconf_file { + self.generate_autoconf_header_file_default_location()?; + } + for src in SRCS_LIST { + let mut next_file = self.libcsp_src_path_base.clone(); + next_file.push(src); + self.build.file(next_file); + } + if self.cfg.rdp { + let mut next_file = self.libcsp_src_path_base.clone(); + next_file.push("csp_rdp.c"); + self.build.file(next_file); + let mut next_file = self.libcsp_src_path_base.clone(); + next_file.push("csp_rdp_queue.c"); + self.build.file(next_file); + } + if self.cfg.promisc { + let mut next_file = self.libcsp_src_path_base.clone(); + next_file.push("csp_promisc.c"); + self.build.file(next_file); + } + if self.cfg.csp_print { + let mut next_file = self.libcsp_src_path_base.clone(); + next_file.push("csp_hex_dump.c"); + self.build.file(next_file); + } + if self.cfg.yaml { + let mut next_file = self.libcsp_src_path_base.clone(); + next_file.push("csp_yaml.c"); + self.build.file(next_file); + } + if self.cfg.rtable { + let mut next_file = self.libcsp_src_path_base.clone(); + next_file.push("csp_rtable_cidr.c"); + self.build.file(next_file); + } + + // TODO: UNIX does not necesarilly mean POSIX? Details to deal with later.. + #[cfg(unix)] + self.posix_arch_files(); + + let mut inc_path = self.libcsp_path.clone(); + inc_path.push("include"); + self.build.include(inc_path); + self.build.include(&self.libcsp_src_path_base); + self.build.cargo_warnings(self.compiler_warnings); + + self.build.compile("csp"); + // TODO: We could generate some sort of information file which contains the + // compilation information and the version of hte library. + Ok(()) + } + + #[cfg(unix)] + fn posix_arch_files(&mut self) { + for src in ARCH_SRCS_UNIX { + let mut next_file = self.libcsp_src_path_base.clone(); + next_file.push(src); + self.build.file(next_file); + } + } + + pub fn generate_autoconf_header_file_default_location(&mut self) -> io::Result<()> { + let mut autoconf_dir = self.out_dir.join("cfg"); + self.build.include(&autoconf_dir); + autoconf_dir.push("csp"); + std::fs::create_dir_all(&autoconf_dir)?; + generate_autoconf_header_file(&autoconf_dir, &self.cfg) + } + + pub fn generate_autoconf_header_file(&mut self, dir: impl AsRef) -> io::Result<()> { + generate_autoconf_header_file(dir, &self.cfg) + } + + pub fn generate_autoconf_rust_file(&self, dir: impl AsRef) -> io::Result<()> { + generate_autoconf_rust_file(dir, &self.cfg) + } +} + +/// Generate the autoconfig.h file which is required to build the C library. This file contains +/// important configuration defines. +pub fn generate_autoconf_header_file(out_dir: impl AsRef, cfg: &Config) -> io::Result<()> { + let out_dir = out_dir.as_ref(); + let mut autoconf_file_string = String::new(); + let version = env!("CARGO_PKG_VERSION"); + let name = env!("CARGO_PKG_NAME"); + autoconf_file_string.push_str(&format!( + "// This file was auto-generated by {} v{}\n", + name, version + )); + #[cfg(unix)] + autoconf_file_string.push_str("#define CSP_POSIX 1\n"); + #[cfg(not(unix))] + autoconf_file_string.push_str("#define CSP_POSIX 0\n"); + autoconf_file_string.push_str("#define CSP_ZEPHYR 0\n"); + autoconf_file_string.push('\n'); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::HAVE_STDIO, + cfg.have_stdio as u32 + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::ENABLE_CSP_PRINT, + cfg.csp_print as u32 + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::PRINT_STDIO, + cfg.print_stdio as u32 + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::REPRODUCIBLE_BUILDS, + cfg.reproducible_builds as u32 + )); + autoconf_file_string.push('\n'); + + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::QFIFO_LEN, + cfg.qfifo_len + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::PORT_MAX_BIND, + cfg.port_max_bind + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::CONN_RXQUEUE_LEN, + cfg.conn_rx_queue_len + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::CONN_MAX, + cfg.conn_max + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::BUFFER_SIZE, + cfg.buffer_size + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::BUFFER_COUNT, + cfg.buffer_count + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::RDP_MAX_WINDOW, + cfg.rdp_max_window + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::RTABLE_SIZE, + cfg.rtable_size + )); + + autoconf_file_string.push('\n'); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::USE_RDP, + cfg.rdp as u32 + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::USE_HMAC, + cfg.hmac as u32 + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::USE_PROMISC, + cfg.promisc as u32 + )); + autoconf_file_string.push_str(&format!( + "#define {} {}\n", + cfg_keys::USE_RTABLE, + cfg.rtable as u32 + )); + + autoconf_file_string.push('\n'); + // TODO: Maybe those will be added at some point.. For now, they are hardcoded to 0. + autoconf_file_string.push_str(&format!("#define {} {}\n", cfg_keys::HAVE_LIBSOCKETCAN, 0)); + autoconf_file_string.push_str(&format!("#define {} {}\n", cfg_keys::HAVE_LIBZMQ, 0)); + let out_file = out_dir.join("autoconfig.h"); + let mut file = std::fs::File::create(out_file)?; + file.write_all(autoconf_file_string.as_bytes())?; + Ok(()) +} + +/// Generate the autoconfig.rs file which is required by the +/// [`libcsp-sys`](https://crates.io/crates/libcsp-sys) Rust bindings crate. +pub fn generate_autoconf_rust_file(out_dir: impl AsRef, cfg: &Config) -> io::Result<()> { + let out_dir = out_dir.as_ref(); + let mut autoconf_file_string = String::new(); + let version = env!("CARGO_PKG_VERSION"); + let name = env!("CARGO_PKG_NAME"); + autoconf_file_string.push_str(&format!( + "// This file was auto-generated by {} v{}\n", + name, version + )); + autoconf_file_string.push_str(&format!( + "pub const {}: usize = {};\n", + cfg_keys::CONN_RXQUEUE_LEN, + cfg.conn_rx_queue_len + )); + autoconf_file_string.push_str(&format!( + "pub const {}: usize = {};\n", + cfg_keys::QFIFO_LEN, + cfg.qfifo_len + )); + autoconf_file_string.push_str(&format!( + "pub const {}: usize = {};\n", + cfg_keys::PORT_MAX_BIND, + cfg.port_max_bind + )); + autoconf_file_string.push_str(&format!( + "pub const {}: usize = {};\n", + cfg_keys::CONN_MAX, + cfg.conn_max + )); + autoconf_file_string.push_str(&format!( + "pub const {}: usize = {};\n", + cfg_keys::BUFFER_SIZE, + cfg.buffer_size + )); + autoconf_file_string.push_str(&format!( + "pub const {}: usize = {};\n", + cfg_keys::RDP_MAX_WINDOW, + cfg.rdp_max_window + )); + autoconf_file_string.push_str(&format!( + "pub const {}: usize = {};\n", + cfg_keys::RTABLE_SIZE, + cfg.rtable_size + )); + let out_file = out_dir.join("autoconfig.rs"); + let mut file = std::fs::File::create(out_file)?; + file.write_all(autoconf_file_string.as_bytes())?; + Ok(()) +} + +#[cfg(test)] +mod tests { + // TODO: Unittest autoconf generators. +} diff --git a/libcsp-sys/CHANGELOG.md b/libcsp-sys/CHANGELOG.md new file mode 100644 index 0000000..fd4480e --- /dev/null +++ b/libcsp-sys/CHANGELOG.md @@ -0,0 +1,13 @@ +Change Log +======= + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +# [unreleased] + +# [v0.1.0] 2024-06-01 + +Initial release diff --git a/libcsp-sys/Cargo.toml b/libcsp-sys/Cargo.toml new file mode 100644 index 0000000..9e3f683 --- /dev/null +++ b/libcsp-sys/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "libcsp-sys" +version = "0.1.0" +edition = "2021" +authors = ["Robin Mueller "] +description = "FFI bindings for libcsp" +homepage = "https://egit.irs.uni-stuttgart.de/rust/libcsp-rust" +repository = "https://egit.irs.uni-stuttgart.de/rust/libcsp-rust" +license = "Apache-2.0" +keywords = ["no-std", "space", "aerospace", "ffi", "csp"] +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +categories = ["aerospace", "external-ffi-bindings", "no-std", "hardware-support", "embedded"] +links = "csp" + +[dependencies] +libc = "0.2" diff --git a/libcsp-sys/LICENSE-APACHE b/libcsp-sys/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/libcsp-sys/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/libcsp-sys/NOTICE b/libcsp-sys/NOTICE new file mode 100644 index 0000000..717a583 --- /dev/null +++ b/libcsp-sys/NOTICE @@ -0,0 +1 @@ +This software contains code developed at the University of Stuttgart's Institute of Space Systems. diff --git a/libcsp-sys/README.md b/libcsp-sys/README.md new file mode 100644 index 0000000..5f0d119 --- /dev/null +++ b/libcsp-sys/README.md @@ -0,0 +1,21 @@ +libcsp-sys +======== + +This crate provides FFI bindings for the [`libcsp` library](https://github.com/libcsp/libcsp). + +Generally, you probably do not want to use this library directly and instead use the +`libcsp` Rust crate which provides a safe and ergonomic Rust API. +You can find some more high-level information and examples in the +[main repository](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust). + +## Compile-time configuration of the `libcsp-rust` library + +The `libcsp-rust` library requires some compile-time configuration file to be included to work +properly. You can see an example version of the file for the workspace +[here](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/examples/autoconfig.rs). +The user has to provide the path to a directory containing this `autoconfig.rs` file using the +`CSP_CONFIG_DIR` environmental variable. + +It is recommended to read the [main workspace README](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust) +for more information to make the generation and specification of this auto-configuration file +as conveniently and easy as possible. diff --git a/libcsp-sys/build.rs b/libcsp-sys/build.rs new file mode 100644 index 0000000..cfe75de --- /dev/null +++ b/libcsp-sys/build.rs @@ -0,0 +1,31 @@ +use std::{env, path::PathBuf}; + +pub const ENV_KEY_CSP_CONFIG_DIR: &str = "CSP_CONFIG_DIR"; + +fn main() { + println!("cargo:rustc-link-lib=csp"); + + let out_path = env::var("OUT_DIR").unwrap(); + let csp_conf_dir = match env::var(ENV_KEY_CSP_CONFIG_DIR) { + Ok(conf_path) => conf_path, + Err(_e) => { + println!( + "cargo:warning={} not set, using CARGO_MANIFEST_DIR to search for autoconfig.rs", + ENV_KEY_CSP_CONFIG_DIR + ); + env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set") + } + }; + let mut csp_conf_path = PathBuf::new(); + csp_conf_path.push(csp_conf_dir); + csp_conf_path.push("autoconfig.rs"); + if !csp_conf_path.exists() { + panic!( + "autoconfig.rs not found at {:?}, is required for library build", + csp_conf_path + ); + } + let out_path_full = PathBuf::from(&out_path).join("autoconfig.rs"); + std::fs::copy(&csp_conf_path, out_path_full).expect("failed to copy autoconfig.rs to OUT_DIR"); + println!("cargo::rerun-if-changed={:?}", &csp_conf_path); +} diff --git a/libcsp-sys/src/config.rs b/libcsp-sys/src/config.rs new file mode 100644 index 0000000..1a8a24e --- /dev/null +++ b/libcsp-sys/src/config.rs @@ -0,0 +1,3 @@ +/// This environbment variable should be set by the user. If it is not set, the library will +/// try to find an autoconfig.rs file inside the CARGO_TARGET_DIR directory. +pub const ENV_KEY_CSP_CONFIG_DIR: &str = "CSP_CONFIG_DIR"; diff --git a/libcsp-sys/src/lib.rs b/libcsp-sys/src/lib.rs new file mode 100644 index 0000000..eee5b36 --- /dev/null +++ b/libcsp-sys/src/lib.rs @@ -0,0 +1,1399 @@ +//! This crate provides FFI bindings for the [`libcsp` library](https://github.com/libcsp/libcsp). + +//! Generally, you probably do not want to use this library directly and instead use the +//! [`libcsp`](https://crates.io/crates/libcsp) Rust crate which provides a safe and ergonomic Rust +//! API. +//! +//! You can find some more high-level information and examples in the +//! [main repository](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust). +//! +//! ## Compile-time configuration +//! +//! This library requires some compile-time configuration file to be included to work +//! properly. You can see an example version of the file for the workspace +//! [here](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/examples/autoconfig.rs). +//! The user has to provide the path to a directory containing this `autoconfig.rs` file using the +//! `CSP_CONFIG_DIR` environmental variable. +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +pub mod config; + +// This file will be created by the build script by copying a user-provided file to the output +// directory. It contains important compile time constants. Compilation of the library is not +// possible without these constants. +include!(concat!(env!("OUT_DIR"), "/autoconfig.rs")); + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_timestamp_t { + pub tv_sec: u32, + pub tv_nsec: u32, +} + +#[doc = "CSP identifier/header."] +#[repr(C)] +#[derive(Debug, Copy, Clone, Default)] +pub struct csp_id_t { + pub pri: u8, + pub flags: u8, + pub src: u16, + pub dst: u16, + pub dport: u8, + pub sport: u8, +} + +#[doc = " CSP Packet.\n\n This structure is constructed to fit with all interface and protocols to prevent the\n need to copy data (zero copy).\n\n .. note:: In most cases a CSP packet cannot be reused in case of send failure, because the\n \t\t\t lower layers may add additional data causing increased length (e.g. CRC32), convert\n \t\t\t the CSP id to different endian (e.g. I2C), etc.\n"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct csp_packet_s { + pub packet_info: csp_packet_s_anon_union, + pub length: u16, + pub id: csp_id_t, + pub next: *mut csp_packet_s, + #[doc = " Additional header bytes, to prepend packed data before transmission\n This must be minimum 6 bytes to accomodate CSP 2.0. But some implementations\n require much more scratch working area for encryption for example.\n\n Ultimately after csp_id_pack() this area will be filled with the CSP header"] + pub header: [u8; 8usize], + pub packet_data_union: csp_packet_s_data_union, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub union csp_packet_s_anon_union { + pub rdp_only: csp_packet_s_anon_union_field_rdp_only, + pub rx_tx_only: csp_packet_s_anon_union_field_rx_tx_only, +} + +impl Default for csp_packet_s_anon_union { + fn default() -> Self { + Self { + rdp_only: Default::default(), + } + } +} + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_packet_s_anon_union_field_rdp_only { + pub rdp_quarantine: u32, + pub timestamp_tx: u32, + pub timestamp_rx: u32, + pub conn: *mut csp_conn_s, +} + +impl Default for csp_packet_s_anon_union_field_rdp_only { + fn default() -> Self { + Self { + rdp_quarantine: Default::default(), + timestamp_tx: Default::default(), + timestamp_rx: Default::default(), + conn: core::ptr::null_mut(), + } + } +} + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_packet_s_anon_union_field_rx_tx_only { + pub rx_count: u16, + pub remain: u16, + pub cfpid: u32, + pub last_used: u32, + pub frame_begin: *mut u8, + pub frame_length: u16, +} + +impl Default for csp_packet_s_anon_union_field_rx_tx_only { + fn default() -> Self { + Self { + rx_count: Default::default(), + remain: Default::default(), + cfpid: Default::default(), + last_used: Default::default(), + frame_begin: core::ptr::null_mut(), + frame_length: Default::default(), + } + } +} + +#[doc = " Data part of packet:"] +#[repr(C)] +#[derive(Copy, Clone)] +pub union csp_packet_s_data_union { + pub data: [u8; CSP_BUFFER_SIZE], + pub data16: [u16; CSP_BUFFER_SIZE / 2usize], + pub data32: [u32; CSP_BUFFER_SIZE / 4usize], +} + +impl Default for csp_packet_s_data_union { + fn default() -> Self { + Self { + data: [0; CSP_BUFFER_SIZE], + } + } +} + +#[doc = " CSP Packet.\n\n This structure is constructed to fit with all interface and protocols to prevent the\n need to copy data (zero copy).\n\n .. note:: In most cases a CSP packet cannot be reused in case of send failure, because the\n \t\t\t lower layers may add additional data causing increased length (e.g. CRC32), convert\n \t\t\t the CSP id to different endian (e.g. I2C), etc.\n"] +pub type csp_packet_t = csp_packet_s; + +pub type csp_queue_handle_t = *mut core::ffi::c_void; +pub type csp_static_queue_t = *mut core::ffi::c_void; + +#[doc = " @brief Connection struct"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_socket_s { + pub rx_queue: csp_queue_handle_t, + pub rx_queue_static: csp_static_queue_t, + pub rx_queue_static_data: + [core::ffi::c_char; CSP_CONN_RXQUEUE_LEN * core::mem::size_of::<*const csp_packet_s>()], + pub opts: u32, +} + +impl Default for csp_socket_s { + fn default() -> Self { + Self { + rx_queue: core::ptr::null_mut(), + rx_queue_static: core::ptr::null_mut(), + rx_queue_static_data: [0; CSP_CONN_RXQUEUE_LEN + * core::mem::size_of::<*const csp_packet_s>()], + opts: Default::default(), + } + } +} + +#[doc = " Forward declaration of socket structure"] +pub type csp_socket_t = csp_socket_s; + +#[doc = " Forward declaration of connection structure"] +pub type csp_conn_t = csp_conn_s; + +pub type atomic_int = u32; + +#[doc = " Connection states"] +pub type csp_conn_state_t = ::core::ffi::c_uint; + +#[doc = " Connection types"] +pub type csp_conn_type_t = ::core::ffi::c_uint; + +#[doc = " RDP Connection states"] +pub type csp_rdp_state_t = ::core::ffi::c_uint; + +#[cfg(unix)] +pub type csp_bin_sem_t = libc::sem_t; + +#[doc = " RDP Connection"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct csp_rdp_t { + #[doc = "< Connection state"] + pub state: csp_rdp_state_t, + #[doc = "< Tracks 'who' have closed the RDP connection"] + pub closed_by: u8, + #[doc = "< The sequence number of the next segment that is to be sent"] + pub snd_nxt: u16, + #[doc = "< The sequence number of the oldest unacknowledged segment"] + pub snd_una: u16, + #[doc = "< The initial send sequence number"] + pub snd_iss: u16, + #[doc = "< The sequence number of the last segment received correctly and in sequence"] + pub rcv_cur: u16, + #[doc = "< The initial receive sequence number"] + pub rcv_irs: u16, + #[doc = "< The last sequence number acknowledged by the receiver"] + pub rcv_lsa: u16, + pub window_size: u32, + pub conn_timeout: u32, + pub packet_timeout: u32, + pub delayed_acks: u32, + pub ack_timeout: u32, + pub ack_delay_count: u32, + pub ack_timestamp: u32, + pub tx_wait: csp_bin_sem_t, +} + +#[doc = " @brief Connection struct"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct csp_conn_s { + pub type_: atomic_int, + pub state: atomic_int, + pub idin: csp_id_t, + pub idout: csp_id_t, + pub sport_outgoing: u8, + pub rx_queue: csp_queue_handle_t, + pub rx_queue_static: csp_static_queue_t, + pub rx_queue_static_data: + [core::ffi::c_char; CSP_CONN_RXQUEUE_LEN * core::mem::size_of::<*const csp_packet_s>()], + pub callback: ::core::option::Option, + pub dest_socket: *mut csp_socket_t, + pub timestamp: u32, + pub opts: u32, + pub rdp: csp_rdp_t, +} + +#[doc = " Interface Tx function.\n\n @return #CSP_ERR_NONE on success, otherwise an error code."] +pub type nexthop_t = ::core::option::Option< + unsafe extern "C" fn( + iface: *mut csp_iface_t, + via: u16, + packet: *mut csp_packet_t, + from_me: ::core::ffi::c_int, + ) -> ::core::ffi::c_int, +>; + +#[doc = " This struct is referenced in documentation.\n Update doc when you change this."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct csp_iface_s { + #[doc = "< Host address on this subnet"] + pub addr: u16, + #[doc = "< Subnet mask"] + pub netmask: u16, + #[doc = "< Name, max compare length is #CSP_IFLIST_NAME_MAX"] + pub name: *const ::core::ffi::c_char, + #[doc = "< Interface data, only known/used by the interface layer, e.g. state information."] + pub interface_data: *mut ::core::ffi::c_void, + #[doc = "< Driver data, only known/used by the driver layer, e.g. device/channel references."] + pub driver_data: *mut ::core::ffi::c_void, + #[doc = "< Next hop (Tx) function"] + pub nexthop: nexthop_t, + #[doc = "< Set default IF flag (CSP supports multiple defaults)"] + pub is_default: u8, + #[doc = "< Successfully transmitted packets"] + pub tx: u32, + #[doc = "< Successfully received packets"] + pub rx: u32, + #[doc = "< Transmit errors (packets)"] + pub tx_error: u32, + #[doc = "< Receive errors, e.g. too large message"] + pub rx_error: u32, + #[doc = "< Dropped packets"] + pub drop: u32, + #[doc = "< Authentication errors (packets)"] + pub autherr: u32, + #[doc = "< Frame format errors (packets)"] + pub frame: u32, + #[doc = "< Transmitted bytes"] + pub txbytes: u32, + #[doc = "< Received bytes"] + pub rxbytes: u32, + #[doc = "< Interrupts"] + pub irq: u32, + pub next: *mut csp_iface_s, +} + +impl Default for csp_iface_s { + fn default() -> Self { + Self { + addr: Default::default(), + netmask: Default::default(), + name: core::ptr::null(), + interface_data: core::ptr::null_mut(), + driver_data: core::ptr::null_mut(), + nexthop: None, + is_default: Default::default(), + tx: Default::default(), + rx: Default::default(), + tx_error: Default::default(), + rx_error: Default::default(), + drop: Default::default(), + autherr: Default::default(), + frame: Default::default(), + txbytes: Default::default(), + rxbytes: Default::default(), + irq: Default::default(), + next: core::ptr::null_mut(), + } + } +} + +#[doc = " Forward declaration of CSP interface, see #csp_iface_s for details."] +pub type csp_iface_t = csp_iface_s; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct csp_if_udp_conf_t { + pub host: *mut ::core::ffi::c_char, + pub lport: ::core::ffi::c_int, + pub rport: ::core::ffi::c_int, + pub server_handle: libc::pthread_t, + pub peer_addr: libc::sockaddr_in, + pub sockfd: ::core::ffi::c_int, +} + +impl Default for csp_if_udp_conf_t { + fn default() -> Self { + Self { + host: core::ptr::null_mut(), + lport: Default::default(), + rport: Default::default(), + server_handle: Default::default(), + peer_addr: libc::sockaddr_in { + sin_family: Default::default(), + sin_port: Default::default(), + sin_addr: libc::in_addr { + s_addr: Default::default(), + }, + sin_zero: Default::default(), + }, + sockfd: Default::default(), + } + } +} + +extern "C" { + #[doc = " Error counters"] + pub static mut csp_dbg_buffer_out: u8; + pub static mut csp_dbg_conn_out: u8; + pub static mut csp_dbg_conn_ovf: u8; + pub static mut csp_dbg_conn_noroute: u8; + pub static mut csp_dbg_inval_reply: u8; + pub static mut csp_dbg_errno: u8; + pub static mut csp_dbg_can_errno: u8; + pub static mut csp_dbg_eth_errno: u8; + pub static mut csp_dbg_rdp_print: u8; + pub static mut csp_dbg_packet_print: u8; + + #[doc = " Initialize CSP.\n This will configure basic structures."] + pub fn csp_init(); + + pub fn csp_print_func(fmt: *const core::ffi::c_char, ...); + + #[doc = " Bind port to socket.\n\n @param[in] socket socket to bind port to\n @param[in] port port number to bind, use #CSP_ANY for all ports. Bindnig to a specific will take precedence over #CSP_ANY.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_bind(socket: *mut csp_socket_t, port: u8) -> core::ffi::c_int; + + #[doc = " Set socket to listen for incoming connections.\n\n @param[in] socket socket\n @param[in] backlog max length of backlog queue. The backlog queue holds incoming connections, waiting to be returned by call to csp_accept().\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_listen(socket: *mut csp_socket_t, backlog: usize) -> ::core::ffi::c_int; + + #[doc = " Route packet from the incoming router queue and check RDP timeouts.\n In order for incoming packets to routed and RDP timeouts to be checked, this function must be called reguarly.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_route_work() -> ::core::ffi::c_int; + + #[doc = " Wait/accept a new connection.\n\n @param[in] socket socket to accept connections on, created by calling csp_socket().\n @param[in] timeout timeout in mS to wait for a connection, use CSP_MAX_TIMEOUT for infinite timeout.\n @return New connection on success, NULL on failure or timeout."] + pub fn csp_accept(socket: *mut csp_socket_t, timeout: u32) -> *mut csp_conn_t; + + #[doc = " Read packet from a connection.\n This fuction will wait on the connection's RX queue for the specified timeout.\n\n @param[in] conn connection\n @param[in] timeout timeout in mS to wait for a packet, use CSP_MAX_TIMEOUT for infinite timeout.\n @return Packet or NULL in case of failure or timeout."] + pub fn csp_read(conn: *mut csp_conn_t, timeout: u32) -> *mut csp_packet_t; + + #[doc = " Send packet on a connection.\n The packet buffer is automatically freed, and cannot be used after the call to csp_send()\n\n @param[in] conn connection\n @param[in] packet packet to send"] + pub fn csp_send(conn: *mut csp_conn_t, packet: *mut csp_packet_t); + + #[doc = " Change the default priority of the connection and send a packet.\n\n .. note:: The priority of the connection will be changed.\n If you need to change it back, call csp_send_prio() again.\n\n @param[in] prio priority to set on the connection\n @param[in] conn connection\n @param[in] packet packet to send"] + pub fn csp_send_prio(prio: u8, conn: *mut csp_conn_t, packet: *mut csp_packet_t); + + #[doc = " Send a packet as a reply to a request (without a connection).\n Calls csp_sendto() with the source address and port from the request.\n\n @param[in] request incoming request\n @param[out] reply reply packet\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS."] + pub fn csp_sendto_reply(request: *const csp_packet_t, reply: *mut csp_packet_t, opts: u32); + + #[doc = " Read data from a connection-less server socket.\n\n @param[in] socket connection-less socket.\n @param[in] timeout timeout in mS to wait for a packet, use #CSP_MAX_TIMEOUT for infinite timeout.\n @return Packet on success, or NULL on failure or timeout."] + pub fn csp_recvfrom(socket: *mut csp_socket_t, timeout: u32) -> *mut csp_packet_t; + + #[doc = " Perform an entire request & reply transaction.\n Creates a connection, send \\a outbuf, wait for reply, copy reply to \\a inbuf and close the connection.\n\n @param[in] prio priority, see #csp_prio_t\n @param[in] dst destination address\n @param[in] dst_port destination port\n @param[in] timeout timeout in mS to wait for a reply\n @param[in] outbuf outgoing data (request)\n @param[in] outlen length of data in \\a outbuf (request)\n @param[out] inbuf user provided buffer for receiving data (reply)\n @param[in] inlen length of expected reply, -1 for unknown size (inbuf MUST be large enough), 0 for no reply.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n\n Returns:\n int: 1 or reply size on success, 0 on failure (error, incoming length does not match, timeout)"] + pub fn csp_transaction_w_opts( + prio: u8, + dst: u16, + dst_port: u8, + timeout: u32, + outbuf: *const ::core::ffi::c_void, + outlen: ::core::ffi::c_int, + inbuf: *mut ::core::ffi::c_void, + inlen: ::core::ffi::c_int, + opts: u32, + ) -> ::core::ffi::c_int; + + #[doc = " Handle CSP service request.\n If the given packet is a service-request (the destination port matches one of CSP service ports #csp_service_port_t),\n the packet will be processed by the specific CSP service handler.\n The packet will either process it or free it, so this function is typically called in the last \"default\" clause of\n a switch/case statement in a CSP listener task.\n In order to listen to csp service ports, bind your listener to the specific services ports #csp_service_port_t or\n use #CSP_ANY to all ports.\n\n @param[in] packet first packet, obtained by using csp_read()"] + pub fn csp_service_handler(packet: *mut csp_packet_t); + + #[doc = " Close an open connection.\n Any packets in the RX queue will be freed.\n\n @param[in] conn connection. Closing a NULL connection is acceptable.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_close(conn: *mut csp_conn_t) -> ::core::ffi::c_int; + + #[doc = " Send a single ping/echo packet.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in ms to wait for reply.\n @param[in] size payload size in bytes.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n @return >=0 echo time in mS on success, otherwise -1 for error."] + pub fn csp_ping( + node: u16, + timeout: u32, + size: ::core::ffi::c_uint, + opts: u8, + ) -> ::core::ffi::c_int; + + #[doc = " Send a single ping/echo packet without waiting for reply.\n Payload is 1 byte.\n\n @param[in] node address of subsystem."] + pub fn csp_ping_noreply(node: u16); + + #[doc = " Request process list.\n\n .. note:: This is currently only supported on FreeRTOS systems.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for replies. The function will not return until the timeout occurrs."] + pub fn csp_ps(node: u16, timeout: u32); + + #[doc = " Request free memory.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] size free memory on subsystem.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_get_memfree(node: u16, timeout: u32, size: *mut u32) -> ::core::ffi::c_int; + + #[doc = " Request free memory and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply."] + pub fn csp_memfree(node: u16, timeout: u32); + + #[doc = " Request free buffers.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] size free buffers.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_get_buf_free(node: u16, timeout: u32, size: *mut u32) -> ::core::ffi::c_int; + + #[doc = " Request free buffers and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply."] + pub fn csp_buf_free(node: u16, timeout: u32); + + #[doc = " Reboot subsystem.\n If handled by the standard CSP service handler, the reboot handler set by csp_sys_set_reboot() on the subsystem, will be invoked.\n\n @param[in] node address of subsystem.\n"] + pub fn csp_reboot(node: u16); + + #[doc = " Shutdown subsystem.\n If handled by the standard CSP service handler, the shutdown handler set by csp_sys_set_shutdown() on the subsystem, will be invoked.\n\n @param[in] node address of subsystem.\n"] + pub fn csp_shutdown(node: u16); + + #[doc = " Request uptime and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n"] + pub fn csp_uptime(node: u16, timeout: u32); + + #[doc = " Request uptime\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] uptime uptime in seconds.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_get_uptime(node: u16, timeout: u32, uptime: *mut u32) -> ::core::ffi::c_int; + + #[doc = " Perform an entire request & reply transaction on an existing connection.\n Send \\a outbuf, wait for reply and copy reply to \\a inbuf.\n\n @param[in] conn connection\n @param[in] timeout timeout in mS to wait for a reply\n @param[in] outbuf outgoing data (request)\n @param[in] outlen length of data in \\a outbuf (request)\n @param[out] inbuf user provided buffer for receiving data (reply)\n @param[in] inlen length of expected reply, -1 for unknown size (inbuf MUST be large enough), 0 for no reply.\n @return 1 or reply size on success, 0 on failure (error, incoming length does not match, timeout)"] + pub fn csp_transaction_persistent( + conn: *mut csp_conn_t, + timeout: u32, + outbuf: *const ::core::ffi::c_void, + outlen: ::core::ffi::c_int, + inbuf: *mut ::core::ffi::c_void, + inlen: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; + + #[doc = " Establish outgoing connection.\n The call will return immediately, unless it is a RDP connection (#CSP_O_RDP) in which case it will wait until the other\n end acknowleges the connection (timeout is determined by the current connection timeout set by csp_rdp_set_opt()).\n\n @param[in] prio priority, see #csp_prio_t\n @param[in] dst Destination address\n @param[in] dst_port Destination port\n @param[in] timeout unused.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n @return Established connection or NULL on failure (no free connections, timeout)."] + pub fn csp_connect( + prio: u8, + dst: u16, + dst_port: u8, + timeout: u32, + opts: u32, + ) -> *mut csp_conn_t; + + #[doc = " Close a socket, freeing it's RX queue and unbinding it from the associated\n port.\n\n @param[in] sock Socket\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_socket_close(sock: *mut csp_socket_t) -> ::core::ffi::c_int; + + #[doc = " Return destination port of connection.\n\n @param[in] conn connection\n @return destination port of an incoming connection"] + pub fn csp_conn_dport(conn: *const csp_conn_t) -> ::core::ffi::c_int; + #[doc = " Return source port of connection.\n\n @param[in] conn connection\n @return source port of an incoming connection"] + pub fn csp_conn_sport(conn: *const csp_conn_t) -> ::core::ffi::c_int; + #[doc = " Return destination address of connection.\n\n @param[in] conn connection\n @return destination address of an incoming connection"] + pub fn csp_conn_dst(conn: *const csp_conn_t) -> ::core::ffi::c_int; + #[doc = " Return source address of connection.\n\n @param[in] conn connection\n @return source address of an incoming connection"] + pub fn csp_conn_src(conn: *const csp_conn_t) -> ::core::ffi::c_int; + #[doc = " Return flags of connection.\n\n @param[in] conn connection\n @return flags of an incoming connection, see @ref CSP_HEADER_FLAGS"] + pub fn csp_conn_flags(conn: *const csp_conn_t) -> ::core::ffi::c_int; + + #[doc = " Get free buffer from task context.\n\n @param[in] unused OBSOLETE ignored field, csp packets have a fixed size now\n @return Buffer pointer to #csp_packet_t or NULL if no buffers available"] + pub fn csp_buffer_get(unused: usize) -> *mut csp_packet_t; + + #[doc = " Free buffer (from task context).\n\n @param[in] buffer buffer to free. NULL is handled gracefully."] + pub fn csp_buffer_free(buffer: *mut ::core::ffi::c_void); + + #[doc = " Print connection table to stdout."] + pub fn csp_conn_print_table(); +} + +pub mod iflist { + use super::*; + + extern "C" { + #[doc = " Add interface to the list.\n\n @param[in] iface The interface must remain valid as long as the application is running.\n @return #CSP_ERR_NONE on success, otherwise an error code."] + pub fn csp_iflist_add(iface: *mut csp_iface_t) -> ::core::ffi::c_int; + + pub fn csp_iflist_print(); + + } +} + +pub mod udp { + use super::*; + + extern "C" { + + #[doc = " Setup UDP peer\n\n RX task:\n A server task will attempt at binding to ip 0.0.0.0 port 9600\n If this fails, it is because another udp server is already running.\n The server task will continue attemting the bind and will not exit before the application is closed.\n\n TX peer:\n Outgoing CSP packets will be transferred to the peer specified by the host argument"] + pub fn csp_if_udp_init(iface: *mut csp_iface_t, ifconf: *mut csp_if_udp_conf_t); + + } +} + +/// Hook module for CSP. +/// +/// You can override these methods by providing them with an implementation block in your +/// application for library with the function signature specified in this module. +pub mod hooks { + use super::*; + + extern "C" { + pub fn csp_output_hook( + idout: *mut csp_id_t, + packet: *mut csp_packet_t, + iface: *mut csp_iface_t, + via: u16, + from_me: ::core::ffi::c_int, + ); + pub fn csp_input_hook(iface: *mut csp_iface_t, packet: *mut csp_packet_t); + pub fn csp_reboot_hook(); + pub fn csp_shutdown_hook(); + pub fn csp_memfree_hook() -> u32; + pub fn csp_ps_hook(packet: *mut csp_packet_t) -> ::core::ffi::c_uint; + #[doc = " Implement these, if you use csp_if_tun"] + pub fn csp_crypto_decrypt( + ciphertext_in: *mut u8, + ciphertext_len: u8, + msg_out: *mut u8, + ) -> ::core::ffi::c_int; + pub fn csp_crypto_encrypt( + msg_begin: *mut u8, + msg_len: u8, + ciphertext_out: *mut u8, + ) -> ::core::ffi::c_int; + pub fn csp_clock_get_time(time: *mut csp_timestamp_t); + pub fn csp_clock_set_time(time: *const csp_timestamp_t) -> ::core::ffi::c_int; + } +} + +#[cfg(test)] +mod tests { + use super::*; + use core::mem::{align_of, size_of}; + use std::mem::MaybeUninit; + + #[test] + fn bindgen_test_layout_csp_timestamp_t() { + const UNINIT: MaybeUninit = MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(csp_timestamp_t)) + ); + assert_eq!( + std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(csp_timestamp_t)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_timestamp_t), + "::", + stringify!(tv_sec) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tv_nsec) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_timestamp_t), + "::", + stringify!(tv_nsec) + ) + ); + } + + #[test] + fn bindgen_test_layout_csp_id() { + const UNINIT: MaybeUninit = MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + size_of::(), + 8usize, + concat!("Size of: ", stringify!(__packed)) + ); + assert_eq!( + align_of::(), + 2usize, + concat!("Alignment of ", stringify!(__packed)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pri) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(pri) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).src) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(src) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dst) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(dst) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dport) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(dport) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sport) as usize - ptr as usize }, + 7usize, + concat!( + "Offset of field: ", + stringify!(__packed), + "::", + stringify!(sport) + ) + ); + } + + #[test] + fn bindgen_test_layout_csp_packet_s__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: MaybeUninit = MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + size_of::(), + 24usize, + concat!( + "Size of: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rdp_quarantine) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(rdp_quarantine) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).timestamp_tx) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(timestamp_tx) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).timestamp_rx) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(timestamp_rx) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).conn) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(conn) + ) + ); + } + + #[test] + fn bindgen_test_layout_csp_packet_s__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: MaybeUninit = MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + size_of::(), + 32usize, + concat!( + "Size of: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rx_count) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(rx_count) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).remain) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(remain) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cfpid) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(cfpid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).last_used) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(last_used) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).frame_begin) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(frame_begin) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).frame_length) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(frame_length) + ) + ); + } + #[test] + fn bindgen_test_layout_csp_packet_s__bindgen_ty_1() { + assert_eq!( + size_of::(), + 32usize, + concat!("Size of: ", stringify!(csp_packet_s_anon_union)) + ); + assert_eq!( + align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_packet_s_anon_union)) + ); + } + + #[test] + fn bindgen_test_layout_csp_packet_s__bindgen_ty_2() { + const UNINIT: MaybeUninit = MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + size_of::(), + 256usize, + concat!("Size of: ", stringify!(csp_packet_s__bindgen_ty_2)) + ); + assert_eq!( + align_of::(), + 4usize, + concat!("Alignment of ", stringify!(csp_packet_s__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_2), + "::", + stringify!(data) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data16) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_2), + "::", + stringify!(data16) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data32) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s__bindgen_ty_2), + "::", + stringify!(data32) + ) + ); + } + #[test] + fn bindgen_test_layout_csp_packet_s() { + const UNINIT: MaybeUninit = MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + size_of::(), + 320usize, + concat!("Size of: ", stringify!(csp_packet_s)) + ); + assert_eq!( + align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_packet_s)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(length) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 34usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(next) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).header) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(csp_packet_s), + "::", + stringify!(header) + ) + ); + } + + #[test] + fn bindgen_test_layout_csp_socket_s() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 152usize, + concat!("Size of: ", stringify!(csp_socket_s)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_socket_s)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rx_queue) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(rx_queue) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rx_queue_static) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(rx_queue_static) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rx_queue_static_data) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(rx_queue_static_data) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).opts) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(csp_socket_s), + "::", + stringify!(opts) + ) + ); + } + + #[test] + fn bindgen_test_layout_csp_if_udp_conf_t() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(csp_if_udp_conf_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_if_udp_conf_t)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).host) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(host) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).lport) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(lport) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rport) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(rport) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).server_handle) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(server_handle) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).peer_addr) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(peer_addr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sockfd) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(csp_if_udp_conf_t), + "::", + stringify!(sockfd) + ) + ); + } + + #[test] + fn bindgen_test_layout_csp_conn_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 280usize, + concat!("Size of: ", stringify!(csp_conn_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_conn_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(state) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).idin) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(idin) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).idout) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(idout) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sport_outgoing) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(sport_outgoing) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(rx_queue) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue_static) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(rx_queue_static) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_queue_static_data) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(rx_queue_static_data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).callback) as usize - ptr as usize }, + 176usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(callback) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).dest_socket) as usize - ptr as usize }, + 184usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(dest_socket) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).timestamp) as usize - ptr as usize }, + 192usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(timestamp) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).opts) as usize - ptr as usize }, + 196usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(opts) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rdp) as usize - ptr as usize }, + 200usize, + concat!( + "Offset of field: ", + stringify!(csp_conn_s), + "::", + stringify!(rdp) + ) + ); + } + + #[test] + fn bindgen_test_layout_csp_iface_s() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 96usize, + concat!("Size of: ", stringify!(csp_iface_s)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(csp_iface_s)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).netmask) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(netmask) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).name) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(name) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).interface_data) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(interface_data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).driver_data) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(driver_data) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).nexthop) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(nexthop) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).is_default) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(is_default) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tx) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(tx) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(rx) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).tx_error) as usize - ptr as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(tx_error) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rx_error) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(rx_error) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).drop) as usize - ptr as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(drop) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).autherr) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(autherr) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).frame) as usize - ptr as usize }, + 68usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(frame) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).txbytes) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(txbytes) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).rxbytes) as usize - ptr as usize }, + 76usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(rxbytes) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).irq) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(irq) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(csp_iface_s), + "::", + stringify!(next) + ) + ); + } +} diff --git a/libcsp-sys/templates/autoconfig.rs b/libcsp-sys/templates/autoconfig.rs new file mode 100644 index 0000000..681f2df --- /dev/null +++ b/libcsp-sys/templates/autoconfig.rs @@ -0,0 +1,8 @@ +pub const CSP_CONN_RXQUEUE_LEN: usize = 16; +pub const CSP_QFIFO_LEN: usize = 15; +pub const CSP_PORT_MAX_BIND: usize = 16; +pub const CSP_CONN_MAX: usize = 8; +pub const CSP_BUFFER_SIZE: usize = 256; +pub const CSP_BUFFER_COUNT: usize = 15; +pub const CSP_RDP_MAX_WINDOW: usize = 5; +pub const CSP_RTABLE_SIZE: usize = 10; diff --git a/libcsp/CHANGELOG.md b/libcsp/CHANGELOG.md new file mode 100644 index 0000000..fd4480e --- /dev/null +++ b/libcsp/CHANGELOG.md @@ -0,0 +1,13 @@ +Change Log +======= + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +# [unreleased] + +# [v0.1.0] 2024-06-01 + +Initial release diff --git a/libcsp/Cargo.toml b/libcsp/Cargo.toml new file mode 100644 index 0000000..6988083 --- /dev/null +++ b/libcsp/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "libcsp" +version = "0.1.0" +edition = "2021" +authors = ["Robin Mueller "] +description = "Safe and ergonomic Rust API for libcsp on top on libcsp-sys" +homepage = "https://egit.irs.uni-stuttgart.de/rust/libcsp-rust" +repository = "https://egit.irs.uni-stuttgart.de/rust/libcsp-rust" +license = "Apache-2.0" +keywords = ["no-std", "space", "aerospace", "ffi", "csp"] +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +categories = ["aerospace", "external-ffi-bindings", "no-std", "hardware-support", "embedded"] + +[dependencies] +bitflags = "2" +num_enum = "0.7" +libc = "0.2" +libcsp-sys = { path = "../libcsp-sys" } diff --git a/libcsp/LICENSE-APACHE b/libcsp/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/libcsp/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/libcsp/NOTICE b/libcsp/NOTICE new file mode 100644 index 0000000..717a583 --- /dev/null +++ b/libcsp/NOTICE @@ -0,0 +1 @@ +This software contains code developed at the University of Stuttgart's Institute of Space Systems. diff --git a/libcsp/README.md b/libcsp/README.md new file mode 100644 index 0000000..feaa517 --- /dev/null +++ b/libcsp/README.md @@ -0,0 +1,11 @@ +libcsp-rust +======== + +This crate provides a (mostly) safe and ergonomic Rust API for the +[`libcsp` library](https://github.com/libcsp/libcsp) on top of the +[`libcsp-sys`](https://crates.io/crates/libcsp-sys) crate. + +You can find some more high-level information and examples in the +[main repository](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust). + +The API documentation should provide all additional information required to use this library. diff --git a/libcsp/src/lib.rs b/libcsp/src/lib.rs new file mode 100644 index 0000000..1399aa0 --- /dev/null +++ b/libcsp/src/lib.rs @@ -0,0 +1,702 @@ +//! This crate provides a (mostly) safe and ergonomic Rust API for the +//! [`libcsp` C library](https://github.com/libcsp/libcsp) on top of the +//! [`libcsp-sys`](https://crates.io/crates/libcsp-sys) crate. +//! +//! You can find some more high-level information and examples in the +//! [main repository](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust). +#![no_std] +#[cfg(feature = "alloc")] +extern crate alloc; +#[cfg(any(feature = "std", test))] +extern crate std; + +use core::time::Duration; + +use num_enum::{IntoPrimitive, TryFromPrimitive}; + +use bitflags::bitflags; +use ffi::{csp_conn_s, csp_packet_s, csp_socket_s}; +pub use libcsp_sys as ffi; + +#[derive(Debug, PartialEq, Eq, Copy, Clone)] +pub enum ReservedPort { + Cmp = 0, + Ping = 1, + Ps = 2, + Memfree = 3, + Reboot = 4, + BufFree = 5, + Uptime = 6, +} + +#[derive(Debug, PartialEq, Eq, Copy, Clone, TryFromPrimitive, IntoPrimitive)] +#[repr(i32)] +pub enum CspError { + None = 0, + NoMem = -1, + Inval = -2, + TimedOut = -3, + Used = -4, + NotSup = -5, + Busy = -6, + Already = -7, + Reset = -8, + NoBufs = -9, + Tx = -10, + Driver = -11, + Again = -12, + NoSys = -38, + Hmac = -100, + Crc32 = -102, + Sfp = -103, +} + +/// Listen on all ports, primarily used with [csp_bind] +pub const CSP_ANY: u8 = 255; +pub const CSP_LOOPBACK: u16 = 0; + +bitflags! { + pub struct SocketFlags: u32 { + const NONE = 0x0000; + /// RDP required. + const RDPREQ = 0x0001; + /// RDP prohibited. + const RDPPROHIB = 0x0002; + /// HMAC required + const HMACREQ = 0x0004; + /// HMAC prohibited. + const HMACPROHIB = 0x0008; + /// CRC32 required. + const CRC32REQ = 0x0040; + const CRC32PROHIB = 0x0080; + const CONN_LESS = 0x0100; + /// Copy opts from incoming packets. Only applies to [csp_sendto_reply] + const SAME = 0x8000; + + // The source may set any bits + const _ = !0; + } +} + +bitflags! { + pub struct ConnectOpts: u32 { + const NONE = SocketFlags::NONE.bits(); + + const RDP = SocketFlags::RDPREQ.bits(); + const NORDP = SocketFlags::RDPPROHIB.bits(); + const HMAC = SocketFlags::HMACREQ.bits(); + const NOHMAC = SocketFlags::HMACPROHIB.bits(); + const CRC32 = SocketFlags::CRC32REQ.bits(); + const NOCRC32 = SocketFlags::CRC32PROHIB.bits(); + const SAME = SocketFlags::SAME.bits(); + + // The source may set any bits + const _ = !0; + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)] +#[repr(u8)] +pub enum ConnState { + Closed = 0, + Open = 1, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)] +#[repr(u8)] +pub enum ConnType { + Client = 0, + Server = 1, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)] +#[repr(u32)] +pub enum RdpState { + Closed = 0, + SynSent = 1, + SynRcvd = 2, + Open = 3, + CloseWait = 4, +} + +#[derive(Debug, PartialEq, Eq, Copy, Clone, TryFromPrimitive, IntoPrimitive)] +#[repr(u8)] +pub enum MsgPriority { + Critical = 0, + High = 1, + Normal = 2, + Low = 3, +} + +pub struct CspPacket(pub csp_packet_s); + +pub struct CspPacketRef(*mut csp_packet_s); + +pub struct CspPacketMut(*mut csp_packet_s); + +impl From for CspPacketRef { + fn from(value: CspPacketMut) -> Self { + Self(value.0) + } +} + +impl CspPacketRef { + pub fn packet_data(&self) -> &[u8] { + unsafe { &(*self.0).packet_data_union.data[..self.packet_length()] } + } + + pub fn whole_data(&self) -> &[u8; ffi::CSP_BUFFER_SIZE] { + unsafe { &(*self.0).packet_data_union.data } + } + + pub fn packet_length(&self) -> usize { + unsafe { (*self.0).length.into() } + } + + pub fn inner(&self) -> *const csp_packet_s { + self.0 + } +} + +pub struct CspPacketRefGuard(Option); + +impl Drop for CspPacketRefGuard { + fn drop(&mut self) { + if let Some(packet) = self.0.take() { + csp_buffer_free(packet) + } + } +} + +impl CspPacketRefGuard { + /// Take the packet out of the guard, preventing it from being freed. + pub fn take(mut self) -> CspPacketRef { + self.0.take().unwrap() + } +} + +impl AsRef for CspPacketRefGuard { + fn as_ref(&self) -> &CspPacketRef { + self.0.as_ref().unwrap() + } +} + +impl CspPacketMut { + pub fn packet_data(&self) -> &[u8] { + unsafe { &(*self.0).packet_data_union.data[..self.packet_length()] } + } + + pub fn whole_data(&self) -> &[u8; ffi::CSP_BUFFER_SIZE] { + unsafe { &(*self.0).packet_data_union.data } + } + + pub fn packet_length(&self) -> usize { + unsafe { (*self.0).length.into() } + } + + pub fn inner(&self) -> *const csp_packet_s { + self.0 + } + + pub fn whole_data_mut(&mut self) -> &mut [u8; ffi::CSP_BUFFER_SIZE] { + unsafe { &mut (*self.0).packet_data_union.data } + } + + pub fn set_data(&mut self, data: &[u8]) -> bool { + if data.len() > self.whole_data().len() { + return false; + } + self.whole_data_mut()[0..data.len()].copy_from_slice(data); + unsafe { + (*self.0).length = data.len() as u16; + } + true + } + + pub fn inner_mut(&self) -> *mut csp_packet_s { + self.0 + } +} + +impl CspPacket { + pub fn new() -> Self { + Self::default() + } +} + +impl Default for CspPacket { + fn default() -> Self { + Self(csp_packet_s { + packet_info: Default::default(), + length: Default::default(), + id: Default::default(), + next: core::ptr::null_mut(), + header: Default::default(), + packet_data_union: Default::default(), + }) + } +} + +#[derive(Default)] +pub struct CspSocket(pub csp_socket_s); + +impl CspSocket { + pub fn inner_as_mut_ptr(&mut self) -> *mut csp_socket_s { + &mut self.0 + } +} + +/// Rust wrapper for [ffi::csp_init]. Initialize the CSP stack. +/// +/// # Safety +/// +/// - You must call this function only once. +pub unsafe fn csp_init() { + // SAFETY: FFI call + unsafe { + ffi::csp_init(); + } +} + +/// Rust wrapper for [ffi::csp_bind]. +pub fn csp_bind(socket: &mut CspSocket, port: u8) { + // SAFETY: FFI call + unsafe { + ffi::csp_bind(socket.inner_as_mut_ptr(), port); + } +} + +/// Rust wrapper for [ffi::csp_listen]. +pub fn csp_listen(socket: &mut CspSocket, backlog: usize) { + // SAFETY: FFI call + unsafe { + ffi::csp_listen(socket.inner_as_mut_ptr(), backlog); + } +} + +/// Rust wrapper for [ffi::csp_route_work]. +pub fn csp_route_work_raw() -> i32 { + unsafe { ffi::csp_route_work() } +} + +/// Rust wrapper for [ffi::csp_route_work] which also converts errors to the [CspError] type. +/// This function will panic if the returned error type is not among the known values of +/// [CspError]. +/// +/// [csp_route_work_raw] can be used if this is not acceptable. +pub fn csp_route_work() -> Result<(), CspError> { + let result = unsafe { ffi::csp_route_work() }; + if result == CspError::None as i32 { + return Ok(()); + } + Err(CspError::try_from(result) + .unwrap_or_else(|_| panic!("unexpected error value {} from csp_route_work", result))) +} + +#[derive(Debug, Copy, Clone)] +pub struct CspConnRef(*mut csp_conn_s); + +impl CspConnRef { + pub fn inner(&mut self) -> Option<&csp_conn_s> { + // SAFETY: Raw pointer access, we return [None] if the pointers is NULL. + unsafe { self.0.as_ref() } + } + + pub fn inner_mut(&mut self) -> Option<&mut csp_conn_s> { + // SAFETY: Raw pointer access, we return [None] if the pointers is NULL. + unsafe { self.0.as_mut() } + } +} + +pub struct CspConnGuard(pub CspConnRef); + +impl Drop for CspConnGuard { + fn drop(&mut self) { + csp_close(self.0); + } +} + +impl AsRef for CspConnGuard { + fn as_ref(&self) -> &CspConnRef { + &self.0 + } +} + +impl AsMut for CspConnGuard { + fn as_mut(&mut self) -> &mut CspConnRef { + &mut self.0 + } +} + +#[derive(Default)] +pub struct CspInterface(pub ffi::csp_iface_t); + +impl CspInterface { + pub fn new(host_addr: u16, is_default: bool) -> Self { + Self(ffi::csp_iface_t { + addr: host_addr, + netmask: Default::default(), + name: core::ptr::null(), + interface_data: core::ptr::null_mut(), + driver_data: core::ptr::null_mut(), + nexthop: None, + is_default: is_default as u8, + tx: Default::default(), + rx: Default::default(), + tx_error: Default::default(), + rx_error: Default::default(), + drop: Default::default(), + autherr: Default::default(), + frame: Default::default(), + txbytes: Default::default(), + rxbytes: Default::default(), + irq: Default::default(), + next: core::ptr::null_mut(), + }) + } +} + +#[derive(Default)] +pub struct CspUdpConf(pub ffi::csp_if_udp_conf_t); + +impl CspUdpConf { + pub fn new(addr: &'static str, lport: u16, rport: u16) -> Self { + Self(ffi::csp_if_udp_conf_t { + host: addr.as_ptr() as *mut i8, + lport: lport.into(), + rport: rport.into(), + server_handle: Default::default(), + peer_addr: libc::sockaddr_in { + sin_family: Default::default(), + sin_port: Default::default(), + sin_addr: libc::in_addr { + s_addr: Default::default(), + }, + sin_zero: Default::default(), + }, + sockfd: Default::default(), + }) + } +} + +pub fn csp_accept_guarded(socket: &mut CspSocket, timeout: Duration) -> Option { + Some(CspConnGuard(csp_accept(socket, timeout)?)) +} + +/// Rust wrapper for [ffi::csp_accept]. +pub fn csp_accept(socket: &mut CspSocket, timeout: Duration) -> Option { + let timeout_millis = timeout.as_millis(); + if timeout_millis > u32::MAX as u128 { + return None; + } + Some(CspConnRef(unsafe { + let addr = ffi::csp_accept(socket.inner_as_mut_ptr(), timeout_millis as u32); + if addr.is_null() { + return None; + } + addr + })) +} + +/// Rust wrapper for [ffi::csp_read]. +pub fn csp_read(conn: &mut CspConnRef, timeout: Duration) -> Option { + let timeout_millis = timeout.as_millis(); + if timeout_millis > u32::MAX as u128 { + return None; + } + let opt_packet = unsafe { ffi::csp_read(conn.0, timeout_millis as u32) }; + if opt_packet.is_null() { + return None; + } + // SAFETY: FFI pointer. + Some(CspPacketRef(unsafe { &mut *opt_packet })) +} + +/// Rust wrapper for [ffi::csp_read] which returns a guarded packet reference. This packet +/// will cleaned up automatically with [csp_buffer_free] on drop. +pub fn csp_read_guarded(conn: &mut CspConnRef, timeout: Duration) -> Option { + Some(CspPacketRefGuard(Some(csp_read(conn, timeout)?))) +} + +/// Rust wrapper for [ffi::csp_recvfrom]. +pub fn csp_recvfrom(socket: &mut CspSocket, timeout: u32) -> Option { + let opt_packet = unsafe { ffi::csp_recvfrom(&mut socket.0, timeout) }; + if opt_packet.is_null() { + return None; + } + Some(CspPacketRef(unsafe { &mut *opt_packet })) +} + +/// Rust wrapper for [ffi::csp_recvfrom] which returns a guarded packet reference. This packet +/// will cleaned up automatically with [csp_buffer_free] on drop. +pub fn csp_recvfrom_guarded(socket: &mut CspSocket, timeout: u32) -> Option { + Some(CspPacketRefGuard(Some(csp_recvfrom(socket, timeout)?))) +} + +/// Rust wrapper for [ffi::csp_conn_dport]. +pub fn csp_conn_dport(conn: &CspConnRef) -> i32 { + // SAFETY: FFI call. + unsafe { ffi::csp_conn_dport(conn.0) } +} + +/// Rust wrapper for [ffi::csp_conn_sport]. +pub fn csp_conn_sport(conn: &CspConnRef) -> i32 { + // SAFETY: FFI call. + unsafe { ffi::csp_conn_sport(conn.0) } +} + +/// Rust wrapper for [ffi::csp_conn_dst]. +pub fn csp_conn_dst(conn: &CspConnRef) -> i32 { + // SAFETY: FFI call. + unsafe { ffi::csp_conn_dst(conn.0) } +} + +/// Rust wrapper for [ffi::csp_conn_src]. +pub fn csp_conn_src(conn: &CspConnRef) -> i32 { + // SAFETY: FFI call. + unsafe { ffi::csp_conn_src(conn.0) } +} + +/// Rust wrapper for [ffi::csp_conn_src]. +pub fn csp_conn_flags(conn: &CspConnRef) -> i32 { + // SAFETY: FFI call. + unsafe { ffi::csp_conn_flags(conn.0) } +} + +/// Rust wrapper for [ffi::csp_conn_src] which also tries to convert the options to +/// a [ConnectOpts] bitfield. +pub fn csp_conn_flags_typed(conn: &CspConnRef) -> Option { + let flags_raw = csp_conn_flags(conn); + if flags_raw < 0 { + return None; + } + // SAFETY: FFI call. + ConnectOpts::from_bits(flags_raw as u32) +} + +pub fn csp_service_handler(packet: CspPacketRef) { + // SAFETY: FFI call. + unsafe { ffi::csp_service_handler(&mut *packet.0) } +} + +/// Rust wrapper for [ffi::csp_close]. +pub fn csp_close(conn: CspConnRef) -> i32 { + // SAFETY: FFI call. + unsafe { ffi::csp_close(conn.0) } +} + +/// Rust wrapper for [ffi::csp_ping], returns the result code directly. +pub fn csp_ping_raw(node: u16, timeout: Duration, size: usize, opts: SocketFlags) -> i32 { + // SAFETY: FFI call. + unsafe { + ffi::csp_ping( + node, + timeout.as_millis() as u32, + size as u32, + opts.bits() as u8, + ) + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct PingError; + +/// Rust wrapper for [ffi::csp_ping]. +pub fn csp_ping( + node: u16, + timeout: Duration, + size: usize, + opts: SocketFlags, +) -> Result { + let result = csp_ping_raw(node, timeout, size, opts); + if result < 0 { + return Err(PingError); + } + Ok(Duration::from_millis(result as u64)) +} + +/// Rust wrapper for [ffi::csp_reboot]. +pub fn csp_reboot(node: u16) { + // SAFETY: FFI call. + unsafe { ffi::csp_reboot(node) } +} + +/// Rust wrapper for [ffi::csp_connect]. +pub fn csp_connect( + prio: MsgPriority, + dst: u16, + dst_port: u8, + timeout: Duration, + opts: ConnectOpts, +) -> Option { + // SAFETY: FFI call. + let conn = unsafe { + ffi::csp_connect( + prio as u8, + dst, + dst_port, + timeout.as_millis() as u32, + opts.bits(), + ) + }; + if conn.is_null() { + return None; + } + // SAFETY: We checked that the pointer is valid. + Some(CspConnRef(conn)) +} + +/// Rust wrapper for [ffi::csp_connect] which returns a guard structure. The connection will be +/// be closed automatically when the guard structure is dropped. +pub fn csp_connect_guarded( + prio: MsgPriority, + dst: u16, + dst_port: u8, + timeout: Duration, + opts: ConnectOpts, +) -> Option { + Some(CspConnGuard(csp_connect( + prio, dst, dst_port, timeout, opts, + )?)) +} + +/// Rust wrapper for [ffi::csp_buffer_get]. +pub fn csp_buffer_get() -> Option { + let packet_ref = unsafe { + // The size argument is unused + ffi::csp_buffer_get(0) + }; + if packet_ref.is_null() { + return None; + } + // SAFETY: We checked that the pointer is valid. + Some(CspPacketMut(unsafe { &mut *packet_ref })) +} + +/// Rust wrapper for [ffi::csp_send]. +pub fn csp_send(conn: &mut CspConnRef, packet: impl Into) { + // SAFETY: FFI call. + unsafe { ffi::csp_send(conn.0, packet.into().0) } +} + +/// Rust wrapper for [ffi::csp_conn_print_table]. +pub fn csp_conn_print_table() { + // SAFETY: FFI call. + unsafe { ffi::csp_conn_print_table() } +} + +/// Rust wrapper for [ffi::csp_buffer_free]. +pub fn csp_buffer_free(packet: impl Into) { + // SAFETY: FFI call and the Rust type system actually ensure the correct type + // is free'd here, while also taking the packet by value. + unsafe { ffi::csp_buffer_free(packet.into().0 as *mut libc::c_void) } +} + +/// Rust wrapper for [ffi::csp_transaction_persistent]. +/// +/// # Parameters +/// +/// * `in_len`: Use [None] if the length is unknown, and the expected reply length otherwise. +/// +/// # Returns +/// +/// 1 or reply size on success, 0 otherwise. +pub fn csp_transaction_persistent( + conn: &mut CspConnRef, + timeout: Duration, + out_data: &[u8], + in_data: &mut [u8], + in_len: Option, +) -> i32 { + unsafe { + ffi::csp_transaction_persistent( + conn.0, + timeout.as_millis() as u32, + out_data.as_ptr() as *const core::ffi::c_void, + out_data.len() as i32, + in_data.as_ptr() as *mut core::ffi::c_void, + in_len.map(|v| v as i32).unwrap_or(-1), + ) + } +} + +/// Rust wrapper for [ffi::csp_transaction_w_opts]. +/// +/// # Parameters +/// +/// * `in_len`: Use [None] if the length is unknown, and the expected reply length otherwise. +/// +/// # Returns +/// +/// 1 or reply size on success, 0 otherwise. +#[allow(clippy::too_many_arguments)] +pub fn csp_transaction_w_opts( + prio: MsgPriority, + dst: u16, + dst_port: u8, + timeout: Duration, + out_data: &[u8], + in_data: &mut [u8], + in_len: Option, + opts: ConnectOpts, +) -> i32 { + unsafe { + ffi::csp_transaction_w_opts( + prio as u8, + dst, + dst_port, + timeout.as_millis() as u32, + out_data.as_ptr() as *const core::ffi::c_void, + out_data.len() as i32, + in_data.as_ptr() as *mut core::ffi::c_void, + in_len.map(|v| v as i32).unwrap_or(-1), + opts.bits(), + ) + } +} + +/// Calls [csp_transaction_w_opts] with [ConnectOpts::NONE]. +pub fn csp_transaction( + prio: MsgPriority, + dst: u16, + dst_port: u8, + timeout: Duration, + out_data: &[u8], + in_data: &mut [u8], + in_len: Option, +) -> i32 { + csp_transaction_w_opts( + prio, + dst, + dst_port, + timeout, + out_data, + in_data, + in_len, + ConnectOpts::NONE, + ) +} + +pub mod udp { + use super::*; + + /// Rust wrapper for [ffi::udp::csp_if_udp_init]. + pub fn csp_if_udp_init(iface: &mut CspInterface, ifconf: &mut CspUdpConf) { + unsafe { ffi::udp::csp_if_udp_init(&mut iface.0, &mut ifconf.0) } + } +} + +pub mod iflist { + use super::*; + + /// Rust wrapper for [ffi::iflist::csp_iflist_print]. + pub fn csp_iflist_print() { + // SAFETY: FFI call. + unsafe { ffi::iflist::csp_iflist_print() } + } + + /// Rust wrapper for [ffi::iflist::csp_iflist_add]. + pub fn csp_iflist_add(iface: &mut CspInterface) -> i32 { + unsafe { ffi::iflist::csp_iflist_add(&mut iface.0) } + } +}