Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / tcpdump / tcpdump-stdinc.h
blob39975f4343d53b6223ef9354a24788c37d3c75d6
1 /* $NetBSD$ */
3 /*
4 * Copyright (c) 2002 - 2003
5 * NetGroup, Politecnico di Torino (Italy)
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Politecnico di Torino nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 * @(#) Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.12.2.5 2006/06/23 02:07:27 hannes Exp (LBL)
38 * Include the appropriate OS header files on Windows and various flavors
39 * of UNIX, and also define some additional items and include various
40 * non-OS header files on Windows, and; this isolates most of the platform
41 * differences to this one file.
44 #ifndef tcpdump_stdinc_h
45 #define tcpdump_stdinc_h
47 #ifdef WIN32
49 #include <stdio.h>
50 #include <winsock2.h>
51 #include <Ws2tcpip.h>
52 #include "bittypes.h"
53 #include <ctype.h>
54 #include <time.h>
55 #include <io.h>
56 #include <fcntl.h>
57 #include <sys/types.h>
58 #include <net/netdb.h> /* in wpcap's Win32/include */
60 #if !defined(__MINGW32__) && !defined(__WATCOMC__)
61 #undef toascii
62 #define isascii __isascii
63 #define toascii __toascii
64 #define stat _stat
65 #define open _open
66 #define fstat _fstat
67 #define read _read
68 #define close _close
69 #define O_RDONLY _O_RDONLY
71 typedef short ino_t;
72 #endif /* __MINGW32__ */
74 #ifdef __MINGW32__
75 #include <stdint.h>
76 #endif
78 /* Protos for missing/x.c functions (ideally <missing/addrinfo.h>
79 * should be used, but it clashes with <ws2tcpip.h>).
81 extern const char *inet_ntop (int, const void *, char *, size_t);
82 extern int inet_pton (int, const char *, void *);
83 extern int inet_aton (const char *cp, struct in_addr *addr);
85 #ifndef INET6_ADDRSTRLEN
86 #define INET6_ADDRSTRLEN 46
87 #endif
89 #ifndef toascii
90 #define toascii(c) ((c) & 0x7f)
91 #endif
93 #ifndef caddr_t
94 typedef char* caddr_t;
95 #endif /* caddr_t */
97 #define MAXHOSTNAMELEN 64
98 #define NI_MAXHOST 1025
99 #define snprintf _snprintf
100 #define vsnprintf _vsnprintf
101 #define RETSIGTYPE void
103 #else /* WIN32 */
105 #include <ctype.h>
106 #include <unistd.h>
107 #include <netdb.h>
108 #if HAVE_INTTYPES_H
109 #include <inttypes.h>
110 #else
111 #if HAVE_STDINT_H
112 #include <stdint.h>
113 #endif
114 #endif
115 #ifdef HAVE_SYS_BITYPES_H
116 #include <sys/bitypes.h>
117 #endif
118 #include <sys/param.h>
119 #include <sys/types.h> /* concession to AIX */
120 #include <sys/time.h>
121 #include <sys/socket.h>
122 #include <netinet/in.h>
124 #ifdef TIME_WITH_SYS_TIME
125 #include <time.h>
126 #endif
128 #include <arpa/inet.h>
130 #endif /* WIN32 */
132 #ifdef INET6
133 #include "ip6.h"
134 #endif
136 #if defined(WIN32) || defined(MSDOS)
137 #define FOPEN_READ_TXT "rt"
138 #define FOPEN_READ_BIN "rb"
139 #define FOPEN_WRITE_TXT "wt"
140 #define FOPEN_WRITE_BIN "wb"
141 #else
142 #define FOPEN_READ_TXT "r"
143 #define FOPEN_READ_BIN FOPEN_READ_TXT
144 #define FOPEN_WRITE_TXT "w"
145 #define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
146 #endif
148 #if defined(__GNUC__) && defined(__i386__) && !defined(__ntohl)
149 #undef ntohl
150 #undef ntohs
151 #undef htonl
152 #undef htons
154 extern __inline__ unsigned long __ntohl (unsigned long x);
155 extern __inline__ unsigned short __ntohs (unsigned short x);
157 #define ntohl(x) __ntohl(x)
158 #define ntohs(x) __ntohs(x)
159 #define htonl(x) __ntohl(x)
160 #define htons(x) __ntohs(x)
162 extern __inline__ unsigned long __ntohl (unsigned long x)
164 __asm__ ("xchgb %b0, %h0\n\t" /* swap lower bytes */
165 "rorl $16, %0\n\t" /* swap words */
166 "xchgb %b0, %h0" /* swap higher bytes */
167 : "=q" (x) : "0" (x));
168 return (x);
171 extern __inline__ unsigned short __ntohs (unsigned short x)
173 __asm__ ("xchgb %b0, %h0" /* swap bytes */
174 : "=q" (x) : "0" (x));
175 return (x);
177 #endif
179 #ifndef INET_ADDRSTRLEN
180 #define INET_ADDRSTRLEN 16
181 #endif
183 #ifndef TRUE
184 #define TRUE 1
185 #endif
187 #ifndef FALSE
188 #define FALSE 0
189 #endif
191 #endif /* tcpdump_stdinc_h */