summary refs log tree commit diff
path: root/src/devices/wwan
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2018-09-23 10:10:27 +0200
committerMichael Biebl <biebl@debian.org>2018-09-23 10:10:27 +0200
commite126f3e804c35480c4f075777430419d6ece23da (patch)
tree5d5821ebcda8cd6ac34d2483bb3354910e508930 /src/devices/wwan
parentc240974325c552cad177c457d6ff04e381fd77a3 (diff)
New upstream version 1.12.4 upstream/1.12.4
Diffstat (limited to 'src/devices/wwan')
-rw-r--r--src/devices/wwan/meson.build6
-rw-r--r--src/devices/wwan/nm-device-modem.c47
-rw-r--r--src/devices/wwan/nm-modem-broadband.c52
-rw-r--r--src/devices/wwan/nm-modem-manager.c14
-rw-r--r--src/devices/wwan/nm-modem-ofono.c47
-rw-r--r--src/devices/wwan/nm-modem.c52
-rw-r--r--src/devices/wwan/nm-modem.h11
7 files changed, 106 insertions, 123 deletions
diff --git a/src/devices/wwan/meson.build b/src/devices/wwan/meson.build
index 2c0ea5a1..abf58594 100644
--- a/src/devices/wwan/meson.build
+++ b/src/devices/wwan/meson.build
@@ -35,10 +35,10 @@ libnm_wwan_dep = declare_dependency(
 
 core_plugins += libnm_wwan
 
-test(
+run_target(
   'check-wwan',
-  check_exports,
-  args: [libnm_wwan.full_path(), linker_script],
+  command: [check_exports, libnm_wwan.full_path(), linker_script],
+  depends: libnm_wwan
 )
 
 sources = files(
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index 4119d598..352b1c3e 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -397,67 +397,34 @@ get_type_description (NMDevice *device)
 }
 
 static gboolean
-check_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
+check_connection_compatible (NMDevice *device, NMConnection *connection)
 {
-	GError *local = NULL;
-
-	if (!NM_DEVICE_CLASS (nm_device_modem_parent_class)->check_connection_compatible (device, connection, error))
+	if (!NM_DEVICE_CLASS (nm_device_modem_parent_class)->check_connection_compatible (device, connection))
 		return FALSE;
 
-	if (!nm_modem_check_connection_compatible (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem,
-	                                           connection,
-	                                           error ? &local : NULL)) {
-		if (error) {
-			g_set_error (error,
-			             NM_UTILS_ERROR,
-			             g_error_matches (local, NM_UTILS_ERROR, NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE)
-			              ? NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE
-			              : NM_UTILS_ERROR_UNKNOWN,
-			             "modem is incompatible with connection: %s",
-			             local->message);
-			g_error_free (local);
-		}
-		return FALSE;
-	}
-	return TRUE;
+	return nm_modem_check_connection_compatible (NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device)->modem, connection);
 }
 
 static gboolean
 check_connection_available (NMDevice *device,
                             NMConnection *connection,
                             NMDeviceCheckConAvailableFlags flags,
-                            const char *specific_object,
-                            GError **error)
+                            const char *specific_object)
 {
 	NMDeviceModem *self = NM_DEVICE_MODEM (device);
 	NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (self);
 	NMModemState state;
 
-	if (!priv->rf_enabled) {
-		nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-		                            "RFKILL for modem enabled");
+	if (!priv->rf_enabled || !priv->modem)
 		return FALSE;
-	}
-
-	if (!priv->modem) {
-		nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-		                            "modem not available");
-		return FALSE;
-	}
 
 	state = nm_modem_get_state (priv->modem);
-	if (state <= NM_MODEM_STATE_INITIALIZING) {
-		nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-		                            "modem not initalized");
+	if (state <= NM_MODEM_STATE_INITIALIZING)
 		return FALSE;
-	}
 
 	if (state == NM_MODEM_STATE_LOCKED) {
-		if (!nm_connection_get_setting_gsm (connection)) {
-			nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-			                            "modem is locked without pin available");
+		if (!nm_connection_get_setting_gsm (connection))
 			return FALSE;
-		}
 	}
 
 	return TRUE;
diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c
index 253574d5..e5678b96 100644
--- a/src/devices/wwan/nm-modem-broadband.c
+++ b/src/devices/wwan/nm-modem-broadband.c
@@ -256,7 +256,7 @@ create_cdma_connect_properties (NMConnection *connection)
 {
 	NMSettingCdma *setting;
 	MMSimpleConnectProperties *properties;
-	const char *str;
+	const gchar *str;
 
 	setting = nm_connection_get_setting_cdma (connection);
 	properties = mm_simple_connect_properties_new ();
@@ -274,7 +274,7 @@ create_gsm_connect_properties (NMConnection *connection)
 	NMSettingGsm *setting;
 	NMSettingPpp *s_ppp;
 	MMSimpleConnectProperties *properties;
-	const char *str;
+	const gchar *str;
 
 	setting = nm_connection_get_setting_gsm (connection);
 	properties = mm_simple_connect_properties_new ();
@@ -617,40 +617,44 @@ act_stage1_prepare (NMModem *_self,
 /*****************************************************************************/
 
 static gboolean
-check_connection_compatible_with_modem (NMModem *_self, NMConnection *connection, GError **error)
+check_connection_compatible (NMModem *_self, NMConnection *connection)
 {
 	NMModemBroadband *self = NM_MODEM_BROADBAND (_self);
 	MMModemCapability modem_caps;
+	NMSettingConnection *s_con;
 
 	modem_caps = mm_modem_get_current_capabilities (self->_priv.modem_iface);
+	s_con = nm_connection_get_setting_connection (connection);
+	g_assert (s_con);
 
 	if (MODEM_CAPS_3GPP (modem_caps)) {
-		if (!_nm_connection_check_main_setting (connection, NM_SETTING_GSM_SETTING_NAME, error))
+		NMSettingGsm *s_gsm;
+
+		if (!g_str_equal (nm_setting_connection_get_connection_type (s_con),
+		                  NM_SETTING_GSM_SETTING_NAME))
+			return FALSE;
+
+		s_gsm = nm_connection_get_setting_gsm (connection);
+		if (!s_gsm)
 			return FALSE;
 
 		return TRUE;
 	}
 
 	if (MODEM_CAPS_3GPP2 (modem_caps)) {
-		if (!_nm_connection_check_main_setting (connection, NM_SETTING_CDMA_SETTING_NAME, error))
+		NMSettingCdma *s_cdma;
+
+		if (!g_str_equal (nm_setting_connection_get_connection_type (s_con),
+		                  NM_SETTING_CDMA_SETTING_NAME))
 			return FALSE;
 
-		return TRUE;
-	}
+		s_cdma = nm_connection_get_setting_cdma (connection);
+		if (!s_cdma)
+			return FALSE;
 
-	if (   !_nm_connection_check_main_setting (connection, NM_SETTING_GSM_SETTING_NAME, NULL)
-	    && !_nm_connection_check_main_setting (connection, NM_SETTING_CDMA_SETTING_NAME, NULL)) {
-		nm_utils_error_set (error,
-		                    NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE,
-		                    "connection type %s is not supported by modem",
-		                    nm_connection_get_connection_type (connection));
-		return FALSE;
+		return TRUE;
 	}
 
-	nm_utils_error_set (error,
-	                    NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-	                    "modem lacks capabilities for %s profile",
-	                    nm_connection_get_connection_type (connection));
 	return FALSE;
 }
 
@@ -864,12 +868,12 @@ static_stage3_ip4_done (NMModemBroadband *self)
 	GError *error = NULL;
 	gs_unref_object NMIP4Config *config = NULL;
 	const char *data_port;
-	const char *address_string;
-	const char *gw_string;
+	const gchar *address_string;
+	const gchar *gw_string;
 	guint32 address_network;
 	guint32 gw = 0;
 	NMPlatformIP4Address address;
-	const char **dns;
+	const gchar **dns;
 	guint i;
 	guint32 ip4_route_table, ip4_route_metric;
 	NMPlatformIP4Route *r;
@@ -975,10 +979,10 @@ stage3_ip6_done (NMModemBroadband *self)
 	GError *error = NULL;
 	NMIP6Config *config = NULL;
 	const char *data_port;
-	const char *address_string;
+	const gchar *address_string;
 	NMPlatformIP6Address address;
 	NMModemIPMethod ip_method;
-	const char **dns;
+	const gchar **dns;
 	guint i;
 
 	g_assert (self->_priv.ipv6_config);
@@ -1472,7 +1476,7 @@ nm_modem_broadband_class_init (NMModemBroadbandClass *klass)
 	modem_class->deactivate_cleanup = deactivate_cleanup;
 	modem_class->set_mm_enabled = set_mm_enabled;
 	modem_class->get_user_pass = get_user_pass;
-	modem_class->check_connection_compatible_with_modem = check_connection_compatible_with_modem;
+	modem_class->check_connection_compatible = check_connection_compatible;
 	modem_class->complete_connection = complete_connection;
 	modem_class->act_stage1_prepare = act_stage1_prepare;
 	modem_class->owns_port = owns_port;
diff --git a/src/devices/wwan/nm-modem-manager.c b/src/devices/wwan/nm-modem-manager.c
index dfc102f3..59cd2bca 100644
--- a/src/devices/wwan/nm-modem-manager.c
+++ b/src/devices/wwan/nm-modem-manager.c
@@ -170,7 +170,7 @@ modm_handle_object_added (MMManager *modem_manager,
                           NMModemManager *self)
 {
 	NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE (self);
-	const char *path;
+	const gchar *path;
 	MMModem *modem_iface;
 	NMModem *modem;
 	GError *error = NULL;
@@ -211,7 +211,7 @@ modm_handle_object_removed (MMManager *manager,
 {
 	NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE (self);
 	NMModem *modem;
-	const char *path;
+	const gchar *path;
 
 	path = mm_object_get_path (modem_object);
 	modem = (NMModem *) g_hash_table_lookup (priv->modems, path);
@@ -246,7 +246,7 @@ modm_handle_name_owner_changed (MMManager *modem_manager,
                                 NMModemManager *self)
 {
 	NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE (self);
-	char *name_owner;
+	gchar *name_owner;
 
 	/* Quit poking, if any */
 	nm_clear_g_source (&priv->modm.relaunch_id);
@@ -341,7 +341,7 @@ static void
 modm_manager_check_name_owner (NMModemManager *self)
 {
 	NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE (self);
-	gs_free char *name_owner = NULL;
+	gs_free gchar *name_owner = NULL;
 
 	name_owner = g_dbus_object_manager_client_get_name_owner (G_DBUS_OBJECT_MANAGER_CLIENT (priv->modm.manager));
 	if (name_owner) {
@@ -606,14 +606,14 @@ ofono_create_modem (NMModemManager *self, const char *path)
 
 static void
 ofono_signal_cb (GDBusProxy *proxy,
-                 char *sender_name,
-                 char *signal_name,
+                 gchar *sender_name,
+                 gchar *signal_name,
                  GVariant *parameters,
                  gpointer user_data)
 {
 	NMModemManager *self = NM_MODEM_MANAGER (user_data);
 	NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE (self);
-	char *object_path;
+	gchar *object_path;
 	NMModem *modem;
 
 	if (g_strcmp0 (signal_name, "ModemAdded") == 0) {
diff --git a/src/devices/wwan/nm-modem-ofono.c b/src/devices/wwan/nm-modem-ofono.c
index ea668590..8b81ac41 100644
--- a/src/devices/wwan/nm-modem-ofono.c
+++ b/src/devices/wwan/nm-modem-ofono.c
@@ -279,42 +279,47 @@ deactivate_cleanup (NMModem *modem, NMDevice *device)
 }
 
 static gboolean
-check_connection_compatible_with_modem (NMModem *modem,
-                                        NMConnection *connection,
-                                        GError **error)
+check_connection_compatible (NMModem *modem,
+                             NMConnection *connection)
 {
 	NMModemOfono *self = NM_MODEM_OFONO (modem);
 	NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
+	NMSettingConnection *s_con;
+	NMSettingGsm *s_gsm;
+	const char *uuid;
 	const char *id;
 
-	if (!_nm_connection_check_main_setting (connection, NM_SETTING_GSM_SETTING_NAME, NULL)) {
-		nm_utils_error_set (error,
-		                    NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE,
-		                    "connection type %s is not supported by ofono modem",
-		                    nm_connection_get_connection_type (connection));
+	s_con = nm_connection_get_setting_connection (connection);
+	g_assert (s_con);
+
+	uuid = nm_connection_get_uuid (connection);
+	id = nm_connection_get_id (connection);
+
+	s_gsm = nm_connection_get_setting_gsm (connection);
+	if (!s_gsm)
 		return FALSE;
-	}
 
 	if (!priv->imsi) {
-		nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-		                            "modem has no IMSI");
+		_LOGW ("skipping %s/%s: no IMSI", uuid, id);
 		return FALSE;
 	}
 
-	id = nm_connection_get_id (connection);
+	if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_GSM_SETTING_NAME)) {
+		_LOGD ("skipping %s/%s: not GSM", uuid, id);
+		return FALSE;
+	}
 
-	if (!strstr (id, "/context")) {
-		nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-		                            "the connection ID has no context");
+	if (!g_strrstr (id, "/context")) {
+		_LOGD ("skipping %s/%s: unexpected ID", uuid, id);
 		return FALSE;
 	}
 
-	if (!strstr (id, priv->imsi)) {
-		nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-		                            "the connection ID does not contain the IMSI");
+	if (!g_strrstr (id, priv->imsi)) {
+		_LOGD ("skipping %s/%s: ID doesn't contain IMSI", uuid, id);
 		return FALSE;
 	}
 
+	_LOGD ("%s/%s compatible with IMSI %s", uuid, id, priv->imsi);
 	return TRUE;
 }
 
@@ -825,8 +830,8 @@ context_property_changed (GDBusProxy *proxy,
 	gboolean ret = FALSE;
 	gs_unref_variant GVariant *v_dict = NULL;
 	const char *interface;
-	const char *s;
-	const char **array, **iter;
+	const gchar *s;
+	const gchar **array, **iter;
 	guint32 address_network, gateway_network;
 	guint32 ip4_route_table, ip4_route_metric;
 	int ifindex;
@@ -1321,7 +1326,7 @@ nm_modem_ofono_class_init (NMModemOfonoClass *klass)
 	modem_class->disconnect = disconnect;
 	modem_class->disconnect_finish = disconnect_finish;
 	modem_class->deactivate_cleanup = deactivate_cleanup;
-	modem_class->check_connection_compatible_with_modem = check_connection_compatible_with_modem;
+	modem_class->check_connection_compatible = check_connection_compatible;
 
 	modem_class->act_stage1_prepare = act_stage1_prepare;
 	modem_class->static_stage3_ip4_config_start = static_stage3_ip4_config_start;
diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c
index 59b081e9..617d5c4a 100644
--- a/src/devices/wwan/nm-modem.c
+++ b/src/devices/wwan/nm-modem.c
@@ -291,7 +291,7 @@ nm_modem_get_supported_ip_types (NMModem *self)
 	return NM_MODEM_GET_PRIVATE (self)->ip_types;
 }
 
-const char *
+const gchar *
 nm_modem_ip_type_to_string (NMModemIPType ip_type)
 {
 	switch (ip_type) {
@@ -1027,29 +1027,35 @@ nm_modem_act_stage2_config (NMModem *self,
 /*****************************************************************************/
 
 gboolean
-nm_modem_check_connection_compatible (NMModem *self, NMConnection *connection, GError **error)
+nm_modem_check_connection_compatible (NMModem *self, NMConnection *connection)
 {
 	NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self);
+	NMSettingConnection *s_con;
+
+	s_con = nm_connection_get_setting_connection (connection);
+	g_assert (s_con);
 
-	if (nm_streq0 (nm_connection_get_connection_type (connection),
-	               NM_SETTING_GSM_SETTING_NAME)) {
+	if (g_str_equal (nm_setting_connection_get_connection_type (s_con),
+	                 NM_SETTING_GSM_SETTING_NAME)) {
 		NMSettingGsm *s_gsm;
 		const char *str;
 
-		s_gsm = _nm_connection_check_main_setting (connection, NM_SETTING_GSM_SETTING_NAME, error);
+		s_gsm = nm_connection_get_setting_gsm (connection);
 		if (!s_gsm)
 			return FALSE;
 
 		str = nm_setting_gsm_get_device_id (s_gsm);
 		if (str) {
 			if (!priv->device_id) {
-				nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-				                            "GSM profile has device-id, device does not");
+				_LOGD ("%s/%s has device-id, device does not",
+				       nm_connection_get_uuid (connection),
+				       nm_connection_get_id (connection));
 				return FALSE;
 			}
-			if (!nm_streq (str, priv->device_id)) {
-				nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-				                            "device has differing device-id than GSM profile");
+			if (strcmp (str, priv->device_id)) {
+				_LOGD ("%s/%s device-id mismatch",
+				       nm_connection_get_uuid (connection),
+				       nm_connection_get_id (connection));
 				return FALSE;
 			}
 		}
@@ -1059,26 +1065,30 @@ nm_modem_check_connection_compatible (NMModem *self, NMConnection *connection, G
 		 * are only compared if present on the device.
 		 */
 
-		if (   priv->sim_id
-		    && (str = nm_setting_gsm_get_sim_id (s_gsm))) {
-			if (!nm_streq (str, priv->sim_id)) {
-				nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-				                            "device has differing sim-id than GSM profile");
+		str = nm_setting_gsm_get_sim_id (s_gsm);
+		if (str && priv->sim_id) {
+			if (strcmp (str, priv->sim_id)) {
+				_LOGD ("%s/%s sim-id mismatch",
+				       nm_connection_get_uuid (connection),
+				       nm_connection_get_id (connection));
 				return FALSE;
 			}
 		}
 
-		if (   priv->sim_operator_id
-		    && (str = nm_setting_gsm_get_sim_operator_id (s_gsm))) {
-			if (!nm_streq (str, priv->sim_operator_id)) {
-				nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-				                            "device has differing sim-operator-id than GSM profile");
+		str = nm_setting_gsm_get_sim_operator_id (s_gsm);
+		if (str && priv->sim_operator_id) {
+			if (strcmp (str, priv->sim_operator_id)) {
+				_LOGD ("%s/%s sim-operator-id mismatch",
+				       nm_connection_get_uuid (connection),
+				       nm_connection_get_id (connection));
 				return FALSE;
 			}
 		}
 	}
 
-	return NM_MODEM_GET_CLASS (self)->check_connection_compatible_with_modem (self, connection, error);
+	if (NM_MODEM_GET_CLASS (self)->check_connection_compatible)
+		return NM_MODEM_GET_CLASS (self)->check_connection_compatible (self, connection);
+	return FALSE;
 }
 
 /*****************************************************************************/
diff --git a/src/devices/wwan/nm-modem.h b/src/devices/wwan/nm-modem.h
index c73745ce..cad9ece4 100644
--- a/src/devices/wwan/nm-modem.h
+++ b/src/devices/wwan/nm-modem.h
@@ -121,9 +121,8 @@ typedef struct {
 	                                            const char **user,
 	                                            const char **pass);
 
-	gboolean (*check_connection_compatible_with_modem) (NMModem *modem,
-	                                                    NMConnection *connection,
-	                                                    GError **error);
+	gboolean (*check_connection_compatible)    (NMModem *modem,
+	                                            NMConnection *connection);
 
 	gboolean (*complete_connection)            (NMModem *modem,
 	                                            NMConnection *connection,
@@ -186,9 +185,7 @@ void        nm_modem_get_capabilities (NMModem *self,
                                        NMDeviceModemCapabilities *modem_caps,
                                        NMDeviceModemCapabilities *current_caps);
 
-gboolean nm_modem_check_connection_compatible (NMModem *self,
-                                               NMConnection *connection,
-                                               GError **error);
+gboolean nm_modem_check_connection_compatible (NMModem *self, NMConnection *connection);
 
 gboolean nm_modem_complete_connection (NMModem *self,
                                        NMConnection *connection,
@@ -276,7 +273,7 @@ void nm_modem_emit_ip6_config_result (NMModem *self,
                                       NMIP6Config *config,
                                       GError *error);
 
-const char *nm_modem_ip_type_to_string (NMModemIPType ip_type);
+const gchar *nm_modem_ip_type_to_string (NMModemIPType ip_type);
 
 guint32 nm_modem_get_configured_mtu (NMDevice *self, NMDeviceMtuSource *out_source);