Commit 708013af authored by Cedric Roux's avatar Cedric Roux

- Mapped ESM/EBR data context to EMM data context in NAS MME

- Corrected Initial context setup req message

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4778 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 56440427
......@@ -3,16 +3,16 @@
#ifndef NAS_MESSAGES_TYPES_H_
#define NAS_MESSAGES_TYPES_H_
#define NAS_UL_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.nas_ul_data_ind
#define NAS_DL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_req
#define NAS_DL_DATA_CNF(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_cnf
#define NAS_CONN_EST_IND(mSGpTR) (mSGpTR)->ittiMsg.nas_conn_est_ind
#define NAS_CONN_EST_CNF(mSGpTR) (mSGpTR)->ittiMsg.nas_conn_est_cnf
#define NAS_BEARER_PARAM(mSGpTR) (mSGpTR)->ittiMsg.nas_bearer_param
#define NAS_AUTHENTICATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_req
#define NAS_AUTHENTICATION_PARAM_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_param_req
#define NAS_AUTHENTICATION_PARAM_RSP(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_param_rsp
#define NAS_AUTHENTICATION_PARAM_FAIL(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_param_fail
#define NAS_UL_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.nas_ul_data_ind
#define NAS_DL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_req
#define NAS_DL_DATA_CNF(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_cnf
#define NAS_CONN_EST_IND(mSGpTR) (mSGpTR)->ittiMsg.nas_conn_est_ind
#define NAS_CONNECTION_ESTABLISHMENT_CNF(mSGpTR) (mSGpTR)->ittiMsg.nas_conn_est_cnf
#define NAS_BEARER_PARAM(mSGpTR) (mSGpTR)->ittiMsg.nas_bearer_param
#define NAS_AUTHENTICATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_req
#define NAS_AUTHENTICATION_PARAM_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_param_req
#define NAS_AUTHENTICATION_PARAM_RSP(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_param_rsp
#define NAS_AUTHENTICATION_PARAM_FAIL(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_param_fail
typedef struct nas_paging_ind_s {
......@@ -29,6 +29,7 @@ typedef struct nas_conn_est_ind_s {
typedef nas_establish_rsp_t nas_conn_est_rej_t;
#if defined(DISABLE_USE_NAS)
typedef struct nas_conn_est_cnf_s {
uint32_t ue_id;
......@@ -36,6 +37,9 @@ typedef struct nas_conn_est_cnf_s {
/* Transparent message from MME_APP to S1AP */
s1ap_initial_ctxt_setup_req_t transparent;
} nas_conn_est_cnf_t;
#else
typedef nas_establish_cnf_t nas_conn_est_cnf_t;
#endif
typedef struct nas_bearer_param_s {
unsigned eNB_ue_s1ap_id:24;
......
......@@ -1117,6 +1117,7 @@ int emm_proc_attach_request(unsigned int ueid, emm_proc_attach_type_t type,
(*emm_ctx)->esm_msg.value = NULL;
(*emm_ctx)->emm_cause = EMM_CAUSE_SUCCESS;
(*emm_ctx)->_emm_fsm_status = EMM_INVALID;
(*emm_ctx)->ueid = ueid;
emm_fsm_set_status(ueid, *emm_ctx, EMM_DEREGISTERED);
#if defined(EPC_BUILD)
......@@ -1130,7 +1131,6 @@ int emm_proc_attach_request(unsigned int ueid, emm_proc_attach_type_t type,
if (rc != RETURNok) {
LOG_TRACE(WARNING, "EMM-PROC - Failed to update EMM context");
/* Do not accept the UE to attach to the network */
(*emm_ctx)->ueid = ueid;
(*emm_ctx)->emm_cause = EMM_CAUSE_ILLEGAL_UE;
rc = _emm_attach_reject(*emm_ctx);
} else {
......@@ -1216,12 +1216,13 @@ int emm_proc_attach_reject(unsigned int ueid, int emm_cause)
***************************************************************************/
int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg)
{
LOG_FUNC_IN;
emm_data_context_t *emm_ctx = NULL;
int rc = RETURNerror;
emm_sap_t emm_sap;
esm_sap_t esm_sap;
LOG_FUNC_IN;
LOG_TRACE(INFO, "EMM-PROC - EPS attach complete (ueid=%u)", ueid);
/* Stop timer T3450 */
......@@ -1238,7 +1239,6 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg)
}
/* Get the UE context */
emm_data_context_t *emm_ctx = NULL;
#if defined(EPC_BUILD)
if (ueid > 0) {
......@@ -1263,6 +1263,7 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg)
esm_sap.is_standalone = FALSE;
esm_sap.ueid = ueid;
esm_sap.recv = esm_msg;
esm_sap.ctx = emm_ctx;
rc = esm_sap_send(&esm_sap);
} else {
LOG_TRACE(ERROR, "EMM-PROC - No EMM context exists");
......@@ -1276,6 +1277,7 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg)
*/
emm_sap.primitive = EMMREG_ATTACH_CNF;
emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
rc = emm_sap_send(&emm_sap);
} else if (esm_sap.err != ESM_SAP_DISCARDED) {
/*
......@@ -1283,6 +1285,7 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg)
*/
emm_sap.primitive = EMMREG_ATTACH_REJ;
emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
rc = emm_sap_send(&emm_sap);
} else {
/*
......@@ -1748,14 +1751,17 @@ static int _emm_attach_reject(void *args)
***************************************************************************/
static int _emm_attach_abort(void *args)
{
LOG_FUNC_IN;
int rc = RETURNerror;
emm_data_context_t *ctx = NULL;
attach_data_t *data;
attach_data_t *data = (attach_data_t *)(args);
LOG_FUNC_IN;
data = (attach_data_t *)(args);
if (data) {
unsigned int ueid = data->ueid;
esm_sap_t esm_sap;
LOG_TRACE(WARNING, "EMM-PROC - Abort the attach procedure (ueid=%u)",
ueid);
......@@ -1771,15 +1777,22 @@ static int _emm_attach_abort(void *args)
}
free(data);
#if defined(EPC_BUILD)
ctx = emm_data_context_get(&_emm_data, ueid);
#else
ctx = _emm_data.ctx[ueid];
#endif
/*
* Notify ESM that the network locally refused PDN connectivity
* to the UE
*/
esm_sap_t esm_sap;
esm_sap.primitive = ESM_PDN_CONNECTIVITY_REJ;
esm_sap.ueid = ueid;
esm_sap.ctx = ctx;
esm_sap.recv = NULL;
rc = esm_sap_send(&esm_sap);
if (rc != RETURNerror) {
/*
* Notify EMM that EPS attach procedure failed
......@@ -1787,16 +1800,9 @@ static int _emm_attach_abort(void *args)
emm_sap_t emm_sap;
emm_sap.primitive = EMMREG_ATTACH_REJ;
emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = ctx;
rc = emm_sap_send(&emm_sap);
if (rc != RETURNerror) {
struct emm_data_context_s *ctx = NULL;
#if defined(EPC_BUILD)
ctx = emm_data_context_get(&_emm_data, ueid);
#else
ctx = _emm_data.ctx[ueid];
#endif
/* Release the UE context */
rc = _emm_attach_release(ctx);
}
......@@ -2098,6 +2104,7 @@ static int _emm_attach(void *args)
esm_sap.primitive = ESM_PDN_CONNECTIVITY_REQ;
esm_sap.is_standalone = FALSE;
esm_sap.ueid = emm_ctx->ueid;
esm_sap.ctx = emm_ctx;
esm_sap.recv = &emm_ctx->esm_msg;
rc = esm_sap_send(&esm_sap);
......@@ -2214,6 +2221,7 @@ static int _emm_attach_accept(emm_data_context_t *emm_ctx, attach_data_t *data)
* Notify EMM-AS SAP that Attach Accept message together with an Activate
* Default EPS Bearer Context Request message has to be sent to the UE
*/
emm_sap.primitive = EMMAS_ESTABLISH_CNF;
emm_sap.u.emm_as.u.establish.ueid = emm_ctx->ueid;
if (emm_ctx->guti_is_new && emm_ctx->old_guti) {
......@@ -2387,6 +2395,26 @@ static int _emm_attach_update(emm_data_context_t *ctx, unsigned int ueid,
} else {
return (RETURNerror);
}
} else {
if (ctx->guti == NULL) {
ctx->guti = (GUTI_t *)malloc(sizeof(GUTI_t));
}
if (ctx->guti != NULL) {
/* TODO: FIXME */
ctx->guti->gummei.plmn.MCCdigit1 = 2;
ctx->guti->gummei.plmn.MCCdigit2 = 0;
ctx->guti->gummei.plmn.MCCdigit3 = 8;
ctx->guti->gummei.plmn.MNCdigit1 = 9;
ctx->guti->gummei.plmn.MNCdigit2 = 2;
ctx->guti->gummei.plmn.MNCdigit3 = 15;
ctx->guti->gummei.MMEcode = 0;
ctx->guti->gummei.MMEgid = 0;
ctx->guti->m_tmsi = (uint32_t) ctx;
} else {
return (RETURNerror);
}
}
/* The IMSI if provided by the UE */
if (imsi) {
......
......@@ -512,6 +512,7 @@ int emm_proc_detach_request(unsigned int ueid, emm_proc_detach_type_t type,
esm_sap_t esm_sap;
esm_sap.primitive = ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ;
esm_sap.ueid = ueid;
esm_sap.ctx = emm_ctx;
esm_sap.data.eps_bearer_context_deactivate.ebi = ESM_SAP_ALL_EBI;
rc = esm_sap_send(&esm_sap);
......@@ -522,6 +523,7 @@ int emm_proc_detach_request(unsigned int ueid, emm_proc_detach_type_t type,
*/
emm_sap.primitive = EMMREG_DETACH_REQ;
emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
rc = emm_sap_send(&emm_sap);
}
}
......
......@@ -202,14 +202,26 @@ int lowerlayer_release(int cause)
***************************************************************************/
int lowerlayer_data_ind(unsigned int ueid, const OctetString *data)
{
LOG_FUNC_IN;
esm_sap_t esm_sap;
int rc;
#if defined(NAS_MME)
emm_data_context_t *emm_ctx;
#endif
LOG_FUNC_IN;
#if defined(NAS_MME)
if (ueid > 0) {
emm_ctx = emm_data_context_get(&_emm_data, ueid);
}
#endif
esm_sap.primitive = ESM_UNITDATA_IND;
esm_sap.is_standalone = TRUE;
esm_sap.ueid = ueid;
#if defined(NAS_MME)
esm_sap.ctx = emm_ctx;
#endif
esm_sap.recv = data;
rc = esm_sap_send(&esm_sap);
......
......@@ -28,6 +28,8 @@ Description Defines internal private data handled by EPS Mobility
#include "OctetString.h"
#include "nas_timer.h"
#include "esmData.h"
#ifdef NAS_MME
#include "emm_fsm.h"
#include "mme_api.h"
......@@ -348,6 +350,8 @@ typedef struct emm_data_context_s {
int emm_cause; /* EMM failure cause code */
emm_fsm_state_t _emm_fsm_status;
esm_data_context_t esm_data_ctx;
} emm_data_context_t;
/*
......
......@@ -1092,7 +1092,7 @@ static int _emm_as_send(const emm_as_t *msg)
LOG_FUNC_RETURN (RETURNok);
} break;
case AS_NAS_ESTABLISH_RSP: {
case AS_NAS_ESTABLISH_CNF: {
if (as_msg.msg.nas_establish_rsp.errCode != AS_SUCCESS) {
nas_itti_dl_data_req(as_msg.msg.nas_establish_rsp.UEid,
as_msg.msg.nas_establish_rsp.nasMsg.data,
......@@ -1100,6 +1100,11 @@ static int _emm_as_send(const emm_as_t *msg)
LOG_FUNC_RETURN (RETURNok);
} else {
/* Handle success case */
nas_itti_establish_cnf(as_msg.msg.nas_establish_rsp.UEid,
as_msg.msg.nas_establish_rsp.errCode,
as_msg.msg.nas_establish_rsp.nasMsg.data,
as_msg.msg.nas_establish_rsp.nasMsg.length);
LOG_FUNC_RETURN (RETURNok);
}
} break;
......@@ -1670,7 +1675,7 @@ static int _emm_as_establish_cnf(const emm_as_establish_t *msg,
LOG_FUNC_IN;
LOG_TRACE(INFO, "EMMAS-SAP - Send AS connection establish response");
LOG_TRACE(INFO, "EMMAS-SAP - Send AS connection establish confirmation");
nas_message_t nas_msg;
memset(&nas_msg, 0 , sizeof(nas_message_t));
......@@ -1678,6 +1683,7 @@ static int _emm_as_establish_cnf(const emm_as_establish_t *msg,
/* Setup the AS message */
as_msg->UEid = msg->ueid;
if (msg->UEid.guti == NULL) {
LOG_TRACE(WARNING, "EMMAS-SAP - GUTI is NULL...");
LOG_FUNC_RETURN (0);
}
as_msg->s_tmsi.MMEcode = msg->UEid.guti->gummei.MMEcode;
......@@ -1703,9 +1709,11 @@ static int _emm_as_establish_cnf(const emm_as_establish_t *msg,
int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size);
if (bytes > 0) {
as_msg->errCode = AS_SUCCESS;
LOG_FUNC_RETURN (AS_NAS_ESTABLISH_RSP);
LOG_FUNC_RETURN (AS_NAS_ESTABLISH_CNF);
}
}
LOG_TRACE(WARNING, "EMMAS-SAP - Size <= 0");
LOG_FUNC_RETURN (0);
}
......
......@@ -24,6 +24,7 @@ Description Defines the EMMESM Service Access Point that provides
#define __EMM_ESMDEF_H__
#include "OctetString.h"
#include "emmData.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
......@@ -76,6 +77,9 @@ typedef struct {
typedef struct {
emm_esm_primitive_t primitive;
unsigned int ueid;
#if defined(NAS_MME)
emm_data_context_t *ctx;
#endif
union {
emm_esm_establish_t establish;
emm_esm_data_t data;
......
......@@ -23,6 +23,7 @@ Description Defines the EMM Service Access Points at which the EPS
#ifndef __EMM_SAP_H__
#define __EMM_SAP_H__
#include "emmData.h"
#include "emm_regDef.h"
#include "emm_esmDef.h"
#include "emm_asDef.h"
......
......@@ -65,7 +65,7 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *);
* retransmission counter */
#define DEDICATED_EPS_BEARER_ACTIVATE_COUNTER_MAX 5
static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi,
static int _dedicated_eps_bearer_activate(emm_data_context_t *ctx, int ebi,
const OctetString *msg);
#endif // NAS_MME
......@@ -102,7 +102,7 @@ static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi,
** Others: None **
** **
***************************************************************************/
int esm_proc_dedicated_eps_bearer_context(unsigned int ueid, int pid,
int esm_proc_dedicated_eps_bearer_context(emm_data_context_t *ctx, int pid,
unsigned int *ebi,
unsigned int *default_ebi,
const esm_proc_qos_t *qos,
......@@ -112,14 +112,14 @@ int esm_proc_dedicated_eps_bearer_context(unsigned int ueid, int pid,
LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - Dedicated EPS bearer context activation "
"(ueid=%u, pid=%d)", ueid, pid);
"(ueid=%u, pid=%d)", ctx->ueid, pid);
/* Assign new EPS bearer context */
*ebi = esm_ebr_assign(ueid, ESM_EBI_UNASSIGNED);
*ebi = esm_ebr_assign(ctx, ESM_EBI_UNASSIGNED);
if (*ebi != ESM_EBI_UNASSIGNED) {
/* Create dedicated EPS bearer context */
*default_ebi = esm_ebr_context_create(ueid, pid, *ebi, FALSE, qos, tft);
*default_ebi = esm_ebr_context_create(ctx, pid, *ebi, FALSE, qos, tft);
if (*default_ebi == ESM_EBI_UNASSIGNED) {
/* No resource available */
LOG_TRACE(WARNING, "ESM-PROC - Failed to create dedicated EPS "
......@@ -162,7 +162,7 @@ int esm_proc_dedicated_eps_bearer_context(unsigned int ueid, int pid,
** **
***************************************************************************/
int esm_proc_dedicated_eps_bearer_context_request(int is_standalone,
unsigned int ueid, int ebi,
emm_data_context_t *ctx, int ebi,
OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -170,15 +170,15 @@ int esm_proc_dedicated_eps_bearer_context_request(int is_standalone,
int rc = RETURNok;
LOG_TRACE(INFO,"ESM-PROC - Initiate dedicated EPS bearer context "
"activation (ueid=%d, ebi=%d)", ueid, ebi);
"activation (ueid=%d, ebi=%d)", ctx->ueid, ebi);
/* Send activate dedicated EPS bearer context request message and
* start timer T3485 */
rc = _dedicated_eps_bearer_activate(ueid, ebi, msg);
rc = _dedicated_eps_bearer_activate(ctx, ebi, msg);
if (rc != RETURNerror) {
/* Set the EPS bearer context state to ACTIVE PENDING */
rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE_PENDING, ue_triggered);
rc = esm_ebr_set_status(ctx, ebi, ESM_EBR_ACTIVE_PENDING, ue_triggered);
if (rc != RETURNok) {
/* The EPS bearer context was already in ACTIVE PENDING state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE PENDING",
......@@ -211,7 +211,7 @@ int esm_proc_dedicated_eps_bearer_context_request(int is_standalone,
** Others: None **
** **
***************************************************************************/
int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi,
int esm_proc_dedicated_eps_bearer_context_accept(emm_data_context_t *ctx, int ebi,
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -219,13 +219,13 @@ int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi,
int rc;
LOG_TRACE(INFO, "ESM-PROC - Dedicated EPS bearer context activation "
"accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi);
"accepted by the UE (ueid=%u, ebi=%d)", ctx->ueid, ebi);
/* Stop T3485 timer */
rc = esm_ebr_stop_timer(ueid, ebi);
rc = esm_ebr_stop_timer(ctx, ebi);
if (rc != RETURNerror) {
/* Set the EPS bearer context state to ACTIVE */
rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE, FALSE);
rc = esm_ebr_set_status(ctx, ebi, ESM_EBR_ACTIVE, FALSE);
if (rc != RETURNok) {
/* The EPS bearer context was already in ACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi);
......@@ -262,22 +262,22 @@ int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi,
** Others: None **
** **
***************************************************************************/
int esm_proc_dedicated_eps_bearer_context_reject(unsigned int ueid, int ebi,
int esm_proc_dedicated_eps_bearer_context_reject(emm_data_context_t *ctx, int ebi,
int *esm_cause)
{
LOG_FUNC_IN;
int rc;
LOG_FUNC_IN;
LOG_TRACE(WARNING, "ESM-PROC - Dedicated EPS bearer context activation "
"not accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi);
"not accepted by the UE (ueid=%u, ebi=%d)", ctx->ueid, ebi);
/* Stop T3485 timer if running */
rc = esm_ebr_stop_timer(ueid, ebi);
rc = esm_ebr_stop_timer(ctx, ebi);
if (rc != RETURNerror) {
int pid, bid;
/* Release the dedicated EPS bearer context and enter state INACTIVE */
rc = esm_proc_eps_bearer_context_deactivate(ueid, TRUE, ebi,
rc = esm_proc_eps_bearer_context_deactivate(ctx, TRUE, ebi,
&pid, &bid, NULL);
if (rc != RETURNok) {
/* Failed to release the dedicated EPS bearer context */
......@@ -558,7 +558,7 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *args)
if (data->count < DEDICATED_EPS_BEARER_ACTIVATE_COUNTER_MAX) {
/* Re-send activate dedicated EPS bearer context request message
* to the UE */
rc = _dedicated_eps_bearer_activate(data->ueid, data->ebi, &data->msg);
rc = _dedicated_eps_bearer_activate(data->ctx, data->ebi, &data->msg);
} else {
/*
* The maximum number of activate dedicated EPS bearer context request
......@@ -566,12 +566,12 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *args)
*/
int pid, bid;
/* Release the dedicated EPS bearer context and enter state INACTIVE */
rc = esm_proc_eps_bearer_context_deactivate(data->ueid, TRUE,
rc = esm_proc_eps_bearer_context_deactivate(data->ctx, TRUE,
data->ebi, &pid, &bid,
NULL);
if (rc != RETURNerror) {
/* Stop timer T3485 */
rc = esm_ebr_stop_timer(data->ueid, data->ebi);
rc = esm_ebr_stop_timer(data->ctx, data->ebi);
}
}
......@@ -601,7 +601,7 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *args)
** Others: T3485 **
** **
***************************************************************************/
static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi,
static int _dedicated_eps_bearer_activate(emm_data_context_t *ctx, int ebi,
const OctetString *msg)
{
LOG_FUNC_IN;
......@@ -615,13 +615,14 @@ static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi,
*/
emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data;
emm_sap.primitive = EMMESM_UNITDATA_REQ;
emm_sap.u.emm_esm.ueid = ueid;
emm_sap.u.emm_esm.ueid = ctx->ueid;
emm_sap.u.emm_esm.ctx = ctx;
emm_esm->msg = *msg;
rc = emm_sap_send(&emm_sap);
if (rc != RETURNerror) {
/* Start T3485 retransmission timer */
rc = esm_ebr_start_timer(ueid, ebi, msg, T3485_DEFAULT_VALUE,
rc = esm_ebr_start_timer(ctx, ebi, msg, T3485_DEFAULT_VALUE,
_dedicated_eps_bearer_activate_t3485_handler);
}
......
......@@ -75,7 +75,7 @@ static void *_default_eps_bearer_activate_t3485_handler(void *);
* retransmission counter */
#define DEFAULT_EPS_BEARER_ACTIVATE_COUNTER_MAX 5
static int _default_eps_bearer_activate(unsigned int ueid, int ebi,
static int _default_eps_bearer_activate(emm_data_context_t *ctx, int ebi,
const OctetString *msg);
#endif // NAS_MME
......@@ -109,7 +109,7 @@ static int _default_eps_bearer_activate(unsigned int ueid, int ebi,
** Others: None **
** **
***************************************************************************/
int esm_proc_default_eps_bearer_context(unsigned int ueid, int pid,
int esm_proc_default_eps_bearer_context(emm_data_context_t *ctx, int pid,
unsigned int *ebi,
const esm_proc_qos_t *qos,
int *esm_cause)
......@@ -117,14 +117,14 @@ int esm_proc_default_eps_bearer_context(unsigned int ueid, int pid,
LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - Default EPS bearer context activation "
"(ueid=%u, pid=%d)", ueid, pid);
"(ueid=%u, pid=%d)", ctx->ueid, pid);
/* Assign new EPS bearer context */
*ebi = esm_ebr_assign(ueid, ESM_EBI_UNASSIGNED);
*ebi = esm_ebr_assign(ctx, ESM_EBI_UNASSIGNED);
if (*ebi != ESM_EBI_UNASSIGNED) {
/* Create default EPS bearer context */
*ebi = esm_ebr_context_create(ueid, pid, *ebi, TRUE, qos, NULL);
*ebi = esm_ebr_context_create(ctx, pid, *ebi, TRUE, qos, NULL);
if (*ebi == ESM_EBI_UNASSIGNED) {
/* No resource available */
LOG_TRACE(WARNING, "ESM-PROC - Failed to create new default EPS "
......@@ -170,25 +170,25 @@ int esm_proc_default_eps_bearer_context(unsigned int ueid, int pid,
** **
***************************************************************************/
int esm_proc_default_eps_bearer_context_request(int is_standalone,
unsigned int ueid, int ebi,
emm_data_context_t *ctx, int ebi,
OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
int rc = RETURNok;
LOG_FUNC_IN;
LOG_TRACE(INFO,"ESM-PROC - Initiate default EPS bearer context activation "
"(ueid=%d, ebi=%d)", ueid, ebi);
"(ueid=%u, ebi=%d)", ctx->ueid, ebi);
if (is_standalone) {
/* Send activate default EPS bearer context request message and
* start timer T3485 */
rc = _default_eps_bearer_activate(ueid, ebi, msg);
rc = _default_eps_bearer_activate(ctx, ebi, msg);
}
if (rc != RETURNerror) {
/* Set the EPS bearer context state to ACTIVE PENDING */
rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE_PENDING, ue_triggered);
rc = esm_ebr_set_status(ctx, ebi, ESM_EBR_ACTIVE_PENDING, ue_triggered);
if (rc != RETURNok) {
/* The EPS bearer context was already in ACTIVE PENDING state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE PENDING",
......@@ -221,7 +221,7 @@ int esm_proc_default_eps_bearer_context_request(int is_standalone,
** Others: None **
** **
***************************************************************************/
int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi,
int esm_proc_default_eps_bearer_context_accept(emm_data_context_t *ctx, int ebi,
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -229,13 +229,13 @@ int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi,
int rc;
LOG_TRACE(INFO, "ESM-PROC - Default EPS bearer context activation "
"accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi);
"accepted by the UE (ueid=%u, ebi=%d)", ctx->ueid, ebi);
/* Stop T3485 timer if running */
rc = esm_ebr_stop_timer(ueid, ebi);
rc = esm_ebr_stop_timer(ctx, ebi);
if (rc != RETURNerror) {
/* Set the EPS bearer context state to ACTIVE */
rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_ACTIVE, FALSE);
rc = esm_ebr_set_status(ctx, ebi, ESM_EBR_ACTIVE, FALSE);
if (rc != RETURNok) {
/* The EPS bearer context was already in ACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi);
......@@ -268,7 +268,7 @@ int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi,
** Others: None **
** **
***************************************************************************/
int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi,
int esm_proc_default_eps_bearer_context_reject(emm_data_context_t *ctx, int ebi,
int *esm_cause)
{
LOG_FUNC_IN;
......@@ -276,14 +276,14 @@ int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi,
int rc;
LOG_TRACE(WARNING, "ESM-PROC - Default EPS bearer context activation "
"not accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi);
"not accepted by the UE (ueid=%u, ebi=%d)", ctx->ueid, ebi);
/* Stop T3485 timer if running */
rc = esm_ebr_stop_timer(ueid, ebi);
rc = esm_ebr_stop_timer(ctx, ebi);
if (rc != RETURNerror) {
int pid, bid;
/* Release the default EPS bearer context and enter state INACTIVE */
rc = esm_proc_eps_bearer_context_deactivate(ueid, TRUE, ebi,
rc = esm_proc_eps_bearer_context_deactivate(ctx, TRUE, ebi,
&pid, &bid, NULL);
if (rc != RETURNok) {
/* Failed to release the default EPS bearer context */
......@@ -318,23 +318,23 @@ int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi,
** Others: None **
** **
***************************************************************************/
int esm_proc_default_eps_bearer_context_failure(unsigned int ueid)
int esm_proc_default_eps_bearer_context_failure(emm_data_context_t *ctx)
{
LOG_FUNC_IN;
int rc = RETURNerror;
int pid;
LOG_FUNC_IN;
LOG_TRACE(WARNING, "ESM-PROC - Default EPS bearer context activation "
"failure (ueid=%u)", ueid);
"failure (ueid=%u)", ctx->ueid);
/* Get the EPS bearer identity of the EPS bearer context which is still
* pending in the active pending state */
int ebi = esm_ebr_get_pending_ebi(ueid, ESM_EBR_ACTIVE_PENDING);
int ebi = esm_ebr_get_pending_ebi(ctx, ESM_EBR_ACTIVE_PENDING);
if (ebi != ESM_EBI_UNASSIGNED) {
int bid;
/* Release the default EPS bearer context and enter state INACTIVE */
rc = esm_proc_eps_bearer_context_deactivate(ueid, TRUE, ebi,
rc = esm_proc_eps_bearer_context_deactivate(ctx, TRUE, ebi,
&pid, &bid, NULL);
}
......@@ -680,7 +680,7 @@ static void *_default_eps_bearer_activate_t3485_handler(void *args)
if (data->count < DEFAULT_EPS_BEARER_ACTIVATE_COUNTER_MAX) {
/* Re-send activate default EPS bearer context request message
* to the UE */
rc = _default_eps_bearer_activate(data->ueid, data->ebi, &data->msg);
rc = _default_eps_bearer_activate(data->ctx, data->ebi, &data->msg);
} else {
/*
* The maximum number of activate default EPS bearer context request
......@@ -688,12 +688,12 @@ static void *_default_eps_bearer_activate_t3485_handler(void *args)
*/
int pid, bid;
/* Release the default EPS bearer context and enter state INACTIVE */
rc = esm_proc_eps_bearer_context_deactivate(data->ueid, TRUE,
rc = esm_proc_eps_bearer_context_deactivate(data->ctx, TRUE,
data->ebi, &pid, &bid,
NULL);
if (rc != RETURNerror) {
/* Stop timer T3485 */
rc = esm_ebr_stop_timer(data->ueid, data->ebi);
rc = esm_ebr_stop_timer(data->ctx, data->ebi);
}
}
......@@ -723,7 +723,7 @@ static void *_default_eps_bearer_activate_t3485_handler(void *args)
** Others: T3485 **
** **
***************************************************************************/
static int _default_eps_bearer_activate(unsigned int ueid, int ebi,
static int _default_eps_bearer_activate(emm_data_context_t *ctx, int ebi,
const OctetString *msg)
{
LOG_FUNC_IN;
......@@ -737,13 +737,14 @@ static int _default_eps_bearer_activate(unsigned int ueid, int ebi,
*/
emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data;
emm_sap.primitive = EMMESM_UNITDATA_REQ;
emm_sap.u.emm_esm.ueid = ueid;
emm_sap.u.emm_esm.ueid = ctx->ueid;
emm_sap.u.emm_esm.ctx = ctx;
emm_esm->msg = *msg;
rc = emm_sap_send(&emm_sap);
if (rc != RETURNerror) {
/* Start T3485 retransmission timer */
rc = esm_ebr_start_timer(ueid, ebi, msg, T3485_DEFAULT_VALUE,
rc = esm_ebr_start_timer(ctx, ebi, msg, T3485_DEFAULT_VALUE,
_default_eps_bearer_activate_t3485_handler);
}
......
......@@ -73,7 +73,7 @@ Description Defines the ESM status procedure executed by the Non-Access
***************************************************************************/
int esm_proc_status_ind(
#ifdef NAS_MME
unsigned int ueid,
emm_data_context_t *ctx,
#endif
int pti, int ebi, int *esm_cause)
{
......@@ -148,7 +148,7 @@ int esm_proc_status_ind(
***************************************************************************/
int esm_proc_status(int is_standalone,
#ifdef NAS_MME
unsigned int ueid,
emm_data_context_t *ctx,
#endif
int ebi, OctetString *msg,
int ue_triggered)
......@@ -168,7 +168,8 @@ int esm_proc_status(int is_standalone,
emm_sap.u.emm_esm.ueid = 0;
#endif
#ifdef NAS_MME
emm_sap.u.emm_esm.ueid = ueid;
emm_sap.u.emm_esm.ueid = ctx->ueid;
emm_sap.u.emm_esm.ctx = ctx;
#endif
emm_sap.u.emm_esm.u.data.msg.length = msg->length;
emm_sap.u.emm_esm.u.data.msg.value = msg->value;
......
......@@ -44,7 +44,7 @@ Description Defines the PDN disconnect ESM procedure executed by the
/****************************************************************************/
#ifdef NAS_MME
extern int _pdn_connectivity_delete(unsigned int ueid, int pid);
extern int _pdn_connectivity_delete(emm_data_context_t *ctx, int pid);
#endif
/****************************************************************************/
......@@ -81,7 +81,7 @@ static void *_pdn_disconnect_t3492_handler(void *);
/*
* PDN disconnection handlers
*/
static int _pdn_disconnect_get_pid(unsigned int ueid, int pti);
static int _pdn_disconnect_get_pid(esm_data_context_t *ctx, int pti);
#endif // NAS_MME
......@@ -368,36 +368,30 @@ int esm_proc_pdn_disconnect_reject(int pti, int *esm_cause)
** Others: None **
** **
***************************************************************************/
int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int *esm_cause)
int esm_proc_pdn_disconnect_request(emm_data_context_t *ctx, int pti, int *esm_cause)
{
LOG_FUNC_IN;
int pid = RETURNerror;
LOG_TRACE(INFO, "ESM-PROC - PDN disconnect requested by the UE "
"(ueid=%d, pti=%d)", ueid, pti);
LOG_FUNC_IN;
if (ueid < ESM_DATA_NB_UE_MAX) {
/* Get UE's ESM context */
esm_data_context_t *ctx = _esm_data.ctx[ueid];
if (_esm_data.ctx[ueid] == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - No ESM context exists");
LOG_TRACE(INFO, "ESM-PROC - PDN disconnect requested by the UE "
"(ueid=%d, pti=%d)", ctx->ueid, pti);
/* Get UE's ESM context */
if (ctx->esm_data_ctx.n_pdns > 1) {
/* Get the identifier of the PDN connection entry assigned to the
* procedure transaction identity */
pid = _pdn_disconnect_get_pid(&ctx->esm_data_ctx, pti);
if (pid < 0) {
LOG_TRACE(ERROR, "ESM-PROC - No PDN connection found (pti=%d)",
pti);
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
} else if (ctx->n_pdns > 1) {
/* Get the identifier of the PDN connection entry assigned to the
* procedure transaction identity */
pid = _pdn_disconnect_get_pid(ueid, pti);
if (pid < 0) {
LOG_TRACE(ERROR, "ESM-PROC - No PDN connection found (pti=%d)",
pti);
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
LOG_FUNC_RETURN (RETURNerror);
}
} else {
/* Attempt to disconnect from the last PDN disconnection
* is not allowed */
*esm_cause = ESM_CAUSE_LAST_PDN_DISCONNECTION_NOT_ALLOWED;
LOG_FUNC_RETURN (RETURNerror);
}
} else {
/* Attempt to disconnect from the last PDN disconnection
* is not allowed */
*esm_cause = ESM_CAUSE_LAST_PDN_DISCONNECTION_NOT_ALLOWED;
}
LOG_FUNC_RETURN(pid);
......@@ -425,18 +419,18 @@ int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int *esm_cause)
** Others: None **
** **
***************************************************************************/
int esm_proc_pdn_disconnect_accept(unsigned int ueid, int pid, int *esm_cause)
int esm_proc_pdn_disconnect_accept(emm_data_context_t *ctx, int pid, int *esm_cause)
{
LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - PDN disconnect accepted by the UE "
"(ueid=%d, pid=%d)", ueid, pid);
"(ueid=%d, pid=%d)", ctx->ueid, pid);
/* Release the connectivity with the requested PDN */
int rc = mme_api_unsubscribe(NULL);
if (rc != RETURNerror) {
/* Delete the PDN connection entry */
int pti = _pdn_connectivity_delete(ueid, pid);
int pti = _pdn_connectivity_delete(ctx, pid);
if (pti != ESM_PT_UNASSIGNED) {
LOG_FUNC_RETURN (RETURNok);
}
......@@ -470,7 +464,7 @@ int esm_proc_pdn_disconnect_accept(unsigned int ueid, int pid, int *esm_cause)
** Others: None **
** **
***************************************************************************/
int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid,
int esm_proc_pdn_disconnect_reject(int is_standalone, emm_data_context_t *ctx,
int ebi, OctetString *msg, int ue_triggered)
{
LOG_FUNC_IN;
......@@ -479,13 +473,14 @@ int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid,
emm_sap_t emm_sap;
LOG_TRACE(WARNING, "ESM-PROC - PDN disconnect not accepted by the network "
"(ueid=%d)", ueid);
"(ueid=%d)", ctx->ueid);
/*
* Notity EMM that ESM PDU has to be forwarded to lower layers
*/
emm_sap.primitive = EMMESM_UNITDATA_REQ;
emm_sap.u.emm_esm.ueid = ueid;
emm_sap.u.emm_esm.ueid = ctx->ueid;
emm_sap.u.emm_esm.ctx = ctx;
emm_sap.u.emm_esm.u.data.msg.length = msg->length;
emm_sap.u.emm_esm.u.data.msg.value = msg->value;
rc = emm_sap_send(&emm_sap);
......@@ -670,15 +665,15 @@ static int _pdn_disconnect_get_default_ebi(int pti)
** Others: None **
** **
***************************************************************************/
static int _pdn_disconnect_get_pid(unsigned int ueid, int pti)
static int _pdn_disconnect_get_pid(esm_data_context_t *ctx, int pti)
{
int i = ESM_DATA_PDN_MAX;
if ( (ueid < ESM_DATA_NB_UE_MAX) && (_esm_data.ctx[ueid] != NULL) ) {
if (ctx != NULL) {
for (i = 0; i < ESM_DATA_PDN_MAX; i++) {
if ( (_esm_data.ctx[ueid]->pdn[i].pid != -1) &&
(_esm_data.ctx[ueid]->pdn[i].data != NULL) ) {
if (_esm_data.ctx[ueid]->pdn[i].data->pti != pti) {
if ( (ctx->pdn[i].pid != -1) &&
(ctx->pdn[i].data != NULL) ) {
if (ctx->pdn[i].data->pti != pti) {
continue;
}
/* PDN entry found */
......@@ -688,6 +683,6 @@ static int _pdn_disconnect_get_pid(unsigned int ueid, int pti)
}
/* Return the identifier of the PDN connection */
return (_esm_data.ctx[ueid]->pdn[i].pid);
return (ctx->pdn[i].pid);
}
#endif // NAS_MME
......@@ -18,17 +18,22 @@ Description Defines internal private data handled by EPS Session
Management sublayer.
*****************************************************************************/
#ifndef __ESMDATA_H__
#define __ESMDATA_H__
#include <stdio.h> // sprintf
#include "networkDef.h"
#include "OctetString.h"
#include "EpsBearerIdentity.h"
#ifdef NAS_MME
#include "mme_api.h"
#endif
#include <stdio.h> // sprintf
#if defined(EPC_BUILD)
# include "tree.h"
#endif
#ifndef __ESMDATA_H__
#define __ESMDATA_H__
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
......@@ -41,6 +46,67 @@ Description Defines internal private data handled by EPS Session
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/*
* Minimal and maximal value of an EPS bearer identity:
* The EPS Bearer Identity (EBI) identifies a message flow
*/
#define ESM_EBI_MIN (EPS_BEARER_IDENTITY_FIRST)
#define ESM_EBI_MAX (EPS_BEARER_IDENTITY_LAST)
/* EPS bearer context states */
typedef enum {
ESM_EBR_INACTIVE, /* No EPS bearer context exists */
ESM_EBR_ACTIVE, /* The EPS bearer context is active,
* in the UE, in the network */
#ifdef NAS_MME
ESM_EBR_INACTIVE_PENDING, /* The network has initiated an EPS bearer
* context deactivation towards the UE */
ESM_EBR_MODIFY_PENDING, /* The network has initiated an EPS bearer
* context modification towards the UE */
ESM_EBR_ACTIVE_PENDING, /* The network has initiated an EPS bearer
* context activation towards the UE */
#endif
ESM_EBR_STATE_MAX
} esm_ebr_state;
#ifdef NAS_MME
/* ESM message timer retransmission data */
typedef struct {
void *ctx;
unsigned int ueid; /* Lower layers UE identifier */
unsigned int ebi; /* EPS bearer identity */
unsigned int count; /* Retransmission counter */
OctetString msg; /* Encoded ESM message to re-transmit */
} esm_ebr_timer_data_t;
#endif
/*
* -----------------------
* EPS bearer context data
* -----------------------
*/
typedef struct {
unsigned char ebi; /* EPS bearer identity */
esm_ebr_state status; /* EPS bearer context status */
#ifdef NAS_UE
int is_default_ebr; /* TRUE if the bearer context is associated
* to a default EPS bearer */
char cid; /* Identifier of the PDN context the EPS
* bearer context has been assigned to */
#endif
#ifdef NAS_MME
struct nas_timer_t timer; /* Retransmission timer */
esm_ebr_timer_data_t *args; /* Retransmission timer parameters data */
#endif
} esm_ebr_context_t;
typedef struct {
unsigned char index; /* Index of the next EPS bearer context
* identity to be used */
#define ESM_EBR_DATA_SIZE (ESM_EBI_MAX - ESM_EBI_MIN + 1)
esm_ebr_context_t *context[ESM_EBR_DATA_SIZE + 1];
} esm_ebr_data_t;
/*
* --------------------------------------------------------------------------
* Structure of data handled by EPS Session Management sublayer in the UE
......@@ -101,7 +167,9 @@ typedef struct {
* fault EPS bearer. Several dedicated EPS bearers may exist within
* a PDN connection.
*/
typedef struct {
typedef struct esm_data_context_s {
unsigned int ue_id;
int n_ebrs; /* Total number of active EPS bearer contexts */
int n_pdns; /* Number of active PDN connections */
int emergency; /* Indicates whether a PDN connection for emergency
......@@ -114,6 +182,8 @@ typedef struct {
* connection is in progress */
esm_pdn_t *data; /* Active PDN connection data */
} pdn[ESM_DATA_PDN_MAX+1];
esm_ebr_data_t ebr;
} esm_data_context_t;
/*
......@@ -149,11 +219,26 @@ typedef struct {
* ESM contexts
* ------------
*/
#define ESM_DATA_NB_UE_MAX (MME_API_NB_UE_MAX + 1)
# if defined(EPC_BUILD)
/* Use a tree for ue data context within MME */
RB_HEAD(esm_data_context_map, esm_data_context_s) ctx_map;
# else
# define ESM_DATA_NB_UE_MAX (MME_API_NB_UE_MAX + 1)
esm_data_context_t *ctx[ESM_DATA_NB_UE_MAX];
# endif
} esm_data_t;
# if defined(EPC_BUILD)
struct esm_data_context_s *esm_data_context_get(
esm_data_t *esm_data, unsigned int _ueid);
struct esm_data_context_s *esm_data_context_remove(
esm_data_t *esm_data, struct esm_data_context_s *elm);
void esm_data_context_add(esm_data_t *esm_data, struct esm_data_context_s *elm);
# endif
#endif //NAS_MME
/****************************************************************************/
......
......@@ -28,7 +28,6 @@ Description Defines functions used to handle state of EPS bearer contexts
#endif
#include "nas_timer.h"
#include "EpsBearerIdentity.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
......@@ -41,32 +40,6 @@ Description Defines functions used to handle state of EPS bearer contexts
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/* EPS bearer context states */
typedef enum {
ESM_EBR_INACTIVE, /* No EPS bearer context exists */
ESM_EBR_ACTIVE, /* The EPS bearer context is active,
* in the UE, in the network */
#ifdef NAS_MME
ESM_EBR_INACTIVE_PENDING, /* The network has initiated an EPS bearer
* context deactivation towards the UE */
ESM_EBR_MODIFY_PENDING, /* The network has initiated an EPS bearer
* context modification towards the UE */
ESM_EBR_ACTIVE_PENDING, /* The network has initiated an EPS bearer
* context activation towards the UE */
#endif
ESM_EBR_STATE_MAX
} esm_ebr_state;
#ifdef NAS_MME
/* ESM message timer retransmission data */
typedef struct {
unsigned int ueid; /* Lower layers UE identifier */
unsigned int ebi; /* EPS bearer identity */
unsigned int count; /* Retransmission counter */
OctetString msg; /* Encoded ESM message to re-transmit */
} esm_ebr_timer_data_t;
#endif
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
......@@ -90,20 +63,20 @@ int esm_ebr_is_not_in_use(int ebi);
#ifdef NAS_MME
void esm_ebr_initialize(void);
int esm_ebr_assign(unsigned int ueid, int ebi);
int esm_ebr_release(unsigned int ueid, int ebi);
int esm_ebr_assign(emm_data_context_t *ctx, int ebi);
int esm_ebr_release(emm_data_context_t *ctx, int ebi);
int esm_ebr_start_timer(unsigned int ueid, int ebi, const OctetString *msg,
int esm_ebr_start_timer(emm_data_context_t *ctx, int ebi, const OctetString *msg,
long sec, nas_timer_callback_t cb);
int esm_ebr_stop_timer(unsigned int ueid, int ebi);
int esm_ebr_stop_timer(emm_data_context_t *ctx, int ebi);
int esm_ebr_get_pending_ebi(unsigned int ueid, esm_ebr_state status);
int esm_ebr_get_pending_ebi(emm_data_context_t *ctx, esm_ebr_state status);
int esm_ebr_set_status(unsigned int ueid, int ebi, esm_ebr_state status,
int esm_ebr_set_status(emm_data_context_t *ctx, int ebi, esm_ebr_state status,
int ue_requested);
esm_ebr_state esm_ebr_get_status(unsigned int ueid, int ebi);
esm_ebr_state esm_ebr_get_status(emm_data_context_t *ctx, int ebi);
int esm_ebr_is_not_in_use(unsigned int ueid, int ebi);
int esm_ebr_is_not_in_use(emm_data_context_t *ctx, int ebi);
#endif
#endif /* __ESM_EBR_H__*/
......@@ -17,18 +17,22 @@ Author Frederic Maurel
Description Defines functions used to handle EPS bearer contexts.
*****************************************************************************/
#include <stdlib.h> // malloc, free
#include <string.h> // memset
#include "esm_ebr_context.h"
#include "commonDef.h"
#include "nas_log.h"
#include "esmData.h"
#include "emmData.h"
#include "esm_ebr.h"
#include "esm_ebr_context.h"
#include "emm_sap.h"
#include <stdlib.h> // malloc, free
#include <string.h> // memset
#if defined(ENABLE_ITTI)
# include "assertions.h"
#endif
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
......@@ -75,48 +79,53 @@ static int _esm_ebr_context_check_precedence(const network_tft_t *,
***************************************************************************/
int esm_ebr_context_create(
#ifdef NAS_MME
unsigned int ueid,
emm_data_context_t *ctx,
#endif
int pid, int ebi, int is_default,
const network_qos_t *qos, const network_tft_t *tft)
{
LOG_FUNC_IN;
int bid;
esm_data_context_t *esm_ctx;
esm_pdn_t *pdn = NULL;
esm_data_context_t *ctx;
LOG_FUNC_IN;
#ifdef NAS_UE
ctx = &_esm_data;
esm_ctx = &_esm_data;
#endif
#ifdef NAS_MME
# if defined(EPC_BUILD)
esm_ctx = &ctx->esm_data_ctx;
# else
if (ueid < ESM_DATA_NB_UE_MAX) {
ctx = _esm_data.ctx[ueid];
} else {
LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED);
}
# endif
#endif
int bid = ESM_DATA_EPS_BEARER_MAX;
esm_pdn_t *pdn = NULL;
bid = ESM_DATA_EPS_BEARER_MAX;
LOG_TRACE(INFO, "ESM-PROC - Create new %s EPS bearer context (ebi=%d) "
"for PDN connection (pid=%d)",
(is_default)? "default" : "dedicated", ebi, pid);
if (pid < ESM_DATA_PDN_MAX) {
if (pid != ctx->pdn[pid].pid) {
if (pid != esm_ctx->pdn[pid].pid) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier %d is "
"not valid", pid);
} else if (ctx->pdn[pid].data == NULL) {
} else if (esm_ctx->pdn[pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been "
"allocated", pid);
}
/* Check the total number of active EPS bearers */
else if (ctx->n_ebrs > ESM_DATA_EPS_BEARER_TOTAL) {
else if (esm_ctx->n_ebrs > ESM_DATA_EPS_BEARER_TOTAL) {
LOG_TRACE(WARNING, "ESM-PROC - The total number of active EPS"
"bearers is exeeded");
} else {
/* Get the PDN connection entry */
pdn = ctx->pdn[pid].data;
pdn = esm_ctx->pdn[pid].data;
if (is_default) {
/* Default EPS bearer entry is defined at index 0 */
bid = 0;
......@@ -143,7 +152,7 @@ int esm_ebr_context_create(
if (ebr != NULL) {
memset(ebr, 0 , sizeof(esm_bearer_t));
/* Increment the total number of active EPS bearers */
ctx->n_ebrs += 1;
esm_ctx->n_ebrs += 1;
/* Increment the number of EPS bearer for this PDN connection */
pdn->n_bearers += 1;
/* Setup the EPS bearer data */
......@@ -169,10 +178,10 @@ int esm_ebr_context_create(
if (is_default) {
/* Set the PDN connection activation indicator */
ctx->pdn[pid].is_active = TRUE;
esm_ctx->pdn[pid].is_active = TRUE;
/* Update the emergency bearer services indicator */
if (pdn->is_emergency) {
ctx->emergency = TRUE;
esm_ctx->emergency = TRUE;
}
}
......@@ -210,28 +219,32 @@ int esm_ebr_context_create(
***************************************************************************/
int esm_ebr_context_release(
#ifdef NAS_MME
unsigned int ueid,
emm_data_context_t *ctx,
#endif
int ebi, int *pid, int *bid)
{
LOG_FUNC_IN;
int found = FALSE;
esm_pdn_t *pdn = NULL;
esm_data_context_t *esm_ctx;
esm_data_context_t *ctx;
LOG_FUNC_IN;
#ifdef NAS_UE
ctx = &_esm_data;
esm_ctx = &_esm_data;
#endif
#ifdef NAS_MME
# if defined(EPC_BUILD)
esm_ctx = &ctx->esm_data_ctx;
# else
if (ueid < ESM_DATA_NB_UE_MAX) {
ctx = _esm_data.ctx[ueid];
ctx = &_esm_data.ctx[ueid];
} else {
LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED);
}
# endif
#endif
int found = FALSE;
esm_pdn_t *pdn = NULL;
if (ebi != ESM_EBI_UNASSIGNED) {
/*
* The identity of the EPS bearer to released is given;
......@@ -241,12 +254,12 @@ int esm_ebr_context_release(
/* Search for active PDN connection */
for (*pid = 0; *pid < ESM_DATA_PDN_MAX; (*pid)++) {
if ( !ctx->pdn[*pid].is_active ) {
if ( !esm_ctx->pdn[*pid].is_active ) {
continue;
}
/* An active PDN connection is found */
if (ctx->pdn[*pid].data != NULL) {
pdn = ctx->pdn[*pid].data;
if (esm_ctx->pdn[*pid].data != NULL) {
pdn = esm_ctx->pdn[*pid].data;
/* Search for the specified EPS bearer context entry */
for (*bid = 0; *bid < pdn->n_bearers; (*bid)++) {
if (pdn->bearer[*bid] != NULL) {
......@@ -273,17 +286,17 @@ int esm_ebr_context_release(
* first EPS bearer context entry at index bid = 0
*/
if (*pid < ESM_DATA_PDN_MAX) {
if (*pid != ctx->pdn[*pid].pid) {
if (*pid != esm_ctx->pdn[*pid].pid) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier %d "
"is not valid", *pid);
} else if (!ctx->pdn[*pid].is_active) {
} else if (!esm_ctx->pdn[*pid].is_active) {
LOG_TRACE(WARNING,"ESM-PROC - PDN connection %d is not active",
*pid);
} else if (ctx->pdn[*pid].data == NULL) {
} else if (esm_ctx->pdn[*pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been "
"allocated", *pid);
} else {
pdn = ctx->pdn[*pid].data;
pdn = esm_ctx->pdn[*pid].data;
if (pdn->bearer[*bid] != NULL) {
ebi = pdn->bearer[*bid]->ebi;
found = TRUE;
......@@ -317,7 +330,7 @@ int esm_ebr_context_release(
* to the PDN connection */
pdn->n_bearers -= 1;
/* Decrement the total number of active EPS bearers */
ctx->n_ebrs -= 1;
esm_ctx->n_ebrs -= 1;
if (*bid == 0) {
/* 3GPP TS 24.301, section 6.4.4.3, 6.4.4.6
......@@ -341,7 +354,7 @@ int esm_ebr_context_release(
ESM_EBR_INACTIVE, TRUE);
#endif
#ifdef NAS_MME
(void) esm_ebr_set_status(ueid, pdn->bearer[i]->ebi,
(void) esm_ebr_set_status(ctx, pdn->bearer[i]->ebi,
ESM_EBR_INACTIVE, TRUE);
#endif
/* Release EPS bearer data */
......@@ -349,7 +362,7 @@ int esm_ebr_context_release(
(void) esm_ebr_release(pdn->bearer[i]->ebi);
#endif
#ifdef NAS_MME
(void) esm_ebr_release(ueid, pdn->bearer[i]->ebi);
(void) esm_ebr_release(ctx, pdn->bearer[i]->ebi);
#endif
// esm_ebr_release()
/* Release dedicated EPS bearer data */
......@@ -359,14 +372,14 @@ int esm_ebr_context_release(
* to the PDN connection */
pdn->n_bearers -= 1;
/* Decrement the total number of active EPS bearers */
ctx->n_ebrs -= 1;
esm_ctx->n_ebrs -= 1;
}
}
/* Reset the PDN connection activation indicator */
ctx->pdn[*pid].is_active = FALSE;
esm_ctx->pdn[*pid].is_active = FALSE;
/* Update the emergency bearer services indicator */
if (pdn->is_emergency) {
ctx->emergency = FALSE;
esm_ctx->emergency = FALSE;
}
}
......@@ -375,7 +388,7 @@ int esm_ebr_context_release(
* If the UE locally deactivated all EPS bearer contexts, the UE
* shall perform a local detach and enter state EMM-DEREGISTERED.
*/
if (ctx->n_ebrs == 0) {
if (esm_ctx->n_ebrs == 0) {
emm_sap_t emm_sap;
emm_sap.primitive = EMMESM_ESTABLISH_CNF;
emm_sap.u.emm_esm.u.establish.is_attached = FALSE;
......@@ -387,7 +400,7 @@ int esm_ebr_context_release(
* the UE shall consider itself attached for emergency bearer
* services only.
*/
else if ( ctx->emergency && (ctx->n_ebrs == 1) ) {
else if (esm_ctx->emergency && (esm_ctx->n_ebrs == 1) ) {
emm_sap_t emm_sap;
emm_sap.primitive = EMMESM_ESTABLISH_CNF;
emm_sap.u.emm_esm.u.establish.is_attached = TRUE;
......@@ -396,7 +409,7 @@ int esm_ebr_context_release(
}
#endif // NAS_UE
#ifdef NAS_MME
if (ctx->n_ebrs == 0) {
if (esm_ctx->n_ebrs == 0) {
/* TODO: Release the PDN connection and marked the UE as inactive
* in the network for EPS services (is_attached = FALSE) */
}
......
......@@ -62,10 +62,10 @@ int esm_ebr_context_check_tft(int pid, int ebi, const network_tft_t *tft,
#endif
#ifdef NAS_MME
int esm_ebr_context_create(unsigned int ueid, int pid, int ebi, int is_default,
int esm_ebr_context_create(emm_data_context_t *ctx, int pid, int ebi, int is_default,
const network_qos_t *qos, const network_tft_t *tft);
int esm_ebr_context_release(unsigned int ueid, int ebi, int *pid, int *bid);
int esm_ebr_context_release(emm_data_context_t *ctx, int ebi, int *pid, int *bid);
#endif
#endif /* __ESM_EBR_CONTEXT_H__ */
#include "emmData.h"
#include "esmData.h"
char ip_addr_str[100];
......
......@@ -23,6 +23,7 @@ Description Defines the EPS Session Management procedure call manager,
#include "commonDef.h"
#include "nas_log.h"
#include "emmData.h"
#include "esmData.h"
#include "esm_pt.h"
#include "esm_ebr.h"
......@@ -106,11 +107,12 @@ void esm_main_initialize(void)
if (mme_api_get_esm_config(&_esm_data.conf) != RETURNok) {
LOG_TRACE(ERROR, "ESM-MAIN - Failed to get MME configuration data");
}
# if !defined(EPC_BUILD)
/* Initialize ESM contexts */
for (i = 0; i < ESM_DATA_NB_UE_MAX; i++) {
_esm_data.ctx[i] = NULL;
}
# endif
/* Initialize the EPS bearer context manager */
esm_ebr_initialize();
......
......@@ -23,6 +23,7 @@ Description Defines the EPS Session Management procedures executed at
#include "networkDef.h"
#include "OctetString.h"
#include "emmData.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
......@@ -68,7 +69,7 @@ typedef enum {
typedef int (*esm_proc_procedure_t) (int, int, OctetString *, int);
#endif
#ifdef NAS_MME
typedef int (*esm_proc_procedure_t) (int, unsigned int, int, OctetString *, int);
typedef int (*esm_proc_procedure_t) (int, emm_data_context_t *, int, OctetString *, int);
#endif
/* EPS bearer level QoS parameters */
......@@ -106,8 +107,8 @@ int esm_proc_status(int is_standalone, int pti, OctetString *msg,
#endif
#ifdef NAS_MME
int esm_proc_status_ind(unsigned int ueid, int pti, int ebi, int *esm_cause);
int esm_proc_status(int is_standalone, unsigned int ueid, int pti,
int esm_proc_status_ind(emm_data_context_t *ctx, int pti, int ebi, int *esm_cause);
int esm_proc_status(int is_standalone, emm_data_context_t *ctx, int pti,
OctetString *msg, int sent_by_ue);
#endif
......@@ -131,14 +132,14 @@ int esm_proc_pdn_connectivity_failure(int is_pending);
#endif
#ifdef NAS_MME
int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti,
int esm_proc_pdn_connectivity_request(emm_data_context_t *ctx, int pti,
esm_proc_pdn_request_t request_type, OctetString *apn,
esm_proc_pdn_type_t pdn_type, OctetString *pdn_addr, esm_proc_qos_t *esm_qos,
int *esm_cause);
int esm_proc_pdn_connectivity_reject(int is_standalone, unsigned int ueid,
int esm_proc_pdn_connectivity_reject(int is_standalone, emm_data_context_t *ctx,
int ebi, OctetString *msg, int ue_triggered);
int esm_proc_pdn_connectivity_failure(unsigned int ueid, int pid);
int esm_proc_pdn_connectivity_failure(emm_data_context_t *ctx, int pid);
#endif
/*
......@@ -156,10 +157,10 @@ int esm_proc_pdn_disconnect_reject(int pti, int *esm_cause);
#endif
#ifdef NAS_MME
int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int *esm_cause);
int esm_proc_pdn_disconnect_request(emm_data_context_t *ctx, int pti, int *esm_cause);
int esm_proc_pdn_disconnect_accept(unsigned int ueid, int pid, int *esm_cause);
int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid,
int esm_proc_pdn_disconnect_accept(emm_data_context_t *ctx, int pid, int *esm_cause);
int esm_proc_pdn_disconnect_reject(int is_standalone, emm_data_context_t *ctx,
int ebi, OctetString *msg, int ue_triggered);
#endif
......@@ -169,15 +170,15 @@ int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid,
* --------------------------------------------------------------------------
*/
#ifdef NAS_MME
int esm_proc_default_eps_bearer_context(unsigned int ueid, int pid,
int esm_proc_default_eps_bearer_context(emm_data_context_t *ctx, int pid,
unsigned int *ebi, const esm_proc_qos_t *esm_qos, int *esm_cause);
int esm_proc_default_eps_bearer_context_request(int is_standalone,
unsigned int ueid, int ebi, OctetString *msg, int ue_triggered);
int esm_proc_default_eps_bearer_context_failure(unsigned int ueid);
emm_data_context_t *ctx, int ebi, OctetString *msg, int ue_triggered);
int esm_proc_default_eps_bearer_context_failure(emm_data_context_t *ctx);
int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi,
int esm_proc_default_eps_bearer_context_accept(emm_data_context_t *ctx, int ebi,
int *esm_cause);
int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi,
int esm_proc_default_eps_bearer_context_reject(emm_data_context_t *ctx, int ebi,
int *esm_cause);
#endif
......@@ -199,15 +200,15 @@ int esm_proc_default_eps_bearer_context_reject(int is_standalone, int ebi,
* --------------------------------------------------------------------------
*/
#ifdef NAS_MME
int esm_proc_dedicated_eps_bearer_context(unsigned int ueid, int pid,
int esm_proc_dedicated_eps_bearer_context(emm_data_context_t *ctx, int pid,
unsigned int *ebi, unsigned int *default_ebi, const esm_proc_qos_t *qos,
const esm_proc_tft_t *tft, int *esm_cause);
int esm_proc_dedicated_eps_bearer_context_request(int is_standalone,
unsigned int ueid, int ebi, OctetString *msg, int ue_triggered);
emm_data_context_t *ctx, int ebi, OctetString *msg, int ue_triggered);
int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi,
int esm_proc_dedicated_eps_bearer_context_accept(emm_data_context_t *ctx, int ebi,
int *esm_cause);
int esm_proc_dedicated_eps_bearer_context_reject(unsigned int ueid, int ebi,
int esm_proc_dedicated_eps_bearer_context_reject(emm_data_context_t *ctx, int ebi,
int *esm_cause);
#endif
......@@ -227,12 +228,12 @@ int esm_proc_dedicated_eps_bearer_context_reject(int is_standalone, int ebi,
* --------------------------------------------------------------------------
*/
#ifdef NAS_MME
int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local,
int ebi, int *pid, int *bid, int *esm_cause);
int esm_proc_eps_bearer_context_deactivate(emm_data_context_t *ctx, int is_local,
int ebi, int *pid, int *bid,
int *esm_cause);
int esm_proc_eps_bearer_context_deactivate_request(int is_standalone,
unsigned int ueid, int ebi, OctetString *msg, int ue_triggered);
int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi,
emm_data_context_t *ctx, int ebi, OctetString *msg, int ue_triggered);
int esm_proc_eps_bearer_context_deactivate_accept(emm_data_context_t *ctx, int ebi,
int *esm_cause);
#endif
......
......@@ -23,6 +23,7 @@ Description Defines functions executed at the ESM Service Access
#define __ESM_RECV_H__
#include "EsmStatus.h"
#include "emmData.h"
#ifdef NAS_UE
#include "PdnConnectivityReject.h"
......@@ -80,7 +81,7 @@ Description Defines functions executed at the ESM Service Access
int esm_recv_status(int pti, int ebi, const esm_status_msg *msg);
#endif
#ifdef NAS_MME
int esm_recv_status(unsigned int ueid, int pti, int ebi,
int esm_recv_status(emm_data_context_t *ctx, int pti, int ebi,
const esm_status_msg *msg);
#endif
......@@ -124,29 +125,30 @@ int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi,
* Transaction related messages
* ----------------------------
*/
int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi,
int esm_recv_pdn_connectivity_request(emm_data_context_t *ctx, int pti, int ebi,
const pdn_connectivity_request_msg *msg, unsigned int *new_ebi, void *data);
int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi,
const pdn_disconnect_request_msg *msg, unsigned int *linked_ebi);
int esm_recv_pdn_disconnect_request(emm_data_context_t *ctx, int pti, int ebi,
const pdn_disconnect_request_msg *msg,
unsigned int *linked_ebi);
/*
* Messages related to EPS bearer contexts
* ---------------------------------------
*/
int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid,
int esm_recv_activate_default_eps_bearer_context_accept(emm_data_context_t *ctx,
int pti, int ebi, const activate_default_eps_bearer_context_accept_msg *msg);
int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid,
int esm_recv_activate_default_eps_bearer_context_reject(emm_data_context_t *ctx,
int pti, int ebi, const activate_default_eps_bearer_context_reject_msg *msg);
int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid,
int esm_recv_activate_dedicated_eps_bearer_context_accept(emm_data_context_t *ctx,
int pti, int ebi, const activate_dedicated_eps_bearer_context_accept_msg *msg);
int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid,
int esm_recv_activate_dedicated_eps_bearer_context_reject(emm_data_context_t *ctx,
int pti, int ebi, const activate_dedicated_eps_bearer_context_reject_msg *msg);
int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid, int pti,
int esm_recv_deactivate_eps_bearer_context_accept(emm_data_context_t *ctx, int pti,
int ebi, const deactivate_eps_bearer_context_accept_msg *msg);
#endif
......
......@@ -53,9 +53,9 @@ static int _esm_sap_send(int msg_type, int is_standalone, int pti, int ebi,
#endif
#ifdef NAS_MME
static int _esm_sap_recv(int msg_type, int is_standalone, unsigned int ueid,
static int _esm_sap_recv(int msg_type, int is_standalone, emm_data_context_t *ctx,
const OctetString *req, OctetString *rsp, esm_sap_error_t *err);
static int _esm_sap_send(int msg_type, int is_standalone, unsigned int ueid,
static int _esm_sap_send(int msg_type, int is_standalone, emm_data_context_t *ctx,
int pti, int ebi, const esm_sap_data_t *data, OctetString *rsp);
#endif
......@@ -186,16 +186,16 @@ int esm_sap_send(esm_sap_t *msg)
#ifdef NAS_MME
/* The MME received a PDN connectivity request message */
rc = _esm_sap_recv(PDN_CONNECTIVITY_REQUEST, msg->is_standalone,
msg->ueid, msg->recv, &msg->send, &msg->err);
msg->ctx, msg->recv, &msg->send, &msg->err);
#endif
break;
case ESM_PDN_CONNECTIVITY_REJ:
#ifdef NAS_MME
/* PDN connectivity locally failed */
pid = esm_proc_default_eps_bearer_context_failure(msg->ueid);
pid = esm_proc_default_eps_bearer_context_failure(msg->ctx);
if (pid != RETURNerror) {
rc = esm_proc_pdn_connectivity_failure(msg->ueid, pid);
rc = esm_proc_pdn_connectivity_failure(msg->ctx, pid);
}
#endif
#ifdef NAS_UE
......@@ -264,7 +264,7 @@ int esm_sap_send(esm_sap_t *msg)
#ifdef NAS_MME
/* The MME received activate default ESP bearer context accept */
rc = _esm_sap_recv(ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT,
msg->is_standalone, msg->ueid,
msg->is_standalone, msg->ctx,
msg->recv, &msg->send, &msg->err);
#endif
#ifdef NAS_UE
......@@ -283,7 +283,7 @@ int esm_sap_send(esm_sap_t *msg)
#ifdef NAS_MME
/* The MME received activate default ESP bearer context reject */
rc = _esm_sap_recv(ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT,
msg->is_standalone, msg->ueid,
msg->is_standalone, msg->ctx,
msg->recv, &msg->send, &msg->err);
#endif
#ifdef NAS_UE
......@@ -325,7 +325,7 @@ int esm_sap_send(esm_sap_t *msg)
msg->data.eps_bearer_context_deactivate.ebi, &pid, &bid);
#endif
#ifdef NAS_MME
rc = esm_proc_eps_bearer_context_deactivate(msg->ueid, TRUE,
rc = esm_proc_eps_bearer_context_deactivate(msg->ctx, TRUE,
msg->data.eps_bearer_context_deactivate.ebi,
&pid, &bid, NULL);
#endif
......@@ -341,7 +341,7 @@ int esm_sap_send(esm_sap_t *msg)
&msg->send, &msg->err);
#endif
#ifdef NAS_MME
rc = _esm_sap_recv(-1, msg->is_standalone, msg->ueid,
rc = _esm_sap_recv(-1, msg->is_standalone, msg->ctx,
msg->recv, &msg->send, &msg->err);
#endif
break;
......@@ -396,7 +396,7 @@ int esm_sap_send(esm_sap_t *msg)
***************************************************************************/
static int _esm_sap_recv(int msg_type, int is_standalone,
#ifdef NAS_MME
unsigned int ueid,
emm_data_context_t *ctx,
#endif
const OctetString *req, OctetString *rsp,
esm_sap_error_t *err)
......@@ -647,7 +647,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
* received from the UE
*/
esm_cause = esm_recv_activate_default_eps_bearer_context_accept(
ueid, pti, ebi,
ctx, pti, ebi,
&esm_msg.activate_default_eps_bearer_context_accept);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
......@@ -668,7 +668,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
* received from the UE
*/
esm_cause = esm_recv_activate_default_eps_bearer_context_reject(
ueid, pti, ebi,
ctx, pti, ebi,
&esm_msg.activate_default_eps_bearer_context_reject);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
......@@ -689,7 +689,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
* received from the UE
*/
esm_cause = esm_recv_deactivate_eps_bearer_context_accept(
ueid, pti, ebi,
ctx, pti, ebi,
&esm_msg.deactivate_eps_bearer_context_accept);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
......@@ -710,7 +710,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
* received from the UE
*/
esm_cause = esm_recv_activate_dedicated_eps_bearer_context_accept(
ueid, pti, ebi,
ctx, pti, ebi,
&esm_msg.activate_dedicated_eps_bearer_context_accept);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
......@@ -731,7 +731,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
* received from the UE
*/
esm_cause = esm_recv_activate_dedicated_eps_bearer_context_reject(
ueid, pti, ebi,
ctx, pti, ebi,
&esm_msg.activate_dedicated_eps_bearer_context_reject);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
......@@ -759,7 +759,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
/*
* Process PDN connectivity request message received from the UE
*/
esm_cause = esm_recv_pdn_connectivity_request(ueid, pti, ebi,
esm_cause = esm_recv_pdn_connectivity_request(ctx, pti, ebi,
&esm_msg.pdn_connectivity_request,
&ebi, &data);
......@@ -854,7 +854,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
/*
* Process PDN disconnect request message received from the UE
*/
esm_cause = esm_recv_pdn_disconnect_request(ueid, pti, ebi,
esm_cause = esm_recv_pdn_disconnect_request(ctx, pti, ebi,
&esm_msg.pdn_disconnect_request, &ebi);
if (esm_cause != ESM_CAUSE_SUCCESS) {
......@@ -890,7 +890,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
/*
* Process received ESM status message
*/
esm_cause = esm_recv_status(ueid, pti, ebi, &esm_msg.esm_status);
esm_cause = esm_recv_status(ctx, pti, ebi, &esm_msg.esm_status);
break;
#endif
......@@ -935,7 +935,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
rc = (*esm_procedure)(is_standalone, ebi, rsp, triggered_by_ue);
#endif
#ifdef NAS_MME
rc = (*esm_procedure)(is_standalone, ueid, ebi, rsp, triggered_by_ue);
rc = (*esm_procedure)(is_standalone, ctx, ebi, rsp, triggered_by_ue);
#endif
if (is_discarded) {
/* Return indication that received message has been discarded */
......@@ -980,10 +980,10 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
***************************************************************************/
static int _esm_sap_send(int msg_type, int is_standalone,
#ifdef NAS_MME
unsigned int ueid,
emm_data_context_t *ctx,
#endif
int pti, int ebi, const esm_sap_data_t *data,
OctetString *rsp)
int pti, int ebi, const esm_sap_data_t *data,
OctetString *rsp)
{
LOG_FUNC_IN;
......@@ -1103,7 +1103,7 @@ static int _esm_sap_send(int msg_type, int is_standalone,
rc = (*esm_procedure)(is_standalone, pti, rsp, sent_by_ue);
#endif
#ifdef NAS_MME
rc = (*esm_procedure)(is_standalone, ueid, pti, rsp, sent_by_ue);
rc = (*esm_procedure)(is_standalone, ctx, pti, rsp, sent_by_ue);
#endif
}
}
......
......@@ -18,6 +18,9 @@ Description Defines the ESM Service Access Point that provides EPS
bearer context handling and resources allocation procedures.
*****************************************************************************/
#include "emmData.h"
#ifndef __ESM_SAPDEF_H__
#define __ESM_SAPDEF_H__
......@@ -132,11 +135,14 @@ typedef struct {
* within this primitive has to be sent/received
* standalone or together within an EMM related
* message */
unsigned int ueid; /* Local UE identifier */
esm_sap_error_t err; /* ESM-SAP error code */
const OctetString *recv; /* Encoded ESM message received */
OctetString send; /* Encoded ESM message to be sent */
esm_sap_data_t data; /* ESM message data parameters */
#if defined(NAS_MME)
emm_data_context_t *ctx; /* UE context */
#endif
unsigned int ueid; /* Local UE identifier */
esm_sap_error_t err; /* ESM-SAP error code */
const OctetString *recv; /* Encoded ESM message received */
OctetString send; /* Encoded ESM message to be sent */
esm_sap_data_t data; /* ESM message data parameters */
} esm_sap_t;
/****************************************************************************/
......
......@@ -47,20 +47,6 @@ int nas_itti_dl_data_req(const uint32_t ue_id, void *const data,
return itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, message_p);
}
void nas_itti_establish_cnf(const nas_error_code_t error_code, void *const data,
const uint32_t length)
{
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS, NAS_CONNECTION_ESTABLISHMENT_CNF);
NAS_CONN_EST_CNF(message_p).nas_establish_cnf.nasMsg.data = data;
NAS_CONN_EST_CNF(message_p).nas_establish_cnf.nasMsg.length = length;
NAS_CONN_EST_CNF(message_p).nas_establish_cnf.errCode = error_code;
itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, message_p);
}
#endif
#if defined(UE_BUILD) && defined(NAS_UE)
......
......@@ -43,8 +43,21 @@
int nas_itti_dl_data_req(const uint32_t ue_id, void *const data,
const uint32_t length);
void nas_itti_establish_cnf(const nas_error_code_t error_code, void *const data,
const uint32_t length);
static inline void nas_itti_establish_cnf(const uint32_t ue_id,
const nas_error_code_t error_code, void *const data,
const uint32_t length)
{
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS, NAS_CONNECTION_ESTABLISHMENT_CNF);
NAS_CONNECTION_ESTABLISHMENT_CNF(message_p).UEid = ue_id;
NAS_CONNECTION_ESTABLISHMENT_CNF(message_p).errCode = error_code;
NAS_CONNECTION_ESTABLISHMENT_CNF(message_p).nasMsg.data = data;
NAS_CONNECTION_ESTABLISHMENT_CNF(message_p).nasMsg.length = length;
itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, message_p);
}
static inline void nas_itti_auth_info_req(const uint32_t ue_id,
const imsi_t *const imsi, uint8_t initial_req, const uint8_t *auts)
......
......@@ -470,7 +470,7 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id,
S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.buffer =
malloc(sizeof(uint8_t) * item_p->nAS_PDU->size);
memcpy(&S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.buffer,
memcpy(S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.buffer,
item_p->nAS_PDU->buf, item_p->nAS_PDU->size);
} else {
S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.length = 0;
......
......@@ -151,16 +151,7 @@ void *s1ap_mme_thread(void *args)
} break;
#else
case NAS_CONNECTION_ESTABLISHMENT_CNF: {
if (AS_TERMINATED_NAS == NAS_CONN_EST_CNF(received_message_p).nas_establish_cnf.errCode) {
/* Attach rejected by NAS -> send result via
* DL info transfer message
*/
s1ap_generate_downlink_nas_transport(NAS_CONN_EST_CNF(received_message_p).ue_id,
NAS_CONN_EST_CNF(received_message_p).nas_establish_cnf.nasMsg.data,
NAS_CONN_EST_CNF(received_message_p).nas_establish_cnf.nasMsg.length);
} else {
s1ap_handle_conn_est_cnf(&NAS_CONN_EST_CNF(received_message_p));
}
s1ap_handle_conn_est_cnf(&NAS_CONNECTION_ESTABLISHMENT_CNF(received_message_p));
} break;
#endif
......
......@@ -28,6 +28,7 @@
*******************************************************************************/
#include <stdio.h>
#include <stdint.h>
#include "s1ap_common.h"
......@@ -226,7 +227,6 @@ int s1ap_generate_downlink_nas_transport(const uint32_t ue_id, void * const data
s1ap_mme_itti_send_sctp_request(buffer_p, length,
ue_ref->eNB->sctp_assoc_id,
ue_ref->sctp_stream_send);
//s1ap_mme_itti_nas_downlink_cnf(ue_ref->mme_ue_s1ap_id, AS_SUCCESS);
}
return 0;
}
......@@ -365,26 +365,24 @@ void s1ap_handle_conn_est_cnf(nas_conn_est_cnf_t *nas_conn_est_cnf_p)
* At least one bearer has been established. We can now send s1ap initial context setup request
* message to eNB.
*/
uint8_t supportedAlgorithms[] = { 0x00, 0x02 };
uint8_t supportedAlgorithms[] = { 0x00, 0x00 };
uint8_t offset = 0;
uint8_t *buffer_p;
uint32_t length;
uint32_t length, teid = 12;
ue_description_t *ue_ref = NULL;
s1ap_message message;
s1ap_initial_ctxt_setup_req_t *initial_p;
S1ap_InitialContextSetupRequestIEs_t *initialContextSetupRequest_p;
S1ap_E_RABToBeSetupItemCtxtSUReq_t e_RABToBeSetup;
S1ap_NAS_PDU_t nas_pdu;
DevAssert(nas_conn_est_cnf_p != NULL);
initial_p = &nas_conn_est_cnf_p->transparent;
if ((ue_ref = s1ap_is_ue_mme_id_in_list(initial_p->mme_ue_s1ap_id)) == NULL) {
if ((ue_ref = s1ap_is_ue_mme_id_in_list(nas_conn_est_cnf_p->UEid)) == NULL) {
S1AP_DEBUG("This mme ue s1ap id (%08x) is not attached to any UE context\n",
initial_p->mme_ue_s1ap_id);
DevParam(initial_p->mme_ue_s1ap_id, 0, 0);
nas_conn_est_cnf_p->UEid);
DevParam(nas_conn_est_cnf_p->UEid, 0, 0);
}
/* Start the outcome response timer.
......@@ -409,53 +407,72 @@ void s1ap_handle_conn_est_cnf(nas_conn_est_cnf_t *nas_conn_est_cnf_p)
initialContextSetupRequest_p->eNB_UE_S1AP_ID = (unsigned long)ue_ref->eNB_ue_s1ap_id;
/* uEaggregateMaximumBitrateDL and uEaggregateMaximumBitrateUL expressed in term of bits/sec */
initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL = initial_p->ambr.br_dl;
initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateUL = initial_p->ambr.br_ul;
e_RABToBeSetup.e_RAB_ID = initial_p->ebi;
e_RABToBeSetup.e_RABlevelQoSParameters.qCI = initial_p->qci;
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.priorityLevel
= initial_p->prio_level; //No priority
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionCapability
= initial_p->pre_emp_capability;
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability
= initial_p->pre_emp_vulnerability;
// initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL = initial_p->ambr.br_dl;
// initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateUL = initial_p->ambr.br_ul;
initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL = 1024 * 1024;
initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL = 512 * 1024;
// e_RABToBeSetup.e_RAB_ID = initial_p->ebi;
e_RABToBeSetup.e_RAB_ID = 5;
// e_RABToBeSetup.e_RABlevelQoSParameters.qCI = initial_p->qci;
e_RABToBeSetup.e_RABlevelQoSParameters.qCI = 0;
memset(&nas_pdu, 0, sizeof(nas_pdu));
nas_pdu.size = nas_conn_est_cnf_p->nasMsg.length;
nas_pdu.buf = nas_conn_est_cnf_p->nasMsg.data;
e_RABToBeSetup.nAS_PDU = &nas_pdu;
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.priorityLevel =
S1ap_PriorityLevel_lowest;
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionCapability =
S1ap_Pre_emptionCapability_shall_not_trigger_pre_emption;
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability =
S1ap_Pre_emptionVulnerability_not_pre_emptable;
INT32_TO_OCTET_STRING(teid, &e_RABToBeSetup.gTP_TEID);
// e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.priorityLevel
// = initial_p->prio_level; //No priority
// e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionCapability
// = initial_p->pre_emp_capability;
// e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability
// = initial_p->pre_emp_vulnerability;
/* Set the GTP-TEID. This is the S1-U S-GW TEID */
INT32_TO_OCTET_STRING(initial_p->teid, &e_RABToBeSetup.gTP_TEID);
// INT32_TO_OCTET_STRING(initial_p->teid, &e_RABToBeSetup.gTP_TEID);
/* S-GW IP address(es) for user-plane */
if ((initial_p->s_gw_address.pdn_type == IPv4) ||
(initial_p->s_gw_address.pdn_type == IPv4_AND_v6))
{
e_RABToBeSetup.transportLayerAddress.buf = calloc(4, sizeof(uint8_t));
/* Only IPv4 supported */
memcpy(e_RABToBeSetup.transportLayerAddress.buf,
initial_p->s_gw_address.address.ipv4_address,
4);
offset += 4;
e_RABToBeSetup.transportLayerAddress.size = 4;
e_RABToBeSetup.transportLayerAddress.bits_unused = 0;
}
if ((initial_p->s_gw_address.pdn_type == IPv6) ||
(initial_p->s_gw_address.pdn_type == IPv4_AND_v6))
{
if (offset == 0) {
/* Both IPv4 and IPv6 provided */
/* TODO: check memory allocation */
e_RABToBeSetup.transportLayerAddress.buf = calloc(16, sizeof(uint8_t));
} else {
/* Only IPv6 supported */
/* TODO: check memory allocation */
e_RABToBeSetup.transportLayerAddress.buf
= realloc(e_RABToBeSetup.transportLayerAddress.buf, (16 + offset) * sizeof(uint8_t));
}
memcpy(&e_RABToBeSetup.transportLayerAddress.buf[offset],
initial_p->s_gw_address.address.ipv6_address,
16);
e_RABToBeSetup.transportLayerAddress.size = 16 + offset;
e_RABToBeSetup.transportLayerAddress.bits_unused = 0;
}
// if ((initial_p->s_gw_address.pdn_type == IPv4) ||
// (initial_p->s_gw_address.pdn_type == IPv4_AND_v6))
// {
// e_RABToBeSetup.transportLayerAddress.buf = calloc(4, sizeof(uint8_t));
// /* Only IPv4 supported */
// memcpy(e_RABToBeSetup.transportLayerAddress.buf,
// initial_p->s_gw_address.address.ipv4_address,
// 4);
// offset += 4;
// e_RABToBeSetup.transportLayerAddress.size = 4;
// e_RABToBeSetup.transportLayerAddress.bits_unused = 0;
// }
// if ((initial_p->s_gw_address.pdn_type == IPv6) ||
// (initial_p->s_gw_address.pdn_type == IPv4_AND_v6))
// {
// if (offset == 0) {
// /* Both IPv4 and IPv6 provided */
// /* TODO: check memory allocation */
// e_RABToBeSetup.transportLayerAddress.buf = calloc(16, sizeof(uint8_t));
// } else {
// /* Only IPv6 supported */
// /* TODO: check memory allocation */
// e_RABToBeSetup.transportLayerAddress.buf
// = realloc(e_RABToBeSetup.transportLayerAddress.buf, (16 + offset) * sizeof(uint8_t));
// }
// memcpy(&e_RABToBeSetup.transportLayerAddress.buf[offset],
// initial_p->s_gw_address.address.ipv6_address,
// 16);
// e_RABToBeSetup.transportLayerAddress.size = 16 + offset;
// e_RABToBeSetup.transportLayerAddress.bits_unused = 0;
// }
ASN_SEQUENCE_ADD(&initialContextSetupRequest_p->e_RABToBeSetupListCtxtSUReq,
&e_RABToBeSetup);
......@@ -473,7 +490,11 @@ void s1ap_handle_conn_est_cnf(nas_conn_est_cnf_t *nas_conn_est_cnf_p)
initialContextSetupRequest_p->ueSecurityCapabilities.integrityProtectionAlgorithms.bits_unused
= 0;
initialContextSetupRequest_p->securityKey.buf = initial_p->keNB; /* 256 bits length */
// initialContextSetupRequest_p->securityKey.buf = initial_p->keNB; /* 256 bits length */
uint8_t keNB[32];
memset(keNB, 0, sizeof(keNB));
initialContextSetupRequest_p->securityKey.buf = keNB;
initialContextSetupRequest_p->securityKey.size = 32;
initialContextSetupRequest_p->securityKey.bits_unused = 0;
......@@ -482,6 +503,8 @@ void s1ap_handle_conn_est_cnf(nas_conn_est_cnf_t *nas_conn_est_cnf_p)
DevMessage("Failed to encode initial context setup request message\n");
}
free(nas_conn_est_cnf_p->nasMsg.data);
s1ap_mme_itti_send_sctp_request(buffer_p, length, ue_ref->eNB->sctp_assoc_id,
ue_ref->sctp_stream_send);
}
......
......@@ -67,7 +67,7 @@ int s1ap_mme_handle_nas_non_delivery(uint32_t assocId, uint32_t stream,
#if defined(DISABLE_USE_NAS)
int s1ap_handle_attach_accepted(nas_attach_accept_t *attach_accept_p);
#else
void s1ap_handle_conn_est_cnf(nas_conn_est_cnf_t *nas_conn_est_cnf_p);
void s1ap_handle_conn_est_cnf(nas_conn_est_cnf_t *nas_conn_est_cnf);
#endif
int s1ap_generate_downlink_nas_transport(const uint32_t ue_id, void * const data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment