diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2019-05-06 17:12:08 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2019-06-05 18:33:39 +0200 |
commit | 03a91270b87d80e187dddfea17e50a04638169b5 (patch) | |
tree | 881510f87e9260f212f676394334351cf2b4d0fd | |
parent | 84539ce4cc9f466862314093de2f2ed9d0438921 (diff) | |
download | NetworkManager-03a91270b87d80e187dddfea17e50a04638169b5.tar.gz |
wwan: expose device id on the bus
The device id is useful to pinpoint the connection to a particular
device. However, we don't expose it anywhere and it's sort of hard to
guess.
-rw-r--r-- | introspection/org.freedesktop.NetworkManager.Device.Modem.xml | 11 | ||||
-rw-r--r-- | src/devices/wwan/libnm-wwan.ver | 1 | ||||
-rw-r--r-- | src/devices/wwan/nm-device-modem.c | 21 | ||||
-rw-r--r-- | src/devices/wwan/nm-device-modem.h | 1 |
4 files changed, 33 insertions, 1 deletions
diff --git a/introspection/org.freedesktop.NetworkManager.Device.Modem.xml b/introspection/org.freedesktop.NetworkManager.Device.Modem.xml index 330d693119..9ef4c7105d 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Modem.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Modem.xml @@ -29,6 +29,17 @@ <property name="CurrentCapabilities" type="u" access="read"/> <!-- + DeviceId: + + An identifier used by the modem backend (ModemManager) that aims to + uniquely identify the a device. Can be used to match a connection to a + particular device. + + Since: 1.20 + --> + <property name="DeviceId" type="s" access="read" /> + + <!-- PropertiesChanged: @properties: A dictionary mapping property names to variant boxed values diff --git a/src/devices/wwan/libnm-wwan.ver b/src/devices/wwan/libnm-wwan.ver index ea966afe6a..eb3bbb792b 100644 --- a/src/devices/wwan/libnm-wwan.ver +++ b/src/devices/wwan/libnm-wwan.ver @@ -10,6 +10,7 @@ global: nm_modem_get_capabilities; nm_modem_get_configured_mtu; nm_modem_get_control_port; + nm_modem_get_device_id; nm_modem_get_driver; nm_modem_get_iid; nm_modem_get_path; diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index ec7cabea9b..df7d1446d7 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2009 - 2011 Red Hat, Inc. + * Copyright (C) 2009 - 2019 Red Hat, Inc. */ #include "nm-default.h" @@ -40,6 +40,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_MODEM, PROP_CAPABILITIES, PROP_CURRENT_CAPABILITIES, + PROP_DEVICE_ID, ); typedef struct { @@ -47,6 +48,7 @@ typedef struct { NMDeviceModemCapabilities caps; NMDeviceModemCapabilities current_caps; gboolean rf_enabled; + char *device_id; } NMDeviceModemPrivate; struct _NMDeviceModem { @@ -722,6 +724,9 @@ get_property (GObject *object, guint prop_id, case PROP_CURRENT_CAPABILITIES: g_value_set_uint (value, priv->current_caps); break; + case PROP_DEVICE_ID: + g_value_set_string (value, priv->device_id); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -745,6 +750,10 @@ set_property (GObject *object, guint prop_id, case PROP_CURRENT_CAPABILITIES: priv->current_caps = g_value_get_uint (value); break; + case PROP_DEVICE_ID: + /* construct-only */ + priv->device_id = g_value_dup_string (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -779,6 +788,7 @@ nm_device_modem_new (NMModem *modem) NM_DEVICE_MODEM_MODEM, modem, NM_DEVICE_MODEM_CAPABILITIES, caps, NM_DEVICE_MODEM_CURRENT_CAPABILITIES, current_caps, + NM_DEVICE_MODEM_DEVICE_ID, nm_modem_get_device_id (modem), NULL); } @@ -792,6 +802,8 @@ dispose (GObject *object) g_clear_object (&priv->modem); } + g_clear_pointer (&priv->device_id, g_free); + G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object); } @@ -804,6 +816,7 @@ static const NMDBusInterfaceInfoExtended interface_info_device_modem = { .properties = NM_DEFINE_GDBUS_PROPERTY_INFOS ( NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("ModemCapabilities", "u", NM_DEVICE_MODEM_CAPABILITIES), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("CurrentCapabilities", "u", NM_DEVICE_MODEM_CURRENT_CAPABILITIES), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("DeviceId", "s", NM_DEVICE_MODEM_DEVICE_ID), ), ), .legacy_property_changed = TRUE, @@ -861,5 +874,11 @@ nm_device_modem_class_init (NMDeviceModemClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_DEVICE_ID] = + g_param_spec_string (NM_DEVICE_MODEM_DEVICE_ID, "", "", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); } diff --git a/src/devices/wwan/nm-device-modem.h b/src/devices/wwan/nm-device-modem.h index 65bda8b6ef..4e299c8f25 100644 --- a/src/devices/wwan/nm-device-modem.h +++ b/src/devices/wwan/nm-device-modem.h @@ -34,6 +34,7 @@ #define NM_DEVICE_MODEM_MODEM "modem" #define NM_DEVICE_MODEM_CAPABILITIES "modem-capabilities" #define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities" +#define NM_DEVICE_MODEM_DEVICE_ID "device-id" typedef struct _NMDeviceModem NMDeviceModem; typedef struct _NMDeviceModemClass NMDeviceModemClass; |