1 /*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated
4 Copyright 2023 NXP
5
6 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as
10 published by the Free Software Foundation;
11
12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
15 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
16 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
17 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20
21 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
22 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
23 SOFTWARE IS DISCLAIMED.
24 */
25
26 #ifndef __BLUETOOTH_H
27 #define __BLUETOOTH_H
28
29 #include <linux/poll.h>
30 #include <net/sock.h>
31 #include <linux/seq_file.h>
32 #include <linux/ethtool.h>
33
34 #define BT_SUBSYS_VERSION 2
35 #define BT_SUBSYS_REVISION 22
36
37 #ifndef AF_BLUETOOTH
38 #define AF_BLUETOOTH 31
39 #define PF_BLUETOOTH AF_BLUETOOTH
40 #endif
41
42 /* Bluetooth versions */
43 #define BLUETOOTH_VER_1_1 1
44 #define BLUETOOTH_VER_1_2 2
45 #define BLUETOOTH_VER_2_0 3
46 #define BLUETOOTH_VER_2_1 4
47 #define BLUETOOTH_VER_4_0 6
48
49 /* Reserv for core and drivers use */
50 #define BT_SKB_RESERVE 8
51
52 #define BTPROTO_L2CAP 0
53 #define BTPROTO_HCI 1
54 #define BTPROTO_SCO 2
55 #define BTPROTO_RFCOMM 3
56 #define BTPROTO_BNEP 4
57 #define BTPROTO_CMTP 5
58 #define BTPROTO_HIDP 6
59 #define BTPROTO_AVDTP 7
60 #define BTPROTO_ISO 8
61 #define BTPROTO_LAST BTPROTO_ISO
62
63 #define SOL_HCI 0
64 #define SOL_L2CAP 6
65 #define SOL_SCO 17
66 #define SOL_RFCOMM 18
67
68 #define BT_SECURITY 4
69 struct bt_security {
70 __u8 level;
71 __u8 key_size;
72 };
73 #define BT_SECURITY_SDP 0
74 #define BT_SECURITY_LOW 1
75 #define BT_SECURITY_MEDIUM 2
76 #define BT_SECURITY_HIGH 3
77 #define BT_SECURITY_FIPS 4
78
79 #define BT_DEFER_SETUP 7
80
81 #define BT_FLUSHABLE 8
82
83 #define BT_FLUSHABLE_OFF 0
84 #define BT_FLUSHABLE_ON 1
85
86 #define BT_POWER 9
87 struct bt_power {
88 __u8 force_active;
89 };
90 #define BT_POWER_FORCE_ACTIVE_OFF 0
91 #define BT_POWER_FORCE_ACTIVE_ON 1
92
93 #define BT_CHANNEL_POLICY 10
94
95 /* BR/EDR only (default policy)
96 * AMP controllers cannot be used.
97 * Channel move requests from the remote device are denied.
98 * If the L2CAP channel is currently using AMP, move the channel to BR/EDR.
99 */
100 #define BT_CHANNEL_POLICY_BREDR_ONLY 0
101
102 /* BR/EDR Preferred
103 * Allow use of AMP controllers.
104 * If the L2CAP channel is currently on AMP, move it to BR/EDR.
105 * Channel move requests from the remote device are allowed.
106 */
107 #define BT_CHANNEL_POLICY_BREDR_PREFERRED 1
108
109 /* AMP Preferred
110 * Allow use of AMP controllers
111 * If the L2CAP channel is currently on BR/EDR and AMP controller
112 * resources are available, initiate a channel move to AMP.
113 * Channel move requests from the remote device are allowed.
114 * If the L2CAP socket has not been connected yet, try to create
115 * and configure the channel directly on an AMP controller rather
116 * than BR/EDR.
117 */
118 #define BT_CHANNEL_POLICY_AMP_PREFERRED 2
119
120 #define BT_VOICE 11
121 struct bt_voice {
122 __u16 setting;
123 };
124
125 #define BT_VOICE_TRANSPARENT 0x0003
126 #define BT_VOICE_CVSD_16BIT 0x0060
127 #define BT_VOICE_TRANSPARENT_16BIT 0x0063
128
129 #define BT_SNDMTU 12
130 #define BT_RCVMTU 13
131 #define BT_PHY 14
132
133 #define BT_PHY_BR_1M_1SLOT BIT(0)
134 #define BT_PHY_BR_1M_3SLOT BIT(1)
135 #define BT_PHY_BR_1M_5SLOT BIT(2)
136 #define BT_PHY_EDR_2M_1SLOT BIT(3)
137 #define BT_PHY_EDR_2M_3SLOT BIT(4)
138 #define BT_PHY_EDR_2M_5SLOT BIT(5)
139 #define BT_PHY_EDR_3M_1SLOT BIT(6)
140 #define BT_PHY_EDR_3M_3SLOT BIT(7)
141 #define BT_PHY_EDR_3M_5SLOT BIT(8)
142 #define BT_PHY_LE_1M_TX BIT(9)
143 #define BT_PHY_LE_1M_RX BIT(10)
144 #define BT_PHY_LE_2M_TX BIT(11)
145 #define BT_PHY_LE_2M_RX BIT(12)
146 #define BT_PHY_LE_CODED_TX BIT(13)
147 #define BT_PHY_LE_CODED_RX BIT(14)
148
149 #define BT_PHY_BREDR_MASK (BT_PHY_BR_1M_1SLOT | BT_PHY_BR_1M_3SLOT | \
150 BT_PHY_BR_1M_5SLOT | BT_PHY_EDR_2M_1SLOT | \
151 BT_PHY_EDR_2M_3SLOT | BT_PHY_EDR_2M_5SLOT | \
152 BT_PHY_EDR_3M_1SLOT | BT_PHY_EDR_3M_3SLOT | \
153 BT_PHY_EDR_3M_5SLOT)
154 #define BT_PHY_LE_MASK (BT_PHY_LE_1M_TX | BT_PHY_LE_1M_RX | \
155 BT_PHY_LE_2M_TX | BT_PHY_LE_2M_RX | \
156 BT_PHY_LE_CODED_TX | BT_PHY_LE_CODED_RX)
157
158 #define BT_MODE 15
159
160 #define BT_MODE_BASIC 0x00
161 #define BT_MODE_ERTM 0x01
162 #define BT_MODE_STREAMING 0x02
163 #define BT_MODE_LE_FLOWCTL 0x03
164 #define BT_MODE_EXT_FLOWCTL 0x04
165
166 #define BT_PKT_STATUS 16
167
168 #define BT_SCM_PKT_STATUS 0x03
169 #define BT_SCM_ERROR 0x04
170
171 #define BT_ISO_QOS 17
172
173 #define BT_ISO_QOS_CIG_UNSET 0xff
174 #define BT_ISO_QOS_CIS_UNSET 0xff
175
176 #define BT_ISO_QOS_BIG_UNSET 0xff
177 #define BT_ISO_QOS_BIS_UNSET 0xff
178
179 #define BT_ISO_SYNC_TIMEOUT 0x07d0 /* 20 secs */
180
181 struct bt_iso_io_qos {
182 __u32 interval;
183 __u16 latency;
184 __u16 sdu;
185 __u8 phys;
186 __u8 rtn;
187 };
188
189 struct bt_iso_ucast_qos {
190 __u8 cig;
191 __u8 cis;
192 __u8 sca;
193 __u8 packing;
194 __u8 framing;
195 struct bt_iso_io_qos in;
196 struct bt_iso_io_qos out;
197 };
198
199 struct bt_iso_bcast_qos {
200 __u8 big;
201 __u8 bis;
202 __u8 sync_factor;
203 __u8 packing;
204 __u8 framing;
205 struct bt_iso_io_qos in;
206 struct bt_iso_io_qos out;
207 __u8 encryption;
208 __u8 bcode[16];
209 __u8 options;
210 __u16 skip;
211 __u16 sync_timeout;
212 __u8 sync_cte_type;
213 __u8 mse;
214 __u16 timeout;
215 };
216
217 struct bt_iso_qos {
218 union {
219 struct bt_iso_ucast_qos ucast;
220 struct bt_iso_bcast_qos bcast;
221 };
222 };
223
224 #define BT_ISO_PHY_1M BIT(0)
225 #define BT_ISO_PHY_2M BIT(1)
226 #define BT_ISO_PHY_CODED BIT(2)
227 #define BT_ISO_PHY_ANY (BT_ISO_PHY_1M | BT_ISO_PHY_2M | \
228 BT_ISO_PHY_CODED)
229
230 #define BT_CODEC 19
231
232 struct bt_codec_caps {
233 __u8 len;
234 __u8 data[];
235 } __packed;
236
237 struct bt_codec {
238 __u8 id;
239 __u16 cid;
240 __u16 vid;
241 __u8 data_path;
242 __u8 num_caps;
243 } __packed;
244
245 struct bt_codecs {
246 __u8 num_codecs;
247 struct bt_codec codecs[];
248 } __packed;
249
250 #define BT_CODEC_CVSD 0x02
251 #define BT_CODEC_TRANSPARENT 0x03
252 #define BT_CODEC_MSBC 0x05
253
254 #define BT_ISO_BASE 20
255
256 /* Socket option value 21 reserved */
257
258 #define BT_PKT_SEQNUM 22
259
260 #define BT_SCM_PKT_SEQNUM 0x05
261
262 __printf(1, 2)
263 void bt_info(const char *fmt, ...);
264 __printf(1, 2)
265 void bt_warn(const char *fmt, ...);
266 __printf(1, 2)
267 void bt_err(const char *fmt, ...);
268 #if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG)
269 void bt_dbg_set(bool enable);
270 bool bt_dbg_get(void);
271 __printf(1, 2)
272 void bt_dbg(const char *fmt, ...);
273 #endif
274 __printf(1, 2)
275 void bt_warn_ratelimited(const char *fmt, ...);
276 __printf(1, 2)
277 void bt_err_ratelimited(const char *fmt, ...);
278
279 #define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__)
280 #define BT_WARN(fmt, ...) bt_warn(fmt "\n", ##__VA_ARGS__)
281 #define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__)
282
283 #if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG)
284 #define BT_DBG(fmt, ...) \
285 bt_dbg("%s:%d: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__)
286 #else
287 #define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__)
288 #endif
289
290 #define bt_dev_name(hdev) ((hdev) ? (hdev)->name : "null")
291
292 #define bt_dev_info(hdev, fmt, ...) \
293 BT_INFO("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
294 #define bt_dev_warn(hdev, fmt, ...) \
295 BT_WARN("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
296 #define bt_dev_err(hdev, fmt, ...) \
297 BT_ERR("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
298 #define bt_dev_dbg(hdev, fmt, ...) \
299 BT_DBG("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
300
301 #define bt_dev_warn_ratelimited(hdev, fmt, ...) \
302 bt_warn_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
303 #define bt_dev_err_ratelimited(hdev, fmt, ...) \
304 bt_err_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
305
306 /* Connection and socket states */
307 enum bt_sock_state {
308 BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
309 BT_OPEN,
310 BT_BOUND,
311 BT_LISTEN,
312 BT_CONNECT,
313 BT_CONNECT2,
314 BT_CONFIG,
315 BT_DISCONN,
316 BT_CLOSED
317 };
318
319 /* If unused will be removed by compiler */
state_to_string(int state)320 static inline const char *state_to_string(int state)
321 {
322 switch (state) {
323 case BT_CONNECTED:
324 return "BT_CONNECTED";
325 case BT_OPEN:
326 return "BT_OPEN";
327 case BT_BOUND:
328 return "BT_BOUND";
329 case BT_LISTEN:
330 return "BT_LISTEN";
331 case BT_CONNECT:
332 return "BT_CONNECT";
333 case BT_CONNECT2:
334 return "BT_CONNECT2";
335 case BT_CONFIG:
336 return "BT_CONFIG";
337 case BT_DISCONN:
338 return "BT_DISCONN";
339 case BT_CLOSED:
340 return "BT_CLOSED";
341 }
342
343 return "invalid state";
344 }
345
346 /* BD Address */
347 typedef struct {
348 __u8 b[6];
349 } __packed bdaddr_t;
350
351 /* BD Address type */
352 #define BDADDR_BREDR 0x00
353 #define BDADDR_LE_PUBLIC 0x01
354 #define BDADDR_LE_RANDOM 0x02
355
bdaddr_type_is_valid(u8 type)356 static inline bool bdaddr_type_is_valid(u8 type)
357 {
358 switch (type) {
359 case BDADDR_BREDR:
360 case BDADDR_LE_PUBLIC:
361 case BDADDR_LE_RANDOM:
362 return true;
363 }
364
365 return false;
366 }
367
bdaddr_type_is_le(u8 type)368 static inline bool bdaddr_type_is_le(u8 type)
369 {
370 switch (type) {
371 case BDADDR_LE_PUBLIC:
372 case BDADDR_LE_RANDOM:
373 return true;
374 }
375
376 return false;
377 }
378
379 #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
380 #define BDADDR_NONE (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
381
382 /* Copy, swap, convert BD Address */
bacmp(const bdaddr_t * ba1,const bdaddr_t * ba2)383 static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
384 {
385 return memcmp(ba1, ba2, sizeof(bdaddr_t));
386 }
bacpy(bdaddr_t * dst,const bdaddr_t * src)387 static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
388 {
389 memcpy(dst, src, sizeof(bdaddr_t));
390 }
391
392 void baswap(bdaddr_t *dst, const bdaddr_t *src);
393
394 /* Common socket structures and functions */
395
396 #define bt_sk(__sk) ((struct bt_sock *) __sk)
397
398 struct bt_sock {
399 struct sock sk;
400 struct list_head accept_q;
401 spinlock_t accept_q_lock; /* protects accept_q */
402 struct sock *parent;
403 unsigned long flags;
404 void (*skb_msg_name)(struct sk_buff *, void *, int *);
405 void (*skb_put_cmsg)(struct sk_buff *, struct msghdr *, struct sock *);
406 };
407
408 enum {
409 BT_SK_DEFER_SETUP,
410 BT_SK_SUSPEND,
411 BT_SK_PKT_STATUS,
412 BT_SK_PKT_SEQNUM,
413 };
414
415 struct bt_sock_list {
416 struct hlist_head head;
417 rwlock_t lock;
418 #ifdef CONFIG_PROC_FS
419 int (* custom_seq_show)(struct seq_file *, void *);
420 #endif
421 };
422
423 int bt_sock_register(int proto, const struct net_proto_family *ops);
424 void bt_sock_unregister(int proto);
425 void bt_sock_link(struct bt_sock_list *l, struct sock *s);
426 void bt_sock_unlink(struct bt_sock_list *l, struct sock *s);
427 bool bt_sock_linked(struct bt_sock_list *l, struct sock *s);
428 struct sock *bt_sock_alloc(struct net *net, struct socket *sock,
429 struct proto *prot, int proto, gfp_t prio, int kern);
430 int bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
431 int flags);
432 int bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg,
433 size_t len, int flags);
434 __poll_t bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait);
435 int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
436 int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
437 int bt_sock_wait_ready(struct sock *sk, unsigned int msg_flags);
438
439 void bt_accept_enqueue(struct sock *parent, struct sock *sk, bool bh);
440 void bt_accept_unlink(struct sock *sk);
441 struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock);
442
443 /* Skb helpers */
444 struct l2cap_ctrl {
445 u8 sframe:1,
446 poll:1,
447 final:1,
448 fcs:1,
449 sar:2,
450 super:2;
451
452 u16 reqseq;
453 u16 txseq;
454 u8 retries;
455 __le16 psm;
456 bdaddr_t bdaddr;
457 struct l2cap_chan *chan;
458 };
459
460 struct hci_dev;
461
462 typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);
463 typedef void (*hci_req_complete_skb_t)(struct hci_dev *hdev, u8 status,
464 u16 opcode, struct sk_buff *skb);
465
466 void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status,
467 hci_req_complete_t *req_complete,
468 hci_req_complete_skb_t *req_complete_skb);
469
470 int hci_ethtool_ts_info(unsigned int index, int sk_proto,
471 struct kernel_ethtool_ts_info *ts_info);
472
473 #define HCI_REQ_START BIT(0)
474 #define HCI_REQ_SKB BIT(1)
475
476 struct hci_ctrl {
477 struct sock *sk;
478 u16 opcode;
479 u8 req_flags;
480 u8 req_event;
481 union {
482 hci_req_complete_t req_complete;
483 hci_req_complete_skb_t req_complete_skb;
484 };
485 };
486
487 struct mgmt_ctrl {
488 struct hci_dev *hdev;
489 u16 opcode;
490 };
491
492 struct bt_skb_cb {
493 u8 pkt_type;
494 u8 force_active;
495 u16 expect;
496 u16 pkt_seqnum;
497 u8 incoming:1;
498 u8 pkt_status:2;
499 union {
500 struct l2cap_ctrl l2cap;
501 struct hci_ctrl hci;
502 struct mgmt_ctrl mgmt;
503 struct scm_creds creds;
504 };
505 };
506 #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
507
508 #define hci_skb_pkt_type(skb) bt_cb((skb))->pkt_type
509 #define hci_skb_pkt_status(skb) bt_cb((skb))->pkt_status
510 #define hci_skb_pkt_seqnum(skb) bt_cb((skb))->pkt_seqnum
511 #define hci_skb_expect(skb) bt_cb((skb))->expect
512 #define hci_skb_opcode(skb) bt_cb((skb))->hci.opcode
513 #define hci_skb_event(skb) bt_cb((skb))->hci.req_event
514 #define hci_skb_sk(skb) bt_cb((skb))->hci.sk
515
bt_skb_alloc(unsigned int len,gfp_t how)516 static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how)
517 {
518 struct sk_buff *skb;
519
520 skb = alloc_skb(len + BT_SKB_RESERVE, how);
521 if (skb)
522 skb_reserve(skb, BT_SKB_RESERVE);
523 return skb;
524 }
525
bt_skb_send_alloc(struct sock * sk,unsigned long len,int nb,int * err)526 static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk,
527 unsigned long len, int nb, int *err)
528 {
529 struct sk_buff *skb;
530
531 skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err);
532 if (skb)
533 skb_reserve(skb, BT_SKB_RESERVE);
534
535 if (!skb && *err)
536 return NULL;
537
538 *err = sock_error(sk);
539 if (*err)
540 goto out;
541
542 if (sk->sk_shutdown) {
543 *err = -ECONNRESET;
544 goto out;
545 }
546
547 return skb;
548
549 out:
550 kfree_skb(skb);
551 return NULL;
552 }
553
554 /* Shall not be called with lock_sock held */
bt_skb_sendmsg(struct sock * sk,struct msghdr * msg,size_t len,size_t mtu,size_t headroom,size_t tailroom)555 static inline struct sk_buff *bt_skb_sendmsg(struct sock *sk,
556 struct msghdr *msg,
557 size_t len, size_t mtu,
558 size_t headroom, size_t tailroom)
559 {
560 struct sk_buff *skb;
561 size_t size = min_t(size_t, len, mtu);
562 int err;
563
564 skb = bt_skb_send_alloc(sk, size + headroom + tailroom,
565 msg->msg_flags & MSG_DONTWAIT, &err);
566 if (!skb)
567 return ERR_PTR(err);
568
569 skb_reserve(skb, headroom);
570 skb_tailroom_reserve(skb, mtu, tailroom);
571
572 if (!copy_from_iter_full(skb_put(skb, size), size, &msg->msg_iter)) {
573 kfree_skb(skb);
574 return ERR_PTR(-EFAULT);
575 }
576
577 skb->priority = READ_ONCE(sk->sk_priority);
578
579 return skb;
580 }
581
582 /* Similar to bt_skb_sendmsg but can split the msg into multiple fragments
583 * accourding to the MTU.
584 */
bt_skb_sendmmsg(struct sock * sk,struct msghdr * msg,size_t len,size_t mtu,size_t headroom,size_t tailroom)585 static inline struct sk_buff *bt_skb_sendmmsg(struct sock *sk,
586 struct msghdr *msg,
587 size_t len, size_t mtu,
588 size_t headroom, size_t tailroom)
589 {
590 struct sk_buff *skb, **frag;
591
592 skb = bt_skb_sendmsg(sk, msg, len, mtu, headroom, tailroom);
593 if (IS_ERR(skb))
594 return skb;
595
596 len -= skb->len;
597 if (!len)
598 return skb;
599
600 /* Add remaining data over MTU as continuation fragments */
601 frag = &skb_shinfo(skb)->frag_list;
602 while (len) {
603 struct sk_buff *tmp;
604
605 tmp = bt_skb_sendmsg(sk, msg, len, mtu, headroom, tailroom);
606 if (IS_ERR(tmp)) {
607 return skb;
608 }
609
610 len -= tmp->len;
611
612 *frag = tmp;
613 frag = &(*frag)->next;
614 }
615
616 return skb;
617 }
618
619 int bt_to_errno(u16 code);
620 __u8 bt_status(int err);
621
622 void hci_sock_set_flag(struct sock *sk, int nr);
623 void hci_sock_clear_flag(struct sock *sk, int nr);
624 int hci_sock_test_flag(struct sock *sk, int nr);
625 unsigned short hci_sock_get_channel(struct sock *sk);
626 u32 hci_sock_get_cookie(struct sock *sk);
627
628 int hci_sock_init(void);
629 void hci_sock_cleanup(void);
630
631 int bt_sysfs_init(void);
632 void bt_sysfs_cleanup(void);
633
634 int bt_procfs_init(struct net *net, const char *name,
635 struct bt_sock_list *sk_list,
636 int (*seq_show)(struct seq_file *, void *));
637 void bt_procfs_cleanup(struct net *net, const char *name);
638
639 extern struct dentry *bt_debugfs;
640
641 int l2cap_init(void);
642 void l2cap_exit(void);
643
644 #if IS_ENABLED(CONFIG_BT_BREDR)
645 int sco_init(void);
646 void sco_exit(void);
647 #else
sco_init(void)648 static inline int sco_init(void)
649 {
650 return 0;
651 }
652
sco_exit(void)653 static inline void sco_exit(void)
654 {
655 }
656 #endif
657
658 #if IS_ENABLED(CONFIG_BT_LE)
659 int iso_init(void);
660 int iso_exit(void);
661 bool iso_inited(void);
662 #else
iso_init(void)663 static inline int iso_init(void)
664 {
665 return 0;
666 }
667
iso_exit(void)668 static inline int iso_exit(void)
669 {
670 return 0;
671 }
672
iso_inited(void)673 static inline bool iso_inited(void)
674 {
675 return false;
676 }
677 #endif
678
679 int mgmt_init(void);
680 void mgmt_exit(void);
681 void mgmt_cleanup(struct sock *sk);
682
683 void bt_sock_reclassify_lock(struct sock *sk, int proto);
684
685 #endif /* __BLUETOOTH_H */
686