return 0;
}
-void DNSMemcapGetCounters(uint64_t *memuse, uint64_t *memcap_state,
- uint64_t *memcap_global)
+uint64_t DNSMemcapGetMemuseCounter(void)
{
- *memuse = SC_ATOMIC_GET(dns_memuse);
- *memcap_state = SC_ATOMIC_GET(dns_memcap_state);
- *memcap_global = SC_ATOMIC_GET(dns_memcap_global);
+ uint64_t x = SC_ATOMIC_GET(dns_memuse);
+ return x;
+}
+
+uint64_t DNSMemcapGetMemcapStateCounter(void)
+{
+ uint64_t x = SC_ATOMIC_GET(dns_memcap_state);
+ return x;
+}
+
+uint64_t DNSMemcapGetMemcapGlobalCounter(void)
+{
+ uint64_t x = SC_ATOMIC_GET(dns_memcap_global);
+ return x;
}
SCEnumCharMap dns_decoder_event_table[ ] = {
void DNSIncrMemcap(uint32_t size, DNSState *state);
void DNSDecrMemcap(uint32_t size, DNSState *state);
int DNSCheckMemcap(uint32_t want, DNSState *state);
-void DNSMemcapGetCounters(uint64_t *memuse, uint64_t *memcap_state,
- uint64_t *memcap_global);
+uint64_t DNSMemcapGetMemuseCounter(void);
+uint64_t DNSMemcapGetMemcapStateCounter(void);
+uint64_t DNSMemcapGetMemcapGlobalCounter(void);
void RegisterDNSParsers(void);
void DNSParserTests(void);
{
char *proto_name = "dns";
+ StatsRegisterGlobalCounter("dns.memuse", DNSMemcapGetMemuseCounter);
+ StatsRegisterGlobalCounter("dns.memcap_state", DNSMemcapGetMemcapStateCounter);
+ StatsRegisterGlobalCounter("dns.memcap_global", DNSMemcapGetMemcapGlobalCounter);
+
/** DNS */
if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) {
AppLayerProtoDetectRegisterProtocol(ALPROTO_DNS, proto_name);
/* App layer parser thread context, from AppLayerParserThreadCtxAlloc(). */
AppLayerParserThreadCtx *alp_tctx;
- uint16_t counter_dns_memuse;
- uint16_t counter_dns_memcap_state;
- uint16_t counter_dns_memcap_global;
-
#ifdef PROFILING
uint64_t ticks_start;
uint64_t ticks_end;
#endif
};
-/** \todo move this into the DNS code. Problem is that there we can't
- * access AppLayerThreadCtx internals. */
-static void DNSUpdateCounters(ThreadVars *tv, AppLayerThreadCtx *app_tctx)
-{
- uint64_t memuse = 0, memcap_state = 0, memcap_global = 0;
-
- DNSMemcapGetCounters(&memuse, &memcap_state, &memcap_global);
-
- StatsSetUI64(tv, app_tctx->counter_dns_memuse, memuse);
- StatsSetUI64(tv, app_tctx->counter_dns_memcap_state, memcap_state);
- StatsSetUI64(tv, app_tctx->counter_dns_memcap_global, memcap_global);
-}
-
/***** L7 layer dispatchers *****/
static void DisableAppLayer(Flow *f)
}
}
- /** \fixme a bit hacky but will be improved in 2.1 */
- if (*alproto == ALPROTO_DNS)
- DNSUpdateCounters(tv, app_tctx);
goto end;
failure:
r = -1;
SCEnter();
int r = 0;
- AppProto alproto;
FLOWLOCK_WRLOCK(f);
"for l7");
}
}
- alproto = f->alproto;
FLOWLOCK_UNLOCK(f);
PACKET_PROFILING_APP_STORE(tctx, p);
- if (alproto == ALPROTO_DNS)
- DNSUpdateCounters(tv, tctx);
SCReturnInt(r);
}
if ((app_tctx->alp_tctx = AppLayerParserThreadCtxAlloc()) == NULL)
goto error;
- /* tv is allowed to be NULL in unittests */
- if (tv != NULL) {
- app_tctx->counter_dns_memuse = StatsRegisterCounter("dns.memuse", tv);
- app_tctx->counter_dns_memcap_state = StatsRegisterCounter("dns.memcap_state", tv);
- app_tctx->counter_dns_memcap_global = StatsRegisterCounter("dns.memcap_global", tv);
- }
-
goto done;
error:
AppLayerDestroyCtxThread(app_tctx);