Clang-formated to prepare for PR

This commit is contained in:
Pedro Alvarez 2019-10-14 17:39:02 +01:00 committed by Andre Puschmann
parent d3a07fdd38
commit 8511fca940
6 changed files with 182 additions and 187 deletions

View File

@ -56,7 +56,7 @@
#define TTI_RX_ACK(tti) (TTI_ADD(tti, FDD_HARQ_DELAY_MS + TX_DELAY)) #define TTI_RX_ACK(tti) (TTI_ADD(tti, FDD_HARQ_DELAY_MS + TX_DELAY))
#define TTIMOD_SZ 20 #define TTIMOD_SZ 20
#define TTIMOD(tti) (tti%TTIMOD_SZ) #define TTIMOD(tti) (tti % TTIMOD_SZ)
#define PHICH_MAX_SF 6 // Maximum PHICH in a subframe (1 in FDD, > 1 in TDD, see table 9.1.2-1 36.213) #define PHICH_MAX_SF 6 // Maximum PHICH in a subframe (1 in FDD, > 1 in TDD, see table 9.1.2-1 36.213)
@ -172,7 +172,7 @@ public:
#endif #endif
} }
void append_bytes(uint8_t *buf, uint32_t size) void append_bytes(uint8_t* buf, uint32_t size)
{ {
memcpy(&msg[N_bytes], buf, size); memcpy(&msg[N_bytes], buf, size);
N_bytes += size; N_bytes += size;

View File

@ -22,8 +22,8 @@
#ifndef SRSLTE_INTERFACES_COMMON_H #ifndef SRSLTE_INTERFACES_COMMON_H
#define SRSLTE_INTERFACES_COMMON_H #define SRSLTE_INTERFACES_COMMON_H
#include "srslte/common/timers.h"
#include "srslte/common/security.h" #include "srslte/common/security.h"
#include "srslte/common/timers.h"
#include <string> #include <string>
namespace srslte { namespace srslte {
@ -60,9 +60,7 @@ typedef struct {
class srslte_gw_config_t class srslte_gw_config_t
{ {
public: public:
srslte_gw_config_t(uint32_t lcid_ = 0) srslte_gw_config_t(uint32_t lcid_ = 0) : lcid(lcid_) {}
:lcid(lcid_)
{}
uint32_t lcid; uint32_t lcid;
}; };
@ -153,9 +151,9 @@ public:
class read_pdu_interface class read_pdu_interface
{ {
public: public:
virtual int read_pdu(uint32_t lcid, uint8_t *payload, uint32_t requested_bytes) = 0; virtual int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) = 0;
}; };
} } // namespace srslte
#endif // SRSLTE_INTERFACES_COMMON_H #endif // SRSLTE_INTERFACES_COMMON_H

View File

@ -114,6 +114,7 @@ class pdcp_entity_nr::reordering_callback : public timer_callback
public: public:
reordering_callback(pdcp_entity_nr* parent_) { parent = parent_; }; reordering_callback(pdcp_entity_nr* parent_) { parent = parent_; };
virtual void timer_expired(uint32_t timer_id) final; virtual void timer_expired(uint32_t timer_id) final;
private: private:
pdcp_entity_nr* parent; pdcp_entity_nr* parent;
}; };

View File

@ -188,7 +188,7 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu)
} }
// Handle reordering timers // Handle reordering timers
if(reordering_timer->is_running() and rx_deliv >= rx_reord){ if (reordering_timer->is_running() and rx_deliv >= rx_reord) {
reordering_timer->stop(); reordering_timer->stop();
reordering_timer->reset(); reordering_timer->reset();
} }
@ -294,8 +294,7 @@ void pdcp_entity_nr::deliver_all_consecutive_counts()
{ {
for (std::map<uint32_t, unique_byte_buffer_t>::iterator it = reorder_queue.begin(); for (std::map<uint32_t, unique_byte_buffer_t>::iterator it = reorder_queue.begin();
it != reorder_queue.end() && it->first == rx_deliv; it != reorder_queue.end() && it->first == rx_deliv;
reorder_queue.erase(it++)) reorder_queue.erase(it++)) {
{
log->debug("Delivering SDU with RCVD_COUNT %" PRIu32 "\n", it->first); log->debug("Delivering SDU with RCVD_COUNT %" PRIu32 "\n", it->first);
// Check RX_DELIV overflow // Check RX_DELIV overflow
@ -312,7 +311,6 @@ void pdcp_entity_nr::deliver_all_consecutive_counts()
// Update RX_DELIV // Update RX_DELIV
rx_deliv = rx_deliv + 1; rx_deliv = rx_deliv + 1;
} }
} }
@ -331,7 +329,7 @@ void pdcp_entity_nr::reordering_callback::timer_expired(uint32_t timer_id)
// Deliver all PDCP SDU(s) consecutivly associeted COUNT value(s) starting from RX_REORD // Deliver all PDCP SDU(s) consecutivly associeted COUNT value(s) starting from RX_REORD
parent->deliver_all_consecutive_counts(); parent->deliver_all_consecutive_counts();
if (parent->rx_deliv < parent->rx_next){ if (parent->rx_deliv < parent->rx_next) {
parent->rx_reord = parent->rx_next; parent->rx_reord = parent->rx_next;
parent->reordering_timer->run(); parent->reordering_timer->run();
} }

