diff options
| -rw-r--r-- | include/net/bluetooth/hci_core.h | 1 | ||||
| -rw-r--r-- | net/bluetooth/mgmt.c | 48 |
2 files changed, 24 insertions, 25 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index bcf8ffe2a843..90cf75afcb02 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
| @@ -86,6 +86,7 @@ struct bdaddr_list { | |||
| 86 | struct bt_uuid { | 86 | struct bt_uuid { |
| 87 | struct list_head list; | 87 | struct list_head list; |
| 88 | u8 uuid[16]; | 88 | u8 uuid[16]; |
| 89 | u8 size; | ||
| 89 | u8 svc_hint; | 90 | u8 svc_hint; |
| 90 | }; | 91 | }; |
| 91 | 92 | ||
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 4fd45a3271e0..8de6d576dc70 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
| @@ -435,28 +435,6 @@ static u32 get_current_settings(struct hci_dev *hdev) | |||
| 435 | 435 | ||
| 436 | #define PNP_INFO_SVCLASS_ID 0x1200 | 436 | #define PNP_INFO_SVCLASS_ID 0x1200 |
| 437 | 437 | ||
| 438 | static u8 bluetooth_base_uuid[] = { | ||
| 439 | 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, | ||
| 440 | 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 441 | }; | ||
| 442 | |||
| 443 | static u16 get_uuid16(u8 *uuid128) | ||
| 444 | { | ||
| 445 | u32 val; | ||
| 446 | int i; | ||
| 447 | |||
| 448 | for (i = 0; i < 12; i++) { | ||
| 449 | if (bluetooth_base_uuid[i] != uuid128[i]) | ||
| 450 | return 0; | ||
| 451 | } | ||
| 452 | |||
| 453 | val = get_unaligned_le32(&uuid128[12]); | ||
| 454 | if (val > 0xffff) | ||
| 455 | return 0; | ||
| 456 | |||
| 457 | return (u16) val; | ||
| 458 | } | ||
| 459 | |||
| 460 | static void create_eir(struct hci_dev *hdev, u8 *data) | 438 | static void create_eir(struct hci_dev *hdev, u8 *data) |
| 461 | { | 439 | { |
| 462 | u8 *ptr = data; | 440 | u8 *ptr = data; |
| @@ -513,10 +491,10 @@ static void create_eir(struct hci_dev *hdev, u8 *data) | |||
| 513 | list_for_each_entry(uuid, &hdev->uuids, list) { | 491 | list_for_each_entry(uuid, &hdev->uuids, list) { |
| 514 | u16 uuid16; | 492 | u16 uuid16; |
| 515 | 493 | ||
| 516 | uuid16 = get_uuid16(uuid->uuid); | 494 | if (uuid->size != 16) |
| 517 | if (uuid16 == 0) | 495 | continue; |
| 518 | return; | ||
| 519 | 496 | ||
| 497 | uuid16 = get_unaligned_le16(&uuid->uuid[12]); | ||
| 520 | if (uuid16 < 0x1100) | 498 | if (uuid16 < 0x1100) |
| 521 | continue; | 499 | continue; |
| 522 | 500 | ||
| @@ -1304,6 +1282,25 @@ unlock: | |||
| 1304 | return err; | 1282 | return err; |
| 1305 | } | 1283 | } |
| 1306 | 1284 | ||
| 1285 | static const u8 bluetooth_base_uuid[] = { | ||
| 1286 | 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, | ||
| 1287 | 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 1288 | }; | ||
| 1289 | |||
| 1290 | static u8 get_uuid_size(const u8 *uuid) | ||
| 1291 | { | ||
| 1292 | u32 val; | ||
| 1293 | |||
| 1294 | if (memcmp(uuid, bluetooth_base_uuid, 12)) | ||
| 1295 | return 128; | ||
| 1296 | |||
| 1297 | val = get_unaligned_le32(&uuid[12]); | ||
| 1298 | if (val > 0xffff) | ||
| 1299 | return 32; | ||
| 1300 | |||
| 1301 | return 16; | ||
| 1302 | } | ||
| 1303 | |||
| 1307 | static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | 1304 | static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) |
| 1308 | { | 1305 | { |
| 1309 | struct mgmt_cp_add_uuid *cp = data; | 1306 | struct mgmt_cp_add_uuid *cp = data; |
| @@ -1329,6 +1326,7 @@ static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
| 1329 | 1326 | ||
| 1330 | memcpy(uuid->uuid, cp->uuid, 16); | 1327 | memcpy(uuid->uuid, cp->uuid, 16); |
| 1331 | uuid->svc_hint = cp->svc_hint; | 1328 | uuid->svc_hint = cp->svc_hint; |
| 1329 | uuid->size = get_uuid_size(cp->uuid); | ||
| 1332 | 1330 | ||
| 1333 | list_add_tail(&uuid->list, &hdev->uuids); | 1331 | list_add_tail(&uuid->list, &hdev->uuids); |
| 1334 | 1332 | ||
