clamav/libclamav/stats.c

704 lines
18 KiB
C
Raw Normal View History

2014-02-04 10:14:25 -05:00
/*
* Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
*
* Author: Shawn Webb
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#if !defined(_WIN32)
#if defined(C_SOLARIS)
#include <sys/utsname.h>
#else
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYSCTLBYNAME
#include <sys/sysctl.h>
#endif
#endif
2013-10-31 15:48:02 -04:00
#else
#include <Windows.h>
#include <tchar.h>
#endif
#ifdef CL_THREAD_SAFE
#include <pthread.h>
#endif
#include <errno.h>
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
#include "others.h"
#include "clamav.h"
#include "dconf.h"
#include "stats_json.h"
#include "stats.h"
#include "hostid_internal.h"
#include "www.h"
#define DEBUG_STATS 0
static cli_flagged_sample_t *find_sample(cli_intel_t *intel, const char *virname, const unsigned char *md5, size_t size, stats_section_t *sections);
void free_sample(cli_flagged_sample_t *sample);
#if DEBUG_STATS
char *get_hash(unsigned char *md5)
{
char *hash;
int i;
hash = calloc(1, 33);
if (!(hash))
return NULL;
for (i = 0; i < 16; i++)
sprintf(hash + (i * 2), "%02x", md5[i]);
return hash;
}
char *get_sample_names(char **names)
{
char *ret;
size_t n, i, sz;
sz = 0;
for (n = 0; names[n] != NULL; n++)
sz += strlen(names[n]);
ret = calloc(1, sz + n + 1);
if (!(ret))
return NULL;
for (i = 0; names[i] != NULL; i++)
sprintf(ret + strlen(ret), "%s%s", (i == 0) ? "" : " ", names[i]);
return ret;
}
void print_sample(cli_flagged_sample_t *sample)
{
char *hash, *names;
size_t i;
if (!(sample))
return;
hash = get_hash(sample->md5);
if (!(hash))
return;
cli_warnmsg("Sample[%s]:\n", hash);
cli_warnmsg(" * Size: %zu\n", sample->size);
cli_warnmsg(" * Hits: %u\n", sample->hits);
free(hash);
names = get_sample_names(sample->virus_name);
if ((names))
cli_warnmsg(" * Names: %s\n", names);
if (sample->sections && sample->sections->nsections) {
for (i = 0; i < sample->sections->nsections; i++) {
hash = get_hash(sample->sections->sections[i].md5);
if ((hash)) {
cli_warnmsg(" * Section[%zu] (%zu): %s\n", i, sample->sections->sections[i].len, hash);
free(hash);
}
}
}
if ((names))
free(names);
}
#endif
void clamav_stats_add_sample(const char *virname, const unsigned char *md5, size_t size, stats_section_t *sections, void *cbdata)
{
cli_intel_t *intel;
cli_flagged_sample_t *sample;
size_t i;
char **p;
int err, submit = 0;
if (!(cbdata))
return;
intel = (cli_intel_t *)cbdata;
if (!(intel->engine))
return;
if (intel->engine->dconf->stats & DCONF_STATS_DISABLED)
return;
/* First check if we need to submit stats based on memory/number limits */
if ((intel->engine->cb_stats_get_size))
submit = (intel->engine->cb_stats_get_size(cbdata) >= intel->maxmem);
else
submit = (clamav_stats_get_size(cbdata) >= intel->maxmem);
if (submit == 0) {
if ((intel->engine->cb_stats_get_num))
submit = (intel->engine->cb_stats_get_num(cbdata) >= intel->maxsamples);
else
submit = (clamav_stats_get_num(cbdata) >= intel->maxsamples);
}
if (submit) {
if ((intel->engine->cb_stats_submit)) {
intel->engine->cb_stats_submit(intel->engine, cbdata);
} else {
if ((intel->engine->cb_stats_flush))
intel->engine->cb_stats_flush(intel->engine, intel);
return;
}
}
#ifdef CL_THREAD_SAFE
err = pthread_mutex_lock(&(intel->mutex));
if (err) {
cli_warnmsg("clamav_stats_add_sample: locking mutex failed (err: %d): %s\n", err, strerror(err));
return;
}
#endif
sample = find_sample(intel, virname, md5, size, sections);
if (!(sample)) {
if (!(intel->samples)) {
sample = intel->samples = calloc(1, sizeof(cli_flagged_sample_t));
if (!(sample))
goto end;
} else {
sample = calloc(1, sizeof(cli_flagged_sample_t));
if (!(sample))
goto end;
sample->next = intel->samples;
intel->samples->prev = sample;
intel->samples = sample;
}
if ((sample->virus_name)) {
for (i = 0; sample->virus_name[i] != NULL; i++)
;
2014-02-05 12:35:16 -05:00
p = realloc(sample->virus_name, sizeof(char **) * (i + 1));
if (!(p)) {
free(sample->virus_name);
free(sample);
if (sample == intel->samples)
intel->samples = NULL;
goto end;
}
sample->virus_name = p;
} else {
i = 0;
sample->virus_name = calloc(1, sizeof(char **));
if (!(sample->virus_name)) {
free(sample);
if (sample == intel->samples)
intel->samples = NULL;
goto end;
}
}
sample->virus_name[i] = strdup((virname != NULL) ? virname : "[unknown]");
if (!(sample->virus_name[i])) {
free(sample->virus_name);
2014-02-06 12:17:00 -05:00
free(sample);
if (sample == intel->samples)
intel->samples = NULL;
goto end;
}
p = realloc(sample->virus_name, sizeof(char **) * (i + 2));
if (!(p)) {
free(sample->virus_name);
free(sample);
if (sample == intel->samples)
intel->samples = NULL;
goto end;
}
sample->virus_name = p;
sample->virus_name[i + 1] = NULL;
memcpy(sample->md5, md5, sizeof(sample->md5));
2014-05-29 15:52:43 -04:00
sample->size = (uint32_t)size;
intel->nsamples++;
if (sections && sections->nsections && !(sample->sections)) {
/* Copy the section data that has already been allocated. We don't care if calloc fails; just skip copying if it does. */
sample->sections = calloc(1, sizeof(stats_section_t));
if ((sample->sections)) {
sample->sections->sections = calloc(sections->nsections, sizeof(struct cli_section_hash));
if ((sample->sections->sections)) {
memcpy(sample->sections->sections, sections->sections, sections->nsections * sizeof(struct cli_section_hash));
sample->sections->nsections = sections->nsections;
} else {
free(sample->sections);
sample->sections = NULL;
}
}
}
}
sample->hits++;
end:
#ifdef CL_THREAD_SAFE
err = pthread_mutex_unlock(&(intel->mutex));
if (err) {
Spelling Adjustments (#30) * spelling: accessed * spelling: alignment * spelling: amalgamated * spelling: answers * spelling: another * spelling: acquisition * spelling: apitid * spelling: ascii * spelling: appending * spelling: appropriate * spelling: arbitrary * spelling: architecture * spelling: asynchronous * spelling: attachments * spelling: argument * spelling: authenticode * spelling: because * spelling: boundary * spelling: brackets * spelling: bytecode * spelling: calculation * spelling: cannot * spelling: changes * spelling: check * spelling: children * spelling: codegen * spelling: commands * spelling: container * spelling: concatenated * spelling: conditions * spelling: continuous * spelling: conversions * spelling: corresponding * spelling: corrupted * spelling: coverity * spelling: crafting * spelling: daemon * spelling: definition * spelling: delivered * spelling: delivery * spelling: delimit * spelling: dependencies * spelling: dependency * spelling: detection * spelling: determine * spelling: disconnects * spelling: distributed * spelling: documentation * spelling: downgraded * spelling: downloading * spelling: endianness * spelling: entities * spelling: especially * spelling: empty * spelling: expected * spelling: explicitly * spelling: existent * spelling: finished * spelling: flexibility * spelling: flexible * spelling: freshclam * spelling: functions * spelling: guarantee * spelling: hardened * spelling: headaches * spelling: heighten * spelling: improper * spelling: increment * spelling: indefinitely * spelling: independent * spelling: inaccessible * spelling: infrastructure Conflicts: docs/html/node68.html * spelling: initializing * spelling: inited * spelling: instream * spelling: installed * spelling: initialization * spelling: initialize * spelling: interface * spelling: intrinsics * spelling: interpreter * spelling: introduced * spelling: invalid * spelling: latency * spelling: lawyers * spelling: libclamav * spelling: likelihood * spelling: loop * spelling: maximum * spelling: million * spelling: milliseconds * spelling: minimum * spelling: minzhuan * spelling: multipart * spelling: misled * spelling: modifiers * spelling: notifying * spelling: objects * spelling: occurred * spelling: occurs * spelling: occurrences * spelling: optimization * spelling: original * spelling: originated * spelling: output * spelling: overridden * spelling: parenthesis * spelling: partition * spelling: performance * spelling: permission * spelling: phishing * spelling: portions * spelling: positives * spelling: preceded * spelling: properties * spelling: protocol * spelling: protos * spelling: quarantine * spelling: recursive * spelling: referring * spelling: reorder * spelling: reset * spelling: resources * spelling: resume * spelling: retrieval * spelling: rewrite * spelling: sanity * spelling: scheduled * spelling: search * spelling: section * spelling: separator * spelling: separated * spelling: specify * spelling: special * spelling: statement * spelling: streams * spelling: succession * spelling: suggests * spelling: superfluous * spelling: suspicious * spelling: synonym * spelling: temporarily * spelling: testfiles * spelling: transverse * spelling: turkish * spelling: typos * spelling: unable * spelling: unexpected * spelling: unexpectedly * spelling: unfinished * spelling: unfortunately * spelling: uninitialized * spelling: unlocking * spelling: unnecessary * spelling: unpack * spelling: unrecognized * spelling: unsupported * spelling: usable * spelling: wherever * spelling: wishlist * spelling: white * spelling: infrastructure * spelling: directories * spelling: overridden * spelling: permission * spelling: yesterday * spelling: initialization * spelling: intrinsics * space adjustment for spelling changes * minor modifications by klin
2018-02-21 15:00:59 -05:00
cli_warnmsg("clamav_stats_add_sample: unlocking mutex failed (err: %d): %s\n", err, strerror(err));
}
#endif
return;
}
void clamav_stats_flush(struct cl_engine *engine, void *cbdata)
{
cli_intel_t *intel;
cli_flagged_sample_t *sample, *next;
int err;
if (!(cbdata) || !(engine))
return;
intel = (cli_intel_t *)cbdata;
#ifdef CL_THREAD_SAFE
err = pthread_mutex_lock(&(intel->mutex));
if (err) {
cli_warnmsg("clamav_stats_flush: locking mutex failed (err: %d): %s\n", err, strerror(err));
return;
}
#endif
for (sample = intel->samples; sample != NULL; sample = next) {
next = sample->next;
free_sample(sample);
}
intel->samples = NULL;
intel->nsamples = 0;
if (intel->hostid) {
free(intel->hostid);
intel->hostid = NULL;
}
#ifdef CL_THREAD_SAFE
err = pthread_mutex_unlock(&(intel->mutex));
if (err)
cli_warnmsg("clamav_stats_flush: unlocking mutex failed (err: %d): %s\n", err, strerror(err));
#endif
}
void free_sample(cli_flagged_sample_t *sample)
{
size_t i;
if ((sample->virus_name)) {
for (i = 0; sample->virus_name[i] != NULL; i++)
free(sample->virus_name[i]);
free(sample->virus_name);
}
if ((sample->sections) && (sample->sections->nsections)) {
free(sample->sections->sections);
free(sample->sections);
}
free(sample);
}
void clamav_stats_submit(struct cl_engine *engine, void *cbdata)
{
char *json;
cli_intel_t *intel, myintel;
cli_flagged_sample_t *sample, *next;
int err;
intel = (cli_intel_t *)cbdata;
if (!(intel) || !(engine))
return;
if (engine->dconf->stats & DCONF_STATS_DISABLED)
return;
if (!(engine->cb_stats_get_hostid)) {
/* Submitting stats is disabled due to HostID being turned off */
if ((engine->cb_stats_flush))
engine->cb_stats_flush(engine, cbdata);
return;
}
cli_dbgmsg("stats - start\n");
#ifdef CL_THREAD_SAFE
err = pthread_mutex_lock(&(intel->mutex));
if (err) {
cli_warnmsg("clamav_stats_submit: locking mutex failed (err: %d): %s\n", err, strerror(err));
if ((intel->engine) && (intel->engine->cb_stats_flush))
intel->engine->cb_stats_flush(intel->engine, cbdata);
return;
}
#endif
/* Empty out the cached intelligence data so that other threads don't sit waiting to add data to the cache */
memcpy(&myintel, intel, sizeof(cli_intel_t));
intel->samples = NULL;
intel->nsamples = 0;
json = export_stats_to_json(engine, &myintel);
#ifdef CL_THREAD_SAFE
err = pthread_mutex_unlock(&(intel->mutex));
if (err) {
cli_warnmsg("clamav_stats_submit: unlocking mutex failed (err: %d): %s\n", err, strerror(err));
}
#endif
for (sample = myintel.samples; sample != NULL; sample = next) {
#if DEBUG_STATS
print_sample(sample);
#endif
next = sample->next;
free_sample(sample);
}
if (json) {
submit_post(STATS_HOST, STATS_PORT, "PUT", "/clamav/1/submit/stats", json, myintel.timeout);
free(json);
}
if (myintel.hostid && !(intel->hostid)) {
free(myintel.hostid);
myintel.hostid = NULL;
}
cli_dbgmsg("stats - end\n");
}
void clamav_stats_remove_sample(const char *virname, const unsigned char *md5, size_t size, void *cbdata)
{
cli_intel_t *intel;
cli_flagged_sample_t *sample;
int err;
intel = (cli_intel_t *)cbdata;
if (!(intel))
return;
#ifdef CL_THREAD_SAFE
err = pthread_mutex_lock(&(intel->mutex));
if (err) {
cli_warnmsg("clamav_stats_remove_sample: locking mutex failed (err: %d): %s\n", err, strerror(err));
return;
}
#endif
while ((sample = find_sample(intel, virname, md5, size, NULL))) {
if (sample->prev)
sample->prev->next = sample->next;
if (sample->next)
sample->next->prev = sample->prev;
if (sample == intel->samples)
intel->samples = sample->next;
free_sample(sample);
intel->nsamples--;
}
#ifdef CL_THREAD_SAFE
err = pthread_mutex_unlock(&(intel->mutex));
if (err) {
cli_warnmsg("clamav_stats_remove_sample: unlocking mutex failed (err: %d): %s\n", err, strerror(err));
}
#endif
}
void clamav_stats_decrement_count(const char *virname, const unsigned char *md5, size_t size, void *cbdata)
{
cli_intel_t *intel;
cli_flagged_sample_t *sample;
int err;
intel = (cli_intel_t *)cbdata;
if (!(intel))
return;
#ifdef CL_THREAD_SAFE
err = pthread_mutex_lock(&(intel->mutex));
if (err) {
cli_warnmsg("clamav_stats_decrement_count: locking mutex failed (err: %d): %s\n", err, strerror(err));
return;
}
#endif
sample = find_sample(intel, virname, md5, size, NULL);
if (!(sample))
goto clamav_stats_decrement_end;
if (sample->hits == 1) {
if ((intel->engine->cb_stats_remove_sample))
intel->engine->cb_stats_remove_sample(virname, md5, size, intel);
else
clamav_stats_remove_sample(virname, md5, size, intel);
goto clamav_stats_decrement_end;
}
sample->hits--;
clamav_stats_decrement_end:
#ifdef CL_THREAD_SAFE
err = pthread_mutex_unlock(&(intel->mutex));
if (err) {
cli_warnmsg("clamav_stats_decrement_count: unlocking mutex failed (err: %d): %s\n", err, strerror(err));
}
#endif
return;
}
size_t clamav_stats_get_num(void *cbdata)
{
cli_intel_t *intel;
intel = (cli_intel_t *)cbdata;
if (!(intel))
return 0;
return intel->nsamples;
}
size_t clamav_stats_get_size(void *cbdata)
{
cli_intel_t *intel;
cli_flagged_sample_t *sample;
size_t sz, i;
int err;
intel = (cli_intel_t *)cbdata;
if (!(intel))
return 0;
sz = sizeof(cli_intel_t);
#ifdef CL_THREAD_SAFE
err = pthread_mutex_lock(&(intel->mutex));
if (err) {
cli_warnmsg("clamav_stats_get_size: locking mutex failed (err: %d): %s\n", err, strerror(err));
return sz;
}
#endif
for (sample = intel->samples; sample != NULL; sample = sample->next) {
sz += sizeof(cli_flagged_sample_t);
if ((sample->virus_name)) {
for (i = 0; sample->virus_name[i] != NULL; i++)
sz += strlen(sample->virus_name[i]);
sz += sizeof(char **) * i;
}
}
#ifdef CL_THREAD_SAFE
err = pthread_mutex_unlock(&(intel->mutex));
if (err) {
cli_warnmsg("clamav_stats_get_size: unlocking mutex failed (err: %d): %s\n", err, strerror(err));
}
#endif
return sz;
}
#if defined(_WIN32)
char *clamav_stats_get_hostid(void *cbdata)
{
HW_PROFILE_INFO HwProfInfo;
2013-10-31 15:48:02 -04:00
if (!GetCurrentHwProfile(&HwProfInfo))
return strdup(STATS_ANON_UUID);
2013-10-31 15:48:02 -04:00
return strdup(HwProfInfo.szHwProfileGuid);
}
#elif defined(C_SOLARIS)
char *clamav_stats_get_hostid(void *cbdata)
{
struct utsname utsnm;
int ret;
ret = uname(&utsnm);
if (ret != -1)
return strdup(utsnm.nodename);
return strdup(STATS_ANON_UUID);
}
#else
char *clamav_stats_get_hostid(void *cbdata)
{
char *buf;
2023-04-07 19:51:04 -07:00
#if HAVE_SYSCTLBYNAME
char *sysctls[] = {"kern.hostuuid", NULL};
size_t bufsz, i;
#endif
UNUSEDPARAM(cbdata);
#if HAVE_SYSCTLBYNAME
/*
* FreeBSD provides a handy-dandy sysctl for grabbing the system's HostID. In a jail that
* hasn't run the hostid rc.d script, the hostid defaults to all zeros.
*/
for (i = 0; sysctls[i] != NULL; i++) {
if (sysctlbyname(sysctls[i], NULL, &bufsz, NULL, 0))
continue;
break; /* Got one */
}
if (sysctls[i] != NULL) {
buf = calloc(1, bufsz + 1);
if (sysctlbyname(sysctls[i], buf, &bufsz, NULL, 0))
return strdup(STATS_ANON_UUID); /* Not sure why this would happen, but we'll just default to the anon uuid on error */
return buf;
}
return strdup(STATS_ANON_UUID);
#else
buf = internal_get_host_id();
if (!(buf))
return strdup(STATS_ANON_UUID);
return buf;
#endif
}
#endif
static cli_flagged_sample_t *find_sample(cli_intel_t *intel, const char *virname, const unsigned char *md5, size_t size, stats_section_t *sections)
{
cli_flagged_sample_t *sample;
size_t i;
for (sample = intel->samples; sample != NULL; sample = sample->next) {
int foundSections = 0;
if (sample->size != size)
continue;
if (memcmp(sample->md5, md5, sizeof(sample->md5)))
continue;
if (!(virname))
return sample;
if ((sections) && (sample->sections)) {
if (sections->nsections == sample->sections->nsections) {
for (i = 0; i < sections->nsections; i++)
if (sections->sections[i].len == sample->sections->sections[i].len)
if (memcmp(sections->sections[i].md5, sample->sections->sections[i].md5, sizeof(stats_section_t)))
break;
if (i == sections->nsections)
foundSections = 1;
}
} else {
foundSections = 1;
}
if (foundSections)
for (i = 0; sample->virus_name[i] != NULL; i++)
if (!strcmp(sample->virus_name[i], virname))
return sample;
}
return NULL;
}
void cl_engine_set_clcb_stats_submit(struct cl_engine *engine, clcb_stats_submit callback)
{
engine->cb_stats_submit = callback;
}
2014-01-22 17:38:29 -05:00
void cl_engine_set_stats_set_cbdata(struct cl_engine *engine, void *cbdata)
{
engine->stats_data = cbdata;
}
void cl_engine_set_clcb_stats_add_sample(struct cl_engine *engine, clcb_stats_add_sample callback)
{
engine->cb_stats_add_sample = callback;
}
void cl_engine_set_clcb_stats_remove_sample(struct cl_engine *engine, clcb_stats_remove_sample callback)
{
engine->cb_stats_remove_sample = callback;
}
void cl_engine_set_clcb_stats_decrement_count(struct cl_engine *engine, clcb_stats_decrement_count callback)
{
engine->cb_stats_decrement_count = callback;
}
void cl_engine_set_clcb_stats_flush(struct cl_engine *engine, clcb_stats_flush callback)
{
engine->cb_stats_flush = callback;
}
void cl_engine_set_clcb_stats_get_num(struct cl_engine *engine, clcb_stats_get_num callback)
{
engine->cb_stats_get_num = callback;
}
void cl_engine_set_clcb_stats_get_size(struct cl_engine *engine, clcb_stats_get_size callback)
{
engine->cb_stats_get_size = callback;
}
void cl_engine_set_clcb_stats_get_hostid(struct cl_engine *engine, clcb_stats_get_hostid callback)
{
engine->cb_stats_get_hostid = callback;
}
void cl_engine_stats_enable(struct cl_engine *engine)
{
engine->cb_stats_add_sample = clamav_stats_add_sample;
engine->cb_stats_submit = clamav_stats_submit;
}