Return u64, update arguments.
return 1;
}
-/*
+/**
* \brief Get the value of the local copy of the counter that hold this id.
*
- * \param id The counter id.
- * \param pca Pointer to the SCPerfPrivateContext.
+ * \param tv threadvars
+ * \param id The counter id.
*
* \retval 0 on success.
* \retval -1 on error.
*/
-double SCPerfGetLocalCounterValue(uint16_t id, SCPerfPrivateContext *pca)
+uint64_t SCPerfGetLocalCounterValue(ThreadVars *tv, uint16_t id)
{
+ SCPerfPrivateContext *pca = tv->perf_private_ctx;
#ifdef DEBUG
BUG_ON (pca == NULL);
BUG_ON ((id < 1) || (id > pca->size));
SCPerfPrivateContext * SCPerfGetAllCountersArray(SCPerfPublicContext *);
int SCPerfUpdateCounterArray(SCPerfPrivateContext *, SCPerfPublicContext *);
-double SCPerfGetLocalCounterValue(uint16_t, SCPerfPrivateContext *);
+uint64_t SCPerfGetLocalCounterValue(struct ThreadVars_ *, uint16_t);
/* functions used to free the resources alloted by the Perf counter API */
void SCPerfReleaseResources(void);
p = UTHBuildPacket((uint8_t *)"boo", strlen("boo"), IPPROTO_TCP);
Detect(&tv, p, det_ctx, NULL, NULL);
- result = (SCPerfGetLocalCounterValue(det_ctx->counter_alerts, tv.perf_private_ctx) == 1);
+ result = (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 1);
Detect(&tv, p, det_ctx, NULL, NULL);
- result &= (SCPerfGetLocalCounterValue(det_ctx->counter_alerts, tv.perf_private_ctx) == 2);
+ result &= (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 2);
UTHFreePackets(&p, 1);
p = UTHBuildPacket((uint8_t *)"roo", strlen("roo"), IPPROTO_TCP);
Detect(&tv, p, det_ctx, NULL, NULL);
- result &= (SCPerfGetLocalCounterValue(det_ctx->counter_alerts, tv.perf_private_ctx) == 2);
+ result &= (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 2);
UTHFreePackets(&p, 1);
p = UTHBuildPacket((uint8_t *)"laboosa", strlen("laboosa"), IPPROTO_TCP);
Detect(&tv, p, det_ctx, NULL, NULL);
- result &= (SCPerfGetLocalCounterValue(det_ctx->counter_alerts, tv.perf_private_ctx) == 3);
+ result &= (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 3);
UTHFreePackets(&p, 1);
end:
AFPDumpCounters(ptv);
SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 "",
tv->name,
- (uint64_t) SCPerfGetLocalCounterValue(ptv->capture_kernel_packets, tv->perf_private_ctx),
- (uint64_t) SCPerfGetLocalCounterValue(ptv->capture_kernel_drops, tv->perf_private_ctx));
+ SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_packets),
+ SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_drops));
#endif
SCLogInfo("(%s) Packets %" PRIu64 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes);
ErfDagThreadVars *ewtn = (ErfDagThreadVars *)data;
(void)SC_ATOMIC_SET(ewtn->livedev->pkts,
- (uint64_t)SCPerfGetLocalCounterValue(ewtn->packets, tv->perf_private_ctx));
+ SCPerfGetLocalCounterValue(tv, ewtn->packets));
(void)SC_ATOMIC_SET(ewtn->livedev->drop,
- (uint64_t)SCPerfGetLocalCounterValue(ewtn->drops, tv->perf_private_ctx));
+ SCPerfGetLocalCounterValue(tv, ewtn->drops));
SCLogInfo("Stream: %d; Bytes: %"PRIu64"; Packets: %"PRIu64
"; Drops: %"PRIu64,
ewtn->dagstream,
ewtn->bytes,
- (uint64_t)SCPerfGetLocalCounterValue(ewtn->packets, tv->perf_private_ctx),
- (uint64_t)SCPerfGetLocalCounterValue(ewtn->drops, tv->perf_private_ctx));
+ SCPerfGetLocalCounterValue(tv, ewtn->packets),
+ SCPerfGetLocalCounterValue(tv, ewtn->drops));
}
/**
NetmapDumpCounters(ntv);
SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 ", bytes %" PRIu64 "",
tv->name,
- (uint64_t) SCPerfGetLocalCounterValue(ntv->capture_kernel_packets, tv->perf_private_ctx),
- (uint64_t) SCPerfGetLocalCounterValue(ntv->capture_kernel_drops, tv->perf_private_ctx),
+ SCPerfGetLocalCounterValue(tv, ntv->capture_kernel_packets),
+ SCPerfGetLocalCounterValue(tv, ntv->capture_kernel_drops),
ntv->bytes);
}
* So to get the number of packet on the interface we can add
* the newly seen packets and drops for this thread and add it
* to the interface counter */
- uint64_t th_pkts = SCPerfGetLocalCounterValue(ptv->capture_kernel_packets,
- ptv->tv->perf_private_ctx);
- uint64_t th_drops = SCPerfGetLocalCounterValue(ptv->capture_kernel_drops,
- ptv->tv->perf_private_ctx);
+ uint64_t th_pkts = SCPerfGetLocalCounterValue(ptv->tv, ptv->capture_kernel_packets);
+ uint64_t th_drops = SCPerfGetLocalCounterValue(ptv->tv, ptv->capture_kernel_drops);
SC_ATOMIC_ADD(ptv->livedev->pkts, pfring_s.recv - th_pkts);
SC_ATOMIC_ADD(ptv->livedev->drop, pfring_s.drop - th_drops);
SCPerfCounterSetUI64(ptv->tv, ptv->capture_kernel_packets, pfring_s.recv);
PfringDumpCounters(ptv);
SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 "",
tv->name,
- (uint64_t) SCPerfGetLocalCounterValue(ptv->capture_kernel_packets, tv->perf_private_ctx),
- (uint64_t) SCPerfGetLocalCounterValue(ptv->capture_kernel_drops, tv->perf_private_ctx));
+ SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_packets),
+ SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_drops));
SCLogInfo("(%s) Packets %" PRIu64 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes);
}