suricata
suricata-common.h File Reference
#include <pcre2.h>
#include <jansson.h>
#include <ctype.h>
#include "tm-threads-common.h"
#include "util-optimize.h"
#include "util-time.h"
#include "util-mem.h"
#include "util-memcmp.h"
#include "util-atomic.h"
#include "util-unittest.h"
#include "queue.h"
#include "tree.h"
Include dependency graph for suricata-common.h:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define __USE_GNU
 
#define CLS   64
 
#define JSON_ESCAPE_SLASH   0
 
#define xstr(s)   str(s)
 
#define str(s)   #s
 
#define BUG_ON(x)
 
#define SigIntId   uint32_t
 
#define PatIntId   uint32_t
 
#define __WORDSIZE   32
 
#define MIN(x, y)   (((x)<(y))?(x):(y))
 
#define MAX(x, y)   (((x)<(y))?(y):(x))
 
#define BIT_U8(n)   ((uint8_t)(1 << (n)))
 
#define BIT_U16(n)   ((uint16_t)(1 << (n)))
 
#define BIT_U32(n)   ((uint32_t)(1UL << (n)))
 
#define BIT_U64(n)   (1ULL << (n))
 
#define WARN_UNUSED   __attribute__((warn_unused_result))
 
#define ATTR_FMT_PRINTF(x, y)
 
#define SCNtohl(x)   (uint32_t)ntohl((x))
 
#define SCNtohs(x)   (uint16_t)ntohs((x))
 
#define SWAP_FLAGS(flags, a, b)
 
#define SWAP_VARS(type, a, b)
 
#define u8_tolower(c)   ((uint8_t)tolower((uint8_t)(c)))
 
#define u8_toupper(c)   ((uint8_t)toupper((uint8_t)(c)))
 
#define SCFwriteUnlocked   fwrite
 
#define SCFflushUnlocked   fflush
 
#define SCClearErrUnlocked   clearerr
 
#define SCFerrorUnlocked   ferror
 
#define ARRAY_SIZE(arr)   (sizeof(arr) / sizeof(arr[0]))
 

Typedefs

typedef enum PacketProfileDetectId_ PacketProfileDetectId
 
typedef struct lua_State lua_State
 

Enumerations

enum  PacketProfileDetectId_ {
  PROF_DETECT_SETUP, PROF_DETECT_GETSGH, PROF_DETECT_IPONLY, PROF_DETECT_RULES,
  PROF_DETECT_TX, PROF_DETECT_PF_PKT, PROF_DETECT_PF_PAYLOAD, PROF_DETECT_PF_TX,
  PROF_DETECT_PF_RECORD, PROF_DETECT_PF_SORT1, PROF_DETECT_PF_SORT2, PROF_DETECT_NONMPMLIST,
  PROF_DETECT_ALERT, PROF_DETECT_TX_UPDATE, PROF_DETECT_CLEANUP, PROF_DETECT_SIZE
}
 
enum  LoggerId {
  LOGGER_UNDEFINED, LOGGER_HTTP, LOGGER_TLS_STORE, LOGGER_TLS_STORE_CLIENT,
  LOGGER_TLS, LOGGER_JSON_TX, LOGGER_FILE, LOGGER_FILEDATA,
  LOGGER_ALERT_DEBUG, LOGGER_ALERT_FAST, LOGGER_ALERT_SYSLOG, LOGGER_JSON_ALERT,
  LOGGER_JSON_ANOMALY, LOGGER_JSON_DROP, LOGGER_FILE_STORE, LOGGER_JSON_FILE,
  LOGGER_TCP_DATA, LOGGER_JSON_FLOW, LOGGER_JSON_NETFLOW, LOGGER_STATS,
  LOGGER_JSON_STATS, LOGGER_PCAP, LOGGER_JSON_METADATA, LOGGER_JSON_FRAME,
  LOGGER_JSON_STREAM, LOGGER_JSON_ARP, LOGGER_USER, LOGGER_SIZE
}
 

Functions

size_t strlcat (char *, const char *src, size_t siz)
 
size_t strlcpy (char *dst, const char *src, size_t siz)
 
char * strptime (const char *__restrict, const char *__restrict, struct tm *__restrict)
 

Variables

int coverage_unittests
 
int g_ut_modules
 
int g_ut_covered
 

