|
| 1 | +# Linux wolfIP + wolfSentry Demo |
| 2 | + |
| 3 | +This example runs a single wolfIP instance on a TAP interface and forwards |
| 4 | +wolfIP packet-filter events into wolfSentry via the wolfIP glue layer. The |
| 5 | +installed wolfSentry actions log every inbound Ethernet frame and drop every |
| 6 | +seventh inbound ICMP echo request while logging the drop decision. |
| 7 | + |
| 8 | +## Prerequisites |
| 9 | + |
| 10 | +* Linux host with `/dev/net/tun` access (run the demo with `sudo`). |
| 11 | +* `libpcap` is **not** required. |
| 12 | +* Build `wolfsentry` with wolfIP support enabled so the packet-filter glue is |
| 13 | + present: |
| 14 | + |
| 15 | + ```sh |
| 16 | + cd ../../wolfsentry |
| 17 | + make WOLFIP=1 WOLFIP_CONFIG_DIR=examples/Linux-wolfIP/wolfip |
| 18 | + ``` |
| 19 | + |
| 20 | + The example will then compile its own copy of wolfIP from `$(WOLFIP_PATH)` |
| 21 | + using the local configuration in `wolfip/config.h`, so you do not need to |
| 22 | + build wolfIP separately. Edit that file if you need different Ethernet/TAP |
| 23 | + settings, such as the wolfIP and host IP addresses or the TAP interface name. |
| 24 | + |
| 25 | +## Build the demo |
| 26 | + |
| 27 | +```sh |
| 28 | +cd wolfsentry/examples/Linux-wolfIP |
| 29 | +make # override WOLFIP_PATH=/path/to/wolfip if needed |
| 30 | +``` |
| 31 | + |
| 32 | +The Makefile first builds a local `libwolfip.a` from |
| 33 | +`$(WOLFIP_PATH)/src/wolfip.c`, picking up the Ethernet/TAP configuration in |
| 34 | +`wolfip/config.h`, and then links the demo against that static library plus |
| 35 | +`../../../wolfsentry/libwolfsentry.a`. Override `WOLFIP_PATH` if your source |
| 36 | +tree lives elsewhere. If `libwolfsentry.a` is missing or older than the |
| 37 | +example sources, the Makefile automatically runs |
| 38 | +`make WOLFIP=1 WOLFIP_CONFIG_DIR=examples/Linux-wolfIP/wolfip` inside |
| 39 | +`../../wolfsentry` so the packet-filter glue is rebuilt with the local config. |
| 40 | + |
| 41 | +## Run the demo |
| 42 | + |
| 43 | +```sh |
| 44 | +sudo ./wolfip-wolfsentry-demo |
| 45 | +``` |
| 46 | + |
| 47 | +The program: |
| 48 | + |
| 49 | +1. Initializes wolfSentry, registers two actions (`log-event` and |
| 50 | + `icmp-mod7`), and loads `wolfip-config.json`. |
| 51 | +2. Installs wolfSentry as the wolfIP packet filter for Ethernet, IPv4 and |
| 52 | + ICMP events. |
| 53 | +3. Brings up wolfIP on a TAP interface (default host IP `10.10.10.1`, |
| 54 | + wolfIP address `10.10.10.2`) and enters the polling loop. |
| 55 | + |
| 56 | +While it runs you can exercise it from the host by pinging |
| 57 | +`10.10.10.2`. The demo now starts a background |
| 58 | +`ping -I wolfip0 -c 100 10.10.10.2` process automatically so you immediately |
| 59 | +get traffic; it stops after 100 packets, and you can launch your own ping if |
| 60 | +you prefer. ICMP echo requests are accepted except when the running counter is |
| 61 | +a multiple of 7 – only those discarded packets are logged. |
| 62 | + |
| 63 | +The demo links in wolfIP's POSIX TAP driver (`tap_linux.c`), so the call to |
| 64 | +`tap_init()` inside the sample automatically creates, configures, and brings up |
| 65 | +the TAP interface on the host (default name `wolfip0`). No manual `ip` |
| 66 | +commands are required beyond running the binary with sufficient privileges. |
| 67 | + |
| 68 | +Stop the demo with `Ctrl+C`. |
| 69 | + |
| 70 | +## Cleaning up |
| 71 | + |
| 72 | +```sh |
| 73 | +make clean |
| 74 | +``` |
| 75 | + |
| 76 | +This removes the local binary and object files; it does not touch the |
| 77 | +wolfIP/wolfSentry build outputs. |
0 commit comments