~ubuntu-branches/ubuntu/vivid/ctdb/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/replace/system/network.h

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Parent
  • Date: 2008-04-26 15:21:27 UTC
  • Revision ID: james.westby@ubuntu.com-20080426152127-58mv5ojv5q362ise
Tags: upstream-1.0.34+git200804242206
ImportĀ upstreamĀ versionĀ 1.0.34+git200804242206

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
#ifdef HAVE_SYS_SOCKET_H
 
31
#include <sys/socket.h>
 
32
#endif
 
33
 
 
34
#ifdef HAVE_UNIXSOCKET
 
35
#include <sys/un.h>
 
36
#endif
 
37
 
 
38
#ifdef HAVE_NETINET_IN_H
 
39
#include <netinet/in.h>
 
40
#endif
 
41
#ifdef HAVE_ARPA_INET_H
 
42
#include <arpa/inet.h>
 
43
#endif
 
44
 
 
45
#ifdef HAVE_NETDB_H
 
46
#include <netdb.h>
 
47
#endif
 
48
 
 
49
#ifdef HAVE_NETINET_TCP_H
 
50
#include <netinet/tcp.h>
 
51
#endif
 
52
 
 
53
/*
 
54
 * The next three defines are needed to access the IPTOS_* options
 
55
 * on some systems.
 
56
 */
 
57
 
 
58
#ifdef HAVE_NETINET_IN_SYSTM_H
 
59
#include <netinet/in_systm.h>
 
60
#endif
 
61
 
 
62
#ifdef HAVE_NETINET_IN_IP_H
 
63
#include <netinet/in_ip.h>
 
64
#endif
 
65
 
 
66
#ifdef HAVE_NETINET_IP_H
 
67
#include <netinet/ip.h>
 
68
#endif
 
69
 
 
70
#ifdef HAVE_NET_IF_H
 
71
#include <net/if.h>
 
72
#endif
 
73
 
 
74
#ifdef HAVE_UNISTD_H
 
75
#include <unistd.h>
 
76
#endif
 
77
 
 
78
#ifdef HAVE_SYS_IOCTL_H
 
79
#include <sys/ioctl.h>
 
80
#endif
 
81
 
 
82
#ifdef REPLACE_INET_NTOA
 
83
/* define is in "replace.h" */
 
84
char *rep_inet_ntoa(struct in_addr ip);
 
85
#endif
 
86
 
 
87
#ifndef HAVE_INET_PTON
 
88
/* define is in "replace.h" */
 
89
int rep_inet_pton(int af, const char *src, void *dst);
 
90
#endif
 
91
 
 
92
#ifndef HAVE_INET_NTOP
 
93
/* define is in "replace.h" */
 
94
const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
 
95
#endif
 
96
 
 
97
#ifdef HAVE_IFADDRS_H
 
98
#include <ifaddrs.h>
 
99
#endif
 
100
 
 
101
#ifndef HAVE_STRUCT_IFADDRS
 
102
struct ifaddrs {
 
103
        struct ifaddrs   *ifa_next;         /* Pointer to next struct */
 
104
        char             *ifa_name;         /* Interface name */
 
105
        unsigned int     ifa_flags;         /* Interface flags */
 
106
        struct sockaddr  *ifa_addr;         /* Interface address */
 
107
        struct sockaddr  *ifa_netmask;      /* Interface netmask */
 
108
#undef ifa_dstaddr
 
109
        struct sockaddr  *ifa_dstaddr;      /* P2P interface destination */
 
110
        void             *ifa_data;         /* Address specific data */
 
111
};
 
112
#endif
 
113
 
 
114
#ifndef HAVE_GETIFADDRS
 
115
int rep_getifaddrs(struct ifaddrs **);
 
116
#endif
 
117
 
 
118
#ifndef HAVE_FREEIFADDRS
 
119
void rep_freeifaddrs(struct ifaddrs *);
 
120
#endif
 
121
 
 
122
/*
 
123
 * Some systems have getaddrinfo but not the
 
124
 * defines needed to use it.
 
125
 */
 
126
 
 
127
/* Various macros that ought to be in <netdb.h>, but might not be */
 
128
 
 
129
#ifndef EAI_FAIL
 
130
#define EAI_BADFLAGS    (-1)
 
131
#define EAI_NONAME      (-2)
 
132
#define EAI_AGAIN       (-3)
 
133
#define EAI_FAIL        (-4)
 
134
#define EAI_FAMILY      (-6)
 
135
#define EAI_SOCKTYPE    (-7)
 
136
#define EAI_SERVICE     (-8)
 
137
#define EAI_MEMORY      (-10)
 
138
#define EAI_SYSTEM      (-11)
 
139
#endif   /* !EAI_FAIL */
 
140
 
 
141
#ifndef AI_PASSIVE
 
142
#define AI_PASSIVE      0x0001
 
143
#endif
 
144
 
 
145
#ifndef AI_CANONNAME
 
146
#define AI_CANONNAME    0x0002
 
147
#endif
 
148
 
 
149
#ifndef AI_NUMERICHOST
 
150
/*
 
151
 * some platforms don't support AI_NUMERICHOST; define as zero if using
 
152
 * the system version of getaddrinfo...
 
153
 */
 
154
#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
 