Detailed Description

Author
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t

Common includes, etc.

Definition in file suricata-common.h.

Macro Definition Documentation

◆ __USE_GNU

#define __USE_GNU

Definition at line 35 of file suricata-common.h.

◆ __WORDSIZE

#define __WORDSIZE   32

FreeBSD does not define __WORDSIZE, but it uses __LONG_BIT Windows does not define WORDSIZE, but it uses __X86 if not succesful yet try the data models

Definition at line 357 of file suricata-common.h.

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 34 of file suricata-common.h.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   arr)    (sizeof(arr) / sizeof(arr[0]))

Definition at line 546 of file suricata-common.h.

◆ ATTR_FMT_PRINTF

#define ATTR_FMT_PRINTF (   x,
 
)

Definition at line 411 of file suricata-common.h.

◆ BIT_U16

#define BIT_U16 (   n)    ((uint16_t)(1 << (n)))

Definition at line 400 of file suricata-common.h.

◆ BIT_U32

#define BIT_U32 (   n)    ((uint32_t)(1UL << (n)))

Definition at line 401 of file suricata-common.h.

◆ BIT_U64

#define BIT_U64 (   n)    (1ULL << (n))

Definition at line 402 of file suricata-common.h.

◆ BIT_U8

#define BIT_U8 (   n)    ((uint8_t)(1 << (n)))

Definition at line 399 of file suricata-common.h.

◆ BUG_ON

#define BUG_ON (   x)
Value:
do { \
if (((x))) { \
fprintf(stderr, "BUG at %s:%d(%s)\n", __FILE__, __LINE__, __func__); \
fprintf(stderr, "Code: '%s'\n", xstr((x))); \
exit(EXIT_FAILURE); \
} \
} while(0)

Definition at line 301 of file suricata-common.h.

◆ CLS

#define CLS   64

Definition at line 57 of file suricata-common.h.

◆ JSON_ESCAPE_SLASH

#define JSON_ESCAPE_SLASH   0

Definition at line 278 of file suricata-common.h.

◆ MAX

#define MAX (   x,
 
)    (((x)<(y))?(y):(x))

Definition at line 396 of file suricata-common.h.

◆ MIN

#define MIN (   x,
 
)    (((x)<(y))?(x):(y))

darwin doesn't defined __BYTE_ORDER and friends, but BYTE_ORDER

Definition at line 392 of file suricata-common.h.

◆ PatIntId

#define PatIntId   uint32_t

same for pattern id's

Definition at line 319 of file suricata-common.h.

◆ SCClearErrUnlocked

#define SCClearErrUnlocked   clearerr

Definition at line 534 of file suricata-common.h.

◆ SCFerrorUnlocked

#define SCFerrorUnlocked   ferror

Definition at line 535 of file suricata-common.h.

◆ SCFflushUnlocked

#define SCFflushUnlocked   fflush

Definition at line 533 of file suricata-common.h.

◆ SCFwriteUnlocked

#define SCFwriteUnlocked   fwrite

Definition at line 532 of file suricata-common.h.

◆ SCNtohl

#define SCNtohl (   x)    (uint32_t)ntohl((x))

Definition at line 414 of file suricata-common.h.

◆ SCNtohs

#define SCNtohs (   x)    (uint16_t)ntohs((x))

Definition at line 415 of file suricata-common.h.

◆ SigIntId

#define SigIntId   uint32_t

type for the internal signature id. Since it's used in the matching engine extensively keeping this as small as possible reduces the overall memory footprint of the engine. Set to uint32_t if the engine needs to support more than 64k sigs.

Definition at line 316 of file suricata-common.h.

◆ str

#define str (   s)    #s

Definition at line 292 of file suricata-common.h.

◆ SWAP_FLAGS

#define SWAP_FLAGS (   flags,
  a,
 
)
Value:
do { \
if (((flags) & ((a)|(b))) == (a)) { \
(flags) &= ~(a); \
(flags) |= (b); \
} else if (((flags) & ((a)|(b))) == (b)) { \
(flags) &= ~(b); \
(flags) |= (a); \
} \
} while(0)

Definition at line 418 of file suricata-common.h.

◆ SWAP_VARS

#define SWAP_VARS (   type,
  a,
 
)
Value:
do { \
type t = (a); \
(a) = (b); \
(b) = t; \
} while (0)

