pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40817?usp=email )
Change subject: {S1AP,NGAP}_Emulation: Simplify lookup code
......................................................................
{S1AP,NGAP}_Emulation: Simplify lookup code
Simplify code matching IDs. Explicitly test, log and exit function
called with both IDs passed as "omit".
Change-Id: I02f33c191d131c6325f3608ceec80be6f036aa84
---
M library/NGAP_Emulation.ttcn
M library/S1AP_Emulation.ttcn
2 files changed, 34 insertions(+), 26 deletions(-)
Approvals:
fixeria: Looks good to me, approved
Jenkins Builder: Verified
osmith: Looks good to me, but someone else must approve
diff --git a/library/NGAP_Emulation.ttcn b/library/NGAP_Emulation.ttcn
index 7b7d93d..aa4b485 100644
--- a/library/NGAP_Emulation.ttcn
+++ b/library/NGAP_Emulation.ttcn
@@ -36,6 +36,7 @@
import from General_Types all;
import from Osmocom_Types all;
import from IPL4asp_Types all;
+import from Misc_Helpers all;
import from DNS_Helpers all;
import from SCTP_Templates all;
@@ -262,24 +263,27 @@
private function f_assoc_id_by_ngap_ids(template (omit) AMF_UE_NGAP_ID amf_id,
template (omit) RAN_UE_NGAP_ID ran_id)
runs on NGAP_Emulation_CT return integer {
- var integer i;
- for (i := 0; i < sizeof(NGapAssociationTable); i := i+1) {
+ if (istemplatekind(ran_id, "omit") and istemplatekind(amf_id,
"omit")) {
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected call
f_assoc_id_by_ngap_ids(omit, omit)");
+ }
+ for (var integer i := 0; i < sizeof(NGapAssociationTable); i := i+1) {
if (not isvalue(NGapAssociationTable[i].ran_ue_ngap_id)) {
continue;
}
- if (istemplatekind(ran_id, "omit") or
- match(NGapAssociationTable[i].ran_ue_ngap_id, ran_id)) {
- if (istemplatekind(amf_id, "omit")) {
- return i;
- } else {
- if (match(NGapAssociationTable[i].amf_ue_ngap_id, amf_id)) {
- return i;
- }
- }
+ if (not istemplatekind(ran_id, "omit") and
+ not match(NGapAssociationTable[i].ran_ue_ngap_id, ran_id)) {
+ continue;
}
+ /* ran_id matched, check amf_id now: */
+ if (not istemplatekind(amf_id, "omit") and
+ not match(NGapAssociationTable[i].amf_ue_ngap_id, amf_id)) {
+ continue;
+ }
+ return i;
}
- setverdict(fail, "NGAP Association Table not found by RAN-ID=", ran_id, "
AMF-ID=", amf_id);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("NGAP Association Table not found by RAN-ID=", ran_id, "
AMF-ID=", amf_id));
+ return -1; /* make ttcn3 compiler happy */
}
private function f_assoc_id_by_comp(NGAP_ConnHdlr client)
diff --git a/library/S1AP_Emulation.ttcn b/library/S1AP_Emulation.ttcn
index 55a3380..b3e7731 100644
--- a/library/S1AP_Emulation.ttcn
+++ b/library/S1AP_Emulation.ttcn
@@ -51,6 +51,7 @@
import from General_Types all;
import from Osmocom_Types all;
import from IPL4asp_Types all;
+import from Misc_Helpers all;
import from DNS_Helpers all;
@@ -207,24 +208,27 @@
private function f_assoc_id_by_s1ap_ids(template (omit) MME_UE_S1AP_ID mme_id,
template (omit) ENB_UE_S1AP_ID enb_id)
runs on S1AP_Emulation_CT return integer {
- var integer i;
- for (i := 0; i < sizeof(S1apAssociationTable); i := i+1) {
+ if (istemplatekind(enb_id, "omit") and istemplatekind(mme_id,
"omit")) {
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected call
f_assoc_id_by_s1ap_ids(omit, omit)");
+ }
+ for (var integer i := 0; i < sizeof(S1apAssociationTable); i := i+1) {
if (not isvalue(S1apAssociationTable[i].enb_ue_s1ap_id)) {
continue;
}
- if (istemplatekind(enb_id, "omit") or
- match(S1apAssociationTable[i].enb_ue_s1ap_id, enb_id)) {
- if (istemplatekind(mme_id, "omit")) {
- return i;
- } else {
- if (match(S1apAssociationTable[i].mme_ue_s1ap_id, mme_id)) {
- return i;
- }
- }
+ if (not istemplatekind(enb_id, "omit") and
+ not match(S1apAssociationTable[i].enb_ue_s1ap_id, enb_id)) {
+ continue;
}
+ /* enb_id matched, check mme_id now: */
+ if (not istemplatekind(mme_id, "omit") and
+ not match(S1apAssociationTable[i].mme_ue_s1ap_id, mme_id)) {
+ continue;
+ }
+ return i;
}
- setverdict(fail, "S1AP Association Table not found by ENB-ID=", enb_id, "
MME-ID=", mme_id);
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ log2str("S1AP Association Table not found by ENB-ID=", enb_id, "
MME-ID=", mme_id));
+ return -1; /* make ttcn3 compiler happy */
}
private function f_assoc_id_by_comp(S1AP_ConnHdlr client)
--
To view, visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40817?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I02f33c191d131c6325f3608ceec80be6f036aa84
Gerrit-Change-Number: 40817
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>