From a3b31966b88c899e63776f886bd50d2d4320d8fd Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 7 Mar 2018 18:48:08 +0000 Subject: [PATCH] Changing Activate EPS bearer function to work with IMSI. --- srsepc/hdr/mme/s1ap.h | 2 +- srsepc/src/mme/mme_gtpc.cc | 8 ++++---- srsepc/src/mme/s1ap.cc | 22 +++++++++++++++------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index 3f9f035e0..311a65784 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -72,7 +72,7 @@ public: bool handle_initiating_message(LIBLTE_S1AP_INITIATINGMESSAGE_STRUCT *msg, struct sctp_sndrcvinfo *enb_sri); bool handle_successful_outcome(LIBLTE_S1AP_SUCCESSFULOUTCOME_STRUCT *msg); - void activate_eps_bearer(uint32_t mme_s1ap_id, uint8_t ebi); + void activate_eps_bearer(uint64_t imsi, uint8_t ebi); void print_enb_ctx_info(const std::string &prefix, const enb_ctx_t &enb_ctx); diff --git a/srsepc/src/mme/mme_gtpc.cc b/srsepc/src/mme/mme_gtpc.cc index fff721978..ff603e14d 100644 --- a/srsepc/src/mme/mme_gtpc.cc +++ b/srsepc/src/mme/mme_gtpc.cc @@ -288,16 +288,16 @@ void mme_gtpc::handle_modify_bearer_response(srslte::gtpc_pdu *mb_resp_pdu) { uint32_t mme_ctrl_teid = mb_resp_pdu->header.teid; - std::map::iterator mme_s1ap_id_it = m_teid_to_mme_s1ap_id.find(mme_ctrl_teid); - if(mme_s1ap_id_it == m_teid_to_mme_s1ap_id.end()) + std::map::iterator imsi_it = m_mme_ctr_teid_to_imsi.find(mme_ctrl_teid); + if(imsi_it == m_mme_ctr_teid_to_imsi.end()) { - m_mme_gtpc_log->error("Could not find MME S1AP Id from control TEID\n"); + m_mme_gtpc_log->error("Could not find IMSI from control TEID\n"); return; } uint8_t ebi = mb_resp_pdu->choice.modify_bearer_response.eps_bearer_context_modified.ebi; m_mme_gtpc_log->debug("Activating EPS bearer with id %d\n", ebi); - m_s1ap->activate_eps_bearer(mme_s1ap_id_it->second,ebi); + m_s1ap->activate_eps_bearer(imsi_it->second,ebi); return; } diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 6e301b9ae..a54096114 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -501,23 +501,31 @@ s1ap::delete_ues_ecm_ctx_in_enb(uint16_t enb_id) //UE Bearer Managment void -s1ap::activate_eps_bearer(uint32_t mme_s1ap_id, uint8_t ebi) +s1ap::activate_eps_bearer(uint64_t imsi, uint8_t ebi) { - std::map::iterator ue_ctx_it = m_mme_ue_s1ap_id_to_ue_ecm_ctx.find(mme_s1ap_id); - if(ue_ctx_it == m_mme_ue_s1ap_id_to_ue_ecm_ctx.end()) + std::map::iterator emm_ctx_it = m_imsi_to_ue_emm_ctx.find(imsi); + if(emm_ctx_it == m_imsi_to_ue_emm_ctx.end()) { - m_s1ap_log->error("Could not find UE context\n"); + m_s1ap_log->error("Could not find UE EMM context\n"); + return; + } + uint32_t mme_ue_s1ap_id = emm_ctx_it->second->mme_ue_s1ap_id; + std::map::iterator ecm_ctx_it = m_mme_ue_s1ap_id_to_ue_ecm_ctx.find(mme_s1ap_id); + if(ecm_ctx_it == m_mme_ue_s1ap_id_to_ue_ecm_ctx.end()) + { + m_s1ap_log->error("Could not find UE ECM context\n"); return; } - ue_ecm_ctx_t * ue_ctx = ue_ctx_it->second; - if (ue_ctx->erabs_ctx[ebi].state != ERAB_CTX_SETUP) + + ue_ecm_ctx_t * ecm_ctx = ue_ctx_it->second; + if (ecm_ctx->erabs_ctx[ebi].state != ERAB_CTX_SETUP) { m_s1ap_log->error("EPS Bearer could not be activated. MME S1AP Id %d, EPS Bearer id %d, state %d\n",mme_s1ap_id,ebi,ue_ctx->erabs_ctx[ebi].state); m_s1ap_log->console("EPS Bearer could not be activated. MME S1AP Id %d, EPS Bearer id %d\n",mme_s1ap_id,ebi,ue_ctx->erabs_ctx[ebi].state); return; } - ue_ctx->erabs_ctx[ebi].state = ERAB_ACTIVE; + ecm_ctx->erabs_ctx[ebi].state = ERAB_ACTIVE; m_s1ap_log->info("Activated EPS Bearer\n"); return; }