Net Packets


Classes

struct  ix_adr_t
struct  ix_netinfo_s

Defines

#define IX_PROCNAME_LEN   12

Typedefs

typedef ix_netinfo_s ix_netinfo_t
typedef ix_net_s ix_net_t
typedef int(*) IX_SERVER_DISCONNECT_FCT (ix_adr_t *padr, int fd)

Functions

int ix_adr_init (ix_adr_t *padr, char *hostip, unsigned short hport)
int ix_adr_initin (ix_adr_t *padr, void *ip, unsigned short hport)
int ix_adr_ip (ix_adr_t *padr, char *ip, int len)
int ix_adr_port (ix_adr_t *padr)
int ix_adr_getip (ix_adr_t *padr, void *ip)
int ix_adr_getnode (ix_adr_t *padr)
char * ix_adr_getproc (ix_adr_t *padr)
char * ix_adr_getnodeproc (ix_adr_t *padr, char *buf, int buflen)
int ix_adr_str (ix_adr_t *padr, char *str, int len)
char * ix_adr_str2 (ix_adr_t *padr, char *str, int len)
int ix_adr_hostandport (ix_adr_t *padr, char *str, int len)
void ix_adr_proc (ix_adr_t *padr, char *proc, int node)
ix_net_tix_net_new (char *tohost, unsigned short toport)
void ix_net_free (ix_net_t *pnet)
int ix_net_setto (ix_net_t *pnet, ix_adr_t *toadr)
int ix_net_setcb (ix_net_t *pnet, IX_SERVER_DISCONNECT_FCT cb)
int ix_net_event (ix_net_t *pnet, unsigned int evid)
int ix_net_trigger (ix_net_t *pnet, unsigned int evid)
int ix_net_send (ix_net_t *pnet)
int ix_tcp_packet (int sd, ix_net_t *pnet)
int ix_udp_msg (ix_net_t *pnet, unsigned char *buf, int buflen)
int ix_tcp_msg (ix_net_t *pnet, unsigned char *buf, int buflen)
int ix_send (ix_net_t *pnet, unsigned char *buf, int buflen, ix_net_t *preply)
ix_buffer_tix_net_getmsg (ix_net_t *pnet)
ix_adr_tix_net_getfrom (ix_net_t *pnet)
ix_adr_tix_net_getto (ix_net_t *pnet)
ix_netinfo_tix_net_getinfo (ix_net_t *pnet)
int ix_net_setinfo (ix_net_t *pnet, ix_netinfo_t *pinfo)
int ix_net_tef (ix_net_t *pnet)

Detailed Description

Following structures are part of net-packet and used by some getter and setter functions: ix_adr_t , ix_netinfo_t .

Typedef Documentation

typedef struct ix_net_s ix_net_t

A Net Packet Object, the implemenation is hidden.

typedef struct ix_netinfo_s ix_netinfo_t

Additional information of a net packet get/set by ix_net_getinfo() / ix_net_setinfo()

typedef int( * ) IX_SERVER_DISCONNECT_FCT(ix_adr_t *padr, int fd)

Callback for server disconnect: When server disconnects and callback is set this function is called.

Parameters:
padr address of server which disconnected file descriptor on which the server was connected.


Function Documentation

int ix_adr_getip ( ix_adr_t padr,
void *  ip 
)

Get binary internet address of ix net address

Returns:
  • 0 OK
  • <0 Error

int ix_adr_getnode ( ix_adr_t padr  ) 

Get node

Parameters:
padr pointer to ix net address
Returns:
node of address

char* ix_adr_getnodeproc ( ix_adr_t padr,
char *  buf,
int  buflen 
)

node number and process name

Parameters:
padr pointer to ix net address structure
buf buffer to store node number and process name
buflen length of supplied buffer
Returns:
buffer with format <node>,<proc>

char* ix_adr_getproc ( ix_adr_t padr  ) 

Get process name

Parameters:
padr pointer to ix net address structure
Returns:
process name of address

int ix_adr_hostandport ( ix_adr_t padr,
char *  str,
int  len 
)

Prints ix_adr_t to string of length len, format ip:port

Returns:
  • number of written chars
  • <0 Error

int ix_adr_init ( ix_adr_t padr,
char *  hostip,
unsigned short  hport 
)

Inits ix_adr_t with ip-adr and port

Parameters:
hostip ip adress in dot-notation ("127.0.0.1")
hport port number in host-order
Returns:
  • 0: OK
  • <0: Error

int ix_adr_initin ( ix_adr_t padr,
void *  ip,
unsigned short  hport 
)

Inits ix_adr_t with internet address and port

Parameters:
ip internet adress in binary network-order
hport port number in host-order
Returns:
  • 0 OK
  • <0 Error

