class Frame

Defined at line 61 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

Implements IEEE 802.15.4 MAC frame generation and parsing.

Public Members

static const uint16_t kInfoStringSize
static const uint8_t kPreambleSize
static const uint8_t kSfdSize
static const uint8_t kPhrSize
static const uint8_t kPhyHeaderSize
static const uint8_t kFcfSize
static const uint8_t kDsnSize
static const uint8_t k154FcsSize
static const uint8_t kImmAckLength

Protected Members

static const uint8_t kSecurityControlSize
static const uint8_t kFrameCounterSize
static const uint8_t kCommandIdSize
static const uint8_t kKeyIndexSize
static const uint16_t kFcfFrameTypeMask
static const uint16_t kFcfAddrNone
static const uint16_t kFcfAddrShort
static const uint16_t kFcfAddrExt
static const uint16_t kFcfAddrMask
static const uint16_t kFcfSecurityEnabled
static const uint16_t kFcfFramePending
static const uint16_t kFcfAckRequest
static const uint16_t kFcfPanidCompression
static const uint16_t kFcfSequenceSuppression
static const uint16_t kFcfIePresent
static const uint16_t kFcfDstAddrShift
static const uint16_t kFcfDstAddrNone
static const uint16_t kFcfDstAddrShort
static const uint16_t kFcfDstAddrExt
static const uint16_t kFcfDstAddrMask
static const uint16_t kFcfFrameVersionMask
static const uint16_t kFcfSrcAddrShift
static const uint16_t kFcfSrcAddrNone
static const uint16_t kFcfSrcAddrShort
static const uint16_t kFcfSrcAddrExt
static const uint16_t kFcfSrcAddrMask
static const uint8_t kSecLevelMask
static const uint8_t kKeyIdModeMask
static const uint8_t kMic0Size
static const uint8_t kMic32Size
static const uint8_t kMic64Size
static const uint8_t kMic128Size
static const uint8_t kMaxMicSize
static const uint8_t kKeySourceSizeMode0
static const uint8_t kKeySourceSizeMode1
static const uint8_t kKeySourceSizeMode2
static const uint8_t kKeySourceSizeMode3
static const uint8_t kInvalidIndex
static const uint8_t kInvalidSize
static const uint8_t kMaxPsduSize

Public Methods

uint8_t GetChannel ()

Returns the IEEE 802.15.4 channel used for transmission or reception.

Defined at line 509 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

const uint8_t * GetPsdu ()

Returns a pointer to the PSDU.

Defined at line 523 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

uint8_t * GetHeader ()

Returns a pointer to the MAC Header.

Defined at line 530 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

const uint8_t * GetHeader ()

Returns a pointer to the MAC Header.

Defined at line 537 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

uint8_t * GetPayload ()

Returns a pointer to the MAC Payload.

Defined at line 544 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

uint8_t * GetFooter ()

Returns a pointer to the MAC Footer.

Defined at line 558 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

template <typename IeType>
const IeType * Find ()

Finds a specific Information Element (IE) in the frame.

This method searches the frame for a Header IE matching the Element ID of

and also validates that

the content of the IE is well-formed according to

Template Parameters

IeType The IE subclass type to find.

Defined at line 586 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

template <typename IeType>
IeType * Find ()

Finds a specific Information Element (IE) in the frame.

This method searches the frame for a Header IE matching the Element ID of

and also validates that

the content of the IE is well-formed according to

Template Parameters

IeType The IE subclass type to find.

Defined at line 601 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

uint16_t GetFrameControlField ()

Returns the Frame Control field of the frame.

Defined at line 694 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

uint8_t GetSequence ()

Returns the Sequence Number value.

Error GetDstPanId (PanId & aPanId)

Gets the Destination PAN Identifier.

Parameters

aPanId [out] The Destination PAN Identifier.
Error GetDstAddr (Address & aAddress)

Gets the Destination Address.

Parameters

aAddress [out] The Destination Address.
Error GetSrcPanId (PanId & aPanId)

Gets the Source PAN Identifier.

Parameters

aPanId [out] The Source PAN Identifier.
Error GetSrcAddr (Address & aAddress)

Gets the Source Address.

Parameters

aAddress [out] The Source Address.
Error GetSecurityControlField (uint8_t & aSecurityControlField)

Gets the Security Control Field.

Parameters

aSecurityControlField [out] The Security Control Field.
Error GetSecurityLevel (uint8_t & aSecurityLevel)

Gets the Security Level Identifier.

Parameters

aSecurityLevel [out] The Security Level Identifier.
Error GetKeyIdMode (uint8_t & aKeyIdMode)

Gets the Key Identifier Mode.

Parameters

aKeyIdMode [out] The Key Identifier Mode.
Error GetFrameCounter (uint32_t & aFrameCounter)

Gets the Frame Counter.

Parameters

aFrameCounter [out] The Frame Counter.
const uint8_t * GetPayload ()

Returns a pointer to the MAC Payload.

