Mistake on this page?
Report an issue in GitHub or email us
l2c_defs.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief L2CAP constants and definitions from the Bluetooth specification.
6  *
7  * Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019-2020 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 #ifndef L2C_DEFS_H
25 #define L2C_DEFS_H
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /*! \addtogroup STACK_L2CAP_API
32  * \{ */
33 
34 /**************************************************************************************************
35  Macros
36 **************************************************************************************************/
37 
38 /** \name L2CAP Packet Constants
39  *
40  */
41 /**@{*/
42 #define L2C_HDR_LEN 4 /*!< \brief L2CAP packet header length */
43 #define L2C_MIN_MTU 23 /*!< \brief Minimum packet payload MTU for LE */
44 #define L2C_SIG_HDR_LEN 4 /*!< \brief L2CAP signaling command header length */
45 #define L2C_LE_SDU_HDR_LEN 2 /*!< \brief L2CAP LE SDU data header length */
46 /**@}*/
47 
48 /*! \brief Max number of channels per enhanced connection request */
49 #define L2C_MAX_EN_CHAN 5
50 
51 /*! \brief Start of L2CAP payload in an HCI ACL packet buffer */
52 #define L2C_PAYLOAD_START (HCI_ACL_HDR_LEN + L2C_HDR_LEN)
53 
54 /*! \brief L2CAP signaling packet base length, including HCI header */
55 #define L2C_SIG_PKT_BASE_LEN (HCI_ACL_HDR_LEN + L2C_HDR_LEN + L2C_SIG_HDR_LEN)
56 
57 /*! \brief L2CAP LE SDU packet base length, including HCI header */
58 #define L2C_LE_SDU_PKT_BASE_LEN (HCI_ACL_HDR_LEN + L2C_HDR_LEN + L2C_LE_SDU_HDR_LEN)
59 
60 /** \name L2CAP Parameter Lengths
61  * Signaling packet parameter lengths
62  */
63 /**@{*/
64 #define L2C_SIG_CONN_UPDATE_REQ_LEN 8 /*!< \brief Connection update request length. */
65 #define L2C_SIG_CONN_UPDATE_RSP_LEN 2 /*!< \brief Connection update response length. */
66 #define L2C_SIG_CMD_REJ_LEN 2 /*!< \brief Command reject length. */
67 #define L2C_SIG_DISCONN_REQ_LEN 4 /*!< \brief Disconnection request length. */
68 #define L2C_SIG_DISCONN_RSP_LEN 4 /*!< \brief Disconnection response length. */
69 #define L2C_SIG_LE_CONN_REQ_LEN 10 /*!< \brief LE connection request length. */
70 #define L2C_SIG_LE_CONN_RSP_LEN 10 /*!< \brief LE connection response length. */
71 #define L2C_SIG_FLOW_CTRL_CREDIT_LEN 4 /*!< \brief Flow control credit lenghth. */
72 #define L2C_SIG_EN_CONNECT_REQ_LEN 8 /*!< \brief Enhanced credit based connection request */
73 #define L2C_SIG_EN_CONNECT_RSP_LEN 8 /*!< \brief Enhanced credit based connection response */
74 #define L2C_SIG_EN_RECONFIG_REQ_LEN 4 /*!< \brief Enhanced credit based reconfiguration request */
75 #define L2C_SIG_EN_RECONFIG_RSP_LEN 2 /*!< \brief Enhanced credit based reconfiguration response */
76 /**@}*/
77 
78 /** \name L2CAP Connection Identifiers
79  * BLE Defined Connection Identifiers (CID)
80  */
81 /**@{*/
82 #define L2C_CID_ATT 0x0004 /*!< \brief CID for attribute protocol */
83 #define L2C_CID_LE_SIGNALING 0x0005 /*!< \brief CID for LE signaling */
84 #define L2C_CID_SMP 0x0006 /*!< \brief CID for security manager protocol */
85 /**@}*/
86 
87 /** \name L2CAP Signaling Codes
88  *
89  */
90 /**@{*/
91 #define L2C_SIG_CMD_REJ 0x01 /*!< \brief Comand reject */
92 #define L2C_SIG_DISCONNECT_REQ 0x06 /*!< \brief Disconnect request */
93 #define L2C_SIG_DISCONNECT_RSP 0x07 /*!< \brief Disconnect response */
94 #define L2C_SIG_CONN_UPDATE_REQ 0x12 /*!< \brief Connection parameter update request */
95 #define L2C_SIG_CONN_UPDATE_RSP 0x13 /*!< \brief Connection parameter update response */
96 #define L2C_SIG_LE_CONNECT_REQ 0x14 /*!< \brief LE credit based connection request */
97 #define L2C_SIG_LE_CONNECT_RSP 0x15 /*!< \brief LE credit based connection response */
98 #define L2C_SIG_FLOW_CTRL_CREDIT 0x16 /*!< \brief LE flow control credit */
99 #define L2C_SIG_EN_CONNECT_REQ 0x17 /*!< \brief Enhanced credit based connection request */
100 #define L2C_SIG_EN_CONNECT_RSP 0x18 /*!< \brief Enhanced credit based connection response */
101 #define L2C_SIG_EN_RECONFIG_REQ 0x19 /*!< \brief Enhanced credit based reconfiguration request */
102 #define L2C_SIG_EN_RECONFIG_RSP 0x1A /*!< \brief Enhanced credit based reconfiguration response */
103 /**@}*/
104 
105 /*! \brief Signaling response code flag */
106 #define L2C_SIG_RSP_FLAG 0x01
107 
108 /** \name L2CAP Command Rejection Codes
109  * BLE defined Command rejection reason codes
110  */
111 /**@{*/
112 #define L2C_REJ_NOT_UNDERSTOOD 0x0000 /*!< \brief Command not understood */
113 #define L2C_REJ_MTU_EXCEEDED 0x0001 /*!< \brief Signaling MTU exceeded */
114 #define L2C_REJ_INVALID_CID 0x0002 /*!< \brief Invalid CID in request */
115 /**@}*/
116 
117 /** \name L2CAP Connection Parameter Update Result Codes
118  * BLE defined result codes
119  */
120 /**@{*/
121 #define L2C_CONN_PARAM_ACCEPTED 0x0000 /*!< \brief Connection parameters accepted */
122 #define L2C_CONN_PARAM_REJECTED 0x0001 /*!< \brief Connection parameters rejected */
123 /**@}*/
124 
125 /** \name L2CAP Connection Result Codes
126  * BLE defined result codes
127  */
128 /**@{*/
129 #define L2C_CONN_SUCCESS 0x0000 /*!< \brief Connection successful */
130 #define L2C_CONN_NONE 0x0001 /*!< \brief No connection result value available */
131 #define L2C_CONN_FAIL_PSM 0x0002 /*!< \brief Connection refused LE_PSM not supported */
132 #define L2C_CONN_FAIL_RES 0x0004 /*!< \brief Connection refused no resources available */
133 #define L2C_CONN_FAIL_AUTH 0x0005 /*!< \brief Connection refused insufficient authentication */
134 #define L2C_CONN_FAIL_AUTHORIZ 0x0006 /*!< \brief Connection refused insufficient authorization */
135 #define L2C_CONN_FAIL_KEY_SIZE 0x0007 /*!< \brief Connection refused insufficient encryption key size */
136 #define L2C_CONN_FAIL_ENC 0x0008 /*!< \brief Connection Refused insufficient encryption */
137 #define L2C_CONN_FAIL_INVALID_SCID 0x0009 /*!< \brief Connection refused invalid source CID */
138 #define L2C_CONN_FAIL_ALLOCATED_SCID 0x000A /*!< \brief Connection refused source CID already allocated */
139 #define L2C_CONN_FAIL_UNACCEPT_PARAM 0x000B /*!< \brief Connection refused unacceptable parameters */
140 #define L2C_CONN_FAIL_INVALID_PARAM 0x000C /*!< \brief Connection refused invalid parameters */
141 /**@}*/
142 
143 /** \name L2CAP Interal Connection Result Codes
144  * Proprietary codes not sent in any L2CAP packet.
145  */
146 /**@{*/
147 #define L2C_CONN_FAIL_TIMEOUT 0xF000 /*!< \brief Request timeout */
148 /**@}*/
149 
150 /** \name L2CAP Signaling Parameter Value Ranges
151  *
152  */
153 /**@{*/
154 #define L2C_PSM_MIN 0x0001 /*!< \brief PSM minimum. */
155 #define L2C_PSM_MAX 0x00FF /*!< \brief PSM maximum. */
156 #define L2C_CID_DYN_MIN 0x0040 /*!< \brief CID dynamic minimum. */
157 #define L2C_CID_DYN_MAX 0x007F /*!< \brief CID dynamic maximum. */
158 #define L2C_MTU_MIN 0x0017 /*!< \brief MTU minimum. */
159 #define L2C_MPS_MIN 0x0017 /*!< \brief MPS minimum. */
160 #define L2C_MPS_MAX 0xFFFD /*!< \brief MPS maximum. */
161 #define L2C_CREDITS_MAX 0xFFFF /*!< \brief Credits maximum. */
162 /**@}*/
163 
164 /** \name L2CAP Enhanced Connection Reconfigure Result Codes
165  *
166  */
167 /**@{*/
168 #define L2C_RECONFIG_FAIL_MTU 0x0001 /*!< \brief Enhanced Reconfiguration refuded - cannot reduce MTU. */
169 #define L2C_RECONFIG_FAIL_MPS 0x0002 /*!< \brief Enhanced Reconfiguration refuded - cannot reduce MPS on more than one channel. */
170 #define L2C_RECONFIG_FAIL_CID 0x0003 /*!< \brief Enhanced Reconfiguration refuded - invalid CID. */
171 #define L2C_RECONFIG_FAIL_PARAM 0x0004 /*!< \brief Enhanced Reconfiguration refuded - unacceptable parameters. */
172 /**@}*/
173 
174 /*! \} */ /*! STACK_L2CAP_API */
175 
176 #ifdef __cplusplus
177 };
178 #endif
179 
180 #endif /* L2C_DEFS_H */
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.