@ -410,76 +410,15 @@ void RunModeShutDown(void)
}
}
}
}
/**
static TmModule * pkt_logger_module = NULL ;
* Initialize the output modules .
static TmModule * tx_logger_module = NULL ;
*/
static TmModule * file_logger_module = NULL ;
void RunModeInitializeOutputs ( void )
static TmModule * filedata_logger_module = NULL ;
{
ConfNode * outputs = ConfGetNode ( " outputs " ) ;
if ( outputs = = NULL ) {
/* No "outputs" section in the configuration. */
return ;
}
ConfNode * output , * output_config ;
TmModule * tm_module ;
TmModule * pkt_logger_module = NULL ;
TmModule * tx_logger_module = NULL ;
TmModule * file_logger_module = NULL ;
TmModule * filedata_logger_module = NULL ;
const char * enabled ;
TAILQ_FOREACH ( output , & outputs - > head , next ) {
if ( strcmp ( output - > val , " stats " ) = = 0 )
continue ;
output_config = ConfNodeLookupChild ( output , output - > val ) ;
if ( output_config = = NULL ) {
/* Shouldn't happen. */
SCLogError ( SC_ERR_INVALID_ARGUMENT ,
" Failed to lookup configuration child node: fast " ) ;
exit ( 1 ) ;
}
enabled = ConfNodeLookupChildValue ( output_config , " enabled " ) ;
if ( enabled = = NULL | | ! ConfValIsTrue ( enabled ) ) {
continue ;
}
if ( strncmp ( output - > val , " unified- " , sizeof ( " unified- " ) - 1 ) = = 0 ) {
SCLogWarning ( SC_ERR_INVALID_ARGUMENT ,
" Unified1 is no longer supported, "
" use Unified2 instead "
" (see https://redmine.openinfosecfoundation.org/issues/353 "
" for an explanation) " ) ;
continue ;
} else if ( strcmp ( output - > val , " alert-prelude " ) = = 0 ) {
# ifndef PRELUDE
SCLogWarning ( SC_ERR_INVALID_ARGUMENT ,
" Prelude support not compiled in. Reconfigure/ "
" recompile with --enable-prelude to add Prelude "
" support. " ) ;
continue ;
# endif
}
OutputModule * module = OutputGetModuleByConfName ( output - > val ) ;
/** \brief Turn output into thread module */
if ( module = = NULL ) {
static void SetupOutput ( const char * name , OutputModule * module , OutputCtx * output_ctx )
SCLogWarning ( SC_ERR_INVALID_ARGUMENT ,
{
" No output module named %s, ignoring " , output - > val ) ;
TmModule * tm_module = TmModuleGetByName ( module - > name ) ;
continue ;
}
OutputCtx * output_ctx = NULL ;
if ( module - > InitFunc ! = NULL ) {
output_ctx = module - > InitFunc ( output_config ) ;
if ( output_ctx = = NULL ) {
/* In most cases the init function will have logged the
* error . Maybe we should exit on init errors ? */
continue ;
}
}
tm_module = TmModuleGetByName ( module - > name ) ;
if ( tm_module = = NULL ) {
if ( tm_module = = NULL ) {
SCLogError ( SC_ERR_INVALID_ARGUMENT ,
SCLogError ( SC_ERR_INVALID_ARGUMENT ,
" TmModuleGetByName for %s failed " , module - > name ) ;
" TmModuleGetByName for %s failed " , module - > name ) ;
@ -585,6 +524,119 @@ void RunModeInitializeOutputs(void)
TAILQ_INSERT_TAIL ( & RunModeOutputs , runmode_output , entries ) ;
TAILQ_INSERT_TAIL ( & RunModeOutputs , runmode_output , entries ) ;
}
}
}
}
/**
* Initialize the output modules .
*/
void RunModeInitializeOutputs ( void )
{
ConfNode * outputs = ConfGetNode ( " outputs " ) ;
if ( outputs = = NULL ) {
/* No "outputs" section in the configuration. */
return ;
}
ConfNode * output , * output_config ;
const char * enabled ;
TAILQ_FOREACH ( output , & outputs - > head , next ) {
if ( strcmp ( output - > val , " stats " ) = = 0 )
continue ;
output_config = ConfNodeLookupChild ( output , output - > val ) ;
if ( output_config = = NULL ) {
/* Shouldn't happen. */
SCLogError ( SC_ERR_INVALID_ARGUMENT ,
" Failed to lookup configuration child node: fast " ) ;
exit ( 1 ) ;
}
enabled = ConfNodeLookupChildValue ( output_config , " enabled " ) ;
if ( enabled = = NULL | | ! ConfValIsTrue ( enabled ) ) {
continue ;
}
if ( strncmp ( output - > val , " unified- " , sizeof ( " unified- " ) - 1 ) = = 0 ) {
SCLogWarning ( SC_ERR_INVALID_ARGUMENT ,
" Unified1 is no longer supported, "
" use Unified2 instead "
" (see https://redmine.openinfosecfoundation.org/issues/353 "
" for an explanation) " ) ;
continue ;
} else if ( strcmp ( output - > val , " alert-prelude " ) = = 0 ) {
# ifndef PRELUDE
SCLogWarning ( SC_ERR_INVALID_ARGUMENT ,
" Prelude support not compiled in. Reconfigure/ "
" recompile with --enable-prelude to add Prelude "
" support. " ) ;
continue ;
# endif
}
OutputModule * module = OutputGetModuleByConfName ( output - > val ) ;
if ( module = = NULL ) {
SCLogWarning ( SC_ERR_INVALID_ARGUMENT ,
" No output module named %s, ignoring " , output - > val ) ;
continue ;
}
OutputCtx * output_ctx = NULL ;
if ( module - > InitFunc ! = NULL ) {
output_ctx = module - > InitFunc ( output_config ) ;
if ( output_ctx = = NULL ) {
/* In most cases the init function will have logged the
* error . Maybe we should exit on init errors ? */
continue ;
}
} else if ( module - > InitSubFunc ! = NULL ) {
SCLogInfo ( " skipping submodule " ) ;
continue ;
}
// TODO if module == parent, find it's children
if ( strcmp ( output - > val , " eve-log " ) = = 0 ) {
ConfNode * types = ConfNodeLookupChild ( output_config , " types " ) ;
SCLogInfo ( " types %p " , types ) ;
if ( types ! = NULL ) {
ConfNode * type = NULL ;
TAILQ_FOREACH ( type , & types - > head , next ) {
SCLogInfo ( " type %s " , type - > val ) ;
OutputModule * sub_module = OutputGetModuleByConfName ( type - > val ) ;
if ( sub_module = = NULL ) {
SCLogWarning ( SC_ERR_INVALID_ARGUMENT ,
" No output module named %s, ignoring " , type - > val ) ;
continue ;
}
if ( sub_module - > parent_name = = NULL | |
strcmp ( sub_module - > parent_name , output - > val ) ! = 0 ) {
SCLogWarning ( SC_ERR_INVALID_ARGUMENT ,
" bad parent for %s, ignoring " , type - > val ) ;
continue ;
}
if ( sub_module - > InitSubFunc = = NULL ) {
SCLogWarning ( SC_ERR_INVALID_ARGUMENT ,
" bad sub-module for %s, ignoring " , type - > val ) ;
continue ;
}
ConfNode * sub_output_config = ConfNodeLookupChild ( type , type - > val ) ;
// sub_output_config may be NULL if no config
/* pass on parent output_ctx */
OutputCtx * sub_output_ctx =
sub_module - > InitSubFunc ( sub_output_config , output_ctx ) ;
if ( sub_output_ctx = = NULL ) {
continue ;
}
SetupOutput ( sub_module - > name , sub_module , sub_output_ctx ) ;
}
}
} else {
SetupOutput ( module - > name , module , output_ctx ) ;
}
}
}
}
/**
/**