From 95bc4f8b08eee99cdebbc6fd2af5e0c8a5f4b1af Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 7 Feb 2018 14:11:42 +0000 Subject: [PATCH] adding tmp emm storage for when the UE uses an unknown guti and id request has to be sent. --- srsepc/hdr/mme/s1ap.h | 4 ++++ srsepc/src/mme/s1ap.cc | 25 +++++++++++++++++++++++++ srsepc/src/mme/s1ap_nas_transport.cc | 27 ++++++++++----------------- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index 9e23868e8..bb0140c57 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -91,6 +91,9 @@ public: bool delete_ue_ecm_ctx(uint32_t mme_ue_s1ap_id); void delete_ues_ecm_ctx_in_enb(uint16_t enb_id); + void store_tmp_ue_emm_ctx(const ue_emm_ctx_t &ue_ecm_ctx); + bool get_tmp_ue_emm_ctx(uint32_t mme_ue_s1ap_id, ue_emm_ctx_t* ue_emm_ptr); + uint32_t allocate_m_tmsi(uint32_t mme_ue_s1ap_id); s1ap_args_t m_s1ap_args; @@ -119,6 +122,7 @@ private: std::map m_imsi_to_ue_emm_ctx; std::map m_mme_ue_s1ap_id_to_ue_ecm_ctx; + std::map m_mme_ue_s1ap_id_to_tmp_ue_emm_ctx; uint32_t m_next_mme_ue_s1ap_id; uint32_t m_next_m_tmsi; diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index d421191d5..9a9ebafee 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -346,6 +346,31 @@ s1ap::add_new_ue_emm_ctx(const ue_emm_ctx_t &ue_emm_ctx) m_imsi_to_ue_emm_ctx.insert(std::pair(ue_ptr->imsi,ue_ptr)); } +void +s1ap::store_tmp_ue_emm_ctx(const ue_emm_ctx_t &tmp_ue_emm_ctx) +{ + ue_emm_ctx_t *ue_ptr = new ue_emm_ctx_t; + memcpy(ue_ptr,&tmp_ue_emm_ctx,sizeof(tmp_ue_emm_ctx)); + + //This map will store UE's ECM context. + m_mme_ue_s1ap_id_to_tmp_ue_emm_ctx.insert(std::pair(ue_ptr->mme_ue_s1ap_id,ue_ptr)); +} + +bool +s1ap::get_tmp_ue_emm_ctx(uint32_t mme_ue_s1ap_id, ue_emm_ctx_t* ue_emm_ptr) +{ + + std::map::iterator it = m_mme_ue_s1ap_id_to_tmp_ue_emm_ctx.find(mme_ue_s1ap_id); + if(it == m_mme_ue_s1ap_id_to_tmp_ue_emm_ctx.end() ) + { + return false; + } + memcpy(ue_emm_ptr, it->second,sizeof(ue_emm_ctx_t)); + delete it->second; + m_mme_ue_s1ap_id_to_tmp_ue_emm_ctx.erase(it); + return true; +} + void s1ap::add_new_ue_ecm_ctx(const ue_ecm_ctx_t &ue_ecm_ctx) { diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index 76719efbe..4998f68e4 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -385,31 +385,24 @@ s1ap_nas_transport::handle_nas_guti_attach_request(uint32_t enb_ue_s1ap_id, m_s1ap_log->info("Attach request -- IMSI: %015lu\n", ue_ecm_ctx.imsi); m_s1ap_log->console("Attach request -- eNB-UE S1AP Id: %d, MME-UE S1AP Id: %d\n", ue_ecm_ctx.enb_ue_s1ap_id, ue_ecm_ctx.mme_ue_s1ap_id); m_s1ap_log->console("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n", - attach_req.ue_network_cap.eea[0], - attach_req.ue_network_cap.eea[1], - attach_req.ue_network_cap.eea[2], - attach_req.ue_network_cap.eea[3], - attach_req.ue_network_cap.eea[4], - attach_req.ue_network_cap.eea[5], - attach_req.ue_network_cap.eea[6], - attach_req.ue_network_cap.eea[7]); + attach_req.ue_network_cap.eea[0], attach_req.ue_network_cap.eea[1], attach_req.ue_network_cap.eea[2], attach_req.ue_network_cap.eea[3], + attach_req.ue_network_cap.eea[4], attach_req.ue_network_cap.eea[5], attach_req.ue_network_cap.eea[6], attach_req.ue_network_cap.eea[7]); m_s1ap_log->console("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n", - attach_req.ue_network_cap.eia[0], - attach_req.ue_network_cap.eia[1], - attach_req.ue_network_cap.eia[2], - attach_req.ue_network_cap.eia[3], - attach_req.ue_network_cap.eia[4], - attach_req.ue_network_cap.eia[5], - attach_req.ue_network_cap.eia[6], - attach_req.ue_network_cap.eia[7]); + attach_req.ue_network_cap.eia[0], attach_req.ue_network_cap.eia[1], attach_req.ue_network_cap.eia[2], attach_req.ue_network_cap.eia[3], + attach_req.ue_network_cap.eia[4], attach_req.ue_network_cap.eia[5], attach_req.ue_network_cap.eia[6], attach_req.ue_network_cap.eia[7]); m_s1ap_log->console("Attach Request -- MS Network Capabilities Present: %s\n", attach_req.ms_network_cap_present ? "true" : "false"); m_s1ap_log->console("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id); m_s1ap_log->console("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id); m_s1ap_log->console("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false"); m_s1ap_log->console("Could not find M-TMSI=0x%x. Sending ID request\n",m_tmsi); - m_s1ap_log->info("Could not find M-TMSI=0x%d. Sending Id Request\n", m_tmsi); + m_s1ap_log->info("Could not find M-TMSI=0x%x. Sending Id Request\n", m_tmsi); m_s1ap->add_new_ue_ecm_ctx(ue_ecm_ctx); + + //We do not know the IMSI of the UE yet + //This will be removed when the Identity request is received + m_s1ap->store_tmp_ue_emm_ctx(tmp_ue_emm_ctx); + pack_identity_request(reply_buffer, ue_ecm_ctx.enb_ue_s1ap_id, ue_ecm_ctx.mme_ue_s1ap_id); *reply_flag = true; return true;