]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
HS 2.0: Process Credential/UsernamePassword/EAPMethod nodes in PPS MO
authorJouni Malinen <jouni@codeaurora.org>
Thu, 21 Jun 2018 16:16:26 +0000 (19:16 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 21 Jun 2018 16:16:26 +0000 (19:16 +0300)
This allows hs20-osu-client to configure wpa_supplicant credential with
a specific EAP method so that roaming consortium OI -based matching can
be used.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
hs20/client/osu_client.c

index f0ba9ab7d289e32563298539b978a1a5d3996ccd..de70065456a840b611f5ecc3b32ef35f0b662d55 100644 (file)
@@ -1463,10 +1463,92 @@ static void set_pps_cred_able_to_share(struct hs20_osu_client *ctx, int id,
 }
 
 
+static void set_pps_cred_eap_method_eap_type(struct hs20_osu_client *ctx,
+                                            int id, xml_node_t *node)
+{
+       char *str = xml_node_get_text(ctx->xml, node);
+       int type;
+       const char *eap_method = NULL;
+
+       if (!str)
+               return;
+       wpa_printf(MSG_INFO,
+                  "- Credential/UsernamePassword/EAPMethod/EAPType = %s", str);
+       type = atoi(str);
+       switch (type) {
+       case EAP_TYPE_TLS:
+               eap_method = "TLS";
+               break;
+       case EAP_TYPE_TTLS:
+               eap_method = "TTLS";
+               break;
+       case EAP_TYPE_PEAP:
+               eap_method = "PEAP";
+               break;
+       case EAP_TYPE_PWD:
+               eap_method = "PWD";
+               break;
+       }
+       xml_node_get_text_free(ctx->xml, str);
+       if (!eap_method) {
+               wpa_printf(MSG_INFO, "Unknown EAPType value");
+               return;
+       }
+
+       if (set_cred(ctx->ifname, id, "eap", eap_method) < 0)
+               wpa_printf(MSG_INFO, "Failed to set cred eap");
+}
+
+
+static void set_pps_cred_eap_method_inner_method(struct hs20_osu_client *ctx,
+                                                int id, xml_node_t *node)
+{
+       char *str = xml_node_get_text(ctx->xml, node);
+       const char *phase2 = NULL;
+
+       if (!str)
+               return;
+       wpa_printf(MSG_INFO,
+                  "- Credential/UsernamePassword/EAPMethod/InnerMethod = %s",
+                  str);
+       if (os_strcmp(str, "PAP") == 0)
+               phase2 = "auth=PAP";
+       else if (os_strcmp(str, "CHAP") == 0)
+               phase2 = "auth=CHAP";
+       else if (os_strcmp(str, "MS-CHAP") == 0)
+               phase2 = "auth=MSCHAP";
+       else if (os_strcmp(str, "MS-CHAP-V2") == 0)
+               phase2 = "auth=MSCHAPV2";
+       xml_node_get_text_free(ctx->xml, str);
+       if (!phase2) {
+               wpa_printf(MSG_INFO, "Unknown InnerMethod value");
+               return;
+       }
+
+       if (set_cred_quoted(ctx->ifname, id, "phase2", phase2) < 0)
+               wpa_printf(MSG_INFO, "Failed to set cred phase2");
+}
+
+
 static void set_pps_cred_eap_method(struct hs20_osu_client *ctx, int id,
                                    xml_node_t *node)
 {
-       wpa_printf(MSG_INFO, "- Credential/UsernamePassword/EAPMethod - TODO");
+       xml_node_t *child;
+       const char *name;
+
+       wpa_printf(MSG_INFO, "- Credential/UsernamePassword/EAPMethod");
+
+       xml_node_for_each_child(ctx->xml, child, node) {
+               xml_node_for_each_check(ctx->xml, child);
+               name = xml_node_get_localname(ctx->xml, child);
+               if (os_strcasecmp(name, "EAPType") == 0)
+                       set_pps_cred_eap_method_eap_type(ctx, id, child);
+               else if (os_strcasecmp(name, "InnerMethod") == 0)
+                       set_pps_cred_eap_method_inner_method(ctx, id, child);
+               else
+                       wpa_printf(MSG_INFO, "Unknown Credential/UsernamePassword/EAPMethod node '%s'",
+                                  name);
+       }
 }