diff --git a/srsenb/hdr/stack/upper/s1ap.h b/srsenb/hdr/stack/upper/s1ap.h index 44572bdf4..34b6cf942 100644 --- a/srsenb/hdr/stack/upper/s1ap.h +++ b/srsenb/hdr/stack/upper/s1ap.h @@ -39,12 +39,13 @@ namespace srsenb { struct ue_ctxt_t { - static const uint16_t invalid_rnti = 0; - static const uint32_t invalid_id = std::numeric_limits::max(); - uint16_t rnti = invalid_rnti; - uint32_t enb_ue_s1ap_id = invalid_id; - uint32_t mme_ue_s1ap_id = invalid_id; - struct timeval init_timestamp = {}; + static const uint32_t invalid_enb_id = std::numeric_limits::max(); + + bool mme_ue_s1ap_id_present = false; + uint16_t rnti = SRSLTE_INVALID_RNTI; + uint32_t enb_ue_s1ap_id = invalid_enb_id; + uint32_t mme_ue_s1ap_id = 0; + struct timeval init_timestamp = {}; }; class s1ap : public s1ap_interface_rrc diff --git a/srsenb/src/stack/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc index 6187211ee..33c6a344a 100644 --- a/srsenb/src/stack/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -986,8 +986,8 @@ bool s1ap::ue::send_initial_ctxt_setup_failure() tx_pdu.set_unsuccessful_outcome().load_info_obj(ASN1_S1AP_ID_INIT_CONTEXT_SETUP); auto& container = tx_pdu.unsuccessful_outcome().value.init_context_setup_request().protocol_ies; - container.enb_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; - container.mme_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id; + container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id; + container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; container.cause.value.set_radio_network().value = cause_radio_network_opts::unspecified; return s1ap_ptr->sctp_send_s1ap_pdu(tx_pdu, ctxt.rnti, "InitialContextSetupFailure"); @@ -1003,8 +1003,8 @@ bool s1ap::ue::send_uectxtmodifyresp() tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_UE_CONTEXT_MOD); auto& container = tx_pdu.successful_outcome().value.ue_context_mod_request().protocol_ies; - container.enb_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; - container.mme_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id; + container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id; + container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; return s1ap_ptr->sctp_send_s1ap_pdu(tx_pdu, ctxt.rnti, "UEContextModificationResponse"); } @@ -1019,8 +1019,8 @@ bool s1ap::ue::send_uectxtmodifyfailure(const cause_c& cause) tx_pdu.set_unsuccessful_outcome().load_info_obj(ASN1_S1AP_ID_UE_CONTEXT_MOD); auto& container = tx_pdu.unsuccessful_outcome().value.ue_context_mod_request().protocol_ies; - container.enb_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; - container.mme_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id; + container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id; + container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; container.cause.value = cause; return s1ap_ptr->sctp_send_s1ap_pdu(tx_pdu, ctxt.rnti, "UEContextModificationFailure"); @@ -1102,7 +1102,7 @@ bool s1ap::send_enb_status_transfer_proc(uint16_t rnti, std::vectorctxt.mme_ue_s1ap_id == mmeid; + return v.second->ctxt.mme_ue_s1ap_id_present and v.second->ctxt.mme_ue_s1ap_id == mmeid; }); return it != users.end() ? it->second.get() : nullptr; } @@ -1219,10 +1216,11 @@ s1ap::ue* s1ap::find_s1apmsg_user(uint32_t enb_id, uint32_t mme_id) s1ap_log->warning("enb_ue_s1ap_id=%d not found - discarding message\n", enb_id); return nullptr; } - if (user_ptr->ctxt.mme_ue_s1ap_id != ue_ctxt_t::invalid_id and user_ptr->ctxt.mme_ue_s1ap_id != mme_id) { + if (user_ptr->ctxt.mme_ue_s1ap_id_present and user_ptr->ctxt.mme_ue_s1ap_id != mme_id) { s1ap_log->warning("MME_UE_S1AP_ID has changed - old:%d, new:%d\n", user_ptr->ctxt.mme_ue_s1ap_id, mme_id); } - user_ptr->ctxt.mme_ue_s1ap_id = mme_id; + user_ptr->ctxt.mme_ue_s1ap_id_present = true; + user_ptr->ctxt.mme_ue_s1ap_id = mme_id; return user_ptr; }