lcrzo_ipc(3)

NAME
lcrzo_ipc - lcrzo library : Inter Processus Communication

CONTENTS
/*    Laurent Constantin's network library (lcrzo)
                 lcrzo_ipc module
  Functions herein allow two process to communicate.
*/
/************************************************************
 * Note about an ipc :                                      *
 * A lcrzo_ipc is used to transmit data between two         *
 * processes.                                               *
 * For example, the first process can write an integer into *
 * the "tube", and the other process will read it.          *
 ************************************************************/
/*-------------------------------------------------------------*/
/* definition of a lcrzo_ipc. You should not use its
   fields directly. */
typedef struct
{ lcrzo_int16 side;
  int readpipe[2];
  int writepipe[2];
  void *readhandle[2];
  void *writehandle[2];
  lcrzo_bool openforreading;
  lcrzo_bool openforwriting;
  lcrzo_bool dataend;
  lcrzo_data storeddata;
  lcrzo_int32 storeddatasize;
} lcrzo_ipc;
/*-------------------------------------------------------------*/
/* Name : lcrzo_ipc_init
   Description :
     Initialize a lcrzo_ipc.
   Input parameter(s) :
   Input/output parameter(s) :
   Output parameter(s) :
     *pipc : lcrzo_ipc initialized
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_ipc_init(lcrzo_ipc *pipc);
/* A is the father process, and B the child */
int lcrzo_ipc_currentprocessissidea(lcrzo_ipc *pipc);
int lcrzo_ipc_currentprocessissideb(lcrzo_ipc *pipc);
/* Name : lcrzo_ipc_close_xxx
   Description :
     Close a lcrzo_ipc.
     Close the reading descriptor of a lcrzo_ipc.
     Close the writing descriptor of a lcrzo_ipc.
   Input parameter(s) :
     ipc : lcrzo_ipc to close
   Input/output parameter(s) :
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_ipc_close(lcrzo_ipc *pipc);
int lcrzo_ipc_close_read(lcrzo_ipc *pipc);
int lcrzo_ipc_close_write(lcrzo_ipc *pipc);
/*-------------------------------------------------------------*/
/* Name : lcrzo_ipc_write_uint8
   Description :
     Write an lcrzo_uint8 in a lcrzo_ipc tube.
   Input parameter(s) :
     ipc : lcrzo_ipc where the data is written
     uint8 : lcrzo_uint8 to write in ipc
   Input/output parameter(s) :
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_ipc_write_uint8(lcrzo_ipc *pipc,
			  lcrzo_uint8 uint8);
/* Name : lcrzo_ipc_read_uint8
   Description :
     Read an lcrzo_uint8 from a lcrzo_ipc tube.
   Input parameter(s) :
     ipc : lcrzo_ipc from where the datas are read
     *pmaxwaitingtime : maximum waiting time (can be a lcrzo_time,
                        LCRZO_WAIT_NODELAY or LCRZO_WAIT_INFINITE)
   Input/output parameter(s) :
   Output parameter(s) :
     *puint8 : lcrzo_uint8 read from the ipc
   Normal return values :
     LCRZO_ERR_OK : ok
     LCRZO_ERR_OKTEMPDATAEND : the function received nothing
                               before pmaxwaitingtime, so it
			       exited without reading data
*/
int lcrzo_ipc_read_uint8(lcrzo_ipc *pipc,
			 lcrzo_time *pmaxwaitingtime,
			 lcrzo_uint8 *puint8);
/* idem, but work on a lcrzo_uint16 */
int lcrzo_ipc_write_uint16(lcrzo_ipc *pipc,
			   lcrzo_uint16 uint16);
int lcrzo_ipc_read_uint16(lcrzo_ipc *pipc,
			  lcrzo_time *pmaxwaitingtime,
			  lcrzo_uint16 *puint16);
/* idem, but work on a lcrzo_uint32 */
int lcrzo_ipc_write_uint32(lcrzo_ipc *pipc,
			   lcrzo_uint32 uint32);
int lcrzo_ipc_read_uint32(lcrzo_ipc *pipc,
			  lcrzo_time *pmaxwaitingtime,
			  lcrzo_uint32 *puint32);
/* idem, but work on a lcrzo_hs */
int lcrzo_ipc_write_hs(lcrzo_ipc *pipc,
		       lcrzo_consths hs);
