13#ifndef PACKET_IEEE802154_H
14#define PACKET_IEEE802154_H
17#define IEEE802154_PROTOABBREV_WPAN "wpan"
18#define IEEE802154_PROTOABBREV_WPAN_BEACON "wpan.beacon"
20#define IEEE802154_PROTOABBREV_WPAN_PANID "wpan.panid"
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"
29#define IEEE802154_MAX_FRAME_LEN 127
30#define IEEE802154_FCS_LEN 2
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
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
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
64#define IEEE802154_CMD_ASRSP_AS_SUCCESS 0x00
65#define IEEE802154_CMD_ASRSP_PAN_FULL 0x01
66#define IEEE802154_CMD_ASRSP_PAN_DENIED 0x02
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
77#define IEEE802154_CMD_GTS_REQ_LEN 0x0F
78#define IEEE802154_CMD_GTS_REQ_DIR 0x10
79#define IEEE802154_CMD_GTS_REQ_TYPE 0x20
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
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
106#define IEEE802154_PENDADDR_SHORT_MASK 0x07
107#define IEEE802154_PENDADDR_LONG_MASK 0x70
108#define IEEE802154_PENDADDR_LONG_SHIFT 4
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
115#define IEEE802154_FCF_TYPE_MASK 0x0007
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
120#define IEEE802154_FCF_SEQNO_SUPPRESSION 0x0100
121#define IEEE802154_FCF_IE_PRESENT 0x0200
122#define IEEE802154_FCF_DADDR_MASK 0x0C00
123#define IEEE802154_FCF_VERSION 0x3000
124#define IEEE802154_FCF_SADDR_MASK 0xC000
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
140#define IEEE802154_FCF_BEACON 0x0
141#define IEEE802154_FCF_DATA 0x1
142#define IEEE802154_FCF_ACK 0x2
143#define IEEE802154_FCF_CMD 0x3
144#define IEEE802154_FCF_RESERVED 0x4
145#define IEEE802154_FCF_MULTIPURPOSE 0x5
146#define IEEE802154_FCF_FRAGMENT 0x6
147#define IEEE802154_FCF_EXTENDED 0x7
150#define IEEE802154_VERSION_2003 0x0
151#define IEEE802154_VERSION_2006 0x1
152#define IEEE802154_VERSION_2015 0x2
153#define IEEE802154_VERSION_RESERVED 0x3
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
162#define IEEE802154_HEADER_IE_TYPE_MASK 0x8000
163#define IEEE802154_HEADER_IE_ID_MASK 0x7F80
164#define IEEE802154_HEADER_IE_LENGTH_MASK 0x007F
167#define IEEE802154_PAYLOAD_IE_TYPE_MASK 0x8000
168#define IEEE802154_PAYLOAD_IE_ID_MASK 0x7800
169#define IEEE802154_PAYLOAD_IE_LENGTH_MASK 0x07FF
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
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
187#define IEEE802154_CC24xx_CRC_OK 0x8000
188#define IEEE802154_CC24xx_CORRELATION 0x7F00
189#define IEEE802154_CC24xx_RSSI 0x00FF
192#define IEEE802154_NO_ADDR16 0xFFFE
193#define IEEE802154_BCAST_ADDR 0xFFFF
194#define IEEE802154_BCAST_PAN 0xFFFF
197#define IEEE802154_PHY_LENGTH_MASK 0x7F
200#define IEEE802154_AUX_SEC_LEVEL_MASK 0x07
201#define IEEE802154_AUX_KEY_ID_MODE_MASK 0x18
202#define IEEE802154_AUX_KEY_ID_MODE_SHIFT 3
203#define IEEE802154_AUX_FRAME_COUNTER_SUPPRESSION_MASK 0x20
204#define IEEE802154_AUX_ASN_IN_NONCE_MASK 0x40
206#define IEEE802154_AUX_CTRL_RESERVED_MASK 0x80
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
214#define IEEE802154E_LE_WUF_LEN 12
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;
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;
235 KEY_HASH_NONE = 0x00,
237 KEY_HASH_THREAD = 0x02
238} ieee802154_key_hash;
241#define IEEE802154_HEADER_IE_VENDOR_SPECIFIC 0x00
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
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
261#define IEEE802154_HEADER_IE_HT1 0x7e
262#define IEEE802154_HEADER_IE_HT2 0x7f
265#define IEEE802154_HEADER_IE_THREAD 0x9b
270#define IEEE802154_PAYLOAD_IE_ESDU 0x0
271#define IEEE802154_PAYLOAD_IE_MLME 0x1
272#define IEEE802154_PAYLOAD_IE_VENDOR 0x2
273#define IEEE802154_PAYLOAD_IE_MPX 0x3
274#define IEEE802154_PAYLOAD_IE_WISUN 0x4
275#define IEEE802154_PAYLOAD_IE_IETF 0x5
277#define IEEE802154_PAYLOAD_IE_TERMINATION 0xf
283#define IEEE802154_MLME_SUBIE_CHANNEL_HOPPING 0x9
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
317#define IEEE802154_IETF_SUBIE_6TOP_DRAFT 0xC9
318#define IEEE802154_IETF_SUBIE_6TOP 0x01
321#define IEEE802154_CIPHER_SIZE 16
324#define IEEE80215_CID 0xBA55ECULL
327#define IEEE802154_MIC_LENGTH(_level_) ((0x2 << ((_level_) & 0x3)) & ~0x3)
329#define IEEE802154_IS_ENCRYPTED(_level_) ((_level_) & 0x4)
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
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
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
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
369#define IEEE802159_MPX_TRANSFER_TYPE_MASK 0x07
370#define IEEE802159_MPX_TRANSACTION_ID_MASK 0xf8
371#define IEEE802159_MPX_TRANSACTION_ID_SHIFT 0x03
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
379#define IEEE802159_MPX_MULTIPLEX_ID_KMP 1
380#define IEEE802159_MPX_MULTIPLEX_ID_WISUN 2
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
392#define IEEE802159_MPX_WISUN_SUBID_MHDS 0
393#define IEEE802159_MPX_WISUN_SUBID_6LOWPAN 1
394#define IEEE802159_MPX_WISUN_SUBID_SECURITY 2
401 int32_t dst_addr_mode;
402 int32_t src_addr_mode;
403 bool security_enable;
406 bool pan_id_compression;
407 bool seqno_suppression;
411 bool long_frame_control;
416 bool payload_ie_present;
418 bool dst_pan_present;
419 bool src_pan_present;
428 ieee802154_security_level security_level;
429 ieee802154_key_id_mode key_id_mode;
430 bool frame_counter_suppression;
431 uint32_t frame_counter;
432 uint8_t key_sequence_counter;
443 GHashTable *short_table;
448 GHashTable *long_table;
449 GHashTable *short_table;
472#define IEEE802154_USER_MAPPING 0
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;
497 ieee802154_key_hash hash_type;
498 uint8_t key[IEEE802154_CIPHER_SIZE];
499 uint8_t mle_key[IEEE802154_CIPHER_SIZE];
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);
516#define IEEE802154_DISSECT_HEADER_OPTION_NO_AUX_SEC_HDR (1 << 1)
570 unsigned char* rx_mic;
571 unsigned* rx_mic_length;
574 ieee802154_decrypt_status* status;
589extern void register_ieee802154_mac_key_hash_handler(
unsigned hash_identifier, ieee802154_set_key_func key_func);
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);
599extern bool ieee802154_short_addr_invalidate(uint16_t, uint16_t,
unsigned);
600extern bool ieee802154_long_addr_invalidate(uint64_t,
unsigned);
607extern unsigned ieee802154_fcs_len;
Definition packet_info.h:43
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