Change in osmo-hlr[master]: add mslookup_manual_test

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

neels gerrit-no-reply at lists.osmocom.org
Mon Nov 25 04:46:06 UTC 2019


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16210 )


Change subject: add mslookup_manual_test
......................................................................

add mslookup_manual_test

This can be used for manually testing proxy routing. It is not run as part of
the testsuite.

Change-Id: I80473528c9524263b60fc3ba37ba246c80bfe452
---
M .gitignore
M configure.ac
M tests/Makefile.am
A tests/mslookup_manual_test/Makefile.am
A tests/mslookup_manual_test/fake_msc.c
A tests/mslookup_manual_test/osmo-hlr-1.cfg
A tests/mslookup_manual_test/osmo-hlr-2.cfg
A tests/mslookup_manual_test/run.sh
8 files changed, 241 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/10/16210/1

diff --git a/.gitignore b/.gitignore
index 1dfa33b..4162ab9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,6 +51,7 @@
 tests/gsup/gsup_test
 tests/db/db_test
 tests/hlr_vty_test.db*
+tests/mslookup_manual_test/fake_msc
 
 # manuals
 doc/manuals/*.html
diff --git a/configure.ac b/configure.ac
index ae18286..bd74527 100644
--- a/configure.ac
+++ b/configure.ac
@@ -192,4 +192,5 @@
 	tests/db/Makefile
 	tests/db_upgrade/Makefile
 	tests/mslookup/Makefile
+	tests/mslookup_manual_test/Makefile
 	)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bc5fc87..396a731 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,6 +4,7 @@
 	db \
 	db_upgrade \
 	mslookup \
+	mslookup_manual_test \
 	$(NULL)
 
 # The `:;' works around a Bash 3.2 bug when the output is not writeable.
diff --git a/tests/mslookup_manual_test/Makefile.am b/tests/mslookup_manual_test/Makefile.am
new file mode 100644
index 0000000..5a0331b
--- /dev/null
+++ b/tests/mslookup_manual_test/Makefile.am
@@ -0,0 +1,41 @@
+AM_CPPFLAGS = \
+	$(all_includes) \
+	-I$(top_srcdir)/include \
+	$(NULL)
+
+AM_CFLAGS = \
+	-Wall \
+	-ggdb3 \
+	-I$(top_srcdir)/include \
+	$(LIBOSMOCORE_CFLAGS) \
+	$(LIBOSMOGSM_CFLAGS) \
+	$(LIBOSMOABIS_CFLAGS) \
+	$(NULL)
+
+AM_LDFLAGS = \
+	-no-install \
+	$(NULL)
+
+EXTRA_DIST = \
+	run.sh \
+	osmo-hlr-1.cfg \
+	osmo-hlr-2.cfg \
+	$(NULL)
+
+noinst_PROGRAMS = \
+	fake_msc \
+	$(NULL)
+
+fake_msc_SOURCES = \
+	fake_msc.c \
+	$(NULL)
+
+fake_msc_LDADD = \
+	$(top_builddir)/src/gsupclient/libosmo-gsup-client.la \
+	$(LIBOSMOCORE_LIBS) \
+	$(LIBOSMOGSM_LIBS) \
+	$(LIBOSMOABIS_LIBS) \
+	$(NULL)
+
+run:
+	$(srcdir)/run.sh $(srcdir) $(builddir)
diff --git a/tests/mslookup_manual_test/fake_msc.c b/tests/mslookup_manual_test/fake_msc.c
new file mode 100644
index 0000000..93439d2
--- /dev/null
+++ b/tests/mslookup_manual_test/fake_msc.c
@@ -0,0 +1,95 @@
+#include <osmocom/core/select.h>
+#include <osmocom/core/application.h>
+#include <osmocom/gsupclient/gsup_client.h>
+#include <osmocom/hlr/logging.h>
+
+void *ctx;
+
+int gsup_client_read_cb(struct osmo_gsup_client *gsupc, struct msgb *msg)
+{
+	struct osmo_gsup_message gsup;
+	if (osmo_gsup_decode(msgb_l2(msg), msgb_l2len(msg), &gsup)) {
+		printf("fake_msc: GSUP rx, but failed to decode\n");
+		return 0;
+	}
+	printf("fake_msc: GSUP rx %s %s (destination_name=%s)\n",
+	       gsup.imsi, osmo_gsup_message_type_name(gsup.message_type),
+	       osmo_quote_str((const char*)gsup.destination_name, gsup.destination_name_len));
+	return 0;
+}
+
+struct osmo_gsup_client *gsupc;
+struct osmo_timer_list do_stuff_timer;
+
+static void gsup_send(const struct osmo_gsup_message *gsup)
+{
+	printf("fake_msc: GSUP tx %s %s\n", gsup->imsi, osmo_gsup_message_type_name(gsup->message_type));
+	osmo_gsup_client_enc_send(gsupc, gsup);
+}
+
+void do_stuff(void *data)
+{
+	static int i = 0;
+	int seq = 0;
+	if (i == seq++) {
+		struct osmo_gsup_message gsup = {
+			.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST,
+			.imsi = "901700000014701",
+			.cn_domain = OSMO_GSUP_CN_DOMAIN_CS,
+		};
+		gsup_send(&gsup);
+	}
+
+	seq += 3;
+	if (i == seq++) {
+		struct osmo_gsup_message gsup = {
+			.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST,
+			.imsi = "901700000014701",
+			.cn_domain = OSMO_GSUP_CN_DOMAIN_CS,
+		};
+		gsup_send(&gsup);
+	}
+
+	if (i == seq++) {
+		struct osmo_gsup_message gsup = {
+			.message_type = OSMO_GSUP_MSGT_INSERT_DATA_RESULT,
+			.imsi = "901700000014701",
+			.cn_domain = OSMO_GSUP_CN_DOMAIN_CS,
+		};
+		gsup_send(&gsup);
+	}
+
+	seq += 60;
+	if (i == seq++) {
+		exit(0);
+	}
+
+	i++;
+	osmo_timer_schedule(&do_stuff_timer, 1, 0);
+}
+
+int main()
+{
+	ctx = talloc_named_const(NULL, 0, "main");
+	osmo_init_logging2(ctx, NULL);
+
+	log_set_print_filename(osmo_stderr_target, 0);
+	log_set_print_level(osmo_stderr_target, 0);
+	log_set_print_category(osmo_stderr_target, 0);
+	log_set_print_category_hex(osmo_stderr_target, 0);
+	log_set_use_color(osmo_stderr_target, 0);
+	log_set_category_filter(osmo_stderr_target, DMSLOOKUP, true, LOGL_DEBUG);
+
+	struct ipaccess_unit gsup_client_name = {
+		.unit_name = "fake-msc-1",
+		.serno = "fake-msc-1",
+	};
+	gsupc = osmo_gsup_client_create2(ctx, &gsup_client_name, "127.0.0.42", OSMO_GSUP_PORT, gsup_client_read_cb,
+					 NULL);
+
+	osmo_timer_setup(&do_stuff_timer, do_stuff, NULL);
+	osmo_timer_schedule(&do_stuff_timer, 1, 0);
+	for (;;) {
+		osmo_select_main_ctx(0);
+	}
+}
diff --git a/tests/mslookup_manual_test/osmo-hlr-1.cfg b/tests/mslookup_manual_test/osmo-hlr-1.cfg
new file mode 100644
index 0000000..2f33e3e
--- /dev/null
+++ b/tests/mslookup_manual_test/osmo-hlr-1.cfg
@@ -0,0 +1,40 @@
+hlr
+ gsup
+  bind ip 127.0.0.1
+  ipa-name testHLR-1
+ ussd route prefix *0# internal own-msisdn
+ ussd route prefix *1# internal own-imsi
+ ussd route prefix *#100# internal own-msisdn
+ ussd route prefix *#101# internal own-imsi
+ store-imei
+
+line vty
+ bind 127.0.0.1
+ctrl
+ bind 127.0.0.1
+
+mslookup
+ mdns
+
+log stderr
+ logging filter all 1
+ logging color 1
+ logging print level 1
+ logging print category 1
+ logging print category-hex 0
+ logging print file basename last
+ logging print extended-timestamp 1
+ logging level set-all debug
+ logging level linp error
+
+log gsmtap 127.0.0.1
+ logging filter all 1
+ logging color 1
+ logging print level 1
+ logging print category 1
+ logging print category-hex 0
+ logging print file basename last
+ logging print extended-timestamp 1
+ logging level set-all debug
+ logging level linp error
+
diff --git a/tests/mslookup_manual_test/osmo-hlr-2.cfg b/tests/mslookup_manual_test/osmo-hlr-2.cfg
new file mode 100644
index 0000000..06ddd4f
--- /dev/null
+++ b/tests/mslookup_manual_test/osmo-hlr-2.cfg
@@ -0,0 +1,40 @@
+hlr
+ gsup
+  bind ip 127.0.0.2
+  ipa-name testHLR-2
+ ussd route prefix *0# internal own-msisdn
+ ussd route prefix *1# internal own-imsi
+ ussd route prefix *#100# internal own-msisdn
+ ussd route prefix *#101# internal own-imsi
+ store-imei
+
+line vty
+ bind 127.0.0.2
+ctrl
+ bind 127.0.0.2
+
+mslookup
+ mdns
+
+log stderr
+ logging filter all 1
+ logging color 1
+ logging print level 1
+ logging print category 1
+ logging print category-hex 0
+ logging print file basename last
+ logging timestamp 1
+ logging level set-all debug
+ logging level linp error
+
+log gsmtap 127.0.0.1
+ logging filter all 1
+ logging color 1
+ logging print level 1
+ logging print category 1
+ logging print category-hex 0
+ logging print file basename last
+ logging print extended-timestamp 1
+ logging level set-all debug
+ logging level linp error
+
diff --git a/tests/mslookup_manual_test/run.sh b/tests/mslookup_manual_test/run.sh
new file mode 100755
index 0000000..ea4dabf
--- /dev/null
+++ b/tests/mslookup_manual_test/run.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+srcdir="${1:-.}"
+builddir="${2:-.}"
+
+cd "$builddir"
+
+osmo-hlr -c "$srcdir/osmo-hlr-1.cfg" -l hlr1.db &
+sleep 1
+osmo-hlr -c "$srcdir/osmo-hlr-2.cfg" -l hlr2.db &
+
+sleep 1
+osmo_interact_vty.py -H 127.0.0.1 -p 4258 -c 'enable; subscriber imsi 111111 create; subscriber imsi 111111 update msisdn 1'
+osmo_interact_vty.py -H 127.0.0.2 -p 4258 -c 'enable; subscriber imsi 222222 create; subscriber imsi 222222 update msisdn 2'
+sleep 1
+
+./fake_msc &
+
+echo enter to exit
+read enter_to_exit
+kill %1 %2 %3
+killall osmo-hlr
+killall fake_msc

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16210
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I80473528c9524263b60fc3ba37ba246c80bfe452
Gerrit-Change-Number: 16210
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191125/560558de/attachment.htm>


More information about the gerrit-log mailing list