netforge 0.1.5

High-performance raw packet I/O engine with AF_XDP, sendmmsg, and pnet backends
Documentation
//! # netforge  -  High-performance raw packet I/O engine
//!
//! High-performance raw packet I/O engine for internet-scale scanning.
//!
//! Provides a unified [`PacketEngine`] trait with three backends, auto-selected
//! by system capability:
//!
//! | Backend | Feature | Mechanism | Requirements |
//! |---------|---------|-----------|--------------|
//! | AF_XDP | `xdp-backend` | Zero-copy userspace ring | Kernel 5.10+, `CAP_BPF`, libbpf |
//! | sendmmsg | `sendmmsg-backend` | Batched `sendmmsg()` syscalls | Linux, `CAP_NET_RAW` |
//! | pnet | `pnet-backend` | Portable single-packet raw sockets | Any platform with `CAP_NET_RAW` |
//!
//! ## Stateless Sequence Encoding
//!
//! The [`seq`] module provides cryptographically-keyed TCP sequence number
//! encoding, allowing fully stateless SYN scanning and banner grabbing.
//! Zero bytes of per-connection state are stored.
//!
//! ## Checksum Computation
//!
//! The [`checksum`] module provides TCP/IP checksum computation for batch
//! packet construction (portable scalar implementation).

#![warn(missing_docs)]
#![warn(clippy::pedantic)]
#![allow(
    clippy::module_name_repetitions,
    clippy::must_use_candidate,
    clippy::missing_errors_doc,
    // doc_markdown fires on protocol-name acronyms (AF_XDP, IP, TCP,
    // UDP, RFC, etc.) that are universally readable without backticks.
    // Backticking them everywhere makes the rendered docs noisy.
    clippy::doc_markdown,
    // Network packet code casts u16/u32 sizes to u8 / usize / i32
    // intentionally  -  the values come from MTU- and ring-bounded
    // counters that cannot exceed the target type's range.
    clippy::cast_possible_truncation,
    clippy::cast_sign_loss,
    clippy::cast_precision_loss,
    clippy::cast_lossless,
    // Hot-loop range iteration is faster than the iterator equivalent
    // in the engine's TX/RX paths and reads more clearly to readers
    // accustomed to C-style packet processing.
    clippy::needless_range_loop,
    clippy::similar_names,
    clippy::too_many_lines,
    // Unsafe blocks in the backends are documented inline and checked
    // by integration tests; the `undocumented_unsafe_blocks` lint
    // double-counts the SAFETY: comments we already have.
    clippy::missing_safety_doc,
    // libc bridging code naturally uses `&mut x as *mut _ as *mut T`
    // to bind into C structs; clippy's preferred `addr_of_mut!` form
    // would require restructuring how mmsghdr is built each call.
    clippy::ptr_as_ptr,
    clippy::borrow_as_ptr,
    clippy::ref_as_ptr,
    clippy::ptr_cast_constness,
)]

pub mod checksum;
pub mod engine;
pub mod packet;
pub mod seq;
pub mod stats_window;

#[cfg(feature = "pnet-backend")]
pub mod backend_pnet;

#[cfg(feature = "sendmmsg-backend")]
pub mod backend_sendmmsg;

#[cfg(feature = "xdp-backend")]
pub mod backend_xdp;

pub use engine::{auto_select, EngineConfig, EngineStats, PacketEngine};
pub use packet::RawPacket;
pub use seq::{SeqEncoder, StatelessCookie};