aboutsummaryrefslogtreecommitdiff
path: root/rustables-sys/src/lib.rs
diff options
context:
space:
mode:
authorlafleur <lafleur@boum.org>2021-10-18 23:43:35 +0200
committerlafleur <lafleur@boum.org>2021-10-19 00:39:55 +0200
commit4a87680c89017730f0a8715f87118c63bb8b7ae8 (patch)
tree9ea0780ef6fb8f3320dedb3c3dc65aebc58ee7a0 /rustables-sys/src/lib.rs
parent26bfea8ed713ab68f0ffe3945e94fee1d766c98e (diff)
rename the crates, update copyright notices
Diffstat (limited to 'rustables-sys/src/lib.rs')
-rw-r--r--rustables-sys/src/lib.rs91
1 files changed, 91 insertions, 0 deletions
diff --git a/rustables-sys/src/lib.rs b/rustables-sys/src/lib.rs
new file mode 100644
index 0000000..82125f4
--- /dev/null
+++ b/rustables-sys/src/lib.rs
@@ -0,0 +1,91 @@
+// Copyryght (c) 2021 GPL lafleur@boum.org and Simon Thoby
+//
+// This file is free software: you may copy, redistribute and/or modify it
+// under the terms of the GNU General Public License as published by the
+// Free Software Foundation, either version 3 of the License, or (at your
+// option) any later version.
+//
+// This file is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see the LICENSE file.
+//
+// This file incorporates work covered by the following copyright and
+// permission notice:
+//
+// Copyright 2018 Amagicom AB.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Low level FFI bindings to [`libnftnl`], a userspace library providing a low-level netlink
+//! programming interface (API) to the in-kernel nf_tables subsystem.
+//!
+//! See [`rustables`] for a higher level safe abstraction.
+//!
+//! # Linking to libmnl and libnftnl
+//!
+//! By default this crate uses pkg-config to find and link to its C dependencies, [`libmnl`] and
+//! [`libnftnl`]. To manually configure where to look for these libraries, set the environment
+//! variables `LIBMNL_LIB_DIR` and `LIBNFTNL_LIB_DIR` to point to the directories where `libmnl.so`
+//! (or `libmnl.a`) and `libnftnl.so` (or `libnftnl.a`) reside.
+//!
+//! # Selecting version of `libnftnl`
+//!
+//! This crate has bindings for most versions of [`libnftnl`]. All bindings are generated by
+//! [`bindgen`] via the `generate_bindings.sh` script in this repository.
+//!
+//! Only one version of `libnftnl` can be exposed via this crate. By default the crate exports the
+//! bindings for the oldest supported version (`libnftnl-1.0.6`). To get newer versions activate the
+//! corresponding features. See `Cargo.toml` for available features/versions.
+//!
+//! So for example, to get bindings to `libnftnl-1.0.9` depend on this crate like this:
+//! ```toml
+//! [dependencies]
+//! rustables-sys = { version = "0.1", features = ["nftnl-1-0-9"] }
+//! ```
+//!
+//! [`libnftnl`]: https://netfilter.org/projects/libnftnl/
+//! [`libmnl`]: https://netfilter.org/projects/libmnl/
+//! [`rustables`]: https://crates.io/crates/rustables
+//! [`bindgen`]: https://crates.io/crates/bindgen
+
+#![no_std]
+#![cfg(target_os = "linux")]
+#![allow(non_camel_case_types)]
+
+pub use libc;
+
+cfg_if::cfg_if! {
+ if #[cfg(feature = "nftnl-1-2-0")] {
+ mod nftnl_1_2_0;
+ pub use self::nftnl_1_2_0::*;
+ } else if #[cfg(feature = "nftnl-1-1-2")] {
+ mod nftnl_1_1_2;
+ pub use self::nftnl_1_1_2::*;
+ } else if #[cfg(feature = "nftnl-1-1-1")] {
+ mod nftnl_1_1_1;
+ pub use self::nftnl_1_1_1::*;
+ } else if #[cfg(feature = "nftnl-1-1-0")] {
+ mod nftnl_1_1_0;
+ pub use self::nftnl_1_1_0::*;
+ } else if #[cfg(feature = "nftnl-1-0-9")] {
+ mod nftnl_1_0_9;
+ pub use self::nftnl_1_0_9::*;
+ } else if #[cfg(feature = "nftnl-1-0-8")] {
+ mod nftnl_1_0_8;
+ pub use self::nftnl_1_0_8::*;
+ } else if #[cfg(feature = "nftnl-1-0-7")] {
+ mod nftnl_1_0_7;
+ pub use self::nftnl_1_0_7::*;
+ } else {
+ mod nftnl_1_0_6;
+ pub use self::nftnl_1_0_6::*;
+ }
+}