Commit 289f1ea9 authored by Frédéric Leroy's avatar Frédéric Leroy

UE/EMM: move _emm_detach_data to emm_data_t

parent 46438c7c
...@@ -85,20 +85,6 @@ void *_emm_detach_t3421_handler(void *); ...@@ -85,20 +85,6 @@ void *_emm_detach_t3421_handler(void *);
*/ */
static int _emm_detach_abort(nas_user_t *user, emm_proc_detach_type_t type); static int _emm_detach_abort(nas_user_t *user, emm_proc_detach_type_t type);
/*
* Internal data used for detach procedure
*/
static struct {
#define EMM_DETACH_COUNTER_MAX 5
unsigned int count; /* Counter used to limit the number of
* subsequently detach attempts */
int switch_off; /* UE switch-off indicator */
emm_proc_detach_type_t type; /* Type of the detach procedure
* currently in progress */
} _emm_detach_data = {0, FALSE, EMM_DETACH_TYPE_RESERVED};
/****************************************************************************/ /****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/ /****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/ /****************************************************************************/
...@@ -128,7 +114,6 @@ static struct { ...@@ -128,7 +114,6 @@ static struct {
** ** ** **
** Outputs: None ** ** Outputs: None **
** Return: RETURNok, RETURNerror ** ** Return: RETURNok, RETURNerror **
** Others: _emm_detach_data **
** ** ** **
***************************************************************************/ ***************************************************************************/
int emm_proc_detach(nas_user_t *user, emm_proc_detach_type_t type, int switch_off) int emm_proc_detach(nas_user_t *user, emm_proc_detach_type_t type, int switch_off)
...@@ -137,15 +122,16 @@ int emm_proc_detach(nas_user_t *user, emm_proc_detach_type_t type, int switch_of ...@@ -137,15 +122,16 @@ int emm_proc_detach(nas_user_t *user, emm_proc_detach_type_t type, int switch_of
emm_sap_t emm_sap; emm_sap_t emm_sap;
emm_as_data_t *emm_as = &emm_sap.u.emm_as.u.data; emm_as_data_t *emm_as = &emm_sap.u.emm_as.u.data;
emm_detach_data_t *emm_detach_data = user->emm_data->emm_detach_data;
int rc; int rc;
LOG_TRACE(INFO, "EMM-PROC - Initiate EPS detach type = %s (%d)", LOG_TRACE(INFO, "EMM-PROC - Initiate EPS detach type = %s (%d)",
_emm_detach_type_str[type], type); _emm_detach_type_str[type], type);
/* Initialize the detach procedure internal data */ /* Initialize the detach procedure internal data */
_emm_detach_data.count = 0; emm_detach_data->count = 0;
_emm_detach_data.switch_off = switch_off; emm_detach_data->switch_off = switch_off;
_emm_detach_data.type = type; emm_detach_data->type = type;
/* Setup EMM procedure handler to be executed upon receiving /* Setup EMM procedure handler to be executed upon receiving
* lower layer notification */ * lower layer notification */
...@@ -202,12 +188,13 @@ int emm_proc_detach_request(void *args) ...@@ -202,12 +188,13 @@ int emm_proc_detach_request(void *args)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
nas_user_t *user=args; nas_user_t *user = args;
emm_timers_t *emm_timers = user->emm_data->emm_timers; emm_timers_t *emm_timers = user->emm_data->emm_timers;
emm_detach_data_t *emm_detach_data = user->emm_data->emm_detach_data;
emm_sap_t emm_sap; emm_sap_t emm_sap;
int rc; int rc;
if ( !_emm_detach_data.switch_off ) { if ( !emm_detach_data->switch_off ) {
/* Start T3421 timer */ /* Start T3421 timer */
emm_timers->T3421.id = nas_timer_start(emm_timers->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", LOG_TRACE(INFO, "EMM-PROC - Timer T3421 (%d) expires in %ld seconds",
...@@ -289,7 +276,6 @@ int emm_proc_detach_accept(void* args) ...@@ -289,7 +276,6 @@ int emm_proc_detach_accept(void* args)
** ** ** **
** Inputs: is_initial: Not used ** ** Inputs: is_initial: Not used **
** args: Not used ** ** args: Not used **
** Others: _emm_detach_data **
** ** ** **
** Outputs: None ** ** Outputs: None **
** Return: RETURNok, RETURNerror ** ** Return: RETURNok, RETURNerror **
...@@ -300,7 +286,8 @@ int emm_proc_detach_failure(int is_initial, void *args) ...@@ -300,7 +286,8 @@ int emm_proc_detach_failure(int is_initial, void *args)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
nas_user_t *user=args; nas_user_t *user = args;
emm_detach_data_t *emm_detach_data = user->emm_data->emm_detach_data;
emm_timers_t *emm_timers = user->emm_data->emm_timers; emm_timers_t *emm_timers = user->emm_data->emm_timers;
emm_sap_t emm_sap; emm_sap_t emm_sap;
int rc; int rc;
...@@ -317,7 +304,7 @@ int emm_proc_detach_failure(int is_initial, void *args) ...@@ -317,7 +304,7 @@ int emm_proc_detach_failure(int is_initial, void *args)
* Notify EMM that detach procedure has to be restarted * Notify EMM that detach procedure has to be restarted
*/ */
emm_sap.primitive = EMMREG_DETACH_INIT; emm_sap.primitive = EMMREG_DETACH_INIT;
emm_sap.u.emm_reg.u.detach.switch_off = _emm_detach_data.switch_off; emm_sap.u.emm_reg.u.detach.switch_off = emm_detach_data->switch_off;
rc = emm_sap_send(user, &emm_sap); rc = emm_sap_send(user, &emm_sap);
LOG_FUNC_RETURN(rc); LOG_FUNC_RETURN(rc);
...@@ -335,7 +322,6 @@ int emm_proc_detach_failure(int is_initial, void *args) ...@@ -335,7 +322,6 @@ int emm_proc_detach_failure(int is_initial, void *args)
** The detach procedure shall be aborted. ** ** The detach procedure shall be aborted. **
** ** ** **
** Inputs: args: not used ** ** Inputs: args: not used **
** Others: _emm_detach_data **
** ** ** **
** Outputs: None ** ** Outputs: None **
** Return: RETURNok, RETURNerror ** ** Return: RETURNok, RETURNerror **
...@@ -348,9 +334,10 @@ int emm_proc_detach_release(void *args) ...@@ -348,9 +334,10 @@ int emm_proc_detach_release(void *args)
LOG_TRACE(WARNING, "EMM-PROC - NAS signalling connection released"); LOG_TRACE(WARNING, "EMM-PROC - NAS signalling connection released");
nas_user_t *user=args; nas_user_t *user = args;
emm_detach_data_t *emm_detach_data = user->emm_data->emm_detach_data;
/* Abort the detach procedure */ /* Abort the detach procedure */
int rc = _emm_detach_abort(user, _emm_detach_data.type); int rc = _emm_detach_abort(user, emm_detach_data->type);
LOG_FUNC_RETURN(rc); LOG_FUNC_RETURN(rc);
} }
...@@ -379,7 +366,6 @@ int emm_proc_detach_release(void *args) ...@@ -379,7 +366,6 @@ int emm_proc_detach_release(void *args)
** the detach procedure shall be aborted. ** ** the detach procedure shall be aborted. **
** ** ** **
** Inputs: args: handler parameters ** ** Inputs: args: handler parameters **
** Others: _emm_detach_data **
** ** ** **
** Outputs: None ** ** Outputs: None **
** Return: None ** ** Return: None **
...@@ -390,17 +376,18 @@ void *_emm_detach_t3421_handler(void *args) ...@@ -390,17 +376,18 @@ void *_emm_detach_t3421_handler(void *args)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
nas_user_t *user=args; nas_user_t *user = args;
emm_detach_data_t *emm_detach_data = user->emm_data->emm_detach_data;
emm_timers_t *emm_timers = user->emm_data->emm_timers; emm_timers_t *emm_timers = user->emm_data->emm_timers;
int rc; int rc;
/* Increment the retransmission counter */ /* Increment the retransmission counter */
_emm_detach_data.count += 1; emm_detach_data->count += 1;
LOG_TRACE(WARNING, "EMM-PROC - T3421 timer expired, " LOG_TRACE(WARNING, "EMM-PROC - T3421 timer expired, "
"retransmission counter = %d", _emm_detach_data.count); "retransmission counter = %d", emm_detach_data->count);
if (_emm_detach_data.count < EMM_DETACH_COUNTER_MAX) { if (emm_detach_data->count < EMM_DETACH_COUNTER_MAX) {
/* Retransmit the Detach Request message */ /* Retransmit the Detach Request message */
emm_sap_t emm_sap; emm_sap_t emm_sap;
emm_as_data_t *emm_as = &emm_sap.u.emm_as.u.data; emm_as_data_t *emm_as = &emm_sap.u.emm_as.u.data;
...@@ -413,9 +400,9 @@ void *_emm_detach_t3421_handler(void *args) ...@@ -413,9 +400,9 @@ void *_emm_detach_t3421_handler(void *args)
emm_as->NASmsg.length = 0; emm_as->NASmsg.length = 0;
emm_as->NASmsg.value = NULL; emm_as->NASmsg.value = NULL;
/* Set the detach type */ /* Set the detach type */
emm_as->type = _emm_detach_data.type; emm_as->type = emm_detach_data->type;
/* 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 = user->emm_data->guti; emm_as->guti = user->emm_data->guti;
emm_as->ueid = 0; emm_as->ueid = 0;
...@@ -438,7 +425,7 @@ void *_emm_detach_t3421_handler(void *args) ...@@ -438,7 +425,7 @@ void *_emm_detach_t3421_handler(void *args)
} }
} else { } else {
/* Abort the detach procedure */ /* Abort the detach procedure */
rc = _emm_detach_abort(user, _emm_detach_data.type); rc = _emm_detach_abort(user, emm_detach_data->type);
} }
LOG_FUNC_RETURN(NULL); LOG_FUNC_RETURN(NULL);
...@@ -457,7 +444,6 @@ void *_emm_detach_t3421_handler(void *args) ...@@ -457,7 +444,6 @@ void *_emm_detach_t3421_handler(void *args)
** Description: Aborts the detach procedure ** ** Description: Aborts the detach procedure **
** ** ** **
** Inputs: type: not used ** ** Inputs: type: not used **
** Others: _emm_detach_data **
** ** ** **
** Outputs: None ** ** Outputs: None **
** Return: RETURNok, RETURNerror ** ** Return: RETURNok, RETURNerror **
......
...@@ -47,6 +47,7 @@ Description Defines internal private data handled by EPS Mobility ...@@ -47,6 +47,7 @@ Description Defines internal private data handled by EPS Mobility
#include "nas_timer.h" #include "nas_timer.h"
#include "esmData.h" #include "esmData.h"
#include "emm_proc_defs.h"
...@@ -93,6 +94,18 @@ Description Defines internal private data handled by EPS Mobility ...@@ -93,6 +94,18 @@ Description Defines internal private data handled by EPS Mobility
/************************ G L O B A L T Y P E S ************************/ /************************ G L O B A L T Y P E S ************************/
/****************************************************************************/ /****************************************************************************/
/*
* Internal data used for detach procedure
*/
typedef struct {
#define EMM_DETACH_COUNTER_MAX 5
unsigned int count; /* Counter used to limit the number of
* subsequently detach attempts */
int switch_off; /* UE switch-off indicator */
emm_proc_detach_type_t type; /* Type of the detach procedure
* currently in progress */
} emm_detach_data_t;
/* /*
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* EPS NAS security context handled by EPS Mobility Management sublayer in * EPS NAS security context handled by EPS Mobility Management sublayer in
...@@ -343,6 +356,7 @@ typedef struct emm_data_s { ...@@ -343,6 +356,7 @@ typedef struct emm_data_s {
* ---------------------------------------- * ----------------------------------------
*/ */
emm_timers_t *emm_timers; emm_timers_t *emm_timers;
emm_detach_data_t *emm_detach_data;
} emm_data_t; } emm_data_t;
......
...@@ -41,6 +41,7 @@ Description Defines the EPS Mobility Management procedure call manager, ...@@ -41,6 +41,7 @@ Description Defines the EPS Mobility Management procedure call manager,
#include "nas_log.h" #include "nas_log.h"
#include "emmData.h" #include "emmData.h"
#include "MobileIdentity.h" #include "MobileIdentity.h"
#include "emm_proc_defs.h"
#include "memory.h" #include "memory.h"
#include "usim_api.h" #include "usim_api.h"
...@@ -105,6 +106,12 @@ void _emm_timers_initialize(emm_timers_t *emm_timers) { ...@@ -105,6 +106,12 @@ void _emm_timers_initialize(emm_timers_t *emm_timers) {
emm_timers->T3430.sec = T3430_DEFAULT_VALUE; emm_timers->T3430.sec = T3430_DEFAULT_VALUE;
} }
void _emm_detach_initialize(emm_detach_data_t *emm_detach) {
emm_detach->count = 0;
emm_detach->switch_off = FALSE;
emm_detach->type = EMM_DETACH_TYPE_RESERVED;
}
/**************************************************************************** /****************************************************************************
** ** ** **
** Name: emm_main_initialize() ** ** Name: emm_main_initialize() **
...@@ -393,6 +400,16 @@ void emm_main_initialize(nas_user_t *user, emm_indication_callback_t cb, const c ...@@ -393,6 +400,16 @@ void emm_main_initialize(nas_user_t *user, emm_indication_callback_t cb, const c
} }
_emm_timers_initialize(user->emm_data->emm_timers); _emm_timers_initialize(user->emm_data->emm_timers);
/*
* Initialize Internal data used for detach procedure
*/
user->emm_data->emm_detach_data = calloc(1, sizeof(emm_detach_data_t));
if ( user->emm_data->emm_detach_data == NULL ) {
LOG_TRACE(ERROR, "EMM-MAIN - Failed to alloc emm_timers");
// FIXME stop here
}
_emm_detach_initialize(user->emm_data->emm_detach_data);
/* /*
* Initialize the user notification callback * Initialize the user notification callback
*/ */
......
...@@ -48,33 +48,6 @@ Description Defines the EPS Mobility Management procedures executed at ...@@ -48,33 +48,6 @@ Description Defines the EPS Mobility Management procedures executed at
/********************* G L O B A L C O N S T A N T S *******************/ /********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/ /****************************************************************************/
/* Type of network attachment */
typedef enum {
EMM_ATTACH_TYPE_EPS = 0,
EMM_ATTACH_TYPE_IMSI,
EMM_ATTACH_TYPE_EMERGENCY,
EMM_ATTACH_TYPE_RESERVED,
} emm_proc_attach_type_t;
/* Type of network detach */
typedef enum {
EMM_DETACH_TYPE_EPS = 0,
EMM_DETACH_TYPE_IMSI,
EMM_DETACH_TYPE_EPS_IMSI,
EMM_DETACH_TYPE_REATTACH,
EMM_DETACH_TYPE_NOT_REATTACH,
EMM_DETACH_TYPE_RESERVED,
} emm_proc_detach_type_t;
/* Type of requested identity */
typedef enum {
EMM_IDENT_TYPE_NOT_AVAILABLE = 0,
EMM_IDENT_TYPE_IMSI,
EMM_IDENT_TYPE_IMEI,
EMM_IDENT_TYPE_IMEISV,
EMM_IDENT_TYPE_TMSI
} emm_proc_identity_type_t;
/****************************************************************************/ /****************************************************************************/
/************************ G L O B A L T Y P E S ************************/ /************************ G L O B A L T Y P E S ************************/
/****************************************************************************/ /****************************************************************************/
......
#ifndef _EMM_PROC_DEFS_H
#define _EMM_PROC_DEFS_H
/* Type of network attachment */
typedef enum {
EMM_ATTACH_TYPE_EPS = 0,
EMM_ATTACH_TYPE_IMSI,
EMM_ATTACH_TYPE_EMERGENCY,
EMM_ATTACH_TYPE_RESERVED,
} emm_proc_attach_type_t;
/* Type of network detach */
typedef enum {
EMM_DETACH_TYPE_EPS = 0,
EMM_DETACH_TYPE_IMSI,
EMM_DETACH_TYPE_EPS_IMSI,
EMM_DETACH_TYPE_REATTACH,
EMM_DETACH_TYPE_NOT_REATTACH,
EMM_DETACH_TYPE_RESERVED,
} emm_proc_detach_type_t;
/* Type of requested identity */
typedef enum {
EMM_IDENT_TYPE_NOT_AVAILABLE = 0,
EMM_IDENT_TYPE_IMSI,
EMM_IDENT_TYPE_IMEI,
EMM_IDENT_TYPE_IMEISV,
EMM_IDENT_TYPE_TMSI
} emm_proc_identity_type_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