|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* Copyright (C) 2007-2014 Open Information Security Foundation
|
|
|
|
|
/* Copyright (C) 2007-2021 Open Information Security Foundation
|
|
|
|
|
*
|
|
|
|
|
* You can copy, redistribute or modify this Program under the terms of
|
|
|
|
|
* the GNU General Public License version 2 as published by the Free
|
|
|
|
@ -35,6 +35,8 @@
|
|
|
|
|
#include "util-validate.h"
|
|
|
|
|
#include "util-magic.h"
|
|
|
|
|
|
|
|
|
|
bool g_filedata_logger_enabled = false;
|
|
|
|
|
|
|
|
|
|
typedef struct OutputLoggerThreadStore_ {
|
|
|
|
|
void *thread_data;
|
|
|
|
|
struct OutputLoggerThreadStore_ *next;
|
|
|
|
@ -97,6 +99,7 @@ int OutputRegisterFiledataLogger(LoggerId id, const char *name,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SCLogDebug("OutputRegisterFiledataLogger happy");
|
|
|
|
|
g_filedata_logger_enabled = true;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -129,6 +132,17 @@ static int CallLoggers(ThreadVars *tv, OutputLoggerThreadStore *store_list,
|
|
|
|
|
return file_logged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void CloseFile(const Packet *p, Flow *f, File *file)
|
|
|
|
|
{
|
|
|
|
|
void *txv = AppLayerParserGetTx(p->proto, f->alproto, f->alstate, file->txid);
|
|
|
|
|
if (txv) {
|
|
|
|
|
AppLayerTxData *txd = AppLayerParserGetTxData(p->proto, f->alproto, txv);
|
|
|
|
|
if (txd)
|
|
|
|
|
txd->files_stored++;
|
|
|
|
|
}
|
|
|
|
|
file->flags |= FILE_STORED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void OutputFiledataLogFfc(ThreadVars *tv, OutputLoggerThreadData *td,
|
|
|
|
|
Packet *p, FileContainer *ffc, const uint8_t call_flags,
|
|
|
|
|
const bool file_close, const bool file_trunc, const uint8_t dir)
|
|
|
|
@ -162,7 +176,7 @@ static void OutputFiledataLogFfc(ThreadVars *tv, OutputLoggerThreadData *td,
|
|
|
|
|
FileCloseFilePtr(ff, NULL, 0, FILE_TRUNCATED);
|
|
|
|
|
}
|
|
|
|
|
CallLoggers(tv, store, p, ff, NULL, 0, OUTPUT_FILEDATA_FLAG_CLOSE, dir);
|
|
|
|
|
ff->flags |= FILE_STORED;
|
|
|
|
|
CloseFile(p, p->flow, ff);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -201,7 +215,7 @@ static void OutputFiledataLogFfc(ThreadVars *tv, OutputLoggerThreadData *td,
|
|
|
|
|
|
|
|
|
|
/* all done */
|
|
|
|
|
if (file_flags & OUTPUT_FILEDATA_FLAG_CLOSE) {
|
|
|
|
|
ff->flags |= FILE_STORED;
|
|
|
|
|
CloseFile(p, p->flow, ff);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|