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) {
179 if (tm_module == NULL) {
180 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
185 if (tm_module == NULL) {
186 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
199 for (uint16_t thread = 0; thread < thread_max; thread++) {
201 snprintf(qname,
sizeof(qname),
"pickup%u", (uint16_t)(thread + 1));
203 SCLogDebug(
"tname %s, qname %s", tname, qname);
208 "packetpool",
"packetpool",
210 if (tv_detect_ncpu == NULL) {
214 if (tm_module == NULL) {
215 FatalError(
"TmModuleGetByName for FlowWorker failed");
224 if (tm_module == NULL) {
225 FatalError(
"TmModuleGetByName RespondReject failed");
241 const char *recv_mod_name,
242 const char *decode_mod_name,
const char *thread_name,
243 const char *live_dev,
void *aconf,
244 unsigned char single_mode)
252 threads_count =
MIN(ModThreadsCount(aconf), thread_max);
253 SCLogInfo(
"%s: creating %" PRId32
" thread%s", live_dev, threads_count,
254 threads_count > 1 ?
"s" :
"");
258 for (
int thread = 0; thread < threads_count; thread++) {
262 char *printable_threadname =
SCMalloc(
sizeof(
char) * (strlen(thread_name)+5+strlen(live_dev)));
263 if (
unlikely(printable_threadname == NULL)) {
264 FatalError(
"failed to alloc printable thread name: %s", strerror(errno));
269 snprintf(tname,
sizeof(tname),
"%s#01-%s", thread_name, visual_devname);
270 snprintf(printable_threadname, strlen(thread_name)+5+strlen(live_dev),
"%s#01-%s",
271 thread_name, live_dev);
273 snprintf(tname,
sizeof(tname),
"%s#%02d-%s", thread_name,
274 thread+1, visual_devname);
275 snprintf(printable_threadname, strlen(thread_name)+5+strlen(live_dev),
"%s#%02d-%s",
276 thread_name, thread+1, live_dev);
279 "packetpool",
"packetpool",
280 "packetpool",
"packetpool",
288 if (tm_module == NULL) {
289 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
294 if (tm_module == NULL) {
295 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
300 if (tm_module == NULL) {
301 FatalError(
"TmModuleGetByName for FlowWorker failed");
306 if (tm_module == NULL) {
307 FatalError(
"TmModuleGetByName RespondReject failed");
323 const char *decode_mod_name,
const char *thread_name,
const char *live_dev)
329 for (ldev = 0; ldev < nlive; ldev++) {
330 const char *live_dev_c = NULL;
331 if ((nlive <= 1) && (live_dev != NULL)) {
332 aconf = ConfigParser(live_dev);
333 live_dev_c = live_dev;
336 aconf = ConfigParser(live_dev_c);
338 RunModeSetLiveCaptureWorkersForDevice(ModThreadsCount,
352 const char *recv_mod_name,
353 const char *decode_mod_name,
const char *thread_name,
354 const char *live_dev)
357 const char *live_dev_c = NULL;
361 FatalError(
"Can't use the 'single' runmode with multiple devices");
364 if (live_dev != NULL) {
365 aconf = ConfigParser(live_dev);
366 live_dev_c = live_dev;
369 aconf = ConfigParser(live_dev_c);
372 return RunModeSetLiveCaptureWorkersForDevice(
386 const char *recv_mod_name,
387 const char *verdict_mod_name,
388 const char *decode_mod_name)
400 if (queues == NULL) {
401 FatalError(
"RunmodeAutoFpCreatePickupQueuesString failed");
405 for (
int i = 0; i < nqueue; i++) {
407 if (cur_queue == NULL) {
410 memset(tname, 0,
sizeof(tname));
415 "packetpool",
"packetpool",
416 queues,
"flow",
"pktacqloop");
417 if (tv_receive == NULL) {
421 if (tm_module == NULL) {
422 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
427 if (tm_module == NULL) {
428 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
439 for (
int thread = 0; thread < thread_max; thread++) {
442 snprintf(qname,
sizeof(qname),
"pickup%u", (uint16_t)(thread + 1));
444 SCLogDebug(
"tname %s, qname %s", tname, qname);
449 "verdict-queue",
"simple",
451 if (tv_detect_ncpu == NULL) {
456 if (tm_module == NULL) {
457 FatalError(
"TmModuleGetByName for FlowWorker failed");
471 for (
int i = 0; i < nqueue; i++) {
472 memset(tname, 0,
sizeof(tname));
477 "verdict-queue",
"simple",
478 "packetpool",
"packetpool",
480 if (tv_verdict == NULL) {
484 if (tm_module == NULL) {
485 FatalError(
"TmModuleGetByName %s failed", verdict_mod_name);
490 if (tm_module == NULL) {
491 FatalError(
"TmModuleGetByName for RespondReject failed");
509 const char *recv_mod_name,
510 const char *verdict_mod_name,
511 const char *decode_mod_name)
516 for (
int i = 0; i < nqueue; i++) {
519 if (cur_queue == NULL) {
524 memset(tname, 0,
sizeof(tname));
528 "packetpool",
"packetpool",
529 "packetpool",
"packetpool",
536 if (tm_module == NULL) {
537 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
542 if (tm_module == NULL) {
543 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
548 if (tm_module == NULL) {
549 FatalError(
"TmModuleGetByName for FlowWorker failed");
554 if (tm_module == NULL) {
555 FatalError(
"TmModuleGetByName %s failed", verdict_mod_name);
560 if (tm_module == NULL) {
561 FatalError(
"TmModuleGetByName for RespondReject failed");