Definition at line 429 of file suricata-common.h.

◆ u8_tolower

#define u8_tolower (   c)    ((uint8_t)tolower((uint8_t)(c)))

Definition at line 437 of file suricata-common.h.

◆ u8_toupper

#define u8_toupper (   c)    ((uint8_t)toupper((uint8_t)(c)))

Definition at line 438 of file suricata-common.h.

◆ WARN_UNUSED

#define WARN_UNUSED   __attribute__((warn_unused_result))

Definition at line 404 of file suricata-common.h.

◆ xstr

#define xstr (   s)    str(s)

Definition at line 291 of file suricata-common.h.

Typedef Documentation

◆ lua_State

typedef struct lua_State lua_State

Definition at line 1 of file suricata-common.h.

◆ PacketProfileDetectId

Enumeration Type Documentation

◆ LoggerId

enum LoggerId
Note
update PacketProfileLoggerIdToString if you change anything here
Enumerator
LOGGER_UNDEFINED 
LOGGER_HTTP 
LOGGER_TLS_STORE 
LOGGER_TLS_STORE_CLIENT 
LOGGER_TLS 
LOGGER_JSON_TX 
LOGGER_FILE 
LOGGER_FILEDATA 
LOGGER_ALERT_DEBUG 
Warning
Note that transaction loggers here with a value > 31 will not work.
LOGGER_ALERT_FAST 
LOGGER_ALERT_SYSLOG 
LOGGER_JSON_ALERT 
LOGGER_JSON_ANOMALY 
LOGGER_JSON_DROP 
LOGGER_FILE_STORE 
LOGGER_JSON_FILE 
LOGGER_TCP_DATA 
LOGGER_JSON_FLOW 
LOGGER_JSON_NETFLOW 
LOGGER_STATS 
LOGGER_JSON_STATS 
LOGGER_PCAP 
LOGGER_JSON_METADATA 
LOGGER_JSON_FRAME 
LOGGER_JSON_STREAM 
LOGGER_JSON_ARP 
LOGGER_USER 
LOGGER_SIZE 

Definition at line 460 of file suricata-common.h.

◆ PacketProfileDetectId_

Enumerator
PROF_DETECT_SETUP 
PROF_DETECT_GETSGH 
PROF_DETECT_IPONLY 
PROF_DETECT_RULES 
PROF_DETECT_TX 
PROF_DETECT_PF_PKT 
PROF_DETECT_PF_PAYLOAD 
PROF_DETECT_PF_TX 
PROF_DETECT_PF_RECORD 
PROF_DETECT_PF_SORT1 
PROF_DETECT_PF_SORT2 
PROF_DETECT_NONMPMLIST 
PROF_DETECT_ALERT 
PROF_DETECT_TX_UPDATE 
PROF_DETECT_CLEANUP 
PROF_DETECT_SIZE 

Definition at line 439 of file suricata-common.h.

Function Documentation

◆ strlcat()

size_t strlcat ( char *  ,
const char *  src,
size_t  siz 
)

Definition at line 45 of file util-strlcatu.c.

References dst, and src.

Referenced by DetectAppLayerMpmRegisterByParentId(), PathMerge(), RunmodeAutoFpCreatePickupQueuesString(), ShortenString(), SSLVersionToString(), StringAsBase64(), and SysFsWriteValue().

Here is the caller graph for this function:

◆ strlcpy()

◆ strptime()

char* strptime ( const char *  __restrict,
const char *  __restrict,
struct tm *  __restrict 
)

Definition at line 97 of file util-strptime.c.

References ALT_E, ALT_O, and LEGAL_ALT.

Referenced by SCStringPatternToTime().

Here is the caller graph for this function:

Variable Documentation

◆ coverage_unittests

int coverage_unittests

Definition at line 889 of file suricata.c.

Referenced by SCParseCommandLine(), SigTableRegisterTests(), and TmModuleRegisterTests().

◆ g_ut_covered

int g_ut_covered

Definition at line 891 of file suricata.c.

Referenced by SCParseCommandLine(), SigTableRegisterTests(), and TmModuleRegisterTests().

◆ g_ut_modules

int g_ut_modules
xstr
#define xstr(s)
Definition: suricata-common.h:290
flags
uint8_t flags
Definition: decode-gre.h:0