]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - 6/contrib/tcpdump/tcpdump-stdinc.h
Clone Kip's Xen on stable/6 tree so that I can work on improving FreeBSD/amd64
[FreeBSD/FreeBSD.git] / 6 / contrib / tcpdump / tcpdump-stdinc.h
1 /*
2  * Copyright (c) 2002 - 2003
3  * NetGroup, Politecnico di Torino (Italy)
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
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.
18  *
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.
30  *
31  *
32  * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.12.2.4 2005/07/09 21:19:45 risso Exp $ (LBL)
33  *
34  * $FreeBSD$
35  */
36
37 /*
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.
42  */
43
44 #ifndef tcpdump_stdinc_h
45 #define tcpdump_stdinc_h
46
47 #ifdef WIN32
48
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 */
59
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
70
71 typedef short ino_t;
72 #endif /* __MINGW32__ */
73
74 #ifdef __MINGW32__
75 #include <stdint.h>
76 #endif
77
78 /* Protos for missing/x.c functions (ideally <missing/addrinfo.h>
79  * should be used, but it clashes with <ws2tcpip.h>).
80  */
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);
84
85 #ifndef INET6_ADDRSTRLEN
86 #define INET6_ADDRSTRLEN 46
87 #endif
88
89 #ifndef toascii
90 #define toascii(c) ((c) & 0x7f)
91 #endif
92
93 #ifndef caddr_t
94 typedef char* caddr_t;
95 #endif /* caddr_t */
96
97 #define MAXHOSTNAMELEN  64
98 #define NI_MAXHOST      1025
99 #define snprintf _snprintf
100 #define vsnprintf _vsnprintf
101 #define RETSIGTYPE void
102
103 #else /* WIN32 */
104
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>
123
124 #ifdef TIME_WITH_SYS_TIME
125 #include <time.h>
126 #endif
127
128 #include <arpa/inet.h>
129
130 #endif /* WIN32 */
131
132 #ifdef INET6
133 #include "ip6.h"
134 #endif
135
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
147
148 #ifndef INET_ADDRSTRLEN
149 #define INET_ADDRSTRLEN 16
150 #endif
151
152 #endif /* tcpdump_stdinc_h */