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.
This commit is contained in:
Dan Williams
2016-06-17 12:25:37 -05:00
committed by Thomas Haller
parent e06e1d4691
commit d99171d700

View File

@@ -734,14 +734,21 @@ modem_get_properties_done (GDBusProxy *proxy, GAsyncResult *result, gpointer use
NMModem * NMModem *
nm_modem_ofono_new (const char *path) nm_modem_ofono_new (const char *path)
{ {
gs_free char *basename = NULL;
g_return_val_if_fail (path != NULL, NULL); g_return_val_if_fail (path != NULL, NULL);
nm_log_dbg (LOGD_MB, "in %s: path %s", __func__, path); 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, return (NMModem *) g_object_new (NM_TYPE_MODEM_OFONO,
NM_MODEM_PATH, path, NM_MODEM_PATH, path,
NM_MODEM_UID, (path + 1), NM_MODEM_UID, basename,
NM_MODEM_DEVICE_ID, (path + 1), NM_MODEM_DEVICE_ID, basename,
NM_MODEM_CONTROL_PORT, "ofono", /* mandatory */ NM_MODEM_CONTROL_PORT, "ofono", /* mandatory */
NM_MODEM_DRIVER, "ofono", NM_MODEM_DRIVER, "ofono",
NM_MODEM_STATE, NM_MODEM_STATE_INITIALIZING, NM_MODEM_STATE, NM_MODEM_STATE_INITIALIZING,