add option to force IMSI attach by not loading NAS ctxt from file

This commit is contained in:
Andre Puschmann 2018-06-19 14:23:47 +02:00
parent fb82e00289
commit 01f6395d70
7 changed files with 32 additions and 12 deletions

View File

@ -38,17 +38,19 @@ namespace srslte {
class srslte_nas_config_t
{
public:
srslte_nas_config_t(uint32_t lcid_ = 0, std::string apn_ = "", std::string user_ = "", std::string pass_ = "")
srslte_nas_config_t(uint32_t lcid_ = 0, std::string apn_ = "", std::string user_ = "", std::string pass_ = "", bool force_imsi_attach_ = false)
:lcid(lcid_),
apn(apn_),
user(user_),
pass(pass_)
pass(pass_),
force_imsi_attach(force_imsi_attach_)
{}
uint32_t lcid;
std::string apn;
std::string user;
std::string pass;
bool force_imsi_attach;
};

View File

@ -39,6 +39,7 @@
#include "phy/phy.h"
#include "upper/usim.h"
#include "upper/rrc.h"
#include "upper/nas.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/common/logger.h"
@ -129,9 +130,7 @@ typedef struct {
usim_args_t usim;
rrc_args_t rrc;
std::string ue_category_str;
std::string apn_name;
std::string apn_user;
std::string apn_pass;
nas_args_t nas;
expert_args_t expert;
}all_args_t;

View File

@ -39,6 +39,13 @@ using srslte::byte_buffer_t;
namespace srsue {
typedef struct {
std::string apn_name;
std::string apn_user;
std::string apn_pass;
bool force_imsi_attach;
} nas_args_t;
// EMM states (3GPP 24.302 v10.0.0)
typedef enum {
EMM_STATE_NULL = 0,

View File

@ -84,9 +84,11 @@ void parse_args(all_args_t *args, int argc, char *argv[]) {
"UECapabilityInformation message. Default 0xe6041000")
("rrc.ue_category", bpo::value<string>(&args->ue_category_str)->default_value("4"), "UE Category (1 to 5)")
("nas.apn", bpo::value<string>(&args->apn_name)->default_value(""), "Set Access Point Name (APN) for data services")
("nas.user", bpo::value<string>(&args->apn_user)->default_value(""), "Username for CHAP authentication")
("nas.pass", bpo::value<string>(&args->apn_pass)->default_value(""), "Password for CHAP authentication")
("nas.apn", bpo::value<string>(&args->nas.apn_name)->default_value(""), "Set Access Point Name (APN) for data services")
("nas.user", bpo::value<string>(&args->nas.apn_user)->default_value(""), "Username for CHAP authentication")
("nas.pass", bpo::value<string>(&args->nas.apn_pass)->default_value(""), "Password for CHAP authentication")
("nas.force_imsi_attach", bpo::value<bool>(&args->nas.force_imsi_attach)->default_value(false), "Whether to always perform an IMSI attach")
("pcap.enable", bpo::value<bool>(&args->pcap.enable)->default_value(false), "Enable MAC packet captures for wireshark")
("pcap.filename", bpo::value<string>(&args->pcap.filename)->default_value("ue.pcap"), "MAC layer capture filename")

View File

@ -210,7 +210,7 @@ bool ue::init(all_args_t *args_) {
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);
srslte_nas_config_t nas_cfg(1, args->apn_name, args->apn_user, args->apn_pass); /* RB_ID_SRB1 */
srslte_nas_config_t nas_cfg(1, args->nas.apn_name, args->nas.apn_user, args->nas.apn_pass, args->nas.force_imsi_attach); /* RB_ID_SRB1 */
nas.init(usim, &rrc, &gw, &nas_log, nas_cfg);
gw.init(&pdcp, &nas, &gw_log, 3 /* RB_ID_DRB1 */);
gw.set_netmask(args->expert.ip_netmask);

View File

@ -1364,6 +1364,11 @@ bool nas::read_ctxt_file(nas_sec_ctxt *ctxt)
return false;
}
if (cfg.force_imsi_attach) {
nas_log->info("Skip reading context from file.\n");
return false;
}
file.open(".ctxt", std::ios::in);
if(file.is_open()) {
if(!readvar(file, "m_tmsi=", &ctxt->guti.m_tmsi)) {return false;}

View File

@ -119,11 +119,16 @@ imei = 353490069873319
#####################################################################
# NAS configuration
#
# apn: Set Access Point Name (APN)
# apn: Set Access Point Name (APN)
# user: Username for CHAP authentication
# pass: Password for CHAP authentication
# force_imsi_attach: Whether to always perform an IMSI
#####################################################################
[nas]
# apn = internetinternet
#apn = internetinternet
#user = srsuser
#pass = srspass
#force_imsi_attach = false
[gui]
enable = false