]> git.sur5r.net Git - openldap/blob - include/ac/socket.h
1527d02e5f051ecf8f8791e6bf8fd7e452128213
[openldap] / include / ac / socket.h
1 /*
2  * Generic socket.h
3  */
4
5 #ifndef _AC_SOCKET_H_
6 #define _AC_SOCKET_H_
7
8 #ifdef HAVE_SYS_TYPES_H
9 #include <sys/types.h>
10 #endif
11
12 #ifdef HAVE_SYS_SOCKET_H
13 #include <sys/socket.h>
14
15 #ifdef HAVE_SYS_SELECT_H
16 #include <sys/select.h>
17 #endif
18
19 #include <netinet/in.h>
20 #include <arpa/inet.h>
21 #include <arpa/nameser.h>
22 #include <netdb.h>
23 #include <resolv.h>
24 #endif
25
26 #ifdef HAVE_WINSOCK2
27 #include <winsock2.h>
28 #elif HAVE_WINSOCK
29 #include <winsock.h>
30 #else
31 #define WSACleanup()
32 #endif
33
34 #ifdef HAVE_PCNFS
35 #include <tklib.h>
36 #endif /* HAVE_PCNFS */
37
38 #ifndef INADDR_LOOPBACK
39 #define INADDR_LOOPBACK ((unsigned long) 0x7f000001)
40 #endif
41
42 #ifndef MAXHOSTNAMELEN
43 #define MAXHOSTNAMELEN  64
44 #endif
45
46 #ifdef MACOS
47 #define tcp_close( s )          tcpclose( s )
48 #else /* MACOS */
49 #ifdef DOS
50 #ifdef PCNFS
51 #define tcp_close( s )          close( s )
52 #endif /* PCNFS */
53 #ifdef NCSA
54 #define tcp_close( s )          netclose( s ); netshut()
55 #endif /* NCSA */
56 #ifdef WINSOCK
57 #define tcp_close( s )          closesocket( s );
58 #endif /* WINSOCK */
59 #else /* DOS */
60 #define tcp_close( s )          close( s )
61 #endif /* DOS */
62 #endif /* MACOS */
63
64 #if !defined(__alpha) || defined(VMS)
65 #define AC_HTONL( l ) htonl( l )
66 #define AC_NTOHL( l ) ntohl( l )
67 #else /* __alpha && !VMS */
68 /*
69  * htonl and ntohl on the DEC Alpha under OSF 1 seem to only swap the
70  * lower-order 32-bits of a (64-bit) long, so we define correct versions
71  * here.
72  */ 
73 #define AC_HTONL( l )   (((long)htonl( (l) & 0x00000000FFFFFFFF )) << 32 \
74         | htonl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
75
76 #define AC_NTOHL( l ) (((long)ntohl( (l) & 0x00000000FFFFFFFF )) << 32 \
77         | ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
78
79 #endif /* __alpha && !VMS */
80
81 #ifndef BYTE_ORDER
82 /*    
83  * Definitions for byte order, according to byte significance from low
84  * address to high.
85  */
86 #define LITTLE_ENDIAN   1234    /* LSB first: i386, vax */
87 #define BIG_ENDIAN  4321                /* MSB first: 68000, ibm, net */
88 #define PDP_ENDIAN  3412                /* LSB first in word, MSW first in long */
89
90 /* assume autoconf's AC_C_BIGENDIAN has been run */
91 /* if it hasn't, we assume (maybe falsely) the order is LITTLE ENDIAN */
92 #ifdef WORDS_BIGENDIAN
93 #define BYTE_ORDER  BIG_ENDIAN
94 #else
95 #define BYTE_ORDER  LITTLE_ENDIAN
96 #endif
97
98 #endif /* BYTE_ORDER */
99
100 #endif /* _AC_SOCKET_H_ */