/**************************************************************************** ** ** ** Name: emm_proc_detach_accept() ** ** ** ** Description: Performs the UE initiated detach procedure for EPS servi- ** ** ces only When the DETACH ACCEPT message is received from ** ** the network. ** ** ** ** 3GPP TS 24.301, section 5.5.2.2.2 ** ** Upon receiving the DETACH ACCEPT message, the UE shall ** ** stop timer T3421, locally deactivate all EPS bearer con- ** ** texts without peer-to-peer signalling and enter state EMM-** ** DEREGISTERED. ** ** ** ** Inputs: None ** ** Others: None ** ** ** ** Outputs: None ** ** Return: RETURNok, RETURNerror ** ** Others: T3421 ** ** ** ***************************************************************************/ int emm_proc_detach_accept(void) { LOG_FUNC_IN; int rc; LOG_TRACE(INFO, "EMM-PROC - UE initiated detach procedure completion"); /* Reset EMM procedure handler */ (void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL); /* Stop timer T3421 */ T3421.id = nas_timer_stop(T3421.id); /* * Notify ESM that all EPS bearer contexts have to be locally deactivated */ esm_sap_t esm_sap; esm_sap.primitive = ESM_EPS_BEARER_CONTEXT_DEACTIVATE_REQ; esm_sap.data.eps_bearer_context_deactivate.ebi = ESM_SAP_ALL_EBI; rc = esm_sap_send(&esm_sap); /* * XXX - Upon receiving notification from ESM that all EPS bearer * contexts are locally deactivated, the UE is considered as * detached from the network and is entered state EMM-DEREGISTERED */ LOG_FUNC_RETURN(rc); }
/**************************************************************************** ** ** ** Name: emm_proc_detach() ** ** ** ** Description: Initiates the detach procedure in order for the UE to de- ** ** tach for EPS services. ** ** ** ** 3GPP TS 24.301, section 5.5.2.2.1 ** ** In state EMM-REGISTERED or EMM-REGISTERED-INITIATED, the ** ** UE initiates the detach procedure by sending a DETACH RE- ** ** QUEST message to the network, starting timer T3421 and ** ** entering state EMM-DEREGISTERED-INITIATED. ** ** ** ** 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 ** ** ** ** Outputs: None ** ** Return: RETURNok, RETURNerror ** ** Others: _emm_detach_data ** ** ** ***************************************************************************/ int emm_proc_detach(emm_proc_detach_type_t type, int switch_off) { LOG_FUNC_IN; emm_sap_t emm_sap; emm_as_data_t *emm_as = &emm_sap.u.emm_as.u.data; int rc; LOG_TRACE(INFO, "EMM-PROC - Initiate EPS detach type = %s (%d)", _emm_detach_type_str[type], type); /* Initialize the detach procedure internal data */ _emm_detach_data.count = 0; _emm_detach_data.switch_off = switch_off; _emm_detach_data.type = type; /* Setup EMM procedure handler to be executed upon receiving * lower layer notification */ rc = emm_proc_lowerlayer_initialize(emm_proc_detach_request, emm_proc_detach_failure, emm_proc_detach_release, NULL); if (rc != RETURNok) { LOG_TRACE(WARNING, "Failed to initialize EMM procedure handler"); LOG_FUNC_RETURN (RETURNerror); } /* Setup NAS information message to transfer */ emm_as->NASinfo = EMM_AS_NAS_INFO_DETACH; emm_as->NASmsg.length = 0; emm_as->NASmsg.value = NULL; /* Set the detach type */ emm_as->type = type; /* Set the switch-off indicator */ emm_as->switch_off = switch_off; /* Set the EPS mobile identity */ emm_as->guti = _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); /* * Notify EMM-AS SAP that Detach Request message has to * be sent to the network */ emm_sap.primitive = EMMAS_DATA_REQ; rc = emm_sap_send(&emm_sap); LOG_FUNC_RETURN(rc); }
/**************************************************************************** ** ** ** Name: emm_proc_attach_failure() ** ** ** ** Description: Performs the attach procedure abnormal case upon receipt ** ** of transmission failure of Attach Request message or At- ** ** tach Complete message. ** ** ** ** 3GPP TS 24.301, section 5.5.1.2.6, cases h and i ** ** The UE shall restart the attach procedure when timer ** ** T3411 expires. ** ** ** ** Inputs: is_initial: TRUE if the NAS message that failed to be ** ** transfered is an initial NAS message (ESM ** ** message embedded within an Attach Request ** ** message) ** ** args: Not used ** ** Others: None ** ** ** ** Outputs: None ** ** Return: RETURNok, RETURNerror ** ** Others: T3410, T3411 ** ** ** ***************************************************************************/ int emm_proc_attach_failure(int is_initial, void *args) { LOG_FUNC_IN; int rc = RETURNok; esm_sap_t esm_sap; LOG_TRACE(WARNING, "EMM-PROC - EPS attach failure"); /* Reset EMM procedure handler */ (void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL); /* Stop timer T3410 if still running */ if (T3410.id != NAS_TIMER_INACTIVE_ID) { LOG_TRACE(INFO, "EMM-PROC - Stop timer T3410 (%d)", T3410.id); T3410.id = nas_timer_stop(T3410.id); } if (is_initial) { /* * Notify ESM that the PDN CONNECTIVITY REQUEST message contained * in the ESM message container IE of the ATTACH REQUEST has failed * to be transmitted */ esm_sap.primitive = ESM_PDN_CONNECTIVITY_REJ; esm_sap.is_standalone = FALSE; esm_sap.recv = NULL; } else { /* * Notify ESM that ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message * contained in the ESM message container IE of the ATTACH COMPLETE * has failed to be transmitted */ esm_sap.primitive = ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_REJ; esm_sap.is_standalone = FALSE; esm_sap.recv = NULL; } rc = esm_sap_send(&esm_sap); if (rc != RETURNerror) { /* Start T3411 timer */ T3411.id = nas_timer_start(T3411.sec, _emm_attach_t3411_handler, NULL); LOG_TRACE(INFO, "EMM-PROC - Timer T3411 (%d) expires in %ld seconds", T3411.id, T3411.sec); } LOG_FUNC_RETURN(rc); }
/**************************************************************************** ** ** ** Name: emm_proc_attach_complete() ** ** ** ** Description: Terminates the attach procedure when Attach Complete mes- ** ** sage has been successfully delivered to the MME. ** ** ** ** 3GPP TS 24.301, section 5.5.1.2.4 ** ** Upon successfully sending the ATTACH COMPLETE message, ** ** the UE shall reset the attach attempt counter and tra- ** ** cking area updating attempt counter, enter state EMM- ** ** REGISTERED and set the EPS update status to EU1-UPDATED. ** ** ** ** Inputs: args: Not used ** ** Others: None ** ** ** ** Outputs: None ** ** Return: RETURNok, RETURNerror ** ** Others: _emm_data, _emm_attach_data ** ** ** ***************************************************************************/ int emm_proc_attach_complete(void *args) { LOG_FUNC_IN; emm_sap_t emm_sap; esm_sap_t esm_sap; int rc; LOG_TRACE(INFO, "EMM-PROC - EPS attach complete"); /* Reset EMM procedure handler */ (void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL); /* Reset the attach attempt counter */ _emm_attach_data.attempt_count = 0; /* TODO: Reset the tracking area updating attempt counter */ /* Set the EPS update status to EU1 UPDATED */ _emm_data.status = EU1_UPDATED; _emm_data.is_attached = TRUE; /* * Notify EMM that network attach complete message has been delivered * to the network */ emm_sap.primitive = EMMREG_ATTACH_CNF; rc = emm_sap_send(&emm_sap); if (rc != RETURNerror) { /* * Notify ESM that the Activate Default EPS Bearer Context Accept * message has been delivered to the network within the Attach * Complete message */ esm_sap.primitive = ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_CNF; esm_sap.is_standalone = FALSE; rc = esm_sap_send(&esm_sap); } LOG_FUNC_RETURN(rc); }
/**************************************************************************** ** ** ** Name: _emm_detach_abort() ** ** ** ** Description: Aborts the detach procedure ** ** ** ** Inputs: type: not used ** ** Others: _emm_detach_data ** ** ** ** Outputs: None ** ** Return: RETURNok, RETURNerror ** ** Others: T3421 ** ** ** ***************************************************************************/ static int _emm_detach_abort(emm_proc_detach_type_t type) { LOG_FUNC_IN; emm_sap_t emm_sap; int rc ; LOG_TRACE(WARNING, "EMM-PROC - Abort the detach procedure"); /* Reset EMM procedure handler */ (void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL); /* Stop timer T3421 */ T3421.id = nas_timer_stop(T3421.id); /* * Notify EMM that detach procedure failed */ emm_sap.primitive = EMMREG_DETACH_FAILED; emm_sap.u.emm_reg.u.detach.type = type; rc = emm_sap_send(&emm_sap); LOG_FUNC_RETURN (rc); }
/**************************************************************************** ** ** ** Name: emm_proc_detach_failure() ** ** ** ** Description: Performs the detach procedure abnormal case upon receipt ** ** of transmission failure of Detach Request message. ** ** ** ** 3GPP TS 24.301, section 5.5.2.2.4, case h ** ** The UE shall restart the detach procedure. ** ** ** ** Inputs: is_initial: Not used ** ** args: Not used ** ** Others: _emm_detach_data ** ** ** ** Outputs: None ** ** Return: RETURNok, RETURNerror ** ** Others: None ** ** ** ***************************************************************************/ int emm_proc_detach_failure(int is_initial, void *args) { LOG_FUNC_IN; emm_sap_t emm_sap; int rc; LOG_TRACE(WARNING, "EMM-PROC - Network detach failure"); /* Reset EMM procedure handler */ (void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL); /* Stop timer T3421 */ T3421.id = nas_timer_stop(T3421.id); /* * Notify EMM that detach procedure has to be restarted */ emm_sap.primitive = EMMREG_DETACH_INIT; emm_sap.u.emm_reg.u.detach.switch_off = _emm_detach_data.switch_off; rc = emm_sap_send(&emm_sap); LOG_FUNC_RETURN(rc); }
/**************************************************************************** ** ** ** Name: emm_proc_attach_accept() ** ** ** ** Description: Performs the attach procedure accepted by the network. ** ** ** ** 3GPP TS 24.301, section 5.5.1.2.4 ** ** Upon receiving the ATTACH ACCEPT message, the UE shall ** ** stop timer T3410 and send an ATTACH COMPLETE message to ** ** the MME. ** ** ** ** Inputs: t3412: Value of the T3412 timer in seconds ** ** t3402: Value of the T3402 timer in seconds ** ** t3423: Value of the T3423 timer in seconds ** ** n_tais: Number of tracking area identities contai- ** ** ned in the TAI list ** ** tai: The TAI list that identifies the tracking ** ** areas the UE is registered to ** ** guti: New UE's temporary identity assigned by ** ** the MME (GUTI reallocation) ** ** n_eplmns: Number of equivalent PLMNs ** ** eplmns: List of equivalent PLMNs ** ** esm_msg_pP: Activate default EPS bearer context re- ** ** quest ESM message ** ** Others: None ** ** ** ** Outputs: None ** ** Return: RETURNok, RETURNerror ** ** Others: _emm_data, T3412, T3402, T3423 ** ** ** ***************************************************************************/ int emm_proc_attach_accept(long t3412, long t3402, long t3423, int n_tais, tai_t *tai, GUTI_t *guti, int n_eplmns, plmn_t *eplmn, const OctetString *esm_msg_pP) { LOG_FUNC_IN; emm_sap_t emm_sap; esm_sap_t esm_sap; int rc; int i; int j; LOG_TRACE(INFO, "EMM-PROC - EPS attach accepted by the network"); /* Stop timer T3410 */ LOG_TRACE(INFO, "EMM-PROC - Stop timer T3410 (%d)", T3410.id); T3410.id = nas_timer_stop(T3410.id); /* Delete old TAI list and store the received TAI list */ _emm_data.ltai.n_tais = n_tais; for (i = 0; (i < n_tais) && (i < EMM_DATA_TAI_MAX); i++) { _emm_data.ltai.tai[i] = tai[i]; } /* Update periodic tracking area update timer value */ T3412.sec = t3412; /* Update attach failure timer value */ if ( !(t3402 < 0) ) { T3402.sec = t3402; } /* Update E-UTRAN deactivate ISR timer value */ if ( !(t3423 < 0) ) { T3423.sec = t3423; } /* Delete old GUTI and store the new assigned GUTI if provided */ if (guti) { *_emm_data.guti = *guti; } /* Update the stored list of equivalent PLMNs */ _emm_data.nvdata.eplmn.n_plmns = 0; if (n_eplmns > 0) { for (i = 0; (i < n_eplmns) && (i < EMM_DATA_EPLMN_MAX); i++) { int is_forbidden = FALSE; if (!_emm_data.is_emergency) { /* If the attach procedure is not for emergency bearer * services, the UE shall remove from the list any PLMN * code that is already in the list of forbidden PLMNs */ for (j = 0; j < _emm_data.fplmn.n_plmns; j++) { if (PLMNS_ARE_EQUAL(eplmn[i], _emm_data.fplmn.plmn[j])) { is_forbidden = TRUE; break; } } } if ( !is_forbidden ) { _emm_data.nvdata.eplmn.plmn[_emm_data.nvdata.eplmn.n_plmns++] = eplmn[i]; } } /* Add the PLMN code of the registered PLMN that sent the list */ if (_emm_data.nvdata.eplmn.n_plmns < EMM_DATA_EPLMN_MAX) { _emm_data.nvdata.eplmn.plmn[_emm_data.nvdata.eplmn.n_plmns++] = _emm_data.splmn; } } /* * Notify ESM that a default EPS bearer has to be activated */ esm_sap.primitive = ESM_DEFAULT_EPS_BEARER_CONTEXT_ACTIVATE_REQ; esm_sap.is_standalone = FALSE; esm_sap.recv = esm_msg_pP; rc = esm_sap_send(&esm_sap); if ( (rc != RETURNerror) && (esm_sap.err == ESM_SAP_SUCCESS) ) { /* Setup EMM procedure handler to be executed upon receiving * lower layer notification */ rc = emm_proc_lowerlayer_initialize(emm_proc_attach_complete, emm_proc_attach_failure, NULL, NULL); if (rc != RETURNok) { LOG_TRACE(WARNING, "EMM-PROC - Failed to initialize EMM procedure handler"); LOG_FUNC_RETURN (RETURNerror); } /* * Notify EMM-AS SAP that Attach Complete message together with * an Activate Default EPS Bearer Context Accept message has to * be sent to the network */ emm_sap.primitive = EMMAS_DATA_REQ; emm_sap.u.emm_as.u.data.guti = _emm_data.guti; emm_sap.u.emm_as.u.data.ueid = 0; /* Setup EPS NAS security data */ emm_as_set_security_data(&emm_sap.u.emm_as.u.data.sctx, _emm_data.security, FALSE, TRUE); /* Get the activate default EPS bearer context accept message * to be transfered within the ESM container of the attach * complete message */ emm_sap.u.emm_as.u.data.NASinfo = EMM_AS_NAS_DATA_ATTACH; emm_sap.u.emm_as.u.data.NASmsg = esm_sap.send; rc = emm_sap_send(&emm_sap); } else if (esm_sap.err != ESM_SAP_DISCARDED) { /* 3GPP TS 24.301, section 5.5.1.2.6, case j * If the ACTIVATE DEFAULT BEARER CONTEXT REQUEST message combined * with the ATTACH ACCEPT is not accepted by the UE due to failure * in the UE ESM sublayer, then the UE shall initiate the detach * procedure by sending a DETACH REQUEST message to the network. */ emm_sap.primitive = EMMREG_DETACH_INIT; rc = emm_sap_send(&emm_sap); } else { /* * ESM procedure failed and, received message has been discarded or * Status message has been returned; ignore ESM procedure failure */ rc = RETURNok; } LOG_FUNC_RETURN(rc); }
/**************************************************************************** ** ** ** Name: emm_proc_attach() ** ** ** ** Description: Initiate EPS attach procedure to register a UE in PS mode ** ** of operation for EPS services only, or register a UE for ** ** emergency bearer services. ** ** ** ** 3GPP TS 24.301, section 5.5.1.2.2 ** ** In state EMM-DEREGISTERED, the UE initiates the attach ** ** procedure by sending an ATTACH REQUEST message to the MME,** ** starting timer T3410 and entering state EMM-REGISTERED- ** ** INITIATED. ** ** ** ** Inputs: type: Type of the requested attach ** ** Others: _emm_data ** ** ** ** Outputs: None ** ** Return: RETURNok, RETURNerror ** ** Others: T3402, T3410, T3411 ** ** ** ***************************************************************************/ int emm_proc_attach(emm_proc_attach_type_t type) { LOG_FUNC_IN; emm_sap_t emm_sap; emm_as_establish_t *emm_as = &emm_sap.u.emm_as.u.establish; esm_sap_t esm_sap; int rc; LOG_TRACE(INFO, "EMM-PROC - Initiate EPS attach type = %s (%d)", _emm_attach_type_str[type], type); /* Update the emergency bearer service indicator */ if (type == EMM_ATTACH_TYPE_EMERGENCY) { _emm_data.is_emergency = TRUE; } /* Setup initial NAS information message to transfer */ emm_as->NASinfo = EMM_AS_NAS_INFO_ATTACH; /* Set the attach type */ emm_as->type = type; /* Set the RRC connection establishment cause */ if (_emm_data.is_emergency) { emm_as->RRCcause = NET_ESTABLISH_CAUSE_EMERGENCY; emm_as->RRCtype = NET_ESTABLISH_TYPE_EMERGENCY_CALLS; } else { emm_as->RRCcause = NET_ESTABLISH_CAUSE_MO_SIGNAL; emm_as->RRCtype = NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL; } /* Set the PLMN identifier of the selected PLMN */ emm_as->plmnID = &_emm_data.splmn; /* * Process the EPS mobile identity */ emm_as->UEid.guti = NULL; emm_as->UEid.tai = NULL; emm_as->UEid.imsi = NULL; emm_as->UEid.imei = NULL; /* Check whether the UE is configured for "AttachWithIMSI" */ if (_emm_data.AttachWithImsi) { /* Check whether the selected PLMN is neither the registered PLMN * nor in the list of equivalent PLMNs */ if ( (!_emm_data.is_rplmn) && (!_emm_data.is_eplmn) ) { LOG_TRACE(INFO, "EMM-PROC - Initiate EPS attach with IMSI"); /* Include the IMSI */ emm_as->UEid.imsi = _emm_data.imsi; } else { LOG_TRACE(INFO, "EMM-PROC - Initiate EPS attach with NO IMSI, is registered PLMN %d, is equivalent PLMN %d", _emm_data.is_rplmn, _emm_data.is_eplmn); } } else if (_emm_data.guti) { LOG_TRACE(INFO, "EMM-PROC - Initiate EPS attach with GUTI"); /* Include a valid GUTI and the last visited registered TAI */ emm_as->UEid.guti = _emm_data.guti; emm_as->UEid.tai = _emm_data.tai; } else if (!_emm_data.is_emergency) { LOG_TRACE(INFO, "EMM-PROC - Initiate EPS attach with IMSI cause is no emergency and no GUTI"); /* Include the IMSI if no valid GUTI is available */ emm_as->UEid.imsi = _emm_data.imsi; } else { /* The UE is attaching for emergency bearer services and * does not hold a valid GUTI */ if (_emm_data.imsi) { /* Include the IMSI if valid (USIM is present) */ LOG_TRACE(INFO, "EMM-PROC - Initiate EPS attach with IMSI cause is emergency and no GUTI"); emm_as->UEid.imsi = _emm_data.imsi; } else { LOG_TRACE(INFO, "EMM-PROC - Initiate EPS attach with IMSI cause is emergency and no GUTI and no IMSI"); /* Include the IMEI if the IMSI is not valid */ emm_as->UEid.imei = _emm_data.imei; } } /* Setup EPS NAS security data */ emm_as_set_security_data(&emm_as->sctx, _emm_data.security, FALSE, FALSE); emm_as->ksi = EMM_AS_NO_KEY_AVAILABLE; if (_emm_data.security) { if (_emm_data.security->type != EMM_KSI_NOT_AVAILABLE) { emm_as->ksi = _emm_data.security->eksi; } LOG_TRACE(INFO, "EMM-PROC - eps_encryption 0x%X", _emm_data.security->capability.eps_encryption); LOG_TRACE(INFO, "EMM-PROC - eps_integrity 0x%X", _emm_data.security->capability.eps_integrity); emm_as->encryption = _emm_data.security->capability.eps_encryption; emm_as->integrity = _emm_data.security->capability.eps_integrity; } /* * Notify ESM that initiation of a PDN connectivity procedure * is requested to setup a default EPS bearer */ esm_sap.primitive = ESM_PDN_CONNECTIVITY_REQ; esm_sap.is_standalone = FALSE; esm_sap.data.pdn_connect.is_defined = TRUE; esm_sap.data.pdn_connect.cid = 1; /* TODO: PDN type should be set according to the IP capability of the UE */ esm_sap.data.pdn_connect.pdn_type = NET_PDN_TYPE_IPV4V6; esm_sap.data.pdn_connect.apn = NULL; esm_sap.data.pdn_connect.is_emergency = _emm_data.is_emergency; rc = esm_sap_send(&esm_sap); if (rc != RETURNerror) { /* Setup EMM procedure handler to be executed upon receiving * lower layer notification */ rc = emm_proc_lowerlayer_initialize(emm_proc_attach_request, emm_proc_attach_failure, emm_proc_attach_release, NULL); if (rc != RETURNok) { LOG_TRACE(WARNING, "Failed to initialize EMM procedure handler"); LOG_FUNC_RETURN (RETURNerror); } /* Start T3410 timer */ T3410.id = nas_timer_start(T3410.sec, _emm_attach_t3410_handler, NULL); LOG_TRACE(INFO,"EMM-PROC - Timer T3410 (%d) expires in %ld seconds", T3410.id, T3410.sec); /* Stop T3402 and T3411 timers if running */ T3402.id = nas_timer_stop(T3402.id); T3411.id = nas_timer_stop(T3411.id); /* * Notify EMM-AS SAP that a RRC connection establishment procedure * is requested from the Access-Stratum to send initial NAS message * attach request to the network */ emm_sap.primitive = EMMAS_ESTABLISH_REQ; /* Get the PDN connectivity request to transfer within the ESM * container of the initial attach request message */ emm_sap.u.emm_as.u.establish.NASmsg = esm_sap.send; rc = emm_sap_send(&emm_sap); } LOG_FUNC_RETURN(rc); }
/**************************************************************************** ** ** ** Name: emm_proc_identification_request() ** ** ** ** Description: Performs the MME requested identification procedure. ** ** ** ** 3GPP TS 24.301, section 5.4.4.3 ** ** Upon receiving the IDENTITY REQUEST message, the UE shall ** ** send an IDENTITY RESPONSE message to the network. The ** ** IDENTITY RESPONSE message shall contain the identifica- ** ** tion parameters as requested by the network. ** ** ** ** Inputs: type: Type of the requested identity ** ** Others: None ** ** ** ** Outputs: None ** ** Return: RETURNok, RETURNerror ** ** Others: None ** ** ** ***************************************************************************/ int emm_proc_identification_request(emm_proc_identity_type_t type) { LOG_FUNC_IN; int rc; emm_sap_t emm_sap; LOG_TRACE(INFO, "EMM-PROC - Identification requested type = %s (%d)", _emm_identity_type_str[type], type); /* Setup EMM procedure handler to be executed upon receiving * lower layer notification */ rc = emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL); if (rc != RETURNok) { LOG_TRACE(WARNING, "EMM-PROC - Failed to initialize EMM procedure handler"); LOG_FUNC_RETURN (RETURNerror); } emm_sap.u.emm_as.u.security.identType = EMM_IDENT_TYPE_NOT_AVAILABLE; switch (type) { case EMM_IDENT_TYPE_IMSI: { imsi_t modified_imsi; /* International Mobile Subscriber Identity is requested */ if (_emm_data.imsi) { memcpy (&modified_imsi, _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) { modified_imsi.u.num.digit6 = 0; } emm_sap.u.emm_as.u.security.identType = EMM_IDENT_TYPE_IMSI; emm_sap.u.emm_as.u.security.imsi = &modified_imsi; LOG_TRACE(INFO, "EMM-PROC - IMSI = %u%u%u %u%u%u %u%u%u%u%x%x%x%x%x", emm_sap.u.emm_as.u.security.imsi->u.num.digit1, emm_sap.u.emm_as.u.security.imsi->u.num.digit2, emm_sap.u.emm_as.u.security.imsi->u.num.digit3, emm_sap.u.emm_as.u.security.imsi->u.num.digit4, emm_sap.u.emm_as.u.security.imsi->u.num.digit5, emm_sap.u.emm_as.u.security.imsi->u.num.digit6, emm_sap.u.emm_as.u.security.imsi->u.num.digit7, emm_sap.u.emm_as.u.security.imsi->u.num.digit8, emm_sap.u.emm_as.u.security.imsi->u.num.digit9, emm_sap.u.emm_as.u.security.imsi->u.num.digit10, emm_sap.u.emm_as.u.security.imsi->u.num.digit11, emm_sap.u.emm_as.u.security.imsi->u.num.digit12, emm_sap.u.emm_as.u.security.imsi->u.num.digit13, emm_sap.u.emm_as.u.security.imsi->u.num.digit14, emm_sap.u.emm_as.u.security.imsi->u.num.digit15); } break; } case EMM_IDENT_TYPE_IMEI: /* International Mobile Equipment Identity is requested */ if (_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; } break; case EMM_IDENT_TYPE_TMSI: /* Temporary Mobile Subscriber Identity is requested */ if (_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; } break; default: /* Other identities are not available */ break; } /* * Notify EMM-AS SAP that Identity Response message has to be sent * 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.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); rc = emm_sap_send(&emm_sap); LOG_FUNC_RETURN (rc); }