Go to the documentation of this file.
68 NoErfDagSupportExit(
ThreadVars *
tv,
const void *initdata,
void **data)
70 SCLogError(
"Error creating thread %s: you do not have support for DAG cards "
71 "enabled please recompile with --enable-dag",
87 #define POLL_INTERVAL 1000;
90 #define BYTES_PER_LOOP (4 * 1024 * 1024)
102 struct timeval maxwait,
poll;
118 uint32_t *pkts_read);
181 int stream_count = 0;
183 if (initdata == NULL) {
184 SCLogError(
"Error: No DAG interface provided.");
190 FatalError(
"Failed to allocate memory for ERF DAG thread vars.");
196 if (dag_parse_name(initdata, ewtn->
dagname, DAGNAME_BUFSIZE,
198 SCLogError(
"Failed to parse DAG interface: %s", (
const char *)initdata);
205 SCLogError(
"Unable to get %s live device", (
const char *)initdata);
210 SCLogInfo(
"Opening DAG: %s on stream: %d for processing",
222 if ((stream_count = dag_rx_get_stream_count(ewtn->
dagfd)) < 0) {
223 SCLogError(
"Failed to open stream: %d, DAG: %s, could not query stream count",
232 if (ewtn->
dagstream > stream_count * 2) {
233 SCLogError(
"Failed to open stream: %d, DAG: %s, insufficient streams: %d", ewtn->
dagstream,
244 if (dag_set_mode(ewtn->
dagfd, ewtn->
dagstream, DAG_REVERSE_MODE)) {
245 SCLogError(
"Failed to set mode to DAG_REVERSE_MODE on stream: %d, DAG: %s",
264 SCLogInfo(
"Attached and started stream: %d on DAG: %s",
270 timerclear(&ewtn->maxwait);
271 ewtn->maxwait.tv_usec =
MAXWAIT;
272 timerclear(&ewtn->
poll);
279 &(ewtn->maxwait), &(ewtn->
poll)) < 0) {
290 *data = (
void *)ewtn;
294 SCLogInfo(
"Starting processing packets from stream: %d on DAG: %s",
319 uint32_t pkts_read = 0;
333 top = dag_advance_stream(
dtv->dagfd,
dtv->dagstream, &(
dtv->btm));
335 if (errno == EAGAIN) {
336 if (
dtv->dagstream & 0x1) {
337 TmThreadsCaptureHandleTimeout(
tv, NULL);
343 SCLogError(
"Failed to read from stream: %d, DAG: %s when "
344 "using dag_advance_stream",
345 dtv->dagstream,
dtv->dagname);
350 diff = top -
dtv->btm;
355 assert(diff >= dag_record_size);
357 err = ProcessErfDagRecords(
dtv, top, &pkts_read);
360 SCLogError(
"Failed to read from stream: %d, DAG: %s",
dtv->dagstream,
dtv->dagname);
367 SCLogDebug(
"Read %d records from stream: %d, DAG: %s",
368 pkts_read,
dtv->dagstream,
dtv->dagname);
381 ProcessErfDagRecords(
ErfDagThreadVars *ewtn, uint8_t *top, uint32_t *pkts_read)
386 dag_record_t *dr = NULL;
394 while (((top - ewtn->
btm) >= dag_record_size) &&
401 prec = (
char *)ewtn->
btm;
402 dr = (dag_record_t*)prec;
416 switch (hdr_type & 0x7f) {
421 case ERF_TYPE_DSM_COLOR_ETH:
422 case ERF_TYPE_COLOR_ETH:
423 case ERF_TYPE_COLOR_HASH_ETH:
433 SCLogError(
"Processing of DAG record type: %d not implemented.", dr->type);
437 err = ProcessErfDagRecord(ewtn, prec);
462 dag_record_t *dr = (dag_record_t*)prec;
463 erf_payload_t *pload;
471 while (hdr_type & 0x80) {
472 if (
rlen < (dag_record_size + (hdr_num * 8))) {
473 SCLogError(
"Insufficient captured packet length.");
476 hdr_type = prec[(dag_record_size + (hdr_num * 8))];
481 if (
rlen < (dag_record_size + (8 * hdr_num) + 2 +
wlen)) {
487 pload = (erf_payload_t *)(prec + dag_record_size + (8 * hdr_num));
509 uint64_t
ts = dr->ts;
511 ts = (
ts & 0xffffffffULL) * 1000000;
513 uint64_t usecs =
ts >> 32;
542 SCLogInfo(
"Stream: %d; Bytes: %"PRIu64
"; Packets: %"PRIu64
570 dag_stop_stream(dagfd, stream);
571 dag_detach_stream(dagfd, stream);
604 SCLogError(
"Error: datalink type %" PRId32
" not yet supported in module DecodeErfDag",
void StatsIncr(ThreadVars *tv, uint16_t id)
Increments the local counter.
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
#define SC_ATOMIC_SET(name, val)
Set the value for the atomic variable.
void TmThreadsSetFlag(ThreadVars *tv, uint32_t flag)
Set a thread flag.
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
TmEcode(* PktAcqLoop)(ThreadVars *, void *, void *)
char dagname[DAGNAME_BUFSIZE]
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
#define PKT_SET_SRC(p, src_val)
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
#define SET_PKT_LEN(p, len)
#define SCTIME_FROM_SECS(s)
#define SCTIME_ADD_USECS(ts, us)
TmEcode(* PktAcqBreakLoop)(ThreadVars *, void *)
LiveDevice * LiveGetDevice(const char *name)
Get a pointer to the device at idx.
Per thread variable structure.
TmEcode(* Func)(ThreadVars *, Packet *, void *)
void ReceiveErfDagThreadExitStats(ThreadVars *, void *)
Print some stats to the log at program exit.
void ReceiveErfDagCloseStream(int dagfd, int stream)
uint64_t StatsGetLocalCounterValue(ThreadVars *tv, uint16_t id)
Get the value of the local copy of the counter that hold this id.
void PacketPoolWait(void)
#define TM_FLAG_DECODE_TM
TmModule tmm_modules[TMM_SIZE]
TmEcode DecodeErfDag(ThreadVars *, Packet *, void *)
This function passes off to link type decoders.
uint32_t max_pending_packets
void TmModuleDecodeErfDagRegister(void)
Register the ERF file decoder module.
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
#define TM_FLAG_RECEIVE_TM
struct timeval maxwait poll
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
TmEcode DecodeErfDagThreadInit(ThreadVars *, const void *, void **)
void TmModuleReceiveErfDagRegister(void)
Register the ERF file receiver (reader) module.
void(* ThreadExitPrintStats)(ThreadVars *, void *)
void StatsAddUI64(ThreadVars *tv, uint16_t id, uint64_t x)
Adds a value of type uint64_t to the local counter.
#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.
TmEcode ReceiveErfDagThreadDeinit(ThreadVars *, void *)
Deinitializes the DAG card.
TmEcode DecodeErfDagThreadDeinit(ThreadVars *tv, void *data)
TmEcode ReceiveErfDagLoop(ThreadVars *, void *data, void *slot)
Receives packets from a DAG interface.
struct TmSlot_ * slot_next
void StatsSyncCountersIfSignalled(ThreadVars *tv)
TmEcode ReceiveErfDagThreadInit(ThreadVars *, const void *, void **)
Initialize the ERF receiver thread, generate a single ErfDagThreadVar structure for each thread,...
uint16_t StatsRegisterCounter(const char *name, struct ThreadVars_ *tv)
Registers a normal, unqualified counter.
struct ErfDagThreadVars_ ErfDagThreadVars
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)
#define LINKTYPE_ETHERNET
volatile uint8_t suricata_ctl_flags