1 /****************************************************************************
2 *
3 * Copyright (C) 2014-2020 Cisco and/or its affiliates. All rights reserved.
4 * Copyright (C) 2005-2013 Sourcefire, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License Version 2 as
8 * published by the Free Software Foundation. You may not use, modify or
9 * distribute this program under any other version of the GNU General
10 * Public License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 ****************************************************************************/
22 /* $Id$ */
23
24 #ifndef __CONFIG_H__
25 #define __CONFIG_H__
26
27 /* config.h. Generated automatically by configure. */
28 /* config.h.in. Generated automatically from configure.in by autoheader. */
29
30 /* Define if on AIX 3.
31 System headers sometimes define this.
32 We just want to avoid a redefinition error message. */
33 #ifndef _ALL_SOURCE
34 /* #undef _ALL_SOURCE */
35 #endif
36
37 /* Define if you have the ANSI C header files. */
38 /* #undef STDC_HEADERS */
39
40 /* Define if your processor stores words with the most significant
41 byte first (like Motorola and SPARC, unlike Intel and VAX). */
42 #define WORDS_LITTLEENDIAN 1
43
44 #define WIN32 1
45
46 #define ERRLIST_PREDEFINED 1
47
48 /* Define if you have the snprintf function. */
49 #define HAVE_SNPRINTF 1
50
51 /* Define if you have the strerror function. */
52 #define HAVE_STRERROR 1
53
54 /* Define if you have the <stdlib.h> header file. */
55 #define HAVE_STDLIB_H 1
56
57 /* Define if you have the <stdint.h> header file. */
58 #define HAVE_STDINT_H 1
59
60 /* Define if you have the <string.h> header file. */
61 #define HAVE_STRING_H 1
62
63 /* Define if you have the <unistd.h> header file. */
64 #define HAVE_UNISTD_H 1
65
66 /* Define if you have the pcap library (-lpcap). */
67 #define HAVE_LIBPCAP 1
68
69 /* Define if you have vswprintf() function */
70 #define HAVE_VSWPRINTF 1
71
72 /* Define if you have wprintf() function */
73 #define HAVE_WPRINTF 1
74
75 /* Define to 1 if you have the <wchar.h> header file. */
76 #define HAVE_WCHAR_H 1
77
78 /* Define to 1 if you have zlib support. */
79 #define HAVE_ZLIB 1
80
81 #ifndef SIZEOF_LONG_INT
82 #define SIZEOF_LONG_INT 4
83 #endif
84
85 #ifdef ENABLE_RESPONSE
86 #define VERSION_ENABLE_RESPONSE "-FlexRESP"
87 #else
88 #define VERSION_ENABLE_RESPONSE
89 #endif
90
91 #ifdef DEBUG
92 #define VERSION_DEBUG " [DEBUG] "
93 #else
94 #define VERSION_DEBUG
95 #endif
96
97 #define LIBPCAP_ACCUMULATES
98
99 /*
100 * This version number here, and package name below,
101 * should both match the ones specified in the
102 * AM_INIT_AUTOMAKE() macro of configure.in
103 */
104 #define VERSION "2.9.18"VERSION_ENABLE_RESPONSE"-WIN32"VERSION_DEBUG
105 #define PACKAGE "snort"
106
107 #define IFNAMSIZ 255
108
109 /* _WIN32_WINNT has been modified to support SetDllDirectory API introduced in
110 * Windows Server 2003 with SP1 and Windows XP with SP2 for Windows DLL Load Vulnerability.
111 * As per documentation available on support forum, the macro corresponding to 0x0502 is _WIN32_WINNT_WS03.
112 * However, Visual studio 6.0 on Win XP SP3 reports this as an undeclared identifier.
113 * So, we decided to use numerical value instead of macro.
114 */
115 #undef _WIN32_WINNT
116 #define _WIN32_WINNT 0x0502
117 #undef NTDDI_VERSION
118 #define NTDDI_VERSION 0x05020000
119
120 /* Abuse header guards to prevent winscard.h from being included.
121 This was needed to prevent conflict with sqlfront.h */
122 #define _WINSCARD_H_
123
124 #include <winsock2.h>
125 #include <windows.h>
126 #ifdef _MSC_VER
127 #pragma warning( disable : 4028 )
128 #endif
129 #include <io.h>
130 #include <process.h>
131 #ifdef _MSC_VER
132 #pragma warning( default : 4028 )
133 #endif
134 #include <sys/timeb.h>
135 #include <direct.h>
136 #include <getopt.h>
137 #ifndef __MINGW32__
138 typedef int pid_t;
139 #endif
140 #ifndef __CYGWIN__
141 typedef long ssize_t;
142 #endif
143 #include <ws2tcpip.h>
144 #include "rpc/types.h"
145
146 #undef interface
147
148 /* Declare standard integer datatypes */
149 #ifdef u_int8_t
150 #undef u_int8_t
151 #endif
152 #ifdef u_int16_t
153 #undef u_int16_t
154 #endif
155 #ifdef u_int32_t
156 #undef u_int32_t
157 #endif
158 #include <stdint.h>
159
160 #ifndef INET6_ADDRSTRLEN
161 #define INET6_ADDRSTRLEN 46
162 #endif
163
164 #if defined(WIN32) && !defined(inline)
165 #define inline __inline
166 #endif
167
168 /* required for some calls to open(),
169 * but it isn't defined under Win32.
170 * Using 0x0080 to match <fcntl.h>
171 * from OpenBSD.
172 */
173 #ifndef O_SYNC
174 #define O_SYNC 0x0080
175 #endif
176
177
178 #ifndef CDECL
179 #define CDECL __cdecl
180 #endif
181
182
183 // #define SIGKILL 9 /* kill (cannot be caught or ignored) */
184 #define SIGQUIT 3 /* quit */
185 #define SIGNAL_SNORT_RELOAD 1 /* Reload */
186 #define SIGNAL_SNORT_DUMP_STATS 30 /* Dump stats */
187 #define SIGNAL_SNORT_ROTATE_STATS 31 /* Rotate stats */
188 #define SIGPIPE 13 /* write on a pipe with no one to read it */
189 // #define EEXIST 17 /* File exists */
190 #ifndef W_OK
191 #define W_OK 0x02 /* test for write permission */
192 #endif
193 #ifndef R_OK
194 #define R_OK 0x04 /* test for read permission */
195 #endif
196 #define S_ISDIR(x) (((x) & 0170000) == 0040000) /* directory */
197 #define S_IRWXU 0000700 /* RWX mask for owner */
198 #define S_IRWXG 0000070 /* RWX mask for group */
199 #define S_IROTH 0000004 /* R for other */
200 #define S_IXOTH 0000001 /* X for other */
201
202 #define bcopy(src, dst, count) memcpy((void *)dst, (const void *)src, (size_t) count)
203 #define bzero(addr, count) memset((addr), 0, (count))
204 #define index strchr
205 #define mkdir(x, y) _mkdir(x)
206 #define snprintf _snprintf
207 #define strncasecmp strnicmp
208 #define strcasecmp stricmp
209 #define ftruncate _chsize
210 #if _MSC_VER < 1500 /* VC9 defines this */
211 #define vsnprintf _vsnprintf
212 #define strdup _strdup
213 #endif
214 #define IXDR_GET_LONG(buf) ((long)ntohl((u_long)*(buf)++))
215 #define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf))
216 #define RPC_MSG_VERSION ((u_long) 2)
217
218 char * strtok_r(char *s1, const char *s2, char **lasts);
219 int inet_aton(const char *cp, struct in_addr *addr);
220 int inet_pton(int af, const char *src, void *dst);
221
222 enum msg_type {
223 CALL=0,
224 REPLY=1
225 };
226
227 typedef unsigned long mode_t;
228
229 struct timezone {
230 int tz_minuteswest; /* minutes west of Greenwich */
231 int tz_dsttime; /* type of dst correction */
232 };
233
234 /*
235 * Interface request structure used for socket
236 * ioctl's. All interface ioctl's must have parameter
237 * definitions which begin with ifr_name. The
238 * remainder may be interface specific.
239 */
240 struct ifreq {
241 char ifr_name[128]; /* if name, e.g. "en0" */
242 union {
243 struct sockaddr ifru_addr;
244 struct sockaddr ifru_dstaddr;
245 struct sockaddr ifru_broadaddr;
246 short ifru_flags;
247 int ifru_metric;
248 caddr_t ifru_data;
249 } ifr_ifru;
250 #define ifr_addr ifr_ifru.ifru_addr /* address */
251 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
252 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
253 #define ifr_flags ifr_ifru.ifru_flags /* flags */
254 #define ifr_metric ifr_ifru.ifru_metric /* metric */
255 #define ifr_mtu ifr_ifru.ifru_metric /* mtu (overload) */
256 #define ifr_media ifr_ifru.ifru_metric /* media options (overload) */
257 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
258 };
259
260
261 #define RUSAGE_SELF 0 /* calling process */
262 #define RUSAGE_CHILDREN -1 /* terminated child processes */
263 struct rusage
264 {
265 struct timeval ru_utime;/* user time used */
266 struct timeval ru_stime;/* system time used */
267 long ru_maxrss;
268 long ru_ixrss; /* integral shared memory size */
269 long ru_idrss; /* integral unshared data " */
270 long ru_isrss; /* integral unshared stack " */
271 long ru_minflt; /* page reclaims */
272 long ru_majflt; /* page faults */
273 long ru_nswap; /* swaps */
274 long ru_inblock; /* block input operations */
275 long ru_oublock; /* block output operations */
276 long ru_msgsnd; /* messages sent */
277 long ru_msgrcv; /* messages received */
278 long ru_nsignals; /* signals received */
279 long ru_nvcsw; /* voluntary context switches */
280 long ru_nivcsw; /* involuntary " */
281 };
282
283 int gettimeofday(struct timeval *,struct timezone *);
284 void *GetAdapterFromList(void *, int);
285 char *print_interface(const char *);
286 void PrintDeviceList(const char *);
287 int init_winsock(void);
288 int ffs(int x);
289
isblank(int c)290 inline int isblank(int c)
291 {
292 if (c == ' ' || c == '\t' || c == '\v')
293 return 1;
294
295 return 0;
296 }
297
298 #if defined(ENABLE_WIN32_SERVICE)
299 #define SERVICE_CMDLINE_PARAM "/SERVICE"
300 #define SERVICE_INSTALL_CMDLINE_PARAM "/INSTALL"
301 #define SERVICE_UNINSTALL_CMDLINE_PARAM "/UNINSTALL"
302 #define SERVICE_SHOW_CMDLINE_PARAM "/SHOW"
303 int SnortServiceMain(int argc, char* argv[]);
304 #endif /* ENABLE_WIN32_SERVICE */
305
306 #ifndef S_IFIFO
307 #define S_IFIFO _S_IFIFO
308 #endif
309
310 #ifndef __FUNCTION__
311 #if _MSV_VER < 1300
312 #define __FUNCTION__ "dont know"
313 #else
314 #define __FUNCTION__ __func__
315 #endif
316 #endif
317
318 #endif /* __CONFIG_H__ */
319
320