]> git.sur5r.net Git - openldap/blob - include/ac/socket.h
Add byte ordering defines.
[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 #define EMSGSIZE WSAEMSGSIZE
29 #define EHOSTUNREACH WSAEHOSTUNREACH
30 #elif HAVE_WINSOCK
31 #include <winsock.h>
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 #ifdef MACOS
43 #define tcp_close( s )          tcpclose( s )
44 #else /* MACOS */
45 #ifdef DOS
46 #ifdef PCNFS
47 #define tcp_close( s )          close( s )
48 #endif /* PCNFS */
49 #ifdef NCSA
50 #define tcp_close( s )          netclose( s ); netshut()
51 #endif /* NCSA */
52 #ifdef WINSOCK
53 #define tcp_close( s )          closesocket( s ); WSACleanup();
54 #endif /* WINSOCK */
55 #else /* DOS */
56 #define tcp_close( s )          close( s )
57 #endif /* DOS */
58 #endif /* MACOS */
59
60 #if !defined(__alpha) || defined(VMS)
61 #define AC_HTONL( l ) htonl( l )
62 #define AC_NTOHL( l ) ntohl( l )
63 #else /* __alpha && !VMS */
64 /*
65  * htonl and ntohl on the DEC Alpha under OSF 1 seem to only swap the
66  * lower-order 32-bits of a (64-bit) long, so we define correct versions
67  * here.
68  */ 
69 #define AC_HTONL( l )   (((long)htonl( (l) & 0x00000000FFFFFFFF )) << 32 \
70         | htonl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
71
72 #define AC_NTOHL( l ) (((long)ntohl( (l) & 0x00000000FFFFFFFF )) << 32 \
73         | ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
74
75 #endif /* __alpha && !VMS */
76
77 #ifndef BYTE_ORDER
78 /*    
79  * Definitions for byte order, according to byte significance from low
80  * address to high.
81  */
82 #define LITTLE_ENDIAN   1234    /* LSB first: i386, vax */
83 #define BIG_ENDIAN  4321                /* MSB first: 68000, ibm, net */
84 #define PDP_ENDIAN  3412                /* LSB first in word, MSW first in long */
85
86 /* assume autoconf's AC_C_BIGENDIAN has been run */
87 #ifdef WORDS_BIGENDIAN
88 #define BYTE_ORDER  BIG_ENDIAN
89 #else
90 #define BYTE_ORDER  LITTLE_ENDIAN
91 #endif
92
93 #endif /* BYTE_ORDER */
94
95 #endif /* _AC_SOCKET_H_ */