aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/bluetooth/hci_core.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/bluetooth/hci_core.h')
-rw-r--r--include/net/bluetooth/hci_core.h78
1 files changed, 61 insertions, 17 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 37ff1aef0845..3c7827005c25 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -75,6 +75,10 @@ struct discovery_state {
75 u32 last_adv_flags; 75 u32 last_adv_flags;
76 u8 last_adv_data[HCI_MAX_AD_LENGTH]; 76 u8 last_adv_data[HCI_MAX_AD_LENGTH];
77 u8 last_adv_data_len; 77 u8 last_adv_data_len;
78 bool report_invalid_rssi;
79 s8 rssi;
80 u16 uuid_count;
81 u8 (*uuids)[16];
78}; 82};
79 83
80struct hci_conn_hash { 84struct hci_conn_hash {
@@ -108,6 +112,7 @@ struct smp_csrk {
108 112
109struct smp_ltk { 113struct smp_ltk {
110 struct list_head list; 114 struct list_head list;
115 struct rcu_head rcu;
111 bdaddr_t bdaddr; 116 bdaddr_t bdaddr;
112 u8 bdaddr_type; 117 u8 bdaddr_type;
113 u8 authenticated; 118 u8 authenticated;
@@ -120,6 +125,7 @@ struct smp_ltk {
120 125
121struct smp_irk { 126struct smp_irk {
122 struct list_head list; 127 struct list_head list;
128 struct rcu_head rcu;
123 bdaddr_t rpa; 129 bdaddr_t rpa;
124 bdaddr_t bdaddr; 130 bdaddr_t bdaddr;
125 u8 addr_type; 131 u8 addr_type;
@@ -128,6 +134,7 @@ struct smp_irk {
128 134
129struct link_key { 135struct link_key {
130 struct list_head list; 136 struct list_head list;
137 struct rcu_head rcu;
131 bdaddr_t bdaddr; 138 bdaddr_t bdaddr;
132 u8 type; 139 u8 type;
133 u8 val[HCI_LINK_KEY_SIZE]; 140 u8 val[HCI_LINK_KEY_SIZE];
@@ -137,10 +144,11 @@ struct link_key {
137struct oob_data { 144struct oob_data {
138 struct list_head list; 145 struct list_head list;
139 bdaddr_t bdaddr; 146 bdaddr_t bdaddr;
147 u8 bdaddr_type;
140 u8 hash192[16]; 148 u8 hash192[16];
141 u8 randomizer192[16]; 149 u8 rand192[16];
142 u8 hash256[16]; 150 u8 hash256[16];
143 u8 randomizer256[16]; 151 u8 rand256[16];
144}; 152};
145 153
146#define HCI_MAX_SHORT_NAME_LENGTH 10 154#define HCI_MAX_SHORT_NAME_LENGTH 10
@@ -303,6 +311,7 @@ struct hci_dev {
303 __u32 req_result; 311 __u32 req_result;
304 312
305 void *smp_data; 313 void *smp_data;
314 void *smp_bredr_data;
306 315
307 struct discovery_state discovery; 316 struct discovery_state discovery;
308 struct hci_conn_hash conn_hash; 317 struct hci_conn_hash conn_hash;
@@ -398,6 +407,8 @@ struct hci_conn {
398 __u16 le_conn_interval; 407 __u16 le_conn_interval;
399 __u16 le_conn_latency; 408 __u16 le_conn_latency;
400 __u16 le_supv_timeout; 409 __u16 le_supv_timeout;
410 __u8 le_adv_data[HCI_MAX_AD_LENGTH];
411 __u8 le_adv_data_len;
401 __s8 rssi; 412 __s8 rssi;
402 __s8 tx_power; 413 __s8 tx_power;
403 __s8 max_tx_power; 414 __s8 max_tx_power;
@@ -496,6 +507,17 @@ static inline void discovery_init(struct hci_dev *hdev)
496 INIT_LIST_HEAD(&hdev->discovery.all); 507 INIT_LIST_HEAD(&hdev->discovery.all);
497 INIT_LIST_HEAD(&hdev->discovery.unknown); 508 INIT_LIST_HEAD(&hdev->discovery.unknown);
498 INIT_LIST_HEAD(&hdev->discovery.resolve); 509 INIT_LIST_HEAD(&hdev->discovery.resolve);
510 hdev->discovery.report_invalid_rssi = true;
511 hdev->discovery.rssi = HCI_RSSI_INVALID;
512}
513
514static inline void hci_discovery_filter_clear(struct hci_dev *hdev)
515{
516 hdev->discovery.report_invalid_rssi = true;
517 hdev->discovery.rssi = HCI_RSSI_INVALID;
518 hdev->discovery.uuid_count = 0;
519 kfree(hdev->discovery.uuids);
520 hdev->discovery.uuids = NULL;
499} 521}
500 522
501bool hci_discovery_active(struct hci_dev *hdev); 523bool hci_discovery_active(struct hci_dev *hdev);
@@ -553,6 +575,8 @@ enum {
553 HCI_CONN_STK_ENCRYPT, 575 HCI_CONN_STK_ENCRYPT,
554 HCI_CONN_AUTH_INITIATOR, 576 HCI_CONN_AUTH_INITIATOR,
555 HCI_CONN_DROP, 577 HCI_CONN_DROP,
578 HCI_CONN_PARAM_REMOVAL_PEND,
579 HCI_CONN_NEW_LINK_KEY,
556}; 580};
557 581
558static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) 582static inline bool hci_conn_ssp_enabled(struct hci_conn *conn)
@@ -643,6 +667,26 @@ static inline unsigned int hci_conn_count(struct hci_dev *hdev)
643 return c->acl_num + c->amp_num + c->sco_num + c->le_num; 667 return c->acl_num + c->amp_num + c->sco_num + c->le_num;
644} 668}
645 669
670static inline __u8 hci_conn_lookup_type(struct hci_dev *hdev, __u16 handle)
671{
672 struct hci_conn_hash *h = &hdev->conn_hash;
673 struct hci_conn *c;
674 __u8 type = INVALID_LINK;
675
676 rcu_read_lock();
677
678 list_for_each_entry_rcu(c, &h->list, list) {
679 if (c->handle == handle) {
680 type = c->type;
681 break;
682 }
683 }
684
685 rcu_read_unlock();
686
687 return type;
688}
689
646static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, 690static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,
647 __u16 handle) 691 __u16 handle)
648{ 692{
@@ -853,6 +897,7 @@ int hci_register_dev(struct hci_dev *hdev);
853void hci_unregister_dev(struct hci_dev *hdev); 897void hci_unregister_dev(struct hci_dev *hdev);
854int hci_suspend_dev(struct hci_dev *hdev); 898int hci_suspend_dev(struct hci_dev *hdev);
855int hci_resume_dev(struct hci_dev *hdev); 899int hci_resume_dev(struct hci_dev *hdev);
900int hci_reset_dev(struct hci_dev *hdev);
856int hci_dev_open(__u16 dev); 901int hci_dev_open(__u16 dev);
857int hci_dev_close(__u16 dev); 902int hci_dev_close(__u16 dev);
858int hci_dev_reset(__u16 dev); 903int hci_dev_reset(__u16 dev);
@@ -894,13 +939,11 @@ struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
894struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, 939struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
895 bdaddr_t *bdaddr, u8 *val, u8 type, 940 bdaddr_t *bdaddr, u8 *val, u8 type,
896 u8 pin_len, bool *persistent); 941 u8 pin_len, bool *persistent);
897struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, __le64 rand,
898 u8 role);
899struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, 942struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
900 u8 addr_type, u8 type, u8 authenticated, 943 u8 addr_type, u8 type, u8 authenticated,
901 u8 tk[16], u8 enc_size, __le16 ediv, __le64 rand); 944 u8 tk[16], u8 enc_size, __le16 ediv, __le64 rand);
902struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr, 945struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
903 u8 addr_type, u8 role); 946 u8 addr_type, u8 role);
904int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type); 947int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type);
905void hci_smp_ltks_clear(struct hci_dev *hdev); 948void hci_smp_ltks_clear(struct hci_dev *hdev);
906int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); 949int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
@@ -915,13 +958,12 @@ void hci_smp_irks_clear(struct hci_dev *hdev);
915 958
916void hci_remote_oob_data_clear(struct hci_dev *hdev); 959void hci_remote_oob_data_clear(struct hci_dev *hdev);
917struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev, 960struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
918 bdaddr_t *bdaddr); 961 bdaddr_t *bdaddr, u8 bdaddr_type);
919int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, 962int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr,
920 u8 *hash, u8 *randomizer); 963 u8 bdaddr_type, u8 *hash192, u8 *rand192,
921int hci_add_remote_oob_ext_data(struct hci_dev *hdev, bdaddr_t *bdaddr, 964 u8 *hash256, u8 *rand256);
922 u8 *hash192, u8 *randomizer192, 965int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr,
923 u8 *hash256, u8 *randomizer256); 966 u8 bdaddr_type);
924int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
925 967
926void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); 968void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
927 969
@@ -972,6 +1014,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
972 1014
973#define hdev_is_powered(hdev) (test_bit(HCI_UP, &hdev->flags) && \ 1015#define hdev_is_powered(hdev) (test_bit(HCI_UP, &hdev->flags) && \
974 !test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) 1016 !test_bit(HCI_AUTO_OFF, &hdev->dev_flags))
1017#define bredr_sc_enabled(dev) ((lmp_sc_capable(dev) || \
1018 test_bit(HCI_FORCE_SC, &(dev)->dbg_flags)) && \
1019 test_bit(HCI_SC_ENABLED, &(dev)->dev_flags))
975 1020
976/* ----- HCI protocols ----- */ 1021/* ----- HCI protocols ----- */
977#define HCI_PROTO_DEFER 0x01 1022#define HCI_PROTO_DEFER 0x01
@@ -1310,9 +1355,8 @@ int mgmt_update_adv_data(struct hci_dev *hdev);
1310void mgmt_discoverable_timeout(struct hci_dev *hdev); 1355void mgmt_discoverable_timeout(struct hci_dev *hdev);
1311void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, 1356void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
1312 bool persistent); 1357 bool persistent);
1313void mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 1358void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn,
1314 u8 addr_type, u32 flags, u8 *name, u8 name_len, 1359 u32 flags, u8 *name, u8 name_len);
1315 u8 *dev_class);
1316void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, 1360void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
1317 u8 link_type, u8 addr_type, u8 reason, 1361 u8 link_type, u8 addr_type, u8 reason,
1318 bool mgmt_connected); 1362 bool mgmt_connected);
@@ -1349,8 +1393,8 @@ void mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class,
1349 u8 status); 1393 u8 status);
1350void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); 1394void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status);
1351void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192, 1395void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192,
1352 u8 *randomizer192, u8 *hash256, 1396 u8 *rand192, u8 *hash256, u8 *rand256,
1353 u8 *randomizer256, u8 status); 1397 u8 status);
1354void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 1398void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
1355 u8 addr_type, u8 *dev_class, s8 rssi, u32 flags, 1399 u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
1356 u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len); 1400 u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len);