Fixed bug when GUTI is unknown but EMM context was previously present. Added function to delete EMM context.

master
Pedro Alvarez 7 years ago
parent fc1629a06e
commit 386e56ef40

@ -87,7 +87,7 @@ public:
void add_new_ue_ecm_ctx(const ue_ecm_ctx_t &ue_ecm_ctx); void add_new_ue_ecm_ctx(const ue_ecm_ctx_t &ue_ecm_ctx);
ue_emm_ctx_t* find_ue_emm_ctx_from_imsi(uint64_t imsi); ue_emm_ctx_t* find_ue_emm_ctx_from_imsi(uint64_t imsi);
ue_ecm_ctx_t* find_ue_ecm_ctx_from_mme_ue_s1ap_id(uint32_t mme_ue_s1ap_id); ue_ecm_ctx_t* find_ue_ecm_ctx_from_mme_ue_s1ap_id(uint32_t mme_ue_s1ap_id);
bool delete_ue_emm_ctx(ue_emm_ctx_t *ue_emm_ctx); bool delete_ue_emm_ctx(uint64_t imsi);
bool delete_ue_ecm_ctx(uint32_t mme_ue_s1ap_id); bool delete_ue_ecm_ctx(uint32_t mme_ue_s1ap_id);
void delete_ues_ecm_ctx_in_enb(uint16_t enb_id); void delete_ues_ecm_ctx_in_enb(uint16_t enb_id);

@ -419,6 +419,22 @@ s1ap::find_ue_ecm_ctx_from_mme_ue_s1ap_id(uint32_t mme_ue_s1ap_id)
return it->second; return it->second;
} }
} }
bool
s1ap::delete_ue_emm_ctx(uint64_t imsi)
{
std::map<uint64_t, ue_emm_ctx_t*>::iterator ue_emm_ctx_it = m_imsi_to_ue_emm_ctx.find(imsi);
if(ue_emm_ctx_it == m_imsi_to_ue_emm_ctx.end())
{
m_s1ap_log->info("Cannot delete UE EMM context, UE not found. IMSI: %d\n", imsi);
return false;
}
//Delete UE context
m_imsi_to_ue_emm_ctx.erase(ue_emm_ctx_it);
delete ue_emm_ctx_it->second;
m_s1ap_log->info("Deleted UE EMM Context.\n");
return true;
}
bool bool
s1ap::delete_ue_ecm_ctx(uint32_t mme_ue_s1ap_id) s1ap::delete_ue_ecm_ctx(uint32_t mme_ue_s1ap_id)
@ -450,7 +466,7 @@ s1ap::delete_ue_ecm_ctx(uint32_t mme_ue_s1ap_id)
//Delete UE context //Delete UE context
m_mme_ue_s1ap_id_to_ue_ecm_ctx.erase(ue_ecm_ctx_it); m_mme_ue_s1ap_id_to_ue_ecm_ctx.erase(ue_ecm_ctx_it);
delete ue_ecm_ctx; delete ue_ecm_ctx;
m_s1ap_log->info("Deleted UE Context.\n"); m_s1ap_log->info("Deleted UE ECM Context.\n");
return true; return true;
} }

@ -619,6 +619,16 @@ s1ap_nas_transport::handle_identity_response(srslte::byte_buffer_t *nas_msg, ue_
for(int i=0;i<=14;i++){ for(int i=0;i<=14;i++){
imsi += id_resp.mobile_id.imsi[i]*std::pow(10,14-i); imsi += id_resp.mobile_id.imsi[i]*std::pow(10,14-i);
} }
//Check if EMM context already exists
ue_emm_ctx_t *ue_tmp_ptr = m_s1ap->find_ue_emm_ctx_from_imsi(imsi);
if(ue_tmp_ptr != NULL)
{
m_s1ap_log->warning("Unkonw GUTI, but UE's EMM context present.\n");
m_s1ap->delete_ue_emm_ctx(imsi);
}
m_s1ap_log->info("Id Response -- IMSI: %015lu\n", imsi); m_s1ap_log->info("Id Response -- IMSI: %015lu\n", imsi);
m_s1ap_log->console("Id Response -- IMSI: %015lu\n", imsi); m_s1ap_log->console("Id Response -- IMSI: %015lu\n", imsi);
ue_ecm_ctx->imsi = imsi; ue_ecm_ctx->imsi = imsi;

Loading…
Cancel
Save