created a asn1 utils with helper functions and types related to the asn1. These types/functions will help isolate the rrc_asn1 lib from most of the layers, reducing this way the compile times, and leading to better isolation. This will also make the transition to NR smoother. I removed the asn1 types from the NAS and USIM interface so far.

master
Francisco Paisana 6 years ago committed by Andre Puschmann
parent 416f9896ec
commit bb0dbf0f1c

@ -0,0 +1,75 @@
/*
* Copyright 2013-2019 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef SRSLTE_RRC_ASN1_UTILS_H
#define SRSLTE_RRC_ASN1_UTILS_H
#include <string>
// fwd decls
namespace asn1 {
namespace rrc {
struct plmn_id_s;
struct s_tmsi_s;
} // namespace rrc
} // namespace asn1
namespace srslte {
struct plmn_id_t {
uint8_t mcc[3];
uint8_t mnc[3];
uint8_t nof_mnc_digits;
plmn_id_t() : mcc(), mnc(), nof_mnc_digits(0) {}
int from_asn1(const asn1::rrc::plmn_id_s* asn1_type);
void to_asn1(asn1::rrc::plmn_id_s* asn1_type) const;
void from_number(uint16_t mcc_num, uint16_t mnc_num);
int from_string(const std::string& plmn_str);
std::string to_string() const;
};
struct s_tmsi_t {
uint8_t mmec;
uint32_t m_tmsi;
void from_asn1(const asn1::rrc::s_tmsi_s* asn1_type);
void to_asn1(asn1::rrc::s_tmsi_s* asn1_type) const;
};
enum class establishment_cause_t {
emergency,
high_prio_access,
mt_access,
mo_sig,
mo_data,
delay_tolerant_access_v1020,
mo_voice_call_v1280,
spare1,
nulltype
};
std::string to_string(const establishment_cause_t& cause);
}
#endif // SRSLTE_RRC_ASN1_UTILS_H

@ -69,7 +69,7 @@ inline bool mcc_to_string(uint16_t mcc, std::string *str)
* MCC 001 results in 0xF001 * MCC 001 results in 0xF001
*****************************************************************************/ *****************************************************************************/
inline bool bytes_to_mcc(uint8_t* bytes, uint16_t* mcc) inline bool bytes_to_mcc(const uint8_t* bytes, uint16_t* mcc)
{ {
*mcc = 0xF000; *mcc = 0xF000;
*mcc |= (((uint16_t)bytes[0]) << 8u); *mcc |= (((uint16_t)bytes[0]) << 8u);
@ -153,7 +153,7 @@ inline bool mnc_to_string(uint16_t mnc, std::string *str)
* MNC 001 results in 0xF001 * MNC 001 results in 0xF001
* MNC 01 results in 0xFF01 * MNC 01 results in 0xFF01
*****************************************************************************/ *****************************************************************************/
inline bool bytes_to_mnc(uint8_t* bytes, uint16_t* mnc, uint8_t len) inline bool bytes_to_mnc(const uint8_t* bytes, uint16_t* mnc, uint8_t len)
{ {
if (len != 3 && len != 2) { if (len != 3 && len != 2) {
*mnc = 0; *mnc = 0;

@ -32,6 +32,7 @@
#include "srslte/asn1/liblte_mme.h" #include "srslte/asn1/liblte_mme.h"
#include "srslte/asn1/rrc_asn1.h" #include "srslte/asn1/rrc_asn1.h"
#include "srslte/asn1/rrc_asn1_utils.h"
#include "srslte/common/common.h" #include "srslte/common/common.h"
#include "srslte/common/interfaces_common.h" #include "srslte/common/interfaces_common.h"
#include "srslte/common/security.h" #include "srslte/common/security.h"
@ -55,7 +56,7 @@ public:
virtual std::string get_imei_str() = 0; virtual std::string get_imei_str() = 0;
virtual bool get_imsi_vec(uint8_t* imsi_, uint32_t n) = 0; virtual bool get_imsi_vec(uint8_t* imsi_, uint32_t n) = 0;
virtual bool get_imei_vec(uint8_t* imei_, uint32_t n) = 0; virtual bool get_imei_vec(uint8_t* imei_, uint32_t n) = 0;
virtual bool get_home_plmn_id(asn1::rrc::plmn_id_s* home_plmn_id) = 0; virtual bool get_home_plmn_id(srslte::plmn_id_t* home_plmn_id) = 0;
virtual auth_result_t generate_authentication_response(uint8_t *rand, virtual auth_result_t generate_authentication_response(uint8_t *rand,
uint8_t *autn_enb, uint8_t *autn_enb,
uint16_t mcc, uint16_t mcc,
@ -131,7 +132,7 @@ public:
} barring_t; } barring_t;
virtual void leave_connected() = 0; virtual void leave_connected() = 0;
virtual void set_barring(barring_t barring) = 0; virtual void set_barring(barring_t barring) = 0;
virtual void paging(asn1::rrc::s_tmsi_s* ue_identiy) = 0; virtual void paging(srslte::s_tmsi_t* ue_identity) = 0;
virtual bool is_attached() = 0; virtual bool is_attached() = 0;
virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0;
virtual uint32_t get_k_enb_count() = 0; virtual uint32_t get_k_enb_count() = 0;
@ -183,7 +184,7 @@ class rrc_interface_nas
{ {
public: public:
typedef struct { typedef struct {
asn1::rrc::plmn_id_s plmn_id; srslte::plmn_id_t plmn_id;
uint16_t tac; uint16_t tac;
} found_plmn_t; } found_plmn_t;
@ -194,10 +195,10 @@ public:
virtual uint16_t get_mnc() = 0; virtual uint16_t get_mnc() = 0;
virtual void enable_capabilities() = 0; virtual void enable_capabilities() = 0;
virtual int plmn_search(found_plmn_t found_plmns[MAX_FOUND_PLMNS]) = 0; virtual int plmn_search(found_plmn_t found_plmns[MAX_FOUND_PLMNS]) = 0;
virtual void plmn_select(asn1::rrc::plmn_id_s plmn_id) = 0; virtual void plmn_select(srslte::plmn_id_t plmn_id) = 0;
virtual bool connection_request(asn1::rrc::establishment_cause_e cause, virtual bool connection_request(srslte::establishment_cause_t cause,
srslte::unique_byte_buffer_t dedicatedInfoNAS) = 0; srslte::unique_byte_buffer_t dedicatedInfoNAS) = 0;
virtual void set_ue_idenity(asn1::rrc::s_tmsi_s s_tmsi) = 0; virtual void set_ue_identity(srslte::s_tmsi_t s_tmsi) = 0;
virtual bool is_connected() = 0; virtual bool is_connected() = 0;
virtual std::string get_rb_name(uint32_t lcid) = 0; virtual std::string get_rb_name(uint32_t lcid) = 0;
virtual uint32_t get_lcid_for_eps_bearer(const uint32_t& eps_bearer_id) = 0; virtual uint32_t get_lcid_for_eps_bearer(const uint32_t& eps_bearer_id) = 0;

@ -32,6 +32,7 @@ add_library(rrc_asn1 STATIC
rrc_asn1.cc rrc_asn1.cc
rrc_asn1_enum.cc rrc_asn1_enum.cc
asn1_utils.cc asn1_utils.cc
rrc_asn1_utils.cc
) )
# Compile RRC ASN1 optimized for size # Compile RRC ASN1 optimized for size
target_compile_options(rrc_asn1 PRIVATE "-Os") target_compile_options(rrc_asn1 PRIVATE "-Os")

@ -0,0 +1,105 @@
/*
* Copyright 2013-2019 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include "srslte/asn1/rrc_asn1_utils.h"
#include "srslte/asn1/rrc_asn1.h"
#include "srslte/common/bcd_helpers.h"
#include "srslte/config.h"
#include <algorithm>
namespace srslte {
int plmn_id_t::from_asn1(const asn1::rrc::plmn_id_s* asn1_type)
{
if (not asn1_type->mcc_present) {
return SRSLTE_ERROR;
}
std::copy(&asn1_type->mcc[0], &asn1_type->mcc[3], &mcc[0]);
nof_mnc_digits = asn1_type->mnc.size();
std::copy(&asn1_type->mnc[0], &asn1_type->mnc[nof_mnc_digits], &mnc[0]);
return SRSLTE_SUCCESS;
}
void plmn_id_t::to_asn1(asn1::rrc::plmn_id_s* asn1_type) const
{
asn1_type->mcc_present = true;
std::copy(&mcc[0], &mcc[3], &asn1_type->mcc[0]);
asn1_type->mnc.resize(nof_mnc_digits);
std::copy(&mnc[0], &mnc[nof_mnc_digits], &asn1_type->mnc[0]);
}
void plmn_id_t::from_number(uint16_t mcc_num, uint16_t mnc_num)
{
srslte::mcc_to_bytes(mcc_num, &mcc[0]);
srslte::mnc_to_bytes(mnc_num, &mnc[0], &nof_mnc_digits);
}
int plmn_id_t::from_string(const std::string& plmn_str)
{
if (plmn_str.size() < 5 or plmn_str.size() > 6) {
return SRSLTE_ERROR;
}
uint16_t mnc_num, mcc_num;
if (not string_to_mcc(std::string(plmn_str.begin(), plmn_str.begin() + 3), &mcc_num)) {
return SRSLTE_ERROR;
}
if (not string_to_mnc(std::string(plmn_str.begin() + 3, plmn_str.end()), &mnc_num)) {
return SRSLTE_ERROR;
}
if (not mcc_to_bytes(mcc_num, &mcc[0])) {
return SRSLTE_ERROR;
}
return mnc_to_bytes(mnc_num, &mnc[0], &nof_mnc_digits) ? SRSLTE_SUCCESS : SRSLTE_ERROR;
}
std::string plmn_id_t::to_string() const
{
std::string mcc_str, mnc_str;
uint16_t mnc_num, mcc_num;
bytes_to_mnc(&mnc[0], &mnc_num, nof_mnc_digits);
bytes_to_mcc(&mcc[0], &mcc_num);
mnc_to_string(mnc_num, &mnc_str);
mcc_to_string(mcc_num, &mcc_str);
return mcc_str + mnc_str;
}
void s_tmsi_t::from_asn1(const asn1::rrc::s_tmsi_s* asn1_type)
{
mmec = asn1_type->mmec.to_number();
m_tmsi = asn1_type->m_tmsi.to_number();
}
void s_tmsi_t::to_asn1(asn1::rrc::s_tmsi_s* asn1_type) const
{
asn1_type->mmec.from_number(mmec);
asn1_type->m_tmsi.from_number(m_tmsi);
}
static_assert((int)establishment_cause_t::nulltype == (int)asn1::rrc::establishment_cause_opts::nulltype,
"Failed conversion of ASN1 type");
std::string to_string(const establishment_cause_t& cause)
{
asn1::rrc::establishment_cause_e asn1_cause((asn1::rrc::establishment_cause_opts::options)cause);
return asn1_cause.to_string();
}
} // namespace

@ -101,15 +101,14 @@ class cell_t
} }
} }
asn1::rrc::plmn_id_s get_plmn(uint32_t idx) srslte::plmn_id_t get_plmn(uint32_t idx)
{ {
if (idx < sib1.cell_access_related_info.plmn_id_list.size() && has_valid_sib1) { if (idx < sib1.cell_access_related_info.plmn_id_list.size() && has_valid_sib1) {
return sib1.cell_access_related_info.plmn_id_list[idx].plmn_id; srslte::plmn_id_t ret;
ret.from_asn1(&sib1.cell_access_related_info.plmn_id_list[idx].plmn_id);
return ret;
} else { } else {
asn1::rrc::plmn_id_s null; return {};
bzero(&null.mcc[0], sizeof(null.mcc));
bzero(&null.mnc[0], sizeof(null.mnc));
return null;
} }
} }
@ -321,9 +320,9 @@ public:
uint16_t get_mcc(); uint16_t get_mcc();
uint16_t get_mnc(); uint16_t get_mnc();
int plmn_search(found_plmn_t found_plmns[MAX_FOUND_PLMNS]); int plmn_search(found_plmn_t found_plmns[MAX_FOUND_PLMNS]);
void plmn_select(asn1::rrc::plmn_id_s plmn_id); void plmn_select(srslte::plmn_id_t plmn_id);
bool connection_request(asn1::rrc::establishment_cause_e cause, srslte::unique_byte_buffer_t dedicated_info_nas); bool connection_request(srslte::establishment_cause_t cause, srslte::unique_byte_buffer_t dedicated_info_nas);
void set_ue_idenity(asn1::rrc::s_tmsi_s s_tmsi); void set_ue_identity(srslte::s_tmsi_t s_tmsi);
// PHY interface // PHY interface
void in_sync(); void in_sync();
@ -386,7 +385,7 @@ private:
rrc_state_t state, last_state; rrc_state_t state, last_state;
uint8_t transaction_id; uint8_t transaction_id;
asn1::rrc::s_tmsi_s ue_identity; srslte::s_tmsi_t ue_identity;
bool ue_identity_configured; bool ue_identity_configured;
bool drb_up; bool drb_up;
@ -619,7 +618,7 @@ private:
phy_interface_rrc_lte::cell_search_ret_t cell_search(); phy_interface_rrc_lte::cell_search_ret_t cell_search();
asn1::rrc::plmn_id_s selected_plmn_id; srslte::plmn_id_t selected_plmn_id;
bool plmn_is_selected; bool plmn_is_selected;
bool security_is_activated; bool security_is_activated;

@ -54,7 +54,7 @@ public:
// RRC interface // RRC interface
void leave_connected(); void leave_connected();
void paging(asn1::rrc::s_tmsi_s* ue_identiy); void paging(srslte::s_tmsi_t* ue_identity);
void set_barring(barring_t barring); void set_barring(barring_t barring);
void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu); void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu);
uint32_t get_k_enb_count(); uint32_t get_k_enb_count();
@ -84,10 +84,10 @@ private:
nas_interface_rrc::barring_t current_barring; nas_interface_rrc::barring_t current_barring;
bool plmn_is_selected; bool plmn_is_selected;
asn1::rrc::plmn_id_s current_plmn; srslte::plmn_id_t current_plmn;
asn1::rrc::plmn_id_s home_plmn; srslte::plmn_id_t home_plmn;
std::vector<asn1::rrc::plmn_id_s> known_plmns; std::vector<srslte::plmn_id_t> known_plmns;
LIBLTE_MME_EMM_INFORMATION_MSG_STRUCT emm_info; LIBLTE_MME_EMM_INFORMATION_MSG_STRUCT emm_info;

@ -45,7 +45,7 @@ public:
bool get_imsi_vec(uint8_t* imsi_, uint32_t n); bool get_imsi_vec(uint8_t* imsi_, uint32_t n);
bool get_imei_vec(uint8_t* imei_, uint32_t n); bool get_imei_vec(uint8_t* imei_, uint32_t n);
bool get_home_plmn_id(asn1::rrc::plmn_id_s* home_plmn_id); bool get_home_plmn_id(srslte::plmn_id_t* home_plmn_id);
auth_result_t generate_authentication_response(uint8_t *rand, auth_result_t generate_authentication_response(uint8_t *rand,
uint8_t *autn_enb, uint8_t *autn_enb,

@ -69,7 +69,7 @@ public:
virtual bool get_imsi_vec(uint8_t* imsi_, uint32_t n) = 0; virtual bool get_imsi_vec(uint8_t* imsi_, uint32_t n) = 0;
virtual bool get_imei_vec(uint8_t* imei_, uint32_t n) = 0; virtual bool get_imei_vec(uint8_t* imei_, uint32_t n) = 0;
virtual bool get_home_plmn_id(asn1::rrc::plmn_id_s* home_plmn_id) = 0; virtual bool get_home_plmn_id(srslte::plmn_id_t* home_plmn_id) = 0;
virtual auth_result_t generate_authentication_response(uint8_t *rand, virtual auth_result_t generate_authentication_response(uint8_t *rand,
uint8_t *autn_enb, uint8_t *autn_enb,

@ -403,12 +403,12 @@ int rrc::plmn_search(found_plmn_t found_plmns[MAX_FOUND_PLMNS])
/* This is the NAS interface. When NAS requests to select a PLMN we have to /* This is the NAS interface. When NAS requests to select a PLMN we have to
* connect to either register or because there is pending higher layer traffic. * connect to either register or because there is pending higher layer traffic.
*/ */
void rrc::plmn_select(asn1::rrc::plmn_id_s plmn_id) void rrc::plmn_select(srslte::plmn_id_t plmn_id)
{ {
plmn_is_selected = true; plmn_is_selected = true;
selected_plmn_id = plmn_id; selected_plmn_id = plmn_id;
rrc_log->info("PLMN Selected %s\n", plmn_id_to_string(plmn_id).c_str()); rrc_log->info("PLMN Selected %s\n", plmn_id.to_string().c_str());
} }
/* 5.3.3.2 Initiation of RRC Connection Establishment procedure /* 5.3.3.2 Initiation of RRC Connection Establishment procedure
@ -419,7 +419,7 @@ void rrc::plmn_select(asn1::rrc::plmn_id_s plmn_id)
* it. Sends connectionRequest message and returns if message transmitted successfully. * it. Sends connectionRequest message and returns if message transmitted successfully.
* It does not wait until completition of Connection Establishment procedure * It does not wait until completition of Connection Establishment procedure
*/ */
bool rrc::connection_request(asn1::rrc::establishment_cause_e cause, srslte::unique_byte_buffer_t dedicated_info_nas) bool rrc::connection_request(srslte::establishment_cause_t cause, srslte::unique_byte_buffer_t dedicated_info_nas)
{ {
if (!plmn_is_selected) { if (!plmn_is_selected) {
@ -464,7 +464,8 @@ bool rrc::connection_request(asn1::rrc::establishment_cause_e cause, srslte::uni
mac_timers->timer_get(t300)->run(); mac_timers->timer_get(t300)->run();
// Send connectionRequest message to lower layers // Send connectionRequest message to lower layers
send_con_request(cause); establishment_cause_e asn1cause((establishment_cause_e::options)cause);
send_con_request(asn1cause);
// Save dedicatedInfoNAS SDU // Save dedicatedInfoNAS SDU
if (this->dedicated_info_nas.get()) { if (this->dedicated_info_nas.get()) {
@ -520,12 +521,12 @@ bool rrc::connection_request(asn1::rrc::establishment_cause_e cause, srslte::uni
return ret; return ret;
} }
void rrc::set_ue_idenity(asn1::rrc::s_tmsi_s s_tmsi) void rrc::set_ue_identity(srslte::s_tmsi_t s_tmsi)
{ {
ue_identity_configured = true; ue_identity_configured = true;
ue_identity = s_tmsi; ue_identity = s_tmsi;
rrc_log->info("Set ue-Identity to 0x%" PRIu64 ":0x%" PRIu64 "\n", ue_identity.mmec.to_number(), rrc_log->info(
ue_identity.m_tmsi.to_number()); "Set ue-Identity to 0x%" PRIu64 ":0x%" PRIu64 "\n", (uint64_t)ue_identity.mmec, (uint64_t)ue_identity.m_tmsi);
} }
/* Retrieves all required SIB or configures them if already retrieved before /* Retrieves all required SIB or configures them if already retrieved before
@ -1287,7 +1288,7 @@ void rrc::send_con_request(asn1::rrc::establishment_cause_e cause)
if (ue_identity_configured) { if (ue_identity_configured) {
rrc_conn_req->ue_id.set_s_tmsi(); rrc_conn_req->ue_id.set_s_tmsi();
rrc_conn_req->ue_id.s_tmsi() = ue_identity; ue_identity.to_asn1(&rrc_conn_req->ue_id.s_tmsi());
} else { } else {
rrc_conn_req->ue_id.set_random_value(); rrc_conn_req->ue_id.set_random_value();
// TODO use proper RNG // TODO use proper RNG
@ -2085,17 +2086,19 @@ void rrc::process_pcch(unique_byte_buffer_t pdu)
return; return;
} }
s_tmsi_s* s_tmsi_paged;
for (uint32_t i = 0; i < paging->paging_record_list.size(); i++) { for (uint32_t i = 0; i < paging->paging_record_list.size(); i++) {
s_tmsi_paged = &paging->paging_record_list[i].ue_id.s_tmsi(); s_tmsi_t s_tmsi_paged;
rrc_log->info("Received paging (%d/%d) for UE %" PRIu64 ":%" PRIu64 "\n", i + 1, s_tmsi_paged.from_asn1(&paging->paging_record_list[i].ue_id.s_tmsi());
paging->paging_record_list.size(), paging->paging_record_list[i].ue_id.s_tmsi().mmec.to_number(), rrc_log->info("Received paging (%d/%d) for UE %" PRIu64 ":%" PRIu64 "\n",
paging->paging_record_list[i].ue_id.s_tmsi().m_tmsi.to_number()); i + 1,
if (ue_identity.mmec == s_tmsi_paged->mmec && ue_identity.m_tmsi == s_tmsi_paged->m_tmsi) { paging->paging_record_list.size(),
(uint64_t)s_tmsi_paged.mmec,
(uint64_t)s_tmsi_paged.m_tmsi);
if (ue_identity.mmec == s_tmsi_paged.mmec && ue_identity.m_tmsi == s_tmsi_paged.m_tmsi) {
if (RRC_STATE_IDLE == state) { if (RRC_STATE_IDLE == state) {
rrc_log->info("S-TMSI match in paging message\n"); rrc_log->info("S-TMSI match in paging message\n");
rrc_log->console("S-TMSI match in paging message\n"); rrc_log->console("S-TMSI match in paging message\n");
nas->paging(s_tmsi_paged); nas->paging(&s_tmsi_paged);
} else { } else {
rrc_log->warning("Received paging while in CONNECT\n"); rrc_log->warning("Received paging while in CONNECT\n");
} }

@ -75,11 +75,7 @@ void nas::init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_
if (!usim->get_home_plmn_id(&home_plmn)) { if (!usim->get_home_plmn_id(&home_plmn)) {
nas_log->error("Getting Home PLMN Id from USIM. Defaulting to 001-01\n"); nas_log->error("Getting Home PLMN Id from USIM. Defaulting to 001-01\n");
uint16_t mcc = 61441; // This is 001 home_plmn.from_number(61441, 65281); // This is 001 01
uint16_t mnc = 65281; // This is 01
home_plmn.mcc_present = true;
srslte::mcc_to_bytes(mcc, &home_plmn.mcc[0]);
srslte::mnc_to_bytes(mnc, home_plmn.mnc);
} }
// parse and sanity check EIA list // parse and sanity check EIA list
@ -164,10 +160,10 @@ bool nas::attach_request() {
known_plmns.clear(); known_plmns.clear();
for (int i=0;i<nof_plmns;i++) { for (int i=0;i<nof_plmns;i++) {
known_plmns.push_back(found_plmns[i].plmn_id); known_plmns.push_back(found_plmns[i].plmn_id);
nas_log->info("Found PLMN: Id=%s, TAC=%d\n", plmn_id_to_string(found_plmns[i].plmn_id).c_str(), nas_log->info(
found_plmns[i].tac); "Found PLMN: Id=%s, TAC=%d\n", found_plmns[i].plmn_id.to_string().c_str(), found_plmns[i].tac);
nas_log->console("Found PLMN: Id=%s, TAC=%d\n", plmn_id_to_string(found_plmns[i].plmn_id).c_str(), nas_log->console(
found_plmns[i].tac); "Found PLMN: Id=%s, TAC=%d\n", found_plmns[i].plmn_id.to_string().c_str(), found_plmns[i].tac);
} }
select_plmn(); select_plmn();
} else if (nof_plmns == 0) { } else if (nof_plmns == 0) {
@ -242,7 +238,7 @@ bool nas::is_attached() {
return state == EMM_STATE_REGISTERED; return state == EMM_STATE_REGISTERED;
} }
void nas::paging(s_tmsi_s* ue_identiy) void nas::paging(s_tmsi_t* ue_identity)
{ {
if (state == EMM_STATE_REGISTERED) { if (state == EMM_STATE_REGISTERED) {
nas_log->info("Received paging: requesting RRC connection establishment\n"); nas_log->info("Received paging: requesting RRC connection establishment\n");
@ -283,17 +279,17 @@ bool nas::rrc_connect() {
// Provide UE-Identity to RRC if have one // Provide UE-Identity to RRC if have one
if (have_guti) { if (have_guti) {
s_tmsi_s s_tmsi; s_tmsi_t s_tmsi;
s_tmsi.mmec.from_number(ctxt.guti.mme_code); s_tmsi.m_tmsi = ctxt.guti.m_tmsi;
s_tmsi.m_tmsi.from_number(ctxt.guti.m_tmsi); s_tmsi.mmec = ctxt.guti.mme_code;
rrc->set_ue_idenity(s_tmsi); rrc->set_ue_identity(s_tmsi);
} }
// Set establishment cause // Set establishment cause
establishment_cause_e establish_cause = establishment_cause_e::mo_sig; srslte::establishment_cause_t establish_cause = srslte::establishment_cause_t::mo_sig;
if (state == EMM_STATE_REGISTERED) { if (state == EMM_STATE_REGISTERED) {
// FIXME: only need to use MT_ACCESS for establishment after paging // FIXME: only need to use MT_ACCESS for establishment after paging
establish_cause = establishment_cause_e::mt_access; establish_cause = establishment_cause_t::mt_access;
} }
if (rrc->connection_request(establish_cause, std::move(dedicatedInfoNAS))) { if (rrc->connection_request(establish_cause, std::move(dedicatedInfoNAS))) {
@ -329,7 +325,7 @@ void nas::select_plmn() {
// First find if Home PLMN is available // First find if Home PLMN is available
for (uint32_t i=0;i<known_plmns.size();i++) { for (uint32_t i=0;i<known_plmns.size();i++) {
if (known_plmns[i].mcc == home_plmn.mcc && known_plmns[i].mnc == home_plmn.mnc) { if (known_plmns[i].mcc == home_plmn.mcc && known_plmns[i].mnc == home_plmn.mnc) {
nas_log->info("Selecting Home PLMN Id=%s\n", plmn_id_to_string(known_plmns[i]).c_str()); nas_log->info("Selecting Home PLMN Id=%s\n", known_plmns[i].to_string().c_str());
plmn_is_selected = true; plmn_is_selected = true;
current_plmn = known_plmns[i]; current_plmn = known_plmns[i];
return; return;
@ -339,12 +335,12 @@ void nas::select_plmn() {
// If not, select the first available PLMN // If not, select the first available PLMN
if (known_plmns.size() > 0) { if (known_plmns.size() > 0) {
nas_log->info("Could not find Home PLMN Id=%s, trying to connect to PLMN Id=%s\n", nas_log->info("Could not find Home PLMN Id=%s, trying to connect to PLMN Id=%s\n",
plmn_id_to_string(home_plmn).c_str(), home_plmn.to_string().c_str(),
plmn_id_to_string(known_plmns[0]).c_str()); known_plmns[0].to_string().c_str());
nas_log->console("Could not find Home PLMN Id=%s, trying to connect to PLMN Id=%s\n", nas_log->console("Could not find Home PLMN Id=%s, trying to connect to PLMN Id=%s\n",
plmn_id_to_string(home_plmn).c_str(), home_plmn.to_string().c_str(),
plmn_id_to_string(known_plmns[0]).c_str()); known_plmns[0].to_string().c_str());
plmn_is_selected = true; plmn_is_selected = true;
current_plmn = known_plmns[0]; current_plmn = known_plmns[0];
} }
@ -676,10 +672,10 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu)
memcpy(&ctxt.guti, &attach_accept.guti.guti, sizeof(LIBLTE_MME_EPS_MOBILE_ID_GUTI_STRUCT)); memcpy(&ctxt.guti, &attach_accept.guti.guti, sizeof(LIBLTE_MME_EPS_MOBILE_ID_GUTI_STRUCT));
have_guti = true; have_guti = true;
// Update RRC UE-Idenity // Update RRC UE-Idenity
s_tmsi_s s_tmsi; s_tmsi_t s_tmsi;
s_tmsi.mmec.from_number(ctxt.guti.mme_code); s_tmsi.mmec = ctxt.guti.mme_code;
s_tmsi.m_tmsi.from_number(ctxt.guti.m_tmsi); s_tmsi.m_tmsi = ctxt.guti.m_tmsi;
rrc->set_ue_idenity(s_tmsi); rrc->set_ue_identity(s_tmsi);
} }
if (attach_accept.lai_present) {} if (attach_accept.lai_present) {}
if (attach_accept.ms_id_present) {} if (attach_accept.ms_id_present) {}
@ -1542,7 +1538,7 @@ void nas::send_detach_request(bool switch_off)
if (rrc->is_connected()) { if (rrc->is_connected()) {
rrc->write_sdu(std::move(pdu)); rrc->write_sdu(std::move(pdu));
} else { } else {
rrc->connection_request(establishment_cause_e::mo_sig, std::move(pdu)); rrc->connection_request(establishment_cause_t::mo_sig, std::move(pdu));
} }
} }

@ -153,7 +153,7 @@ bool usim::get_imei_vec(uint8_t* imei_, uint32_t n)
return true; return true;
} }
bool usim::get_home_plmn_id(plmn_id_s* home_plmn_id) bool usim::get_home_plmn_id(srslte::plmn_id_t* home_plmn_id)
{ {
if (!initiated) { if (!initiated) {
ERROR("USIM not initiated!\n"); ERROR("USIM not initiated!\n");
@ -185,10 +185,9 @@ bool usim::get_home_plmn_id(plmn_id_s* home_plmn_id)
mnc_str << (int) imsi_vec[i]; mnc_str << (int) imsi_vec[i];
} }
string_to_plmn_id(*home_plmn_id, mcc_str.str() + mnc_str.str()); home_plmn_id->from_string(mcc_str.str() + mnc_str.str());
usim_log->info("Read Home PLMN Id=%s\n", usim_log->info("Read Home PLMN Id=%s\n", home_plmn_id->to_string().c_str());
plmn_id_to_string(*home_plmn_id).c_str());
return true; return true;
} }

@ -19,7 +19,7 @@
# #
add_executable(usim_test usim_test.cc) add_executable(usim_test usim_test.cc)
target_link_libraries(usim_test srsue_upper srslte_upper srslte_phy) target_link_libraries(usim_test srsue_upper srslte_upper srslte_phy rrc_asn1)
add_test(usim_test usim_test) add_test(usim_test usim_test)
if(HAVE_PCSC) if(HAVE_PCSC)

@ -97,9 +97,7 @@ class rrc_dummy : public rrc_interface_nas
{ {
public: public:
rrc_dummy() : last_sdu_len(0) { rrc_dummy() : last_sdu_len(0) {
plmns.plmn_id.mcc_present = true; plmns.plmn_id.from_number(mcc, mnc);
mcc_to_bytes(mcc, plmns.plmn_id.mcc.data());
mnc_to_bytes(mnc, plmns.plmn_id.mnc);
plmns.tac = 0xffff; plmns.tac = 0xffff;
} }
void write_sdu(unique_byte_buffer_t sdu) void write_sdu(unique_byte_buffer_t sdu)
@ -116,9 +114,9 @@ public:
memcpy(found, &plmns, sizeof(found_plmn_t)); memcpy(found, &plmns, sizeof(found_plmn_t));
return 1; return 1;
}; };
void plmn_select(plmn_id_s plmn_id){}; void plmn_select(srslte::plmn_id_t plmn_id){};
void set_ue_idenity(s_tmsi_s s_tmsi) {} void set_ue_identity(srslte::s_tmsi_t s_tmsi) {}
bool connection_request(establishment_cause_e cause, srslte::unique_byte_buffer_t sdu) bool connection_request(srslte::establishment_cause_t cause, srslte::unique_byte_buffer_t sdu)
{ {
printf("NAS generated SDU (len=%d):\n", sdu->N_bytes); printf("NAS generated SDU (len=%d):\n", sdu->N_bytes);
last_sdu_len = sdu->N_bytes; last_sdu_len = sdu->N_bytes;

Loading…
Cancel
Save