single runmode: add support for multiple capture threads

remotes/origin/master-1.1.x
Eric Leblond 14 years ago
parent c75fffe92d
commit 77869a2df8

@ -294,7 +294,9 @@ int RunModeIdsAFPSingle(DetectEngineCtx *de_ctx)
ConfGet("af-packet.live-interface", &live_dev);
ret = RunModeSetLiveCaptureSingle(de_ctx,
ParseAFPConfig, "ReceiveAFP",
ParseAFPConfig,
AFPConfigGeThreadsCount,
"ReceiveAFP",
"DecodeAFP", "AFPacket",
live_dev);
if (ret != 0) {

@ -153,7 +153,9 @@ int RunModeIdsPcapSingle(DetectEngineCtx *de_ctx)
ConfGet("pcap.single_pcap_dev", &live_dev);
ret = RunModeSetLiveCaptureSingle(de_ctx,
ParsePcapConfig, "ReceivePcap",
ParsePcapConfig,
PcapConfigGeThreadsCount,
"ReceivePcap",
"DecodePcap", "PcapLive",
live_dev);
if (ret != 0) {

@ -568,12 +568,16 @@ int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx,
}
int RunModeSetLiveCaptureSingle(DetectEngineCtx *de_ctx,
ConfigIfaceParserFunc configparser, char *recv_mod_name,
ConfigIfaceParserFunc configparser,
ConfigIfaceThreadsCountFunc mod_threads_count,
char *recv_mod_name,
char *decode_mod_name, char *thread_name,
const char *live_dev)
{
int nlive = LiveGetDeviceCount();
void *aconf;
int threads_count;
int thread;
if (nlive > 1) {
SCLogError(SC_ERR_RUNMODE,
@ -587,49 +591,61 @@ int RunModeSetLiveCaptureSingle(DetectEngineCtx *de_ctx,
char *live_dev_c = LiveGetDevice(0);
aconf = configparser(live_dev_c);
}
threads_count = mod_threads_count(aconf);
SCLogInfo("Going to use %" PRId32 " thread(s)", threads_count);
/* create the threads */
ThreadVars *tv = TmThreadCreatePacketHandler(thread_name,
"packetpool", "packetpool",
"packetpool", "packetpool",
"pktacqloop");
if (tv == NULL) {
printf("ERROR: TmThreadsCreate failed\n");
exit(EXIT_FAILURE);
}
for (thread = 0; thread < threads_count; thread++) {
char tname[12];
char *n_thread_name = NULL;
ThreadVars *tv = NULL;
TmModule *tm_module = NULL;
snprintf(tname, sizeof(tname), "%s%"PRIu16, thread_name, thread+1);
n_thread_name = SCStrdup(tname);
tv = TmThreadCreatePacketHandler(n_thread_name,
"packetpool", "packetpool",
"packetpool", "packetpool",
"pktacqloop");
if (tv == NULL) {
printf("ERROR: TmThreadsCreate failed\n");
exit(EXIT_FAILURE);
}
TmModule *tm_module = TmModuleGetByName(recv_mod_name);
if (tm_module == NULL) {
printf("ERROR: TmModuleGetByName failed for %s\n", recv_mod_name);
exit(EXIT_FAILURE);
}
TmSlotSetFuncAppend(tv, tm_module, aconf);
tm_module = TmModuleGetByName(recv_mod_name);
if (tm_module == NULL) {
printf("ERROR: TmModuleGetByName failed for %s\n", recv_mod_name);
exit(EXIT_FAILURE);
}
TmSlotSetFuncAppend(tv, tm_module, aconf);
tm_module = TmModuleGetByName(decode_mod_name);
if (tm_module == NULL) {
printf("ERROR: TmModuleGetByName %s failed\n", decode_mod_name);
exit(EXIT_FAILURE);
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
tm_module = TmModuleGetByName(decode_mod_name);
if (tm_module == NULL) {
printf("ERROR: TmModuleGetByName %s failed\n", decode_mod_name);
exit(EXIT_FAILURE);
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
tm_module = TmModuleGetByName("StreamTcp");
if (tm_module == NULL) {
printf("ERROR: TmModuleGetByName StreamTcp failed\n");
exit(EXIT_FAILURE);
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
tm_module = TmModuleGetByName("StreamTcp");
if (tm_module == NULL) {
printf("ERROR: TmModuleGetByName StreamTcp failed\n");
exit(EXIT_FAILURE);
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
tm_module = TmModuleGetByName("Detect");
if (tm_module == NULL) {
printf("ERROR: TmModuleGetByName Detect failed\n");
exit(EXIT_FAILURE);
}
TmSlotSetFuncAppend(tv, tm_module, (void *)de_ctx);
tm_module = TmModuleGetByName("Detect");
if (tm_module == NULL) {
printf("ERROR: TmModuleGetByName Detect failed\n");
exit(EXIT_FAILURE);
}
TmSlotSetFuncAppend(tv, tm_module, (void *)de_ctx);
SetupOutputs(tv);
SetupOutputs(tv);
if (TmThreadSpawn(tv) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
if (TmThreadSpawn(tv) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
}
}
return 0;

@ -40,7 +40,9 @@ int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx,
const char *live_dev);
int RunModeSetLiveCaptureSingle(DetectEngineCtx *de_ctx,
ConfigIfaceParserFunc configparser, char *recv_mod_name,
ConfigIfaceParserFunc configparser,
ConfigIfaceThreadsCountFunc mod_threads_count,
char *recv_mod_name,
char *decode_mod_name, char *thread_name,
const char *live_dev);

Loading…
Cancel
Save