aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-01-04 06:31:59 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-13 10:01:19 -0500
commit561aafbcb2e3f8fee11d3781f866c7b4c4f93a28 (patch)
tree98fc5da4793bd16810a47450afe28e7304bdea8c /net/bluetooth/hci_core.c
parent32748db00228b67a5315a91e1a6dd2c54864d87b (diff)
Bluetooth: Add initial mgmt_confirm_name support
This patch adds initial support for mgmt_confirm_name. It adds the necessary tracking of the name state by extending the inquiry cache. The actual name resolving operation (to be done once inquiry is finished) is not yet part of this patch. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r--net/bluetooth/hci_core.c58
1 files changed, 47 insertions, 11 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index feeea4df2529..fc09a3cbe20c 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -357,12 +357,16 @@ struct hci_dev *hci_dev_get(int index)
357/* ---- Inquiry support ---- */ 357/* ---- Inquiry support ---- */
358static void inquiry_cache_flush(struct hci_dev *hdev) 358static void inquiry_cache_flush(struct hci_dev *hdev)
359{ 359{
360 struct inquiry_cache *cache = &hdev->inq_cache;
360 struct inquiry_entry *p, *n; 361 struct inquiry_entry *p, *n;
361 362
362 list_for_each_entry_safe(p, n, &hdev->inq_cache.list, list) { 363 list_for_each_entry_safe(p, n, &cache->all, all) {
363 list_del(&p->list); 364 list_del(&p->all);
364 kfree(p); 365 kfree(p);
365 } 366 }
367
368 INIT_LIST_HEAD(&cache->unknown);
369 INIT_LIST_HEAD(&cache->resolve);
366} 370}
367 371
368struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr) 372struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr)
@@ -372,7 +376,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *b
372 376
373 BT_DBG("cache %p, %s", cache, batostr(bdaddr)); 377 BT_DBG("cache %p, %s", cache, batostr(bdaddr));
374 378
375 list_for_each_entry(e, &cache->list, list) { 379 list_for_each_entry(e, &cache->all, all) {
376 if (!bacmp(&e->data.bdaddr, bdaddr)) 380 if (!bacmp(&e->data.bdaddr, bdaddr))
377 return e; 381 return e;
378 } 382 }
@@ -380,7 +384,24 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *b
380 return NULL; 384 return NULL;
381} 385}
382 386
383void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data) 387struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev,
388 bdaddr_t *bdaddr)
389{
390 struct inquiry_cache *cache = &hdev->inq_cache;
391 struct inquiry_entry *e;
392
393 BT_DBG("cache %p, %s", cache, batostr(bdaddr));
394
395 list_for_each_entry(e, &cache->unknown, list) {
396 if (!bacmp(&e->data.bdaddr, bdaddr))
397 return e;
398 }
399
400 return NULL;
401}
402
403void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
404 bool name_known)
384{ 405{
385 struct inquiry_cache *cache = &hdev->inq_cache; 406 struct inquiry_cache *cache = &hdev->inq_cache;
386 struct inquiry_entry *ie; 407 struct inquiry_entry *ie;
@@ -388,13 +409,28 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data)
388 BT_DBG("cache %p, %s", cache, batostr(&data->bdaddr)); 409 BT_DBG("cache %p, %s", cache, batostr(&data->bdaddr));
389 410
390 ie = hci_inquiry_cache_lookup(hdev, &data->bdaddr); 411 ie = hci_inquiry_cache_lookup(hdev, &data->bdaddr);
391 if (!ie) { 412 if (ie)
392 /* Entry not in the cache. Add new one. */ 413 goto update;
393 ie = kzalloc(sizeof(struct inquiry_entry), GFP_ATOMIC); 414
394 if (!ie) 415 /* Entry not in the cache. Add new one. */
395 return; 416 ie = kzalloc(sizeof(struct inquiry_entry), GFP_ATOMIC);
417 if (!ie)
418 return;
419
420 list_add(&ie->all, &cache->all);
421
422 if (name_known) {
423 ie->name_state = NAME_KNOWN;
424 } else {
425 ie->name_state = NAME_NOT_KNOWN;
426 list_add(&ie->list, &cache->unknown);
427 }
396 428
397 list_add(&ie->list, &cache->list); 429update:
430 if (name_known && ie->name_state != NAME_KNOWN &&
431 ie->name_state != NAME_PENDING) {
432 ie->name_state = NAME_KNOWN;
433 list_del(&ie->list);
398 } 434 }
399 435
400 memcpy(&ie->data, data, sizeof(*data)); 436 memcpy(&ie->data, data, sizeof(*data));
@@ -409,7 +445,7 @@ static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf)
409 struct inquiry_entry *e; 445 struct inquiry_entry *e;
410 int copied = 0; 446 int copied = 0;
411 447
412 list_for_each_entry(e, &cache->list, list) { 448 list_for_each_entry(e, &cache->all, all) {
413 struct inquiry_data *data = &e->data; 449 struct inquiry_data *data = &e->data;
414 450
415 if (copied >= num) 451 if (copied >= num)