0.01.00
ot::Message Class Reference

This class represents a message. More...

#include <src/core/common/message.hpp>

Inheritance diagram for ot::Message:
ot::Buffer otMessage

Public Types

enum  {
  kTypeIp6 = 0,
  kType6lowpan = 1,
  kTypeMacDataPoll = 2,
  kTypeSupervision = 3
}
 
enum  {
  kSubTypeNone = 0,
  kSubTypeMleAnnounce = 1,
  kSubTypeMleDiscoverRequest = 2,
  kSubTypeMleDiscoverResponse = 3,
  kSubTypeJoinerEntrust = 4,
  kSubTypeMplRetransmission = 5,
  kSubTypeMleGeneral = 6,
  kSubTypeJoinerFinalizeResponse = 7,
  kSubTypeMleChildUpdateRequest = 8
}
 
enum  {
  kPriorityHigh = 0,
  kPriorityMedium = 1,
  kPriorityLow = 2,
  kPriorityVeryLow = 3,
  kNumPriorities = 4
}
 

Public Member Functions

void Free (void)
 This method frees this message buffer.
 
MessageGetNext (void) const
 This method returns a pointer to the next message in the same interface list. More...
 
uint16_t GetLength (void) const
 This method returns the number of bytes in the message. More...
 
otError SetLength (uint16_t aLength)
 This method sets the number of bytes in the message. More...
 
uint8_t GetBufferCount (void) const
 This method returns the number of buffers in the message.
 
uint16_t GetOffset (void) const
 This method returns the byte offset within the message. More...
 
otError MoveOffset (int aDelta)
 This method moves the byte offset within the message. More...
 
otError SetOffset (uint16_t aOffset)
 This method sets the byte offset within the message. More...
 
uint8_t GetType (void) const
 This method returns the type of the message. More...
 
void SetType (uint8_t aType)
 This method sets the message type. More...
 
uint8_t GetSubType (void) const
 This method returns the sub type of the message. More...
 
void SetSubType (uint8_t aSubType)
 This method sets the message sub type. More...
 
bool IsSubTypeMle (void) const
 This method returns whether or not the message is of MLE subtype. More...
 
uint8_t GetPriority (void) const
 This method returns the message priority level. More...
 
otError SetPriority (uint8_t aPriority)
 This method sets the messages priority. More...
 
otError Prepend (const void *aBuf, uint16_t aLength)
 This method prepends bytes to the front of the message. More...
 
otError RemoveHeader (uint16_t aLength)
 This method removes header bytes from the message. More...
 
otError Append (const void *aBuf, uint16_t aLength)
 This method appends bytes to the end of the message. More...
 
uint16_t Read (uint16_t aOffset, uint16_t aLength, void *aBuf) const
 This method reads bytes from the message. More...
 
int Write (uint16_t aOffset, uint16_t aLength, const void *aBuf)
 This method writes bytes to the message. More...
 
int CopyTo (uint16_t aSourceOffset, uint16_t aDestinationOffset, uint16_t aLength, Message &aMessage) const
 This method copies bytes from one message to another. More...
 
MessageClone (uint16_t aLength) const
 This method creates a copy of the current Message. More...
 
MessageClone (void) const
 This method creates a copy of the current Message. More...
 
uint16_t GetDatagramTag (void) const
 This method returns the datagram tag used for 6LoWPAN fragmentation. More...
 
void SetDatagramTag (uint16_t aTag)
 This method sets the datagram tag used for 6LoWPAN fragmentation. More...
 
bool GetChildMask (uint8_t aChildIndex) const
 This method returns whether or not the message forwarding is scheduled for the child. More...
 
void ClearChildMask (uint8_t aChildIndex)
 This method unschedules forwarding of the message to the child. More...
 
void SetChildMask (uint8_t aChildIndex)
 This method schedules forwarding of the message to the child. More...
 
bool IsChildPending (void) const
 This method returns whether or not the message forwarding is scheduled for at least one child. More...
 
uint16_t GetPanId (void) const
 This method returns the IEEE 802.15.4 Destination PAN ID. More...
 
void SetPanId (uint16_t aPanId)
 This method sets the IEEE 802.15.4 Destination PAN ID. More...
 
