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 
35 extern int max_pending_packets;
37 
38 /**
39  * Union determining whether the behavior of the thread is file or directory
40  */
41 typedef union PcapFileBehaviorVar_
42 {
46 
47 /**
48  * Data specific to the thread
49  */
50 typedef struct PcapFileThreadVars_
51 {
54 
57 
58 static TmEcode ReceivePcapFileLoop(ThreadVars *, void *, void *);
59 static TmEcode ReceivePcapFileThreadInit(ThreadVars *, const void *, void **);
60 static void ReceivePcapFileThreadExitStats(ThreadVars *, void *);
61 static TmEcode ReceivePcapFileThreadDeinit(ThreadVars *, void *);
62 
63 static TmEcode DecodePcapFile(ThreadVars *, Packet *, void *);
64 static TmEcode DecodePcapFileThreadInit(ThreadVars *, const void *, void **);
65 static TmEcode DecodePcapFileThreadDeinit(ThreadVars *tv, void *data);
66 
67 static void CleanupPcapDirectoryFromThreadVars(PcapFileThreadVars *tv,
69 static void CleanupPcapFileFromThreadVars(PcapFileThreadVars *tv, PcapFileFileVars *pfv);
70 static void CleanupPcapFileThreadVars(PcapFileThreadVars *tv);
71 static TmEcode PcapFileExit(TmEcode status, struct timespec *last_processed);
72 
73 void CleanupPcapFileFromThreadVars(PcapFileThreadVars *tv, PcapFileFileVars *pfv)
74 {
76  if (tv->is_directory == 0) {
77  tv->behavior.file = NULL;
78  }
79 }
80 
81 void CleanupPcapDirectoryFromThreadVars(PcapFileThreadVars *tv, PcapFileDirectoryVars *ptv)
82 {
84  if (tv->is_directory == 1) {
85  tv->behavior.directory = NULL;
86  }
87 }
88 
89 void CleanupPcapFileThreadVars(PcapFileThreadVars *tv)
90 {
91  if(tv != NULL) {
92  if (tv->is_directory == 0) {
93  if (tv->behavior.file != NULL) {
94  CleanupPcapFileFromThreadVars(tv, tv->behavior.file);
95  }
96  tv->behavior.file = NULL;
97  } else {
98  if (tv->behavior.directory != NULL) {
99  CleanupPcapDirectoryFromThreadVars(tv, tv->behavior.directory);
100  }
101  tv->behavior.directory = NULL;
102  }
103  if (tv->shared.bpf_string != NULL) {
104  SCFree(tv->shared.bpf_string);
105  tv->shared.bpf_string = NULL;
106  }
107  SCFree(tv);
108  }
109 }
110 
111 /**
112  * Pcap File Functionality
113  */
115 {
116  tmm_modules[TMM_RECEIVEPCAPFILE].name = "ReceivePcapFile";
117  tmm_modules[TMM_RECEIVEPCAPFILE].ThreadInit = ReceivePcapFileThreadInit;
119  tmm_modules[TMM_RECEIVEPCAPFILE].PktAcqLoop = ReceivePcapFileLoop;
121  tmm_modules[TMM_RECEIVEPCAPFILE].ThreadExitPrintStats = ReceivePcapFileThreadExitStats;
122  tmm_modules[TMM_RECEIVEPCAPFILE].ThreadDeinit = ReceivePcapFileThreadDeinit;
125 }
126 
128 {
129  tmm_modules[TMM_DECODEPCAPFILE].name = "DecodePcapFile";
130  tmm_modules[TMM_DECODEPCAPFILE].ThreadInit = DecodePcapFileThreadInit;
131  tmm_modules[TMM_DECODEPCAPFILE].Func = DecodePcapFile;
133  tmm_modules[TMM_DECODEPCAPFILE].ThreadDeinit = DecodePcapFileThreadDeinit;
136 }
137 
139 {
140  memset(&pcap_g, 0x00, sizeof(pcap_g));
141  SC_ATOMIC_INIT(pcap_g.invalid_checksums);
142 }
143 
144 TmEcode PcapFileExit(TmEcode status, struct timespec *last_processed)
145 {
147  status = UnixSocketPcapFile(status, last_processed);
148  SCReturnInt(status);
149  } else {
150  EngineStop();
151  SCReturnInt(status);
152  }
153 }
154 
155 TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot)
156 {
157  SCEnter();
158 
159  if(unlikely(data == NULL)) {
160  SCLogError(SC_ERR_INVALID_ARGUMENT, "pcap file reader thread failed to initialize");
161 
162  PcapFileExit(TM_ECODE_FAILED, NULL);
163 
165  }
166 
167  TmEcode status = TM_ECODE_OK;
168  PcapFileThreadVars *ptv = (PcapFileThreadVars *) data;
169  TmSlot *s = (TmSlot *)slot;
170 
171  ptv->shared.slot = s->slot_next;
173 
174  // Indicate that the thread is actually running its application level code (i.e., it can poll
175  // packets)
177 
178  if(ptv->is_directory == 0) {
179  SCLogInfo("Starting file run for %s", ptv->behavior.file->filename);
180  status = PcapFileDispatch(ptv->behavior.file);
181  CleanupPcapFileFromThreadVars(ptv, ptv->behavior.file);
182  } else {
183  SCLogInfo("Starting directory run for %s", ptv->behavior.directory->filename);
185  CleanupPcapDirectoryFromThreadVars(ptv, ptv->behavior.directory);
186  }
187 
188  SCLogDebug("Pcap file loop complete with status %u", status);
189 
190  status = PcapFileExit(status, &ptv->shared.last_processed);
191  SCReturnInt(status);
192 }
193 
194 TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **data)
195 {
196  SCEnter();
197 
198  TmEcode status = TM_ECODE_OK;
199  const char *tmpstring = NULL;
200  const char *tmp_bpf_string = NULL;
201 
202  if (initdata == NULL) {
203  SCLogError(SC_ERR_INVALID_ARGUMENT, "error: initdata == NULL");
204 
206  }
207 
209  if (unlikely(ptv == NULL)) {
211  }
212  memset(ptv, 0, sizeof(PcapFileThreadVars));
213  memset(&ptv->shared.last_processed, 0, sizeof(struct timespec));
214 
215  intmax_t tenant = 0;
216  if (ConfGetInt("pcap-file.tenant-id", &tenant) == 1) {
217  if (tenant > 0 && tenant < UINT_MAX) {
218  ptv->shared.tenant_id = (uint32_t)tenant;
219  SCLogInfo("tenant %u", ptv->shared.tenant_id);
220  } else {
221  SCLogError(SC_ERR_INVALID_ARGUMENT, "tenant out of range");
222  }
223  }
224 
225  if (ConfGet("bpf-filter", &(tmp_bpf_string)) != 1) {
226  SCLogDebug("could not get bpf or none specified");
227  } else {
228  ptv->shared.bpf_string = SCStrdup(tmp_bpf_string);
229  if (unlikely(ptv->shared.bpf_string == NULL)) {
230  SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate bpf_string");
231 
232  CleanupPcapFileThreadVars(ptv);
233 
235  }
236  }
237 
238  int should_delete = 0;
239  ptv->shared.should_delete = false;
240  if (ConfGetBool("pcap-file.delete-when-done", &should_delete) == 1) {
241  ptv->shared.should_delete = should_delete == 1;
242  }
243 
244  DIR *directory = NULL;
245  SCLogDebug("checking file or directory %s", (char*)initdata);
246  if(PcapDetermineDirectoryOrFile((char *)initdata, &directory) == TM_ECODE_FAILED) {
247  CleanupPcapFileThreadVars(ptv);
249  }
250 
251  if(directory == NULL) {
252  SCLogDebug("argument %s was a file", (char *)initdata);
254  if (unlikely(pv == NULL)) {
255  SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate file vars");
256  CleanupPcapFileThreadVars(ptv);
258  }
259  memset(pv, 0, sizeof(PcapFileFileVars));
260 
261  pv->filename = SCStrdup((char *)initdata);
262  if (unlikely(pv->filename == NULL)) {
263  SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate filename");
265  CleanupPcapFileThreadVars(ptv);
267  }
268 
269  pv->shared = &ptv->shared;
270  status = InitPcapFile(pv);
271  if(status == TM_ECODE_OK) {
272  ptv->is_directory = 0;
273  ptv->behavior.file = pv;
274  } else {
276  "Failed to init pcap file %s, skipping", pv->filename);
278  CleanupPcapFileThreadVars(ptv);
280  }
281  } else {
282  SCLogInfo("Argument %s was a directory", (char *)initdata);
284  if (unlikely(pv == NULL)) {
285  SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate directory vars");
286  closedir(directory);
287  CleanupPcapFileThreadVars(ptv);
289  }
290  memset(pv, 0, sizeof(PcapFileDirectoryVars));
291 
292  pv->filename = SCStrdup((char*)initdata);
293  if (unlikely(pv->filename == NULL)) {
294  SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate filename");
296  CleanupPcapFileThreadVars(ptv);
298  }
299  pv->cur_dir_depth = 0;
300 
301  int should_recurse;
302  pv->should_recurse = false;
303  if (ConfGetBool("pcap-file.recursive", &should_recurse) == 1) {
304  pv->should_recurse = (should_recurse == 1);
305  }
306 
307  int should_loop = 0;
308  pv->should_loop = false;
309  if (ConfGetBool("pcap-file.continuous", &should_loop) == 1) {
310  pv->should_loop = (should_loop == 1);
311  }
312 
313  if (pv->should_recurse == true && pv->should_loop == true) {
314  SCLogError(SC_ERR_INVALID_ARGUMENT, "Error, --pcap-file-continuous and --pcap-file-recursive "
315  "cannot be used together.");
317  CleanupPcapFileThreadVars(ptv);
319  }
320 
321  pv->delay = 30;
322  intmax_t delay = 0;
323  if (ConfGetInt("pcap-file.delay", &delay) == 1) {
324  if (delay > 0 && delay < UINT_MAX) {
325  pv->delay = (time_t)delay;
326  SCLogDebug("delay %lu", pv->delay);
327  } else {
328  SCLogError(SC_ERR_INVALID_ARGUMENT, "delay out of range");
329  }
330  }
331 
332  pv->poll_interval = 5;
333  intmax_t poll_interval = 0;
334  if (ConfGetInt("pcap-file.poll-interval", &poll_interval) == 1) {
335  if (poll_interval > 0 && poll_interval < UINT_MAX) {
336  pv->poll_interval = (time_t)poll_interval;
337  SCLogDebug("poll-interval %lu", pv->delay);
338  } else {
339  SCLogError(SC_ERR_INVALID_ARGUMENT, "poll-interval out of range");
340  }
341  }
342 
343  pv->shared = &ptv->shared;
344  pv->directory = directory;
345  TAILQ_INIT(&pv->directory_content);
346 
347  ptv->is_directory = 1;
348  ptv->behavior.directory = pv;
349  }
350 
351  if (ConfGet("pcap-file.checksum-checks", &tmpstring) != 1) {
353  } else {
354  if (strcmp(tmpstring, "auto") == 0) {
356  } else if (ConfValIsTrue(tmpstring)){
358  } else if (ConfValIsFalse(tmpstring)) {
360  }
361  }
363 
364  ptv->shared.tv = tv;
365  *data = (void *)ptv;
366 
368 }
369 
370 void ReceivePcapFileThreadExitStats(ThreadVars *tv, void *data)
371 {
372  SCEnter();
373  if(data != NULL) {
374  PcapFileThreadVars *ptv = (PcapFileThreadVars *)data;
375 
378  SC_ATOMIC_GET(pcap_g.invalid_checksums)) {
379  uint64_t chrate = pcap_g.cnt / SC_ATOMIC_GET(pcap_g.invalid_checksums);
380  if (chrate < CHECKSUM_INVALID_RATIO)
382  "1/%" PRIu64 "th of packets have an invalid checksum,"
383  " consider setting pcap-file.checksum-checks variable to no"
384  " or use '-k none' option on command line.",
385  chrate);
386  else
387  SCLogInfo("1/%" PRIu64 "th of packets have an invalid checksum",
388  chrate);
389  }
390  SCLogNotice(
391  "Pcap-file module read %" PRIu64 " files, %" PRIu64 " packets, %" PRIu64 " bytes",
392  ptv->shared.files,
393  ptv->shared.pkts,
394  ptv->shared.bytes
395  );
396  }
397 }
398 
399 TmEcode ReceivePcapFileThreadDeinit(ThreadVars *tv, void *data)
400 {
401  SCEnter();
402  if(data != NULL) {
403  PcapFileThreadVars *ptv = (PcapFileThreadVars *) data;
404  CleanupPcapFileThreadVars(ptv);
405  }
407 }
408 
409 static TmEcode DecodePcapFile(ThreadVars *tv, Packet *p, void *data)
410 {
411  SCEnter();
413 
415 
416  /* update counters */
418 
419  DecoderFunc decoder;
420  if(ValidateLinkType(p->datalink, &decoder) == TM_ECODE_OK) {
421 
422  /* call the decoder */
423  decoder(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
424 
425 #ifdef DEBUG
427 #endif
428 
430 
432  } else {
434  }
435 }
436 
437 TmEcode DecodePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **data)
438 {
439  SCEnter();
440  DecodeThreadVars *dtv = NULL;
442 
443  if (dtv == NULL)
445 
447 
448  *data = (void *)dtv;
449 
451 }
452 
453 TmEcode DecodePcapFileThreadDeinit(ThreadVars *tv, void *data)
454 {
455  if (data != NULL)
456  DecodeThreadVarsFree(tv, data);
458 }
459 
461 {
462  (void) SC_ATOMIC_ADD(pcap_g.invalid_checksums, 1);
463 }
464 
465 /* eof */
TmModule_::cap_flags
uint8_t cap_flags
Definition: tm-modules.h:67
PcapFileSharedVars_::slot
TmSlot * slot
Definition: source-pcap-file-helper.h:51
ConfGetInt
int ConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:393
PcapFileThreadVars_::is_directory
bool is_directory
Definition: source-pcap-file.c:53
PcapFileDispatch
TmEcode PcapFileDispatch(PcapFileFileVars *ptv)
Main PCAP file reading Loop function.
Definition: source-pcap-file-helper.c:128
PcapFileFileVars_::filename
char * filename
Definition: source-pcap-file-helper.h:70
PcapFileSharedVars_
Definition: source-pcap-file-helper.h:41
max_pending_packets
int max_pending_packets
Definition: suricata.c:177
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:315
source-pcap-file.h
ValidateLinkType
TmEcode ValidateLinkType(int datalink, DecoderFunc *DecoderFn)
Definition: source-pcap-file-helper.c:245
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1058
PcapFileFileVars_::shared
PcapFileSharedVars * shared
Definition: source-pcap-file-helper.h:76
ConfGetBool
int ConfGetBool(const char *name, int *val)
Retrieve a configuration value as an boolen.
Definition: conf.c:473
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
PcapFileBehaviorVar
union PcapFileBehaviorVar_ PcapFileBehaviorVar
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:296
TmThreadsSetFlag
void TmThreadsSetFlag(ThreadVars *tv, uint32_t flag)
Set a thread flag.
Definition: tm-threads.c:98
util-checksum.h
TM_ECODE_DONE
@ TM_ECODE_DONE
Definition: tm-threads-common.h:86
PcapFileThreadVars
struct PcapFileThreadVars_ PcapFileThreadVars
PcapFileSharedVars_::should_delete
bool should_delete
Definition: source-pcap-file-helper.h:48
SC_ATOMIC_ADD
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
Definition: util-atomic.h:333
THV_RUNNING
#define THV_RUNNING
Definition: threadvars.h:54
DecoderFunc
int(* DecoderFunc)(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode.h:880
CHECKSUM_SAMPLE_COUNT
#define CHECKSUM_SAMPLE_COUNT
Definition: util-checksum.h:35
PcapFileBehaviorVar_::directory
PcapFileDirectoryVars * directory
Definition: source-pcap-file.c:43
PcapFileSharedVars_::cb_result
int cb_result
Definition: source-pcap-file-helper.h:62
CHECKSUM_VALIDATION_DISABLE
@ CHECKSUM_VALIDATION_DISABLE
Definition: decode.h:46
PacketDecodeFinalize
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
Definition: decode.c:147
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:85
runmode-unix-socket.h
PcapFileSharedVars_::files
uint64_t files
Definition: source-pcap-file-helper.h:56
ConfValIsTrue
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:522
PcapDetermineDirectoryOrFile
TmEcode PcapDetermineDirectoryOrFile(char *filename, DIR **directory)
Definition: source-pcap-file-directory-helper.c:171
TmModule_::PktAcqLoop
TmEcode(* PktAcqLoop)(ThreadVars *, void *, void *)
Definition: tm-modules.h:54
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:84
TmModule_::ThreadDeinit
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
Definition: tm-modules.h:49
Packet_::datalink
int datalink
Definition: decode.h:607
TmModuleDecodePcapFileRegister
void TmModuleDecodePcapFileRegister(void)
Definition: source-pcap-file.c:127
CHECKSUM_VALIDATION_ENABLE
@ CHECKSUM_VALIDATION_ENABLE
Definition: decode.h:47
ConfGet
int ConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
Definition: conf.c:331
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:528
CHECKSUM_VALIDATION_AUTO
@ CHECKSUM_VALIDATION_AUTO
Definition: decode.h:48
PcapFileGlobalVars_::cnt
uint64_t cnt
Definition: source-pcap-file-helper.h:31
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:54
pcap_g
PcapFileGlobalVars pcap_g
Definition: source-pcap-file.c:36
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:298
GET_PKT_DATA
#define GET_PKT_DATA(p)
Definition: decode.h:219
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
PcapFileThreadVars_::behavior
PcapFileBehaviorVar behavior
Definition: source-pcap-file.c:52
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:200
source-pcap-file-directory-helper.h
RunModeUnixSocketIsActive
int RunModeUnixSocketIsActive(void)
Definition: runmode-unix-socket.c:1716
SC_ERR_INVALID_ARGUMENT
@ SC_ERR_INVALID_ARGUMENT
Definition: util-error.h:43
TmModuleReceivePcapFileRegister
void TmModuleReceivePcapFileRegister(void)
Definition: source-pcap-file.c:114
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:289
source-pcap-file-helper.h
Packet_
Definition: decode.h:428
TM_FLAG_DECODE_TM
#define TM_FLAG_DECODE_TM
Definition: tm-modules.h:32
tmm_modules
TmModule tmm_modules[TMM_SIZE]
Definition: tm-modules.c:33
TMM_DECODEPCAPFILE
@ TMM_DECODEPCAPFILE
Definition: tm-threads-common.h:41
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:218
PcapFileThreadVars_::shared
PcapFileSharedVars shared
Definition: source-pcap-file.c:55
TmSlot_
Definition: tm-threads.h:53
PcapFileFileVars_
Definition: source-pcap-file-helper.h:69
SC_ERR_INVALID_CHECKSUM
@ SC_ERR_INVALID_CHECKSUM
Definition: util-error.h:41
TmEcode
TmEcode
Definition: tm-threads-common.h:83
TmModule_::name
const char * name
Definition: tm-modules.h:44
PcapFileBehaviorVar_::file
PcapFileFileVars * file
Definition: source-pcap-file.c:44
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:215
TM_FLAG_RECEIVE_TM
#define TM_FLAG_RECEIVE_TM
Definition: tm-modules.h:31
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:42
PcapIncreaseInvalidChecksum
void PcapIncreaseInvalidChecksum()
Definition: source-pcap-file.c:460
PcapFileDirectoryVars_::directory
DIR * directory
Definition: source-pcap-file-directory-helper.h:43
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:708
PcapFileThreadVars_
Definition: source-pcap-file.c:51
flow-manager.h
suricata-common.h
PKT_SRC_FFR
@ PKT_SRC_FFR
Definition: decode.h:60
PcapFileGlobalInit
void PcapFileGlobalInit()
Definition: source-pcap-file.c:138
CleanupPcapFileDirectoryVars
void CleanupPcapFileDirectoryVars(PcapFileDirectoryVars *ptv)
Definition: source-pcap-file-directory-helper.c:106
SC_ERR_PCAP_DISPATCH
@ SC_ERR_PCAP_DISPATCH
Definition: util-error.h:50
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:255
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:498
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:428
PcapFileSharedVars_::tenant_id
uint32_t tenant_id
Definition: source-pcap-file-helper.h:44
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
TmModule_::ThreadExitPrintStats
void(* ThreadExitPrintStats)(ThreadVars *, void *)
Definition: tm-modules.h:48
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
PcapFileSharedVars_::last_processed
struct timespec last_processed
Definition: source-pcap-file-helper.h:46
PcapFileDirectoryVars_::cur_dir_depth
uint8_t cur_dir_depth
Definition: source-pcap-file-directory-helper.h:47
PcapFileGlobalVars_::conf_checksum_mode
ChecksumValidationMode conf_checksum_mode
Definition: source-pcap-file-helper.h:32
SCLogWarning
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
Definition: util-debug.h:242
SCFree
#define SCFree(p)
Definition: util-mem.h:61
Packet_::pkt_src
uint8_t pkt_src
Definition: decode.h:579
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:665
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:547
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:689
UnixSocketPcapFile
TmEcode UnixSocketPcapFile(TmEcode tm, struct timespec *last_processed)
Definition: runmode-unix-socket.c:619
SC_ERR_MEM_ALLOC
@ SC_ERR_MEM_ALLOC
Definition: util-error.h:31
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:55
PcapFileBehaviorVar_
Definition: source-pcap-file.c:42
SC_ATOMIC_GET
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:376
CleanupPcapFileFileVars
void CleanupPcapFileFileVars(PcapFileFileVars *pfv)
Definition: source-pcap-file-helper.c:39
PcapFileSharedVars_::tv
ThreadVars * tv
Definition: source-pcap-file-helper.h:50
SCLogNotice
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Definition: util-debug.h:230
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:302
TmModule_::flags
uint8_t flags
Definition: tm-modules.h:70
PcapFileSharedVars_::pkts
uint64_t pkts
Definition: source-pcap-file-helper.h:54
DecodeUpdatePacketCounters
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
Definition: decode.c:655