statistics: Introduce 'struct counter' instead of using unsigned long

This has the advantage that counters can be added all over the code
very easily, while having only one routine that stores all of the
current counter values to the database.  The counters are synced
every 60 seconds, providing relatively fine grained statistics
about the network usage as time passes by.
diff --git a/openbsc/src/handover_logic.c b/openbsc/src/handover_logic.c
index 393b0f2..5297ab6 100644
--- a/openbsc/src/handover_logic.c
+++ b/openbsc/src/handover_logic.c
@@ -97,12 +97,12 @@
 	DEBUGP(DHO, "(old_lchan on BTS %u, new BTS %u)\n",
 		old_lchan->ts->trx->bts->nr, bts->nr);
 
-	bts->network->stats.handover.attempted++;
+	counter_inc(bts->network->stats.handover.attempted);
 
 	new_lchan = lchan_alloc(bts, old_lchan->type);
 	if (!new_lchan) {
 		LOGP(DHO, LOGL_NOTICE, "No free channel\n");
-		bts->network->stats.handover.no_channel++;
+		counter_inc(bts->network->stats.handover.no_channel);
 		return -ENOSPC;
 	}
 
@@ -144,9 +144,10 @@
 static void ho_T3103_cb(void *_ho)
 {
 	struct bsc_handover *ho = _ho;
+	struct gsm_network *net = ho->new_lchan->ts->trx->bts->network;
 
 	DEBUGP(DHO, "HO T3103 expired\n");
-	ho->new_lchan->ts->trx->bts->network->stats.handover.timeout++;
+	counter_inc(net->stats.handover.timeout);
 
 	lchan_free(ho->new_lchan);
 	llist_del(&ho->list);
@@ -207,6 +208,7 @@
 /* GSM 04.08 HANDOVER COMPLETE has been received on new channel */
 static int ho_gsm48_ho_compl(struct gsm_lchan *new_lchan)
 {
+	struct gsm_network *net = new_lchan->ts->trx->bts->network;
 	struct bsc_handover *ho;
 
 	ho = bsc_ho_by_new_lchan(new_lchan);
@@ -215,7 +217,7 @@
 		return -ENODEV;
 	}
 
-	new_lchan->ts->trx->bts->network->stats.handover.completed++;
+	counter_inc(net->stats.handover.completed);
 
 	bsc_del_timer(&ho->T3103);
 
@@ -236,6 +238,7 @@
 /* GSM 04.08 HANDOVER FAIL has been received */
 static int ho_gsm48_ho_fail(struct gsm_lchan *old_lchan)
 {
+	struct gsm_network *net = old_lchan->ts->trx->bts->network;
 	struct bsc_handover *ho;
 
 	ho = bsc_ho_by_old_lchan(old_lchan);
@@ -244,7 +247,7 @@
 		return -ENODEV;
 	}
 
-	old_lchan->ts->trx->bts->network->stats.handover.failed++;
+	counter_inc(net->stats.handover.failed);
 
 	bsc_del_timer(&ho->T3103);
 	llist_del(&ho->list);