Commit 3175405b authored by Johan Hedberg's avatar Johan Hedberg

Bluetooth: Return updated name state with hci_inquiry_cache_update

If user-space has already confirmed the name for a remote device we
shouldn't request confirmation again. The simplest way to do this is to
return the name state from hci_inquiry_cache_update (if it is anything
else than unknown then we do not need confirmation from user-space).
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 561aafbc
...@@ -384,7 +384,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, ...@@ -384,7 +384,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev,
bdaddr_t *bdaddr); bdaddr_t *bdaddr);
struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev,
bdaddr_t *bdaddr); bdaddr_t *bdaddr);
void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
bool name_known); bool name_known);
/* ----- HCI Connections ----- */ /* ----- HCI Connections ----- */
......
...@@ -400,7 +400,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, ...@@ -400,7 +400,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev,
return NULL; return NULL;
} }
void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
bool name_known) bool name_known)
{ {
struct inquiry_cache *cache = &hdev->inq_cache; struct inquiry_cache *cache = &hdev->inq_cache;
...@@ -415,7 +415,7 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, ...@@ -415,7 +415,7 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
/* Entry not in the cache. Add new one. */ /* Entry not in the cache. Add new one. */
ie = kzalloc(sizeof(struct inquiry_entry), GFP_ATOMIC); ie = kzalloc(sizeof(struct inquiry_entry), GFP_ATOMIC);
if (!ie) if (!ie)
return; return false;
list_add(&ie->all, &cache->all); list_add(&ie->all, &cache->all);
...@@ -436,6 +436,11 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, ...@@ -436,6 +436,11 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
memcpy(&ie->data, data, sizeof(*data)); memcpy(&ie->data, data, sizeof(*data));
ie->timestamp = jiffies; ie->timestamp = jiffies;
cache->timestamp = jiffies; cache->timestamp = jiffies;
if (ie->name_state == NAME_NOT_KNOWN)
return false;
return true;
} }
static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf) static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf)
......
...@@ -1525,6 +1525,8 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * ...@@ -1525,6 +1525,8 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
hci_dev_lock(hdev); hci_dev_lock(hdev);
for (; num_rsp; num_rsp--, info++) { for (; num_rsp; num_rsp--, info++) {
bool name_known;
bacpy(&data.bdaddr, &info->bdaddr); bacpy(&data.bdaddr, &info->bdaddr);
data.pscan_rep_mode = info->pscan_rep_mode; data.pscan_rep_mode = info->pscan_rep_mode;
data.pscan_period_mode = info->pscan_period_mode; data.pscan_period_mode = info->pscan_period_mode;
...@@ -1533,9 +1535,10 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * ...@@ -1533,9 +1535,10 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
data.clock_offset = info->clock_offset; data.clock_offset = info->clock_offset;
data.rssi = 0x00; data.rssi = 0x00;
data.ssp_mode = 0x00; data.ssp_mode = 0x00;
hci_inquiry_cache_update(hdev, &data, false);
name_known = hci_inquiry_cache_update(hdev, &data, false);
mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
info->dev_class, 0, 1, NULL); info->dev_class, 0, !name_known, NULL);
} }
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
...@@ -2551,6 +2554,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct ...@@ -2551,6 +2554,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
{ {
struct inquiry_data data; struct inquiry_data data;
int num_rsp = *((__u8 *) skb->data); int num_rsp = *((__u8 *) skb->data);
bool name_known;
BT_DBG("%s num_rsp %d", hdev->name, num_rsp); BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
...@@ -2572,10 +2576,12 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct ...@@ -2572,10 +2576,12 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
data.clock_offset = info->clock_offset; data.clock_offset = info->clock_offset;
data.rssi = info->rssi; data.rssi = info->rssi;
data.ssp_mode = 0x00; data.ssp_mode = 0x00;
hci_inquiry_cache_update(hdev, &data, false);
name_known = hci_inquiry_cache_update(hdev, &data,
false);
mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
info->dev_class, info->rssi, info->dev_class, info->rssi,
1, NULL); !name_known, NULL);
} }
} else { } else {
struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); struct inquiry_info_with_rssi *info = (void *) (skb->data + 1);
...@@ -2589,10 +2595,11 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct ...@@ -2589,10 +2595,11 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
data.clock_offset = info->clock_offset; data.clock_offset = info->clock_offset;
data.rssi = info->rssi; data.rssi = info->rssi;
data.ssp_mode = 0x00; data.ssp_mode = 0x00;
hci_inquiry_cache_update(hdev, &data, false); name_known = hci_inquiry_cache_update(hdev, &data,
false);
mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
info->dev_class, info->rssi, info->dev_class, info->rssi,
1, NULL); !name_known, NULL);
} }
} }
...@@ -2766,7 +2773,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct ...@@ -2766,7 +2773,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct
else else
name_known = true; name_known = true;
hci_inquiry_cache_update(hdev, &data, name_known); name_known = hci_inquiry_cache_update(hdev, &data, name_known);
mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
info->dev_class, info->rssi, info->dev_class, info->rssi,
!name_known, info->data); !name_known, info->data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment