[libreplace] define AI_NUMERICSERV as it's used in getaddrinfo.c
[Samba/bb.git] / source3 / lib / replace / system / network.h
blobc7b499a932cba6303df19fd92f724349382a014c
1 #ifndef _system_network_h
2 #define _system_network_h
3 /*
4 Unix SMB/CIFS implementation.
6 networking system include wrappers
8 Copyright (C) Andrew Tridgell 2004
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
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.
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.
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/>.
29 #ifdef HAVE_SYS_SOCKET_H
30 #include <sys/socket.h>
31 #endif
33 #ifdef HAVE_UNIXSOCKET
34 #include <sys/un.h>
35 #endif
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
44 #ifdef HAVE_NETDB_H
45 #include <netdb.h>
46 #endif
48 #ifdef HAVE_NETINET_TCP_H
49 #include <netinet/tcp.h>
50 #endif
53 * The next three defines are needed to access the IPTOS_* options
54 * on some systems.
57 #ifdef HAVE_NETINET_IN_SYSTM_H
58 #include <netinet/in_systm.h>
59 #endif
61 #ifdef HAVE_NETINET_IN_IP_H
62 #include <netinet/in_ip.h>
63 #endif
65 #ifdef HAVE_NETINET_IP_H
66 #include <netinet/ip.h>
67 #endif
69 #ifdef HAVE_NET_IF_H
70 #include <net/if.h>
71 #endif
73 #ifdef HAVE_UNISTD_H
74 #include <unistd.h>
75 #endif
77 #ifdef HAVE_SYS_IOCTL_H
78 #include <sys/ioctl.h>
79 #endif
81 #ifdef REPLACE_INET_NTOA
82 /* define is in "replace.h" */
83 char *rep_inet_ntoa(struct in_addr ip);
84 #endif
86 #ifndef HAVE_INET_PTON
87 /* define is in "replace.h" */
88 int rep_inet_pton(int af, const char *src, void *dst);
89 #endif
91 #ifndef HAVE_INET_NTOP
92 /* define is in "replace.h" */
93 const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
94 #endif
97 * Some systems have getaddrinfo but not the
98 * defines needed to use it.
101 /* Various macros that ought to be in <netdb.h>, but might not be */
103 #ifndef EAI_FAIL
104 #define EAI_BADFLAGS (-1)
105 #define EAI_NONAME (-2)
106 #define EAI_AGAIN (-3)
107 #define EAI_FAIL (-4)
108 #define EAI_FAMILY (-6)
109 #define EAI_SOCKTYPE (-7)
110 #define EAI_SERVICE (-8)
111 #define EAI_MEMORY (-10)
112 #define EAI_SYSTEM (-11)
113 #endif /* !EAI_FAIL */
115 #ifndef AI_PASSIVE
116 #define AI_PASSIVE 0x0001
117 #endif
119 #ifndef AI_CANONNAME
120 #define AI_CANONNAME 0x0002
121 #endif
123 #ifndef AI_NUMERICHOST
125 * some platforms don't support AI_NUMERICHOST; define as zero if using
126 * the system version of getaddrinfo...
128 #if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
129 #define AI_NUMERICHOST 0
130 #else
131 #define AI_NUMERICHOST 0x0004
132 #endif
133 #endif
135 #ifndef AI_ADDRCONFIG
136 #define AI_ADDRCONFIG 0x0020
137 #endif
139 #ifndef AI_NUMERICSERV
141 * logic copied from AI_NUMERICHOST
143 #if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
144 #define AI_NUMERICSERV 0
145 #else
146 #define AI_NUMERICSERV 0x0400
147 #endif
148 #endif
150 #ifndef NI_NUMERICHOST
151 #define NI_NUMERICHOST 1
152 #endif
154 #ifndef NI_NUMERICSERV
155 #define NI_NUMERICSERV 2
156 #endif
158 #ifndef NI_NOFQDN
159 #define NI_NOFQDN 4
160 #endif
162 #ifndef NI_NAMEREQD
163 #define NI_NAMEREQD 8
164 #endif
166 #ifndef NI_DGRAM
167 #define NI_DGRAM 16
168 #endif
171 #ifndef NI_MAXHOST
172 #define NI_MAXHOST 1025
173 #endif
175 #ifndef NI_MAXSERV
176 #define NI_MAXSERV 32
177 #endif
180 * glibc on linux doesn't seem to have MSG_WAITALL
181 * defined. I think the kernel has it though..
183 #ifndef MSG_WAITALL
184 #define MSG_WAITALL 0
185 #endif
187 #ifndef INADDR_LOOPBACK
188 #define INADDR_LOOPBACK 0x7f000001
189 #endif
191 #ifndef INADDR_NONE
192 #define INADDR_NONE 0xffffffff
193 #endif
195 #ifndef EAFNOSUPPORT
196 #define EAFNOSUPPORT EINVAL
197 #endif
199 #ifndef INET_ADDRSTRLEN
200 #define INET_ADDRSTRLEN 16
201 #endif
203 #ifndef INET6_ADDRSTRLEN
204 #define INET6_ADDRSTRLEN 46
205 #endif
207 #ifndef HOST_NAME_MAX
208 #define HOST_NAME_MAX 256
209 #endif
211 #ifndef HAVE_SOCKLEN_T
212 #define HAVE_SOCKLEN_T
213 typedef int socklen_t;
214 #endif
216 #ifndef HAVE_SA_FAMILY_T
217 #define HAVE_SA_FAMILY_T
218 typedef unsigned short int sa_family_t;
219 #endif
221 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
222 #define HAVE_STRUCT_SOCKADDR_STORAGE
223 #ifdef HAVE_STRUCT_SOCKADDR_IN6
224 #define sockaddr_storage sockaddr_in6
225 #define ss_family sin6_family
226 #else
227 #define sockaddr_storage sockaddr_in
228 #define ss_family sin_family
229 #endif
230 #endif
232 #ifndef HAVE_STRUCT_ADDRINFO
233 #define HAVE_STRUCT_ADDRINFO
234 struct addrinfo {
235 int ai_flags;
236 int ai_family;
237 int ai_socktype;
238 int ai_protocol;
239 socklen_t ai_addrlen;
240 struct sockaddr *ai_addr;
241 char *ai_canonname;
242 struct addrinfo *ai_next;
244 #endif /* HAVE_STRUCT_ADDRINFO */
246 #if !defined(HAVE_GETADDRINFO)
247 #include "getaddrinfo.h"
248 #endif
250 #ifdef SOCKET_WRAPPER
251 #ifndef SOCKET_WRAPPER_NOT_REPLACE
252 #define SOCKET_WRAPPER_REPLACE
253 #endif
254 #include "lib/socket_wrapper/socket_wrapper.h"
255 #endif
257 #endif