Skip to main content

Crate netmap_min_sys

Crate netmap_min_sys 

Source
Expand description

Raw FFI bindings and helper shims for the Netmap kernel-bypass networking framework.

The bulk of the API is generated with bindgen from the Netmap C headers (<net/netmap_user.h> and <net/netmap.h>) and re-exported here. On top of the raw bindings this crate also provides:

  • [nm_open] / [nm_close] — the standard Netmap descriptor helpers. These are static functions in the C headers (so no shared/static library exports them); this crate compiles them in via a small C shim.
  • [NETMAP_TXRING] / [NETMAP_RXRING] / [NETMAP_IF] / [NETMAP_BUF] — Rust implementations of the function-like offset macros from netmap_user.h.
  • The Netmap ioctl numbers (NIOCRXSYNC, NIOCTXSYNC, NIOCREGIF, NIOCCTRL) which bindgen cannot evaluate from the _IO/_IOWR macros.

§Build configuration

The netmap headers are discovered through the NETMAP_LOCATION environment variable (defaulting to /usr/local), looking for headers in $NETMAP_LOCATION/include. When Netmap is not needed, enable the disable-netmap-kernel feature (or set DISABLE_NETMAP_KERNEL) to build an empty crate. If the headers cannot be found at all (for example when the crate is built by crates.io or docs.rs, which never have Netmap installed), the build degrades to the same empty state automatically instead of failing.

Constants§

NIOCCTRL
Control-device request header (_IOWR('i', 151, struct nmreq_header)).
NIOCREGIF
Register a Netmap interface with the kernel (_IOWR('i', 146, struct nmreq)).
NIOCRXSYNC
Synchronize the RX rings (_IO('i', 149) on Linux).
NIOCTXSYNC
Synchronize the TX rings (_IO('i', 148) on Linux).