diff options
author | Jouni Malinen <j@w1.fi> | 2012-01-22 21:33:57 +0200 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2012-01-22 21:54:24 +0200 |
commit | e6c62749476612eede63ceb4c0d79c7fd8e27772 (patch) | |
tree | f8192d8cafafbf0309e6ef29ad0cbd58e3fd6cad /src | |
parent | a3e0105692d4efdafcf50bf438e5aa140217bea1 (diff) | |
download | external_wpa_supplicant_8_ti-e6c62749476612eede63ceb4c0d79c7fd8e27772.zip external_wpa_supplicant_8_ti-e6c62749476612eede63ceb4c0d79c7fd8e27772.tar.gz external_wpa_supplicant_8_ti-e6c62749476612eede63ceb4c0d79c7fd8e27772.tar.bz2 |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/eap_peer/eap.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/eap_peer/eap.c b/src/eap_peer/eap.c index 50ac98f..b1db6cd 100644 --- a/src/eap_peer/eap.c +++ b/src/eap_peer/eap.c @@ -879,6 +879,26 @@ static void eap_sm_processIdentity(struct eap_sm *sm, const struct wpabuf *req) #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, 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_len = scard_get_mnc_len(sm->scard_ctx); + if (mnc_len < 0) + mnc_len = mnc_len_from_imsi(imsi); if (mnc_len < 0) { wpa_printf(MSG_INFO, "Failed to get MNC length from (U)SIM " "assuming 3"); |