1 /* network.h -- network headers */
10 #include <sys/types.h>
11 #include <sys/socket.h>
14 /* net specific includes */
15 #include <netinet/in.h>
16 #include <arpa/inet.h>
19 #define MAX_CONNECTIONS 32
22 #define C_IN_USE (1<<0)
23 #define C_INFO_A (1<<1)
24 #define C_SOCKET (1<<2)
25 #define C_ESTABL (1<<3)
26 #define C_HANGUP (1<<4)
28 #define SEND_N_MAX 128
33 #define MAX_LISTEN_QUEUE 32
35 /* net specific variables */
36 typedef struct s_connection {
41 unsigned short cap; /* capabilities */
44 typedef struct s_net {
45 int l_fd; /* listen file descriptor */
48 /* limited connections by now -- replaced by list management later */
50 t_connection connection[MAX_CONNECTIONS];
51 unsigned int sendmask; /* 32 bits for maximum of 32 connections */
54 /* function prototypes */
55 int network_init(t_net *net);
56 int network_shutdown(t_net *net);
57 int network_set_listen_port(t_net *net,in_port_t port);
58 int network_manage_connection(t_net *net);
59 int network_manage_incoming(t_net *net);
60 int network_send(int fd,unsigned char *data,int datasize);
61 int network_receive(int fd,unsigned char *data,int datasize);