6
6
7
7
/**
8
8
* @file
9
- * @brief IEEE 802.15.4 L2 stack public header
9
+ * @brief IEEE 802.15.4 native L2 stack public header
10
+ *
11
+ * @note All references to the standard in this file cite IEEE 802.15.4-2020.
10
12
*/
11
13
12
14
#ifndef ZEPHYR_INCLUDE_NET_IEEE802154_H_
@@ -88,41 +90,118 @@ extern "C" {
88
90
* - protocol-specific extension to the interface structure (see @ref net_if)
89
91
* - protocol-specific extensions to the network packet structure
90
92
* (see @ref net_pkt),
93
+ *
94
+ * @note All section, table and figure references are to the IEEE 802.15.4-2020
95
+ * standard.
96
+ *
91
97
* @{
92
98
*/
93
99
94
- /* References are to the IEEE 802.15.4-2020 standard */
95
- #define IEEE802154_MAX_PHY_PACKET_SIZE 127 /* see section 11.3, aMaxPhyPacketSize */
96
- #define IEEE802154_FCS_LENGTH 2 /* see section 7.2.1.1 */
100
+ #define IEEE802154_MAX_PHY_PACKET_SIZE 127 /**< see section 11.3, aMaxPhyPacketSize */
101
+ #define IEEE802154_FCS_LENGTH 2 /**< see section 7.2.1.1 */
102
+
103
+ /**
104
+ * @brief IEEE 802.15.4 "hardware" MTU (not to be confused with L3/IP MTU), i.e.
105
+ * the actual payload available to the next higher layer.
106
+ *
107
+ * @details This is equivalent to the IEEE 802.15.4 MAC frame length minus
108
+ * checksum bytes which is again equivalent to the PHY payload aka PSDU length
109
+ * minus checksum bytes. This definition exists for compatibility with the same
110
+ * concept in Linux and Zephyr's L3. It is not a concept from the IEEE 802.15.4
111
+ * standard.
112
+ *
113
+ * @note Currently we only support the original frame size from the 2006
114
+ * standard version and earlier. The 2015+ standard introduced PHYs with larger
115
+ * PHY payload. These are not (yet) supported in Zephyr.
116
+ */
97
117
#define IEEE802154_MTU (IEEE802154_MAX_PHY_PACKET_SIZE - IEEE802154_FCS_LENGTH)
118
+
98
119
/* TODO: Support flexible MTU and FCS lengths for IEEE 802.15.4-2015ff */
99
120
121
+ /** IEEE 802.15.4 short address length. */
100
122
#define IEEE802154_SHORT_ADDR_LENGTH 2
123
+
124
+ /** IEEE 802.15.4 extended address length. */
101
125
#define IEEE802154_EXT_ADDR_LENGTH 8
126
+
127
+ /** IEEE 802.15.4 maximum address length. */
102
128
#define IEEE802154_MAX_ADDR_LENGTH IEEE802154_EXT_ADDR_LENGTH
103
129
130
+ /**
131
+ * A special channel value that symbolizes "all" channels or "any" channel -
132
+ * depending on context.
133
+ */
104
134
#define IEEE802154_NO_CHANNEL USHRT_MAX
105
135
106
- /* See IEEE 802.15.4-2020, sections 6.1 and 7.3.5 */
136
+ /**
137
+ * @{
138
+ * See sections 6.1 and 7.3.5
139
+ */
107
140
#define IEEE802154_BROADCAST_ADDRESS 0xffff
108
141
#define IEEE802154_NO_SHORT_ADDRESS_ASSIGNED 0xfffe
142
+ /** @} */
109
143
110
- /* See IEEE 802.15.4-2020, section 6.1 */
144
+ /* See section 6.1 */
111
145
#define IEEE802154_BROADCAST_PAN_ID 0xffff
112
146
113
- /* See IEEE 802.15.4-2020, section 7.3.5 */
147
+ /* See section 7.3.5 */
114
148
#define IEEE802154_SHORT_ADDRESS_NOT_ASSOCIATED IEEE802154_BROADCAST_ADDRESS
115
149
#define IEEE802154_PAN_ID_NOT_ASSOCIATED IEEE802154_BROADCAST_PAN_ID
116
150
151
+ /** interface-level security attributes, see section 9.5. */
117
152
struct ieee802154_security_ctx {
153
+ /** section 9.5, secFrameCounter */
118
154
uint32_t frame_counter ;
155
+
156
+ /** @cond INTERNAL_HIDDEN */
119
157
struct cipher_ctx enc ;
120
158
struct cipher_ctx dec ;
159
+ /** INTERNAL_HIDDEN @endcond */
160
+
161
+ /**
162
+ * @brief frame-level security key material
163
+ *
164
+ * @details Currently native L2 only supports a single secKeySource, see
165
+ * section 9.5, table 9-9, in combination with secKeyMode zero (implicit
166
+ * key mode), see section 9.4.2.3, table 9-7.
167
+ *
168
+ * @warning This is no longer in accordance with the current version of
169
+ * the standard and needs to be extended in the future for full security
170
+ * procedure compliance.
171
+ */
121
172
uint8_t key [16 ];
173
+
174
+ /** frame-level security key material */
122
175
uint8_t key_len ;
176
+
177
+ /**
178
+ * @brief security level
179
+ *
180
+ * @details Currently native L2 supports a single security level for all
181
+ * frame types, commands and information elements, see section 9.4.2.2,
182
+ * table 9-6 and ieee802154_security_level.
183
+ *
184
+ * @warning This is no longer in accordance with the current version of
185
+ * the standard and needs to be extended in the future for full security
186
+ * procedure compliance.
187
+ */
123
188
uint8_t level : 3 ;
189
+
190
+ /**
191
+ * @brief key_mode
192
+ *
193
+ * @details Currently only implicit key mode is partially supported, see
194
+ * section 9.4.2.3, table 9-7, secKeyMode.
195
+ *
196
+ * @warning This is no longer in accordance with the current version of
197
+ * the standard and needs to be extended in the future for full security
198
+ * procedure compliance.
199
+ */
124
200
uint8_t key_mode : 2 ;
201
+
202
+ /** @cond INTERNAL_HIDDEN */
125
203
uint8_t _unused : 3 ;
204
+ /** INTERNAL_HIDDEN @endcond */
126
205
};
127
206
128
207
enum ieee802154_device_role {
@@ -131,63 +210,77 @@ enum ieee802154_device_role {
131
210
IEEE802154_DEVICE_ROLE_PAN_COORDINATOR ,
132
211
};
133
212
134
- /* This not meant to be used by any code but the IEEE 802.15.4 L2 stack */
213
+ /** IEEE 802.15.4 L2 context. */
135
214
struct ieee802154_context {
136
- /* PAN ID
215
+ /**
216
+ * @brief PAN ID
137
217
*
138
- * The identifier of the PAN on which the device is operating. If this
139
- * value is 0xffff, the device is not associated. See section 8.4.3.1,
140
- * table 8-94, macPanId.
218
+ * @details The identifier of the PAN on which the device is operating.
219
+ * If this value is 0xffff, the device is not associated. See section
220
+ * 8.4.3.1, table 8-94, macPanId.
141
221
*
142
222
* in CPU byte order
143
223
*/
144
224
uint16_t pan_id ;
145
225
146
- /* Channel Number
226
+ /**
227
+ * @brief Channel Number
147
228
*
148
- * The RF channel to use for all transmissions and receptions, see
149
- * section 11.3, table 11-2, phyCurrentChannel. The allowable range
229
+ * @details The RF channel to use for all transmissions and receptions,
230
+ * see section 11.3, table 11-2, phyCurrentChannel. The allowable range
150
231
* of values is PHY dependent as defined in section 10.1.3.
151
232
*
152
233
* in CPU byte order
153
234
*/
154
235
uint16_t channel ;
155
236
156
- /* Short Address
237
+ /**
238
+ * @brief Short Address (in CPU byte order)
157
239
*
158
- * Range:
240
+ * @details Range:
159
241
* * 0x0000–0xfffd: associated, short address was assigned
160
242
* * 0xfffe: associated but no short address assigned
161
243
* * 0xffff: not associated (default),
162
244
*
163
245
* See section 6.4.1, table 6-4 (Usage of the shart address) and
164
246
* section 8.4.3.1, table 8-94, macShortAddress.
165
- *
166
- * in CPU byte order
167
247
*/
168
248
uint16_t short_addr ;
169
249
170
- /* Extended Address
250
+ /**
251
+ * @brief Extended Address (in little endian)
171
252
*
172
- * The extended address is device specific, usually permanently stored
173
- * on the device and immutable.
253
+ * @details The extended address is device specific, usually permanently
254
+ * stored on the device and immutable.
174
255
*
175
256
* See section 8.4.3.1, table 8-94, macExtendedAddress.
176
- *
177
- * in little endian
178
257
*/
179
258
uint8_t ext_addr [IEEE802154_MAX_ADDR_LENGTH ];
180
259
181
- struct net_linkaddr_storage linkaddr ; /* in big endian */
260
+ /** Link layer address (in big endian) */
261
+ struct net_linkaddr_storage linkaddr ;
262
+
182
263
#ifdef CONFIG_NET_L2_IEEE802154_SECURITY
264
+ /** Security context */
183
265
struct ieee802154_security_ctx sec_ctx ;
184
266
#endif
267
+
185
268
#ifdef CONFIG_NET_L2_IEEE802154_MGMT
186
- struct ieee802154_req_params * scan_ctx ; /* guarded by scan_ctx_lock */
269
+ /** Pointer to scanning parameters and results, guarded by scan_ctx_lock */
270
+ struct ieee802154_req_params * scan_ctx ;
271
+
272
+ /**
273
+ * Used to maintain integrity of data for all fields in this struct
274
+ * unless otherwise documented on field level.
275
+ */
187
276
struct k_sem scan_ctx_lock ;
188
277
189
- /* see section 8.4.3.1, table 8-94, macCoordExtendedAddress, the address
190
- * of the coordinator through which the device is associated.
278
+ /**
279
+ * @brief Coordinator extended address
280
+ *
281
+ * @details see section 8.4.3.1, table 8-94, macCoordExtendedAddress,
282
+ * the address of the coordinator through which the device is
283
+ * associated.
191
284
*
192
285
* A value of zero indicates that a coordinator extended address is
193
286
* unknown (default).
@@ -196,8 +289,11 @@ struct ieee802154_context {
196
289
*/
197
290
uint8_t coord_ext_addr [IEEE802154_MAX_ADDR_LENGTH ];
198
291
199
- /* see section 8.4.3.1, table 8-94, macCoordShortAddress, the short
200
- * address assigned to the coordinator through which the device is
292
+ /**
293
+ * @brief Coordinator short address
294
+ *
295
+ * @details see section 8.4.3.1, table 8-94, macCoordShortAddress, the
296
+ * short address assigned to the coordinator through which the device is
201
297
* associated.
202
298
*
203
299
* A value of 0xfffe indicates that the coordinator is only using its
@@ -208,36 +304,64 @@ struct ieee802154_context {
208
304
*/
209
305
uint16_t coord_short_addr ;
210
306
#endif
307
+
308
+ /** transmission power */
211
309
int16_t tx_power ;
310
+
311
+ /** L2 flags */
212
312
enum net_l2_flags flags ;
213
313
214
- /* The sequence number added to the transmitted Data frame or MAC
215
- * command, see section 8.4.3.1, table 8-94, macDsn.
314
+ /**
315
+ * @brief DSN
316
+ *
317
+ * @details The sequence number added to the transmitted Data frame or
318
+ * MAC command, see section 8.4.3.1, table 8-94, macDsn.
216
319
*/
217
320
uint8_t sequence ;
218
321
219
- /* See section 6.1: A device may be operating as end device
220
- * (0 - default), coordinator (1), or PAN coordinator (2).
322
+ /**
323
+ * @brief Device Role
324
+ *
325
+ * @details See section 6.1: A device may be operating as end device (0
326
+ * - default), coordinator (1), or PAN coordinator (2).
221
327
*
222
328
* A value of 3 is undefined.
223
329
*
224
- * Can be read/set via enum ieee802154_device_role.
330
+ * Can be read/set via @ref ieee802154_device_role.
225
331
*/
226
332
uint8_t device_role : 2 ;
227
333
334
+ /** @cond INTERNAL_HIDDEN */
228
335
uint8_t _unused : 5 ;
336
+ /** INTERNAL_HIDDEN @endcond */
229
337
230
- uint8_t ack_requested : 1 ; /* guarded by ack_lock */
231
- uint8_t ack_seq ; /* guarded by ack_lock */
338
+ /**
339
+ * ACK requested flag, guarded by ack_lock
340
+ */
341
+ uint8_t ack_requested : 1 ;
342
+
343
+ /** ACK expected sequence number, guarded by ack_lock */
344
+ uint8_t ack_seq ;
345
+
346
+ /** ACK lock, guards ack_* fields */
232
347
struct k_sem ack_lock ;
233
348
234
- struct k_sem ctx_lock ; /* guards all mutable context attributes unless
235
- * otherwise mentioned on attribute level
236
- */
349
+ /**
350
+ * @brief Context lock
351
+ *
352
+ * @details guards all mutable context attributes unless otherwise
353
+ * mentioned on attribute level
354
+ */
355
+ struct k_sem ctx_lock ;
237
356
};
238
357
358
+ /** @cond INTERNAL_HIDDEN */
359
+
360
+ /* L2 context type to be used with NET_L2_GET_CTX_TYPE */
239
361
#define IEEE802154_L2_CTX_TYPE struct ieee802154_context
240
362
363
+ /** INTERNAL_HIDDEN @endcond */
364
+
241
365
#ifdef __cplusplus
242
366
}
243
367
#endif
0 commit comments