SGSN: Some initial SNS tests for IP-SNS in OsmoSGSN

Change-Id: I821d998704756fa30278f41d0371051db9d3fc58
diff --git a/sgsn/SGSN_Tests_NS.ttcn b/sgsn/SGSN_Tests_NS.ttcn
index dd68b05..e5d012f 100644
--- a/sgsn/SGSN_Tests_NS.ttcn
+++ b/sgsn/SGSN_Tests_NS.ttcn
@@ -47,9 +47,74 @@
 	f_clean_ns_codec();
 }
 
+/* perform outgoing SNS-SIZE procedure */
+testcase TC_SNS_size() runs on RAW_Test_CT {
+	f_init_vty();
+	f_init_ns_codec(mp_nsconfig[0], guard_secs := 10.0);
+	g_handle_rx_alive := true;
+
+	f_outgoing_sns_size();
+	setverdict(pass);
+}
+
+/* outgoing SNS-SIZE procedure with more BSS side IPs than SGSN can handle */
+testcase TC_SNS_size_too_big() runs on RAW_Test_CT {
+	f_init_vty();
+	f_init_ns_codec(mp_nsconfig[0], guard_secs := 10.0);
+	g_handle_rx_alive := true;
+
+	f_outgoing_sns_size(cause := NS_CAUSE_INVALID_NR_OF_NSVCS, num_ip := 100);
+	setverdict(pass);
+}
+
+/* perform outgoing SNS-CONFIG procedure (for BSS) */
+testcase TC_SNS_config_bss() runs on RAW_Test_CT {
+	f_init_vty();
+	f_init_ns_codec(mp_nsconfig[0], guard_secs := 10.0);
+	g_handle_rx_alive := true;
+
+	f_outgoing_sns_size();
+	f_outgoing_sns_config();
+	setverdict(pass);
+}
+
+/* perform incoming SNS-CONFIG procedure (for SGSN) */
+testcase TC_SNS_config_sgsn() runs on RAW_Test_CT {
+	f_init_vty();
+	f_init_ns_codec(mp_nsconfig[0], guard_secs := 10.0);
+	g_handle_rx_alive := true;
+
+	f_outgoing_sns_size();
+	f_outgoing_sns_config();
+	f_incoming_sns_config();
+	setverdict(pass);
+}
+
+/* perform full SNS handshake and then outbound NS-ALIVE */
+testcase TC_SNS_and_alive() runs on RAW_Test_CT {
+	f_init_vty();
+	f_init_ns_codec(mp_nsconfig[0], guard_secs := 120.0);
+	g_handle_rx_alive := true;
+
+	f_outgoing_sns_size();
+	f_outgoing_sns_config();
+	f_incoming_sns_config();
+	f_outgoing_ns_alive();
+	setverdict(pass);
+}
+
 control {
-	execute( TC_NS_connect_alive() );
-	execute( TC_NS_connect_reset() );
+
+	if (mp_nsconfig[0].handle_sns) {
+		execute( TC_SNS_size() );
+		execute( TC_SNS_size_too_big() );
+		execute( TC_SNS_config_bss() );
+		execute( TC_SNS_config_sgsn() );
+		execute( TC_SNS_and_alive() );
+	} else {
+		execute( TC_NS_connect_alive() );
+		execute( TC_NS_connect_reset() );
+	}
 }
 
 }
