Skip to main content

Crate ferranet

Crate ferranet 

Source
Expand description

ferranet — a modern, async-first, zero-copy datalink-layer (Layer 2) networking library.

ferranet lets you open a network interface and send/receive raw Ethernet frames with batching and zero-copy receive. It is a spiritual successor to pnet’s datalink module, rebuilt around the lessons its original author shared in a retrospective: first-class async, justified unsafe, an exposed file descriptor, batching, and a “valid until the end of the block” zero-copy receive model.

§Platform support

v0.1 targets Linux behind a RawChannel abstraction boundary (in the sys module), so other platforms (BSD/macOS, Windows) can be added later without changing the public API. The default backend is AF_PACKET/PACKET_MMAP; an AF_XDP backend (XdpSocket) is available behind the xdp feature.

§Permissions

Opening an AF_PACKET socket requires the CAP_NET_RAW capability. For local development you can grant it to a binary with setcap cap_net_raw+ep <binary>, or run inside a network namespace / container with --cap-add=NET_RAW.

Re-exports§

pub use async_channel::AsyncReceiver;
pub use async_channel::AsyncSender;
pub use block::Block;
pub use block::Frame;
pub use block::FrameMeta;
pub use block::Frames;
pub use block::PacketType;
pub use block::VlanTag;
pub use channel::Channel;
pub use channel::ChannelBuilder;
pub use channel::FanoutMode;
pub use channel::Receiver;
pub use channel::RingConfig;
pub use channel::Sender;
pub use error::Error;
pub use error::Result;
pub use interface::IfAddr;
pub use interface::IfIndex;
pub use interface::Interface;
pub use interface::MacAddr;
pub use interface::interfaces;
pub use sys::Stats;

Modules§

async_channel
Tokio-based asynchronous datalink channel (feature tokio).
block
The zero-copy receive surface: Block, Frame, and frame metadata.
channel
The public, synchronous datalink channel: Channel, ChannelBuilder, Sender, and Receiver.
dummy
An in-memory, privilege-free datalink channel for tests.
error
Error and result types for ferranet.
interface
Network interface types and enumeration.
sys
Platform abstraction boundary for raw datalink channels.

Structs§

XdpConfig
Geometry and mode for an XdpSocket.
XdpSocket
An AF_XDP socket: UMEM + fill/completion/rx/tx rings bound to one interface queue.