Skip to content

Commit

Permalink
Adding emergency registration procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
kbaccar-2 committed Dec 16, 2022
1 parent 254cc71 commit 317e988
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion srsue/hdr/stack/upper/nas_5g.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,4 @@ class nas_5g : public nas_base, public nas_5g_interface_rrc_nr, public nas_5g_in
std::array<pdu_session_t, MAX_PDU_SESSIONS> pdu_sessions;
};
} // namespace srsue
#endif
#endif
2 changes: 2 additions & 0 deletions srsue/hdr/stack/upper/nas_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class nas_5g_args_t
std::string ia5g;
std::string ea5g;
std::vector<pdu_session_cfg_t> pdu_session_cfgs;
bool emergency_registration;

};

} // namespace srsue
Expand Down
3 changes: 2 additions & 1 deletion srsue/src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,14 @@ static int parse_args(all_args_t* args, int argc, char* argv[])
("rrc.nr_measurement_pci", bpo::value<uint32_t>(&args->stack.rrc_nr.sim_nr_meas_pci)->default_value(500), "NR PCI for the simulated NR measurement")
("rrc.nr_short_sn_support", bpo::value<bool>(&args->stack.rrc_nr.pdcp_short_sn_support)->default_value(true), "Announce PDCP short SN support")

("nas.apn", bpo::value<string>(&args->stack.nas.apn_name)->default_value(""), "Set Access Point Name (APN) for data services")
("nas.apn", bpo::value<string>(&args->stack.nas.apn_name)->default_value(""), "Set Access Point Name (APN) for data services")
("nas.apn_protocol", bpo::value<string>(&args->stack.nas.apn_protocol)->default_value(""), "Set Access Point Name (APN) protocol for data services")
("nas.user", bpo::value<string>(&args->stack.nas.apn_user)->default_value(""), "Username for CHAP authentication")
("nas.pass", bpo::value<string>(&args->stack.nas.apn_pass)->default_value(""), "Password for CHAP authentication")
("nas.force_imsi_attach", bpo::value<bool>(&args->stack.nas.force_imsi_attach)->default_value(false), "Whether to always perform an IMSI attach")
("nas.eia", bpo::value<string>(&args->stack.nas.eia)->default_value("1,2,3"), "List of integrity algorithms included in UE capabilities")
("nas.eea", bpo::value<string>(&args->stack.nas.eea)->default_value("0,1,2,3"), "List of ciphering algorithms included in UE capabilities")
("nas.enable_emergency_reg", bpo::value<bool>(&args->stack.nas_5g.emergency_registration)->default_value(false), "Specifies if it is an anonymous emergency registration.")

("pcap.enable", bpo::value<string>(&args->stack.pkt_trace.enable)->default_value("none"), "Enable (MAC, MAC_NR, NAS) packet captures for wireshark")
("pcap.mac_filename", bpo::value<string>(&args->stack.pkt_trace.mac_pcap.filename)->default_value("/tmp/ue_mac.pcap"), "MAC layer capture filename")
Expand Down
31 changes: 20 additions & 11 deletions srsue/src/stack/upper/nas_5g.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,23 +249,31 @@ int nas_5g::write_pdu(srsran::unique_byte_buffer_t pdu)
/*******************************************************************************
* Senders
******************************************************************************/