View File

@ -37,7 +37,6 @@ pdcp_security_cfg sec_cfg = {
srslte::CIPHERING_ALGORITHM_ID_128_EEA2, srslte::CIPHERING_ALGORITHM_ID_128_EEA2,
}; };
// Test SDUs for tx // Test SDUs for tx
uint8_t sdu1[] = {0x18, 0xe2}; uint8_t sdu1[] = {0x18, 0xe2};
uint8_t sdu2[] = {0xde, 0xad}; uint8_t sdu2[] = {0xde, 0xad};
@ -55,7 +54,6 @@ uint8_t pdu1_count4294967295_snlen18[] = {0x83, 0xff, 0xff, 0x1e, 0x47, 0xe6, 0x
// Test PDUs for rx (generated from SDU2) // Test PDUs for rx (generated from SDU2)
uint8_t pdu2_count1_snlen12[] = {0x80, 0x01, 0x5e, 0x3d, 0x64, 0xaf, 0xac, 0x7c}; uint8_t pdu2_count1_snlen12[] = {0x80, 0x01, 0x5e, 0x3d, 0x64, 0xaf, 0xac, 0x7c};
// This is the normal initial state. All state variables are set to zero // This is the normal initial state. All state variables are set to zero
pdcp_initial_state normal_init_state = {}; pdcp_initial_state normal_init_state = {};
@ -143,7 +141,7 @@ int test_rx_in_sequence(std::vector<srslte::unique_byte_buffer_t> pdus,
gw_rx->get_last_pdu(sdu_act); gw_rx->get_last_pdu(sdu_act);
// Check if resulting SDU matches original SDU // Check if resulting SDU matches original SDU
TESTASSERT(compare_two_packets(sdu_exp,sdu_act) == 0); TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0);
} }
// Test if the number of RX packets // Test if the number of RX packets
@ -154,7 +152,10 @@ int test_rx_in_sequence(std::vector<srslte::unique_byte_buffer_t> pdus,
/* /*
* Genric function to test reception of a single out-of-order packet * Genric function to test reception of a single out-of-order packet
*/ */
int test_rx_out_of_order(pdcp_initial_state init_state, uint8_t pdcp_sn_len, srslte::byte_buffer_pool* pool, srslte::log* log) int test_rx_out_of_order(pdcp_initial_state init_state,
uint8_t pdcp_sn_len,
srslte::byte_buffer_pool* pool,
srslte::log* log)
{ {
srslte::pdcp_config_t cfg_tx = {1, srslte::pdcp_config_t cfg_tx = {1,
@ -248,7 +249,7 @@ int test_rx_out_of_order_timeout(uint8_t pdcp_sn_len, srslte::byte_buffer_pool*
TESTASSERT(gw_rx->rx_count == 0); TESTASSERT(gw_rx->rx_count == 0);
// Trigger timer // Trigger timer
for (uint16_t i = 0; i < 500; ++i){ for (uint16_t i = 0; i < 500; ++i) {
timers->step_all(); timers->step_all();
} }
@ -425,8 +426,7 @@ int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
std::vector<srslte::unique_byte_buffer_t> test1_pdus = std::vector<srslte::unique_byte_buffer_t> test1_pdus =
gen_expected_pdus_vector(tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_12, sec_cfg, pool, log); gen_expected_pdus_vector(tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_12, sec_cfg, pool, log);
pdcp_initial_state test1_init_state = {.tx_next = 4095, .rx_next = 4095, .rx_deliv = 4095, .rx_reord = 0}; pdcp_initial_state test1_init_state = {.tx_next = 4095, .rx_next = 4095, .rx_deliv = 4095, .rx_reord = 0};
TESTASSERT(test_rx_in_sequence(std::move(test1_pdus), test1_init_state, srslte::PDCP_SN_LEN_12, 2, pool, log) == TESTASSERT(test_rx_in_sequence(std::move(test1_pdus), test1_init_state, srslte::PDCP_SN_LEN_12, 2, pool, log) == 0);
0);
} }
/* /*
* RX Test 2: PDCP Entity with SN LEN = 12 * RX Test 2: PDCP Entity with SN LEN = 12
@ -441,8 +441,7 @@ int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
gen_expected_pdus_vector(tst_sdu1, test2_counts, srslte::PDCP_SN_LEN_12, sec_cfg, pool, log); gen_expected_pdus_vector(tst_sdu1, test2_counts, srslte::PDCP_SN_LEN_12, sec_cfg, pool, log);
pdcp_initial_state test2_init_state = { pdcp_initial_state test2_init_state = {
.tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0}; .tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0};
TESTASSERT(test_rx_in_sequence(std::move(test2_pdus), test2_init_state, srslte::PDCP_SN_LEN_12, 1, pool, log) == TESTASSERT(test_rx_in_sequence(std::move(test2_pdus), test2_init_state, srslte::PDCP_SN_LEN_12, 1, pool, log) == 0);
0);
} }
/* /*
* RX Test 3: PDCP Entity with SN LEN = 18 * RX Test 3: PDCP Entity with SN LEN = 18
@ -455,8 +454,7 @@ int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
std::vector<srslte::unique_byte_buffer_t> test3_pdus = std::vector<srslte::unique_byte_buffer_t> test3_pdus =
gen_expected_pdus_vector(tst_sdu1, test3_counts, srslte::PDCP_SN_LEN_18, sec_cfg, pool, log); gen_expected_pdus_vector(tst_sdu1, test3_counts, srslte::PDCP_SN_LEN_18, sec_cfg, pool, log);
pdcp_initial_state test3_init_state = {.tx_next = 262144, .rx_next = 262144, .rx_deliv = 262144, .rx_reord = 0}; pdcp_initial_state test3_init_state = {.tx_next = 262144, .rx_next = 262144, .rx_deliv = 262144, .rx_reord = 0};
TESTASSERT(test_rx_in_sequence(std::move(test3_pdus), test3_init_state, srslte::PDCP_SN_LEN_18, 2, pool, log) == TESTASSERT(test_rx_in_sequence(std::move(test3_pdus), test3_init_state, srslte::PDCP_SN_LEN_18, 2, pool, log) == 0);
0);
} }
/* /*
@ -469,9 +467,9 @@ int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
std::iota(test4_counts.begin(), test4_counts.end(), 4294967295); // Starting at COUNT 4294967295 std::iota(test4_counts.begin(), test4_counts.end(), 4294967295); // Starting at COUNT 4294967295
std::vector<srslte::unique_byte_buffer_t> test4_pdus = std::vector<srslte::unique_byte_buffer_t> test4_pdus =
gen_expected_pdus_vector(tst_sdu1, test4_counts, srslte::PDCP_SN_LEN_18, sec_cfg, pool, log); gen_expected_pdus_vector(tst_sdu1, test4_counts, srslte::PDCP_SN_LEN_18, sec_cfg, pool, log);
pdcp_initial_state test4_init_state = {.tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0}; pdcp_initial_state test4_init_state = {
TESTASSERT(test_rx_in_sequence(std::move(test4_pdus), test4_init_state, srslte::PDCP_SN_LEN_18, 1, pool, log) == .tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0};
0); TESTASSERT(test_rx_in_sequence(std::move(test4_pdus), test4_init_state, srslte::PDCP_SN_LEN_18, 1, pool, log) == 0);
} }
/* /*
@ -487,20 +485,19 @@ int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
pdu2->append_bytes(pdu2_count1_snlen12, sizeof(pdu2_count1_snlen12)); pdu2->append_bytes(pdu2_count1_snlen12, sizeof(pdu2_count1_snlen12));
test5_pdus.push_back(std::move(pdu2)); test5_pdus.push_back(std::move(pdu2));
test5_pdus.push_back(std::move(pdu1)); test5_pdus.push_back(std::move(pdu1));
TESTASSERT(test_rx_in_sequence(std::move(test5_pdus), test5_init_state, srslte::PDCP_SN_LEN_12, 2, pool, log) == TESTASSERT(test_rx_in_sequence(std::move(test5_pdus), test5_init_state, srslte::PDCP_SN_LEN_12, 2, pool, log) == 0);
0);
} }
/* /*
* RX Test 5: PDCP Entity with SN LEN = 12 * RX Test 5: PDCP Entity with SN LEN = 12
* Test Reception of one out-of-order packet. * Test Reception of one out-of-order packet.
*/ */
//TESTASSERT(test_rx_out_of_order(normal_init_state, srslte::PDCP_SN_LEN_12, pool, log) == 0); // TESTASSERT(test_rx_out_of_order(normal_init_state, srslte::PDCP_SN_LEN_12, pool, log) == 0);
/* /*
* RX Test 6: PDCP Entity with SN LEN = 12 * RX Test 6: PDCP Entity with SN LEN = 12
* Test Reception of one out-of-order packet at COUNT wraparound. * Test Reception of one out-of-order packet at COUNT wraparound.
*/ */
//TESTASSERT(test_rx_out_of_order(near_wraparound_init_state, srslte::PDCP_SN_LEN_12, pool, log) == 0); // TESTASSERT(test_rx_out_of_order(near_wraparound_init_state, srslte::PDCP_SN_LEN_12, pool, log) == 0);
/* /*
* RX Test 5: PDCP Entity with SN LEN = 12 * RX Test 5: PDCP Entity with SN LEN = 12
@ -524,7 +521,7 @@ int run_all_tests(srslte::byte_buffer_pool* pool)
log.set_level(srslte::LOG_LEVEL_DEBUG); log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(128); log.set_hex_limit(128);
//TESTASSERT(test_tx_all(pool, &log) == 0); // TESTASSERT(test_tx_all(pool, &log) == 0);
TESTASSERT(test_rx_all(pool, &log) == 0); TESTASSERT(test_rx_all(pool, &log) == 0);
// Helpers for generating expected PDUs // Helpers for generating expected PDUs

View File

@ -45,19 +45,20 @@ int compare_two_packets(const srslte::unique_byte_buffer_t& msg1, const srslte::
return 0; return 0;
} }
void print_packet_array(const srslte::unique_byte_buffer_t &msg){ void print_packet_array(const srslte::unique_byte_buffer_t& msg)
{
printf("uint8_t msg[] = {\n"); printf("uint8_t msg[] = {\n");
for (uint64_t i = 0; i < msg->N_bytes; ++i){ for (uint64_t i = 0; i < msg->N_bytes; ++i) {
printf("0x%02x, ",msg->msg[i]); printf("0x%02x, ", msg->msg[i]);
} }
printf("\n};\n"); printf("\n};\n");
} }
struct pdcp_security_cfg { struct pdcp_security_cfg {
uint8_t *k_int_rrc; uint8_t* k_int_rrc;
uint8_t *k_enc_rrc; uint8_t* k_enc_rrc;
uint8_t *k_int_up; uint8_t* k_int_up;
uint8_t *k_enc_up; uint8_t* k_enc_up;
srslte::INTEGRITY_ALGORITHM_ID_ENUM int_algo; srslte::INTEGRITY_ALGORITHM_ID_ENUM int_algo;
srslte::CIPHERING_ALGORITHM_ID_ENUM enc_algo; srslte::CIPHERING_ALGORITHM_ID_ENUM enc_algo;
}; };
@ -109,7 +110,6 @@ public:
void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {} void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {}
std::string get_rb_name(uint32_t lcid) { return "None"; } std::string get_rb_name(uint32_t lcid) { return "None"; }
}; };
class gw_dummy : public srsue::gw_interface_pdcp class gw_dummy : public srsue::gw_interface_pdcp
@ -159,7 +159,8 @@ public:
pdcp.enable_encryption(); pdcp.enable_encryption();
} }
void set_pdcp_initial_state(pdcp_initial_state init_state) { void set_pdcp_initial_state(pdcp_initial_state init_state)
{
pdcp.set_tx_next(init_state.tx_next); pdcp.set_tx_next(init_state.tx_next);
pdcp.set_rx_next(init_state.rx_next); pdcp.set_rx_next(init_state.rx_next);
pdcp.set_rx_deliv(init_state.rx_deliv); pdcp.set_rx_deliv(init_state.rx_deliv);