From 317e988b60f55d20dc92c373da0be6891312038f Mon Sep 17 00:00:00 2001 From: Karim Baccar Date: Fri, 16 Dec 2022 16:23:14 +0100 Subject: [PATCH 1/4] Adding emergency registration procedure --- srsue/hdr/stack/upper/nas_5g.h | 2 +- srsue/hdr/stack/upper/nas_config.h | 2 ++ srsue/src/main.cc | 3 ++- srsue/src/stack/upper/nas_5g.cc | 31 ++++++++++++++-------- srsue/src/stack/upper/nas_5g_procedures.cc | 8 ++---- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/srsue/hdr/stack/upper/nas_5g.h b/srsue/hdr/stack/upper/nas_5g.h index 122ab15e29..4b00081e8e 100644 --- a/srsue/hdr/stack/upper/nas_5g.h +++ b/srsue/hdr/stack/upper/nas_5g.h @@ -208,4 +208,4 @@ class nas_5g : public nas_base, public nas_5g_interface_rrc_nr, public nas_5g_in std::array pdu_sessions; }; } // namespace srsue -#endif \ No newline at end of file +#endif diff --git a/srsue/hdr/stack/upper/nas_config.h b/srsue/hdr/stack/upper/nas_config.h index 0d7184e2f7..f6d7a933d2 100644 --- a/srsue/hdr/stack/upper/nas_config.h +++ b/srsue/hdr/stack/upper/nas_config.h @@ -67,6 +67,8 @@ class nas_5g_args_t std::string ia5g; std::string ea5g; std::vector pdu_session_cfgs; + bool emergency_registration; + }; } // namespace srsue diff --git a/srsue/src/main.cc b/srsue/src/main.cc index ac51d2d98b..979eca69af 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -153,13 +153,14 @@ static int parse_args(all_args_t* args, int argc, char* argv[]) ("rrc.nr_measurement_pci", bpo::value(&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(&args->stack.rrc_nr.pdcp_short_sn_support)->default_value(true), "Announce PDCP short SN support") - ("nas.apn", bpo::value(&args->stack.nas.apn_name)->default_value(""), "Set Access Point Name (APN) for data services") + ("nas.apn", bpo::value(&args->stack.nas.apn_name)->default_value(""), "Set Access Point Name (APN) for data services") ("nas.apn_protocol", bpo::value(&args->stack.nas.apn_protocol)->default_value(""), "Set Access Point Name (APN) protocol for data services") ("nas.user", bpo::value(&args->stack.nas.apn_user)->default_value(""), "Username for CHAP authentication") ("nas.pass", bpo::value(&args->stack.nas.apn_pass)->default_value(""), "Password for CHAP authentication") ("nas.force_imsi_attach", bpo::value(&args->stack.nas.force_imsi_attach)->default_value(false), "Whether to always perform an IMSI attach") ("nas.eia", bpo::value(&args->stack.nas.eia)->default_value("1,2,3"), "List of integrity algorithms included in UE capabilities") ("nas.eea", bpo::value(&args->stack.nas.eea)->default_value("0,1,2,3"), "List of ciphering algorithms included in UE capabilities") + ("nas.enable_emergency_reg", bpo::value(&args->stack.nas_5g.emergency_registration)->default_value(false), "Specifies if it is an anonymous emergency registration.") ("pcap.enable", bpo::value(&args->stack.pkt_trace.enable)->default_value("none"), "Enable (MAC, MAC_NR, NAS) packet captures for wireshark") ("pcap.mac_filename", bpo::value(&args->stack.pkt_trace.mac_pcap.filename)->default_value("/tmp/ue_mac.pcap"), "MAC layer capture filename") diff --git a/srsue/src/stack/upper/nas_5g.cc b/srsue/src/stack/upper/nas_5g.cc index 1f8ac1ec1b..0fc2ffb057 100644 --- a/srsue/src/stack/upper/nas_5g.cc +++ b/srsue/src/stack/upper/nas_5g.cc @@ -249,9 +249,9 @@ 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__); @@ -259,13 +259,21 @@ int nas_5g::send_registration_request() } 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()); @@ -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); } @@ -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(pdu_session_cfg.apn_name.size()); diff --git a/srsue/src/stack/upper/nas_5g_procedures.cc b/srsue/src/stack/upper/nas_5g_procedures.cc index 0d388a18f5..15e4089448 100644 --- a/srsue/src/stack/upper/nas_5g_procedures.cc +++ b/srsue/src/stack/upper/nas_5g_procedures.cc @@ -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; @@ -98,4 +94,4 @@ srsran::proc_outcome_t nas_5g::pdu_session_establishment_procedure::step() return srsran::proc_outcome_t::success; } -} // namespace srsue \ No newline at end of file +} // namespace srsue From 269ddad339ffefffae8d3eb9c0ed30697457563e Mon Sep 17 00:00:00 2001 From: kbaccar Date: Mon, 13 Feb 2023 11:10:38 +0100 Subject: [PATCH 2/4] fixing typos and adding commit --- lib/include/srsran/interfaces/ue_nas_interfaces.h | 2 ++ srsue/hdr/stack/upper/nas_5g_procedures.h | 5 +++-- srsue/hdr/stack/upper/nas_config.h | 3 +-- srsue/src/main.cc | 2 +- srsue/src/stack/upper/nas_5g.cc | 12 ++++++------ srsue/src/stack/upper/nas_5g_procedures.cc | 11 ++++++++++- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/include/srsran/interfaces/ue_nas_interfaces.h b/lib/include/srsran/interfaces/ue_nas_interfaces.h index 133fef6ca1..5d3dd2de33 100644 --- a/lib/include/srsran/interfaces/ue_nas_interfaces.h +++ b/lib/include/srsran/interfaces/ue_nas_interfaces.h @@ -41,6 +41,7 @@ class pdu_session_cfg_t apn_types apn_type = ipv4; std::string apn_user; std::string apn_pass; + bool emergency_registration_5g; }; class nas_interface_rrc { @@ -83,6 +84,7 @@ class nas_5g_interface_procedures add_pdu_session(uint16_t pdu_session_id, uint16_t pdu_session_type, srsran::nas_5g::pdu_address_t pdu_address) = 0; virtual uint32_t allocate_next_proc_trans_id() = 0; + }; } // namespace srsue diff --git a/srsue/hdr/stack/upper/nas_5g_procedures.h b/srsue/hdr/stack/upper/nas_5g_procedures.h index 60716f75f7..a892501d75 100644 --- a/srsue/hdr/stack/upper/nas_5g_procedures.h +++ b/srsue/hdr/stack/upper/nas_5g_procedures.h @@ -57,7 +57,7 @@ class nas_5g::pdu_session_establishment_procedure { public: explicit pdu_session_establishment_procedure(nas_5g_interface_procedures* parent_nas_, srslog::basic_logger& logger_); - srsran::proc_outcome_t init(const uint16_t pdu_session_id, const pdu_session_cfg_t& pdu_session); + srsran::proc_outcome_t init(const uint16_t pdu_session_id, const pdu_session_cfg_t& pdu_session, const bool emergency_pdu_session); srsran::proc_outcome_t react(const srsran::nas_5g::pdu_session_establishment_accept_t& pdu_session_est_accept); srsran::proc_outcome_t react(const srsran::nas_5g::pdu_session_establishment_reject_t& pdu_session_est_reject); srsran::proc_outcome_t step(); @@ -69,8 +69,9 @@ class nas_5g::pdu_session_establishment_procedure nas_5g_interface_procedures* parent_nas; uint32_t transaction_identity = 0; uint16_t pdu_session_id = 0; + bool emergency_pdu_session = false; }; } // namespace srsue -#endif // SRSUE_NAS_5G_PROCEDURES_H_ \ No newline at end of file +#endif // SRSUE_NAS_5G_PROCEDURES_H_ diff --git a/srsue/hdr/stack/upper/nas_config.h b/srsue/hdr/stack/upper/nas_config.h index f6d7a933d2..6d33cc7df0 100644 --- a/srsue/hdr/stack/upper/nas_config.h +++ b/srsue/hdr/stack/upper/nas_config.h @@ -67,8 +67,7 @@ class nas_5g_args_t std::string ia5g; std::string ea5g; std::vector pdu_session_cfgs; - bool emergency_registration; - + bool emergency_registration_5g; }; } // namespace srsue diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 979eca69af..54cdbfb698 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -160,7 +160,7 @@ static int parse_args(all_args_t* args, int argc, char* argv[]) ("nas.force_imsi_attach", bpo::value(&args->stack.nas.force_imsi_attach)->default_value(false), "Whether to always perform an IMSI attach") ("nas.eia", bpo::value(&args->stack.nas.eia)->default_value("1,2,3"), "List of integrity algorithms included in UE capabilities") ("nas.eea", bpo::value(&args->stack.nas.eea)->default_value("0,1,2,3"), "List of ciphering algorithms included in UE capabilities") - ("nas.enable_emergency_reg", bpo::value(&args->stack.nas_5g.emergency_registration)->default_value(false), "Specifies if it is an anonymous emergency registration.") + ("nas.enable_emergency_reg_5g", bpo::value(&args->stack.nas_5g.emergency_registration_5g)->default_value(false), "Specifies if it is an anonymous emergency registration.") ("pcap.enable", bpo::value(&args->stack.pkt_trace.enable)->default_value("none"), "Enable (MAC, MAC_NR, NAS) packet captures for wireshark") ("pcap.mac_filename", bpo::value(&args->stack.pkt_trace.mac_pcap.filename)->default_value("/tmp/ue_mac.pcap"), "MAC layer capture filename") diff --git a/srsue/src/stack/upper/nas_5g.cc b/srsue/src/stack/upper/nas_5g.cc index 0fc2ffb057..23ee85392f 100644 --- a/srsue/src/stack/upper/nas_5g.cc +++ b/srsue/src/stack/upper/nas_5g.cc @@ -249,9 +249,9 @@ 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__); @@ -264,7 +264,7 @@ int nas_5g::send_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; - if(cfg.emergency_registration){ + if(cfg.emergency_registration_5g){ reg_req.registration_type_5gs.registration_type = registration_type_5gs_t::registration_type_type_::options::emergency_registration; @@ -590,14 +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 = (cfg.emergency_registration)? request_type_t::Request_type_value_type_::initial_emergency_request: + ul_nas_msg.request_type.request_type_value = (cfg.emergency_registration_5g)? 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 = (cfg.emergency_registration)? false:true; + ul_nas_msg.s_nssai_present = (cfg.emergency_registration_5g)? 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 = (cfg.emergency_registration)? false:true; + ul_nas_msg.dnn_present = (cfg.emergency_registration_5g)? 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(pdu_session_cfg.apn_name.size()); @@ -1246,7 +1246,7 @@ int nas_5g::trigger_pdu_session_est() pdu_session_cfg_t pdu_session_cfg; uint16_t pdu_session_id; get_unestablished_pdu_session(pdu_session_id, pdu_session_cfg); - pdu_session_establishment_proc.launch(pdu_session_id, pdu_session_cfg); + pdu_session_establishment_proc.launch(pdu_session_id, pdu_session_cfg,cfg.emergency_registration_5g); } return SRSRAN_SUCCESS; } diff --git a/srsue/src/stack/upper/nas_5g_procedures.cc b/srsue/src/stack/upper/nas_5g_procedures.cc index 15e4089448..22708a2808 100644 --- a/srsue/src/stack/upper/nas_5g_procedures.cc +++ b/srsue/src/stack/upper/nas_5g_procedures.cc @@ -52,19 +52,28 @@ nas_5g::pdu_session_establishment_procedure::pdu_session_establishment_procedure {} srsran::proc_outcome_t nas_5g::pdu_session_establishment_procedure::init(const uint16_t pdu_session_id_, - const pdu_session_cfg_t& pdu_session_cfg) + const pdu_session_cfg_t& pdu_session_cfg, + const bool emergency_pdu_session_) { // Get PDU transaction identity transaction_identity = parent_nas->allocate_next_proc_trans_id(); pdu_session_id = pdu_session_id_; parent_nas->send_pdu_session_establishment_request(transaction_identity, pdu_session_id, pdu_session_cfg); + //Check if emergency registration is enabled + emergency_pdu_session = emergency_pdu_session_; + return srsran::proc_outcome_t::yield; } 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 and not emergency_pdu_session){ + 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"); From ae6a7ef6f42d99779df28e464d182f315d0f403c Mon Sep 17 00:00:00 2001 From: kbaccar Date: Mon, 13 Feb 2023 11:49:23 +0100 Subject: [PATCH 3/4] fixing typo --- lib/include/srsran/interfaces/ue_nas_interfaces.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/include/srsran/interfaces/ue_nas_interfaces.h b/lib/include/srsran/interfaces/ue_nas_interfaces.h index 5d3dd2de33..01f51566a2 100644 --- a/lib/include/srsran/interfaces/ue_nas_interfaces.h +++ b/lib/include/srsran/interfaces/ue_nas_interfaces.h @@ -84,7 +84,6 @@ class nas_5g_interface_procedures add_pdu_session(uint16_t pdu_session_id, uint16_t pdu_session_type, srsran::nas_5g::pdu_address_t pdu_address) = 0; virtual uint32_t allocate_next_proc_trans_id() = 0; - }; } // namespace srsue From db5068813bed2621269206a93a6b4defe8b49542 Mon Sep 17 00:00:00 2001 From: Karim Baccar Date: Tue, 23 May 2023 14:14:41 +0100 Subject: [PATCH 4/4] Update nas_5g.cc fixing typo --- srsue/src/stack/upper/nas_5g.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srsue/src/stack/upper/nas_5g.cc b/srsue/src/stack/upper/nas_5g.cc index 59e7f8c74f..a9f138d958 100644 --- a/srsue/src/stack/upper/nas_5g.cc +++ b/srsue/src/stack/upper/nas_5g.cc @@ -579,7 +579,7 @@ int nas_5g::send_pdu_session_establishment_request(uint32_t tran pdu_ses_est_req.pdu_session_type.pdu_session_type_value = static_cast(pdu_session_cfg.apn_type); - pdu_ses_est_req.ssc_mode_present = true;nisab france + pdu_ses_est_req.ssc_mode_present = true; pdu_ses_est_req.ssc_mode.ssc_mode_value = ssc_mode_t::SSC_mode_value_type_::options::ssc_mode_1; // TODO set the capability and extended protocol configuration