BSSGP_Emulation: Make L3 (SM/GMM) decoding a compile-time option

This allows us to build low-level tests that don't require all of L3.

Change-Id: I7ef7e93e2cd1d37e7e4a62947ca8dfde30d93b95
diff --git a/library/BSSGP_Emulation.ttcn b/library/BSSGP_Emulation.ttcnpp
similarity index 97%
rename from library/BSSGP_Emulation.ttcn
rename to library/BSSGP_Emulation.ttcnpp
index e3023ed..05a730b 100644
--- a/library/BSSGP_Emulation.ttcn
+++ b/library/BSSGP_Emulation.ttcnpp
@@ -18,8 +18,10 @@
 import from Osmocom_Gb_Types all;
 import from IPL4asp_Types all;
 
+#ifdef BSSGP_EM_L3
 import from MobileL3_GMM_SM_Types all;
 import from MobileL3_Types all;
+#endif
 
 import from LLC_Types all;
 import from LLC_Templates all;
@@ -50,17 +52,25 @@
 /* port from our (internal) point of view */
 type port BSSGP_SP_PT message {
 	in	PDU_BSSGP,
-		PDU_LLC,
+		PDU_LLC
+#ifdef BSSGP_EM_L3
+		,
 		PDU_L3_MS_SGSN,
-		PDU_L3_SGSN_MS;
+		PDU_L3_SGSN_MS
+#endif
+		;
 	out	PDU_BSSGP,
 		PDU_LLC,
 		PDU_SN,
 		NsStatusIndication,
 		BssgpStatusIndication,
-		ASP_Event,
+		ASP_Event
+#ifdef BSSGP_EM_L3
+		,
 		PDU_L3_MS_SGSN,
-		PDU_L3_SGSN_MS;
+		PDU_L3_SGSN_MS
+#endif
+		;
 } with { extension "internal" };
 
 /* port from the user point of view */
@@ -70,13 +80,21 @@
 		BssgpStatusIndication,
 		PDU_BSSGP,
 		PDU_LLC,
-		PDU_SN,
+		PDU_SN
+#ifdef BSSGP_EM_L3
+		,
 		PDU_L3_MS_SGSN,
-		PDU_L3_SGSN_MS;
+		PDU_L3_SGSN_MS
+#endif
+		;
 	out	PDU_BSSGP,
-		PDU_LLC,
+		PDU_LLC
+#ifdef BSSGP_EM_L3
+		,
 		PDU_L3_SGSN_MS,
-		PDU_L3_MS_SGSN;
+		PDU_L3_MS_SGSN
+#endif
+		;
 } with { extension "internal" };
 
 signature BSSGP_register_client(hexstring imsi, OCT4 tlli, BssgpCellId cell_id);
@@ -167,8 +185,11 @@
 type enumerated BssgpDecodeDepth {
 	BSSGP_DECODE_DEPTH_BSSGP,
 	BSSGP_DECODE_DEPTH_LLC,
-	BSSGP_DECODE_DEPTH_SNDCP,
+	BSSGP_DECODE_DEPTH_SNDCP
+#ifdef BSSGP_EM_L3
+	,
 	BSSGP_DECODE_DEPTH_L3
+#endif
 };
 
 type record BssgpConfig {
@@ -524,8 +545,10 @@
 	var NsUnitdataIndication udi;
 	var PDU_BSSGP bs_pdu;
 	var PDU_LLC llc;
+#ifdef BSSGP_EM_L3
 	var PDU_L3_MS_SGSN l3_mo;
 	var PDU_L3_SGSN_MS l3_mt;
+#endif
 
 	/* bogus unblock, just respond with ACK */
 	[] BSCP.receive(f_BnsUdInd(t_BVC_UNBLOCK(g_cfg.bvci), 0)) -> value udi {
@@ -618,6 +641,7 @@
 		BSCP.send(f_BnsUdReq(bs_pdu, g_cfg.bvci));
 	}
 
+#ifdef BSSGP_EM_L3
 	/* ConnHdlr sends L3: Encode and send as UL_UD / DL_UD */
 	[g_cfg.sgsn_role] BSSGP_SP.receive(PDU_L3_SGSN_MS:?) -> value l3_mt sender vc_conn {
 		var integer idx := f_tbl_idx_by_comp(vc_conn);
@@ -635,6 +659,7 @@
 		var octetstring llc_enc := enc_PDU_LLC(valueof(ts_LLC_UI(l3_enc, sapi, '1'B, n_u)));
 		BSCP.send(f_BnsUdReq(ts_BSSGP_UL_UD(ClientTable[idx].tlli, ClientTable[idx].cell_id, llc_enc), g_cfg.bvci));
 	}
+#endif
 
 	/* ConnHdlr sends raw LLC: Encode and send as UL_UD / DL_UD */
 	[not g_cfg.sgsn_role] BSSGP_SP.receive(PDU_LLC:?) -> value llc sender vc_conn {
@@ -656,6 +681,7 @@
 	return ret;
 }
 
+#ifdef BSSGP_EM_L3
 function f_llc_sapi_by_l3_mo(PDU_L3_MS_SGSN l3_mo) return BIT4 {
 	if (ischosen(l3_mo.msgs.gprs_mm)) {
 		return c_LLC_SAPI_LLGMM;
@@ -679,6 +705,7 @@
 	setverdict(fail, "No LLC SAPI for ", l3_mt);
 	mtc.stop;
 }
+#endif
 
 
 
@@ -698,8 +725,10 @@
 type record BssgpDecoded {
 	PDU_BSSGP bssgp,
 	PDU_LLC llc optional,
+#ifdef BSSGP_EM_L3
 	PDU_L3_MS_SGSN l3_mo optional,
 	PDU_L3_SGSN_MS l3_mt optional,
+#endif
 	PDU_SN sndcp optional
 }
 
@@ -708,8 +737,10 @@
 	var BssgpDecoded dec := {
 		bssgp := bssgp,
 		llc := omit,
+#ifdef BSSGP_EM_L3
 		l3_mo := omit,
 		l3_mt := omit,
+#endif
 		sndcp := omit
 	};
 
@@ -729,6 +760,7 @@
 		}
 	}
 
+#ifdef BSSGP_EM_L3
 	/* Decode L3, if it is a LLC PDU containing L3 */
 	if (g_cfg.depth >= BSSGP_DECODE_DEPTH_L3) {
 		if (isvalue(dec.llc) and match(dec.llc, tr_LLC_UI_L3)) {
@@ -739,6 +771,7 @@
 			}
 		}
 	}
+#endif
 
 	return dec;
 }