~ubuntu-branches/debian/squeeze/ntp/squeeze-201010051545

« back to all changes in this revision

Viewing changes to ports/winnt/include/isc/net.h

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-10-11 16:10:27 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041011161027-icyjbji8ujym633o
Tags: 1:4.2.0a-10ubuntu2
Use ntp.ubuntulinux.org instead of pool.ntp.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 1999-2001  Internet Software Consortium.
 
3
 *
 
4
 * Permission to use, copy, modify, and distribute this software for any
 
5
 * purpose with or without fee is hereby granted, provided that the above
 
6
 * copyright notice and this permission notice appear in all copies.
 
7
 *
 
8
 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
 
9
 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
 
10
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
 
11
 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
 
12
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
 
13
 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
14
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
15
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
16
 */
 
17
 
 
18
/* $Id: net.h,v 1.17 2002/08/01 03:56:08 mayer Exp $ */
 
19
 
 
20
#ifndef ISC_NET_H
 
21
#define ISC_NET_H 1
 
22
 
 
23
/*
 
24
 * Also define LWRES_IPV6_H to keep it from being included if liblwres is
 
25
 * being used, or redefinition errors will occur.
 
26
 */
 
27
#define LWRES_IPV6_H 1
 
28
 
 
29
 
 
30
 
 
31
/*****
 
32
 ***** Module Info
 
33
 *****/
 
34
 
 
35
/*
 
36
 * Basic Networking Types
 
37
 *
 
38
 * This module is responsible for defining the following basic networking
 
39
 * types:
 
40
 *
 
41
 *              struct in_addr
 
42
 *              struct in6_addr
 
43
 *              struct in6_pktinfo
 
44
 *              struct sockaddr
 
45
 *              struct sockaddr_in
 
46
 *              struct sockaddr_in6
 
47
 *              in_port_t
 
48
 *
 
49
 * It ensures that the AF_ and PF_ macros are defined.
 
50
 *
 
51
 * It declares ntoh[sl]() and hton[sl]().
 
52
 *
 
53
 * It declares inet_aton(), inet_ntop(), and inet_pton().
 
54
 *
 
55
 * It ensures that INADDR_ANY, IN6ADDR_ANY_INIT, in6addr_any, and
 
56
 * in6addr_loopback are available.
 
57
 *
 
58
 * It ensures that IN_MULTICAST() is available to check for multicast
 
59
 * addresses.
 
60
 *
 
61
 * MP:
 
62
 *      No impact.
 
63
 *
 
64
 * Reliability:
 
65
 *      No anticipated impact.
 
66
 *
 
67
 * Resources:
 
68
 *      N/A.
 
69
 *
 
70
 * Security:
 
71
 *      No anticipated impact.
 
72
 *
 
73
 * Standards:
 
74
 *      BSD Socket API
 
75
 *      RFC 2553
 
76
 */
 
77
 
 
78
/***
 
79
 *** Imports.
 
80
 ***/
 
81
#include <isc/platform.h>
 
82
 
 
83
/*
 
84
 * Because of some sort of problem in the MS header files, this cannot
 
85
 * be simple "#include <winsock2.h>", because winsock2.h tries to include
 
86
 * windows.h, which then generates an error out of mswsock.h.  _You_
 
87
 * figure it out.
 
88
 */
 
89
#ifndef _WINSOCKAPI_
 
90
#define _WINSOCKAPI_   /* Prevent inclusion of winsock.h in windows.h */
 
91
#endif
 
92
 
 
93
#include <winsock2.h>
 
94
 
 
95
#include <sys/types.h>
 
96
 
 
97
#include <isc/lang.h>
 
98
#include <isc/types.h>
 
99
 
 
100
#include <ws2tcpip.h>
 
101
#include <isc/ipv6.h>
 
102
 
 
103
/*
 
104
 * This is here because named client, interfacemgr.c, etc. use the name as
 
105
 * a variable
 
106
 */
 
107
#undef interface 
 
108
 
 
109
#ifndef INADDR_LOOPBACK
 
110
#define INADDR_LOOPBACK 0x7f000001UL
 
111
#endif
 
112
 
 
113
#ifndef ISC_PLATFORM_HAVEIN6PKTINFO
 
114
struct in6_pktinfo {
 
115
        struct in6_addr ipi6_addr;    /* src/dst IPv6 address */
 
116
        unsigned int    ipi6_ifindex; /* send/recv interface index */
 
117
};
 
118
#endif
 
119
 
 
120
/*
 
121
 * Ensure type in_port_t is defined.
 
122
 */
 
123
#ifdef ISC_PLATFORM_NEEDPORTT
 
124
typedef isc_uint16_t in_port_t;
 
125
#endif
 
126
 
 
127
/*
 
128
 * If this system does not have MSG_TRUNC (as returned from recvmsg())
 
129
 * ISC_PLATFORM_RECVOVERFLOW will be defined.  This will enable the MSG_TRUNC
 
130
 * faking code in socket.c.
 
131
 */
 
132
#ifndef MSG_TRUNC
 
133
#define ISC_PLATFORM_RECVOVERFLOW
 
134
#endif
 
135
 
 
136
#define ISC__IPADDR(x)  ((isc_uint32_t)htonl((isc_uint32_t)(x)))
 
137
 
 
138
#define ISC_IPADDR_ISMULTICAST(i) \
 
