Add preliminary MNC length determination based on IMSI
Some SIM cards do not include MNC length with in EF_AD. Try to figure out the MNC length based on the MCC/MNC values in the beginning of the IMSI. This covers a prepaid Elisa/Kolumbus card that would have ended up using incorrect MNC length based on the 3-digit default. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
a3e0105692
commit
e6c6274947
1 changed files with 22 additions and 0 deletions
|
@ -879,6 +879,26 @@ static void eap_sm_processIdentity(struct eap_sm *sm, const struct wpabuf *req)
|
||||||
|
|
||||||
#ifdef PCSC_FUNCS
|
#ifdef PCSC_FUNCS
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Rules for figuring out MNC length based on IMSI for SIM cards that do not
|
||||||
|
* include MNC length field.
|
||||||
|
*/
|
||||||
|
static int mnc_len_from_imsi(const char *imsi)
|
||||||
|
{
|
||||||
|
char mcc_str[4];
|
||||||
|
unsigned int mcc;
|
||||||
|
|
||||||
|
os_memcpy(mcc_str, imsi, 3);
|
||||||
|
mcc_str[3] = '\0';
|
||||||
|
mcc = atoi(mcc_str);
|
||||||
|
|
||||||
|
if (mcc == 244)
|
||||||
|
return 2; /* Networks in Finland use 2-digit MNC */
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int eap_sm_append_3gpp_realm(struct eap_sm *sm, char *imsi,
|
static int eap_sm_append_3gpp_realm(struct eap_sm *sm, char *imsi,
|
||||||
size_t max_len, size_t *imsi_len)
|
size_t max_len, size_t *imsi_len)
|
||||||
{
|
{
|
||||||
|
@ -892,6 +912,8 @@ static int eap_sm_append_3gpp_realm(struct eap_sm *sm, char *imsi,
|
||||||
|
|
||||||
/* MNC (2 or 3 digits) */
|
/* MNC (2 or 3 digits) */
|
||||||
mnc_len = scard_get_mnc_len(sm->scard_ctx);
|
mnc_len = scard_get_mnc_len(sm->scard_ctx);
|
||||||
|
if (mnc_len < 0)
|
||||||
|
mnc_len = mnc_len_from_imsi(imsi);
|
||||||
if (mnc_len < 0) {
|
if (mnc_len < 0) {
|
||||||
wpa_printf(MSG_INFO, "Failed to get MNC length from (U)SIM "
|
wpa_printf(MSG_INFO, "Failed to get MNC length from (U)SIM "
|
||||||
"assuming 3");
|
"assuming 3");
|
||||||
|
|
Loading…
Reference in a new issue