nfq 0.1.1

Rust library for dealing with NetFilter queue
docs.rs failed to build nfq-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: nfq-0.2.5

nfq - NetFilter queue for Rust

nfq is Rust library for performing userspace handling of packets queued by the kernel packet packet filter chains.

License

In contrast to libnetfilter_queue which is licensed under GPL 2.0, which will require all binaries using that library to be bound by GPL, nfq is dual-licensed under MIT/Apache-2.0. To achieve this, nfq does not use libnetfilter_queue. Instead, nfq communicates using libmnl directly, which is licensed under LGPL.

Example

Here is an example which accepts all packets.

use libc;
use nfq::{Queue, Verdict};

fn main() -> std::io::Result<()> {
   let mut queue = Queue::open()?; 
   queue.bind(libc::AF_INET, 0)?;
   loop {
       let msg = queue.recv()?;
       queue.verdict(msg, Verdict::Accept)?;
   }
   Ok(())
}