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 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 CreateJSONFlowId (json_t *js, const Flow *f)
 
void CreateEveFlowId (JsonBuilder *js, const Flow *f)
 
void JsonTcpFlags (uint8_t flags, json_t *js)
 jsonify tcp flags field Only add 'true' fields in an attempt to keep things reasonably compact. More...
 
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 JsonPacket (const Packet *p, json_t *js, unsigned long max_length)
 Jsonify a packet. More...
 
void EvePacket (const Packet *p, JsonBuilder *js, unsigned long max_length)
 Jsonify a packet. More...
 
void JsonFiveTuple (const Packet *, enum OutputJsonLogDirection, json_t *)
 Add five tuple from packet to JSON object. More...
 
json_t * CreateJSONHeader (const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr)
 
JsonBuilder * CreateEveHeader (const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr)
 
json_t * CreateJSONHeaderWithTxId (const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, uint64_t tx_id)
 
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 JsonAddCommonOptions (const OutputJsonCommonSettings *cfg, const Packet *p, const Flow *f, 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 45 of file output-json.h.

◆ JSON_OUTPUT_BUFFER_SIZE

#define JSON_OUTPUT_BUFFER_SIZE   65535

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

◆ JSON_PROTO_LEN

#define JSON_PROTO_LEN   16

Definition at line 46 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 37 of file output-json.h.

Function Documentation

◆ CreateEveFlowId()

void CreateEveFlowId ( JsonBuilder *  js,
const Flow f 
)

Definition at line 1192 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 1286 of file output-json.c.

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

Referenced by CreateEveHeaderWithTxId(), and JsonBuildFileInfoRecord().

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 1376 of file output-json.c.

References CreateEveHeader(), and unlikely.

Here is the call graph for this function:

◆ CreateJSONFlowId()

void CreateJSONFlowId ( json_t *  js,
const Flow f 
)

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

Referenced by CreateJSONHeader().

Here is the caller graph for this function:

◆ CreateJSONHeader()

json_t* CreateJSONHeader ( const Packet p,
enum OutputJsonLogDirection  dir,
const char *  event_type,
JsonAddrInfo addr 
)

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

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

Referenced by CreateJSONHeaderWithTxId(), and RulesDumpMatchArray().

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

◆ CreateJSONHeaderWithTxId()

json_t* CreateJSONHeaderWithTxId ( const Packet p,
enum OutputJsonLogDirection  dir,
const char *  event_type,
uint64_t  tx_id 
)

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

References CreateJSONHeader(), 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 673 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 716 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 760 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.

◆ JsonAddCommonOptions()

void JsonAddCommonOptions ( const OutputJsonCommonSettings cfg,
const Packet p,
const Flow f,
json_t *  js 
)

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

References OutputJsonCommonSettings_::include_metadata.

◆ JsonAddrInfoInit()

◆ JsonFiveTuple()

void JsonFiveTuple ( const Packet p,
enum OutputJsonLogDirection  dir,
json_t *  js 
)

Add five tuple from packet to JSON object.

Parameters
pPacket
dirlog direction (packet or flow)
jsJSON object

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

References DEBUG_VALIDATE_BUG_ON, Packet_::dp, GET_IPV4_DST_ADDR_PTR, GET_IPV4_SRC_ADDR_PTR, GET_IPV6_DST_ADDR, GET_IPV6_SRC_ADDR, IP_GET_IPPROTO, known_proto, LOG_DIR_FLOW, LOG_DIR_FLOW_TOCLIENT, LOG_DIR_FLOW_TOSERVER, LOG_DIR_PACKET, PKT_IS_IPV4, PKT_IS_IPV6, PKT_IS_TOCLIENT, PKT_IS_TOSERVER, PrintInet(), proto, Packet_::proto, SCProtoNameValid(), Packet_::sp, strlcpy(), and TRUE.

Here is the call graph for this function:

◆ JsonLogThreadDeinit()

TmEcode JsonLogThreadDeinit ( ThreadVars t,
void *  data 
)

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

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

Here is the call graph for this function:

◆ JsonLogThreadInit()

TmEcode JsonLogThreadInit ( ThreadVars t,
const void *  initdata,
void **  data 
)

◆ JsonPacket()

void JsonPacket ( const Packet p,
json_t *  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 691 of file output-json.c.

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

Here is the call graph for this function:

◆ JsonTcpFlags()

void JsonTcpFlags ( uint8_t  flags,
json_t *  js 
)

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

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

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

◆ 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 1463 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 1389 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 88 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 96 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 105 of file output-json.c.

◆ SCJsonString()

json_t* SCJsonString ( const char *  val)

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

References MAX_JSON_SIZE, offset, and PrintBufferData.

Referenced by OutputJsonDNP3SetItem().

Here is the caller graph for this function:

Variable Documentation

◆ json_addr_info_zero

const JsonAddrInfo json_addr_info_zero

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

Referenced by JsonBuildFileInfoRecord().