commit 8e03d56688c7ebf3a8371fac8e376d58f655844f
parent 8620698b661acb36467e0a8bc26b5604837637c2
Author: James Prestwood <prestwoj@gmail.com>
Date: Wed, 20 Jan 2021 10:30:30 -0800
netdev: add netdev_get_all_stations
This is a nl80211 dump version of netdev_get_station aimed at
AP mode. This will dump all stations, parse into
netdev_station_info structs, and call the callback for each
individual station found. Once the dump is completed the destroy
callback is called.
Diffstat:
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/src/netdev.c b/src/netdev.c
@@ -4240,6 +4240,32 @@ int netdev_get_current_station(struct netdev *netdev,
user_data, destroy);
}
+int netdev_get_all_stations(struct netdev *netdev, netdev_get_station_cb_t cb,
+ void *user_data, netdev_destroy_func_t destroy)
+{
+ struct l_genl_msg *msg;
+
+ if (netdev->get_station_cmd_id)
+ return -EBUSY;
+
+ msg = l_genl_msg_new_sized(NL80211_CMD_GET_STATION, 64);
+ l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index);
+
+ netdev->get_station_cmd_id = l_genl_family_dump(nl80211, msg,
+ netdev_get_station_cb, netdev,
+ netdev_get_station_destroy);
+ if (!netdev->get_station_cmd_id) {
+ l_genl_msg_unref(msg);
+ return -EIO;
+ }
+
+ netdev->get_station_cb = cb;
+ netdev->get_station_data = user_data;
+ netdev->get_station_destroy = destroy;
+
+ return 0;
+}
+
static int netdev_cqm_rssi_update(struct netdev *netdev)
{
struct l_genl_msg *msg;
diff --git a/src/netdev.h b/src/netdev.h
@@ -211,6 +211,8 @@ int netdev_get_station(struct netdev *netdev, const uint8_t *mac,
int netdev_get_current_station(struct netdev *netdev,
netdev_get_station_cb_t cb, void *user_data,
netdev_destroy_func_t destroy);
+int netdev_get_all_stations(struct netdev *netdev, netdev_get_station_cb_t cb,
+ void *user_data, netdev_destroy_func_t destroy);
void netdev_handshake_failed(struct handshake_state *hs, uint16_t reason_code);