int lcrzo_ipc_read_hs(lcrzo_ipc *pipc,
		      lcrzo_time *pmaxwaitingtime,
		      lcrzo_hs hs);
/* idem, but work on a lcrzo_ips */
int lcrzo_ipc_write_ips(lcrzo_ipc *pipc,
			lcrzo_constips ips);
int lcrzo_ipc_read_ips(lcrzo_ipc *pipc,
		       lcrzo_time *pmaxwaitingtime,
		       lcrzo_ips ips);
/* idem, but work on a lcrzo_ipa */
int lcrzo_ipc_write_ipa(lcrzo_ipc *pipc,
			lcrzo_constipa ipa);
int lcrzo_ipc_read_ipa(lcrzo_ipc *pipc,
		       lcrzo_time *pmaxwaitingtime,
		       lcrzo_ipa ipa);
/* idem, but work on a lcrzo_ipl */
int lcrzo_ipc_write_ipl(lcrzo_ipc *pipc,
			lcrzo_ipl ipl);
int lcrzo_ipc_read_ipl(lcrzo_ipc *pipc,
		       lcrzo_time *pmaxwaitingtime,
		       lcrzo_ipl *pipl);
/* idem, but work on a lcrzo_eths */
int lcrzo_ipc_write_eths(lcrzo_ipc *pipc,
			 lcrzo_consteths eths);
int lcrzo_ipc_read_eths(lcrzo_ipc *pipc,
			lcrzo_time *pmaxwaitingtime,
			lcrzo_eths eths);
/* idem, but work on a lcrzo_etha */
int lcrzo_ipc_write_etha(lcrzo_ipc *pipc,
			 lcrzo_constetha etha);
int lcrzo_ipc_read_etha(lcrzo_ipc *pipc,
			lcrzo_time *pmaxwaitingtime,
			lcrzo_etha etha);
/* idem, but work on a lcrzo_device */
int lcrzo_ipc_write_device(lcrzo_ipc *pipc,
			   lcrzo_constdevice device);
int lcrzo_ipc_read_device(lcrzo_ipc *pipc,
			  lcrzo_time *pmaxwaitingtime,
			  lcrzo_device device);
/*-------------------------------------------------------------*/
/* idem, but work on a bloc composed of
   device_name + Ethernet_address + IP_address + port_number */
int lcrzo_ipc_write_deviceethaiplport(lcrzo_ipc *pipc,
				      lcrzo_constdevice device,
				      lcrzo_constetha etha,
				      lcrzo_ipl ipl,
				      lcrzo_uint16 port);
int lcrzo_ipc_read_deviceethaiplport(lcrzo_ipc *pipc,
				     lcrzo_time *pmaxwaitingtime,
			             lcrzo_device device,
				     lcrzo_etha etha,
				     lcrzo_ipl *pipl,
				     lcrzo_uint16 *pport);
/* idem, but work on a bloc composed of
   Ethernet_address + IP_address + port_number */
int lcrzo_ipc_write_ethaiplport(lcrzo_ipc *pipc,
				lcrzo_constetha etha,
				lcrzo_ipl ipl,
				lcrzo_uint16 port);
int lcrzo_ipc_read_ethaiplport(lcrzo_ipc *pipc,
			       lcrzo_time *pmaxwaitingtime,
			       lcrzo_etha etha,
			       lcrzo_ipl *pipl,
			       lcrzo_uint16 *pport);
/* idem, but work on a bloc composed of
   IP_address + port_number */
int lcrzo_ipc_write_iplport(lcrzo_ipc *pipc,
			    lcrzo_ipl ipl,
			    lcrzo_uint16 port);
int lcrzo_ipc_read_iplport(lcrzo_ipc *pipc,
			   lcrzo_time *pmaxwaitingtime,
			   lcrzo_ipl *pipl,
			   lcrzo_uint16 *pport);
