fix RRC connect proc in NAS to allow reattch after detach

master
Andre Puschmann 5 years ago
parent 50999d8116
commit bb84b27f0b

@ -251,7 +251,7 @@ private:
bool outcome; bool outcome;
}; };
srslte::proc_outcome_t init(nas* nas_ptr_); srslte::proc_outcome_t init(nas* nas_ptr_, srslte::unique_byte_buffer_t pdu);
srslte::proc_outcome_t step() final; srslte::proc_outcome_t step() final;
static const char* name() { return "RRC Connect"; } static const char* name() { return "RRC Connect"; }

@ -114,7 +114,7 @@ proc_outcome_t nas::plmn_search_proc::trigger_event(const plmn_search_complete_t
nas_ptr->rrc->plmn_select(nas_ptr->current_plmn); nas_ptr->rrc->plmn_select(nas_ptr->current_plmn);
if (not nas_ptr->rrc_connector.launch(nas_ptr)) { if (not nas_ptr->rrc_connector.launch(nas_ptr, nullptr)) {
Error("Unable to initiate RRC connection.\n"); Error("Unable to initiate RRC connection.\n");
return proc_outcome_t::error; return proc_outcome_t::error;
} }
@ -123,7 +123,7 @@ proc_outcome_t nas::plmn_search_proc::trigger_event(const plmn_search_complete_t
return proc_outcome_t::yield; return proc_outcome_t::yield;
} }
proc_outcome_t nas::rrc_connect_proc::init(nas* nas_ptr_) proc_outcome_t nas::rrc_connect_proc::init(nas* nas_ptr_, srslte::unique_byte_buffer_t pdu)
{ {
nas_ptr = nas_ptr_; nas_ptr = nas_ptr_;
@ -132,17 +132,19 @@ proc_outcome_t nas::rrc_connect_proc::init(nas* nas_ptr_)
return proc_outcome_t::success; return proc_outcome_t::success;
} }
// Generate service request or attach request message if (pdu == nullptr) {
unique_byte_buffer_t dedicatedInfoNAS = srslte::allocate_unique_buffer(*nas_ptr->pool, true); // Generate service request or attach request message
if (!dedicatedInfoNAS) { pdu = srslte::allocate_unique_buffer(*nas_ptr->pool, true);
Error("Fatal Error: Couldn't allocate PDU.\n"); if (!pdu) {
return proc_outcome_t::error; Error("Fatal Error: Couldn't allocate PDU.\n");
} return proc_outcome_t::error;
}
if (nas_ptr->state == EMM_STATE_REGISTERED) { if (nas_ptr->state == EMM_STATE_REGISTERED) {
nas_ptr->gen_service_request(dedicatedInfoNAS.get()); nas_ptr->gen_service_request(pdu.get());
} else { } else {
nas_ptr->gen_attach_request(dedicatedInfoNAS.get()); nas_ptr->gen_attach_request(pdu.get());
}
} }
// Provide UE-Identity to RRC if have one // Provide UE-Identity to RRC if have one
@ -160,7 +162,7 @@ proc_outcome_t nas::rrc_connect_proc::init(nas* nas_ptr_)
} }
state = state_t::conn_req; state = state_t::conn_req;
if (not nas_ptr->start_connection_request(establish_cause, std::move(dedicatedInfoNAS))) { if (not nas_ptr->start_connection_request(establish_cause, std::move(pdu))) {
return proc_outcome_t::error; return proc_outcome_t::error;
} }
@ -319,6 +321,7 @@ void nas::start_attach_request(srslte::proc_state_t* result)
return proc_outcome_t::success; return proc_outcome_t::success;
}); });
} else { } else {
nas_log->error("PLMN selected in state %s\n.", emm_state_text[state]);
*result = proc_state_t::error; *result = proc_state_t::error;
} }
break; break;
@ -328,7 +331,7 @@ void nas::start_attach_request(srslte::proc_state_t* result)
*result = proc_state_t::success; *result = proc_state_t::success;
} else { } else {
nas_log->info("NAS is already registered but RRC disconnected. Connecting now...\n"); nas_log->info("NAS is already registered but RRC disconnected. Connecting now...\n");
if (not rrc_connector.launch(this)) { if (not rrc_connector.launch(this, nullptr)) {
nas_log->error("Cannot initiate concurrent rrc connection procedures\n"); nas_log->error("Cannot initiate concurrent rrc connection procedures\n");
*result = proc_state_t::error; *result = proc_state_t::error;
return; return;
@ -371,6 +374,7 @@ bool nas::detach_request() {
case EMM_STATE_REGISTERED: case EMM_STATE_REGISTERED:
// send detach request // send detach request
send_detach_request(true); send_detach_request(true);
plmn_is_selected = false;
state = EMM_STATE_DEREGISTERED; state = EMM_STATE_DEREGISTERED;
break; break;
case EMM_STATE_DEREGISTERED_INITIATED: case EMM_STATE_DEREGISTERED_INITIATED:
@ -400,7 +404,7 @@ void nas::paging(s_tmsi_t* ue_identity)
nas_log->error("Cannot initiate concurrent RRC connection establishment procedures\n"); nas_log->error("Cannot initiate concurrent RRC connection establishment procedures\n");
return; return;
} }
if (not rrc_connector.launch(this)) { if (not rrc_connector.launch(this, nullptr)) {
nas_log->error("Could not launch RRC Connect()\n"); nas_log->error("Could not launch RRC Connect()\n");
return; return;
} }
@ -530,7 +534,7 @@ void nas::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu)
parse_authentication_reject(lcid, std::move(pdu)); parse_authentication_reject(lcid, std::move(pdu));
break; break;
case LIBLTE_MME_MSG_TYPE_IDENTITY_REQUEST: case LIBLTE_MME_MSG_TYPE_IDENTITY_REQUEST:
parse_identity_request(lcid, std::move(pdu)); parse_identity_request(std::move(pdu), sec_hdr_type);
break; break;
case LIBLTE_MME_MSG_TYPE_SECURITY_MODE_COMMAND: case LIBLTE_MME_MSG_TYPE_SECURITY_MODE_COMMAND:
parse_security_mode_command(lcid, std::move(pdu)); parse_security_mode_command(lcid, std::move(pdu));
@ -1694,13 +1698,21 @@ void nas::send_detach_request(bool switch_off)
} }
} }
if (switch_off) {
// Deactivate EPS bearer according to Sec. 5.5.2.2.2
nas_log->info("Clearing EPS bearer context.\n");
eps_bearer.clear();
}
nas_log->info("Sending detach request\n"); nas_log->info("Sending detach request\n");
if (rrc->is_connected()) { if (rrc->is_connected()) {
rrc->write_sdu(std::move(pdu)); rrc->write_sdu(std::move(pdu));
} else { } else {
if (not start_connection_request(establishment_cause_t::mo_sig, std::move(pdu))) {
nas_log->info("Failed to initiate RRC Connection Request\n"); if (not rrc_connector.launch(this, std::move(pdu))) {
nas_log->error("Failed to initiate RRC Connection Request\n");
} }
callbacks.defer_proc(rrc_connector);
} }
} }

Loading…
Cancel
Save