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;
}
diff --git a/pcu/gen_links.sh b/pcu/gen_links.sh
index 3a52c99..d834bd0 100755
--- a/pcu/gen_links.sh
+++ b/pcu/gen_links.sh
@@ -51,7 +51,7 @@
DIR=../library
FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc GSM_Types.ttcn GSM_RR_Types.ttcn Osmocom_Types.ttcn RLCMAC_Templates.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc "
FILES+="NS_Emulation.ttcn NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc "
-FILES+="BSSGP_Emulation.ttcn Osmocom_Gb_Types.ttcn "
+FILES+="BSSGP_Emulation.ttcnpp Osmocom_Gb_Types.ttcn "
FILES+="LLC_Templates.ttcn L3_Templates.ttcn L3_Common.ttcn "
FILES+="PCUIF_Types.ttcn PCUIF_CodecPort.ttcn "
gen_links $DIR $FILES
diff --git a/pcu/regen_makefile.sh b/pcu/regen_makefile.sh
index 6fd000e..b2063ac 100755
--- a/pcu/regen_makefile.sh
+++ b/pcu/regen_makefile.sh
@@ -1,5 +1,7 @@
#!/bin/sh
-FILES="*.ttcn BSSGP_EncDec.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc NS_CodecPort_CtrlFunctDef.cc UD_PT.cc RLCMAC_EncDec.cc LLC_EncDec.cc TELNETasp_PT.cc Native_FunctionDefs.cc"
+FILES="*.ttcn *.ttcnpp BSSGP_EncDec.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc NS_CodecPort_CtrlFunctDef.cc UD_PT.cc RLCMAC_EncDec.cc LLC_EncDec.cc TELNETasp_PT.cc Native_FunctionDefs.cc"
+
+export CPPFLAGS_TTCN3="-DBSSGP_EM_L3"
../regen-makefile.sh PCU_Tests.ttcn $FILES
diff --git a/sgsn/gen_links.sh b/sgsn/gen_links.sh
index 541670d..578b454 100755
--- a/sgsn/gen_links.sh
+++ b/sgsn/gen_links.sh
@@ -85,7 +85,7 @@
DIR=../library
FILES="Misc_Helpers.ttcn General_Types.ttcn GSM_Types.ttcn GSM_RR_Types.ttcn Osmocom_Types.ttcn RLCMAC_Templates.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc "
FILES+="NS_Emulation.ttcn PCUIF_Types.ttcn NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc "
-FILES+="BSSGP_Emulation.ttcn Osmocom_Gb_Types.ttcn "
+FILES+="BSSGP_Emulation.ttcnpp Osmocom_Gb_Types.ttcn "
FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn "
FILES+="Osmocom_VTY_Functions.ttcn "
FILES+="LLC_Templates.ttcn L3_Templates.ttcn L3_Common.ttcn "
diff --git a/sgsn/regen_makefile.sh b/sgsn/regen_makefile.sh
index a239a3b..1d1411e 100755
--- a/sgsn/regen_makefile.sh
+++ b/sgsn/regen_makefile.sh
@@ -2,7 +2,7 @@
FILES="*.ttcn *.ttcnpp *.asn BSSGP_EncDec.cc LLC_EncDec.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc NS_CodecPort_CtrlFunctDef.cc RLCMAC_EncDec.cc Native_FunctionDefs.cc TELNETasp_PT.cc IPA_CodecPort_CtrlFunctDef.cc GTPU_EncDec.cc GTPC_EncDec.cc GTP_CodecPort_CtrlFunctDef.cc SCCP_EncDec.cc SCTPasp_PT.cc RANAP_EncDec.cc "
-export CPPFLAGS_TTCN3="-DIPA_EMULATION_GSUP -DIPA_EMULATION_CTRL -DUSE_MTP3_DISTRIBUTOR -DRAN_EMULATION_RANAP"
+export CPPFLAGS_TTCN3="-DIPA_EMULATION_GSUP -DIPA_EMULATION_CTRL -DUSE_MTP3_DISTRIBUTOR -DRAN_EMULATION_RANAP -DBSSGP_EM_L3"
../regen-makefile.sh SGSN_Tests.ttcn $FILES