Commit ef05c1d9 authored by Frédéric Leroy's avatar Frédéric Leroy

UE/EMM: move static T34XX timers to emm_data_t

parent 491f299b
......@@ -148,6 +148,7 @@ int emm_proc_attach(nas_user_t *user, emm_proc_attach_type_t type)
emm_as_establish_t *emm_as = &emm_sap.u.emm_as.u.establish;
esm_sap_t esm_sap;
int rc;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
LOG_TRACE(INFO, "EMM-PROC - Initiate EPS attach type = %s (%d)",
_emm_attach_type_str[type], type);
......@@ -260,12 +261,12 @@ int emm_proc_attach(nas_user_t *user, emm_proc_attach_type_t type)
}
/* Start T3410 timer */
T3410.id = nas_timer_start(T3410.sec, _emm_attach_t3410_handler, user);
emm_timers->T3410.id = nas_timer_start(emm_timers->T3410.sec, _emm_attach_t3410_handler, user);
LOG_TRACE(INFO,"EMM-PROC - Timer T3410 (%d) expires in %ld seconds",
T3410.id, T3410.sec);
emm_timers->T3410.id, emm_timers->T3410.sec);
/* Stop T3402 and T3411 timers if running */
T3402.id = nas_timer_stop(T3402.id);
T3411.id = nas_timer_stop(T3411.id);
emm_timers->T3402.id = nas_timer_stop(emm_timers->T3402.id);
emm_timers->T3411.id = nas_timer_stop(emm_timers->T3411.id);
/*
* Notify EMM-AS SAP that a RRC connection establishment procedure
......@@ -357,12 +358,13 @@ int emm_proc_attach_accept(nas_user_t *user, long t3412, long t3402, long t3423,
int rc;
int i;
int j;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
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);
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3410 (%d)", emm_timers->T3410.id);
emm_timers->T3410.id = nas_timer_stop(emm_timers->T3410.id);
/* Delete old TAI list and store the received TAI list */
user->emm_data->ltai.n_tais = n_tais;
......@@ -372,16 +374,16 @@ int emm_proc_attach_accept(nas_user_t *user, long t3412, long t3402, long t3423,
}
/* Update periodic tracking area update timer value */
T3412.sec = t3412;
emm_timers->T3412.sec = t3412;
/* Update attach failure timer value */
if ( !(t3402 < 0) ) {
T3402.sec = t3402;
emm_timers->T3402.sec = t3402;
}
/* Update E-UTRAN deactivate ISR timer value */
if ( !(t3423 < 0) ) {
T3423.sec = t3423;
emm_timers->T3423.sec = t3423;
}
/* Delete old GUTI and store the new assigned GUTI if provided */
......@@ -506,13 +508,14 @@ int emm_proc_attach_reject(nas_user_t *user, int emm_cause, const OctetString *e
emm_sap_t emm_sap;
int rc;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
LOG_TRACE(WARNING, "EMM-PROC - EPS attach rejected by the network, "
"EMM cause = %d", emm_cause);
/* Stop timer T3410 */
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3410 (%d)", T3410.id);
T3410.id = nas_timer_stop(T3410.id);
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3410 (%d)", emm_timers->T3410.id);
emm_timers->T3410.id = nas_timer_stop(emm_timers->T3410.id);
/* Update the EPS update status, the GUTI, the visited registered TAI and
* the eKSI */
......@@ -790,6 +793,7 @@ int emm_proc_attach_failure(int is_initial, void *args)
int rc = RETURNok;
esm_sap_t esm_sap;
nas_user_t *user=args;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
LOG_TRACE(WARNING, "EMM-PROC - EPS attach failure");
......@@ -797,9 +801,9 @@ int emm_proc_attach_failure(int is_initial, void *args)
(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 (emm_timers->T3410.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3410 (%d)", emm_timers->T3410.id);
emm_timers->T3410.id = nas_timer_stop(emm_timers->T3410.id);
}
if (is_initial) {
......@@ -826,9 +830,9 @@ int emm_proc_attach_failure(int is_initial, void *args)
if (rc != RETURNerror) {
/* Start T3411 timer */
T3411.id = nas_timer_start(T3411.sec, _emm_attach_t3411_handler, NULL);
emm_timers->T3411.id = nas_timer_start(emm_timers->T3411.sec, _emm_attach_t3411_handler, NULL);
LOG_TRACE(INFO, "EMM-PROC - Timer T3411 (%d) expires in %ld seconds",
T3411.id, T3411.sec);
emm_timers->T3411.id, emm_timers->T3411.sec);
}
LOG_FUNC_RETURN(rc);
......@@ -1002,13 +1006,14 @@ void *_emm_attach_t3410_handler(void *args)
LOG_FUNC_IN;
nas_user_t *user=args;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
emm_sap_t emm_sap;
int rc;
LOG_TRACE(WARNING, "EMM-PROC - T3410 timer expired");
/* Stop T3410 timer */
T3410.id = nas_timer_stop(T3410.id);
emm_timers->T3410.id = nas_timer_stop(emm_timers->T3410.id);
/* Execute abnormal case attach procedure */
_emm_attach_abnormal_cases_bcd(user, &emm_sap);
......@@ -1045,12 +1050,13 @@ static void *_emm_attach_t3411_handler(void *args)
LOG_FUNC_IN;
nas_user_t *user=args;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
emm_sap_t emm_sap;
LOG_TRACE(WARNING, "EMM-PROC - T3411 timer expired");
/* Stop T3411 timer */
T3411.id = nas_timer_stop(T3411.id);
emm_timers->T3411.id = nas_timer_stop(emm_timers->T3411.id);
/*
* Notify EMM that timer T3411 expired and attach procedure has to be
* restarted
......@@ -1090,12 +1096,13 @@ static void *_emm_attach_t3402_handler(void *args)
LOG_FUNC_IN;
nas_user_t *user=args;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
emm_sap_t emm_sap;
LOG_TRACE(WARNING, "EMM-PROC - T3402 timer expired");
/* Stop T3402 timer */
T3402.id = nas_timer_stop(T3402.id);
emm_timers->T3402.id = nas_timer_stop(emm_timers->T3402.id);
/* Reset the attach attempt counter */
_emm_attach_data.attempt_count = 0;
/*
......@@ -1140,23 +1147,23 @@ static void *_emm_attach_t3402_handler(void *args)
static void _emm_attach_abnormal_cases_bcd(nas_user_t *user, emm_sap_t *emm_sap)
{
LOG_FUNC_IN;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
LOG_TRACE(WARNING, "EMM-PROC - Abnormal case, attach counter = %d",
_emm_attach_data.attempt_count);
/* Stop timer T3410 */
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 (emm_timers->T3410.id != NAS_TIMER_INACTIVE_ID) {
LOG_TRACE(INFO, "EMM-PROC - Stop timer T3410 (%d)", emm_timers->T3410.id);
emm_timers->T3410.id = nas_timer_stop(emm_timers->T3410.id);
}
if (_emm_attach_data.attempt_count < EMM_ATTACH_COUNTER_MAX) {
/* Increment the attach attempt counter */
_emm_attach_data.attempt_count += 1;
/* Start T3411 timer */
T3411.id = nas_timer_start(T3411.sec, _emm_attach_t3411_handler, NULL);
emm_timers->T3411.id = nas_timer_start(emm_timers->T3411.sec, _emm_attach_t3411_handler, NULL);
LOG_TRACE(INFO, "EMM-PROC - Timer T3411 (%d) expires in %ld seconds",
T3411.id, T3411.sec);
emm_timers->T3411.id, emm_timers->T3411.sec);
/*
* Notify EMM that the attempt to attach for EPS services failed and
* the attach attempt counter didn't reach its maximum value; network
......@@ -1182,9 +1189,9 @@ static void _emm_attach_abnormal_cases_bcd(nas_user_t *user, emm_sap_t *emm_sap)
user->emm_data->status = EU2_NOT_UPDATED;
/* Start T3402 timer */
T3402.id = nas_timer_start(T3402.sec, _emm_attach_t3402_handler, user);
emm_timers->T3402.id = nas_timer_start(emm_timers->T3402.sec, _emm_attach_t3402_handler, user);
LOG_TRACE(INFO, "EMM-PROC - Timer T3402 (%d) expires in %ld seconds",
T3402.id, T3402.sec);
emm_timers->T3402.id, emm_timers->T3402.sec);
/*
* Notify EMM that the attempt to attach for EPS services failed and
* the attach attempt counter reached its maximum value.
......
This diff is collapsed.
......@@ -203,14 +203,15 @@ int emm_proc_detach_request(void *args)
LOG_FUNC_IN;
nas_user_t *user=args;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
emm_sap_t emm_sap;
int rc;
if ( !_emm_detach_data.switch_off ) {
/* Start T3421 timer */
T3421.id = nas_timer_start(T3421.sec, _emm_detach_t3421_handler, user);
emm_timers->T3421.id = nas_timer_start(emm_timers->T3421.sec, _emm_detach_t3421_handler, user);
LOG_TRACE(INFO, "EMM-PROC - Timer T3421 (%d) expires in %ld seconds",
T3421.id, T3421.sec);
emm_timers->T3421.id, emm_timers->T3421.sec);
}
/*
......@@ -249,6 +250,7 @@ int emm_proc_detach_accept(void* args)
LOG_FUNC_IN;
nas_user_t *user=args;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
int rc;
LOG_TRACE(INFO, "EMM-PROC - UE initiated detach procedure completion");
......@@ -257,7 +259,7 @@ int emm_proc_detach_accept(void* args)
(void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL);
/* Stop timer T3421 */
T3421.id = nas_timer_stop(T3421.id);
emm_timers->T3421.id = nas_timer_stop(emm_timers->T3421.id);
/*
* Notify ESM that all EPS bearer contexts have to be locally deactivated
......@@ -299,6 +301,7 @@ int emm_proc_detach_failure(int is_initial, void *args)
LOG_FUNC_IN;
nas_user_t *user=args;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
emm_sap_t emm_sap;
int rc;
......@@ -308,7 +311,7 @@ int emm_proc_detach_failure(int is_initial, void *args)
(void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL);
/* Stop timer T3421 */
T3421.id = nas_timer_stop(T3421.id);
emm_timers->T3421.id = nas_timer_stop(emm_timers->T3421.id);
/*
* Notify EMM that detach procedure has to be restarted
......@@ -372,7 +375,7 @@ int emm_proc_detach_release(void *args)
** 3GPP TS 24.301, section 5.5.2.2.4 case c **
** On the first four expiries of the timer, the UE shall re- **
** transmit the DETACH REQUEST message and shall reset and **
** restart timer T3421. On the fifth expiry of timer T3421, **
** restart timer emm_timers->T3421. On the fifth expiry of timer T3421, **
** the detach procedure shall be aborted. **
** **
** Inputs: args: handler parameters **
......@@ -388,6 +391,7 @@ void *_emm_detach_t3421_handler(void *args)
LOG_FUNC_IN;
nas_user_t *user=args;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
int rc;
/* Increment the retransmission counter */
......@@ -402,7 +406,7 @@ void *_emm_detach_t3421_handler(void *args)
emm_as_data_t *emm_as = &emm_sap.u.emm_as.u.data;
/* Stop timer T3421 */
T3421.id = nas_timer_stop(T3421.id);
emm_timers->T3421.id = nas_timer_stop(emm_timers->T3421.id);
/* Setup NAS information message to transfer */
emm_as->NASinfo = EMM_AS_NAS_INFO_DETACH;
......@@ -428,9 +432,9 @@ void *_emm_detach_t3421_handler(void *args)
if (rc != RETURNerror) {
/* Start T3421 timer */
T3421.id = nas_timer_start(T3421.sec, _emm_detach_t3421_handler, user);
emm_timers->T3421.id = nas_timer_start(emm_timers->T3421.sec, _emm_detach_t3421_handler, user);
LOG_TRACE(INFO, "EMM-PROC - Timer T3421 (%d) expires in %ld "
"seconds", T3421.id, T3421.sec);
"seconds", emm_timers->T3421.id, emm_timers->T3421.sec);
}
} else {
/* Abort the detach procedure */
......@@ -464,6 +468,7 @@ static int _emm_detach_abort(nas_user_t *user, emm_proc_detach_type_t type)
{
LOG_FUNC_IN;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
emm_sap_t emm_sap;
int rc ;
......@@ -473,7 +478,7 @@ static int _emm_detach_abort(nas_user_t *user, emm_proc_detach_type_t type)
(void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL);
/* Stop timer T3421 */
T3421.id = nas_timer_stop(T3421.id);
emm_timers->T3421.id = nas_timer_stop(emm_timers->T3421.id);
/*
* Notify EMM that detach procedure failed
......
......@@ -112,11 +112,13 @@ void *_emm_service_t3417_handler(void *);
void *_emm_service_t3417_handler(void *args)
{
LOG_FUNC_IN;
nas_user_t *user = args;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
LOG_TRACE(WARNING, "EMM-PROC - T3417 timer expired");
/* Stop timer T3417 */
T3417.id = nas_timer_stop(T3417.id);
emm_timers->T3417.id = nas_timer_stop(emm_timers->T3417.id);
LOG_FUNC_RETURN(NULL);
}
......
......@@ -113,11 +113,13 @@ void *_emm_tau_t3430_handler(void *);
void *_emm_tau_t3430_handler(void *args)
{
LOG_FUNC_IN;
nas_user_t *user = args;
emm_timers_t *emm_timers = user->emm_data->emm_timers;
LOG_TRACE(WARNING, "EMM-PROC - T3430 timer expired");
/* Stop timer T3430 */
T3430.id = nas_timer_stop(T3430.id);
emm_timers->T3430.id = nas_timer_stop(emm_timers->T3430.id);
LOG_FUNC_RETURN(NULL);
}
......
......@@ -197,6 +197,20 @@ typedef struct emm_nvdata_s {
PLMN_LIST_T(EMM_DATA_EPLMN_MAX) eplmn;
} emm_nvdata_t;
typedef struct {
struct nas_timer_t T3402; /* attach failure timer */
struct nas_timer_t T3410; /* attach timer */
struct nas_timer_t T3411; /* attach restart timer */
struct nas_timer_t T3412; /* periodic tracking area update timer */
struct nas_timer_t T3416; /* EPS authentication challenge timer */
struct nas_timer_t T3417; /* Service request timer */
struct nas_timer_t T3418; /* MAC authentication failure timer */
struct nas_timer_t T3420; /* Synch authentication failure timer */
struct nas_timer_t T3421; /* Detach timer */
struct nas_timer_t T3430; /* tracking area update timer */
struct nas_timer_t T3423; /* E-UTRAN deactivate ISR timer */
} emm_timers_t;
/*
* Structure of the EMM data
* -------------------------
......@@ -324,7 +338,11 @@ typedef struct emm_data_s {
*/
emm_security_context_t *security; /* current security context */
emm_security_context_t *non_current; /* non-current security context */
/*
* EPS mobility management timers – UE side
* ----------------------------------------
*/
emm_timers_t *emm_timers;
} emm_data_t;
......@@ -333,11 +351,6 @@ typedef struct emm_data_s {
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/*
* --------------------------------------------------------------------------
* EPS mobility management timers – UE side
* --------------------------------------------------------------------------
*/
#define T3402_DEFAULT_VALUE 720 /* 12 minutes */
#define T3410_DEFAULT_VALUE 15 /* 15 seconds */
#define T3411_DEFAULT_VALUE 10 /* 10 seconds */
......@@ -352,20 +365,6 @@ typedef struct emm_data_s {
#define T3430_DEFAULT_VALUE 15 /* 15 seconds */
#define T3440_DEFAULT_VALUE 10 /* 10 seconds */
// FIXME put in another structure
struct nas_timer_t T3402; /* attach failure timer */
struct nas_timer_t T3410; /* attach timer */
struct nas_timer_t T3411; /* attach restart timer */
struct nas_timer_t T3412; /* periodic tracking area update timer */
struct nas_timer_t T3416; /* EPS authentication challenge timer */
struct nas_timer_t T3417; /* Service request timer */
struct nas_timer_t T3418; /* MAC authentication failure timer */
struct nas_timer_t T3420; /* Synch authentication failure timer */
struct nas_timer_t T3421; /* Detach timer */
struct nas_timer_t T3430; /* tracking area update timer */
struct nas_timer_t T3423; /* E-UTRAN deactivate ISR timer */
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
......
......@@ -79,6 +79,32 @@ static int _emm_main_callback(emm_data_t *emm_data, int);
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
/*
* Initialize EMM timers
*/
void _emm_timers_initialize(emm_timers_t *emm_timers) {
emm_timers->T3410.id = NAS_TIMER_INACTIVE_ID;
emm_timers->T3410.sec = T3410_DEFAULT_VALUE;
emm_timers->T3411.id = NAS_TIMER_INACTIVE_ID;
emm_timers->T3411.sec = T3411_DEFAULT_VALUE;
emm_timers->T3402.id = NAS_TIMER_INACTIVE_ID;
emm_timers->T3402.sec = T3402_DEFAULT_VALUE;
emm_timers->T3416.id = NAS_TIMER_INACTIVE_ID;
emm_timers->T3416.sec = T3416_DEFAULT_VALUE;
emm_timers->T3417.id = NAS_TIMER_INACTIVE_ID;
emm_timers->T3417.sec = T3417_DEFAULT_VALUE;
emm_timers->T3418.id = NAS_TIMER_INACTIVE_ID;
emm_timers->T3418.sec = T3418_DEFAULT_VALUE;
emm_timers->T3420.id = NAS_TIMER_INACTIVE_ID;
emm_timers->T3420.sec = T3420_DEFAULT_VALUE;
emm_timers->T3421.id = NAS_TIMER_INACTIVE_ID;
emm_timers->T3421.sec = T3421_DEFAULT_VALUE;
emm_timers->T3423.id = NAS_TIMER_INACTIVE_ID;
emm_timers->T3423.sec = T3423_DEFAULT_VALUE;
emm_timers->T3430.id = NAS_TIMER_INACTIVE_ID;
emm_timers->T3430.sec = T3430_DEFAULT_VALUE;
}
/****************************************************************************
** **
** Name: emm_main_initialize() **
......@@ -360,26 +386,12 @@ void emm_main_initialize(nas_user_t *user, emm_indication_callback_t cb, const c
/*
* Initialize EMM timers
*/
T3410.id = NAS_TIMER_INACTIVE_ID;
T3410.sec = T3410_DEFAULT_VALUE;
T3411.id = NAS_TIMER_INACTIVE_ID;
T3411.sec = T3411_DEFAULT_VALUE;
T3402.id = NAS_TIMER_INACTIVE_ID;
T3402.sec = T3402_DEFAULT_VALUE;
T3416.id = NAS_TIMER_INACTIVE_ID;
T3416.sec = T3416_DEFAULT_VALUE;
T3417.id = NAS_TIMER_INACTIVE_ID;
T3417.sec = T3417_DEFAULT_VALUE;
T3418.id = NAS_TIMER_INACTIVE_ID;
T3418.sec = T3418_DEFAULT_VALUE;
T3420.id = NAS_TIMER_INACTIVE_ID;
T3420.sec = T3420_DEFAULT_VALUE;
T3421.id = NAS_TIMER_INACTIVE_ID;
T3421.sec = T3421_DEFAULT_VALUE;
T3423.id = NAS_TIMER_INACTIVE_ID;
T3423.sec = T3423_DEFAULT_VALUE;
T3430.id = NAS_TIMER_INACTIVE_ID;
T3430.sec = T3430_DEFAULT_VALUE;
user->emm_data->emm_timers = calloc(1, sizeof(emm_timers_t));
if ( user->emm_data->emm_timers == NULL ) {
LOG_TRACE(ERROR, "EMM-MAIN - Failed to alloc emm_timers");
// FIXME stop here
}
_emm_timers_initialize(user->emm_data->emm_timers);
/*
* Initialize the user notification callback
......@@ -389,7 +401,6 @@ void emm_main_initialize(nas_user_t *user, emm_indication_callback_t cb, const c
/*
* Initialize EMM internal data used for UE in idle mode
*/
// FIXME REVIEW
IdleMode_initialize(user, &_emm_main_callback);
LOG_FUNC_OUT;
......
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