~ubuntu-branches/ubuntu/saucy/sssd/saucy

« back to all changes in this revision

Viewing changes to replace/system/network.h

  • Committer: Stéphane Graber
  • Date: 2011-06-15 16:23:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: stgraber@ubuntu.com-20110615162314-rbhoppnpaxfqo5q7
Merge 1.5.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
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_STROPTS_H
87
 
#include <stropts.h>
88
 
#endif
89
 
 
90
 
#ifndef HAVE_SOCKLEN_T
91
 
#define HAVE_SOCKLEN_T
92
 
typedef int socklen_t;
93
 
#endif
94
 
 
95
 
#if !defined (HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA)
96
 
/* define is in "replace.h" */
97
 
char *rep_inet_ntoa(struct in_addr ip);
98
 
#endif
99
 
 
100
 
#ifndef HAVE_INET_PTON
101
 
/* define is in "replace.h" */
102
 
int rep_inet_pton(int af, const char *src, void *dst);
103
 
#endif
104
 
 
105
 
#ifndef HAVE_INET_NTOP
106
 
/* define is in "replace.h" */
107
 
const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
108
 
#endif
109
 
 
110
 
#ifndef HAVE_INET_ATON
111
 
/* define is in "replace.h" */
112
 
int rep_inet_aton(const char *src, struct in_addr *dst);
113
 
#endif
114
 
 
115
 
#ifndef HAVE_CONNECT
116
 
/* define is in "replace.h" */
117
 
int rep_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
118
 
#endif
119
 
 
120
 
#ifndef HAVE_GETHOSTBYNAME
121
 
/* define is in "replace.h" */
122
 
struct hostent *rep_gethostbyname(const char *name);
123
 
#endif
124
 
 
125
 
#ifdef HAVE_IFADDRS_H
126
 
#include <ifaddrs.h>
127
 
#endif
128
 
 
129
 
#ifndef HAVE_STRUCT_IFADDRS
130
 
struct ifaddrs {
131
 
        struct ifaddrs   *ifa_next;         /* Pointer to next struct */
132
 
        char             *ifa_name;         /* Interface name */
133
 
        unsigned int     ifa_flags;         /* Interface flags */
134
 
        struct sockaddr  *ifa_addr;         /* Interface address */
135
 
        struct sockaddr  *ifa_netmask;      /* Interface netmask */
136
 
#undef ifa_dstaddr
137
 
        struct sockaddr  *ifa_dstaddr;      /* P2P interface destination */
138
 
        void             *ifa_data;         /* Address specific data */
139
 
};
140
 
#endif
141
 
 
142
 
#ifndef HAVE_GETIFADDRS
143
 
int rep_getifaddrs(struct ifaddrs **);
144
 
#endif
145
 
 
146
 
#ifndef HAVE_FREEIFADDRS
147
 
void rep_freeifaddrs(struct ifaddrs *);
148
 
#endif
149
 
 
150
 
#ifndef HAVE_SOCKETPAIR
151
 
/* define is in "replace.h" */
152
 
int rep_socketpair(int d, int type, int protocol, int sv[2]);
153
 
#endif
154
 
 
155
 
/*
156
 
 * Some systems have getaddrinfo but not the
157
 
 * defines needed to use it.
158
 
 */
159
 
 
160
 
/* Various macros that ought to be in <netdb.h>, but might not be */
161
 
 
162
 
#ifndef EAI_FAIL
163
 
#define EAI_BADFLAGS    (-1)
164
 
#define EAI_NONAME      (-2)
165
 
#define EAI_AGAIN       (-3)
166
 
#define EAI_FAIL        (-4)
167
 
#define EAI_FAMILY      (-6)
168
 
#define EAI_SOCKTYPE    (-7)
169
 
#define EAI_SERVICE     (-8)
170
 
#define EAI_MEMORY      (-10)
171
 
#define EAI_SYSTEM      (-11)
172
 
#endif   /* !EAI_FAIL */
173
 
 
174
 
#ifndef AI_PASSIVE
175
 
#define AI_PASSIVE      0x0001
176
 
#endif
177
 
 
178
 
#ifndef AI_CANONNAME
179
 
#define AI_CANONNAME    0x0002
180
 
#endif
181
 
 
182
 
#ifndef AI_NUMERICHOST
183
 
/*
184
 
 * some platforms don't support AI_NUMERICHOST; define as zero if using
185
 
 * the system version of getaddrinfo...
186
 
 */
187
 
#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
188
 
#define AI_NUMERICHOST  0
189
 
#else
190
 
#define AI_NUMERICHOST  0x0004
191
 
#endif
192
 
#endif
193
 
 
194
 
#ifndef AI_ADDRCONFIG
195
 
/*
196
 
 * logic copied from AI_NUMERICHOST
197
 
 */
198
 
#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
199
 
#define AI_ADDRCONFIG   0
200
 
#else
201
 
