Go to the documentation of this file.
107 typedef struct LoggerThreadStoreNode_ {
112 typedef TAILQ_HEAD(LoggerThreadStore_, LoggerThreadStoreNode_) LoggerThreadStore;
122 typedef struct OutputFileRolloverFlag_ {
128 TAILQ_HEAD(, OutputFileRolloverFlag_) output_file_rotation_flags =
159 FatalError(
"Fatal error encountered in OutputRegisterModule. Exiting...");
197 FatalError(
"Fatal error encountered. Exiting...");
237 FatalError(
"Fatal error encountered. Exiting...");
248 static void OutputRegisterTxModuleWrapper(
LoggerId id,
const char *
name,
const char *conf_name,
278 FatalError(
"Fatal error encountered. Exiting...");
281 static void OutputRegisterTxSubModuleWrapper(
LoggerId id,
const char *parent_name,
const char *
name,
309 SCLogDebug(
"Tx logger for alproto %d \"%s\" registered.", alproto,
name);
312 FatalError(
"Fatal error encountered. Exiting...");
327 OutputRegisterTxModuleWrapper(
id,
name, conf_name, InitFunc, alproto, TxLogFunc, -1, -1,
328 TxLogCondition, ThreadInit, ThreadDeinit);
335 OutputRegisterTxSubModuleWrapper(
id, parent_name,
name, conf_name, InitFunc, alproto, TxLogFunc,
336 -1, -1, TxLogCondition, ThreadInit, ThreadDeinit);
351 OutputRegisterTxModuleWrapper(
id,
name, conf_name, InitFunc, alproto, TxLogFunc,
352 tc_log_progress, ts_log_progress, NULL, ThreadInit, ThreadDeinit);
357 int tc_log_progress,
int ts_log_progress,
ThreadInitFunc ThreadInit,
360 OutputRegisterTxSubModuleWrapper(
id, parent_name,
name, conf_name, InitFunc, alproto, TxLogFunc,
361 tc_log_progress, ts_log_progress, NULL, ThreadInit, ThreadDeinit);
376 OutputRegisterTxModuleWrapper(
id,
name, conf_name, InitFunc, alproto, TxLogFunc, -1, -1, NULL,
377 ThreadInit, ThreadDeinit);
384 OutputRegisterTxSubModuleWrapper(
id, parent_name,
name, conf_name, InitFunc, alproto, TxLogFunc,
385 -1, -1, NULL, ThreadInit, ThreadDeinit);
400 if (
unlikely(FileLogFunc == NULL)) {
422 FatalError(
"Fatal error encountered. Exiting...");
437 if (
unlikely(FiledataLogFunc == NULL)) {
458 FatalError(
"Fatal error encountered. Exiting...");
473 if (
unlikely(FlowLogFunc == NULL)) {
495 FatalError(
"Fatal error encountered. Exiting...");
511 if (
unlikely(StreamingLogFunc == NULL)) {
533 FatalError(
"Fatal error encountered. Exiting...");
548 if (
unlikely(StatsLogFunc == NULL)) {
569 FatalError(
"Fatal error encountered. Exiting...");
584 if (
unlikely(StatsLogFunc == NULL)) {
606 FatalError(
"Fatal error encountered. Exiting...");
620 if (strcmp(module->
conf_name, conf_name) == 0)
640 SCFree(simple_json_applayer_loggers);
641 simple_json_applayer_loggers = NULL;
644 static int drop_loggers = 0;
670 SCLogError(
"Failed to allocate memory to register file rotation flag");
673 flag_entry->flag = flag;
690 for (entry =
TAILQ_FIRST(&output_file_rotation_flags); entry != NULL;
693 if (entry->flag == flag) {
694 TAILQ_REMOVE(&output_file_rotation_flags, entry, entries);
713 LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
716 while (logger && thread_store_node) {
718 logger->
FlushFunc(
tv, p, thread_store_node->thread_data);
721 thread_store_node =
TAILQ_NEXT(thread_store_node, entries);
728 LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
731 while (logger && thread_store_node) {
732 logger->
LogFunc(
tv, p, thread_store_node->thread_data);
735 thread_store_node =
TAILQ_NEXT(thread_store_node, entries);
742 LoggerThreadStore *thread_store =
SCCalloc(1,
sizeof(*thread_store));
743 if (thread_store == NULL) {
747 *data = (
void *)thread_store;
752 void *child_thread_data = NULL;
756 SCCalloc(1,
sizeof(*thread_store_node));
757 if (thread_store_node == NULL) {
763 thread_store_node->thread_data = child_thread_data;
773 if (thread_data == NULL)
776 LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
779 while (logger && thread_store_node) {
784 thread_store_node =
TAILQ_NEXT(thread_store_node, entries);
788 while ((thread_store_node =
TAILQ_FIRST(thread_store)) != NULL) {
790 SCFree(thread_store_node);
803 if (logger == NULL) {
813 static void OutputRegisterActiveLogger(
RootLogger *reg)
816 if (logger == NULL) {
832 OutputRegisterActiveLogger(logger);
842 while ((logger =
TAILQ_FIRST(&active_loggers)) != NULL) {
857 return &simple_json_applayer_loggers[alproto];
862 static void RegisterSimpleJsonApplayerLogger(
865 simple_json_applayer_loggers[alproto].
LogTx = LogTx;
867 simple_json_applayer_loggers[alproto].
name =
name;
879 if (
unlikely(simple_json_applayer_loggers == NULL)) {
880 FatalError(
"Failed to allocate simple_json_applayer_loggers");
887 RegisterSimpleJsonApplayerLogger(
ALPROTO_SSH, SCSshLogJson, NULL);
892 RegisterSimpleJsonApplayerLogger(
894 RegisterSimpleJsonApplayerLogger(
ALPROTO_ENIP, SCEnipLoggerLog, NULL);
899 RegisterSimpleJsonApplayerLogger(
902 RegisterSimpleJsonApplayerLogger(
904 RegisterSimpleJsonApplayerLogger(
ALPROTO_QUIC, rs_quic_to_json, NULL);
906 RegisterSimpleJsonApplayerLogger(
909 RegisterSimpleJsonApplayerLogger(
ALPROTO_RFB, rs_rfb_logger_log, NULL);
912 RegisterSimpleJsonApplayerLogger(
ALPROTO_WEBSOCKET, rs_websocket_logger_log, NULL);
913 RegisterSimpleJsonApplayerLogger(
ALPROTO_LDAP, rs_ldap_logger_log, NULL);
915 RegisterSimpleJsonApplayerLogger(
ALPROTO_TEMPLATE, rs_template_logger_log, NULL);
918 RegisterSimpleJsonApplayerLogger(
ALPROTO_HTTP2, rs_http2_log_json,
"http");
920 RegisterSimpleJsonApplayerLogger(
931 void *state,
void *tx, uint64_t tx_id,
int dir)
944 if (!al->
LogTx(tx, js)) {
959 void *state,
void *tx, uint64_t tx_id)
961 return JsonGenericLogger(
tv, thread_data, p, f, state, tx, tx_id,
LOG_DIR_PACKET);
965 void *state,
void *tx, uint64_t tx_id)
967 return JsonGenericLogger(
tv, thread_data, p, f, state, tx, tx_id,
LOG_DIR_FLOW);
970 #define ARRAY_CAP_STEP 16
972 static size_t preregistered_loggers_nb = 0;
973 static size_t preregistered_loggers_cap = 0;
981 if (preregistered_loggers_nb == preregistered_loggers_cap) {
989 preregistered_loggers = tmp;
991 preregistered_loggers[preregistered_loggers_nb] = reg_data;
992 preregistered_loggers_nb++;
1043 SCLogDebug(
"modbus json logger registered.");
1144 if (
ConfGetNode(
"app-layer.protocols.bittorrent-dht") != NULL) {
1153 for (
size_t i = 0; i < preregistered_loggers_nb; i++) {
1159 "%s JSON logger registered.",
AppProtoToString(preregistered_loggers[i].alproto));
1160 RegisterSimpleJsonApplayerLogger(
1161 preregistered_loggers[i].alproto, preregistered_loggers[i].LogTx, NULL);
ThreadDeinitFunc ThreadDeinit
void LogTlsStoreRegister(void)
OutputInitResult OutputJsonLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
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)
PacketLogger PacketFlushFunc
bool AlertJsonDoh2(void *txptr, JsonBuilder *js)
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)
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)
ConfNode * ConfGetNode(const char *name)
Get a ConfNode by name.
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)
void OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, JsonBuilder *js, OutputJsonThreadCtx *ctx)
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)
#define TAILQ_FOREACH(var, head, field)
OutputModule * OutputGetModuleByConfName(const char *conf_name)
Get an output module by name.
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 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
bool(* EveJsonSimpleTxLogFunc)(void *, struct JsonBuilder *)
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
bool JsonPgsqlAddMetadata(void *vtx, JsonBuilder *jb)
void TmModuleLoggerRegister(void)
bool JsonTlsLogJSONExtended(void *vtx, JsonBuilder *tjs)
bool EveFTPDataAddMetadata(void *vtx, JsonBuilder *jb)
void OutputJsonRegister(void)
void OutputClearActiveLoggers(void)
#define TAILQ_ENTRY(type)
void OutputRegisterFileRotationFlag(int *flag)
Register a flag for file rotation notification.
void LogHttpLogRegister(void)
bool AlertJsonDnp3(void *vtx, JsonBuilder *js)
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
OutputInitResult(* OutputInitSubFunc)(ConfNode *, OutputCtx *)
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
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)
JsonBuilder * CreateEveHeader(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, OutputJsonCtx *eve_ctx)
void JsonIKELogRegister(void)
Per thread variable structure.
TmEcode(* ThreadInitFunc)(ThreadVars *, const void *, void **)
SCStreamingLogger StreamingLogFunc
bool EveFTPLogCommand(void *vtx, JsonBuilder *jb)
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 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
bool AlertJsonDns(void *txptr, JsonBuilder *js)
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)
#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)
bool JsonMQTTAddMetadata(void *vtx, JsonBuilder *js)
void JsonDropLogRegister(void)
int(* StatsLogger)(ThreadVars *, void *thread_data, const StatsTable *)
OutputInitResult(* OutputInitFunc)(ConfNode *)
void JsonHttpLogRegister(void)
void JsonArpLogRegister(void)
TmEcode JsonLogThreadDeinit(ThreadVars *t, void *data)
int OutputPreRegisterLogger(EveJsonTxLoggerRegistrationData reg_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
void OutputFiledataLoggerRegister(void)
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 *)