The Frame API contains the functioality used to manage frames.
More...
The Frame API contains the functioality used to manage frames.
This is the generic API available for all frames. Specialized functions are provided by the respective module.
a moep frame
This is the opaque representation of a frame.
u8* moep_frame_get_payload |
( |
moep_frame_t |
frame, |
|
|
size_t * |
len |
|
) |
| |
return payload of a frame
The function moep_frame_get_payload() returns the payload associated with the frame.
- Parameters
-
frame | the frame |
len | returns the length of the payload. |
- Returns
- This function returns a pointer to the payload or NULL if no payload is associated with the frame.
u8* moep_frame_set_payload |
( |
moep_frame_t |
frame, |
|
|
u8 * |
payload, |
|
|
size_t |
len |
|
) |
| |
set payload of a frame
The function moep_frame_set_payload() adds a payload to the frame. Any payload previously set is freed. If payload is NULL only the previous payload is removed. The content of payload is copied to an internal buffer so that payload does not need to be preserved.
- Parameters
-
frame | the frame |
payload | a pointer to the payload |
len | the length of the payload |
- Returns
- This function returns a pointer to the internally saved payload.
- Return values
-
NULL | on error (errno is set appropriately) or if payload is NULL |
- Errors
ENOMEM | Not enough memory available. |
u8* moep_frame_adjust_payload_len |
( |
moep_frame_t |
frame, |
|
|
size_t |
len |
|
) |
| |
adjust the len of the payload of a frame
The function moep_frame_adjust_payload_len() changes the size of the payload associated with the frame. If necessary the internal buffer is changed.
- Parameters
-
frame | the frame |
len | the new length of the payload |
- Returns
- This function returns a pointer to the new internal payload buffer.
- Return values
-
NULL | on error (errno is set appropriately) or if len is 0 |
- Errors
ENOMEM | Not enough memory available. |
int moep_frame_decode |
( |
moep_frame_t |
frame, |
|
|
u8 * |
buf, |
|
|
size_t |
buflen |
|
) |
| |
decode a frame
The function moep_frame_decode() decodes a frame from the buffer buf and saves the parsed content inside frame. This function needs a frame to be already created, so normally one would use moep_dev_frame_decode().
- Parameters
-
frame | the frame to store data in |
buf | the buffer with the frame |
buflen | the length of the buffer |
- Return values
-
0 | on success |
-1 | on error, errno is set appropriately. |
int moep_frame_encode |
( |
moep_frame_t |
frame, |
|
|
u8 ** |
buf, |
|
|
size_t |
buflen |
|
) |
| |
encode a frame
The function moep_frame_encode() encodes a frame to a buffer. This function can be used in multiple ways:
- if buf is NULL, only the length the frame would need is returned.
- if *buf is NULL and buflen is 0, an appropriate buffer is allocated to hold the frame and returned in buf.
- if *buf is NULL and buflen is not 0, a buffer of at most buflen is allocated.
- if *buf is not NULL, it will be used as buffer if it is big enough to hold the frame.
- Parameters
-
frame | the frame to be encoded |
buf | a pointer to the buffer |
buflen | the length of the buffer |
- Returns
- This function returns the length of the encoded frame.
- Return values
-
-1 | on error, errno is set appropriately. |
- Errors
- These are some standard errors generated by this function. Additional errors may be generated and returned from the underlying device specific functions.
EMSGSIZE | The buffer is too small to hold the encoded frame. |
ENOMEM | Not enough memory available. |
destroy a frame
The function moep_frame_destroy() destroys a frame and releases its associated ressources.
- Parameters
-