23#ifndef ZEPHYR_INCLUDE_NET_IEEE802154_IE_H_
24#define ZEPHYR_INCLUDE_NET_IEEE802154_IE_H_
65#define IEEE802154_VENDOR_SPECIFIC_IE_OUI_LEN 3
141struct ieee802154_header_ie {
142#if CONFIG_LITTLE_ENDIAN
166#define IEEE802154_HEADER_IE_HEADER_LENGTH sizeof(uint16_t)
170#define IEEE802154_DEFINE_HEADER_IE(_element_id, _length, _content, _content_type) \
171 (struct ieee802154_header_ie) { \
172 .length = (_length), \
173 .element_id_high = (_element_id) >> 1U, .element_id_low = (_element_id) & 0x01, \
174 .type = IEEE802154_IE_TYPE_HEADER, \
175 .content._content_type = _content, \
178#define IEEE802154_DEFINE_HEADER_IE_VENDOR_SPECIFIC_CONTENT_LEN(_vendor_specific_info_len) \
179 (IEEE802154_VENDOR_SPECIFIC_IE_OUI_LEN + (_vendor_specific_info_len))
181#define IEEE802154_DEFINE_HEADER_IE_VENDOR_SPECIFIC_CONTENT(_vendor_oui, _vendor_specific_info) \
182 (struct ieee802154_header_ie_vendor_specific) { \
183 .vendor_oui = _vendor_oui, .vendor_specific_info = (_vendor_specific_info), \
186#define IEEE802154_DEFINE_HEADER_IE_CSL_REDUCED_CONTENT(_csl_phase, _csl_period) \
187 (struct ieee802154_header_ie_csl_reduced) { \
188 .csl_phase = sys_cpu_to_le16(_csl_phase), \
189 .csl_period = sys_cpu_to_le16(_csl_period), \
192#define IEEE802154_DEFINE_HEADER_IE_CSL_FULL_CONTENT(_csl_phase, _csl_period, \
193 _csl_rendezvous_time) \
194 (struct ieee802154_header_ie_csl_full) { \
195 .csl_phase = sys_cpu_to_le16(_csl_phase), \
196 .csl_period = sys_cpu_to_le16(_csl_period), \
197 .csl_rendezvous_time = sys_cpu_to_le16(_csl_rendezvous_time), \
200#define IEEE802154_HEADER_IE_TIME_CORRECTION_NACK 0x8000
201#define IEEE802154_HEADER_IE_TIME_CORRECTION_MASK 0x0fff
202#define IEEE802154_HEADER_IE_TIME_CORRECTION_SIGN_BIT_MASK 0x0800
204#define IEEE802154_DEFINE_HEADER_IE_TIME_CORRECTION_CONTENT(_ack, _time_correction_us) \
205 (struct ieee802154_header_ie_time_correction) { \
206 .time_sync_info = sys_cpu_to_le16( \
207 (!(_ack) * IEEE802154_HEADER_IE_TIME_CORRECTION_NACK) | \
208 ((_time_correction_us) & IEEE802154_HEADER_IE_TIME_CORRECTION_MASK)), \
230#define IEEE802154_DEFINE_HEADER_IE_VENDOR_SPECIFIC(_vendor_oui, _vendor_specific_info, \
231 _vendor_specific_info_len) \
232 IEEE802154_DEFINE_HEADER_IE(IEEE802154_HEADER_IE_ELEMENT_ID_VENDOR_SPECIFIC_IE, \
233 IEEE802154_DEFINE_HEADER_IE_VENDOR_SPECIFIC_CONTENT_LEN( \
234 _vendor_specific_info_len), \
235 IEEE802154_DEFINE_HEADER_IE_VENDOR_SPECIFIC_CONTENT( \
236 _vendor_oui, _vendor_specific_info), \
254#define IEEE802154_DEFINE_HEADER_IE_CSL_REDUCED(_csl_phase, _csl_period) \
255 IEEE802154_DEFINE_HEADER_IE( \
256 IEEE802154_HEADER_IE_ELEMENT_ID_CSL_IE, \
257 sizeof(struct ieee802154_header_ie_csl_reduced), \
258 IEEE802154_DEFINE_HEADER_IE_CSL_REDUCED_CONTENT(_csl_phase, _csl_period), \
278#define IEEE802154_DEFINE_HEADER_IE_CSL_FULL(_csl_phase, _csl_period, _csl_rendezvous_time) \
279 IEEE802154_DEFINE_HEADER_IE(IEEE802154_HEADER_IE_ELEMENT_ID_CSL_IE, \
280 sizeof(struct ieee802154_header_ie_csl_full), \
281 IEEE802154_DEFINE_HEADER_IE_CSL_FULL_CONTENT( \
282 _csl_phase, _csl_period, _csl_rendezvous_time), \
301#define IEEE802154_DEFINE_HEADER_IE_TIME_CORRECTION(_ack, _time_correction_us) \
302 IEEE802154_DEFINE_HEADER_IE( \
303 IEEE802154_HEADER_IE_ELEMENT_ID_TIME_CORRECTION_IE, \
304 sizeof(struct ieee802154_header_ie_time_correction), \
305 IEEE802154_DEFINE_HEADER_IE_TIME_CORRECTION_CONTENT(_ack, _time_correction_us), \
319 if (ie->
time_sync_info & IEEE802154_HEADER_IE_TIME_CORRECTION_SIGN_BIT_MASK) {
337 ie->element_id_high = element_id >> 1U;
338 ie->element_id_low = element_id & 0x01;
350 return (ie->element_id_high << 1U) | ie->element_id_low;
354#define IEEE802154_TIME_CORRECTION_HEADER_IE_LEN \
355 (IEEE802154_HEADER_IE_HEADER_LENGTH + sizeof(struct ieee802154_header_ie_time_correction))
358#define IEEE802154_HEADER_TERMINATION_1_HEADER_IE_LEN IEEE802154_HEADER_IE_HEADER_LENGTH
ieee802154_header_ie_element_id
Header Information Element IDs.
Definition: ieee802154_ie.h:53
ieee802154_ie_type
Information Element Types.
Definition: ieee802154_ie.h:42
static int16_t ieee802154_header_ie_get_time_correction_us(struct ieee802154_header_ie_time_correction *ie)
Retrieve the time correction value in microseconds from a Time Correction IE, see section 7....
Definition: ieee802154_ie.h:317
static uint8_t ieee802154_header_ie_get_element_id(struct ieee802154_header_ie *ie)
Get the element ID of a header IE.
Definition: ieee802154_ie.h:348
static void ieee802154_header_ie_set_element_id(struct ieee802154_header_ie *ie, uint8_t element_id)
Set the element ID of a header IE.
Definition: ieee802154_ie.h:334
@ IEEE802154_HEADER_IE_ELEMENT_ID_RENDEZVOUS_TIME_IE
Rendezvous time IE.
Definition: ieee802154_ie.h:57
@ IEEE802154_HEADER_IE_ELEMENT_ID_TIME_CORRECTION_IE
Time correction IE.
Definition: ieee802154_ie.h:58
@ IEEE802154_HEADER_IE_ELEMENT_ID_HEADER_TERMINATION_1
Header termination 1.
Definition: ieee802154_ie.h:59
@ IEEE802154_HEADER_IE_ELEMENT_ID_CSL_IE
CSL IE.
Definition: ieee802154_ie.h:55
@ IEEE802154_HEADER_IE_ELEMENT_ID_HEADER_TERMINATION_2
Header termination 2.
Definition: ieee802154_ie.h:60
@ IEEE802154_HEADER_IE_ELEMENT_ID_VENDOR_SPECIFIC_IE
Vendor specific IE.
Definition: ieee802154_ie.h:54
@ IEEE802154_HEADER_IE_ELEMENT_ID_RIT_IE
RIT IE.
Definition: ieee802154_ie.h:56
@ IEEE802154_IE_TYPE_HEADER
Header type.
Definition: ieee802154_ie.h:43
@ IEEE802154_IE_TYPE_PAYLOAD
Payload type.
Definition: ieee802154_ie.h:44
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
__INT16_TYPE__ int16_t
Definition: stdint.h:73