|
|
|
@ -881,7 +881,7 @@ static TmEcode ParseInterfacesList(int run_mode, char *pcap_dev)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct SuriInstance {
|
|
|
|
struct SuriInstance {
|
|
|
|
int running_mode;
|
|
|
|
int run_mode;
|
|
|
|
|
|
|
|
|
|
|
|
char pcap_dev[128];
|
|
|
|
char pcap_dev[128];
|
|
|
|
char *sig_file;
|
|
|
|
char *sig_file;
|
|
|
|
@ -907,7 +907,7 @@ struct SuriInstance {
|
|
|
|
|
|
|
|
|
|
|
|
static void SuriInstanceInit(struct SuriInstance *suri)
|
|
|
|
static void SuriInstanceInit(struct SuriInstance *suri)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
suri->running_mode = 0;
|
|
|
|
suri->run_mode = RUNMODE_UNKNOWN;
|
|
|
|
|
|
|
|
|
|
|
|
memset(suri->pcap_dev, 0, sizeof(suri->pcap_dev));
|
|
|
|
memset(suri->pcap_dev, 0, sizeof(suri->pcap_dev));
|
|
|
|
suri->sig_file = NULL;
|
|
|
|
suri->sig_file = NULL;
|
|
|
|
@ -1012,7 +1012,7 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
if (strcmp((long_opts[option_index]).name , "pfring") == 0 ||
|
|
|
|
if (strcmp((long_opts[option_index]).name , "pfring") == 0 ||
|
|
|
|
strcmp((long_opts[option_index]).name , "pfring-int") == 0) {
|
|
|
|
strcmp((long_opts[option_index]).name , "pfring-int") == 0) {
|
|
|
|
#ifdef HAVE_PFRING
|
|
|
|
#ifdef HAVE_PFRING
|
|
|
|
run_mode = RUNMODE_PFRING;
|
|
|
|
suri->run_mode = RUNMODE_PFRING;
|
|
|
|
if (optarg != NULL) {
|
|
|
|
if (optarg != NULL) {
|
|
|
|
memset(pcap_dev, 0, sizeof(pcap_dev));
|
|
|
|
memset(pcap_dev, 0, sizeof(pcap_dev));
|
|
|
|
strlcpy(pcap_dev, optarg,
|
|
|
|
strlcpy(pcap_dev, optarg,
|
|
|
|
@ -1052,8 +1052,8 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp((long_opts[option_index]).name , "af-packet") == 0){
|
|
|
|
else if (strcmp((long_opts[option_index]).name , "af-packet") == 0){
|
|
|
|
#ifdef HAVE_AF_PACKET
|
|
|
|
#ifdef HAVE_AF_PACKET
|
|
|
|
if (run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
if (suri->run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
run_mode = RUNMODE_AFP_DEV;
|
|
|
|
suri->run_mode = RUNMODE_AFP_DEV;
|
|
|
|
if (optarg) {
|
|
|
|
if (optarg) {
|
|
|
|
LiveRegisterDevice(optarg);
|
|
|
|
LiveRegisterDevice(optarg);
|
|
|
|
memset(suri->pcap_dev, 0, sizeof(suri->pcap_dev));
|
|
|
|
memset(suri->pcap_dev, 0, sizeof(suri->pcap_dev));
|
|
|
|
@ -1061,7 +1061,7 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
((strlen(optarg) < sizeof(suri->pcap_dev)) ?
|
|
|
|
((strlen(optarg) < sizeof(suri->pcap_dev)) ?
|
|
|
|
(strlen(optarg) + 1) : sizeof(suri->pcap_dev)));
|
|
|
|
(strlen(optarg) + 1) : sizeof(suri->pcap_dev)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (run_mode == RUNMODE_AFP_DEV) {
|
|
|
|
} else if (suri->run_mode == RUNMODE_AFP_DEV) {
|
|
|
|
SCLogWarning(SC_WARN_PCAP_MULTI_DEV_EXPERIMENTAL, "using "
|
|
|
|
SCLogWarning(SC_WARN_PCAP_MULTI_DEV_EXPERIMENTAL, "using "
|
|
|
|
"multiple devices to get packets is experimental.");
|
|
|
|
"multiple devices to get packets is experimental.");
|
|
|
|
if (optarg) {
|
|
|
|
if (optarg) {
|
|
|
|
@ -1083,8 +1083,8 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
} else if (strcmp((long_opts[option_index]).name , "pcap") == 0) {
|
|
|
|
} else if (strcmp((long_opts[option_index]).name , "pcap") == 0) {
|
|
|
|
if (run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
if (suri->run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
run_mode = RUNMODE_PCAP_DEV;
|
|
|
|
suri->run_mode = RUNMODE_PCAP_DEV;
|
|
|
|
if (optarg) {
|
|
|
|
if (optarg) {
|
|
|
|
LiveRegisterDevice(optarg);
|
|
|
|
LiveRegisterDevice(optarg);
|
|
|
|
memset(suri->pcap_dev, 0, sizeof(suri->pcap_dev));
|
|
|
|
memset(suri->pcap_dev, 0, sizeof(suri->pcap_dev));
|
|
|
|
@ -1092,7 +1092,7 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
((strlen(optarg) < sizeof(suri->pcap_dev)) ?
|
|
|
|
((strlen(optarg) < sizeof(suri->pcap_dev)) ?
|
|
|
|
(strlen(optarg) + 1) : sizeof(suri->pcap_dev)));
|
|
|
|
(strlen(optarg) + 1) : sizeof(suri->pcap_dev)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (run_mode == RUNMODE_PCAP_DEV) {
|
|
|
|
} else if (suri->run_mode == RUNMODE_PCAP_DEV) {
|
|
|
|
#ifdef OS_WIN32
|
|
|
|
#ifdef OS_WIN32
|
|
|
|
SCLogError(SC_ERR_PCAP_MULTI_DEV_NO_SUPPORT, "pcap multi dev "
|
|
|
|
SCLogError(SC_ERR_PCAP_MULTI_DEV_NO_SUPPORT, "pcap multi dev "
|
|
|
|
"support is not (yet) supported on Windows.");
|
|
|
|
"support is not (yet) supported on Windows.");
|
|
|
|
@ -1115,8 +1115,8 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef BUILD_UNIX_SOCKET
|
|
|
|
#ifdef BUILD_UNIX_SOCKET
|
|
|
|
} else if (strcmp((long_opts[option_index]).name , "unix-socket") == 0) {
|
|
|
|
} else if (strcmp((long_opts[option_index]).name , "unix-socket") == 0) {
|
|
|
|
if (run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
if (suri->run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
run_mode = RUNMODE_UNIX_SOCKET;
|
|
|
|
suri->run_mode = RUNMODE_UNIX_SOCKET;
|
|
|
|
if (optarg) {
|
|
|
|
if (optarg) {
|
|
|
|
if (ConfSet("unix-command.filename", optarg, 0) != 1) {
|
|
|
|
if (ConfSet("unix-command.filename", optarg, 0) != 1) {
|
|
|
|
fprintf(stderr, "ERROR: Failed to set unix-command.filename.\n");
|
|
|
|
fprintf(stderr, "ERROR: Failed to set unix-command.filename.\n");
|
|
|
|
@ -1137,8 +1137,7 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(strcmp((long_opts[option_index]).name, "list-unittests") == 0) {
|
|
|
|
else if(strcmp((long_opts[option_index]).name, "list-unittests") == 0) {
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
/* Set run_mode to unit tests. */
|
|
|
|
suri->run_mode = RUNMODE_LIST_UNITTEST;
|
|
|
|
run_mode = RUNMODE_UNITTEST;
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
fprintf(stderr, "ERROR: Unit tests not enabled. Make sure to pass --enable-unittests to configure when building.\n");
|
|
|
|
fprintf(stderr, "ERROR: Unit tests not enabled. Make sure to pass --enable-unittests to configure when building.\n");
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
@ -1150,7 +1149,7 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
#endif /* UNITTESTS */
|
|
|
|
#endif /* UNITTESTS */
|
|
|
|
} else if (strcmp((long_opts[option_index]).name, "list-runmodes") == 0) {
|
|
|
|
} else if (strcmp((long_opts[option_index]).name, "list-runmodes") == 0) {
|
|
|
|
suri->running_mode = RUNMODE_LIST_RUNMODES;
|
|
|
|
suri->run_mode = RUNMODE_LIST_RUNMODES;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
} else if (strcmp((long_opts[option_index]).name, "list-keywords") == 0) {
|
|
|
|
} else if (strcmp((long_opts[option_index]).name, "list-keywords") == 0) {
|
|
|
|
if (optarg) {
|
|
|
|
if (optarg) {
|
|
|
|
@ -1165,15 +1164,15 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef OS_WIN32
|
|
|
|
#ifdef OS_WIN32
|
|
|
|
else if(strcmp((long_opts[option_index]).name, "service-install") == 0) {
|
|
|
|
else if(strcmp((long_opts[option_index]).name, "service-install") == 0) {
|
|
|
|
suri->running_mode = RUNMODE_INSTALL_SERVICE;
|
|
|
|
suri->run_mode = RUNMODE_INSTALL_SERVICE;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(strcmp((long_opts[option_index]).name, "service-remove") == 0) {
|
|
|
|
else if(strcmp((long_opts[option_index]).name, "service-remove") == 0) {
|
|
|
|
suri->running_mode = RUNMODE_REMOVE_SERVICE;
|
|
|
|
suri->run_mode = RUNMODE_REMOVE_SERVICE;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(strcmp((long_opts[option_index]).name, "service-change-params") == 0) {
|
|
|
|
else if(strcmp((long_opts[option_index]).name, "service-change-params") == 0) {
|
|
|
|
suri->running_mode = RUNMODE_CHANGE_SERVICE_PARAMS;
|
|
|
|
suri->run_mode = RUNMODE_CHANGE_SERVICE_PARAMS;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* OS_WIN32 */
|
|
|
|
#endif /* OS_WIN32 */
|
|
|
|
@ -1212,7 +1211,7 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
#endif /* HAVE_LIBCAP_NG */
|
|
|
|
#endif /* HAVE_LIBCAP_NG */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp((long_opts[option_index]).name, "erf-in") == 0) {
|
|
|
|
else if (strcmp((long_opts[option_index]).name, "erf-in") == 0) {
|
|
|
|
run_mode = RUNMODE_ERF_FILE;
|
|
|
|
suri->run_mode = RUNMODE_ERF_FILE;
|
|
|
|
if (ConfSet("erf-file.file", optarg, 0) != 1) {
|
|
|
|
if (ConfSet("erf-file.file", optarg, 0) != 1) {
|
|
|
|
fprintf(stderr, "ERROR: Failed to set erf-file.file\n");
|
|
|
|
fprintf(stderr, "ERROR: Failed to set erf-file.file\n");
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
@ -1220,10 +1219,10 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp((long_opts[option_index]).name, "dag") == 0) {
|
|
|
|
else if (strcmp((long_opts[option_index]).name, "dag") == 0) {
|
|
|
|
#ifdef HAVE_DAG
|
|
|
|
#ifdef HAVE_DAG
|
|
|
|
if (run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
if (suri->run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
run_mode = RUNMODE_DAG;
|
|
|
|
suri->run_mode = RUNMODE_DAG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (run_mode != RUNMODE_DAG) {
|
|
|
|
else if (suri->run_mode != RUNMODE_DAG) {
|
|
|
|
SCLogError(SC_ERR_MULTIPLE_RUN_MODE,
|
|
|
|
SCLogError(SC_ERR_MULTIPLE_RUN_MODE,
|
|
|
|
"more than one run mode has been specified");
|
|
|
|
"more than one run mode has been specified");
|
|
|
|
usage(argv[0]);
|
|
|
|
usage(argv[0]);
|
|
|
|
@ -1238,7 +1237,7 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp((long_opts[option_index]).name, "napatech") == 0) {
|
|
|
|
else if (strcmp((long_opts[option_index]).name, "napatech") == 0) {
|
|
|
|
#ifdef HAVE_NAPATECH
|
|
|
|
#ifdef HAVE_NAPATECH
|
|
|
|
run_mode = RUNMODE_NAPATECH;
|
|
|
|
suri->run_mode = RUNMODE_NAPATECH;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
SCLogError(SC_ERR_NAPATECH_REQUIRED, "libntapi and a Napatech adapter are required"
|
|
|
|
SCLogError(SC_ERR_NAPATECH_REQUIRED, "libntapi and a Napatech adapter are required"
|
|
|
|
" to capture packets using --napatech.");
|
|
|
|
" to capture packets using --napatech.");
|
|
|
|
@ -1257,7 +1256,7 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
#endif /* HAVE_PCAP_SET_BUFF */
|
|
|
|
#endif /* HAVE_PCAP_SET_BUFF */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(strcmp((long_opts[option_index]).name, "build-info") == 0) {
|
|
|
|
else if(strcmp((long_opts[option_index]).name, "build-info") == 0) {
|
|
|
|
suri->running_mode = RUNMODE_PRINT_BUILDINFO;
|
|
|
|
suri->run_mode = RUNMODE_PRINT_BUILDINFO;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef HAVE_MPIPE
|
|
|
|
#ifdef HAVE_MPIPE
|
|
|
|
@ -1297,7 +1296,7 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
#endif /* OS_WIN32 */
|
|
|
|
#endif /* OS_WIN32 */
|
|
|
|
case 'h':
|
|
|
|
case 'h':
|
|
|
|
suri->running_mode = RUNMODE_PRINT_USAGE;
|
|
|
|
suri->run_mode = RUNMODE_PRINT_USAGE;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
case 'i':
|
|
|
|
case 'i':
|
|
|
|
memset(suri->pcap_dev, 0, sizeof(suri->pcap_dev));
|
|
|
|
memset(suri->pcap_dev, 0, sizeof(suri->pcap_dev));
|
|
|
|
@ -1318,10 +1317,10 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
if (suri->run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
run_mode = RUNMODE_PCAP_DEV;
|
|
|
|
suri->run_mode = RUNMODE_PCAP_DEV;
|
|
|
|
LiveRegisterDevice(suri->pcap_dev);
|
|
|
|
LiveRegisterDevice(suri->pcap_dev);
|
|
|
|
} else if (run_mode == RUNMODE_PCAP_DEV) {
|
|
|
|
} else if (suri->run_mode == RUNMODE_PCAP_DEV) {
|
|
|
|
#ifdef OS_WIN32
|
|
|
|
#ifdef OS_WIN32
|
|
|
|
SCLogError(SC_ERR_PCAP_MULTI_DEV_NO_SUPPORT, "pcap multi dev "
|
|
|
|
SCLogError(SC_ERR_PCAP_MULTI_DEV_NO_SUPPORT, "pcap multi dev "
|
|
|
|
"support is not (yet) supported on Windows.");
|
|
|
|
"support is not (yet) supported on Windows.");
|
|
|
|
@ -1352,12 +1351,12 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'q':
|
|
|
|
case 'q':
|
|
|
|
#ifdef NFQ
|
|
|
|
#ifdef NFQ
|
|
|
|
if (run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
if (suri->run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
run_mode = RUNMODE_NFQ;
|
|
|
|
suri->run_mode = RUNMODE_NFQ;
|
|
|
|
SET_ENGINE_MODE_IPS(engine_mode);
|
|
|
|
SET_ENGINE_MODE_IPS(engine_mode);
|
|
|
|
if (NFQRegisterQueue(optarg) == -1)
|
|
|
|
if (NFQRegisterQueue(optarg) == -1)
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
} else if (run_mode == RUNMODE_NFQ) {
|
|
|
|
} else if (suri->run_mode == RUNMODE_NFQ) {
|
|
|
|
if (NFQRegisterQueue(optarg) == -1)
|
|
|
|
if (NFQRegisterQueue(optarg) == -1)
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -1373,12 +1372,12 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
case 'd':
|
|
|
|
#ifdef IPFW
|
|
|
|
#ifdef IPFW
|
|
|
|
if (run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
if (suri->run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
run_mode = RUNMODE_IPFW;
|
|
|
|
suri->run_mode = RUNMODE_IPFW;
|
|
|
|
SET_ENGINE_MODE_IPS(engine_mode);
|
|
|
|
SET_ENGINE_MODE_IPS(engine_mode);
|
|
|
|
if (IPFWRegisterQueue(optarg) == -1)
|
|
|
|
if (IPFWRegisterQueue(optarg) == -1)
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
} else if (run_mode == RUNMODE_IPFW) {
|
|
|
|
} else if (suri->run_mode == RUNMODE_IPFW) {
|
|
|
|
if (IPFWRegisterQueue(optarg) == -1)
|
|
|
|
if (IPFWRegisterQueue(optarg) == -1)
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -1393,8 +1392,8 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
#endif /* IPFW */
|
|
|
|
#endif /* IPFW */
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
case 'r':
|
|
|
|
if (run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
if (suri->run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
run_mode = RUNMODE_PCAP_FILE;
|
|
|
|
suri->run_mode = RUNMODE_PCAP_FILE;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
|
|
|
|
SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
|
|
|
|
"has been specified");
|
|
|
|
"has been specified");
|
|
|
|
@ -1423,9 +1422,8 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
case 'u':
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
if (run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
if (suri->run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
run_mode = RUNMODE_UNITTEST;
|
|
|
|
suri->run_mode = RUNMODE_UNITTEST;
|
|
|
|
suri->running_mode = RUNMODE_UNITTEST;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode has"
|
|
|
|
SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode has"
|
|
|
|
" been specified");
|
|
|
|
" been specified");
|
|
|
|
@ -1446,7 +1444,7 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'V':
|
|
|
|
case 'V':
|
|
|
|
suri->running_mode = RUNMODE_PRINT_VERSION;
|
|
|
|
suri->run_mode = RUNMODE_PRINT_VERSION;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
case 'F':
|
|
|
|
case 'F':
|
|
|
|
SetBpfStringFromFile(optarg);
|
|
|
|
SetBpfStringFromFile(optarg);
|
|
|
|
@ -1458,17 +1456,17 @@ static TmEcode SuriParseCommandLine(int argc, char** argv, struct SuriInstance *
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (list_app_layer_protocols)
|
|
|
|
if (list_app_layer_protocols)
|
|
|
|
suri->running_mode = RUNMODE_LIST_APP_LAYERS;
|
|
|
|
suri->run_mode = RUNMODE_LIST_APP_LAYERS;
|
|
|
|
if (list_cuda_cards)
|
|
|
|
if (list_cuda_cards)
|
|
|
|
suri->running_mode = RUNMODE_LIST_CUDA_CARDS;
|
|
|
|
suri->run_mode = RUNMODE_LIST_CUDA_CARDS;
|
|
|
|
if (list_keywords)
|
|
|
|
if (list_keywords)
|
|
|
|
suri->running_mode = RUNMODE_LIST_KEYWORDS;
|
|
|
|
suri->run_mode = RUNMODE_LIST_KEYWORDS;
|
|
|
|
if (list_unittests)
|
|
|
|
if (list_unittests)
|
|
|
|
suri->running_mode = RUNMODE_LIST_UNITTEST;
|
|
|
|
suri->run_mode = RUNMODE_LIST_UNITTEST;
|
|
|
|
if (dump_config)
|
|
|
|
if (dump_config)
|
|
|
|
suri->running_mode = RUNMODE_DUMP_CONFIG;
|
|
|
|
suri->run_mode = RUNMODE_DUMP_CONFIG;
|
|
|
|
if (conf_test)
|
|
|
|
if (conf_test)
|
|
|
|
suri->running_mode = RUNMODE_CONF_TEST;
|
|
|
|
suri->run_mode = RUNMODE_CONF_TEST;
|
|
|
|
|
|
|
|
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1530,6 +1528,7 @@ int main(int argc, char **argv)
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Treat internal running mode */
|
|
|
|
switch(suri.running_mode) {
|
|
|
|
switch(suri.running_mode) {
|
|
|
|
case SC_RUN_LIST_KEYWORDS:
|
|
|
|
case SC_RUN_LIST_KEYWORDS:
|
|
|
|
return ListKeywords(suri.keyword_info);
|
|
|
|
return ListKeywords(suri.keyword_info);
|
|
|
|
@ -1580,6 +1579,12 @@ int main(int argc, char **argv)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set the global run mode */
|
|
|
|
|
|
|
|
run_mode = suri.run_mode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (suri.run_mode == RUNMODE_UNITTEST)
|
|
|
|
|
|
|
|
return SuriRunUnittests(0, suri.regex_arg);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef REVISION
|
|
|
|
#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
|
|
|
|
#elif defined RELEASE
|
|
|
|
@ -1598,7 +1603,7 @@ int main(int argc, char **argv)
|
|
|
|
CudaBufferInit();
|
|
|
|
CudaBufferInit();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (!CheckValidDaemonModes(suri.daemon, run_mode)) {
|
|
|
|
if (!CheckValidDaemonModes(suri.daemon, suri.run_mode)) {
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1627,7 +1632,7 @@ int main(int argc, char **argv)
|
|
|
|
AppLayerDetectProtoThreadInit();
|
|
|
|
AppLayerDetectProtoThreadInit();
|
|
|
|
AppLayerParsersInitPostProcess();
|
|
|
|
AppLayerParsersInitPostProcess();
|
|
|
|
|
|
|
|
|
|
|
|
if (suri.running_mode == RUNMODE_DUMP_CONFIG) {
|
|
|
|
if (suri.run_mode == RUNMODE_DUMP_CONFIG) {
|
|
|
|
ConfDump();
|
|
|
|
ConfDump();
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1660,7 +1665,7 @@ int main(int argc, char **argv)
|
|
|
|
* back on a sane default. */
|
|
|
|
* back on a sane default. */
|
|
|
|
char *temp_default_packet_size;
|
|
|
|
char *temp_default_packet_size;
|
|
|
|
if ((ConfGet("default-packet-size", &temp_default_packet_size)) != 1) {
|
|
|
|
if ((ConfGet("default-packet-size", &temp_default_packet_size)) != 1) {
|
|
|
|
switch (run_mode) {
|
|
|
|
switch (suri.run_mode) {
|
|
|
|
case RUNMODE_PCAP_DEV:
|
|
|
|
case RUNMODE_PCAP_DEV:
|
|
|
|
case RUNMODE_AFP_DEV:
|
|
|
|
case RUNMODE_AFP_DEV:
|
|
|
|
case RUNMODE_PFRING:
|
|
|
|
case RUNMODE_PFRING:
|
|
|
|
@ -1684,7 +1689,7 @@ int main(int argc, char **argv)
|
|
|
|
SCLogDebug("Default packet size set to %"PRIu32, default_packet_size);
|
|
|
|
SCLogDebug("Default packet size set to %"PRIu32, default_packet_size);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NFQ
|
|
|
|
#ifdef NFQ
|
|
|
|
if (run_mode == RUNMODE_NFQ)
|
|
|
|
if (suri.run_mode == RUNMODE_NFQ)
|
|
|
|
NFQInitConfig(FALSE);
|
|
|
|
NFQInitConfig(FALSE);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
@ -1699,7 +1704,7 @@ int main(int argc, char **argv)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
if (run_mode == RUNMODE_UNKNOWN) {
|
|
|
|
if (!engine_analysis && !(suri.running_mode == RUNMODE_CONF_TEST)) {
|
|
|
|
if (!engine_analysis && !(suri.run_mode == RUNMODE_CONF_TEST)) {
|
|
|
|
usage(argv[0]);
|
|
|
|
usage(argv[0]);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1940,7 +1945,7 @@ int main(int argc, char **argv)
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(suri.running_mode == RUNMODE_CONF_TEST){
|
|
|
|
if(suri.run_mode == RUNMODE_CONF_TEST){
|
|
|
|
SCLogInfo("Configuration provided was successfully loaded. Exiting.");
|
|
|
|
SCLogInfo("Configuration provided was successfully loaded. Exiting.");
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|