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
changes/23/27623/1
Pau Espin 8 months ago
parent 1463383505
commit 4f8384bfbb
  1. 3
      debian/copyright
  2. 2
      src/Makefile.am
  3. 86
      src/llc.c
  4. 49
      src/llc.h
  5. 2
      src/tbf.cpp
  6. 18
      src/tbf_dl.cpp
  7. 8
      src/tbf_ul.cpp
  8. 94
      tests/edge/EdgeTest.cpp
  9. 4
      tests/llc/LlcTest.cpp
  10. 8
      tests/types/TypesTest.cpp

3
debian/copyright vendored

@ -42,7 +42,7 @@ Files: src/tbf.cpp
src/tbf_dl.cpp
src/sba.cpp
src/sba.h
src/llc.cpp
src/llc.c
src/encoding.cpp
src/encoding.h
src/gprs_rlcmac.cpp
@ -50,6 +50,7 @@ Files: src/tbf.cpp
Copyright: 2012 Ivan Klyuchnikov
2012 Andreas Eversberg <jolly@eversberg.eu>
2013 by Holger Hans Peter Freyther
2022 by by Sysmocom s.f.m.c. GmbH
License: GPL-2.0+
Files: src/gprs_rlcmac.h

@ -73,7 +73,7 @@ libgprs_la_SOURCES = \
encoding.cpp \
sba.c \
decoding.cpp \
llc.cpp \
llc.c \
rlc.cpp \
osmobts_sock.c \
gprs_codel.c \

