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