int nas_5g::send_registration_request()
{

unique_byte_buffer_t pdu = srsran::make_byte_buffer();
if (!pdu) {
logger.error("Couldn't allocate PDU in %s().", __FUNCTION__);
return SRSRAN_ERROR;
}

initial_registration_request_stored.hdr.extended_protocol_discriminator =
nas_5gs_hdr::extended_protocol_discriminator_opts::extended_protocol_discriminator_5gmm;
nas_5gs_hdr::extended_protocol_discriminator_opts::extended_protocol_discriminator_5gmm;
registration_request_t& reg_req = initial_registration_request_stored.set_registration_request();

reg_req.registration_type_5gs.follow_on_request_bit =
registration_type_5gs_t::follow_on_request_bit_type_::options::follow_on_request_pending;
registration_type_5gs_t::follow_on_request_bit_type_::options::follow_on_request_pending;

if(cfg.emergency_registration){
reg_req.registration_type_5gs.registration_type =
registration_type_5gs_t::registration_type_type_::options::emergency_registration;

mobile_identity_5gs_t::imei_s& imei = reg_req.mobile_identity_5gs.set_imei();
usim->get_imei_vec(imei.imei.data(), 15);
}
else {
reg_req.registration_type_5gs.registration_type =
registration_type_5gs_t::registration_type_type_::options::initial_registration;
registration_type_5gs_t::registration_type_type_::options::initial_registration;
mobile_identity_5gs_t::suci_s& suci = reg_req.mobile_identity_5gs.set_suci();
suci.supi_format = mobile_identity_5gs_t::suci_s::supi_format_type_::options::imsi;
usim->get_home_mcc_bytes(suci.mcc.data(), suci.mcc.size());
Expand All @@ -274,15 +282,15 @@ int nas_5g::send_registration_request()
suci.scheme_output.resize(5);
usim->get_home_msin_bcd(suci.scheme_output.data(), 5);
logger.info("Requesting IMSI attach (IMSI=%s)", usim->get_imsi_str().c_str());
}

reg_req.ue_security_capability_present = true;
fill_security_caps(reg_req.ue_security_capability);

if (initial_registration_request_stored.pack(pdu) != SRSASN_SUCCESS) {
logger.error("Failed to pack registration request");
return SRSRAN_ERROR;
logger.error("Failed to pack registration request");
return SRSRAN_ERROR;
}

if (pcap != nullptr) {
pcap->write_nas(pdu.get()->msg, pdu.get()->N_bytes);
}
Expand Down Expand Up @@ -582,13 +590,14 @@ int nas_5g::send_pdu_session_establishment_request(uint32_t tran
ul_nas_msg.pdu_session_id.pdu_session_identity_2_value = pdu_session_id;

ul_nas_msg.request_type_present = true;
ul_nas_msg.request_type.request_type_value = request_type_t::Request_type_value_type_::options::initial_request;
ul_nas_msg.request_type.request_type_value = (cfg.emergency_registration)? request_type_t::Request_type_value_type_::initial_emergency_request:
request_type_t::Request_type_value_type_::options::initial_request;

ul_nas_msg.s_nssai_present = true;
ul_nas_msg.s_nssai_present = (cfg.emergency_registration)? false:true;
ul_nas_msg.s_nssai.type = s_nssai_t::SST_type_::options::sst;
ul_nas_msg.s_nssai.sst = 1;

ul_nas_msg.dnn_present = true;
ul_nas_msg.dnn_present = (cfg.emergency_registration)? false:true;
ul_nas_msg.dnn.dnn_value.resize(pdu_session_cfg.apn_name.size() + 1);
ul_nas_msg.dnn.dnn_value.data()[0] = static_cast<uint8_t>(pdu_session_cfg.apn_name.size());

Expand Down
8 changes: 2 additions & 6 deletions srsue/src/stack/upper/nas_5g_procedures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ srsran::proc_outcome_t nas_5g::pdu_session_establishment_procedure::init(const u
srsran::proc_outcome_t nas_5g::pdu_session_establishment_procedure::react(
const srsran::nas_5g::pdu_session_establishment_accept_t& pdu_session_est_accept)
{
// TODO check the pdu session values
if (pdu_session_est_accept.dnn_present == false) {
logger.warning("Expected DNN in PDU session establishment accept");
return proc_outcome_t::error;
}

if (pdu_session_est_accept.pdu_address_present == false) {
logger.warning("Expected PDU Address in PDU session establishment accept");
return proc_outcome_t::error;
Expand Down Expand Up @@ -98,4 +94,4 @@ srsran::proc_outcome_t nas_5g::pdu_session_establishment_procedure::step()
return srsran::proc_outcome_t::success;
}

} // namespace srsue
} // namespace srsue

0 comments on commit 317e988

Please sign in to comment.