Change in osmo-ttcn3-hacks[master]: NS_Emulation: Add minimal support for SGSN-side SNS handling

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Mar 27 11:17:49 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/13046 )

Change subject: NS_Emulation: Add minimal support for SGSN-side SNS handling
......................................................................

NS_Emulation: Add minimal support for SGSN-side SNS handling

Change-Id: I1edf739d6fd39478f662a28a7d9334ca51c270a3
---
M library/NS_Emulation.ttcn
M pcu/PCU_Tests.ttcn
M sgsn/SGSN_Tests.ttcn
3 files changed, 57 insertions(+), 5 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/library/NS_Emulation.ttcn b/library/NS_Emulation.ttcn
index 6915993..9ad89cb 100644
--- a/library/NS_Emulation.ttcn
+++ b/library/NS_Emulation.ttcn
@@ -116,7 +116,9 @@
 		PortNumber remote_udp_port,
 		charstring remote_ip,
 		Nsvci nsvci,
-		Nsvci nsei
+		Nsvci nsei,
+		boolean role_sgsn,
+		boolean handle_sns
 	}
 
 	private function f_change_state(NseState new_state) runs on NS_CT {
@@ -192,6 +194,8 @@
 			/* FIXME */
 		}
 
+		[config.role_sgsn and config.handle_sns] as_sns_sgsn();
+
 		/* default case of handling unknown PDUs */
 		[] NSCP.receive(t_NS_RecvFrom(?)) -> value rf {
 			log("Rx Unexpected NS PDU ", rf.msg," in state ", g_state);
@@ -201,6 +205,46 @@
 		[] NSCP.receive(ASP_Event:?) -> value evt { NS_SP.send(evt); }
 	}
 
+	/* 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 */
+	altstep as_sns_sgsn() runs on NS_CT {
+		var NS_RecvFrom rf;
+		[] NSCP.receive(t_NS_RecvFrom(tr_SNS_SIZE(config.nsei))) -> value rf {
+			/* blindly acknowledge whatever the PCU sends */
+			NSCP.send(t_NS_Send(g_conn_id, ts_SNS_SIZE_ACK(config.nsei, omit)));
+		}
+		[] NSCP.receive(t_NS_RecvFrom(tr_SNS_SIZE(?))) {
+			setverdict(fail, "SNS-SIZE from unexpected NSEI");
+			self.stop;
+		}
+		[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(config.nsei, true,
+				    {tr_SNS_IPv4(config.remote_ip, config.remote_udp_port)}))) -> value rf {
+			/* blindly acknowledge whatever the PCU sends */
+			NSCP.send(t_NS_Send(g_conn_id, ts_SNS_CONFIG_ACK(config.nsei, omit)));
+			/* send a SNS-CONFIG in response and expect a SNS-CONFIG-ACK */
+			var IP4_Elements v4 := { valueof(ts_SNS_IPv4(config.local_ip, config.local_udp_port)) };
+			NSCP.send(t_NS_Send(g_conn_id, ts_SNS_CONFIG(config.nsei, true, v4)));
+			alt {
+			[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG_ACK(config.nsei, omit))) {
+				/* success */
+				}
+			[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG_ACK(config.nsei, ?))) {
+				setverdict(fail, "Unexpected SNS-CONFIG-NACK");
+				self.stop;
+				}
+			}
+		}
+		[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(config.nsei, false, ?))) { /* ignore */}
+		[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(config.nsei, true, ?))) {
+			setverdict(fail, "Unexpected SNS-CONFIG content");
+			self.stop;
+		}
+		[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(?, ?, ?))) {
+			setverdict(fail, "SNS-CONFIG from unexpected NSEI");
+			self.stop;
+		}
+	}
+
 	private function f_ScanEvents() runs on NS_CT {
 		var NsUnitdataRequest ud_req;
 		var NS_RecvFrom rf;
diff --git a/pcu/PCU_Tests.ttcn b/pcu/PCU_Tests.ttcn
index 6e8185d..f63c4ad 100644
--- a/pcu/PCU_Tests.ttcn
+++ b/pcu/PCU_Tests.ttcn
@@ -43,7 +43,9 @@
 			remote_udp_port := 21000,
 			remote_ip := "127.0.0.1",
 			nsvci := 0,
-			nsei := 2342
+			nsei := 2342,
+			role_sgsn := true,
+			handle_sns := true
 		};
 	}
 
diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index a2e93c0..8b639e6 100644
--- a/sgsn/SGSN_Tests.ttcn
+++ b/sgsn/SGSN_Tests.ttcn
@@ -51,7 +51,9 @@
 			remote_udp_port := 23000,
 			remote_ip := "127.0.0.1",
 			nsvci := 97,
-			nsei := 96
+			nsei := 96,
+			role_sgsn := false,
+			handle_sns := false
 		},
 		{
 			local_udp_port := 21011,
@@ -59,7 +61,9 @@
 			remote_udp_port := 23000,
 			remote_ip := "127.0.0.1",
 			nsvci := 98,
-			nsei := 97
+			nsei := 97,
+			role_sgsn := false,
+			handle_sns := false
 		},
 		{
 			local_udp_port := 21012,
@@ -67,7 +71,9 @@
 			remote_udp_port := 23000,
 			remote_ip := "127.0.0.1",
 			nsvci := 99,
-			nsei := 98
+			nsei := 98,
+			role_sgsn := false,
+			handle_sns := false
 		}
 	};
 };

-- 
To view, visit https://gerrit.osmocom.org/13046
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I1edf739d6fd39478f662a28a7d9334ca51c270a3
Gerrit-Change-Number: 13046
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190327/51d51e0b/attachment.htm>


More information about the gerrit-log mailing list