Change in osmo-ttcn3-hacks[master]: NS_Emulation: Dynamically compute list of v4/v6 endpoints in SNS-CONFIG

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/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Jan 18 17:56:21 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/22303 )


Change subject: NS_Emulation: Dynamically compute list of v4/v6 endpoints in SNS-CONFIG
......................................................................

NS_Emulation: Dynamically compute list of v4/v6 endpoints in SNS-CONFIG

Don't hard-code the assumption that we only have a single IP[v4] endpoint.

Related: OS#4953
Change-Id: I43fe5810b95ebbc9f848856803ac2c71f80d74f3
---
M library/NS_Emulation.ttcnpp
1 file changed, 40 insertions(+), 3 deletions(-)



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

diff --git a/library/NS_Emulation.ttcnpp b/library/NS_Emulation.ttcnpp
index d6c7f61..7bede94 100644
--- a/library/NS_Emulation.ttcnpp
+++ b/library/NS_Emulation.ttcnpp
@@ -491,6 +491,42 @@
 		}
 	}
 
+	/* generate a list of v4 + v6 endpoints based on the NSVConfigurations. This is not strictly
+	 * accurate, as we should create a list of _endpoints_, while we actually create a list of
+	 * NSVCs.  Those are only identical as long as our peer only implements one endpoint */
+	private function gen_sns_ip_elems(out template (omit) IP4_Elements v4_out,
+					  out template (omit) IP6_Elements v6_out) runs on NSVC_CT {
+		var integer i;
+		var IP4_Elements v4 := {};
+		var IP6_Elements v6 := {};
+
+		for (i := 0; i < lengthof(g_config.nsvc); i := i + 1) {
+			var NSVCConfiguration nsvc_cfg := g_config.nsvc[i];
+			if (not ischosen(nsvc_cfg.provider.ip)) {
+				continue;
+			}
+			if (nsvc_cfg.provider.ip.address_family == AF_INET) {
+				v4 := v4 & { valueof(ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
+								 nsvc_cfg.provider.ip.local_udp_port)) };
+			} else if (nsvc_cfg.provider.ip.address_family == AF_INET6) {
+				v6 := v6 & { valueof(ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
+								 nsvc_cfg.provider.ip.local_udp_port)) };
+			}
+		}
+
+		/* we must not return empty lists, but 'omit' as otherwise we get wrong SNS IEs */
+		if (lengthof(v4) == 0) {
+			v4_out := omit;
+		} else {
+			v4_out := v4;
+		}
+		if (lengthof(v6) == 0) {
+			v6_out := omit;
+		} else {
+			v6_out := v6;
+		}
+	}
+
 	/* simple IP Sub-Network Service responder for the SGSN side. This is not a full implementation
 	 * of the protocol, merely sufficient to make the PCU/BSS side happy to proceed */
 	private altstep as_sns_sgsn() runs on NSVC_CT {
@@ -513,9 +549,10 @@
 			/* blindly acknowledge whatever the PCU sends */
 			NSCP.send(ts_SNS_CONFIG_ACK(g_config.nsei, omit));
 			/* send a SNS-CONFIG in response and expect a SNS-CONFIG-ACK */
-			var IP4_Elements v4 := { valueof(ts_SNS_IPv4(g_nsvc_config.provider.ip.local_ip,
-								     g_nsvc_config.provider.ip.local_udp_port)) };
-			NSCP.send(ts_SNS_CONFIG(g_config.nsei, true, v4));
+			var template (omit) IP4_Elements v4;
+			var template (omit) IP6_Elements v6;
+			gen_sns_ip_elems(v4, v6);
+			NSCP.send(ts_SNS_CONFIG(g_config.nsei, true, v4, v6));
 			alt {
 			[] NSCP.receive(tr_SNS_CONFIG_ACK(g_config.nsei, omit)) {
 				/* success */

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/22303
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: I43fe5810b95ebbc9f848856803ac2c71f80d74f3
Gerrit-Change-Number: 22303
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210118/e475e58e/attachment.htm>


More information about the gerrit-log mailing list