Skip to content

Commit 0879fc2

Browse files
authored
Merge pull request #9 from danielinux/icmp_sockets
Added ICMP sockets, DNS PTR. Refactored posix support
2 parents bc98c9c + e39357b commit 0879fc2

File tree

10 files changed

+2048
-378
lines changed

10 files changed

+2048
-378
lines changed

.github/workflows/linux.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ jobs:
4444
run: |
4545
./build/test-ttl-expired
4646
47+
- name: Testing ICMP socket by stealing system calls in ping
48+
run: |
49+
sudo LD_PRELOAD=$PWD/libwolfip.so ping -c 5 10.10.10.1
50+
4751
- name: Install check
4852
run: |
4953
sudo apt-get install -y check
@@ -55,4 +59,3 @@ jobs:
5559
- name: Run unit tests
5660
run: |
5761
build/test/unit
58-

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,35 @@ A single network interface can be associated with the device.
2727
- Pre-allocated buffers for packet processing in static memory
2828

2929

30+
## Functional tests with `LD_PRELOAD`
31+
32+
The POSIX shim builds `libwolfip.so`, which can be injected in front of
33+
host tools so that calls to `socket(2)` and friends are redirected to the
34+
wolfIP stack and the TAP device (`wtcp0`). After running `make`:
35+
36+
```sh
37+
sudo LD_PRELOAD=$PWD/libwolfip.so nc 10.10.10.2 80
38+
```
39+
40+
The example above mirrors the existing `nc`-driven demos: any TCP sockets
41+
opened by the intercepted process are serviced by wolfIP instead of the host
42+
kernel.
43+
44+
### Ping over the TAP device
45+
46+
ICMP datagram sockets can be validated the same way. With the TAP interface
47+
created automatically by the shim and the host endpoint configured in
48+
`config.h` (`HOST_STACK_IP` defaults to `10.10.10.1`), run:
49+
50+
```sh
51+
sudo LD_PRELOAD=$PWD/libwolfip.so ping -I wtcp0 -c5 10.10.10.1
52+
```
53+
54+
The `-I wtcp0` flag pins the test to the injected interface and `-c5`
55+
generates five echo requests. Successful replies confirm the ICMP
56+
datagram socket support end-to-end through the tap device.
57+
3058
## Copyright and License
3159

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

config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010

1111
#define MAX_TCPSOCKETS 4
1212
#define MAX_UDPSOCKETS 2
13+
#define MAX_ICMPSOCKETS 2
1314
#define RXBUF_SIZE LINK_MTU * 16
1415
#define TXBUF_SIZE LINK_MTU * 16
1516

17+
#ifndef WOLFIP_POSIX_TCPDUMP
18+
#define WOLFIP_POSIX_TCPDUMP 0
19+
#endif
20+
1621
#define MAX_NEIGHBORS 16
1722

1823
#ifndef WOLFIP_MAX_INTERFACES
@@ -34,5 +39,6 @@
3439
/* Linux test configuration */
3540
#define WOLFIP_IP "10.10.10.2"
3641
#define HOST_STACK_IP "10.10.10.1"
42+
#define WOLFIP_STATIC_DNS_IP "9.9.9.9"
3743

3844
#endif

0 commit comments

Comments
 (0)