output: sub-module support for other log api's

Packets:
void OutputRegisterPacketSubModule(const char *parent_name, char *name, char *conf_name,
    OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *),
    PacketLogger LogFunc, PacketLogCondition ConditionFunc);

Files:
void OutputRegisterFileSubModule(const char *parent_name, char *name, char *conf_name,
    OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FileLogger FileLogFunc);

Filedata:
void OutputRegisterFiledataSubModule(const char *parent_name, char *name, char *conf_name,
    OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FiledataLogger FiledataLogFunc);
pull/805/head
Victor Julien 11 years ago
parent f830cb8026
commit 79771ff570

@ -108,6 +108,49 @@ error:
exit(EXIT_FAILURE);
}
/**
* \brief Register a packet output sub-module.
*
* This function will register an output module so it can be
* configured with the configuration file.
*
* \retval Returns 0 on success, -1 on failure.
*/
void
OutputRegisterPacketSubModule(const char *parent_name, char *name, char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx),
PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc)
{
if (unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) {
goto error;
}
OutputModule *module = SCCalloc(1, sizeof(*module));
if (unlikely(module == NULL)) {
goto error;
}
module->name = SCStrdup(name);
if (unlikely(module->name == NULL))
goto error;
module->conf_name = SCStrdup(conf_name);
if (unlikely(module->conf_name == NULL))
goto error;
module->parent_name = SCStrdup(parent_name);
if (unlikely(module->conf_name == NULL))
goto error;
module->InitSubFunc = InitFunc;
module->PacketLogFunc = PacketLogFunc;
module->PacketConditionFunc = PacketConditionFunc;
TAILQ_INSERT_TAIL(&output_modules, module, entries);
SCLogDebug("Packet logger \"%s\" registered.", name);
return;
error:
SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
exit(EXIT_FAILURE);
}
/**
* \brief Register a tx output module.
*
@ -221,6 +264,47 @@ error:
exit(EXIT_FAILURE);
}
/**
* \brief Register a file output sub-module.
*
* This function will register an output module so it can be
* configured with the configuration file.
*
* \retval Returns 0 on success, -1 on failure.
*/
void
OutputRegisterFileSubModule(const char *parent_name, char *name, char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FileLogger FileLogFunc)
{
if (unlikely(FileLogFunc == NULL)) {
goto error;
}
OutputModule *module = SCCalloc(1, sizeof(*module));
if (unlikely(module == NULL)) {
goto error;
}
module->name = SCStrdup(name);
if (unlikely(module->name == NULL))
goto error;
module->conf_name = SCStrdup(conf_name);
if (unlikely(module->conf_name == NULL))
goto error;
module->parent_name = SCStrdup(parent_name);
if (unlikely(module->parent_name == NULL))
goto error;
module->InitSubFunc = InitFunc;
module->FileLogFunc = FileLogFunc;
TAILQ_INSERT_TAIL(&output_modules, module, entries);
SCLogDebug("File logger \"%s\" registered.", name);
return;
error:
SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
exit(EXIT_FAILURE);
}
/**
* \brief Register a file data output module.
*
@ -259,6 +343,47 @@ error:
exit(EXIT_FAILURE);
}
/**
* \brief Register a file data output sub-module.
*
* This function will register an output module so it can be
* configured with the configuration file.
*
* \retval Returns 0 on success, -1 on failure.
*/
void
OutputRegisterFiledataSubModule(const char *parent_name, char *name, char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FiledataLogger FiledataLogFunc)
{
if (unlikely(FiledataLogFunc == NULL)) {
goto error;
}
OutputModule *module = SCCalloc(1, sizeof(*module));
if (unlikely(module == NULL)) {
goto error;
}
module->name = SCStrdup(name);
if (unlikely(module->name == NULL))
goto error;
module->conf_name = SCStrdup(conf_name);
if (unlikely(module->conf_name == NULL))
goto error;
module->parent_name = SCStrdup(parent_name);
if (unlikely(module->parent_name == NULL))
goto error;
module->InitSubFunc = InitFunc;
module->FiledataLogFunc = FiledataLogFunc;
TAILQ_INSERT_TAIL(&output_modules, module, entries);
SCLogDebug("Filedata logger \"%s\" registered.", name);
return;
error:
SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
exit(EXIT_FAILURE);
}
/**
* \brief Get an output module by name.
*

@ -57,16 +57,26 @@ void OutputRegisterModule(char *, char *, OutputCtx *(*)(ConfNode *));
void OutputRegisterPacketModule(char *name, char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *),
PacketLogger LogFunc, PacketLogCondition ConditionFunc);
void OutputRegisterPacketSubModule(const char *parent_name, char *name, char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *),
PacketLogger LogFunc, PacketLogCondition ConditionFunc);
void OutputRegisterTxModule(char *name, char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *), uint16_t alproto,
TxLogger TxLogFunc);
void OutputRegisterTxSubModule(const char *parent_name, char *name, char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx), uint16_t alproto,
TxLogger TxLogFunc);
void OutputRegisterFileModule(char *name, char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *), FileLogger FileLogFunc);
void OutputRegisterFileSubModule(const char *parent_name, char *name, char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FileLogger FileLogFunc);
void OutputRegisterFiledataModule(char *name, char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *), FiledataLogger FiledataLogFunc);
void OutputRegisterFiledataSubModule(const char *parent_name, char *name, char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FiledataLogger FiledataLogFunc);
OutputModule *OutputGetModuleByConfName(char *name);
void OutputDeregisterAll(void);

Loading…
Cancel
Save