mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-30 14:22:37 +01:00
netdev: Move deauthenticate handling out of wiphy.c
This commit is contained in:
parent
48c0a216d7
commit
0fe815f870
31
src/netdev.c
31
src/netdev.c
@ -57,6 +57,7 @@ struct netdev {
|
|||||||
|
|
||||||
netdev_event_func_t event_filter;
|
netdev_event_func_t event_filter;
|
||||||
netdev_connect_cb_t connect_cb;
|
netdev_connect_cb_t connect_cb;
|
||||||
|
netdev_disconnect_cb_t disconnect_cb;
|
||||||
void *user_data;
|
void *user_data;
|
||||||
struct l_genl_msg *associate_msg;
|
struct l_genl_msg *associate_msg;
|
||||||
struct eapol_sm *sm;
|
struct eapol_sm *sm;
|
||||||
@ -313,6 +314,21 @@ static void netdev_deauthenticate_event(struct l_genl_msg *msg,
|
|||||||
l_debug("");
|
l_debug("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void netdev_cmd_deauthenticate_cb(struct l_genl_msg *msg,
|
||||||
|
void *user_data)
|
||||||
|
{
|
||||||
|
struct netdev *netdev = user_data;
|
||||||
|
bool r;
|
||||||
|
|
||||||
|
if (l_genl_msg_get_error(msg) < 0)
|
||||||
|
r = false;
|
||||||
|
else
|
||||||
|
r = true;
|
||||||
|
|
||||||
|
if (netdev->disconnect_cb)
|
||||||
|
netdev->disconnect_cb(netdev, r, netdev->user_data);
|
||||||
|
}
|
||||||
|
|
||||||
static struct l_genl_msg *netdev_build_cmd_deauthenticate(struct netdev *netdev,
|
static struct l_genl_msg *netdev_build_cmd_deauthenticate(struct netdev *netdev,
|
||||||
uint16_t reason_code)
|
uint16_t reason_code)
|
||||||
{
|
{
|
||||||
@ -908,6 +924,21 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
|
|||||||
int netdev_disconnect(struct netdev *netdev,
|
int netdev_disconnect(struct netdev *netdev,
|
||||||
netdev_disconnect_cb_t cb, void *user_data)
|
netdev_disconnect_cb_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
|
struct l_genl_msg *deauthenticate;
|
||||||
|
|
||||||
|
deauthenticate = netdev_build_cmd_deauthenticate(netdev,
|
||||||
|
MPDU_REASON_CODE_DEAUTH_LEAVING);
|
||||||
|
if (!l_genl_family_send(nl80211, deauthenticate,
|
||||||
|
netdev_cmd_deauthenticate_cb, netdev, NULL)) {
|
||||||
|
l_genl_msg_unref(deauthenticate);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
netdev->disconnect_cb = cb;
|
||||||
|
netdev->user_data = user_data;
|
||||||
|
|
||||||
|
eapol_cancel(netdev->index);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
src/wiphy.c
22
src/wiphy.c
@ -41,9 +41,7 @@
|
|||||||
#include "src/dbus.h"
|
#include "src/dbus.h"
|
||||||
#include "src/scan.h"
|
#include "src/scan.h"
|
||||||
#include "src/util.h"
|
#include "src/util.h"
|
||||||
#include "src/eapol.h"
|
|
||||||
#include "src/netdev.h"
|
#include "src/netdev.h"
|
||||||
#include "src/mpdu.h"
|
|
||||||
#include "src/network.h"
|
#include "src/network.h"
|
||||||
#include "src/device.h"
|
#include "src/device.h"
|
||||||
#include "src/wiphy.h"
|
#include "src/wiphy.h"
|
||||||
@ -199,12 +197,13 @@ static struct l_dbus_message *device_scan(struct l_dbus *dbus,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void device_disconnect_cb(struct l_genl_msg *msg, void *user_data)
|
static void device_disconnect_cb(struct netdev *netdev, bool success,
|
||||||
|
void *user_data)
|
||||||
{
|
{
|
||||||
struct device *device = user_data;
|
struct device *device = user_data;
|
||||||
struct l_dbus_message *reply;
|
struct l_dbus_message *reply;
|
||||||
|
|
||||||
if (l_genl_msg_get_error(msg) < 0) {
|
if (!success) {
|
||||||
dbus_pending_reply(&device->disconnect_pending,
|
dbus_pending_reply(&device->disconnect_pending,
|
||||||
dbus_error_failed(device->disconnect_pending));
|
dbus_error_failed(device->disconnect_pending));
|
||||||
return;
|
return;
|
||||||
@ -222,9 +221,6 @@ static struct l_dbus_message *device_disconnect(struct l_dbus *dbus,
|
|||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
struct device *device = user_data;
|
struct device *device = user_data;
|
||||||
struct l_genl_msg *msg;
|
|
||||||
uint16_t reason_code = MPDU_REASON_CODE_DEAUTH_LEAVING;
|
|
||||||
enum security security;
|
|
||||||
|
|
||||||
l_debug("");
|
l_debug("");
|
||||||
|
|
||||||
@ -235,16 +231,8 @@ static struct l_dbus_message *device_disconnect(struct l_dbus *dbus,
|
|||||||
if (!device->connected_bss)
|
if (!device->connected_bss)
|
||||||
return dbus_error_not_connected(message);
|
return dbus_error_not_connected(message);
|
||||||
|
|
||||||
security = network_get_security(device->connected_network);
|
if (netdev_disconnect(device->netdev, device_disconnect_cb, device) < 0)
|
||||||
if (security == SECURITY_PSK || security == SECURITY_8021X)
|
return dbus_error_failed(message);
|
||||||
eapol_cancel(device->index);
|
|
||||||
|
|
||||||
msg = l_genl_msg_new_sized(NL80211_CMD_DEAUTHENTICATE, 512);
|
|
||||||
msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &device->index);
|
|
||||||
msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code);
|
|
||||||
msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN,
|
|
||||||
device->connected_bss->addr);
|
|
||||||
l_genl_family_send(nl80211, msg, device_disconnect_cb, device, NULL);
|
|
||||||
|
|
||||||
device_enter_state(device, DEVICE_STATE_DISCONNECTING);
|
device_enter_state(device, DEVICE_STATE_DISCONNECTING);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user