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>
81 #ifdef REPLACE_INET_NTOA
82 /* define is in "replace.h" */
83 char *rep_inet_ntoa(struct in_addr ip);
86 #ifndef HAVE_INET_PTON
87 /* define is in "replace.h" */
88 int rep_inet_pton(int af, const char *src, void *dst);
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);
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 */
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 */
116 #define AI_PASSIVE 0x0001
120 #define AI_CANONNAME 0x0002
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
131 #define AI_NUMERICHOST 0x0004
135 #ifndef AI_ADDRCONFIG
136 #define AI_ADDRCONFIG 0x0020
139 #ifndef NI_NUMERICHOST
140 #define NI_NUMERICHOST 1
143 #ifndef NI_NUMERICSERV
144 #define NI_NUMERICSERV 2
152 #define NI_NAMEREQD 8
161 #define NI_MAXHOST 1025
165 #define NI_MAXSERV 32
169 * glibc on linux doesn't seem to have MSG_WAITALL
170 * defined. I think the kernel has it though..
173 #define MSG_WAITALL 0
176 #ifndef INADDR_LOOPBACK
177 #define INADDR_LOOPBACK 0x7f000001
181 #define INADDR_NONE 0xffffffff
185 #define EAFNOSUPPORT EINVAL
188 #ifndef INET_ADDRSTRLEN
189 #define INET_ADDRSTRLEN 16
192 #ifndef INET6_ADDRSTRLEN
193 #define INET6_ADDRSTRLEN 46
196 #ifndef HOST_NAME_MAX
197 #define HOST_NAME_MAX 256
200 #ifndef HAVE_SOCKLEN_T
201 #define HAVE_SOCKLEN_T
202 typedef int socklen_t;
205 #ifndef HAVE_SA_FAMILY_T
206 #define HAVE_SA_FAMILY_T
207 typedef unsigned short int sa_family_t;
210 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
211 #define HAVE_STRUCT_SOCKADDR_STORAGE
212 #ifdef HAVE_STRUCT_SOCKADDR_IN6
213 #define sockaddr_storage sockaddr_in6
214 #define ss_family sin6_family
216 #define sockaddr_storage sockaddr_in
217 #define ss_family sin_family
221 #ifndef HAVE_STRUCT_ADDRINFO
222 #define HAVE_STRUCT_ADDRINFO
228 socklen_t ai_addrlen;
229 struct sockaddr *ai_addr;
231 struct addrinfo *ai_next;
233 #endif /* HAVE_STRUCT_ADDRINFO */
235 #if !defined(HAVE_GETADDRINFO)
236 #include "getaddrinfo.h"
239 #ifdef SOCKET_WRAPPER
240 #ifndef SOCKET_WRAPPER_NOT_REPLACE
241 #define SOCKET_WRAPPER_REPLACE
243 #include "lib/socket_wrapper/socket_wrapper.h"