suricata
source-pcap-file.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2026 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  *
23  * File based pcap packet acquisition support
24  */
25 
26 #include "suricata-common.h"
27 #include "source-pcap-file.h"
30 #include "flow-manager.h"
31 #include "util-checksum.h"
32 #include "runmode-unix-socket.h"
33 #include "suricata.h"
34 #include "conf.h"
35 #include "util-misc.h"
36 #include "capture-hooks.h"
37 
38 extern uint32_t max_pending_packets;
40 
41 /**
42  * Union determining whether the behavior of the thread is file or directory
43  */
44 typedef union PcapFileBehaviorVar_
45 {
49 
50 /**
51  * Data specific to the thread
52  */
53 typedef struct PcapFileThreadVars_
54 {
57 
60 
61 static TmEcode ReceivePcapFileLoop(ThreadVars *, void *, void *);
62 static TmEcode ReceivePcapFileThreadInit(ThreadVars *, const void *, void **);
63 static void ReceivePcapFileThreadExitStats(ThreadVars *, void *);
64 static TmEcode ReceivePcapFileThreadDeinit(ThreadVars *, void *);
65 
66 static TmEcode DecodePcapFile(ThreadVars *, Packet *, void *);
67 static TmEcode DecodePcapFileThreadInit(ThreadVars *, const void *, void **);
68 static TmEcode DecodePcapFileThreadDeinit(ThreadVars *tv, void *data);
69 
70 static void CleanupPcapDirectoryFromThreadVars(PcapFileThreadVars *tv,
72 static void CleanupPcapFileFromThreadVars(PcapFileThreadVars *tv, PcapFileFileVars *pfv);
73 static void CleanupPcapFileThreadVars(PcapFileThreadVars *tv);
74 static TmEcode PcapFileExit(TmEcode status, struct timespec *last_processed);
75 
76 void CleanupPcapFileFromThreadVars(PcapFileThreadVars *tv, PcapFileFileVars *pfv)
77 {
79  if (tv->is_directory == 0) {
80  tv->behavior.file = NULL;
81  }
82 }
83 
84 void CleanupPcapDirectoryFromThreadVars(PcapFileThreadVars *tv, PcapFileDirectoryVars *ptv)
85 {
87  if (tv->is_directory == 1) {
88  tv->behavior.directory = NULL;
89  }
90 }
91 
92 void CleanupPcapFileThreadVars(PcapFileThreadVars *ptv)
93 {
94  if (ptv != NULL) {
95  if (ptv->is_directory == 0) {
96  if (ptv->behavior.file != NULL) {
97  CleanupPcapFileFromThreadVars(ptv, ptv->behavior.file);
98  }
99  ptv->behavior.file = NULL;
100  } else {
101  if (ptv->behavior.directory != NULL) {
102  CleanupPcapDirectoryFromThreadVars(ptv, ptv->behavior.directory);
103  }
104  ptv->behavior.directory = NULL;
105  }
106  if (ptv->shared.bpf_string != NULL) {
107  SCFree(ptv->shared.bpf_string);
108  ptv->shared.bpf_string = NULL;
109  }
110  SCFree(ptv);
111  }
112 }
113 
114 /**
115  * Pcap File Functionality
116  */
118 {
119  tmm_modules[TMM_RECEIVEPCAPFILE].name = "ReceivePcapFile";
120  tmm_modules[TMM_RECEIVEPCAPFILE].ThreadInit = ReceivePcapFileThreadInit;
122  tmm_modules[TMM_RECEIVEPCAPFILE].PktAcqLoop = ReceivePcapFileLoop;
124  tmm_modules[TMM_RECEIVEPCAPFILE].ThreadExitPrintStats = ReceivePcapFileThreadExitStats;
125  tmm_modules[TMM_RECEIVEPCAPFILE].ThreadDeinit = ReceivePcapFileThreadDeinit;
128 }
129 
131 {
132  tmm_modules[TMM_DECODEPCAPFILE].name = "DecodePcapFile";
133  tmm_modules[TMM_DECODEPCAPFILE].ThreadInit = DecodePcapFileThreadInit;
134  tmm_modules[TMM_DECODEPCAPFILE].Func = DecodePcapFile;
136  tmm_modules[TMM_DECODEPCAPFILE].ThreadDeinit = DecodePcapFileThreadDeinit;
139 }
140 
141 #if defined(HAVE_SETVBUF) && defined(OS_LINUX)
142 #define PCAP_FILE_BUFFER_SIZE_DEFAULT 131072U // 128 KiB
143 #define PCAP_FILE_BUFFER_SIZE_MIN 4096U // 4 KiB
144 #define PCAP_FILE_BUFFER_SIZE_MAX 67108864U // 64MiB
145 #endif
146 
148 {
149  memset(&pcap_g, 0x00, sizeof(pcap_g));
150  SC_ATOMIC_INIT(pcap_g.invalid_checksums);
151 
153 
154 #if defined(HAVE_SETVBUF) && defined(OS_LINUX)
155  pcap_g.read_buffer_size = PCAP_FILE_BUFFER_SIZE_DEFAULT;
156 
157  const char *str = NULL;
158  if (SCConfGetNonNull("pcap-file.buffer-size", &str) == 1) {
159  uint32_t value = 0;
160  if (ParseSizeStringU32(str, &value) < 0) {
161  SCLogWarning("failed to parse pcap-file.buffer-size %s; keeping default %u", str,
162  PCAP_FILE_BUFFER_SIZE_DEFAULT);
163  } else if (value == 0 ||
164  (value >= PCAP_FILE_BUFFER_SIZE_MIN && value <= PCAP_FILE_BUFFER_SIZE_MAX)) {
165  if (value == 0) {
166  SCLogInfo("Pcap-file buffering disabled");
167  } else {
168  SCLogInfo("Pcap-file will use %u buffer size", value);
169  }
170  pcap_g.read_buffer_size = value;
171  } else {
172  SCLogWarning("pcap-file.buffer-size value of %u is invalid. Valid values are 0 to "
173  "disable buffering, or %u-%u",
174  value, PCAP_FILE_BUFFER_SIZE_MIN, PCAP_FILE_BUFFER_SIZE_MAX);
175  }
176  }
177 #endif
178 }
179 
180 TmEcode PcapFileExit(TmEcode status, struct timespec *last_processed)
181 {
183  status = UnixSocketPcapFile(status, last_processed);
184  SCReturnInt(status);
185  } else {
186  EngineStop();
187  SCReturnInt(status);
188  }
189 }
190 
191 TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot)
192 {
193  SCEnter();
194 
195  if(unlikely(data == NULL)) {
196  SCLogError("pcap file reader thread failed to initialize");
197 
198  PcapFileExit(TM_ECODE_FAILED, NULL);
199 
201  }
202 
203  TmEcode status = TM_ECODE_OK;
204  PcapFileThreadVars *ptv = (PcapFileThreadVars *) data;
205  TmSlot *s = (TmSlot *)slot;
206 
207  ptv->shared.slot = s->slot_next;
209 
210  // Indicate that the thread is actually running its application level code (i.e., it can poll
211  // packets)
213 
214  if(ptv->is_directory == 0) {
215  SCLogInfo("Starting file run for %s", ptv->behavior.file->filename);
216  /* Hold a reference for the duration of file processing, including
217  * post-dispatch flow draining during EngineStop, so deletion decision
218  * is deferred until all pseudo packets have been processed. */
219  SC_ATOMIC_ADD(ptv->behavior.file->ref_cnt, 1);
220  status = PcapFileDispatch(ptv->behavior.file);
221  } else {
222  SCLogInfo("Starting directory run for %s", ptv->behavior.directory->filename);
224  CleanupPcapDirectoryFromThreadVars(ptv, ptv->behavior.directory);
225  }
226 
227  SCLogDebug("Pcap file loop complete with status %u", status);
228 
229  status = PcapFileExit(status, &ptv->shared.last_processed);
230 
231  /* Release the hold set before dispatch and trigger deferred cleanup
232  * if requested and this was the final reference. */
233  if (ptv->is_directory == 0) {
234  /* Ensure current pfv global is set for any pseudo packets emitted
235  * during EngineStop/flow drain. */
237  uint32_t prev = SC_ATOMIC_SUB(ptv->behavior.file->ref_cnt, 1);
238  if (prev == 1 && ptv->behavior.file->cleanup_requested) {
240  ptv->behavior.file = NULL;
241  }
242  }
243  SCReturnInt(status);
244 }
245 
246 TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **data)
247 {
248  SCEnter();
249 
250  TmEcode status = TM_ECODE_OK;
251  const char *tmpstring = NULL;
252  const char *tmp_bpf_string = NULL;
253 
254  if (initdata == NULL) {
255  SCLogError("error: initdata == NULL");
256 
258  }
259 
261  if (unlikely(ptv == NULL)) {
263  }
264  memset(&ptv->shared.last_processed, 0, sizeof(struct timespec));
265 
266  intmax_t tenant = 0;
267  if (SCConfGetInt("pcap-file.tenant-id", &tenant) == 1) {
268  if (tenant > 0 && tenant < UINT_MAX) {
269  ptv->shared.tenant_id = (uint32_t)tenant;
270  SCLogInfo("tenant %u", ptv->shared.tenant_id);
271  } else {
272  SCLogError("tenant out of range");
273  }
274  }
275 
276  if (SCConfGetNonNull("bpf-filter", &(tmp_bpf_string)) != 1) {
277  SCLogDebug("could not get bpf or none specified");
278  } else {
279  ptv->shared.bpf_string = SCStrdup(tmp_bpf_string);
280  if (unlikely(ptv->shared.bpf_string == NULL)) {
281  SCLogError("Failed to allocate bpf_string");
282 
283  CleanupPcapFileThreadVars(ptv);
284 
286  }
287  }
288 
290 
291  DIR *directory = NULL;
292  SCLogDebug("checking file or directory %s", (char*)initdata);
293  if(PcapDetermineDirectoryOrFile((char *)initdata, &directory) == TM_ECODE_FAILED) {
294  CleanupPcapFileThreadVars(ptv);
296  }
297 
298  if(directory == NULL) {
299  SCLogDebug("argument %s was a file", (char *)initdata);
300  const size_t toalloc = sizeof(PcapFileFileVars) + pcap_g.read_buffer_size;
301  PcapFileFileVars *pv = SCCalloc(1, toalloc);
302  if (unlikely(pv == NULL)) {
303  SCLogError("Failed to allocate file vars");
304  CleanupPcapFileThreadVars(ptv);
306  }
307 
308  pv->filename = SCStrdup((char *)initdata);
309  if (unlikely(pv->filename == NULL)) {
310  SCLogError("Failed to allocate filename");
312  CleanupPcapFileThreadVars(ptv);
314  }
315 
316  pv->shared = &ptv->shared;
317  status = InitPcapFile(pv);
318  if(status == TM_ECODE_OK) {
319  ptv->is_directory = 0;
320  ptv->behavior.file = pv;
321  } else {
322  SCLogWarning("Failed to init pcap file %s, skipping", pv->filename);
324  CleanupPcapFileThreadVars(ptv);
326  }
327  } else {
328  SCLogInfo("Argument %s was a directory", (char *)initdata);
330  if (unlikely(pv == NULL)) {
331  SCLogError("Failed to allocate directory vars");
332  closedir(directory);
333  CleanupPcapFileThreadVars(ptv);
335  }
336 
337  pv->filename = SCStrdup((char*)initdata);
338  if (unlikely(pv->filename == NULL)) {
339  SCLogError("Failed to allocate filename");
340  closedir(directory);
342  CleanupPcapFileThreadVars(ptv);
344  }
345 
346  int should_recurse;
347  pv->should_recurse = false;
348  if (SCConfGetBool("pcap-file.recursive", &should_recurse) == 1) {
349  pv->should_recurse = (should_recurse == 1);
350  }
351 
352  int should_loop = 0;
353  pv->should_loop = false;
354  if (SCConfGetBool("pcap-file.continuous", &should_loop) == 1) {
355  pv->should_loop = (should_loop == 1);
356  }
357 
358  if (pv->should_recurse && pv->should_loop) {
359  SCLogError("Error, --pcap-file-continuous and --pcap-file-recursive "
360  "cannot be used together.");
361  closedir(directory);
363  CleanupPcapFileThreadVars(ptv);
365  }
366 
367  pv->delay = 30;
368  intmax_t delay = 0;
369  if (SCConfGetInt("pcap-file.delay", &delay) == 1) {
370  if (delay > 0 && delay < UINT_MAX) {
371  pv->delay = (time_t)delay;
372  SCLogDebug("delay %lu", pv->delay);
373  } else {
374  SCLogError("delay out of range");
375  }
376  }
377 
378  pv->poll_interval = 5;
379  intmax_t poll_interval = 0;
380  if (SCConfGetInt("pcap-file.poll-interval", &poll_interval) == 1) {
381  if (poll_interval > 0 && poll_interval < UINT_MAX) {
382  pv->poll_interval = (time_t)poll_interval;
383  SCLogDebug("poll-interval %lu", pv->delay);
384  } else {
385  SCLogError("poll-interval out of range");
386  }
387  }
388 
389  pv->shared = &ptv->shared;
390  pv->directory = directory;
391  TAILQ_INIT(&pv->directory_content);
392 
393  ptv->is_directory = 1;
394  ptv->behavior.directory = pv;
395  }
396 
397  if (SCConfGetNonNull("pcap-file.checksum-checks", &tmpstring) != 1) {
399  } else {
400  if (strcmp(tmpstring, "auto") == 0) {
402  } else if (SCConfValIsTrue(tmpstring)) {
404  } else if (SCConfValIsFalse(tmpstring)) {
406  }
407  }
409 
410  ptv->shared.tv = tv;
411  *data = (void *)ptv;
412 
414 }
415 
416 void ReceivePcapFileThreadExitStats(ThreadVars *tv, void *data)
417 {
418  SCEnter();
419  if(data != NULL) {
420  PcapFileThreadVars *ptv = (PcapFileThreadVars *)data;
421 
424  SC_ATOMIC_GET(pcap_g.invalid_checksums)) {
425  uint64_t chrate = pcap_g.cnt / SC_ATOMIC_GET(pcap_g.invalid_checksums);
426  if (chrate < CHECKSUM_INVALID_RATIO)
427  SCLogWarning("1/%" PRIu64 "th of packets have an invalid checksum,"
428  " consider setting pcap-file.checksum-checks variable to no"
429  " or use '-k none' option on command line.",
430  chrate);
431  else
432  SCLogInfo("1/%" PRIu64 "th of packets have an invalid checksum",
433  chrate);
434  }
435  SCLogNotice("read %" PRIu64 " file%s, %" PRIu64 " packets, %" PRIu64 " bytes",
436  ptv->shared.files, ptv->shared.files == 1 ? "" : "s", ptv->shared.pkts,
437  ptv->shared.bytes);
438  }
439 }
440 
441 TmEcode ReceivePcapFileThreadDeinit(ThreadVars *tv, void *data)
442 {
443  SCEnter();
444  if(data != NULL) {
445  PcapFileThreadVars *ptv = (PcapFileThreadVars *) data;
446 
447  if (!ptv->is_directory && ptv->behavior.file != NULL) {
448  CleanupPcapFileFromThreadVars(ptv, ptv->behavior.file);
449  }
450 
451  CleanupPcapFileThreadVars(ptv);
452  }
454 }
455 
456 static TmEcode DecodePcapFile(ThreadVars *tv, Packet *p, void *data)
457 {
458  SCEnter();
460 
462 
463  /* update counters */
465 
466  DecoderFunc decoder;
467  if(ValidateLinkType(p->datalink, &decoder) == TM_ECODE_OK) {
468 
469  /* call the decoder */
470  decoder(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
471 
472 #ifdef DEBUG
474 #endif
475  DEBUG_VALIDATE_BUG_ON(p->proto != PacketGetIPProto(p));
476 
478 
480  } else {
482  }
483 }
484 
485 TmEcode DecodePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **data)
486 {
487  SCEnter();
488  DecodeThreadVars *dtv = NULL;
490 
491  if (dtv == NULL)
493 
495 
496  *data = (void *)dtv;
497 
499 }
500 
501 TmEcode DecodePcapFileThreadDeinit(ThreadVars *tv, void *data)
502 {
503  if (data != NULL)
504  DecodeThreadVarsFree(tv, data);
506 }
507 
509 {
510  (void) SC_ATOMIC_ADD(pcap_g.invalid_checksums, 1);
511 }
512 
513 /* eof */
TmModule_::cap_flags
uint8_t cap_flags
Definition: tm-modules.h:77
PcapFileSharedVars_::slot
TmSlot * slot
Definition: source-pcap-file-helper.h:59
Packet_::proto
uint8_t proto
Definition: decode.h:537
PcapFileThreadVars_::is_directory
bool is_directory
Definition: source-pcap-file.c:56
SCConfValIsTrue
int SCConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:578
PcapFileDispatch
TmEcode PcapFileDispatch(PcapFileFileVars *ptv)
Main PCAP file reading Loop function.
Definition: source-pcap-file-helper.c:186
PcapFileFileVars_::filename
char * filename
Definition: source-pcap-file-helper.h:78
PcapFileSharedVars_
Definition: source-pcap-file-helper.h:49
TAILQ_INIT
#define TAILQ_INIT(head)
Definition: queue.h:262
PcapFileGlobalVars_
Definition: source-pcap-file-helper.h:37
SC_ATOMIC_INIT
#define SC_ATOMIC_INIT(name)
wrapper for initializing an atomic variable.
Definition: util-atomic.h:314
source-pcap-file.h
ValidateLinkType
TmEcode ValidateLinkType(int datalink, DecoderFunc *DecoderFn)
Definition: source-pcap-file-helper.c:326
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1363
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
PcapFileBehaviorVar
union PcapFileBehaviorVar_ PcapFileBehaviorVar
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
TmThreadsSetFlag
void TmThreadsSetFlag(ThreadVars *tv, uint32_t flag)
Set a thread flag.
Definition: tm-threads.c:103
util-checksum.h
TM_ECODE_DONE
@ TM_ECODE_DONE
Definition: tm-threads-common.h:83
PcapFileThreadVars
struct PcapFileThreadVars_ PcapFileThreadVars
SC_ATOMIC_ADD
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
Definition: util-atomic.h:332
THV_RUNNING
#define THV_RUNNING
Definition: threadvars.h:55
DecoderFunc
int(* DecoderFunc)(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode.h:1224
CHECKSUM_SAMPLE_COUNT
#define CHECKSUM_SAMPLE_COUNT
Definition: util-checksum.h:35
PcapFileBehaviorVar_::directory
PcapFileDirectoryVars * directory
Definition: source-pcap-file.c:46
PcapFileFileVars
struct PcapFileFileVars_ PcapFileFileVars
PcapFileSharedVars_::cb_result
int cb_result
Definition: source-pcap-file-helper.h:70
SCConfGetBool
int SCConfGetBool(const char *name, int *val)
Retrieve a configuration value as a boolean.
Definition: conf.c:524
SCConfValIsFalse
int SCConfValIsFalse(const char *val)
Check if a value is false.
Definition: conf.c:603
CHECKSUM_VALIDATION_DISABLE
@ CHECKSUM_VALIDATION_DISABLE
Definition: decode.h:43
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:235
p
Packet * p
Definition: fuzz_iprep.c:21
PcapFileDirectoryVars_::poll_interval
time_t poll_interval
Definition: source-pcap-file-directory-helper.h:48
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:82
runmode-unix-socket.h
PcapFileSharedVars_::files
uint64_t files
Definition: source-pcap-file-helper.h:64
PcapDetermineDirectoryOrFile
TmEcode PcapDetermineDirectoryOrFile(char *filename, DIR **directory)
Definition: source-pcap-file-directory-helper.c:174
TmModule_::PktAcqLoop
TmEcode(* PktAcqLoop)(ThreadVars *, void *, void *)
Definition: tm-modules.h:58
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:81
TmModule_::ThreadDeinit
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
Definition: tm-modules.h:53
Packet_::datalink
int datalink
Definition: decode.h:651
TmModuleDecodePcapFileRegister
void TmModuleDecodePcapFileRegister(void)
Definition: source-pcap-file.c:130
CHECKSUM_VALIDATION_ENABLE
@ CHECKSUM_VALIDATION_ENABLE
Definition: decode.h:44
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:634
CHECKSUM_VALIDATION_AUTO
@ CHECKSUM_VALIDATION_AUTO
Definition: decode.h:45
capture-hooks.h
PcapFileGlobalVars_::cnt
uint64_t cnt
Definition: source-pcap-file-helper.h:38
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:52
pcap_g
PcapFileGlobalVars pcap_g
Definition: source-pcap-file.c:39
TmModule_::PktAcqBreakLoop
TmEcode(* PktAcqBreakLoop)(ThreadVars *, void *)
Definition: tm-modules.h:61
PcapFileSetCurrentPfv
void PcapFileSetCurrentPfv(PcapFileFileVars *pfv)
Definition: source-pcap-file-helper.c:173
PcapFileDirectoryVars_
Definition: source-pcap-file-directory-helper.h:41
TMM_RECEIVEPCAPFILE
@ TMM_RECEIVEPCAPFILE
Definition: tm-threads-common.h:39
SCConfGetInt
int SCConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:441
PcapFileGlobalVars_::checksum_mode
ChecksumValidationMode checksum_mode
Definition: source-pcap-file-helper.h:40
SCEnter
#define SCEnter(...)
Definition: util-debug.h:284
GET_PKT_DATA
#define GET_PKT_DATA(p)
Definition: decode.h:210
SCConfGetNonNull
int SCConfGetNonNull(const char *name, const char **vptr)
Retrieve the non-null value of a configuration node.
Definition: conf.c:381
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
PcapFileThreadVars_::behavior
PcapFileBehaviorVar behavior
Definition: source-pcap-file.c:55
TmModule_::Func
TmEcode(* Func)(ThreadVars *, Packet *, void *)
Definition: tm-modules.h:56
PcapFileDirectoryVars_::should_recurse
bool should_recurse
Definition: source-pcap-file-directory-helper.h:46
InitPcapFile
TmEcode InitPcapFile(PcapFileFileVars *pfv)
Definition: source-pcap-file-helper.c:257
source-pcap-file-directory-helper.h
RunModeUnixSocketIsActive
int RunModeUnixSocketIsActive(void)
Definition: runmode-unix-socket.c:1797
SCLogWarning
#define SCLogWarning(...)
Macro used to log WARNING messages.
Definition: util-debug.h:262
TmModuleReceivePcapFileRegister
void TmModuleReceivePcapFileRegister(void)
Definition: source-pcap-file.c:117
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:325
SC_ATOMIC_SUB
#define SC_ATOMIC_SUB(name, val)
sub a value from our atomic variable
Definition: util-atomic.h:341
PcapFileInstallCaptureHooks
void PcapFileInstallCaptureHooks(void)
Definition: source-pcap-file-helper.c:440
source-pcap-file-helper.h
Packet_
Definition: decode.h:515
TM_FLAG_DECODE_TM
#define TM_FLAG_DECODE_TM
Definition: tm-modules.h:33
tmm_modules
TmModule tmm_modules[TMM_SIZE]
Definition: tm-modules.c:29
TMM_DECODEPCAPFILE
@ TMM_DECODEPCAPFILE
Definition: tm-threads-common.h:41
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:209
PcapFileThreadVars_::shared
PcapFileSharedVars shared
Definition: source-pcap-file.c:58
conf.h
TmSlot_
Definition: tm-threads.h:53
PcapFileFileVars_
Definition: source-pcap-file-helper.h:77
TmEcode
TmEcode
Definition: tm-threads-common.h:80
max_pending_packets
uint32_t max_pending_packets
Definition: suricata.c:187
PcapIncreaseInvalidChecksum
void PcapIncreaseInvalidChecksum(void)
Definition: source-pcap-file.c:508
TmModule_::name
const char * name
Definition: tm-modules.h:48
PcapFileBehaviorVar_::file
PcapFileFileVars * file
Definition: source-pcap-file.c:47
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:232
TM_FLAG_RECEIVE_TM
#define TM_FLAG_RECEIVE_TM
Definition: tm-modules.h:32
CHECKSUM_INVALID_RATIO
#define CHECKSUM_INVALID_RATIO
Definition: util-checksum.h:36
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:34
PcapFileSharedVars_::bpf_string
char * bpf_string
Definition: source-pcap-file-helper.h:50
PcapFileDirectoryVars_::directory
DIR * directory
Definition: source-pcap-file-directory-helper.h:43
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:848
PcapFileThreadVars_
Definition: source-pcap-file.c:54
flow-manager.h
suricata-common.h
PKT_SRC_FFR
@ PKT_SRC_FFR
Definition: decode.h:58
CleanupPcapFileDirectoryVars
void CleanupPcapFileDirectoryVars(PcapFileDirectoryVars *ptv)
Definition: source-pcap-file-directory-helper.c:109
TmModule_::ThreadInit
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:51
PcapDirectoryDispatch
TmEcode PcapDirectoryDispatch(PcapFileDirectoryVars *ptv)
Definition: source-pcap-file-directory-helper.c:480
SCStrdup
#define SCStrdup(s)
Definition: util-mem.h:56
EngineStop
void EngineStop(void)
make sure threads can stop the engine by calling this function. Purpose: pcap file mode needs to be a...
Definition: suricata.c:492
PcapFileSharedVars_::tenant_id
uint32_t tenant_id
Definition: source-pcap-file-helper.h:52
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:33
ParseSizeStringU32
int ParseSizeStringU32(const char *size, uint32_t *res)
Definition: util-misc.c:174
TmModule_::ThreadExitPrintStats
void(* ThreadExitPrintStats)(ThreadVars *, void *)
Definition: tm-modules.h:52
PcapFileSharedVars_::last_processed
struct timespec last_processed
Definition: source-pcap-file-helper.h:54
str
#define str(s)
Definition: suricata-common.h:316
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
PcapFileGlobalVars_::conf_checksum_mode
ChecksumValidationMode conf_checksum_mode
Definition: source-pcap-file-helper.h:39
SCFree
#define SCFree(p)
Definition: util-mem.h:61
Packet_::pkt_src
uint8_t pkt_src
Definition: decode.h:625
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:994
PcapFileDirectoryVars_::delay
time_t delay
Definition: source-pcap-file-directory-helper.h:47
PcapFileDirectoryVars_::shared
PcapFileSharedVars * shared
Definition: source-pcap-file-directory-helper.h:52
PcapFileDirectoryVars_::should_loop
bool should_loop
Definition: source-pcap-file-directory-helper.h:45
DecodeThreadVarsAlloc
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
Definition: decode.c:830
UnixSocketPcapFile
TmEcode UnixSocketPcapFile(TmEcode tm, struct timespec *last_processed)
Definition: runmode-unix-socket.c:569
PcapFileGlobalInit
void PcapFileGlobalInit(void)
Definition: source-pcap-file.c:147
suricata.h
PcapFileDirectoryVars_::filename
char * filename
Definition: source-pcap-file-directory-helper.h:42
PcapFileParseDeleteMode
PcapFileDeleteMode PcapFileParseDeleteMode(void)
Definition: source-pcap-file-helper.c:445
TmSlot_::slot_next
struct TmSlot_ * slot_next
Definition: tm-threads.h:62
PcapFileSharedVars_::bytes
uint64_t bytes
Definition: source-pcap-file-helper.h:63
PcapFileBehaviorVar_
Definition: source-pcap-file.c:45
SC_ATOMIC_GET
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:375
util-misc.h
CleanupPcapFileFileVars
void CleanupPcapFileFileVars(PcapFileFileVars *pfv)
Definition: source-pcap-file-helper.c:67
PcapFileSharedVars_::tv
ThreadVars * tv
Definition: source-pcap-file-helper.h:58
SCLogNotice
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Definition: util-debug.h:250
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:288
PcapFileSharedVars_::delete_mode
PcapFileDeleteMode delete_mode
Definition: source-pcap-file-helper.h:56
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:109
PcapFileFileVars_::cleanup_requested
bool cleanup_requested
Definition: source-pcap-file-helper.h:92
TmModule_::flags
uint8_t flags
Definition: tm-modules.h:80
PcapFileGlobalVars_::read_buffer_size
uint32_t read_buffer_size
Definition: source-pcap-file-helper.h:42
PcapFileSharedVars_::pkts
uint64_t pkts
Definition: source-pcap-file-helper.h:62
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:798