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 
37 extern uint32_t max_pending_packets;
39 
40 /**
41  * Union determining whether the behavior of the thread is file or directory
42  */
43 typedef union PcapFileBehaviorVar_
44 {
48 
49 /**
50  * Data specific to the thread
51  */
52 typedef struct PcapFileThreadVars_
53 {
56 
59 
60 static TmEcode ReceivePcapFileLoop(ThreadVars *, void *, void *);
61 static TmEcode ReceivePcapFileThreadInit(ThreadVars *, const void *, void **);
62 static void ReceivePcapFileThreadExitStats(ThreadVars *, void *);
63 static TmEcode ReceivePcapFileThreadDeinit(ThreadVars *, void *);
64 
65 static TmEcode DecodePcapFile(ThreadVars *, Packet *, void *);
66 static TmEcode DecodePcapFileThreadInit(ThreadVars *, const void *, void **);
67 static TmEcode DecodePcapFileThreadDeinit(ThreadVars *tv, void *data);
68 
69 static void CleanupPcapDirectoryFromThreadVars(PcapFileThreadVars *tv,
71 static void CleanupPcapFileFromThreadVars(PcapFileThreadVars *tv, PcapFileFileVars *pfv);
72 static void CleanupPcapFileThreadVars(PcapFileThreadVars *tv);
73 static TmEcode PcapFileExit(TmEcode status, struct timespec *last_processed);
74 
75 void CleanupPcapFileFromThreadVars(PcapFileThreadVars *tv, PcapFileFileVars *pfv)
76 {
78  if (tv->is_directory == 0) {
79  tv->behavior.file = NULL;
80  }
81 }
82 
83 void CleanupPcapDirectoryFromThreadVars(PcapFileThreadVars *tv, PcapFileDirectoryVars *ptv)
84 {
86  if (tv->is_directory == 1) {
87  tv->behavior.directory = NULL;
88  }
89 }
90 
91 void CleanupPcapFileThreadVars(PcapFileThreadVars *ptv)
92 {
93  if (ptv != NULL) {
94  if (ptv->is_directory == 0) {
95  if (ptv->behavior.file != NULL) {
96  CleanupPcapFileFromThreadVars(ptv, ptv->behavior.file);
97  }
98  ptv->behavior.file = NULL;
99  } else {
100  if (ptv->behavior.directory != NULL) {
101  CleanupPcapDirectoryFromThreadVars(ptv, ptv->behavior.directory);
102  }
103  ptv->behavior.directory = NULL;
104  }
105  if (ptv->shared.bpf_string != NULL) {
106  SCFree(ptv->shared.bpf_string);
107  ptv->shared.bpf_string = NULL;
108  }
109  SCFree(ptv);
110  }
111 }
112 
113 /**
114  * Pcap File Functionality
115  */
117 {
118  tmm_modules[TMM_RECEIVEPCAPFILE].name = "ReceivePcapFile";
119  tmm_modules[TMM_RECEIVEPCAPFILE].ThreadInit = ReceivePcapFileThreadInit;
121  tmm_modules[TMM_RECEIVEPCAPFILE].PktAcqLoop = ReceivePcapFileLoop;
123  tmm_modules[TMM_RECEIVEPCAPFILE].ThreadExitPrintStats = ReceivePcapFileThreadExitStats;
124  tmm_modules[TMM_RECEIVEPCAPFILE].ThreadDeinit = ReceivePcapFileThreadDeinit;
127 }
128 
130 {
131  tmm_modules[TMM_DECODEPCAPFILE].name = "DecodePcapFile";
132  tmm_modules[TMM_DECODEPCAPFILE].ThreadInit = DecodePcapFileThreadInit;
133  tmm_modules[TMM_DECODEPCAPFILE].Func = DecodePcapFile;
135  tmm_modules[TMM_DECODEPCAPFILE].ThreadDeinit = DecodePcapFileThreadDeinit;
138 }
139 
140 #define PCAP_FILE_BUFFER_SIZE_DEFAULT 131072U // 128 KiB
141 #define PCAP_FILE_BUFFER_SIZE_MIN 4096U // 4 KiB
142 #define PCAP_FILE_BUFFER_SIZE_MAX 67108864U // 64MiB
143 
145 {
146  memset(&pcap_g, 0x00, sizeof(pcap_g));
147  SC_ATOMIC_INIT(pcap_g.invalid_checksums);
148 
149 #if defined(HAVE_SETVBUF) && defined(OS_LINUX)
151 
152  const char *str = NULL;
153  if (ConfGet("pcap-file.buffer-size", &str) == 1) {
154  uint32_t value = 0;
155  if (ParseSizeStringU32(str, &value) < 0) {
156  SCLogWarning("failed to parse pcap-file.buffer-size %s", str);
157  }
158  if (value >= PCAP_FILE_BUFFER_SIZE_MIN && value <= PCAP_FILE_BUFFER_SIZE_MAX) {
159  SCLogInfo("Pcap-file will use %u buffer size", value);
160  pcap_g.read_buffer_size = value;
161  } else {
162  SCLogWarning("pcap-file.buffer-size value of %u is invalid. Valid range is %u-%u",
164  }
165  }
166 #endif
167 }
168 
169 TmEcode PcapFileExit(TmEcode status, struct timespec *last_processed)
170 {
172  status = UnixSocketPcapFile(status, last_processed);
173  SCReturnInt(status);
174  } else {
175  EngineStop();
176  SCReturnInt(status);
177  }
178 }
179 
180 TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot)
181 {
182  SCEnter();
183 
184  if(unlikely(data == NULL)) {
185  SCLogError("pcap file reader thread failed to initialize");
186 
187  PcapFileExit(TM_ECODE_FAILED, NULL);
188 
190  }
191 
192  TmEcode status = TM_ECODE_OK;
193  PcapFileThreadVars *ptv = (PcapFileThreadVars *) data;
194  TmSlot *s = (TmSlot *)slot;
195 
196  ptv->shared.slot = s->slot_next;
198 
199  // Indicate that the thread is actually running its application level code (i.e., it can poll
200  // packets)
202 
203  if(ptv->is_directory == 0) {
204  SCLogInfo("Starting file run for %s", ptv->behavior.file->filename);
205  status = PcapFileDispatch(ptv->behavior.file);
206  CleanupPcapFileFromThreadVars(ptv, ptv->behavior.file);
207  } else {
208  SCLogInfo("Starting directory run for %s", ptv->behavior.directory->filename);
210  CleanupPcapDirectoryFromThreadVars(ptv, ptv->behavior.directory);
211  }
212 
213  SCLogDebug("Pcap file loop complete with status %u", status);
214 
215  status = PcapFileExit(status, &ptv->shared.last_processed);
216  SCReturnInt(status);
217 }
218 
219 TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **data)
220 {
221  SCEnter();
222 
223  TmEcode status = TM_ECODE_OK;
224  const char *tmpstring = NULL;
225  const char *tmp_bpf_string = NULL;
226 
227  if (initdata == NULL) {
228  SCLogError("error: initdata == NULL");
229 
231  }
232 
234  if (unlikely(ptv == NULL)) {
236  }
237  memset(&ptv->shared.last_processed, 0, sizeof(struct timespec));
238 
239  intmax_t tenant = 0;
240  if (ConfGetInt("pcap-file.tenant-id", &tenant) == 1) {
241  if (tenant > 0 && tenant < UINT_MAX) {
242  ptv->shared.tenant_id = (uint32_t)tenant;
243  SCLogInfo("tenant %u", ptv->shared.tenant_id);
244  } else {
245  SCLogError("tenant out of range");
246  }
247  }
248 
249  if (ConfGet("bpf-filter", &(tmp_bpf_string)) != 1) {
250  SCLogDebug("could not get bpf or none specified");
251  } else {
252  ptv->shared.bpf_string = SCStrdup(tmp_bpf_string);
253  if (unlikely(ptv->shared.bpf_string == NULL)) {
254  SCLogError("Failed to allocate bpf_string");
255 
256  CleanupPcapFileThreadVars(ptv);
257 
259  }
260  }
261 
262  int should_delete = 0;
263  ptv->shared.should_delete = false;
264  if (ConfGetBool("pcap-file.delete-when-done", &should_delete) == 1) {
265  ptv->shared.should_delete = should_delete == 1;
266  }
267 
268  DIR *directory = NULL;
269  SCLogDebug("checking file or directory %s", (char*)initdata);
270  if(PcapDetermineDirectoryOrFile((char *)initdata, &directory) == TM_ECODE_FAILED) {
271  CleanupPcapFileThreadVars(ptv);
273  }
274 
275  if(directory == NULL) {
276  SCLogDebug("argument %s was a file", (char *)initdata);
277  const size_t toalloc = sizeof(PcapFileFileVars) + pcap_g.read_buffer_size;
278  PcapFileFileVars *pv = SCCalloc(1, toalloc);
279  if (unlikely(pv == NULL)) {
280  SCLogError("Failed to allocate file vars");
281  CleanupPcapFileThreadVars(ptv);
283  }
284 
285  pv->filename = SCStrdup((char *)initdata);
286  if (unlikely(pv->filename == NULL)) {
287  SCLogError("Failed to allocate filename");
289  CleanupPcapFileThreadVars(ptv);
291  }
292 
293  pv->shared = &ptv->shared;
294  status = InitPcapFile(pv);
295  if(status == TM_ECODE_OK) {
296  ptv->is_directory = 0;
297  ptv->behavior.file = pv;
298  } else {
299  SCLogWarning("Failed to init pcap file %s, skipping", pv->filename);
301  CleanupPcapFileThreadVars(ptv);
303  }
304  } else {
305  SCLogInfo("Argument %s was a directory", (char *)initdata);
307  if (unlikely(pv == NULL)) {
308  SCLogError("Failed to allocate directory vars");
309  closedir(directory);
310  CleanupPcapFileThreadVars(ptv);
312  }
313 
314  pv->filename = SCStrdup((char*)initdata);
315  if (unlikely(pv->filename == NULL)) {
316  SCLogError("Failed to allocate filename");
317  closedir(directory);
319  CleanupPcapFileThreadVars(ptv);
321  }
322  pv->cur_dir_depth = 0;
323 
324  int should_recurse;
325  pv->should_recurse = false;
326  if (ConfGetBool("pcap-file.recursive", &should_recurse) == 1) {
327  pv->should_recurse = (should_recurse == 1);
328  }
329 
330  int should_loop = 0;
331  pv->should_loop = false;
332  if (ConfGetBool("pcap-file.continuous", &should_loop) == 1) {
333  pv->should_loop = (should_loop == 1);
334  }
335 
336  if (pv->should_recurse == true && pv->should_loop == true) {
337  SCLogError("Error, --pcap-file-continuous and --pcap-file-recursive "
338  "cannot be used together.");
339  closedir(directory);
341  CleanupPcapFileThreadVars(ptv);
343  }
344 
345  pv->delay = 30;
346  intmax_t delay = 0;
347  if (ConfGetInt("pcap-file.delay", &delay) == 1) {
348  if (delay > 0 && delay < UINT_MAX) {
349  pv->delay = (time_t)delay;
350  SCLogDebug("delay %lu", pv->delay);
351  } else {
352  SCLogError("delay out of range");
353  }
354  }
355 
356  pv->poll_interval = 5;
357  intmax_t poll_interval = 0;
358  if (ConfGetInt("pcap-file.poll-interval", &poll_interval) == 1) {
359  if (poll_interval > 0 && poll_interval < UINT_MAX) {
360  pv->poll_interval = (time_t)poll_interval;
361  SCLogDebug("poll-interval %lu", pv->delay);
362  } else {
363  SCLogError("poll-interval out of range");
364  }
365  }
366 
367  pv->shared = &ptv->shared;
368  pv->directory = directory;
369  TAILQ_INIT(&pv->directory_content);
370 
371  ptv->is_directory = 1;
372  ptv->behavior.directory = pv;
373  }
374 
375  if (ConfGet("pcap-file.checksum-checks", &tmpstring) != 1) {
377  } else {
378  if (strcmp(tmpstring, "auto") == 0) {
380  } else if (ConfValIsTrue(tmpstring)){
382  } else if (ConfValIsFalse(tmpstring)) {
384  }
385  }
387 
388  ptv->shared.tv = tv;
389  *data = (void *)ptv;
390 
392 }
393 
394 void ReceivePcapFileThreadExitStats(ThreadVars *tv, void *data)
395 {
396  SCEnter();
397  if(data != NULL) {
398  PcapFileThreadVars *ptv = (PcapFileThreadVars *)data;
399 
402  SC_ATOMIC_GET(pcap_g.invalid_checksums)) {
403  uint64_t chrate = pcap_g.cnt / SC_ATOMIC_GET(pcap_g.invalid_checksums);
404  if (chrate < CHECKSUM_INVALID_RATIO)
405  SCLogWarning("1/%" PRIu64 "th of packets have an invalid checksum,"
406  " consider setting pcap-file.checksum-checks variable to no"
407  " or use '-k none' option on command line.",
408  chrate);
409  else
410  SCLogInfo("1/%" PRIu64 "th of packets have an invalid checksum",
411  chrate);
412  }
413  SCLogNotice("read %" PRIu64 " file%s, %" PRIu64 " packets, %" PRIu64 " bytes",
414  ptv->shared.files, ptv->shared.files == 1 ? "" : "s", ptv->shared.pkts,
415  ptv->shared.bytes);
416  }
417 }
418 
419 TmEcode ReceivePcapFileThreadDeinit(ThreadVars *tv, void *data)
420 {
421  SCEnter();
422  if(data != NULL) {
423  PcapFileThreadVars *ptv = (PcapFileThreadVars *) data;
424  CleanupPcapFileThreadVars(ptv);
425  }
427 }
428 
429 static TmEcode DecodePcapFile(ThreadVars *tv, Packet *p, void *data)
430 {
431  SCEnter();
433 
435 
436  /* update counters */
438 
439  DecoderFunc decoder;
440  if(ValidateLinkType(p->datalink, &decoder) == TM_ECODE_OK) {
441 
442  /* call the decoder */
443  decoder(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
444 
445 #ifdef DEBUG
447 #endif
448 
450 
452  } else {
454  }
455 }
456 
457 TmEcode DecodePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **data)
458 {
459  SCEnter();
460  DecodeThreadVars *dtv = NULL;
462 
463  if (dtv == NULL)
465 
467 
468  *data = (void *)dtv;
469 
471 }
472 
473 TmEcode DecodePcapFileThreadDeinit(ThreadVars *tv, void *data)
474 {
475  if (data != NULL)
476  DecodeThreadVarsFree(tv, data);
478 }
479 
481 {
482  (void) SC_ATOMIC_ADD(pcap_g.invalid_checksums, 1);
483 }
484 
485 /* eof */
TmModule_::cap_flags
uint8_t cap_flags
Definition: tm-modules.h:73
PcapFileSharedVars_::slot
TmSlot * slot
Definition: source-pcap-file-helper.h:52
ConfGetInt
int ConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:399
PcapFileThreadVars_::is_directory
bool is_directory
Definition: source-pcap-file.c:55
PcapFileDispatch
TmEcode PcapFileDispatch(PcapFileFileVars *ptv)
Main PCAP file reading Loop function.
Definition: source-pcap-file-helper.c:126
PcapFileFileVars_::filename
char * filename
Definition: source-pcap-file-helper.h:71
PcapFileSharedVars_
Definition: source-pcap-file-helper.h:42
PCAP_FILE_BUFFER_SIZE_MAX
#define PCAP_FILE_BUFFER_SIZE_MAX
Definition: source-pcap-file.c:142
TAILQ_INIT
#define TAILQ_INIT(head)
Definition: queue.h:262
PcapFileGlobalVars_
Definition: source-pcap-file-helper.h:30
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:251
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1317
ConfGetBool
int ConfGetBool(const char *name, int *val)
Retrieve a configuration value as a boolean.
Definition: conf.c:482
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
PcapFileBehaviorVar
union PcapFileBehaviorVar_ PcapFileBehaviorVar
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
TmThreadsSetFlag
void TmThreadsSetFlag(ThreadVars *tv, uint32_t flag)
Set a thread flag.
Definition: tm-threads.c:101
util-checksum.h
TM_ECODE_DONE
@ TM_ECODE_DONE
Definition: tm-threads-common.h:82
PcapFileThreadVars
struct PcapFileThreadVars_ PcapFileThreadVars
PcapFileSharedVars_::should_delete
bool should_delete
Definition: source-pcap-file-helper.h:49
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:1140
CHECKSUM_SAMPLE_COUNT
#define CHECKSUM_SAMPLE_COUNT
Definition: util-checksum.h:35
PCAP_FILE_BUFFER_SIZE_DEFAULT
#define PCAP_FILE_BUFFER_SIZE_DEFAULT
Definition: source-pcap-file.c:140
PcapFileBehaviorVar_::directory
PcapFileDirectoryVars * directory
Definition: source-pcap-file.c:45
PcapFileFileVars
struct PcapFileFileVars_ PcapFileFileVars
PcapFileSharedVars_::cb_result
int cb_result
Definition: source-pcap-file-helper.h:63
CHECKSUM_VALIDATION_DISABLE
@ CHECKSUM_VALIDATION_DISABLE
Definition: decode.h:42
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:206
PcapFileDirectoryVars_::poll_interval
time_t poll_interval
Definition: source-pcap-file-directory-helper.h:49
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:81
runmode-unix-socket.h
PcapFileSharedVars_::files
uint64_t files
Definition: source-pcap-file-helper.h:57
ConfValIsTrue
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:536
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:54
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:80
TmModule_::ThreadDeinit
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
Definition: tm-modules.h:49
Packet_::datalink
int datalink
Definition: decode.h:605
TmModuleDecodePcapFileRegister
void TmModuleDecodePcapFileRegister(void)
Definition: source-pcap-file.c:129
CHECKSUM_VALIDATION_ENABLE
@ CHECKSUM_VALIDATION_ENABLE
Definition: decode.h:43
ConfGet
int ConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
Definition: conf.c:335
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:602
CHECKSUM_VALIDATION_AUTO
@ CHECKSUM_VALIDATION_AUTO
Definition: decode.h:44
PcapFileGlobalVars_::cnt
uint64_t cnt
Definition: source-pcap-file-helper.h:31
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:51
pcap_g
PcapFileGlobalVars pcap_g
Definition: source-pcap-file.c:38
TmModule_::PktAcqBreakLoop
TmEcode(* PktAcqBreakLoop)(ThreadVars *, void *)
Definition: tm-modules.h:57
PcapFileDirectoryVars_
Definition: source-pcap-file-directory-helper.h:41
TMM_RECEIVEPCAPFILE
@ TMM_RECEIVEPCAPFILE
Definition: tm-threads-common.h:39
PcapFileGlobalVars_::checksum_mode
ChecksumValidationMode checksum_mode
Definition: source-pcap-file-helper.h:33
SCEnter
#define SCEnter(...)
Definition: util-debug.h:271
GET_PKT_DATA
#define GET_PKT_DATA(p)
Definition: decode.h:205
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
PcapFileThreadVars_::behavior
PcapFileBehaviorVar behavior
Definition: source-pcap-file.c:54
TmModule_::Func
TmEcode(* Func)(ThreadVars *, Packet *, void *)
Definition: tm-modules.h:52
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:196
source-pcap-file-directory-helper.h
RunModeUnixSocketIsActive
int RunModeUnixSocketIsActive(void)
Definition: runmode-unix-socket.c:1717
SCLogWarning
#define SCLogWarning(...)
Macro used to log WARNING messages.
Definition: util-debug.h:249
TmModuleReceivePcapFileRegister
void TmModuleReceivePcapFileRegister(void)
Definition: source-pcap-file.c:116
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:300
source-pcap-file-helper.h
Packet_
Definition: decode.h:473
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:204
PcapFileThreadVars_::shared
PcapFileSharedVars shared
Definition: source-pcap-file.c:57
conf.h
TmSlot_
Definition: tm-threads.h:53
PcapFileFileVars_
Definition: source-pcap-file-helper.h:70
TmEcode
TmEcode
Definition: tm-threads-common.h:79
max_pending_packets
uint32_t max_pending_packets
Definition: suricata.c:180
PcapIncreaseInvalidChecksum
void PcapIncreaseInvalidChecksum(void)
Definition: source-pcap-file.c:480
TmModule_::name
const char * name
Definition: tm-modules.h:44
PcapFileBehaviorVar_::file
PcapFileFileVars * file
Definition: source-pcap-file.c:46
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:224
PCAP_FILE_BUFFER_SIZE_MIN
#define PCAP_FILE_BUFFER_SIZE_MIN
Definition: source-pcap-file.c:141
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:33
PcapFileSharedVars_::bpf_string
char * bpf_string
Definition: source-pcap-file-helper.h:43
PcapFileDirectoryVars_::directory
DIR * directory
Definition: source-pcap-file-directory-helper.h:43
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:791
PcapFileThreadVars_
Definition: source-pcap-file.c:53
flow-manager.h
suricata-common.h
PKT_SRC_FFR
@ PKT_SRC_FFR
Definition: decode.h:57
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:47
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:446
PcapFileSharedVars_::tenant_id
uint32_t tenant_id
Definition: source-pcap-file-helper.h:45
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
ParseSizeStringU32
int ParseSizeStringU32(const char *size, uint32_t *res)
Definition: util-misc.c:173
TmModule_::ThreadExitPrintStats
void(* ThreadExitPrintStats)(ThreadVars *, void *)
Definition: tm-modules.h:48
PcapFileSharedVars_::last_processed
struct timespec last_processed
Definition: source-pcap-file-helper.h:47
str
#define str(s)
Definition: suricata-common.h:291
PcapFileDirectoryVars_::cur_dir_depth
uint8_t cur_dir_depth
Definition: source-pcap-file-directory-helper.h:47
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
PcapFileGlobalVars_::conf_checksum_mode
ChecksumValidationMode conf_checksum_mode
Definition: source-pcap-file-helper.h:32
SCFree
#define SCFree(p)
Definition: util-mem.h:61
Packet_::pkt_src
uint8_t pkt_src
Definition: decode.h:577
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:929
PcapFileDirectoryVars_::delay
time_t delay
Definition: source-pcap-file-directory-helper.h:48
ConfValIsFalse
int ConfValIsFalse(const char *val)
Check if a value is false.
Definition: conf.c:561
PcapFileDirectoryVars_::shared
PcapFileSharedVars * shared
Definition: source-pcap-file-directory-helper.h:53
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:773
UnixSocketPcapFile
TmEcode UnixSocketPcapFile(TmEcode tm, struct timespec *last_processed)
Definition: runmode-unix-socket.c:568
PcapFileGlobalInit
void PcapFileGlobalInit(void)
Definition: source-pcap-file.c:144
suricata.h
PcapFileDirectoryVars_::filename
char * filename
Definition: source-pcap-file-directory-helper.h:42
TmSlot_::slot_next
struct TmSlot_ * slot_next
Definition: tm-threads.h:62
PcapFileSharedVars_::bytes
uint64_t bytes
Definition: source-pcap-file-helper.h:56
PcapFileBehaviorVar_
Definition: source-pcap-file.c:44
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:39
PcapFileSharedVars_::tv
ThreadVars * tv
Definition: source-pcap-file-helper.h:51
SCLogNotice
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Definition: util-debug.h:237
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:275
TmModule_::flags
uint8_t flags
Definition: tm-modules.h:76
PcapFileGlobalVars_::read_buffer_size
uint32_t read_buffer_size
Definition: source-pcap-file-helper.h:35
PcapFileSharedVars_::pkts
uint64_t pkts
Definition: source-pcap-file-helper.h:55
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:739