|
|
|
@ -91,7 +91,8 @@ mme_gtpc::get_new_ctrl_teid()
|
|
|
|
|
{
|
|
|
|
|
return m_next_ctrl_teid++; //FIXME Use a Id pool?
|
|
|
|
|
}
|
|
|
|
|
void
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
mme_gtpc::send_create_session_request(uint64_t imsi)
|
|
|
|
|
{
|
|
|
|
|
m_mme_gtpc_log->info("Sending Create Session Request.\n");
|
|
|
|
@ -133,17 +134,13 @@ mme_gtpc::send_create_session_request(uint64_t imsi)
|
|
|
|
|
|
|
|
|
|
//Check whether this UE is already registed
|
|
|
|
|
std::map<uint64_t, struct gtpc_ctx>::iterator it = m_imsi_to_gtpc_ctx.find(imsi);
|
|
|
|
|
if(it != m_imsi_to_gtpc_ctx.end())
|
|
|
|
|
{
|
|
|
|
|
if (it != m_imsi_to_gtpc_ctx.end()) {
|
|
|
|
|
m_mme_gtpc_log->warning("Create Session Request being called for an UE with an active GTP-C connection.\n");
|
|
|
|
|
m_mme_gtpc_log->warning("Deleting previous GTP-C connection.\n");
|
|
|
|
|
std::map<uint32_t, uint64_t>::iterator jt = m_mme_ctr_teid_to_imsi.find(it->second.mme_ctr_fteid.teid);
|
|
|
|
|
if(jt == m_mme_ctr_teid_to_imsi.end())
|
|
|
|
|
{
|
|
|
|
|
if (jt == m_mme_ctr_teid_to_imsi.end()) {
|
|
|
|
|
m_mme_gtpc_log->error("Could not find IMSI from MME Ctrl TEID. MME Ctr TEID: %d\n", it->second.mme_ctr_fteid.teid);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
} else {
|
|
|
|
|
m_mme_ctr_teid_to_imsi.erase(jt);
|
|
|
|
|
}
|
|
|
|
|
m_imsi_to_gtpc_ctx.erase(it);
|
|
|
|
@ -160,10 +157,10 @@ mme_gtpc::send_create_session_request(uint64_t imsi)
|
|
|
|
|
gtpc_ctx.mme_ctr_fteid = cs_req->sender_f_teid;
|
|
|
|
|
m_imsi_to_gtpc_ctx.insert(std::pair<uint64_t,gtpc_ctx_t>(imsi,gtpc_ctx));
|
|
|
|
|
m_spgw->handle_create_session_request(cs_req, &cs_resp_pdu);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bool
|
|
|
|
|
mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu)
|
|
|
|
|
{
|
|
|
|
|
struct srslte::gtpc_create_session_response *cs_resp = & cs_resp_pdu->choice.create_session_response;
|
|
|
|
@ -172,19 +169,19 @@ mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu)
|
|
|
|
|
if (cs_resp_pdu->header.type != srslte::GTPC_MSG_TYPE_CREATE_SESSION_RESPONSE) {
|
|
|
|
|
m_mme_gtpc_log->warning("Could not create GTPC session. Not a create session response\n");
|
|
|
|
|
//TODO Handle error
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (cs_resp->cause.cause_value != srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED) {
|
|
|
|
|
m_mme_gtpc_log->warning("Could not create GTPC session. Create Session Request not accepted\n");
|
|
|
|
|
//TODO Handle error
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Get IMSI from the control TEID
|
|
|
|
|
std::map<uint32_t,uint64_t>::iterator id_it = m_mme_ctr_teid_to_imsi.find(cs_resp_pdu->header.teid);
|
|
|
|
|
if(id_it == m_mme_ctr_teid_to_imsi.end()) {
|
|
|
|
|
m_mme_gtpc_log->warning("Could not find IMSI from Ctrl TEID.\n");
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
uint64_t imsi = id_it->second;
|
|
|
|
|
|
|
|
|
@ -198,7 +195,7 @@ mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu)
|
|
|
|
|
//Get S-GW S1-u F-TEID
|
|
|
|
|
if (cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid_present == false){
|
|
|
|
|
m_mme_gtpc_log->error("Did not receive SGW S1-U F-TEID in create session response\n");
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
m_mme_gtpc_log->console("Create Session Response -- SPGW control TEID %d\n", sgw_ctr_fteid.teid);
|
|
|
|
|
m_mme_gtpc_log->info("Create Session Response -- SPGW control TEID %d\n", sgw_ctr_fteid.teid);
|
|
|
|
@ -210,18 +207,18 @@ mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu)
|
|
|
|
|
//Check UE Ipv4 address was allocated
|
|
|
|
|
if (cs_resp->paa_present != true) {
|
|
|
|
|
m_mme_gtpc_log->error("PDN Adress Allocation not present\n");
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (cs_resp->paa.pdn_type != srslte::GTPC_PDN_TYPE_IPV4) {
|
|
|
|
|
m_mme_gtpc_log->error("IPv6 not supported yet\n");
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Save create session response info to E-RAB context
|
|
|
|
|
nas *nas_ctx = m_s1ap->find_nas_ctx_from_imsi(imsi);
|
|
|
|
|
if(nas_ctx == NULL){
|
|
|
|
|
m_mme_gtpc_log->error("Could not find UE context. IMSI %015lu\n", imsi);
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
emm_ctx_t *emm_ctx = &nas_ctx->m_emm_ctx;
|
|
|
|
|
ecm_ctx_t *ecm_ctx = &nas_ctx->m_ecm_ctx;
|
|
|
|
@ -234,7 +231,7 @@ mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu)
|
|
|
|
|
if(it_g == m_imsi_to_gtpc_ctx.end()) {
|
|
|
|
|
//Could not find GTP-C Context
|
|
|
|
|
m_mme_gtpc_log->error("Could not find GTP-C context\n");
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
gtpc_ctx_t *gtpc_ctx = &it_g->second;
|
|
|
|
|
gtpc_ctx->sgw_ctr_fteid = sgw_ctr_fteid;
|
|
|
|
@ -246,11 +243,11 @@ mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu)
|
|
|
|
|
esm_ctx->pdn_addr_alloc= cs_resp->paa;
|
|
|
|
|
esm_ctx->sgw_s1u_fteid = cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid;
|
|
|
|
|
m_s1ap->m_s1ap_ctx_mngmt_proc->send_initial_context_setup_request(nas_ctx, default_bearer);
|
|
|
|
|
return;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bool
|
|
|
|
|
mme_gtpc::send_modify_bearer_request(uint64_t imsi, uint16_t erab_to_modify, srslte::gtp_fteid_t *enb_fteid)
|
|
|
|
|
{
|
|
|
|
|
m_mme_gtpc_log->info("Sending GTP-C Modify bearer request\n");
|
|
|
|
@ -259,7 +256,7 @@ mme_gtpc::send_modify_bearer_request(uint64_t imsi, uint16_t erab_to_modify, srs
|
|
|
|
|
std::map<uint64_t,gtpc_ctx_t>::iterator it = m_imsi_to_gtpc_ctx.find(imsi);
|
|
|
|
|
if (it == m_imsi_to_gtpc_ctx.end()) {
|
|
|
|
|
m_mme_gtpc_log->error("Modify bearer request for UE without GTP-C connection\n");
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
srslte::gtp_fteid_t sgw_ctr_fteid = it->second.sgw_ctr_fteid;
|
|
|
|
|
|
|
|
|
@ -282,7 +279,7 @@ mme_gtpc::send_modify_bearer_request(uint64_t imsi, uint16_t erab_to_modify, srs
|
|
|
|
|
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;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
@ -302,7 +299,7 @@ mme_gtpc::handle_modify_bearer_response(srslte::gtpc_pdu *mb_resp_pdu)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bool
|
|
|
|
|
mme_gtpc::send_delete_session_request(uint64_t imsi)
|
|
|
|
|
{
|
|
|
|
|
m_mme_gtpc_log->info("Sending GTP-C Delete Session Request request. IMSI %" PRIu64 "\n",imsi);
|
|
|
|
@ -314,7 +311,7 @@ mme_gtpc::send_delete_session_request(uint64_t imsi)
|
|
|
|
|
std::map<uint64_t,gtpc_ctx_t>::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;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sgw_ctr_fteid = it_ctx->second.sgw_ctr_fteid;
|
|
|
|
@ -341,7 +338,7 @@ mme_gtpc::send_delete_session_request(uint64_t imsi)
|
|
|
|
|
m_mme_ctr_teid_to_imsi.erase(it_imsi);
|
|
|
|
|
}
|
|
|
|
|
m_imsi_to_gtpc_ctx.erase(it_ctx);
|
|
|
|
|
return;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|