Go to the documentation of this file.
108 typedef struct LoggerThreadStoreNode_ {
113 typedef TAILQ_HEAD(LoggerThreadStore_, LoggerThreadStoreNode_) LoggerThreadStore;
123 typedef struct OutputFileRolloverFlag_ {
131 TAILQ_HEAD(, OutputFileRolloverFlag_) output_file_rotation_flags =
162 FatalError(
"Fatal error encountered in OutputRegisterModule. Exiting...");
200 FatalError(
"Fatal error encountered. Exiting...");
240 FatalError(
"Fatal error encountered. Exiting...");
251 static void OutputRegisterTxModuleWrapper(
LoggerId id,
const char *
name,
const char *conf_name,
281 FatalError(
"Fatal error encountered. Exiting...");
284 static void OutputRegisterTxSubModuleWrapper(
LoggerId id,
const char *parent_name,
const char *
name,
312 SCLogDebug(
"Tx logger for alproto %d \"%s\" registered.", alproto,
name);
315 FatalError(
"Fatal error encountered. Exiting...");
330 OutputRegisterTxModuleWrapper(
id,
name, conf_name, InitFunc, alproto, TxLogFunc, -1, -1,
331 TxLogCondition, ThreadInit, ThreadDeinit);
338 OutputRegisterTxSubModuleWrapper(
id, parent_name,
name, conf_name, InitFunc, alproto, TxLogFunc,
339 -1, -1, TxLogCondition, ThreadInit, ThreadDeinit);
354 OutputRegisterTxModuleWrapper(
id,
name, conf_name, InitFunc, alproto, TxLogFunc,
355 tc_log_progress, ts_log_progress, NULL, ThreadInit, ThreadDeinit);
360 int tc_log_progress,
int ts_log_progress,
ThreadInitFunc ThreadInit,
363 OutputRegisterTxSubModuleWrapper(
id, parent_name,
name, conf_name, InitFunc, alproto, TxLogFunc,
364 tc_log_progress, ts_log_progress, NULL, ThreadInit, ThreadDeinit);
379 OutputRegisterTxModuleWrapper(
id,
name, conf_name, InitFunc, alproto, TxLogFunc, -1, -1, NULL,
380 ThreadInit, ThreadDeinit);
387 OutputRegisterTxSubModuleWrapper(
id, parent_name,
name, conf_name, InitFunc, alproto, TxLogFunc,
388 -1, -1, NULL, ThreadInit, ThreadDeinit);
403 if (
unlikely(FileLogFunc == NULL)) {
425 FatalError(
"Fatal error encountered. Exiting...");
440 if (
unlikely(FiledataLogFunc == NULL)) {
461 FatalError(
"Fatal error encountered. Exiting...");
476 if (
unlikely(FlowLogFunc == NULL)) {
498 FatalError(
"Fatal error encountered. Exiting...");
514 if (
unlikely(StreamingLogFunc == NULL)) {
536 FatalError(
"Fatal error encountered. Exiting...");
551 if (
unlikely(StatsLogFunc == NULL)) {
572 FatalError(
"Fatal error encountered. Exiting...");
587 if (
unlikely(StatsLogFunc == NULL)) {
609 FatalError(
"Fatal error encountered. Exiting...");
623 if (strcmp(module->
conf_name, conf_name) == 0)
643 SCFree(simple_json_applayer_loggers);
644 simple_json_applayer_loggers = NULL;
647 static int drop_loggers = 0;
673 SCLogError(
"Failed to allocate memory to register file rotation flag");
676 flag_entry->flag = flag;
696 for (entry =
TAILQ_FIRST(&output_file_rotation_flags); entry != NULL;
699 if (entry->flag == flag) {
700 TAILQ_REMOVE(&output_file_rotation_flags, entry, entries);
724 LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
727 while (logger && thread_store_node) {
729 logger->
FlushFunc(
tv, p, thread_store_node->thread_data);
732 thread_store_node =
TAILQ_NEXT(thread_store_node, entries);
739 LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
742 while (logger && thread_store_node) {
743 logger->
LogFunc(
tv, p, thread_store_node->thread_data);
746 thread_store_node =
TAILQ_NEXT(thread_store_node, entries);
753 LoggerThreadStore *thread_store =
SCCalloc(1,
sizeof(*thread_store));
754 if (thread_store == NULL) {
758 *data = (
void *)thread_store;
763 void *child_thread_data = NULL;
767 SCCalloc(1,
sizeof(*thread_store_node));
768 if (thread_store_node == NULL) {
774 thread_store_node->thread_data = child_thread_data;
784 if (thread_data == NULL)
787 LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
790 while (logger && thread_store_node) {
795 thread_store_node =
TAILQ_NEXT(thread_store_node, entries);
799 while ((thread_store_node =
TAILQ_FIRST(thread_store)) != NULL) {
801 SCFree(thread_store_node);
814 if (logger == NULL) {
824 static void OutputRegisterActiveLogger(
RootLogger *reg)
827 if (logger == NULL) {
843 OutputRegisterActiveLogger(logger);
853 while ((logger =
TAILQ_FIRST(&active_loggers)) != NULL) {
868 return &simple_json_applayer_loggers[alproto];
873 static void RegisterSimpleJsonApplayerLogger(
876 simple_json_applayer_loggers[alproto].
LogTx = LogTx;
878 simple_json_applayer_loggers[alproto].
name =
name;
890 if (
unlikely(simple_json_applayer_loggers == NULL)) {
891 FatalError(
"Failed to allocate simple_json_applayer_loggers");
896 RegisterSimpleJsonApplayerLogger(
904 RegisterSimpleJsonApplayerLogger(
910 RegisterSimpleJsonApplayerLogger(
912 RegisterSimpleJsonApplayerLogger(
915 RegisterSimpleJsonApplayerLogger(
922 RegisterSimpleJsonApplayerLogger(
924 RegisterSimpleJsonApplayerLogger(
926 RegisterSimpleJsonApplayerLogger(
928 RegisterSimpleJsonApplayerLogger(
931 RegisterSimpleJsonApplayerLogger(
935 RegisterSimpleJsonApplayerLogger(
949 void *state,
void *tx, uint64_t tx_id,
int dir)
962 if (!al->
LogTx(tx, js)) {
977 void *state,
void *tx, uint64_t tx_id)
979 return JsonGenericLogger(
tv, thread_data, p, f, state, tx, tx_id,
LOG_DIR_PACKET);
983 void *state,
void *tx, uint64_t tx_id)
985 return JsonGenericLogger(
tv, thread_data, p, f, state, tx, tx_id,
LOG_DIR_FLOW);
988 #define ARRAY_CAP_STEP 16
990 static size_t preregistered_loggers_nb = 0;
991 static size_t preregistered_loggers_cap = 0;
999 if (preregistered_loggers_nb == preregistered_loggers_cap) {
1007 preregistered_loggers = tmp;
1009 preregistered_loggers[preregistered_loggers_nb] = reg_data;
1010 preregistered_loggers_nb++;
1014 static TxLogger JsonLoggerFromDir(uint8_t dir)
1017 return JsonGenericDirPacketLogger;
1020 return JsonGenericDirFlowLogger;
1070 SCLogDebug(
"modbus json logger registered.");
1170 if (
SCConfGetNode(
"app-layer.protocols.bittorrent-dht") != NULL) {
1179 for (
size_t i = 0; i < preregistered_loggers_nb; i++) {
1182 preregistered_loggers[i].alproto, JsonLoggerFromDir(preregistered_loggers[i].dir),
1185 "%s JSON logger registered.",
AppProtoToString(preregistered_loggers[i].alproto));
1186 RegisterSimpleJsonApplayerLogger(preregistered_loggers[i].alproto,
ThreadDeinitFunc ThreadDeinit
bool JsonMQTTAddMetadata(void *vtx, SCJsonBuilder *js)
void LogTlsStoreRegister(void)
int OutputDropLoggerEnable(void)
void OutputRegisterStreamingModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, SCStreamingLogger StreamingLogFunc, enum SCOutputStreamingType stream_type, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a streaming data output module.
TmEcode(* OutputLogFunc)(ThreadVars *, Packet *, void *)
void JsonDoh2LogRegister(void)
void JsonDCERPCLogRegister(void)
void OutputTxLoggerRegister(void)
void JsonPgsqlLogRegister(void)
bool JsonTlsLogJSONExtended(void *vtx, SCJsonBuilder *tjs)
PacketLogger PacketFlushFunc
void OutputRegisterTxSubModuleWithProgress(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
bool EveFTPDataAddMetadata(void *vtx, SCJsonBuilder *jb)
void JsonSMBLogRegister(void)
void OutputRegisterRootLogger(ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, OutputLogFunc LogFunc, OutputGetActiveCountFunc ActiveCntFunc)
void OutputFileLoggerRegister(void)
OutputFlushFunc FlushFunc
struct HtpBodyChunk_ * next
int(* SCFileLogger)(ThreadVars *, void *thread_data, const Packet *, const File *, void *tx, const uint64_t tx_id, uint8_t direction)
EveJsonSimpleAppLayerLogger * SCEveJsonSimpleGetLogger(AppProto alproto)
SCJsonBuilder * CreateEveHeader(const Packet *p, enum SCOutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, OutputJsonCtx *eve_ctx)
TmEcode JsonLogThreadInit(ThreadVars *t, const void *initdata, void **data)
void LogTlsLogRegister(void)
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
void AlertFastLogRegister(void)
void JsonFileLogRegister(void)
bool AlertJsonDns(void *txptr, SCJsonBuilder *js)
void OutputRegisterStatsSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a stats data output sub-module.
void JsonDNP3LogRegister(void)
void LogCustomFormatRegister(void)
int SCOutputEvePreRegisterLogger(EveJsonTxLoggerRegistrationData reg_data)
#define TAILQ_FOREACH(var, head, field)
OutputModule * OutputGetModuleByConfName(const char *conf_name)
Get an output module by name.
OutputInitResult(* OutputInitFunc)(SCConfNode *)
bool SSHTxLogCondition(ThreadVars *tv, const Packet *p, void *state, void *tx, uint64_t tx_id)
void OutputRegisterTxSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
void OutputSetupActiveLoggers(void)
void AlertSyslogRegister(void)
Function to register the AlertSyslog module.
void JsonDHCPLogRegister(void)
int(* TxLogger)(ThreadVars *, void *thread_data, const Packet *, Flow *f, void *state, void *tx, uint64_t tx_id)
Transaction logger function pointer type.
int(* FlowLogger)(ThreadVars *, void *thread_data, Flow *f)
Flow logger function pointer type.
#define SCMUTEX_INITIALIZER
void OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, SCJsonBuilder *js, OutputJsonThreadCtx *ctx)
#define TAILQ_INSERT_TAIL(head, elm, field)
void PcapLogRegister(void)
OutputInitSubFunc InitSubFunc
void OutputRegisterFiledataModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, SCFiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a file data output module.
int(* SCFiledataLogger)(ThreadVars *, void *thread_data, const Packet *, File *, void *tx, const uint64_t tx_id, const uint8_t *, uint32_t, uint8_t, uint8_t dir)
File-data logger function pointer type.
PacketLogger PacketLogFunc
SCFiledataLogger FiledataLogFunc
void JsonStatsLogRegister(void)
void LogTcpDataLogRegister(void)
void OutputRegisterRootLoggers(void)
Register all root loggers.
TmEcode OutputLoggerThreadDeinit(ThreadVars *tv, void *thread_data)
void OutputRegisterTxModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a tx output module.
void JsonTlsLogRegister(void)
void OutputRegisterFileSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, SCFileLogger FileLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a file output sub-module.
void JsonFlowLogRegister(void)
PacketLogCondition ConditionFunc
void TmModuleLoggerRegister(void)
bool JsonPgsqlAddMetadata(void *vtx, SCJsonBuilder *jb)
void OutputJsonRegister(void)
void OutputClearActiveLoggers(void)
#define TAILQ_ENTRY(type)
void OutputRegisterFileRotationFlag(int *flag)
Register a flag for file rotation notification.
OutputInitResult OutputJsonLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
void LogHttpLogRegister(void)
void OutputRegisterFlowSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a flow output sub-module.
enum SCOutputStreamingType stream_type
ThreadInitFunc ThreadInit
void OutputRegisterTxModuleWithCondition(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a tx output module with condition.
#define TAILQ_HEAD_INITIALIZER(head)
OutputModuleList output_modules
void JsonAnomalyLogRegister(void)
#define TAILQ_REMOVE(head, elm, field)
#define TAILQ_FIRST(head)
void OutputStreamingLoggerRegister(void)
void OutputRegisterStatsModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a stats data output module.
ThreadDeinitFunc ThreadDeinit
#define SCMutexUnlock(mut)
void OutputRegisterTxModuleWithProgress(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a tx output module with progress.
void OutputRegisterModule(const char *, const char *, OutputInitFunc)
void JsonIKELogRegister(void)
Per thread variable structure.
TmEcode(* ThreadInitFunc)(ThreadVars *, const void *, void **)
SCStreamingLogger StreamingLogFunc
TmEcode OutputLoggerThreadInit(ThreadVars *tv, const void *initdata, void **data)
void JsonMQTTLogRegister(void)
void OutputFilestoreRegister(void)
TmEcode(* OutputFlushFunc)(ThreadVars *, Packet *, void *)
void OutputRegisterLoggers(void)
Register all non-root logging modules.
void OutputDeregisterAll(void)
Deregister all modules. Useful for a memory clean exit.
OutputGetActiveCountFunc ActiveCntFunc
void OutputPacketLoggerRegister(void)
void OutputNotifyFileRotation(void)
Notifies all registered file rotation notification flags.
typedef TAILQ_HEAD(LoggerThreadStore_, LoggerThreadStoreNode_)
void EveStreamLogRegister(void)
ThreadInitFunc ThreadInit
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
#define SCRealloc(ptr, sz)
bool(* TxLoggerCondition)(ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id)
Transaction logger condition function pointer type.
void LogStatsLogRegister(void)
ThreadDeinitFunc ThreadDeinitFunc
void JsonFrameLogRegister(void)
TxLoggerCondition TxLogCondition
EveJsonSimpleTxLogFunc LogTx
#define TAILQ_NEXT(elm, field)
void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, OutputPacketLoggerFunctions *output_module_functions)
Register a packet output module.
void LuaLogRegister(void)
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.
void JsonSmtpLogRegister(void)
PacketLogCondition PacketConditionFunc
struct RootLogger_ RootLogger
uint32_t(* OutputGetActiveCountFunc)(void)
ThreadInitFunc ThreadInitFunc
void JsonDnsLogRegister(void)
bool EveFTPLogCommand(void *vtx, SCJsonBuilder *jb)
SCConfNode * SCConfGetNode(const char *name)
Get a SCConfNode by name.
#define SCLogError(...)
Macro used to log ERROR messages.
TmEcode OutputLoggerLog(ThreadVars *tv, Packet *p, void *thread_data)
TmEcode OutputLoggerFlush(ThreadVars *tv, Packet *p, void *thread_data)
void JsonDropLogRegister(void)
int(* StatsLogger)(ThreadVars *, void *thread_data, const StatsTable *)
bool AlertJsonDnp3(void *vtx, SCJsonBuilder *js)
void JsonHttpLogRegister(void)
void JsonArpLogRegister(void)
TmEcode JsonLogThreadDeinit(ThreadVars *t, void *data)
void AlertDebugLogRegister(void)
void OutputUnregisterFileRotationFlag(int *flag)
Unregister a file rotation flag.
void OutputRegisterTxSubModuleWithCondition(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
AppProto alproto
application level protocol
bool(* EveJsonSimpleTxLogFunc)(const void *, void *)
void OutputFiledataLoggerRegister(void)
bool AlertJsonDoh2(void *txptr, SCJsonBuilder *js)
OutputInitResult(* OutputInitSubFunc)(SCConfNode *, OutputCtx *)
int(* SCStreamingLogger)(ThreadVars *, void *thread_data, const Flow *f, const uint8_t *data, uint32_t data_len, uint64_t tx_id, uint8_t flags)
void JsonAlertLogRegister(void)
void JsonNFSLogRegister(void)
void OutputDropLoggerDisable(void)
void JsonNetFlowLogRegister(void)
TmEcode(* ThreadDeinitFunc)(ThreadVars *, void *)