suricata: separate keyword and app layer listing code

The list-keyword and app-layer listing code was spread over all the
init code. This patch introduces a separate file to store non standard
running mode like these ones.
pull/467/head
Eric Leblond 12 years ago
parent 135ef0186b
commit bed48e3a54

@ -318,6 +318,7 @@ util-ringbuffer.c util-ringbuffer.h \
util-rohash.c util-rohash.h \
util-rule-vars.c util-rule-vars.h \
util-runmodes.c util-runmodes.h \
util-running-modes.c util-running-modes.h \
util-signal.c util-signal.h \
util-spm-bm.c util-spm-bm.h \
util-spm-bs2bm.c util-spm-bs2bm.h \

@ -58,6 +58,7 @@
#include "util-ioctl.h"
#include "util-device.h"
#include "util-misc.h"
#include "util-running-modes.h"
#include "detect-parse.h"
#include "detect-engine.h"
@ -1317,20 +1318,25 @@ int main(int argc, char **argv)
}
}
if (!list_keywords && !list_app_layer_protocols) {
if (list_keywords) {
return SuriListKeywords(keyword_info);
}
if (list_app_layer_protocols) {
return SuriListAppLayerProtocols();
}
#ifdef REVISION
SCLogInfo("This is %s version %s (rev %s)", PROG_NAME, PROG_VER, xstr(REVISION));
SCLogInfo("This is %s version %s (rev %s)", PROG_NAME, PROG_VER, xstr(REVISION));
#elif defined RELEASE
SCLogInfo("This is %s version %s RELEASE", PROG_NAME, PROG_VER);
SCLogInfo("This is %s version %s RELEASE", PROG_NAME, PROG_VER);
#else
SCLogInfo("This is %s version %s", PROG_NAME, PROG_VER);
SCLogInfo("This is %s version %s", PROG_NAME, PROG_VER);
#endif
}
SetBpfString(optind, argv);
if (!list_keywords && !list_app_layer_protocols)
UtilCpuPrintSummary();
UtilCpuPrintSummary();
#ifdef __SC_CUDA_SUPPORT__
/* Init the CUDA environment */
@ -1351,9 +1357,7 @@ int main(int argc, char **argv)
TimeInit();
SupportFastPatternForSigMatchTypes();
if (run_mode != RUNMODE_UNITTEST &&
!list_keywords &&
!list_app_layer_protocols) {
if (run_mode != RUNMODE_UNITTEST) {
if (conf_filename == NULL)
conf_filename = DEFAULT_CONF_FILE;
}
@ -1405,10 +1409,6 @@ int main(int argc, char **argv)
#endif
AppLayerDetectProtoThreadInit();
if (list_app_layer_protocols) {
AppLayerListSupportedProtocols();
exit(EXIT_SUCCESS);
}
AppLayerParsersInitPostProcess();
if (dump_config) {
@ -1429,17 +1429,15 @@ int main(int argc, char **argv)
#endif /* OS_WIN32 */
}
if (!list_keywords && !list_app_layer_protocols) {
#ifdef OS_WIN32
if (_stat(log_dir, &buf) != 0) {
if (_stat(log_dir, &buf) != 0) {
#else
if (stat(log_dir, &buf) != 0) {
if (stat(log_dir, &buf) != 0) {
#endif /* OS_WIN32 */
SCLogError(SC_ERR_LOGDIR_CONFIG, "The logging directory \"%s\" "
"supplied by %s (default-log-dir) doesn't exist. "
"Shutting down the engine", log_dir, conf_filename);
exit(EXIT_FAILURE);
}
SCLogError(SC_ERR_LOGDIR_CONFIG, "The logging directory \"%s\" "
"supplied by %s (default-log-dir) doesn't exist. "
"Shutting down the engine", log_dir, conf_filename);
exit(EXIT_FAILURE);
}
/* Pull the max pending packets from the config, if not found fall
@ -1493,13 +1491,12 @@ int main(int argc, char **argv)
/* Load the Host-OS lookup. */
SCHInfoLoadFromConfig();
if (!list_keywords && !list_app_layer_protocols &&
(run_mode != RUNMODE_UNIX_SOCKET)) {
if (run_mode != RUNMODE_UNIX_SOCKET) {
DefragInit();
}
if (run_mode == RUNMODE_UNKNOWN) {
if (!engine_analysis && !list_keywords && !conf_test) {
if (!engine_analysis && !conf_test) {
usage(argv[0]);
exit(EXIT_FAILURE);
}
@ -1529,10 +1526,6 @@ int main(int argc, char **argv)
/* hardcoded initialization code */
SigTableSetup(); /* load the rule keywords */
if (list_keywords) {
SigTableList(keyword_info);
exit(EXIT_FAILURE);
}
TmqhSetup();
StorageInit();

@ -0,0 +1,39 @@
/* Copyright (C) 2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/** \file
*
* \author Eric Leblond <eric@regit.org>
*/
#include "suricata-common.h"
#include "app-layer-detect-proto.h"
int SuriListKeywords(const char *keyword_info)
{
SigTableSetup(); /* load the rule keywords */
SigTableList(keyword_info);
exit(EXIT_SUCCESS);
}
int SuriListAppLayerProtocols()
{
MpmTableSetup();
AppLayerDetectProtoThreadInit();
AppLayerListSupportedProtocols();
exit(EXIT_SUCCESS);
}

@ -0,0 +1,31 @@
/* Copyright (C) 2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/** \file
*
* \author Eric Leblond <eric@regit.org>
*/
#ifndef __UTIL_RUNNING_MODES_H__
#define __UTIL_RUNNING_MODES_H__
int SuriListKeywords(const char *keyword_info);
int SuriListAppLayerProtocols();
#endif /* __UTIL_RUNNING_MODES_H__ */
Loading…
Cancel
Save