diff --git a/srsepc/hdr/mme/mme_gtpc.h b/srsepc/hdr/mme/mme_gtpc.h index f41863698..2c4cb10c9 100644 --- a/srsepc/hdr/mme/mme_gtpc.h +++ b/srsepc/hdr/mme/mme_gtpc.h @@ -51,6 +51,7 @@ public: void send_create_session_request(uint64_t imsi, uint32_t mme_s1ap_id); void handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu); void send_modify_bearer_request(erab_ctx_t *bearer_ctx); + void handle_modify_bearer_response(srslte::gtpc_pdu *mb_resp_pdu); private: diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index 0d0f0a598..ee5e5e6d1 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -87,6 +87,8 @@ public: bool handle_initial_context_setup_response(LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPRESPONSE_STRUCT *in_ctxt_resp); bool handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_msg, ue_ctx_t *ue_ctx); + void activate_eps_bearer(uint32_t mme_s1ap_id, uint8_t ebi); + void print_enb_ctx_info(const enb_ctx_t &enb_ctx); private: diff --git a/srsepc/hdr/spgw/spgw.h b/srsepc/hdr/spgw/spgw.h index 9b5af5eff..62fd704d2 100644 --- a/srsepc/hdr/spgw/spgw.h +++ b/srsepc/hdr/spgw/spgw.h @@ -56,6 +56,7 @@ typedef struct { typedef struct spgw_tunnel_ctx { uint64_t imsi; in_addr_t ue_ipv4; + uint8_t ebi; struct srslte::gtpc_f_teid_ie up_ctrl_fteid; struct srslte::gtpc_f_teid_ie up_user_fteid; struct srslte::gtpc_f_teid_ie dw_ctrl_fteid; diff --git a/srsepc/src/mme/mme_gtpc.cc b/srsepc/src/mme/mme_gtpc.cc index a085e5541..4d7a0aee9 100644 --- a/srsepc/src/mme/mme_gtpc.cc +++ b/srsepc/src/mme/mme_gtpc.cc @@ -189,6 +189,27 @@ mme_gtpc::send_modify_bearer_request(erab_ctx_t *erab_ctx) // srslte::gtpc_pdu mb_resp_pdu; - m_spgw->handle_modify_bearer_request(&mb_req_pdu,&mb_resp_pdu); + m_spgw->handle_modify_bearer_request(&mb_req_pdu,&mb_resp_pdu); + handle_modify_bearer_response(&mb_resp_pdu); + return; } + +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()) + { + m_mme_gtpc_log->error("Could not find MME S1AP Id 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); + + return; +} + } //namespace srsepc diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 27be5ba29..370ed87c2 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -823,6 +823,26 @@ s1ap::handle_ue_context_release_request(LIBLTE_S1AP_MESSAGE_UECONTEXTRELEASEREQU return true; } +void +s1ap::activate_eps_bearer(uint32_t mme_s1ap_id, uint8_t ebi) +{ + std::map::iterator ue_ctx_it = m_active_ues.find(mme_s1ap_id); + if(ue_ctx_it == m_active_ues.end()) + { + m_s1ap_log->error("Could not find UE context\n"); + return; + } + ue_ctx_t * ue_ctx = ue_ctx_it->second; + if (ue_ctx->erabs_ctx[ebi].state != ERAB_CTX_REQUESTED) + { + m_s1ap_log->error("EPS Bearer could not be activated. EPS Bearer id %d\n",ebi); + return; + } + + ue_ctx->erabs_ctx[ebi].state = ERAB_ACTIVE; + m_s1ap_log->info("Activated EPS Bearer\n"); + return; +} void s1ap::print_enb_ctx_info(const enb_ctx_t &enb_ctx) diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index 6d390ad38..ef301d064 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -323,14 +323,16 @@ spgw::handle_create_session_request(struct srslte::gtpc_create_session_request * //Allocate UE IP in_addr_t ue_ip = get_new_ue_ipv4(); + uint8_t default_bearer_id = 5; //Save the UE IP to User TEID map //TODO!!! spgw_tunnel_ctx_t *tunnel_ctx = new spgw_tunnel_ctx_t; tunnel_ctx->imsi = cs_req->imsi; + tunnel_ctx->ebi = default_bearer_id; tunnel_ctx->up_user_fteid.teid = spgw_uplink_user_teid; tunnel_ctx->up_user_fteid.ipv4 = m_s1u_addr.sin_addr.s_addr; tunnel_ctx->dw_ctrl_fteid.teid = cs_req->sender_f_teid.teid; tunnel_ctx->dw_ctrl_fteid.ipv4 = cs_req->sender_f_teid.ipv4; - + tunnel_ctx->up_ctrl_fteid.teid = spgw_uplink_ctrl_teid; tunnel_ctx->ue_ipv4 = ue_ip; m_teid_to_tunnel_ctx.insert(std::pair(spgw_uplink_ctrl_teid,tunnel_ctx)); @@ -349,7 +351,7 @@ spgw::handle_create_session_request(struct srslte::gtpc_create_session_request * cs_resp->sender_f_teid.teid = spgw_uplink_ctrl_teid; cs_resp->sender_f_teid.ipv4 = 0;//FIXME This is not relevant, as the GTP-C is not transmitted over sockets yet. //Bearer context created - cs_resp->eps_bearer_context_created.ebi = 5; + cs_resp->eps_bearer_context_created.ebi = default_bearer_id; cs_resp->eps_bearer_context_created.cause.cause_value = srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED; cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid_present=true; cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid.teid = spgw_uplink_user_teid; @@ -402,13 +404,17 @@ spgw::handle_modify_bearer_request(struct srslte::gtpc_pdu *mb_req_pdu, struct s //Setting up Modify bearer response PDU //Header - srslte::gtpc_header *header = &mb_req_pdu->header; + srslte::gtpc_header *header = &mb_resp_pdu->header; header->piggyback = false; header->teid_present = true; header->teid = tunnel_ctx->dw_ctrl_fteid.teid; // header->type = srslte::GTPC_MSG_TYPE_MODIFY_BEARER_RESPONSE; //PDU - srslte::gtpc_modify_bearer_response *mb_resp = &mb_req_pdu->choice.modify_bearer_response; + srslte::gtpc_modify_bearer_response *mb_resp = &mb_resp_pdu->choice.modify_bearer_response; + mb_resp->cause.cause_value = srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED; + mb_resp->eps_bearer_context_modified.ebi = tunnel_ctx->ebi; + printf("%d %d\n",mb_resp->eps_bearer_context_modified.ebi, tunnel_ctx->ebi); + mb_resp->eps_bearer_context_modified.cause.cause_value = srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED; } } //namespace srsepc