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",
53static void PcapDerefConfig(
void *conf)
62static void *ParsePcapConfig(
const char *iface)
64 const char *threadsstr = NULL;
84 memset(aconf, 0x00,
sizeof(*aconf));
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 ((
SCConfGet(
"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");
219static int PcapConfigGeThreadsCount(
void *conf)
231 const char *live_dev = NULL;
237 (void)
SCConfGet(
"pcap.single-pcap-dev", &live_dev);
240 PcapConfigGeThreadsCount,
248 SCLogDebug(
"RunModeIdsPcapSingle initialised");
271 const char *live_dev = NULL;
276 (void)
SCConfGet(
"pcap.single-pcap-dev", &live_dev);
284 SCLogDebug(
"RunModeIdsPcapAutoFp initialised");
298 const char *live_dev = NULL;
303 (void)
SCConfGet(
"pcap.single-pcap-dev", &live_dev);
311 SCLogDebug(
"RunModeIdsPcapWorkers initialised");
SCConfNode * SCConfGetNode(const char *name)
Get a SCConfNode by name.
int SCConfValIsTrue(const char *val)
Check if a value is true.
int SCConfGetChildValueWithDefault(const SCConfNode *base, const SCConfNode *dflt, const char *name, const char **vptr)
int SCConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
int SCConfValIsFalse(const char *val)
Check if a value is false.
int SCConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
int SCConfGetChildValueBoolWithDefault(const SCConfNode *base, const SCConfNode *dflt, const char *name, int *val)
int SCConfGetChildValueIntWithDefault(const SCConfNode *base, const SCConfNode *dflt, const char *name, intmax_t *val)
@ CHECKSUM_VALIDATION_AUTO
@ CHECKSUM_VALIDATION_ENABLE
@ CHECKSUM_VALIDATION_DISABLE
void RunModeIdsPcapRegister(void)
int RunModeIdsPcapWorkers(void)
Workers version of the PCAP LIVE processing.
int RunModeIdsPcapSingle(void)
Single thread version of the Pcap live processing.
int RunModeIdsPcapAutoFp(void)
RunModIdsPcapAutoFp set up the following thread packet handlers:
const char * RunModeIdsGetDefaultMode(void)
const char * thread_name_single
void RunModeRegisterNewRunMode(enum SCRunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void), int(*RunModeIsIPSEnabled)(void))
Registers a new runmode.
const char * thread_name_autofp
const char * thread_name_workers
char iface[PCAP_IFACE_NAME_LENGTH]
ChecksumValidationMode checksum_mode
void(* DerefFunc)(void *)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
#define SC_ATOMIC_INIT(name)
wrapper for initializing an atomic variable.
#define SC_ATOMIC_SUB(name, val)
sub a value from our atomic variable
int StringParseInt32(int32_t *res, int base, size_t len, const char *str)
SCConfNode * ConfFindDeviceConfig(SCConfNode *node, const char *iface)
Find the configuration node for a specific device.
#define SCLogWarning(...)
Macro used to log WARNING messages.
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
#define SCLogError(...)
Macro used to log ERROR messages.
int ParseSizeStringU64(const char *size, uint64_t *res)
int RunModeSetLiveCaptureSingle(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
int RunModeSetLiveCaptureWorkers(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
void TimeModeSetLive(void)