openwrt / luci

LuCI - OpenWrt Configuration Interface
Apache License 2.0
6.43k stars 2.54k forks source link

Question regarding use of 'luci.sys.wifi.getiwinfo' #3192

Closed dibdot closed 5 years ago

dibdot commented 5 years ago

Hi Jo,

currently I would like to add WPA3 support to luci-app-travelmate. In the past I've used 'luci.sys.wifi.getiwinfo' to gather all relevant information on my wifi scan result page, e.g.:

    local iw    = luci.sys.wifi.getiwinfo(dev)
    luci.util.dumptable(iw.scanlist)

If I check the debug output, the encryption description is usually OK, even for the new WPA3 modes ... only the WPA2/WPA3 mixed mode seems to be broken, e.g.:

Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]: 2 table: 0x55dfcad0
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:   encryption  table: 0x55dfcb30
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:       enabled true
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:       auth_algs   table: 0x55dfda80
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:       description WPA2 PSK (CCMP)
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:       wep false
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:       auth_suites table: 0x55dfda20
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:           1   PSK
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:       wpa 6
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:       pair_ciphers    table: 0x55dfcb80
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:           1   CCMP
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:       group_ciphers   table: 0x55dfd9f0
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:   quality_max 70
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:   ssid    WPA3
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:   channel 1
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:   signal  -34
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:   bssid   06:F0:21:18:25:F9
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:   mode    Master
Wed Oct 16 15:35:48 2019 daemon.err uhttpd[2813]:   quality 70

In comparison the (correct) output of 'iwinfo radio1 scan' on the same device/configuration, e.g.:

Cell 02 - Address: 06:F0:21:18:25:F9
          ESSID: "WPA3"
          Mode: Master  Channel: 1
          Signal: -32 dBm  Quality: 70/70
          Encryption: mixed WPA2/WPA3 PSK/SAE (CCMP)

Is it still "allowed" to use the getiwinfo function or should I use another approach to get these kind of information?

BTW: Currently 'iwinfo scan' didn't list "hidden" APs, seems to be a regression IMHO.

Thanks for your support!

jow- commented 5 years ago

Hi,

I'll fix the mixed WPA3 reporting. About hidden scan results; what do you expect to receive? An entry with the SSID set to an empty string like iw does it?

Cheers, Jo

dibdot commented 5 years ago

Hi,

thanks for the fast response. If I remember correctly, iwinfo has reported "unknown" as ssid for hidden networks in the past.

jow- commented 5 years ago

Okay, I checked how iw reacts to hidden SSIDs and simply reports SSID: (empty string). I'll do the same for iwinfo. Returning unknown in the Lua table is not ideal as there might be a visible network called unknown.

dibdot commented 5 years ago

OK, I'll change that in travelmate then. In the past the hidden unknown ssid was delivered without double quotes, while all real ssid are protected by double quotes.

jow- commented 5 years ago

This is right for the iwinfo ... scan cli output, but the Lua table data does not quote the SSIDs.

dibdot commented 5 years ago

Yep, you're right. Travelmate backend uses iwinfo scan cli, while the luci frontend will use the lua table data ... maybe not the best approach. ;-)

jow- commented 5 years ago

Okay, I'm going to push my fixes now. For hidden networks, the .ssid field in the Lua tables will be unset / not existing, so you can use something like local ssid = entry.ssid or "unknown"

dibdot commented 5 years ago

That's cool - many thanks! Does it fix the iwinfo scan cli, too? Because currently these hidden stations won't be listed at all.

jow- commented 5 years ago

Yes, it will fix both places. The error actually happens when scanning is performed through wpa_supplicant instead of nl80211, in this case entries without SSID were incorrectly skipped.

dibdot commented 5 years ago

Perfect, thanks again!

jow- commented 5 years ago

Updates pushed to master and 19.07