Skip to content

Repository files navigation

wolfIP

Description and project goals

wolfIP is a TCP/IP stack with no dynamic memory allocations, designed to be used in resource-constrained embedded systems.

wolfIP supports both endpoint-only mode and full multi-interface support with optional IP forwarding. By default, it operates as a network endpoint, but can be configured to forward traffic between multiple network interfaces.

Features supported

  • BSD-like, non blocking socket API, with custom callbacks
  • No dynamic memory allocation
    • Fixed number of concurrent sockets
    • Pre-allocated buffers for packet processing in static memory
  • Multi-interface support
  • Optional IPv4-forwarding
  • Optional IPv4 UDP multicast with IGMPv3 ASM membership reports
  • Reusable allocation-free TFTP module under src/tftp/
  • Optional in-tree Wi-Fi supplicant (src/supplicant/) with WPA2-Personal (PSK 4-way), WPA2-Enterprise (EAP-TLS, optional PEAP/MSCHAPv2), and WPA3-Personal (SAE dragonfly with hunt-and-peck and RFC 9380 Hash-to-Element PWE, groups 19/20/21). See tools/hostapd/README.md for the build matrix and interop test harness.

Supported socket types

wolfIP exposes a BSD-like socket(2) API for IPv4 sockets:

DomainTypeProtocolNotes
AF_INETSOCK_STREAM / IPSTACK_SOCK_STREAMTCPConnection-oriented TCP sockets
AF_INETSOCK_DGRAM / IPSTACK_SOCK_DGRAMUDP, or 0UDP datagram sockets
AF_INETSOCK_DGRAM / IPSTACK_SOCK_DGRAMICMPICMP datagram sockets, used for ping-style traffic
AF_INETSOCK_RAW / IPSTACK_SOCK_RAWIP protocol numberIPv4 raw sockets when WOLFIP_RAWSOCKETS is enabled
AF_PACKETSOCK_RAW / IPSTACK_SOCK_RAWEthernet protocol numberLink-layer packet sockets when WOLFIP_PACKET_SOCKETS is enabled

Protocols and RFCs

LayerProtocolFeaturesRFC(s)
Data LinkEthernet IIFrame encapsulationIEEE 802.3
Data LinkARPAddress resolution, request/replyRFC 826
NetworkIPv4Datagram delivery, TTL handlingRFC 791
NetworkIPv4 ForwardingMulti-interface routing (optional)RFC 1812
NetworkICMPEcho request/reply, TTL exceededRFC 792
NetworkIGMPv3ASM membership reports for IPv4 multicast (optional)RFC 3376
NetworkIPsecESP Transport modeRFC 4303
TransportUDPUnicast datagrams, checksum, optional IPv4 multicastRFC 768
TransportTCPConnection management, reliable deliveryRFC 793, RFC 9293
TransportTCPMaximum Segment Size negotiationRFC 793
TransportTCPTCP Timestamps, RTT measurement, PAWS, Window ScalingRFC 7323
TransportTCPRetransmission timeout (RTO) computationRFC 6298, RFC 5681
TransportTCPTCP SACKRFC 2018, RFC 2883, RFC 6675
TransportTCPCongestion Control: Slow start, congestion avoidanceRFC 5681
TransportTCPFast Retransmit, triple duplicate ACK detectionRFC 5681
ApplicationDHCPClient only (DORA)RFC 2131
ApplicationDNSA and PTR record queries (client)RFC 1035
ApplicationHTTP/HTTPSServer with wolfSSL TLS supportRFC 9110
ApplicationTFTPClient/server octet-mode transfers with callback-driven storage and verificationRFC 1350, RFC 2347, RFC 2348, RFC 2349, RFC 7440
VPNwolfGuardFIPS-compliant WireGuard (P-256, AES-256-GCM, SHA-256)Wolfguard

wolfGuard (FIPS WireGuard)

wolfIP includes a native wolfGuard driver, which is a FIPS-compliant implementation of the WireGuard VPN protocol that operates entirely within the wolfIP stack. wolfGuard uses wolfSSL/wolfCrypt FIPS-certified cryptographic primitives:

WireGuard PrimitivewolfGuard FIPS Replacement
Curve25519ECDH with SECP256R1 (P-256)
ChaCha20-Poly1305AES-256-GCM
BLAKE2sSHA-256
BLAKE2s-HMACHMAC-SHA-256

wolfGuard is NOT interoperable with standard WireGuard peers. It interoperates only with other wolfGuard instances (including the wolfGuard kernel module).

Building with wolfGuard

wolfGuard requires wolfSSL with --enable-wolfguard:

make unit-wolfguard # unit tests
make test-wolfguard-loopback # loopback integration tests
make test-wolfguard-interop # interop test binary (used by the script below)

Interop testing against the kernel wolfGuard module

The interop test validates bidirectional tunnel connectivity between wolfIP and the Linux kernel wolfGuard module. It tests both handshake directions (wolfIP as initiator and as responder) and verifies encrypted data flows end-to-end.

