Go to the documentation of this file.
106 typedef struct LoggerThreadStoreNode_ {
111 typedef TAILQ_HEAD(LoggerThreadStore_, LoggerThreadStoreNode_) LoggerThreadStore;
121 typedef struct OutputFileRolloverFlag_ {
127 TAILQ_HEAD(, OutputFileRolloverFlag_) output_file_rotation_flags =
153 SCLogDebug(
"Output module \"%s\" registered.", name);
158 FatalError(
"Fatal error encountered in OutputRegisterModule. Exiting...");
173 if (
unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) {
192 SCLogDebug(
"Packet logger \"%s\" registered.", name);
195 FatalError(
"Fatal error encountered. Exiting...");
211 if (
unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) {
231 SCLogDebug(
"Packet logger \"%s\" registered.", name);
234 FatalError(
"Fatal error encountered. Exiting...");
245 static void OutputRegisterTxModuleWrapper(
LoggerId id,
const char *name,
const char *conf_name,
272 SCLogDebug(
"Tx logger \"%s\" registered.", name);
275 FatalError(
"Fatal error encountered. Exiting...");
278 static void OutputRegisterTxSubModuleWrapper(
LoggerId id,
const char *parent_name,
const char *name,
306 SCLogDebug(
"Tx logger for alproto %d \"%s\" registered.", alproto, name);
309 FatalError(
"Fatal error encountered. Exiting...");
324 OutputRegisterTxModuleWrapper(
id, name, conf_name, InitFunc, alproto, TxLogFunc, -1, -1,
325 TxLogCondition, ThreadInit, ThreadDeinit);
332 OutputRegisterTxSubModuleWrapper(
id, parent_name, name, conf_name, InitFunc, alproto, TxLogFunc,
333 -1, -1, TxLogCondition, ThreadInit, ThreadDeinit);
348 OutputRegisterTxModuleWrapper(
id, name, conf_name, InitFunc, alproto, TxLogFunc,
349 tc_log_progress, ts_log_progress, NULL, ThreadInit, ThreadDeinit);
354 int tc_log_progress,
int ts_log_progress,
ThreadInitFunc ThreadInit,
357 OutputRegisterTxSubModuleWrapper(
id, parent_name, name, conf_name, InitFunc, alproto, TxLogFunc,
358 tc_log_progress, ts_log_progress, NULL, ThreadInit, ThreadDeinit);
373 OutputRegisterTxModuleWrapper(
id, name, conf_name, InitFunc, alproto, TxLogFunc, -1, -1, NULL,
374 ThreadInit, ThreadDeinit);
381 OutputRegisterTxSubModuleWrapper(
id, parent_name, name, conf_name, InitFunc, alproto, TxLogFunc,
382 -1, -1, NULL, ThreadInit, ThreadDeinit);
397 if (
unlikely(FileLogFunc == NULL)) {
416 SCLogDebug(
"File logger \"%s\" registered.", name);
419 FatalError(
"Fatal error encountered. Exiting...");
434 if (
unlikely(FiledataLogFunc == NULL)) {
452 SCLogDebug(
"Filedata logger \"%s\" registered.", name);
455 FatalError(
"Fatal error encountered. Exiting...");
470 if (
unlikely(FlowLogFunc == NULL)) {
489 SCLogDebug(
"Flow logger \"%s\" registered.", name);
492 FatalError(
"Fatal error encountered. Exiting...");
508 if (
unlikely(StreamingLogFunc == NULL)) {
527 SCLogDebug(
"Streaming logger \"%s\" registered.", name);
530 FatalError(
"Fatal error encountered. Exiting...");
545 if (
unlikely(StatsLogFunc == NULL)) {
563 SCLogDebug(
"Stats logger \"%s\" registered.", name);
566 FatalError(
"Fatal error encountered. Exiting...");
581 if (
unlikely(StatsLogFunc == NULL)) {
600 SCLogDebug(
"Stats logger \"%s\" registered.", name);
603 FatalError(
"Fatal error encountered. Exiting...");
617 if (strcmp(module->
conf_name, conf_name) == 0)
637 SCFree(simple_json_applayer_loggers);
638 simple_json_applayer_loggers = NULL;
641 static int drop_loggers = 0;
667 SCLogError(
"Failed to allocate memory to register file rotation flag");
670 flag_entry->flag = flag;
687 for (entry =
TAILQ_FIRST(&output_file_rotation_flags); entry != NULL;
690 if (entry->flag == flag) {
691 TAILQ_REMOVE(&output_file_rotation_flags, entry, entries);
710 LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
713 while (logger && thread_store_node) {
714 logger->
LogFunc(
tv, p, thread_store_node->thread_data);
717 thread_store_node =
TAILQ_NEXT(thread_store_node, entries);
724 LoggerThreadStore *thread_store =
SCCalloc(1,
sizeof(*thread_store));
725 if (thread_store == NULL) {
729 *data = (
void *)thread_store;
734 void *child_thread_data = NULL;
738 SCCalloc(1,
sizeof(*thread_store_node));
739 if (thread_store_node == NULL) {
745 thread_store_node->thread_data = child_thread_data;
755 if (thread_data == NULL)
758 LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
761 while (logger && thread_store_node) {
766 thread_store_node =
TAILQ_NEXT(thread_store_node, entries);
770 while ((thread_store_node =
TAILQ_FIRST(thread_store)) != NULL) {
772 SCFree(thread_store_node);
785 if (logger == NULL) {
795 static void OutputRegisterActiveLogger(
RootLogger *reg)
798 if (logger == NULL) {
814 OutputRegisterActiveLogger(logger);
824 while ((logger =
TAILQ_FIRST(&active_loggers)) != NULL) {
839 return &simple_json_applayer_loggers[alproto];
844 static void RegisterSimpleJsonApplayerLogger(
847 simple_json_applayer_loggers[alproto].
LogTx = LogTx;
849 simple_json_applayer_loggers[alproto].
name = name;
861 if (
unlikely(simple_json_applayer_loggers == NULL)) {
862 FatalError(
"Failed to allocate simple_json_applayer_loggers");
869 RegisterSimpleJsonApplayerLogger(
ALPROTO_SSH, rs_ssh_log_json, NULL);
874 RegisterSimpleJsonApplayerLogger(
876 RegisterSimpleJsonApplayerLogger(
ALPROTO_ENIP, SCEnipLoggerLog, NULL);
881 RegisterSimpleJsonApplayerLogger(
884 RegisterSimpleJsonApplayerLogger(
886 RegisterSimpleJsonApplayerLogger(
ALPROTO_QUIC, rs_quic_to_json, NULL);
888 RegisterSimpleJsonApplayerLogger(
891 RegisterSimpleJsonApplayerLogger(
ALPROTO_RFB, rs_rfb_logger_log, NULL);
894 RegisterSimpleJsonApplayerLogger(
ALPROTO_WEBSOCKET, rs_websocket_logger_log, NULL);
895 RegisterSimpleJsonApplayerLogger(
ALPROTO_LDAP, rs_ldap_logger_log, NULL);
897 RegisterSimpleJsonApplayerLogger(
ALPROTO_TEMPLATE, rs_template_logger_log, NULL);
900 RegisterSimpleJsonApplayerLogger(
ALPROTO_HTTP2, rs_http2_log_json,
"http");
902 RegisterSimpleJsonApplayerLogger(
913 void *state,
void *tx, uint64_t tx_id,
int dir)
926 if (!al->
LogTx(tx, js)) {
941 void *state,
void *tx, uint64_t tx_id)
943 return JsonGenericLogger(
tv, thread_data, p, f, state, tx, tx_id,
LOG_DIR_PACKET);
947 void *state,
void *tx, uint64_t tx_id)
949 return JsonGenericLogger(
tv, thread_data, p, f, state, tx, tx_id,
LOG_DIR_FLOW);
1100 if (
ConfGetNode(
"app-layer.protocols.bittorrent-dht") != 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)
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 OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a packet output sub-module.
void JsonSMBLogRegister(void)
void OutputRegisterRootLogger(ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, OutputLogFunc LogFunc, OutputGetActiveCountFunc ActiveCntFunc)
void OutputFileLoggerRegister(void)
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 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.
int(* PacketLogger)(ThreadVars *, void *thread_data, const Packet *)
Packet 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
void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a packet output module.
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)
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)
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
bool(* TxLoggerCondition)(ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id)
Transaction logger condition function pointer type.
void LogStatsLogRegister(void)
void JsonFrameLogRegister(void)
TxLoggerCondition TxLogCondition
bool AlertJsonDns(void *txptr, JsonBuilder *js)
EveJsonSimpleTxLogFunc LogTx
#define TAILQ_NEXT(elm, field)
int OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, JsonBuilder *js, OutputJsonThreadCtx *ctx)
void LuaLogRegister(void)
void JsonSmtpLogRegister(void)
bool(* PacketLogCondition)(ThreadVars *, void *thread_data, const Packet *)
Packet logger condition function point type.
PacketLogCondition PacketConditionFunc
struct RootLogger_ RootLogger
uint32_t(* OutputGetActiveCountFunc)(void)
void JsonDnsLogRegister(void)
#define SCLogError(...)
Macro used to log ERROR messages.
TmEcode OutputLoggerLog(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)
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 *)