1 #ifndef _system_network_h
2 #define _system_network_h
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
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>
33 #ifdef HAVE_UNIXSOCKET
37 #ifdef HAVE_NETINET_IN_H
38 #include <netinet/in.h>
40 #ifdef HAVE_ARPA_INET_H
41 #include <arpa/inet.h>
48 #ifdef HAVE_NETINET_TCP_H
49 #include <netinet/tcp.h>
53 * The next three defines are needed to access the IPTOS_* options
57 #ifdef HAVE_NETINET_IN_SYSTM_H
58 #include <netinet/in_systm.h>
61 #ifdef HAVE_NETINET_IN_IP_H
62 #include <netinet/in_ip.h>
65 #ifdef HAVE_NETINET_IP_H
66 #include <netinet/ip.h>
77 #ifdef HAVE_SYS_IOCTL_H
78 #include <sys/ioctl.h>
85 #ifdef REPLACE_INET_NTOA
86 /* define is in "replace.h" */
87 char *rep_inet_ntoa(struct in_addr ip);
90 #ifndef HAVE_INET_PTON
91 /* define is in "replace.h" */
92 int rep_inet_pton(int af, const char *src, void *dst);
95 #ifndef HAVE_INET_NTOP
96 /* define is in "replace.h" */
97 const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
101 * Some systems have getaddrinfo but not the
102 * defines needed to use it.
105 /* Various macros that ought to be in <netdb.h>, but might not be */
108 #define EAI_BADFLAGS (-1)
109 #define EAI_NONAME (-2)
110 #define EAI_AGAIN (-3)
111 #define EAI_FAIL (-4)
112 #define EAI_FAMILY (-6)
113 #define EAI_SOCKTYPE (-7)
114 #define EAI_SERVICE (-8)
115 #define EAI_MEMORY (-10)
116 #define EAI_SYSTEM (-11)
117 #endif /* !EAI_FAIL */
120 #define AI_PASSIVE 0x0001
124 #define AI_CANONNAME 0x0002
127 #ifndef AI_NUMERICHOST
129 * some platforms don't support AI_NUMERICHOST; define as zero if using
130 * the system version of getaddrinfo...
132 #if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
133 #define AI_NUMERICHOST 0
135 #define AI_NUMERICHOST 0x0004
139 #ifndef AI_ADDRCONFIG
140 #define AI_ADDRCONFIG 0x0020
143 #ifndef AI_NUMERICSERV
145 * logic copied from AI_NUMERICHOST
147 #if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
148 #define AI_NUMERICSERV 0
150 #define AI_NUMERICSERV 0x0400
154 #ifndef NI_NUMERICHOST
155 #define NI_NUMERICHOST 1
158 #ifndef NI_NUMERICSERV
159 #define NI_NUMERICSERV 2
167 #define NI_NAMEREQD 8
176 #define NI_MAXHOST 1025
180 #define NI_MAXSERV 32
184 * glibc on linux doesn't seem to have MSG_WAITALL
185 * defined. I think the kernel has it though..
188 #define MSG_WAITALL 0
191 #ifndef INADDR_LOOPBACK
192 #define INADDR_LOOPBACK 0x7f000001
196 #define INADDR_NONE 0xffffffff
200 #define EAFNOSUPPORT EINVAL
203 #ifndef INET_ADDRSTRLEN
204 #define INET_ADDRSTRLEN 16
207 #ifndef INET6_ADDRSTRLEN
208 #define INET6_ADDRSTRLEN 46
211 #ifndef HOST_NAME_MAX
212 #define HOST_NAME_MAX 256
215 #ifndef HAVE_SOCKLEN_T
216 #define HAVE_SOCKLEN_T
217 typedef int socklen_t;
220 #ifndef HAVE_SA_FAMILY_T
221 #define HAVE_SA_FAMILY_T
222 typedef unsigned short int sa_family_t;
225 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
226 #define HAVE_STRUCT_SOCKADDR_STORAGE
227 #ifdef HAVE_STRUCT_SOCKADDR_IN6
228 #define sockaddr_storage sockaddr_in6
229 #define ss_family sin6_family
231 #define sockaddr_storage sockaddr_in
232 #define ss_family sin_family
236 #ifndef HAVE_STRUCT_ADDRINFO
237 #define HAVE_STRUCT_ADDRINFO
243 socklen_t ai_addrlen;
244 struct sockaddr *ai_addr;
246 struct addrinfo *ai_next;
248 #endif /* HAVE_STRUCT_ADDRINFO */
250 #if !defined(HAVE_GETADDRINFO)
251 #include "getaddrinfo.h"
254 /* Needed for some systems that don't define it (Solaris). */
256 #define ifr_netmask ifr_addrs
259 #ifdef SOCKET_WRAPPER
260 #ifndef SOCKET_WRAPPER_NOT_REPLACE
261 #define SOCKET_WRAPPER_REPLACE
263 #include "lib/socket_wrapper/socket_wrapper.h"