l2cap.h (f3f668b0ef4399b67e60e4c10a30099d630a6206) | l2cap.h (0e8b207e8a4442f1a662e1a3827e61e40279630a) |
---|---|
1/* 2 BlueZ - Bluetooth protocol stack for Linux 3 Copyright (C) 2000-2001 Qualcomm Incorporated 4 Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org> 5 Copyright (C) 2010 Google Inc. 6 7 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> 8 --- 13 unchanged lines hidden (view full) --- 22 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 23 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 24 SOFTWARE IS DISCLAIMED. 25*/ 26 27#ifndef __L2CAP_H 28#define __L2CAP_H 29 | 1/* 2 BlueZ - Bluetooth protocol stack for Linux 3 Copyright (C) 2000-2001 Qualcomm Incorporated 4 Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org> 5 Copyright (C) 2010 Google Inc. 6 7 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> 8 --- 13 unchanged lines hidden (view full) --- 22 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 23 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 24 SOFTWARE IS DISCLAIMED. 25*/ 26 27#ifndef __L2CAP_H 28#define __L2CAP_H 29 |
30#include <asm/unaligned.h> 31 |
|
30/* L2CAP defaults */ 31#define L2CAP_DEFAULT_MTU 672 32#define L2CAP_DEFAULT_MIN_MTU 48 33#define L2CAP_DEFAULT_FLUSH_TO 0xffff 34#define L2CAP_DEFAULT_TX_WINDOW 63 | 32/* L2CAP defaults */ 33#define L2CAP_DEFAULT_MTU 672 34#define L2CAP_DEFAULT_MIN_MTU 48 35#define L2CAP_DEFAULT_FLUSH_TO 0xffff 36#define L2CAP_DEFAULT_TX_WINDOW 63 |
37#define L2CAP_DEFAULT_EXT_WINDOW 0x3FFF |
|
35#define L2CAP_DEFAULT_MAX_TX 3 36#define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ 37#define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ 38#define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ 39#define L2CAP_DEFAULT_ACK_TO 200 40#define L2CAP_LE_DEFAULT_MTU 23 | 38#define L2CAP_DEFAULT_MAX_TX 3 39#define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ 40#define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ 41#define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ 42#define L2CAP_DEFAULT_ACK_TO 200 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) 43#define L2CAP_DISC_REJ_TIMEOUT (5000) /* 5 seconds */ 44#define L2CAP_ENC_TIMEOUT (5000) /* 5 seconds */ 45#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ 46#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ | 48#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ 49#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ |
47 48/* L2CAP socket address */ 49struct sockaddr_l2 { 50 sa_family_t l2_family; 51 __le16 l2_psm; 52 bdaddr_t l2_bdaddr; 53 __le16 l2_cid; 54}; --- 34 unchanged lines hidden (view full) --- 89#define L2CAP_DISCONN_RSP 0x07 90#define L2CAP_ECHO_REQ 0x08 91#define L2CAP_ECHO_RSP 0x09 92#define L2CAP_INFO_REQ 0x0a 93#define L2CAP_INFO_RSP 0x0b 94#define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 95#define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 96 | 50 51/* L2CAP socket address */ 52struct sockaddr_l2 { 53 sa_family_t l2_family; 54 __le16 l2_psm; 55 bdaddr_t l2_bdaddr; 56 __le16 l2_cid; 57}; --- 34 unchanged lines hidden (view full) --- 92#define L2CAP_DISCONN_RSP 0x07 93#define L2CAP_ECHO_REQ 0x08 94#define L2CAP_ECHO_RSP 0x09 95#define L2CAP_INFO_REQ 0x0a 96#define L2CAP_INFO_RSP 0x0b 97#define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 98#define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 99 |
97/* L2CAP feature mask */ | 100/* L2CAP extended feature mask */ |
98#define L2CAP_FEAT_FLOWCTL 0x00000001 99#define L2CAP_FEAT_RETRANS 0x00000002 | 101#define L2CAP_FEAT_FLOWCTL 0x00000001 102#define L2CAP_FEAT_RETRANS 0x00000002 |
103#define L2CAP_FEAT_BIDIR_QOS 0x00000004 |
|
100#define L2CAP_FEAT_ERTM 0x00000008 101#define L2CAP_FEAT_STREAMING 0x00000010 102#define L2CAP_FEAT_FCS 0x00000020 | 104#define L2CAP_FEAT_ERTM 0x00000008 105#define L2CAP_FEAT_STREAMING 0x00000010 106#define L2CAP_FEAT_FCS 0x00000020 |
107#define L2CAP_FEAT_EXT_FLOW 0x00000040 |
|
103#define L2CAP_FEAT_FIXED_CHAN 0x00000080 | 108#define L2CAP_FEAT_FIXED_CHAN 0x00000080 |
109#define L2CAP_FEAT_EXT_WINDOW 0x00000100 110#define L2CAP_FEAT_UCD 0x00000200 |
|
104 105/* L2CAP checksum option */ 106#define L2CAP_FCS_NONE 0x00 107#define L2CAP_FCS_CRC16 0x01 108 109/* L2CAP Control Field bit masks */ | 111 112/* L2CAP checksum option */ 113#define L2CAP_FCS_NONE 0x00 114#define L2CAP_FCS_CRC16 0x01 115 116/* L2CAP Control Field bit masks */ |
110#define L2CAP_CTRL_SAR 0xC000 111#define L2CAP_CTRL_REQSEQ 0x3F00 112#define L2CAP_CTRL_TXSEQ 0x007E 113#define L2CAP_CTRL_RETRANS 0x0080 114#define L2CAP_CTRL_FINAL 0x0080 115#define L2CAP_CTRL_POLL 0x0010 116#define L2CAP_CTRL_SUPERVISE 0x000C 117#define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ | 117#define L2CAP_CTRL_SAR 0xC000 118#define L2CAP_CTRL_REQSEQ 0x3F00 119#define L2CAP_CTRL_TXSEQ 0x007E 120#define L2CAP_CTRL_SUPERVISE 0x000C |
118 | 121 |
119#define L2CAP_CTRL_TXSEQ_SHIFT 1 120#define L2CAP_CTRL_REQSEQ_SHIFT 8 121#define L2CAP_CTRL_SAR_SHIFT 14 | 122#define L2CAP_CTRL_RETRANS 0x0080 123#define L2CAP_CTRL_FINAL 0x0080 124#define L2CAP_CTRL_POLL 0x0010 125#define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ |
122 | 126 |
127#define L2CAP_CTRL_TXSEQ_SHIFT 1 128#define L2CAP_CTRL_SUPER_SHIFT 2 129#define L2CAP_CTRL_REQSEQ_SHIFT 8 130#define L2CAP_CTRL_SAR_SHIFT 14 131 132/* L2CAP Extended Control Field bit mask */ 133#define L2CAP_EXT_CTRL_TXSEQ 0xFFFC0000 134#define L2CAP_EXT_CTRL_SAR 0x00030000 135#define L2CAP_EXT_CTRL_SUPERVISE 0x00030000 136#define L2CAP_EXT_CTRL_REQSEQ 0x0000FFFC 137 138#define L2CAP_EXT_CTRL_POLL 0x00040000 139#define L2CAP_EXT_CTRL_FINAL 0x00000002 140#define L2CAP_EXT_CTRL_FRAME_TYPE 0x00000001 /* I- or S-Frame */ 141 142#define L2CAP_EXT_CTRL_REQSEQ_SHIFT 2 143#define L2CAP_EXT_CTRL_SAR_SHIFT 16 144#define L2CAP_EXT_CTRL_SUPER_SHIFT 16 145#define L2CAP_EXT_CTRL_TXSEQ_SHIFT 18 146 |
|
123/* L2CAP Supervisory Function */ | 147/* L2CAP Supervisory Function */ |
124#define L2CAP_SUPER_RCV_READY 0x0000 125#define L2CAP_SUPER_REJECT 0x0004 126#define L2CAP_SUPER_RCV_NOT_READY 0x0008 127#define L2CAP_SUPER_SELECT_REJECT 0x000C | 148#define L2CAP_SUPER_RR 0x00 149#define L2CAP_SUPER_REJ 0x01 150#define L2CAP_SUPER_RNR 0x02 151#define L2CAP_SUPER_SREJ 0x03 |
128 129/* L2CAP Segmentation and Reassembly */ | 152 153/* L2CAP Segmentation and Reassembly */ |
130#define L2CAP_SDU_UNSEGMENTED 0x0000 131#define L2CAP_SDU_START 0x4000 132#define L2CAP_SDU_END 0x8000 133#define L2CAP_SDU_CONTINUE 0xC000 | 154#define L2CAP_SAR_UNSEGMENTED 0x00 155#define L2CAP_SAR_START 0x01 156#define L2CAP_SAR_END 0x02 157#define L2CAP_SAR_CONTINUE 0x03 |
134 135/* L2CAP Command rej. reasons */ | 158 159/* L2CAP Command rej. reasons */ |
136#define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 137#define L2CAP_REJ_MTU_EXCEEDED 0x0001 138#define L2CAP_REJ_INVALID_CID 0x0002 | 160#define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 161#define L2CAP_REJ_MTU_EXCEEDED 0x0001 162#define L2CAP_REJ_INVALID_CID 0x0002 |
139 | 163 |
140 | |
141/* L2CAP structures */ 142struct l2cap_hdr { 143 __le16 len; 144 __le16 cid; 145} __packed; 146#define L2CAP_HDR_SIZE 4 | 164/* L2CAP structures */ 165struct l2cap_hdr { 166 __le16 len; 167 __le16 cid; 168} __packed; 169#define L2CAP_HDR_SIZE 4 |
170#define L2CAP_ENH_HDR_SIZE 6 171#define L2CAP_EXT_HDR_SIZE 8 |
|
147 | 172 |
173#define L2CAP_FCS_SIZE 2 174#define L2CAP_SDULEN_SIZE 2 175#define L2CAP_PSMLEN_SIZE 2 176 |
|
148struct l2cap_cmd_hdr { 149 __u8 code; 150 __u8 ident; 151 __le16 len; 152} __packed; 153#define L2CAP_CMD_HDR_SIZE 4 154 155struct l2cap_cmd_rej_unk { --- 56 unchanged lines hidden (view full) --- 212 __le16 result; 213 __u8 data[0]; 214} __packed; 215 216#define L2CAP_CONF_SUCCESS 0x0000 217#define L2CAP_CONF_UNACCEPT 0x0001 218#define L2CAP_CONF_REJECT 0x0002 219#define L2CAP_CONF_UNKNOWN 0x0003 | 177struct l2cap_cmd_hdr { 178 __u8 code; 179 __u8 ident; 180 __le16 len; 181} __packed; 182#define L2CAP_CMD_HDR_SIZE 4 183 184struct l2cap_cmd_rej_unk { --- 56 unchanged lines hidden (view full) --- 241 __le16 result; 242 __u8 data[0]; 243} __packed; 244 245#define L2CAP_CONF_SUCCESS 0x0000 246#define L2CAP_CONF_UNACCEPT 0x0001 247#define L2CAP_CONF_REJECT 0x0002 248#define L2CAP_CONF_UNKNOWN 0x0003 |
249#define L2CAP_CONF_PENDING 0x0004 250#define L2CAP_CONF_EFS_REJECT 0x0005 |
|
220 221struct l2cap_conf_opt { 222 __u8 type; 223 __u8 len; 224 __u8 val[0]; 225} __packed; 226#define L2CAP_CONF_OPT_SIZE 2 227 228#define L2CAP_CONF_HINT 0x80 229#define L2CAP_CONF_MASK 0x7f 230 231#define L2CAP_CONF_MTU 0x01 232#define L2CAP_CONF_FLUSH_TO 0x02 233#define L2CAP_CONF_QOS 0x03 234#define L2CAP_CONF_RFC 0x04 235#define L2CAP_CONF_FCS 0x05 | 251 252struct l2cap_conf_opt { 253 __u8 type; 254 __u8 len; 255 __u8 val[0]; 256} __packed; 257#define L2CAP_CONF_OPT_SIZE 2 258 259#define L2CAP_CONF_HINT 0x80 260#define L2CAP_CONF_MASK 0x7f 261 262#define L2CAP_CONF_MTU 0x01 263#define L2CAP_CONF_FLUSH_TO 0x02 264#define L2CAP_CONF_QOS 0x03 265#define L2CAP_CONF_RFC 0x04 266#define L2CAP_CONF_FCS 0x05 |
267#define L2CAP_CONF_EFS 0x06 268#define L2CAP_CONF_EWS 0x07 |
|
236 237#define L2CAP_CONF_MAX_SIZE 22 238 239struct l2cap_conf_rfc { 240 __u8 mode; 241 __u8 txwin_size; 242 __u8 max_transmit; 243 __le16 retrans_timeout; 244 __le16 monitor_timeout; 245 __le16 max_pdu_size; 246} __packed; 247 248#define L2CAP_MODE_BASIC 0x00 249#define L2CAP_MODE_RETRANS 0x01 250#define L2CAP_MODE_FLOWCTL 0x02 251#define L2CAP_MODE_ERTM 0x03 252#define L2CAP_MODE_STREAMING 0x04 253 | 269 270#define L2CAP_CONF_MAX_SIZE 22 271 272struct l2cap_conf_rfc { 273 __u8 mode; 274 __u8 txwin_size; 275 __u8 max_transmit; 276 __le16 retrans_timeout; 277 __le16 monitor_timeout; 278 __le16 max_pdu_size; 279} __packed; 280 281#define L2CAP_MODE_BASIC 0x00 282#define L2CAP_MODE_RETRANS 0x01 283#define L2CAP_MODE_FLOWCTL 0x02 284#define L2CAP_MODE_ERTM 0x03 285#define L2CAP_MODE_STREAMING 0x04 286 |
287struct l2cap_conf_efs { 288 __u8 id; 289 __u8 stype; 290 __le16 msdu; 291 __le32 sdu_itime; 292 __le32 acc_lat; 293 __le32 flush_to; 294} __packed; 295 296#define L2CAP_SERV_NOTRAFIC 0x00 297#define L2CAP_SERV_BESTEFFORT 0x01 298#define L2CAP_SERV_GUARANTEED 0x02 299 300#define L2CAP_BESTEFFORT_ID 0x01 301 |
|
254struct l2cap_disconn_req { 255 __le16 dcid; 256 __le16 scid; 257} __packed; 258 259struct l2cap_disconn_rsp { 260 __le16 dcid; 261 __le16 scid; --- 5 unchanged lines hidden (view full) --- 267 268struct l2cap_info_rsp { 269 __le16 type; 270 __le16 result; 271 __u8 data[0]; 272} __packed; 273 274/* info type */ | 302struct l2cap_disconn_req { 303 __le16 dcid; 304 __le16 scid; 305} __packed; 306 307struct l2cap_disconn_rsp { 308 __le16 dcid; 309 __le16 scid; --- 5 unchanged lines hidden (view full) --- 315 316struct l2cap_info_rsp { 317 __le16 type; 318 __le16 result; 319 __u8 data[0]; 320} __packed; 321 322/* info type */ |
275#define L2CAP_IT_CL_MTU 0x0001 276#define L2CAP_IT_FEAT_MASK 0x0002 277#define L2CAP_IT_FIXED_CHAN 0x0003 | 323#define L2CAP_IT_CL_MTU 0x0001 324#define L2CAP_IT_FEAT_MASK 0x0002 325#define L2CAP_IT_FIXED_CHAN 0x0003 |
278 279/* info result */ | 326 327/* info result */ |
280#define L2CAP_IR_SUCCESS 0x0000 281#define L2CAP_IR_NOTSUPP 0x0001 | 328#define L2CAP_IR_SUCCESS 0x0000 329#define L2CAP_IR_NOTSUPP 0x0001 |
282 283struct l2cap_conn_param_update_req { 284 __le16 min; 285 __le16 max; 286 __le16 latency; 287 __le16 to_multiplier; 288} __packed; 289 290struct l2cap_conn_param_update_rsp { 291 __le16 result; 292} __packed; 293 294/* Connection Parameters result */ 295#define L2CAP_CONN_PARAM_ACCEPTED 0x0000 296#define L2CAP_CONN_PARAM_REJECTED 0x0001 297 298/* ----- L2CAP channels and connections ----- */ 299struct srej_list { | 330 331struct l2cap_conn_param_update_req { 332 __le16 min; 333 __le16 max; 334 __le16 latency; 335 __le16 to_multiplier; 336} __packed; 337 338struct l2cap_conn_param_update_rsp { 339 __le16 result; 340} __packed; 341 342/* Connection Parameters result */ 343#define L2CAP_CONN_PARAM_ACCEPTED 0x0000 344#define L2CAP_CONN_PARAM_REJECTED 0x0001 345 346/* ----- L2CAP channels and connections ----- */ 347struct srej_list { |
300 __u8 tx_seq; | 348 __u16 tx_seq; |
301 struct list_head list; 302}; 303 304struct l2cap_chan { 305 struct sock *sk; 306 307 struct l2cap_conn *conn; 308 --- 9 unchanged lines hidden (view full) --- 318 __u16 omtu; 319 __u16 flush_to; 320 __u8 mode; 321 __u8 chan_type; 322 323 __le16 sport; 324 325 __u8 sec_level; | 349 struct list_head list; 350}; 351 352struct l2cap_chan { 353 struct sock *sk; 354 355 struct l2cap_conn *conn; 356 --- 9 unchanged lines hidden (view full) --- 366 __u16 omtu; 367 __u16 flush_to; 368 __u8 mode; 369 __u8 chan_type; 370 371 __le16 sport; 372 373 __u8 sec_level; |
326 __u8 role_switch; 327 __u8 force_reliable; 328 __u8 flushable; 329 __u8 force_active; | |
330 331 __u8 ident; 332 333 __u8 conf_req[64]; 334 __u8 conf_len; 335 __u8 num_conf_req; 336 __u8 num_conf_rsp; 337 338 __u8 fcs; 339 | 374 375 __u8 ident; 376 377 __u8 conf_req[64]; 378 __u8 conf_len; 379 __u8 num_conf_req; 380 __u8 num_conf_rsp; 381 382 __u8 fcs; 383 |
340 __u8 tx_win; | 384 __u16 tx_win; 385 __u16 tx_win_max; |
341 __u8 max_tx; 342 __u16 retrans_timeout; 343 __u16 monitor_timeout; 344 __u16 mps; 345 346 unsigned long conf_state; 347 unsigned long conn_state; | 386 __u8 max_tx; 387 __u16 retrans_timeout; 388 __u16 monitor_timeout; 389 __u16 mps; 390 391 unsigned long conf_state; 392 unsigned long conn_state; |
393 unsigned long flags; |
|
348 | 394 |
349 __u8 next_tx_seq; 350 __u8 expected_ack_seq; 351 __u8 expected_tx_seq; 352 __u8 buffer_seq; 353 __u8 buffer_seq_srej; 354 __u8 srej_save_reqseq; 355 __u8 frames_sent; 356 __u8 unacked_frames; | 395 __u16 next_tx_seq; 396 __u16 expected_ack_seq; 397 __u16 expected_tx_seq; 398 __u16 buffer_seq; 399 __u16 buffer_seq_srej; 400 __u16 srej_save_reqseq; 401 __u16 frames_sent; 402 __u16 unacked_frames; |
357 __u8 retry_count; 358 __u8 num_acked; 359 __u16 sdu_len; 360 struct sk_buff *sdu; 361 struct sk_buff *sdu_last_frag; 362 | 403 __u8 retry_count; 404 __u8 num_acked; 405 __u16 sdu_len; 406 struct sk_buff *sdu; 407 struct sk_buff *sdu_last_frag; 408 |
363 __u8 remote_tx_win; | 409 __u16 remote_tx_win; |
364 __u8 remote_max_tx; 365 __u16 remote_mps; 366 | 410 __u8 remote_max_tx; 411 __u16 remote_mps; 412 |
413 __u8 local_id; 414 __u8 local_stype; 415 __u16 local_msdu; 416 __u32 local_sdu_itime; 417 __u32 local_acc_lat; 418 __u32 local_flush_to; 419 420 __u8 remote_id; 421 __u8 remote_stype; 422 __u16 remote_msdu; 423 __u32 remote_sdu_itime; 424 __u32 remote_acc_lat; 425 __u32 remote_flush_to; 426 |
|
367 struct timer_list chan_timer; 368 struct timer_list retrans_timer; 369 struct timer_list monitor_timer; 370 struct timer_list ack_timer; 371 struct sk_buff *tx_send_head; 372 struct sk_buff_head tx_q; 373 struct sk_buff_head srej_q; 374 struct list_head srej_l; --- 65 unchanged lines hidden (view full) --- 440 CONF_REQ_SENT, 441 CONF_INPUT_DONE, 442 CONF_OUTPUT_DONE, 443 CONF_MTU_DONE, 444 CONF_MODE_DONE, 445 CONF_CONNECT_PEND, 446 CONF_NO_FCS_RECV, 447 CONF_STATE2_DEVICE, | 427 struct timer_list chan_timer; 428 struct timer_list retrans_timer; 429 struct timer_list monitor_timer; 430 struct timer_list ack_timer; 431 struct sk_buff *tx_send_head; 432 struct sk_buff_head tx_q; 433 struct sk_buff_head srej_q; 434 struct list_head srej_l; --- 65 unchanged lines hidden (view full) --- 500 CONF_REQ_SENT, 501 CONF_INPUT_DONE, 502 CONF_OUTPUT_DONE, 503 CONF_MTU_DONE, 504 CONF_MODE_DONE, 505 CONF_CONNECT_PEND, 506 CONF_NO_FCS_RECV, 507 CONF_STATE2_DEVICE, |
508 CONF_EWS_RECV, 509 CONF_LOC_CONF_PEND, 510 CONF_REM_CONF_PEND, |
|
448}; 449 450#define L2CAP_CONF_MAX_CONF_REQ 2 451#define L2CAP_CONF_MAX_CONF_RSP 2 452 453enum { 454 CONN_SREJ_SENT, 455 CONN_WAIT_F, 456 CONN_SREJ_ACT, 457 CONN_SEND_PBIT, 458 CONN_REMOTE_BUSY, 459 CONN_LOCAL_BUSY, 460 CONN_REJ_ACT, 461 CONN_SEND_FBIT, 462 CONN_RNR_SENT, 463}; 464 | 511}; 512 513#define L2CAP_CONF_MAX_CONF_REQ 2 514#define L2CAP_CONF_MAX_CONF_RSP 2 515 516enum { 517 CONN_SREJ_SENT, 518 CONN_WAIT_F, 519 CONN_SREJ_ACT, 520 CONN_SEND_PBIT, 521 CONN_REMOTE_BUSY, 522 CONN_LOCAL_BUSY, 523 CONN_REJ_ACT, 524 CONN_SEND_FBIT, 525 CONN_RNR_SENT, 526}; 527 |
528/* Definitions for flags in l2cap_chan */ 529enum { 530 FLAG_ROLE_SWITCH, 531 FLAG_FORCE_ACTIVE, 532 FLAG_FORCE_RELIABLE, 533 FLAG_FLUSHABLE, 534 FLAG_EXT_CTRL, 535 FLAG_EFS_ENABLE, 536}; 537 |
|
465#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) 467#define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ 468 L2CAP_DEFAULT_RETRANS_TO); 469#define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) 470#define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \ 471 L2CAP_DEFAULT_MONITOR_TO); 472#define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) 473#define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ 474 L2CAP_DEFAULT_ACK_TO); 475#define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) 476 | 538#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) 539#define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) 540#define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ 541 L2CAP_DEFAULT_RETRANS_TO); 542#define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) 543#define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \ 544 L2CAP_DEFAULT_MONITOR_TO); 545#define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) 546#define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ 547 L2CAP_DEFAULT_ACK_TO); 548#define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) 549 |
550static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2) 551{ 552 int offset; 553 554 offset = (seq1 - seq2) % (chan->tx_win_max + 1); 555 if (offset < 0) 556 offset += (chan->tx_win_max + 1); 557 558 return offset; 559} 560 561static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq) 562{ 563 return (seq + 1) % (chan->tx_win_max + 1); 564} 565 |
|
477static inline int l2cap_tx_window_full(struct l2cap_chan *ch) 478{ 479 int sub; 480 481 sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; 482 483 if (sub < 0) 484 sub += 64; 485 486 return sub == ch->remote_tx_win; 487} 488 | 566static inline int l2cap_tx_window_full(struct l2cap_chan *ch) 567{ 568 int sub; 569 570 sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; 571 572 if (sub < 0) 573 sub += 64; 574 575 return sub == ch->remote_tx_win; 576} 577 |
489#define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) 490#define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8) 491#define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) 492#define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) 493#define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) | 578static inline __u16 __get_reqseq(struct l2cap_chan *chan, __u32 ctrl) 579{ 580 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 581 return (ctrl & L2CAP_EXT_CTRL_REQSEQ) >> 582 L2CAP_EXT_CTRL_REQSEQ_SHIFT; 583 else 584 return (ctrl & L2CAP_CTRL_REQSEQ) >> L2CAP_CTRL_REQSEQ_SHIFT; 585} |
494 | 586 |
587static inline __u32 __set_reqseq(struct l2cap_chan *chan, __u32 reqseq) 588{ 589 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 590 return (reqseq << L2CAP_EXT_CTRL_REQSEQ_SHIFT) & 591 L2CAP_EXT_CTRL_REQSEQ; 592 else 593 return (reqseq << L2CAP_CTRL_REQSEQ_SHIFT) & L2CAP_CTRL_REQSEQ; 594} 595 596static inline __u16 __get_txseq(struct l2cap_chan *chan, __u32 ctrl) 597{ 598 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 599 return (ctrl & L2CAP_EXT_CTRL_TXSEQ) >> 600 L2CAP_EXT_CTRL_TXSEQ_SHIFT; 601 else 602 return (ctrl & L2CAP_CTRL_TXSEQ) >> L2CAP_CTRL_TXSEQ_SHIFT; 603} 604 605static inline __u32 __set_txseq(struct l2cap_chan *chan, __u32 txseq) 606{ 607 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 608 return (txseq << L2CAP_EXT_CTRL_TXSEQ_SHIFT) & 609 L2CAP_EXT_CTRL_TXSEQ; 610 else 611 return (txseq << L2CAP_CTRL_TXSEQ_SHIFT) & L2CAP_CTRL_TXSEQ; 612} 613 614static inline bool __is_sframe(struct l2cap_chan *chan, __u32 ctrl) 615{ 616 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 617 return ctrl & L2CAP_EXT_CTRL_FRAME_TYPE; 618 else 619 return ctrl & L2CAP_CTRL_FRAME_TYPE; 620} 621 622static inline __u32 __set_sframe(struct l2cap_chan *chan) 623{ 624 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 625 return L2CAP_EXT_CTRL_FRAME_TYPE; 626 else 627 return L2CAP_CTRL_FRAME_TYPE; 628} 629 630static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl) 631{ 632 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 633 return (ctrl & L2CAP_EXT_CTRL_SAR) >> L2CAP_EXT_CTRL_SAR_SHIFT; 634 else 635 return (ctrl & L2CAP_CTRL_SAR) >> L2CAP_CTRL_SAR_SHIFT; 636} 637 638static inline __u32 __set_ctrl_sar(struct l2cap_chan *chan, __u32 sar) 639{ 640 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 641 return (sar << L2CAP_EXT_CTRL_SAR_SHIFT) & L2CAP_EXT_CTRL_SAR; 642 else 643 return (sar << L2CAP_CTRL_SAR_SHIFT) & L2CAP_CTRL_SAR; 644} 645 646static inline bool __is_sar_start(struct l2cap_chan *chan, __u32 ctrl) 647{ 648 return __get_ctrl_sar(chan, ctrl) == L2CAP_SAR_START; 649} 650 651static inline __u32 __get_sar_mask(struct l2cap_chan *chan) 652{ 653 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 654 return L2CAP_EXT_CTRL_SAR; 655 else 656 return L2CAP_CTRL_SAR; 657} 658 659static inline __u8 __get_ctrl_super(struct l2cap_chan *chan, __u32 ctrl) 660{ 661 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 662 return (ctrl & L2CAP_EXT_CTRL_SUPERVISE) >> 663 L2CAP_EXT_CTRL_SUPER_SHIFT; 664 else 665 return (ctrl & L2CAP_CTRL_SUPERVISE) >> L2CAP_CTRL_SUPER_SHIFT; 666} 667 668static inline __u32 __set_ctrl_super(struct l2cap_chan *chan, __u32 super) 669{ 670 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 671 return (super << L2CAP_EXT_CTRL_SUPER_SHIFT) & 672 L2CAP_EXT_CTRL_SUPERVISE; 673 else 674 return (super << L2CAP_CTRL_SUPER_SHIFT) & 675 L2CAP_CTRL_SUPERVISE; 676} 677 678static inline __u32 __set_ctrl_final(struct l2cap_chan *chan) 679{ 680 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 681 return L2CAP_EXT_CTRL_FINAL; 682 else 683 return L2CAP_CTRL_FINAL; 684} 685 686static inline bool __is_ctrl_final(struct l2cap_chan *chan, __u32 ctrl) 687{ 688 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 689 return ctrl & L2CAP_EXT_CTRL_FINAL; 690 else 691 return ctrl & L2CAP_CTRL_FINAL; 692} 693 694static inline __u32 __set_ctrl_poll(struct l2cap_chan *chan) 695{ 696 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 697 return L2CAP_EXT_CTRL_POLL; 698 else 699 return L2CAP_CTRL_POLL; 700} 701 702static inline bool __is_ctrl_poll(struct l2cap_chan *chan, __u32 ctrl) 703{ 704 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 705 return ctrl & L2CAP_EXT_CTRL_POLL; 706 else 707 return ctrl & L2CAP_CTRL_POLL; 708} 709 710static inline __u32 __get_control(struct l2cap_chan *chan, void *p) 711{ 712 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 713 return get_unaligned_le32(p); 714 else 715 return get_unaligned_le16(p); 716} 717 718static inline void __put_control(struct l2cap_chan *chan, __u32 control, 719 void *p) 720{ 721 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 722 return put_unaligned_le32(control, p); 723 else 724 return put_unaligned_le16(control, p); 725} 726 727static inline __u8 __ctrl_size(struct l2cap_chan *chan) 728{ 729 if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 730 return L2CAP_EXT_HDR_SIZE - L2CAP_HDR_SIZE; 731 else 732 return L2CAP_ENH_HDR_SIZE - L2CAP_HDR_SIZE; 733} 734 |
|
495extern int disable_ertm; 496 497int l2cap_init_sockets(void); 498void l2cap_cleanup_sockets(void); 499 500void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); 501int __l2cap_wait_ack(struct sock *sk); 502 503int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); 504int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); 505 506struct l2cap_chan *l2cap_chan_create(struct sock *sk); 507void l2cap_chan_close(struct l2cap_chan *chan, int reason); 508void l2cap_chan_destroy(struct l2cap_chan *chan); 509int l2cap_chan_connect(struct l2cap_chan *chan); 510int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len); 511void l2cap_chan_busy(struct l2cap_chan *chan, int busy); 512 513#endif /* __L2CAP_H */ | 735extern int disable_ertm; 736 737int l2cap_init_sockets(void); 738void l2cap_cleanup_sockets(void); 739 740void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); 741int __l2cap_wait_ack(struct sock *sk); 742 743int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); 744int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); 745 746struct l2cap_chan *l2cap_chan_create(struct sock *sk); 747void l2cap_chan_close(struct l2cap_chan *chan, int reason); 748void l2cap_chan_destroy(struct l2cap_chan *chan); 749int l2cap_chan_connect(struct l2cap_chan *chan); 750int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len); 751void l2cap_chan_busy(struct l2cap_chan *chan, int busy); 752 753#endif /* __L2CAP_H */ |