diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-05-21 11:07:16 +0200 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-05-28 12:28:40 +0200 |
commit | b0e5eaf59adbefc44e01850a6784c9da0c3abbf9 (patch) | |
tree | c7c628b9dd7db86d584e23a8c6d1031928059711 /tests/tbf/TbfTest.cpp | |
parent | 9a2845d491b088cb9e1962ba6dc8af5a4e279401 (diff) |
tbf: Move IMSI to MS object
Currently the IMSI is stored in the TBFs. Since it directly refers to
an MS, it should rather be stored in an MS object.
This patch move the m_imsi field from gprs_rlcmac_tbf to GprsMs,
changes gprs_rlcmac_tbf::imsi() to get the IMSI from the associated
MS object, and adds getter and setter to GprsMs. Before changing the
IMSI of the associated MS object, assign_imsi() checks if there is
already another MS object with the same IMSI and eventually resets
the IMSI of that one. So using update_ms() and assign_imsi() ensures
that there are not two MS object entries is the storage with the
same TLLI or the same IMSI.
Ticket: #1674
Sponsored-by: On-Waves ehf
Diffstat (limited to 'tests/tbf/TbfTest.cpp')
-rw-r--r-- | tests/tbf/TbfTest.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index bf49dbde..bc783176 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -305,6 +305,59 @@ static void test_tbf_delayed_release() printf("=== end %s ===\n", __func__); } +static void test_tbf_imsi() +{ + BTS the_bts; + uint8_t ts_no = 4; + uint8_t ms_class = 45; + uint8_t trx_no; + GprsMs *ms1, *ms2; + + gprs_rlcmac_dl_tbf *dl_tbf[2]; + + printf("=== start %s ===\n", __func__); + + setup_bts(&the_bts, ts_no); + + dl_tbf[0] = create_dl_tbf(&the_bts, ms_class, &trx_no); + dl_tbf[1] = create_dl_tbf(&the_bts, ms_class, &trx_no); + + dl_tbf[0]->update_ms(0xf1000001, GPRS_RLCMAC_DL_TBF); + dl_tbf[1]->update_ms(0xf1000002, GPRS_RLCMAC_DL_TBF); + + dl_tbf[0]->assign_imsi("001001000000001"); + ms1 = the_bts.ms_store().get_ms(0, 0, "001001000000001"); + /* OSMO_ASSERT(ms1 != NULL); */ + ms2 = the_bts.ms_store().get_ms(0xf1000001); + OSMO_ASSERT(ms2 != NULL); + OSMO_ASSERT(strcmp(ms2->imsi(), "001001000000001") == 0); + /* OSMO_ASSERT(ms1 == ms2); */ + + /* change the IMSI on TBF 0 */ + dl_tbf[0]->assign_imsi("001001000000002"); + ms1 = the_bts.ms_store().get_ms(0, 0, "001001000000001"); + OSMO_ASSERT(ms1 == NULL); + ms1 = the_bts.ms_store().get_ms(0, 0, "001001000000002"); + /* OSMO_ASSERT(ms1 != NULL); */ + OSMO_ASSERT(strcmp(ms2->imsi(), "001001000000002") == 0); + /* OSMO_ASSERT(ms1 == ms2); */ + + /* use the same IMSI on TBF 2 */ + dl_tbf[1]->assign_imsi("001001000000002"); + ms1 = the_bts.ms_store().get_ms(0, 0, "001001000000002"); + /* OSMO_ASSERT(ms1 != NULL); */ + OSMO_ASSERT(ms1 != ms2); + /* OSMO_ASSERT(strcmp(ms1->imsi(), "001001000000002") == 0); */ + /* OSMO_ASSERT(strcmp(ms2->imsi(), "") == 0); */ + + tbf_free(dl_tbf[1]); + ms1 = the_bts.ms_store().get_ms(0, 0, "001001000000002"); + OSMO_ASSERT(ms1 == NULL); + + tbf_free(dl_tbf[0]); + printf("=== end %s ===\n", __func__); +} + static void test_tbf_exhaustion() { BTS the_bts; @@ -389,6 +442,7 @@ int main(int argc, char **argv) test_tbf_final_ack(TEST_MODE_STANDARD); test_tbf_final_ack(TEST_MODE_REVERSE_FREE); test_tbf_delayed_release(); + test_tbf_imsi(); test_tbf_exhaustion(); if (getenv("TALLOC_REPORT_FULL")) |