2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation;
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED.
29 #define L2CAP_DEFAULT_MTU 672
30 #define L2CAP_DEFAULT_FLUSH_TO 0xFFFF
32 #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */
33 #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */
35 /* L2CAP socket address */
37 sa_family_t l2_family;
43 /* L2CAP socket options */
44 #define L2CAP_OPTIONS 0x01
45 struct l2cap_options {
52 #define L2CAP_CONNINFO 0x02
53 struct l2cap_conninfo {
59 #define L2CAP_LM_MASTER 0x0001
60 #define L2CAP_LM_AUTH 0x0002
61 #define L2CAP_LM_ENCRYPT 0x0004
62 #define L2CAP_LM_TRUSTED 0x0008
63 #define L2CAP_LM_RELIABLE 0x0010
64 #define L2CAP_LM_SECURE 0x0020
66 /* L2CAP command codes */
67 #define L2CAP_COMMAND_REJ 0x01
68 #define L2CAP_CONN_REQ 0x02
69 #define L2CAP_CONN_RSP 0x03
70 #define L2CAP_CONF_REQ 0x04
71 #define L2CAP_CONF_RSP 0x05
72 #define L2CAP_DISCONN_REQ 0x06
73 #define L2CAP_DISCONN_RSP 0x07
74 #define L2CAP_ECHO_REQ 0x08
75 #define L2CAP_ECHO_RSP 0x09
76 #define L2CAP_INFO_REQ 0x0a
77 #define L2CAP_INFO_RSP 0x0b
79 /* L2CAP structures */
83 } __attribute__ ((packed));
84 #define L2CAP_HDR_SIZE 4
86 struct l2cap_cmd_hdr {
90 } __attribute__ ((packed));
91 #define L2CAP_CMD_HDR_SIZE 4
93 struct l2cap_cmd_rej {
95 } __attribute__ ((packed));
97 struct l2cap_conn_req {
100 } __attribute__ ((packed));
102 struct l2cap_conn_rsp {
107 } __attribute__ ((packed));
109 /* channel indentifier */
110 #define L2CAP_CID_SIGNALING 0x0001
111 #define L2CAP_CID_CONN_LESS 0x0002
112 #define L2CAP_CID_DYN_START 0x0040
113 #define L2CAP_CID_DYN_END 0xffff
116 #define L2CAP_CR_SUCCESS 0x0000
117 #define L2CAP_CR_PEND 0x0001
118 #define L2CAP_CR_BAD_PSM 0x0002
119 #define L2CAP_CR_SEC_BLOCK 0x0003
120 #define L2CAP_CR_NO_MEM 0x0004
123 #define L2CAP_CS_NO_INFO 0x0000
124 #define L2CAP_CS_AUTHEN_PEND 0x0001
125 #define L2CAP_CS_AUTHOR_PEND 0x0002
127 struct l2cap_conf_req {
131 } __attribute__ ((packed));
133 struct l2cap_conf_rsp {
138 } __attribute__ ((packed));
140 #define L2CAP_CONF_SUCCESS 0x0000
141 #define L2CAP_CONF_UNACCEPT 0x0001
142 #define L2CAP_CONF_REJECT 0x0002
143 #define L2CAP_CONF_UNKNOWN 0x0003
145 struct l2cap_conf_opt {
149 } __attribute__ ((packed));
150 #define L2CAP_CONF_OPT_SIZE 2
152 #define L2CAP_CONF_HINT 0x80
154 #define L2CAP_CONF_MTU 0x01
155 #define L2CAP_CONF_FLUSH_TO 0x02
156 #define L2CAP_CONF_QOS 0x03
157 #define L2CAP_CONF_RFC 0x04
159 #define L2CAP_CONF_MAX_SIZE 22
161 struct l2cap_conf_rfc {
165 __le16 retrans_timeout;
166 __le16 monitor_timeout;
168 } __attribute__ ((packed));
170 #define L2CAP_MODE_BASIC 0x00
171 #define L2CAP_MODE_RETRANS 0x01
172 #define L2CAP_MODE_FLOWCTL 0x02
174 struct l2cap_disconn_req {
177 } __attribute__ ((packed));
179 struct l2cap_disconn_rsp {
182 } __attribute__ ((packed));
184 struct l2cap_info_req {
186 } __attribute__ ((packed));
188 struct l2cap_info_rsp {
192 } __attribute__ ((packed));
195 #define L2CAP_IT_CL_MTU 0x0001
196 #define L2CAP_IT_FEAT_MASK 0x0002
197 #define L2CAP_IT_FIXED_CHAN 0x0003
200 #define L2CAP_IR_SUCCESS 0x0000
201 #define L2CAP_IR_NOTSUPP 0x0001
203 /* ----- L2CAP connections ----- */
204 struct l2cap_chan_list {
211 struct hci_conn *hcon;
223 struct timer_list info_timer;
227 struct sk_buff *rx_skb;
234 struct l2cap_chan_list chan_list;
237 #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01
238 #define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04
239 #define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08
241 /* ----- L2CAP channel and socket info ----- */
242 #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk)
266 struct l2cap_conn *conn;
271 #define L2CAP_CONF_REQ_SENT 0x01
272 #define L2CAP_CONF_INPUT_DONE 0x02
273 #define L2CAP_CONF_OUTPUT_DONE 0x04
274 #define L2CAP_CONF_CONNECT_PEND 0x80
276 #define L2CAP_CONF_MAX_RETRIES 2
278 void l2cap_load(void);
280 #endif /* __L2CAP_H */