static void start_file_processing(void) { if (!file_processing_initiated) { file_resume_block_init(); RegisterPreprocStats("file", print_file_stats); file_processing_initiated = true; } }
/** ** This function initializes HttpInspect with a user configuration. ** ** The function is called when HttpInspect is configured in ** snort.conf. It gets passed a string of arguments, which gets ** parsed into configuration constructs that HttpInspect understands. ** ** This function gets called for every HttpInspect configure line. We ** use this characteristic to split up the configuration, so each line ** is a configuration construct. We need to keep track of what part ** of the configuration has been configured, so we don't configure one ** part, then configure it again. ** ** Any upfront memory is allocated here (if necessary). ** ** @param args a string to the preprocessor arguments. ** ** @return void */ static void HttpInspectInit(char *args) { char ErrorString[ERRSTRLEN]; int iErrStrLen = ERRSTRLEN; int iRet; static int siFirstConfig = 1; int iGlobal = 0; if(siFirstConfig) { memset(&hi_stats, 0, sizeof(HIStats)); iRet = hi_ui_config_init_global_conf(&GlobalConf); if (iRet) { snprintf(ErrorString, iErrStrLen, "Error initializing Global Configuration."); FatalError("%s(%d) => %s\n", file_name, file_line, ErrorString); return; } iRet = hi_ui_config_default(&GlobalConf); if (iRet) { snprintf(ErrorString, iErrStrLen, "Error configuring default global configuration."); FatalError("%s(%d) => %s\n", file_name, file_line, ErrorString); return; } iRet = hi_client_init(&GlobalConf); if (iRet) { snprintf(ErrorString, iErrStrLen, "Error initializing client module."); FatalError("%s(%d) => %s\n", file_name, file_line, ErrorString); return; } iRet = hi_norm_init(&GlobalConf); if (iRet) { snprintf(ErrorString, iErrStrLen, "Error initializing normalization module."); FatalError("%s(%d) => %s\n", file_name, file_line, ErrorString); return; } /* ** We set the global configuration variable */ iGlobal = 1; } iRet = HttpInspectSnortConf(&GlobalConf, args, iGlobal, ErrorString, iErrStrLen); if (iRet) { if(iRet > 0) { /* ** Non-fatal Error */ if(ErrorString) { ErrorMessage("%s(%d) => %s\n", file_name, file_line, ErrorString); } } else { /* ** Fatal Error, log error and exit. */ if(ErrorString) { FatalError("%s(%d) => %s\n", file_name, file_line, ErrorString); } else { /* ** Check if ErrorString is undefined. */ if(iRet == -2) { FatalError("%s(%d) => ErrorString is undefined.\n", file_name, file_line); } else { FatalError("%s(%d) => Undefined Error.\n", file_name, file_line); } } } } /* ** Only add the functions one time to the preproc list. */ if(siFirstConfig) { /* ** Add HttpInspect into the preprocessor list */ AddFuncToPreprocList(HttpInspect, PRIORITY_APPLICATION, PP_HTTPINSPECT); RegisterPreprocStats("http_inspect", HttpInspectDropStats); /* ** Remember to add any cleanup functions into the appropriate ** lists. */ AddFuncToPreprocCleanExitList(HttpInspectCleanExit, NULL, PRIORITY_APPLICATION, PP_HTTPINSPECT); AddFuncToPreprocRestartList(HttpInspectCleanExit, NULL, PRIORITY_APPLICATION, PP_HTTPINSPECT); siFirstConfig = 0; #ifdef PERF_PROFILING RegisterPreprocessorProfile("httpinspect", &hiPerfStats, 0, &totalPerfStats); #endif } return; }