summary refs log tree commit diff
path: root/src/devices/nm-device-bridge.c
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/nm-device-bridge.c
parentc240974325c552cad177c457d6ff04e381fd77a3 (diff)
New upstream version 1.12.4 upstream/1.12.4
Diffstat (limited to 'src/devices/nm-device-bridge.c')
-rw-r--r--src/devices/nm-device-bridge.c96
1 files changed, 35 insertions, 61 deletions
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index e79de95c..c81a0253 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -61,63 +61,41 @@ static gboolean
 check_connection_available (NMDevice *device,
                             NMConnection *connection,
                             NMDeviceCheckConAvailableFlags flags,
-                            const char *specific_object,
-                            GError **error)
+                            const char *specific_object)
 {
 	NMSettingBluetooth *s_bt;
 
-	if (!NM_DEVICE_CLASS (nm_device_bridge_parent_class)->check_connection_available (device, connection, flags, specific_object, error))
+	if (!NM_DEVICE_CLASS (nm_device_bridge_parent_class)->check_connection_available (device, connection, flags, specific_object))
 		return FALSE;
 
 	s_bt = _nm_connection_get_setting_bluetooth_for_nap (connection);
 	if (s_bt) {
-		const char *bdaddr;
-
-		if (!nm_bt_vtable_network_server) {
-			nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-			                            "bluetooth plugin not available to activate NAP profile");
-			return FALSE;
-		}
-
-		bdaddr = nm_setting_bluetooth_get_bdaddr (s_bt);
-		if (!nm_bt_vtable_network_server->is_available (nm_bt_vtable_network_server, bdaddr)) {
-			if (bdaddr)
-				nm_utils_error_set (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-				                    "not suitable NAP device \"%s\" available", bdaddr);
-			else
-				nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-				                            "not suitable NAP device available");
-			return FALSE;
-		}
+		return    nm_bt_vtable_network_server
+		       && nm_bt_vtable_network_server->is_available (nm_bt_vtable_network_server,
+		                                                     nm_setting_bluetooth_get_bdaddr (s_bt));
 	}
 
 	return TRUE;
 }
 
 static gboolean
-check_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
+check_connection_compatible (NMDevice *device, NMConnection *connection)
 {
 	NMSettingBridge *s_bridge;
 	const char *mac_address;
 
-	if (!NM_DEVICE_CLASS (nm_device_bridge_parent_class)->check_connection_compatible (device, connection, error))
+	if (!NM_DEVICE_CLASS (nm_device_bridge_parent_class)->check_connection_compatible (device, connection))
 		return FALSE;
 
-	if (   nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME)
-	    && _nm_connection_get_setting_bluetooth_for_nap (connection)) {
-		s_bridge = nm_connection_get_setting_bridge (connection);
-		if (!s_bridge) {
-			nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-			                            "missing bridge setting for bluetooth NAP profile");
-			return FALSE;
-		}
+	s_bridge = nm_connection_get_setting_bridge (connection);
+	if (!s_bridge)
+		return FALSE;
 
-		/* a bluetooth NAP connection is handled by the bridge.
-		 *
-		 * Proceed... */
-	} else {
-		s_bridge = _nm_connection_check_main_setting (connection, NM_SETTING_BRIDGE_SETTING_NAME, error);
-		if (!s_bridge)
+	if (!nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) {
+		if (   nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME)
+		    && _nm_connection_get_setting_bluetooth_for_nap (connection)) {
+			/* a bluetooth NAP connection is handled by the bridge */
+		} else
 			return FALSE;
 	}
 
@@ -126,11 +104,8 @@ check_connection_compatible (NMDevice *device, NMConnection *connection, GError
 		const char *hw_addr;
 
 		hw_addr = nm_device_get_hw_address (device);
-		if (!hw_addr || !nm_utils_hwaddr_matches (hw_addr, -1, mac_address, -1)) {
-			nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
-			                            "mac address mismatches");
+		if (!hw_addr || !nm_utils_hwaddr_matches (hw_addr, -1, mac_address, -1))
 			return FALSE;
-		}
 	}
 
 	return TRUE;
@@ -530,29 +505,28 @@ static void
 nm_device_bridge_class_init (NMDeviceBridgeClass *klass)
 {
 	NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
-	NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
+	NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
+
+	NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_BRIDGE_SETTING_NAME, NM_LINK_TYPE_BRIDGE)
 
 	dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_bridge);
 
-	device_class->connection_type_supported = NM_SETTING_BRIDGE_SETTING_NAME;
-	device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES (NM_LINK_TYPE_BRIDGE);
-
-	device_class->is_master = TRUE;
-	device_class->get_generic_capabilities = get_generic_capabilities;
-	device_class->check_connection_compatible = check_connection_compatible;
-	device_class->check_connection_available = check_connection_available;
-	device_class->complete_connection = complete_connection;
-
-	device_class->update_connection = update_connection;
-	device_class->master_update_slave_connection = master_update_slave_connection;
-
-	device_class->create_and_realize = create_and_realize;
-	device_class->act_stage1_prepare = act_stage1_prepare;
-	device_class->act_stage2_config = act_stage2_config;
-	device_class->deactivate = deactivate;
-	device_class->enslave_slave = enslave_slave;
-	device_class->release_slave = release_slave;
-	device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
+	parent_class->is_master = TRUE;
+	parent_class->get_generic_capabilities = get_generic_capabilities;
+	parent_class->check_connection_compatible = check_connection_compatible;
+	parent_class->check_connection_available = check_connection_available;
+	parent_class->complete_connection = complete_connection;
+
+	parent_class->update_connection = update_connection;
+	parent_class->master_update_slave_connection = master_update_slave_connection;
+
+	parent_class->create_and_realize = create_and_realize;
+	parent_class->act_stage1_prepare = act_stage1_prepare;
+	parent_class->act_stage2_config = act_stage2_config;
+	parent_class->deactivate = deactivate;
+	parent_class->enslave_slave = enslave_slave;
+	parent_class->release_slave = release_slave;
+	parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
 }
 
 /*****************************************************************************/