• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/samba-3.5.8/lib/replace/system/
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   Copyright (C) Jelmer Vernooij 2007
10
11     ** NOTE! The following LGPL license applies to the replace
12     ** library. This does NOT imply that all of Samba is released
13     ** under the LGPL
14
15   This library is free software; you can redistribute it and/or
16   modify it under the terms of the GNU Lesser General Public
17   License as published by the Free Software Foundation; either
18   version 3 of the License, or (at your option) any later version.
19
20   This library is distributed in the hope that it will be useful,
21   but WITHOUT ANY WARRANTY; without even the implied warranty of
22   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23   Lesser General Public License for more details.
24
25   You should have received a copy of the GNU Lesser General Public
26   License along with this library; if not, see <http://www.gnu.org/licenses/>.
27
28*/
29
30#ifndef LIBREPLACE_NETWORK_CHECKS
31#error "AC_LIBREPLACE_NETWORK_CHECKS missing in configure"
32#endif
33
34#ifdef HAVE_SYS_SOCKET_H
35#include <sys/socket.h>
36#endif
37
38#ifdef HAVE_UNIXSOCKET
39#include <sys/un.h>
40#endif
41
42#ifdef HAVE_NETINET_IN_H
43#include <netinet/in.h>
44#endif
45#ifdef HAVE_ARPA_INET_H
46#include <arpa/inet.h>
47#endif
48
49#ifdef HAVE_NETDB_H
50#include <netdb.h>
51#endif
52
53#ifdef HAVE_NETINET_TCP_H
54#include <netinet/tcp.h>
55#endif
56
57/*
58 * The next three defines are needed to access the IPTOS_* options
59 * on some systems.
60 */
61
62#ifdef HAVE_NETINET_IN_SYSTM_H
63#include <netinet/in_systm.h>
64#endif
65
66#ifdef HAVE_NETINET_IN_IP_H
67#include <netinet/in_ip.h>
68#endif
69
70#ifdef HAVE_NETINET_IP_H
71#include <netinet/ip.h>
72#endif
73
74#ifdef HAVE_NET_IF_H
75#include <net/if.h>
76#endif
77
78#ifdef HAVE_UNISTD_H
79#include <unistd.h>
80#endif
81
82#ifdef HAVE_SYS_IOCTL_H
83#include <sys/ioctl.h>
84#endif
85
86#ifdef HAVE_SYS_UIO_H
87#include <sys/uio.h>
88#endif
89
90#ifdef HAVE_STROPTS_H
91#include <stropts.h>
92#endif
93
94#ifndef HAVE_SOCKLEN_T
95#define HAVE_SOCKLEN_T
96typedef int socklen_t;
97#endif
98
99#if !defined (HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA)
100/* define is in "replace.h" */
101char *rep_inet_ntoa(struct in_addr ip);
102#endif
103
104#ifndef HAVE_INET_PTON
105/* define is in "replace.h" */
106int rep_inet_pton(int af, const char *src, void *dst);
107#endif
108
109#ifndef HAVE_INET_NTOP
110/* define is in "replace.h" */
111const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
112#endif
113
114#ifndef HAVE_INET_ATON
115/* define is in "replace.h" */
116int rep_inet_aton(const char *src, struct in_addr *dst);
117#endif
118
119#ifndef HAVE_CONNECT
120/* define is in "replace.h" */
121int rep_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
122#endif
123
124#ifndef HAVE_GETHOSTBYNAME
125/* define is in "replace.h" */
126struct hostent *rep_gethostbyname(const char *name);
127#endif
128
129#ifdef HAVE_IFADDRS_H
130#ifndef BCMARM
131#include <ifaddrs.h>
132#endif
133#endif
134
135#ifndef HAVE_STRUCT_IFADDRS
136struct ifaddrs {
137	struct ifaddrs   *ifa_next;         /* Pointer to next struct */
138	char             *ifa_name;         /* Interface name */
139	unsigned int     ifa_flags;         /* Interface flags */
140	struct sockaddr  *ifa_addr;         /* Interface address */
141	struct sockaddr  *ifa_netmask;      /* Interface netmask */
142#undef ifa_dstaddr
143	struct sockaddr  *ifa_dstaddr;      /* P2P interface destination */
144	void             *ifa_data;         /* Address specific data */
145};
146#endif
147
148#ifndef HAVE_GETIFADDRS
149int rep_getifaddrs(struct ifaddrs **);
150#endif
151
152#ifndef HAVE_FREEIFADDRS
153void rep_freeifaddrs(struct ifaddrs *);
154#endif
155
156#ifndef HAVE_SOCKETPAIR
157/* define is in "replace.h" */
158int rep_socketpair(int d, int type, int protocol, int sv[2]);
159#endif
160
161/*
162 * Some systems have getaddrinfo but not the
163 * defines needed to use it.
164 */
165
166/* Various macros that ought to be in <netdb.h>, but might not be */
167
168#ifndef EAI_FAIL
169#define EAI_BADFLAGS	(-1)
170#define EAI_NONAME	(-2)
171#define EAI_AGAIN	(-3)
172#define EAI_FAIL	(-4)
173#define EAI_FAMILY	(-6)
174#define EAI_SOCKTYPE	(-7)
175#define EAI_SERVICE	(-8)
176#define EAI_MEMORY	(-10)
177#define EAI_SYSTEM	(-11)
178#endif   /* !EAI_FAIL */
179
180#ifndef AI_PASSIVE
181#define AI_PASSIVE	0x0001
182#endif
183
184#ifndef AI_CANONNAME
185#define AI_CANONNAME	0x0002
186#endif
187
188#ifndef AI_NUMERICHOST
189/*
190 * some platforms don't support AI_NUMERICHOST; define as zero if using
191 * the system version of getaddrinfo...
192 */
193#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
194#define AI_NUMERICHOST	0
195#else
196#define AI_NUMERICHOST	0x0004
197#endif
198#endif
199
200/*
201 * Some of the functions in source3/lib/util_sock.c use AI_ADDRCONFIG. On QNX
202 * 6.3.0, this macro is defined but, if it's used, getaddrinfo will fail. This
203 * prevents smbd from opening any sockets.
204 *
205 * If I undefine AI_ADDRCONFIG on such systems and define it to be 0,
206 * this works around the issue.
207 */
208#ifdef __QNX__
209#include <sys/neutrino.h>
210#if _NTO_VERSION == 630
211#undef AI_ADDRCONFIG
212#endif
213#endif
214#ifndef AI_ADDRCONFIG
215/*
216 * logic copied from AI_NUMERICHOST
217 */
218#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
219#define AI_ADDRCONFIG	0
220#else
221#define AI_ADDRCONFIG	0x0020
222#endif
223#endif
224
225#ifndef AI_NUMERICSERV
226/*
227 * logic copied from AI_NUMERICHOST
228 */
229#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
230#define AI_NUMERICSERV	0
231#else
232#define AI_NUMERICSERV	0x0400
233#endif
234#endif
235
236#ifndef NI_NUMERICHOST
237#define NI_NUMERICHOST	1
238#endif
239
240#ifndef NI_NUMERICSERV
241#define NI_NUMERICSERV	2
242#endif
243
244#ifndef NI_NOFQDN
245#define NI_NOFQDN	4
246#endif
247
248#ifndef NI_NAMEREQD
249#define NI_NAMEREQD 	8
250#endif
251
252#ifndef NI_DGRAM
253#define NI_DGRAM	16
254#endif
255
256
257#ifndef NI_MAXHOST
258#define NI_MAXHOST	1025
259#endif
260
261#ifndef NI_MAXSERV
262#define NI_MAXSERV	32
263#endif
264
265/*
266 * glibc on linux doesn't seem to have MSG_WAITALL
267 * defined. I think the kernel has it though..
268 */
269#ifndef MSG_WAITALL
270#define MSG_WAITALL 0
271#endif
272
273#ifndef INADDR_LOOPBACK
274#define INADDR_LOOPBACK 0x7f000001
275#endif
276
277#ifndef INADDR_NONE
278#define INADDR_NONE 0xffffffff
279#endif
280
281#ifndef EAFNOSUPPORT
282#define EAFNOSUPPORT EINVAL
283#endif
284
285#ifndef INET_ADDRSTRLEN
286#define INET_ADDRSTRLEN 16
287#endif
288
289#ifndef INET6_ADDRSTRLEN
290#define INET6_ADDRSTRLEN 46
291#endif
292
293#ifndef HOST_NAME_MAX
294#define HOST_NAME_MAX 255
295#endif
296
297#ifndef MAXHOSTNAMELEN
298#define MAXHOSTNAMELEN HOST_NAME_MAX
299#endif
300
301#ifndef HAVE_SA_FAMILY_T
302#define HAVE_SA_FAMILY_T
303typedef unsigned short int sa_family_t;
304#endif
305
306#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
307#define HAVE_STRUCT_SOCKADDR_STORAGE
308#ifdef HAVE_STRUCT_SOCKADDR_IN6
309#define sockaddr_storage sockaddr_in6
310#define ss_family sin6_family
311#define HAVE_SS_FAMILY 1
312#else
313#define sockaddr_storage sockaddr_in
314#define ss_family sin_family
315#define HAVE_SS_FAMILY 1
316#endif
317#endif
318
319#ifndef HAVE_SS_FAMILY
320#ifdef HAVE___SS_FAMILY
321#define ss_family __ss_family
322#define HAVE_SS_FAMILY 1
323#endif
324#endif
325
326#ifndef IOV_MAX
327# ifdef UIO_MAXIOV
328#  define IOV_MAX UIO_MAXIOV
329# else
330#  ifdef __sgi
331    /*
332     * IRIX 6.5 has sysconf(_SC_IOV_MAX)
333     * which might return 512 or bigger
334     */
335#   define IOV_MAX 512
336#  else
337#   error IOV_MAX and UIO_MAXIOV undefined
338#  endif
339# endif
340#endif
341
342#ifndef HAVE_STRUCT_ADDRINFO
343#define HAVE_STRUCT_ADDRINFO
344struct addrinfo {
345	int			ai_flags;
346	int			ai_family;
347	int			ai_socktype;
348	int			ai_protocol;
349	socklen_t		ai_addrlen;
350	struct sockaddr 	*ai_addr;
351	char			*ai_canonname;
352	struct addrinfo		*ai_next;
353};
354#endif   /* HAVE_STRUCT_ADDRINFO */
355
356#if !defined(HAVE_GETADDRINFO)
357#include "getaddrinfo.h"
358#endif
359
360/* Needed for some systems that don't define it (Solaris). */
361#ifndef ifr_netmask
362#define ifr_netmask ifr_addr
363#endif
364
365/* Some old Linux systems have broken header files */
366#ifdef HAVE_IPV6
367#ifdef HAVE_LINUX_IPV6_V6ONLY_26
368#define IPV6_V6ONLY 26
369#endif /* HAVE_LINUX_IPV6_V6ONLY_26 */
370#endif /* HAVE_IPV6 */
371
372#ifdef SOCKET_WRAPPER
373#ifndef SOCKET_WRAPPER_DISABLE
374#ifndef SOCKET_WRAPPER_NOT_REPLACE
375#define SOCKET_WRAPPER_REPLACE
376#endif /* SOCKET_WRAPPER_NOT_REPLACE */
377#include "../socket_wrapper/socket_wrapper.h"
378#endif /* SOCKET_WRAPPER_DISABLE */
379#endif /* SOCKET_WRAPPER */
380
381#endif
382