Go to the documentation of this file.
58 #define MODULE_NAME "EveStreamLog"
70 static TmEcode EveStreamLogThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
76 if (initdata == NULL) {
77 SCLogDebug(
"Error getting context for EveLogDrop. \"initdata\" argument NULL");
106 memset(aft, 0,
sizeof(*aft));
119 static void EveStreamLogDeInitCtxSub(
OutputCtx *output_ctx)
125 SCLogDebug(
"cleaning up sub output_ctx %p", output_ctx);
129 static uint16_t SetFlag(
ConfNode *conf,
const char *opt,
const uint16_t inflag)
149 EveStreamOutputCtxFree(
ctx);
158 ctx->trigger_flags |=
161 ctx->trigger_flags |= SetFlag(conf,
"all", 0xFFFF);
167 output_ctx->
DeInit = EveStreamLogDeInitCtxSub;
169 result.
ctx = output_ctx;
172 SCLogWarning(
"eve.stream facility is EXPERIMENTAL and can change w/o notice");
178 jb_open_array(jb, name);
180 jb_append_string(jb,
"has_gap");
182 jb_append_string(jb,
"noreassembly");
184 jb_append_string(jb,
"keepalive");
186 jb_append_string(jb,
"depth_reached");
188 jb_append_string(jb,
"trigger_raw");
190 jb_append_string(jb,
"timestamp");
192 jb_append_string(jb,
"zero_timestamp");
194 jb_append_string(jb,
"appproto_detection_completed");
196 jb_append_string(jb,
"appproto_detection_skipped");
198 jb_append_string(jb,
"new_raw_disabled");
200 jb_append_string(jb,
"disable_raw");
202 jb_append_string(jb,
"rst_recv");
208 jb_open_object(jb,
"flags");
210 jb_open_array(jb, name);
212 jb_append_string(jb,
"midstream");
215 jb_append_string(jb,
"midstream_established");
218 jb_append_string(jb,
"midstream_synack");
221 jb_append_string(jb,
"timestamp");
224 jb_append_string(jb,
"server_wscale");
227 jb_append_string(jb,
"closed_by_rst");
230 jb_append_string(jb,
"4whs");
233 jb_append_string(jb,
"detect_evasion_attempt");
236 jb_append_string(jb,
"client_sackok");
239 jb_append_string(jb,
"sackok");
242 jb_append_string(jb,
"3whs_confirmed");
245 jb_append_string(jb,
"app_layer_disabled");
248 jb_append_string(jb,
"bypass");
251 jb_append_string(jb,
"tcp_fast_open");
254 jb_append_string(jb,
"tfo_data_ignored");
265 static void LogStream(
const TcpStream *stream, JsonBuilder *js)
267 jb_set_uint(js,
"isn", stream->
isn);
268 jb_set_uint(js,
"next_seq", stream->
next_seq);
269 jb_set_uint(js,
"last_ack", stream->
last_ack);
270 jb_set_uint(js,
"next_win", stream->
next_win);
272 jb_set_uint(js,
"base_seq", stream->
base_seq);
275 jb_set_uint(js,
"window", stream->
window);
276 jb_set_uint(js,
"wscale", stream->
wscale);
286 jb_set_uint(js,
"seg_cnt", segs);
287 LogStreamSB(&stream->
sb, js);
311 if (p->
flow != NULL) {
313 jb_set_string(js,
"direction",
"to_server");
315 jb_set_string(js,
"direction",
"to_client");
319 jb_open_object(js,
"stream_tcp");
320 jb_open_object(js,
"packet");
322 if (PacketIsIPv4(p)) {
323 const IPV4Hdr *ip4h = PacketGetIPv4(p);
328 }
else if (PacketIsIPv6(p)) {
329 const IPV6Hdr *ip6h = PacketGetIPv6(p);
335 if (PacketIsTCP(p)) {
336 const TCPHdr *tcph = PacketGetTCP(p);
349 jb_open_array(js,
"flags");
351 jb_append_string(js,
"retransmission");
353 jb_append_string(js,
"spurious_retransmission");
355 jb_append_string(js,
"keepalive");
357 jb_append_string(js,
"keepalive_ack");
359 jb_append_string(js,
"window_update");
362 jb_append_string(js,
"event_set");
364 jb_append_string(js,
"state_update");
366 jb_append_string(js,
"dup_ack");
368 jb_append_string(js,
"dsack");
370 jb_append_string(js,
"ack_unseen_data");
372 jb_append_string(js,
"tcp_port_reuse");
374 jb_append_string(js,
"zero_window_probe");
376 jb_append_string(js,
"zero_window_probe_ack");
381 jb_open_object(js,
"session");
385 if (tcp_state != NULL)
386 jb_set_string(js,
"state", tcp_state);
389 if (tcp_pstate != NULL)
390 jb_set_string(js,
"pstate", tcp_pstate);
394 jb_open_object(js,
"client");
395 LogStream(&ssn->
client, js);
397 jb_open_object(js,
"server");
398 LogStream(&ssn->
server, js);
404 jb_open_array(js,
"events");
405 for (
int i = 0; i < p->
events.
cnt; i++) {
415 jb_append_string(js, event);
422 jb_set_string(js,
"reason",
str);
447 return (p->
proto == IPPROTO_TCP &&
448 (
ctx->trigger_flags == 0xffff ||
455 EveStreamLogInitCtxSub, EveStreamLogger, EveStreamLogCondition, EveStreamLogThreadInit,
456 EveStreamLogThreadDeinit);
#define TCP_GET_RAW_SEQ(tcph)
#define IPV4_GET_RAW_IPID(ip4h)
#define STREAMTCP_FLAG_CLIENT_SACKOK
#define TCP_GET_RAW_X2(tcph)
#define IPV6_GET_RAW_PLEN(ip6h)
#define IPV6_GET_RAW_HLIM(ip6h)
#define STREAMTCP_FLAG_DETECTION_EVASION_ATTEMPT
void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a packet output sub-module.
const char * PacketDropReasonToString(enum PacketDropReason r)
uint8_t events[PACKET_ENGINE_EVENT_MAX]
void FreeEveThreadCtx(OutputJsonThreadCtx *ctx)
#define STREAM_PKT_FLAG_DUP_ACK
#define STREAM_PKT_FLAG_KEEPALIVEACK
#define STREAM_PKT_FLAG_DSACK
#define IPV6_GET_RAW_CLASS(ip6h)
void OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, JsonBuilder *js, OutputJsonThreadCtx *ctx)
void EveAddFlowTcpStreamFlags(const TcpStream *stream, const char *name, JsonBuilder *jb)
OutputJsonThreadCtx * CreateEveThreadCtx(ThreadVars *t, OutputJsonCtx *ctx)
#define STREAM_PKT_FLAG_RETRANSMISSION
const JsonAddrInfo json_addr_info_zero
#define FLOW_PKT_TOSERVER
#define STREAMTCP_FLAG_MIDSTREAM_ESTABLISHED
#define STREAMTCP_STREAM_FLAG_KEEPALIVE
#define TCP_GET_RAW_WINDOW(tcph)
#define STREAMTCP_STREAM_FLAG_DEPTH_REACHED
PacketEngineEvents events
int ConfValIsTrue(const char *val)
Check if a value is true.
#define STREAMTCP_FLAG_TFO_DATA_IGNORED
#define STREAMTCP_FLAG_MIDSTREAM
#define IPV4_GET_RAW_IPTOS(ip4h)
#define STREAM_PKT_FLAG_TCP_PORT_REUSE
const struct DecodeEvents_ DEvents[]
#define STREAMTCP_FLAG_BYPASS
struct EveStreamLogThread_ EveStreamLogThread
JsonBuilder * CreateEveHeader(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, OutputJsonCtx *eve_ctx)
#define STREAMTCP_STREAM_FLAG_RST_RECV
#define TCP_ISSET_FLAG_RAW_URG(p)
Per thread variable structure.
#define STREAM_PKT_FLAG_TCP_ZERO_WIN_PROBE_ACK
#define SCLogWarning(...)
Macro used to log WARNING messages.
#define STREAM_PKT_FLAG_STATE_UPDATE
#define STREAMTCP_STREAM_FLAG_TIMESTAMP
#define TCP_ISSET_FLAG_RAW_ACK(p)
#define RB_FOREACH(x, name, head)
#define STREAMTCP_STREAM_FLAG_APPPROTO_DETECTION_SKIPPED
#define IPV4_GET_RAW_IPTTL(ip4h)
uint16_t stream_pkt_flags
#define STREAMTCP_STREAM_FLAG_HAS_GAP
#define TCP_ISSET_FLAG_RAW_FIN(p)
void EveStreamLogRegister(void)
#define STREAM_PKT_FLAG_KEEPALIVE
EveStreamOutputCtx * stream_ctx
#define STREAMTCP_FLAG_CLOSED_BY_RST
#define STREAMTCP_FLAG_TIMESTAMP
#define STREAM_PKT_FLAG_EVENTSET
#define STREAM_PKT_FLAG_TCP_ZERO_WIN_PROBE
void(* DeInit)(struct OutputCtx_ *)
#define TCP_ISSET_FLAG_RAW_PUSH(p)
#define IPV6_GET_RAW_FLOW(ip6h)
#define STREAMTCP_STREAM_FLAG_NEW_RAW_DISABLED
#define STREAMTCP_FLAG_MIDSTREAM_SYNACK
#define STREAM_PKT_FLAG_ACK_UNSEEN_DATA
OutputJsonThreadCtx * ctx
void EveAddFlowTcpFlags(const TcpSession *ssn, const char *name, JsonBuilder *jb)
#define STREAM_PKT_FLAG_SPURIOUS_RETRANSMISSION
#define TCP_ISSET_FLAG_RAW_SYN(p)
#define TCP_ISSET_FLAG_RAW_RST(p)
#define STREAMTCP_STREAM_FLAG_ZERO_TIMESTAMP
#define STREAMTCP_FLAG_APP_LAYER_DISABLED
#define STREAMTCP_STREAM_FLAG_NOREASSEMBLY
const char * StreamTcpStateAsString(const enum TcpState state)
#define STREAMTCP_FLAG_3WHS_CONFIRMED
void JsonAddrInfoInit(const Packet *p, enum OutputJsonLogDirection dir, JsonAddrInfo *addr)
#define IPV4_GET_RAW_IPLEN(ip4h)
#define STREAMTCP_STREAM_FLAG_DISABLE_RAW
#define STREAMTCP_FLAG_4WHS
struct EveStreamOutputCtx_ EveStreamOutputCtx
#define TCP_GET_RAW_URG_POINTER(tcph)
StreamingBufferRegion region
#define STREAMTCP_STREAM_FLAG_TRIGGER_RAW
#define TCP_GET_RAW_ACK(tcph)
#define STREAM_PKT_FLAG_WINDOWUPDATE
union PacketL4::L4Vars vars
#define STREAMTCP_FLAG_TCP_FAST_OPEN
#define STREAMTCP_STREAM_FLAG_APPPROTO_DETECTION_COMPLETED
void OutputDropLoggerDisable(void)
#define STREAMTCP_FLAG_SERVER_WSCALE
#define EVENT_IS_DECODER_PACKET_ERROR(e)
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.