]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
moved eap_from_string() fomr libcharon to libstrongswan to make it available in starter
authorAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 13 Aug 2010 13:07:53 +0000 (15:07 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 13 Aug 2010 13:07:53 +0000 (15:07 +0200)
src/libcharon/sa/authenticators/eap/eap_method.c
src/libcharon/sa/authenticators/eap/eap_method.h
src/libstrongswan/credentials/auth_cfg.c
src/libstrongswan/credentials/auth_cfg.h
src/starter/confread.c

index 45c7a8ca6f972c15ec981083c776bd6edee877b2..892e97bd995cca510736f6c29476412bd5d7d7a2 100644 (file)
 
 #include "eap_method.h"
 
-/*
- * See header
- */
-eap_type_t eap_type_from_string(char *name)
-{
-       int i;
-       static struct {
-               char *name;
-               eap_type_t type;
-       } types[] = {
-               {"identity",    EAP_IDENTITY},
-               {"md5",                 EAP_MD5},
-               {"otp",                 EAP_OTP},
-               {"gtc",                 EAP_GTC},
-               {"tls",                 EAP_TLS},
-               {"ttls",                EAP_TTLS},
-               {"sim",                 EAP_SIM},
-               {"aka",                 EAP_AKA},
-               {"mschapv2",    EAP_MSCHAPV2},
-               {"radius",              EAP_RADIUS},
-       };
-
-       for (i = 0; i < countof(types); i++)
-       {
-               if (strcaseeq(name, types[i].name))
-               {
-                       return types[i].type;
-               }
-       }
-       return 0;
-}
-
 ENUM(eap_code_names, EAP_REQUEST, EAP_FAILURE,
        "EAP_REQUEST",
        "EAP_RESPONSE",
@@ -66,6 +34,3 @@ ENUM(eap_role_names, EAP_SERVER, EAP_PEER,
        "EAP_PEER",
 );
 
-
-
-
index df354edb4434f1da494bfa292918a50e36d54b75..91b419b2c31755099c7818cf0579781d23942413 100644 (file)
@@ -41,14 +41,6 @@ enum eap_role_t {
  */
 extern enum_name_t *eap_role_names;
 
-/**
- * Lookup the EAP method type from a string.
- *
- * @param name         EAP method name (such as "md5", "aka")
- * @return                     method type, 0 if unkown
- */
-eap_type_t eap_type_from_string(char *name);
-
 /**
  * EAP code, type of an EAP message
  */
index 9b3078f06cd31b8ac77111c35b7926a9c35b2b09..01a574fe79eee60f67e54aeb91e4018fb88fa298 100644 (file)
@@ -93,6 +93,38 @@ ENUM(auth_rule_names, AUTH_RULE_IDENTITY, AUTH_HELPER_SUBJECT_HASH_URL,
        "HELPER_SUBJECT_HASH_URL",
 );
 
+/*
+ * See header
+ */
+eap_type_t eap_type_from_string(char *name)
+{
+       int i;
+       static struct {
+               char *name;
+               eap_type_t type;
+       } types[] = {
+               {"identity",    EAP_IDENTITY},
+               {"md5",                 EAP_MD5},
+               {"otp",                 EAP_OTP},
+               {"gtc",                 EAP_GTC},
+               {"tls",                 EAP_TLS},
+               {"ttls",                EAP_TTLS},
+               {"sim",                 EAP_SIM},
+               {"aka",                 EAP_AKA},
+               {"mschapv2",    EAP_MSCHAPV2},
+               {"radius",              EAP_RADIUS},
+       };
+
+       for (i = 0; i < countof(types); i++)
+       {
+               if (strcaseeq(name, types[i].name))
+               {
+                       return types[i].type;
+               }
+       }
+       return 0;
+}
+
 typedef struct private_auth_cfg_t private_auth_cfg_t;
 
 /**
index 29c6634b8e1c89b112e815b41aa4d4ade68a93ab..60c8403cd2bc3e308d715557e116e908aa32e3e8 100644 (file)
@@ -81,6 +81,14 @@ extern enum_name_t *eap_type_names;
  */
 extern enum_name_t *eap_type_short_names;
 
+/**
+ * Lookup the EAP method type from a string.
+ *
+ * @param name         EAP method name (such as "md5", "aka")
+ * @return                     method type, 0 if unkown
+ */
+eap_type_t eap_type_from_string(char *name);
+
 /**
  * Authentication config to use during authentication process.
  *
index b0ee8b389a1db40b3fd41d0f835fd977bca31f37..379c2b4774b7b0bb1a0303d2468c500de0a90172 100644 (file)
@@ -671,39 +671,8 @@ static void load_conn(starter_conn_t *conn, kw_list_t *kw, starter_config_t *cfg
                                }
                                break;
                        }
-                       if (streq(kw->value, "aka"))
-                       {
-                               conn->eap_type = 23;
-                       }
-                       else if (streq(kw->value, "sim"))
-                       {
-                               conn->eap_type = 18;
-                       }
-                       else if (streq(kw->value, "md5"))
-                       {
-                               conn->eap_type = 4;
-                       }
-                       else if (streq(kw->value, "gtc"))
-                       {
-                               conn->eap_type = 6;
-                       }
-                       else if (streq(kw->value, "tls"))
-                       {
-                               conn->eap_type = 13;
-                       }
-                       else if (streq(kw->value, "ttls"))
-                       {
-                               conn->eap_type = 21;
-                       }
-                       else if (streq(kw->value, "mschapv2"))
-                       {
-                               conn->eap_type = 26;
-                       }
-                       else if (streq(kw->value, "radius"))
-                       {       /* pseudo-type */
-                               conn->eap_type = 253;
-                       }
-                       else
+                       conn->eap_type = eap_type_from_string(kw->value);
+                       if (conn->eap_type == 0)
                        {
                                conn->eap_type = atoi(kw->value);
                                if (conn->eap_type == 0)