18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci RFCOMM implementation for Linux Bluetooth stack (BlueZ) 38c2ecf20Sopenharmony_ci Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com> 48c2ecf20Sopenharmony_ci Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org> 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci This program is free software; you can redistribute it and/or modify 78c2ecf20Sopenharmony_ci it under the terms of the GNU General Public License version 2 as 88c2ecf20Sopenharmony_ci published by the Free Software Foundation; 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 118c2ecf20Sopenharmony_ci OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 128c2ecf20Sopenharmony_ci FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 138c2ecf20Sopenharmony_ci IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 148c2ecf20Sopenharmony_ci CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 158c2ecf20Sopenharmony_ci WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 168c2ecf20Sopenharmony_ci ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 178c2ecf20Sopenharmony_ci OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 208c2ecf20Sopenharmony_ci COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 218c2ecf20Sopenharmony_ci SOFTWARE IS DISCLAIMED. 228c2ecf20Sopenharmony_ci*/ 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#include <linux/refcount.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#ifndef __RFCOMM_H 278c2ecf20Sopenharmony_ci#define __RFCOMM_H 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define RFCOMM_CONN_TIMEOUT (HZ * 30) 308c2ecf20Sopenharmony_ci#define RFCOMM_DISC_TIMEOUT (HZ * 20) 318c2ecf20Sopenharmony_ci#define RFCOMM_AUTH_TIMEOUT (HZ * 25) 328c2ecf20Sopenharmony_ci#define RFCOMM_IDLE_TIMEOUT (HZ * 2) 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define RFCOMM_DEFAULT_MTU 127 358c2ecf20Sopenharmony_ci#define RFCOMM_DEFAULT_CREDITS 7 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define RFCOMM_MAX_CREDITS 40 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define RFCOMM_SKB_HEAD_RESERVE 8 408c2ecf20Sopenharmony_ci#define RFCOMM_SKB_TAIL_RESERVE 2 418c2ecf20Sopenharmony_ci#define RFCOMM_SKB_RESERVE (RFCOMM_SKB_HEAD_RESERVE + RFCOMM_SKB_TAIL_RESERVE) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define RFCOMM_SABM 0x2f 448c2ecf20Sopenharmony_ci#define RFCOMM_DISC 0x43 458c2ecf20Sopenharmony_ci#define RFCOMM_UA 0x63 468c2ecf20Sopenharmony_ci#define RFCOMM_DM 0x0f 478c2ecf20Sopenharmony_ci#define RFCOMM_UIH 0xef 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#define RFCOMM_TEST 0x08 508c2ecf20Sopenharmony_ci#define RFCOMM_FCON 0x28 518c2ecf20Sopenharmony_ci#define RFCOMM_FCOFF 0x18 528c2ecf20Sopenharmony_ci#define RFCOMM_MSC 0x38 538c2ecf20Sopenharmony_ci#define RFCOMM_RPN 0x24 548c2ecf20Sopenharmony_ci#define RFCOMM_RLS 0x14 558c2ecf20Sopenharmony_ci#define RFCOMM_PN 0x20 568c2ecf20Sopenharmony_ci#define RFCOMM_NSC 0x04 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define RFCOMM_V24_FC 0x02 598c2ecf20Sopenharmony_ci#define RFCOMM_V24_RTC 0x04 608c2ecf20Sopenharmony_ci#define RFCOMM_V24_RTR 0x08 618c2ecf20Sopenharmony_ci#define RFCOMM_V24_IC 0x40 628c2ecf20Sopenharmony_ci#define RFCOMM_V24_DV 0x80 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define RFCOMM_RPN_BR_2400 0x0 658c2ecf20Sopenharmony_ci#define RFCOMM_RPN_BR_4800 0x1 668c2ecf20Sopenharmony_ci#define RFCOMM_RPN_BR_7200 0x2 678c2ecf20Sopenharmony_ci#define RFCOMM_RPN_BR_9600 0x3 688c2ecf20Sopenharmony_ci#define RFCOMM_RPN_BR_19200 0x4 698c2ecf20Sopenharmony_ci#define RFCOMM_RPN_BR_38400 0x5 708c2ecf20Sopenharmony_ci#define RFCOMM_RPN_BR_57600 0x6 718c2ecf20Sopenharmony_ci#define RFCOMM_RPN_BR_115200 0x7 728c2ecf20Sopenharmony_ci#define RFCOMM_RPN_BR_230400 0x8 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define RFCOMM_RPN_DATA_5 0x0 758c2ecf20Sopenharmony_ci#define RFCOMM_RPN_DATA_6 0x1 768c2ecf20Sopenharmony_ci#define RFCOMM_RPN_DATA_7 0x2 778c2ecf20Sopenharmony_ci#define RFCOMM_RPN_DATA_8 0x3 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci#define RFCOMM_RPN_STOP_1 0 808c2ecf20Sopenharmony_ci#define RFCOMM_RPN_STOP_15 1 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PARITY_NONE 0x0 838c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PARITY_ODD 0x1 848c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PARITY_EVEN 0x3 858c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PARITY_MARK 0x5 868c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PARITY_SPACE 0x7 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define RFCOMM_RPN_FLOW_NONE 0x00 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define RFCOMM_RPN_XON_CHAR 0x11 918c2ecf20Sopenharmony_ci#define RFCOMM_RPN_XOFF_CHAR 0x13 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PM_BITRATE 0x0001 948c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PM_DATA 0x0002 958c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PM_STOP 0x0004 968c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PM_PARITY 0x0008 978c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PM_PARITY_TYPE 0x0010 988c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PM_XON 0x0020 998c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PM_XOFF 0x0040 1008c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PM_FLOW 0x3F00 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define RFCOMM_RPN_PM_ALL 0x3F7F 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistruct rfcomm_hdr { 1058c2ecf20Sopenharmony_ci u8 addr; 1068c2ecf20Sopenharmony_ci u8 ctrl; 1078c2ecf20Sopenharmony_ci u8 len; /* Actual size can be 2 bytes */ 1088c2ecf20Sopenharmony_ci} __packed; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_cistruct rfcomm_cmd { 1118c2ecf20Sopenharmony_ci u8 addr; 1128c2ecf20Sopenharmony_ci u8 ctrl; 1138c2ecf20Sopenharmony_ci u8 len; 1148c2ecf20Sopenharmony_ci u8 fcs; 1158c2ecf20Sopenharmony_ci} __packed; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cistruct rfcomm_mcc { 1188c2ecf20Sopenharmony_ci u8 type; 1198c2ecf20Sopenharmony_ci u8 len; 1208c2ecf20Sopenharmony_ci} __packed; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistruct rfcomm_pn { 1238c2ecf20Sopenharmony_ci u8 dlci; 1248c2ecf20Sopenharmony_ci u8 flow_ctrl; 1258c2ecf20Sopenharmony_ci u8 priority; 1268c2ecf20Sopenharmony_ci u8 ack_timer; 1278c2ecf20Sopenharmony_ci __le16 mtu; 1288c2ecf20Sopenharmony_ci u8 max_retrans; 1298c2ecf20Sopenharmony_ci u8 credits; 1308c2ecf20Sopenharmony_ci} __packed; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cistruct rfcomm_rpn { 1338c2ecf20Sopenharmony_ci u8 dlci; 1348c2ecf20Sopenharmony_ci u8 bit_rate; 1358c2ecf20Sopenharmony_ci u8 line_settings; 1368c2ecf20Sopenharmony_ci u8 flow_ctrl; 1378c2ecf20Sopenharmony_ci u8 xon_char; 1388c2ecf20Sopenharmony_ci u8 xoff_char; 1398c2ecf20Sopenharmony_ci __le16 param_mask; 1408c2ecf20Sopenharmony_ci} __packed; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cistruct rfcomm_rls { 1438c2ecf20Sopenharmony_ci u8 dlci; 1448c2ecf20Sopenharmony_ci u8 status; 1458c2ecf20Sopenharmony_ci} __packed; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cistruct rfcomm_msc { 1488c2ecf20Sopenharmony_ci u8 dlci; 1498c2ecf20Sopenharmony_ci u8 v24_sig; 1508c2ecf20Sopenharmony_ci} __packed; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci/* ---- Core structures, flags etc ---- */ 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_cistruct rfcomm_session { 1558c2ecf20Sopenharmony_ci struct list_head list; 1568c2ecf20Sopenharmony_ci struct socket *sock; 1578c2ecf20Sopenharmony_ci struct timer_list timer; 1588c2ecf20Sopenharmony_ci unsigned long state; 1598c2ecf20Sopenharmony_ci unsigned long flags; 1608c2ecf20Sopenharmony_ci int initiator; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci /* Default DLC parameters */ 1638c2ecf20Sopenharmony_ci int cfc; 1648c2ecf20Sopenharmony_ci uint mtu; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci struct list_head dlcs; 1678c2ecf20Sopenharmony_ci}; 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_cistruct rfcomm_dlc { 1708c2ecf20Sopenharmony_ci struct list_head list; 1718c2ecf20Sopenharmony_ci struct rfcomm_session *session; 1728c2ecf20Sopenharmony_ci struct sk_buff_head tx_queue; 1738c2ecf20Sopenharmony_ci struct timer_list timer; 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci struct mutex lock; 1768c2ecf20Sopenharmony_ci unsigned long state; 1778c2ecf20Sopenharmony_ci unsigned long flags; 1788c2ecf20Sopenharmony_ci refcount_t refcnt; 1798c2ecf20Sopenharmony_ci u8 dlci; 1808c2ecf20Sopenharmony_ci u8 addr; 1818c2ecf20Sopenharmony_ci u8 priority; 1828c2ecf20Sopenharmony_ci u8 v24_sig; 1838c2ecf20Sopenharmony_ci u8 remote_v24_sig; 1848c2ecf20Sopenharmony_ci u8 mscex; 1858c2ecf20Sopenharmony_ci u8 out; 1868c2ecf20Sopenharmony_ci u8 sec_level; 1878c2ecf20Sopenharmony_ci u8 role_switch; 1888c2ecf20Sopenharmony_ci u32 defer_setup; 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci uint mtu; 1918c2ecf20Sopenharmony_ci uint cfc; 1928c2ecf20Sopenharmony_ci uint rx_credits; 1938c2ecf20Sopenharmony_ci uint tx_credits; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci void *owner; 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci void (*data_ready)(struct rfcomm_dlc *d, struct sk_buff *skb); 1988c2ecf20Sopenharmony_ci void (*state_change)(struct rfcomm_dlc *d, int err); 1998c2ecf20Sopenharmony_ci void (*modem_status)(struct rfcomm_dlc *d, u8 v24_sig); 2008c2ecf20Sopenharmony_ci}; 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci/* DLC and session flags */ 2038c2ecf20Sopenharmony_ci#define RFCOMM_RX_THROTTLED 0 2048c2ecf20Sopenharmony_ci#define RFCOMM_TX_THROTTLED 1 2058c2ecf20Sopenharmony_ci#define RFCOMM_TIMED_OUT 2 2068c2ecf20Sopenharmony_ci#define RFCOMM_MSC_PENDING 3 2078c2ecf20Sopenharmony_ci#define RFCOMM_SEC_PENDING 4 2088c2ecf20Sopenharmony_ci#define RFCOMM_AUTH_PENDING 5 2098c2ecf20Sopenharmony_ci#define RFCOMM_AUTH_ACCEPT 6 2108c2ecf20Sopenharmony_ci#define RFCOMM_AUTH_REJECT 7 2118c2ecf20Sopenharmony_ci#define RFCOMM_DEFER_SETUP 8 2128c2ecf20Sopenharmony_ci#define RFCOMM_ENC_DROP 9 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci/* Scheduling flags and events */ 2158c2ecf20Sopenharmony_ci#define RFCOMM_SCHED_WAKEUP 31 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci/* MSC exchange flags */ 2188c2ecf20Sopenharmony_ci#define RFCOMM_MSCEX_TX 1 2198c2ecf20Sopenharmony_ci#define RFCOMM_MSCEX_RX 2 2208c2ecf20Sopenharmony_ci#define RFCOMM_MSCEX_OK (RFCOMM_MSCEX_TX + RFCOMM_MSCEX_RX) 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci/* CFC states */ 2238c2ecf20Sopenharmony_ci#define RFCOMM_CFC_UNKNOWN -1 2248c2ecf20Sopenharmony_ci#define RFCOMM_CFC_DISABLED 0 2258c2ecf20Sopenharmony_ci#define RFCOMM_CFC_ENABLED RFCOMM_MAX_CREDITS 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci/* ---- RFCOMM SEND RPN ---- */ 2288c2ecf20Sopenharmony_ciint rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, 2298c2ecf20Sopenharmony_ci u8 bit_rate, u8 data_bits, u8 stop_bits, 2308c2ecf20Sopenharmony_ci u8 parity, u8 flow_ctrl_settings, 2318c2ecf20Sopenharmony_ci u8 xon_char, u8 xoff_char, u16 param_mask); 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci/* ---- RFCOMM DLCs (channels) ---- */ 2348c2ecf20Sopenharmony_cistruct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio); 2358c2ecf20Sopenharmony_civoid rfcomm_dlc_free(struct rfcomm_dlc *d); 2368c2ecf20Sopenharmony_ciint rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, 2378c2ecf20Sopenharmony_ci u8 channel); 2388c2ecf20Sopenharmony_ciint rfcomm_dlc_close(struct rfcomm_dlc *d, int reason); 2398c2ecf20Sopenharmony_ciint rfcomm_dlc_send(struct rfcomm_dlc *d, struct sk_buff *skb); 2408c2ecf20Sopenharmony_civoid rfcomm_dlc_send_noerror(struct rfcomm_dlc *d, struct sk_buff *skb); 2418c2ecf20Sopenharmony_ciint rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig); 2428c2ecf20Sopenharmony_ciint rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig); 2438c2ecf20Sopenharmony_civoid rfcomm_dlc_accept(struct rfcomm_dlc *d); 2448c2ecf20Sopenharmony_cistruct rfcomm_dlc *rfcomm_dlc_exists(bdaddr_t *src, bdaddr_t *dst, u8 channel); 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci#define rfcomm_dlc_lock(d) mutex_lock(&d->lock) 2478c2ecf20Sopenharmony_ci#define rfcomm_dlc_unlock(d) mutex_unlock(&d->lock) 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_cistatic inline void rfcomm_dlc_hold(struct rfcomm_dlc *d) 2508c2ecf20Sopenharmony_ci{ 2518c2ecf20Sopenharmony_ci refcount_inc(&d->refcnt); 2528c2ecf20Sopenharmony_ci} 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_cistatic inline void rfcomm_dlc_put(struct rfcomm_dlc *d) 2558c2ecf20Sopenharmony_ci{ 2568c2ecf20Sopenharmony_ci if (refcount_dec_and_test(&d->refcnt)) 2578c2ecf20Sopenharmony_ci rfcomm_dlc_free(d); 2588c2ecf20Sopenharmony_ci} 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_civoid __rfcomm_dlc_throttle(struct rfcomm_dlc *d); 2618c2ecf20Sopenharmony_civoid __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d); 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_cistatic inline void rfcomm_dlc_throttle(struct rfcomm_dlc *d) 2648c2ecf20Sopenharmony_ci{ 2658c2ecf20Sopenharmony_ci if (!test_and_set_bit(RFCOMM_RX_THROTTLED, &d->flags)) 2668c2ecf20Sopenharmony_ci __rfcomm_dlc_throttle(d); 2678c2ecf20Sopenharmony_ci} 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_cistatic inline void rfcomm_dlc_unthrottle(struct rfcomm_dlc *d) 2708c2ecf20Sopenharmony_ci{ 2718c2ecf20Sopenharmony_ci if (test_and_clear_bit(RFCOMM_RX_THROTTLED, &d->flags)) 2728c2ecf20Sopenharmony_ci __rfcomm_dlc_unthrottle(d); 2738c2ecf20Sopenharmony_ci} 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci/* ---- RFCOMM sessions ---- */ 2768c2ecf20Sopenharmony_civoid rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src, 2778c2ecf20Sopenharmony_ci bdaddr_t *dst); 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci/* ---- RFCOMM sockets ---- */ 2808c2ecf20Sopenharmony_cistruct sockaddr_rc { 2818c2ecf20Sopenharmony_ci sa_family_t rc_family; 2828c2ecf20Sopenharmony_ci bdaddr_t rc_bdaddr; 2838c2ecf20Sopenharmony_ci u8 rc_channel; 2848c2ecf20Sopenharmony_ci}; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci#define RFCOMM_CONNINFO 0x02 2878c2ecf20Sopenharmony_cistruct rfcomm_conninfo { 2888c2ecf20Sopenharmony_ci __u16 hci_handle; 2898c2ecf20Sopenharmony_ci __u8 dev_class[3]; 2908c2ecf20Sopenharmony_ci}; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci#define RFCOMM_LM 0x03 2938c2ecf20Sopenharmony_ci#define RFCOMM_LM_MASTER 0x0001 2948c2ecf20Sopenharmony_ci#define RFCOMM_LM_AUTH 0x0002 2958c2ecf20Sopenharmony_ci#define RFCOMM_LM_ENCRYPT 0x0004 2968c2ecf20Sopenharmony_ci#define RFCOMM_LM_TRUSTED 0x0008 2978c2ecf20Sopenharmony_ci#define RFCOMM_LM_RELIABLE 0x0010 2988c2ecf20Sopenharmony_ci#define RFCOMM_LM_SECURE 0x0020 2998c2ecf20Sopenharmony_ci#define RFCOMM_LM_FIPS 0x0040 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci#define rfcomm_pi(sk) ((struct rfcomm_pinfo *) sk) 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_cistruct rfcomm_pinfo { 3048c2ecf20Sopenharmony_ci struct bt_sock bt; 3058c2ecf20Sopenharmony_ci bdaddr_t src; 3068c2ecf20Sopenharmony_ci bdaddr_t dst; 3078c2ecf20Sopenharmony_ci struct rfcomm_dlc *dlc; 3088c2ecf20Sopenharmony_ci u8 channel; 3098c2ecf20Sopenharmony_ci u8 sec_level; 3108c2ecf20Sopenharmony_ci u8 role_switch; 3118c2ecf20Sopenharmony_ci}; 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ciint rfcomm_init_sockets(void); 3148c2ecf20Sopenharmony_civoid rfcomm_cleanup_sockets(void); 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ciint rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, 3178c2ecf20Sopenharmony_ci struct rfcomm_dlc **d); 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci/* ---- RFCOMM TTY ---- */ 3208c2ecf20Sopenharmony_ci#define RFCOMM_MAX_DEV 256 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci#define RFCOMMCREATEDEV _IOW('R', 200, int) 3238c2ecf20Sopenharmony_ci#define RFCOMMRELEASEDEV _IOW('R', 201, int) 3248c2ecf20Sopenharmony_ci#define RFCOMMGETDEVLIST _IOR('R', 210, int) 3258c2ecf20Sopenharmony_ci#define RFCOMMGETDEVINFO _IOR('R', 211, int) 3268c2ecf20Sopenharmony_ci#define RFCOMMSTEALDLC _IOW('R', 220, int) 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci/* rfcomm_dev.flags bit definitions */ 3298c2ecf20Sopenharmony_ci#define RFCOMM_REUSE_DLC 0 3308c2ecf20Sopenharmony_ci#define RFCOMM_RELEASE_ONHUP 1 3318c2ecf20Sopenharmony_ci#define RFCOMM_HANGUP_NOW 2 3328c2ecf20Sopenharmony_ci#define RFCOMM_TTY_ATTACHED 3 3338c2ecf20Sopenharmony_ci#define RFCOMM_DEFUNCT_BIT4 4 /* don't reuse this bit - userspace visible */ 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci/* rfcomm_dev.status bit definitions */ 3368c2ecf20Sopenharmony_ci#define RFCOMM_DEV_RELEASED 0 3378c2ecf20Sopenharmony_ci#define RFCOMM_TTY_OWNED 1 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_cistruct rfcomm_dev_req { 3408c2ecf20Sopenharmony_ci s16 dev_id; 3418c2ecf20Sopenharmony_ci u32 flags; 3428c2ecf20Sopenharmony_ci bdaddr_t src; 3438c2ecf20Sopenharmony_ci bdaddr_t dst; 3448c2ecf20Sopenharmony_ci u8 channel; 3458c2ecf20Sopenharmony_ci}; 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_cistruct rfcomm_dev_info { 3488c2ecf20Sopenharmony_ci s16 id; 3498c2ecf20Sopenharmony_ci u32 flags; 3508c2ecf20Sopenharmony_ci u16 state; 3518c2ecf20Sopenharmony_ci bdaddr_t src; 3528c2ecf20Sopenharmony_ci bdaddr_t dst; 3538c2ecf20Sopenharmony_ci u8 channel; 3548c2ecf20Sopenharmony_ci}; 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_cistruct rfcomm_dev_list_req { 3578c2ecf20Sopenharmony_ci u16 dev_num; 3588c2ecf20Sopenharmony_ci struct rfcomm_dev_info dev_info[]; 3598c2ecf20Sopenharmony_ci}; 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ciint rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci#ifdef CONFIG_BT_RFCOMM_TTY 3648c2ecf20Sopenharmony_ciint rfcomm_init_ttys(void); 3658c2ecf20Sopenharmony_civoid rfcomm_cleanup_ttys(void); 3668c2ecf20Sopenharmony_ci#else 3678c2ecf20Sopenharmony_cistatic inline int rfcomm_init_ttys(void) 3688c2ecf20Sopenharmony_ci{ 3698c2ecf20Sopenharmony_ci return 0; 3708c2ecf20Sopenharmony_ci} 3718c2ecf20Sopenharmony_cistatic inline void rfcomm_cleanup_ttys(void) 3728c2ecf20Sopenharmony_ci{ 3738c2ecf20Sopenharmony_ci} 3748c2ecf20Sopenharmony_ci#endif 3758c2ecf20Sopenharmony_ci#endif /* __RFCOMM_H */ 376