pktkit 0.1.3

Zero-copy L2/L3 packet handling toolkit. Frames, packets, hubs, adapters, NAT, virtual TCP/IP, WireGuard, OpenVPN, QEMU networking, TUN/TAP, AF_XDP — all gated behind opt-in cargo features.
Documentation
[package]
name = "pktkit"
version = "0.1.3"
edition = "2024"
rust-version = "1.88"
authors = ["Karpeles Lab Inc."]
license = "MIT"
description = "Zero-copy L2/L3 packet handling toolkit. Frames, packets, hubs, adapters, NAT, virtual TCP/IP, WireGuard, OpenVPN, QEMU networking, TUN/TAP, AF_XDP — all gated behind opt-in cargo features."
repository = "https://github.com/KarpelesLab/pktkit-rs"
homepage = "https://github.com/KarpelesLab/pktkit-rs"
documentation = "https://docs.rs/pktkit"
readme = "README.md"
keywords = ["networking", "packet", "tcp", "wireguard", "tun"]
categories = ["network-programming", "virtualization"]
# The fuzzing harness is a separate crate that depends on this one; it has no
# business in the published package.
exclude = ["fuzz", ".github"]

[features]
# By default we ship only the core: Frame, Packet, hubs, pipes, traits.
# Every other capability is opt-in so users only pull the dependencies they need.
default = []

# Bridging an L3 device onto an L2 network (ARP, NDP, gateway routing).
l2adapter = []

# DHCP client codec + DHCPServer. The client is also used by l2adapter
# when StartDHCP() is called.
dhcp = []

# Link impairment: delay, jitter, loss, duplication, corruption, rate limits.
# Pure std -- no dependencies.
impair = []

# Write traffic crossing a device to a .pcap file for Wireshark / tcpdump.
# Pure std -- no dependencies.
pcap = []

# QEMU userspace network socket protocol (client + listener).
qemu = []

# Linux/macOS TUN/TAP device support.
tuntap = ["dep:libc"]

# Bind an L2 device to an existing interface with an AF_PACKET socket (Linux).
afpacket = ["dep:libc"]

# Linux XDP: load/attach eBPF programs on a device's receive path, with an
# IP-prefix capture program and the maps that drive it.
xdp = ["dep:libc"]

# Linux AF_XDP zero-copy sockets. Layers a userspace datapath on `xdp`.
afxdp = ["xdp"]

# Pure-Rust virtual TCP engine.
vtcp = []

# Userspace NAT stack (L3Device) routing to real OS sockets.
slirp = ["vtcp"]

# High-level virtual client (Dial / Listen / DNS / minimal HTTP).
vclient = ["vtcp"]

# Packet-level IPv4 NAT, NAT64, ALGs, defrag, UPnP.
# UPnP terminates its SOAP control port with the virtual TCP engine (vtcp).
nat = ["vtcp"]

# WireGuard tunnel (Noise IK handshake + transport).
wg = [
    "dep:purecrypto",
    "purecrypto/hash",
    "purecrypto/cipher",
    "purecrypto/ec",
    "purecrypto/rng",
]

# OpenVPN server (TLS control channel + AES-CBC/GCM data channel).
ovpn = [
    "dep:purecrypto",
    "purecrypto/hash",
    "purecrypto/cipher",
    "purecrypto/kdf",
    "purecrypto/rng",
    # The control channel is TLS 1.2 run inside OpenVPN's own reliable
    # transport, so it needs the sans-I/O TLS core plus X.509.
    "purecrypto/tls",
    "purecrypto/x509",
]

# Exposes crate-internal parser entry points to the fuzz targets and the
# randomized robustness test. Not part of `full`; never enable it as a
# dependent -- it is not covered by semver.
fuzzing = []

# Convenience: enable everything (matches the Go upstream featureset).
full = [
    "l2adapter",
    "dhcp",
    "impair",
    "pcap",
    "qemu",
    "tuntap",
    "afpacket",
    "xdp",
    "afxdp",
    "vtcp",
    "slirp",
    "vclient",
    "nat",
    "wg",
    "ovpn",
]

[dependencies]
# libc is the only OS-FFI shim we use, gated behind features that need it.
libc = { version = "0.2", optional = true }

# All cryptography comes from purecrypto: primitives, X.509 and TLS in one
# pure-Rust tree with no foreign code and no build script. `default-features`
# is off so a build pulls only the modules the enabled pktkit features name --
# `wg` does not compile the TLS stack, and `ovpn` does not compile ML-DSA.
purecrypto = { version = "0.7", optional = true, default-features = false, features = ["std", "linux-getrandom"] }

[dev-dependencies]
# Tests may exercise OS sockets; nothing extra needed beyond std.

[lib]
name = "pktkit"
path = "src/lib.rs"

# Hot-path microbenchmarks. No benchmark framework: the harness is a warmup and
# a timed loop, which keeps the dev-dependency list empty.
[[bench]]
name = "hot_path"
harness = false

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]