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