diff --git a/sgsn/SGSN_Tests_SNS.cfg b/sgsn/SGSN_Tests_SNS.cfg
new file mode 100644
index 0000000..d4dcea0
--- /dev/null
+++ b/sgsn/SGSN_Tests_SNS.cfg
@@ -0,0 +1,72 @@
+[ORDERED_INCLUDE]
+# Common configuration, shared between test suites
+"../Common.cfg"
+# testsuite specific configuration, not expected to change
+"./SGSN_Tests.default"
+
+# Local configuration below
+
+[LOGGING]
+
+[TESTPORT_PARAMETERS]
+*.SGSNVTY.CTRL_HOSTNAME := "127.0.0.10"
+
+[MODULE_PARAMETERS]
+SGSN_Tests.mp_nsconfig := {
+	{
+		handle_sns := true,
+		nsvc := {
+			{
+				provider := {
+					ip := {
+						address_family := AF_INET,
+						local_ip := "127.0.0.103",
+						remote_ip := "127.0.0.10"
+					}
+				}
+			}
+		}
+	},
+	{
+		handle_sns := true,
+		nsvc := {
+			{
+				provider := {
+					ip := {
+						address_family := AF_INET,
+						local_ip := "127.0.0.103",
+						remote_ip := "127.0.0.10"
+					}
+				}
+			}
+		}
+	},
+	{
+		handle_sns := true,
+		nsvc := {
+			{
+				provider := {
+					ip := {
+						address_family := AF_INET,
+						local_ip := "127.0.0.103",
+						remote_ip := "127.0.0.10"
+					}
+				}
+			}
+		}
+	}
+}
+SGSN_Tests.mp_ranap_cfg := {
+	{
+		sctp_addr := { 23908, "127.0.0.103", 2905, "127.0.0.200" }
+	}
+}
+SGSN_Tests.mp_hlr_ip := "127.0.0.103"
+SGSN_Tests.mp_ggsn_ip := "127.0.0.103"
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
+SGSN_Tests.control
+SGSN_Tests_Iu.control
+SGSN_Tests_NS.control
diff --git a/sgsn/osmo-sgsn.sns.cfg b/sgsn/osmo-sgsn.sns.cfg
new file mode 100644
index 0000000..69f5147
--- /dev/null
+++ b/sgsn/osmo-sgsn.sns.cfg
@@ -0,0 +1,105 @@
+!
+! OsmoSGSN (1.2.0.46-e77e-dirty) configuration saved from vty
+!!
+!
+log gsmtap 127.0.0.1
+ logging level set-all debug
+ logging filter all 1
+!
+log stderr
+ logging filter all 1
+ logging color 1
+ logging print category 1
+ logging print category-hex 0
+ logging timestamp 1
+ logging print extended-timestamp 1
+ logging print file 1
+ logging level all everything
+ logging level mm debug
+ logging level pag notice
+ logging level meas notice
+ logging level ref notice
+ logging level gprs debug
+ logging level lns debug
+ logging level lbssgp info
+ logging level llc debug
+ logging level sndcp debug
+ logging level slhc notice
+ logging level ranap info
+ logging level sua info
+ logging level v42bis info
+ logging level lglobal info
+ logging level llapd notice
+ logging level linp notice
+ logging level lmux notice
+ logging level lmi notice
+ logging level lmib notice
+ logging level lsms notice
+ logging level lctrl notice
+ logging level lgtp debug
+ logging level lstats notice
+ logging level lgsup debug
+ logging level loap notice
+ logging level lss7 notice
+ logging level lsccp info
+ logging level lsua notice
+ logging level lm3ua notice
+ logging level lmgcp notice
+!
+stats interval 5
+!
+line vty
+ no login
+ bind 127.0.0.10
+ctrl
+ bind 127.0.0.10
+!
+cs7 instance 0
+ point-code 0.23.4
+ asp asp-clnt-OsmoSGSN-A 2905 0 m3ua
+  remote-ip 127.0.0.200
+ as as-clnt-OsmoSGSN-A m3ua
+  asp asp-clnt-OsmoSGSN-A
+  routing-key 3 0.23.4
+ns
+ timer tns-block 3
+ timer tns-block-retries 3
+ timer tns-reset 3
+ timer tns-reset-retries 3
+ timer tns-test 30
+ timer tns-alive 3
+ timer tns-alive-retries 10
+ bind udp local10
+  listen 127.0.0.10 23000
+  accept-dynamic-ip-sns
+ bind udp local10_1
+  listen 127.0.0.10 23001
+ ip-sns-default bind local10
+ !ip-sns-default bind local10_1
+bssgp
+sgsn
+ gtp local-ip 127.0.0.10
+ ggsn 0 remote-ip 127.0.0.103
+ ggsn 0 gtp-version 1
+ gsup remote-ip 127.0.0.103
+ gsup remote-port 4222
+ auth-policy remote
+ gsup oap-id 0
+ ! apn * ggsn 0
+ no cdr filename
+ no cdr trap
+ cdr interval 600
+ timer t3312 600
+ timer t3322 6
+ timer t3350 6
+ timer t3360 6
+ timer t3370 6
+ timer t3313 30
+ timer t3314 44
+ timer t3316 44
+ timer t3385 8
+ timer t3386 8
+ timer t3395 8
+ timer t3397 8
+ no compression rfc1144
+ no compression v42bis