]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Interworking: Allow EAP-SIM/AKA/AKA' override in cred block
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 4 Sep 2012 13:50:52 +0000 (16:50 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 4 Sep 2012 13:50:52 +0000 (16:50 +0300)
The eap parameter in the cred block can now be used to override
automatic EAP-SIM/AKA/AKA' selection.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

wpa_supplicant/interworking.c

index bbcfe4df5c5e17267d9d04f46268a72bfbdf4292..8cf9244b08fe348d95c53312e7a5da46511b0571 100644 (file)
@@ -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;
        }