]> The Tcpdump Group git mirrors - libpcap/blob - pcap-stdinc.h
pcap_create_interface() needs the interface name on Linux.
[libpcap] / pcap-stdinc.h
1 /*
2 * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy)
3 * Copyright (c) 2005 - 2009 CACE Technologies, Inc. Davis (California)
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 * Copyright (C) 1999 WIDE Project.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the project nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 */
60 #ifndef pcap_stdinc_h
61 #define pcap_stdinc_h
62
63 /*
64 * Avoids a compiler warning in case this was already defined
65 * (someone defined _WINSOCKAPI_ when including 'windows.h', in order
66 * to prevent it from including 'winsock.h')
67 */
68 #ifdef _WINSOCKAPI_
69 #undef _WINSOCKAPI_
70 #endif
71
72 #include <winsock2.h>
73 #include <fcntl.h>
74 #include <time.h>
75 #include <io.h>
76
77 #include <ws2tcpip.h>
78
79 #if defined(_MSC_VER)
80 /*
81 * MSVC.
82 */
83
84 #if _MSC_VER >= 1900
85 /*
86 * VS 2015 or newer; we have snprintf() function.
87 */
88 #define HAVE_SNPRINTF
89 #endif
90
91 #if _MSC_VER >= 1800
92 /*
93 * VS 2013 or newer; we have <inttypes.h>.
94 */
95 #include <inttypes.h>
96
97 #define u_int8_t uint8_t
98 #define u_int16_t uint16_t
99 #define u_int32_t uint32_t
100 #define u_int64_t uint64_t
101 #else
102 /*
103 * Earlier VS; we have to define this stuff ourselves.
104 */
105 #ifndef HAVE_U_INT8_T
106 typedef unsigned char u_int8_t;
107 typedef signed char int8_t;
108 #endif
109
110 #ifndef HAVE_U_INT16_T
111 typedef unsigned short u_int16_t;
112 typedef signed short int16_t;
113 #endif
114
115 #ifndef HAVE_U_INT32_T
116 typedef unsigned int u_int32_t;
117 typedef signed int int32_t;
118 #endif
119
120 #ifndef HAVE_U_INT64_T
121 #ifdef _MSC_EXTENSIONS
122 typedef unsigned _int64 u_int64_t;
123 typedef _int64 int64_t;
124 #else /* _MSC_EXTENSIONS */
125 typedef unsigned long long u_int64_t;
126 typedef long long int64_t;
127 #endif
128 #endif
129 #endif
130 #elif defined(__MINGW32__)
131 #include <stdint.h>
132 #endif
133
134 /*
135 * These may be defined by <inttypes.h>.
136 *
137 * XXX - for MSVC, we always want the _MSC_EXTENSIONS versions.
138 * What about other compilers? If, as the MinGW Web site says MinGW
139 * does, the other compilers just use Microsoft's run-time library,
140 * then they should probably use the _MSC_EXTENSIONS even if the
141 * compiler doesn't define _MSC_EXTENSIONS.
142 */
143 #ifndef PRId64
144 #ifdef _MSC_EXTENSIONS
145 #define PRId64 "I64d"
146 #else
147 #define PRId64 "lld"
148 #endif
149 #endif /* PRId64 */
150
151 #ifndef PRIo64
152 #ifdef _MSC_EXTENSIONS
153 #define PRIo64 "I64o"
154 #else
155 #define PRIo64 "llo"
156 #endif
157 #endif /* PRIo64 */
158
159 #ifndef PRIx64
160 #ifdef _MSC_EXTENSIONS
161 #define PRIx64 "I64x"
162 #else
163 #define PRIx64 "llx"
164 #endif
165 #endif
166
167 #ifndef PRIu64
168 #ifdef _MSC_EXTENSIONS
169 #define PRIu64 "I64u"
170 #else
171 #define PRIu64 "llu"
172 #endif
173 #endif
174
175 #ifdef _MSC_VER
176 #define strdup _strdup
177 #endif
178
179 #if !defined(__cplusplus)
180 #define inline __inline
181 #endif
182
183 #endif /* pcap_stdinc_h */