implement periodic Location Update expiry in the VLR

Remove subscribers which fail to send periodic Location Updates from the
list of subscribers known to the VLR. This complements the IMSI detach
procedure: periodic LU expiry triggers an implicit IMSI detach.

Expired subscribers are purged from a periodic timer which iterates
over all subscribers once per minute.

Subscribers with an active connection do not expire. This is controlled
by the subscriber conn FSM which sets a subscriber's the LU expiry timeout
value to GSM_SUBSCRIBER_NO_EXPIRATION while a connection is active.

Add support for fake time with osmo_clock_gettime() to msc_vlr tests.

This functionality existed in OpenBSC but was lost during the nitb split.
This code took some inspiration from the OpenBSC implementation.

Related: OS#1976
Change-Id: Iebdee8b12d22acfcfb265ee41e71cfc8d9eb3ba9
diff --git a/include/osmocom/msc/vlr.h b/include/osmocom/msc/vlr.h
index 0a9ef6f..f12d758 100644
--- a/include/osmocom/msc/vlr.h
+++ b/include/osmocom/msc/vlr.h
@@ -20,6 +20,9 @@
 
 struct log_target;
 
+#define VLR_SUBSCRIBER_NO_EXPIRATION	0
+#define VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL	60	/* in seconds */
+
 /* from 3s to 10s */
 #define GSM_29002_TIMER_S	10
 /* from 15s to 30s */
@@ -148,6 +151,7 @@
 	struct osmo_fsm_inst *proc_arq_fsm;
 
 	bool lu_complete;
+	time_t expire_lu;
 
 	void *msc_conn_ref;
 
@@ -237,6 +241,7 @@
 	struct llist_head operations;
 	struct gsup_client *gsup_client;
 	struct vlr_ops ops;
+	struct osmo_timer_list lu_expire_timer;
 	struct {
 		bool retrieve_imeisv_early;
 		bool retrieve_imeisv_ciphered;
@@ -379,6 +384,7 @@
 				  enum osmo_fsm_term_cause fsm_cause,
 				  uint8_t gsm48_cause);
 
+void vlr_subscr_enable_expire_lu(struct vlr_subscr *vsub);
 
 /* Process Acccess Request FSM */