llc: Convert to C
There's no real reason (other than historical) why code in llc should be
kept as c++ code. Let's rewrite it as C so that it can be included by
existing C code without having to add C->C++ shim, ifdefs all around,
etc.
This simplifies code and easies modification/improvement of the related
objects.
Change-Id: I250680ba581167d7398b2f734769c756cbb61c48
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index 134e856..02a3568 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -535,7 +535,7 @@
printf("=== start %s ===\n", __func__);
- llc.init();
+ llc_init(&llc);
/* TS 44.060, B.1 */
cs = CS4;
@@ -544,8 +544,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, 11);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 11);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -557,8 +557,8 @@
OSMO_ASSERT(count_payload == 11);
OSMO_ASSERT(num_chunks == 1);
- llc.reset();
- llc.put_frame(llc_data, 26);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 26);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -570,8 +570,8 @@
OSMO_ASSERT(count_payload == 26);
OSMO_ASSERT(num_chunks == 2);
- llc.reset();
- llc.put_frame(llc_data, 99);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 99);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -597,8 +597,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, 20);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 20);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -632,8 +632,8 @@
OSMO_ASSERT(count_payload == 1);
OSMO_ASSERT(num_chunks == 1);
- llc.reset();
- llc.put_frame(llc_data, 99);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 99);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -657,8 +657,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, 7);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 7);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -670,8 +670,8 @@
OSMO_ASSERT(count_payload == 7);
OSMO_ASSERT(num_chunks == 1);
- llc.reset();
- llc.put_frame(llc_data, 11);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 11);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -696,8 +696,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, 99);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 99);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -721,8 +721,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, 20);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 20);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -746,8 +746,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, 30);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 30);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -779,8 +779,8 @@
OSMO_ASSERT(count_payload == 10);
OSMO_ASSERT(num_chunks == 1);
- llc.reset();
- llc.put_frame(llc_data, 99);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 99);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -804,8 +804,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, 11);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 11);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -817,8 +817,8 @@
OSMO_ASSERT(count_payload == 11);
OSMO_ASSERT(num_chunks == 1);
- llc.reset();
- llc.put_frame(llc_data, 26);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 26);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -830,8 +830,8 @@
OSMO_ASSERT(count_payload == 26);
OSMO_ASSERT(num_chunks == 2);
- llc.reset();
- llc.put_frame(llc_data, 99);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 99);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -862,8 +862,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, 15);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 15);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -875,8 +875,8 @@
OSMO_ASSERT(count_payload == 15);
OSMO_ASSERT(num_chunks == 1);
- llc.reset();
- llc.put_frame(llc_data, 12);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 12);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -911,8 +911,8 @@
OSMO_ASSERT(count_payload == 0);
OSMO_ASSERT(num_chunks == 1);
- llc.reset();
- llc.put_frame(llc_data, 7);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 7);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -925,8 +925,8 @@
OSMO_ASSERT(count_payload == 7);
OSMO_ASSERT(num_chunks == 2);
- llc.reset();
- llc.put_frame(llc_data, 18);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 18);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -950,8 +950,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, 6);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 6);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -963,8 +963,8 @@
OSMO_ASSERT(count_payload == 6);
OSMO_ASSERT(num_chunks == 1);
- llc.reset();
- llc.put_frame(llc_data, 12);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, 12);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -994,8 +994,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, rdbi.data_len);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, rdbi.data_len);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -1020,8 +1020,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, rdbi.data_len - 1);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, rdbi.data_len - 1);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
@@ -1048,8 +1048,8 @@
write_offset = 0;
memset(data, 0, sizeof(data));
- llc.reset();
- llc.put_frame(llc_data, rdbi.data_len - 2);
+ llc_reset(&llc);
+ llc_put_frame(&llc, llc_data, rdbi.data_len - 2);
count_payload = -1;
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
diff --git a/tests/llc/LlcTest.cpp b/tests/llc/LlcTest.cpp
index d98636a..b18f6de 100644
--- a/tests/llc/LlcTest.cpp
+++ b/tests/llc/LlcTest.cpp
@@ -56,7 +56,7 @@
memcpy(msg_data, data, len);
- queue->enqueue(llc_msg, expire_time);
+ llc_queue_enqueue(queue, llc_msg, expire_time);
}
static void dequeue_and_check(gprs_llc_queue *queue, const uint8_t *exp_data,
@@ -65,7 +65,7 @@
struct msgb *llc_msg;
const MetaInfo *info_res;
- llc_msg = queue->dequeue(&info_res);
+ llc_msg = llc_queue_dequeue(queue, &info_res);
OSMO_ASSERT(llc_msg != NULL);
fprintf(stderr, "dequeued msg, length %u (expected %zu), data %s\n",
diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp
index 3834acb..c497d07 100644
--- a/tests/types/TypesTest.cpp
+++ b/tests/types/TypesTest.cpp
@@ -58,20 +58,20 @@
uint8_t data[LLC_MAX_LEN] = {1, 2, 3, 4, };
uint8_t out;
gprs_llc llc;
- llc.init();
+ llc_init(&llc);
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);
+ llc_put_frame(&llc, data, 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);
+ llc_append_frame(&llc, &data[3], 1);
OSMO_ASSERT(llc_remaining_space(&llc) == LLC_MAX_LEN - 3);
OSMO_ASSERT(llc_frame_length(&llc) == 3);
OSMO_ASSERT(llc_chunk_size(&llc) == 3);
@@ -88,7 +88,7 @@
OSMO_ASSERT(llc.frame[2] == 4);
/* now fill the frame */
- llc.append_frame(data, llc_remaining_space(&llc) - 1);
+ llc_append_frame(&llc, data, llc_remaining_space(&llc) - 1);
OSMO_ASSERT(llc_fits_in_current_frame(&llc, 1));
OSMO_ASSERT(!llc_fits_in_current_frame(&llc, 2));
}