Go to the documentation of this file.
53 static SCJsonBuilder *CreateEveHeaderFromNetFlow(
57 char srcip[46] = {0}, dstip[46] = {0};
60 SCJsonBuilder *js = 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));
76 PrintInet(AF_INET, (
const void *)&(f->
dst.addr_data32[0]), srcip,
sizeof(srcip));
77 PrintInet(AF_INET, (
const void *)&(f->
src.addr_data32[0]), dstip,
sizeof(dstip));
102 SCJbSetString(js,
"timestamp", timebuf);
109 json_object_set_new(js,
"sensor_id", json_integer(sensor_id));
114 SCJbSetString(js,
"in_iface", f->
livedev->
dev);
121 SCJbOpenArray(js,
"vlan");
122 SCJbAppendUint(js, f->
vlan_id[0]);
124 SCJbAppendUint(js, f->
vlan_id[1]);
127 SCJbAppendUint(js, f->
vlan_id[2]);
133 SCJbSetString(js,
"src_ip", srcip);
140 SCJbSetUint(js,
"src_port", sp);
143 SCJbSetString(js,
"dest_ip", dstip);
150 SCJbSetUint(js,
"dest_port", dp);
159 SCJbSetString(js,
"proto",
proto);
164 case IPPROTO_ICMPV6: {
166 uint8_t code = f->
icmp_s.code;
172 SCJbSetUint(js,
"icmp_type",
type);
173 SCJbSetUint(js,
"icmp_code", code);
177 SCJbSetUint(js,
"spi", f->
esp.spi);
184 static void NetFlowLogEveToServer(SCJsonBuilder *js,
Flow *f)
188 SCJbOpenObject(js,
"netflow");
193 char timebuf1[64], timebuf2[64];
198 SCJbSetString(js,
"start", timebuf1);
199 SCJbSetString(js,
"end", timebuf2);
202 SCJbSetUint(js,
"age", age);
210 SCJbSetUint(js,
"tx_cnt", tx_id);
218 if (f->
proto == IPPROTO_TCP) {
219 SCJbOpenObject(js,
"tcp");
224 snprintf(hexflags,
sizeof(hexflags),
"%02x",
226 SCJbSetString(js,
"tcp_flags", hexflags);
234 static void NetFlowLogEveToClient(SCJsonBuilder *js,
Flow *f)
238 SCJbOpenObject(js,
"netflow");
243 char timebuf1[64], timebuf2[64];
248 SCJbSetString(js,
"start", timebuf1);
249 SCJbSetString(js,
"end", timebuf2);
252 SCJbSetUint(js,
"age", age);
263 SCJbSetUint(js,
"tx_cnt", tx_id);
271 if (f->
proto == IPPROTO_TCP) {
272 SCJbOpenObject(js,
"tcp");
277 snprintf(hexflags,
sizeof(hexflags),
"%02x",
279 SCJbSetString(js,
"tcp_flags", hexflags);
292 SCJsonBuilder *jb = CreateEveHeaderFromNetFlow(f, 0, &jhl->
ctx->
cfg);
295 NetFlowLogEveToServer(jb, f);
302 jb = CreateEveHeaderFromNetFlow(f, 1, &jhl->
ctx->
cfg);
305 NetFlowLogEveToClient(jb, f);
void CreateIsoTimeString(const SCTime_t ts, char *str, size_t size)
OutputJsonCommonSettings cfg
struct Flow_::@121::@128 esp
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.
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)
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.
#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)
struct Flow_::@123::@129 icmp_d
struct LiveDevice_ * livedev
union FlowAddress_::@120 address
uint16_t vlan_id[VLAN_MAX_LAYERS]
struct Flow_::@121::@127 icmp_s
TmEcode JsonLogThreadDeinit(ThreadVars *t, void *data)
AppProto alproto
application level protocol
#define FLOW_DIR_REVERSED
uint64_t AppLayerParserGetTxCnt(const Flow *f, void *alstate)
void JsonNetFlowLogRegister(void)