3D-ICE 3.0.0
Data Structures | Macros | Typedefs | Functions
network_message.h File Reference
#include "types.h"

Go to the source code of this file.

Data Structures

struct  NetworkMessage_t
 Structure used to store messages to be sent over network. More...
 

Macros

#define MESSAGE_LENGTH   256
 

Typedefs

typedef struct NetworkMessage_t NetworkMessage_t
 

Functions

void network_message_init (NetworkMessage_t *message)
 
void network_message_destroy (NetworkMessage_t *message)
 
void increase_message_memory (NetworkMessage_t *message, Quantity_t new_size)
 
void build_message_head (NetworkMessage_t *message, MessageType_t type)
 
void insert_message_word (NetworkMessage_t *message, void *word)
 
Error_t extract_message_word (NetworkMessage_t *message, void *word, Quantity_t index)
 

Macro Definition Documentation

◆ MESSAGE_LENGTH

#define MESSAGE_LENGTH   256

The initial number of words that a message can store (header included)

Definition at line 58 of file network_message.h.

Typedef Documentation

◆ NetworkMessage_t

Definition of the type NetworkMessage_t

Definition at line 96 of file network_message.h.

Function Documentation

◆ build_message_head()

void build_message_head ( NetworkMessage_t message,
MessageType_t  type 
)

Builds the head of a message (sets its type)

The function sets the content of the first two words of the message (i.e. the length snd the type)

Parameters
messagethe address of the message to build
typethe type of the request

Definition at line 93 of file network_message.c.

◆ extract_message_word()

Error_t extract_message_word ( NetworkMessage_t message,
void *  word,
Quantity_t  index 
)

Extracts the index-th word from the content of a message

The function will not change the status/content of the message. If index indicates a position out of the message payload the result is undetermined.

Parameters
messagethe address of the message to access
word(out) the address of the word to extrcact
indexthe index of the word (starting from the beginning of the content)
Returns
TDICE_SUCCESS if the operation succeeded
TDICE_FAILURE if there index specifies a word out of the message

Definition at line 121 of file network_message.c.

◆ increase_message_memory()

void increase_message_memory ( NetworkMessage_t message,
Quantity_t  new_size 
)

Changes the amount of memory available to store the message

Parameters
messagethe address of the message
new_sizethe new size (number of words)

Definition at line 76 of file network_message.c.

◆ insert_message_word()

void insert_message_word ( NetworkMessage_t message,
void *  word 
)

Inserts a single word to the content of a message

The value pointed by word will be insert at the end of the message (as a suffix) and the length of the message is incresed conseguently

Parameters
messagethe address of the message to build
word(in) the address of the word to add

Definition at line 102 of file network_message.c.

◆ network_message_destroy()

void network_message_destroy ( NetworkMessage_t message)

Destroys the content of the fields of the structure message

The function releases any dynamic memory used by the structure and resets its state calling network_message_init .

Parameters
messagethe address of the structure to destroy

Definition at line 61 of file network_message.c.

◆ network_message_init()

void network_message_init ( NetworkMessage_t message)

Inits the fields of the message structure with default values

The function reserves memory to store MESSAGE_LENGTH words

Parameters
messagethe address of the structure to initalize

Definition at line 46 of file network_message.c.