diff options
Diffstat (limited to 'include/net/bluetooth/l2cap.h')
-rw-r--r-- | include/net/bluetooth/l2cap.h | 409 |
1 files changed, 355 insertions, 54 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 6cc18f371675..875021ad0675 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -27,17 +27,23 @@ | |||
27 | #ifndef __L2CAP_H | 27 | #ifndef __L2CAP_H |
28 | #define __L2CAP_H | 28 | #define __L2CAP_H |
29 | 29 | ||
30 | #include <asm/unaligned.h> | ||
31 | |||
30 | /* L2CAP defaults */ | 32 | /* L2CAP defaults */ |
31 | #define L2CAP_DEFAULT_MTU 672 | 33 | #define L2CAP_DEFAULT_MTU 672 |
32 | #define L2CAP_DEFAULT_MIN_MTU 48 | 34 | #define L2CAP_DEFAULT_MIN_MTU 48 |
33 | #define L2CAP_DEFAULT_FLUSH_TO 0xffff | 35 | #define L2CAP_DEFAULT_FLUSH_TO 0xffff |
34 | #define L2CAP_DEFAULT_TX_WINDOW 63 | 36 | #define L2CAP_DEFAULT_TX_WINDOW 63 |
37 | #define L2CAP_DEFAULT_EXT_WINDOW 0x3FFF | ||
35 | #define L2CAP_DEFAULT_MAX_TX 3 | 38 | #define L2CAP_DEFAULT_MAX_TX 3 |
36 | #define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ | 39 | #define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ |
37 | #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ | 40 | #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ |
38 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ | 41 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ |
39 | #define L2CAP_DEFAULT_ACK_TO 200 | 42 | #define L2CAP_DEFAULT_ACK_TO 200 |
40 | #define L2CAP_LE_DEFAULT_MTU 23 | 43 | #define L2CAP_LE_DEFAULT_MTU 23 |
44 | #define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF | ||
45 | #define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF | ||
46 | #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF | ||
41 | 47 | ||
42 | #define L2CAP_DISC_TIMEOUT (100) | 48 | #define L2CAP_DISC_TIMEOUT (100) |
43 | #define L2CAP_DISC_REJ_TIMEOUT (5000) /* 5 seconds */ | 49 | #define L2CAP_DISC_REJ_TIMEOUT (5000) /* 5 seconds */ |
@@ -91,52 +97,82 @@ struct l2cap_conninfo { | |||
91 | #define L2CAP_ECHO_RSP 0x09 | 97 | #define L2CAP_ECHO_RSP 0x09 |
92 | #define L2CAP_INFO_REQ 0x0a | 98 | #define L2CAP_INFO_REQ 0x0a |
93 | #define L2CAP_INFO_RSP 0x0b | 99 | #define L2CAP_INFO_RSP 0x0b |
100 | #define L2CAP_CREATE_CHAN_REQ 0x0c | ||
101 | #define L2CAP_CREATE_CHAN_RSP 0x0d | ||
102 | #define L2CAP_MOVE_CHAN_REQ 0x0e | ||
103 | #define L2CAP_MOVE_CHAN_RSP 0x0f | ||
104 | #define L2CAP_MOVE_CHAN_CFM 0x10 | ||
105 | #define L2CAP_MOVE_CHAN_CFM_RSP 0x11 | ||
94 | #define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 | 106 | #define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 |
95 | #define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 | 107 | #define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 |
96 | 108 | ||
97 | /* L2CAP feature mask */ | 109 | /* L2CAP extended feature mask */ |
98 | #define L2CAP_FEAT_FLOWCTL 0x00000001 | 110 | #define L2CAP_FEAT_FLOWCTL 0x00000001 |
99 | #define L2CAP_FEAT_RETRANS 0x00000002 | 111 | #define L2CAP_FEAT_RETRANS 0x00000002 |
112 | #define L2CAP_FEAT_BIDIR_QOS 0x00000004 | ||
100 | #define L2CAP_FEAT_ERTM 0x00000008 | 113 | #define L2CAP_FEAT_ERTM 0x00000008 |
101 | #define L2CAP_FEAT_STREAMING 0x00000010 | 114 | #define L2CAP_FEAT_STREAMING 0x00000010 |
102 | #define L2CAP_FEAT_FCS 0x00000020 | 115 | #define L2CAP_FEAT_FCS 0x00000020 |
116 | #define L2CAP_FEAT_EXT_FLOW 0x00000040 | ||
103 | #define L2CAP_FEAT_FIXED_CHAN 0x00000080 | 117 | #define L2CAP_FEAT_FIXED_CHAN 0x00000080 |
118 | #define L2CAP_FEAT_EXT_WINDOW 0x00000100 | ||
119 | #define L2CAP_FEAT_UCD 0x00000200 | ||
104 | 120 | ||
105 | /* L2CAP checksum option */ | 121 | /* L2CAP checksum option */ |
106 | #define L2CAP_FCS_NONE 0x00 | 122 | #define L2CAP_FCS_NONE 0x00 |
107 | #define L2CAP_FCS_CRC16 0x01 | 123 | #define L2CAP_FCS_CRC16 0x01 |
108 | 124 | ||
125 | /* L2CAP fixed channels */ | ||
126 | #define L2CAP_FC_L2CAP 0x02 | ||
127 | #define L2CAP_FC_A2MP 0x08 | ||
128 | |||
109 | /* L2CAP Control Field bit masks */ | 129 | /* L2CAP Control Field bit masks */ |
110 | #define L2CAP_CTRL_SAR 0xC000 | 130 | #define L2CAP_CTRL_SAR 0xC000 |
111 | #define L2CAP_CTRL_REQSEQ 0x3F00 | 131 | #define L2CAP_CTRL_REQSEQ 0x3F00 |
112 | #define L2CAP_CTRL_TXSEQ 0x007E | 132 | #define L2CAP_CTRL_TXSEQ 0x007E |
113 | #define L2CAP_CTRL_RETRANS 0x0080 | 133 | #define L2CAP_CTRL_SUPERVISE 0x000C |
114 | #define L2CAP_CTRL_FINAL 0x0080 | 134 | |
115 | #define L2CAP_CTRL_POLL 0x0010 | 135 | #define L2CAP_CTRL_RETRANS 0x0080 |
116 | #define L2CAP_CTRL_SUPERVISE 0x000C | 136 | #define L2CAP_CTRL_FINAL 0x0080 |
117 | #define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ | 137 | #define L2CAP_CTRL_POLL 0x0010 |
118 | 138 | #define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ | |
119 | #define L2CAP_CTRL_TXSEQ_SHIFT 1 | 139 | |
120 | #define L2CAP_CTRL_REQSEQ_SHIFT 8 | 140 | #define L2CAP_CTRL_TXSEQ_SHIFT 1 |
121 | #define L2CAP_CTRL_SAR_SHIFT 14 | 141 | #define L2CAP_CTRL_SUPER_SHIFT 2 |
142 | #define L2CAP_CTRL_REQSEQ_SHIFT 8 | ||
143 | #define L2CAP_CTRL_SAR_SHIFT 14 | ||
144 | |||
145 | /* L2CAP Extended Control Field bit mask */ | ||
146 | #define L2CAP_EXT_CTRL_TXSEQ 0xFFFC0000 | ||
147 | #define L2CAP_EXT_CTRL_SAR 0x00030000 | ||
148 | #define L2CAP_EXT_CTRL_SUPERVISE 0x00030000 | ||
149 | #define L2CAP_EXT_CTRL_REQSEQ 0x0000FFFC | ||
150 | |||
151 | #define L2CAP_EXT_CTRL_POLL 0x00040000 | ||
152 | #define L2CAP_EXT_CTRL_FINAL 0x00000002 | ||
153 | #define L2CAP_EXT_CTRL_FRAME_TYPE 0x00000001 /* I- or S-Frame */ | ||
154 | |||
155 | #define L2CAP_EXT_CTRL_REQSEQ_SHIFT 2 | ||
156 | #define L2CAP_EXT_CTRL_SAR_SHIFT 16 | ||
157 | #define L2CAP_EXT_CTRL_SUPER_SHIFT 16 | ||
158 | #define L2CAP_EXT_CTRL_TXSEQ_SHIFT 18 | ||
122 | 159 | ||
123 | /* L2CAP Supervisory Function */ | 160 | /* L2CAP Supervisory Function */ |
124 | #define L2CAP_SUPER_RCV_READY 0x0000 | 161 | #define L2CAP_SUPER_RR 0x00 |
125 | #define L2CAP_SUPER_REJECT 0x0004 | 162 | #define L2CAP_SUPER_REJ 0x01 |
126 | #define L2CAP_SUPER_RCV_NOT_READY 0x0008 | 163 | #define L2CAP_SUPER_RNR 0x02 |
127 | #define L2CAP_SUPER_SELECT_REJECT 0x000C | 164 | #define L2CAP_SUPER_SREJ 0x03 |
128 | 165 | ||
129 | /* L2CAP Segmentation and Reassembly */ | 166 | /* L2CAP Segmentation and Reassembly */ |
130 | #define L2CAP_SDU_UNSEGMENTED 0x0000 | 167 | #define L2CAP_SAR_UNSEGMENTED 0x00 |
131 | #define L2CAP_SDU_START 0x4000 | 168 | #define L2CAP_SAR_START 0x01 |
132 | #define L2CAP_SDU_END 0x8000 | 169 | #define L2CAP_SAR_END 0x02 |
133 | #define L2CAP_SDU_CONTINUE 0xC000 | 170 | #define L2CAP_SAR_CONTINUE 0x03 |
134 | 171 | ||
135 | /* L2CAP Command rej. reasons */ | 172 | /* L2CAP Command rej. reasons */ |
136 | #define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 | 173 | #define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 |
137 | #define L2CAP_REJ_MTU_EXCEEDED 0x0001 | 174 | #define L2CAP_REJ_MTU_EXCEEDED 0x0001 |
138 | #define L2CAP_REJ_INVALID_CID 0x0002 | 175 | #define L2CAP_REJ_INVALID_CID 0x0002 |
139 | |||
140 | 176 | ||
141 | /* L2CAP structures */ | 177 | /* L2CAP structures */ |
142 | struct l2cap_hdr { | 178 | struct l2cap_hdr { |
@@ -144,6 +180,12 @@ struct l2cap_hdr { | |||
144 | __le16 cid; | 180 | __le16 cid; |
145 | } __packed; | 181 | } __packed; |
146 | #define L2CAP_HDR_SIZE 4 | 182 | #define L2CAP_HDR_SIZE 4 |
183 | #define L2CAP_ENH_HDR_SIZE 6 | ||
184 | #define L2CAP_EXT_HDR_SIZE 8 | ||
185 | |||
186 | #define L2CAP_FCS_SIZE 2 | ||
187 | #define L2CAP_SDULEN_SIZE 2 | ||
188 | #define L2CAP_PSMLEN_SIZE 2 | ||
147 | 189 | ||
148 | struct l2cap_cmd_hdr { | 190 | struct l2cap_cmd_hdr { |
149 | __u8 code; | 191 | __u8 code; |
@@ -188,14 +230,15 @@ struct l2cap_conn_rsp { | |||
188 | #define L2CAP_CID_DYN_START 0x0040 | 230 | #define L2CAP_CID_DYN_START 0x0040 |
189 | #define L2CAP_CID_DYN_END 0xffff | 231 | #define L2CAP_CID_DYN_END 0xffff |
190 | 232 | ||
191 | /* connect result */ | 233 | /* connect/create channel results */ |
192 | #define L2CAP_CR_SUCCESS 0x0000 | 234 | #define L2CAP_CR_SUCCESS 0x0000 |
193 | #define L2CAP_CR_PEND 0x0001 | 235 | #define L2CAP_CR_PEND 0x0001 |
194 | #define L2CAP_CR_BAD_PSM 0x0002 | 236 | #define L2CAP_CR_BAD_PSM 0x0002 |
195 | #define L2CAP_CR_SEC_BLOCK 0x0003 | 237 | #define L2CAP_CR_SEC_BLOCK 0x0003 |
196 | #define L2CAP_CR_NO_MEM 0x0004 | 238 | #define L2CAP_CR_NO_MEM 0x0004 |
239 | #define L2CAP_CR_BAD_AMP 0x0005 | ||
197 | 240 | ||
198 | /* connect status */ | 241 | /* connect/create channel status */ |
199 | #define L2CAP_CS_NO_INFO 0x0000 | 242 | #define L2CAP_CS_NO_INFO 0x0000 |
200 | #define L2CAP_CS_AUTHEN_PEND 0x0001 | 243 | #define L2CAP_CS_AUTHEN_PEND 0x0001 |
201 | #define L2CAP_CS_AUTHOR_PEND 0x0002 | 244 | #define L2CAP_CS_AUTHOR_PEND 0x0002 |
@@ -217,6 +260,8 @@ struct l2cap_conf_rsp { | |||
217 | #define L2CAP_CONF_UNACCEPT 0x0001 | 260 | #define L2CAP_CONF_UNACCEPT 0x0001 |
218 | #define L2CAP_CONF_REJECT 0x0002 | 261 | #define L2CAP_CONF_REJECT 0x0002 |
219 | #define L2CAP_CONF_UNKNOWN 0x0003 | 262 | #define L2CAP_CONF_UNKNOWN 0x0003 |
263 | #define L2CAP_CONF_PENDING 0x0004 | ||
264 | #define L2CAP_CONF_EFS_REJECT 0x0005 | ||
220 | 265 | ||
221 | struct l2cap_conf_opt { | 266 | struct l2cap_conf_opt { |
222 | __u8 type; | 267 | __u8 type; |
@@ -233,6 +278,8 @@ struct l2cap_conf_opt { | |||
233 | #define L2CAP_CONF_QOS 0x03 | 278 | #define L2CAP_CONF_QOS 0x03 |
234 | #define L2CAP_CONF_RFC 0x04 | 279 | #define L2CAP_CONF_RFC 0x04 |
235 | #define L2CAP_CONF_FCS 0x05 | 280 | #define L2CAP_CONF_FCS 0x05 |
281 | #define L2CAP_CONF_EFS 0x06 | ||
282 | #define L2CAP_CONF_EWS 0x07 | ||
236 | 283 | ||
237 | #define L2CAP_CONF_MAX_SIZE 22 | 284 | #define L2CAP_CONF_MAX_SIZE 22 |
238 | 285 | ||
@@ -251,6 +298,21 @@ struct l2cap_conf_rfc { | |||
251 | #define L2CAP_MODE_ERTM 0x03 | 298 | #define L2CAP_MODE_ERTM 0x03 |
252 | #define L2CAP_MODE_STREAMING 0x04 | 299 | #define L2CAP_MODE_STREAMING 0x04 |
253 | 300 | ||
301 | struct l2cap_conf_efs { | ||
302 | __u8 id; | ||
303 | __u8 stype; | ||
304 | __le16 msdu; | ||
305 | __le32 sdu_itime; | ||
306 | __le32 acc_lat; | ||
307 | __le32 flush_to; | ||
308 | } __packed; | ||
309 | |||
310 | #define L2CAP_SERV_NOTRAFIC 0x00 | ||
311 | #define L2CAP_SERV_BESTEFFORT 0x01 | ||
312 | #define L2CAP_SERV_GUARANTEED 0x02 | ||
313 | |||
314 | #define L2CAP_BESTEFFORT_ID 0x01 | ||
315 | |||
254 | struct l2cap_disconn_req { | 316 | struct l2cap_disconn_req { |
255 | __le16 dcid; | 317 | __le16 dcid; |
256 | __le16 scid; | 318 | __le16 scid; |
@@ -271,14 +333,57 @@ struct l2cap_info_rsp { | |||
271 | __u8 data[0]; | 333 | __u8 data[0]; |
272 | } __packed; | 334 | } __packed; |
273 | 335 | ||
336 | struct l2cap_create_chan_req { | ||
337 | __le16 psm; | ||
338 | __le16 scid; | ||
339 | __u8 amp_id; | ||
340 | } __packed; | ||
341 | |||
342 | struct l2cap_create_chan_rsp { | ||
343 | __le16 dcid; | ||
344 | __le16 scid; | ||
345 | __le16 result; | ||
346 | __le16 status; | ||
347 | } __packed; | ||
348 | |||
349 | struct l2cap_move_chan_req { | ||
350 | __le16 icid; | ||
351 | __u8 dest_amp_id; | ||
352 | } __packed; | ||
353 | |||
354 | struct l2cap_move_chan_rsp { | ||
355 | __le16 icid; | ||
356 | __le16 result; | ||
357 | } __packed; | ||
358 | |||
359 | #define L2CAP_MR_SUCCESS 0x0000 | ||
360 | #define L2CAP_MR_PEND 0x0001 | ||
361 | #define L2CAP_MR_BAD_ID 0x0002 | ||
362 | #define L2CAP_MR_SAME_ID 0x0003 | ||
363 | #define L2CAP_MR_NOT_SUPP 0x0004 | ||
364 | #define L2CAP_MR_COLLISION 0x0005 | ||
365 | #define L2CAP_MR_NOT_ALLOWED 0x0006 | ||
366 | |||
367 | struct l2cap_move_chan_cfm { | ||
368 | __le16 icid; | ||
369 | __le16 result; | ||
370 | } __packed; | ||
371 | |||
372 | #define L2CAP_MC_CONFIRMED 0x0000 | ||
373 | #define L2CAP_MC_UNCONFIRMED 0x0001 | ||
374 | |||
375 | struct l2cap_move_chan_cfm_rsp { | ||
376 | __le16 icid; | ||
377 | } __packed; | ||
378 | |||
274 | /* info type */ | 379 | /* info type */ |
275 | #define L2CAP_IT_CL_MTU 0x0001 | 380 | #define L2CAP_IT_CL_MTU 0x0001 |
276 | #define L2CAP_IT_FEAT_MASK 0x0002 | 381 | #define L2CAP_IT_FEAT_MASK 0x0002 |
277 | #define L2CAP_IT_FIXED_CHAN 0x0003 | 382 | #define L2CAP_IT_FIXED_CHAN 0x0003 |
278 | 383 | ||
279 | /* info result */ | 384 | /* info result */ |
280 | #define L2CAP_IR_SUCCESS 0x0000 | 385 | #define L2CAP_IR_SUCCESS 0x0000 |
281 | #define L2CAP_IR_NOTSUPP 0x0001 | 386 | #define L2CAP_IR_NOTSUPP 0x0001 |
282 | 387 | ||
283 | struct l2cap_conn_param_update_req { | 388 | struct l2cap_conn_param_update_req { |
284 | __le16 min; | 389 | __le16 min; |
@@ -297,7 +402,7 @@ struct l2cap_conn_param_update_rsp { | |||
297 | 402 | ||
298 | /* ----- L2CAP channels and connections ----- */ | 403 | /* ----- L2CAP channels and connections ----- */ |
299 | struct srej_list { | 404 | struct srej_list { |
300 | __u8 tx_seq; | 405 | __u16 tx_seq; |
301 | struct list_head list; | 406 | struct list_head list; |
302 | }; | 407 | }; |
303 | 408 | ||
@@ -319,14 +424,11 @@ struct l2cap_chan { | |||
319 | __u16 flush_to; | 424 | __u16 flush_to; |
320 | __u8 mode; | 425 | __u8 mode; |
321 | __u8 chan_type; | 426 | __u8 chan_type; |
427 | __u8 chan_policy; | ||
322 | 428 | ||
323 | __le16 sport; | 429 | __le16 sport; |
324 | 430 | ||
325 | __u8 sec_level; | 431 | __u8 sec_level; |
326 | __u8 role_switch; | ||
327 | __u8 force_reliable; | ||
328 | __u8 flushable; | ||
329 | __u8 force_active; | ||
330 | 432 | ||
331 | __u8 ident; | 433 | __u8 ident; |
332 | 434 | ||
@@ -337,7 +439,8 @@ struct l2cap_chan { | |||
337 | 439 | ||
338 | __u8 fcs; | 440 | __u8 fcs; |
339 | 441 | ||
340 | __u8 tx_win; | 442 | __u16 tx_win; |
443 | __u16 tx_win_max; | ||
341 | __u8 max_tx; | 444 | __u8 max_tx; |
342 | __u16 retrans_timeout; | 445 | __u16 retrans_timeout; |
343 | __u16 monitor_timeout; | 446 | __u16 monitor_timeout; |
@@ -345,25 +448,40 @@ struct l2cap_chan { | |||
345 | 448 | ||
346 | unsigned long conf_state; | 449 | unsigned long conf_state; |
347 | unsigned long conn_state; | 450 | unsigned long conn_state; |
348 | 451 | unsigned long flags; | |
349 | __u8 next_tx_seq; | 452 | |
350 | __u8 expected_ack_seq; | 453 | __u16 next_tx_seq; |
351 | __u8 expected_tx_seq; | 454 | __u16 expected_ack_seq; |
352 | __u8 buffer_seq; | 455 | __u16 expected_tx_seq; |
353 | __u8 buffer_seq_srej; | 456 | __u16 buffer_seq; |
354 | __u8 srej_save_reqseq; | 457 | __u16 buffer_seq_srej; |
355 | __u8 frames_sent; | 458 | __u16 srej_save_reqseq; |
356 | __u8 unacked_frames; | 459 | __u16 frames_sent; |
460 | __u16 unacked_frames; | ||
357 | __u8 retry_count; | 461 | __u8 retry_count; |
358 | __u8 num_acked; | 462 | __u8 num_acked; |
359 | __u16 sdu_len; | 463 | __u16 sdu_len; |
360 | struct sk_buff *sdu; | 464 | struct sk_buff *sdu; |
361 | struct sk_buff *sdu_last_frag; | 465 | struct sk_buff *sdu_last_frag; |
362 | 466 | ||
363 | __u8 remote_tx_win; | 467 | __u16 remote_tx_win; |
364 | __u8 remote_max_tx; | 468 | __u8 remote_max_tx; |
365 | __u16 remote_mps; | 469 | __u16 remote_mps; |
366 | 470 | ||
471 | __u8 local_id; | ||
472 | __u8 local_stype; | ||
473 | __u16 local_msdu; | ||
474 | __u32 local_sdu_itime; | ||
475 | __u32 local_acc_lat; | ||
476 | __u32 local_flush_to; | ||
477 | |||
478 | __u8 remote_id; | ||
479 | __u8 remote_stype; | ||
480 | __u16 remote_msdu; | ||
481 | __u32 remote_sdu_itime; | ||
482 | __u32 remote_acc_lat; | ||
483 | __u32 remote_flush_to; | ||
484 | |||
367 | struct timer_list chan_timer; | 485 | struct timer_list chan_timer; |
368 | struct timer_list retrans_timer; | 486 | struct timer_list retrans_timer; |
369 | struct timer_list monitor_timer; | 487 | struct timer_list monitor_timer; |
@@ -391,6 +509,7 @@ struct l2cap_ops { | |||
391 | 509 | ||
392 | struct l2cap_conn { | 510 | struct l2cap_conn { |
393 | struct hci_conn *hcon; | 511 | struct hci_conn *hcon; |
512 | struct hci_chan *hchan; | ||
394 | 513 | ||
395 | bdaddr_t *dst; | 514 | bdaddr_t *dst; |
396 | bdaddr_t *src; | 515 | bdaddr_t *src; |
@@ -445,6 +564,9 @@ enum { | |||
445 | CONF_CONNECT_PEND, | 564 | CONF_CONNECT_PEND, |
446 | CONF_NO_FCS_RECV, | 565 | CONF_NO_FCS_RECV, |
447 | CONF_STATE2_DEVICE, | 566 | CONF_STATE2_DEVICE, |
567 | CONF_EWS_RECV, | ||
568 | CONF_LOC_CONF_PEND, | ||
569 | CONF_REM_CONF_PEND, | ||
448 | }; | 570 | }; |
449 | 571 | ||
450 | #define L2CAP_CONF_MAX_CONF_REQ 2 | 572 | #define L2CAP_CONF_MAX_CONF_REQ 2 |
@@ -462,6 +584,16 @@ enum { | |||
462 | CONN_RNR_SENT, | 584 | CONN_RNR_SENT, |
463 | }; | 585 | }; |
464 | 586 | ||
587 | /* Definitions for flags in l2cap_chan */ | ||
588 | enum { | ||
589 | FLAG_ROLE_SWITCH, | ||
590 | FLAG_FORCE_ACTIVE, | ||
591 | FLAG_FORCE_RELIABLE, | ||
592 | FLAG_FLUSHABLE, | ||
593 | FLAG_EXT_CTRL, | ||
594 | FLAG_EFS_ENABLE, | ||
595 | }; | ||
596 | |||
465 | #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) | 597 | #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) |
466 | #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) | 598 | #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) |
467 | #define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ | 599 | #define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ |
@@ -474,6 +606,22 @@ enum { | |||
474 | L2CAP_DEFAULT_ACK_TO); | 606 | L2CAP_DEFAULT_ACK_TO); |
475 | #define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) | 607 | #define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) |
476 | 608 | ||
609 | static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2) | ||
610 | { | ||
611 | int offset; | ||
612 | |||
613 | offset = (seq1 - seq2) % (chan->tx_win_max + 1); | ||
614 | if (offset < 0) | ||
615 | offset += (chan->tx_win_max + 1); | ||
616 | |||
617 | return offset; | ||
618 | } | ||
619 | |||
620 | static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq) | ||
621 | { | ||
622 | return (seq + 1) % (chan->tx_win_max + 1); | ||
623 | } | ||
624 | |||
477 | static inline int l2cap_tx_window_full(struct l2cap_chan *ch) | 625 | static inline int l2cap_tx_window_full(struct l2cap_chan *ch) |
478 | { | 626 | { |
479 | int sub; | 627 | int sub; |
@@ -486,13 +634,165 @@ static inline int l2cap_tx_window_full(struct l2cap_chan *ch) | |||
486 | return sub == ch->remote_tx_win; | 634 | return sub == ch->remote_tx_win; |
487 | } | 635 | } |
488 | 636 | ||
489 | #define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) | 637 | static inline __u16 __get_reqseq(struct l2cap_chan *chan, __u32 ctrl) |
490 | #define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8) | 638 | { |
491 | #define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) | 639 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) |
492 | #define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) | 640 | return (ctrl & L2CAP_EXT_CTRL_REQSEQ) >> |
493 | #define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) | 641 | L2CAP_EXT_CTRL_REQSEQ_SHIFT; |
642 | else | ||
643 | return (ctrl & L2CAP_CTRL_REQSEQ) >> L2CAP_CTRL_REQSEQ_SHIFT; | ||
644 | } | ||
645 | |||
646 | static inline __u32 __set_reqseq(struct l2cap_chan *chan, __u32 reqseq) | ||
647 | { | ||
648 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
649 | return (reqseq << L2CAP_EXT_CTRL_REQSEQ_SHIFT) & | ||
650 | L2CAP_EXT_CTRL_REQSEQ; | ||
651 | else | ||
652 | return (reqseq << L2CAP_CTRL_REQSEQ_SHIFT) & L2CAP_CTRL_REQSEQ; | ||
653 | } | ||
654 | |||
655 | static inline __u16 __get_txseq(struct l2cap_chan *chan, __u32 ctrl) | ||
656 | { | ||
657 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
658 | return (ctrl & L2CAP_EXT_CTRL_TXSEQ) >> | ||
659 | L2CAP_EXT_CTRL_TXSEQ_SHIFT; | ||
660 | else | ||
661 | return (ctrl & L2CAP_CTRL_TXSEQ) >> L2CAP_CTRL_TXSEQ_SHIFT; | ||
662 | } | ||
663 | |||
664 | static inline __u32 __set_txseq(struct l2cap_chan *chan, __u32 txseq) | ||
665 | { | ||
666 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
667 | return (txseq << L2CAP_EXT_CTRL_TXSEQ_SHIFT) & | ||
668 | L2CAP_EXT_CTRL_TXSEQ; | ||
669 | else | ||
670 | return (txseq << L2CAP_CTRL_TXSEQ_SHIFT) & L2CAP_CTRL_TXSEQ; | ||
671 | } | ||
672 | |||
673 | static inline bool __is_sframe(struct l2cap_chan *chan, __u32 ctrl) | ||
674 | { | ||
675 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
676 | return ctrl & L2CAP_EXT_CTRL_FRAME_TYPE; | ||
677 | else | ||
678 | return ctrl & L2CAP_CTRL_FRAME_TYPE; | ||
679 | } | ||
680 | |||
681 | static inline __u32 __set_sframe(struct l2cap_chan *chan) | ||
682 | { | ||
683 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
684 | return L2CAP_EXT_CTRL_FRAME_TYPE; | ||
685 | else | ||
686 | return L2CAP_CTRL_FRAME_TYPE; | ||
687 | } | ||
688 | |||
689 | static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl) | ||
690 | { | ||
691 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
692 | return (ctrl & L2CAP_EXT_CTRL_SAR) >> L2CAP_EXT_CTRL_SAR_SHIFT; | ||
693 | else | ||
694 | return (ctrl & L2CAP_CTRL_SAR) >> L2CAP_CTRL_SAR_SHIFT; | ||
695 | } | ||
696 | |||
697 | static inline __u32 __set_ctrl_sar(struct l2cap_chan *chan, __u32 sar) | ||
698 | { | ||
699 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
700 | return (sar << L2CAP_EXT_CTRL_SAR_SHIFT) & L2CAP_EXT_CTRL_SAR; | ||
701 | else | ||
702 | return (sar << L2CAP_CTRL_SAR_SHIFT) & L2CAP_CTRL_SAR; | ||
703 | } | ||
704 | |||
705 | static inline bool __is_sar_start(struct l2cap_chan *chan, __u32 ctrl) | ||
706 | { | ||
707 | return __get_ctrl_sar(chan, ctrl) == L2CAP_SAR_START; | ||
708 | } | ||
709 | |||
710 | static inline __u32 __get_sar_mask(struct l2cap_chan *chan) | ||
711 | { | ||
712 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
713 | return L2CAP_EXT_CTRL_SAR; | ||
714 | else | ||
715 | return L2CAP_CTRL_SAR; | ||
716 | } | ||
717 | |||
718 | static inline __u8 __get_ctrl_super(struct l2cap_chan *chan, __u32 ctrl) | ||
719 | { | ||
720 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
721 | return (ctrl & L2CAP_EXT_CTRL_SUPERVISE) >> | ||
722 | L2CAP_EXT_CTRL_SUPER_SHIFT; | ||
723 | else | ||
724 | return (ctrl & L2CAP_CTRL_SUPERVISE) >> L2CAP_CTRL_SUPER_SHIFT; | ||
725 | } | ||
726 | |||
727 | static inline __u32 __set_ctrl_super(struct l2cap_chan *chan, __u32 super) | ||
728 | { | ||
729 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
730 | return (super << L2CAP_EXT_CTRL_SUPER_SHIFT) & | ||
731 | L2CAP_EXT_CTRL_SUPERVISE; | ||
732 | else | ||
733 | return (super << L2CAP_CTRL_SUPER_SHIFT) & | ||
734 | L2CAP_CTRL_SUPERVISE; | ||
735 | } | ||
736 | |||
737 | static inline __u32 __set_ctrl_final(struct l2cap_chan *chan) | ||
738 | { | ||
739 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
740 | return L2CAP_EXT_CTRL_FINAL; | ||
741 | else | ||
742 | return L2CAP_CTRL_FINAL; | ||
743 | } | ||
744 | |||
745 | static inline bool __is_ctrl_final(struct l2cap_chan *chan, __u32 ctrl) | ||
746 | { | ||
747 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
748 | return ctrl & L2CAP_EXT_CTRL_FINAL; | ||
749 | else | ||
750 | return ctrl & L2CAP_CTRL_FINAL; | ||
751 | } | ||
752 | |||
753 | static inline __u32 __set_ctrl_poll(struct l2cap_chan *chan) | ||
754 | { | ||
755 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
756 | return L2CAP_EXT_CTRL_POLL; | ||
757 | else | ||
758 | return L2CAP_CTRL_POLL; | ||
759 | } | ||
760 | |||
761 | static inline bool __is_ctrl_poll(struct l2cap_chan *chan, __u32 ctrl) | ||
762 | { | ||
763 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
764 | return ctrl & L2CAP_EXT_CTRL_POLL; | ||
765 | else | ||
766 | return ctrl & L2CAP_CTRL_POLL; | ||
767 | } | ||
768 | |||
769 | static inline __u32 __get_control(struct l2cap_chan *chan, void *p) | ||
770 | { | ||
771 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
772 | return get_unaligned_le32(p); | ||
773 | else | ||
774 | return get_unaligned_le16(p); | ||
775 | } | ||
776 | |||
777 | static inline void __put_control(struct l2cap_chan *chan, __u32 control, | ||
778 | void *p) | ||
779 | { | ||
780 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
781 | return put_unaligned_le32(control, p); | ||
782 | else | ||
783 | return put_unaligned_le16(control, p); | ||
784 | } | ||
785 | |||
786 | static inline __u8 __ctrl_size(struct l2cap_chan *chan) | ||
787 | { | ||
788 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
789 | return L2CAP_EXT_HDR_SIZE - L2CAP_HDR_SIZE; | ||
790 | else | ||
791 | return L2CAP_ENH_HDR_SIZE - L2CAP_HDR_SIZE; | ||
792 | } | ||
494 | 793 | ||
495 | extern int disable_ertm; | 794 | extern int disable_ertm; |
795 | extern int enable_hs; | ||
496 | 796 | ||
497 | int l2cap_init_sockets(void); | 797 | int l2cap_init_sockets(void); |
498 | void l2cap_cleanup_sockets(void); | 798 | void l2cap_cleanup_sockets(void); |
@@ -507,7 +807,8 @@ struct l2cap_chan *l2cap_chan_create(struct sock *sk); | |||
507 | void l2cap_chan_close(struct l2cap_chan *chan, int reason); | 807 | void l2cap_chan_close(struct l2cap_chan *chan, int reason); |
508 | void l2cap_chan_destroy(struct l2cap_chan *chan); | 808 | void l2cap_chan_destroy(struct l2cap_chan *chan); |
509 | int l2cap_chan_connect(struct l2cap_chan *chan); | 809 | int l2cap_chan_connect(struct l2cap_chan *chan); |
510 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len); | 810 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, |
811 | u32 priority); | ||
511 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); | 812 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); |
512 | 813 | ||
513 | #endif /* __L2CAP_H */ | 814 | #endif /* __L2CAP_H */ |