Go to the documentation of this file.
26 #ifndef SURICATA_SURICATA_COMMON_H
27 #define SURICATA_SURICATA_COMMON_H
44 #if defined(__clang_analyzer__)
47 #define DEBUG_VALIDATION 1
52 void ScanBuildMarkSanitized(
const void *);
56 #define __has_feature(x) 0
58 #if defined(__has_feature)
59 #if __has_feature(address_sanitizer)
60 #define SC_ADDRESS_SANITIZER 1
62 #elif defined(__SANITIZE_ADDRESS__)
63 #define SC_ADDRESS_SANITIZER 1
69 #define REVISION "undefined"
71 #ifndef __SCFILENAME__
72 #define __SCFILENAME__ "undefined"
76 #warning "L1 cache line size not detected during build. Assuming 64 bytes."
117 #include <inttypes.h>
129 #ifndef __STDC_WANT_LIB_EXT1__
130 #define __STDC_WANT_LIB_EXT1__ 1
150 #if HAVE_SYS_SYSCALL_H
151 #include <sys/syscall.h>
159 #include <sys/types.h>
166 #ifdef HAVE_TYPE_U_LONG_NOT_DEFINED
167 typedef unsigned long int u_long;
169 #ifdef HAVE_TYPE_U_INT_NOT_DEFINED
170 typedef unsigned int u_int;
172 #ifdef HAVE_TYPE_U_SHORT_NOT_DEFINED
173 typedef unsigned short u_short;
175 #ifdef HAVE_TYPE_U_CHAR_NOT_DEFINED
176 typedef unsigned char u_char;
195 #include <sys/time.h>
202 #if HAVE_SYS_SIGNAL_H
203 #include <sys/signal.h>
210 #if HAVE_SYS_SOCKET_H
211 #include <sys/socket.h>
215 #include <sys/stat.h>
219 #include <sys/ioctl.h>
223 #include <sys/mman.h>
226 #if HAVE_SYS_RANDOM_H
227 #include <sys/random.h>
230 #if HAVE_NETINET_IN_H
231 #include <netinet/in.h>
235 #include <arpa/inet.h>
247 #if !defined _X86_ && !defined __x86_64
253 #ifdef HAVE_WINSOCK2_H
254 #include <winsock2.h>
256 #ifdef HAVE_WS2TCPIP_H
257 #include <ws2tcpip.h>
261 #ifdef HAVE_WINDOWS_H
263 #define _WIN32_WINNT 0x0501
268 #ifdef HAVE_W32API_WINBASE_H
269 #include <w32api/winbase.h>
272 #ifdef HAVE_W32API_WTYPES_H
273 #include <w32api/wtypes.h>
276 #ifndef SC_PCAP_DONT_INCLUDE_PCAP_H
281 #ifdef HAVE_PCAP_PCAP_H
282 #include <pcap/pcap.h>
303 #ifndef JSON_ESCAPE_SLASH
304 #define JSON_ESCAPE_SLASH 0
315 #ifdef HAVE_MM_MALLOC_H
316 #include <mm_malloc.h>
321 #define xstr(s) str(s)
325 #define BUG_ON(x) if (((x))) exit(1)
327 #if defined HAVE_ASSERT_H && !defined NDEBUG
329 #define BUG_ON(x) assert(!(x))
331 #define BUG_ON(x) do { \
333 fprintf(stderr, "BUG at %s:%d(%s)\n", __FILE__, __LINE__, __func__); \
334 fprintf(stderr, "Code: '%s'\n", xstr((x))); \
335 exit(EXIT_FAILURE); \
346 #define SigIntId uint32_t
349 #define PatIntId uint32_t
354 #define __WORDSIZE __LONG_BIT
357 #define __WORDSIZE LONG_BIT
364 #if defined(__X86__) || defined(_X86_) || defined(_M_IX86)
365 #define __WORDSIZE 32
367 #if defined(__X86_64__) || defined(_X86_64_) || \
368 defined(__x86_64) || defined(__x86_64__) || \
369 defined(__amd64) || defined(__amd64__)
370 #define __WORDSIZE 64
377 #if defined(_ILP32) || defined(__ILP32__)
378 #define __WORDSIZE 32
380 #if defined(_LP64) || defined(__LP64__)
381 #define __WORDSIZE 64
386 #warning Defaulting to __WORDSIZE 32
387 #define __WORDSIZE 32
392 #if defined(BYTE_ORDER)
393 #define __BYTE_ORDER BYTE_ORDER
394 #elif defined(__BYTE_ORDER__)
395 #define __BYTE_ORDER __BYTE_ORDER__
397 #error "byte order not detected"
401 #ifndef __LITTLE_ENDIAN
402 #if defined(LITTLE_ENDIAN)
403 #define __LITTLE_ENDIAN LITTLE_ENDIAN
404 #elif defined(__ORDER_LITTLE_ENDIAN__)
405 #define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
410 #if defined(BIG_ENDIAN)
411 #define __BIG_ENDIAN BIG_ENDIAN
412 #elif defined(__ORDER_BIG_ENDIAN__)
413 #define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
417 #if !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN)
418 #error "byte order: can't figure out big or little"
422 #define MIN(x, y) (((x)<(y))?(x):(y))
426 #define MAX(x, y) (((x)<(y))?(y):(x))
429 #define BIT_U8(n) ((uint8_t)(1 << (n)))
430 #define BIT_U16(n) ((uint16_t)(1 << (n)))
431 #define BIT_U32(n) ((uint32_t)(1UL << (n)))
432 #define BIT_U64(n) (1ULL << (n))
434 #define WARN_UNUSED __attribute__((warn_unused_result))
436 #if defined(__MINGW32__)
437 #define ATTR_FMT_PRINTF(x, y) __attribute__((format(__MINGW_PRINTF_FORMAT, (x), (y))))
438 #elif defined(__GNUC__)
439 #define ATTR_FMT_PRINTF(x, y) __attribute__((format(printf, (x), (y))))
441 #define ATTR_FMT_PRINTF(x, y)
444 #define SCNtohl(x) (uint32_t)ntohl((x))
445 #define SCNtohs(x) (uint16_t)ntohs((x))
448 #define SWAP_FLAGS(flags, a, b) \
450 if (((flags) & ((a)|(b))) == (a)) { \
453 } else if (((flags) & ((a)|(b))) == (b)) { \
459 #define SWAP_VARS(type, a, b) \
467 #define u8_tolower(c) ((uint8_t)tolower((uint8_t)(c)))
468 #define u8_toupper(c) ((uint8_t)toupper((uint8_t)(c)))
551 size_t strlcat(
char *,
const char *
src,
size_t siz);
556 #ifndef HAVE_STRPTIME
557 char *
strptime(
const char * __restrict,
const char * __restrict,
struct tm * __restrict);
560 #ifndef HAVE_FWRITE_UNLOCKED
561 #define SCFwriteUnlocked fwrite
562 #define SCFflushUnlocked fflush
563 #define SCClearErrUnlocked clearerr
564 #define SCFerrorUnlocked ferror
566 #define SCFwriteUnlocked fwrite_unlocked
567 #define SCFflushUnlocked fflush_unlocked
568 #define SCClearErrUnlocked clearerr_unlocked
569 #define SCFerrorUnlocked ferror_unlocked
575 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
size_t strlcpy(char *dst, const char *src, size_t siz)
struct lua_State lua_State
char * strptime(const char *__restrict, const char *__restrict, struct tm *__restrict)
size_t strlcat(char *, const char *src, size_t siz)
enum PacketProfileDetectId_ PacketProfileDetectId
@ LOGGER_TLS_STORE_CLIENT