some network functions (to be continued)
[my-code/ivac.git] / src / inet.h
1 /* inet.h -- inet headers */
2
3 #ifndef INET_H
4 #define INET_H
5
6 /* includes */
7 #include "ivac.h"
8 #include <stdio.h>
9 #include <errno.h>
10 #include <string.h>
11 #include <sys/types.h>
12 #include <sys/socket.h>
13
14 /* net specific includes */
15 #include <netinet/in.h>
16
17 /* defines */
18 #define MAX_CONNECTIONS 32
19 #define IP_DIGITS 16
20 #define C_IN_USE (1<<0)
21 #define C_INFO_A (1<<1)
22 #define C_SOCKET (1<<2)
23 #define C_ESTABL (1<<3)
24 #define C_HANGUP (1<<4)
25
26 /* net specific variables */
27 typedef s_connection {
28   int fd;
29   char name[CHAR_USERNAME];
30   char ip[IP_DIGITS];
31   in_port_t port;
32   unsigned char status;
33 } t_connection;
34
35 typedef s_net {
36   int l_fd; /* listen file descriptor */
37   in_port_t l_port;
38   /* limited connections by now -- replaced by list management later */
39   int c_count;
40   t_connection connection[MAX_CONNECTIONS];
41 } t_net;
42
43 #endif
44