]> The Tcpdump Group git mirrors - tcpdump/blob - tcpdump-stdinc.h
Modified the license at the beginning of the files created by the Politecno di Torino...
[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
33 /*
34 * Include the appropriate OS header files on Windows and various flavors
35 * of UNIX, and also define some additional items and include various
36 * non-OS header files on Windows, and; this isolates most of the platform
37 * differences to this one file.
38 */
39
40 #ifndef tcpdump_stdinc_h
41 #define tcpdump_stdinc_h
42
43 #ifdef WIN32
44
45 #include <stdio.h>
46 #include <winsock2.h>
47 #include "bittypes.h"
48 #include <ctype.h>
49 #include <time.h>
50 #include <io.h>
51 #include "IP6_misc.h"
52 #include <fcntl.h>
53
54 #ifdef __MINGW32__
55 #include <stdint.h>
56 int* _errno();
57 #define errno (*_errno())
58
59 #define INET_ADDRSTRLEN 16
60 #define INET6_ADDRSTRLEN 46
61
62 #endif /* __MINGW32__ */
63
64 #ifndef toascii
65 #define toascii(c) ((c) & 0x7f)
66 #endif
67
68 #ifndef caddr_t
69 typedef char* caddr_t;
70 #endif /* caddr_t */
71
72 #define MAXHOSTNAMELEN 64
73 #define NI_MAXHOST 1025
74 #define IPPROTO_EGP 8 /* Exterior Gateway Protocol */
75 #define snprintf _snprintf
76 #define vsnprintf _vsnprintf
77 #define RETSIGTYPE void
78
79 #if !defined(__MINGW32__) && !defined(__WATCOMC__)
80 #undef toascii
81 #define isascii __isascii
82 #define toascii __toascii
83 #define stat _stat
84 #define open _open
85 #define fstat _fstat
86 #define read _read
87 #define O_RDONLY _O_RDONLY
88
89 typedef short ino_t;
90 #endif /* __MINGW32__ */
91
92 #else /* WIN32 */
93
94 #include <ctype.h>
95 #include <unistd.h>
96 #include <netdb.h>
97 #include <sys/param.h>
98 #include <sys/types.h> /* concession to AIX */
99 #include <sys/time.h>
100 #include <sys/socket.h>
101 #include <netinet/in.h>
102
103 #ifdef TIME_WITH_SYS_TIME
104 #include <time.h>
105 #endif
106
107 #include <arpa/inet.h>
108
109 #endif /* WIN32 */
110
111 #ifdef INET6
112 #include "ip6.h"
113 #endif
114
115 #if defined(WIN32) || defined(MSDOS)
116 #define FOPEN_READ_TXT "rt"
117 #define FOPEN_READ_BIN "rb"
118 #define FOPEN_WRITE_TXT "wt"
119 #define FOPEN_WRITE_BIN "wb"
120 #else
121 #define FOPEN_READ_TXT "r"
122 #define FOPEN_READ_BIN FOPEN_READ_TXT
123 #define FOPEN_WRITE_TXT "w"
124 #define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
125 #endif
126
127 #endif /* tcpdump_stdinc_h */