Commit 45bb4bf0 authored by Marcel Holtmann's avatar Marcel Holtmann Committed by David S. Miller

[Bluetooth]: Workaround for inquiry results with RSSI and page scan mode

This patch implements a workaround for buggy Bluetooth 1.2 devices from
Silicon Wave. Their inquiry results with RSSI contain the page scan mode
field. This field was removed in the final Bluetooth 1.2 specification.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4aa769b9
...@@ -453,6 +453,15 @@ struct inquiry_info_with_rssi { ...@@ -453,6 +453,15 @@ struct inquiry_info_with_rssi {
__u16 clock_offset; __u16 clock_offset;
__s8 rssi; __s8 rssi;
} __attribute__ ((packed)); } __attribute__ ((packed));
struct inquiry_info_with_rssi_and_pscan_mode {
bdaddr_t bdaddr;
__u8 pscan_rep_mode;
__u8 pscan_period_mode;
__u8 pscan_mode;
__u8 dev_class[3];
__u16 clock_offset;
__s8 rssi;
} __attribute__ ((packed));
#define HCI_EV_CONN_COMPLETE 0x03 #define HCI_EV_CONN_COMPLETE 0x03
struct hci_ev_conn_complete { struct hci_ev_conn_complete {
......
...@@ -484,14 +484,18 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff ...@@ -484,14 +484,18 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
/* Inquiry Result */ /* Inquiry Result */
static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
{ {
struct inquiry_data data;
struct inquiry_info *info = (struct inquiry_info *) (skb->data + 1); struct inquiry_info *info = (struct inquiry_info *) (skb->data + 1);
int num_rsp = *((__u8 *) skb->data); int num_rsp = *((__u8 *) skb->data);
BT_DBG("%s num_rsp %d", hdev->name, num_rsp); BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
if (!num_rsp)
return;
hci_dev_lock(hdev); hci_dev_lock(hdev);
for (; num_rsp; num_rsp--) { for (; num_rsp; num_rsp--) {
struct inquiry_data data;
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;
...@@ -502,30 +506,55 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * ...@@ -502,30 +506,55 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
info++; info++;
hci_inquiry_cache_update(hdev, &data); hci_inquiry_cache_update(hdev, &data);
} }
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
} }
/* Inquiry Result With RSSI */ /* Inquiry Result With RSSI */
static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct sk_buff *skb)
{ {
struct inquiry_info_with_rssi *info = (struct inquiry_info_with_rssi *) (skb->data + 1); struct inquiry_data data;
int num_rsp = *((__u8 *) skb->data); int num_rsp = *((__u8 *) skb->data);
BT_DBG("%s num_rsp %d", hdev->name, num_rsp); BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
if (!num_rsp)
return;
hci_dev_lock(hdev); hci_dev_lock(hdev);
for (; num_rsp; num_rsp--) {
struct inquiry_data data; if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) {
bacpy(&data.bdaddr, &info->bdaddr); struct inquiry_info_with_rssi_and_pscan_mode *info =
data.pscan_rep_mode = info->pscan_rep_mode; (struct inquiry_info_with_rssi_and_pscan_mode *) (skb->data + 1);
data.pscan_period_mode = info->pscan_period_mode;
data.pscan_mode = 0x00; for (; num_rsp; num_rsp--) {
memcpy(data.dev_class, info->dev_class, 3); bacpy(&data.bdaddr, &info->bdaddr);
data.clock_offset = info->clock_offset; data.pscan_rep_mode = info->pscan_rep_mode;
data.rssi = info->rssi; data.pscan_period_mode = info->pscan_period_mode;
info++; data.pscan_mode = info->pscan_mode;
hci_inquiry_cache_update(hdev, &data); memcpy(data.dev_class, info->dev_class, 3);
data.clock_offset = info->clock_offset;
data.rssi = info->rssi;
info++;
hci_inquiry_cache_update(hdev, &data);
}
} else {
struct inquiry_info_with_rssi *info =
(struct inquiry_info_with_rssi *) (skb->data + 1);
for (; num_rsp; num_rsp--) {
bacpy(&data.bdaddr, &info->bdaddr);
data.pscan_rep_mode = info->pscan_rep_mode;
data.pscan_period_mode = info->pscan_period_mode;
data.pscan_mode = 0x00;
memcpy(data.dev_class, info->dev_class, 3);
data.clock_offset = info->clock_offset;
data.rssi = info->rssi;
info++;
hci_inquiry_cache_update(hdev, &data);
}
} }
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
} }
......
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