Commit d72294b9 authored by Cedric Roux's avatar Cedric Roux

fix gen_emm_data

It was not setting emm_data->eplmn.plmn[X], only emm_data->eplmn.n_plmns,
leading to the UE to dig for PLMN 00000.

(It's not the end of the story, seems like the PLMN selection
does not work, the UE only tries one from what I've seen, but
I didn't dig much, may be wrong.)
parent ea6fb5c4
......@@ -4,56 +4,65 @@
#include "conf_emm.h"
#include "fs.h"
void gen_emm_data(emm_nvdata_t *emm_data, const char *hplmn, const char *msin, int ehplmn_count, const networks_t networks) {
memset(emm_data, 0, sizeof(emm_nvdata_t));
int hplmn_index = get_plmn_index(hplmn, networks);
plmn_conf_param_t *conf = &networks.items[hplmn_index].conf;
emm_data->imsi.length = 8;
emm_data->imsi.u.num.parity = get_msin_parity(msin, conf->mcc, conf->mnc);
emm_data->imsi.u.num.digit1 = conf->mcc[0];
emm_data->imsi.u.num.digit2 = conf->mcc[1];
emm_data->imsi.u.num.digit3 = conf->mcc[2];
void gen_emm_data(
emm_nvdata_t *emm_data,
const char *hplmn,
const char *msin,
const plmns_list *eplmn,
const networks_t networks)
{
memset(emm_data, 0, sizeof(emm_nvdata_t));
int hplmn_index = get_plmn_index(hplmn, networks);
plmn_conf_param_t *conf = &networks.items[hplmn_index].conf;
int i;
emm_data->imsi.u.num.digit4 = conf->mnc[0];
emm_data->imsi.u.num.digit5 = conf->mnc[1];
emm_data->imsi.length = 8;
emm_data->imsi.u.num.parity = get_msin_parity(msin, conf->mcc, conf->mnc);
emm_data->imsi.u.num.digit1 = conf->mcc[0];
emm_data->imsi.u.num.digit2 = conf->mcc[1];
emm_data->imsi.u.num.digit3 = conf->mcc[2];
if (strlen(conf->mnc) == 3) {
emm_data->rplmn.MNCdigit3 = conf->mnc[2];
emm_data->imsi.u.num.digit4 = conf->mnc[0];
emm_data->imsi.u.num.digit5 = conf->mnc[1];
emm_data->imsi.u.num.digit6 = conf->mnc[2];
emm_data->imsi.u.num.digit7 = msin[0];
emm_data->imsi.u.num.digit8 = msin[1];
emm_data->imsi.u.num.digit9 = msin[2];
emm_data->imsi.u.num.digit10 = msin[3];
emm_data->imsi.u.num.digit11 = msin[4];
emm_data->imsi.u.num.digit12 = msin[5];
emm_data->imsi.u.num.digit13 = msin[6];
emm_data->imsi.u.num.digit14 = msin[7];
emm_data->imsi.u.num.digit15 = msin[8];
if (strlen(conf->mnc) == 3) {
emm_data->rplmn.MNCdigit3 = conf->mnc[2];
} else {
emm_data->rplmn.MNCdigit3 = 0xf;
emm_data->imsi.u.num.digit6 = conf->mnc[2];
emm_data->imsi.u.num.digit7 = msin[0];
emm_data->imsi.u.num.digit8 = msin[1];
emm_data->imsi.u.num.digit9 = msin[2];
emm_data->imsi.u.num.digit10 = msin[3];
emm_data->imsi.u.num.digit11 = msin[4];
emm_data->imsi.u.num.digit12 = msin[5];
emm_data->imsi.u.num.digit13 = msin[6];
emm_data->imsi.u.num.digit14 = msin[7];
emm_data->imsi.u.num.digit15 = msin[8];
} else {
emm_data->rplmn.MNCdigit3 = 0xf;
emm_data->imsi.u.num.digit6 = msin[0];
emm_data->imsi.u.num.digit7 = msin[1];
emm_data->imsi.u.num.digit8 = msin[2];
emm_data->imsi.u.num.digit9 = msin[3];
emm_data->imsi.u.num.digit10 = msin[4];
emm_data->imsi.u.num.digit11 = msin[5];
emm_data->imsi.u.num.digit12 = msin[6];
emm_data->imsi.u.num.digit13 = msin[7];
emm_data->imsi.u.num.digit14 = msin[8];
emm_data->imsi.u.num.digit15 = msin[9];
emm_data->imsi.u.num.digit6 = msin[0];
emm_data->imsi.u.num.digit7 = msin[1];
emm_data->imsi.u.num.digit8 = msin[2];
emm_data->imsi.u.num.digit9 = msin[3];
emm_data->imsi.u.num.digit10 = msin[4];
emm_data->imsi.u.num.digit11 = msin[5];
emm_data->imsi.u.num.digit12 = msin[6];
emm_data->imsi.u.num.digit13 = msin[7];
emm_data->imsi.u.num.digit14 = msin[8];
emm_data->imsi.u.num.digit15 = msin[9];
}
}
emm_data->rplmn.MCCdigit1 = conf->mcc[0];
emm_data->rplmn.MCCdigit2 = conf->mcc[1];
emm_data->rplmn.MCCdigit3 = conf->mcc[2];
emm_data->rplmn.MNCdigit1 = conf->mnc[0];
emm_data->rplmn.MNCdigit2 = conf->mnc[1];
emm_data->rplmn.MCCdigit1 = conf->mcc[0];
emm_data->rplmn.MCCdigit2 = conf->mcc[1];
emm_data->rplmn.MCCdigit3 = conf->mcc[2];
emm_data->rplmn.MNCdigit1 = conf->mnc[0];
emm_data->rplmn.MNCdigit2 = conf->mnc[1];
emm_data->eplmn.n_plmns = ehplmn_count;
emm_data->eplmn.n_plmns = eplmn->size;
for (i = 0; i < eplmn->size; i++) {
emm_data->eplmn.plmn[i] = networks.items[eplmn->items[i]].plmn;
}
}
bool write_emm_data(const char *directory, int user_id, emm_nvdata_t *emm_data) {
......
......@@ -3,8 +3,15 @@
#include "emmData.h"
#include "conf_network.h"
#include "conf_user_plmn.h"
void gen_emm_data(
emm_nvdata_t *emm_data,
const char *hplmn,
const char *msin,
const plmns_list *eplmn,
const networks_t networks);
void gen_emm_data(emm_nvdata_t *emm_data, const char *hplmn, const char *msin, int ehplmn_count, const networks_t networks);
bool write_emm_data(const char *directory, int user_id, emm_nvdata_t *emm_data);
int get_msin_parity(const char * msin, const char *mcc, const char *mnc);
......
......@@ -74,7 +74,7 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou
gen_usim_data(&usim_data_conf, &usim_data, &user_plmns, networks);
gen_emm_data(&emm_data, usim_data_conf.hplmn, usim_data_conf.msin,
user_plmns.equivalents_home.size, networks);
&user_plmns.equivalents_home, networks);
if ( output_flags & OUTPUT_UEDATA ) {
write_user_data(output_dir, i, &user_data);
......
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