remove spaces

master
Ismael Gomez 7 years ago
parent 7a02efe0e5
commit c5bc3b11b7

@ -39,7 +39,7 @@ using srslte::byte_buffer_t;
namespace srsue { namespace srsue {
// EMM states (3GPP 24.302 v10.0.0) // EMM states (3GPP 24.302 v10.0.0)
typedef enum { typedef enum {
EMM_STATE_NULL = 0, EMM_STATE_NULL = 0,
EMM_STATE_DEREGISTERED, EMM_STATE_DEREGISTERED,
EMM_STATE_REGISTERED_INITIATED, EMM_STATE_REGISTERED_INITIATED,
@ -48,8 +48,8 @@ namespace srsue {
EMM_STATE_DEREGISTERED_INITIATED, EMM_STATE_DEREGISTERED_INITIATED,
EMM_STATE_TAU_INITIATED, EMM_STATE_TAU_INITIATED,
EMM_STATE_N_ITEMS, EMM_STATE_N_ITEMS,
} emm_state_t; } emm_state_t;
static const char emm_state_text[EMM_STATE_N_ITEMS][100] = {"NULL", static const char emm_state_text[EMM_STATE_N_ITEMS][100] = {"NULL",
"DEREGISTERED", "DEREGISTERED",
"REGISTERED INITIATED", "REGISTERED INITIATED",
"REGISTERED", "REGISTERED",
@ -57,14 +57,14 @@ namespace srsue {
"DEREGISTERED INITIATED", "DEREGISTERED INITIATED",
"TRACKING AREA UPDATE INITIATED"}; "TRACKING AREA UPDATE INITIATED"};
typedef enum { typedef enum {
PLMN_NOT_SELECTED = 0, PLMN_NOT_SELECTED = 0,
PLMN_SELECTED PLMN_SELECTED
} plmn_selection_state_t; } plmn_selection_state_t;
class nas class nas
: public nas_interface_rrc, public nas_interface_ue { : public nas_interface_rrc, public nas_interface_ue {
public: public:
nas(); nas();
void init(usim_interface_nas *usim_, void init(usim_interface_nas *usim_,
@ -96,7 +96,7 @@ namespace srsue {
void deattach_request(); void deattach_request();
private: private:
srslte::byte_buffer_pool *pool; srslte::byte_buffer_pool *pool;
srslte::log *nas_log; srslte::log *nas_log;
rrc_interface_nas *rrc; rrc_interface_nas *rrc;
@ -177,7 +177,7 @@ namespace srsue {
void send_esm_information_response(); void send_esm_information_response();
void gen_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT *msg); void gen_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT *msg);
}; };
} // namespace srsue } // namespace srsue

@ -43,7 +43,7 @@ using srslte::byte_buffer_t;
namespace srsue { namespace srsue {
// RRC states (3GPP 36.331 v10.0.0) // RRC states (3GPP 36.331 v10.0.0)
typedef enum { typedef enum {
RRC_STATE_IDLE = 0, RRC_STATE_IDLE = 0,
RRC_STATE_PLMN_SELECTION, RRC_STATE_PLMN_SELECTION,
RRC_STATE_CELL_SELECTING, RRC_STATE_CELL_SELECTING,
@ -51,21 +51,21 @@ namespace srsue {
RRC_STATE_CONNECTING, RRC_STATE_CONNECTING,
RRC_STATE_CONNECTED, RRC_STATE_CONNECTED,
RRC_STATE_N_ITEMS, RRC_STATE_N_ITEMS,
} rrc_state_t; } rrc_state_t;
static const char rrc_state_text[RRC_STATE_N_ITEMS][100] = {"IDLE", static const char rrc_state_text[RRC_STATE_N_ITEMS][100] = {"IDLE",
"PLMN SELECTION", "PLMN SELECTION",
"CELL SELECTION", "CELL SELECTION",
"CONNECTING", "CONNECTING",
"CONNECTED", "CONNECTED",
"RRC CONNECTED"}; "RRC CONNECTED"};
typedef enum { typedef enum {
SI_ACQUIRE_IDLE = 0, SI_ACQUIRE_IDLE = 0,
SI_ACQUIRE_SIB1, SI_ACQUIRE_SIB1,
SI_ACQUIRE_SIB2 SI_ACQUIRE_SIB2
} si_acquire_state_t; } si_acquire_state_t;
class rrc class rrc
: public rrc_interface_nas, : public rrc_interface_nas,
public rrc_interface_phy, public rrc_interface_phy,
public rrc_interface_mac, public rrc_interface_mac,
@ -74,8 +74,8 @@ namespace srsue {
public rrc_interface_rlc, public rrc_interface_rlc,
public srslte::timer_callback, public srslte::timer_callback,
public thread public thread
{ {
public: public:
rrc(); rrc();
void init(phy_interface_rrc *phy_, void init(phy_interface_rrc *phy_,
@ -100,7 +100,7 @@ namespace srsue {
void liblte_rrc_log(char *str); void liblte_rrc_log(char *str);
private: private:
srslte::byte_buffer_pool *pool; srslte::byte_buffer_pool *pool;
srslte::log *rrc_log; srslte::log *rrc_log;
phy_interface_rrc *phy; phy_interface_rrc *phy;
@ -266,7 +266,7 @@ namespace srsue {
void set_rrc_default(); void set_rrc_default();
}; };
} // namespace srsue } // namespace srsue

@ -40,11 +40,11 @@
namespace srsue { namespace srsue {
phch_recv::phch_recv() { phch_recv::phch_recv() {
running = false; running = false;
} }
void phch_recv::init(srslte::radio_multi *_radio_handler, mac_interface_phy *_mac, rrc_interface_phy *_rrc, void phch_recv::init(srslte::radio_multi *_radio_handler, mac_interface_phy *_mac, rrc_interface_phy *_rrc,
prach *_prach_buffer, srslte::thread_pool *_workers_pool, prach *_prach_buffer, srslte::thread_pool *_workers_pool,
phch_common *_worker_com, srslte::log *_log_h, uint32_t nof_rx_antennas_, uint32_t prio, phch_common *_worker_com, srslte::log *_log_h, uint32_t nof_rx_antennas_, uint32_t prio,
int sync_cpu_affinity) { int sync_cpu_affinity) {
@ -79,9 +79,9 @@ namespace srsue {
} }
} }
void phch_recv::stop() { void phch_recv::stop() {
running = false; running = false;
wait_thread_finish(); wait_thread_finish();
for (uint32_t i = 0; i < nof_rx_antennas; i++) { for (uint32_t i = 0; i < nof_rx_antennas; i++) {
@ -89,13 +89,13 @@ namespace srsue {
free(sf_buffer[i]); free(sf_buffer[i]);
} }
} }
} }
void phch_recv::set_agc_enable(bool enable) { void phch_recv::set_agc_enable(bool enable) {
do_agc = enable; do_agc = enable;
} }
int radio_recv_wrapper_cs(void *h, cf_t *data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t *rx_time) { int radio_recv_wrapper_cs(void *h, cf_t *data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t *rx_time) {
srslte::radio_multi *radio_h = (srslte::radio_multi *) h; srslte::radio_multi *radio_h = (srslte::radio_multi *) h;
if (radio_h->rx_now(data, nsamples, rx_time)) { if (radio_h->rx_now(data, nsamples, rx_time)) {
int offset = nsamples - radio_h->get_tti_len(); int offset = nsamples - radio_h->get_tti_len();
@ -108,18 +108,18 @@ namespace srsue {
} else { } else {
return -1; return -1;
} }
} }
double callback_set_rx_gain(void *h, double gain) { double callback_set_rx_gain(void *h, double gain) {
srslte::radio_multi *radio_handler = (srslte::radio_multi *) h; srslte::radio_multi *radio_handler = (srslte::radio_multi *) h;
return radio_handler->set_rx_gain_th(gain); return radio_handler->set_rx_gain_th(gain);
} }
void phch_recv::set_time_adv_sec(float _time_adv_sec) { void phch_recv::set_time_adv_sec(float _time_adv_sec) {
time_adv_sec = _time_adv_sec; time_adv_sec = _time_adv_sec;
} }
void phch_recv::set_ue_sync_opts(srslte_ue_sync_t *q) { void phch_recv::set_ue_sync_opts(srslte_ue_sync_t *q) {
if (worker_com->args->cfo_integer_enabled) { if (worker_com->args->cfo_integer_enabled) {
srslte_ue_sync_cfo_i_detec_en(q, true); srslte_ue_sync_cfo_i_detec_en(q, true);
} }
@ -145,9 +145,9 @@ namespace srsue {
} }
srslte_sync_set_sss_algorithm(&q->strack, (sss_alg_t) sss_alg); srslte_sync_set_sss_algorithm(&q->strack, (sss_alg_t) sss_alg);
srslte_sync_set_sss_algorithm(&q->sfind, (sss_alg_t) sss_alg); srslte_sync_set_sss_algorithm(&q->sfind, (sss_alg_t) sss_alg);
} }
bool phch_recv::init_cell() { bool phch_recv::init_cell() {
cell_is_set = false; cell_is_set = false;
if (!srslte_ue_mib_init(&ue_mib, cell)) { if (!srslte_ue_mib_init(&ue_mib, cell)) {
if (!srslte_ue_sync_init_multi(&ue_sync, cell, radio_recv_wrapper_cs, nof_rx_antennas, radio_h)) { if (!srslte_ue_sync_init_multi(&ue_sync, cell, radio_recv_wrapper_cs, nof_rx_antennas, radio_h)) {
@ -179,9 +179,9 @@ namespace srsue {
Error("Error setting cell: initiating ue_mib\n"); Error("Error setting cell: initiating ue_mib\n");
} }
return cell_is_set; return cell_is_set;
} }
void phch_recv::free_cell() { void phch_recv::free_cell() {
if (phy_state != IDLE) { if (phy_state != IDLE) {
phy_state = IDLE; phy_state = IDLE;
usleep(2000); usleep(2000);
@ -198,10 +198,10 @@ namespace srsue {
prach_buffer->free_cell(); prach_buffer->free_cell();
cell_is_set = false; cell_is_set = false;
} }
} }
bool phch_recv::cell_search(int force_N_id_2) { bool phch_recv::cell_search(int force_N_id_2) {
uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN];
uint8_t bch_payload_bits[SRSLTE_BCH_PAYLOAD_LEN / 8]; uint8_t bch_payload_bits[SRSLTE_BCH_PAYLOAD_LEN / 8];
@ -297,19 +297,19 @@ namespace srsue {
Warning("Error decoding MIB: Error decoding PBCH\n"); Warning("Error decoding MIB: Error decoding PBCH\n");
return false; return false;
} }
} }
void phch_recv::resync_sfn() { void phch_recv::resync_sfn() {
sync_sfn_cnt = 0; sync_sfn_cnt = 0;
phy_state = CELL_SELECT; phy_state = CELL_SELECT;
} }
void phch_recv::set_earfcn(std::vector<uint32_t> earfcn) { void phch_recv::set_earfcn(std::vector<uint32_t> earfcn) {
this->earfcn = earfcn; this->earfcn = earfcn;
} }
void phch_recv::cell_search_next() { void phch_recv::cell_search_next() {
cell_search_in_progress = true; cell_search_in_progress = true;
cur_earfcn_index++; cur_earfcn_index++;
if (cur_earfcn_index >= 0) { if (cur_earfcn_index >= 0) {
@ -331,9 +331,9 @@ namespace srsue {
log_h->error("Cell Search: Invalid EARFCN=%d, channel_index=%d\n", earfcn[cur_earfcn_index], cur_earfcn_index); log_h->error("Cell Search: Invalid EARFCN=%d, channel_index=%d\n", earfcn[cur_earfcn_index], cur_earfcn_index);
} }
} }
} }
void phch_recv::cell_search_start() { void phch_recv::cell_search_start() {
if (earfcn.size() > 0) { if (earfcn.size() > 0) {
cur_earfcn_index = -1; cur_earfcn_index = -1;
log_h->console("Starting Cell Search procedure in %d EARFCNs...\n", earfcn.size()); log_h->console("Starting Cell Search procedure in %d EARFCNs...\n", earfcn.size());
@ -343,9 +343,9 @@ namespace srsue {
log_h->info("Empty EARFCN list. Stopping cell search...\n"); log_h->info("Empty EARFCN list. Stopping cell search...\n");
log_h->console("Empty EARFCN list. Stopping cell search...\n"); log_h->console("Empty EARFCN list. Stopping cell search...\n");
} }
} }
bool phch_recv::cell_select(uint32_t earfcn, srslte_cell_t cell) { bool phch_recv::cell_select(uint32_t earfcn, srslte_cell_t cell) {
free_cell(); free_cell();
int cnt=0; int cnt=0;
@ -378,10 +378,10 @@ namespace srsue {
log_h->error("Cell Select: Invalid EARFCN=%d\n", earfcn); log_h->error("Cell Select: Invalid EARFCN=%d\n", earfcn);
} }
return false; return false;
} }
int phch_recv::cell_sync_sfn(void) { int phch_recv::cell_sync_sfn(void) {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN];
@ -418,9 +418,9 @@ namespace srsue {
Debug("SYNC: PSS/SSS not found...\n"); Debug("SYNC: PSS/SSS not found...\n");
} }
return 0; return 0;
} }
int phch_recv::cell_meas_rsrp() { int phch_recv::cell_meas_rsrp() {
uint32_t cfi = 0; uint32_t cfi = 0;
@ -449,9 +449,9 @@ namespace srsue {
} }
return 0; return 0;
} }
void phch_recv::run_thread() { void phch_recv::run_thread() {
int sync_res; int sync_res;
phch_worker *worker = NULL; phch_worker *worker = NULL;
cf_t *buffer[SRSLTE_MAX_PORTS]; cf_t *buffer[SRSLTE_MAX_PORTS];
@ -597,19 +597,19 @@ namespace srsue {
break; break;
} }
} }
} }
uint32_t phch_recv::get_current_tti() { uint32_t phch_recv::get_current_tti() {
return tti; return tti;
} }
bool phch_recv::status_is_sync() { bool phch_recv::status_is_sync() {
return phy_state == CELL_CAMP; return phy_state == CELL_CAMP;
} }
void phch_recv::get_current_cell(srslte_cell_t *cell_) { void phch_recv::get_current_cell(srslte_cell_t *cell_) {
if (cell_) { if (cell_) {
memcpy(cell_, &cell, sizeof(srslte_cell_t)); memcpy(cell_, &cell, sizeof(srslte_cell_t));
} }
} }
} }

@ -33,11 +33,11 @@ using namespace srslte;
namespace srsue { namespace srsue {
nas::nas() nas::nas()
: state(EMM_STATE_DEREGISTERED), plmn_selection(PLMN_SELECTED), is_guti_set(false), ip_addr(0), eps_bearer_id(0), : state(EMM_STATE_DEREGISTERED), plmn_selection(PLMN_SELECTED), is_guti_set(false), ip_addr(0), eps_bearer_id(0),
count_ul(0), count_dl(0) {} count_ul(0), count_dl(0) {}
void nas::init(usim_interface_nas *usim_, void nas::init(usim_interface_nas *usim_,
rrc_interface_nas *rrc_, rrc_interface_nas *rrc_,
gw_interface_nas *gw_, gw_interface_nas *gw_,
srslte::log *nas_log_) { srslte::log *nas_log_) {
@ -50,18 +50,18 @@ namespace srsue {
plmn_selection = PLMN_NOT_SELECTED; plmn_selection = PLMN_NOT_SELECTED;
home_plmn.mcc = 61441; // This is 001 home_plmn.mcc = 61441; // This is 001
home_plmn.mnc = 65281; // This is 01 home_plmn.mnc = 65281; // This is 01
} }
void nas::stop() {} void nas::stop() {}
emm_state_t nas::get_state() { emm_state_t nas::get_state() {
return state; return state;
} }
/******************************************************************************* /*******************************************************************************
UE interface UE interface
*******************************************************************************/ *******************************************************************************/
void nas::attach_request() { void nas::attach_request() {
nas_log->info("Attach Request\n"); nas_log->info("Attach Request\n");
if (state == EMM_STATE_DEREGISTERED) { if (state == EMM_STATE_DEREGISTERED) {
state = EMM_STATE_REGISTERED_INITIATED; state = EMM_STATE_REGISTERED_INITIATED;
@ -75,18 +75,18 @@ namespace srsue {
} else { } else {
nas_log->info("Attach request ignored. State = %s\n", emm_state_text[state]); nas_log->info("Attach request ignored. State = %s\n", emm_state_text[state]);
} }
} }
void nas::deattach_request() { void nas::deattach_request() {
state = EMM_STATE_DEREGISTERED_INITIATED; state = EMM_STATE_DEREGISTERED_INITIATED;
nas_log->info("Dettach request not supported\n"); nas_log->info("Dettach request not supported\n");
} }
/******************************************************************************* /*******************************************************************************
RRC interface RRC interface
*******************************************************************************/ *******************************************************************************/
void nas::plmn_found(LIBLTE_RRC_PLMN_IDENTITY_STRUCT plmn_id, uint16_t tracking_area_code) { void nas::plmn_found(LIBLTE_RRC_PLMN_IDENTITY_STRUCT plmn_id, uint16_t tracking_area_code) {
// Store PLMN if not registered // Store PLMN if not registered
for (uint32_t i=0;i<known_plmns.size();i++) { for (uint32_t i=0;i<known_plmns.size();i++) {
@ -105,30 +105,30 @@ namespace srsue {
if (plmn_id.mcc == home_plmn.mcc && plmn_id.mnc == home_plmn.mnc) { if (plmn_id.mcc == home_plmn.mcc && plmn_id.mnc == home_plmn.mnc) {
rrc->plmn_select(plmn_id); rrc->plmn_select(plmn_id);
} }
} }
void nas::cell_selected() { void nas::cell_selected() {
if (state == EMM_STATE_REGISTERED_INITIATED) { if (state == EMM_STATE_REGISTERED_INITIATED) {
rrc->connect(); rrc->connect();
} else { } else {
nas_log->info("Cell selected in invalid state = %s\n", emm_state_text[state]); nas_log->info("Cell selected in invalid state = %s\n", emm_state_text[state]);
} }
} }
bool nas::is_attached() { bool nas::is_attached() {
return state == EMM_STATE_REGISTERED; return state == EMM_STATE_REGISTERED;
} }
void nas::notify_connection_setup() { void nas::notify_connection_setup() {
nas_log->debug("State = %s\n", emm_state_text[state]); nas_log->debug("State = %s\n", emm_state_text[state]);
if (EMM_STATE_REGISTERED_INITIATED == state) { if (EMM_STATE_REGISTERED_INITIATED == state) {
send_attach_request(); send_attach_request();
} else { } else {
send_service_request(); send_service_request();
} }
} }
void nas::write_pdu(uint32_t lcid, byte_buffer_t *pdu) { void nas::write_pdu(uint32_t lcid, byte_buffer_t *pdu) {
uint8 pd; uint8 pd;
uint8 msg_type; uint8 msg_type;
@ -169,13 +169,13 @@ namespace srsue {
pool->deallocate(pdu); pool->deallocate(pdu);
break; break;
} }
} }
uint32_t nas::get_ul_count() { uint32_t nas::get_ul_count() {
return count_ul; return count_ul;
} }
bool nas::get_s_tmsi(LIBLTE_RRC_S_TMSI_STRUCT *s_tmsi) { bool nas::get_s_tmsi(LIBLTE_RRC_S_TMSI_STRUCT *s_tmsi) {
if (is_guti_set) { if (is_guti_set) {
s_tmsi->mmec = guti.mme_code; s_tmsi->mmec = guti.mme_code;
s_tmsi->m_tmsi = guti.m_tmsi; s_tmsi->m_tmsi = guti.m_tmsi;
@ -183,13 +183,13 @@ namespace srsue {
} else { } else {
return false; return false;
} }
} }
/******************************************************************************* /*******************************************************************************
Security Security
*******************************************************************************/ *******************************************************************************/
void nas::integrity_generate(uint8_t *key_128, void nas::integrity_generate(uint8_t *key_128,
uint32_t count, uint32_t count,
uint8_t rb_id, uint8_t rb_id,
uint8_t direction, uint8_t direction,
@ -220,26 +220,26 @@ namespace srsue {
default: default:
break; break;
} }
} }
void nas::integrity_check() { void nas::integrity_check() {
} }
void nas::cipher_encrypt() { void nas::cipher_encrypt() {
} }
void nas::cipher_decrypt() { void nas::cipher_decrypt() {
} }
/******************************************************************************* /*******************************************************************************
Parsers Parsers
*******************************************************************************/ *******************************************************************************/
void nas::parse_attach_accept(uint32_t lcid, byte_buffer_t *pdu) { void nas::parse_attach_accept(uint32_t lcid, byte_buffer_t *pdu) {
LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT attach_accept; LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT attach_accept;
LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT act_def_eps_bearer_context_req; LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT act_def_eps_bearer_context_req;
LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT attach_complete; LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT attach_complete;
@ -353,9 +353,9 @@ namespace srsue {
state = EMM_STATE_DEREGISTERED; state = EMM_STATE_DEREGISTERED;
pool->deallocate(pdu); pool->deallocate(pdu);
} }
} }
void nas::parse_attach_reject(uint32_t lcid, byte_buffer_t *pdu) { void nas::parse_attach_reject(uint32_t lcid, byte_buffer_t *pdu) {
LIBLTE_MME_ATTACH_REJECT_MSG_STRUCT attach_rej; LIBLTE_MME_ATTACH_REJECT_MSG_STRUCT attach_rej;
liblte_mme_unpack_attach_reject_msg((LIBLTE_BYTE_MSG_STRUCT *) pdu, &attach_rej); liblte_mme_unpack_attach_reject_msg((LIBLTE_BYTE_MSG_STRUCT *) pdu, &attach_rej);
@ -364,9 +364,9 @@ namespace srsue {
state = EMM_STATE_DEREGISTERED; state = EMM_STATE_DEREGISTERED;
pool->deallocate(pdu); pool->deallocate(pdu);
// FIXME: Command RRC to release? // FIXME: Command RRC to release?
} }
void nas::parse_authentication_request(uint32_t lcid, byte_buffer_t *pdu) { void nas::parse_authentication_request(uint32_t lcid, byte_buffer_t *pdu) {
LIBLTE_MME_AUTHENTICATION_REQUEST_MSG_STRUCT auth_req; LIBLTE_MME_AUTHENTICATION_REQUEST_MSG_STRUCT auth_req;
LIBLTE_MME_AUTHENTICATION_RESPONSE_MSG_STRUCT auth_res; LIBLTE_MME_AUTHENTICATION_RESPONSE_MSG_STRUCT auth_res;
@ -401,20 +401,20 @@ namespace srsue {
nas_log->console("Warning: Network authentication failure\n"); nas_log->console("Warning: Network authentication failure\n");
pool->deallocate(pdu); pool->deallocate(pdu);
} }
} }
void nas::parse_authentication_reject(uint32_t lcid, byte_buffer_t *pdu) { void nas::parse_authentication_reject(uint32_t lcid, byte_buffer_t *pdu) {
nas_log->warning("Received Authentication Reject\n"); nas_log->warning("Received Authentication Reject\n");
pool->deallocate(pdu); pool->deallocate(pdu);
state = EMM_STATE_DEREGISTERED; state = EMM_STATE_DEREGISTERED;
// FIXME: Command RRC to release? // FIXME: Command RRC to release?
} }
void nas::parse_identity_request(uint32_t lcid, byte_buffer_t *pdu) { void nas::parse_identity_request(uint32_t lcid, byte_buffer_t *pdu) {
nas_log->error("TODO:parse_identity_request\n"); nas_log->error("TODO:parse_identity_request\n");
} }
void nas::parse_security_mode_command(uint32_t lcid, byte_buffer_t *pdu) { void nas::parse_security_mode_command(uint32_t lcid, byte_buffer_t *pdu) {
bool success; bool success;
LIBLTE_MME_SECURITY_MODE_COMMAND_MSG_STRUCT sec_mode_cmd; LIBLTE_MME_SECURITY_MODE_COMMAND_MSG_STRUCT sec_mode_cmd;
LIBLTE_MME_SECURITY_MODE_COMPLETE_MSG_STRUCT sec_mode_comp; LIBLTE_MME_SECURITY_MODE_COMPLETE_MSG_STRUCT sec_mode_comp;
@ -510,25 +510,25 @@ namespace srsue {
} }
rrc->write_sdu(lcid, pdu); rrc->write_sdu(lcid, pdu);
} }
void nas::parse_service_reject(uint32_t lcid, byte_buffer_t *pdu) { void nas::parse_service_reject(uint32_t lcid, byte_buffer_t *pdu) {
nas_log->error("TODO:parse_service_reject\n"); nas_log->error("TODO:parse_service_reject\n");
} }
void nas::parse_esm_information_request(uint32_t lcid, byte_buffer_t *pdu) { void nas::parse_esm_information_request(uint32_t lcid, byte_buffer_t *pdu) {
nas_log->error("TODO:parse_esm_information_request\n"); nas_log->error("TODO:parse_esm_information_request\n");
} }
void nas::parse_emm_information(uint32_t lcid, byte_buffer_t *pdu) { void nas::parse_emm_information(uint32_t lcid, byte_buffer_t *pdu) {
nas_log->error("TODO:parse_emm_information\n"); nas_log->error("TODO:parse_emm_information\n");
} }
/******************************************************************************* /*******************************************************************************
Senders Senders
*******************************************************************************/ *******************************************************************************/
void nas::send_attach_request() { void nas::send_attach_request() {
LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT attach_req; LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT attach_req;
byte_buffer_t *msg = pool_allocate; byte_buffer_t *msg = pool_allocate;
u_int32_t i; u_int32_t i;
@ -575,9 +575,9 @@ namespace srsue {
nas_log->info("Sending attach request\n"); nas_log->info("Sending attach request\n");
rrc->write_sdu(RB_ID_SRB1, msg); rrc->write_sdu(RB_ID_SRB1, msg);
} }
void nas::gen_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT *msg) { void nas::gen_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT *msg) {
LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT pdn_con_req; LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT pdn_con_req;
nas_log->info("Generating PDN Connectivity Request\n"); nas_log->info("Generating PDN Connectivity Request\n");
@ -596,11 +596,11 @@ namespace srsue {
// Pack the message // Pack the message
liblte_mme_pack_pdn_connectivity_request_msg(&pdn_con_req, msg); liblte_mme_pack_pdn_connectivity_request_msg(&pdn_con_req, msg);
} }
void nas::send_identity_response() {} void nas::send_identity_response() {}
void nas::send_service_request() { void nas::send_service_request() {
byte_buffer_t *msg = pool_allocate; byte_buffer_t *msg = pool_allocate;
count_ul++; count_ul++;
@ -626,8 +626,8 @@ namespace srsue {
msg->N_bytes++; msg->N_bytes++;
nas_log->info("Sending service request\n"); nas_log->info("Sending service request\n");
rrc->write_sdu(RB_ID_SRB1, msg); rrc->write_sdu(RB_ID_SRB1, msg);
} }
void nas::send_esm_information_response() {} void nas::send_esm_information_response() {}
} // namespace srsue } // namespace srsue

@ -46,23 +46,23 @@ namespace srsue {
Base functions Base functions
*******************************************************************************/ *******************************************************************************/
rrc::rrc() rrc::rrc()
: state(RRC_STATE_IDLE), drb_up(false) {} : state(RRC_STATE_IDLE), drb_up(false) {}
static void liblte_rrc_handler(void *ctx, char *str) { static void liblte_rrc_handler(void *ctx, char *str) {
rrc *r = (rrc *) ctx; rrc *r = (rrc *) ctx;
r->liblte_rrc_log(str); r->liblte_rrc_log(str);
} }
void rrc::liblte_rrc_log(char *str) { void rrc::liblte_rrc_log(char *str) {
if (rrc_log) { if (rrc_log) {
rrc_log->warning("[ASN]: %s\n", str); rrc_log->warning("[ASN]: %s\n", str);
} else { } else {
printf("[ASN]: %s\n", str); printf("[ASN]: %s\n", str);
} }
} }
void rrc::init(phy_interface_rrc *phy_, void rrc::init(phy_interface_rrc *phy_,
mac_interface_rrc *mac_, mac_interface_rrc *mac_,
rlc_interface_rrc *rlc_, rlc_interface_rrc *rlc_,
pdcp_interface_rrc *pdcp_, pdcp_interface_rrc *pdcp_,
@ -98,67 +98,67 @@ namespace srsue {
set_rrc_default(); set_rrc_default();
set_phy_default(); set_phy_default();
set_mac_default(); set_mac_default();
} }
void rrc::stop() { void rrc::stop() {
thread_running = false; thread_running = false;
wait_thread_finish(); wait_thread_finish();
} }
rrc_state_t rrc::get_state() { rrc_state_t rrc::get_state() {
return state; return state;
} }
void rrc::set_ue_category(int category) { void rrc::set_ue_category(int category) {
if (category >= 1 && category <= 5) { if (category >= 1 && category <= 5) {
ue_category = category; ue_category = category;
} else { } else {
rrc_log->error("Unsupported UE category %d\n", category); rrc_log->error("Unsupported UE category %d\n", category);
} }
} }
/******************************************************************************* /*******************************************************************************
* *
* *
* *
* PLMN selection, cell selection/reselection and acquisition of SI procedures * PLMN selection, cell selection/reselection and acquisition of SI procedures
* *
* *
* *
*******************************************************************************/ *******************************************************************************/
/******************************************************************************* /*******************************************************************************
NAS interface NAS interface
*******************************************************************************/ *******************************************************************************/
uint16_t rrc::get_mcc() { uint16_t rrc::get_mcc() {
if (current_cell) { if (current_cell) {
if (current_cell->sib1.N_plmn_ids > 0) { if (current_cell->sib1.N_plmn_ids > 0) {
return current_cell->sib1.plmn_id[0].id.mcc; return current_cell->sib1.plmn_id[0].id.mcc;
} }
} }
return 0; return 0;
} }
uint16_t rrc::get_mnc() { uint16_t rrc::get_mnc() {
if (current_cell) { if (current_cell) {
if (current_cell->sib1.N_plmn_ids > 0) { if (current_cell->sib1.N_plmn_ids > 0) {
return current_cell->sib1.plmn_id[0].id.mnc; return current_cell->sib1.plmn_id[0].id.mnc;
} }
} }
return 0; return 0;
} }
void rrc::plmn_search() { void rrc::plmn_search() {
rrc_log->info("Starting PLMN search procedure\n"); rrc_log->info("Starting PLMN search procedure\n");
state = RRC_STATE_PLMN_SELECTION; state = RRC_STATE_PLMN_SELECTION;
phy->cell_search_start(); phy->cell_search_start();
} }
void rrc::plmn_select(LIBLTE_RRC_PLMN_IDENTITY_STRUCT plmn_id) { void rrc::plmn_select(LIBLTE_RRC_PLMN_IDENTITY_STRUCT plmn_id) {
rrc_log->info("PLMN %s selected\n", plmn_id_to_c_str(plmn_id).c_str()); rrc_log->info("PLMN %s selected\n", plmn_id_to_c_str(plmn_id).c_str());
state = RRC_STATE_CELL_SELECTING; state = RRC_STATE_CELL_SELECTING;
@ -169,9 +169,9 @@ namespace srsue {
last_selected_cell = -1; last_selected_cell = -1;
select_next_cell_in_plmn(); select_next_cell_in_plmn();
} }
void rrc::connect() { void rrc::connect() {
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
if (RRC_STATE_CELL_SELECTED == state) { if (RRC_STATE_CELL_SELECTED == state) {
rrc_log->info("RRC in IDLE state - sending connection request.\n"); rrc_log->info("RRC in IDLE state - sending connection request.\n");
@ -181,9 +181,9 @@ namespace srsue {
rrc_log->warning("Received connect() but cell is not selected\n"); rrc_log->warning("Received connect() but cell is not selected\n");
} }
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
} }
void rrc::select_next_cell_in_plmn() { void rrc::select_next_cell_in_plmn() {
for (uint32_t i = last_selected_cell + 1; i < known_cells.size(); i++) { for (uint32_t i = last_selected_cell + 1; i < known_cells.size(); i++) {
for (uint32_t j = 0; j < known_cells[i].sib1.N_plmn_ids; j++) { for (uint32_t j = 0; j < known_cells[i].sib1.N_plmn_ids; j++) {
if (known_cells[i].sib1.plmn_id[j].id.mcc == selected_plmn_id.mcc || if (known_cells[i].sib1.plmn_id[j].id.mcc == selected_plmn_id.mcc ||
@ -223,13 +223,13 @@ namespace srsue {
} }
} }
} }
} }
/******************************************************************************* /*******************************************************************************
PHY interface PHY interface
*******************************************************************************/ *******************************************************************************/
void rrc::cell_found(uint32_t earfcn, srslte_cell_t phy_cell, float rsrp) { void rrc::cell_found(uint32_t earfcn, srslte_cell_t phy_cell, float rsrp) {
// find if cell_id-earfcn combination already exists // find if cell_id-earfcn combination already exists
for (uint32_t i = 0; i < known_cells.size(); i++) { for (uint32_t i = 0; i < known_cells.size(); i++) {
@ -263,10 +263,10 @@ namespace srsue {
cell.phy_cell.id, cell.phy_cell.nof_prb, cell.phy_cell.nof_ports, cell.phy_cell.id, cell.phy_cell.nof_prb, cell.phy_cell.nof_ports,
cell.earfcn, cell.rsrp); cell.earfcn, cell.rsrp);
} }
// Detection of physical layer problems (5.3.11.1) // Detection of physical layer problems (5.3.11.1)
void rrc::out_of_sync() { void rrc::out_of_sync() {
if (!mac_timers->get(t311)->is_running() && !mac_timers->get(t310)->is_running()) { if (!mac_timers->get(t311)->is_running() && !mac_timers->get(t310)->is_running()) {
n310_cnt++; n310_cnt++;
if (n310_cnt == N310) { if (n310_cnt == N310) {
@ -276,10 +276,10 @@ namespace srsue {
rrc_log->info("Detected %d out-of-sync from PHY. Starting T310 timer\n", N310); rrc_log->info("Detected %d out-of-sync from PHY. Starting T310 timer\n", N310);
} }
} }
} }
// Recovery of physical layer problems (5.3.11.2) // Recovery of physical layer problems (5.3.11.2)
void rrc::in_sync() { void rrc::in_sync() {
if (mac_timers->get(t310)->is_running()) { if (mac_timers->get(t310)->is_running()) {
n311_cnt++; n311_cnt++;
if (n311_cnt == N311) { if (n311_cnt == N311) {
@ -288,12 +288,12 @@ namespace srsue {
rrc_log->info("Detected %d in-sync from PHY. Stopping T310 timer\n", N311); rrc_log->info("Detected %d in-sync from PHY. Stopping T310 timer\n", N311);
} }
} }
} }
/******************************************************************************* /*******************************************************************************
PDCP interface PDCP interface
*******************************************************************************/ *******************************************************************************/
void rrc::write_pdu_bcch_bch(byte_buffer_t *pdu) { void rrc::write_pdu_bcch_bch(byte_buffer_t *pdu) {
pool->deallocate(pdu); pool->deallocate(pdu);
if (state == RRC_STATE_PLMN_SELECTION) { if (state == RRC_STATE_PLMN_SELECTION) {
// Do we need to do something with BCH? // Do we need to do something with BCH?
@ -301,9 +301,9 @@ namespace srsue {
} else { } else {
rrc_log->warning("Received BCCH BCH in incorrect state\n"); rrc_log->warning("Received BCCH BCH in incorrect state\n");
} }
} }
void rrc::write_pdu_bcch_dlsch(byte_buffer_t *pdu) { void rrc::write_pdu_bcch_dlsch(byte_buffer_t *pdu) {
rrc_log->info_hex(pdu->msg, pdu->N_bytes, "BCCH DLSCH message received."); rrc_log->info_hex(pdu->msg, pdu->N_bytes, "BCCH DLSCH message received.");
rrc_log->info("BCCH DLSCH message Stack latency: %ld us\n", pdu->get_latency_us()); rrc_log->info("BCCH DLSCH message Stack latency: %ld us\n", pdu->get_latency_us());
LIBLTE_RRC_BCCH_DLSCH_MSG_STRUCT dlsch_msg; LIBLTE_RRC_BCCH_DLSCH_MSG_STRUCT dlsch_msg;
@ -378,11 +378,11 @@ namespace srsue {
} }
} }
} }
// Right now, this thread only controls System Information acquisition procedure // Right now, this thread only controls System Information acquisition procedure
void rrc::run_thread() { void rrc::run_thread() {
uint32_t tti; uint32_t tti;
uint32_t si_win_start, si_win_len; uint32_t si_win_start, si_win_len;
uint16_t period; uint16_t period;
@ -427,7 +427,7 @@ namespace srsue {
} }
usleep(10000); usleep(10000);
} }
} }
@ -448,13 +448,13 @@ namespace srsue {
/******************************************************************************* /*******************************************************************************
* *
* *
* *
* Connection control and establishment/reestablishment procedures * Connection control and establishment/reestablishment procedures
* *
* *
* *
*******************************************************************************/ *******************************************************************************/
@ -463,10 +463,10 @@ namespace srsue {
/******************************************************************************* /*******************************************************************************
NAS interface NAS interface
*******************************************************************************/ *******************************************************************************/
void rrc::write_sdu(uint32_t lcid, byte_buffer_t *sdu) { void rrc::write_sdu(uint32_t lcid, byte_buffer_t *sdu) {
rrc_log->info_hex(sdu->msg, sdu->N_bytes, "RX %s SDU", rb_id_text[lcid]); rrc_log->info_hex(sdu->msg, sdu->N_bytes, "RX %s SDU", rb_id_text[lcid]);
switch (state) { switch (state) {
@ -480,44 +480,44 @@ namespace srsue {
rrc_log->error("SDU received from NAS while RRC state = %s", rrc_state_text[state]); rrc_log->error("SDU received from NAS while RRC state = %s", rrc_state_text[state]);
break; break;
} }
} }
/******************************************************************************* /*******************************************************************************
MAC interface MAC interface
*******************************************************************************/ *******************************************************************************/
/* Reception of PUCCH/SRS release procedure (Section 5.3.13) */ /* Reception of PUCCH/SRS release procedure (Section 5.3.13) */
void rrc::release_pucch_srs() { void rrc::release_pucch_srs() {
// Apply default configuration for PUCCH (CQI and SR) and SRS (release) // Apply default configuration for PUCCH (CQI and SR) and SRS (release)
set_phy_default_pucch_srs(); set_phy_default_pucch_srs();
// Configure RX signals without pregeneration because default option is release // Configure RX signals without pregeneration because default option is release
phy->configure_ul_params(true); phy->configure_ul_params(true);
} }
void rrc::ra_problem() { void rrc::ra_problem() {
radio_link_failure(); radio_link_failure();
} }
/******************************************************************************* /*******************************************************************************
GW interface GW interface
*******************************************************************************/ *******************************************************************************/
bool rrc::is_connected() { bool rrc::is_connected() {
return (RRC_STATE_CONNECTED == state); return (RRC_STATE_CONNECTED == state);
} }
bool rrc::have_drb() { bool rrc::have_drb() {
return drb_up; return drb_up;
} }
/******************************************************************************* /*******************************************************************************
PDCP interface PDCP interface
*******************************************************************************/ *******************************************************************************/
void rrc::write_pdu(uint32_t lcid, byte_buffer_t *pdu) { void rrc::write_pdu(uint32_t lcid, byte_buffer_t *pdu) {
rrc_log->info_hex(pdu->msg, pdu->N_bytes, "TX %s PDU", rb_id_text[lcid]); rrc_log->info_hex(pdu->msg, pdu->N_bytes, "TX %s PDU", rb_id_text[lcid]);
rrc_log->info("TX PDU Stack latency: %ld us\n", pdu->get_latency_us()); rrc_log->info("TX PDU Stack latency: %ld us\n", pdu->get_latency_us());
@ -534,10 +534,10 @@ namespace srsue {
break; break;
} }
} }
void rrc::write_pdu_pcch(byte_buffer_t *pdu) { void rrc::write_pdu_pcch(byte_buffer_t *pdu) {
if (pdu->N_bytes > 0 && pdu->N_bytes < SRSLTE_MAX_BUFFER_SIZE_BITS) { if (pdu->N_bytes > 0 && pdu->N_bytes < SRSLTE_MAX_BUFFER_SIZE_BITS) {
rrc_log->info_hex(pdu->msg, pdu->N_bytes, "PCCH message received %d bytes\n", pdu->N_bytes); rrc_log->info_hex(pdu->msg, pdu->N_bytes, "PCCH message received %d bytes\n", pdu->N_bytes);
rrc_log->info("PCCH message Stack latency: %ld us\n", pdu->get_latency_us()); rrc_log->info("PCCH message Stack latency: %ld us\n", pdu->get_latency_us());
@ -578,23 +578,23 @@ namespace srsue {
} }
} }
} }
} }
/******************************************************************************* /*******************************************************************************
RLC interface RLC interface
*******************************************************************************/ *******************************************************************************/
void rrc::max_retx_attempted() { void rrc::max_retx_attempted() {
//TODO: Handle the radio link failure //TODO: Handle the radio link failure
rrc_log->warning("Max RLC reTx attempted\n"); rrc_log->warning("Max RLC reTx attempted\n");
//radio_link_failure(); //radio_link_failure();
} }
/******************************************************************************* /*******************************************************************************
Senders Senders
*******************************************************************************/ *******************************************************************************/
void rrc::send_con_request() { void rrc::send_con_request() {
rrc_log->debug("Preparing RRC Connection Request\n"); rrc_log->debug("Preparing RRC Connection Request\n");
LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg; LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg;
LIBLTE_RRC_S_TMSI_STRUCT s_tmsi; LIBLTE_RRC_S_TMSI_STRUCT s_tmsi;
@ -635,11 +635,11 @@ namespace srsue {
rrc_log->info("Sending RRC Connection Request on SRB0\n"); rrc_log->info("Sending RRC Connection Request on SRB0\n");
pdcp->write_sdu(RB_ID_SRB0, pdcp_buf); pdcp->write_sdu(RB_ID_SRB0, pdcp_buf);
} }
/* RRC connection re-establishment procedure (5.3.7) */ /* RRC connection re-establishment procedure (5.3.7) */
void rrc::send_con_restablish_request() { void rrc::send_con_restablish_request() {
srslte_cell_t cell; srslte_cell_t cell;
phy->get_current_cell(&cell); phy->get_current_cell(&cell);
@ -724,10 +724,10 @@ namespace srsue {
rrc_log->info("Sending RRC Connection Resetablishment Request on SRB0\n"); rrc_log->info("Sending RRC Connection Resetablishment Request on SRB0\n");
pdcp->write_sdu(RB_ID_SRB0, pdcp_buf); pdcp->write_sdu(RB_ID_SRB0, pdcp_buf);
} }
void rrc::send_con_restablish_complete() { void rrc::send_con_restablish_complete() {
rrc_log->debug("Preparing RRC Connection Reestablishment Complete\n"); rrc_log->debug("Preparing RRC Connection Reestablishment Complete\n");
LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg; LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg;
@ -750,9 +750,9 @@ namespace srsue {
rrc_log->console("RRC Connected\n"); rrc_log->console("RRC Connected\n");
rrc_log->info("Sending RRC Connection Reestablishment Complete\n"); rrc_log->info("Sending RRC Connection Reestablishment Complete\n");
pdcp->write_sdu(RB_ID_SRB1, pdcp_buf); pdcp->write_sdu(RB_ID_SRB1, pdcp_buf);
} }
void rrc::send_con_setup_complete(byte_buffer_t *nas_msg) { void rrc::send_con_setup_complete(byte_buffer_t *nas_msg) {
rrc_log->debug("Preparing RRC Connection Setup Complete\n"); rrc_log->debug("Preparing RRC Connection Setup Complete\n");
LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg; LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg;
@ -780,9 +780,9 @@ namespace srsue {
rrc_log->console("RRC Connected\n"); rrc_log->console("RRC Connected\n");
rrc_log->info("Sending RRC Connection Setup Complete\n"); rrc_log->info("Sending RRC Connection Setup Complete\n");
pdcp->write_sdu(RB_ID_SRB1, pdcp_buf); pdcp->write_sdu(RB_ID_SRB1, pdcp_buf);
} }
void rrc::send_ul_info_transfer(uint32_t lcid, byte_buffer_t *sdu) { void rrc::send_ul_info_transfer(uint32_t lcid, byte_buffer_t *sdu) {
rrc_log->debug("Preparing RX Info Transfer\n"); rrc_log->debug("Preparing RX Info Transfer\n");
LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg; LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg;
@ -810,9 +810,9 @@ namespace srsue {
rrc_log->info("Sending RX Info Transfer\n"); rrc_log->info("Sending RX Info Transfer\n");
pdcp->write_sdu(lcid, pdu); pdcp->write_sdu(lcid, pdu);
} }
void rrc::send_security_mode_complete(uint32_t lcid, byte_buffer_t *pdu) { void rrc::send_security_mode_complete(uint32_t lcid, byte_buffer_t *pdu) {
rrc_log->debug("Preparing Security Mode Complete\n"); rrc_log->debug("Preparing Security Mode Complete\n");
LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg; LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg;
ul_dcch_msg.msg_type = LIBLTE_RRC_UL_DCCH_MSG_TYPE_SECURITY_MODE_COMPLETE; ul_dcch_msg.msg_type = LIBLTE_RRC_UL_DCCH_MSG_TYPE_SECURITY_MODE_COMPLETE;
@ -831,9 +831,9 @@ namespace srsue {
rrc_log->info("Sending Security Mode Complete\n"); rrc_log->info("Sending Security Mode Complete\n");
pdcp->write_sdu(lcid, pdu); pdcp->write_sdu(lcid, pdu);
} }
void rrc::send_rrc_con_reconfig_complete(uint32_t lcid, byte_buffer_t *pdu) { void rrc::send_rrc_con_reconfig_complete(uint32_t lcid, byte_buffer_t *pdu) {
rrc_log->debug("Preparing RRC Connection Reconfig Complete\n"); rrc_log->debug("Preparing RRC Connection Reconfig Complete\n");
LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg; LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg;
@ -853,15 +853,15 @@ namespace srsue {
rrc_log->info("Sending RRC Connection Reconfig Complete\n"); rrc_log->info("Sending RRC Connection Reconfig Complete\n");
pdcp->write_sdu(lcid, pdu); pdcp->write_sdu(lcid, pdu);
} }
void rrc::enable_capabilities() { void rrc::enable_capabilities() {
bool enable_ul_64 = ue_category >= 5 && current_cell->sib2.rr_config_common_sib.pusch_cnfg.enable_64_qam; bool enable_ul_64 = ue_category >= 5 && current_cell->sib2.rr_config_common_sib.pusch_cnfg.enable_64_qam;
rrc_log->info("%s 64QAM PUSCH\n", enable_ul_64 ? "Enabling" : "Disabling"); rrc_log->info("%s 64QAM PUSCH\n", enable_ul_64 ? "Enabling" : "Disabling");
phy->set_config_64qam_en(enable_ul_64); phy->set_config_64qam_en(enable_ul_64);
} }
void rrc::send_rrc_ue_cap_info(uint32_t lcid, byte_buffer_t *pdu) { void rrc::send_rrc_ue_cap_info(uint32_t lcid, byte_buffer_t *pdu) {
rrc_log->debug("Preparing UE Capability Info\n"); rrc_log->debug("Preparing UE Capability Info\n");
LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg; LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg;
@ -937,13 +937,13 @@ namespace srsue {
rrc_log->info("Sending UE Capability Info\n"); rrc_log->info("Sending UE Capability Info\n");
pdcp->write_sdu(lcid, pdu); pdcp->write_sdu(lcid, pdu);
} }
/******************************************************************************* /*******************************************************************************
Parsers Parsers
*******************************************************************************/ *******************************************************************************/
void rrc::parse_dl_ccch(byte_buffer_t *pdu) { void rrc::parse_dl_ccch(byte_buffer_t *pdu) {
srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes * 8); srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes * 8);
bit_buf.N_bits = pdu->N_bytes * 8; bit_buf.N_bits = pdu->N_bytes * 8;
pool->deallocate(pdu); pool->deallocate(pdu);
@ -981,9 +981,9 @@ namespace srsue {
default: default:
break; break;
} }
} }
void rrc::parse_dl_dcch(uint32_t lcid, byte_buffer_t *pdu) { void rrc::parse_dl_dcch(uint32_t lcid, byte_buffer_t *pdu) {
srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes * 8); srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes * 8);
bit_buf.N_bits = pdu->N_bytes * 8; bit_buf.N_bits = pdu->N_bytes * 8;
liblte_rrc_unpack_dl_dcch_msg((LIBLTE_BIT_MSG_STRUCT *) &bit_buf, &dl_dcch_msg); liblte_rrc_unpack_dl_dcch_msg((LIBLTE_BIT_MSG_STRUCT *) &bit_buf, &dl_dcch_msg);
@ -1032,13 +1032,13 @@ namespace srsue {
default: default:
break; break;
} }
} }
/******************************************************************************* /*******************************************************************************
Timer expiration callback Timer expiration callback
*******************************************************************************/ *******************************************************************************/
void rrc::timer_expired(uint32_t timeout_id) { void rrc::timer_expired(uint32_t timeout_id) {
if (timeout_id == t310) { if (timeout_id == t310) {
rrc_log->info("Timer T310 expired: Radio Link Failure\n"); rrc_log->info("Timer T310 expired: Radio Link Failure\n");
radio_link_failure(); radio_link_failure();
@ -1053,13 +1053,13 @@ namespace srsue {
} else { } else {
rrc_log->error("Timeout from unknown timer id %d\n", timeout_id); rrc_log->error("Timeout from unknown timer id %d\n", timeout_id);
} }
} }
/******************************************************************************* /*******************************************************************************
Helpers Helpers
*******************************************************************************/ *******************************************************************************/
void rrc::reset_ue() { void rrc::reset_ue() {
phy->reset(); phy->reset();
mac->reset(); mac->reset();
pdcp->reset(); pdcp->reset();
@ -1068,9 +1068,9 @@ namespace srsue {
mac_timers->get(safe_reset_timer)->stop(); mac_timers->get(safe_reset_timer)->stop();
mac_timers->get(safe_reset_timer)->reset(); mac_timers->get(safe_reset_timer)->reset();
rrc_log->console("RRC Connection released.\n"); rrc_log->console("RRC Connection released.\n");
} }
void rrc::rrc_connection_release() { void rrc::rrc_connection_release() {
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
drb_up = false; drb_up = false;
state = RRC_STATE_IDLE; state = RRC_STATE_IDLE;
@ -1083,15 +1083,15 @@ namespace srsue {
mac_timers->get(safe_reset_timer)->reset(); mac_timers->get(safe_reset_timer)->reset();
mac_timers->get(safe_reset_timer)->run(); mac_timers->get(safe_reset_timer)->run();
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
} }
void rrc::test_con_restablishment() { void rrc::test_con_restablishment() {
printf("Testing connection Reestablishment\n"); printf("Testing connection Reestablishment\n");
send_con_restablish_request(); send_con_restablish_request();
} }
/* Detection of radio link failure (5.3.11.3) */ /* Detection of radio link failure (5.3.11.3) */
void rrc::radio_link_failure() { void rrc::radio_link_failure() {
// TODO: Generate and store failure report // TODO: Generate and store failure report
rrc_log->warning("Detected Radio-Link Failure\n"); rrc_log->warning("Detected Radio-Link Failure\n");
@ -1101,15 +1101,15 @@ namespace srsue {
} else { } else {
send_con_restablish_request(); send_con_restablish_request();
} }
} }
// Determine SI messages scheduling as in 36.331 5.2.3 Acquisition of an SI message // Determine SI messages scheduling as in 36.331 5.2.3 Acquisition of an SI message
uint32_t rrc::sib_start_tti(uint32_t tti, uint32_t period, uint32_t x) { uint32_t rrc::sib_start_tti(uint32_t tti, uint32_t period, uint32_t x) {
return (period * 10 * (1 + tti / (period * 10)) + x) % 10240; // the 1 means next opportunity return (period * 10 * (1 + tti / (period * 10)) + x) % 10240; // the 1 means next opportunity
} }
void rrc::apply_sib2_configs(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2_STRUCT *sib2) { void rrc::apply_sib2_configs(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2_STRUCT *sib2) {
// Apply RACH timeAlginmentTimer configuration // Apply RACH timeAlginmentTimer configuration
mac_interface_rrc::mac_cfg_t cfg; mac_interface_rrc::mac_cfg_t cfg;
@ -1177,10 +1177,10 @@ namespace srsue {
N310, N311, mac_timers->get(t301)->get_timeout(), N310, N311, mac_timers->get(t301)->get_timeout(),
mac_timers->get(t310)->get_timeout(), mac_timers->get(t311)->get_timeout()); mac_timers->get(t310)->get_timeout(), mac_timers->get(t311)->get_timeout());
} }
// Go through all information elements and apply defaults (9.2.4) if not defined // Go through all information elements and apply defaults (9.2.4) if not defined
void rrc::apply_phy_config_dedicated(LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT *phy_cnfg, bool apply_defaults) { void rrc::apply_phy_config_dedicated(LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT *phy_cnfg, bool apply_defaults) {
// Get current configuration // Get current configuration
LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT *current_cfg; LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT *current_cfg;
phy_interface_rrc::phy_cfg_t c; phy_interface_rrc::phy_cfg_t c;
@ -1312,9 +1312,9 @@ namespace srsue {
// Apply changes to PHY // Apply changes to PHY
phy->configure_ul_params(); phy->configure_ul_params();
} }
void rrc::apply_mac_config_dedicated(LIBLTE_RRC_MAC_MAIN_CONFIG_STRUCT *mac_cnfg, bool apply_defaults) { void rrc::apply_mac_config_dedicated(LIBLTE_RRC_MAC_MAIN_CONFIG_STRUCT *mac_cnfg, bool apply_defaults) {
// Set Default MAC main configuration (9.2.2) // Set Default MAC main configuration (9.2.2)
LIBLTE_RRC_MAC_MAIN_CONFIG_STRUCT default_cfg; LIBLTE_RRC_MAC_MAIN_CONFIG_STRUCT default_cfg;
bzero(&default_cfg, sizeof(LIBLTE_RRC_MAC_MAIN_CONFIG_STRUCT)); bzero(&default_cfg, sizeof(LIBLTE_RRC_MAC_MAIN_CONFIG_STRUCT));
@ -1364,9 +1364,9 @@ namespace srsue {
liblte_rrc_prohibit_phr_timer_num[default_cfg.phr_cnfg.prohibit_phr_timer], liblte_rrc_prohibit_phr_timer_num[default_cfg.phr_cnfg.prohibit_phr_timer],
liblte_rrc_dl_pathloss_change_num[default_cfg.phr_cnfg.dl_pathloss_change]); liblte_rrc_dl_pathloss_change_num[default_cfg.phr_cnfg.dl_pathloss_change]);
} }
} }
void rrc::apply_rr_config_dedicated(LIBLTE_RRC_RR_CONFIG_DEDICATED_STRUCT *cnfg) { void rrc::apply_rr_config_dedicated(LIBLTE_RRC_RR_CONFIG_DEDICATED_STRUCT *cnfg) {
if (cnfg->phy_cnfg_ded_present) { if (cnfg->phy_cnfg_ded_present) {
apply_phy_config_dedicated(&cnfg->phy_cnfg_ded, false); apply_phy_config_dedicated(&cnfg->phy_cnfg_ded, false);
// Apply SR configuration to MAC // Apply SR configuration to MAC
@ -1396,15 +1396,15 @@ namespace srsue {
// TODO: handle DRB modification // TODO: handle DRB modification
add_drb(&cnfg->drb_to_add_mod_list[i]); add_drb(&cnfg->drb_to_add_mod_list[i]);
} }
} }
void rrc::handle_con_setup(LIBLTE_RRC_CONNECTION_SETUP_STRUCT *setup) { void rrc::handle_con_setup(LIBLTE_RRC_CONNECTION_SETUP_STRUCT *setup) {
// Apply the Radio Resource configuration // Apply the Radio Resource configuration
apply_rr_config_dedicated(&setup->rr_cnfg); apply_rr_config_dedicated(&setup->rr_cnfg);
} }
/* Reception of RRCConnectionReestablishment by the UE 5.3.7.5 */ /* Reception of RRCConnectionReestablishment by the UE 5.3.7.5 */
void rrc::handle_con_reest(LIBLTE_RRC_CONNECTION_REESTABLISHMENT_STRUCT *setup) { void rrc::handle_con_reest(LIBLTE_RRC_CONNECTION_REESTABLISHMENT_STRUCT *setup) {
mac_timers->get(t301)->stop(); mac_timers->get(t301)->stop();
// TODO: Restablish DRB1. Not done because never was suspended // TODO: Restablish DRB1. Not done because never was suspended
@ -1415,10 +1415,10 @@ namespace srsue {
// TODO: Some security stuff here... is it necessary? // TODO: Some security stuff here... is it necessary?
send_con_restablish_complete(); send_con_restablish_complete();
} }
void rrc::handle_rrc_con_reconfig(uint32_t lcid, LIBLTE_RRC_CONNECTION_RECONFIGURATION_STRUCT *reconfig, void rrc::handle_rrc_con_reconfig(uint32_t lcid, LIBLTE_RRC_CONNECTION_RECONFIGURATION_STRUCT *reconfig,
byte_buffer_t *pdu) { byte_buffer_t *pdu) {
uint32_t i; uint32_t i;
@ -1443,9 +1443,9 @@ namespace srsue {
nas_sdu->N_bytes = reconfig->ded_info_nas_list[i].N_bytes; nas_sdu->N_bytes = reconfig->ded_info_nas_list[i].N_bytes;
nas->write_pdu(lcid, nas_sdu); nas->write_pdu(lcid, nas_sdu);
} }
} }
void rrc::add_srb(LIBLTE_RRC_SRB_TO_ADD_MOD_STRUCT *srb_cnfg) { void rrc::add_srb(LIBLTE_RRC_SRB_TO_ADD_MOD_STRUCT *srb_cnfg) {
// Setup PDCP // Setup PDCP
pdcp->add_bearer(srb_cnfg->srb_id); pdcp->add_bearer(srb_cnfg->srb_id);
if (RB_ID_SRB2 == srb_cnfg->srb_id) if (RB_ID_SRB2 == srb_cnfg->srb_id)
@ -1488,9 +1488,9 @@ namespace srsue {
srbs[srb_cnfg->srb_id] = *srb_cnfg; srbs[srb_cnfg->srb_id] = *srb_cnfg;
rrc_log->info("Added radio bearer %s\n", rb_id_text[srb_cnfg->srb_id]); rrc_log->info("Added radio bearer %s\n", rb_id_text[srb_cnfg->srb_id]);
} }
void rrc::add_drb(LIBLTE_RRC_DRB_TO_ADD_MOD_STRUCT *drb_cnfg) { void rrc::add_drb(LIBLTE_RRC_DRB_TO_ADD_MOD_STRUCT *drb_cnfg) {
if (!drb_cnfg->pdcp_cnfg_present || if (!drb_cnfg->pdcp_cnfg_present ||
!drb_cnfg->rlc_cnfg_present || !drb_cnfg->rlc_cnfg_present ||
@ -1539,18 +1539,18 @@ namespace srsue {
drbs[lcid] = *drb_cnfg; drbs[lcid] = *drb_cnfg;
drb_up = true; drb_up = true;
rrc_log->info("Added radio bearer %s\n", rb_id_text[lcid]); rrc_log->info("Added radio bearer %s\n", rb_id_text[lcid]);
} }
void rrc::release_drb(uint8_t lcid) { void rrc::release_drb(uint8_t lcid) {
// TODO // TODO
} }
/************************** /**************************
* DEFAULT VALUES Section 9 * DEFAULT VALUES Section 9
****************************/ ****************************/
// PHY CONFIG DEDICATED Defaults (3GPP 36.331 v10 9.2.4) // PHY CONFIG DEDICATED Defaults (3GPP 36.331 v10 9.2.4)
void rrc::set_phy_default_pucch_srs() { void rrc::set_phy_default_pucch_srs() {
phy_interface_rrc::phy_cfg_t current_cfg; phy_interface_rrc::phy_cfg_t current_cfg;
phy->get_config(&current_cfg); phy->get_config(&current_cfg);
@ -1566,23 +1566,23 @@ namespace srsue {
LIBLTE_RRC_SCHEDULING_REQUEST_CONFIG_STRUCT cfg; LIBLTE_RRC_SCHEDULING_REQUEST_CONFIG_STRUCT cfg;
bzero(&cfg, sizeof(LIBLTE_RRC_SCHEDULING_REQUEST_CONFIG_STRUCT)); bzero(&cfg, sizeof(LIBLTE_RRC_SCHEDULING_REQUEST_CONFIG_STRUCT));
mac->set_config_sr(&cfg); mac->set_config_sr(&cfg);
} }
void rrc::set_phy_default() { void rrc::set_phy_default() {
LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT defaults; LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT defaults;
bzero(&defaults, sizeof(LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT)); bzero(&defaults, sizeof(LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT));
apply_phy_config_dedicated(&defaults, true); apply_phy_config_dedicated(&defaults, true);
} }
void rrc::set_mac_default() { void rrc::set_mac_default() {
apply_mac_config_dedicated(NULL, true); apply_mac_config_dedicated(NULL, true);
LIBLTE_RRC_SCHEDULING_REQUEST_CONFIG_STRUCT sr_cfg; LIBLTE_RRC_SCHEDULING_REQUEST_CONFIG_STRUCT sr_cfg;
bzero(&sr_cfg, sizeof(LIBLTE_RRC_SCHEDULING_REQUEST_CONFIG_STRUCT)); bzero(&sr_cfg, sizeof(LIBLTE_RRC_SCHEDULING_REQUEST_CONFIG_STRUCT));
sr_cfg.setup_present = false; sr_cfg.setup_present = false;
mac->set_config_sr(&sr_cfg); mac->set_config_sr(&sr_cfg);
} }
void rrc::set_rrc_default() { void rrc::set_rrc_default() {
N310 = 1; N310 = 1;
N311 = 1; N311 = 1;
t301 = mac_timers->get_unique_id(); t301 = mac_timers->get_unique_id();
@ -1592,6 +1592,6 @@ namespace srsue {
mac_timers->get(t310)->set(this, 1000); mac_timers->get(t310)->set(this, 1000);
mac_timers->get(t311)->set(this, 1000); mac_timers->get(t311)->set(this, 1000);
mac_timers->get(safe_reset_timer)->set(this, 10); mac_timers->get(safe_reset_timer)->set(this, 10);
} }
} // namespace srsue } // namespace srsue

Loading…
Cancel
Save