aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/interworking.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-08-26 17:52:19 (GMT)
committerJouni Malinen <j@w1.fi>2012-08-26 20:35:04 (GMT)
commit632c9458c484cc2b662879bb16e2d5571f78cf09 (patch)
tree66a2b8263ab5c9703a5ae0152cab69ac0cda3f74 /wpa_supplicant/interworking.c
parent8f234012814b6343f7c3032aad802e0f48774f9c (diff)
downloadhostap-632c9458c484cc2b662879bb16e2d5571f78cf09.zip
hostap-632c9458c484cc2b662879bb16e2d5571f78cf09.tar.gz
hostap-632c9458c484cc2b662879bb16e2d5571f78cf09.tar.bz2
Interworking: Fix home SP check with real SIM card
The NAI building routine assumed that the credential included the IMSI, but that is not the case when using a real SIM card. Build the NAI based on the IMSI read for the card in such a case. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/interworking.c')
-rw-r--r--wpa_supplicant/interworking.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c
index a649ea9..29ff809 100644
--- a/wpa_supplicant/interworking.c
+++ b/wpa_supplicant/interworking.c
@@ -563,7 +563,7 @@ static int plmn_id_match(struct wpabuf *anqp, const char *imsi, int mnc_len)
static int build_root_nai(char *nai, size_t nai_len, const char *imsi,
- char prefix)
+ size_t mnc_len, char prefix)
{
const char *sep, *msin;
char *end, *pos;
@@ -581,12 +581,16 @@ static int build_root_nai(char *nai, size_t nai_len, const char *imsi,
return -1;
}
sep = os_strchr(imsi, '-');
- if (sep == NULL)
+ if (sep) {
+ plmn_len = sep - imsi;
+ msin = sep + 1;
+ } else if (mnc_len && os_strlen(imsi) >= 3 + mnc_len) {
+ plmn_len = 3 + mnc_len;
+ msin = imsi + plmn_len;
+ } else
return -1;
- plmn_len = sep - imsi;
if (plmn_len != 5 && plmn_len != 6)
return -1;
- msin = sep + 1;
msin_len = os_strlen(msin);
pos = nai;
@@ -617,7 +621,7 @@ static int build_root_nai(char *nai, size_t nai_len, const char *imsi,
static int set_root_nai(struct wpa_ssid *ssid, const char *imsi, char prefix)
{
char nai[100];
- if (build_root_nai(nai, sizeof(nai), imsi, prefix) < 0)
+ if (build_root_nai(nai, sizeof(nai), imsi, 0, prefix) < 0)
return -1;
return wpa_config_set_quoted(ssid, "identity", nai);
}
@@ -1311,8 +1315,17 @@ static int interworking_home_sp(struct wpa_supplicant *wpa_s,
for (cred = wpa_s->conf->cred; cred; cred = cred->next) {
#ifdef INTERWORKING_3GPP
- if (cred->imsi &&
- build_root_nai(nai, sizeof(nai), cred->imsi, 0) == 0) {
+ char *imsi = NULL;
+ int mnc_len = 0;
+ if (cred->imsi)
+ imsi = cred->imsi;
+ else if (cred->pcsc && wpa_s->conf->pcsc_reader &&
+ wpa_s->scard && wpa_s->imsi[0]) {
+ imsi = wpa_s->imsi;
+ mnc_len = wpa_s->mnc_len;
+ }
+ if (imsi && build_root_nai(nai, sizeof(nai), imsi, mnc_len, 0)
+ == 0) {
realm = os_strchr(nai, '@');
if (realm)
realm++;