155
#define AI_NUMERICHOST  0
 
156
#else
 
157
#define AI_NUMERICHOST  0x0004
 
158
#endif
 
159
#endif
 
160
 
 
161
#ifndef AI_ADDRCONFIG
 
162
#define AI_ADDRCONFIG   0x0020
 
163
#endif
 
164
 
 
165
#ifndef AI_NUMERICSERV
 
166
/*
 
167
 * logic copied from AI_NUMERICHOST
 
168
 */
 
169
#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
 
170
#define AI_NUMERICSERV  0
 
171
#else
 
172
#define AI_NUMERICSERV  0x0400
 
173
#endif
 
174
#endif
 
175
 
 
176
#ifndef NI_NUMERICHOST
 
177
#define NI_NUMERICHOST  1
 
178
#endif
 
179
 
 
180
#ifndef NI_NUMERICSERV
 
181
#define NI_NUMERICSERV  2
 
182
#endif
 
183
 
 
184
#ifndef NI_NOFQDN
 
185
#define NI_NOFQDN       4
 
186
#endif
 
187
 
 
188
#ifndef NI_NAMEREQD
 
189
#define NI_NAMEREQD     8
 
190
#endif
 
191
 
 
192
#ifndef NI_DGRAM
 
193
#define NI_DGRAM        16
 
194
#endif
 
195
 
 
196
 
 
197
#ifndef NI_MAXHOST
 
198
#define NI_MAXHOST      1025
 
199
#endif
 
200
 
 
201
#ifndef NI_MAXSERV
 
202
#define NI_MAXSERV      32
 
203
#endif
 
204
 
 
205
/*
 
206
 * glibc on linux doesn't seem to have MSG_WAITALL
 
207
 * defined. I think the kernel has it though..
 
208
 */
 
209
#ifndef MSG_WAITALL
 
210
#define MSG_WAITALL 0
 
211
#endif
 
212
 
 
213
#ifndef INADDR_LOOPBACK
 
214
#define INADDR_LOOPBACK 0x7f000001
 
215
#endif
 
216
 
 
217
#ifndef INADDR_NONE
 
218
#define INADDR_NONE 0xffffffff
 
219
#endif
 
220
 
 
221
#ifndef EAFNOSUPPORT
 
222
#define EAFNOSUPPORT EINVAL
 
223
#endif
 
224
 
 
225
#ifndef INET_ADDRSTRLEN
 
226
#define INET_ADDRSTRLEN 16
 
227
#endif
 
228
 
 
229
#ifndef INET6_ADDRSTRLEN
 
230
#define INET6_ADDRSTRLEN 46
 
231
#endif
 
232
 
 
233
#ifndef HOST_NAME_MAX
 
234
#define HOST_NAME_MAX 256
 
235
#endif
 
236
 
 
237
#ifndef HAVE_SOCKLEN_T
 
238
#define HAVE_SOCKLEN_T
 
239
typedef int socklen_t;
 
240
#endif
 
241
 
 
242
#ifndef HAVE_SA_FAMILY_T
 
243
#define HAVE_SA_FAMILY_T
 
244
typedef unsigned short int sa_family_t;
 
245
#endif
 
246
 
 
247
#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
 
248
#define HAVE_STRUCT_SOCKADDR_STORAGE
 
249
#ifdef HAVE_STRUCT_SOCKADDR_IN6
 
250
#define sockaddr_storage sockaddr_in6
 
251
#define ss_family sin6_family
 
252
#define HAVE_SS_FAMILY 1
 
253
#else
 
254
#define sockaddr_storage sockaddr_in
 
255
#define ss_family sin_family
 
256
#define HAVE_SS_FAMILY 1
 
257
#endif
 
258
#endif
 
259
 
 
260
#ifndef HAVE_SS_FAMILY
 
261
#ifdef HAVE___SS_FAMILY
 
262
#define ss_family __ss_family
 
263
#define HAVE_SS_FAMILY 1
 
264
#endif
 
265
#endif
 
266
 
 
267
#ifndef HAVE_STRUCT_ADDRINFO
 
268
#define HAVE_STRUCT_ADDRINFO
 
269
struct addrinfo {
 
270
        int                     ai_flags;
 
271
        int                     ai_family;
 
272
        int                     ai_socktype;
 
273
        int                     ai_protocol;
 
274
        socklen_t               ai_addrlen;
 
275
        struct sockaddr         *ai_addr;
 
276
        char                    *ai_canonname;
 
277
        struct addrinfo         *ai_next;
 
278
};
 
279
#endif   /* HAVE_STRUCT_ADDRINFO */
 
280
 
 
281
#if !defined(HAVE_GETADDRINFO)
 
282
#include "getaddrinfo.h"
 
283
#endif
 
284
 
 
285
/* Needed for some systems that don't define it (Solaris). */
 
286
#ifndef ifr_netmask
 
287
#define ifr_netmask ifr_addrs
 
288
#endif
 
289
 
 
290
#ifdef SOCKET_WRAPPER
 
291
#ifndef SOCKET_WRAPPER_NOT_REPLACE
 
292
#define SOCKET_WRAPPER_REPLACE
 
293
#endif
 
294
#include "lib/socket_wrapper/socket_wrapper.h"
 
295
#endif
 
296
 
 
297
#endif