const uint8_t * GetFooter ()

Returns a pointer to the MAC Footer.

uint16_t GetMtu ()

Returns the maximum transmission unit size (MTU).

uint8_t GetFcsSize ()

Returns the FCS size.

bool IsEmpty ()

Indicates whether the frame is empty (no payload).

Defined at line 158 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

uint8_t GetType ()

Returns the IEEE 802.15.4 Frame Type.

Defined at line 173 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsAck ()

Returns whether the frame is an Ack frame.

Defined at line 181 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsMacCommand ()

Returns whether the frame is a MAC Command frame.

Defined at line 189 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

uint16_t GetVersion ()

Returns the IEEE 802.15.4 Frame Version.

Defined at line 206 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsVersion2015 ()

Returns if this IEEE 802.15.4 frame's version is 2015.

Defined at line 213 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool GetSecurityEnabled ()

Indicates whether or not security is enabled.

Defined at line 221 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool GetFramePending ()

Indicates whether or not the Frame Pending bit is set.

Defined at line 229 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

void SetFramePending (bool aFramePending)

Sets the Frame Pending bit.

Parameters

aFramePending [in] The Frame Pending bit.

Defined at line 236 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool GetAckRequest ()

Indicates whether or not the Ack Request bit is set.

Defined at line 244 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

void SetAckRequest (bool aAckRequest)

Sets the Ack Request bit.

Parameters

aAckRequest [in] The Ack Request bit.

Defined at line 251 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsPanIdCompressed ()

Indicates whether or not the PanId Compression bit is set.

Defined at line 259 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsIePresent ()

Indicates whether or not IEs present.

Defined at line 267 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

void SetIePresent (bool aIePresent)

Sets the IE Present bit.

Parameters

aIePresent [in] The IE Present bit.

Defined at line 274 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

uint8_t IsSequencePresent ()

Indicates whether or not the Sequence Number is present.

Defined at line 295 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsDstPanIdPresent ()

Indicates whether or not the Destination PAN ID is present.

Defined at line 302 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsDstAddrPresent ()

Indicates whether or not the Destination Address is present for this object.

Defined at line 320 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsSrcPanIdPresent ()

Indicates whether or not the Source Address is present for this object.

Defined at line 337 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsSrcAddrPresent ()

Indicates whether or not the Source Address is present for this object.

Defined at line 354 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool HasAnyHeaderIe ()

Indicates whether the frame contains header IEs.

Defined at line 574 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

template <typename IeType>
bool Has ()

Indicates whether or not the frame contains a specific Information Element (IE).

This method checks whether the frame contains a Header IE matching the Element ID of

with valid

content according to

Template Parameters

IeType The IE subclass type to check.

Defined at line 614 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

RadioType GetRadioType ()

Gets the radio link type of the frame.

Defined at line 644 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

void SetRadioType (RadioType aRadioType)

Sets the radio link type of the frame.

Parameters

aRadioType [in] A radio link type.

Defined at line 651 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

Error ValidatePsdu ()

Validates the frame.

void SetSequence (uint8_t aSequence)

Sets the Sequence Number value.

Parameters

aSequence [in] The Sequence Number value.
void SetFrameCounter (uint32_t aFrameCounter)

Sets the Frame Counter.

Parameters

aFrameCounter [in] The Frame Counter.
const uint8_t * GetKeySource ()

Returns a pointer to the Key Source.

void SetKeySource (const uint8_t * aKeySource)

Sets the Key Source.

Parameters

aKeySource [in] A pointer to the Key Source value.
Error GetKeyId (uint8_t & aKeyId)

Gets the Key Identifier.

Parameters

aKeyId [out] The Key Identifier.
void SetKeyId (uint8_t aKeyId)

Sets the Key Identifier.

Parameters

aKeyId [in] The Key Identifier.
Error GetCommandId (uint8_t & aCommandId)

Gets the Command ID.

Parameters

aCommandId [out] The Command ID.
bool IsDataRequestCommand ()

Indicates whether the frame is a MAC Data Request command (data poll).

For 802.15.4-2015 and above frame, the frame should be already decrypted.

uint8_t GetHeaderLength ()

Returns the MAC header size.

uint8_t GetFooterLength ()

Returns the MAC footer size.

uint16_t GetLength ()

Returns the MAC Frame Length, namely the IEEE 802.15.4 PSDU length.

Defined at line 462 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

uint16_t GetPayloadLength ()

Returns the current MAC Payload length.

uint16_t GetMaxPayloadLength ()

Returns the maximum MAC Payload length for the given MAC header and footer.

void SetLength (uint16_t aLength)

Sets the MAC Frame Length.

Parameters

aLength [in] The MAC Frame Length.

Defined at line 469 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

uint8_t * GetPsdu ()

Returns a pointer to the PSDU.

Defined at line 516 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

void SetPayloadLength (uint16_t aLength)

Sets the MAC Payload length.

void UpdateEnhAckProbingIe (const uint8_t * aData, uint8_t aLen)

