From aa979708a0383dfc228e19e95017cefb72c1e031 Mon Sep 17 00:00:00 2001 From: Carlo Galiotto Date: Tue, 16 Nov 2021 17:38:24 +0100 Subject: [PATCH] rrc-nr,test: add fnc to trigger send_security_cmd The SecurityModeCommand procedure was previously initiated by the RRCSetupComplete msg. However, it should be trigger by the NGAP through the InitialContextSetupRequest msg. This commit implements this change and fills in the function of the NGAP interface that starts the SecurityModeCommand procedure Signed-off-by: Carlo Galiotto --- srsgnb/hdr/stack/rrc/rrc_nr_ue.h | 6 +++--- srsgnb/src/stack/rrc/rrc_nr.cc | 6 ++++++ srsgnb/src/stack/rrc/test/rrc_nr_test_helpers.cc | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/srsgnb/hdr/stack/rrc/rrc_nr_ue.h b/srsgnb/hdr/stack/rrc/rrc_nr_ue.h index 2a4fc984a..765db9294 100644 --- a/srsgnb/hdr/stack/rrc/rrc_nr_ue.h +++ b/srsgnb/hdr/stack/rrc/rrc_nr_ue.h @@ -74,6 +74,9 @@ public: // NGAP interface void establish_eps_bearer(uint32_t pdu_session_id, srsran::const_byte_span nas_pdu, uint32_t lcid); + /* TS 38.331 - 5.3.4 Initial AS security activation */ + void send_security_mode_command(); + private: int send_dl_ccch(const asn1::rrc_nr::dl_ccch_msg_s& dl_ccch_msg); int send_dl_dcch(srsran::nr_srb srb, const asn1::rrc_nr::dl_dcch_msg_s& dl_dcch_msg); @@ -82,9 +85,6 @@ private: void send_rrc_setup(); void send_rrc_reject(uint8_t reject_wait_time_secs); - /* TS 38.331 - 5.3.4 Initial AS security activation */ - void send_security_mode_command(); - /* TS 38.331 - 5.3.5 RRC reconfiguration */ void send_rrc_reconfiguration(); diff --git a/srsgnb/src/stack/rrc/rrc_nr.cc b/srsgnb/src/stack/rrc/rrc_nr.cc index 1b7cbd04b..d78a5b050 100644 --- a/srsgnb/src/stack/rrc/rrc_nr.cc +++ b/srsgnb/src/stack/rrc/rrc_nr.cc @@ -557,6 +557,12 @@ int rrc_nr::ue_set_security_cfg_capabilities(uint16_t rnti, const asn1::ngap_nr: } int rrc_nr::start_security_mode_procedure(uint16_t rnti) { + auto user_it = users.find(rnti); + if (user_it == users.end()){ + logger.error("Starting SecurityModeCommand procedure failed - rnti=0x%x not found", rnti); + return SRSRAN_ERROR; + } + user_it->second->send_security_mode_command(); return SRSRAN_SUCCESS; } int rrc_nr::establish_rrc_bearer(uint16_t rnti, uint16_t pdu_session_id, srsran::const_byte_span nas_pdu, uint32_t lcid) diff --git a/srsgnb/src/stack/rrc/test/rrc_nr_test_helpers.cc b/srsgnb/src/stack/rrc/test/rrc_nr_test_helpers.cc index c45ac8e6e..2530e4af6 100644 --- a/srsgnb/src/stack/rrc/test/rrc_nr_test_helpers.cc +++ b/srsgnb/src/stack/rrc/test/rrc_nr_test_helpers.cc @@ -94,6 +94,9 @@ void test_rrc_nr_security_mode_cmd(srsran::task_scheduler& task_sched, { srsran::unique_byte_buffer_t pdu; + // Trigger Send SecurityCommand (simulate request from NGAP) + rrc_obj.start_security_mode_procedure(rnti); + // Test whether there exists the SRB1 initiated in the Connection Establishment // We test this as the SRB1 was setup in a different function TESTASSERT_EQ(rnti, pdcp.last_sdu_rnti);