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

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Wed Jun 19 22:32:38 UTC 2019


fixeria has uploaded this change for review. ( 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, 84 insertions(+), 94 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/50/14550/1

diff --git a/library/RAN_Emulation.ttcnpp b/library/RAN_Emulation.ttcnpp
index de5b7f3..c7f67c4 100644
--- a/library/RAN_Emulation.ttcnpp
+++ b/library/RAN_Emulation.ttcnpp
@@ -1097,12 +1097,7 @@
 #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));
-		}
+		ranap := valueof(ts_RANAP_DirectTransfer(l3_enc, sapi := sapi_0));
 		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..fdced83 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 := sapi_0,
+			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
 			}
 		}
@@ -1025,88 +1094,14 @@
 template RANAP_PDU
 tr_RANAP_DirectTransfer(template NAS_PDU nas,
 			template SAPI sapi := sapi_0,
-			/* template DirectTransfer.protocolIEs ies := {}, */
+			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
 			}
 		}
@@ -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: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190619/4e90f3bb/attachment.htm>


More information about the gerrit-log mailing list