26#ifndef N_NETWORK_MESSAGES
27#define N_NETWORK_MESSAGES
45#define NETMSG_IDENT_REQUEST 0
47#define NETMSG_IDENT_REPLY_OK 1
49#define NETMSG_IDENT_REPLY_NOK 2
51#define NETMSG_STRING 3
53#define NETMSG_POSITION 4
55#define NETMSG_PING_REQUEST 5
57#define NETMSG_PING_REPLY 6
59#define NETMSG_GET_BOX 7
67#ifndef NETW_MSG_MAX_STRING_LENGTH
68#define NETW_MSG_MAX_STRING_LENGTH (1024UL * 1024UL * 1024UL)
84double htond(
double value);
86double ntohd(
double value);
134int netw_get_position(
N_STR* msg,
int*
id,
double* X,
double* Y,
double* vx,
double* vy,
double* acc_x,
double* acc_y,
int* time_stamp);
Structure of a generic LIST container.
A box including a string and his lenght.
LIST * tabflt
array of casted double value
LIST * tabstr
array of N_STR
LIST * tabint
array of int
double htond(double value)
convert host double to network byte order
int get_str_from_msg(NETW_MSG *msg, char **str)
get a char string from the message
int add_strdup_to_msg(NETW_MSG *msg, const char *str)
add a duplicate of a char string to the message
int netw_get_position(N_STR *msg, int *id, double *X, double *Y, double *vx, double *vy, double *acc_x, double *acc_y, int *time_stamp)
get position data from a network message
NETW_MSG * make_msg_from_str(N_STR *str)
deserialize a N_STR into a NETW_MSG
int empty_msg(NETW_MSG **msg)
empty a NETW_MSG object
double double_swap(double value)
swap bytes of a double value
N_STR * make_str_from_msg(NETW_MSG *msg)
serialize a NETW_MSG into a single N_STR
int netw_get_ping(N_STR *msg, int *type, int *from, int *to, int *time)
get ping data from a network message
int add_nstrptr_to_msg(NETW_MSG *msg, N_STR *str)
add a N_STR pointer to the message without copying
int get_nb_from_msg(NETW_MSG *msg, double *value)
get a float/double value from the message
int netw_get_quit(N_STR *msg)
get quit data from a network message
int create_msg(NETW_MSG **msg)
create a NETW_MSG object
N_STR * netmsg_make_position_msg(int id, double X, double Y, double vx, double vy, double acc_x, double acc_y, int time_stamp)
create a position network message
int netw_msg_get_type(N_STR *msg)
get the type of a network message.
int get_nstr_from_msg(NETW_MSG *msg, N_STR **str)
get a N_STR string from the message
N_STR * netmsg_make_ident(int type, int id, N_STR *name, N_STR *passwd)
create an identification network message
int add_nstrdup_to_msg(NETW_MSG *msg, N_STR *str)
add a duplicate of a N_STR to the message
int add_int_to_msg(NETW_MSG *msg, int value)
add an int to the message
double ntohd(double value)
convert network double to host byte order
int netw_get_string(N_STR *msg, int *id, N_STR **name, N_STR **chan, N_STR **txt, int *color)
get string data from a network message
int delete_msg(NETW_MSG **msg)
delete a NETW_MSG object
int add_nb_to_msg(NETW_MSG *msg, double value)
add a float/double to the message
N_STR * netmsg_make_quit_msg(void)
create a quit network message
N_STR * netmsg_make_ping(int type, int id_from, int id_to, int time)
create a ping network message
int netw_get_ident(N_STR *msg, int *type, int *ident, N_STR **name, N_STR **passwd)
get identification data from a network message
N_STR * netmsg_make_string_msg(int id_from, int id_to, N_STR *name, N_STR *chan, N_STR *txt, int color)
create a string network message
int get_int_from_msg(NETW_MSG *msg, int *value)
get an int from the message
network message, array of char and int
Simple 3D movement simulation.
List structures and definitions.
N_STR and string function declaration.