Go to the documentation of this file.
34 #define ERF_HEADER_LEN 16
36 #define ERF_ETH_PAD_LEN 2
39 #define ERF_TYPE_MASK 0x7f
40 #define ERF_TYPE_MORE_EXT 0x80
41 #define ERF_TYPE_ETH 2
42 #define ERF_TYPE_COLOR_ETH 11
43 #define ERF_TYPE_DSM_COLOR_ETH 16
44 #define ERF_TYPE_COLOR_HASH_ETH 20
69 typedef struct ErfFileThreadVars_ {
132 etv->slot = ((
TmSlot *)slot)->slot_next;
166 if (TmThreadsSlotProcessPkt(etv->tv, etv->slot,
p) !=
TM_ECODE_OK) {
181 unsigned int hdr_num = 0;
184 size_t r = fread(&dr,
sizeof(DagRecord), 1, etv->erf);
186 if (feof(etv->erf)) {
194 uint8_t hdr_type = dr.type;
198 "record length less than size of header");
203 while (hdr_type & ERF_TYPE_MORE_EXT) {
205 SCLogError(
"Insufficient captured packet length.");
210 if (feof(etv->erf)) {
217 hdr_type = ext_hdr[0];
223 SCLogError(
"Insufficient captured packet length.");
228 if (feof(etv->erf)) {
242 r = fread(etv->buffer, caplen, 1, etv->erf);
244 if (feof(etv->erf)) {
255 switch (dr.type & ERF_TYPE_MASK) {
256 case ERF_TYPE_DSM_COLOR_ETH:
257 case ERF_TYPE_COLOR_ETH:
258 case ERF_TYPE_COLOR_HASH_ETH:
274 ts = (
ts & 0xffffffffULL) * 1000000;
276 uint64_t usecs = (
ts >> 32);
280 etv->bytes += caplen;
293 if (initdata == NULL) {
298 FILE *erf = fopen((
const char *)initdata,
"r");
300 SCLogError(
"Failed to open %s: %s", (
char *)initdata, strerror(errno));
306 SCLogError(
"Failed to allocate memory for ERF file thread vars.");
314 SCLogInfo(
"Processing ERF file %s", (
char *)initdata);
325 DecodeErfFileThreadInit(
ThreadVars *
tv,
const void *initdata,
void **data)
383 SCLogInfo(
"Packets: %"PRIu32
"; Bytes: %"PRIu64, etv->pkts, etv->bytes);
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
void TmThreadsSetFlag(ThreadVars *tv, uint32_t flag)
Set a thread flag.
void ReceiveErfFileThreadExitStats(ThreadVars *, void *)
Print some stats to the log at program exit.
void TmModuleDecodeErfFileRegister(void)
Register the ERF file decoder module.
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
TmEcode(* PktAcqLoop)(ThreadVars *, void *, void *)
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
#define PKT_SET_SRC(p, src_val)
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
#define SCTIME_FROM_SECS(s)
#define SCTIME_ADD_USECS(ts, us)
TmEcode(* PktAcqBreakLoop)(ThreadVars *, void *)
Per thread variable structure.
TmEcode(* Func)(ThreadVars *, Packet *, void *)
void PacketPoolWait(void)
#define TM_FLAG_DECODE_TM
TmModule tmm_modules[TMM_SIZE]
struct DagFlags_ DagFlags
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
#define TM_FLAG_RECEIVE_TM
void TmModuleReceiveErfFileRegister(void)
Register the ERF file receiver (reader) module.
TmEcode ReceiveErfFileThreadDeinit(ThreadVars *, void *)
struct DagRecord_ __attribute__((packed))
DNP3 application object header.
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
void EngineStop(void)
make sure threads can stop the engine by calling this function. Purpose: pcap file mode needs to be a...
void(* ThreadExitPrintStats)(ThreadVars *, void *)
#define SCLogError(...)
Macro used to log ERROR messages.
void DatalinkSetGlobalType(int datalink)
Structure to hold thread specific data for all decode modules.
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
#define LINKTYPE_ETHERNET
TmEcode ReceiveErfFileThreadInit(ThreadVars *, const void *, void **)
Initialize the ERF receiver thread.
TmEcode ReceiveErfFileLoop(ThreadVars *, void *, void *)
ERF file reading loop.
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)
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
volatile uint8_t suricata_ctl_flags