aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@espeweb.net>2020-12-16 15:59:45 +0100
committerpespin <pespin@sysmocom.de>2021-01-05 10:34:25 +0000
commitda971ee5026479e869ed75d944404d398c548497 (patch)
tree30bf447c2d828264e51d09f5422ea05421c48d47 /tests
parent86fad1ec4e246110b9d8ae66fd7bc30e1cedb5de (diff)
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it becomes really hard to use them since libosmocore relies heavily on C specific compilation features, which are not available in old C++ compilers (such as designated initializers for complex types in FSMs). GprsMs is right now a quite simple object since initial design of osmo-pcu made it optional and most of the logic was placed and stored duplicated in TBF objects. However, that's changing as we introduce more features, with the GprsMS class getting more weight. Hence, let's move it now to be a C struct in order to be able to easily use libosmocore features there, such as FSMs. Some helper classes which GprsMs uses are also mostly move to C since they are mostly structs with methods, so there's no point in having duplicated APIs for C++ and C for such simple cases. For some more complex classes, like (ul_,dl_)tbf, C API bindings are added where needed so that GprsMs can use functionalitites from that class. Most of those APIs can be kept afterwards and drop the C++ ones since they provide no benefit in general. Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
Diffstat (limited to 'tests')
-rw-r--r--tests/alloc/AllocTest.cpp75
-rw-r--r--tests/app_info/AppInfoTest.cpp4
-rw-r--r--tests/app_info/AppInfoTest.err11
-rw-r--r--tests/edge/EdgeTest.cpp7
-rw-r--r--tests/llc/LlcTest.cpp80
-rw-r--r--tests/ms/MsTest.cpp474
-rw-r--r--tests/tbf/TbfTest.cpp155
-rw-r--r--tests/types/TypesTest.cpp32
8 files changed, 421 insertions, 417 deletions
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 8ebf159..17cee46 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -224,12 +224,12 @@ static inline bool test_alloc_b_ul_dl(bool ts0, bool ts1, bool ts2, bool ts3, bo
return false;
OSMO_ASSERT(ul_tbf->ms());
- OSMO_ASSERT(ul_tbf->ms()->current_trx());
+ OSMO_ASSERT(ms_current_trx(ul_tbf->ms()));
dump_assignment(ul_tbf, "UL", verbose);
/* assume final ack has not been sent */
- dl_tbf = tbf_alloc_dl_tbf(bts, ms, ms->current_trx()->trx_no, false);
+ dl_tbf = tbf_alloc_dl_tbf(bts, ms, ms_current_trx(ms)->trx_no, false);
if (!dl_tbf)
return false;
@@ -268,11 +268,11 @@ static inline bool test_alloc_b_dl_ul(bool ts0, bool ts1, bool ts2, bool ts3, bo
dl_tbf->update_ms(0x23, GPRS_RLCMAC_DL_TBF);
OSMO_ASSERT(dl_tbf->ms() == ms);
- OSMO_ASSERT(dl_tbf->ms()->current_trx());
+ OSMO_ASSERT(ms_current_trx(dl_tbf->ms()));
dump_assignment(dl_tbf, "DL", verbose);
- ul_tbf = tbf_alloc_ul_tbf(bts, ms, ms->current_trx()->trx_no, false);
+ ul_tbf = tbf_alloc_ul_tbf(bts, ms, ms_current_trx(ms)->trx_no, false);
if (!ul_tbf)
return false;
@@ -319,8 +319,8 @@ static inline bool test_alloc_b_jolly(uint8_t ms_class)
return false;
OSMO_ASSERT(ul_tbf->ms() == ms);
- OSMO_ASSERT(ul_tbf->ms()->current_trx());
- trx_no = ms->current_trx()->trx_no;
+ OSMO_ASSERT(ms_current_trx(ul_tbf->ms()));
+ trx_no = ms_current_trx(ms)->trx_no;
dump_assignment(ul_tbf, "UL", true);
/* assume final ack has not been sent */
@@ -453,50 +453,55 @@ static inline char *test_mode_descr(enum test_mode t)
}
}
-static GprsMs *alloc_tbfs(BTS *the_bts, GprsMs *ms, enum test_mode mode)
+static GprsMs *alloc_tbfs(BTS *the_bts, struct GprsMs *old_ms, enum test_mode mode)
{
struct gprs_rlcmac_bts *bts;
+ struct GprsMs *ms, *new_ms;
uint8_t trx_no = -1;
- OSMO_ASSERT(ms != NULL);
+ OSMO_ASSERT(old_ms != NULL);
bts = the_bts->bts_data();
gprs_rlcmac_tbf *tbf = NULL;
- if (ms && ms->current_trx())
- trx_no = ms->current_trx()->trx_no;
+ if (ms_current_trx(old_ms))
+ trx_no = ms_current_trx(old_ms)->trx_no;
- GprsMs::Guard guard1(ms);
+ ms_ref(old_ms);
/* Allocate what is needed first */
switch (mode) {
case TEST_MODE_UL_ONLY:
case TEST_MODE_DL_AFTER_UL:
case TEST_MODE_UL_AND_DL:
- if (ms->ul_tbf())
- tbf_free(ms->ul_tbf());
- tbf = tbf_alloc_ul_tbf(bts, ms, trx_no, false);
- if (tbf == NULL)
+ if (ms_ul_tbf(old_ms))
+ tbf_free(ms_ul_tbf(old_ms));
+ tbf = tbf_alloc_ul_tbf(bts, old_ms, trx_no, false);
+ if (tbf == NULL) {
+ ms_unref(old_ms);
return NULL;
+ }
break;
case TEST_MODE_DL_ONLY:
case TEST_MODE_UL_AFTER_DL:
case TEST_MODE_DL_AND_UL:
- if (ms->dl_tbf())
- tbf_free(ms->dl_tbf());
- tbf = tbf_alloc_dl_tbf(bts, ms, trx_no, false);
- if (tbf == NULL)
+ if (ms_dl_tbf(old_ms))
+ tbf_free(ms_dl_tbf(old_ms));
+ tbf = tbf_alloc_dl_tbf(bts, old_ms, trx_no, false);
+ if (tbf == NULL) {
+ ms_unref(old_ms);
return NULL;
+ }
}
OSMO_ASSERT(tbf);
OSMO_ASSERT(tbf->ms());
- OSMO_ASSERT(ms == NULL || ms == tbf->ms());
+ OSMO_ASSERT(old_ms == tbf->ms());
ms = tbf->ms();
- GprsMs::Guard guard2(ms);
-
+ ms_ref(ms);
+ new_ms = ms;
/* Continue with what is needed next */
switch (mode) {
case TEST_MODE_UL_ONLY:
@@ -506,12 +511,12 @@ static GprsMs *alloc_tbfs(BTS *the_bts, GprsMs *ms, enum test_mode mode)
case TEST_MODE_DL_AFTER_UL:
case TEST_MODE_UL_AND_DL:
- ms = alloc_tbfs(the_bts, ms, TEST_MODE_DL_ONLY);
+ new_ms = alloc_tbfs(the_bts, ms, TEST_MODE_DL_ONLY);
break;
case TEST_MODE_UL_AFTER_DL:
case TEST_MODE_DL_AND_UL:
- ms = alloc_tbfs(the_bts, ms, TEST_MODE_UL_ONLY);
+ new_ms = alloc_tbfs(the_bts, ms, TEST_MODE_UL_ONLY);
break;
}
@@ -527,10 +532,12 @@ static GprsMs *alloc_tbfs(BTS *the_bts, GprsMs *ms, enum test_mode mode)
break;
}
- if (!ms && tbf)
+ if (!new_ms && tbf)
tbf_free(tbf);
- return guard2.is_idle() ? NULL : ms;
+ ms_unref(old_ms);
+ ms_unref(ms);
+ return new_ms;
}
static unsigned alloc_many_tbfs(BTS *the_bts, unsigned min_class,
@@ -556,16 +563,16 @@ static unsigned alloc_many_tbfs(BTS *the_bts, unsigned min_class,
ms = the_bts->ms_by_tlli(tlli);
if (!ms)
ms = the_bts->ms_alloc(0, 0);
- ms->set_ms_class(ms_class);
+ ms_set_ms_class(ms, ms_class);
ms = alloc_tbfs(the_bts, ms, mode);
if (!ms)
break;
- ms->set_tlli(tlli);
+ ms_set_tlli(ms, tlli);
- ul_tbf = ms->ul_tbf();
- dl_tbf = ms->dl_tbf();
- trx = ms->current_trx();
+ ul_tbf = ms_ul_tbf(ms);
+ dl_tbf = ms_dl_tbf(ms);
+ trx = ms_current_trx(ms);
OSMO_ASSERT(ul_tbf || dl_tbf);
@@ -616,12 +623,12 @@ static unsigned alloc_many_tbfs(BTS *the_bts, unsigned min_class,
get_dir_char(0x80, ul_slots, dl_slots, busy_slots));
if (tfi >= 0) {
- OSMO_ASSERT(ms->current_trx());
+ OSMO_ASSERT(ms_current_trx(ms));
tfi2 = the_bts->tfi_find_free(dir, &trx_no2,
- ms->current_trx()->trx_no);
+ ms_current_trx(ms)->trx_no);
OSMO_ASSERT(tfi != tfi2);
OSMO_ASSERT(tfi2 < 0 ||
- trx_no2 == ms->current_trx()->trx_no);
+ trx_no2 == ms_current_trx(ms)->trx_no);
}
ms_class += 1;
diff --git a/tests/app_info/AppInfoTest.cpp b/tests/app_info/AppInfoTest.cpp
index cd4454d..6e33538 100644
--- a/tests/app_info/AppInfoTest.cpp
+++ b/tests/app_info/AppInfoTest.cpp
@@ -152,9 +152,9 @@ void cleanup()
{
fprintf(stderr, "--- %s ---\n", __func__);
+ tbf_free(tbf1);
+ tbf_free(tbf2);
BTS::main_bts()->cleanup();
- talloc_free(tbf1);
- talloc_free(tbf2);
/* FIXME: talloc report disabled, because bts->ms_alloc() in prepare_bts_with_two_dl_tbf_subscr() causes leak */
/* talloc_report_full(tall_pcu_ctx, stderr); */
talloc_free(tall_pcu_ctx);
diff --git a/tests/app_info/AppInfoTest.err b/tests/app_info/AppInfoTest.err
index ae20ea3..9b0910f 100644
--- a/tests/app_info/AppInfoTest.err
+++ b/tests/app_info/AppInfoTest.err
@@ -52,3 +52,14 @@ Previous Packet Application Information was not sent to all subscribers, overwri
Sending Packet Application Information to 2 subscribers with active TBF
--- cleanup ---
+PDCH(TS 4, TRX 0): Detaching TBF(TFI=0 TLLI=0xffffffff DIR=DL STATE=RELEASING EGPRS), 1 TBFs, USFs = 00, TFIs = 00000002.
+PDCH(TS 5, TRX 0): Detaching TBF(TFI=0 TLLI=0xffffffff DIR=DL STATE=RELEASING EGPRS), 1 TBFs, USFs = 00, TFIs = 00000002.
+PDCH(TS 6, TRX 0): Detaching TBF(TFI=0 TLLI=0xffffffff DIR=DL STATE=RELEASING EGPRS), 1 TBFs, USFs = 00, TFIs = 00000002.
+PDCH(TS 7, TRX 0): Detaching TBF(TFI=0 TLLI=0xffffffff DIR=DL STATE=RELEASING EGPRS), 0 TBFs, USFs = 00, TFIs = 00000000.
+Detaching TBF from MS object, TLLI = 0xffffffff, TBF = TBF(TFI=0 TLLI=0xffffffff DIR=DL STATE=RELEASING EGPRS)
+PDCH(TS 4, TRX 0): Detaching TBF(TFI=1 TLLI=0xffffffff DIR=DL STATE=RELEASING EGPRS), 0 TBFs, USFs = 00, TFIs = 00000000.
+PDCH(TS 5, TRX 0): Detaching TBF(TFI=1 TLLI=0xffffffff DIR=DL STATE=RELEASING EGPRS), 0 TBFs, USFs = 00, TFIs = 00000000.
+PDCH(TS 6, TRX 0): Detaching TBF(TFI=1 TLLI=0xffffffff DIR=DL STATE=RELEASING EGPRS), 0 TBFs, USFs = 00, TFIs = 00000000.
+Detaching TBF from MS object, TLLI = 0xffffffff, TBF = TBF(TFI=1 TLLI=0xffffffff DIR=DL STATE=RELEASING EGPRS)
+Destroying MS object, TLLI = 0xffffffff
+Destroying MS object, TLLI = 0xffffffff
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index 67ed2a7..8fa76dd 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -619,7 +619,7 @@ static void test_rlc_unit_encoder()
write_offset = 0;
memset(data, 0, sizeof(data));
- OSMO_ASSERT(llc.chunk_size() == 1);
+ OSMO_ASSERT(llc_chunk_size(&llc) == 1);
count_payload = -1;
@@ -767,7 +767,7 @@ static void test_rlc_unit_encoder()
write_offset = 0;
memset(data, 0, sizeof(data));
- OSMO_ASSERT(llc.chunk_size() == 10);
+ OSMO_ASSERT(llc_chunk_size(&llc) == 10);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -899,7 +899,7 @@ static void test_rlc_unit_encoder()
write_offset = 0;
memset(data, 0, sizeof(data));
- OSMO_ASSERT(llc.chunk_size() == 0);
+ OSMO_ASSERT(llc_chunk_size(&llc) == 0);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -1167,7 +1167,6 @@ static void uplink_header_type_2_parsing_test(BTS *the_bts,
uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta,
uint8_t ms_class)
{
- struct pcu_l1_meas meas;
int tfi = 0;
uint8_t data[79] = {0};
struct gprs_rlc_ul_header_egprs_2 *egprs2 = NULL;
diff --git a/tests/llc/LlcTest.cpp b/tests/llc/LlcTest.cpp
index 10cd96b..bfcac77 100644
--- a/tests/llc/LlcTest.cpp
+++ b/tests/llc/LlcTest.cpp
@@ -60,10 +60,10 @@ static void enqueue_data(gprs_llc_queue *queue, const uint8_t *data, size_t len,
}
static void dequeue_and_check(gprs_llc_queue *queue, const uint8_t *exp_data,
- size_t len, const gprs_llc_queue::MetaInfo *exp_info)
+ size_t len, const MetaInfo *exp_info)
{
struct msgb *llc_msg;
- const gprs_llc_queue::MetaInfo *info_res;
+ const MetaInfo *info_res;
llc_msg = queue->dequeue(&info_res);
OSMO_ASSERT(llc_msg != NULL);
@@ -88,7 +88,7 @@ static void enqueue_data(gprs_llc_queue *queue, const char *message,
}
static void dequeue_and_check(gprs_llc_queue *queue, const char *exp_message,
- const gprs_llc_queue::MetaInfo *exp_info = 0)
+ const MetaInfo *exp_info = 0)
{
dequeue_and_check(queue,
(uint8_t *)(exp_message), strlen(exp_message), exp_info);
@@ -101,33 +101,33 @@ static void test_llc_queue()
printf("=== start %s ===\n", __func__);
- queue.init();
- OSMO_ASSERT(queue.size() == 0);
- OSMO_ASSERT(queue.octets() == 0);
+ llc_queue_init(&queue);
+ OSMO_ASSERT(llc_queue_size(&queue) == 0);
+ OSMO_ASSERT(llc_queue_octets(&queue) == 0);
enqueue_data(&queue, "LLC message", &expire_time);
- OSMO_ASSERT(queue.size() == 1);
- OSMO_ASSERT(queue.octets() == 11);
+ OSMO_ASSERT(llc_queue_size(&queue) == 1);
+ OSMO_ASSERT(llc_queue_octets(&queue) == 11);
enqueue_data(&queue, "other LLC message", &expire_time);
- OSMO_ASSERT(queue.size() == 2);
- OSMO_ASSERT(queue.octets() == 28);
+ OSMO_ASSERT(llc_queue_size(&queue) == 2);
+ OSMO_ASSERT(llc_queue_octets(&queue) == 28);
dequeue_and_check(&queue, "LLC message");
- OSMO_ASSERT(queue.size() == 1);
- OSMO_ASSERT(queue.octets() == 17);
+ OSMO_ASSERT(llc_queue_size(&queue) == 1);
+ OSMO_ASSERT(llc_queue_octets(&queue) == 17);
dequeue_and_check(&queue, "other LLC message");
- OSMO_ASSERT(queue.size() == 0);
- OSMO_ASSERT(queue.octets() == 0);
+ OSMO_ASSERT(llc_queue_size(&queue) == 0);
+ OSMO_ASSERT(llc_queue_octets(&queue) == 0);
enqueue_data(&queue, "LLC", &expire_time);
- OSMO_ASSERT(queue.size() == 1);
- OSMO_ASSERT(queue.octets() == 3);
+ OSMO_ASSERT(llc_queue_size(&queue) == 1);
+ OSMO_ASSERT(llc_queue_octets(&queue) == 3);
- queue.clear(NULL);
- OSMO_ASSERT(queue.size() == 0);
- OSMO_ASSERT(queue.octets() == 0);
+ llc_queue_clear(&queue, NULL);
+ OSMO_ASSERT(llc_queue_size(&queue) == 0);
+ OSMO_ASSERT(llc_queue_octets(&queue) == 0);
printf("=== end %s ===\n", __func__);
}
@@ -135,14 +135,14 @@ static void test_llc_queue()
static void test_llc_meta()
{
gprs_llc_queue queue;
- gprs_llc_queue::MetaInfo info1 = {0};
- gprs_llc_queue::MetaInfo info2 = {0};
+ MetaInfo info1 = {0};
+ MetaInfo info2 = {0};
printf("=== start %s ===\n", __func__);
- queue.init();
- OSMO_ASSERT(queue.size() == 0);
- OSMO_ASSERT(queue.octets() == 0);
+ llc_queue_init(&queue);
+ OSMO_ASSERT(llc_queue_size(&queue) == 0);
+ OSMO_ASSERT(llc_queue_octets(&queue) == 0);
info1.recv_time.tv_sec = 123456777;
info1.recv_time.tv_nsec = 123456000;
@@ -161,9 +161,9 @@ static void test_llc_meta()
dequeue_and_check(&queue, "LLC message 1", &info1);
dequeue_and_check(&queue, "LLC message 2", &info2);
- queue.clear(NULL);
- OSMO_ASSERT(queue.size() == 0);
- OSMO_ASSERT(queue.octets() == 0);
+ llc_queue_clear(&queue, NULL);
+ OSMO_ASSERT(llc_queue_size(&queue) == 0);
+ OSMO_ASSERT(llc_queue_octets(&queue) == 0);
printf("=== end %s ===\n", __func__);
}
@@ -176,8 +176,8 @@ static void test_llc_merge()
printf("=== start %s ===\n", __func__);
- queue1.init();
- queue2.init();
+ llc_queue_init(&queue1);
+ llc_queue_init(&queue2);
clk_mono_override_time->tv_sec += 1;
enqueue_data(&queue1, "*A*", &expire_time);
@@ -194,17 +194,17 @@ static void test_llc_merge()
clk_mono_override_time->tv_sec += 1;
enqueue_data(&queue2, "*E*", &expire_time);
- OSMO_ASSERT(queue1.size() == 3);
- OSMO_ASSERT(queue1.octets() == 9);
- OSMO_ASSERT(queue2.size() == 2);
- OSMO_ASSERT(queue2.octets() == 6);
+ OSMO_ASSERT(llc_queue_size(&queue1) == 3);
+ OSMO_ASSERT(llc_queue_octets(&queue1) == 9);
+ OSMO_ASSERT(llc_queue_size(&queue2) == 2);
+ OSMO_ASSERT(llc_queue_octets(&queue2) == 6);
- queue2.move_and_merge(&queue1);
+ llc_queue_move_and_merge(&queue2, &queue1);
- OSMO_ASSERT(queue1.size() == 0);
- OSMO_ASSERT(queue1.octets() == 0);
- OSMO_ASSERT(queue2.size() == 5);
- OSMO_ASSERT(queue2.octets() == 15);
+ OSMO_ASSERT(llc_queue_size(&queue1) == 0);
+ OSMO_ASSERT(llc_queue_octets(&queue1) == 0);
+ OSMO_ASSERT(llc_queue_size(&queue2) == 5);
+ OSMO_ASSERT(llc_queue_octets(&queue2) == 15);
dequeue_and_check(&queue2, "*A*");
dequeue_and_check(&queue2, "*B*");
@@ -212,8 +212,8 @@ static void test_llc_merge()
dequeue_and_check(&queue2, "*D*");
dequeue_and_check(&queue2, "*E*");
- OSMO_ASSERT(queue2.size() == 0);
- OSMO_ASSERT(queue2.octets() == 0);
+ OSMO_ASSERT(llc_queue_size(&queue2) == 0);
+ OSMO_ASSERT(llc_queue_octets(&queue2) == 0);
printf("=== end %s ===\n", __func__);
}
diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp
index 4f47bc9..c164409 100644
--- a/tests/ms/MsTest.cpp
+++ b/tests/ms/MsTest.cpp
@@ -56,33 +56,33 @@ static void test_ms_state()
printf("=== start %s ===\n", __func__);
- ms = new GprsMs(&the_bts, tlli);
- OSMO_ASSERT(ms->is_idle());
+ ms = ms_alloc(&the_bts, tlli);
+ OSMO_ASSERT(ms_is_idle(ms));
dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
new (dl_tbf) gprs_rlcmac_dl_tbf(&the_bts, ms);
ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
new (ul_tbf) gprs_rlcmac_ul_tbf(&the_bts, ms);
- ms->attach_tbf(ul_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
- OSMO_ASSERT(ms->dl_tbf() == NULL);
+ ms_attach_tbf(ms, ul_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
+ OSMO_ASSERT(ms_dl_tbf(ms) == NULL);
- ms->attach_tbf(dl_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
- OSMO_ASSERT(ms->dl_tbf() == dl_tbf);
+ ms_attach_tbf(ms, dl_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
+ OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf);
- OSMO_ASSERT(ms->tbf(GPRS_RLCMAC_UL_TBF) == ul_tbf);
- OSMO_ASSERT(ms->tbf(GPRS_RLCMAC_DL_TBF) == dl_tbf);
+ OSMO_ASSERT(ms_tbf(ms, GPRS_RLCMAC_UL_TBF) == ul_tbf);
+ OSMO_ASSERT(ms_tbf(ms, GPRS_RLCMAC_DL_TBF) == dl_tbf);
- ms->detach_tbf(ul_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == NULL);
- OSMO_ASSERT(ms->dl_tbf() == dl_tbf);
+ ms_detach_tbf(ms, ul_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf);
- ms->detach_tbf(dl_tbf);
+ ms_detach_tbf(ms, dl_tbf);
/* The ms object is freed now */
ms = NULL;
@@ -92,6 +92,23 @@ static void test_ms_state()
printf("=== end %s ===\n", __func__);
}
+static enum {CB_UNKNOWN, CB_IS_IDLE, CB_IS_ACTIVE} last_cb = CB_UNKNOWN;
+static void ms_idle_cb(struct GprsMs *ms)
+{
+ OSMO_ASSERT(ms_is_idle(ms));
+ printf(" ms_idle() was called\n");
+ last_cb = CB_IS_IDLE;
+}
+static void ms_active_cb(struct GprsMs *ms)
+{
+ OSMO_ASSERT(!ms_is_idle(ms));
+ printf(" ms_active() was called\n");
+ last_cb = CB_IS_ACTIVE;
+}
+static struct gpr_ms_callback ms_cb = {
+ .ms_idle = ms_idle_cb,
+ .ms_active = ms_active_cb
+};
static void test_ms_callback()
{
uint32_t tlli = 0xffeeddbb;
@@ -99,63 +116,50 @@ static void test_ms_callback()
gprs_rlcmac_ul_tbf *ul_tbf;
BTS the_bts;
GprsMs *ms;
- static enum {UNKNOWN, IS_IDLE, IS_ACTIVE} last_cb = UNKNOWN;
-
- struct MyCallback: public GprsMs::Callback {
- virtual void ms_idle(class GprsMs *ms) {
- OSMO_ASSERT(ms->is_idle());
- printf(" ms_idle() was called\n");
- last_cb = IS_IDLE;
- }
- virtual void ms_active(class GprsMs *ms) {
- OSMO_ASSERT(!ms->is_idle());
- printf(" ms_active() was called\n");
- last_cb = IS_ACTIVE;
- }
- } cb;
+ last_cb = CB_UNKNOWN;
printf("=== start %s ===\n", __func__);
- ms = new GprsMs(&the_bts, tlli);
- ms->set_callback(&cb);
+ ms = ms_alloc(&the_bts, tlli);
+ ms_set_callback(ms, &ms_cb);
- OSMO_ASSERT(ms->is_idle());
+ OSMO_ASSERT(ms_is_idle(ms));
dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
new (dl_tbf) gprs_rlcmac_dl_tbf(&the_bts, ms);
ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
new (ul_tbf) gprs_rlcmac_ul_tbf(&the_bts, ms);
- OSMO_ASSERT(last_cb == UNKNOWN);
+ OSMO_ASSERT(last_cb == CB_UNKNOWN);
- ms->attach_tbf(ul_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
- OSMO_ASSERT(ms->dl_tbf() == NULL);
- OSMO_ASSERT(last_cb == IS_ACTIVE);
+ ms_attach_tbf(ms, ul_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
+ OSMO_ASSERT(ms_dl_tbf(ms) == NULL);
+ OSMO_ASSERT(last_cb == CB_IS_ACTIVE);
- last_cb = UNKNOWN;
+ last_cb = CB_UNKNOWN;
- ms->attach_tbf(dl_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
- OSMO_ASSERT(ms->dl_tbf() == dl_tbf);
- OSMO_ASSERT(last_cb == UNKNOWN);
+ ms_attach_tbf(ms, dl_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
+ OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf);
+ OSMO_ASSERT(last_cb == CB_UNKNOWN);
- ms->detach_tbf(ul_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == NULL);
- OSMO_ASSERT(ms->dl_tbf() == dl_tbf);
- OSMO_ASSERT(last_cb == UNKNOWN);
+ ms_detach_tbf(ms, ul_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf);
+ OSMO_ASSERT(last_cb == CB_UNKNOWN);
- ms->detach_tbf(dl_tbf);
- OSMO_ASSERT(ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == NULL);
- OSMO_ASSERT(ms->dl_tbf() == NULL);
- OSMO_ASSERT(last_cb == IS_IDLE);
+ ms_detach_tbf(ms, dl_tbf);
+ OSMO_ASSERT(ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) == NULL);
+ OSMO_ASSERT(last_cb == CB_IS_IDLE);
- last_cb = UNKNOWN;
- delete ms;
+ last_cb = CB_UNKNOWN;
+ talloc_free(ms);
talloc_free(dl_tbf);
talloc_free(ul_tbf);
@@ -163,6 +167,22 @@ static void test_ms_callback()
printf("=== end %s ===\n", __func__);
}
+static bool was_idle;
+static void ms_replace_tbf_idle_cb(struct GprsMs *ms)
+{
+ OSMO_ASSERT(ms_is_idle(ms));
+ printf(" ms_idle() was called\n");
+ was_idle = true;
+}
+static void ms_replace_tbf_active_cb(struct GprsMs *ms)
+{
+ OSMO_ASSERT(!ms_is_idle(ms));
+ printf(" ms_active() was called\n");
+}
+static struct gpr_ms_callback ms_replace_tbf_cb = {
+ .ms_idle = ms_replace_tbf_idle_cb,
+ .ms_active = ms_replace_tbf_active_cb
+};
static void test_ms_replace_tbf()
{
uint32_t tlli = 0xffeeddbb;
@@ -170,26 +190,13 @@ static void test_ms_replace_tbf()
gprs_rlcmac_ul_tbf *ul_tbf;
BTS the_bts;
GprsMs *ms;
- static bool was_idle;
-
- struct MyCallback: public GprsMs::Callback {
- virtual void ms_idle(class GprsMs *ms) {
- OSMO_ASSERT(ms->is_idle());
- printf(" ms_idle() was called\n");
- was_idle = true;
- }
- virtual void ms_active(class GprsMs *ms) {
- OSMO_ASSERT(!ms->is_idle());
- printf(" ms_active() was called\n");
- }
- } cb;
printf("=== start %s ===\n", __func__);
- ms = new GprsMs(&the_bts, tlli);
- ms->set_callback(&cb);
+ ms = ms_alloc(&the_bts, tlli);
+ ms_set_callback(ms, &ms_replace_tbf_cb);
- OSMO_ASSERT(ms->is_idle());
+ OSMO_ASSERT(ms_is_idle(ms));
was_idle = false;
dl_tbf[0] = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
@@ -199,49 +206,49 @@ static void test_ms_replace_tbf()
ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
new (ul_tbf) gprs_rlcmac_ul_tbf(&the_bts, ms);
- ms->attach_tbf(dl_tbf[0]);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == NULL);
- OSMO_ASSERT(ms->dl_tbf() == dl_tbf[0]);
- OSMO_ASSERT(llist_empty(&ms->old_tbfs()));
+ ms_attach_tbf(ms, dl_tbf[0]);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf[0]);
+ OSMO_ASSERT(llist_empty(&ms->old_tbfs));
OSMO_ASSERT(!was_idle);
- ms->attach_tbf(dl_tbf[1]);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == NULL);
- OSMO_ASSERT(ms->dl_tbf() == dl_tbf[1]);
- OSMO_ASSERT(!llist_empty(&ms->old_tbfs()));
+ ms_attach_tbf(ms, dl_tbf[1]);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf[1]);
+ OSMO_ASSERT(!llist_empty(&ms->old_tbfs));
OSMO_ASSERT(!was_idle);
- ms->attach_tbf(ul_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
- OSMO_ASSERT(ms->dl_tbf() == dl_tbf[1]);
- OSMO_ASSERT(!llist_empty(&ms->old_tbfs()));
+ ms_attach_tbf(ms, ul_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
+ OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf[1]);
+ OSMO_ASSERT(!llist_empty(&ms->old_tbfs));
OSMO_ASSERT(!was_idle);
- ms->detach_tbf(ul_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == NULL);
- OSMO_ASSERT(ms->dl_tbf() == dl_tbf[1]);
- OSMO_ASSERT(!llist_empty(&ms->old_tbfs()));
+ ms_detach_tbf(ms, ul_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf[1]);
+ OSMO_ASSERT(!llist_empty(&ms->old_tbfs));
OSMO_ASSERT(!was_idle);
- ms->detach_tbf(dl_tbf[0]);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == NULL);
- OSMO_ASSERT(ms->dl_tbf() == dl_tbf[1]);
- OSMO_ASSERT(llist_empty(&ms->old_tbfs()));
+ ms_detach_tbf(ms, dl_tbf[0]);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf[1]);
+ OSMO_ASSERT(llist_empty(&ms->old_tbfs));
OSMO_ASSERT(!was_idle);
- ms->detach_tbf(dl_tbf[1]);
- OSMO_ASSERT(ms->is_idle());
- OSMO_ASSERT(ms->ul_tbf() == NULL);
- OSMO_ASSERT(ms->dl_tbf() == NULL);
- OSMO_ASSERT(llist_empty(&ms->old_tbfs()));
+ ms_detach_tbf(ms, dl_tbf[1]);
+ OSMO_ASSERT(ms_is_idle(ms));
+ OSMO_ASSERT(ms_ul_tbf(ms) == NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) == NULL);
+ OSMO_ASSERT(llist_empty(&ms->old_tbfs));
OSMO_ASSERT(was_idle);
- delete ms;
+ talloc_free(ms);
talloc_free(dl_tbf[0]);
talloc_free(dl_tbf[1]);
@@ -260,86 +267,86 @@ static void test_ms_change_tlli()
printf("=== start %s ===\n", __func__);
- ms = new GprsMs(&the_bts, start_tlli);
+ ms = ms_alloc(&the_bts, start_tlli);
- OSMO_ASSERT(ms->is_idle());
+ OSMO_ASSERT(ms_is_idle(ms));
/* MS announces TLLI, SGSN uses it immediately */
- ms->set_tlli(new_ms_tlli);
- OSMO_ASSERT(ms->tlli() == new_ms_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(ms->check_tlli(start_tlli));
+ ms_set_tlli(ms, new_ms_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == new_ms_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(ms_check_tlli(ms, start_tlli));
- ms->confirm_tlli(new_ms_tlli);
- OSMO_ASSERT(ms->tlli() == new_ms_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(!ms->check_tlli(start_tlli));
+ ms_confirm_tlli(ms, new_ms_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == new_ms_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(!ms_check_tlli(ms, start_tlli));
/* MS announces TLLI, SGSN uses it later */
- ms->set_tlli(start_tlli);
- ms->confirm_tlli(start_tlli);
+ ms_set_tlli(ms, start_tlli);
+ ms_confirm_tlli(ms, start_tlli);
- ms->set_tlli(new_ms_tlli);
- OSMO_ASSERT(ms->tlli() == new_ms_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(ms->check_tlli(start_tlli));
+ ms_set_tlli(ms, new_ms_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == new_ms_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(ms_check_tlli(ms, start_tlli));
- ms->confirm_tlli(start_tlli);
- OSMO_ASSERT(ms->tlli() == new_ms_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(ms->check_tlli(start_tlli));
+ ms_confirm_tlli(ms, start_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == new_ms_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(ms_check_tlli(ms, start_tlli));
- ms->set_tlli(new_ms_tlli);
- OSMO_ASSERT(ms->tlli() == new_ms_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(ms->check_tlli(start_tlli));
+ ms_set_tlli(ms, new_ms_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == new_ms_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(ms_check_tlli(ms, start_tlli));
- ms->confirm_tlli(new_ms_tlli);
- OSMO_ASSERT(ms->tlli() == new_ms_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(!ms->check_tlli(start_tlli));
+ ms_confirm_tlli(ms, new_ms_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == new_ms_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(!ms_check_tlli(ms, start_tlli));
/* MS announces TLLI, SGSN uses it later after another new TLLI */
- ms->set_tlli(start_tlli);
- ms->confirm_tlli(start_tlli);
-
- ms->set_tlli(new_ms_tlli);
- OSMO_ASSERT(ms->tlli() == new_ms_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(ms->check_tlli(start_tlli));
-
- ms->confirm_tlli(other_sgsn_tlli);
- OSMO_ASSERT(ms->tlli() == new_ms_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(ms->check_tlli(other_sgsn_tlli));
-
- ms->set_tlli(new_ms_tlli);
- OSMO_ASSERT(ms->tlli() == new_ms_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(ms->check_tlli(other_sgsn_tlli));
-
- ms->confirm_tlli(new_ms_tlli);
- OSMO_ASSERT(ms->tlli() == new_ms_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(!ms->check_tlli(start_tlli));
- OSMO_ASSERT(!ms->check_tlli(other_sgsn_tlli));
+ ms_set_tlli(ms, start_tlli);
+ ms_confirm_tlli(ms, start_tlli);
+
+ ms_set_tlli(ms, new_ms_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == new_ms_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(ms_check_tlli(ms, start_tlli));
+
+ ms_confirm_tlli(ms, other_sgsn_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == new_ms_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(ms_check_tlli(ms, other_sgsn_tlli));
+
+ ms_set_tlli(ms, new_ms_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == new_ms_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(ms_check_tlli(ms, other_sgsn_tlli));
+
+ ms_confirm_tlli(ms, new_ms_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == new_ms_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(!ms_check_tlli(ms, start_tlli));
+ OSMO_ASSERT(!ms_check_tlli(ms, other_sgsn_tlli));
/* SGSN uses the new TLLI before it is announced by the MS (shouldn't
* happen in normal use) */
- ms->set_tlli(start_tlli);
- ms->confirm_tlli(start_tlli);
+ ms_set_tlli(ms, start_tlli);
+ ms_confirm_tlli(ms, start_tlli);
- ms->confirm_tlli(new_ms_tlli);
- OSMO_ASSERT(ms->tlli() == start_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(ms->check_tlli(start_tlli));
+ ms_confirm_tlli(ms, new_ms_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == start_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(ms_check_tlli(ms, start_tlli));
- ms->set_tlli(new_ms_tlli);
- OSMO_ASSERT(ms->tlli() == new_ms_tlli);
- OSMO_ASSERT(ms->check_tlli(new_ms_tlli));
- OSMO_ASSERT(!ms->check_tlli(start_tlli));
+ ms_set_tlli(ms, new_ms_tlli);
+ OSMO_ASSERT(ms_tlli(ms) == new_ms_tlli);
+ OSMO_ASSERT(ms_check_tlli(ms, new_ms_tlli));
+ OSMO_ASSERT(!ms_check_tlli(ms, start_tlli));
- delete ms;
+ talloc_free(ms);
printf("=== end %s ===\n", __func__);
}
@@ -353,9 +360,9 @@ static GprsMs *prepare_ms(GprsMsStorage *st, uint32_t tlli, enum gprs_rlcmac_tbf
ms = st->create_ms();
if (dir == GPRS_RLCMAC_UL_TBF)
- ms->set_tlli(tlli);
+ ms_set_tlli(ms, tlli);
else
- ms->confirm_tlli(tlli);
+ ms_confirm_tlli(ms, tlli);
return ms;
}
@@ -378,44 +385,44 @@ static void test_ms_storage()
ms = prepare_ms(&store, tlli + 0, GPRS_RLCMAC_UL_TBF);
OSMO_ASSERT(ms != NULL);
- OSMO_ASSERT(ms->tlli() == tlli + 0);
- ms->set_imsi(imsi1);
- OSMO_ASSERT(strcmp(ms->imsi(), imsi1) == 0);
+ OSMO_ASSERT(ms_tlli(ms) == tlli + 0);
+ ms_set_imsi(ms, imsi1);
+ OSMO_ASSERT(strcmp(ms_imsi(ms), imsi1) == 0);
ms_tmp = store.get_ms(tlli + 0);
OSMO_ASSERT(ms == ms_tmp);
- OSMO_ASSERT(ms->tlli() == tlli + 0);
+ OSMO_ASSERT(ms_tlli(ms) == tlli + 0);
ms_tmp = store.get_ms(0, 0, imsi1);
OSMO_ASSERT(ms == ms_tmp);
- OSMO_ASSERT(strcmp(ms->imsi(), imsi1) == 0);
+ OSMO_ASSERT(strcmp(ms_imsi(ms), imsi1) == 0);
ms_tmp = store.get_ms(0, 0, imsi2);
OSMO_ASSERT(ms_tmp == NULL);
ms = prepare_ms(&store, tlli + 1, GPRS_RLCMAC_UL_TBF);
OSMO_ASSERT(ms != NULL);
- OSMO_ASSERT(ms->tlli() == tlli + 1);
- ms->set_imsi(imsi2);
- OSMO_ASSERT(strcmp(ms->imsi(), imsi2) == 0);
+ OSMO_ASSERT(ms_tlli(ms) == tlli + 1);
+ ms_set_imsi(ms, imsi2);
+ OSMO_ASSERT(strcmp(ms_imsi(ms), imsi2) == 0);
ms_tmp = store.get_ms(tlli + 1);
OSMO_ASSERT(ms == ms_tmp);
- OSMO_ASSERT(ms->tlli() == tlli + 1);
+ OSMO_ASSERT(ms_tlli(ms) == tlli + 1);
ms_tmp = store.get_ms(0, 0, imsi1);
OSMO_ASSERT(ms_tmp != NULL);
OSMO_ASSERT(ms_tmp != ms);
ms_tmp = store.get_ms(0, 0, imsi2);
OSMO_ASSERT(ms == ms_tmp);
- OSMO_ASSERT(strcmp(ms->imsi(), imsi2) == 0);
+ OSMO_ASSERT(strcmp(ms_imsi(ms), imsi2) == 0);
/* delete ms */
ms = store.get_ms(tlli + 0);
OSMO_ASSERT(ms != NULL);
ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
new (ul_tbf) gprs_rlcmac_ul_tbf(&the_bts, ms);
- ms->attach_tbf(ul_tbf);
- ms->detach_tbf(ul_tbf);
+ ms_attach_tbf(ms, ul_tbf);
+ ms_detach_tbf(ms, ul_tbf);
ms = store.get_ms(tlli + 0);
OSMO_ASSERT(ms == NULL);
ms = store.get_ms(tlli + 1);
@@ -424,8 +431,8 @@ static void test_ms_storage()
/* delete ms */
ms = store.get_ms(tlli + 1);
OSMO_ASSERT(ms != NULL);
- ms->attach_tbf(ul_tbf);
- ms->detach_tbf(ul_tbf);
+ ms_attach_tbf(ms, ul_tbf);
+ ms_detach_tbf(ms, ul_tbf);
ms = store.get_ms(tlli + 1);
OSMO_ASSERT(ms == NULL);
@@ -441,62 +448,49 @@ static void test_ms_timeout()
gprs_rlcmac_ul_tbf *ul_tbf;
BTS the_bts;
GprsMs *ms;
- static enum {UNKNOWN, IS_IDLE, IS_ACTIVE} last_cb = UNKNOWN;
-
- struct MyCallback: public GprsMs::Callback {
- virtual void ms_idle(class GprsMs *ms) {
- OSMO_ASSERT(ms->is_idle());
- printf(" ms_idle() was called\n");
- last_cb = IS_IDLE;
- }
- virtual void ms_active(class GprsMs *ms) {
- OSMO_ASSERT(!ms->is_idle());
- printf(" ms_active() was called\n");
- last_cb = IS_ACTIVE;
- }
- } cb;
+ last_cb = CB_UNKNOWN;
printf("=== start %s ===\n", __func__);
- ms = new GprsMs(&the_bts, tlli);
- ms->set_callback(&cb);
- ms->set_timeout(1);
+ ms = ms_alloc(&the_bts, tlli);
+ ms_set_callback(ms, &ms_cb);
+ ms_set_timeout(ms, 1);
- OSMO_ASSERT(ms->is_idle());
+ OSMO_ASSERT(ms_is_idle(ms));
dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
new (dl_tbf) gprs_rlcmac_dl_tbf(&the_bts, ms);
ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
new (ul_tbf) gprs_rlcmac_ul_tbf(&the_bts, ms);
- OSMO_ASSERT(last_cb == UNKNOWN);
+ OSMO_ASSERT(last_cb == CB_UNKNOWN);
- ms->attach_tbf(ul_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(last_cb == IS_ACTIVE);
+ ms_attach_tbf(ms, ul_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(last_cb == CB_IS_ACTIVE);
- last_cb = UNKNOWN;
+ last_cb = CB_UNKNOWN;
- ms->attach_tbf(dl_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(last_cb == UNKNOWN);
+ ms_attach_tbf(ms, dl_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(last_cb == CB_UNKNOWN);
- ms->detach_tbf(ul_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(last_cb == UNKNOWN);
+ ms_detach_tbf(ms, ul_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(last_cb == CB_UNKNOWN);
- ms->detach_tbf(dl_tbf);
- OSMO_ASSERT(!ms->is_idle());
- OSMO_ASSERT(last_cb == UNKNOWN);
+ ms_detach_tbf(ms, dl_tbf);
+ OSMO_ASSERT(!ms_is_idle(ms));
+ OSMO_ASSERT(last_cb == CB_UNKNOWN);
usleep(1100000);
osmo_timers_update();
- OSMO_ASSERT(ms->is_idle());
- OSMO_ASSERT(last_cb == IS_IDLE);
+ OSMO_ASSERT(ms_is_idle(ms));
+ OSMO_ASSERT(last_cb == CB_IS_IDLE);
- last_cb = UNKNOWN;
- delete ms;
+ last_cb = CB_UNKNOWN;
+ talloc_free(ms);
talloc_free(dl_tbf);
talloc_free(ul_tbf);
@@ -519,21 +513,21 @@ static void test_ms_cs_selection()
bts->cs_downgrade_threshold = 0;
bts->cs_adj_lower_limit = 0;
- ms = new GprsMs(&the_bts, tlli);
+ ms = ms_alloc(&the_bts, tlli);
- OSMO_ASSERT(ms->is_idle());
+ OSMO_ASSERT(ms_is_idle(ms));
dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
new (dl_tbf) gprs_rlcmac_dl_tbf(&the_bts, ms);
- ms->attach_tbf(dl_tbf);
+ ms_attach_tbf(ms, dl_tbf);
- OSMO_ASSERT(!ms->is_idle());
+ OSMO_ASSERT(!ms_is_idle(ms));
- OSMO_ASSERT(mcs_chan_code(ms->current_cs_dl()) == 3);
+ OSMO_ASSERT(mcs_chan_code(ms_current_cs_dl(ms)) == 3);
bts->cs_downgrade_threshold = 200;
- OSMO_ASSERT(mcs_chan_code(ms->current_cs_dl()) == 2);
+ OSMO_ASSERT(mcs_chan_code(ms_current_cs_dl(ms)) == 2);
talloc_free(dl_tbf);
@@ -543,10 +537,10 @@ static void test_ms_cs_selection()
static void dump_ms(const GprsMs *ms, const char *pref)
{
printf("%s MS DL %s/%s, UL %s/%s, mode %s, <%s>\n", pref,
- mcs_name(ms->current_cs_dl()), mcs_name(ms->max_cs_dl()),
- mcs_name(ms->current_cs_ul()), mcs_name(ms->max_cs_ul()),
- mode_name(ms->mode()),
- ms->is_idle() ? "IDLE" : "ACTIVE");
+ mcs_name(ms_current_cs_dl(ms)), mcs_name(ms_max_cs_dl(ms)),
+ mcs_name(ms_current_cs_ul(ms)), mcs_name(ms_max_cs_ul(ms)),
+ mode_name(ms_mode(ms)),
+ ms_is_idle(ms) ? "IDLE" : "ACTIVE");
}
static void test_ms_mcs_mode()
@@ -560,48 +554,48 @@ static void test_ms_mcs_mode()
printf("=== start %s ===\n", __func__);
- ms1 = new GprsMs(&the_bts, tlli);
+ ms1 = ms_alloc(&the_bts, tlli);
dump_ms(ms1, "1: no BTS defaults ");
bts->initial_cs_dl = 4;
bts->initial_cs_ul = 1;
bts->cs_downgrade_threshold = 0;
- ms2 = new GprsMs(&the_bts, tlli + 1);
+ ms2 = ms_alloc(&the_bts, tlli + 1);
dump_ms(ms2, "2: with BTS defaults");
dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
new (dl_tbf) gprs_rlcmac_dl_tbf(&the_bts, ms2);
- ms2->attach_tbf(dl_tbf);
+ ms_attach_tbf(ms2, dl_tbf);
dump_ms(ms2, "2: after TBF attach ");
- ms1->set_mode(EGPRS);
+ ms_set_mode(ms1, EGPRS);
dump_ms(ms1, "1: after mode set ");
- ms2->set_mode(EGPRS);
+ ms_set_mode(ms2, EGPRS);
dump_ms(ms2, "2: after mode set ");
- ms1->set_current_cs_dl(MCS7);
+ ms_set_current_cs_dl(ms1, MCS7);
dump_ms(ms1, "1: after MCS set ");
- ms2->set_current_cs_dl(MCS8);
+ ms_set_current_cs_dl(ms2, MCS8);
dump_ms(ms2, "2: after MCS set ");
- ms1->set_mode(EGPRS_GMSK);
+ ms_set_mode(ms1, EGPRS_GMSK);
dump_ms(ms1, "1: after mode set ");
- ms2->set_mode(EGPRS_GMSK);
+ ms_set_mode(ms2, EGPRS_GMSK);
dump_ms(ms2, "2: after mode set ");
// FIXME: following code triggers ASAN failure:
// ms2->detach_tbf(dl_tbf);
// dump_ms(ms2, "2: after TBF detach ");
- ms1->set_mode(GPRS);
+ ms_set_mode(ms1, GPRS);
dump_ms(ms1, "1: after mode set ");
- ms2->set_mode(GPRS);
+ ms_set_mode(ms2, GPRS);
dump_ms(ms2, "2: after mode set ");
talloc_free(dl_tbf);
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index 1a1dc6f..e6041a3 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -109,14 +109,14 @@ static void test_tbf_tlli_update()
OSMO_ASSERT(dl_tbf != NULL);
dl_tbf->update_ms(0x2342, GPRS_RLCMAC_DL_TBF);
dl_tbf->set_ta(4);
- OSMO_ASSERT(ms->dl_tbf() == dl_tbf);
+ OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf);
OSMO_ASSERT(dl_tbf->ms() == ms);
gprs_rlcmac_tbf *ul_tbf = tbf_alloc_ul_tbf(the_bts.bts_data(),
ms, 0, false);
OSMO_ASSERT(ul_tbf != NULL);
ul_tbf->update_ms(0x2342, GPRS_RLCMAC_UL_TBF);
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
OSMO_ASSERT(ul_tbf->ms() == ms);
OSMO_ASSERT(the_bts.ms_by_tlli(0x2342) == ms);
@@ -133,8 +133,8 @@ static void test_tbf_tlli_update()
ms_new = the_bts.ms_by_tlli(0x4232);
OSMO_ASSERT(ms == ms_new);
- OSMO_ASSERT(ms->dl_tbf() == dl_tbf);
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
+ OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf);
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
/* Now use the new TLLI for UL */
ul_tbf->update_ms(0x4232, GPRS_RLCMAC_UL_TBF);
@@ -143,7 +143,7 @@ static void test_tbf_tlli_update()
ms_new = the_bts.ms_by_tlli(0x4232);
OSMO_ASSERT(ms_new != NULL);
- OSMO_ASSERT(ms_new->ta() == 4);
+ OSMO_ASSERT(ms_ta(ms_new) == 4);
OSMO_ASSERT(ul_tbf->ta() == 4);
OSMO_ASSERT(dl_tbf->ta() == 4);
@@ -298,25 +298,27 @@ static void test_tbf_final_ack(enum test_tbf_final_ack_mode test_mode)
/* Clean up and ensure tbfs are in the correct state */
OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_WAIT_RELEASE));
- new_tbf = ms->dl_tbf();
+ new_tbf = ms_dl_tbf(ms);
check_tbf(new_tbf);
OSMO_ASSERT(new_tbf != dl_tbf);
OSMO_ASSERT(new_tbf->tfi() == 1);
check_tbf(dl_tbf);
TBF_SET_ASS_STATE_DL(dl_tbf, GPRS_RLCMAC_DL_ASS_NONE);
if (test_mode == TEST_MODE_REVERSE_FREE) {
- GprsMs::Guard guard(ms);
+ ms_ref(ms);
tbf_free(new_tbf);
- OSMO_ASSERT(ms->dl_tbf() == NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) == NULL);
check_tbf(dl_tbf);
tbf_free(dl_tbf);
+ ms_unref(ms);
} else {
- GprsMs::Guard guard(ms);
+ ms_ref(ms);
tbf_free(dl_tbf);
- OSMO_ASSERT(ms->dl_tbf() == new_tbf);
+ OSMO_ASSERT(ms_dl_tbf(ms) == new_tbf);
check_tbf(new_tbf);
tbf_free(new_tbf);
- OSMO_ASSERT(ms->dl_tbf() == NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) == NULL);
+ ms_unref(ms);
}
fprintf(stderr, "=== end %s ===\n", __func__);
@@ -421,32 +423,33 @@ static void test_tbf_imsi()
dl_tbf[0]->update_ms(0xf1000001, GPRS_RLCMAC_DL_TBF);
dl_tbf[1]->update_ms(0xf1000002, GPRS_RLCMAC_DL_TBF);
- dl_tbf[0]->ms()->set_imsi("001001000000001");
+ ms_set_imsi(dl_tbf[0]->ms(), "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(strcmp(ms_imsi(ms2), "001001000000001") == 0);
OSMO_ASSERT(ms1 == ms2);
/* change the IMSI on TBF 0 */
- dl_tbf[0]->ms()->set_imsi("001001000000002");
+ ms_set_imsi(dl_tbf[0]->ms(), "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(strcmp(ms_imsi(ms2), "001001000000002") == 0);
OSMO_ASSERT(ms1 == ms2);
/* use the same IMSI on TBF 1 */
{
- GprsMs::Guard guard(ms2);
- dl_tbf[1]->ms()->set_imsi("001001000000002");
+ ms_ref(ms2);
+ ms_set_imsi(dl_tbf[1]->ms(), "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);
+ OSMO_ASSERT(strcmp(ms_imsi(ms1), "001001000000002") == 0);
+ OSMO_ASSERT(strcmp(ms_imsi(ms2), "") == 0);
+ ms_unref(ms2);
}
ms2 = the_bts.ms_store().get_ms(0xf1000001);
@@ -539,8 +542,8 @@ static void test_tbf_dl_llc_loss()
ms = the_bts.ms_store().get_ms(0, 0, imsi);
OSMO_ASSERT(ms != NULL);
- OSMO_ASSERT(ms->dl_tbf() != NULL);
- ms->dl_tbf()->set_ta(0);
+ OSMO_ASSERT(ms_dl_tbf(ms) != NULL);
+ ms_dl_tbf(ms)->set_ta(0);
/* Handle LLC frame 2 */
memset(buf, 2, sizeof(buf));
@@ -549,7 +552,7 @@ static void test_tbf_dl_llc_loss()
OSMO_ASSERT(rc >= 0);
/* TBF establishment fails (timeout) */
- tbf_free(ms->dl_tbf());
+ tbf_free(ms_dl_tbf(ms));
/* Handle LLC frame 3 */
memset(buf, 3, sizeof(buf));
@@ -557,7 +560,7 @@ static void test_tbf_dl_llc_loss()
delay_csec, buf, sizeof(buf));
OSMO_ASSERT(rc >= 0);
- OSMO_ASSERT(ms->dl_tbf() != NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) != NULL);
/* Get first BSN */
struct msgb *msg;
@@ -572,8 +575,8 @@ static void test_tbf_dl_llc_loss()
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
};
- while (ms->dl_tbf()->have_data()) {
- msg = ms->dl_tbf()->create_dl_acked_block(fn += 4, 7);
+ while (ms_dl_tbf(ms)->have_data()) {
+ msg = ms_dl_tbf(ms)->create_dl_acked_block(fn += 4, 7);
fprintf(stderr, "MSG = %s\n", msgb_hexdump(msg));
if (!msgb_eq_data_print(msg, exp[expected_data - 1], GSM_MACBLOCK_LEN))
fprintf(stderr, "%s failed at %u\n", __func__, expected_data);
@@ -742,8 +745,8 @@ static gprs_rlcmac_ul_tbf *puan_urbb_len_issue(BTS *the_bts,
ms = the_bts->ms_by_tlli(tlli);
OSMO_ASSERT(ms != NULL);
- OSMO_ASSERT(ms->ta() == qta/4);
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
+ OSMO_ASSERT(ms_ta(ms) == qta/4);
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
/*
* TS 44.060, B.8.1
@@ -890,8 +893,8 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_spb(BTS *the_bts,
ms = the_bts->ms_by_tlli(tlli);
OSMO_ASSERT(ms != NULL);
- OSMO_ASSERT(ms->ta() == qta/4);
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
+ OSMO_ASSERT(ms_ta(ms) == qta/4);
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
/*
* TS 44.060, B.8.1
@@ -1386,8 +1389,8 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_URBB_no_length(BTS *t
ms = the_bts->ms_by_tlli(tlli);
OSMO_ASSERT(ms != NULL);
- OSMO_ASSERT(ms->ta() == qta/4);
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
+ OSMO_ASSERT(ms_ta(ms) == qta/4);
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
return ul_tbf;
}
@@ -1469,8 +1472,8 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_URBB_with_length(BTS
ms = the_bts->ms_by_tlli(tlli);
OSMO_ASSERT(ms != NULL);
- OSMO_ASSERT(ms->ta() == qta/4);
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
+ OSMO_ASSERT(ms_ta(ms) == qta/4);
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
return ul_tbf;
}
@@ -1554,8 +1557,8 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_CRBB(BTS *the_bts,
ms = the_bts->ms_by_tlli(tlli);
OSMO_ASSERT(ms != NULL);
- OSMO_ASSERT(ms->ta() == qta/4);
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
+ OSMO_ASSERT(ms_ta(ms) == qta/4);
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
return ul_tbf;
}
@@ -1637,8 +1640,8 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase(BTS *the_bts,
ms = the_bts->ms_by_tlli(tlli);
OSMO_ASSERT(ms != NULL);
- OSMO_ASSERT(ms->ta() == qta/4);
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
+ OSMO_ASSERT(ms_ta(ms) == qta/4);
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
return ul_tbf;
}
@@ -1655,7 +1658,7 @@ static void send_dl_data(BTS *the_bts, uint32_t tlli, const char *imsi,
ms = the_bts->ms_by_imsi(imsi);
OSMO_ASSERT(ms != NULL);
- OSMO_ASSERT(ms->dl_tbf() != NULL);
+ OSMO_ASSERT(ms_dl_tbf(ms) != NULL);
if (imsi[0] && strcmp(imsi, "000") != 0) {
ms2 = the_bts->ms_by_tlli(tlli);
@@ -1672,7 +1675,7 @@ static void transmit_dl_data(BTS *the_bts, uint32_t tlli, uint32_t *fn,
ms = the_bts->ms_by_tlli(tlli);
OSMO_ASSERT(ms);
- dl_tbf = ms->dl_tbf();
+ dl_tbf = ms_dl_tbf(ms);
OSMO_ASSERT(dl_tbf);
while (dl_tbf->have_data()) {
@@ -1692,7 +1695,7 @@ static inline void print_ta_tlli(const gprs_rlcmac_ul_tbf *ul_tbf, bool print_ms
{
fprintf(stderr, "Got '%s', TA=%d\n", ul_tbf->name(), ul_tbf->ta());
if (print_ms)
- fprintf(stderr, "Got MS: TLLI = 0x%08x, TA = %d\n", ul_tbf->ms()->tlli(), ul_tbf->ms()->ta());
+ fprintf(stderr, "Got MS: TLLI = 0x%08x, TA = %d\n", ms_tlli(ul_tbf->ms()), ms_ta(ul_tbf->ms()));
}
static void test_tbf_single_phase()
@@ -1866,10 +1869,10 @@ static void test_tbf_two_phase()
fprintf(stderr, "=== end %s ===\n", __func__);
}
-static inline void print_ms(const GprsMs *ms, bool old)
+static inline void print_ms(GprsMs *ms, bool old)
{
fprintf(stderr, "%s MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n",
- old ? "Old" : "New", ms->tlli(), ms->ta(), ms->imsi(), ms->llc_queue()->size());
+ old ? "Old" : "New", ms_tlli(ms), ms_ta(ms), ms_imsi(ms), llc_queue_size(ms_llc_queue(ms)));
}
static void test_tbf_ra_update_rach()
@@ -1905,9 +1908,9 @@ static void test_tbf_ra_update_rach()
send_control_ack(ul_tbf);
/* Make sure the RAU Accept gets sent to the MS */
- OSMO_ASSERT(ms1->llc_queue()->size() == 1);
+ OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms1)) == 1);
transmit_dl_data(&the_bts, tlli1, &fn);
- OSMO_ASSERT(ms1->llc_queue()->size() == 0);
+ OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms1)) == 0);
/* Now establish a new TBF for the RA UPDATE COMPLETE (new TLLI) */
ul_tbf = establish_ul_tbf_two_phase(&the_bts, ts_no, tlli2, &fn, qta,
@@ -1963,8 +1966,8 @@ static void test_tbf_dl_flow_and_rach_two_phase()
send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 2 *************", 20);
print_ms(ms1, true);
- OSMO_ASSERT(ms1->llc_queue()->size() == 2);
- dl_tbf = ms1->dl_tbf();
+ OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms1)) == 2);
+ dl_tbf = ms_dl_tbf(ms1);
OSMO_ASSERT(dl_tbf != NULL);
/* Get rid of old UL TBF */
@@ -1986,10 +1989,10 @@ static void test_tbf_dl_flow_and_rach_two_phase()
OSMO_ASSERT(ms2 == ms);
/* A DL TBF should still exist */
- OSMO_ASSERT(ms->dl_tbf());
+ OSMO_ASSERT(ms_dl_tbf(ms));
/* No queued packets should be lost */
- OSMO_ASSERT(ms->llc_queue()->size() == 2);
+ OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms)) == 2);
fprintf(stderr, "=== end %s ===\n", __func__);
}
@@ -2022,8 +2025,8 @@ static void test_tbf_dl_flow_and_rach_single_phase()
send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 2 *************", 20);
print_ms(ms1, true);
- OSMO_ASSERT(ms1->llc_queue()->size() == 2);
- dl_tbf = ms1->dl_tbf();
+ OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms1)) == 2);
+ dl_tbf = ms_dl_tbf(ms1);
OSMO_ASSERT(dl_tbf != NULL);
/* Get rid of old UL TBF */
@@ -2045,10 +2048,10 @@ static void test_tbf_dl_flow_and_rach_single_phase()
OSMO_ASSERT(ms1 != ms);
/* DL TBF should be removed */
- OSMO_ASSERT(!ms->dl_tbf());
+ OSMO_ASSERT(!ms_dl_tbf(ms));
/* No queued packets should be lost */
- OSMO_ASSERT(ms->llc_queue()->size() == 2);
+ OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms)) == 2);
fprintf(stderr, "=== end %s ===\n", __func__);
}
@@ -2099,11 +2102,11 @@ static void test_tbf_dl_reuse()
/* Transmit all data */
transmit_dl_data(&the_bts, tlli1, &fn);
- OSMO_ASSERT(ms1->llc_queue()->size() == 0);
- OSMO_ASSERT(ms1->dl_tbf());
- OSMO_ASSERT(ms1->dl_tbf()->state_is(GPRS_RLCMAC_FINISHED));
+ OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms1)) == 0);
+ OSMO_ASSERT(ms_dl_tbf(ms1));
+ OSMO_ASSERT(ms_dl_tbf(ms1)->state_is(GPRS_RLCMAC_FINISHED));
- dl_tbf1 = ms1->dl_tbf();
+ dl_tbf1 = ms_dl_tbf(ms1);
/* Send some LLC frames */
for (i = 0; i < 10; i++) {
@@ -2132,10 +2135,10 @@ static void test_tbf_dl_reuse()
ms2 = the_bts.ms_by_tlli(tlli1);
OSMO_ASSERT(ms2 == ms1);
- OSMO_ASSERT(ms2->dl_tbf());
- OSMO_ASSERT(ms2->dl_tbf()->state_is(GPRS_RLCMAC_ASSIGN));
+ OSMO_ASSERT(ms_dl_tbf(ms2));
+ OSMO_ASSERT(ms_dl_tbf(ms2)->state_is(GPRS_RLCMAC_ASSIGN));
- dl_tbf2 = ms2->dl_tbf();
+ dl_tbf2 = ms_dl_tbf(ms2);
OSMO_ASSERT(dl_tbf1 != dl_tbf2);
@@ -2144,9 +2147,9 @@ static void test_tbf_dl_reuse()
/* Transmit all data */
transmit_dl_data(&the_bts, tlli1, &fn);
- OSMO_ASSERT(ms2->llc_queue()->size() == 0);
- OSMO_ASSERT(ms2->dl_tbf());
- OSMO_ASSERT(ms2->dl_tbf()->state_is(GPRS_RLCMAC_FINISHED));
+ OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms2)) == 0);
+ OSMO_ASSERT(ms_dl_tbf(ms2));
+ OSMO_ASSERT(ms_dl_tbf(ms2)->state_is(GPRS_RLCMAC_FINISHED));
fprintf(stderr, "=== end %s ===\n", __func__);
}
@@ -2411,8 +2414,8 @@ static gprs_rlcmac_ul_tbf *tbf_li_decoding(BTS *the_bts,
ms = the_bts->ms_by_tlli(tlli);
OSMO_ASSERT(ms != NULL);
- OSMO_ASSERT(ms->ta() == qta/4);
- OSMO_ASSERT(ms->ul_tbf() == ul_tbf);
+ OSMO_ASSERT(ms_ta(ms) == qta/4);
+ OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);
egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg;
egprs3->si = 0;
@@ -2799,9 +2802,7 @@ static void egprs_spb_to_normal_validation(BTS *the_bts,
OSMO_ASSERT(bsn1 == 0);
- dl_tbf->ms()->set_current_cs_dl
- (static_cast < enum CodingScheme >
- (CS4 + demanded_mcs));
+ ms_set_current_cs_dl(dl_tbf->ms(), static_cast < enum CodingScheme > (CS4 + demanded_mcs));
fn = fn_add_blocks(fn, 1);
@@ -2831,9 +2832,7 @@ static void egprs_spb_to_normal_validation(BTS *the_bts,
OSMO_ASSERT(egprs3->cps == 3);
/* Handle (MCS3, MCS3) -> MCS6 case */
- dl_tbf->ms()->set_current_cs_dl
- (static_cast < enum CodingScheme >
- (CS4 + mcs));
+ ms_set_current_cs_dl(dl_tbf->ms(), static_cast < enum CodingScheme > (CS4 + mcs));
NACK(dl_tbf, 0);
@@ -2880,9 +2879,7 @@ static void establish_and_use_egprs_dl_tbf_for_spb(BTS *the_bts,
NACK(dl_tbf, 0);
- dl_tbf->ms()->set_current_cs_dl
- (static_cast < enum CodingScheme >
- (CS4 + demanded_mcs));
+ ms_set_current_cs_dl(dl_tbf->ms(), static_cast < enum CodingScheme > (CS4 + demanded_mcs));
fn = fn_add_blocks(fn, 1);
@@ -2967,9 +2964,7 @@ static void establish_and_use_egprs_dl_tbf_for_retx(BTS *the_bts,
NACK(dl_tbf, 1);
/* Set the demanded MCS to demanded_mcs */
- dl_tbf->ms()->set_current_cs_dl
- (static_cast < enum CodingScheme >
- (CS4 + demanded_mcs));
+ ms_set_current_cs_dl(dl_tbf->ms(), static_cast < enum CodingScheme > (CS4 + demanded_mcs));
fn = fn_add_blocks(fn, 1);
/* Retransmit the first RLC data block with demanded_mcs */
@@ -2994,9 +2989,7 @@ static void establish_and_use_egprs_dl_tbf_for_retx(BTS *the_bts,
NACK(dl_tbf, 0);
NACK(dl_tbf, 1);
- dl_tbf->ms()->set_current_cs_dl
- (static_cast < enum CodingScheme >
- (CS4 + demanded_mcs));
+ ms_set_current_cs_dl(dl_tbf->ms(), static_cast < enum CodingScheme > (CS4 + demanded_mcs));
fn = fn_add_blocks(fn, 1);
/* Send first, second RLC data blocks with demanded_mcs */
@@ -3264,8 +3257,8 @@ int main(int argc, char **argv)
pcu_vty_init();
/* Initialize shared UL measurements */
- meas.set_link_qual(12);
- meas.set_rssi(31);
+ pcu_l1_meas_set_link_qual(&meas, 12);
+ pcu_l1_meas_set_rssi(&meas, 31);
test_tbf_base();
test_tbf_tlli_update();
diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp
index f224146..bc24b30 100644
--- a/tests/types/TypesTest.cpp
+++ b/tests/types/TypesTest.cpp
@@ -58,27 +58,27 @@ static void test_llc(void)
gprs_llc llc;
llc.init();
- OSMO_ASSERT(llc.chunk_size() == 0);
- OSMO_ASSERT(llc.remaining_space() == LLC_MAX_LEN);
- OSMO_ASSERT(llc.frame_length() == 0);
+ OSMO_ASSERT(llc_chunk_size(&llc) == 0);
+ OSMO_ASSERT(llc_remaining_space(&llc) == LLC_MAX_LEN);
+ OSMO_ASSERT(llc_frame_length(&llc) == 0);
llc.put_frame(data, 2);
- OSMO_ASSERT(llc.remaining_space() == LLC_MAX_LEN - 2);
- OSMO_ASSERT(llc.frame_length() == 2);
- OSMO_ASSERT(llc.chunk_size() == 2);
+ OSMO_ASSERT(llc_remaining_space(&llc) == LLC_MAX_LEN - 2);
+ OSMO_ASSERT(llc_frame_length(&llc) == 2);
+ OSMO_ASSERT(llc_chunk_size(&llc) == 2);
OSMO_ASSERT(llc.frame[0] == 1);
OSMO_ASSERT(llc.frame[1] == 2);
llc.append_frame(&data[3], 1);
- OSMO_ASSERT(llc.remaining_space() == LLC_MAX_LEN - 3);
- OSMO_ASSERT(llc.frame_length() == 3);
- OSMO_ASSERT(llc.chunk_size() == 3);
+ OSMO_ASSERT(llc_remaining_space(&llc) == LLC_MAX_LEN - 3);
+ OSMO_ASSERT(llc_frame_length(&llc) == 3);
+ OSMO_ASSERT(llc_chunk_size(&llc) == 3);
/* consume two bytes */
- llc.consume(&out, 1);
- OSMO_ASSERT(llc.remaining_space() == LLC_MAX_LEN - 3);
- OSMO_ASSERT(llc.frame_length() == 3);
- OSMO_ASSERT(llc.chunk_size() == 2);
+ llc_consume_data(&llc, &out, 1);
+ OSMO_ASSERT(llc_remaining_space(&llc) == LLC_MAX_LEN - 3);
+ OSMO_ASSERT(llc_frame_length(&llc) == 3);
+ OSMO_ASSERT(llc_chunk_size(&llc) == 2);
/* check that the bytes are as we expected */
OSMO_ASSERT(llc.frame[0] == 1);
@@ -86,9 +86,9 @@ static void test_llc(void)
OSMO_ASSERT(llc.frame[2] == 4);
/* now fill the frame */
- llc.append_frame(data, llc.remaining_space() - 1);
- OSMO_ASSERT(llc.fits_in_current_frame(1));
- OSMO_ASSERT(!llc.fits_in_current_frame(2));
+ llc.append_frame(data, llc_remaining_space(&llc) - 1);
+ OSMO_ASSERT(llc_fits_in_current_frame(&llc, 1));
+ OSMO_ASSERT(!llc_fits_in_current_frame(&llc, 2));
}
}