Commit 5665b05c authored by Frédéric Leroy's avatar Frédéric Leroy

UE/EMM: move _emm_data to nas_user_t

parent 809be889
This diff is collapsed.
......@@ -163,11 +163,11 @@ static int _authentication_kasme(const OctetString *autn,
** ksi: The NAS ket sey identifier **
** rand: Authentication parameter RAND **
** autn: Authentication parameter AUTN **
** Others: _emm_data, _authentication_data **
** Others: user->emm_data-> _authentication_data **
** **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Others: _emm_data, _authentication_data, T3416, **
** Others: user->emm_data-> _authentication_data, T3416, **
** T3418, T3420 **
** **
***************************************************************************/
......@@ -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
* 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_FUNC_RETURN (RETURNerror);
}
......@@ -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.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.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.res = &res;
/* Setup EPS NAS security data */
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);
if (rc != RETURNerror) {
......@@ -344,29 +344,29 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
_authentication_data.sync_count = 0;
/* Create non-current EPS security context */
if (_emm_data.non_current == NULL) {
_emm_data.non_current =
if (user->emm_data->non_current == NULL) {
user->emm_data->non_current =
(emm_security_context_t *)malloc(sizeof(emm_security_context_t));
}
if (_emm_data.non_current) {
memset(_emm_data.non_current, 0, sizeof(emm_security_context_t));
if (user->emm_data->non_current) {
memset(user->emm_data->non_current, 0, sizeof(emm_security_context_t));
/* Set the security context type */
if (native_ksi) {
_emm_data.non_current->type = EMM_KSI_NATIVE;
user->emm_data->non_current->type = EMM_KSI_NATIVE;
} else {
_emm_data.non_current->type = EMM_KSI_MAPPED;
user->emm_data->non_current->type = EMM_KSI_MAPPED;
}
/* 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
* the PLMN identity of the selected PLMN */
_emm_data.non_current->kasme.length = AUTH_KASME_SIZE;
_emm_data.non_current->kasme.value = malloc(32);
_authentication_kasme(autn, &ck, &ik, &_emm_data.splmn,
&_emm_data.non_current->kasme);
user->emm_data->non_current->kasme.length = AUTH_KASME_SIZE;
user->emm_data->non_current->kasme.value = malloc(32);
_authentication_kasme(autn, &ck, &ik, &user->emm_data->splmn,
&user->emm_data->non_current->kasme);
/* 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,
** **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Others: _emm_data, _authentication_data, T3410, **
** Others: user->emm_data-> _authentication_data, T3410, **
** T3417, T3430 **
** **
***************************************************************************/
......@@ -409,21 +409,21 @@ int emm_proc_authentication_reject(nas_user_t *user)
(void) emm_proc_authentication_delete();
/* 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 */
_emm_data.guti = NULL;
user->emm_data->guti = NULL;
/* Delete the TAI list */
_emm_data.ltai.n_tais = 0;
user->emm_data->ltai.n_tais = 0;
/* Delete the last visited registered TAI */
_emm_data.tai = NULL;
user->emm_data->tai = NULL;
/* Delete the eKSI */
if (_emm_data.security) {
_emm_data.security->type = EMM_KSI_NOT_AVAILABLE;
if (user->emm_data->security) {
user->emm_data->security->type = EMM_KSI_NOT_AVAILABLE;
}
/* Consider the USIM invalid */
_emm_data.usim_is_valid = FALSE;
user->emm_data->usim_is_valid = FALSE;
/* Stop timer T3410 */
if (T3410.id != NAS_TIMER_INACTIVE_ID) {
......@@ -664,14 +664,14 @@ static int _authentication_abnormal_cases_cde(nas_user_t *user, int emm_cause,
*/
emm_sap_t emm_sap;
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.msgType = EMM_AS_MSG_TYPE_AUTH;
emm_sap.u.emm_as.u.security.emm_cause = emm_cause;
emm_sap.u.emm_as.u.security.auts = auts;
/* Setup EPS NAS security data */
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);
if (rc != RETURNerror) {
......@@ -787,7 +787,7 @@ static int _authentication_abnormal_case_f(nas_user_t *user)
*/
emm_sap_t emm_sap;
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;
rc = emm_sap_send(user, &emm_sap);
......
......@@ -124,7 +124,7 @@ static struct {
** Inputs: type: Type of the requested detach **
** switch_off: Indicates whether the detach is required **
** because the UE is switched off or not **
** Others: _emm_data **
** Others: user->emm_data-> **
** **
** Outputs: None **
** Return: RETURNok, RETURNerror **
......@@ -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 */
emm_as->switch_off = switch_off;
/* Set the EPS mobile identity */
emm_as->guti = _emm_data.guti;
emm_as->guti = user->emm_data->guti;
emm_as->ueid = 0;
/* 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
......@@ -413,10 +413,10 @@ void *_emm_detach_t3421_handler(void *args)
/* Set the switch-off indicator */
emm_as->switch_off = _emm_detach_data.switch_off;
/* Set the EPS mobile identity */
emm_as->guti = _emm_data.guti;
emm_as->guti = user->emm_data->guti;
emm_as->ueid = 0;
/* 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);
/*
......
......@@ -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.ueid = ueid;
emm_sap.u.emm_as.u.status.guti = _emm_data.guti;
sctx = _emm_data.security;
emm_sap.u.emm_as.u.status.guti = user->emm_data->guti;
sctx = user->emm_data->security;
/* Setup EPS NAS security data */
emm_as_set_security_data(&emm_sap.u.emm_as.u.status.sctx, sctx,
FALSE, TRUE);
......
......@@ -130,8 +130,8 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t
imsi_t modified_imsi;
/* International Mobile Subscriber Identity is requested */
if (_emm_data.imsi) {
memcpy (&modified_imsi, _emm_data.imsi, sizeof (modified_imsi));
if (user->emm_data->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 */
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
case EMM_IDENT_TYPE_IMEI:
/* 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.imei = _emm_data.imei;
emm_sap.u.emm_as.u.security.imei = user->emm_data->imei;
}
break;
......@@ -177,9 +177,9 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t
case EMM_IDENT_TYPE_TMSI:
/* 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.tmsi = _emm_data.guti->m_tmsi;
emm_sap.u.emm_as.u.security.tmsi = user->emm_data->guti->m_tmsi;
}
break;
......@@ -194,12 +194,12 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t
* to the MME
*/
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.msgType = EMM_AS_MSG_TYPE_IDENT;
/* Setup EPS NAS security data */
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);
LOG_FUNC_RETURN (rc);
......
This diff is collapsed.
......@@ -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 ************************/
/****************************************************************************/
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 ********************/
......@@ -68,7 +68,7 @@ int IdleMode_get_hplmn_index(void);
int IdleMode_get_rplmn_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,
size_t *len);
......
......@@ -160,7 +160,7 @@ int lowerlayer_establish(nas_user_t *user)
LOG_FUNC_IN;
/* Update the EPS Connection Management status */
_emm_data.ecm_status = ECM_CONNECTED;
user->emm_data->ecm_status = ECM_CONNECTED;
LOG_FUNC_RETURN (RETURNok);
}
......@@ -188,7 +188,7 @@ int lowerlayer_release(nas_user_t *user, int cause)
int rc;
/* 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.u.emm_reg.ueid = 0;
......@@ -257,9 +257,9 @@ int lowerlayer_data_req(nas_user_t *user, unsigned int ueid, const OctetString *
//struct emm_data_context_s *ctx = NULL;
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;
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.NASmsg.length = data->length;
......
......@@ -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
* to register to
*/
// FIXME REVIEW
rc = emm_proc_registration_notify(NET_REG_STATE_ON);
rc = emm_proc_registration_notify(user->emm_data, NET_REG_STATE_ON);
if (rc != RETURNok) {
LOG_TRACE(WARNING, "EMM-FSM - "
......
......@@ -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
*/
rc = emm_proc_registration_notify(NET_REG_STATE_DENIED);
rc = emm_proc_registration_notify(user->emm_data, NET_REG_STATE_DENIED);
if (rc != RETURNok) {
LOG_TRACE(WARNING, "EMM-FSM - "
......@@ -112,7 +112,7 @@ int EmmDeregisteredPlmnSearch(nas_user_t *user, const emm_reg_t *evt)
* may be selected either automatically or manually.
* 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) {
LOG_TRACE(WARNING, "EMM-FSM - "
......
......@@ -140,7 +140,7 @@ int EmmRegisteredInitiated(nas_user_t *user, const emm_reg_t *evt)
/*
* 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) {
LOG_TRACE(WARNING, "EMM-FSM - "
......@@ -167,7 +167,7 @@ int EmmRegisteredInitiated(nas_user_t *user, const emm_reg_t *evt)
/*
* 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) {
LOG_TRACE(WARNING, "EMM-FSM - "
......
......@@ -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_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 *);
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 *);
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_status_ind(const emm_as_status_t *, 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_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 *);
/****************************************************************************/
......@@ -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 */
security = _emm_data.security;
security = user->emm_data->security;
/* Decode the received message */
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
memset(&header, 0, sizeof(header));
/* Decrypt the received security protected message */
security = _emm_data.security;
security = user->emm_data->security;
int bytes = nas_message_decrypt((char *)(msg->NASmsg.value),
plain_msg,
&header,
......@@ -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),
&nas_msg,
msg->NASmsg.length,
_emm_data.security);
user->emm_data->security);
if (decoder_rc < 0) {
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)
switch (msg->primitive) {
case _EMMAS_DATA_REQ:
as_msg.msgID = _emm_as_data_req(
as_msg.msgID = _emm_as_data_req(user->emm_data,
&msg->u.data,
&as_msg.msg.ul_info_transfer_req);
break;
case _EMMAS_STATUS_IND:
as_msg.msgID = _emm_as_status_ind(
as_msg.msgID = _emm_as_status_ind(user->emm_data,
&msg->u.status,
&as_msg.msg.ul_info_transfer_req);
break;
......@@ -956,13 +956,13 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg)
case _EMMAS_SECURITY_RES:
as_msg.msgID = _emm_as_security_res(
as_msg.msgID = _emm_as_security_res(user->emm_data,
&msg->u.security,
&as_msg.msg.ul_info_transfer_req);
break;
case _EMMAS_ESTABLISH_REQ:
as_msg.msgID = _emm_as_establish_req(
as_msg.msgID = _emm_as_establish_req(user->emm_data,
&msg->u.establish,
&as_msg.msg.nas_establish_req);
break;
......@@ -1065,7 +1065,7 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg)
** 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)
{
LOG_FUNC_IN;
......@@ -1112,7 +1112,7 @@ static int _emm_as_data_req(const emm_as_data_t *msg,
int bytes;
emm_security_context_t *emm_security_context = NULL;
emm_security_context = _emm_data.security;
emm_security_context = emm_data->security;
if (emm_security_context) {
......@@ -1161,7 +1161,7 @@ static int _emm_as_data_req(const emm_as_data_t *msg,
** 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)
{
LOG_FUNC_IN;
......@@ -1193,7 +1193,7 @@ static int _emm_as_status_ind(const emm_as_status_t *msg,
if (size > 0) {
emm_security_context_t *emm_security_context = NULL;
emm_security_context = _emm_data.security;
emm_security_context = emm_data->security;
if (emm_security_context) {
......@@ -1275,7 +1275,7 @@ static int _emm_as_release_req(const emm_as_release_t *msg,
** 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)
{
LOG_FUNC_IN;
......@@ -1340,7 +1340,7 @@ static int _emm_as_security_res(const emm_as_security_t *msg,
int bytes = _emm_as_encode(&as_msg->nasMsg,
&nas_msg,
size,
_emm_data.security);
emm_data->security);
if (bytes > 0) {
LOG_FUNC_RETURN (AS_UL_INFO_TRANSFER_REQ);
......@@ -1369,7 +1369,7 @@ static int _emm_as_security_res(const emm_as_security_t *msg,
** 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)
{
LOG_FUNC_IN;
......@@ -1433,7 +1433,7 @@ static int _emm_as_establish_req(const emm_as_establish_t *msg,
&as_msg->initialNasMsg,
&nas_msg,
size,
_emm_data.security);
emm_data->security);
if (bytes > 0) {
LOG_FUNC_RETURN (AS_NAS_ESTABLISH_REQ);
......
......@@ -134,7 +134,7 @@ int emm_esm_send(nas_user_t *user, const emm_esm_t *msg)
if (msg->u.establish.is_emergency) {
/* Consider the UE attached for emergency bearer services
* only */
rc = emm_proc_attach_set_emergency();
rc = emm_proc_attach_set_emergency(user->emm_data);
}
} else {
/* 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,
/*
* Check the replayed UE security capabilities
*/
uint8_t eea = (0x80 >> _emm_data.security->capability.eps_encryption);
uint8_t eia = (0x80 >> _emm_data.security->capability.eps_integrity);
uint8_t eea = (0x80 >> user->emm_data->security->capability.eps_encryption);
uint8_t eia = (0x80 >> user->emm_data->security->capability.eps_integrity);
if ( (reea != eea) || (reia != eia) ) {
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,
/*
* 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 "
"is not valid");
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,
else {
LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context seea=%u seia=%u", seea, seia);
/* Update selected cyphering and integrity algorithms */
//LG COMENTED _emm_data.non_current->capability.encryption = seea;
//LG COMENTED _emm_data.non_current->capability.integrity = seia;
//LG COMENTED user->emm_data->non_current->capability.encryption = seea;
//LG COMENTED user->emm_data->non_current->capability.integrity = seia;
_emm_data.non_current->selected_algorithms.encryption = seea;
_emm_data.non_current->selected_algorithms.integrity = seia;
user->emm_data->non_current->selected_algorithms.encryption = seea;
user->emm_data->non_current->selected_algorithms.integrity = seia;
/* Derive the NAS cyphering key */
if (_emm_data.non_current->knas_enc.value == NULL) {
_emm_data.non_current->knas_enc.value =
if (user->emm_data->non_current->knas_enc.value == NULL) {
user->emm_data->non_current->knas_enc.value =
(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");
rc = _security_knas_enc(&_emm_data.non_current->kasme,
&_emm_data.non_current->knas_enc, seea);
rc = _security_knas_enc(&user->emm_data->non_current->kasme,
&user->emm_data->non_current->knas_enc, seea);
}
/* Derive the NAS integrity key */
if (_emm_data.non_current->knas_int.value == NULL) {
_emm_data.non_current->knas_int.value =
if (user->emm_data->non_current->knas_int.value == NULL) {
user->emm_data->non_current->knas_int.value =
(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) {
LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context knas_int");
rc = _security_knas_int(&_emm_data.non_current->kasme,
&_emm_data.non_current->knas_int, seia);
rc = _security_knas_int(&user->emm_data->non_current->kasme,
&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,
if (_security_data.kenb.value != NULL) {
if (rc != RETURNerror) {
LOG_TRACE(INFO, "EMM-PROC - Update the non-current EPS security context kenb");
// LG COMMENT rc = _security_kenb(&_emm_data.security->kasme,
rc = _security_kenb(&_emm_data.non_current->kasme,
// LG COMMENT rc = _security_kenb(&user->emm_data->security->kasme,
rc = _security_kenb(&user->emm_data->non_current->kasme,
&_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,
LOG_TRACE(INFO, "EMM-PROC - NAS security mode command accepted by the UE");
/* 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
* MODE COMMAND message is set to "native security context" and
* the UE has a mapped EPS security context as the current EPS
* security context */
if ( (_emm_data.non_current->type == EMM_KSI_NATIVE) &&
(_emm_data.non_current->eksi == ksi) ) {
if ( (user->emm_data->non_current->type == EMM_KSI_NATIVE) &&
(user->emm_data->non_current->eksi == ksi) ) {
/* The KSI matches the non-current native EPS security
* context; the UE shall take the non-current native EPS
* 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,
LOG_TRACE(INFO,
"EMM-PROC - Update Current security context");
/* Release non-current security context */
_security_release(_emm_data.security);
_emm_data.security = _emm_data.non_current;
_security_release(user->emm_data->security);
user->emm_data->security = user->emm_data->non_current;
/* Reset the uplink NAS COUNT counter */
_emm_data.security->ul_count.overflow = 0;
_emm_data.security->ul_count.seq_num = 0;
user->emm_data->security->ul_count.overflow = 0;
user->emm_data->security->ul_count.seq_num = 0;
/* Set new security context indicator */
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
* MODE COMMAND message is set to "mapped security context" and
* the UE has a mapped EPS security context as the current EPS
* 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 UE shall reset the uplink NAS COUNT counter */
LOG_TRACE(INFO,
"EMM-PROC - Reset uplink NAS COUNT counter");
_emm_data.security->ul_count.overflow = 0;
_emm_data.security->ul_count.seq_num = 0;
user->emm_data->security->ul_count.overflow = 0;
user->emm_data->security->ul_count.seq_num = 0;
}
}
_emm_data.security->selected_algorithms.encryption = seea;
_emm_data.security->selected_algorithms.integrity = seia;
user->emm_data->security->selected_algorithms.encryption = seea;
user->emm_data->security->selected_algorithms.integrity = seia;
#if defined(NAS_BUILT_IN_UE)
nas_itti_kenb_refresh_req(_security_data.kenb.value);
#endif
}
/*
* 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,
*/
emm_sap_t emm_sap;
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.msgType = EMM_AS_MSG_TYPE_SMC;
emm_sap.u.emm_as.u.security.imeisv_request = imeisv_request;
emm_sap.u.emm_as.u.security.emm_cause = emm_cause;
/* Setup EPS NAS security data */
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);
LOG_FUNC_RETURN (rc);
......
......@@ -333,13 +333,6 @@ typedef struct emm_data_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
......
This diff is collapsed.
......@@ -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_cleanup(void);
void emm_main_cleanup(emm_data_t *emm_data);
/* 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 */
const msisdn_t *emm_main_get_msisdn(void);
/* 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);
int emm_main_get_plmn_selection_mode(void);
int emm_main_get_plmn_list(const char **plist);
const char *emm_main_get_selected_plmn(network_plmn_t *plmn, int format);
int emm_main_get_plmn_selection_mode(emm_data_t *emm_data);
int emm_main_get_plmn_list(emm_data_t *emm_data, const char **plist);
const char *emm_main_get_selected_plmn(emm_data_t *emm_data, network_plmn_t *plmn, int format);
/* User's getter for network registration */
Stat_t emm_main_get_plmn_status(void);
tac_t emm_main_get_plmn_tac(void);
ci_t emm_main_get_plmn_ci(void);
AcT_t emm_main_get_plmn_rat(void);
const char *emm_main_get_registered_plmn(network_plmn_t *plmn, int format);
Stat_t emm_main_get_plmn_status(emm_data_t *emm_data);
tac_t emm_main_get_plmn_tac(emm_data_t *emm_data);
ci_t emm_main_get_plmn_ci(emm_data_t *emm_data);
AcT_t emm_main_get_plmn_rat(emm_data_t *emm_data);
const char *emm_main_get_registered_plmn(emm_data_t *emm_data, network_plmn_t *plmn, int format);
/* User's getter for network attachment */
int emm_main_is_attached(void);
int emm_main_is_emergency(void);
int emm_main_is_attached(emm_data_t *emm_data);
int emm_main_is_emergency(emm_data_t *emm_data);
#endif /* __EMM_MAIN_H__*/
......@@ -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_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
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
* Network indication handlers
*---------------------------------------------------------------------------
*/
int emm_proc_registration_notify(Stat_t status);
int emm_proc_location_notify(tac_t tac, ci_t ci, AcT_t rat);
int emm_proc_network_notify(int index);
int emm_proc_registration_notify(emm_data_t *emm_data, Stat_t status);
int emm_proc_location_notify(emm_data_t *emm_data, tac_t tac, ci_t ci, AcT_t rat);
int emm_proc_network_notify(emm_data_t *emm_data, int index);
#endif /* __EMM_PROC_H__*/
......@@ -134,7 +134,7 @@ void nas_proc_cleanup(nas_user_t *user)
/* 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 */
esm_main_cleanup(user->esm_data);
......@@ -251,11 +251,11 @@ int nas_proc_get_eps(nas_user_t *user, int *stat)
** 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;
const imsi_t *imsi = emm_main_get_imsi();
const imsi_t *imsi = emm_main_get_imsi(emm_data);
if (imsi != NULL) {
int offset = 0;
......@@ -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
*/
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) ) {
/*
......@@ -452,16 +452,16 @@ int nas_proc_get_reg_data(nas_user_t *user, int *mode, int *selected, int format
LOG_FUNC_IN;
/* 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 */
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) {
/* An operator is currently selected */
*selected = TRUE;
/* Get the supported Radio Access Technology */
*AcT = emm_main_get_plmn_rat();
*AcT = emm_main_get_plmn_rat(user->emm_data);
} else {
/* No any operator is selected */
*selected = FALSE;
......@@ -489,7 +489,7 @@ int nas_proc_get_oper_list(nas_user_t *user, const char **oper_list)
{
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);
}
......@@ -514,7 +514,7 @@ int nas_proc_get_reg_status(nas_user_t *user, int *stat)
{
LOG_FUNC_IN;
*stat = emm_main_get_plmn_status();
*stat = emm_main_get_plmn_status(user->emm_data);
LOG_FUNC_RETURN (RETURNok);
}
......@@ -542,9 +542,9 @@ int nas_proc_get_loc_info(nas_user_t *user, char *tac, char *ci, int *AcT)
{
LOG_FUNC_IN;
sprintf(tac, "%.4x", emm_main_get_plmn_tac()); // two byte
sprintf(ci, "%.8x", emm_main_get_plmn_ci()); // four byte
*AcT = emm_main_get_plmn_rat(); // E-UTRAN
sprintf(tac, "%.4x", emm_main_get_plmn_tac(user->emm_data)); // two byte
sprintf(ci, "%.8x", emm_main_get_plmn_ci(user->emm_data)); // four byte
*AcT = emm_main_get_plmn_rat(user->emm_data); // E-UTRAN
LOG_FUNC_RETURN (RETURNok);
}
......@@ -570,7 +570,7 @@ int nas_proc_detach(nas_user_t *user, int switch_off)
emm_sap_t emm_sap;
int rc = RETURNok;
if ( emm_main_is_attached() ) {
if ( emm_main_is_attached(user->emm_data) ) {
/* Initiate an Detach procedure */
emm_sap.primitive = EMMREG_DETACH_INIT;
emm_sap.u.emm_reg.u.detach.switch_off = switch_off;
......@@ -601,7 +601,7 @@ int nas_proc_attach(nas_user_t *user)
emm_sap_t emm_sap;
int rc = RETURNok;
if ( !emm_main_is_attached() ) {
if ( !emm_main_is_attached(user->emm_data) ) {
/* Initiate an Attach procedure */
emm_sap.primitive = EMMREG_ATTACH_INIT;
emm_sap.u.emm_reg.u.attach.is_emergency = FALSE;
......@@ -630,7 +630,7 @@ int nas_proc_get_attach_status(nas_user_t *user)
{
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);
}
......@@ -950,14 +950,14 @@ int nas_proc_activate_pdn(nas_user_t *user, int cid)
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
* procedure prior to attempt to request any PDN connectivity
*/
LOG_TRACE(WARNING, "NAS-PROC - UE is not attached to the network");
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
* request a PDN connection to any other PDN */
LOG_TRACE(WARNING,"NAS-PROC - Attached for emergency bearer services");
......
......@@ -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_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_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)
}
/* 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) {
LOG_TRACE(ERROR, "USR-MAIN - Failed to get IMSI number");
......
......@@ -49,14 +49,16 @@ Description NAS type definition to manage a user equipment
#include "esmData.h"
#include "esm_pt_defs.h"
#include "EMM/emm_fsm_defs.h"
#include "EMM/emmData.h"
typedef struct {
int fd;
proc_data_t proc;
esm_data_t *esm_data; // ESM internal data (used within ESM only)
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
emm_fsm_state_t emm_fsm_status; // Current EPS Mobility Management status
emm_data_t *emm_data; // EPS mobility management data
} nas_user_t;
#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