4 * Copyright 1998-2000 The OpenLDAP Foundation, Redwood City, California, USA
7 * Redistribution and use in source and binary forms are permitted only
8 * as authorized by the OpenLDAP Public License. A copy of this
9 * license is available at http://www.OpenLDAP.org/license.html or
10 * in file LICENSE in the top-level directory of the distribution.
16 #ifdef HAVE_SYS_TYPES_H
17 #include <sys/types.h>
20 #ifdef HAVE_SYS_SOCKET_H
21 #include <sys/socket.h>
27 #ifdef HAVE_SYS_SELECT_H
28 #include <sys/select.h>
31 #include <netinet/in.h>
33 #ifdef HAVE_NETINET_TCP_H
34 #include <netinet/tcp.h>
37 #ifdef HAVE_ARPA_INET_H
38 #include <arpa/inet.h>
41 #ifdef HAVE_ARPA_NAMESER_H
42 #include <arpa/nameser.h>
51 #endif /* HAVE_SYS_SOCKET_H */
63 #endif /* HAVE_PCNFS */
65 #ifndef INADDR_LOOPBACK
66 #define INADDR_LOOPBACK (0x7f000001UL)
69 #ifndef MAXHOSTNAMELEN
70 #define MAXHOSTNAMELEN 64
75 #define sock_errno() errno
76 #define sock_errstr(e) STRERROR(e)
79 # define tcp_close( s ) closesocket( s )
80 # define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
81 # define tcp_write( s, buf, len ) send( s, buf, len, 0 )
82 # define ioctl( s, c, a ) ioctlsocket( (s), (c), (a) )
83 # define ioctl_t u_long
84 # define AC_SOCKET_INVALID ((unsigned int) ~0)
86 #define EWOULDBLOCK WSAEWOULDBLOCK
87 #define EINPROGRESS WSAEINPROGRESS
88 #define ETIMEDOUT WSAETIMEDOUT
92 #define sock_errno() WSAGetLastError()
93 #define sock_errstr(e) ber_pvt_wsa_err2string(e)
95 LIBLBER_F (char *) ber_pvt_wsa_err2string LDAP_P((int));
98 # define tcp_close( s ) tcpclose( s )
99 # define tcp_read( s, buf, len ) tcpread( s, buf, len )
100 # define tcp_write( s, buf, len ) tcpwrite( s, buf, len )
104 # define tcp_close( s ) close( s )
105 # define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
106 # define tcp_write( s, buf, len ) send( s, buf, len, 0 )
109 # define tcp_close( s ) do { netclose( s ); netshut() } while(0)
110 # define tcp_read( s, buf, len ) nread( s, buf, len )
111 # define tcp_write( s, buf, len ) netwrite( s, buf, len )
114 #elif HAVE_CLOSESOCKET
115 # define tcp_close( s ) closesocket( s )
118 # define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
119 # define tcp_write( s, buf, len ) send( s, buf, len, 0 )
123 # define tcp_close( s ) close( s )
124 # define tcp_read( s, buf, len) read( s, buf, len )
125 # define tcp_write( s, buf, len) write( s, buf, len )
129 * Only use pipe() on systems where file and socket descriptors
132 #define USE_PIPE HAVE_PIPE
141 #ifndef AC_SOCKET_INVALID
142 # define AC_SOCKET_INVALID (-1)
144 #ifndef AC_SOCKET_ERROR
145 # define AC_SOCKET_ERROR (-1)
148 #if !defined( HAVE_INET_ATON ) && !defined( inet_aton )
149 #define inet_aton ldap_pvt_inet_aton
151 LDAP_F (int) ldap_pvt_inet_aton LDAP_P(( const char *, struct in_addr * ));
154 #if defined(__WIN32) && defined(_ALPHA)
155 /* NT on Alpha is hosed. */
156 # define AC_HTONL( l ) \
157 ((((l)&0xffU)<<24) + (((l)&0xff00U)<<8) + \
158 (((l)&0xff0000U)>>8) + (((l)&0xff000000U)>>24))
159 # define AC_NTOHL(l) AC_HTONL(l)
162 # define AC_HTONL( l ) htonl( l )
163 # define AC_NTOHL( l ) ntohl( l )
166 /* htons()/ntohs() may be broken much like htonl()/ntohl() */
167 #define AC_HTONS( s ) htons( s )
168 #define AC_NTOHS( s ) ntohs( s )
171 #endif /* _AC_SOCKET_H_ */