3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 18:59:22 +01:00

ap: Switch to new frame watch API

This commit is contained in:
Andrew Zaborowski 2020-01-06 13:39:39 +01:00 committed by Denis Kenzior
parent 6484b7dbb6
commit 4a61620a9b

View File

@ -44,6 +44,7 @@
#include "src/handshake.h" #include "src/handshake.h"
#include "src/dbus.h" #include "src/dbus.h"
#include "src/nl80211util.h" #include "src/nl80211util.h"
#include "src/frame-xchg.h"
struct ap_state { struct ap_state {
struct netdev *netdev; struct netdev *netdev;
@ -55,7 +56,6 @@ struct ap_state {
uint32_t beacon_interval; uint32_t beacon_interval;
struct l_uintset *rates; struct l_uintset *rates;
uint8_t pmk[32]; uint8_t pmk[32];
struct l_queue *frame_watch_ids;
uint32_t start_stop_cmd_id; uint32_t start_stop_cmd_id;
uint8_t gtk[CRYPTO_MAX_GTK_LEN]; uint8_t gtk[CRYPTO_MAX_GTK_LEN];
uint8_t gtk_index; uint8_t gtk_index;
@ -109,14 +109,6 @@ static void ap_sta_free(void *data)
l_free(sta); l_free(sta);
} }
static void ap_frame_watch_remove(void *data, void *user_data)
{
struct netdev *netdev = user_data;
if (L_PTR_TO_UINT(data))
netdev_frame_watch_remove(netdev, L_PTR_TO_UINT(data));
}
static void ap_reset(struct ap_state *ap) static void ap_reset(struct ap_state *ap)
{ {
struct netdev *netdev = ap->netdev; struct netdev *netdev = ap->netdev;
@ -132,8 +124,7 @@ static void ap_reset(struct ap_state *ap)
memset(ap->pmk, 0, sizeof(ap->pmk)); memset(ap->pmk, 0, sizeof(ap->pmk));
l_queue_foreach(ap->frame_watch_ids, ap_frame_watch_remove, netdev); frame_watch_wdev_remove(netdev_get_wdev_id(netdev));
l_queue_destroy(ap->frame_watch_ids, NULL);
if (ap->start_stop_cmd_id) if (ap->start_stop_cmd_id)
l_genl_family_cancel(ap->nl80211, ap->start_stop_cmd_id); l_genl_family_cancel(ap->nl80211, ap->start_stop_cmd_id);
@ -968,10 +959,8 @@ bad_frame:
} }
/* 802.11-2016 9.3.3.6 */ /* 802.11-2016 9.3.3.6 */
static void ap_assoc_req_cb(struct netdev *netdev, static void ap_assoc_req_cb(const struct mmpdu_header *hdr, const void *body,
const struct mmpdu_header *hdr, size_t body_len, int rssi, void *user_data)
const void *body, size_t body_len,
void *user_data)
{ {
struct ap_state *ap = user_data; struct ap_state *ap = user_data;
struct sta_state *sta; struct sta_state *sta;
@ -1002,10 +991,8 @@ static void ap_assoc_req_cb(struct netdev *netdev,
} }
/* 802.11-2016 9.3.3.8 */ /* 802.11-2016 9.3.3.8 */
static void ap_reassoc_req_cb(struct netdev *netdev, static void ap_reassoc_req_cb(const struct mmpdu_header *hdr, const void *body,
const struct mmpdu_header *hdr, size_t body_len, int rssi, void *user_data)
const void *body, size_t body_len,
void *user_data)
{ {
struct ap_state *ap = user_data; struct ap_state *ap = user_data;
struct sta_state *sta; struct sta_state *sta;
@ -1056,10 +1043,8 @@ static void ap_probe_resp_cb(struct l_genl_msg *msg, void *user_data)
* Parse Probe Request according to 802.11-2016 9.3.3.10 and act according * Parse Probe Request according to 802.11-2016 9.3.3.10 and act according
* to 802.11-2016 11.1.4.3 * to 802.11-2016 11.1.4.3
*/ */
static void ap_probe_req_cb(struct netdev *netdev, static void ap_probe_req_cb(const struct mmpdu_header *hdr, const void *body,
const struct mmpdu_header *hdr, size_t body_len, int rssi, void *user_data)
const void *body, size_t body_len,
void *user_data)
{ {
struct ap_state *ap = user_data; struct ap_state *ap = user_data;
const struct mmpdu_probe_request *req = body; const struct mmpdu_probe_request *req = body;
@ -1149,10 +1134,8 @@ static void ap_probe_req_cb(struct netdev *netdev,
} }
/* 802.11-2016 9.3.3.5 (frame format), 802.11-2016 11.3.5.9 (MLME/SME) */ /* 802.11-2016 9.3.3.5 (frame format), 802.11-2016 11.3.5.9 (MLME/SME) */
static void ap_disassoc_cb(struct netdev *netdev, static void ap_disassoc_cb(const struct mmpdu_header *hdr, const void *body,
const struct mmpdu_header *hdr, size_t body_len, int rssi, void *user_data)
const void *body, size_t body_len,
void *user_data)
{ {
struct ap_state *ap = user_data; struct ap_state *ap = user_data;
struct sta_state *sta; struct sta_state *sta;
@ -1221,8 +1204,8 @@ static void ap_auth_reply(struct ap_state *ap, const uint8_t *dest,
* 802.11-2016 9.3.3.12 (frame format), 802.11-2016 11.3.4.3 and * 802.11-2016 9.3.3.12 (frame format), 802.11-2016 11.3.4.3 and
* 802.11-2016 12.3.3.2 (MLME/SME) * 802.11-2016 12.3.3.2 (MLME/SME)
*/ */
static void ap_auth_cb(struct netdev *netdev, const struct mmpdu_header *hdr, static void ap_auth_cb(const struct mmpdu_header *hdr, const void *body,
const void *body, size_t body_len, void *user_data) size_t body_len, int rssi, void *user_data)
{ {
struct ap_state *ap = user_data; struct ap_state *ap = user_data;
const struct mmpdu_authentication *auth = body; const struct mmpdu_authentication *auth = body;
@ -1289,9 +1272,8 @@ done:
} }
/* 802.11-2016 9.3.3.13 (frame format), 802.11-2016 11.3.4.5 (MLME/SME) */ /* 802.11-2016 9.3.3.13 (frame format), 802.11-2016 11.3.4.5 (MLME/SME) */
static void ap_deauth_cb(struct netdev *netdev, const struct mmpdu_header *hdr, static void ap_deauth_cb(const struct mmpdu_header *hdr, const void *body,
const void *body, size_t body_len, size_t body_len, int rssi, void *user_data)
void *user_data)
{ {
struct ap_state *ap = user_data; struct ap_state *ap = user_data;
struct sta_state *sta; struct sta_state *sta;
@ -1417,8 +1399,7 @@ static int ap_start(struct ap_state *ap, const char *ssid, const char *psk,
struct netdev *netdev = ap->netdev; struct netdev *netdev = ap->netdev;
struct wiphy *wiphy = netdev_get_wiphy(netdev); struct wiphy *wiphy = netdev_get_wiphy(netdev);
struct l_genl_msg *cmd; struct l_genl_msg *cmd;
const struct l_queue_entry *entry; uint64_t wdev_id = netdev_get_wdev_id(netdev);
uint32_t id;
ap->ssid = l_strdup(ssid); ap->ssid = l_strdup(ssid);
/* TODO: Start a Get Survey to decide the channel */ /* TODO: Start a Get Survey to decide the channel */
@ -1437,41 +1418,34 @@ static int ap_start(struct ap_state *ap, const char *ssid, const char *psk,
ap->pmk) < 0) ap->pmk) < 0)
goto error; goto error;
ap->frame_watch_ids = l_queue_new(); if (!frame_watch_add(wdev_id, 0, 0x0000 |
id = netdev_frame_watch_add(netdev, 0x0000 |
(MPDU_MANAGEMENT_SUBTYPE_ASSOCIATION_REQUEST << 4), (MPDU_MANAGEMENT_SUBTYPE_ASSOCIATION_REQUEST << 4),
NULL, 0, ap_assoc_req_cb, ap); NULL, 0, ap_assoc_req_cb, ap, NULL))
l_queue_push_tail(ap->frame_watch_ids, L_UINT_TO_PTR(id)); goto error;
id = netdev_frame_watch_add(netdev, 0x0000 | if (!frame_watch_add(wdev_id, 0, 0x0000 |
(MPDU_MANAGEMENT_SUBTYPE_REASSOCIATION_REQUEST << 4), (MPDU_MANAGEMENT_SUBTYPE_REASSOCIATION_REQUEST << 4),
NULL, 0, ap_reassoc_req_cb, ap); NULL, 0, ap_reassoc_req_cb, ap, NULL))
l_queue_push_tail(ap->frame_watch_ids, L_UINT_TO_PTR(id)); goto error;
id = netdev_frame_watch_add(netdev, 0x0000 | if (!frame_watch_add(wdev_id, 0, 0x0000 |
(MPDU_MANAGEMENT_SUBTYPE_PROBE_REQUEST << 4), (MPDU_MANAGEMENT_SUBTYPE_PROBE_REQUEST << 4),
NULL, 0, ap_probe_req_cb, ap); NULL, 0, ap_probe_req_cb, ap, NULL))
l_queue_push_tail(ap->frame_watch_ids, L_UINT_TO_PTR(id)); goto error;
id = netdev_frame_watch_add(netdev, 0x0000 | if (!frame_watch_add(wdev_id, 0, 0x0000 |
(MPDU_MANAGEMENT_SUBTYPE_DISASSOCIATION << 4), (MPDU_MANAGEMENT_SUBTYPE_DISASSOCIATION << 4),
NULL, 0, ap_disassoc_cb, ap); NULL, 0, ap_disassoc_cb, ap, NULL))
l_queue_push_tail(ap->frame_watch_ids, L_UINT_TO_PTR(id)); goto error;
id = netdev_frame_watch_add(netdev, 0x0000 | if (!frame_watch_add(wdev_id, 0, 0x0000 |
(MPDU_MANAGEMENT_SUBTYPE_AUTHENTICATION << 4), (MPDU_MANAGEMENT_SUBTYPE_AUTHENTICATION << 4),
NULL, 0, ap_auth_cb, ap); NULL, 0, ap_auth_cb, ap, NULL))
l_queue_push_tail(ap->frame_watch_ids, L_UINT_TO_PTR(id)); goto error;
id = netdev_frame_watch_add(netdev, 0x0000 | if (!frame_watch_add(wdev_id, 0, 0x0000 |
(MPDU_MANAGEMENT_SUBTYPE_DEAUTHENTICATION << 4), (MPDU_MANAGEMENT_SUBTYPE_DEAUTHENTICATION << 4),
NULL, 0, ap_deauth_cb, ap); NULL, 0, ap_deauth_cb, ap, NULL))
l_queue_push_tail(ap->frame_watch_ids, L_UINT_TO_PTR(id));
for (entry = l_queue_get_entries(ap->frame_watch_ids); entry;
entry = entry->next)
if (!L_PTR_TO_UINT(entry->data))
goto error; goto error;
cmd = ap_build_cmd_start_ap(ap); cmd = ap_build_cmd_start_ap(ap);