Adding delete session request.

master
Pedro Alvarez 7 years ago
parent c3f0753a93
commit 8c9704ef3c

@ -76,6 +76,8 @@ typedef union gtpc_msg_choice
struct gtpc_create_session_response create_session_response;
struct gtpc_modify_bearer_request modify_bearer_request;
struct gtpc_modify_bearer_response modify_bearer_response;
struct gtpc_delete_session_request delete_session_request;
struct gtpc_delete_session_response delete_session_response;
} gtpc_msg_choice_t;
/****************************************************************************

@ -377,5 +377,38 @@ struct gtpc_modify_bearer_response
//ext
};
/****************************************************************************
*
* GTP-C v2 Delete Session Resquest
* Ref: 3GPP TS 29.274 v10.14.0 Table 7.2.9.1-1
*
***************************************************************************/
struct gtpc_delete_session_request
{
struct gtpc_cause_ie cause;
//Linked EPS Bearer ID
//User Location Information
//Indication Flags
//Protocol Configuration Options
//Originating Node
//Private extension
};
/****************************************************************************
*
* GTP-C v2 Delete Session Response
* Ref: 3GPP TS 29.274 v10.14.0 Table 7.2.10.1-1
*
***************************************************************************/
struct gtpc_delete_session_response
{
struct gtpc_cause_ie cause;
//Recovery
//Protocol Configuration Options
//Private extension
};
} //namespace
#endif //GTPC_V2_MSG_H

@ -52,6 +52,7 @@ public:
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);
void send_delete_session_request(ue_ctx_t *ue_ctx);
private:

@ -75,6 +75,7 @@ public:
void handle_create_session_request(struct srslte::gtpc_create_session_request *cs_req, struct srslte::gtpc_pdu *cs_resp_pdu);
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_sgi_pdu(srslte::byte_buffer_t *msg);
void handle_s1u_pdu(srslte::byte_buffer_t *msg);

@ -212,4 +212,38 @@ mme_gtpc::handle_modify_bearer_response(srslte::gtpc_pdu *mb_resp_pdu)
return;
}
void
mme_gtpc::send_delete_session_request(ue_ctx_t *ue_ctx)
{
m_mme_gtpc_log->info("Sending GTP-C Delete Session Request request\n");
srslte::gtpc_pdu del_req_pdu;
srslte::gtpc_f_teid_ie *sgw_ctrl_fteid;
//FIXME the UE control TEID sould be stored in the UE ctxt, not in the E-RAB ctxt
//Maybe a mme_s1ap_id to ctrl teid map as well?
for(int i = 0; i<MAX_ERABS_PER_UE; i++)
{
if(ue_ctx->erabs_ctx[i].state != ERAB_DEACTIVATED)
{
sgw_ctrl_fteid = &ue_ctx->erabs_ctx[i].sgw_ctrl_fteid;
break;
}
}
srslte::gtpc_header *header = &del_req_pdu.header;
header->teid_present = true;
header->teid = sgw_ctrl_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 );
srslte::gtpc_pdu del_resp_pdu;
m_spgw->handle_delete_session_request(&del_req_pdu, &del_resp_pdu);
//TODO Handle delete session response
return;
}
} //namespace srsepc

@ -517,7 +517,20 @@ s1ap::handle_ue_context_release_request(LIBLTE_S1AP_MESSAGE_UECONTEXTRELEASEREQU
ue_set->second.erase(mme_ue_s1ap_id);
//Delete any context at the SPGW
//m_spgw->delete_session_request(ue_ctx->imsi);
bool active = false;
for(int i=0;i<MAX_ERABS_PER_UE;i++)
{
if(ue_ctx->second->erabs_ctx[i].state != ERAB_DEACTIVATED)
{
active = true;
break;
}
}
if(active == true)
{
//There are active E-RABs, send delete session request
m_mme_gtpc->send_delete_session_request(ue_ctx->second);
}
//Delete UE context
delete ue_ctx->second;

@ -375,7 +375,7 @@ spgw::handle_sgi_pdu(srslte::byte_buffer_t *msg)
int n = sendto(m_s1u,msg->msg,msg->N_bytes,0,(struct sockaddr*) &enb_addr,sizeof(enb_addr));
if(n<0)
{
m_spgw_log->console("Error sending packet to eNB\n");
m_spgw_log->error("Error sending packet to eNB\n");
return;
}
//m_spgw_log->console("Sent packet to %s:%d. Bytes=%d\n",inet_ntoa(enb_addr.sin_addr), GTPU_RX_PORT,n);
@ -437,7 +437,8 @@ spgw::handle_create_session_request(struct srslte::gtpc_create_session_request *
in_addr_t ue_ip = get_new_ue_ipv4();
uint8_t default_bearer_id = 5;
//Save the UE IP to User TEID map //TODO!!!
//Save the UE IP to User TEID map
spgw_tunnel_ctx_t *tunnel_ctx = new spgw_tunnel_ctx_t;
tunnel_ctx->imsi = cs_req->imsi;
tunnel_ctx->ebi = default_bearer_id;
@ -449,6 +450,7 @@ spgw::handle_create_session_request(struct srslte::gtpc_create_session_request *
tunnel_ctx->up_ctrl_fteid.teid = spgw_uplink_ctrl_teid;
tunnel_ctx->ue_ipv4 = ue_ip;
m_teid_to_tunnel_ctx.insert(std::pair<uint32_t,spgw_tunnel_ctx_t*>(spgw_uplink_ctrl_teid,tunnel_ctx));
//Create session response message
//Setup GTP-C header
header->piggyback = false;
@ -479,13 +481,9 @@ spgw::handle_create_session_request(struct srslte::gtpc_create_session_request *
return;
}
/*
void
spgw::delete_session_request(uint64_t imsi)
{
}
*/
void
spgw::handle_modify_bearer_request(struct srslte::gtpc_pdu *mb_req_pdu, struct srslte::gtpc_pdu *mb_resp_pdu)
{
@ -541,4 +539,32 @@ spgw::handle_modify_bearer_request(struct srslte::gtpc_pdu *mb_req_pdu, struct s
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;
}
void
spgw::handle_delete_session_request(struct srslte::gtpc_pdu *del_req_pdu, struct srslte::gtpc_pdu *del_resp_pdu)
{
//Find tunel ctxt
uint32_t ctrl_teid = del_req_pdu->header.teid;
std::map<uint32_t,spgw_tunnel_ctx_t*>::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 delete\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<in_addr_t,srslte::gtpc_f_teid_ie>::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);
delete tunnel_ctx;
return;
}
} //namespace srsepc

Loading…
Cancel
Save