00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef ns_inet_h
00038 #define ns_inet_h
00039
00040 #include <sys/types.h>
00041 #ifdef WIN32
00042 #include <winsock.h>
00043 #endif
00044 #if defined(__osf__)
00045 #include <machine/endian.h>
00046 #endif
00047 #if defined(__linux__)
00048 #include <endian.h>
00049 #endif
00050 #ifndef IPPROTO_IP
00051 #if defined(__ultrix__) && defined(__cplusplus)
00052 extern "C" {
00053 #include <netinet/in.h>
00054 }
00055 #else
00056 #include <netinet/in.h>
00057 #endif
00058 #endif
00059 #ifndef WIN32
00060 #include <arpa/inet.h>
00061 #endif
00062
00063 #include "config.h"
00064
00065 #ifdef __cplusplus
00066 extern "C" {
00067 #endif
00068 extern char *LookupHostName(u_int32_t addr);
00069 extern char *InetNtoa(u_int32_t addr);
00070 extern u_int32_t LookupLocalAddr(void);
00071 extern u_int32_t LookupHostAddr(const char* host);
00072 extern const char* intoa(u_int32_t addr);
00073 extern u_short in_cksum(u_short*, int);
00074 #ifdef __cplusplus
00075 }
00076 #endif
00077
00078 #ifndef NTOHL
00079 #if BYTE_ORDER==LITTLE_ENDIAN
00080 #define NTOHL(d) ((d) = ntohl((d)))
00081 #define NTOHS(d) ((d) = ntohs((d)))
00082 #define HTONL(d) ((d) = htonl((d)))
00083 #define HTONS(d) ((d) = htons((d)))
00084 #elif BYTE_ORDER==BIG_ENDIAN
00085 #define NTOHL(d)
00086 #define NTOHS(d)
00087 #define HTONL(d)
00088 #define HTONS(d)
00089 #else
00090 #error error - BYTE_ORDER not defined.
00091 #endif
00092 #endif
00093
00094 #ifndef INADDR_LOOPBACK
00095 #define INADDR_LOOPBACK (u_int32_t)0x7F000001
00096 #endif
00097
00098 #if defined(WIN32)
00099 struct msghdr {
00100 caddr_t msg_name;
00101 u_int msg_namelen;
00102 struct iovec *msg_iov;
00103 u_int msg_iovlen;
00104 caddr_t msg_control;
00105 u_int msg_controllen;
00106 int msg_flags;
00107 };
00108 #endif
00109
00110
00111 #ifdef WIN32
00112 #define IN_CLASSD(i) (((u_long)(i) & ((u_long)0xf0000000)) == \
00113 ((u_long)0xe0000000))
00114 #define IN_CLASSD_NET ((u_long)0xf0000000)
00115 #define IN_CLASSD_NSHIFT 28
00116 #define IN_CLASSD_HOST ((u_long)0x0fffffff)
00117 #define IN_MULTICAST(i) IN_CLASSD(i)
00118 #endif
00119
00120
00121 #ifndef HAVE_SOCKLEN_T
00122 typedef int socklen_t;
00123 #endif
00124
00125
00126 #endif
00127