uint8_t GetChannel (void) const
 This method returns the IEEE 802.15.4 Channel to use for transmission. More...
 
void SetChannel (uint8_t aChannel)
 This method sets the IEEE 802.15.4 Channel to use for transmission. More...
 
uint8_t GetTimeout (void) const
 This method returns the timeout used for 6LoWPAN reassembly. More...
 
void SetTimeout (uint8_t aTimeout)
 This method sets the timeout used for 6LoWPAN reassembly. More...
 
int8_t GetInterfaceId (void) const
 This method returns the interface ID. More...
 
void SetInterfaceId (int8_t aInterfaceId)
 This method sets the interface ID. More...
 
bool GetDirectTransmission (void) const
 This method returns whether or not message forwarding is scheduled for direct transmission. More...
 
void ClearDirectTransmission (void)
 This method unschedules forwarding using direct transmission.
 
void SetDirectTransmission (void)
 This method schedules forwarding using direct transmission.
 
bool IsLinkSecurityEnabled (void) const
 This method indicates whether or not link security is enabled for the message. More...
 
void SetLinkSecurityEnabled (bool aEnabled)
 This method sets whether or not link security is enabled for the message. More...
 
void AddRss (int8_t aRss)
 This method updates the average RSS (Received Signal Strength) associated with the message by adding the given RSS value to the average. More...
 
int8_t GetAverageRss (void) const
 This method returns the average RSS (Received Signal Strength) associated with the message. More...
 
const RssAveragerGetRssAverager (void) const
 This method returns a const reference to RssAverager of the message. More...
 
uint16_t UpdateChecksum (uint16_t aChecksum, uint16_t aOffset, uint16_t aLength) const
 This method is used to update a checksum value. More...
 
MessageQueueGetMessageQueue (void) const
 This method returns a pointer to the message queue (if any) where this message is queued. More...
 
- Public Member Functions inherited from ot::Buffer
class BufferGetNextBuffer (void) const
 This method returns a pointer to the next message buffer. More...
 
void SetNextBuffer (class Buffer *buf)
 This method sets the pointer to the next message buffer.
 

Static Public Member Functions

static uint16_t UpdateChecksum (uint16_t aChecksum, uint16_t aValue)
 This static method updates a checksum. More...
 
static uint16_t UpdateChecksum (uint16_t aChecksum, const void *aBuf, uint16_t aLength)
 This static method updates a checksum. More...
 

Friends

class MessagePool
 
class MessageQueue
 
class PriorityQueue
 

Additional Inherited Members

- Public Attributes inherited from otMessage
struct otMessagemNext
 A pointer to the next Message buffer.
 

Detailed Description

This class represents a message.

Member Enumeration Documentation

§ anonymous enum

anonymous enum
Enumerator
kTypeIp6 

A full uncompressed IPv6 packet.

kType6lowpan 

A 6lowpan frame.

kTypeMacDataPoll 

A MAC data poll message.

kTypeSupervision 

A child supervision frame.

§ anonymous enum

anonymous enum
Enumerator
kSubTypeNone 

None.

kSubTypeMleAnnounce 

MLE Announce.

kSubTypeMleDiscoverRequest 

MLE Discover Request.

kSubTypeMleDiscoverResponse 

MLE Discover Response.

kSubTypeJoinerEntrust 

Joiner Entrust.

kSubTypeMplRetransmission 

MPL next retransmission message.

kSubTypeMleGeneral 

General MLE.

kSubTypeJoinerFinalizeResponse 

Joiner Finalize Response.

kSubTypeMleChildUpdateRequest 

MLE Child Update Request.

§ anonymous enum

anonymous enum
Enumerator
kPriorityHigh 

High priority level.

kPriorityMedium 

Medium priority level.

kPriorityLow 

Low priority level.

kPriorityVeryLow 

Very low priority level.

kNumPriorities 

Number of priority levels.

Member Function Documentation

§ AddRss()

void ot::Message::AddRss ( int8_t  aRss)
inline

This method updates the average RSS (Received Signal Strength) associated with the message by adding the given RSS value to the average.

Note that a message can be composed of multiple 802.15.4 data frame fragments each received with a different signal strength.

