Go to the documentation of this file.
44 "Multi-threaded pcap live mode. Packets from each flow are assigned to a consistent "
48 "Workers pcap live mode, each thread does all"
49 " tasks from acquisition to logging",
53 static void PcapDerefConfig(
void *conf)
62 static void *ParsePcapConfig(
const char *iface)
64 const char *threadsstr = NULL;
84 memset(aconf, 0x00,
sizeof(*aconf));
89 if ((
ConfGetInt(
"pcap.buffer-size", &value)) == 1) {
90 if (value >= 0 && value <= INT_MAX) {
91 SCLogInfo(
"Pcap will use %d buffer size", (
int)value);
95 "value of %" PRIiMAX
" is invalid. Valid range is "
103 if ((
ConfGet(
"bpf-filter", &tmpbpf)) == 1) {
113 if (pcap_node == NULL) {
114 SCLogInfo(
"Unable to find pcap config using default value");
122 if (if_root == NULL && if_default == NULL) {
123 SCLogInfo(
"Unable to find pcap config for "
124 "interface %s, using default value",
130 if (if_root == NULL) {
131 if_root = if_default;
138 if (threadsstr != NULL) {
141 "pcap.threads: %s, resetting to 1",
153 const char *s_limit = NULL;
156 if (ret == 1 && s_limit) {
160 SCLogError(
"Failed to parse pcap buffer size: %s", s_limit);
164 if (bsize == (uint64_t)((uint64_t)INT_MAX + (uint64_t)1))
165 bsize = (uint64_t)INT_MAX;
167 if (bsize > INT_MAX) {
168 SCLogError(
"Failed to set pcap buffer size: 2gb max. %" PRIu64
" > %d", bsize,
180 SCLogDebug(
"could not get bpf or none specified");
185 SCLogInfo(
"BPF filter set from command line or via old 'bpf-filter' option.");
189 if (strcmp(tmpctype,
"auto") == 0) {
202 SCLogDebug(
"could not get promisc or none specified");
209 SCLogDebug(
"could not get snaplen or none specified");
210 }
else if (snaplen < INT_MIN || snaplen > INT_MAX) {
211 SCLogDebug(
"snaplen value is not in the accepted range");
219 static int PcapConfigGeThreadsCount(
void *conf)
231 const char *live_dev = NULL;
237 (void)
ConfGet(
"pcap.single-pcap-dev", &live_dev);
240 PcapConfigGeThreadsCount,
248 SCLogDebug(
"RunModeIdsPcapSingle initialised");
271 const char *live_dev = NULL;
276 (void)
ConfGet(
"pcap.single-pcap-dev", &live_dev);
284 SCLogDebug(
"RunModeIdsPcapAutoFp initialised");
298 const char *live_dev = NULL;
303 (void)
ConfGet(
"pcap.single-pcap-dev", &live_dev);
311 SCLogDebug(
"RunModeIdsPcapWorkers initialised");
const char * thread_name_workers
int ConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
int RunModeSetLiveCaptureWorkers(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
#define SC_ATOMIC_INIT(name)
wrapper for initializing an atomic variable.
int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, int *val)
int ParseSizeStringU64(const char *size, uint64_t *res)
ConfNode * ConfGetNode(const char *name)
Get a ConfNode by name.
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
const char * thread_name_autofp
@ CHECKSUM_VALIDATION_DISABLE
int StringParseInt32(int32_t *res, int base, size_t len, const char *str)
int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, intmax_t *val)
const char * thread_name_single
int ConfValIsTrue(const char *val)
Check if a value is true.
size_t strlcpy(char *dst, const char *src, size_t siz)
int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
@ CHECKSUM_VALIDATION_ENABLE
int ConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
@ CHECKSUM_VALIDATION_AUTO
void RunModeRegisterNewRunMode(enum RunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void), int(*RunModeIsIPSEnabled)(void))
Registers a new runmode.
ConfNode * ConfFindDeviceConfig(ConfNode *node, const char *iface)
Find the configuration node for a specific device.
int RunModeIdsPcapSingle(void)
Single thread version of the Pcap live processing.
int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, const char **vptr)
#define SCLogWarning(...)
Macro used to log WARNING messages.
#define SC_ATOMIC_SUB(name, val)
sub a value from our atomic variable
void(* DerefFunc)(void *)
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
void TimeModeSetLive(void)
void RunModeIdsPcapRegister(void)
char iface[PCAP_IFACE_NAME_LENGTH]
int RunModeIdsPcapAutoFp(void)
RunModIdsPcapAutoFp set up the following thread packet handlers:
#define SCLogError(...)
Macro used to log ERROR messages.
int ConfValIsFalse(const char *val)
Check if a value is false.
int RunModeSetLiveCaptureSingle(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
ChecksumValidationMode checksum_mode
int RunModeIdsPcapWorkers(void)
Workers version of the PCAP LIVE processing.
const char * RunModeIdsGetDefaultMode(void)