• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 1999-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 #ifndef L2CDEFS_H
20 #define L2CDEFS_H
21 
22 #include <cstdint>
23 /* L2CAP command codes
24 */
25 #define L2CAP_CMD_REJECT 0x01
26 #define L2CAP_CMD_CONN_REQ 0x02
27 #define L2CAP_CMD_CONN_RSP 0x03
28 #define L2CAP_CMD_CONFIG_REQ 0x04
29 #define L2CAP_CMD_CONFIG_RSP 0x05
30 #define L2CAP_CMD_DISC_REQ 0x06
31 #define L2CAP_CMD_DISC_RSP 0x07
32 #define L2CAP_CMD_ECHO_REQ 0x08
33 #define L2CAP_CMD_ECHO_RSP 0x09
34 #define L2CAP_CMD_INFO_REQ 0x0A
35 #define L2CAP_CMD_INFO_RSP 0x0B
36 #define L2CAP_CMD_AMP_CONN_REQ 0x0C
37 #define L2CAP_CMD_AMP_MOVE_REQ 0x0E
38 #define L2CAP_CMD_BLE_UPDATE_REQ 0x12
39 #define L2CAP_CMD_BLE_UPDATE_RSP 0x13
40 #define L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ 0x14
41 #define L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES 0x15
42 #define L2CAP_CMD_BLE_FLOW_CTRL_CREDIT 0x16
43 /* Enhanced CoC */
44 #define L2CAP_CMD_CREDIT_BASED_CONN_REQ 0x17
45 #define L2CAP_CMD_CREDIT_BASED_CONN_RES 0x18
46 #define L2CAP_CMD_CREDIT_BASED_RECONFIG_REQ 0x19
47 #define L2CAP_CMD_CREDIT_BASED_RECONFIG_RES 0x1A
48 
49 /* Define some packet and header lengths
50 */
51 /* Length and CID                       */
52 #define L2CAP_PKT_OVERHEAD 4
53 /* Cmd code, Id and length              */
54 #define L2CAP_CMD_OVERHEAD 4
55 /* Reason (data is optional)            */
56 #define L2CAP_CMD_REJECT_LEN 2
57 /* PSM and source CID                   */
58 #define L2CAP_CONN_REQ_LEN 4
59 /* Dest CID, source CID, reason, status */
60 #define L2CAP_CONN_RSP_LEN 8
61 /* Dest CID, flags (data is optional)   */
62 #define L2CAP_CONFIG_REQ_LEN 4
63 /* Dest CID, flags, result,data optional*/
64 #define L2CAP_CONFIG_RSP_LEN 6
65 /* Dest CID, source CID                 */
66 #define L2CAP_DISC_REQ_LEN 4
67 /* Dest CID, source CID                 */
68 #define L2CAP_DISC_RSP_LEN 4
69 /* Data is optional                     */
70 #define L2CAP_ECHO_REQ_LEN 0
71 /* Data is optional                     */
72 #define L2CAP_ECHO_RSP_LEN 0
73 /* Info type, result (data is optional) */
74 #define L2CAP_INFO_RSP_LEN 4
75 
76 /* Min and max interval, latency, tout  */
77 #define L2CAP_CMD_BLE_UPD_REQ_LEN 8
78 /* Result                               */
79 #define L2CAP_CMD_BLE_UPD_RSP_LEN 2
80 
81 /* LE_PSM, SCID, MTU, MPS, Init Credit */
82 #define L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ_LEN 10
83 /* DCID, MTU, MPS, Init credit, Result */
84 #define L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES_LEN 10
85 /* CID, Credit */
86 #define L2CAP_CMD_BLE_FLOW_CTRL_CREDIT_LEN 4
87 
88 /* LE PSM, MTU, MPS, Initial Credits, SCIDS[] */
89 #define L2CAP_CMD_CREDIT_BASED_CONN_REQ_MIN_LEN 8
90 /* MTU, MPS, Initial Credits, Result, DCIDS[] */
91 #define L2CAP_CMD_CREDIT_BASED_CONN_RES_MIN_LEN 8
92 
93 /* MTU, MPS, DCIDS[] */
94 #define L2CAP_CMD_CREDIT_BASED_RECONFIG_REQ_MIN_LEN 4
95 /* Result */
96 #define L2CAP_CMD_CREDIT_BASED_RECONFIG_RES_LEN 2
97 
98 /* Define the packet boundary flags
99 */
100 #define L2CAP_PKT_START_NON_FLUSHABLE 0
101 #define L2CAP_PKT_START 2
102 #define L2CAP_PKT_CONTINUE 1
103 #define L2CAP_PKT_TYPE_SHIFT 12
104 
105 #define L2CAP_CONN_INTERNAL_MASK 0xF000
106 #define L2CAP_CONN_LE_MASK 0xFF00
107 
108 /* Define the LE L2CAP Connection Response Result codes
109  */
110 typedef enum : uint8_t {
111   L2CAP_LE_RESULT_CONN_OK = 0,
112   L2CAP_LE_RESULT_NO_PSM = 2,
113   L2CAP_LE_RESULT_NO_RESOURCES = 4,
114   L2CAP_LE_RESULT_INSUFFICIENT_AUTHENTICATION = 5,
115   L2CAP_LE_RESULT_INSUFFICIENT_AUTHORIZATION = 6,
116   L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP_KEY_SIZE = 7,
117   L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP = 8,
118   /* We don't like peer device response */
119   L2CAP_LE_RESULT_INVALID_SOURCE_CID = 9,
120   L2CAP_LE_RESULT_SOURCE_CID_ALREADY_ALLOCATED = 0x0A,
121   L2CAP_LE_RESULT_UNACCEPTABLE_PARAMETERS = 0x0B,
122   L2CAP_LE_RESULT_INVALID_PARAMETERS = 0x0C
123 } tL2CAP_LE_RESULT_CODE;
124 
125 /* Define the L2CAP connection result codes */
126 typedef enum : uint16_t {
127   L2CAP_CONN_OK = 0,
128   L2CAP_CONN_PENDING = 1,
129   L2CAP_CONN_NO_PSM = 2,
130   L2CAP_CONN_SECURITY_BLOCK = 3,
131   L2CAP_CONN_NO_RESOURCES = 4,
132   L2CAP_CONN_TIMEOUT = 0xEEEE,
133   /* Generic L2CAP conn failure reasons */
134   L2CAP_CONN_OTHER_ERROR = L2CAP_CONN_INTERNAL_MASK,
135   L2CAP_CONN_ACL_CONNECTION_FAILED = L2CAP_CONN_INTERNAL_MASK + 1,
136   L2CAP_CONN_CLIENT_SECURITY_CLEARANCE_FAILED = L2CAP_CONN_INTERNAL_MASK + 2,
137   L2CAP_CONN_NO_LINK = L2CAP_CONN_INTERNAL_MASK + 3,
138   L2CAP_CONN_CANCEL =
139       L2CAP_CONN_INTERNAL_MASK + 4, /* L2CAP connection cancelled */
140   /* For LE result codes converted to L2CAP conn failure code */
141   L2CAP_CONN_INSUFFICIENT_AUTHENTICATION =
142       L2CAP_CONN_LE_MASK + L2CAP_LE_RESULT_INSUFFICIENT_AUTHENTICATION,
143   L2CAP_CONN_INSUFFICIENT_AUTHORIZATION =
144       L2CAP_CONN_LE_MASK + L2CAP_LE_RESULT_INSUFFICIENT_AUTHORIZATION,
145   L2CAP_CONN_INSUFFICIENT_ENCRYP_KEY_SIZE =
146       L2CAP_CONN_LE_MASK + L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP_KEY_SIZE,
147   L2CAP_CONN_INSUFFICIENT_ENCRYP =
148       L2CAP_CONN_LE_MASK + L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP,
149   L2CAP_CONN_INVALID_SOURCE_CID =
150       L2CAP_CONN_LE_MASK + L2CAP_LE_RESULT_INVALID_SOURCE_CID,
151   L2CAP_CONN_SOURCE_CID_ALREADY_ALLOCATED =
152       L2CAP_CONN_LE_MASK + L2CAP_LE_RESULT_SOURCE_CID_ALREADY_ALLOCATED,
153   L2CAP_CONN_UNACCEPTABLE_PARAMETERS =
154       L2CAP_CONN_LE_MASK + L2CAP_LE_RESULT_UNACCEPTABLE_PARAMETERS,
155   L2CAP_CONN_INVALID_PARAMETERS =
156       L2CAP_CONN_LE_MASK + L2CAP_LE_RESULT_INVALID_PARAMETERS,
157 } tL2CAP_CONN;
158 
159 #ifndef CASE_RETURN_TEXT
160 #define CASE_RETURN_TEXT(code) \
161   case code:                   \
162     return #code
163 #endif
164 
l2cap_result_code_text(const tL2CAP_CONN & result)165 inline std::string l2cap_result_code_text(const tL2CAP_CONN& result) {
166   switch (result) {
167     CASE_RETURN_TEXT(L2CAP_CONN_OK);
168     CASE_RETURN_TEXT(L2CAP_CONN_PENDING);
169     CASE_RETURN_TEXT(L2CAP_CONN_NO_PSM);
170     CASE_RETURN_TEXT(L2CAP_CONN_SECURITY_BLOCK);
171     CASE_RETURN_TEXT(L2CAP_CONN_NO_RESOURCES);
172     CASE_RETURN_TEXT(L2CAP_CONN_TIMEOUT);
173     CASE_RETURN_TEXT(L2CAP_CONN_OTHER_ERROR);
174     CASE_RETURN_TEXT(L2CAP_CONN_ACL_CONNECTION_FAILED);
175     CASE_RETURN_TEXT(L2CAP_CONN_CLIENT_SECURITY_CLEARANCE_FAILED);
176     CASE_RETURN_TEXT(L2CAP_CONN_NO_LINK);
177     CASE_RETURN_TEXT(L2CAP_CONN_CANCEL);
178     CASE_RETURN_TEXT(L2CAP_CONN_INSUFFICIENT_AUTHENTICATION);
179     CASE_RETURN_TEXT(L2CAP_CONN_INSUFFICIENT_AUTHORIZATION);
180     CASE_RETURN_TEXT(L2CAP_CONN_INSUFFICIENT_ENCRYP_KEY_SIZE);
181     CASE_RETURN_TEXT(L2CAP_CONN_INSUFFICIENT_ENCRYP);
182     CASE_RETURN_TEXT(L2CAP_CONN_INVALID_SOURCE_CID);
183     CASE_RETURN_TEXT(L2CAP_CONN_SOURCE_CID_ALREADY_ALLOCATED);
184     CASE_RETURN_TEXT(L2CAP_CONN_UNACCEPTABLE_PARAMETERS);
185     CASE_RETURN_TEXT(L2CAP_CONN_INVALID_PARAMETERS);
186     default:
187       return std::string("UNKNOWN[") + std::to_string(result) +
188              std::string("]");
189   }
190 }
191 #undef CASE_RETURN_TEXT
192 
to_l2cap_result_code(uint16_t result)193 inline tL2CAP_CONN to_l2cap_result_code(uint16_t result) {
194   return static_cast<tL2CAP_CONN>(result);
195 }
196 
l2cap_le_result_code_text(const tL2CAP_LE_RESULT_CODE & code)197 inline std::string l2cap_le_result_code_text(
198     const tL2CAP_LE_RESULT_CODE& code) {
199   switch (code) {
200     case L2CAP_LE_RESULT_CONN_OK:
201       return std::string("le connection success");
202     case L2CAP_LE_RESULT_NO_PSM:
203       return std::string("le no psm service");
204     case L2CAP_LE_RESULT_NO_RESOURCES:
205       return std::string("le no resources");
206     case L2CAP_LE_RESULT_INSUFFICIENT_AUTHENTICATION:
207       return std::string("le authentication failed");
208     case L2CAP_LE_RESULT_INSUFFICIENT_AUTHORIZATION:
209       return std::string("le authorization failed");
210     case L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP_KEY_SIZE:
211       return std::string("le encryption key size failed");
212     case L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP:
213       return std::string("le encryption failed");
214     case L2CAP_LE_RESULT_INVALID_SOURCE_CID:
215       return std::string("le invalid source channel identifier");
216     case L2CAP_LE_RESULT_SOURCE_CID_ALREADY_ALLOCATED:
217       return std::string("le source channel identifier busy");
218     case L2CAP_LE_RESULT_UNACCEPTABLE_PARAMETERS:
219       return std::string("le unacceptable parameters");
220     case L2CAP_LE_RESULT_INVALID_PARAMETERS:
221       return std::string("invalid parameters");
222   }
223 }
224 
225 /* Credit based reconfig results code */
226 #define L2CAP_RECONFIG_SUCCEED 0
227 #define L2CAP_RECONFIG_REDUCTION_MTU_NO_ALLOWED 1
228 #define L2CAP_RECONFIG_REDUCTION_MPS_NO_ALLOWED 2
229 #define L2CAP_RECONFIG_INVALID_DCID 3
230 #define L2CAP_RECONFIG_UNACCAPTED_PARAM 4
231 
232 /* Define the L2CAP command reject reason codes
233 */
234 #define L2CAP_CMD_REJ_NOT_UNDERSTOOD 0
235 #define L2CAP_CMD_REJ_MTU_EXCEEDED 1
236 #define L2CAP_CMD_REJ_INVALID_CID 2
237 
238 /* L2CAP Predefined CIDs
239 */
240 enum : uint16_t {
241   L2CAP_SIGNALLING_CID = 1,
242   L2CAP_CONNECTIONLESS_CID = 2,
243   L2CAP_AMP_CID = 3,
244   L2CAP_ATT_CID = 4,
245   L2CAP_BLE_SIGNALLING_CID = 5,
246   L2CAP_SMP_CID = 6,
247   L2CAP_SMP_BR_CID = 7,
248   L2CAP_BASE_APPL_CID = 0x0040,
249 };
250 
251 /* Fixed Channels mask bits */
252 
253 /* Signal channel supported (Mandatory) */
254 #define L2CAP_FIXED_CHNL_SIG_BIT (1 << L2CAP_SIGNALLING_CID)
255 
256 /* Connectionless reception */
257 #define L2CAP_FIXED_CHNL_CNCTLESS_BIT (1 << L2CAP_CONNECTIONLESS_CID)
258 
259 /* Attribute protocol supported */
260 #define L2CAP_FIXED_CHNL_ATT_BIT (1 << L2CAP_ATT_CID)
261 
262 /* BLE Signalling supported */
263 #define L2CAP_FIXED_CHNL_BLE_SIG_BIT (1 << L2CAP_BLE_SIGNALLING_CID)
264 
265 /* BLE Security Mgr supported */
266 #define L2CAP_FIXED_CHNL_SMP_BIT (1 << L2CAP_SMP_CID)
267 
268 /* Security Mgr over BR supported */
269 #define L2CAP_FIXED_CHNL_SMP_BR_BIT (1 << L2CAP_SMP_BR_CID)
270 
271 /* Define the L2CAP configuration result codes
272 */
273 #define L2CAP_CFG_OK 0
274 #define L2CAP_CFG_UNACCEPTABLE_PARAMS 1
275 #define L2CAP_CFG_FAILED_NO_REASON 2
276 #define L2CAP_CFG_UNKNOWN_OPTIONS 3
277 #define L2CAP_CFG_PENDING 4
278 
279 static_assert(L2CAP_CONN_OTHER_ERROR != L2CAP_CFG_FAILED_NO_REASON,
280               "Different error code should be provided for Connect error and "
281               "Config error");
282 
283 /* Define the L2CAP configuration option types
284 */
285 #define L2CAP_CFG_TYPE_MTU 0x01
286 #define L2CAP_CFG_TYPE_FLUSH_TOUT 0x02
287 #define L2CAP_CFG_TYPE_QOS 0x03
288 #define L2CAP_CFG_TYPE_FCR 0x04
289 #define L2CAP_CFG_TYPE_FCS 0x05
290 #define L2CAP_CFG_TYPE_EXT_FLOW 0x06
291 
292 #define L2CAP_CFG_MTU_OPTION_LEN 2       /* MTU option length    */
293 #define L2CAP_CFG_FLUSH_OPTION_LEN 2     /* Flush option len     */
294 #define L2CAP_CFG_QOS_OPTION_LEN 22      /* QOS option length    */
295 #define L2CAP_CFG_FCR_OPTION_LEN 9       /* FCR option length    */
296 #define L2CAP_CFG_FCS_OPTION_LEN 1       /* FCR option length    */
297 #define L2CAP_CFG_EXT_FLOW_OPTION_LEN 16 /* Extended Flow Spec   */
298 #define L2CAP_CFG_OPTION_OVERHEAD 2      /* Type and length      */
299 
300 /* Configuration Cmd/Rsp Flags mask
301 */
302 #define L2CAP_CFG_FLAGS_MASK_CONT 0x0001 /* Flags mask: Continuation */
303 
304 /* FCS Check Option values
305 */
306 #define L2CAP_CFG_FCS_BYPASS 0 /* Bypass the FCS in streaming or ERTM modes */
307 #define L2CAP_CFG_FCS_USE \
308   1 /* Use the FCS in streaming or ERTM modes [default] */
309 
310 /* Default values for configuration
311 */
312 #define L2CAP_NO_AUTOMATIC_FLUSH 0xFFFF
313 
314 #define L2CAP_DEFAULT_MTU (672)
315 #define L2CAP_DEFAULT_SERV_TYPE 1
316 #define L2CAP_DEFAULT_TOKEN_RATE 0
317 #define L2CAP_DEFAULT_BUCKET_SIZE 0
318 #define L2CAP_DEFAULT_PEAK_BANDWIDTH 0
319 #define L2CAP_DEFAULT_LATENCY 0xFFFFFFFF
320 #define L2CAP_DEFAULT_DELAY 0xFFFFFFFF
321 
322 /* Define the L2CAP disconnect result codes
323 */
324 #define L2CAP_DISC_OK 0
325 #define L2CAP_DISC_TIMEOUT 0xEEEE
326 
327 /* Define the L2CAP info resp result codes
328 */
329 #define L2CAP_INFO_RESP_RESULT_SUCCESS 0
330 #define L2CAP_INFO_RESP_RESULT_NOT_SUPPORTED 1
331 
332 /* Define the info-type fields of information request & response
333 */
334 #define L2CAP_CONNLESS_MTU_INFO_TYPE 0x0001
335 /* Used in Information Req/Response */
336 #define L2CAP_EXTENDED_FEATURES_INFO_TYPE 0x0002
337 /* Used in AMP                      */
338 #define L2CAP_FIXED_CHANNELS_INFO_TYPE 0x0003
339 
340 /* Connectionless MTU size          */
341 #define L2CAP_CONNLESS_MTU_INFO_SIZE 2
342 /* Extended features array size     */
343 #define L2CAP_EXTENDED_FEATURES_ARRAY_SIZE 4
344 /* Fixed channel array size         */
345 #define L2CAP_FIXED_CHNL_ARRAY_SIZE 8
346 
347 /* Extended features mask bits
348 */
349 /* Enhanced retransmission mode           */
350 #define L2CAP_EXTFEA_ENH_RETRANS 0x00000008
351 /* Streaming Mode                         */
352 #define L2CAP_EXTFEA_STREAM_MODE 0x00000010
353 /* Optional FCS (if set No FCS desired)   */
354 #define L2CAP_EXTFEA_NO_CRC 0x00000020
355 /* Extended flow spec                     */
356 #define L2CAP_EXTFEA_EXT_FLOW_SPEC 0x00000040
357 /* Fixed channels                         */
358 #define L2CAP_EXTFEA_FIXED_CHNLS 0x00000080
359 /* Extended Window Size                   */
360 #define L2CAP_EXTFEA_EXT_WINDOW 0x00000100
361 /* Unicast Connectionless Data Reception  */
362 #define L2CAP_EXTFEA_UCD_RECEPTION 0x00000200
363 
364 /* Mask for locally supported features used in Information Response
365  * (default to none) */
366 #ifndef L2CAP_EXTFEA_SUPPORTED_MASK
367 #define L2CAP_EXTFEA_SUPPORTED_MASK 0
368 #endif
369 
370 /* Mask for LE supported features used in Information Response
371  * (default to none) */
372 #ifndef L2CAP_BLE_EXTFEA_MASK
373 #define L2CAP_BLE_EXTFEA_MASK 0
374 #endif
375 
376 /* Define a value that tells L2CAP to use the default HCI ACL buffer size */
377 #define L2CAP_INVALID_ERM_BUF_SIZE 0
378 /* Define a value that tells L2CAP to use the default MPS */
379 #define L2CAP_DEFAULT_ERM_MPS 0x0000
380 
381 #define L2CAP_FCR_OVERHEAD 2         /* Control word                 */
382 #define L2CAP_FCS_LEN 2              /* FCS takes 2 bytes */
383 #define L2CAP_SDU_LEN_OVERHEAD 2     /* SDU length field is 2 bytes */
384 #define L2CAP_SDU_LEN_OFFSET 2       /* SDU length offset is 2 bytes */
385 #define L2CAP_EXT_CONTROL_OVERHEAD 4 /* Extended Control Field       */
386 /* length(2), channel(2), control(4), SDU length(2) FCS(2) */
387 #define L2CAP_MAX_HEADER_FCS                                                  \
388   (L2CAP_PKT_OVERHEAD + L2CAP_EXT_CONTROL_OVERHEAD + L2CAP_SDU_LEN_OVERHEAD + \
389    L2CAP_FCS_LEN)
390 
391 /* TODO: This value can probably be optimized per transport, and per L2CAP
392  * socket type, but this should not bring any big performance improvements. For
393  * LE CoC, it should be biggest multiple of "PDU length" smaller than 0xffff (so
394  * depend on controller buffer size), for Classic, making it multiple of PDU
395  * length and also of the 3DH5 air including the l2cap headers in each packet.
396  */
397 #define L2CAP_SDU_LENGTH_MAX (8080 + 26 - (L2CAP_MIN_OFFSET + 6))
398 constexpr uint16_t L2CAP_SDU_LENGTH_LE_MAX = 0xffff;
399 
400 /* SAR bits in the control word
401 */
402 /* Control word to begin with for unsegmented PDU*/
403 #define L2CAP_FCR_UNSEG_SDU 0x0000
404 /* ...for Starting PDU of a semented SDU */
405 #define L2CAP_FCR_START_SDU 0x4000
406 /* ...for ending PDU of a segmented SDU */
407 #define L2CAP_FCR_END_SDU 0x8000
408 /* ...for continuation PDU of a segmented SDU */
409 #define L2CAP_FCR_CONT_SDU 0xc000
410 
411 /* Supervisory frame types */
412 /* Supervisory frame - RR                          */
413 #define L2CAP_FCR_SUP_RR 0x0000
414 /* Supervisory frame - REJ                         */
415 #define L2CAP_FCR_SUP_REJ 0x0001
416 /* Supervisory frame - RNR                         */
417 #define L2CAP_FCR_SUP_RNR 0x0002
418 /* Supervisory frame - SREJ                        */
419 #define L2CAP_FCR_SUP_SREJ 0x0003
420 
421 /* Mask to get the SAR bits from control word */
422 #define L2CAP_FCR_SAR_BITS 0xC000
423 /* Bits to shift right to get the SAR bits from ctrl-word */
424 #define L2CAP_FCR_SAR_BITS_SHIFT 14
425 
426 /* Mask to check if a PDU is S-frame */
427 #define L2CAP_FCR_S_FRAME_BIT 0x0001
428 /* Mask to get the req-seq from control word */
429 #define L2CAP_FCR_REQ_SEQ_BITS 0x3F00
430 /* Bits to shift right to get the req-seq from ctrl-word */
431 #define L2CAP_FCR_REQ_SEQ_BITS_SHIFT 8
432 /* Mask on get the tx-seq from control word */
433 #define L2CAP_FCR_TX_SEQ_BITS 0x007E
434 /* Bits to shift right to get the tx-seq from ctrl-word */
435 #define L2CAP_FCR_TX_SEQ_BITS_SHIFT 1
436 
437 /* F-bit in the control word (Sup and I frames)  */
438 #define L2CAP_FCR_F_BIT 0x0080
439 /* P-bit in the control word (Sup frames only)   */
440 #define L2CAP_FCR_P_BIT 0x0010
441 
442 #define L2CAP_FCR_F_BIT_SHIFT 7
443 #define L2CAP_FCR_P_BIT_SHIFT 4
444 
445 /* Mask to get the segmentation bits from ctrl-word */
446 #define L2CAP_FCR_SEG_BITS 0xC000
447 /* Bits to shift right to get the S-bits from ctrl-word */
448 #define L2CAP_FCR_SUP_SHIFT 2
449 /* Mask to get the supervisory bits from ctrl-word */
450 #define L2CAP_FCR_SUP_BITS 0x000C
451 
452 /* Initial state of the CRC register */
453 #define L2CAP_FCR_INIT_CRC 0
454 /* Mask for sequence numbers (range 0 - 63) */
455 #define L2CAP_FCR_SEQ_MODULO 0x3F
456 
457 #endif
458