diff --git a/src/wiphy.c b/src/wiphy.c index cbfa301a..668c28da 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -91,6 +91,26 @@ bool __iwd_device_append_properties(struct netdev *netdev, return true; } +void __iwd_device_foreach(iwd_device_foreach_func func, void *user_data) +{ + const struct l_queue_entry *wiphy_entry; + + for (wiphy_entry = l_queue_get_entries(wiphy_list); wiphy_entry; + wiphy_entry = wiphy_entry->next) { + struct wiphy *wiphy = wiphy_entry->data; + const struct l_queue_entry *netdev_entry; + + netdev_entry = l_queue_get_entries(wiphy->netdev_list); + + while (netdev_entry) { + struct netdev *netdev = netdev_entry->data; + + func(netdev, user_data); + netdev_entry = netdev_entry->next; + } + } +} + static void device_emit_added(struct netdev *netdev) { struct l_dbus *dbus = dbus_get_bus(); diff --git a/src/wiphy.h b/src/wiphy.h index 3fbf6261..17e21d15 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -25,6 +25,8 @@ struct netdev; +typedef void (*iwd_device_foreach_func)(struct netdev *, void *data); + bool wiphy_init(void); bool wiphy_exit(void); @@ -34,3 +36,4 @@ void wiphy_set_ssid(const char *ssid); bool __iwd_device_append_properties(struct netdev *netdev, struct l_dbus_message_builder *builder); +void __iwd_device_foreach(iwd_device_foreach_func func, void *user_data);