This repository has been archived by the owner on Jun 7, 2022. It is now read-only.
Improved error handling for wpa_supplicant interactions #15
Labels
enhancement
New feature or request
Relates to this issue for the
peach-probe
diagnostic tool.Problem
The
peach
device can operate in client or access-point mode (WiFi). Thewpa_supplicant
process is stopped when access-point mode is enabled and thehostapd
process is started (allowing management of theap0
interface which is a virtual interface utilisingwlan0
). Since severalpeach-network
RPCs make use ofwpa_supplicant
, these calls fail when access-point mode is active. Some RPC calls currently panic when client mode is active but there is no active connection.Example behaviour for the
status(iface)
RPC:Access-point mode is active:
RPC Request:
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "status", "params" : {"iface": "wlan0" }, "id":1 }' 127.0.0.1:5110
RPC Response:
{"jsonrpc":"2.0","error":{"code":-32013,"message":"Failed to open control interface for wpasupplicant: No such file or directory (os error 2)"},"id":1}
WPA_CLI output (
sudo wpa_cli -i wlan0 STATUS
):Failed to connect to non-global ctrl_ifname: wlan0 error: No such file or directory
Client mode is active but no credentials have been entered for wireless access-points:
RPC Request:
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "status", "params" : {"iface": "wlan0" }, "id":1 }' 127.0.0.1:5110
RPC Response:
curl: (52) Empty reply from server
Binary stderr:
thread 'http.worker00' panicked at 'None value unwrap for pairwise_cipher in get_status', src/network.rs:442:14
WPA_CLI output (
sudo wpa_cli -i wlan0 STATUS
):Client mode is active but no wireless connection is active:
RPC Request:
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "status", "params" : {"iface": "wlan0" }, "id":1 }' 127.0.0.1:5110
RPC Response:
curl: (52) Empty reply from server
Binary stderr:
thread 'http.worker00' panicked at 'None value unwrap for pairwise_cipher in get_status', src/network.rs:442:14
WPA_CLI output (
sudo wpa_cli -i wlan0 STATUS
):> STATUS wpa_state=DISCONNECTED p2p_device_address=c6:c2:20:c3:3c:60 address=b8:27:eb:9b:5d:5f uuid=a768e933-064d-5417-b613-ca2de4a29095
Client mode is active and connected to an access-point:
RPC Request:
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "status", "params" : {"iface": "wlan0" }, "id":1 }' 127.0.0.1:5110
RPC Response:
{"jsonrpc":"2.0","result":"{\"address\":\"b8:27:eb:9b:5d:5f\",\"bssid\":\"e4:95:6e:40:bd:89\",\"freq\":\"2462\",\"group_cipher\":\"CCMP\",\"id\":\"0\",\"ip_address\":\"192.168.8.193\",\"key_mgmt\":\"WPA2-PSK\",\"mode\":\"station\",\"pairwise_cipher\":\"CCMP\",\"ssid\":\"shadow\",\"wpa_state\":\"COMPLETED\"}","id":1}
WPA_CLI output (
sudo wpa_cli -i wlan0 STATUS
):Solution
The first step is to prevent
peach-network
from panicking. This can be achieved by checking thewpa_state
value returned from the status call and acting accordingly, instead of assuming aCOMPLETED
state and simply iterating through the lines of output to harvest field values (as is currently the case). Once this initial solution has been implemented, it might be worthwhile trying to improve the error message forstatus()
RPC calls made when access-point mode is active.Another potential solution is to add an additional wireless interface to the
peach
device so that a client and access-point can each be run on dedicated devices. This will increase the cost of producing the device but will ultimately simplify the networking and probably make for a more stable system.The text was updated successfully, but these errors were encountered: