suricata
output-json-frame.c
Go to the documentation of this file.
1 /* Copyright (C) 2013-2021 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  *
23  * Logs frames in JSON format.
24  *
25  */
26 
27 #include "suricata-common.h"
28 #include "detect.h"
29 #include "flow.h"
30 #include "conf.h"
31 
32 #include "threads.h"
33 #include "tm-threads.h"
34 #include "threadvars.h"
35 #include "util-debug.h"
36 
37 #include "util-logopenfile.h"
38 #include "util-misc.h"
39 #include "util-unittest.h"
40 #include "util-unittest-helper.h"
41 
42 #include "detect-parse.h"
43 #include "detect-engine.h"
44 #include "detect-engine-mpm.h"
45 #include "detect-reference.h"
46 #include "detect-metadata.h"
47 #include "app-layer-parser.h"
48 #include "app-layer-frames.h"
49 #include "app-layer-dnp3.h"
50 #include "app-layer-htp.h"
51 #include "app-layer-htp-xff.h"
52 #include "app-layer-ftp.h"
54 #include "stream-tcp.h"
55 
56 #include "output.h"
57 #include "output-json.h"
58 #include "output-json-frame.h"
59 
60 #include "util-byte.h"
61 #include "util-privs.h"
62 #include "util-print.h"
63 #include "util-proto-name.h"
64 #include "util-optimize.h"
65 #include "util-buffer.h"
66 #include "util-validate.h"
67 
68 #define MODULE_NAME "JsonFrameLog"
69 
70 #define JSON_STREAM_BUFFER_SIZE 4096
71 
72 typedef struct FrameJsonOutputCtx_ {
74  uint16_t flags;
78 
79 typedef struct JsonFrameLogThread_ {
84 
85 #if 0 // TODO see if this is useful in some way
86 static inline bool NeedsAsHex(uint8_t c)
87 {
88  if (!isprint(c))
89  return true;
90 
91  switch (c) {
92  case '/':
93  case ';':
94  case ':':
95  case '\\':
96  case ' ':
97  case '|':
98  case '"':
99  case '`':
100  case '\'':
101  return true;
102  }
103  return false;
104 }
105 
106 static void PayloadAsHex(const uint8_t *data, uint32_t data_len, char *str, size_t str_len)
107 {
108  bool hex = false;
109  for (uint32_t i = 0; i < data_len; i++) {
110  if (NeedsAsHex(data[i])) {
111  char hex_str[4];
112  snprintf(hex_str, sizeof(hex_str), "%s%02X", !hex ? "|" : " ", data[i]);
113  strlcat(str, hex_str, str_len);
114  hex = true;
115  } else {
116  char p_str[3];
117  snprintf(p_str, sizeof(p_str), "%s%c", hex ? "|" : "", data[i]);
118  strlcat(str, p_str, str_len);
119  hex = false;
120  }
121  }
122  if (hex) {
123  strlcat(str, "|", str_len);
124  }
125 }
126 #endif
127 
130  const Frame *frame;
131  uint64_t last_re; /**< used to detect gaps */
132 };
133 
134 static int FrameJsonStreamDataCallback(
135  void *cb_data, const uint8_t *input, const uint32_t input_len, const uint64_t input_offset)
136 {
137  struct FrameJsonStreamDataCallbackData *cbd = cb_data;
138  const Frame *frame = cbd->frame;
139 
140  uint32_t write_size = input_len;
141  int done = 0;
142 
143  if (frame->len >= 0) {
144  const uint64_t data_re = input_offset + input_len;
145  const uint64_t frame_re = frame->offset + (uint64_t)frame->len;
146 
147  /* data entirely after frame, we're done */
148  if (input_offset >= frame_re) {
149  return 1;
150  }
151  /* make sure to only log data belonging to the frame */
152  if (data_re >= frame_re) {
153  const uint64_t to_write = frame_re - input_offset;
154  if (to_write < (uint64_t)write_size) {
155  write_size = (uint32_t)to_write;
156  }
157  done = 1;
158  }
159  }
160  if (input_offset > cbd->last_re) {
162  cbd->payload, "[%" PRIu64 " bytes missing]", input_offset - cbd->last_re);
163  }
164 
165  if (write_size > 0) {
166  uint32_t written = MemBufferWriteRaw(cbd->payload, input, write_size);
167  if (written < write_size)
168  done = 1;
169  }
170  cbd->last_re = input_offset + write_size;
171  return done;
172 }
173 
174 /** \internal
175  * \brief try to log frame's stream data into payload/payload_printable
176  */
177 static void FrameAddPayloadTCP(Flow *f, const TcpSession *ssn, const TcpStream *stream,
178  const Frame *frame, JsonBuilder *jb, MemBuffer *buffer)
179 {
180  MemBufferReset(buffer);
181 
182  /* consider all data, ACK'd and non-ACK'd */
183  const uint64_t stream_data_re = StreamDataRightEdge(stream, true);
184  bool complete = false;
185  if (frame->len >= 0 && frame->offset + (uint64_t)frame->len <= stream_data_re) {
186  complete = true;
187  }
188 
189  struct FrameJsonStreamDataCallbackData cbd = {
190  .payload = buffer, .frame = frame, .last_re = frame->offset
191  };
192  uint64_t unused = 0;
194  ssn, stream, FrameJsonStreamDataCallback, &cbd, frame->offset, &unused, false);
195  /* if we have all data, but didn't log until the end of the frame, we have a gap at the
196  * end of the frame
197  * TODO what about not logging due to buffer full? */
198  if (complete && frame->len >= 0 && cbd.last_re < frame->offset + (uint64_t)frame->len) {
199  MemBufferWriteString(cbd.payload, "[%" PRIu64 " bytes missing]",
200  (frame->offset + (uint64_t)frame->len) - cbd.last_re);
201  }
202 
203  if (cbd.payload->offset) {
204  jb_set_base64(jb, "payload", cbd.payload->buffer, cbd.payload->offset);
205  uint8_t printable_buf[cbd.payload->offset + 1];
206  uint32_t offset = 0;
207  PrintStringsToBuffer(printable_buf, &offset, sizeof(printable_buf), cbd.payload->buffer,
208  cbd.payload->offset);
209  jb_set_string(jb, "payload_printable", (char *)printable_buf);
210  jb_set_bool(jb, "complete", complete);
211  }
212 }
213 
214 static void FrameAddPayloadUDP(JsonBuilder *js, const Packet *p, const Frame *frame)
215 {
217  if (frame->offset >= p->payload_len)
218  return;
219 
220  uint32_t frame_len;
221  if (frame->len == -1) {
222  frame_len = p->payload_len - frame->offset;
223  } else {
224  frame_len = (uint32_t)frame->len;
225  }
226  if (frame->offset + frame_len > p->payload_len) {
227  frame_len = p->payload_len - frame->offset;
228  JB_SET_FALSE(js, "complete");
229  } else {
230  JB_SET_TRUE(js, "complete");
231  }
232  const uint8_t *data = p->payload + frame->offset;
233  const uint32_t data_len = frame_len;
234 
235  const uint32_t log_data_len = MIN(data_len, 256);
236  jb_set_base64(js, "payload", data, log_data_len);
237 
238  uint8_t printable_buf[log_data_len + 1];
239  uint32_t o = 0;
240  PrintStringsToBuffer(printable_buf, &o, log_data_len + 1, data, log_data_len);
241  printable_buf[log_data_len] = '\0';
242  jb_set_string(js, "payload_printable", (char *)printable_buf);
243 #if 0
244  char pretty_buf[data_len * 4 + 1];
245  pretty_buf[0] = '\0';
246  PayloadAsHex(data, data_len, pretty_buf, data_len * 4 + 1);
247  jb_set_string(js, "payload_hex", pretty_buf);
248 #endif
249 }
250 
251 // TODO separate between stream_offset and frame_offset
252 /** \brief log a single frame
253  * \note ipproto argument is passed to assist static code analyzers
254  */
255 void FrameJsonLogOneFrame(const uint8_t ipproto, const Frame *frame, Flow *f,
256  const TcpStream *stream, const Packet *p, JsonBuilder *jb, MemBuffer *buffer)
257 {
258  DEBUG_VALIDATE_BUG_ON(ipproto != p->proto);
259  DEBUG_VALIDATE_BUG_ON(ipproto != f->proto);
260 
261  jb_open_object(jb, "frame");
262  if (frame->type == FRAME_STREAM_TYPE) {
263  jb_set_string(jb, "type", "stream");
264  } else {
265  jb_set_string(jb, "type", AppLayerParserGetFrameNameById(ipproto, f->alproto, frame->type));
266  }
267  jb_set_uint(jb, "id", frame->id);
268  jb_set_string(jb, "direction", PKT_IS_TOSERVER(p) ? "toserver" : "toclient");
269 
270  if (ipproto == IPPROTO_TCP) {
271  DEBUG_VALIDATE_BUG_ON(stream == NULL);
272  jb_set_uint(jb, "stream_offset", frame->offset);
273 
274  if (frame->len < 0) {
275  uint64_t usable = StreamTcpGetUsable(stream, true);
276  uint64_t len = usable - frame->offset;
277  jb_set_uint(jb, "length", len);
278  } else {
279  jb_set_uint(jb, "length", frame->len);
280  }
281  FrameAddPayloadTCP(f, f->protoctx, stream, frame, jb, buffer);
282  } else {
283  jb_set_uint(jb, "length", frame->len);
284  FrameAddPayloadUDP(jb, p, frame);
285  }
287  jb_set_uint(jb, "tx_id", frame->tx_id);
288  }
289  jb_close(jb);
290 }
291 
292 static int FrameJsonUdp(
293  JsonFrameLogThread *aft, const Packet *p, Flow *f, FramesContainer *frames_container)
294 {
295  FrameJsonOutputCtx *json_output_ctx = aft->json_output_ctx;
296 
297  Frames *frames;
298  if (PKT_IS_TOSERVER(p)) {
299  frames = &frames_container->toserver;
300  } else {
301  frames = &frames_container->toclient;
302  }
303 
304  for (uint32_t idx = 0; idx < frames->cnt; idx++) {
305  Frame *frame = FrameGetByIndex(frames, idx);
306  if (frame == NULL || frame->flags & FRAME_FLAG_LOGGED)
307  continue;
308 
309  /* First initialize the address info (5-tuple). */
311  JsonAddrInfoInit(p, LOG_DIR_PACKET, &addr);
312 
313  JsonBuilder *jb =
314  CreateEveHeader(p, LOG_DIR_PACKET, "frame", &addr, json_output_ctx->eve_ctx);
315  if (unlikely(jb == NULL))
316  return TM_ECODE_OK;
317 
318  jb_set_string(jb, "app_proto", AppProtoToString(f->alproto));
319  FrameJsonLogOneFrame(IPPROTO_UDP, frame, p->flow, NULL, p, jb, aft->payload_buffer);
320  OutputJsonBuilderBuffer(jb, aft->ctx);
321  jb_free(jb);
323  }
324  return TM_ECODE_OK;
325 }
326 
327 static int FrameJson(ThreadVars *tv, JsonFrameLogThread *aft, const Packet *p)
328 {
329  FrameJsonOutputCtx *json_output_ctx = aft->json_output_ctx;
330 
331  BUG_ON(p->flow == NULL);
332 
333  FramesContainer *frames_container = AppLayerFramesGetContainer(p->flow);
334  if (frames_container == NULL)
335  return TM_ECODE_OK;
336 
337  if (p->proto == IPPROTO_UDP) {
338  return FrameJsonUdp(aft, p, p->flow, frames_container);
339  }
340 
341  BUG_ON(p->proto != IPPROTO_TCP);
342  BUG_ON(p->flow->protoctx == NULL);
343 
344  /* TODO can we set these EOF flags once per packet? We have them in detect, tx, file, filedata,
345  * etc */
346  const bool last_pseudo = (p->flowflags & FLOW_PKT_LAST_PSEUDO) != 0;
347  Frames *frames;
348  TcpSession *ssn = p->flow->protoctx;
349  bool eof = (ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED);
350  TcpStream *stream;
351  if (PKT_IS_TOSERVER(p)) {
352  stream = &ssn->client;
353  frames = &frames_container->toserver;
354  SCLogDebug("TOSERVER base %" PRIu64 ", app %" PRIu64, STREAM_BASE_OFFSET(stream),
355  STREAM_APP_PROGRESS(stream));
357  } else {
358  stream = &ssn->server;
359  frames = &frames_container->toclient;
361  }
362  eof |= last_pseudo;
363  SCLogDebug("eof %s", eof ? "true" : "false");
364 
365  for (uint32_t idx = 0; idx < frames->cnt; idx++) {
366  Frame *frame = FrameGetByIndex(frames, idx);
367  if (frame != NULL) {
369  continue;
370 
371  int64_t abs_offset = (int64_t)frame->offset + (int64_t)STREAM_BASE_OFFSET(stream);
372  int64_t win = STREAM_APP_PROGRESS(stream) - abs_offset;
373 
374  if (!eof && win < frame->len && win < 2500) {
375  SCLogDebug("frame id %" PRIi64 " len %" PRIi64 ", win %" PRIi64
376  ", skipping logging",
377  frame->id, frame->len, win);
378  continue;
379  }
380 
381  /* First initialize the address info (5-tuple). */
383  JsonAddrInfoInit(p, LOG_DIR_PACKET, &addr);
384 
385  JsonBuilder *jb =
386  CreateEveHeader(p, LOG_DIR_PACKET, "frame", &addr, json_output_ctx->eve_ctx);
387  if (unlikely(jb == NULL))
388  return TM_ECODE_OK;
389 
390  jb_set_string(jb, "app_proto", AppProtoToString(p->flow->alproto));
391  FrameJsonLogOneFrame(IPPROTO_TCP, frame, p->flow, stream, p, jb, aft->payload_buffer);
392  OutputJsonBuilderBuffer(jb, aft->ctx);
393  jb_free(jb);
395  } else if (frame != NULL) {
396  SCLogDebug("frame %p id %" PRIi64, frame, frame->id);
397  }
398  }
399  return TM_ECODE_OK;
400 }
401 
402 static int JsonFrameLogger(ThreadVars *tv, void *thread_data, const Packet *p)
403 {
404  JsonFrameLogThread *aft = thread_data;
405  return FrameJson(tv, aft, p);
406 }
407 
408 static bool JsonFrameLogCondition(ThreadVars *tv, void *thread_data, const Packet *p)
409 {
410  if (p->flow == NULL || p->flow->alproto == ALPROTO_UNKNOWN)
411  return false;
412 
413  if ((p->proto == IPPROTO_TCP || p->proto == IPPROTO_UDP) && p->flow->alparser != NULL) {
414  FramesContainer *frames_container = AppLayerFramesGetContainer(p->flow);
415  if (frames_container == NULL)
416  return false;
417 
418  Frames *frames;
419  if (PKT_IS_TOSERVER(p)) {
420  frames = &frames_container->toserver;
421  } else {
422  frames = &frames_container->toclient;
423  }
424  return (frames->cnt != 0);
425  }
426  return false;
427 }
428 
429 static TmEcode JsonFrameLogThreadInit(ThreadVars *t, const void *initdata, void **data)
430 {
432  if (unlikely(aft == NULL))
433  return TM_ECODE_FAILED;
434 
435  if (initdata == NULL) {
436  SCLogDebug("Error getting context for EveLogFrame. \"initdata\" argument NULL");
437  goto error_exit;
438  }
439 
440  /** Use the Output Context (file pointer and mutex) */
441  FrameJsonOutputCtx *json_output_ctx = ((OutputCtx *)initdata)->data;
442 
443  aft->payload_buffer = MemBufferCreateNew(json_output_ctx->payload_buffer_size);
444  if (aft->payload_buffer == NULL) {
445  goto error_exit;
446  }
447  aft->ctx = CreateEveThreadCtx(t, json_output_ctx->eve_ctx);
448  if (!aft->ctx) {
449  goto error_exit;
450  }
451 
452  aft->json_output_ctx = json_output_ctx;
453 
454  *data = (void *)aft;
455  return TM_ECODE_OK;
456 
457 error_exit:
458  if (aft->payload_buffer != NULL) {
460  }
461  SCFree(aft);
462  return TM_ECODE_FAILED;
463 }
464 
465 static TmEcode JsonFrameLogThreadDeinit(ThreadVars *t, void *data)
466 {
467  JsonFrameLogThread *aft = (JsonFrameLogThread *)data;
468  if (aft == NULL) {
469  return TM_ECODE_OK;
470  }
471 
473  FreeEveThreadCtx(aft->ctx);
474 
475  /* clear memory */
476  memset(aft, 0, sizeof(JsonFrameLogThread));
477 
478  SCFree(aft);
479  return TM_ECODE_OK;
480 }
481 
482 static void JsonFrameLogDeInitCtxSub(OutputCtx *output_ctx)
483 {
484  SCLogDebug("cleaning up sub output_ctx %p", output_ctx);
485 
486  FrameJsonOutputCtx *json_output_ctx = (FrameJsonOutputCtx *)output_ctx->data;
487 
488  if (json_output_ctx != NULL) {
489  SCFree(json_output_ctx);
490  }
491  SCFree(output_ctx);
492 }
493 
494 /**
495  * \brief Create a new LogFileCtx for "fast" output style.
496  * \param conf The configuration node for this output.
497  * \return A LogFileCtx pointer on success, NULL on failure.
498  */
499 static OutputInitResult JsonFrameLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx)
500 {
501  OutputInitResult result = { NULL, false };
502  OutputJsonCtx *ajt = parent_ctx->data;
503  FrameJsonOutputCtx *json_output_ctx = NULL;
504 
505  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
506  if (unlikely(output_ctx == NULL))
507  return result;
508 
509  json_output_ctx = SCCalloc(1, sizeof(FrameJsonOutputCtx));
510  if (unlikely(json_output_ctx == NULL)) {
511  goto error;
512  }
513 
514  uint32_t payload_buffer_size = 4096;
515  if (conf != NULL) {
516  const char *payload_buffer_value = ConfNodeLookupChildValue(conf, "payload-buffer-size");
517  if (payload_buffer_value != NULL) {
518  uint32_t value;
519  if (ParseSizeStringU32(payload_buffer_value, &value) < 0) {
520  SCLogError("Error parsing payload-buffer-size \"%s\"", payload_buffer_value);
521  goto error;
522  }
523  payload_buffer_size = value;
524  }
525  }
526 
527  json_output_ctx->file_ctx = ajt->file_ctx;
528  json_output_ctx->eve_ctx = ajt;
529  json_output_ctx->payload_buffer_size = payload_buffer_size;
530 
531  output_ctx->data = json_output_ctx;
532  output_ctx->DeInit = JsonFrameLogDeInitCtxSub;
533 
535 
536  result.ctx = output_ctx;
537  result.ok = true;
538  return result;
539 
540 error:
541  if (json_output_ctx != NULL) {
542  SCFree(json_output_ctx);
543  }
544  if (output_ctx != NULL) {
545  SCFree(output_ctx);
546  }
547 
548  return result;
549 }
550 
552 {
553  OutputRegisterPacketSubModule(LOGGER_JSON_FRAME, "eve-log", MODULE_NAME, "eve-log.frame",
554  JsonFrameLogInitCtxSub, JsonFrameLogger, JsonFrameLogCondition, JsonFrameLogThreadInit,
555  JsonFrameLogThreadDeinit, NULL);
556 }
util-byte.h
tm-threads.h
FrameJsonStreamDataCallbackData::frame
const Frame * frame
Definition: output-json-frame.c:130
Packet_::proto
uint8_t proto
Definition: decode.h:459
TcpStream_
Definition: stream-tcp-private.h:106
len
uint8_t len
Definition: app-layer-dnp3.h:2
detect-engine.h
Frame::tx_id
uint64_t tx_id
Definition: app-layer-frames.h:54
MemBuffer_::buffer
uint8_t buffer[]
Definition: util-buffer.h:30
offset
uint64_t offset
Definition: util-streaming-buffer.h:0
stream-tcp.h
FLOW_PKT_LAST_PSEUDO
#define FLOW_PKT_LAST_PSEUDO
Definition: flow.h:232
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
FrameJsonOutputCtx_::flags
uint16_t flags
Definition: output-json-frame.c:74
JsonFrameLogThread_::ctx
OutputJsonThreadCtx * ctx
Definition: output-json-frame.c:82
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
FrameJsonOutputCtx
struct FrameJsonOutputCtx_ FrameJsonOutputCtx
FreeEveThreadCtx
void FreeEveThreadCtx(OutputJsonThreadCtx *ctx)
Definition: output-json-common.c:58
Flow_::proto
uint8_t proto
Definition: flow.h:373
FrameJsonOutputCtx_
Definition: output-json-frame.c:72
Packet_::payload
uint8_t * payload
Definition: decode.h:586
FramesContainer::toserver
Frames toserver
Definition: app-layer-frames.h:74
threads.h
Frame::offset
uint64_t offset
Definition: app-layer-frames.h:51
OutputJsonCtx_
Definition: output-json.h:79
Frame
Definition: app-layer-frames.h:45
Flow_
Flow data structure.
Definition: flow.h:351
AppProtoToString
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
Definition: app-layer-protos.c:75
LogFileCtx_
Definition: util-logopenfile.h:76
output-json-frame.h
OutputJsonBuilderBuffer
int OutputJsonBuilderBuffer(JsonBuilder *js, OutputJsonThreadCtx *ctx)
Definition: output-json.c:928
Frames::cnt
uint16_t cnt
Definition: app-layer-frames.h:61
Frame::id
int64_t id
Definition: app-layer-frames.h:53
CreateEveThreadCtx
OutputJsonThreadCtx * CreateEveThreadCtx(ThreadVars *t, OutputJsonCtx *ctx)
Definition: output-json-common.c:29
FrameGetByIndex
Frame * FrameGetByIndex(Frames *frames, const uint32_t idx)
Definition: app-layer-frames.c:106
json_addr_info_zero
const JsonAddrInfo json_addr_info_zero
Definition: output-json.c:89
FrameJsonOutputCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json-frame.c:73
MIN
#define MIN(x, y)
Definition: suricata-common.h:391
Frames
Definition: app-layer-frames.h:60
FramesContainer
Definition: app-layer-frames.h:73
util-privs.h
app-layer-ftp.h
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:468
APP_LAYER_PARSER_EOF_TS
#define APP_LAYER_PARSER_EOF_TS
Definition: app-layer-parser.h:39
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:85
Flow_::protoctx
void * protoctx
Definition: flow.h:441
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:587
util-unittest.h
MemBuffer_::offset
uint32_t offset
Definition: util-buffer.h:29
util-unittest-helper.h
OutputCtx_::data
void * data
Definition: tm-modules.h:88
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:84
PrintStringsToBuffer
void PrintStringsToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size, const uint8_t *src_buf, const uint32_t src_buf_len)
Definition: util-print.c:199
StreamTcpGetUsable
uint64_t StreamTcpGetUsable(const TcpStream *stream, const bool eof)
Definition: stream-tcp-reassemble.c:425
OutputCtx_
Definition: tm-modules.h:85
app-layer-htp-xff.h
TcpSession_::flags
uint32_t flags
Definition: stream-tcp-private.h:292
OutputJsonThreadCtx_
Definition: output-json.h:87
detect-reference.h
FrameJsonStreamDataCallbackData
Definition: output-json-frame.c:128
Flow_::alparser
AppLayerParserState * alparser
Definition: flow.h:475
app-layer-htp.h
FramesContainer::toclient
Frames toclient
Definition: app-layer-frames.h:75
util-debug.h
FrameJsonOutputCtx_::eve_ctx
OutputJsonCtx * eve_ctx
Definition: output-json-frame.c:76
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:252
AppLayerParserGetFrameNameById
const char * AppLayerParserGetFrameNameById(uint8_t ipproto, AppProto alproto, const uint8_t id)
Definition: app-layer-parser.c:1612
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:47
MODULE_NAME
#define MODULE_NAME
Definition: output-json-frame.c:68
strlcat
size_t strlcat(char *, const char *src, size_t siz)
Definition: util-strlcatu.c:45
app-layer-dnp3.h
output-json.h
FRAME_FLAG_TX_ID_SET
#define FRAME_FLAG_TX_ID_SET
Definition: app-layer-frames.h:38
STREAM_BASE_OFFSET
#define STREAM_BASE_OFFSET(stream)
Definition: stream-tcp-private.h:144
CreateEveHeader
JsonBuilder * CreateEveHeader(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, OutputJsonCtx *eve_ctx)
Definition: output-json.c:787
util-print.h
detect-engine-mpm.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
FrameJsonStreamDataCallbackData::payload
MemBuffer * payload
Definition: output-json-frame.c:129
JB_SET_TRUE
#define JB_SET_TRUE(jb, key)
Definition: rust.h:27
OutputInitResult_::ok
bool ok
Definition: output.h:48
app-layer-parser.h
JsonFrameLogThread_::json_output_ctx
FrameJsonOutputCtx * json_output_ctx
Definition: output-json-frame.c:81
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:300
FrameJsonOutputCtx_::payload_buffer_size
uint32_t payload_buffer_size
Definition: output-json-frame.c:75
JsonAddrInfo_
Definition: output-json.h:47
Packet_
Definition: decode.h:437
AppLayerFramesGetContainer
FramesContainer * AppLayerFramesGetContainer(Flow *f)
Definition: app-layer-parser.c:182
APP_LAYER_PARSER_EOF_TC
#define APP_LAYER_PARSER_EOF_TC
Definition: app-layer-parser.h:40
conf.h
JsonFrameLogThread_
Definition: output-json-frame.c:79
Frame::len
int64_t len
Definition: app-layer-frames.h:52
TmEcode
TmEcode
Definition: tm-threads-common.h:83
util-proto-name.h
MemBuffer_
Definition: util-buffer.h:27
Frame::flags
uint8_t flags
Definition: app-layer-frames.h:47
JsonFrameLogThread_::payload_buffer
MemBuffer * payload_buffer
Definition: output-json-frame.c:80
JsonFrameLogRegister
void JsonFrameLogRegister(void)
Definition: output-json-frame.c:551
OutputInitResult_
Definition: output.h:46
app-layer-frames.h
Packet_::flow
struct Flow_ * flow
Definition: decode.h:476
LOG_DIR_PACKET
@ LOG_DIR_PACKET
Definition: output-json.h:37
Frame::type
uint8_t type
Definition: app-layer-frames.h:46
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:91
OutputRegisterPacketSubModule
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, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a packet output sub-module.
Definition: output.c:209
detect-metadata.h
MemBufferFree
void MemBufferFree(MemBuffer *buffer)
Definition: util-buffer.c:81
util-classification-config.h
FrameConfigEnableAll
void FrameConfigEnableAll(void)
Definition: app-layer-frames.c:45
TcpSession_::client
TcpStream client
Definition: stream-tcp-private.h:295
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
JB_SET_FALSE
#define JB_SET_FALSE(jb, key)
Definition: rust.h:28
ParseSizeStringU32
int ParseSizeStringU32(const char *size, uint32_t *res)
Definition: util-misc.c:181
util-optimize.h
threadvars.h
util-validate.h
FRAME_STREAM_TYPE
#define FRAME_STREAM_TYPE
Definition: app-layer-frames.h:30
TcpSession_::server
TcpStream server
Definition: stream-tcp-private.h:294
str
#define str(s)
Definition: suricata-common.h:291
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
SCFree
#define SCFree(p)
Definition: util-mem.h:61
ConfNode_
Definition: conf.h:32
util-logopenfile.h
FRAME_FLAG_LOGGED
#define FRAME_FLAG_LOGGED
Definition: app-layer-frames.h:42
detect-parse.h
util-buffer.h
FrameJsonLogOneFrame
void FrameJsonLogOneFrame(const uint8_t ipproto, const Frame *frame, Flow *f, const TcpStream *stream, const Packet *p, JsonBuilder *jb, MemBuffer *buffer)
log a single frame
Definition: output-json-frame.c:255
JsonFrameLogThread
struct JsonFrameLogThread_ JsonFrameLogThread
ALPROTO_UNKNOWN
@ ALPROTO_UNKNOWN
Definition: app-layer-protos.h:29
OutputJsonCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json.h:80
LOGGER_JSON_FRAME
@ LOGGER_JSON_FRAME
Definition: suricata-common.h:491
StreamDataRightEdge
uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof)
Definition: stream-tcp-reassemble.c:416
STREAMTCP_FLAG_APP_LAYER_DISABLED
#define STREAMTCP_FLAG_APP_LAYER_DISABLED
Definition: stream-tcp-private.h:201
MemBufferWriteRaw
uint32_t MemBufferWriteRaw(MemBuffer *dst, const uint8_t *raw, const uint32_t raw_len)
Write a raw buffer to the MemBuffer dst.
Definition: util-buffer.c:112
MemBufferWriteString
void MemBufferWriteString(MemBuffer *dst, const char *fmt,...)
Definition: util-buffer.c:127
JsonAddrInfoInit
void JsonAddrInfoInit(const Packet *p, enum OutputJsonLogDirection dir, JsonAddrInfo *addr)
Definition: output-json.c:477
STREAM_APP_PROGRESS
#define STREAM_APP_PROGRESS(stream)
Definition: stream-tcp-private.h:145
TcpSession_
Definition: stream-tcp-private.h:283
util-misc.h
flow.h
AppLayerParserStateIssetFlag
uint16_t AppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint16_t flag)
Definition: app-layer-parser.c:1794
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:450
StreamReassembleLog
int StreamReassembleLog(const TcpSession *ssn, const TcpStream *stream, StreamReassembleRawFunc Callback, void *cb_data, const uint64_t progress_in, uint64_t *progress_out, const bool eof)
Definition: stream-tcp-reassemble.c:1916
FrameJsonStreamDataCallbackData::last_re
uint64_t last_re
Definition: output-json-frame.c:131
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:103
MemBufferCreateNew
MemBuffer * MemBufferCreateNew(uint32_t size)
Definition: util-buffer.c:32
output.h
ConfNodeLookupChildValue
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:814