4 * Copyright 1998-2002 The OpenLDAP Foundation, Redwood City, California, USA
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
9 * Public License. A copy of this license is available at
10 * http://www.OpenLDAP.org/license.html or in file LICENSE in the
11 * 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>
28 #ifdef HAVE_SYS_SELECT_H
29 #include <sys/select.h>
32 #include <netinet/in.h>
34 #ifdef HAVE_NETINET_TCP_H
35 #include <netinet/tcp.h>
38 #ifdef HAVE_ARPA_INET_H
39 #include <arpa/inet.h>
42 #ifdef HAVE_ARPA_NAMESER_H
43 #include <arpa/nameser.h>
52 #endif /* HAVE_SYS_SOCKET_H */
62 #endif /* HAVE_PCNFS */
64 #ifndef INADDR_LOOPBACK
65 #define INADDR_LOOPBACK (0x7f000001UL)
68 #ifndef MAXHOSTNAMELEN
69 #define MAXHOSTNAMELEN 64
74 #define sock_errno() errno
75 #define sock_errstr(e) STRERROR(e)
78 # define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
79 # define tcp_write( s, buf, len ) send( s, buf, len, 0 )
80 # define ioctl( s, c, a ) ioctlsocket( (s), (c), (a) )
81 # define ioctl_t u_long
82 # define AC_SOCKET_INVALID ((unsigned int) ~0)
85 # define tcp_close( s ) (shutdown( s, SD_BOTH ), closesocket( s ))
87 # define tcp_close( s ) closesocket( s )
90 #define EWOULDBLOCK WSAEWOULDBLOCK
91 #define EINPROGRESS WSAEINPROGRESS
92 #define ETIMEDOUT WSAETIMEDOUT
96 #define sock_errno() WSAGetLastError()
97 #define sock_errstr(e) ber_pvt_wsa_err2string(e)
99 LBER_F( char * ) ber_pvt_wsa_err2string LDAP_P((int));
102 # define tcp_close( s ) tcpclose( s )
103 # define tcp_read( s, buf, len ) tcpread( s, buf, len )
104 # define tcp_write( s, buf, len ) tcpwrite( s, buf, len )
108 # define tcp_close( s ) close( s )
109 # define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
110 # define tcp_write( s, buf, len ) send( s, buf, len, 0 )
113 # define tcp_close( s ) do { netclose( s ); netshut() } while(0)
114 # define tcp_read( s, buf, len ) nread( s, buf, len )
115 # define tcp_write( s, buf, len ) netwrite( s, buf, len )
118 #elif HAVE_CLOSESOCKET
119 # define tcp_close( s ) closesocket( s )
122 # define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
123 # define tcp_write( s, buf, len ) send( s, buf, len, 0 )
127 # define tcp_read( s, buf, len) read( s, buf, len )
128 # define tcp_write( s, buf, len) write( s, buf, len )
131 # define tcp_close( s ) (shutdown( s, SHUT_RDWR ), close( s ))
133 # define tcp_close( s ) close( s )
138 * Only use pipe() on systems where file and socket descriptors
141 # define USE_PIPE HAVE_PIPE
150 #ifndef AC_SOCKET_INVALID
151 # define AC_SOCKET_INVALID (-1)
153 #ifndef AC_SOCKET_ERROR
154 # define AC_SOCKET_ERROR (-1)
157 #if !defined( HAVE_INET_ATON ) && !defined( inet_aton )
158 # define inet_aton ldap_pvt_inet_aton
160 LDAP_F (int) ldap_pvt_inet_aton LDAP_P(( const char *, struct in_addr * ));
163 #if defined(__WIN32) && defined(_ALPHA)
164 /* NT on Alpha is hosed. */
165 # define AC_HTONL( l ) \
166 ((((l)&0xffU)<<24) + (((l)&0xff00U)<<8) + \
167 (((l)&0xff0000U)>>8) + (((l)&0xff000000U)>>24))
168 # define AC_NTOHL(l) AC_HTONL(l)
171 # define AC_HTONL( l ) htonl( l )
172 # define AC_NTOHL( l ) ntohl( l )
175 /* htons()/ntohs() may be broken much like htonl()/ntohl() */
176 #define AC_HTONS( s ) htons( s )
177 #define AC_NTOHS( s ) ntohs( s )
180 # if !defined( AF_LOCAL ) && defined( AF_UNIX )
181 # define AF_LOCAL AF_UNIX
183 # if !defined( PF_LOCAL ) && defined( PF_UNIX )
184 # define PF_LOCAL PF_UNIX
188 #ifndef INET_ADDRSTRLEN
189 # define INET_ADDRSTRLEN 16
191 #ifndef INET6_ADDRSTRLEN
192 # define INET6_ADDRSTRLEN 46
195 #ifdef HAVE_GETADDRINFO
196 # ifdef HAVE_GAI_STRERROR
197 # define AC_GAI_STRERROR(x) (gai_strerror((x)))
199 # define AC_GAI_STRERROR(x) (ldap_pvt_gai_strerror((x)))
200 char * ldap_pvt_gai_strerror( int );
204 #endif /* _AC_SOCKET_H_ */