20#ifndef __IEEE802154_FRAME_H__
21#define __IEEE802154_FRAME_H__
34#define IEEE802154_ACK_PKT_LENGTH 3
41#define IEEE802154_MIN_LENGTH IEEE802154_ACK_PKT_LENGTH
49#define IEEE802154_FCF_SEQ_LENGTH 3
56#define IEEE802154_PAN_ID_LENGTH 2
64#define IEEE802154_BEACON_MIN_SIZE 4
71#define IEEE802154_BEACON_SF_SIZE 2
78#define IEEE802154_BEACON_GTS_SPEC_SIZE 1
85#define IEEE802154_BEACON_GTS_IF_MIN_SIZE IEEE802154_BEACON_GTS_SPEC_SIZE
92#define IEEE802154_BEACON_PAS_SPEC_SIZE 1
101#define IEEE802154_BEACON_PAS_IF_MIN_SIZE IEEE802154_BEACON_PAS_SPEC_SIZE
109#define IEEE802154_BEACON_GTS_DIR_SIZE 1
116#define IEEE802154_BEACON_GTS_SIZE 3
123#define IEEE802154_BEACON_GTS_RX 1
130#define IEEE802154_BEACON_GTS_TX 0
201#ifdef CONFIG_LITTLE_ENDIAN
349#define IEEE802154_SECURITY_LEVEL_ENC IEEE802154_SECURITY_LEVEL_RESERVED
357#define IEEE802154_AUTH_TAG_LENGTH_32 4
365#define IEEE802154_AUTH_TAG_LENGTH_64 8
373#define IEEE802154_AUTH_TAG_LENGTH_128 16
396#define IEEE802154_KEY_ID_FIELD_INDEX_LENGTH 1
403#define IEEE802154_KEY_ID_FIELD_SRC_4_INDEX_LENGTH 5
410#define IEEE802154_KEY_ID_FIELD_SRC_8_INDEX_LENGTH 9
417#define IEEE802154_KEY_MAX_LEN 16
425#ifdef CONFIG_LITTLE_ENDIAN
447#define IEEE802154_SECURITY_CF_LENGTH 1
507#define IEEE802154_SECURITY_FRAME_COUNTER_LENGTH 4
532#ifdef CONFIG_LITTLE_ENDIAN
553#ifdef CONFIG_LITTLE_ENDIAN
572#ifdef CONFIG_LITTLE_ENDIAN
595#ifdef CONFIG_LITTLE_ENDIAN
622#ifdef CONFIG_LITTLE_ENDIAN
677#ifdef CONFIG_LITTLE_ENDIAN
720#define IEEE802154_CMD_ASSOC_REQ_LENGTH 1
757#define IEEE802154_CMD_ASSOC_RES_LENGTH 3
792#define IEEE802154_CMD_DISASSOC_NOTE_LENGTH 1
817#define IEEE802154_CMD_COORD_REALIGN_LENGTH 3
827#ifdef CONFIG_LITTLE_ENDIAN
854#define IEEE802154_GTS_REQUEST_LENGTH 1
920#define IEEE802154_CMD_CFI_LENGTH 1
982#ifdef CONFIG_NET_L2_IEEE802154_SECURITY
1002int ieee802514_beacon_header_length(
uint8_t *buf,
uint8_t length);
1006void ieee802154_compute_header_and_authtag_len(
struct net_if *iface,
struct net_linkaddr *dst,
1026#ifdef CONFIG_NET_L2_IEEE802154_SECURITY
1027bool ieee802154_decipher_data_frame(
struct net_if *iface,
struct net_pkt *pkt,
1030#define ieee802154_decipher_data_frame(...) true
#define IEEE802154_EXT_ADDR_LENGTH
IEEE 802.15.4 extended address length.
Definition ieee802154.h:144
IEEE 802.15.4 native L2 stack public header.
ieee802154_frame_type
Values of the Frame Type subfield in the Frame Control field.
Definition ieee802154_frame.h:137
@ IEEE802154_FRAME_TYPE_DATA
Data frame.
Definition ieee802154_frame.h:141
@ IEEE802154_FRAME_TYPE_BEACON
Beacon frame.
Definition ieee802154_frame.h:139
@ IEEE802154_FRAME_TYPE_MAC_COMMAND
MAC command frame.
Definition ieee802154_frame.h:145
@ IEEE802154_FRAME_TYPE_MULTIPURPOSE
Multipurpose frame.
Definition ieee802154_frame.h:149
@ IEEE802154_FRAME_TYPE_FRAK
FRak frame (fragment acknowledgment).
Definition ieee802154_frame.h:151
@ IEEE802154_FRAME_TYPE_EXTENDED
Extended frame type; use the Extended Frame Type field.
Definition ieee802154_frame.h:153
@ IEEE802154_FRAME_TYPE_ACK
Acknowledgment frame.
Definition ieee802154_frame.h:143
@ IEEE802154_FRAME_TYPE_RESERVED
Reserved frame type.
Definition ieee802154_frame.h:147
ieee802154_disassociation_reason_field
Disassociation reason codes in the Disassociation Notification command.
Definition ieee802154_frame.h:764
@ IEEE802154_DRF_RESERVED_PRIMITIVES
Reserved range for MAC primitives.
Definition ieee802154_frame.h:774
@ IEEE802154_DRF_DEVICE_WISH
Device wishes to leave.
Definition ieee802154_frame.h:770
@ IEEE802154_DRF_COORDINATOR_WISH
Coordinator wishes device to leave.
Definition ieee802154_frame.h:768
@ IEEE802154_DRF_RESERVED_2
Reserved.
Definition ieee802154_frame.h:772
@ IEEE802154_DRF_RESERVED_1
Reserved.
Definition ieee802154_frame.h:766
ieee802154_addressing_mode
Destination and Source Addressing Mode subfield values.
Definition ieee802154_frame.h:161
@ IEEE802154_ADDR_MODE_EXTENDED
Extended address (64 bit).
Definition ieee802154_frame.h:169
@ IEEE802154_ADDR_MODE_NONE
Addressing fields omitted (not present).
Definition ieee802154_frame.h:163
@ IEEE802154_ADDR_MODE_RESERVED
Reserved; shall not be used.
Definition ieee802154_frame.h:165
@ IEEE802154_ADDR_MODE_SHORT
Short address (16 bit).
Definition ieee802154_frame.h:167
ieee802154_cfi
Command Frame Identifier (CFI) values for MAC commands.
Definition ieee802154_frame.h:861
@ IEEE802154_CFI_ORPHAN_NOTIFICATION
Orphan notification.
Definition ieee802154_frame.h:875
@ IEEE802154_CFI_DISASSOCIATION_NOTIFICATION
Disassociation notification.
Definition ieee802154_frame.h:869
@ IEEE802154_CFI_COORDINATOR_REALIGNEMENT
Coordinator realignment.
Definition ieee802154_frame.h:879
@ IEEE802154_CFI_ASSOCIATION_RESPONSE
Association response.
Definition ieee802154_frame.h:867
@ IEEE802154_CFI_GTS_REQUEST
GTS request.
Definition ieee802154_frame.h:881
@ IEEE802154_CFI_PAN_ID_CONFLICT_NOTIFICATION
PAN ID conflict notification.
Definition ieee802154_frame.h:873
@ IEEE802154_CFI_ASSOCIATION_REQUEST
Association request.
Definition ieee802154_frame.h:865
@ IEEE802154_CFI_BEACON_REQUEST
Beacon request.
Definition ieee802154_frame.h:877
@ IEEE802154_CFI_DATA_REQUEST
Data request.
Definition ieee802154_frame.h:871
@ IEEE802154_CFI_UNKNOWN
Unknown or unspecified command.
Definition ieee802154_frame.h:863
@ IEEE802154_CFI_RESERVED
Reserved.
Definition ieee802154_frame.h:883
ieee802154_association_status_field
Association status values in the Association Response command.
Definition ieee802154_frame.h:727
@ IEEE802154_ASF_RESERVED_PRIMITIVES
Reserved range for MAC primitives.
Definition ieee802154_frame.h:737
@ IEEE802154_ASF_PAN_ACCESS_DENIED
PAN access denied.
Definition ieee802154_frame.h:733
@ IEEE802154_ASF_SUCCESSFUL
Association successful.
Definition ieee802154_frame.h:729
@ IEEE802154_ASF_RESERVED
Reserved.
Definition ieee802154_frame.h:735
@ IEEE802154_ASF_PAN_AT_CAPACITY
PAN at capacity.
Definition ieee802154_frame.h:731
ieee802154_version
Frame Version subfield values.
Definition ieee802154_frame.h:177
@ IEEE802154_VERSION_802154_2006
IEEE Std 802.15.4-2006.
Definition ieee802154_frame.h:181
@ IEEE802154_VERSION_RESERVED
Reserved for future use.
Definition ieee802154_frame.h:185
@ IEEE802154_VERSION_802154
IEEE Std 802.15.4 (2003 and 2006 excluded).
Definition ieee802154_frame.h:183
@ IEEE802154_VERSION_802154_2003
IEEE Std 802.15.4-2003.
Definition ieee802154_frame.h:179
ieee802154_security_level
Security Level subfield values in the Security Control field.
Definition ieee802154_frame.h:324
@ IEEE802154_SECURITY_LEVEL_RESERVED
Reserved.
Definition ieee802154_frame.h:334
@ IEEE802154_SECURITY_LEVEL_MIC_32
MIC-32 authentication only.
Definition ieee802154_frame.h:328
@ IEEE802154_SECURITY_LEVEL_MIC_128
MIC-128 authentication only.
Definition ieee802154_frame.h:332
@ IEEE802154_SECURITY_LEVEL_ENC_MIC_64
Encryption with MIC-64.
Definition ieee802154_frame.h:338
@ IEEE802154_SECURITY_LEVEL_ENC_MIC_32
Encryption with MIC-32.
Definition ieee802154_frame.h:336
@ IEEE802154_SECURITY_LEVEL_ENC_MIC_128
Encryption with MIC-128.
Definition ieee802154_frame.h:340
@ IEEE802154_SECURITY_LEVEL_MIC_64
MIC-64 authentication only.
Definition ieee802154_frame.h:330
@ IEEE802154_SECURITY_LEVEL_NONE
No security (no encryption, no authentication).
Definition ieee802154_frame.h:326
ieee802154_key_id_mode
Key Identifier Mode subfield values.
Definition ieee802154_frame.h:380
@ IEEE802154_KEY_ID_MODE_SRC_8_INDEX
8-octet Key Source and Key Index.
Definition ieee802154_frame.h:388
@ IEEE802154_KEY_ID_MODE_IMPLICIT
Key is determined implicitly.
Definition ieee802154_frame.h:382
@ IEEE802154_KEY_ID_MODE_INDEX
Key Index only.
Definition ieee802154_frame.h:384
@ IEEE802154_KEY_ID_MODE_SRC_4_INDEX
4-octet Key Source and Key Index.
Definition ieee802154_frame.h:386
Network packet buffer descriptor API.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Destination or Source Address field when PAN ID Compression omits the PAN ID.
Definition ieee802154_frame.h:282
struct ieee802154_address addr
Short or extended address when the PAN ID is omitted (compressed).
Definition ieee802154_frame.h:284
Destination or Source Address field with PAN ID and address.
Definition ieee802154_frame.h:292
uint16_t pan_id
PAN identifier for this address field.
Definition ieee802154_frame.h:294
struct ieee802154_address addr
Short or extended address following the PAN ID.
Definition ieee802154_frame.h:296
Destination or Source Address field in either compressed or plain form.
Definition ieee802154_frame.h:305
struct ieee802154_address_field_plain plain
PAN ID and address (plain addressing).
Definition ieee802154_frame.h:313
struct ieee802154_address_field_comp comp
Address only (PAN ID compressed).
Definition ieee802154_frame.h:315
Short or extended address value in MAC addressing fields.
Definition ieee802154_frame.h:263
uint16_t short_addr
16-bit short address.
Definition ieee802154_frame.h:271
uint8_t ext_addr[0]
Start of 64-bit extended address (eight octets).
Definition ieee802154_frame.h:273
Auxiliary Security Header (ASH) following addressing fields when security is enabled.
Definition ieee802154_frame.h:493
uint32_t frame_counter
Frame Counter field (four octets).
Definition ieee802154_frame.h:497
struct ieee802154_security_control_field control
Security Control field.
Definition ieee802154_frame.h:495
struct ieee802154_key_identifier_field kif
Key Identifier field; length depends on Key Identifier Mode.
Definition ieee802154_frame.h:499
Superframe Specification field of the beacon payload.
Definition ieee802154_frame.h:621
uint16_t association
Association Permit subfield.
Definition ieee802154_frame.h:643
uint16_t reserved
Reserved; shall be zero.
Definition ieee802154_frame.h:647
uint16_t coordinator
PAN Coordinator subfield.
Definition ieee802154_frame.h:645
uint16_t bc_order
Beacon Order subfield.
Definition ieee802154_frame.h:641
uint16_t sf_order
Superframe Order subfield.
Definition ieee802154_frame.h:639
uint16_t cap_slot
Final CAP Slot subfield.
Definition ieee802154_frame.h:651
uint16_t ble
Battery Life Extension subfield.
Definition ieee802154_frame.h:649
Fixed part of the Beacon Payload (Superframe Specification and GTS Specification).
Definition ieee802154_frame.h:661
struct ieee802154_beacon_sf sf
Superframe Specification field.
Definition ieee802154_frame.h:663
struct ieee802154_gts_spec gts
GTS Specification field (always present in this layout).
Definition ieee802154_frame.h:666
Association Request command payload (Capability Information field).
Definition ieee802154_frame.h:674
struct ieee802154_cmd_assoc_req::@142161226336003254172340026226003253060352214227 ci
Capability Information bit field.
uint8_t reserved_1
Reserved; shall be zero.
Definition ieee802154_frame.h:710
uint8_t alloc_addr
Allocate address.
Definition ieee802154_frame.h:696
uint8_t power_src
Power source.
Definition ieee802154_frame.h:706
uint8_t reserved_2
Reserved; shall be zero.
Definition ieee802154_frame.h:700
uint8_t dev_type
Device type (FFD or RFD).
Definition ieee802154_frame.h:708
uint8_t sec_capability
Security capability.
Definition ieee802154_frame.h:698
uint8_t association_type
Association type.
Definition ieee802154_frame.h:702
uint8_t rx_on
Receiver on when idle.
Definition ieee802154_frame.h:704
Association Response command payload.
Definition ieee802154_frame.h:745
uint16_t short_addr
Short address assigned by coordinator, or a special value if none.
Definition ieee802154_frame.h:747
uint8_t status
Association status; see ieee802154_association_status_field.
Definition ieee802154_frame.h:749
Coordinator Realignment command payload.
Definition ieee802154_frame.h:799
uint8_t channel_page
Channel page (optional fourth octet of the channel specification).
Definition ieee802154_frame.h:809
uint16_t coordinator_short_addr
Coordinator short address.
Definition ieee802154_frame.h:803
uint8_t channel
Logical channel.
Definition ieee802154_frame.h:805
uint16_t pan_id
PAN identifier.
Definition ieee802154_frame.h:801
uint16_t short_addr
Short address of the device addressed by this command.
Definition ieee802154_frame.h:807
Disassociation Notification command payload.
Definition ieee802154_frame.h:782
uint8_t reason
Disassociation reason; see ieee802154_disassociation_reason_field.
Definition ieee802154_frame.h:784
Parsed MAC command frame payload.
Definition ieee802154_frame.h:893
uint8_t cfi
Command Frame Identifier; see ieee802154_cfi.
Definition ieee802154_frame.h:895
struct ieee802154_cmd_disassoc_note disassoc_note
Disassociation Notification command.
Definition ieee802154_frame.h:907
struct ieee802154_gts_request gts_request
GTS Request command.
Definition ieee802154_frame.h:911
struct ieee802154_cmd_assoc_req assoc_req
Association Request command.
Definition ieee802154_frame.h:903
struct ieee802154_cmd_assoc_res assoc_res
Association Response command.
Definition ieee802154_frame.h:905
struct ieee802154_cmd_coord_realign coord_realign
Coordinator Realignment command.
Definition ieee802154_frame.h:909
IEEE 802.15.4 L2 context.
Definition ieee802154.h:252
Frame Control field and Sequence Number as in the MHR.
Definition ieee802154_frame.h:194
uint16_t reserved
Reserved; shall be zero.
Definition ieee802154_frame.h:226
uint16_t src_addr_mode
Source Addressing Mode; see ieee802154_addressing_mode.
Definition ieee802154_frame.h:238
uint8_t sequence
Data Sequence Number (DSN) for outgoing frames, or received sequence number; see section 7....
Definition ieee802154_frame.h:254
uint16_t frame_type
Frame Type; see ieee802154_frame_type.
Definition ieee802154_frame.h:236
uint16_t frame_version
Frame Version; see ieee802154_version.
Definition ieee802154_frame.h:240
uint16_t frame_pending
Frame Pending: more data for the recipient.
Definition ieee802154_frame.h:232
uint16_t ar
Acknowledgment Request: sender requests an Imm-Ack or Enh-Ack.
Definition ieee802154_frame.h:230
uint16_t ie_list
IE List / Information Elements Present; Header/Payload IEs follow when set.
Definition ieee802154_frame.h:244
struct ieee802154_fcf_seq::@121000037171274047062010215103364113307151001073 fc
Frame Control field (first two octets of the MHR).
uint16_t dst_addr_mode
Destination Addressing Mode; see ieee802154_addressing_mode.
Definition ieee802154_frame.h:242
uint16_t pan_id_comp
PAN ID Compression; see section 7.2.2.5.
Definition ieee802154_frame.h:228
uint16_t seq_num_suppr
Sequence Number Suppression; no Sequence Number field when set.
Definition ieee802154_frame.h:246
uint16_t security_enabled
Security Enabled: 1 if the Auxiliary Security Header is present.
Definition ieee802154_frame.h:234
Parameters for building a MAC frame (addresses and PAN identifiers).
Definition ieee802154_frame.h:953
uint8_t ext_addr[8]
Extended destination address (big-endian on the air).
Definition ieee802154_frame.h:963
struct ieee802154_frame_params::@044052354265101061322162374367336266017235033000 dst
Destination addressing.
uint16_t pan_id
Destination PAN identifier (CPU byte order).
Definition ieee802154_frame.h:971
uint16_t len
Length of the destination address field in use.
Definition ieee802154_frame.h:969
uint16_t short_addr
Short destination address (CPU byte order).
Definition ieee802154_frame.h:965
GTS Direction field in the beacon payload.
Definition ieee802154_frame.h:531
uint8_t reserved
Reserved; shall be zero.
Definition ieee802154_frame.h:539
uint8_t mask
Direction mask for GTS descriptors (one bit per descriptor).
Definition ieee802154_frame.h:541
GTS Request command payload.
Definition ieee802154_frame.h:824
struct ieee802154_gts_request::@374376201131055220313116360161244007112032316270 gts
GTS request descriptor.
uint8_t reserved
Reserved; shall be zero.
Definition ieee802154_frame.h:838
uint8_t length
GTS length.
Definition ieee802154_frame.h:844
uint8_t type
Characteristics type.
Definition ieee802154_frame.h:840
uint8_t direction
GTS direction (receive or transmit).
Definition ieee802154_frame.h:842
GTS Specification field of the beacon payload.
Definition ieee802154_frame.h:571
uint8_t reserved
Reserved; shall be zero.
Definition ieee802154_frame.h:583
uint8_t permit
GTS Permit subfield.
Definition ieee802154_frame.h:581
uint8_t desc_count
GTS Descriptor Count subfield.
Definition ieee802154_frame.h:585
One GTS descriptor in the GTS List field.
Definition ieee802154_frame.h:550
uint16_t short_address
Short address of the device for which the GTS is described.
Definition ieee802154_frame.h:552
uint8_t starting_slot
GTS Starting Slot subfield.
Definition ieee802154_frame.h:562
uint8_t length
GTS Length subfield.
Definition ieee802154_frame.h:560
Key Identifier field of the Auxiliary Security Header.
Definition ieee802154_frame.h:457
uint8_t key_index
Key Index.
Definition ieee802154_frame.h:467
struct ieee802154_key_identifier_field::@327376257014173026171111007363133054206271315322::@362156237305054176167362056153223043016142342207 mode_2
Key Identifier Mode 2: 4-octet Key Source and Key Index.
struct ieee802154_key_identifier_field::@327376257014173026171111007363133054206271315322::@356155246235321153061003367327361030203273231215 mode_3
Key Identifier Mode 3: 8-octet Key Source and Key Index.
struct ieee802154_key_identifier_field::@327376257014173026171111007363133054206271315322::@067161035130346144103157102011367313142013025225 mode_1
Key Identifier Mode 1: Key Index only.
uint8_t key_src[4]
Key Source (four octets).
Definition ieee802154_frame.h:473
Parsed view of the MAC Header (MHR) and Auxiliary Security Header pointers.
Definition ieee802154_frame.h:515
struct ieee802154_fcf_seq * fs
Frame Control and Sequence Number.
Definition ieee802154_frame.h:517
struct ieee802154_aux_security_hdr * aux_sec
Auxiliary Security Header, if Security Enabled is one.
Definition ieee802154_frame.h:523
struct ieee802154_address_field * src_addr
Source address field, if present per Frame Control.
Definition ieee802154_frame.h:521
struct ieee802154_address_field * dst_addr
Destination address field, if present per Frame Control.
Definition ieee802154_frame.h:519
Parsed MAC Service Data Unit (MSDU) with MHR pointers and payload view.
Definition ieee802154_frame.h:927
struct ieee802154_beacon * beacon
Beacon payload when the frame is a beacon.
Definition ieee802154_frame.h:939
void * payload
Untyped MAC payload (beacon, data, or command body).
Definition ieee802154_frame.h:937
uint16_t payload_length
Length of the MAC payload in octets.
Definition ieee802154_frame.h:944
struct ieee802154_mhr mhr
MAC header (and optional Auxiliary Security Header) references.
Definition ieee802154_frame.h:929
struct ieee802154_command * command
MAC command payload when the frame is a MAC command.
Definition ieee802154_frame.h:941
Pending Address Specification field of the beacon payload.
Definition ieee802154_frame.h:594
uint8_t nb_sap
Number of Short Addresses Pending subfield.
Definition ieee802154_frame.h:612
uint8_t reserved_2
Reserved; shall be zero.
Definition ieee802154_frame.h:610
uint8_t nb_eap
Number of Extended Addresses Pending subfield.
Definition ieee802154_frame.h:608
uint8_t reserved_1
Reserved; shall be zero.
Definition ieee802154_frame.h:606
Security Control field (first octet of the Auxiliary Security Header).
Definition ieee802154_frame.h:424
uint8_t reserved
Reserved; shall be zero.
Definition ieee802154_frame.h:434
uint8_t key_id_mode
Key Identifier Mode; see ieee802154_key_id_mode.
Definition ieee802154_frame.h:436
uint8_t security_level
Security Level; see ieee802154_security_level.
Definition ieee802154_frame.h:438
Network buffer representation.
Definition net_buf.h:1015
uint8_t * data
Pointer to the start of data in the buffer.
Definition net_buf.h:1041
uint16_t len
Length of the data behind the data pointer.
Definition net_buf.h:1044
Network Interface structure.
Definition net_if.h:731
Hardware link address structure.
Definition net_linkaddr.h:83
Network packet.
Definition net_pkt.h:95
struct net_buf * frags
buffer fragment
Definition net_pkt.h:107
struct net_if * iface
Network interface.
Definition net_pkt.h:118