Commit 0083673e authored by Frédéric Leroy's avatar Frédéric Leroy

refactor(conf2uedata): make plmns_list struct for managing plmns

parent 47d4cf65
...@@ -12,18 +12,13 @@ ...@@ -12,18 +12,13 @@
#include "conf_user_data.h" #include "conf_user_data.h"
#include "conf_usim.h" #include "conf_usim.h"
int *ucplmn = NULL; plmns_list ucplmns;
int *oplmn = NULL; plmns_list oplmns;
int *ocplmn = NULL; plmns_list ocplmns;
int *fplmn = NULL; plmns_list fplmns;
int *ehplmn = NULL; plmns_list ehplmns;
int plmn_nb = 0; int plmn_nb = 0;
int ucplmn_nb = 0;
int oplmn_nb = 0;
int ocplmn_nb = 0;
int fplmn_nb = 0;
int ehplmn_nb = 0;
plmn_conf_param_t* user_plmn_list=NULL; plmn_conf_param_t* user_plmn_list=NULL;
network_record_t* user_network_record_list = NULL; network_record_t* user_network_record_list = NULL;
...@@ -241,15 +236,15 @@ int parse_ue_plmn_param(config_setting_t *ue_setting, int user_id, const char ** ...@@ -241,15 +236,15 @@ int parse_ue_plmn_param(config_setting_t *ue_setting, int user_id, const char **
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if ( parse_Xplmn(ue_setting, UCPLMN, user_id, &ucplmn_nb, &ucplmn) == EXIT_FAILURE ) if ( parse_Xplmn(ue_setting, UCPLMN, user_id, &ucplmns) == EXIT_FAILURE )
nb_errors++; nb_errors++;
if ( parse_Xplmn(ue_setting, OPLMN, user_id, &oplmn_nb, &oplmn) == EXIT_FAILURE ) if ( parse_Xplmn(ue_setting, OPLMN, user_id, &oplmns) == EXIT_FAILURE )
nb_errors++; nb_errors++;
if ( parse_Xplmn(ue_setting, OCPLMN, user_id, &ocplmn_nb, &ocplmn) == EXIT_FAILURE ) if ( parse_Xplmn(ue_setting, OCPLMN, user_id, &ocplmns) == EXIT_FAILURE )
nb_errors++; nb_errors++;
if ( parse_Xplmn(ue_setting, FPLMN, user_id, &fplmn_nb, &fplmn) == EXIT_FAILURE ) if ( parse_Xplmn(ue_setting, FPLMN, user_id, &fplmns) == EXIT_FAILURE )
nb_errors++; nb_errors++;
if ( parse_Xplmn(ue_setting, EHPLMN, user_id, &ehplmn_nb, &ehplmn) == EXIT_FAILURE ) if ( parse_Xplmn(ue_setting, EHPLMN, user_id, &ehplmns) == EXIT_FAILURE )
nb_errors++; nb_errors++;
if ( nb_errors > 0 ) if ( nb_errors > 0 )
...@@ -258,7 +253,7 @@ int parse_ue_plmn_param(config_setting_t *ue_setting, int user_id, const char ** ...@@ -258,7 +253,7 @@ int parse_ue_plmn_param(config_setting_t *ue_setting, int user_id, const char **
} }
int parse_Xplmn(config_setting_t *ue_setting, const char *section, int parse_Xplmn(config_setting_t *ue_setting, const char *section,
int user_id, int *plmns_count, int **plmns ) { int user_id, plmns_list *plmns) {
int rc; int rc;
int item_count; int item_count;
config_setting_t *setting; config_setting_t *setting;
...@@ -286,8 +281,8 @@ int parse_Xplmn(config_setting_t *ue_setting, const char *section, ...@@ -286,8 +281,8 @@ int parse_Xplmn(config_setting_t *ue_setting, const char *section,
datas[i] = rc; datas[i] = rc;
} }
*plmns_count = item_count; plmns->size = item_count;
*plmns = datas; plmns->items = datas;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
......
...@@ -43,18 +43,18 @@ typedef struct { ...@@ -43,18 +43,18 @@ typedef struct {
const char *mcc; const char *mcc;
} plmn_conf_param_t; } plmn_conf_param_t;
extern int *ucplmn; typedef struct {
extern int *oplmn; int size;
extern int *ocplmn; int *items;
extern int *fplmn; } plmns_list;
extern int *ehplmn;
extern plmns_list ucplmns;
extern plmns_list oplmns;
extern plmns_list ocplmns;
extern plmns_list fplmns;
extern plmns_list ehplmns;
extern int plmn_nb; extern int plmn_nb;
extern int ucplmn_nb;
extern int oplmn_nb;
extern int ocplmn_nb;
extern int fplmn_nb;
extern int ehplmn_nb;
extern plmn_conf_param_t* user_plmn_list; extern plmn_conf_param_t* user_plmn_list;
extern network_record_t* user_network_record_list; extern network_record_t* user_network_record_list;
...@@ -70,7 +70,7 @@ int parse_plmns(config_setting_t *all_plmn_setting); ...@@ -70,7 +70,7 @@ int parse_plmns(config_setting_t *all_plmn_setting);
int get_plmn_index(const char * mccmnc); int get_plmn_index(const char * mccmnc);
int parse_ue_plmn_param(config_setting_t *ue_setting, int user_id, const char **hplmn); int parse_ue_plmn_param(config_setting_t *ue_setting, int user_id, const char **hplmn);
int parse_Xplmn(config_setting_t *ue_setting, const char *section, int parse_Xplmn(config_setting_t *ue_setting, const char *section,
int user_id, int *plmns_count, int **plmns ); int user_id, plmns_list *plmns);
#endif // _CONF2UEDATA_H #endif // _CONF2UEDATA_H
...@@ -53,7 +53,7 @@ void gen_emm_data(emm_nvdata_t *emm_data, const char *hplmn, const char *msin) { ...@@ -53,7 +53,7 @@ void gen_emm_data(emm_nvdata_t *emm_data, const char *hplmn, const char *msin) {
emm_data->rplmn.MNCdigit1 = user_plmn_list[hplmn_index].mnc[0]; emm_data->rplmn.MNCdigit1 = user_plmn_list[hplmn_index].mnc[0];
emm_data->rplmn.MNCdigit2 = user_plmn_list[hplmn_index].mnc[1]; emm_data->rplmn.MNCdigit2 = user_plmn_list[hplmn_index].mnc[1];
emm_data->eplmn.n_plmns = ehplmn_nb; emm_data->eplmn.n_plmns = ehplmns.size;
} }
int write_emm_data(const char *directory, int user_id, emm_nvdata_t *emm_data) { int write_emm_data(const char *directory, int user_id, emm_nvdata_t *emm_data) {
......
...@@ -96,9 +96,9 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) { ...@@ -96,9 +96,9 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) {
for (int i = 0; i < USIM_FPLMN_MAX; i++) { for (int i = 0; i < USIM_FPLMN_MAX; i++) {
memset(&usim_data->fplmn[i], 0xff, sizeof(plmn_t)); memset(&usim_data->fplmn[i], 0xff, sizeof(plmn_t));
} }
if (fplmn_nb > 0) { if (fplmns.size > 0) {
for (int i = 0; i < fplmn_nb; i++) { for (int i = 0; i < fplmns.size; i++) {
usim_data->fplmn[i] = user_network_record_list[fplmn[i]].plmn; usim_data->fplmn[i] = user_network_record_list[fplmns.items[i]].plmn;
} }
} }
...@@ -183,8 +183,8 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) { ...@@ -183,8 +183,8 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) {
/* /*
* PLMN Network Name and Operator PLMN List * PLMN Network Name and Operator PLMN List
*/ */
for (int i = 0; i < oplmn_nb; i++) { for (int i = 0; i < oplmns.size; i++) {
network_record_t record = user_network_record_list[oplmn[i]]; network_record_t record = user_network_record_list[oplmns.items[i]];
usim_data->pnn[i].fullname.type = USIM_PNN_FULLNAME_TAG; usim_data->pnn[i].fullname.type = USIM_PNN_FULLNAME_TAG;
usim_data->pnn[i].fullname.length = strlen(record.fullname); usim_data->pnn[i].fullname.length = strlen(record.fullname);
strncpy((char*) usim_data->pnn[i].fullname.value, record.fullname, strncpy((char*) usim_data->pnn[i].fullname.value, record.fullname,
...@@ -198,8 +198,8 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) { ...@@ -198,8 +198,8 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) {
usim_data->opl[i].end = record.tac_end; usim_data->opl[i].end = record.tac_end;
usim_data->opl[i].record_id = i; usim_data->opl[i].record_id = i;
} }
if (oplmn_nb < USIM_OPL_MAX) { if (oplmns.size < USIM_OPL_MAX) {
for (int i = oplmn_nb; i < USIM_OPL_MAX; i++) { for (int i = oplmns.size; i < USIM_OPL_MAX; i++) {
memset(&usim_data->opl[i].plmn, 0xff, sizeof(plmn_t)); memset(&usim_data->opl[i].plmn, 0xff, sizeof(plmn_t));
} }
} }
...@@ -207,11 +207,11 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) { ...@@ -207,11 +207,11 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) {
/* /*
* List of Equivalent HPLMNs * List of Equivalent HPLMNs
*/ */
for (int i = 0; i < ehplmn_nb; i++) { for (int i = 0; i < ehplmns.size; i++) {
usim_data->ehplmn[i] = user_network_record_list[ehplmn[i]].plmn; usim_data->ehplmn[i] = user_network_record_list[ehplmns.items[i]].plmn;
} }
if (ehplmn_nb < USIM_EHPLMN_MAX) { if (ehplmns.size < USIM_EHPLMN_MAX) {
for (int i = ehplmn_nb; i < USIM_EHPLMN_MAX; i++) { for (int i = ehplmns.size; i < USIM_EHPLMN_MAX; i++) {
memset(&usim_data->ehplmn[i], 0xff, sizeof(plmn_t)); memset(&usim_data->ehplmn[i], 0xff, sizeof(plmn_t));
} }
} }
...@@ -227,9 +227,9 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) { ...@@ -227,9 +227,9 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) {
for (int i = 0; i < USIM_PLMN_MAX; i++) { for (int i = 0; i < USIM_PLMN_MAX; i++) {
memset(&usim_data->plmn[i], 0xff, sizeof(plmn_t)); memset(&usim_data->plmn[i], 0xff, sizeof(plmn_t));
} }
if (ucplmn_nb > 0) { if (ucplmns.size > 0) {
for (int i = 0; i < ucplmn_nb; i++) { for (int i = 0; i < ucplmns.size; i++) {
usim_data->plmn[i].plmn = user_network_record_list[ucplmn[i]].plmn; usim_data->plmn[i].plmn = user_network_record_list[ucplmns.items[i]].plmn;
} }
} }
...@@ -238,9 +238,9 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) { ...@@ -238,9 +238,9 @@ void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) {
for (int i = 0; i < USIM_OPLMN_MAX; i++) { for (int i = 0; i < USIM_OPLMN_MAX; i++) {
memset(&usim_data->oplmn[i], 0xff, sizeof(plmn_t)); memset(&usim_data->oplmn[i], 0xff, sizeof(plmn_t));
} }
if (ocplmn_nb > 0) { if (ocplmns.size > 0) {
for (int i = 0; i < ocplmn_nb; i++) { for (int i = 0; i < ocplmns.size; i++) {
usim_data->oplmn[i].plmn = user_network_record_list[ocplmn[i]].plmn; usim_data->oplmn[i].plmn = user_network_record_list[ocplmns.items[i]].plmn;
usim_data->oplmn[i].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN usim_data->oplmn[i].AcT = (USIM_ACT_GSM | USIM_ACT_UTRAN
| USIM_ACT_EUTRAN); | USIM_ACT_EUTRAN);
} }
......
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