Parameters
[in]aRssA new RSS value (in dBm) to be added to average.

§ Append()

otError ot::Message::Append ( const void *  aBuf,
uint16_t  aLength 
)

This method appends bytes to the end of the message.

On success, this method grows the message by aLength bytes.

Parameters
[in]aBufA pointer to a data buffer.
[in]aLengthThe number of bytes to append.
Return values
OT_ERROR_NONESuccessfully appended the bytes.
OT_ERROR_NO_BUFSInsufficient available buffers to grow the message.

§ ClearChildMask()

void ot::Message::ClearChildMask ( uint8_t  aChildIndex)

This method unschedules forwarding of the message to the child.

Parameters
[in]aChildIndexThe index into the child table.

§ Clone() [1/2]

Message * ot::Message::Clone ( uint16_t  aLength) const

This method creates a copy of the current Message.

It allocates the new one from the same Message Poll as the original Message and copies aLength octets of a payload.

The Type, SubType, LinkSecurity and Priority fields on the cloned message are also copied from the original one.

Parameters
[in]aLengthNumber of payload bytes to copy.
Returns
A pointer to the message or NULL if insufficient message buffers are available.

§ Clone() [2/2]

Message* ot::Message::Clone ( void  ) const
inline

This method creates a copy of the current Message.

It allocates the new one from the same Message Poll as the original Message and copies a full payload.

Returns
A pointer to the message or NULL if insufficient message buffers are available.

§ CopyTo()

int ot::Message::CopyTo ( uint16_t  aSourceOffset,
uint16_t  aDestinationOffset,
uint16_t  aLength,
Message aMessage 
) const

This method copies bytes from one message to another.

Parameters
[in]aSourceOffsetByte offset within the source message to begin reading.
[in]aDestinationOffsetByte offset within the destination message to begin writing.
[in]aLengthNumber of bytes to copy.
[in]aMessageMessage to copy to.
Returns
The number of bytes copied.

§ GetAverageRss()

int8_t ot::Message::GetAverageRss ( void  ) const
inline

This method returns the average RSS (Received Signal Strength) associated with the message.

Returns
The current average RSS value (in dBm) or OT_RADIO_RSSI_INVALID if no average is available.

§ GetChannel()

uint8_t ot::Message::GetChannel ( void  ) const
inline

This method returns the IEEE 802.15.4 Channel to use for transmission.

Note
Only use this when sending MLE Announce messages.
Returns
The IEEE 802.15.4 Channel to use for transmission.

§ GetChildMask()

bool ot::Message::GetChildMask ( uint8_t  aChildIndex) const

This method returns whether or not the message forwarding is scheduled for the child.

Parameters
[in]aChildIndexThe index into the child table.
Return values
TRUEIf the message is scheduled to be forwarded to the child.
FALSEIf the message is not scheduled to be forwarded to the child.

§ GetDatagramTag()

uint16_t ot::Message::GetDatagramTag ( void  ) const
inline

This method returns the datagram tag used for 6LoWPAN fragmentation.

Returns
The 6LoWPAN datagram tag.

§ GetDirectTransmission()

bool ot::Message::GetDirectTransmission ( void  ) const
inline

This method returns whether or not message forwarding is scheduled for direct transmission.

Return values
TRUEIf message forwarding is scheduled for direct transmission.
FALSEIf message forwarding is not scheduled for direct transmission.

§ GetInterfaceId()

int8_t ot::Message::GetInterfaceId ( void  ) const
inline

This method returns the interface ID.

Returns
The interface ID.

§ GetLength()

uint16_t ot::Message::GetLength ( void  ) const
inline

This method returns the number of bytes in the message.

Returns
The number of bytes in the message.

§ GetMessageQueue()

MessageQueue* ot::Message::GetMessageQueue ( void  ) const
inline

This method returns a pointer to the message queue (if any) where this message is queued.

Returns
A pointer to the message queue or NULL if not in any message queue.

§ GetNext()

Message * ot::Message::GetNext ( void  ) const

This method returns a pointer to the next message in the same interface list.

Returns
A pointer to the next message in the same interface list or NULL if at the end of the list.

