First actual SGSN test case

Change-Id: Id66ddf8dbe1c5cfa96a087235588ba67763b7f05
diff --git a/gprs_gb/Test.ttcn b/gprs_gb/Test.ttcn
index 19cfd26..732b3f5 100644
--- a/gprs_gb/Test.ttcn
+++ b/gprs_gb/Test.ttcn
@@ -10,10 +10,28 @@
 	import from NS_Types all;
 	import from NS_Emulation all;
 	import from LLC_Types all;
+	import from LLC_Templates all;
 	import from RLCMAC_Types all;
 	import from RLCMAC_CSN1_Types all;
 	import from LAPDm_RAW_PT all;
 
+	modulepar {
+		BssgpConfig mp_gb_cfg := {
+			nsei := 96,
+			bvci := 196,
+			cell_id := {
+				ra_id := {
+					lai := {
+						mcc_mnc := '26242F'H, lac := 13135
+					},
+					rac := 0
+				},
+				cell_id := 20960
+			},
+			sgsn_role := true
+		};
+	}
+
 	type record MmContext {
 		octetstring	imsi optional,
 		GprsTlli	tlli,
@@ -51,7 +69,7 @@
 		/* connect lower-end of NS emulation to NS_CODEC_PORT (on top of IPl4) */
 		map(ns_component:NSCP, system:NS_CODEC_PORT);
 		ns_component.start(NSStart());
-		bssgp_component.start(BssgpStart());
+		bssgp_component.start(BssgpStart(mp_gb_cfg));
 
 		lapdm_component := lapdm_CT.create;
 		connect(self:L1, lapdm_component:LAPDM_SP);
@@ -138,20 +156,19 @@
 
 	const octetstring gmm_auth_req := '081200102198c72477ea104895e8b959acc58b108182'O;
 
-	function tx_gmm(boolean c_r, in octetstring gmm_pdu, LlcSapi sapi := LLC_SAPI_GMM) runs on dummy_CT {
-		var LlcPdu llc;
+	function tx_gmm(BIT1 c_r, in octetstring gmm_pdu, BIT4 sapi := c_LLC_SAPI_LLGMM) runs on dummy_CT {
+		var PDU_LLC llc;
 
 		//log("GMM Tx: ", dec_PDU_L3_SGSN_MS(gmm_pdu));
 
 		log(c_r, g_mmctx.n_u, gmm_pdu, sapi);
-		log(t_LLC_UI(c_r, g_mmctx.n_u, gmm_pdu, sapi));
-		llc := valueof(t_LLC_UI(c_r, g_mmctx.n_u, gmm_pdu, sapi));
+		llc := valueof(ts_LLC_UI(gmm_pdu, sapi, c_r, g_mmctx.n_u));
 		log(llc);
 		g_mmctx.n_u := g_mmctx.n_u + 1;
 
-		log(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_LlcPdu(llc)));
+		log(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_PDU_LLC(llc)));
 
-		BSSGP.send(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_LlcPdu(llc)));
+		BSSGP.send(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_PDU_LLC(llc)));
 	}
 
 	function f_bssgp_establish() runs on dummy_CT {
@@ -179,10 +196,10 @@
 		BSSGP.send(ts_BSSGP_PS_PAGING_PTMSI(bvci, imsi, tmsi));
 
 		while (true) {
-			var PDU_BSSGP pdu;
+			var BssgpDecoded bd;
 			alt {
-				[] BSSGP.receive(PDU_BSSGP:?) -> value pdu {
-					log("BSSGP Rx: ", pdu);
+				[] BSSGP.receive(tr_BD_L3_MT(?)) -> value bd {
+					log("BSSGP Rx: ", bd);
 				}
 				[] BSSGP.receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { repeat; }
 				[] BSSGP.receive { repeat; }
@@ -322,7 +339,7 @@
 		var template RlcmacUlBlock blk := t_RLCMAC_UL_DATA_TLLI(0, 0, 0, {t_RLCMAC_LLCBLOCK(payload)}, false, tlli);
 		L1.send(RLCMAC_ph_data_req:{tbf_id := 0, cs := cs, block := blk});
 		/* ensure that this LLC-PDU arrives from the right TLLI at the (simulated) SGSN */
-		BSSGP.receive(tr_BSSGP_UL_UD(tlli, ?, payload));
+		BSSGP.receive(tr_BD_BSSGP(tr_BSSGP_UL_UD(tlli, ?, payload)));
 
 		/* ensure the MS eceives an UL_ACK_NACK */
 		alt {
@@ -346,12 +363,12 @@
 		f_single_ul_block(CS1);
 
 		while (true) {
-			var PDU_BSSGP pdu;
+			var BssgpDecoded bd;
 			var RLCMAC_ph_data_ind dl_msg;
 			alt {
 
-				[] BSSGP.receive(PDU_BSSGP:?) -> value pdu {
-					log("BSSGP Rx: ", pdu);
+				[] BSSGP.receive(tr_BD_BSSGP(?)) -> value bd {
+					log("BSSGP Rx: ", bd);
 				}
 				[] BSSGP.receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { repeat; }
 				[] BSSGP.receive { repeat; }
@@ -369,12 +386,12 @@
 		f_bssgp_establish();
 
 		while (true) {
-			var PDU_BSSGP pdu;
+			var BssgpDecoded bd;
 			alt {
-				[] BSSGP.receive(PDU_BSSGP:?) -> value pdu {
-					log("BSSGP Rx: ", pdu);
+				[] BSSGP.receive(tr_BD_BSSGP(?)) -> value bd {
+					log("BSSGP Rx: ", bd);
 					//log("GMM Rx: ", dec_PDU_L3_MS_SGSN(pdu.payload));
-					g_mmctx.tlli := oct2int(pdu.pDU_BSSGP_UL_UNITDATA.tLLI);
+					g_mmctx.tlli := oct2int(bd.bssgp.pDU_BSSGP_UL_UNITDATA.tLLI);
 					tx_gmm(LLC_CR_DL_CMD, gmm_auth_req);
 				}
 				[] BSSGP.receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { repeat; }
@@ -386,7 +403,7 @@
 
 	function f_llc_dec_and_log(in octetstring inp) {
 		log("LLC Input: ", inp);
-		var LlcPdu dec := dec_LlcPdu(inp);
+		var PDU_LLC dec := dec_PDU_LLC(inp);
 		log("LLC Decoded: ", dec);
 	}
 
@@ -405,17 +422,13 @@
 	testcase TC_selftest_llc() runs on dummy_CT {
 		const octetstring c_gmm_att_pcu := '01c001080103e5e000210a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c00020170580460b'O;
 		const octetstring c_gmm_att_pcu_nofcs := '01c001080103e5e000210a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c000201705'O;
-		const octetstring c_ctrl_ui := 'c001'O;
-
-		log(dec_LlcCtrlUnion(c_ctrl_ui));
-		f_llc_assert(enc_LlcCtrlUnion({ ui := { presence := '110'B, spare := '00'B, n_u := 0, e := false, pm := true } }), c_ctrl_ui);
 
 		f_llc_dec_and_log(c_gmm_att_pcu);
 
 		//f_llc_assert(f_LLC_append_fcs(c_gmm_att_pcu_nofcs), c_gmm_att_pcu);
 
-		log(valueof(t_LLC_UI(LLC_CR_DL_CMD, g_mmctx.n_u, gmm_auth_req, LLC_SAPI_GMM)));
-		log(t_LLC_UI(LLC_CR_DL_CMD, g_mmctx.n_u, gmm_auth_req, LLC_SAPI_GMM));
+		log(valueof(ts_LLC_UI(gmm_auth_req, c_LLC_SAPI_LLGMM, LLC_CR_DL_CMD, g_mmctx.n_u)));
+		log(ts_LLC_UI(gmm_auth_req, c_LLC_SAPI_LLGMM, LLC_CR_DL_CMD, g_mmctx.n_u));
 	}
 
 	testcase TC_selftest_rlcmac() runs on dummy_CT {