Botón WPS en WRT160nl con OpenWRT

notas extraídas de:

WNDR3700 exploration Page 19 — General Discussion — OpenWrt.

explica como activar el botón WPS con la función WPS

WPS button:

If you have a WPS-enabled network device (like a modern USB dongle) supporting Wi-Fi Protected Setup (WPS), you can negotiate joining the router’s Wifi network without manually entering SSID & passkey. You just initiate “WPS authentication” by pushing the similar WPS button on the device (or launching the process by its driver/control software). After the device has initiated the authentication process, you can accept the transaction by using the WPS button on WNDR3700. The connection should then get negotiated, and in most cases in future your PC should remember the received network settings from then on.

After finding the information and browsing the hostapd package sourcecode, the needed actions for enabling the WPS button are pretty simple:

1) Using WPS authentication requires replacing the default ‘wpad-mini’ package with ‘wpad’ and ‘hostapd-utils’. The reason is that the tool “hostapd_cli” and some needed support functions are not included in ‘wpad-mini’.

WPS authentication itself is launched with a command: hostapd_cli -p /var/run/hostapd-phy0 wps_pbc

It tells the running hostapd daemon to participate in ongoing WPS authentication sequence. It needs to be run separately for each radio (= each existing hostapd process).

2) And it only works if the ‘/etc/config/wireless’ has been modified to include info about WPS authentication being allowed byadding the option ‘wps_pushbutton’ ‘1’ to the wifi-iface section of (each) radio. Additionally, the encryption should be WPA2-PSK (or maybe WPA-PSK is enough, I haven’t tested).
(Looks like the version of hostapd scripts in OpenWrt does not support the full scope of hostapd’s capabilities, so many of the config options documented in hostapd docs are left unused.)

That config file is read when radios are turned on, so after editing the config, restart the radios in WNDR3700.
At this point, you should be able to test it by running it from command line. If the message gets passed to hostapd, you should see there result ‘OK’ there. Otherwise the result is ‘FAIL’.
> root@OpenWrt:~# hostapd_cli -p /var/run/hostapd-phy0 wps_pbc
> Selected interface ‘wlan0’
> OK
> root@OpenWrt:~#

3) Add a hotplug button event script to launch the process.

I modified directly the hostapd package source ( /package/hostapd/files/wps-hotplug.sh ), as the hotplug script gets automatically installed to ‘/etc/hotplug.d/button/50-wps’ with the package.  See below.

The script launches hostapd_cli for each radio and lights the WPS led for 10 seconds. There is no monitoring of the result, or anything like that. It is just a dumb script using the hostapd_cli command to pass the message to the hostapd daemon.
Remember to check the button name: Backfire:  wps=”BTN_1″,  trunk:  wps=”wps”

root@OpenWrt:/# cat /etc/hotplug.d/button/50-wps

if [ "$ACTION" = "pressed" -a "$BUTTON" = "BTN_1" ]; then
        echo "255" > /sys/devices/platform/leds-gpio/leds/wndr3700:green:wps/brightness
        for dir in /var/run/hostapd-*; do
                [ -d "$dir" ] || continue
                logger "WPS button active: $dir"
                hostapd_cli -p "$dir" wps_pbc
        done
        sleep 10
        echo "0" > /sys/devices/platform/leds-gpio/leds/wndr3700:green:wps/brightness


root@OpenWrt:/# cat /etc/config/wireless
...
config 'wifi-iface'
        option 'device' 'radio0'
        option 'network' 'lan'
        option 'mode' 'ap'
        option 'ssid' 'public'
        option 'encryption' 'psk2'
        option 'key' 'SecretKey'
        option 'wps_pushbutton' '1'
...


 fi

If everything goes ok, you should see in Syslog not only the button events, but also succesful WPS authentication:


Jan 31 21:11:09 OpenWrt user.notice root: WiFi button used: WiFi up
Jan 31 21:11:09 OpenWrt user.info kernel: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Jan 31 21:11:09 OpenWrt user.info kernel: device wlan0 entered promiscuous mode
Jan 31 21:11:09 OpenWrt user.info kernel: br-lan: port 2(wlan0) entering forwarding state
...
Jan 31 21:12:00 OpenWrt user.notice root: WPS button active: /var/run/hostapd-phy0
Jan 31 21:12:00 OpenWrt user.notice root: WPS button active: /var/run/hostapd-phy1
Jan 31 21:12:03 OpenWrt daemon.info hostapd: wlan0: STA 1c:af:f7:f6:11:dc IEEE 802.11: authenticated
Jan 31 21:12:03 OpenWrt daemon.info hostapd: wlan0: STA 1c:af:f7:f6:11:dc IEEE 802.11: associated (aid 1)
Jan 31 21:12:04 OpenWrt daemon.warn hostapd: wlan0: STA 1c:af:f7:f6:11:dc IEEE 802.1X: authentication failed - EAP type: 0 ((null))
Jan 31 21:12:04 OpenWrt daemon.info hostapd: wlan0: STA 1c:af:f7:f6:11:dc IEEE 802.1X: Supplicant used different EAP type: 254 ((null))
Jan 31 21:12:04 OpenWrt daemon.info hostapd: wlan0: STA 1c:af:f7:f6:11:dc IEEE 802.11: disassociated
Jan 31 21:12:05 OpenWrt daemon.info hostapd: wlan0: STA 1c:af:f7:f6:11:dc IEEE 802.11: deauthenticated due to inactivity
Jan 31 21:12:17 OpenWrt daemon.info hostapd: wlan0: STA 1c:af:f7:f6:11:dc IEEE 802.11: authenticated
Jan 31 21:12:17 OpenWrt daemon.info hostapd: wlan0: STA 1c:af:f7:f6:11:dc IEEE 802.11: associated (aid 1)
Jan 31 21:12:17 OpenWrt daemon.info hostapd: wlan0: STA 1c:af:f7:f6:11:dc RADIUS: starting accounting session 4D47094D-00000000
Jan 31 21:12:17 OpenWrt daemon.info hostapd: wlan0: STA 1c:af:f7:f6:11:dc WPA: pairwise key handshake completed (RSN)
Jan 31 21:12:29 OpenWrt daemon.info dnsmasq-dhcp[1855]: DHCPREQUEST(br-lan) 192.168.1.190 1c:af:f7:f6:11:dc 
Jan 31 21:12:29 OpenWrt daemon.info dnsmasq-dhcp[1855]: DHCPACK(br-lan) 192.168.1.190 1c:af:f7:f6:11:dc HNH57JG

EDIT: added a note about the correct button names in Backfire and trunk.
If you want to check the button names on your system, you can use the following hotplug script that just logs the button 'pressed' actions into system log:


root@OpenWrt:/etc/config# cat /etc/hotplug.d/button/02-log
#!/bin/sh
if [ "$ACTION" = "pressed" ]; then
        logger "button: "$BUTTON
El problema es que no se porqué, la opción wps_pbc no está implementada todavía en el modulo hostapd_cli.

Etiquetas: ,

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

Albert Vaca's blog

About KDE and KDE Connect

The WordPress.com Blog

The latest news on WordPress.com and the WordPress community.

A %d blogueros les gusta esto: