Change in ...osmo-ttcn3-hacks[master]: library/ranap: enrich both t(s|r)_RANAP_DirectTransfer templates

laforge gerrit-no-reply at lists.osmocom.org
Thu Jun 20 16:51:37 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14550 )

Change subject: library/ranap: enrich both t(s|r)_RANAP_DirectTransfer templates
......................................................................

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
---
M library/RAN_Emulation.ttcnpp
M library/ranap/RANAP_Templates.ttcn
2 files changed, 87 insertions(+), 96 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



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 @@
 #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,25 +998,94 @@
  * Direct Transfer
  *****************************************************************************************************/
 
+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;
+}
+
+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_DirectTransfer(template (value) NAS_PDU nas,
-			/* template DirectTransfer.protocolIEs ies := {}, */
+			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 */
-				},
+				protocolIEs := f_gen_ts_dt_ies(nas, sapi, ies),
 				protocolExtensions := exts
 			}
 		}
@@ -1024,89 +1093,15 @@
 }
 template RANAP_PDU
 tr_RANAP_DirectTransfer(template NAS_PDU nas,
-			template SAPI sapi := sapi_0,
-			/* template DirectTransfer.protocolIEs ies := {}, */
+			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 */
-				},
-				protocolExtensions := exts
-			}
-		}
-	}
-}
-
-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) := {
-	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
-						}
-					}
-				},
-				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 := *) := {
-	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 @@
 				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 @@
 	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) {

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14550
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I7333d08c4d5a72159bfbd50fe8e7b1084cd61b9e
Gerrit-Change-Number: 14550
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190620/8c9c0469/attachment.html>


More information about the gerrit-log mailing list