Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_network_msg.h File Reference

Network messages , serialization tools. More...

#include <sys/param.h>
#include "n_str.h"
#include "n_list.h"
#include "n_3d.h"
+ Include dependency graph for n_network_msg.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  NETW_MSG
 network message, array of char and int More...
 

Macros

#define NETMSG_BOX   8
 Network Message is box retrieving reply: (int x , int y , int z , N_STR *data )
 
#define NETMSG_GET_BOX   7
 Network Message is box retrieve: int x , int y , int z.
 
#define NETMSG_IDENT_REPLY_NOK   2
 Network Message is identification reply NON OK: (int)type , (int)id , (N_STR *)name , (N_STR *)password.
 
#define NETMSG_IDENT_REPLY_OK   1
 Network Message is identification reply OK : (int)type , (int)id , (N_STR *)name , (N_STR *)password.
 
#define NETMSG_IDENT_REQUEST   0
 Network Message is identification request: (int)type , (int)id , (N_STR *)name , (N_STR *)password.
 
#define NETMSG_PING_REPLY   6
 Network Message is ping reply: (int)type , (int)id_from , (int)id_to.
 
#define NETMSG_PING_REQUEST   5
 Network Message is ping request: (int)type , (int)id_from , (int)id_to.
 
#define NETMSG_POSITION   4
 Network Message position: (int)type , (int)id , (int)X , (int)Y , (int)x_shift , (int)y_shift ,(int)vx ,(int)vy , (int)speed , (int)acceleration , (int)time_stamp.
 
#define NETMSG_QUIT   9
 Network asking for exit.
 
#define NETMSG_STRING   3
 Network Message is string: (int)type , (int)id , (N_STR *)name , (N_STR *)chan , (N_STR *)text , (int)color.
 
#define NETW_MSG_MAX_STRING_LENGTH   (1024UL * 1024UL * 1024UL)
 Maximum allowed length for a single string inside a network message (default: 1 GB).
 

Functions

int add_int_to_msg (NETW_MSG *msg, int value)
 add an int to the message
 
int add_nb_to_msg (NETW_MSG *msg, double value)
 add a float/double to the message
 
int add_nstrdup_to_msg (NETW_MSG *msg, N_STR *str)
 add a duplicate of a N_STR to the message
 
int add_nstrptr_to_msg (NETW_MSG *msg, N_STR *str)
 add a N_STR pointer to the message without copying
 
int add_strdup_to_msg (NETW_MSG *msg, const char *str)
 add a duplicate of a char string to the message
 
int create_msg (NETW_MSG **msg)
 create a NETW_MSG object
 
int delete_msg (NETW_MSG **msg)
 delete a NETW_MSG object
 
double double_swap (double value)
 swap bytes of a double value
 
int empty_msg (NETW_MSG **msg)
 empty a NETW_MSG object
 
int get_int_from_msg (NETW_MSG *msg, int *value)
 get an int from the message
 
int get_nb_from_msg (NETW_MSG *msg, double *value)
 get a float/double value from the message
 
int get_nstr_from_msg (NETW_MSG *msg, N_STR **str)
 get a N_STR string from the message
 
int get_str_from_msg (NETW_MSG *msg, char **str)
 get a char string from the message
 
double htond (double value)
 convert host double to network byte order
 
NETW_MSGmake_msg_from_str (N_STR *str)
 deserialize a N_STR into a NETW_MSG
 
N_STRmake_str_from_msg (NETW_MSG *msg)
 serialize a NETW_MSG into a single N_STR
 
N_STRnetmsg_make_ident (int type, int id, N_STR *name, N_STR *passwd)
 create an identification network message
 
N_STRnetmsg_make_ping (int type, int id_from, int id_to, int time)
 create a ping network message
 
N_STRnetmsg_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
 
N_STRnetmsg_make_quit_msg (void)
 create a quit network message
 
N_STRnetmsg_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 netw_get_ident (N_STR *msg, int *type, int *ident, N_STR **name, N_STR **passwd)
 get identification data from a network message
 
int netw_get_ping (N_STR *msg, int *type, int *from, int *to, int *time)
 get ping data from a network 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
 
int netw_get_quit (N_STR *msg)
 get quit data from a network message
 
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 netw_msg_get_type (N_STR *msg)
 get the type of a network message.
 
double ntohd (double value)
 convert network double to host byte order
 

Detailed Description

Network messages , serialization tools.

Author
Castagnier Mickael
Version
1.0
Date
10/05/2005

Definition in file n_network_msg.h.