139
                (((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \
 
140
                 == ISC__IPADDR(0xe0000000))
 
141
 
 
142
/*
 
143
 * Fix the FD_SET and FD_CLR Macros to properly cast
 
144
 */
 
145
#undef FD_CLR
 
146
#define FD_CLR(fd, set) do { \
 
147
    u_int __i; \
 
148
    for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
 
149
        if (((fd_set FAR *)(set))->fd_array[__i] == (SOCKET) fd) { \
 
150
            while (__i < ((fd_set FAR *)(set))->fd_count-1) { \
 
151
                ((fd_set FAR *)(set))->fd_array[__i] = \
 
152
                    ((fd_set FAR *)(set))->fd_array[__i+1]; \
 
153
                __i++; \
 
154
            } \
 
155
            ((fd_set FAR *)(set))->fd_count--; \
 
156
            break; \
 
157
        } \
 
158
    } \
 
159
} while (0)
 
160
 
 
161
#undef FD_SET
 
162
#define FD_SET(fd, set) do { \
 
163
    u_int __i; \
 
164
    for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
 
165
        if (((fd_set FAR *)(set))->fd_array[__i] == (SOCKET)(fd)) { \
 
166
            break; \
 
167
        } \
 
168
    } \
 
169
    if (__i == ((fd_set FAR *)(set))->fd_count) { \
 
170
        if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \
 
171
            ((fd_set FAR *)(set))->fd_array[__i] = (SOCKET)(fd); \
 
172
            ((fd_set FAR *)(set))->fd_count++; \
 
173
        } \
 
174
    } \
 
175
} while (0)
 
176
 
 
177
/*
 
178
 * Windows Sockets errors redefined as regular Berkeley error constants.
 
179
 * These are usually commented out in Windows NT to avoid conflicts with errno.h.
 
180
 * Use the WSA constants instead.
 
181
 */
 
182
 
 
183
#define EWOULDBLOCK             WSAEWOULDBLOCK
 
184
#define EINPROGRESS             WSAEINPROGRESS
 
185
#define EALREADY                WSAEALREADY
 
186
#define ENOTSOCK                WSAENOTSOCK
 
187
#define EDESTADDRREQ            WSAEDESTADDRREQ
 
188
#define EMSGSIZE                WSAEMSGSIZE
 
189
#define EPROTOTYPE              WSAEPROTOTYPE
 
190
#define ENOPROTOOPT             WSAENOPROTOOPT
 
191
#define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
 
192
#define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
 
193
#define EOPNOTSUPP              WSAEOPNOTSUPP
 
194
#define EPFNOSUPPORT            WSAEPFNOSUPPORT
 
195
#define EAFNOSUPPORT            WSAEAFNOSUPPORT
 
196
#define EADDRINUSE              WSAEADDRINUSE
 
197
#define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
 
198
#define ENETDOWN                WSAENETDOWN
 
199
#define ENETUNREACH             WSAENETUNREACH
 
200
#define ENETRESET               WSAENETRESET
 
201
#define ECONNABORTED            WSAECONNABORTED
 
202
#define ECONNRESET              WSAECONNRESET
 
203
#define ENOBUFS                 WSAENOBUFS
 
204
#define EISCONN                 WSAEISCONN
 
205
#define ENOTCONN                WSAENOTCONN
 
206
#define ESHUTDOWN               WSAESHUTDOWN
 
207
#define ETOOMANYREFS            WSAETOOMANYREFS
 
208
#define ETIMEDOUT               WSAETIMEDOUT
 
209
#define ECONNREFUSED            WSAECONNREFUSED
 
210
#define ELOOP                   WSAELOOP
 
211
#define EHOSTDOWN               WSAEHOSTDOWN
 
212
#define EHOSTUNREACH            WSAEHOSTUNREACH
 
213
#define EPROCLIM                WSAEPROCLIM
 
214
#define EUSERS                  WSAEUSERS
 
215
#define EDQUOT                  WSAEDQUOT
 
216
#define ESTALE                  WSAESTALE
 
217
#define EREMOTE                 WSAEREMOTE
 
218
 
 
219
 
 
220
/***
 
221
 *** Functions.
 
222
 ***/
 
223
 
 
224
ISC_LANG_BEGINDECLS
 
225
 
 
226
isc_result_t
 
227
isc_net_probeipv4(void);
 
228
/*
 
229
 * Check if the system's kernel supports IPv4.
 
230
 *
 
231
 * Returns:
 
232
 *
 
233
 *      ISC_R_SUCCESS           IPv4 is supported.
 
234
 *      ISC_R_NOTFOUND          IPv4 is not supported.
 
235
 *      ISC_R_UNEXPECTED
 
236
 */
 
237
 
 
238
isc_result_t
 
239
isc_net_probeipv6(void);
 
240
/*
 
241
 * Check if the system's kernel supports IPv6.
 
242
 *
 
243
 * Returns:
 
244
 *
 
245
 *      ISC_R_SUCCESS           IPv6 is supported.
 
246
 *      ISC_R_NOTFOUND          IPv6 is not supported.
 
247
 *      ISC_R_UNEXPECTED
 
248
 */
 
249
 
 
250
#ifdef ISC_PLATFORM_NEEDNTOP
 
251
const char *
 
252
isc_net_ntop(int af, const void *src, char *dst, size_t size);
 
253
#define inet_ntop isc_net_ntop
 
254
#endif
 
255
 
 
256
#ifdef ISC_PLATFORM_NEEDPTON
 
257
int
 
258
isc_net_pton(int af, const char *src, void *dst);
 
259
#define inet_pton isc_net_pton
 
260
#endif
 
261
 
 
262
#ifdef ISC_PLATFORM_NEEDATON
 
263
int
 
264
isc_net_aton(const char *cp, struct in_addr *addr);
 
265
#define inet_aton isc_net_aton
 
266
#endif
 
267
 
 
268
/* Socket Initialization Code */
 
269
 
 
270
BOOL
 
271
Win32InitSockets();
 
272
 
 
273
ISC_LANG_ENDDECLS
 
274
 
 
275
#endif /* ISC_NET_H */