Changed UE set to be accessible from SCTP association.

master
Pedro Alvarez 7 years ago
parent 300b9e7757
commit 362c856e53

@ -82,13 +82,13 @@ public:
bool add_ue_ctx_to_imsi_map(ue_ctx_t *ue_ctx);
bool add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx_t *ue_ctx);
bool add_ue_to_enb_set(uint16_t enb_id, uint32_t mme_ue_s1ap_id);
bool add_ue_to_enb_set(int32_t enb_assoc, uint32_t mme_ue_s1ap_id);
ue_ctx_t* find_ue_ctx_from_imsi(uint64_t imsi);
ue_ctx_t* find_ue_ctx_from_mme_ue_s1ap_id(uint32_t mme_ue_s1ap_id);
bool release_ue_ecm_ctx(uint32_t mme_ue_s1ap_id);
void release_ues_ecm_ctx_in_enb(uint16_t enb_id);
void release_ues_ecm_ctx_in_enb(int32_t enb_assoc);
bool delete_ue_ctx(uint64_t imsi);
uint32_t allocate_m_tmsi(uint64_t imsi);
@ -115,7 +115,7 @@ private:
int m_s1mme;
std::map<uint16_t, enb_ctx_t*> m_active_enbs;
std::map<int32_t, uint16_t> m_sctp_to_enb_id;
std::map<uint16_t,std::set<uint32_t> > m_enb_id_to_ue_ids;
std::map<int32_t,std::set<uint32_t> > m_enb_assoc_to_ue_ids;
std::map<uint64_t, ue_ctx_t*> m_imsi_to_ue_ctx;
std::map<uint32_t, ue_ctx_t*> m_mme_ue_s1ap_id_to_ue_ctx;

