suricata
output-json.h File Reference
#include "suricata-common.h"
#include "util-buffer.h"
#include "util-logopenfile.h"
#include "output.h"
#include "rust.h"
#include "app-layer-htp-xff.h"
#include "suricata-plugin.h"
Include dependency graph for output-json.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  JsonAddrInfo_
 
struct  OutputJSONMemBufferWrapper_
 
struct  OutputJsonCommonSettings_
 
struct  OutputJsonCtx_
 
struct  OutputJsonThreadCtx_
 

Macros

#define JSON_ADDR_LEN   46
 
#define JSON_PROTO_LEN   16
 
#define JSON_OUTPUT_BUFFER_SIZE   65535
 

Typedefs

typedef struct JsonAddrInfo_ JsonAddrInfo
 
typedef struct OutputJSONMemBufferWrapper_ OutputJSONMemBufferWrapper
 
typedef struct OutputJsonCommonSettings_ OutputJsonCommonSettings
 
typedef struct OutputJsonCtx_ OutputJsonCtx
 
typedef struct OutputJsonThreadCtx_ OutputJsonThreadCtx
 

Enumerations

enum  OutputJsonLogDirection { LOG_DIR_PACKET = 0, LOG_DIR_FLOW, LOG_DIR_FLOW_TOCLIENT, LOG_DIR_FLOW_TOSERVER }
 

Functions

void OutputJsonRegister (void)
 
void JsonAddrInfoInit (const Packet *p, enum OutputJsonLogDirection dir, JsonAddrInfo *addr)
 
int OutputJSONMemBufferCallback (const char *str, size_t size, void *data)
 
void CreateEveFlowId (JsonBuilder *js, const Flow *f)
 
void EveFileInfo (JsonBuilder *js, const File *file, const bool stored)
 
void EveTcpFlags (uint8_t flags, JsonBuilder *js)
 jsonify tcp flags field Only add 'true' fields in an attempt to keep things reasonably compact. More...
 
void EvePacket (const Packet *p, JsonBuilder *js, unsigned long max_length)
 Jsonify a packet. More...
 
JsonBuilder * CreateEveHeader (const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr)
 
JsonBuilder * CreateEveHeaderWithTxId (const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, uint64_t tx_id)
 
int OutputJSONBuffer (json_t *js, LogFileCtx *file_ctx, MemBuffer **buffer)
 
int OutputJsonBuilderBuffer (JsonBuilder *js, LogFileCtx *file_ctx, MemBuffer **buffer)
 
OutputInitResult OutputJsonInitCtx (ConfNode *)
 Create a new LogFileCtx for "fast" output style. More...
 
OutputInitResult OutputJsonLogInitSub (ConfNode *conf, OutputCtx *parent_ctx)
 
TmEcode JsonLogThreadInit (ThreadVars *t, const void *initdata, void **data)
 
TmEcode JsonLogThreadDeinit (ThreadVars *t, void *data)
 
json_t * SCJsonBool (int val)
 
json_t * SCJsonString (const char *val)
 
void SCJsonDecref (json_t *js)
 
void EveAddCommonOptions (const OutputJsonCommonSettings *cfg, const Packet *p, const Flow *f, JsonBuilder *js)
 

Variables

const JsonAddrInfo json_addr_info_zero
 

Detailed Description

Author
Tom DeCanio td@np.nosp@m.ulse.nosp@m.tech..nosp@m.com

Definition in file output-json.h.

Macro Definition Documentation

◆ JSON_ADDR_LEN

#define JSON_ADDR_LEN   46

Definition at line 46 of file output-json.h.

◆ JSON_OUTPUT_BUFFER_SIZE

#define JSON_OUTPUT_BUFFER_SIZE   65535

Definition at line 64 of file output-json.h.

◆ JSON_PROTO_LEN

#define JSON_PROTO_LEN   16

Definition at line 47 of file output-json.h.

Typedef Documentation

◆ JsonAddrInfo

typedef struct JsonAddrInfo_ JsonAddrInfo

◆ OutputJsonCommonSettings

◆ OutputJsonCtx

typedef struct OutputJsonCtx_ OutputJsonCtx

◆ OutputJSONMemBufferWrapper

◆ OutputJsonThreadCtx

Enumeration Type Documentation

◆ OutputJsonLogDirection

Enumerator
LOG_DIR_PACKET 
LOG_DIR_FLOW 
LOG_DIR_FLOW_TOCLIENT 
LOG_DIR_FLOW_TOSERVER 

Definition at line 38 of file output-json.h.

Function Documentation

◆ CreateEveFlowId()

void CreateEveFlowId ( JsonBuilder *  js,
const Flow f 
)

Definition at line 758 of file output-json.c.

Referenced by CreateEveHeader().

Here is the caller graph for this function:

◆ CreateEveHeader()

JsonBuilder* CreateEveHeader ( const Packet p,
enum OutputJsonLogDirection  dir,
const char *  event_type,
JsonAddrInfo addr 
)

Definition at line 853 of file output-json.c.

References CreateEveFlowId(), CreateIsoTimeString(), Packet_::flow, Packet_::ts, and unlikely.