int ix_adr_ip ( ix_adr_t padr,
char *  ip,
int  len 
)

Prints ip-address of ix_adr_t to string of length len

Returns:
  • number of written chars
  • <0: Error

int ix_adr_port ( ix_adr_t padr  ) 

Get Port of address

Returns:
  • port
  • <0 Error

void ix_adr_proc ( ix_adr_t padr,
char *  proc,
int  node 
)

Sets string identifier to processname and node for user friendly additional information

Parameters:
padr address to be filled
proc processname to be set
node node number to be set

int ix_adr_str ( ix_adr_t padr,
char *  str,
int  len 
)

Prints ix_adr_t to string of length len format <ip:port:proc>

Returns:
  • number of written chars
  • <0 Error

char* ix_adr_str2 ( ix_adr_t padr,
char *  str,
int  len 
)

Prints ix_adr_t to string of length len format <ip:port:proc>

Returns:
string

int ix_net_event ( ix_net_t pnet,
unsigned int  evid 
)

Depreciated

void ix_net_free ( ix_net_t pnet  ) 

Frees net packet

Returns:
  • 0 OK
  • <0 Error

ix_adr_t* ix_net_getfrom ( ix_net_t pnet  ) 

Get From address of net packet

Returns:
from-address

ix_netinfo_t* ix_net_getinfo ( ix_net_t pnet  ) 

Get Info from net packet

Returns:
info

ix_buffer_t* ix_net_getmsg ( ix_net_t pnet  ) 

Get message buffer from net packet

Returns:
message buffer

ix_adr_t* ix_net_getto ( ix_net_t pnet  ) 

Get To address of net packet

Returns:
to-address

ix_net_t* ix_net_new ( char *  tohost,
unsigned short  toport 
)

Creates a net packet. Parameter tohost may be NULL, use ix_net_setto() to set up destination address.

Parameters:
tohost destination host
toport destination port
Returns:
  • Handle for packet
  • NULL Error

int ix_net_send ( ix_net_t pnet  ) 

Sends netpacket, which had to be set up properly

Parameters:
pnet net packet to send
Returns:
  • 0 OK
  • <0 Error

int ix_net_setcb ( ix_net_t pnet,
IX_SERVER_DISCONNECT_FCT  cb 
)

Set callback for server disconnect. It is called from dispatcher when the addressed server in this packet disconnects from client.

Returns:
  • 0 OK
  • <0 Error

int ix_net_setinfo ( ix_net_t pnet,
ix_netinfo_t pinfo 
)

Sets info to net packet

Returns:
  • 0 OK
  • <0 Error

int ix_net_setto ( ix_net_t pnet,
ix_adr_t toadr 
)

Sets destination address for packet. This function may be used to reuse a packet.

Returns:
  • 0 OK
  • <0 Error

int ix_net_tef ( ix_net_t pnet  ) 

Gets the endian toogle flag

Returns:
  • 0 OK
  • <0 Error

int ix_net_trigger ( ix_net_t pnet,
unsigned int  evid 
)

Sends event evid as netpacket, which had to be set up properly

Returns:
  • 0 OK
  • <0 Error

int ix_send ( ix_net_t pnet,
unsigned char *  buf,
int  buflen,
ix_net_t preply 
)

Synchronnous send: This function waits to receive the reply.

Parameters:
pnet The to-address must have been setup properly with ix_net_new() or ix_net_setto(). The from address is internally taken (port data data supplied by ix_connect_tcp()), see ix_set_reply_cb() for the server setup.
buf send a message buf of len buflen as net-packet per TCP
buflen send a message buf of len buflen as net-packet per TCP
preply the reply of the server, get the message with ix_net_getmessage().
Returns:
  • 0 OK
  • <0 Error

int ix_tcp_msg ( ix_net_t pnet,
unsigned char *  buf,
int  buflen 
)

Asynchronous send as net packet per TCP

Parameters:
pnet The to-address must have been setup properly with ix_net_new() or ix_net_setto(). The from address is internally taken (port data data supplied by ix_connect_tcp()), see ix_set_reply_cb() for the server setup.
buf send a message buf of len buflen as net-packet per TCP
buflen send a message buf of len buflen as net-packet per TCP
Returns:
  • 0 OK
  • <0 Error

int ix_tcp_packet ( int  sd,
ix_net_t pnet 
)

Sends netpacket, which had to be set up properly

Parameters:
fd socket descriptor to send netpacket
pnet net packet to send
Returns:
  • 0 OK
  • <0 Error

int ix_udp_msg ( ix_net_t pnet,
unsigned char *  buf,
int  buflen 
)

Asynchronous send per udp (depreciated)


Generated on 4 Mar 2014 for ixtools by  doxygen 1.4.7