1 /*******************************************************************
4 l2cap.h - list of fce for operation L2CAP protocol and
5 list of L2CAP structures
7 Copyright (C) 2006 by Petr Kovacik petr_kovacik@gmail.com
9 *******************************************************************/
16 #define L2CAP_DEFAULT_MTU 672
17 #define L2CAP_DEFAULT_FLUSH_TO 0xFFFF
19 #define L2CAP_CONN_TIMEOUT (HZ * 40)
21 /* L2CAP socket address */
22 //struct sockaddr_l2 {
23 // sa_family_t l2_family;
24 // unsigned short l2_psm;
25 // bdaddr_t l2_bdaddr;
28 /* L2CAP socket options */
29 //#define L2CAP_OPTIONS 0x01
30 //struct l2cap_options {
38 //#define L2CAP_CONNINFO 0x02
39 //struct l2cap_conninfo {
40 // uint16_t hci_handle;
41 // uint8_t dev_class[3];
45 #define L2CAP_LM_MASTER 0x0001
46 #define L2CAP_LM_AUTH 0x0002
47 #define L2CAP_LM_ENCRYPT 0x0004
48 #define L2CAP_LM_TRUSTED 0x0008
49 #define L2CAP_LM_RELIABLE 0x0010
50 #define L2CAP_LM_SECURE 0x0020
52 /* L2CAP command codes */
53 #define L2CAP_COMMAND_REJ 0x01
54 #define L2CAP_CONN_REQ 0x02
55 #define L2CAP_CONN_RSP 0x03
56 #define L2CAP_CONF_REQ 0x04
57 #define L2CAP_CONF_RSP 0x05
58 #define L2CAP_DISCONN_REQ 0x06
59 #define L2CAP_DISCONN_RSP 0x07
60 #define L2CAP_ECHO_REQ 0x08
61 #define L2CAP_ECHO_RSP 0x09
62 #define L2CAP_INFO_REQ 0x0a
63 #define L2CAP_INFO_RSP 0x0b
65 /* L2CAP structures */
70 #define L2CAP_HDR____len 0
71 #define L2CAP_HDR____cid 2
72 /*--------------------------------*/
73 #define L2CAP_HDR_SIZE 4
74 /****************************************************************/
75 /****************************************************************/
82 #define L2CAP_CMD_HDR____code 0
83 #define L2CAP_CMD_HDR____ident 1
84 #define L2CAP_CMD_HDR____len 2
85 /*--------------------------------*/
86 #define L2CAP_CMD_HDR_SIZE 4
87 /****************************************************************/
88 /****************************************************************/
93 #define L2CAP_CMD_REJ____reason 0
94 /*--------------------------------*/
95 #define L2CAP_CMD_REJ_SIZE 2
96 /****************************************************************/
97 /****************************************************************/
99 typedef struct { //0x02
104 #define L2CAP_CONN_REQ____psm 0
105 #define L2CAP_CONN_REQ____scid 2
106 /*--------------------------------*/
107 #define L2CAP_CONN_REQ_SIZE 4
108 /****************************************************************/
109 /****************************************************************/
111 typedef struct { //0x03
117 #define L2CAP_CONN_RSP____dcid 0
118 #define L2CAP_CONN_RSP____scid 2
119 #define L2CAP_CONN_RSP____result 4
120 #define L2CAP_CONN_RSP____status 6
121 /*--------------------------------*/
122 #define L2CAP_CONN_RSP_SIZE 8
123 /****************************************************************/
124 /****************************************************************/
127 #define L2CAP_CR_SUCCESS 0x0000
128 #define L2CAP_CR_PEND 0x0001
129 #define L2CAP_CR_BAD_PSM 0x0002
130 #define L2CAP_CR_SEC_BLOCK 0x0003
131 #define L2CAP_CR_NO_MEM 0x0004
134 #define L2CAP_CS_NO_INFO 0x0000
135 #define L2CAP_CS_AUTHEN_PEND 0x0001
136 #define L2CAP_CS_AUTHOR_PEND 0x0002
138 typedef struct { //0x04
143 #define L2CAP_CONF_REQ____dcid 0
144 #define L2CAP_CONF_REQ____flags 2
145 #define L2CAP_CONF_REQ____data 4
146 /*--------------------------------*/
147 #define L2CAP_CONF_REQ_SIZE 4
148 /****************************************************************/
149 /****************************************************************/
151 typedef struct { //0x05
157 #define L2CAP_CONF_RSP____scid 0
158 #define L2CAP_CONF_RSP____flags 2
159 #define L2CAP_CONF_RSP____result 4
160 #define L2CAP_CONF_RSP____data 6
161 /*--------------------------------*/
162 #define L2CAP_CONF_RSP_SIZE 6
163 /****************************************************************/
164 /****************************************************************/
168 #define L2CAP_CONF_SUCCESS 0x0000
169 #define L2CAP_CONF_UNACCEPT 0x0001
170 #define L2CAP_CONF_REJECT 0x0002
171 #define L2CAP_CONF_UNKNOWN 0x0003
178 #define L2CAP_CONF_OPT____type 0
179 #define L2CAP_CONF_OPT____len 1
180 #define L2CAP_CONF_OPT____val 2
181 /*--------------------------------*/
182 #define L2CAP_CONF_OPT_SIZE 2
183 /****************************************************************/
184 /****************************************************************/
187 #define L2CAP_CONF_MTU 0x01
188 #define L2CAP_CONF_FLUSH_TO 0x02
189 #define L2CAP_CONF_QOS 0x03
190 #define L2CAP_CONF_RFC 0x04
191 #define L2CAP_CONF_RFC_MODE 0x04
193 #define L2CAP_CONF_MAX_SIZE 22
199 #define L2CAP_DISCONN_REQ____dcid 0
200 #define L2CAP_DISCONN_REQ____scid 2
201 /*--------------------------------*/
202 #define L2CAP_DISCONN_REQ_SIZE 4
203 /****************************************************************/
204 /****************************************************************/
210 #define L2CAP_DISCONN_RSP____dcid 0
211 #define L2CAP_DISCONN_RSP____scid 2
212 /*--------------------------------*/
213 #define L2CAP_DISCONN_RSP_SIZE 4
214 /****************************************************************/
215 /****************************************************************/
221 #define L2CAP_INFO_REQ____type 0
222 #define L2CAP_INFO_REQ____data 2
223 /*--------------------------------*/
224 #define L2CAP_INFO_REQ_SIZE 2
225 /****************************************************************/
226 /****************************************************************/
233 #define L2CAP_INFO_RSP____type 0
234 #define L2CAP_INFO_RSP____result 2
235 #define L2CAP_INFO_RSP____data 4
236 /*--------------------------------*/
237 #define L2CAP_INFO_RSP_SIZE 4
238 /****************************************************************/
239 /****************************************************************/
242 #define L2CAP_IT_CL_MTU 0x0001
243 #define L2CAP_IT_FEAT_MASK 0x0002
246 #define L2CAP_IR_SUCCESS 0x0000
247 #define L2CAP_IR_NOTSUPP 0x0001
255 /*----------------------- funkce zavisle na code -----------------------------------*/
256 int l2cap_signaling(uint8_t *bth_p, uint16_t size, int dev_num);
258 int l2cap_none(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan);
259 int l2cap_cod_command_rej(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan); //0x01
260 int l2cap_cod_conn_req(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan); //0x02
261 int l2cap_cod_conn_rsp(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan); //0x03
262 int l2cap_cod_conf_req(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan); //0x04
263 int l2cap_cod_conf_rsp(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan); //0x05
264 int l2cap_cod_disconn_req(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan); //0x06
265 int l2cap_cod_disconn_rsp(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan); //0x07
266 int l2cap_cod_echo_req(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan); //0x08
267 int l2cap_cod_echo_rsp(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan); //0x09
268 int l2cap_cod_info_req(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan); //0x0a
269 int l2cap_cod_info_rsp(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan); //0x0b
270 //int l2cap_send_data(int inx_handle, int inx_chanal);
272 #endif /* __L2CAP_H */