diff options
author | Daniel Golle <daniel@makrotopia.org> | 2018-11-22 20:53:09 +0100 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2018-12-12 09:37:23 +0100 |
commit | f5753aae233fa64b5d4784ade2cc170f7da539a4 (patch) | |
tree | fe53918ad7ed179876f1e015e655569fdf0b19c1 /package/network/services/hostapd/files/wps-hotplug.sh | |
parent | 5beedcddc3ad2c6f92c24ce2655a84524ca26594 (diff) | |
download | upstream-f5753aae233fa64b5d4784ade2cc170f7da539a4.tar.gz upstream-f5753aae233fa64b5d4784ade2cc170f7da539a4.tar.bz2 upstream-f5753aae233fa64b5d4784ade2cc170f7da539a4.zip |
hostapd: add support for WPS pushbutton station
similar to hostapd, also add a ubus interface for wpa_supplicant
which will allow handling WPS push-button just as it works for hostapd.
In order to have wpa_supplicant running without any network
configuration (so you can use it to retrieve credentials via WPS),
configure wifi-iface in /etc/config/wireless:
config wifi-iface 'default_radio0'
option device 'radio0'
option network 'wwan'
option mode 'sta'
option encryption 'wps'
This section will automatically be edited if credentials have
successfully been acquired via WPS.
Size difference (mips_24kc): roughly +4kb for the 'full' variants of
wpa_supplicant and wpad which do support WPS.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'package/network/services/hostapd/files/wps-hotplug.sh')
-rw-r--r-- | package/network/services/hostapd/files/wps-hotplug.sh | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/package/network/services/hostapd/files/wps-hotplug.sh b/package/network/services/hostapd/files/wps-hotplug.sh index 24af80e55b..ddfd021195 100644 --- a/package/network/services/hostapd/files/wps-hotplug.sh +++ b/package/network/services/hostapd/files/wps-hotplug.sh @@ -1,11 +1,56 @@ #!/bin/sh +wps_catch_credentials() { + local iface ifaces ifc ifname ssid encryption key radio radios + local found=0 + + . /usr/share/libubox/jshn.sh + ubus -S -t 30 listen wps_credentials | while read creds; do + json_init + json_load "$creds" + json_select wps_credentials || continue + json_get_vars ifname ssid key encryption + local ifcname="$ifname" + json_init + json_load "$(ubus -S call network.wireless status)" + json_get_keys radios + for radio in $radios; do + json_select $radio + json_select interfaces + json_get_keys ifaces + for ifc in $ifaces; do + json_select $ifc + json_get_vars ifname + [ "$ifname" = "$ifcname" ] && { + ubus -S call uci set "{\"config\":\"wireless\", \"type\":\"wifi-iface\", \ + \"match\": { \"device\": \"$radio\", \"encryption\": \"wps\" }, \ + \"values\": { \"encryption\": \"$encryption\", \ + \"ssid\": \"$ssid\", \ + \"key\": \"$key\" } }" + ubus -S call uci commit '{"config": "wireless"}' + ubus -S call uci apply + } + json_select .. + done + json_select .. + json_select .. + done + done +} + if [ "$ACTION" = "pressed" -a "$BUTTON" = "wps" ]; then - cd /var/run/hostapd - for socket in *; do - [ -S "$socket" ] || continue - hostapd_cli -i "$socket" wps_pbc + wps_done=0 + ubusobjs="$( ubus -S list hostapd.* )" + for ubusobj in $ubusobjs; do + ubus -S call $ubusobj wps_start && wps_done=1 + done + [ $wps_done = 0 ] || return 0 + wps_done=0 + ubusobjs="$( ubus -S list wpa_supplicant.* )" + for ubusobj in $ubusobjs; do + ubus -S call $ubusobj wps_start && wps_done=1 done + [ $wps_done = 0 ] || wps_catch_credentials & fi return 0 |