]>
The Tcpdump Group git mirrors - tcpdump/blob - tcpdump-stdinc.h
2 * Copyright (c) 2002 - 2003
3 * NetGroup, Politecnico di Torino (Italy)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Politecnico di Torino nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.13 2005-04-20 09:44:32 guy Exp $ (LBL)
36 * Include the appropriate OS header files on Windows and various flavors
37 * of UNIX, and also define some additional items and include various
38 * non-OS header files on Windows, and; this isolates most of the platform
39 * differences to this one file.
42 #ifndef tcpdump_stdinc_h
43 #define tcpdump_stdinc_h
55 #include <sys/types.h>
56 #include <net/netdb.h> /* in wpcap's Win32/include */
62 /* Protos for missing/x.c functions (ideally <missing/addrinfo.h>
63 * should be used, but it clashes with <ws2tcpip.h>).
65 extern const char *inet_ntop (int, const void *, char *, size_t);
66 extern int inet_pton (int, const char *, void *);
67 extern int inet_aton (const char *cp
, struct in_addr
*addr
);
69 #ifndef INET6_ADDRSTRLEN
70 #define INET6_ADDRSTRLEN 46
74 #define toascii(c) ((c) & 0x7f)
78 typedef char* caddr_t
;
81 #define MAXHOSTNAMELEN 64
82 #define NI_MAXHOST 1025
83 #define snprintf _snprintf
84 #define vsnprintf _vsnprintf
85 #define RETSIGTYPE void
99 #ifdef HAVE_SYS_BITYPES_H
100 #include <sys/bitypes.h>
102 #include <sys/param.h>
103 #include <sys/types.h> /* concession to AIX */
104 #include <sys/time.h>
105 #include <sys/socket.h>
106 #include <netinet/in.h>
108 #ifdef TIME_WITH_SYS_TIME
112 #include <arpa/inet.h>
120 #if defined(WIN32) || defined(MSDOS)
121 #define FOPEN_READ_TXT "rt"
122 #define FOPEN_READ_BIN "rb"
123 #define FOPEN_WRITE_TXT "wt"
124 #define FOPEN_WRITE_BIN "wb"
126 #define FOPEN_READ_TXT "r"
127 #define FOPEN_READ_BIN FOPEN_READ_TXT
128 #define FOPEN_WRITE_TXT "w"
129 #define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
132 #if defined(__GNUC__) && defined(__i386__)
138 extern __inline__
unsigned long __ntohl (unsigned long x
);
139 extern __inline__
unsigned short __ntohs (unsigned short x
);
141 #define ntohl(x) __ntohl(x)
142 #define ntohs(x) __ntohs(x)
143 #define htonl(x) __ntohl(x)
144 #define htons(x) __ntohs(x)
146 extern __inline__
unsigned long __ntohl (unsigned long x
)
148 __asm__ ("xchgb %b0, %h0\n\t" /* swap lower bytes */
149 "rorl $16, %0\n\t" /* swap words */
150 "xchgb %b0, %h0" /* swap higher bytes */
151 : "=q" (x
) : "0" (x
));
155 extern __inline__
unsigned short __ntohs (unsigned short x
)
157 __asm__ ("xchgb %b0, %h0" /* swap bytes */
158 : "=q" (x
) : "0" (x
));
163 #ifndef INET_ADDRSTRLEN
164 #define INET_ADDRSTRLEN 16
167 #endif /* tcpdump_stdinc_h */