56static SCJsonBuilder *CreateEveHeaderFromFlow(
const Flow *f)
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));
83 PrintInet(AF_INET, (
const void *)&(f->
dst.addr_data32[0]), srcip,
sizeof(srcip));
84 PrintInet(AF_INET, (
const void *)&(f->
src.addr_data32[0]), dstip,
sizeof(dstip));
94 SCJbSetString(jb,
"timestamp", timebuf);
101 json_object_set_new(js,
"sensor_id", json_integer(sensor_id));
106 SCJbSetString(jb,
"in_iface", f->
livedev->
dev);
113 SCJbOpenArray(jb,
"vlan");
114 SCJbAppendUint(jb, f->
vlan_id[0]);
116 SCJbAppendUint(jb, f->
vlan_id[1]);
119 SCJbAppendUint(jb, f->
vlan_id[2]);
125 SCJbSetString(jb,
"src_ip", srcip);
132 SCJbSetUint(jb,
"src_port", sp);
135 SCJbSetString(jb,
"dest_ip", dstip);
142 SCJbSetUint(jb,
"dest_port", dp);
148 SCJbSetUint(jb,
"ip_v", 4);
150 SCJbSetUint(jb,
"ip_v", 6);
158 SCJbSetString(jb,
"proto",
proto);
167 SCJbSetUint(jb,
"response_icmp_type", f->
icmp_d.
type);
168 SCJbSetUint(jb,
"response_icmp_code", f->
icmp_d.
code);
172 SCJbSetUint(jb,
"spi", f->
esp.
spi);
207 SCJbOpenObject(js,
"bypassed");
222 SCJbSetString(js,
"start", timebuf1);
225static void EveExceptionPolicyLog(SCJsonBuilder *js, uint16_t flag)
229 SCJbSetString(js,
"target",
231 SCJbSetString(js,
"policy",
238 SCJbSetString(js,
"target",
240 SCJbSetString(js,
"policy",
247 SCJbSetString(js,
"target",
249 SCJbSetString(js,
"policy",
259 SCJbSetString(js,
"policy",
268 SCJbSetString(js,
"policy",
275 SCJbSetString(js,
"target",
277 SCJbSetString(js,
"policy",
288 SCJbOpenObject(jb,
"flow");
293 SCJbSetString(jb,
"end", timebuf2);
296 SCJbSetUint(jb,
"age", age);
302 switch (flow_state) {
316#ifdef CAPTURE_OFFLOAD
317 case FLOW_STATE_CAPTURE_BYPASSED:
324 SCLogDebug(
"invalid flow state: %d, contact developers", flow_state);
327 const char *reason = NULL;
329 reason =
"tcp_reuse";
339 SCJbSetString(jb,
"reason", reason);
356 SCJbOpenArray(jb,
"exception_policy");
364 SCJbSetUint(jb,
"tx_cnt", tx_id);
374 if (f->
proto == IPPROTO_TCP) {
375 SCJbOpenObject(jb,
"tcp");
380 snprintf(hexflags,
sizeof(hexflags),
"%02x",
382 SCJbSetString(jb,
"tcp_flags", hexflags);
384 snprintf(hexflags,
sizeof(hexflags),
"%02x",
386 SCJbSetString(jb,
"tcp_flags_ts", hexflags);
388 snprintf(hexflags,
sizeof(hexflags),
"%02x",
390 SCJbSetString(jb,
"tcp_flags_tc", hexflags);
396 if (tcp_state != NULL)
397 SCJbSetString(jb,
"state", tcp_state);
425 MemBufferReset(thread->
buffer);
427 SCJsonBuilder *jb = CreateEveHeaderFromFlow(f);
432 EveFlowLogJSON(thread, jb, f);
uint64_t AppLayerParserGetTxCnt(const Flow *f, void *alstate)
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
void * FlowGetStorageById(const Flow *f, FlowStorageId id)
FlowStorageId GetFlowBypassInfoID(void)
int FlowHasAlerts(const Flow *f)
Check if flow has alerts.
@ FLOW_STATE_LOCAL_BYPASSED
#define FLOW_DIR_REVERSED
#define FLOW_WRONG_THREAD
#define FLOW_END_FLAG_FORCED
#define FLOW_END_FLAG_TIMEOUT
#define FLOW_ACTION_ACCEPT
#define FLOW_END_FLAG_TCPREUSE
#define FLOW_END_FLAG_SHUTDOWN
#define FLOW_END_FLAG_EMERGENCY
OutputInitResult OutputJsonLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
TmEcode JsonLogThreadInit(ThreadVars *t, const void *initdata, void **data)
TmEcode JsonLogThreadDeinit(ThreadVars *t, void *data)
void JsonFlowLogRegister(void)
void EveAddAppProto(Flow *f, SCJsonBuilder *js)
void EveAddFlow(Flow *f, SCJsonBuilder *js)
void EveTcpFlags(const uint8_t flags, SCJsonBuilder *js)
jsonify tcp flags field Only add 'true' fields in an attempt to keep things reasonably compact.
void OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, SCJsonBuilder *js, OutputJsonThreadCtx *ctx)
void CreateEveFlowId(SCJsonBuilder *js, const Flow *f)
void EveAddCommonOptions(const OutputJsonCommonSettings *cfg, const Packet *p, const Flow *f, SCJsonBuilder *js, enum SCOutputJsonLogDirection dir)
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.
#define JB_SET_TRUE(jb, key)
#define JB_SET_STRING(jb, key, val)
#define STREAMTCP_STREAM_FLAG_HAS_GAP
const char * StreamTcpStateAsString(const enum TcpState state)
union FlowAddress_::@128 address
uint8_t applied_exception_policy
struct Flow_::@129::@135 icmp_s
AppProto alproto
application level protocol
uint16_t vlan_id[VLAN_MAX_LAYERS]
struct LiveDevice_ * livedev
struct Flow_::@131::@137 icmp_d
struct Flow_::@129::@136 esp
OutputJsonCommonSettings cfg
Per thread variable structure.
#define EXCEPTION_TARGET_FLAG_DEFRAG_MEMCAP
#define EXCEPTION_TARGET_FLAG_REASSEMBLY_MEMCAP
#define EXCEPTION_TARGET_FLAG_APPLAYER_ERROR
#define EXCEPTION_TARGET_FLAG_MIDSTREAM
#define EXCEPTION_TARGET_FLAG_FLOW_MEMCAP
#define EXCEPTION_TARGET_FLAG_SESSION_MEMCAP
const char * ExceptionPolicyTargetFlagToString(uint8_t target_flag)
enum ExceptionPolicy ExceptionPolicyTargetPolicy(uint8_t target_flag)
const char * ExceptionPolicyEnumToString(enum ExceptionPolicy policy, bool is_json)
const char * PrintInet(int af, const void *src, char *dst, socklen_t size)
bool SCProtoNameValid(uint16_t proto)
Function to check if the received protocol number is valid and do we have corresponding name entry fo...
const char * known_proto[256]
void CreateIsoTimeString(const SCTime_t ts, char *str, size_t size)
#define DEBUG_VALIDATE_BUG_ON(exp)