char *tmpctype;
intmax_t value;
int promisc = 0;
+ intmax_t snaplen = 0;
if (unlikely(aconf == NULL)) {
return NULL;
aconf->promisc = promisc;
}
+ aconf->snaplen = 0;
+ if (ConfGetChildValueIntWithDefault(if_root, if_default, "snaplen", &snaplen) != 1) {
+ SCLogDebug("could not get snaplen or none specified");
+ } else {
+ aconf->snaplen = snaplen;
+ }
+
+
return aconf;
}
TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) {
SCEnter();
PcapIfaceConfig *pcapconfig = initdata;
- int mtu;
+ int snaplen;
if (initdata == NULL) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "initdata == NULL");
SCReturnInt(TM_ECODE_FAILED);
}
- /* We only set snaplen if we can get the MTU */
- mtu = GetIfaceMTU(pcapconfig->iface);
- if (mtu > 0) {
- /* set Snaplen, Promisc, and Timeout. Must be called before pcap_activate */
- int pcap_set_snaplen_r = pcap_set_snaplen(ptv->pcap_handle, mtu);
- //printf("ReceivePcapThreadInit: pcap_set_snaplen(%p) returned %" PRId32 "\n", ptv->pcap_handle, pcap_set_snaplen_r);
+ if (pcapconfig->snaplen == 0) {
+ /* We set snaplen if we can get the MTU */
+ snaplen = GetIfaceMTU(pcapconfig->iface);
+ } else {
+ snaplen = pcapconfig->snaplen;
+ }
+ if (snaplen > 0) {
+ /* set Snaplen. Must be called before pcap_activate */
+ int pcap_set_snaplen_r = pcap_set_snaplen(ptv->pcap_handle, snaplen);
if (pcap_set_snaplen_r != 0) {
SCLogError(SC_ERR_PCAP_SET_SNAPLEN, "Couldn't set snaplen, error: %s", pcap_geterr(ptv->pcap_handle));
SCFree(ptv);
pcapconfig->DerefFunc(pcapconfig);
SCReturnInt(TM_ECODE_FAILED);
}
+ SCLogInfo("Set snaplen to %d for '%s'", snaplen, pcapconfig->iface);
}
/* set Promisc, and Timeout. Must be called before pcap_activate */