Skip to content

Commit

Permalink
endace: Fix source-dag timestamps
Browse files Browse the repository at this point in the history
Bug: #6618.

Fix Endace ERF to SCTime_t timestamp conversion

Fix typo preventing compilation with --enable-dag
  • Loading branch information
sfd authored and victorjulien committed Dec 13, 2023
1 parent 3456dea commit 879db3d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
10 changes: 3 additions & 7 deletions src/source-erf-dag.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
SCReturnInt(TM_ECODE_FAILED);
}

ErfDagThreadVars *ewtn = SCMClloc(1, sizeof(ErfDagThreadVars));
ErfDagThreadVars *ewtn = SCCalloc(1, sizeof(ErfDagThreadVars));
if (unlikely(ewtn == NULL)) {
FatalError("Failed to allocate memory for ERF DAG thread vars.");
}
Expand Down Expand Up @@ -506,17 +506,13 @@ ProcessErfDagRecord(ErfDagThreadVars *ewtn, char *prec)
SCReturnInt(TM_ECODE_FAILED);
}

/* Convert ERF time to timeval - from libpcap. */
/* Convert ERF time to SCTime_t */
uint64_t ts = dr->ts;
p->ts = SCTIME_FROM_SECS(ts >> 32);
ts = (ts & 0xffffffffULL) * 1000000;
ts += 0x80000000; /* rounding */
uint64_t usecs = ts >> 32;
if (usecs >= 1000000) {
usecs -= 1000000;
p->ts += SCTIME_FROM_SECS(1);
}
p->ts += SCTIME_FROM_USECS(usecs);
p->ts = SCTIME_ADD_USECS(p->ts, usecs);

StatsIncr(ewtn->tv, ewtn->packets);
ewtn->bytes += wlen;
Expand Down
7 changes: 1 addition & 6 deletions src/source-erf-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,12 @@ static inline TmEcode ReadErfRecord(ThreadVars *tv, Packet *p, void *data)
GET_PKT_LEN(p) = wlen;
p->datalink = LINKTYPE_ETHERNET;

/* Convert ERF time to timeval - from libpcap. */
/* Convert ERF time to SCTime_t */
uint64_t ts = dr.ts;
p->ts = SCTIME_FROM_SECS(ts >> 32);
ts = (ts & 0xffffffffULL) * 1000000;
ts += 0x80000000; /* rounding */
uint64_t usecs = (ts >> 32);
if (usecs >= 1000000) {
usecs -= 1000000;
p->ts = SCTIME_ADD_SECS(p->ts, 1);
usecs++;
}
p->ts = SCTIME_ADD_USECS(p->ts, usecs);

etv->pkts++;
Expand Down

0 comments on commit 879db3d

Please sign in to comment.