return pkt_src_str;
}
+void CaptureStatsUpdate(ThreadVars *tv, CaptureStats *s, const Packet *p)
+{
+ if (unlikely(PACKET_TEST_ACTION(p, (ACTION_REJECT|ACTION_REJECT_DST|ACTION_REJECT_BOTH)))) {
+ StatsIncr(tv, s->counter_ips_rejected);
+ } else if (unlikely(PACKET_TEST_ACTION(p, ACTION_DROP))) {
+ StatsIncr(tv, s->counter_ips_blocked);
+ } else if (unlikely(p->flags & PKT_STREAM_MODIFIED)) {
+ StatsIncr(tv, s->counter_ips_replaced);
+ } else {
+ StatsIncr(tv, s->counter_ips_accepted);
+ }
+}
+
+void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s)
+{
+ s->counter_ips_accepted = StatsRegisterCounter("ips.accepted", tv);
+ s->counter_ips_blocked = StatsRegisterCounter("ips.blocked", tv);
+ s->counter_ips_rejected = StatsRegisterCounter("ips.rejected", tv);
+ s->counter_ips_replaced = StatsRegisterCounter("ips.replaced", tv);
+}
+
/**
* @}
*/
#endif
} DecodeThreadVars;
+typedef struct CaptureStats_ {
+
+ uint16_t counter_ips_accepted;
+ uint16_t counter_ips_blocked;
+ uint16_t counter_ips_rejected;
+ uint16_t counter_ips_replaced;
+
+} CaptureStats;
+
+void CaptureStatsUpdate(ThreadVars *tv, CaptureStats *s, const Packet *p);
+void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s);
+
/**
* \brief reset these to -1(indicates that the packet is fresh from the queue)
*/
char *data; /** Per function and thread data */
int datalen; /** Length of per function and thread data */
- uint16_t counter_ips_accepted;
- uint16_t counter_ips_blocked;
- uint16_t counter_ips_rejected;
+ CaptureStats stats;
} NFQThreadVars;
/* shared vars for all for nfq queues and threads */
{
NFQThreadVars *ntv = (NFQThreadVars *) initdata;
- ntv->counter_ips_accepted = StatsRegisterCounter("ips.accepted", tv);
- ntv->counter_ips_blocked = StatsRegisterCounter("ips.blocked", tv);
- ntv->counter_ips_rejected = StatsRegisterCounter("ips.rejected", tv);
+ CaptureStatsSetup(tv, &ntv->stats);
*data = (void *)ntv;
return TM_ECODE_OK;
{
NFQThreadVars *ntv = (NFQThreadVars *)data;
/* update counters */
- if (unlikely(PACKET_TEST_ACTION(p, (ACTION_REJECT|ACTION_REJECT_DST|ACTION_REJECT_BOTH)))) {
- StatsIncr(tv, ntv->counter_ips_rejected);
- } else if (unlikely(PACKET_TEST_ACTION(p, ACTION_DROP))) {
- StatsIncr(tv, ntv->counter_ips_blocked);
- } else {
- StatsIncr(tv, ntv->counter_ips_accepted);
- }
+ CaptureStatsUpdate(tv, &ntv->stats, p);
int ret;
/* if this is a tunnel packet we check if we are ready to verdict