aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--src/tbf.cpp29
-rw-r--r--tests/Makefile.am13
-rw-r--r--tests/tbf/TbfTest.cpp102
-rw-r--r--tests/tbf/TbfTest.err3
-rw-r--r--tests/tbf/TbfTest.ok0
-rw-r--r--tests/testsuite.at7
7 files changed, 150 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 9dc2b36c..4e4f1c59 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,6 +34,7 @@ tests/atconfig
tests/package.m4
tests/alloc/AllocTest
tests/rlcmac/RLCMACTest
+tests/tbf/TbfTest
tests/emu/pcu_emu
tests/testsuite
tests/testsuite.log
diff --git a/src/tbf.cpp b/src/tbf.cpp
index fac5aaf8..d78090fb 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -1618,9 +1618,32 @@ void gprs_rlcmac_tbf::update_tlli(uint32_t tlli)
if (tlli == m_tlli)
return;
-#warning "TODO.. find the DL/UL opposite and update the TLLI too"
- LOGP(DRLCMAC, LOGL_NOTICE, "%s changing tlli to TLLI=0x%08x\n",
- tbf_name(this), tlli);
+ bool changedUl = false;
+
+ /*
+ * During a Routing Area Update (due the assignment of a new
+ * P-TMSI) the tlli can change. We notice this when receiving
+ * a PACKET CONTROL ACK.
+ * When we get a TLLI change on the DL we will look if there
+ * is a UL TBF and change the tlli there as well.
+ *
+ * TODO: There could be multiple DL and UL TBFs and we should
+ * have a proper way to link all the related TBFs so we can do
+ * a group update.
+ */
+ if (m_tlli_valid && direction == GPRS_RLCMAC_DL_TBF) {
+ gprs_rlcmac_tbf *ul_tbf;
+ ul_tbf = bts->tbf_by_tlli(m_tlli, GPRS_RLCMAC_UL_TBF);
+
+ if (ul_tbf) {
+ ul_tbf->m_tlli = tlli;
+ changedUl = true;
+ }
+ }
+
+ LOGP(DRLCMAC, LOGL_NOTICE,
+ "%s changing tlli from TLLI=0x%08x TLLI=0x%08x ul_changed=%d\n",
+ tbf_name(this), m_tlli, tlli, changedUl);
m_tlli = tlli;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a752067b..415fb4d4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,6 @@
AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGB_CFLAGS) $(LIBOSMOGSM_CFLAGS) -I$(top_srcdir)/src/
-check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest
+check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest tbf/TbfTest
noinst_PROGRAMS = emu/pcu_emu
rlcmac_RLCMACTest_SOURCES = rlcmac/RLCMACTest.cpp
@@ -17,6 +17,14 @@ alloc_AllocTest_LDADD = \
$(LIBOSMOCORE_LIBS) \
$(COMMON_LA)
+tbf_TbfTest_SOURCES = tbf/TbfTest.cpp
+tbf_TbfTest_LDADD = \
+ $(LIBOSMOGB_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOCORE_LIBS) \
+ $(COMMON_LA) \
+ $(top_builddir)/src/libgprs.la
+
emu_pcu_emu_SOURCES = emu/pcu_emu.cpp emu/test_replay_gprs_attach.cpp \
emu/openbsc_clone.c emu/openbsc_clone.h emu/gprs_tests.h \
emu/test_pdp_activation.cpp
@@ -49,7 +57,8 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
EXTRA_DIST = \
testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \
rlcmac/RLCMACTest.ok rlcmac/RLCMACTest.err \
- alloc/AllocTest.ok alloc/AllocTest.err
+ alloc/AllocTest.ok alloc/AllocTest.err \
+ tbf/TbfTest.ok tbf/TbfTest.err
DISTCLEANFILES = atconfig
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
new file mode 100644
index 00000000..03c2324b
--- /dev/null
+++ b/tests/tbf/TbfTest.cpp
@@ -0,0 +1,102 @@
+/*
+ * TbfTest.cpp
+ *
+ * Copyright (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 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 "bts.h"
+#include "tbf.h"
+#include "gprs_debug.h"
+
+extern "C" {
+#include <osmocom/core/application.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+}
+
+void *tall_pcu_ctx;
+int16_t spoof_mnc = 0, spoof_mcc = 0;
+
+static void test_tbf_tlli_update()
+{
+ BTS the_bts;
+ the_bts.bts_data()->alloc_algorithm = alloc_algorithm_a;
+ the_bts.bts_data()->trx[0].pdch[2].enable();
+ the_bts.bts_data()->trx[0].pdch[3].enable();
+
+ /*
+ * Make a uplink and downlink allocation
+ */
+ gprs_rlcmac_tbf *dl_tbf = tbf_alloc(the_bts.bts_data(),
+ NULL, GPRS_RLCMAC_DL_TBF, 0,
+ 0, 0, 0);
+ dl_tbf->update_tlli(0x2342);
+ dl_tbf->tlli_mark_valid();
+ dl_tbf->ta = 4;
+ the_bts.timing_advance()->remember(0x2342, dl_tbf->ta);
+
+ gprs_rlcmac_tbf *ul_tbf = tbf_alloc(the_bts.bts_data(),
+ ul_tbf, GPRS_RLCMAC_UL_TBF, 0,
+ 0, 0, 0);
+ ul_tbf->update_tlli(0x2342);
+ ul_tbf->tlli_mark_valid();
+
+
+ OSMO_ASSERT(the_bts.tbf_by_tlli(0x2342, GPRS_RLCMAC_DL_TBF) == dl_tbf);
+ OSMO_ASSERT(the_bts.tbf_by_tlli(0x2342, GPRS_RLCMAC_UL_TBF) == ul_tbf);
+
+
+ /*
+ * Now check.. that DL changes and that the timing advance
+ * has changed.
+ */
+ dl_tbf->update_tlli(0x4232);
+ OSMO_ASSERT(!the_bts.tbf_by_tlli(0x2342, GPRS_RLCMAC_DL_TBF));
+ OSMO_ASSERT(!the_bts.tbf_by_tlli(0x2342, GPRS_RLCMAC_UL_TBF));
+
+
+ OSMO_ASSERT(the_bts.tbf_by_tlli(0x4232, GPRS_RLCMAC_DL_TBF) == dl_tbf);
+ OSMO_ASSERT(the_bts.tbf_by_tlli(0x4232, GPRS_RLCMAC_UL_TBF) == ul_tbf);
+}
+
+int main(int argc, char **argv)
+{
+ tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile TbfTest context");
+ if (!tall_pcu_ctx)
+ abort();
+
+ msgb_set_talloc_ctx(tall_pcu_ctx);
+ osmo_init_logging(&gprs_log_info);
+ log_set_use_color(osmo_stderr_target, 0);
+ log_set_print_filename(osmo_stderr_target, 0);
+
+ test_tbf_tlli_update();
+ return EXIT_SUCCESS;
+}
+
+/*
+ * stubs that should not be reached
+ */
+extern "C" {
+void l1if_pdch_req() { abort(); }
+void l1if_connect_pdch() { abort(); }
+void l1if_close_pdch() { abort(); }
+void l1if_open_pdch() { abort(); }
+}
diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err
new file mode 100644
index 00000000..9e2f1830
--- /dev/null
+++ b/tests/tbf/TbfTest.err
@@ -0,0 +1,3 @@
+TBF(TFI=0 TLLI=0x00000000 DIR=DL) changing tlli from TLLI=0x00000000 TLLI=0x00002342 ul_changed=0
+TBF(TFI=0 TLLI=0x00000000 DIR=UL) changing tlli from TLLI=0x00000000 TLLI=0x00002342 ul_changed=0
+TBF(TFI=0 TLLI=0x00002342 DIR=DL) changing tlli from TLLI=0x00002342 TLLI=0x00004232 ul_changed=1
diff --git a/tests/tbf/TbfTest.ok b/tests/tbf/TbfTest.ok
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/tbf/TbfTest.ok
diff --git a/tests/testsuite.at b/tests/testsuite.at
index cad8a68c..4d770050 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -15,3 +15,10 @@ cat $abs_srcdir/alloc/AllocTest.ok > expout
cat $abs_srcdir/alloc/AllocTest.err > experr
AT_CHECK([$abs_top_builddir/tests/alloc/AllocTest], [0], [expout], [experr])
AT_CLEANUP
+
+AT_SETUP([tbf])
+AT_KEYWORDS([tbf])
+cat $abs_srcdir/tbf/TbfTest.ok > expout
+cat $abs_srcdir/tbf/TbfTest.err > experr
+AT_CHECK([$abs_top_builddir/tests/tbf/TbfTest], [0], [expout], [experr])
+AT_CLEANUP