Commit 20cb51cb authored by Frédéric Leroy's avatar Frédéric Leroy

UE/EMM: move _emm_data to nas_user_t

parent 97fdf8bb
This diff is collapsed.
...@@ -163,11 +163,11 @@ static int _authentication_kasme(const OctetString *autn, ...@@ -163,11 +163,11 @@ static int _authentication_kasme(const OctetString *autn,
** ksi: The NAS ket sey identifier ** ** ksi: The NAS ket sey identifier **
** rand: Authentication parameter RAND ** ** rand: Authentication parameter RAND **
** autn: Authentication parameter AUTN ** ** autn: Authentication parameter AUTN **
** Others: _emm_data, _authentication_data ** ** Others: user->emm_data-> _authentication_data **
** ** ** **
** Outputs: None ** ** Outputs: None **
** Return: RETURNok, RETURNerror ** ** Return: RETURNok, RETURNerror **
** Others: _emm_data, _authentication_data, T3416, ** ** Others: user->emm_data-> _authentication_data, T3416, **
** T3418, T3420 ** ** T3418, T3420 **
** ** ** **
***************************************************************************/ ***************************************************************************/
...@@ -185,7 +185,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi, ...@@ -185,7 +185,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
* The UE shall proceed with an EPS authentication challenge only if a * The UE shall proceed with an EPS authentication challenge only if a
* USIM is present * USIM is present
*/ */
if (!_emm_data.usim_is_valid) { if (!user->emm_data->usim_is_valid) {
LOG_TRACE(WARNING, "EMM-PROC - USIM is not present or not valid"); LOG_TRACE(WARNING, "EMM-PROC - USIM is not present or not valid");
LOG_FUNC_RETURN (RETURNerror); LOG_FUNC_RETURN (RETURNerror);
} }
...@@ -327,14 +327,14 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi, ...@@ -327,14 +327,14 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
*/ */
emm_sap_t emm_sap; emm_sap_t emm_sap;
emm_sap.primitive = EMMAS_SECURITY_RES; emm_sap.primitive = EMMAS_SECURITY_RES;
emm_sap.u.emm_as.u.security.guti = _emm_data.guti; emm_sap.u.emm_as.u.security.guti = user->emm_data->guti;
emm_sap.u.emm_as.u.security.ueid = 0; emm_sap.u.emm_as.u.security.ueid = 0;
emm_sap.u.emm_as.u.security.msgType = EMM_AS_MSG_TYPE_AUTH; emm_sap.u.emm_as.u.security.msgType = EMM_AS_MSG_TYPE_AUTH;
emm_sap.u.emm_as.u.security.emm_cause = EMM_CAUSE_SUCCESS; emm_sap.u.emm_as.u.security.emm_cause = EMM_CAUSE_SUCCESS;
emm_sap.u.emm_as.u.security.res = &res; emm_sap.u.emm_as.u.security.res = &res;
/* Setup EPS NAS security data */ /* Setup EPS NAS security data */
emm_as_set_security_data(&emm_sap.u.emm_as.u.security.sctx, emm_as_set_security_data(&emm_sap.u.emm_as.u.security.sctx,
_emm_data.security, FALSE, TRUE); user->emm_data->security, FALSE, TRUE);
rc = emm_sap_send(user, &emm_sap); rc = emm_sap_send(user, &emm_sap);
if (rc != RETURNerror) { if (rc != RETURNerror) {
...@@ -344,29 +344,29 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi, ...@@ -344,29 +344,29 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
_authentication_data.sync_count = 0; _authentication_data.sync_count = 0;
/* Create non-current EPS security context */ /* Create non-current EPS security context */
if (_emm_data.non_current == NULL) { if (user->emm_data->non_current == NULL) {
_emm_data.non_current = user->emm_data->non_current =
(emm_security_context_t *)malloc(sizeof(emm_security_context_t)); (emm_security_context_t *)malloc(sizeof(emm_security_context_t));
} }
if (_emm_data.non_current) { if (user->emm_data->non_current) {
memset(_emm_data.non_current, 0, sizeof(emm_security_context_t)); memset(user->emm_data->non_current, 0, sizeof(emm_security_context_t));
/* Set the security context type */ /* Set the security context type */
if (native_ksi) { if (native_ksi) {
_emm_data.non_current->type = EMM_KSI_NATIVE; user->emm_data->non_current->type = EMM_KSI_NATIVE;
} else { } else {
_emm_data.non_current->type = EMM_KSI_MAPPED; user->emm_data->non_current->type = EMM_KSI_MAPPED;
} }
/* Set the EPS key set identifier */ /* Set the EPS key set identifier */
_emm_data.non_current->eksi = ksi; user->emm_data->non_current->eksi = ksi;
/* Derive the Kasme from the authentication challenge using /* Derive the Kasme from the authentication challenge using
* the PLMN identity of the selected PLMN */ * the PLMN identity of the selected PLMN */
_emm_data.non_current->kasme.length = AUTH_KASME_SIZE; user->emm_data->non_current->kasme.length = AUTH_KASME_SIZE;
_emm_data.non_current->kasme.value = malloc(32); user->emm_data->non_current->kasme.value = malloc(32);
_authentication_kasme(autn, &ck, &ik, &_emm_data.splmn, _authentication_kasme(autn, &ck, &ik, &user->emm_data->splmn,
&_emm_data.non_current->kasme); &user->emm_data->non_current->kasme);
/* NAS integrity and cyphering keys are not yet available */ /* NAS integrity and cyphering keys are not yet available */
} }
} }
...@@ -392,7 +392,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi, ...@@ -392,7 +392,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
** ** ** **
** Outputs: None ** ** Outputs: None **
** Return: RETURNok, RETURNerror ** ** Return: RETURNok, RETURNerror **
** Others: _emm_data, _authentication_data, T3410, ** ** Others: user->emm_data-> _authentication_data, T3410, **
** T3417, T3430 ** ** T3417, T3430 **
** ** ** **
***************************************************************************/ ***************************************************************************/
...@@ -409,21 +409,21 @@ int emm_proc_authentication_reject(nas_user_t *user) ...@@ -409,21 +409,21 @@ int emm_proc_authentication_reject(nas_user_t *user)
(void) emm_proc_authentication_delete(); (void) emm_proc_authentication_delete();
/* Set the EPS update status to EU3 ROAMING NOT ALLOWED */ /* Set the EPS update status to EU3 ROAMING NOT ALLOWED */
_emm_data.status = EU3_ROAMING_NOT_ALLOWED; user->emm_data->status = EU3_ROAMING_NOT_ALLOWED;
/* Delete the stored GUTI */ /* Delete the stored GUTI */
_emm_data.guti = NULL; user->emm_data->guti = NULL;
/* Delete the TAI list */ /* Delete the TAI list */
_emm_data.ltai.n_tais = 0; user->emm_data->ltai.n_tais = 0;
/* Delete the last visited registered TAI */ /* Delete the last visited registered TAI */
_emm_data.tai = NULL; user->emm_data->tai = NULL;
/* Delete the eKSI */ /* Delete the eKSI */
if (_emm_data.security) { if (user->emm_data->security) {
_emm_data.security->type = EMM_KSI_NOT_AVAILABLE; user->emm_data->security->type = EMM_KSI_NOT_AVAILABLE;
} }
/* Consider the USIM invalid */ /* Consider the USIM invalid */
_emm_data.usim_is_valid = FALSE; user->emm_data->usim_is_valid = FALSE;
/* Stop timer T3410 */ /* Stop timer T3410 */
if (T3410.id != NAS_TIMER_INACTIVE_ID) { if (T3410.id != NAS_TIMER_INACTIVE_ID) {
...@@ -664,14 +664,14 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause, ...@@ -664,14 +664,14 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
*/ */
emm_sap_t emm_sap; emm_sap_t emm_sap;
emm_sap.primitive = EMMAS_SECURITY_RES; emm_sap.primitive = EMMAS_SECURITY_RES;
emm_sap.u.emm_as.u.security.guti = _emm_data.guti; emm_sap.u.emm_as.u.security.guti = user->emm_data->guti;
emm_sap.u.emm_as.u.security.ueid = 0; emm_sap.u.emm_as.u.security.ueid = 0;
emm_sap.u.emm_as.u.security.msgType = EMM_AS_MSG_TYPE_AUTH; emm_sap.u.emm_as.u.security.msgType = EMM_AS_MSG_TYPE_AUTH;
emm_sap.u.emm_as.u.security.emm_cause = emm_cause; emm_sap.u.emm_as.u.security.emm_cause = emm_cause;
emm_sap.u.emm_as.u.security.auts = auts; emm_sap.u.emm_as.u.security.auts = auts;
/* Setup EPS NAS security data */ /* Setup EPS NAS security data */
emm_as_set_security_data(&emm_sap.u.emm_as.u.security.sctx, emm_as_set_security_data(&emm_sap.u.emm_as.u.security.sctx,
_emm_data.security, FALSE, TRUE); user->emm_data->security, FALSE, TRUE);
rc = emm_sap_send(user, &emm_sap); rc = emm_sap_send(user, &emm_sap);
if (rc != RETURNerror) { if (rc != RETURNerror) {
...@@ -787,7 +787,7 @@ static int _authentication_abnormal_case_f(nas_user_t *user) ...@@ -787,7 +787,7 @@ static int _authentication_abnormal_case_f(nas_user_t *user)
*/ */
emm_sap_t emm_sap; emm_sap_t emm_sap;
emm_sap.primitive = EMMAS_RELEASE_REQ; emm_sap.primitive = EMMAS_RELEASE_REQ;
emm_sap.u.emm_as.u.release.guti = _emm_data.guti; emm_sap.u.emm_as.u.release.guti = user->emm_data->guti;
emm_sap.u.emm_as.u.release.cause = EMM_AS_CAUSE_AUTHENTICATION; emm_sap.u.emm_as.u.release.cause = EMM_AS_CAUSE_AUTHENTICATION;
rc = emm_sap_send(user, &emm_sap); rc = emm_sap_send(user, &emm_sap);
......
...@@ -124,7 +124,7 @@ static struct { ...@@ -124,7 +124,7 @@ static struct {
** Inputs: type: Type of the requested detach ** ** Inputs: type: Type of the requested detach **
** switch_off: Indicates whether the detach is required ** ** switch_off: Indicates whether the detach is required **
** because the UE is switched off or not ** ** because the UE is switched off or not **
** Others: _emm_data ** ** Others: user->emm_data-> **
** ** ** **
** Outputs: None ** ** Outputs: None **
** Return: RETURNok, RETURNerror ** ** Return: RETURNok, RETURNerror **
...@@ -167,10 +167,10 @@ int emm_proc_detach(nas_user_t *user, emm_proc_detach_type_t type, int switch_of ...@@ -167,10 +167,10 @@ int emm_proc_detach(nas_user_t *user, emm_proc_detach_type_t type, int switch_of
/* Set the switch-off indicator */ /* Set the switch-off indicator */
emm_as->switch_off = switch_off; emm_as->switch_off = switch_off;
/* Set the EPS mobile identity */ /* Set the EPS mobile identity */
emm_as->guti = _emm_data.guti; emm_as->guti = user->emm_data->guti;
emm_as->ueid = 0; emm_as->ueid = 0;
/* Setup EPS NAS security data */ /* Setup EPS NAS security data */
emm_as_set_security_data(&emm_as->sctx, _emm_data.security, FALSE, TRUE); emm_as_set_security_data(&emm_as->sctx, user->emm_data->security, FALSE, TRUE);
/* /*
* Notify EMM-AS SAP that Detach Request message has to * Notify EMM-AS SAP that Detach Request message has to
...@@ -413,10 +413,10 @@ void *_emm_detach_t3421_handler(void *args) ...@@ -413,10 +413,10 @@ void *_emm_detach_t3421_handler(void *args)
/* Set the switch-off indicator */ /* Set the switch-off indicator */
emm_as->switch_off = _emm_detach_data.switch_off; emm_as->switch_off = _emm_detach_data.switch_off;
/* Set the EPS mobile identity */ /* Set the EPS mobile identity */
emm_as->guti = _emm_data.guti; emm_as->guti = user->emm_data->guti;
emm_as->ueid = 0; emm_as->ueid = 0;
/* Setup EPS NAS security data */ /* Setup EPS NAS security data */
emm_as_set_security_data(&emm_as->sctx, _emm_data.security, emm_as_set_security_data(&emm_as->sctx, user->emm_data->security,
FALSE, TRUE); FALSE, TRUE);
/* /*
......
...@@ -134,8 +134,8 @@ int emm_proc_status(nas_user_t *user, unsigned int ueid, int emm_cause) ...@@ -134,8 +134,8 @@ int emm_proc_status(nas_user_t *user, unsigned int ueid, int emm_cause)
emm_sap.u.emm_as.u.status.emm_cause = emm_cause; emm_sap.u.emm_as.u.status.emm_cause = emm_cause;
emm_sap.u.emm_as.u.status.ueid = ueid; emm_sap.u.emm_as.u.status.ueid = ueid;
emm_sap.u.emm_as.u.status.guti = _emm_data.guti; emm_sap.u.emm_as.u.status.guti = user->emm_data->guti;
sctx = _emm_data.security; sctx = user->emm_data->security;
/* Setup EPS NAS security data */ /* Setup EPS NAS security data */
emm_as_set_security_data(&emm_sap.u.emm_as.u.status.sctx, sctx, emm_as_set_security_data(&emm_sap.u.emm_as.u.status.sctx, sctx,
FALSE, TRUE); FALSE, TRUE);
......
...@@ -130,8 +130,8 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t ...@@ -130,8 +130,8 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t
imsi_t modified_imsi; imsi_t modified_imsi;
/* International Mobile Subscriber Identity is requested */ /* International Mobile Subscriber Identity is requested */
if (_emm_data.imsi) { if (user->emm_data->imsi) {
memcpy (&modified_imsi, _emm_data.imsi, sizeof (modified_imsi)); memcpy (&modified_imsi, user->emm_data->imsi, sizeof (modified_imsi));
/* LW: Eventually replace the 0xF value set in MNC digit 3 by a 0 to avoid IMSI to be truncated before reaching HSS */ /* LW: Eventually replace the 0xF value set in MNC digit 3 by a 0 to avoid IMSI to be truncated before reaching HSS */
if (modified_imsi.u.num.digit6 == 0xF) { if (modified_imsi.u.num.digit6 == 0xF) {
...@@ -167,9 +167,9 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t ...@@ -167,9 +167,9 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t
case EMM_IDENT_TYPE_IMEI: case EMM_IDENT_TYPE_IMEI:
/* International Mobile Equipment Identity is requested */ /* International Mobile Equipment Identity is requested */
if (_emm_data.imei) { if (user->emm_data->imei) {
emm_sap.u.emm_as.u.security.identType = EMM_IDENT_TYPE_IMEI; emm_sap.u.emm_as.u.security.identType = EMM_IDENT_TYPE_IMEI;
emm_sap.u.emm_as.u.security.imei = _emm_data.imei; emm_sap.u.emm_as.u.security.imei = user->emm_data->imei;
} }
break; break;
...@@ -177,9 +177,9 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t ...@@ -177,9 +177,9 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t
case EMM_IDENT_TYPE_TMSI: case EMM_IDENT_TYPE_TMSI:
/* Temporary Mobile Subscriber Identity is requested */ /* Temporary Mobile Subscriber Identity is requested */
if (_emm_data.guti) { if (user->emm_data->guti) {
emm_sap.u.emm_as.u.security.identType = EMM_IDENT_TYPE_TMSI; emm_sap.u.emm_as.u.security.identType = EMM_IDENT_TYPE_TMSI;
emm_sap.u.emm_as.u.security.tmsi = _emm_data.guti->m_tmsi; emm_sap.u.emm_as.u.security.tmsi = user->emm_data->guti->m_tmsi;
} }
break; break;
...@@ -194,12 +194,12 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t ...@@ -194,12 +194,12 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t
* to the MME * to the MME
*/ */
emm_sap.primitive = EMMAS_SECURITY_RES; emm_sap.primitive = EMMAS_SECURITY_RES;
emm_sap.u.emm_as.u.security.guti = _emm_data.guti; emm_sap.u.emm_as.u.security.guti = user->emm_data->guti;
emm_sap.u.emm_as.u.security.ueid = 0; emm_sap.u.emm_as.u.security.ueid = 0;
emm_sap.u.emm_as.u.security.msgType = EMM_AS_MSG_TYPE_IDENT; emm_sap.u.emm_as.u.security.msgType = EMM_AS_MSG_TYPE_IDENT;
/* Setup EPS NAS security data */ /* Setup EPS NAS security data */
emm_as_set_security_data(&emm_sap.u.emm_as.u.security.sctx, emm_as_set_security_data(&emm_sap.u.emm_as.u.security.sctx,
_emm_data.security, FALSE, TRUE); user->emm_data->security, FALSE, TRUE);
rc = emm_sap_send(user, &emm_sap); rc = emm_sap_send(user, &emm_sap);
LOG_FUNC_RETURN (rc); LOG_FUNC_RETURN (rc);
......
This diff is collapsed.
...@@ -51,7 +51,7 @@ Description Defines the functions used to get information from the list ...@@ -51,7 +51,7 @@ Description Defines the functions used to get information from the list
/************************ G L O B A L T Y P E S ************************/ /************************ G L O B A L T Y P E S ************************/
/****************************************************************************/ /****************************************************************************/
typedef int (*IdleMode_callback_t) (int); typedef int (*IdleMode_callback_t) (emm_data_t *emm_data, int);
/****************************************************************************/ /****************************************************************************/
/******************** 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 ********************/
...@@ -68,7 +68,7 @@ int IdleMode_get_hplmn_index(void); ...@@ -68,7 +68,7 @@ int IdleMode_get_hplmn_index(void);
int IdleMode_get_rplmn_index(void); int IdleMode_get_rplmn_index(void);
int IdleMode_get_splmn_index(void); int IdleMode_get_splmn_index(void);
int IdleMode_update_plmn_list(int index); int IdleMode_update_plmn_list(emm_data_t *emm_data, int i);
const char *IdleMode_get_plmn_fullname(const plmn_t *plmn, int index, const char *IdleMode_get_plmn_fullname(const plmn_t *plmn, int index,
size_t *len); size_t *len);
......
...@@ -160,7 +160,7 @@ int lowerlayer_establish(nas_user_t *user) ...@@ -160,7 +160,7 @@ int lowerlayer_establish(nas_user_t *user)
LOG_FUNC_IN; LOG_FUNC_IN;
/* Update the EPS Connection Management status */ /* Update the EPS Connection Management status */
_emm_data.ecm_status = ECM_CONNECTED; user->emm_data->ecm_status = ECM_CONNECTED;
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} }
...@@ -188,7 +188,7 @@ int lowerlayer_release(nas_user_t *user, int cause) ...@@ -188,7 +188,7 @@ int lowerlayer_release(nas_user_t *user, int cause)
int rc; int rc;
/* Update the EPS Connection Management status */ /* Update the EPS Connection Management status */
_emm_data.ecm_status = ECM_IDLE; user->emm_data->ecm_status = ECM_IDLE;
emm_sap.primitive = EMMREG_LOWERLAYER_RELEASE; emm_sap.primitive = EMMREG_LOWERLAYER_RELEASE;
emm_sap.u.emm_reg.ueid = 0; emm_sap.u.emm_reg.ueid = 0;
...@@ -257,9 +257,9 @@ int lowerlayer_data_req(nas_user_t *user, unsigned int ueid, const OctetString * ...@@ -257,9 +257,9 @@ int lowerlayer_data_req(nas_user_t *user, unsigned int ueid, const OctetString *
//struct emm_data_context_s *ctx = NULL; //struct emm_data_context_s *ctx = NULL;
emm_sap.primitive = EMMAS_DATA_REQ; emm_sap.primitive = EMMAS_DATA_REQ;
emm_sap.u.emm_as.u.data.guti = _emm_data.guti; emm_sap.u.emm_as.u.data.guti = user->emm_data->guti;
emm_sap.u.emm_as.u.data.ueid = 0; emm_sap.u.emm_as.u.data.ueid = 0;
sctx = _emm_data.security; sctx = user->emm_data->security;
emm_sap.u.emm_as.u.data.NASinfo = 0; emm_sap.u.emm_as.u.data.NASinfo = 0;
emm_sap.u.emm_as.u.data.NASmsg.length = data->length; emm_sap.u.emm_as.u.data.NASmsg.length = data->length;
......
...@@ -108,8 +108,7 @@ int EmmDeregisteredNoCellAvailable(nas_user_t *user, const emm_reg_t *evt) ...@@ -108,8 +108,7 @@ int EmmDeregisteredNoCellAvailable(nas_user_t *user, const emm_reg_t *evt)
* Notify EMM that the MT is currently searching an operator * Notify EMM that the MT is currently searching an operator
* to register to * to register to
*/ */
// FIXME REVIEW rc = emm_proc_registration_notify(user->emm_data, NET_REG_STATE_ON);
rc = emm_proc_registration_notify(NET_REG_STATE_ON);
if (rc != RETURNok) { if (rc != RETURNok) {
LOG_TRACE(WARNING, "EMM-FSM - " LOG_TRACE(WARNING, "EMM-FSM - "
......
...@@ -95,7 +95,7 @@ int EmmDeregisteredPlmnSearch(nas_user_t *user, const emm_reg_t *evt) ...@@ -95,7 +95,7 @@ int EmmDeregisteredPlmnSearch(nas_user_t *user, const emm_reg_t *evt)
/* /*
* No suitable cell of the selected PLMN has been found to camp on * No suitable cell of the selected PLMN has been found to camp on
*/ */
rc = emm_proc_registration_notify(NET_REG_STATE_DENIED); rc = emm_proc_registration_notify(user->emm_data, NET_REG_STATE_DENIED);
if (rc != RETURNok) { if (rc != RETURNok) {
LOG_TRACE(WARNING, "EMM-FSM - " LOG_TRACE(WARNING, "EMM-FSM - "
...@@ -112,7 +112,7 @@ int EmmDeregisteredPlmnSearch(nas_user_t *user, const emm_reg_t *evt) ...@@ -112,7 +112,7 @@ int EmmDeregisteredPlmnSearch(nas_user_t *user, const emm_reg_t *evt)
* may be selected either automatically or manually. * may be selected either automatically or manually.
* Or the user manually re-selected a PLMN to register to. * Or the user manually re-selected a PLMN to register to.
*/ */
rc = emm_proc_registration_notify(NET_REG_STATE_ON); rc = emm_proc_registration_notify(user->emm_data, NET_REG_STATE_ON);
if (rc != RETURNok) { if (rc != RETURNok) {
LOG_TRACE(WARNING, "EMM-FSM - " LOG_TRACE(WARNING, "EMM-FSM - "
......
...@@ -140,7 +140,7 @@ int EmmRegisteredInitiated(nas_user_t *user, const emm_reg_t *evt) ...@@ -140,7 +140,7 @@ int EmmRegisteredInitiated(nas_user_t *user, const emm_reg_t *evt)
/* /*
* Notify EMM that the MT is registered * Notify EMM that the MT is registered
*/ */
rc = emm_proc_registration_notify(NET_REG_STATE_HN); rc = emm_proc_registration_notify(user->emm_data, NET_REG_STATE_HN);
if (rc != RETURNok) { if (rc != RETURNok) {
LOG_TRACE(WARNING, "EMM-FSM - " LOG_TRACE(WARNING, "EMM-FSM - "
...@@ -167,7 +167,7 @@ int EmmRegisteredInitiated(nas_user_t *user, const emm_reg_t *evt) ...@@ -167,7 +167,7 @@ int EmmRegisteredInitiated(nas_user_t *user, const emm_reg_t *evt)
/* /*
* Notify EMM that the MT's registration is denied * Notify EMM that the MT's registration is denied
*/ */
rc = emm_proc_registration_notify(NET_REG_STATE_DENIED); rc = emm_proc_registration_notify(user->emm_data, NET_REG_STATE_DENIED);
if (rc != RETURNok) { if (rc != RETURNok) {
LOG_TRACE(WARNING, "EMM-FSM - " LOG_TRACE(WARNING, "EMM-FSM - "
......
...@@ -135,16 +135,16 @@ static int _emm_as_encrypt( ...@@ -135,16 +135,16 @@ static int _emm_as_encrypt(
static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg); static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg);
static int _emm_as_security_res(const emm_as_security_t *, static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *,
ul_info_transfer_req_t *); ul_info_transfer_req_t *);
static int _emm_as_establish_req(const emm_as_establish_t *, static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *,
nas_establish_req_t *); nas_establish_req_t *);
static int _emm_as_cell_info_req(const emm_as_cell_info_t *, cell_info_req_t *); static int _emm_as_cell_info_req(const emm_as_cell_info_t *, cell_info_req_t *);
static int _emm_as_data_req(const emm_as_data_t *msg, ul_info_transfer_req_t *); static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg, ul_info_transfer_req_t *);
static int _emm_as_status_ind(const emm_as_status_t *, ul_info_transfer_req_t *); static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *, ul_info_transfer_req_t *);
static int _emm_as_release_req(const emm_as_release_t *, nas_release_req_t *); static int _emm_as_release_req(const emm_as_release_t *, nas_release_req_t *);
/****************************************************************************/ /****************************************************************************/
...@@ -321,7 +321,7 @@ static int _emm_as_recv(nas_user_t *user, unsigned int ueid, const char *msg, in ...@@ -321,7 +321,7 @@ static int _emm_as_recv(nas_user_t *user, unsigned int ueid, const char *msg, in
emm_security_context_t *security = NULL; /* Current EPS NAS security context */ emm_security_context_t *security = NULL; /* Current EPS NAS security context */
security = _emm_data.security; security = user->emm_data->security;
/* Decode the received message */ /* Decode the received message */
decoder_rc = nas_message_decode(msg, &nas_msg, len, security); decoder_rc = nas_message_decode(msg, &nas_msg, len, security);
...@@ -428,7 +428,7 @@ static int _emm_as_data_ind(nas_user_t *user, const emm_as_data_t *msg, int *emm ...@@ -428,7 +428,7 @@ static int _emm_as_data_ind(nas_user_t *user, const emm_as_data_t *msg, int *emm
memset(&header, 0, sizeof(header)); memset(&header, 0, sizeof(header));
/* Decrypt the received security protected message */ /* Decrypt the received security protected message */
security = _emm_data.security; security = user->emm_data->security;
int bytes = nas_message_decrypt((char *)(msg->NASmsg.value), int bytes = nas_message_decrypt((char *)(msg->NASmsg.value),
plain_msg, plain_msg,
&header, &header,
...@@ -509,7 +509,7 @@ static int _emm_as_establish_cnf(nas_user_t *user, const emm_as_establish_t *msg ...@@ -509,7 +509,7 @@ static int _emm_as_establish_cnf(nas_user_t *user, const emm_as_establish_t *msg
decoder_rc = nas_message_decode((char *)(msg->NASmsg.value), decoder_rc = nas_message_decode((char *)(msg->NASmsg.value),
&nas_msg, &nas_msg,
msg->NASmsg.length, msg->NASmsg.length,
_emm_data.security); user->emm_data->security);
if (decoder_rc < 0) { if (decoder_rc < 0) {
LOG_TRACE(WARNING, "EMMAS-SAP - Failed to decode initial NAS message" LOG_TRACE(WARNING, "EMMAS-SAP - Failed to decode initial NAS message"
...@@ -937,13 +937,13 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg) ...@@ -937,13 +937,13 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg)
switch (msg->primitive) { switch (msg->primitive) {
case _EMMAS_DATA_REQ: case _EMMAS_DATA_REQ:
as_msg.msgID = _emm_as_data_req( as_msg.msgID = _emm_as_data_req(user->emm_data,
&msg->u.data, &msg->u.data,
&as_msg.msg.ul_info_transfer_req); &as_msg.msg.ul_info_transfer_req);
break; break;
case _EMMAS_STATUS_IND: case _EMMAS_STATUS_IND:
as_msg.msgID = _emm_as_status_ind( as_msg.msgID = _emm_as_status_ind(user->emm_data,
&msg->u.status, &msg->u.status,
&as_msg.msg.ul_info_transfer_req); &as_msg.msg.ul_info_transfer_req);
break; break;
...@@ -956,13 +956,13 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg) ...@@ -956,13 +956,13 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg)
case _EMMAS_SECURITY_RES: case _EMMAS_SECURITY_RES:
as_msg.msgID = _emm_as_security_res( as_msg.msgID = _emm_as_security_res(user->emm_data,
&msg->u.security, &msg->u.security,
&as_msg.msg.ul_info_transfer_req); &as_msg.msg.ul_info_transfer_req);
break; break;
case _EMMAS_ESTABLISH_REQ: case _EMMAS_ESTABLISH_REQ:
as_msg.msgID = _emm_as_establish_req( as_msg.msgID = _emm_as_establish_req(user->emm_data,
&msg->u.establish, &msg->u.establish,
&as_msg.msg.nas_establish_req); &as_msg.msg.nas_establish_req);
break; break;
...@@ -1065,7 +1065,7 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg) ...@@ -1065,7 +1065,7 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
static int _emm_as_data_req(const emm_as_data_t *msg, static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg,
ul_info_transfer_req_t *as_msg) ul_info_transfer_req_t *as_msg)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -1112,7 +1112,7 @@ static int _emm_as_data_req(const emm_as_data_t *msg, ...@@ -1112,7 +1112,7 @@ static int _emm_as_data_req(const emm_as_data_t *msg,
int bytes; int bytes;
emm_security_context_t *emm_security_context = NULL; emm_security_context_t *emm_security_context = NULL;
emm_security_context = _emm_data.security; emm_security_context = emm_data->security;
if (emm_security_context) { if (emm_security_context) {
...@@ -1161,7 +1161,7 @@ static int _emm_as_data_req(const emm_as_data_t *msg, ...@@ -1161,7 +1161,7 @@ static int _emm_as_data_req(const emm_as_data_t *msg,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
static int _emm_as_status_ind(const emm_as_status_t *msg, static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *msg,
ul_info_transfer_req_t *as_msg) ul_info_transfer_req_t *as_msg)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -1193,7 +1193,7 @@ static int _emm_as_status_ind(const emm_as_status_t *msg, ...@@ -1193,7 +1193,7 @@ static int _emm_as_status_ind(const emm_as_status_t *msg,
if (size > 0) { if (size > 0) {
emm_security_context_t *emm_security_context = NULL; emm_security_context_t *emm_security_context = NULL;
emm_security_context = _emm_data.security; emm_security_context = emm_data->security;
if (emm_security_context) { if (emm_security_context) {
...@@ -1275,7 +1275,7 @@ static int _emm_as_release_req(const emm_as_release_t *msg, ...@@ -1275,7 +1275,7 @@ static int _emm_as_release_req(const emm_as_release_t *msg,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
static int _emm_as_security_res(const emm_as_security_t *msg, static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *msg,
ul_info_transfer_req_t *as_msg) ul_info_transfer_req_t *as_msg)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -1340,7 +1340,7 @@ static int _emm_as_security_res(const emm_as_security_t *msg, ...@@ -1340,7 +1340,7 @@ static int _emm_as_security_res(const emm_as_security_t *msg,
int bytes = _emm_as_encode(&as_msg->nasMsg, int bytes = _emm_as_encode(&as_msg->nasMsg,
&nas_msg, &nas_msg,
size, size,
_emm_data.security); emm_data->security);
if (bytes > 0) { if (bytes > 0) {
LOG_FUNC_RETURN (AS_UL_INFO_TRANSFER_REQ); LOG_FUNC_RETURN (AS_UL_INFO_TRANSFER_REQ);
...@@ -1369,7 +1369,7 @@ static int _emm_as_security_res(const emm_as_security_t *msg, ...@@ -1369,7 +1369,7 @@ static int _emm_as_security_res(const emm_as_security_t *msg,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
static int _emm_as_establish_req(const emm_as_establish_t *msg, static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *msg,
nas_establish_req_t *as_msg) nas_establish_req_t *as_msg)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -1433,7 +1433,7 @@ static int _emm_as_establish_req(const emm_as_establish_t *msg, ...@@ -1433,7 +1433,7 @@ static int _emm_as_establish_req(const emm_as_establish_t *msg,
&as_msg->initialNasMsg, &as_msg->initialNasMsg,
&nas_msg, &nas_msg,
size, size,
_emm_data.security); emm_data->security);
if (bytes > 0) { if (bytes > 0) {
LOG_FUNC_RETURN (AS_NAS_ESTABLISH_REQ); LOG_FUNC_RETURN (AS_NAS_ESTABLISH_REQ);
......
...@@ -134,7 +134,7 @@ int emm_esm_send(nas_user_t *user, const emm_esm_t *msg) ...@@ -134,7 +134,7 @@ int emm_esm_send(nas_user_t *user, const emm_esm_t *msg)
if (msg->u.establish.is_emergency) { if (msg->u.establish.is_emergency) {
/* Consider the UE attached for emergency bearer services /* Consider the UE attached for emergency bearer services
* only */ * only */
rc = emm_proc_attach_set_emergency(); rc = emm_proc_attach_set_emergency(user->emm_data);
} }
} else { } else {
/* Consider the UE locally detached from the network */ /* Consider the UE locally detached from the network */
......
...@@ -163,8 +163,8 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi, ...@@ -163,8 +163,8 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
/* /*
* Check the replayed UE security capabilities * Check the replayed UE security capabilities
*/ */
uint8_t eea = (0x80 >> _emm_data.security->capability.eps_encryption); uint8_t eea = (0x80 >> user->emm_data->security->capability.eps_encryption);
uint8_t eia = (0x80 >> _emm_data.security->capability.eps_integrity); uint8_t eia = (0x80 >> user->emm_data->security->capability.eps_integrity);
if ( (reea != eea) || (reia != eia) ) { if ( (reea != eea) || (reia != eia) ) {
LOG_TRACE(WARNING, "EMM-PROC - Replayed UE security capabilities " LOG_TRACE(WARNING, "EMM-PROC - Replayed UE security capabilities "
...@@ -180,7 +180,7 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi, ...@@ -180,7 +180,7 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
/* /*
* Check the non-current EPS security context * Check the non-current EPS security context
*/ */
else if (_emm_data.non_current == NULL) { else if (user->emm_data->non_current == NULL) {
LOG_TRACE(WARNING, "EMM-PROC - Non-current EPS security context " LOG_TRACE(WARNING, "EMM-PROC - Non-current EPS security context "
"is not valid"); "is not valid");
emm_cause = EMM_CAUSE_SECURITY_MODE_REJECTED; emm_cause = EMM_CAUSE_SECURITY_MODE_REJECTED;
...@@ -191,37 +191,37 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi, ...@@ -191,37 +191,37 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
else { else {
LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context seea=%u seia=%u", seea, seia); LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context seea=%u seia=%u", seea, seia);
/* Update selected cyphering and integrity algorithms */ /* Update selected cyphering and integrity algorithms */
//LG COMENTED _emm_data.non_current->capability.encryption = seea; //LG COMENTED user->emm_data->non_current->capability.encryption = seea;
//LG COMENTED _emm_data.non_current->capability.integrity = seia; //LG COMENTED user->emm_data->non_current->capability.integrity = seia;
_emm_data.non_current->selected_algorithms.encryption = seea; user->emm_data->non_current->selected_algorithms.encryption = seea;
_emm_data.non_current->selected_algorithms.integrity = seia; user->emm_data->non_current->selected_algorithms.integrity = seia;
/* Derive the NAS cyphering key */ /* Derive the NAS cyphering key */
if (_emm_data.non_current->knas_enc.value == NULL) { if (user->emm_data->non_current->knas_enc.value == NULL) {
_emm_data.non_current->knas_enc.value = user->emm_data->non_current->knas_enc.value =
(uint8_t *)calloc(1,AUTH_KNAS_ENC_SIZE); (uint8_t *)calloc(1,AUTH_KNAS_ENC_SIZE);
_emm_data.non_current->knas_enc.length = AUTH_KNAS_ENC_SIZE; user->emm_data->non_current->knas_enc.length = AUTH_KNAS_ENC_SIZE;
} }
if (_emm_data.non_current->knas_enc.value != NULL) { if (user->emm_data->non_current->knas_enc.value != NULL) {
LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context knas_enc"); LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context knas_enc");
rc = _security_knas_enc(&_emm_data.non_current->kasme, rc = _security_knas_enc(&user->emm_data->non_current->kasme,
&_emm_data.non_current->knas_enc, seea); &user->emm_data->non_current->knas_enc, seea);
} }
/* Derive the NAS integrity key */ /* Derive the NAS integrity key */
if (_emm_data.non_current->knas_int.value == NULL) { if (user->emm_data->non_current->knas_int.value == NULL) {
_emm_data.non_current->knas_int.value = user->emm_data->non_current->knas_int.value =
(uint8_t *)calloc(1,AUTH_KNAS_INT_SIZE); (uint8_t *)calloc(1,AUTH_KNAS_INT_SIZE);
_emm_data.non_current->knas_int.length = AUTH_KNAS_INT_SIZE; user->emm_data->non_current->knas_int.length = AUTH_KNAS_INT_SIZE;
} }
if (_emm_data.non_current->knas_int.value != NULL) { if (user->emm_data->non_current->knas_int.value != NULL) {
if (rc != RETURNerror) { if (rc != RETURNerror) {
LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context knas_int"); LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context knas_int");
rc = _security_knas_int(&_emm_data.non_current->kasme, rc = _security_knas_int(&user->emm_data->non_current->kasme,
&_emm_data.non_current->knas_int, seia); &user->emm_data->non_current->knas_int, seia);
} }
} }
...@@ -234,10 +234,10 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi, ...@@ -234,10 +234,10 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
if (_security_data.kenb.value != NULL) { if (_security_data.kenb.value != NULL) {
if (rc != RETURNerror) { if (rc != RETURNerror) {
LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context kenb"); LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context kenb");
// LG COMMENT rc = _security_kenb(&_emm_data.security->kasme, // LG COMMENT rc = _security_kenb(&user->emm_data->security->kasme,
rc = _security_kenb(&_emm_data.non_current->kasme, rc = _security_kenb(&user->emm_data->non_current->kasme,
&_security_data.kenb, &_security_data.kenb,
*(uint32_t *)(&_emm_data.non_current->ul_count)); *(uint32_t *)(&user->emm_data->non_current->ul_count));
} }
} }
...@@ -248,13 +248,13 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi, ...@@ -248,13 +248,13 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
LOG_TRACE(INFO, "EMM-PROC - NAS security mode command accepted by the UE"); LOG_TRACE(INFO, "EMM-PROC - NAS security mode command accepted by the UE");
/* Update the current EPS security context */ /* Update the current EPS security context */
if ( native_ksi && (_emm_data.security->type != EMM_KSI_NATIVE) ) { if ( native_ksi && (user->emm_data->security->type != EMM_KSI_NATIVE) ) {
/* The type of security context flag included in the SECURITY /* The type of security context flag included in the SECURITY
* MODE COMMAND message is set to "native security context" and * MODE COMMAND message is set to "native security context" and
* the UE has a mapped EPS security context as the current EPS * the UE has a mapped EPS security context as the current EPS
* security context */ * security context */
if ( (_emm_data.non_current->type == EMM_KSI_NATIVE) && if ( (user->emm_data->non_current->type == EMM_KSI_NATIVE) &&
(_emm_data.non_current->eksi == ksi) ) { (user->emm_data->non_current->eksi == ksi) ) {
/* The KSI matches the non-current native EPS security /* The KSI matches the non-current native EPS security
* context; the UE shall take the non-current native EPS * context; the UE shall take the non-current native EPS
* security context into use which then becomes the * security context into use which then becomes the
...@@ -263,36 +263,37 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi, ...@@ -263,36 +263,37 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
LOG_TRACE(INFO, LOG_TRACE(INFO,
"EMM-PROC - Update Current security context"); "EMM-PROC - Update Current security context");
/* Release non-current security context */ /* Release non-current security context */
_security_release(_emm_data.security); _security_release(user->emm_data->security);
_emm_data.security = _emm_data.non_current; user->emm_data->security = user->emm_data->non_current;
/* Reset the uplink NAS COUNT counter */ /* Reset the uplink NAS COUNT counter */
_emm_data.security->ul_count.overflow = 0; user->emm_data->security->ul_count.overflow = 0;
_emm_data.security->ul_count.seq_num = 0; user->emm_data->security->ul_count.seq_num = 0;
/* Set new security context indicator */ /* Set new security context indicator */
security_context_is_new = TRUE; security_context_is_new = TRUE;
} }
} }
if ( !native_ksi && (_emm_data.security->type != EMM_KSI_NATIVE) ) { if ( !native_ksi && (user->emm_data->security->type != EMM_KSI_NATIVE) ) {
/* The type of security context flag included in the SECURITY /* The type of security context flag included in the SECURITY
* MODE COMMAND message is set to "mapped security context" and * MODE COMMAND message is set to "mapped security context" and
* the UE has a mapped EPS security context as the current EPS * the UE has a mapped EPS security context as the current EPS
* security context */ * security context */
if (ksi != _emm_data.security->eksi) { if (ksi != user->emm_data->security->eksi) {
/* The KSI does not match the current EPS security context; /* The KSI does not match the current EPS security context;
* the UE shall reset the uplink NAS COUNT counter */ * the UE shall reset the uplink NAS COUNT counter */
LOG_TRACE(INFO, LOG_TRACE(INFO,
"EMM-PROC - Reset uplink NAS COUNT counter"); "EMM-PROC - Reset uplink NAS COUNT counter");
_emm_data.security->ul_count.overflow = 0; user->emm_data->security->ul_count.overflow = 0;
_emm_data.security->ul_count.seq_num = 0; user->emm_data->security->ul_count.seq_num = 0;
} }
} }
_emm_data.security->selected_algorithms.encryption = seea; user->emm_data->security->selected_algorithms.encryption = seea;
_emm_data.security->selected_algorithms.integrity = seia; user->emm_data->security->selected_algorithms.integrity = seia;
#if defined(NAS_BUILT_IN_UE) #if defined(NAS_BUILT_IN_UE)
nas_itti_kenb_refresh_req(_security_data.kenb.value); nas_itti_kenb_refresh_req(_security_data.kenb.value);
#endif #endif
} }
/* /*
* NAS security mode command not accepted by the UE * NAS security mode command not accepted by the UE
...@@ -326,14 +327,14 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi, ...@@ -326,14 +327,14 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
*/ */
emm_sap_t emm_sap; emm_sap_t emm_sap;
emm_sap.primitive = EMMAS_SECURITY_RES; emm_sap.primitive = EMMAS_SECURITY_RES;
emm_sap.u.emm_as.u.security.guti = _emm_data.guti; emm_sap.u.emm_as.u.security.guti = user->emm_data->guti;
emm_sap.u.emm_as.u.security.ueid = 0; emm_sap.u.emm_as.u.security.ueid = 0;
emm_sap.u.emm_as.u.security.msgType = EMM_AS_MSG_TYPE_SMC; emm_sap.u.emm_as.u.security.msgType = EMM_AS_MSG_TYPE_SMC;
emm_sap.u.emm_as.u.security.imeisv_request = imeisv_request; emm_sap.u.emm_as.u.security.imeisv_request = imeisv_request;
emm_sap.u.emm_as.u.security.emm_cause = emm_cause; emm_sap.u.emm_as.u.security.emm_cause = emm_cause;
/* Setup EPS NAS security data */ /* Setup EPS NAS security data */
emm_as_set_security_data(&emm_sap.u.emm_as.u.security.sctx, emm_as_set_security_data(&emm_sap.u.emm_as.u.security.sctx,
_emm_data.security, security_context_is_new, TRUE); user->emm_data->security, security_context_is_new, TRUE);
rc = emm_sap_send(user, &emm_sap); rc = emm_sap_send(user, &emm_sap);
LOG_FUNC_RETURN (rc); LOG_FUNC_RETURN (rc);
......
...@@ -333,13 +333,6 @@ typedef struct emm_data_s { ...@@ -333,13 +333,6 @@ typedef struct emm_data_s {
/******************** 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 ********************/
/****************************************************************************/ /****************************************************************************/
/*
* --------------------------------------------------------------------------
* EPS mobility management data (used within EMM only)
* --------------------------------------------------------------------------
*/
emm_data_t _emm_data;
/* /*
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* EPS mobility management timers – UE side * EPS mobility management timers – UE side
......
This diff is collapsed.
...@@ -70,32 +70,32 @@ typedef int (*emm_indication_callback_t) (Stat_t, tac_t, ci_t, AcT_t, ...@@ -70,32 +70,32 @@ typedef int (*emm_indication_callback_t) (Stat_t, tac_t, ci_t, AcT_t,
void emm_main_initialize(nas_user_t *user, emm_indication_callback_t cb, const char *imei); void emm_main_initialize(nas_user_t *user, emm_indication_callback_t cb, const char *imei);
void emm_main_cleanup(void); void emm_main_cleanup(emm_data_t *emm_data);
/* User's getter of UE's identity */ /* User's getter of UE's identity */
const imsi_t *emm_main_get_imsi(void); const imsi_t *emm_main_get_imsi(emm_data_t *emm_data);
/* User's getter of the subscriber dialing number */ /* User's getter of the subscriber dialing number */
const msisdn_t *emm_main_get_msisdn(void); const msisdn_t *emm_main_get_msisdn(void);
/* User's getter/setter for network selection */ /* User's getter/setter for network selection */
int emm_main_set_plmn_selection_mode(int mode, int format, int emm_main_set_plmn_selection_mode(emm_data_t *emm_data, int mode, int format,
const network_plmn_t *plmn, int rat); const network_plmn_t *plmn, int rat);
int emm_main_get_plmn_selection_mode(void); int emm_main_get_plmn_selection_mode(emm_data_t *emm_data);
int emm_main_get_plmn_list(const char **plist); int emm_main_get_plmn_list(emm_data_t *emm_data, const char **plist);
const char *emm_main_get_selected_plmn(network_plmn_t *plmn, int format); const char *emm_main_get_selected_plmn(emm_data_t *emm_data, network_plmn_t *plmn, int format);
/* User's getter for network registration */ /* User's getter for network registration */
Stat_t emm_main_get_plmn_status(void); Stat_t emm_main_get_plmn_status(emm_data_t *emm_data);
tac_t emm_main_get_plmn_tac(void); tac_t emm_main_get_plmn_tac(emm_data_t *emm_data);
ci_t emm_main_get_plmn_ci(void); ci_t emm_main_get_plmn_ci(emm_data_t *emm_data);
AcT_t emm_main_get_plmn_rat(void); AcT_t emm_main_get_plmn_rat(emm_data_t *emm_data);
const char *emm_main_get_registered_plmn(network_plmn_t *plmn, int format); const char *emm_main_get_registered_plmn(emm_data_t *emm_data, network_plmn_t *plmn, int format);
/* User's getter for network attachment */ /* User's getter for network attachment */
int emm_main_is_attached(void); int emm_main_is_attached(emm_data_t *emm_data);
int emm_main_is_emergency(void); int emm_main_is_emergency(emm_data_t *emm_data);
#endif /* __EMM_MAIN_H__*/ #endif /* __EMM_MAIN_H__*/
...@@ -133,7 +133,7 @@ int emm_proc_attach_failure(int is_initial, void *args); ...@@ -133,7 +133,7 @@ int emm_proc_attach_failure(int is_initial, void *args);
int emm_proc_attach_release(void *args); int emm_proc_attach_release(void *args);
int emm_proc_attach_restart(nas_user_t *user); int emm_proc_attach_restart(nas_user_t *user);
int emm_proc_attach_set_emergency(void); int emm_proc_attach_set_emergency(emm_data_t *emm_data);
// FIXME check prototype // FIXME check prototype
int emm_proc_attach_set_detach(void *user); int emm_proc_attach_set_detach(void *user);
...@@ -183,8 +183,8 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi, in ...@@ -183,8 +183,8 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi, in
* Network indication handlers * Network indication handlers
*--------------------------------------------------------------------------- *---------------------------------------------------------------------------
*/ */
int emm_proc_registration_notify(Stat_t status); int emm_proc_registration_notify(emm_data_t *emm_data, Stat_t status);
int emm_proc_location_notify(tac_t tac, ci_t ci, AcT_t rat); int emm_proc_location_notify(emm_data_t *emm_data, tac_t tac, ci_t ci, AcT_t rat);
int emm_proc_network_notify(int index); int emm_proc_network_notify(emm_data_t *emm_data, int index);
#endif /* __EMM_PROC_H__*/ #endif /* __EMM_PROC_H__*/
...@@ -134,7 +134,7 @@ void nas_proc_cleanup(nas_user_t *user) ...@@ -134,7 +134,7 @@ void nas_proc_cleanup(nas_user_t *user)
/* Perform the EPS Mobility Manager's clean up procedure */ /* Perform the EPS Mobility Manager's clean up procedure */
emm_main_cleanup(); emm_main_cleanup(user->emm_data);
/* Perform the EPS Session Manager's clean up procedure */ /* Perform the EPS Session Manager's clean up procedure */
esm_main_cleanup(user->esm_data); esm_main_cleanup(user->esm_data);
...@@ -251,11 +251,11 @@ int nas_proc_get_eps(nas_user_t *user, int *stat) ...@@ -251,11 +251,11 @@ int nas_proc_get_eps(nas_user_t *user, int *stat)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_get_imsi(char *imsi_str) int nas_proc_get_imsi(emm_data_t *emm_data, char *imsi_str)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
const imsi_t *imsi = emm_main_get_imsi(); const imsi_t *imsi = emm_main_get_imsi(emm_data);
if (imsi != NULL) { if (imsi != NULL) {
int offset = 0; int offset = 0;
...@@ -386,7 +386,7 @@ int nas_proc_register(nas_user_t *user, int mode, int format, const network_plmn ...@@ -386,7 +386,7 @@ int nas_proc_register(nas_user_t *user, int mode, int format, const network_plmn
/* /*
* Set the PLMN selection mode of operation * Set the PLMN selection mode of operation
*/ */
int index = emm_main_set_plmn_selection_mode(mode, format, oper, AcT); int index = emm_main_set_plmn_selection_mode(user->emm_data, mode, format, oper, AcT);
if ( !(index < 0) ) { if ( !(index < 0) ) {
/* /*
...@@ -452,16 +452,16 @@ int nas_proc_get_reg_data(nas_user_t *user, int *mode, int *selected, int format ...@@ -452,16 +452,16 @@ int nas_proc_get_reg_data(nas_user_t *user, int *mode, int *selected, int format
LOG_FUNC_IN; LOG_FUNC_IN;
/* Get the PLMN selection mode of operation */ /* Get the PLMN selection mode of operation */
*mode = emm_main_get_plmn_selection_mode(); *mode = emm_main_get_plmn_selection_mode(user->emm_data);
/* Get the currently selected operator */ /* Get the currently selected operator */
const char *oper_name = emm_main_get_selected_plmn(oper, format); const char *oper_name = emm_main_get_selected_plmn(user->emm_data, oper, format);
if (oper_name != NULL) { if (oper_name != NULL) {
/* An operator is currently selected */ /* An operator is currently selected */
*selected = TRUE; *selected = TRUE;
/* Get the supported Radio Access Technology */ /* Get the supported Radio Access Technology */
*AcT = emm_main_get_plmn_rat(); *AcT = emm_main_get_plmn_rat(user->emm_data);
} else { } else {
/* No any operator is selected */ /* No any operator is selected */
*selected = FALSE; *selected = FALSE;
...@@ -489,7 +489,7 @@ int nas_proc_get_oper_list(nas_user_t *user, const char **oper_list) ...@@ -489,7 +489,7 @@ int nas_proc_get_oper_list(nas_user_t *user, const char **oper_list)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
int size = emm_main_get_plmn_list(oper_list); int size = emm_main_get_plmn_list(user->emm_data, oper_list);
LOG_FUNC_RETURN (size); LOG_FUNC_RETURN (size);
} }
...@@ -514,7 +514,7 @@ int nas_proc_get_reg_status(nas_user_t *user, int *stat) ...@@ -514,7 +514,7 @@ int nas_proc_get_reg_status(nas_user_t *user, int *stat)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
*stat = emm_main_get_plmn_status(); *stat = emm_main_get_plmn_status(user->emm_data);
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} }
...@@ -542,9 +542,9 @@ int nas_proc_get_loc_info(nas_user_t *user, char *tac, char *ci, int *AcT) ...@@ -542,9 +542,9 @@ int nas_proc_get_loc_info(nas_user_t *user, char *tac, char *ci, int *AcT)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
sprintf(tac, "%.4x", emm_main_get_plmn_tac()); // two byte sprintf(tac, "%.4x", emm_main_get_plmn_tac(user->emm_data)); // two byte
sprintf(ci, "%.8x", emm_main_get_plmn_ci()); // four byte sprintf(ci, "%.8x", emm_main_get_plmn_ci(user->emm_data)); // four byte
*AcT = emm_main_get_plmn_rat(); // E-UTRAN *AcT = emm_main_get_plmn_rat(user->emm_data); // E-UTRAN
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} }
...@@ -570,7 +570,7 @@ int nas_proc_detach(nas_user_t *user, int switch_off) ...@@ -570,7 +570,7 @@ int nas_proc_detach(nas_user_t *user, int switch_off)
emm_sap_t emm_sap; emm_sap_t emm_sap;
int rc = RETURNok; int rc = RETURNok;
if ( emm_main_is_attached() ) { if ( emm_main_is_attached(user->emm_data) ) {
/* Initiate an Detach procedure */ /* Initiate an Detach procedure */
emm_sap.primitive = EMMREG_DETACH_INIT; emm_sap.primitive = EMMREG_DETACH_INIT;
emm_sap.u.emm_reg.u.detach.switch_off = switch_off; emm_sap.u.emm_reg.u.detach.switch_off = switch_off;
...@@ -601,7 +601,7 @@ int nas_proc_attach(nas_user_t *user) ...@@ -601,7 +601,7 @@ int nas_proc_attach(nas_user_t *user)
emm_sap_t emm_sap; emm_sap_t emm_sap;
int rc = RETURNok; int rc = RETURNok;
if ( !emm_main_is_attached() ) { if ( !emm_main_is_attached(user->emm_data) ) {
/* Initiate an Attach procedure */ /* Initiate an Attach procedure */
emm_sap.primitive = EMMREG_ATTACH_INIT; emm_sap.primitive = EMMREG_ATTACH_INIT;
emm_sap.u.emm_reg.u.attach.is_emergency = FALSE; emm_sap.u.emm_reg.u.attach.is_emergency = FALSE;
...@@ -630,7 +630,7 @@ int nas_proc_get_attach_status(nas_user_t *user) ...@@ -630,7 +630,7 @@ int nas_proc_get_attach_status(nas_user_t *user)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
int is_attached = emm_main_is_attached(); int is_attached = emm_main_is_attached(user->emm_data);
LOG_FUNC_RETURN (is_attached); LOG_FUNC_RETURN (is_attached);
} }
...@@ -950,14 +950,14 @@ int nas_proc_activate_pdn(nas_user_t *user, int cid) ...@@ -950,14 +950,14 @@ int nas_proc_activate_pdn(nas_user_t *user, int cid)
int rc = RETURNok; int rc = RETURNok;
if ( !emm_main_is_attached() ) { if ( !emm_main_is_attached(user->emm_data) ) {
/* /*
* If the UE is not attached to the network, perform EPS attach * If the UE is not attached to the network, perform EPS attach
* procedure prior to attempt to request any PDN connectivity * procedure prior to attempt to request any PDN connectivity
*/ */
LOG_TRACE(WARNING, "NAS-PROC - UE is not attached to the network"); LOG_TRACE(WARNING, "NAS-PROC - UE is not attached to the network");
rc = nas_proc_attach(user); rc = nas_proc_attach(user);
} else if (emm_main_is_emergency()) { } else if (emm_main_is_emergency(user->emm_data)) {
/* The UE is attached for emergency bearer services; It shall not /* The UE is attached for emergency bearer services; It shall not
* request a PDN connection to any other PDN */ * request a PDN connection to any other PDN */
LOG_TRACE(WARNING,"NAS-PROC - Attached for emergency bearer services"); LOG_TRACE(WARNING,"NAS-PROC - Attached for emergency bearer services");
......
...@@ -76,7 +76,7 @@ int nas_proc_enable_s1_mode(nas_user_t *user); ...@@ -76,7 +76,7 @@ int nas_proc_enable_s1_mode(nas_user_t *user);
int nas_proc_disable_s1_mode(nas_user_t *user); int nas_proc_disable_s1_mode(nas_user_t *user);
int nas_proc_get_eps(nas_user_t *user, int *stat); int nas_proc_get_eps(nas_user_t *user, int *stat);
int nas_proc_get_imsi(char *imsi_str); int nas_proc_get_imsi(emm_data_t *emm_data, char *imsi_str);
int nas_proc_get_msisdn(char *msisdn_str, int *ton_npi); int nas_proc_get_msisdn(char *msisdn_str, int *ton_npi);
int nas_proc_get_signal_quality(nas_user_t *user, int *rsrq, int *rsrp); int nas_proc_get_signal_quality(nas_user_t *user, int *rsrq, int *rsrp);
......
...@@ -652,7 +652,7 @@ static int _nas_user_proc_cimi(nas_user_t *user, const at_command_t *data) ...@@ -652,7 +652,7 @@ static int _nas_user_proc_cimi(nas_user_t *user, const at_command_t *data)
} }
/* Get the International Mobile Subscriber Identity (IMSI) */ /* Get the International Mobile Subscriber Identity (IMSI) */
ret_code = nas_proc_get_imsi(cimi->IMSI); ret_code = nas_proc_get_imsi(user->emm_data, cimi->IMSI);
if (ret_code != RETURNok) { if (ret_code != RETURNok) {
LOG_TRACE(ERROR, "USR-MAIN - Failed to get IMSI number"); LOG_TRACE(ERROR, "USR-MAIN - Failed to get IMSI number");
......
...@@ -49,14 +49,16 @@ Description NAS type definition to manage a user equipment ...@@ -49,14 +49,16 @@ Description NAS type definition to manage a user equipment
#include "esmData.h" #include "esmData.h"
#include "esm_pt_defs.h" #include "esm_pt_defs.h"
#include "EMM/emm_fsm_defs.h" #include "EMM/emm_fsm_defs.h"
#include "EMM/emmData.h"
typedef struct { typedef struct {
int fd; int fd;
proc_data_t proc; proc_data_t proc;
esm_data_t *esm_data; // ESM internal data (used within ESM only) esm_data_t *esm_data; // ESM internal data (used within ESM only)
esm_pt_data_t *esm_pt_data; esm_pt_data_t *esm_pt_data;
emm_fsm_state_t emm_fsm_status; // Current EPS Mobility Management status
esm_ebr_data_t *esm_ebr_data; // EPS bearer contexts esm_ebr_data_t *esm_ebr_data; // EPS bearer contexts
emm_fsm_state_t emm_fsm_status; // Current EPS Mobility Management status
emm_data_t *emm_data; // EPS mobility management data
} nas_user_t; } nas_user_t;
#endif #endif
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