62 size_t queues_size = n * 13;
65 char *queues =
SCCalloc(1, queues_size);
67 SCLogError(
"failed to alloc queues buffer: %s", strerror(errno));
71 for (
int thread = 0; thread < n; thread++) {
72 if (strlen(queues) > 0)
73 strlcat(queues,
",", queues_size);
75 snprintf(qname,
sizeof(qname),
"pickup%d", (int16_t)thread+1);
76 strlcat(queues, qname, queues_size);
79 SCLogDebug(
"%d %"PRIuMAX
", queues %s", n, (uintmax_t)queues_size, queues);
87 const char *decode_mod_name,
const char *thread_name,
const char *live_dev)
98 FatalError(
"RunmodeAutoFpCreatePickupQueuesString failed");
101 if ((nlive <= 1) && (live_dev != NULL)) {
104 void *aconf = ConfigParser(live_dev);
106 FatalError(
"Failed to allocate config for %s", live_dev);
109 int threads_count = ModThreadsCount(aconf);
110 SCLogInfo(
"Going to use %" PRId32
" %s receive thread(s)",
111 threads_count, recv_mod_name);
114 for (
int thread = 0; thread < threads_count; thread++) {
115 snprintf(tname,
sizeof(tname),
"%s#%02d", thread_name, thread+1);
118 "packetpool",
"packetpool",
119 queues,
"flow",
"pktacqloop");
120 if (tv_receive == NULL) {
124 if (tm_module == NULL) {
125 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
130 if (tm_module == NULL) {
131 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
142 SCLogInfo(
"Using %d live device(s).", nlive);
144 for (
int lthread = 0; lthread < nlive; lthread++) {
149 FatalError(
"Failed to lookup live dev %d", lthread);
153 void *aconf = ConfigParser(dev);
155 FatalError(
"Multidev: Failed to allocate config for %s (%d)", dev, lthread);
158 int threads_count = ModThreadsCount(aconf);
159 for (
int thread = 0; thread < threads_count; thread++) {
160 char *printable_threadname =
SCMalloc(
sizeof(
char) * (strlen(thread_name)+5+strlen(dev)));
161 if (
unlikely(printable_threadname == NULL)) {
162 FatalError(
"failed to alloc printable thread name: %s", strerror(errno));
164 snprintf(tname,
sizeof(tname),
"%s#%02d-%s", thread_name,
165 thread+1, visual_devname);
166 snprintf(printable_threadname, strlen(thread_name)+5+strlen(dev),
167 "%s#%02d-%s", thread_name, thread+1,
172 "packetpool",
"packetpool",
173 queues,
"flow",
"pktacqloop");
174 if (tv_receive == NULL) {
180 FatalError(
"Failed to allocate memory for iface name");
184 if (tm_module == NULL) {
185 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
190 if (tm_module == NULL) {
191 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
204 for (uint16_t thread = 0; thread < thread_max; thread++) {
206 snprintf(qname,
sizeof(qname),
"pickup%u", (uint16_t)(thread + 1));
208 SCLogDebug(
"tname %s, qname %s", tname, qname);
213 "packetpool",
"packetpool",
215 if (tv_detect_ncpu == NULL) {
219 if (tm_module == NULL) {
220 FatalError(
"TmModuleGetByName for FlowWorker failed");
229 if (tm_module == NULL) {
230 FatalError(
"TmModuleGetByName RespondReject failed");
246 const char *recv_mod_name,
247 const char *decode_mod_name,
const char *thread_name,
248 const char *live_dev,
void *aconf,
249 unsigned char single_mode)
257 threads_count =
MIN(ModThreadsCount(aconf), thread_max);
258 SCLogInfo(
"%s: creating %" PRId32
" thread%s", live_dev, threads_count,
259 threads_count > 1 ?
"s" :
"");
263 for (
int thread = 0; thread < threads_count; thread++) {
267 char *printable_threadname =
SCMalloc(
sizeof(
char) * (strlen(thread_name)+5+strlen(live_dev)));
268 if (
unlikely(printable_threadname == NULL)) {
269 FatalError(
"failed to alloc printable thread name: %s", strerror(errno));
274 snprintf(tname,
sizeof(tname),
"%s#01-%s", thread_name, visual_devname);
275 snprintf(printable_threadname, strlen(thread_name)+5+strlen(live_dev),
"%s#01-%s",
276 thread_name, live_dev);
278 snprintf(tname,
sizeof(tname),
"%s#%02d-%s", thread_name,
279 thread+1, visual_devname);
280 snprintf(printable_threadname, strlen(thread_name)+5+strlen(live_dev),
"%s#%02d-%s",
281 thread_name, thread+1, live_dev);
284 "packetpool",
"packetpool",
285 "packetpool",
"packetpool",
293 FatalError(
"Failed to allocate memory for iface name");
297 if (tm_module == NULL) {
298 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
303 if (tm_module == NULL) {
304 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
309 if (tm_module == NULL) {
310 FatalError(
"TmModuleGetByName for FlowWorker failed");
315 if (tm_module == NULL) {
316 FatalError(
"TmModuleGetByName RespondReject failed");
332 const char *decode_mod_name,
const char *thread_name,
const char *live_dev)
338 for (ldev = 0; ldev < nlive; ldev++) {
339 const char *live_dev_c = NULL;
340 if ((nlive <= 1) && (live_dev != NULL)) {
341 aconf = ConfigParser(live_dev);
342 live_dev_c = live_dev;
345 aconf = ConfigParser(live_dev_c);
347 RunModeSetLiveCaptureWorkersForDevice(ModThreadsCount,
361 const char *recv_mod_name,
362 const char *decode_mod_name,
const char *thread_name,
363 const char *live_dev)
366 const char *live_dev_c = NULL;
370 FatalError(
"Can't use the 'single' runmode with multiple devices");
373 if (live_dev != NULL) {
374 aconf = ConfigParser(live_dev);
375 live_dev_c = live_dev;
378 aconf = ConfigParser(live_dev_c);
381 return RunModeSetLiveCaptureWorkersForDevice(
395 const char *recv_mod_name,
396 const char *verdict_mod_name,
397 const char *decode_mod_name)
409 if (queues == NULL) {
410 FatalError(
"RunmodeAutoFpCreatePickupQueuesString failed");
414 for (
int i = 0; i < nqueue; i++) {
416 if (cur_queue == NULL) {
419 memset(tname, 0,
sizeof(tname));
424 "packetpool",
"packetpool",
425 queues,
"flow",
"pktacqloop");
426 if (tv_receive == NULL) {
430 if (tm_module == NULL) {
431 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
436 if (tm_module == NULL) {
437 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
448 for (
int thread = 0; thread < thread_max; thread++) {
451 snprintf(qname,
sizeof(qname),
"pickup%u", (uint16_t)(thread + 1));
453 SCLogDebug(
"tname %s, qname %s", tname, qname);
458 "verdict-queue",
"simple",
460 if (tv_detect_ncpu == NULL) {
465 if (tm_module == NULL) {
466 FatalError(
"TmModuleGetByName for FlowWorker failed");
480 for (
int i = 0; i < nqueue; i++) {
481 memset(tname, 0,
sizeof(tname));
486 "verdict-queue",
"simple",
487 "packetpool",
"packetpool",
489 if (tv_verdict == NULL) {
493 if (tm_module == NULL) {
494 FatalError(
"TmModuleGetByName %s failed", verdict_mod_name);
499 if (tm_module == NULL) {
500 FatalError(
"TmModuleGetByName for RespondReject failed");
518 const char *recv_mod_name,
519 const char *verdict_mod_name,
520 const char *decode_mod_name)
525 for (
int i = 0; i < nqueue; i++) {
528 if (cur_queue == NULL) {
533 memset(tname, 0,
sizeof(tname));
537 "packetpool",
"packetpool",
538 "packetpool",
"packetpool",
545 if (tm_module == NULL) {
546 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
551 if (tm_module == NULL) {
552 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
557 if (tm_module == NULL) {
558 FatalError(
"TmModuleGetByName for FlowWorker failed");
563 if (tm_module == NULL) {
564 FatalError(
"TmModuleGetByName %s failed", verdict_mod_name);
569 if (tm_module == NULL) {
570 FatalError(
"TmModuleGetByName for RespondReject failed");