From 2b84e7838978784247c6547d7e82baebb44a94ed Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 8 Mar 2018 14:19:13 +0000 Subject: [PATCH] Adding release access bearer request to SPGW. Compiling now. --- srsepc/hdr/spgw/spgw.h | 1 + srsepc/src/mme/mme_gtpc.cc | 2 +- srsepc/src/mme/s1ap.cc | 8 ++++---- srsepc/src/spgw/spgw.cc | 29 ++++++++++++++++++++++++++++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/srsepc/hdr/spgw/spgw.h b/srsepc/hdr/spgw/spgw.h index 3837dcf08..14868c571 100644 --- a/srsepc/hdr/spgw/spgw.h +++ b/srsepc/hdr/spgw/spgw.h @@ -76,6 +76,7 @@ public: void handle_create_session_request(struct srslte::gtpc_create_session_request *cs_req, struct srslte::gtpc_pdu *cs_resp_pdu,bool pack_attach); void handle_modify_bearer_request(struct srslte::gtpc_pdu *mb_req_pdu, struct srslte::gtpc_pdu *mb_resp_pdu); void handle_delete_session_request(struct srslte::gtpc_pdu *del_req_pdu, struct srslte::gtpc_pdu *del_resp_pdu); + void handle_release_access_bearers_request(struct srslte::gtpc_pdu *rel_req_pdu, struct srslte::gtpc_pdu *rel_resp_pdu); void handle_sgi_pdu(srslte::byte_buffer_t *msg); void handle_s1u_pdu(srslte::byte_buffer_t *msg); diff --git a/srsepc/src/mme/mme_gtpc.cc b/srsepc/src/mme/mme_gtpc.cc index 6a6ffda5c..608b29b6e 100644 --- a/srsepc/src/mme/mme_gtpc.cc +++ b/srsepc/src/mme/mme_gtpc.cc @@ -362,7 +362,7 @@ mme_gtpc::send_release_access_bearers_request(uint64_t imsi) m_mme_gtpc_log->info("GTP-C Release Access Berarers Request -- S-GW Control TEID %d\n", sgw_ctrl_fteid->teid ); srslte::gtpc_pdu rel_resp_pdu; - m_spgw->handle_release_access_bearers_response(&del_req_pdu, &rel_resp_pdu); + m_spgw->handle_release_access_bearers_request(&rel_req_pdu, &rel_resp_pdu); //The GTP-C connection will not be torn down, just the user plane bearers. return; diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index a54096114..19b32ba24 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -510,18 +510,18 @@ s1ap::activate_eps_bearer(uint64_t imsi, uint8_t ebi) 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); + std::map::iterator ecm_ctx_it = m_mme_ue_s1ap_id_to_ue_ecm_ctx.find(mme_ue_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 * ecm_ctx = ue_ctx_it->second; + ue_ecm_ctx_t * ecm_ctx = ecm_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); + m_s1ap_log->error("EPS Bearer could not be activated. MME S1AP Id %d, EPS Bearer id %d, state %d\n",mme_ue_s1ap_id,ebi,ecm_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_ue_s1ap_id,ebi,ecm_ctx->erabs_ctx[ebi].state); return; } diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index df62fa43b..b16b89c27 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -571,7 +571,7 @@ spgw::handle_delete_session_request(struct srslte::gtpc_pdu *del_req_pdu, struct //Delete data tunnel pthread_mutex_lock(&m_mutex); - std::map::iterator data_it = m_ip_to_teid.find(tunnel_ctx->ue_ipv4); + std::map::iterator data_it = m_ip_to_teid.find(tunnel_ctx->ue_ipv4); if(data_it != m_ip_to_teid.end()) { m_ip_to_teid.erase(data_it); @@ -583,4 +583,31 @@ spgw::handle_delete_session_request(struct srslte::gtpc_pdu *del_req_pdu, struct return; } +void +spgw::handle_release_access_bearers_request(struct srslte::gtpc_pdu *rel_req_pdu, struct srslte::gtpc_pdu *rel_resp_pdu) +{ + //Find tunel ctxt + uint32_t ctrl_teid = rel_req_pdu->header.teid; + std::map::iterator tunnel_it = m_teid_to_tunnel_ctx.find(ctrl_teid); + if(tunnel_it == m_teid_to_tunnel_ctx.end()) + { + m_spgw_log->warning("Could not find TEID %d to release bearers from\n",ctrl_teid); + return; + } + spgw_tunnel_ctx_t *tunnel_ctx = tunnel_it->second; + in_addr_t ue_ipv4 = tunnel_ctx->ue_ipv4; + + //Delete data tunnel + pthread_mutex_lock(&m_mutex); + std::map::iterator data_it = m_ip_to_teid.find(tunnel_ctx->ue_ipv4); + if(data_it != m_ip_to_teid.end()) + { + m_ip_to_teid.erase(data_it); + } + pthread_mutex_unlock(&m_mutex); + + //Do NOT delete control tunnel + return; +} + } //namespace srsepc