# Requires root, kernel headers, and network access (to clone wolfSSL/wolfGuard)
sudo ./tools/scripts/test-interop-wolfguard.sh

The script builds wolfSSL and the wolfGuard kernel module from source, loads them, generates fresh P-256 keys, and runs a two-phase interop test:

  1. wolfIP initiates — wolfIP creates a handshake, sends a UDP probe through the tunnel, and verifies the echo reply.
  2. Kernel initiates — the kernel creates a fresh handshake to wolfIP, sends data through the tunnel, and wolfIP verifies receipt.

Compile-time configuration

/* config.h */#defineWOLFGUARD 1 /* Enable wolfGuard support */#defineWOLFGUARD_MAX_PEERS 8 /* Max peers per device */#defineWOLFGUARD_MAX_ALLOWED_IPS 32 /* Max allowed-IP entries */#defineWOLFGUARD_STAGED_PACKETS 16 /* Packets queued during handshake */#defineWOLFGUARD_COUNTER_WINDOW 1024 /* Replay window size (bits) */

Functional tests with LD_PRELOAD

The POSIX shim builds libwolfip.so, which can be injected in front of host tools so that calls to socket(2) and friends are redirected to the wolfIP stack and the TAP device (wtcp0). After running make:

sudo LD_PRELOAD=$PWD/libwolfip.so nc 10.10.10.2 80

The example above mirrors the existing nc-driven demos: any TCP sockets opened by the intercepted process are serviced by wolfIP instead of the host kernel.

Ping over the TAP device

ICMP datagram sockets can be validated the same way. With the TAP interface created automatically by the shim and the host endpoint configured in config.h (HOST_STACK_IP defaults to 10.10.10.1), run:

sudo LD_PRELOAD=$PWD/libwolfip.so ping -I wtcp0 -c5 10.10.10.1

The -I wtcp0 flag pins the test to the injected interface and -c5 generates five echo requests. Successful replies confirm the ICMP datagram socket support end-to-end through the tap device.

Optional UDP Multicast

IPv4 UDP multicast is compiled out by default. Define IP_MULTICAST to enable BSD-style multicast socket options and IGMPv3 ASM membership reports:

  • WOLFIP_IP_ADD_MEMBERSHIP
  • WOLFIP_IP_DROP_MEMBERSHIP
  • WOLFIP_IP_MULTICAST_IF
  • WOLFIP_IP_MULTICAST_TTL
  • WOLFIP_IP_MULTICAST_LOOP

The implementation supports any-source multicast joins and leaves. Source filter APIs such as MCAST_JOIN_SOURCE_GROUP are not implemented.

make unit-multicast
./build/test/unit
make build/test-multicast-interop
sudo ./build/test-multicast-interop

The multicast interop test creates a Linux TAP interface (wmcast0) and validates both directions: Linux sending to a wolfIP multicast receiver, and wolfIP sending to a Linux multicast receiver.

FreeRTOS Port

wolfIP now includes a dedicated FreeRTOS wrapper port at:

  • src/port/freeRTOS/bsd_socket.c
  • src/port/freeRTOS/bsd_socket.h

This port follows the same model as the POSIX wrapper:

  • One background task loops on wolfIP_poll()
  • Socket wrappers serialize stack access with a mutex
  • Blocking operations wait on callback-driven wakeups (instead of busy polling)

Documentation

  • API reference: core stack, socket, and protocol-client APIs
  • Porting guide: designing device drivers (with and without DMA) and porting wolfIP to a new operating system

Module how-tos:

  • TLS over wolfIP: running wolfSSL/TLS on wolfIP sockets, the I/O-callback bridge, and non-blocking handshakes

  • HTTP/HTTPS server: the src/http/ server module, handler registration, and enabling HTTPS

  • IPsec ESP: securing traffic with ESP transport mode, SA setup, and Linux ip xfrm interop

  • wolfGuard (FIPS WireGuard): the in-stack WireGuard tunnel, peer/key setup, and kernel interop

  • TFTP: the TFTP client/server module, callback wiring, and the firmware-download pattern

  • DHCP & DNS clients: acquiring a lease, resolving names, and the poll-loop lifecycle

  • Advanced IPv4: multicast/IGMP, IPv4 forwarding, multiple interfaces, and loopback

  • Migrating from lwIP: mapping lwIP concepts and APIs onto wolfIP

Source Layout

  • src/wolfip.c: core TCP/IP stack
  • src/http/: optional HTTP/HTTPS server pieces
  • src/tftp/: reusable TFTP module sources, auto-registered by the top-level Makefile and CMakeLists.txt when present
  • src/port/: platform and OS adaptation layers
  • src/test/: integration and unit tests

Copyright and License

wolfIP is licensed under the GPLv3 license. See the LICENSE file for details. Copyright (c) 2025 wolfSSL Inc.

About

Lightweight TCP/IP stack with no dynamic memory allocations

Topics

Resources

Security policy

Stars

494 stars

Watchers

18 watching

Forks

Releases

Packages

Contributors

Languages