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;
186 #include <sys/time.h>
193 #if HAVE_SYS_SIGNAL_H
194 #include <sys/signal.h>
201 #if HAVE_SYS_SOCKET_H
202 #include <sys/socket.h>
206 #include <sys/stat.h>
210 #include <sys/ioctl.h>
214 #include <sys/mman.h>
217 #if HAVE_SYS_RANDOM_H
218 #include <sys/random.h>
221 #if HAVE_NETINET_IN_H
222 #include <netinet/in.h>
226 #include <arpa/inet.h>
238 #if !defined _X86_ && !defined __x86_64
244 #ifdef HAVE_WINSOCK2_H
245 #include <winsock2.h>
247 #ifdef HAVE_WS2TCPIP_H
248 #include <ws2tcpip.h>
252 #ifdef HAVE_WINDOWS_H
254 #define _WIN32_WINNT 0x0501
259 #ifdef HAVE_W32API_WINBASE_H
260 #include <w32api/winbase.h>
263 #ifdef HAVE_W32API_WTYPES_H
264 #include <w32api/wtypes.h>
267 #ifndef SC_PCAP_DONT_INCLUDE_PCAP_H
272 #ifdef HAVE_PCAP_PCAP_H
273 #include <pcap/pcap.h>
294 #ifndef JSON_ESCAPE_SLASH
295 #define JSON_ESCAPE_SLASH 0
306 #ifdef HAVE_MM_MALLOC_H
307 #include <mm_malloc.h>
312 #define xstr(s) str(s)
316 #define BUG_ON(x) if (((x))) exit(1)
318 #if defined HAVE_ASSERT_H && !defined NDEBUG
320 #define BUG_ON(x) assert(!(x))
322 #define BUG_ON(x) do { \
324 fprintf(stderr, "BUG at %s:%d(%s)\n", __FILE__, __LINE__, __func__); \
325 fprintf(stderr, "Code: '%s'\n", xstr((x))); \
326 exit(EXIT_FAILURE); \
337 #define SigIntId uint32_t
340 #define PatIntId uint32_t
345 #define __WORDSIZE __LONG_BIT
348 #define __WORDSIZE LONG_BIT
355 #if defined(__X86__) || defined(_X86_) || defined(_M_IX86)
356 #define __WORDSIZE 32
358 #if defined(__X86_64__) || defined(_X86_64_) || \
359 defined(__x86_64) || defined(__x86_64__) || \
360 defined(__amd64) || defined(__amd64__)
361 #define __WORDSIZE 64
368 #if defined(_ILP32) || defined(__ILP32__)
369 #define __WORDSIZE 32
371 #if defined(_LP64) || defined(__LP64__)
372 #define __WORDSIZE 64
377 #warning Defaulting to __WORDSIZE 32
378 #define __WORDSIZE 32
383 #if defined(BYTE_ORDER)
384 #define __BYTE_ORDER BYTE_ORDER
385 #elif defined(__BYTE_ORDER__)
386 #define __BYTE_ORDER __BYTE_ORDER__
388 #error "byte order not detected"
392 #ifndef __LITTLE_ENDIAN
393 #if defined(LITTLE_ENDIAN)
394 #define __LITTLE_ENDIAN LITTLE_ENDIAN
395 #elif defined(__ORDER_LITTLE_ENDIAN__)
396 #define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
401 #if defined(BIG_ENDIAN)
402 #define __BIG_ENDIAN BIG_ENDIAN
403 #elif defined(__ORDER_BIG_ENDIAN__)
404 #define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
408 #if !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN)
409 #error "byte order: can't figure out big or little"
413 #define MIN(x, y) (((x)<(y))?(x):(y))
417 #define MAX(x, y) (((x)<(y))?(y):(x))
420 #define BIT_U8(n) ((uint8_t)(1 << (n)))
421 #define BIT_U16(n) ((uint16_t)(1 << (n)))
422 #define BIT_U32(n) ((uint32_t)(1UL << (n)))
423 #define BIT_U64(n) (1ULL << (n))
425 #define WARN_UNUSED __attribute__((warn_unused_result))
427 #if defined(__MINGW32__)
428 #define ATTR_FMT_PRINTF(x, y) __attribute__((format(__MINGW_PRINTF_FORMAT, (x), (y))))
429 #elif defined(__GNUC__)
430 #define ATTR_FMT_PRINTF(x, y) __attribute__((format(printf, (x), (y))))
432 #define ATTR_FMT_PRINTF(x, y)
435 #define SCNtohl(x) (uint32_t)ntohl((x))
436 #define SCNtohs(x) (uint16_t)ntohs((x))
439 #define SWAP_FLAGS(flags, a, b) \
441 if (((flags) & ((a)|(b))) == (a)) { \
444 } else if (((flags) & ((a)|(b))) == (b)) { \
450 #define SWAP_VARS(type, a, b) \
458 #define u8_tolower(c) ((uint8_t)tolower((uint8_t)(c)))
459 #define u8_toupper(c) ((uint8_t)toupper((uint8_t)(c)))
539 size_t strlcat(
char *,
const char *
src,
size_t siz);
544 #ifndef HAVE_STRPTIME
545 char *
strptime(
const char * __restrict,
const char * __restrict,
struct tm * __restrict);
548 #ifndef HAVE_FWRITE_UNLOCKED
549 #define SCFwriteUnlocked fwrite
550 #define SCFflushUnlocked fflush
551 #define SCClearErrUnlocked clearerr
552 #define SCFerrorUnlocked ferror
554 #define SCFwriteUnlocked fwrite_unlocked
555 #define SCFflushUnlocked fflush_unlocked
556 #define SCClearErrUnlocked clearerr_unlocked
557 #define SCFerrorUnlocked ferror_unlocked
563 #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