Referenced by CreateEveHeaderWithTxId(), JsonBuildFileInfoRecord(), and RulesDumpMatchArray().

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

◆ CreateEveHeaderWithTxId()

JsonBuilder* CreateEveHeaderWithTxId ( const Packet p,
enum OutputJsonLogDirection  dir,
const char *  event_type,
JsonAddrInfo addr,
uint64_t  tx_id 
)

Definition at line 930 of file output-json.c.

References CreateEveHeader(), and unlikely.

Here is the call graph for this function:

◆ EveAddCommonOptions()

void EveAddCommonOptions ( const OutputJsonCommonSettings cfg,
const Packet p,
const Flow f,
JsonBuilder *  js 
)

Definition at line 444 of file output-json.c.

References OutputJsonCommonSettings_::include_metadata.

◆ EveFileInfo()

void EveFileInfo ( JsonBuilder *  js,
const File file,
const bool  stored 
)

◆ EvePacket()

void EvePacket ( const Packet p,
JsonBuilder *  js,
unsigned long  max_length 
)

Jsonify a packet.

Parameters
pPacket
jsJSON object
max_lengthIf non-zero, restricts the number of packet data bytes handled.

Definition at line 465 of file output-json.c.

References Base64Encode(), Packet_::datalink, GET_PKT_DATA, GET_PKT_LEN, len, and SC_BASE64_OK.

Here is the call graph for this function:

◆ EveTcpFlags()

void EveTcpFlags ( uint8_t  flags,
JsonBuilder *  js 
)

jsonify tcp flags field Only add 'true' fields in an attempt to keep things reasonably compact.

Definition at line 486 of file output-json.c.

References flags, JB_SET_TRUE, TH_ACK, TH_CWR, TH_ECN, TH_FIN, TH_PUSH, TH_RST, TH_SYN, and TH_URG.

◆ JsonAddrInfoInit()

◆ JsonLogThreadDeinit()

TmEcode JsonLogThreadDeinit ( ThreadVars t,
void *  data 
)

Definition at line 109 of file output-json-common.c.

References OutputJsonThreadCtx_::buffer, MemBufferFree(), SCFree, and TM_ECODE_OK.

Here is the call graph for this function:

◆ JsonLogThreadInit()

◆ OutputJSONBuffer()

◆ OutputJsonBuilderBuffer()

int OutputJsonBuilderBuffer ( JsonBuilder *  js,
LogFileCtx file_ctx,
MemBuffer **  buffer 
)

◆ OutputJsonInitCtx()

OutputInitResult OutputJsonInitCtx ( ConfNode conf)

Create a new LogFileCtx for "fast" output style.

Parameters
confThe configuration node for this output.
Returns
A LogFileCtx pointer on success, NULL on failure.

Definition at line 1017 of file output-json.c.

References ConfGet(), ConfNodeLookupChildValue(), OutputCtx_::data, OutputCtx_::DeInit, OutputJsonCtx_::file_ctx, LogFileFreeCtx(), LogFileNewCtx(), SC_ERR_DEPRECATED_CONF, SCCalloc, SCFree, SCLogDebug, SCLogWarning, SCStrdup, LogFileCtx_::sensor_name, and unlikely.

Referenced by OutputJsonRegister().

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

◆ OutputJsonLogInitSub()

OutputInitResult OutputJsonLogInitSub ( ConfNode conf,
OutputCtx parent_ctx 
)

Definition at line 50 of file output-json-common.c.

References OutputCtx_::data, OutputCtx_::DeInit, SCCalloc, SCFree, and unlikely.

◆ OutputJSONMemBufferCallback()

int OutputJSONMemBufferCallback ( const char *  str,
size_t  size,
void *  data 
)

Definition at line 943 of file output-json.c.

References OutputJSONMemBufferWrapper_::buffer, OutputJSONMemBufferWrapper_::expand_by, MEMBUFFER_OFFSET, MEMBUFFER_SIZE, MemBufferExpand(), MemBufferWriteRaw, and str.

Referenced by OutputJSONBuffer().

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

◆ OutputJsonRegister()

void OutputJsonRegister ( void  )

Definition at line 91 of file output-json.c.

References MODULE_NAME, OutputJsonInitCtx(), and OutputRegisterModule().

Referenced by OutputRegisterLoggers().

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

◆ SCJsonBool()

json_t* SCJsonBool ( int  val)

Definition at line 99 of file output-json.c.

◆ SCJsonDecref()

void SCJsonDecref ( json_t *  json)

Wrap json_decref. This is mainly to expose this function to Rust as its defined in the Jansson header file as an inline function.

Definition at line 108 of file output-json.c.

◆ SCJsonString()

json_t* SCJsonString ( const char *  val)

Definition at line 113 of file output-json.c.

References MAX_JSON_SIZE, offset, and PrintBufferData.

Variable Documentation

◆ json_addr_info_zero

const JsonAddrInfo json_addr_info_zero

Definition at line 89 of file output-json.c.

Referenced by JsonBuildFileInfoRecord().