summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-06-20 05:02:49 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-06-20 22:13:25 +0700
commite06f228be11ba0a7470213a33d8c2001bd9938c1 (patch)
tree8263adc55415bce21ccc4d3ec2f528cb6ee6c884
parent43021cbbf784e08a0a07fcbc19b7bb22f056bbea (diff)
library/ranap: enrich both t(s|r)_RANAP_DirectTransfer templates
Instead of having two similar variants of RANAP_DirectTransfer: - t(s|r)_RANAP_DirectTransfer, and - t(s|r)_RANAP_DirectTransferSAPI, let's make the first one more flexible, and drop the last one. This is achieved by introducing two supplementary functions: - f_gen_ts_dt_ies(), and - f_gen_tr_dt_ies, which dynamically compose DirectTransfer.protocolIEs. Change-Id: I7333d08c4d5a72159bfbd50fe8e7b1084cd61b9e
-rw-r--r--library/RAN_Emulation.ttcnpp8
-rw-r--r--library/ranap/RANAP_Templates.ttcn165
2 files changed, 82 insertions, 91 deletions
diff --git a/library/RAN_Emulation.ttcnpp b/library/RAN_Emulation.ttcnpp
index de5b7f3..b41d7eb 100644
--- a/library/RAN_Emulation.ttcnpp
+++ b/library/RAN_Emulation.ttcnpp
@@ -1097,12 +1097,8 @@ private function f_xmit_raw_l3(integer sccp_conn_id, OCT1 dlci, octetstring l3_e
#ifdef RAN_EMULATION_RANAP
case (RAN_PROTOCOL_RANAP) {
var RANAP_PDU ranap;
- if (false /* SAPI */) {
- var RANAP_IEs.SAPI sapi := sapi_0;
- ranap := valueof(ts_RANAP_DirectTransferSAPI(l3_enc, sapi));
- } else {
- ranap := valueof(ts_RANAP_DirectTransfer(l3_enc));
- }
+ /* FIXME: convert DLCI into SAPI */
+ ranap := valueof(ts_RANAP_DirectTransfer(l3_enc));
RANAP.send(ts_RANAP_DATA_req(sccp_conn_id, ranap));
}
#endif
diff --git a/library/ranap/RANAP_Templates.ttcn b/library/ranap/RANAP_Templates.ttcn
index e55f212..df4ea03 100644
--- a/library/ranap/RANAP_Templates.ttcn
+++ b/library/ranap/RANAP_Templates.ttcn
@@ -998,115 +998,110 @@ tr_RANAP_initialUE_PS(template LAI lai, template RAC rac, template SAI sai,
* Direct Transfer
*****************************************************************************************************/
-template (value) RANAP_PDU
-ts_RANAP_DirectTransfer(template (value) NAS_PDU nas,
- /* template DirectTransfer.protocolIEs ies := {}, */
- template (omit) DirectTransfer.protocolExtensions exts := omit) := {
- initiatingMessage := {
- procedureCode := id_DirectTransfer,
- criticality := ignore,
- value_ := {
- directTransfer := {
- protocolIEs := {
- {
- id := id_NAS_PDU,
- criticality := ignore,
- value_ := {
- nAS_PDU := nas
- }
- }
- /* LAI, RAC, SAI */
- },
- protocolExtensions := exts
+private function f_gen_ts_dt_ies(template (value) NAS_PDU nas,
+ template (omit) SAPI sapi,
+ template (value) DirectTransfer.protocolIEs opt_ies)
+return DirectTransfer.protocolIEs {
+ var DirectTransfer.protocolIEs ies := {
+ /* NAS PDU is mandatory */
+ {
+ id := id_NAS_PDU,
+ criticality := ignore,
+ value_ := {
+ nAS_PDU := valueof(nas)
}
}
+ };
+
+ /* Optional IEs, e.g. LAI, RAC, SAI */
+ ies := ies & valueof(opt_ies);
+
+ /* Optional SAPI is the last IE */
+ if (isvalue(sapi)) {
+ ies := ies & {{
+ id := id_SAPI,
+ criticality := ignore,
+ value_ := {
+ sAPI := valueof(sapi)
+ }
+ }};
}
+
+ return ies;
}
-template RANAP_PDU
-tr_RANAP_DirectTransfer(template NAS_PDU nas,
- template SAPI sapi := sapi_0,
- /* template DirectTransfer.protocolIEs ies := {}, */
- template DirectTransfer.protocolExtensions exts := *) := {
- initiatingMessage := {
- procedureCode := id_DirectTransfer,
- criticality := ignore,
- value_ := {
- directTransfer := {
- protocolIEs := {
- {
- id := id_NAS_PDU,
- criticality := ignore,
- value_ := {
- nAS_PDU := nas
- }
- },
- * /* LAI, RAC, SAI */
- },
- protocolExtensions := exts
+
+private function f_gen_tr_dt_ies(template NAS_PDU nas,
+ template SAPI sapi,
+ template DirectTransfer.protocolIEs opt_ies)
+return template DirectTransfer.protocolIEs {
+ var template DirectTransfer.protocolIEs ies := {
+ /* NAS PDU is mandatory */
+ {
+ id := id_NAS_PDU,
+ criticality := ignore,
+ value_ := {
+ nAS_PDU := nas
}
}
+ };
+
+ /* Optional IEs start from index 1 */
+ var integer idx := 1;
+
+ /* Optional IEs, e.g. LAI, RAC, SAI */
+ if (istemplatekind(opt_ies, "*")) {
+ ies[idx] := *;
+ idx := idx + 1;
+ } else if (not istemplatekind(opt_ies, "omit")) {
+ for (var integer i := 0; i < lengthof(opt_ies); i := i + 1) {
+ ies[idx] := opt_ies[idx];
+ idx := idx + 1;
+ }
}
+
+ /* Optional SAPI is the last IE */
+ if (istemplatekind(sapi, "*")) {
+ ies[idx] := *;
+ } else if (not istemplatekind(sapi, "omit")) {
+ ies[idx] := {
+ id := id_SAPI,
+ criticality := ignore,
+ value_ := {
+ sAPI := sapi
+ }
+ };
+ }
+
+ return ies;
}
template (value) RANAP_PDU
-ts_RANAP_DirectTransferSAPI(template (value) NAS_PDU nas,
- template (value) SAPI sapi := sapi_0,
- /* template DirectTransfer.protocolIEs ies := {}, */
- template (omit) DirectTransfer.protocolExtensions exts := omit) := {
+ts_RANAP_DirectTransfer(template (value) NAS_PDU nas,
+ template (omit) SAPI sapi := omit,
+ template (value) DirectTransfer.protocolIEs ies := {},
+ template (omit) DirectTransfer.protocolExtensions exts := omit) := {
initiatingMessage := {
procedureCode := id_DirectTransfer,
criticality := ignore,
value_ := {
directTransfer := {
- protocolIEs := {
- {
- id := id_NAS_PDU,
- criticality := ignore,
- value_ := {
- nAS_PDU := nas
- }
- },
- /* LAI, RAC, SAI */
- {
- id := id_SAPI,
- criticality := ignore,
- value_ := {
- sAPI := sapi
- }
- }
- },
+ protocolIEs := f_gen_ts_dt_ies(nas, sapi, ies),
protocolExtensions := exts
}
}
}
}
template RANAP_PDU
-tr_RANAP_DirectTransferSAPI(template NAS_PDU nas,
- template SAPI sapi := sapi_0,
- /* template DirectTransfer.protocolIEs ies := {}, */
- template DirectTransfer.protocolExtensions exts := *) := {
+tr_RANAP_DirectTransfer(template NAS_PDU nas,
+ template SAPI sapi := *,
+ template DirectTransfer.protocolIEs ies := *,
+ template DirectTransfer.protocolExtensions exts := *) := {
initiatingMessage := {
procedureCode := id_DirectTransfer,
criticality := ignore,
value_ := {
directTransfer := {
- protocolIEs := {
- {
- id := id_NAS_PDU,
- criticality := ignore,
- value_ := {
- nAS_PDU := nas
- }
- },
- *, /* LAI, RAC, SAI */
- {
- id := id_SAPI,
- criticality := ignore,
- value_ := {
- sAPI := sapi
- }
- }
- },
+ protocolIEs := f_gen_tr_dt_ies(nas, sapi, ies),
protocolExtensions := exts
}
}
@@ -1394,7 +1389,7 @@ function f_ranap_extract_l3(RANAP_PDU ranap) return template (omit) octetstring
return ies[i].value_.nAS_PDU;
}
}
- } else if (match(ranap, tr_RANAP_DirectTransfer(?, ?))) {
+ } else if (match(ranap, tr_RANAP_DirectTransfer(?))) {
var DirectTransfer.protocolIEs ies := ranap.initiatingMessage.value_.directTransfer.protocolIEs;
for (i := 0; i < lengthof(ies); i := i+1) {
if (ies[i].id == id_NAS_PDU) {
@@ -1412,7 +1407,7 @@ function f_ranap_extract_sapi(RANAP_PDU ranap) return template (omit) SAPI
var integer i;
/* InitialUE message has no SAPI */
- if (match(ranap, tr_RANAP_DirectTransfer(?, ?))) {
+ if (match(ranap, tr_RANAP_DirectTransfer(?, omit))) {
var DirectTransfer.protocolIEs ies := ranap.initiatingMessage.value_.directTransfer.protocolIEs;
for (i := 0; i < lengthof(ies); i := i+1) {
if (ies[i].id == id_SAPI) {