class FrameBuilder
Defined at line 50 of file ../../third_party/openthread/src/core/common/frame_builder.hpp
The `FrameBuilder` can be used to construct frame content in a given data buffer.
Public Methods
template <typename ObjectType>
Error Append (const ObjectType & aObject)
Appends an object to the `FrameBuilder`.
Parameters
Template Parameters
Defined at line 183 of file ../../third_party/openthread/src/core/common/frame_builder.hpp
template <typename ObjectType>
ObjectType * Append ()
Appends an object to the `FrameBuilder`.
This method reserves bytes in `FrameBuilder` to accommodate an `ObjectType` and returns a pointer to the
appended `ObjectType`. The `ObjectType` bytes are left uninitialized. Caller is responsible to initialize them.
Template Parameters
Defined at line 215 of file ../../third_party/openthread/src/core/common/frame_builder.hpp
Error AppendUint8 (uint8_t aUint8)
Appends an `uint8_t` value to the `FrameBuilder`.
Parameters
template <Encoding kEncoding, typename UintType>
Error AppendUint (UintType aUint)
Appends an integer value with a specified encoding to the `FrameBuilder`.
The value is converted to the specified
byte order before being appended.
Parameters
Template Parameters
Error AppendBytes (const void * aBuffer, uint16_t aLength)
Appends bytes from a given buffer to the `FrameBuilder`.
Parameters
Error AppendMacAddress (const Mac::Address & aMacAddress)
Appends a given `Mac::Address` to the `FrameBuilder`.
Parameters
Error AppendBytesFromMessage (const Message &aMessage,uint16_taOffset,uint16_taLength)
Appends bytes read from a given message to the `FrameBuilder`.
Parameters
void * AppendLength (uint16_t aLength)
Appends the given number of bytes to the `FrameBuilder`.
This method reserves
bytes at the current position of the `FrameBuilder` and returns a pointer to the
start of this reserved buffer if successful. The reserved bytes are left uninitialized. The caller is
responsible for initializing them.
Parameters
const uint8_t * GetBytes ()
Returns a pointer to the start of `FrameBuilder` buffer.
Defined at line 68 of file ../../third_party/openthread/src/core/common/frame_builder.hpp
uint16_t GetLength ()
Returns the current length of frame (number of bytes appended so far).
Defined at line 75 of file ../../third_party/openthread/src/core/common/frame_builder.hpp
uint16_t GetMaxLength ()
Returns the maximum length of the frame.
Defined at line 82 of file ../../third_party/openthread/src/core/common/frame_builder.hpp
uint16_t GetRemainingLength ()
Returns the remaining length (number of bytes that can be appended) in the frame.
Defined at line 99 of file ../../third_party/openthread/src/core/common/frame_builder.hpp
bool CanAppend (uint16_t aLength)
Indicates whether or not there are enough bytes remaining in the `FrameBuilder` buffer to append a
given number of bytes.
Parameters
Defined at line 110 of file ../../third_party/openthread/src/core/common/frame_builder.hpp
void Init (void * aBuffer, uint16_t aMaxLength)
Initializes the `FrameBuilder` to use a given buffer.
`FrameBuilder` MUST be initialized before its other methods are used.
Parameters
void SetMaxLength (uint16_t aLength)
Sets the maximum length of the frame.
Does not perform any checks on the new given length. The caller MUST ensure that the specified max
length is valid for the frame buffer.
Parameters
Defined at line 92 of file ../../third_party/openthread/src/core/common/frame_builder.hpp
template <typename ObjectType>
Error Insert (uint16_t aOffset, const ObjectType & aObject)
Inserts an object in `FrameBuilder` at a given offset, moving previous content forward.
The caller MUST ensure that
is within the current frame length (from 0 up to and including
`GetLength()`). Otherwise the behavior of this method is undefined.
Parameters
Template Parameters
Defined at line 281 of file ../../third_party/openthread/src/core/common/frame_builder.hpp
template <typename ObjectType>
ObjectType * Read (uint16_t aOffset)
Reads a pointer to a previously appended object in the `FrameBuilder` at a given byte offset.
This method does not perform any bounds checking. The caller MUST ensure the object of type `ObjectType`
fits within the previously appended content.
Parameters
Template Parameters
Defined at line 312 of file ../../third_party/openthread/src/core/common/frame_builder.hpp
void WriteBytes (uint16_taOffset,const void *aBuffer,uint16_taLength)
Writes bytes in `FrameBuilder` at a given offset overwriting the previously appended content.
Does not perform any bound checks. The caller MUST ensure that the given data length fits within the
previously appended content. Otherwise the behavior of this method is undefined.
Parameters
Error InsertBytes (uint16_taOffset,const void *aBuffer,uint16_taLength)
Inserts bytes in `FrameBuilder` at a given offset, moving previous content forward.
The caller MUST ensure that
is within the current frame length (from 0 up to and including
`GetLength()`). Otherwise the behavior of this method is undefined.
Parameters
void RemoveBytes (uint16_t aOffset, uint16_t aLength)
Removes a given number of bytes in `FrameBuilder` at a given offset, moving existing content
after removed bytes backward.
Does not perform any bound checks. The caller MUST ensure that the given length and offset fits
within the previously appended content. Otherwise the behavior of this method is undefined.
Parameters
template <typename ObjectType>
void Write (uint16_t aOffset, const ObjectType & aObject)
Writes an object to the `FrameBuilder` at a given offset overwriting previously appended content.
Does not perform any bound checks. The caller MUST ensure the given data length fits within the
previously appended content. Otherwise the behavior of this method is undefined.
Parameters
Template Parameters
Defined at line 245 of file ../../third_party/openthread/src/core/common/frame_builder.hpp