Go to the documentation of this file.
59 char srcip[46] = {0}, dstip[46] = {0};
62 SCJsonBuilder *jb = SCJbNewObject();
73 PrintInet(AF_INET, (
const void *)&(f->
src.addr_data32[0]), srcip,
sizeof(srcip));
74 PrintInet(AF_INET, (
const void *)&(f->
dst.addr_data32[0]), dstip,
sizeof(dstip));
85 PrintInet(AF_INET, (
const void *)&(f->
dst.addr_data32[0]), srcip,
sizeof(srcip));
86 PrintInet(AF_INET, (
const void *)&(f->
src.addr_data32[0]), dstip,
sizeof(dstip));
98 SCJbSetString(jb,
"timestamp", timebuf);
105 json_object_set_new(js,
"sensor_id", json_integer(sensor_id));
110 SCJbSetString(jb,
"in_iface", f->
livedev->
dev);
117 SCJbOpenArray(jb,
"vlan");
118 SCJbAppendUint(jb, f->
vlan_id[0]);
120 SCJbAppendUint(jb, f->
vlan_id[1]);
123 SCJbAppendUint(jb, f->
vlan_id[2]);
129 SCJbSetString(jb,
"src_ip", srcip);
136 SCJbSetUint(jb,
"src_port", sp);
139 SCJbSetString(jb,
"dest_ip", dstip);
146 SCJbSetUint(jb,
"dest_port", dp);
152 SCJbSetUint(jb,
"ip_v", 4);
154 SCJbSetUint(jb,
"ip_v", 6);
162 SCJbSetString(jb,
"proto",
proto);
168 SCJbSetUint(jb,
"icmp_type", f->
icmp_s.type);
169 SCJbSetUint(jb,
"icmp_code", f->
icmp_s.code);
171 SCJbSetUint(jb,
"response_icmp_type", f->
icmp_d.type);
172 SCJbSetUint(jb,
"response_icmp_code", f->
icmp_d.code);
176 SCJbSetUint(jb,
"spi", f->
esp.spi);
211 SCJbOpenObject(js,
"bypassed");
226 SCJbSetString(js,
"start", timebuf1);
229 static void EveExceptionPolicyLog(SCJsonBuilder *js, uint16_t flag)
233 SCJbSetString(js,
"target",
235 SCJbSetString(js,
"policy",
242 SCJbSetString(js,
"target",
244 SCJbSetString(js,
"policy",
251 SCJbSetString(js,
"target",
253 SCJbSetString(js,
"policy",
263 SCJbSetString(js,
"policy",
272 SCJbSetString(js,
"policy",
279 SCJbSetString(js,
"target",
281 SCJbSetString(js,
"policy",
292 SCJbOpenObject(jb,
"flow");
297 SCJbSetString(jb,
"end", timebuf2);
300 SCJbSetUint(jb,
"age", age);
306 switch (flow_state) {
320 #ifdef CAPTURE_OFFLOAD
321 case FLOW_STATE_CAPTURE_BYPASSED:
328 SCLogDebug(
"invalid flow state: %d, contact developers", flow_state);
331 const char *reason = NULL;
333 reason =
"tcp_reuse";
343 SCJbSetString(jb,
"reason", reason);
351 SCJbOpenArray(jb,
"elephant_direction");
353 SCJbAppendString(jb,
"toserver");
355 SCJbAppendString(jb,
"toclient");
368 SCJbOpenArray(jb,
"exception_policy");
376 SCJbSetUint(jb,
"tx_cnt", tx_id);
386 if (f->
proto == IPPROTO_TCP) {
387 SCJbOpenObject(jb,
"tcp");
392 snprintf(hexflags,
sizeof(hexflags),
"%02x",
394 SCJbSetString(jb,
"tcp_flags", hexflags);
396 snprintf(hexflags,
sizeof(hexflags),
"%02x",
398 SCJbSetString(jb,
"tcp_flags_ts", hexflags);
400 snprintf(hexflags,
sizeof(hexflags),
"%02x",
402 SCJbSetString(jb,
"tcp_flags_tc", hexflags);
408 if (tcp_state != NULL)
409 SCJbSetString(jb,
"state", tcp_state);
437 MemBufferReset(thread->
buffer);
439 SCJsonBuilder *jb = CreateEveHeaderFromFlow(f, &thread->
ctx->
cfg);
444 EveFlowLogJSON(thread, jb, f);
void CreateIsoTimeString(const SCTime_t ts, char *str, size_t size)
void EveAddFlow(Flow *f, SCJsonBuilder *js)
OutputJsonCommonSettings cfg
FlowStorageId GetFlowBypassInfoID(void)
#define FLOW_IS_ELEPHANT_TOCLIENT
struct Flow_::@121::@128 esp
void EveAddAppProto(Flow *f, SCJsonBuilder *js)
TmEcode JsonLogThreadInit(ThreadVars *t, const void *initdata, void **data)
const char * PrintInetIPv6(const void *src, char *dst, socklen_t size, bool compress_ipv6)
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
#define EXCEPTION_TARGET_FLAG_APPLAYER_ERROR
bool SCProtoNameValid(uint16_t proto)
Function to check if the received protocol number is valid and do we have corresponding name entry fo...
void EveTcpFlags(const uint8_t flags, SCJsonBuilder *js)
jsonify tcp flags field Only add 'true' fields in an attempt to keep things reasonably compact.
const char * known_proto[256]
void OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, SCJsonBuilder *js, OutputJsonThreadCtx *ctx)
void CreateEveFlowId(SCJsonBuilder *js, const Flow *f)
const char * ExceptionPolicyTargetFlagToString(uint8_t target_flag)
void JsonFlowLogRegister(void)
OutputInitResult OutputJsonLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
void OutputRegisterFlowSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a flow output sub-module.
@ FLOW_STATE_LOCAL_BYPASSED
#define EXCEPTION_TARGET_FLAG_DEFRAG_MEMCAP
enum ExceptionPolicy ExceptionPolicyTargetPolicy(uint8_t target_flag)
#define JB_SET_STRING(jb, key, val)
void EveAddCommonOptions(const OutputJsonCommonSettings *cfg, const Packet *p, const Flow *f, SCJsonBuilder *js, enum SCOutputJsonLogDirection dir)
Per thread variable structure.
const char * PrintInet(int af, const void *src, char *dst, socklen_t size)
#define FLOW_WRONG_THREAD
#define JB_SET_TRUE(jb, key)
#define FLOW_END_FLAG_TCPREUSE
#define FLOW_END_FLAG_EMERGENCY
#define STREAMTCP_STREAM_FLAG_HAS_GAP
#define EXCEPTION_TARGET_FLAG_REASSEMBLY_MEMCAP
void * FlowGetStorageById(const Flow *f, FlowStorageId id)
#define EXCEPTION_TARGET_FLAG_MIDSTREAM
uint8_t applied_exception_policy
struct Flow_::@123::@129 icmp_d
#define EXCEPTION_TARGET_FLAG_SESSION_MEMCAP
struct LiveDevice_ * livedev
#define FLOW_ACTION_ACCEPT
const char * ExceptionPolicyEnumToString(enum ExceptionPolicy policy, bool is_json)
union FlowAddress_::@120 address
#define FLOW_END_FLAG_SHUTDOWN
#define EXCEPTION_TARGET_FLAG_FLOW_MEMCAP
const char * StreamTcpStateAsString(const enum TcpState state)
uint16_t vlan_id[VLAN_MAX_LAYERS]
int FlowHasAlerts(const Flow *f)
Check if flow has alerts.
#define FLOW_END_FLAG_TIMEOUT
struct Flow_::@121::@127 icmp_s
TmEcode JsonLogThreadDeinit(ThreadVars *t, void *data)
AppProto alproto
application level protocol
#define FLOW_END_FLAG_FORCED
#define FLOW_DIR_REVERSED
uint64_t AppLayerParserGetTxCnt(const Flow *f, void *alstate)
#define DEBUG_VALIDATE_BUG_ON(exp)
#define FLOW_IS_ELEPHANT_TOSERVER