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 |=
162 ctx->trigger_flags |= SetFlag(conf,
"all", 0xFFFF);
168 output_ctx->
DeInit = EveStreamLogDeInitCtxSub;
170 result.
ctx = output_ctx;
173 SCLogWarning(
"eve.stream facility is EXPERIMENTAL and can change w/o notice");
179 jb_open_array(jb,
name);
181 jb_append_string(jb,
"has_gap");
183 jb_append_string(jb,
"noreassembly");
185 jb_append_string(jb,
"keepalive");
187 jb_append_string(jb,
"depth_reached");
189 jb_append_string(jb,
"trigger_raw");
191 jb_append_string(jb,
"timestamp");
193 jb_append_string(jb,
"zero_timestamp");
195 jb_append_string(jb,
"appproto_detection_completed");
197 jb_append_string(jb,
"appproto_detection_skipped");
199 jb_append_string(jb,
"new_raw_disabled");
201 jb_append_string(jb,
"disable_raw");
203 jb_append_string(jb,
"rst_recv");
209 jb_open_object(jb,
"flags");
211 jb_open_array(jb,
name);
213 jb_append_string(jb,
"midstream");
216 jb_append_string(jb,
"midstream_established");
219 jb_append_string(jb,
"midstream_synack");
222 jb_append_string(jb,
"timestamp");
225 jb_append_string(jb,
"server_wscale");
228 jb_append_string(jb,
"closed_by_rst");
231 jb_append_string(jb,
"4whs");
234 jb_append_string(jb,
"detect_evasion_attempt");
237 jb_append_string(jb,
"client_sackok");
240 jb_append_string(jb,
"sackok");
243 jb_append_string(jb,
"3whs_confirmed");
246 jb_append_string(jb,
"app_layer_disabled");
249 jb_append_string(jb,
"bypass");
252 jb_append_string(jb,
"tcp_fast_open");
255 jb_append_string(jb,
"tfo_data_ignored");
266 static void LogStream(
const TcpStream *stream, JsonBuilder *js)
268 jb_set_uint(js,
"isn", stream->
isn);
269 jb_set_uint(js,
"next_seq", stream->
next_seq);
270 jb_set_uint(js,
"last_ack", stream->
last_ack);
271 jb_set_uint(js,
"next_win", stream->
next_win);
273 jb_set_uint(js,
"base_seq", stream->
base_seq);
276 jb_set_uint(js,
"window", stream->
window);
277 jb_set_uint(js,
"wscale", stream->
wscale);
287 jb_set_uint(js,
"seg_cnt", segs);
288 LogStreamSB(&stream->
sb, js);
312 if (p->
flow != NULL) {
314 jb_set_string(js,
"direction",
"to_server");
316 jb_set_string(js,
"direction",
"to_client");
320 jb_open_object(js,
"stream_tcp");
321 jb_open_object(js,
"packet");
323 if (PacketIsIPv4(p)) {
324 const IPV4Hdr *ip4h = PacketGetIPv4(p);
329 }
else if (PacketIsIPv6(p)) {
330 const IPV6Hdr *ip6h = PacketGetIPv6(p);
336 if (PacketIsTCP(p)) {
337 const TCPHdr *tcph = PacketGetTCP(p);
350 jb_open_array(js,
"flags");
352 jb_append_string(js,
"retransmission");
354 jb_append_string(js,
"spurious_retransmission");
356 jb_append_string(js,
"keepalive");
358 jb_append_string(js,
"keepalive_ack");
360 jb_append_string(js,
"window_update");
363 jb_append_string(js,
"event_set");
365 jb_append_string(js,
"state_update");
367 jb_append_string(js,
"dup_ack");
369 jb_append_string(js,
"dsack");
371 jb_append_string(js,
"ack_unseen_data");
373 jb_append_string(js,
"tcp_session_reuse");
375 jb_append_string(js,
"zero_window_probe");
377 jb_append_string(js,
"zero_window_probe_ack");
382 jb_open_object(js,
"session");
386 if (tcp_state != NULL)
387 jb_set_string(js,
"state", tcp_state);
390 if (tcp_pstate != NULL)
391 jb_set_string(js,
"pstate", tcp_pstate);
395 jb_open_object(js,
"client");
396 LogStream(&ssn->
client, js);
398 jb_open_object(js,
"server");
399 LogStream(&ssn->
server, js);
405 jb_open_array(js,
"events");
406 for (
int i = 0; i < p->
events.
cnt; i++) {
416 jb_append_string(js, event);
423 jb_set_string(js,
"reason",
str);
448 return (p->
proto == IPPROTO_TCP &&
449 (
ctx->trigger_flags == 0xffff ||
456 EveStreamLogInitCtxSub, EveStreamLogger, EveStreamLogCondition, EveStreamLogThreadInit,
457 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)
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)
#define STREAM_PKT_FLAG_TCP_SESSION_REUSE
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.