Commit 8998c5d6 authored by Frédéric Leroy's avatar Frédéric Leroy

fix(conf2uedata): make hplmn_index a local variable

There was a side effect corrupting data because hplmn_index was not computed.
parent 930ba96a
......@@ -18,7 +18,6 @@ int *ocplmn = NULL;
int *fplmn = NULL;
int *ehplmn = NULL;
int hplmn_index = 0;
int plmn_nb = 0;
int ucplmn_nb = 0;
int oplmn_nb = 0;
......
......@@ -49,7 +49,6 @@ extern int *ocplmn;
extern int *fplmn;
extern int *ehplmn;
extern int hplmn_index;
extern int plmn_nb;
extern int ucplmn_nb;
extern int oplmn_nb;
......
......@@ -6,11 +6,10 @@
#include "fs.h"
void gen_emm_data(emm_nvdata_t *emm_data, const char *hplmn, const char *msin) {
hplmn_index = get_plmn_index(hplmn);
memset(emm_data, 0, sizeof(emm_nvdata_t));
int hplmn_index = get_plmn_index(hplmn);
emm_data->imsi.length = 8;
emm_data->imsi.u.num.parity = get_msin_parity(msin);
emm_data->imsi.u.num.parity = get_msin_parity(msin, user_plmn_list[hplmn_index].mcc, user_plmn_list[hplmn_index].mnc);
emm_data->imsi.u.num.digit1 = user_plmn_list[hplmn_index].mcc[0];
emm_data->imsi.u.num.digit2 = user_plmn_list[hplmn_index].mcc[1];
emm_data->imsi.u.num.digit3 = user_plmn_list[hplmn_index].mcc[2];
......@@ -69,9 +68,9 @@ int write_emm_data(const char *directory, int user_id, emm_nvdata_t *emm_data) {
return(EXIT_SUCCESS);
}
int get_msin_parity(const char * msin) {
int imsi_size = strlen(msin) + strlen(user_plmn_list[hplmn_index].mcc)
+ strlen(user_plmn_list[hplmn_index].mnc);
int get_msin_parity(const char * msin, const char *mcc, const char *mnc) {
int imsi_size = strlen(msin) + strlen(mcc)
+ strlen(mnc);
int result = (imsi_size % 2 == 0) ? 0 : 1;
return result;
......
......@@ -5,6 +5,6 @@
void gen_emm_data(emm_nvdata_t *emm_data, const char *hplmn, const char *msin);
int write_emm_data(const char *directory, int user_id, emm_nvdata_t *emm_data);
int get_msin_parity(const char * msin);
int get_msin_parity(const char * msin, const char *mcc, const char *mnc);
#endif
......@@ -41,9 +41,12 @@ int parse_ue_sim_param(config_setting_t *ue_setting, int user_id, usim_data_conf
}
void gen_usim_data(usim_data_conf_t *u, usim_data_t *usim_data) {
int hplmn_index = get_plmn_index(u->hplmn);
memset(usim_data, 0, sizeof(usim_data_t));
usim_data->imsi.length = 8;
usim_data->imsi.u.num.parity = get_msin_parity(u->msin);
usim_data->imsi.u.num.parity = get_msin_parity(u->msin,
user_plmn_list[hplmn_index].mcc,
user_plmn_list[hplmn_index].mnc);
usim_data->imsi.u.num.digit1 = user_plmn_list[hplmn_index].mcc[0];
usim_data->imsi.u.num.digit2 = user_plmn_list[hplmn_index].mcc[1];
......
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