missing stuff from samba4's libreplace
[jpeach/samba.git] / source / lib / replace / system / network.h
1 #ifndef _system_network_h
2 #define _system_network_h
3 /* 
4    Unix SMB/CIFS implementation.
5
6    networking system include wrappers
7
8    Copyright (C) Andrew Tridgell 2004
9    
10      ** NOTE! The following LGPL license applies to the replace
11      ** library. This does NOT imply that all of Samba is released
12      ** under the LGPL
13    
14    This library is free software; you can redistribute it and/or
15    modify it under the terms of the GNU Lesser General Public
16    License as published by the Free Software Foundation; either
17    version 3 of the License, or (at your option) any later version.
18
19    This library is distributed in the hope that it will be useful,
20    but WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22    Lesser General Public License for more details.
23
24    You should have received a copy of the GNU Lesser General Public
25    License along with this library; if not, see <http://www.gnu.org/licenses/>.
26
27 */
28
29 #ifdef HAVE_SYS_SOCKET_H
30 #include <sys/socket.h>
31 #endif
32
33 #ifdef HAVE_UNIXSOCKET
34 #include <sys/un.h>
35 #endif
36
37 #ifdef HAVE_NETINET_IN_H
38 #include <netinet/in.h>
39 #endif
40 #ifdef HAVE_ARPA_INET_H
41 #include <arpa/inet.h>
42 #endif
43
44 #ifdef HAVE_NETDB_H
45 #include <netdb.h>
46 #endif
47
48 #ifdef HAVE_NETINET_TCP_H
49 #include <netinet/tcp.h>
50 #endif
51
52 #if !defined(HAVE_GETADDRINFO)
53 #include "getaddrinfo.h"
54 #endif
55
56 /*
57  * The next three defines are needed to access the IPTOS_* options
58  * on some systems.
59  */
60
61 #ifdef HAVE_NETINET_IN_SYSTM_H
62 #include <netinet/in_systm.h>
63 #endif
64
65 #ifdef HAVE_NETINET_IN_IP_H
66 #include <netinet/in_ip.h>
67 #endif
68
69 #ifdef HAVE_NETINET_IP_H
70 #include <netinet/ip.h>
71 #endif
72
73 #ifdef HAVE_NET_IF_H
74 #include <net/if.h>
75 #endif
76
77 #ifdef HAVE_UNISTD_H
78 #include <unistd.h>
79 #endif
80
81 #ifdef HAVE_SYS_IOCTL_H
82 #include <sys/ioctl.h>
83 #endif
84
85 #ifdef SOCKET_WRAPPER
86 #ifndef SOCKET_WRAPPER_NOT_REPLACE
87 #define SOCKET_WRAPPER_REPLACE
88 #endif
89 #include "lib/socket_wrapper/socket_wrapper.h"
90 #endif
91
92 #ifdef REPLACE_INET_NTOA
93 /* define is in "replace.h" */
94 char *rep_inet_ntoa(struct in_addr ip);
95 #endif
96
97 #ifndef HAVE_INET_PTON
98 /* define is in "replace.h" */
99 int rep_inet_pton(int af, const char *src, void *dst);
100 #endif
101
102 #ifndef HAVE_INET_NTOP
103 /* define is in "replace.h" */
104 const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
105 #endif
106
107 /*
108  * glibc on linux doesn't seem to have MSG_WAITALL
109  * defined. I think the kernel has it though..
110  */
111 #ifndef MSG_WAITALL
112 #define MSG_WAITALL 0
113 #endif
114
115 #ifndef INADDR_LOOPBACK
116 #define INADDR_LOOPBACK 0x7f000001
117 #endif
118
119 #ifndef INADDR_NONE
120 #define INADDR_NONE 0xffffffff
121 #endif
122
123 #ifndef EAFNOSUPPORT
124 #define EAFNOSUPPORT EINVAL
125 #endif
126
127 #ifndef INET_ADDRSTRLEN
128 #define INET_ADDRSTRLEN 16
129 #endif
130
131 #ifndef INET6_ADDRSTRLEN
132 #define INET6_ADDRSTRLEN 46
133 #endif
134
135 #ifndef HAVE_SOCKLEN_T
136 typedef int socklen_t;
137 #endif
138
139 #ifndef HAVE_SA_FAMILY_T
140 typedef unsigned short int sa_family_t;
141 #endif
142
143 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
144 #ifdef HAVE_STRUCT_SOCKADDR_IN6
145 #define sockaddr_storage sockaddr_in6
146 #define ss_family sin6_family
147 #else
148 #define sockaddr_storage sockaddr_in
149 #define ss_family sin_family
150 #endif
151 #endif
152
153 #ifndef HOST_NAME_MAX
154 #define HOST_NAME_MAX 256
155 #endif
156
157 #endif