Finds Enhanced ACK Probing (Vendor Specific) IE and updates its Link Metrics Data content.

Parameters

aData [in] A pointer to the data to write.
aLen [in] The length of
InfoString ToInfoString ()

Returns information about the frame object as an `InfoString` object.

Protected Methods

uint8_t FindSrcPanIdIndex ()
uint8_t FindSrcAddrIndex ()
void SetFrameControlField (uint16_t aFcf)

Defined at line 746 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsSecurityEnabled (uint16_t aFcf)

Defined at line 766 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsFramePending (uint16_t aFcf)

Defined at line 767 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsIePresent (uint16_t aFcf)

Defined at line 768 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsAckRequest (uint16_t aFcf)

Defined at line 769 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

void UpdateFcfFlag (bool aSet, uint16_t aBitFlag)
uint8_t SkipSequenceIndex ()
uint8_t FindDstPanIdIndex ()
uint8_t FindDstAddrIndex ()
uint8_t SkipAddrFieldIndex ()
uint8_t FindSecurityHeaderIndex ()
uint8_t SkipSecurityHeaderIndex ()
uint8_t FindPayloadIndex ()
uint8_t FindHeaderIeIndex ()
uint16_t GetFcfDstAddr (uint16_t aFcf)

Defined at line 761 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

uint16_t GetFcfSrcAddr (uint16_t aFcf)

Defined at line 762 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsDstPanIdPresent (uint16_t aFcf)
bool IsSequencePresent (uint16_t aFcf)

Defined at line 763 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsDstAddrPresent (uint16_t aFcf)

Defined at line 764 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsSrcAddrPresent (uint16_t aFcf)

Defined at line 765 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

bool IsSrcPanIdPresent (uint16_t aFcf)
uint16_t DetermineFcfAddrType (const Address & aAddress, uint16_t aBitShift)
uint8_t CalculateAddrFieldSize (uint16_t aFcf)
uint8_t CalculateSecurityHeaderSize (uint8_t aSecurityControl)
uint8_t CalculateKeySourceSize (uint8_t aSecurityControl)
uint8_t CalculateMicSize (uint8_t aSecurityControl)
bool IsVersion2015 (uint16_t aFcf)

Defined at line 770 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

Enumerations

enum Type : uint16_t
Name Value Comments
kTypeBeacon 0

Beacon Frame Type.

kTypeData 1

Data Frame Type.

kTypeAck 2

Ack Frame Type.

kTypeMacCmd 3

MAC Command Frame Type.

kTypeMultipurpose 5

Multipurpose Frame Type.

Represents the MAC frame type.

Values match the Frame Type field in Frame Control Field (FCF) as an `uint16_t`.

Defined at line 69 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

enum Version : uint16_t
Name Value Comments
kVersion2003 0 << 12

2003 Frame Version.

kVersion2006 1 << 12

2006 Frame Version.

kVersion2015 2 << 12

2015 Frame Version.

Represents the MAC frame version.

Values match the Version field in Frame Control Field (FCF) as an `uint16_t`.

Defined at line 83 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

enum SecurityLevel : uint8_t
Name Value Comments
kSecurityNone 0

No security.

kSecurityMic32 1

No encryption, MIC-32 authentication.

kSecurityMic64 2

No encryption, MIC-64 authentication.

kSecurityMic128 3

No encryption, MIC-128 authentication.

kSecurityEnc 4

Encryption, no authentication

kSecurityEncMic32 5

Encryption with MIC-32 authentication.

kSecurityEncMic64 6

Encryption with MIC-64 authentication.

kSecurityEncMic128 7

Encryption with MIC-128 authentication.

Represents the MAC frame security level.

Values match the Security Level field in Security Control Field as an `uint8_t`.

Defined at line 95 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

enum KeyIdMode : uint8_t
Name Value Comments
kKeyIdMode0 0 << 3

Key ID Mode 0 - Key is determined implicitly.

kKeyIdMode1 1 << 3

Key ID Mode 1 - Key is determined from Key Index field.

kKeyIdMode2 2 << 3

Key ID Mode 2 - Key is determined from 4-bytes Key Source and Index fields.

kKeyIdMode3 3 << 3

Key ID Mode 3 - Key is determined from 8-bytes Key Source and Index fields.

Represents the MAC frame security key identifier mode.

Values match the Key Identifier Mode field in Security Control Field as an `uint8_t`.

Defined at line 112 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp

enum CommandId : uint8_t
Name Value
kMacCmdAssociationRequest 1
kMacCmdAssociationResponse 2
kMacCmdDisassociationNotification 3
kMacCmdDataRequest 4
kMacCmdPanidConflictNotification 5
kMacCmdOrphanNotification 6
kMacCmdBeaconRequest 7
kMacCmdCoordinatorRealignment 8
kMacCmdGtsRequest 9

Represents a subset of MAC Command Identifiers.

Defined at line 123 of file ../../third_party/openthread/src/core/mac/mac_frame.hpp