diff options
Diffstat (limited to 'include/net/bluetooth/l2cap.h')
| -rw-r--r-- | include/net/bluetooth/l2cap.h | 77 |
1 files changed, 50 insertions, 27 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 17a689f27a6a..6c241444f902 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | /* | 1 | /* |
| 2 | BlueZ - Bluetooth protocol stack for Linux | 2 | BlueZ - Bluetooth protocol stack for Linux |
| 3 | Copyright (C) 2000-2001 Qualcomm Incorporated | 3 | Copyright (C) 2000-2001 Qualcomm Incorporated |
| 4 | Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org> | ||
| 5 | Copyright (C) 2010 Google Inc. | ||
| 4 | 6 | ||
| 5 | Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> | 7 | Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> |
| 6 | 8 | ||
| @@ -30,11 +32,12 @@ | |||
| 30 | #define L2CAP_DEFAULT_MIN_MTU 48 | 32 | #define L2CAP_DEFAULT_MIN_MTU 48 |
| 31 | #define L2CAP_DEFAULT_FLUSH_TO 0xffff | 33 | #define L2CAP_DEFAULT_FLUSH_TO 0xffff |
| 32 | #define L2CAP_DEFAULT_TX_WINDOW 63 | 34 | #define L2CAP_DEFAULT_TX_WINDOW 63 |
| 33 | #define L2CAP_DEFAULT_NUM_TO_ACK (L2CAP_DEFAULT_TX_WINDOW/5) | ||
| 34 | #define L2CAP_DEFAULT_MAX_TX 3 | 35 | #define L2CAP_DEFAULT_MAX_TX 3 |
| 35 | #define L2CAP_DEFAULT_RETRANS_TO 1000 /* 1 second */ | 36 | #define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ |
| 36 | #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ | 37 | #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ |
| 37 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 672 | 38 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ |
| 39 | #define L2CAP_DEFAULT_ACK_TO 200 | ||
| 40 | #define L2CAP_LOCAL_BUSY_TRIES 12 | ||
| 38 | 41 | ||
| 39 | #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ | 42 | #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ |
| 40 | #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ | 43 | #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ |
| @@ -55,6 +58,8 @@ struct l2cap_options { | |||
| 55 | __u16 flush_to; | 58 | __u16 flush_to; |
| 56 | __u8 mode; | 59 | __u8 mode; |
| 57 | __u8 fcs; | 60 | __u8 fcs; |
| 61 | __u8 max_tx; | ||
| 62 | __u16 txwin_size; | ||
| 58 | }; | 63 | }; |
| 59 | 64 | ||
| 60 | #define L2CAP_CONNINFO 0x02 | 65 | #define L2CAP_CONNINFO 0x02 |
| @@ -126,31 +131,31 @@ struct l2cap_conninfo { | |||
| 126 | struct l2cap_hdr { | 131 | struct l2cap_hdr { |
| 127 | __le16 len; | 132 | __le16 len; |
| 128 | __le16 cid; | 133 | __le16 cid; |
| 129 | } __attribute__ ((packed)); | 134 | } __packed; |
| 130 | #define L2CAP_HDR_SIZE 4 | 135 | #define L2CAP_HDR_SIZE 4 |
| 131 | 136 | ||
| 132 | struct l2cap_cmd_hdr { | 137 | struct l2cap_cmd_hdr { |
| 133 | __u8 code; | 138 | __u8 code; |
| 134 | __u8 ident; | 139 | __u8 ident; |
| 135 | __le16 len; | 140 | __le16 len; |
| 136 | } __attribute__ ((packed)); | 141 | } __packed; |
| 137 | #define L2CAP_CMD_HDR_SIZE 4 | 142 | #define L2CAP_CMD_HDR_SIZE 4 |
| 138 | 143 | ||
| 139 | struct l2cap_cmd_rej { | 144 | struct l2cap_cmd_rej { |
| 140 | __le16 reason; | 145 | __le16 reason; |
| 141 | } __attribute__ ((packed)); | 146 | } __packed; |
| 142 | 147 | ||
| 143 | struct l2cap_conn_req { | 148 | struct l2cap_conn_req { |
| 144 | __le16 psm; | 149 | __le16 psm; |
| 145 | __le16 scid; | 150 | __le16 scid; |
| 146 | } __attribute__ ((packed)); | 151 | } __packed; |
| 147 | 152 | ||
| 148 | struct l2cap_conn_rsp { | 153 | struct l2cap_conn_rsp { |
| 149 | __le16 dcid; | 154 | __le16 dcid; |
| 150 | __le16 scid; | 155 | __le16 scid; |
| 151 | __le16 result; | 156 | __le16 result; |
| 152 | __le16 status; | 157 | __le16 status; |
| 153 | } __attribute__ ((packed)); | 158 | } __packed; |
| 154 | 159 | ||
| 155 | /* channel indentifier */ | 160 | /* channel indentifier */ |
| 156 | #define L2CAP_CID_SIGNALING 0x0001 | 161 | #define L2CAP_CID_SIGNALING 0x0001 |
| @@ -174,14 +179,14 @@ struct l2cap_conf_req { | |||
| 174 | __le16 dcid; | 179 | __le16 dcid; |
| 175 | __le16 flags; | 180 | __le16 flags; |
| 176 | __u8 data[0]; | 181 | __u8 data[0]; |
| 177 | } __attribute__ ((packed)); | 182 | } __packed; |
| 178 | 183 | ||
| 179 | struct l2cap_conf_rsp { | 184 | struct l2cap_conf_rsp { |
| 180 | __le16 scid; | 185 | __le16 scid; |
| 181 | __le16 flags; | 186 | __le16 flags; |
| 182 | __le16 result; | 187 | __le16 result; |
| 183 | __u8 data[0]; | 188 | __u8 data[0]; |
| 184 | } __attribute__ ((packed)); | 189 | } __packed; |
| 185 | 190 | ||
| 186 | #define L2CAP_CONF_SUCCESS 0x0000 | 191 | #define L2CAP_CONF_SUCCESS 0x0000 |
| 187 | #define L2CAP_CONF_UNACCEPT 0x0001 | 192 | #define L2CAP_CONF_UNACCEPT 0x0001 |
| @@ -192,7 +197,7 @@ struct l2cap_conf_opt { | |||
| 192 | __u8 type; | 197 | __u8 type; |
| 193 | __u8 len; | 198 | __u8 len; |
| 194 | __u8 val[0]; | 199 | __u8 val[0]; |
| 195 | } __attribute__ ((packed)); | 200 | } __packed; |
| 196 | #define L2CAP_CONF_OPT_SIZE 2 | 201 | #define L2CAP_CONF_OPT_SIZE 2 |
| 197 | 202 | ||
| 198 | #define L2CAP_CONF_HINT 0x80 | 203 | #define L2CAP_CONF_HINT 0x80 |
| @@ -213,7 +218,7 @@ struct l2cap_conf_rfc { | |||
| 213 | __le16 retrans_timeout; | 218 | __le16 retrans_timeout; |
| 214 | __le16 monitor_timeout; | 219 | __le16 monitor_timeout; |
| 215 | __le16 max_pdu_size; | 220 | __le16 max_pdu_size; |
| 216 | } __attribute__ ((packed)); | 221 | } __packed; |
| 217 | 222 | ||
| 218 | #define L2CAP_MODE_BASIC 0x00 | 223 | #define L2CAP_MODE_BASIC 0x00 |
| 219 | #define L2CAP_MODE_RETRANS 0x01 | 224 | #define L2CAP_MODE_RETRANS 0x01 |
| @@ -224,22 +229,22 @@ struct l2cap_conf_rfc { | |||
| 224 | struct l2cap_disconn_req { | 229 | struct l2cap_disconn_req { |
| 225 | __le16 dcid; | 230 | __le16 dcid; |
| 226 | __le16 scid; | 231 | __le16 scid; |
| 227 | } __attribute__ ((packed)); | 232 | } __packed; |
| 228 | 233 | ||
| 229 | struct l2cap_disconn_rsp { | 234 | struct l2cap_disconn_rsp { |
| 230 | __le16 dcid; | 235 | __le16 dcid; |
| 231 | __le16 scid; | 236 | __le16 scid; |
| 232 | } __attribute__ ((packed)); | 237 | } __packed; |
| 233 | 238 | ||
| 234 | struct l2cap_info_req { | 239 | struct l2cap_info_req { |
| 235 | __le16 type; | 240 | __le16 type; |
| 236 | } __attribute__ ((packed)); | 241 | } __packed; |
| 237 | 242 | ||
| 238 | struct l2cap_info_rsp { | 243 | struct l2cap_info_rsp { |
| 239 | __le16 type; | 244 | __le16 type; |
| 240 | __le16 result; | 245 | __le16 result; |
| 241 | __u8 data[0]; | 246 | __u8 data[0]; |
| 242 | } __attribute__ ((packed)); | 247 | } __packed; |
| 243 | 248 | ||
| 244 | /* info type */ | 249 | /* info type */ |
| 245 | #define L2CAP_IT_CL_MTU 0x0001 | 250 | #define L2CAP_IT_CL_MTU 0x0001 |
| @@ -284,6 +289,11 @@ struct l2cap_conn { | |||
| 284 | struct l2cap_chan_list chan_list; | 289 | struct l2cap_chan_list chan_list; |
| 285 | }; | 290 | }; |
| 286 | 291 | ||
| 292 | struct sock_del_list { | ||
| 293 | struct sock *sk; | ||
| 294 | struct list_head list; | ||
| 295 | }; | ||
| 296 | |||
| 287 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | 297 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 |
| 288 | #define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 | 298 | #define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 |
| 289 | #define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 | 299 | #define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 |
| @@ -292,6 +302,7 @@ struct l2cap_conn { | |||
| 292 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | 302 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) |
| 293 | #define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue) | 303 | #define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue) |
| 294 | #define SREJ_QUEUE(sk) (&l2cap_pi(sk)->srej_queue) | 304 | #define SREJ_QUEUE(sk) (&l2cap_pi(sk)->srej_queue) |
| 305 | #define BUSY_QUEUE(sk) (&l2cap_pi(sk)->busy_queue) | ||
| 295 | #define SREJ_LIST(sk) (&l2cap_pi(sk)->srej_l.list) | 306 | #define SREJ_LIST(sk) (&l2cap_pi(sk)->srej_l.list) |
| 296 | 307 | ||
| 297 | struct srej_list { | 308 | struct srej_list { |
| @@ -320,7 +331,7 @@ struct l2cap_pinfo { | |||
| 320 | __u8 conf_req[64]; | 331 | __u8 conf_req[64]; |
| 321 | __u8 conf_len; | 332 | __u8 conf_len; |
| 322 | __u8 conf_state; | 333 | __u8 conf_state; |
| 323 | __u8 conn_state; | 334 | __u16 conn_state; |
| 324 | 335 | ||
| 325 | __u8 next_tx_seq; | 336 | __u8 next_tx_seq; |
| 326 | __u8 expected_ack_seq; | 337 | __u8 expected_ack_seq; |
| @@ -328,27 +339,34 @@ struct l2cap_pinfo { | |||
| 328 | __u8 buffer_seq; | 339 | __u8 buffer_seq; |
| 329 | __u8 buffer_seq_srej; | 340 | __u8 buffer_seq_srej; |
| 330 | __u8 srej_save_reqseq; | 341 | __u8 srej_save_reqseq; |
| 342 | __u8 frames_sent; | ||
| 331 | __u8 unacked_frames; | 343 | __u8 unacked_frames; |
| 332 | __u8 retry_count; | 344 | __u8 retry_count; |
| 333 | __u8 num_to_ack; | 345 | __u8 num_acked; |
| 334 | __u16 sdu_len; | 346 | __u16 sdu_len; |
| 335 | __u16 partial_sdu_len; | 347 | __u16 partial_sdu_len; |
| 336 | struct sk_buff *sdu; | 348 | struct sk_buff *sdu; |
| 337 | 349 | ||
| 338 | __u8 ident; | 350 | __u8 ident; |
| 339 | 351 | ||
| 352 | __u8 tx_win; | ||
| 353 | __u8 max_tx; | ||
| 340 | __u8 remote_tx_win; | 354 | __u8 remote_tx_win; |
| 341 | __u8 remote_max_tx; | 355 | __u8 remote_max_tx; |
| 342 | __u16 retrans_timeout; | 356 | __u16 retrans_timeout; |
| 343 | __u16 monitor_timeout; | 357 | __u16 monitor_timeout; |
| 344 | __u16 max_pdu_size; | 358 | __u16 remote_mps; |
| 359 | __u16 mps; | ||
| 345 | 360 | ||
| 346 | __le16 sport; | 361 | __le16 sport; |
| 347 | 362 | ||
| 348 | struct timer_list retrans_timer; | 363 | struct timer_list retrans_timer; |
| 349 | struct timer_list monitor_timer; | 364 | struct timer_list monitor_timer; |
| 365 | struct timer_list ack_timer; | ||
| 350 | struct sk_buff_head tx_queue; | 366 | struct sk_buff_head tx_queue; |
| 351 | struct sk_buff_head srej_queue; | 367 | struct sk_buff_head srej_queue; |
| 368 | struct sk_buff_head busy_queue; | ||
| 369 | struct work_struct busy_work; | ||
| 352 | struct srej_list srej_l; | 370 | struct srej_list srej_l; |
| 353 | struct l2cap_conn *conn; | 371 | struct l2cap_conn *conn; |
| 354 | struct sock *next_c; | 372 | struct sock *next_c; |
| @@ -367,19 +385,24 @@ struct l2cap_pinfo { | |||
| 367 | #define L2CAP_CONF_MAX_CONF_REQ 2 | 385 | #define L2CAP_CONF_MAX_CONF_REQ 2 |
| 368 | #define L2CAP_CONF_MAX_CONF_RSP 2 | 386 | #define L2CAP_CONF_MAX_CONF_RSP 2 |
| 369 | 387 | ||
| 370 | #define L2CAP_CONN_SAR_SDU 0x01 | 388 | #define L2CAP_CONN_SAR_SDU 0x0001 |
| 371 | #define L2CAP_CONN_SREJ_SENT 0x02 | 389 | #define L2CAP_CONN_SREJ_SENT 0x0002 |
| 372 | #define L2CAP_CONN_WAIT_F 0x04 | 390 | #define L2CAP_CONN_WAIT_F 0x0004 |
| 373 | #define L2CAP_CONN_SREJ_ACT 0x08 | 391 | #define L2CAP_CONN_SREJ_ACT 0x0008 |
| 374 | #define L2CAP_CONN_SEND_PBIT 0x10 | 392 | #define L2CAP_CONN_SEND_PBIT 0x0010 |
| 375 | #define L2CAP_CONN_REMOTE_BUSY 0x20 | 393 | #define L2CAP_CONN_REMOTE_BUSY 0x0020 |
| 376 | #define L2CAP_CONN_LOCAL_BUSY 0x40 | 394 | #define L2CAP_CONN_LOCAL_BUSY 0x0040 |
| 377 | #define L2CAP_CONN_REJ_ACT 0x80 | 395 | #define L2CAP_CONN_REJ_ACT 0x0080 |
| 396 | #define L2CAP_CONN_SEND_FBIT 0x0100 | ||
| 397 | #define L2CAP_CONN_RNR_SENT 0x0200 | ||
| 398 | #define L2CAP_CONN_SAR_RETRY 0x0400 | ||
| 378 | 399 | ||
| 379 | #define __mod_retrans_timer() mod_timer(&l2cap_pi(sk)->retrans_timer, \ | 400 | #define __mod_retrans_timer() mod_timer(&l2cap_pi(sk)->retrans_timer, \ |
| 380 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); | 401 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); |
| 381 | #define __mod_monitor_timer() mod_timer(&l2cap_pi(sk)->monitor_timer, \ | 402 | #define __mod_monitor_timer() mod_timer(&l2cap_pi(sk)->monitor_timer, \ |
| 382 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); | 403 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); |
| 404 | #define __mod_ack_timer() mod_timer(&l2cap_pi(sk)->ack_timer, \ | ||
| 405 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); | ||
| 383 | 406 | ||
| 384 | static inline int l2cap_tx_window_full(struct sock *sk) | 407 | static inline int l2cap_tx_window_full(struct sock *sk) |
| 385 | { | 408 | { |
