| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
packet-ieee802154.h
1/* packet-ieee802154.h
2 *
3 * IEEE 802.15.4 Dissectors for Wireshark
4 * By Owen Kirby <osk@exegin.com>
5 * Copyright 2007 Exegin Technologies Limited
6 *
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 */
13#ifndef PACKET_IEEE802154_H
14#define PACKET_IEEE802154_H
15
16/* Protocol Abbreviation */
17#define IEEE802154_PROTOABBREV_WPAN "wpan"
18#define IEEE802154_PROTOABBREV_WPAN_BEACON "wpan.beacon"
19/* PANID dissector list is for Decode-As and stateful dissection only. */
20#define IEEE802154_PROTOABBREV_WPAN_PANID "wpan.panid"
21
22/* Dissector tables */
23#define IEEE802154_HEADER_IE_DTABLE "wpan.header_ie"
24#define IEEE802154_PAYLOAD_IE_DTABLE "wpan.payload_ie"
25#define IEEE802154_MLME_IE_DTABLE "wpan.mlme_ie"
26#define IEEE802154_CMD_VENDOR_DTABLE "wpan.cmd.vendor"
27
28/* Packet Overhead from MAC header + footer (excluding addressing) */
29#define IEEE802154_MAX_FRAME_LEN 127
30#define IEEE802154_FCS_LEN 2
31
32/* FCS Types used by user configuration */
33#define IEEE802154_CC24XX_METADATA 0 /* Not an FCS, but TI CC24xx metadata */
34#define IEEE802154_FCS_16_BIT 1 /* ITU-T CRC16 */
35#define IEEE802154_FCS_32_BIT 2 /* ITU-T CRC32 */
36
37/* Command Frame Identifier Types Definitions */
38#define IEEE802154_CMD_ASSOC_REQ 0x01
39#define IEEE802154_CMD_ASSOC_RSP 0x02
40#define IEEE802154_CMD_DISASSOC_NOTIFY 0x03
41#define IEEE802154_CMD_DATA_RQ 0x04
42#define IEEE802154_CMD_PANID_CONFLICT 0x05
43#define IEEE802154_CMD_ORPHAN_NOTIFY 0x06
44#define IEEE802154_CMD_BEACON_REQ 0x07
45#define IEEE802154_CMD_COORD_REALIGN 0x08
46#define IEEE802154_CMD_GTS_REQ 0x09
47#define IEEE802154_CMD_TRLE_MGMT_REQ 0x0a
48#define IEEE802154_CMD_TRLE_MGMT_RSP 0x0b
49/* 0x0c-0x12 reserved in IEEE802.15.4-2015 */
50#define IEEE802154_CMD_DSME_ASSOC_REQ 0x13
51#define IEEE802154_CMD_DSME_ASSOC_RSP 0x14
52#define IEEE802154_CMD_DSME_GTS_REQ 0x15
53#define IEEE802154_CMD_DSME_GTS_RSP 0x16
54#define IEEE802154_CMD_DSME_GTS_NOTIFY 0x17
55#define IEEE802154_CMD_DSME_INFO_REQ 0x18
56#define IEEE802154_CMD_DSME_INFO_RSP 0x19
57#define IEEE802154_CMD_DSME_BEACON_ALLOC_NOTIFY 0x1a
58#define IEEE802154_CMD_DSME_BEACON_COLL_NOTIFY 0x1b
59#define IEEE802154_CMD_DSME_LINK_REPORT 0x1c
60/* 0x1d-0x1f reserved in IEEE802.15.4-2015 */
61#define IEEE802154_CMD_RIT_DATA_REQ 0x20
62#define IEEE802154_CMD_DBS_REQ 0x21
63#define IEEE802154_CMD_DBS_RSP 0x22
64#define IEEE802154_CMD_RIT_DATA_RSP 0x23
65#define IEEE802154_CMD_VENDOR_SPECIFIC 0x24
66/* 0x25-0xff reserved in IEEE802.15.4-2015 */
67
68/* Definitions for Association Response Command */
69#define IEEE802154_CMD_ASRSP_AS_SUCCESS 0x00
70#define IEEE802154_CMD_ASRSP_PAN_FULL 0x01
71#define IEEE802154_CMD_ASRSP_PAN_DENIED 0x02
72
73/* Bit Masks for Capability Information Field
74 Included in Association Req. command */
75#define IEEE802154_CMD_CINFO_ALT_PAN_COORD 0x01
76#define IEEE802154_CMD_CINFO_DEVICE_TYPE 0x02
77#define IEEE802154_CMD_CINFO_POWER_SRC 0x04
78#define IEEE802154_CMD_CINFO_IDLE_RX 0x08
79#define IEEE802154_CMD_CINFO_SEC_CAPABLE 0x40
80#define IEEE802154_CMD_CINFO_ALLOC_ADDR 0x80
81
82#define IEEE802154_CMD_GTS_REQ_LEN 0x0F
83#define IEEE802154_CMD_GTS_REQ_DIR 0x10
84#define IEEE802154_CMD_GTS_REQ_TYPE 0x20
85
86/* Bit masks & shifts for various beacon fields */
87#define IEEE802154_BEACON_ORDER_MASK 0x000F
88#define IEEE802154_SUPERFRAME_ORDER_MASK 0x00F0
89#define IEEE802154_SUPERFRAME_CAP_MASK 0x0F00
90#define IEEE802154_BATT_EXTENSION_MASK 0x1000
91#define IEEE802154_SUPERFRAME_COORD_MASK 0x4000
92#define IEEE802154_ASSOC_PERMIT_MASK 0x8000
93#define IEEE802154_SUPERFRAME_ORDER_SHIFT 4
94#define IEEE802154_SUPERFRAME_CAP_SHIFT 8
95
96#define IEEE802154_GTS_COUNT_MASK 0x07
97#define IEEE802154_GTS_PERMIT_MASK 0x80
98#define IEEE802154_GTS_DIRECTION_SLOT(i) (0x01<<(i))
99#define IEEE802154_GTS_MAX_SLOTS 7
100#define IEEE802154_GTS_DIRECTION_SLOT1 0x01
101#define IEEE802154_GTS_DIRECTION_SLOT2 0x02
102#define IEEE802154_GTS_DIRECTION_SLOT3 0x04
103#define IEEE802154_GTS_DIRECTION_SLOT4 0x08
104#define IEEE802154_GTS_DIRECTION_SLOT5 0x10
105#define IEEE802154_GTS_DIRECTION_SLOT6 0x20
106#define IEEE802154_GTS_DIRECTION_SLOT7 0x40
107#define IEEE802154_GTS_SLOT_MASK 0x0F
108#define IEEE802154_GTS_LENGTH_MASK 0xF0
109#define IEEE802154_GTS_LENGTH_SHIFT 4
110
111#define IEEE802154_PENDADDR_SHORT_MASK 0x07
112#define IEEE802154_PENDADDR_LONG_MASK 0x70
113#define IEEE802154_PENDADDR_LONG_SHIFT 4
114
115#define IEEE802154_SUPERFRAME_DURATION (IEEE802154_BASE_SLOT_DURATION * IEEE802154_SUPERFRAME_SLOTS)
116#define IEEE802154_BASE_SLOT_DURATION 60
117#define IEEE802154_SUPERFRAME_SLOTS 16
118
119/* Bit-masks for the FCF */
120#define IEEE802154_FCF_TYPE_MASK 0x0007 /* Frame Type Mask */
121#define IEEE802154_FCF_SEC_EN 0x0008
122#define IEEE802154_FCF_FRAME_PND 0x0010
123#define IEEE802154_FCF_ACK_REQ 0x0020
124#define IEEE802154_FCF_PAN_ID_COMPRESSION 0x0040 /* known as Intra PAN prior to IEEE 802.15.4-2006 */
125#define IEEE802154_FCF_SEQNO_SUPPRESSION 0x0100
126#define IEEE802154_FCF_IE_PRESENT 0x0200
127#define IEEE802154_FCF_DADDR_MASK 0x0C00 /* destination addressing mask */
128#define IEEE802154_FCF_VERSION 0x3000
129#define IEEE802154_FCF_SADDR_MASK 0xC000 /* source addressing mask */
130
131/* Bit-masks for the Multipurpose FCF */
132#define IEEE802154_MPF_FCF_TYPE_MASK 0x0007
133#define IEEE802154_MPF_FCF_LONG_FC 0x0008
134#define IEEE802154_MPF_FCF_DADDR_MASK 0x0030
135#define IEEE802154_MPF_FCF_SADDR_MASK 0x00C0
136#define IEEE802154_MPF_FCF_PAN_ID_PRESENT 0x0100
137#define IEEE802154_MPF_FCF_SEC_EN 0x0200
138#define IEEE802154_MPF_FCF_SEQNO_SUPPRESSION 0x0400
139#define IEEE802154_MPF_FCF_FRAME_PND 0x0800
140#define IEEE802154_MPF_FCF_VERSION 0x3000
141#define IEEE802154_MPF_FCF_ACK_REQ 0x4000
142#define IEEE802154_MPF_FCF_IE_PRESENT 0x8000
143
144/* Frame Type Definitions */
145#define IEEE802154_FCF_BEACON 0x0 /* Beacon Frame */
146#define IEEE802154_FCF_DATA 0x1 /* Data Frame */
147#define IEEE802154_FCF_ACK 0x2 /* Acknowlegement Frame */
148#define IEEE802154_FCF_CMD 0x3 /* MAC Command Frame */
149#define IEEE802154_FCF_RESERVED 0x4 /* reserved */
150#define IEEE802154_FCF_MULTIPURPOSE 0x5 /* Multipurpose */
151#define IEEE802154_FCF_FRAGMENT 0x6 /* Fragment or Frak */
152#define IEEE802154_FCF_EXTENDED 0x7 /* Extended */
153
154/* Frame version definitions. */
155#define IEEE802154_VERSION_2003 0x0
156#define IEEE802154_VERSION_2006 0x1
157#define IEEE802154_VERSION_2015 0x2
158#define IEEE802154_VERSION_RESERVED 0x3
159
160/* Address Mode Definitions */
161#define IEEE802154_FCF_ADDR_NONE 0x0
162#define IEEE802154_FCF_ADDR_RESERVED 0x1
163#define IEEE802154_FCF_ADDR_SHORT 0x2
164#define IEEE802154_FCF_ADDR_EXT 0x3
165
166/* Header IE Fields */
167#define IEEE802154_HEADER_IE_TYPE_MASK 0x8000
168#define IEEE802154_HEADER_IE_ID_MASK 0x7F80
169#define IEEE802154_HEADER_IE_LENGTH_MASK 0x007F
170
171/* Payload IE Fields */
172#define IEEE802154_PAYLOAD_IE_TYPE_MASK 0x8000
173#define IEEE802154_PAYLOAD_IE_ID_MASK 0x7800
174#define IEEE802154_PAYLOAD_IE_LENGTH_MASK 0x07FF
175
176/* Payload (Nested) Sub IE Fields */
177#define IEEE802154_PSIE_TYPE_MASK 0x8000
178#define IEEE802154_PSIE_ID_MASK_SHORT 0x7F00
179#define IEEE802154_PSIE_LENGTH_MASK_SHORT 0x00FF
180#define IEEE802154_PSIE_ID_MASK_LONG 0x7800
181#define IEEE802154_PSIE_LENGTH_MASK_LONG 0x07FF
182
183/* Enhanced Beacon Filter IE */
184#define IEEE802154_MLME_PSIE_EB_FLT_PJOIN 0x01
185#define IEEE802154_MLME_PSIE_EB_FLT_LQI 0x02
186#define IEEE802154_MLME_PSIE_EB_FLT_PERCENT 0x04
187#define IEEE802154_MLME_PSIE_EB_FLT_ATTR_LEN 0x18
188
189/* Vendor OUIs */
190
191/* Bit-masks for TI CC24xx end-of-packet metadata */
192#define IEEE802154_CC24xx_CRC_OK 0x8000 /* 1 if CRC OK, 0 if not */
193#define IEEE802154_CC24xx_CORRELATION 0x7F00 /* Some LQI stuff */
194#define IEEE802154_CC24xx_RSSI 0x00FF /* Raw RSSI */
195
196/* Special IEEE802.15.4 Addresses */
197#define IEEE802154_NO_ADDR16 0xFFFE
198#define IEEE802154_BCAST_ADDR 0xFFFF
199#define IEEE802154_BCAST_PAN 0xFFFF
200
201/* Bit mask for PHY length field */
202#define IEEE802154_PHY_LENGTH_MASK 0x7F
203
204/* Auxiliary Security Header */
205#define IEEE802154_AUX_SEC_LEVEL_MASK 0x07 /* Security Level */
206#define IEEE802154_AUX_KEY_ID_MODE_MASK 0x18 /* Key Identifier Mode */
207#define IEEE802154_AUX_KEY_ID_MODE_SHIFT 3
208#define IEEE802154_AUX_FRAME_COUNTER_SUPPRESSION_MASK 0x20 /* 802.15.4-2015 */
209#define IEEE802154_AUX_ASN_IN_NONCE_MASK 0x40 /* 802.15.4-2015 */
210/* Note: 802.15.4-2015 specifies bits 6-7 as reserved, but 6 is used for ASN */
211#define IEEE802154_AUX_CTRL_RESERVED_MASK 0x80 /* Reserved */
212
213/* Thread-specific well-known key support */
214#define IEEE802154_THR_WELL_KNOWN_KEY_INDEX 0xff
215#define IEEE802154_THR_WELL_KNOWN_KEY_SRC 0xffffffff
216#define IEEE802154_THR_WELL_KNOWN_EXT_ADDR 0x3506feb823d48712ULL
217
218/* 802.15.4e LE-multipurpose Wake-up frame length */
219#define IEEE802154E_LE_WUF_LEN 12
220
221 typedef enum {
222 SECURITY_LEVEL_NONE = 0x00,
223 SECURITY_LEVEL_MIC_32 = 0x01,
224 SECURITY_LEVEL_MIC_64 = 0x02,
225 SECURITY_LEVEL_MIC_128 = 0x03,
226 SECURITY_LEVEL_ENC = 0x04,
227 SECURITY_LEVEL_ENC_MIC_32 = 0x05,
228 SECURITY_LEVEL_ENC_MIC_64 = 0x06,
229 SECURITY_LEVEL_ENC_MIC_128 = 0x07
230} ieee802154_security_level;
231
232 typedef enum {
233 KEY_ID_MODE_IMPLICIT = 0x00,
234 KEY_ID_MODE_KEY_INDEX = 0x01,
235 KEY_ID_MODE_KEY_EXPLICIT_4 = 0x02,
236 KEY_ID_MODE_KEY_EXPLICIT_8 = 0x03
237} ieee802154_key_id_mode;
238
239 typedef enum {
240 KEY_HASH_NONE = 0x00,
241 KEY_HASH_ZIP = 0x01,
242 KEY_HASH_THREAD = 0x02
243} ieee802154_key_hash;
244
245/* Header IE Element ID */
246#define IEEE802154_HEADER_IE_VENDOR_SPECIFIC 0x00
247/* Reserved 0x01-0x19 */
248#define IEEE802154_HEADER_IE_CSL 0x1a
249#define IEEE802154_HEADER_IE_RIT 0x1b
250#define IEEE802154_HEADER_IE_DSME_PAN 0x1c
251#define IEEE802154_HEADER_IE_RENDEZVOUS 0x1d
252#define IEEE802154_HEADER_IE_TIME_CORR 0x1e
253/* Reserved 0x1f-0x20 */
254#define IEEE802154_HEADER_IE_EXT_DSME_PAN 0x21
255#define IEEE802154_HEADER_IE_FSCD 0x22
256#define IEEE802154_HEADER_IE_SMPL_SUPER_FRM 0x23
257#define IEEE802154_HEADER_IE_SMPL_GTS 0x24
258#define IEEE802154_HEADER_IE_LECIM 0x25
259#define IEEE802154_HEADER_IE_TRLE 0x26
260#define IEEE802154_HEADER_IE_RCC_CAP 0x27
261#define IEEE802154_HEADER_IE_RCCN 0x28
262#define IEEE802154_HEADER_IE_GLOBAL_TIME 0x29
263#define IEEE802154_HEADER_IE_WISUN 0x2a
264#define IEEE802154_HEADER_IE_DA_IE 0x2b
265/* Reserved 0x2c-0x7d */
266#define IEEE802154_HEADER_IE_HT1 0x7e
267#define IEEE802154_HEADER_IE_HT2 0x7f
268
269/* Thread vendor ID */
270#define IEEE802154_HEADER_IE_THREAD 0x9b
271
272/* Reserved 0x80-0xff */
273
274/* Payload IE Group ID */
275#define IEEE802154_PAYLOAD_IE_ESDU 0x0 /* Encapsulated Service Data Unit */
276#define IEEE802154_PAYLOAD_IE_MLME 0x1 /* Media Access Control (MAC) subLayer Management Entity */
277#define IEEE802154_PAYLOAD_IE_VENDOR 0x2 /* Vendor Specific */
278#define IEEE802154_PAYLOAD_IE_MPX 0x3 /* MPX IE (802.15.9) */
279#define IEEE802154_PAYLOAD_IE_WISUN 0x4 /* Wi-SUN IE */
280#define IEEE802154_PAYLOAD_IE_IETF 0x5 /* IETF IE, RFC 8137 */
281/* Reserved 0x6-0xe */
282#define IEEE802154_PAYLOAD_IE_TERMINATION 0xf
283
284/* Payload IE (Nested) Sub ID */
285/* Payload IE (Nested) Sub ID - long format */
286/* 0x0 - 0x7 Reserved */
287/* 0x0 - 0x8 Vendor Specific */
288#define IEEE802154_MLME_SUBIE_CHANNEL_HOPPING 0x9
289/* 0xa - 0xf Reserved */
290/* 0x10 - 0x19 Short Format Reserved */
291#define IEEE802154_MLME_SUBIE_TSCH_SYNCH 0x1A
292#define IEEE802154_MLME_SUBIE_TSCH_SLOTFR_LINK 0x1B
293#define IEEE802154_MLME_SUBIE_TSCH_TIMESLOT 0x1C
294#define IEEE802154_MLME_SUBIE_HOPPING_TIMING 0x1D
295#define IEEE802154_MLME_SUBIE_ENHANCED_BEACON_FILTER 0x1E
296#define IEEE802154_MLME_SUBIE_MAC_METRICS 0x1F
297#define IEEE802154_MLME_SUBIE_ALL_MAC_METRICS 0x20
298#define IEEE802154_MLME_SUBIE_COEXISTENCE_SPEC 0x21
299#define IEEE802154_MLME_SUBIE_SUN_DEVICE_CAPABILITIES 0x22
300#define IEEE802154_MLME_SUBIE_SUN_FSK_GEN_PHY 0x23
301#define IEEE802154_MLME_SUBIE_MODE_SWITCH_PARAMETER 0x24
302#define IEEE802154_MLME_SUBIE_PHY_PARAMETER_CHANGE 0x25
303#define IEEE802154_MLME_SUBIE_O_QPSK_PHY_MODE 0x26
304#define IEEE802154_MLME_SUBIE_PCA_ALLOCATION 0x27
305#define IEEE802154_MLME_SUBIE_DSSS_OPER_MODE 0x28
306#define IEEE802154_MLME_SUBIE_FSK_OPER_MODE 0x29
307#define IEEE802154_MLME_SUBIE_TVWS_PHY_OPE_MODE 0x2B
308#define IEEE802154_MLME_SUBIE_TVWS_DEVICE_CAPAB 0x2C
309#define IEEE802154_MLME_SUBIE_TVWS_DEVICE_CATEG 0x2D
310#define IEEE802154_MLME_SUBIE_TVWS_DEVICE_IDENTIF 0x2E
311#define IEEE802154_MLME_SUBIE_TVWS_DEVICE_LOCATION 0x2F
312#define IEEE802154_MLME_SUBIE_TVWS_CH_INFOR_QUERY 0x30
313#define IEEE802154_MLME_SUBIE_TVWS_CH_INFOR_SOURCE 0x31
314#define IEEE802154_MLME_SUBIE_CTM 0x32
315#define IEEE802154_MLME_SUBIE_TIMESTAMP 0x33
316#define IEEE802154_MLME_SUBIE_TIMESTAMP_DIFF 0x34
317#define IEEE802154_MLME_SUBIE_TMCP_SPECIFICATION 0x35
318#define IEEE802154_MLME_SUBIE_RCC_PHY_OPER_MODE 0x36
319/* 0x37-0x7f Reserved */
320
321/* IETF IE - Sub IE */
322#define IEEE802154_IETF_SUBIE_6TOP_DRAFT 0xC9 /* not formally assigned yet */
323#define IEEE802154_IETF_SUBIE_6TOP 0x01 /* not formally assigned yet */
324
325/* IEEE 802.15.4 cipher block size. */
326#define IEEE802154_CIPHER_SIZE 16
327
328/* IEEE 802.15 CID */
329#define IEEE80215_CID 0xBA55ECULL
330
331/* Macro to compute the MIC length. */
332#define IEEE802154_MIC_LENGTH(_level_) ((0x2 << ((_level_) & 0x3)) & ~0x3)
333/* Macro to check for payload encryption. */
334#define IEEE802154_IS_ENCRYPTED(_level_) ((_level_) & 0x4)
335
336/*SIXTOP Bit-mask*/
337#define IETF_6TOP_VERSION 0x0F
338#define IETF_6TOP_TYPE 0x30
339#define IETF_6TOP_FLAGS_RESERVED 0xC0
340#define IETF_6TOP_SEQNUM 0xFF
341
342/* SIXTOP CMD and RC identifiers */
343#define IETF_6TOP_CMD_ADD 0x01
344#define IETF_6TOP_CMD_DELETE 0x02
345#define IETF_6TOP_CMD_RELOCATE 0x03
346#define IETF_6TOP_CMD_COUNT 0x04
347#define IETF_6TOP_CMD_LIST 0x05
348#define IETF_6TOP_CMD_SIGNAL 0x06
349#define IETF_6TOP_CMD_CLEAR 0x07
350#define IETF_6TOP_RC_SUCCESS 0x00
351#define IETF_6TOP_RC_EOL 0x01
352#define IETF_6TOP_RC_ERR 0x02
353#define IETF_6TOP_RC_RESET 0x03
354#define IETF_6TOP_RC_ERR_VERSION 0x04
355#define IETF_6TOP_RC_ERR_SFID 0x05
356#define IETF_6TOP_RC_ERR_SEQNUM 0x06
357#define IETF_6TOP_RC_ERR_CELLLIST 0x07
358#define IETF_6TOP_RC_ERR_BUSY 0x08
359#define IETF_6TOP_RC_ERR_LOCKED 0x09
360
361/* SIXTOP Message Types */
362#define IETF_6TOP_TYPE_REQUEST 0x00
363#define IETF_6TOP_TYPE_RESPONSE 0x01
364#define IETF_6TOP_TYPE_CONFIRMATION 0x02
365#define IETF_6TOP_TYPE_RESERVED 0x03
366
367/* SIXTOP Cell Options */
368#define IETF_6TOP_CELL_OPTION_TX 0x01
369#define IETF_6TOP_CELL_OPTION_RX 0x02
370#define IETF_6TOP_CELL_OPTION_SHARED 0x04
371#define IETF_6TOP_CELL_OPTION_RESERVED 0xF8
372
373/* IEEE 802.15.9 MPX IE */
374#define IEEE802159_MPX_TRANSFER_TYPE_MASK 0x07
375#define IEEE802159_MPX_TRANSACTION_ID_MASK 0xf8
376#define IEEE802159_MPX_TRANSACTION_ID_SHIFT 0x03
377/* IEEE 802.15.9 Table 19 */
378#define IEEE802159_MPX_FULL_FRAME 0
379#define IEEE802159_MPX_FULL_FRAME_NO_MUXID 1
380#define IEEE802159_MPX_NON_LAST_FRAGMENT 2
381#define IEEE802159_MPX_LAST_FRAGMENT 4
382#define IEEE802159_MPX_ABORT 6
383/* IEEE 802.15.9 Table 20 */
384#define IEEE802159_MPX_MULTIPLEX_ID_KMP 1
385#define IEEE802159_MPX_MULTIPLEX_ID_WISUN 2
386/* IEEE 802.15.9 Table 21 */
387#define IEEE802159_MPX_KMP_ID_IEEE8021X 1
388#define IEEE802159_MPX_KMP_ID_HIP 2
389#define IEEE802159_MPX_KMP_ID_IKEV2 3
390#define IEEE802159_MPX_KMP_ID_PANA 4
391#define IEEE802159_MPX_KMP_ID_DRAGONFLY 5
392#define IEEE802159_MPX_KMP_ID_IEEE80211_4WH 6
393#define IEEE802159_MPX_KMP_ID_IEEE80211_GKH 7
394#define IEEE802159_MPX_KMP_ID_ETSI_TS_102_887_2 8
395#define IEEE802159_MPX_KMP_ID_VENDOR_SPECIFIC 255
396/* Wi-SUN MPX Sub-ID values. */
397#define IEEE802159_MPX_WISUN_SUBID_MHDS 0
398#define IEEE802159_MPX_WISUN_SUBID_6LOWPAN 1
399#define IEEE802159_MPX_WISUN_SUBID_SECURITY 2
400
401/* Structure containing information regarding all necessary packet fields. */
402 typedef struct {
403 /* Frame control field. */
404 int32_t version;
405 int32_t frame_type;
406 int32_t dst_addr_mode;
407 int32_t src_addr_mode;
408 bool security_enable;
409 bool frame_pending;
410 bool ack_request;
411 bool pan_id_compression;
412 bool seqno_suppression;
413 bool ie_present;
414
415 /* Fields exclusive to the 802.15.4-2015 multipurpose frame control field */
416 bool long_frame_control;
417 bool pan_id_present;
418
419 uint8_t seqno;
420 /* Determined during processing of Header IE*/
421 bool payload_ie_present;
422 /* Addressing Info. */
423 bool dst_pan_present;
424 bool src_pan_present;
425 uint16_t dst_pan;
426 uint16_t src_pan;
427 uint16_t dst16;
428 uint64_t dst64;
429 uint16_t src16;
430 uint64_t src64;
431
432 /* Security Info. */
433 ieee802154_security_level security_level;
434 ieee802154_key_id_mode key_id_mode;
435 bool frame_counter_suppression; /* 802.15.4-2015 */
436 uint32_t frame_counter;
437 uint8_t key_sequence_counter; /* Only for 802.15.4-2003 security suite with encryption */
438 uint64_t asn;
439
440 union {
441 uint32_t addr32;
442 uint64_t addr64;
443 } key_source;
444 uint8_t key_index;
445
446 /* Command ID (only if frame_type == 0x3) */
447 uint8_t command_id;
448 GHashTable *short_table;
449} ieee802154_packet;
450
451/* Structure for two-way mapping table */
452 typedef struct {
453 GHashTable *long_table;
454 GHashTable *short_table;
455} ieee802154_map_tab_t;
456
457/* Key used by the short address hash table. */
458 typedef struct {
459 uint16_t pan;
460 uint16_t addr;
461} ieee802154_short_addr;
462
463/* Key used by the long address hash table. */
464 typedef struct {
465 uint64_t addr;
466} ieee802154_long_addr;
467
468/* A mapping record for a frame, pointed to by hash table */
469 typedef struct {
470 const char *proto; /* name of protocol that created this record */
471 unsigned start_fnum;
472 unsigned end_fnum;
473 uint64_t addr64;
474 /*uint32_t frame_counter; TODO for frame counter sequence checks. */
475} ieee802154_map_rec;
476
477#define IEEE802154_USER_MAPPING 0
478
479 typedef struct {
480 uint16_t src_pan;
481 uint16_t src16;
482 uint16_t dst16;
483 ieee802154_map_rec *map_rec;
484 void *packet;
485} ieee802154_hints_t;
486
487 typedef enum {
488 DECRYPT_PACKET_SUCCEEDED,
489 DECRYPT_NOT_ENCRYPTED,
490 DECRYPT_FRAME_COUNTER_SUPPRESSION_UNSUPPORTED,
491 DECRYPT_PACKET_TOO_SMALL,
492 DECRYPT_PACKET_NO_EXT_SRC_ADDR,
493 DECRYPT_PACKET_NO_KEY,
494 DECRYPT_PACKET_DECRYPT_FAILED,
495 DECRYPT_PACKET_MIC_CHECK_FAILED
496} ieee802154_decrypt_status;
497
498/* UAT key structure. */
499 typedef struct {
500 char *pref_key;
501 unsigned key_index;
502 ieee802154_key_hash hash_type;
503 uint8_t key[IEEE802154_CIPHER_SIZE];
504 uint8_t mle_key[IEEE802154_CIPHER_SIZE];
505} ieee802154_key_t;
506
507/* */
508 void dissect_ieee802154_superframe (tvbuff_t *, packet_info *, proto_tree *, unsigned *);
509 void dissect_ieee802154_gtsinfo (tvbuff_t *, packet_info *, proto_tree *, unsigned *);
510 void dissect_ieee802154_pendaddr (tvbuff_t *, packet_info *, proto_tree *, unsigned *);
511 void dissect_ieee802154_aux_sec_header_and_key(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ieee802154_packet *packet, unsigned *offset);
512 void ccm_init_block(uint8_t *block, bool adata, int M, uint64_t addr, uint32_t frame_counter, uint8_t level, int ctr_val, const uint8_t *generic_nonce);
513 bool ccm_ctr_encrypt(const uint8_t *key, const uint8_t *iv, uint8_t *mic, uint8_t *data, int length);
514 bool ccm_cbc_mac(const uint8_t *key, const uint8_t *iv, const uint8_t *a, int a_len, const uint8_t *m, int m_len, uint8_t *mic);
515
516 proto_tree *ieee802154_create_hie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, int ett);
517 proto_tree *ieee802154_create_pie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, int ett);
518
519
521#define IEEE802154_DISSECT_HEADER_OPTION_NO_AUX_SEC_HDR (1 << 1)
532 unsigned ieee802154_dissect_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned options, proto_tree **created_header_tree, ieee802154_packet **parsed_info);
533
545 tvbuff_t* ieee802154_decrypt_payload(tvbuff_t *tvb, unsigned mhr_len, packet_info *pinfo, proto_tree *ieee802154_tree, ieee802154_packet *packet);
546
555 unsigned ieee802154_dissect_payload_ies(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ieee802154_tree, ieee802154_packet *packet);
556
566 unsigned ieee802154_dissect_frame_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ieee802154_tree, ieee802154_packet *packet, bool fcs_ok);
567
568
569/* Results for the decryption */
570 typedef struct {
571 /* Set by decrypt_ieee802154_payload */
572 unsigned char *key; // not valid after return of decrypt_ieee802154_payload
573 unsigned key_number;
574 /* Set by the ieee802154_decrypt_func */
575 unsigned char* rx_mic;
576 unsigned* rx_mic_length;
577 unsigned aux_offset;
578 unsigned aux_length;
579 ieee802154_decrypt_status* status;
580} ieee802154_decrypt_info_t;
581
584 typedef unsigned (*ieee802154_set_key_func) (ieee802154_packet *packet, unsigned char *key, unsigned char *alt_key, ieee802154_key_t *uat_key);
586 typedef tvbuff_t* (*ieee802154_decrypt_func) (tvbuff_t *, unsigned, packet_info *, ieee802154_packet *, ieee802154_decrypt_info_t*);
590 tvbuff_t *decrypt_ieee802154_payload(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *key_tree, ieee802154_packet *packet,
591 ieee802154_decrypt_info_t *decrypt_info, ieee802154_set_key_func set_key_func, ieee802154_decrypt_func decrypt_func);
592
593
594 extern void register_ieee802154_mac_key_hash_handler(unsigned hash_identifier, ieee802154_set_key_func key_func);
595
596/* Short to Extended Address Prototypes */
597 extern ieee802154_map_rec *ieee802154_addr_update(ieee802154_map_tab_t *, uint16_t, uint16_t, uint64_t,
598 const char *, unsigned);
599 extern unsigned ieee802154_short_addr_hash(const void *);
600 extern unsigned ieee802154_long_addr_hash(const void *key);
601 extern gboolean ieee802154_short_addr_equal(const void *, const void *);
602 extern gboolean ieee802154_long_addr_equal(const void *a, const void *b);
603
604 extern bool ieee802154_short_addr_invalidate(uint16_t, uint16_t, unsigned);
605 extern bool ieee802154_long_addr_invalidate(uint64_t, unsigned);
606
607 extern ieee802154_map_tab_t ieee802154_map;
608
609 extern const value_string ieee802154_mpx_kmp_id_vals[];
610 extern const value_string zboss_page_names[];
611
612 extern unsigned ieee802154_fcs_len;
613
614#endif /* PACKET_IEEE802154_H */
_packet_info
Definition packet_info.h:43
_proto_node
Definition proto.h:907
_value_string
Mapping between a 32-bit integer value and its string representation.
Definition value_string.h:33
ieee802154_decrypt_info_t
Definition packet-ieee802154.h:570
ieee802154_hints_t
Definition packet-ieee802154.h:479
ieee802154_key_t
Definition packet-ieee802154.h:499
ieee802154_long_addr
Definition packet-ieee802154.h:464
ieee802154_map_rec
Definition packet-ieee802154.h:469
ieee802154_map_tab_t
Definition packet-ieee802154.h:452
ieee802154_packet
Definition packet-ieee802154.h:402
ieee802154_short_addr
Definition packet-ieee802154.h:458
tvbuff
Definition tvbuff-int.h:35