§ GetOffset()

uint16_t ot::Message::GetOffset ( void  ) const
inline

This method returns the byte offset within the message.

Returns
A byte offset within the message.

§ GetPanId()

uint16_t ot::Message::GetPanId ( void  ) const
inline

This method returns the IEEE 802.15.4 Destination PAN ID.

Note
Only use this when sending MLE Discover Request or Response messages.
Returns
The IEEE 802.15.4 Destination PAN ID.

§ GetPriority()

uint8_t ot::Message::GetPriority ( void  ) const
inline

This method returns the message priority level.

Returns
The priority level associated with this message.

§ GetRssAverager()

const RssAverager& ot::Message::GetRssAverager ( void  ) const
inline

This method returns a const reference to RssAverager of the message.

Returns
A const reference to the RssAverager of the message.

§ GetSubType()

uint8_t ot::Message::GetSubType ( void  ) const
inline

This method returns the sub type of the message.

Returns
The sub type of the message.

§ GetTimeout()

uint8_t ot::Message::GetTimeout ( void  ) const
inline

This method returns the timeout used for 6LoWPAN reassembly.

Returns
The time remaining in seconds.

§ GetType()

uint8_t ot::Message::GetType ( void  ) const
inline

This method returns the type of the message.

Returns
The type of the message.

§ IsChildPending()

bool ot::Message::IsChildPending ( void  ) const

This method returns whether or not the message forwarding is scheduled for at least one child.

Return values
TRUEIf message forwarding is scheduled for at least one child.
FALSEIf message forwarding is not scheduled for any child.

§ IsLinkSecurityEnabled()

bool ot::Message::IsLinkSecurityEnabled ( void  ) const
inline

This method indicates whether or not link security is enabled for the message.

Return values
TRUEIf link security is enabled.
FALSEIf link security is not enabled.

§ IsSubTypeMle()

bool ot::Message::IsSubTypeMle ( void  ) const

This method returns whether or not the message is of MLE subtype.

Return values
TRUEIf message is of MLE subtype.
FLASEIf message is not of MLE subtype.

§ MoveOffset()

otError ot::Message::MoveOffset ( int  aDelta)

This method moves the byte offset within the message.

Parameters
[in]aDeltaThe number of bytes to move the current offset, which may be positive or negative.
Return values
OT_ERROR_NONESuccessfully moved the byte offset.
OT_ERROR_INVALID_ARGSThe resulting byte offset is not within the existing message.

§ Prepend()

otError ot::Message::Prepend ( const void *  aBuf,
uint16_t  aLength 
)

This method prepends bytes to the front of the message.

On success, this method grows the message by aLength bytes.

Parameters
[in]aBufA pointer to a data buffer.
[in]aLengthThe number of bytes to prepend.
Return values
OT_ERROR_NONESuccessfully prepended the bytes.
OT_ERROR_NO_BUFSNot enough reserved bytes in the message.

§ Read()

uint16_t ot::Message::Read ( uint16_t  aOffset,
uint16_t  aLength,
void *  aBuf 
) const

This method reads bytes from the message.

Parameters
[in]aOffsetByte offset within the message to begin reading.
[in]aLengthNumber of bytes to read.
[in]aBufA pointer to a data buffer.
Returns
The number of bytes read.

§ RemoveHeader()

otError ot::Message::RemoveHeader ( uint16_t  aLength)

This method removes header bytes from the message.

Parameters
[in]aLengthNumber of header bytes to remove.
Return values
OT_ERROR_NONESuccessfully removed header bytes from the message.

§ SetChannel()

void ot::Message::SetChannel ( uint8_t  aChannel)
inline

This method sets the IEEE 802.15.4 Channel to use for transmission.

Note
Only use this when sending MLE Announce messages.
Parameters
[in]aChannelThe IEEE 802.15.4 Channel to use for transmission.

§ SetChildMask()

void ot::Message::SetChildMask ( uint8_t  aChildIndex)

This method schedules forwarding of the message to the child.

Parameters
[in]aChildIndexThe index into the child table.

§ SetDatagramTag()

void ot::Message::SetDatagramTag ( uint16_t  aTag)
inline

