Modify Bearer response parsed ok. Starting to setup the user-plane tunnels

master
Pedro Alvarez 7 years ago
parent 04d67509cf
commit d18ff13d27

@ -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:

@ -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:

@ -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;

@ -190,5 +190,26 @@ 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);
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<uint32_t,uint32_t>::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

@ -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<uint32_t,ue_ctx_t*>::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)

@ -323,9 +323,11 @@ 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;
@ -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

Loading…
Cancel
Save