From a4cc9b6ca05b55ee0807041f685ceabb0113aa10 Mon Sep 17 00:00:00 2001 From: Bedran Karakoc Date: Mon, 20 Sep 2021 16:06:22 +0200 Subject: [PATCH] Fix handle_authentication_request and add handler for authentication reject --- srsue/hdr/stack/upper/nas_5g.h | 1 + srsue/src/stack/upper/nas_5g.cc | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/srsue/hdr/stack/upper/nas_5g.h b/srsue/hdr/stack/upper/nas_5g.h index 1d724db9c..c953cbf4a 100644 --- a/srsue/hdr/stack/upper/nas_5g.h +++ b/srsue/hdr/stack/upper/nas_5g.h @@ -143,6 +143,7 @@ private: int handle_registration_accept(srsran::nas_5g::registration_accept_t& registration_accept); int handle_registration_reject(srsran::nas_5g::registration_reject_t& registration_reject); int handle_authentication_request(srsran::nas_5g::authentication_request_t& authentication_request); + int handle_authentication_reject(srsran::nas_5g::authentication_reject_t& authentication_reject); int handle_identity_request(srsran::nas_5g::identity_request_t& identity_request); int handle_service_accept(srsran::nas_5g::service_accept_t& service_accept); int handle_service_reject(srsran::nas_5g::service_reject_t& service_reject); diff --git a/srsue/src/stack/upper/nas_5g.cc b/srsue/src/stack/upper/nas_5g.cc index 8616bd375..f70cdbfca 100644 --- a/srsue/src/stack/upper/nas_5g.cc +++ b/srsue/src/stack/upper/nas_5g.cc @@ -199,6 +199,9 @@ int nas_5g::write_pdu(srsran::unique_byte_buffer_t pdu) case msg_opts::options::registration_reject: handle_registration_reject(nas_msg.registration_reject()); break; + case msg_opts::options::authentication_reject: + handle_authentication_reject(nas_msg.authentication_reject()); + break; case msg_opts::options::authentication_request: handle_authentication_request(nas_msg.authentication_request()); break; @@ -403,7 +406,7 @@ int nas_5g::send_security_mode_complete(const srsran::nas_5g::security_mode_comm imeisv.imeisv[14] = ue_svn_oct1; imeisv.imeisv[15] = ue_svn_oct2; } - + // TODO: Save TMSI registration_request_t& modified_registration_request = initial_registration_request_stored.registration_request(); modified_registration_request.capability_5gmm_present = true; modified_registration_request.requested_nssai_present = true; @@ -475,7 +478,6 @@ int nas_5g::send_authentication_failure(const cause_5gmm_t::cause_5gmm_type_::op pcap->write_nas(pdu.get()->msg, pdu.get()->N_bytes); } - logger.info("Sending Authentication Failure"); rrc_nr->write_sdu(std::move(pdu)); return SRSRAN_SUCCESS; @@ -776,11 +778,6 @@ int nas_5g::handle_authentication_request(authentication_request_t& authenticati logger.info(ctxt_5g.k_amf, 32, "Generated k_amf:"); - if (ctxt.ksi == authentication_request.ng_ksi.nas_key_set_identifier.value) { - send_authentication_failure(cause_5gmm_t::cause_5gmm_type_::ng_ksi_already_in_use, res); - return SRSRAN_ERROR; - } - if (auth_result == AUTH_OK) { logger.info("Network authentication successful"); send_authentication_response(res_star); @@ -799,6 +796,13 @@ int nas_5g::handle_authentication_request(authentication_request_t& authenticati return SRSRAN_SUCCESS; } +int nas_5g::handle_authentication_reject(srsran::nas_5g::authentication_reject_t& authentication_reject) +{ + logger.info("Handling Authentication Reject"); + state.set_deregistered(mm5g_state_t::deregistered_substate_t::plmn_search); + return SRSRAN_SUCCESS; +} + int nas_5g::handle_identity_request(identity_request_t& identity_request) { logger.info("Handling Identity Request");