11da177e4SLinus Torvalds /*
2be21871fSAndrei Emeltchenko RFCOMM implementation for Linux Bluetooth stack (BlueZ)
31da177e4SLinus Torvalds Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
41da177e4SLinus Torvalds Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org>
51da177e4SLinus Torvalds
61da177e4SLinus Torvalds This program is free software; you can redistribute it and/or modify
71da177e4SLinus Torvalds it under the terms of the GNU General Public License version 2 as
81da177e4SLinus Torvalds published by the Free Software Foundation;
91da177e4SLinus Torvalds
101da177e4SLinus Torvalds THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
111da177e4SLinus Torvalds OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
121da177e4SLinus Torvalds FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
131da177e4SLinus Torvalds IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
141da177e4SLinus Torvalds CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
151da177e4SLinus Torvalds WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
161da177e4SLinus Torvalds ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
171da177e4SLinus Torvalds OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
181da177e4SLinus Torvalds
191da177e4SLinus Torvalds ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
201da177e4SLinus Torvalds COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
211da177e4SLinus Torvalds SOFTWARE IS DISCLAIMED.
221da177e4SLinus Torvalds */
231da177e4SLinus Torvalds
24dab6b5daSElena Reshetova #include <linux/refcount.h>
25dab6b5daSElena Reshetova
261da177e4SLinus Torvalds #ifndef __RFCOMM_H
271da177e4SLinus Torvalds #define __RFCOMM_H
281da177e4SLinus Torvalds
291da177e4SLinus Torvalds #define RFCOMM_CONN_TIMEOUT (HZ * 30)
301da177e4SLinus Torvalds #define RFCOMM_DISC_TIMEOUT (HZ * 20)
311da177e4SLinus Torvalds #define RFCOMM_AUTH_TIMEOUT (HZ * 25)
329e726b17SLuiz Augusto von Dentz #define RFCOMM_IDLE_TIMEOUT (HZ * 2)
331da177e4SLinus Torvalds
341da177e4SLinus Torvalds #define RFCOMM_DEFAULT_MTU 127
351da177e4SLinus Torvalds #define RFCOMM_DEFAULT_CREDITS 7
361da177e4SLinus Torvalds
371da177e4SLinus Torvalds #define RFCOMM_MAX_CREDITS 40
381da177e4SLinus Torvalds
391da177e4SLinus Torvalds #define RFCOMM_SKB_HEAD_RESERVE 8
401da177e4SLinus Torvalds #define RFCOMM_SKB_TAIL_RESERVE 2
411da177e4SLinus Torvalds #define RFCOMM_SKB_RESERVE (RFCOMM_SKB_HEAD_RESERVE + RFCOMM_SKB_TAIL_RESERVE)
421da177e4SLinus Torvalds
431da177e4SLinus Torvalds #define RFCOMM_SABM 0x2f
441da177e4SLinus Torvalds #define RFCOMM_DISC 0x43
451da177e4SLinus Torvalds #define RFCOMM_UA 0x63
461da177e4SLinus Torvalds #define RFCOMM_DM 0x0f
471da177e4SLinus Torvalds #define RFCOMM_UIH 0xef
481da177e4SLinus Torvalds
491da177e4SLinus Torvalds #define RFCOMM_TEST 0x08
501da177e4SLinus Torvalds #define RFCOMM_FCON 0x28
511da177e4SLinus Torvalds #define RFCOMM_FCOFF 0x18
521da177e4SLinus Torvalds #define RFCOMM_MSC 0x38
531da177e4SLinus Torvalds #define RFCOMM_RPN 0x24
541da177e4SLinus Torvalds #define RFCOMM_RLS 0x14
551da177e4SLinus Torvalds #define RFCOMM_PN 0x20
561da177e4SLinus Torvalds #define RFCOMM_NSC 0x04
571da177e4SLinus Torvalds
581da177e4SLinus Torvalds #define RFCOMM_V24_FC 0x02
591da177e4SLinus Torvalds #define RFCOMM_V24_RTC 0x04
601da177e4SLinus Torvalds #define RFCOMM_V24_RTR 0x08
611da177e4SLinus Torvalds #define RFCOMM_V24_IC 0x40
621da177e4SLinus Torvalds #define RFCOMM_V24_DV 0x80
631da177e4SLinus Torvalds
641da177e4SLinus Torvalds #define RFCOMM_RPN_BR_2400 0x0
651da177e4SLinus Torvalds #define RFCOMM_RPN_BR_4800 0x1
661da177e4SLinus Torvalds #define RFCOMM_RPN_BR_7200 0x2
671da177e4SLinus Torvalds #define RFCOMM_RPN_BR_9600 0x3
681da177e4SLinus Torvalds #define RFCOMM_RPN_BR_19200 0x4
691da177e4SLinus Torvalds #define RFCOMM_RPN_BR_38400 0x5
701da177e4SLinus Torvalds #define RFCOMM_RPN_BR_57600 0x6
711da177e4SLinus Torvalds #define RFCOMM_RPN_BR_115200 0x7
721da177e4SLinus Torvalds #define RFCOMM_RPN_BR_230400 0x8
731da177e4SLinus Torvalds
741da177e4SLinus Torvalds #define RFCOMM_RPN_DATA_5 0x0
751da177e4SLinus Torvalds #define RFCOMM_RPN_DATA_6 0x1
761da177e4SLinus Torvalds #define RFCOMM_RPN_DATA_7 0x2
771da177e4SLinus Torvalds #define RFCOMM_RPN_DATA_8 0x3
781da177e4SLinus Torvalds
791da177e4SLinus Torvalds #define RFCOMM_RPN_STOP_1 0
801da177e4SLinus Torvalds #define RFCOMM_RPN_STOP_15 1
811da177e4SLinus Torvalds
821da177e4SLinus Torvalds #define RFCOMM_RPN_PARITY_NONE 0x0
833a5e903cSJ. Suter #define RFCOMM_RPN_PARITY_ODD 0x1
843a5e903cSJ. Suter #define RFCOMM_RPN_PARITY_EVEN 0x3
853a5e903cSJ. Suter #define RFCOMM_RPN_PARITY_MARK 0x5
861da177e4SLinus Torvalds #define RFCOMM_RPN_PARITY_SPACE 0x7
871da177e4SLinus Torvalds
881da177e4SLinus Torvalds #define RFCOMM_RPN_FLOW_NONE 0x00
891da177e4SLinus Torvalds
901da177e4SLinus Torvalds #define RFCOMM_RPN_XON_CHAR 0x11
911da177e4SLinus Torvalds #define RFCOMM_RPN_XOFF_CHAR 0x13
921da177e4SLinus Torvalds
931da177e4SLinus Torvalds #define RFCOMM_RPN_PM_BITRATE 0x0001
941da177e4SLinus Torvalds #define RFCOMM_RPN_PM_DATA 0x0002
951da177e4SLinus Torvalds #define RFCOMM_RPN_PM_STOP 0x0004
961da177e4SLinus Torvalds #define RFCOMM_RPN_PM_PARITY 0x0008
971da177e4SLinus Torvalds #define RFCOMM_RPN_PM_PARITY_TYPE 0x0010
981da177e4SLinus Torvalds #define RFCOMM_RPN_PM_XON 0x0020
991da177e4SLinus Torvalds #define RFCOMM_RPN_PM_XOFF 0x0040
1001da177e4SLinus Torvalds #define RFCOMM_RPN_PM_FLOW 0x3F00
1011da177e4SLinus Torvalds
1021da177e4SLinus Torvalds #define RFCOMM_RPN_PM_ALL 0x3F7F
1031da177e4SLinus Torvalds
1041da177e4SLinus Torvalds struct rfcomm_hdr {
1051da177e4SLinus Torvalds u8 addr;
1061da177e4SLinus Torvalds u8 ctrl;
107285b4e90SAndrei Emeltchenko u8 len; /* Actual size can be 2 bytes */
10866c853ccSGustavo F. Padovan } __packed;
1091da177e4SLinus Torvalds
1101da177e4SLinus Torvalds struct rfcomm_cmd {
1111da177e4SLinus Torvalds u8 addr;
1121da177e4SLinus Torvalds u8 ctrl;
1131da177e4SLinus Torvalds u8 len;
1141da177e4SLinus Torvalds u8 fcs;
11566c853ccSGustavo F. Padovan } __packed;
1161da177e4SLinus Torvalds
1171da177e4SLinus Torvalds struct rfcomm_mcc {
1181da177e4SLinus Torvalds u8 type;
1191da177e4SLinus Torvalds u8 len;
12066c853ccSGustavo F. Padovan } __packed;
1211da177e4SLinus Torvalds
1221da177e4SLinus Torvalds struct rfcomm_pn {
1231da177e4SLinus Torvalds u8 dlci;
1241da177e4SLinus Torvalds u8 flow_ctrl;
1251da177e4SLinus Torvalds u8 priority;
1261da177e4SLinus Torvalds u8 ack_timer;
1276ba9c755SAl Viro __le16 mtu;
1281da177e4SLinus Torvalds u8 max_retrans;
1291da177e4SLinus Torvalds u8 credits;
13066c853ccSGustavo F. Padovan } __packed;
1311da177e4SLinus Torvalds
1321da177e4SLinus Torvalds struct rfcomm_rpn {
1331da177e4SLinus Torvalds u8 dlci;
1341da177e4SLinus Torvalds u8 bit_rate;
1351da177e4SLinus Torvalds u8 line_settings;
1361da177e4SLinus Torvalds u8 flow_ctrl;
1371da177e4SLinus Torvalds u8 xon_char;
1381da177e4SLinus Torvalds u8 xoff_char;
1396ba9c755SAl Viro __le16 param_mask;
14066c853ccSGustavo F. Padovan } __packed;
1411da177e4SLinus Torvalds
1421da177e4SLinus Torvalds struct rfcomm_rls {
1431da177e4SLinus Torvalds u8 dlci;
1441da177e4SLinus Torvalds u8 status;
14566c853ccSGustavo F. Padovan } __packed;
1461da177e4SLinus Torvalds
1471da177e4SLinus Torvalds struct rfcomm_msc {
1481da177e4SLinus Torvalds u8 dlci;
1491da177e4SLinus Torvalds u8 v24_sig;
15066c853ccSGustavo F. Padovan } __packed;
1511da177e4SLinus Torvalds
1521da177e4SLinus Torvalds /* ---- Core structures, flags etc ---- */
1531da177e4SLinus Torvalds
1541da177e4SLinus Torvalds struct rfcomm_session {
1551da177e4SLinus Torvalds struct list_head list;
1561da177e4SLinus Torvalds struct socket *sock;
1579e726b17SLuiz Augusto von Dentz struct timer_list timer;
1581da177e4SLinus Torvalds unsigned long state;
1591da177e4SLinus Torvalds unsigned long flags;
1601da177e4SLinus Torvalds int initiator;
1611da177e4SLinus Torvalds
1621da177e4SLinus Torvalds /* Default DLC parameters */
1631da177e4SLinus Torvalds int cfc;
1641da177e4SLinus Torvalds uint mtu;
1651da177e4SLinus Torvalds
1661da177e4SLinus Torvalds struct list_head dlcs;
1671da177e4SLinus Torvalds };
1681da177e4SLinus Torvalds
1691da177e4SLinus Torvalds struct rfcomm_dlc {
1701da177e4SLinus Torvalds struct list_head list;
1711da177e4SLinus Torvalds struct rfcomm_session *session;
1721da177e4SLinus Torvalds struct sk_buff_head tx_queue;
1731da177e4SLinus Torvalds struct timer_list timer;
1741da177e4SLinus Torvalds
17586aae6c7SLibor Pechacek struct mutex lock;
1761da177e4SLinus Torvalds unsigned long state;
1771da177e4SLinus Torvalds unsigned long flags;
178dab6b5daSElena Reshetova refcount_t refcnt;
1791da177e4SLinus Torvalds u8 dlci;
1801da177e4SLinus Torvalds u8 addr;
1811da177e4SLinus Torvalds u8 priority;
1821da177e4SLinus Torvalds u8 v24_sig;
1838b6b3da7SMarcel Holtmann u8 remote_v24_sig;
1841da177e4SLinus Torvalds u8 mscex;
18577db1980SMarcel Holtmann u8 out;
1869f2c8a03SMarcel Holtmann u8 sec_level;
1879f2c8a03SMarcel Holtmann u8 role_switch;
188bb23c0abSMarcel Holtmann u32 defer_setup;
1891da177e4SLinus Torvalds
1901da177e4SLinus Torvalds uint mtu;
1911da177e4SLinus Torvalds uint cfc;
1921da177e4SLinus Torvalds uint rx_credits;
1931da177e4SLinus Torvalds uint tx_credits;
1941da177e4SLinus Torvalds
1951da177e4SLinus Torvalds void *owner;
1961da177e4SLinus Torvalds
1971da177e4SLinus Torvalds void (*data_ready)(struct rfcomm_dlc *d, struct sk_buff *skb);
1981da177e4SLinus Torvalds void (*state_change)(struct rfcomm_dlc *d, int err);
1991da177e4SLinus Torvalds void (*modem_status)(struct rfcomm_dlc *d, u8 v24_sig);
2001da177e4SLinus Torvalds };
2011da177e4SLinus Torvalds
2021da177e4SLinus Torvalds /* DLC and session flags */
2031da177e4SLinus Torvalds #define RFCOMM_RX_THROTTLED 0
2041da177e4SLinus Torvalds #define RFCOMM_TX_THROTTLED 1
2051da177e4SLinus Torvalds #define RFCOMM_TIMED_OUT 2
2061da177e4SLinus Torvalds #define RFCOMM_MSC_PENDING 3
2078c84b830SMarcel Holtmann #define RFCOMM_SEC_PENDING 4
2088c84b830SMarcel Holtmann #define RFCOMM_AUTH_PENDING 5
2098c84b830SMarcel Holtmann #define RFCOMM_AUTH_ACCEPT 6
2108c84b830SMarcel Holtmann #define RFCOMM_AUTH_REJECT 7
2118c84b830SMarcel Holtmann #define RFCOMM_DEFER_SETUP 8
21288149db4SSzymon Janc #define RFCOMM_ENC_DROP 9
2131da177e4SLinus Torvalds
2141da177e4SLinus Torvalds /* Scheduling flags and events */
2151da177e4SLinus Torvalds #define RFCOMM_SCHED_WAKEUP 31
2161da177e4SLinus Torvalds
2171da177e4SLinus Torvalds /* MSC exchange flags */
2181da177e4SLinus Torvalds #define RFCOMM_MSCEX_TX 1
2191da177e4SLinus Torvalds #define RFCOMM_MSCEX_RX 2
2201da177e4SLinus Torvalds #define RFCOMM_MSCEX_OK (RFCOMM_MSCEX_TX + RFCOMM_MSCEX_RX)
2211da177e4SLinus Torvalds
2221da177e4SLinus Torvalds /* CFC states */
2231da177e4SLinus Torvalds #define RFCOMM_CFC_UNKNOWN -1
2241da177e4SLinus Torvalds #define RFCOMM_CFC_DISABLED 0
2251da177e4SLinus Torvalds #define RFCOMM_CFC_ENABLED RFCOMM_MAX_CREDITS
2261da177e4SLinus Torvalds
2273a5e903cSJ. Suter /* ---- RFCOMM SEND RPN ---- */
2283a5e903cSJ. Suter int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
2293a5e903cSJ. Suter u8 bit_rate, u8 data_bits, u8 stop_bits,
2303a5e903cSJ. Suter u8 parity, u8 flow_ctrl_settings,
2313a5e903cSJ. Suter u8 xon_char, u8 xoff_char, u16 param_mask);
2323a5e903cSJ. Suter
2331da177e4SLinus Torvalds /* ---- RFCOMM DLCs (channels) ---- */
234dd0fc66fSAl Viro struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio);
2351da177e4SLinus Torvalds void rfcomm_dlc_free(struct rfcomm_dlc *d);
2365a9d0a3fSWaldemar Rymarkiewicz int rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst,
2375a9d0a3fSWaldemar Rymarkiewicz u8 channel);
2381da177e4SLinus Torvalds int rfcomm_dlc_close(struct rfcomm_dlc *d, int reason);
2391da177e4SLinus Torvalds int rfcomm_dlc_send(struct rfcomm_dlc *d, struct sk_buff *skb);
24072e5108cSPeter Hurley void rfcomm_dlc_send_noerror(struct rfcomm_dlc *d, struct sk_buff *skb);
2411da177e4SLinus Torvalds int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig);
2421da177e4SLinus Torvalds int rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig);
243bb23c0abSMarcel Holtmann void rfcomm_dlc_accept(struct rfcomm_dlc *d);
244c10a848cSPeter Hurley struct rfcomm_dlc *rfcomm_dlc_exists(bdaddr_t *src, bdaddr_t *dst, u8 channel);
2451da177e4SLinus Torvalds
24686aae6c7SLibor Pechacek #define rfcomm_dlc_lock(d) mutex_lock(&d->lock)
24786aae6c7SLibor Pechacek #define rfcomm_dlc_unlock(d) mutex_unlock(&d->lock)
2481da177e4SLinus Torvalds
rfcomm_dlc_hold(struct rfcomm_dlc * d)2491da177e4SLinus Torvalds static inline void rfcomm_dlc_hold(struct rfcomm_dlc *d)
2501da177e4SLinus Torvalds {
251dab6b5daSElena Reshetova refcount_inc(&d->refcnt);
2521da177e4SLinus Torvalds }
2531da177e4SLinus Torvalds
rfcomm_dlc_put(struct rfcomm_dlc * d)2541da177e4SLinus Torvalds static inline void rfcomm_dlc_put(struct rfcomm_dlc *d)
2551da177e4SLinus Torvalds {
256dab6b5daSElena Reshetova if (refcount_dec_and_test(&d->refcnt))
2571da177e4SLinus Torvalds rfcomm_dlc_free(d);
2581da177e4SLinus Torvalds }
2591da177e4SLinus Torvalds
260e74e58f8SJoe Perches void __rfcomm_dlc_throttle(struct rfcomm_dlc *d);
261e74e58f8SJoe Perches void __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d);
2621da177e4SLinus Torvalds
rfcomm_dlc_throttle(struct rfcomm_dlc * d)2631da177e4SLinus Torvalds static inline void rfcomm_dlc_throttle(struct rfcomm_dlc *d)
2641da177e4SLinus Torvalds {
2651da177e4SLinus Torvalds if (!test_and_set_bit(RFCOMM_RX_THROTTLED, &d->flags))
2661da177e4SLinus Torvalds __rfcomm_dlc_throttle(d);
2671da177e4SLinus Torvalds }
2681da177e4SLinus Torvalds
rfcomm_dlc_unthrottle(struct rfcomm_dlc * d)2691da177e4SLinus Torvalds static inline void rfcomm_dlc_unthrottle(struct rfcomm_dlc *d)
2701da177e4SLinus Torvalds {
2711da177e4SLinus Torvalds if (test_and_clear_bit(RFCOMM_RX_THROTTLED, &d->flags))
2721da177e4SLinus Torvalds __rfcomm_dlc_unthrottle(d);
2731da177e4SLinus Torvalds }
2741da177e4SLinus Torvalds
2751da177e4SLinus Torvalds /* ---- RFCOMM sessions ---- */
2765a9d0a3fSWaldemar Rymarkiewicz void rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src,
2775a9d0a3fSWaldemar Rymarkiewicz bdaddr_t *dst);
2781da177e4SLinus Torvalds
2791da177e4SLinus Torvalds /* ---- RFCOMM sockets ---- */
2801da177e4SLinus Torvalds struct sockaddr_rc {
2811da177e4SLinus Torvalds sa_family_t rc_family;
2821da177e4SLinus Torvalds bdaddr_t rc_bdaddr;
2831da177e4SLinus Torvalds u8 rc_channel;
2841da177e4SLinus Torvalds };
2851da177e4SLinus Torvalds
2861da177e4SLinus Torvalds #define RFCOMM_CONNINFO 0x02
2871da177e4SLinus Torvalds struct rfcomm_conninfo {
2881da177e4SLinus Torvalds __u16 hci_handle;
2891da177e4SLinus Torvalds __u8 dev_class[3];
2901da177e4SLinus Torvalds };
2911da177e4SLinus Torvalds
2921da177e4SLinus Torvalds #define RFCOMM_LM 0x03
2931da177e4SLinus Torvalds #define RFCOMM_LM_MASTER 0x0001
2941da177e4SLinus Torvalds #define RFCOMM_LM_AUTH 0x0002
2951da177e4SLinus Torvalds #define RFCOMM_LM_ENCRYPT 0x0004
2961da177e4SLinus Torvalds #define RFCOMM_LM_TRUSTED 0x0008
2971da177e4SLinus Torvalds #define RFCOMM_LM_RELIABLE 0x0010
2981da177e4SLinus Torvalds #define RFCOMM_LM_SECURE 0x0020
2992c068e0bSMarcel Holtmann #define RFCOMM_LM_FIPS 0x0040
3001da177e4SLinus Torvalds
3011da177e4SLinus Torvalds #define rfcomm_pi(sk) ((struct rfcomm_pinfo *) sk)
3021da177e4SLinus Torvalds
3031da177e4SLinus Torvalds struct rfcomm_pinfo {
3041da177e4SLinus Torvalds struct bt_sock bt;
30594a86df0SMarcel Holtmann bdaddr_t src;
30694a86df0SMarcel Holtmann bdaddr_t dst;
3071da177e4SLinus Torvalds struct rfcomm_dlc *dlc;
3081da177e4SLinus Torvalds u8 channel;
3099f2c8a03SMarcel Holtmann u8 sec_level;
3109f2c8a03SMarcel Holtmann u8 role_switch;
3111da177e4SLinus Torvalds };
3121da177e4SLinus Torvalds
3131da177e4SLinus Torvalds int rfcomm_init_sockets(void);
3141da177e4SLinus Torvalds void rfcomm_cleanup_sockets(void);
3151da177e4SLinus Torvalds
3165a9d0a3fSWaldemar Rymarkiewicz int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel,
3175a9d0a3fSWaldemar Rymarkiewicz struct rfcomm_dlc **d);
3181da177e4SLinus Torvalds
3191da177e4SLinus Torvalds /* ---- RFCOMM TTY ---- */
3201da177e4SLinus Torvalds #define RFCOMM_MAX_DEV 256
3211da177e4SLinus Torvalds
3221da177e4SLinus Torvalds #define RFCOMMCREATEDEV _IOW('R', 200, int)
3231da177e4SLinus Torvalds #define RFCOMMRELEASEDEV _IOW('R', 201, int)
3241da177e4SLinus Torvalds #define RFCOMMGETDEVLIST _IOR('R', 210, int)
3251da177e4SLinus Torvalds #define RFCOMMGETDEVINFO _IOR('R', 211, int)
3261da177e4SLinus Torvalds #define RFCOMMSTEALDLC _IOW('R', 220, int)
3271da177e4SLinus Torvalds
3281c64834eSPeter Hurley /* rfcomm_dev.flags bit definitions */
3291da177e4SLinus Torvalds #define RFCOMM_REUSE_DLC 0
3301da177e4SLinus Torvalds #define RFCOMM_RELEASE_ONHUP 1
3311da177e4SLinus Torvalds #define RFCOMM_HANGUP_NOW 2
3321da177e4SLinus Torvalds #define RFCOMM_TTY_ATTACHED 3
3331c64834eSPeter Hurley #define RFCOMM_DEFUNCT_BIT4 4 /* don't reuse this bit - userspace visible */
3341c64834eSPeter Hurley
3351c64834eSPeter Hurley /* rfcomm_dev.status bit definitions */
3361c64834eSPeter Hurley #define RFCOMM_DEV_RELEASED 0
33780ea7337SPeter Hurley #define RFCOMM_TTY_OWNED 1
3381da177e4SLinus Torvalds
3391da177e4SLinus Torvalds struct rfcomm_dev_req {
3401da177e4SLinus Torvalds s16 dev_id;
3411da177e4SLinus Torvalds u32 flags;
3421da177e4SLinus Torvalds bdaddr_t src;
3431da177e4SLinus Torvalds bdaddr_t dst;
3441da177e4SLinus Torvalds u8 channel;
3451da177e4SLinus Torvalds };
3461da177e4SLinus Torvalds
3471da177e4SLinus Torvalds struct rfcomm_dev_info {
3481da177e4SLinus Torvalds s16 id;
3491da177e4SLinus Torvalds u32 flags;
3501da177e4SLinus Torvalds u16 state;
3511da177e4SLinus Torvalds bdaddr_t src;
3521da177e4SLinus Torvalds bdaddr_t dst;
3531da177e4SLinus Torvalds u8 channel;
3541da177e4SLinus Torvalds };
3551da177e4SLinus Torvalds
3561da177e4SLinus Torvalds struct rfcomm_dev_list_req {
3571da177e4SLinus Torvalds u16 dev_num;
358*a7e45454SGustavo A. R. Silva struct rfcomm_dev_info dev_info[];
3591da177e4SLinus Torvalds };
3601da177e4SLinus Torvalds
3611da177e4SLinus Torvalds int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
362af0d3b10SDave Young
363af0d3b10SDave Young #ifdef CONFIG_BT_RFCOMM_TTY
3641da177e4SLinus Torvalds int rfcomm_init_ttys(void);
3651da177e4SLinus Torvalds void rfcomm_cleanup_ttys(void);
366af0d3b10SDave Young #else
rfcomm_init_ttys(void)367af0d3b10SDave Young static inline int rfcomm_init_ttys(void)
368af0d3b10SDave Young {
369af0d3b10SDave Young return 0;
370af0d3b10SDave Young }
rfcomm_cleanup_ttys(void)371af0d3b10SDave Young static inline void rfcomm_cleanup_ttys(void)
372af0d3b10SDave Young {
373af0d3b10SDave Young }
374af0d3b10SDave Young #endif
3751da177e4SLinus Torvalds #endif /* __RFCOMM_H */
376