11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds BlueZ - Bluetooth protocol stack for Linux 31da177e4SLinus Torvalds Copyright (C) 2000-2001 Qualcomm Incorporated 41da177e4SLinus Torvalds 51da177e4SLinus Torvalds Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> 61da177e4SLinus Torvalds 71da177e4SLinus Torvalds This program is free software; you can redistribute it and/or modify 81da177e4SLinus Torvalds it under the terms of the GNU General Public License version 2 as 91da177e4SLinus Torvalds published by the Free Software Foundation; 101da177e4SLinus Torvalds 111da177e4SLinus Torvalds THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 121da177e4SLinus Torvalds OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 131da177e4SLinus Torvalds FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 141da177e4SLinus Torvalds IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 151da177e4SLinus Torvalds CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 161da177e4SLinus Torvalds WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 171da177e4SLinus Torvalds ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 181da177e4SLinus Torvalds OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 191da177e4SLinus Torvalds 201da177e4SLinus Torvalds ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 211da177e4SLinus Torvalds COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 221da177e4SLinus Torvalds SOFTWARE IS DISCLAIMED. 231da177e4SLinus Torvalds */ 241da177e4SLinus Torvalds 251da177e4SLinus Torvalds #ifndef __L2CAP_H 261da177e4SLinus Torvalds #define __L2CAP_H 271da177e4SLinus Torvalds 281da177e4SLinus Torvalds /* L2CAP defaults */ 291da177e4SLinus Torvalds #define L2CAP_DEFAULT_MTU 672 30f2fcfcd6SGustavo F. Padovan #define L2CAP_DEFAULT_MIN_MTU 48 3147ec1dcdSMarcel Holtmann #define L2CAP_DEFAULT_FLUSH_TO 0xffff 321c2acffbSGustavo F. Padovan #define L2CAP_DEFAULT_TX_WINDOW 63 331c2acffbSGustavo F. Padovan #define L2CAP_DEFAULT_NUM_TO_ACK (L2CAP_DEFAULT_TX_WINDOW/5) 34*e90bac06SGustavo F. Padovan #define L2CAP_DEFAULT_MAX_TX 3 35*e90bac06SGustavo F. Padovan #define L2CAP_DEFAULT_RETRANS_TO 1000 /* 1 second */ 36*e90bac06SGustavo F. Padovan #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ 37c74e560cSGustavo F. Padovan #define L2CAP_DEFAULT_MAX_PDU_SIZE 672 381da177e4SLinus Torvalds 394e8402a3SMarcel Holtmann #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ 404e8402a3SMarcel Holtmann #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ 411da177e4SLinus Torvalds 421da177e4SLinus Torvalds /* L2CAP socket address */ 431da177e4SLinus Torvalds struct sockaddr_l2 { 441da177e4SLinus Torvalds sa_family_t l2_family; 458e036fc3SAl Viro __le16 l2_psm; 461da177e4SLinus Torvalds bdaddr_t l2_bdaddr; 47f29972deSMarcel Holtmann __le16 l2_cid; 481da177e4SLinus Torvalds }; 491da177e4SLinus Torvalds 501da177e4SLinus Torvalds /* L2CAP socket options */ 511da177e4SLinus Torvalds #define L2CAP_OPTIONS 0x01 521da177e4SLinus Torvalds struct l2cap_options { 531da177e4SLinus Torvalds __u16 omtu; 541da177e4SLinus Torvalds __u16 imtu; 551da177e4SLinus Torvalds __u16 flush_to; 561da177e4SLinus Torvalds __u8 mode; 571da177e4SLinus Torvalds }; 581da177e4SLinus Torvalds 591da177e4SLinus Torvalds #define L2CAP_CONNINFO 0x02 601da177e4SLinus Torvalds struct l2cap_conninfo { 611da177e4SLinus Torvalds __u16 hci_handle; 621da177e4SLinus Torvalds __u8 dev_class[3]; 631da177e4SLinus Torvalds }; 641da177e4SLinus Torvalds 651da177e4SLinus Torvalds #define L2CAP_LM 0x03 661da177e4SLinus Torvalds #define L2CAP_LM_MASTER 0x0001 671da177e4SLinus Torvalds #define L2CAP_LM_AUTH 0x0002 681da177e4SLinus Torvalds #define L2CAP_LM_ENCRYPT 0x0004 691da177e4SLinus Torvalds #define L2CAP_LM_TRUSTED 0x0008 701da177e4SLinus Torvalds #define L2CAP_LM_RELIABLE 0x0010 711da177e4SLinus Torvalds #define L2CAP_LM_SECURE 0x0020 721da177e4SLinus Torvalds 731da177e4SLinus Torvalds /* L2CAP command codes */ 741da177e4SLinus Torvalds #define L2CAP_COMMAND_REJ 0x01 751da177e4SLinus Torvalds #define L2CAP_CONN_REQ 0x02 761da177e4SLinus Torvalds #define L2CAP_CONN_RSP 0x03 771da177e4SLinus Torvalds #define L2CAP_CONF_REQ 0x04 781da177e4SLinus Torvalds #define L2CAP_CONF_RSP 0x05 791da177e4SLinus Torvalds #define L2CAP_DISCONN_REQ 0x06 801da177e4SLinus Torvalds #define L2CAP_DISCONN_RSP 0x07 811da177e4SLinus Torvalds #define L2CAP_ECHO_REQ 0x08 821da177e4SLinus Torvalds #define L2CAP_ECHO_RSP 0x09 831da177e4SLinus Torvalds #define L2CAP_INFO_REQ 0x0a 841da177e4SLinus Torvalds #define L2CAP_INFO_RSP 0x0b 851da177e4SLinus Torvalds 8647ec1dcdSMarcel Holtmann /* L2CAP feature mask */ 8747ec1dcdSMarcel Holtmann #define L2CAP_FEAT_FLOWCTL 0x00000001 8847ec1dcdSMarcel Holtmann #define L2CAP_FEAT_RETRANS 0x00000002 8947ec1dcdSMarcel Holtmann #define L2CAP_FEAT_ERTM 0x00000008 9047ec1dcdSMarcel Holtmann #define L2CAP_FEAT_STREAMING 0x00000010 9147ec1dcdSMarcel Holtmann #define L2CAP_FEAT_FCS 0x00000020 9247ec1dcdSMarcel Holtmann #define L2CAP_FEAT_FIXED_CHAN 0x00000080 9347ec1dcdSMarcel Holtmann 9447ec1dcdSMarcel Holtmann /* L2CAP checksum option */ 9547ec1dcdSMarcel Holtmann #define L2CAP_FCS_NONE 0x00 9647ec1dcdSMarcel Holtmann #define L2CAP_FCS_CRC16 0x01 9747ec1dcdSMarcel Holtmann 981c2acffbSGustavo F. Padovan /* L2CAP Control Field bit masks */ 991c2acffbSGustavo F. Padovan #define L2CAP_CTRL_SAR 0xC000 1001c2acffbSGustavo F. Padovan #define L2CAP_CTRL_REQSEQ 0x3F00 1011c2acffbSGustavo F. Padovan #define L2CAP_CTRL_TXSEQ 0x007E 1021c2acffbSGustavo F. Padovan #define L2CAP_CTRL_RETRANS 0x0080 1031c2acffbSGustavo F. Padovan #define L2CAP_CTRL_FINAL 0x0080 1041c2acffbSGustavo F. Padovan #define L2CAP_CTRL_POLL 0x0010 1051c2acffbSGustavo F. Padovan #define L2CAP_CTRL_SUPERVISE 0x000C 1061c2acffbSGustavo F. Padovan #define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ 1071c2acffbSGustavo F. Padovan 1081c2acffbSGustavo F. Padovan #define L2CAP_CTRL_TXSEQ_SHIFT 1 1091c2acffbSGustavo F. Padovan #define L2CAP_CTRL_REQSEQ_SHIFT 8 1101c2acffbSGustavo F. Padovan 1111c2acffbSGustavo F. Padovan /* L2CAP Supervisory Function */ 1121c2acffbSGustavo F. Padovan #define L2CAP_SUPER_RCV_READY 0x0000 1131c2acffbSGustavo F. Padovan #define L2CAP_SUPER_REJECT 0x0004 1141c2acffbSGustavo F. Padovan #define L2CAP_SUPER_RCV_NOT_READY 0x0008 1151c2acffbSGustavo F. Padovan #define L2CAP_SUPER_SELECT_REJECT 0x000C 1161c2acffbSGustavo F. Padovan 1171c2acffbSGustavo F. Padovan /* L2CAP Segmentation and Reassembly */ 1181c2acffbSGustavo F. Padovan #define L2CAP_SDU_UNSEGMENTED 0x0000 1191c2acffbSGustavo F. Padovan #define L2CAP_SDU_START 0x4000 1201c2acffbSGustavo F. Padovan #define L2CAP_SDU_END 0x8000 1211c2acffbSGustavo F. Padovan #define L2CAP_SDU_CONTINUE 0xC000 1221c2acffbSGustavo F. Padovan 1231da177e4SLinus Torvalds /* L2CAP structures */ 1241da177e4SLinus Torvalds struct l2cap_hdr { 1258e036fc3SAl Viro __le16 len; 1268e036fc3SAl Viro __le16 cid; 1271da177e4SLinus Torvalds } __attribute__ ((packed)); 1281da177e4SLinus Torvalds #define L2CAP_HDR_SIZE 4 1291da177e4SLinus Torvalds 1301da177e4SLinus Torvalds struct l2cap_cmd_hdr { 1311da177e4SLinus Torvalds __u8 code; 1321da177e4SLinus Torvalds __u8 ident; 1338e036fc3SAl Viro __le16 len; 1341da177e4SLinus Torvalds } __attribute__ ((packed)); 1351da177e4SLinus Torvalds #define L2CAP_CMD_HDR_SIZE 4 1361da177e4SLinus Torvalds 1371da177e4SLinus Torvalds struct l2cap_cmd_rej { 1388e036fc3SAl Viro __le16 reason; 1391da177e4SLinus Torvalds } __attribute__ ((packed)); 1401da177e4SLinus Torvalds 1411da177e4SLinus Torvalds struct l2cap_conn_req { 1428e036fc3SAl Viro __le16 psm; 1438e036fc3SAl Viro __le16 scid; 1441da177e4SLinus Torvalds } __attribute__ ((packed)); 1451da177e4SLinus Torvalds 1461da177e4SLinus Torvalds struct l2cap_conn_rsp { 1478e036fc3SAl Viro __le16 dcid; 1488e036fc3SAl Viro __le16 scid; 1498e036fc3SAl Viro __le16 result; 1508e036fc3SAl Viro __le16 status; 1511da177e4SLinus Torvalds } __attribute__ ((packed)); 1521da177e4SLinus Torvalds 1538db4dc46SGustavo F. Padovan /* channel indentifier */ 1548db4dc46SGustavo F. Padovan #define L2CAP_CID_SIGNALING 0x0001 1558db4dc46SGustavo F. Padovan #define L2CAP_CID_CONN_LESS 0x0002 1568db4dc46SGustavo F. Padovan #define L2CAP_CID_DYN_START 0x0040 1578db4dc46SGustavo F. Padovan #define L2CAP_CID_DYN_END 0xffff 1588db4dc46SGustavo F. Padovan 1591da177e4SLinus Torvalds /* connect result */ 1601da177e4SLinus Torvalds #define L2CAP_CR_SUCCESS 0x0000 1611da177e4SLinus Torvalds #define L2CAP_CR_PEND 0x0001 1621da177e4SLinus Torvalds #define L2CAP_CR_BAD_PSM 0x0002 1631da177e4SLinus Torvalds #define L2CAP_CR_SEC_BLOCK 0x0003 1641da177e4SLinus Torvalds #define L2CAP_CR_NO_MEM 0x0004 1651da177e4SLinus Torvalds 1661da177e4SLinus Torvalds /* connect status */ 1671da177e4SLinus Torvalds #define L2CAP_CS_NO_INFO 0x0000 1681da177e4SLinus Torvalds #define L2CAP_CS_AUTHEN_PEND 0x0001 1691da177e4SLinus Torvalds #define L2CAP_CS_AUTHOR_PEND 0x0002 1701da177e4SLinus Torvalds 1711da177e4SLinus Torvalds struct l2cap_conf_req { 1728e036fc3SAl Viro __le16 dcid; 1738e036fc3SAl Viro __le16 flags; 1741da177e4SLinus Torvalds __u8 data[0]; 1751da177e4SLinus Torvalds } __attribute__ ((packed)); 1761da177e4SLinus Torvalds 1771da177e4SLinus Torvalds struct l2cap_conf_rsp { 1788e036fc3SAl Viro __le16 scid; 1798e036fc3SAl Viro __le16 flags; 1808e036fc3SAl Viro __le16 result; 1811da177e4SLinus Torvalds __u8 data[0]; 1821da177e4SLinus Torvalds } __attribute__ ((packed)); 1831da177e4SLinus Torvalds 1845dee9e7cSMarcel Holtmann #define L2CAP_CONF_SUCCESS 0x0000 1855dee9e7cSMarcel Holtmann #define L2CAP_CONF_UNACCEPT 0x0001 1865dee9e7cSMarcel Holtmann #define L2CAP_CONF_REJECT 0x0002 1875dee9e7cSMarcel Holtmann #define L2CAP_CONF_UNKNOWN 0x0003 1881da177e4SLinus Torvalds 1891da177e4SLinus Torvalds struct l2cap_conf_opt { 1901da177e4SLinus Torvalds __u8 type; 1911da177e4SLinus Torvalds __u8 len; 1921da177e4SLinus Torvalds __u8 val[0]; 1931da177e4SLinus Torvalds } __attribute__ ((packed)); 1941da177e4SLinus Torvalds #define L2CAP_CONF_OPT_SIZE 2 1951da177e4SLinus Torvalds 196589d2746SGustavo F. Padovan #define L2CAP_CONF_HINT 0x80 19747ec1dcdSMarcel Holtmann #define L2CAP_CONF_MASK 0x7f 198589d2746SGustavo F. Padovan 1991da177e4SLinus Torvalds #define L2CAP_CONF_MTU 0x01 2001da177e4SLinus Torvalds #define L2CAP_CONF_FLUSH_TO 0x02 2011da177e4SLinus Torvalds #define L2CAP_CONF_QOS 0x03 2021da177e4SLinus Torvalds #define L2CAP_CONF_RFC 0x04 20347ec1dcdSMarcel Holtmann #define L2CAP_CONF_FCS 0x05 2041da177e4SLinus Torvalds 2051da177e4SLinus Torvalds #define L2CAP_CONF_MAX_SIZE 22 2061da177e4SLinus Torvalds 2076464f35fSMarcel Holtmann struct l2cap_conf_rfc { 2086464f35fSMarcel Holtmann __u8 mode; 2096464f35fSMarcel Holtmann __u8 txwin_size; 2106464f35fSMarcel Holtmann __u8 max_transmit; 2116464f35fSMarcel Holtmann __le16 retrans_timeout; 2126464f35fSMarcel Holtmann __le16 monitor_timeout; 2136464f35fSMarcel Holtmann __le16 max_pdu_size; 2146464f35fSMarcel Holtmann } __attribute__ ((packed)); 2156464f35fSMarcel Holtmann 2166464f35fSMarcel Holtmann #define L2CAP_MODE_BASIC 0x00 2176464f35fSMarcel Holtmann #define L2CAP_MODE_RETRANS 0x01 2186464f35fSMarcel Holtmann #define L2CAP_MODE_FLOWCTL 0x02 21947ec1dcdSMarcel Holtmann #define L2CAP_MODE_ERTM 0x03 220c6b03cf9SMarcel Holtmann #define L2CAP_MODE_STREAMING 0x04 2216464f35fSMarcel Holtmann 2221da177e4SLinus Torvalds struct l2cap_disconn_req { 2238e036fc3SAl Viro __le16 dcid; 2248e036fc3SAl Viro __le16 scid; 2251da177e4SLinus Torvalds } __attribute__ ((packed)); 2261da177e4SLinus Torvalds 2271da177e4SLinus Torvalds struct l2cap_disconn_rsp { 2288e036fc3SAl Viro __le16 dcid; 2298e036fc3SAl Viro __le16 scid; 2301da177e4SLinus Torvalds } __attribute__ ((packed)); 2311da177e4SLinus Torvalds 2321da177e4SLinus Torvalds struct l2cap_info_req { 2338e036fc3SAl Viro __le16 type; 2341da177e4SLinus Torvalds } __attribute__ ((packed)); 2351da177e4SLinus Torvalds 2361da177e4SLinus Torvalds struct l2cap_info_rsp { 2378e036fc3SAl Viro __le16 type; 2388e036fc3SAl Viro __le16 result; 2391da177e4SLinus Torvalds __u8 data[0]; 2401da177e4SLinus Torvalds } __attribute__ ((packed)); 2411da177e4SLinus Torvalds 2421da177e4SLinus Torvalds /* info type */ 2431da177e4SLinus Torvalds #define L2CAP_IT_CL_MTU 0x0001 2441da177e4SLinus Torvalds #define L2CAP_IT_FEAT_MASK 0x0002 245e1027a7cSMarcel Holtmann #define L2CAP_IT_FIXED_CHAN 0x0003 2461da177e4SLinus Torvalds 2471da177e4SLinus Torvalds /* info result */ 2481da177e4SLinus Torvalds #define L2CAP_IR_SUCCESS 0x0000 2491da177e4SLinus Torvalds #define L2CAP_IR_NOTSUPP 0x0001 2501da177e4SLinus Torvalds 2511da177e4SLinus Torvalds /* ----- L2CAP connections ----- */ 2521da177e4SLinus Torvalds struct l2cap_chan_list { 2531da177e4SLinus Torvalds struct sock *head; 2541da177e4SLinus Torvalds rwlock_t lock; 2551da177e4SLinus Torvalds long num; 2561da177e4SLinus Torvalds }; 2571da177e4SLinus Torvalds 2581da177e4SLinus Torvalds struct l2cap_conn { 2591da177e4SLinus Torvalds struct hci_conn *hcon; 2601da177e4SLinus Torvalds 2611da177e4SLinus Torvalds bdaddr_t *dst; 2621da177e4SLinus Torvalds bdaddr_t *src; 2631da177e4SLinus Torvalds 2641da177e4SLinus Torvalds unsigned int mtu; 2651da177e4SLinus Torvalds 2664e8402a3SMarcel Holtmann __u32 feat_mask; 2674e8402a3SMarcel Holtmann 2684e8402a3SMarcel Holtmann __u8 info_state; 2694e8402a3SMarcel Holtmann __u8 info_ident; 2704e8402a3SMarcel Holtmann 2714e8402a3SMarcel Holtmann struct timer_list info_timer; 2724e8402a3SMarcel Holtmann 2731da177e4SLinus Torvalds spinlock_t lock; 2741da177e4SLinus Torvalds 2751da177e4SLinus Torvalds struct sk_buff *rx_skb; 2761da177e4SLinus Torvalds __u32 rx_len; 2771da177e4SLinus Torvalds __u8 rx_ident; 2781da177e4SLinus Torvalds __u8 tx_ident; 2791da177e4SLinus Torvalds 2802950f21aSMarcel Holtmann __u8 disc_reason; 2812950f21aSMarcel Holtmann 2821da177e4SLinus Torvalds struct l2cap_chan_list chan_list; 2831da177e4SLinus Torvalds }; 2841da177e4SLinus Torvalds 2854e8402a3SMarcel Holtmann #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 286984947dcSMarcel Holtmann #define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 287984947dcSMarcel Holtmann #define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 2884e8402a3SMarcel Holtmann 2891da177e4SLinus Torvalds /* ----- L2CAP channel and socket info ----- */ 2901da177e4SLinus Torvalds #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) 2911c2acffbSGustavo F. Padovan #define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue) 2921da177e4SLinus Torvalds 2931da177e4SLinus Torvalds struct l2cap_pinfo { 2941da177e4SLinus Torvalds struct bt_sock bt; 2958e036fc3SAl Viro __le16 psm; 2961da177e4SLinus Torvalds __u16 dcid; 2971da177e4SLinus Torvalds __u16 scid; 2981da177e4SLinus Torvalds 2991da177e4SLinus Torvalds __u16 imtu; 3001da177e4SLinus Torvalds __u16 omtu; 3011da177e4SLinus Torvalds __u16 flush_to; 302c6b03cf9SMarcel Holtmann __u8 mode; 303f2fcfcd6SGustavo F. Padovan __u8 num_conf_req; 304f2fcfcd6SGustavo F. Padovan __u8 num_conf_rsp; 305f2fcfcd6SGustavo F. Padovan 306c6b03cf9SMarcel Holtmann __u8 fcs; 3072af6b9d5SMarcel Holtmann __u8 sec_level; 3082af6b9d5SMarcel Holtmann __u8 role_switch; 3092af6b9d5SMarcel Holtmann __u8 force_reliable; 3101da177e4SLinus Torvalds 3115dee9e7cSMarcel Holtmann __u8 conf_req[64]; 3125dee9e7cSMarcel Holtmann __u8 conf_len; 3131da177e4SLinus Torvalds __u8 conf_state; 314c74e560cSGustavo F. Padovan __u8 conn_state; 3151da177e4SLinus Torvalds 3161c2acffbSGustavo F. Padovan __u8 next_tx_seq; 3171c2acffbSGustavo F. Padovan __u8 expected_ack_seq; 3181c2acffbSGustavo F. Padovan __u8 req_seq; 3191c2acffbSGustavo F. Padovan __u8 expected_tx_seq; 3201c2acffbSGustavo F. Padovan __u8 unacked_frames; 321*e90bac06SGustavo F. Padovan __u8 retry_count; 3221c2acffbSGustavo F. Padovan __u8 num_to_ack; 323c74e560cSGustavo F. Padovan __u16 sdu_len; 324c74e560cSGustavo F. Padovan __u16 partial_sdu_len; 325c74e560cSGustavo F. Padovan struct sk_buff *sdu; 3261c2acffbSGustavo F. Padovan 3271da177e4SLinus Torvalds __u8 ident; 3281da177e4SLinus Torvalds 329f2fcfcd6SGustavo F. Padovan __u8 remote_tx_win; 330f2fcfcd6SGustavo F. Padovan __u8 remote_max_tx; 331f2fcfcd6SGustavo F. Padovan __u16 retrans_timeout; 332f2fcfcd6SGustavo F. Padovan __u16 monitor_timeout; 333f2fcfcd6SGustavo F. Padovan __u16 max_pdu_size; 334f2fcfcd6SGustavo F. Padovan 3358e036fc3SAl Viro __le16 sport; 3361da177e4SLinus Torvalds 337*e90bac06SGustavo F. Padovan struct timer_list retrans_timer; 338*e90bac06SGustavo F. Padovan struct timer_list monitor_timer; 3391c2acffbSGustavo F. Padovan struct sk_buff_head tx_queue; 3401da177e4SLinus Torvalds struct l2cap_conn *conn; 3411da177e4SLinus Torvalds struct sock *next_c; 3421da177e4SLinus Torvalds struct sock *prev_c; 3431da177e4SLinus Torvalds }; 3441da177e4SLinus Torvalds 3451da177e4SLinus Torvalds #define L2CAP_CONF_REQ_SENT 0x01 3461da177e4SLinus Torvalds #define L2CAP_CONF_INPUT_DONE 0x02 3471da177e4SLinus Torvalds #define L2CAP_CONF_OUTPUT_DONE 0x04 348f2fcfcd6SGustavo F. Padovan #define L2CAP_CONF_MTU_DONE 0x08 349f2fcfcd6SGustavo F. Padovan #define L2CAP_CONF_MODE_DONE 0x10 350f2fcfcd6SGustavo F. Padovan #define L2CAP_CONF_CONNECT_PEND 0x20 351f2fcfcd6SGustavo F. Padovan #define L2CAP_CONF_STATE2_DEVICE 0x80 352861d6882SMarcel Holtmann 353f2fcfcd6SGustavo F. Padovan #define L2CAP_CONF_MAX_CONF_REQ 2 354f2fcfcd6SGustavo F. Padovan #define L2CAP_CONF_MAX_CONF_RSP 2 355f2fcfcd6SGustavo F. Padovan 356c74e560cSGustavo F. Padovan #define L2CAP_CONN_SAR_SDU 0x01 35730afb5b2SGustavo F. Padovan #define L2CAP_CONN_UNDER_REJ 0x02 358*e90bac06SGustavo F. Padovan #define L2CAP_CONN_WAIT_F 0x04 359*e90bac06SGustavo F. Padovan 360*e90bac06SGustavo F. Padovan #define __mod_retrans_timer() mod_timer(&l2cap_pi(sk)->retrans_timer, \ 361*e90bac06SGustavo F. Padovan jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); 362*e90bac06SGustavo F. Padovan #define __mod_monitor_timer() mod_timer(&l2cap_pi(sk)->monitor_timer, \ 363*e90bac06SGustavo F. Padovan jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); 364c74e560cSGustavo F. Padovan 3651c2acffbSGustavo F. Padovan static inline int l2cap_tx_window_full(struct sock *sk) 3661c2acffbSGustavo F. Padovan { 3671c2acffbSGustavo F. Padovan struct l2cap_pinfo *pi = l2cap_pi(sk); 3681c2acffbSGustavo F. Padovan int sub; 3691c2acffbSGustavo F. Padovan 3701c2acffbSGustavo F. Padovan sub = (pi->next_tx_seq - pi->expected_ack_seq) % 64; 3711c2acffbSGustavo F. Padovan 3721c2acffbSGustavo F. Padovan if (sub < 0) 3731c2acffbSGustavo F. Padovan sub += 64; 3741c2acffbSGustavo F. Padovan 3751c2acffbSGustavo F. Padovan return (sub == pi->remote_tx_win); 3761c2acffbSGustavo F. Padovan } 3771c2acffbSGustavo F. Padovan 3781c2acffbSGustavo F. Padovan #define __get_txseq(ctrl) ((ctrl) & L2CAP_CTRL_TXSEQ) >> 1 3791c2acffbSGustavo F. Padovan #define __get_reqseq(ctrl) ((ctrl) & L2CAP_CTRL_REQSEQ) >> 8 3801c2acffbSGustavo F. Padovan #define __is_iframe(ctrl) !((ctrl) & L2CAP_CTRL_FRAME_TYPE) 3811c2acffbSGustavo F. Padovan #define __is_sframe(ctrl) (ctrl) & L2CAP_CTRL_FRAME_TYPE 382c74e560cSGustavo F. Padovan #define __is_sar_start(ctrl) ((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START 3831da177e4SLinus Torvalds 3841da177e4SLinus Torvalds void l2cap_load(void); 3851da177e4SLinus Torvalds 3861da177e4SLinus Torvalds #endif /* __L2CAP_H */ 387