pcap: fix "work by luck" code.

remotes/origin/HEAD
Eric Leblond 15 years ago committed by Victor Julien
parent d8d9b0983f
commit 91f42b6f41

@ -472,17 +472,17 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) {
SCReturnInt(TM_ECODE_FAILED); SCReturnInt(TM_ECODE_FAILED);
} }
SCLogInfo("using interface %s", (char *)initdata); SCLogInfo("using interface %s", pcapconfig->iface);
if(strlen(initdata)>PCAP_IFACE_NAME_LENGTH) { if (strlen(pcapconfig->iface) > PCAP_IFACE_NAME_LENGTH) {
SCFree(ptv); SCFree(ptv);
/* Dereference config */ /* Dereference config */
pcapconfig->DerefFunc(pcapconfig); pcapconfig->DerefFunc(pcapconfig);
SCReturnInt(TM_ECODE_FAILED); SCReturnInt(TM_ECODE_FAILED);
} }
strlcpy(ptv->iface, (char *)initdata, PCAP_IFACE_NAME_LENGTH); strlcpy(ptv->iface, pcapconfig->iface, PCAP_IFACE_NAME_LENGTH);
char errbuf[PCAP_ERRBUF_SIZE] = ""; char errbuf[PCAP_ERRBUF_SIZE] = "";
ptv->pcap_handle = pcap_open_live((char *)initdata, LIBPCAP_SNAPLEN, ptv->pcap_handle = pcap_open_live(ptv->iface, LIBPCAP_SNAPLEN,
LIBPCAP_PROMISC, LIBPCAP_COPYWAIT, errbuf); LIBPCAP_PROMISC, LIBPCAP_COPYWAIT, errbuf);
if (ptv->pcap_handle == NULL) { if (ptv->pcap_handle == NULL) {
SCLogError(SC_ERR_PCAP_OPEN_LIVE, "Problem creating pcap handler for live mode, error %s", errbuf); SCLogError(SC_ERR_PCAP_OPEN_LIVE, "Problem creating pcap handler for live mode, error %s", errbuf);

Loading…
Cancel
Save