BSSGP_Emulation: add BssgpDecodeDepth

Make the decoding level (BSSGP, LLC, SNDCP, L3) configurable, so the
existing PCU tests, that expect messages only decoded to the BSSGP
level, can pass again. Move the SNDCP decoding in f_dec_bssgp above the
L3 decoding, so f_dec_bssgp goes through the layers in the reverse order
of f_send_bssgp_dec.

I have verified, that all testsuites using the BSSGP Emulation (SGSN,
PCU, PCU-SNS) are still working with this patch.

Related: OS#4180
Fixes: 955aa94504510139a12d223071cf49ef90788a3d ("BSSGP_Emulation: Abandon "BssgpDecoded" intermediate structure")
Change-Id: I8f76385528c1de98c557cee451c0e0dfd182b605
diff --git a/library/BSSGP_Emulation.ttcn b/library/BSSGP_Emulation.ttcn
index 44946c1..e3023ed 100644
--- a/library/BSSGP_Emulation.ttcn
+++ b/library/BSSGP_Emulation.ttcn
@@ -164,11 +164,19 @@
 	n_u_rx_last := -
 }
 
+type enumerated BssgpDecodeDepth {
+	BSSGP_DECODE_DEPTH_BSSGP,
+	BSSGP_DECODE_DEPTH_LLC,
+	BSSGP_DECODE_DEPTH_SNDCP,
+	BSSGP_DECODE_DEPTH_L3
+};
+
 type record BssgpConfig {
 	Nsvci nsei,
 	Nsvci bvci,
 	BssgpCellId cell_id,
-	boolean sgsn_role
+	boolean sgsn_role,
+	BssgpDecodeDepth depth
 };
 
 function f_BnsUdReq(template PDU_BSSGP pdu, BssgpBvci bvci)
@@ -706,25 +714,32 @@
 	};
 
 	/* Decode LLC, if it is a PDU that contains LLC */
-	if (ischosen(bssgp.pDU_BSSGP_DL_UNITDATA)) {
-		dec.llc := dec_PDU_LLC(bssgp.pDU_BSSGP_DL_UNITDATA.lLC_PDU.lLC_PDU);
-	} else if (ischosen(bssgp.pDU_BSSGP_UL_UNITDATA)) {
-		dec.llc := dec_PDU_LLC(bssgp.pDU_BSSGP_UL_UNITDATA.lLC_PDU.lLC_PDU);
-	}
-
-	/* Decode L3, if it is a LLC PDU containing L3 */
-	if (isvalue(dec.llc) and match(dec.llc, tr_LLC_UI_L3)) {
-		if (g_cfg.sgsn_role) {
-			dec.l3_mo := dec_PDU_L3_MS_SGSN(dec.llc.pDU_LLC_UI.information_field_UI);
-		} else {
-			dec.l3_mt := dec_PDU_L3_SGSN_MS(dec.llc.pDU_LLC_UI.information_field_UI);
+	if (g_cfg.depth >= BSSGP_DECODE_DEPTH_LLC) {
+		if (ischosen(bssgp.pDU_BSSGP_DL_UNITDATA)) {
+			dec.llc := dec_PDU_LLC(bssgp.pDU_BSSGP_DL_UNITDATA.lLC_PDU.lLC_PDU);
+		} else if (ischosen(bssgp.pDU_BSSGP_UL_UNITDATA)) {
+			dec.llc := dec_PDU_LLC(bssgp.pDU_BSSGP_UL_UNITDATA.lLC_PDU.lLC_PDU);
 		}
 	}
 
 	/* Decode SNDCP, if it is a LLC PDU containing user plane data */
-	if (isvalue(dec.llc) and match(dec.llc, tr_LLC_UI_USER)) {
-		dec.sndcp := dec_PDU_SN(dec.llc.pDU_LLC_UI.information_field_UI);
+	if (g_cfg.depth >= BSSGP_DECODE_DEPTH_SNDCP) {
+		if (isvalue(dec.llc) and match(dec.llc, tr_LLC_UI_USER)) {
+			dec.sndcp := dec_PDU_SN(dec.llc.pDU_LLC_UI.information_field_UI);
+		}
 	}
+
+	/* 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)) {
+			if (g_cfg.sgsn_role) {
+				dec.l3_mo := dec_PDU_L3_MS_SGSN(dec.llc.pDU_LLC_UI.information_field_UI);
+			} else {
+				dec.l3_mt := dec_PDU_L3_SGSN_MS(dec.llc.pDU_LLC_UI.information_field_UI);
+			}
+		}
+	}
+
 	return dec;
 }