#include <stdint.h>
#include "packet.h"
#include "payload.h"
Go to the source code of this file.
|
| struct message * | message_new (const struct packet_init *init_packet) |
| | Allocate and initialize a new message from an init packet. More...
|
| |
| struct message * | message_new_blank (uint32_t cid, uint8_t cmd) |
| | Allocate and initialize a new blank message. More...
|
| |
| struct message * | message_new_from_data (uint32_t cid, uint8_t cmd, const uint8_t *data, size_t size) |
| | Allocate and initialize a new message from data. More...
|
| |
| struct message * | message_new_from_payload (uint32_t cid, uint8_t cmd, const struct payload *payload) |
| | Allocate and initialize a new message from payload. More...
|
| |
| struct message * | message_copy (const struct message *message) |
| | Allocate and initialize a new message from another message. More...
|
| |
| bool | message_add_data (struct message *message, const uint8_t *data, size_t size) |
| | Add data to a message. More...
|
| |
| bool | message_add_part (struct message *message, const struct packet_cont *cont_packet) |
| | Add a part to a message. More...
|
| |
| bool | message_next_packet (struct message *message, void **packet_ref) |
| | Get next packet part of a message for sending a message. More...
|
| |
| void | message_free (struct message *message) |
| | Free a message. More...
|
| |
| #define BIT |
( |
|
x | ) |
(1 << (x)) |
The default capacity of a message.
Value:
#define PACKET_INIT_DATA_SIZE
Definition: packet.h:20
#define PACKET_CONT_DATA_SIZE
Definition: packet.h:24
#define PACKET_CONT_MAX_SEQ
Definition: packet.h:25
| bool message_add_data |
( |
struct message * |
message, |
|
|
const uint8_t * |
data, |
|
|
size_t |
size |
|
) |
| |
Add data to a message.
- Parameters
-
| message | The message to add data to. |
| data | The data to add. |
| size | The size of the data. |
- Returns
- Success: true. Failure: false.
| bool message_add_part |
( |
struct message * |
message, |
|
|
const struct packet_cont * |
cont_packet |
|
) |
| |
Add a part to a message.
- Parameters
-
| message | The message. |
| cont_packet | The continuation packet. |
- Returns
- Success: true. Failure: false.
Allocate and initialize a new message from another message.
- Parameters
-
| message | The message to copy. |
- Returns
- Success: The new allocated and initialized message. Failure: NULL.
| void message_free |
( |
struct message * |
message | ) |
|
Free a message.
- Parameters
-
| message | The message to free. |
Allocate and initialize a new message from an init packet.
- Parameters
-
| init_packet | The initialisation packet of the message. |
- Returns
- Success: The new allocated and initialiazed message. Failure: NULL.
| struct message* message_new_blank |
( |
uint32_t |
cid, |
|
|
uint8_t |
cmd |
|
) |
| |
Allocate and initialize a new blank message.
- Parameters
-
| cid | The channel id. |
| cmd | The associated command. |
- Returns
- Success: The new allocated and initialized blank message. Failure: NULL.
| struct message* message_new_from_data |
( |
uint32_t |
cid, |
|
|
uint8_t |
cmd, |
|
|
const uint8_t * |
data, |
|
|
size_t |
size |
|
) |
| |
Allocate and initialize a new message from data.
- Parameters
-
| cid | The channel id. |
| cmd | The associated command. |
| data | The data to put in the message. |
| size | The size of the data. |
- Returns
- Success: The new allocated and initialized message. Failure: NULL.
| struct message* message_new_from_payload |
( |
uint32_t |
cid, |
|
|
uint8_t |
cmd, |
|
|
const struct payload * |
payload |
|
) |
| |
Allocate and initialize a new message from payload.
- Parameters
-
| cid | The channel id. |
| cmd | The associated command. |
| payload | The payload ot put in the message. |
- Returns
- Success: The new allocated and initialized message. Failure: NULL.
| bool message_next_packet |
( |
struct message * |
message, |
|
|
void ** |
packet_ref |
|
) |
| |
Get next packet part of a message for sending a message.
- Parameters
-
| message | The message to get the next packet from. |
| packet_ref | Packet reference to put the crafted packet. |
- Returns
- End of message: false. Not end of message: true.