2017-03-27 10:32:24 +00:00
|
|
|
#define TRACE_MODULE _esm_handler
|
|
|
|
|
|
|
|
#include "core_debug.h"
|
|
|
|
|
|
|
|
#include "nas_message.h"
|
|
|
|
|
2017-04-11 06:13:30 +00:00
|
|
|
#include "mme_context.h"
|
2017-08-10 07:47:18 +00:00
|
|
|
#include "nas_path.h"
|
2017-09-07 06:56:31 +00:00
|
|
|
#include "mme_gtp_path.h"
|
|
|
|
|
|
|
|
#include "esm_build.h"
|
2017-04-08 02:38:09 +00:00
|
|
|
|
2017-09-23 15:59:51 +00:00
|
|
|
status_t esm_handle_pdn_connectivity_request(mme_bearer_t *bearer,
|
2017-04-08 02:38:09 +00:00
|
|
|
nas_pdn_connectivity_request_t *pdn_connectivity_request)
|
|
|
|
{
|
2017-09-08 07:46:37 +00:00
|
|
|
status_t rv;
|
2017-09-06 15:37:16 +00:00
|
|
|
mme_ue_t *mme_ue = NULL;
|
2017-09-08 07:46:37 +00:00
|
|
|
mme_sess_t *sess = NULL;
|
2017-09-23 15:59:51 +00:00
|
|
|
c_uint8_t security_protected_required = 0;
|
2017-09-06 15:37:16 +00:00
|
|
|
|
2017-12-14 12:42:19 +00:00
|
|
|
d_assert(bearer, return CORE_ERROR,);
|
2017-09-08 07:46:37 +00:00
|
|
|
sess = bearer->sess;
|
2017-12-14 12:42:19 +00:00
|
|
|
d_assert(sess, return CORE_ERROR,);
|
2017-09-06 15:37:16 +00:00
|
|
|
mme_ue = sess->mme_ue;
|
2017-12-14 12:42:19 +00:00
|
|
|
d_assert(mme_ue, return CORE_ERROR,);
|
|
|
|
|
|
|
|
d_assert(pdn_connectivity_request, return CORE_ERROR,);
|
2017-09-06 15:37:16 +00:00
|
|
|
|
2017-09-23 15:59:51 +00:00
|
|
|
d_assert(MME_UE_HAVE_IMSI(mme_ue), return CORE_ERROR,
|
2017-09-08 07:46:37 +00:00
|
|
|
"No IMSI in PDN_CPNNECTIVITY_REQUEST");
|
2017-09-23 15:59:51 +00:00
|
|
|
d_assert(SECURITY_CONTEXT_IS_VALID(mme_ue), return CORE_ERROR,
|
2017-09-08 07:46:37 +00:00
|
|
|
"No Security Context in PDN_CPNNECTIVITY_REQUEST");
|
|
|
|
|
2017-12-14 12:42:19 +00:00
|
|
|
memcpy(&sess->request_type, &pdn_connectivity_request->request_type,
|
|
|
|
sizeof(sess->request_type));
|
|
|
|
|
2017-09-23 15:59:51 +00:00
|
|
|
security_protected_required = 0;
|
|
|
|
if (pdn_connectivity_request->presencemask &
|
|
|
|
NAS_PDN_CONNECTIVITY_REQUEST_ESM_INFORMATION_TRANSFER_FLAG_PRESENT)
|
|
|
|
{
|
|
|
|
nas_esm_information_transfer_flag_t *esm_information_transfer_flag =
|
|
|
|
&pdn_connectivity_request->esm_information_transfer_flag;
|
|
|
|
security_protected_required =
|
|
|
|
esm_information_transfer_flag->security_protected_required;
|
|
|
|
}
|
|
|
|
|
2017-09-06 15:37:16 +00:00
|
|
|
if (pdn_connectivity_request->presencemask &
|
|
|
|
NAS_PDN_CONNECTIVITY_REQUEST_ACCESS_POINT_NAME_PRESENT)
|
|
|
|
{
|
|
|
|
sess->pdn = mme_pdn_find_by_apn(mme_ue,
|
2017-09-23 15:59:51 +00:00
|
|
|
pdn_connectivity_request->access_point_name.apn);
|
2017-12-19 08:05:54 +00:00
|
|
|
if (!sess->pdn)
|
|
|
|
{
|
|
|
|
/* Invalid APN */
|
|
|
|
rv = nas_send_pdn_connectivity_reject(
|
|
|
|
sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN);
|
|
|
|
d_assert(rv == CORE_OK,, "nas send failed");
|
|
|
|
|
2017-12-20 04:16:16 +00:00
|
|
|
return CORE_ERROR;
|
2017-12-19 08:05:54 +00:00
|
|
|
}
|
2017-09-06 15:37:16 +00:00
|
|
|
}
|
2017-08-26 09:52:06 +00:00
|
|
|
|
2017-04-14 02:51:27 +00:00
|
|
|
if (pdn_connectivity_request->presencemask &
|
2017-04-14 10:18:08 +00:00
|
|
|
NAS_PDN_CONNECTIVITY_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
|
2017-04-14 02:51:27 +00:00
|
|
|
{
|
|
|
|
nas_protocol_configuration_options_t *protocol_configuration_options =
|
|
|
|
&pdn_connectivity_request->protocol_configuration_options;
|
2017-09-06 11:29:55 +00:00
|
|
|
|
|
|
|
NAS_STORE_DATA(&sess->ue_pco, protocol_configuration_options);
|
2017-04-14 02:51:27 +00:00
|
|
|
}
|
2017-09-08 07:46:37 +00:00
|
|
|
|
2017-09-23 15:59:51 +00:00
|
|
|
if (security_protected_required)
|
2017-09-08 07:46:37 +00:00
|
|
|
{
|
2017-09-23 15:59:51 +00:00
|
|
|
rv = nas_send_esm_information_request(bearer);
|
|
|
|
d_assert(rv == CORE_OK, return CORE_ERROR, "nas send failed");
|
2017-12-19 08:05:54 +00:00
|
|
|
|
|
|
|
return CORE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sess->pdn)
|
|
|
|
{
|
|
|
|
/* Default APN */
|
|
|
|
sess->pdn = mme_default_pdn(mme_ue);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sess->pdn)
|
|
|
|
{
|
|
|
|
rv = mme_gtp_send_create_session_request(sess);
|
|
|
|
d_assert(rv == CORE_OK, return CORE_ERROR, "gtp send failed");
|
2017-09-23 15:59:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-19 08:05:54 +00:00
|
|
|
rv = nas_send_pdn_connectivity_reject(
|
|
|
|
sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN);
|
|
|
|
d_assert(rv == CORE_OK,, "nas send failed");
|
2017-09-23 15:59:51 +00:00
|
|
|
|
2017-12-19 08:05:54 +00:00
|
|
|
return CORE_ERROR;
|
2017-09-08 07:46:37 +00:00
|
|
|
}
|
2017-09-23 15:59:51 +00:00
|
|
|
|
|
|
|
return CORE_OK;
|
2017-04-08 02:38:09 +00:00
|
|
|
}
|
2017-04-11 06:07:46 +00:00
|
|
|
|
2017-09-23 15:59:51 +00:00
|
|
|
status_t esm_handle_information_response(mme_sess_t *sess,
|
2017-04-11 06:07:46 +00:00
|
|
|
nas_esm_information_response_t *esm_information_response)
|
|
|
|
{
|
2017-09-08 07:46:37 +00:00
|
|
|
status_t rv;
|
2017-04-28 07:11:45 +00:00
|
|
|
mme_ue_t *mme_ue = NULL;
|
2017-04-11 06:13:30 +00:00
|
|
|
|
2017-09-23 15:59:51 +00:00
|
|
|
d_assert(sess, return CORE_ERROR, "Null param");
|
2017-08-26 09:52:06 +00:00
|
|
|
mme_ue = sess->mme_ue;
|
2017-09-23 15:59:51 +00:00
|
|
|
d_assert(mme_ue, return CORE_ERROR, "Null param");
|
2017-04-12 04:45:57 +00:00
|
|
|
|
2017-04-11 12:38:24 +00:00
|
|
|
if (esm_information_response->presencemask &
|
|
|
|
NAS_ESM_INFORMATION_RESPONSE_ACCESS_POINT_NAME_PRESENT)
|
|
|
|
{
|
2017-08-11 11:25:52 +00:00
|
|
|
sess->pdn = mme_pdn_find_by_apn(mme_ue,
|
2017-04-11 12:38:24 +00:00
|
|
|
esm_information_response->access_point_name.apn);
|
|
|
|
}
|
|
|
|
|
2017-04-11 14:25:33 +00:00
|
|
|
if (esm_information_response->presencemask &
|
|
|
|
NAS_ESM_INFORMATION_RESPONSE_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
|
|
|
|
{
|
|
|
|
nas_protocol_configuration_options_t *protocol_configuration_options =
|
|
|
|
&esm_information_response->protocol_configuration_options;
|
2017-09-06 11:29:55 +00:00
|
|
|
NAS_STORE_DATA(&sess->ue_pco, protocol_configuration_options);
|
2017-04-11 14:25:33 +00:00
|
|
|
}
|
2017-09-08 07:46:37 +00:00
|
|
|
|
2017-09-23 15:59:51 +00:00
|
|
|
if (sess->pdn)
|
|
|
|
{
|
|
|
|
if (MME_HAVE_SGW_S11_PATH(mme_ue))
|
|
|
|
{
|
|
|
|
rv = nas_send_attach_accept(mme_ue);
|
|
|
|
d_assert(rv == CORE_OK, return CORE_ERROR, "nas send failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rv = mme_gtp_send_create_session_request(sess);
|
|
|
|
d_assert(rv == CORE_OK, return CORE_ERROR, "gtp send failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rv = nas_send_pdn_connectivity_reject(
|
|
|
|
sess, ESM_CAUSE_MISSING_OR_UNKNOWN_APN);
|
|
|
|
d_assert(rv == CORE_OK,, "nas send failed");
|
|
|
|
|
|
|
|
return CORE_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CORE_OK;
|
2017-04-11 06:07:46 +00:00
|
|
|
}
|
2017-09-04 15:04:05 +00:00
|
|
|
|
2017-09-05 04:15:04 +00:00
|
|
|
void esm_handle_activate_default_bearer_accept(mme_bearer_t *bearer)
|
|
|
|
{
|
|
|
|
status_t rv;
|
|
|
|
|
|
|
|
d_assert(bearer, return, "Null param");
|
|
|
|
|
2017-09-07 10:44:08 +00:00
|
|
|
mme_bearer_t *dedicated_bearer = mme_bearer_next(bearer);
|
|
|
|
while(dedicated_bearer)
|
2017-09-05 04:15:04 +00:00
|
|
|
{
|
2017-09-07 12:28:12 +00:00
|
|
|
rv = nas_send_activate_dedicated_bearer_context_request(
|
2017-09-10 14:03:24 +00:00
|
|
|
dedicated_bearer);
|
2017-09-07 06:56:31 +00:00
|
|
|
d_assert(rv == CORE_OK, return,
|
2017-09-07 10:44:08 +00:00
|
|
|
"nas_send_activate_dedicated_bearer_context failed");
|
|
|
|
|
|
|
|
dedicated_bearer = mme_bearer_next(dedicated_bearer);
|
2017-09-05 04:15:04 +00:00
|
|
|
}
|
|
|
|
}
|