aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-07-04 23:08:44 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2017-08-27 17:40:52 +0200
commited3157ce46cde0f3973a5ee0a0a53909f361ae7c (patch)
tree072f9b723003554bead716390f6ed8bf7351d103 /tests
parent2758330b6ab37ff30afca8306080f0e82ef5a732 (diff)
move openbsc/* to repos root
This is the first step in creating this repository from the legacy openbsc.git. Like all other Osmocom repositories, keep the autoconf and automake files in the repository root. openbsc.git has been the sole exception, which ends now. Change-Id: I9c6f2a448d9cb1cc088cf1cf6918b69d7e69b4e7
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am112
-rw-r--r--tests/abis/Makefile.am34
-rw-r--r--tests/abis/abis_test.c93
-rw-r--r--tests/abis/abis_test.ok9
-rw-r--r--tests/atlocal.in7
-rw-r--r--tests/bsc-nat-trie/Makefile.am17
-rw-r--r--tests/bsc-nat-trie/bsc_nat_trie_test.c87
-rw-r--r--tests/bsc-nat-trie/bsc_nat_trie_test.ok20
-rw-r--r--tests/bsc-nat-trie/prefixes.csv25
-rw-r--r--tests/bsc-nat/Makefile.am59
-rw-r--r--tests/bsc-nat/barr.cfg12
-rw-r--r--tests/bsc-nat/barr_dup.cfg2
-rw-r--r--tests/bsc-nat/bsc_data.c275
-rw-r--r--tests/bsc-nat/bsc_nat_test.c1584
-rw-r--r--tests/bsc-nat/bsc_nat_test.ok39
-rw-r--r--tests/bsc-nat/prefixes.csv2
-rw-r--r--tests/bsc/Makefile.am46
-rw-r--r--tests/bsc/bsc_test.c209
-rw-r--r--tests/bsc/bsc_test.ok4
-rw-r--r--tests/channel/Makefile.am35
-rw-r--r--tests/channel/channel_test.c144
-rw-r--r--tests/channel/channel_test.ok3
-rw-r--r--tests/ctrl_test_runner.py683
-rw-r--r--tests/db/Makefile.am48
-rw-r--r--tests/db/db_test.c256
-rw-r--r--tests/db/db_test.err2
-rw-r--r--tests/db/db_test.ok4
-rw-r--r--tests/db/hlr.sqlite3bin0 -> 29696 bytes
-rw-r--r--tests/gbproxy/Makefile.am54
-rw-r--r--tests/gbproxy/gbproxy_test.c4971
-rw-r--r--tests/gbproxy/gbproxy_test.ok7244
-rw-r--r--tests/gprs/Makefile.am10
-rw-r--r--tests/gprs/gprs_test.c236
-rw-r--r--tests/gprs/gprs_test.ok17
-rw-r--r--tests/gsm0408/Makefile.am34
-rw-r--r--tests/gsm0408/gsm0408_test.c697
-rw-r--r--tests/gsm0408/gsm0408_test.ok204
-rw-r--r--tests/gtphub/Makefile.am42
-rw-r--r--tests/gtphub/gtphub_test.c1786
-rw-r--r--tests/gtphub/gtphub_test.ok42
-rw-r--r--tests/mgcp/Makefile.am72
-rw-r--r--tests/mgcp/mgcp_test.c1227
-rw-r--r--tests/mgcp/mgcp_test.ok480
-rw-r--r--tests/mgcp/mgcp_transcoding_test.c654
-rw-r--r--tests/mgcp/mgcp_transcoding_test.ok539
-rw-r--r--tests/mm_auth/Makefile.am37
-rw-r--r--tests/mm_auth/mm_auth_test.c340
-rw-r--r--tests/mm_auth/mm_auth_test.ok40
-rw-r--r--tests/nanobts_omlattr/Makefile.am34
-rw-r--r--tests/nanobts_omlattr/nanobts_omlattr_test.c284
-rw-r--r--tests/nanobts_omlattr/nanobts_omlattr_test.ok26
-rw-r--r--tests/oap/Makefile.am36
-rw-r--r--tests/oap/oap_client_test.c270
-rw-r--r--tests/oap/oap_client_test.err35
-rw-r--r--tests/oap/oap_client_test.ok2
-rw-r--r--tests/sgsn/Makefile.am82
-rw-r--r--tests/sgsn/sgsn_test.c2487
-rw-r--r--tests/sgsn/sgsn_test.ok45
-rw-r--r--tests/slhc/Makefile.am15
-rw-r--r--tests/slhc/slhc_test.c272
-rw-r--r--tests/slhc/slhc_test.ok154
-rw-r--r--tests/smpp/Makefile.am40
-rw-r--r--tests/smpp/smpp_test.c73
-rw-r--r--tests/smpp/smpp_test.err2
-rw-r--r--tests/smpp/smpp_test.ok1
-rw-r--r--tests/smpp_test_runner.py137
-rw-r--r--tests/sndcp_xid/Makefile.am21
-rw-r--r--tests/sndcp_xid/sndcp_xid_test.c284
-rw-r--r--tests/sndcp_xid/sndcp_xid_test.ok11
-rw-r--r--tests/subscr/Makefile.am61
-rw-r--r--tests/subscr/bsc_subscr_test.c130
-rw-r--r--tests/subscr/bsc_subscr_test.err17
-rw-r--r--tests/subscr/bsc_subscr_test.ok11
-rw-r--r--tests/subscr/subscr_test.c117
-rw-r--r--tests/subscr/subscr_test.ok3
-rw-r--r--tests/testsuite.at167
-rw-r--r--tests/trau/Makefile.am45
-rw-r--r--tests/trau/trau_test.c84
-rw-r--r--tests/trau/trau_test.ok10
-rw-r--r--tests/v42bis/Makefile.am15
-rw-r--r--tests/v42bis/v42bis_test.c435
-rw-r--r--tests/v42bis/v42bis_test.ok648
-rw-r--r--tests/vty_test_runner.py1401
-rw-r--r--tests/xid/Makefile.am39
-rw-r--r--tests/xid/xid_test.c164
-rw-r--r--tests/xid/xid_test.ok12
86 files changed, 30207 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 000000000..9cbc1c172
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,112 @@
+SUBDIRS = \
+ gsm0408 \
+ db \
+ channel \
+ mgcp \
+ gprs \
+ abis \
+ gbproxy \
+ trau \
+ subscr \
+ mm_auth \
+ nanobts_omlattr \
+ $(NULL)
+
+if BUILD_NAT
+SUBDIRS += \
+ bsc-nat \
+ bsc-nat-trie \
+ $(NULL)
+endif
+if BUILD_BSC
+SUBDIRS += \
+ bsc \
+ $(NULL)
+endif
+if BUILD_SMPP
+SUBDIRS += \
+ smpp \
+ $(NULL)
+endif
+if HAVE_LIBGTP
+SUBDIRS += \
+ gtphub \
+ $(NULL)
+
+if HAVE_LIBCARES
+SUBDIRS += \
+ sgsn \
+ oap \
+ xid \
+ sndcp_xid \
+ slhc \
+ v42bis \
+ $(NULL)
+endif
+endif
+
+# The `:;' works around a Bash 3.2 bug when the output is not writeable.
+$(srcdir)/package.m4: $(top_srcdir)/configure.ac
+ :;{ \
+ echo '# Signature of the current package.' && \
+ echo 'm4_define([AT_PACKAGE_NAME],' && \
+ echo ' [$(PACKAGE_NAME)])' && \
+ echo 'm4_define([AT_PACKAGE_TARNAME],' && \
+ echo ' [$(PACKAGE_TARNAME)])' && \
+ echo 'm4_define([AT_PACKAGE_VERSION],' && \
+ echo ' [$(PACKAGE_VERSION)])' && \
+ echo 'm4_define([AT_PACKAGE_STRING],' && \
+ echo ' [$(PACKAGE_STRING)])' && \
+ echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \
+ echo ' [$(PACKAGE_BUGREPORT)])'; \
+ echo 'm4_define([AT_PACKAGE_URL],' && \
+ echo ' [$(PACKAGE_URL)])'; \
+ } >'$(srcdir)/package.m4'
+
+EXTRA_DIST = \
+ testsuite.at \
+ $(srcdir)/package.m4 \
+ $(TESTSUITE) \
+ vty_test_runner.py \
+ ctrl_test_runner.py \
+ smpp_test_runner.py \
+ $(NULL)
+
+TESTSUITE = $(srcdir)/testsuite
+
+DISTCLEANFILES = \
+ atconfig \
+ $(NULL)
+
+if ENABLE_EXT_TESTS
+python-tests: $(BUILT_SOURCES)
+ osmotestvty.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v
+ osmotestconfig.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v
+ $(PYTHON) $(srcdir)/vty_test_runner.py -w $(abs_top_builddir) -v
+ $(PYTHON) $(srcdir)/ctrl_test_runner.py -w $(abs_top_builddir) -v
+if BUILD_SMPP
+ $(PYTHON) $(srcdir)/smpp_test_runner.py -w $(abs_top_builddir) -v
+endif
+ rm -f $(top_builddir)/hlr.sqlite3
+else
+python-tests: $(BUILT_SOURCES)
+ echo "Not running python-based tests (determined at configure-time)"
+endif
+
+check-local: atconfig $(TESTSUITE)
+ $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
+ $(MAKE) $(AM_MAKEFLAGS) python-tests
+
+installcheck-local: atconfig $(TESTSUITE)
+ $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \
+ $(TESTSUITEFLAGS)
+
+clean-local:
+ test ! -f '$(TESTSUITE)' || \
+ $(SHELL) '$(TESTSUITE)' --clean
+
+AUTOM4TE = $(SHELL) $(top_srcdir)/missing --run autom4te
+AUTOTEST = $(AUTOM4TE) --language=autotest
+$(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4
+ $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
+ mv $@.tmp $@
diff --git a/tests/abis/Makefile.am b/tests/abis/Makefile.am
new file mode 100644
index 000000000..1c5dede3b
--- /dev/null
+++ b/tests/abis/Makefile.am
@@ -0,0 +1,34 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(COVERAGE_CFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ abis_test.ok \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ abis_test \
+ $(NULL)
+
+abis_test_SOURCES = \
+ abis_test.c \
+ $(NULL)
+
+abis_test_LDADD = \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOABIS_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(NULL)
diff --git a/tests/abis/abis_test.c b/tests/abis/abis_test.c
new file mode 100644
index 000000000..591f8350f
--- /dev/null
+++ b/tests/abis/abis_test.c
@@ -0,0 +1,93 @@
+/*
+ * (C) 2012 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * All Rights Reserved
+ *
+ * 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 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/>.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/gsm/protocol/gsm_12_21.h>
+
+#include <openbsc/gsm_data.h>
+#include <openbsc/abis_nm.h>
+#include <openbsc/debug.h>
+
+static const uint8_t load_config[] = {
+ 0x42, 0x12, 0x00, 0x08, 0x31, 0x36, 0x38, 0x64,
+ 0x34, 0x37, 0x32, 0x00, 0x13, 0x00, 0x0b, 0x76,
+ 0x32, 0x30, 0x30, 0x62, 0x31, 0x34, 0x33, 0x64,
+ 0x30, 0x00, 0x42, 0x12, 0x00, 0x08, 0x31, 0x36,
+ 0x38, 0x64, 0x34, 0x37, 0x32, 0x00, 0x13, 0x00,
+ 0x0b, 0x76, 0x32, 0x30, 0x30, 0x62, 0x31, 0x34,
+ 0x33, 0x64, 0x31, 0x00
+};
+
+static void test_sw_selection(void)
+{
+ struct abis_nm_sw_desc descr[8], tmp;
+ uint16_t len0, len1;
+ int rc, pos;
+
+ rc = abis_nm_get_sw_conf(load_config, ARRAY_SIZE(load_config),
+ &descr[0], ARRAY_SIZE(descr));
+ if (rc != 2) {
+ printf("%s(): FAILED to parse the File Id/File version: %d\n",
+ __func__, rc);
+ abort();
+ }
+
+ len0 = abis_nm_sw_desc_len(&descr[0], true);
+ printf("len: %u\n", len0);
+ printf("file_id: %s\n", osmo_hexdump(descr[0].file_id, descr[0].file_id_len));
+ printf("file_ver: %s\n", osmo_hexdump(descr[0].file_version, descr[0].file_version_len));
+
+ len1 = abis_nm_sw_desc_len(&descr[1], true);
+ printf("len: %u\n", len1);
+ printf("file_id: %s\n", osmo_hexdump(descr[1].file_id, descr[1].file_id_len));
+ printf("file_ver: %s\n", osmo_hexdump(descr[1].file_version, descr[1].file_version_len));
+
+ /* start */
+ pos = abis_nm_select_newest_sw(descr, rc);
+ if (pos != 1) {
+ printf("Selected the wrong version: %d\n", pos);
+ abort();
+ }
+ printf("SELECTED: %d\n", pos);
+
+ /* shuffle */
+ tmp = descr[0];
+ descr[0] = descr[1];
+ descr[1] = tmp;
+ pos = abis_nm_select_newest_sw(descr, rc);
+ if (pos != 0) {
+ printf("Selected the wrong version: %d\n", pos);
+ abort();
+ }
+ printf("SELECTED: %d\n", pos);
+ printf("%s(): OK\n", __func__);
+}
+
+int main(int argc, char **argv)
+{
+ osmo_init_logging(&log_info);
+
+ test_sw_selection();
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/abis/abis_test.ok b/tests/abis/abis_test.ok
new file mode 100644
index 000000000..8418cad87
--- /dev/null
+++ b/tests/abis/abis_test.ok
@@ -0,0 +1,9 @@
+len: 26
+file_id: 31 36 38 64 34 37 32 00
+file_ver: 76 32 30 30 62 31 34 33 64 30 00
+len: 26
+file_id: 31 36 38 64 34 37 32 00
+file_ver: 76 32 30 30 62 31 34 33 64 31 00
+SELECTED: 1
+SELECTED: 0
+test_sw_selection(): OK
diff --git a/tests/atlocal.in b/tests/atlocal.in
new file mode 100644
index 000000000..362bfa9df
--- /dev/null
+++ b/tests/atlocal.in
@@ -0,0 +1,7 @@
+enable_nat_test='@osmo_ac_build_nat@'
+enable_smpp_test='@osmo_ac_build_smpp@'
+enable_bsc_test='@osmo_ac_build_bsc@'
+enable_mgcp_transcoding_test='@osmo_ac_mgcp_transcoding@'
+enable_sgsn_test='@found_libgtp_and_libcares@'
+enable_oap_test='@found_libgtp_and_libcares@'
+enable_gtphub_test='@found_libgtp_and_libcares@'
diff --git a/tests/bsc-nat-trie/Makefile.am b/tests/bsc-nat-trie/Makefile.am
new file mode 100644
index 000000000..cf8ebaf20
--- /dev/null
+++ b/tests/bsc-nat-trie/Makefile.am
@@ -0,0 +1,17 @@
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS)
+AM_LDFLAGS = $(COVERAGE_LDFLAGS)
+
+EXTRA_DIST = bsc_nat_trie_test.ok prefixes.csv
+
+noinst_PROGRAMS = bsc_nat_trie_test
+
+bsc_nat_trie_test_SOURCES = bsc_nat_trie_test.c \
+ $(top_srcdir)/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c
+bsc_nat_trie_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libmgcp/libmgcp.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) -lrt \
+ $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) \
+ $(LIBOSMOABIS_LIBS)
diff --git a/tests/bsc-nat-trie/bsc_nat_trie_test.c b/tests/bsc-nat-trie/bsc_nat_trie_test.c
new file mode 100644
index 000000000..4b4df2faf
--- /dev/null
+++ b/tests/bsc-nat-trie/bsc_nat_trie_test.c
@@ -0,0 +1,87 @@
+/*
+ * (C) 2013 by On-Waves
+ * (C) 2013 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * All Rights Reserved
+ *
+ * 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/>.
+ *
+ */
+
+#include <openbsc/nat_rewrite_trie.h>
+#include <openbsc/debug.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/core/backtrace.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+
+#include <string.h>
+
+int main(int argc, char **argv)
+{
+ struct nat_rewrite *trie;
+
+ osmo_init_logging(&log_info);
+
+ printf("Testing the trie\n");
+
+ trie = nat_rewrite_parse(NULL, "prefixes.csv");
+ OSMO_ASSERT(trie);
+
+ /* verify that it has been parsed */
+ OSMO_ASSERT(trie->prefixes == 17);
+ printf("Dumping the internal trie\n");
+ nat_rewrite_dump(trie);
+
+ /* now do the matching... */
+ OSMO_ASSERT(!nat_rewrite_lookup(trie, ""));
+ OSMO_ASSERT(!nat_rewrite_lookup(trie, "2"));
+
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "1")->rewrite, "1") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "12")->rewrite, "2") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "123")->rewrite, "3") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "1234")->rewrite, "4") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "12345")->rewrite, "5") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "123456")->rewrite, "6") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "1234567")->rewrite, "7") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "12345678")->rewrite, "8") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "123456789")->rewrite, "9") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "1234567890")->rewrite, "10") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "13")->rewrite, "11") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "14")->rewrite, "12") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "15")->rewrite, "13") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "16")->rewrite, "14") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "823455")->rewrite, "15") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "82")->rewrite, "16") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "+49123445")->rewrite, "17") == 0);
+
+ /* match a prefix */
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "121")->rewrite, "2") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "1292323")->rewrite, "2") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "12345678901")->rewrite, "10") == 0);
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "160")->rewrite, "14") == 0);
+
+ OSMO_ASSERT(strcmp(nat_rewrite_lookup(trie, "12345678901123452123123")->rewrite, "10") == 0);
+
+ /* invalid input */
+ OSMO_ASSERT(!nat_rewrite_lookup(trie, "12abc"));
+
+ talloc_free(trie);
+
+ trie = nat_rewrite_parse(NULL, "does_not_exist.csv");
+ OSMO_ASSERT(!trie);
+
+ printf("Done with the tests.\n");
+ return 0;
+}
diff --git a/tests/bsc-nat-trie/bsc_nat_trie_test.ok b/tests/bsc-nat-trie/bsc_nat_trie_test.ok
new file mode 100644
index 000000000..4d4cc9949
--- /dev/null
+++ b/tests/bsc-nat-trie/bsc_nat_trie_test.ok
@@ -0,0 +1,20 @@
+Testing the trie
+Dumping the internal trie
+1,1
+12,2
+123,3
+1234,4
+12345,5
+123456,6
+1234567,7
+12345678,8
+123456789,9
+1234567890,10
+13,11
+14,12
+15,13
+16,14
+82,16
+823455,15
++49123,17
+Done with the tests.
diff --git a/tests/bsc-nat-trie/prefixes.csv b/tests/bsc-nat-trie/prefixes.csv
new file mode 100644
index 000000000..35485b1a3
--- /dev/null
+++ b/tests/bsc-nat-trie/prefixes.csv
@@ -0,0 +1,25 @@
+1,1
+12,2
+123,3
+1234,4
+12345,5
+123456,6
+1234567,7
+12345678,8
+123456789,9
+1234567890,10
+13,11
+14,12
+15,13
+16,14
+823455,15
+82,16
++49123,17
+1ABC,18
+12345678901234567890,19
+,20
+14A,21
+124,324324324234
+1234567890,10
+no line
+99,
diff --git a/tests/bsc-nat/Makefile.am b/tests/bsc-nat/Makefile.am
new file mode 100644
index 000000000..40be3a32f
--- /dev/null
+++ b/tests/bsc-nat/Makefile.am
@@ -0,0 +1,59 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBOSMOCTRL_LIBS) \
+ $(LIBOSMOSCCP_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(LIBOSMONETIF_CFLAGS) \
+ $(COVERAGE_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(COVERAGE_LDFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ bsc_nat_test.ok \
+ bsc_data.c \
+ barr.cfg \
+ barr_dup.cfg \
+ prefixes.csv \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ bsc_nat_test \
+ $(NULL)
+
+bsc_nat_test_SOURCES = \
+ bsc_nat_test.c \
+ $(top_srcdir)/src/osmo-bsc_nat/bsc_filter.c \
+ $(top_srcdir)/src/osmo-bsc_nat/bsc_sccp.c \
+ $(top_srcdir)/src/osmo-bsc_nat/bsc_nat_utils.c \
+ $(top_srcdir)/src/osmo-bsc_nat/bsc_nat_rewrite.c \
+ $(top_srcdir)/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c \
+ $(top_srcdir)/src/osmo-bsc_nat/bsc_mgcp_utils.c \
+ $(top_srcdir)/src/osmo-bsc_nat/bsc_nat_filter.c
+
+bsc_nat_test_LDADD = \
+ $(top_builddir)/src/libfilter/libfilter.a \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
+ $(top_builddir)/src/libmgcp/libmgcp.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOSCCP_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
+ $(LIBOSMOABIS_LIBS) \
+ $(LIBOSMONETIF_LIBS) \
+ $(LIBOSMOCTRL_LIBS) \
+ -lrt \
+ $(NULL)
diff --git a/tests/bsc-nat/barr.cfg b/tests/bsc-nat/barr.cfg
new file mode 100644
index 000000000..a9a4a2b31
--- /dev/null
+++ b/tests/bsc-nat/barr.cfg
@@ -0,0 +1,12 @@
+12123124:3:2:
+12123123:3:1:
+12123128:3:6:
+12123125:3:3:
+12123127:3:5:
+12123126:3:4:
+12123120:3:4:
+12123119:3:4:
+12123118:3:4:
+12123117:3:4:
+12123116:3:4:
+12123115:3:4:
diff --git a/tests/bsc-nat/barr_dup.cfg b/tests/bsc-nat/barr_dup.cfg
new file mode 100644
index 000000000..ea94631ce
--- /dev/null
+++ b/tests/bsc-nat/barr_dup.cfg
@@ -0,0 +1,2 @@
+12123124:3:2:
+12123124:3:2:
diff --git a/tests/bsc-nat/bsc_data.c b/tests/bsc-nat/bsc_data.c
new file mode 100644
index 000000000..3a9f1da62
--- /dev/null
+++ b/tests/bsc-nat/bsc_data.c
@@ -0,0 +1,275 @@
+/* test data */
+
+/* BSC -> MSC, CR */
+static const uint8_t bsc_cr[] = {
+0x00, 0x2e, 0xfd,
+0x01, 0x00, 0x00, 0x15, 0x02, 0x02, 0x04, 0x02,
+0x42, 0xfe, 0x0f, 0x21, 0x00, 0x1f, 0x57, 0x05,
+0x08, 0x00, 0x72, 0xf4, 0x80, 0x20, 0x1c, 0xc3,
+0x51, 0x17, 0x12, 0x05, 0x08, 0x20, 0x72, 0xf4,
+0x90, 0x20, 0x1d, 0x50, 0x08, 0x29, 0x47, 0x80,
+0x00, 0x00, 0x00, 0x00, 0x80, 0x00 };
+
+static const uint8_t bsc_cr_patched[] = {
+0x00, 0x2e, 0xfd,
+0x01, 0x00, 0x00, 0x05, 0x02, 0x02, 0x04, 0x02,
+0x42, 0xfe, 0x0f, 0x21, 0x00, 0x1f, 0x57, 0x05,
+0x08, 0x00, 0x72, 0xf4, 0x80, 0x20, 0x1c, 0xc3,
+0x51, 0x17, 0x12, 0x05, 0x08, 0x20, 0x72, 0xf4,
+0x90, 0x20, 0x1d, 0x50, 0x08, 0x29, 0x47, 0x80,
+0x00, 0x00, 0x00, 0x00, 0x80, 0x00 };
+
+/* CC, MSC -> BSC */
+static const uint8_t msc_cc[] = {
+0x00, 0x0a, 0xfd,
+0x02, 0x00, 0x00, 0x05, 0x01, 0x1f, 0xe4, 0x02,
+0x01, 0x00 };
+static const uint8_t msc_cc_patched[] = {
+0x00, 0x0a, 0xfd,
+0x02, 0x00, 0x00, 0x15, 0x01, 0x1f, 0xe4, 0x02,
+0x01, 0x00 };
+
+/* Classmark, BSC -> MSC */
+static const uint8_t bsc_dtap[] = {
+0x00, 0x17, 0xfd,
+0x06, 0x01, 0x1f, 0xe4, 0x00, 0x01, 0x10, 0x00,
+0x0e, 0x54, 0x12, 0x03, 0x50, 0x18, 0x93, 0x13,
+0x06, 0x60, 0x14, 0x45, 0x00, 0x81, 0x00 };
+
+static const uint8_t bsc_dtap_patched[] = {
+0x00, 0x17, 0xfd,
+0x06, 0x01, 0x1f, 0xe4, 0x00, 0x01, 0x10, 0x00,
+0x0e, 0x54, 0x12, 0x03, 0x50, 0x18, 0x93, 0x13,
+0x06, 0x60, 0x14, 0x45, 0x00, 0x81, 0x00 };
+
+/* Clear command, MSC -> BSC */
+static const uint8_t msc_dtap[] = {
+0x00, 0x0d, 0xfd,
+0x06, 0x00, 0x00, 0x05, 0x00, 0x01, 0x06, 0x00,
+0x04, 0x20, 0x04, 0x01, 0x09 };
+static const uint8_t msc_dtap_patched[] = {
+0x00, 0x0d, 0xfd,
+0x06, 0x00, 0x00, 0x15, 0x00, 0x01, 0x06, 0x00,
+0x04, 0x20, 0x04, 0x01, 0x09 };
+
+/*RLSD, MSC -> BSC */
+static const uint8_t msc_rlsd[] = {
+0x00, 0x0a, 0xfd,
+0x04, 0x00, 0x00, 0x05, 0x01, 0x1f, 0xe4, 0x00,
+0x01, 0x00 };
+static const uint8_t msc_rlsd_patched[] = {
+0x00, 0x0a, 0xfd,
+0x04, 0x00, 0x00, 0x15, 0x01, 0x1f, 0xe4, 0x00,
+0x01, 0x00 };
+
+/* RLC, BSC -> MSC */
+static const uint8_t bsc_rlc[] = {
+0x00, 0x07, 0xfd,
+0x05, 0x01, 0x1f, 0xe4, 0x00, 0x00, 0x15 };
+
+static const uint8_t bsc_rlc_patched[] = {
+0x00, 0x07, 0xfd,
+0x05, 0x01, 0x1f, 0xe4, 0x00, 0x00, 0x05 };
+
+
+/* a paging command */
+static const uint8_t paging_by_lac_cmd[] = {
+0x00, 0x22, 0xfd, 0x09,
+0x00, 0x03, 0x07, 0x0b, 0x04, 0x43, 0x02, 0x00,
+0xfe, 0x04, 0x43, 0x5c, 0x00, 0xfe, 0x12, 0x00,
+0x10, 0x52, 0x08, 0x08, 0x29, 0x47, 0x10, 0x02,
+0x01, 0x50, 0x02, 0x30, 0x1a, 0x03, 0x05, 0x20,
+0x15 };
+
+/* an assignment command */
+static const uint8_t ass_cmd[] = {
+0x00, 0x12, 0xfd, 0x06,
+0x00, 0x00, 0x49, 0x00, 0x01, 0x0b, 0x00, 0x09,
+0x01, 0x0b, 0x03, 0x01, 0x0a, 0x11, 0x01, 0x00,
+0x01 };
+
+/* identity response */
+static const uint8_t id_resp[] = {
+0x00, 0x15, 0xfd, 0x06, 0x01, 0x1c, 0xdc,
+0x00, 0x01, 0x0e, 0x01, 0x00, 0x0b, 0x05, 0x59,
+0x08, 0x29, 0x40, 0x21, 0x03, 0x07, 0x48, 0x66,
+0x31
+};
+
+/* sms code msg */
+static const uint8_t smsc_rewrite[] = {
+0x00, 0x30, 0xfd, 0x06, 0x01, 0x13, 0x1e, 0x00,
+0x01, 0x29, 0x01, 0x03, 0x26, 0x09, 0x01, 0x23,
+0x00, 0x0c, 0x00, 0x07, 0x91, 0x36, 0x19, 0x08,
+0x00, 0x10, 0x50, 0x17, 0x21, 0x0c, 0x0f, 0x81,
+0x00, 0x94, 0x51, 0x87, 0x86, 0x78, 0x46, 0xf5,
+0x00, 0x00, 0x09, 0xcc, 0xb7, 0xbd, 0x0c, 0xca,
+0xbf, 0xeb, 0x20
+};
+
+static const uint8_t smsc_rewrite_patched[] = {
+0x00, 0x31, 0xfd, 0x06, 0x01, 0x13, 0x1e, 0x00,
+0x01, 0x2a, 0x01, 0x03, 0x27, 0x09, 0x01, 0x24,
+0x00, 0x0c, 0x00, 0x08, 0x91, 0x66, 0x66, 0x66,
+0x66, 0x66, 0x66, 0xf7, 0x17, 0x01, 0x0c, 0x0f,
+0x81, 0x00, 0x94, 0x51, 0x87, 0x86, 0x78, 0x46,
+0xf5, 0x00, 0x00, 0x09, 0xcc, 0xb7, 0xbd, 0x0c,
+0xca, 0xbf, 0xeb, 0x20
+};
+
+static const uint8_t smsc_rewrite_patched_hdr[] = {
+0x00, 0x30, 0xfd, 0x06, 0x01, 0x13, 0x1e, 0x00,
+0x01, 0x29, 0x01, 0x03, 0x26, 0x09, 0x01, 0x23,
+0x00, 0x0c, 0x00, 0x07, 0x91, 0x36, 0x19, 0x08,
+0x00, 0x10, 0x50, 0x17, 0x01, 0x0c, 0x0f, 0x81,
+0x00, 0x94, 0x51, 0x87, 0x86, 0x78, 0x46, 0xf5,
+0x00, 0x00, 0x09, 0xcc, 0xb7, 0xbd, 0x0c, 0xca,
+0xbf, 0xeb, 0x20
+};
+
+static const uint8_t smsc_rewrite_num_patched[] = {
+0x00, 0x2f, 0xfd, 0x06, 0x01, 0x13, 0x1e, 0x00,
+0x01, 0x28, 0x01, 0x03, 0x25, 0x09, 0x01, 0x22,
+0x00, 0x0c, 0x00, 0x07, 0x91, 0x36, 0x19, 0x08,
+0x00, 0x10, 0x50, 0x16, 0x21, 0x0c, 0x0d, 0x91,
+ 0x23, 0x51, 0x87, 0x86, 0x78, 0x46, 0xf5,
+0x00, 0x00, 0x09, 0xcc, 0xb7, 0xbd, 0x0c, 0xca,
+0xbf, 0xeb, 0x20
+};
+
+static const uint8_t smsc_rewrite_num_patched_tp_srr[] = {
+0x00, 0x2f, 0xfd, 0x06, 0x01, 0x13, 0x1e, 0x00,
+0x01, 0x28, 0x01, 0x03, 0x25, 0x09, 0x01, 0x22,
+0x00, 0x0c, 0x00, 0x07, 0x91, 0x36, 0x19, 0x08,
+0x00, 0x10, 0x50, 0x16, 0x01, 0x0c, 0x0d, 0x91,
+ 0x23, 0x51, 0x87, 0x86, 0x78, 0x46, 0xf5,
+0x00, 0x00, 0x09, 0xcc, 0xb7, 0xbd, 0x0c, 0xca,
+0xbf, 0xeb, 0x20
+};
+
+/*
+ * MGCP messages
+ */
+
+/* nothing to patch */
+static const char crcx[] = "CRCX 23265295 8@mgw MGCP 1.0\r\nC: 394b0439fb\r\nL: p:20, a:AMR, nt:IN\r\nM: recvonly\r\n";
+static const char crcx_patched[] = "CRCX 23265295 1e@mgw MGCP 1.0\r\nC: 394b0439fb\r\nL: p:20, a:AMR, nt:IN\r\nM: recvonly\r\n";
+
+
+/* patch the ip and port */
+static const char crcx_resp[] = "200 23265295\r\nI: 1\r\n\r\nv=0\r\nc=IN IP4 172.16.18.2\r\nm=audio 4002 RTP/AVP 98 3\r\na=rtpmap:98 AMR/8000\r\n";
+static const char crcx_resp_patched[] = "200 23265295\r\nI: 1\r\n\r\nv=0\r\nc=IN IP4 10.0.0.1\r\nm=audio 999 RTP/AVP 98 3\r\na=rtpmap:98 AMR/8000\r\na=fmtp:98 mode-set=2\r\n";
+
+/* patch the ip and port */
+static const char mdcx[] = "MDCX 23330829 8@mgw MGCP 1.0\r\nC: 394b0439fb\r\nI: 1\r\nL: p:20, a:AMR, nt:IN\r\nM: recvonly\r\n\r\nv=0\r\no=- 1049380491 0 IN IP4 172.16.18.2\r\ns=-\r\nc=IN IP4 172.16.18.2\r\nt=0 0\r\nm=audio 4410 RTP/AVP 126\r\na=rtpmap:126 AMR/8000/1\r\na=fmtp:126 mode-set=2;start-mode=0\r\na=ptime:20\r\na=recvonly\r\nm=image 4412 udptl t38\r\na=T38FaxVersion:0\r\na=T38MaxBitRate:14400\r\n";
+static const char mdcx_patched[] = "MDCX 23330829 1e@mgw MGCP 1.0\r\nC: 394b0439fb\r\nI: 1\r\nL: p:20, a:AMR, nt:IN\r\nM: recvonly\r\n\r\nv=0\r\no=- 1049380491 0 IN IP4 172.16.18.2\r\ns=-\r\nc=IN IP4 10.0.0.23\r\nt=0 0\r\nm=audio 6666 RTP/AVP 126\r\na=rtpmap:126 AMR/8000/1\r\na=fmtp:126 mode-set=2;start-mode=0\r\na=ptime:20\r\na=recvonly\r\nm=image 4412 udptl t38\r\na=T38FaxVersion:0\r\na=T38MaxBitRate:14400\r\n";
+
+
+static const char mdcx_resp[] = "200 23330829\r\n\r\nv=0\r\nc=IN IP4 172.16.18.2\r\nm=audio 4002 RTP/AVP 98\r\na=rtpmap:98 AMR/8000\r\n";
+static const char mdcx_resp_patched[] = "200 23330829\r\n\r\nv=0\r\nc=IN IP4 10.0.0.23\r\nm=audio 5555 RTP/AVP 98\r\na=rtpmap:98 AMR/8000\r\na=fmtp:98 mode-set=2\r\n";
+
+/* different line ending */
+static const char mdcx_resp2[] = "200 33330829\n\nv=0\nc=IN IP4 172.16.18.2\nm=audio 4002 RTP/AVP 98\na=rtpmap:98 AMR/8000\n";
+static const char mdcx_resp_patched2[] = "200 33330829\n\nv=0\nc=IN IP4 10.0.0.23\nm=audio 5555 RTP/AVP 98\na=rtpmap:98 AMR/8000\na=fmtp:98 mode-set=2\n";
+static const char mdcx_resp_patched2_noamr[] = "200 33330829\n\nv=0\nc=IN IP4 10.0.0.23\nm=audio 5555 RTP/AVP 98\na=rtpmap:98 AMR/8000\n";
+
+struct mgcp_patch_test {
+ const char *orig;
+ const char *patch;
+ const char *ip;
+ const int port;
+ const int payload_type;
+ const int ensure_mode_set;
+};
+
+static const struct mgcp_patch_test mgcp_messages[] = {
+ {
+ .orig = crcx,
+ .patch = crcx_patched,
+ .ip = "0.0.0.0",
+ .port = 2323,
+ .ensure_mode_set = 1,
+ },
+ {
+ .orig = crcx_resp,
+ .patch = crcx_resp_patched,
+ .ip = "10.0.0.1",
+ .port = 999,
+ .payload_type = 98,
+ .ensure_mode_set = 1,
+ },
+ {
+ .orig = mdcx,
+ .patch = mdcx_patched,
+ .ip = "10.0.0.23",
+ .port = 6666,
+ .payload_type = 126,
+ .ensure_mode_set = 1,
+ },
+ {
+ .orig = mdcx_resp,
+ .patch = mdcx_resp_patched,
+ .ip = "10.0.0.23",
+ .port = 5555,
+ .payload_type = 98,
+ .ensure_mode_set = 1,
+ },
+ {
+ .orig = mdcx_resp2,
+ .patch = mdcx_resp_patched2,
+ .ip = "10.0.0.23",
+ .port = 5555,
+ .payload_type = 98,
+ .ensure_mode_set = 1,
+ },
+ {
+ .orig = mdcx_resp2,
+ .patch = mdcx_resp_patched2_noamr,
+ .ip = "10.0.0.23",
+ .port = 5555,
+ .payload_type = 98,
+ .ensure_mode_set = 0,
+ },
+};
+
+/* CC Setup messages */
+static const uint8_t cc_setup_national[] = {
+ 0x00, 0x20, 0xfd, 0x06, 0x01, 0x12,
+ 0x6d, 0x00, 0x01, 0x19, 0x01, 0x00, 0x16, 0x03,
+ 0x05, 0x04, 0x06, 0x60, 0x04, 0x02, 0x00, 0x05,
+ 0x81, 0x5e, 0x06, 0x81, 0x10, 0x27, 0x33, 0x63,
+ 0x66, 0x15, 0x02, 0x11, 0x01
+};
+
+static const uint8_t cc_setup_national_patched[] = {
+ 0x00, 0x21, 0xfd, 0x06, 0x01, 0x12,
+ 0x6d, 0x00, 0x01, 0x1a, 0x01, 0x00, 0x17, 0x03,
+ 0x05, 0x04, 0x06, 0x60, 0x04, 0x02, 0x00, 0x05,
+ 0x81, 0x5e, 0x07, 0x91, 0x94, 0x71, 0x32, 0x33,
+ 0x66, 0xf6, 0x15, 0x02, 0x11, 0x01
+};
+
+/* patch the phone number of cc_setup_national_patched */
+static const uint8_t cc_setup_national_patched_patched[] = {
+ 0x00, 0x21, 0xfd, 0x06, 0x01, 0x12,
+ 0x6d, 0x00, 0x01, 0x1a, 0x01, 0x00, 0x17, 0x03,
+ 0x05, 0x04, 0x06, 0x60, 0x04, 0x02, 0x00, 0x05,
+ 0x81, 0x5e, 0x07, 0x91, 0x63, 0x71, 0x32, 0x33,
+ 0x66, 0xf6, 0x15, 0x02, 0x11, 0x01
+};
+
+static const uint8_t cc_setup_international[] = {
+ 0x00, 0x22, 0xfd, 0x06, 0x01, 0x13,
+ 0xe7, 0x00, 0x01, 0x1b, 0x01, 0x00, 0x18, 0x03,
+ 0x45, 0x04, 0x06, 0x60, 0x04, 0x02, 0x00, 0x05,
+ 0x81, 0x5e, 0x08, 0x81, 0x00, 0x94, 0x71, 0x33,
+ 0x63, 0x66, 0x03, 0x15, 0x02, 0x11, 0x01
+};
+
+static const uint8_t cc_setup_national_again[] = {
+ 0x00, 0x22, 0xfd, 0x06, 0x01, 0x12, 0x6d, 0x00,
+ 0x01, 0x1b, 0x01, 0x00, 0x18, 0x03, 0x05, 0x04,
+ 0x06, 0x60, 0x04, 0x02, 0x00, 0x05, 0x81, 0x5e,
+ 0x08, 0x81, 0x63, 0x94, 0x71, 0x32, 0x33, 0x66,
+ 0xf6, 0x15, 0x02, 0x11, 0x01
+};
diff --git a/tests/bsc-nat/bsc_nat_test.c b/tests/bsc-nat/bsc_nat_test.c
new file mode 100644
index 000000000..2914a01b5
--- /dev/null
+++ b/tests/bsc-nat/bsc_nat_test.c
@@ -0,0 +1,1584 @@
+/*
+ * BSC NAT Message filtering
+ *
+ * (C) 2010-2013 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2010-2013 by On-Waves
+ *
+ * All Rights Reserved
+ *
+ * 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 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/>.
+ *
+ */
+
+
+#include <openbsc/debug.h>
+#include <openbsc/gsm_data.h>
+#include <openbsc/bsc_nat.h>
+#include <openbsc/bsc_nat_sccp.h>
+#include <openbsc/bsc_msg_filter.h>
+#include <openbsc/nat_rewrite_trie.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/core/backtrace.h>
+#include <osmocom/core/talloc.h>
+
+#include <osmocom/sccp/sccp.h>
+#include <osmocom/gsm/protocol/gsm_08_08.h>
+
+#include <stdio.h>
+
+/* test messages for ipa */
+static uint8_t ipa_id[] = {
+ 0x00, 0x01, 0xfe, 0x06,
+};
+
+/* SCCP messages are below */
+static uint8_t gsm_reset[] = {
+ 0x00, 0x12, 0xfd,
+ 0x09, 0x00, 0x03, 0x05, 0x07, 0x02, 0x42, 0xfe,
+ 0x02, 0x42, 0xfe, 0x06, 0x00, 0x04, 0x30, 0x04,
+ 0x01, 0x20,
+};
+
+static const uint8_t gsm_reset_ack[] = {
+ 0x00, 0x13, 0xfd,
+ 0x09, 0x00, 0x03, 0x07, 0x0b, 0x04, 0x43, 0x01,
+ 0x00, 0xfe, 0x04, 0x43, 0x5c, 0x00, 0xfe, 0x03,
+ 0x00, 0x01, 0x31,
+};
+
+static const uint8_t gsm_paging[] = {
+ 0x00, 0x20, 0xfd,
+ 0x09, 0x00, 0x03, 0x07, 0x0b, 0x04, 0x43, 0x01,
+ 0x00, 0xfe, 0x04, 0x43, 0x5c, 0x00, 0xfe, 0x10,
+ 0x00, 0x0e, 0x52, 0x08, 0x08, 0x29, 0x47, 0x10,
+ 0x02, 0x01, 0x31, 0x97, 0x61, 0x1a, 0x01, 0x06,
+};
+
+/* BSC -> MSC connection open */
+static const uint8_t bssmap_cr[] = {
+ 0x00, 0x2c, 0xfd,
+ 0x01, 0x01, 0x02, 0x03, 0x02, 0x02, 0x04, 0x02,
+ 0x42, 0xfe, 0x0f, 0x1f, 0x00, 0x1d, 0x57, 0x05,
+ 0x08, 0x00, 0x72, 0xf4, 0x80, 0x20, 0x12, 0xc3,
+ 0x50, 0x17, 0x10, 0x05, 0x24, 0x11, 0x03, 0x33,
+ 0x19, 0xa2, 0x08, 0x29, 0x47, 0x10, 0x02, 0x01,
+ 0x31, 0x97, 0x61, 0x00
+};
+
+/* MSC -> BSC connection confirm */
+static const uint8_t bssmap_cc[] = {
+ 0x00, 0x0a, 0xfd,
+ 0x02, 0x01, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00,
+};
+
+/* MSC -> BSC released */
+static const uint8_t bssmap_released[] = {
+ 0x00, 0x0e, 0xfd,
+ 0x04, 0x00, 0x00, 0x03, 0x01, 0x02, 0x03, 0x00, 0x01, 0x0f,
+ 0x02, 0x23, 0x42, 0x00,
+};
+
+/* BSC -> MSC released */
+static const uint8_t bssmap_release_complete[] = {
+ 0x00, 0x07, 0xfd,
+ 0x05, 0x01, 0x02, 0x03, 0x00, 0x00, 0x03
+};
+
+/* both directions IT timer */
+static const uint8_t connnection_it[] = {
+ 0x00, 0x0b, 0xfd,
+ 0x10, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03,
+ 0x00, 0x00, 0x00, 0x00,
+};
+
+/* error in both directions */
+static const uint8_t proto_error[] = {
+ 0x00, 0x05, 0xfd,
+ 0x0f, 0x22, 0x33, 0x44, 0x00,
+};
+
+/* MGCP wrap... */
+static const uint8_t mgcp_msg[] = {
+ 0x00, 0x03, 0xfc,
+ 0x20, 0x20, 0x20,
+};
+
+/* location updating request */
+static const uint8_t bss_lu[] = {
+ 0x00, 0x2e, 0xfd,
+ 0x01, 0x91, 0x45, 0x14, 0x02, 0x02, 0x04, 0x02,
+ 0x42, 0xfe, 0x0f, 0x21, 0x00, 0x1f, 0x57, 0x05,
+ 0x08, 0x00, 0x72, 0xf4, 0x80, 0x20, 0x14, 0xc3,
+ 0x50, 0x17, 0x12, 0x05, 0x08, 0x70, 0x72, 0xf4,
+ 0x80, 0xff, 0xfe, 0x30, 0x08, 0x29, 0x44, 0x50,
+ 0x12, 0x03, 0x24, 0x01, 0x95, 0x00
+};
+
+/* paging response */
+static const uint8_t pag_resp[] = {
+ 0x00, 0x2c, 0xfd, 0x01, 0xe5, 0x68,
+ 0x14, 0x02, 0x02, 0x04, 0x02, 0x42, 0xfe, 0x0f,
+ 0x1f, 0x00, 0x1d, 0x57, 0x05, 0x08, 0x00, 0x72,
+ 0xf4, 0x80, 0x20, 0x16, 0xc3, 0x50, 0x17, 0x10,
+ 0x06, 0x27, 0x01, 0x03, 0x30, 0x18, 0x96, 0x08,
+ 0x29, 0x26, 0x30, 0x32, 0x11, 0x42, 0x01, 0x19,
+ 0x00
+};
+
+struct filter_result {
+ const uint8_t *data;
+ const uint16_t length;
+ const int dir;
+ const int result;
+};
+
+static const struct filter_result results[] = {
+ {
+ .data = ipa_id,
+ .length = ARRAY_SIZE(ipa_id),
+ .dir = DIR_MSC,
+ .result = 1,
+ },
+ {
+ .data = gsm_reset,
+ .length = ARRAY_SIZE(gsm_reset),
+ .dir = DIR_MSC,
+ .result = 1,
+ },
+ {
+ .data = gsm_reset_ack,
+ .length = ARRAY_SIZE(gsm_reset_ack),
+ .dir = DIR_BSC,
+ .result = 1,
+ },
+ {
+ .data = gsm_paging,
+ .length = ARRAY_SIZE(gsm_paging),
+ .dir = DIR_BSC,
+ .result = 0,
+ },
+ {
+ .data = bssmap_cr,
+ .length = ARRAY_SIZE(bssmap_cr),
+ .dir = DIR_MSC,
+ .result = 0,
+ },
+ {
+ .data = bssmap_cc,
+ .length = ARRAY_SIZE(bssmap_cc),
+ .dir = DIR_BSC,
+ .result = 0,
+ },
+ {
+ .data = bssmap_released,
+ .length = ARRAY_SIZE(bssmap_released),
+ .dir = DIR_MSC,
+ .result = 0,
+ },
+ {
+ .data = bssmap_release_complete,
+ .length = ARRAY_SIZE(bssmap_release_complete),
+ .dir = DIR_BSC,
+ .result = 0,
+ },
+ {
+ .data = mgcp_msg,
+ .length = ARRAY_SIZE(mgcp_msg),
+ .dir = DIR_MSC,
+ .result = 0,
+ },
+ {
+ .data = connnection_it,
+ .length = ARRAY_SIZE(connnection_it),
+ .dir = DIR_BSC,
+ .result = 0,
+ },
+ {
+ .data = connnection_it,
+ .length = ARRAY_SIZE(connnection_it),
+ .dir = DIR_MSC,
+ .result = 0,
+ },
+ {
+ .data = proto_error,
+ .length = ARRAY_SIZE(proto_error),
+ .dir = DIR_BSC,
+ .result = 0,
+ },
+ {
+ .data = proto_error,
+ .length = ARRAY_SIZE(proto_error),
+ .dir = DIR_MSC,
+ .result = 0,
+ },
+
+};
+
+static void test_filter(void)
+{
+ int i;
+
+
+ /* start testinh with proper messages */
+ printf("Testing BSS Filtering.\n");
+ for (i = 0; i < ARRAY_SIZE(results); ++i) {
+ int result;
+ struct bsc_nat_parsed *parsed;
+ struct msgb *msg = msgb_alloc(4096, "test-message");
+
+ printf("Going to test item: %d\n", i);
+ memcpy(msg->data, results[i].data, results[i].length);
+ msg->l2h = msgb_put(msg, results[i].length);
+
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Failed to parse the message\n");
+ continue;
+ }
+
+ result = bsc_nat_filter_ipa(results[i].dir, msg, parsed);
+ if (result != results[i].result) {
+ printf("FAIL: Not the expected result got: %d wanted: %d\n",
+ result, results[i].result);
+ }
+
+ msgb_free(msg);
+ }
+}
+
+#include "bsc_data.c"
+
+static void copy_to_msg(struct msgb *msg, const uint8_t *data, unsigned int length)
+{
+ msgb_reset(msg);
+ msg->l2h = msgb_put(msg, length);
+ memcpy(msg->l2h, data, msgb_l2len(msg));
+}
+
+static void verify_msg(struct msgb *out, const uint8_t *ref, int ref_len)
+{
+ if (out->len != ref_len) {
+ printf("FAIL: The size should match: %d vs. %d\n",
+ out->len, ref_len);
+ printf("%s\n", osmo_hexdump(out->data, out->len));
+ printf("Wanted\n");
+ printf("%s\n", osmo_hexdump(ref, ref_len));
+ abort();
+ }
+
+ if (memcmp(out->data, ref, out->len) != 0) {
+ printf("FAIL: the data should be changed.\n");
+ printf("%s\n", osmo_hexdump(out->data, out->len));
+ printf("Wanted\n");
+ printf("%s\n", osmo_hexdump(ref, ref_len));
+ abort();
+ }
+}
+
+
+#define VERIFY(con_found, con, msg, ver, str) \
+ if (!con_found) { \
+ printf("Failed to find connection.\n"); \
+ abort(); \
+ } \
+ if (con_found->bsc != con) { \
+ printf("Got connection of the wrong BSC: %d\n", \
+ con_found->bsc->cfg->nr); \
+ abort(); \
+ } \
+ if (memcmp(msg->data, ver, sizeof(ver)) != 0) { \
+ printf("Failed to patch the %s msg.\n", str); \
+ abort(); \
+ }
+
+/* test conn tracking once */
+static void test_contrack()
+{
+ struct bsc_nat *nat;
+ struct bsc_connection *con;
+ struct nat_sccp_connection *con_found;
+ struct nat_sccp_connection *rc_con;
+ struct bsc_nat_parsed *parsed;
+ struct msgb *msg;
+
+ printf("Testing connection tracking.\n");
+ nat = bsc_nat_alloc();
+ con = bsc_connection_alloc(nat);
+ con->cfg = bsc_config_alloc(nat, "foo", 0);
+ bsc_config_add_lac(con->cfg, 23);
+ bsc_config_add_lac(con->cfg, 49);
+ bsc_config_add_lac(con->cfg, 42);
+ bsc_config_del_lac(con->cfg, 49);
+ bsc_config_add_lac(con->cfg, 1111);
+ msg = msgb_alloc(4096, "test");
+
+ /* 1.) create a connection */
+ copy_to_msg(msg, bsc_cr, sizeof(bsc_cr));
+ parsed = bsc_nat_parse(msg);
+ con_found = patch_sccp_src_ref_to_msc(msg, parsed, con);
+ if (con_found != NULL) {
+ printf("Con should not exist realref(%u)\n",
+ sccp_src_ref_to_int(&con_found->real_ref));
+ abort();
+ }
+ rc_con = create_sccp_src_ref(con, parsed);
+ if (!rc_con) {
+ printf("Failed to create a ref\n");
+ abort();
+ }
+ con_found = patch_sccp_src_ref_to_msc(msg, parsed, con);
+ if (!con_found) {
+ printf("Failed to find connection.\n");
+ abort();
+ }
+ if (con_found->bsc != con) {
+ printf("Got connection of the wrong BSC: %d\n",
+ con_found->bsc->cfg->nr);
+ abort();
+ }
+ if (con_found != rc_con) {
+ printf("Failed to find the right connection.\n");
+ abort();
+ }
+ if (memcmp(msg->data, bsc_cr_patched, sizeof(bsc_cr_patched)) != 0) {
+ printf("Failed to patch the BSC CR msg.\n");
+ abort();
+ }
+ talloc_free(parsed);
+
+ /* 2.) get the cc */
+ copy_to_msg(msg, msc_cc, sizeof(msc_cc));
+ parsed = bsc_nat_parse(msg);
+ con_found = patch_sccp_src_ref_to_bsc(msg, parsed, nat);
+ VERIFY(con_found, con, msg, msc_cc_patched, "MSC CC");
+ if (update_sccp_src_ref(con_found, parsed) != 0) {
+ printf("Failed to update the SCCP con.\n");
+ abort();
+ }
+
+ /* 3.) send some data */
+ copy_to_msg(msg, bsc_dtap, sizeof(bsc_dtap));
+ parsed = bsc_nat_parse(msg);
+ con_found = patch_sccp_src_ref_to_msc(msg, parsed, con);
+ VERIFY(con_found, con, msg, bsc_dtap_patched, "BSC DTAP");
+
+ /* 4.) receive some data */
+ copy_to_msg(msg, msc_dtap, sizeof(msc_dtap));
+ parsed = bsc_nat_parse(msg);
+ con_found = patch_sccp_src_ref_to_bsc(msg, parsed, nat);
+ VERIFY(con_found, con, msg, msc_dtap_patched, "MSC DTAP");
+
+ /* 5.) close the connection */
+ copy_to_msg(msg, msc_rlsd, sizeof(msc_rlsd));
+ parsed = bsc_nat_parse(msg);
+ con_found = patch_sccp_src_ref_to_bsc(msg, parsed, nat);
+ VERIFY(con_found, con, msg, msc_rlsd_patched, "MSC RLSD");
+
+ /* 6.) confirm the connection close */
+ copy_to_msg(msg, bsc_rlc, sizeof(bsc_rlc));
+ parsed = bsc_nat_parse(msg);
+ con_found = patch_sccp_src_ref_to_msc(msg, parsed, con);
+ if (!con_found) {
+ printf("Failed to find connection.\n");
+ abort();
+ }
+ if (con_found->bsc != con) {
+ printf("Got connection of the wrong BSC: %d\n",
+ con_found->bsc->cfg->nr);
+ abort();
+ }
+ if (memcmp(msg->data, bsc_rlc_patched, sizeof(bsc_rlc_patched)) != 0) {
+ printf("Failed to patch the BSC CR msg.\n");
+ abort();
+ }
+ remove_sccp_src_ref(con, msg, parsed);
+ talloc_free(parsed);
+
+ copy_to_msg(msg, bsc_rlc, sizeof(bsc_rlc));
+ parsed = bsc_nat_parse(msg);
+ con_found = patch_sccp_src_ref_to_msc(msg, parsed, con);
+
+ /* verify that it is gone */
+ if (con_found != NULL) {
+ printf("Con should not exist real_ref(%u)\n",
+ sccp_src_ref_to_int(&con_found->real_ref));
+ abort();
+ }
+ talloc_free(parsed);
+
+
+ bsc_config_free(con->cfg);
+ bsc_nat_free(nat);
+ msgb_free(msg);
+}
+
+static void test_paging(void)
+{
+ struct bsc_nat *nat;
+ struct bsc_connection *con;
+ struct bsc_config *cfg;
+
+ printf("Testing paging by lac.\n");
+
+ nat = bsc_nat_alloc();
+ con = bsc_connection_alloc(nat);
+ cfg = bsc_config_alloc(nat, "unknown", 0);
+ con->cfg = cfg;
+ bsc_config_add_lac(cfg, 23);
+ con->authenticated = 1;
+ llist_add(&con->list_entry, &nat->bsc_connections);
+
+ /* Test it by not finding it */
+ if (bsc_config_handles_lac(cfg, 8213) != 0) {
+ printf("Should not be handled.\n");
+ abort();
+ }
+
+ /* Test by finding it */
+ bsc_config_del_lac(cfg, 23);
+ bsc_config_add_lac(cfg, 8213);
+ if (bsc_config_handles_lac(cfg, 8213) == 0) {
+ printf("Should have found it.\n");
+ abort();
+ }
+
+ bsc_nat_free(nat);
+}
+
+static void test_mgcp_allocations(void)
+{
+#if 0
+ struct bsc_connection *bsc;
+ struct bsc_nat *nat;
+ struct nat_sccp_connection con;
+ int i, j, multiplex;
+
+ printf("Testing MGCP.\n");
+ memset(&con, 0, sizeof(con));
+
+ nat = bsc_nat_alloc();
+ nat->bsc_endpoints = talloc_zero_array(nat,
+ struct bsc_endpoint,
+ 65);
+ nat->mgcp_cfg = mgcp_config_alloc();
+ nat->mgcp_cfg->trunk.number_endpoints = 64;
+
+ bsc = bsc_connection_alloc(nat);
+ bsc->cfg = bsc_config_alloc(nat, "foo", 0);
+ bsc->cfg->max_endpoints = 60;
+ bsc_config_add_lac(bsc->cfg, 2323);
+ bsc->last_endpoint = 0x22;
+ con.bsc = bsc;
+
+ bsc_init_endps_if_needed(bsc);
+
+ i = 1;
+ do {
+ if (bsc_assign_endpoint(bsc, &con) != 0) {
+ printf("failed to allocate... on iteration %d\n", i);
+ break;
+ }
+ ++i;
+ } while(1);
+
+ multiplex = bsc_mgcp_nr_multiplexes(bsc->cfg->max_endpoints);
+ for (i = 0; i < multiplex; ++i) {
+ for (j = 0; j < 32; ++j)
+ printf("%d", bsc->_endpoint_status[i*32 + j]);
+ printf(": %d of %d\n", i*32 + 32, 32 * 8);
+ }
+#endif
+}
+
+static void test_mgcp_ass_tracking(void)
+{
+ struct bsc_connection *bsc;
+ struct bsc_nat *nat;
+ struct nat_sccp_connection con;
+ struct bsc_nat_parsed *parsed;
+ struct msgb *msg;
+
+ printf("Testing MGCP.\n");
+ memset(&con, 0, sizeof(con));
+
+ nat = bsc_nat_alloc();
+ nat->bsc_endpoints = talloc_zero_array(nat,
+ struct bsc_endpoint,
+ 33);
+ nat->mgcp_cfg = mgcp_config_alloc();
+ nat->mgcp_cfg->trunk.number_endpoints = 64;
+ mgcp_endpoints_allocate(&nat->mgcp_cfg->trunk);
+
+ bsc = bsc_connection_alloc(nat);
+ bsc->cfg = bsc_config_alloc(nat, "foo", 0);
+ bsc_config_add_lac(bsc->cfg, 2323);
+ bsc->last_endpoint = 0x1e;
+ con.bsc = bsc;
+
+ msg = msgb_alloc(4096, "foo");
+ copy_to_msg(msg, ass_cmd, sizeof(ass_cmd));
+ parsed = bsc_nat_parse(msg);
+
+ if (msg->l2h[16] != 0 ||
+ msg->l2h[17] != 0x1) {
+ printf("Input is not as expected.. %s 0x%x\n",
+ osmo_hexdump(msg->l2h, msgb_l2len(msg)),
+ msg->l2h[17]);
+ abort();
+ }
+
+ if (bsc_mgcp_assign_patch(&con, msg) != 0) {
+ printf("Failed to handle assignment.\n");
+ abort();
+ }
+
+ if (con.msc_endp != 1) {
+ printf("Timeslot should be 1.\n");
+ abort();
+ }
+
+ if (con.bsc_endp != 0x1) {
+ printf("Assigned timeslot should have been 1.\n");
+ abort();
+ }
+ if (con.bsc->_endpoint_status[0x1] != 1) {
+ printf("The status on the BSC is wrong.\n");
+ abort();
+ }
+
+ int multiplex, timeslot;
+ mgcp_endpoint_to_timeslot(0x1, &multiplex, &timeslot);
+
+ uint16_t cic = htons(timeslot & 0x1f);
+ if (memcmp(&cic, &msg->l2h[16], sizeof(cic)) != 0) {
+ printf("Message was not patched properly\n");
+ printf("data cic: 0x%x %s\n", cic, osmo_hexdump(msg->l2h, msgb_l2len(msg)));
+ abort();
+ }
+
+ talloc_free(parsed);
+
+ bsc_mgcp_dlcx(&con);
+ if (con.bsc_endp != -1 || con.msc_endp != -1 ||
+ con.bsc->_endpoint_status[1] != 0 || con.bsc->last_endpoint != 0x1) {
+ printf("Clearing should remove the mapping.\n");
+ abort();
+ }
+
+ bsc_config_free(bsc->cfg);
+ bsc_nat_free(nat);
+}
+
+/* test the code to find a given connection */
+static void test_mgcp_find(void)
+{
+ struct bsc_nat *nat;
+ struct bsc_connection *con;
+ struct nat_sccp_connection *sccp_con;
+
+ printf("Testing finding of a BSC Connection\n");
+
+ nat = bsc_nat_alloc();
+ con = bsc_connection_alloc(nat);
+ llist_add(&con->list_entry, &nat->bsc_connections);
+
+ sccp_con = talloc_zero(con, struct nat_sccp_connection);
+ sccp_con->msc_endp = 12;
+ sccp_con->bsc_endp = 12;
+ sccp_con->bsc = con;
+ llist_add(&sccp_con->list_entry, &nat->sccp_connections);
+
+ if (bsc_mgcp_find_con(nat, 11) != NULL) {
+ printf("Found the wrong connection.\n");
+ abort();
+ }
+
+ if (bsc_mgcp_find_con(nat, 12) != sccp_con) {
+ printf("Didn't find the connection\n");
+ abort();
+ }
+
+ /* free everything */
+ bsc_nat_free(nat);
+}
+
+static void test_mgcp_rewrite(void)
+{
+ int i;
+ struct msgb *output;
+ printf("Testing rewriting MGCP messages.\n");
+
+ for (i = 0; i < ARRAY_SIZE(mgcp_messages); ++i) {
+ const char *orig = mgcp_messages[i].orig;
+ const char *patc = mgcp_messages[i].patch;
+ const char *ip = mgcp_messages[i].ip;
+ const int port = mgcp_messages[i].port;
+ const int expected_payload_type = mgcp_messages[i].payload_type;
+ const int ensure_mode_set = mgcp_messages[i].ensure_mode_set;
+ int payload_type = -1;
+
+ char *input = strdup(orig);
+
+ output = bsc_mgcp_rewrite(input, strlen(input), 0x1e,
+ ip, port, -1, &payload_type, ensure_mode_set);
+
+ if (payload_type != -1) {
+ fprintf(stderr, "Found media payload type %d in SDP data\n",
+ payload_type);
+ if (payload_type != expected_payload_type) {
+ printf("Wrong payload type %d (expected %d)\n",
+ payload_type, expected_payload_type);
+ abort();
+ }
+ }
+
+ if (msgb_l2len(output) != strlen(patc)) {
+ printf("Wrong sizes for test: %d %u != %zu != %zu\n", i, msgb_l2len(output), strlen(patc), strlen(orig));
+ printf("String '%s' vs '%s'\n", (const char *) output->l2h, patc);
+ abort();
+ }
+
+ if (memcmp(output->l2h, patc, msgb_l2len(output)) != 0) {
+ printf("Broken on %d msg: '%s'\n", i, (const char *) output->l2h);
+ abort();
+ }
+
+ msgb_free(output);
+ free(input);
+ }
+}
+
+static void test_mgcp_parse(void)
+{
+ int code, ci;
+ char transaction[60];
+
+ printf("Testing MGCP response parsing.\n");
+
+ if (bsc_mgcp_parse_response(crcx_resp, &code, transaction) != 0) {
+ printf("Failed to parse CRCX resp.\n");
+ abort();
+ }
+
+ if (code != 200) {
+ printf("Failed to parse the CODE properly. Got: %d\n", code);
+ abort();
+ }
+
+ if (strcmp(transaction, "23265295") != 0) {
+ printf("Failed to parse transaction id: '%s'\n", transaction);
+ abort();
+ }
+
+ ci = bsc_mgcp_extract_ci(crcx_resp);
+ if (ci != 1) {
+ printf("Failed to parse the CI. Got: %d\n", ci);
+ abort();
+ }
+}
+
+struct cr_filter {
+ const uint8_t *data;
+ int length;
+ int result;
+ int contype;
+
+ const char *bsc_imsi_allow;
+ const char *bsc_imsi_deny;
+ const char *nat_imsi_deny;
+ int nat_cm_reject_cause;
+ int nat_lu_reject_cause;
+ int bsc_cm_reject_cause;
+ int bsc_lu_reject_cause;
+ int want_cm_reject_cause;
+ int want_lu_reject_cause;
+};
+
+static struct cr_filter cr_filter[] = {
+ {
+ .data = bssmap_cr,
+ .length = sizeof(bssmap_cr),
+ .result = 1,
+ .contype = FLT_CON_TYPE_CM_SERV_REQ,
+ .nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ },
+ {
+ .data = bss_lu,
+ .length = sizeof(bss_lu),
+ .result = 1,
+ .contype = FLT_CON_TYPE_LU,
+ .nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ },
+ {
+ .data = pag_resp,
+ .length = sizeof(pag_resp),
+ .result = 1,
+ .contype = FLT_CON_TYPE_PAG_RESP,
+ .nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ },
+ {
+ /* nat deny is before blank/null BSC */
+ .data = bss_lu,
+ .length = sizeof(bss_lu),
+ .result = -3,
+ .nat_imsi_deny = "[0-9]*",
+ .contype = FLT_CON_TYPE_LU,
+ .nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ },
+ {
+ /* BSC allow is before NAT deny */
+ .data = bss_lu,
+ .length = sizeof(bss_lu),
+ .result = 1,
+ .nat_imsi_deny = "[0-9]*",
+ .bsc_imsi_allow = "2440[0-9]*",
+ .contype = FLT_CON_TYPE_LU,
+ .nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ },
+ {
+ /* BSC allow is before NAT deny */
+ .data = bss_lu,
+ .length = sizeof(bss_lu),
+ .result = 1,
+ .bsc_imsi_allow = "[0-9]*",
+ .nat_imsi_deny = "[0-9]*",
+ .contype = FLT_CON_TYPE_LU,
+ .nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ },
+ {
+ /* filter as deny is first */
+ .data = bss_lu,
+ .length = sizeof(bss_lu),
+ .result = 1,
+ .bsc_imsi_deny = "[0-9]*",
+ .bsc_imsi_allow = "[0-9]*",
+ .nat_imsi_deny = "[0-9]*",
+ .contype = FLT_CON_TYPE_LU,
+ .nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ },
+ {
+ /* deny by nat rule */
+ .data = bss_lu,
+ .length = sizeof(bss_lu),
+ .result = -3,
+ .bsc_imsi_deny = "000[0-9]*",
+ .nat_imsi_deny = "[0-9]*",
+ .contype = FLT_CON_TYPE_LU,
+ .nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ },
+ {
+ /* deny by nat rule */
+ .data = bss_lu,
+ .length = sizeof(bss_lu),
+ .result = -3,
+ .bsc_imsi_deny = "000[0-9]*",
+ .nat_imsi_deny = "[0-9]*",
+ .contype = FLT_CON_TYPE_LU,
+ .nat_cm_reject_cause = 0x23,
+ .nat_lu_reject_cause = 0x42,
+ .bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_lu_reject_cause = 0x42,
+ .want_cm_reject_cause = 0x23,
+ },
+ {
+ /* deny by bsc rule */
+ .data = bss_lu,
+ .length = sizeof(bss_lu),
+ .result = -2,
+ .bsc_imsi_deny = "[0-9]*",
+ .contype = FLT_CON_TYPE_LU,
+ .nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .want_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ },
+ {
+ /* deny by bsc rule */
+ .data = bss_lu,
+ .length = sizeof(bss_lu),
+ .result = -2,
+ .bsc_imsi_deny = "[0-9]*",
+ .contype = FLT_CON_TYPE_LU,
+ .nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
+ .bsc_cm_reject_cause = 0x42,
+ .bsc_lu_reject_cause = 0x23,
+ .want_lu_reject_cause = 0x23,
+ .want_cm_reject_cause = 0x42,
+ },
+};
+
+static void test_cr_filter()
+{
+ int i, res, contype;
+ struct msgb *msg = msgb_alloc(4096, "test_cr_filter");
+ struct bsc_nat_parsed *parsed;
+ struct bsc_msg_acc_lst *nat_lst, *bsc_lst;
+ struct bsc_msg_acc_lst_entry *nat_entry, *bsc_entry;
+ struct bsc_filter_reject_cause cause;
+
+ struct bsc_nat *nat = bsc_nat_alloc();
+ struct bsc_connection *bsc = bsc_connection_alloc(nat);
+ bsc->cfg = bsc_config_alloc(nat, "foo", 0);
+ bsc_config_add_lac(bsc->cfg, 1234);
+ bsc->cfg->acc_lst_name = "bsc";
+ nat->acc_lst_name = "nat";
+
+ nat_lst = bsc_msg_acc_lst_get(nat, &nat->access_lists, "nat");
+ bsc_lst = bsc_msg_acc_lst_get(nat, &nat->access_lists, "bsc");
+
+ bsc_entry = bsc_msg_acc_lst_entry_create(bsc_lst);
+ nat_entry = bsc_msg_acc_lst_entry_create(nat_lst);
+
+ /* test the default value as we are going to overwrite it */
+ OSMO_ASSERT(bsc_entry->cm_reject_cause == GSM48_REJECT_PLMN_NOT_ALLOWED);
+ OSMO_ASSERT(bsc_entry->lu_reject_cause == GSM48_REJECT_PLMN_NOT_ALLOWED);
+
+ for (i = 0; i < ARRAY_SIZE(cr_filter); ++i) {
+ char *imsi;
+ msgb_reset(msg);
+ copy_to_msg(msg, cr_filter[i].data, cr_filter[i].length);
+
+ bsc_entry->cm_reject_cause = cr_filter[i].bsc_cm_reject_cause;
+ bsc_entry->lu_reject_cause = cr_filter[i].bsc_lu_reject_cause;
+ nat_entry->cm_reject_cause = cr_filter[i].nat_cm_reject_cause;
+ nat_entry->lu_reject_cause = cr_filter[i].nat_lu_reject_cause;
+
+ if (gsm_parse_reg(nat_entry, &nat_entry->imsi_deny_re, &nat_entry->imsi_deny,
+ cr_filter[i].nat_imsi_deny ? 1 : 0,
+ &cr_filter[i].nat_imsi_deny) != 0)
+ abort();
+ if (gsm_parse_reg(bsc_entry, &bsc_entry->imsi_allow_re, &bsc_entry->imsi_allow,
+ cr_filter[i].bsc_imsi_allow ? 1 : 0,
+ &cr_filter[i].bsc_imsi_allow) != 0)
+ abort();
+ if (gsm_parse_reg(bsc_entry, &bsc_entry->imsi_deny_re, &bsc_entry->imsi_deny,
+ cr_filter[i].bsc_imsi_deny ? 1 : 0,
+ &cr_filter[i].bsc_imsi_deny) != 0)
+ abort();
+
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Failed to parse the message\n");
+ abort();
+ }
+
+ memset(&cause, 0, sizeof(cause));
+ res = bsc_nat_filter_sccp_cr(bsc, msg, parsed, &contype, &imsi, &cause);
+ if (res != cr_filter[i].result) {
+ printf("FAIL: Wrong result %d for test %d.\n", res, i);
+ abort();
+ }
+
+
+ OSMO_ASSERT(cause.cm_reject_cause == cr_filter[i].want_cm_reject_cause);
+ OSMO_ASSERT(cause.lu_reject_cause == cr_filter[i].want_lu_reject_cause);
+
+ if (contype != cr_filter[i].contype) {
+ printf("FAIL: Wrong contype %d for test %d.\n", res, contype);
+ abort();
+ }
+
+ talloc_steal(parsed, imsi);
+ talloc_free(parsed);
+ }
+
+ msgb_free(msg);
+ bsc_nat_free(nat);
+}
+
+static void test_dt_filter()
+{
+ int i;
+ struct msgb *msg = msgb_alloc(4096, "test_dt_filter");
+ struct bsc_nat_parsed *parsed;
+ struct bsc_filter_reject_cause cause;
+
+ struct bsc_nat *nat = bsc_nat_alloc();
+ struct bsc_connection *bsc = bsc_connection_alloc(nat);
+ struct nat_sccp_connection *con = talloc_zero(0, struct nat_sccp_connection);
+
+ bsc->cfg = bsc_config_alloc(nat, "foo", 0);
+ bsc_config_add_lac(bsc->cfg, 23);
+ con->bsc = bsc;
+
+ msgb_reset(msg);
+ copy_to_msg(msg, id_resp, ARRAY_SIZE(id_resp));
+
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse ID resp\n");
+ abort();
+ }
+
+ if (parsed->bssap != BSSAP_MSG_DTAP) {
+ printf("FAIL: It should be dtap\n");
+ abort();
+ }
+
+ /* gsm_type is actually the size of the dtap */
+ if (parsed->gsm_type < msgb_l3len(msg) - 3) {
+ printf("FAIL: Not enough space for the content\n");
+ abort();
+ }
+
+ memset(&cause, 0, sizeof(cause));
+ OSMO_ASSERT(!con->filter_state.imsi);
+ if (bsc_nat_filter_dt(bsc, msg, con, parsed, &cause) != 1) {
+ printf("FAIL: Should have passed..\n");
+ abort();
+ }
+ OSMO_ASSERT(con->filter_state.imsi);
+ OSMO_ASSERT(talloc_parent(con->filter_state.imsi) == con);
+
+ /* just some basic length checking... */
+ for (i = ARRAY_SIZE(id_resp); i >= 0; --i) {
+ msgb_reset(msg);
+ copy_to_msg(msg, id_resp, ARRAY_SIZE(id_resp));
+
+ parsed = bsc_nat_parse(msg);
+ if (!parsed)
+ continue;
+
+ con->filter_state.imsi_checked = 0;
+ memset(&cause, 0, sizeof(cause));
+ bsc_nat_filter_dt(bsc, msg, con, parsed, &cause);
+ }
+
+ msgb_free(msg);
+ bsc_nat_free(nat);
+}
+
+static void test_setup_rewrite()
+{
+ struct msgb *msg = msgb_alloc(4096, "test_dt_filter");
+ struct msgb *out;
+ struct bsc_nat_parsed *parsed;
+ const char *imsi = "27408000001234";
+
+ struct bsc_nat *nat = bsc_nat_alloc();
+
+ /* a fake list */
+ struct osmo_config_list entries;
+ struct osmo_config_entry entry;
+
+ INIT_LLIST_HEAD(&entries.entry);
+ entry.mcc = "274";
+ entry.mnc = "08";
+ entry.option = "^0([1-9])";
+ entry.text = "0049";
+ llist_add_tail(&entry.list, &entries.entry);
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr, &entries);
+
+ /* verify that nothing changed */
+ msgb_reset(msg);
+ copy_to_msg(msg, cc_setup_international, ARRAY_SIZE(cc_setup_international));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse ID resp\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (msg != out) {
+ printf("FAIL: The message should not have been changed\n");
+ abort();
+ }
+
+ verify_msg(out, cc_setup_international, ARRAY_SIZE(cc_setup_international));
+ talloc_free(parsed);
+
+ /* verify that something in the message changes */
+ msgb_reset(msg);
+ copy_to_msg(msg, cc_setup_national, ARRAY_SIZE(cc_setup_national));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse ID resp\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (!out) {
+ printf("FAIL: A new message should be created.\n");
+ abort();
+ }
+
+ if (msg == out) {
+ printf("FAIL: The message should have changed\n");
+ abort();
+ }
+
+ verify_msg(out, cc_setup_national_patched, ARRAY_SIZE(cc_setup_national_patched));
+ msgb_free(out);
+
+ /* Make sure that a wildcard is matching */
+ entry.mnc = "*";
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr, &entries);
+ msg = msgb_alloc(4096, "test_dt_filter");
+ copy_to_msg(msg, cc_setup_national, ARRAY_SIZE(cc_setup_national));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse ID resp\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (!out) {
+ printf("FAIL: A new message should be created.\n");
+ abort();
+ }
+
+ if (msg == out) {
+ printf("FAIL: The message should have changed\n");
+ abort();
+ }
+
+ verify_msg(out, cc_setup_national_patched, ARRAY_SIZE(cc_setup_national_patched));
+ msgb_free(out);
+
+ /* Make sure that a wildcard is matching */
+ entry.mnc = "09";
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr, &entries);
+ msg = msgb_alloc(4096, "test_dt_filter");
+ copy_to_msg(msg, cc_setup_national, ARRAY_SIZE(cc_setup_national));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse ID resp\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (out != msg) {
+ printf("FAIL: The message should be unchanged.\n");
+ abort();
+ }
+
+ verify_msg(out, cc_setup_national, ARRAY_SIZE(cc_setup_national));
+ msgb_free(out);
+
+ /* Now see what happens to an international number */
+ entry.mnc = "*";
+ entry.option = "^\\+[0-9][0-9]([1-9])";
+ entry.text = "0036";
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr, &entries);
+ msg = msgb_alloc(4096, "test_dt_filter");
+ copy_to_msg(msg, cc_setup_national_patched, ARRAY_SIZE(cc_setup_national_patched));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse ID resp %d\n", __LINE__);
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (!out) {
+ printf("FAIL: A new message should be created %d.\n", __LINE__);
+ abort();
+ }
+
+ if (msg == out) {
+ printf("FAIL: The message should have changed %d\n", __LINE__);
+ abort();
+ }
+
+ verify_msg(out, cc_setup_national_patched_patched,
+ ARRAY_SIZE(cc_setup_national_patched_patched));
+ msgb_free(out);
+
+ /* go from international back to national */
+ entry.mnc = "*";
+ entry.option = "^\\+([0-9])";
+ entry.text = "36";
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr, &entries);
+ msg = msgb_alloc(4096, "test_dt_filter");
+ copy_to_msg(msg, cc_setup_national_patched, ARRAY_SIZE(cc_setup_national_patched));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse ID resp %d\n", __LINE__);
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (!out) {
+ printf("FAIL: A new message should be created %d.\n", __LINE__);
+ abort();
+ }
+
+ if (msg == out) {
+ printf("FAIL: The message should have changed %d\n", __LINE__);
+ abort();
+ }
+
+ verify_msg(out, cc_setup_national_again,
+ ARRAY_SIZE(cc_setup_national_again));
+ msgb_free(out);
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr, NULL);
+ bsc_nat_free(nat);
+}
+
+static void test_setup_rewrite_prefix(void)
+{
+ struct msgb *msg = msgb_alloc(4096, "test_dt_filter");
+ struct msgb *out;
+ struct bsc_nat_parsed *parsed;
+ const char *imsi = "27408000001234";
+
+ struct bsc_nat *nat = bsc_nat_alloc();
+
+ /* a fake list */
+ struct osmo_config_list entries;
+ struct osmo_config_entry entry;
+
+ INIT_LLIST_HEAD(&entries.entry);
+ entry.mcc = "274";
+ entry.mnc = "08";
+ entry.option = "^0([1-9])";
+ entry.text = "prefix_lookup";
+ llist_add_tail(&entry.list, &entries.entry);
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr, &entries);
+
+ nat->num_rewr_trie = nat_rewrite_parse(nat, "prefixes.csv");
+
+ msgb_reset(msg);
+ copy_to_msg(msg, cc_setup_national, ARRAY_SIZE(cc_setup_national));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse ID resp\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (!out) {
+ printf("FAIL: A new message should be created.\n");
+ abort();
+ }
+
+ if (msg == out) {
+ printf("FAIL: The message should have changed\n");
+ abort();
+ }
+
+ verify_msg(out, cc_setup_national_patched, ARRAY_SIZE(cc_setup_national_patched));
+ msgb_free(out);
+
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr, NULL);
+ bsc_nat_free(nat);
+}
+
+static void test_setup_rewrite_post(void)
+{
+ struct msgb *msg = msgb_alloc(4096, "test_dt_filter");
+ struct msgb *out;
+ struct bsc_nat_parsed *parsed;
+ const char *imsi = "27408000001234";
+
+ struct bsc_nat *nat = bsc_nat_alloc();
+
+ /* a fake list */
+ struct osmo_config_list entries;
+ struct osmo_config_entry entry;
+ struct osmo_config_list entries_post;
+ struct osmo_config_entry entry_post;
+
+ INIT_LLIST_HEAD(&entries.entry);
+ entry.mcc = "274";
+ entry.mnc = "08";
+ entry.option = "^0([1-9])";
+ entry.text = "0049";
+ llist_add_tail(&entry.list, &entries.entry);
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr, &entries);
+
+ /* attempt to undo the previous one */
+ INIT_LLIST_HEAD(&entries_post.entry);
+ entry_post.mcc = "274";
+ entry_post.mnc = "08";
+ entry_post.option = "^\\+49([1-9])";
+ entry_post.text = "prefix_lookup";
+ llist_add_tail(&entry_post.list, &entries_post.entry);
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr_post, &entries_post);
+
+ nat->num_rewr_trie = nat_rewrite_parse(nat, "prefixes.csv");
+
+ msgb_reset(msg);
+ copy_to_msg(msg, cc_setup_national, ARRAY_SIZE(cc_setup_national));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse ID resp\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (!out) {
+ printf("FAIL: A new message should be created.\n");
+ abort();
+ }
+
+ if (msg == out) {
+ printf("FAIL: The message should have changed\n");
+ abort();
+ }
+
+ verify_msg(out, cc_setup_national, ARRAY_SIZE(cc_setup_national));
+ msgb_free(out);
+
+ bsc_nat_free(nat);
+}
+
+static void test_sms_smsc_rewrite()
+{
+ struct msgb *msg = msgb_alloc(4096, "SMSC rewrite"), *out;
+ struct bsc_nat_parsed *parsed;
+ const char *imsi = "515039900406700";
+
+ struct bsc_nat *nat = bsc_nat_alloc();
+
+ /* a fake list */
+ struct osmo_config_list smsc_entries, dest_entries, clear_entries;
+ struct osmo_config_entry smsc_entry, dest_entry, clear_entry;
+
+ INIT_LLIST_HEAD(&smsc_entries.entry);
+ INIT_LLIST_HEAD(&dest_entries.entry);
+ INIT_LLIST_HEAD(&clear_entries.entry);
+ smsc_entry.mcc = "^515039";
+ smsc_entry.option = "639180000105()";
+ smsc_entry.text = "6666666666667";
+ llist_add_tail(&smsc_entry.list, &smsc_entries.entry);
+ dest_entry.mcc = "515";
+ dest_entry.mnc = "03";
+ dest_entry.option = "^0049";
+ dest_entry.text = "";
+ llist_add_tail(&dest_entry.list, &dest_entries.entry);
+ clear_entry.mcc = "^515039";
+ clear_entry.option = "^0049";
+ clear_entry.text = "";
+ llist_add_tail(&clear_entry.list, &clear_entries.entry);
+
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->smsc_rewr, &smsc_entries);
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->tpdest_match, &dest_entries);
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->sms_clear_tp_srr, &clear_entries);
+
+ printf("Testing SMSC rewriting.\n");
+
+ /*
+ * Check if the SMSC address is changed
+ */
+ copy_to_msg(msg, smsc_rewrite, ARRAY_SIZE(smsc_rewrite));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse SMS\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (out == msg) {
+ printf("FAIL: This should have changed.\n");
+ abort();
+ }
+
+ verify_msg(out, smsc_rewrite_patched, ARRAY_SIZE(smsc_rewrite_patched));
+ msgb_free(out);
+
+ /* clear out the filter for SMSC */
+ printf("Attempting to only rewrite the HDR\n");
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->smsc_rewr, NULL);
+ msg = msgb_alloc(4096, "SMSC rewrite");
+ copy_to_msg(msg, smsc_rewrite, ARRAY_SIZE(smsc_rewrite));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse SMS\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (out == msg) {
+ printf("FAIL: This should have changed.\n");
+ abort();
+ }
+
+ verify_msg(out, smsc_rewrite_patched_hdr, ARRAY_SIZE(smsc_rewrite_patched_hdr));
+ msgb_free(out);
+
+ /* clear out the next filter */
+ printf("Attempting to change nothing.\n");
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->sms_clear_tp_srr, NULL);
+ msg = msgb_alloc(4096, "SMSC rewrite");
+ copy_to_msg(msg, smsc_rewrite, ARRAY_SIZE(smsc_rewrite));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse SMS\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (out != msg) {
+ printf("FAIL: This should not have changed.\n");
+ abort();
+ }
+
+ verify_msg(out, smsc_rewrite, ARRAY_SIZE(smsc_rewrite));
+ msgb_free(out);
+ bsc_nat_free(nat);
+}
+
+static void test_sms_number_rewrite(void)
+{
+ struct msgb *msg, *out;
+ struct bsc_nat_parsed *parsed;
+ const char *imsi = "515039900406700";
+
+ struct bsc_nat *nat = bsc_nat_alloc();
+
+ /* a fake list */
+ struct osmo_config_list num_entries, clear_entries;
+ struct osmo_config_entry num_entry, clear_entry;
+
+ INIT_LLIST_HEAD(&num_entries.entry);
+ num_entry.mcc = "^515039";
+ num_entry.option = "^0049()";
+ num_entry.text = "0032";
+ llist_add_tail(&num_entry.list, &num_entries.entry);
+
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->sms_num_rewr, &num_entries);
+
+ printf("Testing SMS TP-DA rewriting.\n");
+
+ /*
+ * Check if the SMSC address is changed
+ */
+ msg = msgb_alloc(4096, "SMSC rewrite");
+ copy_to_msg(msg, smsc_rewrite, ARRAY_SIZE(smsc_rewrite));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse SMS\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (out == msg) {
+ printf("FAIL: This should have changed.\n");
+ abort();
+ }
+
+ verify_msg(out, smsc_rewrite_num_patched,
+ ARRAY_SIZE(smsc_rewrite_num_patched));
+ msgb_free(out);
+
+ /*
+ * Now with TP-SRR rewriting enabled
+ */
+ INIT_LLIST_HEAD(&clear_entries.entry);
+ clear_entry.mcc = "^515039";
+ clear_entry.option = "";
+ clear_entry.text = "";
+ llist_add_tail(&clear_entry.list, &clear_entries.entry);
+ bsc_nat_num_rewr_entry_adapt(nat, &nat->sms_clear_tp_srr, &clear_entries);
+
+ msg = msgb_alloc(4096, "SMSC rewrite");
+ copy_to_msg(msg, smsc_rewrite, ARRAY_SIZE(smsc_rewrite));
+ parsed = bsc_nat_parse(msg);
+ if (!parsed) {
+ printf("FAIL: Could not parse SMS\n");
+ abort();
+ }
+
+ out = bsc_nat_rewrite_msg(nat, msg, parsed, imsi);
+ if (out == msg) {
+ printf("FAIL: This should have changed.\n");
+ abort();
+ }
+
+ verify_msg(out, smsc_rewrite_num_patched_tp_srr,
+ ARRAY_SIZE(smsc_rewrite_num_patched_tp_srr));
+ msgb_free(out);
+ bsc_nat_free(nat);
+}
+
+static void test_barr_list_parsing(void)
+{
+ int rc;
+ int cm, lu;
+ struct rb_node *node;
+ struct rb_root root = RB_ROOT;
+ struct osmo_config_list *lst = osmo_config_list_parse(NULL, "barr.cfg");
+ if (lst == NULL)
+ abort();
+
+ rc = bsc_filter_barr_adapt(NULL, &root, lst);
+ if (rc != 0)
+ abort();
+ talloc_free(lst);
+
+
+ for (node = rb_first(&root); node; node = rb_next(node)) {
+ struct bsc_filter_barr_entry *entry;
+ entry = rb_entry(node, struct bsc_filter_barr_entry, node);
+ printf("IMSI: %s CM: %d LU: %d\n", entry->imsi,
+ entry->cm_reject_cause, entry->lu_reject_cause);
+ }
+
+ /* do the look up now.. */
+ rc = bsc_filter_barr_find(&root, "12123119", &cm, &lu);
+ if (!rc) {
+ printf("Failed to find the IMSI.\n");
+ abort();
+ }
+
+ if (cm != 3 || lu != 4) {
+ printf("Found CM(%d) and LU(%d)\n", cm, lu);
+ abort();
+ }
+
+ /* empty and check that it is empty */
+ bsc_filter_barr_adapt(NULL, &root, NULL);
+ if (!RB_EMPTY_ROOT(&root)) {
+ printf("Failed to empty the list.\n");
+ abort();
+ }
+
+ /* check that dup results in an error */
+ lst = osmo_config_list_parse(NULL, "barr_dup.cfg");
+ if (lst == NULL) {
+ printf("Failed to parse list with dups\n");
+ abort();
+ }
+
+ rc = bsc_filter_barr_adapt(NULL, &root, lst);
+ if (rc != -1) {
+ printf("It should have failed due dup\n");
+ abort();
+ }
+ talloc_free(lst);
+
+ /* dump for reference */
+ for (node = rb_first(&root); node; node = rb_next(node)) {
+ struct bsc_filter_barr_entry *entry;
+ entry = rb_entry(node, struct bsc_filter_barr_entry, node);
+ printf("IMSI: %s CM: %d LU: %d\n", entry->imsi,
+ entry->cm_reject_cause, entry->lu_reject_cause);
+
+ }
+ rc = bsc_filter_barr_adapt(NULL, &root, NULL);
+}
+
+static void test_nat_extract_lac()
+{
+ int res;
+ struct bsc_connection *bsc;
+ struct bsc_nat *nat;
+ struct nat_sccp_connection con;
+ struct bsc_nat_parsed *parsed;
+ struct msgb *msg = msgb_alloc(4096, "test-message");
+
+ printf("Testing LAC extraction from SCCP CR\n");
+
+ /* initialize the testcase */
+ nat = bsc_nat_alloc();
+ bsc = bsc_connection_alloc(nat);
+ bsc->cfg = bsc_config_alloc(nat, "foo", 0);
+
+ memset(&con, 0, sizeof(con));
+ con.bsc = bsc;
+
+ /* create the SCCP CR */
+ msg->l2h = msgb_put(msg, ARRAY_SIZE(bssmap_cr));
+ memcpy(msg->l2h, bssmap_cr, ARRAY_SIZE(bssmap_cr));
+
+ /* parse it and pass it on */
+ parsed = bsc_nat_parse(msg);
+ res = bsc_nat_extract_lac(bsc, &con, parsed, msg);
+ OSMO_ASSERT(res == 0);
+
+ /* verify the LAC */
+ OSMO_ASSERT(con.lac == 8210);
+ OSMO_ASSERT(con.ci == 50000);
+
+ bsc_nat_free(nat);
+}
+
+int main(int argc, char **argv)
+{
+ msgb_talloc_ctx_init(NULL, 0);
+ sccp_set_log_area(DSCCP);
+ osmo_init_logging(&log_info);
+
+ test_filter();
+ test_contrack();
+ test_paging();
+ test_mgcp_ass_tracking();
+ test_mgcp_find();
+ test_mgcp_rewrite();
+ test_mgcp_parse();
+ test_cr_filter();
+ test_dt_filter();
+ test_setup_rewrite();
+ test_setup_rewrite_prefix();
+ test_setup_rewrite_post();
+ test_sms_smsc_rewrite();
+ test_sms_number_rewrite();
+ test_mgcp_allocations();
+ test_barr_list_parsing();
+ test_nat_extract_lac();
+
+ printf("Testing execution completed.\n");
+ return 0;
+}
+
+/* stub */
+void bsc_nat_send_mgcp_to_msc(struct bsc_nat *nat, struct msgb *msg)
+{
+ abort();
+}
diff --git a/tests/bsc-nat/bsc_nat_test.ok b/tests/bsc-nat/bsc_nat_test.ok
new file mode 100644
index 000000000..ab04f4273
--- /dev/null
+++ b/tests/bsc-nat/bsc_nat_test.ok
@@ -0,0 +1,39 @@
+Testing BSS Filtering.
+Going to test item: 0
+Going to test item: 1
+Going to test item: 2
+Going to test item: 3
+Going to test item: 4
+Going to test item: 5
+Going to test item: 6
+Going to test item: 7
+Going to test item: 8
+Going to test item: 9
+Going to test item: 10
+Going to test item: 11
+Going to test item: 12
+Testing connection tracking.
+Testing paging by lac.
+Testing MGCP.
+Testing finding of a BSC Connection
+Testing rewriting MGCP messages.
+Testing MGCP response parsing.
+Testing SMSC rewriting.
+Attempting to only rewrite the HDR
+Attempting to change nothing.
+Testing SMS TP-DA rewriting.
+IMSI: 12123115 CM: 3 LU: 4
+IMSI: 12123116 CM: 3 LU: 4
+IMSI: 12123117 CM: 3 LU: 4
+IMSI: 12123118 CM: 3 LU: 4
+IMSI: 12123119 CM: 3 LU: 4
+IMSI: 12123120 CM: 3 LU: 4
+IMSI: 12123123 CM: 3 LU: 1
+IMSI: 12123124 CM: 3 LU: 2
+IMSI: 12123125 CM: 3 LU: 3
+IMSI: 12123126 CM: 3 LU: 4
+IMSI: 12123127 CM: 3 LU: 5
+IMSI: 12123128 CM: 3 LU: 6
+IMSI: 12123124 CM: 3 LU: 2
+Testing LAC extraction from SCCP CR
+Testing execution completed.
diff --git a/tests/bsc-nat/prefixes.csv b/tests/bsc-nat/prefixes.csv
new file mode 100644
index 000000000..0c7660f10
--- /dev/null
+++ b/tests/bsc-nat/prefixes.csv
@@ -0,0 +1,2 @@
+0172,0049
++49,0
diff --git a/tests/bsc/Makefile.am b/tests/bsc/Makefile.am
new file mode 100644
index 000000000..9de4145b7
--- /dev/null
+++ b/tests/bsc/Makefile.am
@@ -0,0 +1,46 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBOSMOSCCP_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(COVERAGE_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(COVERAGE_LDFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ bsc_test.ok \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ bsc_test \
+ $(NULL)
+
+bsc_test_SOURCES = \
+ bsc_test.c \
+ $(top_srcdir)/src/osmo-bsc/osmo_bsc_filter.c \
+ $(NULL)
+
+bsc_test_LDADD = \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libmsc/libmsc.a \
+ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
+ $(top_builddir)/src/libmgcp/libmgcp.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOSCCP_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
+ $(LIBOSMOABIS_LIBS) \
+ -lrt \
+ $(NULL)
diff --git a/tests/bsc/bsc_test.c b/tests/bsc/bsc_test.c
new file mode 100644
index 000000000..20ed5b43b
--- /dev/null
+++ b/tests/bsc/bsc_test.c
@@ -0,0 +1,209 @@
+/*
+ * BSC Message filtering
+ *
+ * (C) 2013 by sysmocom s.f.m.c. GmbH
+ * Written by Jacob Erlbeck <jerlbeck@sysmocom.de>
+ * (C) 2010-2013 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2010-2013 by On-Waves
+ *
+ * All Rights Reserved
+ *
+ * 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 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/>.
+ *
+ */
+
+
+#include <openbsc/debug.h>
+#include <openbsc/gsm_data.h>
+
+#include <openbsc/osmo_bsc.h>
+#include <openbsc/bsc_msc_data.h>
+#include <openbsc/gsm_04_80.h>
+#include <openbsc/gsm_subscriber.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/core/backtrace.h>
+#include <osmocom/core/talloc.h>
+
+#include <stdio.h>
+#include <search.h>
+
+enum test {
+ TEST_SCAN_TO_BTS,
+ TEST_SCAN_TO_MSC,
+};
+
+/* GSM 04.08 MM INFORMATION test message */
+static uint8_t gsm48_mm_info_nn_tzt[] = {
+ 0x05, 0x32, 0x45, 0x08, 0x80, 0x4f, 0x77, 0xeb,
+ 0x1a, 0xb6, 0x97, 0xe7, 0x47, 0x31, 0x90, 0x61,
+ 0x11, 0x02, 0x73, 0x00,
+};
+
+static uint8_t gsm48_mm_info_nn_tzt_out[] = {
+ 0x05, 0x32, 0x45, 0x08, 0x80, 0x4f, 0x77, 0xeb,
+ 0x1a, 0xb6, 0x97, 0xe7, 0x47, 0x31, 0x90, 0x61,
+ 0x11, 0x02, 0x73, 0x1a,
+};
+
+static uint8_t gsm48_mm_info_nn_tzt_dst[] = {
+ 0x05, 0x32, 0x45, 0x08, 0x80, 0x4f, 0x77, 0xeb,
+ 0x1a, 0xb6, 0x97, 0xe7, 0x47, 0x31, 0x90, 0x61,
+ 0x11, 0x02, 0x73, 0x00, 0x49, 0x01, 0x00,
+};
+
+static uint8_t gsm48_mm_info_nn_tzt_dst_out[] = {
+ 0x05, 0x32, 0x45, 0x08, 0x80, 0x4f, 0x77, 0xeb,
+ 0x1a, 0xb6, 0x97, 0xe7, 0x47, 0x31, 0x90, 0x61,
+ 0x11, 0x02, 0x73, 0x1a, 0x49, 0x01, 0x02,
+};
+
+struct test_definition {
+ const uint8_t *data;
+ const uint16_t length;
+ const int dir;
+ const int result;
+ const uint8_t *out_data;
+ const uint16_t out_length;
+ const char* params;
+ const int n_params;
+};
+
+static int get_int(const char *params, size_t nmemb, const char *key, int def, int *is_set)
+{
+ const char *kv = NULL;
+
+ kv = strstr(params, key);
+ if (kv) {
+ kv += strlen(key) + 1;
+ fprintf(stderr, "get_int(%s) -> %d\n", key, atoi(kv));
+ if (is_set)
+ *is_set = 1;
+ }
+
+ return kv ? atoi(kv) : def;
+}
+
+static const struct test_definition test_scan_defs[] = {
+ {
+ .data = gsm48_mm_info_nn_tzt_dst,
+ .length = ARRAY_SIZE(gsm48_mm_info_nn_tzt),
+ .dir = TEST_SCAN_TO_BTS,
+ .result = 0,
+ .out_data = gsm48_mm_info_nn_tzt_dst_out,
+ .out_length = ARRAY_SIZE(gsm48_mm_info_nn_tzt_out),
+ .params = "tz_hr=-5 tz_mn=15 tz_dst=2",
+ .n_params = 3,
+ },
+ {
+ .data = gsm48_mm_info_nn_tzt_dst,
+ .length = ARRAY_SIZE(gsm48_mm_info_nn_tzt_dst),
+ .dir = TEST_SCAN_TO_BTS,
+ .result = 0,
+ .out_data = gsm48_mm_info_nn_tzt_dst_out,
+ .out_length = ARRAY_SIZE(gsm48_mm_info_nn_tzt_dst_out),
+ .params = "tz_hr=-5 tz_mn=15 tz_dst=2",
+ .n_params = 3,
+ },
+};
+
+static void test_scan(void)
+{
+ int i;
+
+ struct gsm_network *net;
+ struct gsm_bts *bts;
+ struct osmo_bsc_sccp_con *sccp_con;
+ struct bsc_msc_data *msc;
+ struct gsm_subscriber_connection *conn;
+
+ net = talloc_zero(NULL, struct gsm_network);
+ bts = talloc_zero(net, struct gsm_bts);
+ sccp_con = talloc_zero(net, struct osmo_bsc_sccp_con);
+ msc = talloc_zero(net, struct bsc_msc_data);
+ conn = talloc_zero(net, struct gsm_subscriber_connection);
+
+ bts->network = net;
+ sccp_con->msc = msc;
+ conn->bts = bts;
+ conn->sccp_con = sccp_con;
+
+ /* start testing with proper messages */
+ printf("Testing BTS<->MSC message scan.\n");
+ for (i = 0; i < ARRAY_SIZE(test_scan_defs); ++i) {
+ const struct test_definition *test_def = &test_scan_defs[i];
+ int result;
+ struct msgb *msg = msgb_alloc(4096, "test-message");
+ int is_set = 0;
+
+ net->tz.hr = get_int(test_def->params, test_def->n_params, "tz_hr", 0, &is_set);
+ net->tz.mn = get_int(test_def->params, test_def->n_params, "tz_mn", 0, &is_set);
+ net->tz.dst = get_int(test_def->params, test_def->n_params, "tz_dst", 0, &is_set);
+ net->tz.override = 1;
+
+ printf("Going to test item: %d\n", i);
+ msg->l3h = msgb_put(msg, test_def->length);
+ memcpy(msg->l3h, test_def->data, test_def->length);
+
+ switch (test_def->dir) {
+ case TEST_SCAN_TO_BTS:
+ /* override timezone of msg coming from the MSC */
+ result = bsc_scan_msc_msg(conn, msg);
+ break;
+ case TEST_SCAN_TO_MSC:
+ /* override timezone of msg coming from the BSC */
+ /* FIXME: no test for this case is defined in
+ * test_scan_defs[], so this is never used. */
+ result = bsc_scan_bts_msg(conn, msg);
+ break;
+ default:
+ abort();
+ break;
+ }
+
+ if (result != test_def->result) {
+ printf("FAIL: Not the expected result, got: %d wanted: %d\n",
+ result, test_def->result);
+ goto out;
+ }
+
+ if (msgb_l3len(msg) != test_def->out_length) {
+ printf("FAIL: Not the expected message size, got: %d wanted: %d\n",
+ msgb_l3len(msg), test_def->out_length);
+ goto out;
+ }
+
+ if (memcmp(msgb_l3(msg), test_def->out_data, test_def->out_length) != 0) {
+ printf("FAIL: Not the expected message\n");
+ goto out;
+ }
+
+out:
+ msgb_free(msg);
+ }
+
+ talloc_free(net);
+}
+
+
+int main(int argc, char **argv)
+{
+ msgb_talloc_ctx_init(NULL, 0);
+ osmo_init_logging(&log_info);
+
+ test_scan();
+
+ printf("Testing execution completed.\n");
+ return 0;
+}
diff --git a/tests/bsc/bsc_test.ok b/tests/bsc/bsc_test.ok
new file mode 100644
index 000000000..0564bf0cd
--- /dev/null
+++ b/tests/bsc/bsc_test.ok
@@ -0,0 +1,4 @@
+Testing BTS<->MSC message scan.
+Going to test item: 0
+Going to test item: 1
+Testing execution completed.
diff --git a/tests/channel/Makefile.am b/tests/channel/Makefile.am
new file mode 100644
index 000000000..ca470ace4
--- /dev/null
+++ b/tests/channel/Makefile.am
@@ -0,0 +1,35 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ channel_test.ok \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ channel_test \
+ $(NULL)
+
+channel_test_SOURCES = \
+ channel_test.c \
+ $(NULL)
+
+channel_test_LDADD = \
+ $(top_builddir)/src/libmsc/libmsc.a \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBCRYPTO_LIBS) \
+ -ldbi \
+ $(NULL)
diff --git a/tests/channel/channel_test.c b/tests/channel/channel_test.c
new file mode 100644
index 000000000..88293d0a8
--- /dev/null
+++ b/tests/channel/channel_test.c
@@ -0,0 +1,144 @@
+/*
+ * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * All Rights Reserved
+ *
+ * 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 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/>.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <assert.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/core/select.h>
+
+#include <openbsc/common_bsc.h>
+#include <openbsc/abis_rsl.h>
+#include <openbsc/debug.h>
+#include <openbsc/gsm_subscriber.h>
+
+static int s_end = 0;
+static struct gsm_subscriber_connection s_conn;
+static void *s_data;
+static gsm_cbfn *s_cbfn = NULL;
+
+/* our handler */
+static int subscr_cb(unsigned int hook, unsigned int event, struct msgb *msg, void *data, void *param)
+{
+ assert(hook == 101);
+ assert(event == 200);
+ assert(msg == (void*)0x1323L);
+ assert(data == &s_conn);
+ assert(param == (void*)0x2342L);
+ printf("Reached, didn't crash, test passed\n");
+ s_end = true;
+ return 0;
+}
+
+/* mock object for testing, directly invoke the cb... maybe later through the timer */
+int paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data)
+{
+ s_data = data;
+ s_cbfn = cbfn;
+
+ /* claim we have patched */
+ return 1;
+}
+
+
+void test_request_chan(void)
+{
+ struct gsm_network *network;
+ struct gsm_bts *bts;
+
+ printf("Testing the gsm_subscriber chan logic\n");
+
+ /* Create a dummy network */
+ network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ if (!network)
+ exit(1);
+ bts = gsm_bts_alloc(network);
+ bts->location_area_code = 23;
+ s_conn.network = network;
+
+ /* Create a dummy subscriber */
+ struct gsm_subscriber *subscr = subscr_alloc();
+ subscr->lac = 23;
+ subscr->group = network->subscr_group;
+
+ OSMO_ASSERT(subscr->group);
+ OSMO_ASSERT(subscr->group->net == network);
+
+ /* Ask for a channel... */
+ struct subscr_request *sr;
+ sr = subscr_request_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L);
+ OSMO_ASSERT(sr);
+ OSMO_ASSERT(s_cbfn);
+ s_cbfn(101, 200, (void*)0x1323L, &s_conn, s_data);
+
+ OSMO_ASSERT(s_end);
+}
+
+void test_dyn_ts_subslots(void)
+{
+ struct gsm_bts_trx_ts ts;
+
+ printf("Testing subslot numbers for pchan types\n");
+
+ ts.pchan = GSM_PCHAN_TCH_F;
+ OSMO_ASSERT(ts_subslots(&ts) == 1);
+
+ ts.pchan = GSM_PCHAN_TCH_H;
+ OSMO_ASSERT(ts_subslots(&ts) == 2);
+
+ ts.pchan = GSM_PCHAN_PDCH;
+ OSMO_ASSERT(ts_subslots(&ts) == 0);
+
+ ts.pchan = GSM_PCHAN_TCH_F_PDCH;
+ ts.flags = 0; /* TCH_F mode */
+ OSMO_ASSERT(ts_subslots(&ts) == 1);
+ ts.flags = TS_F_PDCH_ACTIVE;
+ OSMO_ASSERT(ts_subslots(&ts) == 0);
+
+ ts.pchan = GSM_PCHAN_TCH_F_TCH_H_PDCH;
+ ts.dyn.pchan_is = GSM_PCHAN_TCH_F;
+ OSMO_ASSERT(ts_subslots(&ts) == 1);
+ ts.dyn.pchan_is = GSM_PCHAN_TCH_H;
+ OSMO_ASSERT(ts_subslots(&ts) == 2);
+ ts.dyn.pchan_is = GSM_PCHAN_PDCH;
+ OSMO_ASSERT(ts_subslots(&ts) == 0);
+}
+
+int main(int argc, char **argv)
+{
+ osmo_init_logging(&log_info);
+
+ test_request_chan();
+ test_dyn_ts_subslots();
+
+ return EXIT_SUCCESS;
+}
+
+void _abis_nm_sendmsg() {}
+void sms_alloc() {}
+void sms_free() {}
+void gsm_net_update_ctype(struct gsm_network *network) {}
+void gsm48_secure_channel() {}
+void paging_request_stop() {}
+void vty_out() {}
+
+struct tlv_definition nm_att_tlvdef;
+
diff --git a/tests/channel/channel_test.ok b/tests/channel/channel_test.ok
new file mode 100644
index 000000000..33c819350
--- /dev/null
+++ b/tests/channel/channel_test.ok
@@ -0,0 +1,3 @@
+Testing the gsm_subscriber chan logic
+Reached, didn't crash, test passed
+Testing subslot numbers for pchan types
diff --git a/tests/ctrl_test_runner.py b/tests/ctrl_test_runner.py
new file mode 100644
index 000000000..0a99c8992
--- /dev/null
+++ b/tests/ctrl_test_runner.py
@@ -0,0 +1,683 @@
+#!/usr/bin/env python
+
+# (C) 2013 by Jacob Erlbeck <jerlbeck@sysmocom.de>
+# (C) 2014 by Holger Hans Peter Freyther
+# based on vty_test_runner.py:
+# (C) 2013 by Katerina Barone-Adesi <kat.obsc@gmail.com>
+# (C) 2013 by Holger Hans Peter Freyther
+# based on bsc_control.py.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import time
+import unittest
+import socket
+import sys
+import struct
+
+import osmopy.obscvty as obscvty
+import osmopy.osmoutil as osmoutil
+
+# add $top_srcdir/contrib to find ipa.py
+sys.path.append(os.path.join(sys.path[0], '..', 'contrib'))
+
+from ipa import Ctrl, IPA
+
+# to be able to find $top_srcdir/doc/...
+confpath = os.path.join(sys.path[0], '..')
+verbose = False
+
+class TestCtrlBase(unittest.TestCase):
+
+ def ctrl_command(self):
+ raise Exception("Needs to be implemented by a subclass")
+
+ def ctrl_app(self):
+ raise Exception("Needs to be implemented by a subclass")
+
+ def setUp(self):
+ osmo_ctrl_cmd = self.ctrl_command()[:]
+ config_index = osmo_ctrl_cmd.index('-c')
+ if config_index:
+ cfi = config_index + 1
+ osmo_ctrl_cmd[cfi] = os.path.join(confpath, osmo_ctrl_cmd[cfi])
+
+ try:
+ self.proc = osmoutil.popen_devnull(osmo_ctrl_cmd)
+ except OSError:
+ print >> sys.stderr, "Current directory: %s" % os.getcwd()
+ print >> sys.stderr, "Consider setting -b"
+ time.sleep(2)
+
+ appstring = self.ctrl_app()[2]
+ appport = self.ctrl_app()[0]
+ self.connect("127.0.0.1", appport)
+ self.next_id = 1000
+
+ def tearDown(self):
+ self.disconnect()
+ osmoutil.end_proc(self.proc)
+
+ def disconnect(self):
+ if not (self.sock is None):
+ self.sock.close()
+
+ def connect(self, host, port):
+ if verbose:
+ print "Connecting to host %s:%i" % (host, port)
+
+ retries = 30
+ while True:
+ try:
+ sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sck.setblocking(1)
+ sck.connect((host, port))
+ except IOError:
+ retries -= 1
+ if retries <= 0:
+ raise
+ time.sleep(.1)
+ continue
+ break
+ self.sock = sck
+ return sck
+
+ def send(self, data):
+ if verbose:
+ print "Sending \"%s\"" %(data)
+ data = Ctrl().add_header(data)
+ return self.sock.send(data) == len(data)
+
+ def send_set(self, var, value, id):
+ setmsg = "SET %s %s %s" %(id, var, value)
+ return self.send(setmsg)
+
+ def send_get(self, var, id):
+ getmsg = "GET %s %s" %(id, var)
+ return self.send(getmsg)
+
+ def do_set(self, var, value):
+ id = self.next_id
+ self.next_id += 1
+ self.send_set(var, value, id)
+ return self.recv_msgs()[id]
+
+ def do_get(self, var):
+ id = self.next_id
+ self.next_id += 1
+ self.send_get(var, id)
+ return self.recv_msgs()[id]
+
+ def recv_msgs(self):
+ responses = {}
+ data = self.sock.recv(4096)
+ while (len(data)>0):
+ (head, data) = IPA().split_combined(data)
+ answer = Ctrl().rem_header(head)
+ if verbose:
+ print "Got message:", answer
+ (mtype, id, msg) = answer.split(None, 2)
+ id = int(id)
+ rsp = {'mtype': mtype, 'id': id}
+ if mtype == "ERROR":
+ rsp['error'] = msg
+ else:
+ split = msg.split(None, 1)
+ rsp['var'] = split[0]
+ if len(split) > 1:
+ rsp['value'] = split[1]
+ else:
+ rsp['value'] = None
+ responses[id] = rsp
+
+ if verbose:
+ print "Decoded replies: ", responses
+
+ return responses
+
+
+class TestCtrlBSC(TestCtrlBase):
+
+ def tearDown(self):
+ TestCtrlBase.tearDown(self)
+ os.unlink("tmp_dummy_sock")
+
+ def ctrl_command(self):
+ return ["./src/osmo-bsc/osmo-bsc", "-r", "tmp_dummy_sock", "-c",
+ "doc/examples/osmo-bsc/osmo-bsc.cfg"]
+
+ def ctrl_app(self):
+ return (4249, "./src/osmo-bsc/osmo-bsc", "OsmoBSC", "bsc")
+
+ def testCtrlErrs(self):
+ r = self.do_get('invalid')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Command not found')
+
+ r = self.do_set('rf_locked', '999')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Value failed verification.')
+
+ r = self.do_get('bts')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Error while parsing the index.')
+
+ r = self.do_get('bts.999')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Error while resolving object')
+
+ def testBtsLac(self):
+ r = self.do_get('bts.0.location-area-code')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.location-area-code')
+ self.assertEquals(r['value'], '1')
+
+ r = self.do_set('bts.0.location-area-code', '23')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.location-area-code')
+ self.assertEquals(r['value'], '23')
+
+ r = self.do_get('bts.0.location-area-code')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.location-area-code')
+ self.assertEquals(r['value'], '23')
+
+ r = self.do_set('bts.0.location-area-code', '-1')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Input not within the range')
+
+ def testBtsCi(self):
+ r = self.do_get('bts.0.cell-identity')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.cell-identity')
+ self.assertEquals(r['value'], '0')
+
+ r = self.do_set('bts.0.cell-identity', '23')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.cell-identity')
+ self.assertEquals(r['value'], '23')
+
+ r = self.do_get('bts.0.cell-identity')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.cell-identity')
+ self.assertEquals(r['value'], '23')
+
+ r = self.do_set('bts.0.cell-identity', '-1')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Input not within the range')
+
+ def testBtsGenerateSystemInformation(self):
+ r = self.do_get('bts.0.send-new-system-informations')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Write Only attribute')
+
+ # No RSL links so it will fail
+ r = self.do_set('bts.0.send-new-system-informations', '1')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Failed to generate SI')
+
+ def testBtsChannelLoad(self):
+ r = self.do_set('bts.0.channel-load', '1')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Read Only attribute')
+
+ # No RSL link so everything is 0
+ r = self.do_get('bts.0.channel-load')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['value'],
+ 'CCCH+SDCCH4,0,0 TCH/F,0,0 TCH/H,0,0 SDCCH8,0,0'
+ + ' TCH/F_PDCH,0,0 CCCH+SDCCH4+CBCH,0,0'
+ + ' SDCCH8+CBCH,0,0 TCH/F_TCH/H_PDCH,0,0')
+
+ def testBtsOmlConnectionState(self):
+ """Check OML state. It will not be connected"""
+ r = self.do_set('bts.0.oml-connection-state', '1')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Read Only attribute')
+
+ # No RSL link so everything is 0
+ r = self.do_get('bts.0.oml-connection-state')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['value'], 'disconnected')
+
+ def testTrxPowerRed(self):
+ r = self.do_get('bts.0.trx.0.max-power-reduction')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.trx.0.max-power-reduction')
+ self.assertEquals(r['value'], '20')
+
+ r = self.do_set('bts.0.trx.0.max-power-reduction', '22')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.trx.0.max-power-reduction')
+ self.assertEquals(r['value'], '22')
+
+ r = self.do_get('bts.0.trx.0.max-power-reduction')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.trx.0.max-power-reduction')
+ self.assertEquals(r['value'], '22')
+
+ r = self.do_set('bts.0.trx.0.max-power-reduction', '1')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Value must be even')
+
+ def testTrxArfcn(self):
+ r = self.do_get('bts.0.trx.0.arfcn')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.trx.0.arfcn')
+ self.assertEquals(r['value'], '871')
+
+ r = self.do_set('bts.0.trx.0.arfcn', '873')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.trx.0.arfcn')
+ self.assertEquals(r['value'], '873')
+
+ r = self.do_get('bts.0.trx.0.arfcn')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.trx.0.arfcn')
+ self.assertEquals(r['value'], '873')
+
+ r = self.do_set('bts.0.trx.0.arfcn', '2000')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Input not within the range')
+
+ def testRfLock(self):
+ r = self.do_get('bts.0.rf_state')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.rf_state')
+ self.assertEquals(r['value'], 'inoperational,unlocked,on')
+
+ r = self.do_set('rf_locked', '1')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'rf_locked')
+ self.assertEquals(r['value'], '1')
+
+ time.sleep(1.5)
+
+ r = self.do_get('bts.0.rf_state')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.rf_state')
+ self.assertEquals(r['value'], 'inoperational,locked,off')
+
+ r = self.do_get('rf_locked')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'rf_locked')
+ self.assertEquals(r['value'], 'state=off,policy=off')
+
+ r = self.do_set('rf_locked', '0')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'rf_locked')
+ self.assertEquals(r['value'], '0')
+
+ time.sleep(1.5)
+
+ r = self.do_get('bts.0.rf_state')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.rf_state')
+ self.assertEquals(r['value'], 'inoperational,unlocked,on')
+
+ r = self.do_get('rf_locked')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'rf_locked')
+ self.assertEquals(r['value'], 'state=off,policy=on')
+
+ def testTimezone(self):
+ r = self.do_get('timezone')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'timezone')
+ self.assertEquals(r['value'], 'off')
+
+ r = self.do_set('timezone', '-2,15,2')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'timezone')
+ self.assertEquals(r['value'], '-2,15,2')
+
+ r = self.do_get('timezone')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'timezone')
+ self.assertEquals(r['value'], '-2,15,2')
+
+ # Test invalid input
+ r = self.do_set('timezone', '-2,15,2,5,6,7')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'timezone')
+ self.assertEquals(r['value'], '-2,15,2')
+
+ r = self.do_set('timezone', '-2,15')
+ self.assertEquals(r['mtype'], 'ERROR')
+ r = self.do_set('timezone', '-2')
+ self.assertEquals(r['mtype'], 'ERROR')
+ r = self.do_set('timezone', '1')
+
+ r = self.do_set('timezone', 'off')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'timezone')
+ self.assertEquals(r['value'], 'off')
+
+ r = self.do_get('timezone')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'timezone')
+ self.assertEquals(r['value'], 'off')
+
+ def testMcc(self):
+ r = self.do_set('mcc', '23')
+ r = self.do_get('mcc')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'mcc')
+ self.assertEquals(r['value'], '23')
+
+ r = self.do_set('mcc', '023')
+ r = self.do_get('mcc')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'mcc')
+ self.assertEquals(r['value'], '23')
+
+ def testMnc(self):
+ r = self.do_set('mnc', '9')
+ r = self.do_get('mnc')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'mnc')
+ self.assertEquals(r['value'], '9')
+
+ r = self.do_set('mnc', '09')
+ r = self.do_get('mnc')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'mnc')
+ self.assertEquals(r['value'], '9')
+
+
+ def testMccMncApply(self):
+ # Test some invalid input
+ r = self.do_set('mcc-mnc-apply', 'WRONG')
+ self.assertEquals(r['mtype'], 'ERROR')
+
+ r = self.do_set('mcc-mnc-apply', '1,')
+ self.assertEquals(r['mtype'], 'ERROR')
+
+ r = self.do_set('mcc-mnc-apply', '200,3')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'mcc-mnc-apply')
+ self.assertEquals(r['value'], 'Tried to drop the BTS')
+
+ # Set it again
+ r = self.do_set('mcc-mnc-apply', '200,3')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'mcc-mnc-apply')
+ self.assertEquals(r['value'], 'Nothing changed')
+
+ # Change it
+ r = self.do_set('mcc-mnc-apply', '200,4')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'mcc-mnc-apply')
+ self.assertEquals(r['value'], 'Tried to drop the BTS')
+
+ # Change it
+ r = self.do_set('mcc-mnc-apply', '201,4')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'mcc-mnc-apply')
+ self.assertEquals(r['value'], 'Tried to drop the BTS')
+
+ # Verify
+ r = self.do_get('mnc')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'mnc')
+ self.assertEquals(r['value'], '4')
+
+ r = self.do_get('mcc')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'mcc')
+ self.assertEquals(r['value'], '201')
+
+ # Change it
+ r = self.do_set('mcc-mnc-apply', '202,03')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'mcc-mnc-apply')
+ self.assertEquals(r['value'], 'Tried to drop the BTS')
+
+ r = self.do_get('mnc')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'mnc')
+ self.assertEquals(r['value'], '3')
+
+ r = self.do_get('mcc')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'mcc')
+ self.assertEquals(r['value'], '202')
+
+class TestCtrlNITB(TestCtrlBase):
+
+ def tearDown(self):
+ TestCtrlBase.tearDown(self)
+ os.unlink("test_hlr.sqlite3")
+
+ def ctrl_command(self):
+ return ["./src/osmo-nitb/osmo-nitb", "-c",
+ "doc/examples/osmo-nitb/nanobts/openbsc.cfg", "-l", "test_hlr.sqlite3"]
+
+ def ctrl_app(self):
+ return (4249, "./src/osmo-nitb/osmo-nitb", "OsmoBSC", "nitb")
+
+ def testNumberOfBTS(self):
+ r = self.do_get('number-of-bts')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'number-of-bts')
+ self.assertEquals(r['value'], '1')
+
+ def testSubscriberAddWithKi(self):
+ """Test that we can set the algorithm to none, xor, comp128v1"""
+
+ r = self.do_set('subscriber-modify-v1', '2620345,445566')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-modify-v1')
+ self.assertEquals(r['value'], 'OK')
+
+ r = self.do_set('subscriber-modify-v1', '2620345,445566,none')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-modify-v1')
+ self.assertEquals(r['value'], 'OK')
+
+ r = self.do_set('subscriber-modify-v1', '2620345,445566,xor')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Value failed verification.')
+
+ r = self.do_set('subscriber-modify-v1', '2620345,445566,comp128v1,00112233445566778899AABBCCDDEEFF')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-modify-v1')
+ self.assertEquals(r['value'], 'OK')
+
+ r = self.do_set('subscriber-modify-v1', '2620345,445566,none')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-modify-v1')
+ self.assertEquals(r['value'], 'OK')
+
+ def testSubscriberAddRemove(self):
+ r = self.do_set('subscriber-modify-v1', '2620345,445566')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-modify-v1')
+ self.assertEquals(r['value'], 'OK')
+
+ r = self.do_set('subscriber-modify-v1', '2620345,445567')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-modify-v1')
+ self.assertEquals(r['value'], 'OK')
+
+ # TODO. verify that the entry has been created and modified? Invoke
+ # the sqlite3 CLI or do it through the DB libraries?
+
+ r = self.do_set('subscriber-delete-v1', '2620345')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['value'], 'Removed')
+
+ r = self.do_set('subscriber-delete-v1', '2620345')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Failed to find subscriber')
+
+ def testSubscriberList(self):
+ # TODO. Add command to mark a subscriber as active
+ r = self.do_get('subscriber-list-active-v1')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-list-active-v1')
+ self.assertEquals(r['value'], None)
+
+ def testApplyConfiguration(self):
+ r = self.do_get('bts.0.apply-configuration')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Write Only attribute')
+
+ r = self.do_set('bts.0.apply-configuration', '1')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['value'], 'Tried to drop the BTS')
+
+ def testGprsMode(self):
+ r = self.do_get('bts.0.gprs-mode')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.gprs-mode')
+ self.assertEquals(r['value'], 'none')
+
+ r = self.do_set('bts.0.gprs-mode', 'bla')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Mode is not known')
+
+ r = self.do_set('bts.0.gprs-mode', 'egprs')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['value'], 'egprs')
+
+ r = self.do_get('bts.0.gprs-mode')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.gprs-mode')
+ self.assertEquals(r['value'], 'egprs')
+
+class TestCtrlNAT(TestCtrlBase):
+
+ def ctrl_command(self):
+ return ["./src/osmo-bsc_nat/osmo-bsc_nat", "-c",
+ "doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg"]
+
+ def ctrl_app(self):
+ return (4250, "./src/osmo-bsc_nat/osmo-bsc_nat", "OsmoNAT", "nat")
+
+ def testAccessList(self):
+ r = self.do_get('net.0.bsc_cfg.0.access-list-name')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'net')
+ self.assertEquals(r['value'], None)
+
+ r = self.do_set('net.0.bsc_cfg.0.access-list-name', 'bla')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'net')
+ self.assertEquals(r['value'], 'bla')
+
+ r = self.do_get('net.0.bsc_cfg.0.access-list-name')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'net')
+ self.assertEquals(r['value'], 'bla')
+
+ r = self.do_set('net.0.bsc_cfg.0.no-access-list-name', '1')
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'net')
+ self.assertEquals(r['value'], None)
+
+ r = self.do_get('net.0.bsc_cfg.0.access-list-name')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'net')
+ self.assertEquals(r['value'], None)
+
+ def testAccessListManagement(self):
+ r = self.do_set("net.0.add.allow.access-list.404", "abc")
+ self.assertEquals(r['mtype'], 'ERROR')
+
+ r = self.do_set("net.0.add.allow.access-list.bla", "^234$")
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'net.0.add.allow.access-list.bla')
+ self.assertEquals(r['value'], 'IMSI allow added to access list')
+
+ # TODO.. find a way to actually see if this rule has been
+ # added. e.g. by implementing a get for the list.
+
+class TestCtrlSGSN(TestCtrlBase):
+ def ctrl_command(self):
+ return ["./src/gprs/osmo-sgsn", "-c",
+ "doc/examples/osmo-sgsn/osmo-sgsn.cfg"]
+
+ def ctrl_app(self):
+ return (4251, "./src/gprs/osmo-sgsn", "OsmoSGSN", "sgsn")
+
+ def testListSubscribers(self):
+ # TODO. Add command to mark a subscriber as active
+ r = self.do_get('subscriber-list-active-v1')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'subscriber-list-active-v1')
+ self.assertEquals(r['value'], None)
+
+def add_bsc_test(suite, workdir):
+ if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc/osmo-bsc")):
+ print("Skipping the BSC test")
+ return
+ test = unittest.TestLoader().loadTestsFromTestCase(TestCtrlBSC)
+ suite.addTest(test)
+
+def add_nitb_test(suite, workdir):
+ test = unittest.TestLoader().loadTestsFromTestCase(TestCtrlNITB)
+ suite.addTest(test)
+
+def add_nat_test(suite, workdir):
+ if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc_nat/osmo-bsc_nat")):
+ print("Skipping the NAT test")
+ return
+ test = unittest.TestLoader().loadTestsFromTestCase(TestCtrlNAT)
+ suite.addTest(test)
+
+def add_sgsn_test(suite, workdir):
+ if not os.path.isfile(os.path.join(workdir, "src/gprs/osmo-sgsn")):
+ print("Skipping the SGSN test")
+ return
+ test = unittest.TestLoader().loadTestsFromTestCase(TestCtrlSGSN)
+ suite.addTest(test)
+
+if __name__ == '__main__':
+ import argparse
+ import sys
+
+ workdir = '.'
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-v", "--verbose", dest="verbose",
+ action="store_true", help="verbose mode")
+ parser.add_argument("-p", "--pythonconfpath", dest="p",
+ help="searchpath for config")
+ parser.add_argument("-w", "--workdir", dest="w",
+ help="Working directory")
+ args = parser.parse_args()
+
+ verbose_level = 1
+ if args.verbose:
+ verbose_level = 2
+ verbose = True
+
+ if args.w:
+ workdir = args.w
+
+ if args.p:
+ confpath = args.p
+
+ print "confpath %s, workdir %s" % (confpath, workdir)
+ os.chdir(workdir)
+ print "Running tests for specific control commands"
+ suite = unittest.TestSuite()
+ add_bsc_test(suite, workdir)
+ add_nitb_test(suite, workdir)
+ add_nat_test(suite, workdir)
+ add_sgsn_test(suite, workdir)
+ res = unittest.TextTestRunner(verbosity=verbose_level).run(suite)
+ sys.exit(len(res.errors) + len(res.failures))
diff --git a/tests/db/Makefile.am b/tests/db/Makefile.am
new file mode 100644
index 000000000..0eed5cd55
--- /dev/null
+++ b/tests/db/Makefile.am
@@ -0,0 +1,48 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(LIBSMPP34_CFLAGS) \
+ $(COVERAGE_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(COVERAGE_LDFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ db_test.ok \
+ db_test.err \
+ hlr.sqlite3 \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ db_test \
+ $(NULL)
+
+db_test_SOURCES = \
+ db_test.c \
+ $(NULL)
+
+db_test_LDADD = \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libmsc/libmsc.a \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOABIS_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBSMPP34_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
+ $(LIBCRYPTO_LIBS) \
+ -ldbi \
+ $(NULL)
diff --git a/tests/db/db_test.c b/tests/db/db_test.c
new file mode 100644
index 000000000..755a6e9eb
--- /dev/null
+++ b/tests/db/db_test.c
@@ -0,0 +1,256 @@
+/* (C) 2008 by Jan Luebbe <jluebbe@debian.org>
+ * (C) 2009-2016 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2014 by Alexander Chemeris <Alexander.Chemeris@fairwaves.co>
+ * All Rights Reserved
+ *
+ * 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 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/>.
+ *
+ */
+
+#include <openbsc/debug.h>
+#include <openbsc/db.h>
+#include <openbsc/gsm_subscriber.h>
+#include <openbsc/gsm_04_11.h>
+
+#include <osmocom/core/application.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <inttypes.h>
+
+static struct gsm_network dummy_net;
+static struct gsm_subscriber_group dummy_sgrp;
+
+#define SUBSCR_PUT(sub) \
+ sub->group = &dummy_sgrp; \
+ subscr_put(sub);
+
+#define COMPARE(original, copy) \
+ if (original->id != copy->id) \
+ printf("Ids do not match in %s:%d %llu %llu\n", \
+ __FUNCTION__, __LINE__, original->id, copy->id); \
+ if (original->lac != copy->lac) \
+ printf("LAC do not match in %s:%d %d %d\n", \
+ __FUNCTION__, __LINE__, original->lac, copy->lac); \
+ if (original->authorized != copy->authorized) \
+ printf("Authorize do not match in %s:%d %d %d\n", \
+ __FUNCTION__, __LINE__, original->authorized, \
+ copy->authorized); \
+ if (strcmp(original->imsi, copy->imsi) != 0) \
+ printf("IMSIs do not match in %s:%d '%s' '%s'\n", \
+ __FUNCTION__, __LINE__, original->imsi, copy->imsi); \
+ if (original->tmsi != copy->tmsi) \
+ printf("TMSIs do not match in %s:%d '%u' '%u'\n", \
+ __FUNCTION__, __LINE__, original->tmsi, copy->tmsi); \
+ if (strcmp(original->name, copy->name) != 0) \
+ printf("names do not match in %s:%d '%s' '%s'\n", \
+ __FUNCTION__, __LINE__, original->name, copy->name); \
+ if (strcmp(original->extension, copy->extension) != 0) \
+ printf("Extensions do not match in %s:%d '%s' '%s'\n", \
+ __FUNCTION__, __LINE__, original->extension, copy->extension); \
+
+/*
+ * Create/Store a SMS and then try to load it.
+ */
+static void test_sms(void)
+{
+ int rc;
+ struct gsm_sms *sms;
+ struct gsm_subscriber *subscr;
+ subscr = db_get_subscriber(GSM_SUBSCRIBER_IMSI, "9993245423445");
+ OSMO_ASSERT(subscr);
+ subscr->group = &dummy_sgrp;
+
+ sms = sms_alloc();
+ sms->receiver = subscr_get(subscr);
+
+ sms->src.ton = 0x23;
+ sms->src.npi = 0x24;
+ memcpy(sms->src.addr, "1234", strlen("1234") + 1);
+
+ sms->dst.ton = 0x32;
+ sms->dst.npi = 0x42;
+ memcpy(sms->dst.addr, subscr->extension, sizeof(subscr->extension));
+
+ memcpy(sms->text, "Text123", strlen("Text123") + 1);
+ memcpy(sms->user_data, "UserData123", strlen("UserData123") + 1);
+ sms->user_data_len = strlen("UserData123");
+
+ /* random values */
+ sms->reply_path_req = 1;
+ sms->status_rep_req = 2;
+ sms->ud_hdr_ind = 3;
+ sms->protocol_id = 4;
+ sms->data_coding_scheme = 5;
+
+ rc = db_sms_store(sms);
+ sms_free(sms);
+ OSMO_ASSERT(rc == 0);
+
+ /* now query */
+ sms = db_sms_get_unsent_for_subscr(subscr);
+ OSMO_ASSERT(sms);
+ OSMO_ASSERT(sms->receiver == subscr);
+ OSMO_ASSERT(sms->reply_path_req == 1);
+ OSMO_ASSERT(sms->status_rep_req == 2);
+ OSMO_ASSERT(sms->ud_hdr_ind == 3);
+ OSMO_ASSERT(sms->protocol_id == 4);
+ OSMO_ASSERT(sms->data_coding_scheme == 5);
+ OSMO_ASSERT(sms->src.ton == 0x23);
+ OSMO_ASSERT(sms->src.npi == 0x24);
+ OSMO_ASSERT(sms->dst.ton == 0x32);
+ OSMO_ASSERT(sms->dst.npi == 0x42);
+ OSMO_ASSERT(strcmp((char *) sms->text, "Text123") == 0);
+ OSMO_ASSERT(sms->user_data_len == strlen("UserData123"));
+ OSMO_ASSERT(strcmp((char *) sms->user_data, "UserData123") == 0);
+
+ /* Mark the SMS as delivered */
+ db_sms_mark_delivered(sms);
+ sms_free(sms);
+
+ sms = db_sms_get_unsent_for_subscr(subscr);
+ OSMO_ASSERT(!sms);
+
+ subscr_put(subscr);
+}
+
+static void test_sms_migrate(void)
+{
+ struct gsm_subscriber *rcv_subscr;
+ struct gsm_sms *sms;
+ static const uint8_t user_data_1[] = {
+ 0x41, 0xf1, 0xd8, 0x05, 0x22, 0x96, 0xcd, 0x2e,
+ 0x90, 0xf1, 0xfd, 0x06, 0x00 };
+ static const uint8_t user_data_2[] = {
+ 0x41, 0xf1, 0xd8, 0x05, 0x22, 0x96, 0xcd, 0x2e,
+ 0xd0, 0xf1, 0xfd, 0x06, 0x00 };
+
+ rcv_subscr = db_get_subscriber(GSM_SUBSCRIBER_IMSI, "901010000001111");
+ rcv_subscr->group = &dummy_sgrp;
+
+ sms = db_sms_get(&dummy_net, 1);
+ OSMO_ASSERT(sms->id == 1);
+ OSMO_ASSERT(sms->receiver == rcv_subscr);
+ OSMO_ASSERT(strcmp(sms->text, "Abc. Def. Foo") == 0);
+ OSMO_ASSERT(sms->user_data_len == ARRAY_SIZE(user_data_1));
+ OSMO_ASSERT(memcmp(sms->user_data, user_data_1, ARRAY_SIZE(user_data_1)) == 0);
+ sms_free(sms);
+
+ sms = db_sms_get(&dummy_net, 2);
+ OSMO_ASSERT(sms->id == 2);
+ OSMO_ASSERT(sms->receiver == rcv_subscr);
+ OSMO_ASSERT(strcmp(sms->text, "Abc. Def. Goo") == 0);
+ OSMO_ASSERT(sms->user_data_len == ARRAY_SIZE(user_data_2));
+ OSMO_ASSERT(memcmp(sms->user_data, user_data_2, ARRAY_SIZE(user_data_2)) == 0);
+ sms_free(sms);
+
+ subscr_put(rcv_subscr);
+}
+
+static void test_subs(const char *imsi, char *imei1, char *imei2, bool make_ext)
+{
+ struct gsm_subscriber *alice = NULL, *alice_db;
+ char scratch_str[256];
+
+ alice = db_create_subscriber(imsi, GSM_MIN_EXTEN, GSM_MAX_EXTEN,
+ make_ext);
+ db_subscriber_assoc_imei(alice, imei1);
+ if (imei2)
+ db_subscriber_assoc_imei(alice, imei2);
+ db_subscriber_alloc_tmsi(alice);
+ alice->lac=42;
+ db_sync_subscriber(alice);
+ /* Get by TMSI */
+ snprintf(scratch_str, sizeof(scratch_str), "%"PRIu32, alice->tmsi);
+ alice_db = db_get_subscriber(GSM_SUBSCRIBER_TMSI, scratch_str);
+ COMPARE(alice, alice_db);
+ SUBSCR_PUT(alice_db);
+ /* Get by IMSI */
+ alice_db = db_get_subscriber(GSM_SUBSCRIBER_IMSI, imsi);
+ COMPARE(alice, alice_db);
+ SUBSCR_PUT(alice_db);
+ /* Get by id */
+ snprintf(scratch_str, sizeof(scratch_str), "%llu", alice->id);
+ alice_db = db_get_subscriber(GSM_SUBSCRIBER_ID, scratch_str);
+ COMPARE(alice, alice_db);
+ SUBSCR_PUT(alice_db);
+ /* Get by extension */
+ alice_db = db_get_subscriber(GSM_SUBSCRIBER_EXTENSION, alice->extension);
+ if (alice_db) {
+ if (!make_ext)
+ printf("FAIL: bogus extension created for IMSI %s\n",
+ imsi);
+ COMPARE(alice, alice_db);
+ SUBSCR_PUT(alice_db);
+ } else if (make_ext)
+ printf("FAIL: no subscriber extension for IMSI %s\n", imsi);
+ SUBSCR_PUT(alice);
+}
+
+int main()
+{
+ printf("Testing subscriber database code.\n");
+ osmo_init_logging(&log_info);
+ log_set_print_filename(osmo_stderr_target, 0);
+
+ dummy_net.subscr_group = &dummy_sgrp;
+ dummy_sgrp.net = &dummy_net;
+
+ if (db_init("hlr.sqlite3")) {
+ printf("DB: Failed to init database. Please check the option settings.\n");
+ return 1;
+ }
+ printf("DB: Database initialized.\n");
+
+ if (db_prepare()) {
+ printf("DB: Failed to prepare database.\n");
+ return 1;
+ }
+ printf("DB: Database prepared.\n");
+
+ struct gsm_subscriber *alice = NULL;
+ struct gsm_subscriber *alice_db;
+
+ char *alice_imsi = "3243245432345";
+ alice = db_create_subscriber(alice_imsi, GSM_MIN_EXTEN, GSM_MAX_EXTEN,
+ true);
+ db_sync_subscriber(alice);
+ alice_db = db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice->imsi);
+ COMPARE(alice, alice_db);
+ SUBSCR_PUT(alice_db);
+ SUBSCR_PUT(alice);
+
+ test_subs("3693245423445", "1234567890", NULL, true);
+ test_subs("9993245423445", "1234567890", "6543560920", true);
+ test_subs("3123122223445", "1234567890", NULL, false);
+ test_subs("9123121223445", "1234567890", "6543560920", false);
+
+ /* create it again and see it fails */
+ alice = db_create_subscriber(alice_imsi, GSM_MIN_EXTEN, GSM_MAX_EXTEN,
+ true);
+ OSMO_ASSERT(!alice);
+
+ test_sms();
+ test_sms_migrate();
+
+ db_fini();
+
+ printf("Done\n");
+ return 0;
+}
+
+/* stubs */
+void vty_out() {}
diff --git a/tests/db/db_test.err b/tests/db/db_test.err
new file mode 100644
index 000000000..fa9a54c09
--- /dev/null
+++ b/tests/db/db_test.err
@@ -0,0 +1,2 @@
+Going to migrate from revision 3
+ \ No newline at end of file
diff --git a/tests/db/db_test.ok b/tests/db/db_test.ok
new file mode 100644
index 000000000..2632a8c8a
--- /dev/null
+++ b/tests/db/db_test.ok
@@ -0,0 +1,4 @@
+Testing subscriber database code.
+DB: Database initialized.
+DB: Database prepared.
+Done
diff --git a/tests/db/hlr.sqlite3 b/tests/db/hlr.sqlite3
new file mode 100644
index 000000000..e59dcdca3
--- /dev/null
+++ b/tests/db/hlr.sqlite3
Binary files differ
diff --git a/tests/gbproxy/Makefile.am b/tests/gbproxy/Makefile.am
new file mode 100644
index 000000000..2dd66dfd4
--- /dev/null
+++ b/tests/gbproxy/Makefile.am
@@ -0,0 +1,54 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(COVERAGE_LDFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ gbproxy_test.ok \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ gbproxy_test \
+ $(NULL)
+
+gbproxy_test_SOURCES = \
+ gbproxy_test.c \
+ $(NULL)
+
+gbproxy_test_LDFLAGS = \
+ -Wl,--wrap=RAND_bytes \
+ $(NULL)
+
+gbproxy_test_LDADD = \
+ $(top_builddir)/src/gprs/gb_proxy.o \
+ $(top_builddir)/src/gprs/gb_proxy_patch.o \
+ $(top_builddir)/src/gprs/gb_proxy_peer.o \
+ $(top_builddir)/src/gprs/gb_proxy_tlli.o \
+ $(top_builddir)/src/gprs/gprs_gb_parse.o \
+ $(top_builddir)/src/gprs/gprs_llc_parse.o \
+ $(top_builddir)/src/gprs/crc24.o \
+ $(top_builddir)/src/gprs/gprs_utils.o \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGB_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
+ $(LIBOSMOABIS_LIBS) \
+ $(LIBRARY_DL) \
+ $(LIBCRYPTO_LIBS) \
+ -lrt \
+ $(NULL)
diff --git a/tests/gbproxy/gbproxy_test.c b/tests/gbproxy/gbproxy_test.c
new file mode 100644
index 000000000..577daa95e
--- /dev/null
+++ b/tests/gbproxy/gbproxy_test.c
@@ -0,0 +1,4971 @@
+/* test routines for gbproxy
+ * send NS messages to the gbproxy and dumps what happens
+ * (C) 2013 by sysmocom s.f.m.c. GmbH
+ * Author: Jacob Erlbeck <jerlbeck@sysmocom.de>
+ */
+
+#undef _GNU_SOURCE
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <getopt.h>
+#include <dlfcn.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/application.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/rate_ctr.h>
+#include <osmocom/gsm/tlv.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
+#include <osmocom/gprs/gprs_msgb.h>
+#include <osmocom/gprs/gprs_ns.h>
+#include <osmocom/gprs/gprs_bssgp.h>
+
+#include <openbsc/gb_proxy.h>
+#include <openbsc/gprs_utils.h>
+#include <openbsc/gprs_llc.h>
+#include <openbsc/gprs_gb_parse.h>
+#include <openbsc/debug.h>
+
+#include <openssl/rand.h>
+
+#define REMOTE_BSS_ADDR 0x01020304
+#define REMOTE_SGSN_ADDR 0x05060708
+
+#define SGSN_NSEI 0x0100
+
+#define REMOTE_SGSN2_ADDR 0x15161718
+#define SGSN2_NSEI 0x0102
+
+#define MATCH_ANY (-1)
+
+struct gbproxy_config gbcfg = {0};
+
+struct llist_head *received_messages = NULL;
+
+/* override, requires '-Wl,--wrap=RAND_bytes' */
+int __real_RAND_bytes(unsigned char *buf, int num);
+int mock_RAND_bytes(unsigned char *buf, int num);
+int (*RAND_bytes_cb)(unsigned char *, int) =
+ &mock_RAND_bytes;
+
+int __wrap_RAND_bytes(unsigned char *buf, int num)
+{
+ return (*RAND_bytes_cb)(buf, num);
+}
+
+static int rand_seq_num = 0;
+int mock_RAND_bytes(unsigned char *buf, int num)
+{
+ uint32_t val;
+
+ OSMO_ASSERT(num == sizeof(val));
+ OSMO_ASSERT(__real_RAND_bytes(buf, num) == 1);
+
+ val = 0x00dead00 + rand_seq_num;
+
+ rand_seq_num++;
+
+ memcpy(buf, &val, num);
+
+ return 1;
+}
+
+static void cleanup_test()
+{
+ rand_seq_num = 0;
+}
+
+static int dump_global(FILE *stream, int indent)
+{
+ unsigned int i;
+ const struct rate_ctr_group_desc *desc;
+ int rc;
+
+ rc = fprintf(stream, "%*sGbproxy global:\n", indent, "");
+ if (rc < 0)
+ return rc;
+
+ desc = gbcfg.ctrg->desc;
+
+ for (i = 0; i < desc->num_ctr; i++) {
+ struct rate_ctr *ctr = &gbcfg.ctrg->ctr[i];
+ if (ctr->current) {
+ rc = fprintf(stream, "%*s %s: %llu\n",
+ indent, "",
+ desc->ctr_desc[i].description,
+ (long long)ctr->current);
+
+ if (rc < 0)
+ return rc;
+ }
+ }
+
+ return 0;
+}
+
+static int dump_peers(FILE *stream, int indent, time_t now,
+ struct gbproxy_config *cfg)
+{
+ struct gbproxy_peer *peer;
+ struct gprs_ra_id raid;
+ unsigned int i;
+ const struct rate_ctr_group_desc *desc;
+ int rc;
+
+ rc = fprintf(stream, "%*sPeers:\n", indent, "");
+ if (rc < 0)
+ return rc;
+
+ llist_for_each_entry(peer, &cfg->bts_peers, list) {
+ struct gbproxy_link_info *link_info;
+ struct gbproxy_patch_state *state = &peer->patch_state;
+ gsm48_parse_ra(&raid, peer->ra);
+
+ rc = fprintf(stream, "%*s NSEI %u, BVCI %u, %sblocked, "
+ "RAI %u-%u-%u-%u\n",
+ indent, "",
+ peer->nsei, peer->bvci,
+ peer->blocked ? "" : "not ",
+ raid.mcc, raid.mnc, raid.lac, raid.rac);
+
+ if (rc < 0)
+ return rc;
+
+ desc = peer->ctrg->desc;
+
+ for (i = 0; i < desc->num_ctr; i++) {
+ struct rate_ctr *ctr = &peer->ctrg->ctr[i];
+ if (ctr->current) {
+ rc = fprintf(stream, "%*s %s: %llu\n",
+ indent, "",
+ desc->ctr_desc[i].description,
+ (long long)ctr->current);
+
+ if (rc < 0)
+ return rc;
+ }
+ }
+
+ fprintf(stream, "%*s TLLI-Cache: %d\n",
+ indent, "", state->logical_link_count);
+ llist_for_each_entry(link_info, &state->logical_links, list) {
+ char mi_buf[200];
+ time_t age = now ? now - link_info->timestamp : 0;
+ int stored_msgs = 0;
+ struct llist_head *iter;
+ enum gbproxy_match_id match_id;
+ llist_for_each(iter, &link_info->stored_msgs)
+ stored_msgs++;
+
+ if (link_info->imsi_len > 0) {
+ snprintf(mi_buf, sizeof(mi_buf), "(invalid)");
+ gsm48_mi_to_string(mi_buf, sizeof(mi_buf),
+ link_info->imsi,
+ link_info->imsi_len);
+ } else {
+ snprintf(mi_buf, sizeof(mi_buf), "(none)");
+ }
+ fprintf(stream, "%*s TLLI %08x",
+ indent, "", link_info->tlli.current);
+ if (link_info->tlli.assigned)
+ fprintf(stream, "/%08x", link_info->tlli.assigned);
+ if (link_info->sgsn_tlli.current) {
+ fprintf(stream, " -> %08x",
+ link_info->sgsn_tlli.current);
+ if (link_info->sgsn_tlli.assigned)
+ fprintf(stream, "/%08x",
+ link_info->sgsn_tlli.assigned);
+ }
+ fprintf(stream, ", IMSI %s, AGE %d",
+ mi_buf, (int)age);
+
+ if (stored_msgs)
+ fprintf(stream, ", STORED %d", stored_msgs);
+
+ for (match_id = 0; match_id < ARRAY_SIZE(cfg->matches);
+ ++match_id) {
+ if (cfg->matches[match_id].enable &&
+ link_info->is_matching[match_id]) {
+ fprintf(stream, ", IMSI matches");
+ break;
+ }
+ }
+
+ if (link_info->imsi_acq_pending)
+ fprintf(stream, ", IMSI acquisition in progress");
+
+ if (cfg->route_to_sgsn2)
+ fprintf(stream, ", SGSN NSEI %d",
+ link_info->sgsn_nsei);
+
+ if (link_info->is_deregistered)
+ fprintf(stream, ", DE-REGISTERED");
+
+ rc = fprintf(stream, "\n");
+ if (rc < 0)
+ return rc;
+ }
+ }
+
+ return 0;
+}
+
+const uint8_t *convert_ra(struct gprs_ra_id *raid)
+{
+ static uint8_t buf[6];
+ gsm48_construct_ra(buf, raid);
+ return buf;
+}
+
+/* DTAP - Attach Request */
+static const unsigned char dtap_attach_req[] = {
+ 0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,
+ 0x05, 0xf4, 0xfb, 0xc5, 0x46, 0x79, 0x11, 0x22,
+ 0x33, 0x40, 0x50, 0x60, 0x19, 0x18, 0xb3, 0x43,
+ 0x2b, 0x25, 0x96, 0x62, 0x00, 0x60, 0x80, 0x9a,
+ 0xc2, 0xc6, 0x62, 0x00, 0x60, 0x80, 0xba, 0xc8,
+ 0xc6, 0x62, 0x00, 0x60, 0x80, 0x00,
+};
+
+/* DTAP - Attach Request (invalid RAI) */
+static const unsigned char dtap_attach_req2[] = {
+ 0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,
+ 0x05, 0xf4, 0xfb, 0x00, 0xbe, 0xef, 0x99, 0x99,
+ 0x99, 0x40, 0x50, 0x60, 0x19, 0x18, 0xb3, 0x43,
+ 0x2b, 0x25, 0x96, 0x62, 0x00, 0x60, 0x80, 0x9a,
+ 0xc2, 0xc6, 0x62, 0x00, 0x60, 0x80, 0xba, 0xc8,
+ 0xc6, 0x62, 0x00, 0x60, 0x80, 0x00,
+};
+
+/* DTAP - Attach Request (P-TMSI 0x3f32b700) */
+static const unsigned char dtap_attach_req3[] = {
+ 0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,
+ 0x05, 0xf4, 0xef, 0xe2, 0xb7, 0x00, 0x11, 0x22,
+ 0x33, 0x40, 0x50, 0x60, 0x19, 0x18, 0xb3, 0x43,
+ 0x2b, 0x25, 0x96, 0x62, 0x00, 0x60, 0x80, 0x9a,
+ 0xc2, 0xc6, 0x62, 0x00, 0x60, 0x80, 0xba, 0xc8,
+ 0xc6, 0x62, 0x00, 0x60, 0x80, 0x00,
+};
+
+/* DTAP - Attach Request (IMSI 12131415161718) */
+static const unsigned char dtap_attach_req4[] = {
+ 0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,
+ 0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60, 0x19,
+ 0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00,
+ 0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60,
+ 0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80,
+ 0x00,
+};
+
+/* DTAP - Identity Request */
+static const unsigned char dtap_identity_req[] = {
+ 0x08, 0x15, 0x01
+};
+
+/* DTAP - Identity Response */
+static const unsigned char dtap_identity_resp[] = {
+ 0x08, 0x16, 0x08, 0x11, 0x12, 0x13, 0x14, 0x15,
+ 0x16, 0x17, 0x18
+};
+
+/* DTAP - Identity Response, IMSI 2 */
+static const unsigned char dtap_identity2_resp[] = {
+ 0x08, 0x16, 0x08, 0x11, 0x12, 0x99, 0x99, 0x99,
+ 0x16, 0x17, 0x18
+};
+
+/* DTAP - Identity Response, IMSI 3 */
+static const unsigned char dtap_identity3_resp[] = {
+ 0x08, 0x16, 0x08, 0x11, 0x12, 0x99, 0x99, 0x99,
+ 0x26, 0x27, 0x28
+};
+
+/* DTAP - Attach Accept */
+static const unsigned char dtap_attach_acc[] = {
+ 0x08, 0x02, 0x01, 0x49, 0x04, 0x21, 0x63, 0x54,
+ 0x40, 0x50, 0x60, 0x19, 0xcd, 0xd7, 0x08, 0x17,
+ 0x16, 0x18, 0x05, 0xf4, 0xef, 0xe2, 0xb7, 0x00
+};
+
+/* DTAP - Attach Accept, P-TMSI 2 */
+static const unsigned char dtap_attach_acc2[] = {
+ 0x08, 0x02, 0x01, 0x49, 0x04, 0x21, 0x63, 0x54,
+ 0x40, 0x50, 0x60, 0x19, 0xcd, 0xd7, 0x08, 0x17,
+ 0x16, 0x18, 0x05, 0xf4, 0xe0, 0x98, 0x76, 0x54
+};
+
+/* DTAP - Attach Complete */
+static const unsigned char dtap_attach_complete[] = {
+ 0x08, 0x03
+};
+
+/* DTAP - Attach Reject (GPRS services not allowed) */
+static const unsigned char dtap_attach_rej7[] = {
+ 0x08, 0x04, 0x07
+};
+
+/* DTAP - GMM Information */
+static const unsigned char dtap_gmm_information[] = {
+ 0x08, 0x21
+};
+
+/* DTAP - Routing Area Update Request */
+static const unsigned char dtap_ra_upd_req[] = {
+ 0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,
+ 0x60, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
+ 0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
+ 0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
+ 0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
+ 0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
+ 0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
+};
+
+/* DTAP - Routing Area Update Accept */
+static const unsigned char dtap_ra_upd_acc[] = {
+ 0x08, 0x09, 0x00, 0x49, 0x21, 0x63, 0x54,
+ 0x40, 0x50, 0x60, 0x19, 0x54, 0xab, 0xb3, 0x18,
+ 0x05, 0xf4, 0xef, 0xe2, 0xb7, 0x00, 0x17, 0x16,
+};
+
+/* DTAP - Routing Area Update Accept, P-TMSI 2 */
+static const unsigned char dtap_ra_upd_acc2[] = {
+ 0x08, 0x09, 0x00, 0x49, 0x21, 0x63, 0x54,
+ 0x40, 0x50, 0x60, 0x19, 0x54, 0xab, 0xb3, 0x18,
+ 0x05, 0xf4, 0xe0, 0x98, 0x76, 0x54, 0x17, 0x16,
+};
+
+/* DTAP - Routing Area Update Accept, P-TMSI 3 */
+static const unsigned char dtap_ra_upd_acc3[] = {
+ 0x08, 0x09, 0x00, 0x49, 0x21, 0x63, 0x54,
+ 0x40, 0x50, 0x60, 0x19, 0x54, 0xab, 0xb3, 0x18,
+ 0x05, 0xf4, 0xe0, 0x54, 0x32, 0x10, 0x17, 0x16,
+};
+
+/* DTAP - Routing Area Update Complete */
+static const unsigned char dtap_ra_upd_complete[] = {
+ 0x08, 0x0a
+};
+
+/* DTAP - Routing Area Update Reject */
+/* cause = 10 ("Implicitly detached"), force_standby = 0 */
+static const unsigned char dtap_ra_upd_rej[] = {
+ 0x08, 0x0b, 0x0a, 0x00,
+};
+
+/* DTAP - Activate PDP Context Request */
+static const unsigned char dtap_act_pdp_ctx_req[] = {
+ 0x0a, 0x41, 0x05, 0x03, 0x0c, 0x00,
+ 0x00, 0x1f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0x01, 0x21, 0x28, 0x03,
+ 0x02, 0x61, 0x62, 0x27, 0x14, 0x80, 0x80, 0x21,
+ 0x10, 0x01, 0x00, 0x00, 0x10, 0x81, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x83, 0x06, 0x00, 0x00, 0x00,
+ 0x00
+};
+
+/* DTAP - Detach Request (MO) */
+/* normal detach, power_off = 1 */
+static const unsigned char dtap_detach_po_req[] = {
+ 0x08, 0x05, 0x09, 0x18, 0x05, 0xf4, 0xef, 0xe2,
+ 0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb
+};
+
+/* DTAP - Detach Request (MO) */
+/* normal detach, power_off = 0 */
+static const unsigned char dtap_detach_req[] = {
+ 0x08, 0x05, 0x01, 0x18, 0x05, 0xf4, 0xef, 0xe2,
+ 0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb
+};
+
+/* DTAP - Detach Accept (MO) */
+static const unsigned char dtap_detach_acc[] = {
+ 0x08, 0x06, 0x00
+};
+
+/* DTAP - Detach Request (MT) */
+/* normal detach, reattach required, implicitly detached */
+static const unsigned char dtap_mt_detach_rea_req[] = {
+ 0x08, 0x05, 0x01, 0x25, 0x0a
+};
+
+/* DTAP - Detach Request (MT) */
+/* normal detach, reattach not required, implicitly detached */
+static const unsigned char dtap_mt_detach_req[] = {
+ 0x08, 0x05, 0x02, 0x25, 0x0a
+};
+
+/* DTAP - Detach Accept (MT) */
+static const unsigned char dtap_mt_detach_acc[] = {
+ 0x08, 0x06
+};
+
+/* GPRS-LLC - SAPI: LLGMM, U, XID */
+static const unsigned char llc_u_xid_ul[] = {
+ 0x41, 0xfb, 0x01, 0x00, 0x0e, 0x00, 0x64, 0x11,
+ 0x05, 0x16, 0x01, 0x90, 0x66, 0xb3, 0x28
+};
+
+/* GPRS-LLC - SAPI: LLGMM, U, XID */
+static const unsigned char llc_u_xid_dl[] = {
+ 0x41, 0xfb, 0x30, 0x84, 0x10, 0x61, 0xb6, 0x64,
+ 0xe4, 0xa9, 0x1a, 0x9e
+};
+
+/* GPRS-LLC - SAPI: LL11, UI, NSAPI 5, DNS query */
+static const unsigned char llc_ui_ll11_dns_query_ul[] = {
+ 0x0b, 0xc0, 0x01, 0x65, 0x00, 0x00, 0x00, 0x45,
+ 0x00, 0x00, 0x38, 0x95, 0x72, 0x00, 0x00, 0x45,
+ 0x11, 0x20, 0x85, 0x0a, 0xc0, 0x07, 0xe4, 0xac,
+ 0x10, 0x01, 0x0a, 0xad, 0xab, 0x00, 0x35, 0x00,
+ 0x24, 0x0e, 0x1c, 0x3b, 0xe0, 0x01, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x6d, 0x05, 0x68, 0x65, 0x69, 0x73, 0x65, 0x02,
+ 0x64, 0x65, 0x00, 0x00, 0x01, 0x00, 0x01, 0x47,
+ 0x8f, 0x07
+};
+
+/* GPRS-LLC - SAPI: LL11, UI, NSAPI 5, DNS query */
+static const unsigned char llc_ui_ll11_dns_resp_dl[] = {
+ 0x4b, 0xc0, 0x01, 0x65, 0x00, 0x00, 0x00, 0x45,
+ 0x00, 0x00, 0xc6, 0x00, 0x00, 0x40, 0x00, 0x3e,
+ 0x11, 0x7c, 0x69, 0xac, 0x10, 0x01, 0x0a, 0x0a,
+ 0xc0, 0x07, 0xe4, 0x00, 0x35, 0xad, 0xab, 0x00,
+ 0xb2, 0x74, 0x4e, 0x3b, 0xe0, 0x81, 0x80, 0x00,
+ 0x01, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x01,
+ 0x6d, 0x05, 0x68, 0x65, 0x69, 0x73, 0x65, 0x02,
+ 0x64, 0x65, 0x00, 0x00, 0x01, 0x00, 0x01, 0xc0,
+ 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0e,
+ 0x10, 0x00, 0x04, 0xc1, 0x63, 0x90, 0x58, 0xc0,
+ 0x0e, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e,
+ 0x10, 0x00, 0x16, 0x03, 0x6e, 0x73, 0x32, 0x0c,
+ 0x70, 0x6f, 0x70, 0x2d, 0x68, 0x61, 0x6e, 0x6e,
+ 0x6f, 0x76, 0x65, 0x72, 0x03, 0x6e, 0x65, 0x74,
+ 0x00, 0xc0, 0x0e, 0x00, 0x02, 0x00, 0x01, 0x00,
+ 0x00, 0x0e, 0x10, 0x00, 0x10, 0x02, 0x6e, 0x73,
+ 0x01, 0x73, 0x08, 0x70, 0x6c, 0x75, 0x73, 0x6c,
+ 0x69, 0x6e, 0x65, 0xc0, 0x14, 0xc0, 0x0e, 0x00,
+ 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10, 0x00,
+ 0x05, 0x02, 0x6e, 0x73, 0xc0, 0x0e, 0xc0, 0x0e,
+ 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x10,
+ 0x00, 0x05, 0x02, 0x6e, 0x73, 0xc0, 0x5f, 0xc0,
+ 0x0e, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x0e,
+ 0x10, 0x00, 0x12, 0x02, 0x6e, 0x73, 0x0c, 0x70,
+ 0x6f, 0x70, 0x2d, 0x68, 0x61, 0x6e, 0x6e, 0x6f,
+ 0x76, 0x65, 0x72, 0xc0, 0x14, 0xaa, 0xdf, 0x31
+};
+
+static int gprs_process_message(struct gprs_ns_inst *nsi, const char *text,
+ struct sockaddr_in *peer, const unsigned char* data,
+ size_t data_len);
+
+static void send_ns_reset(struct gprs_ns_inst *nsi, struct sockaddr_in *src_addr,
+ enum ns_cause cause, uint16_t nsvci, uint16_t nsei)
+{
+ /* GPRS Network Service, PDU type: NS_RESET,
+ */
+ unsigned char msg[12] = {
+ 0x02, 0x00, 0x81, 0x01, 0x01, 0x82, 0x11, 0x22,
+ 0x04, 0x82, 0x11, 0x22
+ };
+
+ msg[3] = cause;
+ msg[6] = nsvci / 256;
+ msg[7] = nsvci % 256;
+ msg[10] = nsei / 256;
+ msg[11] = nsei % 256;
+
+ gprs_process_message(nsi, "RESET", src_addr, msg, sizeof(msg));
+}
+
+static void send_ns_reset_ack(struct gprs_ns_inst *nsi, struct sockaddr_in *src_addr,
+ uint16_t nsvci, uint16_t nsei)
+{
+ /* GPRS Network Service, PDU type: NS_RESET_ACK,
+ */
+ unsigned char msg[9] = {
+ 0x03, 0x01, 0x82, 0x11, 0x22,
+ 0x04, 0x82, 0x11, 0x22
+ };
+
+ msg[3] = nsvci / 256;
+ msg[4] = nsvci % 256;
+ msg[7] = nsei / 256;
+ msg[8] = nsei % 256;
+
+ gprs_process_message(nsi, "RESET_ACK", src_addr, msg, sizeof(msg));
+}
+
+static void send_ns_alive(struct gprs_ns_inst *nsi, struct sockaddr_in *src_addr)
+{
+ /* GPRS Network Service, PDU type: NS_ALIVE */
+ unsigned char msg[1] = {
+ 0x0a
+ };
+
+ gprs_process_message(nsi, "ALIVE", src_addr, msg, sizeof(msg));
+}
+
+static void send_ns_alive_ack(struct gprs_ns_inst *nsi, struct sockaddr_in *src_addr)
+{
+ /* GPRS Network Service, PDU type: NS_ALIVE_ACK */
+ unsigned char msg[1] = {
+ 0x0b
+ };
+
+ gprs_process_message(nsi, "ALIVE_ACK", src_addr, msg, sizeof(msg));
+}
+
+static void send_ns_unblock(struct gprs_ns_inst *nsi, struct sockaddr_in *src_addr)
+{
+ /* GPRS Network Service, PDU type: NS_UNBLOCK */
+ unsigned char msg[1] = {
+ 0x06
+ };
+
+ gprs_process_message(nsi, "UNBLOCK", src_addr, msg, sizeof(msg));
+}
+
+static void send_ns_unblock_ack(struct gprs_ns_inst *nsi, struct sockaddr_in *src_addr)
+{
+ /* GPRS Network Service, PDU type: NS_UNBLOCK_ACK */
+ unsigned char msg[1] = {
+ 0x07
+ };
+
+ gprs_process_message(nsi, "UNBLOCK_ACK", src_addr, msg, sizeof(msg));
+}
+
+static void send_ns_unitdata(struct gprs_ns_inst *nsi, const char *text,
+ struct sockaddr_in *src_addr, uint16_t nsbvci,
+ const unsigned char *bssgp_msg, size_t bssgp_msg_size)
+{
+ /* GPRS Network Service, PDU type: NS_UNITDATA */
+ unsigned char msg[4096] = {
+ 0x00, 0x00, 0x00, 0x00
+ };
+
+ OSMO_ASSERT(bssgp_msg_size <= sizeof(msg) - 4);
+
+ msg[2] = nsbvci / 256;
+ msg[3] = nsbvci % 256;
+ memcpy(msg + 4, bssgp_msg, bssgp_msg_size);
+
+ gprs_process_message(nsi, text ? text : "UNITDATA", src_addr, msg, bssgp_msg_size + 4);
+}
+
+static void send_bssgp_ul_unitdata(
+ struct gprs_ns_inst *nsi, const char *text,
+ struct sockaddr_in *src_addr, uint16_t nsbvci, uint32_t tlli,
+ struct gprs_ra_id *raid, uint16_t cell_id,
+ const uint8_t *llc_msg, size_t llc_msg_size)
+{
+ /* GPRS Network Service, PDU type: NS_UNITDATA */
+ /* Base Station Subsystem GPRS Protocol: UL_UNITDATA */
+ unsigned char msg[4096] = {
+ 0x01, /* TLLI */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
+ 0x08, 0x88, /* RAI */ 0x11, 0x22, 0x33, 0x40, 0x50, 0x60,
+ /* CELL ID */ 0x00, 0x00, 0x00, 0x80, 0x0e, /* LLC LEN */ 0x00, 0x00,
+ };
+
+ size_t bssgp_msg_size = 23 + llc_msg_size;
+
+ OSMO_ASSERT(bssgp_msg_size <= sizeof(msg));
+
+ gsm48_construct_ra(msg + 10, raid);
+ msg[1] = (uint8_t)(tlli >> 24);
+ msg[2] = (uint8_t)(tlli >> 16);
+ msg[3] = (uint8_t)(tlli >> 8);
+ msg[4] = (uint8_t)(tlli >> 0);
+ msg[16] = cell_id / 256;
+ msg[17] = cell_id % 256;
+ msg[21] = llc_msg_size / 256;
+ msg[22] = llc_msg_size % 256;
+ memcpy(msg + 23, llc_msg, llc_msg_size);
+
+ send_ns_unitdata(nsi, text ? text : "BSSGP UL UNITDATA",
+ src_addr, nsbvci, msg, bssgp_msg_size);
+}
+
+static void send_bssgp_dl_unitdata(
+ struct gprs_ns_inst *nsi, const char *text,
+ struct sockaddr_in *src_addr, uint16_t nsbvci, uint32_t tlli,
+ int with_racap_drx, const uint8_t *imsi, size_t imsi_size,
+ const uint8_t *llc_msg, size_t llc_msg_size)
+{
+ /* Base Station Subsystem GPRS Protocol: DL_UNITDATA */
+ unsigned char msg[4096] = {
+ 0x00, /* TLLI */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x20,
+ 0x16, 0x82, 0x02, 0x58,
+ };
+ unsigned char racap_drx[] = {
+ 0x13, 0x99, 0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96,
+ 0x62, 0x00, 0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62,
+ 0x00, 0x60, 0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00,
+ 0x60, 0x80, 0x00, 0x0a, 0x82, 0x08, 0x02
+ };
+
+ size_t bssgp_msg_size = 0;
+
+ OSMO_ASSERT(51 + imsi_size + llc_msg_size <= sizeof(msg));
+
+ msg[1] = (uint8_t)(tlli >> 24);
+ msg[2] = (uint8_t)(tlli >> 16);
+ msg[3] = (uint8_t)(tlli >> 8);
+ msg[4] = (uint8_t)(tlli >> 0);
+
+ bssgp_msg_size = 12;
+
+ if (with_racap_drx) {
+ memcpy(msg + bssgp_msg_size, racap_drx, sizeof(racap_drx));
+ bssgp_msg_size += sizeof(racap_drx);
+ }
+
+ if (imsi) {
+ OSMO_ASSERT(imsi_size <= 127);
+ msg[bssgp_msg_size] = BSSGP_IE_IMSI;
+ msg[bssgp_msg_size + 1] = 0x80 | imsi_size;
+ memcpy(msg + bssgp_msg_size + 2, imsi, imsi_size);
+ bssgp_msg_size += 2 + imsi_size;
+ }
+
+ if ((bssgp_msg_size % 4) != 0) {
+ size_t abytes = (4 - (bssgp_msg_size + 2) % 4) % 4;
+ msg[bssgp_msg_size] = BSSGP_IE_ALIGNMENT;
+ msg[bssgp_msg_size + 1] = 0x80 | abytes;
+ memset(msg + bssgp_msg_size + 2, 0, abytes);
+ bssgp_msg_size += 2 + abytes;
+ }
+
+ msg[bssgp_msg_size] = BSSGP_IE_LLC_PDU;
+ if (llc_msg_size < 128) {
+ msg[bssgp_msg_size + 1] = 0x80 | llc_msg_size;
+ bssgp_msg_size += 2;
+ } else {
+ msg[bssgp_msg_size + 1] = llc_msg_size / 256;
+ msg[bssgp_msg_size + 2] = llc_msg_size % 256;
+ bssgp_msg_size += 3;
+ }
+ memcpy(msg + bssgp_msg_size, llc_msg, llc_msg_size);
+ bssgp_msg_size += llc_msg_size;
+
+
+ send_ns_unitdata(nsi, text ? text : "BSSGP DL UNITDATA",
+ src_addr, nsbvci, msg, bssgp_msg_size);
+}
+
+static void send_bssgp_reset(struct gprs_ns_inst *nsi, struct sockaddr_in *src_addr,
+ uint16_t bvci)
+{
+ /* GPRS Network Service, PDU type: NS_UNITDATA, BVCI 0
+ * BSSGP RESET */
+ unsigned char msg[18] = {
+ 0x22, 0x04, 0x82, 0x4a,
+ 0x2e, 0x07, 0x81, 0x08, 0x08, 0x88, 0x11, 0x22,
+ 0x33, 0x40, 0x50, 0x60, 0x10, 0x00
+ };
+
+ msg[3] = bvci / 256;
+ msg[4] = bvci % 256;
+
+ send_ns_unitdata(nsi, "BVC_RESET", src_addr, 0, msg, sizeof(msg));
+}
+
+static void send_bssgp_reset_ack(struct gprs_ns_inst *nsi,
+ struct sockaddr_in *src_addr, uint16_t bvci)
+{
+ /* GPRS Network Service, PDU type: NS_UNITDATA, BVCI 0
+ * BSSGP RESET_ACK */
+ static unsigned char msg[5] = {
+ 0x23, 0x04, 0x82, 0x00,
+ 0x00
+ };
+
+ msg[3] = bvci / 256;
+ msg[4] = bvci % 256;
+
+ send_ns_unitdata(nsi, "BVC_RESET_ACK", src_addr, 0, msg, sizeof(msg));
+}
+
+static void send_bssgp_suspend(struct gprs_ns_inst *nsi,
+ struct sockaddr_in *src_addr,
+ uint32_t tlli,
+ struct gprs_ra_id *raid)
+{
+ /* Base Station Subsystem GPRS Protocol, BSSGP SUSPEND */
+ unsigned char msg[15] = {
+ 0x0b, 0x1f, 0x84, /* TLLI */ 0xff, 0xff, 0xff, 0xff, 0x1b,
+ 0x86, /* RAI */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+ };
+
+ msg[3] = (uint8_t)(tlli >> 24);
+ msg[4] = (uint8_t)(tlli >> 16);
+ msg[5] = (uint8_t)(tlli >> 8);
+ msg[6] = (uint8_t)(tlli >> 0);
+
+ gsm48_construct_ra(msg + 9, raid);
+
+ send_ns_unitdata(nsi, "BVC_SUSPEND", src_addr, 0, msg, sizeof(msg));
+}
+
+static void send_bssgp_suspend_ack(struct gprs_ns_inst *nsi,
+ struct sockaddr_in *src_addr,
+ uint32_t tlli,
+ struct gprs_ra_id *raid)
+{
+ /* Base Station Subsystem GPRS Protocol, BSSGP SUSPEND ACK */
+ unsigned char msg[18] = {
+ 0x0c, 0x1f, 0x84, /* TLLI */ 0xff, 0xff, 0xff, 0xff, 0x1b,
+ 0x86, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1d,
+ 0x81, 0x01
+ };
+
+ msg[3] = (uint8_t)(tlli >> 24);
+ msg[4] = (uint8_t)(tlli >> 16);
+ msg[5] = (uint8_t)(tlli >> 8);
+ msg[6] = (uint8_t)(tlli >> 0);
+
+ gsm48_construct_ra(msg + 9, raid);
+
+ send_ns_unitdata(nsi, "BVC_SUSPEND_ACK", src_addr, 0, msg, sizeof(msg));
+}
+
+static void send_bssgp_llc_discarded(struct gprs_ns_inst *nsi,
+ struct sockaddr_in *src_addr,
+ uint16_t bvci, uint32_t tlli,
+ unsigned n_frames, unsigned n_octets)
+{
+ /* Base Station Subsystem GPRS Protocol: LLC-DISCARDED (0x2c) */
+ unsigned char msg[] = {
+ 0x2c, 0x1f, 0x84, /* TLLI */ 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0x81, /* n frames */ 0xff, 0x04, 0x82, /* BVCI */ 0xff, 0xff, 0x25, 0x83,
+ /* n octets */ 0xff, 0xff, 0xff
+ };
+
+ msg[3] = (uint8_t)(tlli >> 24);
+ msg[4] = (uint8_t)(tlli >> 16);
+ msg[5] = (uint8_t)(tlli >> 8);
+ msg[6] = (uint8_t)(tlli >> 0);
+ msg[9] = (uint8_t)(n_frames);
+ msg[12] = (uint8_t)(bvci >> 8);
+ msg[13] = (uint8_t)(bvci >> 0);
+ msg[16] = (uint8_t)(n_octets >> 16);
+ msg[17] = (uint8_t)(n_octets >> 8);
+ msg[18] = (uint8_t)(n_octets >> 0);
+
+ send_ns_unitdata(nsi, "LLC_DISCARDED", src_addr, 0, msg, sizeof(msg));
+}
+
+static void send_bssgp_paging(struct gprs_ns_inst *nsi,
+ struct sockaddr_in *src_addr,
+ const uint8_t *imsi, size_t imsi_size,
+ struct gprs_ra_id *raid, uint32_t ptmsi)
+{
+ /* Base Station Subsystem GPRS Protocol, BSSGP SUSPEND */
+ unsigned char msg[100] = {
+ 0x06,
+ };
+
+ const unsigned char drx_ie[] = {0x0a, 0x82, 0x07, 0x04};
+ const unsigned char qos_ie[] = {0x18, 0x83, 0x00, 0x00, 0x00};
+
+ size_t bssgp_msg_size = 1;
+
+ if (imsi) {
+ OSMO_ASSERT(imsi_size <= 127);
+ msg[bssgp_msg_size] = BSSGP_IE_IMSI;
+ msg[bssgp_msg_size + 1] = 0x80 | imsi_size;
+ memcpy(msg + bssgp_msg_size + 2, imsi, imsi_size);
+ bssgp_msg_size += 2 + imsi_size;
+ }
+
+ memcpy(msg + bssgp_msg_size, drx_ie, sizeof(drx_ie));
+ bssgp_msg_size += sizeof(drx_ie);
+
+ if (raid) {
+ msg[bssgp_msg_size] = BSSGP_IE_ROUTEING_AREA;
+ msg[bssgp_msg_size+1] = 0x86;
+ gsm48_construct_ra(msg + bssgp_msg_size + 2, raid);
+ bssgp_msg_size += 8;
+ }
+
+ memcpy(msg + bssgp_msg_size, qos_ie, sizeof(qos_ie));
+ bssgp_msg_size += sizeof(qos_ie);
+
+ if (ptmsi != GSM_RESERVED_TMSI) {
+ const uint32_t ptmsi_be = htonl(ptmsi);
+ msg[bssgp_msg_size] = BSSGP_IE_TMSI;
+ msg[bssgp_msg_size+1] = 0x84;
+ memcpy(msg + bssgp_msg_size + 2, &ptmsi_be, 4);
+ bssgp_msg_size += 6;
+ }
+
+ send_ns_unitdata(nsi, "PAGING_PS", src_addr, 0, msg, bssgp_msg_size);
+}
+
+static void send_bssgp_flow_control_bvc(struct gprs_ns_inst *nsi,
+ struct sockaddr_in *src_addr,
+ uint16_t bvci, uint8_t tag)
+{
+ /* GPRS Network Service, PDU type: NS_UNITDATA,
+ * BSSGP FLOW_CONTROL_BVC */
+ unsigned char msg[] = {
+ 0x26, 0x1e, 0x81, /* Tag */ 0xff, 0x05, 0x82, 0x01, 0xdc,
+ 0x03, 0x82, 0x02, 0x76, 0x01, 0x82, 0x00, 0x50,
+ 0x1c, 0x82, 0x02, 0x58, 0x06, 0x82, 0x00, 0x03
+ };
+
+ msg[3] = tag;
+
+ send_ns_unitdata(nsi, "FLOW_CONTROL_BVC", src_addr, bvci,
+ msg, sizeof(msg));
+}
+
+static void send_bssgp_flow_control_bvc_ack(struct gprs_ns_inst *nsi,
+ struct sockaddr_in *src_addr,
+ uint16_t bvci, uint8_t tag)
+{
+ /* GPRS Network Service, PDU type: NS_UNITDATA,
+ * BSSGP FLOW_CONTROL_BVC_ACK */
+ unsigned char msg[] = {
+ 0x27, 0x1e, 0x81, /* Tag */ 0xce
+ };
+
+ msg[3] = tag;
+
+ send_ns_unitdata(nsi, "FLOW_CONTROL_BVC_ACK", src_addr, bvci,
+ msg, sizeof(msg));
+}
+
+static void send_llc_ul_ui(
+ struct gprs_ns_inst *nsi, const char *text,
+ struct sockaddr_in *src_addr, uint16_t nsbvci, uint32_t tlli,
+ struct gprs_ra_id *raid, uint16_t cell_id,
+ unsigned sapi, unsigned nu,
+ const uint8_t *msg, size_t msg_size)
+{
+ unsigned char llc_msg[4096] = {
+ 0x00, 0xc0, 0x01
+ };
+
+ size_t llc_msg_size = 3 + msg_size + 3;
+ uint8_t e_bit = 0;
+ uint8_t pm_bit = 1;
+ unsigned fcs;
+
+ nu &= 0x01ff;
+
+ OSMO_ASSERT(llc_msg_size <= sizeof(llc_msg));
+
+ llc_msg[0] = (sapi & 0x0f);
+ llc_msg[1] = 0xc0 | (nu >> 6); /* UI frame */
+ llc_msg[2] = (nu << 2) | ((e_bit & 1) << 1) | (pm_bit & 1);
+
+ memcpy(llc_msg + 3, msg, msg_size);
+
+ fcs = gprs_llc_fcs(llc_msg, msg_size + 3);
+ llc_msg[3 + msg_size + 0] = (uint8_t)(fcs >> 0);
+ llc_msg[3 + msg_size + 1] = (uint8_t)(fcs >> 8);
+ llc_msg[3 + msg_size + 2] = (uint8_t)(fcs >> 16);
+
+ send_bssgp_ul_unitdata(nsi, text ? text : "LLC UI",
+ src_addr, nsbvci, tlli, raid, cell_id,
+ llc_msg, llc_msg_size);
+}
+
+static void send_llc_dl_ui(
+ struct gprs_ns_inst *nsi, const char *text,
+ struct sockaddr_in *src_addr, uint16_t nsbvci, uint32_t tlli,
+ int with_racap_drx, const uint8_t *imsi, size_t imsi_size,
+ unsigned sapi, unsigned nu,
+ const uint8_t *msg, size_t msg_size)
+{
+ /* GPRS Network Service, PDU type: NS_UNITDATA */
+ /* Base Station Subsystem GPRS Protocol: UL_UNITDATA */
+ unsigned char llc_msg[4096] = {
+ 0x00, 0x00, 0x01
+ };
+
+ size_t llc_msg_size = 3 + msg_size + 3;
+ uint8_t e_bit = 0;
+ uint8_t pm_bit = 1;
+ unsigned fcs;
+
+ nu &= 0x01ff;
+
+ OSMO_ASSERT(llc_msg_size <= sizeof(llc_msg));
+
+ llc_msg[0] = 0x40 | (sapi & 0x0f);
+ llc_msg[1] = 0xc0 | (nu >> 6); /* UI frame */
+ llc_msg[2] = (nu << 2) | ((e_bit & 1) << 1) | (pm_bit & 1);
+
+ memcpy(llc_msg + 3, msg, msg_size);
+
+ fcs = gprs_llc_fcs(llc_msg, msg_size + 3);
+ llc_msg[3 + msg_size + 0] = (uint8_t)(fcs >> 0);
+ llc_msg[3 + msg_size + 1] = (uint8_t)(fcs >> 8);
+ llc_msg[3 + msg_size + 2] = (uint8_t)(fcs >> 16);
+
+ send_bssgp_dl_unitdata(nsi, text ? text : "LLC UI",
+ src_addr, nsbvci, tlli,
+ with_racap_drx, imsi, imsi_size,
+ llc_msg, llc_msg_size);
+}
+
+
+static void setup_ns(struct gprs_ns_inst *nsi, struct sockaddr_in *src_addr,
+ uint16_t nsvci, uint16_t nsei)
+{
+ printf("Setup NS-VC: remote 0x%08x:%d, "
+ "NSVCI 0x%04x(%d), NSEI 0x%04x(%d)\n\n",
+ ntohl(src_addr->sin_addr.s_addr), ntohs(src_addr->sin_port),
+ nsvci, nsvci, nsei, nsei);
+
+ send_ns_reset(nsi, src_addr, NS_CAUSE_OM_INTERVENTION, nsvci, nsei);
+ send_ns_alive(nsi, src_addr);
+ send_ns_unblock(nsi, src_addr);
+ send_ns_alive_ack(nsi, src_addr);
+}
+
+static void setup_bssgp(struct gprs_ns_inst *nsi, struct sockaddr_in *src_addr,
+ uint16_t bvci)
+{
+ printf("Setup BSSGP: remote 0x%08x:%d, "
+ "BVCI 0x%04x(%d)\n\n",
+ ntohl(src_addr->sin_addr.s_addr), ntohs(src_addr->sin_port),
+ bvci, bvci);
+
+ send_bssgp_reset(nsi, src_addr, bvci);
+}
+
+static void connect_sgsn(struct gprs_ns_inst *nsi, struct sockaddr_in *sgsn_peer,
+ uint32_t sgsn_nsei)
+{
+ gprs_ns_nsip_connect(nsi, sgsn_peer, sgsn_nsei, sgsn_nsei+1);
+ send_ns_reset_ack(nsi, sgsn_peer, sgsn_nsei+1, sgsn_nsei);
+ send_ns_alive_ack(nsi, sgsn_peer);
+ send_ns_unblock_ack(nsi, sgsn_peer);
+ send_ns_alive(nsi, sgsn_peer);
+}
+
+static void configure_sgsn_peer(struct sockaddr_in *sgsn_peer)
+{
+ sgsn_peer->sin_family = AF_INET;
+ sgsn_peer->sin_port = htons(32000);
+ sgsn_peer->sin_addr.s_addr = htonl(REMOTE_SGSN_ADDR);
+}
+
+static void configure_sgsn2_peer(struct sockaddr_in *sgsn_peer)
+{
+ sgsn_peer->sin_family = AF_INET;
+ sgsn_peer->sin_port = htons(32001);
+ sgsn_peer->sin_addr.s_addr = htonl(REMOTE_SGSN2_ADDR);
+}
+
+static void configure_bss_peers(struct sockaddr_in *bss_peers, size_t size)
+{
+ size_t i;
+
+ for (i = 0; i < size; ++i) {
+ bss_peers[i].sin_family = AF_INET;
+ bss_peers[i].sin_port = htons((i + 1) * 1111);
+ bss_peers[i].sin_addr.s_addr = htonl(REMOTE_BSS_ADDR);
+ }
+}
+
+int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg,
+ struct sockaddr_in *saddr, enum gprs_ns_ll ll);
+
+/* override */
+int gprs_ns_callback(enum gprs_ns_evt event, struct gprs_nsvc *nsvc,
+ struct msgb *msg, uint16_t bvci)
+{
+ printf("CALLBACK, event %d, msg length %zu, bvci 0x%04x\n%s\n\n",
+ event, msgb_bssgp_len(msg), bvci,
+ osmo_hexdump(msgb_l2(msg), msgb_l2len(msg)));
+
+ switch (event) {
+ case GPRS_NS_EVT_UNIT_DATA:
+ return gbprox_rcvmsg(&gbcfg, msg, nsvc->nsei, bvci, nsvc->nsvci);
+ default:
+ break;
+ }
+ return 0;
+}
+
+/* override */
+ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
+ const struct sockaddr *dest_addr, socklen_t addrlen)
+{
+ typedef ssize_t (*sendto_t)(int, const void *, size_t, int,
+ const struct sockaddr *, socklen_t);
+ static sendto_t real_sendto = NULL;
+ uint32_t dest_host = htonl(((struct sockaddr_in *)dest_addr)->sin_addr.s_addr);
+ int dest_port = htons(((struct sockaddr_in *)dest_addr)->sin_port);
+
+ if (!real_sendto)
+ real_sendto = dlsym(RTLD_NEXT, "sendto");
+
+ if (dest_host == REMOTE_BSS_ADDR)
+ printf("MESSAGE to BSS at 0x%08x:%d, msg length %zu\n%s\n\n",
+ dest_host, dest_port,
+ len, osmo_hexdump(buf, len));
+ else if (dest_host == REMOTE_SGSN_ADDR)
+ printf("MESSAGE to SGSN at 0x%08x:%d, msg length %zu\n%s\n\n",
+ dest_host, dest_port,
+ len, osmo_hexdump(buf, len));
+ else if (dest_host == REMOTE_SGSN2_ADDR)
+ printf("MESSAGE to SGSN 2 at 0x%08x:%d, msg length %zu\n%s\n\n",
+ dest_host, dest_port,
+ len, osmo_hexdump(buf, len));
+ else
+ return real_sendto(sockfd, buf, len, flags, dest_addr, addrlen);
+
+ return len;
+}
+
+/* override */
+int gprs_ns_sendmsg(struct gprs_ns_inst *nsi, struct msgb *msg)
+{
+ typedef int (*gprs_ns_sendmsg_t)(struct gprs_ns_inst *nsi, struct msgb *msg);
+ static gprs_ns_sendmsg_t real_gprs_ns_sendmsg = NULL;
+ uint16_t bvci = msgb_bvci(msg);
+ uint16_t nsei = msgb_nsei(msg);
+
+ size_t len = msgb_length(msg);
+
+ if (!real_gprs_ns_sendmsg)
+ real_gprs_ns_sendmsg = dlsym(RTLD_NEXT, "gprs_ns_sendmsg");
+
+ if (nsei == SGSN_NSEI)
+ printf("NS UNITDATA MESSAGE to SGSN, BVCI 0x%04x, "
+ "msg length %zu (%s)\n",
+ bvci, len, __func__);
+ else if (nsei == SGSN2_NSEI)
+ printf("NS UNITDATA MESSAGE to SGSN 2, BVCI 0x%04x, "
+ "msg length %zu (%s)\n",
+ bvci, len, __func__);
+ else
+ printf("NS UNITDATA MESSAGE to BSS, BVCI 0x%04x, "
+ "msg length %zu (%s)\n",
+ bvci, len, __func__);
+
+ if (received_messages) {
+ struct msgb *msg_copy;
+ msg_copy = gprs_msgb_copy(msg, "received_messages");
+ llist_add_tail(&msg_copy->list, received_messages);
+ }
+
+ return real_gprs_ns_sendmsg(nsi, msg);
+}
+
+/* Get the next message from the receive FIFO
+ *
+ * \returns a pointer to the message which will be invalidated at the next call
+ * to expect_msg. Returns NULL, if there is no message left.
+ */
+static struct msgb *expect_msg(void)
+{
+ static struct msgb *msg = NULL;
+
+ msgb_free(msg);
+ msg = NULL;
+
+ if (!received_messages)
+ return NULL;
+
+ if (llist_empty(received_messages))
+ return NULL;
+
+ msg = llist_entry(received_messages->next, struct msgb, list);
+ llist_del(&msg->list);
+
+ return msg;
+}
+
+struct expect_result {
+ struct msgb *msg;
+ struct gprs_gb_parse_context parse_ctx;
+};
+
+static struct expect_result *expect_bssgp_msg(
+ int match_nsei, int match_bvci, int match_pdu_type)
+{
+ static struct expect_result result;
+ static const struct expect_result empty_result = {0,};
+ static struct msgb *msg;
+ uint16_t nsei;
+ int rc;
+
+ memcpy(&result, &empty_result, sizeof(result));
+
+ msg = expect_msg();
+ if (!msg)
+ return NULL;
+
+ nsei = msgb_nsei(msg);
+
+ if (match_nsei != MATCH_ANY && match_nsei != nsei) {
+ fprintf(stderr, "%s: NSEI mismatch (expected %u, got %u)\n",
+ __func__, match_nsei, nsei);
+ return NULL;
+ }
+
+ if (match_bvci != MATCH_ANY && match_bvci != msgb_bvci(msg)) {
+ fprintf(stderr, "%s: BVCI mismatch (expected %u, got %u)\n",
+ __func__, match_bvci, msgb_bvci(msg));
+ return NULL;
+ }
+
+ result.msg = msg;
+
+ result.parse_ctx.to_bss = nsei != SGSN_NSEI && nsei != SGSN2_NSEI;
+ result.parse_ctx.peer_nsei = nsei;
+
+ if (!msgb_bssgph(msg)) {
+ fprintf(stderr, "%s: Expected BSSGP\n", __func__);
+ return NULL;
+ }
+
+ rc = gprs_gb_parse_bssgp(msgb_bssgph(msg), msgb_bssgp_len(msg),
+ &result.parse_ctx);
+
+ if (!rc) {
+ fprintf(stderr, "%s: Failed to parse message\n", __func__);
+ return NULL;
+ }
+
+ if (match_pdu_type != MATCH_ANY &&
+ match_pdu_type != result.parse_ctx.pdu_type) {
+ fprintf(stderr, "%s: PDU type mismatch (expected %u, got %u)\n",
+ __func__, match_pdu_type, result.parse_ctx.pdu_type);
+ return NULL;
+ }
+
+ return &result;
+}
+
+static struct expect_result *expect_llc_msg(
+ int match_nsei, int match_bvci, int match_sapi, int match_type)
+{
+ static struct expect_result *result;
+
+ result = expect_bssgp_msg(match_nsei, match_bvci, MATCH_ANY);
+ if (!result)
+ return NULL;
+
+ if (!result->parse_ctx.llc) {
+ fprintf(stderr, "%s: Expected LLC message\n", __func__);
+ return NULL;
+ }
+
+ if (match_sapi != MATCH_ANY &&
+ match_sapi != result->parse_ctx.llc_hdr_parsed.sapi) {
+ fprintf(stderr, "%s: LLC SAPI mismatch (expected %u, got %u)\n",
+ __func__, match_sapi, result->parse_ctx.llc_hdr_parsed.sapi);
+ return NULL;
+ }
+
+ if (match_type != MATCH_ANY &&
+ match_type != result->parse_ctx.llc_hdr_parsed.cmd) {
+ fprintf(stderr,
+ "%s: LLC command/type mismatch (expected %u, got %u)\n",
+ __func__, match_type, result->parse_ctx.llc_hdr_parsed.cmd);
+ return NULL;
+ }
+
+ return result;
+}
+
+static struct expect_result *expect_gmm_msg(int match_nsei, int match_bvci,
+ int match_type)
+{
+ static struct expect_result *result;
+
+ result = expect_llc_msg(match_nsei, match_bvci, GPRS_SAPI_GMM, GPRS_LLC_UI);
+ if (!result)
+ return NULL;
+
+ if (!result->parse_ctx.g48_hdr) {
+ fprintf(stderr, "%s: Expected GSM 04.08 message\n", __func__);
+ return NULL;
+ }
+
+ if (match_type != MATCH_ANY &&
+ match_type != result->parse_ctx.g48_hdr->msg_type) {
+ fprintf(stderr,
+ "%s: GSM 04.08 message type mismatch (expected %u, got %u)\n",
+ __func__, match_type, result->parse_ctx.g48_hdr->msg_type);
+ return NULL;
+ }
+
+ return result;
+}
+
+static void dump_rate_ctr_group(FILE *stream, const char *prefix,
+ struct rate_ctr_group *ctrg)
+{
+ unsigned int i;
+
+ for (i = 0; i < ctrg->desc->num_ctr; i++) {
+ struct rate_ctr *ctr = &ctrg->ctr[i];
+ if (ctr->current && !strchr(ctrg->desc->ctr_desc[i].name, '.'))
+ fprintf(stream, " %s%s: %llu%s",
+ prefix, ctrg->desc->ctr_desc[i].description,
+ (long long)ctr->current,
+ "\n");
+ };
+}
+
+/* Signal handler for signals from NS layer */
+static int test_signal(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct ns_signal_data *nssd = signal_data;
+ int rc;
+
+ if (subsys != SS_L_NS)
+ return 0;
+
+ switch (signal) {
+ case S_NS_RESET:
+ printf("==> got signal NS_RESET, NS-VC 0x%04x/%s\n",
+ nssd->nsvc->nsvci,
+ gprs_ns_ll_str(nssd->nsvc));
+ break;
+
+ case S_NS_ALIVE_EXP:
+ printf("==> got signal NS_ALIVE_EXP, NS-VC 0x%04x/%s\n",
+ nssd->nsvc->nsvci,
+ gprs_ns_ll_str(nssd->nsvc));
+ break;
+
+ case S_NS_BLOCK:
+ printf("==> got signal NS_BLOCK, NS-VC 0x%04x/%s\n",
+ nssd->nsvc->nsvci,
+ gprs_ns_ll_str(nssd->nsvc));
+ break;
+
+ case S_NS_UNBLOCK:
+ printf("==> got signal NS_UNBLOCK, NS-VC 0x%04x/%s\n",
+ nssd->nsvc->nsvci,
+ gprs_ns_ll_str(nssd->nsvc));
+ break;
+
+ case S_NS_REPLACED:
+ printf("==> got signal NS_REPLACED: 0x%04x/%s",
+ nssd->nsvc->nsvci,
+ gprs_ns_ll_str(nssd->nsvc));
+ printf(" -> 0x%04x/%s\n",
+ nssd->old_nsvc->nsvci,
+ gprs_ns_ll_str(nssd->old_nsvc));
+ break;
+
+ default:
+ printf("==> got signal %d, NS-VC 0x%04x/%s\n", signal,
+ nssd->nsvc->nsvci,
+ gprs_ns_ll_str(nssd->nsvc));
+ break;
+ }
+ printf("\n");
+ rc = gbprox_signal(subsys, signal, handler_data, signal_data);
+ return rc;
+}
+
+static int gprs_process_message(struct gprs_ns_inst *nsi, const char *text, struct sockaddr_in *peer, const unsigned char* data, size_t data_len)
+{
+ struct msgb *msg;
+ int ret;
+ if (data_len > NS_ALLOC_SIZE - NS_ALLOC_HEADROOM) {
+ fprintf(stderr, "message too long: %zu\n", data_len);
+ return -1;
+ }
+
+ msg = gprs_ns_msgb_alloc();
+ OSMO_ASSERT(msg);
+ memmove(msg->data, data, data_len);
+ msg->l2h = msg->data;
+ msgb_put(msg, data_len);
+
+ printf("PROCESSING %s from 0x%08x:%d\n%s\n\n",
+ text, ntohl(peer->sin_addr.s_addr), ntohs(peer->sin_port),
+ osmo_hexdump(data, data_len));
+
+ ret = gprs_ns_rcvmsg(nsi, msg, peer, GPRS_NS_LL_UDP);
+
+ printf("result (%s) = %d\n\n", text, ret);
+
+ msgb_free(msg);
+
+ return ret;
+}
+
+static void gprs_dump_nsi(struct gprs_ns_inst *nsi)
+{
+ struct gprs_nsvc *nsvc;
+
+ printf("Current NS-VCIs:\n");
+ llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) {
+ struct sockaddr_in *peer = &(nsvc->ip.bts_addr);
+ printf(" VCI 0x%04x, NSEI 0x%04x, peer 0x%08x:%d%s%s\n",
+ nsvc->nsvci, nsvc->nsei,
+ ntohl(peer->sin_addr.s_addr), ntohs(peer->sin_port),
+ nsvc->state & NSE_S_BLOCKED ? ", blocked" : "",
+ nsvc->state & NSE_S_ALIVE ? "" : ", dead"
+ );
+ dump_rate_ctr_group(stdout, " ", nsvc->ctrg);
+ }
+ printf("\n");
+}
+
+static void test_gbproxy()
+{
+ struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+ struct sockaddr_in bss_peer[4] = {{0},};
+ struct sockaddr_in sgsn_peer= {0};
+
+ bssgp_nsi = nsi;
+ gbcfg.nsi = bssgp_nsi;
+ gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
+
+ configure_sgsn_peer(&sgsn_peer);
+ configure_bss_peers(bss_peer, ARRAY_SIZE(bss_peer));
+
+ printf("=== %s ===\n", __func__);
+ printf("--- Initialise SGSN ---\n\n");
+
+ connect_sgsn(nsi, &sgsn_peer, SGSN_NSEI);
+ gprs_dump_nsi(nsi);
+
+ printf("--- Initialise BSS 1 ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x1001, 0x1000);
+ setup_bssgp(nsi, &bss_peer[0], 0x1002);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1002);
+
+ printf("--- Initialise BSS 2 ---\n\n");
+
+ setup_ns(nsi, &bss_peer[1], 0x2001, 0x2000);
+ setup_bssgp(nsi, &bss_peer[1], 0x2002);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x2002);
+
+ printf("--- Move BSS 1 to new port ---\n\n");
+
+ setup_ns(nsi, &bss_peer[2], 0x1001, 0x1000);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Move BSS 2 to former BSS 1 port ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x2001, 0x2000);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Move BSS 1 to current BSS 2 port ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x2001, 0x2000);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Move BSS 2 to new port ---\n\n");
+
+ setup_ns(nsi, &bss_peer[3], 0x2001, 0x2000);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Move BSS 2 to former BSS 1 port ---\n\n");
+
+ setup_ns(nsi, &bss_peer[2], 0x2001, 0x2000);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Move BSS 1 to original BSS 1 port ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x1001, 0x1000);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Reset BSS 1 with a new BVCI ---\n\n");
+
+ setup_bssgp(nsi, &bss_peer[0], 0x1012);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1012);
+
+ printf("--- Reset BSS 1 with the old BVCI ---\n\n");
+
+ setup_bssgp(nsi, &bss_peer[0], 0x1002);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1002);
+
+ printf("--- Reset BSS 1 with the old BVCI again ---\n\n");
+
+ setup_bssgp(nsi, &bss_peer[0], 0x1002);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1002);
+
+ printf("--- Send message from BSS 1 to SGSN, BVCI 0x1012 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], 0x1012, (uint8_t *)"", 0);
+
+ printf("--- Send message from SGSN to BSS 1, BVCI 0x1012 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, 0x1012, (uint8_t *)"", 0);
+
+ printf("--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], 0x1012, (uint8_t *)"", 0);
+
+ printf("--- Send message from SGSN to BSS 1, BVCI 0x1002 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, 0x1012, (uint8_t *)"", 0);
+
+ printf("--- Send message from BSS 2 to SGSN, BVCI 0x2002 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], 0x2002, (uint8_t *)"", 0);
+
+ printf("--- Send message from SGSN to BSS 2, BVCI 0x2002 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, 0x2002, (uint8_t *)"", 0);
+
+ printf("--- Reset BSS 1 with the old BVCI on BSS2's link ---\n\n");
+
+ setup_bssgp(nsi, &bss_peer[2], 0x1002);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ dump_global(stdout, 0);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1002);
+
+ printf("--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], 0x1012, (uint8_t *)"", 0);
+
+ printf("--- Send message from SGSN to BSS 1, BVCI 0x1002 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, 0x1012, (uint8_t *)"", 0);
+
+ printf("--- Send message from SGSN to BSS 1, BVCI 0x10ff (invalid) ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, 0x10ff, (uint8_t *)"", 0);
+
+ /* Find peer */
+ OSMO_ASSERT(gbproxy_peer_by_bvci(&gbcfg, 0xeeee) == NULL);
+ OSMO_ASSERT(gbproxy_peer_by_bvci(&gbcfg, 0x1000) == NULL);
+ OSMO_ASSERT(gbproxy_peer_by_bvci(&gbcfg, 0x1012) != NULL);
+ OSMO_ASSERT(gbproxy_peer_by_nsei(&gbcfg, 0xeeee) == NULL);
+ OSMO_ASSERT(gbproxy_peer_by_nsei(&gbcfg, 0x1012) == NULL);
+ OSMO_ASSERT(gbproxy_peer_by_nsei(&gbcfg, 0x1000) != NULL);
+
+
+ /* Cleanup */
+ OSMO_ASSERT(gbproxy_cleanup_peers(&gbcfg, 0, 0) == 0);
+ OSMO_ASSERT(gbproxy_cleanup_peers(&gbcfg, 0x1000, 0xeeee) == 0);
+ OSMO_ASSERT(gbproxy_cleanup_peers(&gbcfg, 0, 0x1002) == 0);
+ OSMO_ASSERT(gbproxy_cleanup_peers(&gbcfg, 0x1000, 0x1012) == 1);
+ OSMO_ASSERT(gbproxy_cleanup_peers(&gbcfg, 0x1000, 0x1012) == 0);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ dump_global(stdout, 0);
+
+ gbprox_reset(&gbcfg);
+ gprs_ns_destroy(nsi);
+ nsi = NULL;
+}
+
+static void test_gbproxy_ident_changes()
+{
+ struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+ struct sockaddr_in bss_peer[1] = {{0},};
+ struct sockaddr_in sgsn_peer= {0};
+ uint16_t nsei[2] = {0x1000, 0x2000};
+ uint16_t nsvci[2] = {0x1001, 0x2001};
+ uint16_t bvci[4] = {0x1002, 0x2002, 0x3002, 0x4002};
+
+ bssgp_nsi = nsi;
+ gbcfg.nsi = bssgp_nsi;
+ gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
+
+ configure_sgsn_peer(&sgsn_peer);
+ configure_bss_peers(bss_peer, ARRAY_SIZE(bss_peer));
+
+ printf("=== %s ===\n", __func__);
+ printf("--- Initialise SGSN ---\n\n");
+
+ connect_sgsn(nsi, &sgsn_peer, SGSN_NSEI);
+ gprs_dump_nsi(nsi);
+
+ printf("--- Initialise BSS 1 ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], nsvci[0], nsei[0]);
+ gprs_dump_nsi(nsi);
+
+ printf("--- Setup BVCI 1 ---\n\n");
+
+ setup_bssgp(nsi, &bss_peer[0], bvci[0]);
+ send_bssgp_reset_ack(nsi, &sgsn_peer, bvci[0]);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Setup BVCI 2 ---\n\n");
+
+ setup_bssgp(nsi, &bss_peer[0], bvci[1]);
+ send_bssgp_reset_ack(nsi, &sgsn_peer, bvci[1]);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Send message from BSS 1 to SGSN and back, BVCI 1 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], bvci[0], (uint8_t *)"", 0);
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, bvci[0], (uint8_t *)"", 0);
+
+ printf("--- Send message from BSS 1 to SGSN and back, BVCI 2 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], bvci[1], (uint8_t *)"", 0);
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, bvci[1], (uint8_t *)"", 0);
+
+ printf("--- Change NSEI ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], nsvci[0], nsei[1]);
+ gprs_dump_nsi(nsi);
+
+ printf("--- Setup BVCI 1 ---\n\n");
+
+ setup_bssgp(nsi, &bss_peer[0], bvci[0]);
+ send_bssgp_reset_ack(nsi, &sgsn_peer, bvci[0]);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Setup BVCI 3 ---\n\n");
+
+ setup_bssgp(nsi, &bss_peer[0], bvci[2]);
+ send_bssgp_reset_ack(nsi, &sgsn_peer, bvci[2]);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Send message from BSS 1 to SGSN and back, BVCI 1 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], bvci[0], (uint8_t *)"", 0);
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, bvci[0], (uint8_t *)"", 0);
+
+ printf("--- Send message from BSS 1 to SGSN and back, BVCI 2 "
+ " (should fail) ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], bvci[1], (uint8_t *)"", 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, bvci[1], (uint8_t *)"", 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Send message from BSS 1 to SGSN and back, BVCI 3 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], bvci[2], (uint8_t *)"", 0);
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, bvci[2], (uint8_t *)"", 0);
+
+ printf("--- Change NSVCI ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], nsvci[1], nsei[1]);
+ gprs_dump_nsi(nsi);
+
+ printf("--- Setup BVCI 1 ---\n\n");
+
+ setup_bssgp(nsi, &bss_peer[0], bvci[0]);
+ send_bssgp_reset_ack(nsi, &sgsn_peer, bvci[0]);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Setup BVCI 4 ---\n\n");
+
+ setup_bssgp(nsi, &bss_peer[0], bvci[3]);
+ send_bssgp_reset_ack(nsi, &sgsn_peer, bvci[3]);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Send message from BSS 1 to SGSN and back, BVCI 1 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], bvci[0], (uint8_t *)"", 0);
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, bvci[0], (uint8_t *)"", 0);
+
+ printf("--- Send message from BSS 1 to SGSN and back, BVCI 2 "
+ " (should fail) ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], bvci[1], (uint8_t *)"", 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, bvci[1], (uint8_t *)"", 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Send message from BSS 1 to SGSN and back, BVCI 3 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], bvci[2], (uint8_t *)"", 0);
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, bvci[2], (uint8_t *)"", 0);
+
+ printf("--- Send message from BSS 1 to SGSN and back, BVCI 4 ---\n\n");
+
+ send_ns_unitdata(nsi, NULL, &bss_peer[0], bvci[3], (uint8_t *)"", 0);
+ send_ns_unitdata(nsi, NULL, &sgsn_peer, bvci[3], (uint8_t *)"", 0);
+
+ dump_global(stdout, 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ gbprox_reset(&gbcfg);
+ gprs_ns_destroy(nsi);
+ nsi = NULL;
+}
+
+static void test_gbproxy_ra_patching()
+{
+ struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+ struct sockaddr_in bss_peer[1] = {{0},};
+ struct sockaddr_in sgsn_peer= {0};
+ struct gprs_ra_id rai_bss =
+ {.mcc = 112, .mnc = 332, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_sgsn =
+ {.mcc = 123, .mnc = 456, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_unknown =
+ {.mcc = 1, .mnc = 99, .lac = 99, .rac = 96};
+ uint16_t cell_id = 0x7530;
+ const char *err_msg = NULL;
+ const uint32_t ptmsi = 0xefe2b700;
+ const uint32_t local_tlli = 0xefe2b700;
+ const uint32_t foreign_tlli = 0xbbc54679;
+ const uint32_t foreign_tlli2 = 0xbb00beef;
+ const uint8_t imsi[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18};
+ const char *patch_re = "^9898|^121314";
+ struct gbproxy_link_info *link_info;
+ struct gbproxy_peer *peer;
+ LLIST_HEAD(rcv_list);
+ struct expect_result *expect_res;
+
+ OSMO_ASSERT(local_tlli == gprs_tmsi2tlli(ptmsi, TLLI_LOCAL));
+
+ bssgp_nsi = nsi;
+ gbcfg.nsi = bssgp_nsi;
+ gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
+ gbcfg.core_mcc = 123;
+ gbcfg.core_mnc = 456;
+ gbcfg.core_apn = talloc_zero_size(NULL, 100);
+ gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
+ gbcfg.patch_ptmsi = 0;
+
+ configure_sgsn_peer(&sgsn_peer);
+ configure_bss_peers(bss_peer, ARRAY_SIZE(bss_peer));
+
+ if (gbproxy_set_patch_filter(&gbcfg.matches[GBPROX_MATCH_PATCHING],
+ patch_re, &err_msg) != 0) {
+ fprintf(stderr, "Failed to compile RE '%s': %s\n",
+ patch_re, err_msg);
+ exit(1);
+ }
+
+
+ printf("=== %s ===\n", __func__);
+ printf("--- Initialise SGSN ---\n\n");
+
+ connect_sgsn(nsi, &sgsn_peer, SGSN_NSEI);
+ gprs_dump_nsi(nsi);
+
+ printf("--- Initialise BSS 1 ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x1001, 0x1000);
+
+ received_messages = &rcv_list;
+
+ setup_bssgp(nsi, &bss_peer[0], 0x1002);
+ gprs_dump_nsi(nsi);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000);
+ OSMO_ASSERT(peer != NULL);
+
+ OSMO_ASSERT(expect_bssgp_msg(SGSN_NSEI, 0, BSSGP_PDUT_BVC_RESET));
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1002);
+
+ OSMO_ASSERT(expect_bssgp_msg(0x1000, 0, BSSGP_PDUT_BVC_RESET_ACK));
+
+ send_bssgp_suspend(nsi, &bss_peer[0], 0xccd1758b, &rai_bss);
+
+ OSMO_ASSERT(expect_bssgp_msg(SGSN_NSEI, 0, BSSGP_PDUT_SUSPEND));
+
+ send_bssgp_suspend_ack(nsi, &sgsn_peer, 0xccd1758b, &rai_sgsn);
+
+ OSMO_ASSERT(expect_bssgp_msg(0x1000, 0, BSSGP_PDUT_SUSPEND_ACK));
+
+ dump_global(stdout, 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(2 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+ OSMO_ASSERT(1 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_SGSN].current);
+
+ printf("--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---\n\n");
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, 0,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ OSMO_ASSERT(4 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ send_llc_dl_ui(nsi, "IDENT REQUEST", &sgsn_peer, 0x1002,
+ foreign_tlli, 0, NULL, 0,
+ GPRS_SAPI_GMM, 0,
+ dtap_identity_req, sizeof(dtap_identity_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ID_REQ));
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, 3,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ID_RESP));
+
+ OSMO_ASSERT(5 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+ OSMO_ASSERT(1 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_SGSN].current);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, 1,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ OSMO_ASSERT(2 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_SGSN].current);
+
+ OSMO_ASSERT(gbproxy_peer_by_rai(&gbcfg, convert_ra(&rai_bss)) != NULL);
+ OSMO_ASSERT(gbproxy_peer_by_rai(&gbcfg, convert_ra(&rai_sgsn)) == NULL);
+ OSMO_ASSERT(gbproxy_peer_by_rai(&gbcfg, convert_ra(&rai_unknown)) == NULL);
+
+ OSMO_ASSERT(gbproxy_peer_by_lai(&gbcfg, convert_ra(&rai_bss)) != NULL);
+ OSMO_ASSERT(gbproxy_peer_by_lai(&gbcfg, convert_ra(&rai_sgsn)) == NULL);
+ OSMO_ASSERT(gbproxy_peer_by_lai(&gbcfg, convert_ra(&rai_unknown)) == NULL);
+
+ OSMO_ASSERT(gbproxy_peer_by_lac(&gbcfg, convert_ra(&rai_bss)) != NULL);
+ OSMO_ASSERT(gbproxy_peer_by_lac(&gbcfg, convert_ra(&rai_sgsn)) != NULL);
+ OSMO_ASSERT(gbproxy_peer_by_lac(&gbcfg, convert_ra(&rai_unknown)) == NULL);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_tlli);
+ OSMO_ASSERT(link_info->tlli.current != local_tlli);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current != local_tlli);
+ OSMO_ASSERT(!link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, 4,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ OSMO_ASSERT(6 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_tlli);
+ OSMO_ASSERT(link_info->tlli.current != local_tlli);
+ OSMO_ASSERT(link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current != local_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+
+ /* Replace APN (1) */
+ send_llc_ul_ui(nsi, "ACT PDP CTX REQ (REPLACE APN)", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, 3,
+ dtap_act_pdp_ctx_req, sizeof(dtap_act_pdp_ctx_req));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GSM_ACT_PDP_REQ));
+
+ OSMO_ASSERT(7 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_tlli);
+ OSMO_ASSERT(link_info->tlli.current != local_tlli);
+ OSMO_ASSERT(link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current != local_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, 2,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_INFO));
+
+ OSMO_ASSERT(2 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_SGSN].current);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == 0);
+ OSMO_ASSERT(link_info->tlli.current == local_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == 0);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == local_tlli);
+
+ /* Replace APN (2) */
+ send_llc_ul_ui(nsi, "ACT PDP CTX REQ (REPLACE APN)", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, 3,
+ dtap_act_pdp_ctx_req, sizeof(dtap_act_pdp_ctx_req));
+
+ expect_res = expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GSM_ACT_PDP_REQ);
+ OSMO_ASSERT(expect_res != NULL);
+ OSMO_ASSERT(expect_res->parse_ctx.apn_ie_len == gbcfg.core_apn_size + 2);
+
+ OSMO_ASSERT(8 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+
+ gbcfg.core_apn[0] = 0;
+ gbcfg.core_apn_size = 0;
+
+ /* Remove APN */
+ send_llc_ul_ui(nsi, "ACT PDP CTX REQ (REMOVE APN)", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, 3,
+ dtap_act_pdp_ctx_req, sizeof(dtap_act_pdp_ctx_req));
+
+ expect_res = expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GSM_ACT_PDP_REQ);
+ OSMO_ASSERT(expect_res != NULL);
+ OSMO_ASSERT(expect_res->parse_ctx.apn_ie_len == 0);
+
+ OSMO_ASSERT(9 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Detach */
+ send_llc_ul_ui(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, 6,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_DETACH_REQ));
+
+ OSMO_ASSERT(10 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+ OSMO_ASSERT(2 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_SGSN].current);
+
+ send_llc_dl_ui(nsi, "DETACH ACC", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, 5,
+ dtap_detach_acc, sizeof(dtap_detach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_DETACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- RA update ---\n\n");
+
+ send_llc_ul_ui(nsi, "RA UPD REQ", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, 0x7080,
+ GPRS_SAPI_GMM, 5,
+ dtap_ra_upd_req, sizeof(dtap_ra_upd_req));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_RA_UPD_REQ));
+
+ OSMO_ASSERT(12 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+
+ send_llc_dl_ui(nsi, "RA UPD ACC", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, 6,
+ dtap_ra_upd_acc, sizeof(dtap_ra_upd_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_RA_UPD_ACK));
+
+ OSMO_ASSERT(3 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_SGSN].current);
+
+ /* Remove APN */
+ send_llc_ul_ui(nsi, "ACT PDP CTX REQ (REMOVE APN)", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, 3,
+ dtap_act_pdp_ctx_req, sizeof(dtap_act_pdp_ctx_req));
+
+ expect_res = expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GSM_ACT_PDP_REQ);
+ OSMO_ASSERT(expect_res != NULL);
+ OSMO_ASSERT(expect_res->parse_ctx.apn_ie_len == 0);
+
+ OSMO_ASSERT(13 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Detach (power off -> no Detach Accept) */
+ send_llc_ul_ui(nsi, "DETACH REQ (PWR OFF)", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, 6,
+ dtap_detach_po_req, sizeof(dtap_detach_po_req));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_DETACH_REQ));
+
+ OSMO_ASSERT(14 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+
+ dump_global(stdout, 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Bad cases ---\n\n");
+
+ /* The RAI in the Attach Request message differs from the RAI in the
+ * BSSGP message, only patch the latter */
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST (foreign RAI)", &bss_peer[0], 0x1002,
+ foreign_tlli2, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, 0,
+ dtap_attach_req2, sizeof(dtap_attach_req2));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ OSMO_ASSERT(15 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_BSS].current);
+
+ printf("TLLI is already detached, shouldn't patch\n");
+ send_llc_ul_ui(nsi, "ACT PDP CTX REQ", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, 3,
+ dtap_act_pdp_ctx_req, sizeof(dtap_act_pdp_ctx_req));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GSM_ACT_PDP_REQ));
+
+ printf("Invalid RAI, shouldn't patch\n");
+ send_bssgp_suspend_ack(nsi, &sgsn_peer, 0xccd1758b, &rai_unknown);
+
+ /* TODO: The following breaks with the current libosmocore, enable it
+ * again (and remove the plain expect_msg), when the msgb_bssgph patch
+ * is integrated */
+ /* OSMO_ASSERT(expect_bssgp_msg(SGSN_NSEI, 0, BSSGP_PDUT_STATUS)); */
+ OSMO_ASSERT(expect_msg());
+
+ dump_global(stdout, 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!expect_msg());
+ received_messages = NULL;
+
+ gbproxy_clear_patch_filter(&gbcfg.matches[GBPROX_MATCH_PATCHING]);
+ gbprox_reset(&gbcfg);
+ gprs_ns_destroy(nsi);
+ nsi = NULL;
+}
+
+static void test_gbproxy_ptmsi_assignment()
+{
+ struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+ struct sockaddr_in bss_peer[1] = {{0},};
+ struct sockaddr_in sgsn_peer= {0};
+ struct gprs_ra_id rai_bss =
+ {.mcc = 112, .mnc = 332, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_unknown =
+ {.mcc = 1, .mnc = 99, .lac = 99, .rac = 96};
+ uint16_t cell_id = 0x1234;
+
+ const uint32_t ptmsi = 0xefe2b700;
+ const uint32_t local_tlli = 0xefe2b700;
+
+ const uint32_t foreign_tlli1 = 0x8000dead;
+ const uint32_t foreign_tlli2 = 0x8000beef;
+
+ const uint8_t imsi1[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18};
+ const uint8_t imsi2[] = {0x11, 0x12, 0x99, 0x99, 0x99, 0x16, 0x17, 0x18};
+
+ struct gbproxy_link_info *link_info, *link_info2;
+ struct gbproxy_peer *peer;
+ unsigned bss_nu = 0;
+ unsigned sgsn_nu = 0;
+
+ OSMO_ASSERT(local_tlli == gprs_tmsi2tlli(ptmsi, TLLI_LOCAL));
+
+ bssgp_nsi = nsi;
+ gbcfg.nsi = bssgp_nsi;
+ gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
+ gbcfg.core_mcc = 0;
+ gbcfg.core_mnc = 0;
+ gbcfg.core_apn = talloc_zero_size(NULL, 100);
+ gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
+ gbcfg.patch_ptmsi = 0;
+
+ configure_sgsn_peer(&sgsn_peer);
+ configure_bss_peers(bss_peer, ARRAY_SIZE(bss_peer));
+
+ printf("=== %s ===\n", __func__);
+ printf("--- Initialise SGSN ---\n\n");
+
+ connect_sgsn(nsi, &sgsn_peer, SGSN_NSEI);
+
+ printf("--- Initialise BSS 1 ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x1001, 0x1000);
+ setup_bssgp(nsi, &bss_peer[0], 0x1002);
+
+ peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000);
+ OSMO_ASSERT(peer != NULL);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1002);
+
+ gprs_dump_nsi(nsi);
+ dump_global(stdout, 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Establish first LLC connection ---\n\n");
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli1, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "IDENT REQUEST", &sgsn_peer, 0x1002,
+ foreign_tlli1, 0, NULL, 0,
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_identity_req, sizeof(dtap_identity_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_tlli1, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli1, 1, imsi1, sizeof(imsi1),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli1);
+ link_info2 = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->tlli.assigned == local_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_tlli1);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == ptmsi);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_tlli1);
+ OSMO_ASSERT(link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == ptmsi);
+
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi1, sizeof(imsi1),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_imsi(peer, imsi1, ARRAY_SIZE(imsi1));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.ptmsi == ptmsi);
+ OSMO_ASSERT(!gbproxy_link_info_by_imsi(peer, imsi2, ARRAY_SIZE(imsi2)));
+
+ link_info2 = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->tlli.assigned == 0);
+ OSMO_ASSERT(link_info->tlli.current == local_tlli);
+ OSMO_ASSERT(link_info->tlli.ptmsi == ptmsi);
+
+ printf("--- Establish second LLC connection with the same P-TMSI ---\n\n");
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli2, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "IDENT REQUEST", &sgsn_peer, 0x1002,
+ foreign_tlli2, 0, NULL, 0,
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_identity_req, sizeof(dtap_identity_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_tlli2, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity2_resp, sizeof(dtap_identity2_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli2, 1, imsi2, sizeof(imsi2),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli2);
+ link_info2 = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->tlli.assigned == local_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_tlli2);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == ptmsi);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_tlli2);
+ OSMO_ASSERT(link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == ptmsi);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi2, sizeof(imsi2),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_imsi(peer, imsi2, ARRAY_SIZE(imsi2));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.ptmsi == ptmsi);
+ OSMO_ASSERT(!gbproxy_link_info_by_imsi(peer, imsi1, ARRAY_SIZE(imsi1)));
+
+ link_info2 = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->tlli.assigned == 0);
+ OSMO_ASSERT(link_info->tlli.current == local_tlli);
+ OSMO_ASSERT(link_info->tlli.ptmsi == ptmsi);
+
+ dump_global(stdout, 0);
+
+ gbprox_reset(&gbcfg);
+ gprs_ns_destroy(nsi);
+ nsi = NULL;
+
+ cleanup_test();
+}
+
+static void test_gbproxy_ptmsi_patching()
+{
+ struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+ struct sockaddr_in bss_peer[1] = {{0},};
+ struct sockaddr_in sgsn_peer= {0};
+ struct gprs_ra_id rai_bss =
+ {.mcc = 112, .mnc = 332, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_sgsn =
+ {.mcc = 123, .mnc = 456, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_wrong_mcc_sgsn =
+ {.mcc = 999, .mnc = 456, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_unknown =
+ {.mcc = 1, .mnc = 99, .lac = 99, .rac = 96};
+ uint16_t cell_id = 0x1234;
+
+ const uint32_t sgsn_ptmsi = 0xefe2b700;
+ const uint32_t sgsn_ptmsi2 = 0xe0987654;
+ const uint32_t sgsn_ptmsi3 = 0xe0543210;
+ const uint32_t local_sgsn_tlli = 0xefe2b700;
+ const uint32_t local_sgsn_tlli2 = 0xe0987654;
+ const uint32_t local_sgsn_tlli3 = 0xe0543210;
+ const uint32_t random_sgsn_tlli = 0x78dead00;
+ const uint32_t unknown_sgsn_tlli = 0xeebadbad;
+
+ const uint32_t bss_ptmsi = 0xc0dead01;
+ const uint32_t bss_ptmsi2 = 0xc0dead02;
+ const uint32_t bss_ptmsi3 = 0xc0dead03;
+ const uint32_t local_bss_tlli = 0xc0dead01;
+ const uint32_t local_bss_tlli2 = 0xc0dead02;
+ const uint32_t local_bss_tlli3 = 0xc0dead03;
+ const uint32_t foreign_bss_tlli = 0x8000dead;
+
+
+ const uint8_t imsi[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18};
+ struct gbproxy_link_info *link_info;
+ struct gbproxy_peer *peer;
+ unsigned bss_nu = 0;
+ unsigned sgsn_nu = 0;
+ int old_ctr;
+
+ OSMO_ASSERT(local_sgsn_tlli == gprs_tmsi2tlli(sgsn_ptmsi, TLLI_LOCAL));
+ OSMO_ASSERT(local_sgsn_tlli2 == gprs_tmsi2tlli(sgsn_ptmsi2, TLLI_LOCAL));
+ OSMO_ASSERT(local_sgsn_tlli3 == gprs_tmsi2tlli(sgsn_ptmsi3, TLLI_LOCAL));
+ OSMO_ASSERT(local_bss_tlli == gprs_tmsi2tlli(bss_ptmsi, TLLI_LOCAL));
+ OSMO_ASSERT(local_bss_tlli2 == gprs_tmsi2tlli(bss_ptmsi2, TLLI_LOCAL));
+ OSMO_ASSERT(local_bss_tlli3 == gprs_tmsi2tlli(bss_ptmsi3, TLLI_LOCAL));
+
+ bssgp_nsi = nsi;
+ gbcfg.nsi = bssgp_nsi;
+ gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
+ gbcfg.core_mcc = 123;
+ gbcfg.core_mnc = 456;
+ gbcfg.core_apn = talloc_zero_size(NULL, 100);
+ gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
+ gbcfg.patch_ptmsi = 1;
+
+ configure_sgsn_peer(&sgsn_peer);
+ configure_bss_peers(bss_peer, ARRAY_SIZE(bss_peer));
+
+ printf("=== %s ===\n", __func__);
+ printf("--- Initialise SGSN ---\n\n");
+
+ connect_sgsn(nsi, &sgsn_peer, SGSN_NSEI);
+
+ printf("--- Initialise BSS 1 ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x1001, 0x1000);
+ setup_bssgp(nsi, &bss_peer[0], 0x1002);
+
+ peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000);
+ OSMO_ASSERT(peer != NULL);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1002);
+
+ gprs_dump_nsi(nsi);
+ dump_global(stdout, 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---\n\n");
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "IDENT REQUEST", &sgsn_peer, 0x1002,
+ random_sgsn_tlli, 0, NULL, 0,
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_identity_req, sizeof(dtap_identity_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ random_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, random_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == bss_ptmsi);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli);
+ OSMO_ASSERT(!link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.ptmsi == sgsn_ptmsi);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.assigned == 0);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == 0);
+
+ send_llc_ul_ui(nsi, "ACT PDP CTX REQ (REPLACE APN)", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_act_pdp_ctx_req, sizeof(dtap_act_pdp_ctx_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Non-DTAP */
+ send_bssgp_ul_unitdata(nsi, "XID (UL)", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ llc_u_xid_ul, sizeof(llc_u_xid_ul));
+
+ send_bssgp_dl_unitdata(nsi, "XID (DL)", &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, imsi, sizeof(imsi),
+ llc_u_xid_dl, sizeof(llc_u_xid_dl));
+
+ send_bssgp_ul_unitdata(nsi, "LL11 DNS QUERY (UL)", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ llc_ui_ll11_dns_query_ul,
+ sizeof(llc_ui_ll11_dns_query_ul));
+
+ send_bssgp_dl_unitdata(nsi, "LL11 DNS RESP (DL)", &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, imsi, sizeof(imsi),
+ llc_ui_ll11_dns_resp_dl,
+ sizeof(llc_ui_ll11_dns_resp_dl));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Repeated RA Update Requests */
+ send_llc_ul_ui(nsi, "RA UPD REQ (P-TMSI 2)", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, 0x7080,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_ra_upd_req, sizeof(dtap_ra_upd_req));
+
+ send_llc_dl_ui(nsi, "RA UDP ACC (P-TMSI 2)", &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_ra_upd_acc2, sizeof(dtap_ra_upd_acc2));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli2, SGSN_NSEI) != NULL);
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli2);
+ OSMO_ASSERT(link_info->tlli.current == local_bss_tlli);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == bss_ptmsi2);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli2);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == local_sgsn_tlli);
+ OSMO_ASSERT(!link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.ptmsi == sgsn_ptmsi2);
+
+ send_llc_ul_ui(nsi, "RA UPD REQ (P-TMSI 3)", &bss_peer[0], 0x1002,
+ local_bss_tlli2, &rai_bss, 0x7080,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_ra_upd_req, sizeof(dtap_ra_upd_req));
+
+ send_llc_dl_ui(nsi, "RA UDP ACC (P-TMSI 3)", &sgsn_peer, 0x1002,
+ local_sgsn_tlli2, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_ra_upd_acc3, sizeof(dtap_ra_upd_acc3));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli2, SGSN_NSEI) == NULL);
+ OSMO_ASSERT(gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli3, SGSN_NSEI) != NULL);
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli3);
+ OSMO_ASSERT(link_info->tlli.current == local_bss_tlli);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == bss_ptmsi3);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli3);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == local_sgsn_tlli);
+ OSMO_ASSERT(!link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.ptmsi == sgsn_ptmsi3);
+
+ send_llc_ul_ui(nsi, "RA UPD COMPLETE", &bss_peer[0], 0x1002,
+ local_bss_tlli3, &rai_bss, 0x7080,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_ra_upd_complete, sizeof(dtap_ra_upd_complete));
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_bss_tlli3);
+
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ local_sgsn_tlli3, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli3, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == local_bss_tlli3);
+ OSMO_ASSERT(link_info->tlli.assigned == 0);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == local_sgsn_tlli3);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == 0);
+
+ /* Other messages */
+ send_bssgp_llc_discarded(nsi, &bss_peer[0], 0x1002,
+ local_bss_tlli3, 1, 12);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_suspend(nsi, &bss_peer[0], local_bss_tlli3, &rai_bss);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_suspend_ack(nsi, &sgsn_peer, local_sgsn_tlli3, &rai_sgsn);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ old_ctr = peer->ctrg->ctr[GBPROX_PEER_CTR_PTMSI_PATCHED_SGSN].current;
+
+ send_bssgp_paging(nsi, &sgsn_peer, imsi, sizeof(imsi), &rai_bss, sgsn_ptmsi3);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(old_ctr + 1 ==
+ peer->ctrg->ctr[GBPROX_PEER_CTR_PTMSI_PATCHED_SGSN].current);
+
+ /* Bad case: Invalid BVCI */
+ send_bssgp_llc_discarded(nsi, &bss_peer[0], 0xeee1,
+ local_bss_tlli3, 1, 12);
+ dump_global(stdout, 0);
+
+ /* Bad case: Invalid RAI */
+ send_bssgp_suspend_ack(nsi, &sgsn_peer, local_sgsn_tlli3, &rai_unknown);
+
+ dump_global(stdout, 0);
+
+ /* Bad case: Invalid MCC (LAC ok) */
+ send_bssgp_suspend_ack(nsi, &sgsn_peer, local_sgsn_tlli3,
+ &rai_wrong_mcc_sgsn);
+
+ dump_global(stdout, 0);
+
+ /* Bad case: Invalid TLLI from SGSN (IMSI unknown) */
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ unknown_sgsn_tlli, 1, NULL, 0,
+ GPRS_SAPI_GMM, 2,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ /* Bad case: Invalid TLLI from SGSN (IMSI known) */
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ unknown_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, 3,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ /* Detach */
+ send_llc_ul_ui(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ local_bss_tlli3, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "DETACH ACC", &sgsn_peer, 0x1002,
+ local_sgsn_tlli3, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_detach_acc, sizeof(dtap_detach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ dump_global(stdout, 0);
+
+ gbprox_reset(&gbcfg);
+ gprs_ns_destroy(nsi);
+ nsi = NULL;
+
+ cleanup_test();
+}
+
+static void test_gbproxy_ptmsi_patching_bad_cases()
+{
+ struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+ struct sockaddr_in bss_peer[1] = {{0},};
+ struct sockaddr_in sgsn_peer= {0};
+ struct gprs_ra_id rai_bss =
+ {.mcc = 112, .mnc = 332, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_unknown =
+ {.mcc = 1, .mnc = 99, .lac = 99, .rac = 96};
+ uint16_t cell_id = 0x1234;
+
+ const uint32_t sgsn_ptmsi = 0xefe2b700;
+ const uint32_t local_sgsn_tlli = 0xefe2b700;
+ const uint32_t random_sgsn_tlli = 0x78dead00;
+
+ const uint32_t bss_ptmsi = 0xc0dead01;
+ const uint32_t local_bss_tlli = 0xc0dead01;
+ const uint32_t foreign_bss_tlli = 0x8000dead;
+
+
+ const uint8_t imsi[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18};
+ struct gbproxy_link_info *link_info;
+ struct gbproxy_peer *peer;
+ unsigned bss_nu = 0;
+ unsigned sgsn_nu = 0;
+
+ OSMO_ASSERT(local_sgsn_tlli == gprs_tmsi2tlli(sgsn_ptmsi, TLLI_LOCAL));
+ OSMO_ASSERT(local_bss_tlli == gprs_tmsi2tlli(bss_ptmsi, TLLI_LOCAL));
+
+ bssgp_nsi = nsi;
+ gbcfg.nsi = bssgp_nsi;
+ gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
+ gbcfg.core_mcc = 123;
+ gbcfg.core_mnc = 456;
+ gbcfg.core_apn = talloc_zero_size(NULL, 100);
+ gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
+ gbcfg.patch_ptmsi = 1;
+
+ configure_sgsn_peer(&sgsn_peer);
+ configure_bss_peers(bss_peer, ARRAY_SIZE(bss_peer));
+
+ printf("=== %s ===\n", __func__);
+ printf("--- Initialise SGSN ---\n\n");
+
+ connect_sgsn(nsi, &sgsn_peer, SGSN_NSEI);
+
+ printf("--- Initialise BSS 1 ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x1001, 0x1000);
+ setup_bssgp(nsi, &bss_peer[0], 0x1002);
+
+ peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000);
+ OSMO_ASSERT(peer != NULL);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1002);
+
+ gprs_dump_nsi(nsi);
+ dump_global(stdout, 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---\n\n");
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "IDENT REQUEST", &sgsn_peer, 0x1002,
+ random_sgsn_tlli, 0, NULL, 0,
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_identity_req, sizeof(dtap_identity_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ random_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, random_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == bss_ptmsi);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli);
+ OSMO_ASSERT(!link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.ptmsi == sgsn_ptmsi);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT (duplicated)", &sgsn_peer, 0x1002,
+ random_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, random_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == bss_ptmsi);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli);
+ OSMO_ASSERT(!link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.ptmsi == sgsn_ptmsi);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.assigned == 0);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == 0);
+
+ /* Detach */
+ send_llc_ul_ui(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "DETACH ACC", &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_detach_acc, sizeof(dtap_detach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ dump_global(stdout, 0);
+
+ gbprox_reset(&gbcfg);
+ gprs_ns_destroy(nsi);
+ nsi = NULL;
+
+ cleanup_test();
+}
+
+
+static void test_gbproxy_imsi_acquisition()
+{
+ struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+ struct sockaddr_in bss_peer[1] = {{0},};
+ struct sockaddr_in sgsn_peer= {0};
+ struct gprs_ra_id rai_bss =
+ {.mcc = 112, .mnc = 332, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_sgsn =
+ {.mcc = 123, .mnc = 456, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_wrong_mcc_sgsn =
+ {.mcc = 999, .mnc = 456, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_unknown =
+ {.mcc = 1, .mnc = 99, .lac = 99, .rac = 96};
+ uint16_t cell_id = 0x1234;
+
+ const uint32_t sgsn_ptmsi = 0xefe2b700;
+ const uint32_t local_sgsn_tlli = 0xefe2b700;
+ const uint32_t random_sgsn_tlli = 0x78dead00;
+ const uint32_t random_sgsn_tlli2 = 0x78dead02;
+
+ const uint32_t bss_ptmsi = 0xc0dead01;
+ const uint32_t local_bss_tlli = 0xc0dead01;
+ const uint32_t foreign_bss_tlli = 0x8000dead;
+ const uint32_t other_bss_tlli = 0x8000beef;
+
+ const uint8_t imsi[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18};
+ struct gbproxy_link_info *link_info;
+ struct gbproxy_peer *peer;
+ unsigned bss_nu = 0;
+ unsigned sgsn_nu = 0;
+
+ OSMO_ASSERT(local_sgsn_tlli == gprs_tmsi2tlli(sgsn_ptmsi, TLLI_LOCAL));
+
+ bssgp_nsi = nsi;
+ gbcfg.nsi = bssgp_nsi;
+ gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
+ gbcfg.core_mcc = 123;
+ gbcfg.core_mnc = 456;
+ gbcfg.core_apn = talloc_zero_size(NULL, 100);
+ gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
+ gbcfg.patch_ptmsi = 1;
+ gbcfg.acquire_imsi = 1;
+
+ configure_sgsn_peer(&sgsn_peer);
+ configure_bss_peers(bss_peer, ARRAY_SIZE(bss_peer));
+
+ printf("=== %s ===\n", __func__);
+ printf("--- Initialise SGSN ---\n\n");
+
+ connect_sgsn(nsi, &sgsn_peer, SGSN_NSEI);
+
+ printf("--- Initialise BSS 1 ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x1001, 0x1000);
+ setup_bssgp(nsi, &bss_peer[0], 0x1002);
+
+ peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000);
+ OSMO_ASSERT(peer != NULL);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1002);
+
+ gprs_dump_nsi(nsi);
+ dump_global(stdout, 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---\n\n");
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "IDENT REQUEST", &sgsn_peer, 0x1002,
+ random_sgsn_tlli, 0, NULL, 0,
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_identity_req, sizeof(dtap_identity_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ random_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, random_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == bss_ptmsi);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli);
+ OSMO_ASSERT(!link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.ptmsi == sgsn_ptmsi);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.assigned == 0);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == 0);
+
+ /* Non-DTAP */
+ send_bssgp_ul_unitdata(nsi, "XID (UL)", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ llc_u_xid_ul, sizeof(llc_u_xid_ul));
+
+ send_bssgp_dl_unitdata(nsi, "XID (DL)", &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, imsi, sizeof(imsi),
+ llc_u_xid_dl, sizeof(llc_u_xid_dl));
+
+ send_bssgp_ul_unitdata(nsi, "LL11 DNS QUERY (UL)", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ llc_ui_ll11_dns_query_ul,
+ sizeof(llc_ui_ll11_dns_query_ul));
+
+ send_bssgp_dl_unitdata(nsi, "LL11 DNS RESP (DL)", &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, imsi, sizeof(imsi),
+ llc_ui_ll11_dns_resp_dl,
+ sizeof(llc_ui_ll11_dns_resp_dl));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Other messages */
+ send_bssgp_llc_discarded(nsi, &bss_peer[0], 0x1002,
+ local_bss_tlli, 1, 12);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_llc_discarded(nsi, &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, 12);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_suspend(nsi, &bss_peer[0], local_bss_tlli, &rai_bss);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_suspend_ack(nsi, &sgsn_peer, local_sgsn_tlli, &rai_sgsn);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Bad case: Invalid BVCI */
+ send_bssgp_llc_discarded(nsi, &bss_peer[0], 0xeee1,
+ local_bss_tlli, 1, 12);
+ dump_global(stdout, 0);
+
+ /* Bad case: Invalid RAI */
+ send_bssgp_suspend_ack(nsi, &sgsn_peer, local_sgsn_tlli, &rai_unknown);
+
+ dump_global(stdout, 0);
+
+ /* Bad case: Invalid MCC (LAC ok) */
+ send_bssgp_suspend_ack(nsi, &sgsn_peer, local_sgsn_tlli,
+ &rai_wrong_mcc_sgsn);
+
+ dump_global(stdout, 0);
+
+ /* Detach */
+ send_llc_ul_ui(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "DETACH ACC", &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_detach_acc, sizeof(dtap_detach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* RA Update request */
+
+ send_llc_ul_ui(nsi, "RA UPD REQ", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_unknown, 0x7080,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_ra_upd_req, sizeof(dtap_ra_upd_req));
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "RA UDP ACC", &sgsn_peer, 0x1002,
+ random_sgsn_tlli2, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_ra_upd_acc, sizeof(dtap_ra_upd_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Detach */
+
+ send_llc_ul_ui(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "DETACH ACC", &sgsn_peer, 0x1002,
+ local_sgsn_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_detach_acc, sizeof(dtap_detach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Special case: Repeated Attach Requests */
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ send_llc_ul_ui(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Special case: Detach from an unknown TLLI */
+
+ send_llc_ul_ui(nsi, "DETACH REQ (unknown TLLI)", &bss_peer[0], 0x1002,
+ other_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Special case: Repeated RA Update Requests */
+
+ send_llc_ul_ui(nsi, "RA UPD REQ", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_unknown, 0x7080,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_ra_upd_req, sizeof(dtap_ra_upd_req));
+
+ send_llc_ul_ui(nsi, "RA UPD REQ", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_unknown, 0x7080,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_ra_upd_req, sizeof(dtap_ra_upd_req));
+
+ send_llc_ul_ui(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ dump_global(stdout, 0);
+
+ gbprox_reset(&gbcfg);
+ gprs_ns_destroy(nsi);
+ nsi = NULL;
+
+ cleanup_test();
+}
+
+static void test_gbproxy_secondary_sgsn()
+{
+ struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+ struct sockaddr_in bss_peer[1] = {{0},};
+ struct sockaddr_in sgsn_peer[2]= {{0},};
+ struct gprs_ra_id rai_bss =
+ {.mcc = 112, .mnc = 332, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_sgsn =
+ {.mcc = 123, .mnc = 456, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_unknown =
+ {.mcc = 1, .mnc = 99, .lac = 99, .rac = 96};
+ uint16_t cell_id = 0x1234;
+
+ const uint32_t sgsn_ptmsi = 0xefe2b700;
+ const uint32_t local_sgsn_tlli = 0xefe2b700;
+ const uint32_t random_sgsn_tlli = 0x78dead00;
+
+ const uint32_t bss_ptmsi = 0xc0dead01;
+ const uint32_t local_bss_tlli = 0xc0dead01;
+ const uint32_t foreign_bss_tlli = 0x8000dead;
+
+ const uint32_t sgsn_ptmsi2 = 0xe0987654;
+ const uint32_t local_sgsn_tlli2 = 0xe0987654;
+ const uint32_t random_sgsn_tlli2 = 0x78dead02;
+ const uint32_t bss_ptmsi2 = 0xc0dead03;
+ const uint32_t local_bss_tlli2 = 0xc0dead03;
+ const uint32_t foreign_bss_tlli2 = 0x8000beef;
+
+ const uint32_t random_sgsn_tlli3 = 0x78dead04;
+ const uint32_t bss_ptmsi3 = 0xc0dead05;
+ const uint32_t local_bss_tlli3 = 0xc0dead05;
+ const uint32_t foreign_bss_tlli3 = 0x8000feed;
+
+ const uint8_t imsi1[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18};
+ const uint8_t imsi2[] = {0x11, 0x12, 0x99, 0x99, 0x99, 0x16, 0x17, 0x18};
+ const uint8_t imsi3[] = {0x11, 0x12, 0x99, 0x99, 0x99, 0x26, 0x27, 0x28};
+ struct gbproxy_link_info *link_info;
+ struct gbproxy_link_info *other_info;
+ struct gbproxy_peer *peer;
+ unsigned bss_nu = 0;
+ unsigned sgsn_nu = 0;
+
+ const char *err_msg = NULL;
+ const char *filter_re = "999999";
+
+ OSMO_ASSERT(local_sgsn_tlli == gprs_tmsi2tlli(sgsn_ptmsi, TLLI_LOCAL));
+ OSMO_ASSERT(local_sgsn_tlli2 == gprs_tmsi2tlli(sgsn_ptmsi2, TLLI_LOCAL));
+
+ bssgp_nsi = nsi;
+ gbcfg.nsi = bssgp_nsi;
+ gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
+ gbcfg.core_mcc = 123;
+ gbcfg.core_mnc = 456;
+ gbcfg.core_apn = talloc_zero_size(NULL, 100);
+ gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
+ gbcfg.patch_ptmsi = 1;
+ gbcfg.acquire_imsi = 1;
+
+ gbcfg.route_to_sgsn2 = 1;
+ gbcfg.nsip_sgsn2_nsei = SGSN2_NSEI;
+
+ if (gbproxy_set_patch_filter(&gbcfg.matches[GBPROX_MATCH_ROUTING],
+ filter_re, &err_msg) != 0) {
+ fprintf(stderr, "gbprox_set_patch_filter: got error: %s\n",
+ err_msg);
+ OSMO_ASSERT(err_msg == NULL);
+ }
+
+ configure_sgsn_peer(&sgsn_peer[0]);
+ configure_sgsn2_peer(&sgsn_peer[1]);
+ configure_bss_peers(bss_peer, ARRAY_SIZE(bss_peer));
+
+ printf("=== %s ===\n", __func__);
+ printf("--- Initialise SGSN 1 ---\n\n");
+
+ connect_sgsn(nsi, &sgsn_peer[0], SGSN_NSEI);
+
+ printf("--- Initialise SGSN 2 ---\n\n");
+
+ connect_sgsn(nsi, &sgsn_peer[1], SGSN2_NSEI);
+
+ printf("--- Initialise BSS 1 ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x1001, 0x1000);
+ setup_bssgp(nsi, &bss_peer[0], 0x0);
+ send_bssgp_reset_ack(nsi, &sgsn_peer[0], 0x0);
+ setup_bssgp(nsi, &bss_peer[0], 0x1002);
+ send_bssgp_reset_ack(nsi, &sgsn_peer[0], 0x1002);
+ send_bssgp_reset_ack(nsi, &sgsn_peer[1], 0x1002);
+
+ peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000);
+ OSMO_ASSERT(peer != NULL);
+
+ gprs_dump_nsi(nsi);
+ dump_global(stdout, 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Flow control ---\n\n");
+
+ send_bssgp_flow_control_bvc(nsi, &bss_peer[0], 0x1002, 1);
+ send_bssgp_flow_control_bvc_ack(nsi, &sgsn_peer[0], 0x1002, 1);
+ send_bssgp_flow_control_bvc_ack(nsi, &sgsn_peer[1], 0x1002, 1);
+
+ printf("--- Establish GPRS connection (SGSN 1) ---\n\n");
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "IDENT REQUEST", &sgsn_peer[0], 0x1002,
+ random_sgsn_tlli, 0, NULL, 0,
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_identity_req, sizeof(dtap_identity_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer[0], 0x1002,
+ random_sgsn_tlli, 1, imsi1, sizeof(imsi1),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN2_NSEI));
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, random_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == bss_ptmsi);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli);
+ OSMO_ASSERT(!link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.ptmsi == sgsn_ptmsi);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN2_NSEI));
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer[0], 0x1002,
+ local_sgsn_tlli, 1, imsi1, sizeof(imsi1),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN2_NSEI));
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == local_bss_tlli);
+ OSMO_ASSERT(link_info->tlli.assigned == 0);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == 0);
+
+ /* Non-DTAP */
+ send_bssgp_ul_unitdata(nsi, "XID (UL)", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ llc_u_xid_ul, sizeof(llc_u_xid_ul));
+
+ send_bssgp_dl_unitdata(nsi, "XID (DL)", &sgsn_peer[0], 0x1002,
+ local_sgsn_tlli, 1, imsi1, sizeof(imsi1),
+ llc_u_xid_dl, sizeof(llc_u_xid_dl));
+
+ send_bssgp_ul_unitdata(nsi, "LL11 DNS QUERY (UL)", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ llc_ui_ll11_dns_query_ul,
+ sizeof(llc_ui_ll11_dns_query_ul));
+
+ send_bssgp_dl_unitdata(nsi, "LL11 DNS RESP (DL)", &sgsn_peer[0], 0x1002,
+ local_sgsn_tlli, 1, imsi1, sizeof(imsi1),
+ llc_ui_ll11_dns_resp_dl,
+ sizeof(llc_ui_ll11_dns_resp_dl));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Other messages */
+ send_bssgp_llc_discarded(nsi, &bss_peer[0], 0x1002,
+ local_bss_tlli, 1, 12);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_llc_discarded(nsi, &sgsn_peer[0], 0x1002,
+ local_sgsn_tlli, 1, 12);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_suspend(nsi, &bss_peer[0], local_bss_tlli, &rai_bss);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_suspend_ack(nsi, &sgsn_peer[0], local_sgsn_tlli, &rai_sgsn);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Establish GPRS connection (SGSN 2) ---\n\n");
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_bss_tlli2, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_bss_tlli2, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity2_resp, sizeof(dtap_identity2_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "IDENT REQUEST", &sgsn_peer[1], 0x1002,
+ random_sgsn_tlli2, 0, NULL, 0,
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_identity_req, sizeof(dtap_identity_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_bss_tlli2, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity2_resp, sizeof(dtap_identity2_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer[1], 0x1002,
+ random_sgsn_tlli2, 1, imsi2, sizeof(imsi2),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc2, sizeof(dtap_attach_acc2));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_sgsn_tlli(peer, random_sgsn_tlli2, SGSN_NSEI));
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, random_sgsn_tlli2, SGSN2_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli2);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli2);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == bss_ptmsi2);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli2);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli2);
+ OSMO_ASSERT(!link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.ptmsi == sgsn_ptmsi2);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_bss_tlli2, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli2, SGSN_NSEI));
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli2, SGSN2_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli2);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli2);
+ OSMO_ASSERT(link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli2);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli2);
+ OSMO_ASSERT(link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer[1], 0x1002,
+ local_sgsn_tlli2, 1, imsi2, sizeof(imsi2),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli2, SGSN_NSEI));
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli2, SGSN2_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == local_bss_tlli2);
+ OSMO_ASSERT(link_info->tlli.assigned == 0);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == local_sgsn_tlli2);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == 0);
+
+ /* Non-DTAP */
+ send_bssgp_ul_unitdata(nsi, "XID (UL)", &bss_peer[0], 0x1002,
+ local_bss_tlli2, &rai_bss, cell_id,
+ llc_u_xid_ul, sizeof(llc_u_xid_ul));
+
+ send_bssgp_dl_unitdata(nsi, "XID (DL)", &sgsn_peer[1], 0x1002,
+ local_sgsn_tlli2, 1, imsi2, sizeof(imsi2),
+ llc_u_xid_dl, sizeof(llc_u_xid_dl));
+
+ send_bssgp_ul_unitdata(nsi, "LL11 DNS QUERY (UL)", &bss_peer[0], 0x1002,
+ local_bss_tlli2, &rai_bss, cell_id,
+ llc_ui_ll11_dns_query_ul,
+ sizeof(llc_ui_ll11_dns_query_ul));
+
+ send_bssgp_dl_unitdata(nsi, "LL11 DNS RESP (DL)", &sgsn_peer[1], 0x1002,
+ local_sgsn_tlli2, 1, imsi2, sizeof(imsi2),
+ llc_ui_ll11_dns_resp_dl,
+ sizeof(llc_ui_ll11_dns_resp_dl));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Other messages */
+ send_bssgp_llc_discarded(nsi, &bss_peer[0], 0x1002,
+ local_bss_tlli2, 1, 12);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_llc_discarded(nsi, &sgsn_peer[1], 0x1002,
+ local_sgsn_tlli2, 1, 12);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_suspend(nsi, &bss_peer[0], local_bss_tlli2, &rai_bss);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_bssgp_suspend_ack(nsi, &sgsn_peer[1], local_sgsn_tlli2, &rai_sgsn);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Establish GPRS connection (SGSN 2, P-TMSI collision) ---\n\n");
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_bss_tlli3, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_bss_tlli3, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity3_resp, sizeof(dtap_identity3_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "IDENT REQUEST", &sgsn_peer[1], 0x1002,
+ random_sgsn_tlli3, 0, NULL, 0,
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_identity_req, sizeof(dtap_identity_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_bss_tlli3, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity3_resp, sizeof(dtap_identity3_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT (P-TMSI 1)", &sgsn_peer[1], 0x1002,
+ random_sgsn_tlli3, 1, imsi3, sizeof(imsi3),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_sgsn_tlli(peer, random_sgsn_tlli3, SGSN_NSEI));
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, random_sgsn_tlli3, SGSN2_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli3);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli3);
+ OSMO_ASSERT(!link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->tlli.ptmsi == bss_ptmsi3);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli3);
+ OSMO_ASSERT(!link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.ptmsi == sgsn_ptmsi);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_bss_tlli3, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ other_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(other_info);
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN2_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info != other_info);
+ OSMO_ASSERT(link_info->tlli.assigned == local_bss_tlli3);
+ OSMO_ASSERT(link_info->tlli.current == foreign_bss_tlli3);
+ OSMO_ASSERT(link_info->tlli.bss_validated);
+ OSMO_ASSERT(!link_info->tlli.net_validated);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == random_sgsn_tlli3);
+ OSMO_ASSERT(link_info->sgsn_tlli.bss_validated);
+ OSMO_ASSERT(!link_info->sgsn_tlli.net_validated);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer[1], 0x1002,
+ local_sgsn_tlli, 1, imsi3, sizeof(imsi3),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ other_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN_NSEI);
+ OSMO_ASSERT(other_info);
+ link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_sgsn_tlli, SGSN2_NSEI);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info != other_info);
+ OSMO_ASSERT(link_info->tlli.current == local_bss_tlli3);
+ OSMO_ASSERT(link_info->tlli.assigned == 0);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == local_sgsn_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == 0);
+
+
+ printf("--- Shutdown GPRS connection (SGSN 1) ---\n\n");
+
+ /* Detach */
+ send_llc_ul_ui(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ local_bss_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "DETACH ACC", &sgsn_peer[0], 0x1002,
+ local_sgsn_tlli, 1, imsi1, sizeof(imsi1),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_detach_acc, sizeof(dtap_detach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Shutdown GPRS connection (SGSN 2) ---\n\n");
+
+ send_llc_ul_ui(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ local_bss_tlli2, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "DETACH ACC", &sgsn_peer[1], 0x1002,
+ local_sgsn_tlli2, 1, imsi2, sizeof(imsi2),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_detach_acc, sizeof(dtap_detach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Shutdown GPRS connection (SGSN 2, P-TMSI 1) ---\n\n");
+
+ send_llc_ul_ui(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ local_bss_tlli3, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "DETACH ACC", &sgsn_peer[1], 0x1002,
+ local_sgsn_tlli, 1, imsi3, sizeof(imsi3),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_detach_acc, sizeof(dtap_detach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ dump_global(stdout, 0);
+
+ gbproxy_clear_patch_filter(&gbcfg.matches[GBPROX_MATCH_ROUTING]);
+ gbprox_reset(&gbcfg);
+ gprs_ns_destroy(nsi);
+ nsi = NULL;
+
+ cleanup_test();
+}
+
+static void test_gbproxy_keep_info()
+{
+ struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+ struct sockaddr_in bss_peer[1] = {{0},};
+ struct sockaddr_in sgsn_peer= {0};
+ struct gprs_ra_id rai_bss =
+ {.mcc = 112, .mnc = 332, .lac = 16464, .rac = 96};
+ uint16_t cell_id = 0x1234;
+
+ const uint32_t ptmsi = 0xefe2b700;
+ const uint32_t local_tlli = 0xefe2b700;
+ const uint32_t foreign_tlli = 0xafe2b700;
+
+ const uint8_t imsi[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18};
+ struct gbproxy_link_info *link_info, *link_info2;
+ struct gbproxy_peer *peer;
+ unsigned bss_nu = 0;
+ unsigned sgsn_nu = 0;
+
+ LLIST_HEAD(rcv_list);
+
+ OSMO_ASSERT(local_tlli == gprs_tmsi2tlli(ptmsi, TLLI_LOCAL));
+
+ bssgp_nsi = nsi;
+ gbcfg.nsi = bssgp_nsi;
+ gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
+ gbcfg.patch_ptmsi = 0;
+ gbcfg.acquire_imsi = 1;
+ gbcfg.core_mcc = 0;
+ gbcfg.core_mnc = 0;
+ gbcfg.core_apn = NULL;
+ gbcfg.core_apn_size = 0;
+ gbcfg.route_to_sgsn2 = 0;
+ gbcfg.nsip_sgsn2_nsei = 0xffff;
+ gbcfg.keep_link_infos = GBPROX_KEEP_ALWAYS;
+
+ configure_sgsn_peer(&sgsn_peer);
+ configure_bss_peers(bss_peer, ARRAY_SIZE(bss_peer));
+
+ printf("=== %s ===\n", __func__);
+ printf("--- Initialise SGSN ---\n\n");
+
+ connect_sgsn(nsi, &sgsn_peer, SGSN_NSEI);
+
+ printf("--- Initialise BSS 1 ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x1001, 0x1000);
+ setup_bssgp(nsi, &bss_peer[0], 0x1002);
+
+ peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000);
+ OSMO_ASSERT(peer != NULL);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1002);
+
+ gprs_dump_nsi(nsi);
+ dump_global(stdout, 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---\n\n");
+
+ received_messages = &rcv_list;
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ID_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->imsi_len == 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(link_info->imsi_acq_pending);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->imsi_len > 0);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+ OSMO_ASSERT(gprs_tlli_type(link_info->sgsn_tlli.current) == TLLI_FOREIGN);
+
+ send_llc_dl_ui(nsi, "IDENT REQUEST", &sgsn_peer, 0x1002,
+ foreign_tlli, 0, NULL, 0,
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_identity_req, sizeof(dtap_identity_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ID_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ID_RESP));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->imsi_len > 0);
+ OSMO_ASSERT(gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi)));
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_INFO));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+
+ /* Detach (MO) */
+ send_llc_ul_ui(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_DETACH_REQ));
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "DETACH ACC", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_detach_acc, sizeof(dtap_detach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_DETACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_tlli(peer, local_tlli));
+ link_info = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->is_deregistered);
+
+ OSMO_ASSERT(!expect_msg());
+
+ /* Re-Attach */
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req3, sizeof(dtap_attach_req3));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len != 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+ OSMO_ASSERT(gprs_tlli_type(link_info->sgsn_tlli.current) == TLLI_FOREIGN);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Detach (MT) */
+ send_llc_dl_ui(nsi, "DETACH REQ (re-attach)", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_mt_detach_rea_req, sizeof(dtap_mt_detach_rea_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_DETACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+
+ send_llc_ul_ui(nsi, "DETACH ACC", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_mt_detach_acc, sizeof(dtap_mt_detach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_DETACH_ACK));
+ OSMO_ASSERT(!expect_msg());
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_tlli(peer, local_tlli));
+ link_info = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->is_deregistered);
+
+ /* Re-Attach */
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req3, sizeof(dtap_attach_req3));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len != 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Detach (MT) */
+ send_llc_dl_ui(nsi, "DETACH REQ", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_mt_detach_req, sizeof(dtap_mt_detach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_DETACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+
+ send_llc_ul_ui(nsi, "DETACH ACC", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_mt_detach_acc, sizeof(dtap_mt_detach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_DETACH_ACK));
+ OSMO_ASSERT(!expect_msg());
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_tlli(peer, local_tlli));
+ link_info = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->is_deregistered);
+
+ /* Re-Attach with IMSI */
+ send_llc_ul_ui(nsi, "ATTACH REQUEST (IMSI)", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req4, sizeof(dtap_attach_req4));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len != 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == foreign_tlli);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Detach (MT) */
+ send_llc_dl_ui(nsi, "DETACH REQ", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_mt_detach_req, sizeof(dtap_mt_detach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_DETACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+
+ send_llc_ul_ui(nsi, "DETACH ACC", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_mt_detach_acc, sizeof(dtap_mt_detach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_DETACH_ACK));
+ OSMO_ASSERT(!expect_msg());
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_tlli(peer, local_tlli));
+ link_info = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->is_deregistered);
+
+ /* Re-Attach */
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req3, sizeof(dtap_attach_req3));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len != 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* RA update procedure (reject -> Detach) */
+ send_llc_ul_ui(nsi, "RA UPD REQ", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, 0x7080,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_ra_upd_req, sizeof(dtap_ra_upd_req));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_RA_UPD_REQ));
+
+ send_llc_dl_ui(nsi, "RA UDP REJ", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_ra_upd_rej, sizeof(dtap_ra_upd_rej));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_RA_UPD_REJ));
+ OSMO_ASSERT(!expect_msg());
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_tlli(peer, local_tlli));
+ link_info = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->is_deregistered);
+
+ /* Bad case: Re-Attach with wrong (initial) P-TMSI */
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ID_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info != link_info2);
+ OSMO_ASSERT(link_info->imsi_len == 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(link_info->imsi_acq_pending);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len != 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len > 0);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Detach (MT) */
+ send_llc_dl_ui(nsi, "DETACH REQ", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_mt_detach_req, sizeof(dtap_mt_detach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_DETACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+
+ send_llc_ul_ui(nsi, "DETACH ACC", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_mt_detach_acc, sizeof(dtap_mt_detach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_DETACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_tlli(peer, local_tlli));
+ link_info = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->is_deregistered);
+
+ OSMO_ASSERT(!expect_msg());
+
+ /* Bad case: Re-Attach with local TLLI */
+ send_llc_ul_ui(nsi, "ATTACH REQUEST (local TLLI)", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req3, sizeof(dtap_attach_req3));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len != 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == local_tlli);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Detach (MT) */
+ send_llc_dl_ui(nsi, "DETACH REQ (re-attach)", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_mt_detach_rea_req, sizeof(dtap_mt_detach_rea_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_DETACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+
+ send_llc_ul_ui(nsi, "DETACH ACC", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_mt_detach_acc, sizeof(dtap_mt_detach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_DETACH_ACK));
+ OSMO_ASSERT(!expect_msg());
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_tlli(peer, local_tlli));
+ link_info = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->is_deregistered);
+
+ /* Bad case: Unexpected Re-Attach with IMSI after completed attachment
+ * procedure */
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req3, sizeof(dtap_attach_req3));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len != 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_INFO));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST (unexpected, IMSI)",
+ &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req4, sizeof(dtap_attach_req4));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len != 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == foreign_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == 0);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Detach (MT) */
+ send_llc_dl_ui(nsi, "DETACH REQ", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_mt_detach_req, sizeof(dtap_mt_detach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_DETACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+
+ send_llc_ul_ui(nsi, "DETACH ACC", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_mt_detach_acc, sizeof(dtap_mt_detach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_DETACH_ACK));
+ OSMO_ASSERT(!expect_msg());
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_tlli(peer, local_tlli));
+ link_info = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->is_deregistered);
+
+ /* Bad case: Unexpected Re-Attach with P-TMSI after completed attachment
+ * procedure */
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req3, sizeof(dtap_attach_req3));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len != 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "GMM INFO", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_gmm_information, sizeof(dtap_gmm_information));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_INFO));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST (unexpected)", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req3, sizeof(dtap_attach_req3));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len != 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+ OSMO_ASSERT(link_info->sgsn_tlli.current == foreign_tlli);
+ OSMO_ASSERT(link_info->sgsn_tlli.assigned == 0);
+
+ send_llc_dl_ui(nsi, "ATTACH ACCEPT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_acc, sizeof(dtap_attach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "ATTACH COMPLETE", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_complete, sizeof(dtap_attach_complete));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_COMPL));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ /* Detach (MT) */
+ send_llc_dl_ui(nsi, "DETACH REQ", &sgsn_peer, 0x1002,
+ local_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_mt_detach_req, sizeof(dtap_mt_detach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_DETACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, local_tlli);
+ OSMO_ASSERT(link_info);
+
+ send_llc_ul_ui(nsi, "DETACH ACC", &bss_peer[0], 0x1002,
+ local_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_mt_detach_acc, sizeof(dtap_mt_detach_acc));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_DETACH_ACK));
+ OSMO_ASSERT(!expect_msg());
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_tlli(peer, local_tlli));
+ link_info = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->is_deregistered);
+
+
+ /* Attach rejected */
+
+ gbproxy_delete_link_infos(peer);
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ID_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->imsi_len == 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(link_info->imsi_acq_pending);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info2 = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info == link_info2);
+ OSMO_ASSERT(link_info->imsi_len != 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(!link_info->imsi_acq_pending);
+
+ send_llc_dl_ui(nsi, "ATTACH REJECT", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_attach_rej7, sizeof(dtap_attach_rej7));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ATTACH_REJ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_tlli(peer, foreign_tlli));
+
+ OSMO_ASSERT(!expect_msg());
+
+ /* Attach (incomplete) and Detach (MO) */
+
+ gbproxy_delete_link_infos(peer);
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ID_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->imsi_len == 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(link_info->imsi_acq_pending);
+
+ send_llc_ul_ui(nsi, "DETACH REQ (MO)", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_req, sizeof(dtap_detach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_DETACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!expect_msg());
+
+ /* Attach (incomplete) and Detach (MT) */
+
+ gbproxy_delete_link_infos(peer);
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_ID_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->imsi_len == 0);
+ OSMO_ASSERT(!link_info->is_deregistered);
+ OSMO_ASSERT(link_info->imsi_acq_pending);
+
+ send_llc_dl_ui(nsi, "DETACH REQ (MT)", &sgsn_peer, 0x1002,
+ foreign_tlli, 1, imsi, sizeof(imsi),
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_mt_detach_req, sizeof(dtap_mt_detach_req));
+
+ OSMO_ASSERT(expect_gmm_msg(0x1000, 0x1002, GSM48_MT_GMM_DETACH_REQ));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ link_info = gbproxy_link_info_by_tlli(peer, foreign_tlli);
+ OSMO_ASSERT(link_info);
+
+ send_llc_ul_ui(nsi, "DETACH ACC", &bss_peer[0], 0x1002,
+ foreign_tlli, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_mt_detach_acc, sizeof(dtap_mt_detach_acc));
+
+ /* TODO: The stored messaged should be cleaned when receiving a Detach
+ * Ack. Remove the first OSMO_ASSERT when this is fixed. */
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_ATTACH_REQ));
+ OSMO_ASSERT(expect_gmm_msg(SGSN_NSEI, 0x1002, GSM48_MT_GMM_DETACH_ACK));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ OSMO_ASSERT(!gbproxy_link_info_by_tlli(peer, foreign_tlli));
+ link_info = gbproxy_link_info_by_imsi(peer, imsi, sizeof(imsi));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->is_deregistered);
+
+ OSMO_ASSERT(!expect_msg());
+ received_messages = NULL;
+
+ dump_global(stdout, 0);
+
+ gbprox_reset(&gbcfg);
+ gprs_ns_destroy(nsi);
+ nsi = NULL;
+
+ cleanup_test();
+}
+
+struct gbproxy_link_info *register_tlli(
+ struct gbproxy_peer *peer, uint32_t tlli,
+ const uint8_t *imsi, size_t imsi_len, time_t now)
+{
+ struct gbproxy_link_info *link_info;
+ int imsi_matches = -1;
+ int tlli_already_known = 0;
+ struct gbproxy_config *cfg = peer->cfg;
+
+ /* Check, whether the IMSI matches */
+ if (gprs_is_mi_imsi(imsi, imsi_len)) {
+ imsi_matches = gbproxy_check_imsi(
+ &cfg->matches[GBPROX_MATCH_PATCHING], imsi, imsi_len);
+ if (imsi_matches < 0)
+ return NULL;
+ }
+
+ link_info = gbproxy_link_info_by_tlli(peer, tlli);
+
+ if (!link_info) {
+ link_info = gbproxy_link_info_by_imsi(peer, imsi, imsi_len);
+
+ if (link_info) {
+ /* TLLI has changed somehow, adjust it */
+ LOGP(DGPRS, LOGL_INFO,
+ "The TLLI has changed from %08x to %08x\n",
+ link_info->tlli.current, tlli);
+ link_info->tlli.current = tlli;
+ }
+ }
+
+ if (!link_info) {
+ link_info = gbproxy_link_info_alloc(peer);
+ link_info->tlli.current = tlli;
+ } else {
+ gbproxy_detach_link_info(peer, link_info);
+ tlli_already_known = 1;
+ }
+
+ OSMO_ASSERT(link_info != NULL);
+
+ if (!tlli_already_known)
+ LOGP(DGPRS, LOGL_INFO, "Adding TLLI %08x to list\n", tlli);
+
+ gbproxy_attach_link_info(peer, now, link_info);
+ gbproxy_update_link_info(link_info, imsi, imsi_len);
+
+ if (imsi_matches >= 0)
+ link_info->is_matching[GBPROX_MATCH_PATCHING] = imsi_matches;
+
+ return link_info;
+}
+
+static void test_gbproxy_tlli_expire(void)
+{
+ struct gbproxy_config cfg = {0};
+ struct gbproxy_peer *peer;
+ const char *err_msg = NULL;
+ const uint8_t imsi1[] = { GSM_MI_TYPE_IMSI, 0x23, 0x24, 0x25, 0x26 };
+ const uint8_t imsi2[] = { GSM_MI_TYPE_IMSI, 0x26, 0x27, 0x28, 0x29 };
+ const uint8_t imsi3[] = { GSM_MI_TYPE_IMSI | 0x10, 0x32, 0x54, 0x76, 0xf8 };
+ const uint32_t tlli1 = 1234 | 0xc0000000;
+ const uint32_t tlli2 = 5678 | 0xc0000000;
+ const uint32_t tlli3 = 3456 | 0xc0000000;
+ const char *filter_re = ".*";
+ time_t now = 1407479214;
+
+ printf("Test TLLI info expiry\n\n");
+
+ gbproxy_init_config(&cfg);
+
+ if (gbproxy_set_patch_filter(&cfg.matches[GBPROX_MATCH_PATCHING],
+ filter_re, &err_msg) != 0) {
+ fprintf(stderr, "gbprox_set_patch_filter: got error: %s\n",
+ err_msg);
+ OSMO_ASSERT(err_msg == NULL);
+ }
+
+ {
+ struct gbproxy_link_info *link_info;
+
+ printf("Test TLLI replacement:\n");
+
+ cfg.tlli_max_len = 0;
+ cfg.tlli_max_age = 0;
+ peer = gbproxy_peer_alloc(&cfg, 20);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 0);
+
+ printf(" Add TLLI 1, IMSI 1\n");
+ link_info = register_tlli(peer, tlli1,
+ imsi1, ARRAY_SIZE(imsi1), now);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == tlli1);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 1);
+
+ /* replace the old entry */
+ printf(" Add TLLI 2, IMSI 1 (should replace TLLI 1)\n");
+ link_info = register_tlli(peer, tlli2,
+ imsi1, ARRAY_SIZE(imsi1), now);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == tlli2);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 1);
+
+ dump_peers(stdout, 2, now, &cfg);
+
+ /* verify that 5678 has survived */
+ link_info = gbproxy_link_info_by_imsi(peer, imsi1, ARRAY_SIZE(imsi1));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == tlli2);
+ link_info = gbproxy_link_info_by_imsi(peer, imsi2, ARRAY_SIZE(imsi2));
+ OSMO_ASSERT(!link_info);
+
+ printf("\n");
+
+ gbproxy_peer_free(peer);
+ }
+
+ {
+ struct gbproxy_link_info *link_info;
+
+ printf("Test IMSI replacement:\n");
+
+ cfg.tlli_max_len = 0;
+ cfg.tlli_max_age = 0;
+ peer = gbproxy_peer_alloc(&cfg, 20);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 0);
+
+ printf(" Add TLLI 1, IMSI 1\n");
+ link_info = register_tlli(peer, tlli1,
+ imsi1, ARRAY_SIZE(imsi1), now);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == tlli1);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 1);
+
+ /* try to replace the old entry */
+ printf(" Add TLLI 1, IMSI 2 (should replace IMSI 1)\n");
+ link_info = register_tlli(peer, tlli1,
+ imsi2, ARRAY_SIZE(imsi2), now);
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == tlli1);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 1);
+
+ dump_peers(stdout, 2, now, &cfg);
+
+ /* verify that 5678 has survived */
+ link_info = gbproxy_link_info_by_imsi(peer, imsi1, ARRAY_SIZE(imsi1));
+ OSMO_ASSERT(!link_info);
+ link_info = gbproxy_link_info_by_imsi(peer, imsi2, ARRAY_SIZE(imsi2));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == tlli1);
+
+ printf("\n");
+
+ gbproxy_peer_free(peer);
+ }
+
+ {
+ struct gbproxy_link_info *link_info;
+ int num_removed;
+
+ printf("Test TLLI expiry, max_len == 1:\n");
+
+ cfg.tlli_max_len = 1;
+ cfg.tlli_max_age = 0;
+ peer = gbproxy_peer_alloc(&cfg, 20);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 0);
+
+ printf(" Add TLLI 1, IMSI 1\n");
+ register_tlli(peer, tlli1, imsi1, ARRAY_SIZE(imsi1), now);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 1);
+
+ /* replace the old entry */
+ printf(" Add TLLI 2, IMSI 2 (should replace IMSI 1)\n");
+ register_tlli(peer, tlli2, imsi2, ARRAY_SIZE(imsi2), now);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 2);
+
+ num_removed = gbproxy_remove_stale_link_infos(peer, now + 2);
+ OSMO_ASSERT(num_removed == 1);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 1);
+
+ dump_peers(stdout, 2, now, &cfg);
+
+ /* verify that 5678 has survived */
+ link_info = gbproxy_link_info_by_imsi(peer, imsi1, ARRAY_SIZE(imsi1));
+ OSMO_ASSERT(!link_info);
+ link_info = gbproxy_link_info_by_imsi(peer, imsi2, ARRAY_SIZE(imsi2));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == tlli2);
+
+ printf("\n");
+
+ gbproxy_peer_free(peer);
+ }
+
+ {
+ struct gbproxy_link_info *link_info;
+ int num_removed;
+
+ printf("Test TLLI expiry, max_age == 1:\n");
+
+ cfg.tlli_max_len = 0;
+ cfg.tlli_max_age = 1;
+ peer = gbproxy_peer_alloc(&cfg, 20);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 0);
+
+ printf(" Add TLLI 1, IMSI 1 (should expire after timeout)\n");
+ register_tlli(peer, tlli1, imsi1, ARRAY_SIZE(imsi1), now);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 1);
+
+ printf(" Add TLLI 2, IMSI 2 (should not expire after timeout)\n");
+ register_tlli(peer, tlli2, imsi2, ARRAY_SIZE(imsi2),
+ now + 1);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 2);
+
+ num_removed = gbproxy_remove_stale_link_infos(peer, now + 2);
+ OSMO_ASSERT(num_removed == 1);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 1);
+
+ dump_peers(stdout, 2, now + 2, &cfg);
+
+ /* verify that 5678 has survived */
+ link_info = gbproxy_link_info_by_imsi(peer, imsi1, ARRAY_SIZE(imsi1));
+ OSMO_ASSERT(!link_info);
+ link_info = gbproxy_link_info_by_imsi(peer, imsi2, ARRAY_SIZE(imsi2));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == tlli2);
+
+ printf("\n");
+
+ gbproxy_peer_free(peer);
+ }
+
+ {
+ struct gbproxy_link_info *link_info;
+ int num_removed;
+
+ printf("Test TLLI expiry, max_len == 2, max_age == 1:\n");
+
+ cfg.tlli_max_len = 0;
+ cfg.tlli_max_age = 1;
+ peer = gbproxy_peer_alloc(&cfg, 20);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 0);
+
+ printf(" Add TLLI 1, IMSI 1 (should expire)\n");
+ register_tlli(peer, tlli1, imsi1, ARRAY_SIZE(imsi1), now);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 1);
+
+ printf(" Add TLLI 2, IMSI 2 (should expire after timeout)\n");
+ register_tlli(peer, tlli2, imsi2, ARRAY_SIZE(imsi2),
+ now + 1);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 2);
+
+ printf(" Add TLLI 3, IMSI 3 (should not expire after timeout)\n");
+ register_tlli(peer, tlli3, imsi3, ARRAY_SIZE(imsi3),
+ now + 2);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 3);
+
+ dump_peers(stdout, 2, now + 2, &cfg);
+
+ printf(" Remove stale TLLIs\n");
+ num_removed = gbproxy_remove_stale_link_infos(peer, now + 3);
+ OSMO_ASSERT(num_removed == 2);
+ OSMO_ASSERT(peer->patch_state.logical_link_count == 1);
+
+ dump_peers(stdout, 2, now + 2, &cfg);
+
+ /* verify that tlli3 has survived */
+ link_info = gbproxy_link_info_by_imsi(peer, imsi1, ARRAY_SIZE(imsi1));
+ OSMO_ASSERT(!link_info);
+ link_info = gbproxy_link_info_by_imsi(peer, imsi2, ARRAY_SIZE(imsi2));
+ OSMO_ASSERT(!link_info);
+ link_info = gbproxy_link_info_by_imsi(peer, imsi3, ARRAY_SIZE(imsi3));
+ OSMO_ASSERT(link_info);
+ OSMO_ASSERT(link_info->tlli.current == tlli3);
+
+ printf("\n");
+
+ gbproxy_peer_free(peer);
+ }
+ gbproxy_clear_patch_filter(&cfg.matches[GBPROX_MATCH_PATCHING]);
+ gbprox_reset(&cfg);
+
+ cleanup_test();
+}
+
+static void test_gbproxy_imsi_matching(void)
+{
+ const char *err_msg = NULL;
+ const uint8_t imsi1[] = { GSM_MI_TYPE_IMSI | 0x10, 0x32, 0x54, 0xf6 };
+ const uint8_t imsi2[] = { GSM_MI_TYPE_IMSI | GSM_MI_ODD | 0x10, 0x32, 0x54, 0x76 };
+ const uint8_t imsi3_bad[] = { GSM_MI_TYPE_IMSI | 0x10, 0xee, 0x54, 0xff };
+ const uint8_t tmsi1[] = { GSM_MI_TYPE_TMSI | 0xf0, 0x11, 0x22, 0x33, 0x44 };
+ const uint8_t tmsi2_bad[] = { GSM_MI_TYPE_TMSI | 0xf0, 0x11, 0x22 };
+ const uint8_t imei1[] = { GSM_MI_TYPE_IMEI | 0x10, 0x32, 0x54, 0xf6 };
+ const uint8_t imei2[] = { GSM_MI_TYPE_IMEI | GSM_MI_ODD | 0x10, 0x32, 0x54, 0x76 };
+ const char *filter_re1 = ".*";
+ const char *filter_re2 = "^1234";
+ const char *filter_re3 = "^4321";
+ const char *filter_re4_bad = "^12[";
+ struct gbproxy_match match = {0,};
+
+ printf("=== Test IMSI/TMSI matching ===\n\n");
+
+ OSMO_ASSERT(match.enable == 0);
+
+ OSMO_ASSERT(gbproxy_set_patch_filter(&match, filter_re1, &err_msg) == 0);
+ OSMO_ASSERT(match.enable == 1);
+
+ OSMO_ASSERT(gbproxy_set_patch_filter(&match, filter_re2, &err_msg) == 0);
+ OSMO_ASSERT(match.enable == 1);
+
+ err_msg = NULL;
+ OSMO_ASSERT(gbproxy_set_patch_filter(&match, filter_re4_bad, &err_msg) == -1);
+ OSMO_ASSERT(err_msg != NULL);
+ OSMO_ASSERT(match.enable == 0);
+
+ OSMO_ASSERT(gbproxy_set_patch_filter(&match, filter_re2, &err_msg) == 0);
+ OSMO_ASSERT(match.enable == 1);
+
+ OSMO_ASSERT(gbproxy_set_patch_filter(&match, NULL, &err_msg) == 0);
+ OSMO_ASSERT(match.enable == 0);
+
+ OSMO_ASSERT(gbproxy_set_patch_filter(&match, filter_re2, &err_msg) == 0);
+ OSMO_ASSERT(match.enable == 1);
+
+ gbproxy_clear_patch_filter(&match);
+ OSMO_ASSERT(match.enable == 0);
+
+ OSMO_ASSERT(gbproxy_set_patch_filter(&match, filter_re2, &err_msg) == 0);
+ OSMO_ASSERT(match.enable == 1);
+
+ OSMO_ASSERT(gbproxy_check_imsi(&match, imsi1, ARRAY_SIZE(imsi1)) == 1);
+ OSMO_ASSERT(gbproxy_check_imsi(&match, imsi2, ARRAY_SIZE(imsi2)) == 1);
+ /* imsi3_bad contains 0xE and 0xF digits, but the conversion function
+ * doesn't complain, so gbproxy_check_imsi() doesn't return -1 in this
+ * case. */
+ OSMO_ASSERT(gbproxy_check_imsi(&match, imsi3_bad, ARRAY_SIZE(imsi3_bad)) == 0);
+ OSMO_ASSERT(gbproxy_check_imsi(&match, tmsi1, ARRAY_SIZE(tmsi1)) == -1);
+ OSMO_ASSERT(gbproxy_check_imsi(&match, tmsi2_bad, ARRAY_SIZE(tmsi2_bad)) == -1);
+ OSMO_ASSERT(gbproxy_check_imsi(&match, imei1, ARRAY_SIZE(imei1)) == -1);
+ OSMO_ASSERT(gbproxy_check_imsi(&match, imei2, ARRAY_SIZE(imei2)) == -1);
+
+ OSMO_ASSERT(gbproxy_set_patch_filter(&match, filter_re3, &err_msg) == 0);
+ OSMO_ASSERT(match.enable == 1);
+
+ OSMO_ASSERT(gbproxy_check_imsi(&match, imsi1, ARRAY_SIZE(imsi1)) == 0);
+ OSMO_ASSERT(gbproxy_check_imsi(&match, imsi2, ARRAY_SIZE(imsi2)) == 0);
+ OSMO_ASSERT(gbproxy_check_imsi(&match, imsi3_bad, ARRAY_SIZE(imsi3_bad)) == 0);
+ OSMO_ASSERT(gbproxy_check_imsi(&match, tmsi1, ARRAY_SIZE(tmsi1)) == -1);
+ OSMO_ASSERT(gbproxy_check_imsi(&match, tmsi2_bad, ARRAY_SIZE(tmsi2_bad)) == -1);
+ OSMO_ASSERT(gbproxy_check_imsi(&match, imei1, ARRAY_SIZE(imei1)) == -1);
+ OSMO_ASSERT(gbproxy_check_imsi(&match, imei2, ARRAY_SIZE(imei2)) == -1);
+
+ /* TODO: Check correct length but wrong type with is_mi_tmsi */
+
+ gbproxy_clear_patch_filter(&match);
+ OSMO_ASSERT(match.enable == 0);
+
+ cleanup_test();
+}
+
+static void test_gbproxy_stored_messages()
+{
+ struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+ struct sockaddr_in bss_peer[1] = {{0},};
+ struct sockaddr_in sgsn_peer= {0};
+ struct gprs_ra_id rai_bss =
+ {.mcc = 112, .mnc = 332, .lac = 16464, .rac = 96};
+ struct gprs_ra_id rai_unknown =
+ {.mcc = 1, .mnc = 99, .lac = 99, .rac = 96};
+ uint16_t cell_id = 0x1234;
+
+ const uint32_t ptmsi = 0xefe2b700;
+ const uint32_t local_tlli = 0xefe2b700;
+
+ const uint32_t foreign_tlli1 = 0x8000dead;
+
+ struct gbproxy_peer *peer;
+ unsigned bss_nu = 0;
+ unsigned sgsn_nu = 0;
+
+ OSMO_ASSERT(local_tlli == gprs_tmsi2tlli(ptmsi, TLLI_LOCAL));
+
+ bssgp_nsi = nsi;
+ gbcfg.nsi = bssgp_nsi;
+ gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
+ gbcfg.core_mcc = 0;
+ gbcfg.core_mnc = 0;
+ gbcfg.core_apn = talloc_zero_size(NULL, 100);
+ gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
+ gbcfg.patch_ptmsi = 0;
+ gbcfg.acquire_imsi = 1;
+ gbcfg.keep_link_infos = 0;
+
+ configure_sgsn_peer(&sgsn_peer);
+ configure_bss_peers(bss_peer, ARRAY_SIZE(bss_peer));
+
+ printf("=== %s ===\n", __func__);
+ printf("--- Initialise SGSN ---\n\n");
+
+ connect_sgsn(nsi, &sgsn_peer, SGSN_NSEI);
+
+ printf("--- Initialise BSS 1 ---\n\n");
+
+ setup_ns(nsi, &bss_peer[0], 0x1001, 0x1000);
+ setup_bssgp(nsi, &bss_peer[0], 0x1002);
+
+ peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000);
+ OSMO_ASSERT(peer != NULL);
+
+ send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1002);
+
+ gprs_dump_nsi(nsi);
+ dump_global(stdout, 0);
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ printf("--- Establish first LLC connection ---\n\n");
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_tlli1, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_dl_ui(nsi, "IDENT REQUEST", &sgsn_peer, 0x1002,
+ foreign_tlli1, 0, NULL, 0,
+ GPRS_SAPI_GMM, sgsn_nu++,
+ dtap_identity_req, sizeof(dtap_identity_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "DETACH ACCEPT", &bss_peer[0], 0x1002,
+ foreign_tlli1, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_detach_acc, sizeof(dtap_detach_acc));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ send_llc_ul_ui(nsi, "IDENT RESPONSE", &bss_peer[0], 0x1002,
+ foreign_tlli1, &rai_bss, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_identity_resp, sizeof(dtap_identity_resp));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
+ dump_global(stdout, 0);
+
+ gbprox_reset(&gbcfg);
+ gprs_ns_destroy(nsi);
+ nsi = NULL;
+
+ cleanup_test();
+}
+
+static struct log_info_cat gprs_categories[] = {
+ [DGPRS] = {
+ .name = "DGPRS",
+ .description = "GPRS Packet Service",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ },
+ [DNS] = {
+ .name = "DNS",
+ .description = "GPRS Network Service (NS)",
+ .enabled = 1, .loglevel = LOGL_INFO,
+ },
+ [DBSSGP] = {
+ .name = "DBSSGP",
+ .description = "GPRS BSS Gateway Protocol (BSSGP)",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ },
+};
+
+static struct log_info info = {
+ .cat = gprs_categories,
+ .num_cat = ARRAY_SIZE(gprs_categories),
+};
+
+int main(int argc, char **argv)
+{
+ msgb_talloc_ctx_init(NULL, 0);
+
+ osmo_init_logging(&info);
+ log_set_use_color(osmo_stderr_target, 0);
+ log_set_print_filename(osmo_stderr_target, 0);
+ osmo_signal_register_handler(SS_L_NS, &test_signal, &gbcfg);
+
+ log_set_print_filename(osmo_stderr_target, 0);
+ log_set_log_level(osmo_stderr_target, LOGL_DEBUG);
+ log_set_all_filter(osmo_stderr_target, 1);
+
+ rate_ctr_init(NULL);
+
+ setlinebuf(stdout);
+
+ printf("===== GbProxy test START\n");
+ gbproxy_init_config(&gbcfg);
+ test_gbproxy();
+ test_gbproxy_ident_changes();
+ test_gbproxy_imsi_matching();
+ test_gbproxy_ptmsi_assignment();
+ test_gbproxy_ra_patching();
+ test_gbproxy_ptmsi_patching();
+ test_gbproxy_ptmsi_patching_bad_cases();
+ test_gbproxy_imsi_acquisition();
+ test_gbproxy_secondary_sgsn();
+ test_gbproxy_keep_info();
+ test_gbproxy_tlli_expire();
+ test_gbproxy_stored_messages();
+ printf("===== GbProxy test END\n\n");
+
+ exit(EXIT_SUCCESS);
+}
diff --git a/tests/gbproxy/gbproxy_test.ok b/tests/gbproxy/gbproxy_test.ok
new file mode 100644
index 000000000..737aec0ba
--- /dev/null
+++ b/tests/gbproxy/gbproxy_test.ok
@@ -0,0 +1,7244 @@
+===== GbProxy test START
+=== test_gbproxy ===
+--- Initialise SGSN ---
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 12
+02 00 81 01 01 82 01 01 04 82 01 00
+
+PROCESSING RESET_ACK from 0x05060708:32000
+03 01 82 01 01 04 82 01 00
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0a
+
+result (RESET_ACK) = 1
+
+PROCESSING ALIVE_ACK from 0x05060708:32000
+0b
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+06
+
+result (ALIVE_ACK) = 1
+
+PROCESSING UNBLOCK_ACK from 0x05060708:32000
+07
+
+==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000
+
+result (UNBLOCK_ACK) = 0
+
+PROCESSING ALIVE from 0x05060708:32000
+0a
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0b
+
+result (ALIVE) = 1
+
+Current NS-VCIs:
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+--- Initialise BSS 1 ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+Current NS-VCIs:
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+--- Initialise BSS 2 ---
+
+Setup NS-VC: remote 0x01020304:2222, NSVCI 0x2001(8193), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:2222
+02 00 81 01 01 82 20 01 04 82 20 00
+
+==> got signal NS_RESET, NS-VC 0x2001/1.2.3.4:2222
+
+MESSAGE to BSS at 0x01020304:2222, msg length 9
+03 01 82 20 01 04 82 20 00
+
+MESSAGE to BSS at 0x01020304:2222, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:2222
+0a
+
+MESSAGE to BSS at 0x01020304:2222, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:2222
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x2001/1.2.3.4:2222
+
+MESSAGE to BSS at 0x01020304:2222, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:2222
+0b
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:2222, BVCI 0x2002(8194)
+
+PROCESSING BVC_RESET from 0x01020304:2222
+00 00 00 00 22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:2222
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 20 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 20 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:2222, msg length 9
+00 00 00 00 23 04 82 20 02
+
+result (BVC_RESET_ACK) = 9
+
+--- Move BSS 1 to new port ---
+
+Setup NS-VC: remote 0x01020304:3333, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:3333
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:3333
+
+MESSAGE to BSS at 0x01020304:3333, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:3333, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:3333
+0a
+
+MESSAGE to BSS at 0x01020304:3333, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:3333
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:3333
+
+MESSAGE to BSS at 0x01020304:3333, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:3333
+0b
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:2222
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:3333
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+--- Move BSS 2 to former BSS 1 port ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x2001(8193), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 20 01 04 82 20 00
+
+==> got signal NS_RESET, NS-VC 0x2001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 20 01 04 82 20 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x2001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:3333
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+--- Move BSS 1 to current BSS 2 port ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x2001(8193), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 20 01 04 82 20 00
+
+==> got signal NS_RESET, NS-VC 0x2001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 20 01 04 82 20 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x2001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:3333
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+--- Move BSS 2 to new port ---
+
+Setup NS-VC: remote 0x01020304:4444, NSVCI 0x2001(8193), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:4444
+02 00 81 01 01 82 20 01 04 82 20 00
+
+==> got signal NS_RESET, NS-VC 0x2001/1.2.3.4:4444
+
+MESSAGE to BSS at 0x01020304:4444, msg length 9
+03 01 82 20 01 04 82 20 00
+
+MESSAGE to BSS at 0x01020304:4444, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:4444
+0a
+
+MESSAGE to BSS at 0x01020304:4444, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:4444
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x2001/1.2.3.4:4444
+
+MESSAGE to BSS at 0x01020304:4444, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:4444
+0b
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:4444
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:3333
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+--- Move BSS 2 to former BSS 1 port ---
+
+Setup NS-VC: remote 0x01020304:3333, NSVCI 0x2001(8193), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:3333
+02 00 81 01 01 82 20 01 04 82 20 00
+
+==> got signal NS_REPLACED: 0x2001/1.2.3.4:4444 -> 0x1001/1.2.3.4:3333
+
+==> got signal NS_RESET, NS-VC 0x2001/1.2.3.4:3333
+
+MESSAGE to BSS at 0x01020304:3333, msg length 9
+03 01 82 20 01 04 82 20 00
+
+MESSAGE to BSS at 0x01020304:3333, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:3333
+0a
+
+MESSAGE to BSS at 0x01020304:3333, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:3333
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x2001/1.2.3.4:3333
+
+MESSAGE to BSS at 0x01020304:3333, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:3333
+0b
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:3333
+ NS-VC replaced other count: 1
+ VCI 0x1001, NSEI 0x1000, peer 0x00000000:0
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+--- Move BSS 1 to original BSS 1 port ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:3333
+ NS-VC replaced other count: 1
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+--- Reset BSS 1 with a new BVCI ---
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1012(4114)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 12 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 12 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 12 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:3333
+ NS-VC replaced other count: 1
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 4096, BVCI 4114, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 12
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 12
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 12
+
+result (BVC_RESET_ACK) = 9
+
+--- Reset BSS 1 with the old BVCI ---
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:3333
+ NS-VC replaced other count: 1
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 4096, BVCI 4114, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+--- Reset BSS 1 with the old BVCI again ---
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:3333
+ NS-VC replaced other count: 1
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 4096, BVCI 4114, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+--- Send message from BSS 1 to SGSN, BVCI 0x1012 ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 10 12
+
+CALLBACK, event 0, msg length 0, bvci 0x1012
+00 00 10 12
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1012, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 10 12
+
+result (UNITDATA) = 4
+
+--- Send message from SGSN to BSS 1, BVCI 0x1012 ---
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 10 12
+
+CALLBACK, event 0, msg length 0, bvci 0x1012
+00 00 10 12
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1012, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 4
+00 00 10 12
+
+result (UNITDATA) = 4
+
+--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 10 12
+
+CALLBACK, event 0, msg length 0, bvci 0x1012
+00 00 10 12
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1012, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 10 12
+
+result (UNITDATA) = 4
+
+--- Send message from SGSN to BSS 1, BVCI 0x1002 ---
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 10 12
+
+CALLBACK, event 0, msg length 0, bvci 0x1012
+00 00 10 12
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1012, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 4
+00 00 10 12
+
+result (UNITDATA) = 4
+
+--- Send message from BSS 2 to SGSN, BVCI 0x2002 ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 20 02
+
+CALLBACK, event 0, msg length 0, bvci 0x2002
+00 00 20 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x2002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 20 02
+
+result (UNITDATA) = 4
+
+--- Send message from SGSN to BSS 2, BVCI 0x2002 ---
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 20 02
+
+CALLBACK, event 0, msg length 0, bvci 0x2002
+00 00 20 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x2002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:3333, msg length 4
+00 00 20 02
+
+result (UNITDATA) = 4
+
+--- Reset BSS 1 with the old BVCI on BSS2's link ---
+
+Setup BSSGP: remote 0x01020304:3333, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:3333
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:3333
+ NS-VC replaced other count: 1
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 4096, BVCI 4114, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+Gbproxy global:
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:3333, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 10 12
+
+CALLBACK, event 0, msg length 0, bvci 0x1012
+00 00 10 12
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1012, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 10 12
+
+result (UNITDATA) = 4
+
+--- Send message from SGSN to BSS 1, BVCI 0x1002 ---
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 10 12
+
+CALLBACK, event 0, msg length 0, bvci 0x1012
+00 00 10 12
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1012, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 4
+00 00 10 12
+
+result (UNITDATA) = 4
+
+--- Send message from SGSN to BSS 1, BVCI 0x10ff (invalid) ---
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 10 ff
+
+CALLBACK, event 0, msg length 0, bvci 0x10ff
+00 00 10 ff
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 10 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 14
+00 00 00 00 41 07 81 05 04 82 10 ff 15 80
+
+result (UNITDATA) = 14
+
+Peers:
+ NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+Gbproxy global:
+ Invalid BVC Identifier : 1
+=== test_gbproxy_ident_changes ===
+--- Initialise SGSN ---
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 12
+02 00 81 01 01 82 01 01 04 82 01 00
+
+PROCESSING RESET_ACK from 0x05060708:32000
+03 01 82 01 01 04 82 01 00
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0a
+
+result (RESET_ACK) = 1
+
+PROCESSING ALIVE_ACK from 0x05060708:32000
+0b
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+06
+
+result (ALIVE_ACK) = 1
+
+PROCESSING UNBLOCK_ACK from 0x05060708:32000
+07
+
+==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000
+
+result (UNBLOCK_ACK) = 0
+
+PROCESSING ALIVE from 0x05060708:32000
+0a
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0b
+
+result (ALIVE) = 1
+
+Current NS-VCIs:
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+--- Initialise BSS 1 ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+--- Setup BVCI 1 ---
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+--- Setup BVCI 2 ---
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x2002(8194)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 20 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 20 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 20 02
+
+result (BVC_RESET_ACK) = 9
+
+Peers:
+ NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+--- Send message from BSS 1 to SGSN and back, BVCI 1 ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 10 02
+
+CALLBACK, event 0, msg length 0, bvci 0x1002
+00 00 10 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 10 02
+
+result (UNITDATA) = 4
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 10 02
+
+CALLBACK, event 0, msg length 0, bvci 0x1002
+00 00 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 4
+00 00 10 02
+
+result (UNITDATA) = 4
+
+--- Send message from BSS 1 to SGSN and back, BVCI 2 ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 20 02
+
+CALLBACK, event 0, msg length 0, bvci 0x2002
+00 00 20 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x2002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 20 02
+
+result (UNITDATA) = 4
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 20 02
+
+CALLBACK, event 0, msg length 0, bvci 0x2002
+00 00 20 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x2002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 4
+00 00 20 02
+
+result (UNITDATA) = 4
+
+--- Change NSEI ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 20 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 20 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+ VCI 0x1001, NSEI 0x2000, peer 0x01020304:1111
+ NS-VC changed NSEI count : 1
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+--- Setup BVCI 1 ---
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+Peers:
+ NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+--- Setup BVCI 3 ---
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x3002(12290)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 30 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 30 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 30 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 30 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 30 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 30 02
+
+result (BVC_RESET_ACK) = 9
+
+Peers:
+ NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+--- Send message from BSS 1 to SGSN and back, BVCI 1 ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 10 02
+
+CALLBACK, event 0, msg length 0, bvci 0x1002
+00 00 10 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 10 02
+
+result (UNITDATA) = 4
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 10 02
+
+CALLBACK, event 0, msg length 0, bvci 0x1002
+00 00 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 4
+00 00 10 02
+
+result (UNITDATA) = 4
+
+--- Send message from BSS 1 to SGSN and back, BVCI 2 (should fail) ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 20 02
+
+CALLBACK, event 0, msg length 0, bvci 0x2002
+00 00 20 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x2002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 20 02
+
+result (UNITDATA) = 4
+
+Peers:
+ NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 20 02
+
+CALLBACK, event 0, msg length 0, bvci 0x2002
+00 00 20 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x2002, msg length 0 (gprs_ns_sendmsg)
+result (UNITDATA) = -22
+
+Peers:
+ NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ NS Transmission error : 1
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+--- Send message from BSS 1 to SGSN and back, BVCI 3 ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 30 02
+
+CALLBACK, event 0, msg length 0, bvci 0x3002
+00 00 30 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x3002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 30 02
+
+result (UNITDATA) = 4
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 30 02
+
+CALLBACK, event 0, msg length 0, bvci 0x3002
+00 00 30 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x3002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 4
+00 00 30 02
+
+result (UNITDATA) = 4
+
+--- Change NSVCI ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x2001(8193), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 20 01 04 82 20 00
+
+==> got signal NS_REPLACED: 0x2001/0.0.0.0:0 -> 0x1001/1.2.3.4:1111
+
+==> got signal NS_RESET, NS-VC 0x2001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 20 01 04 82 20 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x2001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+ VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111
+ NS-VC replaced other count: 1
+ VCI 0x1001, NSEI 0x2000, peer 0x00000000:0
+ NS-VC changed NSEI count : 1
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+--- Setup BVCI 1 ---
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+Peers:
+ NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ NS Transmission error : 1
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+--- Setup BVCI 4 ---
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x4002(16386)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 40 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 40 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 40 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 40 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 40 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 40 02
+
+result (BVC_RESET_ACK) = 9
+
+Peers:
+ NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ NS Transmission error : 1
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+--- Send message from BSS 1 to SGSN and back, BVCI 1 ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 10 02
+
+CALLBACK, event 0, msg length 0, bvci 0x1002
+00 00 10 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 10 02
+
+result (UNITDATA) = 4
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 10 02
+
+CALLBACK, event 0, msg length 0, bvci 0x1002
+00 00 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 4
+00 00 10 02
+
+result (UNITDATA) = 4
+
+--- Send message from BSS 1 to SGSN and back, BVCI 2 (should fail) ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 20 02
+
+CALLBACK, event 0, msg length 0, bvci 0x2002
+00 00 20 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x2002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 20 02
+
+result (UNITDATA) = 4
+
+Peers:
+ NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 2
+ NS Transmission error : 1
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 20 02
+
+CALLBACK, event 0, msg length 0, bvci 0x2002
+00 00 20 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x2002, msg length 0 (gprs_ns_sendmsg)
+result (UNITDATA) = -22
+
+Peers:
+ NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 2
+ NS Transmission error : 2
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+--- Send message from BSS 1 to SGSN and back, BVCI 3 ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 30 02
+
+CALLBACK, event 0, msg length 0, bvci 0x3002
+00 00 30 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x3002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 30 02
+
+result (UNITDATA) = 4
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 30 02
+
+CALLBACK, event 0, msg length 0, bvci 0x3002
+00 00 30 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x3002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 4
+00 00 30 02
+
+result (UNITDATA) = 4
+
+--- Send message from BSS 1 to SGSN and back, BVCI 4 ---
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 40 02
+
+CALLBACK, event 0, msg length 0, bvci 0x4002
+00 00 40 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x4002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 4
+00 00 40 02
+
+result (UNITDATA) = 4
+
+PROCESSING UNITDATA from 0x05060708:32000
+00 00 40 02
+
+CALLBACK, event 0, msg length 0, bvci 0x4002
+00 00 40 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x4002, msg length 0 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 4
+00 00 40 02
+
+result (UNITDATA) = 4
+
+Gbproxy global:
+Peers:
+ NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+ NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 2
+ NS Transmission error : 2
+ TLLI-Cache: 0
+ NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
+ NSEI mismatch : 1
+ TLLI-Cache: 0
+=== Test IMSI/TMSI matching ===
+
+=== test_gbproxy_ptmsi_assignment ===
+--- Initialise SGSN ---
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 12
+02 00 81 01 01 82 01 01 04 82 01 00
+
+PROCESSING RESET_ACK from 0x05060708:32000
+03 01 82 01 01 04 82 01 00
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0a
+
+result (RESET_ACK) = 1
+
+PROCESSING ALIVE_ACK from 0x05060708:32000
+0b
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+06
+
+result (ALIVE_ACK) = 1
+
+PROCESSING UNBLOCK_ACK from 0x05060708:32000
+07
+
+==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000
+
+result (UNBLOCK_ACK) = 0
+
+PROCESSING ALIVE from 0x05060708:32000
+0a
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0b
+
+result (ALIVE) = 1
+
+--- Initialise BSS 1 ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+Current NS-VCIs:
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Gbproxy global:
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+--- Establish first LLC connection ---
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+result (ATTACH REQUEST) = 79
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 8000dead, IMSI (none), AGE 0
+PROCESSING IDENT REQUEST from 0x05060708:32000
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+CALLBACK, event 0, msg length 23, bvci 0x1002
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 23 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 27
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+result (IDENT REQUEST) = 27
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 8000dead, IMSI (none), AGE 0
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 44
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+result (IDENT RESPONSE) = 44
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 8000dead, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ Attach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/efe2b700 -> 8000dead/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 09 08 03 39 d7 bc
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 09 08 03 39 d7 bc
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 09 08 03 39 d7 bc
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/efe2b700 -> 8000dead/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+--- Establish second LLC connection with the same P-TMSI ---
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 0d 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 46 42 6e
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 0d 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 46 42 6e
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 0d 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 46 42 6e
+
+result (ATTACH REQUEST) = 79
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 2
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI 8000beef -> 8000beef, IMSI (none), AGE 0
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING IDENT REQUEST from 0x05060708:32000
+00 00 10 02 00 80 00 be ef 00 50 20 16 82 02 58 0e 89 41 c0 0d 08 15 01 0c a6 18
+
+CALLBACK, event 0, msg length 23, bvci 0x1002
+00 00 10 02 00 80 00 be ef 00 50 20 16 82 02 58 0e 89 41 c0 0d 08 15 01 0c a6 18
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 23 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 27
+00 00 10 02 00 80 00 be ef 00 50 20 16 82 02 58 0e 89 41 c0 0d 08 15 01 0c a6 18
+
+result (IDENT REQUEST) = 27
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 2
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI 8000beef -> 8000beef, IMSI (none), AGE 0
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 11 08 16 08 11 12 99 99 99 16 17 18 bf d2 01
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 11 08 16 08 11 12 99 99 99 16 17 18 bf d2 01
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 44
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 11 08 16 08 11 12 99 99 99 16 17 18 bf d2 01
+
+result (IDENT RESPONSE) = 44
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 2
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI 8000beef -> 8000beef, IMSI 12199999961718, AGE 0
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 80 00 be ef 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 9e 41 c0 11 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 3a 6d d4
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 80 00 be ef 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 9e 41 c0 11 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 3a 6d d4
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 80 00 be ef 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 9e 41 c0 11 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 3a 6d d4
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000beef/efe2b700 -> 8000beef/efe2b700, IMSI 12199999961718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 15 08 03 86 ac 47
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 15 08 03 86 ac 47
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 15 08 03 86 ac 47
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000beef/efe2b700 -> 8000beef/efe2b700, IMSI 12199999961718, AGE 0
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 88 41 c0 15 08 21 bb c1 c6
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 88 41 c0 15 08 21 bb c1 c6
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 88 41 c0 15 08 21 bb c1 c6
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12199999961718, AGE 0
+Gbproxy global:
+=== test_gbproxy_ra_patching ===
+--- Initialise SGSN ---
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 12
+02 00 81 01 01 82 01 01 04 82 01 00
+
+PROCESSING RESET_ACK from 0x05060708:32000
+03 01 82 01 01 04 82 01 00
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0a
+
+result (RESET_ACK) = 1
+
+PROCESSING ALIVE_ACK from 0x05060708:32000
+0b
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+06
+
+result (ALIVE_ACK) = 1
+
+PROCESSING UNBLOCK_ACK from 0x05060708:32000
+07
+
+==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000
+
+result (UNBLOCK_ACK) = 0
+
+PROCESSING ALIVE from 0x05060708:32000
+0a
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0b
+
+result (ALIVE) = 1
+
+Current NS-VCIs:
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+--- Initialise BSS 1 ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 21 63 54 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+Current NS-VCIs:
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 1
+ TLLI-Cache: 0
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+PROCESSING BVC_SUSPEND from 0x01020304:1111
+00 00 00 00 0b 1f 84 cc d1 75 8b 1b 86 11 22 33 40 50 60
+
+CALLBACK, event 0, msg length 15, bvci 0x0000
+00 00 00 00 0b 1f 84 cc d1 75 8b 1b 86 11 22 33 40 50 60
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 15 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 19
+00 00 00 00 0b 1f 84 cc d1 75 8b 1b 86 21 63 54 40 50 60
+
+result (BVC_SUSPEND) = 19
+
+PROCESSING BVC_SUSPEND_ACK from 0x05060708:32000
+00 00 00 00 0c 1f 84 cc d1 75 8b 1b 86 21 63 54 40 50 60 1d 81 01
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 0c 1f 84 cc d1 75 8b 1b 86 21 63 54 40 50 60 1d 81 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 22
+00 00 00 00 0c 1f 84 cc d1 75 8b 1b 86 11 22 33 40 50 60 1d 81 01
+
+result (BVC_SUSPEND_ACK) = 22
+
+Gbproxy global:
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 2
+ RAID patched (SGSN): 1
+ TLLI from SGSN unknown : 1
+ TLLI-Cache: 0
+--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 bb c5 46 79 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 bb c5 46 79 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 bb c5 46 79 00 00 04 08 88 21 63 54 40 50 60 75 30 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 21 63 54 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 8e cd 32
+
+result (ATTACH REQUEST) = 79
+
+PROCESSING IDENT REQUEST from 0x05060708:32000
+00 00 10 02 00 bb c5 46 79 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+CALLBACK, event 0, msg length 23, bvci 0x1002
+00 00 10 02 00 bb c5 46 79 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 23 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 27
+00 00 10 02 00 bb c5 46 79 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+result (IDENT REQUEST) = 27
+
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 bb c5 46 79 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 11 01 c0 0d 08 16 08 11 12 13 14 15 16 17 18 b7 1b 9a
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 bb c5 46 79 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 11 01 c0 0d 08 16 08 11 12 13 14 15 16 17 18 b7 1b 9a
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 44
+00 00 10 02 01 bb c5 46 79 00 00 04 08 88 21 63 54 40 50 60 75 30 00 80 0e 00 11 01 c0 0d 08 16 08 11 12 13 14 15 16 17 18 b7 1b 9a
+
+result (IDENT RESPONSE) = 44
+
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 bb c5 46 79 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 bb c5 46 79 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 bb c5 46 79 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 11 22 33 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 be 38 c0
+
+result (ATTACH ACCEPT) = 92
+
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 08 01 c0 11 08 03 ea 67 11
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 08 01 c0 11 08 03 ea 67 11
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 75 30 00 80 0e 00 08 01 c0 11 08 03 ea 67 11
+
+result (ATTACH COMPLETE) = 35
+
+PROCESSING ACT PDP CTX REQ (REPLACE APN) from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+CALLBACK, event 0, msg length 76, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 81 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 85
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 75 30 00 80 0e 00 3a 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 08 03 66 6f 6f 03 62 61 72 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 24 9d 75
+
+result (ACT PDP CTX REQ (REPLACE APN)) = 85
+
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+result (GMM INFO) = 70
+
+PROCESSING ACT PDP CTX REQ (REPLACE APN) from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+CALLBACK, event 0, msg length 76, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 81 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 85
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 75 30 00 80 0e 00 3a 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 08 03 66 6f 6f 03 62 61 72 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 24 9d 75
+
+result (ACT PDP CTX REQ (REPLACE APN)) = 85
+
+PROCESSING ACT PDP CTX REQ (REMOVE APN) from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+CALLBACK, event 0, msg length 76, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 71 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 75
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 75 30 00 80 0e 00 30 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 85 fa 60
+
+result (ACT PDP CTX REQ (REMOVE APN)) = 75
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 9
+ RAID patched (SGSN): 2
+ APN patched : 3
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ PDP Activation Request count : 3
+ TLLI from SGSN unknown : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0, IMSI matches
+PROCESSING DETACH REQ from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 15 01 c0 19 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 7e e1 41
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 15 01 c0 19 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 7e e1 41
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 44 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 48
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 75 30 00 80 0e 00 15 01 c0 19 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 7e e1 41
+
+result (DETACH REQ) = 48
+
+PROCESSING DETACH ACC from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 15 08 06 00 f7 35 f0
+
+CALLBACK, event 0, msg length 67, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 15 08 06 00 f7 35 f0
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 67 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 71
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 15 08 06 00 f7 35 f0
+
+result (DETACH ACC) = 71
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 10
+ RAID patched (SGSN): 2
+ APN patched : 3
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ PDP Activation Request count : 3
+ TLLI from SGSN unknown : 1
+ TLLI-Cache: 0
+--- RA update ---
+
+PROCESSING RA UPD REQ from 0x01020304:1111
+00 00 10 02 01 bb c5 46 79 00 00 04 08 88 11 22 33 40 50 60 70 80 00 80 0e 00 3e 01 c0 15 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 96 3e 97
+
+CALLBACK, event 0, msg length 85, bvci 0x1002
+00 00 10 02 01 bb c5 46 79 00 00 04 08 88 11 22 33 40 50 60 70 80 00 80 0e 00 3e 01 c0 15 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 96 3e 97
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 85 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 89
+00 00 10 02 01 bb c5 46 79 00 00 04 08 88 21 63 54 40 50 60 70 80 00 80 0e 00 3e 01 c0 15 08 08 10 21 63 54 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 1d f0 41
+
+result (RA UPD REQ) = 89
+
+PROCESSING RA UPD ACC from 0x05060708:32000
+00 00 10 02 00 bb c5 46 79 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 19 08 09 00 49 21 63 54 40 50 60 19 54 ab b3 18 05 f4 ef e2 b7 00 17 16 d7 59 65
+
+CALLBACK, event 0, msg length 87, bvci 0x1002
+00 00 10 02 00 bb c5 46 79 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 19 08 09 00 49 21 63 54 40 50 60 19 54 ab b3 18 05 f4 ef e2 b7 00 17 16 d7 59 65
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 87 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 91
+00 00 10 02 00 bb c5 46 79 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 19 08 09 00 49 11 22 33 40 50 60 19 54 ab b3 18 05 f4 ef e2 b7 00 17 16 3a 03 54
+
+result (RA UPD ACC) = 91
+
+PROCESSING ACT PDP CTX REQ (REMOVE APN) from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+CALLBACK, event 0, msg length 76, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 71 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 75
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 75 30 00 80 0e 00 30 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 85 fa 60
+
+result (ACT PDP CTX REQ (REMOVE APN)) = 75
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 13
+ RAID patched (SGSN): 3
+ APN patched : 4
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 1
+ RoutingArea Update Accept count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ PDP Activation Request count : 4
+ TLLI from SGSN unknown : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI bbc54679/efe2b700 -> bbc54679/efe2b700, IMSI 12131415161718, AGE 0, IMSI matches
+PROCESSING DETACH REQ (PWR OFF) from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 15 01 c0 19 08 05 09 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 84 0c eb
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 15 01 c0 19 08 05 09 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 84 0c eb
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 44 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 48
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 75 30 00 80 0e 00 15 01 c0 19 08 05 09 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 84 0c eb
+
+result (DETACH REQ (PWR OFF)) = 48
+
+Gbproxy global:
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 14
+ RAID patched (SGSN): 3
+ APN patched : 4
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 1
+ RoutingArea Update Accept count : 1
+ Detach Request count : 2
+ Detach Accept count : 1
+ PDP Activation Request count : 4
+ TLLI from SGSN unknown : 1
+ TLLI-Cache: 0
+--- Bad cases ---
+
+PROCESSING ATTACH REQUEST (foreign RAI) from 0x01020304:1111
+00 00 10 02 01 bb 00 be ef 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb 00 be ef 99 99 99 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 2d c7 df
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 bb 00 be ef 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb 00 be ef 99 99 99 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 2d c7 df
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 bb 00 be ef 00 00 04 08 88 21 63 54 40 50 60 75 30 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb 00 be ef 99 99 99 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 2d c7 df
+
+result (ATTACH REQUEST (foreign RAI)) = 79
+
+TLLI is already detached, shouldn't patch
+PROCESSING ACT PDP CTX REQ from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+CALLBACK, event 0, msg length 76, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 76 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 80
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 75 30 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+result (ACT PDP CTX REQ) = 80
+
+Invalid RAI, shouldn't patch
+PROCESSING BVC_SUSPEND_ACK from 0x05060708:32000
+00 00 00 00 0c 1f 84 cc d1 75 8b 1b 86 00 f1 99 00 63 60 1d 81 01
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 0c 1f 84 cc d1 75 8b 1b 86 00 f1 99 00 63 60 1d 81 01
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 28
+00 00 00 00 41 07 81 21 15 92 0c 1f 84 cc d1 75 8b 1b 86 00 f1 99 00 63 60 1d 81 01
+
+result (BVC_SUSPEND_ACK) = 28
+
+Gbproxy global:
+ Invalid Routing Area Identifier : 1
+ Patch error: no peer : 1
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 16
+ RAID patched (SGSN): 3
+ APN patched : 4
+ Attach Request count : 2
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 1
+ RoutingArea Update Accept count : 1
+ Detach Request count : 2
+ Detach Accept count : 1
+ PDP Activation Request count : 5
+ TLLI from SGSN unknown : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI efe2b700 -> efe2b700, IMSI (none), AGE 0
+ TLLI bb00beef -> bb00beef, IMSI (none), AGE 0
+=== test_gbproxy_ptmsi_patching ===
+--- Initialise SGSN ---
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 12
+02 00 81 01 01 82 01 01 04 82 01 00
+
+PROCESSING RESET_ACK from 0x05060708:32000
+03 01 82 01 01 04 82 01 00
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0a
+
+result (RESET_ACK) = 1
+
+PROCESSING ALIVE_ACK from 0x05060708:32000
+0b
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+06
+
+result (ALIVE_ACK) = 1
+
+PROCESSING UNBLOCK_ACK from 0x05060708:32000
+07
+
+==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000
+
+result (UNBLOCK_ACK) = 0
+
+PROCESSING ALIVE from 0x05060708:32000
+0a
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0b
+
+result (ALIVE) = 1
+
+--- Initialise BSS 1 ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 21 63 54 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+Current NS-VCIs:
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Gbproxy global:
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 1
+ TLLI-Cache: 0
+--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 78 de ad 00 00 00 04 08 88 21 63 54 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+result (ATTACH REQUEST) = 79
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 2
+ TLLI patched (BSS ): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI (none), AGE 0
+PROCESSING IDENT REQUEST from 0x05060708:32000
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+CALLBACK, event 0, msg length 23, bvci 0x1002
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 23 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 27
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+result (IDENT REQUEST) = 27
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 2
+ TLLI patched (BSS ): 1
+ TLLI patched (SGSN): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI (none), AGE 0
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 44
+00 00 10 02 01 78 de ad 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+result (IDENT RESPONSE) = 44
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 3
+ TLLI patched (BSS ): 2
+ TLLI patched (SGSN): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 11 22 33 40 50 60 19 cd d7 08 17 16 18 05 f4 c0 de ad 01 0c 0a 29
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 3
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 2
+ TLLI patched (SGSN): 2
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/c0dead01 -> 78dead00/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 09 08 03 39 d7 bc
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 09 08 03 39 d7 bc
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 08 01 c0 09 08 03 39 d7 bc
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 4
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 3
+ TLLI patched (SGSN): 2
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/c0dead01 -> 78dead00/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 4
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 3
+ TLLI patched (SGSN): 3
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ACT PDP CTX REQ (REPLACE APN) from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+CALLBACK, event 0, msg length 76, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 81 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 85
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 3a 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 08 03 66 6f 6f 03 62 61 72 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 24 9d 75
+
+result (ACT PDP CTX REQ (REPLACE APN)) = 85
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 5
+ RAID patched (SGSN): 1
+ APN patched : 1
+ TLLI patched (BSS ): 4
+ TLLI patched (SGSN): 3
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ PDP Activation Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING XID (UL) from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+CALLBACK, event 0, msg length 38, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 38 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 42
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+result (XID (UL)) = 42
+
+PROCESSING XID (DL) from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+CALLBACK, event 0, msg length 70, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 70 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 74
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+result (XID (DL)) = 74
+
+PROCESSING LL11 DNS QUERY (UL) from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+CALLBACK, event 0, msg length 89, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 89 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 93
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+result (LL11 DNS QUERY (UL)) = 93
+
+PROCESSING LL11 DNS RESP (DL) from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+CALLBACK, event 0, msg length 267, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 267 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 271
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+result (LL11 DNS RESP (DL)) = 271
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 7
+ RAID patched (SGSN): 1
+ APN patched : 1
+ TLLI patched (BSS ): 6
+ TLLI patched (SGSN): 5
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ PDP Activation Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING RA UPD REQ (P-TMSI 2) from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 70 80 00 80 0e 00 3e 01 c0 11 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 e2 6d 78
+
+CALLBACK, event 0, msg length 85, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 70 80 00 80 0e 00 3e 01 c0 11 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 e2 6d 78
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 85 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 89
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 70 80 00 80 0e 00 3e 01 c0 11 08 08 10 21 63 54 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 69 a3 ae
+
+result (RA UPD REQ (P-TMSI 2)) = 89
+
+PROCESSING RA UDP ACC (P-TMSI 2) from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 0d 08 09 00 49 21 63 54 40 50 60 19 54 ab b3 18 05 f4 e0 98 76 54 17 16 9f e8 ea
+
+CALLBACK, event 0, msg length 87, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 0d 08 09 00 49 21 63 54 40 50 60 19 54 ab b3 18 05 f4 e0 98 76 54 17 16 9f e8 ea
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 87 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 91
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 0d 08 09 00 49 11 22 33 40 50 60 19 54 ab b3 18 05 f4 c0 de ad 02 17 16 bb 4d a0
+
+result (RA UDP ACC (P-TMSI 2)) = 91
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 9
+ RAID patched (SGSN): 2
+ APN patched : 1
+ TLLI patched (BSS ): 7
+ TLLI patched (SGSN): 6
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 1
+ RoutingArea Update Accept count : 1
+ PDP Activation Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01/c0dead02 -> efe2b700/e0987654, IMSI 12131415161718, AGE 0
+PROCESSING RA UPD REQ (P-TMSI 3) from 0x01020304:1111
+00 00 10 02 01 c0 de ad 02 00 00 04 08 88 11 22 33 40 50 60 70 80 00 80 0e 00 3e 01 c0 15 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 96 3e 97
+
+CALLBACK, event 0, msg length 85, bvci 0x1002
+00 00 10 02 01 c0 de ad 02 00 00 04 08 88 11 22 33 40 50 60 70 80 00 80 0e 00 3e 01 c0 15 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 96 3e 97
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 85 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 89
+00 00 10 02 01 e0 98 76 54 00 00 04 08 88 21 63 54 40 50 60 70 80 00 80 0e 00 3e 01 c0 15 08 08 10 21 63 54 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 1d f0 41
+
+result (RA UPD REQ (P-TMSI 3)) = 89
+
+PROCESSING RA UDP ACC (P-TMSI 3) from 0x05060708:32000
+00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 11 08 09 00 49 21 63 54 40 50 60 19 54 ab b3 18 05 f4 e0 54 32 10 17 16 1b a3 a8
+
+CALLBACK, event 0, msg length 87, bvci 0x1002
+00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 11 08 09 00 49 21 63 54 40 50 60 19 54 ab b3 18 05 f4 e0 54 32 10 17 16 1b a3 a8
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 87 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 91
+00 00 10 02 00 c0 de ad 02 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 11 08 09 00 49 11 22 33 40 50 60 19 54 ab b3 18 05 f4 c0 de ad 03 17 16 6e 58 26
+
+result (RA UDP ACC (P-TMSI 3)) = 91
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 11
+ RAID patched (SGSN): 3
+ APN patched : 1
+ TLLI patched (BSS ): 8
+ TLLI patched (SGSN): 7
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 2
+ RoutingArea Update Accept count : 2
+ PDP Activation Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01/c0dead03 -> efe2b700/e0543210, IMSI 12131415161718, AGE 0
+PROCESSING RA UPD COMPLETE from 0x01020304:1111
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 70 80 00 80 0e 00 08 01 c0 19 08 0a d5 5f 5e
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 70 80 00 80 0e 00 08 01 c0 19 08 0a d5 5f 5e
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 e0 54 32 10 00 00 04 08 88 21 63 54 40 50 60 70 80 00 80 0e 00 08 01 c0 19 08 0a d5 5f 5e
+
+result (RA UPD COMPLETE) = 35
+
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 e0 54 32 10 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 15 08 21 bb c1 c6
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 e0 54 32 10 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 15 08 21 bb c1 c6
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 c0 de ad 03 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 15 08 21 bb c1 c6
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 12
+ RAID patched (SGSN): 3
+ APN patched : 1
+ TLLI patched (BSS ): 9
+ TLLI patched (SGSN): 8
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 2
+ RoutingArea Update Accept count : 2
+ RoutingArea Update Compltd count: 1
+ PDP Activation Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead03 -> e0543210, IMSI 12131415161718, AGE 0
+PROCESSING LLC_DISCARDED from 0x01020304:1111
+00 00 00 00 2c 1f 84 c0 de ad 03 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+CALLBACK, event 0, msg length 19, bvci 0x0000
+00 00 00 00 2c 1f 84 c0 de ad 03 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 19 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 23
+00 00 00 00 2c 1f 84 e0 54 32 10 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+result (LLC_DISCARDED) = 23
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 12
+ RAID patched (SGSN): 3
+ APN patched : 1
+ TLLI patched (BSS ): 10
+ TLLI patched (SGSN): 8
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 2
+ RoutingArea Update Accept count : 2
+ RoutingArea Update Compltd count: 1
+ PDP Activation Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead03 -> e0543210, IMSI 12131415161718, AGE 0
+PROCESSING BVC_SUSPEND from 0x01020304:1111
+00 00 00 00 0b 1f 84 c0 de ad 03 1b 86 11 22 33 40 50 60
+
+CALLBACK, event 0, msg length 15, bvci 0x0000
+00 00 00 00 0b 1f 84 c0 de ad 03 1b 86 11 22 33 40 50 60
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 15 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 19
+00 00 00 00 0b 1f 84 e0 54 32 10 1b 86 21 63 54 40 50 60
+
+result (BVC_SUSPEND) = 19
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 13
+ RAID patched (SGSN): 3
+ APN patched : 1
+ TLLI patched (BSS ): 11
+ TLLI patched (SGSN): 8
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 2
+ RoutingArea Update Accept count : 2
+ RoutingArea Update Compltd count: 1
+ PDP Activation Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead03 -> e0543210, IMSI 12131415161718, AGE 0
+PROCESSING BVC_SUSPEND_ACK from 0x05060708:32000
+00 00 00 00 0c 1f 84 e0 54 32 10 1b 86 21 63 54 40 50 60 1d 81 01
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 0c 1f 84 e0 54 32 10 1b 86 21 63 54 40 50 60 1d 81 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 22
+00 00 00 00 0c 1f 84 c0 de ad 03 1b 86 11 22 33 40 50 60 1d 81 01
+
+result (BVC_SUSPEND_ACK) = 22
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 13
+ RAID patched (SGSN): 4
+ APN patched : 1
+ TLLI patched (BSS ): 11
+ TLLI patched (SGSN): 9
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 2
+ RoutingArea Update Accept count : 2
+ RoutingArea Update Compltd count: 1
+ PDP Activation Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead03 -> e0543210, IMSI 12131415161718, AGE 0
+PROCESSING PAGING_PS from 0x05060708:32000
+00 00 00 00 06 0d 88 11 12 13 14 15 16 17 18 0a 82 07 04 1b 86 11 22 33 40 50 60 18 83 00 00 00 20 84 e0 54 32 10
+
+CALLBACK, event 0, msg length 34, bvci 0x0000
+00 00 00 00 06 0d 88 11 12 13 14 15 16 17 18 0a 82 07 04 1b 86 11 22 33 40 50 60 18 83 00 00 00 20 84 e0 54 32 10
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 34 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 38
+00 00 00 00 06 0d 88 11 12 13 14 15 16 17 18 0a 82 07 04 1b 86 11 22 33 40 50 60 18 83 00 00 00 20 84 c0 de ad 03
+
+result (PAGING_PS) = 38
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 13
+ RAID patched (SGSN): 5
+ APN patched : 1
+ TLLI patched (BSS ): 11
+ TLLI patched (SGSN): 9
+ P-TMSI patched (SGSN): 4
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 2
+ RoutingArea Update Accept count : 2
+ RoutingArea Update Compltd count: 1
+ PDP Activation Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead03 -> e0543210, IMSI 12131415161718, AGE 0
+PROCESSING LLC_DISCARDED from 0x01020304:1111
+00 00 00 00 2c 1f 84 c0 de ad 03 0f 81 01 04 82 ee e1 25 83 00 00 0c
+
+CALLBACK, event 0, msg length 19, bvci 0x0000
+00 00 00 00 2c 1f 84 c0 de ad 03 0f 81 01 04 82 ee e1 25 83 00 00 0c
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 19 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 23
+00 00 00 00 2c 1f 84 e0 54 32 10 0f 81 01 04 82 ee e1 25 83 00 00 0c
+
+result (LLC_DISCARDED) = 23
+
+Gbproxy global:
+PROCESSING BVC_SUSPEND_ACK from 0x05060708:32000
+00 00 00 00 0c 1f 84 e0 54 32 10 1b 86 00 f1 99 00 63 60 1d 81 01
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 0c 1f 84 e0 54 32 10 1b 86 00 f1 99 00 63 60 1d 81 01
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 28
+00 00 00 00 41 07 81 21 15 92 0c 1f 84 e0 54 32 10 1b 86 00 f1 99 00 63 60 1d 81 01
+
+result (BVC_SUSPEND_ACK) = 28
+
+Gbproxy global:
+ Invalid Routing Area Identifier : 1
+ Patch error: no peer : 1
+PROCESSING BVC_SUSPEND_ACK from 0x05060708:32000
+00 00 00 00 0c 1f 84 e0 54 32 10 1b 86 99 69 54 40 50 60 1d 81 01
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 0c 1f 84 e0 54 32 10 1b 86 99 69 54 40 50 60 1d 81 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 22
+00 00 00 00 0c 1f 84 c0 de ad 03 1b 86 11 22 33 40 50 60 1d 81 01
+
+result (BVC_SUSPEND_ACK) = 22
+
+Gbproxy global:
+ Invalid Routing Area Identifier : 1
+ Patch error: no peer : 1
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ee ba db ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 00 83 00 00 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+CALLBACK, event 0, msg length 58, bvci 0x1002
+00 00 10 02 00 ee ba db ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 00 83 00 00 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 58 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 62
+00 00 10 02 00 ee ba db ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 00 83 00 00 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+result (GMM INFO) = 62
+
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ee ba db ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 0d 08 21 68 71 6b
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ee ba db ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 0d 08 21 68 71 6b
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 ee ba db ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 0d 08 21 68 71 6b
+
+result (GMM INFO) = 70
+
+PROCESSING DETACH REQ from 0x01020304:1111
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 1d 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb aa cc a3
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 1d 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb aa cc a3
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 44 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 48
+00 00 10 02 01 e0 54 32 10 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 15 01 c0 1d 08 05 01 18 05 f4 e0 54 32 10 19 03 b9 97 cb ea 6d af
+
+result (DETACH REQ) = 48
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 14
+ RAID patched (SGSN): 6
+ APN patched : 1
+ TLLI patched (BSS ): 13
+ TLLI patched (SGSN): 10
+ P-TMSI patched (BSS ): 1
+ P-TMSI patched (SGSN): 4
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 2
+ RoutingArea Update Accept count : 2
+ RoutingArea Update Compltd count: 1
+ Detach Request count : 1
+ PDP Activation Request count : 1
+ TLLI from SGSN unknown : 2
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead03 -> e0543210, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x05060708:32000
+00 00 10 02 00 e0 54 32 10 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 19 08 06 00 04 ff 52
+
+CALLBACK, event 0, msg length 67, bvci 0x1002
+00 00 10 02 00 e0 54 32 10 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 19 08 06 00 04 ff 52
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 67 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 71
+00 00 10 02 00 c0 de ad 03 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 19 08 06 00 04 ff 52
+
+result (DETACH ACC) = 71
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 14
+ RAID patched (SGSN): 6
+ APN patched : 1
+ TLLI patched (BSS ): 13
+ TLLI patched (SGSN): 11
+ P-TMSI patched (BSS ): 1
+ P-TMSI patched (SGSN): 4
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 2
+ RoutingArea Update Accept count : 2
+ RoutingArea Update Compltd count: 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ PDP Activation Request count : 1
+ TLLI from SGSN unknown : 2
+ TLLI-Cache: 0
+Gbproxy global:
+ Invalid Routing Area Identifier : 1
+ Patch error: no peer : 1
+=== test_gbproxy_ptmsi_patching_bad_cases ===
+--- Initialise SGSN ---
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 12
+02 00 81 01 01 82 01 01 04 82 01 00
+
+PROCESSING RESET_ACK from 0x05060708:32000
+03 01 82 01 01 04 82 01 00
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0a
+
+result (RESET_ACK) = 1
+
+PROCESSING ALIVE_ACK from 0x05060708:32000
+0b
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+06
+
+result (ALIVE_ACK) = 1
+
+PROCESSING UNBLOCK_ACK from 0x05060708:32000
+07
+
+==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000
+
+result (UNBLOCK_ACK) = 0
+
+PROCESSING ALIVE from 0x05060708:32000
+0a
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0b
+
+result (ALIVE) = 1
+
+--- Initialise BSS 1 ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 21 63 54 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+Current NS-VCIs:
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Gbproxy global:
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 1
+ TLLI-Cache: 0
+--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 78 de ad 00 00 00 04 08 88 21 63 54 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+result (ATTACH REQUEST) = 79
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 2
+ TLLI patched (BSS ): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI (none), AGE 0
+PROCESSING IDENT REQUEST from 0x05060708:32000
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+CALLBACK, event 0, msg length 23, bvci 0x1002
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 23 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 27
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+result (IDENT REQUEST) = 27
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 2
+ TLLI patched (BSS ): 1
+ TLLI patched (SGSN): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI (none), AGE 0
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 44
+00 00 10 02 01 78 de ad 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+result (IDENT RESPONSE) = 44
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 3
+ TLLI patched (BSS ): 2
+ TLLI patched (SGSN): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 11 22 33 40 50 60 19 cd d7 08 17 16 18 05 f4 c0 de ad 01 0c 0a 29
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 3
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 2
+ TLLI patched (SGSN): 2
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/c0dead01 -> 78dead00/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT (duplicated) from 0x05060708:32000
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 09 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 1d 9e 24
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 09 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 1d 9e 24
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 09 08 02 01 49 04 11 22 33 40 50 60 19 cd d7 08 17 16 18 05 f4 c0 de ad 01 42 f6 fc
+
+result (ATTACH ACCEPT (duplicated)) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 3
+ RAID patched (SGSN): 2
+ TLLI patched (BSS ): 2
+ TLLI patched (SGSN): 3
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 1
+ Attach Accept count : 2
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/c0dead01 -> 78dead00/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 09 08 03 39 d7 bc
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 09 08 03 39 d7 bc
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 08 01 c0 09 08 03 39 d7 bc
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 4
+ RAID patched (SGSN): 2
+ TLLI patched (BSS ): 3
+ TLLI patched (SGSN): 3
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 1
+ Attach Accept count : 2
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/c0dead01 -> 78dead00/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 0d 08 21 68 71 6b
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 0d 08 21 68 71 6b
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 0d 08 21 68 71 6b
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 4
+ RAID patched (SGSN): 2
+ TLLI patched (BSS ): 3
+ TLLI patched (SGSN): 4
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 1
+ Attach Accept count : 2
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH REQ from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 0d 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 37 67 c6
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 0d 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 37 67 c6
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 44 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 48
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 15 01 c0 0d 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 37 67 c6
+
+result (DETACH REQ) = 48
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 5
+ RAID patched (SGSN): 2
+ TLLI patched (BSS ): 4
+ TLLI patched (SGSN): 4
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 1
+ Attach Accept count : 2
+ Attach Completed count : 1
+ Detach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 11 08 06 00 cf 8a 58
+
+CALLBACK, event 0, msg length 67, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 11 08 06 00 cf 8a 58
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 67 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 71
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 11 08 06 00 cf 8a 58
+
+result (DETACH ACC) = 71
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 5
+ RAID patched (SGSN): 2
+ TLLI patched (BSS ): 4
+ TLLI patched (SGSN): 5
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 1
+ Attach Accept count : 2
+ Attach Completed count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI-Cache: 0
+Gbproxy global:
+=== test_gbproxy_imsi_acquisition ===
+--- Initialise SGSN ---
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 12
+02 00 81 01 01 82 01 01 04 82 01 00
+
+PROCESSING RESET_ACK from 0x05060708:32000
+03 01 82 01 01 04 82 01 00
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0a
+
+result (RESET_ACK) = 1
+
+PROCESSING ALIVE_ACK from 0x05060708:32000
+0b
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+06
+
+result (ALIVE_ACK) = 1
+
+PROCESSING UNBLOCK_ACK from 0x05060708:32000
+07
+
+==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000
+
+result (UNBLOCK_ACK) = 0
+
+PROCESSING ALIVE from 0x05060708:32000
+0a
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0b
+
+result (ALIVE) = 1
+
+--- Initialise BSS 1 ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 21 63 54 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+Current NS-VCIs:
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Gbproxy global:
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 1
+ TLLI-Cache: 0
+--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (ATTACH REQUEST) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI (none), AGE 0, STORED 1, IMSI acquisition in progress
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 78 de ad 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 21 63 54 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 8e cd 32
+
+result (IDENT RESPONSE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 3
+ TLLI patched (BSS ): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI 12131415161718, AGE 0
+PROCESSING IDENT REQUEST from 0x05060708:32000
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+CALLBACK, event 0, msg length 23, bvci 0x1002
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 23 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 27
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+result (IDENT REQUEST) = 27
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 3
+ TLLI patched (BSS ): 1
+ TLLI patched (SGSN): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI 12131415161718, AGE 0
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 09 08 16 08 11 12 13 14 15 16 17 18 ba 14 c3
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 09 08 16 08 11 12 13 14 15 16 17 18 ba 14 c3
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 44
+00 00 10 02 01 78 de ad 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 11 01 c0 09 08 16 08 11 12 13 14 15 16 17 18 ba 14 c3
+
+result (IDENT RESPONSE) = 44
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 4
+ TLLI patched (BSS ): 2
+ TLLI patched (SGSN): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 11 22 33 40 50 60 19 cd d7 08 17 16 18 05 f4 c0 de ad 01 0c 0a 29
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 4
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 2
+ TLLI patched (SGSN): 2
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/c0dead01 -> 78dead00/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 0d 08 03 55 1c ea
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 0d 08 03 55 1c ea
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 08 01 c0 0d 08 03 55 1c ea
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 5
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 3
+ TLLI patched (SGSN): 2
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/c0dead01 -> 78dead00/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 5
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 3
+ TLLI patched (SGSN): 3
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING XID (UL) from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+CALLBACK, event 0, msg length 38, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 38 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 42
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+result (XID (UL)) = 42
+
+PROCESSING XID (DL) from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+CALLBACK, event 0, msg length 70, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 70 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 74
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+result (XID (DL)) = 74
+
+PROCESSING LL11 DNS QUERY (UL) from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+CALLBACK, event 0, msg length 89, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 89 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 93
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+result (LL11 DNS QUERY (UL)) = 93
+
+PROCESSING LL11 DNS RESP (DL) from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+CALLBACK, event 0, msg length 267, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 267 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 271
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+result (LL11 DNS RESP (DL)) = 271
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 7
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 5
+ TLLI patched (SGSN): 5
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING LLC_DISCARDED from 0x01020304:1111
+00 00 00 00 2c 1f 84 c0 de ad 01 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+CALLBACK, event 0, msg length 19, bvci 0x0000
+00 00 00 00 2c 1f 84 c0 de ad 01 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 19 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 23
+00 00 00 00 2c 1f 84 ef e2 b7 00 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+result (LLC_DISCARDED) = 23
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 7
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 6
+ TLLI patched (SGSN): 5
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING LLC_DISCARDED from 0x05060708:32000
+00 00 00 00 2c 1f 84 ef e2 b7 00 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+CALLBACK, event 0, msg length 19, bvci 0x0000
+00 00 00 00 2c 1f 84 ef e2 b7 00 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 25 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 29
+00 00 00 00 41 07 81 27 15 93 2c 1f 84 ef e2 b7 00 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+result (LLC_DISCARDED) = 29
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 7
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 6
+ TLLI patched (SGSN): 6
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING BVC_SUSPEND from 0x01020304:1111
+00 00 00 00 0b 1f 84 c0 de ad 01 1b 86 11 22 33 40 50 60
+
+CALLBACK, event 0, msg length 15, bvci 0x0000
+00 00 00 00 0b 1f 84 c0 de ad 01 1b 86 11 22 33 40 50 60
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 15 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 19
+00 00 00 00 0b 1f 84 ef e2 b7 00 1b 86 21 63 54 40 50 60
+
+result (BVC_SUSPEND) = 19
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 8
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 7
+ TLLI patched (SGSN): 6
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING BVC_SUSPEND_ACK from 0x05060708:32000
+00 00 00 00 0c 1f 84 ef e2 b7 00 1b 86 21 63 54 40 50 60 1d 81 01
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 0c 1f 84 ef e2 b7 00 1b 86 21 63 54 40 50 60 1d 81 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 22
+00 00 00 00 0c 1f 84 c0 de ad 01 1b 86 11 22 33 40 50 60 1d 81 01
+
+result (BVC_SUSPEND_ACK) = 22
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 8
+ RAID patched (SGSN): 2
+ TLLI patched (BSS ): 7
+ TLLI patched (SGSN): 7
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING LLC_DISCARDED from 0x01020304:1111
+00 00 00 00 2c 1f 84 c0 de ad 01 0f 81 01 04 82 ee e1 25 83 00 00 0c
+
+CALLBACK, event 0, msg length 19, bvci 0x0000
+00 00 00 00 2c 1f 84 c0 de ad 01 0f 81 01 04 82 ee e1 25 83 00 00 0c
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 19 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 23
+00 00 00 00 2c 1f 84 ef e2 b7 00 0f 81 01 04 82 ee e1 25 83 00 00 0c
+
+result (LLC_DISCARDED) = 23
+
+Gbproxy global:
+ BSSGP protocol error (SGSN): 1
+PROCESSING BVC_SUSPEND_ACK from 0x05060708:32000
+00 00 00 00 0c 1f 84 ef e2 b7 00 1b 86 00 f1 99 00 63 60 1d 81 01
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 0c 1f 84 ef e2 b7 00 1b 86 00 f1 99 00 63 60 1d 81 01
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 28
+00 00 00 00 41 07 81 21 15 92 0c 1f 84 ef e2 b7 00 1b 86 00 f1 99 00 63 60 1d 81 01
+
+result (BVC_SUSPEND_ACK) = 28
+
+Gbproxy global:
+ Invalid Routing Area Identifier : 1
+ BSSGP protocol error (SGSN): 1
+ Patch error: no peer : 1
+PROCESSING BVC_SUSPEND_ACK from 0x05060708:32000
+00 00 00 00 0c 1f 84 ef e2 b7 00 1b 86 99 69 54 40 50 60 1d 81 01
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 0c 1f 84 ef e2 b7 00 1b 86 99 69 54 40 50 60 1d 81 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 22
+00 00 00 00 0c 1f 84 c0 de ad 01 1b 86 11 22 33 40 50 60 1d 81 01
+
+result (BVC_SUSPEND_ACK) = 22
+
+Gbproxy global:
+ Invalid Routing Area Identifier : 1
+ BSSGP protocol error (SGSN): 1
+ Patch error: no peer : 1
+PROCESSING DETACH REQ from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 11 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 6d b1 de
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 11 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 6d b1 de
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 44 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 48
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 15 01 c0 11 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 6d b1 de
+
+result (DETACH REQ) = 48
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 9
+ RAID patched (SGSN): 3
+ TLLI patched (BSS ): 9
+ TLLI patched (SGSN): 8
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ Detach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 0d 08 06 00 aa ab ee
+
+CALLBACK, event 0, msg length 67, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 0d 08 06 00 aa ab ee
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 67 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 71
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 0d 08 06 00 aa ab ee
+
+result (DETACH ACC) = 71
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 9
+ RAID patched (SGSN): 3
+ TLLI patched (BSS ): 9
+ TLLI patched (SGSN): 9
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI-Cache: 0
+PROCESSING RA UPD REQ from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 70 80 00 80 0e 00 3e 01 c0 15 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 96 3e 97
+
+CALLBACK, event 0, msg length 85, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 70 80 00 80 0e 00 3e 01 c0 15 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 96 3e 97
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (RA UPD REQ) = 0
+
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 19 08 16 08 11 12 13 14 15 16 17 18 35 23 fc
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 19 08 16 08 11 12 13 14 15 16 17 18 35 23 fc
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 85 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 89
+00 00 10 02 01 78 de ad 02 00 00 04 08 88 21 63 54 00 63 60 70 80 00 80 0e 00 3e 01 c0 15 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 96 3e 97
+
+result (IDENT RESPONSE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 10
+ RAID patched (SGSN): 3
+ TLLI patched (BSS ): 10
+ TLLI patched (SGSN): 9
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead02, IMSI 12131415161718, AGE 0
+PROCESSING RA UDP ACC from 0x05060708:32000
+00 00 10 02 00 78 de ad 02 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 11 08 09 00 49 21 63 54 40 50 60 19 54 ab b3 18 05 f4 ef e2 b7 00 17 16 36 98 77
+
+CALLBACK, event 0, msg length 87, bvci 0x1002
+00 00 10 02 00 78 de ad 02 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 11 08 09 00 49 21 63 54 40 50 60 19 54 ab b3 18 05 f4 ef e2 b7 00 17 16 36 98 77
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 87 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 91
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9d 41 c0 11 08 09 00 49 11 22 33 40 50 60 19 54 ab b3 18 05 f4 c0 de ad 03 17 16 6e 58 26
+
+result (RA UDP ACC) = 91
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 10
+ RAID patched (SGSN): 4
+ TLLI patched (BSS ): 10
+ TLLI patched (SGSN): 10
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 1
+ RoutingArea Update Accept count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/c0dead03 -> 78dead02/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH REQ from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 1d 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb aa cc a3
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 1d 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb aa cc a3
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 06 00 11 f5 c0
+
+result (DETACH REQ) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 10
+ RAID patched (SGSN): 4
+ TLLI patched (BSS ): 10
+ TLLI patched (SGSN): 10
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 1
+ RoutingArea Update Accept count : 1
+ Detach Request count : 2
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/c0dead03 -> 78dead02/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 15 08 06 00 f7 35 f0
+
+CALLBACK, event 0, msg length 67, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 15 08 06 00 f7 35 f0
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 67 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 71
+00 00 10 02 00 c0 de ad 03 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 15 08 06 00 f7 35 f0
+
+result (DETACH ACC) = 71
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 10
+ RAID patched (SGSN): 4
+ TLLI patched (BSS ): 10
+ TLLI patched (SGSN): 11
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 1
+ RoutingArea Update Accept count : 1
+ Detach Request count : 2
+ Detach Accept count : 2
+ TLLI-Cache: 0
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 21 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 44 b6 bb
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 21 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 44 b6 bb
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (ATTACH REQUEST) = 0
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 25 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 1d aa 57
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 25 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 1d aa 57
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 00 09 41 c4 05 08 15 01 8f 47 9e
+
+result (ATTACH REQUEST) = 0
+
+PROCESSING DETACH REQ from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 29 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb d9 1d ef
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 29 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb d9 1d ef
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 00 09 41 c4 09 08 06 00 da 80 ca
+
+result (DETACH REQ) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 10
+ RAID patched (SGSN): 4
+ TLLI patched (BSS ): 10
+ TLLI patched (SGSN): 11
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 3
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 1
+ RoutingArea Update Accept count : 1
+ Detach Request count : 3
+ Detach Accept count : 2
+ TLLI-Cache: 0
+PROCESSING DETACH REQ (unknown TLLI) from 0x01020304:1111
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 2d 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 0d 30 0d
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 2d 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 0d 30 0d
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 be ef 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 06 00 11 f5 c0
+
+result (DETACH REQ (unknown TLLI)) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 10
+ RAID patched (SGSN): 4
+ TLLI patched (BSS ): 10
+ TLLI patched (SGSN): 11
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 3
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 1
+ RoutingArea Update Accept count : 1
+ Detach Request count : 4
+ Detach Accept count : 2
+ TLLI-Cache: 0
+PROCESSING RA UPD REQ from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 70 80 00 80 0e 00 3e 01 c0 31 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 d8 cf d8
+
+CALLBACK, event 0, msg length 85, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 70 80 00 80 0e 00 3e 01 c0 31 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 d8 cf d8
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (RA UPD REQ) = 0
+
+PROCESSING RA UPD REQ from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 70 80 00 80 0e 00 3e 01 c0 35 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 ac 9c 37
+
+CALLBACK, event 0, msg length 85, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 70 80 00 80 0e 00 3e 01 c0 35 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 ac 9c 37
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 00 09 41 c4 05 08 15 01 8f 47 9e
+
+result (RA UPD REQ) = 0
+
+PROCESSING DETACH REQ from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 39 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 44 b6 8a
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 39 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 44 b6 8a
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 00 09 41 c4 09 08 06 00 da 80 ca
+
+result (DETACH REQ) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 10
+ RAID patched (SGSN): 4
+ TLLI patched (BSS ): 10
+ TLLI patched (SGSN): 11
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 3
+ Attach Accept count : 1
+ Attach Completed count : 1
+ RoutingArea Update Request count: 3
+ RoutingArea Update Accept count : 1
+ Detach Request count : 5
+ Detach Accept count : 2
+ TLLI-Cache: 0
+Gbproxy global:
+ Invalid Routing Area Identifier : 1
+ BSSGP protocol error (SGSN): 1
+ Patch error: no peer : 1
+=== test_gbproxy_secondary_sgsn ===
+--- Initialise SGSN 1 ---
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 12
+02 00 81 01 01 82 01 01 04 82 01 00
+
+PROCESSING RESET_ACK from 0x05060708:32000
+03 01 82 01 01 04 82 01 00
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0a
+
+result (RESET_ACK) = 1
+
+PROCESSING ALIVE_ACK from 0x05060708:32000
+0b
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+06
+
+result (ALIVE_ACK) = 1
+
+PROCESSING UNBLOCK_ACK from 0x05060708:32000
+07
+
+==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000
+
+result (UNBLOCK_ACK) = 0
+
+PROCESSING ALIVE from 0x05060708:32000
+0a
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0b
+
+result (ALIVE) = 1
+
+--- Initialise SGSN 2 ---
+
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 12
+02 00 81 01 01 82 01 03 04 82 01 02
+
+PROCESSING RESET_ACK from 0x15161718:32001
+03 01 82 01 03 04 82 01 02
+
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 1
+0a
+
+result (RESET_ACK) = 1
+
+PROCESSING ALIVE_ACK from 0x15161718:32001
+0b
+
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 1
+06
+
+result (ALIVE_ACK) = 1
+
+PROCESSING UNBLOCK_ACK from 0x15161718:32001
+07
+
+==> got signal NS_UNBLOCK, NS-VC 0x0103/21.22.23.24:32001
+
+result (UNBLOCK_ACK) = 0
+
+PROCESSING ALIVE from 0x15161718:32001
+0a
+
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 1
+0b
+
+result (ALIVE) = 1
+
+--- Initialise BSS 1 ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x0000(0)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 00 00
+
+result (BVC_RESET) = 9
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 00 00
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 00 00
+
+result (BVC_RESET_ACK) = -2
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 21 63 54 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 21 63 54 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+PROCESSING BVC_RESET_ACK from 0x15161718:32001
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 1
+
+Current NS-VCIs:
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0103, NSEI 0x0102, peer 0x15161718:32001
+ NS-VC Block count : 1
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Gbproxy global:
+ Invalid BVC Identifier : 1
+ Patch error: no peer : 1
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 1
+ TLLI-Cache: 0
+--- Flow control ---
+
+PROCESSING FLOW_CONTROL_BVC from 0x01020304:1111
+00 00 10 02 26 1e 81 01 05 82 01 dc 03 82 02 76 01 82 00 50 1c 82 02 58 06 82 00 03
+
+CALLBACK, event 0, msg length 24, bvci 0x1002
+00 00 10 02 26 1e 81 01 05 82 01 dc 03 82 02 76 01 82 00 50 1c 82 02 58 06 82 00 03
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 28
+00 00 10 02 26 1e 81 01 05 82 01 dc 03 82 02 76 01 82 00 50 1c 82 02 58 06 82 00 03
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 28
+00 00 10 02 26 1e 81 01 05 82 01 dc 03 82 02 76 01 82 00 50 1c 82 02 58 06 82 00 03
+
+result (FLOW_CONTROL_BVC) = 28
+
+PROCESSING FLOW_CONTROL_BVC_ACK from 0x05060708:32000
+00 00 10 02 27 1e 81 01
+
+CALLBACK, event 0, msg length 4, bvci 0x1002
+00 00 10 02 27 1e 81 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 4 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 8
+00 00 10 02 27 1e 81 01
+
+result (FLOW_CONTROL_BVC_ACK) = 8
+
+PROCESSING FLOW_CONTROL_BVC_ACK from 0x15161718:32001
+00 00 10 02 27 1e 81 01
+
+CALLBACK, event 0, msg length 4, bvci 0x1002
+00 00 10 02 27 1e 81 01
+
+result (FLOW_CONTROL_BVC_ACK) = 0
+
+--- Establish GPRS connection (SGSN 1) ---
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (ATTACH REQUEST) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI (none), AGE 0, STORED 1, IMSI acquisition in progress, SGSN NSEI 65535
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 78 de ad 00 00 00 04 08 88 21 63 54 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+result (IDENT RESPONSE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 2
+ TLLI patched (BSS ): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING IDENT REQUEST from 0x05060708:32000
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+CALLBACK, event 0, msg length 23, bvci 0x1002
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 23 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 27
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+result (IDENT REQUEST) = 27
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 2
+ TLLI patched (BSS ): 1
+ TLLI patched (SGSN): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 09 08 16 08 11 12 13 14 15 16 17 18 ba 14 c3
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 09 08 16 08 11 12 13 14 15 16 17 18 ba 14 c3
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 44
+00 00 10 02 01 78 de ad 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 11 01 c0 09 08 16 08 11 12 13 14 15 16 17 18 ba 14 c3
+
+result (IDENT RESPONSE) = 44
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 3
+ TLLI patched (BSS ): 2
+ TLLI patched (SGSN): 1
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 78dead00, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 78 de ad 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 11 22 33 40 50 60 19 cd d7 08 17 16 18 05 f4 c0 de ad 01 0c 0a 29
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 3
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 2
+ TLLI patched (SGSN): 2
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/c0dead01 -> 78dead00/efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 0d 08 03 55 1c ea
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 0d 08 03 55 1c ea
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 08 01 c0 0d 08 03 55 1c ea
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 4
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 3
+ TLLI patched (SGSN): 2
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead/c0dead01 -> 78dead00/efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 4
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 3
+ TLLI patched (SGSN): 3
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING XID (UL) from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+CALLBACK, event 0, msg length 38, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 38 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 42
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+result (XID (UL)) = 42
+
+PROCESSING XID (DL) from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+CALLBACK, event 0, msg length 70, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 70 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 74
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+result (XID (DL)) = 74
+
+PROCESSING LL11 DNS QUERY (UL) from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+CALLBACK, event 0, msg length 89, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 89 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 93
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+result (LL11 DNS QUERY (UL)) = 93
+
+PROCESSING LL11 DNS RESP (DL) from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+CALLBACK, event 0, msg length 267, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 267 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 271
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+result (LL11 DNS RESP (DL)) = 271
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 6
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 5
+ TLLI patched (SGSN): 5
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING LLC_DISCARDED from 0x01020304:1111
+00 00 00 00 2c 1f 84 c0 de ad 01 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+CALLBACK, event 0, msg length 19, bvci 0x0000
+00 00 00 00 2c 1f 84 c0 de ad 01 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 19 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 23
+00 00 00 00 2c 1f 84 ef e2 b7 00 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+result (LLC_DISCARDED) = 23
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 6
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 6
+ TLLI patched (SGSN): 5
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING LLC_DISCARDED from 0x05060708:32000
+00 00 00 00 2c 1f 84 ef e2 b7 00 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+CALLBACK, event 0, msg length 19, bvci 0x0000
+00 00 00 00 2c 1f 84 ef e2 b7 00 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 25 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 29
+00 00 00 00 41 07 81 27 15 93 2c 1f 84 ef e2 b7 00 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+result (LLC_DISCARDED) = 29
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 6
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 6
+ TLLI patched (SGSN): 6
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING BVC_SUSPEND from 0x01020304:1111
+00 00 00 00 0b 1f 84 c0 de ad 01 1b 86 11 22 33 40 50 60
+
+CALLBACK, event 0, msg length 15, bvci 0x0000
+00 00 00 00 0b 1f 84 c0 de ad 01 1b 86 11 22 33 40 50 60
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 15 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 19
+00 00 00 00 0b 1f 84 ef e2 b7 00 1b 86 21 63 54 40 50 60
+
+result (BVC_SUSPEND) = 19
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 7
+ RAID patched (SGSN): 1
+ TLLI patched (BSS ): 7
+ TLLI patched (SGSN): 6
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING BVC_SUSPEND_ACK from 0x05060708:32000
+00 00 00 00 0c 1f 84 ef e2 b7 00 1b 86 21 63 54 40 50 60 1d 81 01
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 0c 1f 84 ef e2 b7 00 1b 86 21 63 54 40 50 60 1d 81 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 22
+00 00 00 00 0c 1f 84 c0 de ad 01 1b 86 11 22 33 40 50 60 1d 81 01
+
+result (BVC_SUSPEND_ACK) = 22
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 7
+ RAID patched (SGSN): 2
+ TLLI patched (BSS ): 7
+ TLLI patched (SGSN): 7
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+--- Establish GPRS connection (SGSN 2) ---
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 11 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 bf 00 5c
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 11 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 bf 00 5c
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 be ef 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (ATTACH REQUEST) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 7
+ RAID patched (SGSN): 2
+ TLLI patched (BSS ): 7
+ TLLI patched (SGSN): 7
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 2
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI 8000beef -> 78dead02, IMSI (none), AGE 0, STORED 1, IMSI acquisition in progress, SGSN NSEI 65535
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 15 08 16 08 11 12 99 99 99 16 17 18 b2 dd 58
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 15 08 16 08 11 12 99 99 99 16 17 18 b2 dd 58
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 79
+00 00 10 02 01 78 de ad 02 00 00 04 08 88 21 63 54 00 63 60 12 34 00 80 0e 00 34 01 c0 11 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 bf 00 5c
+
+result (IDENT RESPONSE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 8
+ RAID patched (SGSN): 2
+ TLLI patched (BSS ): 8
+ TLLI patched (SGSN): 7
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 2
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI 8000beef -> 78dead02, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING IDENT REQUEST from 0x15161718:32001
+00 00 10 02 00 78 de ad 02 00 50 20 16 82 02 58 0e 89 41 c0 0d 08 15 01 0c a6 18
+
+CALLBACK, event 0, msg length 23, bvci 0x1002
+00 00 10 02 00 78 de ad 02 00 50 20 16 82 02 58 0e 89 41 c0 0d 08 15 01 0c a6 18
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 23 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 27
+00 00 10 02 00 80 00 be ef 00 50 20 16 82 02 58 0e 89 41 c0 0d 08 15 01 0c a6 18
+
+result (IDENT REQUEST) = 27
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 8
+ RAID patched (SGSN): 2
+ TLLI patched (BSS ): 8
+ TLLI patched (SGSN): 8
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 2
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI 8000beef -> 78dead02, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 19 08 16 08 11 12 99 99 99 16 17 18 a5 cc b3
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 be ef 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 19 08 16 08 11 12 99 99 99 16 17 18 a5 cc b3
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 44
+00 00 10 02 01 78 de ad 02 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 11 01 c0 19 08 16 08 11 12 99 99 99 16 17 18 a5 cc b3
+
+result (IDENT RESPONSE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 9
+ RAID patched (SGSN): 2
+ TLLI patched (BSS ): 9
+ TLLI patched (SGSN): 8
+ P-TMSI patched (SGSN): 1
+ Attach Request count : 2
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI 8000beef -> 78dead02, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING ATTACH ACCEPT from 0x15161718:32001
+00 00 10 02 00 78 de ad 02 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 9e 41 c0 11 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 e0 98 76 54 cb 1c 5b
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 78 de ad 02 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 9e 41 c0 11 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 e0 98 76 54 cb 1c 5b
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 80 00 be ef 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 9e 41 c0 11 08 02 01 49 04 11 22 33 40 50 60 19 cd d7 08 17 16 18 05 f4 c0 de ad 03 32 40 fa
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 9
+ RAID patched (SGSN): 3
+ TLLI patched (BSS ): 9
+ TLLI patched (SGSN): 9
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI 8000beef/c0dead03 -> 78dead02/e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 1d 08 03 5e 3a ea
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 1d 08 03 5e 3a ea
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 35
+00 00 10 02 01 e0 98 76 54 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 08 01 c0 1d 08 03 5e 3a ea
+
+result (ATTACH COMPLETE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 10
+ RAID patched (SGSN): 3
+ TLLI patched (BSS ): 10
+ TLLI patched (SGSN): 9
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI 8000beef/c0dead03 -> 78dead02/e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING GMM INFO from 0x15161718:32001
+00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 88 41 c0 15 08 21 bb c1 c6
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 88 41 c0 15 08 21 bb c1 c6
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 c0 de ad 03 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 88 41 c0 15 08 21 bb c1 c6
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 10
+ RAID patched (SGSN): 3
+ TLLI patched (BSS ): 10
+ TLLI patched (SGSN): 10
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING XID (UL) from 0x01020304:1111
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+CALLBACK, event 0, msg length 38, bvci 0x1002
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 38 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 42
+00 00 10 02 01 e0 98 76 54 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
+
+result (XID (UL)) = 0
+
+PROCESSING XID (DL) from 0x15161718:32001
+00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+CALLBACK, event 0, msg length 70, bvci 0x1002
+00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 70 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 74
+00 00 10 02 00 c0 de ad 03 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
+
+result (XID (DL)) = 74
+
+PROCESSING LL11 DNS QUERY (UL) from 0x01020304:1111
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+CALLBACK, event 0, msg length 89, bvci 0x1002
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 89 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 93
+00 00 10 02 01 e0 98 76 54 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
+
+result (LL11 DNS QUERY (UL)) = 0
+
+PROCESSING LL11 DNS RESP (DL) from 0x15161718:32001
+00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+CALLBACK, event 0, msg length 267, bvci 0x1002
+00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 267 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 271
+00 00 10 02 00 c0 de ad 03 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
+
+result (LL11 DNS RESP (DL)) = 271
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 12
+ RAID patched (SGSN): 3
+ TLLI patched (BSS ): 12
+ TLLI patched (SGSN): 12
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING LLC_DISCARDED from 0x01020304:1111
+00 00 00 00 2c 1f 84 c0 de ad 03 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+CALLBACK, event 0, msg length 19, bvci 0x0000
+00 00 00 00 2c 1f 84 c0 de ad 03 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x0000, msg length 19 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 23
+00 00 00 00 2c 1f 84 e0 98 76 54 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+result (LLC_DISCARDED) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 12
+ RAID patched (SGSN): 3
+ TLLI patched (BSS ): 13
+ TLLI patched (SGSN): 12
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING LLC_DISCARDED from 0x15161718:32001
+00 00 00 00 2c 1f 84 e0 98 76 54 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+CALLBACK, event 0, msg length 19, bvci 0x0000
+00 00 00 00 2c 1f 84 e0 98 76 54 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x0000, msg length 25 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 29
+00 00 00 00 41 07 81 27 15 93 2c 1f 84 e0 98 76 54 0f 81 01 04 82 10 02 25 83 00 00 0c
+
+result (LLC_DISCARDED) = 29
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 12
+ RAID patched (SGSN): 3
+ TLLI patched (BSS ): 13
+ TLLI patched (SGSN): 13
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING BVC_SUSPEND from 0x01020304:1111
+00 00 00 00 0b 1f 84 c0 de ad 03 1b 86 11 22 33 40 50 60
+
+CALLBACK, event 0, msg length 15, bvci 0x0000
+00 00 00 00 0b 1f 84 c0 de ad 03 1b 86 11 22 33 40 50 60
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x0000, msg length 15 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 19
+00 00 00 00 0b 1f 84 e0 98 76 54 1b 86 21 63 54 40 50 60
+
+result (BVC_SUSPEND) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 13
+ RAID patched (SGSN): 3
+ TLLI patched (BSS ): 14
+ TLLI patched (SGSN): 13
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING BVC_SUSPEND_ACK from 0x15161718:32001
+00 00 00 00 0c 1f 84 e0 98 76 54 1b 86 21 63 54 40 50 60 1d 81 01
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 0c 1f 84 e0 98 76 54 1b 86 21 63 54 40 50 60 1d 81 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 22
+00 00 00 00 0c 1f 84 c0 de ad 03 1b 86 11 22 33 40 50 60 1d 81 01
+
+result (BVC_SUSPEND_ACK) = 22
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 13
+ RAID patched (SGSN): 4
+ TLLI patched (BSS ): 14
+ TLLI patched (SGSN): 14
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+--- Establish GPRS connection (SGSN 2, P-TMSI collision) ---
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 80 00 fe ed 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 21 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 44 b6 bb
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 80 00 fe ed 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 21 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 44 b6 bb
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 fe ed 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (ATTACH REQUEST) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 13
+ RAID patched (SGSN): 4
+ TLLI patched (BSS ): 14
+ TLLI patched (SGSN): 14
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 3
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 3
+ TLLI-Cache: 3
+ TLLI 8000feed -> 78dead04, IMSI (none), AGE 0, STORED 1, IMSI acquisition in progress, SGSN NSEI 65535
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 fe ed 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 25 08 16 08 11 12 99 99 99 26 27 28 58 c7 cb
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 fe ed 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 25 08 16 08 11 12 99 99 99 26 27 28 58 c7 cb
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 79
+00 00 10 02 01 78 de ad 04 00 00 04 08 88 21 63 54 00 63 60 12 34 00 80 0e 00 34 01 c0 21 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 44 b6 bb
+
+result (IDENT RESPONSE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 14
+ RAID patched (SGSN): 4
+ TLLI patched (BSS ): 15
+ TLLI patched (SGSN): 14
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 3
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 3
+ TLLI-Cache: 3
+ TLLI 8000feed -> 78dead04, IMSI 12199999962728, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING IDENT REQUEST from 0x15161718:32001
+00 00 10 02 00 78 de ad 04 00 50 20 16 82 02 58 0e 89 41 c0 19 08 15 01 a2 f2 a4
+
+CALLBACK, event 0, msg length 23, bvci 0x1002
+00 00 10 02 00 78 de ad 04 00 50 20 16 82 02 58 0e 89 41 c0 19 08 15 01 a2 f2 a4
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 23 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 27
+00 00 10 02 00 80 00 fe ed 00 50 20 16 82 02 58 0e 89 41 c0 19 08 15 01 a2 f2 a4
+
+result (IDENT REQUEST) = 27
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 14
+ RAID patched (SGSN): 4
+ TLLI patched (BSS ): 15
+ TLLI patched (SGSN): 15
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 3
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 3
+ TLLI-Cache: 3
+ TLLI 8000feed -> 78dead04, IMSI 12199999962728, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 fe ed 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 29 08 16 08 11 12 99 99 99 26 27 28 4f d6 20
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 fe ed 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 29 08 16 08 11 12 99 99 99 26 27 28 4f d6 20
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 44
+00 00 10 02 01 78 de ad 04 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 11 01 c0 29 08 16 08 11 12 99 99 99 26 27 28 4f d6 20
+
+result (IDENT RESPONSE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 15
+ RAID patched (SGSN): 4
+ TLLI patched (BSS ): 16
+ TLLI patched (SGSN): 15
+ P-TMSI patched (SGSN): 2
+ Attach Request count : 3
+ Attach Accept count : 2
+ Attach Completed count : 2
+ TLLI cache size : 3
+ TLLI-Cache: 3
+ TLLI 8000feed -> 78dead04, IMSI 12199999962728, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING ATTACH ACCEPT (P-TMSI 1) from 0x15161718:32001
+00 00 10 02 00 78 de ad 04 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 26 27 28 00 81 00 0e 9e 41 c0 1d 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 74 91 01
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 78 de ad 04 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 26 27 28 00 81 00 0e 9e 41 c0 1d 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 74 91 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 80 00 fe ed 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 26 27 28 00 81 00 0e 9e 41 c0 1d 08 02 01 49 04 11 22 33 40 50 60 19 cd d7 08 17 16 18 05 f4 c0 de ad 05 3e 78 6e
+
+result (ATTACH ACCEPT (P-TMSI 1)) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 15
+ RAID patched (SGSN): 5
+ TLLI patched (BSS ): 16
+ TLLI patched (SGSN): 16
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 2
+ TLLI cache size : 3
+ TLLI-Cache: 3
+ TLLI 8000feed/c0dead05 -> 78dead04/efe2b700, IMSI 12199999962728, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 c0 de ad 05 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 2d 08 03 43 50 ea
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 c0 de ad 05 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 2d 08 03 43 50 ea
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 08 01 c0 2d 08 03 43 50 ea
+
+result (ATTACH COMPLETE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 16
+ RAID patched (SGSN): 5
+ TLLI patched (BSS ): 17
+ TLLI patched (SGSN): 16
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 3
+ TLLI cache size : 3
+ TLLI-Cache: 3
+ TLLI 8000feed/c0dead05 -> 78dead04/efe2b700, IMSI 12199999962728, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+PROCESSING GMM INFO from 0x15161718:32001
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 26 27 28 00 81 00 0e 88 41 c0 21 08 21 ca 60 90
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 26 27 28 00 81 00 0e 88 41 c0 21 08 21 ca 60 90
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 c0 de ad 05 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 26 27 28 00 81 00 0e 88 41 c0 21 08 21 ca 60 90
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 16
+ RAID patched (SGSN): 5
+ TLLI patched (BSS ): 17
+ TLLI patched (SGSN): 17
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 3
+ TLLI cache size : 3
+ TLLI-Cache: 3
+ TLLI c0dead05 -> efe2b700, IMSI 12199999962728, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+--- Shutdown GPRS connection (SGSN 1) ---
+
+PROCESSING DETACH REQ from 0x01020304:1111
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 31 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 57 e6 15
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 c0 de ad 01 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 31 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 57 e6 15
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 44 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 48
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 15 01 c0 31 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 57 e6 15
+
+result (DETACH REQ) = 48
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 17
+ RAID patched (SGSN): 5
+ TLLI patched (BSS ): 18
+ TLLI patched (SGSN): 17
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 3
+ Detach Request count : 1
+ TLLI cache size : 3
+ TLLI-Cache: 3
+ TLLI c0dead01 -> efe2b700, IMSI 12131415161718, AGE 0, SGSN NSEI 256
+ TLLI c0dead05 -> efe2b700, IMSI 12199999962728, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+PROCESSING DETACH ACC from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 25 08 06 00 4d 09 cd
+
+CALLBACK, event 0, msg length 67, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 25 08 06 00 4d 09 cd
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 67 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 71
+00 00 10 02 00 c0 de ad 01 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 25 08 06 00 4d 09 cd
+
+result (DETACH ACC) = 71
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 17
+ RAID patched (SGSN): 5
+ TLLI patched (BSS ): 18
+ TLLI patched (SGSN): 18
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 3
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI c0dead05 -> efe2b700, IMSI 12199999962728, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+--- Shutdown GPRS connection (SGSN 2) ---
+
+PROCESSING DETACH REQ from 0x01020304:1111
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 35 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 83 cb f7
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 c0 de ad 03 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 35 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 83 cb f7
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 44 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 48
+00 00 10 02 01 e0 98 76 54 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 15 01 c0 35 08 05 01 18 05 f4 e0 98 76 54 19 03 b9 97 cb b4 31 31
+
+result (DETACH REQ) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 18
+ RAID patched (SGSN): 5
+ TLLI patched (BSS ): 19
+ TLLI patched (SGSN): 18
+ P-TMSI patched (BSS ): 1
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 3
+ Detach Request count : 2
+ Detach Accept count : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI c0dead03 -> e0987654, IMSI 12199999961718, AGE 0, IMSI matches, SGSN NSEI 258
+ TLLI c0dead05 -> efe2b700, IMSI 12199999962728, AGE 0, IMSI matches, SGSN NSEI 258
+PROCESSING DETACH ACC from 0x15161718:32001
+00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 89 41 c0 29 08 06 00 be c3 6f
+
+CALLBACK, event 0, msg length 67, bvci 0x1002
+00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 89 41 c0 29 08 06 00 be c3 6f
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 67 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 71
+00 00 10 02 00 c0 de ad 03 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 89 41 c0 29 08 06 00 be c3 6f
+
+result (DETACH ACC) = 71
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 18
+ RAID patched (SGSN): 5
+ TLLI patched (BSS ): 19
+ TLLI patched (SGSN): 19
+ P-TMSI patched (BSS ): 1
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 3
+ Detach Request count : 2
+ Detach Accept count : 2
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead05 -> efe2b700, IMSI 12199999962728, AGE 0, IMSI matches, SGSN NSEI 258
+--- Shutdown GPRS connection (SGSN 2, P-TMSI 1) ---
+
+PROCESSING DETACH REQ from 0x01020304:1111
+00 00 10 02 01 c0 de ad 05 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 39 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 44 b6 8a
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 c0 de ad 05 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 39 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 44 b6 8a
+
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 44 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 48
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 15 01 c0 39 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 44 b6 8a
+
+result (DETACH REQ) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 19
+ RAID patched (SGSN): 5
+ TLLI patched (BSS ): 20
+ TLLI patched (SGSN): 19
+ P-TMSI patched (BSS ): 1
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 3
+ Detach Request count : 3
+ Detach Accept count : 2
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0dead05 -> efe2b700, IMSI 12199999962728, AGE 0, IMSI matches, SGSN NSEI 258
+PROCESSING DETACH ACC from 0x15161718:32001
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 26 27 28 00 81 00 0e 89 41 c0 2d 08 06 00 86 7c c7
+
+CALLBACK, event 0, msg length 67, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 26 27 28 00 81 00 0e 89 41 c0 2d 08 06 00 86 7c c7
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 67 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 71
+00 00 10 02 00 c0 de ad 05 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 26 27 28 00 81 00 0e 89 41 c0 2d 08 06 00 86 7c c7
+
+result (DETACH ACC) = 71
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ RAID patched (BSS ): 19
+ RAID patched (SGSN): 5
+ TLLI patched (BSS ): 20
+ TLLI patched (SGSN): 20
+ P-TMSI patched (BSS ): 1
+ P-TMSI patched (SGSN): 3
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 3
+ Detach Request count : 3
+ Detach Accept count : 3
+ TLLI-Cache: 0
+Gbproxy global:
+ Invalid BVC Identifier : 1
+ BSSGP protocol error (SGSN): 2
+ Patch error: no peer : 1
+=== test_gbproxy_keep_info ===
+--- Initialise SGSN ---
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 12
+02 00 81 01 01 82 01 01 04 82 01 00
+
+PROCESSING RESET_ACK from 0x05060708:32000
+03 01 82 01 01 04 82 01 00
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0a
+
+result (RESET_ACK) = 1
+
+PROCESSING ALIVE_ACK from 0x05060708:32000
+0b
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+06
+
+result (ALIVE_ACK) = 1
+
+PROCESSING UNBLOCK_ACK from 0x05060708:32000
+07
+
+==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000
+
+result (UNBLOCK_ACK) = 0
+
+PROCESSING ALIVE from 0x05060708:32000
+0a
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0b
+
+result (ALIVE) = 1
+
+--- Initialise BSS 1 ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+Current NS-VCIs:
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Gbproxy global:
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+--- Send message from BSS 1 to SGSN, BVCI 0x1002 ---
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (ATTACH REQUEST) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI (none), AGE 0, STORED 1, IMSI acquisition in progress
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 05 08 16 08 11 12 13 14 15 16 17 18 ad 05 28
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+result (IDENT RESPONSE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING IDENT REQUEST from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+CALLBACK, event 0, msg length 23, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 23 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 27
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+result (IDENT REQUEST) = 27
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 09 08 16 08 11 12 13 14 15 16 17 18 ba 14 c3
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 09 08 16 08 11 12 13 14 15 16 17 18 ba 14 c3
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 44
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 09 08 16 08 11 12 13 14 15 16 17 18 ba 14 c3
+
+result (IDENT RESPONSE) = 44
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 05 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 53 62 f1
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ Attach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 0d 08 03 55 1c ea
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 0d 08 03 55 1c ea
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 0d 08 03 55 1c ea
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 09 08 21 04 ba 3d
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH REQ from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 11 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 6d b1 de
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 11 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 6d b1 de
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 44 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 48
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 11 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 6d b1 de
+
+result (DETACH REQ) = 48
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ Detach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 0d 08 06 00 aa ab ee
+
+CALLBACK, event 0, msg length 67, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 0d 08 06 00 aa ab ee
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 67 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 71
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 0d 08 06 00 aa ab ee
+
+result (DETACH ACC) = 71
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ Attach Accept count : 1
+ Attach Completed count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 15 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 e6 71 c7
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 15 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 e6 71 c7
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 15 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 e6 71 c7
+
+result (ATTACH REQUEST) = 79
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 2
+ Attach Accept count : 1
+ Attach Completed count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 11 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 3a 6d d4
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 11 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 3a 6d d4
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 11 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 3a 6d d4
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 19 08 03 32 f1 bc
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 19 08 03 32 f1 bc
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 19 08 03 32 f1 bc
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH REQ (re-attach) from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 15 08 05 01 25 0a 67 0e 96
+
+CALLBACK, event 0, msg length 69, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 15 08 05 01 25 0a 67 0e 96
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 69 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 73
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 15 08 05 01 25 0a 67 0e 96
+
+result (DETACH REQ (re-attach)) = 73
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 1d 08 06 3d 1c 8b
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 1d 08 06 3d 1c 8b
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 1d 08 06 3d 1c 8b
+
+result (DETACH ACC) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 2
+ Attach Accept count : 2
+ Attach Completed count : 2
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 21 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 44 db cc
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 21 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 44 db cc
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 21 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 44 db cc
+
+result (ATTACH REQUEST) = 79
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 3
+ Attach Accept count : 2
+ Attach Completed count : 2
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 19 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 27 3c 84
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 19 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 27 3c 84
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 19 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 27 3c 84
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 2
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 25 08 03 9b c6 47
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 25 08 03 9b c6 47
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 25 08 03 9b c6 47
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 3
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH REQ from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 1d 08 05 02 25 0a dd 56 6c
+
+CALLBACK, event 0, msg length 69, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 1d 08 05 02 25 0a dd 56 6c
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 69 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 73
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 1d 08 05 02 25 0a dd 56 6c
+
+result (DETACH REQ) = 73
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 3
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 29 08 06 4c bd dd
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 29 08 06 4c bd dd
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 29 08 06 4c bd dd
+
+result (DETACH ACC) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 3
+ Attach Accept count : 3
+ Attach Completed count : 3
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+PROCESSING ATTACH REQUEST (IMSI) from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 37 01 c0 2d 08 01 02 f5 e0 21 08 02 08 11 12 13 14 15 16 17 18 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 a5 85 76
+
+CALLBACK, event 0, msg length 78, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 37 01 c0 2d 08 01 02 f5 e0 21 08 02 08 11 12 13 14 15 16 17 18 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 a5 85 76
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 78 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 82
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 37 01 c0 2d 08 01 02 f5 e0 21 08 02 08 11 12 13 14 15 16 17 18 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 a5 85 76
+
+result (ATTACH REQUEST (IMSI)) = 82
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 4
+ Attach Accept count : 3
+ Attach Completed count : 3
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 21 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 cf 80 6e
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 21 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 cf 80 6e
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 21 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 cf 80 6e
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 4
+ Attach Accept count : 4
+ Attach Completed count : 3
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 31 08 03 fc 2b 11
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 31 08 03 fc 2b 11
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 31 08 03 fc 2b 11
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 4
+ Attach Accept count : 4
+ Attach Completed count : 4
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH REQ from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 25 08 05 02 25 0a 8e ee 85
+
+CALLBACK, event 0, msg length 69, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 25 08 05 02 25 0a 8e ee 85
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 69 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 73
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 25 08 05 02 25 0a 8e ee 85
+
+result (DETACH REQ) = 73
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 4
+ Attach Accept count : 4
+ Attach Completed count : 4
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 35 08 06 f3 c6 26
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 35 08 06 f3 c6 26
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 35 08 06 f3 c6 26
+
+result (DETACH ACC) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 4
+ Attach Accept count : 4
+ Attach Completed count : 4
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 39 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 e4 85 12
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 39 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 e4 85 12
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 39 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 e4 85 12
+
+result (ATTACH REQUEST) = 79
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 5
+ Attach Accept count : 4
+ Attach Completed count : 4
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 29 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 d2 d1 3e
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 29 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 d2 d1 3e
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 29 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 d2 d1 3e
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 5
+ Attach Accept count : 5
+ Attach Completed count : 4
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 3d 08 03 48 76 ea
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 3d 08 03 48 76 ea
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 3d 08 03 48 76 ea
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 5
+ Attach Accept count : 5
+ Attach Completed count : 5
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING RA UPD REQ from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 70 80 00 80 0e 00 3e 01 c0 41 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 30 73 32
+
+CALLBACK, event 0, msg length 85, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 70 80 00 80 0e 00 3e 01 c0 41 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 30 73 32
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 85 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 89
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 70 80 00 80 0e 00 3e 01 c0 41 08 08 10 11 22 33 40 50 60 1d 19 13 42 33 57 2b f7 c8 48 02 13 48 50 c8 48 02 14 48 50 c8 48 02 17 49 10 c8 48 02 00 19 8b b2 92 17 16 27 07 04 31 02 e5 e0 32 02 20 00 30 73 32
+
+result (RA UPD REQ) = 89
+
+PROCESSING RA UDP REJ from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8a 41 c0 2d 08 0b 0a 00 41 30 a7
+
+CALLBACK, event 0, msg length 68, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8a 41 c0 2d 08 0b 0a 00 41 30 a7
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 68 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 72
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8a 41 c0 2d 08 0b 0a 00 41 30 a7
+
+result (RA UDP REJ) = 72
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 5
+ Attach Accept count : 5
+ Attach Completed count : 5
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 45 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 50 cc c3
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 45 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 50 cc c3
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (ATTACH REQUEST) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 6
+ Attach Accept count : 5
+ Attach Completed count : 5
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 2
+ TLLI-Cache: 2
+ TLLI afe2b700 -> afe2b700, IMSI (none), AGE 0, STORED 1, IMSI acquisition in progress
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 49 08 16 08 11 12 13 14 15 16 17 18 86 ca 3f
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 49 08 16 08 11 12 13 14 15 16 17 18 86 ca 3f
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 45 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 50 cc c3
+
+result (IDENT RESPONSE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 6
+ Attach Accept count : 5
+ Attach Completed count : 5
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 31 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 f5 22 ce
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 31 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 f5 22 ce
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 31 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 f5 22 ce
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 6
+ Attach Accept count : 6
+ Attach Completed count : 5
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 4d 08 03 79 84 ea
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 4d 08 03 79 84 ea
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 4d 08 03 79 84 ea
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 6
+ Attach Accept count : 6
+ Attach Completed count : 6
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH REQ from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 35 08 05 02 25 0a 9b fa 57
+
+CALLBACK, event 0, msg length 69, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 35 08 05 02 25 0a 9b fa 57
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 69 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 73
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 35 08 05 02 25 0a 9b fa 57
+
+result (DETACH REQ) = 73
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 6
+ Attach Accept count : 6
+ Attach Completed count : 6
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 51 08 06 a5 d9 70
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 51 08 06 a5 d9 70
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 51 08 06 a5 d9 70
+
+result (DETACH ACC) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 6
+ Attach Accept count : 6
+ Attach Completed count : 6
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+PROCESSING ATTACH REQUEST (local TLLI) from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 55 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 f9 cc e9
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 55 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 f9 cc e9
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 55 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 f9 cc e9
+
+result (ATTACH REQUEST (local TLLI)) = 79
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 7
+ Attach Accept count : 6
+ Attach Completed count : 6
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 39 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 e8 73 9e
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 39 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 e8 73 9e
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 39 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 e8 73 9e
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 7
+ Attach Accept count : 7
+ Attach Completed count : 6
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 59 08 03 1e 69 bc
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 59 08 03 1e 69 bc
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 59 08 03 1e 69 bc
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 7
+ Attach Accept count : 7
+ Attach Completed count : 7
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH REQ (re-attach) from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 3d 08 05 01 25 0a 21 a2 ad
+
+CALLBACK, event 0, msg length 69, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 3d 08 05 01 25 0a 21 a2 ad
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 69 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 73
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 3d 08 05 01 25 0a 21 a2 ad
+
+result (DETACH REQ (re-attach)) = 73
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 7
+ Attach Accept count : 7
+ Attach Completed count : 7
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 5d 08 06 11 84 8b
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 5d 08 06 11 84 8b
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 5d 08 06 11 84 8b
+
+result (DETACH ACC) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 7
+ Attach Accept count : 7
+ Attach Completed count : 7
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 61 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 5b 66 e2
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 61 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 5b 66 e2
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 61 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 5b 66 e2
+
+result (ATTACH REQUEST) = 79
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 8
+ Attach Accept count : 7
+ Attach Completed count : 7
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 41 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 9e 50 40
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 41 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 9e 50 40
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 41 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 9e 50 40
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 8
+ Attach Accept count : 8
+ Attach Completed count : 7
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 65 08 03 b7 5e 47
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 65 08 03 b7 5e 47
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 65 08 03 b7 5e 47
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 8
+ Attach Accept count : 8
+ Attach Completed count : 8
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 45 08 21 9c 7f c6
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 45 08 21 9c 7f c6
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 45 08 21 9c 7f c6
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 8
+ Attach Accept count : 8
+ Attach Completed count : 8
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH REQUEST (unexpected, IMSI) from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 37 01 c0 69 08 01 02 f5 e0 21 08 02 08 11 12 13 14 15 16 17 18 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 e1 11 8e
+
+CALLBACK, event 0, msg length 78, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 37 01 c0 69 08 01 02 f5 e0 21 08 02 08 11 12 13 14 15 16 17 18 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 e1 11 8e
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 78 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 82
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 37 01 c0 69 08 01 02 f5 e0 21 08 02 08 11 12 13 14 15 16 17 18 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 e1 11 8e
+
+result (ATTACH REQUEST (unexpected, IMSI)) = 82
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 9
+ Attach Accept count : 8
+ Attach Completed count : 8
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 49 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 83 01 10
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 49 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 83 01 10
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 49 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 83 01 10
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 9
+ Attach Accept count : 9
+ Attach Completed count : 8
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 6d 08 03 6f c8 ea
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 6d 08 03 6f c8 ea
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 6d 08 03 6f c8 ea
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 9
+ Attach Accept count : 9
+ Attach Completed count : 9
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH REQ from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 4d 08 05 02 25 0a 51 0e 1b
+
+CALLBACK, event 0, msg length 69, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 4d 08 05 02 25 0a 51 0e 1b
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 69 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 73
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 4d 08 05 02 25 0a 51 0e 1b
+
+result (DETACH REQ) = 73
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 9
+ Attach Accept count : 9
+ Attach Completed count : 9
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 71 08 06 b3 95 70
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 71 08 06 b3 95 70
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 71 08 06 b3 95 70
+
+result (DETACH ACC) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 9
+ Attach Accept count : 9
+ Attach Completed count : 9
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 75 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 ab 17 53
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 75 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 ab 17 53
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 75 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 ab 17 53
+
+result (ATTACH REQUEST) = 79
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 10
+ Attach Accept count : 9
+ Attach Completed count : 9
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 51 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 a4 f2 e0
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 51 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 a4 f2 e0
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 51 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 a4 f2 e0
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 10
+ Attach Accept count : 10
+ Attach Completed count : 9
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 79 08 03 08 25 bc
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 79 08 03 08 25 bc
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 79 08 03 08 25 bc
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 10
+ Attach Accept count : 10
+ Attach Completed count : 10
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING GMM INFO from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 55 08 21 97 59 c6
+
+CALLBACK, event 0, msg length 66, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 55 08 21 97 59 c6
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 66 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 70
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 88 41 c0 55 08 21 97 59 c6
+
+result (GMM INFO) = 70
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 10
+ Attach Accept count : 10
+ Attach Completed count : 10
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH REQUEST (unexpected) from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 7d 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 a2 24 d0
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 7d 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 a2 24 d0
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 7d 08 01 02 f5 e0 21 08 02 05 f4 ef e2 b7 00 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 a2 24 d0
+
+result (ATTACH REQUEST (unexpected)) = 79
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 11
+ Attach Accept count : 10
+ Attach Completed count : 10
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH ACCEPT from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 59 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 b9 a3 b0
+
+CALLBACK, event 0, msg length 88, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 59 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 b9 a3 b0
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 88 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 92
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 9e 41 c0 59 08 02 01 49 04 21 63 54 40 50 60 19 cd d7 08 17 16 18 05 f4 ef e2 b7 00 b9 a3 b0
+
+result (ATTACH ACCEPT) = 92
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 11
+ Attach Accept count : 11
+ Attach Completed count : 10
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH COMPLETE from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 81 08 03 b9 71 10
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 81 08 03 b9 71 10
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 81 08 03 b9 71 10
+
+result (ATTACH COMPLETE) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 11
+ Attach Accept count : 11
+ Attach Completed count : 11
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700/efe2b700 -> afe2b700/efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH REQ from 0x05060708:32000
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 5d 08 05 02 25 0a 44 1a c9
+
+CALLBACK, event 0, msg length 69, bvci 0x1002
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 5d 08 05 02 25 0a 44 1a c9
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 69 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 73
+00 00 10 02 00 ef e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 5d 08 05 02 25 0a 44 1a c9
+
+result (DETACH REQ) = 73
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 11
+ Attach Accept count : 11
+ Attach Completed count : 11
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI efe2b700 -> efe2b700, IMSI 12131415161718, AGE 0
+PROCESSING DETACH ACC from 0x01020304:1111
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 85 08 06 b6 9c 27
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 85 08 06 b6 9c 27
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 85 08 06 b6 9c 27
+
+result (DETACH ACC) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 11
+ Attach Accept count : 11
+ Attach Completed count : 11
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 89 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 21 24 df
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 89 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 21 24 df
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (ATTACH REQUEST) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 12
+ Attach Accept count : 11
+ Attach Completed count : 11
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI (none), AGE 0, STORED 1, IMSI acquisition in progress
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 8d 08 16 08 11 12 13 14 15 16 17 18 74 ac 38
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 8d 08 16 08 11 12 13 14 15 16 17 18 74 ac 38
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 89 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 21 24 df
+
+result (IDENT RESPONSE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 12
+ Attach Accept count : 11
+ Attach Completed count : 11
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0
+PROCESSING ATTACH REJECT from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 61 08 04 07 79 ba a5
+
+CALLBACK, event 0, msg length 67, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 61 08 04 07 79 ba a5
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 67 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 71
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 89 41 c0 61 08 04 07 79 ba a5
+
+result (ATTACH REJECT) = 71
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 12
+ Attach Reject count : 1
+ Attach Accept count : 11
+ Attach Completed count : 11
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 91 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 81 7a 01
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 91 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 81 7a 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (ATTACH REQUEST) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 13
+ Attach Reject count : 1
+ Attach Accept count : 11
+ Attach Completed count : 11
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 1
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI (none), AGE 0, STORED 1, IMSI acquisition in progress
+PROCESSING DETACH REQ (MO) from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 95 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 9c dc fc
+
+CALLBACK, event 0, msg length 44, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 95 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 9c dc fc
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 0e 00 09 41 c4 05 08 06 00 29 4a 68
+
+result (DETACH REQ (MO)) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 13
+ Attach Reject count : 1
+ Attach Accept count : 11
+ Attach Completed count : 11
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 2
+ Detach Accept count : 1
+ TLLI-Cache: 0
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 99 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 88 49 82
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 99 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 88 49 82
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (ATTACH REQUEST) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 14
+ Attach Reject count : 1
+ Attach Accept count : 11
+ Attach Completed count : 11
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 2
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI (none), AGE 0, STORED 1, IMSI acquisition in progress
+PROCESSING DETACH REQ (MT) from 0x05060708:32000
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 65 08 05 02 25 0a 17 a2 20
+
+CALLBACK, event 0, msg length 69, bvci 0x1002
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 65 08 05 02 25 0a 17 a2 20
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 69 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 73
+00 00 10 02 00 af e2 b7 00 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 13 14 15 16 17 18 00 81 00 0e 8b 41 c0 65 08 05 02 25 0a 17 a2 20
+
+result (DETACH REQ (MT)) = 73
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 14
+ Attach Reject count : 1
+ Attach Accept count : 11
+ Attach Completed count : 11
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 2
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI afe2b700 -> afe2b700, IMSI 12131415161718, AGE 0, STORED 1, IMSI acquisition in progress
+PROCESSING DETACH ACC from 0x01020304:1111
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 9d 08 06 65 2c 8a
+
+CALLBACK, event 0, msg length 31, bvci 0x1002
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 9d 08 06 65 2c 8a
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 34 01 c0 99 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 88 49 82
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 35
+00 00 10 02 01 af e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 9d 08 06 65 2c 8a
+
+result (DETACH ACC) = 35
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 14
+ Attach Reject count : 1
+ Attach Accept count : 11
+ Attach Completed count : 11
+ RoutingArea Update Request count: 1
+ RoutingArea Update Reject count : 1
+ Detach Request count : 2
+ Detach Accept count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
+Gbproxy global:
+Test TLLI info expiry
+
+Test TLLI replacement:
+ Add TLLI 1, IMSI 1
+ Add TLLI 2, IMSI 1 (should replace TLLI 1)
+ Peers:
+ NSEI 0, BVCI 20, not blocked, RAI 0-0-0-0
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c000162e, IMSI 03242526, AGE 0, IMSI matches
+
+Test IMSI replacement:
+ Add TLLI 1, IMSI 1
+ Add TLLI 1, IMSI 2 (should replace IMSI 1)
+ Peers:
+ NSEI 0, BVCI 20, not blocked, RAI 0-0-0-0
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c00004d2, IMSI 06272829, AGE 0, IMSI matches
+
+Test TLLI expiry, max_len == 1:
+ Add TLLI 1, IMSI 1
+ Add TLLI 2, IMSI 2 (should replace IMSI 1)
+ Peers:
+ NSEI 0, BVCI 20, not blocked, RAI 0-0-0-0
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c000162e, IMSI 06272829, AGE 0, IMSI matches
+
+Test TLLI expiry, max_age == 1:
+ Add TLLI 1, IMSI 1 (should expire after timeout)
+ Add TLLI 2, IMSI 2 (should not expire after timeout)
+ Peers:
+ NSEI 0, BVCI 20, not blocked, RAI 0-0-0-0
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c000162e, IMSI 06272829, AGE 1, IMSI matches
+
+Test TLLI expiry, max_len == 2, max_age == 1:
+ Add TLLI 1, IMSI 1 (should expire)
+ Add TLLI 2, IMSI 2 (should expire after timeout)
+ Add TLLI 3, IMSI 3 (should not expire after timeout)
+ Peers:
+ NSEI 0, BVCI 20, not blocked, RAI 0-0-0-0
+ TLLI cache size : 3
+ TLLI-Cache: 3
+ TLLI c0000d80, IMSI 12345678, AGE 0, IMSI matches
+ TLLI c000162e, IMSI 06272829, AGE 1, IMSI matches
+ TLLI c00004d2, IMSI 03242526, AGE 2, IMSI matches
+ Remove stale TLLIs
+ Peers:
+ NSEI 0, BVCI 20, not blocked, RAI 0-0-0-0
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI c0000d80, IMSI 12345678, AGE 0, IMSI matches
+
+=== test_gbproxy_stored_messages ===
+--- Initialise SGSN ---
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 12
+02 00 81 01 01 82 01 01 04 82 01 00
+
+PROCESSING RESET_ACK from 0x05060708:32000
+03 01 82 01 01 04 82 01 00
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0a
+
+result (RESET_ACK) = 1
+
+PROCESSING ALIVE_ACK from 0x05060708:32000
+0b
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+06
+
+result (ALIVE_ACK) = 1
+
+PROCESSING UNBLOCK_ACK from 0x05060708:32000
+07
+
+==> got signal NS_UNBLOCK, NS-VC 0x0101/5.6.7.8:32000
+
+result (UNBLOCK_ACK) = 0
+
+PROCESSING ALIVE from 0x05060708:32000
+0a
+
+MESSAGE to SGSN at 0x05060708:32000, msg length 1
+0b
+
+result (ALIVE) = 1
+
+--- Initialise BSS 1 ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+03 01 82 10 01 04 82 10 00
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0a
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+0b
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS at 0x01020304:1111, msg length 1
+07
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING BVC_RESET from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+CALLBACK, event 0, msg length 18, bvci 0x0000
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 22
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00
+
+result (BVC_RESET) = 22
+
+PROCESSING BVC_RESET_ACK from 0x05060708:32000
+00 00 00 00 23 04 82 10 02
+
+CALLBACK, event 0, msg length 5, bvci 0x0000
+00 00 00 00 23 04 82 10 02
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x0000, msg length 5 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 9
+00 00 00 00 23 04 82 10 02
+
+result (BVC_RESET_ACK) = 9
+
+Current NS-VCIs:
+ VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+ VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
+ NS-VC Block count : 1
+
+Gbproxy global:
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ TLLI-Cache: 0
+--- Establish first LLC connection ---
+
+PROCESSING ATTACH REQUEST from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+CALLBACK, event 0, msg length 75, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 24 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 28
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 00 09 41 c4 01 08 15 01 b7 f8 36
+
+result (ATTACH REQUEST) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 8000dead, IMSI (none), AGE 0, STORED 1, IMSI acquisition in progress
+PROCESSING IDENT REQUEST from 0x05060708:32000
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+CALLBACK, event 0, msg length 23, bvci 0x1002
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+NS UNITDATA MESSAGE to BSS, BVCI 0x1002, msg length 23 (gprs_ns_sendmsg)
+MESSAGE to BSS at 0x01020304:1111, msg length 27
+00 00 10 02 00 80 00 de ad 00 50 20 16 82 02 58 0e 89 41 c0 01 08 15 01 ff 6c ba
+
+result (IDENT REQUEST) = 27
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 8000dead, IMSI (none), AGE 0, STORED 1, IMSI acquisition in progress
+PROCESSING DETACH ACCEPT from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 09 01 c0 05 08 06 00 f8 92 41
+
+CALLBACK, event 0, msg length 32, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 09 01 c0 05 08 06 00 f8 92 41
+
+result (DETACH ACCEPT) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ TLLI cache size : 1
+ TLLI-Cache: 1
+ TLLI 8000dead -> 8000dead, IMSI (none), AGE 0, STORED 2, IMSI acquisition in progress
+PROCESSING IDENT RESPONSE from 0x01020304:1111
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 09 08 16 08 11 12 13 14 15 16 17 18 ba 14 c3
+
+CALLBACK, event 0, msg length 40, bvci 0x1002
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 09 08 16 08 11 12 13 14 15 16 17 18 ba 14 c3
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN at 0x05060708:32000, msg length 79
+00 00 10 02 01 80 00 de ad 00 00 04 08 88 00 f1 99 00 63 60 12 34 00 80 0e 00 34 01 c0 01 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 16 6d 01
+
+result (IDENT RESPONSE) = 0
+
+Peers:
+ NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
+ Attach Request count : 1
+ TLLI-Cache: 0
+Gbproxy global:
+===== GbProxy test END
+
diff --git a/tests/gprs/Makefile.am b/tests/gprs/Makefile.am
new file mode 100644
index 000000000..902313f2a
--- /dev/null
+++ b/tests/gprs/Makefile.am
@@ -0,0 +1,10 @@
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOABIS_CFLAGS)
+
+EXTRA_DIST = gprs_test.ok
+
+noinst_PROGRAMS = gprs_test
+
+gprs_test_SOURCES = gprs_test.c $(top_srcdir)/src/gprs/gprs_utils.c
+
+gprs_test_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
diff --git a/tests/gprs/gprs_test.c b/tests/gprs/gprs_test.c
new file mode 100644
index 000000000..ff7740494
--- /dev/null
+++ b/tests/gprs/gprs_test.c
@@ -0,0 +1,236 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+
+#include <openbsc/gprs_llc.h>
+#include <openbsc/gprs_utils.h>
+
+#include <openbsc/debug.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/gsm/gsup.h>
+
+#define ASSERT_FALSE(x) if (x) { printf("Should have returned false.\n"); abort(); }
+#define ASSERT_TRUE(x) if (!x) { printf("Should have returned true.\n"); abort(); }
+
+/**
+ * GSM 04.64 8.4.2 Receipt of unacknowledged information
+ */
+static int nu_is_retransmission(uint16_t nu, uint16_t vur)
+{
+ int ret = gprs_llc_is_retransmit(nu, vur);
+ printf("N(U) = %d, V(UR) = %d => %s\n", nu, vur,
+ ret == 1 ? "retransmit" : "new");
+ return ret;
+}
+
+static void test_8_4_2()
+{
+ printf("Testing gprs_llc_is_retransmit.\n");
+
+ ASSERT_FALSE(nu_is_retransmission(0, 0));
+ ASSERT_TRUE (nu_is_retransmission(0, 1));
+
+ /* expect 1... check for retransmissions */
+ ASSERT_TRUE (nu_is_retransmission(0, 1));
+ ASSERT_TRUE (nu_is_retransmission(511, 1));
+ ASSERT_TRUE (nu_is_retransmission(483, 1));
+ ASSERT_TRUE (nu_is_retransmission(482, 1));
+ ASSERT_FALSE(nu_is_retransmission(481, 1));
+
+ /* expect 511... check for retransmissions */
+ ASSERT_FALSE(nu_is_retransmission(0, 240)); // ahead
+ ASSERT_FALSE(nu_is_retransmission(0, 511)); // ahead
+ ASSERT_FALSE(nu_is_retransmission(1, 511)); // ahead
+ ASSERT_FALSE(nu_is_retransmission(511, 511)); // same
+ ASSERT_TRUE (nu_is_retransmission(510, 511)); // behind
+ ASSERT_TRUE (nu_is_retransmission(481, 511)); // behind
+ ASSERT_FALSE(nu_is_retransmission(479, 511)); // wrapped
+}
+
+static void apn_round_trip(const uint8_t *input, size_t len, const char *wanted_output)
+{
+ char output[len ? len : 1];
+ uint8_t encoded[len + 50];
+ char *out_str;
+ int enc_len;
+
+ /* decode and verify we have what we want */
+ out_str = gprs_apn_to_str(output, input, len);
+ OSMO_ASSERT(out_str);
+ OSMO_ASSERT(out_str == &output[0]);
+ OSMO_ASSERT(strlen(out_str) == strlen(wanted_output));
+ OSMO_ASSERT(strcmp(out_str, wanted_output) == 0);
+
+ /* encode and verify it */
+ if (len != 0) {
+ enc_len = gprs_str_to_apn(encoded, ARRAY_SIZE(encoded), wanted_output);
+ OSMO_ASSERT(enc_len == len);
+ OSMO_ASSERT(memcmp(encoded, input, enc_len) == 0);
+ } else {
+ enc_len = gprs_str_to_apn(encoded, 0, wanted_output);
+ OSMO_ASSERT(enc_len == -1);
+ }
+}
+
+static void test_gsm_03_03_apn(void)
+{
+
+ {
+ /* test invalid writes */
+ const uint8_t ref[10] = { 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF };
+ uint8_t output[10];
+ int enc_len;
+
+ memcpy(output, ref, ARRAY_SIZE(output));
+ enc_len = gprs_str_to_apn(output, 0, "");
+ OSMO_ASSERT(enc_len == -1);
+ OSMO_ASSERT(memcmp(ref, output, ARRAY_SIZE(ref)) == 0);
+
+ memcpy(output, ref, ARRAY_SIZE(output));
+ enc_len = gprs_str_to_apn(output, 0, "foo");
+ OSMO_ASSERT(enc_len == -1);
+ OSMO_ASSERT(memcmp(ref, output, ARRAY_SIZE(ref)) == 0);
+
+ memcpy(output, ref, ARRAY_SIZE(output));
+ enc_len = gprs_str_to_apn(output, 1, "foo");
+ OSMO_ASSERT(enc_len == -1);
+ OSMO_ASSERT(memcmp(ref + 1, output + 1, ARRAY_SIZE(ref) - 1) == 0);
+
+ memcpy(output, ref, ARRAY_SIZE(output));
+ enc_len = gprs_str_to_apn(output, 2, "foo");
+ OSMO_ASSERT(enc_len == -1);
+ OSMO_ASSERT(memcmp(ref + 2, output + 2, ARRAY_SIZE(ref) - 2) == 0);
+
+ memcpy(output, ref, ARRAY_SIZE(output));
+ enc_len = gprs_str_to_apn(output, 3, "foo");
+ OSMO_ASSERT(enc_len == -1);
+ OSMO_ASSERT(memcmp(ref + 3, output + 3, ARRAY_SIZE(ref) - 3) == 0);
+ }
+
+ {
+ /* single empty label */
+ uint8_t input[] = { 0x0 };
+ const char *output = "";
+ apn_round_trip(input, ARRAY_SIZE(input), output);
+ }
+
+ {
+ /* no label */
+ uint8_t input[] = { };
+ const char *output = "";
+ apn_round_trip(input, ARRAY_SIZE(input), output);
+ }
+
+ {
+ /* single label with A */
+ uint8_t input[] = { 0x1, 65 };
+ const char *output = "A";
+ apn_round_trip(input, ARRAY_SIZE(input), output);
+ OSMO_ASSERT(gprs_apn_to_str(NULL, input, ARRAY_SIZE(input) - 1) == NULL);
+ }
+
+ {
+ uint8_t input[] = { 0x3, 65, 66, 67, 0x2, 90, 122 };
+ const char *output = "ABC.Zz";
+ char tmp[strlen(output) + 1];
+ apn_round_trip(input, ARRAY_SIZE(input), output);
+ OSMO_ASSERT(gprs_apn_to_str(tmp, input, ARRAY_SIZE(input) - 1) == NULL);
+ OSMO_ASSERT(gprs_apn_to_str(tmp, input, ARRAY_SIZE(input) - 2) == NULL);
+ OSMO_ASSERT(gprs_apn_to_str(tmp, input, ARRAY_SIZE(input) - 4) == NULL);
+ OSMO_ASSERT(gprs_apn_to_str(tmp, input, ARRAY_SIZE(input) - 5) == NULL);
+ OSMO_ASSERT(gprs_apn_to_str(tmp, input, ARRAY_SIZE(input) - 6) == NULL);
+ }
+}
+
+static void test_gprs_timer_enc_dec(void)
+{
+ int i, u, secs, tmr;
+ const int upper_secs_test_limit = 12000;
+ int dec_secs, last_dec_secs = -1;
+
+ printf("Test GPRS timer decoding/encoding\n");
+
+ /* Check gprs_tmr_to_secs with all 256 encoded values */
+ for (u = 0; u <= GPRS_TMR_DEACTIVATED; u += 32) {
+ fprintf(stderr, "Testing decoding with timer value unit %u\n",
+ u / 32);
+ for (i = 0; i < 32; i++) {
+ switch (u) {
+ case GPRS_TMR_2SECONDS:
+ OSMO_ASSERT(gprs_tmr_to_secs(u + i) == 2 * i);
+ break;
+
+ default:
+ case GPRS_TMR_MINUTE:
+ OSMO_ASSERT(gprs_tmr_to_secs(u + i) == 60 * i);
+ break;
+
+ case GPRS_TMR_6MINUTE:
+ OSMO_ASSERT(gprs_tmr_to_secs(u + i) == 360 * i);
+ break;
+
+ case GPRS_TMR_DEACTIVATED:
+ OSMO_ASSERT(gprs_tmr_to_secs(u + i) == -1);
+ break;
+ }
+
+ OSMO_ASSERT(gprs_tmr_to_secs(u + i) < upper_secs_test_limit);
+ }
+ }
+
+ /* Check gprs_secs_to_tmr_floor for secs that can exactly be
+ * represented as GPRS timer values */
+ for (i = 0; i < GPRS_TMR_DEACTIVATED; i++) {
+ int j;
+ secs = gprs_tmr_to_secs(i);
+ tmr = gprs_secs_to_tmr_floor(secs);
+ OSMO_ASSERT(secs == gprs_tmr_to_secs(tmr));
+
+ /* Check that the highest resolution is used */
+ for (j = 0; j < tmr; j++)
+ OSMO_ASSERT(secs != gprs_tmr_to_secs(j));
+ }
+ OSMO_ASSERT(GPRS_TMR_DEACTIVATED == gprs_secs_to_tmr_floor(-1));
+
+ /* Check properties of gprs_secs_to_tmr_floor */
+ for (secs = 0; secs <= upper_secs_test_limit; secs++) {
+ int tmr = gprs_secs_to_tmr_floor(secs);
+ int delta_secs = gprs_tmr_to_secs((tmr & ~0x1f) | 1);
+ dec_secs = gprs_tmr_to_secs(tmr);
+
+ /* Check floor */
+ OSMO_ASSERT(dec_secs <= secs);
+ /* Check monotonicity */
+ OSMO_ASSERT(dec_secs >= last_dec_secs);
+ /* Check max distance (<= resolution) */
+ OSMO_ASSERT(dec_secs - last_dec_secs <= delta_secs);
+
+ last_dec_secs = dec_secs;
+ }
+}
+
+const struct log_info_cat default_categories[] = {
+ [DGPRS] = {
+ .name = "DGPRS",
+ .description = "GPRS Packet Service",
+ .enabled = 0, .loglevel = LOGL_DEBUG,
+ },
+};
+
+static struct log_info info = {
+ .cat = default_categories,
+ .num_cat = ARRAY_SIZE(default_categories),
+};
+
+int main(int argc, char **argv)
+{
+ osmo_init_logging(&info);
+
+ test_8_4_2();
+ test_gsm_03_03_apn();
+ test_gprs_timer_enc_dec();
+
+ printf("Done.\n");
+ return EXIT_SUCCESS;
+}
diff --git a/tests/gprs/gprs_test.ok b/tests/gprs/gprs_test.ok
new file mode 100644
index 000000000..da7888c6a
--- /dev/null
+++ b/tests/gprs/gprs_test.ok
@@ -0,0 +1,17 @@
+Testing gprs_llc_is_retransmit.
+N(U) = 0, V(UR) = 0 => new
+N(U) = 0, V(UR) = 1 => retransmit
+N(U) = 0, V(UR) = 1 => retransmit
+N(U) = 511, V(UR) = 1 => retransmit
+N(U) = 483, V(UR) = 1 => retransmit
+N(U) = 482, V(UR) = 1 => retransmit
+N(U) = 481, V(UR) = 1 => new
+N(U) = 0, V(UR) = 240 => new
+N(U) = 0, V(UR) = 511 => new
+N(U) = 1, V(UR) = 511 => new
+N(U) = 511, V(UR) = 511 => new
+N(U) = 510, V(UR) = 511 => retransmit
+N(U) = 481, V(UR) = 511 => retransmit
+N(U) = 479, V(UR) = 511 => new
+Test GPRS timer decoding/encoding
+Done.
diff --git a/tests/gsm0408/Makefile.am b/tests/gsm0408/Makefile.am
new file mode 100644
index 000000000..ae81c2c7c
--- /dev/null
+++ b/tests/gsm0408/Makefile.am
@@ -0,0 +1,34 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ gsm0408_test \
+ $(NULL)
+
+EXTRA_DIST = \
+ gsm0408_test.ok \
+ $(NULL)
+
+gsm0408_test_SOURCES = \
+ gsm0408_test.c \
+ $(NULL)
+
+gsm0408_test_LDADD = \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOABIS_LIBS) \
+ -ldbi \
+ $(NULL)
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
new file mode 100644
index 000000000..5a8c6ca52
--- /dev/null
+++ b/tests/gsm0408/gsm0408_test.c
@@ -0,0 +1,697 @@
+/* simple test for the gsm0408 formatting functions */
+/*
+ * (C) 2008 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * All Rights Reserved
+ *
+ * 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 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/>.
+ *
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <arpa/inet.h>
+
+#include <openbsc/common_bsc.h>
+#include <openbsc/gsm_04_08.h>
+#include <openbsc/gsm_04_11.h>
+#include <openbsc/gsm_subscriber.h>
+#include <openbsc/gsm_data_shared.h>
+#include <openbsc/debug.h>
+#include <openbsc/arfcn_range_encode.h>
+#include <openbsc/system_information.h>
+#include <openbsc/abis_rsl.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/gsm/sysinfo.h>
+
+#define COMPARE(result, op, value) \
+ if (!((result) op (value))) {\
+ fprintf(stderr, "Compare failed. Was %x should be %x in %s:%d\n",result, value, __FILE__, __LINE__); \
+ exit(-1); \
+ }
+
+#define COMPARE_STR(result, value) \
+ if (strcmp(result, value) != 0) { \
+ fprintf(stderr, "Compare failed. Was %s should be %s in %s:%d\n",result, value, __FILE__, __LINE__); \
+ exit(-1); \
+ }
+
+#define DBG(...)
+
+#define VERIFY(res, cmp, wanted) \
+ if (!(res cmp wanted)) { \
+ printf("ASSERT failed: %s:%d Wanted: %d %s %d\n", \
+ __FILE__, __LINE__, (int) res, # cmp, (int) wanted); \
+ }
+
+
+
+/*
+ * Test Location Area Identifier formatting. Table 10.5.3 of 04.08
+ */
+static void test_location_area_identifier(void)
+{
+ struct gsm48_loc_area_id lai48;
+
+ printf("Testing test location area identifier\n");
+
+ /*
+ * Test the default/test setup. Coming from
+ * bsc_hack.c dumps
+ */
+ gsm48_generate_lai(&lai48, 1, 1, 1);
+ COMPARE(lai48.digits[0], ==, 0x00);
+ COMPARE(lai48.digits[1], ==, 0xF1);
+ COMPARE(lai48.digits[2], ==, 0x10);
+ COMPARE(lai48.lac, ==, htons(0x0001));
+
+ gsm48_generate_lai(&lai48, 602, 1, 15);
+ COMPARE(lai48.digits[0], ==, 0x06);
+ COMPARE(lai48.digits[1], ==, 0xF2);
+ COMPARE(lai48.digits[2], ==, 0x10);
+ COMPARE(lai48.lac, ==, htons(0x000f));
+}
+
+static inline void gen(struct gsm_bts *bts, const char *s)
+{
+ int r;
+
+ bts->si_valid = 0;
+ bts->si_valid |= (1 << SYSINFO_TYPE_2quater);
+
+ printf("generating SI2quater for %zu EARFCNs and %zu UARFCNs...\n",
+ si2q_earfcn_count(&bts->si_common.si2quater_neigh_list), bts->si_common.uarfcn_length);
+
+ r = gsm_generate_si(bts, SYSINFO_TYPE_2quater);
+ if (r > 0)
+ for (bts->si2q_index = 0; bts->si2q_index < bts->si2q_count + 1; bts->si2q_index++)
+ printf("generated %s SI2quater [%02u/%02u]: [%d] %s\n",
+ GSM_BTS_HAS_SI(bts, SYSINFO_TYPE_2quater) ? "valid" : "invalid",
+ bts->si2q_index, bts->si2q_count, r,
+ osmo_hexdump((void *)GSM_BTS_SI2Q(bts, bts->si2q_index), GSM_MACBLOCK_LEN));
+ else
+ printf("%s() failed to generate SI2quater: %s\n", s, strerror(-r));
+}
+
+static inline void del_earfcn_b(struct gsm_bts *bts, uint16_t earfcn)
+{
+ struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list;
+ int r = osmo_earfcn_del(e, earfcn);
+ if (r)
+ printf("failed to remove EARFCN %u: %s\n", earfcn, strerror(-r));
+ else
+ printf("removed EARFCN %u - ", earfcn);
+
+ gen(bts, __func__);
+}
+
+static inline void add_earfcn_b(struct gsm_bts *bts, uint16_t earfcn, uint8_t bw)
+{
+ struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list;
+ int r = osmo_earfcn_add(e, earfcn, bw);
+ if (r)
+ printf("failed to add EARFCN %u: %s\n", earfcn, strerror(-r));
+ else
+ printf("added EARFCN %u - ", earfcn);
+
+ gen(bts, __func__);
+}
+
+static inline void _bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble, bool diversity)
+{
+ int r;
+
+ bts->u_offset = 0;
+
+ r = bts_uarfcn_add(bts, arfcn, scramble, diversity);
+ if (r < 0)
+ printf("failed to add UARFCN to SI2quater: %s\n", strerror(-r));
+ else {
+ bts->si2q_count = si2q_num(bts) - 1;
+ gen(bts, __func__);
+ }
+}
+
+static inline void test_si2q_segfault(void)
+{
+ struct gsm_bts *bts;
+ struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ printf("Test SI2quater UARFCN (same scrambling code and diversity):\n");
+
+ if (!network)
+ exit(1);
+ bts = gsm_bts_alloc(network);
+
+ _bts_uarfcn_add(bts, 10564, 319, 0);
+ _bts_uarfcn_add(bts, 10612, 319, 0);
+ gen(bts, __func__);
+}
+
+static inline void test_si2q_mu(void)
+{
+ struct gsm_bts *bts;
+ struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ printf("Test SI2quater multiple UARFCNs:\n");
+
+ if (!network)
+ exit(1);
+ bts = gsm_bts_alloc(network);
+
+ _bts_uarfcn_add(bts, 10564, 318, 0);
+ _bts_uarfcn_add(bts, 10612, 319, 0);
+ _bts_uarfcn_add(bts, 10612, 31, 0);
+ _bts_uarfcn_add(bts, 10612, 19, 0);
+ _bts_uarfcn_add(bts, 10613, 64, 0);
+ _bts_uarfcn_add(bts, 10613, 164, 0);
+ _bts_uarfcn_add(bts, 10613, 14, 0);
+}
+
+static inline void test_si2q_u(void)
+{
+ struct gsm_bts *bts;
+ struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ printf("Testing SYSINFO_TYPE_2quater UARFCN generation:\n");
+
+ if (!network)
+ exit(1);
+
+ bts = gsm_bts_alloc(network);
+
+ /* first generate invalid SI as no UARFCN added */
+ gen(bts, __func__);
+
+ /* subsequent calls should produce valid SI if there's enough memory */
+ _bts_uarfcn_add(bts, 1982, 13, 1);
+ _bts_uarfcn_add(bts, 1982, 44, 0);
+ _bts_uarfcn_add(bts, 1982, 61, 1);
+ _bts_uarfcn_add(bts, 1982, 89, 1);
+ _bts_uarfcn_add(bts, 1982, 113, 0);
+ _bts_uarfcn_add(bts, 1982, 123, 0);
+ _bts_uarfcn_add(bts, 1982, 56, 1);
+ _bts_uarfcn_add(bts, 1982, 72, 1);
+ _bts_uarfcn_add(bts, 1982, 223, 1);
+ _bts_uarfcn_add(bts, 1982, 14, 0);
+ _bts_uarfcn_add(bts, 1982, 88, 0);
+}
+
+static inline void test_si2q_e(void)
+{
+ struct gsm_bts *bts;
+ struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ printf("Testing SYSINFO_TYPE_2quater EARFCN generation:\n");
+
+ if (!network)
+ exit(1);
+
+ bts = gsm_bts_alloc(network);
+
+ bts->si_common.si2quater_neigh_list.arfcn = bts->si_common.data.earfcn_list;
+ bts->si_common.si2quater_neigh_list.meas_bw = bts->si_common.data.meas_bw_list;
+ bts->si_common.si2quater_neigh_list.length = MAX_EARFCN_LIST;
+ bts->si_common.si2quater_neigh_list.thresh_hi = 5;
+
+ osmo_earfcn_init(&bts->si_common.si2quater_neigh_list);
+
+ /* first generate invalid SI as no EARFCN added */
+ gen(bts, __func__);
+
+ /* subsequent calls should produce valid SI if there's enough memory and EARFCNs */
+ add_earfcn_b(bts, 1917, 5);
+ del_earfcn_b(bts, 1917);
+ add_earfcn_b(bts, 1917, 1);
+ add_earfcn_b(bts, 1932, OSMO_EARFCN_MEAS_INVALID);
+ add_earfcn_b(bts, 1937, 2);
+ add_earfcn_b(bts, 1945, OSMO_EARFCN_MEAS_INVALID);
+ add_earfcn_b(bts, 1965, OSMO_EARFCN_MEAS_INVALID);
+ add_earfcn_b(bts, 1967, 4);
+ add_earfcn_b(bts, 1982, 3);
+}
+
+static inline void test_si2q_long(void)
+{
+ struct gsm_bts *bts;
+ struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ printf("Testing SYSINFO_TYPE_2quater combined EARFCN & UARFCN generation:\n");
+
+ if (!network)
+ exit(1);
+
+ bts = gsm_bts_alloc(network);
+
+ bts->si_common.si2quater_neigh_list.arfcn = bts->si_common.data.earfcn_list;
+ bts->si_common.si2quater_neigh_list.meas_bw = bts->si_common.data.meas_bw_list;
+ bts->si_common.si2quater_neigh_list.length = MAX_EARFCN_LIST;
+ bts->si_common.si2quater_neigh_list.thresh_hi = 5;
+
+ osmo_earfcn_init(&bts->si_common.si2quater_neigh_list);
+
+ bts_earfcn_add(bts, 1922, 11, 22, 8,32, 8);
+ bts_earfcn_add(bts, 1922, 11, 22, 8, 32, 8);
+ bts_earfcn_add(bts, 1924, 11, 12, 6, 11, 5);
+ bts_earfcn_add(bts, 1923, 11, 12, 6, 11, 5);
+ bts_earfcn_add(bts, 1925, 11, 12, 6, 11, 5);
+ bts_earfcn_add(bts, 2111, 11, 12, 6, 11, 5);
+ bts_earfcn_add(bts, 2112, 11, 12, 6, 11, 4);
+ bts_earfcn_add(bts, 2113, 11, 12, 6, 11, 3);
+ bts_earfcn_add(bts, 2114, 11, 12, 6, 11, 2);
+ bts_earfcn_add(bts, 2131, 11, 12, 6, 11, 5);
+ bts_earfcn_add(bts, 2132, 11, 12, 6, 11, 4);
+ bts_earfcn_add(bts, 2133, 11, 12, 6, 11, 3);
+ bts_earfcn_add(bts, 2134, 11, 12, 6, 11, 2);
+ bts_earfcn_add(bts, 2121, 11, 12, 6, 11, 5);
+ bts_earfcn_add(bts, 2122, 11, 12, 6, 11, 4);
+ bts_earfcn_add(bts, 2123, 11, 12, 6, 11, 3);
+ bts_earfcn_add(bts, 2124, 11, 12, 6, 11, 2);
+ _bts_uarfcn_add(bts, 1976, 13, 1);
+ _bts_uarfcn_add(bts, 1976, 38, 1);
+ _bts_uarfcn_add(bts, 1976, 44, 1);
+ _bts_uarfcn_add(bts, 1976, 120, 1);
+ _bts_uarfcn_add(bts, 1976, 140, 1);
+ _bts_uarfcn_add(bts, 1976, 163, 1);
+ _bts_uarfcn_add(bts, 1976, 166, 1);
+ _bts_uarfcn_add(bts, 1976, 217, 1);
+ _bts_uarfcn_add(bts, 1976, 224, 1);
+ _bts_uarfcn_add(bts, 1976, 225, 1);
+ _bts_uarfcn_add(bts, 1976, 226, 1);
+}
+
+static void test_mi_functionality(void)
+{
+ const char *imsi_odd = "987654321098763";
+ const char *imsi_even = "9876543210987654";
+ const uint32_t tmsi = 0xfabeacd0;
+ uint8_t mi[128];
+ unsigned int mi_len;
+ char mi_parsed[GSM48_MI_SIZE];
+
+ printf("Testing parsing and generating TMSI/IMSI\n");
+
+ /* tmsi code */
+ mi_len = gsm48_generate_mid_from_tmsi(mi, tmsi);
+ gsm48_mi_to_string(mi_parsed, sizeof(mi_parsed), mi + 2, mi_len - 2);
+ COMPARE((uint32_t)strtoul(mi_parsed, NULL, 10), ==, tmsi);
+
+ /* imsi code */
+ mi_len = gsm48_generate_mid_from_imsi(mi, imsi_odd);
+ gsm48_mi_to_string(mi_parsed, sizeof(mi_parsed), mi + 2, mi_len -2);
+ printf("hex: %s\n", osmo_hexdump(mi, mi_len));
+ COMPARE_STR(mi_parsed, imsi_odd);
+
+ mi_len = gsm48_generate_mid_from_imsi(mi, imsi_even);
+ gsm48_mi_to_string(mi_parsed, sizeof(mi_parsed), mi + 2, mi_len -2);
+ printf("hex: %s\n", osmo_hexdump(mi, mi_len));
+ COMPARE_STR(mi_parsed, imsi_even);
+}
+
+struct {
+ int range;
+ int arfcns_num;
+ int arfcns[RANGE_ENC_MAX_ARFCNS];
+} arfcn_test_ranges[] = {
+ {ARFCN_RANGE_512, 12,
+ { 1, 12, 31, 51, 57, 91, 97, 98, 113, 117, 120, 125 }},
+ {ARFCN_RANGE_512, 17,
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }},
+ {ARFCN_RANGE_512, 18,
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }},
+ {ARFCN_RANGE_512, 18,
+ { 1, 17, 31, 45, 58, 79, 81, 97,
+ 113, 127, 213, 277, 287, 311, 331, 391,
+ 417, 511 }},
+ {ARFCN_RANGE_512, 6,
+ { 1, 17, 31, 45, 58, 79 }},
+ {ARFCN_RANGE_512, 6,
+ { 10, 17, 31, 45, 58, 79 }},
+ {ARFCN_RANGE_1024, 17,
+ { 0, 17, 31, 45, 58, 79, 81, 97,
+ 113, 127, 213, 277, 287, 311, 331, 391,
+ 1023 }},
+ {ARFCN_RANGE_1024, 16,
+ { 17, 31, 45, 58, 79, 81, 97, 113,
+ 127, 213, 277, 287, 311, 331, 391, 1023 }},
+ {-1}
+};
+
+static int test_single_range_encoding(int range, const int *orig_arfcns,
+ int arfcns_num, int silent)
+{
+ int arfcns[RANGE_ENC_MAX_ARFCNS];
+ int w[RANGE_ENC_MAX_ARFCNS];
+ int f0_included = 0;
+ int rc, f0;
+ uint8_t chan_list[16] = {0};
+ struct gsm_sysinfo_freq dec_freq[1024] = {{0}};
+ int dec_arfcns[RANGE_ENC_MAX_ARFCNS] = {0};
+ int dec_arfcns_count = 0;
+ int arfcns_used = 0;
+ int i;
+
+ arfcns_used = arfcns_num;
+ memmove(arfcns, orig_arfcns, sizeof(arfcns));
+
+ f0 = range == ARFCN_RANGE_1024 ? 0 : arfcns[0];
+ /*
+ * Manipulate the ARFCN list according to the rules in J4 depending
+ * on the selected range.
+ */
+ arfcns_used = range_enc_filter_arfcns(arfcns, arfcns_used,
+ f0, &f0_included);
+
+ memset(w, 0, sizeof(w));
+ range_enc_arfcns(range, arfcns, arfcns_used, w, 0);
+
+ if (!silent)
+ fprintf(stderr, "range=%d, arfcns_used=%d, f0=%d, f0_included=%d\n",
+ range, arfcns_used, f0, f0_included);
+
+ /* Select the range and the amount of bits needed */
+ switch (range) {
+ case ARFCN_RANGE_128:
+ range_enc_range128(chan_list, f0, w);
+ break;
+ case ARFCN_RANGE_256:
+ range_enc_range256(chan_list, f0, w);
+ break;
+ case ARFCN_RANGE_512:
+ range_enc_range512(chan_list, f0, w);
+ break;
+ case ARFCN_RANGE_1024:
+ range_enc_range1024(chan_list, f0, f0_included, w);
+ break;
+ default:
+ return 1;
+ };
+
+ if (!silent)
+ printf("chan_list = %s\n",
+ osmo_hexdump(chan_list, sizeof(chan_list)));
+
+ rc = gsm48_decode_freq_list(dec_freq, chan_list, sizeof(chan_list),
+ 0xfe, 1);
+ if (rc != 0) {
+ printf("Cannot decode freq list, rc = %d\n", rc);
+ return 1;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(dec_freq); i++) {
+ if (dec_freq[i].mask &&
+ dec_arfcns_count < ARRAY_SIZE(dec_arfcns))
+ dec_arfcns[dec_arfcns_count++] = i;
+ }
+
+ if (!silent) {
+ printf("Decoded freqs %d (expected %d)\n",
+ dec_arfcns_count, arfcns_num);
+ printf("Decoded: ");
+ for (i = 0; i < dec_arfcns_count; i++) {
+ printf("%d ", dec_arfcns[i]);
+ if (dec_arfcns[i] != orig_arfcns[i])
+ printf("(!= %d) ", orig_arfcns[i]);
+ }
+ printf("\n");
+ }
+
+ if (dec_arfcns_count != arfcns_num) {
+ printf("Wrong number of arfcns\n");
+ return 1;
+ }
+
+ if (memcmp(dec_arfcns, orig_arfcns, sizeof(dec_arfcns)) != 0) {
+ printf("Decoding error, got wrong freqs\n");
+ fprintf(stderr, " w = ");
+ for (i = 0; i < ARRAY_SIZE(w); i++)
+ fprintf(stderr, "%d ", w[i]);
+ fprintf(stderr, "\n");
+ return 1;
+ }
+
+ return 0;
+}
+
+static void test_random_range_encoding(int range, int max_arfcn_num)
+{
+ int arfcns_num = 0;
+ int test_idx;
+ int rc, max_count;
+ int num_tests = 1024;
+
+ printf("Random range test: range %d, max num ARFCNs %d\n",
+ range, max_arfcn_num);
+
+ srandom(1);
+
+ for (max_count = 1; max_count < max_arfcn_num; max_count++) {
+ for (test_idx = 0; test_idx < num_tests; test_idx++) {
+ int count;
+ int i;
+ int min_freq = 0;
+
+ int rnd_arfcns[RANGE_ENC_MAX_ARFCNS] = {0};
+ char rnd_arfcns_set[1024] = {0};
+
+ if (range < ARFCN_RANGE_1024)
+ min_freq = random() % (1023 - range);
+
+ for (count = max_count; count; ) {
+ int arfcn = min_freq + random() % (range + 1);
+ OSMO_ASSERT(arfcn < ARRAY_SIZE(rnd_arfcns_set));
+
+ if (!rnd_arfcns_set[arfcn]) {
+ rnd_arfcns_set[arfcn] = 1;
+ count -= 1;
+ }
+ }
+
+ arfcns_num = 0;
+ for (i = 0; i < ARRAY_SIZE(rnd_arfcns_set); i++)
+ if (rnd_arfcns_set[i])
+ rnd_arfcns[arfcns_num++] = i;
+
+ rc = test_single_range_encoding(range, rnd_arfcns,
+ arfcns_num, 1);
+ if (rc != 0) {
+ printf("Failed on test %d, range %d, num ARFCNs %d\n",
+ test_idx, range, max_count);
+ test_single_range_encoding(range, rnd_arfcns,
+ arfcns_num, 0);
+ return;
+ }
+ }
+ }
+}
+
+static void test_range_encoding()
+{
+ int *arfcns;
+ int arfcns_num = 0;
+ int test_idx;
+ int range;
+
+ for (test_idx = 0; arfcn_test_ranges[test_idx].arfcns_num > 0; test_idx++)
+ {
+ arfcns_num = arfcn_test_ranges[test_idx].arfcns_num;
+ arfcns = &arfcn_test_ranges[test_idx].arfcns[0];
+ range = arfcn_test_ranges[test_idx].range;
+
+ printf("Range test %d: range %d, num ARFCNs %d\n",
+ test_idx, range, arfcns_num);
+
+ test_single_range_encoding(range, arfcns, arfcns_num, 0);
+ }
+
+ test_random_range_encoding(ARFCN_RANGE_128, 29);
+ test_random_range_encoding(ARFCN_RANGE_256, 22);
+ test_random_range_encoding(ARFCN_RANGE_512, 18);
+ test_random_range_encoding(ARFCN_RANGE_1024, 16);
+}
+
+static int freqs1[] = {
+ 12, 70, 121, 190, 250, 320, 401, 475, 520, 574, 634, 700, 764, 830, 905, 980
+};
+
+static int freqs2[] = {
+ 402, 460, 1, 67, 131, 197, 272, 347,
+};
+
+static int freqs3[] = {
+ 68, 128, 198, 279, 353, 398, 452,
+
+};
+
+static int w_out[] = {
+ 122, 2, 69, 204, 75, 66, 60, 70, 83, 3, 24, 67, 54, 64, 70, 9,
+};
+
+static int range128[] = {
+ 1, 1 + 127,
+};
+
+static int range256[] = {
+ 1, 1 + 128,
+};
+
+static int range512[] = {
+ 1, 1+ 511,
+};
+
+
+static void test_arfcn_filter()
+{
+ int arfcns[50], i, res, f0_included;
+ for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
+ arfcns[i] = (i + 1) * 2;
+
+ /* check that the arfcn is taken out. f0_included is only set for Range1024 */
+ f0_included = 24;
+ res = range_enc_filter_arfcns(arfcns, ARRAY_SIZE(arfcns),
+ arfcns[0], &f0_included);
+ VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
+ VERIFY(f0_included, ==, 1);
+ for (i = 0; i < res; ++i)
+ VERIFY(arfcns[i], ==, ((i+2) * 2) - (2+1));
+
+ /* check with range1024, ARFCN 0 is included */
+ for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
+ arfcns[i] = i * 2;
+ res = range_enc_filter_arfcns(arfcns, ARRAY_SIZE(arfcns),
+ 0, &f0_included);
+ VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
+ VERIFY(f0_included, ==, 1);
+ for (i = 0; i < res; ++i)
+ VERIFY(arfcns[i], ==, (i + 1) * 2 - 1);
+
+ /* check with range1024, ARFCN 0 not included */
+ for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
+ arfcns[i] = (i + 1) * 2;
+ res = range_enc_filter_arfcns(arfcns, ARRAY_SIZE(arfcns),
+ 0, &f0_included);
+ VERIFY(res, ==, ARRAY_SIZE(arfcns));
+ VERIFY(f0_included, ==, 0);
+ for (i = 0; i < res; ++i)
+ VERIFY(arfcns[i], ==, ((i + 1) * 2) - 1);
+}
+
+static void test_print_encoding()
+{
+ int rc;
+ int w[17];
+ uint8_t chan_list[16];
+ memset(chan_list, 0x23, sizeof(chan_list));
+
+ for (rc = 0; rc < ARRAY_SIZE(w); ++rc)
+ switch (rc % 3) {
+ case 0:
+ w[rc] = 0xAAAA;
+ break;
+ case 1:
+ w[rc] = 0x5555;
+ break;
+ case 2:
+ w[rc] = 0x9696;
+ break;
+ }
+
+ range_enc_range512(chan_list, (1 << 9) | 0x96, w);
+
+ printf("Range512: %s\n", osmo_hexdump(chan_list, ARRAY_SIZE(chan_list)));
+}
+
+static void test_si_range_helpers()
+{
+ int ws[(sizeof(freqs1)/sizeof(freqs1[0]))];
+ int i, f0 = 0xFFFFFF;
+
+ memset(&ws[0], 0x23, sizeof(ws));
+
+ i = range_enc_find_index(1023, freqs1, ARRAY_SIZE(freqs1));
+ printf("Element is: %d => freqs[i] = %d\n", i, i >= 0 ? freqs1[i] : -1);
+ VERIFY(i, ==, 2);
+
+ i = range_enc_find_index(511, freqs2, ARRAY_SIZE(freqs2));
+ printf("Element is: %d => freqs[i] = %d\n", i, i >= 0 ? freqs2[i] : -1);
+ VERIFY(i, ==, 2);
+
+ i = range_enc_find_index(511, freqs3, ARRAY_SIZE(freqs3));
+ printf("Element is: %d => freqs[i] = %d\n", i, i >= 0 ? freqs3[i] : -1);
+ VERIFY(i, ==, 0);
+
+ range_enc_arfcns(1023, freqs1, ARRAY_SIZE(freqs1), ws, 0);
+
+ for (i = 0; i < sizeof(freqs1)/sizeof(freqs1[0]); ++i) {
+ printf("w[%d]=%d\n", i, ws[i]);
+ VERIFY(ws[i], ==, w_out[i]);
+ }
+
+ i = range_enc_determine_range(range128, ARRAY_SIZE(range128), &f0);
+ VERIFY(i, ==, ARFCN_RANGE_128);
+ VERIFY(f0, ==, 1);
+
+ i = range_enc_determine_range(range256, ARRAY_SIZE(range256), &f0);
+ VERIFY(i, ==, ARFCN_RANGE_256);
+ VERIFY(f0, ==, 1);
+
+ i = range_enc_determine_range(range512, ARRAY_SIZE(range512), &f0);
+ VERIFY(i, ==, ARFCN_RANGE_512);
+ VERIFY(f0, ==, 1);
+}
+
+static void test_gsm411_rp_ref_wrap(void)
+{
+ struct gsm_subscriber_connection conn;
+ int res;
+
+ printf("testing RP-Reference wrap\n");
+
+ memset(&conn, 0, sizeof(conn));
+ conn.next_rp_ref = 255;
+
+ res = sms_next_rp_msg_ref(&conn.next_rp_ref);
+ printf("Allocated reference: %d\n", res);
+ OSMO_ASSERT(res == 255);
+
+ res = sms_next_rp_msg_ref(&conn.next_rp_ref);
+ printf("Allocated reference: %d\n", res);
+ OSMO_ASSERT(res == 0);
+
+ res = sms_next_rp_msg_ref(&conn.next_rp_ref);
+ printf("Allocated reference: %d\n", res);
+ OSMO_ASSERT(res == 1);
+}
+
+int main(int argc, char **argv)
+{
+ osmo_init_logging(&log_info);
+ log_set_log_level(osmo_stderr_target, LOGL_INFO);
+
+ test_location_area_identifier();
+ test_mi_functionality();
+
+ test_si_range_helpers();
+ test_arfcn_filter();
+ test_print_encoding();
+ test_range_encoding();
+ test_gsm411_rp_ref_wrap();
+
+ test_si2q_segfault();
+ test_si2q_e();
+ test_si2q_u();
+ test_si2q_mu();
+ test_si2q_long();
+
+ printf("Done.\n");
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
new file mode 100644
index 000000000..d30f42155
--- /dev/null
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -0,0 +1,204 @@
+Testing test location area identifier
+Testing parsing and generating TMSI/IMSI
+hex: 17 08 99 78 56 34 12 90 78 36
+hex: 17 09 91 78 56 34 12 90 78 56 f4
+Element is: 2 => freqs[i] = 121
+Element is: 2 => freqs[i] = 1
+Element is: 0 => freqs[i] = 68
+w[0]=122
+w[1]=2
+w[2]=69
+w[3]=204
+w[4]=75
+w[5]=66
+w[6]=60
+w[7]=70
+w[8]=83
+w[9]=3
+w[10]=24
+w[11]=67
+w[12]=54
+w[13]=64
+w[14]=70
+w[15]=9
+Range512: 89 4b 2a 95 65 95 55 2c a9 55 aa 55 6a 95 59 55
+Range test 0: range 511, num ARFCNs 12
+chan_list = 88 00 98 34 85 36 7c 50 22 dc 5e ec 00 00 00 00
+Decoded freqs 12 (expected 12)
+Decoded: 1 12 31 51 57 91 97 98 113 117 120 125
+Range test 1: range 511, num ARFCNs 17
+chan_list = 88 00 82 7f 01 3f 7e 04 0b ff ff fc 10 41 07 e0
+Decoded freqs 17 (expected 17)
+Decoded: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+Range test 2: range 511, num ARFCNs 18
+chan_list = 88 00 82 7f 01 7f 7e 04 0b ff ff fc 10 41 07 ff
+Decoded freqs 18 (expected 18)
+Decoded: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
+Range test 3: range 511, num ARFCNs 18
+chan_list = 88 00 94 3a 44 32 d7 2a 43 2a 13 94 e5 38 39 f6
+Decoded freqs 18 (expected 18)
+Decoded: 1 17 31 45 58 79 81 97 113 127 213 277 287 311 331 391 417 511
+Range test 4: range 511, num ARFCNs 6
+chan_list = 88 00 8b 3c 88 b9 6b 00 00 00 00 00 00 00 00 00
+Decoded freqs 6 (expected 6)
+Decoded: 1 17 31 45 58 79
+Range test 5: range 511, num ARFCNs 6
+chan_list = 88 05 08 fc 88 b9 6b 00 00 00 00 00 00 00 00 00
+Decoded freqs 6 (expected 6)
+Decoded: 10 17 31 45 58 79
+Range test 6: range 1023, num ARFCNs 17
+chan_list = 84 71 e4 ab b9 58 05 cb 39 17 fd b0 75 62 0f 2f
+Decoded freqs 17 (expected 17)
+Decoded: 0 17 31 45 58 79 81 97 113 127 213 277 287 311 331 391 1023
+Range test 7: range 1023, num ARFCNs 16
+chan_list = 80 71 e4 ab b9 58 05 cb 39 17 fd b0 75 62 0f 2f
+Decoded freqs 16 (expected 16)
+Decoded: 17 31 45 58 79 81 97 113 127 213 277 287 311 331 391 1023
+Random range test: range 127, max num ARFCNs 29
+Random range test: range 255, max num ARFCNs 22
+Random range test: range 511, max num ARFCNs 18
+Random range test: range 1023, max num ARFCNs 16
+testing RP-Reference wrap
+Allocated reference: 255
+Allocated reference: 0
+Allocated reference: 1
+Test SI2quater UARFCN (same scrambling code and diversity):
+generating SI2quater for 0 EARFCNs and 1 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 52 88 0a 7e 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 2 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 52 e8 0a 7f 52 88 0a 7e 0b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 2 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 52 e8 0a 7f 52 88 0a 7e 0b 2b 2b 2b 2b 2b 2b 2b 2b
+Testing SYSINFO_TYPE_2quater EARFCN generation:
+generating SI2quater for 0 EARFCNs and 0 UARFCNs...
+generated invalid SI2quater [00/00]: [23] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+added EARFCN 1917 - generating SI2quater for 1 EARFCNs and 0 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 04 86 59 83 be e8 50 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+removed EARFCN 1917 - generating SI2quater for 0 EARFCNs and 0 UARFCNs...
+generated invalid SI2quater [00/00]: [23] 59 06 07 c0 00 04 86 59 83 be e8 50 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+added EARFCN 1917 - generating SI2quater for 1 EARFCNs and 0 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 04 86 59 83 be c8 50 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+added EARFCN 1932 - generating SI2quater for 2 EARFCNs and 0 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 30 14 03 2b 2b 2b 2b 2b 2b 2b 2b
+added EARFCN 1937 - generating SI2quater for 3 EARFCNs and 0 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a0 a0 2b 2b 2b 2b 2b 2b
+added EARFCN 1945 - generating SI2quater for 4 EARFCNs and 0 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a8 3c c8 28 0b 2b 2b 2b
+added EARFCN 1965 - generating SI2quater for 5 EARFCNs and 0 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a8 3c ca 0f 5a 0a 03 2b
+added EARFCN 1967 - generating SI2quater for 6 EARFCNs and 0 UARFCNs...
+generated valid SI2quater [00/01]: [23] 59 06 07 c0 20 04 86 59 83 be cc 1e 31 07 91 a8 3c ca 0f 5a 0a 03 2b
+generated valid SI2quater [01/01]: [23] 59 06 07 c2 20 04 86 59 83 d7 e0 50 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+added EARFCN 1982 - generating SI2quater for 7 EARFCNs and 0 UARFCNs...
+generated valid SI2quater [00/01]: [23] 59 06 07 c0 20 04 86 59 83 be cc 1e 31 07 91 a8 3c ca 0f 5a 0a 03 2b
+generated valid SI2quater [01/01]: [23] 59 06 07 c2 20 04 86 59 83 d7 e4 1e fa c2 80 2b 2b 2b 2b 2b 2b 2b 2b
+Testing SYSINFO_TYPE_2quater UARFCN generation:
+generating SI2quater for 0 EARFCNs and 0 UARFCNs...
+generated invalid SI2quater [00/00]: [23] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+generating SI2quater for 0 EARFCNs and 1 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 0f 7c 0c 1a 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 2 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 0f 7c 14 1a 1f 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 3 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 0f 7c 18 58 12 f0 83 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 4 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 0f 7c 20 58 2e f0 f2 03 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 5 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 0f 7c 28 58 2e 22 f2 4e 83 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 6 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 0f 7c 34 1a 64 26 5d f2 05 03 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 7 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 0f 7c 38 58 12 22 fd ce 8e 05 03 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 8 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 0f 7c 40 58 1d 22 fa ce 88 85 7b 0b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 9 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 0f 7c 4c 7a 34 0e 64 77 85 43 55 c8 0b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 10 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 0f 7c 50 1c 3b 31 fa dd 88 85 7b c4 1c 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 11 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 0f 7c 58 1c 3b 25 7a ea 08 91 fb c4 1f b0 2b 2b 2b
+Test SI2quater multiple UARFCNs:
+generating SI2quater for 0 EARFCNs and 1 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 52 88 0a 7c 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 2 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 52 e8 0a 7f 52 88 0a 7c 0b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 3 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 52 e8 12 7e e0 a9 44 05 3e 0b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 4 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 52 e8 18 3f f4 90 54 a2 02 9f 03 2b 2b 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 5 UARFCNs...
+generated valid SI2quater [00/00]: [23] 59 06 07 c0 00 25 52 ea 08 81 52 e8 18 3f f4 90 54 a2 02 9f 03 2b 2b
+generating SI2quater for 0 EARFCNs and 6 UARFCNs...
+generated valid SI2quater [00/01]: [23] 59 06 07 c0 20 25 52 ea 08 81 52 e8 10 3f f4 a9 75 04 a4 0b 2b 2b 2b
+generated valid SI2quater [01/01]: [23] 59 06 07 c2 20 25 52 e8 28 81 df 7f fa 32 d4 a2 02 9f 03 2b 2b 2b 2b
+generating SI2quater for 0 EARFCNs and 7 UARFCNs...
+generated valid SI2quater [00/01]: [23] 59 06 07 c0 20 25 52 ea 10 81 ce a9 74 08 1f fa 54 ba 82 52 03 2b 2b
+generated valid SI2quater [01/01]: [23] 59 06 07 c2 20 25 52 e8 30 81 d3 7f fd b2 86 54 a2 02 9f 03 2b 2b 2b
+Testing SYSINFO_TYPE_2quater combined EARFCN & UARFCN generation:
+generating SI2quater for 17 EARFCNs and 1 UARFCNs...
+generated valid SI2quater [00/04]: [23] 59 06 07 c0 80 25 0f 70 0c 1a 10 99 66 0f 04 83 c1 1c bb 2b 03 2b 2b
+generated valid SI2quater [01/04]: [23] 59 06 07 c2 80 04 86 59 83 c2 6c 1e 0f 60 f0 bb 08 3f d7 2e ca c1 2b
+generated valid SI2quater [02/04]: [23] 59 06 07 c4 80 04 86 59 84 20 64 21 06 e1 08 55 08 53 d7 2e ca c1 2b
+generated valid SI2quater [03/04]: [23] 59 06 07 c6 80 04 86 59 84 2a 64 21 56 e1 0a d5 08 49 d7 2e ca c1 2b
+generated valid SI2quater [04/04]: [23] 59 06 07 c8 80 04 86 59 84 25 64 21 2e e1 09 94 e5 d9 58 2b 2b 2b 2b
+generating SI2quater for 17 EARFCNs and 2 UARFCNs...
+generated valid SI2quater [00/04]: [23] 59 06 07 c0 80 25 0f 70 14 4d e7 00 44 b3 07 82 41 e0 8e 5d 95 83 2b
+generated valid SI2quater [01/04]: [23] 59 06 07 c2 80 04 86 59 83 c2 6c 1e 0f 60 f0 bb 08 3f d7 2e ca c1 2b
+generated valid SI2quater [02/04]: [23] 59 06 07 c4 80 04 86 59 84 20 64 21 06 e1 08 55 08 53 d7 2e ca c1 2b
+generated valid SI2quater [03/04]: [23] 59 06 07 c6 80 04 86 59 84 2a 64 21 56 e1 0a d5 08 49 d7 2e ca c1 2b
+generated valid SI2quater [04/04]: [23] 59 06 07 c8 80 04 86 59 84 25 64 21 2e e1 09 94 e5 d9 58 2b 2b 2b 2b
+generating SI2quater for 17 EARFCNs and 3 UARFCNs...
+generated valid SI2quater [00/04]: [23] 59 06 07 c0 80 25 0f 70 1c 4d e7 03 04 86 59 83 c1 20 f0 47 2e ca c1
+generated valid SI2quater [01/04]: [23] 59 06 07 c2 80 04 86 59 83 c2 6c 1e 0f 60 f0 bb 08 3f d7 2e ca c1 2b
+generated valid SI2quater [02/04]: [23] 59 06 07 c4 80 04 86 59 84 20 64 21 06 e1 08 55 08 53 d7 2e ca c1 2b
+generated valid SI2quater [03/04]: [23] 59 06 07 c6 80 04 86 59 84 2a 64 21 56 e1 0a d5 08 49 d7 2e ca c1 2b
+generated valid SI2quater [04/04]: [23] 59 06 07 c8 80 04 86 59 84 25 64 21 2e e1 09 94 e5 d9 58 2b 2b 2b 2b
+generating SI2quater for 17 EARFCNs and 4 UARFCNs...
+generated valid SI2quater [00/04]: [23] 59 06 07 c0 80 25 0f 70 24 59 fa 26 73 84 86 59 83 c1 1c bb 2b 03 2b
+generated valid SI2quater [01/04]: [23] 59 06 07 c2 80 04 86 59 83 c1 20 f0 9b 07 83 d8 3c 2e b9 76 56 0b 2b
+generated valid SI2quater [02/04]: [23] 59 06 07 c4 80 04 86 59 84 1f ec 21 03 21 08 37 08 42 a7 2e ca c1 2b
+generated valid SI2quater [03/04]: [23] 59 06 07 c6 80 04 86 59 84 29 ec 21 53 21 0a b7 08 56 a7 2e ca c1 2b
+generated valid SI2quater [04/04]: [23] 59 06 07 c8 80 04 86 59 84 24 ec 21 2b 21 09 77 08 4c a7 2e ca c1 2b
+generating SI2quater for 17 EARFCNs and 5 UARFCNs...
+generated valid SI2quater [00/04]: [23] 59 06 07 c0 80 25 0f 70 2c 59 fa 30 73 f6 04 86 59 83 c1 1c bb 2b 03
+generated valid SI2quater [01/04]: [23] 59 06 07 c2 80 04 86 59 83 c1 20 f0 9b 07 83 d8 3c 2e b9 76 56 0b 2b
+generated valid SI2quater [02/04]: [23] 59 06 07 c4 80 04 86 59 84 1f ec 21 03 21 08 37 08 42 a7 2e ca c1 2b
+generated valid SI2quater [03/04]: [23] 59 06 07 c6 80 04 86 59 84 29 ec 21 53 21 0a b7 08 56 a7 2e ca c1 2b
+generated valid SI2quater [04/04]: [23] 59 06 07 c8 80 04 86 59 84 24 ec 21 2b 21 09 77 08 4c a7 2e ca c1 2b
+generating SI2quater for 17 EARFCNs and 6 UARFCNs...
+generated valid SI2quater [00/05]: [23] 59 06 07 c0 a0 25 0f 70 34 f1 ae 15 f3 f4 83 04 86 59 72 ec ac 0b 2b
+generated valid SI2quater [01/05]: [23] 59 06 07 c2 a0 04 86 59 83 c1 20 f0 48 3c 26 c1 e0 f5 cb b2 b0 2b 2b
+generated valid SI2quater [02/05]: [23] 59 06 07 c4 a0 04 86 59 83 c2 ec 20 ff 61 08 19 08 41 b7 2e ca c1 2b
+generated valid SI2quater [03/05]: [23] 59 06 07 c6 a0 04 86 59 84 21 54 21 4f 61 0a 99 08 55 b7 2e ca c1 2b
+generated valid SI2quater [04/05]: [23] 59 06 07 c8 a0 04 86 59 84 2b 54 21 27 61 09 59 08 4b b7 2e ca c1 2b
+generated valid SI2quater [05/05]: [23] 59 06 07 ca a0 04 86 59 84 26 53 97 65 60 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 17 EARFCNs and 7 UARFCNs...
+generated valid SI2quater [00/05]: [23] 59 06 07 c0 a0 25 0f 70 3c f1 ae 15 f3 f4 83 01 84 86 59 72 ec ac 0b
+generated valid SI2quater [01/05]: [23] 59 06 07 c2 a0 04 86 59 83 c1 20 f0 48 3c 26 c1 e0 f5 cb b2 b0 2b 2b
+generated valid SI2quater [02/05]: [23] 59 06 07 c4 a0 04 86 59 83 c2 ec 20 ff 61 08 19 08 41 b7 2e ca c1 2b
+generated valid SI2quater [03/05]: [23] 59 06 07 c6 a0 04 86 59 84 21 54 21 4f 61 0a 99 08 55 b7 2e ca c1 2b
+generated valid SI2quater [04/05]: [23] 59 06 07 c8 a0 04 86 59 84 2b 54 21 27 61 09 59 08 4b b7 2e ca c1 2b
+generated valid SI2quater [05/05]: [23] 59 06 07 ca a0 04 86 59 84 26 53 97 65 60 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 17 EARFCNs and 8 UARFCNs...
+generated valid SI2quater [00/02]: [23] 59 06 07 c0 40 25 0f 70 45 19 a0 0d 7d 7e a6 19 e7 00 44 b3 07 82 41
+generated valid SI2quater [01/02]: [23] 59 06 07 c2 40 04 86 59 84 2b 54 21 27 61 09 59 08 4b b7 2e ca c1 2b
+generated valid SI2quater [02/02]: [23] 59 06 07 c4 40 04 86 59 84 26 53 97 65 60 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 17 EARFCNs and 9 UARFCNs...
+generated valid SI2quater [00/02]: [23] 59 06 07 c0 40 25 0f 70 4d 19 a0 26 fd 66 a6 03 e7 fa 10 99 66 0f 04
+generated valid SI2quater [01/02]: [23] 59 06 07 c2 40 04 86 59 84 2b 54 21 27 61 09 59 08 4b b7 2e ca c1 2b
+generated valid SI2quater [02/02]: [23] 59 06 07 c4 40 04 86 59 84 26 53 97 65 60 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 17 EARFCNs and 10 UARFCNs...
+generated valid SI2quater [00/05]: [23] 59 06 07 c0 a0 25 0f 70 55 47 89 1e fd 7c b0 00 e7 9b b0 04 12 c8 2b
+generated valid SI2quater [01/05]: [23] 59 06 07 c2 a0 04 86 59 83 c1 20 f0 48 3c 26 c1 e0 f5 cb b2 b0 2b 2b
+generated valid SI2quater [02/05]: [23] 59 06 07 c4 a0 04 86 59 83 c2 ec 20 ff 61 08 19 08 41 b7 2e ca c1 2b
+generated valid SI2quater [03/05]: [23] 59 06 07 c6 a0 04 86 59 84 21 54 21 4f 61 0a 99 08 55 b7 2e ca c1 2b
+generated valid SI2quater [04/05]: [23] 59 06 07 c8 a0 04 86 59 84 2b 54 21 27 61 09 59 08 4b b7 2e ca c1 2b
+generated valid SI2quater [05/05]: [23] 59 06 07 ca a0 04 86 59 84 26 53 97 65 60 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generating SI2quater for 17 EARFCNs and 11 UARFCNs...
+generated valid SI2quater [00/05]: [23] 59 06 07 c0 a0 25 0f 70 5d 47 89 1e fd 7c b0 01 67 9b b3 f8 2b 2b 2b
+generated valid SI2quater [01/05]: [23] 59 06 07 c2 a0 04 86 59 83 c1 20 f0 48 3c 26 c1 e0 f5 cb b2 b0 2b 2b
+generated valid SI2quater [02/05]: [23] 59 06 07 c4 a0 04 86 59 83 c2 ec 20 ff 61 08 19 08 41 b7 2e ca c1 2b
+generated valid SI2quater [03/05]: [23] 59 06 07 c6 a0 04 86 59 84 21 54 21 4f 61 0a 99 08 55 b7 2e ca c1 2b
+generated valid SI2quater [04/05]: [23] 59 06 07 c8 a0 04 86 59 84 2b 54 21 27 61 09 59 08 4b b7 2e ca c1 2b
+generated valid SI2quater [05/05]: [23] 59 06 07 ca a0 04 86 59 84 26 53 97 65 60 2b 2b 2b 2b 2b 2b 2b 2b 2b
+Done.
diff --git a/tests/gtphub/Makefile.am b/tests/gtphub/Makefile.am
new file mode 100644
index 000000000..5c834b782
--- /dev/null
+++ b/tests/gtphub/Makefile.am
@@ -0,0 +1,42 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(LIBGTP_CFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ gtphub_test.ok \
+ $(NULL)
+
+if HAVE_LIBGTP
+if HAVE_LIBCARES
+noinst_PROGRAMS = \
+ gtphub_test \
+ $(NULL)
+endif
+endif
+
+gtphub_test_SOURCES = \
+ gtphub_test.c \
+ $(NULL)
+
+gtphub_test_LDFLAGS = \
+ -Wl,--wrap=gtphub_resolve_ggsn_addr \
+ -Wl,--wrap=gtphub_ares_init \
+ -Wl,--wrap=gtphub_write \
+ $(NULL)
+
+gtphub_test_LDADD = \
+ $(top_builddir)/src/gprs/gtphub.o \
+ $(top_builddir)/src/gprs/gprs_utils.o \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBGTP_LIBS) \
+ -lrt \
+ $(NULL)
diff --git a/tests/gtphub/gtphub_test.c b/tests/gtphub/gtphub_test.c
new file mode 100644
index 000000000..e7c27d2cb
--- /dev/null
+++ b/tests/gtphub/gtphub_test.c
@@ -0,0 +1,1786 @@
+/* Test the GTP hub */
+
+/* (C) 2015 by sysmocom s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * Author: Neels Hofmeyr <nhofmeyr@sysmcom.de>
+ *
+ * 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/>.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <unistd.h>
+
+#include <osmocom/core/utils.h>
+#include <osmocom/core/application.h>
+
+#include <openbsc/debug.h>
+
+#include <openbsc/gtphub.h>
+#include <gtp.h>
+#include <gtpie.h>
+
+#define ZERO_STRUCT(struct_pointer) memset(struct_pointer, '\0', \
+ sizeof(*(struct_pointer)))
+
+#define LVL2_ASSERT(exp) LVL2_ASSERT_R(exp, return 0)
+#define LVL2_ASSERT_R(exp, ret) \
+ if (!(exp)) { \
+ fprintf(stderr, "LVL2 Assert failed %s %s:%d\n", #exp, \
+ __FILE__, __LINE__); \
+ osmo_generate_backtrace(); \
+ ret; \
+ }
+
+/* Convenience makro, note: only within this C file. */
+#define LOG(label) \
+ { fprintf(stderr, "\n" label "\n"); \
+ printf(label "\n"); }
+
+void gtphub_init(struct gtphub *hub);
+void gtphub_free(struct gtphub *hub);
+
+void *osmo_gtphub_ctx;
+
+static void nr_mapping_free(struct expiring_item *e)
+{
+ struct nr_mapping *m = container_of(e, struct nr_mapping,
+ expiry_entry);
+ nr_mapping_del(m);
+ talloc_free(m);
+}
+
+static struct nr_mapping *nr_mapping_alloc(void)
+{
+ struct nr_mapping *m;
+ m = talloc(osmo_gtphub_ctx, struct nr_mapping);
+ nr_mapping_init(m);
+ m->expiry_entry.del_cb = nr_mapping_free;
+ return m;
+}
+
+static struct nr_mapping *nr_map_have(struct nr_map *map, void *origin,
+ nr_t orig, time_t now)
+{
+ struct nr_mapping *mapping;
+
+ mapping = nr_map_get(map, origin, orig);
+ if (!mapping) {
+ mapping = nr_mapping_alloc();
+ mapping->origin = origin;
+ mapping->orig = orig;
+ nr_map_add(map, mapping, now);
+ }
+
+ return mapping;
+}
+
+static nr_t nr_map_verify(const struct nr_map *map, void *origin, nr_t orig,
+ nr_t expect_repl)
+{
+ struct nr_mapping *m;
+ m = nr_map_get(map, origin, orig);
+
+ if (!m) {
+ printf("mapping not found for %p %d\n", origin, orig);
+ return 0;
+ }
+
+ if (m->repl != expect_repl) {
+ printf("mapping found, but nr mismatches: expect %d, got %d\n",
+ (int)expect_repl, (int)m->repl);
+ return 0;
+ }
+
+ return 1;
+}
+
+static int nr_map_verify_inv(const struct nr_map *map, nr_t repl,
+ void *expect_origin, nr_t expect_orig)
+{
+ struct nr_mapping *m;
+ m = nr_map_get_inv(map, repl);
+ if (!m) {
+ printf("mapping not found for %d\n", (int)repl);
+ return 0;
+ }
+
+ if (m->origin != expect_origin) {
+ printf("mapping found, but origin mismatches:"
+ " expect %p, got %p\n",
+ expect_origin, m->origin);
+ return 0;
+ }
+
+ if (m->orig != expect_orig) {
+ printf("mapping found, but nr mismatches: expect %d, got %d\n",
+ (int)expect_orig, (int)m->orig);
+ return 0;
+ }
+
+ return 1;
+}
+
+
+static void test_nr_map_basic(void)
+{
+ struct nr_pool _pool;
+ struct nr_pool *pool = &_pool;
+ struct nr_map _map;
+ struct nr_map *map = &_map;
+
+ nr_pool_init(pool, 1, 1000);
+ nr_map_init(map, pool, NULL);
+
+ OSMO_ASSERT(llist_empty(&map->mappings));
+
+#define TEST_N_HALF 100
+#define TEST_N (2*TEST_N_HALF)
+#define TEST_I 123
+ uint32_t i, check_i;
+ uint32_t m[TEST_N];
+ struct nr_mapping *mapping;
+
+ /* create half of TEST_N mappings from one origin */
+ void *origin1 = (void*)0x1234;
+ for (i = 0; i < TEST_N_HALF; i++) {
+ nr_t orig = TEST_I + i;
+ mapping = nr_map_have(map, origin1, orig, 0);
+ m[i] = mapping->repl;
+ OSMO_ASSERT(m[i] != 0);
+ OSMO_ASSERT(llist_count(&map->mappings) == (i+1));
+ for (check_i = 0; check_i < i; check_i++)
+ OSMO_ASSERT(m[check_i] != m[i]);
+ }
+ OSMO_ASSERT(llist_count(&map->mappings) == TEST_N_HALF);
+
+ /* create another TEST_N mappings with the same original numbers, but
+ * from a different origin */
+ void *origin2 = (void*)0x5678;
+ for (i = 0; i < TEST_N_HALF; i++) {
+ int i2 = TEST_N_HALF + i;
+ nr_t orig = TEST_I + i;
+ mapping = nr_map_have(map, origin2, orig, 0);
+ m[i2] = mapping->repl;
+ OSMO_ASSERT(m[i2] != 0);
+ OSMO_ASSERT(llist_count(&map->mappings) == (i2+1));
+ for (check_i = 0; check_i < i2; check_i++)
+ OSMO_ASSERT(m[check_i] != m[i2]);
+ }
+ OSMO_ASSERT(llist_count(&map->mappings) == TEST_N);
+
+ /* verify mappings */
+ for (i = 0; i < TEST_N_HALF; i++) {
+ nr_t orig = TEST_I + i;
+ {
+ OSMO_ASSERT(nr_map_verify(map, origin1, orig, m[i]));
+ OSMO_ASSERT(nr_map_verify_inv(map, m[i], origin1,
+ orig));
+ }
+ {
+ int i2 = TEST_N_HALF + i;
+ OSMO_ASSERT(nr_map_verify(map, origin2, orig, m[i2]));
+ OSMO_ASSERT(nr_map_verify_inv(map, m[i2], origin2,
+ orig));
+ }
+ }
+
+ /* remove all mappings */
+ for (i = 0; i < TEST_N_HALF; i++) {
+ OSMO_ASSERT(llist_count(&map->mappings) == (TEST_N - 2*i));
+
+ nr_t orig = TEST_I + i;
+ nr_mapping_del(nr_map_get(map, origin1, orig));
+ nr_mapping_del(nr_map_get(map, origin2, orig));
+ }
+ OSMO_ASSERT(llist_empty(&map->mappings));
+#undef TEST_N
+#undef TEST_I
+}
+
+static int nr_map_is(struct nr_map *map, const char *str)
+{
+ static char buf[4096];
+ char *pos = buf;
+ size_t len = sizeof(buf);
+ struct nr_mapping *m;
+ llist_for_each_entry(m, &map->mappings, entry) {
+ size_t wrote = snprintf(pos, len, "(%u->%u@%d), ",
+ m->orig,
+ m->repl,
+ (int)m->expiry_entry.expiry);
+ OSMO_ASSERT(wrote < len);
+ pos += wrote;
+ len -= wrote;
+ }
+ *pos = '\0';
+
+ if (strncmp(buf, str, sizeof(buf)) != 0) {
+ printf("FAILURE: nr_map_is() mismatches expected value:\n"
+ "expected: \"%s\"\n"
+ "is: \"%s\"\n",
+ str, buf);
+ return 0;
+ }
+ return 1;
+}
+
+static int test_nr_map_wrap_with(nr_t nr_min, nr_t nr_max, nr_t repl_last,
+ nr_t orig_start, int orig_n,
+ const char *expect)
+{
+ struct nr_pool _pool;
+ struct nr_pool *pool = &_pool;
+ struct nr_map _map;
+ struct nr_map *map = &_map;
+
+ nr_pool_init(pool, nr_min, nr_max);
+ nr_map_init(map, pool, NULL);
+
+ pool->last_nr = repl_last;
+
+ void *origin = (void*)0x1234;
+
+ int i;
+ for (i = 0; i < orig_n; i++)
+ LVL2_ASSERT(nr_map_have(map, origin, orig_start + i, 0));
+
+ LVL2_ASSERT(nr_map_is(map, expect));
+
+ nr_map_clear(map);
+ return 1;
+}
+
+static void test_nr_map_wrap(void)
+{
+ OSMO_ASSERT(test_nr_map_wrap_with(
+ 0, UINT_MAX, UINT_MAX - 2,
+ 1, 5,
+ "(1->4294967294@0), "
+ "(2->4294967295@0), "
+ "(3->0@0), "
+ "(4->1@0), "
+ "(5->2@0), "
+ ));
+ OSMO_ASSERT(test_nr_map_wrap_with(
+ 5, 10, 8,
+ 1, 5,
+ "(1->9@0), (2->10@0), (3->5@0), (4->6@0), (5->7@0), "
+ ));
+}
+
+static void test_expiry(void)
+{
+ struct expiry expiry;
+ struct nr_pool pool;
+ struct nr_map map;
+ int i;
+
+ expiry_init(&expiry, 30);
+ nr_pool_init(&pool, 1, 1000);
+ nr_map_init(&map, &pool, &expiry);
+ OSMO_ASSERT(nr_map_is(&map, ""));
+
+ /* tick on empty map */
+ OSMO_ASSERT(expiry_tick(&expiry, 10000) == 0);
+ OSMO_ASSERT(nr_map_is(&map, ""));
+
+#define MAP1 \
+ "(10->1@10040), " \
+ ""
+
+#define MAP2 \
+ "(20->2@10050), " \
+ "(21->3@10051), " \
+ "(22->4@10052), " \
+ "(23->5@10053), " \
+ "(24->6@10054), " \
+ "(25->7@10055), " \
+ "(26->8@10056), " \
+ "(27->9@10057), " \
+ ""
+
+#define MAP3 \
+ "(420->10@10072), " \
+ "(421->11@10072), " \
+ "(422->12@10072), " \
+ "(423->13@10072), " \
+ "(424->14@10072), " \
+ "(425->15@10072), " \
+ "(426->16@10072), " \
+ "(427->17@10072), " \
+ ""
+
+ /* add mapping at time 10010. */
+ nr_map_have(&map, 0, 10, 10010);
+ OSMO_ASSERT(nr_map_is(&map, MAP1));
+
+ /* tick on unexpired item. */
+ OSMO_ASSERT(expiry_tick(&expiry, 10010) == 0);
+ OSMO_ASSERT(expiry_tick(&expiry, 10011) == 0);
+ OSMO_ASSERT(nr_map_is(&map, MAP1));
+
+ /* Spread mappings at 10020, 10021, ... 10027. */
+ for (i = 0; i < 8; i++)
+ nr_map_have(&map, 0, 20 + i, 10020 + i);
+ OSMO_ASSERT(nr_map_is(&map, MAP1 MAP2));
+
+ /* tick on unexpired items. */
+ OSMO_ASSERT(expiry_tick(&expiry, 10030) == 0);
+ OSMO_ASSERT(expiry_tick(&expiry, 10039) == 0);
+ OSMO_ASSERT(nr_map_is(&map, MAP1 MAP2));
+
+ /* expire the first item (from 10010). */
+ OSMO_ASSERT(expiry_tick(&expiry, 10010 + 30) == 1);
+ OSMO_ASSERT(nr_map_is(&map, MAP2));
+
+ /* again nothing to expire */
+ OSMO_ASSERT(expiry_tick(&expiry, 10041) == 0);
+ OSMO_ASSERT(nr_map_is(&map, MAP2));
+
+ /* Mappings all at the same time. */
+ for (i = 0; i < 8; i++)
+ nr_map_have(&map, 0, 420 + i, 10042);
+ OSMO_ASSERT(nr_map_is(&map, MAP2 MAP3));
+
+ /* Eight to expire, were added further above to be chronologically
+ * correct, at 10020..10027. */
+ OSMO_ASSERT(expiry_tick(&expiry, 10027 + 30) == 8);
+ OSMO_ASSERT(nr_map_is(&map, MAP3));
+
+ /* again nothing to expire */
+ OSMO_ASSERT(expiry_tick(&expiry, 10027 + 30) == 0);
+ OSMO_ASSERT(nr_map_is(&map, MAP3));
+
+ /* Eight to expire, from 10042. Now at 10042 + 30: */
+ OSMO_ASSERT(expiry_tick(&expiry, 10042 + 30) == 8);
+ OSMO_ASSERT(nr_map_is(&map, ""));
+
+#undef MAP1
+#undef MAP2
+#undef MAP3
+}
+
+char resolve_ggsn_got_imsi[GSM23003_IMSI_MAX_DIGITS+1];
+char resolve_ggsn_got_ni[GSM_APN_LENGTH];
+
+struct osmo_sockaddr resolved_ggsn_addr;
+static int resolve_to_ggsn(const char *addr, uint16_t port)
+{
+ LVL2_ASSERT(osmo_sockaddr_init_udp(&resolved_ggsn_addr,
+ addr, port)
+ == 0);
+ return 1;
+}
+
+struct osmo_sockaddr resolved_sgsn_addr;
+static int resolve_to_sgsn(const char *addr, uint16_t port)
+{
+ LVL2_ASSERT(osmo_sockaddr_init_udp(&resolved_sgsn_addr,
+ addr, port)
+ == 0);
+ return 1;
+}
+
+struct osmo_sockaddr sgsn_sender;
+static int send_from_sgsn(const char *addr, uint16_t port)
+{
+ LVL2_ASSERT(osmo_sockaddr_init_udp(&sgsn_sender,
+ addr, port)
+ == 0);
+ return 1;
+}
+
+struct osmo_sockaddr ggsn_sender;
+static int send_from_ggsn(const char *addr, uint16_t port)
+{
+ LVL2_ASSERT(osmo_sockaddr_init_udp(&ggsn_sender,
+ addr, port)
+ == 0);
+ return 1;
+}
+
+
+/* override, requires '-Wl,--wrap=gtphub_resolve_ggsn_addr' */
+struct gtphub_peer_port *__real_gtphub_resolve_ggsn_addr(struct gtphub *hub,
+ const char *imsi_str,
+ const char *apn_ni_str);
+
+struct gtphub_peer_port *__wrap_gtphub_resolve_ggsn_addr(struct gtphub *hub,
+ const char *imsi_str,
+ const char *apn_ni_str)
+{
+ struct gsn_addr resolved_gsna;
+ uint16_t resolved_port;
+
+ OSMO_ASSERT(gsn_addr_from_sockaddr(&resolved_gsna, &resolved_port,
+ &resolved_ggsn_addr) == 0);
+
+ struct gtphub_peer_port *pp;
+ pp = gtphub_port_have(hub, &hub->to_gsns[GTPH_SIDE_GGSN][GTPH_PLANE_CTRL],
+ &resolved_gsna, resolved_port);
+ printf("- __wrap_gtphub_resolve_ggsn_addr():\n"
+ " returning GGSN addr from imsi %s ni %s: %s\n",
+ imsi_str, apn_ni_str, gtphub_port_str(pp));
+
+ if (!imsi_str)
+ imsi_str = "(null)";
+ osmo_strlcpy(resolve_ggsn_got_imsi, imsi_str,
+ sizeof(resolve_ggsn_got_imsi));
+
+ if (!apn_ni_str)
+ apn_ni_str = "(null)";
+ osmo_strlcpy(resolve_ggsn_got_ni, apn_ni_str,
+ sizeof(resolve_ggsn_got_ni));
+
+ return pp;
+}
+
+#define was_resolved_for(IMSI,NI) _was_resolved_for(IMSI, NI, __FILE__, __LINE__)
+static int _was_resolved_for(const char *imsi, const char *ni, const char
+ *file, int line)
+{
+ int cmp0 = strncmp(imsi, resolve_ggsn_got_imsi,
+ sizeof(resolve_ggsn_got_imsi));
+
+ if (cmp0 != 0) {
+ printf("\n%s:%d: was_resolved_for(): MISMATCH for IMSI\n"
+ " expecting: '%s'\n"
+ " got: '%s'\n\n",
+ file,
+ line,
+ imsi, resolve_ggsn_got_imsi);
+ }
+
+ int cmp1 = strncmp(ni, resolve_ggsn_got_ni,
+ sizeof(resolve_ggsn_got_ni));
+ if (cmp1 != 0) {
+ printf("\n%s:%d: was_resolved_for(): MISMATCH for NI\n"
+ " expecting: '%s'\n"
+ " got: '%s'\n\n",
+ file,
+ line,
+ ni, resolve_ggsn_got_ni);
+ }
+
+ return (cmp0 == 0) && (cmp1 == 0);
+}
+
+/* override, requires '-Wl,--wrap=gtphub_ares_init' */
+int __real_gtphub_ares_init(struct gtphub *hub);
+
+int __wrap_gtphub_ares_init(struct gtphub *hub)
+{
+ /* Do nothing. */
+ return 0;
+}
+
+/* override, requires '-Wl,--wrap=gtphub_write' */
+int __real_gtphub_write(const struct osmo_fd *to,
+ const struct osmo_sockaddr *to_addr,
+ const uint8_t *buf, size_t buf_len);
+
+int __wrap_gtphub_write(const struct osmo_fd *to,
+ const struct osmo_sockaddr *to_addr,
+ const uint8_t *buf, size_t buf_len)
+{
+ printf("Out-of-band gtphub_write(%d):\n"
+ "to %s\n"
+ "%s\n",
+ (int)buf_len,
+ osmo_sockaddr_to_str(to_addr),
+ osmo_hexdump(buf, buf_len));
+ return 0;
+}
+
+#define buf_len 1024
+static uint8_t buf[buf_len];
+static uint8_t *reply_buf;
+
+static unsigned int msg(const char *hex)
+{
+ unsigned int l = osmo_hexparse(hex, buf, buf_len);
+ OSMO_ASSERT(l > 0);
+ return l;
+}
+
+/* Compare static buf to given string constant. The amount of bytes is obtained
+ * from parsing the GTP header in buf. hex must match an osmo_hexdump() of the
+ * desired message. Return 1 if size and content match. */
+#define reply_is(MSG) _reply_is(MSG, __FILE__, __LINE__)
+static int _reply_is(const char *hex, const char *file, int line)
+{
+ struct gtp1_header_long *h = (void*)reply_buf;
+ int len = ntoh16(h->length) + 8;
+ const char *dump = osmo_hexdump_nospc(reply_buf, len);
+ int cmp = strcmp(dump, hex);
+
+ if (cmp != 0) {
+ printf("\n%s:%d: reply_is(): MISMATCH\n"
+ " expecting:\n'%s'\n"
+ " got:\n'%s'\n\n",
+ file,
+ line,
+ hex, dump);
+ int i;
+ int l = strlen(hex);
+ int m = strlen(dump);
+ if (m < l)
+ l = m;
+ for (i = 0; i < l; i++) {
+ if (hex[i] != dump[i]) {
+ printf("First mismatch at position %d:\n"
+ " %s\n %s\n", i, hex + i, dump + i);
+ break;
+ }
+ }
+ }
+ return cmp == 0;
+}
+
+#define same_addr(GOT, EXPECTED) _same_addr((GOT),(EXPECTED), __FILE__, __LINE__)
+static int _same_addr(const struct osmo_sockaddr *got,
+ const struct osmo_sockaddr *expected,
+ const char *file, int line)
+{
+ int cmp = osmo_sockaddr_cmp(got, expected);
+ if (!cmp)
+ return 1;
+ char buf[256];
+ printf("\n%s:%d: addr_is(): MISMATCH\n"
+ " expecting: '%s'\n"
+ " got: '%s'\n\n",
+ file, line,
+ osmo_sockaddr_to_str(expected),
+ osmo_sockaddr_to_strb(got, buf, sizeof(buf)));
+ return 0;
+}
+
+
+time_t now;
+static struct gtphub _hub;
+static struct gtphub *hub = &_hub;
+
+static int setup_test_hub()
+{
+ /* Not really needed, but to make 100% sure... */
+ ZERO_STRUCT(hub);
+
+ gtphub_init(hub);
+
+ /* Tell this mock gtphub its local address for this test. */
+ LVL2_ASSERT(gsn_addr_from_str(&hub->to_gsns[GTPH_SIDE_SGSN][GTPH_PLANE_CTRL].local_addr,
+ "127.0.1.1") == 0);
+ LVL2_ASSERT(gsn_addr_from_str(&hub->to_gsns[GTPH_SIDE_SGSN][GTPH_PLANE_USER].local_addr,
+ "127.0.1.2") == 0);
+ LVL2_ASSERT(gsn_addr_from_str(&hub->to_gsns[GTPH_SIDE_GGSN][GTPH_PLANE_CTRL].local_addr,
+ "127.0.2.1") == 0);
+ LVL2_ASSERT(gsn_addr_from_str(&hub->to_gsns[GTPH_SIDE_GGSN][GTPH_PLANE_USER].local_addr,
+ "127.0.2.2") == 0);
+
+ hub->restart_counter = 0x23;
+ now = 345;
+ LVL2_ASSERT(send_from_sgsn("192.168.42.23", 423));
+ LVL2_ASSERT(resolve_to_ggsn("192.168.43.34", 2123));
+ LVL2_ASSERT(send_from_ggsn("192.168.43.34", 434));
+ LVL2_ASSERT(resolve_to_sgsn("192.168.42.23", 2123));
+
+#define GGSNS_CTRL_FD 1
+#define GGSNS_USER_FD 2
+#define SGSNS_CTRL_FD 3
+#define SGSNS_USER_FD 4
+ hub->to_gsns[GTPH_SIDE_GGSN][GTPH_PLANE_CTRL].ofd.priv_nr = GGSNS_CTRL_FD;
+ hub->to_gsns[GTPH_SIDE_GGSN][GTPH_PLANE_USER].ofd.priv_nr = GGSNS_USER_FD;
+ hub->to_gsns[GTPH_SIDE_SGSN][GTPH_PLANE_CTRL].ofd.priv_nr = SGSNS_CTRL_FD;
+ hub->to_gsns[GTPH_SIDE_SGSN][GTPH_PLANE_USER].ofd.priv_nr = SGSNS_USER_FD;
+
+ return 1;
+}
+
+static int clear_test_hub()
+{
+ /* expire all */
+ gtphub_gc(hub, now + (60 * GTPH_EXPIRE_SLOWLY_MINUTES) + 1);
+
+ int plane_idx;
+ plane_idx = GTPH_PLANE_CTRL;
+ LVL2_ASSERT(llist_empty(&hub->to_gsns[GTPH_SIDE_GGSN][plane_idx].peers));
+ LVL2_ASSERT(llist_empty(&hub->to_gsns[GTPH_SIDE_SGSN][plane_idx].peers));
+ plane_idx = GTPH_PLANE_USER;
+ LVL2_ASSERT(llist_empty(&hub->to_gsns[GTPH_SIDE_GGSN][plane_idx].peers));
+ LVL2_ASSERT(llist_empty(&hub->to_gsns[GTPH_SIDE_SGSN][plane_idx].peers));
+
+ LVL2_ASSERT(llist_empty(&hub->tunnels));
+ LVL2_ASSERT(llist_empty(&hub->pending_deletes));
+ LVL2_ASSERT(llist_empty(&hub->ggsn_lookups));
+ LVL2_ASSERT(llist_empty(&hub->resolved_ggsns));
+
+ gtphub_free(hub);
+ return 1;
+}
+
+static int tunnels_are(const char *expect)
+{
+ static char buf[4096];
+ char *pos = buf;
+ size_t len = sizeof(buf);
+ struct gtphub_tunnel *t;
+ llist_for_each_entry(t, &hub->tunnels, entry) {
+ size_t wrote = snprintf(pos, len, "%s @%d\n",
+ gtphub_tunnel_str(t),
+ (int)t->expiry_entry.expiry);
+ LVL2_ASSERT(wrote < len);
+ pos += wrote;
+ len -= wrote;
+ }
+ *pos = '\0';
+
+ if (strncmp(buf, expect, sizeof(buf)) != 0) {
+ fprintf(stderr, "FAILURE: tunnels_are() mismatches expected value:\n"
+ "EXPECTED:\n%s\n"
+ "IS:\n%s\n",
+ expect, buf);
+ LVL2_ASSERT("tunnels do not match expected listing.");
+ return 0;
+ }
+ return 1;
+}
+
+static void test_echo(void)
+{
+ LOG("test_echo");
+ OSMO_ASSERT(setup_test_hub());
+
+ now = 123;
+
+ struct osmo_fd *to_ofd;
+ struct osmo_sockaddr to_addr;
+ struct gtphub_peer_port *pp;
+ int send;
+
+ const char *gtp_ping_from_sgsn =
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr */
+ "01" /* type 01: Echo request */
+ "0004" /* length of 4 after header TEI */
+ "00000000" /* header TEI == 0 in Echo */
+ "abcd" /* some 2 octet sequence nr */
+ "0000" /* N-PDU 0, no extension header (why is this here?) */
+ ;
+
+ const char *gtp_pong_to_sgsn =
+ "32"
+ "02" /* type 02: Echo response */
+ "0006" /* length of 6 after header TEI */
+ "00000000" /* header TEI == 0 in Echo */
+ "abcd" /* same sequence nr */
+ "0000"
+ "0e23" /* Recovery with restart counter */
+ ;
+
+ to_ofd = NULL;
+ ZERO_STRUCT(&to_addr);
+ send = gtphub_handle_buf(hub, GTPH_SIDE_SGSN, GTPH_PLANE_CTRL,
+ &sgsn_sender, buf, msg(gtp_ping_from_sgsn),
+ now, &reply_buf, &to_ofd, &to_addr);
+ OSMO_ASSERT(send > 0);
+ OSMO_ASSERT(to_addr.l);
+ OSMO_ASSERT(same_addr(&to_addr, &sgsn_sender));
+ OSMO_ASSERT(to_ofd && (to_ofd->priv_nr == SGSNS_CTRL_FD));
+ OSMO_ASSERT(reply_is(gtp_pong_to_sgsn));
+
+ pp = gtphub_port_find_sa(&hub->to_gsns[GTPH_SIDE_SGSN][GTPH_PLANE_CTRL],
+ &sgsn_sender);
+ /* We don't record Echo peers. */
+ OSMO_ASSERT(!pp);
+
+ const char *gtp_ping_from_ggsn =
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr */
+ "01" /* type 01: Echo request */
+ "0004" /* length of 4 after header TEI */
+ "00000000" /* header TEI == 0 in Echo */
+ "cdef" /* some 2 octet sequence nr */
+ "0000" /* N-PDU 0, no extension header (why is this here?) */
+ ;
+
+ const char *gtp_pong_to_ggsn =
+ "32"
+ "02" /* type 02: Echo response */
+ "0006" /* length of 6 after header TEI */
+ "00000000" /* header TEI == 0 in Echo */
+ "cdef" /* same sequence nr */
+ "0000"
+ "0e23" /* Recovery with restart counter */
+ ;
+
+ to_ofd = NULL;
+ ZERO_STRUCT(&to_addr);
+ send = gtphub_handle_buf(hub, GTPH_SIDE_GGSN, GTPH_PLANE_CTRL,
+ &ggsn_sender, buf, msg(gtp_ping_from_ggsn),
+ now, &reply_buf, &to_ofd, &to_addr);
+ OSMO_ASSERT(send > 0);
+ OSMO_ASSERT(same_addr(&to_addr, &ggsn_sender));
+ OSMO_ASSERT(to_ofd && (to_ofd->priv_nr == GGSNS_CTRL_FD));
+ OSMO_ASSERT(reply_is(gtp_pong_to_ggsn));
+
+ pp = gtphub_port_find_sa(&hub->to_gsns[GTPH_SIDE_GGSN][GTPH_PLANE_CTRL],
+ &sgsn_sender);
+ OSMO_ASSERT(!pp);
+
+
+ /* And all the same on the user plane. */
+
+ to_ofd = NULL;
+ ZERO_STRUCT(&to_addr);
+ send = gtphub_handle_buf(hub, GTPH_SIDE_SGSN, GTPH_PLANE_USER,
+ &sgsn_sender, buf, msg(gtp_ping_from_sgsn),
+ now, &reply_buf, &to_ofd, &to_addr);
+ OSMO_ASSERT(send > 0);
+ OSMO_ASSERT(to_addr.l);
+ OSMO_ASSERT(same_addr(&to_addr, &sgsn_sender));
+ OSMO_ASSERT(to_ofd && (to_ofd->priv_nr == SGSNS_USER_FD));
+ OSMO_ASSERT(reply_is(gtp_pong_to_sgsn));
+
+ pp = gtphub_port_find_sa(&hub->to_gsns[GTPH_SIDE_SGSN][GTPH_PLANE_USER],
+ &sgsn_sender);
+ OSMO_ASSERT(!pp);
+
+ to_ofd = NULL;
+ ZERO_STRUCT(&to_addr);
+ send = gtphub_handle_buf(hub, GTPH_SIDE_GGSN, GTPH_PLANE_USER,
+ &ggsn_sender, buf, msg(gtp_ping_from_ggsn),
+ now, &reply_buf, &to_ofd, &to_addr);
+ OSMO_ASSERT(send > 0);
+ OSMO_ASSERT(same_addr(&to_addr, &ggsn_sender));
+ OSMO_ASSERT(to_ofd && (to_ofd->priv_nr == GGSNS_USER_FD));
+ OSMO_ASSERT(reply_is(gtp_pong_to_ggsn));
+
+ pp = gtphub_port_find_sa(&hub->to_gsns[GTPH_SIDE_GGSN][GTPH_PLANE_USER],
+ &sgsn_sender);
+ OSMO_ASSERT(!pp);
+
+
+ OSMO_ASSERT(clear_test_hub());
+}
+
+
+#define MSG_PDP_CTX_REQ(len, seq, restart, imsi, tei_u, tei_c, apn, gsn_c, gsn_u) \
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr. */ \
+ "10" /* type 16: Create PDP Context Request */ \
+ len /* msg length = 8 + len (2 octets) */ \
+ "00000000" /* No TEI yet */ \
+ seq /* Sequence nr (2 octets) */ \
+ "00" /* N-PDU 0 */ \
+ "00" /* No extensions */ \
+ /* IEs */ \
+ "0e" restart /* 14: Recovery (restart counter: 1 octet) */ \
+ "02" /* 2 = IMSI */ \
+ imsi /* (8 octets) */ \
+ "0f01" /* 15: Selection mode = MS provided APN, subscription not verified*/ \
+ "10" /* 16: TEI Data I */ \
+ tei_u /* (4 octets) */ \
+ "11" /* 17: TEI Control Plane */ \
+ tei_c /* (4 octets) */ \
+ "1400" /* 20: NSAPI = 0*/ \
+ "1a" /* 26: Charging Characteristics */ \
+ "0800" \
+ "80" /* 128: End User Address */ \
+ "0002" /* length = 2: empty PDP Address */ \
+ "f121" /* spare 0xf0, PDP organization 1, PDP type number 0x21 = 33 */ \
+ "83" /* 131: Access Point Name */ \
+ apn /* (2 octets length, N octets encoded APN-NI) */ \
+ "84" /* 132: Protocol Configuration Options */ \
+ "0015" /* length = 21 */ \
+ "80c0231101010011036d69670868656d6d656c6967" \
+ "85" /* 133: GSN Address */ \
+ gsn_c /* (2 octets length, N octets addr) */ \
+ "85" /* 133: GSN Address (second entry) */ \
+ gsn_u /* (2 octets length, N octets addr) */ \
+ "86" /* 134: MS International PSTN/ISDN Number (MSISDN) */ \
+ "0007" /* length */ \
+ "916407123254f6" /* 1946702123456(f) */ \
+ "87" /* 135: Quality of Service (QoS) Profile */ \
+ "0004" /* length */ \
+ "00" /* priority */ \
+ "0b921f" /* QoS profile data */
+
+#define MSG_PDP_CTX_RSP(len, tei_h, seq, restart, tei_u, tei_c, gsn_c, gsn_u) \
+ "32" \
+ "11" /* Create PDP Context Response */ \
+ len /* msg length = 8 + len (2 octets) */ \
+ tei_h /* destination TEI (sent in req above) */ \
+ seq /* mapped seq */ \
+ "00" "00" \
+ /* IEs */ \
+ "01" /* 1: Cause */ \
+ "80" /* value = 0b10000000 = response, no rejection. */ \
+ "08" /* 8: Reordering Required */ \
+ "00" /* not required. */ \
+ "0e" restart /* 14: Recovery */ \
+ "10" /* 16: TEI Data I */ \
+ tei_u \
+ "11" /* 17: TEI Control */ \
+ tei_c \
+ "7f" /* 127: Charging ID */ \
+ "00000001" \
+ "80" /* 128: End User Address */ \
+ "0006" /* length = 6 */ \
+ "f121" /* spare 0xf0, PDP organization 1, PDP type number 0x21 = 33 */ \
+ "7f000002" \
+ "84" /* 132: Protocol Configuration Options */ \
+ "0014" /* len = 20 */ \
+ "8080211002000010810608080808830600000000" \
+ "85" /* 133: GSN Address (Ctrl) */ \
+ gsn_c \
+ "85" /* 133: GSN Address (User) */ \
+ gsn_u \
+ "87" /* 135: Quality of Service (QoS) Profile */ \
+ "0004" /* length */ \
+ "00" /* priority */ \
+ "0b921f" /* QoS profile data */
+
+#define msg_from_sgsn_c(A,B,C,D) msg_from_sgsn(GTPH_PLANE_CTRL, A,B,C,D)
+#define msg_from_sgsn_u(A,B,C,D) msg_from_sgsn(GTPH_PLANE_USER, A,B,C,D)
+static int msg_from_sgsn(int plane_idx,
+ struct osmo_sockaddr *_sgsn_sender,
+ struct osmo_sockaddr *ggsn_receiver,
+ const char *hex_from_sgsn,
+ const char *hex_to_ggsn)
+{
+ struct osmo_fd *ggsn_ofd = NULL;
+ struct osmo_sockaddr ggsn_addr;
+ int send;
+ send = gtphub_handle_buf(hub, GTPH_SIDE_SGSN, plane_idx, _sgsn_sender,
+ buf, msg(hex_from_sgsn), now,
+ &reply_buf, &ggsn_ofd, &ggsn_addr);
+ LVL2_ASSERT(send > 0);
+ LVL2_ASSERT(same_addr(&ggsn_addr, ggsn_receiver));
+ LVL2_ASSERT(reply_is(hex_to_ggsn));
+ return 1;
+}
+
+#define msg_from_ggsn_c(A,B,C,D) msg_from_ggsn(GTPH_PLANE_CTRL, A,B,C,D)
+#define msg_from_ggsn_u(A,B,C,D) msg_from_ggsn(GTPH_PLANE_USER, A,B,C,D)
+static int msg_from_ggsn(int plane_idx,
+ struct osmo_sockaddr *ggsn_sender,
+ struct osmo_sockaddr *sgsn_receiver,
+ const char *msg_from_ggsn,
+ const char *msg_to_sgsn)
+{
+ struct osmo_fd *sgsn_ofd;
+ struct osmo_sockaddr sgsn_addr;
+ int send;
+ send = gtphub_handle_buf(hub, GTPH_SIDE_GGSN, plane_idx, ggsn_sender,
+ buf, msg(msg_from_ggsn), now,
+ &reply_buf, &sgsn_ofd, &sgsn_addr);
+ if (*msg_to_sgsn) {
+ LVL2_ASSERT(send > 0);
+ LVL2_ASSERT(same_addr(&sgsn_addr, sgsn_receiver));
+ LVL2_ASSERT(reply_is(msg_to_sgsn));
+ }
+ else
+ LVL2_ASSERT(send == 0);
+ return 1;
+}
+
+static int create_pdp_ctx()
+{
+ const char *gtp_req_from_sgsn =
+ MSG_PDP_CTX_REQ("0068",
+ "abcd",
+ "60",
+ "42000121436587f9",
+ "00000123",
+ "00000321",
+ "0009""08696e7465726e6574", /* "(8)internet" */
+ "0004""c0a82a17", /* same as default sgsn_sender */
+ "0004""c0a82a17"
+ );
+ const char *gtp_req_to_ggsn =
+ MSG_PDP_CTX_REQ("0068",
+ "6d31", /* mapped seq ("abcd") */
+ "23",
+ "42000121436587f9",
+ "00000001", /* Data I: tunnel's TEI */
+ "00000001", /* Control: tunnel's TEI */
+ "0009""08696e7465726e6574",
+ "0004""7f000201", /* replaced with gtphub's ggsn ctrl */
+ "0004""7f000202" /* replaced with gtphub's ggsn user */
+ );
+
+ LVL2_ASSERT(msg_from_sgsn_c(&sgsn_sender,
+ &resolved_ggsn_addr,
+ gtp_req_from_sgsn,
+ gtp_req_to_ggsn));
+ LVL2_ASSERT(was_resolved_for("240010123456789", "internet"));
+
+ LVL2_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C=0 U=0)"
+ " @21945\n"));
+
+ const char *gtp_resp_from_ggsn =
+ MSG_PDP_CTX_RSP("004e",
+ "00000001", /* destination TEI (sent in req above) */
+ "6d31", /* mapped seq */
+ "01", /* restart */
+ "00000567", /* TEI U */
+ "00000765", /* TEI C */
+ "0004""c0a82b22", /* GSN addresses */
+ "0004""c0a82b22" /* (== resolved_ggsn_addr) */
+ );
+ const char *gtp_resp_to_sgsn =
+ MSG_PDP_CTX_RSP("004e",
+ "00000321", /* unmapped TEI ("001") */
+ "abcd", /* unmapped seq ("6d31") */
+ "23",
+ "00000001", /* mapped TEI from GGSN ("567") */
+ "00000001", /* mapped TEI from GGSN ("765") */
+ "0004""7f000101", /* gtphub's address towards SGSNs (Ctrl) */
+ "0004""7f000102" /* gtphub's address towards SGSNs (User) */
+ );
+ /* The response should go back to whichever port the request came from
+ * (unmapped by sequence nr) */
+ LVL2_ASSERT(msg_from_ggsn_c(&resolved_ggsn_addr,
+ &sgsn_sender,
+ gtp_resp_from_ggsn,
+ gtp_resp_to_sgsn));
+
+ return 1;
+}
+
+#define MSG_DEL_PDP_CTX_REQ(tei, seq) \
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr. */ \
+ "14" /* type 20: Delete PDP Context Request */ \
+ "0008" /* msg length = 8 + len (2 octets) */ \
+ tei /* TEI Ctrl */ \
+ seq /* Sequence nr (2 octets) */ \
+ "00" /* N-PDU 0 */ \
+ "00" /* No extensions */ \
+ /* IEs */ \
+ "13fe" /* 19: Teardown ind = 0 */ \
+ "1400" /* 20: NSAPI = 0*/ \
+
+#define MSG_DEL_PDP_CTX_RSP(tei, seq) \
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr. */ \
+ "15" /* type 21: Delete PDP Context Response */ \
+ "0006" /* msg length = 8 + len (2 octets) */ \
+ tei /* TEI Ctrl */ \
+ seq /* Sequence nr (2 octets) */ \
+ "00" /* N-PDU 0 */ \
+ "00" /* No extensions */ \
+ /* IEs */ \
+ "01" /* 1: Cause */ \
+ "80" /* value = 0b10000000 = response, no rejection. */ \
+
+static int delete_pdp_ctx_from_sgsn(void)
+{
+ now += GTPH_EXPIRE_QUICKLY_SECS + 1;
+ gtphub_gc(hub, now);
+
+ LVL2_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @21945\n"));
+
+ /* TEI Ctrl from above and next sequence after abcd. */
+ const char *gtp_req_from_sgsn = MSG_DEL_PDP_CTX_REQ("00000001", "abce");
+ const char *gtp_req_to_ggsn = MSG_DEL_PDP_CTX_REQ("00000765", "6d32");
+
+ LVL2_ASSERT(msg_from_sgsn_c(&sgsn_sender,
+ &resolved_ggsn_addr,
+ gtp_req_from_sgsn,
+ gtp_req_to_ggsn));
+
+ /* 21945 + 31 = 21976 */
+ LVL2_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @21976\n"));
+
+ const char *gtp_resp_from_ggsn =
+ MSG_DEL_PDP_CTX_RSP("00000001", "6d32");
+ const char *gtp_resp_to_sgsn =
+ MSG_DEL_PDP_CTX_RSP("00000321", "abce");
+
+ /* The response should go back to whichever port the request came from
+ * (unmapped by sequence nr) */
+ LVL2_ASSERT(msg_from_ggsn_c(&resolved_ggsn_addr,
+ &sgsn_sender,
+ gtp_resp_from_ggsn,
+ gtp_resp_to_sgsn));
+
+ LVL2_ASSERT(tunnels_are(""));
+
+ return 1;
+}
+
+static int delete_pdp_ctx_from_ggsn(void)
+{
+ now += GTPH_EXPIRE_QUICKLY_SECS + 1;
+ gtphub_gc(hub, now);
+
+ LVL2_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @21945\n"));
+
+ /* TEI Ctrl from above and next sequence after abcd. */
+ const char *gtp_req_from_ggsn = MSG_DEL_PDP_CTX_REQ("00000001", "5432");
+ const char *gtp_req_to_sgsn = MSG_DEL_PDP_CTX_REQ("00000321", "6d31");
+
+ LVL2_ASSERT(msg_from_ggsn_c(&ggsn_sender,
+ &resolved_sgsn_addr,
+ gtp_req_from_ggsn,
+ gtp_req_to_sgsn));
+
+ /* 21945 + 31 = 21976 */
+ LVL2_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @21976\n"));
+
+ const char *gtp_resp_from_sgsn =
+ MSG_DEL_PDP_CTX_RSP("00000001", "6d31");
+ const char *gtp_resp_to_ggsn =
+ MSG_DEL_PDP_CTX_RSP("00000765", "5432");
+
+ /* The response should go back to whichever port the request came from
+ * (unmapped by sequence nr) */
+ LVL2_ASSERT(msg_from_sgsn_c(&resolved_sgsn_addr,
+ &ggsn_sender,
+ gtp_resp_from_sgsn,
+ gtp_resp_to_ggsn));
+
+ LVL2_ASSERT(tunnels_are(""));
+
+ return 1;
+}
+
+static void test_one_pdp_ctx(int del_from_side)
+{
+ if (del_from_side == GTPH_SIDE_SGSN)
+ LOG("test_one_pdp_ctx (del from SGSN)")
+ else LOG("test_one_pdp_ctx (del from GGSN)");
+ OSMO_ASSERT(setup_test_hub());
+
+ OSMO_ASSERT(create_pdp_ctx());
+
+ struct gtphub_peer_port *ggsn_port =
+ gtphub_port_find_sa(&hub->to_gsns[GTPH_SIDE_GGSN][GTPH_PLANE_CTRL],
+ &resolved_ggsn_addr);
+ OSMO_ASSERT(ggsn_port);
+ struct gtphub_peer *ggsn = ggsn_port->peer_addr->peer;
+ /* now == 345; now + 30 == 375.
+ * seq mapping from above:
+ * 0xabcd == 43981 (sent in the packet)
+ * 0x6d31 == 27953 (harcoded seq mapping start val) */
+ OSMO_ASSERT(nr_map_is(&ggsn->seq_map, "(43981->27953@375), "));
+
+ /* now == 345; now + (6 * 60 * 60) == 21600 + 345 == 21945.
+ * 0x00000321 == 801 (TEI from SGSN Ctrl)
+ * 0x00000123 == 291 (TEI from SGSN User)
+ * 0x00000765 == 1893 (TEI from GGSN Ctrl)
+ * 0x00000567 == 1383 (TEI from GGSN User)
+ * Mapped TEIs should be 1 and 2. */
+ OSMO_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @21945\n"));
+
+ if (del_from_side == GTPH_SIDE_SGSN) {
+ OSMO_ASSERT(delete_pdp_ctx_from_sgsn());
+ } else {
+ OSMO_ASSERT(delete_pdp_ctx_from_ggsn());
+ }
+ OSMO_ASSERT(tunnels_are(""));
+
+ OSMO_ASSERT(clear_test_hub());
+}
+
+static void test_user_data(void)
+{
+ LOG("test_user_data");
+
+ OSMO_ASSERT(setup_test_hub());
+
+ OSMO_ASSERT(create_pdp_ctx());
+
+ /* now == 345; now + (6 * 60 * 60) == 21600 + 345 == 21945. */
+ OSMO_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @21945\n"));
+
+ LOG("- user data starts");
+ /* Now expect default port numbers for User plane. */
+ resolve_to_ggsn("192.168.43.34", 2152);
+ resolve_to_sgsn("192.168.42.23", 2152);
+
+ /* 10 minutes later */
+ now += 600;
+
+ const char *u_from_ggsn =
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr */
+ "ff" /* type 255: G-PDU */
+ "0058" /* length: 88 + 8 octets == 96 */
+ "00000001" /* mapped TEI for SGSN from create_pdp_ctx() */
+ "0070" /* seq */
+ "0000" /* No extensions */
+ /* User data (ICMP packet), 96 - 12 = 84 octets */
+ "45000054daee40004001f7890a172a010a172a02080060d23f590071e3f8"
+ "4156000000007241010000000000101112131415161718191a1b1c1d1e1f"
+ "202122232425262728292a2b2c2d2e2f3031323334353637"
+ ;
+ const char *u_to_sgsn =
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr */
+ "ff" /* type 255: G-PDU */
+ "0058" /* length: 88 + 8 octets == 96 */
+ "00000123" /* unmapped User TEI */
+ "6d31" /* new mapped seq */
+ "0000"
+ "45000054daee40004001f7890a172a010a172a02080060d23f590071e3f8"
+ "4156000000007241010000000000101112131415161718191a1b1c1d1e1f"
+ "202122232425262728292a2b2c2d2e2f3031323334353637"
+ ;
+
+ /* This depends on create_pdp_ctx() sending resolved_sgsn_addr as GSN
+ * Address IEs in the GGSN's Create PDP Ctx Response. */
+ OSMO_ASSERT(msg_from_ggsn_u(&ggsn_sender,
+ &resolved_sgsn_addr,
+ u_from_ggsn,
+ u_to_sgsn));
+
+ /* Make sure the user plane messages have refreshed the TEI mapping
+ * timeouts: 21945 + 600 == 22545. */
+ OSMO_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @22545\n"));
+
+ const char *u_from_sgsn =
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr */
+ "ff" /* type 255: G-PDU */
+ "0058" /* length: 88 + 8 octets == 96 */
+ "00000001" /* mapped User TEI for GGSN from create_pdp_ctx() */
+ "1234" /* unknown seq */
+ "0000" /* No extensions */
+ /* User data (ICMP packet), 96 - 12 = 84 octets */
+ "45000054daee40004001f7890a172a010a172a02080060d23f590071e3f8"
+ "4156000000007241010000000000101112131415161718191a1b1c1d1e1f"
+ "202122232425262728292a2b2c2d2e2f3031323334353637"
+ ;
+ const char *u_to_ggsn =
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr */
+ "ff" /* type 255: G-PDU */
+ "0058" /* length: 88 + 8 octets == 96 */
+ "00000567" /* unmapped User TEI */
+ "6d31" /* unmapped seq */
+ "0000"
+ "45000054daee40004001f7890a172a010a172a02080060d23f590071e3f8"
+ "4156000000007241010000000000101112131415161718191a1b1c1d1e1f"
+ "202122232425262728292a2b2c2d2e2f3031323334353637"
+ ;
+
+ OSMO_ASSERT(msg_from_sgsn_u(&sgsn_sender,
+ &resolved_ggsn_addr,
+ u_from_sgsn,
+ u_to_ggsn));
+
+ /* Make sure the user plane messages have refreshed the TEI mapping
+ * timeouts: 21945 + 600 == 22545. Both timeouts refreshed: */
+ OSMO_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @22545\n"));
+
+ OSMO_ASSERT(clear_test_hub());
+}
+
+static void test_reused_tei(void)
+{
+ LOG("test_reused_tei");
+
+ OSMO_ASSERT(setup_test_hub());
+
+ OSMO_ASSERT(create_pdp_ctx());
+
+ const char *gtp_req_from_sgsn =
+ MSG_PDP_CTX_REQ("0068",
+ "abce", /* Next seq */
+ "60",
+ "42000121436587f9",
+ "00000123", /* Same TEIs as before */
+ "00000321",
+ "0009""08696e7465726e6574", /* "(8)internet" */
+ "0004""c0a82a17", /* same as default sgsn_sender */
+ "0004""c0a82a17"
+ );
+ const char *gtp_req_to_ggsn =
+ MSG_PDP_CTX_REQ("0068",
+ "6d32", /* mapped seq ("abce") */
+ "23",
+ "42000121436587f9",
+ "00000002", /* mapped TEI Data I ("123") */
+ "00000002", /* mapped TEI Control ("321") */
+ "0009""08696e7465726e6574",
+ "0004""7f000201", /* replaced with gtphub's ggsn ctrl */
+ "0004""7f000202" /* replaced with gtphub's ggsn user */
+ );
+
+ OSMO_ASSERT(msg_from_sgsn_c(&sgsn_sender,
+ &resolved_ggsn_addr,
+ gtp_req_from_sgsn,
+ gtp_req_to_ggsn));
+ OSMO_ASSERT(was_resolved_for("240010123456789", "internet"));
+
+ OSMO_ASSERT(tunnels_are(
+ "TEI=2:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C=0 U=0)"
+ " @21945\n"));
+
+ const char *gtp_resp_from_ggsn =
+ MSG_PDP_CTX_RSP("004e",
+ "00000002", /* destination TEI (sent in req above) */
+ "6d32", /* mapped seq */
+ "01", /* restart */
+ "00000567", /* TEI U */
+ "00000765", /* TEI C */
+ "0004""c0a82b22", /* GSN addresses */
+ "0004""c0a82b22" /* (== resolved_ggsn_addr) */
+ );
+ const char *gtp_resp_to_sgsn =
+ MSG_PDP_CTX_RSP("004e",
+ "00000321", /* unmapped TEI ("001") */
+ "abce", /* unmapped seq ("6d32") */
+ "23",
+ "00000002", /* mapped TEI from GGSN ("567") */
+ "00000002", /* mapped TEI from GGSN ("765") */
+ "0004""7f000101", /* gtphub's address towards SGSNs (Ctrl) */
+ "0004""7f000102" /* gtphub's address towards SGSNs (User) */
+ );
+ /* The response should go back to whichever port the request came from
+ * (unmapped by sequence nr) */
+ OSMO_ASSERT(msg_from_ggsn_c(&resolved_ggsn_addr,
+ &sgsn_sender,
+ gtp_resp_from_ggsn,
+ gtp_resp_to_sgsn));
+
+ OSMO_ASSERT(clear_test_hub());
+}
+
+static void test_peer_restarted(void)
+{
+ LOG("test_peer_restarted");
+
+ OSMO_ASSERT(setup_test_hub());
+
+ OSMO_ASSERT(create_pdp_ctx());
+
+ now += 10;
+
+ const char *gtp_req_from_sgsn =
+ MSG_PDP_CTX_REQ("0068",
+ "1234", /* brand new seq */
+ "61", /* DIFFERING restart counter */
+ "42000121436587f9",
+ "00000abc",
+ "00000cba",
+ "0009""08696e7465726e6574", /* "(8)internet" */
+ "0004""c0a82a17", /* same as default sgsn_sender */
+ "0004""c0a82a17"
+ );
+ const char *gtp_req_to_ggsn =
+ MSG_PDP_CTX_REQ("0068",
+ "6d33", /* mapped seq ("1234") */
+ "23",
+ "42000121436587f9",
+ "00000002", /* mapped TEI Data I ("123") */
+ "00000002", /* mapped TEI Control ("321") */
+ "0009""08696e7465726e6574",
+ "0004""7f000201", /* replaced with gtphub's ggsn ctrl */
+ "0004""7f000202" /* replaced with gtphub's ggsn user */
+ );
+
+ OSMO_ASSERT(msg_from_sgsn_c(&sgsn_sender,
+ &resolved_ggsn_addr,
+ gtp_req_from_sgsn,
+ gtp_req_to_ggsn));
+ OSMO_ASSERT(was_resolved_for("240010123456789", "internet"));
+
+ OSMO_ASSERT(tunnels_are(
+ "TEI=2:"
+ " 192.168.42.23 (TEI C=cba U=abc)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C=0 U=0)"
+ " @21955\n"
+ "TEI=1:"
+ " (uninitialized) (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @21945\n"
+ ));
+
+ const char *gtp_resp_from_ggsn =
+ MSG_PDP_CTX_RSP("004e",
+ "00000002", /* destination TEI (sent in req above) */
+ "6d33", /* mapped seq */
+ "01", /* restart */
+ "00000def", /* TEI U */
+ "00000fde", /* TEI C */
+ "0004""c0a82b22", /* GSN addresses */
+ "0004""c0a82b22" /* (== resolved_ggsn_addr) */
+ );
+ const char *gtp_resp_to_sgsn =
+ MSG_PDP_CTX_RSP("004e",
+ "00000cba", /* unmapped TEI ("005") */
+ "1234", /* unmapped seq ("6d32") */
+ "23",
+ "00000002", /* mapped TEI from GGSN ("567") */
+ "00000002", /* mapped TEI from GGSN ("765") */
+ "0004""7f000101", /* gtphub's address towards SGSNs (Ctrl) */
+ "0004""7f000102" /* gtphub's address towards SGSNs (User) */
+ );
+ /* The response should go back to whichever port the request came from
+ * (unmapped by sequence nr) */
+ OSMO_ASSERT(msg_from_ggsn_c(&resolved_ggsn_addr,
+ &sgsn_sender,
+ gtp_resp_from_ggsn,
+ gtp_resp_to_sgsn));
+
+ OSMO_ASSERT(clear_test_hub());
+}
+
+static void test_peer_restarted_reusing_tei(void)
+{
+ LOG("test_peer_restarted_reusing_tei");
+
+ OSMO_ASSERT(setup_test_hub());
+
+ OSMO_ASSERT(create_pdp_ctx());
+
+ now += 10;
+
+ const char *gtp_req_from_sgsn =
+ MSG_PDP_CTX_REQ("0068",
+ "1234", /* brand new seq */
+ "61", /* DIFFERING restart counter */
+ "42000121436587f9",
+ "00000123", /* SAME TEI */
+ "00000321",
+ "0009""08696e7465726e6574", /* "(8)internet" */
+ "0004""c0a82a17", /* same as default sgsn_sender */
+ "0004""c0a82a17"
+ );
+ const char *gtp_req_to_ggsn =
+ MSG_PDP_CTX_REQ("0068",
+ "6d33", /* seq 6d31 + 2, after "out-of-band" Delete PDP Ctx
+ due to differing restart counter. */
+ "23",
+ "42000121436587f9",
+ "00000002", /* mapped TEI Data I ("123") */
+ "00000002", /* mapped TEI Control ("321") */
+ "0009""08696e7465726e6574",
+ "0004""7f000201", /* replaced with gtphub's ggsn ctrl */
+ "0004""7f000202" /* replaced with gtphub's ggsn user */
+ );
+
+ OSMO_ASSERT(msg_from_sgsn_c(&sgsn_sender,
+ &resolved_ggsn_addr,
+ gtp_req_from_sgsn,
+ gtp_req_to_ggsn));
+ OSMO_ASSERT(was_resolved_for("240010123456789", "internet"));
+
+ OSMO_ASSERT(tunnels_are(
+ "TEI=2:" /* being established after restart */
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C=0 U=0)"
+ " @21955\n"
+ "TEI=1:" /* invalidated due to restart */
+ " (uninitialized) (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @21945\n"
+ ));
+
+ /* An "out-of-band" delete request should have been sent to the GGSN
+ * (checked by expected log output in gtphub_test.ok), and the GGSN
+ * will (usually) send a Delete Response like this: */
+ const char *gtp_del_resp_from_ggsn =
+ MSG_DEL_PDP_CTX_RSP("00000001", "6d32");
+
+ /* For this response (due to peer restart) we expect no forwarded
+ * message. */
+ OSMO_ASSERT(msg_from_ggsn_c(&resolved_ggsn_addr,
+ &sgsn_sender,
+ gtp_del_resp_from_ggsn,
+ ""));
+
+ OSMO_ASSERT(tunnels_are(
+ "TEI=2:" /* still being established after restart */
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C=0 U=0)"
+ " @21955\n"
+ ));
+
+ const char *gtp_resp_from_ggsn =
+ MSG_PDP_CTX_RSP("004e",
+ "00000002", /* destination TEI (sent in req above) */
+ "6d33", /* mapped seq */
+ "01", /* restart */
+ "00000def", /* TEI U */
+ "00000fde", /* TEI C */
+ "0004""c0a82b22", /* GSN addresses */
+ "0004""c0a82b22" /* (== resolved_ggsn_addr) */
+ );
+ const char *gtp_resp_to_sgsn =
+ MSG_PDP_CTX_RSP("004e",
+ "00000321", /* unmapped TEI ("005") */
+ "1234", /* unmapped seq ("6d33") */
+ "23",
+ "00000002", /* mapped TEI from GGSN ("567") */
+ "00000002", /* mapped TEI from GGSN ("765") */
+ "0004""7f000101", /* gtphub's address towards SGSNs (Ctrl) */
+ "0004""7f000102" /* gtphub's address towards SGSNs (User) */
+ );
+ /* The response should go back to whichever port the request came from
+ * (unmapped by sequence nr) */
+ OSMO_ASSERT(msg_from_ggsn_c(&resolved_ggsn_addr,
+ &sgsn_sender,
+ gtp_resp_from_ggsn,
+ gtp_resp_to_sgsn));
+
+ OSMO_ASSERT(tunnels_are(
+ "TEI=2:" /* still being established after restart */
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=fde U=def)"
+ " @21955\n"
+ ));
+
+ OSMO_ASSERT(clear_test_hub());
+}
+
+static void test_sgsn_behind_nat(void)
+{
+ LOG("test_user_data");
+
+ OSMO_ASSERT(setup_test_hub());
+ hub->sgsn_use_sender = 1; /* <-- Main difference to test_user_data() */
+ resolve_to_sgsn("192.168.42.23", 423); /* Same as sender */
+
+ OSMO_ASSERT(create_pdp_ctx());
+
+ /* now == 345; now + (6 * 60 * 60) == 21600 + 345 == 21945. */
+ OSMO_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @21945\n"));
+
+ LOG("- user data starts");
+ /* Now expect default port numbers for User plane -- except SGSN. */
+ resolve_to_ggsn("192.168.43.34", 2152);
+
+ /* 10 minutes later */
+ now += 600;
+
+ const char *u_from_ggsn =
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr */
+ "ff" /* type 255: G-PDU */
+ "0058" /* length: 88 + 8 octets == 96 */
+ "00000001" /* mapped User TEI for SGSN from create_pdp_ctx() */
+ "0070" /* seq */
+ "0000" /* No extensions */
+ /* User data (ICMP packet), 96 - 12 = 84 octets */
+ "45000054daee40004001f7890a172a010a172a02080060d23f590071e3f8"
+ "4156000000007241010000000000101112131415161718191a1b1c1d1e1f"
+ "202122232425262728292a2b2c2d2e2f3031323334353637"
+ ;
+ const char *u_to_sgsn =
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr */
+ "ff" /* type 255: G-PDU */
+ "0058" /* length: 88 + 8 octets == 96 */
+ "00000123" /* unmapped User TEI */
+ "6d31" /* new mapped seq */
+ "0000"
+ "45000054daee40004001f7890a172a010a172a02080060d23f590071e3f8"
+ "4156000000007241010000000000101112131415161718191a1b1c1d1e1f"
+ "202122232425262728292a2b2c2d2e2f3031323334353637"
+ ;
+
+ /* This depends on create_pdp_ctx() sending resolved_sgsn_addr as GSN
+ * Address IEs in the GGSN's Create PDP Ctx Response. */
+ OSMO_ASSERT(msg_from_ggsn_u(&ggsn_sender,
+ &resolved_sgsn_addr,
+ u_from_ggsn,
+ u_to_sgsn));
+
+ /* Make sure the user plane messages have refreshed the TEI mapping
+ * timeouts: 21945 + 600 == 22545. */
+ OSMO_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @22545\n"));
+
+ const char *u_from_sgsn =
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr */
+ "ff" /* type 255: G-PDU */
+ "0058" /* length: 88 + 8 octets == 96 */
+ "00000001" /* mapped User TEI for GGSN from create_pdp_ctx() */
+ "1234" /* unknown seq */
+ "0000" /* No extensions */
+ /* User data (ICMP packet), 96 - 12 = 84 octets */
+ "45000054daee40004001f7890a172a010a172a02080060d23f590071e3f8"
+ "4156000000007241010000000000101112131415161718191a1b1c1d1e1f"
+ "202122232425262728292a2b2c2d2e2f3031323334353637"
+ ;
+ const char *u_to_ggsn =
+ "32" /* 0b001'1 0010: version 1, protocol GTP, with seq nr */
+ "ff" /* type 255: G-PDU */
+ "0058" /* length: 88 + 8 octets == 96 */
+ "00000567" /* unmapped User TEI */
+ "6d31" /* unmapped seq */
+ "0000"
+ "45000054daee40004001f7890a172a010a172a02080060d23f590071e3f8"
+ "4156000000007241010000000000101112131415161718191a1b1c1d1e1f"
+ "202122232425262728292a2b2c2d2e2f3031323334353637"
+ ;
+
+ OSMO_ASSERT(msg_from_sgsn_u(&sgsn_sender,
+ &resolved_ggsn_addr,
+ u_from_sgsn,
+ u_to_ggsn));
+
+ /* Make sure the user plane messages have refreshed the TEI mapping
+ * timeouts: 21945 + 600 == 22545. Both timeouts refreshed: */
+ OSMO_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @22545\n"));
+
+ OSMO_ASSERT(clear_test_hub());
+}
+
+void test_parallel_context_creation(void)
+{
+ LOG("test_parallel_context_creation");
+
+ OSMO_ASSERT(setup_test_hub());
+
+ const char *gtp_req_from_sgsn1 =
+ MSG_PDP_CTX_REQ("0068",
+ "abcd",
+ "60",
+ "42000121436587f9",
+ "00000123",
+ "00000321",
+ "0009""08696e7465726e6574", /* "(8)internet" */
+ "0004""c0a82a17", /* same as default sgsn_sender */
+ "0004""c0a82a17"
+ );
+ const char *gtp_req_to_ggsn1 =
+ MSG_PDP_CTX_REQ("0068",
+ "6d31", /* mapped seq ("abcd") */
+ "23",
+ "42000121436587f9",
+ "00000001", /* mapped TEI Data I ("123") */
+ "00000001", /* mapped TEI Control ("321") */
+ "0009""08696e7465726e6574",
+ "0004""7f000201", /* replaced with gtphub's ggsn ctrl */
+ "0004""7f000202" /* replaced with gtphub's ggsn user */
+ );
+
+ OSMO_ASSERT(msg_from_sgsn_c(&sgsn_sender,
+ &resolved_ggsn_addr,
+ gtp_req_from_sgsn1,
+ gtp_req_to_ggsn1));
+
+ OSMO_ASSERT(tunnels_are(
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C=0 U=0)"
+ " @21945\n"));
+
+ now ++;
+
+ const char *gtp_req_from_sgsn2 =
+ MSG_PDP_CTX_REQ("0068",
+ "abce",
+ "60",
+ "42000121436588f9",
+ "00000124",
+ "00000322",
+ "0009""08696e7465726e6574", /* "(8)internet" */
+ "0004""c0a82a17", /* same as default sgsn_sender */
+ "0004""c0a82a17"
+ );
+ const char *gtp_req_to_ggsn2 =
+ MSG_PDP_CTX_REQ("0068",
+ "6d32", /* mapped seq ("abce") */
+ "23",
+ "42000121436588f9",
+ "00000002", /* mapped TEI Data I ("124") */
+ "00000002", /* mapped TEI Control ("322") */
+ "0009""08696e7465726e6574",
+ "0004""7f000201", /* replaced with gtphub's ggsn ctrl */
+ "0004""7f000202" /* replaced with gtphub's ggsn user */
+ );
+
+ OSMO_ASSERT(msg_from_sgsn_c(&sgsn_sender,
+ &resolved_ggsn_addr,
+ gtp_req_from_sgsn2,
+ gtp_req_to_ggsn2));
+
+ OSMO_ASSERT(tunnels_are(
+ "TEI=2:"
+ " 192.168.42.23 (TEI C=322 U=124)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C=0 U=0)"
+ " @21946\n"
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C=0 U=0)"
+ " @21945\n"
+ ));
+
+ now ++;
+
+ const char *gtp_resp_from_ggsn1 =
+ MSG_PDP_CTX_RSP("004e",
+ "00000001", /* destination TEI (sent in req above) */
+ "6d31", /* mapped seq */
+ "01", /* restart */
+ "00000567", /* TEI U */
+ "00000765", /* TEI C */
+ "0004""c0a82b22", /* GSN addresses */
+ "0004""c0a82b22" /* (== resolved_ggsn_addr) */
+ );
+ const char *gtp_resp_to_sgsn1 =
+ MSG_PDP_CTX_RSP("004e",
+ "00000321", /* unmapped TEI ("001") */
+ "abcd", /* unmapped seq ("6d31") */
+ "23",
+ "00000001", /* mapped TEI from GGSN ("567") */
+ "00000001", /* mapped TEI from GGSN ("765") */
+ "0004""7f000101", /* gtphub's address towards SGSNs (Ctrl) */
+ "0004""7f000102" /* gtphub's address towards SGSNs (User) */
+ );
+
+ OSMO_ASSERT(msg_from_ggsn_c(&resolved_ggsn_addr,
+ &sgsn_sender,
+ gtp_resp_from_ggsn1,
+ gtp_resp_to_sgsn1));
+
+ OSMO_ASSERT(tunnels_are(
+ "TEI=2:"
+ " 192.168.42.23 (TEI C=322 U=124)"
+ " <-> 192.168.43.34/(uninitialized) (TEI C=0 U=0)"
+ " @21946\n"
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @21947\n"
+ ));
+
+ now ++;
+
+ const char *gtp_resp_from_ggsn2 =
+ MSG_PDP_CTX_RSP("004e",
+ "00000002", /* destination TEI (sent in req above) */
+ "6d32", /* mapped seq */
+ "01", /* restart */
+ "00000568", /* TEI U */
+ "00000766", /* TEI C */
+ "0004""c0a82b22", /* GSN addresses */
+ "0004""c0a82b22" /* (== resolved_ggsn_addr) */
+ );
+ const char *gtp_resp_to_sgsn2 =
+ MSG_PDP_CTX_RSP("004e",
+ "00000322", /* unmapped TEI ("001") */
+ "abce", /* unmapped seq ("6d31") */
+ "23",
+ "00000002", /* mapped TEI from GGSN ("567") */
+ "00000002", /* mapped TEI from GGSN ("765") */
+ "0004""7f000101", /* gtphub's address towards SGSNs (Ctrl) */
+ "0004""7f000102" /* gtphub's address towards SGSNs (User) */
+ );
+
+ OSMO_ASSERT(msg_from_ggsn_c(&resolved_ggsn_addr,
+ &sgsn_sender,
+ gtp_resp_from_ggsn2,
+ gtp_resp_to_sgsn2));
+
+ OSMO_ASSERT(tunnels_are(
+ "TEI=2:"
+ " 192.168.42.23 (TEI C=322 U=124)"
+ " <-> 192.168.43.34 (TEI C=766 U=568)"
+ " @21948\n"
+ "TEI=1:"
+ " 192.168.42.23 (TEI C=321 U=123)"
+ " <-> 192.168.43.34 (TEI C=765 U=567)"
+ " @21947\n"
+ ));
+
+ OSMO_ASSERT(clear_test_hub());
+}
+
+
+static struct log_info_cat gtphub_categories[] = {
+ [DGTPHUB] = {
+ .name = "DGTPHUB",
+ .description = "GTP Hub",
+ .color = "\033[1;33m",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ },
+};
+
+static struct log_info info = {
+ .cat = gtphub_categories,
+ .num_cat = ARRAY_SIZE(gtphub_categories),
+};
+
+int main(int argc, char **argv)
+{
+ osmo_init_logging(&info);
+ osmo_gtphub_ctx = talloc_named_const(NULL, 0, "osmo_gtphub");
+
+ test_nr_map_basic();
+ test_nr_map_wrap();
+ test_expiry();
+ test_echo();
+ test_one_pdp_ctx(GTPH_SIDE_SGSN);
+ test_one_pdp_ctx(GTPH_SIDE_GGSN);
+ test_user_data();
+ test_reused_tei();
+ test_peer_restarted();
+ test_peer_restarted_reusing_tei();
+ test_sgsn_behind_nat();
+ test_parallel_context_creation();
+ printf("Done\n");
+
+ talloc_report_full(osmo_gtphub_ctx, stderr);
+ OSMO_ASSERT(talloc_total_blocks(osmo_gtphub_ctx) == 1);
+ return 0;
+}
+
diff --git a/tests/gtphub/gtphub_test.ok b/tests/gtphub/gtphub_test.ok
new file mode 100644
index 000000000..e60d5f2b2
--- /dev/null
+++ b/tests/gtphub/gtphub_test.ok
@@ -0,0 +1,42 @@
+test_echo
+test_one_pdp_ctx (del from SGSN)
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
+test_one_pdp_ctx (del from GGSN)
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
+test_user_data
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
+- user data starts
+test_reused_tei
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
+test_peer_restarted
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
+Out-of-band gtphub_write(16):
+to 192.168.43.34 port 2123
+32 14 00 08 00 00 07 65 6d 32 00 00 13 ff 14 00
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
+test_peer_restarted_reusing_tei
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
+Out-of-band gtphub_write(16):
+to 192.168.43.34 port 2123
+32 14 00 08 00 00 07 65 6d 32 00 00 13 ff 14 00
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
+test_user_data
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
+- user data starts
+test_parallel_context_creation
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456789 ni internet: 192.168.43.34 port 2123
+- __wrap_gtphub_resolve_ggsn_addr():
+ returning GGSN addr from imsi 240010123456889 ni internet: 192.168.43.34 port 2123
+Done
diff --git a/tests/mgcp/Makefile.am b/tests/mgcp/Makefile.am
new file mode 100644
index 000000000..4b18036cc
--- /dev/null
+++ b/tests/mgcp/Makefile.am
@@ -0,0 +1,72 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir) \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_FLAGS) \
+ $(LIBOSMONETIF_CFLAGS) \
+ $(LIBOSMOSCCP_CFLAGS) \
+ $(COVERAGE_CFLAGS) \
+ $(LIBBCG729_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(COVERAGE_LDFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ mgcp_test.ok \
+ mgcp_transcoding_test.ok \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ mgcp_test \
+ $(NULL)
+if BUILD_MGCP_TRANSCODING
+noinst_PROGRAMS += \
+ mgcp_transcoding_test \
+ $(NULL)
+endif
+
+mgcp_test_SOURCES = \
+ mgcp_test.c \
+ $(NULL)
+
+mgcp_test_LDADD = \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libmgcp/libmgcp.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOSCCP_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
+ $(LIBRARY_DL) \
+ $(LIBOSMONETIF_LIBS) \
+ -lrt \
+ -lm \
+ $(NULL)
+
+mgcp_transcoding_test_SOURCES = \
+ mgcp_transcoding_test.c \
+ $(NULL)
+
+mgcp_transcoding_test_LDADD = \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libmgcp/libmgcp.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBBCG729_LIBS) \
+ $(LIBOSMOSCCP_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
+ $(LIBRARY_DL) \
+ $(LIBOSMONETIF_LIBS) \
+ $(LIBRARY_GSM) \
+ -lrt \
+ -lm \
+ $(NULL)
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
new file mode 100644
index 000000000..43a453af8
--- /dev/null
+++ b/tests/mgcp/mgcp_test.c
@@ -0,0 +1,1227 @@
+/*
+ * (C) 2011-2012,2014 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2011-2012,2014 by On-Waves
+ * All Rights Reserved
+ *
+ * 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/>.
+ */
+#undef _GNU_SOURCE
+#define _GNU_SOURCE
+
+#include <openbsc/mgcp.h>
+#include <openbsc/vty.h>
+#include <openbsc/mgcp_internal.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+#include <string.h>
+#include <limits.h>
+#include <dlfcn.h>
+#include <time.h>
+#include <math.h>
+
+char *strline_r(char *str, char **saveptr);
+
+const char *strline_test_data =
+ "one CR\r"
+ "two CR\r"
+ "\r"
+ "one CRLF\r\n"
+ "two CRLF\r\n"
+ "\r\n"
+ "one LF\n"
+ "two LF\n"
+ "\n"
+ "mixed (4 lines)\r\r\n\n\r\n";
+
+#define EXPECTED_NUMBER_OF_LINES 13
+
+static void test_strline(void)
+{
+ char *save = NULL;
+ char *line;
+ char buf[2048];
+ int counter = 0;
+
+ osmo_strlcpy(buf, strline_test_data, sizeof(buf));
+
+ for (line = strline_r(buf, &save); line;
+ line = strline_r(NULL, &save)) {
+ printf("line: '%s'\n", line);
+ counter++;
+ }
+
+ OSMO_ASSERT(counter == EXPECTED_NUMBER_OF_LINES);
+}
+
+#define AUEP1 "AUEP 158663169 ds/e1-1/2@172.16.6.66 MGCP 1.0\r\n"
+#define AUEP1_RET "200 158663169 OK\r\n"
+#define AUEP2 "AUEP 18983213 ds/e1-2/1@172.16.6.66 MGCP 1.0\r\n"
+#define AUEP2_RET "500 18983213 FAIL\r\n"
+#define EMPTY "\r\n"
+#define EMPTY_RET NULL
+#define SHORT "CRCX \r\n"
+#define SHORT_RET "510 000000 FAIL\r\n"
+
+#define MDCX_WRONG_EP "MDCX 18983213 ds/e1-3/1@172.16.6.66 MGCP 1.0\r\n"
+#define MDCX_ERR_RET "510 18983213 FAIL\r\n"
+#define MDCX_UNALLOCATED "MDCX 18983214 ds/e1-1/2@172.16.6.66 MGCP 1.0\r\n"
+#define MDCX_RET "400 18983214 FAIL\r\n"
+#define MDCX3 "MDCX 18983215 1@mgw MGCP 1.0\r\n"
+#define MDCX3_RET "200 18983215 OK\r\n" \
+ "I: 1\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 1 23 IN IP4 0.0.0.0\r\n" \
+ "s=-\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 0 RTP/AVP 126\r\n" \
+ "a=rtpmap:126 AMR/8000\r\n" \
+ "a=ptime:20\r\n"
+#define MDCX3_FMTP_RET "200 18983215 OK\r\n" \
+ "I: 3\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 3 23 IN IP4 0.0.0.0\r\n" \
+ "s=-\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 0 RTP/AVP 126\r\n" \
+ "a=rtpmap:126 AMR/8000\r\n" \
+ "a=fmtp:126 0/1/2\r\n" \
+ "a=ptime:20\r\n"
+#define MDCX4 "MDCX 18983216 1@mgw MGCP 1.0\r\n" \
+ "M: sendrecv\r" \
+ "C: 2\r\n" \
+ "I: 1\r\n" \
+ "L: p:20, a:AMR, nt:IN\r\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 1 23 IN IP4 0.0.0.0\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 4441 RTP/AVP 99\r\n" \
+ "a=rtpmap:99 AMR/8000\r\n" \
+ "a=ptime:40\r\n"
+#define MDCX4_RET(Ident) "200 " Ident " OK\r\n" \
+ "I: 1\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 1 23 IN IP4 0.0.0.0\r\n" \
+ "s=-\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 0 RTP/AVP 126\r\n" \
+ "a=rtpmap:126 AMR/8000\r\n" \
+ "a=ptime:20\r\n"
+
+#define MDCX4_PT1 "MDCX 18983217 1@mgw MGCP 1.0\r\n" \
+ "M: sendrecv\r" \
+ "C: 2\r\n" \
+ "I: 1\r\n" \
+ "L: p:20-40, a:AMR, nt:IN\r\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 1 23 IN IP4 0.0.0.0\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 4441 RTP/AVP 99\r\n" \
+ "a=rtpmap:99 AMR/8000\r\n" \
+ "a=ptime:40\r\n"
+
+#define MDCX4_PT2 "MDCX 18983218 1@mgw MGCP 1.0\r\n" \
+ "M: sendrecv\r" \
+ "C: 2\r\n" \
+ "I: 1\r\n" \
+ "L: p:20-20, a:AMR, nt:IN\r\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 1 23 IN IP4 0.0.0.0\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 4441 RTP/AVP 99\r\n" \
+ "a=rtpmap:99 AMR/8000\r\n" \
+ "a=ptime:40\r\n"
+
+#define MDCX4_PT3 "MDCX 18983219 1@mgw MGCP 1.0\r\n" \
+ "M: sendrecv\r" \
+ "C: 2\r\n" \
+ "I: 1\r\n" \
+ "L: a:AMR, nt:IN\r\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 1 23 IN IP4 0.0.0.0\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 4441 RTP/AVP 99\r\n" \
+ "a=rtpmap:99 AMR/8000\r\n" \
+ "a=ptime:40\r\n"
+
+#define MDCX4_SO "MDCX 18983220 1@mgw MGCP 1.0\r\n" \
+ "M: sendonly\r" \
+ "C: 2\r\n" \
+ "I: 1\r\n" \
+ "L: p:20, a:AMR, nt:IN\r\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 1 23 IN IP4 0.0.0.0\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 4441 RTP/AVP 99\r\n" \
+ "a=rtpmap:99 AMR/8000\r\n" \
+ "a=ptime:40\r\n"
+
+#define MDCX4_RO "MDCX 18983221 1@mgw MGCP 1.0\r\n" \
+ "M: recvonly\r" \
+ "C: 2\r\n" \
+ "I: 1\r\n" \
+ "L: p:20, a:AMR, nt:IN\r\n"
+
+#define SHORT2 "CRCX 1"
+#define SHORT2_RET "510 000000 FAIL\r\n"
+#define SHORT3 "CRCX 1 1@mgw"
+#define SHORT4 "CRCX 1 1@mgw MGCP"
+#define SHORT5 "CRCX 1 1@mgw MGCP 1.0"
+
+#define CRCX "CRCX 2 1@mgw MGCP 1.0\r\n" \
+ "M: recvonly\r\n" \
+ "C: 2\r\n" \
+ "X\r\n" \
+ "L: p:20\r\n" \
+ "\r\n" \
+ "v=0\r\n" \
+ "c=IN IP4 123.12.12.123\r\n" \
+ "m=audio 5904 RTP/AVP 97\r\n" \
+ "a=rtpmap:97 GSM-EFR/8000\r\n" \
+ "a=ptime:40\r\n"
+
+#define CRCX_RET "200 2 OK\r\n" \
+ "I: 1\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 1 23 IN IP4 0.0.0.0\r\n" \
+ "s=-\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 0 RTP/AVP 126\r\n" \
+ "a=rtpmap:126 AMR/8000\r\n" \
+ "a=ptime:20\r\n"
+
+#define CRCX_RET_NO_RTPMAP "200 2 OK\r\n" \
+ "I: 1\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 1 23 IN IP4 0.0.0.0\r\n" \
+ "s=-\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 0 RTP/AVP 126\r\n" \
+ "a=ptime:20\r\n"
+
+#define CRCX_FMTP_RET "200 2 OK\r\n" \
+ "I: 3\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 3 23 IN IP4 0.0.0.0\r\n" \
+ "s=-\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 0 RTP/AVP 126\r\n" \
+ "a=rtpmap:126 AMR/8000\r\n" \
+ "a=fmtp:126 0/1/2\r\n" \
+ "a=ptime:20\r\n"
+
+#define CRCX_ZYN "CRCX 2 1@mgw MGCP 1.0\r" \
+ "M: recvonly\r" \
+ "C: 2\r\r" \
+ "v=0\r" \
+ "c=IN IP4 123.12.12.123\r" \
+ "m=audio 5904 RTP/AVP 97\r" \
+ "a=rtpmap:97 GSM-EFR/8000\r"
+
+#define CRCX_ZYN_RET "200 2 OK\r\n" \
+ "I: 2\n" \
+ "\n" \
+ "v=0\r\n" \
+ "o=- 2 23 IN IP4 0.0.0.0\r\n" \
+ "s=-\r\n" \
+ "c=IN IP4 0.0.0.0\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 0 RTP/AVP 126\r\n" \
+ "a=rtpmap:126 AMR/8000\r\n" \
+ "a=ptime:20\r\n"
+
+#define DLCX "DLCX 7 1@mgw MGCP 1.0\r\n" \
+ "C: 2\r\n"
+
+#define DLCX_RET "250 7 OK\r\n" \
+ "P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0\r\n" \
+ "X-Osmo-CP: EC TIS=0, TOS=0, TIR=0, TOR=0\r\n"
+
+#define RQNT "RQNT 186908780 1@mgw MGCP 1.0\r\n" \
+ "X: B244F267488\r\n" \
+ "S: D/9\r\n"
+
+#define RQNT2 "RQNT 186908781 1@mgw MGCP 1.0\r\n" \
+ "X: ADD4F26746F\r\n" \
+ "R: D/[0-9#*](N), G/ft, fxr/t38\r\n"
+
+#define RQNT1_RET "200 186908780 OK\r\n"
+#define RQNT2_RET "200 186908781 OK\r\n"
+
+#define PTYPE_IGNORE 0 /* == default initializer */
+#define PTYPE_NONE 128
+#define PTYPE_NYI PTYPE_NONE
+
+#define CRCX_MULT_1 "CRCX 2 1@mgw MGCP 1.0\r\n" \
+ "M: recvonly\r\n" \
+ "C: 2\r\n" \
+ "X\r\n" \
+ "L: p:20\r\n" \
+ "\r\n" \
+ "v=0\r\n" \
+ "c=IN IP4 123.12.12.123\r\n" \
+ "m=audio 5904 RTP/AVP 18 97\r\n"\
+ "a=rtpmap:18 G729/8000\r\n" \
+ "a=rtpmap:97 GSM-EFR/8000\r\n" \
+ "a=ptime:40\r\n"
+
+#define CRCX_MULT_2 "CRCX 2 2@mgw MGCP 1.0\r\n" \
+ "M: recvonly\r\n" \
+ "C: 2\r\n" \
+ "X\r\n" \
+ "L: p:20\r\n" \
+ "\r\n" \
+ "v=0\r\n" \
+ "c=IN IP4 123.12.12.123\r\n" \
+ "m=audio 5904 RTP/AVP 18 97 101\r\n"\
+ "a=rtpmap:18 G729/8000\r\n" \
+ "a=rtpmap:97 GSM-EFR/8000\r\n" \
+ "a=rtpmap:101 FOO/8000\r\n" \
+ "a=ptime:40\r\n"
+
+#define CRCX_MULT_3 "CRCX 2 3@mgw MGCP 1.0\r\n" \
+ "M: recvonly\r\n" \
+ "C: 2\r\n" \
+ "X\r\n" \
+ "L: p:20\r\n" \
+ "\r\n" \
+ "v=0\r\n" \
+ "c=IN IP4 123.12.12.123\r\n" \
+ "m=audio 5904 RTP/AVP\r\n" \
+ "a=rtpmap:18 G729/8000\r\n" \
+ "a=rtpmap:97 GSM-EFR/8000\r\n" \
+ "a=rtpmap:101 FOO/8000\r\n" \
+ "a=ptime:40\r\n"
+
+#define CRCX_MULT_4 "CRCX 2 4@mgw MGCP 1.0\r\n" \
+ "M: recvonly\r\n" \
+ "C: 2\r\n" \
+ "X\r\n" \
+ "L: p:20\r\n" \
+ "\r\n" \
+ "v=0\r\n" \
+ "c=IN IP4 123.12.12.123\r\n" \
+ "m=audio 5904 RTP/AVP 18\r\n" \
+ "a=rtpmap:18 G729/8000\r\n" \
+ "a=rtpmap:97 GSM-EFR/8000\r\n" \
+ "a=rtpmap:101 FOO/8000\r\n" \
+ "a=ptime:40\r\n"
+
+#define CRCX_MULT_GSM_EXACT \
+ "CRCX 259260421 5@mgw MGCP 1.0\r\n" \
+ "C: 1355c6041e\r\n" \
+ "I: 3\r\n" \
+ "L: p:20, a:GSM, nt:IN\r\n" \
+ "M: recvonly\r\n" \
+ "\r\n" \
+ "v=0\r\n" \
+ "o=- 1439038275 1439038275 IN IP4 192.168.181.247\r\n" \
+ "s=-\r\nc=IN IP4 192.168.181.247\r\n" \
+ "t=0 0\r\nm=audio 29084 RTP/AVP 255 0 8 3 18 4 96 97 101\r\n" \
+ "a=rtpmap:0 PCMU/8000\r\n" \
+ "a=rtpmap:8 PCMA/8000\r\n" \
+ "a=rtpmap:3 gsm/8000\r\n" \
+ "a=rtpmap:18 G729/8000\r\n" \
+ "a=fmtp:18 annexb=no\r\n" \
+ "a=rtpmap:4 G723/8000\r\n" \
+ "a=rtpmap:96 iLBC/8000\r\n" \
+ "a=fmtp:96 mode=20\r\n" \
+ "a=rtpmap:97 iLBC/8000\r\n" \
+ "a=fmtp:97 mode=30\r\n" \
+ "a=rtpmap:101 telephone-event/8000\r\n" \
+ "a=fmtp:101 0-15\r\n" \
+ "a=recvonly\r\n"
+#define MDCX_NAT_DUMMY \
+ "MDCX 23 5@mgw MGCP 1.0\r\n" \
+ "C: 1355c6041e\r\n" \
+ "\r\n" \
+ "c=IN IP4 8.8.8.8\r\n" \
+ "m=audio 16434 RTP/AVP 255\r\n"
+
+
+struct mgcp_test {
+ const char *name;
+ const char *req;
+ const char *exp_resp;
+ int exp_net_ptype;
+ int exp_bts_ptype;
+
+ const char *extra_fmtp;
+};
+
+static const struct mgcp_test tests[] = {
+ { "AUEP1", AUEP1, AUEP1_RET },
+ { "AUEP2", AUEP2, AUEP2_RET },
+ { "MDCX1", MDCX_WRONG_EP, MDCX_ERR_RET },
+ { "MDCX2", MDCX_UNALLOCATED, MDCX_RET },
+ { "CRCX", CRCX, CRCX_RET, 97, 126 },
+ { "MDCX3", MDCX3, MDCX3_RET, PTYPE_NONE, 126 },
+ { "MDCX4", MDCX4, MDCX4_RET("18983216"), 99, 126 },
+ { "MDCX4_PT1", MDCX4_PT1, MDCX4_RET("18983217"), 99, 126 },
+ { "MDCX4_PT2", MDCX4_PT2, MDCX4_RET("18983218"), 99, 126 },
+ { "MDCX4_PT3", MDCX4_PT3, MDCX4_RET("18983219"), 99, 126 },
+ { "MDCX4_SO", MDCX4_SO, MDCX4_RET("18983220"), 99, 126 },
+ { "MDCX4_RO", MDCX4_RO, MDCX4_RET("18983221"), PTYPE_IGNORE, 126 },
+ { "DLCX", DLCX, DLCX_RET, -1, -1 },
+ { "CRCX_ZYN", CRCX_ZYN, CRCX_ZYN_RET, 97, 126 },
+ { "EMPTY", EMPTY, EMPTY_RET },
+ { "SHORT1", SHORT, SHORT_RET },
+ { "SHORT2", SHORT2, SHORT2_RET },
+ { "SHORT3", SHORT3, SHORT2_RET },
+ { "SHORT4", SHORT4, SHORT2_RET },
+ { "RQNT1", RQNT, RQNT1_RET },
+ { "RQNT2", RQNT2, RQNT2_RET },
+ { "DLCX", DLCX, DLCX_RET, -1, -1 },
+ { "CRCX", CRCX, CRCX_FMTP_RET, 97, 126, .extra_fmtp = "a=fmtp:126 0/1/2" },
+ { "MDCX3", MDCX3, MDCX3_FMTP_RET, PTYPE_NONE, 126 , .extra_fmtp = "a=fmtp:126 0/1/2" },
+ { "DLCX", DLCX, DLCX_RET, -1, -1 , .extra_fmtp = "a=fmtp:126 0/1/2" },
+};
+
+static const struct mgcp_test retransmit[] = {
+ { "CRCX", CRCX, CRCX_RET },
+ { "RQNT1", RQNT, RQNT1_RET },
+ { "RQNT2", RQNT2, RQNT2_RET },
+ { "MDCX3", MDCX3, MDCX3_RET },
+ { "DLCX", DLCX, DLCX_RET },
+};
+
+static struct msgb *create_msg(const char *str)
+{
+ struct msgb *msg;
+
+ msg = msgb_alloc_headroom(4096, 128, "MGCP msg");
+ int len = sprintf((char *)msg->data, "%s", str);
+ msg->l2h = msgb_put(msg, len);
+ return msg;
+}
+
+static int last_endpoint = -1;
+
+static int mgcp_test_policy_cb(struct mgcp_trunk_config *cfg, int endpoint,
+ int state, const char *transactio_id)
+{
+ fprintf(stderr, "Policy CB got state %d on endpoint %d\n",
+ state, endpoint);
+ last_endpoint = endpoint;
+ return MGCP_POLICY_CONT;
+}
+
+#define MGCP_DUMMY_LOAD 0x23
+static int dummy_packets = 0;
+/* override and forward */
+ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
+ const struct sockaddr *dest_addr, socklen_t addrlen)
+{
+ typedef ssize_t (*sendto_t)(int, const void *, size_t, int,
+ const struct sockaddr *, socklen_t);
+ static sendto_t real_sendto = NULL;
+ uint32_t dest_host = htonl(((struct sockaddr_in *)dest_addr)->sin_addr.s_addr);
+ int dest_port = htons(((struct sockaddr_in *)dest_addr)->sin_port);
+
+ if (!real_sendto)
+ real_sendto = dlsym(RTLD_NEXT, "sendto");
+
+ if (len == 1 && ((const char *)buf)[0] == MGCP_DUMMY_LOAD ) {
+ fprintf(stderr, "Dummy packet to 0x%08x:%d, msg length %zu\n%s\n\n",
+ dest_host, dest_port,
+ len, osmo_hexdump(buf, len));
+ dummy_packets += 1;
+ }
+
+ return real_sendto(sockfd, buf, len, flags, dest_addr, addrlen);
+}
+
+static int64_t force_monotonic_time_us = -1;
+/* override and forward */
+int clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+ typedef int (*clock_gettime_t)(clockid_t clk_id, struct timespec *tp);
+ static clock_gettime_t real_clock_gettime = NULL;
+
+ if (!real_clock_gettime)
+ real_clock_gettime = dlsym(RTLD_NEXT, "clock_gettime");
+
+ if (clk_id == CLOCK_MONOTONIC && force_monotonic_time_us >= 0) {
+ tp->tv_sec = force_monotonic_time_us / 1000000;
+ tp->tv_nsec = (force_monotonic_time_us % 1000000) * 1000;
+ return 0;
+ }
+
+ return real_clock_gettime(clk_id, tp);
+}
+
+#define CONN_UNMODIFIED (0x1000)
+
+static void test_values(void)
+{
+ /* Check that NONE disables all output */
+ OSMO_ASSERT((MGCP_CONN_NONE & MGCP_CONN_RECV_SEND) == 0)
+
+ /* Check that LOOPBACK enables all output */
+ OSMO_ASSERT((MGCP_CONN_LOOPBACK & MGCP_CONN_RECV_SEND) ==
+ MGCP_CONN_RECV_SEND)
+}
+
+
+static void test_messages(void)
+{
+ struct mgcp_config *cfg;
+ struct mgcp_endpoint *endp;
+ int i;
+
+ cfg = mgcp_config_alloc();
+
+ cfg->trunk.number_endpoints = 64;
+ mgcp_endpoints_allocate(&cfg->trunk);
+
+ cfg->policy_cb = mgcp_test_policy_cb;
+
+ mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1));
+
+ /* reset endpoints */
+ for (i = 0; i < cfg->trunk.number_endpoints; i++) {
+ endp = &cfg->trunk.endpoints[i];
+ endp->net_end.codec.payload_type = PTYPE_NONE;
+ endp->net_end.packet_duration_ms = -1;
+
+ OSMO_ASSERT(endp->conn_mode == MGCP_CONN_NONE);
+ endp->conn_mode |= CONN_UNMODIFIED;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(tests); i++) {
+ const struct mgcp_test *t = &tests[i];
+ struct msgb *inp;
+ struct msgb *msg;
+
+ printf("Testing %s\n", t->name);
+
+ last_endpoint = -1;
+ dummy_packets = 0;
+
+ osmo_talloc_replace_string(cfg, &cfg->trunk.audio_fmtp_extra, t->extra_fmtp);
+
+ inp = create_msg(t->req);
+ msg = mgcp_handle_message(cfg, inp);
+ msgb_free(inp);
+ if (!t->exp_resp) {
+ if (msg)
+ printf("%s failed '%s'\n", t->name, (char *) msg->data);
+ } else if (strcmp((char *) msg->data, t->exp_resp) != 0)
+ printf("%s failed '%s'\n", t->name, (char *) msg->data);
+ msgb_free(msg);
+
+ if (dummy_packets)
+ printf("Dummy packets: %d\n", dummy_packets);
+
+ if (last_endpoint != -1) {
+ endp = &cfg->trunk.endpoints[last_endpoint];
+
+ if (endp->net_end.packet_duration_ms != -1)
+ printf("Detected packet duration: %d\n",
+ endp->net_end.packet_duration_ms);
+ else
+ printf("Packet duration not set\n");
+ if (endp->local_options.pkt_period_min ||
+ endp->local_options.pkt_period_max)
+ printf("Requested packetetization period: "
+ "%d-%d\n",
+ endp->local_options.pkt_period_min,
+ endp->local_options.pkt_period_max);
+ else
+ printf("Requested packetization period not set\n");
+
+ if ((endp->conn_mode & CONN_UNMODIFIED) == 0) {
+ printf("Connection mode: %d:%s%s%s%s\n",
+ endp->conn_mode,
+ !endp->conn_mode ? " NONE" : "",
+ endp->conn_mode & MGCP_CONN_SEND_ONLY ?
+ " SEND" : "",
+ endp->conn_mode & MGCP_CONN_RECV_ONLY ?
+ " RECV" : "",
+ endp->conn_mode & MGCP_CONN_LOOPBACK &
+ ~MGCP_CONN_RECV_SEND ?
+ " LOOP" : "");
+ fprintf(stderr,
+ "BTS output %sabled, NET output %sabled\n",
+ endp->bts_end.output_enabled ? "en" : "dis",
+ endp->net_end.output_enabled ? "en" : "dis");
+ } else
+ printf("Connection mode not set\n");
+
+ OSMO_ASSERT(endp->net_end.output_enabled ==
+ (endp->conn_mode & MGCP_CONN_SEND_ONLY ? 1 : 0));
+ OSMO_ASSERT(endp->bts_end.output_enabled ==
+ (endp->conn_mode & MGCP_CONN_RECV_ONLY ? 1 : 0));
+
+ endp->net_end.packet_duration_ms = -1;
+ endp->local_options.pkt_period_min = 0;
+ endp->local_options.pkt_period_max = 0;
+ endp->conn_mode |= CONN_UNMODIFIED;
+ }
+
+
+ /* Check detected payload type */
+ if (t->exp_net_ptype != PTYPE_IGNORE ||
+ t->exp_bts_ptype != PTYPE_IGNORE) {
+ OSMO_ASSERT(last_endpoint != -1);
+ endp = &cfg->trunk.endpoints[last_endpoint];
+
+ fprintf(stderr, "endpoint %d: "
+ "payload type BTS %d (exp %d), NET %d (exp %d)\n",
+ last_endpoint,
+ endp->bts_end.codec.payload_type, t->exp_bts_ptype,
+ endp->net_end.codec.payload_type, t->exp_net_ptype);
+
+ if (t->exp_bts_ptype != PTYPE_IGNORE)
+ OSMO_ASSERT(endp->bts_end.codec.payload_type ==
+ t->exp_bts_ptype);
+ if (t->exp_net_ptype != PTYPE_IGNORE)
+ OSMO_ASSERT(endp->net_end.codec.payload_type ==
+ t->exp_net_ptype);
+
+ /* Reset them again for next test */
+ endp->net_end.codec.payload_type = PTYPE_NONE;
+ }
+ }
+
+ talloc_free(cfg);
+}
+
+static void test_retransmission(void)
+{
+ struct mgcp_config *cfg;
+ int i;
+
+ cfg = mgcp_config_alloc();
+
+ cfg->trunk.number_endpoints = 64;
+ mgcp_endpoints_allocate(&cfg->trunk);
+
+ mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1));
+
+ /* reset endpoints */
+ for (i = 0; i < cfg->trunk.number_endpoints; i++) {
+ struct mgcp_endpoint *endp;
+ endp = &cfg->trunk.endpoints[i];
+ endp->bts_end.packet_duration_ms = 20;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(retransmit); i++) {
+ const struct mgcp_test *t = &retransmit[i];
+ struct msgb *inp;
+ struct msgb *msg;
+
+ printf("Testing %s\n", t->name);
+
+ inp = create_msg(t->req);
+ msg = mgcp_handle_message(cfg, inp);
+ msgb_free(inp);
+ if (strcmp((char *) msg->data, t->exp_resp) != 0)
+ printf("%s failed '%s'\n", t->name, (char *) msg->data);
+ msgb_free(msg);
+
+ /* Retransmit... */
+ printf("Re-transmitting %s\n", t->name);
+ inp = create_msg(t->req);
+ msg = mgcp_handle_message(cfg, inp);
+ msgb_free(inp);
+ if (strcmp((char *) msg->data, t->exp_resp) != 0)
+ printf("%s failed '%s'\n", t->name, (char *) msg->data);
+ msgb_free(msg);
+ }
+
+ talloc_free(cfg);
+}
+
+static int rqnt_cb(struct mgcp_endpoint *endp, char _tone)
+{
+ ptrdiff_t tone = _tone;
+ endp->cfg->data = (void *) tone;
+ return 0;
+}
+
+static void test_rqnt_cb(void)
+{
+ struct mgcp_config *cfg;
+ struct msgb *inp, *msg;
+
+ cfg = mgcp_config_alloc();
+ cfg->rqnt_cb = rqnt_cb;
+
+ cfg->trunk.number_endpoints = 64;
+ mgcp_endpoints_allocate(&cfg->trunk);
+
+ mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1));
+
+ inp = create_msg(CRCX);
+ msgb_free(mgcp_handle_message(cfg, inp));
+ msgb_free(inp);
+
+ /* send the RQNT and check for the CB */
+ inp = create_msg(RQNT);
+ msg = mgcp_handle_message(cfg, inp);
+ if (strncmp((const char *) msg->l2h, "200", 3) != 0) {
+ printf("FAILED: message is not 200. '%s'\n", msg->l2h);
+ abort();
+ }
+
+ if (cfg->data != (void *) '9') {
+ printf("FAILED: callback not called: %p\n", cfg->data);
+ abort();
+ }
+
+ msgb_free(msg);
+ msgb_free(inp);
+
+ inp = create_msg(DLCX);
+ msgb_free(mgcp_handle_message(cfg, inp));
+ msgb_free(inp);
+ talloc_free(cfg);
+}
+
+struct pl_test {
+ int cycles;
+ uint16_t base_seq;
+ uint16_t max_seq;
+ uint32_t packets;
+
+ uint32_t expected;
+ int loss;
+};
+
+static const struct pl_test pl_test_dat[] = {
+ /* basic.. just one package */
+ { .cycles = 0, .base_seq = 0, .max_seq = 0, .packets = 1, .expected = 1, .loss = 0},
+ /* some packages and a bit of loss */
+ { .cycles = 0, .base_seq = 0, .max_seq = 100, .packets = 100, .expected = 101, .loss = 1},
+ /* wrap around */
+ { .cycles = 1<<16, .base_seq = 0xffff, .max_seq = 2, .packets = 4, .expected = 4, .loss = 0},
+ /* min loss */
+ { .cycles = 0, .base_seq = 0, .max_seq = 0, .packets = UINT_MAX, .expected = 1, .loss = INT_MIN },
+ /* max loss, with wrap around on expected max */
+ { .cycles = INT_MAX, .base_seq = 0, .max_seq = UINT16_MAX, .packets = 0, .expected = ((uint32_t)(INT_MAX) + UINT16_MAX + 1), .loss = INT_MAX },
+};
+
+static void test_packet_loss_calc(void)
+{
+ int i;
+ printf("Testing packet loss calculation.\n");
+
+ for (i = 0; i < ARRAY_SIZE(pl_test_dat); ++i) {
+ uint32_t expected;
+ int loss;
+ struct mgcp_rtp_state state;
+ struct mgcp_rtp_end rtp;
+ memset(&state, 0, sizeof(state));
+ memset(&rtp, 0, sizeof(rtp));
+
+ state.stats_initialized = 1;
+ state.stats_base_seq = pl_test_dat[i].base_seq;
+ state.stats_max_seq = pl_test_dat[i].max_seq;
+ state.stats_cycles = pl_test_dat[i].cycles;
+
+ rtp.packets = pl_test_dat[i].packets;
+ mgcp_state_calc_loss(&state, &rtp, &expected, &loss);
+
+ if (loss != pl_test_dat[i].loss || expected != pl_test_dat[i].expected) {
+ printf("FAIL: Wrong exp/loss at idx(%d) Loss(%d vs. %d) Exp(%u vs. %u)\n",
+ i, loss, pl_test_dat[i].loss,
+ expected, pl_test_dat[i].expected);
+ }
+ }
+}
+
+static void test_mgcp_stats(void)
+{
+ printf("Testing stat parsing\n");
+
+ uint32_t bps, bos, pr, _or, jitter;
+ struct msgb *msg;
+ int loss;
+ int rc;
+
+ msg = create_msg(DLCX_RET);
+ rc = mgcp_parse_stats(msg, &bps, &bos, &pr, &_or, &loss, &jitter);
+ printf("Parsing result: %d\n", rc);
+ if (bps != 0 || bos != 0 || pr != 0 || _or != 0 || loss != 0 || jitter != 0)
+ printf("FAIL: Parsing failed1.\n");
+ msgb_free(msg);
+
+ msg = create_msg("250 7 OK\r\nP: PS=10, OS=20, PR=30, OR=40, PL=-3, JI=40\r\n");
+ rc = mgcp_parse_stats(msg, &bps, &bos, &pr, &_or, &loss, &jitter);
+ printf("Parsing result: %d\n", rc);
+ if (bps != 10 || bos != 20 || pr != 30 || _or != 40 || loss != -3 || jitter != 40)
+ printf("FAIL: Parsing failed2.\n");
+ msgb_free(msg);
+}
+
+struct rtp_packet_info {
+ float txtime;
+ int len;
+ char *data;
+};
+
+struct rtp_packet_info test_rtp_packets1[] = {
+ /* RTP: SeqNo=0, TS=0 */
+ {0.000000, 20, "\x80\x62\x00\x00\x00\x00\x00\x00\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=1, TS=160 */
+ {0.020000, 20, "\x80\x62\x00\x01\x00\x00\x00\xA0\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=2, TS=320 */
+ {0.040000, 20, "\x80\x62\x00\x02\x00\x00\x01\x40\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* Repeat RTP timestamp: */
+ /* RTP: SeqNo=3, TS=320 */
+ {0.060000, 20, "\x80\x62\x00\x03\x00\x00\x01\x40\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=4, TS=480 */
+ {0.080000, 20, "\x80\x62\x00\x04\x00\x00\x01\xE0\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=5, TS=640 */
+ {0.100000, 20, "\x80\x62\x00\x05\x00\x00\x02\x80\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* Double skip RTP timestamp (delta = 2*160): */
+ /* RTP: SeqNo=6, TS=960 */
+ {0.120000, 20, "\x80\x62\x00\x06\x00\x00\x03\xC0\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=7, TS=1120 */
+ {0.140000, 20, "\x80\x62\x00\x07\x00\x00\x04\x60\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=8, TS=1280 */
+ {0.160000, 20, "\x80\x62\x00\x08\x00\x00\x05\x00\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* Non 20ms RTP timestamp (delta = 120): */
+ /* RTP: SeqNo=9, TS=1400 */
+ {0.180000, 20, "\x80\x62\x00\x09\x00\x00\x05\x78\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=10, TS=1560 */
+ {0.200000, 20, "\x80\x62\x00\x0A\x00\x00\x06\x18\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=11, TS=1720 */
+ {0.220000, 20, "\x80\x62\x00\x0B\x00\x00\x06\xB8\x11\x22\x33\x44"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* SSRC changed to 0x10203040, RTP timestamp jump */
+ /* RTP: SeqNo=12, TS=34688 */
+ {0.240000, 20, "\x80\x62\x00\x0C\x00\x00\x87\x80\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=13, TS=34848 */
+ {0.260000, 20, "\x80\x62\x00\x0D\x00\x00\x88\x20\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=14, TS=35008 */
+ {0.280000, 20, "\x80\x62\x00\x0E\x00\x00\x88\xC0\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* Non 20ms RTP timestamp (delta = 120): */
+ /* RTP: SeqNo=15, TS=35128 */
+ {0.300000, 20, "\x80\x62\x00\x0F\x00\x00\x89\x38\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=16, TS=35288 */
+ {0.320000, 20, "\x80\x62\x00\x10\x00\x00\x89\xD8\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=17, TS=35448 */
+ {0.340000, 20, "\x80\x62\x00\x11\x00\x00\x8A\x78\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x8A\xAB\xCD\xEF"},
+ /* SeqNo increment by 2, RTP timestamp delta = 320: */
+ /* RTP: SeqNo=19, TS=35768 */
+ {0.360000, 20, "\x80\x62\x00\x13\x00\x00\x8B\xB8\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=20, TS=35928 */
+ {0.380000, 20, "\x80\x62\x00\x14\x00\x00\x8C\x58\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=21, TS=36088 */
+ {0.380000, 20, "\x80\x62\x00\x15\x00\x00\x8C\xF8\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* Repeat last packet */
+ /* RTP: SeqNo=21, TS=36088 */
+ {0.400000, 20, "\x80\x62\x00\x15\x00\x00\x8C\xF8\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=22, TS=36248 */
+ {0.420000, 20, "\x80\x62\x00\x16\x00\x00\x8D\x98\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=23, TS=36408 */
+ {0.440000, 20, "\x80\x62\x00\x17\x00\x00\x8E\x38\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* Don't increment SeqNo but increment timestamp by 160 */
+ /* RTP: SeqNo=23, TS=36568 */
+ {0.460000, 20, "\x80\x62\x00\x17\x00\x00\x8E\xD8\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=24, TS=36728 */
+ {0.480000, 20, "\x80\x62\x00\x18\x00\x00\x8F\x78\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=25, TS=36888 */
+ {0.500000, 20, "\x80\x62\x00\x19\x00\x00\x90\x18\x10\x20\x30\x40"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* SSRC changed to 0x50607080, RTP timestamp jump, Delay of 1.5s,
+ * SeqNo jump */
+ /* RTP: SeqNo=1000, TS=160000 */
+ {2.000000, 20, "\x80\x62\x03\xE8\x00\x02\x71\x00\x50\x60\x70\x80"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=1001, TS=160160 */
+ {2.020000, 20, "\x80\x62\x03\xE9\x00\x02\x71\xA0\x50\x60\x70\x80"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+ /* RTP: SeqNo=1002, TS=160320 */
+ {2.040000, 20, "\x80\x62\x03\xEA\x00\x02\x72\x40\x50\x60\x70\x80"
+ "\x01\x23\x45\x67\x89\xAB\xCD\xEF"},
+};
+
+void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *state,
+ struct mgcp_rtp_end *rtp_end, struct sockaddr_in *addr,
+ char *data, int len);
+
+static void test_packet_error_detection(int patch_ssrc, int patch_ts)
+{
+ int i;
+
+ struct mgcp_trunk_config trunk;
+ struct mgcp_endpoint endp;
+ struct mgcp_rtp_state state;
+ struct mgcp_rtp_end *rtp = &endp.net_end;
+ struct sockaddr_in addr = {0};
+ char buffer[4096];
+ uint32_t last_ssrc = 0;
+ uint32_t last_timestamp = 0;
+ uint32_t last_seqno = 0;
+ int last_in_ts_err_cnt = 0;
+ int last_out_ts_err_cnt = 0;
+
+ printf("Testing packet error detection%s%s.\n",
+ patch_ssrc ? ", patch SSRC" : "",
+ patch_ts ? ", patch timestamps" : "");
+
+ memset(&trunk, 0, sizeof(trunk));
+ memset(&endp, 0, sizeof(endp));
+ memset(&state, 0, sizeof(state));
+
+ trunk.number_endpoints = 1;
+ trunk.endpoints = &endp;
+ trunk.force_constant_ssrc = patch_ssrc;
+ trunk.force_aligned_timing = patch_ts;
+
+ endp.tcfg = &trunk;
+
+ mgcp_initialize_endp(&endp);
+
+ rtp->codec.payload_type = 98;
+
+ for (i = 0; i < ARRAY_SIZE(test_rtp_packets1); ++i) {
+ struct rtp_packet_info *info = test_rtp_packets1 + i;
+
+ force_monotonic_time_us = round(1000000.0 * info->txtime);
+
+ OSMO_ASSERT(info->len <= sizeof(buffer));
+ OSMO_ASSERT(info->len >= 0);
+ memmove(buffer, info->data, info->len);
+
+ mgcp_rtp_end_config(&endp, 1, rtp);
+
+ mgcp_patch_and_count(&endp, &state, rtp, &addr,
+ buffer, info->len);
+
+ if (state.out_stream.ssrc != last_ssrc) {
+ printf("Output SSRC changed to %08x\n",
+ state.out_stream.ssrc);
+ last_ssrc = state.out_stream.ssrc;
+ }
+
+ printf("In TS: %d, dTS: %d, Seq: %d\n",
+ state.in_stream.last_timestamp,
+ state.in_stream.last_tsdelta,
+ state.in_stream.last_seq);
+
+ printf("Out TS change: %d, dTS: %d, Seq change: %d, "
+ "TS Err change: in %+d, out %+d\n",
+ state.out_stream.last_timestamp - last_timestamp,
+ state.out_stream.last_tsdelta,
+ state.out_stream.last_seq - last_seqno,
+ state.in_stream.err_ts_counter - last_in_ts_err_cnt,
+ state.out_stream.err_ts_counter - last_out_ts_err_cnt);
+
+ printf("Stats: Jitter = %u, Transit = %d\n",
+ mgcp_state_calc_jitter(&state), state.stats_transit);
+
+ last_in_ts_err_cnt = state.in_stream.err_ts_counter;
+ last_out_ts_err_cnt = state.out_stream.err_ts_counter;
+ last_timestamp = state.out_stream.last_timestamp;
+ last_seqno = state.out_stream.last_seq;
+ }
+
+ force_monotonic_time_us = -1;
+}
+
+static void test_multilple_codec(void)
+{
+ struct mgcp_config *cfg;
+ struct mgcp_endpoint *endp;
+ struct msgb *inp, *resp;
+ struct in_addr addr;
+
+ printf("Testing multiple payload types\n");
+
+ cfg = mgcp_config_alloc();
+ cfg->trunk.number_endpoints = 64;
+ mgcp_endpoints_allocate(&cfg->trunk);
+ cfg->policy_cb = mgcp_test_policy_cb;
+ mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1));
+
+ /* Allocate endpoint 1@mgw with two codecs */
+ last_endpoint = -1;
+ inp = create_msg(CRCX_MULT_1);
+ resp = mgcp_handle_message(cfg, inp);
+ msgb_free(inp);
+ msgb_free(resp);
+
+ OSMO_ASSERT(last_endpoint == 1);
+ endp = &cfg->trunk.endpoints[last_endpoint];
+ OSMO_ASSERT(endp->net_end.codec.payload_type == 18);
+ OSMO_ASSERT(endp->net_end.alt_codec.payload_type == 97);
+
+ /* Allocate 2@mgw with three codecs, last one ignored */
+ last_endpoint = -1;
+ inp = create_msg(CRCX_MULT_2);
+ resp = mgcp_handle_message(cfg, inp);
+ msgb_free(inp);
+ msgb_free(resp);
+
+ OSMO_ASSERT(last_endpoint == 2);
+ endp = &cfg->trunk.endpoints[last_endpoint];
+ OSMO_ASSERT(endp->net_end.codec.payload_type == 18);
+ OSMO_ASSERT(endp->net_end.alt_codec.payload_type == 97);
+
+ /* Allocate 3@mgw with no codecs, check for PT == -1 */
+ last_endpoint = -1;
+ inp = create_msg(CRCX_MULT_3);
+ resp = mgcp_handle_message(cfg, inp);
+ msgb_free(inp);
+ msgb_free(resp);
+
+ OSMO_ASSERT(last_endpoint == 3);
+ endp = &cfg->trunk.endpoints[last_endpoint];
+ OSMO_ASSERT(endp->net_end.codec.payload_type == -1);
+ OSMO_ASSERT(endp->net_end.alt_codec.payload_type == -1);
+
+ /* Allocate 4@mgw with a single codec */
+ last_endpoint = -1;
+ inp = create_msg(CRCX_MULT_4);
+ resp = mgcp_handle_message(cfg, inp);
+ msgb_free(inp);
+ msgb_free(resp);
+
+ OSMO_ASSERT(last_endpoint == 4);
+ endp = &cfg->trunk.endpoints[last_endpoint];
+ OSMO_ASSERT(endp->net_end.codec.payload_type == 18);
+ OSMO_ASSERT(endp->net_end.alt_codec.payload_type == -1);
+
+ /* Allocate 5@mgw at select GSM.. */
+ last_endpoint = -1;
+ inp = create_msg(CRCX_MULT_GSM_EXACT);
+ talloc_free(cfg->trunk.audio_name);
+ cfg->trunk.audio_name = "GSM/8000";
+ cfg->trunk.no_audio_transcoding = 1;
+ resp = mgcp_handle_message(cfg, inp);
+ msgb_free(inp);
+ msgb_free(resp);
+
+ OSMO_ASSERT(last_endpoint == 5);
+ endp = &cfg->trunk.endpoints[last_endpoint];
+ OSMO_ASSERT(endp->net_end.codec.payload_type == 3);
+ OSMO_ASSERT(endp->net_end.alt_codec.payload_type == -1);
+
+ inp = create_msg(MDCX_NAT_DUMMY);
+ last_endpoint = -1;
+ resp = mgcp_handle_message(cfg, inp);
+ msgb_free(inp);
+ msgb_free(resp);
+ OSMO_ASSERT(last_endpoint == 5);
+ endp = &cfg->trunk.endpoints[last_endpoint];
+ OSMO_ASSERT(endp->net_end.codec.payload_type == 3);
+ OSMO_ASSERT(endp->net_end.alt_codec.payload_type == -1);
+ OSMO_ASSERT(endp->net_end.rtp_port == htons(16434));
+ memset(&addr, 0, sizeof(addr));
+ inet_aton("8.8.8.8", &addr);
+ OSMO_ASSERT(endp->net_end.addr.s_addr == addr.s_addr);
+
+ /* Check what happens without that flag */
+
+ /* Free the previous endpoint and the data ... */
+ mgcp_release_endp(endp);
+ talloc_free(endp->last_response);
+ talloc_free(endp->last_trans);
+ endp->last_response = endp->last_trans = NULL;
+
+ last_endpoint = -1;
+ inp = create_msg(CRCX_MULT_GSM_EXACT);
+ cfg->trunk.no_audio_transcoding = 0;
+ resp = mgcp_handle_message(cfg, inp);
+ msgb_free(inp);
+ msgb_free(resp);
+
+ OSMO_ASSERT(last_endpoint == 5);
+ endp = &cfg->trunk.endpoints[last_endpoint];
+ OSMO_ASSERT(endp->net_end.codec.payload_type == 255);
+ OSMO_ASSERT(endp->net_end.alt_codec.payload_type == 0);
+
+ talloc_free(cfg);
+}
+
+static void test_no_cycle(void)
+{
+ struct mgcp_config *cfg;
+ struct mgcp_endpoint *endp;
+
+ printf("Testing no sequence flow on initial packet\n");
+
+ cfg = mgcp_config_alloc();
+ cfg->trunk.number_endpoints = 64;
+ mgcp_endpoints_allocate(&cfg->trunk);
+
+ endp = &cfg->trunk.endpoints[1];
+ OSMO_ASSERT(endp->net_state.stats_initialized == 0);
+
+ mgcp_rtp_annex_count(endp, &endp->net_state, 0, 0, 2342);
+ OSMO_ASSERT(endp->net_state.stats_initialized == 1);
+ OSMO_ASSERT(endp->net_state.stats_cycles == 0);
+ OSMO_ASSERT(endp->net_state.stats_max_seq == 0);
+
+ mgcp_rtp_annex_count(endp, &endp->net_state, 1, 0, 2342);
+ OSMO_ASSERT(endp->net_state.stats_initialized == 1);
+ OSMO_ASSERT(endp->net_state.stats_cycles == 0);
+ OSMO_ASSERT(endp->net_state.stats_max_seq == 1);
+
+ /* now jump.. */
+ mgcp_rtp_annex_count(endp, &endp->net_state, UINT16_MAX, 0, 2342);
+ OSMO_ASSERT(endp->net_state.stats_initialized == 1);
+ OSMO_ASSERT(endp->net_state.stats_cycles == 0);
+ OSMO_ASSERT(endp->net_state.stats_max_seq == UINT16_MAX);
+
+ /* and wrap */
+ mgcp_rtp_annex_count(endp, &endp->net_state, 0, 0, 2342);
+ OSMO_ASSERT(endp->net_state.stats_initialized == 1);
+ OSMO_ASSERT(endp->net_state.stats_cycles == UINT16_MAX + 1);
+ OSMO_ASSERT(endp->net_state.stats_max_seq == 0);
+
+ talloc_free(cfg);
+}
+
+static void test_no_name(void)
+{
+ struct mgcp_config *cfg;
+ struct mgcp_endpoint *endp;
+ struct msgb *inp, *msg;
+ int i;
+
+ printf("Testing no rtpmap name\n");
+ cfg = mgcp_config_alloc();
+
+ cfg->trunk.number_endpoints = 64;
+ cfg->trunk.audio_send_name = 0;
+ mgcp_endpoints_allocate(&cfg->trunk);
+
+ cfg->policy_cb = mgcp_test_policy_cb;
+
+ mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1));
+
+ /* reset endpoints */
+ for (i = 0; i < cfg->trunk.number_endpoints; i++) {
+ endp = &cfg->trunk.endpoints[i];
+ endp->net_end.codec.payload_type = PTYPE_NONE;
+ endp->net_end.packet_duration_ms = -1;
+
+ OSMO_ASSERT(endp->conn_mode == MGCP_CONN_NONE);
+ endp->conn_mode |= CONN_UNMODIFIED;
+ }
+
+ inp = create_msg(CRCX);
+ msg = mgcp_handle_message(cfg, inp);
+ if (strcmp((char *) msg->data, CRCX_RET_NO_RTPMAP) != 0)
+ printf("FAILED: there should not be a RTPMAP: %s\n",
+ (char *) msg->data);
+ msgb_free(inp);
+ msgb_free(msg);
+
+ mgcp_release_endp(&cfg->trunk.endpoints[1]);
+ talloc_free(cfg);
+}
+
+static void test_osmux_cid(void)
+{
+ int id, i;
+
+ OSMO_ASSERT(osmux_used_cid() == 0);
+ id = osmux_get_cid();
+ OSMO_ASSERT(id == 0);
+ OSMO_ASSERT(osmux_used_cid() == 1);
+ osmux_put_cid(id);
+ OSMO_ASSERT(osmux_used_cid() == 0);
+
+ for (i = 0; i < 256; ++i) {
+ id = osmux_get_cid();
+ OSMO_ASSERT(id == i);
+ OSMO_ASSERT(osmux_used_cid() == i + 1);
+ }
+
+ id = osmux_get_cid();
+ OSMO_ASSERT(id == -1);
+
+ for (i = 0; i < 256; ++i)
+ osmux_put_cid(i);
+ OSMO_ASSERT(osmux_used_cid() == 0);
+}
+
+int main(int argc, char **argv)
+{
+ msgb_talloc_ctx_init(NULL, 0);
+ osmo_init_logging(&log_info);
+
+ test_strline();
+ test_values();
+ test_messages();
+ test_retransmission();
+ test_packet_loss_calc();
+ test_rqnt_cb();
+ test_mgcp_stats();
+ test_packet_error_detection(1, 0);
+ test_packet_error_detection(0, 0);
+ test_packet_error_detection(0, 1);
+ test_packet_error_detection(1, 1);
+ test_multilple_codec();
+ test_no_cycle();
+ test_no_name();
+ test_osmux_cid();
+
+ printf("Done\n");
+ return EXIT_SUCCESS;
+}
diff --git a/tests/mgcp/mgcp_test.ok b/tests/mgcp/mgcp_test.ok
new file mode 100644
index 000000000..4e27282ee
--- /dev/null
+++ b/tests/mgcp/mgcp_test.ok
@@ -0,0 +1,480 @@
+line: 'one CR'
+line: 'two CR'
+line: ''
+line: 'one CRLF'
+line: 'two CRLF'
+line: ''
+line: 'one LF'
+line: 'two LF'
+line: ''
+line: 'mixed (4 lines)'
+line: ''
+line: ''
+line: ''
+Testing AUEP1
+Testing AUEP2
+Testing MDCX1
+Testing MDCX2
+Testing CRCX
+Dummy packets: 1
+Detected packet duration: 40
+Requested packetetization period: 20-20
+Connection mode: 1: RECV
+Testing MDCX3
+Dummy packets: 1
+Packet duration not set
+Requested packetization period not set
+Connection mode not set
+Testing MDCX4
+Dummy packets: 1
+Detected packet duration: 40
+Requested packetetization period: 20-20
+Connection mode: 3: SEND RECV
+Testing MDCX4_PT1
+Dummy packets: 1
+Detected packet duration: 40
+Requested packetetization period: 20-40
+Connection mode: 3: SEND RECV
+Testing MDCX4_PT2
+Dummy packets: 1
+Detected packet duration: 40
+Requested packetetization period: 20-20
+Connection mode: 3: SEND RECV
+Testing MDCX4_PT3
+Dummy packets: 1
+Detected packet duration: 40
+Requested packetization period not set
+Connection mode: 3: SEND RECV
+Testing MDCX4_SO
+Detected packet duration: 40
+Requested packetetization period: 20-20
+Connection mode: 2: SEND
+Testing MDCX4_RO
+Dummy packets: 1
+Packet duration not set
+Requested packetetization period: 20-20
+Connection mode: 1: RECV
+Testing DLCX
+Detected packet duration: 20
+Requested packetization period not set
+Connection mode: 0: NONE
+Testing CRCX_ZYN
+Dummy packets: 1
+Packet duration not set
+Requested packetization period not set
+Connection mode: 1: RECV
+Testing EMPTY
+Testing SHORT1
+Testing SHORT2
+Testing SHORT3
+Testing SHORT4
+Testing RQNT1
+Testing RQNT2
+Testing DLCX
+Detected packet duration: 20
+Requested packetization period not set
+Connection mode: 0: NONE
+Testing CRCX
+Dummy packets: 1
+Detected packet duration: 40
+Requested packetetization period: 20-20
+Connection mode: 1: RECV
+Testing MDCX3
+Dummy packets: 1
+Packet duration not set
+Requested packetization period not set
+Connection mode not set
+Testing DLCX
+Detected packet duration: 20
+Requested packetization period not set
+Connection mode: 0: NONE
+Testing CRCX
+Re-transmitting CRCX
+Testing RQNT1
+Re-transmitting RQNT1
+Testing RQNT2
+Re-transmitting RQNT2
+Testing MDCX3
+Re-transmitting MDCX3
+Testing DLCX
+Re-transmitting DLCX
+Testing packet loss calculation.
+Testing stat parsing
+Parsing result: 0
+Parsing result: 0
+Testing packet error detection, patch SSRC.
+Output SSRC changed to 11223344
+In TS: 0, dTS: 0, Seq: 0
+Out TS change: 0, dTS: 0, Seq change: 0, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 160, dTS: 160, Seq: 1
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 320, dTS: 160, Seq: 2
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 320, dTS: 160, Seq: 3
+Out TS change: 0, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 10, Transit = 160
+In TS: 480, dTS: 160, Seq: 4
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 9, Transit = 160
+In TS: 640, dTS: 160, Seq: 5
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 8, Transit = 160
+In TS: 960, dTS: 320, Seq: 6
+Out TS change: 320, dTS: 320, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 18, Transit = 0
+In TS: 1120, dTS: 160, Seq: 7
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 17, Transit = 0
+In TS: 1280, dTS: 160, Seq: 8
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 16, Transit = 0
+In TS: 1400, dTS: 120, Seq: 9
+Out TS change: 120, dTS: 120, Seq change: 1, TS Err change: in +1, out +1
+Stats: Jitter = 17, Transit = 40
+In TS: 1560, dTS: 160, Seq: 10
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 16, Transit = 40
+In TS: 1720, dTS: 160, Seq: 11
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 15, Transit = 40
+In TS: 34688, dTS: 0, Seq: 12
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 34848, dTS: 160, Seq: 13
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 35008, dTS: 160, Seq: 14
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 35128, dTS: 120, Seq: 15
+Out TS change: 120, dTS: 120, Seq change: 1, TS Err change: in +1, out +1
+Stats: Jitter = 2, Transit = -32728
+In TS: 35288, dTS: 160, Seq: 16
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 2, Transit = -32728
+In TS: 35448, dTS: 160, Seq: 17
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 2, Transit = -32728
+In TS: 35768, dTS: 160, Seq: 19
+Out TS change: 320, dTS: 160, Seq change: 2, TS Err change: in +0, out +0
+Stats: Jitter = 12, Transit = -32888
+In TS: 35928, dTS: 160, Seq: 20
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 11, Transit = -32888
+In TS: 36088, dTS: 160, Seq: 21
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 20, Transit = -33048
+In TS: 36088, dTS: 160, Seq: 21
+Out TS change: 0, dTS: 160, Seq change: 0, TS Err change: in +0, out +0
+Stats: Jitter = 29, Transit = -32888
+In TS: 36248, dTS: 160, Seq: 22
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 27, Transit = -32888
+In TS: 36408, dTS: 160, Seq: 23
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 25, Transit = -32888
+In TS: 36568, dTS: 160, Seq: 23
+Out TS change: 160, dTS: 160, Seq change: 0, TS Err change: in +1, out +1
+Stats: Jitter = 24, Transit = -32888
+In TS: 36728, dTS: 160, Seq: 24
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 22, Transit = -32888
+In TS: 36888, dTS: 160, Seq: 25
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 21, Transit = -32888
+In TS: 160000, dTS: 0, Seq: 1000
+Out TS change: 12000, dTS: 12000, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+In TS: 160160, dTS: 160, Seq: 1001
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+In TS: 160320, dTS: 160, Seq: 1002
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+Testing packet error detection.
+Output SSRC changed to 11223344
+In TS: 0, dTS: 0, Seq: 0
+Out TS change: 0, dTS: 0, Seq change: 0, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 160, dTS: 160, Seq: 1
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 320, dTS: 160, Seq: 2
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 320, dTS: 160, Seq: 3
+Out TS change: 0, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 10, Transit = 160
+In TS: 480, dTS: 160, Seq: 4
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 9, Transit = 160
+In TS: 640, dTS: 160, Seq: 5
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 8, Transit = 160
+In TS: 960, dTS: 320, Seq: 6
+Out TS change: 320, dTS: 320, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 18, Transit = 0
+In TS: 1120, dTS: 160, Seq: 7
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 17, Transit = 0
+In TS: 1280, dTS: 160, Seq: 8
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 16, Transit = 0
+In TS: 1400, dTS: 120, Seq: 9
+Out TS change: 120, dTS: 120, Seq change: 1, TS Err change: in +1, out +1
+Stats: Jitter = 17, Transit = 40
+In TS: 1560, dTS: 160, Seq: 10
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 16, Transit = 40
+In TS: 1720, dTS: 160, Seq: 11
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 15, Transit = 40
+Output SSRC changed to 10203040
+In TS: 34688, dTS: 0, Seq: 12
+Out TS change: 32968, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 34848, dTS: 160, Seq: 13
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 35008, dTS: 160, Seq: 14
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 35128, dTS: 120, Seq: 15
+Out TS change: 120, dTS: 120, Seq change: 1, TS Err change: in +1, out +1
+Stats: Jitter = 2, Transit = -32728
+In TS: 35288, dTS: 160, Seq: 16
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 2, Transit = -32728
+In TS: 35448, dTS: 160, Seq: 17
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 2, Transit = -32728
+In TS: 35768, dTS: 160, Seq: 19
+Out TS change: 320, dTS: 160, Seq change: 2, TS Err change: in +0, out +0
+Stats: Jitter = 12, Transit = -32888
+In TS: 35928, dTS: 160, Seq: 20
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 11, Transit = -32888
+In TS: 36088, dTS: 160, Seq: 21
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 20, Transit = -33048
+In TS: 36088, dTS: 160, Seq: 21
+Out TS change: 0, dTS: 160, Seq change: 0, TS Err change: in +0, out +0
+Stats: Jitter = 29, Transit = -32888
+In TS: 36248, dTS: 160, Seq: 22
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 27, Transit = -32888
+In TS: 36408, dTS: 160, Seq: 23
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 25, Transit = -32888
+In TS: 36568, dTS: 160, Seq: 23
+Out TS change: 160, dTS: 160, Seq change: 0, TS Err change: in +1, out +1
+Stats: Jitter = 24, Transit = -32888
+In TS: 36728, dTS: 160, Seq: 24
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 22, Transit = -32888
+In TS: 36888, dTS: 160, Seq: 25
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 21, Transit = -32888
+Output SSRC changed to 50607080
+In TS: 160000, dTS: 0, Seq: 1000
+Out TS change: 123112, dTS: 160, Seq change: 975, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+In TS: 160160, dTS: 160, Seq: 1001
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+In TS: 160320, dTS: 160, Seq: 1002
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+Testing packet error detection, patch timestamps.
+Output SSRC changed to 11223344
+In TS: 0, dTS: 0, Seq: 0
+Out TS change: 0, dTS: 0, Seq change: 0, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 160, dTS: 160, Seq: 1
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 320, dTS: 160, Seq: 2
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 320, dTS: 160, Seq: 3
+Out TS change: 0, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 10, Transit = 160
+In TS: 480, dTS: 160, Seq: 4
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 9, Transit = 160
+In TS: 640, dTS: 160, Seq: 5
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 8, Transit = 160
+In TS: 960, dTS: 320, Seq: 6
+Out TS change: 320, dTS: 320, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 18, Transit = 0
+In TS: 1120, dTS: 160, Seq: 7
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 17, Transit = 0
+In TS: 1280, dTS: 160, Seq: 8
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 16, Transit = 0
+In TS: 1400, dTS: 120, Seq: 9
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +1, out +0
+Stats: Jitter = 17, Transit = 40
+In TS: 1560, dTS: 160, Seq: 10
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 16, Transit = 40
+In TS: 1720, dTS: 160, Seq: 11
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 15, Transit = 40
+Output SSRC changed to 10203040
+In TS: 34688, dTS: 0, Seq: 12
+Out TS change: 32968, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 34848, dTS: 160, Seq: 13
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 35008, dTS: 160, Seq: 14
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 35128, dTS: 120, Seq: 15
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +1, out +0
+Stats: Jitter = 2, Transit = -32728
+In TS: 35288, dTS: 160, Seq: 16
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 2, Transit = -32728
+In TS: 35448, dTS: 160, Seq: 17
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 2, Transit = -32728
+In TS: 35768, dTS: 160, Seq: 19
+Out TS change: 320, dTS: 160, Seq change: 2, TS Err change: in +0, out +0
+Stats: Jitter = 12, Transit = -32888
+In TS: 35928, dTS: 160, Seq: 20
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 11, Transit = -32888
+In TS: 36088, dTS: 160, Seq: 21
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 20, Transit = -33048
+In TS: 36088, dTS: 160, Seq: 21
+Out TS change: 0, dTS: 160, Seq change: 0, TS Err change: in +0, out +0
+Stats: Jitter = 29, Transit = -32888
+In TS: 36248, dTS: 160, Seq: 22
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 27, Transit = -32888
+In TS: 36408, dTS: 160, Seq: 23
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 25, Transit = -32888
+In TS: 36568, dTS: 160, Seq: 23
+Out TS change: 160, dTS: 160, Seq change: 0, TS Err change: in +1, out +1
+Stats: Jitter = 24, Transit = -32888
+In TS: 36728, dTS: 160, Seq: 24
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 22, Transit = -32888
+In TS: 36888, dTS: 160, Seq: 25
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 21, Transit = -32888
+Output SSRC changed to 50607080
+In TS: 160000, dTS: 0, Seq: 1000
+Out TS change: 123112, dTS: 160, Seq change: 975, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+In TS: 160160, dTS: 160, Seq: 1001
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+In TS: 160320, dTS: 160, Seq: 1002
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+Testing packet error detection, patch SSRC, patch timestamps.
+Output SSRC changed to 11223344
+In TS: 0, dTS: 0, Seq: 0
+Out TS change: 0, dTS: 0, Seq change: 0, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 160, dTS: 160, Seq: 1
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 320, dTS: 160, Seq: 2
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = 0
+In TS: 320, dTS: 160, Seq: 3
+Out TS change: 0, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 10, Transit = 160
+In TS: 480, dTS: 160, Seq: 4
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 9, Transit = 160
+In TS: 640, dTS: 160, Seq: 5
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 8, Transit = 160
+In TS: 960, dTS: 320, Seq: 6
+Out TS change: 320, dTS: 320, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 18, Transit = 0
+In TS: 1120, dTS: 160, Seq: 7
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 17, Transit = 0
+In TS: 1280, dTS: 160, Seq: 8
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 16, Transit = 0
+In TS: 1400, dTS: 120, Seq: 9
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +1, out +0
+Stats: Jitter = 17, Transit = 40
+In TS: 1560, dTS: 160, Seq: 10
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 16, Transit = 40
+In TS: 1720, dTS: 160, Seq: 11
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 15, Transit = 40
+In TS: 34688, dTS: 0, Seq: 12
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 34848, dTS: 160, Seq: 13
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 35008, dTS: 160, Seq: 14
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -32768
+In TS: 35128, dTS: 120, Seq: 15
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +1, out +0
+Stats: Jitter = 2, Transit = -32728
+In TS: 35288, dTS: 160, Seq: 16
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 2, Transit = -32728
+In TS: 35448, dTS: 160, Seq: 17
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 2, Transit = -32728
+In TS: 35768, dTS: 160, Seq: 19
+Out TS change: 320, dTS: 160, Seq change: 2, TS Err change: in +0, out +0
+Stats: Jitter = 12, Transit = -32888
+In TS: 35928, dTS: 160, Seq: 20
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 11, Transit = -32888
+In TS: 36088, dTS: 160, Seq: 21
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 20, Transit = -33048
+In TS: 36088, dTS: 160, Seq: 21
+Out TS change: 0, dTS: 160, Seq change: 0, TS Err change: in +0, out +0
+Stats: Jitter = 29, Transit = -32888
+In TS: 36248, dTS: 160, Seq: 22
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 27, Transit = -32888
+In TS: 36408, dTS: 160, Seq: 23
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 25, Transit = -32888
+In TS: 36568, dTS: 160, Seq: 23
+Out TS change: 160, dTS: 160, Seq change: 0, TS Err change: in +1, out +1
+Stats: Jitter = 24, Transit = -32888
+In TS: 36728, dTS: 160, Seq: 24
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 22, Transit = -32888
+In TS: 36888, dTS: 160, Seq: 25
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 21, Transit = -32888
+In TS: 160000, dTS: 0, Seq: 1000
+Out TS change: 12000, dTS: 12000, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+In TS: 160160, dTS: 160, Seq: 1001
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+In TS: 160320, dTS: 160, Seq: 1002
+Out TS change: 160, dTS: 160, Seq change: 1, TS Err change: in +0, out +0
+Stats: Jitter = 0, Transit = -144000
+Testing multiple payload types
+Testing no sequence flow on initial packet
+Testing no rtpmap name
+Done
diff --git a/tests/mgcp/mgcp_transcoding_test.c b/tests/mgcp/mgcp_transcoding_test.c
new file mode 100644
index 000000000..c5c0a0bab
--- /dev/null
+++ b/tests/mgcp/mgcp_transcoding_test.c
@@ -0,0 +1,654 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <err.h>
+#include <stdint.h>
+
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/application.h>
+
+#include <osmocom/netif/rtp.h>
+
+#include <openbsc/debug.h>
+#include <openbsc/gsm_data.h>
+#include <openbsc/mgcp.h>
+#include <openbsc/mgcp_internal.h>
+
+#include "bscconfig.h"
+#ifndef BUILD_MGCP_TRANSCODING
+#error "Requires MGCP transcoding enabled (see --enable-mgcp-transcoding)"
+#endif
+
+#include "openbsc/mgcp_transcode.h"
+
+uint8_t *audio_frame_l16[] = {
+};
+
+struct rtp_packets {
+ float t;
+ int len;
+ char *data;
+};
+
+struct rtp_packets audio_packets_l16[] = {
+ /* RTP: SeqNo=1, TS=160 */
+ {0.020000, 332,
+ "\x80\x0B\x00\x01\x00\x00\x00\xA0\x11\x22\x33\x44"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ "\x00\x00\x40\x13\x5A\x9E\x40\x13\x00\x00\xBF\xED\xA5\x62\xBF\xED"
+ },
+};
+
+struct rtp_packets audio_packets_gsm[] = {
+ /* RTP: SeqNo=1, TS=160 */
+ {0.020000, 45,
+ "\x80\x03\x00\x01\x00\x00\x00\xA0\x11\x22\x33\x44"
+ "\xD4\x7C\xE3\xE9\x62\x50\x39\xF0\xF8\xB4\x68\xEA\x6C\x0E\x81\x1B"
+ "\x56\x2A\xD5\xBC\x69\x9C\xD1\xF0\x66\x7A\xEC\x49\x7A\x33\x3D\x0A"
+ "\xDE"
+ },
+};
+
+struct rtp_packets audio_packets_gsm_invalid_size[] = {
+ /* RTP: SeqNo=1, TS=160 */
+ {0.020000, 41,
+ "\x80\x03\x00\x01\x00\x00\x00\xA0\x11\x22\x33\x44"
+ "\xD4\x7C\xE3\xE9\x62\x50\x39\xF0\xF8\xB4\x68\xEA\x6C\x0E\x81\x1B"
+ "\x56\x2A\xD5\xBC\x69\x9C\xD1\xF0\x66\x7A\xEC\x49\x7A\x33\x3D\x0A"
+ "\xDE"
+ },
+};
+
+struct rtp_packets audio_packets_gsm_invalid_data[] = {
+ /* RTP: SeqNo=1, TS=160 */
+ {0.020000, 45,
+ "\x80\x03\x00\x01\x00\x00\x00\xA0\x11\x22\x33\x44"
+ "\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE"
+ "\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE"
+ "\xEE"
+ },
+};
+
+struct rtp_packets audio_packets_gsm_invalid_ptype[] = {
+ /* RTP: SeqNo=1, TS=160 */
+ {0.020000, 45,
+ "\x80\x08\x00\x01\x00\x00\x00\xA0\x11\x22\x33\x44"
+ "\xD4\x7C\xE3\xE9\x62\x50\x39\xF0\xF8\xB4\x68\xEA\x6C\x0E\x81\x1B"
+ "\x56\x2A\xD5\xBC\x69\x9C\xD1\xF0\x66\x7A\xEC\x49\x7A\x33\x3D\x0A"
+ "\xDE"
+ },
+};
+
+struct rtp_packets audio_packets_g729[] = {
+ /* RTP: SeqNo=1, TS=160 */
+ {0.020000, 32,
+ "\x80\x12\x00\x01\x00\x00\x00\xA0\x11\x22\x33\x44"
+ "\xAF\xC2\x81\x40\x00\xFA\xCE\xA4\x21\x7C\xC5\xC3\x4F\xA5\x98\xF5"
+ "\xB2\x95\xC4\xAD"
+ },
+};
+
+struct rtp_packets audio_packets_pcma[] = {
+ /* RTP: SeqNo=1, TS=160 */
+ {0.020000, 172,
+ "\x80\x08\x00\x01\x00\x00\x00\xA0\x11\x22\x33\x44"
+ "\xD5\xA5\xA3\xA5\xD5\x25\x23\x25\xD5\xA5\xA3\xA5\xD5\x25\x23\x25"
+ "\xD5\xA5\xA3\xA5\xD5\x25\x23\x25\xD5\xA5\xA3\xA5\xD5\x25\x23\x25"
+ "\xD5\xA5\xA3\xA5\xD5\x25\x23\x25\xD5\xA5\xA3\xA5\xD5\x25\x23\x25"
+ "\xD5\xA5\xA3\xA5\xD5\x25\x23\x25\xD5\xA5\xA3\xA5\xD5\x25\x23\x25"
+ "\xD5\xA5\xA3\xA5\xD5\x25\x23\x25\xD5\xA5\xA3\xA5\xD5\x25\x23\x25"
+ "\xD5\xA5\xA3\xA5\xD5\x25\x23\x25\xD5\xA5\xA3\xA5\xD5\x25\x23\x25"
+ "\xD5\xA5\xA3\xA5\xD5\x25\x23\x25\xD5\xA5\xA3\xA5\xD5\x25\x23\x25"
+ "\xD5\xA5\xA3\xA5\xD5\x25\x23\x25\xD5\xA5\xA3\xA5\xD5\x25\x23\x25"
+ "\xD5\xA5\xA3\xA5\xD5\x25\x23\x25\xD5\xA5\xA3\xA5\xD5\x25\x23\x25"
+ "\xD5\xA5\xA3\xA5\xD5\x25\x23\x25\xD5\xA5\xA3\xA5\xD5\x25\x23\x25"
+ },
+ /* RTP: SeqNo=26527, TS=232640 */
+ {0.020000, 92,
+ "\x80\x08\x67\x9f\x00\x03\x8c\xc0\x04\xaa\x67\x9f\xd5\xd5\xd5\xd5"
+ "\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5"
+ "\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5"
+ "\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5\xd5"
+ "\xd5\xd5\xd5\xd5\xd5\xd5\x55\x55\xd5\xd5\x55\x55\xd5\xd5\x55\x55"
+ "\xd5\xd5\xd5\x55\x55\xd5\xd5\xd5\x55\x55\xd5\xd5"
+ },
+ /* RTP: SeqNo=26528, TS=232720 */
+ {0.020000, 92,
+ "\x80\x08\x67\xa0\x00\x03\x8d\x10\x04\xaa\x67\x9f\x55\xd5\xd5\x55"
+ "\xd5\x55\xd5\xd5\xd5\x55\xd5\x55\xd5\xd5\x55\xd5\x55\xd5\x55\xd5"
+ "\x55\x55\xd5\x55\xd5\xd5\x55\x55\x55\x55\x55\xd5\xd5\x55\xd5\xd5"
+ "\xd5\x55\xd5\xd5\xd5\x55\x54\x55\xd5\xd5\x55\xd5\xd5\xd5\xd5\x55"
+ "\x54\x55\xd5\x55\xd5\x55\x55\x55\x55\x55\xd5\xd5\xd5\xd5\xd5\xd4"
+ "\xd5\x54\x55\xd5\xd4\xd5\x54\xd5\x55\xd5\xd5\xd5"
+ },
+};
+
+
+
+static int audio_name_to_type(const char *name)
+{
+ if (!strcasecmp(name, "gsm"))
+ return 3;
+#ifdef HAVE_BCG729
+ else if (!strcasecmp(name, "g729"))
+ return 18;
+#endif
+ else if (!strcasecmp(name, "pcma"))
+ return 8;
+ else if (!strcasecmp(name, "l16"))
+ return 11;
+ return -1;
+}
+
+int mgcp_get_trans_frame_size(void *state_, int nsamples, int dst);
+
+static int given_configured_endpoint(int in_samples, int out_samples,
+ const char *srcfmt, const char *dstfmt,
+ void **out_ctx, struct mgcp_endpoint **out_endp)
+{
+ int rc;
+ struct mgcp_rtp_end *dst_end;
+ struct mgcp_rtp_end *src_end;
+ struct mgcp_config *cfg;
+ struct mgcp_trunk_config *tcfg;
+ struct mgcp_endpoint *endp;
+
+ cfg = mgcp_config_alloc();
+ tcfg = talloc_zero(cfg, struct mgcp_trunk_config);
+ endp = talloc_zero(tcfg, struct mgcp_endpoint);
+
+ cfg->setup_rtp_processing_cb = mgcp_transcoding_setup;
+ cfg->rtp_processing_cb = mgcp_transcoding_process_rtp;
+ cfg->get_net_downlink_format_cb = mgcp_transcoding_net_downlink_format;
+
+ tcfg->endpoints = endp;
+ tcfg->number_endpoints = 1;
+ tcfg->cfg = cfg;
+ endp->tcfg = tcfg;
+ endp->cfg = cfg;
+ mgcp_initialize_endp(endp);
+
+ dst_end = &endp->bts_end;
+ dst_end->codec.payload_type = audio_name_to_type(dstfmt);
+
+ src_end = &endp->net_end;
+ src_end->codec.payload_type = audio_name_to_type(srcfmt);
+
+ if (out_samples) {
+ dst_end->codec.frame_duration_den = dst_end->codec.rate;
+ dst_end->codec.frame_duration_num = out_samples;
+ dst_end->frames_per_packet = 1;
+ dst_end->force_output_ptime = 1;
+ }
+
+ rc = mgcp_transcoding_setup(endp, dst_end, src_end);
+ if (rc < 0) {
+ printf("setup failed: %s", strerror(-rc));
+ abort();
+ }
+
+ *out_ctx = cfg;
+ *out_endp = endp;
+ return 0;
+}
+
+
+static int transcode_test(const char *srcfmt, const char *dstfmt,
+ uint8_t *src_pkts, size_t src_pkt_size)
+{
+ char buf[4096] = {0x80, 0};
+ void *ctx;
+
+ struct mgcp_rtp_end *dst_end;
+ struct mgcp_process_rtp_state *state;
+ struct mgcp_endpoint *endp;
+ int in_size;
+ const int in_samples = 160;
+ int len, cont;
+
+ printf("== Transcoding test ==\n");
+ printf("converting %s -> %s\n", srcfmt, dstfmt);
+
+ given_configured_endpoint(in_samples, 0, srcfmt, dstfmt, &ctx, &endp);
+
+ dst_end = &endp->bts_end;
+ state = dst_end->rtp_process_data;
+ OSMO_ASSERT(state != NULL);
+
+ in_size = mgcp_transcoding_get_frame_size(state, in_samples, 0);
+ OSMO_ASSERT(sizeof(buf) >= in_size + 12);
+
+ memcpy(buf, src_pkts, src_pkt_size);
+
+ len = src_pkt_size;
+
+ cont = mgcp_transcoding_process_rtp(endp, dst_end,
+ buf, &len, sizeof(buf));
+ if (cont < 0) {
+ printf("Nothing encoded due: %s\n", strerror(-cont));
+ talloc_free(ctx);
+ return -1;
+ }
+
+ if (len < 24) {
+ printf("encoded: %s\n", osmo_hexdump((unsigned char *)buf, len));
+ } else {
+ const char *str = osmo_hexdump((unsigned char *)buf, len);
+ int i = 0;
+ const int prefix = 4;
+ const int cutlen = 48;
+ int nchars = 0;
+
+ printf("encoded:\n");
+ do {
+ nchars = printf("%*s%-.*s", prefix, "", cutlen, str + i);
+ i += nchars - prefix;
+ printf("\n");
+ } while (nchars - prefix >= cutlen);
+ }
+ printf("counted: %d\n", cont);
+ talloc_free(ctx);
+ return 0;
+}
+
+static void test_rtp_seq_state(void)
+{
+ char buf[4096];
+ int len;
+ int cont;
+ void *ctx;
+ struct mgcp_endpoint *endp;
+ struct mgcp_process_rtp_state *state;
+ struct rtp_hdr *hdr;
+ uint32_t ts_no;
+ uint16_t seq_no;
+
+ given_configured_endpoint(160, 0, "pcma", "l16", &ctx, &endp);
+ state = endp->bts_end.rtp_process_data;
+ OSMO_ASSERT(!state->is_running);
+ OSMO_ASSERT(state->next_seq == 0);
+ OSMO_ASSERT(state->next_time == 0);
+
+ /* initialize packet */
+ len = audio_packets_pcma[0].len;
+ memcpy(buf, audio_packets_pcma[0].data, len);
+ cont = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, len);
+ OSMO_ASSERT(cont >= 0);
+ OSMO_ASSERT(state->is_running);
+ OSMO_ASSERT(state->next_seq == 2);
+ OSMO_ASSERT(state->next_time == 240);
+
+ /* verify that the right timestamp was written */
+ OSMO_ASSERT(len == audio_packets_pcma[0].len);
+ hdr = (struct rtp_hdr *) &buf[0];
+
+ memcpy(&ts_no, &hdr->timestamp, sizeof(ts_no));
+ OSMO_ASSERT(htonl(ts_no) == 160);
+ memcpy(&seq_no, &hdr->sequence, sizeof(seq_no));
+ OSMO_ASSERT(htons(seq_no) == 1);
+ /* Check the right sequence number is written */
+ state->next_seq = 1234;
+ len = audio_packets_pcma[0].len;
+ memcpy(buf, audio_packets_pcma[0].data, len);
+ cont = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, len);
+ OSMO_ASSERT(cont >= 0);
+ OSMO_ASSERT(len == audio_packets_pcma[0].len);
+ hdr = (struct rtp_hdr *) &buf[0];
+
+ memcpy(&seq_no, &hdr->sequence, sizeof(seq_no));
+ OSMO_ASSERT(htons(seq_no) == 1234);
+
+ talloc_free(ctx);
+}
+
+static void test_transcode_result(void)
+{
+ char buf[4096];
+ int len, res;
+ void *ctx;
+ struct mgcp_endpoint *endp;
+ struct mgcp_process_rtp_state *state;
+
+ {
+ /* from GSM to PCMA and same ptime */
+ given_configured_endpoint(160, 0, "gsm", "pcma", &ctx, &endp);
+ state = endp->bts_end.rtp_process_data;
+
+ /* result */
+ len = audio_packets_gsm[0].len;
+ memcpy(buf, audio_packets_gsm[0].data, len);
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ OSMO_ASSERT(res == sizeof(struct rtp_hdr));
+ OSMO_ASSERT(state->sample_cnt == 0);
+
+ len = res;
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ OSMO_ASSERT(res == -ENOMSG);
+
+ talloc_free(ctx);
+ }
+
+ {
+ /* from GSM to PCMA and same ptime */
+ given_configured_endpoint(160, 160, "gsm", "pcma", &ctx, &endp);
+ state = endp->bts_end.rtp_process_data;
+
+ /* result */
+ len = audio_packets_gsm[0].len;
+ memcpy(buf, audio_packets_gsm[0].data, len);
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ OSMO_ASSERT(res == sizeof(struct rtp_hdr));
+ OSMO_ASSERT(state->sample_cnt == 0);
+
+ len = res;
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ OSMO_ASSERT(res == -EAGAIN);
+
+ talloc_free(ctx);
+ }
+
+ {
+ /* from PCMA to GSM and wrong different ptime */
+ given_configured_endpoint(80, 160, "pcma", "gsm", &ctx, &endp);
+ state = endp->bts_end.rtp_process_data;
+
+ /* Add the first sample */
+ len = audio_packets_pcma[1].len;
+ memcpy(buf, audio_packets_pcma[1].data, len);
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ OSMO_ASSERT(state->sample_cnt == 80);
+ OSMO_ASSERT(state->next_time == 232640);
+ OSMO_ASSERT(res < 0);
+
+ /* Add the second sample and it should be consumable */
+ len = audio_packets_pcma[2].len;
+ memcpy(buf, audio_packets_pcma[2].data, len);
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ OSMO_ASSERT(state->sample_cnt == 0);
+ OSMO_ASSERT(state->next_time == 232640 + 80 + 160);
+ OSMO_ASSERT(res == sizeof(struct rtp_hdr));
+
+ talloc_free(ctx);
+ }
+
+ {
+ /* from PCMA to GSM with a big time jump */
+ struct rtp_hdr *hdr;
+ uint32_t ts;
+
+ given_configured_endpoint(80, 160, "pcma", "gsm", &ctx, &endp);
+ state = endp->bts_end.rtp_process_data;
+
+ /* Add the first sample */
+ len = audio_packets_pcma[1].len;
+ memcpy(buf, audio_packets_pcma[1].data, len);
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ OSMO_ASSERT(state->sample_cnt == 80);
+ OSMO_ASSERT(state->next_time == 232640);
+ OSMO_ASSERT(state->next_seq == 26527);
+ OSMO_ASSERT(res < 0);
+
+ /* Add a skip to the packet to force a 'resync' */
+ len = audio_packets_pcma[2].len;
+ memcpy(buf, audio_packets_pcma[2].data, len);
+ hdr = (struct rtp_hdr *) &buf[0];
+ /* jump the time and add alignment error */
+ ts = ntohl(hdr->timestamp) + 123 * 80 + 2;
+ hdr->timestamp = htonl(ts);
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ OSMO_ASSERT(res < 0);
+ OSMO_ASSERT(state->sample_cnt == 80);
+ OSMO_ASSERT(state->next_time == ts);
+ OSMO_ASSERT(state->next_seq == 26527);
+ /* TODO: this can create alignment errors */
+
+
+ /* Now attempt to consume 160 samples */
+ len = audio_packets_pcma[2].len;
+ memcpy(buf, audio_packets_pcma[2].data, len);
+ hdr = (struct rtp_hdr *) &buf[0];
+ ts += 80;
+ hdr->timestamp = htonl(ts);
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ OSMO_ASSERT(res == 12);
+ OSMO_ASSERT(state->sample_cnt == 0);
+ OSMO_ASSERT(state->next_time == ts + 160);
+ OSMO_ASSERT(state->next_seq == 26528);
+
+ talloc_free(ctx);
+ }
+}
+
+static void test_transcode_change(void)
+{
+ char buf[4096] = {0x80, 0};
+ void *ctx;
+
+ struct mgcp_endpoint *endp;
+ struct mgcp_process_rtp_state *state;
+ struct rtp_hdr *hdr;
+
+ int len, res;
+
+ {
+ /* from GSM to PCMA and same ptime */
+ printf("Testing Initial L16->GSM, PCMA->GSM\n");
+ given_configured_endpoint(160, 0, "l16", "gsm", &ctx, &endp);
+ endp->net_end.alt_codec = endp->net_end.codec;
+ endp->net_end.alt_codec.payload_type = audio_name_to_type("pcma");
+ state = endp->bts_end.rtp_process_data;
+
+ /* initial transcoding work */
+ OSMO_ASSERT(state->src_fmt == AF_L16);
+ OSMO_ASSERT(state->dst_fmt == AF_GSM);
+ OSMO_ASSERT(endp->net_end.alt_codec.payload_type == 8);
+ OSMO_ASSERT(endp->net_end.codec.payload_type == 11);
+
+ /* result */
+ len = audio_packets_pcma[0].len;
+ memcpy(buf, audio_packets_pcma[0].data, len);
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ state = endp->bts_end.rtp_process_data;
+ OSMO_ASSERT(res == sizeof(struct rtp_hdr));
+ OSMO_ASSERT(state->sample_cnt == 0);
+ OSMO_ASSERT(state->src_fmt == AF_PCMA);
+ OSMO_ASSERT(state->dst_fmt == AF_GSM);
+ OSMO_ASSERT(endp->net_end.alt_codec.payload_type == 11);
+ OSMO_ASSERT(endp->net_end.codec.payload_type == 8);
+
+ len = res;
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ OSMO_ASSERT(res == -ENOMSG);
+ OSMO_ASSERT(state == endp->bts_end.rtp_process_data);
+
+
+ /* now check that comfort noise doesn't change anything */
+ len = audio_packets_pcma[1].len;
+ memcpy(buf, audio_packets_pcma[1].data, len);
+ hdr = (struct rtp_hdr *) buf;
+ hdr->payload_type = 12;
+ res = mgcp_transcoding_process_rtp(endp, &endp->bts_end, buf, &len, ARRAY_SIZE(buf));
+ OSMO_ASSERT(state == endp->bts_end.rtp_process_data);
+ OSMO_ASSERT(state->sample_cnt == 80);
+ OSMO_ASSERT(state->src_fmt == AF_PCMA);
+ OSMO_ASSERT(state->dst_fmt == AF_GSM);
+ OSMO_ASSERT(endp->net_end.alt_codec.payload_type == 11);
+ OSMO_ASSERT(endp->net_end.codec.payload_type == 8);
+
+ talloc_free(ctx);
+ }
+}
+
+static int test_repacking(int in_samples, int out_samples, int no_transcode)
+{
+ char buf[4096] = {0x80, 0};
+ int cc;
+ struct mgcp_endpoint *endp;
+ void *ctx;
+
+ struct mgcp_process_rtp_state *state;
+ int in_cnt;
+ int out_size;
+ int in_size;
+ uint32_t ts = 0;
+ uint16_t seq = 0;
+ const char *srcfmt = "pcma";
+ const char *dstfmt = no_transcode ? "pcma" : "l16";
+
+ printf("== Transcoding test ==\n");
+ printf("converting %s -> %s\n", srcfmt, dstfmt);
+
+ given_configured_endpoint(in_samples, out_samples, srcfmt, dstfmt, &ctx, &endp);
+
+ state = endp->bts_end.rtp_process_data;
+ OSMO_ASSERT(state != NULL);
+
+ in_size = mgcp_transcoding_get_frame_size(state, in_samples, 0);
+ OSMO_ASSERT(sizeof(buf) >= in_size + 12);
+
+ out_size = mgcp_transcoding_get_frame_size(state, -1, 1);
+ OSMO_ASSERT(sizeof(buf) >= out_size + 12);
+
+ buf[1] = endp->net_end.codec.payload_type;
+ *(uint16_t*)(buf+2) = htons(1);
+ *(uint32_t*)(buf+4) = htonl(0);
+ *(uint32_t*)(buf+8) = htonl(0xaabbccdd);
+
+ for (in_cnt = 0; in_cnt < 16; in_cnt++) {
+ int cont;
+ int len;
+
+ /* fake PCMA data */
+ printf("generating %d %s input samples\n", in_samples, srcfmt);
+ for (cc = 0; cc < in_samples; cc++)
+ buf[12+cc] = cc;
+
+ *(uint16_t*)(buf+2) = htonl(seq);
+ *(uint32_t*)(buf+4) = htonl(ts);
+
+ seq += 1;
+ ts += in_samples;
+
+ cc += 12; /* include RTP header */
+
+ len = cc;
+
+ do {
+ cont = mgcp_transcoding_process_rtp(endp, &endp->bts_end,
+ buf, &len, sizeof(buf));
+ if (cont == -EAGAIN) {
+ fprintf(stderr, "Got EAGAIN\n");
+ break;
+ }
+
+ if (cont < 0) {
+ printf("processing failed: %s", strerror(-cont));
+ abort();
+ }
+
+ len -= 12; /* ignore RTP header */
+
+ printf("got %d %s output frames (%d octets) count=%d\n",
+ len / out_size, dstfmt, len, cont);
+
+ len = cont;
+ } while (len > 0);
+ }
+
+ talloc_free(ctx);
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int rc;
+ osmo_init_logging(&log_info);
+
+ printf("=== Transcoding Good Cases ===\n");
+
+ transcode_test("l16", "l16",
+ (uint8_t *)audio_packets_l16[0].data,
+ audio_packets_l16[0].len);
+ transcode_test("l16", "gsm",
+ (uint8_t *)audio_packets_l16[0].data,
+ audio_packets_l16[0].len);
+ transcode_test("l16", "pcma",
+ (uint8_t *)audio_packets_l16[0].data,
+ audio_packets_l16[0].len);
+ transcode_test("gsm", "l16",
+ (uint8_t *)audio_packets_gsm[0].data,
+ audio_packets_gsm[0].len);
+ transcode_test("gsm", "gsm",
+ (uint8_t *)audio_packets_gsm[0].data,
+ audio_packets_gsm[0].len);
+ transcode_test("gsm", "pcma",
+ (uint8_t *)audio_packets_gsm[0].data,
+ audio_packets_gsm[0].len);
+ transcode_test("pcma", "l16",
+ (uint8_t *)audio_packets_pcma[0].data,
+ audio_packets_pcma[0].len);
+ transcode_test("pcma", "gsm",
+ (uint8_t *)audio_packets_pcma[0].data,
+ audio_packets_pcma[0].len);
+ transcode_test("pcma", "pcma",
+ (uint8_t *)audio_packets_pcma[0].data,
+ audio_packets_pcma[0].len);
+
+ printf("=== Transcoding Bad Cases ===\n");
+
+ printf("Invalid size:\n");
+ rc = transcode_test("gsm", "pcma",
+ (uint8_t *)audio_packets_gsm_invalid_size[0].data,
+ audio_packets_gsm_invalid_size[0].len);
+ OSMO_ASSERT(rc < 0);
+
+ printf("Invalid data:\n");
+ rc = transcode_test("gsm", "pcma",
+ (uint8_t *)audio_packets_gsm_invalid_data[0].data,
+ audio_packets_gsm_invalid_data[0].len);
+ OSMO_ASSERT(rc < 0);
+
+ printf("Invalid payload type:\n");
+ rc = transcode_test("gsm", "pcma",
+ (uint8_t *)audio_packets_gsm_invalid_ptype[0].data,
+ audio_packets_gsm_invalid_ptype[0].len);
+ OSMO_ASSERT(rc == 0);
+
+ printf("=== Repacking ===\n");
+
+ test_repacking(160, 160, 0);
+ test_repacking(160, 160, 1);
+ test_repacking(160, 80, 0);
+ test_repacking(160, 80, 1);
+ test_repacking(160, 320, 0);
+ test_repacking(160, 320, 1);
+ test_repacking(160, 240, 0);
+ test_repacking(160, 240, 1);
+ test_repacking(160, 100, 0);
+ test_repacking(160, 100, 1);
+ test_rtp_seq_state();
+ test_transcode_result();
+ test_transcode_change();
+
+ return 0;
+}
+
diff --git a/tests/mgcp/mgcp_transcoding_test.ok b/tests/mgcp/mgcp_transcoding_test.ok
new file mode 100644
index 000000000..387cfd275
--- /dev/null
+++ b/tests/mgcp/mgcp_transcoding_test.ok
@@ -0,0 +1,539 @@
+=== Transcoding Good Cases ===
+== Transcoding test ==
+converting l16 -> l16
+encoded:
+ 80 0b 00 01 00 00 00 a0 11 22 33 44 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed 00 00 40 13
+ 5a 9e 40 13 00 00 bf ed a5 62 bf ed
+counted: 0
+== Transcoding test ==
+converting l16 -> gsm
+encoded:
+ 80 0b 00 01 00 00 00 a0 11 22 33 44 d4 7c e3 e9
+ 62 50 39 f0 f8 b4 68 ea 6c 0e 81 1b 56 2a d5 bc
+ 69 9c d1 f0 66 7a ec 49 7a 33 3d 0a de
+counted: 12
+== Transcoding test ==
+converting l16 -> pcma
+encoded:
+ 80 0b 00 01 00 00 00 a0 11 22 33 44 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25
+counted: 12
+== Transcoding test ==
+converting gsm -> l16
+encoded:
+ 80 03 00 01 00 00 00 a0 11 22 33 44 00 00 54 00
+ 59 f0 34 20 c4 c8 b9 f8 e2 18 f1 e8 f2 28 f0 e0
+ 46 08 4f 80 2c a0 a9 c8 80 00 c0 58 3f 80 63 c0
+ 24 b8 fa b8 f6 88 0b a0 c8 70 a8 b0 c8 c0 3b a8
+ 66 a0 2e 38 d1 f8 98 98 aa 18 e8 30 26 a0 37 40
+ 37 e8 17 00 ee 50 b7 80 b1 88 de 28 18 40 45 b0
+ 4f 48 21 d8 df 78 ae 68 ab 98 d6 b8 18 18 48 90
+ 4e 70 27 40 e8 10 b5 b0 ac 80 d4 60 14 50 48 48
+ 50 10 2a 00 ec 08 ba 00 af 58 d1 c0 10 60 45 c8
+ 54 10 30 78 f1 a8 bb 18 ad 48 ce 30 0a e8 3f 30
+ 4f 10 32 18 f6 18 bf 20 ac 30 cd 80 0b d0 43 d8
+ 55 e0 34 a0 f5 78 bc 98 ad 98 cd c8 0a 80 40 58
+ 51 c0 35 40 f9 60 c1 68 ac c8 cb 38 08 00 40 98
+ 51 e0 34 d8 fa 28 c2 f0 ae 40 c7 70 02 d0 3c a8
+ 54 78 38 a0 fc 68 c2 08 ad 50 c7 78 01 60 39 c0
+ 51 38 3a e8 00 e8 c6 38 ab d8 c4 00 fe 08 39 18
+ 50 30 39 50 01 d8 ca 70 b1 80 c4 c8 fc 58 36 40
+ 51 d8 3b 08 02 80 c8 58 b0 60 c5 a8 fb d0 33 e8
+ 4e 80 3c e0 06 10 cb 90 ae 48 c2 60 f9 58 34 08
+ 4d a0 3a a8 06 48 cf 80 b4 60 c3 e8 f7 90 30 18
+ 4d a0 3b 98 07 90 cf 18 b4 68 c4 88
+counted: 12
+== Transcoding test ==
+converting gsm -> gsm
+encoded:
+ 80 03 00 01 00 00 00 a0 11 22 33 44 d4 7c e3 e9
+ 62 50 39 f0 f8 b4 68 ea 6c 0e 81 1b 56 2a d5 bc
+ 69 9c d1 f0 66 7a ec 49 7a 33 3d 0a de
+counted: 0
+== Transcoding test ==
+converting gsm -> pcma
+encoded:
+ 80 03 00 01 00 00 00 a0 11 22 33 44 d5 a0 a3 bf
+ 38 24 08 19 1e 1b a4 a6 b3 20 2a 3a ba ad b7 60
+ 17 92 3e 20 3e b8 ac b2 32 2c 20 02 b6 be be 82
+ 04 27 26 35 8d a4 a6 b5 35 21 20 31 8d a7 a6 b6
+ 02 27 21 30 81 a7 a1 b0 06 24 21 32 85 a4 a0 bd
+ 19 24 21 3d 90 ba a6 bc 16 25 21 3c 92 a5 a0 bf
+ 10 25 21 3c 90 a5 a1 bf 6f 3a 21 3f 95 a5 a1 bf
+ 62 3b 21 39 f3 bb a0 b9 79 3b 21 39 c3 b9 a1 b8
+ db 39 20 3b 4a b9 a1 b9 c8 3f 26 38 78 be a1 b8
+ f1 3e 26 38 65 bc a6 bb ed 3f 21 3b 6f bf a6 b8
+ ec 3d 27 3b 15 bd a6 b8 eb 3d 27 38
+counted: 12
+== Transcoding test ==
+converting pcma -> l16
+encoded:
+ 80 08 00 01 00 00 00 a0 11 22 33 44 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00 00 08 42 00
+ 5a 00 42 00 00 08 be 00 a6 00 be 00
+counted: 12
+== Transcoding test ==
+converting pcma -> gsm
+encoded:
+ 80 08 00 01 00 00 00 a0 11 22 33 44 d4 b9 f4 5d
+ d9 50 5a e1 a0 cd 76 ea 52 0e 87 53 ad d4 ea a2
+ 0a 63 ca e9 60 79 e2 2a 25 d2 c0 f3 39
+counted: 12
+== Transcoding test ==
+converting pcma -> pcma
+encoded:
+ 80 08 00 01 00 00 00 a0 11 22 33 44 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25 d5 a5 a3 a5
+ d5 25 23 25 d5 a5 a3 a5 d5 25 23 25
+counted: 0
+=== Transcoding Bad Cases ===
+Invalid size:
+== Transcoding test ==
+converting gsm -> pcma
+Nothing encoded due: No message of desired type
+Invalid data:
+== Transcoding test ==
+converting gsm -> pcma
+Nothing encoded due: No message of desired type
+Invalid payload type:
+== Transcoding test ==
+converting gsm -> pcma
+encoded:
+ 80 08 00 01 00 00 00 a0 11 22 33 44 d5 a0 a3 bf
+ 38 24 08 19 1e 1b a4 a6 b3 20 2a 3a ba ad b7 60
+ 17 92 3e 20 3e b8 ac b2 32 2c 20 02 b6 be be 82
+ 04 27 26 35 8d a4 a6 b5 35 21 20 31 8d a7 a6 b6
+ 02 27 21 30 81 a7 a1 b0 06 24 21 32 85 a4 a0 bd
+ 19 24 21 3d 90 ba a6 bc 16 25 21 3c 92 a5 a0 bf
+ 10 25 21 3c 90 a5 a1 bf 6f 3a 21 3f 95 a5 a1 bf
+ 62 3b 21 39 f3 bb a0 b9 79 3b 21 39 c3 b9 a1 b8
+ db 39 20 3b 4a b9 a1 b9 c8 3f 26 38 78 be a1 b8
+ f1 3e 26 38 65 bc a6 bb ed 3f 21 3b 6f bf a6 b8
+ ec 3d 27 3b 15 bd a6 b8 eb 3d 27 38
+counted: 12
+=== Repacking ===
+== Transcoding test ==
+converting pcma -> l16
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+generating 160 pcma input samples
+got 2 l16 output frames (320 octets) count=12
+== Transcoding test ==
+converting pcma -> pcma
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+generating 160 pcma input samples
+got 2 pcma output frames (160 octets) count=12
+== Transcoding test ==
+converting pcma -> l16
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+== Transcoding test ==
+converting pcma -> pcma
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+== Transcoding test ==
+converting pcma -> l16
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 l16 output frames (640 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 l16 output frames (640 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 l16 output frames (640 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 l16 output frames (640 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 l16 output frames (640 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 l16 output frames (640 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 l16 output frames (640 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 l16 output frames (640 octets) count=12
+== Transcoding test ==
+converting pcma -> pcma
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 pcma output frames (320 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 pcma output frames (320 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 pcma output frames (320 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 pcma output frames (320 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 pcma output frames (320 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 pcma output frames (320 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 pcma output frames (320 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 4 pcma output frames (320 octets) count=12
+== Transcoding test ==
+converting pcma -> l16
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 l16 output frames (480 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 l16 output frames (480 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 l16 output frames (480 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 l16 output frames (480 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 l16 output frames (480 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 l16 output frames (480 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 l16 output frames (480 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 l16 output frames (480 octets) count=12
+== Transcoding test ==
+converting pcma -> pcma
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 pcma output frames (240 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 pcma output frames (240 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 pcma output frames (240 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 pcma output frames (240 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 pcma output frames (240 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 pcma output frames (240 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 pcma output frames (240 octets) count=12
+generating 160 pcma input samples
+generating 160 pcma input samples
+got 3 pcma output frames (240 octets) count=12
+== Transcoding test ==
+converting pcma -> l16
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+generating 160 pcma input samples
+got 1 l16 output frames (160 octets) count=12
+got 1 l16 output frames (160 octets) count=12
+== Transcoding test ==
+converting pcma -> pcma
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+generating 160 pcma input samples
+got 1 pcma output frames (80 octets) count=12
+got 1 pcma output frames (80 octets) count=12
+Testing Initial L16->GSM, PCMA->GSM
diff --git a/tests/mm_auth/Makefile.am b/tests/mm_auth/Makefile.am
new file mode 100644
index 000000000..cb351988b
--- /dev/null
+++ b/tests/mm_auth/Makefile.am
@@ -0,0 +1,37 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBCRYPTO_CFLAGS) \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ mm_auth_test \
+ $(NULL)
+
+EXTRA_DIST = \
+ mm_auth_test.ok \
+ $(NULL)
+
+mm_auth_test_SOURCES = \
+ mm_auth_test.c \
+ $(NULL)
+
+mm_auth_test_LDFLAGS = \
+ -Wl,--wrap=db_get_authinfo_for_subscr \
+ -Wl,--wrap=db_get_lastauthtuple_for_subscr \
+ -Wl,--wrap=db_sync_lastauthtuple_for_subscr \
+ $(NULL)
+
+mm_auth_test_LDADD = \
+ $(top_builddir)/src/libmsc/libmsc.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(NULL)
diff --git a/tests/mm_auth/mm_auth_test.c b/tests/mm_auth/mm_auth_test.c
new file mode 100644
index 000000000..b8777a8c5
--- /dev/null
+++ b/tests/mm_auth/mm_auth_test.c
@@ -0,0 +1,340 @@
+#include <stdbool.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/core/logging.h>
+
+#include <openbsc/debug.h>
+#include <openbsc/gsm_data.h>
+#include <openbsc/gsm_subscriber.h>
+#include <openbsc/auth.h>
+
+#define min(A,B) ((A)>(B)? (B) : (A))
+
+static char *auth_tuple_str(struct gsm_auth_tuple *atuple)
+{
+ static char buf[256];
+ char *pos = buf;
+ int len = sizeof(buf);
+ int l;
+
+#define print2buf(FMT, args...) do {\
+ l = snprintf(pos, len, FMT, ## args); \
+ pos += l;\
+ len -= l;\
+ } while (0)
+
+ print2buf("gsm_auth_tuple {\n");
+ print2buf(" .use_count = %d\n", atuple->use_count);
+ print2buf(" .key_seq = %d\n", atuple->key_seq);
+ print2buf(" .rand = %s\n", osmo_hexdump(atuple->vec.rand, sizeof(atuple->vec.rand)));
+ print2buf(" .sres = %s\n", osmo_hexdump(atuple->vec.sres, sizeof(atuple->vec.sres)));
+ print2buf(" .kc = %s\n", osmo_hexdump(atuple->vec.kc, sizeof(atuple->vec.kc)));
+ print2buf("}\n");
+#undef print2buf
+
+ return buf;
+}
+
+static bool auth_tuple_is(struct gsm_auth_tuple *atuple,
+ const char *expect_str)
+{
+ int l, l1, l2;
+ int i;
+ char *tuple_str = auth_tuple_str(atuple);
+ bool same = (strcmp(expect_str, tuple_str) == 0);
+ if (!same) {
+ l1 = strlen(expect_str);
+ l2 = strlen(tuple_str);
+ printf("Expected %d:\n%s\nGot %d:\n%s\n",
+ l1, expect_str, l2, tuple_str);
+ l = min(l1, l2);
+ for (i = 0; i < l; i++) {
+ if (expect_str[i] != tuple_str[i]) {
+ printf("Difference at pos %d"
+ " (%c 0x%0x != %c 0x%0x)\n",
+ i, expect_str[i], expect_str[i],
+ tuple_str[i], tuple_str[i]);
+ break;
+ }
+ }
+ }
+ return same;
+}
+
+/* override, requires '-Wl,--wrap=db_get_authinfo_for_subscr' */
+int __real_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo,
+ struct gsm_subscriber *subscr);
+
+int test_get_authinfo_rc = 0;
+struct gsm_auth_info test_auth_info = {0};
+struct gsm_auth_info default_auth_info = {
+ .auth_algo = AUTH_ALGO_COMP128v1,
+ .a3a8_ki_len = 16,
+ .a3a8_ki = { 0 }
+};
+
+int __wrap_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo,
+ struct gsm_subscriber *subscr)
+{
+ *ainfo = test_auth_info;
+ printf("wrapped: db_get_authinfo_for_subscr(): rc = %d\n", test_get_authinfo_rc);
+ return test_get_authinfo_rc;
+}
+
+/* override, requires '-Wl,--wrap=db_get_lastauthtuple_for_subscr' */
+int __real_db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple,
+ struct gsm_subscriber *subscr);
+
+int test_get_lastauthtuple_rc = 0;
+struct gsm_auth_tuple test_last_auth_tuple = { 0 };
+struct gsm_auth_tuple default_auth_tuple = { 0 };
+
+int __wrap_db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple,
+ struct gsm_subscriber *subscr)
+{
+ *atuple = test_last_auth_tuple;
+ printf("wrapped: db_get_lastauthtuple_for_subscr(): rc = %d\n", test_get_lastauthtuple_rc);
+ return test_get_lastauthtuple_rc;
+}
+
+/* override, requires '-Wl,--wrap=db_sync_lastauthtuple_for_subscr' */
+int __real_db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple,
+ struct gsm_subscriber *subscr);
+int test_sync_lastauthtuple_rc = 0;
+int __wrap_db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple,
+ struct gsm_subscriber *subscr)
+{
+ test_last_auth_tuple = *atuple;
+ printf("wrapped: db_sync_lastauthtuple_for_subscr(): rc = %d\n", test_sync_lastauthtuple_rc);
+ return test_sync_lastauthtuple_rc;
+}
+
+int auth_get_tuple_for_subscr_verbose(struct gsm_auth_tuple *atuple,
+ struct gsm_subscriber *subscr,
+ int key_seq)
+{
+ int auth_action;
+ auth_action = auth_get_tuple_for_subscr(atuple, subscr, key_seq);
+ printf("auth_get_tuple_for_subscr(key_seq=%d) --> auth_action == %s\n",
+ key_seq, auth_action_str(auth_action));
+ return auth_action;
+}
+
+/* override libssl RAND_bytes() to get testable crypto results */
+int RAND_bytes(uint8_t *rand, int len)
+{
+ memset(rand, 23, len);
+ return 1;
+}
+
+static void test_error()
+{
+ int auth_action;
+
+ struct gsm_auth_tuple atuple = {0};
+ struct gsm_subscriber subscr = {0};
+ int key_seq = 0;
+
+ printf("\n* test_error()\n");
+
+ /* any error (except -ENOENT) */
+ test_get_authinfo_rc = -EIO;
+ auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
+ key_seq);
+ OSMO_ASSERT(auth_action == AUTH_ERROR);
+}
+
+static void test_auth_not_avail()
+{
+ int auth_action;
+
+ struct gsm_auth_tuple atuple = {0};
+ struct gsm_subscriber subscr = {0};
+ int key_seq = 0;
+
+ printf("\n* test_auth_not_avail()\n");
+
+ /* no entry */
+ test_get_authinfo_rc = -ENOENT;
+ auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
+ key_seq);
+ OSMO_ASSERT(auth_action == AUTH_NOT_AVAIL);
+}
+
+static void test_auth_then_ciph1()
+{
+ int auth_action;
+
+ struct gsm_auth_tuple atuple = {0};
+ struct gsm_subscriber subscr = {0};
+ int key_seq;
+
+ printf("\n* test_auth_then_ciph1()\n");
+
+ /* Ki entry, but no auth tuple negotiated yet */
+ test_auth_info = default_auth_info;
+ test_last_auth_tuple = default_auth_tuple;
+ test_get_authinfo_rc = 0;
+ test_get_lastauthtuple_rc = -ENOENT;
+ key_seq = 0;
+ auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
+ key_seq);
+ OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH);
+ OSMO_ASSERT(auth_tuple_is(&atuple,
+ "gsm_auth_tuple {\n"
+ " .use_count = 1\n"
+ " .key_seq = 0\n"
+ " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n"
+ " .sres = a1 ab c6 90 \n"
+ " .kc = 0f 27 ed f3 ac 97 ac 00 \n"
+ "}\n"
+ ));
+
+ /* With a different last saved key_seq stored in the out-arg of
+ * db_get_lastauthtuple_for_subscr() by coincidence, expect absolutely
+ * the same as above. */
+ test_auth_info = default_auth_info;
+ test_last_auth_tuple = default_auth_tuple;
+ test_last_auth_tuple.key_seq = 3;
+ test_get_authinfo_rc = 0;
+ test_get_lastauthtuple_rc = -ENOENT;
+ key_seq = 0;
+ auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
+ key_seq);
+ OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH);
+ OSMO_ASSERT(auth_tuple_is(&atuple,
+ "gsm_auth_tuple {\n"
+ " .use_count = 1\n"
+ " .key_seq = 0\n"
+ " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n"
+ " .sres = a1 ab c6 90 \n"
+ " .kc = 0f 27 ed f3 ac 97 ac 00 \n"
+ "}\n"
+ ));
+}
+
+static void test_auth_then_ciph2()
+{
+ int auth_action;
+
+ struct gsm_auth_tuple atuple = {0};
+ struct gsm_subscriber subscr = {0};
+ int key_seq;
+
+ printf("\n* test_auth_then_ciph2()\n");
+
+ /* Ki entry, auth tuple negotiated, but invalid incoming key_seq */
+ test_auth_info = default_auth_info;
+ test_last_auth_tuple = default_auth_tuple;
+ test_last_auth_tuple.key_seq = 2;
+ test_get_authinfo_rc = 0;
+ test_get_lastauthtuple_rc = 0;
+ key_seq = GSM_KEY_SEQ_INVAL;
+ auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
+ key_seq);
+ OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH);
+ OSMO_ASSERT(auth_tuple_is(&atuple,
+ "gsm_auth_tuple {\n"
+ " .use_count = 1\n"
+ " .key_seq = 3\n"
+ " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n"
+ " .sres = a1 ab c6 90 \n"
+ " .kc = 0f 27 ed f3 ac 97 ac 00 \n"
+ "}\n"
+ ));
+
+ /* Change the last saved key_seq, expect last_auth_tuple.key_seq + 1 */
+ test_auth_info = default_auth_info;
+ test_last_auth_tuple = default_auth_tuple;
+ test_last_auth_tuple.key_seq = 3;
+ test_get_authinfo_rc = 0;
+ test_get_lastauthtuple_rc = 0;
+ key_seq = GSM_KEY_SEQ_INVAL;
+ auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
+ key_seq);
+ OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH);
+ OSMO_ASSERT(auth_tuple_is(&atuple,
+ "gsm_auth_tuple {\n"
+ " .use_count = 1\n"
+ " .key_seq = 4\n"
+ " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n"
+ " .sres = a1 ab c6 90 \n"
+ " .kc = 0f 27 ed f3 ac 97 ac 00 \n"
+ "}\n"
+ ));
+}
+
+static void test_auth_reuse()
+{
+ int auth_action;
+ struct gsm_auth_tuple atuple = {0};
+ struct gsm_subscriber subscr = {0};
+ int key_seq;
+
+ printf("\n* test_auth_reuse()\n");
+
+ /* Ki entry, auth tuple negotiated, valid+matching incoming key_seq */
+ test_auth_info = default_auth_info;
+ test_last_auth_tuple = default_auth_tuple;
+ test_last_auth_tuple.key_seq = key_seq = 3;
+ test_last_auth_tuple.use_count = 1;
+ test_get_authinfo_rc = 0;
+ test_get_lastauthtuple_rc = 0;
+ auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
+ key_seq);
+ OSMO_ASSERT(auth_action == AUTH_DO_CIPH);
+ OSMO_ASSERT(auth_tuple_is(&atuple,
+ "gsm_auth_tuple {\n"
+ " .use_count = 2\n"
+ " .key_seq = 3\n"
+ " .rand = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n"
+ " .sres = 00 00 00 00 \n"
+ " .kc = 00 00 00 00 00 00 00 00 \n"
+ "}\n"
+ ));
+}
+
+static void test_auth_reuse_key_seq_mismatch()
+{
+ int auth_action;
+ struct gsm_auth_tuple atuple = {0};
+ struct gsm_subscriber subscr = {0};
+ int key_seq;
+
+ printf("\n* test_auth_reuse_key_seq_mismatch()\n");
+
+ /* Ki entry, auth tuple negotiated, valid+matching incoming key_seq */
+ test_auth_info = default_auth_info;
+ test_last_auth_tuple = default_auth_tuple;
+ test_last_auth_tuple.key_seq = 3;
+ key_seq = 4;
+ test_last_auth_tuple.use_count = 1;
+ test_get_authinfo_rc = 0;
+ test_get_lastauthtuple_rc = 0;
+ auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
+ key_seq);
+ OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH);
+ OSMO_ASSERT(auth_tuple_is(&atuple,
+ "gsm_auth_tuple {\n"
+ " .use_count = 1\n"
+ " .key_seq = 4\n"
+ " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n"
+ " .sres = a1 ab c6 90 \n"
+ " .kc = 0f 27 ed f3 ac 97 ac 00 \n"
+ "}\n"
+ ));
+}
+
+int main(void)
+{
+ osmo_init_logging(&log_info);
+ log_set_log_level(osmo_stderr_target, LOGL_INFO);
+
+ test_error();
+ test_auth_not_avail();
+ test_auth_then_ciph1();
+ test_auth_then_ciph2();
+ test_auth_reuse();
+ test_auth_reuse_key_seq_mismatch();
+ return 0;
+}
diff --git a/tests/mm_auth/mm_auth_test.ok b/tests/mm_auth/mm_auth_test.ok
new file mode 100644
index 000000000..6c49f97b7
--- /dev/null
+++ b/tests/mm_auth/mm_auth_test.ok
@@ -0,0 +1,40 @@
+
+* test_error()
+wrapped: db_get_authinfo_for_subscr(): rc = -5
+auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_ERROR
+
+* test_auth_not_avail()
+wrapped: db_get_authinfo_for_subscr(): rc = -2
+auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_NOT_AVAIL
+
+* test_auth_then_ciph1()
+wrapped: db_get_authinfo_for_subscr(): rc = 0
+wrapped: db_get_lastauthtuple_for_subscr(): rc = -2
+wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
+auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH
+wrapped: db_get_authinfo_for_subscr(): rc = 0
+wrapped: db_get_lastauthtuple_for_subscr(): rc = -2
+wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
+auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH
+
+* test_auth_then_ciph2()
+wrapped: db_get_authinfo_for_subscr(): rc = 0
+wrapped: db_get_lastauthtuple_for_subscr(): rc = 0
+wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
+auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH
+wrapped: db_get_authinfo_for_subscr(): rc = 0
+wrapped: db_get_lastauthtuple_for_subscr(): rc = 0
+wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
+auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH
+
+* test_auth_reuse()
+wrapped: db_get_authinfo_for_subscr(): rc = 0
+wrapped: db_get_lastauthtuple_for_subscr(): rc = 0
+wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
+auth_get_tuple_for_subscr(key_seq=3) --> auth_action == AUTH_DO_CIPH
+
+* test_auth_reuse_key_seq_mismatch()
+wrapped: db_get_authinfo_for_subscr(): rc = 0
+wrapped: db_get_lastauthtuple_for_subscr(): rc = 0
+wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
+auth_get_tuple_for_subscr(key_seq=4) --> auth_action == AUTH_DO_AUTH_THEN_CIPH
diff --git a/tests/nanobts_omlattr/Makefile.am b/tests/nanobts_omlattr/Makefile.am
new file mode 100644
index 000000000..b03d50cc1
--- /dev/null
+++ b/tests/nanobts_omlattr/Makefile.am
@@ -0,0 +1,34 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ nanobts_omlattr_test \
+ $(NULL)
+
+EXTRA_DIST = \
+ nanobts_omlattr_test.ok \
+ $(NULL)
+
+nanobts_omlattr_test_SOURCES = \
+ nanobts_omlattr_test.c \
+ $(NULL)
+
+nanobts_omlattr_test_LDADD = \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libmsc/libmsc.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOABIS_LIBS) \
+ -ldbi \
+ $(NULL)
diff --git a/tests/nanobts_omlattr/nanobts_omlattr_test.c b/tests/nanobts_omlattr/nanobts_omlattr_test.c
new file mode 100644
index 000000000..ee138b8f7
--- /dev/null
+++ b/tests/nanobts_omlattr/nanobts_omlattr_test.c
@@ -0,0 +1,284 @@
+/* Test OML attribute generator */
+
+/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
+ * All Rights Reserved
+ *
+ * Author: 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/>.
+ */
+
+#include <openbsc/gprs_llc_xid.h>
+#include <openbsc/debug.h>
+#include <openbsc/gsm_data.h>
+#include <openbsc/bts_ipaccess_nanobts_omlattr.h>
+
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/application.h>
+
+#include <stdio.h>
+#include <string.h>
+
+struct gsm_bts_model bts_model_nanobts = {
+ .type = GSM_BTS_TYPE_NANOBTS,
+ .name = "nanobts",
+ .start = NULL,
+ .oml_rcvmsg = NULL,
+ .e1line_bind_ops = NULL,
+ .nm_att_tlvdef = {
+ .def = {
+ /* ip.access specifics */
+ [NM_ATT_IPACC_DST_IP] = {TLV_TYPE_FIXED, 4},
+ [NM_ATT_IPACC_DST_IP_PORT] =
+ {TLV_TYPE_FIXED, 2},
+ [NM_ATT_IPACC_STREAM_ID] = {TLV_TYPE_TV,},
+ [NM_ATT_IPACC_SEC_OML_CFG] =
+ {TLV_TYPE_FIXED, 6},
+ [NM_ATT_IPACC_IP_IF_CFG] =
+ {TLV_TYPE_FIXED, 8},
+ [NM_ATT_IPACC_IP_GW_CFG] =
+ {TLV_TYPE_FIXED, 12},
+ [NM_ATT_IPACC_IN_SERV_TIME] =
+ {TLV_TYPE_FIXED, 4},
+ [NM_ATT_IPACC_LOCATION] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_PAGING_CFG] =
+ {TLV_TYPE_FIXED, 2},
+ [NM_ATT_IPACC_UNIT_ID] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_UNIT_NAME] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_SNMP_CFG] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_PRIM_OML_CFG_LIST] =
+ {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_NV_FLAGS] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_FREQ_CTRL] =
+ {TLV_TYPE_FIXED, 2},
+ [NM_ATT_IPACC_PRIM_OML_FB_TOUT] =
+ {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_CUR_SW_CFG] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_TIMING_BUS] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_CGI] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_RAC] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_OBJ_VERSION] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_GPRS_PAGING_CFG] =
+ {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_NSEI] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_BVCI] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_NSVCI] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_NS_CFG] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_BSSGP_CFG] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_NS_LINK_CFG] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_RLC_CFG] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_ALM_THRESH_LIST] =
+ {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_MONIT_VAL_LIST] =
+ {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_TIB_CONTROL] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_SUPP_FEATURES] =
+ {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_CODING_SCHEMES] =
+ {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_RLC_CFG_2] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_HEARTB_TOUT] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_UPTIME] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_RLC_CFG_3] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_SSL_CFG] = {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_SEC_POSSIBLE] =
+ {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_IML_SSL_STATE] =
+ {TLV_TYPE_TL16V},
+ [NM_ATT_IPACC_REVOC_DATE] = {TLV_TYPE_TL16V},
+ },
+ },
+};
+
+static void test_nanobts_attr_bts_get(struct gsm_bts *bts, uint8_t *expected)
+{
+ struct msgb *msgb;
+
+ printf("Testing nanobts_attr_bts_get()...\n");
+
+ msgb = nanobts_attr_bts_get(bts);
+ printf("result= %s\n", osmo_hexdump_nospc(msgb->data, msgb->len));
+ printf("expected=%s\n", osmo_hexdump_nospc(expected, msgb->len));
+ OSMO_ASSERT(memcmp(msgb->data, expected, msgb->len) == 0);
+ msgb_free(msgb);
+
+ printf("ok.\n");
+ printf("\n");
+}
+
+static void test_nanobts_attr_nse_get(struct gsm_bts *bts, uint8_t *expected)
+{
+ struct msgb *msgb;
+
+ printf("Testing nanobts_attr_nse_get()...\n");
+
+ msgb = nanobts_attr_nse_get(bts);
+ printf("result= %s\n", osmo_hexdump_nospc(msgb->data, msgb->len));
+ printf("expected=%s\n", osmo_hexdump_nospc(expected, msgb->len));
+ OSMO_ASSERT(memcmp(msgb->data, expected, msgb->len) == 0);
+ msgb_free(msgb);
+
+ printf("ok.\n");
+ printf("\n");
+}
+
+static void test_nanobts_attr_cell_get(struct gsm_bts *bts, uint8_t *expected)
+{
+ struct msgb *msgb;
+
+ printf("Testing nanobts_attr_cell_get()...\n");
+
+ msgb = nanobts_attr_cell_get(bts);
+ printf("result= %s\n", osmo_hexdump_nospc(msgb->data, msgb->len));
+ printf("expected=%s\n", osmo_hexdump_nospc(expected, msgb->len));
+ OSMO_ASSERT(memcmp(msgb->data, expected, msgb->len) == 0);
+ msgb_free(msgb);
+
+ printf("ok.\n");
+ printf("\n");
+}
+
+static void test_nanobts_attr_nscv_get(struct gsm_bts *bts, uint8_t *expected)
+{
+ struct msgb *msgb;
+
+ printf("Testing nanobts_attr_nscv_get()...\n");
+
+ msgb = nanobts_attr_nscv_get(bts);
+ printf("result= %s\n", osmo_hexdump_nospc(msgb->data, msgb->len));
+ printf("expected=%s\n", osmo_hexdump_nospc(expected, msgb->len));
+ OSMO_ASSERT(memcmp(msgb->data, expected, msgb->len) == 0);
+ msgb_free(msgb);
+
+ printf("ok.\n");
+ printf("\n");
+}
+
+static void test_nanobts_attr_radio_get(struct gsm_bts *bts,
+ struct gsm_bts_trx *trx,
+ uint8_t *expected)
+{
+ struct msgb *msgb;
+
+ printf("Testing nanobts_attr_nscv_get()...\n");
+
+ msgb = nanobts_attr_radio_get(bts, trx);
+ printf("result= %s\n", osmo_hexdump_nospc(msgb->data, msgb->len));
+ printf("expected=%s\n", osmo_hexdump_nospc(expected, msgb->len));
+ OSMO_ASSERT(memcmp(msgb->data, expected, msgb->len) == 0);
+ msgb_free(msgb);
+
+ printf("ok.\n");
+ printf("\n");
+}
+
+int main(int argc, char **argv)
+{
+ void *ctx;
+
+ struct gsm_bts *bts;
+ struct gsm_network *net;
+ struct gsm_bts_trx *trx;
+
+ ctx = talloc_named_const(NULL, 0, "ctx");
+
+ /* Allocate environmental structs (bts, net, trx) */
+ net = talloc_zero(ctx, struct gsm_network);
+ INIT_LLIST_HEAD(&net->bts_list);
+ gsm_bts_model_register(&bts_model_nanobts);
+ bts = gsm_bts_alloc_register(net, GSM_BTS_TYPE_NANOBTS, 63);
+ OSMO_ASSERT(bts);
+ trx = talloc_zero(ctx, struct gsm_bts_trx);
+
+ /* Parameters needed by nanobts_attr_bts_get() */
+ bts->rach_b_thresh = -1;
+ bts->rach_ldavg_slots = -1;
+ bts->c0->arfcn = 866;
+ bts->cell_identity = 1337;
+ bts->network->country_code = 1;
+ bts->network->network_code = 1;
+ bts->location_area_code = 1;
+ bts->gprs.rac = 0;
+ uint8_t attr_bts_expected[] =
+ { 0x19, 0x55, 0x5b, 0x61, 0x67, 0x6d, 0x73, 0x18, 0x06, 0x0e, 0x00,
+ 0x02, 0x01, 0x20, 0x33, 0x1e, 0x24, 0x24, 0xa8, 0x34, 0x21,
+ 0xa8, 0x1f, 0x3f, 0x25,
+ 0x00, 0x01, 0x0a, 0x0c, 0x0a, 0x0b, 0x01, 0x2a, 0x0a, 0x2b,
+ 0x03, 0xe8, 0x0a, 0x80,
+ 0x23, 0x0a, 0x08, 0x03, 0x62, 0x09, 0x3f, 0x99, 0x00, 0x07,
+ 0x00, 0xf1, 0x10, 0x00,
+ 0x01, 0x05, 0x39
+ };
+
+ /* Parameters needed to test nanobts_attr_nse_get() */
+ bts->gprs.nse.nsei = 101;
+ uint8_t attr_nse_expected[] =
+ { 0x9d, 0x00, 0x02, 0x00, 0x65, 0xa0, 0x00, 0x07, 0x03, 0x03, 0x03,
+ 0x03, 0x1e, 0x03, 0x0a, 0xa1, 0x00, 0x0b, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x0a, 0x03,
+ 0x0a, 0x03, 0x0a, 0x03
+ };
+
+ /* Parameters needed to test nanobts_attr_cell_get() */
+ bts->gprs.rac = 0x00;
+ bts->gprs.cell.bvci = 2;
+ bts->gprs.mode = BTS_GPRS_GPRS;
+ uint8_t attr_cell_expected[] =
+ { 0x9a, 0x00, 0x01, 0x00, 0x9c, 0x00, 0x02, 0x05, 0x03, 0x9e, 0x00,
+ 0x02, 0x00, 0x02, 0xa3, 0x00, 0x09, 0x14, 0x05, 0x05, 0xa0,
+ 0x05, 0x0a, 0x04, 0x08,
+ 0x0f, 0xa8, 0x00, 0x02, 0x0f, 0x00, 0xa9, 0x00, 0x05, 0x00,
+ 0xfa, 0x00, 0xfa, 0x02
+ };
+
+ /* Parameters needed to test nanobts_attr_nscv_get() */
+ bts->gprs.nsvc[0].nsvci = 0x65;
+ bts->gprs.nsvc[0].remote_port = 0x59d8;
+ bts->gprs.nsvc[0].remote_ip = 0x0a090165;
+ bts->gprs.nsvc[0].local_port = 0x5a3c;
+ uint8_t attr_nscv_expected[] =
+ { 0x9f, 0x00, 0x02, 0x00, 0x65, 0xa2, 0x00, 0x08, 0x59, 0xd8, 0x0a,
+ 0x09, 0x01, 0x65, 0x5a, 0x3c
+ };
+
+ /* Parameters needed to test nanobts_attr_radio_get() */
+ trx->arfcn = 866;
+ trx->max_power_red = 22;
+ bts->c0->max_power_red = 22;
+ uint8_t attr_radio_expected[] =
+ { 0x2d, 0x0b, 0x05, 0x00, 0x02, 0x03, 0x62 };
+
+ /* Run tests */
+ test_nanobts_attr_bts_get(bts, attr_bts_expected);
+ test_nanobts_attr_nse_get(bts, attr_nse_expected);
+ test_nanobts_attr_cell_get(bts, attr_cell_expected);
+ test_nanobts_attr_nscv_get(bts, attr_nscv_expected);
+ test_nanobts_attr_radio_get(bts, trx, attr_radio_expected);
+
+ printf("Done\n");
+ talloc_free(bts);
+ talloc_free(net);
+ talloc_free(trx);
+ talloc_report_full(ctx, stderr);
+ OSMO_ASSERT(talloc_total_blocks(ctx) == 1);
+ return 0;
+}
+
+/* stubs */
+struct osmo_prim_hdr;
+int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
+{
+ abort();
+}
diff --git a/tests/nanobts_omlattr/nanobts_omlattr_test.ok b/tests/nanobts_omlattr/nanobts_omlattr_test.ok
new file mode 100644
index 000000000..91b655f8f
--- /dev/null
+++ b/tests/nanobts_omlattr/nanobts_omlattr_test.ok
@@ -0,0 +1,26 @@
+Testing nanobts_attr_bts_get()...
+result= 19555b61676d7318060e00020120331e2424a83421a81f3f2500010a0c0a0b012a0a2b03e80a80230a080362093f99000700f11000010539
+expected=19555b61676d7318060e00020120331e2424a83421a81f3f2500010a0c0a0b012a0a2b03e80a80230a080362093f99000700f11000010539
+ok.
+
+Testing nanobts_attr_nse_get()...
+result= 9d00020065a00007030303031e030aa1000b03030303030a030a030a03
+expected=9d00020065a00007030303031e030aa1000b03030303030a030a030a03
+ok.
+
+Testing nanobts_attr_cell_get()...
+result= 9a0001009c000205039e00020002a30009140505a0050a04080fa800020f00a9000500fa00fa02
+expected=9a0001009c000205039e00020002a30009140505a0050a04080fa800020f00a9000500fa00fa02
+ok.
+
+Testing nanobts_attr_nscv_get()...
+result= 9f00020065a2000859d80a0901655a3c
+expected=9f00020065a2000859d80a0901655a3c
+ok.
+
+Testing nanobts_attr_nscv_get()...
+result= 2d0b0500020362
+expected=2d0b0500020362
+ok.
+
+Done
diff --git a/tests/oap/Makefile.am b/tests/oap/Makefile.am
new file mode 100644
index 000000000..1bb672d44
--- /dev/null
+++ b/tests/oap/Makefile.am
@@ -0,0 +1,36 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ oap_client_test.ok \
+ oap_client_test.err \
+ $(NULL)
+
+if HAVE_LIBGTP
+if HAVE_LIBCARES
+noinst_PROGRAMS = \
+ oap_client_test \
+ $(NULL)
+endif
+endif
+
+oap_client_test_SOURCES = \
+ oap_client_test.c \
+ $(NULL)
+
+oap_client_test_LDADD = \
+ $(top_builddir)/src/gprs/gprs_utils.o \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ -lrt
+
diff --git a/tests/oap/oap_client_test.c b/tests/oap/oap_client_test.c
new file mode 100644
index 000000000..e6501cb6d
--- /dev/null
+++ b/tests/oap/oap_client_test.c
@@ -0,0 +1,270 @@
+/* Test Osmocom Authentication Protocol */
+/*
+ * (C) 2015 by sysmocom s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * 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/>.
+ *
+ */
+
+#include <osmocom/core/application.h>
+#include <osmocom/gsm/oap.h>
+
+#include <openbsc/debug.h>
+#include <openbsc/oap_client.h>
+
+#include <stdio.h>
+#include <string.h>
+
+static void test_oap_api(void)
+{
+ printf("Testing OAP API\n");
+
+ struct oap_client_config _config;
+ struct oap_client_config *config = &_config;
+
+ struct oap_client_state _state;
+ struct oap_client_state *state = &_state;
+
+ struct osmo_oap_message oap_rx;
+ struct msgb *msg_rx;
+
+ struct osmo_oap_message oap_tx;
+ struct msgb *msg_tx;
+
+ memset(config, 0, sizeof(*config));
+ memset(state, 0, sizeof(*state));
+
+ OSMO_ASSERT(osmo_hexparse("0102030405060708090a0b0c0d0e0f10", config->secret_k, 16) == 16);
+ OSMO_ASSERT(osmo_hexparse("1112131415161718191a1b1c1d1e1f20", config->secret_opc, 16) == 16);
+
+ fprintf(stderr, "- make sure filling with zeros means uninitialized\n");
+ OSMO_ASSERT(state->state == OAP_UNINITIALIZED);
+
+ fprintf(stderr, "- reject messages in uninitialized state\n");
+ memset(&oap_rx, 0, sizeof(oap_rx));
+ state->client_id = 1;
+ oap_rx.message_type = OAP_MSGT_REGISTER_ERROR;
+ msg_rx = oap_client_encoded(&oap_rx);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0);
+ OSMO_ASSERT(state->state == OAP_UNINITIALIZED);
+ msgb_free(msg_rx);
+ OSMO_ASSERT(!msg_tx);
+
+ fprintf(stderr, "- NULL config should disable\n");
+ OSMO_ASSERT( oap_client_init(NULL, state) == 0 );
+ OSMO_ASSERT(state->state == OAP_DISABLED);
+
+ fprintf(stderr, "- reject messages in disabled state\n");
+ memset(state, 0, sizeof(*state));
+ memset(&oap_rx, 0, sizeof(oap_rx));
+ state->state = OAP_DISABLED;
+ state->client_id = 1;
+ oap_rx.message_type = OAP_MSGT_REGISTER_ERROR;
+ msg_rx = oap_client_encoded(&oap_rx);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0);
+ OSMO_ASSERT(state->state == OAP_DISABLED);
+ msgb_free(msg_rx);
+ OSMO_ASSERT(!msg_tx);
+
+ fprintf(stderr, "- invalid client_id and shared secret\n");
+ memset(state, 0, sizeof(*state));
+ config->client_id = 0;
+ config->secret_k_present = 0;
+ config->secret_opc_present = 0;
+ OSMO_ASSERT( oap_client_init(config, state) == 0 );
+ OSMO_ASSERT(state->state == OAP_DISABLED);
+
+ fprintf(stderr, "- reset state\n");
+ memset(state, 0, sizeof(*state));
+
+ fprintf(stderr, "- only client_id is invalid\n");
+ config->client_id = 0;
+ config->secret_k_present = 1;
+ config->secret_opc_present = 1;
+ OSMO_ASSERT( oap_client_init(config, state) == 0 );
+ OSMO_ASSERT(state->state == OAP_DISABLED);
+
+ memset(state, 0, sizeof(*state));
+
+ fprintf(stderr, "- valid id, but omitted shared_secret (1/2)\n");
+ config->client_id = 12345;
+ config->secret_k_present = 0;
+ config->secret_opc_present = 1;
+ OSMO_ASSERT( oap_client_init(config, state) == 0 );
+ OSMO_ASSERT(state->state == OAP_DISABLED);
+
+ memset(state, 0, sizeof(*state));
+
+ fprintf(stderr, "- valid id, but omitted shared_secret (2/2)\n");
+ config->client_id = 12345;
+ config->secret_k_present = 1;
+ config->secret_opc_present = 0;
+ OSMO_ASSERT( oap_client_init(config, state) == 0 );
+ OSMO_ASSERT(state->state == OAP_DISABLED);
+
+ memset(state, 0, sizeof(*state));
+
+
+ fprintf(stderr, "- mint configuration\n");
+ config->client_id = 12345;
+ config->secret_k_present = 1;
+ config->secret_opc_present = 1;
+ /*config->secret_* buffers are still set from the top */
+ OSMO_ASSERT( oap_client_init(config, state) == 0 );
+ OSMO_ASSERT(state->state == OAP_INITIALIZED);
+
+
+ fprintf(stderr, "- Missing challenge data\n");
+ memset(&oap_rx, 0, sizeof(oap_rx));
+ oap_rx.message_type = OAP_MSGT_CHALLENGE_REQUEST;
+ oap_rx.rand_present = 0;
+ oap_rx.autn_present = 0;
+ msg_rx = oap_client_encoded(&oap_rx);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2);
+ msgb_free(msg_rx);
+ OSMO_ASSERT(!msg_tx);
+
+ fprintf(stderr, "- AUTN missing\n");
+ osmo_hexparse("0102030405060708090a0b0c0d0e0f10",
+ oap_rx.rand, 16);
+ oap_rx.rand_present = 1;
+ msg_rx = oap_client_encoded(&oap_rx);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2);
+ msgb_free(msg_rx);
+ OSMO_ASSERT(!msg_tx);
+
+ fprintf(stderr, "- RAND missing\n");
+ oap_rx.rand_present = 0;
+ osmo_hexparse("cec4e3848a33000086781158ca40f136",
+ oap_rx.autn, 16);
+ oap_rx.autn_present = 1;
+ msg_rx = oap_client_encoded(&oap_rx);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2);
+ msgb_free(msg_rx);
+ OSMO_ASSERT(!msg_tx);
+
+ fprintf(stderr, "- wrong autn (by one bit)\n");
+ osmo_hexparse("0102030405060708090a0b0c0d0e0f10",
+ oap_rx.rand, 16);
+ osmo_hexparse("dec4e3848a33000086781158ca40f136",
+ oap_rx.autn, 16);
+ oap_rx.rand_present = 1;
+ oap_rx.autn_present = 1;
+ msg_rx = oap_client_encoded(&oap_rx);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2);
+ msgb_free(msg_rx);
+ OSMO_ASSERT(!msg_tx);
+
+ fprintf(stderr, "- all data correct\n");
+ osmo_hexparse("cec4e3848a33000086781158ca40f136",
+ oap_rx.autn, 16);
+ msg_rx = oap_client_encoded(&oap_rx);
+
+ fprintf(stderr, "- but refuse to evaluate in uninitialized state\n");
+ OSMO_ASSERT(state->state == OAP_INITIALIZED);
+
+ state->state = OAP_UNINITIALIZED;
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0);
+ OSMO_ASSERT(!msg_tx);
+
+ state->state = OAP_DISABLED;
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0);
+ OSMO_ASSERT(!msg_tx);
+
+ state->state = OAP_INITIALIZED;
+
+ fprintf(stderr, "- now everything is correct\n");
+ /* a successful return value here indicates correct autn */
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0);
+ msgb_free(msg_rx);
+
+ fprintf(stderr, "- Expect the challenge response in msg_tx\n");
+ OSMO_ASSERT(msg_tx);
+ OSMO_ASSERT(osmo_oap_decode(&oap_tx, msg_tx->data, msg_tx->len) == 0);
+ OSMO_ASSERT(oap_tx.message_type == OAP_MSGT_CHALLENGE_RESULT);
+ OSMO_ASSERT(strcmp("e2d05b598c61d9ba",
+ osmo_hexdump_nospc(oap_tx.xres, sizeof(oap_tx.xres)))
+ == 0);
+ OSMO_ASSERT(state->state == OAP_SENT_CHALLENGE_RESULT);
+ msgb_free(msg_tx);
+ msg_tx = 0;
+
+ struct oap_client_state saved_state = _state;
+
+ fprintf(stderr, "- Receive registration error for the first time.\n");
+
+ memset(&oap_rx, 0, sizeof(oap_rx));
+ oap_rx.message_type = OAP_MSGT_REGISTER_ERROR;
+ oap_rx.cause = GMM_CAUSE_PROTO_ERR_UNSPEC;
+ msg_rx = oap_client_encoded(&oap_rx);
+
+ OSMO_ASSERT(state->registration_failures == 0);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0);
+ OSMO_ASSERT(state->registration_failures == 1);
+ OSMO_ASSERT(msg_tx);
+ OSMO_ASSERT(osmo_oap_decode(&oap_tx, msg_tx->data, msg_tx->len) == 0);
+ OSMO_ASSERT(oap_tx.message_type == OAP_MSGT_REGISTER_REQUEST);
+ OSMO_ASSERT(state->state == OAP_REQUESTED_CHALLENGE);
+ msgb_free(msg_tx);
+ msg_tx = 0;
+
+ fprintf(stderr, "- Receive registration error for the Nth time.\n");
+ state->registration_failures = 999;
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -11);
+ OSMO_ASSERT(!msg_tx);
+ OSMO_ASSERT(state->state == OAP_INITIALIZED);
+ msgb_free(msg_tx);
+ msg_tx = 0;
+
+ msgb_free(msg_rx);
+
+ fprintf(stderr, "- Registration success\n");
+
+ _state = saved_state;
+ memset(&oap_rx, 0, sizeof(oap_rx));
+ oap_rx.message_type = OAP_MSGT_REGISTER_RESULT;
+ msg_rx = oap_client_encoded(&oap_rx);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0);
+ OSMO_ASSERT(!msg_tx);
+ OSMO_ASSERT(state->state == OAP_REGISTERED);
+ msgb_free(msg_rx);
+}
+
+static struct log_info_cat oap_client_test_categories[] = {
+};
+
+static struct log_info info = {
+ .cat = oap_client_test_categories,
+ .num_cat = ARRAY_SIZE(oap_client_test_categories),
+};
+
+int main(int argc, char **argv)
+{
+ msgb_talloc_ctx_init(NULL, 0);
+ osmo_init_logging(&info);
+
+ OSMO_ASSERT(osmo_stderr_target);
+ log_set_use_color(osmo_stderr_target, 0);
+ log_set_print_timestamp(osmo_stderr_target, 0);
+ log_set_print_filename(osmo_stderr_target, 0);
+ log_set_print_category(osmo_stderr_target, 1);
+ log_parse_category_mask(osmo_stderr_target, "DLOAP,1");
+
+ test_oap_api();
+ printf("Done\n");
+
+ return 0;
+}
+
diff --git a/tests/oap/oap_client_test.err b/tests/oap/oap_client_test.err
new file mode 100644
index 000000000..62ddc9efa
--- /dev/null
+++ b/tests/oap/oap_client_test.err
@@ -0,0 +1,35 @@
+- make sure filling with zeros means uninitialized
+- reject messages in uninitialized state
+DLOAP Received OAP message 5, but the OAP client is not initialized
+- NULL config should disable
+- reject messages in disabled state
+DLOAP Received OAP message 5, but the OAP client is disabled
+- invalid client_id and shared secret
+- reset state
+- only client_id is invalid
+- valid id, but omitted shared_secret (1/2)
+DLOAP OAP: client ID set, but secret K missing.
+- valid id, but omitted shared_secret (2/2)
+DLOAP OAP: client ID set, but secret OPC missing.
+- mint configuration
+- Missing challenge data
+DLOAP OAP challenge incomplete (rand_present: 0, autn_present: 0)
+- AUTN missing
+DLOAP OAP challenge incomplete (rand_present: 1, autn_present: 0)
+- RAND missing
+DLOAP OAP challenge incomplete (rand_present: 0, autn_present: 1)
+- wrong autn (by one bit)
+DLOAP OAP: AUTN mismatch!
+DLOAP OAP: AUTN from server: dec4e3848a33000086781158ca40f136
+DLOAP OAP: AUTN expected: cec4e3848a33000086781158ca40f136
+- all data correct
+- but refuse to evaluate in uninitialized state
+DLOAP Received OAP message 8, but the OAP client is not initialized
+DLOAP Received OAP message 8, but the OAP client is disabled
+- now everything is correct
+- Expect the challenge response in msg_tx
+- Receive registration error for the first time.
+DLOAP OAP registration failed
+- Receive registration error for the Nth time.
+DLOAP OAP registration failed
+- Registration success
diff --git a/tests/oap/oap_client_test.ok b/tests/oap/oap_client_test.ok
new file mode 100644
index 000000000..59108a792
--- /dev/null
+++ b/tests/oap/oap_client_test.ok
@@ -0,0 +1,2 @@
+Testing OAP API
+Done
diff --git a/tests/sgsn/Makefile.am b/tests/sgsn/Makefile.am
new file mode 100644
index 000000000..f1606cb96
--- /dev/null
+++ b/tests/sgsn/Makefile.am
@@ -0,0 +1,82 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBCARES_CFLAGS) \
+ $(NULL)
+if BUILD_IU
+AM_CFLAGS += \
+ $(LIBASN1C_CFLAGS) \
+ $(LIBOSMOSIGTRAN_CFLAGS) \
+ $(LIBOSMORANAP_CFLAGS) \
+ $(NULL)
+endif
+
+EXTRA_DIST = \
+ sgsn_test.ok \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ sgsn_test \
+ $(NULL)
+
+sgsn_test_SOURCES = \
+ sgsn_test.c \
+ $(NULL)
+
+sgsn_test_LDFLAGS = \
+ -Wl,--wrap=RAND_bytes \
+ -Wl,--wrap=sgsn_update_subscriber_data \
+ -Wl,--wrap=gprs_subscr_request_update_location \
+ -Wl,--wrap=gprs_subscr_request_auth_info \
+ -Wl,--wrap=gsup_client_send \
+ $(NULL)
+
+sgsn_test_LDADD = \
+ $(top_builddir)/src/gprs/gprs_llc_parse.o \
+ $(top_builddir)/src/gprs/gprs_llc.o \
+ $(top_builddir)/src/gprs/crc24.o \
+ $(top_builddir)/src/gprs/gprs_sndcp.o \
+ $(top_builddir)/src/gprs/gprs_gmm.o \
+ $(top_builddir)/src/gprs/gprs_sgsn.o \
+ $(top_builddir)/src/gprs/sgsn_vty.o \
+ $(top_builddir)/src/gprs/sgsn_libgtp.o \
+ $(top_builddir)/src/gprs/sgsn_auth.o \
+ $(top_builddir)/src/gprs/sgsn_ares.o \
+ $(top_builddir)/src/gprs/gprs_utils.o \
+ $(top_builddir)/src/gprs/gprs_subscriber.o \
+ $(top_builddir)/src/gprs/gprs_gb_parse.o \
+ $(top_builddir)/src/gprs/gprs_llc_xid.o \
+ $(top_builddir)/src/gprs/gprs_sndcp_xid.o \
+ $(top_builddir)/src/gprs/slhc.o \
+ $(top_builddir)/src/gprs/gprs_sndcp_comp.o \
+ $(top_builddir)/src/gprs/gprs_sndcp_pcomp.o \
+ $(top_builddir)/src/gprs/v42bis.o \
+ $(top_builddir)/src/gprs/gprs_sndcp_dcomp.o \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOABIS_LIBS) \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOGB_LIBS) \
+ $(LIBCARES_LIBS) \
+ $(LIBCRYPTO_LIBS) \
+ $(LIBGTP_LIBS) \
+ -lrt \
+ -lm \
+ $(NULL)
+
+if BUILD_IU
+sgsn_test_LDADD += \
+ $(top_builddir)/src/libiu/libiu.a \
+ $(LIBOSMORANAP_LIBS) \
+ $(LIBOSMOSIGTRAN_LIBS) \
+ $(LIBASN1C_LIBS) \
+ $(NULL)
+endif
diff --git a/tests/sgsn/sgsn_test.c b/tests/sgsn/sgsn_test.c
new file mode 100644
index 000000000..2f1513a29
--- /dev/null
+++ b/tests/sgsn/sgsn_test.c
@@ -0,0 +1,2487 @@
+/* Test the SGSN */
+/*
+ * (C) 2014 by Holger Hans Peter Freyther
+ * (C) 2014 by sysmocom s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * 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/>.
+ *
+ */
+
+#include <openbsc/gprs_llc.h>
+#include <openbsc/sgsn.h>
+#include <openbsc/gprs_gmm.h>
+#include <openbsc/debug.h>
+#include <openbsc/gprs_subscriber.h>
+#include <osmocom/gsm/gsup.h>
+#include <openbsc/gsup_client.h>
+#include <openbsc/gprs_utils.h>
+#include <openbsc/gprs_gb_parse.h>
+
+#include <osmocom/gprs/gprs_bssgp.h>
+
+#include <osmocom/gsm/gsm_utils.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/rate_ctr.h>
+#include <osmocom/core/utils.h>
+
+#include <stdio.h>
+
+void *tall_bsc_ctx;
+static struct sgsn_instance sgsn_inst = {
+ .config_file = "osmo_sgsn.cfg",
+ .cfg = {
+ .gtp_statedir = "./",
+ .auth_policy = SGSN_AUTH_POLICY_CLOSED,
+ },
+};
+struct sgsn_instance *sgsn = &sgsn_inst;
+unsigned sgsn_tx_counter = 0;
+struct msgb *last_msg = NULL;
+struct gprs_gb_parse_context last_dl_parse_ctx;
+
+static void reset_last_msg()
+{
+ if (last_msg)
+ msgb_free(last_msg);
+
+ last_msg = NULL;
+ memset(&last_dl_parse_ctx, 0, sizeof(last_dl_parse_ctx));
+}
+
+static void cleanup_test()
+{
+ reset_last_msg();
+}
+
+static uint32_t get_new_ptmsi(const struct gprs_gb_parse_context *parse_ctx)
+{
+ uint32_t new_ptmsi = GSM_RESERVED_TMSI;
+
+ if (parse_ctx->new_ptmsi_enc)
+ gprs_parse_tmsi(parse_ctx->new_ptmsi_enc, &new_ptmsi);
+
+ return new_ptmsi;
+}
+
+/* override */
+int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime,
+ struct bssgp_dl_ud_par *dup)
+{
+ int rc;
+
+ reset_last_msg();
+
+ last_msg = msg;
+ OSMO_ASSERT(msgb_data(last_msg) != NULL);
+
+ rc = gprs_gb_parse_llc(msgb_data(last_msg), msgb_length(last_msg),
+ &last_dl_parse_ctx);
+
+ fprintf(stderr, "Got DL LLC message: %s\n",
+ gprs_gb_message_name(&last_dl_parse_ctx, "UNKNOWN"));
+
+ OSMO_ASSERT(rc > 0);
+
+ sgsn_tx_counter += 1;
+ return 0;
+}
+
+/* override, requires '-Wl,--wrap=RAND_bytes' */
+int __real_RAND_bytes(unsigned char *buf, int num);
+int mock_RAND_bytes(unsigned char *buf, int num);
+int (*RAND_bytes_cb)(unsigned char *, int) =
+ &mock_RAND_bytes;
+
+int __wrap_RAND_bytes(unsigned char *buf, int num)
+{
+ return (*RAND_bytes_cb)(buf, num);
+}
+/* make results of A&C ref predictable */
+int mock_RAND_bytes(unsigned char *buf, int num)
+{
+ if (num > 1)
+ return __real_RAND_bytes(buf, num);
+ buf[0] = 0;
+ return 1;
+}
+
+/* override, requires '-Wl,--wrap=sgsn_update_subscriber_data' */
+void __real_sgsn_update_subscriber_data(struct sgsn_mm_ctx *);
+void (*update_subscriber_data_cb)(struct sgsn_mm_ctx *) =
+ &__real_sgsn_update_subscriber_data;
+
+void __wrap_sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx)
+{
+ (*update_subscriber_data_cb)(mmctx);
+}
+
+/* override, requires '-Wl,--wrap=gprs_subscr_request_update_location' */
+int __real_gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx);
+int (*subscr_request_update_location_cb)(struct sgsn_mm_ctx *mmctx) =
+ &__real_gprs_subscr_request_update_location;
+
+int __wrap_gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx) {
+ return (*subscr_request_update_location_cb)(mmctx);
+};
+
+/* override, requires '-Wl,--wrap=gprs_subscr_request_auth_info' */
+int __real_gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx);
+int (*subscr_request_auth_info_cb)(struct sgsn_mm_ctx *mmctx) =
+ &__real_gprs_subscr_request_auth_info;
+
+int __wrap_gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx) {
+ return (*subscr_request_auth_info_cb)(mmctx);
+};
+
+/* override, requires '-Wl,--wrap=gsup_client_send' */
+int __real_gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
+int (*gsup_client_send_cb)(struct gsup_client *gsupc, struct msgb *msg) =
+ &__real_gsup_client_send;
+
+int __wrap_gsup_client_send(struct gsup_client *gsupc, struct msgb *msg)
+{
+ return (*gsup_client_send_cb)(gsupc, msg);
+};
+
+static int count(struct llist_head *head)
+{
+ struct llist_head *cur;
+ int count = 0;
+
+ llist_for_each(cur, head)
+ count += 1;
+
+ return count;
+}
+
+static struct msgb *create_msg(const uint8_t *data, size_t len)
+{
+ struct msgb *msg = msgb_alloc(len + 8, "test message");
+ msg->l1h = msgb_put(msg, 8);
+ msg->l2h = msgb_put(msg, len);
+ memcpy(msg->l2h, data, len);
+
+ msgb_bcid(msg) = msg->l1h;
+ msgb_gmmh(msg) = msg->l2h;
+ return msg;
+}
+
+/*
+ * Create a context and search for it
+ */
+static struct sgsn_mm_ctx *alloc_mm_ctx(uint32_t tlli, struct gprs_ra_id *raid)
+{
+ struct sgsn_mm_ctx *ctx, *ictx;
+ struct gprs_llc_lle *lle;
+ int old_count = count(gprs_llme_list());
+
+ lle = gprs_lle_get_or_create(tlli, 3);
+ ctx = sgsn_mm_ctx_alloc_gb(tlli, raid);
+ ctx->gmm_state = GMM_REGISTERED_NORMAL;
+ ctx->gb.llme = lle->llme;
+
+ ictx = sgsn_mm_ctx_by_tlli(tlli, raid);
+ OSMO_ASSERT(ictx == ctx);
+
+ OSMO_ASSERT(count(gprs_llme_list()) == old_count + 1);
+
+ return ctx;
+}
+
+static void send_0408_message(struct gprs_llc_llme *llme, uint32_t tlli,
+ const struct gprs_ra_id *bssgp_raid,
+ const uint8_t *data, size_t data_len)
+{
+ struct msgb *msg;
+
+ reset_last_msg();
+ sgsn_tx_counter = 0;
+
+ msg = create_msg(data, data_len);
+ msgb_tlli(msg) = tlli;
+ bssgp_create_cell_id(msgb_bcid(msg), bssgp_raid, 0);
+ gsm0408_gprs_rcvmsg_gb(msg, llme, false);
+ msgb_free(msg);
+}
+
+static void test_llme(void)
+{
+ struct gprs_llc_lle *lle, *lle_copy;
+ uint32_t local_tlli;
+
+ printf("Testing LLME allocations\n");
+ local_tlli = gprs_tmsi2tlli(0x234, TLLI_LOCAL);
+
+ /* initial state */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+
+ /* Create a new entry */
+ lle = gprs_lle_get_or_create(local_tlli, 3);
+ OSMO_ASSERT(lle);
+ OSMO_ASSERT(count(gprs_llme_list()) == 1);
+
+ /* No new entry is created */
+ lle_copy = gprs_lle_get_or_create(local_tlli, 3);
+ OSMO_ASSERT(lle == lle_copy);
+ OSMO_ASSERT(count(gprs_llme_list()) == 1);
+
+ /* unassign which should delete it*/
+ gprs_llgmm_unassign(lle->llme);
+
+ /* Check that everything was cleaned up */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+
+ cleanup_test();
+}
+
+struct gprs_subscr *last_updated_subscr = NULL;
+void my_dummy_sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx)
+{
+ OSMO_ASSERT(mmctx);
+ fprintf(stderr, "Called %s, mmctx = %p, subscr = %p\n",
+ __func__, mmctx, mmctx->subscr);
+ last_updated_subscr = mmctx->subscr;
+}
+
+static void assert_subscr(const struct gprs_subscr *subscr, const char *imsi)
+{
+ struct gprs_subscr *sfound;
+ OSMO_ASSERT(subscr);
+ OSMO_ASSERT(strcmp(subscr->imsi, imsi) == 0);
+
+ sfound = gprs_subscr_get_by_imsi(imsi);
+ OSMO_ASSERT(sfound == subscr);
+
+ gprs_subscr_put(sfound);
+}
+
+static void show_subscrs(FILE *out)
+{
+ struct gprs_subscr *subscr;
+
+ llist_for_each_entry(subscr, gprs_subscribers, entry) {
+ fprintf(out, " Subscriber: %s, "
+ "use count: %d\n",
+ subscr->imsi, subscr->use_count);
+ }
+}
+
+static void assert_no_subscrs()
+{
+ show_subscrs(stdout);
+ fflush(stdout);
+ OSMO_ASSERT(llist_empty(gprs_subscribers));
+}
+
+#define VERBOSE_ASSERT(val, expect_op, fmt) \
+ do { \
+ printf(#val " == " fmt "\n", (val)); \
+ OSMO_ASSERT((val) expect_op); \
+ } while (0);
+
+static void test_subscriber(void)
+{
+ struct gprs_subscr *s1, *s2, *s3;
+ const char *imsi1 = "1234567890";
+ const char *imsi2 = "9876543210";
+ const char *imsi3 = "5656565656";
+
+ update_subscriber_data_cb = my_dummy_sgsn_update_subscriber_data;
+
+ printf("Testing core subscriber data API\n");
+
+ /* Check for emptiness */
+ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL);
+ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL);
+ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi3) == NULL);
+ VERBOSE_ASSERT(llist_count(gprs_subscribers), == 0, "%d");
+
+ /* Allocate entry 1 */
+ s1 = gprs_subscr_get_or_create(imsi1);
+ VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d");
+ s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT;
+ assert_subscr(s1, imsi1);
+ VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d");
+ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL);
+
+ /* Allocate entry 2 */
+ s2 = gprs_subscr_get_or_create(imsi2);
+ VERBOSE_ASSERT(llist_count(gprs_subscribers), == 2, "%d");
+ s2->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT;
+
+ /* Allocate entry 3 */
+ s3 = gprs_subscr_get_or_create(imsi3);
+ VERBOSE_ASSERT(llist_count(gprs_subscribers), == 3, "%d");
+
+ /* Check entries */
+ assert_subscr(s1, imsi1);
+ assert_subscr(s2, imsi2);
+ assert_subscr(s3, imsi3);
+
+ /* Update entry 1 */
+ last_updated_subscr = NULL;
+ gprs_subscr_update(s1);
+ OSMO_ASSERT(last_updated_subscr == NULL);
+ OSMO_ASSERT(s1->sgsn_data->mm == NULL);
+ OSMO_ASSERT((s1->flags & GPRS_SUBSCRIBER_FIRST_CONTACT) == 0);
+
+ /* There is no subscriber cache. Verify it */
+ gprs_subscr_cleanup(s1);
+ gprs_subscr_put(s1);
+ s1 = NULL;
+ VERBOSE_ASSERT(llist_count(gprs_subscribers), == 2, "%d");
+ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL);
+
+ assert_subscr(s2, imsi2);
+ assert_subscr(s3, imsi3);
+
+ /* Free entry 2 (GPRS_SUBSCRIBER_FIRST_CONTACT is set) */
+ gprs_subscr_cleanup(s2);
+ gprs_subscr_put(s2);
+ s2 = NULL;
+ VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d");
+ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL);
+ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL);
+ assert_subscr(s3, imsi3);
+
+ /* Try to delete entry 3 */
+ gprs_subscr_cleanup(s3);
+ gprs_subscr_put(s3);
+ s3 = NULL;
+ VERBOSE_ASSERT(llist_count(gprs_subscribers), == 0, "%d");
+ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi3) == NULL);
+
+ OSMO_ASSERT(llist_empty(gprs_subscribers));
+
+ update_subscriber_data_cb = __real_sgsn_update_subscriber_data;
+
+ cleanup_test();
+}
+
+static void test_auth_triplets(void)
+{
+ struct gprs_subscr *s1, *s1found;
+ const char *imsi1 = "1234567890";
+ struct gsm_auth_tuple *at;
+ struct sgsn_mm_ctx *ctx;
+ struct gprs_ra_id raid = { 0, };
+ uint32_t local_tlli = 0xffeeddcc;
+
+ printf("Testing authentication triplet handling\n");
+
+ /* Check for emptiness */
+ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL);
+
+ /* Allocate entry 1 */
+ s1 = gprs_subscr_get_or_create(imsi1);
+ s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT;
+ s1found = gprs_subscr_get_by_imsi(imsi1);
+ OSMO_ASSERT(s1found == s1);
+ gprs_subscr_put(s1found);
+
+ /* Create a context */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ ctx = alloc_mm_ctx(local_tlli, &raid);
+
+ /* Attach s1 to ctx */
+ ctx->subscr = gprs_subscr_get(s1);
+ ctx->subscr->sgsn_data->mm = ctx;
+
+ /* Try to get auth tuple */
+ at = sgsn_auth_get_tuple(ctx, GSM_KEY_SEQ_INVAL);
+ OSMO_ASSERT(at == NULL);
+
+ /* Add triplets */
+ s1->sgsn_data->auth_triplets[0].key_seq = 0;
+ s1->sgsn_data->auth_triplets[1].key_seq = 1;
+ s1->sgsn_data->auth_triplets[2].key_seq = 2;
+
+ /* Try to get auth tuple */
+ at = sgsn_auth_get_tuple(ctx, GSM_KEY_SEQ_INVAL);
+ OSMO_ASSERT(at != NULL);
+ OSMO_ASSERT(at->key_seq == 0);
+ OSMO_ASSERT(at->use_count == 1);
+ at = sgsn_auth_get_tuple(ctx, at->key_seq);
+ OSMO_ASSERT(at != NULL);
+ OSMO_ASSERT(at->key_seq == 1);
+ OSMO_ASSERT(at->use_count == 1);
+ at = sgsn_auth_get_tuple(ctx, at->key_seq);
+ OSMO_ASSERT(at != NULL);
+ OSMO_ASSERT(at->key_seq == 2);
+ OSMO_ASSERT(at->use_count == 1);
+ at = sgsn_auth_get_tuple(ctx, at->key_seq);
+ OSMO_ASSERT(at == NULL);
+
+ /* Free MM context and subscriber */
+ gprs_subscr_put(s1);
+ sgsn_mm_ctx_cleanup_free(ctx);
+ s1found = gprs_subscr_get_by_imsi(imsi1);
+ OSMO_ASSERT(s1found == NULL);
+
+ cleanup_test();
+}
+
+#define TEST_GSUP_IMSI1_IE 0x01, 0x05, 0x21, 0x43, 0x65, 0x87, 0x09
+
+static int rx_gsup_message(const uint8_t *data, size_t data_len)
+{
+ struct msgb *msg;
+ int rc;
+
+ msg = msgb_alloc(1024, __func__);
+ msg->l2h = msgb_put(msg, data_len);
+ OSMO_ASSERT(msg->l2h != NULL);
+ memcpy(msg->l2h, data, data_len);
+ rc = gprs_subscr_rx_gsup_message(msg);
+ msgb_free(msg);
+
+ return rc;
+}
+
+static void test_subscriber_gsup(void)
+{
+ struct gprs_subscr *s1, *s1found;
+ const char *imsi1 = "1234567890";
+ struct sgsn_mm_ctx *ctx;
+ struct gprs_ra_id raid = { 0, };
+ uint32_t local_tlli = 0xffeeddcc;
+ struct sgsn_subscriber_pdp_data *pdpd;
+ int rc;
+
+ static const uint8_t send_auth_info_res[] = {
+ 0x0a,
+ TEST_GSUP_IMSI1_IE,
+ 0x03, 0x22, /* Auth tuple */
+ 0x20, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x21, 0x04,
+ 0x21, 0x22, 0x23, 0x24,
+ 0x22, 0x08,
+ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
+ 0x03, 0x22, /* Auth tuple */
+ 0x20, 0x10,
+ 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
+ 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90,
+ 0x21, 0x04,
+ 0xa1, 0xa2, 0xa3, 0xa4,
+ 0x22, 0x08,
+ 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8,
+ };
+
+ static const uint8_t send_auth_info_err[] = {
+ 0x09,
+ TEST_GSUP_IMSI1_IE,
+ 0x02, 0x01, 0x07 /* GPRS not allowed */
+ };
+
+#define MSISDN 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09
+
+ static const uint8_t s1_msisdn[] = { MSISDN };
+
+ static const uint8_t update_location_res[] = {
+ 0x06,
+ TEST_GSUP_IMSI1_IE,
+ 0x08, 0x09, MSISDN,
+ 0x04, 0x00, /* PDP info complete */
+ 0x05, 0x12,
+ 0x10, 0x01, 0x01,
+ 0x11, 0x02, 0xf1, 0x21, /* IPv4 */
+ 0x12, 0x09, 0x04, 't', 'e', 's', 't', 0x03, 'a', 'p', 'n',
+ 0x05, 0x11,
+ 0x10, 0x01, 0x02,
+ 0x11, 0x02, 0xf1, 0x21, /* IPv4 */
+ 0x12, 0x08, 0x03, 'f', 'o', 'o', 0x03, 'a', 'p', 'n',
+ };
+
+#undef MSISDN
+
+ static const uint8_t update_location_err[] = {
+ 0x05,
+ TEST_GSUP_IMSI1_IE,
+ 0x02, 0x01, 0x07 /* GPRS not allowed */
+ };
+
+ static const uint8_t location_cancellation_req[] = {
+ 0x1c,
+ TEST_GSUP_IMSI1_IE,
+ 0x06, 0x01, 0x00,
+ };
+
+ static const uint8_t location_cancellation_req_withdraw[] = {
+ 0x1c,
+ TEST_GSUP_IMSI1_IE,
+ 0x06, 0x01, 0x01,
+ };
+
+ static const uint8_t location_cancellation_req_other[] = {
+ 0x1c,
+ 0x01, 0x05, 0x11, 0x11, 0x11, 0x11, 0x01,
+ 0x06, 0x01, 0x00,
+ };
+
+ static const uint8_t purge_ms_err[] = {
+ 0x0d,
+ TEST_GSUP_IMSI1_IE,
+ 0x02, 0x01, 0x02, /* IMSI unknown in HLR */
+ };
+
+ static const uint8_t purge_ms_err_no_cause[] = {
+ 0x0d,
+ TEST_GSUP_IMSI1_IE,
+ };
+
+ static const uint8_t purge_ms_res[] = {
+ 0x0e,
+ TEST_GSUP_IMSI1_IE,
+ 0x07, 0x00,
+ };
+
+
+ static const uint8_t insert_data_req[] = {
+ 0x10,
+ TEST_GSUP_IMSI1_IE,
+ 0x05, 0x11,
+ 0x10, 0x01, 0x03,
+ 0x11, 0x02, 0xf1, 0x21, /* IPv4 */
+ 0x12, 0x08, 0x03, 'b', 'a', 'r', 0x03, 'a', 'p', 'n',
+ };
+
+ static const uint8_t delete_data_req[] = {
+ 0x14,
+ TEST_GSUP_IMSI1_IE,
+ 0x10, 0x01, 0x03,
+ };
+
+ printf("Testing subscriber GSUP handling\n");
+
+ update_subscriber_data_cb = my_dummy_sgsn_update_subscriber_data;
+
+ /* Check for emptiness */
+ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL);
+
+ /* Allocate entry 1 */
+ s1 = gprs_subscr_get_or_create(imsi1);
+ s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT;
+ s1found = gprs_subscr_get_by_imsi(imsi1);
+ OSMO_ASSERT(s1found == s1);
+ gprs_subscr_put(s1found);
+
+ /* Create a context */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ ctx = alloc_mm_ctx(local_tlli, &raid);
+
+ /* Attach s1 to ctx */
+ ctx->subscr = gprs_subscr_get(s1);
+ ctx->subscr->sgsn_data->mm = ctx;
+
+ /* Inject SendAuthInfoReq GSUP message */
+ rc = rx_gsup_message(send_auth_info_res, sizeof(send_auth_info_res));
+ OSMO_ASSERT(rc >= 0);
+ OSMO_ASSERT(last_updated_subscr == s1);
+
+ /* Check triplets */
+ OSMO_ASSERT(s1->sgsn_data->auth_triplets[0].key_seq == 0);
+ OSMO_ASSERT(s1->sgsn_data->auth_triplets[1].key_seq == 1);
+ OSMO_ASSERT(s1->sgsn_data->auth_triplets[2].key_seq == GSM_KEY_SEQ_INVAL);
+
+ /* Inject SendAuthInfoErr GSUP message */
+ rc = rx_gsup_message(send_auth_info_err, sizeof(send_auth_info_err));
+ OSMO_ASSERT(rc == -GMM_CAUSE_GPRS_NOTALLOWED);
+ OSMO_ASSERT(last_updated_subscr == s1);
+ OSMO_ASSERT(s1->sgsn_data->error_cause == GMM_CAUSE_GPRS_NOTALLOWED);
+
+ /* Check triplets */
+ OSMO_ASSERT(s1->sgsn_data->auth_triplets[0].key_seq == GSM_KEY_SEQ_INVAL);
+ OSMO_ASSERT(s1->sgsn_data->auth_triplets[1].key_seq == GSM_KEY_SEQ_INVAL);
+ OSMO_ASSERT(s1->sgsn_data->auth_triplets[2].key_seq == GSM_KEY_SEQ_INVAL);
+
+ /* Inject UpdateLocRes GSUP message */
+ rc = rx_gsup_message(update_location_res, sizeof(update_location_res));
+ OSMO_ASSERT(rc >= 0);
+ OSMO_ASSERT(last_updated_subscr == s1);
+ OSMO_ASSERT(s1->flags & GPRS_SUBSCRIBER_ENABLE_PURGE);
+ OSMO_ASSERT(s1->sgsn_data->error_cause == SGSN_ERROR_CAUSE_NONE);
+ OSMO_ASSERT(s1->sgsn_data->msisdn_len == sizeof(s1_msisdn));
+ OSMO_ASSERT(memcmp(s1->sgsn_data->msisdn, s1_msisdn, sizeof(s1_msisdn)) == 0);
+ OSMO_ASSERT(!llist_empty(&s1->sgsn_data->pdp_list));
+ pdpd = llist_entry(s1->sgsn_data->pdp_list.next,
+ struct sgsn_subscriber_pdp_data, list);
+ OSMO_ASSERT(strcmp(pdpd->apn_str, "test.apn") == 0);
+ pdpd = llist_entry(pdpd->list.next,
+ struct sgsn_subscriber_pdp_data, list);
+ OSMO_ASSERT(strcmp(pdpd->apn_str, "foo.apn") == 0);
+
+ /* Check authorization */
+ OSMO_ASSERT(s1->authorized == 1);
+
+ /* Inject UpdateLocErr GSUP message */
+ rc = rx_gsup_message(update_location_err, sizeof(update_location_err));
+ OSMO_ASSERT(rc == -GMM_CAUSE_GPRS_NOTALLOWED);
+ OSMO_ASSERT(last_updated_subscr == s1);
+ OSMO_ASSERT(s1->sgsn_data->error_cause == GMM_CAUSE_GPRS_NOTALLOWED);
+
+ /* Check authorization */
+ OSMO_ASSERT(s1->authorized == 0);
+
+ /* Inject InsertSubscrData GSUP message */
+ last_updated_subscr = NULL;
+ rc = rx_gsup_message(insert_data_req, sizeof(insert_data_req));
+ OSMO_ASSERT(rc == -ENOTSUP); /* not connected */
+ OSMO_ASSERT(last_updated_subscr == s1);
+
+ /* Inject DeleteSubscrData GSUP message */
+ last_updated_subscr = NULL;
+ rc = rx_gsup_message(delete_data_req, sizeof(delete_data_req));
+ if (rc != -GMM_CAUSE_SEM_INCORR_MSG)
+ printf("Unexpected response to DSD: %d\n", rc);
+ OSMO_ASSERT(last_updated_subscr == NULL);
+
+ /* Inject wrong LocCancelReq GSUP message */
+ last_updated_subscr = NULL;
+ rc = rx_gsup_message(location_cancellation_req_other,
+ sizeof(location_cancellation_req_other));
+ OSMO_ASSERT(rc == -GMM_CAUSE_IMSI_UNKNOWN);
+ OSMO_ASSERT(last_updated_subscr == NULL);
+
+ /* Check cancellation result */
+ OSMO_ASSERT(!(s1->flags & GPRS_SUBSCRIBER_CANCELLED));
+ OSMO_ASSERT(s1->sgsn_data->mm != NULL);
+
+ /* Inject LocCancelReq GSUP message */
+ rc = rx_gsup_message(location_cancellation_req,
+ sizeof(location_cancellation_req));
+ OSMO_ASSERT(rc >= 0);
+ OSMO_ASSERT(last_updated_subscr == s1);
+ OSMO_ASSERT(s1->sgsn_data->error_cause == SGSN_ERROR_CAUSE_NONE);
+
+ /* Check cancellation result */
+ OSMO_ASSERT(s1->flags & GPRS_SUBSCRIBER_CANCELLED);
+ OSMO_ASSERT(s1->sgsn_data->mm == NULL);
+
+ /* Inject LocCancelReq(withdraw) GSUP message */
+ rc = rx_gsup_message(location_cancellation_req_withdraw,
+ sizeof(location_cancellation_req_withdraw));
+ OSMO_ASSERT(rc >= 0);
+ OSMO_ASSERT(s1->sgsn_data->error_cause == GMM_CAUSE_IMPL_DETACHED);
+
+ /* Inject PurgeMsRes GSUP message */
+ rc = rx_gsup_message(purge_ms_res,
+ sizeof(purge_ms_res));
+ OSMO_ASSERT(rc >= 0);
+ OSMO_ASSERT(!(s1->flags & GPRS_SUBSCRIBER_ENABLE_PURGE));
+
+ /* Free MM context and subscriber */
+ OSMO_ASSERT(ctx->subscr == NULL);
+ sgsn_mm_ctx_cleanup_free(ctx);
+ gprs_subscr_put(s1);
+ s1found = gprs_subscr_get_by_imsi(imsi1);
+ OSMO_ASSERT(s1found == NULL);
+
+ /* Inject PurgeMsRes GSUP message */
+ rc = rx_gsup_message(purge_ms_res,
+ sizeof(purge_ms_res));
+ OSMO_ASSERT(rc >= 0);
+
+ /* Inject PurgeMsErr(IMSI unknown in HLR) GSUP message */
+ rc = rx_gsup_message(purge_ms_err,
+ sizeof(purge_ms_err));
+ OSMO_ASSERT(rc == -GMM_CAUSE_IMSI_UNKNOWN);
+
+ /* Inject PurgeMsErr() GSUP message */
+ rc = rx_gsup_message(purge_ms_err_no_cause,
+ sizeof(purge_ms_err_no_cause));
+ OSMO_ASSERT(rc == -GMM_CAUSE_NET_FAIL);
+
+ /* Inject InsertSubscrData GSUP message (unknown IMSI) */
+ last_updated_subscr = NULL;
+ rc = rx_gsup_message(insert_data_req, sizeof(insert_data_req));
+ OSMO_ASSERT(rc == -GMM_CAUSE_IMSI_UNKNOWN);
+ OSMO_ASSERT(last_updated_subscr == NULL);
+
+ /* Inject DeleteSubscrData GSUP message (unknown IMSI) */
+ rc = rx_gsup_message(delete_data_req, sizeof(delete_data_req));
+ OSMO_ASSERT(rc == -GMM_CAUSE_IMSI_UNKNOWN);
+ OSMO_ASSERT(last_updated_subscr == NULL);
+
+ /* Inject LocCancelReq GSUP message (unknown IMSI) */
+ rc = rx_gsup_message(location_cancellation_req,
+ sizeof(location_cancellation_req));
+ OSMO_ASSERT(rc == -GMM_CAUSE_IMSI_UNKNOWN);
+ OSMO_ASSERT(last_updated_subscr == NULL);
+
+ update_subscriber_data_cb = __real_sgsn_update_subscriber_data;
+
+ cleanup_test();
+}
+
+int my_gsup_client_send_dummy(struct gsup_client *gsupc, struct msgb *msg)
+{
+ msgb_free(msg);
+ return 0;
+};
+
+/*
+ * Test that a GMM Detach will remove the MMCTX and the
+ * associated LLME.
+ */
+static void test_gmm_detach(void)
+{
+ struct gprs_ra_id raid = { 0, };
+ struct sgsn_mm_ctx *ctx, *ictx;
+ uint32_t local_tlli;
+
+ printf("Testing GMM detach\n");
+
+ /* DTAP - Detach Request (MO) */
+ /* normal detach, power_off = 0 */
+ static const unsigned char detach_req[] = {
+ 0x08, 0x05, 0x01, 0x18, 0x05, 0xf4, 0xef, 0xe2,
+ 0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb
+ };
+
+ local_tlli = gprs_tmsi2tlli(0x23, TLLI_LOCAL);
+
+ /* Create a context */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ ctx = alloc_mm_ctx(local_tlli, &raid);
+
+ /* inject the detach */
+ send_0408_message(ctx->gb.llme, local_tlli, &raid,
+ detach_req, ARRAY_SIZE(detach_req));
+
+ /* verify that a single message (hopefully the Detach Accept) has been
+ * sent by the SGSN */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+
+ /* verify that things are gone */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ ictx = sgsn_mm_ctx_by_tlli(local_tlli, &raid);
+ OSMO_ASSERT(!ictx);
+
+ cleanup_test();
+}
+
+/*
+ * Test that a GMM Detach will remove the MMCTX and the associated LLME but
+ * will not sent a Detach Accept message (power_off = 1)
+ */
+static void test_gmm_detach_power_off(void)
+{
+ struct gprs_ra_id raid = { 0, };
+ struct sgsn_mm_ctx *ctx, *ictx;
+ uint32_t local_tlli;
+
+ printf("Testing GMM detach (power off)\n");
+
+ /* DTAP - Detach Request (MO) */
+ /* normal detach, power_off = 1 */
+ static const unsigned char detach_req[] = {
+ 0x08, 0x05, 0x09, 0x18, 0x05, 0xf4, 0xef, 0xe2,
+ 0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb
+ };
+
+ local_tlli = gprs_tmsi2tlli(0x23, TLLI_LOCAL);
+
+ /* Create a context */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ ctx = alloc_mm_ctx(local_tlli, &raid);
+
+ /* inject the detach */
+ send_0408_message(ctx->gb.llme, local_tlli, &raid,
+ detach_req, ARRAY_SIZE(detach_req));
+
+ /* verify that no message (and therefore no Detach Accept) has been
+ * sent by the SGSN */
+ OSMO_ASSERT(sgsn_tx_counter == 0);
+
+ /* verify that things are gone */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ ictx = sgsn_mm_ctx_by_tlli(local_tlli, &raid);
+ OSMO_ASSERT(!ictx);
+
+ cleanup_test();
+}
+
+/*
+ * Test that a GMM Detach will remove the associated LLME if there is no MMCTX.
+ */
+static void test_gmm_detach_no_mmctx(void)
+{
+ struct gprs_ra_id raid = { 0, };
+ struct gprs_llc_lle *lle;
+ uint32_t local_tlli;
+
+ printf("Testing GMM detach (no MMCTX)\n");
+
+ /* DTAP - Detach Request (MO) */
+ /* normal detach, power_off = 0 */
+ static const unsigned char detach_req[] = {
+ 0x08, 0x05, 0x01, 0x18, 0x05, 0xf4, 0xef, 0xe2,
+ 0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb
+ };
+
+ /* Create an LLME */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ local_tlli = gprs_tmsi2tlli(0x23, TLLI_LOCAL);
+ lle = gprs_lle_get_or_create(local_tlli, 3);
+
+ OSMO_ASSERT(count(gprs_llme_list()) == 1);
+
+ /* inject the detach */
+ send_0408_message(lle->llme, local_tlli, &raid,
+ detach_req, ARRAY_SIZE(detach_req));
+
+ /* verify that the LLME is gone */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+
+ cleanup_test();
+}
+
+/*
+ * Test that a single GMM Detach Accept message will not cause the SGSN to send
+ * any message or leave an MM context at the SGSN.
+ */
+static void test_gmm_detach_accept_unexpected(void)
+{
+ struct gprs_ra_id raid = { 0, };
+ struct gprs_llc_lle *lle;
+ uint32_t local_tlli;
+
+ printf("Testing GMM detach accept (unexpected)\n");
+
+ /* DTAP - Detach Accept (MT) */
+ /* normal detach */
+ static const unsigned char detach_acc[] = {
+ 0x08, 0x06
+ };
+
+ /* Create an LLME */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ local_tlli = gprs_tmsi2tlli(0x23, TLLI_LOCAL);
+ lle = gprs_lle_get_or_create(local_tlli, 3);
+
+ /* inject the detach */
+ send_0408_message(lle->llme, local_tlli, &raid,
+ detach_acc, ARRAY_SIZE(detach_acc));
+
+ /* verify that no message (and therefore no Status or XID reset) has been
+ * sent by the SGSN */
+ OSMO_ASSERT(sgsn_tx_counter == 0);
+
+ /* verify that things are gone */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+
+ cleanup_test();
+}
+
+/*
+ * Test that a GMM Status will remove the associated LLME if there is no MMCTX.
+ */
+static void test_gmm_status_no_mmctx(void)
+{
+ struct gprs_ra_id raid = { 0, };
+ struct gprs_llc_lle *lle;
+ uint32_t local_tlli;
+
+ printf("Testing GMM Status (no MMCTX)\n");
+
+ /* DTAP - GMM Status, protocol error */
+ static const unsigned char gmm_status[] = {
+ 0x08, 0x20, 0x6f
+ };
+
+ /* Create an LLME */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ local_tlli = gprs_tmsi2tlli(0x23, TLLI_LOCAL);
+ lle = gprs_lle_get_or_create(local_tlli, 3);
+
+ OSMO_ASSERT(count(gprs_llme_list()) == 1);
+
+ /* inject the detach */
+ send_0408_message(lle->llme, local_tlli, &raid,
+ gmm_status, ARRAY_SIZE(gmm_status));
+
+ /* verify that no message has been sent by the SGSN */
+ OSMO_ASSERT(sgsn_tx_counter == 0);
+
+ /* verify that the LLME is gone */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+
+ cleanup_test();
+}
+
+/*
+ * Test the GMM Attach procedure
+ */
+static void test_gmm_attach(int retry)
+{
+ struct gprs_ra_id raid = { 0, };
+ struct sgsn_mm_ctx *ctx = NULL;
+ struct sgsn_mm_ctx *ictx;
+ uint32_t ptmsi1;
+ uint32_t foreign_tlli;
+ uint32_t local_tlli = 0;
+ struct gprs_llc_lle *lle;
+
+ /* DTAP - Attach Request */
+ /* The P-TMSI is not known by the SGSN */
+ static const unsigned char attach_req[] = {
+ 0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02, 0x05, 0xf4,
+ 0xfb, 0xc5, 0x46, 0x79, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60,
+ 0x19, 0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00, 0x60,
+ 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60, 0x80, 0xba, 0xc8,
+ 0xc6, 0x62, 0x00, 0x60, 0x80, 0x00
+ };
+
+ /* DTAP - Identity Response IMEI */
+ static const unsigned char ident_resp_imei[] = {
+ 0x08, 0x16, 0x08, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78,
+ 0x56
+ };
+
+ /* DTAP - Identity Response IMSI */
+ static const unsigned char ident_resp_imsi[] = {
+ 0x08, 0x16, 0x08, 0x19, 0x32, 0x54, 0x76, 0x98, 0x10, 0x32,
+ 0x54
+ };
+
+ /* DTAP - Authentication and Ciphering Resp */
+ static const unsigned char auth_ciph_resp[] = {
+ 0x08, 0x13, 0x00, 0x22, 0x51, 0xe5, 0x51, 0xe5, 0x23, 0x09,
+ 0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x01
+ };
+
+ /* DTAP - Attach Complete */
+ static const unsigned char attach_compl[] = {
+ 0x08, 0x03
+ };
+
+ /* DTAP - Detach Request (MO) */
+ /* normal detach, power_off = 0 */
+ static const unsigned char detach_req[] = {
+ 0x08, 0x05, 0x01, 0x18, 0x05, 0xf4, 0xeb, 0x8b,
+ 0x45, 0x67, 0x19, 0x03, 0xb9, 0x97, 0xcb
+ };
+
+ printf("Testing GMM attach%s\n", retry ? " with retry" : "");
+
+ foreign_tlli = gprs_tmsi2tlli(0xc0000023, TLLI_FOREIGN);
+
+ /* Create a LLE/LLME */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ lle = gprs_lle_get_or_create(foreign_tlli, 3);
+ OSMO_ASSERT(count(gprs_llme_list()) == 1);
+
+ /* inject the attach request */
+ send_0408_message(lle->llme, foreign_tlli, &raid,
+ attach_req, ARRAY_SIZE(attach_req));
+
+ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid);
+ OSMO_ASSERT(ctx != NULL);
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+
+ /* we expect an identity request (IMEI) */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+
+ /* inject the identity response (IMEI) */
+ send_0408_message(ctx->gb.llme, foreign_tlli, &raid,
+ ident_resp_imei, ARRAY_SIZE(ident_resp_imei));
+
+ /* we expect an identity request (IMSI) */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+
+ /* inject the identity response (IMSI) */
+ send_0408_message(ctx->gb.llme, foreign_tlli, &raid,
+ ident_resp_imsi, ARRAY_SIZE(ident_resp_imsi));
+
+ /* check that the MM context has not been removed due to a failed
+ * authorization */
+ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+
+retry_attach_req:
+
+ if (retry && sgsn_tx_counter == 0) {
+ fprintf(stderr, "Retrying attach request\n");
+ /* re-inject the attach request */
+ send_0408_message(lle->llme, foreign_tlli, &raid,
+ attach_req, ARRAY_SIZE(attach_req));
+ }
+
+ if (ctx->auth_state == SGSN_AUTH_AUTHENTICATE && sgsn_tx_counter == 1) {
+ /* we got an auth & ciph request */
+
+ /* inject the auth & ciph response */
+ send_0408_message(ctx->gb.llme, foreign_tlli, &raid,
+ auth_ciph_resp, ARRAY_SIZE(auth_ciph_resp));
+
+ /* check that the MM context has not been removed due to a
+ * failed authorization */
+ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));
+ if (ctx->subscr && ctx->subscr->sgsn_data->msisdn_len > 0)
+ OSMO_ASSERT(strcmp(ctx->msisdn, "+49166213323") == 0);
+ }
+
+ if (retry && sgsn_tx_counter == 0)
+ goto retry_attach_req;
+
+ /* we expect an attach accept/reject */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+ ptmsi1 = get_new_ptmsi(&last_dl_parse_ctx);
+ OSMO_ASSERT(ptmsi1 != GSM_RESERVED_TMSI);
+
+ /* this has been randomly assigned by the SGSN */
+ local_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
+
+ /* inject the attach complete */
+ send_0408_message(ctx->gb.llme, local_tlli, &raid,
+ attach_compl, ARRAY_SIZE(attach_compl));
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
+
+ /* we don't expect a response */
+ OSMO_ASSERT(sgsn_tx_counter == 0);
+
+ /* inject the detach */
+ send_0408_message(ctx->gb.llme, local_tlli, &raid,
+ detach_req, ARRAY_SIZE(detach_req));
+
+ /* verify that things are gone */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ ictx = sgsn_mm_ctx_by_tlli(local_tlli, &raid);
+ OSMO_ASSERT(!ictx);
+
+ cleanup_test();
+}
+
+static void test_gmm_attach_acl(void)
+{
+ const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
+
+ sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_CLOSED;
+ sgsn_acl_add("123456789012345", &sgsn->cfg);
+ printf("Auth policy 'closed': ");
+ test_gmm_attach(0);
+ sgsn_acl_del("123456789012345", &sgsn->cfg);
+
+ sgsn->cfg.auth_policy = saved_auth_policy;
+
+ cleanup_test();
+}
+
+int my_subscr_request_update_location(struct sgsn_mm_ctx *mmctx) {
+ int rc;
+ rc = __real_gprs_subscr_request_update_location(mmctx);
+ if (rc == -ENOTSUP) {
+ OSMO_ASSERT(mmctx->subscr);
+ gprs_subscr_update(mmctx->subscr);
+ }
+ return rc;
+};
+
+int my_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx) {
+ gprs_subscr_update(mmctx->subscr);
+ return 0;
+};
+
+static void test_gmm_attach_subscr(void)
+{
+ const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
+ struct gprs_subscr *subscr;
+
+ sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
+ subscr_request_update_location_cb = my_subscr_request_update_location;
+ subscr_request_auth_info_cb = my_subscr_request_auth_info;
+
+ subscr = gprs_subscr_get_or_create("123456789012345");
+ subscr->authorized = 1;
+
+ printf("Auth policy 'remote': ");
+ test_gmm_attach(0);
+ gprs_subscr_put(subscr);
+ assert_no_subscrs();
+
+ sgsn->cfg.auth_policy = saved_auth_policy;
+ subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
+ subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;
+
+ cleanup_test();
+}
+
+int my_subscr_request_auth_info_fake_auth(struct sgsn_mm_ctx *mmctx)
+{
+ /* Fake an authentication */
+ OSMO_ASSERT(mmctx->subscr);
+ mmctx->is_authenticated = 1;
+ gprs_subscr_update_auth_info(mmctx->subscr);
+
+ return 0;
+};
+
+static void test_gmm_attach_subscr_fake_auth(void)
+{
+ const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
+ struct gprs_subscr *subscr;
+
+ sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
+ subscr_request_update_location_cb = my_subscr_request_update_location;
+ subscr_request_auth_info_cb = my_subscr_request_auth_info_fake_auth;
+
+ subscr = gprs_subscr_get_or_create("123456789012345");
+ subscr->authorized = 1;
+ sgsn->cfg.require_authentication = 1;
+ sgsn->cfg.require_update_location = 1;
+
+ printf("Auth policy 'remote', auth faked: ");
+ test_gmm_attach(0);
+ gprs_subscr_put(subscr);
+ assert_no_subscrs();
+
+ sgsn->cfg.auth_policy = saved_auth_policy;
+ subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
+ subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;
+
+ cleanup_test();
+}
+
+int my_subscr_request_auth_info_real_auth(struct sgsn_mm_ctx *mmctx)
+{
+ struct gsm_auth_tuple at = {
+ .vec.sres = {0x51, 0xe5, 0x51, 0xe5},
+ .vec.auth_types = OSMO_AUTH_TYPE_GSM,
+ .key_seq = 0
+ };
+
+ /* Fake an authentication */
+ OSMO_ASSERT(mmctx->subscr);
+ mmctx->subscr->sgsn_data->auth_triplets[0] = at;
+
+ gprs_subscr_update_auth_info(mmctx->subscr);
+
+ return 0;
+};
+
+static void test_gmm_attach_subscr_real_auth(void)
+{
+ const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
+ struct gprs_subscr *subscr;
+
+ sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
+ subscr_request_update_location_cb = my_subscr_request_update_location;
+ subscr_request_auth_info_cb = my_subscr_request_auth_info_real_auth;
+
+ subscr = gprs_subscr_get_or_create("123456789012345");
+ subscr->authorized = 1;
+ sgsn->cfg.require_authentication = 1;
+ sgsn->cfg.require_update_location = 1;
+
+ printf("Auth policy 'remote', triplet based auth: ");
+
+ test_gmm_attach(0);
+ gprs_subscr_put(subscr);
+ assert_no_subscrs();
+
+ sgsn->cfg.auth_policy = saved_auth_policy;
+ subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
+ subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;
+
+ cleanup_test();
+}
+
+#define TEST_GSUP_IMSI_LONG_IE 0x01, 0x08, \
+ 0x21, 0x43, 0x65, 0x87, 0x09, 0x21, 0x43, 0xf5
+
+static int auth_info_skip = 0;
+static int upd_loc_skip = 0;
+
+int my_subscr_request_auth_info_gsup_auth(struct sgsn_mm_ctx *mmctx)
+{
+ static const uint8_t send_auth_info_res[] = {
+ 0x0a,
+ TEST_GSUP_IMSI_LONG_IE,
+ 0x03, 0x22, /* Auth tuple */
+ 0x20, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x21, 0x04,
+ 0x51, 0xe5, 0x51, 0xe5,
+ 0x22, 0x08,
+ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
+ };
+
+ OSMO_ASSERT(!mmctx || mmctx->subscr);
+
+ if (auth_info_skip > 0) {
+ auth_info_skip -= 1;
+ return -EAGAIN;
+ }
+
+ /* Fake an SendAuthInfoRes */
+ rx_gsup_message(send_auth_info_res, sizeof(send_auth_info_res));
+
+ return 0;
+};
+
+int my_subscr_request_update_gsup_auth(struct sgsn_mm_ctx *mmctx) {
+ static const uint8_t update_location_res[] = {
+ 0x06,
+ TEST_GSUP_IMSI_LONG_IE,
+ 0x04, 0x00, /* PDP info complete */
+ 0x05, 0x12,
+ 0x10, 0x01, 0x01,
+ 0x11, 0x02, 0xf1, 0x21, /* IPv4 */
+ 0x12, 0x09, 0x04, 't', 'e', 's', 't', 0x03, 'a', 'p', 'n',
+ 0x08, 0x07, /* MSISDN 49166213323 encoded */
+ 0x91, 0x94, 0x61, 0x26, 0x31, 0x23, 0xF3,
+ 0x09, 0x07, /* MSISDN 38166213323 encoded */
+ 0x91, 0x83, 0x61, 0x26, 0x31, 0x23, 0xF3,
+ };
+
+ OSMO_ASSERT(!mmctx || mmctx->subscr);
+
+ if (upd_loc_skip > 0) {
+ upd_loc_skip -= 1;
+ return -EAGAIN;
+ }
+
+ /* Fake an UpdateLocRes */
+ return rx_gsup_message(update_location_res, sizeof(update_location_res));
+};
+
+
+static void test_gmm_attach_subscr_gsup_auth(int retry)
+{
+ const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
+ struct gprs_subscr *subscr;
+
+ sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
+ subscr_request_update_location_cb = my_subscr_request_update_gsup_auth;
+ subscr_request_auth_info_cb = my_subscr_request_auth_info_gsup_auth;
+ if (retry) {
+ upd_loc_skip = 3;
+ auth_info_skip = 3;
+ }
+
+ subscr = gprs_subscr_get_or_create("123456789012345");
+ subscr->authorized = 1;
+ sgsn->cfg.require_authentication = 1;
+ sgsn->cfg.require_update_location = 1;
+ gprs_subscr_put(subscr);
+
+ printf("Auth policy 'remote', GSUP based auth: ");
+ test_gmm_attach(retry);
+ assert_no_subscrs();
+
+ sgsn->cfg.auth_policy = saved_auth_policy;
+ subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
+ subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;
+ upd_loc_skip = 0;
+ auth_info_skip = 0;
+
+ cleanup_test();
+}
+
+int my_gsup_client_send(struct gsup_client *gsupc, struct msgb *msg)
+{
+ struct osmo_gsup_message to_peer = {0};
+ struct osmo_gsup_message from_peer = {0};
+ struct msgb *reply_msg;
+ int rc;
+
+ /* Simulate the GSUP peer */
+ rc = osmo_gsup_decode(msgb_data(msg), msgb_length(msg), &to_peer);
+ OSMO_ASSERT(rc >= 0);
+ OSMO_ASSERT(to_peer.imsi[0] != 0);
+ osmo_strlcpy(from_peer.imsi, to_peer.imsi, sizeof(from_peer.imsi));
+
+ /* This invalidates the pointers in to_peer */
+ msgb_free(msg);
+
+ switch (to_peer.message_type) {
+ case OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST:
+ /* Send UPDATE_LOCATION_RESULT */
+ return my_subscr_request_update_gsup_auth(NULL);
+
+ case OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST:
+ /* Send SEND_AUTH_INFO_RESULT */
+ return my_subscr_request_auth_info_gsup_auth(NULL);
+
+ case OSMO_GSUP_MSGT_PURGE_MS_REQUEST:
+ from_peer.message_type = OSMO_GSUP_MSGT_PURGE_MS_RESULT;
+ break;
+
+ default:
+ if ((to_peer.message_type & 0b00000011) == 0) {
+ /* Unhandled request */
+ /* Send error(NOT_IMPL) */
+ from_peer.message_type = to_peer.message_type + 1;
+ from_peer.cause = GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL;
+ break;
+ }
+
+ /* Ignore it */
+ return 0;
+ }
+
+ reply_msg = gsup_client_msgb_alloc();
+ reply_msg->l2h = reply_msg->data;
+ osmo_gsup_encode(reply_msg, &from_peer);
+ gprs_subscr_rx_gsup_message(reply_msg);
+ msgb_free(reply_msg);
+
+ return 0;
+};
+
+static void test_gmm_attach_subscr_real_gsup_auth(int retry)
+{
+ const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
+ struct gprs_subscr *subscr;
+
+ sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
+ gsup_client_send_cb = my_gsup_client_send;
+
+ sgsn->gsup_client = talloc_zero(tall_bsc_ctx, struct gsup_client);
+
+ if (retry) {
+ upd_loc_skip = 3;
+ auth_info_skip = 3;
+ }
+
+ printf("Auth policy 'remote', real GSUP based auth: ");
+ test_gmm_attach(retry);
+
+ subscr = gprs_subscr_get_by_imsi("123456789012345");
+ OSMO_ASSERT(subscr == NULL);
+ assert_no_subscrs();
+
+ sgsn->cfg.auth_policy = saved_auth_policy;
+ gsup_client_send_cb = __real_gsup_client_send;
+ upd_loc_skip = 0;
+ auth_info_skip = 0;
+ talloc_free(sgsn->gsup_client);
+ sgsn->gsup_client = NULL;
+
+ cleanup_test();
+}
+
+/*
+ * Test the GMM Rejects
+ */
+static void test_gmm_reject(void)
+{
+ struct gprs_ra_id raid = { 0, };
+ struct sgsn_mm_ctx *ctx = NULL;
+ uint32_t foreign_tlli;
+ struct gprs_llc_lle *lle;
+ int idx;
+
+ /* DTAP - Attach Request */
+ /* Invalid MI length */
+ static const unsigned char attach_req_inv_mi_len[] = {
+ 0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02, 0x09, 0xf4,
+ 0xfb, 0xc5, 0x46, 0x79, 0xff, 0xff, 0xff, 0xff, 0x11, 0x22,
+ 0x33, 0x40, 0x50, 0x60, 0x19, 0x18, 0xb3, 0x43, 0x2b, 0x25,
+ 0x96, 0x62, 0x00, 0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00,
+ 0x60, 0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80, 0x00
+ };
+
+ /* DTAP - Attach Request */
+ /* Invalid MI type (IMEI) */
+ static const unsigned char attach_req_inv_mi_type[] = {
+ 0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02, 0x05, 0xf2,
+ 0xfb, 0xc5, 0x46, 0x79, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60,
+ 0x19, 0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00, 0x60,
+ 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60, 0x80, 0xba, 0xc8,
+ 0xc6, 0x62, 0x00, 0x60, 0x80, 0x00
+ };
+
+ /* DTAP - Routing Area Update Request */
+ static const unsigned char dtap_ra_upd_req[] = {
+ 0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,
+ 0x60, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
+ 0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
+ 0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
+ 0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
+ 0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
+ 0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
+ };
+
+ /* DTAP - Routing Area Update Request */
+ /* Invalid type: GPRS_UPD_T_RA_LA_IMSI_ATT */
+ static const unsigned char dtap_ra_upd_req_inv_type[] = {
+ 0x08, 0x08, 0x12, 0x11, 0x22, 0x33, 0x40, 0x50,
+ 0x60, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
+ 0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
+ 0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
+ 0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
+ 0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
+ 0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
+ };
+
+ /* DTAP - Routing Area Update Request */
+ /* Invalid cap length */
+ static const unsigned char dtap_ra_upd_req_inv_cap_len[] = {
+ 0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,
+ 0x60, 0x3d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
+ 0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
+ 0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
+ 0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
+ 0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
+ };
+
+ struct test {
+ const char *title;
+ const unsigned char *msg;
+ unsigned msg_len;
+ unsigned num_resp;
+
+ };
+ static struct test tests[] = {
+ {
+ .title = "Attach Request (invalid MI length)",
+ .msg = attach_req_inv_mi_len,
+ .msg_len = sizeof(attach_req_inv_mi_len),
+ .num_resp = 1 /* Reject */
+
+ },
+ {
+ .title = "Attach Request (invalid MI type)",
+ .msg = attach_req_inv_mi_type,
+ .msg_len = sizeof(attach_req_inv_mi_type),
+ .num_resp = 1 /* Reject */
+ },
+ {
+ .title = "Routing Area Update Request (valid)",
+ .msg = dtap_ra_upd_req,
+ .msg_len = sizeof(dtap_ra_upd_req),
+ .num_resp = 2 /* XID Reset + Reject */
+ },
+ {
+ .title = "Routing Area Update Request (invalid type)",
+ .msg = dtap_ra_upd_req_inv_type,
+ .msg_len = sizeof(dtap_ra_upd_req_inv_type),
+ .num_resp = 1 /* Reject */
+ },
+ {
+ .title = "Routing Area Update Request (invalid CAP length)",
+ .msg = dtap_ra_upd_req_inv_cap_len,
+ .msg_len = sizeof(dtap_ra_upd_req_inv_cap_len),
+ .num_resp = 1 /* Reject */
+ },
+ };
+
+ printf("Testing GMM reject\n");
+
+ /* reset the PRNG used by sgsn_alloc_ptmsi */
+ srand(1);
+
+ foreign_tlli = gprs_tmsi2tlli(0xc0000023, TLLI_FOREIGN);
+
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+
+ for (idx = 0; idx < ARRAY_SIZE(tests); idx++) {
+ const struct test *test = &tests[idx];
+ printf(" - %s\n", test->title);
+
+ /* Create a LLE/LLME */
+ lle = gprs_lle_get_or_create(foreign_tlli, 3);
+ OSMO_ASSERT(count(gprs_llme_list()) == 1);
+
+ /* Inject the Request message */
+ send_0408_message(lle->llme, foreign_tlli, &raid,
+ test->msg, test->msg_len);
+
+ /* We expect a Reject message */
+ fprintf(stderr, "sgsn_tx_counter = %d (expected %d)\n",
+ sgsn_tx_counter, test->num_resp);
+ OSMO_ASSERT(sgsn_tx_counter == test->num_resp);
+
+ /* verify that LLME/MM are removed */
+ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid);
+ OSMO_ASSERT(ctx == NULL);
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ }
+
+ cleanup_test();
+}
+
+/*
+ * Test cancellation of attached MM contexts
+ */
+static void test_gmm_cancel(void)
+{
+ struct gprs_ra_id raid = { 0, };
+ struct sgsn_mm_ctx *ctx = NULL;
+ struct sgsn_mm_ctx *ictx;
+ uint32_t ptmsi1;
+ uint32_t foreign_tlli;
+ uint32_t local_tlli = 0;
+ struct gprs_llc_lle *lle;
+ const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
+
+ /* DTAP - Attach Request */
+ /* The P-TMSI is not known by the SGSN */
+ static const unsigned char attach_req[] = {
+ 0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02, 0x05, 0xf4,
+ 0xfb, 0xc5, 0x46, 0x79, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60,
+ 0x19, 0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00, 0x60,
+ 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60, 0x80, 0xba, 0xc8,
+ 0xc6, 0x62, 0x00, 0x60, 0x80, 0x00
+ };
+
+ /* DTAP - Identity Response IMEI */
+ static const unsigned char ident_resp_imei[] = {
+ 0x08, 0x16, 0x08, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78,
+ 0x56
+ };
+
+ /* DTAP - Identity Response IMSI */
+ static const unsigned char ident_resp_imsi[] = {
+ 0x08, 0x16, 0x08, 0x19, 0x32, 0x54, 0x76, 0x98, 0x10, 0x32,
+ 0x54
+ };
+
+ /* DTAP - Attach Complete */
+ static const unsigned char attach_compl[] = {
+ 0x08, 0x03
+ };
+
+ printf("Testing cancellation\n");
+
+ sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_OPEN;
+
+ foreign_tlli = gprs_tmsi2tlli(0xc0000023, TLLI_FOREIGN);
+
+ /* Create a LLE/LLME */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ lle = gprs_lle_get_or_create(foreign_tlli, 3);
+ OSMO_ASSERT(count(gprs_llme_list()) == 1);
+
+ /* inject the attach request */
+ send_0408_message(lle->llme, foreign_tlli, &raid,
+ attach_req, ARRAY_SIZE(attach_req));
+
+ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid);
+ OSMO_ASSERT(ctx != NULL);
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+
+ /* we expect an identity request (IMEI) */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+
+ /* inject the identity response (IMEI) */
+ send_0408_message(ctx->gb.llme, foreign_tlli, &raid,
+ ident_resp_imei, ARRAY_SIZE(ident_resp_imei));
+
+ /* we expect an identity request (IMSI) */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+
+ /* inject the identity response (IMSI) */
+ send_0408_message(ctx->gb.llme, foreign_tlli, &raid,
+ ident_resp_imsi, ARRAY_SIZE(ident_resp_imsi));
+
+ /* check that the MM context has not been removed due to a failed
+ * authorization */
+ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+
+ /* we expect an attach accept/reject */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+ ptmsi1 = get_new_ptmsi(&last_dl_parse_ctx);
+ OSMO_ASSERT(ptmsi1 != GSM_RESERVED_TMSI);
+
+ /* this has been randomly assigned by the SGSN */
+ local_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
+
+ /* inject the attach complete */
+ send_0408_message(ctx->gb.llme, foreign_tlli, &raid,
+ attach_compl, ARRAY_SIZE(attach_compl));
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
+
+ /* we don't expect a response */
+ OSMO_ASSERT(sgsn_tx_counter == 0);
+
+ /* cancel */
+ gsm0408_gprs_access_cancelled(ctx, 0);
+
+ /* verify that things are gone */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ ictx = sgsn_mm_ctx_by_tlli(local_tlli, &raid);
+ OSMO_ASSERT(!ictx);
+
+ sgsn->cfg.auth_policy = saved_auth_policy;
+
+ cleanup_test();
+}
+
+/*
+ * Test the dynamic allocation of P-TMSIs
+ */
+static void test_gmm_ptmsi_allocation(void)
+{
+ struct gprs_ra_id raid = {332, 112, 16464, 96};
+ struct sgsn_mm_ctx *ctx = NULL;
+ struct sgsn_mm_ctx *ictx;
+ uint32_t foreign_tlli;
+ uint32_t ptmsi1;
+ uint32_t ptmsi2;
+ uint32_t received_ptmsi;
+ uint32_t old_ptmsi;
+ uint32_t local_tlli = 0;
+ struct gprs_llc_lle *lle;
+ const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
+
+ /* DTAP - Attach Request (IMSI 12131415161718) */
+ static const unsigned char attach_req[] = {
+ 0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,
+ 0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60, 0x19,
+ 0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00,
+ 0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60,
+ 0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80,
+ 0x00,
+ };
+
+ /* DTAP - Identity Response IMEI */
+ static const unsigned char ident_resp_imei[] = {
+ 0x08, 0x16, 0x08, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78,
+ 0x56
+ };
+
+ /* DTAP - Attach Complete */
+ static const unsigned char attach_compl[] = {
+ 0x08, 0x03
+ };
+
+ /* DTAP - Routing Area Update Request */
+ static const unsigned char ra_upd_req[] = {
+ 0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,
+ 0x60, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
+ 0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
+ 0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
+ 0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
+ 0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
+ 0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
+ };
+
+ /* DTAP - Routing Area Update Complete */
+ static const unsigned char ra_upd_complete[] = {
+ 0x08, 0x0a
+ };
+
+ /* DTAP - Detach Request (MO) */
+ /* normal detach, power_off = 1 */
+ static const unsigned char detach_req[] = {
+ 0x08, 0x05, 0x09, 0x18, 0x05, 0xf4, 0xef, 0xe2,
+ 0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb
+ };
+
+ sgsn->cfg.auth_policy = SGSN_AUTH_POLICY_OPEN;
+
+ printf("Testing P-TMSI allocation\n");
+
+ printf(" - sgsn_alloc_ptmsi\n");
+
+ /* reset the PRNG used by sgsn_alloc_ptmsi */
+ srand(1);
+
+ ptmsi1 = sgsn_alloc_ptmsi();
+ OSMO_ASSERT(ptmsi1 != GSM_RESERVED_TMSI);
+
+ ptmsi2 = sgsn_alloc_ptmsi();
+ OSMO_ASSERT(ptmsi2 != GSM_RESERVED_TMSI);
+
+ OSMO_ASSERT(ptmsi1 != ptmsi2);
+
+ ptmsi1 = ptmsi2 = GSM_RESERVED_TMSI;
+
+ printf(" - Repeated Attach Request\n");
+
+ foreign_tlli = gprs_tmsi2tlli(0xc0000023, TLLI_FOREIGN);
+
+ /* Create a LLE/LLME */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ lle = gprs_lle_get_or_create(foreign_tlli, 3);
+ OSMO_ASSERT(count(gprs_llme_list()) == 1);
+
+ /* inject the attach request */
+ send_0408_message(lle->llme, foreign_tlli, &raid,
+ attach_req, ARRAY_SIZE(attach_req));
+
+ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid);
+ OSMO_ASSERT(ctx != NULL);
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+ OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
+ ptmsi1 = ctx->p_tmsi;
+
+ old_ptmsi = ctx->p_tmsi_old;
+
+ /* we expect an identity request (IMEI) */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+
+ /* inject the identity response (IMEI) */
+ send_0408_message(ctx->gb.llme, foreign_tlli, &raid,
+ ident_resp_imei, ARRAY_SIZE(ident_resp_imei));
+
+ /* check that the MM context has not been removed due to a failed
+ * authorization */
+ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+ OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
+
+ /* we expect an attach accept */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+ received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
+ OSMO_ASSERT(received_ptmsi == ptmsi1);
+
+ /* we ignore this and send the attach again */
+ send_0408_message(lle->llme, foreign_tlli, &raid,
+ attach_req, ARRAY_SIZE(attach_req));
+
+ /* the allocated P-TMSI should be the same */
+ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid);
+ OSMO_ASSERT(ctx != NULL);
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+ OSMO_ASSERT(ctx->p_tmsi_old == old_ptmsi);
+ OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
+
+ /* we expect an attach accept */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+ received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
+ OSMO_ASSERT(received_ptmsi == ptmsi1);
+
+ /* inject the attach complete */
+ local_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
+ send_0408_message(ctx->gb.llme, local_tlli, &raid,
+ attach_compl, ARRAY_SIZE(attach_compl));
+
+ /* we don't expect a response */
+ OSMO_ASSERT(sgsn_tx_counter == 0);
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
+ OSMO_ASSERT(ctx->p_tmsi_old == 0);
+ OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
+
+ printf(" - Repeated RA Update Request\n");
+
+ /* inject the RA update request */
+ send_0408_message(ctx->gb.llme, local_tlli, &raid,
+ ra_upd_req, ARRAY_SIZE(ra_upd_req));
+
+ /* we expect an RA update accept */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+ OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);
+ OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
+ OSMO_ASSERT(ctx->p_tmsi != ptmsi1);
+ ptmsi2 = ctx->p_tmsi;
+
+ /* repeat the RA update request */
+ send_0408_message(ctx->gb.llme, local_tlli, &raid,
+ ra_upd_req, ARRAY_SIZE(ra_upd_req));
+
+ /* we expect an RA update accept */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+ received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
+ OSMO_ASSERT(received_ptmsi == ptmsi2);
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+ OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);
+ OSMO_ASSERT(ctx->p_tmsi == ptmsi2);
+
+ /* inject the RA update complete */
+ local_tlli = gprs_tmsi2tlli(ptmsi2, TLLI_LOCAL);
+ send_0408_message(ctx->gb.llme, local_tlli, &raid,
+ ra_upd_complete, ARRAY_SIZE(ra_upd_complete));
+
+ /* we don't expect a response */
+ OSMO_ASSERT(sgsn_tx_counter == 0);
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
+ OSMO_ASSERT(ctx->p_tmsi_old == 0);
+ OSMO_ASSERT(ctx->p_tmsi == ptmsi2);
+
+ /* inject the detach */
+ send_0408_message(ctx->gb.llme, local_tlli, &raid,
+ detach_req, ARRAY_SIZE(detach_req));
+
+ /* verify that things are gone */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ ictx = sgsn_mm_ctx_by_tlli(local_tlli, &raid);
+ OSMO_ASSERT(!ictx);
+
+ sgsn->cfg.auth_policy = saved_auth_policy;
+
+ cleanup_test();
+}
+
+/*
+ * Test changing of routing areas
+ */
+static void test_gmm_routing_areas(void)
+{
+ struct gprs_ra_id raid1 = {332, 112, 16464, 96};
+ struct gprs_ra_id raid2 = {332, 112, 16464, 97};
+ struct sgsn_mm_ctx *ctx = NULL;
+ struct sgsn_mm_ctx *ictx;
+ uint32_t ptmsi1;
+ uint32_t received_ptmsi;
+ uint32_t ms_tlli = 0;
+ struct gprs_llc_lle *lle;
+ const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
+
+ /* DTAP - Attach Request (IMSI 12131415161718) */
+ static const unsigned char attach_req[] = {
+ 0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,
+ 0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60, 0x19,
+ 0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00,
+ 0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60,
+ 0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80,
+ 0x00,
+ };
+
+ /* DTAP - Attach Request (IMSI 12131415161718) (RA 2) */
+ static const unsigned char attach_req2[] = {
+ 0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,
+ 0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x11, 0x22, 0x33, 0x40, 0x50, 0x61, 0x19,
+ 0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00,
+ 0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60,
+ 0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80,
+ 0x00,
+ };
+
+ /* DTAP - Identity Response IMEI */
+ static const unsigned char ident_resp_imei[] = {
+ 0x08, 0x16, 0x08, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78,
+ 0x56
+ };
+
+ /* DTAP - Attach Complete */
+ static const unsigned char attach_compl[] = {
+ 0x08, 0x03
+ };
+
+ /* DTAP - Routing Area Update Request (coming from RA 1) */
+ static const unsigned char ra_upd_req1[] = {
+ 0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,
+ 0x60, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
+ 0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
+ 0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
+ 0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
+ 0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
+ 0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
+ };
+
+ /* DTAP - Routing Area Update Request (coming from RA 2) */
+ static const unsigned char ra_upd_req2[] = {
+ 0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,
+ 0x61, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
+ 0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
+ 0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
+ 0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
+ 0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
+ 0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
+ };
+
+ /* DTAP - Routing Area Update Request (coming from RA other) */
+ /* raid_other = {443, 223, 16464, 98}; */
+ static const unsigned char ra_upd_req_other[] = {
+ 0x08, 0x08, 0x10, 0x22, 0x33, 0x44, 0x40, 0x50,
+ 0x62, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
+ 0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
+ 0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
+ 0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
+ 0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
+ 0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
+ };
+
+ /* DTAP - Routing Area Update Complete */
+ static const unsigned char ra_upd_complete[] = {
+ 0x08, 0x0a
+ };
+
+ /* DTAP - Detach Request (MO) */
+ /* normal detach, power_off = 1 */
+ static const unsigned char detach_req[] = {
+ 0x08, 0x05, 0x09, 0x18, 0x05, 0xf4, 0xef, 0xe2,
+ 0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb
+ };
+
+ sgsn->cfg.auth_policy = SGSN_AUTH_POLICY_OPEN;
+
+ printf("Testing routing area changes\n");
+
+ /* reset the PRNG used by sgsn_alloc_ptmsi */
+ srand(1);
+
+ ptmsi1 = GSM_RESERVED_TMSI;
+
+ printf(" - Attach Request (RA 1)\n");
+
+ ms_tlli = gprs_tmsi2tlli(0x00000023, TLLI_RANDOM);
+
+ /* Create a LLE/LLME */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ lle = gprs_lle_get_or_create(ms_tlli, 3);
+ OSMO_ASSERT(count(gprs_llme_list()) == 1);
+
+ /* inject the attach request */
+ send_0408_message(lle->llme, ms_tlli, &raid1,
+ attach_req, ARRAY_SIZE(attach_req));
+
+ ctx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid1);
+ OSMO_ASSERT(ctx != NULL);
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+ OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
+
+ /* we expect an identity request (IMEI) */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+ OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_ID_REQ);
+ OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli);
+
+ /* inject the identity response (IMEI) */
+ send_0408_message(ctx->gb.llme, ms_tlli, &raid1,
+ ident_resp_imei, ARRAY_SIZE(ident_resp_imei));
+
+ /* check that the MM context has not been removed due to a failed
+ * authorization */
+ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(ms_tlli, &raid1));
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+
+ /* we expect an attach accept */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+ OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_ATTACH_ACK);
+ OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli);
+
+ received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
+ OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);
+ ptmsi1 = received_ptmsi;
+
+ /* inject the attach complete */
+ ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
+ send_0408_message(ctx->gb.llme, ms_tlli, &raid1,
+ attach_compl, ARRAY_SIZE(attach_compl));
+
+ /* we don't expect a response */
+ OSMO_ASSERT(sgsn_tx_counter == 0);
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
+ OSMO_ASSERT(ctx->p_tmsi_old == 0);
+ OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
+
+ printf(" - RA Update Request (RA 1 -> RA 1)\n");
+
+ /* inject the RA update request */
+ send_0408_message(ctx->gb.llme, ms_tlli, &raid1,
+ ra_upd_req1, ARRAY_SIZE(ra_upd_req1));
+
+ /* we expect an RA update accept */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+ OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK);
+ // OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli);
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+ OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);
+ OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
+ OSMO_ASSERT(ctx->p_tmsi != ptmsi1);
+
+ received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
+ OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);
+ ptmsi1 = received_ptmsi;
+
+ /* inject the RA update complete */
+ ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
+ send_0408_message(ctx->gb.llme, ms_tlli, &raid1,
+ ra_upd_complete, ARRAY_SIZE(ra_upd_complete));
+
+ /* we don't expect a response */
+ OSMO_ASSERT(sgsn_tx_counter == 0);
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
+ OSMO_ASSERT(ctx->p_tmsi_old == 0);
+ OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
+ OSMO_ASSERT(ctx->gb.tlli == ms_tlli);
+
+ printf(" - RA Update Request (RA 1 -> RA 2)\n");
+
+ /* inject the RA update request */
+ ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_FOREIGN);
+
+ /* It is coming from RA 1 => ra_upd_req1 */
+ send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
+ ra_upd_req1, ARRAY_SIZE(ra_upd_req1));
+
+ /* we expect an RA update accept */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+ OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK);
+
+ printf(" - RA Update Request (RA other -> RA 2)\n");
+
+ /* inject the RA update request */
+ ms_tlli = gprs_tmsi2tlli(0x12345678, TLLI_FOREIGN);
+
+ /* It is coming from RA 1 => ra_upd_req1 */
+ send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
+ ra_upd_req_other, ARRAY_SIZE(ra_upd_req_other));
+
+ /* we expect an RA update reject (and a LLC XID RESET) */
+ OSMO_ASSERT(sgsn_tx_counter == 2);
+ OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_REJ);
+ /* this has killed the LLE/LLME */
+
+ printf(" - Attach Request (RA 2)\n");
+
+ /* Create a LLE/LLME */
+ OSMO_ASSERT(count(gprs_llme_list()) == 1);
+ lle = gprs_lle_get_or_create(ms_tlli, 3);
+ OSMO_ASSERT(count(gprs_llme_list()) == 1);
+
+ /* inject the attach request */
+ send_0408_message(lle->llme, ms_tlli, &raid2,
+ attach_req2, ARRAY_SIZE(attach_req2));
+
+ ctx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid2);
+ OSMO_ASSERT(ctx != NULL);
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+ OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
+
+ /* we expect an attach accept */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+ OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_ATTACH_ACK);
+
+ received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
+ OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);
+ ptmsi1 = received_ptmsi;
+
+ /* inject the attach complete */
+ ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
+ ictx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid2);
+ OSMO_ASSERT(ictx != NULL);
+ OSMO_ASSERT(ictx == ctx);
+
+ send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
+ attach_compl, ARRAY_SIZE(attach_compl));
+
+ /* we don't expect a response */
+ OSMO_ASSERT(sgsn_tx_counter == 0);
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
+ OSMO_ASSERT(ctx->p_tmsi_old == 0);
+ OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
+
+ printf(" - RA Update Request (RA 2 -> RA 2)\n");
+
+ /* inject the RA update request */
+ send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
+ ra_upd_req2, ARRAY_SIZE(ra_upd_req2));
+
+ /* we expect an RA update accept */
+ OSMO_ASSERT(sgsn_tx_counter == 1);
+ OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK);
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
+ OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);
+ OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
+ OSMO_ASSERT(ctx->p_tmsi != ptmsi1);
+
+ received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
+ OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);
+ ptmsi1 = received_ptmsi;
+
+ /* inject the RA update complete */
+ ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
+ send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
+ ra_upd_complete, ARRAY_SIZE(ra_upd_complete));
+
+ /* we don't expect a response */
+ OSMO_ASSERT(sgsn_tx_counter == 0);
+
+ OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
+ OSMO_ASSERT(ctx->p_tmsi_old == 0);
+ OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
+ OSMO_ASSERT(ctx->gb.tlli == ms_tlli);
+
+
+ /* inject the detach */
+ send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
+ detach_req, ARRAY_SIZE(detach_req));
+
+ /* verify that things are gone */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ ictx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid2);
+ OSMO_ASSERT(!ictx);
+
+ sgsn->cfg.auth_policy = saved_auth_policy;
+
+ cleanup_test();
+}
+
+static void test_apn_matching(void)
+{
+ struct apn_ctx *actx, *actxs[9];
+
+ printf("Testing APN matching\n");
+
+ actxs[0] = sgsn_apn_ctx_find_alloc("*.test", "");
+ actxs[1] = sgsn_apn_ctx_find_alloc("*.def.test", "");
+ actxs[2] = sgsn_apn_ctx_find_alloc("abc.def.test", "");
+ actxs[3] = NULL;
+
+ actxs[4] = sgsn_apn_ctx_find_alloc("abc.def.test", "456");
+ actxs[5] = sgsn_apn_ctx_find_alloc("abc.def.test", "456123");
+ actxs[6] = sgsn_apn_ctx_find_alloc("*.def.test", "456");
+ actxs[7] = sgsn_apn_ctx_find_alloc("*.def.test", "456123");
+
+ actxs[8] = sgsn_apn_ctx_find_alloc("ghi.def.test", "456");
+
+ actx = sgsn_apn_ctx_match("abc.def.test", "12345678");
+ OSMO_ASSERT(actx == actxs[2]);
+ actx = sgsn_apn_ctx_match("aBc.dEf.test", "12345678");
+ OSMO_ASSERT(actx == actxs[2]);
+ actx = sgsn_apn_ctx_match("xyz.def.test", "12345678");
+ OSMO_ASSERT(actx == actxs[1]);
+ actx = sgsn_apn_ctx_match("xyz.dEf.test", "12345678");
+ OSMO_ASSERT(actx == actxs[1]);
+ actx = sgsn_apn_ctx_match("xyz.uvw.test", "12345678");
+ OSMO_ASSERT(actx == actxs[0]);
+ actx = sgsn_apn_ctx_match("xyz.uvw.foo", "12345678");
+ OSMO_ASSERT(actx == NULL);
+
+ actxs[3] = sgsn_apn_ctx_find_alloc("*", "");
+ actx = sgsn_apn_ctx_match("xyz.uvw.foo", "12345678");
+ OSMO_ASSERT(actx == actxs[3]);
+
+ actx = sgsn_apn_ctx_match("abc.def.test", "45699900");
+ OSMO_ASSERT(actx == actxs[4]);
+
+ actx = sgsn_apn_ctx_match("xyz.def.test", "45699900");
+ OSMO_ASSERT(actx == actxs[6]);
+
+ actx = sgsn_apn_ctx_match("abc.def.test", "45612300");
+ OSMO_ASSERT(actx == actxs[5]);
+
+ actx = sgsn_apn_ctx_match("xyz.def.test", "45612300");
+ OSMO_ASSERT(actx == actxs[7]);
+
+ actx = sgsn_apn_ctx_match("ghi.def.test", "45699900");
+ OSMO_ASSERT(actx == actxs[8]);
+
+ actx = sgsn_apn_ctx_match("ghi.def.test", "45612300");
+ OSMO_ASSERT(actx == actxs[7]);
+
+ /* Free APN contexts and check how the matching changes */
+
+ sgsn_apn_ctx_free(actxs[7]);
+ actx = sgsn_apn_ctx_match("ghi.def.test", "45612300");
+ OSMO_ASSERT(actx == actxs[8]);
+
+ sgsn_apn_ctx_free(actxs[8]);
+ actx = sgsn_apn_ctx_match("ghi.def.test", "45612300");
+ OSMO_ASSERT(actx == actxs[6]);
+
+ sgsn_apn_ctx_free(actxs[6]);
+ actx = sgsn_apn_ctx_match("ghi.def.test", "45612300");
+ OSMO_ASSERT(actx == actxs[1]);
+
+ sgsn_apn_ctx_free(actxs[5]);
+ actx = sgsn_apn_ctx_match("abc.def.test", "45612300");
+ OSMO_ASSERT(actx == actxs[4]);
+
+ sgsn_apn_ctx_free(actxs[4]);
+ actx = sgsn_apn_ctx_match("abc.def.test", "45612300");
+ OSMO_ASSERT(actx == actxs[2]);
+
+ sgsn_apn_ctx_free(actxs[2]);
+ actx = sgsn_apn_ctx_match("abc.def.test", "12345678");
+ OSMO_ASSERT(actx == actxs[1]);
+
+ sgsn_apn_ctx_free(actxs[1]);
+ actx = sgsn_apn_ctx_match("abc.def.test", "12345678");
+ OSMO_ASSERT(actx == actxs[0]);
+
+ sgsn_apn_ctx_free(actxs[0]);
+ actx = sgsn_apn_ctx_match("abc.def.test", "12345678");
+ OSMO_ASSERT(actx == actxs[3]);
+
+ sgsn_apn_ctx_free(actxs[3]);
+ actx = sgsn_apn_ctx_match("abc.def.test", "12345678");
+ OSMO_ASSERT(actx == NULL);
+
+ cleanup_test();
+}
+
+struct sgsn_subscriber_pdp_data* sgsn_subscriber_pdp_data_alloc(
+ struct sgsn_subscriber_data *sdata);
+
+static void test_ggsn_selection(void)
+{
+ struct apn_ctx *actxs[4];
+ struct sgsn_ggsn_ctx *ggc, *ggcs[3];
+ struct gprs_subscr *s1;
+ const char *imsi1 = "1234567890";
+ struct sgsn_mm_ctx *ctx;
+ struct gprs_ra_id raid = { 0, };
+ uint32_t local_tlli = 0xffeeddcc;
+ enum gsm48_gsm_cause gsm_cause;
+ struct tlv_parsed tp;
+ uint8_t apn_enc[GSM_APN_LENGTH + 10];
+ struct sgsn_subscriber_pdp_data *pdp_data;
+ char apn_str[GSM_APN_LENGTH];
+
+ printf("Testing GGSN selection\n");
+
+ gsup_client_send_cb = my_gsup_client_send_dummy;
+
+ /* Check for emptiness */
+ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL);
+
+ /* Create a context */
+ OSMO_ASSERT(count(gprs_llme_list()) == 0);
+ ctx = alloc_mm_ctx(local_tlli, &raid);
+ osmo_strlcpy(ctx->imsi, imsi1, sizeof(ctx->imsi));
+
+ /* Allocate and attach a subscriber */
+ s1 = gprs_subscr_get_or_create_by_mmctx(ctx);
+ assert_subscr(s1, imsi1);
+
+ tp.lv[GSM48_IE_GSM_APN].len = 0;
+ tp.lv[GSM48_IE_GSM_APN].val = apn_enc;
+
+ /* TODO: Add PDP info entries to s1 */
+
+ ggcs[0] = sgsn_ggsn_ctx_find_alloc(0);
+ ggcs[1] = sgsn_ggsn_ctx_find_alloc(1);
+ ggcs[2] = sgsn_ggsn_ctx_find_alloc(2);
+
+ actxs[0] = sgsn_apn_ctx_find_alloc("test.apn", "123456");
+ actxs[0]->ggsn = ggcs[0];
+ actxs[1] = sgsn_apn_ctx_find_alloc("*.apn", "123456");
+ actxs[1]->ggsn = ggcs[1];
+ actxs[2] = sgsn_apn_ctx_find_alloc("*", "456789");
+ actxs[2]->ggsn = ggcs[2];
+
+ pdp_data = sgsn_subscriber_pdp_data_alloc(s1->sgsn_data);
+ pdp_data->context_id = 1;
+ pdp_data->pdp_type = 0x0121;
+ osmo_strlcpy(pdp_data->apn_str, "*", sizeof(pdp_data->apn_str));
+
+ /* Resolve GGSNs */
+
+ tp.lv[GSM48_IE_GSM_APN].len =
+ gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Test.Apn");
+
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
+ OSMO_ASSERT(ggc != NULL);
+ OSMO_ASSERT(ggc->id == 0);
+ OSMO_ASSERT(strcmp(apn_str, "Test.Apn") == 0);
+
+ tp.lv[GSM48_IE_GSM_APN].len =
+ gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Other.Apn");
+
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
+ OSMO_ASSERT(ggc != NULL);
+ OSMO_ASSERT(ggc->id == 1);
+ OSMO_ASSERT(strcmp(apn_str, "Other.Apn") == 0);
+
+ tp.lv[GSM48_IE_GSM_APN].len = 0;
+ tp.lv[GSM48_IE_GSM_APN].val = NULL;
+
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
+ OSMO_ASSERT(ggc != NULL);
+ OSMO_ASSERT(ggc->id == 0);
+ OSMO_ASSERT(strcmp(apn_str, "") == 0);
+
+ actxs[3] = sgsn_apn_ctx_find_alloc("*", "123456");
+ actxs[3]->ggsn = ggcs[2];
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
+ OSMO_ASSERT(ggc != NULL);
+ OSMO_ASSERT(ggc->id == 2);
+ OSMO_ASSERT(strcmp(apn_str, "") == 0);
+
+ sgsn_apn_ctx_free(actxs[3]);
+ tp.lv[GSM48_IE_GSM_APN].val = apn_enc;
+
+ tp.lv[GSM48_IE_GSM_APN].len =
+ gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Foo.Bar");
+
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
+ OSMO_ASSERT(ggc == NULL);
+ OSMO_ASSERT(gsm_cause == GSM_CAUSE_MISSING_APN);
+ OSMO_ASSERT(strcmp(apn_str, "Foo.Bar") == 0);
+
+ tp.lv[GSM48_IE_GSM_APN].len = sizeof(apn_enc);
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
+ OSMO_ASSERT(ggc == NULL);
+ OSMO_ASSERT(gsm_cause == GSM_CAUSE_INV_MAND_INFO);
+
+ /* Add PDP data entry to subscriber */
+
+ osmo_strlcpy(pdp_data->apn_str, "Test.Apn", sizeof(pdp_data->apn_str));
+
+ tp.lv[GSM48_IE_GSM_APN].len =
+ gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Test.Apn");
+
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
+ OSMO_ASSERT(ggc != NULL);
+ OSMO_ASSERT(ggc->id == 0);
+ OSMO_ASSERT(strcmp(apn_str, "Test.Apn") == 0);
+
+ tp.lv[GSM48_IE_GSM_APN].len =
+ gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Other.Apn");
+
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
+ OSMO_ASSERT(ggc == NULL);
+ OSMO_ASSERT(gsm_cause == GSM_CAUSE_REQ_SERV_OPT_NOTSUB);
+ OSMO_ASSERT(strcmp(apn_str, "") == 0);
+
+ /* Cleanup */
+
+ gprs_subscr_put(s1);
+ sgsn_mm_ctx_cleanup_free(ctx);
+
+ assert_no_subscrs();
+
+ sgsn_apn_ctx_free(actxs[0]);
+ sgsn_apn_ctx_free(actxs[1]);
+ sgsn_apn_ctx_free(actxs[2]);
+
+ sgsn_ggsn_ctx_free(ggcs[0]);
+ sgsn_ggsn_ctx_free(ggcs[1]);
+ sgsn_ggsn_ctx_free(ggcs[2]);
+
+ gsup_client_send_cb = __real_gsup_client_send;
+
+ cleanup_test();
+}
+
+static struct log_info_cat gprs_categories[] = {
+ [DMM] = {
+ .name = "DMM",
+ .description = "Layer3 Mobility Management (MM)",
+ .color = "\033[1;33m",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ },
+ [DPAG] = {
+ .name = "DPAG",
+ .description = "Paging Subsystem",
+ .color = "\033[1;38m",
+ .enabled = 1, .loglevel = LOGL_NOTICE,
+ },
+ [DMEAS] = {
+ .name = "DMEAS",
+ .description = "Radio Measurement Processing",
+ .enabled = 0, .loglevel = LOGL_NOTICE,
+ },
+ [DREF] = {
+ .name = "DREF",
+ .description = "Reference Counting",
+ .enabled = 0, .loglevel = LOGL_NOTICE,
+ },
+ [DGPRS] = {
+ .name = "DGPRS",
+ .description = "GPRS Packet Service",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ },
+ [DNS] = {
+ .name = "DNS",
+ .description = "GPRS Network Service (NS)",
+ .enabled = 1, .loglevel = LOGL_INFO,
+ },
+ [DBSSGP] = {
+ .name = "DBSSGP",
+ .description = "GPRS BSS Gateway Protocol (BSSGP)",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ },
+ [DLLC] = {
+ .name = "DLLC",
+ .description = "GPRS Logical Link Control Protocol (LLC)",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ },
+ [DSNDCP] = {
+ .name = "DSNDCP",
+ .description = "GPRS Sub-Network Dependent Control Protocol (SNDCP)",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ },
+};
+
+static struct log_info info = {
+ .cat = gprs_categories,
+ .num_cat = ARRAY_SIZE(gprs_categories),
+};
+
+int main(int argc, char **argv)
+{
+ void *osmo_sgsn_ctx;
+ void *msgb_ctx;
+
+ osmo_init_logging(&info);
+ osmo_sgsn_ctx = talloc_named_const(NULL, 0, "osmo_sgsn");
+ tall_bsc_ctx = talloc_named_const(osmo_sgsn_ctx, 0, "bsc");
+ msgb_ctx = msgb_talloc_ctx_init(osmo_sgsn_ctx, 0);
+
+ sgsn_rate_ctr_init();
+ sgsn_auth_init();
+ gprs_subscr_init(sgsn);
+
+ test_llme();
+ test_subscriber();
+ test_auth_triplets();
+ test_subscriber_gsup();
+ test_gmm_detach();
+ test_gmm_detach_power_off();
+ test_gmm_detach_no_mmctx();
+ test_gmm_detach_accept_unexpected();
+ test_gmm_status_no_mmctx();
+ test_gmm_attach_acl();
+ test_gmm_attach_subscr();
+ test_gmm_attach_subscr_fake_auth();
+ test_gmm_attach_subscr_real_auth();
+ test_gmm_attach_subscr_gsup_auth(0);
+ test_gmm_attach_subscr_gsup_auth(1);
+ test_gmm_attach_subscr_real_gsup_auth(0);
+ test_gmm_reject();
+ test_gmm_cancel();
+ test_gmm_ptmsi_allocation();
+ test_gmm_routing_areas();
+ test_apn_matching();
+ test_ggsn_selection();
+ printf("Done\n");
+
+ talloc_report_full(osmo_sgsn_ctx, stderr);
+ OSMO_ASSERT(talloc_total_blocks(msgb_ctx) == 1);
+ OSMO_ASSERT(talloc_total_blocks(tall_bsc_ctx) == 2);
+ return 0;
+}
+
+
+/* stubs */
+struct osmo_prim_hdr;
+int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
+{
+ abort();
+}
diff --git a/tests/sgsn/sgsn_test.ok b/tests/sgsn/sgsn_test.ok
new file mode 100644
index 000000000..f38d7309d
--- /dev/null
+++ b/tests/sgsn/sgsn_test.ok
@@ -0,0 +1,45 @@
+Testing LLME allocations
+Testing core subscriber data API
+llist_count(gprs_subscribers) == 0
+llist_count(gprs_subscribers) == 1
+llist_count(gprs_subscribers) == 1
+llist_count(gprs_subscribers) == 2
+llist_count(gprs_subscribers) == 3
+llist_count(gprs_subscribers) == 2
+llist_count(gprs_subscribers) == 1
+llist_count(gprs_subscribers) == 0
+Testing authentication triplet handling
+Testing subscriber GSUP handling
+Testing GMM detach
+Testing GMM detach (power off)
+Testing GMM detach (no MMCTX)
+Testing GMM detach accept (unexpected)
+Testing GMM Status (no MMCTX)
+Auth policy 'closed': Testing GMM attach
+Auth policy 'remote': Testing GMM attach
+Auth policy 'remote', auth faked: Testing GMM attach
+Auth policy 'remote', triplet based auth: Testing GMM attach
+Auth policy 'remote', GSUP based auth: Testing GMM attach
+Auth policy 'remote', GSUP based auth: Testing GMM attach with retry
+Auth policy 'remote', real GSUP based auth: Testing GMM attach
+Testing GMM reject
+ - Attach Request (invalid MI length)
+ - Attach Request (invalid MI type)
+ - Routing Area Update Request (valid)
+ - Routing Area Update Request (invalid type)
+ - Routing Area Update Request (invalid CAP length)
+Testing cancellation
+Testing P-TMSI allocation
+ - sgsn_alloc_ptmsi
+ - Repeated Attach Request
+ - Repeated RA Update Request
+Testing routing area changes
+ - Attach Request (RA 1)
+ - RA Update Request (RA 1 -> RA 1)
+ - RA Update Request (RA 1 -> RA 2)
+ - RA Update Request (RA other -> RA 2)
+ - Attach Request (RA 2)
+ - RA Update Request (RA 2 -> RA 2)
+Testing APN matching
+Testing GGSN selection
+Done
diff --git a/tests/slhc/Makefile.am b/tests/slhc/Makefile.am
new file mode 100644
index 000000000..32a3cc447
--- /dev/null
+++ b/tests/slhc/Makefile.am
@@ -0,0 +1,15 @@
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBCARES_CFLAGS)
+
+EXTRA_DIST = slhc_test.ok
+
+noinst_PROGRAMS = slhc_test
+
+slhc_test_SOURCES = slhc_test.c
+
+slhc_test_LDADD = \
+ $(top_builddir)/src/gprs/slhc.o \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS)
+
+
diff --git a/tests/slhc/slhc_test.c b/tests/slhc/slhc_test.c
new file mode 100644
index 000000000..d2e1cd9dc
--- /dev/null
+++ b/tests/slhc/slhc_test.c
@@ -0,0 +1,272 @@
+/* Test SLHC/RFC1144 TCP/IP Header compression/decompression */
+
+/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
+ * All Rights Reserved
+ *
+ * Author: 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/>.
+ */
+
+#include <openbsc/slhc.h>
+#include <openbsc/debug.h>
+
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+
+#include <osmocom/core/application.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <arpa/inet.h>
+
+/* Number of compression slots (S0-1) */
+#define SLOTS 8
+
+/* Maximum packet bytes to display */
+#define DISP_MAX_BYTES 100
+
+/* Sample packets to test with */
+#define PACKETS_LEN 15
+char *packets[] = {
+ /* With TCP Option 10 (Timestamps) in place (forces UNCOMPRESSED_TCP) */
+ "4510004046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27",
+ "4510005b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0",
+ "4510003746df40004006a9aec0a8646ec0a864640017ad8b81980133f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01",
+ "4510003746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01",
+ "4510007446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a0d0a",
+ "4510004246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20",
+ /* Regular TCP packets (COMPRESSED_TCP) */
+ "4510003446dd40004006a9b3c0a8646ec0a864640017ad8b81980100f3ac984d501800e371410000fffd18fffd20fffd23fffd27",
+ "4510004f46de40004006a997c0a8646ec0a864640017ad8b8198010cf3ac984d501800e3cda40000fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0",
+ "4510002b46df40004006a9bac0a8646ec0a864640017ad8b81980133f3ac989f501800e3a70a0000fffd01",
+ "4510002b46e040004006a9b9c0a8646ec0a864640017ad8b81980136f3ac98a2501800e3a7060000fffb01",
+ "4510006846e140004006a97bc0a8646ec0a864640017ad8b81980139f3ac98a5501800e3c2d000000d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a0d0a",
+ "4510003646e240004006a9acc0a8646ec0a864640017ad8b81980179f3ac98a5501800e321fb0000706f6c6c7578206c6f67696e3a20",
+ /* UDP packets (TYPE_IP */
+ "450000396e0b40004011a0310a0901650a09170105da003500255489a60f01000001000000000000076f736d6f636f6d036f72670000010001",
+ "450000dc9eeb00004011aeae0a0917010a090165003505da00c83fbaa60f81800001000100030004076f736d6f636f6d036f72670000010001c00c00010001000079be0004904c2b4cc00c000200010000173d00130773756e6265616d08676e756d6f6e6b73c014c00c000200010000173d000603646e73c041c00c000200010000173d000a0767616e65736861c041c058000100010000173d0004d55f2e45c058001c00010000173d0010200107800045f0460000000000690001c06a0001000100006a710004d55f1b78c039000100010000173d000453ecb2cb",
+ "45000037652340004011a91b0a0901650a091701ef1b0035002376a2c3910100000100000000000006676f6f676c650264650000010001",
+ "0050b6162c10000db93a3ff908004500004726a6000038114083080808080a0901650035ef1b00338a8cc3918180000100010000000006676f6f676c650264650000010001c00c000100010000012b0004d83ad503",
+};
+
+/* Compress a packet using Van Jacobson RFC1144 header compression */
+static int compress(uint8_t *data_o, uint8_t *data_i, int len,
+ struct slcompress *comp)
+{
+ uint8_t *comp_ptr; /* Not used */
+ int compr_len;
+
+ /* Create a working copy of the incoming data */
+ memcpy(data_o, data_i, len);
+
+ /* Run compressor */
+ compr_len = slhc_compress(comp, data_i, len, data_o, &comp_ptr, 0);
+ return compr_len;
+}
+
+/* Expand a packet using Van Jacobson RFC1144 header compression */
+static int expand(uint8_t *data_o, uint8_t *data_i, int len,
+ struct slcompress *comp)
+{
+ int data_decompressed_len;
+
+ /* Create a working copy of the incoming data */
+ memcpy(data_o, data_i, len);
+
+ /* Handle an uncompressed packet (learn header information */
+ if ((data_i[0] & SL_TYPE_UNCOMPRESSED_TCP) == SL_TYPE_UNCOMPRESSED_TCP) {
+ data_o[0] &= 0x4F;
+ data_decompressed_len = slhc_remember(comp, data_o, len);
+ return data_decompressed_len;
+ }
+
+ /* Uncompress compressed packets */
+ else if (data_o[0] & SL_TYPE_COMPRESSED_TCP) {
+ data_decompressed_len = slhc_uncompress(comp, data_o, len);
+ return data_decompressed_len;
+ }
+
+ /* Regular or unknown packets will not be touched */
+ return len;
+}
+
+/* Calculate IP Header checksum */
+static uint16_t calc_ip_csum(uint8_t *data, int len)
+{
+ int i;
+ uint32_t accumulator = 0;
+ uint16_t *pointer = (uint16_t *) data;
+
+ for (i = len; i > 1; i -= 2) {
+ accumulator += *pointer;
+ pointer++;
+ }
+
+ if (len % 2)
+ accumulator += *pointer;
+
+ accumulator = (accumulator & 0xffff) + ((accumulator >> 16) & 0xffff);
+ accumulator += (accumulator >> 16) & 0xffff;
+ return (~accumulator);
+}
+
+/* Calculate TCP/IP checksum */
+static uint16_t calc_tcpip_csum(const void *ctx, uint8_t *packet, int len)
+{
+ uint8_t *buf;
+ uint16_t csum;
+
+ buf = talloc_zero_size(ctx, len);
+ memset(buf, 0, len);
+ memcpy(buf, packet + 12, 8);
+ buf[9] = packet[9];
+ buf[11] = (len - 20) & 0xFF;
+ buf[10] = (len - 20) >> 8 & 0xFF;
+ memcpy(buf + 12, packet + 20, len - 20);
+ csum = calc_ip_csum(buf, len - 20 + 12);
+ talloc_free(buf);
+ return csum;
+}
+
+/* Check TCP/IP packet */
+static void check_packet(const void *ctx, uint8_t *packet, int len)
+{
+ /* Check IP header */
+ OSMO_ASSERT(len > 20);
+ OSMO_ASSERT(calc_ip_csum(packet, 20) == 0);
+
+ printf("packet[9]=%02x\n", packet[9]);
+
+ /* Check TCP packet */
+ if (packet[9] != 0x06)
+ return;
+ OSMO_ASSERT(len > 40);
+ OSMO_ASSERT(calc_tcpip_csum(ctx, packet, len) == 0);
+}
+
+/* Compress / Decompress packets */
+static void test_slhc(const void *ctx)
+{
+ char packet_ascii[2048];
+ int i;
+
+ struct slcompress *comp;
+ uint8_t packet[1024];
+ int packet_len;
+ uint8_t packet_compr[1024];
+ int packet_compr_len;
+ uint8_t packet_decompr[1024];
+ int packet_decompr_len;
+
+ printf("Allocating compression state...\n");
+ comp = slhc_init(ctx, SLOTS, SLOTS);
+ OSMO_ASSERT(comp);
+
+ for (i = 0; i < PACKETS_LEN; i++) {
+ printf("Testing with packet No. %d\n", i);
+
+ /* Read input file */
+ memset(packet_ascii, 0, sizeof(packet_ascii));
+ memset(packet, 0, sizeof(packet));
+ memset(packet_compr, 0, sizeof(packet_compr));
+ memset(packet_decompr, 0, sizeof(packet_decompr));
+
+ OSMO_ASSERT(strlen(packets[i]) < sizeof(packet_ascii));
+ strcpy(packet_ascii, packets[i]);
+
+ packet_len =
+ osmo_hexparse(packet_ascii, packet, sizeof(packet));
+ check_packet(ctx, packet, packet_len);
+
+ /* Run compression/decompression algorithm */
+ printf("Compressing...\n");
+ packet_compr_len =
+ compress(packet_compr, packet, packet_len, comp);
+ printf("Decompressing...\n");
+ packet_decompr_len =
+ expand(packet_decompr, packet_compr, packet_compr_len,
+ comp);
+ OSMO_ASSERT(packet_decompr_len == packet_len);
+ check_packet(ctx, packet_decompr, packet_decompr_len);
+
+ /* Display results */
+ printf("Results:\n");
+ if (packet_compr_len > DISP_MAX_BYTES)
+ packet_compr_len = DISP_MAX_BYTES;
+ if (packet_len > DISP_MAX_BYTES)
+ packet_len = DISP_MAX_BYTES;
+ if (packet_decompr_len > DISP_MAX_BYTES)
+ packet_decompr_len = DISP_MAX_BYTES;
+ printf("Original Packet: (%i bytes) %s\n", packet_len,
+ osmo_hexdump_nospc(packet, packet_len));
+ printf("DecompressedPacket: (%i bytes) %s\n",
+ packet_decompr_len, osmo_hexdump_nospc(packet_decompr,
+ packet_decompr_len));
+ printf("CompressedPacket: (%i bytes) %s\n", packet_compr_len,
+ osmo_hexdump_nospc(packet_compr, packet_compr_len));
+ slhc_o_status(comp);
+ slhc_o_status(comp);
+
+ printf("\n");
+ }
+
+ printf("Freeing compression state...\n");
+ slhc_free(comp);
+ printf("\n");
+}
+
+static struct log_info_cat gprs_categories[] = {
+ [DSNDCP] = {
+ .name = "DSNDCP",
+ .description =
+ "GPRS Sub-Network Dependent Control Protocol (SNDCP)",
+ .enabled = 1,.loglevel = LOGL_DEBUG,
+ },
+ [DSLHC] = {
+ .name = "DSLHC",
+ .description =
+ "Van Jacobson RFC1144 TCP/IP header compression (SLHC)",
+ .enabled = 1,.loglevel = LOGL_DEBUG,
+ }
+};
+
+static struct log_info info = {
+ .cat = gprs_categories,
+ .num_cat = ARRAY_SIZE(gprs_categories),
+};
+
+int main(int argc, char **argv)
+{
+ void *ctx;
+
+ osmo_init_logging(&info);
+
+ ctx = talloc_named_const(NULL, 0, "slhc_ctx");
+
+ test_slhc(ctx);
+
+ printf("Done\n");
+
+ talloc_report_full(ctx, stderr);
+ OSMO_ASSERT(talloc_total_blocks(ctx) == 1);
+ return 0;
+}
+
+/* stubs */
+struct osmo_prim_hdr;
+int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
+{
+ abort();
+}
diff --git a/tests/slhc/slhc_test.ok b/tests/slhc/slhc_test.ok
new file mode 100644
index 000000000..71f48a179
--- /dev/null
+++ b/tests/slhc/slhc_test.ok
@@ -0,0 +1,154 @@
+Allocating compression state...
+Testing with packet No. 0
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (64 bytes) 4510004046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27
+DecompressedPacket: (64 bytes) 4510004046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27
+CompressedPacket: (64 bytes) 7510004046dd40004000a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27
+
+Testing with packet No. 1
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (91 bytes) 4510005b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0
+DecompressedPacket: (91 bytes) 4510005b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0
+CompressedPacket: (91 bytes) 7510005b46de40004000a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0
+
+Testing with packet No. 2
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (55 bytes) 4510003746df40004006a9aec0a8646ec0a864640017ad8b81980133f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01
+DecompressedPacket: (55 bytes) 4510003746df40004006a9aec0a8646ec0a864640017ad8b81980133f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01
+CompressedPacket: (55 bytes) 7510003746df40004000a9aec0a8646ec0a864640017ad8b81980133f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01
+
+Testing with packet No. 3
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (55 bytes) 4510003746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01
+DecompressedPacket: (55 bytes) 4510003746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01
+CompressedPacket: (55 bytes) 7510003746e040004000a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01
+
+Testing with packet No. 4
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (100 bytes) 4510007446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d
+DecompressedPacket: (100 bytes) 4510007446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d
+CompressedPacket: (100 bytes) 7510007446e140004000a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d
+
+Testing with packet No. 5
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (66 bytes) 4510004246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20
+DecompressedPacket: (66 bytes) 4510004246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20
+CompressedPacket: (66 bytes) 7510004246e240004000a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20
+
+Testing with packet No. 6
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (52 bytes) 4510003446dd40004006a9b3c0a8646ec0a864640017ad8b81980100f3ac984d501800e371410000fffd18fffd20fffd23fffd27
+DecompressedPacket: (52 bytes) 4510003446dd40004006a9b3c0a8646ec0a864640017ad8b81980100f3ac984d501800e371410000fffd18fffd20fffd23fffd27
+CompressedPacket: (52 bytes) 7510003446dd40004000a9b3c0a8646ec0a864640017ad8b81980100f3ac984d501800e371410000fffd18fffd20fffd23fffd27
+
+Testing with packet No. 7
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (79 bytes) 4510004f46de40004006a997c0a8646ec0a864640017ad8b8198010cf3ac984d501800e3cda40000fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0
+DecompressedPacket: (79 bytes) 4510004f46de40004006a997c0a8646ec0a864640017ad8b8198010cf3ac984d501800e3cda40000fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0
+CompressedPacket: (43 bytes) df00cda4fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0
+
+Testing with packet No. 8
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (43 bytes) 4510002b46df40004006a9bac0a8646ec0a864640017ad8b81980133f3ac989f501800e3a70a0000fffd01
+DecompressedPacket: (43 bytes) 4510002b46df40004006a9bac0a8646ec0a864640017ad8b81980133f3ac989f501800e3a70a0000fffd01
+CompressedPacket: (9 bytes) dc00a70a5227fffd01
+
+Testing with packet No. 9
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (43 bytes) 4510002b46e040004006a9b9c0a8646ec0a864640017ad8b81980136f3ac98a2501800e3a7060000fffb01
+DecompressedPacket: (43 bytes) 4510002b46e040004006a9b9c0a8646ec0a864640017ad8b81980136f3ac98a2501800e3a7060000fffb01
+CompressedPacket: (7 bytes) db00a706fffb01
+
+Testing with packet No. 10
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (100 bytes) 4510006846e140004006a97bc0a8646ec0a864640017ad8b81980139f3ac98a5501800e3c2d000000d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d
+DecompressedPacket: (100 bytes) 4510006846e140004006a97bc0a8646ec0a864640017ad8b81980139f3ac98a5501800e3c2d000000d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d
+CompressedPacket: (68 bytes) db00c2d00d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a0d0a
+
+Testing with packet No. 11
+packet[9]=06
+Compressing...
+Decompressing...
+packet[9]=06
+Results:
+Original Packet: (54 bytes) 4510003646e240004006a9acc0a8646ec0a864640017ad8b81980179f3ac98a5501800e321fb0000706f6c6c7578206c6f67696e3a20
+DecompressedPacket: (54 bytes) 4510003646e240004006a9acc0a8646ec0a864640017ad8b81980179f3ac98a5501800e321fb0000706f6c6c7578206c6f67696e3a20
+CompressedPacket: (18 bytes) df0021fb706f6c6c7578206c6f67696e3a20
+
+Testing with packet No. 12
+packet[9]=11
+Compressing...
+Decompressing...
+packet[9]=11
+Results:
+Original Packet: (57 bytes) 450000396e0b40004011a0310a0901650a09170105da003500255489a60f01000001000000000000076f736d6f636f6d036f72670000010001
+DecompressedPacket: (57 bytes) 450000396e0b40004011a0310a0901650a09170105da003500255489a60f01000001000000000000076f736d6f636f6d036f72670000010001
+CompressedPacket: (57 bytes) 450000396e0b40004011a0310a0901650a09170105da003500255489a60f01000001000000000000076f736d6f636f6d036f72670000010001
+
+Testing with packet No. 13
+packet[9]=11
+Compressing...
+Decompressing...
+packet[9]=11
+Results:
+Original Packet: (100 bytes) 450000dc9eeb00004011aeae0a0917010a090165003505da00c83fbaa60f81800001000100030004076f736d6f636f6d036f72670000010001c00c00010001000079be0004904c2b4cc00c000200010000173d00130773756e6265616d08676e756d6f6e
+DecompressedPacket: (100 bytes) 450000dc9eeb00004011aeae0a0917010a090165003505da00c83fbaa60f81800001000100030004076f736d6f636f6d036f72670000010001c00c00010001000079be0004904c2b4cc00c000200010000173d00130773756e6265616d08676e756d6f6e
+CompressedPacket: (100 bytes) 450000dc9eeb00004011aeae0a0917010a090165003505da00c83fbaa60f81800001000100030004076f736d6f636f6d036f72670000010001c00c00010001000079be0004904c2b4cc00c000200010000173d00130773756e6265616d08676e756d6f6e
+
+Testing with packet No. 14
+packet[9]=11
+Compressing...
+Decompressing...
+packet[9]=11
+Results:
+Original Packet: (55 bytes) 45000037652340004011a91b0a0901650a091701ef1b0035002376a2c3910100000100000000000006676f6f676c650264650000010001
+DecompressedPacket: (55 bytes) 45000037652340004011a91b0a0901650a091701ef1b0035002376a2c3910100000100000000000006676f6f676c650264650000010001
+CompressedPacket: (55 bytes) 45000037652340004011a91b0a0901650a091701ef1b0035002376a2c3910100000100000000000006676f6f676c650264650000010001
+
+Freeing compression state...
+
+Done
diff --git a/tests/smpp/Makefile.am b/tests/smpp/Makefile.am
new file mode 100644
index 000000000..508270753
--- /dev/null
+++ b/tests/smpp/Makefile.am
@@ -0,0 +1,40 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src/libmsc \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBOSMOSCCP_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(COVERAGE_CFLAGS) \
+ $(LIBSMPP34_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(COVERAGE_LDFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ smpp_test.ok \
+ smpp_test.err \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ smpp_test \
+ $(NULL)
+
+smpp_test_SOURCES = \
+ smpp_test.c \
+ $(top_builddir)/src/libmsc/smpp_utils.c \
+ $(NULL)
+
+smpp_test_LDADD = \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(NULL)
diff --git a/tests/smpp/smpp_test.c b/tests/smpp/smpp_test.c
new file mode 100644
index 000000000..62fa9d2e9
--- /dev/null
+++ b/tests/smpp/smpp_test.c
@@ -0,0 +1,73 @@
+/*
+ * (C) 2013 by Holger Hans Peter Freyther
+ * All Rights Reserved
+ *
+ * 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/>.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <openbsc/debug.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/core/backtrace.h>
+
+#include "smpp_smsc.h"
+
+struct coding_test {
+ uint8_t dcs;
+ uint8_t coding;
+ int mode;
+ int res;
+};
+
+static struct coding_test codecs[] = {
+ { .dcs = 0xf6 , .coding = 0x02, .mode = MODE_8BIT, .res = 0 },
+ { .dcs = 0xf2 , .coding = 0x01, .mode = MODE_7BIT, .res = 0 },
+ { .dcs = 0x02 , .coding = 0x01, .mode = MODE_7BIT, .res = 0 },
+ { .dcs = 0x06 , .coding = 0x02, .mode = MODE_8BIT, .res = 0 },
+ { .dcs = 0x0A , .coding = 0x08, .mode = MODE_8BIT, .res = 0 },
+ { .dcs = 0x0E , .coding = 0xFF, .mode = 0xFF, .res = -1 },
+ { .dcs = 0xE0 , .coding = 0xFF, .mode = 0xFF, .res = -1 },
+};
+
+static void test_coding_scheme(void)
+{
+ int i;
+ printf("Testing coding scheme support\n");
+
+ for (i = 0; i < ARRAY_SIZE(codecs); ++i) {
+ uint8_t coding;
+ int mode, res;
+
+ res = smpp_determine_scheme(codecs[i].dcs, &coding, &mode);
+ OSMO_ASSERT(res == codecs[i].res);
+ if (res != -1) {
+ OSMO_ASSERT(mode == codecs[i].mode);
+ OSMO_ASSERT(coding == codecs[i].coding);
+ }
+ }
+}
+
+int main(int argc, char **argv)
+{
+ osmo_init_logging(&log_info);
+ log_set_use_color(osmo_stderr_target, 0);
+ log_set_print_filename(osmo_stderr_target, 0);
+
+ test_coding_scheme();
+ return EXIT_SUCCESS;
+}
diff --git a/tests/smpp/smpp_test.err b/tests/smpp/smpp_test.err
new file mode 100644
index 000000000..ec966ba47
--- /dev/null
+++ b/tests/smpp/smpp_test.err
@@ -0,0 +1,2 @@
+SMPP MO Unknown Data Coding 0x0e
+SMPP MO Unknown Data Coding 0xe0
diff --git a/tests/smpp/smpp_test.ok b/tests/smpp/smpp_test.ok
new file mode 100644
index 000000000..fd44804d1
--- /dev/null
+++ b/tests/smpp/smpp_test.ok
@@ -0,0 +1 @@
+Testing coding scheme support
diff --git a/tests/smpp_test_runner.py b/tests/smpp_test_runner.py
new file mode 100644
index 000000000..2fd144b2b
--- /dev/null
+++ b/tests/smpp_test_runner.py
@@ -0,0 +1,137 @@
+#!/usr/bin/env python
+
+# (C) 2014 by Holger Hans Peter Freyther
+# based on vty_test_runner.py:
+# (C) 2013 by Katerina Barone-Adesi <kat.obsc@gmail.com>
+# (C) 2013 by Holger Hans Peter Freyther
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import sys
+import time
+import unittest
+import socket
+
+import osmopy.obscvty as obscvty
+import osmopy.osmoutil as osmoutil
+
+confpath = os.path.join(sys.path[0], '..')
+
+class TestVTYBase(unittest.TestCase):
+
+ def vty_command(self):
+ raise Exception("Needs to be implemented by a subclass")
+
+ def vty_app(self):
+ raise Exception("Needs to be implemented by a subclass")
+
+ def setUp(self):
+ osmo_vty_cmd = self.vty_command()[:]
+ config_index = osmo_vty_cmd.index('-c')
+ if config_index:
+ cfi = config_index + 1
+ osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi])
+
+ try:
+ self.proc = osmoutil.popen_devnull(osmo_vty_cmd)
+ except OSError:
+ print >> sys.stderr, "Current directory: %s" % os.getcwd()
+ print >> sys.stderr, "Consider setting -b"
+
+ appstring = self.vty_app()[2]
+ appport = self.vty_app()[0]
+ self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport)
+
+ def tearDown(self):
+ if self.vty:
+ self.vty._close_socket()
+ self.vty = None
+ osmoutil.end_proc(self.proc)
+
+
+class TestSMPPNITB(TestVTYBase):
+
+ def vty_command(self):
+ return ["./src/osmo-nitb/osmo-nitb", "-c",
+ "doc/examples/osmo-nitb/nanobts/openbsc.cfg"]
+
+ def vty_app(self):
+ return (4242, "./src/osmo-nitb/osmo-nitb", "OpenBSC", "nitb")
+
+ def testSMPPCrashes(self):
+ # Enable the configuration
+ self.vty.enable()
+ self.assertTrue(self.vty.verify("configure terminal", ['']))
+ self.assertEquals(self.vty.node(), 'config')
+
+ self.assertTrue(self.vty.verify('smpp', ['']))
+ self.assertEquals(self.vty.node(), 'config-smpp')
+ self.assertTrue(self.vty.verify('system-id test', ['']))
+ self.assertTrue(self.vty.verify('local-tcp-port 2775', ['']))
+ self.assertTrue(self.vty.verify('esme test', ['']))
+ self.assertEquals(self.vty.node(), 'config-smpp-esme')
+ self.assertTrue(self.vty.verify('default-route', ['']))
+ self.assertTrue(self.vty.verify('end', ['']))
+
+ # NITB should listen to 2775 now!
+ sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sck.setblocking(1)
+ sck.connect(('0.0.0.0', 2775))
+ sck.sendall('\x00\x00\x00\x02\x00')
+ sck.close()
+
+ # Check if the VTY is still there
+ self.vty.verify('disable',[''])
+
+ # Now for the second packet
+ sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sck.setblocking(1)
+ sck.connect(('0.0.0.0', 2775))
+ sck.sendall('\x00\x01\x00\x01\x01')
+ sck.close()
+
+ self.vty.verify('enable',[''])
+
+if __name__ == '__main__':
+ import argparse
+ import sys
+
+ workdir = '.'
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-v", "--verbose", dest="verbose",
+ action="store_true", help="verbose mode")
+ parser.add_argument("-p", "--pythonconfpath", dest="p",
+ help="searchpath for config")
+ parser.add_argument("-w", "--workdir", dest="w",
+ help="Working directory")
+ args = parser.parse_args()
+
+ verbose_level = 1
+ if args.verbose:
+ verbose_level = 2
+
+ if args.w:
+ workdir = args.w
+
+ if args.p:
+ confpath = args.p
+
+ print "confpath %s, workdir %s" % (confpath, workdir)
+ os.chdir(workdir)
+ print "Running tests for specific SMPP"
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSMPPNITB))
+ res = unittest.TextTestRunner(verbosity=verbose_level).run(suite)
+ sys.exit(len(res.errors) + len(res.failures))
diff --git a/tests/sndcp_xid/Makefile.am b/tests/sndcp_xid/Makefile.am
new file mode 100644
index 000000000..d09c41b28
--- /dev/null
+++ b/tests/sndcp_xid/Makefile.am
@@ -0,0 +1,21 @@
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBCARES_CFLAGS)
+
+EXTRA_DIST = sndcp_xid_test.ok
+
+noinst_PROGRAMS = sndcp_xid_test
+
+sndcp_xid_test_SOURCES = sndcp_xid_test.c
+
+sndcp_xid_test_LDADD = \
+ $(top_builddir)/src/gprs/gprs_sndcp_xid.o \
+ $(LIBOSMOABIS_LIBS) \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOGB_LIBS) \
+ $(LIBCARES_LIBS) \
+ $(LIBCRYPTO_LIBS) \
+ $(LIBGTP_LIBS) \
+ -lrt -lm
+
+
diff --git a/tests/sndcp_xid/sndcp_xid_test.c b/tests/sndcp_xid/sndcp_xid_test.c
new file mode 100644
index 000000000..151dd2bb5
--- /dev/null
+++ b/tests/sndcp_xid/sndcp_xid_test.c
@@ -0,0 +1,284 @@
+/* Test SNDCP-XID Encoding/Decoding */
+
+/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
+ * All Rights Reserved
+ *
+ * Author: 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/>.
+ */
+
+#include <openbsc/gprs_sndcp_xid.h>
+#include <openbsc/debug.h>
+
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+
+#include <osmocom/core/application.h>
+
+#include <stdio.h>
+#include <string.h>
+
+/* Test SNDCP-XID decoding with a real world sample */
+static void test_xid_decode_realworld(const void *ctx)
+{
+ struct llist_head *comp_fields;
+ int rc;
+ printf("Testing SNDCP XID-Decoder/Encoder (real world data)\n");
+
+ /* Example of a real world SNDCP-XID message */
+ uint8_t xid[] =
+ { 0x00, 0x01, 0x00, 0x02, 0x31, 0x82, 0x02, 0x27, 0x89, 0xff, 0xe0,
+ 0x00, 0x0f, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02,
+ 0x01, 0x02, 0x00, 0x03, 0x01, 0x03, 0x00, 0x04, 0x01, 0x04, 0x00, 0x05,
+ 0x01, 0x05, 0x00, 0x06, 0x00, 0x07, 0x01, 0x07, 0x00, 0x08, 0x01, 0x08,
+ 0x80, 0x00, 0x04, 0x12, 0x00, 0x40, 0x07 };
+ uint8_t xid_r[512];
+
+ /* Parse and show contained comp fields */
+ comp_fields = gprs_sndcp_parse_xid(NULL, ctx, xid, sizeof(xid), NULL);
+ OSMO_ASSERT(comp_fields);
+ printf("Decoded:\n");
+ gprs_sndcp_dump_comp_fields(comp_fields, DSNDCP);
+
+ /* Encode comp-fields again */
+ rc = gprs_sndcp_compile_xid(xid_r,sizeof(xid_r), comp_fields,
+ DEFAULT_SNDCP_VERSION);
+ printf("Result length=%i\n",rc);
+ printf("Encoded: %s\n", osmo_hexdump_nospc(xid, sizeof(xid)));
+ printf("Rencoded: %s\n", osmo_hexdump_nospc(xid_r, rc));
+
+ OSMO_ASSERT(rc == 54);
+ OSMO_ASSERT(memcmp(xid, xid_r, sizeof(xid)) == 0);
+
+ /* Free comp fields */
+ talloc_free(comp_fields);
+
+ printf("\n");
+}
+
+/* Encode and decode test with artificial test data */
+static void test_xid_encode_decode(const void *ctx)
+{
+ printf("Testing SNDCP XID-Encoder/Decoder\n");
+
+ LLIST_HEAD(comp_fields);
+ struct gprs_sndcp_pcomp_rfc1144_params rfc1144_params;
+ struct gprs_sndcp_comp_field rfc1144_comp_field;
+ struct gprs_sndcp_pcomp_rfc2507_params rfc2507_params;
+ struct gprs_sndcp_comp_field rfc2507_comp_field;
+ struct gprs_sndcp_pcomp_rohc_params rohc_params;
+ struct gprs_sndcp_comp_field rohc_comp_field;
+ struct gprs_sndcp_dcomp_v42bis_params v42bis_params;
+ struct gprs_sndcp_comp_field v42bis_comp_field;
+ struct gprs_sndcp_dcomp_v44_params v44_params;
+ struct gprs_sndcp_comp_field v44_comp_field;
+ struct llist_head *comp_fields_dec;
+
+ uint8_t xid[512];
+ unsigned int xid_len = sizeof(xid);
+ int rc;
+
+ memset(&rfc1144_comp_field, 0, sizeof(struct gprs_sndcp_comp_field));
+ memset(&rfc2507_comp_field, 0, sizeof(struct gprs_sndcp_comp_field));
+ memset(&rohc_comp_field, 0, sizeof(struct gprs_sndcp_comp_field));
+ memset(&v42bis_comp_field, 0, sizeof(struct gprs_sndcp_comp_field));
+ memset(&v44_comp_field, 0, sizeof(struct gprs_sndcp_comp_field));
+
+ /* Setup which NSAPIs shall make use of rfc1144 */
+ rfc1144_params.nsapi[0] = 5;
+ rfc1144_params.nsapi_len = 1;
+
+ /* Setup rfc1144 operating parameters */
+ rfc1144_params.s01 = 7;
+
+ /* Setup rfc1144 compression field */
+ rfc1144_comp_field.p = 1;
+ rfc1144_comp_field.entity = 0;
+ rfc1144_comp_field.algo = RFC_1144;
+ rfc1144_comp_field.comp[RFC1144_PCOMP1] = 1;
+ rfc1144_comp_field.comp[RFC1144_PCOMP2] = 2;
+ rfc1144_comp_field.comp_len = RFC1144_PCOMP_NUM;
+ rfc1144_comp_field.rfc1144_params = &rfc1144_params;
+
+ /* Setup which NSAPIs shall make use of rfc1144 */
+ rfc2507_params.nsapi[0] = 6;
+ rfc2507_params.nsapi_len = 1;
+
+ /* Setup rfc2507 operating parameters */
+ rfc2507_params.f_max_period = 256;
+ rfc2507_params.f_max_time = 5;
+ rfc2507_params.max_header = 168;
+ rfc2507_params.tcp_space = 15;
+ rfc2507_params.non_tcp_space = 15;
+
+ /* Setup rfc2507 compression field */
+ rfc2507_comp_field.p = 1;
+ rfc2507_comp_field.entity = 1;
+ rfc2507_comp_field.algo = RFC_2507;
+ rfc2507_comp_field.comp[RFC2507_PCOMP1] = 3;
+ rfc2507_comp_field.comp[RFC2507_PCOMP2] = 4;
+ rfc2507_comp_field.comp[RFC2507_PCOMP3] = 5;
+ rfc2507_comp_field.comp[RFC2507_PCOMP4] = 6;
+ rfc2507_comp_field.comp[RFC2507_PCOMP5] = 7;
+ rfc2507_comp_field.comp_len = RFC2507_PCOMP_NUM;
+ rfc2507_comp_field.rfc2507_params = &rfc2507_params;
+
+ /* Setup which NSAPIs shall make use of ROHC */
+ rohc_params.nsapi[0] = 5;
+ rohc_params.nsapi[1] = 6;
+ rohc_params.nsapi[2] = 7;
+ rohc_params.nsapi[3] = 8;
+ rohc_params.nsapi[4] = 9;
+ rohc_params.nsapi[5] = 10;
+ rohc_params.nsapi[6] = 11;
+ rohc_params.nsapi[7] = 12;
+ rohc_params.nsapi[8] = 13;
+ rohc_params.nsapi[9] = 14;
+ rohc_params.nsapi[10] = 15;
+ rohc_params.nsapi_len = 11;
+
+ /* Setup ROHC operating parameters */
+ rohc_params.max_cid = 15; /* default */
+ rohc_params.max_header = 168; /* default */
+ rohc_params.profile[0] = ROHC_UNCOMPRESSED;
+ rohc_params.profile[1] = ROHC_RTP;
+ rohc_params.profile[2] = ROHCV2_RTP;
+ rohc_params.profile[3] = ROHC_UDP;
+ rohc_params.profile[4] = ROHCv2_UDP;
+ rohc_params.profile[5] = ROHC_ESP;
+ rohc_params.profile[6] = ROHCV2_ESP;
+ rohc_params.profile[7] = ROHC_IP;
+ rohc_params.profile[8] = ROHCV2_IP;
+ rohc_params.profile[9] = ROHC_LLA;
+ rohc_params.profile[10] = ROHC_LLA_WITH_R_MODE;
+ rohc_params.profile[11] = ROHC_TCP;
+ rohc_params.profile[12] = ROHC_RTP_UDP_LITE;
+ rohc_params.profile[13] = ROHCV2_RTP_UDP_LITE;
+ rohc_params.profile[14] = ROHC_UDP_LITE;
+ rohc_params.profile[15] = ROHCV2_UDP_LITE;
+ rohc_params.profile_len = 16;
+
+ /* Setup ROHC compression field */
+ rohc_comp_field.p = 1;
+ rohc_comp_field.entity = 2;
+ rohc_comp_field.algo = ROHC;
+ rohc_comp_field.comp[ROHC_PCOMP1] = 8;
+ rohc_comp_field.comp[ROHC_PCOMP2] = 9;
+ rohc_comp_field.comp_len = ROHC_PCOMP_NUM;
+ rohc_comp_field.rohc_params = &rohc_params;
+
+ /* Setup which NSAPIs shall make use of v42bis */
+ v42bis_params.nsapi[0] = 5;
+ v42bis_params.nsapi_len = 1;
+
+ /* Setup v42bis operating parameters */
+ v42bis_params.p0 = 3;
+ v42bis_params.p1 = 2048;
+ v42bis_params.p2 = 20;
+
+ /* Setup v42bis compression field */
+ v42bis_comp_field.p = 1;
+ v42bis_comp_field.entity = 3;
+ v42bis_comp_field.algo = V42BIS;
+ v42bis_comp_field.comp[V42BIS_DCOMP1] = 10;
+ v42bis_comp_field.comp_len = V42BIS_DCOMP_NUM;
+ v42bis_comp_field.v42bis_params = &v42bis_params;
+
+ /* Setup which NSAPIs shall make use of v44 */
+ v44_params.nsapi[0] = 5;
+ v44_params.nsapi_len = 1;
+
+ /* Setup v44 operating parameters */
+ v44_params.c0 = 0x80;
+ v44_params.p0 = 3;
+ v44_params.p1t = 300;
+ v44_params.p1r = 300;
+ v44_params.p3t = 600;
+ v44_params.p3r = 600;
+
+ /* Setup v44 compression field */
+ v44_comp_field.p = 1;
+ v44_comp_field.entity = 3;
+ v44_comp_field.algo = V44;
+ v44_comp_field.comp[V44_DCOMP1] = 10;
+ v44_comp_field.comp[V44_DCOMP2] = 11;
+ v44_comp_field.comp_len = V44_DCOMP_NUM;
+ v44_comp_field.v44_params = &v44_params;
+
+ /* Add compression field(s) to list */
+ llist_add(&v44_comp_field.list, &comp_fields);
+ llist_add(&v42bis_comp_field.list, &comp_fields);
+ llist_add(&rfc1144_comp_field.list, &comp_fields);
+ llist_add(&rfc2507_comp_field.list, &comp_fields);
+ llist_add(&rohc_comp_field.list, &comp_fields);
+ printf("Test input data:\n");
+ gprs_sndcp_dump_comp_fields(&comp_fields, DSNDCP);
+
+ /* Encode SNDCP-XID fields */
+ rc = gprs_sndcp_compile_xid(xid, xid_len, &comp_fields,
+ DEFAULT_SNDCP_VERSION);
+ OSMO_ASSERT(rc > 0);
+
+ printf("Encoded: %s (%i bytes)\n", osmo_hexdump_nospc(xid, rc), rc);
+
+ /* Parse and show contained comp fields */
+ comp_fields_dec = gprs_sndcp_parse_xid(NULL, ctx, xid, rc, NULL);
+ OSMO_ASSERT(comp_fields_dec);
+
+ printf("Decoded:\n");
+ gprs_sndcp_dump_comp_fields(comp_fields_dec, DSNDCP);
+
+ /* Free comp fields */
+ talloc_free(comp_fields_dec);
+}
+
+static struct log_info_cat gprs_categories[] = {
+ [DSNDCP] = {
+ .name = "DSNDCP",
+ .description =
+ "GPRS Sub-Network Dependent Control Protocol (SNDCP)",
+ .enabled = 1,.loglevel = LOGL_DEBUG,
+ }
+};
+
+static struct log_info info = {
+ .cat = gprs_categories,
+ .num_cat = ARRAY_SIZE(gprs_categories),
+};
+
+int main(int argc, char **argv)
+{
+ void *xid_ctx;
+
+ osmo_init_logging(&info);
+
+ xid_ctx = talloc_named_const(NULL, 0, "xid_ctx");
+
+ test_xid_decode_realworld(xid_ctx);
+ test_xid_encode_decode(xid_ctx);
+
+ printf("Done\n");
+
+ talloc_report_full(xid_ctx, stderr);
+ OSMO_ASSERT(talloc_total_blocks(xid_ctx) == 1);
+ return 0;
+}
+
+/* stubs */
+struct osmo_prim_hdr;
+int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
+{
+ abort();
+}
diff --git a/tests/sndcp_xid/sndcp_xid_test.ok b/tests/sndcp_xid/sndcp_xid_test.ok
new file mode 100644
index 000000000..f3572827c
--- /dev/null
+++ b/tests/sndcp_xid/sndcp_xid_test.ok
@@ -0,0 +1,11 @@
+Testing SNDCP XID-Decoder/Encoder (real world data)
+Decoded:
+Result length=54
+Encoded: 000100023182022789ffe0000f00a8000000010101000201020003010300040104000501050006000701070008010880000412004007
+Rencoded: 000100023182022789ffe0000f00a8000000010101000201020003010300040104000501050006000701070008010880000412004007
+
+Testing SNDCP XID-Encoder/Decoder
+Test input data:
+Encoded: 000100011a83010dab00208003012c012c02580258830007a000200308001402408000041200200781010c3456700040010005a80f000f82022789ffe0000f00a80000000101010002010200030103000401040005010500060007010700080108 (97 bytes)
+Decoded:
+Done
diff --git a/tests/subscr/Makefile.am b/tests/subscr/Makefile.am
new file mode 100644
index 000000000..6342444ff
--- /dev/null
+++ b/tests/subscr/Makefile.am
@@ -0,0 +1,61 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(LIBSMPP34_CFLAGS) \
+ $(COVERAGE_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(COVERAGE_LDFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ subscr_test.ok \
+ bsc_subscr_test.ok \
+ bsc_subscr_test.err \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ subscr_test \
+ bsc_subscr_test \
+ $(NULL)
+
+subscr_test_SOURCES = \
+ subscr_test.c \
+ $(NULL)
+
+subscr_test_LDADD = \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOABIS_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBSMPP34_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
+ $(NULL)
+
+bsc_subscr_test_SOURCES = \
+ bsc_subscr_test.c \
+ $(NULL)
+
+bsc_subscr_test_LDADD = \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOABIS_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBSMPP34_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
+ $(NULL)
diff --git a/tests/subscr/bsc_subscr_test.c b/tests/subscr/bsc_subscr_test.c
new file mode 100644
index 000000000..60d687d58
--- /dev/null
+++ b/tests/subscr/bsc_subscr_test.c
@@ -0,0 +1,130 @@
+/* (C) 2008 by Jan Luebbe <jluebbe@debian.org>
+ * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2014 by Alexander Chemeris <Alexander.Chemeris@fairwaves.co>
+ * All Rights Reserved
+ *
+ * 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 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/>.
+ *
+ */
+
+#include <openbsc/debug.h>
+#include <openbsc/bsc_subscriber.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/core/utils.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <inttypes.h>
+
+struct llist_head *bsc_subscribers;
+
+#define VERBOSE_ASSERT(val, expect_op, fmt) \
+ do { \
+ printf(#val " == " fmt "\n", (val)); \
+ OSMO_ASSERT((val) expect_op); \
+ } while (0);
+
+static void assert_bsc_subscr(const struct bsc_subscr *bsub, const char *imsi)
+{
+ struct bsc_subscr *sfound;
+ OSMO_ASSERT(bsub);
+ OSMO_ASSERT(strcmp(bsub->imsi, imsi) == 0);
+
+ sfound = bsc_subscr_find_by_imsi(bsc_subscribers, imsi);
+ OSMO_ASSERT(sfound == bsub);
+
+ bsc_subscr_put(sfound);
+}
+
+static void test_bsc_subscr(void)
+{
+ struct bsc_subscr *s1, *s2, *s3;
+ const char *imsi1 = "1234567890";
+ const char *imsi2 = "9876543210";
+ const char *imsi3 = "5656565656";
+
+ printf("Test BSC subscriber allocation and deletion\n");
+
+ /* Check for emptiness */
+ VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d");
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL);
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL);
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL);
+
+ /* Allocate entry 1 */
+ s1 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi1);
+ VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d");
+ assert_bsc_subscr(s1, imsi1);
+ VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d");
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL);
+
+ /* Allocate entry 2 */
+ s2 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi2);
+ VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d");
+
+ /* Allocate entry 3 */
+ s3 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi3);
+ VERBOSE_ASSERT(llist_count(bsc_subscribers), == 3, "%d");
+
+ /* Check entries */
+ assert_bsc_subscr(s1, imsi1);
+ assert_bsc_subscr(s2, imsi2);
+ assert_bsc_subscr(s3, imsi3);
+
+ /* Free entry 1 */
+ bsc_subscr_put(s1);
+ s1 = NULL;
+ VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d");
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL);
+
+ assert_bsc_subscr(s2, imsi2);
+ assert_bsc_subscr(s3, imsi3);
+
+ /* Free entry 2 */
+ bsc_subscr_put(s2);
+ s2 = NULL;
+ VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d");
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL);
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL);
+ assert_bsc_subscr(s3, imsi3);
+
+ /* Free entry 3 */
+ bsc_subscr_put(s3);
+ s3 = NULL;
+ VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d");
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL);
+
+ OSMO_ASSERT(llist_empty(bsc_subscribers));
+}
+
+int main()
+{
+ printf("Testing BSC subscriber core code.\n");
+ osmo_init_logging(&log_info);
+ log_set_print_filename(osmo_stderr_target, 0);
+ log_set_print_timestamp(osmo_stderr_target, 0);
+ log_set_use_color(osmo_stderr_target, 0);
+ log_set_print_category(osmo_stderr_target, 1);
+ log_set_category_filter(osmo_stderr_target, DREF, 1, LOGL_DEBUG);
+
+ bsc_subscribers = talloc_zero(NULL, struct llist_head);
+ INIT_LLIST_HEAD(bsc_subscribers);
+
+ test_bsc_subscr();
+
+ printf("Done\n");
+ return 0;
+}
diff --git a/tests/subscr/bsc_subscr_test.err b/tests/subscr/bsc_subscr_test.err
new file mode 100644
index 000000000..a66317a36
--- /dev/null
+++ b/tests/subscr/bsc_subscr_test.err
@@ -0,0 +1,17 @@
+DREF BSC subscr IMSI:1234567890 usage increases to: 2
+DREF BSC subscr IMSI:1234567890 usage decreases to: 1
+DREF BSC subscr IMSI:1234567890 usage increases to: 2
+DREF BSC subscr IMSI:1234567890 usage decreases to: 1
+DREF BSC subscr IMSI:9876543210 usage increases to: 2
+DREF BSC subscr IMSI:9876543210 usage decreases to: 1
+DREF BSC subscr IMSI:5656565656 usage increases to: 2
+DREF BSC subscr IMSI:5656565656 usage decreases to: 1
+DREF BSC subscr IMSI:1234567890 usage decreases to: 0
+DREF BSC subscr IMSI:9876543210 usage increases to: 2
+DREF BSC subscr IMSI:9876543210 usage decreases to: 1
+DREF BSC subscr IMSI:5656565656 usage increases to: 2
+DREF BSC subscr IMSI:5656565656 usage decreases to: 1
+DREF BSC subscr IMSI:9876543210 usage decreases to: 0
+DREF BSC subscr IMSI:5656565656 usage increases to: 2
+DREF BSC subscr IMSI:5656565656 usage decreases to: 1
+DREF BSC subscr IMSI:5656565656 usage decreases to: 0
diff --git a/tests/subscr/bsc_subscr_test.ok b/tests/subscr/bsc_subscr_test.ok
new file mode 100644
index 000000000..0f6a8be01
--- /dev/null
+++ b/tests/subscr/bsc_subscr_test.ok
@@ -0,0 +1,11 @@
+Testing BSC subscriber core code.
+Test BSC subscriber allocation and deletion
+llist_count(bsc_subscribers) == 0
+llist_count(bsc_subscribers) == 1
+llist_count(bsc_subscribers) == 1
+llist_count(bsc_subscribers) == 2
+llist_count(bsc_subscribers) == 3
+llist_count(bsc_subscribers) == 2
+llist_count(bsc_subscribers) == 1
+llist_count(bsc_subscribers) == 0
+Done
diff --git a/tests/subscr/subscr_test.c b/tests/subscr/subscr_test.c
new file mode 100644
index 000000000..2a5d0e1c2
--- /dev/null
+++ b/tests/subscr/subscr_test.c
@@ -0,0 +1,117 @@
+/* (C) 2008 by Jan Luebbe <jluebbe@debian.org>
+ * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2014 by Alexander Chemeris <Alexander.Chemeris@fairwaves.co>
+ * All Rights Reserved
+ *
+ * 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 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/>.
+ *
+ */
+
+#include <openbsc/debug.h>
+#include <openbsc/db.h>
+#include <openbsc/gsm_subscriber.h>
+#include <openbsc/gsm_04_11.h>
+
+#include <osmocom/core/application.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <inttypes.h>
+
+static struct gsm_network dummy_net;
+static struct gsm_subscriber_group dummy_sgrp;
+
+static void test_subscr(void)
+{
+ struct gsm_subscriber *subscr;
+ const char *imsi = "1234567890";
+
+ printf("Test subscriber allocation and deletion\n");
+
+ /* Don't keep subscr */
+
+ dummy_sgrp.keep_subscr = 0;
+
+ OSMO_ASSERT(llist_empty(&active_subscribers));
+
+ subscr = subscr_get_or_create(&dummy_sgrp, imsi);
+
+ OSMO_ASSERT(!llist_empty(&active_subscribers));
+ OSMO_ASSERT(subscr->use_count == 1);
+
+ subscr_put(subscr);
+
+ OSMO_ASSERT(llist_empty(&active_subscribers));
+
+ /* Keep subscr */
+
+ dummy_sgrp.keep_subscr = 1;
+
+ subscr = subscr_get_or_create(&dummy_sgrp, imsi);
+
+ OSMO_ASSERT(!llist_empty(&active_subscribers));
+ OSMO_ASSERT(subscr->use_count == 1);
+
+ subscr_put(subscr);
+ OSMO_ASSERT(!llist_empty(&active_subscribers));
+ OSMO_ASSERT(subscr->use_count == 0);
+
+ subscr_get(subscr);
+ OSMO_ASSERT(subscr->use_count == 1);
+
+ subscr_purge_inactive(&dummy_sgrp);
+
+ OSMO_ASSERT(!llist_empty(&active_subscribers));
+ OSMO_ASSERT(subscr->use_count == 1);
+
+ subscr_put(subscr);
+ OSMO_ASSERT(!llist_empty(&active_subscribers));
+ OSMO_ASSERT(subscr->use_count == 0);
+
+ subscr_purge_inactive(&dummy_sgrp);
+
+ OSMO_ASSERT(llist_empty(&active_subscribers));
+
+ /* Test force_no_keep */
+
+ dummy_sgrp.keep_subscr = 0;
+
+ subscr = subscr_get_or_create(&dummy_sgrp, imsi);
+ OSMO_ASSERT(subscr);
+ subscr->keep_in_ram = 1;
+
+ OSMO_ASSERT(!llist_empty(&active_subscribers));
+ OSMO_ASSERT(subscr->use_count == 1);
+
+ subscr->keep_in_ram = 0;
+
+ subscr_put(subscr);
+ OSMO_ASSERT(llist_empty(&active_subscribers));
+}
+
+int main()
+{
+ printf("Testing subscriber core code.\n");
+ osmo_init_logging(&log_info);
+ log_set_print_filename(osmo_stderr_target, 0);
+
+ dummy_net.subscr_group = &dummy_sgrp;
+ dummy_sgrp.net = &dummy_net;
+
+ test_subscr();
+
+ printf("Done\n");
+ return 0;
+}
diff --git a/tests/subscr/subscr_test.ok b/tests/subscr/subscr_test.ok
new file mode 100644
index 000000000..72a376944
--- /dev/null
+++ b/tests/subscr/subscr_test.ok
@@ -0,0 +1,3 @@
+Testing subscriber core code.
+Test subscriber allocation and deletion
+Done
diff --git a/tests/testsuite.at b/tests/testsuite.at
new file mode 100644
index 000000000..280aeb2ed
--- /dev/null
+++ b/tests/testsuite.at
@@ -0,0 +1,167 @@
+AT_INIT
+AT_BANNER([Regression tests.])
+
+AT_SETUP([gsm0408])
+AT_KEYWORDS([gsm0408])
+cat $abs_srcdir/gsm0408/gsm0408_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/gsm0408/gsm0408_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([subscr])
+AT_KEYWORDS([subscr])
+cat $abs_srcdir/subscr/subscr_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/subscr/subscr_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([bsc_subscr])
+AT_KEYWORDS([bsc_subscr])
+cat $abs_srcdir/subscr/bsc_subscr_test.ok > expout
+cat $abs_srcdir/subscr/bsc_subscr_test.err > experr
+AT_CHECK([$abs_top_builddir/tests/subscr/bsc_subscr_test], [], [expout], [experr])
+AT_CLEANUP
+
+AT_SETUP([db])
+AT_KEYWORDS([db])
+cat $abs_srcdir/db/db_test.ok > expout
+cat $abs_srcdir/db/db_test.err > experr
+cat $abs_srcdir/db/hlr.sqlite3 > hlr.sqlite3
+AT_CHECK([$abs_top_builddir/tests/db/db_test], [], [expout], [experr])
+AT_CLEANUP
+
+AT_SETUP([channel])
+AT_KEYWORDS([channel])
+cat $abs_srcdir/channel/channel_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/channel/channel_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([mgcp])
+AT_KEYWORDS([mgcp])
+cat $abs_srcdir/mgcp/mgcp_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/mgcp/mgcp_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([mgcp-trans])
+AT_KEYWORDS([mgcp-trans])
+AT_CHECK([test "$enable_mgcp_transcoding_test" == yes || exit 77])
+cat $abs_srcdir/mgcp/mgcp_transcoding_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/mgcp/mgcp_transcoding_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([gprs])
+AT_KEYWORDS([gprs])
+cat $abs_srcdir/gprs/gprs_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/gprs/gprs_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([bsc-nat])
+AT_KEYWORDS([bsc-nat])
+AT_CHECK([test "$enable_nat_test" != no || exit 77])
+cp $abs_srcdir/bsc-nat/prefixes.csv .
+cp $abs_srcdir/bsc-nat/barr.cfg .
+cp $abs_srcdir/bsc-nat/barr_dup.cfg .
+cat $abs_srcdir/bsc-nat/bsc_nat_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/bsc-nat/bsc_nat_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([smpp])
+AT_KEYWORDS([smpp])
+AT_CHECK([test "$enable_smpp_test" != no || exit 77])
+cat $abs_srcdir/smpp/smpp_test.ok > expout
+cat $abs_srcdir/smpp/smpp_test.err > experr
+AT_CHECK([$abs_top_builddir/tests/smpp/smpp_test], [], [expout], [experr])
+AT_CLEANUP
+
+AT_SETUP([bsc-nat-trie])
+AT_KEYWORDS([bsc-nat-trie])
+AT_CHECK([test "$enable_nat_test" != no || exit 77])
+cp $abs_srcdir/bsc-nat-trie/prefixes.csv .
+cat $abs_srcdir/bsc-nat-trie/bsc_nat_trie_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/bsc-nat-trie/bsc_nat_trie_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([abis])
+AT_KEYWORDS([abis])
+cat $abs_srcdir/abis/abis_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/abis/abis_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([bsc])
+AT_KEYWORDS([bsc])
+AT_CHECK([test "$enable_bsc_test" != no || exit 77])
+cat $abs_srcdir/bsc/bsc_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/bsc/bsc_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([gbproxy])
+AT_KEYWORDS([gbproxy])
+cat $abs_srcdir/gbproxy/gbproxy_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/gbproxy/gbproxy_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([trau])
+AT_KEYWORDS([trau])
+cat $abs_srcdir/trau/trau_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau/trau_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([sgsn])
+AT_KEYWORDS([sgsn])
+AT_CHECK([test "$enable_sgsn_test" != no || exit 77])
+cat $abs_srcdir/sgsn/sgsn_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/sgsn/sgsn_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([oap])
+AT_KEYWORDS([oap])
+AT_CHECK([test "$enable_oap_test" != no || exit 77])
+cat $abs_srcdir/oap/oap_client_test.ok > expout
+cat $abs_srcdir/oap/oap_client_test.err > experr
+AT_CHECK([$abs_top_builddir/tests/oap/oap_client_test], [], [expout], [experr])
+AT_CLEANUP
+
+AT_SETUP([gtphub])
+AT_KEYWORDS([gtphub])
+AT_CHECK([test "$enable_gtphub_test" != no || exit 77])
+cat $abs_srcdir/gtphub/gtphub_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/gtphub/gtphub_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([mm_auth])
+AT_KEYWORDS([mm_auth])
+cat $abs_srcdir/mm_auth/mm_auth_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/mm_auth/mm_auth_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([xid])
+AT_KEYWORDS([xid])
+AT_CHECK([test "$enable_sgsn_test" != no || exit 77])
+cat $abs_srcdir/xid/xid_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/xid/xid_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([sndcp_xid])
+AT_KEYWORDS([sndcp_xid])
+AT_CHECK([test "$enable_sgsn_test" != no || exit 77])
+cat $abs_srcdir/sndcp_xid/sndcp_xid_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/sndcp_xid/sndcp_xid_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([slhc])
+AT_KEYWORDS([slhc])
+AT_CHECK([test "$enable_sgsn_test" != no || exit 77])
+cat $abs_srcdir/slhc/slhc_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/slhc/slhc_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([v42bis])
+AT_KEYWORDS([v42bis])
+AT_CHECK([test "$enable_sgsn_test" != no || exit 77])
+cat $abs_srcdir/v42bis/v42bis_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/v42bis/v42bis_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([nanobts_omlattr])
+AT_KEYWORDS([nanobts_omlattr])
+cat $abs_srcdir/nanobts_omlattr/nanobts_omlattr_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/nanobts_omlattr/nanobts_omlattr_test], [], [expout], [ignore])
+AT_CLEANUP
diff --git a/tests/trau/Makefile.am b/tests/trau/Makefile.am
new file mode 100644
index 000000000..1d014ba3c
--- /dev/null
+++ b/tests/trau/Makefile.am
@@ -0,0 +1,45 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBOSMOABIS_CFLAGS) \
+ $(LIBSMPP34_CFLAGS) \
+ $(COVERAGE_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(COVERAGE_LDFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ trau_test.ok \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ trau_test \
+ $(NULL)
+
+trau_test_SOURCES = \
+ trau_test.c \
+ $(NULL)
+
+trau_test_LDADD = \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOABIS_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBSMPP34_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
+ $(LIBRARY_DL) \
+ -ldbi \
+ $(NULL)
+
diff --git a/tests/trau/trau_test.c b/tests/trau/trau_test.c
new file mode 100644
index 000000000..c74e6dbb3
--- /dev/null
+++ b/tests/trau/trau_test.c
@@ -0,0 +1,84 @@
+/* (C) 2013 by Andreas Eversberg <jolly@eversberg.eu>
+ * All Rights Reserved
+ *
+ * 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 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/>.
+ *
+ */
+
+#include <osmocom/abis/trau_frame.h>
+#include <openbsc/trau_mux.h>
+#include <osmocom/core/msgb.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+void test_trau_fr_efr(unsigned char *data)
+{
+ struct decoded_trau_frame tf;
+ struct msgb *msg;
+ struct gsm_data_frame *frame;
+
+ printf("Testing TRAU FR transcoding.\n");
+ data[0] = 0xd0;
+ trau_encode_fr(&tf, data);
+ tf.c_bits[11] = 0; /* clear BFI */
+ msg = trau_decode_fr(1, &tf);
+ OSMO_ASSERT(msg != NULL);
+ frame = (struct gsm_data_frame *)msg->data;
+ OSMO_ASSERT(frame->msg_type == GSM_TCHF_FRAME);
+ OSMO_ASSERT(!memcmp(frame->data, data, 33));
+ msgb_free(msg);
+
+ printf("Testing TRAU EFR transcoding.\n");
+ data[0] = 0xc0;
+ trau_encode_efr(&tf, data);
+ OSMO_ASSERT(tf.d_bits[0] == 1); /* spare bit must be 1 */
+ tf.c_bits[11] = 0; /* clear BFI */
+ msg = trau_decode_efr(1, &tf);
+ OSMO_ASSERT(msg != NULL);
+ frame = (struct gsm_data_frame *)msg->data;
+ OSMO_ASSERT(frame->msg_type == GSM_TCHF_FRAME_EFR);
+ OSMO_ASSERT(!memcmp(frame->data, data, 31));
+
+ printf("Testing TRAU EFR decoding with CRC error.\n");
+ tf.d_bits[0] = 0; /* spare bit must be included */
+ msg = trau_decode_efr(1, &tf);
+ OSMO_ASSERT(msg != NULL);
+ frame = (struct gsm_data_frame *)msg->data;
+ OSMO_ASSERT(frame->msg_type == GSM_BAD_FRAME);
+ msgb_free(msg);
+}
+
+int main()
+{
+ unsigned char data[33];
+ int i;
+
+ msgb_talloc_ctx_init(NULL, 0);
+
+ memset(data, 0x00, sizeof(data));
+ test_trau_fr_efr(data);
+ memset(data, 0xff, sizeof(data));
+ test_trau_fr_efr(data);
+ srandom(42);
+ for (i = 0; i < sizeof(data); i++)
+ data[i] = random();
+ test_trau_fr_efr(data);
+ printf("Done\n");
+ return 0;
+}
+
+/* stubs */
+void vty_out() {}
diff --git a/tests/trau/trau_test.ok b/tests/trau/trau_test.ok
new file mode 100644
index 000000000..ef7123073
--- /dev/null
+++ b/tests/trau/trau_test.ok
@@ -0,0 +1,10 @@
+Testing TRAU FR transcoding.
+Testing TRAU EFR transcoding.
+Testing TRAU EFR decoding with CRC error.
+Testing TRAU FR transcoding.
+Testing TRAU EFR transcoding.
+Testing TRAU EFR decoding with CRC error.
+Testing TRAU FR transcoding.
+Testing TRAU EFR transcoding.
+Testing TRAU EFR decoding with CRC error.
+Done
diff --git a/tests/v42bis/Makefile.am b/tests/v42bis/Makefile.am
new file mode 100644
index 000000000..a031e33bd
--- /dev/null
+++ b/tests/v42bis/Makefile.am
@@ -0,0 +1,15 @@
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBCARES_CFLAGS)
+
+EXTRA_DIST = v42bis_test.ok
+
+noinst_PROGRAMS = v42bis_test
+
+v42bis_test_SOURCES = v42bis_test.c
+
+v42bis_test_LDADD = \
+ $(top_builddir)/src/gprs/v42bis.o \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOCORE_LIBS)
+
+
diff --git a/tests/v42bis/v42bis_test.c b/tests/v42bis/v42bis_test.c
new file mode 100644
index 000000000..7e907858d
--- /dev/null
+++ b/tests/v42bis/v42bis_test.c
@@ -0,0 +1,435 @@
+/* Test v42bis Compression/Decompression */
+
+/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
+ * All Rights Reserved
+ *
+ * Author: 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/>.
+ */
+
+#include <openbsc/v42bis.h>
+#include <openbsc/v42bis_private.h>
+#include <openbsc/debug.h>
+
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+
+#include <osmocom/core/application.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+
+/* V.42bis compression parameters */
+#define P0 3 /* Direction */
+#define P1 512 /* Max number of codewords */
+#define P2 20 /* Max string length */
+
+/* V.42bis compression buffer size
+ * (Does not affect the compression/decompression result) */
+#define MAX_BLOCK_SIZE 1024
+
+/* Compressed sample packets, sniffed from real communication */
+#define COMPR_PACKETS_LEN 33
+char *compr_packets[] = {
+ /* K800i */
+ "4500010268000700004006cefac0a80002550d93d740000050462c7ba7e4d1753a80184000aad500000101080a0001a670084dafb4474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005ab97a052b960d59b368d5b2ddb3e60e9c372ef610b6dbf56bd8b165030f2e7cf88dd63b68f64c3d9b76ed1cb58847b490d122e8d0a24761185913d50e1aa423f0dc49036387d6d7b169e4d0cac68e1cd93b70f0804123f7eee03372dcc801038f193b306a68b5b2864d9a3b629a30b1a2b5081b35384613357a07c6133271d4e021a3064d52347182ee81b119c69c3a72d2b079b37e4409c177e6f4902163738cdd71f8a0a903d68ec21866e4c0918185087dfb329cec9831834d951a337c4a2e1174891c3badf5e8d113a38f1c336e24520c8a65751d1844d4c7696d852c1f240e992becf8918d0c9145465441939fcc6a1950a206b7e1fca38e1145eaebc129230aeb24f57bcab011c3c68829f5efe7bfcbe4c814e731668c3042f6fef93a62d9909561e4c91123c163d0085a3a4e1c3466c6c649ea048d519d5ff3a0f95ef4280c2471269e61633ee9193469de8845a3554d9fa74199c48622e7fa7dac30ac602f9af40a9ef0236a54268247cd7f923946d0a8d1c3c68d1e35788c5002e54ad0a00100",
+ "4500010268000900004006cef8c0a80002550d93d740000050462c7ba7e4d1753a801840007e7f00000101080a0001d1cc084db0ae474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005ab97a052b960d59b368d5b2ddb3e60e9c372ef610b6dbf56bd8b165030f2e7cf88dd63b68f64c3d9b76ed1cb58847b490d122e8d0a24761185913d50e1aa423f0dc49036387d6d7b169e4d0cac68e1cd93b70f0804123f7eee03372dcc801038f193b306a68b5b2864d9a3b629a30b1a2b5081b35384613357a07c6133271d4e021a3064d52347182ee81b119c69c3a72d2b079b37e4409c177e6f4902163738cdd71f8a0a903d68ec21866e4c0918185087dfb329cec9831834d951a337c4a2e1174891c3badf5e8d113a38f1c336e24520c8a65751d1844d4c7696d852c1f240e992becf8918d0c9145465441939fcc6a1950a206b7e1fca38e1145eaebc129230aeb24f57bcab011c3c68829f5efe7bfcbe4c814e731668c3042f6fef93a62d9909561e4c91123c163d0085a3a4e1c3466c6c649ea048d519d5ff3a0f95ef4280c2471269e61633ee9193469de8845a3554d9fa74199c48622e7fa7dac30ac602f9af40a9ef0236a54268247cd7f923946d0a8d1c3c68d1e35788c5002e54ad0a00100",
+ "4500010268000b00004006cef6c0a80002550d93d740000050462c7ba7e4d1753b80193fff131c00000101080a00022884084dc558474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005ab97a052b960d59b368d5b2ddb3e60e9c372ef610b6dbf56bd8b165030f2e7cf88dd63b68f64c3d9b76ed1cb58847b490d122e8d0a24761185913d50e1aa423f0dc49036387d6d7b169e4d0cac68e1cd93b70f0804123f7eee03372dcc801038f193b306a68b5b2864d9a3b629a30b1a2b5081b35384613357a07c6133271d4e021a3064d52347182ee81b119c69c3a72d2b079b37e4409c177e6f4902163738cdd71f8a0a903d68ec21866e4c0918185087dfb329cec9831834d951a337c4a2e1174891c3badf5e8d113a38f1c336e24520c8a65751d1844d4c7696d852c1f240e992be4e8918d8c9045465441939fcc6a1950a206b7e1dca38e1145eaebb929230aeb24f579cab011c3c68829f5efe7afcbe4c814e731668c3042f6fef93a62d9909561e4c91123c163d0084a3a4e1c3466c6c649ea048dd19c5ff3a0f95ef4280c2471269e61633ee9193469de8845a3554d9fa74199c48622c7fa7dac30ac5c2f9af40a1ef0236a502682478dff913946d0a8d1c3c68d1e35788c5002e54ad0a00100",
+ "4500010268000c00004006cef5c0a80002550d93d740000050462c7ba7e4d1753b80193fff65ab00000101080a0002d5f4084dc558474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005ab97a052b960d59b368d5b2ddb3e60e9c372ef610b6dbf56bd8b165030f2e7cf88dd63b68f64c3d9b76ed1cb58847b490d122e8d0a24761185913d50e1aa423f0dc49036387d6d7b169e4d0cac68e1cd93b70f0804123f7eee03372dcc801038f193b306a68b5b2864d9a3b629a30b1a2b5081b35384613357a07c6133271d4e021a3064d52347182ee81b119c69c3a72d2b079b37e4409c177e6f4902163738cdd71f8a0a903d68ec21866e4c0918185087dfb329cec9831834d951a337c4a2e1174891c3badf5e8d113a38f1c336e24520c8a65751d1844d4c7696d852c1f240e992be4e8918d8c9045465441939fcc6a1950a206b7e1dca38e1145eaebb929230aeb24f579cab011c3c68829f5efe7afcbe4c814e731668c3042f6fef93a62d9909561e4c91123c163d0084a3a4e1c3466c6c649ea048dd19c5ff3a0f95ef4280c2471269e61633ee9193469de8845a3554d9fa74199c48622c7fa7dac30ac5c2f9af40a1ef0236a502682478dff913946d0a8d1c3c68d1e35788c5002e54ad0a00100",
+ "450001022d000f00004006ac5ec0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00",
+ "450001022d001000004006ac5dc0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00",
+ "450001022d001100004006ac5cc0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00",
+ "450001022d001200004006ac5bc0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00",
+ "4500010268001300004006ceeec0a80002550d93d740000050462c7ba7e4d1753b80193fff7b4a00000101080a0003c054084dc558474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005bbb7e0d3b964dd9b369d7b6ddb3e60e9c372ef614beeb15ac58b2660513368cf8cdd63b68f65045ab96ed9cb58947b490d1422851a34861185923d50e9aa423f0dc490363c756d8b269e4d8cac68e9cd93b70f0804143376fe13372dcc801038f193b306a6cb5b2864d9a3b629a30b1b2b5081b353848173d7a07c6133271d4e021a3068d52347184ee81c119c69c3a72d2b079c37e4489c177e6f4902183730cde71f8a0a913d6cec21866e4c091818548fdfb329cec9831834d951a337e4e2e2174891c3baef5e8d113a38f1c336e2656148a85751d1844d6c7716da52c1f240f9b2fecf8918d0c9145465441a39f0c6b1950a40ab7f1fca38e1145ecebc129234aeb24f67bcab011c3c68829f6f1ebb7cbe4c894e731668c3052163ffa3a63d9949561e4c91123c263d0105a3a4e1c3466c8c651ea04cd519d60f3a0016f14290c2471289e61735ee9193469de8c45b3554d1fa84299c88622e73afeac30ac6037aaf40a9ef0236a54268247cd7f923946d0a8d1c3c68d1e35788c5002e58a50a10100",
+ "450001022d001400004006ac59c0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00",
+ "450001022d001500004006ac58c0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00",
+ "4500010239000500004006ac5cc0a800020a0901ab40001f90c286afa741a348cb801840007fcb0000050a41a348dc41a34a440000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d69786564330057b36eedfa954dd8b165cfa6ddb3e60e9c372ef6049eab95ab57b062fd02164cf8cdd53b68f640256b16ed9cb38547b490d1e22791a043efc030b2c6a91d344547e0b99306c68eabad5fd3c871958d1d39b077e0e00183c6eddcbf67e4b89103061e337660d4b86a650d9b3477c4346162e56a11366a7080164d14c6133271d4e021a3068d5134717eee818119c69c3a72d2b079837e4489bf77e6f4902103738cdc71f8a0a9d3d58ec11866e4c091818548fcf9329cec9831834d951a33783e2ef173891c3bab69cc88c1a3674f1d347a6cdcf8134bea3a30889c8fb3da4a583e48162a37a891231b19208b8ca882c63e99d432a038fd6d8339471d238ac8d793534614d549e40b956123868d1153e4d3b77f97c99129cc63cc1861242c7df275beb2092bc3c89323467ef7fc693a4e1c3466c0c631ea04cdd09d5cf3a0e96e66e81d1848e2403cc366bcd13368d2bcf98ae6aa9a3e4c7ffe0c00",
+ "450001025b000a00004006ac35c0a800020a0901ab40011f90c293b0a8af5e58be5018400072a60000474554202f72656470686f6e652e706e6720485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c33005cbd82154b368e59b46ad9ee597307ce1b177b066fedfa35ec583665010b266cf8cdd63b68f6543d9b76ed1cb58747b490d16268d1a34961185933d50e1aa523f0dc490363c7d6d7b169e4d8cac68e1cd93b70f0804123f7eee03372dcc801038f193b306a6cb5b2864d9a3b629a30b1b2b5081b3538461b457a07c6133238f190518366299a3843f7c0d80c634e1d3969d8bc513fa244e03b737ac890b139c6ee387cd0d4096b07610c3372e0c8c042647e7d194e76cc98c1a64a8d1940259718ba448e9dd63466c4e01134a80e1a3d38721c8a65751d1844d2c7696d65261f240d9923dcd8918d0c9045465441839fcc6a1950a606b7e1bca38e1145e8ebd929230aeb24f485cab011c3c68829f4ede3d7cbe4c814e731668c3032d3be1a3c75c6b2296be4c91123c1830e451d270e1a3364e32c758206694fb079d07c3f9a1406923812cfb0c1b9f40c9a346fc6a2d9aaa64fd4a175d33064b894bfff812b5bc2a421b3e60c8e32860e0d00",
+ "4500010267001200004006ac21c0a800020a0901ab40011f90c293b0a8af5e58be80184000ee770000050aaf5e6437af5e8c230000474554202f72656470686f6e652e706e6720485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d33006fc8de41b3c72b5cb974e7cc853ca2858c164c9d42950ac3c81aae76d04c1d81e74e1a183bc8e2d64d2307593676e4ecde8183070c1ac2892b9f91e3460e1878ccd8815183ac95356cd2dc11d3848915b245d8a8c1c1fa69d43b309e90098a878c1a3454d1c461ba0706691873eac849c3e6cdfc112514df99d343860cd23188c7e183a68e5a3b126398910347061622fcfdcb70b263c60c36556acc48bab904d32572ecd8a63123060fa54a75d0e861d224532cb4ebc020223f8e6d2b3cf920b1585d62c9936c64a82c32a20a9a826468cb80c255b98deb27758c28d25f4f5119516a27e9df54868d1836464ce9ffbf20612647a65c8f316384119effd5e0a9c3968d5b234f8e1851ae94a9ec3871d098691b87aa1334518fa6cd83063d54a93090c4d978864d50aa67d0a479c3160d59357db432fd9ba66245aa0a193aac7953278d9e3f679894c1946900",
+ "4500010236003000004006cf03c0a80002550d93d740020050c30e84a9441d06ac80184000c2f400000101080a00052df410fc31bd474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005cbd82154b968d59b46ad9baddb3e60e9c372ef618c6fb35ecd8b26707173e9cf80dd73b68f6544dbbb6ed1cb68a47b490d16268d1a34961185933d50e1aa523f0dc49036307d7d8b369e4e0cac68e1cda3b70f080416377efe13372dcc801038f193b306a70b5b2864d9a3b629a30b1c2b5081b35384a1b457a07c6133271d4e021a306cd52347186ee81d119c69c3a72d2b079d37e4409c277e6f49021a3738cde71f8a0a923d60ec31866e4c0918185887dfc329cec9831834d951a3380522e3174891c3baff5e8d113a38f1c336e285a1c8aa5751d1844d8c7796dc52c1f24109d33f408928d8c9145465441b39f4c6b1950a60eb7011da48e1145eeebc929238aeb24f77dcab011c3c68829f7f3efbfcbe4c814e831668c3062367ffa3a64d9989561e4c91123c363d0186a3a4e1c3466cac659ea040dd29d61f3a0097f34290c24712a9e61837ee9193469de9045c3554d9fa843870600",
+ "4500010260004500004006cec4c0a80002550d93d740030050c3134faac89c8b2980184000578d00000101080a000535c010fc34c8474554202f6e697276616e612e63737320485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d33006fcede41b3072c5dbb78e7dcad3ca2858c164ea14aa50ac3c81aaf76d0541d81e74e1a183bcef2f64d23c7593676e4fcde8183070c1ac6913b9f91e3460e187884c2a871d6ca1a3669ee8869c2c4cad9226cd4e0801d75ea1d184f7caac143460d1aab68e238dd0303358c3975e4a461f3c6fe88128fefcce9214306ea18c8e3f04153a7edd0b841e5c0918185c87f83329cec9831834d951a33967e2ee174891c3bbaf5e8d113a38f1c336e3ac2718a05771d1844eac7d16d252e1f241985563489928d8c954546544193900c6e1950bc3ab7a11da58e11450aea292a234aee240595cab011c3c68829050f2624cce4c814ed31668c3012f7a0fc3a6fd9c49561e4c91123ce63d0702a3b4e1c3466e0c6b1ea04cdd4a36cf3a0592f952a0c2471ccc839c3268e1aab67d0a479f316cd59357db83af59b062346ab0d1f46b47933e7ce9e329c3a0d00",
+ "4500010264004600004006cebfc0a80002550d93d740040050c3135bab2189da61801840008f2d00000101080a000535c410fc34dc474554202f382d4269742f4c6162656c2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300952fbf517b07cd1e9f77f3ee9da317f38816325a48a56a152b0c236bc4da419375049e3b6960ec50fb3b388d1c6ad9d891237c070e1e3068245f1e7d468e1b3960e0316307460db556d6b04973474c132656d4f254836376d5ab7760008da3060f193568b4a28923750f8cd530e6d4919386cd9bfc234a48be33a7870c19ab632c8fc3074d1db87630c63023078e0c2c440c2294e164c78c196caad498f1547409a94be4d8e9ad478f9e187de498710352a4542cbbebc020823f4e6f2b74f920e1c81da34a966c64bc2c32a20a1a866476cb802236ba0def2c758c2872500f521951782739d854868d1836464c39a89061612647a6788f31638411ba0aebd791cb86ae0c234f8e18891e838654da71e2a03133378e562768ae2a7d9b078d7bab5861208913f20c1bfa5acfa049f3462e1ab56afa80950a38cdc68d5a214aa4a873e74fa144474a951a00",
+ "4500010264005800004006ceadc0a80002550d93d740050050c31389acaf7b26538018400075c900000101080a000537d010fc354a474554202f382d4269742f41636f726e2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300942dbf497b07cd1e9f76f1ea9d93f7f28816325a48a56af50e0c236bc2da418375049e3b6960ec48eb1b388d1c69d9d891137c070e1e306820570e7d468e1b3960e0316307468db456d6b04973474c132656d2f2548343b699aa57613c2113470d1e326ad064451347ea1e18aa61cca923270d9b37f94794887c674e0f193254c7501e870f9a3a6fed608c11148e0c2c440c2294e164c78c196caad498f1347409a94be4d8e1ad478f9e187de4987103520e1ca95874d78141047f1cde56e6f241c2713bc6942bd9c87059644415340cc9e89601252c741bdd57ea1851e4a09ea432a2ec4e72d0a90c1b316c8c9872502143c34c8e4ce91e63c608237315d6af1397cd5c19469e1c31023d060da9b4e3c44163466e9cac4ed0585dea360f9af6efefc0401227e81936f4b39e4193e64d5c3469d5f4f92a15709a8d1bb342944831a7ce9e42898a942a3500",
+ "4500010266007600004006ce8dc0a80002550d93d740060050c31431ada11fa06780184000f08e00000101080a00053b3c10fc35ef474554202f382d4269742f416d73747261642e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d33009733bf597b07cd9e9e78f5f2d5a379440b192da656bd9a1586913563eda0d13a02cf9d343076ac052e9c468eb56cecc819be03070f18349433973e23c78d1c30f098b103a3c65a2b6bd8a4b923a609132b6b77aac141db2ad63b309e9089a3060f193568b6a28933750f0cc830e6d4919386cd9bfd234a50be33a7870c199063308fc3074d9db87636c63023078e0c2c44103294e164c78c196caad49801957489a94be404ddaa478f9e187de4987133b2e4542cbcebc020a23f8e6f2b75f920f9d87d63cb976c64c82c32a20a9a876478cb803256ba8def2f758c28a2500f5319517a27512855868d1836464c51d8f061622647a67c8f31638491ba0defd799cba6ae0c234f8e18911e83c6d4db71e2a0314337ce562768b03a859b07cdfbab5961208943f20c1bfb5bcfa049f3662e9ab56afa849d3a388d478f5b2756bcf813e850a3484d4e9d1a00",
+ "4500010264007700004006ce8ec0a80002550d93d740040050c3135ddb2189e0108018400060d600000101080a00053b4010fc35e7474554202f382d4269742f41746172692e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300932bbf497b07cd1e9f76f1ea9d93d7f28816325a48a56a152b0c236b84da419375049e3b6960ec48dbfb378d1c69d9d891037c070e1e30681c4ffe7c468e1b3960e0316307468db456d6b04973474c132656d2f254832376d5ab77603c2113470d1e326ad068451347ea1e18a961cca923270d9b37f84794807c674e0f193252c7481e870f9aa1da2fc63023078e0c2c440a1e94e164c78c196caad498f1147409a94be4d8d9ad478f9e187de49871e311a4542cb9ebc020723fce6e2b73f920d968e7224a956c64b42c32a20a9a856472cb8022f4b90dee2a758c286250cf511951742731c854868d1836464c31887061612647a6708f31638491b908e9d789cb66ae0c234f8e18791e8386d4d971e2a03123378e562768ae26759b070d7bab58612089f3f10c9bf95acfa049f3262e9ab46afa8095fa378d468d5a1f469c8833e7ce9f41434a951a00",
+ "4500010264007c00004006ce89c0a80002550d93d740070050c314f3aefa37ceb18018400009f900000101080a00053e3410fc369e474554202f382d4269742f4170706c652e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300942dbf517b07cd1e9f76f1ea9d93f7f28816325a48a56a152b0c236bc4da419375049e3b6960ec50dbfb378d1c6ad9d891037c070e1e30681c4ffe7c468e1b3960e0316307460db556d6b04973474c132656d4f254832376d5ab77603c2113470d1e326ad068451347ea1e18a961cca923270d9ba15a4b44be33a7870c19a963248fc3074d9db7762cc63023078e0c2c400da691e164c78c196caad498f1147409a94be4d8d9ad478f9e187de49871e311a4542cb9ebc020723fce6e2b73f920d1a8dd224a956c64b42c32a20a9aa16472cb8022f6b90dee2a758c2862504f521951742731e854868d1836464c29a910cd602647a6708f31638491b908e9d789cb66ae0c234f8e18791e8386d4d971e2a03123378e562768ae2e7dc3260f1af656b1c24012e7e31936f3b59e4193e64d5c346ad5f4012bd56f9a8c19b53a84281167ce9d3f8b86942a3500",
+ "4500010265007d00004006ce87c0a80002550d93d740050050c3138bdcaf7b296780183cec0de600000101080a00053e3410fc368e474554202f382d4269742f447261676f6e2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d33009631bf597b07cd1e9f8df5f2d59379440b192da656bd9a1586913563eda0d13a02cf9d343076ac052e9c468eb56cecc819be03070f18349433973e23c78d1c30f098b103a3c65a2b6bd8a4b923a609132b6b79aac141db2ad63b309e9089a3068f50345bd1c499ba07c6631873eac849c3e68dfe112526df99d343868cc73198c7e183a64e5c3b1963989103470616220715ca70b263c60c36556acc804abac4d42572ecf8d6a3474f8c3e72ccb80939722a16de75601051c3dfb715a27c9074ec9e71654b363260161951054d4332bc6540192bddc6f7963a461441a847a98c28bd93208ce3d3460c1b23a6205cd89030932353bec79831c208d185f7ebcc6553d7c8932346a4c7a03175769c3868ccd08db3d5091aac4ce1e641f3fe6a561848e2883cc3c6fed63368d2bc998b66ad9a3e61a7fe4dc391e3d688132beeec0974a8519253a70600",
+ "4500010269008000004006ce80c0a80002550d93d740060050c3143301dfa11fa3de80183c892b5d00000101080a0005412c10fc3761474554202f382d4269742f456e74657270726973652e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f6600952f67defcc66dd03d3df7f6fd3bc72fe7112d64b4b08a552b571846d6983dda75049e3b6960ec701b7c388d1c6e8dca21be03070f183496db694e63468e1b3960e0316307460db756d6b04973474c132656dcee5483c376d6ad77603c2113470d1e326ad0784513c7ea1e18ae6110959386cd1bfe234a58be33a7870c19ae63548fc347285d3b1b63989103470616220ad3c870b263c60c36556acc986aba84d52572ecfcd6a3474f8c3e72ccb81149d22a96a3756010d91fe7b715bc7c90d4f9b891a54b36326216195105cd4332476540312bdd0678973a4614a923478f531951d0dc49d299aa0c1b316c8c98d2b9e143c64c8e4c011f63c60823781be2af63970d5e19469e1c31223d060dabbce3c44163e66e1caf4ed06c853a370f1af85ab9c2401267e41936f7bd9e4193e68d5d346ed5f4216bd5701aa142bd4eac78d1e7cfa1489596b46a3500",
+ "4500010268008100004006ce80c0a80002550d93d740040050c313600b2189e30280183d0e896b00000101080a000541d810fc379d474554202f382d4269742f436f6d6d6f646f72652e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f3300952f67defcc6ed1d347b7ceeedfb778e5fce235ac8686115ab56ae308cac316b074dd71178eea481b1c3edf0e23472b86563478ef11d3878c0a0d1fc79f519396ee48081c78c1d1835dc5a59c326cd1d314d985871cb530d8edb59b7de81f1844c1c3578c8a841e3154d1cab7b60bc8631a78e9c346cdef81f51c2f29d393d64c8781de3791c3e68ead0b5d3318699a032b01061e85086931d3366b0a95263c654d325ac2e916327b81e3d7a62f49163c64dc9a056b1fcae038348ff38c1ade0e5832424f88e2e61b29131b3c8882a682292f92d038ad9ea36c4c3d431a248433d4c6544019ea46154193662d81831a5e1c38889991c99223ec68c1146f03ed45fc72e1bbc328c3c3962a47a0c1a5671c78983c6ccdd385e9da0d9ea746e1e34f2b5728581248ec9336cf27b3d8326cd1bbb68dcaae943d62ae13420417aad78312350a1448d228523c3aad500",
+ "4500010263008200004006ce84c0a80002550d93d740050050c3138e0daf7b2cf180183962cb2f00000101080a000542b410fc3822474554202f382d4269742f454143412e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b330096dfa4bd83668f4fbb78f5cec97b79440b192da24ead7a1586913561eda0c13a02cf9d343076a4f50d9c468eb46cecc809be03070f1834902b873e23c78d1c30f098b103a3465a2b6bd8a4b923a609132b6979aac1219baad53b309e9089a3060f193568b2a28913750f0cd530e6d4919386cd9bfc234a44be33a7870c19aa63288fc3074d9db77630c63023078e0c2c440c2294e164c78c196caad498e1347489a84be4d8e1ad478f9e187de49871035264542cbaebc020823f0e6f2b73f920e1b81da34a966c64bc2c32a20a1a866474cb801216ba8dee2c758c287250cf511951762739c854868d1836464c39a89021612647a6748f31638491b90aebd789cb66ae0c234f8e18811e8346d4d971e2a03123374e562768ac26759b074dfbaa5761208913f20c1bfa59cfa049f3262e9ab46afa7c8dfa37cdc68d59214aa4a873e7cfa04347468d1a00",
+ "4500010262008500004006ce82c0a80002550d93d740070050c314f5defa37d29b80183c168b6100000101080a000542c810fc37e5474554202f382d4269742f4d53582e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b330095dfa0bd83668fcfba77f3cec16b79440b192da04aa56a1586913560eda0b93a02cf9d343076a0edfd9b460eb46cecc801be03070f18348e277f3e23c78d1c30f098b103a3065a2b6bd8a4b923a609132b6879aac1117b6ad53b309e9089a3060f193568b0a28903750f8cd430e6d4919386cd1bfc234a40be33a7870c19a963248fc3074d1db7762ec63023078e0c2c440a1e94e164c78c196caad498d1147409a84be4d8d9ad478f9e187de49871f33124542cb9ebc020723fce6e2b72f920d9a8fd62ca956c64b82c32a20a9a856472cb8002f6b90dee2b758c2862508f511951742731b854868d1836464c318870e1602647a6708f31638411b908e9d781cb46ae0c234f8e18791e830654d971e2a03113370e562768aa226d9b070d7baa5661208903f20c9bf958cfa049f3062e1ab46afa7885ea378d468d581f469c9853674fa0424542851a00",
+ "4500010265009400004006ce70c0a80002550d93d740060050c3143614a11fa986801836e1f43c00000101080a000545b010fc38b7474554202f382d4269742f4d617474656c2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300942dbf512b744fcfbb79f7ced17b79440b192da452b58a1586913562eda0c93a02cf9d343076a8edfd9b460eb56cecc801be03070f18348e277f3e23c78d1c30f098b103a3865a2b6bd8a4b923a609132b6a77aac111bbead53b309e9089a3060f193568b4a28923750f8cd430e6d4919386cd1bfc234a44be33a7870c19a963248fc3074d1db87630c63023078e0c2c440a1e94e164c78c196caad498f1347409a94be4d8d9ad478f9e187de498710352a4542cb9ebc020723fce6e2b74f920e1a81da34a966c64bc2c32a20a1a866472cb8022f6b90dee2c758c2862504f521951742731e854868d1836464c31889021612647a6708f31638411ba08e9d791bbd8c89323469ec7a02195769c3868cc7ca5abd5099aab4bdfe641c3de2a561848e2843cc366bed63368d2bc018a46ad9a3e60a5fe4db371a356881229eae4f97368d19152a50600",
+ "4500010263009900004006ce6dc0a80002550d93d740040050c313623f2189e66b801839a5739a00000101080a0005464c10fc38f3474554202f382d4269742f4f7269632e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b330095dfa4bd83668f4fc578f5eab13ca2858c1651a756bd0ac3c89ab076d0601d81e74e1a183bd2fa064e23475a3676e404df8183070c1ac895439f91e3460e1878ccd8815123ad95356cd2dc11d3848995b43cd5e0904dd5ea1d184fc8c45183878c1a3459d1c489ba0706631873eac849c3e64dfe112520df99d343860cc63194c7e18326e8768c31ccc88123030b1183086538d93163069b2a356638155d22ea12397678ebd1a327461f3966dc7c0c19158bee3a3088e08fc3db8a5c3e4838dac19872251b192e8b8ca882862119dd32a084856ea3fb4a1d238a1cd483544694dd490e36956123868d11530e2a642898c99129dd63cc186144aec2fa75e0b2912bc3c8932346a0c7a01135769c3868ccc48d93d5091aab4adde641d3beea551848e2803cc3867ed63368d2bc818b26ad9a3e5fa3f64db3716356881229e6d4d91328519151a30600",
+ "4500010269009e00004006ce62c0a80002550d93d740060050c3143845a11fab60801840003c1c00000101080a000547d810fc38b7474554202f382d4269742f526164696f536861636b2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f330096316be6fcc6ed1d347b7a46f60b584fe7112d64b4b08a552b5718468ad6b183a6eb083c77d2c0d8e17678711a39dcb2b123c7f80e1c3c60d068febcfa8c1c3772c0c063c60e8c1a6e89b24973474c132656dcee5483e376d6ad77603c2113470d1e326ad0784513c7ea1e189361cca923270d9b37fd4794b87c674e0f193226c7781e870f9a3a74ed748c61460e1c195888307428c3c98e1933d854a93163eae9125697c8b1135c8f1e3d31fac831e3a6e449ab587ed78141847f9ce056f0f24112127cc79731d9c8a0596444153411c9fc9601c56c751be263ea1851a4a19ea732a2004fd2b0aa0c1b316c8c98d2f061c4c54c8e4c111f63c60823781fe6af6357685e234f8e18a91e838655dd71e2a03173378e572768b6469d9b074d7cad5c61208963f20c1bfc5ecfa049f3c62e1ab76afa90b55a380d48905e2b5ecc1874e8d1a44b515ab51a00",
+ "4500010266009f00004006ce64c0a80002550d93d740050050c313903caf7b2f9580183d5ce4ef00000101080a0005481810fc3934474554202f382d4269742f5068696c6970732e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300952fbf597b07cd1e9f8cf5f2d58379440b192da85ac5aa1586913563eda0d93a02cf9d343076acfd1d9c468eb56cecc811be03070f1834922f8f3e23c78d1c30f098b103a3c65a2b41d3dc11d3848995b53cd5e0987d35eb1d184fc8c45183878c1a345cd1c4a1ba0786631873eac8492334ff881292efcce9214386e318cbe3f0415307b19d8b31ccc88123030b1183086538d93163069b2a3566441d5d82ea1239767aebd1a327461f3966dc7c0c4915cbee3a3088e08fd3db0a5d3e483672bf9872251b192e8b8ca882e60d1a32bb6540191bdd86f7953a461439a847a98c28bc931c7c2ac3460c1b23a61c5428f830932353bcc79831c2085d85f5ebc8654357869127478c448f4183eaed3871d098991b87ab133459990ecd83a63d56ad3090c40179860d7dae67d0a4792317cd5a357d8852059c46a346ae0f234ecca9b32750a322a9520d00",
+ "450001049b00ae00004006cc20c0a80002550d93d740050050c31396ceaf7b396e801840009ad400000101080a0005611010fc3d6b474554202f382d4269742f6d72776f6e672e67696620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d33009733bf617b07cd9e9f8ef7f6d5a379440b192da85ac5aa1586913564eda0d93a02cf9d343076b00d3e9c460eb66cecc821be03070f183496379f3e23c78d1c30f098b103a3065b2b6b92de11d3848915b63dd5e0a87d35eb1d184fc814c543460d1aae68e250dd0303328c3975e4a461f346ff881294efcce9214306e418cde3f0415347ae1d8c31ccc88123030b1183086538d93163069b2a3566442d5d82ea1239767eebd1a327461f3966dc801449154bef3a3088e48ff3db0a513e48387ac7a892251b192f8b8ca882862199de32a0909d6e033c4b1d238a1cd4a3544614df490e3e956123868d11530e2a644898c99129e063cc186184a8423578ead06563d7c8932346a6c7a04175769c3868ccd48dc3d5099aac4ce3e641f31eab561848e2843cc3a628d73368d2bca18b86ad9a3e62a9fe4db3712357881229eadce933e8d09154a92a417265848c1d307afec489074e198678e6108d31a7e8882557ae4c9111357903abdf7f7b052b96ec4f3868d51e7e1b77ae74198ef7f63d1a76ce52bf50cf4c9d7355b7ddb290634cae7cb9b4dec05f135b76c178c41d347b7e16eeabc732db16325a74cf7a07869135647bff0e3e7c075bdad3732c6f4e7c070e1ed37dcb993e23c78d1c30f07807cfd6ca1a3669ee8869c2c40adb9e6a70a8d60ae30999a278c8e4e78a260ed53d3020c33088900d43ae25204aa46818239f8d6cbc631c3a120b11ff6964a864c9e6e58ca8a54b505d220727579d3b7d06bd48158b52a6f99f72b542940f923a13ed600c39838d8c974546fc6548a63761b2d36d8067a96344913a72f428951105cd9d248a9fcab011c3c688298ad30c444398c99129e063cc18313bce683578eae8b66be4c91123d363246f003b0e1a33d2b93a41939569dc3c68d6df8181248e193967d814e57a064d9a3774d1b055d387cd1caa7fd36cdcc835618f853a63d07473510655aa0100",
+
+ /* SGSN with IAXMODEM V.42bis */
+ "45000101a0f3d84000400679210a0901abc0a800021f90400538e210f07a827bb1501900ed7be90000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205765642c203301312041756720323031362030393a32383a353220474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a66003f481c9162e40a97294800002068746d6c20506600588a3c6162644409183200002f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d66006f8234f87187cd1d006c653e4469726563746f7279206c697374696e672066016f72202f3c2f7469746c990068bcff2823e70c9fff6b6a943f9f7e7dfbf7f1e7d7bf9f5fb1c2ef6beafcc7d3fd3b7ced646aa34f03a404fa3373a4c64113630efdec27534e7509538d7e32ff657044a8f1bb0c82067f72f71e00",
+ "45000101a0e9a54000400683540a0901abc0a800021f904004437442f17a4ab3b1501900ed04900000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205765642c203301312041756720323031362030393a32373a353520474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a66003f481c9162e40a97294800002068746d6c20506600588a3c6162644409183200002f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e672066016f72202f3c2f7469746c990068beff2823e70c9f816b6a9847af9ebd7bf8f2e9dbc7af5ff142f06bea0cc4e31d7cfced646aa74f03a444fa3373a4c64113634e7ded28554e7d1953cd7e320365744cb811bc8c82078376ff1e00",
+};
+
+/* Uncompressed sample packets, sniffed from real communication */
+#define UNCOMPR_PACKETS_LEN 11
+char *uncompr_packets[] = {
+ "45000236000700004006cf2cc0a80002550d93d7400000501e200da7c0c95a70801840002e3700000101080a000174140853d489474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a",
+ "4510004046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27",
+ "4510005b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0",
+ "4510003746df40004006a9aec0a8646ec0a864640017ad8b81980133f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01",
+ "4510003746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01",
+ "4510007446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a0d0a",
+ "4510004246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20",
+ "450001a0b41140004006b8e80a0901abc0a800021f904002d5b860b5bab240ae501900ed861d0000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205475652c2033302041756720323031362030393a34333a303720474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a3c21444f43545950452068746d6c205055424c494320222d2f2f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e6720666f72202f3c2f7469746c653e0a3c626f64793e0a3c68323e4469726563746f7279206c697374696e6720666f72202f3c2f68323e0a3c68723e0a3c756c3e0a3c6c693e3c6120687265663d2272656470686f6e652e706e67223e72656470686f6e652e706e673c2f613e0a3c2f756c3e0a3c68723e0a3c2f626f64793e0a3c2f68746d6c3e0a",
+ "450000e2971b40003706026c550d93d7c0a8000200504047217f5922c903759c8018007c4fb400000101080a1153ce39002cf6e8485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613134392d3436652d34323736386138656338656330220d0a0d0a",
+ "450000e224f1400037067496550d93d7c0a80002005040489387ebf0c904389f8018007cec5700000101080a1153cf01002cf8fc485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613338302d3861362d34323736383761323236383830220d0a0d0a",
+ "450000e2b66140003706e325550d93d7c0a8000200504049fbb679bcc9051ea48018007cebea00000101080a1153cfdc002cfdb4485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343120474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338313336642d3138642d34353832306530393638303430220d0a0d0a",
+};
+
+/* Calculate IP Header checksum */
+static uint16_t calc_ip_csum(uint8_t *data, int len)
+{
+ int i;
+ uint32_t accumulator = 0;
+ uint16_t *pointer = (uint16_t *) data;
+
+ for (i = len; i > 1; i -= 2) {
+ accumulator += *pointer;
+ pointer++;
+ }
+
+ if (len % 2)
+ accumulator += *pointer;
+
+ accumulator = (accumulator & 0xffff) + ((accumulator >> 16) & 0xffff);
+ accumulator += (accumulator >> 16) & 0xffff;
+ return (~accumulator);
+}
+
+/* Calculate TCP/IP checksum */
+static uint16_t calc_tcpip_csum(const void *ctx, uint8_t *packet, int len)
+{
+ uint8_t *buf;
+ uint16_t csum;
+
+ buf = talloc_zero_size(ctx, len);
+ memset(buf, 0, len);
+ memcpy(buf, packet + 12, 8);
+ buf[9] = packet[9];
+ buf[11] = (len - 20) & 0xFF;
+ buf[10] = (len - 20) >> 8 & 0xFF;
+ memcpy(buf + 12, packet + 20, len - 20);
+ csum = calc_ip_csum(buf, len - 20 + 12);
+ talloc_free(buf);
+ return csum;
+}
+
+/* A simple function to show the ascii content of a packet */
+void show_packet(uint8_t *packet, int len)
+{
+ int i;
+ char c;
+ for (i = 0; i < len; i++) {
+ c = packet[i];
+ if (c >= 0x20 && c <= 0x7E)
+ printf("%c", c);
+ else
+ printf(".");
+ }
+ printf("\n");
+}
+
+/* A struct to capture the output data of compressor and decompressor */
+struct v42bis_output_buffer {
+ uint8_t *buf;
+ uint8_t *buf_pointer;
+ int len;
+};
+
+/* A simple testpattern generator */
+static void gen_test_pattern(uint8_t *data, int len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ data[i] = i & 0xF0;
+}
+
+/* Handler to capture the output data from the compressor */
+void tx_v42bis_frame_handler(void *user_data, const uint8_t *pkt, int len)
+{
+ struct v42bis_output_buffer *output_buffer =
+ (struct v42bis_output_buffer *)user_data;
+ memcpy(output_buffer->buf_pointer, pkt, len);
+ output_buffer->buf_pointer += len;
+ output_buffer->len += len;
+ return;
+}
+
+/* Handler to capture the output data from the decompressor */
+void tx_v42bis_data_handler(void *user_data, const uint8_t *buf, int len)
+{
+ /* stub, never used */
+ OSMO_ASSERT(false);
+ return;
+}
+
+/* Handler to capture the output data from the compressor */
+void rx_v42bis_frame_handler(void *user_data, const uint8_t *pkt, int len)
+{
+ /* stub, never used */
+ OSMO_ASSERT(false);
+ return;
+}
+
+/* Handler to capture the output data from the decompressor */
+void rx_v42bis_data_handler(void *user_data, const uint8_t *buf, int len)
+{
+ struct v42bis_output_buffer *output_buffer =
+ (struct v42bis_output_buffer *)user_data;
+ memcpy(output_buffer->buf_pointer, buf, len);
+ output_buffer->buf_pointer += len;
+ output_buffer->len += len;
+ return;
+}
+
+/* Test V.42bis compression and decompression */
+static void v42bis(const void *ctx, int mode, uint8_t *testvec, int len)
+{
+ v42bis_state_t *tx_state;
+ v42bis_state_t *rx_state;
+ uint8_t *uncompressed_original;
+ uint8_t *compressed;
+ uint8_t *uncompressed;
+
+ uncompressed_original = talloc_zero_size(ctx, len);
+ uncompressed = talloc_zero_size(ctx, len);
+
+ /* Note: We allocate double the size for the compressed buffer,
+ * because in some cases the compression may increase the amount.
+ * of data. */
+ compressed = talloc_zero_size(ctx, len * 2);
+
+ int rc;
+ int rc_sum = 0;
+ struct v42bis_output_buffer compressed_data;
+ struct v42bis_output_buffer uncompressed_data;
+
+ /* Initalize */
+ tx_state =
+ v42bis_init(ctx, NULL, P0, P1, P2,
+ &tx_v42bis_frame_handler, NULL, MAX_BLOCK_SIZE,
+ &tx_v42bis_data_handler, NULL, MAX_BLOCK_SIZE);
+ OSMO_ASSERT(tx_state);
+ rx_state =
+ v42bis_init(ctx, NULL, P0, P1, P2,
+ &rx_v42bis_frame_handler, NULL, MAX_BLOCK_SIZE,
+ &rx_v42bis_data_handler, NULL, MAX_BLOCK_SIZE);
+ OSMO_ASSERT(rx_state);
+ v42bis_compression_control(tx_state, mode);
+
+ /* Setup input data */
+ memcpy(uncompressed_original, testvec, len);
+
+ /* Run compressor */
+ compressed_data.buf = compressed;
+ compressed_data.buf_pointer = compressed;
+ compressed_data.len = 0;
+ tx_state->compress.user_data = (&compressed_data);
+ rc = v42bis_compress(tx_state, uncompressed_original, len);
+ printf("v42bis_compress() rc=%d\n", rc);
+ OSMO_ASSERT(rc == 0);
+ rc = v42bis_compress_flush(tx_state);
+ printf("v42bis_compress_flush() rc=%d\n", rc);
+ OSMO_ASSERT(rc == 0);
+
+ /* Decompress again */
+ uncompressed_data.buf = uncompressed;
+ uncompressed_data.buf_pointer = uncompressed;
+ uncompressed_data.len = 0;
+ rx_state->decompress.user_data = (&uncompressed_data);
+ rc = v42bis_decompress(rx_state, compressed_data.buf,
+ compressed_data.len);
+ printf("v42bis_decompress() rc=%d\n", rc);
+ rc = v42bis_decompress_flush(rx_state);
+ rc_sum += rc;
+ printf("v42bis_decompress_flush() rc=%d\n", rc);
+ rc_sum += rc;
+
+ /* Check results */
+ printf("Mode: %i\n", mode);
+
+ printf("uncompressed_original= %s ASCII:",
+ osmo_hexdump_nospc(uncompressed_original, len));
+ show_packet(uncompressed_original, len);
+ printf("uncompressed= %s ASCII:",
+ osmo_hexdump_nospc(uncompressed_data.buf,
+ uncompressed_data.len));
+ show_packet(uncompressed_data.buf, uncompressed_data.len);
+ printf("compressed= %s ASCII:",
+ osmo_hexdump_nospc(compressed_data.buf, compressed_data.len));
+ show_packet(compressed_data.buf, compressed_data.len);
+
+ rc = memcmp(uncompressed, uncompressed_original, len);
+ printf("memcmp() rc=%d\n", rc);
+ rc_sum += rc;
+ OSMO_ASSERT(rc_sum == 0);
+
+ /* Free buffers and exit */
+ v42bis_free(tx_state);
+ v42bis_free(rx_state);
+ talloc_free(uncompressed_original);
+ talloc_free(compressed);
+ talloc_free(uncompressed);
+ printf("\n");
+}
+
+/* Test V.42bis compression and decompression with generated data*/
+static void test_v42bis(const void *ctx)
+{
+ printf("Testing compression/decompression with generated data:\n");
+ uint8_t testvec[1024];
+ int len = sizeof(testvec);
+ gen_test_pattern(testvec, len);
+ v42bis(ctx, V42BIS_COMPRESSION_MODE_DYNAMIC, testvec, len);
+ v42bis(ctx, V42BIS_COMPRESSION_MODE_ALWAYS, testvec, len);
+ v42bis(ctx, V42BIS_COMPRESSION_MODE_NEVER, testvec, len);
+}
+
+/* Test V.42bis compression and decompression with some TCP/IP packets */
+static void test_v42bis_tcpip(const void *ctx, int packet_id)
+{
+ uint8_t *testvec;
+ int len;
+ printf
+ ("Testing compression/decompression with realistic TCP/IP packets:\n");
+ printf("Packet No.: %i\n", packet_id);
+ len = strlen(uncompr_packets[packet_id]);
+ testvec = talloc_zero_size(ctx, len);
+ len = osmo_hexparse(uncompr_packets[packet_id], testvec, len);
+ OSMO_ASSERT(len > 0);
+ v42bis(ctx, V42BIS_COMPRESSION_MODE_DYNAMIC, testvec, len);
+ v42bis(ctx, V42BIS_COMPRESSION_MODE_ALWAYS, testvec, len);
+ v42bis(ctx, V42BIS_COMPRESSION_MODE_NEVER, testvec, len);
+ talloc_free(testvec);
+}
+
+/* Test V.42bis decompression with real, sniffed packets */
+static void test_v42bis_tcpip_decompress(const void *ctx, int packet_id)
+{
+ uint8_t *compressed;
+ int compressed_len;
+ uint8_t *uncompressed;
+ v42bis_state_t *rx_state;
+ int rc;
+ int rc_sum = 0;
+ int len;
+ struct v42bis_output_buffer uncompressed_data;
+
+ printf
+ ("Testing decompression with sniffed compressed TCP/IP packets:\n");
+ printf("Packet No.: %i\n", packet_id);
+ len = strlen(compr_packets[packet_id]);
+
+ uncompressed = talloc_zero_size(ctx, len);
+ compressed = talloc_zero_size(ctx, len);
+
+ /* Initalize */
+ rx_state =
+ v42bis_init(ctx, NULL, P0, P1, P2,
+ &rx_v42bis_frame_handler, NULL, MAX_BLOCK_SIZE,
+ &rx_v42bis_data_handler, NULL, MAX_BLOCK_SIZE);
+ OSMO_ASSERT(rx_state);
+
+ /* Setup input data */
+ compressed_len =
+ osmo_hexparse(compr_packets[packet_id], compressed, len);
+
+ /* Decompress */
+ uncompressed_data.buf = uncompressed;
+ uncompressed_data.buf_pointer = uncompressed;
+ uncompressed_data.len = 0;
+ rx_state->decompress.user_data = (&uncompressed_data);
+ rc = v42bis_decompress_flush(rx_state);
+ printf("v42bis_decompress_flush() rc=%d\n", rc);
+ rc_sum += rc;
+ rc = v42bis_decompress(rx_state, compressed, compressed_len);
+ printf("v42bis_decompress() rc=%d\n", rc);
+ rc_sum += rc;
+ rc = v42bis_decompress_flush(rx_state);
+ printf("v42bis_decompress_flush() rc=%d\n", rc);
+ rc_sum += rc;
+
+ /* Check results */
+ printf("compressed= %s ASCII:",
+ osmo_hexdump_nospc(compressed, compressed_len));
+ show_packet(compressed, compressed_len);
+ printf("uncompressed= %s ASCII:",
+ osmo_hexdump_nospc(uncompressed_data.buf,
+ uncompressed_data.len));
+ show_packet(uncompressed_data.buf, uncompressed_data.len);
+
+ OSMO_ASSERT(calc_ip_csum(uncompressed_data.buf, 20) == 0);
+ OSMO_ASSERT(calc_tcpip_csum(ctx, uncompressed_data.buf,
+ uncompressed_data.len) == 0);
+
+ /* Free buffers and exit */
+ v42bis_free(rx_state);
+ talloc_free(uncompressed);
+ talloc_free(compressed);
+ printf("\n");
+}
+
+static struct log_info_cat gprs_categories[] = {
+ [DV42BIS] = {
+ .name = "DV42BIS",
+ .description = "V.42bis data compression (SNDCP)",
+ .enabled = 1,.loglevel = LOGL_DEBUG,
+ }
+};
+
+static struct log_info info = {
+ .cat = gprs_categories,
+ .num_cat = ARRAY_SIZE(gprs_categories),
+};
+
+int main(int argc, char **argv)
+{
+ void *v42bis_ctx;
+ int i;
+
+ osmo_init_logging(&info);
+
+ v42bis_ctx = talloc_named_const(NULL, 0, "v42bis_ctx");
+
+ test_v42bis(v42bis_ctx);
+
+ for (i = 0; i < UNCOMPR_PACKETS_LEN; i++)
+ test_v42bis_tcpip(v42bis_ctx, i);
+
+ for (i = 0; i < COMPR_PACKETS_LEN; i++)
+ test_v42bis_tcpip_decompress(v42bis_ctx, i);
+
+ printf("Done\n");
+ talloc_report_full(v42bis_ctx, stderr);
+ OSMO_ASSERT(talloc_total_blocks(v42bis_ctx) == 1);
+ return 0;
+}
+
+/* stubs */
+struct osmo_prim_hdr;
+int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
+{
+ abort();
+}
diff --git a/tests/v42bis/v42bis_test.ok b/tests/v42bis/v42bis_test.ok
new file mode 100644
index 000000000..070767473
--- /dev/null
+++ b/tests/v42bis/v42bis_test.ok
@@ -0,0 +1,648 @@
+Testing compression/decompression with generated data:
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 00000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0 ASCII:................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................
+uncompressed= 00000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0 ASCII:................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................
+compressed= 000100000000000000003300040b4e9870f020428409478c58b89021c38633663c7c081162c42143264ea448b1e29429172f62c49871cc988d1b3972ec3867cec78f2041861c3468e44892244b4e9a74f2244a9429478d5ab99225cb96b366bd7c091366cc61c366cea449b3e6b469376fe2c49973dcb89d3b79f2ec396fdecf9f4081062d587028c184098d226cd83029c388119942ac58f129c58c19a562ecd8b12ac79021b1822c59722bc99429bda26cd9322ccb9831c9c2ac59f32ccd9c39d5e2ecd9b32dcfa041e102254ad4e0d1a348952a5ddab4a953a850a34e9d4ad5aad5ab59b36ae5cab5ebd7af60c58a1d5bb6ac59b468d3ae5dcbd6addbb771e3ca9d3b7740ddba07efde5d9837efc3bd7b27f6ed7bf1efdf8d81037f1c3c7864e1c2270f1f5e9938f1cbc58b67366e7cf3f1e39d9123ff0c00 ASCII:..........3...N.p. B..G.X..!..3f<|..b.!C&N.H...)./b..q....9r.8g... A..4h.H.$KN.t.$J.)G.Z..%...f.|..f.a.f..I...i7o...s...;y..9o...@..-Xp(...."l.0)....B.X.)....b...*..!..,Yr+..)..l.2,..1...Y.,..9.....-..A..%J....H.*]...S.P.N.J....Y.j......`...[..Y.h..].....q...;w@.....].7...{'..{........<xd..'..^.8....g6n|.....#...
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 00000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0 ASCII:................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................
+uncompressed= 00000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0 ASCII:................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................
+compressed= 0001330003060e2448b0e08409070f22449870c488850b19326c3863c6c3871021461c3264e2448a142b4e9972f122468c19c78cd9b89123c78e73e67cfc081264c84183468e2449b2e4a449274fa2449972d4a8952b59b26c396bd6cb973061c61c366ce64c9a346b4e9b76f3264e9c39c78ddbb99327cf9ef3e6fdfc091468d0820587124c98d028c2860d93328c189129c48a159f52cc98512ac68e1dab720c19122bc89225b7924c99d22bca962dc3b28c19932ccc9a35cfd2cc99532dce9e3ddbf20c1a142e50a2440d1e3d8a54a9d2a54d9b3a850a35ead4a954ad5abd9a35ab56ae5cbb7efd0a56acd8b165cb9a458b36eddab56cddba7d1b37aedcb97307d4ad7bf0eedd8579f33edcbb7762dfbe17fffedd1838f0c7c18347162e7cf2f0e1958913bf5cbc7866e3c6371f3fde1939f2cf00 ASCII:..3....$H......"D.p.....2l8c....!F.2d.D..+N.r."F.......#..s.|...d.A.F.$I...I'O.D.r...+Y.l9k...0a..6l.L.4kN.v.&N.9.....'........h.....L..(....2...)....R..Q*....r...+..%..L..+..-.....,..5....S-..=......P.D..=.T...M.:..5...T.Z..5.V.\.~..V...e..E.6...l..}.7...s...{....y.>..wb.......8....G..|.......\.xf..7.?..9...
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 00000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0 ASCII:................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................
+uncompressed= 00000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0 ASCII:................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................
+compressed= 0001000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f000000000000000000000000000000000101010101010101010101010101010102020202020202020202020202020202030303030303030303030303030303030404040404040404040404040404040405050505050505050505050505050505060606060606060606060606060606060707070707070707070707070707070708080808080808080808080808080808090909090909090909090909090909090a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0 ASCII:................................. 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................................................ 0000000000000000@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPP````````````````pppppppppppppppp................................................................................................................................
+memcmp() rc=0
+
+Testing compression/decompression with realistic TCP/IP packets:
+Packet No.: 0
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 45000236000700004006cf2cc0a80002550d93d7400000501e200da7c0c95a70801840002e3700000101080a000174140853d489474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..6....@..,....U...@..P. ....Zp..@..7........t..S..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+uncompressed= 45000236000700004006cf2cc0a80002550d93d7400000501e200da7c0c95a70801840002e3700000101080a000174140853d489474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..6....@..,....U...@..P. ....Zp..@..7........t..S..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+compressed= 4500010236000700004006cf2cc0a80002550d93d7400000501e200da7c0c95a70801840002e3700000101080a000174140853d489474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c6963330062d990358b562ddb3d6beec079e3620f61bb5dbf861d5b36f0e0c287df68bd8366cfd4b369d7ce518b78440b192d820e2d7a1486913551eda0413a02cf9d343076687d1d9b460ead6cecc891bd03070f183472ef0e3e23c78d1c30f098b103a386562b6bd8a4b923a609132b5a8bb05183633451a377603c2113470d1e326ad024451327e81e189b61cca923270d9b37eb4794107c674e0f193236c7d81d870f9a3a60ed288c61460e1c195888d0b72fc3c98e1933d854a931c3a7e4124197c8b1d35a8f1e3d31fac831e34622c5a05856d78141447d9cd656c8f241e290b9c28e1fd9c8105964441534f9c9ac9601256a701bce3fea1851a4be1e9c32a2b04e52bfa70c1b316c8c9852ff7efebb4c8e4c711e63c6082364ef9faf23960d5919469e1c31123c068da0a5e3c44163666c9ca44ed018d5f9350f9aef458fc2401267e21936e6939e4193e68d58345ad5f4791a346800 ASCII:E...6....@..,....U...@..P. ....Zp..@..7........t..S..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, applic3.b..5.V-.=k..y.b.a.]...[6.....h..f...i..Q.xD..-..-z...5Q..A:...40vh}..F..l........4r..>#...0......V+k...#...+Z..Q.c4Q.w`<!.G..2j.$E.'....a..#'..7.G..|gN..26......:`.(.aF...X.../....3.T.1....A....Z..=1..1.F"..XV..AD}..V..A.........YdD.4.....%jp..?..Q....2..NR....1l..R.~..L.Lq.c..#d...#..Y.F..1.<......Acfl..N....5...E..@.g..6...A...X4Z..y.4h.
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 45000236000700004006cf2cc0a80002550d93d7400000501e200da7c0c95a70801840002e3700000101080a000174140853d489474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..6....@..,....U...@..P. ....Zp..@..7........t..S..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+uncompressed= 45000236000700004006cf2cc0a80002550d93d7400000501e200da7c0c95a70801840002e3700000101080a000174140853d489474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..6....@..,....U...@..P. ....Zp..@..7........t..S..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+compressed= 450000030ae418a060c0802109a4bd18b68a20160896b40d493825c40808aa8631eb3267d0068b31742424406041830104ee5c5860e51a232548ae8c903162c9952b5364d088410342032266cca09973a7c7083878dedc6133874c9d3b32e0b0d983e6cc8b1164e6cc79c3c60c19a772e2c8c813e74c0c3d5c632c6dfa34ea9db656b16ae5ea15ac583664cda255cb76cf9a3b70deb8d843d86ed7af61c7960d3cb8f0e1375aefa0d933f56cdab573d4221ed142468ba0438b1e8561644d543b68908ec073270d8c1d5a5fc7a691432b1b3b7264efc0c103068ddcbb83cfc87123070c3c66ecc0a8a1d5ca1a3669ee8869c2c48ad6226cd4e0184dd4e81d184fc8c45183878c1a3449d1c409ba07c6661873eac849c3e6cdfa112504df99d343868ccd3176c7e183a60e583b0a6398910347061622f4edcb70b263c60c36556accf029b944d02572ecb4d6a3474f8c3e72ccb89148312896d5756010511fa7b515b27c903864aeb0e347363244161951054d7e32ab6540891adc86f38f3a4614a9af07a78c28ac93d4ef29c3460c1b23a6d4bf9fff2e9323539cc79831c208d9fbe7eb88654356869127478c048f412368e93871d098191b27a9133446757ecd83e67bd1a33090c49978868df9a467d0a47923168d56357d9e060d1a00 ASCII:E.......`..!...... .....I8%.....1.2g...1t$$@`A....\X`..#%H...1b..+Sd..A.B."f...s...8x..a3.L.;2........d..y.....r.....L.=\c,m.4...V.j....X6d..U.v..;p...C.n..a...<...7Z...3.l..s."..BF..C...adMT;h...s'...Z_...C+.;rd...........q#..<f.......6i..i...."l...M....O..Q....4I......f.s..I.....%....C...1v.....X;.c...G.."...p.c..6Uj..).D.%r....GO.>r...H1(..u`.Q.....|.8d...G62D..Q.M~2.e@......:F......(....).F..#.......#S...1.......eCV..'G...A#h.8q....'..4Fu~...{..0...x....g..y#..V5}.....
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 45000236000700004006cf2cc0a80002550d93d7400000501e200da7c0c95a70801840002e3700000101080a000174140853d489474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..6....@..,....U...@..P. ....Zp..@..7........t..S..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+uncompressed= 45000236000700004006cf2cc0a80002550d93d7400000501e200da7c0c95a70801840002e3700000101080a000174140853d489474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..6....@..,....U...@..P. ....Zp..@..7........t..S..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+compressed= 4500010236000700004006cf2cc0a80002550d93d7400000501e200da7c0c95a70801840002e3700000101080a000174140853d489474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d3133012d323030372042726f777365722f4e657446726f6e742f332e332050726f6601696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E...6....@..,....U...@..P. ....Zp..@..7........t..S..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13.-2007 Browser/NetFront/3.3 Prof.ile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+memcmp() rc=0
+
+Testing compression/decompression with realistic TCP/IP packets:
+Packet No.: 1
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 4510004046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27 ASCII:E..@F.@.@.....dn..dd...........M....*.........G....^..... ..#..'
+uncompressed= 4510004046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27 ASCII:E..@F.@.@.....dn..dd...........M....*.........G....^..... ..#..'
+compressed= 451000014046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27 ASCII:E...@F.@.@.....dn..dd...........M....*.........G....^..... ..#..'
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 4510004046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27 ASCII:E..@F.@.@.....dn..dd...........M....*.........G....^..... ..#..'
+uncompressed= 4510004046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27 ASCII:E..@F.@.@.....dn..dd...........M....*.........G....^..... ..#..'
+compressed= 45000013060c49026e48c104ac540d5b75268ec33367066880e588d0260203ecbdda0465d08601e65a641830800081050d062450122e013561610402dc5073444d1335550400 ASCII:E.....I.nH...T.[u&..3g.h....&......e....Zd.0......$P...5aa...PsDM.5U..
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 4510004046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27 ASCII:E..@F.@.@.....dn..dd...........M....*.........G....^..... ..#..'
+uncompressed= 4510004046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27 ASCII:E..@F.@.@.....dn..dd...........M....*.........G....^..... ..#..'
+compressed= 451000014046dd40004006a9a7c0a8646ec0a864640017ad8b81980100f3ac984d801800e32a1600000101080a000647de06d1bf5efffd18fffd20fffd23fffd27 ASCII:E...@F.@.@.....dn..dd...........M....*.........G....^..... ..#..'
+memcmp() rc=0
+
+Testing compression/decompression with realistic TCP/IP packets:
+Packet No.: 2
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 4510005b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0 ASCII:E..[F.@.@.....dn..dd...........M.....u........G....a........!.."..... .....#.....'.........
+uncompressed= 4510005b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0 ASCII:E..[F.@.@.....dn..dd...........M.....u........G....a........!.."..... .....#.....'.........
+compressed= 451000015b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0 ASCII:E...[F.@.@.....dn..dd...........M.....u........G....a........!.."..... .....#.....'.........
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 4510005b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0 ASCII:E..[F.@.@.....dn..dd...........M.....u........G....a........!.."..... .....#.....'.........
+uncompressed= 4510005b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0 ASCII:E..[F.@.@.....dn..dd...........M.....u........G....a........!.."..... .....#.....'.........
+compressed= 45000013067849126ec880210958391ab6ea4c9c8767ce0cd000cb11a14d041ed87bb509caa00d03cc25c233600001020b1a0c48a0445c026ac2c808f467402040113949080c58c2260281fd461010386fa809a348fba9583a74c3d200 ASCII:E....xI.n..!.X9...L..g.......M...{.......%.3`......H.D\.j....g@ @.9I..X.&...F..8o...H..X:t...
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 4510005b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0 ASCII:E..[F.@.@.....dn..dd...........M.....u........G....a........!.."..... .....#.....'.........
+uncompressed= 4510005b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0 ASCII:E..[F.@.@.....dn..dd...........M.....u........G....a........!.."..... .....#.....'.........
+compressed= 451000015b46de40004006a98bc0a8646ec0a864640017ad8b8198010cf3ac984d801800e3867500000101080a000647df06d1bf61fffb03fffd1ffffd21fffe22fffb05fffa2001fff0fffa2301fff0fffa2701fff0fffa1801fff0 ASCII:E...[F.@.@.....dn..dd...........M.....u........G....a........!.."..... .....#.....'.........
+memcmp() rc=0
+
+Testing compression/decompression with realistic TCP/IP packets:
+Packet No.: 3
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 4510003746df40004006a9aec0a8646ec0a864640017ad8b81980133f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01 ASCII:E..7F.@.@.....dn..dd.......3........_.........G....c...
+uncompressed= 4510003746df40004006a9aec0a8646ec0a864640017ad8b81980133f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01 ASCII:E..7F.@.@.....dn..dd.......3........_.........G....c...
+compressed= 451000013746df40004006a9aec0a8646ec0a864640017ad8b8198013301f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01 ASCII:E...7F.@.@.....dn..dd.......3........._.........G....c...
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 4510003746df40004006a9aec0a8646ec0a864640017ad8b81980133f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01 ASCII:E..7F.@.@.....dn..dd.......3........_.........G....c...
+uncompressed= 4510003746df40004006a9aec0a8646ec0a864640017ad8b81980133f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01 ASCII:E..7F.@.@.....dn..dd.......3........_.........G....c...
+compressed= 4500001306e848226ec880210958c51ab6ea4c9c8767ce0cd000cb11a14d046cd87bb549d4a00d03cc89d136600001020b1a0c48a0845c026ac2cc0804482000 ASCII:E.....H"n..!.X....L..g.......M.l.{.I.......6`......H..\.j....H .
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 4510003746df40004006a9aec0a8646ec0a864640017ad8b81980133f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01 ASCII:E..7F.@.@.....dn..dd.......3........_.........G....c...
+uncompressed= 4510003746df40004006a9aec0a8646ec0a864640017ad8b81980133f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01 ASCII:E..7F.@.@.....dn..dd.......3........_.........G....c...
+compressed= 451000013746df40004006a9aec0a8646ec0a864640017ad8b8198013301f3ac989f801800e35fd700000101080a000647e106d1bf63fffd01 ASCII:E...7F.@.@.....dn..dd.......3........._.........G....c...
+memcmp() rc=0
+
+Testing compression/decompression with realistic TCP/IP packets:
+Packet No.: 4
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 4510003746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01 ASCII:E..7F.@.@.....dn..dd.......6........_.........G....d...
+uncompressed= 4510003746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01 ASCII:E..7F.@.@.....dn..dd.......6........_.........G....d...
+compressed= 451000013746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01 ASCII:E...7F.@.@.....dn..dd.......6........_.........G....d...
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 4510003746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01 ASCII:E..7F.@.@.....dn..dd.......6........_.........G....d...
+uncompressed= 4510003746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01 ASCII:E..7F.@.@.....dn..dd.......6........_.........G....d...
+compressed= 4500001306e848326ec880210958c11ab6ea4c9c8767ce0cd000cb11a14d0472d87bb5a9d4a00d03cc89a936600001020b1a0c48a0845c026ac2ce08f4472000 ASCII:E.....H2n..!.X....L..g.......M.r.{.........6`......H..\.j....G .
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 4510003746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01 ASCII:E..7F.@.@.....dn..dd.......6........_.........G....d...
+uncompressed= 4510003746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01 ASCII:E..7F.@.@.....dn..dd.......6........_.........G....d...
+compressed= 451000013746e040004006a9adc0a8646ec0a864640017ad8b81980136f3ac98a2801800e35fd200000101080a000647e106d1bf64fffb01 ASCII:E...7F.@.@.....dn..dd.......6........_.........G....d...
+memcmp() rc=0
+
+Testing compression/decompression with realistic TCP/IP packets:
+Packet No.: 5
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 4510007446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a0d0a ASCII:E..tF.@.@..o..dn..dd.......9........{.........G....d..------------------..Wellcome to pollux..------------------....
+uncompressed= 4510007446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a0d0a ASCII:E..tF.@.@..o..dn..dd.......9........{.........G....d..------------------..Wellcome to pollux..------------------....
+compressed= 451000017446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d3300386d6a41f3e68d193970d08cb82367c41c3940f1ecb1b97327549e0d6c0600 ASCII:E...tF.@.@..o..dn..dd.......9........{.........G....d..----------------3.8mjA....9p...#g..9@....s'T..l..
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 4510007446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a0d0a ASCII:E..tF.@.@..o..dn..dd.......9........{.........G....d..------------------..Wellcome to pollux..------------------....
+uncompressed= 4510007446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a0d0a ASCII:E..tF.@.@..o..dn..dd.......9........{.........G....d..------------------..Wellcome to pollux..------------------....
+compressed= 4500001306dc49426ec880210958c919b6ea4c9c8767ce0cd000cb11a14d0478d87bb509d5a00d03ccf9f134600001020b1a0c48a0a45c026ac2ce40680003064e9c3973eac469530b9a376fccc8818366c41d3923e6c8018a678fcd9d3ba1f26c603300 ASCII:E.....IBn..!.X....L..g.......M.x.{.........4`......H..\.j..@h...N.9s..iS..7o....f..9#....g...;..l`3.
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 4510007446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a0d0a ASCII:E..tF.@.@..o..dn..dd.......9........{.........G....d..------------------..Wellcome to pollux..------------------....
+uncompressed= 4510007446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a0d0a ASCII:E..tF.@.@..o..dn..dd.......9........{.........G....d..------------------..Wellcome to pollux..------------------....
+compressed= 451000017446e140004006a96fc0a8646ec0a864640017ad8b81980139f3ac98a5801800e37b9b00000101080a000647e206d1bf640d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a57656c6c636f6d6520746f20706f6c6c75780d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0d0a0d0a ASCII:E...tF.@.@..o..dn..dd.......9........{.........G....d..------------------..Wellcome to pollux..------------------....
+memcmp() rc=0
+
+Testing compression/decompression with realistic TCP/IP packets:
+Packet No.: 6
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 4510004246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20 ASCII:E..BF.@.@.....dn..dd.......y..................G....opollux login:
+uncompressed= 4510004246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20 ASCII:E..BF.@.@.....dn..dd.......y..................G....opollux login:
+compressed= 451000014246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20 ASCII:E...BF.@.@.....dn..dd.......y..................G....opollux login:
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 4510004246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20 ASCII:E..BF.@.@.....dn..dd.......y..................G....opollux login:
+uncompressed= 4510004246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20 ASCII:E..BF.@.@.....dn..dd.......y..................G....opollux login:
+compressed= 45000013061449526ec8802109588d1ab6ea4c9c8767ce0cd000cb11a14d04f8d87bb509d5a00d03cc759b35600001020b1a0c48a0e45d026ac2e4cc91f3e60d9e3d23dec851c3264e8f110100 ASCII:E.....IRn..!.X....L..g.......M...{.......u.5`......H..].j........=#..Q.&N....
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 4510004246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20 ASCII:E..BF.@.@.....dn..dd.......y..................G....opollux login:
+uncompressed= 4510004246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20 ASCII:E..BF.@.@.....dn..dd.......y..................G....opollux login:
+compressed= 451000014246e240004006a9a0c0a8646ec0a864640017ad8b81980179f3ac98a5801800e3dab000000101080a000647ec06d1bf6f706f6c6c7578206c6f67696e3a20 ASCII:E...BF.@.@.....dn..dd.......y..................G....opollux login:
+memcmp() rc=0
+
+Testing compression/decompression with realistic TCP/IP packets:
+Packet No.: 7
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 450001a0b41140004006b8e80a0901abc0a800021f904002d5b860b5bab240ae501900ed861d0000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205475652c2033302041756720323031362030393a34333a303720474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a3c21444f43545950452068746d6c205055424c494320222d2f2f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e6720666f72202f3c2f7469746c653e0a3c626f64793e0a3c68323e4469726563746f7279206c697374696e6720666f72202f3c2f68323e0a3c68723e0a3c756c3e0a3c6c693e3c6120687265663d2272656470686f6e652e706e67223e72656470686f6e652e706e673c2f613e0a3c2f756c3e0a3c68723e0a3c2f626f64793e0a3c2f68746d6c3e0a ASCII:E.....@.@.............@...`...@.P.......HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Tue, 30 Aug 2016 09:43:07 GMT..Content-type: text/html; charset=UTF-8..Content-Length: 222....<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>.<title>Directory listing for /</title>.<body>.<h2>Directory listing for /</h2>.<hr>.<ul>.<li><a href="redphone.png">redphone.png</a>.</ul>.<hr>.</body>.</html>.
+uncompressed= 450001a0b41140004006b8e80a0901abc0a800021f904002d5b860b5bab240ae501900ed861d0000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205475652c2033302041756720323031362030393a34333a303720474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a3c21444f43545950452068746d6c205055424c494320222d2f2f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e6720666f72202f3c2f7469746c653e0a3c626f64793e0a3c68323e4469726563746f7279206c697374696e6720666f72202f3c2f68323e0a3c68723e0a3c756c3e0a3c6c693e3c6120687265663d2272656470686f6e652e706e67223e72656470686f6e652e706e673c2f613e0a3c2f756c3e0a3c68723e0a3c2f626f64793e0a3c2f68746d6c3e0a ASCII:E.....@.@.............@...`...@.P.......HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Tue, 30 Aug 2016 09:43:07 GMT..Content-type: text/html; charset=UTF-8..Content-Length: 222....<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>.<title>Directory listing for /</title>.<body>.<h2>Directory listing for /</h2>.<hr>.<ul>.<li><a href="redphone.png">redphone.png</a>.</ul>.<hr>.</body>.</html>.
+compressed= 45000101a0b41140004006b8e80a0901abc0a800021f904002d5b860b5bab240ae501900ed861d0000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205475652c203301302041756720323031362030393a34333a303720474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a206600356ad4c899f3078923528c5ce13205c908c58c9d6229f2848991112560c890a1050033432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e672066016f72202f3c2f7469746c990068bcff2823e70c9fff6b6a943f9f7e7dfbf7f1e7d7bf9f3fb1c2ef6beafcc7d3fd3b7ced6468a34f03a404fa3373a4c64113630efdec27534e7509538d7e32ff657044a8f1bb0c82067f72f71e00 ASCII:E......@.@.............@...`...@.P.......HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Tue, 3.0 Aug 2016 09:43:07 GMT..Content-type: text/html; charset=UTF-8..Content-Length: f.5j......#R.\.2......b).....%`.....3C//DTD HTML 3.2 Final//EN"><html>.<title>Directory listing f.or /</titl..h..(#....kj.?.~}.......?...k.....;|.dh.O....3s..A.c...'SNu.S.~2.epD.......r...
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 450001a0b41140004006b8e80a0901abc0a800021f904002d5b860b5bab240ae501900ed861d0000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205475652c2033302041756720323031362030393a34333a303720474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a3c21444f43545950452068746d6c205055424c494320222d2f2f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e6720666f72202f3c2f7469746c653e0a3c626f64793e0a3c68323e4469726563746f7279206c697374696e6720666f72202f3c2f68323e0a3c68723e0a3c756c3e0a3c6c693e3c6120687265663d2272656470686f6e652e706e67223e72656470686f6e652e706e673c2f613e0a3c2f756c3e0a3c68723e0a3c2f626f64793e0a3c2f68746d6c3e0a ASCII:E.....@.@.............@...`...@.P.......HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Tue, 30 Aug 2016 09:43:07 GMT..Content-type: text/html; charset=UTF-8..Content-Length: 222....<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>.<title>Directory listing for /</title>.<body>.<h2>Directory listing for /</h2>.<hr>.<ul>.<li><a href="redphone.png">redphone.png</a>.</ul>.<hr>.</body>.</html>.
+uncompressed= 450001a0b41140004006b8e80a0901abc0a800021f904002d5b860b5bab240ae501900ed861d0000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205475652c2033302041756720323031362030393a34333a303720474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a3c21444f43545950452068746d6c205055424c494320222d2f2f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e6720666f72202f3c2f7469746c653e0a3c626f64793e0a3c68323e4469726563746f7279206c697374696e6720666f72202f3c2f68323e0a3c68723e0a3c756c3e0a3c6c693e3c6120687265663d2272656470686f6e652e706e67223e72656470686f6e652e706e673c2f613e0a3c2f756c3e0a3c68723e0a3c2f626f64793e0a3c2f68746d6c3e0a ASCII:E.....@.@.............@...`...@.P.......HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Tue, 30 Aug 2016 09:43:07 GMT..Content-type: text/html; charset=UTF-8..Content-Length: 222....<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>.<title>Directory listing for /</title>.<body>.<h2>Directory listing for /</h2>.<hr>.<ul>.<li><a href="redphone.png">redphone.png</a>.</ul>.<hr>.</body>.</html>.
+compressed= 45000003088cba4561c880210976ad6bc08080ab61ab061410316948016cbbc6e0ea556b48ac291c06c04b0462c0802557ae4c914123c68c113566c894e20442032b68eae4e1d96384153670e6bc41b3b2a58c1931728c98c2e7ce1a397164d488a18369ce2364eea0017a050f9a17236cc8248247cdcc19349acee0d1e3868d1e33748c5002e54a4e2353bbc6b903e30e9f395e4774dd7347c69a3b70def81861660d993a76d0dc0182e54a12183bf4f245e317c693cf6aa202ad51a346ce9c3f481c9162e40a972948462866ec144b91274c8c8c280143860c2d368c003f72e5c88895509e908d516344123671c8bc018e244a89203f6abf09d2e0c71d36778c0639c2a60e1a3377e4d4e133e20d1b3be1e3a44dc37e848c1f32c28f47e3fd47193967f8fc5f53a3fcf9f4ebdbbf8f3fbffefdfc89157e5f53e73f9eeedfe16b27431b7d1a2025d09f9923350e9a1873e8673f9972aa4b986af493f92f8323428ddf651034f893bbf700 ASCII:E......Ea..!.v.k....a....1iH.l....UkH.)...K.b..%W.L.A#...5f....B.+h....c..6p..A.....1r......9qd....i.#d...z....#l.$.G...4........3t.P..JN#S.......9^Gt.sG..;p...af..:v.....J..;..E.....j...Q.F..?H..b...)HF(f..K.'L..(.C..-6..?r....P...QcD.6q....$J. ?j......6w..9....3w...3...;...M.~...2..G..G.9g.._S........?......~_S.?....k'C.}. %...#5...s.g?.r.K.j.../.#B..e.4.....
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 450001a0b41140004006b8e80a0901abc0a800021f904002d5b860b5bab240ae501900ed861d0000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205475652c2033302041756720323031362030393a34333a303720474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a3c21444f43545950452068746d6c205055424c494320222d2f2f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e6720666f72202f3c2f7469746c653e0a3c626f64793e0a3c68323e4469726563746f7279206c697374696e6720666f72202f3c2f68323e0a3c68723e0a3c756c3e0a3c6c693e3c6120687265663d2272656470686f6e652e706e67223e72656470686f6e652e706e673c2f613e0a3c2f756c3e0a3c68723e0a3c2f626f64793e0a3c2f68746d6c3e0a ASCII:E.....@.@.............@...`...@.P.......HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Tue, 30 Aug 2016 09:43:07 GMT..Content-type: text/html; charset=UTF-8..Content-Length: 222....<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>.<title>Directory listing for /</title>.<body>.<h2>Directory listing for /</h2>.<hr>.<ul>.<li><a href="redphone.png">redphone.png</a>.</ul>.<hr>.</body>.</html>.
+uncompressed= 450001a0b41140004006b8e80a0901abc0a800021f904002d5b860b5bab240ae501900ed861d0000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205475652c2033302041756720323031362030393a34333a303720474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a3c21444f43545950452068746d6c205055424c494320222d2f2f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e6720666f72202f3c2f7469746c653e0a3c626f64793e0a3c68323e4469726563746f7279206c697374696e6720666f72202f3c2f68323e0a3c68723e0a3c756c3e0a3c6c693e3c6120687265663d2272656470686f6e652e706e67223e72656470686f6e652e706e673c2f613e0a3c2f756c3e0a3c68723e0a3c2f626f64793e0a3c2f68746d6c3e0a ASCII:E.....@.@.............@...`...@.P.......HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Tue, 30 Aug 2016 09:43:07 GMT..Content-type: text/html; charset=UTF-8..Content-Length: 222....<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>.<title>Directory listing for /</title>.<body>.<h2>Directory listing for /</h2>.<hr>.<ul>.<li><a href="redphone.png">redphone.png</a>.</ul>.<hr>.</body>.</html>.
+compressed= 45000101a0b41140004006b8e80a0901abc0a800021f904002d5b860b5bab240ae501900ed861d0000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205475652c203301302041756720323031362030393a34333a303720474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a3c21444f43545950452068746d6c205055424c494320222d2f2f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e672066016f72202f3c2f7469746c653e0a3c626f64793e0a3c68323e4469726563746f7279206c697374696e6720666f72202f3c2f68323e0a3c68723e0a3c756c3e0a3c6c693e3c6120687265663d2272656470686f6e652e706e67223e72656470686f6e652e706e673c2f613e0a3c2f756c3e0a3c68723e0a3c2f626f64793e0a3c2f68746d6c3e0a ASCII:E......@.@.............@...`...@.P.......HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Tue, 3.0 Aug 2016 09:43:07 GMT..Content-type: text/html; charset=UTF-8..Content-Length: 222....<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>.<title>Directory listing f.or /</title>.<body>.<h2>Directory listing for /</h2>.<hr>.<ul>.<li><a href="redphone.png">redphone.png</a>.</ul>.<hr>.</body>.</html>.
+memcmp() rc=0
+
+Testing compression/decompression with realistic TCP/IP packets:
+Packet No.: 8
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 450000e2971b40003706026c550d93d7c0a8000200504047217f5922c903759c8018007c4fb400000101080a1153ce39002cf6e8485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613134392d3436652d34323736386138656338656330220d0a0d0a ASCII:E.....@.7..lU........P@G!.Y"..u....|O........S.9.,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a149-46e-42768a8ec8ec0"....
+uncompressed= 450000e2971b40003706026c550d93d7c0a8000200504047217f5922c903759c8018007c4fb400000101080a1153ce39002cf6e8485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613134392d3436652d34323736386138656338656330220d0a0d0a ASCII:E.....@.7..lU........P@G!.Y"..u....|O........S.9.,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a149-46e-42768a8ec8ec0"....
+compressed= 45000100e2971b40003706026c550d93d7c0a8000200504047217f5922c903759c8018007c4fb400000101080a1153ce39002cf6e8485454502f312e312033013034204e6f74204d6f646966016965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613134392d3436652d3432373638613865633865990066669478fa3400 ASCII:E......@.7..lU........P@G!.Y"..u....|O........S.9.,..HTTP/1.1 3.04 Not Modif.ied..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a149-46e-42768a8ec8e..ff.x.4.
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 450000e2971b40003706026c550d93d7c0a8000200504047217f5922c903759c8018007c4fb400000101080a1153ce39002cf6e8485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613134392d3436652d34323736386138656338656330220d0a0d0a ASCII:E.....@.7..lU........P@G!.Y"..u....|O........S.9.,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a149-46e-42768a8ec8ec0"....
+uncompressed= 450000e2971b40003706026c550d93d7c0a8000200504047217f5922c903759c8018007c4fb400000101080a1153ce39002cf6e8485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613134392d3436652d34323736386138656338656330220d0a0d0a ASCII:E.....@.7..lU........P@G!.Y"..u....|O........S.9.,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a149-46e-42768a8ec8ec0"....
+compressed= 450000030694d3e461c8001d090abcc102c192b661ab061418306588121282b894606600cfa7411b06fc91728b2001020b1a50b0128dc78017f9d62db972658a0c1a31688cb031e3c6882872ee8c8022e70c9b346cd09c81d0e008993b687a8cb88207cd0b9f334610c1a366448d1934728c20dbc3468e1e37b82a8172e5a9153475f2ccad4a640e19336bd03c3522274e1c3466eeb0015cd5091a3473601079c3a6eed3c48b1b3fae5bb5301c3472f0dc0152432b1c327b80d0983163c6532457c8a8a95ae286991d6468dce001e3460e34b76be8c8217bc760e066669478fa3400 ASCII:E.......a...........a....0e......`f...A....r. ....P........-.re...1h..1...(r..."...4l.......;hz.......3F...fD..4r. ..F..7.*.r...4u...Jd..3k.<5"'N.4f...\...4s`.y.......?.[.0.4r...RC+.2{...1c.S$W...Z....dh....F.4.k..!{.`.ff.x.4.
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 450000e2971b40003706026c550d93d7c0a8000200504047217f5922c903759c8018007c4fb400000101080a1153ce39002cf6e8485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613134392d3436652d34323736386138656338656330220d0a0d0a ASCII:E.....@.7..lU........P@G!.Y"..u....|O........S.9.,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a149-46e-42768a8ec8ec0"....
+uncompressed= 450000e2971b40003706026c550d93d7c0a8000200504047217f5922c903759c8018007c4fb400000101080a1153ce39002cf6e8485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613134392d3436652d34323736386138656338656330220d0a0d0a ASCII:E.....@.7..lU........P@G!.Y"..u....|O........S.9.,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a149-46e-42768a8ec8ec0"....
+compressed= 45000100e2971b40003706026c550d93d7c0a8000200504047217f5922c903759c8018007c4fb400000101080a1153ce39002cf6e8485454502f312e312033013034204e6f74204d6f646966016965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613134392d3436652d34323736386138656338656330220d0a0d0a ASCII:E......@.7..lU........P@G!.Y"..u....|O........S.9.,..HTTP/1.1 3.04 Not Modif.ied..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a149-46e-42768a8ec8ec0"....
+memcmp() rc=0
+
+Testing compression/decompression with realistic TCP/IP packets:
+Packet No.: 9
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 450000e224f1400037067496550d93d7c0a80002005040489387ebf0c904389f8018007cec5700000101080a1153cf01002cf8fc485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613338302d3861362d34323736383761323236383830220d0a0d0a ASCII:E...$.@.7.t.U........P@H......8....|.W.......S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a380-8a6-427687a226880"....
+uncompressed= 450000e224f1400037067496550d93d7c0a80002005040489387ebf0c904389f8018007cec5700000101080a1153cf01002cf8fc485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613338302d3861362d34323736383761323236383830220d0a0d0a ASCII:E...$.@.7.t.U........P@H......8....|.W.......S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a380-8a6-427687a226880"....
+compressed= 45000100e224f1400037067496550d93d7c0a80002005040489387ebf0c904389f8018007cec5700000101080a1153cf01002cf8fc485454502f312e312033013034204e6f74204d6f646966016965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613338302d3861362d34323736383761323236383830220d0a0d0a ASCII:E....$.@.7.t.U........P@H......8....|.W.......S...,..HTTP/1.1 3.04 Not Modif.ied..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a380-8a6-427687a226880"....
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 450000e224f1400037067496550d93d7c0a80002005040489387ebf0c904389f8018007cec5700000101080a1153cf01002cf8fc485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613338302d3861362d34323736383761323236383830220d0a0d0a ASCII:E...$.@.7.t.U........P@H......8....|.W.......S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a380-8a6-427687a226880"....
+uncompressed= 450000e224f1400037067496550d93d7c0a80002005040489387ebf0c904389f8018007cec5700000101080a1153cf01002cf8fc485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613338302d3861362d34323736383761323236383830220d0a0d0a ASCII:E...$.@.7.t.U........P@H......8....|.W.......S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a380-8a6-427687a226880"....
+compressed= 4500000306943b416fc8001d09ee64c202c192b661ab0614183065c8124b8adccd63766087a8411b06fc79a7852001020b1a50b0228dc08017fbfe2db972658a0c1a31688cb031e3c6882872ee8c8022e70c9b346cd09c81d0e008993b687a8cb88207cd0b9f334610c1a366448d1934728c20dbc3468e1e37b82a8172e5a9153475f2ccad4a640e19336bd03c3522274e1c3466eeb0015cd5091a3473601079c3a6eed3c48b1b3fae5bb5301c3472f0dc0152432b1c327b80d0983163c6532457c8a8a95ae286991d646cec980143760e18376ae8c8b14307991a357cd72ef1f46900 ASCII:E.....;Ao.....d.....a....0e..K...cv`..A...y.. ....P."......-.re...1h..1...(r..."...4l.......;hz.......3F...fD..4r. ..F..7.*.r...4u...Jd..3k.<5"'N.4f...\...4s`.y.......?.[.0.4r...RC+.2{...1c.S$W...Z....dl...Cv..7j...C...5|....i.
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 450000e224f1400037067496550d93d7c0a80002005040489387ebf0c904389f8018007cec5700000101080a1153cf01002cf8fc485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613338302d3861362d34323736383761323236383830220d0a0d0a ASCII:E...$.@.7.t.U........P@H......8....|.W.......S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a380-8a6-427687a226880"....
+uncompressed= 450000e224f1400037067496550d93d7c0a80002005040489387ebf0c904389f8018007cec5700000101080a1153cf01002cf8fc485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613338302d3861362d34323736383761323236383830220d0a0d0a ASCII:E...$.@.7.t.U........P@H......8....|.W.......S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a380-8a6-427687a226880"....
+compressed= 45000100e224f1400037067496550d93d7c0a80002005040489387ebf0c904389f8018007cec5700000101080a1153cf01002cf8fc485454502f312e312033013034204e6f74204d6f646966016965640d0a446174653a205475652c2033302041756720323031362031363a33363a343020474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338613338302d3861362d34323736383761323236383830220d0a0d0a ASCII:E....$.@.7.t.U........P@H......8....|.W.......S...,..HTTP/1.1 3.04 Not Modif.ied..Date: Tue, 30 Aug 2016 16:36:40 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8a380-8a6-427687a226880"....
+memcmp() rc=0
+
+Testing compression/decompression with realistic TCP/IP packets:
+Packet No.: 10
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 0
+uncompressed_original= 450000e2b66140003706e325550d93d7c0a8000200504049fbb679bcc9051ea48018007cebea00000101080a1153cfdc002cfdb4485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343120474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338313336642d3138642d34353832306530393638303430220d0a0d0a ASCII:E....a@.7..%U........P@I..y........|.........S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:41 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8136d-18d-45820e0968040"....
+uncompressed= 450000e2b66140003706e325550d93d7c0a8000200504049fbb679bcc9051ea48018007cebea00000101080a1153cfdc002cfdb4485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343120474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338313336642d3138642d34353832306530393638303430220d0a0d0a ASCII:E....a@.7..%U........P@I..y........|.........S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:41 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8136d-18d-45820e0968040"....
+compressed= 45000100e2b66140003706e325550d93d7c0a8000200504049fbb679bcc9051ea48018007cebea00000101080a1153cfdc002cfdb4485454502f312e312033013034204e6f74204d6f646966016965640d0a446174653a205475652c2033302041756720323031362031363a33363a343120474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338313336642d3138642d34353832306530393638303430220d0a0d0a ASCII:E.....a@.7..%U........P@I..y........|.........S...,..HTTP/1.1 3.04 Not Modif.ied..Date: Tue, 30 Aug 2016 16:36:41 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8136d-18d-45820e0968040"....
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 1
+uncompressed_original= 450000e2b66140003706e325550d93d7c0a8000200504049fbb679bcc9051ea48018007cebea00000101080a1153cfdc002cfdb4485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343120474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338313336642d3138642d34353832306530393638303430220d0a0d0a ASCII:E....a@.7..%U........P@I..y........|.........S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:41 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8136d-18d-45820e0968040"....
+uncompressed= 450000e2b66140003706e325550d93d7c0a8000200504049fbb679bcc9051ea48018007cebea00000101080a1153cfdc002cfdb4485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343120474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338313336642d3138642d34353832306530393638303430220d0a0d0a ASCII:E....a@.7..%U........P@I..y........|.........S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:41 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8136d-18d-45820e0968040"....
+compressed= 450000030694cb4566c8001d09cca1c002c192b661ab061418306508137fb9f8fc628620c4a9411b06fc71d78e2001020b1a50b022eddb8017006f2db972658a0c1a31688cb031e3c6882872ee8c8022e70c9b346cd09c81d0e008993b687a8cb88207cd0b9f334610c1a366448d1934728c20dbc3468e1e377a2a8172e5a9153475f2ccad4a640e19336bd03c3522274e1c3466eeb0015cd5091a3473601079c3a6eed3c48b1b3fae5bb5301c3472f0dc0152432b1c327b80d0983163c6532457c8a8a95ae286991d34d29e81416347ed1b387688453383478e1d40679478fa3400 ASCII:E......Ef...........a....0e......b. ..A...q.. ....P.".....o-.re...1h..1...(r..."...4l.......;hz.......3F...fD..4r. ..F..7z*.r...4u...Jd..3k.<5"'N.4f...\...4s`.y.......?.[.0.4r...RC+.2{...1c.S$W...Z....4...AcG..8v.E3.G..@g.x.4.
+memcmp() rc=0
+
+v42bis_compress() rc=0
+v42bis_compress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+Mode: 2
+uncompressed_original= 450000e2b66140003706e325550d93d7c0a8000200504049fbb679bcc9051ea48018007cebea00000101080a1153cfdc002cfdb4485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343120474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338313336642d3138642d34353832306530393638303430220d0a0d0a ASCII:E....a@.7..%U........P@I..y........|.........S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:41 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8136d-18d-45820e0968040"....
+uncompressed= 450000e2b66140003706e325550d93d7c0a8000200504049fbb679bcc9051ea48018007cebea00000101080a1153cfdc002cfdb4485454502f312e3120333034204e6f74204d6f6469666965640d0a446174653a205475652c2033302041756720323031362031363a33363a343120474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338313336642d3138642d34353832306530393638303430220d0a0d0a ASCII:E....a@.7..%U........P@I..y........|.........S...,..HTTP/1.1 304 Not Modified..Date: Tue, 30 Aug 2016 16:36:41 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8136d-18d-45820e0968040"....
+compressed= 45000100e2b66140003706e325550d93d7c0a8000200504049fbb679bcc9051ea48018007cebea00000101080a1153cfdc002cfdb4485454502f312e312033013034204e6f74204d6f646966016965640d0a446174653a205475652c2033302041756720323031362031363a33363a343120474d540d0a5365727665723a204170616368650d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4b6565702d416c6976653a2074696d656f75743d322c206d61783d313030300d0a455461673a2022346338313336642d3138642d34353832306530393638303430220d0a0d0a ASCII:E.....a@.7..%U........P@I..y........|.........S...,..HTTP/1.1 3.04 Not Modif.ied..Date: Tue, 30 Aug 2016 16:36:41 GMT..Server: Apache..Connection: Keep-Alive..Keep-Alive: timeout=2, max=1000..ETag: "4c8136d-18d-45820e0968040"....
+memcmp() rc=0
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 0
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010268000700004006cefac0a80002550d93d740000050462c7ba7e4d1753a80184000aad500000101080a0001a670084dafb4474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005ab97a052b960d59b368d5b2ddb3e60e9c372ef610b6dbf56bd8b165030f2e7cf88dd63b68f64c3d9b76ed1cb58847b490d122e8d0a24761185913d50e1aa423f0dc49036387d6d7b169e4d0cac68e1cd93b70f0804123f7eee03372dcc801038f193b306a68b5b2864d9a3b629a30b1a2b5081b35384613357a07c6133271d4e021a3064d52347182ee81b119c69c3a72d2b079b37e4409c177e6f4902163738cdd71f8a0a903d68ec21866e4c0918185087dfb329cec9831834d951a337c4a2e1174891c3badf5e8d113a38f1c336e24520c8a65751d1844d4c7696d852c1f240e992becf8918d0c9145465441939fcc6a1950a206b7e1fca38e1145eaebc129230aeb24f57bcab011c3c68829f5efe7bfcbe4c814e731668c3042f6fef93a62d9909561e4c91123c163d0085a3a4e1c3466c6c649ea048d519d5ff3a0f95ef4280c2471269e61633ee9193469de8845a3554d9fa74199c48622e7fa7dac30ac602f9af40a9ef0236a54268247cd7f923946d0a8d1c3c68d1e35788c5002e54ad0a00100 ASCII:E...h....@.......U...@..PF,{...u:..@............p.M..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed3.Z.z.+..Y.h.......7......k..e...|...;h.L=.v....G..."...Ga.Y.....#..I.c....i.......;p..A#...3r......;0jh...M.;b.0.....58F.5z...2q..!..MR4q.......:r..y.~D..w...!cs..q........f......}.2...1.M..3|J..t..;........3n$R..eu..D..im.,.$..+......EFTA...j.P........E...)#..$.{......).........1f.0B...:b...a...#.c..Z:N.4f..I...Q._...^.(.$q&.ac>..4i..E.UM..A..."..}.0.`/.....#jT&.G...9F.......5x.P..J....
+uncompressed= 45000268000700004006cefac0a80002550d93d740000050462c7ba7e4d1753a80184000aad500000101080a0001a670084dafb4474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a49662d4d6f6469666965642d53696e63653a205475652c2032332041756720323031362031323a33343a323920474d540d0a0d0a ASCII:E..h....@.......U...@..PF,{...u:..@............p.M..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..If-Modified-Since: Tue, 23 Aug 2016 12:34:29 GMT....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 1
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010268000900004006cef8c0a80002550d93d740000050462c7ba7e4d1753a801840007e7f00000101080a0001d1cc084db0ae474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005ab97a052b960d59b368d5b2ddb3e60e9c372ef610b6dbf56bd8b165030f2e7cf88dd63b68f64c3d9b76ed1cb58847b490d122e8d0a24761185913d50e1aa423f0dc49036387d6d7b169e4d0cac68e1cd93b70f0804123f7eee03372dcc801038f193b306a68b5b2864d9a3b629a30b1a2b5081b35384613357a07c6133271d4e021a3064d52347182ee81b119c69c3a72d2b079b37e4409c177e6f4902163738cdd71f8a0a903d68ec21866e4c0918185087dfb329cec9831834d951a337c4a2e1174891c3badf5e8d113a38f1c336e24520c8a65751d1844d4c7696d852c1f240e992becf8918d0c9145465441939fcc6a1950a206b7e1fca38e1145eaebc129230aeb24f57bcab011c3c68829f5efe7bfcbe4c814e731668c3042f6fef93a62d9909561e4c91123c163d0085a3a4e1c3466c6c649ea048d519d5ff3a0f95ef4280c2471269e61633ee9193469de8845a3554d9fa74199c48622e7fa7dac30ac602f9af40a9ef0236a54268247cd7f923946d0a8d1c3c68d1e35788c5002e54ad0a00100 ASCII:E...h....@.......U...@..PF,{...u:..@.~............M..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed3.Z.z.+..Y.h.......7......k..e...|...;h.L=.v....G..."...Ga.Y.....#..I.c....i.......;p..A#...3r......;0jh...M.;b.0.....58F.5z...2q..!..MR4q.......:r..y.~D..w...!cs..q........f......}.2...1.M..3|J..t..;........3n$R..eu..D..im.,.$..+......EFTA...j.P........E...)#..$.{......).........1f.0B...:b...a...#.c..Z:N.4f..I...Q._...^.(.$q&.ac>..4i..E.UM..A..."..}.0.`/.....#jT&.G...9F.......5x.P..J....
+uncompressed= 45000268000900004006cef8c0a80002550d93d740000050462c7ba7e4d1753a801840007e7f00000101080a0001d1cc084db0ae474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a49662d4d6f6469666965642d53696e63653a205475652c2032332041756720323031362031323a33343a323920474d540d0a0d0a ASCII:E..h....@.......U...@..PF,{...u:..@.~............M..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..If-Modified-Since: Tue, 23 Aug 2016 12:34:29 GMT....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 2
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010268000b00004006cef6c0a80002550d93d740000050462c7ba7e4d1753b80193fff131c00000101080a00022884084dc558474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005ab97a052b960d59b368d5b2ddb3e60e9c372ef610b6dbf56bd8b165030f2e7cf88dd63b68f64c3d9b76ed1cb58847b490d122e8d0a24761185913d50e1aa423f0dc49036387d6d7b169e4d0cac68e1cd93b70f0804123f7eee03372dcc801038f193b306a68b5b2864d9a3b629a30b1a2b5081b35384613357a07c6133271d4e021a3064d52347182ee81b119c69c3a72d2b079b37e4409c177e6f4902163738cdd71f8a0a903d68ec21866e4c0918185087dfb329cec9831834d951a337c4a2e1174891c3badf5e8d113a38f1c336e24520c8a65751d1844d4c7696d852c1f240e992be4e8918d8c9045465441939fcc6a1950a206b7e1dca38e1145eaebb929230aeb24f579cab011c3c68829f5efe7afcbe4c814e731668c3042f6fef93a62d9909561e4c91123c163d0084a3a4e1c3466c6c649ea048dd19c5ff3a0f95ef4280c2471269e61633ee9193469de8845a3554d9fa74199c48622c7fa7dac30ac5c2f9af40a1ef0236a502682478dff913946d0a8d1c3c68d1e35788c5002e54ad0a00100 ASCII:E...h....@.......U...@..PF,{...u;..?...........(..M.XGET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed3.Z.z.+..Y.h.......7......k..e...|...;h.L=.v....G..."...Ga.Y.....#..I.c....i.......;p..A#...3r......;0jh...M.;b.0.....58F.5z...2q..!..MR4q.......:r..y.~D..w...!cs..q........f......}.2...1.M..3|J..t..;........3n$R..eu..D..im.,.$..+......EFTA...j.P........E...)#..$.y......).........1f.0B...:b...a...#.c..J:N.4f..I....._...^.(.$q&.ac>..4i..E.UM..A..."..}.0.\/.....#jP&.G...9F.......5x.P..J....
+uncompressed= 45000268000b00004006cef6c0a80002550d93d740000050462c7ba7e4d1753b80193fff131c00000101080a00022884084dc558474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a49662d4d6f6469666965642d53696e63653a205475652c2032332041756720323031362031323a33343a323920474d540d0a0d0a ASCII:E..h....@.......U...@..PF,{...u;..?...........(..M.XGET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..If-Modified-Since: Tue, 23 Aug 2016 12:34:29 GMT....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 3
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010268000c00004006cef5c0a80002550d93d740000050462c7ba7e4d1753b80193fff65ab00000101080a0002d5f4084dc558474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005ab97a052b960d59b368d5b2ddb3e60e9c372ef610b6dbf56bd8b165030f2e7cf88dd63b68f64c3d9b76ed1cb58847b490d122e8d0a24761185913d50e1aa423f0dc49036387d6d7b169e4d0cac68e1cd93b70f0804123f7eee03372dcc801038f193b306a68b5b2864d9a3b629a30b1a2b5081b35384613357a07c6133271d4e021a3064d52347182ee81b119c69c3a72d2b079b37e4409c177e6f4902163738cdd71f8a0a903d68ec21866e4c0918185087dfb329cec9831834d951a337c4a2e1174891c3badf5e8d113a38f1c336e24520c8a65751d1844d4c7696d852c1f240e992be4e8918d8c9045465441939fcc6a1950a206b7e1dca38e1145eaebb929230aeb24f579cab011c3c68829f5efe7afcbe4c814e731668c3042f6fef93a62d9909561e4c91123c163d0084a3a4e1c3466c6c649ea048dd19c5ff3a0f95ef4280c2471269e61633ee9193469de8845a3554d9fa74199c48622c7fa7dac30ac5c2f9af40a1ef0236a502682478dff913946d0a8d1c3c68d1e35788c5002e54ad0a00100 ASCII:E...h....@.......U...@..PF,{...u;..?.e............M.XGET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed3.Z.z.+..Y.h.......7......k..e...|...;h.L=.v....G..."...Ga.Y.....#..I.c....i.......;p..A#...3r......;0jh...M.;b.0.....58F.5z...2q..!..MR4q.......:r..y.~D..w...!cs..q........f......}.2...1.M..3|J..t..;........3n$R..eu..D..im.,.$..+......EFTA...j.P........E...)#..$.y......).........1f.0B...:b...a...#.c..J:N.4f..I....._...^.(.$q&.ac>..4i..E.UM..A..."..}.0.\/.....#jP&.G...9F.......5x.P..J....
+uncompressed= 45000268000c00004006cef5c0a80002550d93d740000050462c7ba7e4d1753b80193fff65ab00000101080a0002d5f4084dc558474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a49662d4d6f6469666965642d53696e63653a205475652c2032332041756720323031362031323a33343a323920474d540d0a0d0a ASCII:E..h....@.......U...@..PF,{...u;..?.e............M.XGET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..If-Modified-Since: Tue, 23 Aug 2016 12:34:29 GMT....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 4
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 450001022d000f00004006ac5ec0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00 ASCII:E...-....@..^........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application3.\....g..8o\...vj..Y........w..I..k.9`..h!....;{.0....4>G........O......9.w........g......3v`..je..4w.4ab.j.6jpd.....'d...CF...h....#2.9u..a.&...x...!CF.....AS....1...#.....e8.1c..*5f.D\...9vF....G..:h..H.&..u`...g...|...._"E62...Q..{2.e@9z..q.:F.Y....(....).F..#..o..-.#S...1......`e.U..'G...y.s.8h.d......1..AS}gO.H. <....3h.......>Eo...
+uncompressed= 4500022d000f00004006ac5ec0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a2031302e392e312e3137313a383030300d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..-....@..^........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: 10.9.1.171:8000..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 5
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 450001022d001000004006ac5dc0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00 ASCII:E...-....@..]........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application3.\....g..8o\...vj..Y........w..I..k.9`..h!....;{.0....4>G........O......9.w........g......3v`..je..4w.4ab.j.6jpd.....'d...CF...h....#2.9u..a.&...x...!CF.....AS....1...#.....e8.1c..*5f.D\...9vF....G..:h..H.&..u`...g...|...._"E62...Q..{2.e@9z..q.:F.Y....(....).F..#..o..-.#S...1......`e.U..'G...y.s.8h.d......1..AS}gO.H. <....3h.......>Eo...
+uncompressed= 4500022d001000004006ac5dc0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a2031302e392e312e3137313a383030300d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..-....@..]........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: 10.9.1.171:8000..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 6
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 450001022d001100004006ac5cc0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00 ASCII:E...-....@..\........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application3.\....g..8o\...vj..Y........w..I..k.9`..h!....;{.0....4>G........O......9.w........g......3v`..je..4w.4ab.j.6jpd.....'d...CF...h....#2.9u..a.&...x...!CF.....AS....1...#.....e8.1c..*5f.D\...9vF....G..:h..H.&..u`...g...|...._"E62...Q..{2.e@9z..q.:F.Y....(....).F..#..o..-.#S...1......`e.U..'G...y.s.8h.d......1..AS}gO.H. <....3h.......>Eo...
+uncompressed= 4500022d001100004006ac5cc0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a2031302e392e312e3137313a383030300d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..-....@..\........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: 10.9.1.171:8000..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 7
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 450001022d001200004006ac5bc0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00 ASCII:E...-....@..[........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application3.\....g..8o\...vj..Y........w..I..k.9`..h!....;{.0....4>G........O......9.w........g......3v`..je..4w.4ab.j.6jpd.....'d...CF...h....#2.9u..a.&...x...!CF.....AS....1...#.....e8.1c..*5f.D\...9vF....G..:h..H.&..u`...g...|...._"E62...Q..{2.e@9z..q.:F.Y....(....).F..#..o..-.#S...1......`e.U..'G...y.s.8h.d......1..AS}gO.H. <....3h.......>Eo...
+uncompressed= 4500022d001200004006ac5bc0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a2031302e392e312e3137313a383030300d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..-....@..[........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: 10.9.1.171:8000..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 8
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010268001300004006ceeec0a80002550d93d740000050462c7ba7e4d1753b80193fff7b4a00000101080a0003c054084dc558474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005bbb7e0d3b964dd9b369d7b6ddb3e60e9c372ef614beeb15ac58b2660513368cf8cdd63b68f65045ab96ed9cb58947b490d1422851a34861185923d50e9aa423f0dc490363c756d8b269e4d8cac68e9cd93b70f0804143376fe13372dcc801038f193b306a6cb5b2864d9a3b629a30b1b2b5081b353848173d7a07c6133271d4e021a3068d52347184ee81c119c69c3a72d2b079c37e4489c177e6f4902183730cde71f8a0a913d6cec21866e4c091818548fdfb329cec9831834d951a337e4e2e2174891c3baef5e8d113a38f1c336e2656148a85751d1844d6c7716da52c1f240f9b2fecf8918d0c9145465441a39f0c6b1950a40ab7f1fca38e1145ecebc129234aeb24f67bcab011c3c68829f6f1ebb7cbe4c894e731668c3052163ffa3a63d9949561e4c91123c263d0105a3a4e1c3466c8c651ea04cd519d60f3a0016f14290c2471289e61735ee9193469de8c45b3554d1fa84299c88622e73afeac30ac6037aaf40a9ef0236a54268247cd7f923946d0a8d1c3c68d1e35788c5002e58a50a10100 ASCII:E...h....@.......U...@..PF,{...u;..?.{J.........T.M.XGET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed3.[.~.;.M..i.......7.......X.f..6....;h.PE......G...B(Q.Ha.Y#....#..I.c.V..i.......;p..AC7o.3r......;0jl...M.;b.0.....58H.=z...2q..!...R4q.......:r..y.~D..w...!.s..q........f.....H..2...1.M..3~N.!t..;........3n&V...u..D..qm.,.$../......EFTA...k.P........E...)#J.$.{......).........1f.0R.?.:c...a...#.c..Z:N.4f..Q...Q.`...o.).$q(.as^..4i..E.UM..B...".:..0.`7.....#jT&.G...9F.......5x.P...P...
+uncompressed= 45000268001300004006ceeec0a80002550d93d740000050462c7ba7e4d1753b80193fff7b4a00000101080a0003c054084dc558474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a49662d4d6f6469666965642d53696e63653a205475652c2032332041756720323031362031323a33343a323920474d540d0a0d0a ASCII:E..h....@.......U...@..PF,{...u;..?.{J.........T.M.XGET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..If-Modified-Since: Tue, 23 Aug 2016 12:34:29 GMT....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 9
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 450001022d001400004006ac59c0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00 ASCII:E...-....@..Y........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application3.\....g..8o\...vj..Y........w..I..k.9`..h!....;{.0....4>G........O......9.w........g......3v`..je..4w.4ab.j.6jpd.....'d...CF...h....#2.9u..a.&...x...!CF.....AS....1...#.....e8.1c..*5f.D\...9vF....G..:h..H.&..u`...g...|...._"E62...Q..{2.e@9z..q.:F.Y....(....).F..#..o..-.#S...1......`e.U..'G...y.s.8h.d......1..AS}gO.H. <....3h.......>Eo...
+uncompressed= 4500022d001400004006ac59c0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a2031302e392e312e3137313a383030300d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..-....@..Y........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: 10.9.1.171:8000..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 10
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 450001022d001500004006ac58c0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e33005cbd8215bb67cd1d386f5cecd1cb766ad5ab59b7decdbbb7ef1ba877d0ec49daf56bd83960fd8e6821a3c5cd9c3b7bc230b2e6a81d343e47e0b99306c60ea8a54fd3c801958d1d39a877e0e00183c6ebd8b767e4b89103061e337660d4806a650d9b3477c4346162056a11366a7064d6c9f30e8c2764e2a8c143460d9a9f68e2dcdc0323328c3975e4a461f326fc881278efcce9214346e418b1e3f04153c7aa9dfd31ccc88123030b11f5ec6538d93163069b2a3566d0445ce2e612397646d398118347cd9a3a68f49848f12696d0756010011f67b415ad7c90fc17be5f224536322e16195105cd7b32a16540397adb06718a3a461459afe7a58c28a293acb729c3460c1b23a6ac6ffffe2d93235388c79831c288d6f6ddeb6065a355869127478cdcae79b3739c3868cc648df3d3091a9e31abe641537d674f1848e2203cc386fbcf3368d2bcc18a06aa9a3e456fde0c00 ASCII:E...-....@..X........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application3.\....g..8o\...vj..Y........w..I..k.9`..h!....;{.0....4>G........O......9.w........g......3v`..je..4w.4ab.j.6jpd.....'d...CF...h....#2.9u..a.&...x...!CF.....AS....1...#.....e8.1c..*5f.D\...9vF....G..:h..H.&..u`...g...|...._"E62...Q..{2.e@9z..q.:F.Y....(....).F..#..o..-.#S...1......`e.U..'G...y.s.8h.d......1..AS}gO.H. <....3h.......>Eo...
+uncompressed= 4500022d001500004006ac58c0a800020a0901ab40011f4046a2f5a8e0a618025018400093480000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a2031302e392e312e3137313a383030300d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..-....@..X........@..@F.......P.@..H..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: 10.9.1.171:8000..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 11
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010239000500004006ac5cc0a800020a0901ab40001f90c286afa741a348cb801840007fcb0000050a41a348dc41a34a440000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d69786564330057b36eedfa954dd8b165cfa6ddb3e60e9c372ef6049eab95ab57b062fd02164cf8cdd53b68f640256b16ed9cb38547b490d1e22791a043efc030b2c6a91d344547e0b99306c68eabad5fd3c871958d1d39b077e0e00183c6eddcbf67e4b89103061e337660d4b86a650d9b3477c4346162e56a11366a7080164d14c6133271d4e021a3068d5134717eee818119c69c3a72d2b079837e4489bf77e6f4902103738cdc71f8a0a9d3d58ec11866e4c091818548fcf9329cec9831834d951a33783e2ef173891c3bab69cc88c1a3674f1d347a6cdcf8134bea3a30889c8fb3da4a583e48162a37a891231b19208b8ca882c63e99d432a038fd6d8339471d238ac8d793534614d549e40b956123868d1153e4d3b77f97c99129cc63cc1861242c7df275beb2092bc3c89323467ef7fc693a4e1c3466c0c631ea04cdd09d5cf3a0e96e66e81d1848e2403cc366bcd13368d2bcf98ae6aa9a3e4c7ffe0c00 ASCII:E...9....@..\........@.......A.H...@.......A.H.A.JD..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed3.W.n...M..e.......7.......W.b...L...;h.@%k.....G....'..C..0....4EG........_..q...9.w........g......3v`..je..4w.4ab.j.6jp..M...2q..!...Q4q~......:r..y.~D..w...!.s..q........f.....H..2...1.M..3x>..s..;.i....gO.4zl...K.:0.....JX>H.*7..#.. .....>..2.8.m.9G.#....SF..I...a#...S.......).c..a$,}.u...+...#F~..i:N.4f..1.....\...nf...H.@<.f..3h.......>L....
+uncompressed= 45000239000500004006ac5cc0a800020a0901ab40001f90c286afa741a348cb801840007fcb0000050a41a348dc41a34a440000474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a2031302e392e312e3137313a383038300d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..9....@..\........@.......A.H...@.......A.H.A.JD..GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: 10.9.1.171:8080..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 12
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 450001025b000a00004006ac35c0a800020a0901ab40011f90c293b0a8af5e58be5018400072a60000474554202f72656470686f6e652e706e6720485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c33005cbd82154b368e59b46ad9ee597307ce1b177b066fedfa35ec583665010b266cf8cdd63b68f6543d9b76ed1cb58747b490d16268d1a34961185933d50e1aa523f0dc490363c7d6d7b169e4d8cac68e1cd93b70f0804123f7eee03372dcc801038f193b306a6cb5b2864d9a3b629a30b1b2b5081b3538461b457a07c6133238f190518366299a3843f7c0d80c634e1d3969d8bc513fa244e03b737ac890b139c6ee387cd0d4096b07610c3372e0c8c042647e7d194e76cc98c1a64a8d1940259718ba448e9dd63466c4e01134a80e1a3d38721c8a65751d1844d2c7696d65261f240d9923dcd8918d0c9045465441839fcc6a1950a606b7e1bca38e1145e8ebd929230aeb24f485cab011c3c68829f4ede3d7cbe4c814e731668c3032d3be1a3c75c6b2296be4c91123c1830e451d270e1a3364e32c758206694fb079d07c3f9a1406923812cfb0c1b9f40c9a346fc6a2d9aaa64fd4a175d33064b894bfff812b5bc2a421b3e60c8e32860e0d00 ASCII:E...[....@..5........@........^X.P.@.r...GET /redphone.png HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed,3.\...K6.Y.j..Ys....{.o..5.X6e..&l...;h.T=.v....G...bh..Ia.Y3....#..I.c....i.......;p..A#...3r......;0jl...M.;b.0.....58F.Ez...28..Q.f).8C....cN.9i..Q?.D.;sz...9..8|...k.a.3r...Bd~}.Nv....J..@%...D...4f...4...=8r..eu..D..ime&.$..#......EFTA...j.P........E...)#..$........).........1f.02...<u..)k...#...E.'..3d.,u..iO.y.|?....8........4o.....O..u.0d.....+[..!....2....
+uncompressed= 4500025b000a00004006ac35c0a800020a0901ab40011f90c293b0a8af5e58be5018400072a60000474554202f72656470686f6e652e706e6720485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a2031302e392e312e3137313a383038300d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f31302e392e312e3137313a383038302f0d0a0d0a ASCII:E..[....@..5........@........^X.P.@.r...GET /redphone.png HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: 10.9.1.171:8080..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://10.9.1.171:8080/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 13
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010267001200004006ac21c0a800020a0901ab40011f90c293b0a8af5e58be80184000ee770000050aaf5e6437af5e8c230000474554202f72656470686f6e652e706e6720485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d33006fc8de41b3c72b5cb974e7cc853ca2858c164c9d42950ac3c81aae76d04c1d81e74e1a183bc8e2d64d2307593676e4ecde8183070c1ac2892b9f91e3460e1878ccd8815183ac95356cd2dc11d3848915b245d8a8c1c1fa69d43b309e90098a878c1a3454d1c461ba0706691873eac849c3e6cdfc112514df99d343860cd23188c7e183a68e5a3b126398910347061622fcfdcb70b263c60c36556acc48bab904d32572ecd8a63123060fa54a75d0e861d224532cb4ebc020223f8e6d2b3cf920b1585d62c9936c64a82c32a20a9a826468cb80c255b98deb27758c28d25f4f5119516a27e9df54868d1836464ce9ffbf20612647a65c8f316384119effd5e0a9c3968d5b234f8e1851ae94a9ec3871d098691b87aa1334518fa6cd83063d54a93090c4d978864d50aa67d0a479c3160d59357db432fd9ba66245aa0a193aac7953278d9e3f679894c1946900 ASCII:E...g....@..!........@........^X...@..w.....^d7.^.#..GET /redphone.png HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xm3.o..A..+\.t...<....L.B......v.L...N..;...M#.Y6v..........+...F..x...Q...5l........E.....i.;0.......4T..a...i.s..I.....%....C...1......Z;.c...G.."...p.c..6Uj.H....%r...1#...Ju..a.$S,... "?.m+<. .X]b..ld.,2....dh...U...'u.(._OQ.Qj'..T...6FL... a&G.\.1c..........[#O..Q....8q..i....4Q.....=T.0...x.MP.g..y...Y5}.2...bE...:.yS'..?g....i.
+uncompressed= 45000267001200004006ac21c0a800020a0901ab40011f90c293b0a8af5e58be80184000ee770000050aaf5e6437af5e8c230000474554202f72656470686f6e652e706e6720485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a2031302e392e312e3137313a383038300d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f31302e392e312e3137313a383038302f0d0a0d0a ASCII:E..g....@..!........@........^X...@..w.....^d7.^.#..GET /redphone.png HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: 10.9.1.171:8080..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://10.9.1.171:8080/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 14
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010236003000004006cf03c0a80002550d93d740020050c30e84a9441d06ac80184000c2f400000101080a00052df410fc31bd474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d6978656433005cbd82154b968d59b46ad9baddb3e60e9c372ef618c6fb35ecd8b26707173e9cf80dd73b68f6544dbbb6ed1cb68a47b490d16268d1a34961185933d50e1aa523f0dc49036307d7d8b369e4e0cac68e1cda3b70f080416377efe13372dcc801038f193b306a70b5b2864d9a3b629a30b1c2b5081b35384a1b457a07c6133271d4e021a306cd52347186ee81d119c69c3a72d2b079d37e4409c277e6f49021a3738cde71f8a0a923d60ec31866e4c0918185887dfc329cec9831834d951a3380522e3174891c3baff5e8d113a38f1c336e285a1c8aa5751d1844d8c7796dc52c1f24109d33f408928d8c9145465441b39f4c6b1950a60eb7011da48e1145eeebc929238aeb24f77dcab011c3c68829f7f3efbfcbe4c814e831668c3062367ffa3a64d9989561e4c91123c363d0186a3a4e1c3466cac659ea040dd29d61f3a0097f34290c24712a9e61837ee9193469de9045c3554d9fa843870600 ASCII:E...6.0..@.......U...@..P....D.....@...........-...1.GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed3.\...K..Y.j.......7.....5...g..>....;h.TM......G...bh..Ia.Y3....#..I.c....i.......;p..Acw..3r......;0jp...M.;b.0.....58J.Ez...2q..!...R4q.......:r..y.~D..w...!.s..q...#....f......}.2...1.M..3.R.1t..;........3n(Z...u..D..ym.,.$..3......EFTA..Lk.P........E...)#..$.}......).........1f.0b6..:d...a...#.c..j:N.4f..Y.....a....4).$q*.a.~..4i..E.UM..C...
+uncompressed= 45000236003000004006cf03c0a80002550d93d740020050c30e84a9441d06ac80184000c2f400000101080a00052df410fc31bd474554202f20485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a0d0a ASCII:E..6.0..@.......U...@..P....D.....@...........-...1.GET / HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 15
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010260004500004006cec4c0a80002550d93d740030050c3134faac89c8b2980184000578d00000101080a000535c010fc34c8474554202f6e697276616e612e63737320485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d33006fcede41b3072c5dbb78e7dcad3ca2858c164ea14aa50ac3c81aaf76d0541d81e74e1a183bcef2f64d23c7593676e4fcde8183070c1ac6913b9f91e3460e187884c2a871d6ca1a3669ee8869c2c4cad9226cd4e0801d75ea1d184f7caac143460d1aab68e238dd0303358c3975e4a461f3c6fe88128fefcce9214306ea18c8e3f04153a7edd0b841e5c0918185c87f83329cec9831834d951a33967e2ee174891c3bbaf5e8d113a38f1c336e3ac2718a05771d1844eac7d16d252e1f241985563489928d8c954546544193900c6e1950bc3ab7a11da58e11450aea292a234aee240595cab011c3c68829050f2624cce4c814ed31668c3012f7a0fc3a6fd9c49561e4c91123ce63d0702a3b4e1c3466e0c6b1ea04cdd4a36cf3a0592f952a0c2471ccc839c3268e1aab67d0a479f316cd59357db83af59b062346ab0d1f46b47933e7ce9e329c3a0d00 ASCII:E...`.E..@.......U...@..P..O....)..@.W.........5...4.GET /nirvana.css HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xm3.o..A..,].x...<....N.J......v.T...N..;...M#.Y6v..........;...F..x...q...6i..i...."l....u...O|..CF...h.8...5.9u..a.........!C......AS....A........2...1.M..3.~..t..;........3n:.q..w..D...m%..$..V4.....EFTA...n.P.:......E..)*#J.$........)..&$.....1f.0....:o...a...#.c.p*;N.4f........l..Y/.*.$q..9.&...g..y...Y5}.:...#F...F.y3...2.:..
+uncompressed= 45000260004500004006cec4c0a80002550d93d740030050c3134faac89c8b2980184000578d00000101080a000535c010fc34c8474554202f6e697276616e612e63737320485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..`.E..@.......U...@..P..O....)..@.W.........5...4.GET /nirvana.css HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 16
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010264004600004006cebfc0a80002550d93d740040050c3135bab2189da61801840008f2d00000101080a000535c410fc34dc474554202f382d4269742f4c6162656c2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300952fbf517b07cd1e9f77f3ee9da317f38816325a48a56a152b0c236bc4da419375049e3b6960ec50fb3b388d1c6ad9d891237c070e1e3068245f1e7d468e1b3960e0316307460db556d6b04973474c132656d4f254836376d5ab7760008da3060f193568b4a28923750f8cd530e6d4919386cd9bfc234a48be33a7870c19ab632c8fc3074d1db87630c63023078e0c2c440c2294e164c78c196caad498f1547409a94be4d8e9ad478f9e187de498710352a4542cbbebc020823f4e6f2b74f920e1c81da34a966c64bc2c32a20a1a866476cb802236ba0def2c758c2872500f521951782739d854868d1836464c39a89061612647a6788f31638411ba0aebd791cb86ae0c234f8e18891e838654da71e2a03133378e562768ae2a7d9b078d7bab5861208913f20c1bfa5acfa049f3462e1ab56afa80950a38cdc68d5a214aa4a873e74fa144474a951a00 ASCII:E...d.F..@.......U...@..P..[.!..a..@..-........5...4.GET /8-Bit/Label.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtm3../.Q{....w........2ZH.j.+.#k..A.u..;i`.P.;8..j...#|...0h$_.}F..9`.1c.F..V..IsGL.&V..T.cv..w`......5h...#u...0........#JH.3.....c,...M..v0.0#...,D."..d...l....Tt..K....G...}..q.R.T,... .?No+t. ....J.ld.,2....dv.."6...,u.(rP.R.Qx'9.T...6FL9..aa&G.x.1c...........#O......T.q..137.V'h.*}...{.Xa ......Z..I.F...j....8...Z!J..s.O.DGJ...
+uncompressed= 45000264004600004006cebfc0a80002550d93d740040050c3135bab2189da61801840008f2d00000101080a000535c410fc34dc474554202f382d4269742f4c6162656c2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..d.F..@.......U...@..P..[.!..a..@..-........5...4.GET /8-Bit/Label.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 17
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010264005800004006ceadc0a80002550d93d740050050c31389acaf7b26538018400075c900000101080a000537d010fc354a474554202f382d4269742f41636f726e2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300942dbf497b07cd1e9f76f1ea9d93f7f28816325a48a56af50e0c236bc2da418375049e3b6960ec48eb1b388d1c69d9d891137c070e1e306820570e7d468e1b3960e0316307468db456d6b04973474c132656d2f2548343b699aa57613c2113470d1e326ad064451347ea1e18aa61cca923270d9b37f94794887c674e0f193254c7501e870f9a3a6fed608c11148e0c2c440c2294e164c78c196caad498f1347409a94be4d8e1ad478f9e187de4987103520e1ca95874d78141047f1cde56e6f241c2713bc6942bd9c87059644415340cc9e89601252c741bdd57ea1851e4a09ea432a2ec4e72d0a90c1b316c8c9872502143c34c8e4ce91e63c608237315d6af1397cd5c19469e1c31023d060da9b4e3c44163466e9cac4ed0585dea360f9af6efefc0401227e81936f4b39e4193e64d5c3469d5f4f92a15709a8d1bb342944831a7ce9e42898a942a3500 ASCII:E...d.X..@.......U...@..P.....{&S..@.u.........7...5JGET /8-Bit/Acorn.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtm3..-.I{....v........2ZH.j...#k..A.u..;i`.H..8..i....|...0h W.}F..9`.1c.F..V..IsGL.&V..T.C...Wa<!.G..2j.dE.G....a..#'..7.G..|gN..2T.P....:o.`.....,D."..d...l....4t..K....G...}..q.R...Xt..A....V..A.q;..+..pYdD.4.....%,t..W..Q....2..Nr....1l..rP!C.L.L..c..#s......\.F..1.=......AcFn..N.X].6......@.'..6...A..M\4i...*.p....B.H1...B...*5.
+uncompressed= 45000264005800004006ceadc0a80002550d93d740050050c31389acaf7b26538018400075c900000101080a000537d010fc354a474554202f382d4269742f41636f726e2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..d.X..@.......U...@..P.....{&S..@.u.........7...5JGET /8-Bit/Acorn.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 18
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010266007600004006ce8dc0a80002550d93d740060050c31431ada11fa06780184000f08e00000101080a00053b3c10fc35ef474554202f382d4269742f416d73747261642e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d33009733bf597b07cd9e9e78f5f2d5a379440b192da656bd9a1586913563eda0d13a02cf9d343076ac052e9c468eb56cecc819be03070f18349433973e23c78d1c30f098b103a3c65a2b6bd8a4b923a609132b6b77aac141db2ad63b309e9089a3060f193568b6a28933750f0cc830e6d4919386cd9bfd234a50be33a7870c199063308fc3074d9db87636c63023078e0c2c44103294e164c78c196caad49801957489a94be404ddaa478f9e187de4987133b2e4542cbcebc020a23f8e6f2b75f920f9d87d63cb976c64c82c32a20a9a876478cb803256ba8def2f758c28a2500f5319517a27512855868d1836464c51d8f061622647a67c8f31638491ba0defd799cba6ae0c234f8e18911e83c6d4db71e2a0314337ce562768b03a859b07cdfbab5961208943f20c1bfb5bcfa049f3662e9ab56afa849d3a388d478f5b2756bcf813e850a3484d4e9d1a00 ASCII:E...f.v..@.......U...@..P..1....g..@...........;<..5.GET /8-Bit/Amstrad.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtm3..3.Y{....x....yD..-.V.....5c...:...40v....F..l........4.3.>#...0......Z+k...#...+kw..A.*.;0.......5h...3u...0........#JP.3.....c0...M..v6.0#...,D.2..d...l.....t..K....G...}..q3..T,... .?.o+u. ..}c..ld.,2....dx..2V.../u.(.P.S.Qz'Q(U...6FLQ..ab&G.|.1c...........#O........q..1C7.V'h.:......Ya .C....[..I.f...j...:8.G.['V....P.HMN...
+uncompressed= 45000266007600004006ce8dc0a80002550d93d740060050c31431ada11fa06780184000f08e00000101080a00053b3c10fc35ef474554202f382d4269742f416d73747261642e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..f.v..@.......U...@..P..1....g..@...........;<..5.GET /8-Bit/Amstrad.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 19
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010264007700004006ce8ec0a80002550d93d740040050c3135ddb2189e0108018400060d600000101080a00053b4010fc35e7474554202f382d4269742f41746172692e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300932bbf497b07cd1e9f76f1ea9d93d7f28816325a48a56a152b0c236b84da419375049e3b6960ec48dbfb378d1c69d9d891037c070e1e30681c4ffe7c468e1b3960e0316307468db456d6b04973474c132656d2f254832376d5ab77603c2113470d1e326ad068451347ea1e18a961cca923270d9b37f84794807c674e0f193252c7481e870f9aa1da2fc63023078e0c2c440a1e94e164c78c196caad498f1147409a94be4d8d9ad478f9e187de49871e311a4542cb9ebc020723fce6e2b73f920d968e7224a956c64b42c32a20a9a856472cb8022f4b90dee2a758c286250cf511951742731c854868d1836464c31887061612647a6708f31638491b908e9d789cb66ae0c234f8e18791e8386d4d971e2a03123378e562768ae26759b070d7bab58612089f3f10c9bf95acfa049f3262e9ab46afa8095fa378d468d5a1f469c8833e7ce9f41434a951a00 ASCII:E...d.w..@.......U...@..P..].!.....@.`.........;@..5.GET /8-Bit/Atari.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtm3..+.I{....v........2ZH.j.+.#k..A.u..;i`.H..7..i....|...0h.O.|F..9`.1c.F..V..IsGL.&V..T.#v..w`<!.G..2j.hE.G....a..#'..7.G..|gN..2R.H....../.0#...,D....d...l.....t..K....G...}..q...T,... r?.n+s. .h."J.ld.,2....dr.."....*u.(bP.Q.Qt'1.T...6FL1.paa&G.p.1c........f..#O..y.....q..1#7.V'h.&u...{.Xa ......Z..I.&...j....7.F.Z.F..3...ACJ...
+uncompressed= 45000264007700004006ce8ec0a80002550d93d740040050c3135ddb2189e0108018400060d600000101080a00053b4010fc35e7474554202f382d4269742f41746172692e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..d.w..@.......U...@..P..].!.....@.`.........;@..5.GET /8-Bit/Atari.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 20
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010264007c00004006ce89c0a80002550d93d740070050c314f3aefa37ceb18018400009f900000101080a00053e3410fc369e474554202f382d4269742f4170706c652e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300942dbf517b07cd1e9f76f1ea9d93f7f28816325a48a56a152b0c236bc4da419375049e3b6960ec50dbfb378d1c6ad9d891037c070e1e30681c4ffe7c468e1b3960e0316307460db556d6b04973474c132656d4f254832376d5ab77603c2113470d1e326ad068451347ea1e18a961cca923270d9ba15a4b44be33a7870c19a963248fc3074d9db7762cc63023078e0c2c400da691e164c78c196caad498f1147409a94be4d8d9ad478f9e187de49871e311a4542cb9ebc020723fce6e2b73f920d1a8dd224a956c64b42c32a20a9aa16472cb8022f6b90dee2a758c2862504f521951742731e854868d1836464c29a910cd602647a6708f31638491b908e9d789cb66ae0c234f8e18791e8386d4d971e2a03123378e562768ae2e7dc3260f1af656b1c24012e7e31936f3b59e4193e64d5c346ad5f4012bd56f9a8c19b53a84281167ce9d3f8b86942a3500 ASCII:E...d.|..@.......U...@..P.....7....@...........>4..6.GET /8-Bit/Apple.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtm3..-.Q{....v........2ZH.j.+.#k..A.u..;i`.P..7..j....|...0h.O.|F..9`.1c.F..V..IsGL.&V..T.#v..w`<!.G..2j.hE.G....a..#'...ZKD.3.....c$...M..v,.0#...,@....d...l.....t..K....G...}..q...T,... r?.n+s. ..."J.ld.,2....dr.."....*u.(bPOR.Qt'1.T...6FL)...`&G.p.1c........f..#O..y.....q..1#7.V'h..}.&...V..@....6...A..M\4j...+.o....:.(.g..?...*5.
+uncompressed= 45000264007c00004006ce89c0a80002550d93d740070050c314f3aefa37ceb18018400009f900000101080a00053e3410fc369e474554202f382d4269742f4170706c652e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..d.|..@.......U...@..P.....7....@...........>4..6.GET /8-Bit/Apple.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 21
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010265007d00004006ce87c0a80002550d93d740050050c3138bdcaf7b296780183cec0de600000101080a00053e3410fc368e474554202f382d4269742f447261676f6e2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d33009631bf597b07cd1e9f8df5f2d59379440b192da656bd9a1586913563eda0d13a02cf9d343076ac052e9c468eb56cecc819be03070f18349433973e23c78d1c30f098b103a3c65a2b6bd8a4b923a609132b6b79aac141db2ad63b309e9089a3068f50345bd1c499ba07c6631873eac849c3e68dfe112526df99d343868cc73198c7e183a64e5c3b1963989103470616220715ca70b263c60c36556acc804abac4d42572ecf8d6a3474f8c3e72ccb80939722a16de75601051c3dfb715a27c9074ec9e71654b363260161951054d4332bc6540192bddc6f7963a461441a847a98c28bd93208ce3d3460c1b23a6205cd89030932353bec79831c208d185f7ebcc6553d7c8932346a4c7a03175769c3868ccd08db3d5091aac4ce1e641f3fe6a561848e2883cc3c6fed63368d2bc998b66ad9a3e61a7fe4dc391e3d688132beeec0974a8519253a70600 ASCII:E...e.}..@.......U...@..P.....{)g..<...........>4..6.GET /8-Bit/Dragon.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtm3..1.Y{.........yD..-.V.....5c...:...40v....F..l........4.3.>#...0......Z+k...#...+ky..A.*.;0......P4[......c.s..I.....%&...C...1.....N\;.c...G.."...p.c..6Uj..J...%r....GO.>r...9r*..u`.Q.....|.t..qeK62`..Q.MC2.e@.+....:F.A.G..(.. ...F..#. \..0.#S...1.......eS...#F...1uv.8h........L..A..jV.H..<....3h....f..>a..M......+...t.Q.S...
+uncompressed= 45000265007d00004006ce87c0a80002550d93d740050050c3138bdcaf7b296780183cec0de600000101080a00053e3410fc368e474554202f382d4269742f447261676f6e2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..e.}..@.......U...@..P.....{)g..<...........>4..6.GET /8-Bit/Dragon.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 22
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010269008000004006ce80c0a80002550d93d740060050c3143301dfa11fa3de80183c892b5d00000101080a0005412c10fc3761474554202f382d4269742f456e74657270726973652e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f6600952f67defcc66dd03d3df7f6fd3bc72fe7112d64b4b08a552b571846d6983dda75049e3b6960ec701b7c388d1c6e8dca21be03070f183496db694e63468e1b3960e0316307460db756d6b04973474c132656dcee5483c376d6ad77603c2113470d1e326ad0784513c7ea1e18ae6110959386cd1bfe234a58be33a7870c19ae63548fc347285d3b1b63989103470616220ad3c870b263c60c36556acc986aba84d52572ecfcd6a3474f8c3e72ccb81149d22a96a3756010d91fe7b715bc7c90d4f9b891a54b36326216195105cd4332476540312bdd0678973a4614a923478f531951d0dc49d299aa0c1b316c8c98d2b9e143c64c8e4c011f63c60823781be2af63970d5e19469e1c31223d060dabbce3c44163e66e1caf4ed06c853a370f1af85ab9c2401267e41936f7bd9e4193e68d5d346ed5f4216bd5701aa142bd4eac78d1e7cfa1489596b46a3500 ASCII:E...i....@.......U...@..P..3........<.+]........A,..7aGET /8-Bit/Enterprise.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/f../g...m.==...;./..-d...U+W.F..=.u..;i`.p.|8..n..!.....4..iNcF..9`.1c.F..V..IsGL.&V..T..v..w`<!.G..2j.xE......a.......#JX.3.....cT..G(];.c...G.."...p.c..6Uj..j...%r....GO.>r...I.*..u`.......|......K62b..Q..C2Ge@1+..x.:F..#G.S.Q..I.....1l.....C.L.L..c..#x...c..^.F..1"=......Ac.n..N.l.:7...Z..@.g..6...A...]4n..!k.p..B.N.x....H...j5.
+uncompressed= 45000269008000004006ce80c0a80002550d93d740060050c31433dfa11fa3de80183c892b5d00000101080a0005412c10fc3761474554202f382d4269742f456e74657270726973652e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..i....@.......U...@..P..3.......<.+]........A,..7aGET /8-Bit/Enterprise.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 23
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010268008100004006ce80c0a80002550d93d740040050c313600b2189e30280183d0e896b00000101080a000541d810fc379d474554202f382d4269742f436f6d6d6f646f72652e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f3300952f67defcc6ed1d347b7ceeedfb778e5fce235ac8686115ab56ae308cac316b074dd71178eea481b1c3edf0e23472b86563478ef11d3878c0a0d1fc79f519396ee48081c78c1d1835dc5a59c326cd1d314d985871cb530d8edb59b7de81f1844c1c3578c8a841e3154d1cab7b60bc8631a78e9c346cdef81f51c2f29d393d64c8781de3791c3e68ead0b5d3318699a032b01061e85086931d3366b0a95263c654d325ac2e916327b81e3d7a62f49163c64dc9a056b1fcae038348ff38c1ade0e5832424f88e2e61b29131b3c8882a682292f92d038ad9ea36c4c3d431a248433d4c6544019ea46154193662d81831a5e1c38889991c99223ec68c1146f03ed45fc72e1bbc328c3c3962a47a0c1a5671c78983c6ccdd385e9da0d9ea746e1e34f2b5728581248ec9336cf27b3d8326cd1bbb68dcaae943d62ae13420417aad78312350a1448d228523c3aad500 ASCII:E...h....@.......U...@..P..`.!.....=..k........A...7.GET /8-Bit/Commodore.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/3../g.....4{|...w._.#Z.ha..V.0..1k.M..x........4r.ecG...8x....y..9n.......5.ZY.&..1M.Xq.S...Y.....L.5x..A..M..{`..1...4l...Q...9=d.x..y.>h....1...2..a.P...3f..Rc.T.%...c'..=zb..c.M..V.....H.8.....$$...a..1...*h"..-....6...1.HC=LeD...aT.6b..1........">...F.>._....2.<9b.z..Vq......8^....tn.4..r..$..3l.{=.&...h...C.*.4 Az.x1#P.D.".#....
+uncompressed= 45000268008100004006ce80c0a80002550d93d740040050c313600b2189e30280183d0e896b00000101080a000541d810fc379d474554202f382d4269742f436f6d6d6f646f72652e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..h....@.......U...@..P..`.!.....=..k........A...7.GET /8-Bit/Commodore.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 24
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010263008200004006ce84c0a80002550d93d740050050c3138e0daf7b2cf180183962cb2f00000101080a000542b410fc3822474554202f382d4269742f454143412e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b330096dfa4bd83668f4fbb78f5cec97b79440b192da24ead7a1586913561eda0c13a02cf9d343076a4f50d9c468eb46cecc809be03070f1834902b873e23c78d1c30f098b103a3465a2b6bd8a4b923a609132b6979aac1219baad53b309e9089a3060f193568b2a28913750f0cd530e6d4919386cd9bfc234a44be33a7870c19aa63288fc3074d9db77630c63023078e0c2c440c2294e164c78c196caad498e1347489a84be4d8e1ad478f9e187de49871035264542cbaebc020823f0e6f2b73f920e1b81da34a966c64bc2c32a20a1a866474cb801216ba8dee2c758c287250cf511951762739c854868d1836464c39a89021612647a6748f31638491b90aebd789cb66ae0c234f8e18811e8346d4d971e2a03123374e562768ac26759b074dfbaa5761208913f20c1bfa59cfa049f3262e9ab46afa7c8dfa37cdc68d59214aa4a873e7cfa04347468d1a00 ASCII:E...c....@.......U...@..P.....{,...9b./........B...8"GET /8-Bit/EACA.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+3......f.O.x...{yD..-.N.z...5a...:...40v....F..l........4.+.>#...0.....FZ+k...#...+iy..!...;0.......5h....u...0........#JD.3.....c(...M..v0.0#...,D."..d...l....4t..K....G...}..q.RdT,... .?.o+s. ....J.ld.,2....dt.......,u.(rP.Q.Qv'9.T...6FL9..!a&G.t.1c........f..#O.....F..q..1#7NV'h.&u..M..Wa ......Y..I.&...j.|..7...Y!J..s...CGF...
+uncompressed= 45000263008200004006ce84c0a80002550d93d740050050c3138e0daf7b2cf180183962cb2f00000101080a000542b410fc3822474554202f382d4269742f454143412e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..c....@.......U...@..P.....{,...9b./........B...8"GET /8-Bit/EACA.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 25
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010262008500004006ce82c0a80002550d93d740070050c314f5defa37d29b80183c168b6100000101080a000542c810fc37e5474554202f382d4269742f4d53582e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b330095dfa0bd83668fcfba77f3cec16b79440b192da04aa56a1586913560eda0b93a02cf9d343076a0edfd9b460eb46cecc801be03070f18348e277f3e23c78d1c30f098b103a3065a2b6bd8a4b923a609132b6879aac1117b6ad53b309e9089a3060f193568b0a28903750f8cd430e6d4919386cd1bfc234a40be33a7870c19a963248fc3074d1db7762ec63023078e0c2c440a1e94e164c78c196caad498d1147409a84be4d8d9ad478f9e187de49871f33124542cb9ebc020723fce6e2b72f920d9a8fd62ca956c64b82c32a20a9a856472cb8002f6b90dee2b758c2862508f511951742731b854868d1836464c318870e1602647a6708f31638411b908e9d781cb46ae0c234f8e18791e830654d971e2a03113370e562768aa226d9b070d7baa5661208903f20c9bf958cfa049f3062e1ab46afa7885ea378d468d581f469c9853674fa0424542851a00 ASCII:E...b....@.......U...@..P.....7....<..a........B...7.GET /8-Bit/MSX.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+3......f...w...kyD..-.J.j...5`...:...40v....F..l........4.'.>#...0......Z+k...#...+hy...{j.;0.......5h....u...0........#J@.3.....c$...M..v..0#...,D....d...l.....t..K....G...}..q.1$T,... r?.n+r. ...b..ld.,2....dr.......+u.(bP.Q.Qt'1.T...6FL1.p.`&G.p.1c........F..#O..y...T.q..1.7.V'h."m...{.Va ......X..I.....j.x..7.F.X.F..SgO.BEB...
+uncompressed= 45000262008500004006ce82c0a80002550d93d740070050c314f5defa37d29b80183c168b6100000101080a000542c810fc37e5474554202f382d4269742f4d53582e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..b....@.......U...@..P.....7....<..a........B...7.GET /8-Bit/MSX.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 26
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010265009400004006ce70c0a80002550d93d740060050c3143614a11fa986801836e1f43c00000101080a000545b010fc38b7474554202f382d4269742f4d617474656c2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300942dbf512b744fcfbb79f7ced17b79440b192da452b58a1586913562eda0c93a02cf9d343076a8edfd9b460eb56cecc801be03070f18348e277f3e23c78d1c30f098b103a3865a2b6bd8a4b923a609132b6a77aac111bbead53b309e9089a3060f193568b4a28923750f8cd430e6d4919386cd1bfc234a44be33a7870c19a963248fc3074d1db87630c63023078e0c2c440a1e94e164c78c196caad498f1347409a94be4d8d9ad478f9e187de498710352a4542cb9ebc020723fce6e2b74f920e1a81da34a966c64bc2c32a20a1a866472cb8022f6b90dee2c758c2862504f521951742731e854868d1836464c31889021612647a6708f31638411ba08e9d791bbd8c89323469ec7a02195769c3868cc7ca5abd5099aab4bdfe641c3de2a561848e2843cc366bed63368d2bc018a46ad9a3e60a5fe4db371a356881229eae4f97368d19152a50600 ASCII:E...e....@..p....U...@..P..6.......6..<........E...8.GET /8-Bit/Mattel.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtm3..-.Q+tO..y...{yD..-.R.....5b...:...40v....F..l........4.'.>#...0......Z+k...#...+jw......;0.......5h...#u...0........#JD.3.....c$...M..v0.0#...,D....d...l....4t..K....G...}..q.R.T,... r?.n+t. ....J.ld.,2....dr.."....,u.(bPOR.Qt'1.T...6FL1..!a&G.p.1c...........#F...!.v.8h.|......K..A..*V.H..<.f..3h....F..>`..M.q.V..)...sh..R...
+uncompressed= 45000265009400004006ce70c0a80002550d93d740060050c3143614a11fa986801836e1f43c00000101080a000545b010fc38b7474554202f382d4269742f4d617474656c2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..e....@..p....U...@..P..6.......6..<........E...8.GET /8-Bit/Mattel.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 27
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010263009900004006ce6dc0a80002550d93d740040050c313623f2189e66b801839a5739a00000101080a0005464c10fc38f3474554202f382d4269742f4f7269632e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b330095dfa4bd83668f4fc578f5eab13ca2858c1651a756bd0ac3c89ab076d0601d81e74e1a183bd2fa064e23475a3676e404df8183070c1ac895439f91e3460e1878ccd8815123ad95356cd2dc11d3848995b43cd5e0904dd5ea1d184fc8c45183878c1a3459d1c489ba0706631873eac849c3e64dfe112520df99d343860cc63194c7e18326e8768c31ccc88123030b1183086538d93163069b2a356638155d22ea12397678ebd1a327461f3966dc7c0c19158bee3a3088e08fc3db8a5c3e4838dac19872251b192e8b8ca882862119dd32a084856ea3fb4a1d238a1cd483544694dd490e36956123868d11530e2a642898c99129dd63cc186144aec2fa75e0b2912bc3c8932346a0c7a01135769c3868ccc48d93d5091aab4adde641d3beea551848e2803cc3867ed63368d2bc818b26ad9a3e5fa3f64db3716356881229e6d4d91328519151a30600 ASCII:E...c....@..m....U...@..P..b?!..k..9.s.........FL..8.GET /8-Bit/Oric.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+3......f.O.x...<....Q.V......v.`...N..;...N#GZ6v..........C...F..x...Q#..5l........<...M....O..Q....4Y......c.s..I..M..% ...C...1....&.v.1...#.....e8.1c..*5f8.]"..9vx...'F.9f.|.....:0......\>H8...r%........!..2...n..J.#....TF..I.6.a#...S.*d(...).c..aD...u...+...#F....5v.8h........J..A...U.H..<..~.3h....&..>_..M.qcV..)....(Q.Q...
+uncompressed= 45000263009900004006ce6dc0a80002550d93d740040050c313623f2189e66b801839a5739a00000101080a0005464c10fc38f3474554202f382d4269742f4f7269632e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..c....@..m....U...@..P..b?!..k..9.s.........FL..8.GET /8-Bit/Oric.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 28
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010269009e00004006ce62c0a80002550d93d740060050c3143845a11fab60801840003c1c00000101080a000547d810fc38b7474554202f382d4269742f526164696f536861636b2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f330096316be6fcc6ed1d347b7a46f60b584fe7112d64b4b08a552b5718468ad6b183a6eb083c77d2c0d8e17678711a39dcb2b123c7f80e1c3c60d068febcfa8c1c3772c0c063c60e8c1a6e89b24973474c132656dcee5483e376d6ad77603c2113470d1e326ad0784513c7ea1e189361cca923270d9b37fd4794b87c674e0f193226c7781e870f9a3a74ed748c61460e1c195888307428c3c98e1933d854a93163eae9125697c8b1135c8f1e3d31fac831e3a6e449ab587ed78141847f9ce056f0f24112127cc79731d9c8a0596444153411c9fc9601c56c751be263ea1851a4a19ea732a2004fd2b0aa0c1b316c8c98d2f061c4c54c8e4c111f63c60823781fe6af6357685e234f8e18a91e838655dd71e2a03173378e572768b6469d9b074d7cad5c61208963f20c1bfc5ecfa049f3c62e1ab76afa90b55a380d48905e2b5ecc1874e8d1a44b515ab51a00 ASCII:E...i....@..b....U...@..P..8E...`..@.<.........G...8.GET /8-Bit/RadioShack.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/3..1k.....4{zF..XO..-d...U+W.F.......<w....vxq.9...#....<`.h.....7r..c....n..IsGL.&V..T..v..w`<!.G..2j.xE......a..#'..7.G..|gN..2&.x....:t.t.aF...X.0t(....3.T.1c...V....\..=1..1...I.X~..A....V..A..|..1...YdD.4......lu..c..Q....2..O.....1l....a..L.L..c..#x...cWh^#O......U.q..1s7.W'h.F...M|.\a .c....^..I.....j...Z8.H.^+^..t...KQZ...
+uncompressed= 45000269009e00004006ce62c0a80002550d93d740060050c3143845a11fab60801840003c1c00000101080a000547d810fc38b7474554202f382d4269742f526164696f536861636b2e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..i....@..b....U...@..P..8E...`..@.<.........G...8.GET /8-Bit/RadioShack.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 29
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 4500010266009f00004006ce64c0a80002550d93d740050050c313903caf7b2f9580183d5ce4ef00000101080a0005481810fc3934474554202f382d4269742f5068696c6970732e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d3300952fbf597b07cd1e9f8cf5f2d58379440b192da85ac5aa1586913563eda0d93a02cf9d343076acfd1d9c468eb56cecc811be03070f1834922f8f3e23c78d1c30f098b103a3c65a2b41d3dc11d3848995b53cd5e0987d35eb1d184fc8c45183878c1a345cd1c4a1ba0786631873eac8492334ff881292efcce9214386e318cbe3f0415307b19d8b31ccc88123030b1183086538d93163069b2a3566441d5d82ea1239767aebd1a327461f3966dc7c0c4915cbee3a3088e08fd3db0a5d3e483672bf9872251b192e8b8ca882e60d1a32bb6540191bdd86f7953a461439a847a98c28bc931c7c2ac3460c1b23a61c5428f830932353bcc79831c2085d85f5ebc8654357869127478c448f4183eaed3871d098991b87ab133459990ecd83a63d56ad3090c40179860d7dae67d0a4792317cd5a357d8852059c46a346ae0f234ecca9b32750a322a9520d00 ASCII:E...f....@..d....U...@..P...<.{/...=\..........H...94GET /8-Bit/Philips.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtm3../.Y{.........yD..-.Z.....5c...:...40v....F..l........4./.>#...0......Z+A........<...}5...O..Q....4\......c.s..I#4.......!C......AS....1...#.....e8.1c..*5fD.]...9vz...'F.9f.|.I...:0......]>H6r..r%..........2.e@......:F.9.G..(...|*.F..#..T(.0.#S...1..]....eCW..'G.D.A...8q.......4Y.....=V.0...y..}.g..y#..Z5}.R..F.F..#N...'P.".R..
+uncompressed= 45000266009f00004006ce64c0a80002550d93d740050050c313903caf7b2f9580183d5ce4ef00000101080a0005481810fc3934474554202f382d4269742f5068696c6970732e47494620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E..f....@..d....U...@..P...<.{/...=\..........H...94GET /8-Bit/Philips.GIF HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 30
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 450001049b00ae00004006cc20c0a80002550d93d740050050c31396ceaf7b396e801840009ad400000101080a0005611010fc3d6b474554202f382d4269742f6d72776f6e672e67696620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d33009733bf617b07cd9e9f8ef7f6d5a379440b192da85ac5aa1586913564eda0d93a02cf9d343076b00d3e9c460eb66cecc821be03070f183496379f3e23c78d1c30f098b103a3065b2b6b92de11d3848915b63dd5e0a87d35eb1d184fc814c543460d1aae68e250dd0303328c3975e4a461f346ff881294efcce9214306e418cde3f0415347ae1d8c31ccc88123030b1183086538d93163069b2a3566442d5d82ea1239767eebd1a327461f3966dc801449154bef3a3088e48ff3db0a513e48387ac7a892251b192f8b8ca882862199de32a0909d6e033c4b1d238a1cd4a3544614df490e3e956123868d11530e2a644898c99129e063cc186184a8423578ead06563d7c8932346a6c7a04175769c3868ccd48dc3d5099aac4ce3e641f31eab561848e2843cc3a628d73368d2bca18b86ad9a3e62a9fe4db3712357881229eadce933e8d09154a92a417265848c1d307afec489074e198678e6108d31a7e8882557ae4c9111357903abdf7f7b052b96ec4f3868d51e7e1b77ae74198ef7f63d1a76ce52bf50cf4c9d7355b7ddb290634cae7cb9b4dec05f135b76c178c41d347b7e16eeabc732db16325a74cf7a07869135647bff0e3e7c075bdad3732c6f4e7c070e1ed37dcb993e23c78d1c30f07807cfd6ca1a3669ee8869c2c40adb9e6a70a8d60ae30999a278c8e4e78a260ed53d3020c33088900d43ae25204aa46818239f8d6cbc631c3a120b11ff6964a864c9e6e58ca8a54b505d220727579d3b7d06bd48158b52a6f99f72b542940f923a13ed600c39838d8c974546fc6548a63761b2d36d8067a96344913a72f428951105cd9d248a9fcab011c3c688298ad30c444398c99129e063cc18313bce683578eae8b66be4c91123d363246f003b0e1a33d2b93a41939569dc3c68d6df8181248e193967d814e57a064d9a3774d1b055d387cd1caa7fd36cdcc835618f853a63d07473510655aa0100 ASCII:E........@.. ....U...@..P.....{9n..@...........a...=kGET /8-Bit/mrwong.gif HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtm3..3.a{.........yD..-.Z.....5d...:...40v..>.F..l..!.....4.7.>#...0......[+k........=...}5...O...CF...h.P...2.9u..a.F.......!C......ASG...1...#.....e8.1c..*5fD-]...9v~...'F.9f...I.K.:0......Q>H8z...%../.....!..2...n.<K.#....TF..I.>.a#...S.*dH...).c..a..B5x..ec...#F...Auv.8h........L..A...V.H..<..(.3h.......>b..M.q#W..)...3...T.*Are...0z....N..x...1...%W.L..5y....{.+..O8h..~.w.t....=.v.R.P.L.sU....cL.|...._.[v.x..4{~....2..2Zt.z...5d{..>|.[..s,oN|....}..>#...0.x.....6i..i.....jp.......x....&..=0 .0...C.% J.h.#..l.c.:....id.d......KP]".'W.;}..H..R...r.B...:..`.9....EF.eH.7a..m.g.cD.:r.(.....$........)...DC...).c..1;.h5x...k...#.c$o.;..3..:A..i.<h....$..9g...z.M.7t..U.......l..5a..:c.tsQ.U...
+uncompressed= 4500049b00ae00004006cc20c0a80002550d93d740050050c31396ceaf7b396e801840009ad400000101080a0005611010fc3d6b474554202f382d4269742f6d72776f6e672e67696620485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a474554202f382d4269742f7374756d626c6575706f6e2e706e6720485454502f312e310d0a4163636570743a206d756c7469706172742f6d697865642c206170706c69636174696f6e2f766e642e7761702e6d756c7469706172742e6d697865642c206170706c69636174696f6e2f766e642e7761702e7868746d6c2b786d6c2c206170706c69636174696f6e2f7868746d6c2b786d6c2c20746578742f766e642e7761702e776d6c2c202a2f2a0d0a4163636570742d436861727365743a207574662d382c207574662d31362c2069736f2d383835392d312c2069736f2d31303634362d7563732d322c2053686966745f4a49532c20426967350d0a4163636570742d4c616e67756167653a20656e0d0a782d7761702d70726f66696c653a2022687474703a2f2f7761702e736f6e796572696373736f6e2e636f6d2f554170726f662f4b38303069523230312e786d6c220d0a486f73743a207777772e7a6f636b2e636f6d0d0a557365722d4167656e743a20536f6e794572696373736f6e4b383030692f5232422052656c656173652f4d61722d31332d323030372042726f777365722f4e657446726f6e742f332e332050726f66696c652f4d4944502d322e3020436f6e66696775726174696f6e2f434c44432d312e310d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a206465666c6174652c20677a69700d0a526566657265723a20687474703a2f2f7777772e7a6f636b2e636f6d2f0d0a0d0a ASCII:E.......@.. ....U...@..P.....{9n..@...........a...=kGET /8-Bit/mrwong.gif HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....GET /8-Bit/stumbleupon.png HTTP/1.1..Accept: multipart/mixed, application/vnd.wap.multipart.mixed, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/vnd.wap.wml, */*..Accept-Charset: utf-8, utf-16, iso-8859-1, iso-10646-ucs-2, Shift_JIS, Big5..Accept-Language: en..x-wap-profile: "http://wap.sonyericsson.com/UAprof/K800iR201.xml"..Host: www.zock.com..User-Agent: SonyEricssonK800i/R2B Release/Mar-13-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1..Connection: Keep-Alive..Accept-Encoding: deflate, gzip..Referer: http://www.zock.com/....
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 31
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 45000101a0f3d84000400679210a0901abc0a800021f90400538e210f07a827bb1501900ed7be90000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205765642c203301312041756720323031362030393a32383a353220474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a66003f481c9162e40a97294800002068746d6c20506600588a3c6162644409183200002f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d66006f8234f87187cd1d006c653e4469726563746f7279206c697374696e672066016f72202f3c2f7469746c990068bcff2823e70c9fff6b6a943f9f7e7dfbf7f1e7d7bf9f5fb1c2ef6beafcc7d3fd3b7ced646aa34f03a404fa3373a4c64113630efdec27534e7509538d7e32ff657044a8f1bb0c82067f72f71e00 ASCII:E......@.@.y!..........@.8...z.{.P...{...HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Wed, 3.1 Aug 2016 09:28:52 GMT..Content-type: text/html; charset=UTF-8..Content-Length: 222....f.?H..b...)H.. html Pf.X.<abdD..2../W3C//DTD HTML 3.2 Final//EN"><htmf.o.4.q....le>Directory listing f.or /</titl..h..(#....kj.?.~}......._...k.....;|.dj.O....3s..A.c...'SNu.S.~2.epD.......r...
+uncompressed= 450001a0f3d84000400679210a0901abc0a800021f90400538e210f07a827bb1501900ed7be90000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205765642c2033312041756720323031362030393a32383a353220474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a3c21444f43545950452068746d6c205055424c494320222d2f2f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e6720666f72202f3c2f7469746c653e0a3c626f64793e0a3c68323e4469726563746f7279206c697374696e6720666f72202f3c2f68323e0a3c68723e0a3c756c3e0a3c6c693e3c6120687265663d2272656470686f6e652e706e67223e72656470686f6e652e706e673c2f613e0a3c2f756c3e0a3c68723e0a3c2f626f64793e0a3c2f68746d6c3e0a ASCII:E.....@.@.y!..........@.8...z.{.P...{...HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Wed, 31 Aug 2016 09:28:52 GMT..Content-type: text/html; charset=UTF-8..Content-Length: 222....<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>.<title>Directory listing for /</title>.<body>.<h2>Directory listing for /</h2>.<hr>.<ul>.<li><a href="redphone.png">redphone.png</a>.</ul>.<hr>.</body>.</html>.
+
+Testing decompression with sniffed compressed TCP/IP packets:
+Packet No.: 32
+v42bis_decompress_flush() rc=0
+v42bis_decompress() rc=0
+v42bis_decompress_flush() rc=0
+compressed= 45000101a0e9a54000400683540a0901abc0a800021f904004437442f17a4ab3b1501900ed04900000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205765642c203301312041756720323031362030393a32373a353520474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a66003f481c9162e40a97294800002068746d6c20506600588a3c6162644409183200002f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e672066016f72202f3c2f7469746c990068beff2823e70c9f816b6a9847af9ebd7bf8f2e9dbc7af5ff142f06bea0cc4e31d7cfced646aa74f03a444fa3373a4c64113634e7ded28554e7d1953cd7e320365744cb811bc8c82078376ff1e00 ASCII:E......@.@..T..........@.CtB.zJ..P.......HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Wed, 3.1 Aug 2016 09:27:55 GMT..Content-type: text/html; charset=UTF-8..Content-Length: 222....f.?H..b...)H.. html Pf.X.<abdD..2../W3C//DTD HTML 3.2 Final//EN"><html>.<title>Directory listing f.or /</titl..h..(#....kj.G...{......_.B.k.....|..dj.O..D.3s..A.cN}.(UN}.S.~2.etL.......v...
+uncompressed= 450001a0e9a54000400683540a0901abc0a800021f904004437442f17a4ab3b1501900ed04900000485454502f312e3020323030204f4b0d0a5365727665723a2053696d706c65485454502f302e3620507974686f6e2f322e372e360d0a446174653a205765642c2033312041756720323031362030393a32373a353520474d540d0a436f6e74656e742d747970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a436f6e74656e742d4c656e6774683a203232320d0a0d0a3c21444f43545950452068746d6c205055424c494320222d2f2f5733432f2f4454442048544d4c20332e322046696e616c2f2f454e223e3c68746d6c3e0a3c7469746c653e4469726563746f7279206c697374696e6720666f72202f3c2f7469746c653e0a3c626f64793e0a3c68323e4469726563746f7279206c697374696e6720666f72202f3c2f68323e0a3c68723e0a3c756c3e0a3c6c693e3c6120687265663d2272656470686f6e652e706e67223e72656470686f6e652e706e673c2f613e0a3c2f756c3e0a3c68723e0a3c2f626f64793e0a3c2f68746d6c3e0a ASCII:E.....@.@..T..........@.CtB.zJ..P.......HTTP/1.0 200 OK..Server: SimpleHTTP/0.6 Python/2.7.6..Date: Wed, 31 Aug 2016 09:27:55 GMT..Content-type: text/html; charset=UTF-8..Content-Length: 222....<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>.<title>Directory listing for /</title>.<body>.<h2>Directory listing for /</h2>.<hr>.<ul>.<li><a href="redphone.png">redphone.png</a>.</ul>.<hr>.</body>.</html>.
+
+Done
diff --git a/tests/vty_test_runner.py b/tests/vty_test_runner.py
new file mode 100644
index 000000000..92775d5b7
--- /dev/null
+++ b/tests/vty_test_runner.py
@@ -0,0 +1,1401 @@
+#!/usr/bin/env python
+
+# (C) 2013 by Katerina Barone-Adesi <kat.obsc@gmail.com>
+# (C) 2013 by Holger Hans Peter Freyther
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os, sys
+import time
+import unittest
+import socket
+import subprocess
+
+import osmopy.obscvty as obscvty
+import osmopy.osmoutil as osmoutil
+
+# add $top_srcdir/contrib to find ipa.py
+sys.path.append(os.path.join(sys.path[0], '..', 'contrib'))
+
+from ipa import IPA
+
+# to be able to find $top_srcdir/doc/...
+confpath = os.path.join(sys.path[0], '..')
+
+class TestVTYBase(unittest.TestCase):
+
+ def vty_command(self):
+ raise Exception("Needs to be implemented by a subclass")
+
+ def vty_app(self):
+ raise Exception("Needs to be implemented by a subclass")
+
+ def setUp(self):
+ osmo_vty_cmd = self.vty_command()[:]
+ config_index = osmo_vty_cmd.index('-c')
+ if config_index:
+ cfi = config_index + 1
+ osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi])
+
+ try:
+ self.proc = osmoutil.popen_devnull(osmo_vty_cmd)
+ except OSError:
+ print >> sys.stderr, "Current directory: %s" % os.getcwd()
+ print >> sys.stderr, "Consider setting -b"
+
+ appstring = self.vty_app()[2]
+ appport = self.vty_app()[0]
+ self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport)
+
+ def tearDown(self):
+ if self.vty:
+ self.vty._close_socket()
+ self.vty = None
+ osmoutil.end_proc(self.proc)
+
+class TestVTYMGCP(TestVTYBase):
+ def vty_command(self):
+ return ["./src/osmo-bsc_mgcp/osmo-bsc_mgcp", "-c",
+ "doc/examples/osmo-bsc_mgcp/mgcp.cfg"]
+
+ def vty_app(self):
+ return (4243, "./src/osmo-bsc_mgcp/osmo-bsc_mgcp", "OpenBSC MGCP", "mgcp")
+
+ def testForcePtime(self):
+ self.vty.enable()
+ res = self.vty.command("show running-config")
+ self.assert_(res.find(' rtp force-ptime 20\r') > 0)
+ self.assertEquals(res.find(' no rtp force-ptime\r'), -1)
+
+ self.vty.command("configure terminal")
+ self.vty.command("mgcp")
+ self.vty.command("no rtp force-ptime")
+ res = self.vty.command("show running-config")
+ self.assertEquals(res.find(' rtp force-ptime 20\r'), -1)
+ self.assertEquals(res.find(' no rtp force-ptime\r'), -1)
+
+ def testOmitAudio(self):
+ self.vty.enable()
+ res = self.vty.command("show running-config")
+ self.assert_(res.find(' sdp audio-payload send-name\r') > 0)
+ self.assertEquals(res.find(' no sdp audio-payload send-name\r'), -1)
+
+ self.vty.command("configure terminal")
+ self.vty.command("mgcp")
+ self.vty.command("no sdp audio-payload send-name")
+ res = self.vty.command("show running-config")
+ self.assertEquals(res.find(' rtp sdp audio-payload send-name\r'), -1)
+ self.assert_(res.find(' no sdp audio-payload send-name\r') > 0)
+
+ # TODO: test it for the trunk!
+
+ def testBindAddr(self):
+ self.vty.enable()
+
+ self.vty.command("configure terminal")
+ self.vty.command("mgcp")
+
+ # enable.. disable bts-bind-ip
+ self.vty.command("rtp bts-bind-ip 254.253.252.250")
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('rtp bts-bind-ip 254.253.252.250') > 0)
+ self.vty.command("no rtp bts-bind-ip")
+ res = self.vty.command("show running-config")
+ self.assertEquals(res.find(' rtp bts-bind-ip'), -1)
+
+ # enable.. disable net-bind-ip
+ self.vty.command("rtp net-bind-ip 254.253.252.250")
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('rtp net-bind-ip 254.253.252.250') > 0)
+ self.vty.command("no rtp net-bind-ip")
+ res = self.vty.command("show running-config")
+ self.assertEquals(res.find(' rtp net-bind-ip'), -1)
+
+
+class TestVTYGenericBSC(TestVTYBase):
+
+ def checkForEndAndExit(self):
+ res = self.vty.command("list")
+ #print ('looking for "exit"\n')
+ self.assert_(res.find(' exit\r') > 0)
+ #print 'found "exit"\nlooking for "end"\n'
+ self.assert_(res.find(' end\r') > 0)
+ #print 'found "end"\n'
+
+ def _testConfigNetworkTree(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify("configure terminal",['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify("network",['']))
+ self.assertEquals(self.vty.node(), 'config-net')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify("bts 0",['']))
+ self.assertEquals(self.vty.node(), 'config-net-bts')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify("trx 0",['']))
+ self.assertEquals(self.vty.node(), 'config-net-bts-trx')
+ self.checkForEndAndExit()
+ self.vty.command("write terminal")
+ self.assertTrue(self.vty.verify("exit",['']))
+ self.assertEquals(self.vty.node(), 'config-net-bts')
+ self.assertTrue(self.vty.verify("exit",['']))
+ self.assertTrue(self.vty.verify("bts 1",['']))
+ self.assertEquals(self.vty.node(), 'config-net-bts')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify("trx 1",['']))
+ self.assertEquals(self.vty.node(), 'config-net-bts-trx')
+ self.checkForEndAndExit()
+ self.vty.command("write terminal")
+ self.assertTrue(self.vty.verify("exit",['']))
+ self.assertEquals(self.vty.node(), 'config-net-bts')
+ self.assertTrue(self.vty.verify("exit",['']))
+ self.assertEquals(self.vty.node(), 'config-net')
+ self.assertTrue(self.vty.verify("exit",['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify("exit",['']))
+ self.assertTrue(self.vty.node() is None)
+
+class TestVTYNITB(TestVTYGenericBSC):
+
+ def vty_command(self):
+ return ["./src/osmo-nitb/osmo-nitb", "-c",
+ "doc/examples/osmo-nitb/nanobts/openbsc.cfg"]
+
+ def vty_app(self):
+ return (4242, "./src/osmo-nitb/osmo-nitb", "OpenBSC", "nitb")
+
+ def testConfigNetworkTree(self):
+ self._testConfigNetworkTree()
+
+ def checkForSmpp(self):
+ """SMPP is not always enabled, check if it is"""
+ res = self.vty.command("list")
+ return "smpp" in res
+
+ def testSmppFirst(self):
+ # enable the configuration
+ self.vty.enable()
+ self.vty.command("configure terminal")
+
+ if not self.checkForSmpp():
+ return
+
+ self.vty.command("smpp")
+
+ # check the default
+ res = self.vty.command("write terminal")
+ self.assert_(res.find(' no smpp-first') > 0)
+
+ self.vty.verify("smpp-first", [''])
+ res = self.vty.command("write terminal")
+ self.assert_(res.find(' smpp-first') > 0)
+ self.assertEquals(res.find('no smpp-first'), -1)
+
+ self.vty.verify("no smpp-first", [''])
+ res = self.vty.command("write terminal")
+ self.assert_(res.find('no smpp-first') > 0)
+
+ def testVtyTree(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify("configure terminal", ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('mncc-int', ['']))
+ self.assertEquals(self.vty.node(), 'config-mncc-int')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('exit', ['']))
+
+ if self.checkForSmpp():
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify('smpp', ['']))
+ self.assertEquals(self.vty.node(), 'config-smpp')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify("exit", ['']))
+
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify("exit", ['']))
+ self.assertTrue(self.vty.node() is None)
+
+ # Check searching for outer node's commands
+ self.vty.command("configure terminal")
+ self.vty.command('mncc-int')
+
+ if self.checkForSmpp():
+ self.vty.command('smpp')
+ self.assertEquals(self.vty.node(), 'config-smpp')
+ self.vty.command('mncc-int')
+
+ self.assertEquals(self.vty.node(), 'config-mncc-int')
+
+ def testVtyAuthorization(self):
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("network")
+ self.assertTrue(self.vty.verify("auth policy closed", ['']))
+ self.assertTrue(self.vty.verify("auth policy regexp", ['']))
+ self.assertTrue(self.vty.verify("authorized-regexp ^001", ['']))
+ self.assertTrue(self.vty.verify("authorized-regexp 02$", ['']))
+ self.assertTrue(self.vty.verify("authorized-regexp *123.*", ['']))
+ self.vty.command("end")
+ self.vty.command("configure terminal")
+ self.vty.command("nitb")
+ self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
+ self.assertTrue(self.vty.verify("subscriber-create-on-demand no-extension", ['']))
+ self.vty.command("end")
+
+ def testSi2Q(self):
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("network")
+ self.vty.command("bts 0")
+ before = self.vty.command("show running-config")
+ self.vty.command("si2quater neighbor-list add earfcn 1911 threshold 11 2")
+ self.vty.command("si2quater neighbor-list add earfcn 1924 threshold 11 3")
+ self.vty.command("si2quater neighbor-list add earfcn 2111 threshold 11")
+ self.vty.command("si2quater neighbor-list del earfcn 1911")
+ self.vty.command("si2quater neighbor-list del earfcn 1924")
+ self.vty.command("si2quater neighbor-list del earfcn 2111")
+ self.assertEquals(before, self.vty.command("show running-config"))
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 13 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 38 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 44 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 120 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 140 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 163 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 166 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 217 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 224 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 225 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 226 1")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 13")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 38")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 44")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 120")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 140")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 163")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 166")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 217")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 224")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 225")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 226")
+ self.assertEquals(before, self.vty.command("show running-config"))
+
+ def testEnableDisablePeriodicLU(self):
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("network")
+ self.vty.command("bts 0")
+
+ # Test invalid input
+ self.vty.verify("periodic location update 0", ['% Unknown command.'])
+ self.vty.verify("periodic location update 5", ['% Unknown command.'])
+ self.vty.verify("periodic location update 1531", ['% Unknown command.'])
+
+ # Enable periodic lu..
+ self.vty.verify("periodic location update 60", [''])
+ res = self.vty.command("write terminal")
+ self.assert_(res.find('periodic location update 60') > 0)
+ self.assertEquals(res.find('no periodic location update'), -1)
+
+ # Now disable it..
+ self.vty.verify("no periodic location update", [''])
+ res = self.vty.command("write terminal")
+ self.assertEquals(res.find('periodic location update 60'), -1)
+ self.assert_(res.find('no periodic location update') > 0)
+
+ def testEnableDisableSiHacks(self):
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("network")
+ self.vty.command("bts 0")
+
+ # Enable periodic lu..
+ self.vty.verify("force-combined-si", [''])
+ res = self.vty.command("write terminal")
+ self.assert_(res.find(' force-combined-si') > 0)
+ self.assertEquals(res.find('no force-combined-si'), -1)
+
+ # Now disable it..
+ self.vty.verify("no force-combined-si", [''])
+ res = self.vty.command("write terminal")
+ self.assertEquals(res.find(' force-combined-si'), -1)
+ self.assert_(res.find('no force-combined-si') > 0)
+
+ def testRachAccessControlClass(self):
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("network")
+ self.vty.command("bts 0")
+
+ # Test invalid input
+ self.vty.verify("rach access-control-class", ['% Command incomplete.'])
+ self.vty.verify("rach access-control-class 1", ['% Command incomplete.'])
+ self.vty.verify("rach access-control-class -1", ['% Unknown command.'])
+ self.vty.verify("rach access-control-class 10", ['% Unknown command.'])
+ self.vty.verify("rach access-control-class 16", ['% Unknown command.'])
+
+ # Barred rach access control classes
+ for classNum in range(16):
+ if classNum != 10:
+ self.vty.verify("rach access-control-class " + str(classNum) + " barred", [''])
+
+ # Verify settings
+ res = self.vty.command("write terminal")
+ for classNum in range(16):
+ if classNum != 10:
+ self.assert_(res.find("rach access-control-class " + str(classNum) + " barred") > 0)
+
+ # Allowed rach access control classes
+ for classNum in range(16):
+ if classNum != 10:
+ self.vty.verify("rach access-control-class " + str(classNum) + " allowed", [''])
+
+ # Verify settings
+ res = self.vty.command("write terminal")
+ for classNum in range(16):
+ if classNum != 10:
+ self.assertEquals(res.find("rach access-control-class " + str(classNum) + " barred"), -1)
+
+ def testSubscriberCreateDeleteTwice(self):
+ """
+ OS#1657 indicates that there might be an issue creating the
+ same subscriber twice. This test will use the VTY command to
+ create a subscriber and then issue a second create command
+ with the same IMSI. The test passes if the VTY continues to
+ respond to VTY commands.
+ """
+ self.vty.enable()
+
+ imsi = "204300854013739"
+
+ # Initially we don't have this subscriber
+ self.vty.verify('show subscriber imsi '+imsi, ['% No subscriber found for imsi '+imsi])
+
+ # Lets create one
+ res = self.vty.command('subscriber create imsi '+imsi)
+ self.assert_(res.find(" IMSI: "+imsi) > 0)
+ # And now create one again.
+ res2 = self.vty.command('subscriber create imsi '+imsi)
+ self.assert_(res2.find(" IMSI: "+imsi) > 0)
+ self.assertEqual(res, res2)
+
+ # Verify it has been created
+ res = self.vty.command('show subscriber imsi '+imsi)
+ self.assert_(res.find(" IMSI: "+imsi) > 0)
+
+ # Delete it
+ res = self.vty.command('subscriber imsi ' + imsi + ' delete')
+ self.assert_("" == res)
+
+ # Now it should not be there anymore
+ res = self.vty.command('show subscriber imsi '+imsi)
+ self.assert_(('% No subscriber found for imsi ' + imsi) == res)
+
+
+ def testSubscriberCreateDelete(self):
+ self.vty.enable()
+
+ imsi = "204300854013739"
+ imsi2 = "222301824913762"
+ imsi3 = "333500854113763"
+ imsi4 = "444583744053764"
+
+ # Initially we don't have this subscriber
+ self.vty.verify('show subscriber imsi '+imsi, ['% No subscriber found for imsi '+imsi])
+
+ # Lets create one
+ res = self.vty.command('subscriber create imsi '+imsi)
+ self.assert_(res.find(" IMSI: "+imsi) > 0)
+ self.assert_(res.find("Extension") > 0)
+
+ # Now we have it
+ res = self.vty.command('show subscriber imsi '+imsi)
+ self.assert_(res.find(" IMSI: "+imsi) > 0)
+
+ # With narrow random interval
+ self.vty.command("configure terminal")
+ self.vty.command("nitb")
+ self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
+ # wrong interval
+ res = self.vty.command("subscriber-create-on-demand random 221 122")
+ # error string will contain arguments
+ self.assert_(res.find("122") > 0)
+ self.assert_(res.find("221") > 0)
+ # correct interval - silent ok
+ self.assertTrue(self.vty.verify("subscriber-create-on-demand random 221 222", ['']))
+ self.vty.command("end")
+
+ res = self.vty.command('subscriber create imsi ' + imsi2)
+ self.assert_(res.find(" IMSI: " + imsi2) > 0)
+ self.assert_(res.find("221") > 0 or res.find("222") > 0)
+ self.assert_(res.find(" Extension: ") > 0)
+
+ # Without extension
+ self.vty.command("configure terminal")
+ self.vty.command("nitb")
+ self.assertTrue(self.vty.verify("subscriber-create-on-demand no-extension", ['']))
+ self.vty.command("end")
+ res = self.vty.command('subscriber create imsi ' + imsi3)
+ self.assert_(res.find(" IMSI: " + imsi3) > 0)
+ self.assertEquals(res.find("Extension"), -1)
+
+ # With extension again
+ self.vty.command("configure terminal")
+ self.vty.command("nitb")
+ self.assertTrue(self.vty.verify("no subscriber-create-on-demand", ['']))
+ self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
+ self.assertTrue(self.vty.verify("subscriber-create-on-demand random 221 666", ['']))
+ self.vty.command("end")
+
+ res = self.vty.command('subscriber create imsi ' + imsi4)
+ self.assert_(res.find(" IMSI: " + imsi4) > 0)
+ self.assert_(res.find(" Extension: ") > 0)
+
+ # Delete it
+ res = self.vty.command('subscriber imsi ' + imsi + ' delete')
+ self.assert_("" == res)
+ res = self.vty.command('subscriber imsi ' + imsi2 + ' delete')
+ self.assert_("" == res)
+ res = self.vty.command('subscriber imsi ' + imsi3 + ' delete')
+ self.assert_("" == res)
+ res = self.vty.command('subscriber imsi ' + imsi4 + ' delete')
+ self.assert_("" == res)
+
+ # Now it should not be there anymore
+ res = self.vty.command('show subscriber imsi '+imsi)
+ self.assert_(('% No subscriber found for imsi ' + imsi) == res)
+
+ # range
+ self.vty.command("end")
+ self.vty.command("configure terminal")
+ self.vty.command("nitb")
+ self.assertTrue(self.vty.verify("subscriber-create-on-demand random 9999999998 9999999999", ['']))
+ res = self.vty.command("show running-config")
+ self.assert_(res.find("subscriber-create-on-demand random 9999999998 9999999999"))
+ self.vty.command("end")
+
+ res = self.vty.command('subscriber create imsi ' + imsi)
+ print(res)
+ self.assert_(res.find(" IMSI: " + imsi) > 0)
+ self.assert_(res.find("9999999998") > 0 or res.find("9999999999") > 0)
+ self.assert_(res.find(" Extension: ") > 0)
+
+ res = self.vty.command('subscriber imsi ' + imsi + ' delete')
+ self.assert_("" == res)
+
+ res = self.vty.command('show subscriber imsi '+imsi)
+ self.assert_(('% No subscriber found for imsi ' + imsi) == res)
+
+
+ def testSubscriberSettings(self):
+ self.vty.enable()
+
+ imsi = "204300854013739"
+ imsi2 = "204301824913769"
+ wrong_imsi = "204300999999999"
+
+ # Lets create one
+ res = self.vty.command('subscriber create imsi '+imsi)
+ self.assert_(res.find(" IMSI: "+imsi) > 0)
+ self.assert_(res.find("Extension") > 0)
+
+ self.vty.verify('subscriber imsi '+wrong_imsi+' name wrong', ['% No subscriber found for imsi '+wrong_imsi])
+ res = self.vty.command('subscriber imsi '+imsi+' name '+('X' * 160))
+ self.assert_(res.find("NAME is too long") > 0)
+
+ self.vty.verify('subscriber imsi '+imsi+' name '+('G' * 159), [''])
+
+ self.vty.verify('subscriber imsi '+wrong_imsi+' extension 840', ['% No subscriber found for imsi '+wrong_imsi])
+ res = self.vty.command('subscriber imsi '+imsi+' extension '+('9' * 15))
+ self.assert_(res.find("EXTENSION is too long") > 0)
+
+ self.vty.verify('subscriber imsi '+imsi+' extension '+('1' * 14), [''])
+
+ # With narrow random interval
+ self.vty.command("configure terminal")
+ self.vty.command("nitb")
+ self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
+ # wrong interval
+ res = self.vty.command("subscriber-create-on-demand random 221 122")
+ self.assert_(res.find("122") > 0)
+ self.assert_(res.find("221") > 0)
+ # correct interval
+ self.assertTrue(self.vty.verify("subscriber-create-on-demand random 221 222", ['']))
+ self.vty.command("end")
+
+ # create subscriber with extension in a configured interval
+ res = self.vty.command('subscriber create imsi ' + imsi2)
+ self.assert_(res.find(" IMSI: " + imsi2) > 0)
+ self.assert_(res.find("221") > 0 or res.find("222") > 0)
+ self.assert_(res.find(" Extension: ") > 0)
+
+ # Delete it
+ res = self.vty.command('subscriber imsi ' + imsi + ' delete')
+ self.assert_(res != "")
+ # imsi2 is inactive so deletion should succeed
+ res = self.vty.command('subscriber imsi ' + imsi2 + ' delete')
+ self.assert_("" == res)
+
+ def testShowPagingGroup(self):
+ res = self.vty.command("show paging-group 255 1234567")
+ self.assertEqual(res, "% can't find BTS 255")
+ res = self.vty.command("show paging-group 0 1234567")
+ self.assertEquals(res, "%Paging group for IMSI 1234567 on BTS #0 is 7")
+
+ def testShowNetwork(self):
+ res = self.vty.command("show network")
+ self.assert_(res.startswith('BSC is on Country Code') >= 0)
+
+ def testMeasurementFeed(self):
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("mncc-int")
+
+ res = self.vty.command("write terminal")
+ self.assertEquals(res.find('meas-feed scenario'), -1)
+
+ self.vty.command("meas-feed scenario bla")
+ res = self.vty.command("write terminal")
+ self.assert_(res.find('meas-feed scenario bla') > 0)
+
+ self.vty.command("meas-feed scenario abcdefghijklmnopqrstuvwxyz01234567890")
+ res = self.vty.command("write terminal")
+ self.assertEquals(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz01234567890'), -1)
+ self.assertEquals(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz012345'), -1)
+ self.assert_(res.find('meas-feed scenario abcdefghijklmnopqrstuvwxyz01234') > 0)
+
+
+class TestVTYBSC(TestVTYGenericBSC):
+
+ def vty_command(self):
+ return ["./src/osmo-bsc/osmo-bsc", "-c",
+ "doc/examples/osmo-bsc/osmo-bsc.cfg"]
+
+ def vty_app(self):
+ return (4242, "./src/osmo-bsc/osmo-bsc", "OsmoBSC", "bsc")
+
+ def testConfigNetworkTree(self):
+ self._testConfigNetworkTree()
+
+ def testVtyTree(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify("configure terminal", ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify("msc 0", ['']))
+ self.assertEquals(self.vty.node(), 'config-msc')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify("exit", ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify("bsc", ['']))
+ self.assertEquals(self.vty.node(), 'config-bsc')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify("exit", ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify("exit", ['']))
+ self.assertTrue(self.vty.node() is None)
+
+ # Check searching for outer node's commands
+ self.vty.command("configure terminal")
+ self.vty.command('msc 0')
+ self.vty.command("bsc")
+ self.assertEquals(self.vty.node(), 'config-bsc')
+ self.vty.command("msc 0")
+ self.assertEquals(self.vty.node(), 'config-msc')
+
+ def testUssdNotificationsMsc(self):
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("msc")
+
+ # Test invalid input
+ self.vty.verify("bsc-msc-lost-text", ['% Command incomplete.'])
+ self.vty.verify("bsc-welcome-text", ['% Command incomplete.'])
+ self.vty.verify("bsc-grace-text", ['% Command incomplete.'])
+
+ # Enable USSD notifications
+ self.vty.verify("bsc-msc-lost-text MSC disconnected", [''])
+ self.vty.verify("bsc-welcome-text Hello MS", [''])
+ self.vty.verify("bsc-grace-text In grace period", [''])
+
+ # Verify settings
+ res = self.vty.command("write terminal")
+ self.assert_(res.find('bsc-msc-lost-text MSC disconnected') > 0)
+ self.assertEquals(res.find('no bsc-msc-lost-text'), -1)
+ self.assert_(res.find('bsc-welcome-text Hello MS') > 0)
+ self.assertEquals(res.find('no bsc-welcome-text'), -1)
+ self.assert_(res.find('bsc-grace-text In grace period') > 0)
+ self.assertEquals(res.find('no bsc-grace-text'), -1)
+
+ # Now disable it..
+ self.vty.verify("no bsc-msc-lost-text", [''])
+ self.vty.verify("no bsc-welcome-text", [''])
+ self.vty.verify("no bsc-grace-text", [''])
+
+ # Verify settings
+ res = self.vty.command("write terminal")
+ self.assertEquals(res.find('bsc-msc-lost-text MSC disconnected'), -1)
+ self.assert_(res.find('no bsc-msc-lost-text') > 0)
+ self.assertEquals(res.find('bsc-welcome-text Hello MS'), -1)
+ self.assert_(res.find('no bsc-welcome-text') > 0)
+ self.assertEquals(res.find('bsc-grace-text In grace period'), -1)
+ self.assert_(res.find('no bsc-grace-text') > 0)
+
+ def testUssdNotificationsBsc(self):
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("bsc")
+
+ # Test invalid input
+ self.vty.verify("missing-msc-text", ['% Command incomplete.'])
+
+ # Enable USSD notifications
+ self.vty.verify("missing-msc-text No MSC found", [''])
+
+ # Verify settings
+ res = self.vty.command("write terminal")
+ self.assert_(res.find('missing-msc-text No MSC found') > 0)
+ self.assertEquals(res.find('no missing-msc-text'), -1)
+
+ # Now disable it..
+ self.vty.verify("no missing-msc-text", [''])
+
+ # Verify settings
+ res = self.vty.command("write terminal")
+ self.assertEquals(res.find('missing-msc-text No MSC found'), -1)
+ self.assert_(res.find('no missing-msc-text') > 0)
+
+ def testNetworkTimezone(self):
+ self.vty.enable()
+ self.vty.verify("configure terminal", [''])
+ self.vty.verify("network", [''])
+
+ # Test invalid input
+ self.vty.verify("timezone", ['% Command incomplete.'])
+ self.vty.verify("timezone 20 0", ['% Unknown command.'])
+ self.vty.verify("timezone 0 11", ['% Unknown command.'])
+ self.vty.verify("timezone 0 0 99", ['% Unknown command.'])
+
+ # Set time zone without DST
+ self.vty.verify("timezone 2 30", [''])
+
+ # Verify settings
+ res = self.vty.command("write terminal")
+ self.assert_(res.find('timezone 2 30') > 0)
+ self.assertEquals(res.find('timezone 2 30 '), -1)
+
+ # Set time zone with DST
+ self.vty.verify("timezone 2 30 1", [''])
+
+ # Verify settings
+ res = self.vty.command("write terminal")
+ self.assert_(res.find('timezone 2 30 1') > 0)
+
+ # Now disable it..
+ self.vty.verify("no timezone", [''])
+
+ # Verify settings
+ res = self.vty.command("write terminal")
+ self.assertEquals(res.find(' timezone'), -1)
+
+ def testShowNetwork(self):
+ res = self.vty.command("show network")
+ self.assert_(res.startswith('BSC is on Country Code') >= 0)
+
+ def testPingPongConfiguration(self):
+ self.vty.enable()
+ self.vty.verify("configure terminal", [''])
+ self.vty.verify("network", [''])
+ self.vty.verify("msc 0", [''])
+
+ self.vty.verify("timeout-ping 12", [''])
+ self.vty.verify("timeout-pong 14", [''])
+ res = self.vty.command("show running-config")
+ self.assert_(res.find(" timeout-ping 12") > 0)
+ self.assert_(res.find(" timeout-pong 14") > 0)
+ self.assert_(res.find(" no timeout-ping advanced") > 0)
+
+ self.vty.verify("timeout-ping advanced", [''])
+ res = self.vty.command("show running-config")
+ self.assert_(res.find(" timeout-ping 12") > 0)
+ self.assert_(res.find(" timeout-pong 14") > 0)
+ self.assert_(res.find(" timeout-ping advanced") > 0)
+
+ self.vty.verify("no timeout-ping advanced", [''])
+ res = self.vty.command("show running-config")
+ self.assert_(res.find(" timeout-ping 12") > 0)
+ self.assert_(res.find(" timeout-pong 14") > 0)
+ self.assert_(res.find(" no timeout-ping advanced") > 0)
+
+ self.vty.verify("no timeout-ping", [''])
+ res = self.vty.command("show running-config")
+ self.assertEquals(res.find(" timeout-ping 12"), -1)
+ self.assertEquals(res.find(" timeout-pong 14"), -1)
+ self.assertEquals(res.find(" no timeout-ping advanced"), -1)
+ self.assert_(res.find(" no timeout-ping") > 0)
+
+ self.vty.verify("timeout-ping advanced", ['%ping handling is disabled. Enable it first.'])
+
+ # And back to enabling it
+ self.vty.verify("timeout-ping 12", [''])
+ self.vty.verify("timeout-pong 14", [''])
+ res = self.vty.command("show running-config")
+ self.assert_(res.find(" timeout-ping 12") > 0)
+ self.assert_(res.find(" timeout-pong 14") > 0)
+ self.assert_(res.find(" timeout-ping advanced") > 0)
+
+ def testMscDataCoreLACCI(self):
+ self.vty.enable()
+ res = self.vty.command("show running-config")
+ self.assertEquals(res.find("core-location-area-code"), -1)
+ self.assertEquals(res.find("core-cell-identity"), -1)
+
+ self.vty.command("configure terminal")
+ self.vty.command("msc 0")
+ self.vty.command("core-location-area-code 666")
+ self.vty.command("core-cell-identity 333")
+
+ res = self.vty.command("show running-config")
+ self.assert_(res.find("core-location-area-code 666") > 0)
+ self.assert_(res.find("core-cell-identity 333") > 0)
+
+class TestVTYNAT(TestVTYGenericBSC):
+
+ def vty_command(self):
+ return ["./src/osmo-bsc_nat/osmo-bsc_nat", "-l", "127.0.0.1", "-c",
+ "doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg"]
+
+ def vty_app(self):
+ return (4244, "src/osmo-bsc_nat/osmo-bsc_nat", "OsmoBSCNAT", "nat")
+
+ def testBSCreload(self):
+ # Use different port for the mock msc to avoid clashing with
+ # the osmo-bsc_nat itself
+ ip = "127.0.0.1"
+ port = 5522
+ self.vty.enable()
+ bscs1 = self.vty.command("show bscs-config")
+ nat_bsc_reload(self)
+ bscs2 = self.vty.command("show bscs-config")
+ # check that multiple calls to bscs-config-file give the same result
+ self.assertEquals(bscs1, bscs2)
+
+ # add new bsc
+ self.vty.command("configure terminal")
+ self.vty.command("nat")
+ self.vty.command("bsc 5")
+ self.vty.command("token key")
+ self.vty.command("location_area_code 666")
+ self.vty.command("end")
+
+ # update bsc token
+ self.vty.command("configure terminal")
+ self.vty.command("nat")
+ self.vty.command("bsc 1")
+ self.vty.command("token xyu")
+ self.vty.command("end")
+
+ nat_msc_ip(self, ip, port)
+ msc_socket, msc = nat_msc_test(self, ip, port, verbose=True)
+ try:
+ b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc)
+ b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc)
+ b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc)
+
+ self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured"))
+ self.assertTrue(3 == nat_bsc_num_con(self))
+ self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
+
+ nat_bsc_reload(self)
+ bscs2 = self.vty.command("show bscs-config")
+ # check that the reset to initial config succeeded
+ self.assertEquals(bscs1, bscs2)
+
+ self.assertEquals("2 BSCs configured", self.vty.command("show nat num-bscs-configured"))
+ self.assertTrue(1 == nat_bsc_num_con(self))
+ rem = self.vty.command("show bsc connections").split(' ')
+ # remaining connection is for BSC0
+ self.assertEquals('0', rem[2])
+ # remaining connection is authorized
+ self.assertEquals('1', rem[4])
+ self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection"))
+ finally:
+ msc.close()
+ msc_socket.close()
+
+ def testVtyTree(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify('configure terminal', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('mgcp', ['']))
+ self.assertEquals(self.vty.node(), 'config-mgcp')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('exit', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify('nat', ['']))
+ self.assertEquals(self.vty.node(), 'config-nat')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('bsc 0', ['']))
+ self.assertEquals(self.vty.node(), 'config-nat-bsc')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('exit', ['']))
+ self.assertEquals(self.vty.node(), 'config-nat')
+ self.assertTrue(self.vty.verify('exit', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify('exit', ['']))
+ self.assertTrue(self.vty.node() is None)
+
+ # Check searching for outer node's commands
+ self.vty.command('configure terminal')
+ self.vty.command('mgcp')
+ self.vty.command('nat')
+ self.assertEquals(self.vty.node(), 'config-nat')
+ self.vty.command('mgcp')
+ self.assertEquals(self.vty.node(), 'config-mgcp')
+ self.vty.command('nat')
+ self.assertEquals(self.vty.node(), 'config-nat')
+ self.vty.command('bsc 0')
+ self.vty.command('mgcp')
+ self.assertEquals(self.vty.node(), 'config-mgcp')
+
+ def testRewriteNoRewrite(self):
+ self.vty.enable()
+ res = self.vty.command("configure terminal")
+ res = self.vty.command("nat")
+ res = self.vty.command("number-rewrite rewrite.cfg")
+ res = self.vty.command("no number-rewrite")
+
+ def testEnsureNoEnsureModeSet(self):
+ self.vty.enable()
+ res = self.vty.command("configure terminal")
+ res = self.vty.command("nat")
+
+ # Ensure the default
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('\n sdp-ensure-amr-mode-set') > 0)
+
+ self.vty.command("sdp-ensure-amr-mode-set")
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('\n sdp-ensure-amr-mode-set') > 0)
+
+ self.vty.command("no sdp-ensure-amr-mode-set")
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('\n no sdp-ensure-amr-mode-set') > 0)
+
+ def testRewritePostNoRewrite(self):
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("nat")
+ self.vty.verify("number-rewrite-post rewrite.cfg", [''])
+ self.vty.verify("no number-rewrite-post", [''])
+
+
+ def testPrefixTreeLoading(self):
+ cfg = os.path.join(confpath, "tests/bsc-nat-trie/prefixes.csv")
+
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("nat")
+ res = self.vty.command("prefix-tree %s" % cfg)
+ self.assertEqual(res, "% prefix-tree loaded 17 rules.")
+ self.vty.command("end")
+
+ res = self.vty.command("show prefix-tree")
+ self.assertEqual(res, '1,1\r\n12,2\r\n123,3\r\n1234,4\r\n12345,5\r\n123456,6\r\n1234567,7\r\n12345678,8\r\n123456789,9\r\n1234567890,10\r\n13,11\r\n14,12\r\n15,13\r\n16,14\r\n82,16\r\n823455,15\r\n+49123,17')
+
+ self.vty.command("configure terminal")
+ self.vty.command("nat")
+ self.vty.command("no prefix-tree")
+ self.vty.command("end")
+
+ res = self.vty.command("show prefix-tree")
+ self.assertEqual(res, "% there is now prefix tree loaded.")
+
+ def testUssdSideChannelProvider(self):
+ self.vty.command("end")
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("nat")
+ self.vty.command("ussd-token key")
+ self.vty.command("end")
+
+ res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is not connected and not authorized.'])
+ self.assertTrue(res)
+
+ ussdSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ ussdSocket.connect(('127.0.0.1', 5001))
+ ussdSocket.settimeout(2.0)
+ print "Connected to %s:%d" % ussdSocket.getpeername()
+
+ print "Expecting ID_GET request"
+ data = ussdSocket.recv(4)
+ self.assertEqual(data, "\x00\x01\xfe\x04")
+
+ print "Going to send ID_RESP response"
+ res = ussdSocket.send(IPA().id_resp(IPA().tag_name('key')))
+ self.assertEqual(res, 10)
+
+ # initiating PING/PONG cycle to know, that the ID_RESP message has been processed
+
+ print "Going to send PING request"
+ res = ussdSocket.send(IPA().ping())
+ self.assertEqual(res, 4)
+
+ print "Expecting PONG response"
+ data = ussdSocket.recv(4)
+ self.assertEqual(data, "\x00\x01\xfe\x01")
+
+ res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is connected and authorized.'])
+ self.assertTrue(res)
+
+ print "Going to shut down connection"
+ ussdSocket.shutdown(socket.SHUT_WR)
+
+ print "Expecting EOF"
+ data = ussdSocket.recv(4)
+ self.assertEqual(data, "")
+
+ ussdSocket.close()
+
+ res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is not connected and not authorized.'])
+ self.assertTrue(res)
+
+ def testAccessList(self):
+ """
+ Verify that the imsi-deny can have a reject cause or no reject cause
+ """
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("nat")
+
+ # Old default
+ self.vty.command("access-list test-default imsi-deny ^123[0-9]*$")
+ res = self.vty.command("show running-config").split("\r\n")
+ asserted = False
+ for line in res:
+ if line.startswith(" access-list test-default"):
+ self.assertEqual(line, " access-list test-default imsi-deny ^123[0-9]*$ 11 11")
+ asserted = True
+ self.assert_(asserted)
+
+ # Check the optional CM Service Reject Cause
+ self.vty.command("access-list test-cm-deny imsi-deny ^123[0-9]*$ 42").split("\r\n")
+ res = self.vty.command("show running-config").split("\r\n")
+ asserted = False
+ for line in res:
+ if line.startswith(" access-list test-cm"):
+ self.assertEqual(line, " access-list test-cm-deny imsi-deny ^123[0-9]*$ 42 11")
+ asserted = True
+ self.assert_(asserted)
+
+ # Check the optional LU Reject Cause
+ self.vty.command("access-list test-lu-deny imsi-deny ^123[0-9]*$ 23 42").split("\r\n")
+ res = self.vty.command("show running-config").split("\r\n")
+ asserted = False
+ for line in res:
+ if line.startswith(" access-list test-lu"):
+ self.assertEqual(line, " access-list test-lu-deny imsi-deny ^123[0-9]*$ 23 42")
+ asserted = True
+ self.assert_(asserted)
+
+class TestVTYGbproxy(TestVTYGenericBSC):
+
+ def vty_command(self):
+ return ["./src/gprs/osmo-gbproxy", "-c",
+ "doc/examples/osmo-gbproxy/osmo-gbproxy.cfg"]
+
+ def vty_app(self):
+ return (4246, "./src/gprs/osmo-gbproxy", "OsmoGbProxy", "bsc")
+
+ def testVtyTree(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify('configure terminal', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('ns', ['']))
+ self.assertEquals(self.vty.node(), 'config-ns')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('exit', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify('gbproxy', ['']))
+ self.assertEquals(self.vty.node(), 'config-gbproxy')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('exit', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+
+ def testVtyShow(self):
+ res = self.vty.command("show ns")
+ self.assert_(res.find('Encapsulation NS-UDP-IP') >= 0)
+
+ res = self.vty.command("show gbproxy stats")
+ self.assert_(res.find('GBProxy Global Statistics') >= 0)
+
+ def testVtyDeletePeer(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify('delete-gbproxy-peer 9999 bvci 7777', ['BVC not found']))
+ res = self.vty.command("delete-gbproxy-peer 9999 all dry-run")
+ self.assert_(res.find('Not Deleted 0 BVC') >= 0)
+ self.assert_(res.find('Not Deleted 0 NS-VC') >= 0)
+ res = self.vty.command("delete-gbproxy-peer 9999 only-bvc dry-run")
+ self.assert_(res.find('Not Deleted 0 BVC') >= 0)
+ self.assert_(res.find('Not Deleted 0 NS-VC') < 0)
+ res = self.vty.command("delete-gbproxy-peer 9999 only-nsvc dry-run")
+ self.assert_(res.find('Not Deleted 0 BVC') < 0)
+ self.assert_(res.find('Not Deleted 0 NS-VC') >= 0)
+ res = self.vty.command("delete-gbproxy-peer 9999 all")
+ self.assert_(res.find('Deleted 0 BVC') >= 0)
+ self.assert_(res.find('Deleted 0 NS-VC') >= 0)
+
+class TestVTYSGSN(TestVTYGenericBSC):
+
+ def vty_command(self):
+ return ["./src/gprs/osmo-sgsn", "-c",
+ "doc/examples/osmo-sgsn/osmo-sgsn.cfg"]
+
+ def vty_app(self):
+ return (4245, "./src/gprs/osmo-sgsn", "OsmoSGSN", "sgsn")
+
+ def testVtyTree(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify('configure terminal', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('ns', ['']))
+ self.assertEquals(self.vty.node(), 'config-ns')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('exit', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify('sgsn', ['']))
+ self.assertEquals(self.vty.node(), 'config-sgsn')
+ self.checkForEndAndExit()
+ self.assertTrue(self.vty.verify('exit', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+
+ def testVtyShow(self):
+ res = self.vty.command("show ns")
+ self.assert_(res.find('Encapsulation NS-UDP-IP') >= 0)
+ self.assertTrue(self.vty.verify('show bssgp', ['']))
+ self.assertTrue(self.vty.verify('show bssgp stats', ['']))
+ # TODO: uncomment when the command does not segfault anymore
+ # self.assertTrue(self.vty.verify('show bssgp nsei 123', ['']))
+ # self.assertTrue(self.vty.verify('show bssgp nsei 123 stats', ['']))
+
+ self.assertTrue(self.vty.verify('show sgsn', ['']))
+ self.assertTrue(self.vty.verify('show mm-context all', ['']))
+ self.assertTrue(self.vty.verify('show mm-context imsi 000001234567', ['No MM context for IMSI 000001234567']))
+ self.assertTrue(self.vty.verify('show pdp-context all', ['']))
+
+ res = self.vty.command("show sndcp")
+ self.assert_(res.find('State of SNDCP Entities') >= 0)
+
+ res = self.vty.command("show llc")
+ self.assert_(res.find('State of LLC Entities') >= 0)
+
+ def testVtyAuth(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify('configure terminal', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify('sgsn', ['']))
+ self.assertEquals(self.vty.node(), 'config-sgsn')
+ self.assertTrue(self.vty.verify('auth-policy accept-all', ['']))
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('auth-policy accept-all') > 0)
+ self.assertTrue(self.vty.verify('auth-policy acl-only', ['']))
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('auth-policy acl-only') > 0)
+ self.assertTrue(self.vty.verify('auth-policy closed', ['']))
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('auth-policy closed') > 0)
+ self.assertTrue(self.vty.verify('gsup remote-ip 127.0.0.4', ['']))
+ self.assertTrue(self.vty.verify('gsup remote-port 2222', ['']))
+ self.assertTrue(self.vty.verify('auth-policy remote', ['']))
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('auth-policy remote') > 0)
+
+ def testVtySubscriber(self):
+ self.vty.enable()
+ res = self.vty.command('show subscriber cache')
+ self.assert_(res.find('1234567890') < 0)
+ self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 create', ['']))
+ res = self.vty.command('show subscriber cache')
+ self.assert_(res.find('1234567890') >= 0)
+ self.assert_(res.find('Authorized: 0') >= 0)
+ self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 update-location-result ok', ['']))
+ res = self.vty.command('show subscriber cache')
+ self.assert_(res.find('1234567890') >= 0)
+ self.assert_(res.find('Authorized: 1') >= 0)
+ self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 cancel update-procedure', ['']))
+ res = self.vty.command('show subscriber cache')
+ self.assert_(res.find('1234567890') >= 0)
+ self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 destroy', ['']))
+ res = self.vty.command('show subscriber cache')
+ self.assert_(res.find('1234567890') < 0)
+
+ def testVtyGgsn(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify('configure terminal', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify('sgsn', ['']))
+ self.assertEquals(self.vty.node(), 'config-sgsn')
+ self.assertTrue(self.vty.verify('ggsn 0 remote-ip 127.99.99.99', ['']))
+ self.assertTrue(self.vty.verify('ggsn 0 gtp-version 1', ['']))
+ self.assertTrue(self.vty.verify('apn * ggsn 0', ['']))
+ self.assertTrue(self.vty.verify('apn apn1.test ggsn 0', ['']))
+ self.assertTrue(self.vty.verify('apn apn1.test ggsn 1', ['% a GGSN with id 1 has not been defined']))
+ self.assertTrue(self.vty.verify('apn apn1.test imsi-prefix 123456 ggsn 0', ['']))
+ self.assertTrue(self.vty.verify('apn apn2.test imsi-prefix 123456 ggsn 0', ['']))
+ res = self.vty.command("show running-config")
+ self.assert_(res.find('ggsn 0 remote-ip 127.99.99.99') >= 0)
+ self.assert_(res.find('ggsn 0 gtp-version 1') >= 0)
+ self.assert_(res.find('apn * ggsn 0') >= 0)
+ self.assert_(res.find('apn apn1.test ggsn 0') >= 0)
+ self.assert_(res.find('apn apn1.test imsi-prefix 123456 ggsn 0') >= 0)
+ self.assert_(res.find('apn apn2.test imsi-prefix 123456 ggsn 0') >= 0)
+
+ def testVtyEasyAPN(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify('configure terminal', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify('sgsn', ['']))
+ self.assertEquals(self.vty.node(), 'config-sgsn')
+
+ res = self.vty.command("show running-config")
+ self.assertEquals(res.find("apn internet"), -1)
+
+ self.assertTrue(self.vty.verify("access-point-name internet.apn", ['']))
+ res = self.vty.command("show running-config")
+ self.assert_(res.find("apn internet.apn ggsn 0") >= 0)
+
+ self.assertTrue(self.vty.verify("no access-point-name internet.apn", ['']))
+ res = self.vty.command("show running-config")
+ self.assertEquals(res.find("apn internet"), -1)
+
+ def testVtyCDR(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify('configure terminal', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify('sgsn', ['']))
+ self.assertEquals(self.vty.node(), 'config-sgsn')
+
+ res = self.vty.command("show running-config")
+ self.assert_(res.find("no cdr filename") > 0)
+
+ self.vty.command("cdr filename bla.cdr")
+ res = self.vty.command("show running-config")
+ self.assertEquals(res.find("no cdr filename"), -1)
+ self.assert_(res.find(" cdr filename bla.cdr") > 0)
+
+ self.vty.command("no cdr filename")
+ res = self.vty.command("show running-config")
+ self.assert_(res.find("no cdr filename") > 0)
+ self.assertEquals(res.find(" cdr filename bla.cdr"), -1)
+
+ res = self.vty.command("show running-config")
+ self.assert_(res.find(" cdr interval 600") > 0)
+
+ self.vty.command("cdr interval 900")
+ res = self.vty.command("show running-config")
+ self.assert_(res.find(" cdr interval 900") > 0)
+ self.assertEquals(res.find(" cdr interval 600"), -1)
+
+def add_nat_test(suite, workdir):
+ if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc_nat/osmo-bsc_nat")):
+ print("Skipping the NAT test")
+ return
+ test = unittest.TestLoader().loadTestsFromTestCase(TestVTYNAT)
+ suite.addTest(test)
+
+def nat_bsc_reload(x):
+ x.vty.command("configure terminal")
+ x.vty.command("nat")
+ x.vty.command("bscs-config-file bscs.config")
+ x.vty.command("end")
+
+def nat_msc_ip(x, ip, port):
+ x.vty.command("configure terminal")
+ x.vty.command("nat")
+ x.vty.command("msc ip " + ip)
+ x.vty.command("msc port " + str(port))
+ x.vty.command("end")
+
+def data2str(d):
+ return d.encode('hex').lower()
+
+def nat_msc_test(x, ip, port, verbose = False):
+ msc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ msc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ msc.settimeout(5)
+ msc.bind((ip, port))
+ msc.listen(5)
+ if (verbose):
+ print "MSC is ready at " + ip
+ conn = None
+ while True:
+ vty_response = x.vty.command("show msc connection")
+ print "'show msc connection' says: %r" % vty_response
+ if vty_response == "MSC is connected: 1":
+ # success
+ break;
+ if vty_response != "MSC is connected: 0":
+ raise Exception("Unexpected response to 'show msc connection'"
+ " vty command: %r" % vty_response)
+
+ timeout_retries = 6
+ while timeout_retries > 0:
+ try:
+ conn, addr = msc.accept()
+ print "MSC got connection from ", addr
+ break
+ except socket.timeout:
+ print "socket timed out."
+ timeout_retries -= 1
+ continue
+
+ if not conn:
+ raise Exception("VTY reports MSC is connected, but I haven't"
+ " connected yet: %r %r" % (ip, port))
+ return msc, conn
+
+def ipa_handle_small(x, verbose = False):
+ s = data2str(x.recv(4))
+ if len(s) != 4*2:
+ raise Exception("expected to receive 4 bytes, but got %d (%r)" % (len(s)/2, s))
+ if "0001fe00" == s:
+ if (verbose):
+ print "\tBSC <- NAT: PING?"
+ x.send(IPA().pong())
+ elif "0001fe06" == s:
+ if (verbose):
+ print "\tBSC <- NAT: IPA ID ACK"
+ x.send(IPA().id_ack())
+ elif "0001fe00" == s:
+ if (verbose):
+ print "\tBSC <- NAT: PONG!"
+ else:
+ if (verbose):
+ print "\tBSC <- NAT: ", s
+
+def ipa_handle_resp(x, tk, verbose = False, proc=None):
+ s = data2str(x.recv(38))
+ if "0023fe040108010701020103010401050101010011" in s:
+ retries = 3
+ while True:
+ print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T"))
+ try:
+ x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8'))))
+ print "\tdone sending IPA identity(%s) at %s" % (tk,
+ time.strftime("%T"))
+ break
+ except:
+ print "\tfailed sending IPA identity at", time.strftime("%T")
+ if proc:
+ print "\tproc.poll() = %r" % proc.poll()
+ if retries < 1:
+ print "\tgiving up"
+ raise
+ print "\tretrying (%d attempts left)" % retries
+ retries -= 1
+ else:
+ if (verbose):
+ print "\tBSC <- NAT: ", s
+
+def nat_bsc_num_con(x):
+ return len(x.vty.command("show bsc connections").split('\n'))
+
+def nat_bsc_sock_test(nr, tk, verbose = False, proc=None):
+ bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ bsc.bind(('127.0.0.1', 0))
+ bsc.connect(('127.0.0.1', 5000))
+ if (verbose):
+ print "BSC%d " %nr
+ print "\tconnected to %s:%d" % bsc.getpeername()
+ if proc:
+ print "\tproc.poll() = %r" % proc.poll()
+ print "\tproc.pid = %r" % proc.pid
+ ipa_handle_small(bsc, verbose)
+ ipa_handle_resp(bsc, tk, verbose, proc=proc)
+ if proc:
+ print "\tproc.poll() = %r" % proc.poll()
+ bsc.recv(27) # MGCP msg
+ if proc:
+ print "\tproc.poll() = %r" % proc.poll()
+ ipa_handle_small(bsc, verbose)
+ return bsc
+
+def add_bsc_test(suite, workdir):
+ if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc/osmo-bsc")):
+ print("Skipping the BSC test")
+ return
+ test = unittest.TestLoader().loadTestsFromTestCase(TestVTYBSC)
+ suite.addTest(test)
+
+def add_gbproxy_test(suite, workdir):
+ if not os.path.isfile(os.path.join(workdir, "src/gprs/osmo-gbproxy")):
+ print("Skipping the Gb-Proxy test")
+ return
+ test = unittest.TestLoader().loadTestsFromTestCase(TestVTYGbproxy)
+ suite.addTest(test)
+
+def add_sgsn_test(suite, workdir):
+ if not os.path.isfile(os.path.join(workdir, "src/gprs/osmo-sgsn")):
+ print("Skipping the SGSN test")
+ return
+ test = unittest.TestLoader().loadTestsFromTestCase(TestVTYSGSN)
+ suite.addTest(test)
+
+if __name__ == '__main__':
+ import argparse
+ import sys
+
+ workdir = '.'
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-v", "--verbose", dest="verbose",
+ action="store_true", help="verbose mode")
+ parser.add_argument("-p", "--pythonconfpath", dest="p",
+ help="searchpath for config")
+ parser.add_argument("-w", "--workdir", dest="w",
+ help="Working directory")
+ parser.add_argument("test_name", nargs="*", help="(parts of) test names to run, case-insensitive")
+ args = parser.parse_args()
+
+ verbose_level = 1
+ if args.verbose:
+ verbose_level = 2
+
+ if args.w:
+ workdir = args.w
+
+ if args.p:
+ confpath = args.p
+
+ print "confpath %s, workdir %s" % (confpath, workdir)
+ os.chdir(workdir)
+ print "Running tests for specific VTY commands"
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYMGCP))
+ suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYNITB))
+ add_bsc_test(suite, workdir)
+ add_nat_test(suite, workdir)
+ add_gbproxy_test(suite, workdir)
+ add_sgsn_test(suite, workdir)
+
+ if args.test_name:
+ osmoutil.pick_tests(suite, *args.test_name)
+
+ res = unittest.TextTestRunner(verbosity=verbose_level, stream=sys.stdout).run(suite)
+ sys.exit(len(res.errors) + len(res.failures))
+
+# vim: shiftwidth=4 expandtab nocin ai
diff --git a/tests/xid/Makefile.am b/tests/xid/Makefile.am
new file mode 100644
index 000000000..aaf17edf2
--- /dev/null
+++ b/tests/xid/Makefile.am
@@ -0,0 +1,39 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(LIBCARES_CFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ xid_test.ok \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ xid_test \
+ $(NULL)
+
+xid_test_SOURCES = \
+ xid_test.c \
+ $(NULL)
+
+xid_test_LDADD = \
+ $(top_builddir)/src/gprs/gprs_llc_xid.o \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(LIBOSMOABIS_LIBS) \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOGB_LIBS) \
+ $(LIBCARES_LIBS) \
+ $(LIBCRYPTO_LIBS) \
+ $(LIBGTP_LIBS) \
+ -lrt \
+ -lm \
+ $(NULL)
+
diff --git a/tests/xid/xid_test.c b/tests/xid/xid_test.c
new file mode 100644
index 000000000..b77a4ae85
--- /dev/null
+++ b/tests/xid/xid_test.c
@@ -0,0 +1,164 @@
+/* Test LLC-XID Encoding/Decoding */
+
+/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
+ * All Rights Reserved
+ *
+ * Author: 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/>.
+ */
+
+#include <openbsc/gprs_llc_xid.h>
+#include <openbsc/debug.h>
+
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+
+#include <osmocom/core/application.h>
+
+#include <stdio.h>
+#include <string.h>
+
+/* Test XID encoding */
+static void test_xid_encode(const void *ctx)
+{
+ struct gprs_llc_xid_field xid_field_1;
+ struct gprs_llc_xid_field xid_field_2;
+ struct gprs_llc_xid_field xid_field_3;
+ struct gprs_llc_xid_field xid_field_4;
+ LLIST_HEAD(xid_fields);
+ uint8_t xid[255];
+ uint8_t xid_expected[] =
+ { 0x10, 0x8c, 0x14, 0x43, 0x43, 0x43, 0x43, 0x43, 0x0b, 0x42, 0x42,
+ 0x42, 0x05, 0x41 };
+ int rc;
+
+ printf("Testing LLC XID-Encoder\n");
+
+ /* Setup some simple XID data */
+ xid_field_1.type = 1;
+ xid_field_2.type = 2;
+ xid_field_3.type = 3;
+ xid_field_4.type = 4;
+
+ xid_field_1.data = (uint8_t *) "A";
+ xid_field_2.data = (uint8_t *) "BBB";
+ xid_field_3.data = (uint8_t *) "CCCCC";
+ xid_field_4.data = NULL;
+
+ xid_field_1.data_len = 1;
+ xid_field_2.data_len = 3;
+ xid_field_3.data_len = 5;
+ xid_field_4.data_len = 0;
+
+ llist_add(&xid_field_4.list, &xid_fields);
+ llist_add(&xid_field_3.list, &xid_fields);
+ llist_add(&xid_field_2.list, &xid_fields);
+ llist_add(&xid_field_1.list, &xid_fields);
+
+ printf("Data to encode:\n");
+ gprs_llc_dump_xid_fields(&xid_fields, DSNDCP);
+
+ /* Encode data */
+ rc = gprs_llc_compile_xid(xid, sizeof(xid), &xid_fields);
+ OSMO_ASSERT(rc == 14);
+ printf("Encoded: %s (%i bytes)\n", osmo_hexdump_nospc(xid, rc), rc);
+ printf("Expected: %s (%i bytes)\n",
+ osmo_hexdump_nospc(xid_expected, sizeof(xid_expected)),
+ (int)sizeof(xid_expected));
+
+ OSMO_ASSERT(memcmp(xid_expected, xid, sizeof(xid_expected)) == 0);
+
+ printf("\n");
+}
+
+/* Test XID decoding */
+static void test_xid_decode(const void *ctx)
+{
+ struct llist_head *xid_fields;
+ int rc;
+
+ printf("Testing LLC XID-Decoder/Encoder\n");
+
+ /* Example of a real world LLC-XID message */
+ uint8_t xid[] =
+ { 0x01, 0x00, 0x16, 0x05, 0xf0, 0x1a, 0x05, 0xf0, 0xac, 0xd8, 0x00,
+ 0x01, 0x00, 0x02, 0x31, 0x82, 0x02, 0x27, 0x89, 0xff, 0xe0, 0x00, 0x0f,
+ 0x00, 0xa8, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x01, 0x02,
+ 0x00, 0x03, 0x01, 0x03, 0x00, 0x04, 0x01, 0x04, 0x00, 0x05, 0x01, 0x05,
+ 0x00, 0x06, 0x00, 0x07, 0x01, 0x07, 0x00, 0x08, 0x01, 0x08, 0x80, 0x00,
+ 0x04, 0x12, 0x00, 0x40, 0x07 };
+
+ uint8_t xid_r[512];
+
+ /* Decode and display XID fields */
+ xid_fields = gprs_llc_parse_xid(ctx, xid, sizeof(xid));
+ OSMO_ASSERT(xid_fields);
+
+ printf("Decoded:\n");
+ gprs_llc_dump_xid_fields(xid_fields, DSNDCP);
+
+
+ /* Encode xid-fields again */
+ rc = gprs_llc_compile_xid(xid_r, sizeof(xid_r), xid_fields);
+ printf("Result length=%i\n",rc);
+ printf("Encoded: %s\n", osmo_hexdump_nospc(xid, sizeof(xid)));
+ printf("Rencoded: %s\n", osmo_hexdump_nospc(xid_r, rc));
+
+ OSMO_ASSERT(rc == 64);
+ OSMO_ASSERT(memcmp(xid, xid_r, sizeof(xid)) == 0);
+
+ /* Free xid fields */
+ talloc_free(xid_fields);
+
+ printf("\n");
+}
+
+static struct log_info_cat gprs_categories[] = {
+ [DSNDCP] = {
+ .name = "DSNDCP",
+ .description =
+ "GPRS Sub-Network Dependent Control Protocol (SNDCP)",
+ .enabled = 1,.loglevel = LOGL_DEBUG,
+ }
+};
+
+static struct log_info info = {
+ .cat = gprs_categories,
+ .num_cat = ARRAY_SIZE(gprs_categories),
+};
+
+int main(int argc, char **argv)
+{
+ void *xid_ctx;
+
+ osmo_init_logging(&info);
+
+ xid_ctx = talloc_named_const(NULL, 0, "xid_ctx");
+
+ test_xid_decode(xid_ctx);
+ test_xid_encode(xid_ctx);
+ printf("Done\n");
+
+ talloc_report_full(xid_ctx, stderr);
+ OSMO_ASSERT(talloc_total_blocks(xid_ctx) == 1);
+ return 0;
+}
+
+/* stubs */
+struct osmo_prim_hdr;
+int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
+{
+ abort();
+}
diff --git a/tests/xid/xid_test.ok b/tests/xid/xid_test.ok
new file mode 100644
index 000000000..4cf825ca5
--- /dev/null
+++ b/tests/xid/xid_test.ok
@@ -0,0 +1,12 @@
+Testing LLC XID-Decoder/Encoder
+Decoded:
+Result length=64
+Encoded: 01001605f01a05f0acd8000100023182022789ffe0000f00a8000000010101000201020003010300040104000501050006000701070008010880000412004007
+Rencoded: 01001605f01a05f0acd8000100023182022789ffe0000f00a8000000010101000201020003010300040104000501050006000701070008010880000412004007
+
+Testing LLC XID-Encoder
+Data to encode:
+Encoded: 108c1443434343430b4242420541 (14 bytes)
+Expected: 108c1443434343430b4242420541 (14 bytes)
+
+Done