2
* Copyright (C) 1999-2001 Internet Software Consortium.
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.
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.
18
/* $Id: net.h,v 1.17 2002/08/01 03:56:08 mayer Exp $ */
24
* Also define LWRES_IPV6_H to keep it from being included if liblwres is
25
* being used, or redefinition errors will occur.
27
#define LWRES_IPV6_H 1
36
* Basic Networking Types
38
* This module is responsible for defining the following basic networking
49
* It ensures that the AF_ and PF_ macros are defined.
51
* It declares ntoh[sl]() and hton[sl]().
53
* It declares inet_aton(), inet_ntop(), and inet_pton().
55
* It ensures that INADDR_ANY, IN6ADDR_ANY_INIT, in6addr_any, and
56
* in6addr_loopback are available.
58
* It ensures that IN_MULTICAST() is available to check for multicast
65
* No anticipated impact.
71
* No anticipated impact.
81
#include <isc/platform.h>
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_
90
#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */
95
#include <sys/types.h>
98
#include <isc/types.h>
100
#include <ws2tcpip.h>
101
#include <isc/ipv6.h>
104
* This is here because named client, interfacemgr.c, etc. use the name as
109
#ifndef INADDR_LOOPBACK
110
#define INADDR_LOOPBACK 0x7f000001UL
113
#ifndef ISC_PLATFORM_HAVEIN6PKTINFO
115
struct in6_addr ipi6_addr; /* src/dst IPv6 address */
116
unsigned int ipi6_ifindex; /* send/recv interface index */
121
* Ensure type in_port_t is defined.
123
#ifdef ISC_PLATFORM_NEEDPORTT
124
typedef isc_uint16_t in_port_t;
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.
133
#define ISC_PLATFORM_RECVOVERFLOW
136
#define ISC__IPADDR(x) ((isc_uint32_t)htonl((isc_uint32_t)(x)))
138
#define ISC_IPADDR_ISMULTICAST(i) \
139
(((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \
140
== ISC__IPADDR(0xe0000000))
143
* Fix the FD_SET and FD_CLR Macros to properly cast
146
#define FD_CLR(fd, set) do { \
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]; \
155
((fd_set FAR *)(set))->fd_count--; \
162
#define FD_SET(fd, set) do { \
164
for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
165
if (((fd_set FAR *)(set))->fd_array[__i] == (SOCKET)(fd)) { \
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++; \
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.
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
227
isc_net_probeipv4(void);
229
* Check if the system's kernel supports IPv4.
233
* ISC_R_SUCCESS IPv4 is supported.
234
* ISC_R_NOTFOUND IPv4 is not supported.
239
isc_net_probeipv6(void);
241
* Check if the system's kernel supports IPv6.
245
* ISC_R_SUCCESS IPv6 is supported.
246
* ISC_R_NOTFOUND IPv6 is not supported.
250
#ifdef ISC_PLATFORM_NEEDNTOP
252
isc_net_ntop(int af, const void *src, char *dst, size_t size);
253
#define inet_ntop isc_net_ntop
256
#ifdef ISC_PLATFORM_NEEDPTON
258
isc_net_pton(int af, const char *src, void *dst);
259
#define inet_pton isc_net_pton
262
#ifdef ISC_PLATFORM_NEEDATON
264
isc_net_aton(const char *cp, struct in_addr *addr);
265
#define inet_aton isc_net_aton
268
/* Socket Initialization Code */
275
#endif /* ISC_NET_H */