5 * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
8 * Redistribution and use in source and binary forms are permitted only
9 * as authorized by the OpenLDAP Public License. A copy of this
10 * license is available at http://www.OpenLDAP.org/license.html or
11 * in file LICENSE in the top-level directory of the distribution.
17 #ifdef HAVE_SYS_TYPES_H
18 #include <sys/types.h>
21 #ifdef HAVE_SYS_SOCKET_H
22 #include <sys/socket.h>
24 #ifdef HAVE_SYS_SELECT_H
25 #include <sys/select.h>
28 #include <netinet/in.h>
30 #ifdef HAVE_NETINET_TCP_H
31 #include <netinet/tcp.h>
34 #ifdef HAVE_ARPA_INET_H
35 #include <arpa/inet.h>
38 #ifdef HAVE_ARPA_NAMESER_H
39 #include <arpa/nameser.h>
48 #endif /* HAVE_SYS_SOCKET_H */
60 #endif /* HAVE_PCNFS */
62 #ifndef INADDR_LOOPBACK
63 #define INADDR_LOOPBACK (0x7f000001UL)
66 #ifndef MAXHOSTNAMELEN
67 #define MAXHOSTNAMELEN 64
71 # define tcp_close( s ) closesocket( s );
72 # define ioctl( s, c, a ) ioctlsocket( (s), (c), (a) )
73 # define ioctl_t u_long
74 # define AC_SOCKET_INVALID ((unsigned int) ~0)
76 #define EWOULDBLOCK WSAEWOULDBLOCK
77 #define EINPROGRESS WSAEINPROGRESS
78 #define ETIMEDOUT WSAETIMEDOUT
80 #define sock_errno() WSAGetLastError()
81 #define sock_errstr() WSAGetLastErrorString()
84 # define tcp_close( s ) tcpclose( s )
88 # define tcp_close( s ) close( s )
91 # define tcp_close( s ) do { netclose( s ); netshut() } while(0)
94 #elif HAVE_CLOSESOCKET
95 # define tcp_close( s ) closesocket( s )
98 # define tcp_close( s ) close( s )
99 # define sock_errno() errno
100 # define sock_errstr() strerror(errno)
107 #ifndef AC_SOCKET_INVALID
108 # define AC_SOCKET_INVALID (-1)
111 #if !defined( HAVE_INET_ATON ) && !defined( inet_aton )
112 #define inet_aton ldap_pvt_inet_aton
114 int ldap_pvt_inet_aton LDAP_P(( const char *, struct in_addr * ));
117 #if defined(__WIN32) && defined(_ALPHA)
118 /* NT on Alpha is hosed. */
119 #define AC_HTONL( l ) \
120 ((((l)&0xff)<<24) + (((l)&0xff00)<<8) + \
121 (((l)&0xff0000)>>8) + (((l)&0xff000000)>>24))
122 #define AC_NTOHL(l) AC_HTONL(l)
124 #elif defined(__alpha) && !defined(VMS)
126 * htonl and ntohl on the DEC Alpha under OSF 1 seem to only swap the
127 * lower-order 32-bits of a (64-bit) long, so we define correct versions
130 #define AC_HTONL( l ) (((long)htonl( (l) & 0x00000000FFFFFFFF )) << 32 \
131 | htonl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
133 #define AC_NTOHL( l ) (((long)ntohl( (l) & 0x00000000FFFFFFFF )) << 32 \
134 | ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
137 #define AC_HTONL( l ) htonl( l )
138 #define AC_NTOHL( l ) ntohl( l )
141 /* htons()/ntohs() may be broken much like htonl()/ntohl() */
142 #define AC_HTONS( s ) htons( s )
143 #define AC_NTOHS( s ) ntohs( s )
146 #endif /* _AC_SOCKET_H_ */