From d8680cc9a8e469493886fe8537a7156267fa5020 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Sun, 29 Mar 2020 12:26:32 +0200 Subject: [PATCH] nas: add helper to pack attach request and send to RRC --- srsue/hdr/stack/upper/nas.h | 1 + srsue/src/stack/upper/nas.cc | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/srsue/hdr/stack/upper/nas.h b/srsue/hdr/stack/upper/nas.h index d744e67e5..e5fd0ac90 100644 --- a/srsue/hdr/stack/upper/nas.h +++ b/srsue/hdr/stack/upper/nas.h @@ -210,6 +210,7 @@ private: void send_authentication_failure(const uint8_t cause, const uint8_t* auth_fail_param); void gen_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT* msg); void send_security_mode_reject(uint8_t cause); + void send_attach_request(); void send_detach_request(bool switch_off); void send_detach_accept(); void send_activate_dedicated_eps_bearer_context_accept(const uint8_t& proc_transaction_id, diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index 16e553c19..94e7d3d9a 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -356,7 +356,13 @@ void nas::timer_expired(uint32_t timeout_id) } } else if (timeout_id == t3411.id()) { nas_log->info("Timer T3411 expired: trying to attach again\n"); - start_attach_proc(nullptr, srslte::establishment_cause_t::mo_sig); + if (rrc->is_connected()) { + // send attach request through established RRC connection + send_attach_request(); + } else { + // start attach procedure + start_attach_proc(nullptr, srslte::establishment_cause_t::mo_sig); + } } else if (timeout_id == t3421.id()) { nas_log->info("Timer T3421 expired: entering EMM_STATE_DEREGISTERED\n"); // TODO: TS 24.301 says to resend detach request but doesn't say how often before entering EMM_STATE_DEREGISTERED @@ -1826,6 +1832,20 @@ void nas::send_security_mode_reject(uint8_t cause) rrc->write_sdu(std::move(msg)); } +/** + * Pack attach request message and send to RRC for transmission. + */ +void nas::send_attach_request() +{ + unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool, true); + if (!pdu) { + nas_log->error("Fatal Error: Couldn't allocate PDU in %s().\n", __FUNCTION__); + return; + } + gen_attach_request(pdu); + rrc->write_sdu(std::move(pdu)); +} + void nas::send_detach_request(bool switch_off) { unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool, true);