suricata
suricata-common.h File Reference
#include "autoconf.h"
#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 REVISION   "undefined"
 
#define __SCFILENAME__   "undefined"
 
#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 enum LoggerId LoggerId
 
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

◆ __SCFILENAME__

#define __SCFILENAME__   "undefined"

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

◆ __USE_GNU

#define __USE_GNU

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

◆ _GNU_SOURCE

#define _GNU_SOURCE

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

◆ ARRAY_SIZE

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

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

◆ ATTR_FMT_PRINTF

#define ATTR_FMT_PRINTF (   x,
 
)

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

◆ BIT_U16

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

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

◆ BIT_U32

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

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

◆ BIT_U64

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

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

◆ BIT_U8

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

Definition at line 415 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)
#define xstr(s)

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

◆ CLS

#define CLS   64

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

◆ JSON_ESCAPE_SLASH

#define JSON_ESCAPE_SLASH   0

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

◆ MAX

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

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

◆ PatIntId

#define PatIntId   uint32_t

same for pattern id's

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

◆ REVISION

#define REVISION   "undefined"

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

◆ SCClearErrUnlocked

#define SCClearErrUnlocked   clearerr

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

◆ SCFerrorUnlocked

#define SCFerrorUnlocked   ferror

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

◆ SCFflushUnlocked

#define SCFflushUnlocked   fflush

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

◆ SCFwriteUnlocked

#define SCFwriteUnlocked   fwrite

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

◆ SCNtohl

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

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

◆ SCNtohs

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

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

◆ str

#define str (   s)    #s

Definition at line 308 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)
uint8_t flags
Definition decode-gre.h:0

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

◆ SWAP_VARS

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

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

◆ u8_tolower

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

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

◆ u8_toupper

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

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

◆ WARN_UNUSED

#define WARN_UNUSED   __attribute__((warn_unused_result))

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

◆ xstr

#define xstr (   s)    str(s)

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

Typedef Documentation

◆ LoggerId

typedef enum LoggerId LoggerId
Note
update PacketProfileLoggerIdToString if you change anything here

◆ lua_State

typedef struct lua_State lua_State

Definition at line 523 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 477 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 456 of file suricata-common.h.

Function Documentation

◆ strlcat()

◆ 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, LEGAL_ALT, strptime(), and TIME_MAX.

Referenced by SCStringPatternToTime(), and strptime().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ coverage_unittests

int coverage_unittests
extern

◆ g_ut_covered

int g_ut_covered
extern

◆ g_ut_modules

int g_ut_modules
extern