ms: Support new and old TLLIs

According to the specification (GSM 04.08/24.008, 4.7.1.5) after a
new P-TMSI has been assigned, the old P-TMSI must be kept basically
until it has been used by both sides. Since the TLLI will be derived
from the P-TMSI, the old TLLI must also be kept until the new TLLI
has been used by both MS and SGSN.

This commit modifies the TLLI handling of GprsMs accordingly.
set_tlli() is only used with TLLIs derived from MS messages,
confirm_tlli() is used with TLLIs derived from messages received from
the SGSN. tlli() returns the value set by the MS. check_tlli()
matches each of the TLLI used by either MS or SGSN as well as the old
TLLI until it has been confirmed.

Sponsored-by: On-Waves ehf
diff --git a/src/gprs_ms.h b/src/gprs_ms.h
index 3a8a2e1..ac1928e 100644
--- a/src/gprs_ms.h
+++ b/src/gprs_ms.h
@@ -51,8 +51,10 @@
 
 	gprs_rlcmac_ul_tbf *ul_tbf() const {return m_ul_tbf;}
 	gprs_rlcmac_dl_tbf *dl_tbf() const {return m_dl_tbf;}
-	uint32_t tlli() const {return m_tlli;}
+	uint32_t tlli() const;
 	void set_tlli(uint32_t tlli);
+	bool confirm_tlli(uint32_t tlli);
+	bool check_tlli(uint32_t tlli);
 
 	void attach_tbf(gprs_rlcmac_tbf *tbf);
 	void attach_ul_tbf(gprs_rlcmac_ul_tbf *tbf);
@@ -78,7 +80,20 @@
 	gprs_rlcmac_ul_tbf *m_ul_tbf;
 	gprs_rlcmac_dl_tbf *m_dl_tbf;
 	uint32_t m_tlli;
+	uint32_t m_new_ul_tlli;
+	uint32_t m_new_dl_tlli;
 	bool m_is_idle;
 	int m_ref;
 	LListHead<GprsMs> m_list;
 };
+
+inline uint32_t GprsMs::tlli() const
+{
+	return m_new_ul_tlli ? m_new_ul_tlli : m_tlli;
+}
+
+inline bool GprsMs::check_tlli(uint32_t tlli)
+{
+	return tlli != 0 &&
+		(tlli == m_tlli || tlli == m_new_ul_tlli || tlli == m_new_dl_tlli);
+}