[PATCH 1/2] Bluetooth: Shorten complete name if no short name in set local name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Generate shortened local name if no short name specified
to simplify appending local name to scan rsp data.

Signed-off-by: Michał Narajowski <michal.narajowski@xxxxxxxxxxx>
---
 net/bluetooth/mgmt.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 7360380..cc6e571 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3103,7 +3103,16 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data,
 		goto failed;
 	}
 
-	memcpy(hdev->short_name, cp->short_name, sizeof(hdev->short_name));
+	/* if no short name set and complete name is longer than max
+	 * short name length then shorten complete name
+	 */
+	if (!strlen(cp->short_name) &&
+	    (strlen(cp->name) > HCI_MAX_SHORT_NAME_LENGTH)) {
+		memcpy(hdev->short_name, cp->name, sizeof(hdev->short_name));
+	} else {
+		memcpy(hdev->short_name, cp->short_name,
+		       sizeof(hdev->short_name));
+	}
 
 	if (!hdev_is_powered(hdev)) {
 		memcpy(hdev->dev_name, cp->name, sizeof(hdev->dev_name));
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux