62 size_t queues_size = n * 13;
65 char *queues =
SCMalloc(queues_size);
67 SCLogError(
"failed to alloc queues buffer: %s", strerror(errno));
70 memset(queues, 0x00, queues_size);
72 for (
int thread = 0; thread < n; thread++) {
73 if (strlen(queues) > 0)
74 strlcat(queues,
",", queues_size);
76 snprintf(qname,
sizeof(qname),
"pickup%d", (int16_t)thread+1);
77 strlcat(queues, qname, queues_size);
80 SCLogDebug(
"%d %"PRIuMAX
", queues %s", n, (uintmax_t)queues_size, queues);
88 const char *decode_mod_name,
const char *thread_name,
const char *live_dev)
99 FatalError(
"RunmodeAutoFpCreatePickupQueuesString failed");
102 if ((nlive <= 1) && (live_dev != NULL)) {
105 void *aconf = ConfigParser(live_dev);
107 FatalError(
"Failed to allocate config for %s", live_dev);
110 int threads_count = ModThreadsCount(aconf);
111 SCLogInfo(
"Going to use %" PRId32
" %s receive thread(s)",
112 threads_count, recv_mod_name);
115 for (
int thread = 0; thread < threads_count; thread++) {
116 snprintf(tname,
sizeof(tname),
"%s#%02d", thread_name, thread+1);
119 "packetpool",
"packetpool",
120 queues,
"flow",
"pktacqloop");
121 if (tv_receive == NULL) {
125 if (tm_module == NULL) {
126 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
131 if (tm_module == NULL) {
132 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
143 SCLogInfo(
"Using %d live device(s).", nlive);
145 for (
int lthread = 0; lthread < nlive; lthread++) {
150 FatalError(
"Failed to lookup live dev %d", lthread);
154 void *aconf = ConfigParser(dev);
156 FatalError(
"Multidev: Failed to allocate config for %s (%d)", dev, lthread);
159 int threads_count = ModThreadsCount(aconf);
160 for (
int thread = 0; thread < threads_count; thread++) {
161 char *printable_threadname =
SCMalloc(
sizeof(
char) * (strlen(thread_name)+5+strlen(dev)));
162 if (
unlikely(printable_threadname == NULL)) {
163 FatalError(
"failed to alloc printable thread name: %s", strerror(errno));
165 snprintf(tname,
sizeof(tname),
"%s#%02d-%s", thread_name,
166 thread+1, visual_devname);
167 snprintf(printable_threadname, strlen(thread_name)+5+strlen(dev),
168 "%s#%02d-%s", thread_name, thread+1,
173 "packetpool",
"packetpool",
174 queues,
"flow",
"pktacqloop");
175 if (tv_receive == NULL) {
180 if (tm_module == NULL) {
181 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
186 if (tm_module == NULL) {
187 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
200 for (uint16_t thread = 0; thread < thread_max; thread++) {
202 snprintf(qname,
sizeof(qname),
"pickup%u", (uint16_t)(thread + 1));
204 SCLogDebug(
"tname %s, qname %s", tname, qname);
209 "packetpool",
"packetpool",
211 if (tv_detect_ncpu == NULL) {
215 if (tm_module == NULL) {
216 FatalError(
"TmModuleGetByName for FlowWorker failed");
225 if (tm_module == NULL) {
226 FatalError(
"TmModuleGetByName RespondReject failed");
242 const char *recv_mod_name,
243 const char *decode_mod_name,
const char *thread_name,
244 const char *live_dev,
void *aconf,
245 unsigned char single_mode)
253 threads_count =
MIN(ModThreadsCount(aconf), thread_max);
254 SCLogInfo(
"%s: creating %" PRId32
" thread%s", live_dev, threads_count,
255 threads_count > 1 ?
"s" :
"");
259 for (
int thread = 0; thread < threads_count; thread++) {
263 char *printable_threadname =
SCMalloc(
sizeof(
char) * (strlen(thread_name)+5+strlen(live_dev)));
264 if (
unlikely(printable_threadname == NULL)) {
265 FatalError(
"failed to alloc printable thread name: %s", strerror(errno));
270 snprintf(tname,
sizeof(tname),
"%s#01-%s", thread_name, visual_devname);
271 snprintf(printable_threadname, strlen(thread_name)+5+strlen(live_dev),
"%s#01-%s",
272 thread_name, live_dev);
274 snprintf(tname,
sizeof(tname),
"%s#%02d-%s", thread_name,
275 thread+1, visual_devname);
276 snprintf(printable_threadname, strlen(thread_name)+5+strlen(live_dev),
"%s#%02d-%s",
277 thread_name, thread+1, live_dev);
280 "packetpool",
"packetpool",
281 "packetpool",
"packetpool",
289 if (tm_module == NULL) {
290 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
295 if (tm_module == NULL) {
296 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
301 if (tm_module == NULL) {
302 FatalError(
"TmModuleGetByName for FlowWorker failed");
307 if (tm_module == NULL) {
308 FatalError(
"TmModuleGetByName RespondReject failed");
324 const char *decode_mod_name,
const char *thread_name,
const char *live_dev)
330 for (ldev = 0; ldev < nlive; ldev++) {
331 const char *live_dev_c = NULL;
332 if ((nlive <= 1) && (live_dev != NULL)) {
333 aconf = ConfigParser(live_dev);
334 live_dev_c = live_dev;
337 aconf = ConfigParser(live_dev_c);
339 RunModeSetLiveCaptureWorkersForDevice(ModThreadsCount,
353 const char *recv_mod_name,
354 const char *decode_mod_name,
const char *thread_name,
355 const char *live_dev)
358 const char *live_dev_c = NULL;
362 FatalError(
"Can't use the 'single' runmode with multiple devices");
365 if (live_dev != NULL) {
366 aconf = ConfigParser(live_dev);
367 live_dev_c = live_dev;
370 aconf = ConfigParser(live_dev_c);
373 return RunModeSetLiveCaptureWorkersForDevice(
387 const char *recv_mod_name,
388 const char *verdict_mod_name,
389 const char *decode_mod_name)
401 if (queues == NULL) {
402 FatalError(
"RunmodeAutoFpCreatePickupQueuesString failed");
406 for (
int i = 0; i < nqueue; i++) {
408 if (cur_queue == NULL) {
411 memset(tname, 0,
sizeof(tname));
416 "packetpool",
"packetpool",
417 queues,
"flow",
"pktacqloop");
418 if (tv_receive == NULL) {
422 if (tm_module == NULL) {
423 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
428 if (tm_module == NULL) {
429 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
440 for (
int thread = 0; thread < thread_max; thread++) {
443 snprintf(qname,
sizeof(qname),
"pickup%u", (uint16_t)(thread + 1));
445 SCLogDebug(
"tname %s, qname %s", tname, qname);
450 "verdict-queue",
"simple",
452 if (tv_detect_ncpu == NULL) {
457 if (tm_module == NULL) {
458 FatalError(
"TmModuleGetByName for FlowWorker failed");
472 for (
int i = 0; i < nqueue; i++) {
473 memset(tname, 0,
sizeof(tname));
478 "verdict-queue",
"simple",
479 "packetpool",
"packetpool",
481 if (tv_verdict == NULL) {
485 if (tm_module == NULL) {
486 FatalError(
"TmModuleGetByName %s failed", verdict_mod_name);
491 if (tm_module == NULL) {
492 FatalError(
"TmModuleGetByName for RespondReject failed");
510 const char *recv_mod_name,
511 const char *verdict_mod_name,
512 const char *decode_mod_name)
517 for (
int i = 0; i < nqueue; i++) {
520 if (cur_queue == NULL) {
525 memset(tname, 0,
sizeof(tname));
529 "packetpool",
"packetpool",
530 "packetpool",
"packetpool",
537 if (tm_module == NULL) {
538 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
543 if (tm_module == NULL) {
544 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
549 if (tm_module == NULL) {
550 FatalError(
"TmModuleGetByName for FlowWorker failed");
555 if (tm_module == NULL) {
556 FatalError(
"TmModuleGetByName %s failed", verdict_mod_name);
561 if (tm_module == NULL) {
562 FatalError(
"TmModuleGetByName for RespondReject failed");