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 typedef struct FrameJsonOutputCtx_ {
72  uint16_t flags;
76 
77 typedef struct JsonFrameLogThread_ {
82 
83 #if 0 // TODO see if this is useful in some way
84 static inline bool NeedsAsHex(uint8_t c)
85 {
86  if (!isprint(c))
87  return true;
88 
89  switch (c) {
90  case '/':
91  case ';':
92  case ':':
93  case '\\':
94  case ' ':
95  case '|':
96  case '"':
97  case '`':
98  case '\'':
99  return true;
100  }
101  return false;
102 }
103 
104 static void PayloadAsHex(const uint8_t *data, uint32_t data_len, char *str, size_t str_len)
105 {
106  bool hex = false;
107  for (uint32_t i = 0; i < data_len; i++) {
108  if (NeedsAsHex(data[i])) {
109  char hex_str[4];
110  snprintf(hex_str, sizeof(hex_str), "%s%02X", !hex ? "|" : " ", data[i]);
111  strlcat(str, hex_str, str_len);
112  hex = true;
113  } else {
114  char p_str[3];
115  snprintf(p_str, sizeof(p_str), "%s%c", hex ? "|" : "", data[i]);
116  strlcat(str, p_str, str_len);
117  hex = false;
118  }
119  }
120  if (hex) {
121  strlcat(str, "|", str_len);
122  }
123 }
124 #endif
125 
128  const Frame *frame;
129  uint64_t last_re; /**< used to detect gaps */
130 };
131 
132 static int FrameJsonStreamDataCallback(
133  void *cb_data, const uint8_t *input, const uint32_t input_len, const uint64_t input_offset)
134 {
135  struct FrameJsonStreamDataCallbackData *cbd = cb_data;
136  const Frame *frame = cbd->frame;
137 
138  uint32_t write_size = input_len;
139  int done = 0;
140 
141  if (frame->len >= 0) {
142  const uint64_t data_re = input_offset + input_len;
143  const uint64_t frame_re = frame->offset + (uint64_t)frame->len;
144 
145  /* data entirely after frame, we're done */
146  if (input_offset >= frame_re) {
147  return 1;
148  }
149  /* make sure to only log data belonging to the frame */
150  if (data_re >= frame_re) {
151  const uint64_t to_write = frame_re - input_offset;
152  if (to_write < (uint64_t)write_size) {
153  write_size = (uint32_t)to_write;
154  }
155  done = 1;
156  }
157  }
158  if (input_offset > cbd->last_re) {
160  cbd->payload, "[%" PRIu64 " bytes missing]", input_offset - cbd->last_re);
161  }
162 
163  if (write_size > 0) {
164  uint32_t written = MemBufferWriteRaw(cbd->payload, input, write_size);
165  if (written < write_size)
166  done = 1;
167  }
168  cbd->last_re = input_offset + write_size;
169  return done;
170 }
171 
172 /** \internal
173  * \brief try to log frame's stream data into payload/payload_printable
174  */
175 static void FrameAddPayloadTCP(Flow *f, const TcpSession *ssn, const TcpStream *stream,
176  const Frame *frame, SCJsonBuilder *jb, MemBuffer *buffer)
177 {
178  MemBufferReset(buffer);
179 
180  /* consider all data, ACK'd and non-ACK'd */
181  const uint64_t stream_data_re = StreamDataRightEdge(stream, true);
182  bool complete = false;
183  if (frame->len >= 0 && frame->offset + (uint64_t)frame->len <= stream_data_re) {
184  complete = true;
185  }
186 
187  struct FrameJsonStreamDataCallbackData cbd = {
188  .payload = buffer, .frame = frame, .last_re = frame->offset
189  };
190  uint64_t unused = 0;
192  ssn, stream, FrameJsonStreamDataCallback, &cbd, frame->offset, &unused, false);
193  /* if we have all data, but didn't log until the end of the frame, we have a gap at the
194  * end of the frame
195  * TODO what about not logging due to buffer full? */
196  if (complete && frame->len >= 0 && cbd.last_re < frame->offset + (uint64_t)frame->len) {
197  MemBufferWriteString(cbd.payload, "[%" PRIu64 " bytes missing]",
198  (frame->offset + (uint64_t)frame->len) - cbd.last_re);
199  }
200 
201  if (cbd.payload->offset) {
202  SCJbSetBase64(jb, "payload", cbd.payload->buffer, cbd.payload->offset);
203  SCJbSetPrintAsciiString(jb, "payload_printable", cbd.payload->buffer, cbd.payload->offset);
204  SCJbSetBool(jb, "complete", complete);
205  }
206 }
207 
208 static void FrameAddPayloadUDP(SCJsonBuilder *js, const Packet *p, const Frame *frame)
209 {
211  if (frame->offset >= p->payload_len)
212  return;
213 
214  uint32_t frame_len;
215  if (frame->len == -1) {
216  frame_len = (uint32_t)(p->payload_len - frame->offset);
217  } else {
218  frame_len = (uint32_t)frame->len;
219  }
220  if (frame->offset + frame_len > p->payload_len) {
221  frame_len = (uint32_t)(p->payload_len - frame->offset);
222  JB_SET_FALSE(js, "complete");
223  } else {
224  JB_SET_TRUE(js, "complete");
225  }
226  const uint8_t *data = p->payload + frame->offset;
227  const uint32_t data_len = frame_len;
228 
229  const uint32_t log_data_len = MIN(data_len, 256);
230  SCJbSetBase64(js, "payload", data, log_data_len);
231 
232  SCJbSetPrintAsciiString(js, "payload_printable", data, log_data_len);
233 #if 0
234  char pretty_buf[data_len * 4 + 1];
235  pretty_buf[0] = '\0';
236  PayloadAsHex(data, data_len, pretty_buf, data_len * 4 + 1);
237  SCJbSetString(js, "payload_hex", pretty_buf);
238 #endif
239 }
240 
241 // TODO separate between stream_offset and frame_offset
242 /** \brief log a single frame
243  * \note ipproto argument is passed to assist static code analyzers
244  */
245 void FrameJsonLogOneFrame(const uint8_t ipproto, const Frame *frame, Flow *f,
246  const TcpStream *stream, const Packet *p, SCJsonBuilder *jb, MemBuffer *buffer)
247 {
248  DEBUG_VALIDATE_BUG_ON(ipproto != p->proto);
249  DEBUG_VALIDATE_BUG_ON(ipproto != f->proto);
250 
251  SCJbOpenObject(jb, "frame");
252  if (frame->type == FRAME_STREAM_TYPE) {
253  SCJbSetString(jb, "type", "stream");
254  } else {
255  SCJbSetString(jb, "type", AppLayerParserGetFrameNameById(ipproto, f->alproto, frame->type));
256  }
257  SCJbSetUint(jb, "id", frame->id);
258  SCJbSetString(jb, "direction", PKT_IS_TOSERVER(p) ? "toserver" : "toclient");
259 
260  if (ipproto == IPPROTO_TCP) {
261  DEBUG_VALIDATE_BUG_ON(stream == NULL);
262  SCJbSetUint(jb, "stream_offset", frame->offset);
263 
264  if (frame->len < 0) {
265  uint64_t usable = StreamTcpGetUsable(stream, true);
266  uint64_t len = usable - frame->offset;
267  SCJbSetUint(jb, "length", len);
268  } else {
269  SCJbSetUint(jb, "length", frame->len);
270  }
271  FrameAddPayloadTCP(f, f->protoctx, stream, frame, jb, buffer);
272  } else {
273  SCJbSetUint(jb, "length", frame->len);
274  FrameAddPayloadUDP(jb, p, frame);
275  }
277  SCJbSetUint(jb, "tx_id", frame->tx_id);
278  }
279  SCJbClose(jb);
280 }
281 
282 static int FrameJsonUdp(ThreadVars *tv, JsonFrameLogThread *aft, const Packet *p, Flow *f,
283  FramesContainer *frames_container)
284 {
285  FrameJsonOutputCtx *json_output_ctx = aft->json_output_ctx;
286 
287  Frames *frames;
288  if (PKT_IS_TOSERVER(p)) {
289  frames = &frames_container->toserver;
290  } else {
291  frames = &frames_container->toclient;
292  }
293 
294  for (uint32_t idx = 0; idx < frames->cnt; idx++) {
295  Frame *frame = FrameGetByIndex(frames, idx);
296  if (frame == NULL || frame->flags & FRAME_FLAG_LOGGED)
297  continue;
298 
299  /* First initialize the address info (5-tuple). */
301  JsonAddrInfoInit(p, LOG_DIR_PACKET, &addr);
302 
303  SCJsonBuilder *jb =
304  CreateEveHeader(p, LOG_DIR_PACKET, "frame", &addr, json_output_ctx->eve_ctx);
305  if (unlikely(jb == NULL))
306  return TM_ECODE_OK;
307 
308  SCJbSetString(jb, "app_proto", AppProtoToString(f->alproto));
309  FrameJsonLogOneFrame(IPPROTO_UDP, frame, p->flow, NULL, p, jb, aft->payload_buffer);
310  OutputJsonBuilderBuffer(tv, p, p->flow, jb, aft->ctx);
311  SCJbFree(jb);
313  }
314  return TM_ECODE_OK;
315 }
316 
317 static int FrameJson(ThreadVars *tv, JsonFrameLogThread *aft, const Packet *p)
318 {
319  FrameJsonOutputCtx *json_output_ctx = aft->json_output_ctx;
320 
321  DEBUG_VALIDATE_BUG_ON(p->flow == NULL);
322 
323  FramesContainer *frames_container = AppLayerFramesGetContainer(p->flow);
324  if (frames_container == NULL)
325  return TM_ECODE_OK;
326 
327  if (p->proto == IPPROTO_UDP) {
328  return FrameJsonUdp(tv, aft, p, p->flow, frames_container);
329  }
330 
331  DEBUG_VALIDATE_BUG_ON(p->proto != IPPROTO_TCP);
332  DEBUG_VALIDATE_BUG_ON(p->flow->protoctx == NULL);
333 
334  /* TODO can we set these EOF flags once per packet? We have them in detect, tx, file, filedata,
335  * etc */
336  const bool last_pseudo = (p->flowflags & FLOW_PKT_LAST_PSEUDO) != 0;
337  Frames *frames;
338  TcpSession *ssn = p->flow->protoctx;
339  bool eof = (ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED);
340  TcpStream *stream;
341  if (PKT_IS_TOSERVER(p)) {
342  stream = &ssn->client;
343  frames = &frames_container->toserver;
344  SCLogDebug("TOSERVER base %" PRIu64 ", app %" PRIu64, STREAM_BASE_OFFSET(stream),
345  STREAM_APP_PROGRESS(stream));
347  } else {
348  stream = &ssn->server;
349  frames = &frames_container->toclient;
351  }
352  eof |= last_pseudo;
353  SCLogDebug("eof %s", eof ? "true" : "false");
354 
355  for (uint32_t idx = 0; idx < frames->cnt; idx++) {
356  Frame *frame = FrameGetByIndex(frames, idx);
357  if (frame != NULL) {
359  continue;
360 
361  int64_t abs_offset = (int64_t)frame->offset + (int64_t)STREAM_BASE_OFFSET(stream);
362  int64_t win = STREAM_APP_PROGRESS(stream) - abs_offset;
363 
364  /* skip frame if threshold not yet reached, esp if frame length is
365  * still unknown. */
366  if (!eof && ((frame->len == -1) || (win < frame->len)) && win < 2500) {
367  SCLogDebug("frame id %" PRIi64 " len %" PRIi64 ", win %" PRIi64
368  ", skipping logging",
369  frame->id, frame->len, win);
370  continue;
371  }
372 
373  /* First initialize the address info (5-tuple). */
375  JsonAddrInfoInit(p, LOG_DIR_PACKET, &addr);
376 
377  SCJsonBuilder *jb =
378  CreateEveHeader(p, LOG_DIR_PACKET, "frame", &addr, json_output_ctx->eve_ctx);
379  if (unlikely(jb == NULL))
380  return TM_ECODE_OK;
381 
382  SCJbSetString(jb, "app_proto", AppProtoToString(p->flow->alproto));
383  FrameJsonLogOneFrame(IPPROTO_TCP, frame, p->flow, stream, p, jb, aft->payload_buffer);
384  OutputJsonBuilderBuffer(tv, p, p->flow, jb, aft->ctx);
385  SCJbFree(jb);
387  }
388  }
389  return TM_ECODE_OK;
390 }
391 
392 static int JsonFrameLogger(ThreadVars *tv, void *thread_data, const Packet *p)
393 {
394  JsonFrameLogThread *aft = thread_data;
395  return FrameJson(tv, aft, p);
396 }
397 
398 static bool JsonFrameLogCondition(ThreadVars *tv, void *thread_data, const Packet *p)
399 {
400  if (p->flow == NULL || p->flow->alproto == ALPROTO_UNKNOWN)
401  return false;
402 
403  if ((p->proto == IPPROTO_TCP || p->proto == IPPROTO_UDP) && p->flow->alparser != NULL) {
404  if (p->proto == IPPROTO_TCP) {
405  if ((PKT_IS_PSEUDOPKT(p) || (p->flow->flags & FLOW_TS_APP_UPDATED)) &&
406  PKT_IS_TOSERVER(p)) {
407  // fallthrough
408  } else if ((PKT_IS_PSEUDOPKT(p) || (p->flow->flags & FLOW_TC_APP_UPDATED)) &&
409  PKT_IS_TOCLIENT(p)) {
410  // fallthrough
411  } else {
412  return false;
413  }
414  }
415 
416  FramesContainer *frames_container = AppLayerFramesGetContainer(p->flow);
417  if (frames_container == NULL)
418  return false;
419 
420  Frames *frames;
421  if (PKT_IS_TOSERVER(p)) {
422  frames = &frames_container->toserver;
423  } else {
424  frames = &frames_container->toclient;
425  }
426  return (frames->cnt != 0);
427  }
428  return false;
429 }
430 
431 static TmEcode JsonFrameLogThreadInit(ThreadVars *t, const void *initdata, void **data)
432 {
434  if (unlikely(aft == NULL))
435  return TM_ECODE_FAILED;
436 
437  if (initdata == NULL) {
438  SCLogDebug("Error getting context for EveLogFrame. \"initdata\" argument NULL");
439  goto error_exit;
440  }
441 
442  /** Use the Output Context (file pointer and mutex) */
443  FrameJsonOutputCtx *json_output_ctx = ((OutputCtx *)initdata)->data;
444 
445  aft->payload_buffer = MemBufferCreateNew(json_output_ctx->payload_buffer_size);
446  if (aft->payload_buffer == NULL) {
447  goto error_exit;
448  }
449  aft->ctx = CreateEveThreadCtx(t, json_output_ctx->eve_ctx);
450  if (!aft->ctx) {
451  goto error_exit;
452  }
453 
454  aft->json_output_ctx = json_output_ctx;
455 
456  *data = (void *)aft;
457  return TM_ECODE_OK;
458 
459 error_exit:
460  if (aft->payload_buffer != NULL) {
462  }
463  SCFree(aft);
464  return TM_ECODE_FAILED;
465 }
466 
467 static TmEcode JsonFrameLogThreadDeinit(ThreadVars *t, void *data)
468 {
469  JsonFrameLogThread *aft = (JsonFrameLogThread *)data;
470  if (aft == NULL) {
471  return TM_ECODE_OK;
472  }
473 
475  FreeEveThreadCtx(aft->ctx);
476 
477  /* clear memory */
478  memset(aft, 0, sizeof(JsonFrameLogThread));
479 
480  SCFree(aft);
481  return TM_ECODE_OK;
482 }
483 
484 static void JsonFrameLogDeInitCtxSub(OutputCtx *output_ctx)
485 {
486  SCLogDebug("cleaning up sub output_ctx %p", output_ctx);
487 
488  FrameJsonOutputCtx *json_output_ctx = (FrameJsonOutputCtx *)output_ctx->data;
489 
490  if (json_output_ctx != NULL) {
491  SCFree(json_output_ctx);
492  }
493  SCFree(output_ctx);
494 }
495 
496 /**
497  * \brief Create a new LogFileCtx for "fast" output style.
498  * \param conf The configuration node for this output.
499  * \return A LogFileCtx pointer on success, NULL on failure.
500  */
501 static OutputInitResult JsonFrameLogInitCtxSub(SCConfNode *conf, OutputCtx *parent_ctx)
502 {
503  OutputInitResult result = { NULL, false };
504  OutputJsonCtx *ajt = parent_ctx->data;
505  FrameJsonOutputCtx *json_output_ctx = NULL;
506 
507  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
508  if (unlikely(output_ctx == NULL))
509  return result;
510 
511  json_output_ctx = SCCalloc(1, sizeof(FrameJsonOutputCtx));
512  if (unlikely(json_output_ctx == NULL)) {
513  goto error;
514  }
515 
516  uint32_t payload_buffer_size = 4096;
517  if (conf != NULL) {
518  const char *payload_buffer_value = SCConfNodeLookupChildValue(conf, "payload-buffer-size");
519  if (payload_buffer_value != NULL) {
520  uint32_t value;
521  if (ParseSizeStringU32(payload_buffer_value, &value) < 0) {
522  SCLogError("Error parsing payload-buffer-size \"%s\"", payload_buffer_value);
523  goto error;
524  } else if (value == 0) {
525  // you should not ask for payload if you want 0 of it
526  SCLogError("Error payload-buffer-size should not be 0");
527  goto error;
528  }
529  payload_buffer_size = value;
530  }
531  }
532 
533  json_output_ctx->file_ctx = ajt->file_ctx;
534  json_output_ctx->eve_ctx = ajt;
535  json_output_ctx->payload_buffer_size = payload_buffer_size;
536 
537  output_ctx->data = json_output_ctx;
538  output_ctx->DeInit = JsonFrameLogDeInitCtxSub;
539 
541 
542  result.ctx = output_ctx;
543  result.ok = true;
544  return result;
545 
546 error:
547  if (json_output_ctx != NULL) {
548  SCFree(json_output_ctx);
549  }
550  if (output_ctx != NULL) {
551  SCFree(output_ctx);
552  }
553 
554  return result;
555 }
556 
558 {
559  OutputPacketLoggerFunctions output_logger_functions = {
560  .LogFunc = JsonFrameLogger,
561  .FlushFunc = OutputJsonLogFlush,
562  .ConditionFunc = JsonFrameLogCondition,
563  .ThreadInitFunc = JsonFrameLogThreadInit,
564  .ThreadDeinitFunc = JsonFrameLogThreadDeinit,
565  .ThreadExitPrintStatsFunc = NULL,
566  };
567  OutputRegisterPacketSubModule(LOGGER_JSON_FRAME, "eve-log", MODULE_NAME, "eve-log.frame",
568  JsonFrameLogInitCtxSub, &output_logger_functions);
569 }
PKT_IS_TOCLIENT
#define PKT_IS_TOCLIENT(p)
Definition: decode.h:239
util-byte.h
tm-threads.h
FrameJsonStreamDataCallbackData::frame
const Frame * frame
Definition: output-json-frame.c:128
Packet_::proto
uint8_t proto
Definition: decode.h:523
TcpStream_
Definition: stream-tcp-private.h:106
OutputJsonLogFlush
int OutputJsonLogFlush(ThreadVars *tv, void *thread_data, const Packet *p)
Definition: output-json-common.c:73
len
uint8_t len
Definition: app-layer-dnp3.h:2
SCAppLayerParserStateIssetFlag
uint16_t SCAppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint16_t flag)
Definition: app-layer-parser.c:1833
detect-engine.h
Frame::tx_id
uint64_t tx_id
Definition: app-layer-frames.h:52
MemBuffer_::buffer
uint8_t buffer[]
Definition: util-buffer.h:30
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1323
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:72
JsonFrameLogThread_::ctx
OutputJsonThreadCtx * ctx
Definition: output-json-frame.c:80
AppLayerFramesGetContainer
FramesContainer * AppLayerFramesGetContainer(const Flow *f)
Definition: app-layer-parser.c:184
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:279
FrameJsonOutputCtx
struct FrameJsonOutputCtx_ FrameJsonOutputCtx
FreeEveThreadCtx
void FreeEveThreadCtx(OutputJsonThreadCtx *ctx)
Definition: output-json-common.c:58
Flow_::proto
uint8_t proto
Definition: flow.h:370
FrameJsonOutputCtx_
Definition: output-json-frame.c:70
Packet_::payload
uint8_t * payload
Definition: decode.h:605
FramesContainer::toserver
Frames toserver
Definition: app-layer-frames.h:72
CreateEveHeader
SCJsonBuilder * CreateEveHeader(const Packet *p, enum SCOutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, OutputJsonCtx *eve_ctx)
Definition: output-json.c:832
threads.h
Frame::offset
uint64_t offset
Definition: app-layer-frames.h:49
OutputJsonCtx_
Definition: output-json.h:75
Frame
Definition: app-layer-frames.h:43
Flow_
Flow data structure.
Definition: flow.h:348
AppProtoToString
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
Definition: app-layer-protos.c:41
FLOW_TC_APP_UPDATED
#define FLOW_TC_APP_UPDATED
Definition: flow.h:120
LogFileCtx_
Definition: util-logopenfile.h:72
output-json-frame.h
Frames::cnt
uint16_t cnt
Definition: app-layer-frames.h:59
Frame::id
int64_t id
Definition: app-layer-frames.h:51
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:145
json_addr_info_zero
const JsonAddrInfo json_addr_info_zero
Definition: output-json.c:81
FrameJsonOutputCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json-frame.c:71
MIN
#define MIN(x, y)
Definition: suricata-common.h:408
Frames
Definition: app-layer-frames.h:58
FramesContainer
Definition: app-layer-frames.h:71
util-privs.h
OutputJsonBuilderBuffer
void OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, SCJsonBuilder *js, OutputJsonThreadCtx *ctx)
Definition: output-json.c:997
SCConfNodeLookupChildValue
const char * SCConfNodeLookupChildValue(const SCConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:824
app-layer-ftp.h
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:532
APP_LAYER_PARSER_EOF_TS
#define APP_LAYER_PARSER_EOF_TS
Definition: app-layer-parser.h:53
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:82
Flow_::protoctx
void * protoctx
Definition: flow.h:433
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:606
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:91
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:81
StreamTcpGetUsable
uint64_t StreamTcpGetUsable(const TcpStream *stream, const bool eof)
Definition: stream-tcp-reassemble.c:426
OutputCtx_
Definition: tm-modules.h:88
app-layer-htp-xff.h
TcpSession_::flags
uint32_t flags
Definition: stream-tcp-private.h:294
OutputJsonThreadCtx_
Definition: output-json.h:83
detect-reference.h
FrameJsonStreamDataCallbackData
Definition: output-json-frame.c:126
Flow_::alparser
AppLayerParserState * alparser
Definition: flow.h:470
JsonAddrInfoInit
void JsonAddrInfoInit(const Packet *p, enum SCOutputJsonLogDirection dir, JsonAddrInfo *addr)
Definition: output-json.c:468
app-layer-htp.h
FramesContainer::toclient
Frames toclient
Definition: app-layer-frames.h:73
util-debug.h
FrameJsonOutputCtx_::eve_ctx
OutputJsonCtx * eve_ctx
Definition: output-json-frame.c:74
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:238
AppLayerParserGetFrameNameById
const char * AppLayerParserGetFrameNameById(uint8_t ipproto, AppProto alproto, const uint8_t id)
Definition: app-layer-parser.c:1622
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:36
STREAM_BASE_OFFSET
#define STREAM_BASE_OFFSET(stream)
Definition: stream-tcp-private.h:144
util-print.h
detect-engine-mpm.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
FrameJsonStreamDataCallbackData::payload
MemBuffer * payload
Definition: output-json-frame.c:127
JB_SET_TRUE
#define JB_SET_TRUE(jb, key)
Definition: rust.h:32
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:79
FrameJsonOutputCtx_::payload_buffer_size
uint32_t payload_buffer_size
Definition: output-json-frame.c:73
JsonAddrInfo_
Definition: output-json.h:41
Packet_
Definition: decode.h:501
APP_LAYER_PARSER_EOF_TC
#define APP_LAYER_PARSER_EOF_TC
Definition: app-layer-parser.h:54
conf.h
JsonFrameLogThread_
Definition: output-json-frame.c:77
Frame::len
int64_t len
Definition: app-layer-frames.h:50
TmEcode
TmEcode
Definition: tm-threads-common.h:80
util-proto-name.h
MemBuffer_
Definition: util-buffer.h:27
Frame::flags
uint8_t flags
Definition: app-layer-frames.h:45
JsonFrameLogThread_::payload_buffer
MemBuffer * payload_buffer
Definition: output-json-frame.c:78
JsonFrameLogRegister
void JsonFrameLogRegister(void)
Definition: output-json-frame.c:557
OutputInitResult_
Definition: output.h:46
app-layer-frames.h
Packet_::flow
struct Flow_ * flow
Definition: decode.h:546
Frame::type
uint8_t type
Definition: app-layer-frames.h:44
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:94
detect-metadata.h
MemBufferFree
void MemBufferFree(MemBuffer *buffer)
Definition: util-buffer.c:86
OutputPacketLoggerFunctions_::LogFunc
PacketLogger LogFunc
Definition: output.h:88
FLOW_TS_APP_UPDATED
#define FLOW_TS_APP_UPDATED
Definition: flow.h:119
util-classification-config.h
FrameConfigEnableAll
void FrameConfigEnableAll(void)
Definition: app-layer-frames.c:56
TcpSession_::client
TcpStream client
Definition: stream-tcp-private.h:297
OutputRegisterPacketSubModule
void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, OutputPacketLoggerFunctions *output_logger_functions)
Register a packet output sub-module.
Definition: output.c:234
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
JB_SET_FALSE
#define JB_SET_FALSE(jb, key)
Definition: rust.h:33
ParseSizeStringU32
int ParseSizeStringU32(const char *size, uint32_t *res)
Definition: util-misc.c:174
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:296
str
#define str(s)
Definition: suricata-common.h:308
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:271
SCFree
#define SCFree(p)
Definition: util-mem.h:61
util-logopenfile.h
Flow_::flags
uint32_t flags
Definition: flow.h:413
FRAME_FLAG_LOGGED
#define FRAME_FLAG_LOGGED
Definition: app-layer-frames.h:40
detect-parse.h
FrameJsonLogOneFrame
void FrameJsonLogOneFrame(const uint8_t ipproto, const Frame *frame, Flow *f, const TcpStream *stream, const Packet *p, SCJsonBuilder *jb, MemBuffer *buffer)
log a single frame
Definition: output-json-frame.c:245
util-buffer.h
JsonFrameLogThread
struct JsonFrameLogThread_ JsonFrameLogThread
ALPROTO_UNKNOWN
@ ALPROTO_UNKNOWN
Definition: app-layer-protos.h:29
OutputJsonCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json.h:76
LOGGER_JSON_FRAME
@ LOGGER_JSON_FRAME
Definition: suricata-common.h:509
StreamDataRightEdge
uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof)
Definition: stream-tcp-reassemble.c:417
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:115
MemBufferWriteString
void MemBufferWriteString(MemBuffer *dst, const char *fmt,...)
Definition: util-buffer.c:130
LOG_DIR_PACKET
@ LOG_DIR_PACKET
Definition: output-eve-bindgen.h:32
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
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:442
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:1969
FrameJsonStreamDataCallbackData::last_re
uint64_t last_re
Definition: output-json-frame.c:129
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
SCConfNode_
Definition: conf.h:37
OutputPacketLoggerFunctions_
Definition: output.h:87
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:102
MemBufferCreateNew
MemBuffer * MemBufferCreateNew(uint32_t size)
Definition: util-buffer.c:32
output.h