]> Pileus Git - ~andy/linux/commitdiff
Bluetooth: mgmt: Add local name information to read_info reply
authorJohan Hedberg <johan.hedberg@nokia.com>
Wed, 16 Mar 2011 12:29:36 +0000 (14:29 +0200)
committerGustavo F. Padovan <padovan@profusion.mobi>
Thu, 31 Mar 2011 17:22:54 +0000 (14:22 -0300)
This patch adds the name of the adapter to the reply of the read_info
management command.

The management messages reserve 249 bytes for the name instead of 248
(like in the HCI spec) so that there is always a guarantee that it is
nul-terminated. That way it can safely be passed onto string
manipulation functions.

Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
include/net/bluetooth/mgmt.h
net/bluetooth/mgmt.c

index 5fabfa886b3eefc58bfe5fefc82350a178753c4f..7d0749bed09083811c6012688e88ef2586524568 100644 (file)
@@ -41,6 +41,10 @@ struct mgmt_rp_read_index_list {
        __le16 index[0];
 } __packed;
 
+/* Reserve one extra byte for names in management messages so that they
+ * are always guaranteed to be nul-terminated */
+#define MGMT_MAX_NAME_LENGTH           (HCI_MAX_NAME_LENGTH + 1)
+
 #define MGMT_OP_READ_INFO              0x0004
 struct mgmt_rp_read_info {
        __u8 type;
@@ -55,6 +59,7 @@ struct mgmt_rp_read_info {
        __u16 manufacturer;
        __u8 hci_ver;
        __u16 hci_rev;
+       __u8 name[MGMT_MAX_NAME_LENGTH];
 } __packed;
 
 struct mgmt_mode {
index 0054c74e27b7fcd4971477408721b003e773f37a..ffdb2f4e8635dbc04b6330a279f58087f3515318 100644 (file)
@@ -183,6 +183,8 @@ static int read_controller_info(struct sock *sk, u16 index)
 
        set_bit(HCI_MGMT, &hdev->flags);
 
+       memset(&rp, 0, sizeof(rp));
+
        rp.type = hdev->dev_type;
 
        rp.powered = test_bit(HCI_UP, &hdev->flags);
@@ -204,6 +206,8 @@ static int read_controller_info(struct sock *sk, u16 index)
        rp.hci_ver = hdev->hci_ver;
        put_unaligned_le16(hdev->hci_rev, &rp.hci_rev);
 
+       memcpy(rp.name, hdev->dev_name, sizeof(hdev->dev_name));
+
        hci_dev_unlock_bh(hdev);
        hci_dev_put(hdev);