pub unsafe extern "C" fn ieee802154_set_frame_hdr(
buf: *mut u8,
src: *const u8,
src_len: size_t,
dst: *const u8,
dst_len: size_t,
src_pan: le_uint16_t,
dst_pan: le_uint16_t,
flags: u8,
seq: u8,
) -> size_t
Expand description
@brief Initializes an IEEE 802.15.4 MAC frame header in @p buf.
@pre Resulting header must fit in memory allocated at @p buf.
@see IEEE Std 802.15.4-2011, 5.2.1 General MAC frame format.
If @p dst is NULL the IEEE802154_FCF_ACK_REQ will be unset to prevent flooding the network.
@param[out] buf Target memory for frame header. @param[in] src Source address for frame in network byteorder. May be NULL if @ref IEEE802154_FCF_SRC_ADDR_VOID is set in @p flags. @param[in] src_len Length of @p src. Legal values are: * 0 (will set @ref IEEE802154_FCF_SRC_ADDR_VOID in MHR) * 2 (will set @ref IEEE802154_FCF_SRC_ADDR_SHORT in MHR) * 8 (will set @ref IEEE802154_FCF_SRC_ADDR_LONG in MHR) @param[in] dst Destination address for frame in network byteorder. May be NULL if @ref IEEE802154_FCF_SRC_ADDR_VOID is set in @p flags. @param[in] dst_len Length of @p dst. Legal values are: * 0 (will set @ref IEEE802154_FCF_DST_ADDR_VOID in MHR) * 2 (will set @ref IEEE802154_FCF_DST_ADDR_SHORT in MHR) * 8 (will set @ref IEEE802154_FCF_DST_ADDR_LONG in MHR) @param[in] src_pan Source PAN ID in little-endian. May be 0 if @ref IEEE802154_FCF_PAN_COMP is set in @p flags. Otherwise, it will be ignored, when @ref IEEE802154_FCF_PAN_COMP is set. @param[in] dst_pan Destination PAN ID in little-endian. @param[in] flags Flags for the frame. These are interchangeable with the first byte of the IEEE 802.15.4 FCF. This means that it encompasses the type values, @ref IEEE802154_FCF_SECURITY_EN, @ref IEEE802154_FCF_FRAME_PEND, and @ref IEEE802154_FCF_ACK_REQ. @param[in] seq Sequence number for frame.
The version field in the FCF will be set implicitly to version 1.
@return Size of frame header on success. @return 0, on error (flags set to unexpected state).