Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 352342
b: refs/heads/master
c: 213202e
h: refs/heads/master
v: v3
  • Loading branch information
Johan Hedberg authored and Gustavo Padovan committed Feb 1, 2013
1 parent 8cb7b61 commit 6c2aa60
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 892bbc5794daac57bff09c584821ed271fa18046
refs/heads/master: 213202edc9b5ae60eef2a915b83b4aa19b1c3617
78 changes: 43 additions & 35 deletions trunk/net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,51 @@ static u32 get_current_settings(struct hci_dev *hdev)

#define PNP_INFO_SVCLASS_ID 0x1200

static u8 *create_uuid16_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len)
{
u8 *ptr = data, *uuids_start = NULL;
struct bt_uuid *uuid;

if (len < 4)
return ptr;

list_for_each_entry(uuid, &hdev->uuids, list) {
u16 uuid16;

if (uuid->size != 16)
continue;

uuid16 = get_unaligned_le16(&uuid->uuid[12]);
if (uuid16 < 0x1100)
continue;

if (uuid16 == PNP_INFO_SVCLASS_ID)
continue;

if (!uuids_start) {
uuids_start = ptr;
uuids_start[0] = 1;
uuids_start[1] = EIR_UUID16_ALL;
ptr += 2;
}

/* Stop if not enough space to put next UUID */
if ((ptr - data) + sizeof(u16) > len) {
uuids_start[1] = EIR_UUID16_SOME;
break;
}

*ptr++ = (uuid16 & 0x00ff);
*ptr++ = (uuid16 & 0xff00) >> 8;
uuids_start[0] += sizeof(uuid16);
}

return ptr;
}

static void create_eir(struct hci_dev *hdev, u8 *data)
{
u8 *ptr = data;
u8 *uuids_start;
struct bt_uuid *uuid;
size_t name_len;

name_len = strlen(hdev->dev_name);
Expand Down Expand Up @@ -480,39 +520,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
ptr += 10;
}

uuids_start = NULL;

/* Group all UUID16 types */
list_for_each_entry(uuid, &hdev->uuids, list) {
u16 uuid16;

if (uuid->size != 16)
continue;

uuid16 = get_unaligned_le16(&uuid->uuid[12]);
if (uuid16 < 0x1100)
continue;

if (uuid16 == PNP_INFO_SVCLASS_ID)
continue;

if (!uuids_start) {
uuids_start = ptr;
uuids_start[0] = 1;
uuids_start[1] = EIR_UUID16_ALL;
ptr += 2;
}

/* Stop if not enough space to put next UUID */
if ((ptr - data) + 2 + sizeof(u16) > HCI_MAX_EIR_LENGTH) {
uuids_start[1] = EIR_UUID16_SOME;
break;
}

*ptr++ = (uuid16 & 0x00ff);
*ptr++ = (uuid16 & 0xff00) >> 8;
uuids_start[0] += sizeof(uuid16);
}
ptr = create_uuid16_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data));
}

static int update_eir(struct hci_dev *hdev)
Expand Down

0 comments on commit 6c2aa60

Please sign in to comment.