summary refs log tree commit diff
path: root/src/nm-device-bt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nm-device-bt.c')
-rw-r--r--src/nm-device-bt.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/nm-device-bt.c b/src/nm-device-bt.c
index cadedcf7..366e2683 100644
--- a/src/nm-device-bt.c
+++ b/src/nm-device-bt.c
@@ -63,6 +63,7 @@ typedef struct {
 	guint mm_watch_id;
 	gboolean mm_running;
 
+	guint8 hw_addr[ETH_ALEN];  /* binary representation of bdaddr */
 	char *bdaddr;
 	char *name;
 	guint32 capabilities;
@@ -117,14 +118,6 @@ guint32 nm_device_bt_get_capabilities (NMDeviceBt *self)
 	return NM_DEVICE_BT_GET_PRIVATE (self)->capabilities;
 }
 
-const char *nm_device_bt_get_hw_address (NMDeviceBt *self)
-{
-	g_return_val_if_fail (self != NULL, NULL);
-	g_return_val_if_fail (NM_IS_DEVICE_BT (self), NULL);
-
-	return NM_DEVICE_BT_GET_PRIVATE (self)->bdaddr;
-}
-
 static guint32
 get_connection_bt_type (NMConnection *connection)
 {
@@ -156,16 +149,9 @@ get_best_auto_connection (NMDevice *device,
 
 	for (iter = connections; iter; iter = g_slist_next (iter)) {
 		NMConnection *connection = NM_CONNECTION (iter->data);
-		NMSettingConnection *s_con;
 		guint32 bt_type;
 
-		s_con = nm_connection_get_setting_connection (connection);
-		g_assert (s_con);
-
-		if (!nm_setting_connection_get_autoconnect (s_con))
-			continue;
-
-		if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_BLUETOOTH_SETTING_NAME))
+		if (!nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME))
 			continue;
 
 		bt_type = get_connection_bt_type (connection);
@@ -401,6 +387,15 @@ get_generic_capabilities (NMDevice *dev)
 	return NM_DEVICE_CAP_NM_SUPPORTED;
 }
 
+static const guint8 *
+get_hw_address (NMDevice *device, guint *out_len)
+{
+	NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
+
+	*out_len = sizeof (priv->hw_addr);
+	return priv->hw_addr;
+}
+
 static gboolean
 hwaddr_matches (NMDevice *device,
                 NMConnection *connection,
@@ -1231,6 +1226,8 @@ set_property (GObject *object, guint prop_id,
 	case PROP_HW_ADDRESS:
 		/* Construct only */
 		priv->bdaddr = g_ascii_strup (g_value_get_string (value), -1);
+		if (!nm_utils_hwaddr_aton (priv->bdaddr, ARPHRD_ETHER, &priv->hw_addr))
+			nm_log_err (LOGD_HW, "Failed to convert BT address '%s'", priv->bdaddr);
 		break;
 	case PROP_BT_NAME:
 		/* Construct only */
@@ -1326,6 +1323,7 @@ nm_device_bt_class_init (NMDeviceBtClass *klass)
 	device_class->check_connection_available = check_connection_available;
 	device_class->complete_connection = complete_connection;
 	device_class->hwaddr_matches = hwaddr_matches;
+	device_class->get_hw_address = get_hw_address;
 	device_class->is_available = is_available;
 
 	device_class->state_changed = device_state_changed;