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 @@ ...@@ -3,16 +3,16 @@
#ifndef NAS_MESSAGES_TYPES_H_ #ifndef NAS_MESSAGES_TYPES_H_
#define NAS_MESSAGES_TYPES_H_ #define NAS_MESSAGES_TYPES_H_
#define NAS_UL_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.nas_ul_data_ind #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_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_req
#define NAS_DL_DATA_CNF(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_cnf #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_IND(mSGpTR) (mSGpTR)->ittiMsg.nas_conn_est_ind
#define NAS_CONN_EST_CNF(mSGpTR) (mSGpTR)->ittiMsg.nas_conn_est_cnf #define NAS_CONNECTION_ESTABLISHMENT_CNF(mSGpTR) (mSGpTR)->ittiMsg.nas_conn_est_cnf
#define NAS_BEARER_PARAM(mSGpTR) (mSGpTR)->ittiMsg.nas_bearer_param #define NAS_BEARER_PARAM(mSGpTR) (mSGpTR)->ittiMsg.nas_bearer_param
#define NAS_AUTHENTICATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_req #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_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_param_req
#define NAS_AUTHENTICATION_PARAM_RSP(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_param_rsp #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_AUTHENTICATION_PARAM_FAIL(mSGpTR) (mSGpTR)->ittiMsg.nas_auth_param_fail
typedef struct nas_paging_ind_s { typedef struct nas_paging_ind_s {
...@@ -29,6 +29,7 @@ typedef struct nas_conn_est_ind_s { ...@@ -29,6 +29,7 @@ typedef struct nas_conn_est_ind_s {
typedef nas_establish_rsp_t nas_conn_est_rej_t; typedef nas_establish_rsp_t nas_conn_est_rej_t;
#if defined(DISABLE_USE_NAS)
typedef struct nas_conn_est_cnf_s { typedef struct nas_conn_est_cnf_s {
uint32_t ue_id; uint32_t ue_id;
...@@ -36,6 +37,9 @@ typedef struct nas_conn_est_cnf_s { ...@@ -36,6 +37,9 @@ typedef struct nas_conn_est_cnf_s {
/* Transparent message from MME_APP to S1AP */ /* Transparent message from MME_APP to S1AP */
s1ap_initial_ctxt_setup_req_t transparent; s1ap_initial_ctxt_setup_req_t transparent;
} nas_conn_est_cnf_t; } nas_conn_est_cnf_t;
#else
typedef nas_establish_cnf_t nas_conn_est_cnf_t;
#endif
typedef struct nas_bearer_param_s { typedef struct nas_bearer_param_s {
unsigned eNB_ue_s1ap_id:24; unsigned eNB_ue_s1ap_id:24;
......
...@@ -1117,6 +1117,7 @@ int emm_proc_attach_request(unsigned int ueid, emm_proc_attach_type_t type, ...@@ -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)->esm_msg.value = NULL;
(*emm_ctx)->emm_cause = EMM_CAUSE_SUCCESS; (*emm_ctx)->emm_cause = EMM_CAUSE_SUCCESS;
(*emm_ctx)->_emm_fsm_status = EMM_INVALID; (*emm_ctx)->_emm_fsm_status = EMM_INVALID;
(*emm_ctx)->ueid = ueid;
emm_fsm_set_status(ueid, *emm_ctx, EMM_DEREGISTERED); emm_fsm_set_status(ueid, *emm_ctx, EMM_DEREGISTERED);
#if defined(EPC_BUILD) #if defined(EPC_BUILD)
...@@ -1130,7 +1131,6 @@ int emm_proc_attach_request(unsigned int ueid, emm_proc_attach_type_t type, ...@@ -1130,7 +1131,6 @@ int emm_proc_attach_request(unsigned int ueid, emm_proc_attach_type_t type,
if (rc != RETURNok) { if (rc != RETURNok) {
LOG_TRACE(WARNING, "EMM-PROC - Failed to update EMM context"); LOG_TRACE(WARNING, "EMM-PROC - Failed to update EMM context");
/* Do not accept the UE to attach to the network */ /* Do not accept the UE to attach to the network */
(*emm_ctx)->ueid = ueid;
(*emm_ctx)->emm_cause = EMM_CAUSE_ILLEGAL_UE; (*emm_ctx)->emm_cause = EMM_CAUSE_ILLEGAL_UE;
rc = _emm_attach_reject(*emm_ctx); rc = _emm_attach_reject(*emm_ctx);
} else { } else {
...@@ -1216,12 +1216,13 @@ int emm_proc_attach_reject(unsigned int ueid, int emm_cause) ...@@ -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) 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; int rc = RETURNerror;
emm_sap_t emm_sap; emm_sap_t emm_sap;
esm_sap_t esm_sap; esm_sap_t esm_sap;
LOG_FUNC_IN;
LOG_TRACE(INFO, "EMM-PROC - EPS attach complete (ueid=%u)", ueid); LOG_TRACE(INFO, "EMM-PROC - EPS attach complete (ueid=%u)", ueid);
/* Stop timer T3450 */ /* Stop timer T3450 */
...@@ -1238,7 +1239,6 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg) ...@@ -1238,7 +1239,6 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg)
} }
/* Get the UE context */ /* Get the UE context */
emm_data_context_t *emm_ctx = NULL;
#if defined(EPC_BUILD) #if defined(EPC_BUILD)
if (ueid > 0) { if (ueid > 0) {
...@@ -1263,6 +1263,7 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg) ...@@ -1263,6 +1263,7 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg)
esm_sap.is_standalone = FALSE; esm_sap.is_standalone = FALSE;
esm_sap.ueid = ueid; esm_sap.ueid = ueid;
esm_sap.recv = esm_msg; esm_sap.recv = esm_msg;
esm_sap.ctx = emm_ctx;
rc = esm_sap_send(&esm_sap); rc = esm_sap_send(&esm_sap);
} else { } else {
LOG_TRACE(ERROR, "EMM-PROC - No EMM context exists"); 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) ...@@ -1276,6 +1277,7 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg)
*/ */
emm_sap.primitive = EMMREG_ATTACH_CNF; emm_sap.primitive = EMMREG_ATTACH_CNF;
emm_sap.u.emm_reg.ueid = ueid; emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
} else if (esm_sap.err != ESM_SAP_DISCARDED) { } else if (esm_sap.err != ESM_SAP_DISCARDED) {
/* /*
...@@ -1283,6 +1285,7 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg) ...@@ -1283,6 +1285,7 @@ int emm_proc_attach_complete(unsigned int ueid, const OctetString *esm_msg)
*/ */
emm_sap.primitive = EMMREG_ATTACH_REJ; emm_sap.primitive = EMMREG_ATTACH_REJ;
emm_sap.u.emm_reg.ueid = ueid; emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
} else { } else {
/* /*
...@@ -1748,14 +1751,17 @@ static int _emm_attach_reject(void *args) ...@@ -1748,14 +1751,17 @@ static int _emm_attach_reject(void *args)
***************************************************************************/ ***************************************************************************/
static int _emm_attach_abort(void *args) static int _emm_attach_abort(void *args)
{ {
LOG_FUNC_IN;
int rc = RETURNerror; 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) { if (data) {
unsigned int ueid = data->ueid; unsigned int ueid = data->ueid;
esm_sap_t esm_sap;
LOG_TRACE(WARNING, "EMM-PROC - Abort the attach procedure (ueid=%u)", LOG_TRACE(WARNING, "EMM-PROC - Abort the attach procedure (ueid=%u)",
ueid); ueid);
...@@ -1771,15 +1777,22 @@ static int _emm_attach_abort(void *args) ...@@ -1771,15 +1777,22 @@ static int _emm_attach_abort(void *args)
} }
free(data); 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 * Notify ESM that the network locally refused PDN connectivity
* to the UE * to the UE
*/ */
esm_sap_t esm_sap;
esm_sap.primitive = ESM_PDN_CONNECTIVITY_REJ; esm_sap.primitive = ESM_PDN_CONNECTIVITY_REJ;
esm_sap.ueid = ueid; esm_sap.ueid = ueid;
esm_sap.ctx = ctx;
esm_sap.recv = NULL; esm_sap.recv = NULL;
rc = esm_sap_send(&esm_sap); rc = esm_sap_send(&esm_sap);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* /*
* Notify EMM that EPS attach procedure failed * Notify EMM that EPS attach procedure failed
...@@ -1787,16 +1800,9 @@ static int _emm_attach_abort(void *args) ...@@ -1787,16 +1800,9 @@ static int _emm_attach_abort(void *args)
emm_sap_t emm_sap; emm_sap_t emm_sap;
emm_sap.primitive = EMMREG_ATTACH_REJ; emm_sap.primitive = EMMREG_ATTACH_REJ;
emm_sap.u.emm_reg.ueid = ueid; emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = ctx;
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
if (rc != RETURNerror) { 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 */ /* Release the UE context */
rc = _emm_attach_release(ctx); rc = _emm_attach_release(ctx);
} }
...@@ -2098,6 +2104,7 @@ static int _emm_attach(void *args) ...@@ -2098,6 +2104,7 @@ static int _emm_attach(void *args)
esm_sap.primitive = ESM_PDN_CONNECTIVITY_REQ; esm_sap.primitive = ESM_PDN_CONNECTIVITY_REQ;
esm_sap.is_standalone = FALSE; esm_sap.is_standalone = FALSE;
esm_sap.ueid = emm_ctx->ueid; esm_sap.ueid = emm_ctx->ueid;
esm_sap.ctx = emm_ctx;
esm_sap.recv = &emm_ctx->esm_msg; esm_sap.recv = &emm_ctx->esm_msg;
rc = esm_sap_send(&esm_sap); 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) ...@@ -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 * 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 * Default EPS Bearer Context Request message has to be sent to the UE
*/ */
emm_sap.primitive = EMMAS_ESTABLISH_CNF; emm_sap.primitive = EMMAS_ESTABLISH_CNF;
emm_sap.u.emm_as.u.establish.ueid = emm_ctx->ueid; emm_sap.u.emm_as.u.establish.ueid = emm_ctx->ueid;
if (emm_ctx->guti_is_new && emm_ctx->old_guti) { 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, ...@@ -2387,6 +2395,26 @@ static int _emm_attach_update(emm_data_context_t *ctx, unsigned int ueid,
} else { } else {
return (RETURNerror); 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 */ /* The IMSI if provided by the UE */
if (imsi) { if (imsi) {
......
...@@ -512,6 +512,7 @@ int emm_proc_detach_request(unsigned int ueid, emm_proc_detach_type_t type, ...@@ -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_t esm_sap;
esm_sap.primitive = ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ; esm_sap.primitive = ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ;
esm_sap.ueid = ueid; esm_sap.ueid = ueid;
esm_sap.ctx = emm_ctx;
esm_sap.data.eps_bearer_context_deactivate.ebi = ESM_SAP_ALL_EBI; esm_sap.data.eps_bearer_context_deactivate.ebi = ESM_SAP_ALL_EBI;
rc = esm_sap_send(&esm_sap); rc = esm_sap_send(&esm_sap);
...@@ -522,6 +523,7 @@ int emm_proc_detach_request(unsigned int ueid, emm_proc_detach_type_t type, ...@@ -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.primitive = EMMREG_DETACH_REQ;
emm_sap.u.emm_reg.ueid = ueid; emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
} }
} }
......
...@@ -202,14 +202,26 @@ int lowerlayer_release(int cause) ...@@ -202,14 +202,26 @@ int lowerlayer_release(int cause)
***************************************************************************/ ***************************************************************************/
int lowerlayer_data_ind(unsigned int ueid, const OctetString *data) int lowerlayer_data_ind(unsigned int ueid, const OctetString *data)
{ {
LOG_FUNC_IN;
esm_sap_t esm_sap; esm_sap_t esm_sap;
int rc; 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.primitive = ESM_UNITDATA_IND;
esm_sap.is_standalone = TRUE; esm_sap.is_standalone = TRUE;
esm_sap.ueid = ueid; esm_sap.ueid = ueid;
#if defined(NAS_MME)
esm_sap.ctx = emm_ctx;
#endif
esm_sap.recv = data; esm_sap.recv = data;
rc = esm_sap_send(&esm_sap); rc = esm_sap_send(&esm_sap);
......
...@@ -28,6 +28,8 @@ Description Defines internal private data handled by EPS Mobility ...@@ -28,6 +28,8 @@ Description Defines internal private data handled by EPS Mobility
#include "OctetString.h" #include "OctetString.h"
#include "nas_timer.h" #include "nas_timer.h"
#include "esmData.h"
#ifdef NAS_MME #ifdef NAS_MME
#include "emm_fsm.h" #include "emm_fsm.h"
#include "mme_api.h" #include "mme_api.h"
...@@ -348,6 +350,8 @@ typedef struct emm_data_context_s { ...@@ -348,6 +350,8 @@ typedef struct emm_data_context_s {
int emm_cause; /* EMM failure cause code */ int emm_cause; /* EMM failure cause code */
emm_fsm_state_t _emm_fsm_status; emm_fsm_state_t _emm_fsm_status;
esm_data_context_t esm_data_ctx;
} emm_data_context_t; } emm_data_context_t;
/* /*
......
...@@ -1092,7 +1092,7 @@ static int _emm_as_send(const emm_as_t *msg) ...@@ -1092,7 +1092,7 @@ static int _emm_as_send(const emm_as_t *msg)
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} break; } break;
case AS_NAS_ESTABLISH_RSP: { case AS_NAS_ESTABLISH_CNF: {
if (as_msg.msg.nas_establish_rsp.errCode != AS_SUCCESS) { if (as_msg.msg.nas_establish_rsp.errCode != AS_SUCCESS) {
nas_itti_dl_data_req(as_msg.msg.nas_establish_rsp.UEid, nas_itti_dl_data_req(as_msg.msg.nas_establish_rsp.UEid,
as_msg.msg.nas_establish_rsp.nasMsg.data, as_msg.msg.nas_establish_rsp.nasMsg.data,
...@@ -1100,6 +1100,11 @@ static int _emm_as_send(const emm_as_t *msg) ...@@ -1100,6 +1100,11 @@ static int _emm_as_send(const emm_as_t *msg)
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} else { } else {
/* Handle success case */ /* 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; } break;
...@@ -1670,7 +1675,7 @@ static int _emm_as_establish_cnf(const emm_as_establish_t *msg, ...@@ -1670,7 +1675,7 @@ static int _emm_as_establish_cnf(const emm_as_establish_t *msg,
LOG_FUNC_IN; 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; nas_message_t nas_msg;
memset(&nas_msg, 0 , sizeof(nas_message_t)); memset(&nas_msg, 0 , sizeof(nas_message_t));
...@@ -1678,6 +1683,7 @@ static int _emm_as_establish_cnf(const emm_as_establish_t *msg, ...@@ -1678,6 +1683,7 @@ static int _emm_as_establish_cnf(const emm_as_establish_t *msg,
/* Setup the AS message */ /* Setup the AS message */
as_msg->UEid = msg->ueid; as_msg->UEid = msg->ueid;
if (msg->UEid.guti == NULL) { if (msg->UEid.guti == NULL) {
LOG_TRACE(WARNING, "EMMAS-SAP - GUTI is NULL...");
LOG_FUNC_RETURN (0); LOG_FUNC_RETURN (0);
} }
as_msg->s_tmsi.MMEcode = msg->UEid.guti->gummei.MMEcode; 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, ...@@ -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); int bytes = _emm_as_encode(&as_msg->nasMsg, &nas_msg, size);
if (bytes > 0) { if (bytes > 0) {
as_msg->errCode = AS_SUCCESS; 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); LOG_FUNC_RETURN (0);
} }
......
...@@ -24,6 +24,7 @@ Description Defines the EMMESM Service Access Point that provides ...@@ -24,6 +24,7 @@ Description Defines the EMMESM Service Access Point that provides
#define __EMM_ESMDEF_H__ #define __EMM_ESMDEF_H__
#include "OctetString.h" #include "OctetString.h"
#include "emmData.h"
/****************************************************************************/ /****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/ /********************* G L O B A L C O N S T A N T S *******************/
...@@ -76,6 +77,9 @@ typedef struct { ...@@ -76,6 +77,9 @@ typedef struct {
typedef struct { typedef struct {
emm_esm_primitive_t primitive; emm_esm_primitive_t primitive;
unsigned int ueid; unsigned int ueid;
#if defined(NAS_MME)
emm_data_context_t *ctx;
#endif
union { union {
emm_esm_establish_t establish; emm_esm_establish_t establish;
emm_esm_data_t data; emm_esm_data_t data;
......
...@@ -23,6 +23,7 @@ Description Defines the EMM Service Access Points at which the EPS ...@@ -23,6 +23,7 @@ Description Defines the EMM Service Access Points at which the EPS
#ifndef __EMM_SAP_H__ #ifndef __EMM_SAP_H__
#define __EMM_SAP_H__ #define __EMM_SAP_H__
#include "emmData.h"
#include "emm_regDef.h" #include "emm_regDef.h"
#include "emm_esmDef.h" #include "emm_esmDef.h"
#include "emm_asDef.h" #include "emm_asDef.h"
......
...@@ -65,7 +65,7 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *); ...@@ -65,7 +65,7 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *);
* retransmission counter */ * retransmission counter */
#define DEDICATED_EPS_BEARER_ACTIVATE_COUNTER_MAX 5 #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); const OctetString *msg);
#endif // NAS_MME #endif // NAS_MME
...@@ -102,7 +102,7 @@ static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi, ...@@ -102,7 +102,7 @@ static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi,
** Others: None ** ** 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 *ebi,
unsigned int *default_ebi, unsigned int *default_ebi,
const esm_proc_qos_t *qos, const esm_proc_qos_t *qos,
...@@ -112,14 +112,14 @@ int esm_proc_dedicated_eps_bearer_context(unsigned int ueid, int pid, ...@@ -112,14 +112,14 @@ int esm_proc_dedicated_eps_bearer_context(unsigned int ueid, int pid,
LOG_FUNC_IN; LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - Dedicated EPS bearer context activation " 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 */ /* 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) { if (*ebi != ESM_EBI_UNASSIGNED) {
/* Create dedicated EPS bearer context */ /* 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) { if (*default_ebi == ESM_EBI_UNASSIGNED) {
/* No resource available */ /* No resource available */
LOG_TRACE(WARNING, "ESM-PROC - Failed to create dedicated EPS " 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, ...@@ -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, 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) OctetString *msg, int ue_triggered)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -170,15 +170,15 @@ int esm_proc_dedicated_eps_bearer_context_request(int is_standalone, ...@@ -170,15 +170,15 @@ int esm_proc_dedicated_eps_bearer_context_request(int is_standalone,
int rc = RETURNok; int rc = RETURNok;
LOG_TRACE(INFO,"ESM-PROC - Initiate dedicated EPS bearer context " 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 /* Send activate dedicated EPS bearer context request message and
* start timer T3485 */ * start timer T3485 */
rc = _dedicated_eps_bearer_activate(ueid, ebi, msg); rc = _dedicated_eps_bearer_activate(ctx, ebi, msg);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Set the EPS bearer context state to ACTIVE PENDING */ /* 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) { if (rc != RETURNok) {
/* The EPS bearer context was already in ACTIVE PENDING state */ /* The EPS bearer context was already in ACTIVE PENDING state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE PENDING", 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, ...@@ -211,7 +211,7 @@ int esm_proc_dedicated_eps_bearer_context_request(int is_standalone,
** Others: None ** ** 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) int *esm_cause)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -219,13 +219,13 @@ int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi, ...@@ -219,13 +219,13 @@ int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi,
int rc; int rc;
LOG_TRACE(INFO, "ESM-PROC - Dedicated EPS bearer context activation " 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 */ /* Stop T3485 timer */
rc = esm_ebr_stop_timer(ueid, ebi); rc = esm_ebr_stop_timer(ctx, ebi);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Set the EPS bearer context state to ACTIVE */ /* 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) { if (rc != RETURNok) {
/* The EPS bearer context was already in ACTIVE state */ /* The EPS bearer context was already in ACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi); 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, ...@@ -262,22 +262,22 @@ int esm_proc_dedicated_eps_bearer_context_accept(unsigned int ueid, int ebi,
** Others: None ** ** 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) int *esm_cause)
{ {
LOG_FUNC_IN;
int rc; int rc;
LOG_FUNC_IN;
LOG_TRACE(WARNING, "ESM-PROC - Dedicated EPS bearer context activation " 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 */ /* Stop T3485 timer if running */
rc = esm_ebr_stop_timer(ueid, ebi); rc = esm_ebr_stop_timer(ctx, ebi);
if (rc != RETURNerror) { if (rc != RETURNerror) {
int pid, bid; int pid, bid;
/* Release the dedicated EPS bearer context and enter state INACTIVE */ /* 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); &pid, &bid, NULL);
if (rc != RETURNok) { if (rc != RETURNok) {
/* Failed to release the dedicated EPS bearer context */ /* Failed to release the dedicated EPS bearer context */
...@@ -558,7 +558,7 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *args) ...@@ -558,7 +558,7 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *args)
if (data->count < DEDICATED_EPS_BEARER_ACTIVATE_COUNTER_MAX) { if (data->count < DEDICATED_EPS_BEARER_ACTIVATE_COUNTER_MAX) {
/* Re-send activate dedicated EPS bearer context request message /* Re-send activate dedicated EPS bearer context request message
* to the UE */ * 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 { } else {
/* /*
* The maximum number of activate dedicated EPS bearer context request * The maximum number of activate dedicated EPS bearer context request
...@@ -566,12 +566,12 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *args) ...@@ -566,12 +566,12 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *args)
*/ */
int pid, bid; int pid, bid;
/* Release the dedicated EPS bearer context and enter state INACTIVE */ /* 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, data->ebi, &pid, &bid,
NULL); NULL);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Stop timer T3485 */ /* 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) ...@@ -601,7 +601,7 @@ static void *_dedicated_eps_bearer_activate_t3485_handler(void *args)
** Others: T3485 ** ** 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) const OctetString *msg)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -615,13 +615,14 @@ static int _dedicated_eps_bearer_activate(unsigned int ueid, int ebi, ...@@ -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_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data;
emm_sap.primitive = EMMESM_UNITDATA_REQ; 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; emm_esm->msg = *msg;
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Start T3485 retransmission timer */ /* 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); _dedicated_eps_bearer_activate_t3485_handler);
} }
......
...@@ -75,7 +75,7 @@ static void *_default_eps_bearer_activate_t3485_handler(void *); ...@@ -75,7 +75,7 @@ static void *_default_eps_bearer_activate_t3485_handler(void *);
* retransmission counter */ * retransmission counter */
#define DEFAULT_EPS_BEARER_ACTIVATE_COUNTER_MAX 5 #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); const OctetString *msg);
#endif // NAS_MME #endif // NAS_MME
...@@ -109,7 +109,7 @@ static int _default_eps_bearer_activate(unsigned int ueid, int ebi, ...@@ -109,7 +109,7 @@ static int _default_eps_bearer_activate(unsigned int ueid, int ebi,
** Others: None ** ** 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, unsigned int *ebi,
const esm_proc_qos_t *qos, const esm_proc_qos_t *qos,
int *esm_cause) int *esm_cause)
...@@ -117,14 +117,14 @@ int esm_proc_default_eps_bearer_context(unsigned int ueid, int pid, ...@@ -117,14 +117,14 @@ int esm_proc_default_eps_bearer_context(unsigned int ueid, int pid,
LOG_FUNC_IN; LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - Default EPS bearer context activation " 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 */ /* 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) { if (*ebi != ESM_EBI_UNASSIGNED) {
/* Create default EPS bearer context */ /* 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) { if (*ebi == ESM_EBI_UNASSIGNED) {
/* No resource available */ /* No resource available */
LOG_TRACE(WARNING, "ESM-PROC - Failed to create new default EPS " 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, ...@@ -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, 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) OctetString *msg, int ue_triggered)
{ {
LOG_FUNC_IN;
int rc = RETURNok; int rc = RETURNok;
LOG_FUNC_IN;
LOG_TRACE(INFO,"ESM-PROC - Initiate default EPS bearer context activation " 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) { if (is_standalone) {
/* Send activate default EPS bearer context request message and /* Send activate default EPS bearer context request message and
* start timer T3485 */ * start timer T3485 */
rc = _default_eps_bearer_activate(ueid, ebi, msg); rc = _default_eps_bearer_activate(ctx, ebi, msg);
} }
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Set the EPS bearer context state to ACTIVE PENDING */ /* 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) { if (rc != RETURNok) {
/* The EPS bearer context was already in ACTIVE PENDING state */ /* The EPS bearer context was already in ACTIVE PENDING state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE PENDING", 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, ...@@ -221,7 +221,7 @@ int esm_proc_default_eps_bearer_context_request(int is_standalone,
** Others: None ** ** 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) int *esm_cause)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -229,13 +229,13 @@ int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi, ...@@ -229,13 +229,13 @@ int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi,
int rc; int rc;
LOG_TRACE(INFO, "ESM-PROC - Default EPS bearer context activation " 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 */ /* Stop T3485 timer if running */
rc = esm_ebr_stop_timer(ueid, ebi); rc = esm_ebr_stop_timer(ctx, ebi);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Set the EPS bearer context state to ACTIVE */ /* 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) { if (rc != RETURNok) {
/* The EPS bearer context was already in ACTIVE state */ /* The EPS bearer context was already in ACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already ACTIVE", ebi); 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, ...@@ -268,7 +268,7 @@ int esm_proc_default_eps_bearer_context_accept(unsigned int ueid, int ebi,
** Others: None ** ** 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) int *esm_cause)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -276,14 +276,14 @@ int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi, ...@@ -276,14 +276,14 @@ int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi,
int rc; int rc;
LOG_TRACE(WARNING, "ESM-PROC - Default EPS bearer context activation " 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 */ /* Stop T3485 timer if running */
rc = esm_ebr_stop_timer(ueid, ebi); rc = esm_ebr_stop_timer(ctx, ebi);
if (rc != RETURNerror) { if (rc != RETURNerror) {
int pid, bid; int pid, bid;
/* Release the default EPS bearer context and enter state INACTIVE */ /* 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); &pid, &bid, NULL);
if (rc != RETURNok) { if (rc != RETURNok) {
/* Failed to release the default EPS bearer context */ /* 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, ...@@ -318,23 +318,23 @@ int esm_proc_default_eps_bearer_context_reject(unsigned int ueid, int ebi,
** Others: None ** ** 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 rc = RETURNerror;
int pid; int pid;
LOG_FUNC_IN;
LOG_TRACE(WARNING, "ESM-PROC - Default EPS bearer context activation " 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 /* Get the EPS bearer identity of the EPS bearer context which is still
* pending in the active pending state */ * 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) { if (ebi != ESM_EBI_UNASSIGNED) {
int bid; int bid;
/* Release the default EPS bearer context and enter state INACTIVE */ /* 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); &pid, &bid, NULL);
} }
...@@ -680,7 +680,7 @@ static void *_default_eps_bearer_activate_t3485_handler(void *args) ...@@ -680,7 +680,7 @@ static void *_default_eps_bearer_activate_t3485_handler(void *args)
if (data->count < DEFAULT_EPS_BEARER_ACTIVATE_COUNTER_MAX) { if (data->count < DEFAULT_EPS_BEARER_ACTIVATE_COUNTER_MAX) {
/* Re-send activate default EPS bearer context request message /* Re-send activate default EPS bearer context request message
* to the UE */ * 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 { } else {
/* /*
* The maximum number of activate default EPS bearer context request * The maximum number of activate default EPS bearer context request
...@@ -688,12 +688,12 @@ static void *_default_eps_bearer_activate_t3485_handler(void *args) ...@@ -688,12 +688,12 @@ static void *_default_eps_bearer_activate_t3485_handler(void *args)
*/ */
int pid, bid; int pid, bid;
/* Release the default EPS bearer context and enter state INACTIVE */ /* 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, data->ebi, &pid, &bid,
NULL); NULL);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Stop timer T3485 */ /* 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) ...@@ -723,7 +723,7 @@ static void *_default_eps_bearer_activate_t3485_handler(void *args)
** Others: T3485 ** ** 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) const OctetString *msg)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -737,13 +737,14 @@ static int _default_eps_bearer_activate(unsigned int ueid, int ebi, ...@@ -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_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data;
emm_sap.primitive = EMMESM_UNITDATA_REQ; 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; emm_esm->msg = *msg;
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Start T3485 retransmission timer */ /* 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); _default_eps_bearer_activate_t3485_handler);
} }
......
...@@ -31,6 +31,7 @@ Description Defines the EPS bearer context deactivation ESM procedure ...@@ -31,6 +31,7 @@ Description Defines the EPS bearer context deactivation ESM procedure
#include "commonDef.h" #include "commonDef.h"
#include "nas_log.h" #include "nas_log.h"
#include "emmData.h"
#include "esmData.h" #include "esmData.h"
#include "esm_cause.h" #include "esm_cause.h"
#include "esm_ebr.h" #include "esm_ebr.h"
...@@ -77,9 +78,9 @@ static void *_eps_bearer_deactivate_t3495_handler(void *); ...@@ -77,9 +78,9 @@ static void *_eps_bearer_deactivate_t3495_handler(void *);
* retransmission counter */ * retransmission counter */
#define EPS_BEARER_DEACTIVATE_COUNTER_MAX 5 #define EPS_BEARER_DEACTIVATE_COUNTER_MAX 5
static int _eps_bearer_deactivate(unsigned int ueid, int ebi, static int _eps_bearer_deactivate(emm_data_context_t *ctx, int ebi,
const OctetString *msg); const OctetString *msg);
static int _eps_bearer_release(unsigned int ueid, int ebi, int *pid, int *bid); static int _eps_bearer_release(emm_data_context_t *ctx, int ebi, int *pid, int *bid);
#endif // NAS_MME #endif // NAS_MME
...@@ -121,24 +122,24 @@ static int _eps_bearer_release(unsigned int ueid, int ebi, int *pid, int *bid); ...@@ -121,24 +122,24 @@ static int _eps_bearer_release(unsigned int ueid, int ebi, int *pid, int *bid);
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local, int esm_proc_eps_bearer_context_deactivate(emm_data_context_t *ctx, int is_local,
int ebi, int *pid, int *bid, int ebi, int *pid, int *bid,
int *esm_cause) int *esm_cause)
{ {
LOG_FUNC_IN;
int rc = RETURNerror; int rc = RETURNerror;
LOG_FUNC_IN;
if (is_local) { if (is_local) {
if (ebi != ESM_SAP_ALL_EBI) { if (ebi != ESM_SAP_ALL_EBI) {
/* Locally release the specified EPS bearer context */ /* Locally release the specified EPS bearer context */
rc = _eps_bearer_release(ueid, ebi, pid, bid); rc = _eps_bearer_release(ctx, ebi, pid, bid);
} else if ( (ueid < ESM_DATA_NB_UE_MAX) && _esm_data.ctx[ueid] ) { } else if (ctx != NULL) {
/* Locally release all the EPS bearer contexts */ /* Locally release all the EPS bearer contexts */
*bid = 0; *bid = 0;
for (*pid = 0; *pid < ESM_DATA_PDN_MAX; (*pid)++) { for (*pid = 0; *pid < ESM_DATA_PDN_MAX; (*pid)++) {
if (_esm_data.ctx[ueid]->pdn[*pid].data) { if (ctx->esm_data_ctx.pdn[*pid].data) {
rc = _eps_bearer_release(ueid, ESM_EBI_UNASSIGNED, rc = _eps_bearer_release(ctx, ESM_EBI_UNASSIGNED,
pid, bid); pid, bid);
if (rc != RETURNok) { if (rc != RETURNok) {
break; break;
...@@ -150,26 +151,28 @@ int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local, ...@@ -150,26 +151,28 @@ int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local,
} }
LOG_TRACE(INFO, "ESM-PROC - EPS bearer context deactivation " LOG_TRACE(INFO, "ESM-PROC - EPS bearer context deactivation "
"(ueid=%u, ebi=%d)", ueid, ebi); "(ueid=%u, ebi=%d)", ctx->ueid, ebi);
if ( (ueid < ESM_DATA_NB_UE_MAX) && (_esm_data.ctx[ueid] != NULL) && if ((ctx != NULL) &&
(*pid < ESM_DATA_PDN_MAX) ) { (*pid < ESM_DATA_PDN_MAX) ) {
if (_esm_data.ctx[ueid]->pdn[*pid].pid != *pid) { if (ctx->esm_data_ctx.pdn[*pid].pid != *pid) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier %d " LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier %d "
"is not valid", *pid); "is not valid", *pid);
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR; *esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
} else if (_esm_data.ctx[ueid]->pdn[*pid].data == NULL) { } else if (ctx->esm_data_ctx.pdn[*pid].data == NULL) {
LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been " LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been "
"allocated", *pid); "allocated", *pid);
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR; *esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
} else if (!_esm_data.ctx[ueid]->pdn[*pid].is_active) { } else if (!ctx->esm_data_ctx.pdn[*pid].is_active) {
LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d is not active", LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d is not active",
*pid); *pid);
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR; *esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
} else { } else {
int i; int i;
esm_pdn_t *pdn = ctx->esm_data_ctx.pdn[*pid].data;
*esm_cause = ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY; *esm_cause = ESM_CAUSE_INVALID_EPS_BEARER_IDENTITY;
esm_pdn_t *pdn = _esm_data.ctx[ueid]->pdn[*pid].data;
for (i = 0; i < pdn->n_bearers; i++) { for (i = 0; i < pdn->n_bearers; i++) {
if (pdn->bearer[i]->ebi != ebi) { if (pdn->bearer[i]->ebi != ebi) {
continue; continue;
...@@ -209,7 +212,7 @@ int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local, ...@@ -209,7 +212,7 @@ int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local,
** ** ** **
***************************************************************************/ ***************************************************************************/
int esm_proc_eps_bearer_context_deactivate_request(int is_standalone, int esm_proc_eps_bearer_context_deactivate_request(int is_standalone,
unsigned int ueid, int ebi, emm_data_context_t *ctx, int ebi,
OctetString *msg, int ue_triggered) OctetString *msg, int ue_triggered)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -217,15 +220,15 @@ int esm_proc_eps_bearer_context_deactivate_request(int is_standalone, ...@@ -217,15 +220,15 @@ int esm_proc_eps_bearer_context_deactivate_request(int is_standalone,
int rc; int rc;
LOG_TRACE(INFO,"ESM-PROC - Initiate EPS bearer context deactivation " LOG_TRACE(INFO,"ESM-PROC - Initiate EPS bearer context deactivation "
"(ueid=%d, ebi=%d)", ueid, ebi); "(ueid=%d, ebi=%d)", ctx->ueid, ebi);
/* Send deactivate EPS bearer context request message and /* Send deactivate EPS bearer context request message and
* start timer T3495 */ * start timer T3495 */
rc = _eps_bearer_deactivate(ueid, ebi, msg); rc = _eps_bearer_deactivate(ctx, ebi, msg);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Set the EPS bearer context state to ACTIVE PENDING */ /* Set the EPS bearer context state to ACTIVE PENDING */
rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_INACTIVE_PENDING, rc = esm_ebr_set_status(ctx, ebi, ESM_EBR_INACTIVE_PENDING,
ue_triggered); ue_triggered);
if (rc != RETURNok) { if (rc != RETURNok) {
/* The EPS bearer context was already in ACTIVE state */ /* The EPS bearer context was already in ACTIVE state */
...@@ -261,7 +264,7 @@ int esm_proc_eps_bearer_context_deactivate_request(int is_standalone, ...@@ -261,7 +264,7 @@ int esm_proc_eps_bearer_context_deactivate_request(int is_standalone,
** Others: T3495 ** ** Others: T3495 **
** ** ** **
***************************************************************************/ ***************************************************************************/
int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi, int esm_proc_eps_bearer_context_deactivate_accept(emm_data_context_t *ctx, int ebi,
int *esm_cause) int *esm_cause)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -270,14 +273,14 @@ int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi, ...@@ -270,14 +273,14 @@ int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi,
int pid = RETURNerror; int pid = RETURNerror;
LOG_TRACE(INFO, "ESM-PROC - EPS bearer context deactivation " LOG_TRACE(INFO, "ESM-PROC - EPS bearer context deactivation "
"accepted by the UE (ueid=%u, ebi=%d)", ueid, ebi); "accepted by the UE (ueid=%u, ebi=%d)", ctx->ueid, ebi);
/* Stop T3495 timer if running */ /* Stop T3495 timer if running */
rc = esm_ebr_stop_timer(ueid, ebi); rc = esm_ebr_stop_timer(ctx, ebi);
if (rc != RETURNerror) { if (rc != RETURNerror) {
int bid; int bid;
/* Release the EPS bearer context */ /* Release the EPS bearer context */
rc = _eps_bearer_release(ueid, ebi, &pid, &bid); rc = _eps_bearer_release(ctx, ebi, &pid, &bid);
if (rc != RETURNok) { if (rc != RETURNok) {
/* Failed to release the EPS bearer context */ /* Failed to release the EPS bearer context */
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR; *esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
...@@ -567,7 +570,7 @@ static void *_eps_bearer_deactivate_t3495_handler(void *args) ...@@ -567,7 +570,7 @@ static void *_eps_bearer_deactivate_t3495_handler(void *args)
if (data->count < EPS_BEARER_DEACTIVATE_COUNTER_MAX) { if (data->count < EPS_BEARER_DEACTIVATE_COUNTER_MAX) {
/* Re-send deactivate EPS bearer context request message to the UE */ /* Re-send deactivate EPS bearer context request message to the UE */
rc = _eps_bearer_deactivate(data->ueid, data->ebi, &data->msg); rc = _eps_bearer_deactivate(data->ctx, data->ebi, &data->msg);
} else { } else {
/* /*
* The maximum number of deactivate EPS bearer context request * The maximum number of deactivate EPS bearer context request
...@@ -576,10 +579,10 @@ static void *_eps_bearer_deactivate_t3495_handler(void *args) ...@@ -576,10 +579,10 @@ static void *_eps_bearer_deactivate_t3495_handler(void *args)
int pid, bid; int pid, bid;
/* Deactivate the EPS bearer context locally without peer-to-peer /* Deactivate the EPS bearer context locally without peer-to-peer
* signalling between the UE and the MME */ * signalling between the UE and the MME */
rc = _eps_bearer_release(data->ueid, data->ebi, &pid, &bid); rc = _eps_bearer_release(data->ctx, data->ebi, &pid, &bid);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Stop timer T3495 */ /* Stop timer T3495 */
rc = esm_ebr_stop_timer(data->ueid, data->ebi); rc = esm_ebr_stop_timer(data->ctx, data->ebi);
} }
} }
...@@ -611,7 +614,7 @@ static void *_eps_bearer_deactivate_t3495_handler(void *args) ...@@ -611,7 +614,7 @@ static void *_eps_bearer_deactivate_t3495_handler(void *args)
** Others: T3495 ** ** Others: T3495 **
** ** ** **
***************************************************************************/ ***************************************************************************/
static int _eps_bearer_deactivate(unsigned int ueid, int ebi, static int _eps_bearer_deactivate(emm_data_context_t *ctx, int ebi,
const OctetString *msg) const OctetString *msg)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -625,13 +628,14 @@ static int _eps_bearer_deactivate(unsigned int ueid, int ebi, ...@@ -625,13 +628,14 @@ static int _eps_bearer_deactivate(unsigned int ueid, int ebi,
*/ */
emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data; emm_esm_data_t *emm_esm = &emm_sap.u.emm_esm.u.data;
emm_sap.primitive = EMMESM_UNITDATA_REQ; 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; emm_esm->msg = *msg;
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Start T3495 retransmission timer */ /* Start T3495 retransmission timer */
rc = esm_ebr_start_timer(ueid, ebi, msg, T3495_DEFAULT_VALUE, rc = esm_ebr_start_timer(ctx, ebi, msg, T3495_DEFAULT_VALUE,
_eps_bearer_deactivate_t3495_handler); _eps_bearer_deactivate_t3495_handler);
} }
...@@ -657,25 +661,25 @@ static int _eps_bearer_deactivate(unsigned int ueid, int ebi, ...@@ -657,25 +661,25 @@ static int _eps_bearer_deactivate(unsigned int ueid, int ebi,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
static int _eps_bearer_release(unsigned int ueid, int ebi, int *pid, int *bid) static int _eps_bearer_release(emm_data_context_t *ctx, int ebi, int *pid, int *bid)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
int rc = RETURNerror; int rc = RETURNerror;
/* Release the EPS bearer context entry */ /* Release the EPS bearer context entry */
ebi = esm_ebr_context_release(ueid, ebi, pid, bid); ebi = esm_ebr_context_release(ctx, ebi, pid, bid);
if (ebi == ESM_EBI_UNASSIGNED) { if (ebi == ESM_EBI_UNASSIGNED) {
LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer context"); LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer context");
} else { } else {
/* Set the EPS bearer context state to INACTIVE */ /* Set the EPS bearer context state to INACTIVE */
rc = esm_ebr_set_status(ueid, ebi, ESM_EBR_INACTIVE, FALSE); rc = esm_ebr_set_status(ctx, ebi, ESM_EBR_INACTIVE, FALSE);
if (rc != RETURNok) { if (rc != RETURNok) {
/* The EPS bearer context was already in INACTIVE state */ /* The EPS bearer context was already in INACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already INACTIVE", ebi); LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already INACTIVE", ebi);
} else { } else {
/* Release EPS bearer data */ /* Release EPS bearer data */
rc = esm_ebr_release(ueid, ebi); rc = esm_ebr_release(ctx, ebi);
if (rc != RETURNok) { if (rc != RETURNok) {
LOG_TRACE(WARNING, LOG_TRACE(WARNING,
"ESM-PROC - Failed to release EPS bearer data"); "ESM-PROC - Failed to release EPS bearer data");
......
...@@ -73,7 +73,7 @@ Description Defines the ESM status procedure executed by the Non-Access ...@@ -73,7 +73,7 @@ Description Defines the ESM status procedure executed by the Non-Access
***************************************************************************/ ***************************************************************************/
int esm_proc_status_ind( int esm_proc_status_ind(
#ifdef NAS_MME #ifdef NAS_MME
unsigned int ueid, emm_data_context_t *ctx,
#endif #endif
int pti, int ebi, int *esm_cause) int pti, int ebi, int *esm_cause)
{ {
...@@ -148,7 +148,7 @@ int esm_proc_status_ind( ...@@ -148,7 +148,7 @@ int esm_proc_status_ind(
***************************************************************************/ ***************************************************************************/
int esm_proc_status(int is_standalone, int esm_proc_status(int is_standalone,
#ifdef NAS_MME #ifdef NAS_MME
unsigned int ueid, emm_data_context_t *ctx,
#endif #endif
int ebi, OctetString *msg, int ebi, OctetString *msg,
int ue_triggered) int ue_triggered)
...@@ -168,7 +168,8 @@ int esm_proc_status(int is_standalone, ...@@ -168,7 +168,8 @@ int esm_proc_status(int is_standalone,
emm_sap.u.emm_esm.ueid = 0; emm_sap.u.emm_esm.ueid = 0;
#endif #endif
#ifdef NAS_MME #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 #endif
emm_sap.u.emm_esm.u.data.msg.length = msg->length; emm_sap.u.emm_esm.u.data.msg.length = msg->length;
emm_sap.u.emm_esm.u.data.msg.value = msg->value; emm_sap.u.emm_esm.u.data.msg.value = msg->value;
......
...@@ -29,6 +29,9 @@ Description Defines the PDN connectivity ESM procedure executed by the ...@@ -29,6 +29,9 @@ Description Defines the PDN connectivity ESM procedure executed by the
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> // malloc, free
#include <string.h> // memset, memcpy, memcmp
#include "esm_proc.h" #include "esm_proc.h"
#include "commonDef.h" #include "commonDef.h"
#include "nas_log.h" #include "nas_log.h"
...@@ -38,13 +41,14 @@ Description Defines the PDN connectivity ESM procedure executed by the ...@@ -38,13 +41,14 @@ Description Defines the PDN connectivity ESM procedure executed by the
#include "esm_pt.h" #include "esm_pt.h"
#ifdef NAS_MME #ifdef NAS_MME
#include "mme_api.h" # include "mme_api.h"
#endif #endif
#include "emm_sap.h" #include "emm_sap.h"
#include <stdlib.h> // malloc, free #if defined(ENABLE_ITTI)
#include <string.h> // memset, memcpy, memcmp # include "assertions.h"
#endif
/****************************************************************************/ /****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/
...@@ -93,10 +97,13 @@ static void *_pdn_connectivity_t3482_handler(void *); ...@@ -93,10 +97,13 @@ static void *_pdn_connectivity_t3482_handler(void *);
/* /*
* PDN connection handlers * PDN connection handlers
*/ */
static int _pdn_connectivity_create(unsigned int ueid, int pti, static int _pdn_connectivity_create(emm_data_context_t *ctx,
const OctetString *apn, esm_proc_pdn_type_t pdn_type, int pti,
const OctetString *pdn_addr, int is_emergency); const OctetString *apn,
int _pdn_connectivity_delete(unsigned int ueid, int pid); esm_proc_pdn_type_t pdn_type,
const OctetString *pdn_addr,
int is_emergency);
int _pdn_connectivity_delete(emm_data_context_t *ctx, int pid);
#endif // NAS_MME #endif // NAS_MME
...@@ -588,7 +595,7 @@ int esm_proc_pdn_connectivity_failure(int is_pending) ...@@ -588,7 +595,7 @@ int esm_proc_pdn_connectivity_failure(int is_pending)
** Others: _esm_data ** ** Others: _esm_data **
** ** ** **
***************************************************************************/ ***************************************************************************/
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, esm_proc_pdn_request_t request_type,
OctetString *apn, OctetString *apn,
esm_proc_pdn_type_t pdn_type, esm_proc_pdn_type_t pdn_type,
...@@ -596,22 +603,24 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti, ...@@ -596,22 +603,24 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti,
esm_proc_qos_t *esm_qos, esm_proc_qos_t *esm_qos,
int *esm_cause) int *esm_cause)
{ {
LOG_FUNC_IN;
int rc = RETURNerror; int rc = RETURNerror;
int pid = RETURNerror; int pid = RETURNerror;
LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - PDN connectivity requested by the UE " LOG_TRACE(INFO, "ESM-PROC - PDN connectivity requested by the UE "
"(ueid=%u, pti=%d) PDN type = %s, APN = %s", ueid, pti, "(ueid=%u, pti=%d) PDN type = %s, APN = %s", ctx->ueid, pti,
(pdn_type == ESM_PDN_TYPE_IPV4)? "IPv4" : (pdn_type == ESM_PDN_TYPE_IPV4)? "IPv4" :
(pdn_type == ESM_PDN_TYPE_IPV6)? "IPv6" : "IPv4v6", (pdn_type == ESM_PDN_TYPE_IPV6)? "IPv6" : "IPv4v6",
(apn)? (char *)(apn->value) : "null"); (apn) ? (char *)(apn->value) : "null");
#if !defined(EPC_BUILD)
/* UE identifier sanity check */ /* UE identifier sanity check */
if (ueid >= ESM_DATA_NB_UE_MAX) { if (ctx->ueid >= ESM_DATA_NB_UE_MAX) {
LOG_TRACE(WARNING, "ESM-PROC - Number of connected UEs exceeded"); LOG_TRACE(WARNING, "ESM-PROC - Number of connected UEs exceeded");
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
#endif
/* /*
* Check network IP capabilities * Check network IP capabilities
...@@ -659,24 +668,17 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti, ...@@ -659,24 +668,17 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti,
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
/* Create new ESM context for the UE within the MME */
if (_esm_data.ctx[ueid] == NULL) { /* Create new PDN connection */
_esm_data.ctx[ueid] = pid = _pdn_connectivity_create(ctx, pti, apn, pdn_type,
(esm_data_context_t *)malloc(sizeof(esm_data_context_t)); pdn_addr, is_emergency);
memset(_esm_data.ctx[ueid], 0 , sizeof(esm_data_context_t)); /* Setup ESM QoS parameters */
} if (esm_qos) {
if (_esm_data.ctx[ueid]) { esm_qos->gbrUL = qos.gbr[MME_API_UPLINK];
/* Create new PDN connection */ esm_qos->gbrDL = qos.gbr[MME_API_DOWNLINK];
pid = _pdn_connectivity_create(ueid, pti, apn, pdn_type, esm_qos->mbrUL = qos.mbr[MME_API_UPLINK];
pdn_addr, is_emergency); esm_qos->mbrDL = qos.mbr[MME_API_DOWNLINK];
/* Setup ESM QoS parameters */ esm_qos->qci = qos.qci;
if (esm_qos) {
esm_qos->gbrUL = qos.gbr[MME_API_UPLINK];
esm_qos->gbrDL = qos.gbr[MME_API_DOWNLINK];
esm_qos->mbrUL = qos.mbr[MME_API_UPLINK];
esm_qos->mbrDL = qos.mbr[MME_API_DOWNLINK];
esm_qos->qci = qos.qci;
}
} }
if (pid < 0) { if (pid < 0) {
...@@ -716,7 +718,7 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti, ...@@ -716,7 +718,7 @@ int esm_proc_pdn_connectivity_request(unsigned int ueid, int pti,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
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 ebi, OctetString *msg, int ue_triggered)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -724,7 +726,7 @@ int esm_proc_pdn_connectivity_reject(int is_standalone, unsigned int ueid, ...@@ -724,7 +726,7 @@ int esm_proc_pdn_connectivity_reject(int is_standalone, unsigned int ueid,
int rc = RETURNerror; int rc = RETURNerror;
LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity not accepted by the " LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity not accepted by the "
"network (ueid=%d)", ueid); "network (ueid=%d)", ctx->ueid);
if (is_standalone) { if (is_standalone) {
emm_sap_t emm_sap; emm_sap_t emm_sap;
...@@ -732,7 +734,7 @@ int esm_proc_pdn_connectivity_reject(int is_standalone, unsigned int ueid, ...@@ -732,7 +734,7 @@ int esm_proc_pdn_connectivity_reject(int is_standalone, unsigned int ueid,
* Notity EMM that ESM PDU has to be forwarded to lower layers * Notity EMM that ESM PDU has to be forwarded to lower layers
*/ */
emm_sap.primitive = EMMESM_UNITDATA_REQ; emm_sap.primitive = EMMESM_UNITDATA_REQ;
emm_sap.u.emm_esm.ueid = 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.length = msg->length;
emm_sap.u.emm_esm.u.data.msg.value = msg->value; emm_sap.u.emm_esm.u.data.msg.value = msg->value;
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
...@@ -746,35 +748,37 @@ int esm_proc_pdn_connectivity_reject(int is_standalone, unsigned int ueid, ...@@ -746,35 +748,37 @@ int esm_proc_pdn_connectivity_reject(int is_standalone, unsigned int ueid,
/**************************************************************************** /****************************************************************************
** ** ** **
** Name: esm_proc_pdn_connectivity_failure() ** ** Name: esm_proc_pdn_connectivity_failure() **
** ** ** **
** Description: Performs PDN connectivity procedure upon receiving noti- ** ** Description: Performs PDN connectivity procedure upon receiving noti- **
** fication from the EPS Mobility Management sublayer that ** ** fication from the EPS Mobility Management sublayer that **
** EMM procedure that initiated PDN connectivity activation ** ** EMM procedure that initiated PDN connectivity activation **
** locally failed. ** ** locally failed. **
** ** ** **
** The MME releases the PDN connection entry allocated when ** ** The MME releases the PDN connection entry allocated when **
** the PDN connectivity procedure was requested by the UE. ** ** the PDN connectivity procedure was requested by the UE. **
** ** ** **
** Inputs: ueid: UE local identifier ** ** Inputs: ueid: UE local identifier **
** pid: Identifier of the PDN connection to be ** ** pid: Identifier of the PDN connection to be **
** released ** ** released **
** Others: None ** ** Others: None **
** ** ** **
** Outputs: None ** ** Outputs: None **
** Return: RETURNok, RETURNerror ** ** Return: RETURNok, RETURNerror **
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int esm_proc_pdn_connectivity_failure(unsigned int ueid, int pid) int esm_proc_pdn_connectivity_failure(emm_data_context_t *ctx, int pid)
{ {
int pti;
LOG_FUNC_IN; LOG_FUNC_IN;
LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity failure (ueid=%u, pid=%d)", LOG_TRACE(WARNING, "ESM-PROC - PDN connectivity failure (ueid=%u, pid=%d)",
ueid, pid); ctx->ueid, pid);
/* Delete the PDN connection entry */ /* Delete the PDN connection entry */
int pti = _pdn_connectivity_delete(ueid, pid); pti = _pdn_connectivity_delete(ctx, pid);
if (pti != ESM_PT_UNASSIGNED) { if (pti != ESM_PT_UNASSIGNED) {
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} }
...@@ -1229,26 +1233,28 @@ static int _pdn_connectivity_find_pdn(const OctetString *apn, ...@@ -1229,26 +1233,28 @@ static int _pdn_connectivity_find_pdn(const OctetString *apn,
*/ */
/**************************************************************************** /****************************************************************************
** ** ** **
** Name: _pdn_connectivity_create() ** ** Name: _pdn_connectivity_create() **
** ** ** **
** Description: Creates a new PDN connection entry for the specified UE ** ** Description: Creates a new PDN connection entry for the specified UE **
** ** ** **
** Inputs: ueid: UE local identifier ** ** Inputs: ueid: UE local identifier **
** pti: Procedure transaction identity ** ** ctx: UE context **
** apn: Access Point Name of the PDN connection ** ** pti: Procedure transaction identity **
** pdn_type: PDN type (IPv4, IPv6, IPv4v6) ** ** apn: Access Point Name of the PDN connection **
** pdn_addr: Network allocated PDN IPv4 or IPv6 address ** ** pdn_type: PDN type (IPv4, IPv6, IPv4v6) **
** is_emergency: TRUE if the PDN connection has to be esta- ** ** pdn_addr: Network allocated PDN IPv4 or IPv6 address **
** blished for emergency bearer services ** ** is_emergency: TRUE if the PDN connection has to be esta- **
** Others: _esm_data ** ** blished for emergency bearer services **
** Others: _esm_data **
** ** ** **
** Outputs: None ** ** Outputs: None **
** Return: The identifier of the PDN connection if ** ** Return: The identifier of the PDN connection if **
** successfully created; -1 otherwise. ** ** successfully created; -1 otherwise. **
** Others: _esm_data ** ** Others: _esm_data **
** ** ** **
***************************************************************************/ ***************************************************************************/
static int _pdn_connectivity_create(unsigned int ueid, int pti, static int _pdn_connectivity_create(emm_data_context_t *ctx,
int pti,
const OctetString *apn, const OctetString *apn,
esm_proc_pdn_type_t pdn_type, esm_proc_pdn_type_t pdn_type,
const OctetString *pdn_addr, const OctetString *pdn_addr,
...@@ -1260,25 +1266,14 @@ static int _pdn_connectivity_create(unsigned int ueid, int pti, ...@@ -1260,25 +1266,14 @@ static int _pdn_connectivity_create(unsigned int ueid, int pti,
"(pti=%d) APN = %s, IP address = %s (ueid=%u)", pti, apn->value, "(pti=%d) APN = %s, IP address = %s (ueid=%u)", pti, apn->value,
(pdn_type == ESM_PDN_TYPE_IPV4)? esm_data_get_ipv4_addr(pdn_addr) : (pdn_type == ESM_PDN_TYPE_IPV4)? esm_data_get_ipv4_addr(pdn_addr) :
(pdn_type == ESM_PDN_TYPE_IPV6)? esm_data_get_ipv6_addr(pdn_addr) : (pdn_type == ESM_PDN_TYPE_IPV6)? esm_data_get_ipv6_addr(pdn_addr) :
esm_data_get_ipv4v6_addr(pdn_addr), ueid); esm_data_get_ipv4v6_addr(pdn_addr), ctx->ueid);
if (ueid < ESM_DATA_NB_UE_MAX) { /* Search for an available PDN connection entry */
if (_esm_data.ctx[ueid] == NULL) { for (pid = 0; pid < ESM_DATA_PDN_MAX; pid++) {
LOG_TRACE(ERROR, "ESM-PROC - ESM context has not been allocated"); if (ctx->esm_data_ctx.pdn[pid].data != NULL) {
} else if (_esm_data.ctx[ueid]->n_pdns > ESM_DATA_PDN_MAX) { continue;
LOG_TRACE(WARNING, "ESM-PROC - Number of PDN connection exceeded");
} else if (_esm_data.ctx[ueid]->emergency && is_emergency) {
LOG_TRACE(WARNING, "ESM-PROC - PDN connection for emergency bearer "
"services already established");
} else {
/* Search for an available PDN connection entry */
for (pid = 0; pid < ESM_DATA_PDN_MAX; pid++) {
if (_esm_data.ctx[ueid]->pdn[pid].data != NULL) {
continue;
}
break;
}
} }
break;
} }
if (pid < ESM_DATA_PDN_MAX) { if (pid < ESM_DATA_PDN_MAX) {
...@@ -1287,13 +1282,13 @@ static int _pdn_connectivity_create(unsigned int ueid, int pti, ...@@ -1287,13 +1282,13 @@ static int _pdn_connectivity_create(unsigned int ueid, int pti,
if (pdn != NULL) { if (pdn != NULL) {
memset(pdn, 0, sizeof(esm_pdn_t)); memset(pdn, 0, sizeof(esm_pdn_t));
/* Increment the number of PDN connections */ /* Increment the number of PDN connections */
_esm_data.ctx[ueid]->n_pdns += 1; ctx->esm_data_ctx.n_pdns += 1;
/* Set the PDN connection identifier */ /* Set the PDN connection identifier */
_esm_data.ctx[ueid]->pdn[pid].pid = pid; ctx->esm_data_ctx.pdn[pid].pid = pid;
/* Reset the PDN connection active indicator */ /* Reset the PDN connection active indicator */
_esm_data.ctx[ueid]->pdn[pid].is_active = FALSE; ctx->esm_data_ctx.pdn[pid].is_active = FALSE;
/* Setup the PDN connection data */ /* Setup the PDN connection data */
_esm_data.ctx[ueid]->pdn[pid].data = pdn; ctx->esm_data_ctx.pdn[pid].data = pdn;
/* Set the procedure transaction identity */ /* Set the procedure transaction identity */
pdn->pti = pti; pdn->pti = pti;
...@@ -1317,7 +1312,7 @@ static int _pdn_connectivity_create(unsigned int ueid, int pti, ...@@ -1317,7 +1312,7 @@ static int _pdn_connectivity_create(unsigned int ueid, int pti,
pdn->type = pdn_type; pdn->type = pdn_type;
} }
/* Return the identifier of the new PDN connection */ /* Return the identifier of the new PDN connection */
return (_esm_data.ctx[ueid]->pdn[pid].pid); return (ctx->esm_data_ctx.pdn[pid].pid);
} }
LOG_TRACE(WARNING, "ESM-PROC - Failed to create new PDN connection " LOG_TRACE(WARNING, "ESM-PROC - Failed to create new PDN connection "
"(pid=%d)", pid); "(pid=%d)", pid);
...@@ -1328,59 +1323,59 @@ static int _pdn_connectivity_create(unsigned int ueid, int pti, ...@@ -1328,59 +1323,59 @@ static int _pdn_connectivity_create(unsigned int ueid, int pti,
/**************************************************************************** /****************************************************************************
** ** ** **
** Name: _pdn_connectivity_delete() ** ** Name: _pdn_connectivity_delete() **
** ** ** **
** Description: Deletes PDN connection to the specified UE associated to ** ** Description: Deletes PDN connection to the specified UE associated to **
** PDN connection entry with given identifier ** ** PDN connection entry with given identifier **
** ** ** **
** Inputs: ueid: UE local identifier ** ** Inputs: ueid: UE local identifier **
** pid: Identifier of the PDN connection to be ** ** pid: Identifier of the PDN connection to be **
** released ** ** released **
** Others: _esm_data ** ** Others: _esm_data **
** ** ** **
** Outputs: None ** ** Outputs: None **
** Return: The identity of the procedure transaction ** ** Return: The identity of the procedure transaction **
** assigned to the PDN connection when suc- ** ** assigned to the PDN connection when suc- **
** cessfully released; ** ** cessfully released; **
** UNASSIGNED value otherwise. ** ** UNASSIGNED value otherwise. **
** Others: _esm_data ** ** Others: _esm_data **
** ** ** **
***************************************************************************/ ***************************************************************************/
int _pdn_connectivity_delete(unsigned int ueid, int pid) int _pdn_connectivity_delete(emm_data_context_t *ctx, int pid)
{ {
int pti = ESM_PT_UNASSIGNED; int pti = ESM_PT_UNASSIGNED;
if (ueid < ESM_DATA_NB_UE_MAX) { if (ctx == NULL) {
if (_esm_data.ctx[ueid] == NULL) { return pti;
LOG_TRACE(ERROR, "ESM-PROC - ESM context has not been allocated"); }
} else if (pid < ESM_DATA_PDN_MAX) {
if (pid != _esm_data.ctx[ueid]->pdn[pid].pid) { if (pid < ESM_DATA_PDN_MAX) {
LOG_TRACE(ERROR, if (pid != ctx->esm_data_ctx.pdn[pid].pid) {
"ESM-PROC - PDN connection identifier is not valid"); LOG_TRACE(ERROR,
} else if (_esm_data.ctx[ueid]->pdn[pid].data == NULL) { "ESM-PROC - PDN connection identifier is not valid");
LOG_TRACE(ERROR, } else if (ctx->esm_data_ctx.pdn[pid].data == NULL) {
"ESM-PROC - PDN connection has not been allocated"); LOG_TRACE(ERROR,
} else if (_esm_data.ctx[ueid]->pdn[pid].is_active) { "ESM-PROC - PDN connection has not been allocated");
LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active"); } else if (ctx->esm_data_ctx.pdn[pid].is_active) {
} else { LOG_TRACE(ERROR, "ESM-PROC - PDN connection is active");
/* Get the identity of the procedure transaction that created } else {
* the PDN connection */ /* Get the identity of the procedure transaction that created
pti = _esm_data.ctx[ueid]->pdn[pid].data->pti; * the PDN connection */
} pti = ctx->esm_data_ctx.pdn[pid].data->pti;
} }
} }
if (pti != ESM_PT_UNASSIGNED) { if (pti != ESM_PT_UNASSIGNED) {
/* Decrement the number of PDN connections */ /* Decrement the number of PDN connections */
_esm_data.ctx[ueid]->n_pdns -= 1; ctx->esm_data_ctx.n_pdns -= 1;
/* Set the PDN connection as available */ /* Set the PDN connection as available */
_esm_data.ctx[ueid]->pdn[pid].pid = -1; ctx->esm_data_ctx.pdn[pid].pid = -1;
/* Release allocated PDN connection data */ /* Release allocated PDN connection data */
if (_esm_data.ctx[ueid]->pdn[pid].data->apn.length > 0) { if (ctx->esm_data_ctx.pdn[pid].data->apn.length > 0) {
free(_esm_data.ctx[ueid]->pdn[pid].data->apn.value); free(ctx->esm_data_ctx.pdn[pid].data->apn.value);
} }
free(_esm_data.ctx[ueid]->pdn[pid].data); free(ctx->esm_data_ctx.pdn[pid].data);
_esm_data.ctx[ueid]->pdn[pid].data = NULL; ctx->esm_data_ctx.pdn[pid].data = NULL;
LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d released", pid); LOG_TRACE(WARNING, "ESM-PROC - PDN connection %d released", pid);
} }
......
...@@ -44,7 +44,7 @@ Description Defines the PDN disconnect ESM procedure executed by the ...@@ -44,7 +44,7 @@ Description Defines the PDN disconnect ESM procedure executed by the
/****************************************************************************/ /****************************************************************************/
#ifdef NAS_MME #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 #endif
/****************************************************************************/ /****************************************************************************/
...@@ -81,7 +81,7 @@ static void *_pdn_disconnect_t3492_handler(void *); ...@@ -81,7 +81,7 @@ static void *_pdn_disconnect_t3492_handler(void *);
/* /*
* PDN disconnection handlers * 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 #endif // NAS_MME
...@@ -368,36 +368,30 @@ int esm_proc_pdn_disconnect_reject(int pti, int *esm_cause) ...@@ -368,36 +368,30 @@ int esm_proc_pdn_disconnect_reject(int pti, int *esm_cause)
** Others: None ** ** 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; int pid = RETURNerror;
LOG_TRACE(INFO, "ESM-PROC - PDN disconnect requested by the UE " LOG_FUNC_IN;
"(ueid=%d, pti=%d)", ueid, pti);
if (ueid < ESM_DATA_NB_UE_MAX) { LOG_TRACE(INFO, "ESM-PROC - PDN disconnect requested by the UE "
/* Get UE's ESM context */ "(ueid=%d, pti=%d)", ctx->ueid, pti);
esm_data_context_t *ctx = _esm_data.ctx[ueid];
if (_esm_data.ctx[ueid] == NULL) { /* Get UE's ESM context */
LOG_TRACE(ERROR, "ESM-PROC - No ESM context exists"); 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; *esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
} else if (ctx->n_pdns > 1) { LOG_FUNC_RETURN (RETURNerror);
/* 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;
} }
} 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); LOG_FUNC_RETURN(pid);
...@@ -425,18 +419,18 @@ int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int *esm_cause) ...@@ -425,18 +419,18 @@ int esm_proc_pdn_disconnect_request(unsigned int ueid, int pti, int *esm_cause)
** Others: None ** ** 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_FUNC_IN;
LOG_TRACE(INFO, "ESM-PROC - PDN disconnect accepted by the UE " 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 */ /* Release the connectivity with the requested PDN */
int rc = mme_api_unsubscribe(NULL); int rc = mme_api_unsubscribe(NULL);
if (rc != RETURNerror) { if (rc != RETURNerror) {
/* Delete the PDN connection entry */ /* Delete the PDN connection entry */
int pti = _pdn_connectivity_delete(ueid, pid); int pti = _pdn_connectivity_delete(ctx, pid);
if (pti != ESM_PT_UNASSIGNED) { if (pti != ESM_PT_UNASSIGNED) {
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} }
...@@ -470,7 +464,7 @@ int esm_proc_pdn_disconnect_accept(unsigned int ueid, int pid, int *esm_cause) ...@@ -470,7 +464,7 @@ int esm_proc_pdn_disconnect_accept(unsigned int ueid, int pid, int *esm_cause)
** Others: None ** ** 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) int ebi, OctetString *msg, int ue_triggered)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -479,13 +473,14 @@ int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid, ...@@ -479,13 +473,14 @@ int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid,
emm_sap_t emm_sap; emm_sap_t emm_sap;
LOG_TRACE(WARNING, "ESM-PROC - PDN disconnect not accepted by the network " 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 * Notity EMM that ESM PDU has to be forwarded to lower layers
*/ */
emm_sap.primitive = EMMESM_UNITDATA_REQ; 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.length = msg->length;
emm_sap.u.emm_esm.u.data.msg.value = msg->value; emm_sap.u.emm_esm.u.data.msg.value = msg->value;
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
...@@ -670,15 +665,15 @@ static int _pdn_disconnect_get_default_ebi(int pti) ...@@ -670,15 +665,15 @@ static int _pdn_disconnect_get_default_ebi(int pti)
** Others: None ** ** 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; 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++) { for (i = 0; i < ESM_DATA_PDN_MAX; i++) {
if ( (_esm_data.ctx[ueid]->pdn[i].pid != -1) && if ( (ctx->pdn[i].pid != -1) &&
(_esm_data.ctx[ueid]->pdn[i].data != NULL) ) { (ctx->pdn[i].data != NULL) ) {
if (_esm_data.ctx[ueid]->pdn[i].data->pti != pti) { if (ctx->pdn[i].data->pti != pti) {
continue; continue;
} }
/* PDN entry found */ /* PDN entry found */
...@@ -688,6 +683,6 @@ static int _pdn_disconnect_get_pid(unsigned int ueid, int pti) ...@@ -688,6 +683,6 @@ static int _pdn_disconnect_get_pid(unsigned int ueid, int pti)
} }
/* Return the identifier of the PDN connection */ /* Return the identifier of the PDN connection */
return (_esm_data.ctx[ueid]->pdn[i].pid); return (ctx->pdn[i].pid);
} }
#endif // NAS_MME #endif // NAS_MME
...@@ -18,17 +18,22 @@ Description Defines internal private data handled by EPS Session ...@@ -18,17 +18,22 @@ Description Defines internal private data handled by EPS Session
Management sublayer. Management sublayer.
*****************************************************************************/ *****************************************************************************/
#ifndef __ESMDATA_H__ #include <stdio.h> // sprintf
#define __ESMDATA_H__
#include "networkDef.h" #include "networkDef.h"
#include "OctetString.h" #include "OctetString.h"
#include "EpsBearerIdentity.h"
#ifdef NAS_MME #ifdef NAS_MME
#include "mme_api.h" #include "mme_api.h"
#endif #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 *******************/ /********************* 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 ...@@ -41,6 +46,67 @@ Description Defines internal private data handled by EPS Session
/************************ G L O B A L T Y P E S ************************/ /************************ 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 * Structure of data handled by EPS Session Management sublayer in the UE
...@@ -101,7 +167,9 @@ typedef struct { ...@@ -101,7 +167,9 @@ typedef struct {
* fault EPS bearer. Several dedicated EPS bearers may exist within * fault EPS bearer. Several dedicated EPS bearers may exist within
* a PDN connection. * 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_ebrs; /* Total number of active EPS bearer contexts */
int n_pdns; /* Number of active PDN connections */ int n_pdns; /* Number of active PDN connections */
int emergency; /* Indicates whether a PDN connection for emergency int emergency; /* Indicates whether a PDN connection for emergency
...@@ -114,6 +182,8 @@ typedef struct { ...@@ -114,6 +182,8 @@ typedef struct {
* connection is in progress */ * connection is in progress */
esm_pdn_t *data; /* Active PDN connection data */ esm_pdn_t *data; /* Active PDN connection data */
} pdn[ESM_DATA_PDN_MAX+1]; } pdn[ESM_DATA_PDN_MAX+1];
esm_ebr_data_t ebr;
} esm_data_context_t; } esm_data_context_t;
/* /*
...@@ -149,11 +219,26 @@ typedef struct { ...@@ -149,11 +219,26 @@ typedef struct {
* ESM contexts * 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]; esm_data_context_t *ctx[ESM_DATA_NB_UE_MAX];
# endif
} esm_data_t; } 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 #endif //NAS_MME
/****************************************************************************/ /****************************************************************************/
......
...@@ -19,26 +19,20 @@ Description Defines functions used to handle state of EPS bearer contexts ...@@ -19,26 +19,20 @@ Description Defines functions used to handle state of EPS bearer contexts
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> // malloc, free
#include <string.h> // memcpy
#include "emmData.h"
#include "esm_ebr.h" #include "esm_ebr.h"
#include "commonDef.h" #include "commonDef.h"
#include "nas_log.h" #include "nas_log.h"
#include "mme_api.h" #include "mme_api.h"
#include <stdlib.h> // malloc, free
#include <string.h> // memcpy
/****************************************************************************/ /****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/ /**************** E X T E R N A L D E F I N I T I O N 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)
#ifdef NAS_UE #ifdef NAS_UE
#define ESM_EBR_NB_UE_MAX 1 #define ESM_EBR_NB_UE_MAX 1
#endif #endif
...@@ -61,37 +55,15 @@ static const char *_esm_ebr_state_str[ESM_EBR_STATE_MAX] = { ...@@ -61,37 +55,15 @@ static const char *_esm_ebr_state_str[ESM_EBR_STATE_MAX] = {
#endif #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;
/* /*
* ---------------------------------- * ----------------------------------
* List of EPS bearer contexts per UE * List of EPS bearer contexts per UE
* ---------------------------------- * ----------------------------------
*/ */
static struct {
unsigned char index; /* Index of the next EPS bearer context #if !defined(EPC_BUILD)
* identity to be used */ static esm_ebr_data_t _esm_ebr_data[ESM_EBR_NB_UE_MAX];
#define ESM_EBR_DATA_SIZE (ESM_EBI_MAX - ESM_EBI_MIN + 1) #endif
esm_ebr_context_t *context[ESM_EBR_DATA_SIZE + 1];
} _esm_ebr_data[ESM_EBR_NB_UE_MAX];
/* /*
* ---------------------- * ----------------------
...@@ -123,7 +95,12 @@ static const network_pdn_state_t _esm_ebr_pdn_state[2][2][2] = { ...@@ -123,7 +95,12 @@ static const network_pdn_state_t _esm_ebr_pdn_state[2][2][2] = {
/* Returns the index of the next available entry in the list of EPS bearer /* Returns the index of the next available entry in the list of EPS bearer
* context data */ * context data */
#ifdef NAS_MME
static int _esm_ebr_get_available_entry(emm_data_context_t *ctx);
#endif
#ifdef NAS_UE
static int _esm_ebr_get_available_entry(unsigned int ueid); static int _esm_ebr_get_available_entry(unsigned int ueid);
#endif
/****************************************************************************/ /****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/ /****************** E X P O R T E D F U N C T I O N S ******************/
...@@ -149,7 +126,9 @@ void esm_ebr_initialize( ...@@ -149,7 +126,9 @@ void esm_ebr_initialize(
#endif #endif
) )
{ {
#if !defined(EPC_BUILD)
int ueid, i; int ueid, i;
LOG_FUNC_IN; LOG_FUNC_IN;
for (ueid = 0; ueid < ESM_EBR_NB_UE_MAX; ueid++) { for (ueid = 0; ueid < ESM_EBR_NB_UE_MAX; ueid++) {
...@@ -159,12 +138,13 @@ void esm_ebr_initialize( ...@@ -159,12 +138,13 @@ void esm_ebr_initialize(
_esm_ebr_data[ueid].context[i] = NULL; _esm_ebr_data[ueid].context[i] = NULL;
} }
} }
#ifdef NAS_UE # ifdef NAS_UE
/* Initialize the user notification callback */ /* Initialize the user notification callback */
_esm_ebr_callback = *cb; _esm_ebr_callback = *cb;
#endif # endif
LOG_FUNC_OUT; LOG_FUNC_OUT;
#endif
} }
/**************************************************************************** /****************************************************************************
...@@ -192,10 +172,10 @@ void esm_ebr_initialize( ...@@ -192,10 +172,10 @@ void esm_ebr_initialize(
int esm_ebr_assign(int ebi, int cid, int default_ebr) int esm_ebr_assign(int ebi, int cid, int default_ebr)
#endif #endif
#ifdef NAS_MME #ifdef NAS_MME
int esm_ebr_assign(unsigned int ueid, int ebi) int esm_ebr_assign(emm_data_context_t *ctx, int ebi)
#endif #endif
{ {
LOG_FUNC_IN; esm_ebr_context_t *ebr_ctx;
#ifdef NAS_UE #ifdef NAS_UE
unsigned int ueid = 0; unsigned int ueid = 0;
...@@ -203,14 +183,18 @@ int esm_ebr_assign(unsigned int ueid, int ebi) ...@@ -203,14 +183,18 @@ int esm_ebr_assign(unsigned int ueid, int ebi)
int i; int i;
if (ueid >= ESM_EBR_NB_UE_MAX) { LOG_FUNC_IN;
LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED);
} #if defined(NAS_UE)
ebr_ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN];
#else
ebr_ctx = ctx->esm_data_ctx.ebr.context[ebi - ESM_EBI_MIN];
#endif
if (ebi != ESM_EBI_UNASSIGNED) { if (ebi != ESM_EBI_UNASSIGNED) {
if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) { if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) {
LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED);
} else if (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN] != NULL) { } else if (ebr_ctx != NULL) {
LOG_TRACE(WARNING, "ESM-FSM - EPS bearer context already " LOG_TRACE(WARNING, "ESM-FSM - EPS bearer context already "
"assigned (ebi=%d)", ebi); "assigned (ebi=%d)", ebi);
LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED);
...@@ -219,7 +203,11 @@ int esm_ebr_assign(unsigned int ueid, int ebi) ...@@ -219,7 +203,11 @@ int esm_ebr_assign(unsigned int ueid, int ebi)
i = ebi - ESM_EBI_MIN; i = ebi - ESM_EBI_MIN;
} else { } else {
/* Search for an available EPS bearer identity */ /* Search for an available EPS bearer identity */
#ifdef NAS_UE
i = _esm_ebr_get_available_entry(ueid); i = _esm_ebr_get_available_entry(ueid);
#else
i = _esm_ebr_get_available_entry(ctx);
#endif
if (i < 0) { if (i < 0) {
LOG_FUNC_RETURN(ESM_EBI_UNASSIGNED); LOG_FUNC_RETURN(ESM_EBI_UNASSIGNED);
} }
...@@ -228,33 +216,44 @@ int esm_ebr_assign(unsigned int ueid, int ebi) ...@@ -228,33 +216,44 @@ int esm_ebr_assign(unsigned int ueid, int ebi)
} }
/* Assign new EPS bearer context */ /* Assign new EPS bearer context */
_esm_ebr_data[ueid].context[i] = ebr_ctx =
(esm_ebr_context_t *)malloc(sizeof(esm_ebr_context_t)); (esm_ebr_context_t *)malloc(sizeof(esm_ebr_context_t));
if (_esm_ebr_data[ueid].context[i] == NULL) { if (ebr_ctx == NULL) {
LOG_FUNC_RETURN(ESM_EBI_UNASSIGNED); LOG_FUNC_RETURN(ESM_EBI_UNASSIGNED);
} }
#if defined(EPC_BUILD)
ctx->esm_data_ctx.ebr.context[ebi - ESM_EBI_MIN] = ebr_ctx;
#else
_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN] = ebr_ctx;
#endif
/* Store the index of the next available EPS bearer identity */ /* Store the index of the next available EPS bearer identity */
#ifdef NAS_MME
ctx->esm_data_ctx.ebr.index = i + 1;
#else
_esm_ebr_data[ueid].index = i + 1; _esm_ebr_data[ueid].index = i + 1;
#endif
/* Set the EPS bearer identity */ /* Set the EPS bearer identity */
_esm_ebr_data[ueid].context[i]->ebi = ebi; ebr_ctx->ebi = ebi;
/* Set the EPS bearer context status to INACTIVE */ /* Set the EPS bearer context status to INACTIVE */
_esm_ebr_data[ueid].context[i]->status = ESM_EBR_INACTIVE; ebr_ctx->status = ESM_EBR_INACTIVE;
#ifdef NAS_UE #ifdef NAS_UE
/* Set the default EPS bearer indicator */ /* Set the default EPS bearer indicator */
_esm_ebr_data[ueid].context[i]->is_default_ebr = default_ebr; ebr_ctx->is_default_ebr = default_ebr;
/* Set the identifier of the PDN context the EPS bearer is assigned to */ /* Set the identifier of the PDN context the EPS bearer is assigned to */
_esm_ebr_data[ueid].context[i]->cid = cid; ebr_ctx->cid = cid;
#endif #endif
#ifdef NAS_MME #ifdef NAS_MME
/* Disable the retransmission timer */ /* Disable the retransmission timer */
_esm_ebr_data[ueid].context[i]->timer.id = NAS_TIMER_INACTIVE_ID; ebr_ctx->timer.id = NAS_TIMER_INACTIVE_ID;
/* Setup retransmission timer parameters */ /* Setup retransmission timer parameters */
_esm_ebr_data[ueid].context[i]->args = NULL; ebr_ctx->args = NULL;
#endif #endif
LOG_TRACE(INFO, "ESM-FSM - EPS bearer context %d assigned", ebi); LOG_TRACE(INFO, "ESM-FSM - EPS bearer context %d assigned", ebi);
LOG_FUNC_RETURN(_esm_ebr_data[ueid].context[i]->ebi); LOG_FUNC_RETURN(ebr_ctx->ebi);
} }
/**************************************************************************** /****************************************************************************
...@@ -277,55 +276,57 @@ int esm_ebr_assign(unsigned int ueid, int ebi) ...@@ -277,55 +276,57 @@ int esm_ebr_assign(unsigned int ueid, int ebi)
***************************************************************************/ ***************************************************************************/
int esm_ebr_release( int esm_ebr_release(
#ifdef NAS_MME #ifdef NAS_MME
unsigned int ueid, emm_data_context_t *ctx,
#endif #endif
int ebi) int ebi)
{ {
LOG_FUNC_IN;
#ifdef NAS_UE #ifdef NAS_UE
unsigned int ueid = 0; unsigned int ueid = 0;
#endif #endif
esm_ebr_context_t *ebr_ctx;
LOG_FUNC_IN;
if (ueid >= ESM_EBR_NB_UE_MAX) {
LOG_FUNC_RETURN (RETURNerror);
}
if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) { if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) {
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
/* Get EPS bearer context data */ /* Get EPS bearer context data */
esm_ebr_context_t *ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]; #if defined(NAS_MME)
if ( (ctx == NULL) || (ctx->ebi != ebi) ) { ebr_ctx = ctx->esm_data_ctx.ebr.context[ebi - ESM_EBI_MIN];
#else
ebr_ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN];
#endif
if ( (ebr_ctx == NULL) || (ebr_ctx->ebi != ebi) ) {
/* EPS bearer context not assigned */ /* EPS bearer context not assigned */
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
/* Do not release active EPS bearer context */ /* Do not release active EPS bearer context */
if (ctx->status != ESM_EBR_INACTIVE) { if (ebr_ctx->status != ESM_EBR_INACTIVE) {
LOG_TRACE(ERROR, "ESM-FSM - EPS bearer context is not INACTIVE"); LOG_TRACE(ERROR, "ESM-FSM - EPS bearer context is not INACTIVE");
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
#ifdef NAS_MME #ifdef NAS_MME
/* Stop the retransmission timer if still running */ /* Stop the retransmission timer if still running */
if (ctx->timer.id != NAS_TIMER_INACTIVE_ID) { if (ebr_ctx->timer.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d", LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d",
ctx->timer.id); ebr_ctx->timer.id);
ctx->timer.id = nas_timer_stop(ctx->timer.id); ebr_ctx->timer.id = nas_timer_stop(ebr_ctx->timer.id);
} }
/* Release the retransmisison timer parameters */ /* Release the retransmisison timer parameters */
if (ctx->args) { if (ebr_ctx->args) {
if (ctx->args->msg.length > 0) { if (ebr_ctx->args->msg.length > 0) {
free(ctx->args->msg.value); free(ebr_ctx->args->msg.value);
} }
free(ctx->args); free(ebr_ctx->args);
ctx->args = NULL; ebr_ctx->args = NULL;
} }
#endif #endif
/* Release EPS bearer context data */ /* Release EPS bearer context data */
free(_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]); free(ebr_ctx);
_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN] = NULL; ebr_ctx = NULL;
LOG_TRACE(INFO, "ESM-FSM - EPS bearer context %d released", ebi); LOG_TRACE(INFO, "ESM-FSM - EPS bearer context %d released", ebi);
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
...@@ -353,57 +354,56 @@ int esm_ebr_release( ...@@ -353,57 +354,56 @@ int esm_ebr_release(
** Others: _esm_ebr_data ** ** Others: _esm_ebr_data **
** ** ** **
***************************************************************************/ ***************************************************************************/
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) long sec, nas_timer_callback_t cb)
{ {
esm_ebr_context_t *ebr_ctx;
LOG_FUNC_IN; LOG_FUNC_IN;
if (ueid >= ESM_EBR_NB_UE_MAX) {
LOG_FUNC_RETURN (RETURNerror);
}
if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) { if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) {
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
/* Get EPS bearer context data */ /* Get EPS bearer context data */
esm_ebr_context_t *ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]; ebr_ctx = ctx->esm_data_ctx.ebr.context[ebi - ESM_EBI_MIN];
if ( (ctx == NULL) || (ctx->ebi != ebi) ) { if ( (ebr_ctx == NULL) || (ebr_ctx->ebi != ebi) ) {
/* EPS bearer context not assigned */ /* EPS bearer context not assigned */
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
if (ctx->timer.id != NAS_TIMER_INACTIVE_ID) { if (ebr_ctx->timer.id != NAS_TIMER_INACTIVE_ID) {
if (ctx->args) { if (ebr_ctx->args) {
/* Re-start the retransmission timer */ /* Re-start the retransmission timer */
ctx->timer.id = nas_timer_restart(ctx->timer.id); ebr_ctx->timer.id = nas_timer_restart(ebr_ctx->timer.id);
} }
} else { } else {
/* Setup the retransmission timer parameters */ /* Setup the retransmission timer parameters */
ctx->args = (esm_ebr_timer_data_t *)malloc(sizeof(esm_ebr_timer_data_t)); ebr_ctx->args = (esm_ebr_timer_data_t *)malloc(sizeof(esm_ebr_timer_data_t));
if (ctx->args) { if (ebr_ctx->args) {
/* Set the UE identifier */ /* Set the UE identifier */
ctx->args->ueid = ueid; ebr_ctx->args->ueid = ctx->ueid;
/* Set the EPS bearer identity */ /* Set the EPS bearer identity */
ctx->args->ebi = ebi; ebr_ctx->args->ebi = ebi;
/* Reset the retransmission counter */ /* Reset the retransmission counter */
ctx->args->count = 0; ebr_ctx->args->count = 0;
/* Set the ESM message to be re-transmited */ /* Set the ESM message to be re-transmited */
ctx->args->msg.value = (uint8_t *)malloc(msg->length); ebr_ctx->args->msg.value = (uint8_t *)malloc(msg->length);
ctx->args->msg.length = 0; ebr_ctx->args->msg.length = 0;
if (ctx->args->msg.value) { if (ebr_ctx->args->msg.value) {
memcpy(ctx->args->msg.value, msg->value, msg->length); memcpy(ebr_ctx->args->msg.value, msg->value, msg->length);
ctx->args->msg.length = msg->length; ebr_ctx->args->msg.length = msg->length;
} }
/* Setup the retransmission timer to expire at the given /* Setup the retransmission timer to expire at the given
* time interval */ * time interval */
ctx->timer.id = nas_timer_start(sec, cb, ctx->args); ebr_ctx->timer.id = nas_timer_start(sec, cb, ebr_ctx->args);
ctx->timer.sec = sec; ebr_ctx->timer.sec = sec;
} }
} }
if ( (ctx->args != NULL) && (ctx->timer.id != NAS_TIMER_INACTIVE_ID) ) { if ( (ebr_ctx->args != NULL) && (ebr_ctx->timer.id != NAS_TIMER_INACTIVE_ID) ) {
LOG_TRACE(INFO, "ESM-FSM - Retransmission timer %d expires in " LOG_TRACE(INFO, "ESM-FSM - Retransmission timer %d expires in "
"%ld seconds", ctx->timer.id, ctx->timer.sec); "%ld seconds", ebr_ctx->timer.id, ebr_ctx->timer.sec);
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} }
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
...@@ -425,38 +425,37 @@ int esm_ebr_start_timer( unsigned int ueid, int ebi, const OctetString *msg, ...@@ -425,38 +425,37 @@ int esm_ebr_start_timer( unsigned int ueid, int ebi, const OctetString *msg,
** Others: _esm_ebr_data ** ** Others: _esm_ebr_data **
** ** ** **
***************************************************************************/ ***************************************************************************/
int esm_ebr_stop_timer( unsigned int ueid, int ebi) int esm_ebr_stop_timer(emm_data_context_t *ctx, int ebi)
{ {
esm_ebr_context_t *ebr_ctx ;
LOG_FUNC_IN; LOG_FUNC_IN;
if (ueid >= ESM_EBR_NB_UE_MAX) {
LOG_FUNC_RETURN (RETURNerror);
}
if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) { if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) {
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
/* Get EPS bearer context data */ /* Get EPS bearer context data */
esm_ebr_context_t *ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]; ebr_ctx = ctx->esm_data_ctx.ebr.context[ebi - ESM_EBI_MIN];
if ( (ctx == NULL) || (ctx->ebi != ebi) ) { if ( (ebr_ctx == NULL) || (ebr_ctx->ebi != ebi) ) {
/* EPS bearer context not assigned */ /* EPS bearer context not assigned */
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
/* Stop the retransmission timer if still running */ /* Stop the retransmission timer if still running */
if (ctx->timer.id != NAS_TIMER_INACTIVE_ID) { if (ebr_ctx->timer.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d", LOG_TRACE(INFO, "ESM-FSM - Stop retransmission timer %d",
ctx->timer.id); ebr_ctx->timer.id);
ctx->timer.id = nas_timer_stop(ctx->timer.id); ebr_ctx->timer.id = nas_timer_stop(ebr_ctx->timer.id);
} }
/* Release the retransmisison timer parameters */ /* Release the retransmisison timer parameters */
if (ctx->args) { if (ebr_ctx->args) {
if (ctx->args->msg.length > 0) { if (ebr_ctx->args->msg.length > 0) {
free(ctx->args->msg.value); free(ebr_ctx->args->msg.value);
} }
free(ctx->args); free(ebr_ctx->args);
ctx->args = NULL; ebr_ctx->args = NULL;
} }
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
...@@ -480,16 +479,17 @@ int esm_ebr_stop_timer( unsigned int ueid, int ebi) ...@@ -480,16 +479,17 @@ int esm_ebr_stop_timer( unsigned int ueid, int ebi)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
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 i;
LOG_FUNC_IN; LOG_FUNC_IN;
int i;
for (i = 0; i < ESM_EBR_DATA_SIZE; i++) { for (i = 0; i < ESM_EBR_DATA_SIZE; i++) {
if (_esm_ebr_data[ueid].context[i] == NULL) { if (ctx->esm_data_ctx.ebr.context[i] == NULL) {
continue; continue;
} }
if (_esm_ebr_data[ueid].context[i]->status != status) { if (ctx->esm_data_ctx.ebr.context[i]->status != status) {
continue; continue;
} }
/* EPS bearer context entry found */ /* EPS bearer context entry found */
...@@ -497,7 +497,7 @@ int esm_ebr_get_pending_ebi(unsigned int ueid, esm_ebr_state status) ...@@ -497,7 +497,7 @@ int esm_ebr_get_pending_ebi(unsigned int ueid, esm_ebr_state status)
} }
if (i < ESM_EBR_DATA_SIZE) { if (i < ESM_EBR_DATA_SIZE) {
LOG_FUNC_RETURN (_esm_ebr_data[ueid].context[i]->ebi); LOG_FUNC_RETURN (ctx->esm_data_ctx.ebr.context[i]->ebi);
} }
/* EPS bearer context entry not found */ /* EPS bearer context entry not found */
LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED);
...@@ -526,47 +526,56 @@ int esm_ebr_get_pending_ebi(unsigned int ueid, esm_ebr_state status) ...@@ -526,47 +526,56 @@ int esm_ebr_get_pending_ebi(unsigned int ueid, esm_ebr_state status)
***************************************************************************/ ***************************************************************************/
int esm_ebr_set_status( int esm_ebr_set_status(
#ifdef NAS_MME #ifdef NAS_MME
unsigned int ueid, emm_data_context_t *ctx,
#endif #endif
int ebi, esm_ebr_state status, int ue_requested) int ebi, esm_ebr_state status, int ue_requested)
{ {
LOG_FUNC_IN; esm_ebr_context_t *ebr_ctx;
esm_ebr_state old_status; esm_ebr_state old_status;
LOG_FUNC_IN;
#ifdef NAS_UE #ifdef NAS_UE
unsigned int ueid = 0; unsigned int ueid = 0;
#endif
if (ueid >= ESM_EBR_NB_UE_MAX) { if (ueid >= ESM_EBR_NB_UE_MAX) {
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
#else
if (ctx == NULL) {
LOG_FUNC_RETURN (RETURNerror);
}
#endif
if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) { if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) {
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
/* Get EPS bearer context data */ /* Get EPS bearer context data */
esm_ebr_context_t *ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]; #ifdef NAS_UE
if ( (ctx == NULL) || (ctx->ebi != ebi) ) { ebr_ctx = _esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN];
#else
ebr_ctx = ctx->esm_data_ctx.ebr.context[ebi - ESM_EBI_MIN];
#endif
if ( (ebr_ctx == NULL) || (ebr_ctx->ebi != ebi) ) {
/* EPS bearer context not assigned */ /* EPS bearer context not assigned */
LOG_TRACE(ERROR, "ESM-FSM - EPS bearer context not assigned " LOG_TRACE(ERROR, "ESM-FSM - EPS bearer context not assigned "
"(ebi=%d)", ebi); "(ebi=%d)", ebi);
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
old_status = ctx->status; old_status = ebr_ctx->status;
if (status < ESM_EBR_STATE_MAX) { if (status < ESM_EBR_STATE_MAX) {
LOG_TRACE(INFO, "ESM-FSM - Status of EPS bearer context %d changed:" LOG_TRACE(INFO, "ESM-FSM - Status of EPS bearer context %d changed:"
" %s ===> %s", ebi, " %s ===> %s", ebi,
_esm_ebr_state_str[old_status], _esm_ebr_state_str[status]); _esm_ebr_state_str[old_status], _esm_ebr_state_str[status]);
if (status != old_status) { if (status != old_status) {
ctx->status = status; ebr_ctx->status = status;
#ifdef NAS_UE #ifdef NAS_UE
/* /*
* Notify the user that the state of the EPS bearer has changed * Notify the user that the state of the EPS bearer has changed
*/ */
(*_esm_ebr_callback)(ctx->cid, (*_esm_ebr_callback)(ebr_ctx->cid,
_esm_ebr_pdn_state[ue_requested][ctx->is_default_ebr][status]); _esm_ebr_pdn_state[ue_requested][ebr_ctx->is_default_ebr][status]);
#endif #endif
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} }
...@@ -592,15 +601,31 @@ int esm_ebr_set_status( ...@@ -592,15 +601,31 @@ int esm_ebr_set_status(
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
esm_ebr_state esm_ebr_get_status(
#ifdef NAS_MME #ifdef NAS_MME
unsigned int ueid, esm_ebr_state esm_ebr_get_status(
#endif emm_data_context_t *ctx,
int ebi) int ebi)
{ {
if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) {
return (ESM_EBR_INACTIVE);
}
if (ctx->esm_data_ctx.ebr.context[ebi - ESM_EBI_MIN] == NULL) {
/* EPS bearer context not allocated */
return (ESM_EBR_INACTIVE);
}
if (ctx->esm_data_ctx.ebr.context[ebi - ESM_EBI_MIN]->ebi != ebi) {
/* EPS bearer context not assigned */
return (ESM_EBR_INACTIVE);
}
return (ctx->esm_data_ctx.ebr.context[ebi - ESM_EBI_MIN]->status);
}
#endif
#ifdef NAS_UE #ifdef NAS_UE
esm_ebr_state esm_ebr_get_status(
int ebi)
{
unsigned int ueid = 0; unsigned int ueid = 0;
#endif
if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) { if ( (ebi < ESM_EBI_MIN) || (ebi > ESM_EBI_MAX) ) {
return (ESM_EBR_INACTIVE); return (ESM_EBR_INACTIVE);
...@@ -615,6 +640,7 @@ esm_ebr_state esm_ebr_get_status( ...@@ -615,6 +640,7 @@ esm_ebr_state esm_ebr_get_status(
} }
return (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]->status); return (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]->status);
} }
#endif
/**************************************************************************** /****************************************************************************
** ** ** **
...@@ -654,17 +680,21 @@ int esm_ebr_is_reserved(int ebi) ...@@ -654,17 +680,21 @@ int esm_ebr_is_reserved(int ebi)
***************************************************************************/ ***************************************************************************/
int esm_ebr_is_not_in_use( int esm_ebr_is_not_in_use(
#ifdef NAS_MME #ifdef NAS_MME
unsigned int ueid, emm_data_context_t *ctx,
#endif #endif
int ebi) int ebi)
{ {
#ifdef NAS_UE #ifdef NAS_UE
unsigned int ueid = 0; unsigned int ueid = 0;
#endif
return ( (ebi == ESM_EBI_UNASSIGNED) || return ( (ebi == ESM_EBI_UNASSIGNED) ||
(_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN] == NULL) || (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN] == NULL) ||
(_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]->ebi) != ebi); (_esm_ebr_data[ueid].context[ebi - ESM_EBI_MIN]->ebi) != ebi);
#else
return ( (ebi == ESM_EBI_UNASSIGNED) ||
(ctx->esm_data_ctx.ebr.context[ebi - ESM_EBI_MIN] == NULL) ||
(ctx->esm_data_ctx.ebr.context[ebi - ESM_EBI_MIN]->ebi) != ebi);
#endif
} }
/****************************************************************************/ /****************************************************************************/
...@@ -688,6 +718,27 @@ int esm_ebr_is_not_in_use( ...@@ -688,6 +718,27 @@ int esm_ebr_is_not_in_use(
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
#ifdef NAS_MME
static int _esm_ebr_get_available_entry(emm_data_context_t *ctx)
{
int i;
for (i = ctx->esm_data_ctx.ebr.index; i < ESM_EBR_DATA_SIZE; i++) {
if (ctx->esm_data_ctx.ebr.context[i] != NULL) {
continue;
}
return i;
}
for (i = 0; i < ctx->esm_data_ctx.ebr.index; i++) {
if (ctx->esm_data_ctx.ebr.context[i] != NULL) {
continue;
}
return i;
}
/* No available EBI entry found */
return (-1);
}
#endif
#ifdef NAS_UE
static int _esm_ebr_get_available_entry(unsigned int ueid) static int _esm_ebr_get_available_entry(unsigned int ueid)
{ {
int i; int i;
...@@ -706,3 +757,4 @@ static int _esm_ebr_get_available_entry(unsigned int ueid) ...@@ -706,3 +757,4 @@ static int _esm_ebr_get_available_entry(unsigned int ueid)
/* No available EBI entry found */ /* No available EBI entry found */
return (-1); return (-1);
} }
#endif
...@@ -28,7 +28,6 @@ Description Defines functions used to handle state of EPS bearer contexts ...@@ -28,7 +28,6 @@ Description Defines functions used to handle state of EPS bearer contexts
#endif #endif
#include "nas_timer.h" #include "nas_timer.h"
#include "EpsBearerIdentity.h"
/****************************************************************************/ /****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/ /********************* 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 ...@@ -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 ************************/ /************************ 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 ********************/ /******************** 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); ...@@ -90,20 +63,20 @@ int esm_ebr_is_not_in_use(int ebi);
#ifdef NAS_MME #ifdef NAS_MME
void esm_ebr_initialize(void); void esm_ebr_initialize(void);
int esm_ebr_assign(unsigned int ueid, int ebi); int esm_ebr_assign(emm_data_context_t *ctx, int ebi);
int esm_ebr_release(unsigned int ueid, 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); 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); 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
#endif /* __ESM_EBR_H__*/ #endif /* __ESM_EBR_H__*/
...@@ -17,18 +17,22 @@ Author Frederic Maurel ...@@ -17,18 +17,22 @@ Author Frederic Maurel
Description Defines functions used to handle EPS bearer contexts. 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 "commonDef.h"
#include "nas_log.h" #include "nas_log.h"
#include "esmData.h" #include "emmData.h"
#include "esm_ebr.h" #include "esm_ebr.h"
#include "esm_ebr_context.h"
#include "emm_sap.h" #include "emm_sap.h"
#include <stdlib.h> // malloc, free #if defined(ENABLE_ITTI)
#include <string.h> // memset # include "assertions.h"
#endif
/****************************************************************************/ /****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/ /**************** 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 *, ...@@ -75,48 +79,53 @@ static int _esm_ebr_context_check_precedence(const network_tft_t *,
***************************************************************************/ ***************************************************************************/
int esm_ebr_context_create( int esm_ebr_context_create(
#ifdef NAS_MME #ifdef NAS_MME
unsigned int ueid, emm_data_context_t *ctx,
#endif #endif
int pid, int ebi, int is_default, int pid, int ebi, int is_default,
const network_qos_t *qos, const network_tft_t *tft) 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 #ifdef NAS_UE
ctx = &_esm_data; esm_ctx = &_esm_data;
#endif #endif
#ifdef NAS_MME #ifdef NAS_MME
# if defined(EPC_BUILD)
esm_ctx = &ctx->esm_data_ctx;
# else
if (ueid < ESM_DATA_NB_UE_MAX) { if (ueid < ESM_DATA_NB_UE_MAX) {
ctx = _esm_data.ctx[ueid]; ctx = _esm_data.ctx[ueid];
} else { } else {
LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED);
} }
# endif
#endif #endif
int bid = ESM_DATA_EPS_BEARER_MAX; bid = ESM_DATA_EPS_BEARER_MAX;
esm_pdn_t *pdn = NULL;
LOG_TRACE(INFO, "ESM-PROC - Create new %s EPS bearer context (ebi=%d) " LOG_TRACE(INFO, "ESM-PROC - Create new %s EPS bearer context (ebi=%d) "
"for PDN connection (pid=%d)", "for PDN connection (pid=%d)",
(is_default)? "default" : "dedicated", ebi, pid); (is_default)? "default" : "dedicated", ebi, pid);
if (pid < ESM_DATA_PDN_MAX) { 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 " LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier %d is "
"not valid", pid); "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 " LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been "
"allocated", pid); "allocated", pid);
} }
/* Check the total number of active EPS bearers */ /* 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" LOG_TRACE(WARNING, "ESM-PROC - The total number of active EPS"
"bearers is exeeded"); "bearers is exeeded");
} else { } else {
/* Get the PDN connection entry */ /* Get the PDN connection entry */
pdn = ctx->pdn[pid].data; pdn = esm_ctx->pdn[pid].data;
if (is_default) { if (is_default) {
/* Default EPS bearer entry is defined at index 0 */ /* Default EPS bearer entry is defined at index 0 */
bid = 0; bid = 0;
...@@ -143,7 +152,7 @@ int esm_ebr_context_create( ...@@ -143,7 +152,7 @@ int esm_ebr_context_create(
if (ebr != NULL) { if (ebr != NULL) {
memset(ebr, 0 , sizeof(esm_bearer_t)); memset(ebr, 0 , sizeof(esm_bearer_t));
/* Increment the total number of active EPS bearers */ /* 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 */ /* Increment the number of EPS bearer for this PDN connection */
pdn->n_bearers += 1; pdn->n_bearers += 1;
/* Setup the EPS bearer data */ /* Setup the EPS bearer data */
...@@ -169,10 +178,10 @@ int esm_ebr_context_create( ...@@ -169,10 +178,10 @@ int esm_ebr_context_create(
if (is_default) { if (is_default) {
/* Set the PDN connection activation indicator */ /* 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 */ /* Update the emergency bearer services indicator */
if (pdn->is_emergency) { if (pdn->is_emergency) {
ctx->emergency = TRUE; esm_ctx->emergency = TRUE;
} }
} }
...@@ -210,28 +219,32 @@ int esm_ebr_context_create( ...@@ -210,28 +219,32 @@ int esm_ebr_context_create(
***************************************************************************/ ***************************************************************************/
int esm_ebr_context_release( int esm_ebr_context_release(
#ifdef NAS_MME #ifdef NAS_MME
unsigned int ueid, emm_data_context_t *ctx,
#endif #endif
int ebi, int *pid, int *bid) 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 #ifdef NAS_UE
ctx = &_esm_data; esm_ctx = &_esm_data;
#endif #endif
#ifdef NAS_MME #ifdef NAS_MME
# if defined(EPC_BUILD)
esm_ctx = &ctx->esm_data_ctx;
# else
if (ueid < ESM_DATA_NB_UE_MAX) { if (ueid < ESM_DATA_NB_UE_MAX) {
ctx = _esm_data.ctx[ueid]; ctx = &_esm_data.ctx[ueid];
} else { } else {
LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED); LOG_FUNC_RETURN (ESM_EBI_UNASSIGNED);
} }
# endif
#endif #endif
int found = FALSE;
esm_pdn_t *pdn = NULL;
if (ebi != ESM_EBI_UNASSIGNED) { if (ebi != ESM_EBI_UNASSIGNED) {
/* /*
* The identity of the EPS bearer to released is given; * The identity of the EPS bearer to released is given;
...@@ -241,12 +254,12 @@ int esm_ebr_context_release( ...@@ -241,12 +254,12 @@ int esm_ebr_context_release(
/* Search for active PDN connection */ /* Search for active PDN connection */
for (*pid = 0; *pid < ESM_DATA_PDN_MAX; (*pid)++) { for (*pid = 0; *pid < ESM_DATA_PDN_MAX; (*pid)++) {
if ( !ctx->pdn[*pid].is_active ) { if ( !esm_ctx->pdn[*pid].is_active ) {
continue; continue;
} }
/* An active PDN connection is found */ /* An active PDN connection is found */
if (ctx->pdn[*pid].data != NULL) { if (esm_ctx->pdn[*pid].data != NULL) {
pdn = ctx->pdn[*pid].data; pdn = esm_ctx->pdn[*pid].data;
/* Search for the specified EPS bearer context entry */ /* Search for the specified EPS bearer context entry */
for (*bid = 0; *bid < pdn->n_bearers; (*bid)++) { for (*bid = 0; *bid < pdn->n_bearers; (*bid)++) {
if (pdn->bearer[*bid] != NULL) { if (pdn->bearer[*bid] != NULL) {
...@@ -273,17 +286,17 @@ int esm_ebr_context_release( ...@@ -273,17 +286,17 @@ int esm_ebr_context_release(
* first EPS bearer context entry at index bid = 0 * first EPS bearer context entry at index bid = 0
*/ */
if (*pid < ESM_DATA_PDN_MAX) { 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 " LOG_TRACE(ERROR, "ESM-PROC - PDN connection identifier %d "
"is not valid", *pid); "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", LOG_TRACE(WARNING,"ESM-PROC - PDN connection %d is not active",
*pid); *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 " LOG_TRACE(ERROR, "ESM-PROC - PDN connection %d has not been "
"allocated", *pid); "allocated", *pid);
} else { } else {
pdn = ctx->pdn[*pid].data; pdn = esm_ctx->pdn[*pid].data;
if (pdn->bearer[*bid] != NULL) { if (pdn->bearer[*bid] != NULL) {
ebi = pdn->bearer[*bid]->ebi; ebi = pdn->bearer[*bid]->ebi;
found = TRUE; found = TRUE;
...@@ -317,7 +330,7 @@ int esm_ebr_context_release( ...@@ -317,7 +330,7 @@ int esm_ebr_context_release(
* to the PDN connection */ * to the PDN connection */
pdn->n_bearers -= 1; pdn->n_bearers -= 1;
/* Decrement the total number of active EPS bearers */ /* Decrement the total number of active EPS bearers */
ctx->n_ebrs -= 1; esm_ctx->n_ebrs -= 1;
if (*bid == 0) { if (*bid == 0) {
/* 3GPP TS 24.301, section 6.4.4.3, 6.4.4.6 /* 3GPP TS 24.301, section 6.4.4.3, 6.4.4.6
...@@ -341,7 +354,7 @@ int esm_ebr_context_release( ...@@ -341,7 +354,7 @@ int esm_ebr_context_release(
ESM_EBR_INACTIVE, TRUE); ESM_EBR_INACTIVE, TRUE);
#endif #endif
#ifdef NAS_MME #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); ESM_EBR_INACTIVE, TRUE);
#endif #endif
/* Release EPS bearer data */ /* Release EPS bearer data */
...@@ -349,7 +362,7 @@ int esm_ebr_context_release( ...@@ -349,7 +362,7 @@ int esm_ebr_context_release(
(void) esm_ebr_release(pdn->bearer[i]->ebi); (void) esm_ebr_release(pdn->bearer[i]->ebi);
#endif #endif
#ifdef NAS_MME #ifdef NAS_MME
(void) esm_ebr_release(ueid, pdn->bearer[i]->ebi); (void) esm_ebr_release(ctx, pdn->bearer[i]->ebi);
#endif #endif
// esm_ebr_release() // esm_ebr_release()
/* Release dedicated EPS bearer data */ /* Release dedicated EPS bearer data */
...@@ -359,14 +372,14 @@ int esm_ebr_context_release( ...@@ -359,14 +372,14 @@ int esm_ebr_context_release(
* to the PDN connection */ * to the PDN connection */
pdn->n_bearers -= 1; pdn->n_bearers -= 1;
/* Decrement the total number of active EPS bearers */ /* Decrement the total number of active EPS bearers */
ctx->n_ebrs -= 1; esm_ctx->n_ebrs -= 1;
} }
} }
/* Reset the PDN connection activation indicator */ /* 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 */ /* Update the emergency bearer services indicator */
if (pdn->is_emergency) { if (pdn->is_emergency) {
ctx->emergency = FALSE; esm_ctx->emergency = FALSE;
} }
} }
...@@ -375,7 +388,7 @@ int esm_ebr_context_release( ...@@ -375,7 +388,7 @@ int esm_ebr_context_release(
* If the UE locally deactivated all EPS bearer contexts, the UE * If the UE locally deactivated all EPS bearer contexts, the UE
* shall perform a local detach and enter state EMM-DEREGISTERED. * 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_t emm_sap;
emm_sap.primitive = EMMESM_ESTABLISH_CNF; emm_sap.primitive = EMMESM_ESTABLISH_CNF;
emm_sap.u.emm_esm.u.establish.is_attached = FALSE; emm_sap.u.emm_esm.u.establish.is_attached = FALSE;
...@@ -387,7 +400,7 @@ int esm_ebr_context_release( ...@@ -387,7 +400,7 @@ int esm_ebr_context_release(
* the UE shall consider itself attached for emergency bearer * the UE shall consider itself attached for emergency bearer
* services only. * 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_t emm_sap;
emm_sap.primitive = EMMESM_ESTABLISH_CNF; emm_sap.primitive = EMMESM_ESTABLISH_CNF;
emm_sap.u.emm_esm.u.establish.is_attached = TRUE; emm_sap.u.emm_esm.u.establish.is_attached = TRUE;
...@@ -396,7 +409,7 @@ int esm_ebr_context_release( ...@@ -396,7 +409,7 @@ int esm_ebr_context_release(
} }
#endif // NAS_UE #endif // NAS_UE
#ifdef NAS_MME #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 /* TODO: Release the PDN connection and marked the UE as inactive
* in the network for EPS services (is_attached = FALSE) */ * 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, ...@@ -62,10 +62,10 @@ int esm_ebr_context_check_tft(int pid, int ebi, const network_tft_t *tft,
#endif #endif
#ifdef NAS_MME #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); 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
#endif /* __ESM_EBR_CONTEXT_H__ */ #endif /* __ESM_EBR_CONTEXT_H__ */
#include "emmData.h"
#include "esmData.h" #include "esmData.h"
char ip_addr_str[100]; char ip_addr_str[100];
......
...@@ -23,6 +23,7 @@ Description Defines the EPS Session Management procedure call manager, ...@@ -23,6 +23,7 @@ Description Defines the EPS Session Management procedure call manager,
#include "commonDef.h" #include "commonDef.h"
#include "nas_log.h" #include "nas_log.h"
#include "emmData.h"
#include "esmData.h" #include "esmData.h"
#include "esm_pt.h" #include "esm_pt.h"
#include "esm_ebr.h" #include "esm_ebr.h"
...@@ -106,11 +107,12 @@ void esm_main_initialize(void) ...@@ -106,11 +107,12 @@ void esm_main_initialize(void)
if (mme_api_get_esm_config(&_esm_data.conf) != RETURNok) { if (mme_api_get_esm_config(&_esm_data.conf) != RETURNok) {
LOG_TRACE(ERROR, "ESM-MAIN - Failed to get MME configuration data"); LOG_TRACE(ERROR, "ESM-MAIN - Failed to get MME configuration data");
} }
# if !defined(EPC_BUILD)
/* Initialize ESM contexts */ /* Initialize ESM contexts */
for (i = 0; i < ESM_DATA_NB_UE_MAX; i++) { for (i = 0; i < ESM_DATA_NB_UE_MAX; i++) {
_esm_data.ctx[i] = NULL; _esm_data.ctx[i] = NULL;
} }
# endif
/* Initialize the EPS bearer context manager */ /* Initialize the EPS bearer context manager */
esm_ebr_initialize(); esm_ebr_initialize();
......
...@@ -23,6 +23,7 @@ Description Defines the EPS Session Management procedures executed at ...@@ -23,6 +23,7 @@ Description Defines the EPS Session Management procedures executed at
#include "networkDef.h" #include "networkDef.h"
#include "OctetString.h" #include "OctetString.h"
#include "emmData.h"
/****************************************************************************/ /****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/ /********************* G L O B A L C O N S T A N T S *******************/
...@@ -68,7 +69,7 @@ typedef enum { ...@@ -68,7 +69,7 @@ typedef enum {
typedef int (*esm_proc_procedure_t) (int, int, OctetString *, int); typedef int (*esm_proc_procedure_t) (int, int, OctetString *, int);
#endif #endif
#ifdef NAS_MME #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 #endif
/* EPS bearer level QoS parameters */ /* EPS bearer level QoS parameters */
...@@ -106,8 +107,8 @@ int esm_proc_status(int is_standalone, int pti, OctetString *msg, ...@@ -106,8 +107,8 @@ int esm_proc_status(int is_standalone, int pti, OctetString *msg,
#endif #endif
#ifdef NAS_MME #ifdef NAS_MME
int esm_proc_status_ind(unsigned int ueid, int pti, int ebi, int *esm_cause); int esm_proc_status_ind(emm_data_context_t *ctx, int pti, int ebi, int *esm_cause);
int esm_proc_status(int is_standalone, unsigned int ueid, int pti, int esm_proc_status(int is_standalone, emm_data_context_t *ctx, int pti,
OctetString *msg, int sent_by_ue); OctetString *msg, int sent_by_ue);
#endif #endif
...@@ -131,14 +132,14 @@ int esm_proc_pdn_connectivity_failure(int is_pending); ...@@ -131,14 +132,14 @@ int esm_proc_pdn_connectivity_failure(int is_pending);
#endif #endif
#ifdef NAS_MME #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_request_t request_type, OctetString *apn,
esm_proc_pdn_type_t pdn_type, OctetString *pdn_addr, esm_proc_qos_t *esm_qos, esm_proc_pdn_type_t pdn_type, OctetString *pdn_addr, esm_proc_qos_t *esm_qos,
int *esm_cause); 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 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 #endif
/* /*
...@@ -156,10 +157,10 @@ int esm_proc_pdn_disconnect_reject(int pti, int *esm_cause); ...@@ -156,10 +157,10 @@ int esm_proc_pdn_disconnect_reject(int pti, int *esm_cause);
#endif #endif
#ifdef NAS_MME #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_accept(emm_data_context_t *ctx, int pid, int *esm_cause);
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); int ebi, OctetString *msg, int ue_triggered);
#endif #endif
...@@ -169,15 +170,15 @@ int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid, ...@@ -169,15 +170,15 @@ int esm_proc_pdn_disconnect_reject(int is_standalone, unsigned int ueid,
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
*/ */
#ifdef NAS_MME #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); unsigned int *ebi, const esm_proc_qos_t *esm_qos, int *esm_cause);
int esm_proc_default_eps_bearer_context_request(int is_standalone, int esm_proc_default_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_default_eps_bearer_context_failure(unsigned int ueid); 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_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); int *esm_cause);
#endif #endif
...@@ -199,15 +200,15 @@ int esm_proc_default_eps_bearer_context_reject(int is_standalone, int ebi, ...@@ -199,15 +200,15 @@ int esm_proc_default_eps_bearer_context_reject(int is_standalone, int ebi,
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
*/ */
#ifdef NAS_MME #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, unsigned int *ebi, unsigned int *default_ebi, const esm_proc_qos_t *qos,
const esm_proc_tft_t *tft, int *esm_cause); const esm_proc_tft_t *tft, int *esm_cause);
int esm_proc_dedicated_eps_bearer_context_request(int is_standalone, 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_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); int *esm_cause);
#endif #endif
...@@ -227,12 +228,12 @@ int esm_proc_dedicated_eps_bearer_context_reject(int is_standalone, int ebi, ...@@ -227,12 +228,12 @@ int esm_proc_dedicated_eps_bearer_context_reject(int is_standalone, int ebi,
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
*/ */
#ifdef NAS_MME #ifdef NAS_MME
int esm_proc_eps_bearer_context_deactivate(unsigned int ueid, int is_local, 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 ebi, int *pid, int *bid,
int *esm_cause);
int esm_proc_eps_bearer_context_deactivate_request(int is_standalone, int esm_proc_eps_bearer_context_deactivate_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_eps_bearer_context_deactivate_accept(emm_data_context_t *ctx, int ebi,
int esm_proc_eps_bearer_context_deactivate_accept(unsigned int ueid, int ebi,
int *esm_cause); int *esm_cause);
#endif #endif
......
...@@ -74,15 +74,15 @@ Description Defines functions executed at the ESM Service Access ...@@ -74,15 +74,15 @@ Description Defines functions executed at the ESM Service Access
int esm_recv_status(int pti, int ebi, const esm_status_msg *msg) int esm_recv_status(int pti, int ebi, const esm_status_msg *msg)
#endif #endif
#ifdef NAS_MME #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) const esm_status_msg *msg)
#endif #endif
{ {
LOG_FUNC_IN;
int esm_cause; int esm_cause;
int rc; int rc;
LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-SAP - Received ESM status message (pti=%d, ebi=%d)", LOG_TRACE(INFO, "ESM-SAP - Received ESM status message (pti=%d, ebi=%d)",
pti, ebi); pti, ebi);
...@@ -97,7 +97,7 @@ int esm_recv_status(unsigned int ueid, int pti, int ebi, ...@@ -97,7 +97,7 @@ int esm_recv_status(unsigned int ueid, int pti, int ebi,
rc = esm_proc_status_ind(pti, ebi, &esm_cause); rc = esm_proc_status_ind(pti, ebi, &esm_cause);
#endif #endif
#ifdef NAS_MME #ifdef NAS_MME
rc = esm_proc_status_ind(ueid, pti, ebi, &esm_cause); rc = esm_proc_status_ind(ctx, pti, ebi, &esm_cause);
#endif #endif
if (rc != RETURNerror) { if (rc != RETURNerror) {
esm_cause = ESM_CAUSE_SUCCESS; esm_cause = ESM_CAUSE_SUCCESS;
...@@ -678,16 +678,16 @@ int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi, ...@@ -678,16 +678,16 @@ int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
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, const pdn_connectivity_request_msg *msg,
unsigned int *new_ebi, void *data) unsigned int *new_ebi, void *data)
{ {
LOG_FUNC_IN;
int esm_cause = ESM_CAUSE_SUCCESS; int esm_cause = ESM_CAUSE_SUCCESS;
LOG_FUNC_IN;
LOG_TRACE(INFO, "ESM-SAP - Received PDN Connectivity Request message " LOG_TRACE(INFO, "ESM-SAP - Received PDN Connectivity Request message "
"(ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); "(ueid=%u, pti=%d, ebi=%d)", ctx->ueid, pti, ebi);
/* /*
* Procedure transaction identity checking * Procedure transaction identity checking
...@@ -767,7 +767,7 @@ int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi, ...@@ -767,7 +767,7 @@ int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi,
} }
/* Execute the PDN connectivity procedure requested by the UE */ /* Execute the PDN connectivity procedure requested by the UE */
int pid = esm_proc_pdn_connectivity_request(ueid, pti, request_type, int pid = esm_proc_pdn_connectivity_request(ctx, pti, request_type,
&esm_data->apn, &esm_data->apn,
esm_data->pdn_type, esm_data->pdn_type,
&esm_data->pdn_addr, &esm_data->pdn_addr,
...@@ -775,7 +775,7 @@ int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi, ...@@ -775,7 +775,7 @@ int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi,
&esm_cause); &esm_cause);
if (pid != RETURNerror) { if (pid != RETURNerror) {
/* Create local default EPS bearer context */ /* Create local default EPS bearer context */
int rc = esm_proc_default_eps_bearer_context(ueid, pid, new_ebi, int rc = esm_proc_default_eps_bearer_context(ctx, pid, new_ebi,
&esm_data->qos, &esm_cause); &esm_data->qos, &esm_cause);
if (rc != RETURNerror) { if (rc != RETURNerror) {
esm_cause = ESM_CAUSE_SUCCESS; esm_cause = ESM_CAUSE_SUCCESS;
...@@ -806,7 +806,7 @@ int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi, ...@@ -806,7 +806,7 @@ int esm_recv_pdn_connectivity_request(unsigned int ueid, int pti, int ebi,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi, int esm_recv_pdn_disconnect_request(emm_data_context_t *ctx, int pti, int ebi,
const pdn_disconnect_request_msg *msg, const pdn_disconnect_request_msg *msg,
unsigned int *linked_ebi) unsigned int *linked_ebi)
{ {
...@@ -815,7 +815,7 @@ int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi, ...@@ -815,7 +815,7 @@ int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi,
int esm_cause = ESM_CAUSE_SUCCESS; int esm_cause = ESM_CAUSE_SUCCESS;
LOG_TRACE(INFO, "ESM-SAP - Received PDN Disconnect Request message " LOG_TRACE(INFO, "ESM-SAP - Received PDN Disconnect Request message "
"(ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); "(ueid=%d, pti=%d, ebi=%d)", ctx->ueid, pti, ebi);
/* /*
* Procedure transaction identity checking * Procedure transaction identity checking
...@@ -842,14 +842,14 @@ int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi, ...@@ -842,14 +842,14 @@ int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi,
* Message processing * Message processing
*/ */
/* Execute the PDN disconnect procedure requested by the UE */ /* Execute the PDN disconnect procedure requested by the UE */
int pid = esm_proc_pdn_disconnect_request(ueid, pti, &esm_cause); int pid = esm_proc_pdn_disconnect_request(ctx, pti, &esm_cause);
if (pid != RETURNerror) { if (pid != RETURNerror) {
/* Get the identity of the default EPS bearer context assigned to /* Get the identity of the default EPS bearer context assigned to
* the PDN connection to disconnect from */ * the PDN connection to disconnect from */
*linked_ebi = msg->linkedepsbeareridentity; *linked_ebi = msg->linkedepsbeareridentity;
/* Release the associated default EPS bearer context */ /* Release the associated default EPS bearer context */
int bid = 0; int bid = 0;
int rc = esm_proc_eps_bearer_context_deactivate(ueid, FALSE, int rc = esm_proc_eps_bearer_context_deactivate(ctx, FALSE,
*linked_ebi, *linked_ebi,
&pid, &bid, &esm_cause); &pid, &bid, &esm_cause);
if (rc != RETURNerror) { if (rc != RETURNerror) {
...@@ -880,7 +880,7 @@ int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi, ...@@ -880,7 +880,7 @@ int esm_recv_pdn_disconnect_request(unsigned int ueid, int pti, int ebi,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
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, int pti, int ebi,
const activate_default_eps_bearer_context_accept_msg *msg) const activate_default_eps_bearer_context_accept_msg *msg)
{ {
...@@ -889,7 +889,7 @@ int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid, ...@@ -889,7 +889,7 @@ int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid,
int esm_cause = ESM_CAUSE_SUCCESS; int esm_cause = ESM_CAUSE_SUCCESS;
LOG_TRACE(INFO, "ESM-SAP - Received Activate Default EPS Bearer Context " LOG_TRACE(INFO, "ESM-SAP - Received Activate Default EPS Bearer Context "
"Accept message (ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); "Accept message (ueid=%d, pti=%d, ebi=%d)", ctx->ueid, pti, ebi);
/* /*
* Procedure transaction identity checking * Procedure transaction identity checking
...@@ -904,7 +904,7 @@ int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid, ...@@ -904,7 +904,7 @@ int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid,
/* /*
* EPS bearer identity checking * EPS bearer identity checking
*/ */
else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ueid, ebi) ) { else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ctx, ebi) ) {
/* 3GPP TS 24.301, section 7.3.2, case f /* 3GPP TS 24.301, section 7.3.2, case f
* Reserved or assigned value that does not match an existing EPS * Reserved or assigned value that does not match an existing EPS
* bearer context * bearer context
...@@ -918,7 +918,7 @@ int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid, ...@@ -918,7 +918,7 @@ int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid,
*/ */
/* Execute the default EPS bearer context activation procedure accepted /* Execute the default EPS bearer context activation procedure accepted
* by the UE */ * by the UE */
int rc = esm_proc_default_eps_bearer_context_accept(ueid, ebi, &esm_cause); int rc = esm_proc_default_eps_bearer_context_accept(ctx, ebi, &esm_cause);
if (rc != RETURNerror) { if (rc != RETURNerror) {
esm_cause = ESM_CAUSE_SUCCESS; esm_cause = ESM_CAUSE_SUCCESS;
} }
...@@ -946,7 +946,7 @@ int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid, ...@@ -946,7 +946,7 @@ int esm_recv_activate_default_eps_bearer_context_accept(unsigned int ueid,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
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, int pti, int ebi,
const activate_default_eps_bearer_context_reject_msg *msg) const activate_default_eps_bearer_context_reject_msg *msg)
{ {
...@@ -955,7 +955,7 @@ int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid, ...@@ -955,7 +955,7 @@ int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid,
int esm_cause = ESM_CAUSE_SUCCESS; int esm_cause = ESM_CAUSE_SUCCESS;
LOG_TRACE(INFO, "ESM-SAP - Received Activate Default EPS Bearer Context " LOG_TRACE(INFO, "ESM-SAP - Received Activate Default EPS Bearer Context "
"Reject message (ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); "Reject message (ueid=%d, pti=%d, ebi=%d)", ctx->ueid, pti, ebi);
/* /*
* Procedure transaction identity checking * Procedure transaction identity checking
...@@ -970,7 +970,7 @@ int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid, ...@@ -970,7 +970,7 @@ int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid,
/* /*
* EPS bearer identity checking * EPS bearer identity checking
*/ */
else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ueid, ebi) ) { else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ctx, ebi) ) {
/* 3GPP TS 24.301, section 7.3.2, case f /* 3GPP TS 24.301, section 7.3.2, case f
* Reserved or assigned value that does not match an existing EPS * Reserved or assigned value that does not match an existing EPS
* bearer context * bearer context
...@@ -984,7 +984,7 @@ int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid, ...@@ -984,7 +984,7 @@ int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid,
*/ */
/* Execute the default EPS bearer context activation procedure not accepted /* Execute the default EPS bearer context activation procedure not accepted
* by the UE */ * by the UE */
int rc = esm_proc_default_eps_bearer_context_reject(ueid, ebi, &esm_cause); int rc = esm_proc_default_eps_bearer_context_reject(ctx, ebi, &esm_cause);
if (rc != RETURNerror) { if (rc != RETURNerror) {
esm_cause = ESM_CAUSE_SUCCESS; esm_cause = ESM_CAUSE_SUCCESS;
} }
...@@ -1012,7 +1012,7 @@ int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid, ...@@ -1012,7 +1012,7 @@ int esm_recv_activate_default_eps_bearer_context_reject(unsigned int ueid,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
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, int pti, int ebi,
const activate_dedicated_eps_bearer_context_accept_msg *msg) const activate_dedicated_eps_bearer_context_accept_msg *msg)
{ {
...@@ -1022,7 +1022,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid, ...@@ -1022,7 +1022,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid,
LOG_TRACE(INFO, "ESM-SAP - Received Activate Dedicated EPS Bearer " LOG_TRACE(INFO, "ESM-SAP - Received Activate Dedicated EPS Bearer "
"Context Accept message (ueid=%d, pti=%d, ebi=%d)", "Context Accept message (ueid=%d, pti=%d, ebi=%d)",
ueid, pti, ebi); ctx->ueid, pti, ebi);
/* /*
* Procedure transaction identity checking * Procedure transaction identity checking
...@@ -1037,7 +1037,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid, ...@@ -1037,7 +1037,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid,
/* /*
* EPS bearer identity checking * EPS bearer identity checking
*/ */
else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ueid, ebi) ) { else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ctx, ebi) ) {
/* 3GPP TS 24.301, section 7.3.2, case f /* 3GPP TS 24.301, section 7.3.2, case f
* Reserved or assigned value that does not match an existing EPS * Reserved or assigned value that does not match an existing EPS
* bearer context * bearer context
...@@ -1051,7 +1051,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid, ...@@ -1051,7 +1051,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid,
*/ */
/* Execute the dedicated EPS bearer context activation procedure accepted /* Execute the dedicated EPS bearer context activation procedure accepted
* by the UE */ * by the UE */
int rc = esm_proc_dedicated_eps_bearer_context_accept(ueid, ebi, int rc = esm_proc_dedicated_eps_bearer_context_accept(ctx, ebi,
&esm_cause); &esm_cause);
if (rc != RETURNerror) { if (rc != RETURNerror) {
esm_cause = ESM_CAUSE_SUCCESS; esm_cause = ESM_CAUSE_SUCCESS;
...@@ -1080,7 +1080,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid, ...@@ -1080,7 +1080,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_accept(unsigned int ueid,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
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, int pti, int ebi,
const activate_dedicated_eps_bearer_context_reject_msg *msg) const activate_dedicated_eps_bearer_context_reject_msg *msg)
{ {
...@@ -1090,7 +1090,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid, ...@@ -1090,7 +1090,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid,
LOG_TRACE(INFO, "ESM-SAP - Received Activate Dedicated EPS Bearer " LOG_TRACE(INFO, "ESM-SAP - Received Activate Dedicated EPS Bearer "
"Context Reject message (ueid=%d, pti=%d, ebi=%d)", "Context Reject message (ueid=%d, pti=%d, ebi=%d)",
ueid, pti, ebi); ctx->ueid, pti, ebi);
/* /*
* Procedure transaction identity checking * Procedure transaction identity checking
...@@ -1105,7 +1105,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid, ...@@ -1105,7 +1105,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid,
/* /*
* EPS bearer identity checking * EPS bearer identity checking
*/ */
else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ueid, ebi) ) { else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ctx, ebi) ) {
/* 3GPP TS 24.301, section 7.3.2, case f /* 3GPP TS 24.301, section 7.3.2, case f
* Reserved or assigned value that does not match an existing EPS * Reserved or assigned value that does not match an existing EPS
* bearer context * bearer context
...@@ -1119,7 +1119,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid, ...@@ -1119,7 +1119,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid,
*/ */
/* Execute the dedicated EPS bearer context activation procedure not /* Execute the dedicated EPS bearer context activation procedure not
* accepted by the UE */ * accepted by the UE */
int rc = esm_proc_dedicated_eps_bearer_context_reject(ueid, ebi, int rc = esm_proc_dedicated_eps_bearer_context_reject(ctx, ebi,
&esm_cause); &esm_cause);
if (rc != RETURNerror) { if (rc != RETURNerror) {
esm_cause = ESM_CAUSE_SUCCESS; esm_cause = ESM_CAUSE_SUCCESS;
...@@ -1147,7 +1147,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid, ...@@ -1147,7 +1147,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_reject(unsigned int ueid,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid, int esm_recv_deactivate_eps_bearer_context_accept(emm_data_context_t *ctx,
int pti, int ebi, int pti, int ebi,
const deactivate_eps_bearer_context_accept_msg *msg) const deactivate_eps_bearer_context_accept_msg *msg)
{ {
...@@ -1156,7 +1156,7 @@ int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid, ...@@ -1156,7 +1156,7 @@ int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid,
int esm_cause = ESM_CAUSE_SUCCESS; int esm_cause = ESM_CAUSE_SUCCESS;
LOG_TRACE(INFO, "ESM-SAP - Received Deactivate EPS Bearer Context " LOG_TRACE(INFO, "ESM-SAP - Received Deactivate EPS Bearer Context "
"Accept message (ueid=%d, pti=%d, ebi=%d)", ueid, pti, ebi); "Accept message (ueid=%d, pti=%d, ebi=%d)", ctx->ueid, pti, ebi);
/* /*
* Procedure transaction identity checking * Procedure transaction identity checking
...@@ -1171,7 +1171,7 @@ int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid, ...@@ -1171,7 +1171,7 @@ int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid,
/* /*
* EPS bearer identity checking * EPS bearer identity checking
*/ */
else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ueid, ebi) ) { else if ( esm_ebr_is_reserved(ebi) || esm_ebr_is_not_in_use(ctx, ebi) ) {
/* 3GPP TS 24.301, section 7.3.2, case f /* 3GPP TS 24.301, section 7.3.2, case f
* Reserved or assigned value that does not match an existing EPS * Reserved or assigned value that does not match an existing EPS
* bearer context * bearer context
...@@ -1185,11 +1185,11 @@ int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid, ...@@ -1185,11 +1185,11 @@ int esm_recv_deactivate_eps_bearer_context_accept(unsigned int ueid,
*/ */
/* Execute the default EPS bearer context activation procedure accepted /* Execute the default EPS bearer context activation procedure accepted
* by the UE */ * by the UE */
int pid = esm_proc_eps_bearer_context_deactivate_accept(ueid, ebi, int pid = esm_proc_eps_bearer_context_deactivate_accept(ctx, ebi,
&esm_cause); &esm_cause);
if (pid != RETURNerror) { if (pid != RETURNerror) {
/* Release all the resources reserved for the PDN */ /* Release all the resources reserved for the PDN */
int rc = esm_proc_pdn_disconnect_accept(ueid, pid, &esm_cause); int rc = esm_proc_pdn_disconnect_accept(ctx, pid, &esm_cause);
if (rc != RETURNerror) { if (rc != RETURNerror) {
esm_cause = ESM_CAUSE_SUCCESS; esm_cause = ESM_CAUSE_SUCCESS;
......
...@@ -23,6 +23,7 @@ Description Defines functions executed at the ESM Service Access ...@@ -23,6 +23,7 @@ Description Defines functions executed at the ESM Service Access
#define __ESM_RECV_H__ #define __ESM_RECV_H__
#include "EsmStatus.h" #include "EsmStatus.h"
#include "emmData.h"
#ifdef NAS_UE #ifdef NAS_UE
#include "PdnConnectivityReject.h" #include "PdnConnectivityReject.h"
...@@ -80,7 +81,7 @@ Description Defines functions executed at the ESM Service Access ...@@ -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); int esm_recv_status(int pti, int ebi, const esm_status_msg *msg);
#endif #endif
#ifdef NAS_MME #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); const esm_status_msg *msg);
#endif #endif
...@@ -124,29 +125,30 @@ int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi, ...@@ -124,29 +125,30 @@ int esm_recv_deactivate_eps_bearer_context_request(int pti, int ebi,
* Transaction related messages * 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); 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, 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); const pdn_disconnect_request_msg *msg,
unsigned int *linked_ebi);
/* /*
* Messages related to EPS bearer contexts * 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 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 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 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 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); int ebi, const deactivate_eps_bearer_context_accept_msg *msg);
#endif #endif
......
...@@ -53,9 +53,9 @@ static int _esm_sap_send(int msg_type, int is_standalone, int pti, int ebi, ...@@ -53,9 +53,9 @@ static int _esm_sap_send(int msg_type, int is_standalone, int pti, int ebi,
#endif #endif
#ifdef NAS_MME #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); 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); int pti, int ebi, const esm_sap_data_t *data, OctetString *rsp);
#endif #endif
...@@ -186,16 +186,16 @@ int esm_sap_send(esm_sap_t *msg) ...@@ -186,16 +186,16 @@ int esm_sap_send(esm_sap_t *msg)
#ifdef NAS_MME #ifdef NAS_MME
/* The MME received a PDN connectivity request message */ /* The MME received a PDN connectivity request message */
rc = _esm_sap_recv(PDN_CONNECTIVITY_REQUEST, msg->is_standalone, 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 #endif
break; break;
case ESM_PDN_CONNECTIVITY_REJ: case ESM_PDN_CONNECTIVITY_REJ:
#ifdef NAS_MME #ifdef NAS_MME
/* PDN connectivity locally failed */ /* 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) { if (pid != RETURNerror) {
rc = esm_proc_pdn_connectivity_failure(msg->ueid, pid); rc = esm_proc_pdn_connectivity_failure(msg->ctx, pid);
} }
#endif #endif
#ifdef NAS_UE #ifdef NAS_UE
...@@ -264,7 +264,7 @@ int esm_sap_send(esm_sap_t *msg) ...@@ -264,7 +264,7 @@ int esm_sap_send(esm_sap_t *msg)
#ifdef NAS_MME #ifdef NAS_MME
/* The MME received activate default ESP bearer context accept */ /* The MME received activate default ESP bearer context accept */
rc = _esm_sap_recv(ACTIVATE_DEFAULT_EPS_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); msg->recv, &msg->send, &msg->err);
#endif #endif
#ifdef NAS_UE #ifdef NAS_UE
...@@ -283,7 +283,7 @@ int esm_sap_send(esm_sap_t *msg) ...@@ -283,7 +283,7 @@ int esm_sap_send(esm_sap_t *msg)
#ifdef NAS_MME #ifdef NAS_MME
/* The MME received activate default ESP bearer context reject */ /* The MME received activate default ESP bearer context reject */
rc = _esm_sap_recv(ACTIVATE_DEFAULT_EPS_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); msg->recv, &msg->send, &msg->err);
#endif #endif
#ifdef NAS_UE #ifdef NAS_UE
...@@ -325,7 +325,7 @@ int esm_sap_send(esm_sap_t *msg) ...@@ -325,7 +325,7 @@ int esm_sap_send(esm_sap_t *msg)
msg->data.eps_bearer_context_deactivate.ebi, &pid, &bid); msg->data.eps_bearer_context_deactivate.ebi, &pid, &bid);
#endif #endif
#ifdef NAS_MME #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, msg->data.eps_bearer_context_deactivate.ebi,
&pid, &bid, NULL); &pid, &bid, NULL);
#endif #endif
...@@ -341,7 +341,7 @@ int esm_sap_send(esm_sap_t *msg) ...@@ -341,7 +341,7 @@ int esm_sap_send(esm_sap_t *msg)
&msg->send, &msg->err); &msg->send, &msg->err);
#endif #endif
#ifdef NAS_MME #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); msg->recv, &msg->send, &msg->err);
#endif #endif
break; break;
...@@ -396,7 +396,7 @@ int esm_sap_send(esm_sap_t *msg) ...@@ -396,7 +396,7 @@ int esm_sap_send(esm_sap_t *msg)
***************************************************************************/ ***************************************************************************/
static int _esm_sap_recv(int msg_type, int is_standalone, static int _esm_sap_recv(int msg_type, int is_standalone,
#ifdef NAS_MME #ifdef NAS_MME
unsigned int ueid, emm_data_context_t *ctx,
#endif #endif
const OctetString *req, OctetString *rsp, const OctetString *req, OctetString *rsp,
esm_sap_error_t *err) esm_sap_error_t *err)
...@@ -647,7 +647,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone, ...@@ -647,7 +647,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
* received from the UE * received from the UE
*/ */
esm_cause = esm_recv_activate_default_eps_bearer_context_accept( esm_cause = esm_recv_activate_default_eps_bearer_context_accept(
ueid, pti, ebi, ctx, pti, ebi,
&esm_msg.activate_default_eps_bearer_context_accept); &esm_msg.activate_default_eps_bearer_context_accept);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
...@@ -668,7 +668,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone, ...@@ -668,7 +668,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
* received from the UE * received from the UE
*/ */
esm_cause = esm_recv_activate_default_eps_bearer_context_reject( esm_cause = esm_recv_activate_default_eps_bearer_context_reject(
ueid, pti, ebi, ctx, pti, ebi,
&esm_msg.activate_default_eps_bearer_context_reject); &esm_msg.activate_default_eps_bearer_context_reject);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
...@@ -689,7 +689,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone, ...@@ -689,7 +689,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
* received from the UE * received from the UE
*/ */
esm_cause = esm_recv_deactivate_eps_bearer_context_accept( esm_cause = esm_recv_deactivate_eps_bearer_context_accept(
ueid, pti, ebi, ctx, pti, ebi,
&esm_msg.deactivate_eps_bearer_context_accept); &esm_msg.deactivate_eps_bearer_context_accept);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
...@@ -710,7 +710,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone, ...@@ -710,7 +710,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
* received from the UE * received from the UE
*/ */
esm_cause = esm_recv_activate_dedicated_eps_bearer_context_accept( esm_cause = esm_recv_activate_dedicated_eps_bearer_context_accept(
ueid, pti, ebi, ctx, pti, ebi,
&esm_msg.activate_dedicated_eps_bearer_context_accept); &esm_msg.activate_dedicated_eps_bearer_context_accept);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
...@@ -731,7 +731,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone, ...@@ -731,7 +731,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
* received from the UE * received from the UE
*/ */
esm_cause = esm_recv_activate_dedicated_eps_bearer_context_reject( esm_cause = esm_recv_activate_dedicated_eps_bearer_context_reject(
ueid, pti, ebi, ctx, pti, ebi,
&esm_msg.activate_dedicated_eps_bearer_context_reject); &esm_msg.activate_dedicated_eps_bearer_context_reject);
if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) || if ( (esm_cause == ESM_CAUSE_INVALID_PTI_VALUE) ||
...@@ -759,7 +759,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone, ...@@ -759,7 +759,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
/* /*
* Process PDN connectivity request message received from the UE * 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, &esm_msg.pdn_connectivity_request,
&ebi, &data); &ebi, &data);
...@@ -854,7 +854,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone, ...@@ -854,7 +854,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
/* /*
* Process PDN disconnect request message received from the UE * 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); &esm_msg.pdn_disconnect_request, &ebi);
if (esm_cause != ESM_CAUSE_SUCCESS) { if (esm_cause != ESM_CAUSE_SUCCESS) {
...@@ -890,7 +890,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone, ...@@ -890,7 +890,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
/* /*
* Process received ESM status message * 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; break;
#endif #endif
...@@ -935,7 +935,7 @@ static int _esm_sap_recv(int msg_type, int is_standalone, ...@@ -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); rc = (*esm_procedure)(is_standalone, ebi, rsp, triggered_by_ue);
#endif #endif
#ifdef NAS_MME #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 #endif
if (is_discarded) { if (is_discarded) {
/* Return indication that received message has been discarded */ /* Return indication that received message has been discarded */
...@@ -980,10 +980,10 @@ static int _esm_sap_recv(int msg_type, int is_standalone, ...@@ -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, static int _esm_sap_send(int msg_type, int is_standalone,
#ifdef NAS_MME #ifdef NAS_MME
unsigned int ueid, emm_data_context_t *ctx,
#endif #endif
int pti, int ebi, const esm_sap_data_t *data, int pti, int ebi, const esm_sap_data_t *data,
OctetString *rsp) OctetString *rsp)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -1103,7 +1103,7 @@ static int _esm_sap_send(int msg_type, int is_standalone, ...@@ -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); rc = (*esm_procedure)(is_standalone, pti, rsp, sent_by_ue);
#endif #endif
#ifdef NAS_MME #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 #endif
} }
} }
......
...@@ -18,6 +18,9 @@ Description Defines the ESM Service Access Point that provides EPS ...@@ -18,6 +18,9 @@ Description Defines the ESM Service Access Point that provides EPS
bearer context handling and resources allocation procedures. bearer context handling and resources allocation procedures.
*****************************************************************************/ *****************************************************************************/
#include "emmData.h"
#ifndef __ESM_SAPDEF_H__ #ifndef __ESM_SAPDEF_H__
#define __ESM_SAPDEF_H__ #define __ESM_SAPDEF_H__
...@@ -132,11 +135,14 @@ typedef struct { ...@@ -132,11 +135,14 @@ typedef struct {
* within this primitive has to be sent/received * within this primitive has to be sent/received
* standalone or together within an EMM related * standalone or together within an EMM related
* message */ * message */
unsigned int ueid; /* Local UE identifier */ #if defined(NAS_MME)
esm_sap_error_t err; /* ESM-SAP error code */ emm_data_context_t *ctx; /* UE context */
const OctetString *recv; /* Encoded ESM message received */ #endif
OctetString send; /* Encoded ESM message to be sent */ unsigned int ueid; /* Local UE identifier */
esm_sap_data_t data; /* ESM message data parameters */ 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; } esm_sap_t;
/****************************************************************************/ /****************************************************************************/
......
...@@ -47,20 +47,6 @@ int nas_itti_dl_data_req(const uint32_t ue_id, void *const data, ...@@ -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); 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 #endif
#if defined(UE_BUILD) && defined(NAS_UE) #if defined(UE_BUILD) && defined(NAS_UE)
......
...@@ -43,8 +43,21 @@ ...@@ -43,8 +43,21 @@
int nas_itti_dl_data_req(const uint32_t ue_id, void *const data, int nas_itti_dl_data_req(const uint32_t ue_id, void *const data,
const uint32_t length); const uint32_t length);
void nas_itti_establish_cnf(const nas_error_code_t error_code, void *const data, static inline void nas_itti_establish_cnf(const uint32_t ue_id,
const uint32_t length); 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, 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) 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, ...@@ -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 = S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.buffer =
malloc(sizeof(uint8_t) * item_p->nAS_PDU->size); 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); item_p->nAS_PDU->buf, item_p->nAS_PDU->size);
} else { } else {
S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.length = 0; 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) ...@@ -151,16 +151,7 @@ void *s1ap_mme_thread(void *args)
} break; } break;
#else #else
case NAS_CONNECTION_ESTABLISHMENT_CNF: { case NAS_CONNECTION_ESTABLISHMENT_CNF: {
if (AS_TERMINATED_NAS == NAS_CONN_EST_CNF(received_message_p).nas_establish_cnf.errCode) { s1ap_handle_conn_est_cnf(&NAS_CONNECTION_ESTABLISHMENT_CNF(received_message_p));
/* 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));
}
} break; } break;
#endif #endif
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
*******************************************************************************/ *******************************************************************************/
#include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include "s1ap_common.h" #include "s1ap_common.h"
...@@ -226,7 +227,6 @@ int s1ap_generate_downlink_nas_transport(const uint32_t ue_id, void * const data ...@@ -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, s1ap_mme_itti_send_sctp_request(buffer_p, length,
ue_ref->eNB->sctp_assoc_id, ue_ref->eNB->sctp_assoc_id,
ue_ref->sctp_stream_send); ue_ref->sctp_stream_send);
//s1ap_mme_itti_nas_downlink_cnf(ue_ref->mme_ue_s1ap_id, AS_SUCCESS);
} }
return 0; return 0;
} }
...@@ -365,26 +365,24 @@ void s1ap_handle_conn_est_cnf(nas_conn_est_cnf_t *nas_conn_est_cnf_p) ...@@ -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 * At least one bearer has been established. We can now send s1ap initial context setup request
* message to eNB. * message to eNB.
*/ */
uint8_t supportedAlgorithms[] = { 0x00, 0x02 }; uint8_t supportedAlgorithms[] = { 0x00, 0x00 };
uint8_t offset = 0; uint8_t offset = 0;
uint8_t *buffer_p; uint8_t *buffer_p;
uint32_t length; uint32_t length, teid = 12;
ue_description_t *ue_ref = NULL; ue_description_t *ue_ref = NULL;
s1ap_message message; s1ap_message message;
s1ap_initial_ctxt_setup_req_t *initial_p;
S1ap_InitialContextSetupRequestIEs_t *initialContextSetupRequest_p; S1ap_InitialContextSetupRequestIEs_t *initialContextSetupRequest_p;
S1ap_E_RABToBeSetupItemCtxtSUReq_t e_RABToBeSetup; S1ap_E_RABToBeSetupItemCtxtSUReq_t e_RABToBeSetup;
S1ap_NAS_PDU_t nas_pdu;
DevAssert(nas_conn_est_cnf_p != NULL); 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(nas_conn_est_cnf_p->UEid)) == NULL) {
if ((ue_ref = s1ap_is_ue_mme_id_in_list(initial_p->mme_ue_s1ap_id)) == NULL) {
S1AP_DEBUG("This mme ue s1ap id (%08x) is not attached to any UE context\n", S1AP_DEBUG("This mme ue s1ap id (%08x) is not attached to any UE context\n",
initial_p->mme_ue_s1ap_id); nas_conn_est_cnf_p->UEid);
DevParam(initial_p->mme_ue_s1ap_id, 0, 0); DevParam(nas_conn_est_cnf_p->UEid, 0, 0);
} }
/* Start the outcome response timer. /* 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) ...@@ -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; initialContextSetupRequest_p->eNB_UE_S1AP_ID = (unsigned long)ue_ref->eNB_ue_s1ap_id;
/* uEaggregateMaximumBitrateDL and uEaggregateMaximumBitrateUL expressed in term of bits/sec */ /* uEaggregateMaximumBitrateDL and uEaggregateMaximumBitrateUL expressed in term of bits/sec */
initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL = initial_p->ambr.br_dl; // initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL = initial_p->ambr.br_dl;
initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateUL = initial_p->ambr.br_ul; // initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateUL = initial_p->ambr.br_ul;
e_RABToBeSetup.e_RAB_ID = initial_p->ebi; initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL = 1024 * 1024;
e_RABToBeSetup.e_RABlevelQoSParameters.qCI = initial_p->qci; initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL = 512 * 1024;
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.priorityLevel
= initial_p->prio_level; //No priority // e_RABToBeSetup.e_RAB_ID = initial_p->ebi;
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionCapability e_RABToBeSetup.e_RAB_ID = 5;
= initial_p->pre_emp_capability; // e_RABToBeSetup.e_RABlevelQoSParameters.qCI = initial_p->qci;
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability e_RABToBeSetup.e_RABlevelQoSParameters.qCI = 0;
= initial_p->pre_emp_vulnerability;
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 */ /* 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 */ /* S-GW IP address(es) for user-plane */
if ((initial_p->s_gw_address.pdn_type == IPv4) || // if ((initial_p->s_gw_address.pdn_type == IPv4) ||
(initial_p->s_gw_address.pdn_type == IPv4_AND_v6)) // (initial_p->s_gw_address.pdn_type == IPv4_AND_v6))
{ // {
e_RABToBeSetup.transportLayerAddress.buf = calloc(4, sizeof(uint8_t)); // e_RABToBeSetup.transportLayerAddress.buf = calloc(4, sizeof(uint8_t));
/* Only IPv4 supported */ // /* Only IPv4 supported */
memcpy(e_RABToBeSetup.transportLayerAddress.buf, // memcpy(e_RABToBeSetup.transportLayerAddress.buf,
initial_p->s_gw_address.address.ipv4_address, // initial_p->s_gw_address.address.ipv4_address,
4); // 4);
offset += 4; // offset += 4;
e_RABToBeSetup.transportLayerAddress.size = 4; // e_RABToBeSetup.transportLayerAddress.size = 4;
e_RABToBeSetup.transportLayerAddress.bits_unused = 0; // e_RABToBeSetup.transportLayerAddress.bits_unused = 0;
} // }
if ((initial_p->s_gw_address.pdn_type == IPv6) || // if ((initial_p->s_gw_address.pdn_type == IPv6) ||
(initial_p->s_gw_address.pdn_type == IPv4_AND_v6)) // (initial_p->s_gw_address.pdn_type == IPv4_AND_v6))
{ // {
if (offset == 0) { // if (offset == 0) {
/* Both IPv4 and IPv6 provided */ // /* Both IPv4 and IPv6 provided */
/* TODO: check memory allocation */ // /* TODO: check memory allocation */
e_RABToBeSetup.transportLayerAddress.buf = calloc(16, sizeof(uint8_t)); // e_RABToBeSetup.transportLayerAddress.buf = calloc(16, sizeof(uint8_t));
} else { // } else {
/* Only IPv6 supported */ // /* Only IPv6 supported */
/* TODO: check memory allocation */ // /* TODO: check memory allocation */
e_RABToBeSetup.transportLayerAddress.buf // e_RABToBeSetup.transportLayerAddress.buf
= realloc(e_RABToBeSetup.transportLayerAddress.buf, (16 + offset) * sizeof(uint8_t)); // = realloc(e_RABToBeSetup.transportLayerAddress.buf, (16 + offset) * sizeof(uint8_t));
} // }
memcpy(&e_RABToBeSetup.transportLayerAddress.buf[offset], // memcpy(&e_RABToBeSetup.transportLayerAddress.buf[offset],
initial_p->s_gw_address.address.ipv6_address, // initial_p->s_gw_address.address.ipv6_address,
16); // 16);
e_RABToBeSetup.transportLayerAddress.size = 16 + offset; // e_RABToBeSetup.transportLayerAddress.size = 16 + offset;
e_RABToBeSetup.transportLayerAddress.bits_unused = 0; // e_RABToBeSetup.transportLayerAddress.bits_unused = 0;
} // }
ASN_SEQUENCE_ADD(&initialContextSetupRequest_p->e_RABToBeSetupListCtxtSUReq, ASN_SEQUENCE_ADD(&initialContextSetupRequest_p->e_RABToBeSetupListCtxtSUReq,
&e_RABToBeSetup); &e_RABToBeSetup);
...@@ -473,7 +490,11 @@ void s1ap_handle_conn_est_cnf(nas_conn_est_cnf_t *nas_conn_est_cnf_p) ...@@ -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 initialContextSetupRequest_p->ueSecurityCapabilities.integrityProtectionAlgorithms.bits_unused
= 0; = 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.size = 32;
initialContextSetupRequest_p->securityKey.bits_unused = 0; 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) ...@@ -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"); 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, s1ap_mme_itti_send_sctp_request(buffer_p, length, ue_ref->eNB->sctp_assoc_id,
ue_ref->sctp_stream_send); ue_ref->sctp_stream_send);
} }
......
...@@ -67,7 +67,7 @@ int s1ap_mme_handle_nas_non_delivery(uint32_t assocId, uint32_t stream, ...@@ -67,7 +67,7 @@ int s1ap_mme_handle_nas_non_delivery(uint32_t assocId, uint32_t stream,
#if defined(DISABLE_USE_NAS) #if defined(DISABLE_USE_NAS)
int s1ap_handle_attach_accepted(nas_attach_accept_t *attach_accept_p); int s1ap_handle_attach_accepted(nas_attach_accept_t *attach_accept_p);
#else #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 #endif
int s1ap_generate_downlink_nas_transport(const uint32_t ue_id, void * const data, 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