mirror of https://github.com/PentHertz/srsLTE.git
add return value to USIM init and exit UE if reader wasn't found
This commit is contained in:
parent
3b70c70eee
commit
0a6a72832a
|
@ -65,7 +65,7 @@ class pcsc_usim
|
||||||
public:
|
public:
|
||||||
pcsc_usim();
|
pcsc_usim();
|
||||||
~pcsc_usim();
|
~pcsc_usim();
|
||||||
void init(usim_args_t *args, srslte::log *usim_log_);
|
int init(usim_args_t *args, srslte::log *usim_log_);
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
// NAS interface
|
// NAS interface
|
||||||
|
|
|
@ -41,7 +41,7 @@ class usim
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
usim();
|
usim();
|
||||||
void init(usim_args_t *args, srslte::log *usim_log_);
|
int init(usim_args_t *args, srslte::log *usim_log_);
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
// NAS interface
|
// NAS interface
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
virtual ~usim_base();
|
virtual ~usim_base();
|
||||||
static usim_base* get_instance(usim_args_t *args, srslte::log *usim_log_);
|
static usim_base* get_instance(usim_args_t *args, srslte::log *usim_log_);
|
||||||
|
|
||||||
virtual void init(usim_args_t *args, srslte::log *usim_log_) = 0;
|
virtual int init(usim_args_t *args, srslte::log *usim_log_) = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
|
|
||||||
// NAS interface
|
// NAS interface
|
||||||
|
|
|
@ -133,6 +133,13 @@ bool ue::init(all_args_t *args_) {
|
||||||
|
|
||||||
// Init layers
|
// Init layers
|
||||||
|
|
||||||
|
// Init USIM first to allow early exit in case reader couldn't be found
|
||||||
|
usim = usim_base::get_instance(&args->usim, &usim_log);
|
||||||
|
if (usim->init(&args->usim, &usim_log)) {
|
||||||
|
usim_log.console("Failed to initialize USIM.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// PHY inits in background, start before radio
|
// PHY inits in background, start before radio
|
||||||
args->expert.phy.nof_rx_ant = args->rf.nof_rx_ant;
|
args->expert.phy.nof_rx_ant = args->rf.nof_rx_ant;
|
||||||
phy.init(&radio, &mac, &rrc, phy_log, &args->expert.phy);
|
phy.init(&radio, &mac, &rrc, phy_log, &args->expert.phy);
|
||||||
|
@ -197,8 +204,7 @@ bool ue::init(all_args_t *args_) {
|
||||||
mac.init(&phy, &rlc, &rrc, &mac_log);
|
mac.init(&phy, &rlc, &rrc, &mac_log);
|
||||||
rlc.init(&pdcp, &rrc, this, &rlc_log, &mac, 0 /* RB_ID_SRB0 */);
|
rlc.init(&pdcp, &rrc, this, &rlc_log, &mac, 0 /* RB_ID_SRB0 */);
|
||||||
pdcp.init(&rlc, &rrc, &gw, &pdcp_log, 0 /* RB_ID_SRB0 */, SECURITY_DIRECTION_UPLINK);
|
pdcp.init(&rlc, &rrc, &gw, &pdcp_log, 0 /* RB_ID_SRB0 */, SECURITY_DIRECTION_UPLINK);
|
||||||
usim = usim_base::get_instance(&args->usim, &usim_log);
|
|
||||||
usim->init(&args->usim, &usim_log);
|
|
||||||
srslte_nas_config_t nas_cfg(1, args->apn); /* RB_ID_SRB1 */
|
srslte_nas_config_t nas_cfg(1, args->apn); /* RB_ID_SRB1 */
|
||||||
nas.init(usim, &rrc, &gw, &nas_log, nas_cfg);
|
nas.init(usim, &rrc, &gw, &nas_log, nas_cfg);
|
||||||
gw.init(&pdcp, &nas, &gw_log, 3 /* RB_ID_DRB1 */);
|
gw.init(&pdcp, &nas, &gw_log, 3 /* RB_ID_DRB1 */);
|
||||||
|
|
|
@ -45,12 +45,12 @@ pcsc_usim::~pcsc_usim()
|
||||||
sc.deinit();
|
sc.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcsc_usim::init(usim_args_t *args, srslte::log *log_)
|
int pcsc_usim::init(usim_args_t *args, srslte::log *log_)
|
||||||
{
|
{
|
||||||
log = log_;
|
log = log_;
|
||||||
|
|
||||||
if (sc.init(args, log_) == SRSLTE_SUCCESS) {
|
if (sc.init(args, log_) != SRSLTE_SUCCESS) {
|
||||||
initiated = true;
|
return SRSLTE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read IMSI from SIM card
|
// Read IMSI from SIM card
|
||||||
|
@ -92,6 +92,10 @@ void pcsc_usim::init(usim_args_t *args, srslte::log *log_)
|
||||||
// Get MNC length
|
// Get MNC length
|
||||||
mnc_length = sc.get_mnc_len();
|
mnc_length = sc.get_mnc_len();
|
||||||
log->debug("MNC length %d\n", mnc_length);
|
log->debug("MNC length %d\n", mnc_length);
|
||||||
|
|
||||||
|
initiated = true;
|
||||||
|
|
||||||
|
return SRSLTE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcsc_usim::stop()
|
void pcsc_usim::stop()
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace srsue{
|
||||||
usim::usim() : initiated(false)
|
usim::usim() : initiated(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void usim::init(usim_args_t *args, srslte::log *usim_log_)
|
int usim::init(usim_args_t *args, srslte::log *usim_log_)
|
||||||
{
|
{
|
||||||
usim_log = usim_log_;
|
usim_log = usim_log_;
|
||||||
imsi_str = args->imsi;
|
imsi_str = args->imsi;
|
||||||
|
@ -89,6 +89,8 @@ void usim::init(usim_args_t *args, srslte::log *usim_log_)
|
||||||
auth_algo = auth_algo_xor;
|
auth_algo = auth_algo_xor;
|
||||||
}
|
}
|
||||||
initiated = true;
|
initiated = true;
|
||||||
|
|
||||||
|
return SRSLTE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usim::stop()
|
void usim::stop()
|
||||||
|
|
Loading…
Reference in New Issue