From 7e414b21c2af7c96c11a5ecf4e153e8e46efaa29 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 4 Sep 2012 16:50:52 +0300 Subject: [PATCH] Interworking: Allow EAP-SIM/AKA/AKA' override in cred block The eap parameter in the cred block can now be used to override automatic EAP-SIM/AKA/AKA' selection. Signed-hostap: Jouni Malinen --- wpa_supplicant/interworking.c | 41 ++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c index bbcfe4df5..8cf9244b0 100644 --- a/wpa_supplicant/interworking.c +++ b/wpa_supplicant/interworking.c @@ -736,6 +736,9 @@ static int interworking_connect_3gpp(struct wpa_supplicant *wpa_s, struct wpa_cred *cred; struct wpa_ssid *ssid; const u8 *ie; + int eap_type; + int res; + char prefix; if (bss->anqp == NULL || bss->anqp->anqp_3gpp == NULL) return -1; @@ -797,14 +800,40 @@ static int interworking_connect_3gpp(struct wpa_supplicant *wpa_s, if (interworking_set_hs20_params(ssid) < 0) goto fail; - /* TODO: figure out whether to use EAP-SIM, EAP-AKA, or EAP-AKA' */ - if (wpa_config_set(ssid, "eap", "SIM", 0) < 0) { - wpa_printf(MSG_DEBUG, "EAP-SIM not supported"); + eap_type = EAP_TYPE_SIM; + if (cred->pcsc && wpa_s->scard && scard_supports_umts(wpa_s->scard)) + eap_type = EAP_TYPE_AKA; + if (cred->eap_method && cred->eap_method[0].vendor == EAP_VENDOR_IETF) { + if (cred->eap_method[0].method == EAP_TYPE_SIM || + cred->eap_method[0].method == EAP_TYPE_AKA || + cred->eap_method[0].method == EAP_TYPE_AKA_PRIME) + eap_type = cred->eap_method[0].method; + } + + switch (eap_type) { + case EAP_TYPE_SIM: + prefix = '1'; + res = wpa_config_set(ssid, "eap", "SIM", 0); + break; + case EAP_TYPE_AKA: + prefix = '0'; + res = wpa_config_set(ssid, "eap", "AKA", 0); + break; + case EAP_TYPE_AKA_PRIME: + prefix = '6'; + res = wpa_config_set(ssid, "eap", "AKA'", 0); + break; + default: + res = -1; + break; + } + if (res < 0) { + wpa_printf(MSG_DEBUG, "Selected EAP method (%d) not supported", + eap_type); goto fail; } - if (cred->pcsc && wpa_s->scard && scard_supports_umts(wpa_s->scard)) - wpa_config_set(ssid, "eap", "AKA", 0); - if (!cred->pcsc && set_root_nai(ssid, cred->imsi, '1') < 0) { + + if (!cred->pcsc && set_root_nai(ssid, cred->imsi, prefix) < 0) { wpa_printf(MSG_DEBUG, "Failed to set Root NAI"); goto fail; }