2 releases

Uses old Rust 2015

0.1.1 Oct 16, 2024
0.1.0 Feb 25, 2023

#6 in #updated

Download history 19/week @ 2024-09-23 230/week @ 2024-10-14 8/week @ 2024-10-21 5/week @ 2024-11-04

243 downloads per month
Used in seqknock-nftables

GPL-2.0 license

11KB
113 lines

Source

Stolen with pride from https://github.com/chifflier/libnftables-sys and updated for libnftables1.

libnftables Rust Bindings

License: GPL-2.0 Build Status Crates.io Version

The libnftables-sys crate provides declarations and linkage for the libnftables C library. The libnftables-sys crate provides minimal abstractions over the native libnftables library functions.

Dependencies

In order to use the libnftables-sys crate, you must have the libnftables library installed.

Usage

Add libnftables-sys as a dependency in Cargo.toml:

[dependencies]
libnftables-sys = "0.1"

Import the libnftables_sys crate and use the functions as they're defined in the native libnftables library. You can also use the Nftables struct, a very thin layer on top of the native functions.

extern crate libnftables_sys;
use libnftables_sys::*;

fn main() {
    let mut nft = Nftables::new();

    let cmd = CStr::from_bytes_with_nul(b"list ruleset\0").unwrap();
    let (rc,output,error) = nft.run_cmd(cmd.as_ptr());
}

See the examples directory for complete examples.

License

This crate has the same license as libnftables, which is GPL version 2 only.

No runtime deps

~0–1.9MB
~37K SLoC