From dbb8b6a360c9726ef0bc8c774e4eedd732314e90 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Sun, 29 Mar 2020 15:26:45 +0200 Subject: [PATCH] nas: add helper for entering new state in FSM the helper will log the event --- srsue/hdr/stack/upper/nas.h | 1 + srsue/src/stack/upper/nas.cc | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/srsue/hdr/stack/upper/nas.h b/srsue/hdr/stack/upper/nas.h index e5fd0ac90..ca0b36a2a 100644 --- a/srsue/hdr/stack/upper/nas.h +++ b/srsue/hdr/stack/upper/nas.h @@ -220,6 +220,7 @@ private: void send_activate_test_mode_complete(const uint8_t sec_hdr_type); // Other internal helpers + void enter_state(emm_state_t state_); void handle_airplane_mode_sim(); void enter_emm_deregistered(); diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index 585eadc13..430981ad1 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -253,7 +253,7 @@ void nas::init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_ usim = usim_; rrc = rrc_; gw = gw_; - state = EMM_STATE_DEREGISTERED; + enter_state(EMM_STATE_DEREGISTERED); if (!usim->get_home_plmn_id(&home_plmn)) { nas_log->error("Getting Home PLMN Id from USIM. Defaulting to 001-01\n"); @@ -493,7 +493,13 @@ void nas::enter_emm_deregistered() eps_bearer.clear(); plmn_is_selected = false; - state = EMM_STATE_DEREGISTERED; + enter_state(EMM_STATE_DEREGISTERED); +} + +void nas::enter_state(emm_state_t state_) +{ + state = state_; + nas_log->info("New state %s\n", emm_state_text[state]); } void nas::left_rrc_connected() {} @@ -1186,7 +1192,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) bearer.eps_bearer_id = act_def_eps_bearer_context_req.eps_bearer_id; if (eps_bearer.insert(eps_bearer_map_pair_t(bearer.eps_bearer_id, bearer)).second) { // bearer added successfully - state = EMM_STATE_REGISTERED; + enter_state(EMM_STATE_REGISTERED); attach_attempt_counter = 0; // reset according to 5.5.1.1 @@ -1919,7 +1925,7 @@ void nas::send_detach_request(bool switch_off) enter_emm_deregistered(); } else { // we are expecting a response from the core - state = EMM_STATE_DEREGISTERED_INITIATED; + enter_state(EMM_STATE_DEREGISTERED_INITIATED); // start T3421 nas_log->info("Starting T3421\n"); @@ -2234,7 +2240,7 @@ void nas::send_esm_information_response(const uint8 proc_transaction_id) unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool, true); if (!pdu) { - nas_log->error("Fatal Error: Couldn't allocate PDU in send_attach_request().\n"); + nas_log->error("Fatal Error: Couldn't allocate PDU in %s.\n", __FUNCTION__); return; }