Wireshark 2.9.0-477-g68ec514b The Wireshark network protocol analyzer

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 /* 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 /* Frame Type Definitions */
127 #define IEEE802154_FCF_BEACON 0x0 /* Beacon Frame */
128 #define IEEE802154_FCF_DATA 0x1 /* Data Frame */
129 #define IEEE802154_FCF_ACK 0x2 /* Acknowlegement Frame */
130 #define IEEE802154_FCF_CMD 0x3 /* MAC Command Frame */
131 #define IEEE802154_FCF_RESERVED 0x4 /* reserved */
132 #define IEEE802154_FCF_MULTIPURPOSE 0x5 /* Multipurpose */
133 #define IEEE802154_FCF_FRAGMENT 0x6 /* Fragment or Frak */
134 #define IEEE802154_FCF_EXTENDED 0x7 /* Extended */
135
136 /* Frame version definitions. */
137 #define IEEE802154_VERSION_2003 0x0
138 #define IEEE802154_VERSION_2006 0x1
139 #define IEEE802154_VERSION_2015 0x2
140 #define IEEE802154_VERSION_RESERVED 0x3
141
142 /* Address Mode Definitions */
143 #define IEEE802154_FCF_ADDR_NONE 0x0
144 #define IEEE802154_FCF_ADDR_RESERVED 0x1
145 #define IEEE802154_FCF_ADDR_SHORT 0x2
146 #define IEEE802154_FCF_ADDR_EXT 0x3
147
148 /* Header IE Fields */
149 #define IEEE802154_HEADER_IE_TYPE_MASK 0x8000
150 #define IEEE802154_HEADER_IE_ID_MASK 0x7F80
151 #define IEEE802154_HEADER_IE_LENGTH_MASK 0x007F
152
153 /* Payload IE Fields */
154 #define IEEE802154_PAYLOAD_IE_TYPE_MASK 0x8000
155 #define IEEE802154_PAYLOAD_IE_ID_MASK 0x7800
156 #define IEEE802154_PAYLOAD_IE_LENGTH_MASK 0x07FF
157
158 /* Payload (Nested) Sub IE Fields */
159 #define IEEE802154_PSIE_TYPE_MASK 0x8000
160 #define IEEE802154_PSIE_ID_MASK_SHORT 0x7F00
161 #define IEEE802154_PSIE_LENGTH_MASK_SHORT 0x00FF
162 #define IEEE802154_PSIE_ID_MASK_LONG 0x7800
163 #define IEEE802154_PSIE_LENGTH_MASK_LONG 0x07FF
164
165 /* Enhanced Beacon Filter IE */
166 #define IEEE802154_MLME_PSIE_EB_FLT_PJOIN 0x01
167 #define IEEE802154_MLME_PSIE_EB_FLT_LQI 0x02
168 #define IEEE802154_MLME_PSIE_EB_FLT_PERCENT 0x04
169 #define IEEE802154_MLME_PSIE_EB_FLT_ATTR_LEN 0x18
170
171 /* Vendor OUIs */
172
173 /* Bit-masks for CC24xx style FCS */
174 #define IEEE802154_CC24xx_CORRELATION 0x7F00
175 #define IEEE802154_CC24xx_CRC_OK 0x8000
176 #define IEEE802154_CC24xx_RSSI 0x00FF
177
178 /* Special IEEE802.15.4 Addresses */
179 #define IEEE802154_NO_ADDR16 0xFFFE
180 #define IEEE802154_BCAST_ADDR 0xFFFF
181 #define IEEE802154_BCAST_PAN 0xFFFF
182
183 /* Bit mask for PHY length field */
184 #define IEEE802154_PHY_LENGTH_MASK 0x7F
185
186 /* Auxiliary Security Header */
187 #define IEEE802154_AUX_SEC_LEVEL_MASK 0x07 /* Security Level */
188 #define IEEE802154_AUX_KEY_ID_MODE_MASK 0x18 /* Key Identifier Mode */
189 #define IEEE802154_AUX_KEY_ID_MODE_SHIFT 3
190 #define IEEE802154_AUX_FRAME_COUNTER_SUPPRESSION_MASK 0x20 /* 802.15.4-2015 */
191 #define IEEE802154_AUX_ASN_IN_NONCE_MASK 0x40 /* 802.15.4-2015 */
192 /* Note: 802.15.4-2015 specifies bits 6-7 as reserved, but 6 is used for ASN */
193 #define IEEE802154_AUX_CTRL_RESERVED_MASK 0x80 /* Reserved */
194
195 /* Thread-specific well-known key support */
196 #define IEEE802154_THR_WELL_KNOWN_KEY_INDEX 0xff
197 #define IEEE802154_THR_WELL_KNOWN_KEY_SRC 0xffffffff
198 #define IEEE802154_THR_WELL_KNOWN_EXT_ADDR 0x3506feb823d48712ULL
199
200 typedef enum {
201 SECURITY_LEVEL_NONE = 0x00,
202 SECURITY_LEVEL_MIC_32 = 0x01,
203 SECURITY_LEVEL_MIC_64 = 0x02,
204 SECURITY_LEVEL_MIC_128 = 0x03,
205 SECURITY_LEVEL_ENC = 0x04,
206 SECURITY_LEVEL_ENC_MIC_32 = 0x05,
207 SECURITY_LEVEL_ENC_MIC_64 = 0x06,
208 SECURITY_LEVEL_ENC_MIC_128 = 0x07
209 } ieee802154_security_level;
210
211 typedef enum {
212 KEY_ID_MODE_IMPLICIT = 0x00,
213 KEY_ID_MODE_KEY_INDEX = 0x01,
214 KEY_ID_MODE_KEY_EXPLICIT_4 = 0x02,
215 KEY_ID_MODE_KEY_EXPLICIT_8 = 0x03
216 } ieee802154_key_id_mode;
217
218 typedef enum {
219 KEY_HASH_NONE = 0x00,
220 KEY_HASH_ZIP = 0x01,
221 KEY_HASH_THREAD = 0x02
222 } ieee802154_key_hash;
223
224 /* Header IE Element ID */
225 #define IEEE802154_HEADER_IE_VENDOR_SPECIFIC 0x00
226 /* Reserved 0x01-0x19 */
227 #define IEEE802154_HEADER_IE_CSL 0x1a
228 #define IEEE802154_HEADER_IE_RIT 0x1b
229 #define IEEE802154_HEADER_IE_DSME_PAN 0x1c
230 #define IEEE802154_HEADER_IE_RENDEZVOUS 0x1d
231 #define IEEE802154_HEADER_IE_TIME_CORR 0x1e
232 /* Reserved 0x1f-0x20 */
233 #define IEEE802154_HEADER_IE_EXT_DSME_PAN 0x21
234 #define IEEE802154_HEADER_IE_FSCD 0x22
235 #define IEEE802154_HEADER_IE_SMPL_SUPER_FRM 0x23
236 #define IEEE802154_HEADER_IE_SMPL_GTS 0x24
237 #define IEEE802154_HEADER_IE_LECIM 0x25
238 #define IEEE802154_HEADER_IE_TRLE 0x26
239 #define IEEE802154_HEADER_IE_RCC_CAP 0x27
240 #define IEEE802154_HEADER_IE_RCCN 0x28
241 #define IEEE802154_HEADER_IE_GLOBAL_TIME 0x29
242 #define IEEE802154_HEADER_IE_WISUN 0x2a
243 #define IEEE802154_HEADER_IE_DA_IE 0x2b
244 /* Reserved 0x2c-0x7d */
245 #define IEEE802154_HEADER_IE_HT1 0x7e
246 #define IEEE802154_HEADER_IE_HT2 0x7f
247 /* Reserved 0x80-0xff */
248
249 /* Payload IE Group ID */
250 #define IEEE802154_PAYLOAD_IE_ESDU 0x0 /* Encapsulated Service Data Unit */
251 #define IEEE802154_PAYLOAD_IE_MLME 0x1 /* Media Access Control (MAC) subLayer Management Entity */
252 #define IEEE802154_PAYLOAD_IE_VENDOR 0x2 /* Vendor Specific */
253 #define IEEE802154_PAYLOAD_IE_MPX 0x3 /* MPX IE (802.15.9) */
254 #define IEEE802154_PAYLOAD_IE_WISUN 0x4 /* Wi-SUN IE */
255 #define IEEE802154_PAYLOAD_IE_IETF 0x5 /* IETF IE, RFC 8137 */
256 /* Reserved 0x6-0xe */
257 #define IEEE802154_PAYLOAD_IE_TERMINATION 0xf
258
259 /* Payload IE (Nested) Sub ID */
260 /* Payload IE (Nested) Sub ID - long format */
261 /* 0x0 - 0x7 Reserved */
262 /* 0x0 - 0x8 Vendor Specific */
263 #define IEEE802154_MLME_SUBIE_CHANNEL_HOPPING 0x9
264 /* 0xa - 0xf Reserved */
265 /* 0x10 - 0x19 Short Format Reserved */
266 #define IEEE802154_MLME_SUBIE_TSCH_SYNCH 0x1A
267 #define IEEE802154_MLME_SUBIE_TSCH_SLOTFR_LINK 0x1B
268 #define IEEE802154_MLME_SUBIE_TSCH_TIMESLOT 0x1C
269 #define IEEE802154_MLME_SUBIE_HOPPING_TIMING 0x1D
270 #define IEEE802154_MLME_SUBIE_ENHANCED_BEACON_FILTER 0x1E
271 #define IEEE802154_MLME_SUBIE_MAC_METRICS 0x1F
272 #define IEEE802154_MLME_SUBIE_ALL_MAC_METRICS 0x20
273 #define IEEE802154_MLME_SUBIE_COEXISTENCE_SPEC 0x21
274 #define IEEE802154_MLME_SUBIE_SUN_DEVICE_CAPABILITIES 0x22
275 #define IEEE802154_MLME_SUBIE_SUN_FSK_GEN_PHY 0x23
276 #define IEEE802154_MLME_SUBIE_MODE_SWITCH_PARAMETER 0x24
277 #define IEEE802154_MLME_SUBIE_PHY_PARAMETER_CHANGE 0x25
278 #define IEEE802154_MLME_SUBIE_O_QPSK_PHY_MODE 0x26
279 #define IEEE802154_MLME_SUBIE_PCA_ALLOCATION 0x27
280 #define IEEE802154_MLME_SUBIE_DSSS_OPER_MODE 0x28
281 #define IEEE802154_MLME_SUBIE_FSK_OPER_MODE 0x29
282 #define IEEE802154_MLME_SUBIE_TVWS_PHY_OPE_MODE 0x2B
283 #define IEEE802154_MLME_SUBIE_TVWS_DEVICE_CAPAB 0x2C
284 #define IEEE802154_MLME_SUBIE_TVWS_DEVICE_CATEG 0x2D
285 #define IEEE802154_MLME_SUBIE_TVWS_DEVICE_IDENTIF 0x2E
286 #define IEEE802154_MLME_SUBIE_TVWS_DEVICE_LOCATION 0x2F
287 #define IEEE802154_MLME_SUBIE_TVWS_CH_INFOR_QUERY 0x30
288 #define IEEE802154_MLME_SUBIE_TVWS_CH_INFOR_SOURCE 0x31
289 #define IEEE802154_MLME_SUBIE_CTM 0x32
290 #define IEEE802154_MLME_SUBIE_TIMESTAMP 0x33
291 #define IEEE802154_MLME_SUBIE_TIMESTAMP_DIFF 0x34
292 #define IEEE802154_MLME_SUBIE_TMCP_SPECIFICATION 0x35
293 #define IEEE802154_MLME_SUBIE_RCC_PHY_OPER_MODE 0x36
294 /* 0x37-0x7f Reserved */
295
296 /* IETF IE - Sub IE */
297 #define IEEE802154_IETF_SUBIE_6TOP 0xC9 /* not formally assigned yet */
298
299 /* IEEE 802.15.4 cipher block size. */
300 #define IEEE802154_CIPHER_SIZE 16
301
302 /* Macro to compute the MIC length. */
303 #define IEEE802154_MIC_LENGTH(_level_) ((0x2 << ((_level_) & 0x3)) & ~0x3)
304 /* Macro to check for payload encryption. */
305 #define IEEE802154_IS_ENCRYPTED(_level_) ((_level_) & 0x4)
306
307 /*SIXTOP Bit-mask*/
308 #define IETF_6TOP_VERSION 0x0F
309 #define IETF_6TOP_TYPE 0x30
310 #define IETF_6TOP_FLAGS_RESERVED 0xC0
311 #define IETF_6TOP_SEQNUM 0xFF
312
313 /* SIXTOP CMD and RC identifiers */
314 #define IETF_6TOP_CMD_ADD 0x01
315 #define IETF_6TOP_CMD_DELETE 0x02
316 #define IETF_6TOP_CMD_RELOCATE 0x03
317 #define IETF_6TOP_CMD_COUNT 0x04
318 #define IETF_6TOP_CMD_LIST 0x05
319 #define IETF_6TOP_CMD_SIGNAL 0x06
320 #define IETF_6TOP_CMD_CLEAR 0x07
321 #define IETF_6TOP_RC_SUCCESS 0x00
322 #define IETF_6TOP_RC_EOL 0x01
323 #define IETF_6TOP_RC_ERR 0x02
324 #define IETF_6TOP_RC_RESET 0x03
325 #define IETF_6TOP_RC_ERR_VERSION 0x04
326 #define IETF_6TOP_RC_ERR_SFID 0x05
327 #define IETF_6TOP_RC_ERR_SEQNUM 0x06
328 #define IETF_6TOP_RC_ERR_CELLLIST 0x07
329 #define IETF_6TOP_RC_ERR_BUSY 0x08
330 #define IETF_6TOP_RC_ERR_LOCKED 0x09
331
332 /* SIXTOP Message Types */
333 #define IETF_6TOP_TYPE_REQUEST 0x00
334 #define IETF_6TOP_TYPE_RESPONSE 0x01
335 #define IETF_6TOP_TYPE_CONFIRMATION 0x02
336 #define IETF_6TOP_TYPE_RESERVED 0x03
337
338 /* SIXTOP Cell Options */
339 #define IETF_6TOP_CELL_OPTION_TX 0x01
340 #define IETF_6TOP_CELL_OPTION_RX 0x02
341 #define IETF_6TOP_CELL_OPTION_SHARED 0x04
342 #define IETF_6TOP_CELL_OPTION_RESERVED 0xF8
343
344 /* IEEE 802.15.9 MPX IE */
345 #define IEEE802159_MPX_TRANSFER_TYPE_MASK 0x07
346 #define IEEE802159_MPX_TRANSACTION_ID_MASK 0xf8
347 #define IEEE802159_MPX_TRANSACTION_ID_SHIFT 0x03
348 /* IEEE 802.15.9 Table 19 */
349 #define IEEE802159_MPX_FULL_FRAME 0
350 #define IEEE802159_MPX_FULL_FRAME_NO_MUXID 1
351 #define IEEE802159_MPX_NON_LAST_FRAGMENT 2
352 #define IEEE802159_MPX_LAST_FRAGMENT 4
353 #define IEEE802159_MPX_ABORT 6
354 /* IEEE 802.15.9 Table 20 */
355 #define IEEE802159_MPX_MULTIPLEX_ID_KMP 1
356 #define IEEE802159_MPX_MULTIPLEX_ID_WISUN 2
357 /* IEEE 802.15.9 Table 21 */
358 #define IEEE802159_MPX_KMP_ID_IEEE8021X 1
359 #define IEEE802159_MPX_KMP_ID_HIP 2
360 #define IEEE802159_MPX_KMP_ID_IKEV2 3
361 #define IEEE802159_MPX_KMP_ID_PANA 4
362 #define IEEE802159_MPX_KMP_ID_DRAGONFLY 5
363 #define IEEE802159_MPX_KMP_ID_IEEE80211_4WH 6
364 #define IEEE802159_MPX_KMP_ID_IEEE80211_GKH 7
365 #define IEEE802159_MPX_KMP_ID_ETSI_TS_102_887_2 8
366 #define IEEE802159_MPX_KMP_ID_VENDOR_SPECIFIC 255
367 /* Wi-SUN MPX Sub-ID values. */
368 #define IEEE802159_MPX_WISUN_SUBID_MHDS 0
369 #define IEEE802159_MPX_WISUN_SUBID_6LOWPAN 1
370 #define IEEE802159_MPX_WISUN_SUBID_SECURITY 2
371
372 /* Structure containing information regarding all necessary packet fields. */
373 typedef struct {
374 /* Frame control field. */
375 gint32 version;
376 gint32 frame_type;
377 gint32 dst_addr_mode;
378 gint32 src_addr_mode;
379 gboolean security_enable;
380 gboolean frame_pending;
381 gboolean ack_request;
382 gboolean pan_id_compression;
383 gboolean seqno_suppression;
384 gboolean ie_present;
385 guint8 seqno;
386 /* Determined during processing of Header IE*/
387 gboolean payload_ie_present;
388 /* Addressing Info. */
389 guint16 dst_pan;
390 guint16 src_pan;
391 guint16 dst16;
392 guint64 dst64;
393 guint16 src16;
394 guint64 src64;
395
396 /* Security Info. */
397 ieee802154_security_level security_level;
398 ieee802154_key_id_mode key_id_mode;
399 gboolean frame_counter_suppression; /* 802.15.4-2015 */
400 guint32 frame_counter;
401 guint8 key_sequence_counter; /* Only for 802.15.4-2003 security suite with encryption */
402
403 union {
404 guint32 addr32;
405 guint64 addr64;
406 } key_source;
407 guint8 key_index;
408
409 /* Command ID (only if frame_type == 0x3) */
410 guint8 command_id;
411 GHashTable *short_table;
412 } ieee802154_packet;
413
414 /* Structure for two-way mapping table */
415 typedef struct {
416 GHashTable *long_table;
417 GHashTable *short_table;
418 } ieee802154_map_tab_t;
419
420 /* Key used by the short address hash table. */
421 typedef struct {
422 guint16 pan;
423 guint16 addr;
424 } ieee802154_short_addr;
425
426 /* Key used by the long address hash table. */
427 typedef struct {
428 guint64 addr;
429 } ieee802154_long_addr;
430
431 /* A mapping record for a frame, pointed to by hash table */
432 typedef struct {
433 const char *proto; /* name of protocol that created this record */
434 guint start_fnum;
435 guint end_fnum;
436 guint64 addr64;
437 /*guint32 frame_counter; TODO for frame counter sequence checks. */
438 } ieee802154_map_rec;
439
440 #define IEEE802154_USER_MAPPING 0
441
442 typedef struct {
443 guint16 src_pan;
444 guint16 src16;
445 guint16 dst16;
446 ieee802154_map_rec *map_rec;
447 void *packet;
448 } ieee802154_hints_t;
449
450 typedef enum {
451 DECRYPT_PACKET_SUCCEEDED,
452 DECRYPT_NOT_ENCRYPTED,
453 DECRYPT_FRAME_COUNTER_SUPPRESSION_UNSUPPORTED,
454 DECRYPT_PACKET_TOO_SMALL,
455 DECRYPT_PACKET_NO_EXT_SRC_ADDR,
456 DECRYPT_PACKET_NO_KEY,
457 DECRYPT_PACKET_DECRYPT_FAILED,
458 DECRYPT_PACKET_MIC_CHECK_FAILED
459 } ieee802154_decrypt_status;
460
461 /* UAT key structure. */
462 typedef struct {
463 gchar *pref_key;
464 guint key_index;
465 ieee802154_key_hash hash_type;
466 guint8 key[IEEE802154_CIPHER_SIZE];
467 guint8 mle_key[IEEE802154_CIPHER_SIZE];
468 } ieee802154_key_t;
469
470 /* */
471 void dissect_ieee802154_superframe (tvbuff_t *, packet_info *, proto_tree *, guint *);
472 void dissect_ieee802154_gtsinfo (tvbuff_t *, packet_info *, proto_tree *, guint *);
473 void dissect_ieee802154_pendaddr (tvbuff_t *, packet_info *, proto_tree *, guint *);
474 void dissect_ieee802154_aux_sec_header_and_key(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ieee802154_packet *packet, guint *offset);
475 void ccm_init_block(gchar *block, gboolean adata, gint M, guint64 addr, guint32 frame_counter, guint8 level, gint ctr_val, const gchar *generic_nonce);
476 gboolean ccm_ctr_encrypt(const gchar *key, const gchar *iv, gchar *mic, gchar *data, gint length);
477 gboolean ccm_cbc_mac(const gchar *key, const gchar *iv, const gchar *a, gint a_len, const gchar *m, gint m_len, gchar *mic);
478
479 proto_tree *ieee802154_create_hie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett);
480 proto_tree *ieee802154_create_pie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett);
481
482
484 #define IEEE802154_DISSECT_HEADER_OPTION_NO_AUX_SEC_HDR (1 << 1)
485
495 guint ieee802154_dissect_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint options, proto_tree **created_header_tree, ieee802154_packet **parsed_info);
496
508 tvbuff_t* ieee802154_decrypt_payload(tvbuff_t *tvb, guint mhr_len, packet_info *pinfo, proto_tree *ieee802154_tree, ieee802154_packet *packet);
509
518 guint ieee802154_dissect_payload_ies(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ieee802154_tree, ieee802154_packet *packet);
519
529 guint ieee802154_dissect_frame_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ieee802154_tree, ieee802154_packet *packet, gboolean fcs_ok);
530
531
532 /* Results for the decryption */
533 typedef struct {
534 /* Set by decrypt_ieee802154_payload */
535 unsigned char *key; // not valid after return of decrypt_ieee802154_payload
536 guint key_number;
537 /* Set by the ieee802154_decrypt_func */
538 unsigned char* rx_mic;
539 guint* rx_mic_length;
540 guint aux_offset;
541 guint aux_length;
542 ieee802154_decrypt_status* status;
543 } ieee802154_decrypt_info_t;
544
547 typedef guint (*ieee802154_set_key_func) (ieee802154_packet *packet, unsigned char *key, unsigned char *alt_key, ieee802154_key_t *uat_key);
549 typedef tvbuff_t* (*ieee802154_decrypt_func) (tvbuff_t *, guint, packet_info *, ieee802154_packet *, ieee802154_decrypt_info_t*);
553 tvbuff_t *decrypt_ieee802154_payload(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *key_tree, ieee802154_packet *packet,
554 ieee802154_decrypt_info_t *decrypt_info, ieee802154_set_key_func set_key_func, ieee802154_decrypt_func decrypt_func);
555
556
557 extern void register_ieee802154_mac_key_hash_handler(guint hash_identifier, ieee802154_set_key_func key_func);
558
559 /* Short to Extended Address Prototypes */
560 extern ieee802154_map_rec *ieee802154_addr_update(ieee802154_map_tab_t *, guint16, guint16, guint64,
561 const char *, guint);
562 extern guint ieee802154_short_addr_hash(gconstpointer);
563 extern guint ieee802154_long_addr_hash(gconstpointer key);
564 extern gboolean ieee802154_short_addr_equal(gconstpointer, gconstpointer);
565 extern gboolean ieee802154_long_addr_equal(gconstpointer a, gconstpointer b);
566
567 extern gboolean ieee802154_short_addr_invalidate(guint16, guint16, guint);
568 extern gboolean ieee802154_long_addr_invalidate(guint64, guint);
569
570 extern ieee802154_map_tab_t ieee802154_map;
571
572 extern const value_string ieee802154_mpx_kmp_id_vals[];
573
574 #endif /* PACKET_IEEE802154_H */
ieee802154_packet
Definition: packet-ieee802154.h:373
ieee802154_key_t
Definition: packet-ieee802154.h:462
_packet_info
Definition: packet_info.h:44
tvbuff
Definition: tvbuff-int.h:35
ieee802154_map_tab_t
Definition: packet-ieee802154.h:415
ieee802154_long_addr
Definition: packet-ieee802154.h:427
ieee802154_decrypt_info_t
Definition: packet-ieee802154.h:533
ieee802154_short_addr
Definition: packet-ieee802154.h:421
ieee802154_hints_t
Definition: packet-ieee802154.h:442
ieee802154_map_rec
Definition: packet-ieee802154.h:432
_value_string
Definition: value_string.h:24
_proto_node
Definition: proto.h:759