This method sets the datagram tag used for 6LoWPAN fragmentation.

Parameters
[in]aTagThe 6LoWPAN datagram tag.

§ SetInterfaceId()

void ot::Message::SetInterfaceId ( int8_t  aInterfaceId)
inline

This method sets the interface ID.

Parameters
[in]aInterfaceIdThe interface ID value.

§ SetLength()

otError ot::Message::SetLength ( uint16_t  aLength)

This method sets the number of bytes in the message.

Parameters
[in]aLengthRequested number of bytes in the message.
Return values
OT_ERROR_NONESuccessfully set the length of the message.
OT_ERROR_NO_BUFSFailed to grow the size of the message because insufficient buffers were available.

§ SetLinkSecurityEnabled()

void ot::Message::SetLinkSecurityEnabled ( bool  aEnabled)
inline

This method sets whether or not link security is enabled for the message.

Parameters
[in]aEnabledTRUE if link security is enabled, FALSE otherwise.

§ SetOffset()

otError ot::Message::SetOffset ( uint16_t  aOffset)

This method sets the byte offset within the message.

Parameters
[in]aOffsetThe number of bytes to move the current offset, which may be positive or negative.
Return values
OT_ERROR_NONESuccessfully moved the byte offset.
OT_ERROR_INVALID_ARGSThe requested byte offset is not within the existing message.

§ SetPanId()

void ot::Message::SetPanId ( uint16_t  aPanId)
inline

This method sets the IEEE 802.15.4 Destination PAN ID.

Note
Only use this when sending MLE Discover Request or Response messages.
Parameters
[in]aPanIdThe IEEE 802.15.4 Destination PAN ID.

§ SetPriority()

otError ot::Message::SetPriority ( uint8_t  aPriority)

This method sets the messages priority.

If the message is already queued in a priority queue, changing the priority ensures to update the message in the associated queue.

Parameters
[in]aProrityThe message priority level.
Return values
OT_ERROR_NONESuccessfully set the priority for the message.
OT_ERROR_INVALID_ARGSPriority level is not invalid.

§ SetSubType()

void ot::Message::SetSubType ( uint8_t  aSubType)
inline

This method sets the message sub type.

Parameters
[in]aSubTypeThe message sub type.

§ SetTimeout()

void ot::Message::SetTimeout ( uint8_t  aTimeout)
inline

This method sets the timeout used for 6LoWPAN reassembly.

Parameters
[in]aTimeoutThe timeout value.

§ SetType()

void ot::Message::SetType ( uint8_t  aType)
inline

This method sets the message type.

Parameters
[in]aTypeThe message type.

§ UpdateChecksum() [1/3]

uint16_t ot::Message::UpdateChecksum ( uint16_t  aChecksum,
uint16_t  aValue 
)
static

This static method updates a checksum.

Parameters
[in]aChecksumThe checksum value to update.
[in]aValueThe 16-bit value to update aChecksum with.
Returns
The updated checksum.

§ UpdateChecksum() [2/3]

uint16_t ot::Message::UpdateChecksum ( uint16_t  aChecksum,
const void *  aBuf,
uint16_t  aLength 
)
static

This static method updates a checksum.

Parameters
[in]aChecksumThe checksum value to update.
[in]aBufA pointer to a buffer.
[in]aLengthThe number of bytes in aBuf.
Returns
The updated checksum.

§ UpdateChecksum() [3/3]

uint16_t ot::Message::UpdateChecksum ( uint16_t  aChecksum,
uint16_t  aOffset,
uint16_t  aLength 
) const

This method is used to update a checksum value.

Parameters
[in]aChecksumInitial checksum value.
[in]aOffsetByte offset within the message to begin checksum computation.
[in]aLengthNumber of bytes to compute the checksum over.
Return values
Theupdated checksum value.

§ Write()

int ot::Message::Write ( uint16_t  aOffset,
uint16_t  aLength,
const void *  aBuf 
)

This method writes bytes to the message.

Parameters
[in]aOffsetByte offset within the message to begin writing.
[in]aLengthNumber of bytes to write.
[in]aBufA pointer to a data buffer.
Returns
The number of bytes written.

The documentation for this class was generated from the following files: