2017-04-12 12:44:18 +00:00
|
|
|
#define TRACE_MODULE _mme_s11_handler
|
|
|
|
|
|
|
|
#include "core_debug.h"
|
|
|
|
|
|
|
|
#include "gtp_types.h"
|
|
|
|
|
|
|
|
#include "mme_event.h"
|
|
|
|
#include "mme_context.h"
|
2017-08-09 15:41:09 +00:00
|
|
|
|
|
|
|
#include "s1ap_build.h"
|
|
|
|
#include "s1ap_path.h"
|
|
|
|
#include "mme_s11_build.h"
|
2017-04-12 12:44:18 +00:00
|
|
|
#include "mme_s11_handler.h"
|
2017-08-10 08:02:07 +00:00
|
|
|
#include "mme_s11_path.h"
|
|
|
|
|
2017-08-11 06:21:03 +00:00
|
|
|
void mme_s11_handle_create_session_request(mme_sess_t *sess)
|
2017-08-10 08:02:07 +00:00
|
|
|
{
|
|
|
|
status_t rv;
|
|
|
|
pkbuf_t *pkbuf = NULL;
|
|
|
|
|
2017-08-11 11:39:52 +00:00
|
|
|
/* FIXME : SGW Selection */
|
|
|
|
MME_SESSION_SELECT_SGW(sess);
|
|
|
|
|
2017-08-11 06:21:03 +00:00
|
|
|
rv = mme_s11_build_create_session_request(&pkbuf, sess);
|
2017-08-10 08:02:07 +00:00
|
|
|
d_assert(rv == CORE_OK, return,
|
|
|
|
"S11 build error");
|
|
|
|
|
2017-08-11 11:39:52 +00:00
|
|
|
rv = mme_s11_send_to_sgw(sess, GTP_CREATE_SESSION_REQUEST_TYPE, pkbuf);
|
2017-08-10 08:02:07 +00:00
|
|
|
d_assert(rv == CORE_OK, return, "S11 send error");
|
|
|
|
}
|
2017-04-12 12:44:18 +00:00
|
|
|
|
|
|
|
void mme_s11_handle_create_session_response(
|
2017-04-27 14:06:10 +00:00
|
|
|
mme_sess_t *sess, gtp_create_session_response_t *rsp)
|
2017-04-12 12:44:18 +00:00
|
|
|
{
|
|
|
|
gtp_f_teid_t *sgw_s11_teid = NULL;
|
|
|
|
gtp_f_teid_t *sgw_s1u_teid = NULL;
|
|
|
|
|
2017-04-13 10:15:53 +00:00
|
|
|
mme_bearer_t *bearer = NULL;
|
2017-04-13 03:21:47 +00:00
|
|
|
pdn_t *pdn = NULL;
|
2017-04-12 12:44:18 +00:00
|
|
|
|
2017-04-27 14:06:10 +00:00
|
|
|
d_assert(sess, return, "Null param");
|
2017-04-12 12:44:18 +00:00
|
|
|
d_assert(rsp, return, "Null param");
|
|
|
|
|
|
|
|
if (rsp->sender_f_teid_for_control_plane.presence == 0)
|
|
|
|
{
|
|
|
|
d_error("No GTP TEID");
|
|
|
|
return;
|
|
|
|
}
|
2017-04-13 03:21:47 +00:00
|
|
|
if (rsp->pdn_address_allocation.presence == 0)
|
|
|
|
{
|
|
|
|
d_error("No PDN Address Allocation");
|
|
|
|
return;
|
|
|
|
}
|
2017-04-12 12:44:18 +00:00
|
|
|
if (rsp->bearer_contexts_created.presence == 0)
|
|
|
|
{
|
|
|
|
d_error("No Bearer");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (rsp->bearer_contexts_created.eps_bearer_id.presence == 0)
|
|
|
|
{
|
|
|
|
d_error("No EPS Bearer ID");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (rsp->bearer_contexts_created.s1_u_enodeb_f_teid.presence == 0)
|
|
|
|
{
|
|
|
|
d_error("No GTP TEID");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-27 14:06:10 +00:00
|
|
|
bearer = mme_bearer_find_by_sess_ebi(
|
|
|
|
sess, rsp->bearer_contexts_created.eps_bearer_id.u8);
|
2017-04-13 10:15:53 +00:00
|
|
|
d_assert(bearer, return, "No ESM Context");
|
2017-08-11 11:25:52 +00:00
|
|
|
pdn = sess->pdn;
|
2017-04-13 03:21:47 +00:00
|
|
|
d_assert(pdn, return, "No PDN Context");
|
2017-04-12 12:44:18 +00:00
|
|
|
|
|
|
|
/* Receive Control Plane(UL) : SGW-S11 */
|
|
|
|
sgw_s11_teid = rsp->sender_f_teid_for_control_plane.data;
|
2017-04-27 14:06:10 +00:00
|
|
|
sess->sgw_s11_teid = ntohl(sgw_s11_teid->teid);
|
|
|
|
sess->sgw_s11_addr = sgw_s11_teid->ipv4_addr;
|
2017-04-12 12:44:18 +00:00
|
|
|
|
2017-04-13 03:21:47 +00:00
|
|
|
memcpy(&pdn->paa, rsp->pdn_address_allocation.data,
|
|
|
|
rsp->pdn_address_allocation.len);
|
|
|
|
|
|
|
|
if (rsp->protocol_configuration_options.presence)
|
|
|
|
{
|
2017-04-13 10:15:53 +00:00
|
|
|
bearer->pgw_pco_len = rsp->protocol_configuration_options.len;
|
|
|
|
memcpy(bearer->pgw_pco, rsp->protocol_configuration_options.data,
|
|
|
|
bearer->pgw_pco_len);
|
2017-04-13 03:21:47 +00:00
|
|
|
}
|
|
|
|
|
2017-04-12 12:44:18 +00:00
|
|
|
/* Receive Data Plane(UL) : SGW-S1U */
|
|
|
|
sgw_s1u_teid = rsp->bearer_contexts_created.s1_u_enodeb_f_teid.data;
|
2017-04-13 10:15:53 +00:00
|
|
|
bearer->sgw_s1u_teid = ntohl(sgw_s1u_teid->teid);
|
|
|
|
bearer->sgw_s1u_addr = sgw_s1u_teid->ipv4_addr;
|
2017-04-12 13:27:32 +00:00
|
|
|
|
2017-08-02 06:11:08 +00:00
|
|
|
d_trace(3, "[GTP] Create Session Response : "
|
|
|
|
"MME[%d] <-- SGW[%d]\n", sess->mme_s11_teid, sess->sgw_s11_teid);
|
2017-04-12 12:44:18 +00:00
|
|
|
}
|
2017-04-13 16:26:50 +00:00
|
|
|
|
|
|
|
void mme_s11_handle_modify_bearer_response(
|
2017-04-27 14:06:10 +00:00
|
|
|
mme_sess_t *sess, gtp_modify_bearer_response_t *rsp)
|
2017-04-13 16:26:50 +00:00
|
|
|
{
|
2017-08-09 15:41:09 +00:00
|
|
|
d_trace(3, "[GTP] Modify Bearer Response : "
|
|
|
|
"MME[%d] <-- SGW[%d]\n", sess->mme_s11_teid, sess->sgw_s11_teid);
|
2017-04-13 16:26:50 +00:00
|
|
|
}
|
2017-04-28 02:20:09 +00:00
|
|
|
|
|
|
|
void mme_s11_handle_delete_session_response(
|
2017-04-28 04:46:16 +00:00
|
|
|
mme_sess_t *sess, gtp_delete_session_response_t *rsp)
|
2017-04-28 02:20:09 +00:00
|
|
|
{
|
2017-04-28 04:46:16 +00:00
|
|
|
if (rsp->cause.presence == 0)
|
2017-04-28 02:20:09 +00:00
|
|
|
{
|
|
|
|
d_error("No Cause");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-10 07:47:18 +00:00
|
|
|
mme_sess_remove(sess);
|
|
|
|
|
2017-08-02 06:11:08 +00:00
|
|
|
d_trace(3, "[GTP] Delete Session Response : "
|
|
|
|
"MME[%d] <-- SGW[%d]\n", sess->mme_s11_teid, sess->sgw_s11_teid);
|
2017-04-28 02:20:09 +00:00
|
|
|
}
|
2017-07-25 12:15:25 +00:00
|
|
|
|
|
|
|
void mme_s11_handle_release_access_bearers_response(
|
|
|
|
mme_sess_t *sess, gtp_release_access_bearers_response_t *rsp)
|
|
|
|
{
|
|
|
|
d_assert(rsp, return, "Null param");
|
|
|
|
d_assert(sess, return, "Null param");
|
|
|
|
|
|
|
|
if (rsp->cause.presence == 0)
|
|
|
|
{
|
|
|
|
d_error("No Cause");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-02 06:11:08 +00:00
|
|
|
d_trace(3, "[GTP] Release Access Bearers Response : "
|
|
|
|
"MME[%d] <-- SGW[%d]\n", sess->mme_s11_teid, sess->sgw_s11_teid);
|
2017-07-25 12:15:25 +00:00
|
|
|
}
|
2017-08-02 23:18:19 +00:00
|
|
|
|
|
|
|
void mme_s11_handle_downlink_data_notification(
|
2017-08-03 00:32:50 +00:00
|
|
|
gtp_xact_t *xact, mme_sess_t *sess,
|
|
|
|
gtp_downlink_data_notification_t *noti)
|
2017-08-02 23:18:19 +00:00
|
|
|
{
|
2017-08-09 15:41:09 +00:00
|
|
|
status_t rv;
|
2017-08-02 23:18:19 +00:00
|
|
|
mme_bearer_t *bearer = NULL;
|
2017-08-09 15:41:09 +00:00
|
|
|
pkbuf_t *s11buf = NULL;
|
2017-08-02 23:18:19 +00:00
|
|
|
|
2017-08-03 00:32:50 +00:00
|
|
|
d_assert(xact, return, "Null param");
|
2017-08-02 23:18:19 +00:00
|
|
|
d_assert(sess, return, "Null param");
|
|
|
|
d_assert(noti, return, "Null param");
|
|
|
|
|
|
|
|
d_trace(3, "[GTP] Downlink Data Notification : "
|
|
|
|
"MME[%d] <-- SGW[%d]\n", sess->mme_s11_teid, sess->sgw_s11_teid);
|
|
|
|
|
|
|
|
bearer = mme_bearer_find_by_sess_ebi(sess, noti->eps_bearer_id.u8);
|
|
|
|
d_assert(bearer, return, "No ESM Context");
|
|
|
|
|
2017-08-09 15:41:09 +00:00
|
|
|
/* Build Downlink data notification ack */
|
|
|
|
rv = mme_s11_build_downlink_data_notification_ack(&s11buf, sess);
|
|
|
|
d_assert(rv == CORE_OK, return, "S11 build error");
|
|
|
|
|
|
|
|
d_assert(gtp_xact_commit(xact,
|
|
|
|
GTP_DOWNLINK_DATA_NOTIFICATION_ACKNOWLEDGE_TYPE,
|
|
|
|
sess->sgw_s11_teid, s11buf) == CORE_OK,
|
|
|
|
return , "xact commit error");
|
2017-08-02 23:18:19 +00:00
|
|
|
}
|