Fix MS ending up with assigned imsi 000

The whole paging path and data structre is cleaned up.
New MS helpers ms_imsi_is_valid() and ms_paging_group() are introduced
to help in the process and keep implementation details inside GprsMs
class.

Related: OS#5303
Change-Id: I4c0838b26ede58e4b711410eee2a8e4f71e9414b
diff --git a/src/gprs_ms.c b/src/gprs_ms.c
index 0d6be4d..5e75d06 100644
--- a/src/gprs_ms.c
+++ b/src/gprs_ms.c
@@ -522,6 +522,18 @@
 	osmo_strlcpy(ms->imsi, imsi, sizeof(ms->imsi));
 }
 
+uint16_t ms_paging_group(struct GprsMs *ms)
+{
+	uint16_t pgroup;
+	if (!ms_imsi_is_valid(ms))
+		return 0; /* 000 is the special "all paging" group */
+	if ((pgroup = imsi2paging_group(ms_imsi(ms))) > 999) {
+		LOGPMS(ms, DRLCMAC, LOGL_ERROR, "IMSI to paging group failed!\n");
+		return 0;
+	}
+	return pgroup;
+}
+
 void ms_set_ta(struct GprsMs *ms, uint8_t ta_)
 {
 	if (ta_ == ms->ta)