@ -299,7 +299,7 @@ s1ap::add_new_enb_ctx(const enb_ctx_t &enb_ctx, const struct sctp_sndrcvinfo *en
memcpy(enb_ptr,&enb_ctx,sizeof(enb_ctx_t));
m_active_enbs.insert(std::pair<uint16_t,enb_ctx_t*>(enb_ptr->enb_id,enb_ptr));
m_sctp_to_enb_id.insert(std::pair<int32_t,uint16_t>(enb_sri->sinfo_assoc_id, enb_ptr->enb_id));
m_enb_id_to_ue_ids.insert(std::pair<uint16_t,std::set<uint32_t> >(enb_ptr->enb_id,ue_set));
m_enb_assoc_to_ue_ids.insert(std::pair<int32_t,std::set<uint32_t> >(enb_sri->sinfo_assoc_id,ue_set));
return;
}
@ -335,7 +335,7 @@ s1ap::delete_enb_ctx(int32_t assoc_id)
m_s1ap_log->console("Deleting eNB context. eNB Id: 0x%x\n", enb_id);
//Delete connected UEs ctx
release_ues_ecm_ctx_in_enb(enb_id);
release_ues_ecm_ctx_in_enb(assoc_id);
//Delete eNB
delete it_ctx->second;
@ -398,23 +398,23 @@ s1ap::add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx_t *ue_ctx)
}
bool
s1ap::add_ue_to_enb_set(uint16_t enb_id, uint32_t mme_ue_s1ap_id)
s1ap::add_ue_to_enb_set(int32_t enb_assoc, uint32_t mme_ue_s1ap_id)
{
std::map<uint16_t,std::set<uint32_t> >::iterator ues_in_enb = m_enb_id_to_ue_ids.find(enb_id);
if(ues_in_enb == m_enb_id_to_ue_ids.end())
std::map<int32_t,std::set<uint32_t> >::iterator ues_in_enb = m_enb_assoc_to_ue_ids.find(enb_assoc);
if(ues_in_enb == m_enb_assoc_to_ue_ids.end())
{
m_s1ap_log->error("Could not find eNB from eNB Id 0x%x",enb_id);
m_s1ap_log->error("Could not find eNB from eNB SCTP association %d",enb_assoc);
return false;
}
std::set<uint32_t>::iterator ue_id = ues_in_enb->second.find(mme_ue_s1ap_id);
if(ue_id != ues_in_enb->second.end())
{
m_s1ap_log->error("Could not find eNB from eNB Id %d",enb_id);
m_s1ap_log->error("UE with MME UE S1AP Id already exists %d",mme_ue_s1ap_id);
return false;
}
ues_in_enb->second.insert(mme_ue_s1ap_id);
m_s1ap_log->debug("Added UE with MME-UE S1AP Id %d to eNB 0x%xcontext %d\n", mme_ue_s1ap_id, enb_id);
m_s1ap_log->debug("Added UE with MME-UE S1AP Id %d to eNB with association %d\n", mme_ue_s1ap_id, enb_assoc);
return true;
}
@ -447,11 +447,11 @@ s1ap::find_ue_ctx_from_imsi(uint64_t imsi)
}
void
s1ap::release_ues_ecm_ctx_in_enb(uint16_t enb_id)
s1ap::release_ues_ecm_ctx_in_enb(int32_t enb_assoc)
{
m_s1ap_log->console("Releasing UEs context\n");
//delete UEs ctx
std::map<uint16_t,std::set<uint32_t> >::iterator ues_in_enb = m_enb_id_to_ue_ids.find(enb_id);
std::map<int32_t,std::set<uint32_t> >::iterator ues_in_enb = m_enb_assoc_to_ue_ids.find(enb_assoc);
std::set<uint32_t>::iterator ue_id = ues_in_enb->second.begin();
if(ue_id == ues_in_enb->second.end())
{
@ -497,8 +497,8 @@ s1ap::release_ue_ecm_ctx(uint32_t mme_ue_s1ap_id)
return false;
}
uint16_t enb_id = it->second;
std::map<uint16_t,std::set<uint32_t> >::iterator ue_set = m_enb_id_to_ue_ids.find(enb_id);
if(ue_set == m_enb_id_to_ue_ids.end())
std::map<int32_t,std::set<uint32_t> >::iterator ue_set = m_enb_assoc_to_ue_ids.find(ecm_ctx->enb_sri.sinfo_assoc_id);
if(ue_set == m_enb_assoc_to_ue_ids.end())
{
m_s1ap_log->error("Could not find the eNB's UEs.\n");
return false;

@ -498,7 +498,7 @@ s1ap_nas_transport::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id,
memcpy(new_ctx,&ue_ctx,sizeof(ue_ctx_t));
m_s1ap->add_ue_ctx_to_imsi_map(new_ctx);
m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(new_ctx);
m_s1ap->add_ue_to_enb_set(enb_id,mme_ue_s1ap_id);
m_s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id,ecm_ctx->mme_ue_s1ap_id);
//Pack NAS Authentication Request in Downlink NAS Transport msg
pack_authentication_request(reply_buffer, ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id, autn, rand);
@ -612,7 +612,7 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id,
ue_ctx_t *new_ctx = new ue_ctx_t;
memcpy(new_ctx,&ue_ctx,sizeof(ue_ctx_t));
m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(new_ctx);
m_s1ap->add_ue_to_enb_set(enb_id,mme_ue_s1ap_id);
m_s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id,ecm_ctx->mme_ue_s1ap_id);
pack_identity_request(reply_buffer, ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id);
*reply_flag = true;
@ -662,7 +662,7 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id,
//Store context based on MME UE S1AP id
m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx);
m_s1ap->add_ue_to_enb_set(enb_id,mme_ue_s1ap_id);
m_s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id,ecm_ctx->mme_ue_s1ap_id);
//Re-generate K_eNB
liblte_security_generate_k_enb(emm_ctx->security_ctxt.k_asme, emm_ctx->security_ctxt.ul_nas_count, emm_ctx->security_ctxt.k_enb);

Loading…
Cancel
Save