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

aObject [in] A reference to the object to append.

Template Parameters

ObjectType The object type to append.

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

ObjectType The object type to append.

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

aUint8 [in] The `uint8_t` value to append.
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

aUint [in] The integer value to append.

Template Parameters

kEncoding The encoding to use (big or little endian).
UintType The unsigned integer type.
Error AppendBytes (const void * aBuffer, uint16_t aLength)

Appends bytes from a given buffer to the `FrameBuilder`.

Parameters

aBuffer [in] A pointer to a data bytes to append.
aLength [in] Number of bytes in
Error AppendMacAddress (const Mac::Address & aMacAddress)

Appends a given `Mac::Address` to the `FrameBuilder`.

Parameters

aMacAddress [in] A `Mac::Address` to append.
Error AppendBytesFromMessage (const Message & aMessage, uint16_t aOffset, uint16_t aLength)

Appends bytes read from a given message to the `FrameBuilder`.

Parameters

aMessage [in] The message to read the bytes from.
aOffset [in] The offset into start reading the bytes from.
aLength [in] Number of bytes to read fromand append.
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

aLength [in] The number of bytes to append.
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

aLength [in] The append length.

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

aBuffer [in] A pointer to a buffer.
aLength [in] The max data length (number of bytes in
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

aLength [in] The maximum frame length.

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

aOffset [in] The offset to insert bytes.
aObject [in] A reference to the object to insert.

Template Parameters

ObjectType The object type to insert.

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

aOffset [in] The byte offset where the object starts.

Template Parameters

ObjectType The object type to read.

Defined at line 312 of file ../../third_party/openthread/src/core/common/frame_builder.hpp

void WriteBytes (uint16_t aOffset, const void * aBuffer, uint16_t aLength)

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

aOffset [in] The offset to begin writing.
aBuffer [in] A pointer to a data buffer to write.
aLength [in] Number of bytes in
Error InsertBytes (uint16_t aOffset, const void * aBuffer, uint16_t aLength)

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

aOffset [in] The offset to insert bytes.
aBuffer [in] A pointer to a data buffer to insert.
aLength [in] Number of bytes in
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

aOffset [in] The offset to remove bytes from.
aLength [in] The number of bytes to remove.
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

aOffset [in] The offset to begin writing.
aObject [in] A reference to the object to write.

Template Parameters

ObjectType The object type to write.

Defined at line 245 of file ../../third_party/openthread/src/core/common/frame_builder.hpp