1 | #ifndef USOCKET_H |
2 | #define USOCKET_H |
3 | /*=========================================================================*\ |
4 | * Socket compatibilization module for Unix |
5 | * LuaSocket toolkit |
6 | \*=========================================================================*/ |
7 | |
8 | /*=========================================================================*\ |
9 | * BSD include files |
10 | \*=========================================================================*/ |
11 | /* error codes */ |
12 | #include <errno.h> |
13 | /* close function */ |
14 | #include <unistd.h> |
15 | /* fnctnl function and associated constants */ |
16 | #include <fcntl.h> |
17 | /* struct sockaddr */ |
18 | #include <sys/types.h> |
19 | /* socket function */ |
20 | #include <sys/socket.h> |
21 | /* struct timeval */ |
22 | #include <sys/time.h> |
23 | /* gethostbyname and gethostbyaddr functions */ |
24 | #include <netdb.h> |
25 | /* sigpipe handling */ |
26 | #include <signal.h> |
27 | /* IP stuff*/ |
28 | #include <netinet/in.h> |
29 | #include <arpa/inet.h> |
30 | /* TCP options (nagle algorithm disable) */ |
31 | #include <netinet/tcp.h> |
32 | #include <net/if.h> |
33 | |
34 | #ifndef SO_REUSEPORT |
35 | #define SO_REUSEPORT SO_REUSEADDR |
36 | #endif |
37 | |
38 | /* Some platforms use IPV6_JOIN_GROUP instead if |
39 | * IPV6_ADD_MEMBERSHIP. The semantics are same, though. */ |
40 | #ifndef IPV6_ADD_MEMBERSHIP |
41 | #ifdef IPV6_JOIN_GROUP |
42 | #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP |
43 | #endif /* IPV6_JOIN_GROUP */ |
44 | #endif /* !IPV6_ADD_MEMBERSHIP */ |
45 | |
46 | /* Same with IPV6_DROP_MEMBERSHIP / IPV6_LEAVE_GROUP. */ |
47 | #ifndef IPV6_DROP_MEMBERSHIP |
48 | #ifdef IPV6_LEAVE_GROUP |
49 | #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP |
50 | #endif /* IPV6_LEAVE_GROUP */ |
51 | #endif /* !IPV6_DROP_MEMBERSHIP */ |
52 | |
53 | typedef int t_socket; |
54 | typedef t_socket *p_socket; |
55 | typedef struct sockaddr_storage t_sockaddr_storage; |
56 | |
57 | #define SOCKET_INVALID (-1) |
58 | |
59 | #endif /* USOCKET_H */ |
60 | |