mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-21 11:52:34 +01:00
device: Migrate authentication to netdev api
This also moves device_connect_network to device.c where it belongs
This commit is contained in:
parent
51f89e34e9
commit
aedbdd01ae
65
src/device.c
65
src/device.c
@ -27,6 +27,7 @@
|
|||||||
#include <ell/ell.h>
|
#include <ell/ell.h>
|
||||||
|
|
||||||
#include "src/common.h"
|
#include "src/common.h"
|
||||||
|
#include "src/netdev.h"
|
||||||
#include "src/dbus.h"
|
#include "src/dbus.h"
|
||||||
#include "src/network.h"
|
#include "src/network.h"
|
||||||
#include "src/device.h"
|
#include "src/device.h"
|
||||||
@ -136,6 +137,70 @@ void device_disassociated(struct device *device)
|
|||||||
IWD_NETWORK_INTERFACE, "Connected");
|
IWD_NETWORK_INTERFACE, "Connected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void device_connect_cb(struct netdev *netdev, enum netdev_result result,
|
||||||
|
void *user_data)
|
||||||
|
{
|
||||||
|
struct device *device = user_data;
|
||||||
|
|
||||||
|
if (result != NETDEV_RESULT_OK) {
|
||||||
|
if (device->connect_pending)
|
||||||
|
dbus_pending_reply(&device->connect_pending,
|
||||||
|
dbus_error_failed(device->connect_pending));
|
||||||
|
|
||||||
|
device_disassociated(device);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void device_netdev_event(struct netdev *netdev, enum netdev_event event,
|
||||||
|
void *user_data)
|
||||||
|
{
|
||||||
|
switch (event) {
|
||||||
|
case NETDEV_EVENT_AUTHENTICATING:
|
||||||
|
l_debug("Authenticating");
|
||||||
|
break;
|
||||||
|
case NETDEV_EVENT_ASSOCIATING:
|
||||||
|
l_debug("Associating");
|
||||||
|
break;
|
||||||
|
case NETDEV_EVENT_4WAY_HANDSHAKE:
|
||||||
|
l_debug("Handshaking");
|
||||||
|
break;
|
||||||
|
case NETDEV_EVENT_SETTING_KEYS:
|
||||||
|
l_debug("Setting keys");
|
||||||
|
break;
|
||||||
|
case NETDEV_EVENT_LOST_BEACON:
|
||||||
|
l_debug("Beacon lost");
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void device_connect_network(struct device *device, struct network *network,
|
||||||
|
struct scan_bss *bss,
|
||||||
|
struct l_dbus_message *message)
|
||||||
|
{
|
||||||
|
struct l_dbus *dbus = dbus_get_bus();
|
||||||
|
|
||||||
|
device->connect_pending = l_dbus_message_ref(message);
|
||||||
|
|
||||||
|
if (netdev_connect(device->netdev, bss, NULL,
|
||||||
|
device_netdev_event,
|
||||||
|
device_connect_cb, device) < 0) {
|
||||||
|
dbus_pending_reply(&device->connect_pending,
|
||||||
|
dbus_error_failed(device->connect_pending));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
device->connected_bss = bss;
|
||||||
|
device->connected_network = network;
|
||||||
|
|
||||||
|
device_enter_state(device, DEVICE_STATE_CONNECTING);
|
||||||
|
|
||||||
|
l_dbus_property_changed(dbus, device_get_path(device),
|
||||||
|
IWD_DEVICE_INTERFACE, "ConnectedNetwork");
|
||||||
|
l_dbus_property_changed(dbus, network_get_path(network),
|
||||||
|
IWD_NETWORK_INTERFACE, "Connected");
|
||||||
|
}
|
||||||
|
|
||||||
bool device_init(void)
|
bool device_init(void)
|
||||||
{
|
{
|
||||||
device_watches = l_queue_new();
|
device_watches = l_queue_new();
|
||||||
|
52
src/wiphy.c
52
src/wiphy.c
@ -193,19 +193,6 @@ static void device_lost_beacon(struct device *device)
|
|||||||
device_disassociated(device);
|
device_disassociated(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void genl_connect_cb(struct l_genl_msg *msg, void *user_data)
|
|
||||||
{
|
|
||||||
struct device *device = user_data;
|
|
||||||
|
|
||||||
if (l_genl_msg_get_error(msg) < 0) {
|
|
||||||
if (device->connect_pending)
|
|
||||||
dbus_pending_reply(&device->connect_pending,
|
|
||||||
dbus_error_failed(device->connect_pending));
|
|
||||||
|
|
||||||
device_disassociated(device);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ie_rsn_cipher_suite wiphy_select_cipher(struct wiphy *wiphy, uint16_t mask)
|
enum ie_rsn_cipher_suite wiphy_select_cipher(struct wiphy *wiphy, uint16_t mask)
|
||||||
{
|
{
|
||||||
mask &= wiphy->pairwise_ciphers;
|
mask &= wiphy->pairwise_ciphers;
|
||||||
@ -220,45 +207,6 @@ enum ie_rsn_cipher_suite wiphy_select_cipher(struct wiphy *wiphy, uint16_t mask)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mlme_authenticate_cmd(struct network *network, struct scan_bss *bss)
|
|
||||||
{
|
|
||||||
struct device *device = network_get_device(network);
|
|
||||||
const char *ssid = network_get_ssid(network);
|
|
||||||
uint32_t auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
|
|
||||||
struct l_genl_msg *msg;
|
|
||||||
|
|
||||||
msg = l_genl_msg_new_sized(NL80211_CMD_AUTHENTICATE, 512);
|
|
||||||
msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &device->index);
|
|
||||||
msg_append_attr(msg, NL80211_ATTR_WIPHY_FREQ, 4, &bss->frequency);
|
|
||||||
msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, bss->addr);
|
|
||||||
msg_append_attr(msg, NL80211_ATTR_SSID, strlen(ssid), ssid);
|
|
||||||
msg_append_attr(msg, NL80211_ATTR_AUTH_TYPE, 4, &auth_type);
|
|
||||||
l_genl_family_send(nl80211, msg, genl_connect_cb, device, NULL);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void device_connect_network(struct device *device, struct network *network,
|
|
||||||
struct scan_bss *bss,
|
|
||||||
struct l_dbus_message *message)
|
|
||||||
{
|
|
||||||
struct l_dbus *dbus = dbus_get_bus();
|
|
||||||
|
|
||||||
device->connect_pending = l_dbus_message_ref(message);
|
|
||||||
|
|
||||||
device->connected_bss = bss;
|
|
||||||
device->connected_network = network;
|
|
||||||
|
|
||||||
device_enter_state(device, DEVICE_STATE_CONNECTING);
|
|
||||||
|
|
||||||
mlme_authenticate_cmd(network, bss);
|
|
||||||
|
|
||||||
l_dbus_property_changed(dbus, device_get_path(device),
|
|
||||||
IWD_DEVICE_INTERFACE, "ConnectedNetwork");
|
|
||||||
l_dbus_property_changed(dbus, network_get_path(network),
|
|
||||||
IWD_NETWORK_INTERFACE, "Connected");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void bss_free(void *data)
|
static void bss_free(void *data)
|
||||||
{
|
{
|
||||||
struct scan_bss *bss = data;
|
struct scan_bss *bss = data;
|
||||||
|
Loading…
Reference in New Issue
Block a user