msc: Add and use gsm_subscriber_group

Currently every subcriber object directly refers to the gsm_network
which contains a flag shared by every related subscriber
(keep_subscr). This adds a dependency on gsm_network even if only the
function defined in gsm_subscriber_base.c are used.

This patch adds a new struct gsm_subscriber_group which contains the
keep_subscr flag and a back reference to the network object. The
latter is not dereferenced in gsm_subscriber_base.c, so it can safely
be set to NULL when only that part of the gsm_subscriber API is being
used. It also changes that API to use gsm_subscriber_group instead of
gsm_network parameters.

Since there are some places where a pointer to the gsm_network is
needed but where only a gsm_subscriber is available, a 'net' back
pointer is added to the group struct, too. Nevertheless subscr group
and network could be separated completely, but this is not the topic
of this commit.

Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
index dda3157..a801e0e 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
@@ -167,7 +167,7 @@
 		LOGP(DMSC, LOGL_ERROR, "eMLPP is not handled\n");
 	}
 
-	subscr = subscr_get_or_create(msc->network, mi_string);
+	subscr = subscr_get_or_create(msc->network->subscr_group, mi_string);
 	if (!subscr) {
 		LOGP(DMSC, LOGL_ERROR, "Failed to allocate a subscriber for %s\n", mi_string);
 		return -1;
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c
index 608f525..596bfbd 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c
@@ -78,11 +78,12 @@
 
 	switch (mi_type) {
 	case GSM_MI_TYPE_TMSI:
-		subscr = subscr_active_by_tmsi(conn->bts->network,
+		subscr = subscr_active_by_tmsi(conn->bts->network->subscr_group,
 					       tmsi_from_string(mi_string));
 		break;
 	case GSM_MI_TYPE_IMSI:
-		subscr = subscr_active_by_imsi(conn->bts->network, mi_string);
+		subscr = subscr_active_by_imsi(conn->bts->network->subscr_group,
+					       mi_string);
 		break;
 	default:
 		subscr = NULL;
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c
index 4e1c79e..aa268a4 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c
@@ -41,7 +41,7 @@
 {
 	struct gsm_bts *bts = NULL;
 
-	if (subscr->net->bsc_data->rf_ctrl->policy == S_RF_ON)
+	if (subscr->group->net->bsc_data->rf_ctrl->policy == S_RF_ON)
 		goto page;
 
 	/*
@@ -49,7 +49,7 @@
 	 * with NULL and iterate through all bts.
 	 */
 	do {
-		bts = gsm_bts_by_lac(subscr->net, subscr->lac, bts);
+		bts = gsm_bts_by_lac(subscr->group->net, subscr->lac, bts);
 		if (!bts)
 			break;
 
@@ -68,7 +68,8 @@
 	/* All bts are either off or in the grace period */
 	return 0;
 page:
-	return paging_request(subscr->net, subscr, chan_needed, NULL, msc);
+	return paging_request(subscr->group->net, subscr, chan_needed, NULL,
+			      msc);
 }
 
 static int handle_sub(struct gsm_lchan *lchan, const char *text)