xref: /openbmc/linux/include/net/bluetooth/rfcomm.h (revision be21871f24b0fcd8d0d09c8090385c9cec80efa3)
11da177e4SLinus Torvalds /*
2*be21871fSAndrei 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 
241da177e4SLinus Torvalds #ifndef __RFCOMM_H
251da177e4SLinus Torvalds #define __RFCOMM_H
261da177e4SLinus Torvalds 
271da177e4SLinus Torvalds #define RFCOMM_PSM 3
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 
3756f3a40aSMarcel Holtmann #define RFCOMM_MAX_L2CAP_MTU	1013
381da177e4SLinus Torvalds #define RFCOMM_MAX_CREDITS	40
391da177e4SLinus Torvalds 
401da177e4SLinus Torvalds #define RFCOMM_SKB_HEAD_RESERVE	8
411da177e4SLinus Torvalds #define RFCOMM_SKB_TAIL_RESERVE	2
421da177e4SLinus Torvalds #define RFCOMM_SKB_RESERVE  (RFCOMM_SKB_HEAD_RESERVE + RFCOMM_SKB_TAIL_RESERVE)
431da177e4SLinus Torvalds 
441da177e4SLinus Torvalds #define RFCOMM_SABM	0x2f
451da177e4SLinus Torvalds #define RFCOMM_DISC	0x43
461da177e4SLinus Torvalds #define RFCOMM_UA	0x63
471da177e4SLinus Torvalds #define RFCOMM_DM	0x0f
481da177e4SLinus Torvalds #define RFCOMM_UIH	0xef
491da177e4SLinus Torvalds 
501da177e4SLinus Torvalds #define RFCOMM_TEST	0x08
511da177e4SLinus Torvalds #define RFCOMM_FCON	0x28
521da177e4SLinus Torvalds #define RFCOMM_FCOFF	0x18
531da177e4SLinus Torvalds #define RFCOMM_MSC	0x38
541da177e4SLinus Torvalds #define RFCOMM_RPN	0x24
551da177e4SLinus Torvalds #define RFCOMM_RLS	0x14
561da177e4SLinus Torvalds #define RFCOMM_PN	0x20
571da177e4SLinus Torvalds #define RFCOMM_NSC	0x04
581da177e4SLinus Torvalds 
591da177e4SLinus Torvalds #define RFCOMM_V24_FC	0x02
601da177e4SLinus Torvalds #define RFCOMM_V24_RTC	0x04
611da177e4SLinus Torvalds #define RFCOMM_V24_RTR	0x08
621da177e4SLinus Torvalds #define RFCOMM_V24_IC	0x40
631da177e4SLinus Torvalds #define RFCOMM_V24_DV	0x80
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds #define RFCOMM_RPN_BR_2400	0x0
661da177e4SLinus Torvalds #define RFCOMM_RPN_BR_4800	0x1
671da177e4SLinus Torvalds #define RFCOMM_RPN_BR_7200	0x2
681da177e4SLinus Torvalds #define RFCOMM_RPN_BR_9600	0x3
691da177e4SLinus Torvalds #define RFCOMM_RPN_BR_19200	0x4
701da177e4SLinus Torvalds #define RFCOMM_RPN_BR_38400	0x5
711da177e4SLinus Torvalds #define RFCOMM_RPN_BR_57600	0x6
721da177e4SLinus Torvalds #define RFCOMM_RPN_BR_115200	0x7
731da177e4SLinus Torvalds #define RFCOMM_RPN_BR_230400	0x8
741da177e4SLinus Torvalds 
751da177e4SLinus Torvalds #define RFCOMM_RPN_DATA_5	0x0
761da177e4SLinus Torvalds #define RFCOMM_RPN_DATA_6	0x1
771da177e4SLinus Torvalds #define RFCOMM_RPN_DATA_7	0x2
781da177e4SLinus Torvalds #define RFCOMM_RPN_DATA_8	0x3
791da177e4SLinus Torvalds 
801da177e4SLinus Torvalds #define RFCOMM_RPN_STOP_1	0
811da177e4SLinus Torvalds #define RFCOMM_RPN_STOP_15	1
821da177e4SLinus Torvalds 
831da177e4SLinus Torvalds #define RFCOMM_RPN_PARITY_NONE	0x0
843a5e903cSJ. Suter #define RFCOMM_RPN_PARITY_ODD	0x1
853a5e903cSJ. Suter #define RFCOMM_RPN_PARITY_EVEN	0x3
863a5e903cSJ. Suter #define RFCOMM_RPN_PARITY_MARK	0x5
871da177e4SLinus Torvalds #define RFCOMM_RPN_PARITY_SPACE	0x7
881da177e4SLinus Torvalds 
891da177e4SLinus Torvalds #define RFCOMM_RPN_FLOW_NONE	0x00
901da177e4SLinus Torvalds 
911da177e4SLinus Torvalds #define RFCOMM_RPN_XON_CHAR	0x11
921da177e4SLinus Torvalds #define RFCOMM_RPN_XOFF_CHAR	0x13
931da177e4SLinus Torvalds 
941da177e4SLinus Torvalds #define RFCOMM_RPN_PM_BITRATE		0x0001
951da177e4SLinus Torvalds #define RFCOMM_RPN_PM_DATA		0x0002
961da177e4SLinus Torvalds #define RFCOMM_RPN_PM_STOP		0x0004
971da177e4SLinus Torvalds #define RFCOMM_RPN_PM_PARITY		0x0008
981da177e4SLinus Torvalds #define RFCOMM_RPN_PM_PARITY_TYPE	0x0010
991da177e4SLinus Torvalds #define RFCOMM_RPN_PM_XON		0x0020
1001da177e4SLinus Torvalds #define RFCOMM_RPN_PM_XOFF		0x0040
1011da177e4SLinus Torvalds #define RFCOMM_RPN_PM_FLOW		0x3F00
1021da177e4SLinus Torvalds 
1031da177e4SLinus Torvalds #define RFCOMM_RPN_PM_ALL		0x3F7F
1041da177e4SLinus Torvalds 
1051da177e4SLinus Torvalds struct rfcomm_hdr {
1061da177e4SLinus Torvalds 	u8 addr;
1071da177e4SLinus Torvalds 	u8 ctrl;
108285b4e90SAndrei Emeltchenko 	u8 len;    /* Actual size can be 2 bytes */
10966c853ccSGustavo F. Padovan } __packed;
1101da177e4SLinus Torvalds 
1111da177e4SLinus Torvalds struct rfcomm_cmd {
1121da177e4SLinus Torvalds 	u8 addr;
1131da177e4SLinus Torvalds 	u8 ctrl;
1141da177e4SLinus Torvalds 	u8 len;
1151da177e4SLinus Torvalds 	u8 fcs;
11666c853ccSGustavo F. Padovan } __packed;
1171da177e4SLinus Torvalds 
1181da177e4SLinus Torvalds struct rfcomm_mcc {
1191da177e4SLinus Torvalds 	u8 type;
1201da177e4SLinus Torvalds 	u8 len;
12166c853ccSGustavo F. Padovan } __packed;
1221da177e4SLinus Torvalds 
1231da177e4SLinus Torvalds struct rfcomm_pn {
1241da177e4SLinus Torvalds 	u8  dlci;
1251da177e4SLinus Torvalds 	u8  flow_ctrl;
1261da177e4SLinus Torvalds 	u8  priority;
1271da177e4SLinus Torvalds 	u8  ack_timer;
1286ba9c755SAl Viro 	__le16 mtu;
1291da177e4SLinus Torvalds 	u8  max_retrans;
1301da177e4SLinus Torvalds 	u8  credits;
13166c853ccSGustavo F. Padovan } __packed;
1321da177e4SLinus Torvalds 
1331da177e4SLinus Torvalds struct rfcomm_rpn {
1341da177e4SLinus Torvalds 	u8  dlci;
1351da177e4SLinus Torvalds 	u8  bit_rate;
1361da177e4SLinus Torvalds 	u8  line_settings;
1371da177e4SLinus Torvalds 	u8  flow_ctrl;
1381da177e4SLinus Torvalds 	u8  xon_char;
1391da177e4SLinus Torvalds 	u8  xoff_char;
1406ba9c755SAl Viro 	__le16 param_mask;
14166c853ccSGustavo F. Padovan } __packed;
1421da177e4SLinus Torvalds 
1431da177e4SLinus Torvalds struct rfcomm_rls {
1441da177e4SLinus Torvalds 	u8  dlci;
1451da177e4SLinus Torvalds 	u8  status;
14666c853ccSGustavo F. Padovan } __packed;
1471da177e4SLinus Torvalds 
1481da177e4SLinus Torvalds struct rfcomm_msc {
1491da177e4SLinus Torvalds 	u8  dlci;
1501da177e4SLinus Torvalds 	u8  v24_sig;
15166c853ccSGustavo F. Padovan } __packed;
1521da177e4SLinus Torvalds 
1531da177e4SLinus Torvalds /* ---- Core structures, flags etc ---- */
1541da177e4SLinus Torvalds 
1551da177e4SLinus Torvalds struct rfcomm_session {
1561da177e4SLinus Torvalds 	struct list_head list;
1571da177e4SLinus Torvalds 	struct socket   *sock;
1589e726b17SLuiz Augusto von Dentz 	struct timer_list timer;
1591da177e4SLinus Torvalds 	unsigned long    state;
1601da177e4SLinus Torvalds 	unsigned long    flags;
1611da177e4SLinus Torvalds 	atomic_t         refcnt;
1621da177e4SLinus Torvalds 	int              initiator;
1631da177e4SLinus Torvalds 
1641da177e4SLinus Torvalds 	/* Default DLC parameters */
1651da177e4SLinus Torvalds 	int    cfc;
1661da177e4SLinus Torvalds 	uint   mtu;
1671da177e4SLinus Torvalds 
1681da177e4SLinus Torvalds 	struct list_head dlcs;
1691da177e4SLinus Torvalds };
1701da177e4SLinus Torvalds 
1711da177e4SLinus Torvalds struct rfcomm_dlc {
1721da177e4SLinus Torvalds 	struct list_head      list;
1731da177e4SLinus Torvalds 	struct rfcomm_session *session;
1741da177e4SLinus Torvalds 	struct sk_buff_head   tx_queue;
1751da177e4SLinus Torvalds 	struct timer_list     timer;
1761da177e4SLinus Torvalds 
1771da177e4SLinus Torvalds 	spinlock_t    lock;
1781da177e4SLinus Torvalds 	unsigned long state;
1791da177e4SLinus Torvalds 	unsigned long flags;
1801da177e4SLinus Torvalds 	atomic_t      refcnt;
1811da177e4SLinus Torvalds 	u8            dlci;
1821da177e4SLinus Torvalds 	u8            addr;
1831da177e4SLinus Torvalds 	u8            priority;
1841da177e4SLinus Torvalds 	u8            v24_sig;
1858b6b3da7SMarcel Holtmann 	u8            remote_v24_sig;
1861da177e4SLinus Torvalds 	u8            mscex;
18777db1980SMarcel Holtmann 	u8            out;
1889f2c8a03SMarcel Holtmann 	u8            sec_level;
1899f2c8a03SMarcel Holtmann 	u8            role_switch;
190bb23c0abSMarcel Holtmann 	u32           defer_setup;
1911da177e4SLinus Torvalds 
1921da177e4SLinus Torvalds 	uint          mtu;
1931da177e4SLinus Torvalds 	uint          cfc;
1941da177e4SLinus Torvalds 	uint          rx_credits;
1951da177e4SLinus Torvalds 	uint          tx_credits;
1961da177e4SLinus Torvalds 
1971da177e4SLinus Torvalds 	void          *owner;
1981da177e4SLinus Torvalds 
1991da177e4SLinus Torvalds 	void (*data_ready)(struct rfcomm_dlc *d, struct sk_buff *skb);
2001da177e4SLinus Torvalds 	void (*state_change)(struct rfcomm_dlc *d, int err);
2011da177e4SLinus Torvalds 	void (*modem_status)(struct rfcomm_dlc *d, u8 v24_sig);
2021da177e4SLinus Torvalds };
2031da177e4SLinus Torvalds 
2041da177e4SLinus Torvalds /* DLC and session flags */
2051da177e4SLinus Torvalds #define RFCOMM_RX_THROTTLED 0
2061da177e4SLinus Torvalds #define RFCOMM_TX_THROTTLED 1
2071da177e4SLinus Torvalds #define RFCOMM_TIMED_OUT    2
2081da177e4SLinus Torvalds #define RFCOMM_MSC_PENDING  3
2098c84b830SMarcel Holtmann #define RFCOMM_SEC_PENDING  4
2108c84b830SMarcel Holtmann #define RFCOMM_AUTH_PENDING 5
2118c84b830SMarcel Holtmann #define RFCOMM_AUTH_ACCEPT  6
2128c84b830SMarcel Holtmann #define RFCOMM_AUTH_REJECT  7
2138c84b830SMarcel Holtmann #define RFCOMM_DEFER_SETUP  8
2141da177e4SLinus Torvalds 
2151da177e4SLinus Torvalds /* Scheduling flags and events */
2161da177e4SLinus Torvalds #define RFCOMM_SCHED_WAKEUP 31
2171da177e4SLinus Torvalds 
2181da177e4SLinus Torvalds /* MSC exchange flags */
2191da177e4SLinus Torvalds #define RFCOMM_MSCEX_TX     1
2201da177e4SLinus Torvalds #define RFCOMM_MSCEX_RX     2
2211da177e4SLinus Torvalds #define RFCOMM_MSCEX_OK     (RFCOMM_MSCEX_TX + RFCOMM_MSCEX_RX)
2221da177e4SLinus Torvalds 
2231da177e4SLinus Torvalds /* CFC states */
2241da177e4SLinus Torvalds #define RFCOMM_CFC_UNKNOWN  -1
2251da177e4SLinus Torvalds #define RFCOMM_CFC_DISABLED 0
2261da177e4SLinus Torvalds #define RFCOMM_CFC_ENABLED  RFCOMM_MAX_CREDITS
2271da177e4SLinus Torvalds 
2283a5e903cSJ. Suter /* ---- RFCOMM SEND RPN ---- */
2293a5e903cSJ. Suter int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
2303a5e903cSJ. Suter 			u8 bit_rate, u8 data_bits, u8 stop_bits,
2313a5e903cSJ. Suter 			u8 parity, u8 flow_ctrl_settings,
2323a5e903cSJ. Suter 			u8 xon_char, u8 xoff_char, u16 param_mask);
2333a5e903cSJ. Suter 
2341da177e4SLinus Torvalds /* ---- RFCOMM DLCs (channels) ---- */
235dd0fc66fSAl Viro struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio);
2361da177e4SLinus Torvalds void rfcomm_dlc_free(struct rfcomm_dlc *d);
2371da177e4SLinus Torvalds int  rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, 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);
2401da177e4SLinus Torvalds int  rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig);
2411da177e4SLinus Torvalds int  rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig);
242bb23c0abSMarcel Holtmann void rfcomm_dlc_accept(struct rfcomm_dlc *d);
2431da177e4SLinus Torvalds 
2441da177e4SLinus Torvalds #define rfcomm_dlc_lock(d)     spin_lock(&d->lock)
2451da177e4SLinus Torvalds #define rfcomm_dlc_unlock(d)   spin_unlock(&d->lock)
2461da177e4SLinus Torvalds 
2471da177e4SLinus Torvalds static inline void rfcomm_dlc_hold(struct rfcomm_dlc *d)
2481da177e4SLinus Torvalds {
2491da177e4SLinus Torvalds 	atomic_inc(&d->refcnt);
2501da177e4SLinus Torvalds }
2511da177e4SLinus Torvalds 
2521da177e4SLinus Torvalds static inline void rfcomm_dlc_put(struct rfcomm_dlc *d)
2531da177e4SLinus Torvalds {
2541da177e4SLinus Torvalds 	if (atomic_dec_and_test(&d->refcnt))
2551da177e4SLinus Torvalds 		rfcomm_dlc_free(d);
2561da177e4SLinus Torvalds }
2571da177e4SLinus Torvalds 
25841380930SHarvey Harrison extern void __rfcomm_dlc_throttle(struct rfcomm_dlc *d);
25941380930SHarvey Harrison extern void __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d);
2601da177e4SLinus Torvalds 
2611da177e4SLinus Torvalds static inline void rfcomm_dlc_throttle(struct rfcomm_dlc *d)
2621da177e4SLinus Torvalds {
2631da177e4SLinus Torvalds 	if (!test_and_set_bit(RFCOMM_RX_THROTTLED, &d->flags))
2641da177e4SLinus Torvalds 		__rfcomm_dlc_throttle(d);
2651da177e4SLinus Torvalds }
2661da177e4SLinus Torvalds 
2671da177e4SLinus Torvalds static inline void rfcomm_dlc_unthrottle(struct rfcomm_dlc *d)
2681da177e4SLinus Torvalds {
2691da177e4SLinus Torvalds 	if (test_and_clear_bit(RFCOMM_RX_THROTTLED, &d->flags))
2701da177e4SLinus Torvalds 		__rfcomm_dlc_unthrottle(d);
2711da177e4SLinus Torvalds }
2721da177e4SLinus Torvalds 
2731da177e4SLinus Torvalds /* ---- RFCOMM sessions ---- */
2741da177e4SLinus Torvalds void   rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src, bdaddr_t *dst);
2751da177e4SLinus Torvalds 
2761da177e4SLinus Torvalds static inline void rfcomm_session_hold(struct rfcomm_session *s)
2771da177e4SLinus Torvalds {
2781da177e4SLinus Torvalds 	atomic_inc(&s->refcnt);
2791da177e4SLinus Torvalds }
2801da177e4SLinus Torvalds 
2811da177e4SLinus Torvalds /* ---- RFCOMM sockets ---- */
2821da177e4SLinus Torvalds struct sockaddr_rc {
2831da177e4SLinus Torvalds 	sa_family_t	rc_family;
2841da177e4SLinus Torvalds 	bdaddr_t	rc_bdaddr;
2851da177e4SLinus Torvalds 	u8		rc_channel;
2861da177e4SLinus Torvalds };
2871da177e4SLinus Torvalds 
2881da177e4SLinus Torvalds #define RFCOMM_CONNINFO	0x02
2891da177e4SLinus Torvalds struct rfcomm_conninfo {
2901da177e4SLinus Torvalds 	__u16 hci_handle;
2911da177e4SLinus Torvalds 	__u8  dev_class[3];
2921da177e4SLinus Torvalds };
2931da177e4SLinus Torvalds 
2941da177e4SLinus Torvalds #define RFCOMM_LM	0x03
2951da177e4SLinus Torvalds #define RFCOMM_LM_MASTER	0x0001
2961da177e4SLinus Torvalds #define RFCOMM_LM_AUTH		0x0002
2971da177e4SLinus Torvalds #define RFCOMM_LM_ENCRYPT	0x0004
2981da177e4SLinus Torvalds #define RFCOMM_LM_TRUSTED	0x0008
2991da177e4SLinus Torvalds #define RFCOMM_LM_RELIABLE	0x0010
3001da177e4SLinus Torvalds #define RFCOMM_LM_SECURE	0x0020
3011da177e4SLinus Torvalds 
3021da177e4SLinus Torvalds #define rfcomm_pi(sk) ((struct rfcomm_pinfo *) sk)
3031da177e4SLinus Torvalds 
3041da177e4SLinus Torvalds struct rfcomm_pinfo {
3051da177e4SLinus Torvalds 	struct bt_sock bt;
3061da177e4SLinus Torvalds 	struct rfcomm_dlc   *dlc;
3071da177e4SLinus Torvalds 	u8     channel;
3089f2c8a03SMarcel Holtmann 	u8     sec_level;
3099f2c8a03SMarcel Holtmann 	u8     role_switch;
3101da177e4SLinus Torvalds };
3111da177e4SLinus Torvalds 
3121da177e4SLinus Torvalds int  rfcomm_init_sockets(void);
3131da177e4SLinus Torvalds void rfcomm_cleanup_sockets(void);
3141da177e4SLinus Torvalds 
3151da177e4SLinus Torvalds int  rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc **d);
3161da177e4SLinus Torvalds 
3171da177e4SLinus Torvalds /* ---- RFCOMM TTY ---- */
3181da177e4SLinus Torvalds #define RFCOMM_MAX_DEV  256
3191da177e4SLinus Torvalds 
3201da177e4SLinus Torvalds #define RFCOMMCREATEDEV		_IOW('R', 200, int)
3211da177e4SLinus Torvalds #define RFCOMMRELEASEDEV	_IOW('R', 201, int)
3221da177e4SLinus Torvalds #define RFCOMMGETDEVLIST	_IOR('R', 210, int)
3231da177e4SLinus Torvalds #define RFCOMMGETDEVINFO	_IOR('R', 211, int)
3241da177e4SLinus Torvalds #define RFCOMMSTEALDLC		_IOW('R', 220, int)
3251da177e4SLinus Torvalds 
3261da177e4SLinus Torvalds #define RFCOMM_REUSE_DLC      0
3271da177e4SLinus Torvalds #define RFCOMM_RELEASE_ONHUP  1
3281da177e4SLinus Torvalds #define RFCOMM_HANGUP_NOW     2
3291da177e4SLinus Torvalds #define RFCOMM_TTY_ATTACHED   3
3308de0a154SVille Tervo #define RFCOMM_TTY_RELEASED   4
3311da177e4SLinus Torvalds 
3321da177e4SLinus Torvalds struct rfcomm_dev_req {
3331da177e4SLinus Torvalds 	s16      dev_id;
3341da177e4SLinus Torvalds 	u32      flags;
3351da177e4SLinus Torvalds 	bdaddr_t src;
3361da177e4SLinus Torvalds 	bdaddr_t dst;
3371da177e4SLinus Torvalds 	u8       channel;
3381da177e4SLinus Torvalds };
3391da177e4SLinus Torvalds 
3401da177e4SLinus Torvalds struct rfcomm_dev_info {
3411da177e4SLinus Torvalds 	s16      id;
3421da177e4SLinus Torvalds 	u32      flags;
3431da177e4SLinus Torvalds 	u16      state;
3441da177e4SLinus Torvalds 	bdaddr_t src;
3451da177e4SLinus Torvalds 	bdaddr_t dst;
3461da177e4SLinus Torvalds 	u8       channel;
3471da177e4SLinus Torvalds };
3481da177e4SLinus Torvalds 
3491da177e4SLinus Torvalds struct rfcomm_dev_list_req {
3501da177e4SLinus Torvalds 	u16      dev_num;
3511da177e4SLinus Torvalds 	struct   rfcomm_dev_info dev_info[0];
3521da177e4SLinus Torvalds };
3531da177e4SLinus Torvalds 
3541da177e4SLinus Torvalds int  rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
355af0d3b10SDave Young 
356af0d3b10SDave Young #ifdef CONFIG_BT_RFCOMM_TTY
3571da177e4SLinus Torvalds int  rfcomm_init_ttys(void);
3581da177e4SLinus Torvalds void rfcomm_cleanup_ttys(void);
359af0d3b10SDave Young #else
360af0d3b10SDave Young static inline int rfcomm_init_ttys(void)
361af0d3b10SDave Young {
362af0d3b10SDave Young 	return 0;
363af0d3b10SDave Young }
364af0d3b10SDave Young static inline void rfcomm_cleanup_ttys(void)
365af0d3b10SDave Young {
366af0d3b10SDave Young }
367af0d3b10SDave Young #endif
3681da177e4SLinus Torvalds #endif /* __RFCOMM_H */
369