Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
- name: Build linux tests
run: |
mkdir -p build/port
make
make EXTRA_CFLAGS="-DWOLFIP_RAWSOCKETS=1 -DWOLFIP_PACKET_SOCKETS=1"
make EXTRA_CFLAGS="-DWOLFIP_RAWSOCKETS=1 -DWOLFIP_PACKET_SOCKETS=1" build/raw_ping build/packet_ping

- name: Run standalone "event loop" test
timeout-minutes: 5
Expand Down Expand Up @@ -102,6 +103,18 @@ jobs:
set -euo pipefail
timeout --preserve-status 2m sudo LD_PRELOAD=$PWD/libwolfip.so ping -4 -n -c 5 127.0.0.1

- name: Testing raw sockets with raw_ping
timeout-minutes: 2
run: |
set -euo pipefail
timeout --preserve-status 2m sudo ./build/raw_ping 10.10.10.1

- name: Testing packet sockets with packet_ping
timeout-minutes: 2
run: |
set -euo pipefail
timeout --preserve-status 2m sudo ./build/packet_ping wtcp0 10.10.10.1

- name: Install check
run: |
sudo apt-get install -y check
Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CC?=gcc
CFLAGS:=-Wall -Werror -Wextra -I. -D_GNU_SOURCE
CFLAGS+=-g -ggdb -Wdeclaration-after-statement
EXTRA_CFLAGS?=
CFLAGS+=$(EXTRA_CFLAGS)
LDFLAGS+=-pthread
# additional debug flags:
Expand Down Expand Up @@ -158,7 +159,8 @@ endif
EXE=build/tcpecho build/tcp_netcat_poll build/tcp_netcat_select \
build/test-evloop build/test-dns build/test-wolfssl-forwarding \
build/test-ttl-expired build/test-wolfssl build/test-httpd \
build/ipfilter-logger build/test-esp build/esp-server
build/ipfilter-logger \
build/test-esp build/esp-server
ifeq ($(UNAME_S),Linux)
EXE+= build/test-evloop-tun
endif
Expand Down Expand Up @@ -254,6 +256,14 @@ build/tcp_netcat_select: $(OBJ) build/port/posix/bsd_socket.o build/test/tcp_net
@echo "[LD] $@"
@$(CC) $(CFLAGS) -o $@ $(BEGIN_GROUP) $(^) $(LDFLAGS) $(END_GROUP)

build/raw_ping: $(OBJ) build/port/posix/bsd_socket.o build/test/raw_ping.o
@echo "[LD] $@"
@$(CC) $(CFLAGS) -o $@ $(BEGIN_GROUP) $(^) $(LDFLAGS) $(END_GROUP)

build/packet_ping: $(OBJ) build/port/posix/bsd_socket.o build/test/packet_ping.o
@echo "[LD] $@"
@$(CC) $(CFLAGS) -o $@ $(BEGIN_GROUP) $(^) $(LDFLAGS) $(END_GROUP)


build/test-wolfssl:CFLAGS+=-Wno-cpp -DWOLFSSL_DEBUG -DWOLFSSL_WOLFIP
build/test-httpd:CFLAGS+=-Wno-cpp -DWOLFSSL_DEBUG -DWOLFSSL_WOLFIP -Isrc/http
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ configured to forward traffic between multiple network interfaces.
- Multi-interface support
- Optional IPv4-forwarding

## Supported socket types

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

| Domain | Type | Protocol | Notes |
|--------|------|----------|-------|
| `AF_INET` | `SOCK_STREAM` / `IPSTACK_SOCK_STREAM` | TCP | Connection-oriented TCP sockets |
| `AF_INET` | `SOCK_DGRAM` / `IPSTACK_SOCK_DGRAM` | UDP, or `0` | UDP datagram sockets |
| `AF_INET` | `SOCK_DGRAM` / `IPSTACK_SOCK_DGRAM` | ICMP | ICMP datagram sockets, used for ping-style traffic |
| `AF_INET` | `SOCK_RAW` / `IPSTACK_SOCK_RAW` | IP protocol number | IPv4 raw sockets when `WOLFIP_RAWSOCKETS` is enabled |
| `AF_PACKET` | `SOCK_RAW` / `IPSTACK_SOCK_RAW` | Ethernet protocol number | Link-layer packet sockets when `WOLFIP_PACKET_SOCKETS` is enabled |

## Protocols and RFCs

| Layer | Protocol | Features | RFC(s) |
Expand Down
22 changes: 22 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@
#define WOLFIP_MAX_INTERFACES 2
#endif

#ifndef WOLFIP_RAWSOCKETS
#define WOLFIP_RAWSOCKETS 0
#endif

#ifndef WOLFIP_MAX_RAWSOCKETS
#define WOLFIP_MAX_RAWSOCKETS 4
#endif

#ifndef WOLFIP_PACKET_SOCKETS
#define WOLFIP_PACKET_SOCKETS 0
#endif

#if WOLFIP_PACKET_SOCKETS && !defined(ETHERNET)
#undef WOLFIP_PACKET_SOCKETS
#define WOLFIP_PACKET_SOCKETS 0
#error "WOLFIP_PACKET_SOCKETS requires ETHERNET to be defined. Please adjust your configuration."
#endif

#ifndef WOLFIP_MAX_PACKETSOCKETS
#define WOLFIP_MAX_PACKETSOCKETS 2
#endif
Comment thread
danielinux marked this conversation as resolved.

#ifndef WOLFIP_ENABLE_FORWARDING
#define WOLFIP_ENABLE_FORWARDING 0
#endif
Expand Down
Loading
Loading