Files
OpenUniFi/README.md
T
2026-07-10 15:44:09 +02:00

93 lines
2.9 KiB
Markdown

# openUF — C
Daemon that makes an OpenWrt router appear as a **UniFi U6 InWall** to the UniFi Network controller.
## Implemented Features
| Feature | Description | Implementation |
| --- | --- | --- |
| **L2 Discovery** | UDP broadcast + multicast every 10s | `announce.c` → port 10001 |
| **Adoption** | AES-128-CBC handshake with the controller | `inform.c``handle_response()` |
| **WiFi Config** | Creates WiFi networks from the controller via UCI | `wlan.c``wlan_apply_config()` |
| **Band Steering** | 802.11k/v Neighbor Reports + BSS Transition | `wlan.c``apply_vap()` |
| **Fast Roaming** | 802.11r FT with mobility_domain derived from MAC | `wlan.c``apply_vap()` |
| **WPA3 / PMF** | SAE, SAE-mixed, 802.11w 0/1/2 | `wlan.c``sec_to_uci()` |
| **WiFi Clients** | MAC, signal, bitrate, bytes per VAP | `clients.c``iw station dump` |
| **Wired Clients** | MACs from bridge FDB | `clients.c``bridge fdb` |
| **CPU / RAM** | Real-time usage | `sysinfo.c``/proc/stat` + `/proc/meminfo` |
| **Interfaces** | Speed, duplex, rx/tx counters | `sysinfo.c``/proc/net/dev` |
| **Channel / RF** | Channel utilization, noise, tx_power | `sysinfo.c``iw survey dump` |
| **LLDP Send** | Custom frames via AF_PACKET raw socket | `lldp.c``lldp_send_frame()` |
| **LLDP Read** | Neighbors for UniFi topology | `lldp.c``lldpctl -f json` |
## Quick Installation
```sh
# On the OpenWrt device:
opkg update
opkg install gcc make libmbedtls-dev libuci-dev libjson-c-dev
# Compile and install
make -f Makefile.standalone install
# Configure
vi /etc/openuf/openuf.conf # adjust controller_ip and lan_if
# Start
/etc/init.d/openuf start
/etc/init.d/openuf enable # start on boot
```
## Configuration
```ini
controller_ip = 192.168.1.1 # UniFi controller IP
lan_if = br-lan # LAN interface (for MAC and IP)
ufmodel = u6-inwall # emulated model
inform_interval = 10 # seconds between informs
enable_announce = 1
enable_inform = 1
```
## U6 InWall Model
A **U6 IW** is emulated because it has 5 GbE ports, which covers most OpenWrt routers. The model reports:
* 5 ethernet ports (eth0-eth4)
* 2.4 GHz WiFi 6 Radio (HE/802.11ax)
* 5 GHz WiFi 6 Radio (HE/802.11ax)
## LLDP
For visual topology in UniFi:
```sh
opkg install lldpd
/etc/init.d/lldpd start
/etc/init.d/lldpd enable
```
openuf sends its own LLDP frames even without lldpd (raw socket).
With lldpd installed, it also reports upstream neighbors (switches).
## Adoption
The process is automatic:
1. The AP appears as "Pending" in UniFi.
2. Click on "Adopt" → the controller sends a new key.
3. The AP applies the key and becomes "Connected".
4. The controller pushes the WiFi configuration (SSIDs, channels, etc.).
To reset: `rm /etc/openuf/state.json && reboot`
## Dependencies
```sh
opkg install libmbedtls libuci libjson-c
opkg install lldpd # optional, for topology
```