From d99171d700c68e9f6b7d69f70a6918bd7d0c310c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 17 Jun 2016 12:25:37 -0500 Subject: [PATCH] wwan: use modem basename as NM device name NM_MODEM_UID is used as the modem device name, and the device name cannot contain path-like characters. Ofono has a bluez plugin that detects paired DUN/PAN capable Bluetooth devices, and these devices are created with a multi-component object path like "/hfp/org/bluez/hci0/dev_00_26_E2_AB_68_66". The NM ofono plugin cannot use these paths as NM device names. Instead, strip off any path components and use the last part of the object path as the NM device name. --- src/devices/wwan/nm-modem-ofono.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/devices/wwan/nm-modem-ofono.c b/src/devices/wwan/nm-modem-ofono.c index 4f0860ad2..f1a526cdf 100644 --- a/src/devices/wwan/nm-modem-ofono.c +++ b/src/devices/wwan/nm-modem-ofono.c @@ -734,14 +734,21 @@ modem_get_properties_done (GDBusProxy *proxy, GAsyncResult *result, gpointer use NMModem * nm_modem_ofono_new (const char *path) { + gs_free char *basename = NULL; + g_return_val_if_fail (path != NULL, NULL); nm_log_dbg (LOGD_MB, "in %s: path %s", __func__, path); + /* Use short modem name (not its object path) as the NM device name (which + * comes from NM_MODEM_UID)and the device ID. + */ + basename = g_path_get_basename (path); + return (NMModem *) g_object_new (NM_TYPE_MODEM_OFONO, NM_MODEM_PATH, path, - NM_MODEM_UID, (path + 1), - NM_MODEM_DEVICE_ID, (path + 1), + NM_MODEM_UID, basename, + NM_MODEM_DEVICE_ID, basename, NM_MODEM_CONTROL_PORT, "ofono", /* mandatory */ NM_MODEM_DRIVER, "ofono", NM_MODEM_STATE, NM_MODEM_STATE_INITIALIZING,