daniel-p-carvalho opened a new pull request, #3876: URL: https://github.com/apache/nuttx-apps/pull/3876
## Summary Add the `wifibridge` command and the `netutils/wifibridge` library behind it. They turn a Wi-Fi interface into a SoftAP and bridge it to an Ethernet interface at layer 2, so Ethernet devices (printers, PLCs, PCs) reach the wireless network and the other way round, without routing. The bridge interface carries the IP address and, optionally, a DHCP server. It is the NuttX counterpart of Microchip's Ethernet to Wi-Fi bridge reference design for the EV49N51A, but it is not tied to a board: it works with any Ethernet and Wi-Fi netdev pair that can be bridge ports. ``` wifibridge start [-s <ssid>] [-p <passphrase>] [-c <channel>] [-3] [-a <ipaddr>] [-d] wifibridge stop wifibridge status ``` - `netutils/wifibridge` (`include/netutils/wifibridge.h`): `wifibridge_start()`, `wifibridge_stop()` and `wifibridge_status()`. `start` sets up the SoftAP with `wapi` (WPA2-PSK or WPA3-SAE, CCMP), creates the bridge with the `SIOCBR*` ioctl commands, adds the ports, sets the bridge address and optionally starts the DHCP server. If a step fails, what was done is undone. - `system/wifibridge`: the NSH command, with the defaults taken from Kconfig. - A README for the command. The documentation page is in apache/nuttx (see below). It builds on `CONFIG_NET_BRIDGE` and `brctl` (apache/nuttx#20519, nuttx-apps#3819), and needs a Wi-Fi driver with the master mode and an Ethernet driver that receives foreign MAC addresses (`CONFIG_NET_PROMISCUOUS`). Not in this PR: STA mode (a station cannot be bridged at layer 2), and saving the SSID and the passphrase. ## Impact New, optional (`CONFIG_SYSTEM_WIFIBRIDGE`, `CONFIG_NETUTILS_WIFIBRIDGE`), default `n`. No change to existing code, build or configurations. The default passphrase is documented as something to change before deploying. Companion changes in apache/nuttx, to be opened after this one: the documentation page `Documentation/applications/system/wifibridge`, and a PIC32MZ option for the Ethernet MAC address, since the PIC32MZ-W1 has no factory programmed one. ## Testing Host: Ubuntu Linux, XC32 v6.00 (`xc32-gcc`). Target: EV49N51A (PIC32MZ-W1), with a test configuration based on the board's bridge configuration plus `CONFIG_SYSTEM_WIFIBRIDGE` and `CONFIG_NETUTILS_WIFIBRIDGE_DHCPD` (not part of this PR). The Ethernet port is cabled to the host and a Wi-Fi station of the host joins the SoftAP. - `wifibridge start -d` brings up the SoftAP, `br0` (10.0.0.2) with `eth0` and `wlan0` up, and the DHCP server on `br0`. - The Wi-Fi station gets 10.0.0.100 from the board and pings `br0`, and the Ethernet device (10.0.0.101, in a network namespace so that the traffic has to cross the cable) through the bridge: 5/5 and 4/4, with the TX counters of `eth0` and `wlan0` increasing together. - Five `stop`/`start` cycles (and three more after the last cleanup): the access point stops and starts each time and the heap use stays at 27504 to 27520 bytes. - Error paths: `start` twice returns `EEXIST`, an invalid channel or a short passphrase returns `EINVAL`, `stop` without a bridge returns `ENODEV`. - Custom `-s`, `-p`, `-c` and `-a` values bring up the access point with those parameters. - `sim:nsh` with the options enabled builds without warnings. `checkpatch` passes. Not tested: WPA3 (`-3`), which needs the BA414E engine of the PIC32MZ-W1. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
