]>
Commit | Line | Data |
---|---|---|
04fafe4e | 1 | /* |
1da177e4 | 2 | BlueZ - Bluetooth protocol stack for Linux |
2d0a0346 | 3 | Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved. |
1da177e4 LT |
4 | |
5 | Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License version 2 as | |
9 | published by the Free Software Foundation; | |
10 | ||
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | |
14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | |
04fafe4e RS |
15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES |
16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
1da177e4 LT |
18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
19 | ||
04fafe4e RS |
20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | |
1da177e4 LT |
22 | SOFTWARE IS DISCLAIMED. |
23 | */ | |
24 | ||
25 | #ifndef __HCI_CORE_H | |
26 | #define __HCI_CORE_H | |
27 | ||
a6b7a407 | 28 | #include <linux/interrupt.h> |
1da177e4 LT |
29 | #include <net/bluetooth/hci.h> |
30 | ||
31 | /* HCI upper protocols */ | |
32 | #define HCI_PROTO_L2CAP 0 | |
33 | #define HCI_PROTO_SCO 1 | |
34 | ||
5e59b791 LAD |
35 | /* HCI priority */ |
36 | #define HCI_PRIO_MAX 7 | |
37 | ||
1da177e4 | 38 | /* HCI Core structures */ |
1da177e4 LT |
39 | struct inquiry_data { |
40 | bdaddr_t bdaddr; | |
41 | __u8 pscan_rep_mode; | |
42 | __u8 pscan_period_mode; | |
43 | __u8 pscan_mode; | |
44 | __u8 dev_class[3]; | |
1ebb9252 | 45 | __le16 clock_offset; |
1da177e4 | 46 | __s8 rssi; |
41a96212 | 47 | __u8 ssp_mode; |
1da177e4 LT |
48 | }; |
49 | ||
50 | struct inquiry_entry { | |
70f23020 | 51 | struct inquiry_entry *next; |
1da177e4 LT |
52 | __u32 timestamp; |
53 | struct inquiry_data data; | |
54 | }; | |
55 | ||
56 | struct inquiry_cache { | |
70f23020 | 57 | spinlock_t lock; |
1da177e4 | 58 | __u32 timestamp; |
70f23020 | 59 | struct inquiry_entry *list; |
1da177e4 LT |
60 | }; |
61 | ||
62 | struct hci_conn_hash { | |
63 | struct list_head list; | |
64 | spinlock_t lock; | |
65 | unsigned int acl_num; | |
66 | unsigned int sco_num; | |
fcd89c09 | 67 | unsigned int le_num; |
1da177e4 LT |
68 | }; |
69 | ||
73d80deb LAD |
70 | struct hci_chan_hash { |
71 | struct list_head list; | |
72 | spinlock_t lock; | |
73 | unsigned int num; | |
74 | }; | |
75 | ||
f0358568 JH |
76 | struct bdaddr_list { |
77 | struct list_head list; | |
78 | bdaddr_t bdaddr; | |
79 | }; | |
2aeb9a1a JH |
80 | |
81 | struct bt_uuid { | |
82 | struct list_head list; | |
83 | u8 uuid[16]; | |
1aff6f09 | 84 | u8 svc_hint; |
2aeb9a1a JH |
85 | }; |
86 | ||
34918cd7 VCG |
87 | struct key_master_id { |
88 | __le16 ediv; | |
89 | u8 rand[8]; | |
90 | } __packed; | |
91 | ||
92 | struct link_key_data { | |
93 | bdaddr_t bdaddr; | |
94 | u8 type; | |
95 | u8 val[16]; | |
96 | u8 pin_len; | |
97 | u8 dlen; | |
98 | u8 data[0]; | |
99 | } __packed; | |
100 | ||
55ed8ca1 JH |
101 | struct link_key { |
102 | struct list_head list; | |
103 | bdaddr_t bdaddr; | |
104 | u8 type; | |
105 | u8 val[16]; | |
106 | u8 pin_len; | |
34918cd7 VCG |
107 | u8 dlen; |
108 | u8 data[0]; | |
55ed8ca1 JH |
109 | }; |
110 | ||
2763eda6 SJ |
111 | struct oob_data { |
112 | struct list_head list; | |
113 | bdaddr_t bdaddr; | |
114 | u8 hash[16]; | |
115 | u8 randomizer[16]; | |
116 | }; | |
117 | ||
76c8686f AG |
118 | struct adv_entry { |
119 | struct list_head list; | |
120 | bdaddr_t bdaddr; | |
121 | u8 bdaddr_type; | |
122 | }; | |
123 | ||
cd4c5391 | 124 | #define NUM_REASSEMBLY 4 |
1da177e4 LT |
125 | struct hci_dev { |
126 | struct list_head list; | |
127 | spinlock_t lock; | |
128 | atomic_t refcnt; | |
129 | ||
130 | char name[8]; | |
131 | unsigned long flags; | |
132 | __u16 id; | |
c13854ce | 133 | __u8 bus; |
943da25d | 134 | __u8 dev_type; |
1da177e4 | 135 | bdaddr_t bdaddr; |
1f6c6378 | 136 | __u8 dev_name[HCI_MAX_NAME_LENGTH]; |
80a1e1db | 137 | __u8 eir[HCI_MAX_EIR_LENGTH]; |
a9de9248 | 138 | __u8 dev_class[3]; |
1aff6f09 JH |
139 | __u8 major_class; |
140 | __u8 minor_class; | |
1da177e4 | 141 | __u8 features[8]; |
971e3a4b | 142 | __u8 extfeatures[8]; |
a9de9248 | 143 | __u8 commands[64]; |
333140b5 | 144 | __u8 ssp_mode; |
1143e5a6 MH |
145 | __u8 hci_ver; |
146 | __u16 hci_rev; | |
d5859e22 | 147 | __u8 lmp_ver; |
1143e5a6 | 148 | __u16 manufacturer; |
d5859e22 | 149 | __le16 lmp_subver; |
1da177e4 | 150 | __u16 voice_setting; |
17fa4b9d | 151 | __u8 io_capability; |
1da177e4 LT |
152 | |
153 | __u16 pkt_type; | |
5b7f9909 | 154 | __u16 esco_type; |
1da177e4 LT |
155 | __u16 link_policy; |
156 | __u16 link_mode; | |
157 | ||
04837f64 MH |
158 | __u32 idle_timeout; |
159 | __u16 sniff_min_interval; | |
160 | __u16 sniff_max_interval; | |
161 | ||
928abaa7 AE |
162 | __u8 amp_status; |
163 | __u32 amp_total_bw; | |
164 | __u32 amp_max_bw; | |
165 | __u32 amp_min_latency; | |
166 | __u32 amp_max_pdu; | |
167 | __u8 amp_type; | |
168 | __u16 amp_pal_cap; | |
169 | __u16 amp_assoc_size; | |
170 | __u32 amp_max_flush_to; | |
171 | __u32 amp_be_flush_to; | |
172 | ||
9f61656a JH |
173 | unsigned int auto_accept_delay; |
174 | ||
1da177e4 LT |
175 | unsigned long quirks; |
176 | ||
177 | atomic_t cmd_cnt; | |
178 | unsigned int acl_cnt; | |
179 | unsigned int sco_cnt; | |
6ed58ec5 | 180 | unsigned int le_cnt; |
1da177e4 LT |
181 | |
182 | unsigned int acl_mtu; | |
183 | unsigned int sco_mtu; | |
6ed58ec5 | 184 | unsigned int le_mtu; |
1da177e4 LT |
185 | unsigned int acl_pkts; |
186 | unsigned int sco_pkts; | |
6ed58ec5 | 187 | unsigned int le_pkts; |
1da177e4 | 188 | |
1da177e4 LT |
189 | unsigned long acl_last_tx; |
190 | unsigned long sco_last_tx; | |
6ed58ec5 | 191 | unsigned long le_last_tx; |
1da177e4 | 192 | |
f48fd9c8 MH |
193 | struct workqueue_struct *workqueue; |
194 | ||
ab81cbf9 JH |
195 | struct work_struct power_on; |
196 | struct work_struct power_off; | |
197 | struct timer_list off_timer; | |
198 | ||
16ab91ab JH |
199 | __u16 discov_timeout; |
200 | struct delayed_work discov_off; | |
201 | ||
6bd32326 | 202 | struct timer_list cmd_timer; |
1da177e4 LT |
203 | struct tasklet_struct cmd_task; |
204 | struct tasklet_struct rx_task; | |
205 | struct tasklet_struct tx_task; | |
206 | ||
207 | struct sk_buff_head rx_q; | |
208 | struct sk_buff_head raw_q; | |
209 | struct sk_buff_head cmd_q; | |
210 | ||
211 | struct sk_buff *sent_cmd; | |
cd4c5391 | 212 | struct sk_buff *reassembly[NUM_REASSEMBLY]; |
1da177e4 | 213 | |
a6a67efd | 214 | struct mutex req_lock; |
1da177e4 LT |
215 | wait_queue_head_t req_wait_q; |
216 | __u32 req_status; | |
217 | __u32 req_result; | |
a5040efa JH |
218 | |
219 | __u16 init_last_cmd; | |
1da177e4 LT |
220 | |
221 | struct inquiry_cache inq_cache; | |
222 | struct hci_conn_hash conn_hash; | |
ea4bd8ba | 223 | struct list_head blacklist; |
1da177e4 | 224 | |
2aeb9a1a JH |
225 | struct list_head uuids; |
226 | ||
55ed8ca1 JH |
227 | struct list_head link_keys; |
228 | ||
2763eda6 SJ |
229 | struct list_head remote_oob_data; |
230 | ||
76c8686f | 231 | struct list_head adv_entries; |
35815085 | 232 | struct timer_list adv_timer; |
76c8686f | 233 | |
1da177e4 LT |
234 | struct hci_dev_stats stat; |
235 | ||
236 | struct sk_buff_head driver_init; | |
237 | ||
238 | void *driver_data; | |
239 | void *core_data; | |
240 | ||
70f23020 | 241 | atomic_t promisc; |
1da177e4 | 242 | |
ca325f69 MH |
243 | struct dentry *debugfs; |
244 | ||
a91f2e39 MH |
245 | struct device *parent; |
246 | struct device dev; | |
1da177e4 | 247 | |
611b30f7 MH |
248 | struct rfkill *rfkill; |
249 | ||
70f23020 | 250 | struct module *owner; |
1da177e4 LT |
251 | |
252 | int (*open)(struct hci_dev *hdev); | |
253 | int (*close)(struct hci_dev *hdev); | |
254 | int (*flush)(struct hci_dev *hdev); | |
255 | int (*send)(struct sk_buff *skb); | |
256 | void (*destruct)(struct hci_dev *hdev); | |
257 | void (*notify)(struct hci_dev *hdev, unsigned int evt); | |
258 | int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg); | |
259 | }; | |
260 | ||
261 | struct hci_conn { | |
262 | struct list_head list; | |
263 | ||
adc4266d | 264 | atomic_t refcnt; |
adc4266d SJ |
265 | |
266 | bdaddr_t dst; | |
5a9d0a3f | 267 | __u8 dst_type; |
adc4266d SJ |
268 | __u16 handle; |
269 | __u16 state; | |
270 | __u8 mode; | |
271 | __u8 type; | |
272 | __u8 out; | |
273 | __u8 attempt; | |
274 | __u8 dev_class[3]; | |
275 | __u8 features[8]; | |
276 | __u8 ssp_mode; | |
277 | __u16 interval; | |
278 | __u16 pkt_type; | |
279 | __u16 link_policy; | |
280 | __u32 link_mode; | |
13d39315 | 281 | __u8 key_type; |
adc4266d SJ |
282 | __u8 auth_type; |
283 | __u8 sec_level; | |
284 | __u8 pending_sec_level; | |
285 | __u8 pin_length; | |
726b4ffc | 286 | __u8 enc_key_size; |
adc4266d SJ |
287 | __u8 io_capability; |
288 | __u8 power_save; | |
289 | __u16 disc_timeout; | |
290 | unsigned long pend; | |
04837f64 | 291 | |
03b555e1 JH |
292 | __u8 remote_cap; |
293 | __u8 remote_oob; | |
294 | __u8 remote_auth; | |
295 | ||
adc4266d | 296 | unsigned int sent; |
04837f64 | 297 | |
1da177e4 | 298 | struct sk_buff_head data_q; |
73d80deb | 299 | struct hci_chan_hash chan_hash; |
1da177e4 | 300 | |
04837f64 MH |
301 | struct timer_list disc_timer; |
302 | struct timer_list idle_timer; | |
9f61656a | 303 | struct timer_list auto_accept_timer; |
04837f64 | 304 | |
f3784d83 RQ |
305 | struct work_struct work_add; |
306 | struct work_struct work_del; | |
b219e3ac MH |
307 | |
308 | struct device dev; | |
9eba32b8 | 309 | atomic_t devref; |
b219e3ac | 310 | |
1da177e4 LT |
311 | struct hci_dev *hdev; |
312 | void *l2cap_data; | |
313 | void *sco_data; | |
1da177e4 LT |
314 | |
315 | struct hci_conn *link; | |
e9a416b5 JH |
316 | |
317 | void (*connect_cfm_cb) (struct hci_conn *conn, u8 status); | |
318 | void (*security_cfm_cb) (struct hci_conn *conn, u8 status); | |
319 | void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason); | |
1da177e4 LT |
320 | }; |
321 | ||
73d80deb LAD |
322 | struct hci_chan { |
323 | struct list_head list; | |
324 | ||
325 | struct hci_conn *conn; | |
326 | struct sk_buff_head data_q; | |
327 | unsigned int sent; | |
328 | }; | |
329 | ||
1da177e4 LT |
330 | extern struct hci_proto *hci_proto[]; |
331 | extern struct list_head hci_dev_list; | |
332 | extern struct list_head hci_cb_list; | |
333 | extern rwlock_t hci_dev_list_lock; | |
334 | extern rwlock_t hci_cb_list_lock; | |
335 | ||
336 | /* ----- Inquiry cache ----- */ | |
70f23020 AE |
337 | #define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ |
338 | #define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ | |
1da177e4 LT |
339 | |
340 | #define inquiry_cache_lock(c) spin_lock(&c->lock) | |
341 | #define inquiry_cache_unlock(c) spin_unlock(&c->lock) | |
342 | #define inquiry_cache_lock_bh(c) spin_lock_bh(&c->lock) | |
343 | #define inquiry_cache_unlock_bh(c) spin_unlock_bh(&c->lock) | |
344 | ||
345 | static inline void inquiry_cache_init(struct hci_dev *hdev) | |
346 | { | |
347 | struct inquiry_cache *c = &hdev->inq_cache; | |
348 | spin_lock_init(&c->lock); | |
349 | c->list = NULL; | |
350 | } | |
351 | ||
352 | static inline int inquiry_cache_empty(struct hci_dev *hdev) | |
353 | { | |
354 | struct inquiry_cache *c = &hdev->inq_cache; | |
a02cec21 | 355 | return c->list == NULL; |
1da177e4 LT |
356 | } |
357 | ||
358 | static inline long inquiry_cache_age(struct hci_dev *hdev) | |
359 | { | |
360 | struct inquiry_cache *c = &hdev->inq_cache; | |
361 | return jiffies - c->timestamp; | |
362 | } | |
363 | ||
364 | static inline long inquiry_entry_age(struct inquiry_entry *e) | |
365 | { | |
366 | return jiffies - e->timestamp; | |
367 | } | |
368 | ||
5a9d0a3f WR |
369 | struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, |
370 | bdaddr_t *bdaddr); | |
1da177e4 LT |
371 | void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data); |
372 | ||
373 | /* ----- HCI Connections ----- */ | |
374 | enum { | |
375 | HCI_CONN_AUTH_PEND, | |
19f8def0 | 376 | HCI_CONN_REAUTH_PEND, |
1da177e4 | 377 | HCI_CONN_ENCRYPT_PEND, |
04837f64 MH |
378 | HCI_CONN_RSWITCH_PEND, |
379 | HCI_CONN_MODE_CHANGE_PEND, | |
e73439d8 | 380 | HCI_CONN_SCO_SETUP_PEND, |
d26a2345 | 381 | HCI_CONN_LE_SMP_PEND, |
1da177e4 LT |
382 | }; |
383 | ||
384 | static inline void hci_conn_hash_init(struct hci_dev *hdev) | |
385 | { | |
386 | struct hci_conn_hash *h = &hdev->conn_hash; | |
387 | INIT_LIST_HEAD(&h->list); | |
388 | spin_lock_init(&h->lock); | |
389 | h->acl_num = 0; | |
390 | h->sco_num = 0; | |
391 | } | |
392 | ||
393 | static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) | |
394 | { | |
395 | struct hci_conn_hash *h = &hdev->conn_hash; | |
396 | list_add(&c->list, &h->list); | |
fcd89c09 VT |
397 | switch (c->type) { |
398 | case ACL_LINK: | |
1da177e4 | 399 | h->acl_num++; |
fcd89c09 VT |
400 | break; |
401 | case LE_LINK: | |
402 | h->le_num++; | |
403 | break; | |
404 | case SCO_LINK: | |
405 | case ESCO_LINK: | |
1da177e4 | 406 | h->sco_num++; |
fcd89c09 VT |
407 | break; |
408 | } | |
1da177e4 LT |
409 | } |
410 | ||
411 | static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) | |
412 | { | |
413 | struct hci_conn_hash *h = &hdev->conn_hash; | |
414 | list_del(&c->list); | |
fcd89c09 VT |
415 | switch (c->type) { |
416 | case ACL_LINK: | |
1da177e4 | 417 | h->acl_num--; |
fcd89c09 VT |
418 | break; |
419 | case LE_LINK: | |
420 | h->le_num--; | |
421 | break; | |
422 | case SCO_LINK: | |
423 | case ESCO_LINK: | |
1da177e4 | 424 | h->sco_num--; |
fcd89c09 VT |
425 | break; |
426 | } | |
1da177e4 LT |
427 | } |
428 | ||
52087a79 LAD |
429 | static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type) |
430 | { | |
431 | struct hci_conn_hash *h = &hdev->conn_hash; | |
432 | switch (type) { | |
433 | case ACL_LINK: | |
434 | return h->acl_num; | |
435 | case LE_LINK: | |
436 | return h->le_num; | |
437 | case SCO_LINK: | |
438 | case ESCO_LINK: | |
439 | return h->sco_num; | |
440 | default: | |
441 | return 0; | |
442 | } | |
443 | } | |
444 | ||
1da177e4 | 445 | static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, |
adc4266d | 446 | __u16 handle) |
1da177e4 LT |
447 | { |
448 | struct hci_conn_hash *h = &hdev->conn_hash; | |
449 | struct list_head *p; | |
450 | struct hci_conn *c; | |
451 | ||
452 | list_for_each(p, &h->list) { | |
453 | c = list_entry(p, struct hci_conn, list); | |
454 | if (c->handle == handle) | |
455 | return c; | |
456 | } | |
457 | return NULL; | |
458 | } | |
459 | ||
460 | static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev, | |
adc4266d | 461 | __u8 type, bdaddr_t *ba) |
1da177e4 LT |
462 | { |
463 | struct hci_conn_hash *h = &hdev->conn_hash; | |
464 | struct list_head *p; | |
465 | struct hci_conn *c; | |
466 | ||
467 | list_for_each(p, &h->list) { | |
468 | c = list_entry(p, struct hci_conn, list); | |
469 | if (c->type == type && !bacmp(&c->dst, ba)) | |
470 | return c; | |
471 | } | |
472 | return NULL; | |
473 | } | |
474 | ||
4c67bc74 | 475 | static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, |
adc4266d | 476 | __u8 type, __u16 state) |
4c67bc74 MH |
477 | { |
478 | struct hci_conn_hash *h = &hdev->conn_hash; | |
479 | struct list_head *p; | |
480 | struct hci_conn *c; | |
481 | ||
482 | list_for_each(p, &h->list) { | |
483 | c = list_entry(p, struct hci_conn, list); | |
484 | if (c->type == type && c->state == state) | |
485 | return c; | |
486 | } | |
487 | return NULL; | |
488 | } | |
489 | ||
73d80deb LAD |
490 | static inline void hci_chan_hash_init(struct hci_conn *c) |
491 | { | |
492 | struct hci_chan_hash *h = &c->chan_hash; | |
493 | INIT_LIST_HEAD(&h->list); | |
494 | spin_lock_init(&h->lock); | |
495 | h->num = 0; | |
496 | } | |
497 | ||
498 | static inline void hci_chan_hash_add(struct hci_conn *c, struct hci_chan *chan) | |
499 | { | |
500 | struct hci_chan_hash *h = &c->chan_hash; | |
501 | list_add(&chan->list, &h->list); | |
502 | h->num++; | |
503 | } | |
504 | ||
505 | static inline void hci_chan_hash_del(struct hci_conn *c, struct hci_chan *chan) | |
506 | { | |
507 | struct hci_chan_hash *h = &c->chan_hash; | |
508 | list_del(&chan->list); | |
509 | h->num--; | |
510 | } | |
511 | ||
4c67bc74 | 512 | void hci_acl_connect(struct hci_conn *conn); |
1da177e4 LT |
513 | void hci_acl_disconn(struct hci_conn *conn, __u8 reason); |
514 | void hci_add_sco(struct hci_conn *conn, __u16 handle); | |
b6a0dc82 | 515 | void hci_setup_sync(struct hci_conn *conn, __u16 handle); |
e73439d8 | 516 | void hci_sco_setup(struct hci_conn *conn, __u8 status); |
1da177e4 LT |
517 | |
518 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst); | |
a9de9248 MH |
519 | int hci_conn_del(struct hci_conn *conn); |
520 | void hci_conn_hash_flush(struct hci_dev *hdev); | |
521 | void hci_conn_check_pending(struct hci_dev *hdev); | |
1da177e4 | 522 | |
73d80deb LAD |
523 | struct hci_chan *hci_chan_create(struct hci_conn *conn); |
524 | int hci_chan_del(struct hci_chan *chan); | |
525 | void hci_chan_hash_flush(struct hci_conn *conn); | |
526 | ||
5a9d0a3f WR |
527 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, |
528 | __u8 sec_level, __u8 auth_type); | |
e7c29cb1 | 529 | int hci_conn_check_link_mode(struct hci_conn *conn); |
b3b1b061 | 530 | int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); |
0684e5f9 | 531 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); |
1da177e4 | 532 | int hci_conn_change_link_key(struct hci_conn *conn); |
8c1b2355 | 533 | int hci_conn_switch_role(struct hci_conn *conn, __u8 role); |
1da177e4 | 534 | |
14b12d0b | 535 | void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); |
04837f64 | 536 | void hci_conn_enter_sniff_mode(struct hci_conn *conn); |
1da177e4 | 537 | |
9eba32b8 MH |
538 | void hci_conn_hold_device(struct hci_conn *conn); |
539 | void hci_conn_put_device(struct hci_conn *conn); | |
540 | ||
1da177e4 LT |
541 | static inline void hci_conn_hold(struct hci_conn *conn) |
542 | { | |
543 | atomic_inc(&conn->refcnt); | |
04837f64 | 544 | del_timer(&conn->disc_timer); |
1da177e4 LT |
545 | } |
546 | ||
547 | static inline void hci_conn_put(struct hci_conn *conn) | |
548 | { | |
549 | if (atomic_dec_and_test(&conn->refcnt)) { | |
04837f64 | 550 | unsigned long timeo; |
454d48ff | 551 | if (conn->type == ACL_LINK || conn->type == LE_LINK) { |
04837f64 | 552 | del_timer(&conn->idle_timer); |
6ac59344 | 553 | if (conn->state == BT_CONNECTED) { |
052b30b0 | 554 | timeo = msecs_to_jiffies(conn->disc_timeout); |
6ac59344 | 555 | if (!conn->out) |
052b30b0 | 556 | timeo *= 2; |
5a9d0a3f | 557 | } else { |
6ac59344 | 558 | timeo = msecs_to_jiffies(10); |
5a9d0a3f WR |
559 | } |
560 | } else { | |
04837f64 | 561 | timeo = msecs_to_jiffies(10); |
5a9d0a3f | 562 | } |
04837f64 | 563 | mod_timer(&conn->disc_timer, jiffies + timeo); |
1da177e4 LT |
564 | } |
565 | } | |
566 | ||
1da177e4 LT |
567 | /* ----- HCI Devices ----- */ |
568 | static inline void __hci_dev_put(struct hci_dev *d) | |
569 | { | |
570 | if (atomic_dec_and_test(&d->refcnt)) | |
571 | d->destruct(d); | |
572 | } | |
573 | ||
574 | static inline void hci_dev_put(struct hci_dev *d) | |
04fafe4e | 575 | { |
1da177e4 LT |
576 | __hci_dev_put(d); |
577 | module_put(d->owner); | |
578 | } | |
579 | ||
580 | static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d) | |
581 | { | |
582 | atomic_inc(&d->refcnt); | |
583 | return d; | |
584 | } | |
585 | ||
586 | static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) | |
587 | { | |
588 | if (try_module_get(d->owner)) | |
589 | return __hci_dev_hold(d); | |
590 | return NULL; | |
591 | } | |
592 | ||
593 | #define hci_dev_lock(d) spin_lock(&d->lock) | |
594 | #define hci_dev_unlock(d) spin_unlock(&d->lock) | |
595 | #define hci_dev_lock_bh(d) spin_lock_bh(&d->lock) | |
596 | #define hci_dev_unlock_bh(d) spin_unlock_bh(&d->lock) | |
597 | ||
598 | struct hci_dev *hci_dev_get(int index); | |
599 | struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); | |
600 | ||
601 | struct hci_dev *hci_alloc_dev(void); | |
602 | void hci_free_dev(struct hci_dev *hdev); | |
603 | int hci_register_dev(struct hci_dev *hdev); | |
59735631 | 604 | void hci_unregister_dev(struct hci_dev *hdev); |
1da177e4 LT |
605 | int hci_suspend_dev(struct hci_dev *hdev); |
606 | int hci_resume_dev(struct hci_dev *hdev); | |
607 | int hci_dev_open(__u16 dev); | |
608 | int hci_dev_close(__u16 dev); | |
609 | int hci_dev_reset(__u16 dev); | |
610 | int hci_dev_reset_stat(__u16 dev); | |
611 | int hci_dev_cmd(unsigned int cmd, void __user *arg); | |
612 | int hci_get_dev_list(void __user *arg); | |
613 | int hci_get_dev_info(void __user *arg); | |
614 | int hci_get_conn_list(void __user *arg); | |
615 | int hci_get_conn_info(struct hci_dev *hdev, void __user *arg); | |
40be492f | 616 | int hci_get_auth_info(struct hci_dev *hdev, void __user *arg); |
1da177e4 LT |
617 | int hci_inquiry(void __user *arg); |
618 | ||
f0358568 JH |
619 | struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); |
620 | int hci_blacklist_clear(struct hci_dev *hdev); | |
b2a66aad AJ |
621 | int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr); |
622 | int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr); | |
f0358568 | 623 | |
2aeb9a1a JH |
624 | int hci_uuids_clear(struct hci_dev *hdev); |
625 | ||
55ed8ca1 JH |
626 | int hci_link_keys_clear(struct hci_dev *hdev); |
627 | struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); | |
d25e28ab JH |
628 | int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, |
629 | bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len); | |
75d262c2 VCG |
630 | struct link_key *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]); |
631 | struct link_key *hci_find_link_key_type(struct hci_dev *hdev, | |
632 | bdaddr_t *bdaddr, u8 type); | |
633 | int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, | |
726b4ffc | 634 | u8 key_size, __le16 ediv, u8 rand[8], u8 ltk[16]); |
55ed8ca1 JH |
635 | int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); |
636 | ||
2763eda6 SJ |
637 | int hci_remote_oob_data_clear(struct hci_dev *hdev); |
638 | struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev, | |
639 | bdaddr_t *bdaddr); | |
640 | int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, | |
641 | u8 *randomizer); | |
642 | int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); | |
643 | ||
35815085 | 644 | #define ADV_CLEAR_TIMEOUT (3*60*HZ) /* Three minutes */ |
76c8686f AG |
645 | int hci_adv_entries_clear(struct hci_dev *hdev); |
646 | struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr); | |
647 | int hci_add_adv_entry(struct hci_dev *hdev, | |
648 | struct hci_ev_le_advertising_info *ev); | |
649 | ||
ab81cbf9 JH |
650 | void hci_del_off_timer(struct hci_dev *hdev); |
651 | ||
1da177e4 LT |
652 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); |
653 | ||
76bca880 | 654 | int hci_recv_frame(struct sk_buff *skb); |
ef222013 | 655 | int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count); |
99811510 | 656 | int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); |
ef222013 | 657 | |
0ac7e700 | 658 | void hci_init_sysfs(struct hci_dev *hdev); |
ce242970 DH |
659 | int hci_add_sysfs(struct hci_dev *hdev); |
660 | void hci_del_sysfs(struct hci_dev *hdev); | |
a67e899c | 661 | void hci_conn_init_sysfs(struct hci_conn *conn); |
b219e3ac MH |
662 | void hci_conn_add_sysfs(struct hci_conn *conn); |
663 | void hci_conn_del_sysfs(struct hci_conn *conn); | |
1da177e4 | 664 | |
a91f2e39 | 665 | #define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->parent = (pdev)) |
1da177e4 LT |
666 | |
667 | /* ----- LMP capabilities ----- */ | |
04837f64 MH |
668 | #define lmp_rswitch_capable(dev) ((dev)->features[0] & LMP_RSWITCH) |
669 | #define lmp_encrypt_capable(dev) ((dev)->features[0] & LMP_ENCRYPT) | |
670 | #define lmp_sniff_capable(dev) ((dev)->features[0] & LMP_SNIFF) | |
671 | #define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) | |
5b7f9909 | 672 | #define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) |
769be974 | 673 | #define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) |
e702112f | 674 | #define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH) |
6ed58ec5 | 675 | #define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE) |
1da177e4 | 676 | |
eead27da AG |
677 | /* ----- Extended LMP capabilities ----- */ |
678 | #define lmp_host_le_capable(dev) ((dev)->extfeatures[0] & LMP_HOST_LE) | |
679 | ||
1da177e4 LT |
680 | /* ----- HCI protocols ----- */ |
681 | struct hci_proto { | |
8c1b2355 | 682 | char *name; |
1da177e4 LT |
683 | unsigned int id; |
684 | unsigned long flags; | |
685 | ||
686 | void *priv; | |
687 | ||
5a9d0a3f WR |
688 | int (*connect_ind) (struct hci_dev *hdev, bdaddr_t *bdaddr, |
689 | __u8 type); | |
1da177e4 | 690 | int (*connect_cfm) (struct hci_conn *conn, __u8 status); |
2950f21a MH |
691 | int (*disconn_ind) (struct hci_conn *conn); |
692 | int (*disconn_cfm) (struct hci_conn *conn, __u8 reason); | |
5a9d0a3f WR |
693 | int (*recv_acldata) (struct hci_conn *conn, struct sk_buff *skb, |
694 | __u16 flags); | |
1da177e4 | 695 | int (*recv_scodata) (struct hci_conn *conn, struct sk_buff *skb); |
5a9d0a3f WR |
696 | int (*security_cfm) (struct hci_conn *conn, __u8 status, |
697 | __u8 encrypt); | |
1da177e4 LT |
698 | }; |
699 | ||
5a9d0a3f WR |
700 | static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, |
701 | __u8 type) | |
1da177e4 LT |
702 | { |
703 | register struct hci_proto *hp; | |
704 | int mask = 0; | |
8c1b2355 | 705 | |
1da177e4 LT |
706 | hp = hci_proto[HCI_PROTO_L2CAP]; |
707 | if (hp && hp->connect_ind) | |
708 | mask |= hp->connect_ind(hdev, bdaddr, type); | |
709 | ||
710 | hp = hci_proto[HCI_PROTO_SCO]; | |
711 | if (hp && hp->connect_ind) | |
712 | mask |= hp->connect_ind(hdev, bdaddr, type); | |
713 | ||
714 | return mask; | |
715 | } | |
716 | ||
717 | static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) | |
718 | { | |
719 | register struct hci_proto *hp; | |
720 | ||
721 | hp = hci_proto[HCI_PROTO_L2CAP]; | |
722 | if (hp && hp->connect_cfm) | |
723 | hp->connect_cfm(conn, status); | |
724 | ||
725 | hp = hci_proto[HCI_PROTO_SCO]; | |
726 | if (hp && hp->connect_cfm) | |
727 | hp->connect_cfm(conn, status); | |
e9a416b5 JH |
728 | |
729 | if (conn->connect_cfm_cb) | |
730 | conn->connect_cfm_cb(conn, status); | |
1da177e4 LT |
731 | } |
732 | ||
2950f21a | 733 | static inline int hci_proto_disconn_ind(struct hci_conn *conn) |
1da177e4 LT |
734 | { |
735 | register struct hci_proto *hp; | |
9f5a0d7b | 736 | int reason = HCI_ERROR_REMOTE_USER_TERM; |
1da177e4 LT |
737 | |
738 | hp = hci_proto[HCI_PROTO_L2CAP]; | |
739 | if (hp && hp->disconn_ind) | |
2950f21a | 740 | reason = hp->disconn_ind(conn); |
1da177e4 LT |
741 | |
742 | hp = hci_proto[HCI_PROTO_SCO]; | |
743 | if (hp && hp->disconn_ind) | |
2950f21a MH |
744 | reason = hp->disconn_ind(conn); |
745 | ||
746 | return reason; | |
747 | } | |
748 | ||
749 | static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) | |
750 | { | |
751 | register struct hci_proto *hp; | |
752 | ||
753 | hp = hci_proto[HCI_PROTO_L2CAP]; | |
754 | if (hp && hp->disconn_cfm) | |
755 | hp->disconn_cfm(conn, reason); | |
756 | ||
757 | hp = hci_proto[HCI_PROTO_SCO]; | |
758 | if (hp && hp->disconn_cfm) | |
759 | hp->disconn_cfm(conn, reason); | |
e9a416b5 JH |
760 | |
761 | if (conn->disconn_cfm_cb) | |
762 | conn->disconn_cfm_cb(conn, reason); | |
1da177e4 LT |
763 | } |
764 | ||
765 | static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) | |
766 | { | |
767 | register struct hci_proto *hp; | |
8c1b2355 MH |
768 | __u8 encrypt; |
769 | ||
770 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) | |
771 | return; | |
772 | ||
773 | encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; | |
1da177e4 LT |
774 | |
775 | hp = hci_proto[HCI_PROTO_L2CAP]; | |
8c1b2355 MH |
776 | if (hp && hp->security_cfm) |
777 | hp->security_cfm(conn, status, encrypt); | |
1da177e4 LT |
778 | |
779 | hp = hci_proto[HCI_PROTO_SCO]; | |
8c1b2355 MH |
780 | if (hp && hp->security_cfm) |
781 | hp->security_cfm(conn, status, encrypt); | |
e9a416b5 JH |
782 | |
783 | if (conn->security_cfm_cb) | |
784 | conn->security_cfm_cb(conn, status); | |
1da177e4 LT |
785 | } |
786 | ||
5a9d0a3f WR |
787 | static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, |
788 | __u8 encrypt) | |
1da177e4 LT |
789 | { |
790 | register struct hci_proto *hp; | |
791 | ||
792 | hp = hci_proto[HCI_PROTO_L2CAP]; | |
8c1b2355 MH |
793 | if (hp && hp->security_cfm) |
794 | hp->security_cfm(conn, status, encrypt); | |
1da177e4 LT |
795 | |
796 | hp = hci_proto[HCI_PROTO_SCO]; | |
8c1b2355 MH |
797 | if (hp && hp->security_cfm) |
798 | hp->security_cfm(conn, status, encrypt); | |
e9a416b5 JH |
799 | |
800 | if (conn->security_cfm_cb) | |
801 | conn->security_cfm_cb(conn, status); | |
1da177e4 LT |
802 | } |
803 | ||
804 | int hci_register_proto(struct hci_proto *hproto); | |
805 | int hci_unregister_proto(struct hci_proto *hproto); | |
806 | ||
807 | /* ----- HCI callbacks ----- */ | |
808 | struct hci_cb { | |
809 | struct list_head list; | |
810 | ||
811 | char *name; | |
812 | ||
5a9d0a3f WR |
813 | void (*security_cfm) (struct hci_conn *conn, __u8 status, |
814 | __u8 encrypt); | |
1da177e4 LT |
815 | void (*key_change_cfm) (struct hci_conn *conn, __u8 status); |
816 | void (*role_switch_cfm) (struct hci_conn *conn, __u8 status, __u8 role); | |
817 | }; | |
818 | ||
819 | static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) | |
820 | { | |
821 | struct list_head *p; | |
8c1b2355 | 822 | __u8 encrypt; |
1da177e4 LT |
823 | |
824 | hci_proto_auth_cfm(conn, status); | |
825 | ||
8c1b2355 MH |
826 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) |
827 | return; | |
828 | ||
829 | encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; | |
830 | ||
1da177e4 LT |
831 | read_lock_bh(&hci_cb_list_lock); |
832 | list_for_each(p, &hci_cb_list) { | |
833 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | |
8c1b2355 MH |
834 | if (cb->security_cfm) |
835 | cb->security_cfm(conn, status, encrypt); | |
1da177e4 LT |
836 | } |
837 | read_unlock_bh(&hci_cb_list_lock); | |
838 | } | |
839 | ||
5a9d0a3f WR |
840 | static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, |
841 | __u8 encrypt) | |
1da177e4 LT |
842 | { |
843 | struct list_head *p; | |
844 | ||
435fef20 MH |
845 | if (conn->sec_level == BT_SECURITY_SDP) |
846 | conn->sec_level = BT_SECURITY_LOW; | |
847 | ||
88167aed VCG |
848 | if (conn->pending_sec_level > conn->sec_level) |
849 | conn->sec_level = conn->pending_sec_level; | |
850 | ||
9719f8af | 851 | hci_proto_encrypt_cfm(conn, status, encrypt); |
1da177e4 LT |
852 | |
853 | read_lock_bh(&hci_cb_list_lock); | |
854 | list_for_each(p, &hci_cb_list) { | |
855 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | |
8c1b2355 MH |
856 | if (cb->security_cfm) |
857 | cb->security_cfm(conn, status, encrypt); | |
1da177e4 LT |
858 | } |
859 | read_unlock_bh(&hci_cb_list_lock); | |
860 | } | |
861 | ||
862 | static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) | |
863 | { | |
864 | struct list_head *p; | |
865 | ||
866 | read_lock_bh(&hci_cb_list_lock); | |
867 | list_for_each(p, &hci_cb_list) { | |
868 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | |
869 | if (cb->key_change_cfm) | |
870 | cb->key_change_cfm(conn, status); | |
871 | } | |
872 | read_unlock_bh(&hci_cb_list_lock); | |
873 | } | |
874 | ||
5a9d0a3f WR |
875 | static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, |
876 | __u8 role) | |
1da177e4 LT |
877 | { |
878 | struct list_head *p; | |
879 | ||
880 | read_lock_bh(&hci_cb_list_lock); | |
881 | list_for_each(p, &hci_cb_list) { | |
882 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | |
883 | if (cb->role_switch_cfm) | |
884 | cb->role_switch_cfm(conn, status, role); | |
885 | } | |
886 | read_unlock_bh(&hci_cb_list_lock); | |
887 | } | |
888 | ||
889 | int hci_register_cb(struct hci_cb *hcb); | |
890 | int hci_unregister_cb(struct hci_cb *hcb); | |
891 | ||
892 | int hci_register_notifier(struct notifier_block *nb); | |
893 | int hci_unregister_notifier(struct notifier_block *nb); | |
894 | ||
a9de9248 | 895 | int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); |
73d80deb | 896 | void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); |
0d861d8b | 897 | void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); |
1da177e4 | 898 | |
a9de9248 | 899 | void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); |
1da177e4 LT |
900 | |
901 | void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data); | |
902 | ||
903 | /* ----- HCI Sockets ----- */ | |
eec8d2bc JH |
904 | void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, |
905 | struct sock *skip_sk); | |
1da177e4 | 906 | |
0381101f JH |
907 | /* Management interface */ |
908 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); | |
c71e97bf JH |
909 | int mgmt_index_added(u16 index); |
910 | int mgmt_index_removed(u16 index); | |
5add6af8 | 911 | int mgmt_powered(u16 index, u8 powered); |
73f22f62 | 912 | int mgmt_discoverable(u16 index, u8 discoverable); |
9fbcbb45 | 913 | int mgmt_connectable(u16 index, u8 connectable); |
2d7cee58 | 914 | int mgmt_write_scan_failed(u16 index, u8 scan, u8 status); |
4df378a1 | 915 | int mgmt_new_key(u16 index, struct link_key *key, u8 persistent); |
cfafccf7 | 916 | int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type); |
f7520543 | 917 | int mgmt_disconnected(u16 index, bdaddr_t *bdaddr); |
8962ee74 | 918 | int mgmt_disconnect_failed(u16 index); |
17d5c04c | 919 | int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status); |
a770bb5a | 920 | int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure); |
980e1a53 JH |
921 | int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
922 | int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); | |
55bc1a37 JH |
923 | int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value, |
924 | u8 confirm_hint); | |
a5c29683 JH |
925 | int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
926 | int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, | |
927 | u8 status); | |
2a611692 | 928 | int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status); |
b312b161 | 929 | int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status); |
c35938b2 SJ |
930 | int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, |
931 | u8 status); | |
e17acd40 JH |
932 | int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, |
933 | u8 *eir); | |
a88a9652 | 934 | int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name); |
164a6e78 | 935 | int mgmt_inquiry_failed(u16 index, u8 status); |
314b2381 | 936 | int mgmt_discovering(u16 index, u8 discovering); |
5e762444 AJ |
937 | int mgmt_device_blocked(u16 index, bdaddr_t *bdaddr); |
938 | int mgmt_device_unblocked(u16 index, bdaddr_t *bdaddr); | |
0381101f | 939 | |
1da177e4 LT |
940 | /* HCI info for socket */ |
941 | #define hci_pi(sk) ((struct hci_pinfo *) sk) | |
942 | ||
943 | struct hci_pinfo { | |
944 | struct bt_sock bt; | |
945 | struct hci_dev *hdev; | |
946 | struct hci_filter filter; | |
947 | __u32 cmsg_mask; | |
c02178d2 | 948 | unsigned short channel; |
1da177e4 LT |
949 | }; |
950 | ||
951 | /* HCI security filter */ | |
952 | #define HCI_SFLT_MAX_OGF 5 | |
953 | ||
954 | struct hci_sec_filter { | |
955 | __u32 type_mask; | |
956 | __u32 event_mask[2]; | |
957 | __u32 ocf_mask[HCI_SFLT_MAX_OGF + 1][4]; | |
958 | }; | |
959 | ||
960 | /* ----- HCI requests ----- */ | |
961 | #define HCI_REQ_DONE 0 | |
962 | #define HCI_REQ_PEND 1 | |
963 | #define HCI_REQ_CANCELED 2 | |
964 | ||
a6a67efd TG |
965 | #define hci_req_lock(d) mutex_lock(&d->req_lock) |
966 | #define hci_req_unlock(d) mutex_unlock(&d->req_lock) | |
1da177e4 | 967 | |
23bb5763 | 968 | void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result); |
1da177e4 | 969 | |
2ce603eb CT |
970 | void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, |
971 | u16 latency, u16 to_multiplier); | |
a7a595f6 VCG |
972 | void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], |
973 | __u8 ltk[16]); | |
974 | void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]); | |
975 | void hci_le_ltk_neg_reply(struct hci_conn *conn); | |
976 | ||
2519a1fc | 977 | int hci_do_inquiry(struct hci_dev *hdev, u8 length); |
023d5049 | 978 | int hci_cancel_inquiry(struct hci_dev *hdev); |
2519a1fc | 979 | |
1da177e4 | 980 | #endif /* __HCI_CORE_H */ |