return 0;
}
+void DNSMemcapGetCounters(uint64_t *memuse, uint64_t *memcap_state,
+ uint64_t *memcap_global)
+{
+ *memuse = SC_ATOMIC_GET(dns_memuse);
+ *memcap_state = SC_ATOMIC_GET(dns_memcap_state);
+ *memcap_global = SC_ATOMIC_GET(dns_memcap_global);
+}
SCEnumCharMap dns_decoder_event_table[ ] = {
{ "UNSOLLICITED_RESPONSE", DNS_DECODER_EVENT_UNSOLLICITED_RESPONSE, },
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);
void RegisterDNSParsers(void);
void DNSParserTests(void);
#include "util-profiling.h"
#include "util-validate.h"
#include "decode-events.h"
+
#include "app-layer-htp-mem.h"
+#include "app-layer-dns-common.h"
/**
* \brief This is for the app layer in general and it contains per thread
#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);
+
+ SCPerfCounterSetUI64(app_tctx->counter_dns_memuse,
+ tv->sc_perf_pca, memuse);
+ SCPerfCounterSetUI64(app_tctx->counter_dns_memcap_state,
+ tv->sc_perf_pca, memcap_state);
+ SCPerfCounterSetUI64(app_tctx->counter_dns_memcap_global,
+ tv->sc_perf_pca, memcap_global);
+}
+
/***** L7 layer dispatchers *****/
int AppLayerHandleTCPData(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
}
/** \fixme a bit hacky but will be improved in 2.1 */
- HTPMemuseCounter(tv, ra_ctx);
+ if (*alproto == ALPROTO_HTTP)
+ HTPMemuseCounter(tv, ra_ctx);
+ else 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);
}