diff options
| author | Lubomir Rintel <lkundrak@v3.sk> | 2018-07-03 19:09:34 +0200 |
|---|---|---|
| committer | Lubomir Rintel <lkundrak@v3.sk> | 2018-09-24 15:36:19 +0200 |
| commit | d8971fcbcd3309e7abf6e30c4bcf5283858f4ce3 (patch) | |
| tree | 0d1dad97a1ff8c185f85aec059a18cd1922a99b9 | |
| parent | 9664f284a1d8575798daa9abf9cd7f49a19b48d9 (diff) | |
| download | NetworkManager-d8971fcbcd3309e7abf6e30c4bcf5283858f4ce3.tar.gz | |
device: expose connectivity check result on a device
Separate properties for IPv4 and IPv6.
| -rw-r--r-- | introspection/org.freedesktop.NetworkManager.Device.xml | 22 | ||||
| -rw-r--r-- | src/devices/nm-device.c | 33 | ||||
| -rw-r--r-- | src/devices/nm-device.h | 4 | ||||
| -rw-r--r-- | src/nm-manager.c | 5 |
4 files changed, 45 insertions, 19 deletions
diff --git a/introspection/org.freedesktop.NetworkManager.Device.xml b/introspection/org.freedesktop.NetworkManager.Device.xml index be0a612cc4..f168115697 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.xml @@ -257,6 +257,28 @@ <property name="Real" type="b" access="read"/> <!-- + Ip4Connectivity: + + The result of the last IPv4 connectivity check. + + Since: 1.16 + + Returns: <link linkend="NMConnectivityState">NMConnectivityState</link> + --> + <property name="Ip4Connectivity" type="u" access="read"/> + + <!-- + Ip6Connectivity: + + The result of the last IPv6 connectivity check. + + Since: 1.16 + + Returns: <link linkend="NMConnectivityState">NMConnectivityState</link> + --> + <property name="Ip6Connectivity" type="u" access="read"/> + + <!-- Reapply: @connection: The optional connection settings that will be reapplied on the device. If empty, the currently active settings-connection will be used. The connection cannot arbitrarly differ from the current applied-connection otherwise the call will fail. Only certain changes are supported, like adding or removing IP addresses. @version_id: If non-zero, the current version id of the applied-connection must match. The current version id can be retrieved via GetAppliedConnection. This optional argument allows to catch concurrent modifications between the GetAppliedConnection call and Reapply. diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index b145a96257..4954b519d7 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -197,7 +197,6 @@ enum { REMOVED, RECHECK_AUTO_ACTIVATE, RECHECK_ASSUME, - CONNECTIVITY_CHANGED, LAST_SIGNAL, }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -243,7 +242,8 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDevice, PROP_REFRESH_RATE_MS, PROP_TX_BYTES, PROP_RX_BYTES, - PROP_CONNECTIVITY, + PROP_IP4_CONNECTIVITY, + PROP_IP6_CONNECTIVITY, ); typedef struct _NMDevicePrivate { @@ -2799,8 +2799,7 @@ concheck_update_state (NMDevice *self, int addr_family, nm_connectivity_state_to_string (state)); priv->concheck_x[IS_IPv4].state = state; - _notify (self, PROP_CONNECTIVITY); - g_signal_emit (self, signals[CONNECTIVITY_CHANGED], 0); + _notify (self, IS_IPv4 ? PROP_IP4_CONNECTIVITY : PROP_IP6_CONNECTIVITY); if ( priv->state == NM_DEVICE_STATE_ACTIVATED && !nm_device_sys_iface_state_is_external (self)) { @@ -16395,8 +16394,11 @@ get_property (GObject *object, guint prop_id, case PROP_RX_BYTES: g_value_set_uint64 (value, priv->stats.rx_bytes); break; - case PROP_CONNECTIVITY: - g_value_set_uint (value, nm_device_get_connectivity_state (self)); + case PROP_IP4_CONNECTIVITY: + g_value_set_uint (value, priv->concheck_x[1].state); + break; + case PROP_IP6_CONNECTIVITY: + g_value_set_uint (value, priv->concheck_x[0].state); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -16484,6 +16486,8 @@ static const NMDBusInterfaceInfoExtended interface_info_device = { NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Metered", "u", NM_DEVICE_METERED), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("LldpNeighbors", "aa{sv}", NM_DEVICE_LLDP_NEIGHBORS), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Real", "b", NM_DEVICE_REAL), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("Ip4Connectivity", "u", NM_DEVICE_IP4_CONNECTIVITY), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("Ip6Connectivity", "u", NM_DEVICE_IP6_CONNECTIVITY), ), ), }; @@ -16760,8 +16764,13 @@ nm_device_class_init (NMDeviceClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_CONNECTIVITY] = - g_param_spec_uint (NM_DEVICE_CONNECTIVITY, "", "", + obj_properties[PROP_IP4_CONNECTIVITY] = + g_param_spec_uint (NM_DEVICE_IP4_CONNECTIVITY, "", "", + NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_FULL, NM_CONNECTIVITY_UNKNOWN, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_IP6_CONNECTIVITY] = + g_param_spec_uint (NM_DEVICE_IP6_CONNECTIVITY, "", "", NM_CONNECTIVITY_UNKNOWN, NM_CONNECTIVITY_FULL, NM_CONNECTIVITY_UNKNOWN, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); @@ -16841,12 +16850,4 @@ nm_device_class_init (NMDeviceClass *klass) G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); - - signals[CONNECTIVITY_CHANGED] = - g_signal_new (NM_DEVICE_CONNECTIVITY_CHANGED, - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); } diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index d32bf25250..d1e58d4749 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -143,13 +143,13 @@ nm_device_state_reason_check (NMDeviceStateReason reason) #define NM_DEVICE_STATE_CHANGED "state-changed" #define NM_DEVICE_LINK_INITIALIZED "link-initialized" #define NM_DEVICE_AUTOCONNECT_ALLOWED "autoconnect-allowed" -#define NM_DEVICE_CONNECTIVITY_CHANGED "connectivity-changed" #define NM_DEVICE_STATISTICS_REFRESH_RATE_MS "refresh-rate-ms" #define NM_DEVICE_STATISTICS_TX_BYTES "tx-bytes" #define NM_DEVICE_STATISTICS_RX_BYTES "rx-bytes" -#define NM_DEVICE_CONNECTIVITY "connectivity" +#define NM_DEVICE_IP4_CONNECTIVITY "ip4-connectivity" +#define NM_DEVICE_IP6_CONNECTIVITY "ip6-connectivity" #define NM_TYPE_DEVICE (nm_device_get_type ()) #define NM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE, NMDevice)) diff --git a/src/nm-manager.c b/src/nm-manager.c index 120cecd928..51c3975d32 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2955,7 +2955,10 @@ add_device (NMManager *self, NMDevice *device, GError **error) G_CALLBACK (device_realized), self); - g_signal_connect (device, NM_DEVICE_CONNECTIVITY_CHANGED, + g_signal_connect (device, "notify::" NM_DEVICE_IP4_CONNECTIVITY, + G_CALLBACK (device_connectivity_changed), + self); + g_signal_connect (device, "notify::" NM_DEVICE_IP6_CONNECTIVITY, G_CALLBACK (device_connectivity_changed), self); |
