suricata
suricata-common.h File Reference
#include <pcre.h>
#include <jansson.h>
#include "util-optimize.h"
#include <htp/htp.h>
#include "threads.h"
#include "tm-threads-common.h"
#include "util-debug.h"
#include "util-error.h"
#include "util-mem.h"
#include "detect-engine-alert.h"
#include "util-path.h"
#include "util-conf.h"
Include dependency graph for suricata-common.h:

Go to the source code of this file.

Macros

#define TRUE   1
 
#define FALSE   0
 
#define _GNU_SOURCE
 
#define __USE_GNU
 
#define CLS   64
 
#define JSON_ESCAPE_SLASH   0
 
#define json_boolean(val)   SCJsonBool((val))
 
#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 pcre_free_study   pcre_free
 
#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)   (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 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 void 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_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_DNS_TS, LOGGER_DNS_TC, LOGGER_HTTP,
  LOGGER_TLS_STORE, LOGGER_TLS, LOGGER_JSON_DNS_TS, LOGGER_JSON_DNS_TC,
  LOGGER_JSON_HTTP, LOGGER_JSON_SMTP, LOGGER_JSON_TLS, LOGGER_JSON_NFS,
  LOGGER_JSON_TFTP, LOGGER_JSON_FTP, LOGGER_JSON_DNP3_TS, LOGGER_JSON_DNP3_TC,
  LOGGER_JSON_SSH, LOGGER_JSON_SMB, LOGGER_JSON_IKEV2, LOGGER_JSON_KRB5,
  LOGGER_JSON_DHCP, LOGGER_JSON_SNMP, LOGGER_JSON_SIP, LOGGER_JSON_TEMPLATE_RUST,
  LOGGER_JSON_RFB, LOGGER_JSON_MQTT, LOGGER_JSON_TEMPLATE, LOGGER_JSON_RDP,
  LOGGER_JSON_DCERPC, LOGGER_JSON_HTTP2, LOGGER_ALERT_DEBUG, LOGGER_ALERT_FAST,
  LOGGER_UNIFIED2, LOGGER_ALERT_SYSLOG, LOGGER_DROP, 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_PRELUDE, LOGGER_PCAP, LOGGER_JSON_METADATA,
  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 38 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 339 of file suricata-common.h.

◆ _GNU_SOURCE

#define _GNU_SOURCE

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

◆ ARRAY_SIZE

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

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

◆ ATTR_FMT_PRINTF

#define ATTR_FMT_PRINTF (   x,
 
)

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

◆ BIT_U16

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

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

◆ BIT_U32

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

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

◆ BIT_U64

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

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

◆ BIT_U8

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

Definition at line 385 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 283 of file suricata-common.h.

◆ CLS

#define CLS   64

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

◆ FALSE

#define FALSE   0

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

◆ json_boolean

#define json_boolean (   val)    SCJsonBool((val))

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

◆ JSON_ESCAPE_SLASH

#define JSON_ESCAPE_SLASH   0

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

◆ MAX

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

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

◆ MIN

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

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

◆ PatIntId

#define PatIntId   uint32_t

same for pattern id's

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

◆ pcre_free_study

#define pcre_free_study   pcre_free

darwin doesn't defined __BYTE_ORDER and friends, but BYTE_ORDER

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

◆ SCClearErrUnlocked

#define SCClearErrUnlocked   clearerr

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

◆ SCFerrorUnlocked

#define SCFerrorUnlocked   ferror

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

◆ SCFflushUnlocked

#define SCFflushUnlocked   fflush

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

◆ SCFwriteUnlocked

#define SCFwriteUnlocked   fwrite

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

◆ SCNtohl

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

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

◆ SCNtohs

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

Definition at line 399 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 298 of file suricata-common.h.

◆ str

#define str (   s)    #s

Definition at line 274 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 402 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 413 of file suricata-common.h.

◆ TRUE

#define TRUE   1

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

◆ WARN_UNUSED

#define WARN_UNUSED   __attribute__((warn_unused_result))

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

◆ xstr

#define xstr (   s)    str(s)

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

Typedef Documentation

◆ lua_State

typedef void lua_State

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

◆ PacketProfileDetectId

Enumeration Type Documentation

◆ LoggerId

enum LoggerId
Note
update PacketProfileLoggertIdToString if you change anything here
Enumerator
LOGGER_UNDEFINED 
LOGGER_DNS_TS 
LOGGER_DNS_TC 
LOGGER_HTTP 
LOGGER_TLS_STORE 
LOGGER_TLS 
LOGGER_JSON_DNS_TS 
LOGGER_JSON_DNS_TC 
LOGGER_JSON_HTTP 
LOGGER_JSON_SMTP 
LOGGER_JSON_TLS 
LOGGER_JSON_NFS 
LOGGER_JSON_TFTP 
LOGGER_JSON_FTP 
LOGGER_JSON_DNP3_TS 
LOGGER_JSON_DNP3_TC 
LOGGER_JSON_SSH 
LOGGER_JSON_SMB 
LOGGER_JSON_IKEV2 
LOGGER_JSON_KRB5 
LOGGER_JSON_DHCP 
LOGGER_JSON_SNMP 
LOGGER_JSON_SIP 
LOGGER_JSON_TEMPLATE_RUST 
LOGGER_JSON_RFB 
LOGGER_JSON_MQTT 
LOGGER_JSON_TEMPLATE 
LOGGER_JSON_RDP 
LOGGER_JSON_DCERPC 
LOGGER_JSON_HTTP2 
LOGGER_ALERT_DEBUG 
LOGGER_ALERT_FAST 
LOGGER_UNIFIED2 
LOGGER_ALERT_SYSLOG 
LOGGER_DROP 
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_PRELUDE 
LOGGER_PCAP 
LOGGER_JSON_METADATA 
LOGGER_SIZE 

Definition at line 439 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_SORT1 
PROF_DETECT_PF_SORT2 
PROF_DETECT_NONMPMLIST 
PROF_DETECT_ALERT 
PROF_DETECT_TX_UPDATE 
PROF_DETECT_CLEANUP 
PROF_DETECT_SIZE 

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

Function Documentation

◆ strlcat()

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

◆ 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 833 of file suricata.c.

Referenced by SigTableRegisterTests(), and TmModuleRegisterTests().

◆ g_ut_covered

int g_ut_covered

Definition at line 835 of file suricata.c.

Referenced by SigTableRegisterTests(), and TmModuleRegisterTests().

◆ g_ut_modules

int g_ut_modules

Definition at line 834 of file suricata.c.

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

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