#define AI_ADDRCONFIG   0x0020
202
 
#endif
203
 
#endif
204
 
 
205
 
#ifndef AI_NUMERICSERV
206
 
/*
207
 
 * logic copied from AI_NUMERICHOST
208
 
 */
209
 
#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
210
 
#define AI_NUMERICSERV  0
211
 
#else
212
 
#define AI_NUMERICSERV  0x0400
213
 
#endif
214
 
#endif
215
 
 
216
 
#ifndef NI_NUMERICHOST
217
 
#define NI_NUMERICHOST  1
218
 
#endif
219
 
 
220
 
#ifndef NI_NUMERICSERV
221
 
#define NI_NUMERICSERV  2
222
 
#endif
223
 
 
224
 
#ifndef NI_NOFQDN
225
 
#define NI_NOFQDN       4
226
 
#endif
227
 
 
228
 
#ifndef NI_NAMEREQD
229
 
#define NI_NAMEREQD     8
230
 
#endif
231
 
 
232
 
#ifndef NI_DGRAM
233
 
#define NI_DGRAM        16
234
 
#endif
235
 
 
236
 
 
237
 
#ifndef NI_MAXHOST
238
 
#define NI_MAXHOST      1025
239
 
#endif
240
 
 
241
 
#ifndef NI_MAXSERV
242
 
#define NI_MAXSERV      32
243
 
#endif
244
 
 
245
 
/*
246
 
 * glibc on linux doesn't seem to have MSG_WAITALL
247
 
 * defined. I think the kernel has it though..
248
 
 */
249
 
#ifndef MSG_WAITALL
250
 
#define MSG_WAITALL 0
251
 
#endif
252
 
 
253
 
#ifndef INADDR_LOOPBACK
254
 
#define INADDR_LOOPBACK 0x7f000001
255
 
#endif
256
 
 
257
 
#ifndef INADDR_NONE
258
 
#define INADDR_NONE 0xffffffff
259
 
#endif
260
 
 
261
 
#ifndef EAFNOSUPPORT
262
 
#define EAFNOSUPPORT EINVAL
263
 
#endif
264
 
 
265
 
#ifndef INET_ADDRSTRLEN
266
 
#define INET_ADDRSTRLEN 16
267
 
#endif
268
 
 
269
 
#ifndef INET6_ADDRSTRLEN
270
 
#define INET6_ADDRSTRLEN 46
271
 
#endif
272
 
 
273
 
#ifndef HOST_NAME_MAX
274
 
#define HOST_NAME_MAX 256
275
 
#endif
276
 
 
277
 
#ifndef HAVE_SA_FAMILY_T
278
 
#define HAVE_SA_FAMILY_T
279
 
typedef unsigned short int sa_family_t;
280
 
#endif
281
 
 
282
 
#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
283
 
#define HAVE_STRUCT_SOCKADDR_STORAGE
284
 
#ifdef HAVE_STRUCT_SOCKADDR_IN6
285
 
#define sockaddr_storage sockaddr_in6
286
 
#define ss_family sin6_family
287
 
#define HAVE_SS_FAMILY 1
288
 
#else
289
 
#define sockaddr_storage sockaddr_in
290
 
#define ss_family sin_family
291
 
#define HAVE_SS_FAMILY 1
292
 
#endif
293
 
#endif
294
 
 
295
 
#ifndef HAVE_SS_FAMILY
296
 
#ifdef HAVE___SS_FAMILY
297
 
#define ss_family __ss_family
298
 
#define HAVE_SS_FAMILY 1
299
 
#endif
300
 
#endif
301
 
 
302
 
#ifndef HAVE_STRUCT_ADDRINFO
303
 
#define HAVE_STRUCT_ADDRINFO
304
 
struct addrinfo {
305
 
        int                     ai_flags;
306
 
        int                     ai_family;
307
 
        int                     ai_socktype;
308
 
        int                     ai_protocol;
309
 
        socklen_t               ai_addrlen;
310
 
        struct sockaddr         *ai_addr;
311
 
        char                    *ai_canonname;
312
 
        struct addrinfo         *ai_next;
313
 
};
314
 
#endif   /* HAVE_STRUCT_ADDRINFO */
315
 
 
316
 
#if !defined(HAVE_GETADDRINFO)
317
 
#include "getaddrinfo.h"
318
 
#endif
319
 
 
320
 
/* Needed for some systems that don't define it (Solaris). */
321
 
#ifndef ifr_netmask
322
 
#define ifr_netmask ifr_addr
323
 
#endif
324
 
 
325
 
#ifdef SOCKET_WRAPPER
326
 
#ifndef SOCKET_WRAPPER_NOT_REPLACE
327
 
#define SOCKET_WRAPPER_REPLACE
328
 
#endif
329
 
#include "../socket_wrapper/socket_wrapper.h"
330
 
#endif
331
 
 
332
 
#endif