Go to the documentation of this file.
37 static void PcapFileCallbackLoop(
char *user,
struct pcap_pkthdr *h, u_char *pkt);
61 void PcapFileCallbackLoop(
char *user,
struct pcap_pkthdr *h, u_char *pkt)
66 SCLogNotice(
"skipping packet %" PRIu64, g_eps_pcap_packet_loss);
134 (u_char *)ptv->first_pkt_data);
135 ptv->first_pkt_hdr = NULL;
136 ptv->first_pkt_data = NULL;
139 int packet_q_len = 64;
153 int r = pcap_dispatch(ptv->
pcap_handle, packet_q_len,
154 (pcap_handler)PcapFileCallbackLoop, (u_char *)ptv);
156 SCLogError(
"error code %" PRId32
" %s for %s", r, pcap_geterr(ptv->pcap_handle),
163 SCLogInfo(
"pcap file %s end of file reached (pcap err code %" PRId32
")",
165 ptv->shared->files++;
168 SCLogError(
"Pcap callback PcapFileCallbackLoop failed for %s", ptv->filename);
185 if (r <= 0 || pfv->first_pkt_hdr == NULL) {
186 SCLogError(
"failed to get first packet timestamp. pcap_next_ex(): %d", r);
198 char errbuf[PCAP_ERRBUF_SIZE] =
"";
211 #if defined(HAVE_SETVBUF) && defined(OS_LINUX)
216 SCLogWarning(
"Failed to setvbuf on PCAP file handle: %s", strerror(errno));
233 pcap_freecode(&pfv->
filter);
236 pcap_freecode(&pfv->
filter);
243 if (!PeekFirstPacketTimestamp(pfv))
279 "datalink type %" PRId32
" not (yet) supported in module PcapFile.", datalink);
TmEcode PcapFileDispatch(PcapFileFileVars *ptv)
Main PCAP file reading Loop function.
const u_char * first_pkt_data
int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
TmEcode ValidateLinkType(int datalink, DecoderFunc *DecoderFn)
PcapFileSharedVars * shared
int(* DecoderFunc)(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
#define LINKTYPE_LINUX_SLL
int DecodeCHDLC(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
@ CHECKSUM_VALIDATION_DISABLE
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
int ChecksumAutoModeCheck(uint64_t thread_count, uint64_t iface_count, uint64_t iface_fail)
Check if the number of invalid checksums indicate checksum offloading in place.
size_t strlcpy(char *dst, const char *src, size_t siz)
#define SCTIME_FROM_TIMEVAL_UNTRUSTED(tv)
variant to deal with potentially bad timestamps, like from pcap files
#define PKT_SET_SRC(p, src_val)
int DecodeNull(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
@ CHECKSUM_VALIDATION_AUTO
ChecksumValidationMode checksum_mode
#define SCTIME_FROM_TIMEVAL(tv)
TmEcode InitPcapFile(PcapFileFileVars *pfv)
#define LINKTYPE_GRE_OVER_IP
#define SCLogWarning(...)
Macro used to log WARNING messages.
void PacketPoolWait(void)
#define PACKET_PROFILING_TMM_END(p, id)
#define PKT_IGNORE_CHECKSUM
uint32_t max_pending_packets
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
void TmThreadsInitThreadsTimestamp(const SCTime_t ts)
char pcap_filename[PATH_MAX]
int DecodeSll(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
struct timeval first_pkt_ts
#define PACKET_PROFILING_TMM_START(p, id)
#define SCLogError(...)
Macro used to log ERROR messages.
void DatalinkSetGlobalType(int datalink)
#define LINKTYPE_CISCO_HDLC
const char * PcapFileGetFilename(void)
int DecodeRaw(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
struct pcap_pkthdr * first_pkt_hdr
PcapFileGlobalVars pcap_g
struct bpf_program filter
void StatsSyncCountersIfSignalled(ThreadVars *tv)
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
void CleanupPcapFileFileVars(PcapFileFileVars *pfv)
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Packet * PacketGetFromQueueOrAlloc(void)
Get a packet. We try to get a packet from the packetpool first, but if that is empty we alloc a packe...
int DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
uint32_t read_buffer_size
#define LINKTYPE_ETHERNET
volatile uint8_t suricata_ctl_flags