mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
New AP_Networking_SITL_TUN backend that opens a Linux TAP device and
bridges the lwIP stack to it. Slots into the same "ethernet" position
in PPP_ETHERNET_GATEWAY mode that the ChibiOS backend takes on real
hardware, so a SITL build acting as a PPPGW can be reached by developer
tools on the host (browsers, curl, ...) at the periph's PPP-side IP.
A new Tools/scripts/Networking/sitl_network.sh handles the one-time
host setup: it creates the TAP device under the current user (so the
SITL binary needs no extra privileges), assigns the host's IP, and
installs iptables MASQUERADE + FORWARD rules so the SITL subnet can
reach the wider host network / internet via NAT. The matching `down`
action undoes exactly what `up` put in place, using a small state file
in /tmp to remember the outbound interface and the previous
net.ipv4.ip_forward setting. Tools/scripts/Networking/README.md
documents the usage and customisation knobs.
Tools/scripts/Networking/sitl_network.sh up # create TAP + NAT
sim_vehicle.py -v Plane -f quadplane-PPP
curl http://10.77.193.20/ # PPPGW web UI
Tools/scripts/Networking/sitl_network.sh down
The backend's init falls back to a "PPPGW-only, no host bridge" mode
if the TAP device is not pre-created (TUNSETIFF returns EPERM): it
seeds activeSettings from the user-configured IP params and prints a
one-line warning. That way the same hwdef works in autotest (which
runs without root and without sitl_network.sh) and in developer
sessions (which run it).
Gated by AP_NETWORKING_BACKEND_SITL_TUN (default 0); turned on in a
per-board hwdef when wanted. AP_NETWORKING_NEED_LWIP is widened to
include this backend so the lwIP sources get pulled into the build.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>