diff options
45 files changed, 174 insertions, 10516 deletions
@@ -1,2 +1,2 @@ [workspace] -members = ["rustables-sys", "rustables"] +members = ["rustables"] diff --git a/rustables-sys/Cargo.toml b/rustables-sys/Cargo.toml deleted file mode 100644 index 49a0d51..0000000 --- a/rustables-sys/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "rustables-sys" -version = "0.7.0" -authors = ["lafleur@boum.org, Simon Thoby, Mullvad VPN"] -license = "GPL-3.0-or-later" -description = "Low level FFI bindings to libnftnl. Provides low-level userspace access to the in-kernel nf_tables subsystem" -repository = "https://gitlab.com/rustwall/rustables" -readme = "README.md" -keywords = ["nftables", "nft", "firewall", "iptables", "netfilter"] -categories = ["network-programming", "os::unix-apis", "external-ffi-bindings", "no-std"] -edition = "2018" - - -[features] -nftnl-1-0-7 = [] -nftnl-1-0-8 = ["nftnl-1-0-7"] -nftnl-1-0-9 = ["nftnl-1-0-8"] -nftnl-1-1-0 = ["nftnl-1-0-9"] -nftnl-1-1-1 = ["nftnl-1-1-0"] -nftnl-1-1-2 = ["nftnl-1-1-1"] -nftnl-1-2-0 = ["nftnl-1-1-2"] -default = ["nftnl-1-2-0"] - -[dependencies] -cfg-if = "1.0" -libc = "0.2.43" - -[build-dependencies] -cfg-if = "1.0" -pkg-config = "0.3" diff --git a/rustables-sys/README.md b/rustables-sys/README.md deleted file mode 100644 index 2069ade..0000000 --- a/rustables-sys/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# rustables-sys - -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"] } -``` - -License: GNU GPLv3 - -Original work licensed by Amagicom AB under MIT/Apache-2.0 - -Since the GNU GPLv3 applies to parts of this software, you may use the original -software if you wish to use the more permissive MIT/Apache-2.0 licenses : -[nftnl-rs](https://github.com/mullvad/nftnl-rs). - -[`libnftnl`]: https://netfilter.org/projects/libnftnl/ -[`libmnl`]: https://netfilter.org/projects/libmnl/ -[`rustables`]: https://crates.io/crates/rustables -[`bindgen`]: https://crates.io/crates/bindgen - diff --git a/rustables-sys/build.rs b/rustables-sys/build.rs deleted file mode 100644 index 52e7329..0000000 --- a/rustables-sys/build.rs +++ /dev/null @@ -1,65 +0,0 @@ -extern crate pkg_config; - -use std::{env, path::PathBuf}; - -cfg_if::cfg_if! { - if #[cfg(feature = "nftnl-1-2-0")] { - const MIN_VERSION: &str = "1.2.0"; - } else if #[cfg(feature = "nftnl-1-1-2")] { - const MIN_VERSION: &str = "1.1.2"; - } else if #[cfg(feature = "nftnl-1-1-1")] { - const MIN_VERSION: &str = "1.1.1"; - } else if #[cfg(feature = "nftnl-1-1-0")] { - const MIN_VERSION: &str = "1.1.0"; - } else if #[cfg(feature = "nftnl-1-0-9")] { - const MIN_VERSION: &str = "1.0.9"; - } else if #[cfg(feature = "nftnl-1-0-8")] { - const MIN_VERSION: &str = "1.0.8"; - } else if #[cfg(feature = "nftnl-1-0-7")] { - const MIN_VERSION: &str = "1.0.7"; - } else { - const MIN_VERSION: &str = "1.0.6"; - } -} - -fn get_env(var: &'static str) -> Option<PathBuf> { - println!("cargo:rerun-if-env-changed={}", var); - env::var_os(var).map(PathBuf::from) -} - -fn main() { - if let Some(lib_dir) = get_env("LIBNFTNL_LIB_DIR") { - if !lib_dir.is_dir() { - panic!( - "libnftnl library directory does not exist: {}", - lib_dir.display() - ); - } - println!("cargo:rustc-link-search=native={}", lib_dir.display()); - println!("cargo:rustc-link-lib=nftnl"); - } else { - // Trying with pkg-config instead - println!("Minimum libnftnl version: {}", MIN_VERSION); - pkg_config::Config::new() - .atleast_version(MIN_VERSION) - .probe("libnftnl") - .unwrap(); - } - - if let Some(lib_dir) = get_env("LIBMNL_LIB_DIR") { - if !lib_dir.is_dir() { - panic!( - "libmnl library directory does not exist: {}", - lib_dir.display() - ); - } - println!("cargo:rustc-link-search=native={}", lib_dir.display()); - println!("cargo:rustc-link-lib=mnl"); - } else { - // Trying with pkg-config instead - pkg_config::Config::new() - .atleast_version("1.0.0") - .probe("libmnl") - .unwrap(); - } -} diff --git a/rustables-sys/generate_bindings.sh b/rustables-sys/generate_bindings.sh deleted file mode 100755 index dc1455c..0000000 --- a/rustables-sys/generate_bindings.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash - -# give libnftnl C library dir as first argument and output binding as second. -# Example: -# $ ./generate_bindings.sh ../../libnftnl-1.0.8 src/nftnl_1_0_8.rs - -set -ue - -LIBNFTNL_PATH=$1 -BINDING_PATH=$2 - -echo "Writing the result to $BINDING_PATH" - -bindgen \ - --no-doc-comments \ - --use-core \ - --no-prepend-enum-name \ - --whitelist-function '^nftnl_.+$' \ - --whitelist-type '^nftnl_.+$' \ - --whitelist-var '^nftnl_.+$' \ - --whitelist-var '^NFTNL_.+$' \ - --blacklist-type '(FILE|iovec)' \ - --blacklist-type '^_IO_.+$' \ - --blacklist-type '^__.+$' \ - --blacklist-type 'nlmsghdr' \ - --raw-line 'use libc::{c_char, c_int, c_void, iovec, nlmsghdr, FILE};' \ - --raw-line 'use core::option::Option;' \ - --ctypes-prefix 'libc' \ - -o $BINDING_PATH \ - libnftnl.h --\ - -I$LIBNFTNL_PATH/include - -# Tidy up and correct things I could not manage to configure bindgen to do for me -sed -i 's/libc::\(c_[a-z]*\)/\1/g' $BINDING_PATH -sed -i 's/::core::option::Option/Option/g' $BINDING_PATH -sed -i 's/_bindgen_ty_[0-9]\+/u32/g' $BINDING_PATH -sed -i 's/pub type u32 = u32;//g' $BINDING_PATH -sed -i '/#\[derive(Debug, Copy, Clone)\]/d' $BINDING_PATH - -# Change struct bodies to (c_void); -# Search regex: {\n +_unused: \[u8; 0],\n} -# Replace string: (c_void);\n -sed -i -e '/^pub struct .* {$/ { - N;N - s/ {\n *_unused: \[u8; 0\],\n}/(c_void);\n/ -}' "$BINDING_PATH" - - -# Remove all }\nextern "C" { to condense code a bit -# Search regex: }\nextern "C" { -# Replace string: -sed -i -e '/^extern "C" {$/ { - :loop - n - /^}$/! b loop - /^}$/ { - N - t reset_condition_flags - :reset_condition_flags - s/}\nextern "C" {// - t loop - } -}' "$BINDING_PATH" - -# Add bindgen version to comment at start of file -sed -i "1s/bindgen/$(bindgen --version)/" $BINDING_PATH - -rustfmt $BINDING_PATH diff --git a/rustables-sys/libnftnl.h b/rustables-sys/libnftnl.h deleted file mode 100644 index e6eb221..0000000 --- a/rustables-sys/libnftnl.h +++ /dev/null @@ -1,12 +0,0 @@ -#include <libnftnl/batch.h> -#include <libnftnl/chain.h> -#include <libnftnl/common.h> -#include <libnftnl/expr.h> -#include <libnftnl/gen.h> -#include <libnftnl/object.h> -#include <libnftnl/rule.h> -#include <libnftnl/ruleset.h> -#include <libnftnl/set.h> -#include <libnftnl/table.h> -#include <libnftnl/trace.h> -#include <libnftnl/udata.h> diff --git a/rustables-sys/src/lib.rs b/rustables-sys/src/lib.rs deleted file mode 100644 index 82125f4..0000000 --- a/rustables-sys/src/lib.rs +++ /dev/null @@ -1,91 +0,0 @@ -// 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::*; - } -} diff --git a/rustables-sys/src/nftnl_1_0_6.rs b/rustables-sys/src/nftnl_1_0_6.rs deleted file mode 100644 index 901dbab..0000000 --- a/rustables-sys/src/nftnl_1_0_6.rs +++ /dev/null @@ -1,1043 +0,0 @@ -// automatically generated by rust-bindgen 0.39.0 - -use core::option::Option; -use libc::{c_char, c_int, c_void, iovec, nlmsghdr, FILE}; - -#[repr(C)] -pub struct nftnl_batch(c_void); - -extern "C" { - pub fn nftnl_batch_alloc(pg_size: u32, pg_overrun_size: u32) -> *mut nftnl_batch; - - pub fn nftnl_batch_update(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_free(batch: *mut nftnl_batch); - - pub fn nftnl_batch_buffer(batch: *mut nftnl_batch) -> *mut c_void; - - pub fn nftnl_batch_buffer_len(batch: *mut nftnl_batch) -> u32; - - pub fn nftnl_batch_iovec_len(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_iovec(batch: *mut nftnl_batch, iov: *mut iovec, iovlen: u32); -} -pub const NFTNL_PARSE_EBADINPUT: u32 = 0; -pub const NFTNL_PARSE_EMISSINGNODE: u32 = 1; -pub const NFTNL_PARSE_EBADTYPE: u32 = 2; -pub const NFTNL_PARSE_EOPNOTSUPP: u32 = 3; - -pub const NFTNL_OUTPUT_DEFAULT: nftnl_output_type = 0; -pub const NFTNL_OUTPUT_XML: nftnl_output_type = 1; -pub const NFTNL_OUTPUT_JSON: nftnl_output_type = 2; -pub type nftnl_output_type = u32; -pub const NFTNL_OF_EVENT_NEW: nftnl_output_flags = 1; -pub const NFTNL_OF_EVENT_DEL: nftnl_output_flags = 2; -pub const NFTNL_OF_EVENT_ANY: nftnl_output_flags = 3; -pub type nftnl_output_flags = u32; -pub const NFTNL_CMD_UNSPEC: nftnl_cmd_type = 0; -pub const NFTNL_CMD_ADD: nftnl_cmd_type = 1; -pub const NFTNL_CMD_INSERT: nftnl_cmd_type = 2; -pub const NFTNL_CMD_DELETE: nftnl_cmd_type = 3; -pub const NFTNL_CMD_REPLACE: nftnl_cmd_type = 4; -pub const NFTNL_CMD_FLUSH: nftnl_cmd_type = 5; -pub const NFTNL_CMD_MAX: nftnl_cmd_type = 6; -pub type nftnl_cmd_type = u32; -pub const NFTNL_PARSE_NONE: nftnl_parse_type = 0; -pub const NFTNL_PARSE_XML: nftnl_parse_type = 1; -pub const NFTNL_PARSE_JSON: nftnl_parse_type = 2; -pub const NFTNL_PARSE_MAX: nftnl_parse_type = 3; -pub type nftnl_parse_type = u32; -#[repr(C)] -pub struct nftnl_parse_err(c_void); - -extern "C" { - pub fn nftnl_nlmsg_build_hdr( - buf: *mut c_char, - cmd: u16, - family: u16, - type_: u16, - seq: u32, - ) -> *mut nlmsghdr; - - pub fn nftnl_parse_err_alloc() -> *mut nftnl_parse_err; - - pub fn nftnl_parse_err_free(arg1: *mut nftnl_parse_err); - - pub fn nftnl_parse_perror(str: *const c_char, err: *mut nftnl_parse_err) -> c_int; - - pub fn nftnl_batch_is_supported() -> c_int; - - pub fn nftnl_batch_begin(buf: *mut c_char, seq: u32); - - pub fn nftnl_batch_end(buf: *mut c_char, seq: u32); -} -#[repr(C)] -pub struct nftnl_chain(c_void); - -extern "C" { - pub fn nftnl_chain_alloc() -> *mut nftnl_chain; - - pub fn nftnl_chain_free(arg1: *const nftnl_chain); -} -pub const NFTNL_CHAIN_NAME: nftnl_chain_attr = 0; -pub const NFTNL_CHAIN_FAMILY: nftnl_chain_attr = 1; -pub const NFTNL_CHAIN_TABLE: nftnl_chain_attr = 2; -pub const NFTNL_CHAIN_HOOKNUM: nftnl_chain_attr = 3; -pub const NFTNL_CHAIN_PRIO: nftnl_chain_attr = 4; -pub const NFTNL_CHAIN_POLICY: nftnl_chain_attr = 5; -pub const NFTNL_CHAIN_USE: nftnl_chain_attr = 6; -pub const NFTNL_CHAIN_BYTES: nftnl_chain_attr = 7; -pub const NFTNL_CHAIN_PACKETS: nftnl_chain_attr = 8; -pub const NFTNL_CHAIN_HANDLE: nftnl_chain_attr = 9; -pub const NFTNL_CHAIN_TYPE: nftnl_chain_attr = 10; -pub const NFTNL_CHAIN_DEV: nftnl_chain_attr = 11; -pub const __NFTNL_CHAIN_MAX: nftnl_chain_attr = 12; -pub type nftnl_chain_attr = u32; -extern "C" { - pub fn nftnl_chain_is_set(c: *const nftnl_chain, attr: u16) -> bool; - - pub fn nftnl_chain_unset(c: *mut nftnl_chain, attr: u16); - - pub fn nftnl_chain_set(t: *mut nftnl_chain, attr: u16, data: *const c_void); - - pub fn nftnl_chain_set_data(t: *mut nftnl_chain, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_chain_set_u8(t: *mut nftnl_chain, attr: u16, data: u8); - - pub fn nftnl_chain_set_u32(t: *mut nftnl_chain, attr: u16, data: u32); - - pub fn nftnl_chain_set_s32(t: *mut nftnl_chain, attr: u16, data: i32); - - pub fn nftnl_chain_set_u64(t: *mut nftnl_chain, attr: u16, data: u64); - - pub fn nftnl_chain_set_str(t: *mut nftnl_chain, attr: u16, str: *const c_char); - - pub fn nftnl_chain_get(c: *const nftnl_chain, attr: u16) -> *const c_void; - - pub fn nftnl_chain_get_data( - c: *const nftnl_chain, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_chain_get_str(c: *const nftnl_chain, attr: u16) -> *const c_char; - - pub fn nftnl_chain_get_u8(c: *const nftnl_chain, attr: u16) -> u8; - - pub fn nftnl_chain_get_u32(c: *const nftnl_chain, attr: u16) -> u32; - - pub fn nftnl_chain_get_s32(c: *const nftnl_chain, attr: u16) -> i32; - - pub fn nftnl_chain_get_u64(c: *const nftnl_chain, attr: u16) -> u64; - - pub fn nftnl_chain_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_chain); - - pub fn nftnl_chain_parse( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_parse_file( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_fprintf( - fp: *mut FILE, - c: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_chain) -> c_int; -} -#[repr(C)] -pub struct nftnl_chain_list(c_void); - -extern "C" { - pub fn nftnl_chain_list_alloc() -> *mut nftnl_chain_list; - - pub fn nftnl_chain_list_free(list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_is_empty(list: *const nftnl_chain_list) -> c_int; - - pub fn nftnl_chain_list_foreach( - chain_list: *mut nftnl_chain_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_chain, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_chain_list_add(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_add_tail(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_del(c: *mut nftnl_chain); -} -#[repr(C)] -pub struct nftnl_chain_list_iter(c_void); - -extern "C" { - pub fn nftnl_chain_list_iter_create(l: *mut nftnl_chain_list) -> *mut nftnl_chain_list_iter; - - pub fn nftnl_chain_list_iter_next(iter: *mut nftnl_chain_list_iter) -> *mut nftnl_chain; - - pub fn nftnl_chain_list_iter_destroy(iter: *mut nftnl_chain_list_iter); -} -#[repr(C)] -pub struct nftnl_expr(c_void); - -pub const NFTNL_EXPR_NAME: u32 = 0; -pub const NFTNL_EXPR_BASE: u32 = 1; - -extern "C" { - pub fn nftnl_expr_alloc(name: *const c_char) -> *mut nftnl_expr; - - pub fn nftnl_expr_free(expr: *const nftnl_expr); - - pub fn nftnl_expr_is_set(expr: *const nftnl_expr, type_: u16) -> bool; - - pub fn nftnl_expr_set(expr: *mut nftnl_expr, type_: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_expr_set_u8(expr: *mut nftnl_expr, type_: u16, data: u8); - - pub fn nftnl_expr_set_u16(expr: *mut nftnl_expr, type_: u16, data: u16); - - pub fn nftnl_expr_set_u32(expr: *mut nftnl_expr, type_: u16, data: u32); - - pub fn nftnl_expr_set_u64(expr: *mut nftnl_expr, type_: u16, data: u64); - - pub fn nftnl_expr_set_str(expr: *mut nftnl_expr, type_: u16, str: *const c_char); - - pub fn nftnl_expr_get(expr: *const nftnl_expr, type_: u16, data_len: *mut u32) - -> *const c_void; - - pub fn nftnl_expr_get_u8(expr: *const nftnl_expr, type_: u16) -> u8; - - pub fn nftnl_expr_get_u16(expr: *const nftnl_expr, type_: u16) -> u16; - - pub fn nftnl_expr_get_u32(expr: *const nftnl_expr, type_: u16) -> u32; - - pub fn nftnl_expr_get_u64(expr: *const nftnl_expr, type_: u16) -> u64; - - pub fn nftnl_expr_get_str(expr: *const nftnl_expr, type_: u16) -> *const c_char; - - pub fn nftnl_expr_snprintf( - buf: *mut c_char, - buflen: usize, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_EXPR_PAYLOAD_DREG: u32 = 1; -pub const NFTNL_EXPR_PAYLOAD_BASE: u32 = 2; -pub const NFTNL_EXPR_PAYLOAD_OFFSET: u32 = 3; -pub const NFTNL_EXPR_PAYLOAD_LEN: u32 = 4; -pub const NFTNL_EXPR_PAYLOAD_SREG: u32 = 5; -pub const NFTNL_EXPR_PAYLOAD_CSUM_TYPE: u32 = 6; -pub const NFTNL_EXPR_PAYLOAD_CSUM_OFFSET: u32 = 7; - -pub const NFTNL_EXPR_META_KEY: u32 = 1; -pub const NFTNL_EXPR_META_DREG: u32 = 2; -pub const NFTNL_EXPR_META_SREG: u32 = 3; - -pub const NFTNL_EXPR_CMP_SREG: u32 = 1; -pub const NFTNL_EXPR_CMP_OP: u32 = 2; -pub const NFTNL_EXPR_CMP_DATA: u32 = 3; - -pub const NFTNL_EXPR_IMM_DREG: u32 = 1; -pub const NFTNL_EXPR_IMM_DATA: u32 = 2; -pub const NFTNL_EXPR_IMM_VERDICT: u32 = 3; -pub const NFTNL_EXPR_IMM_CHAIN: u32 = 4; - -pub const NFTNL_EXPR_CTR_PACKETS: u32 = 1; -pub const NFTNL_EXPR_CTR_BYTES: u32 = 2; - -pub const NFTNL_EXPR_BITWISE_SREG: u32 = 1; -pub const NFTNL_EXPR_BITWISE_DREG: u32 = 2; -pub const NFTNL_EXPR_BITWISE_LEN: u32 = 3; -pub const NFTNL_EXPR_BITWISE_MASK: u32 = 4; -pub const NFTNL_EXPR_BITWISE_XOR: u32 = 5; - -pub const NFTNL_EXPR_TG_NAME: u32 = 1; -pub const NFTNL_EXPR_TG_REV: u32 = 2; -pub const NFTNL_EXPR_TG_INFO: u32 = 3; - -pub const NFTNL_EXPR_MT_NAME: u32 = 1; -pub const NFTNL_EXPR_MT_REV: u32 = 2; -pub const NFTNL_EXPR_MT_INFO: u32 = 3; - -pub const NFTNL_EXPR_NAT_TYPE: u32 = 1; -pub const NFTNL_EXPR_NAT_FAMILY: u32 = 2; -pub const NFTNL_EXPR_NAT_REG_ADDR_MIN: u32 = 3; -pub const NFTNL_EXPR_NAT_REG_ADDR_MAX: u32 = 4; -pub const NFTNL_EXPR_NAT_REG_PROTO_MIN: u32 = 5; -pub const NFTNL_EXPR_NAT_REG_PROTO_MAX: u32 = 6; -pub const NFTNL_EXPR_NAT_FLAGS: u32 = 7; - -pub const NFTNL_EXPR_LOOKUP_SREG: u32 = 1; -pub const NFTNL_EXPR_LOOKUP_DREG: u32 = 2; -pub const NFTNL_EXPR_LOOKUP_SET: u32 = 3; -pub const NFTNL_EXPR_LOOKUP_SET_ID: u32 = 4; - -pub const NFTNL_EXPR_DYNSET_SREG_KEY: u32 = 1; -pub const NFTNL_EXPR_DYNSET_SREG_DATA: u32 = 2; -pub const NFTNL_EXPR_DYNSET_OP: u32 = 3; -pub const NFTNL_EXPR_DYNSET_TIMEOUT: u32 = 4; -pub const NFTNL_EXPR_DYNSET_SET_NAME: u32 = 5; -pub const NFTNL_EXPR_DYNSET_SET_ID: u32 = 6; -pub const NFTNL_EXPR_DYNSET_EXPR: u32 = 7; - -pub const NFTNL_EXPR_LOG_PREFIX: u32 = 1; -pub const NFTNL_EXPR_LOG_GROUP: u32 = 2; -pub const NFTNL_EXPR_LOG_SNAPLEN: u32 = 3; -pub const NFTNL_EXPR_LOG_QTHRESHOLD: u32 = 4; -pub const NFTNL_EXPR_LOG_LEVEL: u32 = 5; -pub const NFTNL_EXPR_LOG_FLAGS: u32 = 6; - -pub const NFTNL_EXPR_EXTHDR_DREG: u32 = 1; -pub const NFTNL_EXPR_EXTHDR_TYPE: u32 = 2; -pub const NFTNL_EXPR_EXTHDR_OFFSET: u32 = 3; -pub const NFTNL_EXPR_EXTHDR_LEN: u32 = 4; - -pub const NFTNL_EXPR_CT_DREG: u32 = 1; -pub const NFTNL_EXPR_CT_KEY: u32 = 2; -pub const NFTNL_EXPR_CT_DIR: u32 = 3; -pub const NFTNL_EXPR_CT_SREG: u32 = 4; - -pub const NFTNL_EXPR_BYTEORDER_DREG: u32 = 1; -pub const NFTNL_EXPR_BYTEORDER_SREG: u32 = 2; -pub const NFTNL_EXPR_BYTEORDER_OP: u32 = 3; -pub const NFTNL_EXPR_BYTEORDER_LEN: u32 = 4; -pub const NFTNL_EXPR_BYTEORDER_SIZE: u32 = 5; - -pub const NFTNL_EXPR_LIMIT_RATE: u32 = 1; -pub const NFTNL_EXPR_LIMIT_UNIT: u32 = 2; -pub const NFTNL_EXPR_LIMIT_BURST: u32 = 3; -pub const NFTNL_EXPR_LIMIT_TYPE: u32 = 4; -pub const NFTNL_EXPR_LIMIT_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_REJECT_TYPE: u32 = 1; -pub const NFTNL_EXPR_REJECT_CODE: u32 = 2; - -pub const NFTNL_EXPR_QUEUE_NUM: u32 = 1; -pub const NFTNL_EXPR_QUEUE_TOTAL: u32 = 2; -pub const NFTNL_EXPR_QUEUE_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_MASQ_FLAGS: u32 = 1; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MIN: u32 = 2; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MAX: u32 = 3; - -pub const NFTNL_EXPR_REDIR_REG_PROTO_MIN: u32 = 1; -pub const NFTNL_EXPR_REDIR_REG_PROTO_MAX: u32 = 2; -pub const NFTNL_EXPR_REDIR_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_DUP_SREG_ADDR: u32 = 1; -pub const NFTNL_EXPR_DUP_SREG_DEV: u32 = 2; - -pub const NFTNL_EXPR_FWD_SREG_DEV: u32 = 1; - -#[repr(C)] -pub struct nftnl_gen(c_void); - -extern "C" { - pub fn nftnl_gen_alloc() -> *mut nftnl_gen; - - pub fn nftnl_gen_free(arg1: *const nftnl_gen); -} -pub const NFTNL_GEN_ID: u32 = 0; -pub const __NFTNL_GEN_MAX: u32 = 1; - -extern "C" { - pub fn nftnl_gen_is_set(gen: *const nftnl_gen, attr: u16) -> bool; - - pub fn nftnl_gen_unset(gen: *mut nftnl_gen, attr: u16); - - pub fn nftnl_gen_set(gen: *mut nftnl_gen, attr: u16, data: *const c_void); - - pub fn nftnl_gen_set_data(gen: *mut nftnl_gen, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_gen_get(gen: *const nftnl_gen, attr: u16) -> *const c_void; - - pub fn nftnl_gen_get_data( - gen: *const nftnl_gen, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_gen_set_u32(gen: *mut nftnl_gen, attr: u16, data: u32); - - pub fn nftnl_gen_get_u32(gen: *const nftnl_gen, attr: u16) -> u32; - - pub fn nftnl_gen_nlmsg_parse(nlh: *const nlmsghdr, gen: *mut nftnl_gen) -> c_int; - - pub fn nftnl_gen_snprintf( - buf: *mut c_char, - size: usize, - gen: *const nftnl_gen, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_gen_fprintf(fp: *mut FILE, gen: *const nftnl_gen, type_: u32, flags: u32) - -> c_int; -} -#[repr(C)] -pub struct nftnl_rule(c_void); - -extern "C" { - pub fn nftnl_rule_alloc() -> *mut nftnl_rule; - - pub fn nftnl_rule_free(arg1: *const nftnl_rule); -} -pub const NFTNL_RULE_FAMILY: nftnl_rule_attr = 0; -pub const NFTNL_RULE_TABLE: nftnl_rule_attr = 1; -pub const NFTNL_RULE_CHAIN: nftnl_rule_attr = 2; -pub const NFTNL_RULE_HANDLE: nftnl_rule_attr = 3; -pub const NFTNL_RULE_COMPAT_PROTO: nftnl_rule_attr = 4; -pub const NFTNL_RULE_COMPAT_FLAGS: nftnl_rule_attr = 5; -pub const NFTNL_RULE_POSITION: nftnl_rule_attr = 6; -pub const NFTNL_RULE_USERDATA: nftnl_rule_attr = 7; -pub const __NFTNL_RULE_MAX: nftnl_rule_attr = 8; -pub type nftnl_rule_attr = u32; -extern "C" { - pub fn nftnl_rule_unset(r: *mut nftnl_rule, attr: u16); - - pub fn nftnl_rule_is_set(r: *const nftnl_rule, attr: u16) -> bool; - - pub fn nftnl_rule_set(r: *mut nftnl_rule, attr: u16, data: *const c_void); - - pub fn nftnl_rule_set_data(r: *mut nftnl_rule, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_rule_set_u32(r: *mut nftnl_rule, attr: u16, val: u32); - - pub fn nftnl_rule_set_u64(r: *mut nftnl_rule, attr: u16, val: u64); - - pub fn nftnl_rule_set_str(r: *mut nftnl_rule, attr: u16, str: *const c_char); - - pub fn nftnl_rule_get(r: *const nftnl_rule, attr: u16) -> *const c_void; - - pub fn nftnl_rule_get_data( - r: *const nftnl_rule, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_rule_get_str(r: *const nftnl_rule, attr: u16) -> *const c_char; - - pub fn nftnl_rule_get_u8(r: *const nftnl_rule, attr: u16) -> u8; - - pub fn nftnl_rule_get_u32(r: *const nftnl_rule, attr: u16) -> u32; - - pub fn nftnl_rule_get_u64(r: *const nftnl_rule, attr: u16) -> u64; - - pub fn nftnl_rule_add_expr(r: *mut nftnl_rule, expr: *mut nftnl_expr); - - pub fn nftnl_rule_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *mut nftnl_rule); - - pub fn nftnl_rule_parse( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_parse_file( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_rule, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_rule_fprintf(fp: *mut FILE, r: *const nftnl_rule, type_: u32, flags: u32) - -> c_int; - - pub fn nftnl_rule_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_rule) -> c_int; - - pub fn nftnl_expr_foreach( - r: *mut nftnl_rule, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_expr, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_expr_iter(c_void); - -extern "C" { - pub fn nftnl_expr_iter_create(r: *mut nftnl_rule) -> *mut nftnl_expr_iter; - - pub fn nftnl_expr_iter_next(iter: *mut nftnl_expr_iter) -> *mut nftnl_expr; - - pub fn nftnl_expr_iter_destroy(iter: *mut nftnl_expr_iter); -} -#[repr(C)] -pub struct nftnl_rule_list(c_void); - -extern "C" { - pub fn nftnl_rule_list_alloc() -> *mut nftnl_rule_list; - - pub fn nftnl_rule_list_free(list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_is_empty(list: *const nftnl_rule_list) -> c_int; - - pub fn nftnl_rule_list_add(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_add_tail(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_del(r: *mut nftnl_rule); - - pub fn nftnl_rule_list_foreach( - rule_list: *mut nftnl_rule_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_rule, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_rule_list_iter(c_void); - -extern "C" { - pub fn nftnl_rule_list_iter_create(l: *mut nftnl_rule_list) -> *mut nftnl_rule_list_iter; - - pub fn nftnl_rule_list_iter_cur(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_next(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_destroy(iter: *const nftnl_rule_list_iter); -} -#[repr(C)] -pub struct nftnl_ruleset(c_void); - -extern "C" { - pub fn nftnl_ruleset_alloc() -> *mut nftnl_ruleset; - - pub fn nftnl_ruleset_free(r: *const nftnl_ruleset); -} -pub const NFTNL_RULESET_TABLELIST: u32 = 0; -pub const NFTNL_RULESET_CHAINLIST: u32 = 1; -pub const NFTNL_RULESET_SETLIST: u32 = 2; -pub const NFTNL_RULESET_RULELIST: u32 = 3; - -pub const NFTNL_RULESET_UNSPEC: nftnl_ruleset_type = 0; -pub const NFTNL_RULESET_RULESET: nftnl_ruleset_type = 1; -pub const NFTNL_RULESET_TABLE: nftnl_ruleset_type = 2; -pub const NFTNL_RULESET_CHAIN: nftnl_ruleset_type = 3; -pub const NFTNL_RULESET_RULE: nftnl_ruleset_type = 4; -pub const NFTNL_RULESET_SET: nftnl_ruleset_type = 5; -pub const NFTNL_RULESET_SET_ELEMS: nftnl_ruleset_type = 6; -pub type nftnl_ruleset_type = u32; -extern "C" { - pub fn nftnl_ruleset_is_set(r: *const nftnl_ruleset, attr: u16) -> bool; - - pub fn nftnl_ruleset_unset(r: *mut nftnl_ruleset, attr: u16); - - pub fn nftnl_ruleset_set(r: *mut nftnl_ruleset, attr: u16, data: *mut c_void); - - pub fn nftnl_ruleset_get(r: *const nftnl_ruleset, attr: u16) -> *mut c_void; -} -pub const NFTNL_RULESET_CTX_CMD: u32 = 0; -pub const NFTNL_RULESET_CTX_TYPE: u32 = 1; -pub const NFTNL_RULESET_CTX_TABLE: u32 = 2; -pub const NFTNL_RULESET_CTX_CHAIN: u32 = 3; -pub const NFTNL_RULESET_CTX_RULE: u32 = 4; -pub const NFTNL_RULESET_CTX_SET: u32 = 5; -pub const NFTNL_RULESET_CTX_DATA: u32 = 6; - -#[repr(C)] -pub struct nftnl_parse_ctx(c_void); - -extern "C" { - pub fn nftnl_ruleset_ctx_free(ctx: *const nftnl_parse_ctx); - - pub fn nftnl_ruleset_ctx_is_set(ctx: *const nftnl_parse_ctx, attr: u16) -> bool; - - pub fn nftnl_ruleset_ctx_get(ctx: *const nftnl_parse_ctx, attr: u16) -> *mut c_void; - - pub fn nftnl_ruleset_ctx_get_u32(ctx: *const nftnl_parse_ctx, attr: u16) -> u32; - - pub fn nftnl_ruleset_parse_file_cb( - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse_buffer_cb( - type_: nftnl_parse_type, - buffer: *const c_char, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_parse_file( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_snprintf( - buf: *mut c_char, - size: usize, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_ruleset_fprintf( - fp: *mut FILE, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_SET_TABLE: nftnl_set_attr = 0; -pub const NFTNL_SET_NAME: nftnl_set_attr = 1; -pub const NFTNL_SET_FLAGS: nftnl_set_attr = 2; -pub const NFTNL_SET_KEY_TYPE: nftnl_set_attr = 3; -pub const NFTNL_SET_KEY_LEN: nftnl_set_attr = 4; -pub const NFTNL_SET_DATA_TYPE: nftnl_set_attr = 5; -pub const NFTNL_SET_DATA_LEN: nftnl_set_attr = 6; -pub const NFTNL_SET_FAMILY: nftnl_set_attr = 7; -pub const NFTNL_SET_ID: nftnl_set_attr = 8; -pub const NFTNL_SET_POLICY: nftnl_set_attr = 9; -pub const NFTNL_SET_DESC_SIZE: nftnl_set_attr = 10; -pub const NFTNL_SET_TIMEOUT: nftnl_set_attr = 11; -pub const NFTNL_SET_GC_INTERVAL: nftnl_set_attr = 12; -pub const __NFTNL_SET_MAX: nftnl_set_attr = 13; -pub type nftnl_set_attr = u32; -#[repr(C)] -pub struct nftnl_set(c_void); - -extern "C" { - pub fn nftnl_set_alloc() -> *mut nftnl_set; - - pub fn nftnl_set_free(s: *const nftnl_set); - - pub fn nftnl_set_clone(set: *const nftnl_set) -> *mut nftnl_set; - - pub fn nftnl_set_is_set(s: *const nftnl_set, attr: u16) -> bool; - - pub fn nftnl_set_unset(s: *mut nftnl_set, attr: u16); - - pub fn nftnl_set_set(s: *mut nftnl_set, attr: u16, data: *const c_void); - - pub fn nftnl_set_set_data(s: *mut nftnl_set, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_set_set_u32(s: *mut nftnl_set, attr: u16, val: u32); - - pub fn nftnl_set_set_u64(s: *mut nftnl_set, attr: u16, val: u64); - - pub fn nftnl_set_set_str(s: *mut nftnl_set, attr: u16, str: *const c_char); - - pub fn nftnl_set_get(s: *const nftnl_set, attr: u16) -> *const c_void; - - pub fn nftnl_set_get_data(s: *const nftnl_set, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_set_get_str(s: *const nftnl_set, attr: u16) -> *const c_char; - - pub fn nftnl_set_get_u32(s: *const nftnl_set, attr: u16) -> u32; - - pub fn nftnl_set_get_u64(s: *const nftnl_set, attr: u16) -> u64; - - pub fn nftnl_set_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_elems_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_fprintf(fp: *mut FILE, s: *const nftnl_set, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list(c_void); - -extern "C" { - pub fn nftnl_set_list_alloc() -> *mut nftnl_set_list; - - pub fn nftnl_set_list_free(list: *mut nftnl_set_list); - - pub fn nftnl_set_list_is_empty(list: *const nftnl_set_list) -> c_int; - - pub fn nftnl_set_list_add(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_add_tail(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_del(s: *mut nftnl_set); - - pub fn nftnl_set_list_foreach( - set_list: *mut nftnl_set_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_set, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list_iter(c_void); - -extern "C" { - pub fn nftnl_set_list_iter_create(l: *mut nftnl_set_list) -> *mut nftnl_set_list_iter; - - pub fn nftnl_set_list_iter_cur(iter: *mut nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_next(iter: *mut nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_destroy(iter: *const nftnl_set_list_iter); - - pub fn nftnl_set_parse( - s: *mut nftnl_set, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_parse_file( - s: *mut nftnl_set, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; -} -pub const NFTNL_SET_ELEM_FLAGS: u32 = 0; -pub const NFTNL_SET_ELEM_KEY: u32 = 1; -pub const NFTNL_SET_ELEM_VERDICT: u32 = 2; -pub const NFTNL_SET_ELEM_CHAIN: u32 = 3; -pub const NFTNL_SET_ELEM_DATA: u32 = 4; -pub const NFTNL_SET_ELEM_TIMEOUT: u32 = 5; -pub const NFTNL_SET_ELEM_EXPIRATION: u32 = 6; -pub const NFTNL_SET_ELEM_USERDATA: u32 = 7; -pub const NFTNL_SET_ELEM_EXPR: u32 = 8; - -#[repr(C)] -pub struct nftnl_set_elem(c_void); - -extern "C" { - pub fn nftnl_set_elem_alloc() -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_free(s: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_clone(elem: *mut nftnl_set_elem) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_add(s: *mut nftnl_set, elem: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_unset(s: *mut nftnl_set_elem, attr: u16); - - pub fn nftnl_set_elem_set( - s: *mut nftnl_set_elem, - attr: u16, - data: *const c_void, - data_len: u32, - ); - - pub fn nftnl_set_elem_set_u32(s: *mut nftnl_set_elem, attr: u16, val: u32); - - pub fn nftnl_set_elem_set_u64(s: *mut nftnl_set_elem, attr: u16, val: u64); - - pub fn nftnl_set_elem_set_str(s: *mut nftnl_set_elem, attr: u16, str: *const c_char); - - pub fn nftnl_set_elem_get( - s: *mut nftnl_set_elem, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_set_elem_get_str(s: *mut nftnl_set_elem, attr: u16) -> *const c_char; - - pub fn nftnl_set_elem_get_u32(s: *mut nftnl_set_elem, attr: u16) -> u32; - - pub fn nftnl_set_elem_get_u64(s: *mut nftnl_set_elem, attr: u16) -> u64; - - pub fn nftnl_set_elem_is_set(s: *const nftnl_set_elem, attr: u16) -> bool; - - pub fn nftnl_set_elems_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_elem_nlmsg_build_payload(nlh: *mut nlmsghdr, e: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_parse( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_parse_file( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_fprintf( - fp: *mut FILE, - se: *mut nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_foreach( - s: *mut nftnl_set, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_set_elem, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_elems_iter(c_void); - -extern "C" { - pub fn nftnl_set_elems_iter_create(s: *mut nftnl_set) -> *mut nftnl_set_elems_iter; - - pub fn nftnl_set_elems_iter_cur(iter: *mut nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_next(iter: *mut nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_destroy(iter: *mut nftnl_set_elems_iter); - - pub fn nftnl_set_elems_nlmsg_build_payload_iter( - nlh: *mut nlmsghdr, - iter: *mut nftnl_set_elems_iter, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_table(c_void); - -extern "C" { - pub fn nftnl_table_alloc() -> *mut nftnl_table; - - pub fn nftnl_table_free(arg1: *const nftnl_table); -} -pub const NFTNL_TABLE_NAME: nftnl_table_attr = 0; -pub const NFTNL_TABLE_FAMILY: nftnl_table_attr = 1; -pub const NFTNL_TABLE_FLAGS: nftnl_table_attr = 2; -pub const NFTNL_TABLE_USE: nftnl_table_attr = 3; -pub const __NFTNL_TABLE_MAX: nftnl_table_attr = 4; -pub type nftnl_table_attr = u32; -extern "C" { - pub fn nftnl_table_is_set(t: *const nftnl_table, attr: u16) -> bool; - - pub fn nftnl_table_unset(t: *mut nftnl_table, attr: u16); - - pub fn nftnl_table_set(t: *mut nftnl_table, attr: u16, data: *const c_void); - - pub fn nftnl_table_set_data(t: *mut nftnl_table, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_table_get(t: *const nftnl_table, attr: u16) -> *const c_void; - - pub fn nftnl_table_get_data( - t: *const nftnl_table, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_table_set_u8(t: *mut nftnl_table, attr: u16, data: u8); - - pub fn nftnl_table_set_u32(t: *mut nftnl_table, attr: u16, data: u32); - - pub fn nftnl_table_set_str(t: *mut nftnl_table, attr: u16, str: *const c_char); - - pub fn nftnl_table_get_u8(t: *const nftnl_table, attr: u16) -> u8; - - pub fn nftnl_table_get_u32(t: *const nftnl_table, attr: u16) -> u32; - - pub fn nftnl_table_get_str(t: *const nftnl_table, attr: u16) -> *const c_char; - - pub fn nftnl_table_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_table); - - pub fn nftnl_table_parse( - t: *mut nftnl_table, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_parse_file( - t: *mut nftnl_table, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_fprintf( - fp: *mut FILE, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_table) -> c_int; -} -#[repr(C)] -pub struct nftnl_table_list(c_void); - -extern "C" { - pub fn nftnl_table_list_alloc() -> *mut nftnl_table_list; - - pub fn nftnl_table_list_free(list: *mut nftnl_table_list); - - pub fn nftnl_table_list_is_empty(list: *const nftnl_table_list) -> c_int; - - pub fn nftnl_table_list_foreach( - table_list: *mut nftnl_table_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_table, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_table_list_add(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_add_tail(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_del(r: *mut nftnl_table); -} -#[repr(C)] -pub struct nftnl_table_list_iter(c_void); - -extern "C" { - pub fn nftnl_table_list_iter_create(l: *mut nftnl_table_list) -> *mut nftnl_table_list_iter; - - pub fn nftnl_table_list_iter_next(iter: *mut nftnl_table_list_iter) -> *mut nftnl_table; - - pub fn nftnl_table_list_iter_destroy(iter: *const nftnl_table_list_iter); -} -pub const NFTNL_TRACE_CHAIN: nftnl_trace_attr = 0; -pub const NFTNL_TRACE_FAMILY: nftnl_trace_attr = 1; -pub const NFTNL_TRACE_ID: nftnl_trace_attr = 2; -pub const NFTNL_TRACE_IIF: nftnl_trace_attr = 3; -pub const NFTNL_TRACE_IIFTYPE: nftnl_trace_attr = 4; -pub const NFTNL_TRACE_JUMP_TARGET: nftnl_trace_attr = 5; -pub const NFTNL_TRACE_OIF: nftnl_trace_attr = 6; -pub const NFTNL_TRACE_OIFTYPE: nftnl_trace_attr = 7; -pub const NFTNL_TRACE_MARK: nftnl_trace_attr = 8; -pub const NFTNL_TRACE_LL_HEADER: nftnl_trace_attr = 9; -pub const NFTNL_TRACE_NETWORK_HEADER: nftnl_trace_attr = 10; -pub const NFTNL_TRACE_TRANSPORT_HEADER: nftnl_trace_attr = 11; -pub const NFTNL_TRACE_TABLE: nftnl_trace_attr = 12; -pub const NFTNL_TRACE_TYPE: nftnl_trace_attr = 13; -pub const NFTNL_TRACE_RULE_HANDLE: nftnl_trace_attr = 14; -pub const NFTNL_TRACE_VERDICT: nftnl_trace_attr = 15; -pub const NFTNL_TRACE_NFPROTO: nftnl_trace_attr = 16; -pub const NFTNL_TRACE_POLICY: nftnl_trace_attr = 17; -pub const __NFTNL_TRACE_MAX: nftnl_trace_attr = 18; -pub type nftnl_trace_attr = u32; -#[repr(C)] -pub struct nftnl_trace(c_void); - -extern "C" { - pub fn nftnl_trace_alloc() -> *mut nftnl_trace; - - pub fn nftnl_trace_free(trace: *const nftnl_trace); - - pub fn nftnl_trace_is_set(trace: *const nftnl_trace, type_: u16) -> bool; - - pub fn nftnl_trace_get_data( - trace: *const nftnl_trace, - type_: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_trace_get_u16(trace: *const nftnl_trace, type_: u16) -> u16; - - pub fn nftnl_trace_get_u32(trace: *const nftnl_trace, type_: u16) -> u32; - - pub fn nftnl_trace_get_u64(trace: *const nftnl_trace, type_: u16) -> u64; - - pub fn nftnl_trace_get_str(trace: *const nftnl_trace, type_: u16) -> *const c_char; - - pub fn nftnl_trace_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_trace) -> c_int; -} -#[repr(C)] -pub struct nftnl_udata(c_void); - -#[repr(C)] -pub struct nftnl_udata_buf(c_void); - -extern "C" { - pub fn nftnl_udata_buf_alloc(data_size: u32) -> *mut nftnl_udata_buf; - - pub fn nftnl_udata_buf_free(buf: *const nftnl_udata_buf); - - pub fn nftnl_udata_buf_len(buf: *const nftnl_udata_buf) -> u32; - - pub fn nftnl_udata_buf_data(buf: *const nftnl_udata_buf) -> *mut c_void; - - pub fn nftnl_udata_buf_put(buf: *mut nftnl_udata_buf, data: *const c_void, len: u32); - - pub fn nftnl_udata_start(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_end(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_put( - buf: *mut nftnl_udata_buf, - type_: u8, - len: u32, - value: *const c_void, - ) -> bool; - - pub fn nftnl_udata_put_strz(buf: *mut nftnl_udata_buf, type_: u8, strz: *const c_char) -> bool; - - pub fn nftnl_udata_type(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_len(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_get(attr: *const nftnl_udata) -> *mut c_void; - - pub fn nftnl_udata_next(attr: *const nftnl_udata) -> *mut nftnl_udata; -} -pub type nftnl_udata_cb_t = - Option<unsafe extern "C" fn(attr: *const nftnl_udata, data: *mut c_void) -> c_int>; -extern "C" { - pub fn nftnl_udata_parse( - data: *const c_void, - data_len: u32, - cb: nftnl_udata_cb_t, - cb_data: *mut c_void, - ) -> c_int; -} diff --git a/rustables-sys/src/nftnl_1_0_7.rs b/rustables-sys/src/nftnl_1_0_7.rs deleted file mode 100644 index 7bf3e83..0000000 --- a/rustables-sys/src/nftnl_1_0_7.rs +++ /dev/null @@ -1,1224 +0,0 @@ -// automatically generated by rust-bindgen 0.39.0 - -use core::option::Option; -use libc::{c_char, c_int, c_void, iovec, nlmsghdr, FILE}; - -#[repr(C)] -pub struct nftnl_batch(c_void); - -extern "C" { - pub fn nftnl_batch_alloc(pg_size: u32, pg_overrun_size: u32) -> *mut nftnl_batch; - - pub fn nftnl_batch_update(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_free(batch: *mut nftnl_batch); - - pub fn nftnl_batch_buffer(batch: *mut nftnl_batch) -> *mut c_void; - - pub fn nftnl_batch_buffer_len(batch: *mut nftnl_batch) -> u32; - - pub fn nftnl_batch_iovec_len(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_iovec(batch: *mut nftnl_batch, iov: *mut iovec, iovlen: u32); -} -pub const NFTNL_PARSE_EBADINPUT: u32 = 0; -pub const NFTNL_PARSE_EMISSINGNODE: u32 = 1; -pub const NFTNL_PARSE_EBADTYPE: u32 = 2; -pub const NFTNL_PARSE_EOPNOTSUPP: u32 = 3; - -pub const NFTNL_OUTPUT_DEFAULT: nftnl_output_type = 0; -pub const NFTNL_OUTPUT_XML: nftnl_output_type = 1; -pub const NFTNL_OUTPUT_JSON: nftnl_output_type = 2; -pub type nftnl_output_type = u32; -pub const NFTNL_OF_EVENT_NEW: nftnl_output_flags = 1; -pub const NFTNL_OF_EVENT_DEL: nftnl_output_flags = 2; -pub const NFTNL_OF_EVENT_ANY: nftnl_output_flags = 3; -pub type nftnl_output_flags = u32; -pub const NFTNL_CMD_UNSPEC: nftnl_cmd_type = 0; -pub const NFTNL_CMD_ADD: nftnl_cmd_type = 1; -pub const NFTNL_CMD_INSERT: nftnl_cmd_type = 2; -pub const NFTNL_CMD_DELETE: nftnl_cmd_type = 3; -pub const NFTNL_CMD_REPLACE: nftnl_cmd_type = 4; -pub const NFTNL_CMD_FLUSH: nftnl_cmd_type = 5; -pub const NFTNL_CMD_MAX: nftnl_cmd_type = 6; -pub type nftnl_cmd_type = u32; -pub const NFTNL_PARSE_NONE: nftnl_parse_type = 0; -pub const NFTNL_PARSE_XML: nftnl_parse_type = 1; -pub const NFTNL_PARSE_JSON: nftnl_parse_type = 2; -pub const NFTNL_PARSE_MAX: nftnl_parse_type = 3; -pub type nftnl_parse_type = u32; -#[repr(C)] -pub struct nftnl_parse_err(c_void); - -extern "C" { - pub fn nftnl_nlmsg_build_hdr( - buf: *mut c_char, - cmd: u16, - family: u16, - type_: u16, - seq: u32, - ) -> *mut nlmsghdr; - - pub fn nftnl_parse_err_alloc() -> *mut nftnl_parse_err; - - pub fn nftnl_parse_err_free(arg1: *mut nftnl_parse_err); - - pub fn nftnl_parse_perror(str: *const c_char, err: *mut nftnl_parse_err) -> c_int; - - pub fn nftnl_batch_is_supported() -> c_int; - - pub fn nftnl_batch_begin(buf: *mut c_char, seq: u32); - - pub fn nftnl_batch_end(buf: *mut c_char, seq: u32); -} -#[repr(C)] -pub struct nftnl_chain(c_void); - -extern "C" { - pub fn nftnl_chain_alloc() -> *mut nftnl_chain; - - pub fn nftnl_chain_free(arg1: *const nftnl_chain); -} -pub const NFTNL_CHAIN_NAME: nftnl_chain_attr = 0; -pub const NFTNL_CHAIN_FAMILY: nftnl_chain_attr = 1; -pub const NFTNL_CHAIN_TABLE: nftnl_chain_attr = 2; -pub const NFTNL_CHAIN_HOOKNUM: nftnl_chain_attr = 3; -pub const NFTNL_CHAIN_PRIO: nftnl_chain_attr = 4; -pub const NFTNL_CHAIN_POLICY: nftnl_chain_attr = 5; -pub const NFTNL_CHAIN_USE: nftnl_chain_attr = 6; -pub const NFTNL_CHAIN_BYTES: nftnl_chain_attr = 7; -pub const NFTNL_CHAIN_PACKETS: nftnl_chain_attr = 8; -pub const NFTNL_CHAIN_HANDLE: nftnl_chain_attr = 9; -pub const NFTNL_CHAIN_TYPE: nftnl_chain_attr = 10; -pub const NFTNL_CHAIN_DEV: nftnl_chain_attr = 11; -pub const __NFTNL_CHAIN_MAX: nftnl_chain_attr = 12; -pub type nftnl_chain_attr = u32; -extern "C" { - pub fn nftnl_chain_is_set(c: *const nftnl_chain, attr: u16) -> bool; - - pub fn nftnl_chain_unset(c: *mut nftnl_chain, attr: u16); - - pub fn nftnl_chain_set(t: *mut nftnl_chain, attr: u16, data: *const c_void); - - pub fn nftnl_chain_set_data( - t: *mut nftnl_chain, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_chain_set_u8(t: *mut nftnl_chain, attr: u16, data: u8); - - pub fn nftnl_chain_set_u32(t: *mut nftnl_chain, attr: u16, data: u32); - - pub fn nftnl_chain_set_s32(t: *mut nftnl_chain, attr: u16, data: i32); - - pub fn nftnl_chain_set_u64(t: *mut nftnl_chain, attr: u16, data: u64); - - pub fn nftnl_chain_set_str(t: *mut nftnl_chain, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_chain_get(c: *const nftnl_chain, attr: u16) -> *const c_void; - - pub fn nftnl_chain_get_data( - c: *const nftnl_chain, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_chain_get_str(c: *const nftnl_chain, attr: u16) -> *const c_char; - - pub fn nftnl_chain_get_u8(c: *const nftnl_chain, attr: u16) -> u8; - - pub fn nftnl_chain_get_u32(c: *const nftnl_chain, attr: u16) -> u32; - - pub fn nftnl_chain_get_s32(c: *const nftnl_chain, attr: u16) -> i32; - - pub fn nftnl_chain_get_u64(c: *const nftnl_chain, attr: u16) -> u64; - - pub fn nftnl_chain_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_chain); - - pub fn nftnl_chain_parse( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_parse_file( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_fprintf( - fp: *mut FILE, - c: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_chain) -> c_int; -} -#[repr(C)] -pub struct nftnl_chain_list(c_void); - -extern "C" { - pub fn nftnl_chain_list_alloc() -> *mut nftnl_chain_list; - - pub fn nftnl_chain_list_free(list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_is_empty(list: *const nftnl_chain_list) -> c_int; - - pub fn nftnl_chain_list_foreach( - chain_list: *mut nftnl_chain_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_chain, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_chain_list_add(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_add_tail(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_del(c: *mut nftnl_chain); -} -#[repr(C)] -pub struct nftnl_chain_list_iter(c_void); - -extern "C" { - pub fn nftnl_chain_list_iter_create(l: *const nftnl_chain_list) -> *mut nftnl_chain_list_iter; - - pub fn nftnl_chain_list_iter_next(iter: *mut nftnl_chain_list_iter) -> *mut nftnl_chain; - - pub fn nftnl_chain_list_iter_destroy(iter: *mut nftnl_chain_list_iter); -} -#[repr(C)] -pub struct nftnl_expr(c_void); - -pub const NFTNL_EXPR_NAME: u32 = 0; -pub const NFTNL_EXPR_BASE: u32 = 1; - -extern "C" { - pub fn nftnl_expr_alloc(name: *const c_char) -> *mut nftnl_expr; - - pub fn nftnl_expr_free(expr: *const nftnl_expr); - - pub fn nftnl_expr_is_set(expr: *const nftnl_expr, type_: u16) -> bool; - - pub fn nftnl_expr_set( - expr: *mut nftnl_expr, - type_: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_expr_set_u8(expr: *mut nftnl_expr, type_: u16, data: u8); - - pub fn nftnl_expr_set_u16(expr: *mut nftnl_expr, type_: u16, data: u16); - - pub fn nftnl_expr_set_u32(expr: *mut nftnl_expr, type_: u16, data: u32); - - pub fn nftnl_expr_set_u64(expr: *mut nftnl_expr, type_: u16, data: u64); - - pub fn nftnl_expr_set_str(expr: *mut nftnl_expr, type_: u16, str: *const c_char) -> c_int; - - pub fn nftnl_expr_get(expr: *const nftnl_expr, type_: u16, data_len: *mut u32) - -> *const c_void; - - pub fn nftnl_expr_get_u8(expr: *const nftnl_expr, type_: u16) -> u8; - - pub fn nftnl_expr_get_u16(expr: *const nftnl_expr, type_: u16) -> u16; - - pub fn nftnl_expr_get_u32(expr: *const nftnl_expr, type_: u16) -> u32; - - pub fn nftnl_expr_get_u64(expr: *const nftnl_expr, type_: u16) -> u64; - - pub fn nftnl_expr_get_str(expr: *const nftnl_expr, type_: u16) -> *const c_char; - - pub fn nftnl_expr_cmp(e1: *const nftnl_expr, e2: *const nftnl_expr) -> bool; - - pub fn nftnl_expr_snprintf( - buf: *mut c_char, - buflen: usize, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_EXPR_PAYLOAD_DREG: u32 = 1; -pub const NFTNL_EXPR_PAYLOAD_BASE: u32 = 2; -pub const NFTNL_EXPR_PAYLOAD_OFFSET: u32 = 3; -pub const NFTNL_EXPR_PAYLOAD_LEN: u32 = 4; -pub const NFTNL_EXPR_PAYLOAD_SREG: u32 = 5; -pub const NFTNL_EXPR_PAYLOAD_CSUM_TYPE: u32 = 6; -pub const NFTNL_EXPR_PAYLOAD_CSUM_OFFSET: u32 = 7; -pub const NFTNL_EXPR_PAYLOAD_FLAGS: u32 = 8; - -pub const NFTNL_EXPR_NG_DREG: u32 = 1; -pub const NFTNL_EXPR_NG_MODULUS: u32 = 2; -pub const NFTNL_EXPR_NG_TYPE: u32 = 3; -pub const NFTNL_EXPR_NG_OFFSET: u32 = 4; - -pub const NFTNL_EXPR_META_KEY: u32 = 1; -pub const NFTNL_EXPR_META_DREG: u32 = 2; -pub const NFTNL_EXPR_META_SREG: u32 = 3; - -pub const NFTNL_EXPR_RT_KEY: u32 = 1; -pub const NFTNL_EXPR_RT_DREG: u32 = 2; - -pub const NFTNL_EXPR_CMP_SREG: u32 = 1; -pub const NFTNL_EXPR_CMP_OP: u32 = 2; -pub const NFTNL_EXPR_CMP_DATA: u32 = 3; - -pub const NFTNL_EXPR_RANGE_SREG: u32 = 1; -pub const NFTNL_EXPR_RANGE_OP: u32 = 2; -pub const NFTNL_EXPR_RANGE_FROM_DATA: u32 = 3; -pub const NFTNL_EXPR_RANGE_TO_DATA: u32 = 4; - -pub const NFTNL_EXPR_IMM_DREG: u32 = 1; -pub const NFTNL_EXPR_IMM_DATA: u32 = 2; -pub const NFTNL_EXPR_IMM_VERDICT: u32 = 3; -pub const NFTNL_EXPR_IMM_CHAIN: u32 = 4; - -pub const NFTNL_EXPR_CTR_PACKETS: u32 = 1; -pub const NFTNL_EXPR_CTR_BYTES: u32 = 2; - -pub const NFTNL_EXPR_BITWISE_SREG: u32 = 1; -pub const NFTNL_EXPR_BITWISE_DREG: u32 = 2; -pub const NFTNL_EXPR_BITWISE_LEN: u32 = 3; -pub const NFTNL_EXPR_BITWISE_MASK: u32 = 4; -pub const NFTNL_EXPR_BITWISE_XOR: u32 = 5; - -pub const NFTNL_EXPR_TG_NAME: u32 = 1; -pub const NFTNL_EXPR_TG_REV: u32 = 2; -pub const NFTNL_EXPR_TG_INFO: u32 = 3; - -pub const NFTNL_EXPR_MT_NAME: u32 = 1; -pub const NFTNL_EXPR_MT_REV: u32 = 2; -pub const NFTNL_EXPR_MT_INFO: u32 = 3; - -pub const NFTNL_EXPR_NAT_TYPE: u32 = 1; -pub const NFTNL_EXPR_NAT_FAMILY: u32 = 2; -pub const NFTNL_EXPR_NAT_REG_ADDR_MIN: u32 = 3; -pub const NFTNL_EXPR_NAT_REG_ADDR_MAX: u32 = 4; -pub const NFTNL_EXPR_NAT_REG_PROTO_MIN: u32 = 5; -pub const NFTNL_EXPR_NAT_REG_PROTO_MAX: u32 = 6; -pub const NFTNL_EXPR_NAT_FLAGS: u32 = 7; - -pub const NFTNL_EXPR_LOOKUP_SREG: u32 = 1; -pub const NFTNL_EXPR_LOOKUP_DREG: u32 = 2; -pub const NFTNL_EXPR_LOOKUP_SET: u32 = 3; -pub const NFTNL_EXPR_LOOKUP_SET_ID: u32 = 4; -pub const NFTNL_EXPR_LOOKUP_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_DYNSET_SREG_KEY: u32 = 1; -pub const NFTNL_EXPR_DYNSET_SREG_DATA: u32 = 2; -pub const NFTNL_EXPR_DYNSET_OP: u32 = 3; -pub const NFTNL_EXPR_DYNSET_TIMEOUT: u32 = 4; -pub const NFTNL_EXPR_DYNSET_SET_NAME: u32 = 5; -pub const NFTNL_EXPR_DYNSET_SET_ID: u32 = 6; -pub const NFTNL_EXPR_DYNSET_EXPR: u32 = 7; - -pub const NFTNL_EXPR_LOG_PREFIX: u32 = 1; -pub const NFTNL_EXPR_LOG_GROUP: u32 = 2; -pub const NFTNL_EXPR_LOG_SNAPLEN: u32 = 3; -pub const NFTNL_EXPR_LOG_QTHRESHOLD: u32 = 4; -pub const NFTNL_EXPR_LOG_LEVEL: u32 = 5; -pub const NFTNL_EXPR_LOG_FLAGS: u32 = 6; - -pub const NFTNL_EXPR_EXTHDR_DREG: u32 = 1; -pub const NFTNL_EXPR_EXTHDR_TYPE: u32 = 2; -pub const NFTNL_EXPR_EXTHDR_OFFSET: u32 = 3; -pub const NFTNL_EXPR_EXTHDR_LEN: u32 = 4; - -pub const NFTNL_EXPR_CT_DREG: u32 = 1; -pub const NFTNL_EXPR_CT_KEY: u32 = 2; -pub const NFTNL_EXPR_CT_DIR: u32 = 3; -pub const NFTNL_EXPR_CT_SREG: u32 = 4; - -pub const NFTNL_EXPR_BYTEORDER_DREG: u32 = 1; -pub const NFTNL_EXPR_BYTEORDER_SREG: u32 = 2; -pub const NFTNL_EXPR_BYTEORDER_OP: u32 = 3; -pub const NFTNL_EXPR_BYTEORDER_LEN: u32 = 4; -pub const NFTNL_EXPR_BYTEORDER_SIZE: u32 = 5; - -pub const NFTNL_EXPR_LIMIT_RATE: u32 = 1; -pub const NFTNL_EXPR_LIMIT_UNIT: u32 = 2; -pub const NFTNL_EXPR_LIMIT_BURST: u32 = 3; -pub const NFTNL_EXPR_LIMIT_TYPE: u32 = 4; -pub const NFTNL_EXPR_LIMIT_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_REJECT_TYPE: u32 = 1; -pub const NFTNL_EXPR_REJECT_CODE: u32 = 2; - -pub const NFTNL_EXPR_QUEUE_NUM: u32 = 1; -pub const NFTNL_EXPR_QUEUE_TOTAL: u32 = 2; -pub const NFTNL_EXPR_QUEUE_FLAGS: u32 = 3; -pub const NFTNL_EXPR_QUEUE_SREG_QNUM: u32 = 4; - -pub const NFTNL_EXPR_QUOTA_BYTES: u32 = 1; -pub const NFTNL_EXPR_QUOTA_FLAGS: u32 = 2; -pub const NFTNL_EXPR_QUOTA_CONSUMED: u32 = 3; - -pub const NFTNL_EXPR_MASQ_FLAGS: u32 = 1; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MIN: u32 = 2; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MAX: u32 = 3; - -pub const NFTNL_EXPR_REDIR_REG_PROTO_MIN: u32 = 1; -pub const NFTNL_EXPR_REDIR_REG_PROTO_MAX: u32 = 2; -pub const NFTNL_EXPR_REDIR_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_DUP_SREG_ADDR: u32 = 1; -pub const NFTNL_EXPR_DUP_SREG_DEV: u32 = 2; - -pub const NFTNL_EXPR_FWD_SREG_DEV: u32 = 1; - -pub const NFTNL_EXPR_HASH_SREG: u32 = 1; -pub const NFTNL_EXPR_HASH_DREG: u32 = 2; -pub const NFTNL_EXPR_HASH_LEN: u32 = 3; -pub const NFTNL_EXPR_HASH_MODULUS: u32 = 4; -pub const NFTNL_EXPR_HASH_SEED: u32 = 5; -pub const NFTNL_EXPR_HASH_OFFSET: u32 = 6; - -pub const NFTNL_EXPR_FIB_DREG: u32 = 1; -pub const NFTNL_EXPR_FIB_RESULT: u32 = 2; -pub const NFTNL_EXPR_FIB_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_OBJREF_IMM_TYPE: u32 = 1; -pub const NFTNL_EXPR_OBJREF_IMM_NAME: u32 = 2; -pub const NFTNL_EXPR_OBJREF_SET_SREG: u32 = 3; -pub const NFTNL_EXPR_OBJREF_SET_NAME: u32 = 4; -pub const NFTNL_EXPR_OBJREF_SET_ID: u32 = 5; - -#[repr(C)] -pub struct nftnl_gen(c_void); - -extern "C" { - pub fn nftnl_gen_alloc() -> *mut nftnl_gen; - - pub fn nftnl_gen_free(arg1: *const nftnl_gen); -} -pub const NFTNL_GEN_ID: u32 = 0; -pub const __NFTNL_GEN_MAX: u32 = 1; - -extern "C" { - pub fn nftnl_gen_is_set(gen: *const nftnl_gen, attr: u16) -> bool; - - pub fn nftnl_gen_unset(gen: *mut nftnl_gen, attr: u16); - - pub fn nftnl_gen_set(gen: *mut nftnl_gen, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_gen_set_data( - gen: *mut nftnl_gen, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_gen_get(gen: *const nftnl_gen, attr: u16) -> *const c_void; - - pub fn nftnl_gen_get_data( - gen: *const nftnl_gen, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_gen_set_u32(gen: *mut nftnl_gen, attr: u16, data: u32); - - pub fn nftnl_gen_get_u32(gen: *const nftnl_gen, attr: u16) -> u32; - - pub fn nftnl_gen_nlmsg_parse(nlh: *const nlmsghdr, gen: *mut nftnl_gen) -> c_int; - - pub fn nftnl_gen_snprintf( - buf: *mut c_char, - size: usize, - gen: *const nftnl_gen, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_gen_fprintf(fp: *mut FILE, gen: *const nftnl_gen, type_: u32, flags: u32) - -> c_int; -} -pub const NFTNL_OBJ_TABLE: u32 = 0; -pub const NFTNL_OBJ_NAME: u32 = 1; -pub const NFTNL_OBJ_TYPE: u32 = 2; -pub const NFTNL_OBJ_FAMILY: u32 = 3; -pub const NFTNL_OBJ_USE: u32 = 4; -pub const NFTNL_OBJ_BASE: u32 = 16; -pub const __NFTNL_OBJ_MAX: u32 = 17; - -pub const NFTNL_OBJ_CTR_PKTS: u32 = 16; -pub const NFTNL_OBJ_CTR_BYTES: u32 = 17; - -pub const NFTNL_OBJ_QUOTA_BYTES: u32 = 16; -pub const NFTNL_OBJ_QUOTA_CONSUMED: u32 = 17; -pub const NFTNL_OBJ_QUOTA_FLAGS: u32 = 18; - -#[repr(C)] -pub struct nftnl_obj(c_void); - -extern "C" { - pub fn nftnl_obj_alloc() -> *mut nftnl_obj; - - pub fn nftnl_obj_free(ne: *const nftnl_obj); - - pub fn nftnl_obj_is_set(ne: *const nftnl_obj, attr: u16) -> bool; - - pub fn nftnl_obj_unset(ne: *mut nftnl_obj, attr: u16); - - pub fn nftnl_obj_set_data(ne: *mut nftnl_obj, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_obj_set(ne: *mut nftnl_obj, attr: u16, data: *const c_void); - - pub fn nftnl_obj_set_u32(ne: *mut nftnl_obj, attr: u16, val: u32); - - pub fn nftnl_obj_set_u64(obj: *mut nftnl_obj, attr: u16, val: u64); - - pub fn nftnl_obj_set_str(ne: *mut nftnl_obj, attr: u16, str: *const c_char); - - pub fn nftnl_obj_get_data(ne: *mut nftnl_obj, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_obj_get(ne: *mut nftnl_obj, attr: u16) -> *const c_void; - - pub fn nftnl_obj_get_u32(ne: *mut nftnl_obj, attr: u16) -> u32; - - pub fn nftnl_obj_get_u64(obj: *mut nftnl_obj, attr: u16) -> u64; - - pub fn nftnl_obj_get_str(ne: *mut nftnl_obj, attr: u16) -> *const c_char; - - pub fn nftnl_obj_nlmsg_build_payload(nlh: *mut nlmsghdr, ne: *const nftnl_obj); - - pub fn nftnl_obj_nlmsg_parse(nlh: *const nlmsghdr, ne: *mut nftnl_obj) -> c_int; - - pub fn nftnl_obj_parse( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_parse_file( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_snprintf( - buf: *mut c_char, - size: usize, - ne: *const nftnl_obj, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_obj_fprintf(fp: *mut FILE, ne: *const nftnl_obj, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list(c_void); - -extern "C" { - pub fn nftnl_obj_list_alloc() -> *mut nftnl_obj_list; - - pub fn nftnl_obj_list_free(list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_is_empty(list: *mut nftnl_obj_list) -> c_int; - - pub fn nftnl_obj_list_add(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_add_tail(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_del(t: *mut nftnl_obj); - - pub fn nftnl_obj_list_foreach( - table_list: *mut nftnl_obj_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_obj, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list_iter(c_void); - -extern "C" { - pub fn nftnl_obj_list_iter_create(l: *mut nftnl_obj_list) -> *mut nftnl_obj_list_iter; - - pub fn nftnl_obj_list_iter_next(iter: *mut nftnl_obj_list_iter) -> *mut nftnl_obj; - - pub fn nftnl_obj_list_iter_destroy(iter: *mut nftnl_obj_list_iter); -} -#[repr(C)] -pub struct nftnl_rule(c_void); - -extern "C" { - pub fn nftnl_rule_alloc() -> *mut nftnl_rule; - - pub fn nftnl_rule_free(arg1: *const nftnl_rule); -} -pub const NFTNL_RULE_FAMILY: nftnl_rule_attr = 0; -pub const NFTNL_RULE_TABLE: nftnl_rule_attr = 1; -pub const NFTNL_RULE_CHAIN: nftnl_rule_attr = 2; -pub const NFTNL_RULE_HANDLE: nftnl_rule_attr = 3; -pub const NFTNL_RULE_COMPAT_PROTO: nftnl_rule_attr = 4; -pub const NFTNL_RULE_COMPAT_FLAGS: nftnl_rule_attr = 5; -pub const NFTNL_RULE_POSITION: nftnl_rule_attr = 6; -pub const NFTNL_RULE_USERDATA: nftnl_rule_attr = 7; -pub const __NFTNL_RULE_MAX: nftnl_rule_attr = 8; -pub type nftnl_rule_attr = u32; -extern "C" { - pub fn nftnl_rule_unset(r: *mut nftnl_rule, attr: u16); - - pub fn nftnl_rule_is_set(r: *const nftnl_rule, attr: u16) -> bool; - - pub fn nftnl_rule_set(r: *mut nftnl_rule, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_rule_set_data( - r: *mut nftnl_rule, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_rule_set_u32(r: *mut nftnl_rule, attr: u16, val: u32); - - pub fn nftnl_rule_set_u64(r: *mut nftnl_rule, attr: u16, val: u64); - - pub fn nftnl_rule_set_str(r: *mut nftnl_rule, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_rule_get(r: *const nftnl_rule, attr: u16) -> *const c_void; - - pub fn nftnl_rule_get_data( - r: *const nftnl_rule, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_rule_get_str(r: *const nftnl_rule, attr: u16) -> *const c_char; - - pub fn nftnl_rule_get_u8(r: *const nftnl_rule, attr: u16) -> u8; - - pub fn nftnl_rule_get_u32(r: *const nftnl_rule, attr: u16) -> u32; - - pub fn nftnl_rule_get_u64(r: *const nftnl_rule, attr: u16) -> u64; - - pub fn nftnl_rule_add_expr(r: *mut nftnl_rule, expr: *mut nftnl_expr); - - pub fn nftnl_rule_cmp(r1: *const nftnl_rule, r2: *const nftnl_rule) -> bool; - - pub fn nftnl_rule_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *mut nftnl_rule); - - pub fn nftnl_rule_parse( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_parse_file( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_rule, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_rule_fprintf(fp: *mut FILE, r: *const nftnl_rule, type_: u32, flags: u32) - -> c_int; - - pub fn nftnl_rule_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_rule) -> c_int; - - pub fn nftnl_expr_foreach( - r: *mut nftnl_rule, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_expr, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_expr_iter(c_void); - -extern "C" { - pub fn nftnl_expr_iter_create(r: *const nftnl_rule) -> *mut nftnl_expr_iter; - - pub fn nftnl_expr_iter_next(iter: *mut nftnl_expr_iter) -> *mut nftnl_expr; - - pub fn nftnl_expr_iter_destroy(iter: *mut nftnl_expr_iter); -} -#[repr(C)] -pub struct nftnl_rule_list(c_void); - -extern "C" { - pub fn nftnl_rule_list_alloc() -> *mut nftnl_rule_list; - - pub fn nftnl_rule_list_free(list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_is_empty(list: *const nftnl_rule_list) -> c_int; - - pub fn nftnl_rule_list_add(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_add_tail(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_del(r: *mut nftnl_rule); - - pub fn nftnl_rule_list_foreach( - rule_list: *mut nftnl_rule_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_rule, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_rule_list_iter(c_void); - -extern "C" { - pub fn nftnl_rule_list_iter_create(l: *const nftnl_rule_list) -> *mut nftnl_rule_list_iter; - - pub fn nftnl_rule_list_iter_cur(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_next(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_destroy(iter: *const nftnl_rule_list_iter); -} -#[repr(C)] -pub struct nftnl_ruleset(c_void); - -extern "C" { - pub fn nftnl_ruleset_alloc() -> *mut nftnl_ruleset; - - pub fn nftnl_ruleset_free(r: *const nftnl_ruleset); -} -pub const NFTNL_RULESET_TABLELIST: u32 = 0; -pub const NFTNL_RULESET_CHAINLIST: u32 = 1; -pub const NFTNL_RULESET_SETLIST: u32 = 2; -pub const NFTNL_RULESET_RULELIST: u32 = 3; - -pub const NFTNL_RULESET_UNSPEC: nftnl_ruleset_type = 0; -pub const NFTNL_RULESET_RULESET: nftnl_ruleset_type = 1; -pub const NFTNL_RULESET_TABLE: nftnl_ruleset_type = 2; -pub const NFTNL_RULESET_CHAIN: nftnl_ruleset_type = 3; -pub const NFTNL_RULESET_RULE: nftnl_ruleset_type = 4; -pub const NFTNL_RULESET_SET: nftnl_ruleset_type = 5; -pub const NFTNL_RULESET_SET_ELEMS: nftnl_ruleset_type = 6; -pub type nftnl_ruleset_type = u32; -extern "C" { - pub fn nftnl_ruleset_is_set(r: *const nftnl_ruleset, attr: u16) -> bool; - - pub fn nftnl_ruleset_unset(r: *mut nftnl_ruleset, attr: u16); - - pub fn nftnl_ruleset_set(r: *mut nftnl_ruleset, attr: u16, data: *mut c_void); - - pub fn nftnl_ruleset_get(r: *const nftnl_ruleset, attr: u16) -> *mut c_void; -} -pub const NFTNL_RULESET_CTX_CMD: u32 = 0; -pub const NFTNL_RULESET_CTX_TYPE: u32 = 1; -pub const NFTNL_RULESET_CTX_TABLE: u32 = 2; -pub const NFTNL_RULESET_CTX_CHAIN: u32 = 3; -pub const NFTNL_RULESET_CTX_RULE: u32 = 4; -pub const NFTNL_RULESET_CTX_SET: u32 = 5; -pub const NFTNL_RULESET_CTX_DATA: u32 = 6; - -#[repr(C)] -pub struct nftnl_parse_ctx(c_void); - -extern "C" { - pub fn nftnl_ruleset_ctx_free(ctx: *const nftnl_parse_ctx); - - pub fn nftnl_ruleset_ctx_is_set(ctx: *const nftnl_parse_ctx, attr: u16) -> bool; - - pub fn nftnl_ruleset_ctx_get(ctx: *const nftnl_parse_ctx, attr: u16) -> *mut c_void; - - pub fn nftnl_ruleset_ctx_get_u32(ctx: *const nftnl_parse_ctx, attr: u16) -> u32; - - pub fn nftnl_ruleset_parse_file_cb( - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse_buffer_cb( - type_: nftnl_parse_type, - buffer: *const c_char, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_parse_file( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_snprintf( - buf: *mut c_char, - size: usize, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_ruleset_fprintf( - fp: *mut FILE, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_SET_TABLE: nftnl_set_attr = 0; -pub const NFTNL_SET_NAME: nftnl_set_attr = 1; -pub const NFTNL_SET_FLAGS: nftnl_set_attr = 2; -pub const NFTNL_SET_KEY_TYPE: nftnl_set_attr = 3; -pub const NFTNL_SET_KEY_LEN: nftnl_set_attr = 4; -pub const NFTNL_SET_DATA_TYPE: nftnl_set_attr = 5; -pub const NFTNL_SET_DATA_LEN: nftnl_set_attr = 6; -pub const NFTNL_SET_FAMILY: nftnl_set_attr = 7; -pub const NFTNL_SET_ID: nftnl_set_attr = 8; -pub const NFTNL_SET_POLICY: nftnl_set_attr = 9; -pub const NFTNL_SET_DESC_SIZE: nftnl_set_attr = 10; -pub const NFTNL_SET_TIMEOUT: nftnl_set_attr = 11; -pub const NFTNL_SET_GC_INTERVAL: nftnl_set_attr = 12; -pub const NFTNL_SET_USERDATA: nftnl_set_attr = 13; -pub const NFTNL_SET_OBJ_TYPE: nftnl_set_attr = 14; -pub const __NFTNL_SET_MAX: nftnl_set_attr = 15; -pub type nftnl_set_attr = u32; -#[repr(C)] -pub struct nftnl_set(c_void); - -extern "C" { - pub fn nftnl_set_alloc() -> *mut nftnl_set; - - pub fn nftnl_set_free(s: *const nftnl_set); - - pub fn nftnl_set_clone(set: *const nftnl_set) -> *mut nftnl_set; - - pub fn nftnl_set_is_set(s: *const nftnl_set, attr: u16) -> bool; - - pub fn nftnl_set_unset(s: *mut nftnl_set, attr: u16); - - pub fn nftnl_set_set(s: *mut nftnl_set, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_set_set_data( - s: *mut nftnl_set, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_set_u32(s: *mut nftnl_set, attr: u16, val: u32); - - pub fn nftnl_set_set_u64(s: *mut nftnl_set, attr: u16, val: u64); - - pub fn nftnl_set_set_str(s: *mut nftnl_set, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_get(s: *const nftnl_set, attr: u16) -> *const c_void; - - pub fn nftnl_set_get_data(s: *const nftnl_set, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_set_get_str(s: *const nftnl_set, attr: u16) -> *const c_char; - - pub fn nftnl_set_get_u32(s: *const nftnl_set, attr: u16) -> u32; - - pub fn nftnl_set_get_u64(s: *const nftnl_set, attr: u16) -> u64; - - pub fn nftnl_set_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_elems_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_fprintf(fp: *mut FILE, s: *const nftnl_set, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list(c_void); - -extern "C" { - pub fn nftnl_set_list_alloc() -> *mut nftnl_set_list; - - pub fn nftnl_set_list_free(list: *mut nftnl_set_list); - - pub fn nftnl_set_list_is_empty(list: *const nftnl_set_list) -> c_int; - - pub fn nftnl_set_list_add(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_add_tail(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_del(s: *mut nftnl_set); - - pub fn nftnl_set_list_foreach( - set_list: *mut nftnl_set_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_set, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list_iter(c_void); - -extern "C" { - pub fn nftnl_set_list_iter_create(l: *const nftnl_set_list) -> *mut nftnl_set_list_iter; - - pub fn nftnl_set_list_iter_cur(iter: *const nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_next(iter: *mut nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_destroy(iter: *const nftnl_set_list_iter); - - pub fn nftnl_set_parse( - s: *mut nftnl_set, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_parse_file( - s: *mut nftnl_set, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; -} -pub const NFTNL_SET_ELEM_FLAGS: u32 = 0; -pub const NFTNL_SET_ELEM_KEY: u32 = 1; -pub const NFTNL_SET_ELEM_VERDICT: u32 = 2; -pub const NFTNL_SET_ELEM_CHAIN: u32 = 3; -pub const NFTNL_SET_ELEM_DATA: u32 = 4; -pub const NFTNL_SET_ELEM_TIMEOUT: u32 = 5; -pub const NFTNL_SET_ELEM_EXPIRATION: u32 = 6; -pub const NFTNL_SET_ELEM_USERDATA: u32 = 7; -pub const NFTNL_SET_ELEM_EXPR: u32 = 8; -pub const NFTNL_SET_ELEM_OBJREF: u32 = 9; - -#[repr(C)] -pub struct nftnl_set_elem(c_void); - -extern "C" { - pub fn nftnl_set_elem_alloc() -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_free(s: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_clone(elem: *mut nftnl_set_elem) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_add(s: *mut nftnl_set, elem: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_unset(s: *mut nftnl_set_elem, attr: u16); - - pub fn nftnl_set_elem_set( - s: *mut nftnl_set_elem, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_elem_set_u32(s: *mut nftnl_set_elem, attr: u16, val: u32); - - pub fn nftnl_set_elem_set_u64(s: *mut nftnl_set_elem, attr: u16, val: u64); - - pub fn nftnl_set_elem_set_str(s: *mut nftnl_set_elem, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_elem_get( - s: *mut nftnl_set_elem, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_set_elem_get_str(s: *mut nftnl_set_elem, attr: u16) -> *const c_char; - - pub fn nftnl_set_elem_get_u32(s: *mut nftnl_set_elem, attr: u16) -> u32; - - pub fn nftnl_set_elem_get_u64(s: *mut nftnl_set_elem, attr: u16) -> u64; - - pub fn nftnl_set_elem_is_set(s: *const nftnl_set_elem, attr: u16) -> bool; - - pub fn nftnl_set_elems_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_elem_nlmsg_build_payload(nlh: *mut nlmsghdr, e: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_parse( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_parse_file( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_fprintf( - fp: *mut FILE, - se: *mut nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_foreach( - s: *mut nftnl_set, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_set_elem, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_elems_iter(c_void); - -extern "C" { - pub fn nftnl_set_elems_iter_create(s: *const nftnl_set) -> *mut nftnl_set_elems_iter; - - pub fn nftnl_set_elems_iter_cur(iter: *const nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_next(iter: *mut nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_destroy(iter: *mut nftnl_set_elems_iter); - - pub fn nftnl_set_elems_nlmsg_build_payload_iter( - nlh: *mut nlmsghdr, - iter: *mut nftnl_set_elems_iter, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_table(c_void); - -extern "C" { - pub fn nftnl_table_alloc() -> *mut nftnl_table; - - pub fn nftnl_table_free(arg1: *const nftnl_table); -} -pub const NFTNL_TABLE_NAME: nftnl_table_attr = 0; -pub const NFTNL_TABLE_FAMILY: nftnl_table_attr = 1; -pub const NFTNL_TABLE_FLAGS: nftnl_table_attr = 2; -pub const NFTNL_TABLE_USE: nftnl_table_attr = 3; -pub const __NFTNL_TABLE_MAX: nftnl_table_attr = 4; -pub type nftnl_table_attr = u32; -extern "C" { - pub fn nftnl_table_is_set(t: *const nftnl_table, attr: u16) -> bool; - - pub fn nftnl_table_unset(t: *mut nftnl_table, attr: u16); - - pub fn nftnl_table_set(t: *mut nftnl_table, attr: u16, data: *const c_void); - - pub fn nftnl_table_set_data( - t: *mut nftnl_table, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_table_get(t: *const nftnl_table, attr: u16) -> *const c_void; - - pub fn nftnl_table_get_data( - t: *const nftnl_table, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_table_set_u8(t: *mut nftnl_table, attr: u16, data: u8); - - pub fn nftnl_table_set_u32(t: *mut nftnl_table, attr: u16, data: u32); - - pub fn nftnl_table_set_str(t: *mut nftnl_table, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_table_get_u8(t: *const nftnl_table, attr: u16) -> u8; - - pub fn nftnl_table_get_u32(t: *const nftnl_table, attr: u16) -> u32; - - pub fn nftnl_table_get_str(t: *const nftnl_table, attr: u16) -> *const c_char; - - pub fn nftnl_table_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_table); - - pub fn nftnl_table_parse( - t: *mut nftnl_table, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_parse_file( - t: *mut nftnl_table, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_fprintf( - fp: *mut FILE, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_table) -> c_int; -} -#[repr(C)] -pub struct nftnl_table_list(c_void); - -extern "C" { - pub fn nftnl_table_list_alloc() -> *mut nftnl_table_list; - - pub fn nftnl_table_list_free(list: *mut nftnl_table_list); - - pub fn nftnl_table_list_is_empty(list: *const nftnl_table_list) -> c_int; - - pub fn nftnl_table_list_foreach( - table_list: *mut nftnl_table_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_table, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_table_list_add(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_add_tail(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_del(r: *mut nftnl_table); -} -#[repr(C)] -pub struct nftnl_table_list_iter(c_void); - -extern "C" { - pub fn nftnl_table_list_iter_create(l: *const nftnl_table_list) -> *mut nftnl_table_list_iter; - - pub fn nftnl_table_list_iter_next(iter: *mut nftnl_table_list_iter) -> *mut nftnl_table; - - pub fn nftnl_table_list_iter_destroy(iter: *const nftnl_table_list_iter); -} -pub const NFTNL_TRACE_CHAIN: nftnl_trace_attr = 0; -pub const NFTNL_TRACE_FAMILY: nftnl_trace_attr = 1; -pub const NFTNL_TRACE_ID: nftnl_trace_attr = 2; -pub const NFTNL_TRACE_IIF: nftnl_trace_attr = 3; -pub const NFTNL_TRACE_IIFTYPE: nftnl_trace_attr = 4; -pub const NFTNL_TRACE_JUMP_TARGET: nftnl_trace_attr = 5; -pub const NFTNL_TRACE_OIF: nftnl_trace_attr = 6; -pub const NFTNL_TRACE_OIFTYPE: nftnl_trace_attr = 7; -pub const NFTNL_TRACE_MARK: nftnl_trace_attr = 8; -pub const NFTNL_TRACE_LL_HEADER: nftnl_trace_attr = 9; -pub const NFTNL_TRACE_NETWORK_HEADER: nftnl_trace_attr = 10; -pub const NFTNL_TRACE_TRANSPORT_HEADER: nftnl_trace_attr = 11; -pub const NFTNL_TRACE_TABLE: nftnl_trace_attr = 12; -pub const NFTNL_TRACE_TYPE: nftnl_trace_attr = 13; -pub const NFTNL_TRACE_RULE_HANDLE: nftnl_trace_attr = 14; -pub const NFTNL_TRACE_VERDICT: nftnl_trace_attr = 15; -pub const NFTNL_TRACE_NFPROTO: nftnl_trace_attr = 16; -pub const NFTNL_TRACE_POLICY: nftnl_trace_attr = 17; -pub const __NFTNL_TRACE_MAX: nftnl_trace_attr = 18; -pub type nftnl_trace_attr = u32; -#[repr(C)] -pub struct nftnl_trace(c_void); - -extern "C" { - pub fn nftnl_trace_alloc() -> *mut nftnl_trace; - - pub fn nftnl_trace_free(trace: *const nftnl_trace); - - pub fn nftnl_trace_is_set(trace: *const nftnl_trace, type_: u16) -> bool; - - pub fn nftnl_trace_get_data( - trace: *const nftnl_trace, - type_: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_trace_get_u16(trace: *const nftnl_trace, type_: u16) -> u16; - - pub fn nftnl_trace_get_u32(trace: *const nftnl_trace, type_: u16) -> u32; - - pub fn nftnl_trace_get_u64(trace: *const nftnl_trace, type_: u16) -> u64; - - pub fn nftnl_trace_get_str(trace: *const nftnl_trace, type_: u16) -> *const c_char; - - pub fn nftnl_trace_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_trace) -> c_int; -} -#[repr(C)] -pub struct nftnl_udata(c_void); - -#[repr(C)] -pub struct nftnl_udata_buf(c_void); - -extern "C" { - pub fn nftnl_udata_buf_alloc(data_size: u32) -> *mut nftnl_udata_buf; - - pub fn nftnl_udata_buf_free(buf: *const nftnl_udata_buf); - - pub fn nftnl_udata_buf_len(buf: *const nftnl_udata_buf) -> u32; - - pub fn nftnl_udata_buf_data(buf: *const nftnl_udata_buf) -> *mut c_void; - - pub fn nftnl_udata_buf_put(buf: *mut nftnl_udata_buf, data: *const c_void, len: u32); - - pub fn nftnl_udata_start(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_end(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_put( - buf: *mut nftnl_udata_buf, - type_: u8, - len: u32, - value: *const c_void, - ) -> bool; - - pub fn nftnl_udata_put_strz(buf: *mut nftnl_udata_buf, type_: u8, strz: *const c_char) -> bool; - - pub fn nftnl_udata_type(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_len(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_get(attr: *const nftnl_udata) -> *mut c_void; - - pub fn nftnl_udata_next(attr: *const nftnl_udata) -> *mut nftnl_udata; -} -pub type nftnl_udata_cb_t = - Option<unsafe extern "C" fn(attr: *const nftnl_udata, data: *mut c_void) -> c_int>; -extern "C" { - pub fn nftnl_udata_parse( - data: *const c_void, - data_len: u32, - cb: nftnl_udata_cb_t, - cb_data: *mut c_void, - ) -> c_int; -} diff --git a/rustables-sys/src/nftnl_1_0_8.rs b/rustables-sys/src/nftnl_1_0_8.rs deleted file mode 100644 index 29bce5f..0000000 --- a/rustables-sys/src/nftnl_1_0_8.rs +++ /dev/null @@ -1,1251 +0,0 @@ -// automatically generated by rust-bindgen 0.39.0 - -use core::option::Option; -use libc::{c_char, c_int, c_void, iovec, nlmsghdr, FILE}; - -#[repr(C)] -pub struct nftnl_batch(c_void); - -extern "C" { - pub fn nftnl_batch_alloc(pg_size: u32, pg_overrun_size: u32) -> *mut nftnl_batch; - - pub fn nftnl_batch_update(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_free(batch: *mut nftnl_batch); - - pub fn nftnl_batch_buffer(batch: *mut nftnl_batch) -> *mut c_void; - - pub fn nftnl_batch_buffer_len(batch: *mut nftnl_batch) -> u32; - - pub fn nftnl_batch_iovec_len(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_iovec(batch: *mut nftnl_batch, iov: *mut iovec, iovlen: u32); -} -pub const NFTNL_PARSE_EBADINPUT: u32 = 0; -pub const NFTNL_PARSE_EMISSINGNODE: u32 = 1; -pub const NFTNL_PARSE_EBADTYPE: u32 = 2; -pub const NFTNL_PARSE_EOPNOTSUPP: u32 = 3; - -pub const NFTNL_OUTPUT_DEFAULT: nftnl_output_type = 0; -pub const NFTNL_OUTPUT_XML: nftnl_output_type = 1; -pub const NFTNL_OUTPUT_JSON: nftnl_output_type = 2; -pub type nftnl_output_type = u32; -pub const NFTNL_OF_EVENT_NEW: nftnl_output_flags = 1; -pub const NFTNL_OF_EVENT_DEL: nftnl_output_flags = 2; -pub const NFTNL_OF_EVENT_ANY: nftnl_output_flags = 3; -pub type nftnl_output_flags = u32; -pub const NFTNL_CMD_UNSPEC: nftnl_cmd_type = 0; -pub const NFTNL_CMD_ADD: nftnl_cmd_type = 1; -pub const NFTNL_CMD_INSERT: nftnl_cmd_type = 2; -pub const NFTNL_CMD_DELETE: nftnl_cmd_type = 3; -pub const NFTNL_CMD_REPLACE: nftnl_cmd_type = 4; -pub const NFTNL_CMD_FLUSH: nftnl_cmd_type = 5; -pub const NFTNL_CMD_MAX: nftnl_cmd_type = 6; -pub type nftnl_cmd_type = u32; -pub const NFTNL_PARSE_NONE: nftnl_parse_type = 0; -pub const NFTNL_PARSE_XML: nftnl_parse_type = 1; -pub const NFTNL_PARSE_JSON: nftnl_parse_type = 2; -pub const NFTNL_PARSE_MAX: nftnl_parse_type = 3; -pub type nftnl_parse_type = u32; -#[repr(C)] -pub struct nftnl_parse_err(c_void); - -extern "C" { - pub fn nftnl_nlmsg_build_hdr( - buf: *mut c_char, - type_: u16, - family: u16, - flags: u16, - seq: u32, - ) -> *mut nlmsghdr; - - pub fn nftnl_parse_err_alloc() -> *mut nftnl_parse_err; - - pub fn nftnl_parse_err_free(arg1: *mut nftnl_parse_err); - - pub fn nftnl_parse_perror(str: *const c_char, err: *mut nftnl_parse_err) -> c_int; - - pub fn nftnl_batch_is_supported() -> c_int; - - pub fn nftnl_batch_begin(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; - - pub fn nftnl_batch_end(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; -} -#[repr(C)] -pub struct nftnl_chain(c_void); - -extern "C" { - pub fn nftnl_chain_alloc() -> *mut nftnl_chain; - - pub fn nftnl_chain_free(arg1: *const nftnl_chain); -} -pub const NFTNL_CHAIN_NAME: nftnl_chain_attr = 0; -pub const NFTNL_CHAIN_FAMILY: nftnl_chain_attr = 1; -pub const NFTNL_CHAIN_TABLE: nftnl_chain_attr = 2; -pub const NFTNL_CHAIN_HOOKNUM: nftnl_chain_attr = 3; -pub const NFTNL_CHAIN_PRIO: nftnl_chain_attr = 4; -pub const NFTNL_CHAIN_POLICY: nftnl_chain_attr = 5; -pub const NFTNL_CHAIN_USE: nftnl_chain_attr = 6; -pub const NFTNL_CHAIN_BYTES: nftnl_chain_attr = 7; -pub const NFTNL_CHAIN_PACKETS: nftnl_chain_attr = 8; -pub const NFTNL_CHAIN_HANDLE: nftnl_chain_attr = 9; -pub const NFTNL_CHAIN_TYPE: nftnl_chain_attr = 10; -pub const NFTNL_CHAIN_DEV: nftnl_chain_attr = 11; -pub const __NFTNL_CHAIN_MAX: nftnl_chain_attr = 12; -pub type nftnl_chain_attr = u32; -extern "C" { - pub fn nftnl_chain_is_set(c: *const nftnl_chain, attr: u16) -> bool; - - pub fn nftnl_chain_unset(c: *mut nftnl_chain, attr: u16); - - pub fn nftnl_chain_set(t: *mut nftnl_chain, attr: u16, data: *const c_void); - - pub fn nftnl_chain_set_data( - t: *mut nftnl_chain, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_chain_set_u8(t: *mut nftnl_chain, attr: u16, data: u8); - - pub fn nftnl_chain_set_u32(t: *mut nftnl_chain, attr: u16, data: u32); - - pub fn nftnl_chain_set_s32(t: *mut nftnl_chain, attr: u16, data: i32); - - pub fn nftnl_chain_set_u64(t: *mut nftnl_chain, attr: u16, data: u64); - - pub fn nftnl_chain_set_str(t: *mut nftnl_chain, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_chain_get(c: *const nftnl_chain, attr: u16) -> *const c_void; - - pub fn nftnl_chain_get_data( - c: *const nftnl_chain, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_chain_get_str(c: *const nftnl_chain, attr: u16) -> *const c_char; - - pub fn nftnl_chain_get_u8(c: *const nftnl_chain, attr: u16) -> u8; - - pub fn nftnl_chain_get_u32(c: *const nftnl_chain, attr: u16) -> u32; - - pub fn nftnl_chain_get_s32(c: *const nftnl_chain, attr: u16) -> i32; - - pub fn nftnl_chain_get_u64(c: *const nftnl_chain, attr: u16) -> u64; - - pub fn nftnl_chain_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_chain); - - pub fn nftnl_chain_parse( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_parse_file( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_fprintf( - fp: *mut FILE, - c: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_chain) -> c_int; -} -#[repr(C)] -pub struct nftnl_chain_list(c_void); - -extern "C" { - pub fn nftnl_chain_list_alloc() -> *mut nftnl_chain_list; - - pub fn nftnl_chain_list_free(list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_is_empty(list: *const nftnl_chain_list) -> c_int; - - pub fn nftnl_chain_list_foreach( - chain_list: *mut nftnl_chain_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_chain, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_chain_list_add(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_add_tail(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_del(c: *mut nftnl_chain); -} -#[repr(C)] -pub struct nftnl_chain_list_iter(c_void); - -extern "C" { - pub fn nftnl_chain_list_iter_create(l: *const nftnl_chain_list) -> *mut nftnl_chain_list_iter; - - pub fn nftnl_chain_list_iter_next(iter: *mut nftnl_chain_list_iter) -> *mut nftnl_chain; - - pub fn nftnl_chain_list_iter_destroy(iter: *mut nftnl_chain_list_iter); -} -#[repr(C)] -pub struct nftnl_expr(c_void); - -pub const NFTNL_EXPR_NAME: u32 = 0; -pub const NFTNL_EXPR_BASE: u32 = 1; - -extern "C" { - pub fn nftnl_expr_alloc(name: *const c_char) -> *mut nftnl_expr; - - pub fn nftnl_expr_free(expr: *const nftnl_expr); - - pub fn nftnl_expr_is_set(expr: *const nftnl_expr, type_: u16) -> bool; - - pub fn nftnl_expr_set( - expr: *mut nftnl_expr, - type_: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_expr_set_u8(expr: *mut nftnl_expr, type_: u16, data: u8); - - pub fn nftnl_expr_set_u16(expr: *mut nftnl_expr, type_: u16, data: u16); - - pub fn nftnl_expr_set_u32(expr: *mut nftnl_expr, type_: u16, data: u32); - - pub fn nftnl_expr_set_u64(expr: *mut nftnl_expr, type_: u16, data: u64); - - pub fn nftnl_expr_set_str(expr: *mut nftnl_expr, type_: u16, str: *const c_char) -> c_int; - - pub fn nftnl_expr_get(expr: *const nftnl_expr, type_: u16, data_len: *mut u32) - -> *const c_void; - - pub fn nftnl_expr_get_u8(expr: *const nftnl_expr, type_: u16) -> u8; - - pub fn nftnl_expr_get_u16(expr: *const nftnl_expr, type_: u16) -> u16; - - pub fn nftnl_expr_get_u32(expr: *const nftnl_expr, type_: u16) -> u32; - - pub fn nftnl_expr_get_u64(expr: *const nftnl_expr, type_: u16) -> u64; - - pub fn nftnl_expr_get_str(expr: *const nftnl_expr, type_: u16) -> *const c_char; - - pub fn nftnl_expr_cmp(e1: *const nftnl_expr, e2: *const nftnl_expr) -> bool; - - pub fn nftnl_expr_snprintf( - buf: *mut c_char, - buflen: usize, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_EXPR_PAYLOAD_DREG: u32 = 1; -pub const NFTNL_EXPR_PAYLOAD_BASE: u32 = 2; -pub const NFTNL_EXPR_PAYLOAD_OFFSET: u32 = 3; -pub const NFTNL_EXPR_PAYLOAD_LEN: u32 = 4; -pub const NFTNL_EXPR_PAYLOAD_SREG: u32 = 5; -pub const NFTNL_EXPR_PAYLOAD_CSUM_TYPE: u32 = 6; -pub const NFTNL_EXPR_PAYLOAD_CSUM_OFFSET: u32 = 7; -pub const NFTNL_EXPR_PAYLOAD_FLAGS: u32 = 8; - -pub const NFTNL_EXPR_NG_DREG: u32 = 1; -pub const NFTNL_EXPR_NG_MODULUS: u32 = 2; -pub const NFTNL_EXPR_NG_TYPE: u32 = 3; -pub const NFTNL_EXPR_NG_OFFSET: u32 = 4; - -pub const NFTNL_EXPR_META_KEY: u32 = 1; -pub const NFTNL_EXPR_META_DREG: u32 = 2; -pub const NFTNL_EXPR_META_SREG: u32 = 3; - -pub const NFTNL_EXPR_RT_KEY: u32 = 1; -pub const NFTNL_EXPR_RT_DREG: u32 = 2; - -pub const NFTNL_EXPR_CMP_SREG: u32 = 1; -pub const NFTNL_EXPR_CMP_OP: u32 = 2; -pub const NFTNL_EXPR_CMP_DATA: u32 = 3; - -pub const NFTNL_EXPR_RANGE_SREG: u32 = 1; -pub const NFTNL_EXPR_RANGE_OP: u32 = 2; -pub const NFTNL_EXPR_RANGE_FROM_DATA: u32 = 3; -pub const NFTNL_EXPR_RANGE_TO_DATA: u32 = 4; - -pub const NFTNL_EXPR_IMM_DREG: u32 = 1; -pub const NFTNL_EXPR_IMM_DATA: u32 = 2; -pub const NFTNL_EXPR_IMM_VERDICT: u32 = 3; -pub const NFTNL_EXPR_IMM_CHAIN: u32 = 4; - -pub const NFTNL_EXPR_CTR_PACKETS: u32 = 1; -pub const NFTNL_EXPR_CTR_BYTES: u32 = 2; - -pub const NFTNL_EXPR_BITWISE_SREG: u32 = 1; -pub const NFTNL_EXPR_BITWISE_DREG: u32 = 2; -pub const NFTNL_EXPR_BITWISE_LEN: u32 = 3; -pub const NFTNL_EXPR_BITWISE_MASK: u32 = 4; -pub const NFTNL_EXPR_BITWISE_XOR: u32 = 5; - -pub const NFTNL_EXPR_TG_NAME: u32 = 1; -pub const NFTNL_EXPR_TG_REV: u32 = 2; -pub const NFTNL_EXPR_TG_INFO: u32 = 3; - -pub const NFTNL_EXPR_MT_NAME: u32 = 1; -pub const NFTNL_EXPR_MT_REV: u32 = 2; -pub const NFTNL_EXPR_MT_INFO: u32 = 3; - -pub const NFTNL_EXPR_NAT_TYPE: u32 = 1; -pub const NFTNL_EXPR_NAT_FAMILY: u32 = 2; -pub const NFTNL_EXPR_NAT_REG_ADDR_MIN: u32 = 3; -pub const NFTNL_EXPR_NAT_REG_ADDR_MAX: u32 = 4; -pub const NFTNL_EXPR_NAT_REG_PROTO_MIN: u32 = 5; -pub const NFTNL_EXPR_NAT_REG_PROTO_MAX: u32 = 6; -pub const NFTNL_EXPR_NAT_FLAGS: u32 = 7; - -pub const NFTNL_EXPR_LOOKUP_SREG: u32 = 1; -pub const NFTNL_EXPR_LOOKUP_DREG: u32 = 2; -pub const NFTNL_EXPR_LOOKUP_SET: u32 = 3; -pub const NFTNL_EXPR_LOOKUP_SET_ID: u32 = 4; -pub const NFTNL_EXPR_LOOKUP_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_DYNSET_SREG_KEY: u32 = 1; -pub const NFTNL_EXPR_DYNSET_SREG_DATA: u32 = 2; -pub const NFTNL_EXPR_DYNSET_OP: u32 = 3; -pub const NFTNL_EXPR_DYNSET_TIMEOUT: u32 = 4; -pub const NFTNL_EXPR_DYNSET_SET_NAME: u32 = 5; -pub const NFTNL_EXPR_DYNSET_SET_ID: u32 = 6; -pub const NFTNL_EXPR_DYNSET_EXPR: u32 = 7; - -pub const NFTNL_EXPR_LOG_PREFIX: u32 = 1; -pub const NFTNL_EXPR_LOG_GROUP: u32 = 2; -pub const NFTNL_EXPR_LOG_SNAPLEN: u32 = 3; -pub const NFTNL_EXPR_LOG_QTHRESHOLD: u32 = 4; -pub const NFTNL_EXPR_LOG_LEVEL: u32 = 5; -pub const NFTNL_EXPR_LOG_FLAGS: u32 = 6; - -pub const NFTNL_EXPR_EXTHDR_DREG: u32 = 1; -pub const NFTNL_EXPR_EXTHDR_TYPE: u32 = 2; -pub const NFTNL_EXPR_EXTHDR_OFFSET: u32 = 3; -pub const NFTNL_EXPR_EXTHDR_LEN: u32 = 4; -pub const NFTNL_EXPR_EXTHDR_FLAGS: u32 = 5; -pub const NFTNL_EXPR_EXTHDR_OP: u32 = 6; -pub const NFTNL_EXPR_EXTHDR_SREG: u32 = 7; - -pub const NFTNL_EXPR_CT_DREG: u32 = 1; -pub const NFTNL_EXPR_CT_KEY: u32 = 2; -pub const NFTNL_EXPR_CT_DIR: u32 = 3; -pub const NFTNL_EXPR_CT_SREG: u32 = 4; - -pub const NFTNL_EXPR_BYTEORDER_DREG: u32 = 1; -pub const NFTNL_EXPR_BYTEORDER_SREG: u32 = 2; -pub const NFTNL_EXPR_BYTEORDER_OP: u32 = 3; -pub const NFTNL_EXPR_BYTEORDER_LEN: u32 = 4; -pub const NFTNL_EXPR_BYTEORDER_SIZE: u32 = 5; - -pub const NFTNL_EXPR_LIMIT_RATE: u32 = 1; -pub const NFTNL_EXPR_LIMIT_UNIT: u32 = 2; -pub const NFTNL_EXPR_LIMIT_BURST: u32 = 3; -pub const NFTNL_EXPR_LIMIT_TYPE: u32 = 4; -pub const NFTNL_EXPR_LIMIT_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_REJECT_TYPE: u32 = 1; -pub const NFTNL_EXPR_REJECT_CODE: u32 = 2; - -pub const NFTNL_EXPR_QUEUE_NUM: u32 = 1; -pub const NFTNL_EXPR_QUEUE_TOTAL: u32 = 2; -pub const NFTNL_EXPR_QUEUE_FLAGS: u32 = 3; -pub const NFTNL_EXPR_QUEUE_SREG_QNUM: u32 = 4; - -pub const NFTNL_EXPR_QUOTA_BYTES: u32 = 1; -pub const NFTNL_EXPR_QUOTA_FLAGS: u32 = 2; -pub const NFTNL_EXPR_QUOTA_CONSUMED: u32 = 3; - -pub const NFTNL_EXPR_MASQ_FLAGS: u32 = 1; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MIN: u32 = 2; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MAX: u32 = 3; - -pub const NFTNL_EXPR_REDIR_REG_PROTO_MIN: u32 = 1; -pub const NFTNL_EXPR_REDIR_REG_PROTO_MAX: u32 = 2; -pub const NFTNL_EXPR_REDIR_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_DUP_SREG_ADDR: u32 = 1; -pub const NFTNL_EXPR_DUP_SREG_DEV: u32 = 2; - -pub const NFTNL_EXPR_FWD_SREG_DEV: u32 = 1; - -pub const NFTNL_EXPR_HASH_SREG: u32 = 1; -pub const NFTNL_EXPR_HASH_DREG: u32 = 2; -pub const NFTNL_EXPR_HASH_LEN: u32 = 3; -pub const NFTNL_EXPR_HASH_MODULUS: u32 = 4; -pub const NFTNL_EXPR_HASH_SEED: u32 = 5; -pub const NFTNL_EXPR_HASH_OFFSET: u32 = 6; -pub const NFTNL_EXPR_HASH_TYPE: u32 = 7; - -pub const NFTNL_EXPR_FIB_DREG: u32 = 1; -pub const NFTNL_EXPR_FIB_RESULT: u32 = 2; -pub const NFTNL_EXPR_FIB_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_OBJREF_IMM_TYPE: u32 = 1; -pub const NFTNL_EXPR_OBJREF_IMM_NAME: u32 = 2; -pub const NFTNL_EXPR_OBJREF_SET_SREG: u32 = 3; -pub const NFTNL_EXPR_OBJREF_SET_NAME: u32 = 4; -pub const NFTNL_EXPR_OBJREF_SET_ID: u32 = 5; - -#[repr(C)] -pub struct nftnl_gen(c_void); - -extern "C" { - pub fn nftnl_gen_alloc() -> *mut nftnl_gen; - - pub fn nftnl_gen_free(arg1: *const nftnl_gen); -} -pub const NFTNL_GEN_ID: u32 = 0; -pub const __NFTNL_GEN_MAX: u32 = 1; - -extern "C" { - pub fn nftnl_gen_is_set(gen: *const nftnl_gen, attr: u16) -> bool; - - pub fn nftnl_gen_unset(gen: *mut nftnl_gen, attr: u16); - - pub fn nftnl_gen_set(gen: *mut nftnl_gen, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_gen_set_data( - gen: *mut nftnl_gen, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_gen_get(gen: *const nftnl_gen, attr: u16) -> *const c_void; - - pub fn nftnl_gen_get_data( - gen: *const nftnl_gen, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_gen_set_u32(gen: *mut nftnl_gen, attr: u16, data: u32); - - pub fn nftnl_gen_get_u32(gen: *const nftnl_gen, attr: u16) -> u32; - - pub fn nftnl_gen_nlmsg_parse(nlh: *const nlmsghdr, gen: *mut nftnl_gen) -> c_int; - - pub fn nftnl_gen_snprintf( - buf: *mut c_char, - size: usize, - gen: *const nftnl_gen, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_gen_fprintf(fp: *mut FILE, gen: *const nftnl_gen, type_: u32, flags: u32) - -> c_int; -} -pub const NFTNL_OBJ_TABLE: u32 = 0; -pub const NFTNL_OBJ_NAME: u32 = 1; -pub const NFTNL_OBJ_TYPE: u32 = 2; -pub const NFTNL_OBJ_FAMILY: u32 = 3; -pub const NFTNL_OBJ_USE: u32 = 4; -pub const NFTNL_OBJ_BASE: u32 = 16; -pub const __NFTNL_OBJ_MAX: u32 = 17; - -pub const NFTNL_OBJ_CTR_PKTS: u32 = 16; -pub const NFTNL_OBJ_CTR_BYTES: u32 = 17; - -pub const NFTNL_OBJ_QUOTA_BYTES: u32 = 16; -pub const NFTNL_OBJ_QUOTA_CONSUMED: u32 = 17; -pub const NFTNL_OBJ_QUOTA_FLAGS: u32 = 18; - -pub const NFTNL_OBJ_CT_HELPER_NAME: u32 = 16; -pub const NFTNL_OBJ_CT_HELPER_L3PROTO: u32 = 17; -pub const NFTNL_OBJ_CT_HELPER_L4PROTO: u32 = 18; - -pub const NFTNL_OBJ_LIMIT_RATE: u32 = 16; -pub const NFTNL_OBJ_LIMIT_UNIT: u32 = 17; -pub const NFTNL_OBJ_LIMIT_BURST: u32 = 18; -pub const NFTNL_OBJ_LIMIT_TYPE: u32 = 19; -pub const NFTNL_OBJ_LIMIT_FLAGS: u32 = 20; - -#[repr(C)] -pub struct nftnl_obj(c_void); - -extern "C" { - pub fn nftnl_obj_alloc() -> *mut nftnl_obj; - - pub fn nftnl_obj_free(ne: *const nftnl_obj); - - pub fn nftnl_obj_is_set(ne: *const nftnl_obj, attr: u16) -> bool; - - pub fn nftnl_obj_unset(ne: *mut nftnl_obj, attr: u16); - - pub fn nftnl_obj_set_data(ne: *mut nftnl_obj, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_obj_set(ne: *mut nftnl_obj, attr: u16, data: *const c_void); - - pub fn nftnl_obj_set_u8(ne: *mut nftnl_obj, attr: u16, val: u8); - - pub fn nftnl_obj_set_u16(ne: *mut nftnl_obj, attr: u16, val: u16); - - pub fn nftnl_obj_set_u32(ne: *mut nftnl_obj, attr: u16, val: u32); - - pub fn nftnl_obj_set_u64(obj: *mut nftnl_obj, attr: u16, val: u64); - - pub fn nftnl_obj_set_str(ne: *mut nftnl_obj, attr: u16, str: *const c_char); - - pub fn nftnl_obj_get_data(ne: *mut nftnl_obj, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_obj_get(ne: *mut nftnl_obj, attr: u16) -> *const c_void; - - pub fn nftnl_obj_get_u8(ne: *mut nftnl_obj, attr: u16) -> u8; - - pub fn nftnl_obj_get_u16(obj: *mut nftnl_obj, attr: u16) -> u16; - - pub fn nftnl_obj_get_u32(ne: *mut nftnl_obj, attr: u16) -> u32; - - pub fn nftnl_obj_get_u64(obj: *mut nftnl_obj, attr: u16) -> u64; - - pub fn nftnl_obj_get_str(ne: *mut nftnl_obj, attr: u16) -> *const c_char; - - pub fn nftnl_obj_nlmsg_build_payload(nlh: *mut nlmsghdr, ne: *const nftnl_obj); - - pub fn nftnl_obj_nlmsg_parse(nlh: *const nlmsghdr, ne: *mut nftnl_obj) -> c_int; - - pub fn nftnl_obj_parse( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_parse_file( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_snprintf( - buf: *mut c_char, - size: usize, - ne: *const nftnl_obj, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_obj_fprintf(fp: *mut FILE, ne: *const nftnl_obj, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list(c_void); - -extern "C" { - pub fn nftnl_obj_list_alloc() -> *mut nftnl_obj_list; - - pub fn nftnl_obj_list_free(list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_is_empty(list: *mut nftnl_obj_list) -> c_int; - - pub fn nftnl_obj_list_add(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_add_tail(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_del(t: *mut nftnl_obj); - - pub fn nftnl_obj_list_foreach( - table_list: *mut nftnl_obj_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_obj, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list_iter(c_void); - -extern "C" { - pub fn nftnl_obj_list_iter_create(l: *mut nftnl_obj_list) -> *mut nftnl_obj_list_iter; - - pub fn nftnl_obj_list_iter_next(iter: *mut nftnl_obj_list_iter) -> *mut nftnl_obj; - - pub fn nftnl_obj_list_iter_destroy(iter: *mut nftnl_obj_list_iter); -} -#[repr(C)] -pub struct nftnl_rule(c_void); - -extern "C" { - pub fn nftnl_rule_alloc() -> *mut nftnl_rule; - - pub fn nftnl_rule_free(arg1: *const nftnl_rule); -} -pub const NFTNL_RULE_FAMILY: nftnl_rule_attr = 0; -pub const NFTNL_RULE_TABLE: nftnl_rule_attr = 1; -pub const NFTNL_RULE_CHAIN: nftnl_rule_attr = 2; -pub const NFTNL_RULE_HANDLE: nftnl_rule_attr = 3; -pub const NFTNL_RULE_COMPAT_PROTO: nftnl_rule_attr = 4; -pub const NFTNL_RULE_COMPAT_FLAGS: nftnl_rule_attr = 5; -pub const NFTNL_RULE_POSITION: nftnl_rule_attr = 6; -pub const NFTNL_RULE_USERDATA: nftnl_rule_attr = 7; -pub const NFTNL_RULE_ID: nftnl_rule_attr = 8; -pub const __NFTNL_RULE_MAX: nftnl_rule_attr = 9; -pub type nftnl_rule_attr = u32; -extern "C" { - pub fn nftnl_rule_unset(r: *mut nftnl_rule, attr: u16); - - pub fn nftnl_rule_is_set(r: *const nftnl_rule, attr: u16) -> bool; - - pub fn nftnl_rule_set(r: *mut nftnl_rule, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_rule_set_data( - r: *mut nftnl_rule, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_rule_set_u32(r: *mut nftnl_rule, attr: u16, val: u32); - - pub fn nftnl_rule_set_u64(r: *mut nftnl_rule, attr: u16, val: u64); - - pub fn nftnl_rule_set_str(r: *mut nftnl_rule, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_rule_get(r: *const nftnl_rule, attr: u16) -> *const c_void; - - pub fn nftnl_rule_get_data( - r: *const nftnl_rule, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_rule_get_str(r: *const nftnl_rule, attr: u16) -> *const c_char; - - pub fn nftnl_rule_get_u8(r: *const nftnl_rule, attr: u16) -> u8; - - pub fn nftnl_rule_get_u32(r: *const nftnl_rule, attr: u16) -> u32; - - pub fn nftnl_rule_get_u64(r: *const nftnl_rule, attr: u16) -> u64; - - pub fn nftnl_rule_add_expr(r: *mut nftnl_rule, expr: *mut nftnl_expr); - - pub fn nftnl_rule_cmp(r1: *const nftnl_rule, r2: *const nftnl_rule) -> bool; - - pub fn nftnl_rule_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *mut nftnl_rule); - - pub fn nftnl_rule_parse( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_parse_file( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_rule, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_rule_fprintf(fp: *mut FILE, r: *const nftnl_rule, type_: u32, flags: u32) - -> c_int; - - pub fn nftnl_rule_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_rule) -> c_int; - - pub fn nftnl_expr_foreach( - r: *mut nftnl_rule, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_expr, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_expr_iter(c_void); - -extern "C" { - pub fn nftnl_expr_iter_create(r: *const nftnl_rule) -> *mut nftnl_expr_iter; - - pub fn nftnl_expr_iter_next(iter: *mut nftnl_expr_iter) -> *mut nftnl_expr; - - pub fn nftnl_expr_iter_destroy(iter: *mut nftnl_expr_iter); -} -#[repr(C)] -pub struct nftnl_rule_list(c_void); - -extern "C" { - pub fn nftnl_rule_list_alloc() -> *mut nftnl_rule_list; - - pub fn nftnl_rule_list_free(list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_is_empty(list: *const nftnl_rule_list) -> c_int; - - pub fn nftnl_rule_list_add(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_add_tail(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_del(r: *mut nftnl_rule); - - pub fn nftnl_rule_list_foreach( - rule_list: *mut nftnl_rule_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_rule, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_rule_list_iter(c_void); - -extern "C" { - pub fn nftnl_rule_list_iter_create(l: *const nftnl_rule_list) -> *mut nftnl_rule_list_iter; - - pub fn nftnl_rule_list_iter_cur(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_next(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_destroy(iter: *const nftnl_rule_list_iter); -} -#[repr(C)] -pub struct nftnl_ruleset(c_void); - -extern "C" { - pub fn nftnl_ruleset_alloc() -> *mut nftnl_ruleset; - - pub fn nftnl_ruleset_free(r: *const nftnl_ruleset); -} -pub const NFTNL_RULESET_TABLELIST: u32 = 0; -pub const NFTNL_RULESET_CHAINLIST: u32 = 1; -pub const NFTNL_RULESET_SETLIST: u32 = 2; -pub const NFTNL_RULESET_RULELIST: u32 = 3; - -pub const NFTNL_RULESET_UNSPEC: nftnl_ruleset_type = 0; -pub const NFTNL_RULESET_RULESET: nftnl_ruleset_type = 1; -pub const NFTNL_RULESET_TABLE: nftnl_ruleset_type = 2; -pub const NFTNL_RULESET_CHAIN: nftnl_ruleset_type = 3; -pub const NFTNL_RULESET_RULE: nftnl_ruleset_type = 4; -pub const NFTNL_RULESET_SET: nftnl_ruleset_type = 5; -pub const NFTNL_RULESET_SET_ELEMS: nftnl_ruleset_type = 6; -pub type nftnl_ruleset_type = u32; -extern "C" { - pub fn nftnl_ruleset_is_set(r: *const nftnl_ruleset, attr: u16) -> bool; - - pub fn nftnl_ruleset_unset(r: *mut nftnl_ruleset, attr: u16); - - pub fn nftnl_ruleset_set(r: *mut nftnl_ruleset, attr: u16, data: *mut c_void); - - pub fn nftnl_ruleset_get(r: *const nftnl_ruleset, attr: u16) -> *mut c_void; -} -pub const NFTNL_RULESET_CTX_CMD: u32 = 0; -pub const NFTNL_RULESET_CTX_TYPE: u32 = 1; -pub const NFTNL_RULESET_CTX_TABLE: u32 = 2; -pub const NFTNL_RULESET_CTX_CHAIN: u32 = 3; -pub const NFTNL_RULESET_CTX_RULE: u32 = 4; -pub const NFTNL_RULESET_CTX_SET: u32 = 5; -pub const NFTNL_RULESET_CTX_DATA: u32 = 6; - -#[repr(C)] -pub struct nftnl_parse_ctx(c_void); - -extern "C" { - pub fn nftnl_ruleset_ctx_free(ctx: *const nftnl_parse_ctx); - - pub fn nftnl_ruleset_ctx_is_set(ctx: *const nftnl_parse_ctx, attr: u16) -> bool; - - pub fn nftnl_ruleset_ctx_get(ctx: *const nftnl_parse_ctx, attr: u16) -> *mut c_void; - - pub fn nftnl_ruleset_ctx_get_u32(ctx: *const nftnl_parse_ctx, attr: u16) -> u32; - - pub fn nftnl_ruleset_parse_file_cb( - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse_buffer_cb( - type_: nftnl_parse_type, - buffer: *const c_char, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_parse_file( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_snprintf( - buf: *mut c_char, - size: usize, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_ruleset_fprintf( - fp: *mut FILE, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_SET_TABLE: nftnl_set_attr = 0; -pub const NFTNL_SET_NAME: nftnl_set_attr = 1; -pub const NFTNL_SET_FLAGS: nftnl_set_attr = 2; -pub const NFTNL_SET_KEY_TYPE: nftnl_set_attr = 3; -pub const NFTNL_SET_KEY_LEN: nftnl_set_attr = 4; -pub const NFTNL_SET_DATA_TYPE: nftnl_set_attr = 5; -pub const NFTNL_SET_DATA_LEN: nftnl_set_attr = 6; -pub const NFTNL_SET_FAMILY: nftnl_set_attr = 7; -pub const NFTNL_SET_ID: nftnl_set_attr = 8; -pub const NFTNL_SET_POLICY: nftnl_set_attr = 9; -pub const NFTNL_SET_DESC_SIZE: nftnl_set_attr = 10; -pub const NFTNL_SET_TIMEOUT: nftnl_set_attr = 11; -pub const NFTNL_SET_GC_INTERVAL: nftnl_set_attr = 12; -pub const NFTNL_SET_USERDATA: nftnl_set_attr = 13; -pub const NFTNL_SET_OBJ_TYPE: nftnl_set_attr = 14; -pub const __NFTNL_SET_MAX: nftnl_set_attr = 15; -pub type nftnl_set_attr = u32; -#[repr(C)] -pub struct nftnl_set(c_void); - -extern "C" { - pub fn nftnl_set_alloc() -> *mut nftnl_set; - - pub fn nftnl_set_free(s: *const nftnl_set); - - pub fn nftnl_set_clone(set: *const nftnl_set) -> *mut nftnl_set; - - pub fn nftnl_set_is_set(s: *const nftnl_set, attr: u16) -> bool; - - pub fn nftnl_set_unset(s: *mut nftnl_set, attr: u16); - - pub fn nftnl_set_set(s: *mut nftnl_set, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_set_set_data( - s: *mut nftnl_set, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_set_u32(s: *mut nftnl_set, attr: u16, val: u32); - - pub fn nftnl_set_set_u64(s: *mut nftnl_set, attr: u16, val: u64); - - pub fn nftnl_set_set_str(s: *mut nftnl_set, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_get(s: *const nftnl_set, attr: u16) -> *const c_void; - - pub fn nftnl_set_get_data(s: *const nftnl_set, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_set_get_str(s: *const nftnl_set, attr: u16) -> *const c_char; - - pub fn nftnl_set_get_u32(s: *const nftnl_set, attr: u16) -> u32; - - pub fn nftnl_set_get_u64(s: *const nftnl_set, attr: u16) -> u64; - - pub fn nftnl_set_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_elems_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_fprintf(fp: *mut FILE, s: *const nftnl_set, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list(c_void); - -extern "C" { - pub fn nftnl_set_list_alloc() -> *mut nftnl_set_list; - - pub fn nftnl_set_list_free(list: *mut nftnl_set_list); - - pub fn nftnl_set_list_is_empty(list: *const nftnl_set_list) -> c_int; - - pub fn nftnl_set_list_add(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_add_tail(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_del(s: *mut nftnl_set); - - pub fn nftnl_set_list_foreach( - set_list: *mut nftnl_set_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_set, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list_iter(c_void); - -extern "C" { - pub fn nftnl_set_list_iter_create(l: *const nftnl_set_list) -> *mut nftnl_set_list_iter; - - pub fn nftnl_set_list_iter_cur(iter: *const nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_next(iter: *mut nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_destroy(iter: *const nftnl_set_list_iter); - - pub fn nftnl_set_parse( - s: *mut nftnl_set, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_parse_file( - s: *mut nftnl_set, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; -} -pub const NFTNL_SET_ELEM_FLAGS: u32 = 0; -pub const NFTNL_SET_ELEM_KEY: u32 = 1; -pub const NFTNL_SET_ELEM_VERDICT: u32 = 2; -pub const NFTNL_SET_ELEM_CHAIN: u32 = 3; -pub const NFTNL_SET_ELEM_DATA: u32 = 4; -pub const NFTNL_SET_ELEM_TIMEOUT: u32 = 5; -pub const NFTNL_SET_ELEM_EXPIRATION: u32 = 6; -pub const NFTNL_SET_ELEM_USERDATA: u32 = 7; -pub const NFTNL_SET_ELEM_EXPR: u32 = 8; -pub const NFTNL_SET_ELEM_OBJREF: u32 = 9; - -#[repr(C)] -pub struct nftnl_set_elem(c_void); - -extern "C" { - pub fn nftnl_set_elem_alloc() -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_free(s: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_clone(elem: *mut nftnl_set_elem) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_add(s: *mut nftnl_set, elem: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_unset(s: *mut nftnl_set_elem, attr: u16); - - pub fn nftnl_set_elem_set( - s: *mut nftnl_set_elem, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_elem_set_u32(s: *mut nftnl_set_elem, attr: u16, val: u32); - - pub fn nftnl_set_elem_set_u64(s: *mut nftnl_set_elem, attr: u16, val: u64); - - pub fn nftnl_set_elem_set_str(s: *mut nftnl_set_elem, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_elem_get( - s: *mut nftnl_set_elem, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_set_elem_get_str(s: *mut nftnl_set_elem, attr: u16) -> *const c_char; - - pub fn nftnl_set_elem_get_u32(s: *mut nftnl_set_elem, attr: u16) -> u32; - - pub fn nftnl_set_elem_get_u64(s: *mut nftnl_set_elem, attr: u16) -> u64; - - pub fn nftnl_set_elem_is_set(s: *const nftnl_set_elem, attr: u16) -> bool; - - pub fn nftnl_set_elems_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_elem_nlmsg_build_payload(nlh: *mut nlmsghdr, e: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_parse( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_parse_file( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_fprintf( - fp: *mut FILE, - se: *mut nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_foreach( - s: *mut nftnl_set, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_set_elem, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_elems_iter(c_void); - -extern "C" { - pub fn nftnl_set_elems_iter_create(s: *const nftnl_set) -> *mut nftnl_set_elems_iter; - - pub fn nftnl_set_elems_iter_cur(iter: *const nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_next(iter: *mut nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_destroy(iter: *mut nftnl_set_elems_iter); - - pub fn nftnl_set_elems_nlmsg_build_payload_iter( - nlh: *mut nlmsghdr, - iter: *mut nftnl_set_elems_iter, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_table(c_void); - -extern "C" { - pub fn nftnl_table_alloc() -> *mut nftnl_table; - - pub fn nftnl_table_free(arg1: *const nftnl_table); -} -pub const NFTNL_TABLE_NAME: nftnl_table_attr = 0; -pub const NFTNL_TABLE_FAMILY: nftnl_table_attr = 1; -pub const NFTNL_TABLE_FLAGS: nftnl_table_attr = 2; -pub const NFTNL_TABLE_USE: nftnl_table_attr = 3; -pub const __NFTNL_TABLE_MAX: nftnl_table_attr = 4; -pub type nftnl_table_attr = u32; -extern "C" { - pub fn nftnl_table_is_set(t: *const nftnl_table, attr: u16) -> bool; - - pub fn nftnl_table_unset(t: *mut nftnl_table, attr: u16); - - pub fn nftnl_table_set(t: *mut nftnl_table, attr: u16, data: *const c_void); - - pub fn nftnl_table_set_data( - t: *mut nftnl_table, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_table_get(t: *const nftnl_table, attr: u16) -> *const c_void; - - pub fn nftnl_table_get_data( - t: *const nftnl_table, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_table_set_u8(t: *mut nftnl_table, attr: u16, data: u8); - - pub fn nftnl_table_set_u32(t: *mut nftnl_table, attr: u16, data: u32); - - pub fn nftnl_table_set_str(t: *mut nftnl_table, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_table_get_u8(t: *const nftnl_table, attr: u16) -> u8; - - pub fn nftnl_table_get_u32(t: *const nftnl_table, attr: u16) -> u32; - - pub fn nftnl_table_get_str(t: *const nftnl_table, attr: u16) -> *const c_char; - - pub fn nftnl_table_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_table); - - pub fn nftnl_table_parse( - t: *mut nftnl_table, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_parse_file( - t: *mut nftnl_table, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_fprintf( - fp: *mut FILE, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_table) -> c_int; -} -#[repr(C)] -pub struct nftnl_table_list(c_void); - -extern "C" { - pub fn nftnl_table_list_alloc() -> *mut nftnl_table_list; - - pub fn nftnl_table_list_free(list: *mut nftnl_table_list); - - pub fn nftnl_table_list_is_empty(list: *const nftnl_table_list) -> c_int; - - pub fn nftnl_table_list_foreach( - table_list: *mut nftnl_table_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_table, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_table_list_add(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_add_tail(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_del(r: *mut nftnl_table); -} -#[repr(C)] -pub struct nftnl_table_list_iter(c_void); - -extern "C" { - pub fn nftnl_table_list_iter_create(l: *const nftnl_table_list) -> *mut nftnl_table_list_iter; - - pub fn nftnl_table_list_iter_next(iter: *mut nftnl_table_list_iter) -> *mut nftnl_table; - - pub fn nftnl_table_list_iter_destroy(iter: *const nftnl_table_list_iter); -} -pub const NFTNL_TRACE_CHAIN: nftnl_trace_attr = 0; -pub const NFTNL_TRACE_FAMILY: nftnl_trace_attr = 1; -pub const NFTNL_TRACE_ID: nftnl_trace_attr = 2; -pub const NFTNL_TRACE_IIF: nftnl_trace_attr = 3; -pub const NFTNL_TRACE_IIFTYPE: nftnl_trace_attr = 4; -pub const NFTNL_TRACE_JUMP_TARGET: nftnl_trace_attr = 5; -pub const NFTNL_TRACE_OIF: nftnl_trace_attr = 6; -pub const NFTNL_TRACE_OIFTYPE: nftnl_trace_attr = 7; -pub const NFTNL_TRACE_MARK: nftnl_trace_attr = 8; -pub const NFTNL_TRACE_LL_HEADER: nftnl_trace_attr = 9; -pub const NFTNL_TRACE_NETWORK_HEADER: nftnl_trace_attr = 10; -pub const NFTNL_TRACE_TRANSPORT_HEADER: nftnl_trace_attr = 11; -pub const NFTNL_TRACE_TABLE: nftnl_trace_attr = 12; -pub const NFTNL_TRACE_TYPE: nftnl_trace_attr = 13; -pub const NFTNL_TRACE_RULE_HANDLE: nftnl_trace_attr = 14; -pub const NFTNL_TRACE_VERDICT: nftnl_trace_attr = 15; -pub const NFTNL_TRACE_NFPROTO: nftnl_trace_attr = 16; -pub const NFTNL_TRACE_POLICY: nftnl_trace_attr = 17; -pub const __NFTNL_TRACE_MAX: nftnl_trace_attr = 18; -pub type nftnl_trace_attr = u32; -#[repr(C)] -pub struct nftnl_trace(c_void); - -extern "C" { - pub fn nftnl_trace_alloc() -> *mut nftnl_trace; - - pub fn nftnl_trace_free(trace: *const nftnl_trace); - - pub fn nftnl_trace_is_set(trace: *const nftnl_trace, type_: u16) -> bool; - - pub fn nftnl_trace_get_data( - trace: *const nftnl_trace, - type_: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_trace_get_u16(trace: *const nftnl_trace, type_: u16) -> u16; - - pub fn nftnl_trace_get_u32(trace: *const nftnl_trace, type_: u16) -> u32; - - pub fn nftnl_trace_get_u64(trace: *const nftnl_trace, type_: u16) -> u64; - - pub fn nftnl_trace_get_str(trace: *const nftnl_trace, type_: u16) -> *const c_char; - - pub fn nftnl_trace_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_trace) -> c_int; -} -#[repr(C)] -pub struct nftnl_udata(c_void); - -#[repr(C)] -pub struct nftnl_udata_buf(c_void); - -extern "C" { - pub fn nftnl_udata_buf_alloc(data_size: u32) -> *mut nftnl_udata_buf; - - pub fn nftnl_udata_buf_free(buf: *const nftnl_udata_buf); - - pub fn nftnl_udata_buf_len(buf: *const nftnl_udata_buf) -> u32; - - pub fn nftnl_udata_buf_data(buf: *const nftnl_udata_buf) -> *mut c_void; - - pub fn nftnl_udata_buf_put(buf: *mut nftnl_udata_buf, data: *const c_void, len: u32); - - pub fn nftnl_udata_start(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_end(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_put( - buf: *mut nftnl_udata_buf, - type_: u8, - len: u32, - value: *const c_void, - ) -> bool; - - pub fn nftnl_udata_put_u32(buf: *mut nftnl_udata_buf, type_: u8, data: u32) -> bool; - - pub fn nftnl_udata_put_strz(buf: *mut nftnl_udata_buf, type_: u8, strz: *const c_char) -> bool; - - pub fn nftnl_udata_type(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_len(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_get(attr: *const nftnl_udata) -> *mut c_void; - - pub fn nftnl_udata_get_u32(attr: *const nftnl_udata) -> u32; - - pub fn nftnl_udata_next(attr: *const nftnl_udata) -> *mut nftnl_udata; -} -pub type nftnl_udata_cb_t = - Option<unsafe extern "C" fn(attr: *const nftnl_udata, data: *mut c_void) -> c_int>; -extern "C" { - pub fn nftnl_udata_parse( - data: *const c_void, - data_len: u32, - cb: nftnl_udata_cb_t, - cb_data: *mut c_void, - ) -> c_int; -} diff --git a/rustables-sys/src/nftnl_1_0_9.rs b/rustables-sys/src/nftnl_1_0_9.rs deleted file mode 100644 index f9b2809..0000000 --- a/rustables-sys/src/nftnl_1_0_9.rs +++ /dev/null @@ -1,1258 +0,0 @@ -// automatically generated by rust-bindgen 0.39.0 - -use core::option::Option; -use libc::{c_char, c_int, c_void, iovec, nlmsghdr, FILE}; - -#[repr(C)] -pub struct nftnl_batch(c_void); - -extern "C" { - pub fn nftnl_batch_alloc(pg_size: u32, pg_overrun_size: u32) -> *mut nftnl_batch; - - pub fn nftnl_batch_update(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_free(batch: *mut nftnl_batch); - - pub fn nftnl_batch_buffer(batch: *mut nftnl_batch) -> *mut c_void; - - pub fn nftnl_batch_buffer_len(batch: *mut nftnl_batch) -> u32; - - pub fn nftnl_batch_iovec_len(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_iovec(batch: *mut nftnl_batch, iov: *mut iovec, iovlen: u32); -} -pub const NFTNL_PARSE_EBADINPUT: u32 = 0; -pub const NFTNL_PARSE_EMISSINGNODE: u32 = 1; -pub const NFTNL_PARSE_EBADTYPE: u32 = 2; -pub const NFTNL_PARSE_EOPNOTSUPP: u32 = 3; - -pub const NFTNL_OUTPUT_DEFAULT: nftnl_output_type = 0; -pub const NFTNL_OUTPUT_XML: nftnl_output_type = 1; -pub const NFTNL_OUTPUT_JSON: nftnl_output_type = 2; -pub type nftnl_output_type = u32; -pub const NFTNL_OF_EVENT_NEW: nftnl_output_flags = 1; -pub const NFTNL_OF_EVENT_DEL: nftnl_output_flags = 2; -pub const NFTNL_OF_EVENT_ANY: nftnl_output_flags = 3; -pub type nftnl_output_flags = u32; -pub const NFTNL_CMD_UNSPEC: nftnl_cmd_type = 0; -pub const NFTNL_CMD_ADD: nftnl_cmd_type = 1; -pub const NFTNL_CMD_INSERT: nftnl_cmd_type = 2; -pub const NFTNL_CMD_DELETE: nftnl_cmd_type = 3; -pub const NFTNL_CMD_REPLACE: nftnl_cmd_type = 4; -pub const NFTNL_CMD_FLUSH: nftnl_cmd_type = 5; -pub const NFTNL_CMD_MAX: nftnl_cmd_type = 6; -pub type nftnl_cmd_type = u32; -pub const NFTNL_PARSE_NONE: nftnl_parse_type = 0; -pub const NFTNL_PARSE_XML: nftnl_parse_type = 1; -pub const NFTNL_PARSE_JSON: nftnl_parse_type = 2; -pub const NFTNL_PARSE_MAX: nftnl_parse_type = 3; -pub type nftnl_parse_type = u32; -#[repr(C)] -pub struct nftnl_parse_err(c_void); - -extern "C" { - pub fn nftnl_nlmsg_build_hdr( - buf: *mut c_char, - type_: u16, - family: u16, - flags: u16, - seq: u32, - ) -> *mut nlmsghdr; - - pub fn nftnl_parse_err_alloc() -> *mut nftnl_parse_err; - - pub fn nftnl_parse_err_free(arg1: *mut nftnl_parse_err); - - pub fn nftnl_parse_perror(str: *const c_char, err: *mut nftnl_parse_err) -> c_int; - - pub fn nftnl_batch_is_supported() -> c_int; - - pub fn nftnl_batch_begin(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; - - pub fn nftnl_batch_end(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; -} -#[repr(C)] -pub struct nftnl_chain(c_void); - -extern "C" { - pub fn nftnl_chain_alloc() -> *mut nftnl_chain; - - pub fn nftnl_chain_free(arg1: *const nftnl_chain); -} -pub const NFTNL_CHAIN_NAME: nftnl_chain_attr = 0; -pub const NFTNL_CHAIN_FAMILY: nftnl_chain_attr = 1; -pub const NFTNL_CHAIN_TABLE: nftnl_chain_attr = 2; -pub const NFTNL_CHAIN_HOOKNUM: nftnl_chain_attr = 3; -pub const NFTNL_CHAIN_PRIO: nftnl_chain_attr = 4; -pub const NFTNL_CHAIN_POLICY: nftnl_chain_attr = 5; -pub const NFTNL_CHAIN_USE: nftnl_chain_attr = 6; -pub const NFTNL_CHAIN_BYTES: nftnl_chain_attr = 7; -pub const NFTNL_CHAIN_PACKETS: nftnl_chain_attr = 8; -pub const NFTNL_CHAIN_HANDLE: nftnl_chain_attr = 9; -pub const NFTNL_CHAIN_TYPE: nftnl_chain_attr = 10; -pub const NFTNL_CHAIN_DEV: nftnl_chain_attr = 11; -pub const __NFTNL_CHAIN_MAX: nftnl_chain_attr = 12; -pub type nftnl_chain_attr = u32; -extern "C" { - pub fn nftnl_chain_is_set(c: *const nftnl_chain, attr: u16) -> bool; - - pub fn nftnl_chain_unset(c: *mut nftnl_chain, attr: u16); - - pub fn nftnl_chain_set(t: *mut nftnl_chain, attr: u16, data: *const c_void); - - pub fn nftnl_chain_set_data( - t: *mut nftnl_chain, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_chain_set_u8(t: *mut nftnl_chain, attr: u16, data: u8); - - pub fn nftnl_chain_set_u32(t: *mut nftnl_chain, attr: u16, data: u32); - - pub fn nftnl_chain_set_s32(t: *mut nftnl_chain, attr: u16, data: i32); - - pub fn nftnl_chain_set_u64(t: *mut nftnl_chain, attr: u16, data: u64); - - pub fn nftnl_chain_set_str(t: *mut nftnl_chain, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_chain_get(c: *const nftnl_chain, attr: u16) -> *const c_void; - - pub fn nftnl_chain_get_data( - c: *const nftnl_chain, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_chain_get_str(c: *const nftnl_chain, attr: u16) -> *const c_char; - - pub fn nftnl_chain_get_u8(c: *const nftnl_chain, attr: u16) -> u8; - - pub fn nftnl_chain_get_u32(c: *const nftnl_chain, attr: u16) -> u32; - - pub fn nftnl_chain_get_s32(c: *const nftnl_chain, attr: u16) -> i32; - - pub fn nftnl_chain_get_u64(c: *const nftnl_chain, attr: u16) -> u64; - - pub fn nftnl_chain_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_chain); - - pub fn nftnl_chain_parse( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_parse_file( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_fprintf( - fp: *mut FILE, - c: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_chain) -> c_int; -} -#[repr(C)] -pub struct nftnl_chain_list(c_void); - -extern "C" { - pub fn nftnl_chain_list_alloc() -> *mut nftnl_chain_list; - - pub fn nftnl_chain_list_free(list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_is_empty(list: *const nftnl_chain_list) -> c_int; - - pub fn nftnl_chain_list_foreach( - chain_list: *mut nftnl_chain_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_chain, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_chain_list_add(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_add_tail(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_del(c: *mut nftnl_chain); -} -#[repr(C)] -pub struct nftnl_chain_list_iter(c_void); - -extern "C" { - pub fn nftnl_chain_list_iter_create(l: *const nftnl_chain_list) -> *mut nftnl_chain_list_iter; - - pub fn nftnl_chain_list_iter_next(iter: *mut nftnl_chain_list_iter) -> *mut nftnl_chain; - - pub fn nftnl_chain_list_iter_destroy(iter: *mut nftnl_chain_list_iter); -} -#[repr(C)] -pub struct nftnl_expr(c_void); - -pub const NFTNL_EXPR_NAME: u32 = 0; -pub const NFTNL_EXPR_BASE: u32 = 1; - -extern "C" { - pub fn nftnl_expr_alloc(name: *const c_char) -> *mut nftnl_expr; - - pub fn nftnl_expr_free(expr: *const nftnl_expr); - - pub fn nftnl_expr_is_set(expr: *const nftnl_expr, type_: u16) -> bool; - - pub fn nftnl_expr_set( - expr: *mut nftnl_expr, - type_: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_expr_set_u8(expr: *mut nftnl_expr, type_: u16, data: u8); - - pub fn nftnl_expr_set_u16(expr: *mut nftnl_expr, type_: u16, data: u16); - - pub fn nftnl_expr_set_u32(expr: *mut nftnl_expr, type_: u16, data: u32); - - pub fn nftnl_expr_set_u64(expr: *mut nftnl_expr, type_: u16, data: u64); - - pub fn nftnl_expr_set_str(expr: *mut nftnl_expr, type_: u16, str: *const c_char) -> c_int; - - pub fn nftnl_expr_get(expr: *const nftnl_expr, type_: u16, data_len: *mut u32) - -> *const c_void; - - pub fn nftnl_expr_get_u8(expr: *const nftnl_expr, type_: u16) -> u8; - - pub fn nftnl_expr_get_u16(expr: *const nftnl_expr, type_: u16) -> u16; - - pub fn nftnl_expr_get_u32(expr: *const nftnl_expr, type_: u16) -> u32; - - pub fn nftnl_expr_get_u64(expr: *const nftnl_expr, type_: u16) -> u64; - - pub fn nftnl_expr_get_str(expr: *const nftnl_expr, type_: u16) -> *const c_char; - - pub fn nftnl_expr_cmp(e1: *const nftnl_expr, e2: *const nftnl_expr) -> bool; - - pub fn nftnl_expr_snprintf( - buf: *mut c_char, - buflen: usize, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_expr_fprintf( - fp: *mut FILE, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_EXPR_PAYLOAD_DREG: u32 = 1; -pub const NFTNL_EXPR_PAYLOAD_BASE: u32 = 2; -pub const NFTNL_EXPR_PAYLOAD_OFFSET: u32 = 3; -pub const NFTNL_EXPR_PAYLOAD_LEN: u32 = 4; -pub const NFTNL_EXPR_PAYLOAD_SREG: u32 = 5; -pub const NFTNL_EXPR_PAYLOAD_CSUM_TYPE: u32 = 6; -pub const NFTNL_EXPR_PAYLOAD_CSUM_OFFSET: u32 = 7; -pub const NFTNL_EXPR_PAYLOAD_FLAGS: u32 = 8; - -pub const NFTNL_EXPR_NG_DREG: u32 = 1; -pub const NFTNL_EXPR_NG_MODULUS: u32 = 2; -pub const NFTNL_EXPR_NG_TYPE: u32 = 3; -pub const NFTNL_EXPR_NG_OFFSET: u32 = 4; - -pub const NFTNL_EXPR_META_KEY: u32 = 1; -pub const NFTNL_EXPR_META_DREG: u32 = 2; -pub const NFTNL_EXPR_META_SREG: u32 = 3; - -pub const NFTNL_EXPR_RT_KEY: u32 = 1; -pub const NFTNL_EXPR_RT_DREG: u32 = 2; - -pub const NFTNL_EXPR_CMP_SREG: u32 = 1; -pub const NFTNL_EXPR_CMP_OP: u32 = 2; -pub const NFTNL_EXPR_CMP_DATA: u32 = 3; - -pub const NFTNL_EXPR_RANGE_SREG: u32 = 1; -pub const NFTNL_EXPR_RANGE_OP: u32 = 2; -pub const NFTNL_EXPR_RANGE_FROM_DATA: u32 = 3; -pub const NFTNL_EXPR_RANGE_TO_DATA: u32 = 4; - -pub const NFTNL_EXPR_IMM_DREG: u32 = 1; -pub const NFTNL_EXPR_IMM_DATA: u32 = 2; -pub const NFTNL_EXPR_IMM_VERDICT: u32 = 3; -pub const NFTNL_EXPR_IMM_CHAIN: u32 = 4; - -pub const NFTNL_EXPR_CTR_PACKETS: u32 = 1; -pub const NFTNL_EXPR_CTR_BYTES: u32 = 2; - -pub const NFTNL_EXPR_BITWISE_SREG: u32 = 1; -pub const NFTNL_EXPR_BITWISE_DREG: u32 = 2; -pub const NFTNL_EXPR_BITWISE_LEN: u32 = 3; -pub const NFTNL_EXPR_BITWISE_MASK: u32 = 4; -pub const NFTNL_EXPR_BITWISE_XOR: u32 = 5; - -pub const NFTNL_EXPR_TG_NAME: u32 = 1; -pub const NFTNL_EXPR_TG_REV: u32 = 2; -pub const NFTNL_EXPR_TG_INFO: u32 = 3; - -pub const NFTNL_EXPR_MT_NAME: u32 = 1; -pub const NFTNL_EXPR_MT_REV: u32 = 2; -pub const NFTNL_EXPR_MT_INFO: u32 = 3; - -pub const NFTNL_EXPR_NAT_TYPE: u32 = 1; -pub const NFTNL_EXPR_NAT_FAMILY: u32 = 2; -pub const NFTNL_EXPR_NAT_REG_ADDR_MIN: u32 = 3; -pub const NFTNL_EXPR_NAT_REG_ADDR_MAX: u32 = 4; -pub const NFTNL_EXPR_NAT_REG_PROTO_MIN: u32 = 5; -pub const NFTNL_EXPR_NAT_REG_PROTO_MAX: u32 = 6; -pub const NFTNL_EXPR_NAT_FLAGS: u32 = 7; - -pub const NFTNL_EXPR_LOOKUP_SREG: u32 = 1; -pub const NFTNL_EXPR_LOOKUP_DREG: u32 = 2; -pub const NFTNL_EXPR_LOOKUP_SET: u32 = 3; -pub const NFTNL_EXPR_LOOKUP_SET_ID: u32 = 4; -pub const NFTNL_EXPR_LOOKUP_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_DYNSET_SREG_KEY: u32 = 1; -pub const NFTNL_EXPR_DYNSET_SREG_DATA: u32 = 2; -pub const NFTNL_EXPR_DYNSET_OP: u32 = 3; -pub const NFTNL_EXPR_DYNSET_TIMEOUT: u32 = 4; -pub const NFTNL_EXPR_DYNSET_SET_NAME: u32 = 5; -pub const NFTNL_EXPR_DYNSET_SET_ID: u32 = 6; -pub const NFTNL_EXPR_DYNSET_EXPR: u32 = 7; - -pub const NFTNL_EXPR_LOG_PREFIX: u32 = 1; -pub const NFTNL_EXPR_LOG_GROUP: u32 = 2; -pub const NFTNL_EXPR_LOG_SNAPLEN: u32 = 3; -pub const NFTNL_EXPR_LOG_QTHRESHOLD: u32 = 4; -pub const NFTNL_EXPR_LOG_LEVEL: u32 = 5; -pub const NFTNL_EXPR_LOG_FLAGS: u32 = 6; - -pub const NFTNL_EXPR_EXTHDR_DREG: u32 = 1; -pub const NFTNL_EXPR_EXTHDR_TYPE: u32 = 2; -pub const NFTNL_EXPR_EXTHDR_OFFSET: u32 = 3; -pub const NFTNL_EXPR_EXTHDR_LEN: u32 = 4; -pub const NFTNL_EXPR_EXTHDR_FLAGS: u32 = 5; -pub const NFTNL_EXPR_EXTHDR_OP: u32 = 6; -pub const NFTNL_EXPR_EXTHDR_SREG: u32 = 7; - -pub const NFTNL_EXPR_CT_DREG: u32 = 1; -pub const NFTNL_EXPR_CT_KEY: u32 = 2; -pub const NFTNL_EXPR_CT_DIR: u32 = 3; -pub const NFTNL_EXPR_CT_SREG: u32 = 4; - -pub const NFTNL_EXPR_BYTEORDER_DREG: u32 = 1; -pub const NFTNL_EXPR_BYTEORDER_SREG: u32 = 2; -pub const NFTNL_EXPR_BYTEORDER_OP: u32 = 3; -pub const NFTNL_EXPR_BYTEORDER_LEN: u32 = 4; -pub const NFTNL_EXPR_BYTEORDER_SIZE: u32 = 5; - -pub const NFTNL_EXPR_LIMIT_RATE: u32 = 1; -pub const NFTNL_EXPR_LIMIT_UNIT: u32 = 2; -pub const NFTNL_EXPR_LIMIT_BURST: u32 = 3; -pub const NFTNL_EXPR_LIMIT_TYPE: u32 = 4; -pub const NFTNL_EXPR_LIMIT_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_REJECT_TYPE: u32 = 1; -pub const NFTNL_EXPR_REJECT_CODE: u32 = 2; - -pub const NFTNL_EXPR_QUEUE_NUM: u32 = 1; -pub const NFTNL_EXPR_QUEUE_TOTAL: u32 = 2; -pub const NFTNL_EXPR_QUEUE_FLAGS: u32 = 3; -pub const NFTNL_EXPR_QUEUE_SREG_QNUM: u32 = 4; - -pub const NFTNL_EXPR_QUOTA_BYTES: u32 = 1; -pub const NFTNL_EXPR_QUOTA_FLAGS: u32 = 2; -pub const NFTNL_EXPR_QUOTA_CONSUMED: u32 = 3; - -pub const NFTNL_EXPR_MASQ_FLAGS: u32 = 1; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MIN: u32 = 2; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MAX: u32 = 3; - -pub const NFTNL_EXPR_REDIR_REG_PROTO_MIN: u32 = 1; -pub const NFTNL_EXPR_REDIR_REG_PROTO_MAX: u32 = 2; -pub const NFTNL_EXPR_REDIR_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_DUP_SREG_ADDR: u32 = 1; -pub const NFTNL_EXPR_DUP_SREG_DEV: u32 = 2; - -pub const NFTNL_EXPR_FWD_SREG_DEV: u32 = 1; - -pub const NFTNL_EXPR_HASH_SREG: u32 = 1; -pub const NFTNL_EXPR_HASH_DREG: u32 = 2; -pub const NFTNL_EXPR_HASH_LEN: u32 = 3; -pub const NFTNL_EXPR_HASH_MODULUS: u32 = 4; -pub const NFTNL_EXPR_HASH_SEED: u32 = 5; -pub const NFTNL_EXPR_HASH_OFFSET: u32 = 6; -pub const NFTNL_EXPR_HASH_TYPE: u32 = 7; - -pub const NFTNL_EXPR_FIB_DREG: u32 = 1; -pub const NFTNL_EXPR_FIB_RESULT: u32 = 2; -pub const NFTNL_EXPR_FIB_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_OBJREF_IMM_TYPE: u32 = 1; -pub const NFTNL_EXPR_OBJREF_IMM_NAME: u32 = 2; -pub const NFTNL_EXPR_OBJREF_SET_SREG: u32 = 3; -pub const NFTNL_EXPR_OBJREF_SET_NAME: u32 = 4; -pub const NFTNL_EXPR_OBJREF_SET_ID: u32 = 5; - -#[repr(C)] -pub struct nftnl_gen(c_void); - -extern "C" { - pub fn nftnl_gen_alloc() -> *mut nftnl_gen; - - pub fn nftnl_gen_free(arg1: *const nftnl_gen); -} -pub const NFTNL_GEN_ID: u32 = 0; -pub const __NFTNL_GEN_MAX: u32 = 1; - -extern "C" { - pub fn nftnl_gen_is_set(gen: *const nftnl_gen, attr: u16) -> bool; - - pub fn nftnl_gen_unset(gen: *mut nftnl_gen, attr: u16); - - pub fn nftnl_gen_set(gen: *mut nftnl_gen, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_gen_set_data( - gen: *mut nftnl_gen, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_gen_get(gen: *const nftnl_gen, attr: u16) -> *const c_void; - - pub fn nftnl_gen_get_data( - gen: *const nftnl_gen, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_gen_set_u32(gen: *mut nftnl_gen, attr: u16, data: u32); - - pub fn nftnl_gen_get_u32(gen: *const nftnl_gen, attr: u16) -> u32; - - pub fn nftnl_gen_nlmsg_parse(nlh: *const nlmsghdr, gen: *mut nftnl_gen) -> c_int; - - pub fn nftnl_gen_snprintf( - buf: *mut c_char, - size: usize, - gen: *const nftnl_gen, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_gen_fprintf(fp: *mut FILE, gen: *const nftnl_gen, type_: u32, flags: u32) - -> c_int; -} -pub const NFTNL_OBJ_TABLE: u32 = 0; -pub const NFTNL_OBJ_NAME: u32 = 1; -pub const NFTNL_OBJ_TYPE: u32 = 2; -pub const NFTNL_OBJ_FAMILY: u32 = 3; -pub const NFTNL_OBJ_USE: u32 = 4; -pub const NFTNL_OBJ_BASE: u32 = 16; -pub const __NFTNL_OBJ_MAX: u32 = 17; - -pub const NFTNL_OBJ_CTR_PKTS: u32 = 16; -pub const NFTNL_OBJ_CTR_BYTES: u32 = 17; - -pub const NFTNL_OBJ_QUOTA_BYTES: u32 = 16; -pub const NFTNL_OBJ_QUOTA_CONSUMED: u32 = 17; -pub const NFTNL_OBJ_QUOTA_FLAGS: u32 = 18; - -pub const NFTNL_OBJ_CT_HELPER_NAME: u32 = 16; -pub const NFTNL_OBJ_CT_HELPER_L3PROTO: u32 = 17; -pub const NFTNL_OBJ_CT_HELPER_L4PROTO: u32 = 18; - -pub const NFTNL_OBJ_LIMIT_RATE: u32 = 16; -pub const NFTNL_OBJ_LIMIT_UNIT: u32 = 17; -pub const NFTNL_OBJ_LIMIT_BURST: u32 = 18; -pub const NFTNL_OBJ_LIMIT_TYPE: u32 = 19; -pub const NFTNL_OBJ_LIMIT_FLAGS: u32 = 20; - -#[repr(C)] -pub struct nftnl_obj(c_void); - -extern "C" { - pub fn nftnl_obj_alloc() -> *mut nftnl_obj; - - pub fn nftnl_obj_free(ne: *const nftnl_obj); - - pub fn nftnl_obj_is_set(ne: *const nftnl_obj, attr: u16) -> bool; - - pub fn nftnl_obj_unset(ne: *mut nftnl_obj, attr: u16); - - pub fn nftnl_obj_set_data(ne: *mut nftnl_obj, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_obj_set(ne: *mut nftnl_obj, attr: u16, data: *const c_void); - - pub fn nftnl_obj_set_u8(ne: *mut nftnl_obj, attr: u16, val: u8); - - pub fn nftnl_obj_set_u16(ne: *mut nftnl_obj, attr: u16, val: u16); - - pub fn nftnl_obj_set_u32(ne: *mut nftnl_obj, attr: u16, val: u32); - - pub fn nftnl_obj_set_u64(obj: *mut nftnl_obj, attr: u16, val: u64); - - pub fn nftnl_obj_set_str(ne: *mut nftnl_obj, attr: u16, str: *const c_char); - - pub fn nftnl_obj_get_data(ne: *mut nftnl_obj, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_obj_get(ne: *mut nftnl_obj, attr: u16) -> *const c_void; - - pub fn nftnl_obj_get_u8(ne: *mut nftnl_obj, attr: u16) -> u8; - - pub fn nftnl_obj_get_u16(obj: *mut nftnl_obj, attr: u16) -> u16; - - pub fn nftnl_obj_get_u32(ne: *mut nftnl_obj, attr: u16) -> u32; - - pub fn nftnl_obj_get_u64(obj: *mut nftnl_obj, attr: u16) -> u64; - - pub fn nftnl_obj_get_str(ne: *mut nftnl_obj, attr: u16) -> *const c_char; - - pub fn nftnl_obj_nlmsg_build_payload(nlh: *mut nlmsghdr, ne: *const nftnl_obj); - - pub fn nftnl_obj_nlmsg_parse(nlh: *const nlmsghdr, ne: *mut nftnl_obj) -> c_int; - - pub fn nftnl_obj_parse( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_parse_file( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_snprintf( - buf: *mut c_char, - size: usize, - ne: *const nftnl_obj, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_obj_fprintf(fp: *mut FILE, ne: *const nftnl_obj, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list(c_void); - -extern "C" { - pub fn nftnl_obj_list_alloc() -> *mut nftnl_obj_list; - - pub fn nftnl_obj_list_free(list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_is_empty(list: *mut nftnl_obj_list) -> c_int; - - pub fn nftnl_obj_list_add(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_add_tail(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_del(t: *mut nftnl_obj); - - pub fn nftnl_obj_list_foreach( - table_list: *mut nftnl_obj_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_obj, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list_iter(c_void); - -extern "C" { - pub fn nftnl_obj_list_iter_create(l: *mut nftnl_obj_list) -> *mut nftnl_obj_list_iter; - - pub fn nftnl_obj_list_iter_next(iter: *mut nftnl_obj_list_iter) -> *mut nftnl_obj; - - pub fn nftnl_obj_list_iter_destroy(iter: *mut nftnl_obj_list_iter); -} -#[repr(C)] -pub struct nftnl_rule(c_void); - -extern "C" { - pub fn nftnl_rule_alloc() -> *mut nftnl_rule; - - pub fn nftnl_rule_free(arg1: *const nftnl_rule); -} -pub const NFTNL_RULE_FAMILY: nftnl_rule_attr = 0; -pub const NFTNL_RULE_TABLE: nftnl_rule_attr = 1; -pub const NFTNL_RULE_CHAIN: nftnl_rule_attr = 2; -pub const NFTNL_RULE_HANDLE: nftnl_rule_attr = 3; -pub const NFTNL_RULE_COMPAT_PROTO: nftnl_rule_attr = 4; -pub const NFTNL_RULE_COMPAT_FLAGS: nftnl_rule_attr = 5; -pub const NFTNL_RULE_POSITION: nftnl_rule_attr = 6; -pub const NFTNL_RULE_USERDATA: nftnl_rule_attr = 7; -pub const NFTNL_RULE_ID: nftnl_rule_attr = 8; -pub const __NFTNL_RULE_MAX: nftnl_rule_attr = 9; -pub type nftnl_rule_attr = u32; -extern "C" { - pub fn nftnl_rule_unset(r: *mut nftnl_rule, attr: u16); - - pub fn nftnl_rule_is_set(r: *const nftnl_rule, attr: u16) -> bool; - - pub fn nftnl_rule_set(r: *mut nftnl_rule, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_rule_set_data( - r: *mut nftnl_rule, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_rule_set_u32(r: *mut nftnl_rule, attr: u16, val: u32); - - pub fn nftnl_rule_set_u64(r: *mut nftnl_rule, attr: u16, val: u64); - - pub fn nftnl_rule_set_str(r: *mut nftnl_rule, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_rule_get(r: *const nftnl_rule, attr: u16) -> *const c_void; - - pub fn nftnl_rule_get_data( - r: *const nftnl_rule, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_rule_get_str(r: *const nftnl_rule, attr: u16) -> *const c_char; - - pub fn nftnl_rule_get_u8(r: *const nftnl_rule, attr: u16) -> u8; - - pub fn nftnl_rule_get_u32(r: *const nftnl_rule, attr: u16) -> u32; - - pub fn nftnl_rule_get_u64(r: *const nftnl_rule, attr: u16) -> u64; - - pub fn nftnl_rule_add_expr(r: *mut nftnl_rule, expr: *mut nftnl_expr); - - pub fn nftnl_rule_cmp(r1: *const nftnl_rule, r2: *const nftnl_rule) -> bool; - - pub fn nftnl_rule_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *mut nftnl_rule); - - pub fn nftnl_rule_parse( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_parse_file( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_rule, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_rule_fprintf(fp: *mut FILE, r: *const nftnl_rule, type_: u32, flags: u32) - -> c_int; - - pub fn nftnl_rule_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_rule) -> c_int; - - pub fn nftnl_expr_foreach( - r: *mut nftnl_rule, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_expr, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_expr_iter(c_void); - -extern "C" { - pub fn nftnl_expr_iter_create(r: *const nftnl_rule) -> *mut nftnl_expr_iter; - - pub fn nftnl_expr_iter_next(iter: *mut nftnl_expr_iter) -> *mut nftnl_expr; - - pub fn nftnl_expr_iter_destroy(iter: *mut nftnl_expr_iter); -} -#[repr(C)] -pub struct nftnl_rule_list(c_void); - -extern "C" { - pub fn nftnl_rule_list_alloc() -> *mut nftnl_rule_list; - - pub fn nftnl_rule_list_free(list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_is_empty(list: *const nftnl_rule_list) -> c_int; - - pub fn nftnl_rule_list_add(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_add_tail(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_del(r: *mut nftnl_rule); - - pub fn nftnl_rule_list_foreach( - rule_list: *mut nftnl_rule_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_rule, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_rule_list_iter(c_void); - -extern "C" { - pub fn nftnl_rule_list_iter_create(l: *const nftnl_rule_list) -> *mut nftnl_rule_list_iter; - - pub fn nftnl_rule_list_iter_cur(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_next(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_destroy(iter: *const nftnl_rule_list_iter); -} -#[repr(C)] -pub struct nftnl_ruleset(c_void); - -extern "C" { - pub fn nftnl_ruleset_alloc() -> *mut nftnl_ruleset; - - pub fn nftnl_ruleset_free(r: *const nftnl_ruleset); -} -pub const NFTNL_RULESET_TABLELIST: u32 = 0; -pub const NFTNL_RULESET_CHAINLIST: u32 = 1; -pub const NFTNL_RULESET_SETLIST: u32 = 2; -pub const NFTNL_RULESET_RULELIST: u32 = 3; - -pub const NFTNL_RULESET_UNSPEC: nftnl_ruleset_type = 0; -pub const NFTNL_RULESET_RULESET: nftnl_ruleset_type = 1; -pub const NFTNL_RULESET_TABLE: nftnl_ruleset_type = 2; -pub const NFTNL_RULESET_CHAIN: nftnl_ruleset_type = 3; -pub const NFTNL_RULESET_RULE: nftnl_ruleset_type = 4; -pub const NFTNL_RULESET_SET: nftnl_ruleset_type = 5; -pub const NFTNL_RULESET_SET_ELEMS: nftnl_ruleset_type = 6; -pub type nftnl_ruleset_type = u32; -extern "C" { - pub fn nftnl_ruleset_is_set(r: *const nftnl_ruleset, attr: u16) -> bool; - - pub fn nftnl_ruleset_unset(r: *mut nftnl_ruleset, attr: u16); - - pub fn nftnl_ruleset_set(r: *mut nftnl_ruleset, attr: u16, data: *mut c_void); - - pub fn nftnl_ruleset_get(r: *const nftnl_ruleset, attr: u16) -> *mut c_void; -} -pub const NFTNL_RULESET_CTX_CMD: u32 = 0; -pub const NFTNL_RULESET_CTX_TYPE: u32 = 1; -pub const NFTNL_RULESET_CTX_TABLE: u32 = 2; -pub const NFTNL_RULESET_CTX_CHAIN: u32 = 3; -pub const NFTNL_RULESET_CTX_RULE: u32 = 4; -pub const NFTNL_RULESET_CTX_SET: u32 = 5; -pub const NFTNL_RULESET_CTX_DATA: u32 = 6; - -#[repr(C)] -pub struct nftnl_parse_ctx(c_void); - -extern "C" { - pub fn nftnl_ruleset_ctx_free(ctx: *const nftnl_parse_ctx); - - pub fn nftnl_ruleset_ctx_is_set(ctx: *const nftnl_parse_ctx, attr: u16) -> bool; - - pub fn nftnl_ruleset_ctx_get(ctx: *const nftnl_parse_ctx, attr: u16) -> *mut c_void; - - pub fn nftnl_ruleset_ctx_get_u32(ctx: *const nftnl_parse_ctx, attr: u16) -> u32; - - pub fn nftnl_ruleset_parse_file_cb( - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse_buffer_cb( - type_: nftnl_parse_type, - buffer: *const c_char, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_parse_file( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_snprintf( - buf: *mut c_char, - size: usize, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_ruleset_fprintf( - fp: *mut FILE, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_SET_TABLE: nftnl_set_attr = 0; -pub const NFTNL_SET_NAME: nftnl_set_attr = 1; -pub const NFTNL_SET_FLAGS: nftnl_set_attr = 2; -pub const NFTNL_SET_KEY_TYPE: nftnl_set_attr = 3; -pub const NFTNL_SET_KEY_LEN: nftnl_set_attr = 4; -pub const NFTNL_SET_DATA_TYPE: nftnl_set_attr = 5; -pub const NFTNL_SET_DATA_LEN: nftnl_set_attr = 6; -pub const NFTNL_SET_FAMILY: nftnl_set_attr = 7; -pub const NFTNL_SET_ID: nftnl_set_attr = 8; -pub const NFTNL_SET_POLICY: nftnl_set_attr = 9; -pub const NFTNL_SET_DESC_SIZE: nftnl_set_attr = 10; -pub const NFTNL_SET_TIMEOUT: nftnl_set_attr = 11; -pub const NFTNL_SET_GC_INTERVAL: nftnl_set_attr = 12; -pub const NFTNL_SET_USERDATA: nftnl_set_attr = 13; -pub const NFTNL_SET_OBJ_TYPE: nftnl_set_attr = 14; -pub const __NFTNL_SET_MAX: nftnl_set_attr = 15; -pub type nftnl_set_attr = u32; -#[repr(C)] -pub struct nftnl_set(c_void); - -extern "C" { - pub fn nftnl_set_alloc() -> *mut nftnl_set; - - pub fn nftnl_set_free(s: *const nftnl_set); - - pub fn nftnl_set_clone(set: *const nftnl_set) -> *mut nftnl_set; - - pub fn nftnl_set_is_set(s: *const nftnl_set, attr: u16) -> bool; - - pub fn nftnl_set_unset(s: *mut nftnl_set, attr: u16); - - pub fn nftnl_set_set(s: *mut nftnl_set, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_set_set_data( - s: *mut nftnl_set, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_set_u32(s: *mut nftnl_set, attr: u16, val: u32); - - pub fn nftnl_set_set_u64(s: *mut nftnl_set, attr: u16, val: u64); - - pub fn nftnl_set_set_str(s: *mut nftnl_set, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_get(s: *const nftnl_set, attr: u16) -> *const c_void; - - pub fn nftnl_set_get_data(s: *const nftnl_set, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_set_get_str(s: *const nftnl_set, attr: u16) -> *const c_char; - - pub fn nftnl_set_get_u32(s: *const nftnl_set, attr: u16) -> u32; - - pub fn nftnl_set_get_u64(s: *const nftnl_set, attr: u16) -> u64; - - pub fn nftnl_set_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_elems_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_fprintf(fp: *mut FILE, s: *const nftnl_set, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list(c_void); - -extern "C" { - pub fn nftnl_set_list_alloc() -> *mut nftnl_set_list; - - pub fn nftnl_set_list_free(list: *mut nftnl_set_list); - - pub fn nftnl_set_list_is_empty(list: *const nftnl_set_list) -> c_int; - - pub fn nftnl_set_list_add(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_add_tail(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_del(s: *mut nftnl_set); - - pub fn nftnl_set_list_foreach( - set_list: *mut nftnl_set_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_set, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list_iter(c_void); - -extern "C" { - pub fn nftnl_set_list_iter_create(l: *const nftnl_set_list) -> *mut nftnl_set_list_iter; - - pub fn nftnl_set_list_iter_cur(iter: *const nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_next(iter: *mut nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_destroy(iter: *const nftnl_set_list_iter); - - pub fn nftnl_set_parse( - s: *mut nftnl_set, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_parse_file( - s: *mut nftnl_set, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; -} -pub const NFTNL_SET_ELEM_FLAGS: u32 = 0; -pub const NFTNL_SET_ELEM_KEY: u32 = 1; -pub const NFTNL_SET_ELEM_VERDICT: u32 = 2; -pub const NFTNL_SET_ELEM_CHAIN: u32 = 3; -pub const NFTNL_SET_ELEM_DATA: u32 = 4; -pub const NFTNL_SET_ELEM_TIMEOUT: u32 = 5; -pub const NFTNL_SET_ELEM_EXPIRATION: u32 = 6; -pub const NFTNL_SET_ELEM_USERDATA: u32 = 7; -pub const NFTNL_SET_ELEM_EXPR: u32 = 8; -pub const NFTNL_SET_ELEM_OBJREF: u32 = 9; - -#[repr(C)] -pub struct nftnl_set_elem(c_void); - -extern "C" { - pub fn nftnl_set_elem_alloc() -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_free(s: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_clone(elem: *mut nftnl_set_elem) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_add(s: *mut nftnl_set, elem: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_unset(s: *mut nftnl_set_elem, attr: u16); - - pub fn nftnl_set_elem_set( - s: *mut nftnl_set_elem, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_elem_set_u32(s: *mut nftnl_set_elem, attr: u16, val: u32); - - pub fn nftnl_set_elem_set_u64(s: *mut nftnl_set_elem, attr: u16, val: u64); - - pub fn nftnl_set_elem_set_str(s: *mut nftnl_set_elem, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_elem_get( - s: *mut nftnl_set_elem, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_set_elem_get_str(s: *mut nftnl_set_elem, attr: u16) -> *const c_char; - - pub fn nftnl_set_elem_get_u32(s: *mut nftnl_set_elem, attr: u16) -> u32; - - pub fn nftnl_set_elem_get_u64(s: *mut nftnl_set_elem, attr: u16) -> u64; - - pub fn nftnl_set_elem_is_set(s: *const nftnl_set_elem, attr: u16) -> bool; - - pub fn nftnl_set_elems_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_elem_nlmsg_build_payload(nlh: *mut nlmsghdr, e: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_parse( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_parse_file( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_fprintf( - fp: *mut FILE, - se: *mut nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_foreach( - s: *mut nftnl_set, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_set_elem, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_elems_iter(c_void); - -extern "C" { - pub fn nftnl_set_elems_iter_create(s: *const nftnl_set) -> *mut nftnl_set_elems_iter; - - pub fn nftnl_set_elems_iter_cur(iter: *const nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_next(iter: *mut nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_destroy(iter: *mut nftnl_set_elems_iter); - - pub fn nftnl_set_elems_nlmsg_build_payload_iter( - nlh: *mut nlmsghdr, - iter: *mut nftnl_set_elems_iter, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_table(c_void); - -extern "C" { - pub fn nftnl_table_alloc() -> *mut nftnl_table; - - pub fn nftnl_table_free(arg1: *const nftnl_table); -} -pub const NFTNL_TABLE_NAME: nftnl_table_attr = 0; -pub const NFTNL_TABLE_FAMILY: nftnl_table_attr = 1; -pub const NFTNL_TABLE_FLAGS: nftnl_table_attr = 2; -pub const NFTNL_TABLE_USE: nftnl_table_attr = 3; -pub const __NFTNL_TABLE_MAX: nftnl_table_attr = 4; -pub type nftnl_table_attr = u32; -extern "C" { - pub fn nftnl_table_is_set(t: *const nftnl_table, attr: u16) -> bool; - - pub fn nftnl_table_unset(t: *mut nftnl_table, attr: u16); - - pub fn nftnl_table_set(t: *mut nftnl_table, attr: u16, data: *const c_void); - - pub fn nftnl_table_set_data( - t: *mut nftnl_table, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_table_get(t: *const nftnl_table, attr: u16) -> *const c_void; - - pub fn nftnl_table_get_data( - t: *const nftnl_table, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_table_set_u8(t: *mut nftnl_table, attr: u16, data: u8); - - pub fn nftnl_table_set_u32(t: *mut nftnl_table, attr: u16, data: u32); - - pub fn nftnl_table_set_str(t: *mut nftnl_table, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_table_get_u8(t: *const nftnl_table, attr: u16) -> u8; - - pub fn nftnl_table_get_u32(t: *const nftnl_table, attr: u16) -> u32; - - pub fn nftnl_table_get_str(t: *const nftnl_table, attr: u16) -> *const c_char; - - pub fn nftnl_table_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_table); - - pub fn nftnl_table_parse( - t: *mut nftnl_table, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_parse_file( - t: *mut nftnl_table, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_fprintf( - fp: *mut FILE, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_table) -> c_int; -} -#[repr(C)] -pub struct nftnl_table_list(c_void); - -extern "C" { - pub fn nftnl_table_list_alloc() -> *mut nftnl_table_list; - - pub fn nftnl_table_list_free(list: *mut nftnl_table_list); - - pub fn nftnl_table_list_is_empty(list: *const nftnl_table_list) -> c_int; - - pub fn nftnl_table_list_foreach( - table_list: *mut nftnl_table_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_table, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_table_list_add(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_add_tail(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_del(r: *mut nftnl_table); -} -#[repr(C)] -pub struct nftnl_table_list_iter(c_void); - -extern "C" { - pub fn nftnl_table_list_iter_create(l: *const nftnl_table_list) -> *mut nftnl_table_list_iter; - - pub fn nftnl_table_list_iter_next(iter: *mut nftnl_table_list_iter) -> *mut nftnl_table; - - pub fn nftnl_table_list_iter_destroy(iter: *const nftnl_table_list_iter); -} -pub const NFTNL_TRACE_CHAIN: nftnl_trace_attr = 0; -pub const NFTNL_TRACE_FAMILY: nftnl_trace_attr = 1; -pub const NFTNL_TRACE_ID: nftnl_trace_attr = 2; -pub const NFTNL_TRACE_IIF: nftnl_trace_attr = 3; -pub const NFTNL_TRACE_IIFTYPE: nftnl_trace_attr = 4; -pub const NFTNL_TRACE_JUMP_TARGET: nftnl_trace_attr = 5; -pub const NFTNL_TRACE_OIF: nftnl_trace_attr = 6; -pub const NFTNL_TRACE_OIFTYPE: nftnl_trace_attr = 7; -pub const NFTNL_TRACE_MARK: nftnl_trace_attr = 8; -pub const NFTNL_TRACE_LL_HEADER: nftnl_trace_attr = 9; -pub const NFTNL_TRACE_NETWORK_HEADER: nftnl_trace_attr = 10; -pub const NFTNL_TRACE_TRANSPORT_HEADER: nftnl_trace_attr = 11; -pub const NFTNL_TRACE_TABLE: nftnl_trace_attr = 12; -pub const NFTNL_TRACE_TYPE: nftnl_trace_attr = 13; -pub const NFTNL_TRACE_RULE_HANDLE: nftnl_trace_attr = 14; -pub const NFTNL_TRACE_VERDICT: nftnl_trace_attr = 15; -pub const NFTNL_TRACE_NFPROTO: nftnl_trace_attr = 16; -pub const NFTNL_TRACE_POLICY: nftnl_trace_attr = 17; -pub const __NFTNL_TRACE_MAX: nftnl_trace_attr = 18; -pub type nftnl_trace_attr = u32; -#[repr(C)] -pub struct nftnl_trace(c_void); - -extern "C" { - pub fn nftnl_trace_alloc() -> *mut nftnl_trace; - - pub fn nftnl_trace_free(trace: *const nftnl_trace); - - pub fn nftnl_trace_is_set(trace: *const nftnl_trace, type_: u16) -> bool; - - pub fn nftnl_trace_get_data( - trace: *const nftnl_trace, - type_: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_trace_get_u16(trace: *const nftnl_trace, type_: u16) -> u16; - - pub fn nftnl_trace_get_u32(trace: *const nftnl_trace, type_: u16) -> u32; - - pub fn nftnl_trace_get_u64(trace: *const nftnl_trace, type_: u16) -> u64; - - pub fn nftnl_trace_get_str(trace: *const nftnl_trace, type_: u16) -> *const c_char; - - pub fn nftnl_trace_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_trace) -> c_int; -} -#[repr(C)] -pub struct nftnl_udata(c_void); - -#[repr(C)] -pub struct nftnl_udata_buf(c_void); - -extern "C" { - pub fn nftnl_udata_buf_alloc(data_size: u32) -> *mut nftnl_udata_buf; - - pub fn nftnl_udata_buf_free(buf: *const nftnl_udata_buf); - - pub fn nftnl_udata_buf_len(buf: *const nftnl_udata_buf) -> u32; - - pub fn nftnl_udata_buf_data(buf: *const nftnl_udata_buf) -> *mut c_void; - - pub fn nftnl_udata_buf_put(buf: *mut nftnl_udata_buf, data: *const c_void, len: u32); - - pub fn nftnl_udata_start(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_end(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_put( - buf: *mut nftnl_udata_buf, - type_: u8, - len: u32, - value: *const c_void, - ) -> bool; - - pub fn nftnl_udata_put_u32(buf: *mut nftnl_udata_buf, type_: u8, data: u32) -> bool; - - pub fn nftnl_udata_put_strz(buf: *mut nftnl_udata_buf, type_: u8, strz: *const c_char) -> bool; - - pub fn nftnl_udata_type(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_len(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_get(attr: *const nftnl_udata) -> *mut c_void; - - pub fn nftnl_udata_get_u32(attr: *const nftnl_udata) -> u32; - - pub fn nftnl_udata_next(attr: *const nftnl_udata) -> *mut nftnl_udata; -} -pub type nftnl_udata_cb_t = - Option<unsafe extern "C" fn(attr: *const nftnl_udata, data: *mut c_void) -> c_int>; -extern "C" { - pub fn nftnl_udata_parse( - data: *const c_void, - data_len: u32, - cb: nftnl_udata_cb_t, - cb_data: *mut c_void, - ) -> c_int; -} diff --git a/rustables-sys/src/nftnl_1_1_0.rs b/rustables-sys/src/nftnl_1_1_0.rs deleted file mode 100644 index 62be614..0000000 --- a/rustables-sys/src/nftnl_1_1_0.rs +++ /dev/null @@ -1,1267 +0,0 @@ -// automatically generated by rust-bindgen 0.39.0 - -use core::option::Option; -use libc::{c_char, c_int, c_void, iovec, nlmsghdr, FILE}; - -#[repr(C)] -pub struct nftnl_batch(c_void); - -extern "C" { - pub fn nftnl_batch_alloc(pg_size: u32, pg_overrun_size: u32) -> *mut nftnl_batch; - - pub fn nftnl_batch_update(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_free(batch: *mut nftnl_batch); - - pub fn nftnl_batch_buffer(batch: *mut nftnl_batch) -> *mut c_void; - - pub fn nftnl_batch_buffer_len(batch: *mut nftnl_batch) -> u32; - - pub fn nftnl_batch_iovec_len(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_iovec(batch: *mut nftnl_batch, iov: *mut iovec, iovlen: u32); -} -pub const NFTNL_PARSE_EBADINPUT: u32 = 0; -pub const NFTNL_PARSE_EMISSINGNODE: u32 = 1; -pub const NFTNL_PARSE_EBADTYPE: u32 = 2; -pub const NFTNL_PARSE_EOPNOTSUPP: u32 = 3; - -pub const NFTNL_OUTPUT_DEFAULT: nftnl_output_type = 0; -pub const NFTNL_OUTPUT_XML: nftnl_output_type = 1; -pub const NFTNL_OUTPUT_JSON: nftnl_output_type = 2; -pub type nftnl_output_type = u32; -pub const NFTNL_OF_EVENT_NEW: nftnl_output_flags = 1; -pub const NFTNL_OF_EVENT_DEL: nftnl_output_flags = 2; -pub const NFTNL_OF_EVENT_ANY: nftnl_output_flags = 3; -pub type nftnl_output_flags = u32; -pub const NFTNL_CMD_UNSPEC: nftnl_cmd_type = 0; -pub const NFTNL_CMD_ADD: nftnl_cmd_type = 1; -pub const NFTNL_CMD_INSERT: nftnl_cmd_type = 2; -pub const NFTNL_CMD_DELETE: nftnl_cmd_type = 3; -pub const NFTNL_CMD_REPLACE: nftnl_cmd_type = 4; -pub const NFTNL_CMD_FLUSH: nftnl_cmd_type = 5; -pub const NFTNL_CMD_MAX: nftnl_cmd_type = 6; -pub type nftnl_cmd_type = u32; -pub const NFTNL_PARSE_NONE: nftnl_parse_type = 0; -pub const NFTNL_PARSE_XML: nftnl_parse_type = 1; -pub const NFTNL_PARSE_JSON: nftnl_parse_type = 2; -pub const NFTNL_PARSE_MAX: nftnl_parse_type = 3; -pub type nftnl_parse_type = u32; -#[repr(C)] -pub struct nftnl_parse_err(c_void); - -extern "C" { - pub fn nftnl_nlmsg_build_hdr( - buf: *mut c_char, - type_: u16, - family: u16, - flags: u16, - seq: u32, - ) -> *mut nlmsghdr; - - pub fn nftnl_parse_err_alloc() -> *mut nftnl_parse_err; - - pub fn nftnl_parse_err_free(arg1: *mut nftnl_parse_err); - - pub fn nftnl_parse_perror(str: *const c_char, err: *mut nftnl_parse_err) -> c_int; - - pub fn nftnl_batch_is_supported() -> c_int; - - pub fn nftnl_batch_begin(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; - - pub fn nftnl_batch_end(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; -} -#[repr(C)] -pub struct nftnl_chain(c_void); - -extern "C" { - pub fn nftnl_chain_alloc() -> *mut nftnl_chain; - - pub fn nftnl_chain_free(arg1: *const nftnl_chain); -} -pub const NFTNL_CHAIN_NAME: nftnl_chain_attr = 0; -pub const NFTNL_CHAIN_FAMILY: nftnl_chain_attr = 1; -pub const NFTNL_CHAIN_TABLE: nftnl_chain_attr = 2; -pub const NFTNL_CHAIN_HOOKNUM: nftnl_chain_attr = 3; -pub const NFTNL_CHAIN_PRIO: nftnl_chain_attr = 4; -pub const NFTNL_CHAIN_POLICY: nftnl_chain_attr = 5; -pub const NFTNL_CHAIN_USE: nftnl_chain_attr = 6; -pub const NFTNL_CHAIN_BYTES: nftnl_chain_attr = 7; -pub const NFTNL_CHAIN_PACKETS: nftnl_chain_attr = 8; -pub const NFTNL_CHAIN_HANDLE: nftnl_chain_attr = 9; -pub const NFTNL_CHAIN_TYPE: nftnl_chain_attr = 10; -pub const NFTNL_CHAIN_DEV: nftnl_chain_attr = 11; -pub const __NFTNL_CHAIN_MAX: nftnl_chain_attr = 12; -pub type nftnl_chain_attr = u32; -extern "C" { - pub fn nftnl_chain_is_set(c: *const nftnl_chain, attr: u16) -> bool; - - pub fn nftnl_chain_unset(c: *mut nftnl_chain, attr: u16); - - pub fn nftnl_chain_set(t: *mut nftnl_chain, attr: u16, data: *const c_void); - - pub fn nftnl_chain_set_data( - t: *mut nftnl_chain, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_chain_set_u8(t: *mut nftnl_chain, attr: u16, data: u8); - - pub fn nftnl_chain_set_u32(t: *mut nftnl_chain, attr: u16, data: u32); - - pub fn nftnl_chain_set_s32(t: *mut nftnl_chain, attr: u16, data: i32); - - pub fn nftnl_chain_set_u64(t: *mut nftnl_chain, attr: u16, data: u64); - - pub fn nftnl_chain_set_str(t: *mut nftnl_chain, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_chain_get(c: *const nftnl_chain, attr: u16) -> *const c_void; - - pub fn nftnl_chain_get_data( - c: *const nftnl_chain, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_chain_get_str(c: *const nftnl_chain, attr: u16) -> *const c_char; - - pub fn nftnl_chain_get_u8(c: *const nftnl_chain, attr: u16) -> u8; - - pub fn nftnl_chain_get_u32(c: *const nftnl_chain, attr: u16) -> u32; - - pub fn nftnl_chain_get_s32(c: *const nftnl_chain, attr: u16) -> i32; - - pub fn nftnl_chain_get_u64(c: *const nftnl_chain, attr: u16) -> u64; - - pub fn nftnl_chain_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_chain); - - pub fn nftnl_chain_parse( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_parse_file( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_fprintf( - fp: *mut FILE, - c: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_chain) -> c_int; -} -#[repr(C)] -pub struct nftnl_chain_list(c_void); - -extern "C" { - pub fn nftnl_chain_list_alloc() -> *mut nftnl_chain_list; - - pub fn nftnl_chain_list_free(list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_is_empty(list: *const nftnl_chain_list) -> c_int; - - pub fn nftnl_chain_list_foreach( - chain_list: *mut nftnl_chain_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_chain, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_chain_list_add(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_add_tail(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_del(c: *mut nftnl_chain); -} -#[repr(C)] -pub struct nftnl_chain_list_iter(c_void); - -extern "C" { - pub fn nftnl_chain_list_iter_create(l: *const nftnl_chain_list) -> *mut nftnl_chain_list_iter; - - pub fn nftnl_chain_list_iter_next(iter: *mut nftnl_chain_list_iter) -> *mut nftnl_chain; - - pub fn nftnl_chain_list_iter_destroy(iter: *mut nftnl_chain_list_iter); -} -#[repr(C)] -pub struct nftnl_expr(c_void); - -pub const NFTNL_EXPR_NAME: u32 = 0; -pub const NFTNL_EXPR_BASE: u32 = 1; - -extern "C" { - pub fn nftnl_expr_alloc(name: *const c_char) -> *mut nftnl_expr; - - pub fn nftnl_expr_free(expr: *const nftnl_expr); - - pub fn nftnl_expr_is_set(expr: *const nftnl_expr, type_: u16) -> bool; - - pub fn nftnl_expr_set( - expr: *mut nftnl_expr, - type_: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_expr_set_u8(expr: *mut nftnl_expr, type_: u16, data: u8); - - pub fn nftnl_expr_set_u16(expr: *mut nftnl_expr, type_: u16, data: u16); - - pub fn nftnl_expr_set_u32(expr: *mut nftnl_expr, type_: u16, data: u32); - - pub fn nftnl_expr_set_u64(expr: *mut nftnl_expr, type_: u16, data: u64); - - pub fn nftnl_expr_set_str(expr: *mut nftnl_expr, type_: u16, str: *const c_char) -> c_int; - - pub fn nftnl_expr_get(expr: *const nftnl_expr, type_: u16, data_len: *mut u32) - -> *const c_void; - - pub fn nftnl_expr_get_u8(expr: *const nftnl_expr, type_: u16) -> u8; - - pub fn nftnl_expr_get_u16(expr: *const nftnl_expr, type_: u16) -> u16; - - pub fn nftnl_expr_get_u32(expr: *const nftnl_expr, type_: u16) -> u32; - - pub fn nftnl_expr_get_u64(expr: *const nftnl_expr, type_: u16) -> u64; - - pub fn nftnl_expr_get_str(expr: *const nftnl_expr, type_: u16) -> *const c_char; - - pub fn nftnl_expr_cmp(e1: *const nftnl_expr, e2: *const nftnl_expr) -> bool; - - pub fn nftnl_expr_snprintf( - buf: *mut c_char, - buflen: usize, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_expr_fprintf( - fp: *mut FILE, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_EXPR_PAYLOAD_DREG: u32 = 1; -pub const NFTNL_EXPR_PAYLOAD_BASE: u32 = 2; -pub const NFTNL_EXPR_PAYLOAD_OFFSET: u32 = 3; -pub const NFTNL_EXPR_PAYLOAD_LEN: u32 = 4; -pub const NFTNL_EXPR_PAYLOAD_SREG: u32 = 5; -pub const NFTNL_EXPR_PAYLOAD_CSUM_TYPE: u32 = 6; -pub const NFTNL_EXPR_PAYLOAD_CSUM_OFFSET: u32 = 7; -pub const NFTNL_EXPR_PAYLOAD_FLAGS: u32 = 8; - -pub const NFTNL_EXPR_NG_DREG: u32 = 1; -pub const NFTNL_EXPR_NG_MODULUS: u32 = 2; -pub const NFTNL_EXPR_NG_TYPE: u32 = 3; -pub const NFTNL_EXPR_NG_OFFSET: u32 = 4; - -pub const NFTNL_EXPR_META_KEY: u32 = 1; -pub const NFTNL_EXPR_META_DREG: u32 = 2; -pub const NFTNL_EXPR_META_SREG: u32 = 3; - -pub const NFTNL_EXPR_RT_KEY: u32 = 1; -pub const NFTNL_EXPR_RT_DREG: u32 = 2; - -pub const NFTNL_EXPR_CMP_SREG: u32 = 1; -pub const NFTNL_EXPR_CMP_OP: u32 = 2; -pub const NFTNL_EXPR_CMP_DATA: u32 = 3; - -pub const NFTNL_EXPR_RANGE_SREG: u32 = 1; -pub const NFTNL_EXPR_RANGE_OP: u32 = 2; -pub const NFTNL_EXPR_RANGE_FROM_DATA: u32 = 3; -pub const NFTNL_EXPR_RANGE_TO_DATA: u32 = 4; - -pub const NFTNL_EXPR_IMM_DREG: u32 = 1; -pub const NFTNL_EXPR_IMM_DATA: u32 = 2; -pub const NFTNL_EXPR_IMM_VERDICT: u32 = 3; -pub const NFTNL_EXPR_IMM_CHAIN: u32 = 4; - -pub const NFTNL_EXPR_CTR_PACKETS: u32 = 1; -pub const NFTNL_EXPR_CTR_BYTES: u32 = 2; - -pub const NFTNL_EXPR_BITWISE_SREG: u32 = 1; -pub const NFTNL_EXPR_BITWISE_DREG: u32 = 2; -pub const NFTNL_EXPR_BITWISE_LEN: u32 = 3; -pub const NFTNL_EXPR_BITWISE_MASK: u32 = 4; -pub const NFTNL_EXPR_BITWISE_XOR: u32 = 5; - -pub const NFTNL_EXPR_TG_NAME: u32 = 1; -pub const NFTNL_EXPR_TG_REV: u32 = 2; -pub const NFTNL_EXPR_TG_INFO: u32 = 3; - -pub const NFTNL_EXPR_MT_NAME: u32 = 1; -pub const NFTNL_EXPR_MT_REV: u32 = 2; -pub const NFTNL_EXPR_MT_INFO: u32 = 3; - -pub const NFTNL_EXPR_NAT_TYPE: u32 = 1; -pub const NFTNL_EXPR_NAT_FAMILY: u32 = 2; -pub const NFTNL_EXPR_NAT_REG_ADDR_MIN: u32 = 3; -pub const NFTNL_EXPR_NAT_REG_ADDR_MAX: u32 = 4; -pub const NFTNL_EXPR_NAT_REG_PROTO_MIN: u32 = 5; -pub const NFTNL_EXPR_NAT_REG_PROTO_MAX: u32 = 6; -pub const NFTNL_EXPR_NAT_FLAGS: u32 = 7; - -pub const NFTNL_EXPR_LOOKUP_SREG: u32 = 1; -pub const NFTNL_EXPR_LOOKUP_DREG: u32 = 2; -pub const NFTNL_EXPR_LOOKUP_SET: u32 = 3; -pub const NFTNL_EXPR_LOOKUP_SET_ID: u32 = 4; -pub const NFTNL_EXPR_LOOKUP_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_DYNSET_SREG_KEY: u32 = 1; -pub const NFTNL_EXPR_DYNSET_SREG_DATA: u32 = 2; -pub const NFTNL_EXPR_DYNSET_OP: u32 = 3; -pub const NFTNL_EXPR_DYNSET_TIMEOUT: u32 = 4; -pub const NFTNL_EXPR_DYNSET_SET_NAME: u32 = 5; -pub const NFTNL_EXPR_DYNSET_SET_ID: u32 = 6; -pub const NFTNL_EXPR_DYNSET_EXPR: u32 = 7; - -pub const NFTNL_EXPR_LOG_PREFIX: u32 = 1; -pub const NFTNL_EXPR_LOG_GROUP: u32 = 2; -pub const NFTNL_EXPR_LOG_SNAPLEN: u32 = 3; -pub const NFTNL_EXPR_LOG_QTHRESHOLD: u32 = 4; -pub const NFTNL_EXPR_LOG_LEVEL: u32 = 5; -pub const NFTNL_EXPR_LOG_FLAGS: u32 = 6; - -pub const NFTNL_EXPR_EXTHDR_DREG: u32 = 1; -pub const NFTNL_EXPR_EXTHDR_TYPE: u32 = 2; -pub const NFTNL_EXPR_EXTHDR_OFFSET: u32 = 3; -pub const NFTNL_EXPR_EXTHDR_LEN: u32 = 4; -pub const NFTNL_EXPR_EXTHDR_FLAGS: u32 = 5; -pub const NFTNL_EXPR_EXTHDR_OP: u32 = 6; -pub const NFTNL_EXPR_EXTHDR_SREG: u32 = 7; - -pub const NFTNL_EXPR_CT_DREG: u32 = 1; -pub const NFTNL_EXPR_CT_KEY: u32 = 2; -pub const NFTNL_EXPR_CT_DIR: u32 = 3; -pub const NFTNL_EXPR_CT_SREG: u32 = 4; - -pub const NFTNL_EXPR_BYTEORDER_DREG: u32 = 1; -pub const NFTNL_EXPR_BYTEORDER_SREG: u32 = 2; -pub const NFTNL_EXPR_BYTEORDER_OP: u32 = 3; -pub const NFTNL_EXPR_BYTEORDER_LEN: u32 = 4; -pub const NFTNL_EXPR_BYTEORDER_SIZE: u32 = 5; - -pub const NFTNL_EXPR_LIMIT_RATE: u32 = 1; -pub const NFTNL_EXPR_LIMIT_UNIT: u32 = 2; -pub const NFTNL_EXPR_LIMIT_BURST: u32 = 3; -pub const NFTNL_EXPR_LIMIT_TYPE: u32 = 4; -pub const NFTNL_EXPR_LIMIT_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_REJECT_TYPE: u32 = 1; -pub const NFTNL_EXPR_REJECT_CODE: u32 = 2; - -pub const NFTNL_EXPR_QUEUE_NUM: u32 = 1; -pub const NFTNL_EXPR_QUEUE_TOTAL: u32 = 2; -pub const NFTNL_EXPR_QUEUE_FLAGS: u32 = 3; -pub const NFTNL_EXPR_QUEUE_SREG_QNUM: u32 = 4; - -pub const NFTNL_EXPR_QUOTA_BYTES: u32 = 1; -pub const NFTNL_EXPR_QUOTA_FLAGS: u32 = 2; -pub const NFTNL_EXPR_QUOTA_CONSUMED: u32 = 3; - -pub const NFTNL_EXPR_MASQ_FLAGS: u32 = 1; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MIN: u32 = 2; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MAX: u32 = 3; - -pub const NFTNL_EXPR_REDIR_REG_PROTO_MIN: u32 = 1; -pub const NFTNL_EXPR_REDIR_REG_PROTO_MAX: u32 = 2; -pub const NFTNL_EXPR_REDIR_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_DUP_SREG_ADDR: u32 = 1; -pub const NFTNL_EXPR_DUP_SREG_DEV: u32 = 2; - -pub const NFTNL_EXPR_FLOW_TABLE_NAME: u32 = 1; - -pub const NFTNL_EXPR_FWD_SREG_DEV: u32 = 1; - -pub const NFTNL_EXPR_HASH_SREG: u32 = 1; -pub const NFTNL_EXPR_HASH_DREG: u32 = 2; -pub const NFTNL_EXPR_HASH_LEN: u32 = 3; -pub const NFTNL_EXPR_HASH_MODULUS: u32 = 4; -pub const NFTNL_EXPR_HASH_SEED: u32 = 5; -pub const NFTNL_EXPR_HASH_OFFSET: u32 = 6; -pub const NFTNL_EXPR_HASH_TYPE: u32 = 7; - -pub const NFTNL_EXPR_FIB_DREG: u32 = 1; -pub const NFTNL_EXPR_FIB_RESULT: u32 = 2; -pub const NFTNL_EXPR_FIB_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_OBJREF_IMM_TYPE: u32 = 1; -pub const NFTNL_EXPR_OBJREF_IMM_NAME: u32 = 2; -pub const NFTNL_EXPR_OBJREF_SET_SREG: u32 = 3; -pub const NFTNL_EXPR_OBJREF_SET_NAME: u32 = 4; -pub const NFTNL_EXPR_OBJREF_SET_ID: u32 = 5; - -#[repr(C)] -pub struct nftnl_gen(c_void); - -extern "C" { - pub fn nftnl_gen_alloc() -> *mut nftnl_gen; - - pub fn nftnl_gen_free(arg1: *const nftnl_gen); -} -pub const NFTNL_GEN_ID: u32 = 0; -pub const __NFTNL_GEN_MAX: u32 = 1; - -extern "C" { - pub fn nftnl_gen_is_set(gen: *const nftnl_gen, attr: u16) -> bool; - - pub fn nftnl_gen_unset(gen: *mut nftnl_gen, attr: u16); - - pub fn nftnl_gen_set(gen: *mut nftnl_gen, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_gen_set_data( - gen: *mut nftnl_gen, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_gen_get(gen: *const nftnl_gen, attr: u16) -> *const c_void; - - pub fn nftnl_gen_get_data( - gen: *const nftnl_gen, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_gen_set_u32(gen: *mut nftnl_gen, attr: u16, data: u32); - - pub fn nftnl_gen_get_u32(gen: *const nftnl_gen, attr: u16) -> u32; - - pub fn nftnl_gen_nlmsg_parse(nlh: *const nlmsghdr, gen: *mut nftnl_gen) -> c_int; - - pub fn nftnl_gen_snprintf( - buf: *mut c_char, - size: usize, - gen: *const nftnl_gen, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_gen_fprintf(fp: *mut FILE, gen: *const nftnl_gen, type_: u32, flags: u32) - -> c_int; -} -pub const NFTNL_OBJ_TABLE: u32 = 0; -pub const NFTNL_OBJ_NAME: u32 = 1; -pub const NFTNL_OBJ_TYPE: u32 = 2; -pub const NFTNL_OBJ_FAMILY: u32 = 3; -pub const NFTNL_OBJ_USE: u32 = 4; -pub const NFTNL_OBJ_HANDLE: u32 = 5; -pub const NFTNL_OBJ_BASE: u32 = 16; -pub const __NFTNL_OBJ_MAX: u32 = 17; - -pub const NFTNL_OBJ_CTR_PKTS: u32 = 16; -pub const NFTNL_OBJ_CTR_BYTES: u32 = 17; - -pub const NFTNL_OBJ_QUOTA_BYTES: u32 = 16; -pub const NFTNL_OBJ_QUOTA_CONSUMED: u32 = 17; -pub const NFTNL_OBJ_QUOTA_FLAGS: u32 = 18; - -pub const NFTNL_OBJ_CT_HELPER_NAME: u32 = 16; -pub const NFTNL_OBJ_CT_HELPER_L3PROTO: u32 = 17; -pub const NFTNL_OBJ_CT_HELPER_L4PROTO: u32 = 18; - -pub const NFTNL_OBJ_LIMIT_RATE: u32 = 16; -pub const NFTNL_OBJ_LIMIT_UNIT: u32 = 17; -pub const NFTNL_OBJ_LIMIT_BURST: u32 = 18; -pub const NFTNL_OBJ_LIMIT_TYPE: u32 = 19; -pub const NFTNL_OBJ_LIMIT_FLAGS: u32 = 20; - -#[repr(C)] -pub struct nftnl_obj(c_void); - -extern "C" { - pub fn nftnl_obj_alloc() -> *mut nftnl_obj; - - pub fn nftnl_obj_free(ne: *const nftnl_obj); - - pub fn nftnl_obj_is_set(ne: *const nftnl_obj, attr: u16) -> bool; - - pub fn nftnl_obj_unset(ne: *mut nftnl_obj, attr: u16); - - pub fn nftnl_obj_set_data(ne: *mut nftnl_obj, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_obj_set(ne: *mut nftnl_obj, attr: u16, data: *const c_void); - - pub fn nftnl_obj_set_u8(ne: *mut nftnl_obj, attr: u16, val: u8); - - pub fn nftnl_obj_set_u16(ne: *mut nftnl_obj, attr: u16, val: u16); - - pub fn nftnl_obj_set_u32(ne: *mut nftnl_obj, attr: u16, val: u32); - - pub fn nftnl_obj_set_u64(obj: *mut nftnl_obj, attr: u16, val: u64); - - pub fn nftnl_obj_set_str(ne: *mut nftnl_obj, attr: u16, str: *const c_char); - - pub fn nftnl_obj_get_data(ne: *mut nftnl_obj, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_obj_get(ne: *mut nftnl_obj, attr: u16) -> *const c_void; - - pub fn nftnl_obj_get_u8(ne: *mut nftnl_obj, attr: u16) -> u8; - - pub fn nftnl_obj_get_u16(obj: *mut nftnl_obj, attr: u16) -> u16; - - pub fn nftnl_obj_get_u32(ne: *mut nftnl_obj, attr: u16) -> u32; - - pub fn nftnl_obj_get_u64(obj: *mut nftnl_obj, attr: u16) -> u64; - - pub fn nftnl_obj_get_str(ne: *mut nftnl_obj, attr: u16) -> *const c_char; - - pub fn nftnl_obj_nlmsg_build_payload(nlh: *mut nlmsghdr, ne: *const nftnl_obj); - - pub fn nftnl_obj_nlmsg_parse(nlh: *const nlmsghdr, ne: *mut nftnl_obj) -> c_int; - - pub fn nftnl_obj_parse( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_parse_file( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_snprintf( - buf: *mut c_char, - size: usize, - ne: *const nftnl_obj, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_obj_fprintf(fp: *mut FILE, ne: *const nftnl_obj, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list(c_void); - -extern "C" { - pub fn nftnl_obj_list_alloc() -> *mut nftnl_obj_list; - - pub fn nftnl_obj_list_free(list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_is_empty(list: *mut nftnl_obj_list) -> c_int; - - pub fn nftnl_obj_list_add(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_add_tail(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_del(t: *mut nftnl_obj); - - pub fn nftnl_obj_list_foreach( - table_list: *mut nftnl_obj_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_obj, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list_iter(c_void); - -extern "C" { - pub fn nftnl_obj_list_iter_create(l: *mut nftnl_obj_list) -> *mut nftnl_obj_list_iter; - - pub fn nftnl_obj_list_iter_next(iter: *mut nftnl_obj_list_iter) -> *mut nftnl_obj; - - pub fn nftnl_obj_list_iter_destroy(iter: *mut nftnl_obj_list_iter); -} -#[repr(C)] -pub struct nftnl_rule(c_void); - -extern "C" { - pub fn nftnl_rule_alloc() -> *mut nftnl_rule; - - pub fn nftnl_rule_free(arg1: *const nftnl_rule); -} -pub const NFTNL_RULE_FAMILY: nftnl_rule_attr = 0; -pub const NFTNL_RULE_TABLE: nftnl_rule_attr = 1; -pub const NFTNL_RULE_CHAIN: nftnl_rule_attr = 2; -pub const NFTNL_RULE_HANDLE: nftnl_rule_attr = 3; -pub const NFTNL_RULE_COMPAT_PROTO: nftnl_rule_attr = 4; -pub const NFTNL_RULE_COMPAT_FLAGS: nftnl_rule_attr = 5; -pub const NFTNL_RULE_POSITION: nftnl_rule_attr = 6; -pub const NFTNL_RULE_USERDATA: nftnl_rule_attr = 7; -pub const NFTNL_RULE_ID: nftnl_rule_attr = 8; -pub const __NFTNL_RULE_MAX: nftnl_rule_attr = 9; -pub type nftnl_rule_attr = u32; -extern "C" { - pub fn nftnl_rule_unset(r: *mut nftnl_rule, attr: u16); - - pub fn nftnl_rule_is_set(r: *const nftnl_rule, attr: u16) -> bool; - - pub fn nftnl_rule_set(r: *mut nftnl_rule, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_rule_set_data( - r: *mut nftnl_rule, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_rule_set_u32(r: *mut nftnl_rule, attr: u16, val: u32); - - pub fn nftnl_rule_set_u64(r: *mut nftnl_rule, attr: u16, val: u64); - - pub fn nftnl_rule_set_str(r: *mut nftnl_rule, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_rule_get(r: *const nftnl_rule, attr: u16) -> *const c_void; - - pub fn nftnl_rule_get_data( - r: *const nftnl_rule, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_rule_get_str(r: *const nftnl_rule, attr: u16) -> *const c_char; - - pub fn nftnl_rule_get_u8(r: *const nftnl_rule, attr: u16) -> u8; - - pub fn nftnl_rule_get_u32(r: *const nftnl_rule, attr: u16) -> u32; - - pub fn nftnl_rule_get_u64(r: *const nftnl_rule, attr: u16) -> u64; - - pub fn nftnl_rule_add_expr(r: *mut nftnl_rule, expr: *mut nftnl_expr); - - pub fn nftnl_rule_cmp(r1: *const nftnl_rule, r2: *const nftnl_rule) -> bool; - - pub fn nftnl_rule_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *mut nftnl_rule); - - pub fn nftnl_rule_parse( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_parse_file( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_rule, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_rule_fprintf(fp: *mut FILE, r: *const nftnl_rule, type_: u32, flags: u32) - -> c_int; - - pub fn nftnl_rule_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_rule) -> c_int; - - pub fn nftnl_expr_foreach( - r: *mut nftnl_rule, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_expr, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_expr_iter(c_void); - -extern "C" { - pub fn nftnl_expr_iter_create(r: *const nftnl_rule) -> *mut nftnl_expr_iter; - - pub fn nftnl_expr_iter_next(iter: *mut nftnl_expr_iter) -> *mut nftnl_expr; - - pub fn nftnl_expr_iter_destroy(iter: *mut nftnl_expr_iter); -} -#[repr(C)] -pub struct nftnl_rule_list(c_void); - -extern "C" { - pub fn nftnl_rule_list_alloc() -> *mut nftnl_rule_list; - - pub fn nftnl_rule_list_free(list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_is_empty(list: *const nftnl_rule_list) -> c_int; - - pub fn nftnl_rule_list_add(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_add_tail(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_del(r: *mut nftnl_rule); - - pub fn nftnl_rule_list_foreach( - rule_list: *mut nftnl_rule_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_rule, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_rule_list_iter(c_void); - -extern "C" { - pub fn nftnl_rule_list_iter_create(l: *const nftnl_rule_list) -> *mut nftnl_rule_list_iter; - - pub fn nftnl_rule_list_iter_cur(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_next(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_destroy(iter: *const nftnl_rule_list_iter); -} -#[repr(C)] -pub struct nftnl_ruleset(c_void); - -extern "C" { - pub fn nftnl_ruleset_alloc() -> *mut nftnl_ruleset; - - pub fn nftnl_ruleset_free(r: *const nftnl_ruleset); -} -pub const NFTNL_RULESET_TABLELIST: u32 = 0; -pub const NFTNL_RULESET_CHAINLIST: u32 = 1; -pub const NFTNL_RULESET_SETLIST: u32 = 2; -pub const NFTNL_RULESET_RULELIST: u32 = 3; - -pub const NFTNL_RULESET_UNSPEC: nftnl_ruleset_type = 0; -pub const NFTNL_RULESET_RULESET: nftnl_ruleset_type = 1; -pub const NFTNL_RULESET_TABLE: nftnl_ruleset_type = 2; -pub const NFTNL_RULESET_CHAIN: nftnl_ruleset_type = 3; -pub const NFTNL_RULESET_RULE: nftnl_ruleset_type = 4; -pub const NFTNL_RULESET_SET: nftnl_ruleset_type = 5; -pub const NFTNL_RULESET_SET_ELEMS: nftnl_ruleset_type = 6; -pub type nftnl_ruleset_type = u32; -extern "C" { - pub fn nftnl_ruleset_is_set(r: *const nftnl_ruleset, attr: u16) -> bool; - - pub fn nftnl_ruleset_unset(r: *mut nftnl_ruleset, attr: u16); - - pub fn nftnl_ruleset_set(r: *mut nftnl_ruleset, attr: u16, data: *mut c_void); - - pub fn nftnl_ruleset_get(r: *const nftnl_ruleset, attr: u16) -> *mut c_void; -} -pub const NFTNL_RULESET_CTX_CMD: u32 = 0; -pub const NFTNL_RULESET_CTX_TYPE: u32 = 1; -pub const NFTNL_RULESET_CTX_TABLE: u32 = 2; -pub const NFTNL_RULESET_CTX_CHAIN: u32 = 3; -pub const NFTNL_RULESET_CTX_RULE: u32 = 4; -pub const NFTNL_RULESET_CTX_SET: u32 = 5; -pub const NFTNL_RULESET_CTX_DATA: u32 = 6; - -#[repr(C)] -pub struct nftnl_parse_ctx(c_void); - -extern "C" { - pub fn nftnl_ruleset_ctx_free(ctx: *const nftnl_parse_ctx); - - pub fn nftnl_ruleset_ctx_is_set(ctx: *const nftnl_parse_ctx, attr: u16) -> bool; - - pub fn nftnl_ruleset_ctx_get(ctx: *const nftnl_parse_ctx, attr: u16) -> *mut c_void; - - pub fn nftnl_ruleset_ctx_get_u32(ctx: *const nftnl_parse_ctx, attr: u16) -> u32; - - pub fn nftnl_ruleset_parse_file_cb( - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse_buffer_cb( - type_: nftnl_parse_type, - buffer: *const c_char, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_parse_file( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_snprintf( - buf: *mut c_char, - size: usize, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_ruleset_fprintf( - fp: *mut FILE, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_SET_TABLE: nftnl_set_attr = 0; -pub const NFTNL_SET_NAME: nftnl_set_attr = 1; -pub const NFTNL_SET_FLAGS: nftnl_set_attr = 2; -pub const NFTNL_SET_KEY_TYPE: nftnl_set_attr = 3; -pub const NFTNL_SET_KEY_LEN: nftnl_set_attr = 4; -pub const NFTNL_SET_DATA_TYPE: nftnl_set_attr = 5; -pub const NFTNL_SET_DATA_LEN: nftnl_set_attr = 6; -pub const NFTNL_SET_FAMILY: nftnl_set_attr = 7; -pub const NFTNL_SET_ID: nftnl_set_attr = 8; -pub const NFTNL_SET_POLICY: nftnl_set_attr = 9; -pub const NFTNL_SET_DESC_SIZE: nftnl_set_attr = 10; -pub const NFTNL_SET_TIMEOUT: nftnl_set_attr = 11; -pub const NFTNL_SET_GC_INTERVAL: nftnl_set_attr = 12; -pub const NFTNL_SET_USERDATA: nftnl_set_attr = 13; -pub const NFTNL_SET_OBJ_TYPE: nftnl_set_attr = 14; -pub const NFTNL_SET_HANDLE: nftnl_set_attr = 15; -pub const __NFTNL_SET_MAX: nftnl_set_attr = 16; -pub type nftnl_set_attr = u32; -#[repr(C)] -pub struct nftnl_set(c_void); - -extern "C" { - pub fn nftnl_set_alloc() -> *mut nftnl_set; - - pub fn nftnl_set_free(s: *const nftnl_set); - - pub fn nftnl_set_clone(set: *const nftnl_set) -> *mut nftnl_set; - - pub fn nftnl_set_is_set(s: *const nftnl_set, attr: u16) -> bool; - - pub fn nftnl_set_unset(s: *mut nftnl_set, attr: u16); - - pub fn nftnl_set_set(s: *mut nftnl_set, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_set_set_data( - s: *mut nftnl_set, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_set_u32(s: *mut nftnl_set, attr: u16, val: u32); - - pub fn nftnl_set_set_u64(s: *mut nftnl_set, attr: u16, val: u64); - - pub fn nftnl_set_set_str(s: *mut nftnl_set, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_get(s: *const nftnl_set, attr: u16) -> *const c_void; - - pub fn nftnl_set_get_data(s: *const nftnl_set, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_set_get_str(s: *const nftnl_set, attr: u16) -> *const c_char; - - pub fn nftnl_set_get_u32(s: *const nftnl_set, attr: u16) -> u32; - - pub fn nftnl_set_get_u64(s: *const nftnl_set, attr: u16) -> u64; - - pub fn nftnl_set_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_elems_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_fprintf(fp: *mut FILE, s: *const nftnl_set, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list(c_void); - -extern "C" { - pub fn nftnl_set_list_alloc() -> *mut nftnl_set_list; - - pub fn nftnl_set_list_free(list: *mut nftnl_set_list); - - pub fn nftnl_set_list_is_empty(list: *const nftnl_set_list) -> c_int; - - pub fn nftnl_set_list_add(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_add_tail(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_del(s: *mut nftnl_set); - - pub fn nftnl_set_list_foreach( - set_list: *mut nftnl_set_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_set, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list_iter(c_void); - -extern "C" { - pub fn nftnl_set_list_iter_create(l: *const nftnl_set_list) -> *mut nftnl_set_list_iter; - - pub fn nftnl_set_list_iter_cur(iter: *const nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_next(iter: *mut nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_destroy(iter: *const nftnl_set_list_iter); - - pub fn nftnl_set_parse( - s: *mut nftnl_set, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_parse_file( - s: *mut nftnl_set, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; -} -pub const NFTNL_SET_ELEM_FLAGS: u32 = 0; -pub const NFTNL_SET_ELEM_KEY: u32 = 1; -pub const NFTNL_SET_ELEM_VERDICT: u32 = 2; -pub const NFTNL_SET_ELEM_CHAIN: u32 = 3; -pub const NFTNL_SET_ELEM_DATA: u32 = 4; -pub const NFTNL_SET_ELEM_TIMEOUT: u32 = 5; -pub const NFTNL_SET_ELEM_EXPIRATION: u32 = 6; -pub const NFTNL_SET_ELEM_USERDATA: u32 = 7; -pub const NFTNL_SET_ELEM_EXPR: u32 = 8; -pub const NFTNL_SET_ELEM_OBJREF: u32 = 9; - -#[repr(C)] -pub struct nftnl_set_elem(c_void); - -extern "C" { - pub fn nftnl_set_elem_alloc() -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_free(s: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_clone(elem: *mut nftnl_set_elem) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_add(s: *mut nftnl_set, elem: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_unset(s: *mut nftnl_set_elem, attr: u16); - - pub fn nftnl_set_elem_set( - s: *mut nftnl_set_elem, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_elem_set_u32(s: *mut nftnl_set_elem, attr: u16, val: u32); - - pub fn nftnl_set_elem_set_u64(s: *mut nftnl_set_elem, attr: u16, val: u64); - - pub fn nftnl_set_elem_set_str(s: *mut nftnl_set_elem, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_elem_get( - s: *mut nftnl_set_elem, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_set_elem_get_str(s: *mut nftnl_set_elem, attr: u16) -> *const c_char; - - pub fn nftnl_set_elem_get_u32(s: *mut nftnl_set_elem, attr: u16) -> u32; - - pub fn nftnl_set_elem_get_u64(s: *mut nftnl_set_elem, attr: u16) -> u64; - - pub fn nftnl_set_elem_is_set(s: *const nftnl_set_elem, attr: u16) -> bool; - - pub fn nftnl_set_elems_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_elem_nlmsg_build_payload(nlh: *mut nlmsghdr, e: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_parse( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_parse_file( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_fprintf( - fp: *mut FILE, - se: *mut nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_foreach( - s: *mut nftnl_set, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_set_elem, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_elems_iter(c_void); - -extern "C" { - pub fn nftnl_set_elems_iter_create(s: *const nftnl_set) -> *mut nftnl_set_elems_iter; - - pub fn nftnl_set_elems_iter_cur(iter: *const nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_next(iter: *mut nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_destroy(iter: *mut nftnl_set_elems_iter); - - pub fn nftnl_set_elems_nlmsg_build_payload_iter( - nlh: *mut nlmsghdr, - iter: *mut nftnl_set_elems_iter, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_table(c_void); - -extern "C" { - pub fn nftnl_table_alloc() -> *mut nftnl_table; - - pub fn nftnl_table_free(arg1: *const nftnl_table); -} -pub const NFTNL_TABLE_NAME: nftnl_table_attr = 0; -pub const NFTNL_TABLE_FAMILY: nftnl_table_attr = 1; -pub const NFTNL_TABLE_FLAGS: nftnl_table_attr = 2; -pub const NFTNL_TABLE_USE: nftnl_table_attr = 3; -pub const NFTNL_TABLE_HANDLE: nftnl_table_attr = 4; -pub const __NFTNL_TABLE_MAX: nftnl_table_attr = 5; -pub type nftnl_table_attr = u32; -extern "C" { - pub fn nftnl_table_is_set(t: *const nftnl_table, attr: u16) -> bool; - - pub fn nftnl_table_unset(t: *mut nftnl_table, attr: u16); - - pub fn nftnl_table_set(t: *mut nftnl_table, attr: u16, data: *const c_void); - - pub fn nftnl_table_set_data( - t: *mut nftnl_table, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_table_get(t: *const nftnl_table, attr: u16) -> *const c_void; - - pub fn nftnl_table_get_data( - t: *const nftnl_table, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_table_set_u8(t: *mut nftnl_table, attr: u16, data: u8); - - pub fn nftnl_table_set_u32(t: *mut nftnl_table, attr: u16, data: u32); - - pub fn nftnl_table_set_u64(t: *mut nftnl_table, attr: u16, data: u64); - - pub fn nftnl_table_set_str(t: *mut nftnl_table, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_table_get_u8(t: *const nftnl_table, attr: u16) -> u8; - - pub fn nftnl_table_get_u32(t: *const nftnl_table, attr: u16) -> u32; - - pub fn nftnl_table_get_u64(t: *const nftnl_table, attr: u16) -> u64; - - pub fn nftnl_table_get_str(t: *const nftnl_table, attr: u16) -> *const c_char; - - pub fn nftnl_table_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_table); - - pub fn nftnl_table_parse( - t: *mut nftnl_table, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_parse_file( - t: *mut nftnl_table, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_fprintf( - fp: *mut FILE, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_table) -> c_int; -} -#[repr(C)] -pub struct nftnl_table_list(c_void); - -extern "C" { - pub fn nftnl_table_list_alloc() -> *mut nftnl_table_list; - - pub fn nftnl_table_list_free(list: *mut nftnl_table_list); - - pub fn nftnl_table_list_is_empty(list: *const nftnl_table_list) -> c_int; - - pub fn nftnl_table_list_foreach( - table_list: *mut nftnl_table_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_table, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_table_list_add(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_add_tail(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_del(r: *mut nftnl_table); -} -#[repr(C)] -pub struct nftnl_table_list_iter(c_void); - -extern "C" { - pub fn nftnl_table_list_iter_create(l: *const nftnl_table_list) -> *mut nftnl_table_list_iter; - - pub fn nftnl_table_list_iter_next(iter: *mut nftnl_table_list_iter) -> *mut nftnl_table; - - pub fn nftnl_table_list_iter_destroy(iter: *const nftnl_table_list_iter); -} -pub const NFTNL_TRACE_CHAIN: nftnl_trace_attr = 0; -pub const NFTNL_TRACE_FAMILY: nftnl_trace_attr = 1; -pub const NFTNL_TRACE_ID: nftnl_trace_attr = 2; -pub const NFTNL_TRACE_IIF: nftnl_trace_attr = 3; -pub const NFTNL_TRACE_IIFTYPE: nftnl_trace_attr = 4; -pub const NFTNL_TRACE_JUMP_TARGET: nftnl_trace_attr = 5; -pub const NFTNL_TRACE_OIF: nftnl_trace_attr = 6; -pub const NFTNL_TRACE_OIFTYPE: nftnl_trace_attr = 7; -pub const NFTNL_TRACE_MARK: nftnl_trace_attr = 8; -pub const NFTNL_TRACE_LL_HEADER: nftnl_trace_attr = 9; -pub const NFTNL_TRACE_NETWORK_HEADER: nftnl_trace_attr = 10; -pub const NFTNL_TRACE_TRANSPORT_HEADER: nftnl_trace_attr = 11; -pub const NFTNL_TRACE_TABLE: nftnl_trace_attr = 12; -pub const NFTNL_TRACE_TYPE: nftnl_trace_attr = 13; -pub const NFTNL_TRACE_RULE_HANDLE: nftnl_trace_attr = 14; -pub const NFTNL_TRACE_VERDICT: nftnl_trace_attr = 15; -pub const NFTNL_TRACE_NFPROTO: nftnl_trace_attr = 16; -pub const NFTNL_TRACE_POLICY: nftnl_trace_attr = 17; -pub const __NFTNL_TRACE_MAX: nftnl_trace_attr = 18; -pub type nftnl_trace_attr = u32; -#[repr(C)] -pub struct nftnl_trace(c_void); - -extern "C" { - pub fn nftnl_trace_alloc() -> *mut nftnl_trace; - - pub fn nftnl_trace_free(trace: *const nftnl_trace); - - pub fn nftnl_trace_is_set(trace: *const nftnl_trace, type_: u16) -> bool; - - pub fn nftnl_trace_get_data( - trace: *const nftnl_trace, - type_: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_trace_get_u16(trace: *const nftnl_trace, type_: u16) -> u16; - - pub fn nftnl_trace_get_u32(trace: *const nftnl_trace, type_: u16) -> u32; - - pub fn nftnl_trace_get_u64(trace: *const nftnl_trace, type_: u16) -> u64; - - pub fn nftnl_trace_get_str(trace: *const nftnl_trace, type_: u16) -> *const c_char; - - pub fn nftnl_trace_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_trace) -> c_int; -} -#[repr(C)] -pub struct nftnl_udata(c_void); - -#[repr(C)] -pub struct nftnl_udata_buf(c_void); - -extern "C" { - pub fn nftnl_udata_buf_alloc(data_size: u32) -> *mut nftnl_udata_buf; - - pub fn nftnl_udata_buf_free(buf: *const nftnl_udata_buf); - - pub fn nftnl_udata_buf_len(buf: *const nftnl_udata_buf) -> u32; - - pub fn nftnl_udata_buf_data(buf: *const nftnl_udata_buf) -> *mut c_void; - - pub fn nftnl_udata_buf_put(buf: *mut nftnl_udata_buf, data: *const c_void, len: u32); - - pub fn nftnl_udata_start(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_end(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_put( - buf: *mut nftnl_udata_buf, - type_: u8, - len: u32, - value: *const c_void, - ) -> bool; - - pub fn nftnl_udata_put_u32(buf: *mut nftnl_udata_buf, type_: u8, data: u32) -> bool; - - pub fn nftnl_udata_put_strz(buf: *mut nftnl_udata_buf, type_: u8, strz: *const c_char) -> bool; - - pub fn nftnl_udata_type(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_len(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_get(attr: *const nftnl_udata) -> *mut c_void; - - pub fn nftnl_udata_get_u32(attr: *const nftnl_udata) -> u32; - - pub fn nftnl_udata_next(attr: *const nftnl_udata) -> *mut nftnl_udata; -} -pub type nftnl_udata_cb_t = - Option<unsafe extern "C" fn(attr: *const nftnl_udata, data: *mut c_void) -> c_int>; -extern "C" { - pub fn nftnl_udata_parse( - data: *const c_void, - data_len: u32, - cb: nftnl_udata_cb_t, - cb_data: *mut c_void, - ) -> c_int; -} diff --git a/rustables-sys/src/nftnl_1_1_1.rs b/rustables-sys/src/nftnl_1_1_1.rs deleted file mode 100644 index 85432c0..0000000 --- a/rustables-sys/src/nftnl_1_1_1.rs +++ /dev/null @@ -1,1281 +0,0 @@ -// automatically generated by rust-bindgen 0.39.0 - -use core::option::Option; -use libc::{c_char, c_int, c_void, iovec, nlmsghdr, FILE}; - -#[repr(C)] -pub struct nftnl_batch(c_void); - -extern "C" { - pub fn nftnl_batch_alloc(pg_size: u32, pg_overrun_size: u32) -> *mut nftnl_batch; - - pub fn nftnl_batch_update(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_free(batch: *mut nftnl_batch); - - pub fn nftnl_batch_buffer(batch: *mut nftnl_batch) -> *mut c_void; - - pub fn nftnl_batch_buffer_len(batch: *mut nftnl_batch) -> u32; - - pub fn nftnl_batch_iovec_len(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_iovec(batch: *mut nftnl_batch, iov: *mut iovec, iovlen: u32); -} -pub const NFTNL_PARSE_EBADINPUT: u32 = 0; -pub const NFTNL_PARSE_EMISSINGNODE: u32 = 1; -pub const NFTNL_PARSE_EBADTYPE: u32 = 2; -pub const NFTNL_PARSE_EOPNOTSUPP: u32 = 3; - -pub const NFTNL_OUTPUT_DEFAULT: nftnl_output_type = 0; -pub const NFTNL_OUTPUT_XML: nftnl_output_type = 1; -pub const NFTNL_OUTPUT_JSON: nftnl_output_type = 2; -pub type nftnl_output_type = u32; -pub const NFTNL_OF_EVENT_NEW: nftnl_output_flags = 1; -pub const NFTNL_OF_EVENT_DEL: nftnl_output_flags = 2; -pub const NFTNL_OF_EVENT_ANY: nftnl_output_flags = 3; -pub type nftnl_output_flags = u32; -pub const NFTNL_CMD_UNSPEC: nftnl_cmd_type = 0; -pub const NFTNL_CMD_ADD: nftnl_cmd_type = 1; -pub const NFTNL_CMD_INSERT: nftnl_cmd_type = 2; -pub const NFTNL_CMD_DELETE: nftnl_cmd_type = 3; -pub const NFTNL_CMD_REPLACE: nftnl_cmd_type = 4; -pub const NFTNL_CMD_FLUSH: nftnl_cmd_type = 5; -pub const NFTNL_CMD_MAX: nftnl_cmd_type = 6; -pub type nftnl_cmd_type = u32; -pub const NFTNL_PARSE_NONE: nftnl_parse_type = 0; -pub const NFTNL_PARSE_XML: nftnl_parse_type = 1; -pub const NFTNL_PARSE_JSON: nftnl_parse_type = 2; -pub const NFTNL_PARSE_MAX: nftnl_parse_type = 3; -pub type nftnl_parse_type = u32; -#[repr(C)] -pub struct nftnl_parse_err(c_void); - -extern "C" { - pub fn nftnl_nlmsg_build_hdr( - buf: *mut c_char, - type_: u16, - family: u16, - flags: u16, - seq: u32, - ) -> *mut nlmsghdr; - - pub fn nftnl_parse_err_alloc() -> *mut nftnl_parse_err; - - pub fn nftnl_parse_err_free(arg1: *mut nftnl_parse_err); - - pub fn nftnl_parse_perror(str: *const c_char, err: *mut nftnl_parse_err) -> c_int; - - pub fn nftnl_batch_is_supported() -> c_int; - - pub fn nftnl_batch_begin(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; - - pub fn nftnl_batch_end(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; -} -#[repr(C)] -pub struct nftnl_chain(c_void); - -extern "C" { - pub fn nftnl_chain_alloc() -> *mut nftnl_chain; - - pub fn nftnl_chain_free(arg1: *const nftnl_chain); -} -pub const NFTNL_CHAIN_NAME: nftnl_chain_attr = 0; -pub const NFTNL_CHAIN_FAMILY: nftnl_chain_attr = 1; -pub const NFTNL_CHAIN_TABLE: nftnl_chain_attr = 2; -pub const NFTNL_CHAIN_HOOKNUM: nftnl_chain_attr = 3; -pub const NFTNL_CHAIN_PRIO: nftnl_chain_attr = 4; -pub const NFTNL_CHAIN_POLICY: nftnl_chain_attr = 5; -pub const NFTNL_CHAIN_USE: nftnl_chain_attr = 6; -pub const NFTNL_CHAIN_BYTES: nftnl_chain_attr = 7; -pub const NFTNL_CHAIN_PACKETS: nftnl_chain_attr = 8; -pub const NFTNL_CHAIN_HANDLE: nftnl_chain_attr = 9; -pub const NFTNL_CHAIN_TYPE: nftnl_chain_attr = 10; -pub const NFTNL_CHAIN_DEV: nftnl_chain_attr = 11; -pub const __NFTNL_CHAIN_MAX: nftnl_chain_attr = 12; -pub type nftnl_chain_attr = u32; -extern "C" { - pub fn nftnl_chain_is_set(c: *const nftnl_chain, attr: u16) -> bool; - - pub fn nftnl_chain_unset(c: *mut nftnl_chain, attr: u16); - - pub fn nftnl_chain_set(t: *mut nftnl_chain, attr: u16, data: *const c_void); - - pub fn nftnl_chain_set_data( - t: *mut nftnl_chain, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_chain_set_u8(t: *mut nftnl_chain, attr: u16, data: u8); - - pub fn nftnl_chain_set_u32(t: *mut nftnl_chain, attr: u16, data: u32); - - pub fn nftnl_chain_set_s32(t: *mut nftnl_chain, attr: u16, data: i32); - - pub fn nftnl_chain_set_u64(t: *mut nftnl_chain, attr: u16, data: u64); - - pub fn nftnl_chain_set_str(t: *mut nftnl_chain, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_chain_get(c: *const nftnl_chain, attr: u16) -> *const c_void; - - pub fn nftnl_chain_get_data( - c: *const nftnl_chain, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_chain_get_str(c: *const nftnl_chain, attr: u16) -> *const c_char; - - pub fn nftnl_chain_get_u8(c: *const nftnl_chain, attr: u16) -> u8; - - pub fn nftnl_chain_get_u32(c: *const nftnl_chain, attr: u16) -> u32; - - pub fn nftnl_chain_get_s32(c: *const nftnl_chain, attr: u16) -> i32; - - pub fn nftnl_chain_get_u64(c: *const nftnl_chain, attr: u16) -> u64; - - pub fn nftnl_chain_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_chain); - - pub fn nftnl_chain_parse( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_parse_file( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_fprintf( - fp: *mut FILE, - c: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_chain) -> c_int; -} -#[repr(C)] -pub struct nftnl_chain_list(c_void); - -extern "C" { - pub fn nftnl_chain_list_alloc() -> *mut nftnl_chain_list; - - pub fn nftnl_chain_list_free(list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_is_empty(list: *const nftnl_chain_list) -> c_int; - - pub fn nftnl_chain_list_foreach( - chain_list: *mut nftnl_chain_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_chain, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_chain_list_add(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_add_tail(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_del(c: *mut nftnl_chain); -} -#[repr(C)] -pub struct nftnl_chain_list_iter(c_void); - -extern "C" { - pub fn nftnl_chain_list_iter_create(l: *const nftnl_chain_list) -> *mut nftnl_chain_list_iter; - - pub fn nftnl_chain_list_iter_next(iter: *mut nftnl_chain_list_iter) -> *mut nftnl_chain; - - pub fn nftnl_chain_list_iter_destroy(iter: *mut nftnl_chain_list_iter); -} -#[repr(C)] -pub struct nftnl_expr(c_void); - -pub const NFTNL_EXPR_NAME: u32 = 0; -pub const NFTNL_EXPR_BASE: u32 = 1; - -extern "C" { - pub fn nftnl_expr_alloc(name: *const c_char) -> *mut nftnl_expr; - - pub fn nftnl_expr_free(expr: *const nftnl_expr); - - pub fn nftnl_expr_is_set(expr: *const nftnl_expr, type_: u16) -> bool; - - pub fn nftnl_expr_set( - expr: *mut nftnl_expr, - type_: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_expr_set_u8(expr: *mut nftnl_expr, type_: u16, data: u8); - - pub fn nftnl_expr_set_u16(expr: *mut nftnl_expr, type_: u16, data: u16); - - pub fn nftnl_expr_set_u32(expr: *mut nftnl_expr, type_: u16, data: u32); - - pub fn nftnl_expr_set_u64(expr: *mut nftnl_expr, type_: u16, data: u64); - - pub fn nftnl_expr_set_str(expr: *mut nftnl_expr, type_: u16, str: *const c_char) -> c_int; - - pub fn nftnl_expr_get(expr: *const nftnl_expr, type_: u16, data_len: *mut u32) - -> *const c_void; - - pub fn nftnl_expr_get_u8(expr: *const nftnl_expr, type_: u16) -> u8; - - pub fn nftnl_expr_get_u16(expr: *const nftnl_expr, type_: u16) -> u16; - - pub fn nftnl_expr_get_u32(expr: *const nftnl_expr, type_: u16) -> u32; - - pub fn nftnl_expr_get_u64(expr: *const nftnl_expr, type_: u16) -> u64; - - pub fn nftnl_expr_get_str(expr: *const nftnl_expr, type_: u16) -> *const c_char; - - pub fn nftnl_expr_cmp(e1: *const nftnl_expr, e2: *const nftnl_expr) -> bool; - - pub fn nftnl_expr_snprintf( - buf: *mut c_char, - buflen: usize, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_expr_fprintf( - fp: *mut FILE, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_EXPR_PAYLOAD_DREG: u32 = 1; -pub const NFTNL_EXPR_PAYLOAD_BASE: u32 = 2; -pub const NFTNL_EXPR_PAYLOAD_OFFSET: u32 = 3; -pub const NFTNL_EXPR_PAYLOAD_LEN: u32 = 4; -pub const NFTNL_EXPR_PAYLOAD_SREG: u32 = 5; -pub const NFTNL_EXPR_PAYLOAD_CSUM_TYPE: u32 = 6; -pub const NFTNL_EXPR_PAYLOAD_CSUM_OFFSET: u32 = 7; -pub const NFTNL_EXPR_PAYLOAD_FLAGS: u32 = 8; - -pub const NFTNL_EXPR_NG_DREG: u32 = 1; -pub const NFTNL_EXPR_NG_MODULUS: u32 = 2; -pub const NFTNL_EXPR_NG_TYPE: u32 = 3; -pub const NFTNL_EXPR_NG_OFFSET: u32 = 4; -pub const NFTNL_EXPR_NG_SET_NAME: u32 = 5; -pub const NFTNL_EXPR_NG_SET_ID: u32 = 6; - -pub const NFTNL_EXPR_META_KEY: u32 = 1; -pub const NFTNL_EXPR_META_DREG: u32 = 2; -pub const NFTNL_EXPR_META_SREG: u32 = 3; - -pub const NFTNL_EXPR_RT_KEY: u32 = 1; -pub const NFTNL_EXPR_RT_DREG: u32 = 2; - -pub const NFTNL_EXPR_SOCKET_KEY: u32 = 1; -pub const NFTNL_EXPR_SOCKET_DREG: u32 = 2; - -pub const NFTNL_EXPR_CMP_SREG: u32 = 1; -pub const NFTNL_EXPR_CMP_OP: u32 = 2; -pub const NFTNL_EXPR_CMP_DATA: u32 = 3; - -pub const NFTNL_EXPR_RANGE_SREG: u32 = 1; -pub const NFTNL_EXPR_RANGE_OP: u32 = 2; -pub const NFTNL_EXPR_RANGE_FROM_DATA: u32 = 3; -pub const NFTNL_EXPR_RANGE_TO_DATA: u32 = 4; - -pub const NFTNL_EXPR_IMM_DREG: u32 = 1; -pub const NFTNL_EXPR_IMM_DATA: u32 = 2; -pub const NFTNL_EXPR_IMM_VERDICT: u32 = 3; -pub const NFTNL_EXPR_IMM_CHAIN: u32 = 4; - -pub const NFTNL_EXPR_CTR_PACKETS: u32 = 1; -pub const NFTNL_EXPR_CTR_BYTES: u32 = 2; - -pub const NFTNL_EXPR_CONNLIMIT_COUNT: u32 = 1; -pub const NFTNL_EXPR_CONNLIMIT_FLAGS: u32 = 2; - -pub const NFTNL_EXPR_BITWISE_SREG: u32 = 1; -pub const NFTNL_EXPR_BITWISE_DREG: u32 = 2; -pub const NFTNL_EXPR_BITWISE_LEN: u32 = 3; -pub const NFTNL_EXPR_BITWISE_MASK: u32 = 4; -pub const NFTNL_EXPR_BITWISE_XOR: u32 = 5; - -pub const NFTNL_EXPR_TG_NAME: u32 = 1; -pub const NFTNL_EXPR_TG_REV: u32 = 2; -pub const NFTNL_EXPR_TG_INFO: u32 = 3; - -pub const NFTNL_EXPR_MT_NAME: u32 = 1; -pub const NFTNL_EXPR_MT_REV: u32 = 2; -pub const NFTNL_EXPR_MT_INFO: u32 = 3; - -pub const NFTNL_EXPR_NAT_TYPE: u32 = 1; -pub const NFTNL_EXPR_NAT_FAMILY: u32 = 2; -pub const NFTNL_EXPR_NAT_REG_ADDR_MIN: u32 = 3; -pub const NFTNL_EXPR_NAT_REG_ADDR_MAX: u32 = 4; -pub const NFTNL_EXPR_NAT_REG_PROTO_MIN: u32 = 5; -pub const NFTNL_EXPR_NAT_REG_PROTO_MAX: u32 = 6; -pub const NFTNL_EXPR_NAT_FLAGS: u32 = 7; - -pub const NFTNL_EXPR_LOOKUP_SREG: u32 = 1; -pub const NFTNL_EXPR_LOOKUP_DREG: u32 = 2; -pub const NFTNL_EXPR_LOOKUP_SET: u32 = 3; -pub const NFTNL_EXPR_LOOKUP_SET_ID: u32 = 4; -pub const NFTNL_EXPR_LOOKUP_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_DYNSET_SREG_KEY: u32 = 1; -pub const NFTNL_EXPR_DYNSET_SREG_DATA: u32 = 2; -pub const NFTNL_EXPR_DYNSET_OP: u32 = 3; -pub const NFTNL_EXPR_DYNSET_TIMEOUT: u32 = 4; -pub const NFTNL_EXPR_DYNSET_SET_NAME: u32 = 5; -pub const NFTNL_EXPR_DYNSET_SET_ID: u32 = 6; -pub const NFTNL_EXPR_DYNSET_EXPR: u32 = 7; - -pub const NFTNL_EXPR_LOG_PREFIX: u32 = 1; -pub const NFTNL_EXPR_LOG_GROUP: u32 = 2; -pub const NFTNL_EXPR_LOG_SNAPLEN: u32 = 3; -pub const NFTNL_EXPR_LOG_QTHRESHOLD: u32 = 4; -pub const NFTNL_EXPR_LOG_LEVEL: u32 = 5; -pub const NFTNL_EXPR_LOG_FLAGS: u32 = 6; - -pub const NFTNL_EXPR_EXTHDR_DREG: u32 = 1; -pub const NFTNL_EXPR_EXTHDR_TYPE: u32 = 2; -pub const NFTNL_EXPR_EXTHDR_OFFSET: u32 = 3; -pub const NFTNL_EXPR_EXTHDR_LEN: u32 = 4; -pub const NFTNL_EXPR_EXTHDR_FLAGS: u32 = 5; -pub const NFTNL_EXPR_EXTHDR_OP: u32 = 6; -pub const NFTNL_EXPR_EXTHDR_SREG: u32 = 7; - -pub const NFTNL_EXPR_CT_DREG: u32 = 1; -pub const NFTNL_EXPR_CT_KEY: u32 = 2; -pub const NFTNL_EXPR_CT_DIR: u32 = 3; -pub const NFTNL_EXPR_CT_SREG: u32 = 4; - -pub const NFTNL_EXPR_BYTEORDER_DREG: u32 = 1; -pub const NFTNL_EXPR_BYTEORDER_SREG: u32 = 2; -pub const NFTNL_EXPR_BYTEORDER_OP: u32 = 3; -pub const NFTNL_EXPR_BYTEORDER_LEN: u32 = 4; -pub const NFTNL_EXPR_BYTEORDER_SIZE: u32 = 5; - -pub const NFTNL_EXPR_LIMIT_RATE: u32 = 1; -pub const NFTNL_EXPR_LIMIT_UNIT: u32 = 2; -pub const NFTNL_EXPR_LIMIT_BURST: u32 = 3; -pub const NFTNL_EXPR_LIMIT_TYPE: u32 = 4; -pub const NFTNL_EXPR_LIMIT_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_REJECT_TYPE: u32 = 1; -pub const NFTNL_EXPR_REJECT_CODE: u32 = 2; - -pub const NFTNL_EXPR_QUEUE_NUM: u32 = 1; -pub const NFTNL_EXPR_QUEUE_TOTAL: u32 = 2; -pub const NFTNL_EXPR_QUEUE_FLAGS: u32 = 3; -pub const NFTNL_EXPR_QUEUE_SREG_QNUM: u32 = 4; - -pub const NFTNL_EXPR_QUOTA_BYTES: u32 = 1; -pub const NFTNL_EXPR_QUOTA_FLAGS: u32 = 2; -pub const NFTNL_EXPR_QUOTA_CONSUMED: u32 = 3; - -pub const NFTNL_EXPR_MASQ_FLAGS: u32 = 1; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MIN: u32 = 2; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MAX: u32 = 3; - -pub const NFTNL_EXPR_REDIR_REG_PROTO_MIN: u32 = 1; -pub const NFTNL_EXPR_REDIR_REG_PROTO_MAX: u32 = 2; -pub const NFTNL_EXPR_REDIR_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_DUP_SREG_ADDR: u32 = 1; -pub const NFTNL_EXPR_DUP_SREG_DEV: u32 = 2; - -pub const NFTNL_EXPR_FLOW_TABLE_NAME: u32 = 1; - -pub const NFTNL_EXPR_FWD_SREG_DEV: u32 = 1; -pub const NFTNL_EXPR_FWD_SREG_ADDR: u32 = 2; -pub const NFTNL_EXPR_FWD_NFPROTO: u32 = 3; - -pub const NFTNL_EXPR_HASH_SREG: u32 = 1; -pub const NFTNL_EXPR_HASH_DREG: u32 = 2; -pub const NFTNL_EXPR_HASH_LEN: u32 = 3; -pub const NFTNL_EXPR_HASH_MODULUS: u32 = 4; -pub const NFTNL_EXPR_HASH_SEED: u32 = 5; -pub const NFTNL_EXPR_HASH_OFFSET: u32 = 6; -pub const NFTNL_EXPR_HASH_TYPE: u32 = 7; -pub const NFTNL_EXPR_HASH_SET_NAME: u32 = 8; -pub const NFTNL_EXPR_HASH_SET_ID: u32 = 9; - -pub const NFTNL_EXPR_FIB_DREG: u32 = 1; -pub const NFTNL_EXPR_FIB_RESULT: u32 = 2; -pub const NFTNL_EXPR_FIB_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_OBJREF_IMM_TYPE: u32 = 1; -pub const NFTNL_EXPR_OBJREF_IMM_NAME: u32 = 2; -pub const NFTNL_EXPR_OBJREF_SET_SREG: u32 = 3; -pub const NFTNL_EXPR_OBJREF_SET_NAME: u32 = 4; -pub const NFTNL_EXPR_OBJREF_SET_ID: u32 = 5; - -#[repr(C)] -pub struct nftnl_gen(c_void); - -extern "C" { - pub fn nftnl_gen_alloc() -> *mut nftnl_gen; - - pub fn nftnl_gen_free(arg1: *const nftnl_gen); -} -pub const NFTNL_GEN_ID: u32 = 0; -pub const __NFTNL_GEN_MAX: u32 = 1; - -extern "C" { - pub fn nftnl_gen_is_set(gen: *const nftnl_gen, attr: u16) -> bool; - - pub fn nftnl_gen_unset(gen: *mut nftnl_gen, attr: u16); - - pub fn nftnl_gen_set(gen: *mut nftnl_gen, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_gen_set_data( - gen: *mut nftnl_gen, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_gen_get(gen: *const nftnl_gen, attr: u16) -> *const c_void; - - pub fn nftnl_gen_get_data( - gen: *const nftnl_gen, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_gen_set_u32(gen: *mut nftnl_gen, attr: u16, data: u32); - - pub fn nftnl_gen_get_u32(gen: *const nftnl_gen, attr: u16) -> u32; - - pub fn nftnl_gen_nlmsg_parse(nlh: *const nlmsghdr, gen: *mut nftnl_gen) -> c_int; - - pub fn nftnl_gen_snprintf( - buf: *mut c_char, - size: usize, - gen: *const nftnl_gen, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_gen_fprintf(fp: *mut FILE, gen: *const nftnl_gen, type_: u32, flags: u32) - -> c_int; -} -pub const NFTNL_OBJ_TABLE: u32 = 0; -pub const NFTNL_OBJ_NAME: u32 = 1; -pub const NFTNL_OBJ_TYPE: u32 = 2; -pub const NFTNL_OBJ_FAMILY: u32 = 3; -pub const NFTNL_OBJ_USE: u32 = 4; -pub const NFTNL_OBJ_HANDLE: u32 = 5; -pub const NFTNL_OBJ_BASE: u32 = 16; -pub const __NFTNL_OBJ_MAX: u32 = 17; - -pub const NFTNL_OBJ_CTR_PKTS: u32 = 16; -pub const NFTNL_OBJ_CTR_BYTES: u32 = 17; - -pub const NFTNL_OBJ_QUOTA_BYTES: u32 = 16; -pub const NFTNL_OBJ_QUOTA_CONSUMED: u32 = 17; -pub const NFTNL_OBJ_QUOTA_FLAGS: u32 = 18; - -pub const NFTNL_OBJ_CT_HELPER_NAME: u32 = 16; -pub const NFTNL_OBJ_CT_HELPER_L3PROTO: u32 = 17; -pub const NFTNL_OBJ_CT_HELPER_L4PROTO: u32 = 18; - -pub const NFTNL_OBJ_LIMIT_RATE: u32 = 16; -pub const NFTNL_OBJ_LIMIT_UNIT: u32 = 17; -pub const NFTNL_OBJ_LIMIT_BURST: u32 = 18; -pub const NFTNL_OBJ_LIMIT_TYPE: u32 = 19; -pub const NFTNL_OBJ_LIMIT_FLAGS: u32 = 20; - -#[repr(C)] -pub struct nftnl_obj(c_void); - -extern "C" { - pub fn nftnl_obj_alloc() -> *mut nftnl_obj; - - pub fn nftnl_obj_free(ne: *const nftnl_obj); - - pub fn nftnl_obj_is_set(ne: *const nftnl_obj, attr: u16) -> bool; - - pub fn nftnl_obj_unset(ne: *mut nftnl_obj, attr: u16); - - pub fn nftnl_obj_set_data(ne: *mut nftnl_obj, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_obj_set(ne: *mut nftnl_obj, attr: u16, data: *const c_void); - - pub fn nftnl_obj_set_u8(ne: *mut nftnl_obj, attr: u16, val: u8); - - pub fn nftnl_obj_set_u16(ne: *mut nftnl_obj, attr: u16, val: u16); - - pub fn nftnl_obj_set_u32(ne: *mut nftnl_obj, attr: u16, val: u32); - - pub fn nftnl_obj_set_u64(obj: *mut nftnl_obj, attr: u16, val: u64); - - pub fn nftnl_obj_set_str(ne: *mut nftnl_obj, attr: u16, str: *const c_char); - - pub fn nftnl_obj_get_data(ne: *mut nftnl_obj, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_obj_get(ne: *mut nftnl_obj, attr: u16) -> *const c_void; - - pub fn nftnl_obj_get_u8(ne: *mut nftnl_obj, attr: u16) -> u8; - - pub fn nftnl_obj_get_u16(obj: *mut nftnl_obj, attr: u16) -> u16; - - pub fn nftnl_obj_get_u32(ne: *mut nftnl_obj, attr: u16) -> u32; - - pub fn nftnl_obj_get_u64(obj: *mut nftnl_obj, attr: u16) -> u64; - - pub fn nftnl_obj_get_str(ne: *mut nftnl_obj, attr: u16) -> *const c_char; - - pub fn nftnl_obj_nlmsg_build_payload(nlh: *mut nlmsghdr, ne: *const nftnl_obj); - - pub fn nftnl_obj_nlmsg_parse(nlh: *const nlmsghdr, ne: *mut nftnl_obj) -> c_int; - - pub fn nftnl_obj_parse( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_parse_file( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_snprintf( - buf: *mut c_char, - size: usize, - ne: *const nftnl_obj, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_obj_fprintf(fp: *mut FILE, ne: *const nftnl_obj, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list(c_void); - -extern "C" { - pub fn nftnl_obj_list_alloc() -> *mut nftnl_obj_list; - - pub fn nftnl_obj_list_free(list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_is_empty(list: *mut nftnl_obj_list) -> c_int; - - pub fn nftnl_obj_list_add(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_add_tail(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_del(t: *mut nftnl_obj); - - pub fn nftnl_obj_list_foreach( - table_list: *mut nftnl_obj_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_obj, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list_iter(c_void); - -extern "C" { - pub fn nftnl_obj_list_iter_create(l: *mut nftnl_obj_list) -> *mut nftnl_obj_list_iter; - - pub fn nftnl_obj_list_iter_next(iter: *mut nftnl_obj_list_iter) -> *mut nftnl_obj; - - pub fn nftnl_obj_list_iter_destroy(iter: *mut nftnl_obj_list_iter); -} -#[repr(C)] -pub struct nftnl_rule(c_void); - -extern "C" { - pub fn nftnl_rule_alloc() -> *mut nftnl_rule; - - pub fn nftnl_rule_free(arg1: *const nftnl_rule); -} -pub const NFTNL_RULE_FAMILY: nftnl_rule_attr = 0; -pub const NFTNL_RULE_TABLE: nftnl_rule_attr = 1; -pub const NFTNL_RULE_CHAIN: nftnl_rule_attr = 2; -pub const NFTNL_RULE_HANDLE: nftnl_rule_attr = 3; -pub const NFTNL_RULE_COMPAT_PROTO: nftnl_rule_attr = 4; -pub const NFTNL_RULE_COMPAT_FLAGS: nftnl_rule_attr = 5; -pub const NFTNL_RULE_POSITION: nftnl_rule_attr = 6; -pub const NFTNL_RULE_USERDATA: nftnl_rule_attr = 7; -pub const NFTNL_RULE_ID: nftnl_rule_attr = 8; -pub const __NFTNL_RULE_MAX: nftnl_rule_attr = 9; -pub type nftnl_rule_attr = u32; -extern "C" { - pub fn nftnl_rule_unset(r: *mut nftnl_rule, attr: u16); - - pub fn nftnl_rule_is_set(r: *const nftnl_rule, attr: u16) -> bool; - - pub fn nftnl_rule_set(r: *mut nftnl_rule, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_rule_set_data( - r: *mut nftnl_rule, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_rule_set_u32(r: *mut nftnl_rule, attr: u16, val: u32); - - pub fn nftnl_rule_set_u64(r: *mut nftnl_rule, attr: u16, val: u64); - - pub fn nftnl_rule_set_str(r: *mut nftnl_rule, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_rule_get(r: *const nftnl_rule, attr: u16) -> *const c_void; - - pub fn nftnl_rule_get_data( - r: *const nftnl_rule, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_rule_get_str(r: *const nftnl_rule, attr: u16) -> *const c_char; - - pub fn nftnl_rule_get_u8(r: *const nftnl_rule, attr: u16) -> u8; - - pub fn nftnl_rule_get_u32(r: *const nftnl_rule, attr: u16) -> u32; - - pub fn nftnl_rule_get_u64(r: *const nftnl_rule, attr: u16) -> u64; - - pub fn nftnl_rule_add_expr(r: *mut nftnl_rule, expr: *mut nftnl_expr); - - pub fn nftnl_rule_cmp(r1: *const nftnl_rule, r2: *const nftnl_rule) -> bool; - - pub fn nftnl_rule_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *mut nftnl_rule); - - pub fn nftnl_rule_parse( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_parse_file( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_rule, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_rule_fprintf(fp: *mut FILE, r: *const nftnl_rule, type_: u32, flags: u32) - -> c_int; - - pub fn nftnl_rule_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_rule) -> c_int; - - pub fn nftnl_expr_foreach( - r: *mut nftnl_rule, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_expr, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_expr_iter(c_void); - -extern "C" { - pub fn nftnl_expr_iter_create(r: *const nftnl_rule) -> *mut nftnl_expr_iter; - - pub fn nftnl_expr_iter_next(iter: *mut nftnl_expr_iter) -> *mut nftnl_expr; - - pub fn nftnl_expr_iter_destroy(iter: *mut nftnl_expr_iter); -} -#[repr(C)] -pub struct nftnl_rule_list(c_void); - -extern "C" { - pub fn nftnl_rule_list_alloc() -> *mut nftnl_rule_list; - - pub fn nftnl_rule_list_free(list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_is_empty(list: *const nftnl_rule_list) -> c_int; - - pub fn nftnl_rule_list_add(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_add_tail(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_insert_at(r: *mut nftnl_rule, pos: *mut nftnl_rule); - - pub fn nftnl_rule_list_del(r: *mut nftnl_rule); - - pub fn nftnl_rule_list_foreach( - rule_list: *mut nftnl_rule_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_rule, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_rule_list_iter(c_void); - -extern "C" { - pub fn nftnl_rule_list_iter_create(l: *const nftnl_rule_list) -> *mut nftnl_rule_list_iter; - - pub fn nftnl_rule_list_iter_cur(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_next(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_destroy(iter: *const nftnl_rule_list_iter); -} -#[repr(C)] -pub struct nftnl_ruleset(c_void); - -extern "C" { - pub fn nftnl_ruleset_alloc() -> *mut nftnl_ruleset; - - pub fn nftnl_ruleset_free(r: *const nftnl_ruleset); -} -pub const NFTNL_RULESET_TABLELIST: u32 = 0; -pub const NFTNL_RULESET_CHAINLIST: u32 = 1; -pub const NFTNL_RULESET_SETLIST: u32 = 2; -pub const NFTNL_RULESET_RULELIST: u32 = 3; - -pub const NFTNL_RULESET_UNSPEC: nftnl_ruleset_type = 0; -pub const NFTNL_RULESET_RULESET: nftnl_ruleset_type = 1; -pub const NFTNL_RULESET_TABLE: nftnl_ruleset_type = 2; -pub const NFTNL_RULESET_CHAIN: nftnl_ruleset_type = 3; -pub const NFTNL_RULESET_RULE: nftnl_ruleset_type = 4; -pub const NFTNL_RULESET_SET: nftnl_ruleset_type = 5; -pub const NFTNL_RULESET_SET_ELEMS: nftnl_ruleset_type = 6; -pub type nftnl_ruleset_type = u32; -extern "C" { - pub fn nftnl_ruleset_is_set(r: *const nftnl_ruleset, attr: u16) -> bool; - - pub fn nftnl_ruleset_unset(r: *mut nftnl_ruleset, attr: u16); - - pub fn nftnl_ruleset_set(r: *mut nftnl_ruleset, attr: u16, data: *mut c_void); - - pub fn nftnl_ruleset_get(r: *const nftnl_ruleset, attr: u16) -> *mut c_void; -} -pub const NFTNL_RULESET_CTX_CMD: u32 = 0; -pub const NFTNL_RULESET_CTX_TYPE: u32 = 1; -pub const NFTNL_RULESET_CTX_TABLE: u32 = 2; -pub const NFTNL_RULESET_CTX_CHAIN: u32 = 3; -pub const NFTNL_RULESET_CTX_RULE: u32 = 4; -pub const NFTNL_RULESET_CTX_SET: u32 = 5; -pub const NFTNL_RULESET_CTX_DATA: u32 = 6; - -#[repr(C)] -pub struct nftnl_parse_ctx(c_void); - -extern "C" { - pub fn nftnl_ruleset_ctx_free(ctx: *const nftnl_parse_ctx); - - pub fn nftnl_ruleset_ctx_is_set(ctx: *const nftnl_parse_ctx, attr: u16) -> bool; - - pub fn nftnl_ruleset_ctx_get(ctx: *const nftnl_parse_ctx, attr: u16) -> *mut c_void; - - pub fn nftnl_ruleset_ctx_get_u32(ctx: *const nftnl_parse_ctx, attr: u16) -> u32; - - pub fn nftnl_ruleset_parse_file_cb( - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse_buffer_cb( - type_: nftnl_parse_type, - buffer: *const c_char, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_parse_file( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_snprintf( - buf: *mut c_char, - size: usize, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_ruleset_fprintf( - fp: *mut FILE, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_SET_TABLE: nftnl_set_attr = 0; -pub const NFTNL_SET_NAME: nftnl_set_attr = 1; -pub const NFTNL_SET_FLAGS: nftnl_set_attr = 2; -pub const NFTNL_SET_KEY_TYPE: nftnl_set_attr = 3; -pub const NFTNL_SET_KEY_LEN: nftnl_set_attr = 4; -pub const NFTNL_SET_DATA_TYPE: nftnl_set_attr = 5; -pub const NFTNL_SET_DATA_LEN: nftnl_set_attr = 6; -pub const NFTNL_SET_FAMILY: nftnl_set_attr = 7; -pub const NFTNL_SET_ID: nftnl_set_attr = 8; -pub const NFTNL_SET_POLICY: nftnl_set_attr = 9; -pub const NFTNL_SET_DESC_SIZE: nftnl_set_attr = 10; -pub const NFTNL_SET_TIMEOUT: nftnl_set_attr = 11; -pub const NFTNL_SET_GC_INTERVAL: nftnl_set_attr = 12; -pub const NFTNL_SET_USERDATA: nftnl_set_attr = 13; -pub const NFTNL_SET_OBJ_TYPE: nftnl_set_attr = 14; -pub const NFTNL_SET_HANDLE: nftnl_set_attr = 15; -pub const __NFTNL_SET_MAX: nftnl_set_attr = 16; -pub type nftnl_set_attr = u32; -#[repr(C)] -pub struct nftnl_set(c_void); - -extern "C" { - pub fn nftnl_set_alloc() -> *mut nftnl_set; - - pub fn nftnl_set_free(s: *const nftnl_set); - - pub fn nftnl_set_clone(set: *const nftnl_set) -> *mut nftnl_set; - - pub fn nftnl_set_is_set(s: *const nftnl_set, attr: u16) -> bool; - - pub fn nftnl_set_unset(s: *mut nftnl_set, attr: u16); - - pub fn nftnl_set_set(s: *mut nftnl_set, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_set_set_data( - s: *mut nftnl_set, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_set_u32(s: *mut nftnl_set, attr: u16, val: u32); - - pub fn nftnl_set_set_u64(s: *mut nftnl_set, attr: u16, val: u64); - - pub fn nftnl_set_set_str(s: *mut nftnl_set, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_get(s: *const nftnl_set, attr: u16) -> *const c_void; - - pub fn nftnl_set_get_data(s: *const nftnl_set, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_set_get_str(s: *const nftnl_set, attr: u16) -> *const c_char; - - pub fn nftnl_set_get_u32(s: *const nftnl_set, attr: u16) -> u32; - - pub fn nftnl_set_get_u64(s: *const nftnl_set, attr: u16) -> u64; - - pub fn nftnl_set_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_elems_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_fprintf(fp: *mut FILE, s: *const nftnl_set, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list(c_void); - -extern "C" { - pub fn nftnl_set_list_alloc() -> *mut nftnl_set_list; - - pub fn nftnl_set_list_free(list: *mut nftnl_set_list); - - pub fn nftnl_set_list_is_empty(list: *const nftnl_set_list) -> c_int; - - pub fn nftnl_set_list_add(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_add_tail(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_del(s: *mut nftnl_set); - - pub fn nftnl_set_list_foreach( - set_list: *mut nftnl_set_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_set, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list_iter(c_void); - -extern "C" { - pub fn nftnl_set_list_iter_create(l: *const nftnl_set_list) -> *mut nftnl_set_list_iter; - - pub fn nftnl_set_list_iter_cur(iter: *const nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_next(iter: *mut nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_destroy(iter: *const nftnl_set_list_iter); - - pub fn nftnl_set_parse( - s: *mut nftnl_set, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_parse_file( - s: *mut nftnl_set, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; -} -pub const NFTNL_SET_ELEM_FLAGS: u32 = 0; -pub const NFTNL_SET_ELEM_KEY: u32 = 1; -pub const NFTNL_SET_ELEM_VERDICT: u32 = 2; -pub const NFTNL_SET_ELEM_CHAIN: u32 = 3; -pub const NFTNL_SET_ELEM_DATA: u32 = 4; -pub const NFTNL_SET_ELEM_TIMEOUT: u32 = 5; -pub const NFTNL_SET_ELEM_EXPIRATION: u32 = 6; -pub const NFTNL_SET_ELEM_USERDATA: u32 = 7; -pub const NFTNL_SET_ELEM_EXPR: u32 = 8; -pub const NFTNL_SET_ELEM_OBJREF: u32 = 9; - -#[repr(C)] -pub struct nftnl_set_elem(c_void); - -extern "C" { - pub fn nftnl_set_elem_alloc() -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_free(s: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_clone(elem: *mut nftnl_set_elem) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_add(s: *mut nftnl_set, elem: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_unset(s: *mut nftnl_set_elem, attr: u16); - - pub fn nftnl_set_elem_set( - s: *mut nftnl_set_elem, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_elem_set_u32(s: *mut nftnl_set_elem, attr: u16, val: u32); - - pub fn nftnl_set_elem_set_u64(s: *mut nftnl_set_elem, attr: u16, val: u64); - - pub fn nftnl_set_elem_set_str(s: *mut nftnl_set_elem, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_elem_get( - s: *mut nftnl_set_elem, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_set_elem_get_str(s: *mut nftnl_set_elem, attr: u16) -> *const c_char; - - pub fn nftnl_set_elem_get_u32(s: *mut nftnl_set_elem, attr: u16) -> u32; - - pub fn nftnl_set_elem_get_u64(s: *mut nftnl_set_elem, attr: u16) -> u64; - - pub fn nftnl_set_elem_is_set(s: *const nftnl_set_elem, attr: u16) -> bool; - - pub fn nftnl_set_elems_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_elem_nlmsg_build_payload(nlh: *mut nlmsghdr, e: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_parse( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_parse_file( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_fprintf( - fp: *mut FILE, - se: *mut nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_foreach( - s: *mut nftnl_set, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_set_elem, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_elems_iter(c_void); - -extern "C" { - pub fn nftnl_set_elems_iter_create(s: *const nftnl_set) -> *mut nftnl_set_elems_iter; - - pub fn nftnl_set_elems_iter_cur(iter: *const nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_next(iter: *mut nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_destroy(iter: *mut nftnl_set_elems_iter); - - pub fn nftnl_set_elems_nlmsg_build_payload_iter( - nlh: *mut nlmsghdr, - iter: *mut nftnl_set_elems_iter, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_table(c_void); - -extern "C" { - pub fn nftnl_table_alloc() -> *mut nftnl_table; - - pub fn nftnl_table_free(arg1: *const nftnl_table); -} -pub const NFTNL_TABLE_NAME: nftnl_table_attr = 0; -pub const NFTNL_TABLE_FAMILY: nftnl_table_attr = 1; -pub const NFTNL_TABLE_FLAGS: nftnl_table_attr = 2; -pub const NFTNL_TABLE_USE: nftnl_table_attr = 3; -pub const NFTNL_TABLE_HANDLE: nftnl_table_attr = 4; -pub const __NFTNL_TABLE_MAX: nftnl_table_attr = 5; -pub type nftnl_table_attr = u32; -extern "C" { - pub fn nftnl_table_is_set(t: *const nftnl_table, attr: u16) -> bool; - - pub fn nftnl_table_unset(t: *mut nftnl_table, attr: u16); - - pub fn nftnl_table_set(t: *mut nftnl_table, attr: u16, data: *const c_void); - - pub fn nftnl_table_set_data( - t: *mut nftnl_table, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_table_get(t: *const nftnl_table, attr: u16) -> *const c_void; - - pub fn nftnl_table_get_data( - t: *const nftnl_table, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_table_set_u8(t: *mut nftnl_table, attr: u16, data: u8); - - pub fn nftnl_table_set_u32(t: *mut nftnl_table, attr: u16, data: u32); - - pub fn nftnl_table_set_u64(t: *mut nftnl_table, attr: u16, data: u64); - - pub fn nftnl_table_set_str(t: *mut nftnl_table, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_table_get_u8(t: *const nftnl_table, attr: u16) -> u8; - - pub fn nftnl_table_get_u32(t: *const nftnl_table, attr: u16) -> u32; - - pub fn nftnl_table_get_u64(t: *const nftnl_table, attr: u16) -> u64; - - pub fn nftnl_table_get_str(t: *const nftnl_table, attr: u16) -> *const c_char; - - pub fn nftnl_table_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_table); - - pub fn nftnl_table_parse( - t: *mut nftnl_table, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_parse_file( - t: *mut nftnl_table, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_fprintf( - fp: *mut FILE, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_table) -> c_int; -} -#[repr(C)] -pub struct nftnl_table_list(c_void); - -extern "C" { - pub fn nftnl_table_list_alloc() -> *mut nftnl_table_list; - - pub fn nftnl_table_list_free(list: *mut nftnl_table_list); - - pub fn nftnl_table_list_is_empty(list: *const nftnl_table_list) -> c_int; - - pub fn nftnl_table_list_foreach( - table_list: *mut nftnl_table_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_table, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_table_list_add(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_add_tail(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_del(r: *mut nftnl_table); -} -#[repr(C)] -pub struct nftnl_table_list_iter(c_void); - -extern "C" { - pub fn nftnl_table_list_iter_create(l: *const nftnl_table_list) -> *mut nftnl_table_list_iter; - - pub fn nftnl_table_list_iter_next(iter: *mut nftnl_table_list_iter) -> *mut nftnl_table; - - pub fn nftnl_table_list_iter_destroy(iter: *const nftnl_table_list_iter); -} -pub const NFTNL_TRACE_CHAIN: nftnl_trace_attr = 0; -pub const NFTNL_TRACE_FAMILY: nftnl_trace_attr = 1; -pub const NFTNL_TRACE_ID: nftnl_trace_attr = 2; -pub const NFTNL_TRACE_IIF: nftnl_trace_attr = 3; -pub const NFTNL_TRACE_IIFTYPE: nftnl_trace_attr = 4; -pub const NFTNL_TRACE_JUMP_TARGET: nftnl_trace_attr = 5; -pub const NFTNL_TRACE_OIF: nftnl_trace_attr = 6; -pub const NFTNL_TRACE_OIFTYPE: nftnl_trace_attr = 7; -pub const NFTNL_TRACE_MARK: nftnl_trace_attr = 8; -pub const NFTNL_TRACE_LL_HEADER: nftnl_trace_attr = 9; -pub const NFTNL_TRACE_NETWORK_HEADER: nftnl_trace_attr = 10; -pub const NFTNL_TRACE_TRANSPORT_HEADER: nftnl_trace_attr = 11; -pub const NFTNL_TRACE_TABLE: nftnl_trace_attr = 12; -pub const NFTNL_TRACE_TYPE: nftnl_trace_attr = 13; -pub const NFTNL_TRACE_RULE_HANDLE: nftnl_trace_attr = 14; -pub const NFTNL_TRACE_VERDICT: nftnl_trace_attr = 15; -pub const NFTNL_TRACE_NFPROTO: nftnl_trace_attr = 16; -pub const NFTNL_TRACE_POLICY: nftnl_trace_attr = 17; -pub const __NFTNL_TRACE_MAX: nftnl_trace_attr = 18; -pub type nftnl_trace_attr = u32; -#[repr(C)] -pub struct nftnl_trace(c_void); - -extern "C" { - pub fn nftnl_trace_alloc() -> *mut nftnl_trace; - - pub fn nftnl_trace_free(trace: *const nftnl_trace); - - pub fn nftnl_trace_is_set(trace: *const nftnl_trace, type_: u16) -> bool; - - pub fn nftnl_trace_get_data( - trace: *const nftnl_trace, - type_: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_trace_get_u16(trace: *const nftnl_trace, type_: u16) -> u16; - - pub fn nftnl_trace_get_u32(trace: *const nftnl_trace, type_: u16) -> u32; - - pub fn nftnl_trace_get_u64(trace: *const nftnl_trace, type_: u16) -> u64; - - pub fn nftnl_trace_get_str(trace: *const nftnl_trace, type_: u16) -> *const c_char; - - pub fn nftnl_trace_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_trace) -> c_int; -} -#[repr(C)] -pub struct nftnl_udata(c_void); - -#[repr(C)] -pub struct nftnl_udata_buf(c_void); - -extern "C" { - pub fn nftnl_udata_buf_alloc(data_size: u32) -> *mut nftnl_udata_buf; - - pub fn nftnl_udata_buf_free(buf: *const nftnl_udata_buf); - - pub fn nftnl_udata_buf_len(buf: *const nftnl_udata_buf) -> u32; - - pub fn nftnl_udata_buf_data(buf: *const nftnl_udata_buf) -> *mut c_void; - - pub fn nftnl_udata_buf_put(buf: *mut nftnl_udata_buf, data: *const c_void, len: u32); - - pub fn nftnl_udata_start(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_end(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_put( - buf: *mut nftnl_udata_buf, - type_: u8, - len: u32, - value: *const c_void, - ) -> bool; - - pub fn nftnl_udata_put_u32(buf: *mut nftnl_udata_buf, type_: u8, data: u32) -> bool; - - pub fn nftnl_udata_put_strz(buf: *mut nftnl_udata_buf, type_: u8, strz: *const c_char) -> bool; - - pub fn nftnl_udata_type(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_len(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_get(attr: *const nftnl_udata) -> *mut c_void; - - pub fn nftnl_udata_get_u32(attr: *const nftnl_udata) -> u32; - - pub fn nftnl_udata_next(attr: *const nftnl_udata) -> *mut nftnl_udata; -} -pub type nftnl_udata_cb_t = - Option<unsafe extern "C" fn(attr: *const nftnl_udata, data: *mut c_void) -> c_int>; -extern "C" { - pub fn nftnl_udata_parse( - data: *const c_void, - data_len: u32, - cb: nftnl_udata_cb_t, - cb_data: *mut c_void, - ) -> c_int; -} diff --git a/rustables-sys/src/nftnl_1_1_2.rs b/rustables-sys/src/nftnl_1_1_2.rs deleted file mode 100644 index 963f2f6..0000000 --- a/rustables-sys/src/nftnl_1_1_2.rs +++ /dev/null @@ -1,1333 +0,0 @@ -// automatically generated by rust-bindgen 0.49.0 - -use core::option::Option; -use libc::{c_char, c_int, c_void, iovec, nlmsghdr, FILE}; - -#[repr(C)] -pub struct nftnl_batch(c_void); - -extern "C" { - pub fn nftnl_batch_alloc(pg_size: u32, pg_overrun_size: u32) -> *mut nftnl_batch; - - pub fn nftnl_batch_update(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_free(batch: *mut nftnl_batch); - - pub fn nftnl_batch_buffer(batch: *mut nftnl_batch) -> *mut c_void; - - pub fn nftnl_batch_buffer_len(batch: *mut nftnl_batch) -> u32; - - pub fn nftnl_batch_iovec_len(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_iovec(batch: *mut nftnl_batch, iov: *mut iovec, iovlen: u32); -} -pub const NFTNL_PARSE_EBADINPUT: u32 = 0; -pub const NFTNL_PARSE_EMISSINGNODE: u32 = 1; -pub const NFTNL_PARSE_EBADTYPE: u32 = 2; -pub const NFTNL_PARSE_EOPNOTSUPP: u32 = 3; - -pub const NFTNL_OUTPUT_DEFAULT: nftnl_output_type = 0; -pub const NFTNL_OUTPUT_XML: nftnl_output_type = 1; -pub const NFTNL_OUTPUT_JSON: nftnl_output_type = 2; -pub type nftnl_output_type = u32; -pub const NFTNL_OF_EVENT_NEW: nftnl_output_flags = 1; -pub const NFTNL_OF_EVENT_DEL: nftnl_output_flags = 2; -pub const NFTNL_OF_EVENT_ANY: nftnl_output_flags = 3; -pub type nftnl_output_flags = u32; -pub const NFTNL_CMD_UNSPEC: nftnl_cmd_type = 0; -pub const NFTNL_CMD_ADD: nftnl_cmd_type = 1; -pub const NFTNL_CMD_INSERT: nftnl_cmd_type = 2; -pub const NFTNL_CMD_DELETE: nftnl_cmd_type = 3; -pub const NFTNL_CMD_REPLACE: nftnl_cmd_type = 4; -pub const NFTNL_CMD_FLUSH: nftnl_cmd_type = 5; -pub const NFTNL_CMD_MAX: nftnl_cmd_type = 6; -pub type nftnl_cmd_type = u32; -pub const NFTNL_PARSE_NONE: nftnl_parse_type = 0; -pub const NFTNL_PARSE_XML: nftnl_parse_type = 1; -pub const NFTNL_PARSE_JSON: nftnl_parse_type = 2; -pub const NFTNL_PARSE_MAX: nftnl_parse_type = 3; -pub type nftnl_parse_type = u32; -#[repr(C)] -pub struct nftnl_parse_err(c_void); - -extern "C" { - pub fn nftnl_nlmsg_build_hdr( - buf: *mut c_char, - type_: u16, - family: u16, - flags: u16, - seq: u32, - ) -> *mut nlmsghdr; - - pub fn nftnl_parse_err_alloc() -> *mut nftnl_parse_err; - - pub fn nftnl_parse_err_free(arg1: *mut nftnl_parse_err); - - pub fn nftnl_parse_perror(str: *const c_char, err: *mut nftnl_parse_err) -> c_int; - - pub fn nftnl_batch_is_supported() -> c_int; - - pub fn nftnl_batch_begin(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; - - pub fn nftnl_batch_end(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; -} -#[repr(C)] -pub struct nftnl_chain(c_void); - -extern "C" { - pub fn nftnl_chain_alloc() -> *mut nftnl_chain; - - pub fn nftnl_chain_free(arg1: *const nftnl_chain); -} -pub const NFTNL_CHAIN_NAME: nftnl_chain_attr = 0; -pub const NFTNL_CHAIN_FAMILY: nftnl_chain_attr = 1; -pub const NFTNL_CHAIN_TABLE: nftnl_chain_attr = 2; -pub const NFTNL_CHAIN_HOOKNUM: nftnl_chain_attr = 3; -pub const NFTNL_CHAIN_PRIO: nftnl_chain_attr = 4; -pub const NFTNL_CHAIN_POLICY: nftnl_chain_attr = 5; -pub const NFTNL_CHAIN_USE: nftnl_chain_attr = 6; -pub const NFTNL_CHAIN_BYTES: nftnl_chain_attr = 7; -pub const NFTNL_CHAIN_PACKETS: nftnl_chain_attr = 8; -pub const NFTNL_CHAIN_HANDLE: nftnl_chain_attr = 9; -pub const NFTNL_CHAIN_TYPE: nftnl_chain_attr = 10; -pub const NFTNL_CHAIN_DEV: nftnl_chain_attr = 11; -pub const __NFTNL_CHAIN_MAX: nftnl_chain_attr = 12; -pub type nftnl_chain_attr = u32; -extern "C" { - pub fn nftnl_chain_is_set(c: *const nftnl_chain, attr: u16) -> bool; - - pub fn nftnl_chain_unset(c: *mut nftnl_chain, attr: u16); - - pub fn nftnl_chain_set(t: *mut nftnl_chain, attr: u16, data: *const c_void); - - pub fn nftnl_chain_set_data( - t: *mut nftnl_chain, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_chain_set_u8(t: *mut nftnl_chain, attr: u16, data: u8); - - pub fn nftnl_chain_set_u32(t: *mut nftnl_chain, attr: u16, data: u32); - - pub fn nftnl_chain_set_s32(t: *mut nftnl_chain, attr: u16, data: i32); - - pub fn nftnl_chain_set_u64(t: *mut nftnl_chain, attr: u16, data: u64); - - pub fn nftnl_chain_set_str(t: *mut nftnl_chain, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_chain_get(c: *const nftnl_chain, attr: u16) -> *const c_void; - - pub fn nftnl_chain_get_data( - c: *const nftnl_chain, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_chain_get_str(c: *const nftnl_chain, attr: u16) -> *const c_char; - - pub fn nftnl_chain_get_u8(c: *const nftnl_chain, attr: u16) -> u8; - - pub fn nftnl_chain_get_u32(c: *const nftnl_chain, attr: u16) -> u32; - - pub fn nftnl_chain_get_s32(c: *const nftnl_chain, attr: u16) -> i32; - - pub fn nftnl_chain_get_u64(c: *const nftnl_chain, attr: u16) -> u64; - - pub fn nftnl_chain_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_chain); - - pub fn nftnl_chain_parse( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_parse_file( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_fprintf( - fp: *mut FILE, - c: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_chain) -> c_int; -} -#[repr(C)] -pub struct nftnl_chain_list(c_void); - -extern "C" { - pub fn nftnl_chain_list_alloc() -> *mut nftnl_chain_list; - - pub fn nftnl_chain_list_free(list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_is_empty(list: *const nftnl_chain_list) -> c_int; - - pub fn nftnl_chain_list_foreach( - chain_list: *mut nftnl_chain_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_chain, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_chain_list_add(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_add_tail(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_del(c: *mut nftnl_chain); -} -#[repr(C)] -pub struct nftnl_chain_list_iter(c_void); - -extern "C" { - pub fn nftnl_chain_list_iter_create(l: *const nftnl_chain_list) -> *mut nftnl_chain_list_iter; - - pub fn nftnl_chain_list_iter_next(iter: *mut nftnl_chain_list_iter) -> *mut nftnl_chain; - - pub fn nftnl_chain_list_iter_destroy(iter: *mut nftnl_chain_list_iter); -} -#[repr(C)] -pub struct nftnl_expr(c_void); - -pub const NFTNL_EXPR_NAME: u32 = 0; -pub const NFTNL_EXPR_BASE: u32 = 1; - -extern "C" { - pub fn nftnl_expr_alloc(name: *const c_char) -> *mut nftnl_expr; - - pub fn nftnl_expr_free(expr: *const nftnl_expr); - - pub fn nftnl_expr_is_set(expr: *const nftnl_expr, type_: u16) -> bool; - - pub fn nftnl_expr_set( - expr: *mut nftnl_expr, - type_: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_expr_set_u8(expr: *mut nftnl_expr, type_: u16, data: u8); - - pub fn nftnl_expr_set_u16(expr: *mut nftnl_expr, type_: u16, data: u16); - - pub fn nftnl_expr_set_u32(expr: *mut nftnl_expr, type_: u16, data: u32); - - pub fn nftnl_expr_set_u64(expr: *mut nftnl_expr, type_: u16, data: u64); - - pub fn nftnl_expr_set_str(expr: *mut nftnl_expr, type_: u16, str: *const c_char) -> c_int; - - pub fn nftnl_expr_get(expr: *const nftnl_expr, type_: u16, data_len: *mut u32) - -> *const c_void; - - pub fn nftnl_expr_get_u8(expr: *const nftnl_expr, type_: u16) -> u8; - - pub fn nftnl_expr_get_u16(expr: *const nftnl_expr, type_: u16) -> u16; - - pub fn nftnl_expr_get_u32(expr: *const nftnl_expr, type_: u16) -> u32; - - pub fn nftnl_expr_get_u64(expr: *const nftnl_expr, type_: u16) -> u64; - - pub fn nftnl_expr_get_str(expr: *const nftnl_expr, type_: u16) -> *const c_char; - - pub fn nftnl_expr_snprintf( - buf: *mut c_char, - buflen: usize, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_expr_fprintf( - fp: *mut FILE, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_EXPR_PAYLOAD_DREG: u32 = 1; -pub const NFTNL_EXPR_PAYLOAD_BASE: u32 = 2; -pub const NFTNL_EXPR_PAYLOAD_OFFSET: u32 = 3; -pub const NFTNL_EXPR_PAYLOAD_LEN: u32 = 4; -pub const NFTNL_EXPR_PAYLOAD_SREG: u32 = 5; -pub const NFTNL_EXPR_PAYLOAD_CSUM_TYPE: u32 = 6; -pub const NFTNL_EXPR_PAYLOAD_CSUM_OFFSET: u32 = 7; -pub const NFTNL_EXPR_PAYLOAD_FLAGS: u32 = 8; - -pub const NFTNL_EXPR_NG_DREG: u32 = 1; -pub const NFTNL_EXPR_NG_MODULUS: u32 = 2; -pub const NFTNL_EXPR_NG_TYPE: u32 = 3; -pub const NFTNL_EXPR_NG_OFFSET: u32 = 4; -pub const NFTNL_EXPR_NG_SET_NAME: u32 = 5; -pub const NFTNL_EXPR_NG_SET_ID: u32 = 6; - -pub const NFTNL_EXPR_META_KEY: u32 = 1; -pub const NFTNL_EXPR_META_DREG: u32 = 2; -pub const NFTNL_EXPR_META_SREG: u32 = 3; - -pub const NFTNL_EXPR_RT_KEY: u32 = 1; -pub const NFTNL_EXPR_RT_DREG: u32 = 2; - -pub const NFTNL_EXPR_SOCKET_KEY: u32 = 1; -pub const NFTNL_EXPR_SOCKET_DREG: u32 = 2; - -pub const NFTNL_EXPR_TUNNEL_KEY: u32 = 1; -pub const NFTNL_EXPR_TUNNEL_DREG: u32 = 2; - -pub const NFTNL_EXPR_CMP_SREG: u32 = 1; -pub const NFTNL_EXPR_CMP_OP: u32 = 2; -pub const NFTNL_EXPR_CMP_DATA: u32 = 3; - -pub const NFTNL_EXPR_RANGE_SREG: u32 = 1; -pub const NFTNL_EXPR_RANGE_OP: u32 = 2; -pub const NFTNL_EXPR_RANGE_FROM_DATA: u32 = 3; -pub const NFTNL_EXPR_RANGE_TO_DATA: u32 = 4; - -pub const NFTNL_EXPR_IMM_DREG: u32 = 1; -pub const NFTNL_EXPR_IMM_DATA: u32 = 2; -pub const NFTNL_EXPR_IMM_VERDICT: u32 = 3; -pub const NFTNL_EXPR_IMM_CHAIN: u32 = 4; - -pub const NFTNL_EXPR_CTR_PACKETS: u32 = 1; -pub const NFTNL_EXPR_CTR_BYTES: u32 = 2; - -pub const NFTNL_EXPR_CONNLIMIT_COUNT: u32 = 1; -pub const NFTNL_EXPR_CONNLIMIT_FLAGS: u32 = 2; - -pub const NFTNL_EXPR_BITWISE_SREG: u32 = 1; -pub const NFTNL_EXPR_BITWISE_DREG: u32 = 2; -pub const NFTNL_EXPR_BITWISE_LEN: u32 = 3; -pub const NFTNL_EXPR_BITWISE_MASK: u32 = 4; -pub const NFTNL_EXPR_BITWISE_XOR: u32 = 5; - -pub const NFTNL_EXPR_TG_NAME: u32 = 1; -pub const NFTNL_EXPR_TG_REV: u32 = 2; -pub const NFTNL_EXPR_TG_INFO: u32 = 3; - -pub const NFTNL_EXPR_MT_NAME: u32 = 1; -pub const NFTNL_EXPR_MT_REV: u32 = 2; -pub const NFTNL_EXPR_MT_INFO: u32 = 3; - -pub const NFTNL_EXPR_NAT_TYPE: u32 = 1; -pub const NFTNL_EXPR_NAT_FAMILY: u32 = 2; -pub const NFTNL_EXPR_NAT_REG_ADDR_MIN: u32 = 3; -pub const NFTNL_EXPR_NAT_REG_ADDR_MAX: u32 = 4; -pub const NFTNL_EXPR_NAT_REG_PROTO_MIN: u32 = 5; -pub const NFTNL_EXPR_NAT_REG_PROTO_MAX: u32 = 6; -pub const NFTNL_EXPR_NAT_FLAGS: u32 = 7; - -pub const NFTNL_EXPR_TPROXY_FAMILY: u32 = 1; -pub const NFTNL_EXPR_TPROXY_REG_ADDR: u32 = 2; -pub const NFTNL_EXPR_TPROXY_REG_PORT: u32 = 3; - -pub const NFTNL_EXPR_LOOKUP_SREG: u32 = 1; -pub const NFTNL_EXPR_LOOKUP_DREG: u32 = 2; -pub const NFTNL_EXPR_LOOKUP_SET: u32 = 3; -pub const NFTNL_EXPR_LOOKUP_SET_ID: u32 = 4; -pub const NFTNL_EXPR_LOOKUP_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_DYNSET_SREG_KEY: u32 = 1; -pub const NFTNL_EXPR_DYNSET_SREG_DATA: u32 = 2; -pub const NFTNL_EXPR_DYNSET_OP: u32 = 3; -pub const NFTNL_EXPR_DYNSET_TIMEOUT: u32 = 4; -pub const NFTNL_EXPR_DYNSET_SET_NAME: u32 = 5; -pub const NFTNL_EXPR_DYNSET_SET_ID: u32 = 6; -pub const NFTNL_EXPR_DYNSET_EXPR: u32 = 7; - -pub const NFTNL_EXPR_LOG_PREFIX: u32 = 1; -pub const NFTNL_EXPR_LOG_GROUP: u32 = 2; -pub const NFTNL_EXPR_LOG_SNAPLEN: u32 = 3; -pub const NFTNL_EXPR_LOG_QTHRESHOLD: u32 = 4; -pub const NFTNL_EXPR_LOG_LEVEL: u32 = 5; -pub const NFTNL_EXPR_LOG_FLAGS: u32 = 6; - -pub const NFTNL_EXPR_EXTHDR_DREG: u32 = 1; -pub const NFTNL_EXPR_EXTHDR_TYPE: u32 = 2; -pub const NFTNL_EXPR_EXTHDR_OFFSET: u32 = 3; -pub const NFTNL_EXPR_EXTHDR_LEN: u32 = 4; -pub const NFTNL_EXPR_EXTHDR_FLAGS: u32 = 5; -pub const NFTNL_EXPR_EXTHDR_OP: u32 = 6; -pub const NFTNL_EXPR_EXTHDR_SREG: u32 = 7; - -pub const NFTNL_EXPR_CT_DREG: u32 = 1; -pub const NFTNL_EXPR_CT_KEY: u32 = 2; -pub const NFTNL_EXPR_CT_DIR: u32 = 3; -pub const NFTNL_EXPR_CT_SREG: u32 = 4; - -pub const NFTNL_EXPR_BYTEORDER_DREG: u32 = 1; -pub const NFTNL_EXPR_BYTEORDER_SREG: u32 = 2; -pub const NFTNL_EXPR_BYTEORDER_OP: u32 = 3; -pub const NFTNL_EXPR_BYTEORDER_LEN: u32 = 4; -pub const NFTNL_EXPR_BYTEORDER_SIZE: u32 = 5; - -pub const NFTNL_EXPR_LIMIT_RATE: u32 = 1; -pub const NFTNL_EXPR_LIMIT_UNIT: u32 = 2; -pub const NFTNL_EXPR_LIMIT_BURST: u32 = 3; -pub const NFTNL_EXPR_LIMIT_TYPE: u32 = 4; -pub const NFTNL_EXPR_LIMIT_FLAGS: u32 = 5; - -pub const NFTNL_EXPR_REJECT_TYPE: u32 = 1; -pub const NFTNL_EXPR_REJECT_CODE: u32 = 2; - -pub const NFTNL_EXPR_QUEUE_NUM: u32 = 1; -pub const NFTNL_EXPR_QUEUE_TOTAL: u32 = 2; -pub const NFTNL_EXPR_QUEUE_FLAGS: u32 = 3; -pub const NFTNL_EXPR_QUEUE_SREG_QNUM: u32 = 4; - -pub const NFTNL_EXPR_QUOTA_BYTES: u32 = 1; -pub const NFTNL_EXPR_QUOTA_FLAGS: u32 = 2; -pub const NFTNL_EXPR_QUOTA_CONSUMED: u32 = 3; - -pub const NFTNL_EXPR_MASQ_FLAGS: u32 = 1; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MIN: u32 = 2; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MAX: u32 = 3; - -pub const NFTNL_EXPR_REDIR_REG_PROTO_MIN: u32 = 1; -pub const NFTNL_EXPR_REDIR_REG_PROTO_MAX: u32 = 2; -pub const NFTNL_EXPR_REDIR_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_DUP_SREG_ADDR: u32 = 1; -pub const NFTNL_EXPR_DUP_SREG_DEV: u32 = 2; - -pub const NFTNL_EXPR_FLOW_TABLE_NAME: u32 = 1; - -pub const NFTNL_EXPR_FWD_SREG_DEV: u32 = 1; -pub const NFTNL_EXPR_FWD_SREG_ADDR: u32 = 2; -pub const NFTNL_EXPR_FWD_NFPROTO: u32 = 3; - -pub const NFTNL_EXPR_HASH_SREG: u32 = 1; -pub const NFTNL_EXPR_HASH_DREG: u32 = 2; -pub const NFTNL_EXPR_HASH_LEN: u32 = 3; -pub const NFTNL_EXPR_HASH_MODULUS: u32 = 4; -pub const NFTNL_EXPR_HASH_SEED: u32 = 5; -pub const NFTNL_EXPR_HASH_OFFSET: u32 = 6; -pub const NFTNL_EXPR_HASH_TYPE: u32 = 7; -pub const NFTNL_EXPR_HASH_SET_NAME: u32 = 8; -pub const NFTNL_EXPR_HASH_SET_ID: u32 = 9; - -pub const NFTNL_EXPR_FIB_DREG: u32 = 1; -pub const NFTNL_EXPR_FIB_RESULT: u32 = 2; -pub const NFTNL_EXPR_FIB_FLAGS: u32 = 3; - -pub const NFTNL_EXPR_OBJREF_IMM_TYPE: u32 = 1; -pub const NFTNL_EXPR_OBJREF_IMM_NAME: u32 = 2; -pub const NFTNL_EXPR_OBJREF_SET_SREG: u32 = 3; -pub const NFTNL_EXPR_OBJREF_SET_NAME: u32 = 4; -pub const NFTNL_EXPR_OBJREF_SET_ID: u32 = 5; - -pub const NFTNL_EXPR_OSF_DREG: u32 = 1; -pub const NFTNL_EXPR_OSF_TTL: u32 = 2; - -pub const NFTNL_EXPR_XFRM_DREG: u32 = 1; -pub const NFTNL_EXPR_XFRM_SREG: u32 = 2; -pub const NFTNL_EXPR_XFRM_KEY: u32 = 3; -pub const NFTNL_EXPR_XFRM_DIR: u32 = 4; -pub const NFTNL_EXPR_XFRM_SPNUM: u32 = 5; - -#[repr(C)] -pub struct nftnl_gen(c_void); - -extern "C" { - pub fn nftnl_gen_alloc() -> *mut nftnl_gen; - - pub fn nftnl_gen_free(arg1: *const nftnl_gen); -} -pub const NFTNL_GEN_ID: u32 = 0; -pub const __NFTNL_GEN_MAX: u32 = 1; - -extern "C" { - pub fn nftnl_gen_is_set(gen: *const nftnl_gen, attr: u16) -> bool; - - pub fn nftnl_gen_unset(gen: *mut nftnl_gen, attr: u16); - - pub fn nftnl_gen_set(gen: *mut nftnl_gen, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_gen_set_data( - gen: *mut nftnl_gen, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_gen_get(gen: *const nftnl_gen, attr: u16) -> *const c_void; - - pub fn nftnl_gen_get_data( - gen: *const nftnl_gen, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_gen_set_u32(gen: *mut nftnl_gen, attr: u16, data: u32); - - pub fn nftnl_gen_get_u32(gen: *const nftnl_gen, attr: u16) -> u32; - - pub fn nftnl_gen_nlmsg_parse(nlh: *const nlmsghdr, gen: *mut nftnl_gen) -> c_int; - - pub fn nftnl_gen_snprintf( - buf: *mut c_char, - size: usize, - gen: *const nftnl_gen, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_gen_fprintf(fp: *mut FILE, gen: *const nftnl_gen, type_: u32, flags: u32) - -> c_int; -} -pub const NFTNL_OBJ_TABLE: u32 = 0; -pub const NFTNL_OBJ_NAME: u32 = 1; -pub const NFTNL_OBJ_TYPE: u32 = 2; -pub const NFTNL_OBJ_FAMILY: u32 = 3; -pub const NFTNL_OBJ_USE: u32 = 4; -pub const NFTNL_OBJ_HANDLE: u32 = 5; -pub const NFTNL_OBJ_BASE: u32 = 16; -pub const __NFTNL_OBJ_MAX: u32 = 17; - -pub const NFTNL_OBJ_CTR_PKTS: u32 = 16; -pub const NFTNL_OBJ_CTR_BYTES: u32 = 17; - -pub const NFTNL_OBJ_QUOTA_BYTES: u32 = 16; -pub const NFTNL_OBJ_QUOTA_CONSUMED: u32 = 17; -pub const NFTNL_OBJ_QUOTA_FLAGS: u32 = 18; - -pub const NFTNL_OBJ_CT_HELPER_NAME: u32 = 16; -pub const NFTNL_OBJ_CT_HELPER_L3PROTO: u32 = 17; -pub const NFTNL_OBJ_CT_HELPER_L4PROTO: u32 = 18; - -pub const NFTNL_CTTIMEOUT_TCP_SYN_SENT: nftnl_cttimeout_array_tcp = 0; -pub const NFTNL_CTTIMEOUT_TCP_SYN_RECV: nftnl_cttimeout_array_tcp = 1; -pub const NFTNL_CTTIMEOUT_TCP_ESTABLISHED: nftnl_cttimeout_array_tcp = 2; -pub const NFTNL_CTTIMEOUT_TCP_FIN_WAIT: nftnl_cttimeout_array_tcp = 3; -pub const NFTNL_CTTIMEOUT_TCP_CLOSE_WAIT: nftnl_cttimeout_array_tcp = 4; -pub const NFTNL_CTTIMEOUT_TCP_LAST_ACK: nftnl_cttimeout_array_tcp = 5; -pub const NFTNL_CTTIMEOUT_TCP_TIME_WAIT: nftnl_cttimeout_array_tcp = 6; -pub const NFTNL_CTTIMEOUT_TCP_CLOSE: nftnl_cttimeout_array_tcp = 7; -pub const NFTNL_CTTIMEOUT_TCP_SYN_SENT2: nftnl_cttimeout_array_tcp = 8; -pub const NFTNL_CTTIMEOUT_TCP_RETRANS: nftnl_cttimeout_array_tcp = 9; -pub const NFTNL_CTTIMEOUT_TCP_UNACK: nftnl_cttimeout_array_tcp = 10; -pub const NFTNL_CTTIMEOUT_TCP_MAX: nftnl_cttimeout_array_tcp = 11; -pub type nftnl_cttimeout_array_tcp = u32; -pub const NFTNL_CTTIMEOUT_UDP_UNREPLIED: nftnl_cttimeout_array_udp = 0; -pub const NFTNL_CTTIMEOUT_UDP_REPLIED: nftnl_cttimeout_array_udp = 1; -pub const NFTNL_CTTIMEOUT_UDP_MAX: nftnl_cttimeout_array_udp = 2; -pub type nftnl_cttimeout_array_udp = u32; -pub const NFTNL_OBJ_CT_TIMEOUT_L3PROTO: u32 = 16; -pub const NFTNL_OBJ_CT_TIMEOUT_L4PROTO: u32 = 17; -pub const NFTNL_OBJ_CT_TIMEOUT_ARRAY: u32 = 18; - -pub const NFTNL_OBJ_LIMIT_RATE: u32 = 16; -pub const NFTNL_OBJ_LIMIT_UNIT: u32 = 17; -pub const NFTNL_OBJ_LIMIT_BURST: u32 = 18; -pub const NFTNL_OBJ_LIMIT_TYPE: u32 = 19; -pub const NFTNL_OBJ_LIMIT_FLAGS: u32 = 20; - -pub const NFTNL_OBJ_TUNNEL_ID: u32 = 16; -pub const NFTNL_OBJ_TUNNEL_IPV4_SRC: u32 = 17; -pub const NFTNL_OBJ_TUNNEL_IPV4_DST: u32 = 18; -pub const NFTNL_OBJ_TUNNEL_IPV6_SRC: u32 = 19; -pub const NFTNL_OBJ_TUNNEL_IPV6_DST: u32 = 20; -pub const NFTNL_OBJ_TUNNEL_IPV6_FLOWLABEL: u32 = 21; -pub const NFTNL_OBJ_TUNNEL_SPORT: u32 = 22; -pub const NFTNL_OBJ_TUNNEL_DPORT: u32 = 23; -pub const NFTNL_OBJ_TUNNEL_FLAGS: u32 = 24; -pub const NFTNL_OBJ_TUNNEL_TOS: u32 = 25; -pub const NFTNL_OBJ_TUNNEL_TTL: u32 = 26; -pub const NFTNL_OBJ_TUNNEL_VXLAN_GBP: u32 = 27; -pub const NFTNL_OBJ_TUNNEL_ERSPAN_VERSION: u32 = 28; -pub const NFTNL_OBJ_TUNNEL_ERSPAN_V1_INDEX: u32 = 29; -pub const NFTNL_OBJ_TUNNEL_ERSPAN_V2_HWID: u32 = 30; -pub const NFTNL_OBJ_TUNNEL_ERSPAN_V2_DIR: u32 = 31; - -pub const NFTNL_OBJ_SECMARK_CTX: u32 = 16; - -#[repr(C)] -pub struct nftnl_obj(c_void); - -extern "C" { - pub fn nftnl_obj_alloc() -> *mut nftnl_obj; - - pub fn nftnl_obj_free(ne: *const nftnl_obj); - - pub fn nftnl_obj_is_set(ne: *const nftnl_obj, attr: u16) -> bool; - - pub fn nftnl_obj_unset(ne: *mut nftnl_obj, attr: u16); - - pub fn nftnl_obj_set_data(ne: *mut nftnl_obj, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_obj_set(ne: *mut nftnl_obj, attr: u16, data: *const c_void); - - pub fn nftnl_obj_set_u8(ne: *mut nftnl_obj, attr: u16, val: u8); - - pub fn nftnl_obj_set_u16(ne: *mut nftnl_obj, attr: u16, val: u16); - - pub fn nftnl_obj_set_u32(ne: *mut nftnl_obj, attr: u16, val: u32); - - pub fn nftnl_obj_set_u64(obj: *mut nftnl_obj, attr: u16, val: u64); - - pub fn nftnl_obj_set_str(ne: *mut nftnl_obj, attr: u16, str: *const c_char); - - pub fn nftnl_obj_get_data(ne: *mut nftnl_obj, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_obj_get(ne: *mut nftnl_obj, attr: u16) -> *const c_void; - - pub fn nftnl_obj_get_u8(ne: *mut nftnl_obj, attr: u16) -> u8; - - pub fn nftnl_obj_get_u16(obj: *mut nftnl_obj, attr: u16) -> u16; - - pub fn nftnl_obj_get_u32(ne: *mut nftnl_obj, attr: u16) -> u32; - - pub fn nftnl_obj_get_u64(obj: *mut nftnl_obj, attr: u16) -> u64; - - pub fn nftnl_obj_get_str(ne: *mut nftnl_obj, attr: u16) -> *const c_char; - - pub fn nftnl_obj_nlmsg_build_payload(nlh: *mut nlmsghdr, ne: *const nftnl_obj); - - pub fn nftnl_obj_nlmsg_parse(nlh: *const nlmsghdr, ne: *mut nftnl_obj) -> c_int; - - pub fn nftnl_obj_parse( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_parse_file( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_snprintf( - buf: *mut c_char, - size: usize, - ne: *const nftnl_obj, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_obj_fprintf(fp: *mut FILE, ne: *const nftnl_obj, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list(c_void); - -extern "C" { - pub fn nftnl_obj_list_alloc() -> *mut nftnl_obj_list; - - pub fn nftnl_obj_list_free(list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_is_empty(list: *mut nftnl_obj_list) -> c_int; - - pub fn nftnl_obj_list_add(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_add_tail(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_del(t: *mut nftnl_obj); - - pub fn nftnl_obj_list_foreach( - table_list: *mut nftnl_obj_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_obj, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list_iter(c_void); - -extern "C" { - pub fn nftnl_obj_list_iter_create(l: *mut nftnl_obj_list) -> *mut nftnl_obj_list_iter; - - pub fn nftnl_obj_list_iter_next(iter: *mut nftnl_obj_list_iter) -> *mut nftnl_obj; - - pub fn nftnl_obj_list_iter_destroy(iter: *mut nftnl_obj_list_iter); -} -#[repr(C)] -pub struct nftnl_rule(c_void); - -extern "C" { - pub fn nftnl_rule_alloc() -> *mut nftnl_rule; - - pub fn nftnl_rule_free(arg1: *const nftnl_rule); -} -pub const NFTNL_RULE_FAMILY: nftnl_rule_attr = 0; -pub const NFTNL_RULE_TABLE: nftnl_rule_attr = 1; -pub const NFTNL_RULE_CHAIN: nftnl_rule_attr = 2; -pub const NFTNL_RULE_HANDLE: nftnl_rule_attr = 3; -pub const NFTNL_RULE_COMPAT_PROTO: nftnl_rule_attr = 4; -pub const NFTNL_RULE_COMPAT_FLAGS: nftnl_rule_attr = 5; -pub const NFTNL_RULE_POSITION: nftnl_rule_attr = 6; -pub const NFTNL_RULE_USERDATA: nftnl_rule_attr = 7; -pub const NFTNL_RULE_ID: nftnl_rule_attr = 8; -pub const __NFTNL_RULE_MAX: nftnl_rule_attr = 9; -pub type nftnl_rule_attr = u32; -extern "C" { - pub fn nftnl_rule_unset(r: *mut nftnl_rule, attr: u16); - - pub fn nftnl_rule_is_set(r: *const nftnl_rule, attr: u16) -> bool; - - pub fn nftnl_rule_set(r: *mut nftnl_rule, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_rule_set_data( - r: *mut nftnl_rule, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_rule_set_u32(r: *mut nftnl_rule, attr: u16, val: u32); - - pub fn nftnl_rule_set_u64(r: *mut nftnl_rule, attr: u16, val: u64); - - pub fn nftnl_rule_set_str(r: *mut nftnl_rule, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_rule_get(r: *const nftnl_rule, attr: u16) -> *const c_void; - - pub fn nftnl_rule_get_data( - r: *const nftnl_rule, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_rule_get_str(r: *const nftnl_rule, attr: u16) -> *const c_char; - - pub fn nftnl_rule_get_u8(r: *const nftnl_rule, attr: u16) -> u8; - - pub fn nftnl_rule_get_u32(r: *const nftnl_rule, attr: u16) -> u32; - - pub fn nftnl_rule_get_u64(r: *const nftnl_rule, attr: u16) -> u64; - - pub fn nftnl_rule_add_expr(r: *mut nftnl_rule, expr: *mut nftnl_expr); - - pub fn nftnl_rule_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *mut nftnl_rule); - - pub fn nftnl_rule_parse( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_parse_file( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_rule, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_rule_fprintf(fp: *mut FILE, r: *const nftnl_rule, type_: u32, flags: u32) - -> c_int; - - pub fn nftnl_rule_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_rule) -> c_int; - - pub fn nftnl_expr_foreach( - r: *mut nftnl_rule, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_expr, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_expr_iter(c_void); - -extern "C" { - pub fn nftnl_expr_iter_create(r: *const nftnl_rule) -> *mut nftnl_expr_iter; - - pub fn nftnl_expr_iter_next(iter: *mut nftnl_expr_iter) -> *mut nftnl_expr; - - pub fn nftnl_expr_iter_destroy(iter: *mut nftnl_expr_iter); -} -#[repr(C)] -pub struct nftnl_rule_list(c_void); - -extern "C" { - pub fn nftnl_rule_list_alloc() -> *mut nftnl_rule_list; - - pub fn nftnl_rule_list_free(list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_is_empty(list: *const nftnl_rule_list) -> c_int; - - pub fn nftnl_rule_list_add(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_add_tail(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_insert_at(r: *mut nftnl_rule, pos: *mut nftnl_rule); - - pub fn nftnl_rule_list_del(r: *mut nftnl_rule); - - pub fn nftnl_rule_list_foreach( - rule_list: *mut nftnl_rule_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_rule, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_rule_list_iter(c_void); - -extern "C" { - pub fn nftnl_rule_list_iter_create(l: *const nftnl_rule_list) -> *mut nftnl_rule_list_iter; - - pub fn nftnl_rule_list_iter_cur(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_next(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_destroy(iter: *const nftnl_rule_list_iter); -} -#[repr(C)] -pub struct nftnl_ruleset(c_void); - -extern "C" { - pub fn nftnl_ruleset_alloc() -> *mut nftnl_ruleset; - - pub fn nftnl_ruleset_free(r: *const nftnl_ruleset); -} -pub const NFTNL_RULESET_TABLELIST: u32 = 0; -pub const NFTNL_RULESET_CHAINLIST: u32 = 1; -pub const NFTNL_RULESET_SETLIST: u32 = 2; -pub const NFTNL_RULESET_RULELIST: u32 = 3; - -pub const NFTNL_RULESET_UNSPEC: nftnl_ruleset_type = 0; -pub const NFTNL_RULESET_RULESET: nftnl_ruleset_type = 1; -pub const NFTNL_RULESET_TABLE: nftnl_ruleset_type = 2; -pub const NFTNL_RULESET_CHAIN: nftnl_ruleset_type = 3; -pub const NFTNL_RULESET_RULE: nftnl_ruleset_type = 4; -pub const NFTNL_RULESET_SET: nftnl_ruleset_type = 5; -pub const NFTNL_RULESET_SET_ELEMS: nftnl_ruleset_type = 6; -pub type nftnl_ruleset_type = u32; -extern "C" { - pub fn nftnl_ruleset_is_set(r: *const nftnl_ruleset, attr: u16) -> bool; - - pub fn nftnl_ruleset_unset(r: *mut nftnl_ruleset, attr: u16); - - pub fn nftnl_ruleset_set(r: *mut nftnl_ruleset, attr: u16, data: *mut c_void); - - pub fn nftnl_ruleset_get(r: *const nftnl_ruleset, attr: u16) -> *mut c_void; -} -pub const NFTNL_RULESET_CTX_CMD: u32 = 0; -pub const NFTNL_RULESET_CTX_TYPE: u32 = 1; -pub const NFTNL_RULESET_CTX_TABLE: u32 = 2; -pub const NFTNL_RULESET_CTX_CHAIN: u32 = 3; -pub const NFTNL_RULESET_CTX_RULE: u32 = 4; -pub const NFTNL_RULESET_CTX_SET: u32 = 5; -pub const NFTNL_RULESET_CTX_DATA: u32 = 6; - -#[repr(C)] -pub struct nftnl_parse_ctx(c_void); - -extern "C" { - pub fn nftnl_ruleset_ctx_free(ctx: *const nftnl_parse_ctx); - - pub fn nftnl_ruleset_ctx_is_set(ctx: *const nftnl_parse_ctx, attr: u16) -> bool; - - pub fn nftnl_ruleset_ctx_get(ctx: *const nftnl_parse_ctx, attr: u16) -> *mut c_void; - - pub fn nftnl_ruleset_ctx_get_u32(ctx: *const nftnl_parse_ctx, attr: u16) -> u32; - - pub fn nftnl_ruleset_parse_file_cb( - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse_buffer_cb( - type_: nftnl_parse_type, - buffer: *const c_char, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_parse_file( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_snprintf( - buf: *mut c_char, - size: usize, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_ruleset_fprintf( - fp: *mut FILE, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_SET_TABLE: nftnl_set_attr = 0; -pub const NFTNL_SET_NAME: nftnl_set_attr = 1; -pub const NFTNL_SET_FLAGS: nftnl_set_attr = 2; -pub const NFTNL_SET_KEY_TYPE: nftnl_set_attr = 3; -pub const NFTNL_SET_KEY_LEN: nftnl_set_attr = 4; -pub const NFTNL_SET_DATA_TYPE: nftnl_set_attr = 5; -pub const NFTNL_SET_DATA_LEN: nftnl_set_attr = 6; -pub const NFTNL_SET_FAMILY: nftnl_set_attr = 7; -pub const NFTNL_SET_ID: nftnl_set_attr = 8; -pub const NFTNL_SET_POLICY: nftnl_set_attr = 9; -pub const NFTNL_SET_DESC_SIZE: nftnl_set_attr = 10; -pub const NFTNL_SET_TIMEOUT: nftnl_set_attr = 11; -pub const NFTNL_SET_GC_INTERVAL: nftnl_set_attr = 12; -pub const NFTNL_SET_USERDATA: nftnl_set_attr = 13; -pub const NFTNL_SET_OBJ_TYPE: nftnl_set_attr = 14; -pub const NFTNL_SET_HANDLE: nftnl_set_attr = 15; -pub const __NFTNL_SET_MAX: nftnl_set_attr = 16; -pub type nftnl_set_attr = u32; -#[repr(C)] -pub struct nftnl_set(c_void); - -extern "C" { - pub fn nftnl_set_alloc() -> *mut nftnl_set; - - pub fn nftnl_set_free(s: *const nftnl_set); - - pub fn nftnl_set_clone(set: *const nftnl_set) -> *mut nftnl_set; - - pub fn nftnl_set_is_set(s: *const nftnl_set, attr: u16) -> bool; - - pub fn nftnl_set_unset(s: *mut nftnl_set, attr: u16); - - pub fn nftnl_set_set(s: *mut nftnl_set, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_set_set_data( - s: *mut nftnl_set, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_set_u32(s: *mut nftnl_set, attr: u16, val: u32); - - pub fn nftnl_set_set_u64(s: *mut nftnl_set, attr: u16, val: u64); - - pub fn nftnl_set_set_str(s: *mut nftnl_set, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_get(s: *const nftnl_set, attr: u16) -> *const c_void; - - pub fn nftnl_set_get_data(s: *const nftnl_set, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_set_get_str(s: *const nftnl_set, attr: u16) -> *const c_char; - - pub fn nftnl_set_get_u32(s: *const nftnl_set, attr: u16) -> u32; - - pub fn nftnl_set_get_u64(s: *const nftnl_set, attr: u16) -> u64; - - pub fn nftnl_set_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_elems_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_fprintf(fp: *mut FILE, s: *const nftnl_set, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list(c_void); - -extern "C" { - pub fn nftnl_set_list_alloc() -> *mut nftnl_set_list; - - pub fn nftnl_set_list_free(list: *mut nftnl_set_list); - - pub fn nftnl_set_list_is_empty(list: *const nftnl_set_list) -> c_int; - - pub fn nftnl_set_list_add(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_add_tail(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_del(s: *mut nftnl_set); - - pub fn nftnl_set_list_foreach( - set_list: *mut nftnl_set_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_set, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list_iter(c_void); - -extern "C" { - pub fn nftnl_set_list_iter_create(l: *const nftnl_set_list) -> *mut nftnl_set_list_iter; - - pub fn nftnl_set_list_iter_cur(iter: *const nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_next(iter: *mut nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_destroy(iter: *const nftnl_set_list_iter); - - pub fn nftnl_set_parse( - s: *mut nftnl_set, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_parse_file( - s: *mut nftnl_set, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; -} -pub const NFTNL_SET_ELEM_FLAGS: u32 = 0; -pub const NFTNL_SET_ELEM_KEY: u32 = 1; -pub const NFTNL_SET_ELEM_VERDICT: u32 = 2; -pub const NFTNL_SET_ELEM_CHAIN: u32 = 3; -pub const NFTNL_SET_ELEM_DATA: u32 = 4; -pub const NFTNL_SET_ELEM_TIMEOUT: u32 = 5; -pub const NFTNL_SET_ELEM_EXPIRATION: u32 = 6; -pub const NFTNL_SET_ELEM_USERDATA: u32 = 7; -pub const NFTNL_SET_ELEM_EXPR: u32 = 8; -pub const NFTNL_SET_ELEM_OBJREF: u32 = 9; - -#[repr(C)] -pub struct nftnl_set_elem(c_void); - -extern "C" { - pub fn nftnl_set_elem_alloc() -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_free(s: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_clone(elem: *mut nftnl_set_elem) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_add(s: *mut nftnl_set, elem: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_unset(s: *mut nftnl_set_elem, attr: u16); - - pub fn nftnl_set_elem_set( - s: *mut nftnl_set_elem, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_elem_set_u32(s: *mut nftnl_set_elem, attr: u16, val: u32); - - pub fn nftnl_set_elem_set_u64(s: *mut nftnl_set_elem, attr: u16, val: u64); - - pub fn nftnl_set_elem_set_str(s: *mut nftnl_set_elem, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_set_elem_get( - s: *mut nftnl_set_elem, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_set_elem_get_str(s: *mut nftnl_set_elem, attr: u16) -> *const c_char; - - pub fn nftnl_set_elem_get_u32(s: *mut nftnl_set_elem, attr: u16) -> u32; - - pub fn nftnl_set_elem_get_u64(s: *mut nftnl_set_elem, attr: u16) -> u64; - - pub fn nftnl_set_elem_is_set(s: *const nftnl_set_elem, attr: u16) -> bool; - - pub fn nftnl_set_elems_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_elem_nlmsg_build_payload(nlh: *mut nlmsghdr, e: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_parse( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_parse_file( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_snprintf( - buf: *mut c_char, - size: usize, - s: *const nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_fprintf( - fp: *mut FILE, - se: *mut nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_foreach( - s: *mut nftnl_set, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_set_elem, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_elems_iter(c_void); - -extern "C" { - pub fn nftnl_set_elems_iter_create(s: *const nftnl_set) -> *mut nftnl_set_elems_iter; - - pub fn nftnl_set_elems_iter_cur(iter: *const nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_next(iter: *mut nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_destroy(iter: *mut nftnl_set_elems_iter); - - pub fn nftnl_set_elems_nlmsg_build_payload_iter( - nlh: *mut nlmsghdr, - iter: *mut nftnl_set_elems_iter, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_table(c_void); - -extern "C" { - pub fn nftnl_table_alloc() -> *mut nftnl_table; - - pub fn nftnl_table_free(arg1: *const nftnl_table); -} -pub const NFTNL_TABLE_NAME: nftnl_table_attr = 0; -pub const NFTNL_TABLE_FAMILY: nftnl_table_attr = 1; -pub const NFTNL_TABLE_FLAGS: nftnl_table_attr = 2; -pub const NFTNL_TABLE_USE: nftnl_table_attr = 3; -pub const NFTNL_TABLE_HANDLE: nftnl_table_attr = 4; -pub const __NFTNL_TABLE_MAX: nftnl_table_attr = 5; -pub type nftnl_table_attr = u32; -extern "C" { - pub fn nftnl_table_is_set(t: *const nftnl_table, attr: u16) -> bool; - - pub fn nftnl_table_unset(t: *mut nftnl_table, attr: u16); - - pub fn nftnl_table_set(t: *mut nftnl_table, attr: u16, data: *const c_void); - - pub fn nftnl_table_set_data( - t: *mut nftnl_table, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_table_get(t: *const nftnl_table, attr: u16) -> *const c_void; - - pub fn nftnl_table_get_data( - t: *const nftnl_table, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_table_set_u8(t: *mut nftnl_table, attr: u16, data: u8); - - pub fn nftnl_table_set_u32(t: *mut nftnl_table, attr: u16, data: u32); - - pub fn nftnl_table_set_u64(t: *mut nftnl_table, attr: u16, data: u64); - - pub fn nftnl_table_set_str(t: *mut nftnl_table, attr: u16, str: *const c_char) -> c_int; - - pub fn nftnl_table_get_u8(t: *const nftnl_table, attr: u16) -> u8; - - pub fn nftnl_table_get_u32(t: *const nftnl_table, attr: u16) -> u32; - - pub fn nftnl_table_get_u64(t: *const nftnl_table, attr: u16) -> u64; - - pub fn nftnl_table_get_str(t: *const nftnl_table, attr: u16) -> *const c_char; - - pub fn nftnl_table_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_table); - - pub fn nftnl_table_parse( - t: *mut nftnl_table, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_parse_file( - t: *mut nftnl_table, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_snprintf( - buf: *mut c_char, - size: usize, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_fprintf( - fp: *mut FILE, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_table) -> c_int; -} -#[repr(C)] -pub struct nftnl_table_list(c_void); - -extern "C" { - pub fn nftnl_table_list_alloc() -> *mut nftnl_table_list; - - pub fn nftnl_table_list_free(list: *mut nftnl_table_list); - - pub fn nftnl_table_list_is_empty(list: *const nftnl_table_list) -> c_int; - - pub fn nftnl_table_list_foreach( - table_list: *mut nftnl_table_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_table, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_table_list_add(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_add_tail(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_del(r: *mut nftnl_table); -} -#[repr(C)] -pub struct nftnl_table_list_iter(c_void); - -extern "C" { - pub fn nftnl_table_list_iter_create(l: *const nftnl_table_list) -> *mut nftnl_table_list_iter; - - pub fn nftnl_table_list_iter_next(iter: *mut nftnl_table_list_iter) -> *mut nftnl_table; - - pub fn nftnl_table_list_iter_destroy(iter: *const nftnl_table_list_iter); -} -pub const NFTNL_TRACE_CHAIN: nftnl_trace_attr = 0; -pub const NFTNL_TRACE_FAMILY: nftnl_trace_attr = 1; -pub const NFTNL_TRACE_ID: nftnl_trace_attr = 2; -pub const NFTNL_TRACE_IIF: nftnl_trace_attr = 3; -pub const NFTNL_TRACE_IIFTYPE: nftnl_trace_attr = 4; -pub const NFTNL_TRACE_JUMP_TARGET: nftnl_trace_attr = 5; -pub const NFTNL_TRACE_OIF: nftnl_trace_attr = 6; -pub const NFTNL_TRACE_OIFTYPE: nftnl_trace_attr = 7; -pub const NFTNL_TRACE_MARK: nftnl_trace_attr = 8; -pub const NFTNL_TRACE_LL_HEADER: nftnl_trace_attr = 9; -pub const NFTNL_TRACE_NETWORK_HEADER: nftnl_trace_attr = 10; -pub const NFTNL_TRACE_TRANSPORT_HEADER: nftnl_trace_attr = 11; -pub const NFTNL_TRACE_TABLE: nftnl_trace_attr = 12; -pub const NFTNL_TRACE_TYPE: nftnl_trace_attr = 13; -pub const NFTNL_TRACE_RULE_HANDLE: nftnl_trace_attr = 14; -pub const NFTNL_TRACE_VERDICT: nftnl_trace_attr = 15; -pub const NFTNL_TRACE_NFPROTO: nftnl_trace_attr = 16; -pub const NFTNL_TRACE_POLICY: nftnl_trace_attr = 17; -pub const __NFTNL_TRACE_MAX: nftnl_trace_attr = 18; -pub type nftnl_trace_attr = u32; -#[repr(C)] -pub struct nftnl_trace(c_void); - -extern "C" { - pub fn nftnl_trace_alloc() -> *mut nftnl_trace; - - pub fn nftnl_trace_free(trace: *const nftnl_trace); - - pub fn nftnl_trace_is_set(trace: *const nftnl_trace, type_: u16) -> bool; - - pub fn nftnl_trace_get_data( - trace: *const nftnl_trace, - type_: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_trace_get_u16(trace: *const nftnl_trace, type_: u16) -> u16; - - pub fn nftnl_trace_get_u32(trace: *const nftnl_trace, type_: u16) -> u32; - - pub fn nftnl_trace_get_u64(trace: *const nftnl_trace, type_: u16) -> u64; - - pub fn nftnl_trace_get_str(trace: *const nftnl_trace, type_: u16) -> *const c_char; - - pub fn nftnl_trace_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_trace) -> c_int; -} -#[repr(C)] -pub struct nftnl_udata(c_void); - -#[repr(C)] -pub struct nftnl_udata_buf(c_void); - -extern "C" { - pub fn nftnl_udata_buf_alloc(data_size: u32) -> *mut nftnl_udata_buf; - - pub fn nftnl_udata_buf_free(buf: *const nftnl_udata_buf); - - pub fn nftnl_udata_buf_len(buf: *const nftnl_udata_buf) -> u32; - - pub fn nftnl_udata_buf_data(buf: *const nftnl_udata_buf) -> *mut c_void; - - pub fn nftnl_udata_buf_put(buf: *mut nftnl_udata_buf, data: *const c_void, len: u32); - - pub fn nftnl_udata_start(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_end(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_put( - buf: *mut nftnl_udata_buf, - type_: u8, - len: u32, - value: *const c_void, - ) -> bool; - - pub fn nftnl_udata_put_u32(buf: *mut nftnl_udata_buf, type_: u8, data: u32) -> bool; - - pub fn nftnl_udata_put_strz(buf: *mut nftnl_udata_buf, type_: u8, strz: *const c_char) -> bool; - - pub fn nftnl_udata_type(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_len(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_get(attr: *const nftnl_udata) -> *mut c_void; - - pub fn nftnl_udata_get_u32(attr: *const nftnl_udata) -> u32; - - pub fn nftnl_udata_next(attr: *const nftnl_udata) -> *mut nftnl_udata; -} -pub type nftnl_udata_cb_t = - Option<unsafe extern "C" fn(attr: *const nftnl_udata, data: *mut c_void) -> c_int>; -extern "C" { - pub fn nftnl_udata_parse( - data: *const c_void, - data_len: u32, - cb: nftnl_udata_cb_t, - cb_data: *mut c_void, - ) -> c_int; -} diff --git a/rustables-sys/src/nftnl_1_2_0.rs b/rustables-sys/src/nftnl_1_2_0.rs deleted file mode 100644 index 3c5998e..0000000 --- a/rustables-sys/src/nftnl_1_2_0.rs +++ /dev/null @@ -1,1476 +0,0 @@ -/* automatically generated by rust-bindgen 0.59.1 0.59.1 */ - -use core::option::Option; -use libc::{c_char, c_int, c_uint, c_ulong, c_void, nlmsghdr, FILE}; - -pub const NFTNL_UDATA_COMMENT_MAXLEN: u32 = 128; -#[repr(C)] -pub struct nftnl_batch(c_void); - -extern "C" { - pub fn nftnl_batch_alloc(pg_size: u32, pg_overrun_size: u32) -> *mut nftnl_batch; - - pub fn nftnl_batch_update(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_free(batch: *mut nftnl_batch); - - pub fn nftnl_batch_buffer(batch: *mut nftnl_batch) -> *mut c_void; - - pub fn nftnl_batch_buffer_len(batch: *mut nftnl_batch) -> u32; - - pub fn nftnl_batch_iovec_len(batch: *mut nftnl_batch) -> c_int; - - pub fn nftnl_batch_iovec(batch: *mut nftnl_batch, iov: *mut [u8; 0usize], iovlen: u32); -} -pub type size_t = c_ulong; -pub const NFTNL_PARSE_EBADINPUT: c_uint = 0; -pub const NFTNL_PARSE_EMISSINGNODE: c_uint = 1; -pub const NFTNL_PARSE_EBADTYPE: c_uint = 2; -pub const NFTNL_PARSE_EOPNOTSUPP: c_uint = 3; -pub const NFTNL_OUTPUT_DEFAULT: nftnl_output_type = 0; -pub const NFTNL_OUTPUT_XML: nftnl_output_type = 1; -pub const NFTNL_OUTPUT_JSON: nftnl_output_type = 2; -pub type nftnl_output_type = c_uint; -pub const NFTNL_OF_EVENT_NEW: nftnl_output_flags = 1; -pub const NFTNL_OF_EVENT_DEL: nftnl_output_flags = 2; -pub const NFTNL_OF_EVENT_ANY: nftnl_output_flags = 3; -pub type nftnl_output_flags = c_uint; -pub const NFTNL_CMD_UNSPEC: nftnl_cmd_type = 0; -pub const NFTNL_CMD_ADD: nftnl_cmd_type = 1; -pub const NFTNL_CMD_INSERT: nftnl_cmd_type = 2; -pub const NFTNL_CMD_DELETE: nftnl_cmd_type = 3; -pub const NFTNL_CMD_REPLACE: nftnl_cmd_type = 4; -pub const NFTNL_CMD_FLUSH: nftnl_cmd_type = 5; -pub const NFTNL_CMD_MAX: nftnl_cmd_type = 6; -pub type nftnl_cmd_type = c_uint; -pub const NFTNL_PARSE_NONE: nftnl_parse_type = 0; -pub const NFTNL_PARSE_XML: nftnl_parse_type = 1; -pub const NFTNL_PARSE_JSON: nftnl_parse_type = 2; -pub const NFTNL_PARSE_MAX: nftnl_parse_type = 3; -pub type nftnl_parse_type = c_uint; -#[repr(C)] -pub struct nftnl_parse_err(c_void); - -extern "C" { - pub fn nftnl_nlmsg_build_hdr( - buf: *mut c_char, - type_: u16, - family: u16, - flags: u16, - seq: u32, - ) -> *mut nlmsghdr; - - pub fn nftnl_parse_err_alloc() -> *mut nftnl_parse_err; - - pub fn nftnl_parse_err_free(arg1: *mut nftnl_parse_err); - - pub fn nftnl_parse_perror(str_: *const c_char, err: *mut nftnl_parse_err) -> c_int; - - pub fn nftnl_batch_is_supported() -> c_int; - - pub fn nftnl_batch_begin(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; - - pub fn nftnl_batch_end(buf: *mut c_char, seq: u32) -> *mut nlmsghdr; -} -#[repr(C)] -pub struct nftnl_chain(c_void); - -#[repr(C)] -pub struct nftnl_rule(c_void); - -extern "C" { - pub fn nftnl_chain_alloc() -> *mut nftnl_chain; - - pub fn nftnl_chain_free(arg1: *const nftnl_chain); -} -pub const NFTNL_CHAIN_NAME: nftnl_chain_attr = 0; -pub const NFTNL_CHAIN_FAMILY: nftnl_chain_attr = 1; -pub const NFTNL_CHAIN_TABLE: nftnl_chain_attr = 2; -pub const NFTNL_CHAIN_HOOKNUM: nftnl_chain_attr = 3; -pub const NFTNL_CHAIN_PRIO: nftnl_chain_attr = 4; -pub const NFTNL_CHAIN_POLICY: nftnl_chain_attr = 5; -pub const NFTNL_CHAIN_USE: nftnl_chain_attr = 6; -pub const NFTNL_CHAIN_BYTES: nftnl_chain_attr = 7; -pub const NFTNL_CHAIN_PACKETS: nftnl_chain_attr = 8; -pub const NFTNL_CHAIN_HANDLE: nftnl_chain_attr = 9; -pub const NFTNL_CHAIN_TYPE: nftnl_chain_attr = 10; -pub const NFTNL_CHAIN_DEV: nftnl_chain_attr = 11; -pub const NFTNL_CHAIN_DEVICES: nftnl_chain_attr = 12; -pub const NFTNL_CHAIN_FLAGS: nftnl_chain_attr = 13; -pub const NFTNL_CHAIN_ID: nftnl_chain_attr = 14; -pub const NFTNL_CHAIN_USERDATA: nftnl_chain_attr = 15; -pub const __NFTNL_CHAIN_MAX: nftnl_chain_attr = 16; -pub type nftnl_chain_attr = c_uint; -extern "C" { - pub fn nftnl_chain_is_set(c: *const nftnl_chain, attr: u16) -> bool; - - pub fn nftnl_chain_unset(c: *mut nftnl_chain, attr: u16); - - pub fn nftnl_chain_set(t: *mut nftnl_chain, attr: u16, data: *const c_void); - - pub fn nftnl_chain_set_data( - t: *mut nftnl_chain, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_chain_set_u8(t: *mut nftnl_chain, attr: u16, data: u8); - - pub fn nftnl_chain_set_u32(t: *mut nftnl_chain, attr: u16, data: u32); - - pub fn nftnl_chain_set_s32(t: *mut nftnl_chain, attr: u16, data: i32); - - pub fn nftnl_chain_set_u64(t: *mut nftnl_chain, attr: u16, data: u64); - - pub fn nftnl_chain_set_str(t: *mut nftnl_chain, attr: u16, str_: *const c_char) -> c_int; - - pub fn nftnl_chain_set_array(t: *mut nftnl_chain, attr: u16, data: *mut *const c_char) - -> c_int; - - pub fn nftnl_chain_get(c: *const nftnl_chain, attr: u16) -> *const c_void; - - pub fn nftnl_chain_get_data( - c: *const nftnl_chain, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_chain_get_str(c: *const nftnl_chain, attr: u16) -> *const c_char; - - pub fn nftnl_chain_get_u8(c: *const nftnl_chain, attr: u16) -> u8; - - pub fn nftnl_chain_get_u32(c: *const nftnl_chain, attr: u16) -> u32; - - pub fn nftnl_chain_get_s32(c: *const nftnl_chain, attr: u16) -> i32; - - pub fn nftnl_chain_get_u64(c: *const nftnl_chain, attr: u16) -> u64; - - pub fn nftnl_chain_get_array(c: *const nftnl_chain, attr: u16) -> *const *const c_char; - - pub fn nftnl_chain_rule_add(rule: *mut nftnl_rule, c: *mut nftnl_chain); - - pub fn nftnl_chain_rule_del(rule: *mut nftnl_rule); - - pub fn nftnl_chain_rule_add_tail(rule: *mut nftnl_rule, c: *mut nftnl_chain); - - pub fn nftnl_chain_rule_insert_at(rule: *mut nftnl_rule, pos: *mut nftnl_rule); - - pub fn nftnl_chain_rule_append_at(rule: *mut nftnl_rule, pos: *mut nftnl_rule); - - pub fn nftnl_chain_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_chain); - - pub fn nftnl_chain_parse( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_parse_file( - c: *mut nftnl_chain, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_chain_snprintf( - buf: *mut c_char, - size: size_t, - t: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_fprintf( - fp: *mut FILE, - c: *const nftnl_chain, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_chain_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_chain) -> c_int; - - pub fn nftnl_rule_foreach( - c: *mut nftnl_chain, - cb: Option<unsafe extern "C" fn(r: *mut nftnl_rule, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_rule_lookup_byindex(c: *mut nftnl_chain, index: u32) -> *mut nftnl_rule; -} -#[repr(C)] -pub struct nftnl_rule_iter(c_void); - -extern "C" { - pub fn nftnl_rule_iter_create(c: *const nftnl_chain) -> *mut nftnl_rule_iter; - - pub fn nftnl_rule_iter_next(iter: *mut nftnl_rule_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_iter_destroy(iter: *mut nftnl_rule_iter); -} -#[repr(C)] -pub struct nftnl_chain_list(c_void); - -extern "C" { - pub fn nftnl_chain_list_alloc() -> *mut nftnl_chain_list; - - pub fn nftnl_chain_list_free(list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_is_empty(list: *const nftnl_chain_list) -> c_int; - - pub fn nftnl_chain_list_foreach( - chain_list: *mut nftnl_chain_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_chain, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_chain_list_lookup_byname( - chain_list: *mut nftnl_chain_list, - chain: *const c_char, - ) -> *mut nftnl_chain; - - pub fn nftnl_chain_list_add(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_add_tail(r: *mut nftnl_chain, list: *mut nftnl_chain_list); - - pub fn nftnl_chain_list_del(c: *mut nftnl_chain); -} -#[repr(C)] -pub struct nftnl_chain_list_iter(c_void); - -extern "C" { - pub fn nftnl_chain_list_iter_create(l: *const nftnl_chain_list) -> *mut nftnl_chain_list_iter; - - pub fn nftnl_chain_list_iter_next(iter: *mut nftnl_chain_list_iter) -> *mut nftnl_chain; - - pub fn nftnl_chain_list_iter_destroy(iter: *mut nftnl_chain_list_iter); -} -#[repr(C)] -pub struct nftnl_expr(c_void); - -pub const NFTNL_EXPR_NAME: c_uint = 0; -pub const NFTNL_EXPR_BASE: c_uint = 1; - -extern "C" { - pub fn nftnl_expr_alloc(name: *const c_char) -> *mut nftnl_expr; - - pub fn nftnl_expr_free(expr: *const nftnl_expr); - - pub fn nftnl_expr_is_set(expr: *const nftnl_expr, type_: u16) -> bool; - - pub fn nftnl_expr_set( - expr: *mut nftnl_expr, - type_: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_expr_set_u8(expr: *mut nftnl_expr, type_: u16, data: u8); - - pub fn nftnl_expr_set_u16(expr: *mut nftnl_expr, type_: u16, data: u16); - - pub fn nftnl_expr_set_u32(expr: *mut nftnl_expr, type_: u16, data: u32); - - pub fn nftnl_expr_set_u64(expr: *mut nftnl_expr, type_: u16, data: u64); - - pub fn nftnl_expr_set_str(expr: *mut nftnl_expr, type_: u16, str_: *const c_char) -> c_int; - - pub fn nftnl_expr_get(expr: *const nftnl_expr, type_: u16, data_len: *mut u32) - -> *const c_void; - - pub fn nftnl_expr_get_u8(expr: *const nftnl_expr, type_: u16) -> u8; - - pub fn nftnl_expr_get_u16(expr: *const nftnl_expr, type_: u16) -> u16; - - pub fn nftnl_expr_get_u32(expr: *const nftnl_expr, type_: u16) -> u32; - - pub fn nftnl_expr_get_u64(expr: *const nftnl_expr, type_: u16) -> u64; - - pub fn nftnl_expr_get_str(expr: *const nftnl_expr, type_: u16) -> *const c_char; - - pub fn nftnl_expr_build_payload(nlh: *mut nlmsghdr, expr: *mut nftnl_expr); - - pub fn nftnl_expr_add_expr(expr: *mut nftnl_expr, type_: u32, e: *mut nftnl_expr); - - pub fn nftnl_expr_expr_foreach( - e: *const nftnl_expr, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_expr, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_expr_snprintf( - buf: *mut c_char, - buflen: size_t, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_expr_fprintf( - fp: *mut FILE, - expr: *const nftnl_expr, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_EXPR_PAYLOAD_DREG: c_uint = 1; -pub const NFTNL_EXPR_PAYLOAD_BASE: c_uint = 2; -pub const NFTNL_EXPR_PAYLOAD_OFFSET: c_uint = 3; -pub const NFTNL_EXPR_PAYLOAD_LEN: c_uint = 4; -pub const NFTNL_EXPR_PAYLOAD_SREG: c_uint = 5; -pub const NFTNL_EXPR_PAYLOAD_CSUM_TYPE: c_uint = 6; -pub const NFTNL_EXPR_PAYLOAD_CSUM_OFFSET: c_uint = 7; -pub const NFTNL_EXPR_PAYLOAD_FLAGS: c_uint = 8; - -pub const NFTNL_EXPR_NG_DREG: c_uint = 1; -pub const NFTNL_EXPR_NG_MODULUS: c_uint = 2; -pub const NFTNL_EXPR_NG_TYPE: c_uint = 3; -pub const NFTNL_EXPR_NG_OFFSET: c_uint = 4; -pub const NFTNL_EXPR_NG_SET_NAME: c_uint = 5; -pub const NFTNL_EXPR_NG_SET_ID: c_uint = 6; - -pub const NFTNL_EXPR_META_KEY: c_uint = 1; -pub const NFTNL_EXPR_META_DREG: c_uint = 2; -pub const NFTNL_EXPR_META_SREG: c_uint = 3; - -pub const NFTNL_EXPR_RT_KEY: c_uint = 1; -pub const NFTNL_EXPR_RT_DREG: c_uint = 2; - -pub const NFTNL_EXPR_SOCKET_KEY: c_uint = 1; -pub const NFTNL_EXPR_SOCKET_DREG: c_uint = 2; -pub const NFTNL_EXPR_SOCKET_LEVEL: c_uint = 3; - -pub const NFTNL_EXPR_TUNNEL_KEY: c_uint = 1; -pub const NFTNL_EXPR_TUNNEL_DREG: c_uint = 2; - -pub const NFTNL_EXPR_CMP_SREG: c_uint = 1; -pub const NFTNL_EXPR_CMP_OP: c_uint = 2; -pub const NFTNL_EXPR_CMP_DATA: c_uint = 3; - -pub const NFTNL_EXPR_RANGE_SREG: c_uint = 1; -pub const NFTNL_EXPR_RANGE_OP: c_uint = 2; -pub const NFTNL_EXPR_RANGE_FROM_DATA: c_uint = 3; -pub const NFTNL_EXPR_RANGE_TO_DATA: c_uint = 4; - -pub const NFTNL_EXPR_IMM_DREG: c_uint = 1; -pub const NFTNL_EXPR_IMM_DATA: c_uint = 2; -pub const NFTNL_EXPR_IMM_VERDICT: c_uint = 3; -pub const NFTNL_EXPR_IMM_CHAIN: c_uint = 4; -pub const NFTNL_EXPR_IMM_CHAIN_ID: c_uint = 5; - -pub const NFTNL_EXPR_CTR_PACKETS: c_uint = 1; -pub const NFTNL_EXPR_CTR_BYTES: c_uint = 2; - -pub const NFTNL_EXPR_CONNLIMIT_COUNT: c_uint = 1; -pub const NFTNL_EXPR_CONNLIMIT_FLAGS: c_uint = 2; - -pub const NFTNL_EXPR_BITWISE_SREG: c_uint = 1; -pub const NFTNL_EXPR_BITWISE_DREG: c_uint = 2; -pub const NFTNL_EXPR_BITWISE_LEN: c_uint = 3; -pub const NFTNL_EXPR_BITWISE_MASK: c_uint = 4; -pub const NFTNL_EXPR_BITWISE_XOR: c_uint = 5; -pub const NFTNL_EXPR_BITWISE_OP: c_uint = 6; -pub const NFTNL_EXPR_BITWISE_DATA: c_uint = 7; - -pub const NFTNL_EXPR_TG_NAME: c_uint = 1; -pub const NFTNL_EXPR_TG_REV: c_uint = 2; -pub const NFTNL_EXPR_TG_INFO: c_uint = 3; - -pub const NFTNL_EXPR_MT_NAME: c_uint = 1; -pub const NFTNL_EXPR_MT_REV: c_uint = 2; -pub const NFTNL_EXPR_MT_INFO: c_uint = 3; - -pub const NFTNL_EXPR_NAT_TYPE: c_uint = 1; -pub const NFTNL_EXPR_NAT_FAMILY: c_uint = 2; -pub const NFTNL_EXPR_NAT_REG_ADDR_MIN: c_uint = 3; -pub const NFTNL_EXPR_NAT_REG_ADDR_MAX: c_uint = 4; -pub const NFTNL_EXPR_NAT_REG_PROTO_MIN: c_uint = 5; -pub const NFTNL_EXPR_NAT_REG_PROTO_MAX: c_uint = 6; -pub const NFTNL_EXPR_NAT_FLAGS: c_uint = 7; - -pub const NFTNL_EXPR_TPROXY_FAMILY: c_uint = 1; -pub const NFTNL_EXPR_TPROXY_REG_ADDR: c_uint = 2; -pub const NFTNL_EXPR_TPROXY_REG_PORT: c_uint = 3; - -pub const NFTNL_EXPR_LOOKUP_SREG: c_uint = 1; -pub const NFTNL_EXPR_LOOKUP_DREG: c_uint = 2; -pub const NFTNL_EXPR_LOOKUP_SET: c_uint = 3; -pub const NFTNL_EXPR_LOOKUP_SET_ID: c_uint = 4; -pub const NFTNL_EXPR_LOOKUP_FLAGS: c_uint = 5; - -pub const NFTNL_EXPR_DYNSET_SREG_KEY: c_uint = 1; -pub const NFTNL_EXPR_DYNSET_SREG_DATA: c_uint = 2; -pub const NFTNL_EXPR_DYNSET_OP: c_uint = 3; -pub const NFTNL_EXPR_DYNSET_TIMEOUT: c_uint = 4; -pub const NFTNL_EXPR_DYNSET_SET_NAME: c_uint = 5; -pub const NFTNL_EXPR_DYNSET_SET_ID: c_uint = 6; -pub const NFTNL_EXPR_DYNSET_EXPR: c_uint = 7; -pub const NFTNL_EXPR_DYNSET_EXPRESSIONS: c_uint = 8; -pub const NFTNL_EXPR_DYNSET_FLAGS: c_uint = 9; - -pub const NFTNL_EXPR_LOG_PREFIX: c_uint = 1; -pub const NFTNL_EXPR_LOG_GROUP: c_uint = 2; -pub const NFTNL_EXPR_LOG_SNAPLEN: c_uint = 3; -pub const NFTNL_EXPR_LOG_QTHRESHOLD: c_uint = 4; -pub const NFTNL_EXPR_LOG_LEVEL: c_uint = 5; -pub const NFTNL_EXPR_LOG_FLAGS: c_uint = 6; - -pub const NFTNL_EXPR_EXTHDR_DREG: c_uint = 1; -pub const NFTNL_EXPR_EXTHDR_TYPE: c_uint = 2; -pub const NFTNL_EXPR_EXTHDR_OFFSET: c_uint = 3; -pub const NFTNL_EXPR_EXTHDR_LEN: c_uint = 4; -pub const NFTNL_EXPR_EXTHDR_FLAGS: c_uint = 5; -pub const NFTNL_EXPR_EXTHDR_OP: c_uint = 6; -pub const NFTNL_EXPR_EXTHDR_SREG: c_uint = 7; - -pub const NFTNL_EXPR_CT_DREG: c_uint = 1; -pub const NFTNL_EXPR_CT_KEY: c_uint = 2; -pub const NFTNL_EXPR_CT_DIR: c_uint = 3; -pub const NFTNL_EXPR_CT_SREG: c_uint = 4; - -pub const NFTNL_EXPR_BYTEORDER_DREG: c_uint = 1; -pub const NFTNL_EXPR_BYTEORDER_SREG: c_uint = 2; -pub const NFTNL_EXPR_BYTEORDER_OP: c_uint = 3; -pub const NFTNL_EXPR_BYTEORDER_LEN: c_uint = 4; -pub const NFTNL_EXPR_BYTEORDER_SIZE: c_uint = 5; - -pub const NFTNL_EXPR_LIMIT_RATE: c_uint = 1; -pub const NFTNL_EXPR_LIMIT_UNIT: c_uint = 2; -pub const NFTNL_EXPR_LIMIT_BURST: c_uint = 3; -pub const NFTNL_EXPR_LIMIT_TYPE: c_uint = 4; -pub const NFTNL_EXPR_LIMIT_FLAGS: c_uint = 5; - -pub const NFTNL_EXPR_REJECT_TYPE: c_uint = 1; -pub const NFTNL_EXPR_REJECT_CODE: c_uint = 2; - -pub const NFTNL_EXPR_QUEUE_NUM: c_uint = 1; -pub const NFTNL_EXPR_QUEUE_TOTAL: c_uint = 2; -pub const NFTNL_EXPR_QUEUE_FLAGS: c_uint = 3; -pub const NFTNL_EXPR_QUEUE_SREG_QNUM: c_uint = 4; - -pub const NFTNL_EXPR_QUOTA_BYTES: c_uint = 1; -pub const NFTNL_EXPR_QUOTA_FLAGS: c_uint = 2; -pub const NFTNL_EXPR_QUOTA_CONSUMED: c_uint = 3; - -pub const NFTNL_EXPR_MASQ_FLAGS: c_uint = 1; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MIN: c_uint = 2; -pub const NFTNL_EXPR_MASQ_REG_PROTO_MAX: c_uint = 3; - -pub const NFTNL_EXPR_REDIR_REG_PROTO_MIN: c_uint = 1; -pub const NFTNL_EXPR_REDIR_REG_PROTO_MAX: c_uint = 2; -pub const NFTNL_EXPR_REDIR_FLAGS: c_uint = 3; - -pub const NFTNL_EXPR_DUP_SREG_ADDR: c_uint = 1; -pub const NFTNL_EXPR_DUP_SREG_DEV: c_uint = 2; - -pub const NFTNL_EXPR_FLOW_TABLE_NAME: c_uint = 1; - -pub const NFTNL_EXPR_FWD_SREG_DEV: c_uint = 1; -pub const NFTNL_EXPR_FWD_SREG_ADDR: c_uint = 2; -pub const NFTNL_EXPR_FWD_NFPROTO: c_uint = 3; - -pub const NFTNL_EXPR_HASH_SREG: c_uint = 1; -pub const NFTNL_EXPR_HASH_DREG: c_uint = 2; -pub const NFTNL_EXPR_HASH_LEN: c_uint = 3; -pub const NFTNL_EXPR_HASH_MODULUS: c_uint = 4; -pub const NFTNL_EXPR_HASH_SEED: c_uint = 5; -pub const NFTNL_EXPR_HASH_OFFSET: c_uint = 6; -pub const NFTNL_EXPR_HASH_TYPE: c_uint = 7; -pub const NFTNL_EXPR_HASH_SET_NAME: c_uint = 8; -pub const NFTNL_EXPR_HASH_SET_ID: c_uint = 9; - -pub const NFTNL_EXPR_FIB_DREG: c_uint = 1; -pub const NFTNL_EXPR_FIB_RESULT: c_uint = 2; -pub const NFTNL_EXPR_FIB_FLAGS: c_uint = 3; - -pub const NFTNL_EXPR_OBJREF_IMM_TYPE: c_uint = 1; -pub const NFTNL_EXPR_OBJREF_IMM_NAME: c_uint = 2; -pub const NFTNL_EXPR_OBJREF_SET_SREG: c_uint = 3; -pub const NFTNL_EXPR_OBJREF_SET_NAME: c_uint = 4; -pub const NFTNL_EXPR_OBJREF_SET_ID: c_uint = 5; - -pub const NFTNL_EXPR_OSF_DREG: c_uint = 1; -pub const NFTNL_EXPR_OSF_TTL: c_uint = 2; -pub const NFTNL_EXPR_OSF_FLAGS: c_uint = 3; - -pub const NFTNL_EXPR_XFRM_DREG: c_uint = 1; -pub const NFTNL_EXPR_XFRM_SREG: c_uint = 2; -pub const NFTNL_EXPR_XFRM_KEY: c_uint = 3; -pub const NFTNL_EXPR_XFRM_DIR: c_uint = 4; -pub const NFTNL_EXPR_XFRM_SPNUM: c_uint = 5; - -pub const NFTNL_EXPR_SYNPROXY_MSS: c_uint = 1; -pub const NFTNL_EXPR_SYNPROXY_WSCALE: c_uint = 2; -pub const NFTNL_EXPR_SYNPROXY_FLAGS: c_uint = 3; - -#[repr(C)] -pub struct nftnl_gen(c_void); - -extern "C" { - pub fn nftnl_gen_alloc() -> *mut nftnl_gen; - - pub fn nftnl_gen_free(arg1: *const nftnl_gen); -} -pub const NFTNL_GEN_ID: c_uint = 0; -pub const __NFTNL_GEN_MAX: c_uint = 1; - -extern "C" { - pub fn nftnl_gen_is_set(gen: *const nftnl_gen, attr: u16) -> bool; - - pub fn nftnl_gen_unset(gen: *mut nftnl_gen, attr: u16); - - pub fn nftnl_gen_set(gen: *mut nftnl_gen, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_gen_set_data( - gen: *mut nftnl_gen, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_gen_get(gen: *const nftnl_gen, attr: u16) -> *const c_void; - - pub fn nftnl_gen_get_data( - gen: *const nftnl_gen, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_gen_set_u32(gen: *mut nftnl_gen, attr: u16, data: u32); - - pub fn nftnl_gen_get_u32(gen: *const nftnl_gen, attr: u16) -> u32; - - pub fn nftnl_gen_nlmsg_parse(nlh: *const nlmsghdr, gen: *mut nftnl_gen) -> c_int; - - pub fn nftnl_gen_snprintf( - buf: *mut c_char, - size: size_t, - gen: *const nftnl_gen, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_gen_fprintf(fp: *mut FILE, gen: *const nftnl_gen, type_: u32, flags: u32) - -> c_int; -} -pub const NFTNL_OBJ_TABLE: c_uint = 0; -pub const NFTNL_OBJ_NAME: c_uint = 1; -pub const NFTNL_OBJ_TYPE: c_uint = 2; -pub const NFTNL_OBJ_FAMILY: c_uint = 3; -pub const NFTNL_OBJ_USE: c_uint = 4; -pub const NFTNL_OBJ_HANDLE: c_uint = 5; -pub const NFTNL_OBJ_USERDATA: c_uint = 6; -pub const NFTNL_OBJ_BASE: c_uint = 16; -pub const __NFTNL_OBJ_MAX: c_uint = 17; - -pub const NFTNL_OBJ_CTR_PKTS: c_uint = 16; -pub const NFTNL_OBJ_CTR_BYTES: c_uint = 17; - -pub const NFTNL_OBJ_QUOTA_BYTES: c_uint = 16; -pub const NFTNL_OBJ_QUOTA_CONSUMED: c_uint = 17; -pub const NFTNL_OBJ_QUOTA_FLAGS: c_uint = 18; - -pub const NFTNL_OBJ_CT_HELPER_NAME: c_uint = 16; -pub const NFTNL_OBJ_CT_HELPER_L3PROTO: c_uint = 17; -pub const NFTNL_OBJ_CT_HELPER_L4PROTO: c_uint = 18; - -pub const NFTNL_CTTIMEOUT_TCP_SYN_SENT: nftnl_cttimeout_array_tcp = 0; -pub const NFTNL_CTTIMEOUT_TCP_SYN_RECV: nftnl_cttimeout_array_tcp = 1; -pub const NFTNL_CTTIMEOUT_TCP_ESTABLISHED: nftnl_cttimeout_array_tcp = 2; -pub const NFTNL_CTTIMEOUT_TCP_FIN_WAIT: nftnl_cttimeout_array_tcp = 3; -pub const NFTNL_CTTIMEOUT_TCP_CLOSE_WAIT: nftnl_cttimeout_array_tcp = 4; -pub const NFTNL_CTTIMEOUT_TCP_LAST_ACK: nftnl_cttimeout_array_tcp = 5; -pub const NFTNL_CTTIMEOUT_TCP_TIME_WAIT: nftnl_cttimeout_array_tcp = 6; -pub const NFTNL_CTTIMEOUT_TCP_CLOSE: nftnl_cttimeout_array_tcp = 7; -pub const NFTNL_CTTIMEOUT_TCP_SYN_SENT2: nftnl_cttimeout_array_tcp = 8; -pub const NFTNL_CTTIMEOUT_TCP_RETRANS: nftnl_cttimeout_array_tcp = 9; -pub const NFTNL_CTTIMEOUT_TCP_UNACK: nftnl_cttimeout_array_tcp = 10; -pub const NFTNL_CTTIMEOUT_TCP_MAX: nftnl_cttimeout_array_tcp = 11; -pub type nftnl_cttimeout_array_tcp = c_uint; -pub const NFTNL_CTTIMEOUT_UDP_UNREPLIED: nftnl_cttimeout_array_udp = 0; -pub const NFTNL_CTTIMEOUT_UDP_REPLIED: nftnl_cttimeout_array_udp = 1; -pub const NFTNL_CTTIMEOUT_UDP_MAX: nftnl_cttimeout_array_udp = 2; -pub type nftnl_cttimeout_array_udp = c_uint; -pub const NFTNL_OBJ_CT_TIMEOUT_L3PROTO: c_uint = 16; -pub const NFTNL_OBJ_CT_TIMEOUT_L4PROTO: c_uint = 17; -pub const NFTNL_OBJ_CT_TIMEOUT_ARRAY: c_uint = 18; - -pub const NFTNL_OBJ_CT_EXPECT_L3PROTO: c_uint = 16; -pub const NFTNL_OBJ_CT_EXPECT_L4PROTO: c_uint = 17; -pub const NFTNL_OBJ_CT_EXPECT_DPORT: c_uint = 18; -pub const NFTNL_OBJ_CT_EXPECT_TIMEOUT: c_uint = 19; -pub const NFTNL_OBJ_CT_EXPECT_SIZE: c_uint = 20; - -pub const NFTNL_OBJ_LIMIT_RATE: c_uint = 16; -pub const NFTNL_OBJ_LIMIT_UNIT: c_uint = 17; -pub const NFTNL_OBJ_LIMIT_BURST: c_uint = 18; -pub const NFTNL_OBJ_LIMIT_TYPE: c_uint = 19; -pub const NFTNL_OBJ_LIMIT_FLAGS: c_uint = 20; - -pub const NFTNL_OBJ_SYNPROXY_MSS: c_uint = 16; -pub const NFTNL_OBJ_SYNPROXY_WSCALE: c_uint = 17; -pub const NFTNL_OBJ_SYNPROXY_FLAGS: c_uint = 18; - -pub const NFTNL_OBJ_TUNNEL_ID: c_uint = 16; -pub const NFTNL_OBJ_TUNNEL_IPV4_SRC: c_uint = 17; -pub const NFTNL_OBJ_TUNNEL_IPV4_DST: c_uint = 18; -pub const NFTNL_OBJ_TUNNEL_IPV6_SRC: c_uint = 19; -pub const NFTNL_OBJ_TUNNEL_IPV6_DST: c_uint = 20; -pub const NFTNL_OBJ_TUNNEL_IPV6_FLOWLABEL: c_uint = 21; -pub const NFTNL_OBJ_TUNNEL_SPORT: c_uint = 22; -pub const NFTNL_OBJ_TUNNEL_DPORT: c_uint = 23; -pub const NFTNL_OBJ_TUNNEL_FLAGS: c_uint = 24; -pub const NFTNL_OBJ_TUNNEL_TOS: c_uint = 25; -pub const NFTNL_OBJ_TUNNEL_TTL: c_uint = 26; -pub const NFTNL_OBJ_TUNNEL_VXLAN_GBP: c_uint = 27; -pub const NFTNL_OBJ_TUNNEL_ERSPAN_VERSION: c_uint = 28; -pub const NFTNL_OBJ_TUNNEL_ERSPAN_V1_INDEX: c_uint = 29; -pub const NFTNL_OBJ_TUNNEL_ERSPAN_V2_HWID: c_uint = 30; -pub const NFTNL_OBJ_TUNNEL_ERSPAN_V2_DIR: c_uint = 31; - -pub const NFTNL_OBJ_SECMARK_CTX: c_uint = 16; - -#[repr(C)] -pub struct nftnl_obj(c_void); - -extern "C" { - pub fn nftnl_obj_alloc() -> *mut nftnl_obj; - - pub fn nftnl_obj_free(ne: *const nftnl_obj); - - pub fn nftnl_obj_is_set(ne: *const nftnl_obj, attr: u16) -> bool; - - pub fn nftnl_obj_unset(ne: *mut nftnl_obj, attr: u16); - - pub fn nftnl_obj_set_data(ne: *mut nftnl_obj, attr: u16, data: *const c_void, data_len: u32); - - pub fn nftnl_obj_set(ne: *mut nftnl_obj, attr: u16, data: *const c_void); - - pub fn nftnl_obj_set_u8(ne: *mut nftnl_obj, attr: u16, val: u8); - - pub fn nftnl_obj_set_u16(ne: *mut nftnl_obj, attr: u16, val: u16); - - pub fn nftnl_obj_set_u32(ne: *mut nftnl_obj, attr: u16, val: u32); - - pub fn nftnl_obj_set_u64(obj: *mut nftnl_obj, attr: u16, val: u64); - - pub fn nftnl_obj_set_str(ne: *mut nftnl_obj, attr: u16, str_: *const c_char); - - pub fn nftnl_obj_get_data(ne: *mut nftnl_obj, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_obj_get(ne: *mut nftnl_obj, attr: u16) -> *const c_void; - - pub fn nftnl_obj_get_u8(ne: *mut nftnl_obj, attr: u16) -> u8; - - pub fn nftnl_obj_get_u16(obj: *mut nftnl_obj, attr: u16) -> u16; - - pub fn nftnl_obj_get_u32(ne: *mut nftnl_obj, attr: u16) -> u32; - - pub fn nftnl_obj_get_u64(obj: *mut nftnl_obj, attr: u16) -> u64; - - pub fn nftnl_obj_get_str(ne: *mut nftnl_obj, attr: u16) -> *const c_char; - - pub fn nftnl_obj_nlmsg_build_payload(nlh: *mut nlmsghdr, ne: *const nftnl_obj); - - pub fn nftnl_obj_nlmsg_parse(nlh: *const nlmsghdr, ne: *mut nftnl_obj) -> c_int; - - pub fn nftnl_obj_parse( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_parse_file( - ne: *mut nftnl_obj, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_obj_snprintf( - buf: *mut c_char, - size: size_t, - ne: *const nftnl_obj, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_obj_fprintf(fp: *mut FILE, ne: *const nftnl_obj, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list(c_void); - -extern "C" { - pub fn nftnl_obj_list_alloc() -> *mut nftnl_obj_list; - - pub fn nftnl_obj_list_free(list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_is_empty(list: *mut nftnl_obj_list) -> c_int; - - pub fn nftnl_obj_list_add(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_add_tail(r: *mut nftnl_obj, list: *mut nftnl_obj_list); - - pub fn nftnl_obj_list_del(t: *mut nftnl_obj); - - pub fn nftnl_obj_list_foreach( - table_list: *mut nftnl_obj_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_obj, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_obj_list_iter(c_void); - -extern "C" { - pub fn nftnl_obj_list_iter_create(l: *mut nftnl_obj_list) -> *mut nftnl_obj_list_iter; - - pub fn nftnl_obj_list_iter_next(iter: *mut nftnl_obj_list_iter) -> *mut nftnl_obj; - - pub fn nftnl_obj_list_iter_destroy(iter: *mut nftnl_obj_list_iter); - - pub fn nftnl_rule_alloc() -> *mut nftnl_rule; - - pub fn nftnl_rule_free(arg1: *const nftnl_rule); -} -pub const NFTNL_RULE_FAMILY: nftnl_rule_attr = 0; -pub const NFTNL_RULE_TABLE: nftnl_rule_attr = 1; -pub const NFTNL_RULE_CHAIN: nftnl_rule_attr = 2; -pub const NFTNL_RULE_HANDLE: nftnl_rule_attr = 3; -pub const NFTNL_RULE_COMPAT_PROTO: nftnl_rule_attr = 4; -pub const NFTNL_RULE_COMPAT_FLAGS: nftnl_rule_attr = 5; -pub const NFTNL_RULE_POSITION: nftnl_rule_attr = 6; -pub const NFTNL_RULE_USERDATA: nftnl_rule_attr = 7; -pub const NFTNL_RULE_ID: nftnl_rule_attr = 8; -pub const NFTNL_RULE_POSITION_ID: nftnl_rule_attr = 9; -pub const __NFTNL_RULE_MAX: nftnl_rule_attr = 10; -pub type nftnl_rule_attr = c_uint; -extern "C" { - pub fn nftnl_rule_unset(r: *mut nftnl_rule, attr: u16); - - pub fn nftnl_rule_is_set(r: *const nftnl_rule, attr: u16) -> bool; - - pub fn nftnl_rule_set(r: *mut nftnl_rule, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_rule_set_data( - r: *mut nftnl_rule, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_rule_set_u32(r: *mut nftnl_rule, attr: u16, val: u32); - - pub fn nftnl_rule_set_u64(r: *mut nftnl_rule, attr: u16, val: u64); - - pub fn nftnl_rule_set_str(r: *mut nftnl_rule, attr: u16, str_: *const c_char) -> c_int; - - pub fn nftnl_rule_get(r: *const nftnl_rule, attr: u16) -> *const c_void; - - pub fn nftnl_rule_get_data( - r: *const nftnl_rule, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_rule_get_str(r: *const nftnl_rule, attr: u16) -> *const c_char; - - pub fn nftnl_rule_get_u8(r: *const nftnl_rule, attr: u16) -> u8; - - pub fn nftnl_rule_get_u32(r: *const nftnl_rule, attr: u16) -> u32; - - pub fn nftnl_rule_get_u64(r: *const nftnl_rule, attr: u16) -> u64; - - pub fn nftnl_rule_add_expr(r: *mut nftnl_rule, expr: *mut nftnl_expr); - - pub fn nftnl_rule_del_expr(expr: *mut nftnl_expr); - - pub fn nftnl_rule_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *mut nftnl_rule); - - pub fn nftnl_rule_parse( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_parse_file( - r: *mut nftnl_rule, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_rule_snprintf( - buf: *mut c_char, - size: size_t, - t: *const nftnl_rule, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_rule_fprintf(fp: *mut FILE, r: *const nftnl_rule, type_: u32, flags: u32) - -> c_int; - - pub fn nftnl_rule_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_rule) -> c_int; - - pub fn nftnl_expr_foreach( - r: *mut nftnl_rule, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_expr, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_expr_iter(c_void); - -extern "C" { - pub fn nftnl_expr_iter_create(r: *const nftnl_rule) -> *mut nftnl_expr_iter; - - pub fn nftnl_expr_iter_next(iter: *mut nftnl_expr_iter) -> *mut nftnl_expr; - - pub fn nftnl_expr_iter_destroy(iter: *mut nftnl_expr_iter); -} -#[repr(C)] -pub struct nftnl_rule_list(c_void); - -extern "C" { - pub fn nftnl_rule_list_alloc() -> *mut nftnl_rule_list; - - pub fn nftnl_rule_list_free(list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_is_empty(list: *const nftnl_rule_list) -> c_int; - - pub fn nftnl_rule_list_add(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_add_tail(r: *mut nftnl_rule, list: *mut nftnl_rule_list); - - pub fn nftnl_rule_list_insert_at(r: *mut nftnl_rule, pos: *mut nftnl_rule); - - pub fn nftnl_rule_list_del(r: *mut nftnl_rule); - - pub fn nftnl_rule_list_foreach( - rule_list: *mut nftnl_rule_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_rule, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_rule_list_iter(c_void); - -extern "C" { - pub fn nftnl_rule_list_iter_create(l: *const nftnl_rule_list) -> *mut nftnl_rule_list_iter; - - pub fn nftnl_rule_list_iter_cur(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_next(iter: *mut nftnl_rule_list_iter) -> *mut nftnl_rule; - - pub fn nftnl_rule_list_iter_destroy(iter: *const nftnl_rule_list_iter); -} -#[repr(C)] -pub struct nftnl_ruleset(c_void); - -extern "C" { - pub fn nftnl_ruleset_alloc() -> *mut nftnl_ruleset; - - pub fn nftnl_ruleset_free(r: *const nftnl_ruleset); -} -pub const NFTNL_RULESET_TABLELIST: c_uint = 0; -pub const NFTNL_RULESET_CHAINLIST: c_uint = 1; -pub const NFTNL_RULESET_SETLIST: c_uint = 2; -pub const NFTNL_RULESET_RULELIST: c_uint = 3; - -pub const NFTNL_RULESET_UNSPEC: nftnl_ruleset_type = 0; -pub const NFTNL_RULESET_RULESET: nftnl_ruleset_type = 1; -pub const NFTNL_RULESET_TABLE: nftnl_ruleset_type = 2; -pub const NFTNL_RULESET_CHAIN: nftnl_ruleset_type = 3; -pub const NFTNL_RULESET_RULE: nftnl_ruleset_type = 4; -pub const NFTNL_RULESET_SET: nftnl_ruleset_type = 5; -pub const NFTNL_RULESET_SET_ELEMS: nftnl_ruleset_type = 6; -pub type nftnl_ruleset_type = c_uint; -extern "C" { - pub fn nftnl_ruleset_is_set(r: *const nftnl_ruleset, attr: u16) -> bool; - - pub fn nftnl_ruleset_unset(r: *mut nftnl_ruleset, attr: u16); - - pub fn nftnl_ruleset_set(r: *mut nftnl_ruleset, attr: u16, data: *mut c_void); - - pub fn nftnl_ruleset_get(r: *const nftnl_ruleset, attr: u16) -> *mut c_void; -} -pub const NFTNL_RULESET_CTX_CMD: c_uint = 0; -pub const NFTNL_RULESET_CTX_TYPE: c_uint = 1; -pub const NFTNL_RULESET_CTX_TABLE: c_uint = 2; -pub const NFTNL_RULESET_CTX_CHAIN: c_uint = 3; -pub const NFTNL_RULESET_CTX_RULE: c_uint = 4; -pub const NFTNL_RULESET_CTX_SET: c_uint = 5; -pub const NFTNL_RULESET_CTX_DATA: c_uint = 6; - -#[repr(C)] -pub struct nftnl_parse_ctx(c_void); - -extern "C" { - pub fn nftnl_ruleset_ctx_free(ctx: *const nftnl_parse_ctx); - - pub fn nftnl_ruleset_ctx_is_set(ctx: *const nftnl_parse_ctx, attr: u16) -> bool; - - pub fn nftnl_ruleset_ctx_get(ctx: *const nftnl_parse_ctx, attr: u16) -> *mut c_void; - - pub fn nftnl_ruleset_ctx_get_u32(ctx: *const nftnl_parse_ctx, attr: u16) -> u32; - - pub fn nftnl_ruleset_parse_file_cb( - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse_buffer_cb( - type_: nftnl_parse_type, - buffer: *const c_char, - err: *mut nftnl_parse_err, - data: *mut c_void, - cb: Option<unsafe extern "C" fn(ctx: *const nftnl_parse_ctx) -> c_int>, - ) -> c_int; - - pub fn nftnl_ruleset_parse( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_parse_file( - rs: *mut nftnl_ruleset, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_ruleset_snprintf( - buf: *mut c_char, - size: size_t, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_ruleset_fprintf( - fp: *mut FILE, - rs: *const nftnl_ruleset, - type_: u32, - flags: u32, - ) -> c_int; -} -pub const NFTNL_SET_TABLE: nftnl_set_attr = 0; -pub const NFTNL_SET_NAME: nftnl_set_attr = 1; -pub const NFTNL_SET_FLAGS: nftnl_set_attr = 2; -pub const NFTNL_SET_KEY_TYPE: nftnl_set_attr = 3; -pub const NFTNL_SET_KEY_LEN: nftnl_set_attr = 4; -pub const NFTNL_SET_DATA_TYPE: nftnl_set_attr = 5; -pub const NFTNL_SET_DATA_LEN: nftnl_set_attr = 6; -pub const NFTNL_SET_FAMILY: nftnl_set_attr = 7; -pub const NFTNL_SET_ID: nftnl_set_attr = 8; -pub const NFTNL_SET_POLICY: nftnl_set_attr = 9; -pub const NFTNL_SET_DESC_SIZE: nftnl_set_attr = 10; -pub const NFTNL_SET_TIMEOUT: nftnl_set_attr = 11; -pub const NFTNL_SET_GC_INTERVAL: nftnl_set_attr = 12; -pub const NFTNL_SET_USERDATA: nftnl_set_attr = 13; -pub const NFTNL_SET_OBJ_TYPE: nftnl_set_attr = 14; -pub const NFTNL_SET_HANDLE: nftnl_set_attr = 15; -pub const NFTNL_SET_DESC_CONCAT: nftnl_set_attr = 16; -pub const NFTNL_SET_EXPR: nftnl_set_attr = 17; -pub const NFTNL_SET_EXPRESSIONS: nftnl_set_attr = 18; -pub const __NFTNL_SET_MAX: nftnl_set_attr = 19; -pub type nftnl_set_attr = c_uint; -#[repr(C)] -pub struct nftnl_set(c_void); - -extern "C" { - pub fn nftnl_set_alloc() -> *mut nftnl_set; - - pub fn nftnl_set_free(s: *const nftnl_set); - - pub fn nftnl_set_clone(set: *const nftnl_set) -> *mut nftnl_set; - - pub fn nftnl_set_is_set(s: *const nftnl_set, attr: u16) -> bool; - - pub fn nftnl_set_unset(s: *mut nftnl_set, attr: u16); - - pub fn nftnl_set_set(s: *mut nftnl_set, attr: u16, data: *const c_void) -> c_int; - - pub fn nftnl_set_set_data( - s: *mut nftnl_set, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_set_u32(s: *mut nftnl_set, attr: u16, val: u32); - - pub fn nftnl_set_set_u64(s: *mut nftnl_set, attr: u16, val: u64); - - pub fn nftnl_set_set_str(s: *mut nftnl_set, attr: u16, str_: *const c_char) -> c_int; - - pub fn nftnl_set_get(s: *const nftnl_set, attr: u16) -> *const c_void; - - pub fn nftnl_set_get_data(s: *const nftnl_set, attr: u16, data_len: *mut u32) -> *const c_void; - - pub fn nftnl_set_get_str(s: *const nftnl_set, attr: u16) -> *const c_char; - - pub fn nftnl_set_get_u32(s: *const nftnl_set, attr: u16) -> u32; - - pub fn nftnl_set_get_u64(s: *const nftnl_set, attr: u16) -> u64; - - pub fn nftnl_set_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_elems_nlmsg_parse(nlh: *const nlmsghdr, s: *mut nftnl_set) -> c_int; - - pub fn nftnl_set_snprintf( - buf: *mut c_char, - size: size_t, - s: *const nftnl_set, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_fprintf(fp: *mut FILE, s: *const nftnl_set, type_: u32, flags: u32) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list(c_void); - -extern "C" { - pub fn nftnl_set_list_alloc() -> *mut nftnl_set_list; - - pub fn nftnl_set_list_free(list: *mut nftnl_set_list); - - pub fn nftnl_set_list_is_empty(list: *const nftnl_set_list) -> c_int; - - pub fn nftnl_set_list_add(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_add_tail(s: *mut nftnl_set, list: *mut nftnl_set_list); - - pub fn nftnl_set_list_del(s: *mut nftnl_set); - - pub fn nftnl_set_list_foreach( - set_list: *mut nftnl_set_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_set, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_set_list_lookup_byname( - set_list: *mut nftnl_set_list, - set: *const c_char, - ) -> *mut nftnl_set; - - pub fn nftnl_set_add_expr(s: *mut nftnl_set, expr: *mut nftnl_expr); - - pub fn nftnl_set_expr_foreach( - s: *const nftnl_set, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_expr, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_list_iter(c_void); - -extern "C" { - pub fn nftnl_set_list_iter_create(l: *const nftnl_set_list) -> *mut nftnl_set_list_iter; - - pub fn nftnl_set_list_iter_cur(iter: *const nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_next(iter: *mut nftnl_set_list_iter) -> *mut nftnl_set; - - pub fn nftnl_set_list_iter_destroy(iter: *const nftnl_set_list_iter); - - pub fn nftnl_set_parse( - s: *mut nftnl_set, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_parse_file( - s: *mut nftnl_set, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; -} -pub const NFTNL_SET_ELEM_FLAGS: c_uint = 0; -pub const NFTNL_SET_ELEM_KEY: c_uint = 1; -pub const NFTNL_SET_ELEM_VERDICT: c_uint = 2; -pub const NFTNL_SET_ELEM_CHAIN: c_uint = 3; -pub const NFTNL_SET_ELEM_DATA: c_uint = 4; -pub const NFTNL_SET_ELEM_TIMEOUT: c_uint = 5; -pub const NFTNL_SET_ELEM_EXPIRATION: c_uint = 6; -pub const NFTNL_SET_ELEM_USERDATA: c_uint = 7; -pub const NFTNL_SET_ELEM_EXPR: c_uint = 8; -pub const NFTNL_SET_ELEM_OBJREF: c_uint = 9; -pub const NFTNL_SET_ELEM_KEY_END: c_uint = 10; -pub const NFTNL_SET_ELEM_EXPRESSIONS: c_uint = 11; -pub const __NFTNL_SET_ELEM_MAX: c_uint = 12; - -#[repr(C)] -pub struct nftnl_set_elem(c_void); - -extern "C" { - pub fn nftnl_set_elem_alloc() -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_free(s: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_clone(elem: *mut nftnl_set_elem) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elem_add(s: *mut nftnl_set, elem: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_unset(s: *mut nftnl_set_elem, attr: u16); - - pub fn nftnl_set_elem_set( - s: *mut nftnl_set_elem, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_set_elem_set_u32(s: *mut nftnl_set_elem, attr: u16, val: u32); - - pub fn nftnl_set_elem_set_u64(s: *mut nftnl_set_elem, attr: u16, val: u64); - - pub fn nftnl_set_elem_set_str(s: *mut nftnl_set_elem, attr: u16, str_: *const c_char) -> c_int; - - pub fn nftnl_set_elem_get( - s: *mut nftnl_set_elem, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_set_elem_get_str(s: *mut nftnl_set_elem, attr: u16) -> *const c_char; - - pub fn nftnl_set_elem_get_u32(s: *mut nftnl_set_elem, attr: u16) -> u32; - - pub fn nftnl_set_elem_get_u64(s: *mut nftnl_set_elem, attr: u16) -> u64; - - pub fn nftnl_set_elem_is_set(s: *const nftnl_set_elem, attr: u16) -> bool; - - pub fn nftnl_set_elems_nlmsg_build_payload(nlh: *mut nlmsghdr, s: *mut nftnl_set); - - pub fn nftnl_set_elem_nlmsg_build_payload(nlh: *mut nlmsghdr, e: *mut nftnl_set_elem); - - pub fn nftnl_set_elem_parse( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_parse_file( - e: *mut nftnl_set_elem, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_set_elem_snprintf( - buf: *mut c_char, - size: size_t, - s: *const nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_fprintf( - fp: *mut FILE, - se: *const nftnl_set_elem, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_set_elem_add_expr(e: *mut nftnl_set_elem, expr: *mut nftnl_expr); - - pub fn nftnl_set_elem_expr_foreach( - e: *mut nftnl_set_elem, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_expr, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_set_elem_foreach( - s: *mut nftnl_set, - cb: Option<unsafe extern "C" fn(e: *mut nftnl_set_elem, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_set_elems_iter(c_void); - -extern "C" { - pub fn nftnl_set_elems_iter_create(s: *const nftnl_set) -> *mut nftnl_set_elems_iter; - - pub fn nftnl_set_elems_iter_cur(iter: *const nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_next(iter: *mut nftnl_set_elems_iter) -> *mut nftnl_set_elem; - - pub fn nftnl_set_elems_iter_destroy(iter: *mut nftnl_set_elems_iter); - - pub fn nftnl_set_elems_nlmsg_build_payload_iter( - nlh: *mut nlmsghdr, - iter: *mut nftnl_set_elems_iter, - ) -> c_int; -} -#[repr(C)] -pub struct nftnl_table(c_void); - -extern "C" { - pub fn nftnl_table_alloc() -> *mut nftnl_table; - - pub fn nftnl_table_free(arg1: *const nftnl_table); -} -pub const NFTNL_TABLE_NAME: nftnl_table_attr = 0; -pub const NFTNL_TABLE_FAMILY: nftnl_table_attr = 1; -pub const NFTNL_TABLE_FLAGS: nftnl_table_attr = 2; -pub const NFTNL_TABLE_USE: nftnl_table_attr = 3; -pub const NFTNL_TABLE_HANDLE: nftnl_table_attr = 4; -pub const NFTNL_TABLE_USERDATA: nftnl_table_attr = 5; -pub const NFTNL_TABLE_OWNER: nftnl_table_attr = 6; -pub const __NFTNL_TABLE_MAX: nftnl_table_attr = 7; -pub type nftnl_table_attr = c_uint; -extern "C" { - pub fn nftnl_table_is_set(t: *const nftnl_table, attr: u16) -> bool; - - pub fn nftnl_table_unset(t: *mut nftnl_table, attr: u16); - - pub fn nftnl_table_set(t: *mut nftnl_table, attr: u16, data: *const c_void); - - pub fn nftnl_table_set_data( - t: *mut nftnl_table, - attr: u16, - data: *const c_void, - data_len: u32, - ) -> c_int; - - pub fn nftnl_table_get(t: *const nftnl_table, attr: u16) -> *const c_void; - - pub fn nftnl_table_get_data( - t: *const nftnl_table, - attr: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_table_set_u8(t: *mut nftnl_table, attr: u16, data: u8); - - pub fn nftnl_table_set_u32(t: *mut nftnl_table, attr: u16, data: u32); - - pub fn nftnl_table_set_u64(t: *mut nftnl_table, attr: u16, data: u64); - - pub fn nftnl_table_set_str(t: *mut nftnl_table, attr: u16, str_: *const c_char) -> c_int; - - pub fn nftnl_table_get_u8(t: *const nftnl_table, attr: u16) -> u8; - - pub fn nftnl_table_get_u32(t: *const nftnl_table, attr: u16) -> u32; - - pub fn nftnl_table_get_u64(t: *const nftnl_table, attr: u16) -> u64; - - pub fn nftnl_table_get_str(t: *const nftnl_table, attr: u16) -> *const c_char; - - pub fn nftnl_table_nlmsg_build_payload(nlh: *mut nlmsghdr, t: *const nftnl_table); - - pub fn nftnl_table_parse( - t: *mut nftnl_table, - type_: nftnl_parse_type, - data: *const c_char, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_parse_file( - t: *mut nftnl_table, - type_: nftnl_parse_type, - fp: *mut FILE, - err: *mut nftnl_parse_err, - ) -> c_int; - - pub fn nftnl_table_snprintf( - buf: *mut c_char, - size: size_t, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_fprintf( - fp: *mut FILE, - t: *const nftnl_table, - type_: u32, - flags: u32, - ) -> c_int; - - pub fn nftnl_table_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_table) -> c_int; -} -#[repr(C)] -pub struct nftnl_table_list(c_void); - -extern "C" { - pub fn nftnl_table_list_alloc() -> *mut nftnl_table_list; - - pub fn nftnl_table_list_free(list: *mut nftnl_table_list); - - pub fn nftnl_table_list_is_empty(list: *const nftnl_table_list) -> c_int; - - pub fn nftnl_table_list_foreach( - table_list: *mut nftnl_table_list, - cb: Option<unsafe extern "C" fn(t: *mut nftnl_table, data: *mut c_void) -> c_int>, - data: *mut c_void, - ) -> c_int; - - pub fn nftnl_table_list_add(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_add_tail(r: *mut nftnl_table, list: *mut nftnl_table_list); - - pub fn nftnl_table_list_del(r: *mut nftnl_table); -} -#[repr(C)] -pub struct nftnl_table_list_iter(c_void); - -extern "C" { - pub fn nftnl_table_list_iter_create(l: *const nftnl_table_list) -> *mut nftnl_table_list_iter; - - pub fn nftnl_table_list_iter_next(iter: *mut nftnl_table_list_iter) -> *mut nftnl_table; - - pub fn nftnl_table_list_iter_destroy(iter: *const nftnl_table_list_iter); -} -pub const NFTNL_TRACE_CHAIN: nftnl_trace_attr = 0; -pub const NFTNL_TRACE_FAMILY: nftnl_trace_attr = 1; -pub const NFTNL_TRACE_ID: nftnl_trace_attr = 2; -pub const NFTNL_TRACE_IIF: nftnl_trace_attr = 3; -pub const NFTNL_TRACE_IIFTYPE: nftnl_trace_attr = 4; -pub const NFTNL_TRACE_JUMP_TARGET: nftnl_trace_attr = 5; -pub const NFTNL_TRACE_OIF: nftnl_trace_attr = 6; -pub const NFTNL_TRACE_OIFTYPE: nftnl_trace_attr = 7; -pub const NFTNL_TRACE_MARK: nftnl_trace_attr = 8; -pub const NFTNL_TRACE_LL_HEADER: nftnl_trace_attr = 9; -pub const NFTNL_TRACE_NETWORK_HEADER: nftnl_trace_attr = 10; -pub const NFTNL_TRACE_TRANSPORT_HEADER: nftnl_trace_attr = 11; -pub const NFTNL_TRACE_TABLE: nftnl_trace_attr = 12; -pub const NFTNL_TRACE_TYPE: nftnl_trace_attr = 13; -pub const NFTNL_TRACE_RULE_HANDLE: nftnl_trace_attr = 14; -pub const NFTNL_TRACE_VERDICT: nftnl_trace_attr = 15; -pub const NFTNL_TRACE_NFPROTO: nftnl_trace_attr = 16; -pub const NFTNL_TRACE_POLICY: nftnl_trace_attr = 17; -pub const __NFTNL_TRACE_MAX: nftnl_trace_attr = 18; -pub type nftnl_trace_attr = c_uint; -#[repr(C)] -pub struct nftnl_trace(c_void); - -extern "C" { - pub fn nftnl_trace_alloc() -> *mut nftnl_trace; - - pub fn nftnl_trace_free(trace: *const nftnl_trace); - - pub fn nftnl_trace_is_set(trace: *const nftnl_trace, type_: u16) -> bool; - - pub fn nftnl_trace_get_data( - trace: *const nftnl_trace, - type_: u16, - data_len: *mut u32, - ) -> *const c_void; - - pub fn nftnl_trace_get_u16(trace: *const nftnl_trace, type_: u16) -> u16; - - pub fn nftnl_trace_get_u32(trace: *const nftnl_trace, type_: u16) -> u32; - - pub fn nftnl_trace_get_u64(trace: *const nftnl_trace, type_: u16) -> u64; - - pub fn nftnl_trace_get_str(trace: *const nftnl_trace, type_: u16) -> *const c_char; - - pub fn nftnl_trace_nlmsg_parse(nlh: *const nlmsghdr, t: *mut nftnl_trace) -> c_int; -} -pub const NFTNL_UDATA_TABLE_COMMENT: nftnl_udata_table_types = 0; -pub const __NFTNL_UDATA_TABLE_MAX: nftnl_udata_table_types = 1; -pub type nftnl_udata_table_types = c_uint; -pub const NFTNL_UDATA_CHAIN_COMMENT: nftnl_udata_chain_types = 0; -pub const __NFTNL_UDATA_CHAIN_MAX: nftnl_udata_chain_types = 1; -pub type nftnl_udata_chain_types = c_uint; -pub const NFTNL_UDATA_RULE_COMMENT: nftnl_udata_rule_types = 0; -pub const NFTNL_UDATA_RULE_EBTABLES_POLICY: nftnl_udata_rule_types = 1; -pub const __NFTNL_UDATA_RULE_MAX: nftnl_udata_rule_types = 2; -pub type nftnl_udata_rule_types = c_uint; -pub const NFTNL_UDATA_OBJ_COMMENT: nftnl_udata_obj_types = 0; -pub const __NFTNL_UDATA_OBJ_MAX: nftnl_udata_obj_types = 1; -pub type nftnl_udata_obj_types = c_uint; -pub const NFTNL_UDATA_SET_KEYBYTEORDER: nftnl_udata_set_types = 0; -pub const NFTNL_UDATA_SET_DATABYTEORDER: nftnl_udata_set_types = 1; -pub const NFTNL_UDATA_SET_MERGE_ELEMENTS: nftnl_udata_set_types = 2; -pub const NFTNL_UDATA_SET_KEY_TYPEOF: nftnl_udata_set_types = 3; -pub const NFTNL_UDATA_SET_DATA_TYPEOF: nftnl_udata_set_types = 4; -pub const NFTNL_UDATA_SET_EXPR: nftnl_udata_set_types = 5; -pub const NFTNL_UDATA_SET_DATA_INTERVAL: nftnl_udata_set_types = 6; -pub const NFTNL_UDATA_SET_COMMENT: nftnl_udata_set_types = 7; -pub const __NFTNL_UDATA_SET_MAX: nftnl_udata_set_types = 8; -pub type nftnl_udata_set_types = c_uint; -pub const NFTNL_UDATA_SET_TYPEOF_EXPR: c_uint = 0; -pub const NFTNL_UDATA_SET_TYPEOF_DATA: c_uint = 1; -pub const __NFTNL_UDATA_SET_TYPEOF_MAX: c_uint = 2; - -pub const NFTNL_UDATA_SET_ELEM_COMMENT: nftnl_udata_set_elem_types = 0; -pub const NFTNL_UDATA_SET_ELEM_FLAGS: nftnl_udata_set_elem_types = 1; -pub const __NFTNL_UDATA_SET_ELEM_MAX: nftnl_udata_set_elem_types = 2; -pub type nftnl_udata_set_elem_types = c_uint; -pub const NFTNL_SET_ELEM_F_INTERVAL_OPEN: nftnl_udata_set_elem_flags = 1; -pub type nftnl_udata_set_elem_flags = c_uint; -#[repr(C)] -pub struct nftnl_udata(c_void); - -#[repr(C)] -pub struct nftnl_udata_buf(c_void); - -extern "C" { - pub fn nftnl_udata_buf_alloc(data_size: u32) -> *mut nftnl_udata_buf; - - pub fn nftnl_udata_buf_free(buf: *const nftnl_udata_buf); - - pub fn nftnl_udata_buf_len(buf: *const nftnl_udata_buf) -> u32; - - pub fn nftnl_udata_buf_data(buf: *const nftnl_udata_buf) -> *mut c_void; - - pub fn nftnl_udata_buf_put(buf: *mut nftnl_udata_buf, data: *const c_void, len: u32); - - pub fn nftnl_udata_start(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_end(buf: *const nftnl_udata_buf) -> *mut nftnl_udata; - - pub fn nftnl_udata_put( - buf: *mut nftnl_udata_buf, - type_: u8, - len: u32, - value: *const c_void, - ) -> bool; - - pub fn nftnl_udata_put_u32(buf: *mut nftnl_udata_buf, type_: u8, data: u32) -> bool; - - pub fn nftnl_udata_put_strz(buf: *mut nftnl_udata_buf, type_: u8, strz: *const c_char) -> bool; - - pub fn nftnl_udata_nest_start(buf: *mut nftnl_udata_buf, type_: u8) -> *mut nftnl_udata; - - pub fn nftnl_udata_nest_end(buf: *mut nftnl_udata_buf, ud: *mut nftnl_udata); - - pub fn nftnl_udata_type(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_len(attr: *const nftnl_udata) -> u8; - - pub fn nftnl_udata_get(attr: *const nftnl_udata) -> *mut c_void; - - pub fn nftnl_udata_get_u32(attr: *const nftnl_udata) -> u32; - - pub fn nftnl_udata_next(attr: *const nftnl_udata) -> *mut nftnl_udata; -} -pub type nftnl_udata_cb_t = - Option<unsafe extern "C" fn(attr: *const nftnl_udata, data: *mut c_void) -> c_int>; -extern "C" { - pub fn nftnl_udata_parse( - data: *const c_void, - data_len: u32, - cb: nftnl_udata_cb_t, - cb_data: *mut c_void, - ) -> c_int; -} diff --git a/rustables/Cargo.toml b/rustables/Cargo.toml index d948055..5ac819b 100644 --- a/rustables/Cargo.toml +++ b/rustables/Cargo.toml @@ -13,20 +13,12 @@ edition = "2018" [features] query = [] unsafe-raw-handles = [] -nftnl-1-0-7 = ["rustables-sys/nftnl-1-0-7"] -nftnl-1-0-8 = ["rustables-sys/nftnl-1-0-8"] -nftnl-1-0-9 = ["rustables-sys/nftnl-1-0-9"] -nftnl-1-1-0 = ["rustables-sys/nftnl-1-1-0"] -nftnl-1-1-1 = ["rustables-sys/nftnl-1-1-1"] -nftnl-1-1-2 = ["rustables-sys/nftnl-1-1-2"] -nftnl-1-2-0 = ["rustables-sys/nftnl-1-2-0"] -default = ["nftnl-1-2-0"] [dependencies] bitflags = "1.0" thiserror = "1.0" log = "0.4" -rustables-sys = { path = "../rustables-sys", version = "0.7" } +libc = "0.2.43" mnl = "0.2" [dev-dependencies] @@ -34,6 +26,7 @@ ipnetwork = "0.16" [build-dependencies] bindgen = "0.53.1" +pkg-config = "0.3" regex = "1.5.4" lazy_static = "1.4.0" diff --git a/rustables/build.rs b/rustables/build.rs index fee34ff..180e06b 100644 --- a/rustables/build.rs +++ b/rustables/build.rs @@ -1,13 +1,64 @@ use bindgen; - +use lazy_static::lazy_static; +use regex::{Captures, Regex}; +use pkg_config; +use std::env; use std::fs::File; use std::io::Write; use std::path::PathBuf; use std::borrow::Cow; -use lazy_static::lazy_static; -use regex::{Captures, Regex}; +const SYS_HEADER_FILE: &str = "wrapper.h"; +const SYS_BINDINGS_FILE: &str = "src/sys.rs"; +const TESTS_HEADER_FILE: &str = "tests_wrapper.h"; +const TESTS_BINDINGS_FILE: &str = "tests/sys.rs"; +const MIN_LIBNFTNL_VERSION: &str = "1.0.6"; + + +fn get_env(var: &'static str) -> Option<PathBuf> { + println!("cargo:rerun-if-env-changed={}", var); + env::var_os(var).map(PathBuf::from) +} + +/// Set env vars to help rustc find linked libraries. +fn setup_libs() { + if let Some(lib_dir) = get_env("LIBNFTNL_LIB_DIR") { + if !lib_dir.is_dir() { + panic!( + "libnftnl library directory does not exist: {}", + lib_dir.display() + ); + } + println!("cargo:rustc-link-search=native={}", lib_dir.display()); + println!("cargo:rustc-link-lib=nftnl"); + } else { + // Trying with pkg-config instead + println!("Minimum libnftnl version: {}", MIN_LIBNFTNL_VERSION); + pkg_config::Config::new() + .atleast_version(MIN_LIBNFTNL_VERSION) + .probe("libnftnl") + .unwrap(); + } + + if let Some(lib_dir) = get_env("LIBMNL_LIB_DIR") { + if !lib_dir.is_dir() { + panic!( + "libmnl library directory does not exist: {}", + lib_dir.display() + ); + } + println!("cargo:rustc-link-search=native={}", lib_dir.display()); + println!("cargo:rustc-link-lib=mnl"); + } else { + // Trying with pkg-config instead + pkg_config::Config::new() + .atleast_version("1.0.0") + .probe("libmnl") + .unwrap(); + } +} + /// Recast nft_*_attributes from u32 to u16 in header file `before`. fn reformat_units(before: &str) -> Cow<str> { lazy_static! { @@ -18,31 +69,92 @@ fn reformat_units(before: &str) -> Cow<str> { }) } -fn main() { +fn generate_consts() { // Tell cargo to invalidate the built crate whenever the headers change. - println!("cargo:rerun-if-changed=wrapper.h"); + println!("cargo:rerun-if-changed={}", SYS_HEADER_FILE); let bindings = bindgen::Builder::default() - .header("wrapper.h") + .header(SYS_HEADER_FILE) .generate_comments(false) .prepend_enum_name(false) + .use_core() + .whitelist_function("^nftnl_.+$") + .whitelist_type("^nftnl_.+$") + .whitelist_var("^nftnl_.+$") + .whitelist_var("^NFTNL_.+$") + .blacklist_type("(FILE|iovec)") + .blacklist_type("^_IO_.+$") + .blacklist_type("^__.+$") + .blacklist_type("nlmsghdr") + .raw_line("#![allow(non_camel_case_types)]\n\n") + .raw_line("pub use libc;") + .raw_line("use libc::{c_char, c_int, c_ulong, c_void, iovec, nlmsghdr, FILE};") + .raw_line("use core::option::Option;") + .ctypes_prefix("libc") // Tell cargo to invalidate the built crate whenever any of the // included header files changed. .parse_callbacks(Box::new(bindgen::CargoCallbacks)) // Finish the builder and generate the bindings. .generate() // Unwrap the Result and panic on failure. - .expect("Unable to generate bindings"); + .expect("Error: unable to generate bindings"); + + let mut s = bindings.to_string() + // Add newlines because in alpine bindgen doesn't add them after + // statements. + .replace(" ; ", ";\n") + .replace("#[derive(Debug, Copy, Clone)]", ""); + let re = Regex::new(r"libc::(c_[a-z]*)").unwrap(); + s = re.replace_all(&s, "$1").into(); + let re = Regex::new(r"::core::option::(Option)").unwrap(); + s = re.replace_all(&s, "$1").into(); + let re = Regex::new(r"_bindgen_ty_[0-9]+").unwrap(); + s = re.replace_all(&s, "u32").into(); + // Change struct bodies to c_void. + let re = Regex::new(r"(pub struct .*) \{\n *_unused: \[u8; 0\],\n\}\n").unwrap(); + s = re.replace_all(&s, "$1(c_void);\n").into(); + let re = Regex::new(r"pub type u32 = u32;\n").unwrap(); + s = re.replace_all(&s, "").into(); + + // Write the bindings to the rust header file. + let out_path = PathBuf::from(SYS_BINDINGS_FILE); + File::create(out_path) + .expect("Error: could not create rust header file.") + .write_all(&s.as_bytes()) + .expect("Error: could not write to the rust header file."); +} + +fn generate_test_consts() { + // Tell cargo to invalidate the built crate whenever the headers change. + println!("cargo:rerun-if-changed={}", TESTS_HEADER_FILE); + + let bindings = bindgen::Builder::default() + .header(TESTS_HEADER_FILE) + .generate_comments(false) + .prepend_enum_name(false) + .raw_line("#![allow(non_camel_case_types, dead_code)]\n\n") + // Tell cargo to invalidate the built crate whenever any of the + // included header files changed. + .parse_callbacks(Box::new(bindgen::CargoCallbacks)) + // Finish the builder and generate the bindings. + .generate() + // Unwrap the Result and panic on failure. + .expect("Error: unable to generate bindings needed for tests."); // Add newlines because in alpine bindgen doesn't add them after statements. let s = bindings.to_string().replace(" ; ", ";\n"); let s = reformat_units(&s); - let h = String::from("#![allow(non_camel_case_types, dead_code)]\n\n") + &s; // Write the bindings to the rust header file. - let out_path = PathBuf::from("src/tests/bindings.rs"); + let out_path = PathBuf::from(TESTS_BINDINGS_FILE); File::create(out_path) .expect("Error: could not create rust header file.") - .write_all(&h.as_bytes()) + .write_all(&s.as_bytes()) .expect("Error: could not write to the rust header file."); } + +fn main() { + setup_libs(); + generate_consts(); + generate_test_consts(); +} diff --git a/rustables/examples/add-rules.rs b/rustables/examples/add-rules.rs index 4fea491..3aae7ee 100644 --- a/rustables/examples/add-rules.rs +++ b/rustables/examples/add-rules.rs @@ -37,7 +37,7 @@ //! ``` use ipnetwork::{IpNetwork, Ipv4Network}; -use rustables::{nft_expr, rustables_sys::libc, Batch, Chain, FinalizedBatch, ProtoFamily, Rule, Table}; +use rustables::{nft_expr, sys::libc, Batch, Chain, FinalizedBatch, ProtoFamily, Rule, Table}; use std::{ ffi::{self, CString}, io, diff --git a/rustables/examples/filter-ethernet.rs b/rustables/examples/filter-ethernet.rs index 23be8a1..b16c49e 100644 --- a/rustables/examples/filter-ethernet.rs +++ b/rustables/examples/filter-ethernet.rs @@ -22,7 +22,7 @@ //! # nft delete table inet example-filter-ethernet //! ``` -use rustables::{nft_expr, rustables_sys::libc, Batch, Chain, FinalizedBatch, ProtoFamily, Rule, Table}; +use rustables::{nft_expr, sys::libc, Batch, Chain, FinalizedBatch, ProtoFamily, Rule, Table}; use std::{ffi::CString, io, rc::Rc}; const TABLE_NAME: &str = "example-filter-ethernet"; diff --git a/rustables/src/batch.rs b/rustables/src/batch.rs index 3cdd52b..c8ec5aa 100644 --- a/rustables/src/batch.rs +++ b/rustables/src/batch.rs @@ -1,5 +1,5 @@ use crate::{MsgType, NlMsg}; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self as sys, libc}; use std::ffi::c_void; use std::os::raw::c_char; use std::ptr; @@ -157,7 +157,7 @@ impl FinalizedBatch { }; num_pages ]; - let iovecs_ptr = iovecs.as_mut_ptr() as *mut [u8; 0]; + let iovecs_ptr = iovecs.as_mut_ptr(); unsafe { sys::nftnl_batch_iovec(self.batch.batch, iovecs_ptr, num_pages as u32); } diff --git a/rustables/src/chain.rs b/rustables/src/chain.rs index ac9c57d..20043ac 100644 --- a/rustables/src/chain.rs +++ b/rustables/src/chain.rs @@ -1,5 +1,5 @@ use crate::{MsgType, Table}; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self as sys, libc}; #[cfg(feature = "query")] use std::convert::TryFrom; use std::{ diff --git a/rustables/src/expr/bitwise.rs b/rustables/src/expr/bitwise.rs index a5d9343..59ef41b 100644 --- a/rustables/src/expr/bitwise.rs +++ b/rustables/src/expr/bitwise.rs @@ -1,5 +1,5 @@ use super::{Expression, Rule, ToSlice}; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self, libc}; use std::ffi::c_void; use std::os::raw::c_char; diff --git a/rustables/src/expr/cmp.rs b/rustables/src/expr/cmp.rs index 747974d..384f0b4 100644 --- a/rustables/src/expr/cmp.rs +++ b/rustables/src/expr/cmp.rs @@ -1,5 +1,5 @@ use super::{DeserializationError, Expression, Rule, ToSlice}; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self, libc}; use std::{ borrow::Cow, ffi::{c_void, CString}, diff --git a/rustables/src/expr/counter.rs b/rustables/src/expr/counter.rs index 099e7fa..71064df 100644 --- a/rustables/src/expr/counter.rs +++ b/rustables/src/expr/counter.rs @@ -1,5 +1,5 @@ use super::{DeserializationError, Expression, Rule}; -use rustables_sys as sys; +use crate::sys; use std::os::raw::c_char; /// A counter expression adds a counter to the rule that is incremented to count number of packets diff --git a/rustables/src/expr/ct.rs b/rustables/src/expr/ct.rs index 001aef8..7d6614c 100644 --- a/rustables/src/expr/ct.rs +++ b/rustables/src/expr/ct.rs @@ -1,5 +1,5 @@ use super::{DeserializationError, Expression, Rule}; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self, libc}; use std::os::raw::c_char; bitflags::bitflags! { diff --git a/rustables/src/expr/immediate.rs b/rustables/src/expr/immediate.rs index ff4ad04..0787e06 100644 --- a/rustables/src/expr/immediate.rs +++ b/rustables/src/expr/immediate.rs @@ -1,5 +1,5 @@ use super::{DeserializationError, Expression, Register, Rule, ToSlice}; -use rustables_sys as sys; +use crate::sys; use std::ffi::c_void; use std::os::raw::c_char; diff --git a/rustables/src/expr/log.rs b/rustables/src/expr/log.rs index db96ba9..5c06897 100644 --- a/rustables/src/expr/log.rs +++ b/rustables/src/expr/log.rs @@ -1,5 +1,5 @@ use super::{DeserializationError, Expression, Rule}; -use rustables_sys as sys; +use crate::sys; use std::ffi::{CStr, CString}; use std::os::raw::c_char; use thiserror::Error; diff --git a/rustables/src/expr/lookup.rs b/rustables/src/expr/lookup.rs index 7796b29..8e288a0 100644 --- a/rustables/src/expr/lookup.rs +++ b/rustables/src/expr/lookup.rs @@ -1,6 +1,6 @@ use super::{DeserializationError, Expression, Rule}; use crate::set::Set; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self, libc}; use std::ffi::{CStr, CString}; use std::os::raw::c_char; diff --git a/rustables/src/expr/masquerade.rs b/rustables/src/expr/masquerade.rs index 40565d5..c1a06de 100644 --- a/rustables/src/expr/masquerade.rs +++ b/rustables/src/expr/masquerade.rs @@ -1,5 +1,5 @@ use super::{DeserializationError, Expression, Rule}; -use rustables_sys as sys; +use crate::sys; use std::os::raw::c_char; /// Sets the source IP to that of the output interface. diff --git a/rustables/src/expr/meta.rs b/rustables/src/expr/meta.rs index 199f3d3..bf77774 100644 --- a/rustables/src/expr/meta.rs +++ b/rustables/src/expr/meta.rs @@ -1,5 +1,5 @@ use super::{DeserializationError, Expression, Rule}; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self, libc}; use std::os::raw::c_char; /// A meta expression refers to meta data associated with a packet. diff --git a/rustables/src/expr/mod.rs b/rustables/src/expr/mod.rs index b20a752..fbf49d6 100644 --- a/rustables/src/expr/mod.rs +++ b/rustables/src/expr/mod.rs @@ -9,7 +9,7 @@ use std::net::Ipv4Addr; use std::net::Ipv6Addr; use super::rule::Rule; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self, libc}; use thiserror::Error; mod bitwise; diff --git a/rustables/src/expr/nat.rs b/rustables/src/expr/nat.rs index 51f439f..8beaa30 100644 --- a/rustables/src/expr/nat.rs +++ b/rustables/src/expr/nat.rs @@ -1,6 +1,6 @@ use super::{DeserializationError, Expression, Register, Rule}; use crate::ProtoFamily; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self, libc}; use std::{convert::TryFrom, os::raw::c_char}; #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] diff --git a/rustables/src/expr/payload.rs b/rustables/src/expr/payload.rs index 334c939..7612fd9 100644 --- a/rustables/src/expr/payload.rs +++ b/rustables/src/expr/payload.rs @@ -1,5 +1,5 @@ use super::{DeserializationError, Expression, Rule}; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self, libc}; use std::os::raw::c_char; pub trait HeaderField { diff --git a/rustables/src/expr/register.rs b/rustables/src/expr/register.rs index 2cfcc3b..f0aed94 100644 --- a/rustables/src/expr/register.rs +++ b/rustables/src/expr/register.rs @@ -1,6 +1,6 @@ use std::fmt::Debug; -use rustables_sys::libc; +use crate::sys::libc; use super::DeserializationError; diff --git a/rustables/src/expr/reject.rs b/rustables/src/expr/reject.rs index 550a287..2ea0cbf 100644 --- a/rustables/src/expr/reject.rs +++ b/rustables/src/expr/reject.rs @@ -1,9 +1,6 @@ use super::{DeserializationError, Expression, Rule}; use crate::ProtoFamily; -use rustables_sys::{ - self as sys, - libc::{self, c_char}, -}; +use crate::sys::{self, libc::{self, c_char}}; /// A reject expression that defines the type of rejection message sent /// when discarding a packet. diff --git a/rustables/src/expr/verdict.rs b/rustables/src/expr/verdict.rs index 6a6b802..3c4c374 100644 --- a/rustables/src/expr/verdict.rs +++ b/rustables/src/expr/verdict.rs @@ -1,8 +1,5 @@ use super::{DeserializationError, Expression, Rule}; -use rustables_sys::{ - self as sys, - libc::{self, c_char}, -}; +use crate::sys::{self, libc::{self, c_char}}; use std::ffi::{CStr, CString}; /// A verdict expression. In the background, this is usually an "Immediate" expression in nftnl diff --git a/rustables/src/expr/wrapper.rs b/rustables/src/expr/wrapper.rs index 5162c21..1bcc520 100644 --- a/rustables/src/expr/wrapper.rs +++ b/rustables/src/expr/wrapper.rs @@ -3,10 +3,8 @@ use std::ffi::CString; use std::fmt::Debug; use std::rc::Rc; -use super::DeserializationError; -use super::Expression; -use crate::Rule; -use rustables_sys as sys; +use super::{DeserializationError, Expression}; +use crate::{sys, Rule}; pub struct ExpressionWrapper { pub(crate) expr: *const sys::nftnl_expr, diff --git a/rustables/src/lib.rs b/rustables/src/lib.rs index d94c753..6eedf9f 100644 --- a/rustables/src/lib.rs +++ b/rustables/src/lib.rs @@ -76,8 +76,8 @@ use thiserror::Error; #[macro_use] extern crate log; -pub use rustables_sys; -use rustables_sys::libc; +pub mod sys; +use sys::libc; use std::{convert::TryFrom, ffi::c_void, ops::Deref}; macro_rules! try_alloc { @@ -118,9 +118,6 @@ pub use rule::{get_rules_cb, list_rules_for_chain}; pub mod set; -#[cfg(test)] -mod tests; - /// The type of the message as it's sent to netfilter. A message consists of an object, such as a /// [`Table`], [`Chain`] or [`Rule`] for example, and a [`MsgType`] to describe what to do with /// that object. If a [`Table`] object is sent with `MsgType::Add` then that table will be added diff --git a/rustables/src/query.rs b/rustables/src/query.rs index 8d2c281..02c4082 100644 --- a/rustables/src/query.rs +++ b/rustables/src/query.rs @@ -1,4 +1,4 @@ -use crate::{nft_nlmsg_maxsize, rustables_sys as sys, ProtoFamily}; +use crate::{nft_nlmsg_maxsize, sys, ProtoFamily}; use sys::libc; /// Returns a buffer containing a netlink message which requests a list of all the netfilter diff --git a/rustables/src/rule.rs b/rustables/src/rule.rs index b315daf..c8cb90d 100644 --- a/rustables/src/rule.rs +++ b/rustables/src/rule.rs @@ -1,6 +1,6 @@ use crate::expr::ExpressionWrapper; use crate::{chain::Chain, expr::Expression, MsgType}; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self, libc}; use std::ffi::{c_void, CStr, CString}; use std::fmt::Debug; use std::os::raw::c_char; diff --git a/rustables/src/set.rs b/rustables/src/set.rs index aef74db..d6b9514 100644 --- a/rustables/src/set.rs +++ b/rustables/src/set.rs @@ -1,5 +1,5 @@ use crate::{table::Table, MsgType, ProtoFamily}; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self, libc}; use std::{ cell::Cell, ffi::{c_void, CStr, CString}, diff --git a/rustables/src/table.rs b/rustables/src/table.rs index 7cc475f..2f21453 100644 --- a/rustables/src/table.rs +++ b/rustables/src/table.rs @@ -1,5 +1,5 @@ use crate::{MsgType, ProtoFamily}; -use rustables_sys::{self as sys, libc}; +use crate::sys::{self, libc}; #[cfg(feature = "query")] use std::convert::TryFrom; use std::{ diff --git a/rustables/src/tests/mod.rs b/rustables/tests/expr.rs index 9a76606..5c27119 100644 --- a/rustables/src/tests/mod.rs +++ b/rustables/tests/expr.rs @@ -1,19 +1,19 @@ -use crate::expr::{ +use rustables::{nft_nlmsg_maxsize, Chain, MsgType, NlMsg, ProtoFamily, Rule, Table}; +use rustables::set::Set; +use rustables::sys::libc::{nlmsghdr, AF_UNIX, NFNETLINK_V0, NFNL_SUBSYS_NFTABLES, NF_DROP}; +use rustables::expr::{ Bitwise, Cmp, CmpOp, Conntrack, Counter, Expression, HeaderField, IcmpCode, Immediate, Log, LogGroup, LogPrefix, Lookup, Meta, Nat, NatType, Payload, Register, Reject, TcpHeaderField, - TransportHeaderField, + TransportHeaderField, Verdict }; -use crate::set::Set; -use crate::{nft_nlmsg_maxsize, Chain, MsgType, NlMsg, ProtoFamily, Rule, Table}; -use rustables_sys::libc::{nlmsghdr, AF_UNIX, NFNETLINK_V0, NFNL_SUBSYS_NFTABLES}; use std::ffi::{c_void, CStr}; use std::mem::size_of; use std::net::Ipv4Addr; use std::rc::Rc; use thiserror::Error; -mod bindings; -use bindings::*; +mod sys; +use sys::*; fn get_subsystem_from_nlmsghdr_type(x: u16) -> u8 { ((x & 0xff00) >> 8) as u8 @@ -445,7 +445,7 @@ fn lookup_expr_is_valid() { ); } -use crate::expr::Masquerade; +use rustables::expr::Masquerade; #[test] fn masquerade_expr_is_valid() { let masquerade = Masquerade; @@ -653,8 +653,6 @@ fn reject_expr_is_valid() { ); } -use crate::expr::Verdict; -use rustables_sys::libc::NF_DROP; #[test] fn verdict_expr_is_valid() { let verdict = Verdict::Drop; diff --git a/rustables/tests_wrapper.h b/rustables/tests_wrapper.h new file mode 100644 index 0000000..8f976e8 --- /dev/null +++ b/rustables/tests_wrapper.h @@ -0,0 +1 @@ +#include "linux/netfilter/nf_tables.h" diff --git a/rustables/wrapper.h b/rustables/wrapper.h index 8f976e8..e6eb221 100644 --- a/rustables/wrapper.h +++ b/rustables/wrapper.h @@ -1 +1,12 @@ -#include "linux/netfilter/nf_tables.h" +#include <libnftnl/batch.h> +#include <libnftnl/chain.h> +#include <libnftnl/common.h> +#include <libnftnl/expr.h> +#include <libnftnl/gen.h> +#include <libnftnl/object.h> +#include <libnftnl/rule.h> +#include <libnftnl/ruleset.h> +#include <libnftnl/set.h> +#include <libnftnl/table.h> +#include <libnftnl/trace.h> +#include <libnftnl/udata.h> |