From: Victor Julien Date: Fri, 15 Apr 2016 10:26:40 +0000 (+0200) Subject: pcap: small cleanups X-Git-Tag: suricata-3.1RC1~244 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3efc4e0721e6548faed1174445c734d61ba643d;p=thirdparty%2Fsuricata.git pcap: small cleanups --- diff --git a/src/source-pcap-file.c b/src/source-pcap-file.c index c2187eda1b..4df2c72a61 100644 --- a/src/source-pcap-file.c +++ b/src/source-pcap-file.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2014 Open Information Security Foundation +/* Copyright (C) 2007-2016 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -59,8 +59,6 @@ extern int max_pending_packets; -//static int pcap_max_read_packets = 0; - typedef struct PcapFileGlobalVars_ { pcap_t *pcap_handle; int (*Decoder)(ThreadVars *, DecodeThreadVars *, Packet *, u_int8_t *, u_int16_t, PacketQueue *); @@ -73,9 +71,6 @@ typedef struct PcapFileGlobalVars_ { } PcapFileGlobalVars; -/** max packets < 65536 */ -//#define PCAP_FILE_MAX_PKTS 256 - typedef struct PcapFileThreadVars_ { uint32_t tenant_id; @@ -260,8 +255,10 @@ TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot) TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) { SCEnter(); + char *tmpbpfstring = NULL; char *tmpstring = NULL; + if (initdata == NULL) { SCLogError(SC_ERR_INVALID_ARGUMENT, "error: initdata == NULL"); SCReturnInt(TM_ECODE_FAILED); @@ -302,14 +299,15 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) } else { SCLogInfo("using bpf-filter \"%s\"", tmpbpfstring); - if(pcap_compile(pcap_g.pcap_handle,&pcap_g.filter,tmpbpfstring,1,0) < 0) { - SCLogError(SC_ERR_BPF,"bpf compilation error %s",pcap_geterr(pcap_g.pcap_handle)); + if (pcap_compile(pcap_g.pcap_handle, &pcap_g.filter, tmpbpfstring, 1, 0) < 0) { + SCLogError(SC_ERR_BPF,"bpf compilation error %s", + pcap_geterr(pcap_g.pcap_handle)); SCFree(ptv); return TM_ECODE_FAILED; } - if(pcap_setfilter(pcap_g.pcap_handle,&pcap_g.filter) < 0) { - SCLogError(SC_ERR_BPF,"could not set bpf filter %s",pcap_geterr(pcap_g.pcap_handle)); + if (pcap_setfilter(pcap_g.pcap_handle, &pcap_g.filter) < 0) { + SCLogError(SC_ERR_BPF,"could not set bpf filter %s", pcap_geterr(pcap_g.pcap_handle)); SCFree(ptv); return TM_ECODE_FAILED; } @@ -318,7 +316,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) pcap_g.datalink = pcap_datalink(pcap_g.pcap_handle); SCLogDebug("datalink %" PRId32 "", pcap_g.datalink); - switch(pcap_g.datalink) { + switch (pcap_g.datalink) { case LINKTYPE_LINUX_SLL: pcap_g.Decoder = DecodeSll; break;