@ -15,32 +15,36 @@
* GNU General Public License for more details.
*/
#include <bts.h>
#include <stdio.h>
extern "C" {
#include <osmocom/core/msgb.h>
}
#include "bts.h"
#include "pcu_utils.h"
#include "llc.h"
void llc_init(struct gprs_llc *llc)
{
llc_reset(llc);
}
/* reset LLC frame */
void gprs_llc::reset()
void llc_reset(struct gprs_llc *llc)
{
index = 0;
length = 0;
llc->index = 0;
llc->length = 0;
memset(frame, 0x42, sizeof(frame));
memset(llc->frame, 0x42, sizeof(llc->frame));
}
void gprs_llc::reset_frame_space()
void llc_reset_frame_space(struct gprs_llc *llc)
{
index = 0;
llc->index = 0;
}
/* Put an Unconfirmed Information (UI) Dummy command, see GSM 44.064, 6.4.2.2 */
void gprs_llc::put_dummy_frame(size_t req_len)
void llc_put_dummy_frame(struct gprs_llc *llc, size_t req_len)
{
/* The shortest dummy command (the spec requests at least 6 octets) */
static const uint8_t llc_dummy_command[] = {
@ -48,39 +52,34 @@ void gprs_llc::put_dummy_frame(size_t req_len)
};
static const size_t max_dummy_command_len = 79;
put_frame(llc_dummy_command, sizeof(llc_dummy_command));
llc_put_frame(llc, llc_dummy_command, sizeof(llc_dummy_command));
if (req_len > max_dummy_command_len)
req_len = max_dummy_command_len;
/* Add further stuffing, if the requested length exceeds the minimum
* dummy command length */
if (length < req_len) {
memset(&frame[length], 0x2b, req_len - length);
length = req_len;
if (llc->length < req_len) {
memset(&llc->frame[llc->length], 0x2b, req_len - llc->length);
llc->length = req_len;
}
}
void gprs_llc::put_frame(const uint8_t *data, size_t len)
void llc_put_frame(struct gprs_llc *llc, const uint8_t *data, size_t len)
{
/* only put frames when we are empty */
OSMO_ASSERT(index == 0 && length == 0);
append_frame(data, len);
OSMO_ASSERT(llc->index == 0 && llc->length == 0);
llc_append_frame(llc, data, len);
}
void gprs_llc::append_frame(const uint8_t *data, size_t len)
void llc_append_frame(struct gprs_llc *llc, const uint8_t *data, size_t len)
{
/* TODO: bounds check */
memcpy(frame + length, data, len);
length += len;
}
void gprs_llc::init()
{
reset();
memcpy(llc->frame + llc->length, data, len);
llc->length += len;
}
bool gprs_llc::is_user_data_frame(uint8_t *data, size_t len)
bool llc_is_user_data_frame(const uint8_t *data, size_t len)
{
if (len < 2)
return false;
@ -104,20 +103,20 @@ void llc_queue_init(struct gprs_llc_queue *q)
}
void gprs_llc_queue::enqueue(struct msgb *llc_msg, const struct timespec *expire_time)
void llc_queue_enqueue(struct gprs_llc_queue *q, struct msgb *llc_msg, const struct timespec *expire_time)
{
MetaInfo *meta_storage;
struct MetaInfo *meta_storage;
osmo_static_assert(sizeof(*meta_storage) <= sizeof(llc_msg->cb), info_does_not_fit);
queue_size += 1;
queue_octets += msgb_length(llc_msg);
q->queue_size += 1;
q->queue_octets += msgb_length(llc_msg);
meta_storage = (MetaInfo *)&llc_msg->cb[0];
meta_storage = (struct MetaInfo *)&llc_msg->cb[0];
osmo_clock_gettime(CLOCK_MONOTONIC, &meta_storage->recv_time);
meta_storage->expire_time = *expire_time;
msgb_enqueue(&queue, llc_msg);
msgb_enqueue(&q->queue, llc_msg);
}
void llc_queue_clear(struct gprs_llc_queue *q, struct gprs_rlcmac_bts *bts)
@ -159,8 +158,8 @@ void llc_queue_move_and_merge(struct gprs_llc_queue *q, struct gprs_llc_queue *o
msg = msg1;
msg1 = NULL;
} else {
const MetaInfo *mi1 = (MetaInfo *)&msg1->cb[0];
const MetaInfo *mi2 = (MetaInfo *)&msg2->cb[0];
const struct MetaInfo *mi1 = (struct MetaInfo *)&msg1->cb[0];
const struct MetaInfo *mi2 = (struct MetaInfo *)&msg2->cb[0];
if (timespeccmp(&mi2->recv_time, &mi1->recv_time, >)) {
msg = msg1;
@ -189,24 +188,24 @@ void llc_queue_move_and_merge(struct gprs_llc_queue *q, struct gprs_llc_queue *o
#define ALPHA 0.5f
struct msgb *gprs_llc_queue::dequeue(const MetaInfo **info)
struct msgb *llc_queue_dequeue(struct gprs_llc_queue *q, const struct MetaInfo **info)
{
struct msgb *msg;
struct timespec *tv, tv_now, tv_result;
uint32_t lifetime;
const MetaInfo *meta_storage;
const struct MetaInfo *meta_storage;
msg = msgb_dequeue(&queue);
msg = msgb_dequeue(&q->queue);
if (!msg)
return NULL;
meta_storage = (MetaInfo *)&msg->cb[0];
meta_storage = (struct MetaInfo *)&msg->cb[0];
if (info)
*info = meta_storage;
queue_size -= 1;
queue_octets -= msgb_length(msg);
q->queue_size -= 1;
q->queue_octets -= msgb_length(msg);
/* take the second time */
osmo_clock_gettime(CLOCK_MONOTONIC, &tv_now);
@ -214,12 +213,12 @@ struct msgb *gprs_llc_queue::dequeue(const MetaInfo **info)
timespecsub(&tv_now, &meta_storage->recv_time, &tv_result);
lifetime = tv_result.tv_sec*1000 + tv_result.tv_nsec/1000000;
avg_queue_delay = avg_queue_delay * ALPHA + lifetime * (1-ALPHA);
q->avg_queue_delay = q->avg_queue_delay * ALPHA + lifetime * (1-ALPHA);
return msg;
}
void gprs_llc_queue::calc_pdu_lifetime(struct gprs_rlcmac_bts *bts, const uint16_t pdu_delay_csec, struct timespec *tv)
void llc_queue_calc_pdu_lifetime(struct gprs_rlcmac_bts *bts, const uint16_t pdu_delay_csec, struct timespec *tv)
{
uint16_t delay_csec;
if (bts->pcu->vty.force_llc_lifetime)
@ -241,8 +240,7 @@ void gprs_llc_queue::calc_pdu_lifetime(struct gprs_rlcmac_bts *bts, const uint16
timespecadd(&now, &csec, tv);
}
bool gprs_llc_queue::is_frame_expired(const struct timespec *tv_now,
const struct timespec *tv)
bool llc_queue_is_frame_expired(const struct timespec *tv_now, const struct timespec *tv)
{
/* Timeout is infinite */
if (tv->tv_sec == 0 && tv->tv_nsec == 0)

@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 by Holger Hans Peter Freyther
* Copyright (C) 2022 by by Sysmocom s.f.m.c. GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -16,16 +17,15 @@
#ifdef __cplusplus
extern "C" {
#endif
#include <osmocom/core/linuxlist.h>
#ifdef __cplusplus
}
#endif
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/msgb.h>
#define LLC_MAX_LEN 1543
struct gprs_rlcmac_bts;
@ -34,23 +34,19 @@ struct gprs_rlcmac_bts;
* I represent the LLC data to a MS
*/
struct gprs_llc {
#ifdef __cplusplus
static bool is_user_data_frame(uint8_t *data, size_t len);
void init();
void reset();
void reset_frame_space();
void put_frame(const uint8_t *data, size_t len);
void put_dummy_frame(size_t req_len);
void append_frame(const uint8_t *data, size_t len);
#endif
uint8_t frame[LLC_MAX_LEN]; /* current DL or UL frame */
uint16_t index; /* current write/read position of frame */
uint16_t length; /* len of current DL LLC_frame, 0 == no frame */
};
bool llc_is_user_data_frame(const uint8_t *data, size_t len);
void llc_init(struct gprs_llc *llc);
void llc_reset(struct gprs_llc *llc);
void llc_reset_frame_space(struct gprs_llc *llc);
void llc_put_frame(struct gprs_llc *llc, const uint8_t *data, size_t len);
void llc_put_dummy_frame(struct gprs_llc *llc, size_t req_len);
void llc_append_frame(struct gprs_llc *llc, const uint8_t *data, size_t len);
struct MetaInfo {
struct timespec recv_time;
@ -60,28 +56,21 @@ struct MetaInfo {
* I store the LLC frames that come from the SGSN.
*/
struct gprs_llc_queue {
#ifdef __cplusplus
static void calc_pdu_lifetime(struct gprs_rlcmac_bts *bts, const uint16_t pdu_delay_csec,
struct timespec *tv);
static bool is_frame_expired(const struct timespec *now,
const struct timespec *tv);
static bool is_user_data_frame(uint8_t *data, size_t len);
void enqueue(struct msgb *llc_msg, const struct timespec *expire_time);
struct msgb *dequeue(const MetaInfo **info = 0);
#endif
uint32_t avg_queue_delay; /* Average delay of data going through the queue */
size_t queue_size;
size_t queue_octets;
struct llist_head queue; /* queued LLC DL data */
};
#ifdef __cplusplus
extern "C" {
#endif
void llc_queue_calc_pdu_lifetime(struct gprs_rlcmac_bts *bts, const uint16_t pdu_delay_csec,
struct timespec *tv);
bool llc_queue_is_frame_expired(const struct timespec *tv_now, const struct timespec *tv);
void llc_queue_init(struct gprs_llc_queue *q);
void llc_queue_clear(struct gprs_llc_queue *q, struct gprs_rlcmac_bts *bts);
void llc_queue_move_and_merge(struct gprs_llc_queue *q, struct gprs_llc_queue *o);
void llc_queue_enqueue(struct gprs_llc_queue *q, struct msgb *llc_msg, const struct timespec *expire_time);
struct msgb *llc_queue_dequeue(struct gprs_llc_queue *q, const struct MetaInfo **info);
static inline uint16_t llc_chunk_size(const struct gprs_llc *llc)
{

@ -130,7 +130,7 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(struct gprs_rlcmac_bts *bts_, GprsMs *ms, gprs_
OSMO_ASSERT(dl_ass_fsm.fi);
m_rlc.init();
m_llc.init();
llc_init(&m_llc);
m_name_buf[0] = '\0';

@ -217,9 +217,9 @@ int gprs_rlcmac_dl_tbf::append_data(uint16_t pdu_delay_csec,
if (!llc_msg)
return -ENOMEM;
gprs_llc_queue::calc_pdu_lifetime(bts, pdu_delay_csec, &expire_time);
llc_queue_calc_pdu_lifetime(bts, pdu_delay_csec, &expire_time);
memcpy(msgb_put(llc_msg, len), data, len);
llc_queue()->enqueue(llc_msg, &expire_time);
llc_queue_enqueue(llc_queue(), llc_msg, &expire_time);
start_llc_timer();
if (state_is(TBF_ST_WAIT_RELEASE)) {
@ -358,7 +358,7 @@ struct msgb *gprs_rlcmac_dl_tbf::llc_dequeue(bssgp_bvc_ctx *bctx)
osmo_clock_gettime(CLOCK_MONOTONIC, &tv_now);
timespecadd(&tv_now, &hyst_delta, &tv_now2);
while ((msg = llc_queue()->dequeue(&info))) {
while ((msg = llc_queue_dequeue(llc_queue(), &info))) {
const struct timespec *tv_disc = &info->expire_time;
const struct timespec *tv_recv = &info->recv_time;
@ -372,11 +372,11 @@ struct msgb *gprs_rlcmac_dl_tbf::llc_dequeue(bssgp_bvc_ctx *bctx)
}
/* Is the age below the low water mark? */
if (!gprs_llc_queue::is_frame_expired(&tv_now2, tv_disc))
if (!llc_queue_is_frame_expired(&tv_now2, tv_disc))
break;
/* Is the age below the high water mark */
if (!gprs_llc_queue::is_frame_expired(&tv_now, tv_disc)) {
if (!llc_queue_is_frame_expired(&tv_now, tv_disc)) {
/* Has the previous message not been dropped? */
if (frames == 0)
break;
@ -391,7 +391,7 @@ struct msgb *gprs_rlcmac_dl_tbf::llc_dequeue(bssgp_bvc_ctx *bctx)
break;
/* Is it a GMM message? */
if (!gprs_llc::is_user_data_frame(msg->data, msg->len))
if (!llc_is_user_data_frame(msg->data, msg->len))
break;
}
@ -634,7 +634,7 @@ void gprs_rlcmac_dl_tbf::schedule_next_frame()
LOGPTBFDL(this, LOGL_DEBUG, "Dequeue next LLC (len=%d)\n", msg->len);
m_llc.put_frame(msg->data, msg->len);
llc_put_frame(&m_llc, msg->data, msg->len);
bts_do_rate_ctr_inc(bts, CTR_LLC_FRAME_SCHED);
msgb_free(msg);
m_last_dl_drained_fn = -1;
@ -726,7 +726,7 @@ int gprs_rlcmac_dl_tbf::create_new_bsn(const uint32_t fn, enum CodingScheme cs)
* "Delayed release of downlink Temporary Block Flow" */
/* A header will need to by added, so we just need
* space-1 octets */
m_llc.put_dummy_frame(space - 1);
llc_put_dummy_frame(&m_llc, space - 1);
LOGPTBFDL(this, LOGL_DEBUG,
"Empty chunk, added LLC dummy command of size %d, drained_since=%d\n",
@ -747,7 +747,7 @@ int gprs_rlcmac_dl_tbf::create_new_bsn(const uint32_t fn, enum CodingScheme cs)
LOGPTBFDL(this, LOGL_DEBUG, "Complete DL frame, len=%d\n", llc_frame_length(&m_llc));
gprs_rlcmac_dl_bw(this, llc_frame_length(&m_llc));
bts_do_rate_ctr_add(bts, CTR_LLC_DL_BYTES, llc_frame_length(&m_llc));
m_llc.reset();
llc_reset(&m_llc);
if (is_final) {
request_dl_ack();

@ -283,7 +283,7 @@ int gprs_rlcmac_ul_tbf::assemble_forward_llc(const gprs_rlc_data *_data)
i + 1, frame->offset, frame->length,
frame->is_complete);
m_llc.append_frame(data + frame->offset, frame->length);
llc_append_frame(&m_llc, data + frame->offset, frame->length);
llc_consume(&m_llc, frame->length);
}
@ -292,7 +292,7 @@ int gprs_rlcmac_ul_tbf::assemble_forward_llc(const gprs_rlc_data *_data)
LOGPTBFUL(this, LOGL_DEBUG, "complete UL frame len=%d\n", llc_frame_length(&m_llc));
snd_ul_ud();
bts_do_rate_ctr_add(bts, CTR_LLC_UL_BYTES, llc_frame_length(&m_llc));
m_llc.reset();
llc_reset(&m_llc);
}
}
@ -544,7 +544,7 @@ int gprs_rlcmac_ul_tbf::snd_ul_ud()
LOGP(DBSSGP, LOGL_INFO, "LLC [PCU -> SGSN] %s len=%d\n", tbf_name(this), llc_frame_length(&m_llc));
if (!bctx) {
LOGP(DBSSGP, LOGL_ERROR, "No bctx\n");
m_llc.reset_frame_space();
llc_reset_frame_space(&m_llc);
return -EIO;
}
@ -556,7 +556,7 @@ int gprs_rlcmac_ul_tbf::snd_ul_ud()
qos_profile[2] = QOS_PROFILE;
bssgp_tx_ul_ud(bctx, tlli(), qos_profile, llc_pdu);
m_llc.reset_frame_space();
llc_reset_frame_space(&m_llc);
return 0;
}

@ -535,7 +535,7 @@ static void test_rlc_unit_encoder()
printf("=== start %s ===\n", __func__);
llc.init();
llc_init(&llc);
/* TS 44.060, B.1 */
cs = CS4;
@ -544,8 +544,8 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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 @@ static void test_rlc_unit_encoder()
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,

@ -56,7 +56,7 @@ static void enqueue_data(gprs_llc_queue *queue, const uint8_t *data, size_t len,
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 @@ static void dequeue_and_check(gprs_llc_queue *queue, const uint8_t *exp_data,
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",

@ -58,20 +58,20 @@ static void test_llc(void)
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 @@ static void test_llc(void)
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));
}

Loading…
Cancel
Save