pcap: add 'promisc' YAML configuration variable

This patch adds a promisc variable to pcap configuration. It is
used to decided if interface is switched to promiscuous mode.
pull/287/merge
Eric Leblond 13 years ago committed by Victor Julien
parent 1aaa828b63
commit e8aa66a44c

@ -93,6 +93,7 @@ void *ParsePcapConfig(const char *iface)
char *tmpbpf;
char *tmpctype;
intmax_t value;
int promisc = 0;
if (unlikely(aconf == NULL)) {
return NULL;
@ -209,6 +210,13 @@ void *ParsePcapConfig(const char *iface)
}
}
aconf->promisc = LIBPCAP_PROMISC;
if (ConfGetChildValueBoolWithDefault(if_root, if_default, "promisc", &promisc) != 1) {
SCLogDebug("could not get promisc or none specified");
} else {
aconf->promisc = promisc;
}
return aconf;
}

@ -415,7 +415,8 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) {
}
}
int pcap_set_promisc_r = pcap_set_promisc(ptv->pcap_handle,LIBPCAP_PROMISC);
/* set Promisc, and Timeout. Must be called before pcap_activate */
int pcap_set_promisc_r = pcap_set_promisc(ptv->pcap_handle, pcapconfig->promisc);
//printf("ReceivePcapThreadInit: pcap_set_promisc(%p) returned %" PRId32 "\n", ptv->pcap_handle, pcap_set_promisc_r);
if (pcap_set_promisc_r != 0) {
SCLogError(SC_ERR_PCAP_SET_PROMISC, "Couldn't set promisc mode, error %s", pcap_geterr(ptv->pcap_handle));

@ -53,6 +53,8 @@ typedef struct PcapIfaceConfig_
int threads;
/* socket buffer size */
int buffer_size;
/* promiscuous value */
int promisc;
/* BPF filter */
char *bpf_filter;
ChecksumValidationMode checksum_mode;

@ -709,6 +709,8 @@ pcap:
# rings. In this case, set up the threads variable to N to start N threads
# listening on the same interface.
#threads: 16
# set to no to disable promiscuous mode:
#promisc: no
# Put default values here
- interface: default
#checksum-checks: auto

Loading…
Cancel
Save