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.
138 lines
3.7 KiB
C
138 lines
3.7 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_PDCP_BASE_TEST_H
|
||
|
#define SRSRAN_PDCP_BASE_TEST_H
|
||
5 years ago
|
|
||
4 years ago
|
#include "srsran/common/buffer_pool.h"
|
||
|
#include "srsran/common/security.h"
|
||
|
#include "srsran/common/test_common.h"
|
||
|
#include "srsran/interfaces/pdcp_interface_types.h"
|
||
|
#include "srsran/interfaces/ue_gw_interfaces.h"
|
||
|
#include "srsran/interfaces/ue_interfaces.h"
|
||
|
#include "srsran/interfaces/ue_rlc_interfaces.h"
|
||
5 years ago
|
#include <iostream>
|
||
|
|
||
4 years ago
|
int compare_two_packets(const srsran::unique_byte_buffer_t& msg1, const srsran::unique_byte_buffer_t& msg2)
|
||
5 years ago
|
{
|
||
|
TESTASSERT(msg1->N_bytes == msg2->N_bytes);
|
||
5 years ago
|
TESTASSERT(memcmp(msg1->msg, msg2->msg, msg1->N_bytes) == 0);
|
||
5 years ago
|
return 0;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
* Dummy classes
|
||
|
*/
|
||
|
class rlc_dummy : public srsue::rlc_interface_pdcp
|
||
|
{
|
||
|
public:
|
||
4 years ago
|
explicit rlc_dummy(srslog::basic_logger& logger) : logger(logger) {}
|
||
5 years ago
|
|
||
4 years ago
|
void get_last_sdu(const srsran::unique_byte_buffer_t& pdu)
|
||
5 years ago
|
{
|
||
|
memcpy(pdu->msg, last_pdcp_pdu->msg, last_pdcp_pdu->N_bytes);
|
||
|
pdu->N_bytes = last_pdcp_pdu->N_bytes;
|
||
|
}
|
||
4 years ago
|
void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu)
|
||
5 years ago
|
{
|
||
4 years ago
|
logger.info(sdu->msg, sdu->N_bytes, "RLC SDU");
|
||
5 years ago
|
last_pdcp_pdu.swap(sdu);
|
||
|
rx_count++;
|
||
|
}
|
||
|
void discard_sdu(uint32_t lcid, uint32_t discard_sn)
|
||
|
{
|
||
4 years ago
|
logger.info("Notifing RLC to discard SDU (SN=%u)", discard_sn);
|
||
5 years ago
|
discard_count++;
|
||
4 years ago
|
logger.info("Discard_count=%" PRIu64 "", discard_count);
|
||
5 years ago
|
}
|
||
|
|
||
|
uint64_t rx_count = 0;
|
||
|
uint64_t discard_count = 0;
|
||
|
|
||
|
private:
|
||
4 years ago
|
srslog::basic_logger& logger;
|
||
4 years ago
|
srsran::unique_byte_buffer_t last_pdcp_pdu;
|
||
5 years ago
|
|
||
|
bool rb_is_um(uint32_t lcid) { return false; }
|
||
5 years ago
|
bool sdu_queue_is_full(uint32_t lcid) { return false; };
|
||
5 years ago
|
};
|
||
|
|
||
|
class rrc_dummy : public srsue::rrc_interface_pdcp
|
||
|
{
|
||
|
public:
|
||
4 years ago
|
explicit rrc_dummy(srslog::basic_logger& logger) : logger(logger) {}
|
||
5 years ago
|
|
||
4 years ago
|
void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) {}
|
||
|
void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) {}
|
||
|
void write_pdu_pcch(srsran::unique_byte_buffer_t pdu) {}
|
||
|
void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {}
|
||
4 years ago
|
void notify_pdcp_integrity_error(uint32_t lcid) {}
|
||
5 years ago
|
|
||
4 years ago
|
const char* get_rb_name(uint32_t lcid) { return "None"; }
|
||
5 years ago
|
|
||
4 years ago
|
srslog::basic_logger& logger;
|
||
5 years ago
|
|
||
|
// Members for testing
|
||
5 years ago
|
uint32_t rx_count = 0;
|
||
4 years ago
|
srsran::unique_byte_buffer_t last_pdu;
|
||
5 years ago
|
|
||
|
// Methods for testing
|
||
4 years ago
|
void get_last_pdu(const srsran::unique_byte_buffer_t& pdu)
|
||
5 years ago
|
{
|
||
|
memcpy(pdu->msg, last_pdu->msg, last_pdu->N_bytes);
|
||
|
pdu->N_bytes = last_pdu->N_bytes;
|
||
|
}
|
||
|
|
||
4 years ago
|
void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
|
||
5 years ago
|
{
|
||
4 years ago
|
logger.info(pdu->msg, pdu->N_bytes, "RRC PDU");
|
||
5 years ago
|
rx_count++;
|
||
|
last_pdu.swap(pdu);
|
||
|
}
|
||
5 years ago
|
};
|
||
|
|
||
|
class gw_dummy : public srsue::gw_interface_pdcp
|
||
|
{
|
||
|
public:
|
||
4 years ago
|
explicit gw_dummy(srslog::basic_logger& logger) : logger(logger) {}
|
||
5 years ago
|
|
||
4 years ago
|
void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {}
|
||
5 years ago
|
uint32_t rx_count = 0;
|
||
|
|
||
4 years ago
|
void get_last_pdu(const srsran::unique_byte_buffer_t& pdu)
|
||
5 years ago
|
{
|
||
|
memcpy(pdu->msg, last_pdu->msg, last_pdu->N_bytes);
|
||
|
pdu->N_bytes = last_pdu->N_bytes;
|
||
|
}
|
||
4 years ago
|
void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
|
||
5 years ago
|
{
|
||
4 years ago
|
logger.info(pdu->msg, pdu->N_bytes, "GW PDU");
|
||
5 years ago
|
rx_count++;
|
||
|
last_pdu.swap(pdu);
|
||
|
}
|
||
|
|
||
|
private:
|
||
4 years ago
|
srslog::basic_logger& logger;
|
||
4 years ago
|
srsran::unique_byte_buffer_t last_pdu;
|
||
5 years ago
|
};
|
||
|
|
||
|
// Helper to print packets
|
||
4 years ago
|
void print_packet_array(const srsran::unique_byte_buffer_t& msg)
|
||
5 years ago
|
{
|
||
|
printf("uint8_t msg[] = {\n");
|
||
|
for (uint64_t i = 0; i < msg->N_bytes; ++i) {
|
||
|
printf("0x%02x, ", msg->msg[i]);
|
||
|
}
|
||
|
printf("\n};\n");
|
||
|
}
|
||
4 years ago
|
#endif // SRSRAN_PDCP_BASE_TEST_H
|