Go to the documentation of this file.
73 memset(op, 0x00,
sizeof(*op));
92 SCLogDebug(
"OutputRegisterFiledataLogger happy");
101 const uint8_t *data, uint32_t data_len, uint8_t
flags, uint8_t dir)
107 while (logger && store) {
117 logger = logger->
next;
138 FileContainer *ffc,
const uint8_t call_flags,
const bool file_close,
const bool file_trunc,
144 for (ff = ffc->
head; ff != NULL; ff = ff->
next) {
145 uint8_t file_flags = call_flags;
148 FilemagicThreadLookup(&td->magic_ctx, ff);
165 (file_trunc || file_close)) {
170 CloseFile(p, p->
flow, ff);
196 const uint8_t *data = NULL;
197 uint32_t data_len = 0;
203 const int file_logged = CallLoggers(
tv, store, p, ff, data, data_len, file_flags, dir);
209 CloseFile(p, p->
flow, ff);
229 if (f == NULL || f->
alstate == NULL) {
233 if (p->
proto != IPPROTO_TCP && p->
proto != IPPROTO_UDP) {
242 OutputFiledataLogFfc(
tv, op_thread_data, p, ffc_ts, STREAM_TOSERVER, file_close_ts,
243 file_trunc, STREAM_TOSERVER);
248 OutputFiledataLogFfc(
tv, op_thread_data, p, ffc_tc, STREAM_TOCLIENT, file_close_tc,
249 file_trunc, STREAM_TOCLIENT);
258 static TmEcode OutputFiledataLogThreadInit(
ThreadVars *
tv,
const void *initdata,
void **data)
263 memset(td, 0x00,
sizeof(*td));
268 td->magic_ctx = MagicInitContext();
269 if (td->magic_ctx == NULL) {
275 SCLogDebug(
"OutputFiledataLogThreadInit happy (*data %p)", *data);
284 memset(
ts, 0x00,
sizeof(*
ts));
287 ts->thread_data = retptr;
289 if (td->
store == NULL) {
293 while (tmp->
next != NULL)
302 logger = logger->
next;
313 while (logger && store) {
321 logger = logger->
next;
325 MagicDeinitContext(op_thread_data->magic_ctx);
332 static void OutputFiledataLogExitPrintStats(
ThreadVars *
tv,
void *thread_data)
338 while (logger && store) {
343 logger = logger->
next;
348 static uint32_t OutputFiledataLoggerGetActiveCount(
void)
360 OutputFiledataLogThreadDeinit, OutputFiledataLogExitPrintStats,
361 OutputFiledataLog, OutputFiledataLoggerGetActiveCount);
372 logger = next_logger;
OutputLoggerThreadStore * store
struct OutputLoggerThreadStore_ * next
#define SC_ATOMIC_INIT(name)
wrapper for initializing an atomic variable.
#define SC_ATOMIC_SET(name, val)
Set the value for the atomic variable.
ThreadDeinitFunc ThreadDeinit
int StreamTcpReassembleDepthReached(Packet *p)
check if stream in pkt direction has depth reached
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
void OutputFiledataShutdown(void)
#define FLOW_PKT_TOSERVER
struct OutputFiledataLogger_ * next
FileContainer * AppLayerParserGetFiles(const Flow *f, const uint8_t direction)
int(* FiledataLogger)(ThreadVars *, void *thread_data, const Packet *, File *, const uint8_t *, uint32_t, uint8_t, uint8_t dir)
int StreamingBufferGetDataAtOffset(const StreamingBuffer *sb, const uint8_t **data, uint32_t *data_len, uint64_t offset)
#define OUTPUT_FILEDATA_FLAG_CLOSE
int OutputRegisterFiledataLogger(LoggerId id, const char *name, FiledataLogger LogFunc, OutputCtx *output_ctx, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
SC_ATOMIC_DECLARE(unsigned int, g_file_store_id)
int FileCloseFilePtr(File *ff, const uint8_t *data, uint32_t data_len, uint16_t flags)
#define PKT_PSEUDO_STREAM_END
Per thread variable structure.
TmEcode(* ThreadInitFunc)(ThreadVars *, const void *, void **)
void * AppLayerParserGetTx(uint8_t ipproto, AppProto alproto, void *alstate, uint64_t tx_id)
uint64_t FileDataSize(const File *file)
get the size of the file data
#define PACKET_PROFILING_LOGGER_END(p, id)
struct OutputFiledataLogger_ OutputFiledataLogger
void(* ThreadExitPrintStatsFunc)(ThreadVars *, void *)
#define OUTPUT_FILEDATA_FLAG_OPEN
struct OutputFiledataLoggerThreadData_ OutputFiledataLoggerThreadData
AppLayerTxData * AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx)
ThreadExitPrintStatsFunc ThreadExitPrintStats
#define PACKET_PROFILING_LOGGER_START(p, id)
void OutputRegisterRootLogger(ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats, OutputLogFunc LogFunc, OutputGetActiveCountFunc ActiveCntFunc)
bool g_filedata_logger_enabled
ThreadInitFunc ThreadInit
AppProto alproto
application level protocol
void OutputFiledataLoggerRegister(void)
#define DEBUG_VALIDATE_BUG_ON(exp)
TmEcode(* ThreadDeinitFunc)(ThreadVars *, void *)