aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-06-19 10:59:58 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-06-19 13:38:36 +0200
commit407851b865f49ddb0ea37a1d8a26a979f08e50d8 (patch)
tree4d96c0f500f83f97292041d7cf19c20395689073
parent196ddc58a414bb0209e672896d1119d7297c2872 (diff)
tbf: Add BTS::ms_alloc methodjerlbeck/wip/ms-struct
Currently the code that creates the MS objects with tbf.cpp is duplicated. This commit moves the corresponding code into a new method. Since there is no TLLI available there, the GprsMsStorage::create_ms method has been refactored into two variants, one with TLLI/direction and one without. Sponsored-by: On-Waves ehf
-rw-r--r--src/bts.cpp11
-rw-r--r--src/bts.h1
-rw-r--r--src/gprs_ms_storage.cpp17
-rw-r--r--src/gprs_ms_storage.h1
-rw-r--r--src/tbf.cpp14
5 files changed, 30 insertions, 14 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index 0ff0ffa..bc5ac94 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -522,6 +522,17 @@ void BTS::snd_dl_ass(gprs_rlcmac_tbf *tbf, uint8_t poll, const char *imsi)
}
+GprsMs *BTS::ms_alloc(uint8_t ms_class)
+{
+ GprsMs *ms;
+ ms = ms_store().create_ms();
+
+ ms->set_timeout(m_bts.ms_idle_sec);
+ ms->set_ms_class(ms_class);
+
+ return ms;
+}
+
/*
* PDCH code below. TODO: move to a separate file
*/
diff --git a/src/bts.h b/src/bts.h
index f2db318..7e34db5 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -229,6 +229,7 @@ public:
GprsMsStorage &ms_store();
GprsMs *ms_by_tlli(uint32_t tlli, uint32_t old_tlli = 0);
+ GprsMs *ms_alloc(uint8_t ms_class);
/*
* Statistics
diff --git a/src/gprs_ms_storage.cpp b/src/gprs_ms_storage.cpp
index 1f124a5..515ed75 100644
--- a/src/gprs_ms_storage.cpp
+++ b/src/gprs_ms_storage.cpp
@@ -80,6 +80,18 @@ GprsMs *GprsMsStorage::get_ms(uint32_t tlli, uint32_t old_tlli, const char *imsi
return NULL;
}
+GprsMs *GprsMsStorage::create_ms()
+{
+ GprsMs *ms;
+
+ ms = new GprsMs(m_bts, 0);
+
+ ms->set_callback(this);
+ llist_add(&ms->list(), &m_list);
+
+ return ms;
+}
+
GprsMs *GprsMsStorage::create_ms(uint32_t tlli, enum gprs_rlcmac_tbf_direction dir)
{
GprsMs *ms = get_ms(tlli);
@@ -87,15 +99,12 @@ GprsMs *GprsMsStorage::create_ms(uint32_t tlli, enum gprs_rlcmac_tbf_direction d
if (ms)
return ms;
- ms = new GprsMs(m_bts, 0);
+ ms = create_ms();
if (dir == GPRS_RLCMAC_UL_TBF)
ms->set_tlli(tlli);
else
ms->confirm_tlli(tlli);
- ms->set_callback(this);
- llist_add(&ms->list(), &m_list);
-
return ms;
}
diff --git a/src/gprs_ms_storage.h b/src/gprs_ms_storage.h
index ad1e656..df788bf 100644
--- a/src/gprs_ms_storage.h
+++ b/src/gprs_ms_storage.h
@@ -38,6 +38,7 @@ public:
GprsMs *get_ms(uint32_t tlli, uint32_t old_tlli = 0, const char *imsi = 0) const;
GprsMs *create_ms(uint32_t tlli, enum gprs_rlcmac_tbf_direction dir);
+ GprsMs *create_ms();
const LListHead<GprsMs>& ms_list() const {return m_list;}
private:
diff --git a/src/tbf.cpp b/src/tbf.cpp
index faddb79..9bdc1f7 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -499,11 +499,8 @@ struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts,
tbf->direction = GPRS_RLCMAC_UL_TBF;
- if (!ms) {
- ms = bts->bts->ms_store().create_ms(0, tbf->direction);
- ms->set_timeout(bts->ms_idle_sec);
- ms->set_ms_class(ms_class);
- }
+ if (!ms)
+ ms = bts->bts->ms_alloc(ms_class);
rc = setup_tbf(tbf, bts, ms, tfi, trx, ms_class, single_slot);
/* if no resource */
@@ -539,11 +536,8 @@ struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts,
tbf->direction = GPRS_RLCMAC_DL_TBF;
- if (!ms) {
- ms = bts->bts->ms_store().create_ms(0, tbf->direction);
- ms->set_timeout(bts->ms_idle_sec);
- ms->set_ms_class(ms_class);
- }
+ if (!ms)
+ ms = bts->bts->ms_alloc(ms_class);
rc = setup_tbf(tbf, bts, ms, tfi, trx, ms_class, single_slot);
/* if no resource */