diff --git a/srsepc/hdr/mme/mme_gtpc.h b/srsepc/hdr/mme/mme_gtpc.h index f94b05ccd..b832969ee 100644 --- a/srsepc/hdr/mme/mme_gtpc.h +++ b/srsepc/hdr/mme/mme_gtpc.h @@ -56,7 +56,7 @@ public: void handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu, bool pack_attach); void send_modify_bearer_request(uint64_t imsi, erab_ctx_t *bearer_ctx); void handle_modify_bearer_response(srslte::gtpc_pdu *mb_resp_pdu); - void send_delete_session_request(ue_ecm_ctx_t *ue_ecm_ctx); + void send_delete_session_request(uint64_t imsi); private: diff --git a/srsepc/src/mme/mme_gtpc.cc b/srsepc/src/mme/mme_gtpc.cc index 015ce5093..eec12d9ac 100644 --- a/srsepc/src/mme/mme_gtpc.cc +++ b/srsepc/src/mme/mme_gtpc.cc @@ -307,28 +307,47 @@ mme_gtpc::send_delete_session_request(uint64_t imsi) { m_mme_gtpc_log->info("Sending GTP-C Delete Session Request request. IMSI %d\n",imsi); srslte::gtpc_pdu del_req_pdu; - srslte::gtp_fteid_t sgw_ctrl_fteid; - - std::map::iterator it = m_imsi_to_gtpc_ctx.find(imsi); - + srslte::gtp_fteid_t sgw_ctr_fteid; + srslte::gtp_fteid_t mme_ctr_fteid; + //Get S-GW Ctr TEID + std::map::iterator it_ctx = m_imsi_to_gtpc_ctx.find(imsi); + if(it_ctx == m_imsi_to_gtpc_ctx.end()) + { + m_mme_gtpc_log->error("Could not find GTP-C context to remove\n"); + return; + } + sgw_ctr_fteid = it_ctx->second.sgw_ctr_fteid; + mme_ctr_fteid = it_ctx->second.mme_ctr_fteid; srslte::gtpc_header *header = &del_req_pdu.header; header->teid_present = true; - header->teid = sgw_ctrl_fteid->teid; + header->teid = sgw_ctr_fteid.teid; header->type = srslte::GTPC_MSG_TYPE_DELETE_SESSION_REQUEST; srslte::gtpc_delete_session_request *del_req = &del_req_pdu.choice.delete_session_request; del_req->cause.cause_value = srslte::GTPC_CAUSE_VALUE_ISR_DEACTIVATION; - m_mme_gtpc_log->info("GTP-C Delete Session Request -- S-GW Control TEID %d\n", sgw_ctrl_fteid->teid ); + m_mme_gtpc_log->info("GTP-C Delete Session Request -- S-GW Control TEID %d\n", sgw_ctr_fteid.teid ); srslte::gtpc_pdu del_resp_pdu; m_spgw->handle_delete_session_request(&del_req_pdu, &del_resp_pdu); //TODO Handle delete session response + + //Delete GTP-C context + std::map::iterator it_imsi = m_mme_ctr_teid_to_imsi.find(mme_ctr_fteid.teid); + if(it_imsi == m_mme_ctr_teid_to_imsi.end()) + { + m_mme_gtpc_log->error("Could not find IMSI from MME ctr TEID"); + } + else + { + m_mme_ctr_teid_to_imsi.erase(it_imsi); + } + m_imsi_to_gtpc_ctx.erase(it_ctx); return; } void -mme_gtpc::send_release_access_bearers_request(ue_ecm_ctx_t *ecm_ctx) +mme_gtpc::send_release_access_bearers_request(uint64_t imsi) { m_mme_gtpc_log->info("Sending GTP-C Delete Access Bearers Request\n"); srslte::gtpc_pdu rel_req_pdu; diff --git a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc index 02a2fb8d2..dd211cb04 100644 --- a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc @@ -283,7 +283,7 @@ s1ap_ctx_mngmt_proc::handle_ue_context_release_request(LIBLTE_S1AP_MESSAGE_UECON if(active == true) { //There are active E-RABs, send delete session request - m_mme_gtpc->send_delete_session_request(ue_ecm_ctx); + m_mme_gtpc->send_delete_session_request(ue_ecm_ctx->imsi); } //m_s1ap->delete_ue_ctx(ue_ctx); for(int i=0;i