Add SGs Interface

Add an SGs interface (3GPP TS 29.118) to osmo-msc in order to support
SMS tunneling and Circuit Switched Fallback (CSFB)

Change-Id: I73359925fc1ca72b33a1466e6ac41307f2f0b11d
Related: OS#3615
diff --git a/tests/msc_vlr/Makefile.am b/tests/msc_vlr/Makefile.am
index 8a5e719..dea63e5 100644
--- a/tests/msc_vlr/Makefile.am
+++ b/tests/msc_vlr/Makefile.am
@@ -57,6 +57,7 @@
 
 noinst_HEADERS = \
 	msc_vlr_tests.h \
+	stubs.h \
 	$(NULL)
 
 EXTRA_DIST = \
diff --git a/tests/msc_vlr/msc_vlr_test_authen_reuse.c b/tests/msc_vlr/msc_vlr_test_authen_reuse.c
index bdbdae3..0972584 100644
--- a/tests/msc_vlr/msc_vlr_test_authen_reuse.c
+++ b/tests/msc_vlr/msc_vlr_test_authen_reuse.c
@@ -24,6 +24,7 @@
 /* NOTE that further auth re-use tests exist in msc_vlr_test_hlr_reject.c */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 static void _test_auth_reuse(enum osmo_rat_type via_ran,
 			     int set_max_reuse_count,
diff --git a/tests/msc_vlr/msc_vlr_test_call.c b/tests/msc_vlr/msc_vlr_test_call.c
index b5f6b6c..29639b5 100644
--- a/tests/msc_vlr/msc_vlr_test_call.c
+++ b/tests/msc_vlr/msc_vlr_test_call.c
@@ -22,6 +22,7 @@
  */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 #include <osmocom/msc/gsm_04_08.h>
 
diff --git a/tests/msc_vlr/msc_vlr_test_gsm_authen.c b/tests/msc_vlr/msc_vlr_test_gsm_authen.c
index f6f1ab6..8dca655 100644
--- a/tests/msc_vlr/msc_vlr_test_gsm_authen.c
+++ b/tests/msc_vlr/msc_vlr_test_gsm_authen.c
@@ -22,6 +22,7 @@
  */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 static void test_gsm_authen()
 {
diff --git a/tests/msc_vlr/msc_vlr_test_gsm_ciph.c b/tests/msc_vlr/msc_vlr_test_gsm_ciph.c
index 31b5f5d..19092e2 100644
--- a/tests/msc_vlr/msc_vlr_test_gsm_ciph.c
+++ b/tests/msc_vlr/msc_vlr_test_gsm_ciph.c
@@ -22,6 +22,7 @@
  */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 static void test_ciph()
 {
diff --git a/tests/msc_vlr/msc_vlr_test_hlr_reject.c b/tests/msc_vlr/msc_vlr_test_hlr_reject.c
index 13bed42..c613ff9 100644
--- a/tests/msc_vlr/msc_vlr_test_hlr_reject.c
+++ b/tests/msc_vlr/msc_vlr_test_hlr_reject.c
@@ -22,6 +22,7 @@
  */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 static void test_hlr_rej_auth_info_unknown_imsi()
 {
diff --git a/tests/msc_vlr/msc_vlr_test_hlr_timeout.c b/tests/msc_vlr/msc_vlr_test_hlr_timeout.c
index b23a7a7..bb7ef19 100644
--- a/tests/msc_vlr/msc_vlr_test_hlr_timeout.c
+++ b/tests/msc_vlr/msc_vlr_test_hlr_timeout.c
@@ -22,6 +22,7 @@
  */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 #include <osmocom/core/logging.h>
 
diff --git a/tests/msc_vlr/msc_vlr_test_ms_timeout.c b/tests/msc_vlr/msc_vlr_test_ms_timeout.c
index 3702a0c..9eae850 100644
--- a/tests/msc_vlr/msc_vlr_test_ms_timeout.c
+++ b/tests/msc_vlr/msc_vlr_test_ms_timeout.c
@@ -22,6 +22,7 @@
  */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 static void test_ms_timeout_lu_auth_resp()
 {
diff --git a/tests/msc_vlr/msc_vlr_test_no_authen.c b/tests/msc_vlr/msc_vlr_test_no_authen.c
index d52d3d6..df23011 100644
--- a/tests/msc_vlr/msc_vlr_test_no_authen.c
+++ b/tests/msc_vlr/msc_vlr_test_no_authen.c
@@ -22,6 +22,7 @@
  */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 static void test_no_authen()
 {
diff --git a/tests/msc_vlr/msc_vlr_test_reject_concurrency.c b/tests/msc_vlr/msc_vlr_test_reject_concurrency.c
index 66d2e39..ec7117b 100644
--- a/tests/msc_vlr/msc_vlr_test_reject_concurrency.c
+++ b/tests/msc_vlr/msc_vlr_test_reject_concurrency.c
@@ -22,6 +22,7 @@
  */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 static void test_reject_2nd_conn()
 {
diff --git a/tests/msc_vlr/msc_vlr_test_rest.c b/tests/msc_vlr/msc_vlr_test_rest.c
index 4587383..7c17a83 100644
--- a/tests/msc_vlr/msc_vlr_test_rest.c
+++ b/tests/msc_vlr/msc_vlr_test_rest.c
@@ -22,6 +22,7 @@
  */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 static void test_early_stage()
 {
diff --git a/tests/msc_vlr/msc_vlr_test_ss.c b/tests/msc_vlr/msc_vlr_test_ss.c
index 0390196..b264d07 100644
--- a/tests/msc_vlr/msc_vlr_test_ss.c
+++ b/tests/msc_vlr/msc_vlr_test_ss.c
@@ -21,6 +21,7 @@
  */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 #define IMSI "901700000004620"
 
diff --git a/tests/msc_vlr/msc_vlr_test_umts_authen.c b/tests/msc_vlr/msc_vlr_test_umts_authen.c
index beeea22..8528b98 100644
--- a/tests/msc_vlr/msc_vlr_test_umts_authen.c
+++ b/tests/msc_vlr/msc_vlr_test_umts_authen.c
@@ -22,6 +22,7 @@
  */
 
 #include "msc_vlr_tests.h"
+#include "stubs.h"
 
 static void _test_umts_authen(enum osmo_rat_type via_ran)
 {
diff --git a/tests/msc_vlr/stubs.h b/tests/msc_vlr/stubs.h
new file mode 100644
index 0000000..bf55baa
--- /dev/null
+++ b/tests/msc_vlr/stubs.h
@@ -0,0 +1,40 @@
+/* (C) 2018-2019 by sysmocom s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * Author: Harald Welte, Philipp Maier
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+void osmo_stream_srv_link_set_data(struct osmo_stream_srv_link *link, void *data) {}
+struct osmo_fd *osmo_stream_srv_get_ofd(struct osmo_stream_srv *srv) { return NULL; }
+void osmo_stream_srv_destroy(struct osmo_stream_srv *conn) {}
+struct osmo_stream_srv *osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link,
+					       int fd, int (*cb)(struct osmo_stream_srv *conn),
+					       int (*closed_cb)(struct osmo_stream_srv *conn),
+					       void *data) { return NULL; }
+void osmo_stream_srv_send(struct osmo_stream_srv *conn, struct msgb *msg) {}
+void osmo_stream_srv_link_set_proto(struct osmo_stream_srv_link *link, uint16_t proto) {}
+struct osmo_fd *osmo_stream_srv_link_get_ofd(struct osmo_stream_srv_link *link) { return NULL; }
+struct osmo_stream_srv_link *osmo_stream_srv_link_create(void *ctx) { return NULL; }
+void *osmo_stream_srv_get_data(struct osmo_stream_srv *conn) { return NULL; }
+void osmo_stream_srv_link_set_nodelay(struct osmo_stream_srv_link *link, bool nodelay) {}
+void osmo_stream_srv_link_set_accept_cb(struct osmo_stream_srv_link *link, int (*accept_cb)
+					(struct osmo_stream_srv_link *link, int fd)) {}
+int osmo_stream_srv_link_open(struct osmo_stream_srv_link *link) { return 0; }
+void *osmo_stream_srv_link_get_data(struct osmo_stream_srv_link *link) { return NULL; }
+void osmo_stream_srv_link_set_port(struct osmo_stream_srv_link *link, uint16_t port) {}
+void osmo_stream_srv_link_set_addr(struct osmo_stream_srv_link *link, const char *addr) {}
+int sctp_recvmsg(int sd, void *msg, size_t len, void *from, void *fromlen, void *info, int *msg_flags) { return 0; }
diff --git a/tests/sms_queue/sms_queue_test.c b/tests/sms_queue/sms_queue_test.c
index 68819b9..e426377 100644
--- a/tests/sms_queue/sms_queue_test.c
+++ b/tests/sms_queue/sms_queue_test.c
@@ -237,3 +237,24 @@
 
 	return 0;
 }
+
+void osmo_stream_srv_link_set_data(struct osmo_stream_srv_link *link, void *data) {}
+struct osmo_fd *osmo_stream_srv_get_ofd(struct osmo_stream_srv *srv) { return NULL; }
+void osmo_stream_srv_destroy(struct osmo_stream_srv *conn) {}
+struct osmo_stream_srv *osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link,
+					       int fd, int (*cb)(struct osmo_stream_srv *conn),
+					       int (*closed_cb)(struct osmo_stream_srv *conn),
+					       void *data) { return NULL; }
+void osmo_stream_srv_send(struct osmo_stream_srv *conn, struct msgb *msg) {}
+void osmo_stream_srv_link_set_proto(struct osmo_stream_srv_link *link, uint16_t proto) {}
+struct osmo_fd *osmo_stream_srv_link_get_ofd(struct osmo_stream_srv_link *link) { return NULL; }
+struct osmo_stream_srv_link *osmo_stream_srv_link_create(void *ctx) { return NULL; }
+void *osmo_stream_srv_get_data(struct osmo_stream_srv *conn) { return NULL; }
+void osmo_stream_srv_link_set_nodelay(struct osmo_stream_srv_link *link, bool nodelay) {}
+void osmo_stream_srv_link_set_accept_cb(struct osmo_stream_srv_link *link, int (*accept_cb)
+					(struct osmo_stream_srv_link *link, int fd)) {}
+int osmo_stream_srv_link_open(struct osmo_stream_srv_link *link) { return 0; }
+void *osmo_stream_srv_link_get_data(struct osmo_stream_srv_link *link) { return NULL; }
+void osmo_stream_srv_link_set_port(struct osmo_stream_srv_link *link, uint16_t port) {}
+void osmo_stream_srv_link_set_addr(struct osmo_stream_srv_link *link, const char *addr) {}
+int sctp_recvmsg(int sd, void *msg, size_t len, void *from, void *fromlen, void *info, int *msg_flags) { return 0; }
diff --git a/tests/test_nodes.vty b/tests/test_nodes.vty
index c62c692..f2312d1 100644
--- a/tests/test_nodes.vty
+++ b/tests/test_nodes.vty
@@ -4,6 +4,7 @@
 ...
   network
   msc
+  sgs
   mncc-int
   hlr
 ...
@@ -92,6 +93,18 @@
 OsmoMSC# configure terminal
 OsmoMSC(config)# network
 OsmoMSC(config-net)# end
+
+OsmoMSC# configure terminal
+OsmoMSC(config)# sgs
+OsmoMSC(config-sgs)# list
+...
+  local-ip A.B.C.D
+  local-port <0-65535>
+  timer (ts5|ts6-2|ts7|ts11|ts14|ts15) <1-120>
+  counter (ns7|ns11) <0-255>
+  vlr-name FQDN
+OsmoMSC(config-sgs)# end
+
 OsmoMSC# disable
 OsmoMSC> enable
 
@@ -125,4 +138,7 @@
 hlr
  remote-ip 127.0.0.1
  remote-port 4222
+sgs
+ local-ip 0.0.0.0
+ vlr-name vlr.example.net
 end