Commit 7340b5e0 authored by Frédéric Leroy's avatar Frédéric Leroy

UE/EMM: move _plmn_list to nas_user_t

parent 2d7f557a
This diff is collapsed.
......@@ -63,21 +63,21 @@ typedef int (*IdleMode_callback_t) (emm_data_t *emm_data, int);
void IdleMode_initialize(nas_user_t *user, IdleMode_callback_t cb);
int IdleMode_get_nb_plmns(void);
int IdleMode_get_hplmn_index(void);
int IdleMode_get_rplmn_index(void);
int IdleMode_get_splmn_index(void);
int IdleMode_get_nb_plmns(emm_plmn_list_t *emm_plmn_list);
int IdleMode_get_hplmn_index(emm_plmn_list_t *emm_plmn_list);
int IdleMode_get_rplmn_index(emm_plmn_list_t *emm_plmn_list);
int IdleMode_get_splmn_index(emm_plmn_list_t *emm_plmn_list);
int IdleMode_update_plmn_list(emm_data_t *emm_data, int i);
int IdleMode_update_plmn_list(emm_plmn_list_t *emm_plmn_list, emm_data_t *emm_data, int i);
const char *IdleMode_get_plmn_fullname(const plmn_t *plmn, int index,
const char *IdleMode_get_plmn_fullname(emm_plmn_list_t *emm_plmn_list, const plmn_t *plmn, int index,
size_t *len);
const char *IdleMode_get_plmn_shortname(const plmn_t *plmn, int index,
const char *IdleMode_get_plmn_shortname(emm_plmn_list_t *emm_plmn_list, const plmn_t *plmn, int index,
size_t *len);
const char *IdleMode_get_plmn_id(const plmn_t *plmn, int index, size_t *len);
const char *IdleMode_get_plmn_id(emm_plmn_list_t *emm_plmn_list, const plmn_t *plmn, int index, size_t *len);
int IdleMode_get_plmn_fullname_index(const char *plmn);
int IdleMode_get_plmn_shortname_index(const char *plmn);
int IdleMode_get_plmn_id_index(const char *plmn);
int IdleMode_get_plmn_fullname_index(emm_plmn_list_t *emm_plmn_list, const char *plmn);
int IdleMode_get_plmn_shortname_index(emm_plmn_list_t *emm_plmn_list, const char *plmn);
int IdleMode_get_plmn_id_index(emm_plmn_list_t *emm_plmn_list, const char *plmn);
#endif /* __IDLEMODE_H__*/
#ifndef _IDLEMODE_DEFS_H
#define _IDLEMODE_DEFS_H
/*
* A list of PLMN identities in priority order is maintained locally
* to perform the PLMN selection procedure.
*
* In automatic mode of operation, this list is used for PLMN selection when
* the UE is switched on, or upon recovery from lack of coverage, or when the
* user requests the UE to initiate PLMN reselection, and registration.
* In manual mode of operation, this list is displayed to the user that may
* select an available PLMN and initiate registration.
*
* The list may contain PLMN identifiers in the following order:
* - The last registered PLMN or each equivalent PLMN present in the list of
* "equivalent PLMNs" (EPLMN_MAX), when UE is switched on or following
* recovery from lack of coverage;
* - The highest priority PLMN in the list of "equivalent HPLMNs" or the
* HPLMN derived from the IMSI (1)
* - Each PLMN/access technology combination in the "User Controlled PLMN
* Selector with Access Technology" (PLMN_MAX)
* - Each PLMN/access technology combination in the "Operator Controlled PLMN
* Selector with Access Technology" (OPLMN_MAX)
* - Other PLMN/access technology combinations with received high quality
* signal in random order (TODO)
* - Other PLMN/access technology combinations in order of decreasing signal
* quality (TODO)
* - The last selected PLMN again (1)
*/
typedef struct {
int n_plmns;
#define EMM_PLMN_LIST_SIZE (EMM_DATA_EPLMN_MAX + EMM_DATA_PLMN_MAX + \
EMM_DATA_OPLMN_MAX + 2)
plmn_t *plmn[EMM_PLMN_LIST_SIZE];
int index; /* Index of the PLMN for which selection is ongoing */
int hplmn; /* Index of the home PLMN or the highest priority
* equivalent home PLMN */
int fplmn; /* Index of the first forbidden PLMN */
int splmn; /* Index of the currently selected PLMN */
int rplmn; /* Index of the currently registered PLMN */
struct plmn_param_t {
char fullname[NET_FORMAT_LONG_SIZE+1]; /* PLMN full identifier */
char shortname[NET_FORMAT_SHORT_SIZE+1]; /* PLMN short identifier */
char num[NET_FORMAT_NUM_SIZE+1]; /* PLMN numeric identifier */
int stat; /* Indication of the PLMN availability */
int tac; /* Location/Tracking Area Code */
int ci; /* Serving cell identifier */
int rat; /* Radio Access Technology supported by the serving cell */
} param[EMM_PLMN_LIST_SIZE];
} emm_plmn_list_t;
#endif
......@@ -63,10 +63,10 @@ static int _emm_main_get_imei(imei_t *imei, const char *imei_str);
static int _emm_main_imsi_cmp(imsi_t *imsi1, imsi_t *imsi2);
static const char *_emm_main_get_plmn(const plmn_t *plmn, int index,
static const char *_emm_main_get_plmn(emm_plmn_list_t *emm_plmn_list, const plmn_t *plmn, int index,
int format, size_t *size);
static int _emm_main_get_plmn_index(const char *plmn, int format);
static int _emm_main_get_plmn_index(emm_plmn_list_t *emm_plmn_list, const char *plmn, int format);
/*
* USIM application data
......@@ -538,12 +538,14 @@ const msisdn_t *emm_main_get_msisdn(void)
** Others: user->emm_data-> **
** **
***************************************************************************/
int emm_main_set_plmn_selection_mode(emm_data_t *emm_data, int mode, int format,
int emm_main_set_plmn_selection_mode(nas_user_t *user, int mode, int format,
const network_plmn_t *plmn, int rat)
{
LOG_FUNC_IN;
int index;
emm_data_t *emm_data = user->emm_data;
emm_plmn_list_t *emm_plmn_list = user->emm_plmn_list;
LOG_TRACE(INFO, "EMM-MAIN - PLMN selection: mode=%d, format=%d, plmn=%s, "
"rat=%d", mode, format, (const char *)&plmn->id, rat);
......@@ -552,7 +554,7 @@ int emm_main_set_plmn_selection_mode(emm_data_t *emm_data, int mode, int format,
if (mode != EMM_DATA_PLMN_AUTO) {
/* Get the index of the PLMN in the list of available PLMNs */
index = _emm_main_get_plmn_index((const char *)&plmn->id, format);
index = _emm_main_get_plmn_index(emm_plmn_list, (const char *)&plmn->id, format);
if (index < 0) {
LOG_TRACE(WARNING, "EMM-MAIN - PLMN %s not available",
......@@ -568,7 +570,7 @@ int emm_main_set_plmn_selection_mode(emm_data_t *emm_data, int mode, int format,
* register to when switched on; the equivalent PLMNs list shall not be
* applied to the user reselection in Automatic Network Selection Mode.
*/
index = IdleMode_get_hplmn_index();
index = IdleMode_get_hplmn_index(emm_plmn_list);
}
LOG_FUNC_RETURN (index);
......@@ -609,11 +611,11 @@ int emm_main_get_plmn_selection_mode(emm_data_t *emm_data)
** Others: None **
** **
***************************************************************************/
int emm_main_get_plmn_list(emm_data_t *emm_data, const char **plist)
int emm_main_get_plmn_list(emm_plmn_list_t *emm_plmn_list, emm_data_t *emm_data, const char **plist)
{
LOG_FUNC_IN;
int size = IdleMode_update_plmn_list(emm_data, 0);
int size = IdleMode_update_plmn_list(emm_plmn_list, emm_data, 0);
*plist = emm_data->plist.buffer;
LOG_FUNC_RETURN (size);
......@@ -635,7 +637,7 @@ int emm_main_get_plmn_list(emm_data_t *emm_data, const char **plist)
** Others: None **
** **
***************************************************************************/
const char *emm_main_get_selected_plmn(emm_data_t *emm_data, network_plmn_t *plmn, int format)
const char *emm_main_get_selected_plmn(emm_plmn_list_t *emm_plmn_list, emm_data_t *emm_data, network_plmn_t *plmn, int format)
{
LOG_FUNC_IN;
......@@ -643,10 +645,10 @@ const char *emm_main_get_selected_plmn(emm_data_t *emm_data, network_plmn_t *plm
/*
* Get the identifier of the selected PLMN in the list of available PLMNs
*/
int index = IdleMode_get_splmn_index();
int index = IdleMode_get_splmn_index(emm_plmn_list);
if ( !(index < 0) ) {
const char *name = _emm_main_get_plmn(&emm_data->splmn, index,
const char *name = _emm_main_get_plmn(emm_plmn_list, &emm_data->splmn, index,
format, &size);
if (size > 0) {
......@@ -673,7 +675,7 @@ const char *emm_main_get_selected_plmn(emm_data_t *emm_data, network_plmn_t *plm
** Others: None **
** **
***************************************************************************/
const char *emm_main_get_registered_plmn(emm_data_t *emm_data, network_plmn_t *plmn, int format)
const char *emm_main_get_registered_plmn(emm_plmn_list_t *emm_plmn_list, emm_data_t *emm_data, network_plmn_t *plmn, int format)
{
LOG_FUNC_IN;
......@@ -682,10 +684,10 @@ const char *emm_main_get_registered_plmn(emm_data_t *emm_data, network_plmn_t *p
/*
* Get the identifier of the registered PLMN in the list of available PLMNs
*/
int index = IdleMode_get_rplmn_index();
int index = IdleMode_get_rplmn_index(emm_plmn_list);
if ( !(index < 0) ) {
const char *name = _emm_main_get_plmn(&emm_data->nvdata.rplmn,
const char *name = _emm_main_get_plmn(emm_plmn_list, &emm_data->nvdata.rplmn,
index, format, &size);
if (size > 0) {
......@@ -952,24 +954,24 @@ static int _emm_main_imsi_cmp(imsi_t *imsi1, imsi_t *imsi2)
** Others: None **
** **
***************************************************************************/
static const char *_emm_main_get_plmn(const plmn_t *plmn, int index,
static const char *_emm_main_get_plmn(emm_plmn_list_t *emm_plmn_list, const plmn_t *plmn, int index,
int format, size_t *size)
{
if ( PLMN_IS_VALID(*plmn) ) {
switch (format) {
case NET_FORMAT_LONG:
/* Get the long alpha-numeric representation of the PLMN */
return IdleMode_get_plmn_fullname(plmn, index, size);
return IdleMode_get_plmn_fullname(emm_plmn_list, plmn, index, size);
break;
case NET_FORMAT_SHORT:
/* Get the short alpha-numeric representation of the PLMN */
return IdleMode_get_plmn_shortname(plmn, index, size);
return IdleMode_get_plmn_shortname(emm_plmn_list, plmn, index, size);
break;
case NET_FORMAT_NUM:
/* Get the numeric representation of the PLMN */
return IdleMode_get_plmn_id(plmn, index, size);
return IdleMode_get_plmn_id(emm_plmn_list, plmn, index, size);
break;
default:
......@@ -1002,24 +1004,24 @@ static const char *_emm_main_get_plmn(const plmn_t *plmn, int index,
** Others: None **
** **
***************************************************************************/
static int _emm_main_get_plmn_index(const char *plmn, int format)
static int _emm_main_get_plmn_index(emm_plmn_list_t *emm_plmn_list, const char *plmn, int format)
{
int index = -1;
switch (format) {
case NET_FORMAT_LONG:
/* Get the index of the long alpha-numeric PLMN identifier */
index = IdleMode_get_plmn_fullname_index(plmn);
index = IdleMode_get_plmn_fullname_index(emm_plmn_list, plmn);
break;
case NET_FORMAT_SHORT:
/* Get the index of the short alpha-numeric PLMN identifier */
index = IdleMode_get_plmn_shortname_index(plmn);
index = IdleMode_get_plmn_shortname_index(emm_plmn_list, plmn);
break;
case NET_FORMAT_NUM:
/* Get the index of the numeric PLMN identifier */
index = IdleMode_get_plmn_id_index(plmn);
index = IdleMode_get_plmn_id_index(emm_plmn_list, plmn);
break;
default:
......
......@@ -80,18 +80,18 @@ const imsi_t *emm_main_get_imsi(emm_data_t *emm_data);
const msisdn_t *emm_main_get_msisdn(void);
/* User's getter/setter for network selection */
int emm_main_set_plmn_selection_mode(emm_data_t *emm_data, int mode, int format,
int emm_main_set_plmn_selection_mode(nas_user_t *user, int mode, int format,
const network_plmn_t *plmn, int rat);
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);
int emm_main_get_plmn_list(emm_plmn_list_t *emm_plmn_list, emm_data_t *emm_data, const char **plist);
const char *emm_main_get_selected_plmn(emm_plmn_list_t *emm_plmn_list, emm_data_t *emm_data, network_plmn_t *plmn, int format);
/* User's getter for network registration */
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);
const char *emm_main_get_registered_plmn(emm_plmn_list_t *emm_plmn_list, emm_data_t *emm_data, network_plmn_t *plmn, int format);
/* User's getter for network attachment */
int emm_main_is_attached(emm_data_t *emm_data);
......
......@@ -185,6 +185,6 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi, in
*/
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);
int emm_proc_network_notify(emm_plmn_list_t *emm_plmn_list, emm_data_t *emm_data, int index);
#endif /* __EMM_PROC_H__*/
......@@ -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(user->emm_data, mode, format, oper, AcT);
int index = emm_main_set_plmn_selection_mode(user, mode, format, oper, AcT);
if ( !(index < 0) ) {
/*
......@@ -455,7 +455,7 @@ int nas_proc_get_reg_data(nas_user_t *user, int *mode, int *selected, int format
*mode = emm_main_get_plmn_selection_mode(user->emm_data);
/* Get the currently selected operator */
const char *oper_name = emm_main_get_selected_plmn(user->emm_data, oper, format);
const char *oper_name = emm_main_get_selected_plmn(user->emm_plmn_list, user->emm_data, oper, format);
if (oper_name != NULL) {
/* An operator is currently selected */
......@@ -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(user->emm_data, oper_list);
int size = emm_main_get_plmn_list(user->emm_plmn_list, user->emm_data, oper_list);
LOG_FUNC_RETURN (size);
}
......
......@@ -50,6 +50,7 @@ Description NAS type definition to manage a user equipment
#include "esm_pt_defs.h"
#include "EMM/emm_fsm_defs.h"
#include "EMM/emmData.h"
#include "EMM/IdleMode_defs.h"
typedef struct {
int fd;
......@@ -59,6 +60,7 @@ typedef struct {
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
emm_plmn_list_t *emm_plmn_list; // list of PLMN identities
} 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