mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-10 17:52:36 +01:00
device: Introduce __device_connect_network
The version with '__' prefix is the raw version that returns errnos. The version without '__' prefix deals with D-Bus error conversion.
This commit is contained in:
parent
31081f98e7
commit
a1a6c2d7d6
49
src/device.c
49
src/device.c
@ -1693,34 +1693,27 @@ bool device_set_autoconnect(struct device *device, bool autoconnect)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void device_connect_network(struct device *device, struct network *network,
|
int __device_connect_network(struct device *device, struct network *network,
|
||||||
struct scan_bss *bss,
|
struct scan_bss *bss)
|
||||||
struct l_dbus_message *message)
|
|
||||||
{
|
{
|
||||||
struct l_dbus *dbus = dbus_get_bus();
|
struct l_dbus *dbus = dbus_get_bus();
|
||||||
struct handshake_state *hs;
|
struct handshake_state *hs;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (device_is_busy(device))
|
||||||
|
return -EBUSY;
|
||||||
|
|
||||||
hs = device_handshake_setup(device, network, bss);
|
hs = device_handshake_setup(device, network, bss);
|
||||||
|
if (!hs)
|
||||||
|
return -ENOTSUP;
|
||||||
|
|
||||||
if (!hs) {
|
r = netdev_connect(device->netdev, bss, hs, device_netdev_event,
|
||||||
if (message)
|
device_connect_cb, device);
|
||||||
l_dbus_send(dbus, dbus_error_not_supported(message));
|
if (r < 0) {
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (netdev_connect(device->netdev, bss, hs, device_netdev_event,
|
|
||||||
device_connect_cb, device) < 0) {
|
|
||||||
handshake_state_free(hs);
|
handshake_state_free(hs);
|
||||||
|
return r;
|
||||||
if (message)
|
|
||||||
l_dbus_send(dbus, dbus_error_failed(message));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
device->connect_pending = l_dbus_message_ref(message);
|
|
||||||
|
|
||||||
device->connected_bss = bss;
|
device->connected_bss = bss;
|
||||||
device->connected_network = network;
|
device->connected_network = network;
|
||||||
|
|
||||||
@ -1730,6 +1723,24 @@ void device_connect_network(struct device *device, struct network *network,
|
|||||||
IWD_DEVICE_INTERFACE, "ConnectedNetwork");
|
IWD_DEVICE_INTERFACE, "ConnectedNetwork");
|
||||||
l_dbus_property_changed(dbus, network_get_path(network),
|
l_dbus_property_changed(dbus, network_get_path(network),
|
||||||
IWD_NETWORK_INTERFACE, "Connected");
|
IWD_NETWORK_INTERFACE, "Connected");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void device_connect_network(struct device *device, struct network *network,
|
||||||
|
struct scan_bss *bss,
|
||||||
|
struct l_dbus_message *message)
|
||||||
|
{
|
||||||
|
int err = __device_connect_network(device, network, bss);
|
||||||
|
|
||||||
|
if (err < 0) {
|
||||||
|
struct l_dbus *dbus = dbus_get_bus();
|
||||||
|
|
||||||
|
l_dbus_send(dbus, dbus_error_from_errno(err, message));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
device->connect_pending = l_dbus_message_ref(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void device_scan_triggered(int err, void *user_data)
|
static void device_scan_triggered(int err, void *user_data)
|
||||||
|
@ -79,6 +79,8 @@ struct network *device_network_find(struct device *device, const char *ssid,
|
|||||||
enum security security);
|
enum security security);
|
||||||
|
|
||||||
bool device_set_autoconnect(struct device *device, bool autoconnect);
|
bool device_set_autoconnect(struct device *device, bool autoconnect);
|
||||||
|
int __device_connect_network(struct device *device, struct network *network,
|
||||||
|
struct scan_bss *bss);
|
||||||
void device_connect_network(struct device *device, struct network *network,
|
void device_connect_network(struct device *device, struct network *network,
|
||||||
struct scan_bss *bss,
|
struct scan_bss *bss,
|
||||||
struct l_dbus_message *message);
|
struct l_dbus_message *message);
|
||||||
|
Loading…
Reference in New Issue
Block a user