/*-------------------------------------------------------------*/
/* Name : lcrzo_ipc_write_msg
   Description :
     Write a data block in a lcrzo_ipc tube.
   Input parameter(s) :
     ipc : lcrzo_ipc where the data is written
     data : data to write
     datasize : size of data
   Input/output parameter(s) :
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_ipc_write_msg(lcrzo_ipc *pipc,
			lcrzo_constdata data,
			lcrzo_int32 datasize);
/* Name : lcrzo_ipc_write
   Description :
     Write a data flow in a lcrzo_ipc tube.
     If datasize is too long, data will be written in several
     chunks (use lcrzo_ipc_write_msg if you want data to be written
     in one step).
  Input parameter(s) :
     ipc : lcrzo_ipc where the data is written
     data : data to write
     datasize : size of data
   Input/output parameter(s) :
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_ipc_write(lcrzo_ipc *pipc,
		    lcrzo_constdata data,
		    lcrzo_int32 datasize);
/* Name : lcrzo_ipc_readm
   Description :
     Read data from a lcrzo_ipc tube.
   Input parameter(s) :
     ipc : lcrzo_ipc from where the datas are read
     *pmaxwaitingtime : maximum waiting time (can be a lcrzo_time,
                        LCRZO_WAIT_NODELAY or LCRZO_WAIT_INFINITE)
   Input/output parameter(s) :
   Output parameter(s) :
     *pdataout : pointer which will be malloced (so, the
                 memory will have to be freed by the
                 user with 'free(*pdataout)').
                 The allocated memory will be set with the read data
     *pdataoutsize : reached size of *pdataout
   Normal return values :
     LCRZO_ERR_OK : ok
     LCRZO_ERR_OKTEMPDATAEND : the function received nothing
                               before pmaxwaitingtime, so it
			       exited without reading data
*/
int lcrzo_ipc_readm(lcrzo_ipc *pipc,
		    lcrzo_time *pmaxwaitingtime,
		    lcrzo_data *pdataout,
		    lcrzo_int32 *pdataoutsize);
/* Name : lcrzo_ipc_readm_fixed
   Description :
     Read data from a lcrzo_ipc tube. Data read has a fixed size.
   Input parameter(s) :
     ipc : lcrzo_ipc from where the datas are read
     *pmaxwaitingtime : maximum waiting time (can be a lcrzo_time,
                        LCRZO_WAIT_NODELAY or LCRZO_WAIT_INFINITE)
     datasizetoread : exact size to read
   Input/output parameter(s) :
   Output parameter(s) :
     *pdataout : pointer which will be malloced (so, the
                 memory will have to be freed by the
                 user with 'free(*pdataout)').
                 The allocated memory will be set with the read data
   Normal return values :
     LCRZO_ERR_OK : ok
     LCRZO_ERR_OKTEMPDATAEND : the function received nothing
                               before pmaxwaitingtime, so it
			       exited without reading data
*/
int lcrzo_ipc_readm_fixed(lcrzo_ipc *pipc,
			  lcrzo_time *pmaxwaitingtime,
			  lcrzo_int32 datasizetoread,
			  lcrzo_data *pdataout);
/* Name : lcrzo_ipc_readm_line
   Description :
     Read a line (till \r\n) from a lcrzo_ipc tube.
   Input parameter(s) :
     ipc : lcrzo_ipc from where the datas are read
     *pmaxwaitingtime : maximum waiting time (can be a lcrzo_time,
                        LCRZO_WAIT_NODELAY or LCRZO_WAIT_INFINITE)
   Input/output parameter(s) :
   Output parameter(s) :
     *pdataout : pointer which will be malloced (so, the
                 memory will have to be freed by the
                 user with 'free(*pdataout)').
                 The allocated memory will be set with the read data
     *pdataoutsize : reached size of *pdataout
   Normal return values :
     LCRZO_ERR_OK : ok
     LCRZO_ERR_OKTEMPDATAEND : the function received nothing
                               before pmaxwaitingtime, so it
			       exited without reading data
*/
int lcrzo_ipc_readm_line(lcrzo_ipc *pipc,
			 lcrzo_time *pmaxwaitingtime,
			 lcrzo_data *pdataout,
			 lcrzo_int32 *pdataoutsize);

SEE ALSO
lcrzo(3), lcrzo_types(3), lcrzo_data(3), lcrzo_string(3), lcrzo_time(3), lcrzo_file(3), lcrzo_address(3), lcrzo_device(3), lcrzo_list(3), lcrzo_process(3), lcrzo_ipc(3), lcrzo_header(3), lcrzo_ipopt(3), lcrzo_tcpopt(3), lcrzo_packet(3), lcrzo_icmp(3), lcrzo_print(3), lcrzo_record(3), lcrzo_conf(3), lcrzo_spoof(3), lcrzo_sniff(3), lcrzo_sock(3), lcrzo_wait(3), lcrzo_global(3), lcrzo_error(3) lcrzo_misc(3), lcrzo_obso(3),