diff options
author | Thomas Haller <thaller@redhat.com> | 2018-11-21 10:47:51 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-12-09 14:47:31 +0100 |
commit | 936c6d0b0a9fd43cf8431f0a271dc07b317ce7d6 (patch) | |
tree | 1e6ba488233803323b8165ee4ae25af581f587de /src/nm-manager.h | |
parent | c9354cb47771263b0762e0400de1b894fa480cd1 (diff) |
core: add nm_manager_for_each_active_connection_safe() and nm_manager_for_each_device_safe()
Analog to c_list_for_each_safe(), which allows to delete the current instance
while iterating. Note that modifying the list any other way is unsafe.
Diffstat (limited to 'src/nm-manager.h')
-rw-r--r-- | src/nm-manager.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/nm-manager.h b/src/nm-manager.h index 06ca633de8..4b159f1ebd 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -97,6 +97,19 @@ const CList * nm_manager_get_active_connections (NMManager *manager); }); \ iter = c_list_entry (iter->active_connections_lst.next, NMActiveConnection, active_connections_lst)) +#define nm_manager_for_each_active_connection_safe(manager, iter, tmp_list, iter_safe) \ + for (tmp_list = nm_manager_get_active_connections (manager), \ + iter_safe = tmp_list->next; \ + ({ \ + if (iter_safe != tmp_list) { \ + iter = c_list_entry (iter_safe, NMActiveConnection, active_connections_lst); \ + iter_safe = iter_safe->next; \ + } else \ + iter = NULL; \ + (iter != NULL); \ + }); \ + ) + NMSettingsConnection **nm_manager_get_activatable_connections (NMManager *manager, gboolean for_auto_activation, gboolean sort, @@ -121,6 +134,19 @@ const CList * nm_manager_get_devices (NMManager *manager); }); \ iter = c_list_entry (iter->devices_lst.next, NMDevice, devices_lst)) +#define nm_manager_for_each_device_safe(manager, iter, tmp_list, iter_safe) \ + for (tmp_list = nm_manager_get_devices (manager), \ + iter_safe = tmp_list->next; \ + ({ \ + if (iter_safe != tmp_list) { \ + iter = c_list_entry (iter_safe, NMDevice, devices_lst); \ + iter_safe = iter_safe->next; \ + } else \ + iter = NULL; \ + (iter != NULL); \ + }); \ + ) + NMDevice * nm_manager_get_device_by_ifindex (NMManager *manager, int ifindex); NMDevice * nm_manager_get_device_by_path (NMManager *manager, |