mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 16:20:09 +01:00
manager: add a method to get a particular device of given type
And also make the remove_device() method use it behind the scenes.
This commit is contained in:
parent
d7f7725ae8
commit
6af5030cf2
3 changed files with 31 additions and 10 deletions
|
|
@ -117,7 +117,7 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
|
|||
return;
|
||||
}
|
||||
if (renamed)
|
||||
nm_manager_remove_device (nm_manager_get (), iface);
|
||||
nm_manager_remove_device (nm_manager_get (), iface, NM_DEVICE_TYPE_PPP);
|
||||
|
||||
nm_device_activate_schedule_ip4_config_result (device, config);
|
||||
return;
|
||||
|
|
@ -195,7 +195,7 @@ act_stage3_ip4_config_start (NMDevice *device,
|
|||
if (!nm_device_take_over_link (device, priv->pending_ifname, &renamed))
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
if (renamed)
|
||||
nm_manager_remove_device (nm_manager_get (), priv->pending_ifname);
|
||||
nm_manager_remove_device (nm_manager_get (), priv->pending_ifname, NM_DEVICE_TYPE_PPP);
|
||||
if (out_config)
|
||||
*out_config = g_steal_pointer (&priv->pending_ip4_config);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1270,22 +1270,38 @@ nm_manager_iface_for_uuid (NMManager *self, const char *uuid)
|
|||
return nm_connection_get_interface_name (NM_CONNECTION (connection));
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_manager_remove_device (NMManager *self, const char *ifname)
|
||||
NMDevice *
|
||||
nm_manager_get_device (NMManager *self, const char *ifname, NMDeviceType device_type)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||
GSList *iter;
|
||||
NMDevice *d;
|
||||
|
||||
g_return_val_if_fail (ifname, NULL);
|
||||
g_return_val_if_fail (device_type != NM_DEVICE_TYPE_UNKNOWN, NULL);
|
||||
|
||||
for (iter = priv->devices; iter; iter = iter->next) {
|
||||
d = iter->data;
|
||||
if (nm_streq0 (nm_device_get_iface (d), ifname)) {
|
||||
remove_device (self, d, FALSE, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( nm_device_get_device_type (d) == device_type
|
||||
&& nm_streq0 (nm_device_get_iface (d), ifname))
|
||||
return d;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_manager_remove_device (NMManager *self, const char *ifname, NMDeviceType device_type)
|
||||
{
|
||||
NMDevice *d;
|
||||
|
||||
d = nm_manager_get_device (self, ifname, device_type);
|
||||
if (!d)
|
||||
return FALSE;
|
||||
|
||||
remove_device (self, d, FALSE, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -126,6 +126,11 @@ gboolean nm_manager_deactivate_connection (NMManager *manager,
|
|||
|
||||
void nm_manager_set_capability (NMManager *self, NMCapability cap);
|
||||
|
||||
gboolean nm_manager_remove_device (NMManager *self, const char *ifname);
|
||||
NMDevice * nm_manager_get_device (NMManager *self,
|
||||
const char *ifname,
|
||||
NMDeviceType device_type);
|
||||
gboolean nm_manager_remove_device (NMManager *self,
|
||||
const char *ifname,
|
||||
NMDeviceType device_type);
|
||||
|
||||
#endif /* __NETWORKMANAGER_MANAGER_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue