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 /src/tbf.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 'src/tbf.cpp')
-rw-r--r-- | src/tbf.cpp | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp index 51b2aa5c..0771969f 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -51,10 +51,42 @@ uint32_t gprs_rlcmac_tbf::tlli() const return m_ms ? m_ms->tlli() : 0; } -void gprs_rlcmac_tbf::assign_imsi(const char *imsi) +const char *gprs_rlcmac_tbf::imsi() const { - strncpy(m_imsi, imsi, sizeof(m_imsi)); - m_imsi[sizeof(m_imsi) - 1] = '\0'; + static const char nullc = 0; + return m_ms ? m_ms->imsi() : &nullc; +} + +void gprs_rlcmac_tbf::assign_imsi(const char *imsi_) +{ + GprsMs *old_ms; + + if (!imsi_ || !m_ms) { + LOGP(DRLCMAC, LOGL_ERROR, + "%s failed to assign IMSI: missing IMSI or MS object\n", + name()); + return; + } + + if (strcmp(imsi_, imsi()) == 0) + return; + + /* really change the IMSI */ + + old_ms = bts->ms_store().get_ms(0, 0, imsi_); + if (old_ms) { + /* We cannot find m_ms by IMSI since we know that it has a + * different IMSI */ + OSMO_ASSERT(old_ms != m_ms); + + LOGP(DRLCMAC, LOGL_INFO, + "%s the IMSI '%s' was already assigned to another " + "MS object: TLLI = 0x%08x, that IMSI will be removed\n", + name(), imsi_, old_ms->tlli()); + old_ms->set_imsi(""); + } + + m_ms->set_imsi(imsi_); } void gprs_rlcmac_tbf::set_new_tbf(gprs_rlcmac_tbf *tbf) @@ -404,9 +436,9 @@ void gprs_rlcmac_tbf::poll_timeout() LOGP(DRLCMAC, LOGL_DEBUG, "Re-send dowlink assignment " "for %s on PCH (IMSI=%s)\n", tbf_name(dl_tbf), - m_imsi); + imsi()); /* send immediate assignment */ - dl_tbf->bts->snd_dl_ass(dl_tbf, 0, m_imsi); + dl_tbf->bts->snd_dl_ass(dl_tbf, 0, imsi()); dl_tbf->m_wait_confirm = 1; } } else |