commit c4771c4c5dbbe9db5941d7885c7864a4bafb4567
parent 630c487534f0b1b0bae1e7b44d7effbd47a83032
Author: James Prestwood <james.prestwood@linux.intel.com>
Date: Thu, 15 Aug 2019 13:15:20 -0700
station: introduce station_network_foreach
Iterates all networks for a given station object.
Diffstat:
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/src/station.c b/src/station.c
@@ -2932,6 +2932,31 @@ struct station *station_find(uint32_t ifindex)
return NULL;
}
+struct network_foreach_data {
+ station_network_foreach_func_t func;
+ void *user_data;
+};
+
+static void network_foreach(const void *key, void *value, void *user_data)
+{
+ struct network_foreach_data *data = user_data;
+ struct network *network = value;
+
+ data->func(network, data->user_data);
+}
+
+void station_network_foreach(struct station *station,
+ station_network_foreach_func_t func,
+ void *user_data)
+{
+ struct network_foreach_data data = {
+ .func = func,
+ .user_data = user_data,
+ };
+
+ l_hashmap_foreach(station->networks, network_foreach, &data);
+}
+
static struct station *station_create(struct netdev *netdev)
{
struct station *station;
diff --git a/src/station.h b/src/station.h
@@ -46,6 +46,7 @@ enum station_state {
typedef void (*station_foreach_func_t)(struct station *, void *data);
typedef void (*station_state_watch_func_t)(enum station_state, void *userdata);
typedef void (*station_destroy_func_t)(void *userdata);
+typedef void (*station_network_foreach_func_t)(struct network *, void *data);
struct wiphy *station_get_wiphy(struct station *station);
struct netdev *station_get_netdev(struct station *station);
@@ -80,3 +81,7 @@ int station_disconnect(struct station *station);
struct station *station_find(uint32_t ifindex);
void station_foreach(station_foreach_func_t func, void *user_data);
+
+void station_network_foreach(struct station *station,
+ station_network_foreach_func_t func,
+ void *user_data);