sgsn: Implement TLLI assignment/modification/unassignment

It's important that we implement the proper TLLI handling whenever our
P-TMSI changes.

Change-Id: I5b95b9e49f0a1db9659714c4d01f340fd44fafe8
diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index 70e8124..a59bde3 100644
--- a/sgsn/SGSN_Tests.ttcn
+++ b/sgsn/SGSN_Tests.ttcn
@@ -69,6 +69,7 @@
 	OCT3 p_tmsi_sig optional,
 	/* TLLI of the simulated MS */
 	OCT4 tlli,
+	OCT4 tlli_old optional,
 	RoutingAreaIdentificationV ra optional,
 	BssgpCellId bssgp_cell_id,
 	AuthVector vec optional,
@@ -168,6 +169,7 @@
 		p_tmsi := omit,
 		p_tmsi_sig := omit,
 		tlli := f_gprs_tlli_random(),
+		tlli_old := omit,
 		ra := omit,
 		bssgp_cell_id := gb.cfg.cell_id,
 		vec := omit,
@@ -278,6 +280,14 @@
 	deactivate(di);
 }
 
+function f_upd_ptmsi_and_tlli(OCT4 p_tmsi) runs on BSSGP_ConnHdlr {
+	g_pars.p_tmsi := p_tmsi;
+	/* update TLLI */
+	g_pars.tlli_old := g_pars.tlli;
+	g_pars.tlli := g_pars.p_tmsi or4b 'c0000000'O;
+	f_bssgp_client_llgmm_assign(g_pars.tlli_old, g_pars.tlli);
+}
+
 function f_process_attach_accept(PDU_GMM_AttachAccept aa) runs on BSSGP_ConnHdlr {
 	/* mandatory IE */
 	g_pars.ra := aa.routingAreaIdentification;
@@ -286,8 +296,7 @@
 			setverdict(fail, "unexpected P-TMSI allocation");
 			self.stop;
 		}
-		g_pars.p_tmsi := aa.allocatedPTMSI.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi.octets;
-		/* update TLLI? */
+		f_upd_ptmsi_and_tlli(aa.allocatedPTMSI.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi.octets);
 	}
 	if (ispresent(aa.msIdentity)) {
 		setverdict(fail, "unexpected TMSI allocation in non-combined attach");