diff options
author | Thomas Haller <thaller@redhat.com> | 2016-05-09 18:16:45 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-05-12 11:14:13 +0200 |
commit | 887c5e0afefb5281b05be60b983a678da0151664 (patch) | |
tree | fbb1e791c87b258632048f56a4733b839240e10e | |
parent | 993ae2d414f7e092a0d6695d2e0a2b6c9a36b37a (diff) | |
download | NetworkManager-887c5e0afefb5281b05be60b983a678da0151664.tar.gz |
device: add function to change device capabilites
-rw-r--r-- | src/devices/nm-device.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index faf736df18..2c4cde3333 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -550,6 +550,17 @@ nm_device_has_capability (NMDevice *self, NMDeviceCapabilities caps) return NM_FLAGS_ANY (NM_DEVICE_GET_PRIVATE (self)->capabilities, caps); } +static void +_add_capabilities (NMDevice *self, NMDeviceCapabilities capabilities) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + + if (!NM_FLAGS_ALL (priv->capabilities, capabilities)) { + priv->capabilities |= capabilities; + _notify (self, PROP_CAPABILITIES); + } +} + /***********************************************************/ const char * @@ -1931,6 +1942,7 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) NMDevicePrivate *priv; NMDeviceClass *klass; static guint32 id = 0; + NMDeviceCapabilities capabilities = 0; g_return_if_fail (NM_IS_DEVICE (self)); @@ -1963,7 +1975,7 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) priv->dev_id = nm_platform_link_get_dev_id (NM_PLATFORM_GET, priv->ifindex); if (nm_platform_link_is_software (NM_PLATFORM_GET, priv->ifindex)) - priv->capabilities |= NM_DEVICE_CAP_IS_SOFTWARE; + capabilities |= NM_DEVICE_CAP_IS_SOFTWARE; priv->mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ifindex); _notify (self, PROP_MTU); @@ -1983,7 +1995,9 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) } if (klass->get_generic_capabilities) - priv->capabilities |= klass->get_generic_capabilities (self); + capabilities |= klass->get_generic_capabilities (self); + + _add_capabilities (self, capabilities); if (!priv->udi) { /* Use a placeholder UDI until we get a real one */ @@ -2018,8 +2032,6 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) priv->carrier = TRUE; } - _notify (self, PROP_CAPABILITIES); - klass->realize_start_notify (self, plink); /* Do not manage externally created software devices until they are IFF_UP |