stats: Implement timer based reporting

This calls stats_flush in regular intervals which polls the
statistical values and calls the active reporters when values have
changed.

Sponsored-by: On-Waves ehf
diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h
index b4fb727..489e0e4 100644
--- a/include/osmocom/core/stats.h
+++ b/include/osmocom/core/stats.h
@@ -32,7 +32,6 @@
 
 	/* config */
 	int enabled;
-	int interval;
 	char *name_prefix;
 	char *dest_addr_str;
 	char *bind_addr_str;
@@ -50,9 +49,17 @@
 	struct llist_head list;
 };
 
+struct stats_config {
+	int interval;
+};
+
+extern struct stats_config *stats_config;
+
 void stats_init(void *ctx);
 int stats_report();
 
+int stats_set_interval(int interval);
+
 struct stats_reporter *stats_reporter_alloc(enum stats_reporter_type type,
 	const char *name);
 void stats_reporter_free(struct stats_reporter *srep);
@@ -64,7 +71,6 @@
 int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr);
 int stats_reporter_set_remote_port(struct stats_reporter *srep, int port);
 int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr);
-int stats_reporter_set_interval(struct stats_reporter *srep, int interval);
 int stats_reporter_set_name_prefix(struct stats_reporter *srep, const char *prefix);
 int stats_reporter_enable(struct stats_reporter *srep);
 int stats_reporter_disable(struct stats_reporter *srep);