suricata
source-pcap-file.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2016 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 (SCConfGet("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", str);
162  }
163  if (value >= PCAP_FILE_BUFFER_SIZE_MIN && value <= PCAP_FILE_BUFFER_SIZE_MAX) {
164  SCLogInfo("Pcap-file will use %u buffer size", value);
165  pcap_g.read_buffer_size = value;
166  } else {
167  SCLogWarning("pcap-file.buffer-size value of %u is invalid. Valid range is %u-%u",
168  value, PCAP_FILE_BUFFER_SIZE_MIN, PCAP_FILE_BUFFER_SIZE_MAX);
169  }
170  }
171 #endif
172 }
173 
174 TmEcode PcapFileExit(TmEcode status, struct timespec *last_processed)
175 {
177  status = UnixSocketPcapFile(status, last_processed);
178  SCReturnInt(status);
179  } else {
180  EngineStop();
181  SCReturnInt(status);
182  }
183 }
184 
185 TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot)
186 {
187  SCEnter();
188 
189  if(unlikely(data == NULL)) {
190  SCLogError("pcap file reader thread failed to initialize");
191 
192  PcapFileExit(TM_ECODE_FAILED, NULL);
193 
195  }
196 
197  TmEcode status = TM_ECODE_OK;
198  PcapFileThreadVars *ptv = (PcapFileThreadVars *) data;
199  TmSlot *s = (TmSlot *)slot;
200 
201  ptv->shared.slot = s->slot_next;
203 
204  // Indicate that the thread is actually running its application level code (i.e., it can poll
205  // packets)
207 
208  if(ptv->is_directory == 0) {
209  SCLogInfo("Starting file run for %s", ptv->behavior.file->filename);
210  /* Hold a reference for the duration of file processing, including
211  * post-dispatch flow draining during EngineStop, so deletion decision
212  * is deferred until all pseudo packets have been processed. */
213  SC_ATOMIC_ADD(ptv->behavior.file->ref_cnt, 1);
214  status = PcapFileDispatch(ptv->behavior.file);
215  } else {
216  SCLogInfo("Starting directory run for %s", ptv->behavior.directory->filename);
218  CleanupPcapDirectoryFromThreadVars(ptv, ptv->behavior.directory);
219  }
220 
221  SCLogDebug("Pcap file loop complete with status %u", status);
222 
223  status = PcapFileExit(status, &ptv->shared.last_processed);
224 
225  /* Release the hold set before dispatch and trigger deferred cleanup
226  * if requested and this was the final reference. */
227  if (ptv->is_directory == 0) {
228  /* Ensure current pfv global is set for any pseudo packets emitted
229  * during EngineStop/flow drain. */
231  uint32_t prev = SC_ATOMIC_SUB(ptv->behavior.file->ref_cnt, 1);
232  if (prev == 1 && ptv->behavior.file->cleanup_requested) {
234  ptv->behavior.file = NULL;
235  }
236  }
237  SCReturnInt(status);
238 }
239 
240 TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **data)
241 {
242  SCEnter();
243 
244  TmEcode status = TM_ECODE_OK;
245  const char *tmpstring = NULL;
246  const char *tmp_bpf_string = NULL;
247 
248  if (initdata == NULL) {
249  SCLogError("error: initdata == NULL");
250 
252  }
253 
255  if (unlikely(ptv == NULL)) {
257  }
258  memset(&ptv->shared.last_processed, 0, sizeof(struct timespec));
259 
260  intmax_t tenant = 0;
261  if (SCConfGetInt("pcap-file.tenant-id", &tenant) == 1) {
262  if (tenant > 0 && tenant < UINT_MAX) {
263  ptv->shared.tenant_id = (uint32_t)tenant;
264  SCLogInfo("tenant %u", ptv->shared.tenant_id);
265  } else {
266  SCLogError("tenant out of range");
267  }
268  }
269 
270  if (SCConfGet("bpf-filter", &(tmp_bpf_string)) != 1) {
271  SCLogDebug("could not get bpf or none specified");
272  } else {
273  ptv->shared.bpf_string = SCStrdup(tmp_bpf_string);
274  if (unlikely(ptv->shared.bpf_string == NULL)) {
275  SCLogError("Failed to allocate bpf_string");
276 
277  CleanupPcapFileThreadVars(ptv);
278 
280  }
281  }
282 
284 
285  DIR *directory = NULL;
286  SCLogDebug("checking file or directory %s", (char*)initdata);
287  if(PcapDetermineDirectoryOrFile((char *)initdata, &directory) == TM_ECODE_FAILED) {
288  CleanupPcapFileThreadVars(ptv);
290  }
291 
292  if(directory == NULL) {
293  SCLogDebug("argument %s was a file", (char *)initdata);
294  const size_t toalloc = sizeof(PcapFileFileVars) + pcap_g.read_buffer_size;
295  PcapFileFileVars *pv = SCCalloc(1, toalloc);
296  if (unlikely(pv == NULL)) {
297  SCLogError("Failed to allocate file vars");
298  CleanupPcapFileThreadVars(ptv);
300  }
301 
302  pv->filename = SCStrdup((char *)initdata);
303  if (unlikely(pv->filename == NULL)) {
304  SCLogError("Failed to allocate filename");
306  CleanupPcapFileThreadVars(ptv);
308  }
309 
310  pv->shared = &ptv->shared;
311  status = InitPcapFile(pv);
312  if(status == TM_ECODE_OK) {
313  ptv->is_directory = 0;
314  ptv->behavior.file = pv;
315  } else {
316  SCLogWarning("Failed to init pcap file %s, skipping", pv->filename);
318  CleanupPcapFileThreadVars(ptv);
320  }
321  } else {
322  SCLogInfo("Argument %s was a directory", (char *)initdata);
324  if (unlikely(pv == NULL)) {
325  SCLogError("Failed to allocate directory vars");
326  closedir(directory);
327  CleanupPcapFileThreadVars(ptv);
329  }
330 
331  pv->filename = SCStrdup((char*)initdata);
332  if (unlikely(pv->filename == NULL)) {
333  SCLogError("Failed to allocate filename");
334  closedir(directory);
336  CleanupPcapFileThreadVars(ptv);
338  }
339 
340  int should_recurse;
341  pv->should_recurse = false;
342  if (SCConfGetBool("pcap-file.recursive", &should_recurse) == 1) {
343  pv->should_recurse = (should_recurse == 1);
344  }
345 
346  int should_loop = 0;
347  pv->should_loop = false;
348  if (SCConfGetBool("pcap-file.continuous", &should_loop) == 1) {
349  pv->should_loop = (should_loop == 1);
350  }
351 
352  if (pv->should_recurse && pv->should_loop) {
353  SCLogError("Error, --pcap-file-continuous and --pcap-file-recursive "
354  "cannot be used together.");
355  closedir(directory);
357  CleanupPcapFileThreadVars(ptv);
359  }
360 
361  pv->delay = 30;
362  intmax_t delay = 0;
363  if (SCConfGetInt("pcap-file.delay", &delay) == 1) {
364  if (delay > 0 && delay < UINT_MAX) {
365  pv->delay = (time_t)delay;
366  SCLogDebug("delay %lu", pv->delay);
367  } else {
368  SCLogError("delay out of range");
369  }
370  }
371 
372  pv->poll_interval = 5;
373  intmax_t poll_interval = 0;
374  if (SCConfGetInt("pcap-file.poll-interval", &poll_interval) == 1) {
375  if (poll_interval > 0 && poll_interval < UINT_MAX) {
376  pv->poll_interval = (time_t)poll_interval;
377  SCLogDebug("poll-interval %lu", pv->delay);
378  } else {
379  SCLogError("poll-interval out of range");
380  }
381  }
382 
383  pv->shared = &ptv->shared;
384  pv->directory = directory;
385  TAILQ_INIT(&pv->directory_content);
386 
387  ptv->is_directory = 1;
388  ptv->behavior.directory = pv;
389  }
390 
391  if (SCConfGet("pcap-file.checksum-checks", &tmpstring) != 1) {
393  } else {
394  if (strcmp(tmpstring, "auto") == 0) {
396  } else if (SCConfValIsTrue(tmpstring)) {
398  } else if (SCConfValIsFalse(tmpstring)) {
400  }
401  }
403 
404  ptv->shared.tv = tv;
405  *data = (void *)ptv;
406 
408 }
409 
410 void ReceivePcapFileThreadExitStats(ThreadVars *tv, void *data)
411 {
412  SCEnter();
413  if(data != NULL) {
414  PcapFileThreadVars *ptv = (PcapFileThreadVars *)data;
415 
418  SC_ATOMIC_GET(pcap_g.invalid_checksums)) {
419  uint64_t chrate = pcap_g.cnt / SC_ATOMIC_GET(pcap_g.invalid_checksums);
420  if (chrate < CHECKSUM_INVALID_RATIO)
421  SCLogWarning("1/%" PRIu64 "th of packets have an invalid checksum,"
422  " consider setting pcap-file.checksum-checks variable to no"
423  " or use '-k none' option on command line.",
424  chrate);
425  else
426  SCLogInfo("1/%" PRIu64 "th of packets have an invalid checksum",
427  chrate);
428  }
429  SCLogNotice("read %" PRIu64 " file%s, %" PRIu64 " packets, %" PRIu64 " bytes",
430  ptv->shared.files, ptv->shared.files == 1 ? "" : "s", ptv->shared.pkts,
431  ptv->shared.bytes);
432  }
433 }
434 
435 TmEcode ReceivePcapFileThreadDeinit(ThreadVars *tv, void *data)
436 {
437  SCEnter();
438  if(data != NULL) {
439  PcapFileThreadVars *ptv = (PcapFileThreadVars *) data;
440 
441  if (!ptv->is_directory && ptv->behavior.file != NULL) {
442  CleanupPcapFileFromThreadVars(ptv, ptv->behavior.file);
443  }
444 
445  CleanupPcapFileThreadVars(ptv);
446  }
448 }
449 
450 static TmEcode DecodePcapFile(ThreadVars *tv, Packet *p, void *data)
451 {
452  SCEnter();
454 
456 
457  /* update counters */
459 
460  DecoderFunc decoder;
461  if(ValidateLinkType(p->datalink, &decoder) == TM_ECODE_OK) {
462 
463  /* call the decoder */
464  decoder(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
465 
466 #ifdef DEBUG
468 #endif
469 
471 
473  } else {
475  }
476 }
477 
478 TmEcode DecodePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **data)
479 {
480  SCEnter();
481  DecodeThreadVars *dtv = NULL;
483 
484  if (dtv == NULL)
486 
488 
489  *data = (void *)dtv;
490 
492 }
493 
494 TmEcode DecodePcapFileThreadDeinit(ThreadVars *tv, void *data)
495 {
496  if (data != NULL)
497  DecodeThreadVarsFree(tv, data);
499 }
500 
502 {
503  (void) SC_ATOMIC_ADD(pcap_g.invalid_checksums, 1);
504 }
505 
506 /* eof */
TmModule_::cap_flags
uint8_t cap_flags
Definition: tm-modules.h:77
PcapFileSharedVars_::slot
TmSlot * slot
Definition: source-pcap-file-helper.h:59
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:552
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:320
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1323
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
SCConfGet
int SCConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
Definition: conf.c:351
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:1182
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:498
SCConfValIsFalse
int SCConfValIsFalse(const char *val)
Check if a value is false.
Definition: conf.c:577
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:238
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:635
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:415
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:209
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:317
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:434
source-pcap-file-helper.h
Packet_
Definition: decode.h:501
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:208
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:501
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:842
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:474
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:308
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:611
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:959
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:824
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:439
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:102
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:792