mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.2 KiB
C
73 lines
2.2 KiB
C
4 years ago
|
/**
|
||
5 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
5 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
5 years ago
|
*
|
||
4 years ago
|
* 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.
|
||
5 years ago
|
*
|
||
|
*/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_RLC_TEST_COMMON_H
|
||
|
#define SRSRAN_RLC_TEST_COMMON_H
|
||
5 years ago
|
|
||
4 years ago
|
#include "srsran/common/byte_buffer.h"
|
||
|
#include "srsran/interfaces/ue_pdcp_interfaces.h"
|
||
|
#include "srsran/interfaces/ue_rrc_interfaces.h"
|
||
5 years ago
|
#include <vector>
|
||
|
|
||
4 years ago
|
namespace srsran {
|
||
5 years ago
|
|
||
|
class rlc_um_tester : public srsue::pdcp_interface_rlc, public srsue::rrc_interface_rlc
|
||
|
{
|
||
|
public:
|
||
|
rlc_um_tester() {}
|
||
|
|
||
|
// PDCP interface
|
||
|
void write_pdu(uint32_t lcid, unique_byte_buffer_t sdu)
|
||
|
{
|
||
5 years ago
|
// check length
|
||
5 years ago
|
if (lcid != 3 && sdu->N_bytes != expected_sdu_len) {
|
||
|
printf("Received PDU with size %d, expected %d. Exiting.\n", sdu->N_bytes, expected_sdu_len);
|
||
|
exit(-1);
|
||
|
}
|
||
5 years ago
|
|
||
|
// check content
|
||
|
uint8_t first_byte = *sdu->msg;
|
||
|
for (uint32_t i = 0; i < sdu->N_bytes; i++) {
|
||
|
if (sdu->msg[i] != first_byte) {
|
||
|
printf("Received corrupted SDU with size %d. Exiting.\n", sdu->N_bytes);
|
||
4 years ago
|
srsran_vec_fprint_byte(stdout, sdu->msg, sdu->N_bytes);
|
||
5 years ago
|
exit(-1);
|
||
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
// srsran_vec_fprint_byte(stdout, sdu->msg, sdu->N_bytes);
|
||
5 years ago
|
sdus.push_back(std::move(sdu));
|
||
|
}
|
||
|
void write_pdu_bcch_bch(unique_byte_buffer_t sdu) {}
|
||
|
void write_pdu_bcch_dlsch(unique_byte_buffer_t sdu) {}
|
||
|
void write_pdu_pcch(unique_byte_buffer_t sdu) {}
|
||
4 years ago
|
void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { sdus.push_back(std::move(sdu)); }
|
||
|
void notify_delivery(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) {}
|
||
|
void notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) {}
|
||
5 years ago
|
|
||
|
// RRC interface
|
||
|
void max_retx_attempted() {}
|
||
3 years ago
|
void protocol_failure() {}
|
||
4 years ago
|
const char* get_rb_name(uint32_t lcid) { return ""; }
|
||
5 years ago
|
void set_expected_sdu_len(uint32_t len) { expected_sdu_len = len; }
|
||
|
|
||
|
uint32_t get_num_sdus() { return sdus.size(); }
|
||
|
|
||
|
// TODO: this should be private
|
||
|
std::vector<unique_byte_buffer_t> sdus;
|
||
|
uint32_t expected_sdu_len = 0;
|
||
|
};
|
||
|
|
||
4 years ago
|
} // namespace srsran
|
||
5 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_RLC_TEST_COMMON_H
|