Skip to content

Commit 317e988

Browse files
committed
Adding emergency registration procedure
1 parent 254cc71 commit 317e988

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed

srsue/hdr/stack/upper/nas_5g.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,4 @@ class nas_5g : public nas_base, public nas_5g_interface_rrc_nr, public nas_5g_in
208208
std::array<pdu_session_t, MAX_PDU_SESSIONS> pdu_sessions;
209209
};
210210
} // namespace srsue
211-
#endif
211+
#endif

srsue/hdr/stack/upper/nas_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class nas_5g_args_t
6767
std::string ia5g;
6868
std::string ea5g;
6969
std::vector<pdu_session_cfg_t> pdu_session_cfgs;
70+
bool emergency_registration;
71+
7072
};
7173

7274
} // namespace srsue

srsue/src/main.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,14 @@ static int parse_args(all_args_t* args, int argc, char* argv[])
153153
("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")
154154
("rrc.nr_short_sn_support", bpo::value<bool>(&args->stack.rrc_nr.pdcp_short_sn_support)->default_value(true), "Announce PDCP short SN support")
155155

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

164165
("pcap.enable", bpo::value<string>(&args->stack.pkt_trace.enable)->default_value("none"), "Enable (MAC, MAC_NR, NAS) packet captures for wireshark")
165166
("pcap.mac_filename", bpo::value<string>(&args->stack.pkt_trace.mac_pcap.filename)->default_value("/tmp/ue_mac.pcap"), "MAC layer capture filename")

srsue/src/stack/upper/nas_5g.cc

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,23 +249,31 @@ int nas_5g::write_pdu(srsran::unique_byte_buffer_t pdu)
249249
/*******************************************************************************
250250
* Senders
251251
******************************************************************************/
252-
253252
int nas_5g::send_registration_request()
254253
{
254+
255255
unique_byte_buffer_t pdu = srsran::make_byte_buffer();
256256
if (!pdu) {
257257
logger.error("Couldn't allocate PDU in %s().", __FUNCTION__);
258258
return SRSRAN_ERROR;
259259
}
260260

261261
initial_registration_request_stored.hdr.extended_protocol_discriminator =
262-
nas_5gs_hdr::extended_protocol_discriminator_opts::extended_protocol_discriminator_5gmm;
262+
nas_5gs_hdr::extended_protocol_discriminator_opts::extended_protocol_discriminator_5gmm;
263263
registration_request_t& reg_req = initial_registration_request_stored.set_registration_request();
264-
265264
reg_req.registration_type_5gs.follow_on_request_bit =
266-
registration_type_5gs_t::follow_on_request_bit_type_::options::follow_on_request_pending;
265+
registration_type_5gs_t::follow_on_request_bit_type_::options::follow_on_request_pending;
266+
267+
if(cfg.emergency_registration){
268+
reg_req.registration_type_5gs.registration_type =
269+
registration_type_5gs_t::registration_type_type_::options::emergency_registration;
270+
271+
mobile_identity_5gs_t::imei_s& imei = reg_req.mobile_identity_5gs.set_imei();
272+
usim->get_imei_vec(imei.imei.data(), 15);
273+
}
274+
else {
267275
reg_req.registration_type_5gs.registration_type =
268-
registration_type_5gs_t::registration_type_type_::options::initial_registration;
276+
registration_type_5gs_t::registration_type_type_::options::initial_registration;
269277
mobile_identity_5gs_t::suci_s& suci = reg_req.mobile_identity_5gs.set_suci();
270278
suci.supi_format = mobile_identity_5gs_t::suci_s::supi_format_type_::options::imsi;
271279
usim->get_home_mcc_bytes(suci.mcc.data(), suci.mcc.size());
@@ -274,15 +282,15 @@ int nas_5g::send_registration_request()
274282
suci.scheme_output.resize(5);
275283
usim->get_home_msin_bcd(suci.scheme_output.data(), 5);
276284
logger.info("Requesting IMSI attach (IMSI=%s)", usim->get_imsi_str().c_str());
285+
}
277286

278287
reg_req.ue_security_capability_present = true;
279288
fill_security_caps(reg_req.ue_security_capability);
280289

281290
if (initial_registration_request_stored.pack(pdu) != SRSASN_SUCCESS) {
282-
logger.error("Failed to pack registration request");
283-
return SRSRAN_ERROR;
291+
logger.error("Failed to pack registration request");
292+
return SRSRAN_ERROR;
284293
}
285-
286294
if (pcap != nullptr) {
287295
pcap->write_nas(pdu.get()->msg, pdu.get()->N_bytes);
288296
}
@@ -582,13 +590,14 @@ int nas_5g::send_pdu_session_establishment_request(uint32_t tran
582590
ul_nas_msg.pdu_session_id.pdu_session_identity_2_value = pdu_session_id;
583591

584592
ul_nas_msg.request_type_present = true;
585-
ul_nas_msg.request_type.request_type_value = request_type_t::Request_type_value_type_::options::initial_request;
593+
ul_nas_msg.request_type.request_type_value = (cfg.emergency_registration)? request_type_t::Request_type_value_type_::initial_emergency_request:
594+
request_type_t::Request_type_value_type_::options::initial_request;
586595

587-
ul_nas_msg.s_nssai_present = true;
596+
ul_nas_msg.s_nssai_present = (cfg.emergency_registration)? false:true;
588597
ul_nas_msg.s_nssai.type = s_nssai_t::SST_type_::options::sst;
589598
ul_nas_msg.s_nssai.sst = 1;
590599

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

srsue/src/stack/upper/nas_5g_procedures.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ srsran::proc_outcome_t nas_5g::pdu_session_establishment_procedure::init(const u
6565
srsran::proc_outcome_t nas_5g::pdu_session_establishment_procedure::react(
6666
const srsran::nas_5g::pdu_session_establishment_accept_t& pdu_session_est_accept)
6767
{
68-
// TODO check the pdu session values
69-
if (pdu_session_est_accept.dnn_present == false) {
70-
logger.warning("Expected DNN in PDU session establishment accept");
71-
return proc_outcome_t::error;
72-
}
68+
7369
if (pdu_session_est_accept.pdu_address_present == false) {
7470
logger.warning("Expected PDU Address in PDU session establishment accept");
7571
return proc_outcome_t::error;
@@ -98,4 +94,4 @@ srsran::proc_outcome_t nas_5g::pdu_session_establishment_procedure::step()
9894
return srsran::proc_outcome_t::success;
9995
}
10096

101-
} // namespace srsue
97+
} // namespace srsue

0 commit comments

Comments
 (0)