mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-26 02:19:26 +01:00
device: Rework device_hidden_network_scan_results
Rework the logic slightly to simplify the need for error labels. Also the connect_pending variable might not have been properly reset to NULL in case of error, so make sure we reset it prior to calling into network_connect_new_hidden_network
This commit is contained in:
parent
d8c8ebdf3a
commit
d744915534
34
src/device.c
34
src/device.c
@ -2150,21 +2150,24 @@ static bool device_hidden_network_scan_results(uint32_t wiphy_id,
|
|||||||
struct network *network;
|
struct network *network;
|
||||||
const char *ssid;
|
const char *ssid;
|
||||||
uint8_t ssid_len;
|
uint8_t ssid_len;
|
||||||
struct l_dbus_message *reply;
|
struct l_dbus_message *msg;
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
struct scan_bss *bss;
|
struct scan_bss *bss;
|
||||||
|
|
||||||
l_debug("");
|
l_debug("");
|
||||||
|
|
||||||
|
msg = device->connect_pending;
|
||||||
|
device->connect_pending = NULL;
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
reply = dbus_error_failed(device->connect_pending);
|
dbus_pending_reply(&msg, dbus_error_failed(msg));
|
||||||
goto bss_list_not_owned_error;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!l_dbus_message_get_arguments(device->connect_pending, "s",
|
if (!l_dbus_message_get_arguments(device->connect_pending, "s",
|
||||||
&ssid)) {
|
&ssid)) {
|
||||||
reply = dbus_error_invalid_args(device->connect_pending);
|
dbus_pending_reply(&msg, dbus_error_invalid_args(msg));
|
||||||
goto bss_list_not_owned_error;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &now);
|
clock_gettime(CLOCK_REALTIME, &now);
|
||||||
@ -2191,32 +2194,21 @@ next:
|
|||||||
network_open = device_network_find(device, ssid, SECURITY_NONE);
|
network_open = device_network_find(device, ssid, SECURITY_NONE);
|
||||||
|
|
||||||
if (!network_psk && !network_open) {
|
if (!network_psk && !network_open) {
|
||||||
reply = dbus_error_not_found(device->connect_pending);
|
dbus_pending_reply(&msg, dbus_error_not_found(msg));
|
||||||
|
return true;
|
||||||
goto bss_list_owned_error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (network_psk && network_open) {
|
if (network_psk && network_open) {
|
||||||
reply = dbus_error_service_set_overlap(device->connect_pending);
|
dbus_pending_reply(&msg, dbus_error_service_set_overlap(msg));
|
||||||
|
return true;
|
||||||
goto bss_list_owned_error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
network = network_psk ? : network_open;
|
network = network_psk ? : network_open;
|
||||||
|
|
||||||
network_connect_new_hidden_network(network, device->connect_pending);
|
network_connect_new_hidden_network(network, device->connect_pending);
|
||||||
|
l_dbus_message_unref(msg);
|
||||||
l_dbus_message_unref(device->connect_pending);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bss_list_owned_error:
|
|
||||||
dbus_pending_reply(&device->connect_pending, reply);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
bss_list_not_owned_error:
|
|
||||||
dbus_pending_reply(&device->connect_pending, reply);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct l_dbus_message *device_connect_hidden_network(struct l_dbus *dbus,
|
static struct l_dbus_message *device_connect_hidden_network(struct l_dbus *dbus,
|
||||||
|
Loading…
Reference in New Issue
Block a user