diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-07-14 14:13:48 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-07-14 14:13:48 -0400 |
commit | 333140b57fa7867bc92e5ee879b6ac4ef5e1d867 (patch) | |
tree | a498d195bff090371993ec2bf63505f768434540 | |
parent | 0493684ed2397e111574f343534d8e4ec440dfa5 (diff) |
[Bluetooth] Track status of Simple Pairing mode
The Simple Pairing feature is optional and needs to be enabled by the
host stack first. The Linux kernel relies on the Bluetooth daemon to
either enable or disable it, but at any time it needs to know the
current state of the Simple Pairing mode. So track any changes made
by external entities and store the current mode in the HCI device
structure.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r-- | include/net/bluetooth/hci.h | 11 | ||||
-rw-r--r-- | include/net/bluetooth/hci_core.h | 1 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 37 |
3 files changed, 49 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 79629ff40e3e..6d0c04a81fc7 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -514,6 +514,17 @@ struct hci_cp_host_buffer_size { | |||
514 | __le16 sco_max_pkt; | 514 | __le16 sco_max_pkt; |
515 | } __attribute__ ((packed)); | 515 | } __attribute__ ((packed)); |
516 | 516 | ||
517 | #define HCI_OP_READ_SSP_MODE 0x0c55 | ||
518 | struct hci_rp_read_ssp_mode { | ||
519 | __u8 status; | ||
520 | __u8 mode; | ||
521 | } __attribute__ ((packed)); | ||
522 | |||
523 | #define HCI_OP_WRITE_SSP_MODE 0x0c56 | ||
524 | struct hci_cp_write_ssp_mode { | ||
525 | __u8 mode; | ||
526 | } __attribute__ ((packed)); | ||
527 | |||
517 | #define HCI_OP_READ_LOCAL_VERSION 0x1001 | 528 | #define HCI_OP_READ_LOCAL_VERSION 0x1001 |
518 | struct hci_rp_read_local_version { | 529 | struct hci_rp_read_local_version { |
519 | __u8 status; | 530 | __u8 status; |
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 6424d63e3395..b85754e29a78 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -75,6 +75,7 @@ struct hci_dev { | |||
75 | __u8 dev_class[3]; | 75 | __u8 dev_class[3]; |
76 | __u8 features[8]; | 76 | __u8 features[8]; |
77 | __u8 commands[64]; | 77 | __u8 commands[64]; |
78 | __u8 ssp_mode; | ||
78 | __u8 hci_ver; | 79 | __u8 hci_ver; |
79 | __u16 hci_rev; | 80 | __u16 hci_rev; |
80 | __u16 manufacturer; | 81 | __u16 manufacturer; |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 7c9ac01cd8f9..6077a651aac6 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -391,6 +391,35 @@ static void hci_cc_host_buffer_size(struct hci_dev *hdev, struct sk_buff *skb) | |||
391 | hci_req_complete(hdev, status); | 391 | hci_req_complete(hdev, status); |
392 | } | 392 | } |
393 | 393 | ||
394 | static void hci_cc_read_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) | ||
395 | { | ||
396 | struct hci_rp_read_ssp_mode *rp = (void *) skb->data; | ||
397 | |||
398 | BT_DBG("%s status 0x%x", hdev->name, rp->status); | ||
399 | |||
400 | if (rp->status) | ||
401 | return; | ||
402 | |||
403 | hdev->ssp_mode = rp->mode; | ||
404 | } | ||
405 | |||
406 | static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) | ||
407 | { | ||
408 | __u8 status = *((__u8 *) skb->data); | ||
409 | void *sent; | ||
410 | |||
411 | BT_DBG("%s status 0x%x", hdev->name, status); | ||
412 | |||
413 | if (status) | ||
414 | return; | ||
415 | |||
416 | sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_MODE); | ||
417 | if (!sent) | ||
418 | return; | ||
419 | |||
420 | hdev->ssp_mode = *((__u8 *) sent); | ||
421 | } | ||
422 | |||
394 | static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb) | 423 | static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb) |
395 | { | 424 | { |
396 | struct hci_rp_read_local_version *rp = (void *) skb->data; | 425 | struct hci_rp_read_local_version *rp = (void *) skb->data; |
@@ -1084,6 +1113,14 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk | |||
1084 | hci_cc_host_buffer_size(hdev, skb); | 1113 | hci_cc_host_buffer_size(hdev, skb); |
1085 | break; | 1114 | break; |
1086 | 1115 | ||
1116 | case HCI_OP_READ_SSP_MODE: | ||
1117 | hci_cc_read_ssp_mode(hdev, skb); | ||
1118 | break; | ||
1119 | |||
1120 | case HCI_OP_WRITE_SSP_MODE: | ||
1121 | hci_cc_write_ssp_mode(hdev, skb); | ||
1122 | break; | ||
1123 | |||
1087 | case HCI_OP_READ_LOCAL_VERSION: | 1124 | case HCI_OP_READ_LOCAL_VERSION: |
1088 | hci_cc_read_local_version(hdev, skb); | 1125 | hci_cc_read_local_version(hdev, skb); |
1089 | break; | 1126 | break; |