Packet client. More...
#include "packet.h"
Packet client interface | |
| |
#define | PACKET_PREFIX(packet, type) (type *) packet_prefix((packet), sizeof(type)) |
Allocates the specified type right before the actual packet content and returns its pointer. | |
#define | PACKET_SUFFIX(packet, type) (type *) packet_suffix((packet), sizeof(type)) |
Allocates the specified type right after the actual packet content and returns its pointer. | |
#define | PACKET_TRIM(packet, prefix, suffix) packet_trim((packet), sizeof(prefix), sizeof(suffix)) |
Trims the actual packet content by the specified prefix and suffix types. | |
void * | packet_prefix (packet_t packet, size_t length) |
Allocates the specified space right before the actual packet content and returns its pointer. | |
void * | packet_suffix (packet_t packet, size_t length) |
Allocates the specified space right after the actual packet content and returns its pointer. | |
int | packet_trim (packet_t packet, size_t prefix, size_t suffix) |
Trims the actual packet content by the specified prefix and suffix lengths. | |
int | packet_copy_data (packet_t packet, const void *data, size_t length) |
Copies the specified data to the beginning of the actual packet content. | |
packet_id_t | packet_get_id (const packet_t packet) |
Returns the packet identifier. | |
size_t | packet_get_data_length (const packet_t packet) |
Returns the packet content length. | |
void * | packet_get_data (const packet_t packet) |
Returns the pointer to the beginning of the packet content. | |
int | packet_get_addr (const packet_t packet, uint8_t **src, uint8_t **dest) |
Returns the stored packet addresses and their length. | |
int | packet_set_addr (packet_t packet, const uint8_t *src, const uint8_t *dest, size_t addr_len) |
Sets the packet addresses. | |
int | packet_translate (int phone, packet_ref packet, packet_id_t packet_id) |
Translates the packet identifier to the packet reference. | |
packet_t | packet_get_4 (int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix) |
Obtains the packet of the given dimensions. | |
packet_t | packet_get_1 (int phone, size_t content) |
Obtains the packet of the given content size. | |
void | pq_release (int phone, packet_id_t packet_id) |
Releases the packet queue. | |
packet_t | packet_get_copy (int phone, packet_t packet) |
Returns the packet copy. |
Packet client.
The hosting module has to be compiled with both the packet.c and the packet_client.c source files. To function correctly, initialization of the packet map by the pm_init() function has to happen at the first place. The module should not send the packet messages to the packet server but use the functions provided. The packet map should be released by the pm_destroy() function during the module termination. The packets and the packet queues can't be locked at all. The processing modules should process them sequentially - by passing the packets to the next module and stopping using the passed ones.