2020-11-26 01:25:22 -08:00
|
|
|
/**
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* \section COPYRIGHT
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2021-03-19 03:45:56 -07:00
|
|
|
* Copyright 2013-2021 Software Radio Systems Limited
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* By using this file, you agree to the terms and conditions set
|
|
|
|
* forth in the LICENSE file which can be found at the top level of
|
|
|
|
* the distribution.
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
#include "srsran/common/test_common.h"
|
2021-06-28 03:21:44 -07:00
|
|
|
#include "srsran/rlc/rlc_um_lte.h"
|
2019-10-23 02:53:00 -07:00
|
|
|
#include <iostream>
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
// Fixed header only
|
2019-12-16 07:04:22 -08:00
|
|
|
uint8_t pdu1[] = {0x18, 0xE2};
|
2017-05-18 03:52:29 -07:00
|
|
|
uint32_t PDU1_LEN = 2;
|
|
|
|
|
|
|
|
// Fixed + 1 LI field (value 104)
|
2019-12-16 07:04:22 -08:00
|
|
|
uint8_t pdu2[] = {0x1C, 0xE1, 0x06, 0x80};
|
2017-05-18 03:52:29 -07:00
|
|
|
uint32_t PDU2_LEN = 4;
|
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2021-02-10 04:16:53 -08:00
|
|
|
srslog::init();
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
srsran::rlc_umd_pdu_header_t h;
|
|
|
|
srsran::byte_buffer_t b1, b2;
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
memcpy(b1.msg, &pdu1[0], PDU1_LEN);
|
|
|
|
b1.N_bytes = PDU1_LEN;
|
2021-03-19 03:45:56 -07:00
|
|
|
rlc_um_read_data_pdu_header(&b1, srsran::rlc_umd_sn_size_t::size10bits, &h);
|
2021-01-26 10:15:28 -08:00
|
|
|
TESTASSERT(0x03 == h.fi);
|
|
|
|
TESTASSERT(0 == h.N_li);
|
|
|
|
TESTASSERT(226 == h.sn);
|
2017-05-18 03:52:29 -07:00
|
|
|
rlc_um_write_data_pdu_header(&h, &b2);
|
2021-01-26 10:15:28 -08:00
|
|
|
TESTASSERT(b2.N_bytes == PDU1_LEN);
|
2019-12-16 07:04:22 -08:00
|
|
|
for (uint32_t i = 0; i < b2.N_bytes; i++)
|
2021-01-26 10:15:28 -08:00
|
|
|
TESTASSERT(b2.msg[i] == b1.msg[i]);
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2019-05-13 07:53:33 -07:00
|
|
|
b1.clear();
|
|
|
|
b2.clear();
|
2021-03-19 03:45:56 -07:00
|
|
|
memset(&h, 0, sizeof(srsran::rlc_umd_pdu_header_t));
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
memcpy(b1.msg, &pdu2[0], PDU2_LEN);
|
|
|
|
b1.N_bytes = PDU2_LEN;
|
2021-03-19 03:45:56 -07:00
|
|
|
rlc_um_read_data_pdu_header(&b1, srsran::rlc_umd_sn_size_t::size10bits, &h);
|
2021-01-26 10:15:28 -08:00
|
|
|
TESTASSERT(0x03 == h.fi);
|
|
|
|
TESTASSERT(225 == h.sn);
|
|
|
|
TESTASSERT(1 == h.N_li);
|
|
|
|
TESTASSERT(104 == h.li[0]);
|
2017-05-18 03:52:29 -07:00
|
|
|
rlc_um_write_data_pdu_header(&h, &b2);
|
2021-01-26 10:15:28 -08:00
|
|
|
TESTASSERT(b2.N_bytes == PDU2_LEN);
|
2019-12-16 07:04:22 -08:00
|
|
|
for (uint32_t i = 0; i < b2.N_bytes; i++)
|
2021-01-26 10:15:28 -08:00
|
|
|
TESTASSERT(b2.msg[i] == b1.msg[i]);
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|