]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use a single define for maximum number of EAP methods
authorJouni Malinen <j@w1.fi>
Thu, 17 Nov 2011 18:06:33 +0000 (20:06 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 17 Nov 2011 18:06:33 +0000 (20:06 +0200)
This cleans up the code a bit by not having to deal with theoretical
possibility of maximum number of EAP methods to be different between
various components in hostapd.

Signed-hostap: Jouni Malinen <j@w1.fi>

hostapd/config_file.c
src/ap/ap_config.h
src/ap/authsrv.c
src/ap/ieee802_1x.c
src/common/defs.h
src/eap_server/eap.h

index 1bfd456f9e93dd0d66a37b52048cb401241f9276..6708244551dcbf6ee47b4ea7e1c7d886e1a62d9c 100644 (file)
@@ -330,7 +330,7 @@ static int hostapd_config_read_eap_user(const char *fname,
                        }
 
                        num_methods++;
-                       if (num_methods >= EAP_USER_MAX_METHODS)
+                       if (num_methods >= EAP_MAX_METHODS)
                                break;
                skip_eap:
                        if (pos3 == NULL)
index fe20fc2b31cdfb8ecb1b2132d68b04bb58e245de..32c829298b84c3e94cfb9cc8ae2ac336269f5d9f 100644 (file)
@@ -104,7 +104,6 @@ struct hostapd_wpa_psk {
        u8 addr[ETH_ALEN];
 };
 
-#define EAP_USER_MAX_METHODS 8
 struct hostapd_eap_user {
        struct hostapd_eap_user *next;
        u8 *identity;
@@ -112,7 +111,7 @@ struct hostapd_eap_user {
        struct {
                int vendor;
                u32 method;
-       } methods[EAP_USER_MAX_METHODS];
+       } methods[EAP_MAX_METHODS];
        u8 *password;
        size_t password_len;
        int phase2;
index 7c87fde4154b9f8436b40451626c84a04c7a1e8d..f0001c0944a4238683148d86125f099e2b08f404 100644 (file)
@@ -60,7 +60,7 @@ static int hostapd_radius_get_eap_user(void *ctx, const u8 *identity,
                                       struct eap_user *user)
 {
        const struct hostapd_eap_user *eap_user;
-       int i, count;
+       int i;
 
        eap_user = hostapd_get_eap_user(ctx, identity, identity_len, phase2);
        if (eap_user == NULL)
@@ -70,10 +70,7 @@ static int hostapd_radius_get_eap_user(void *ctx, const u8 *identity,
                return 0;
 
        os_memset(user, 0, sizeof(*user));
-       count = EAP_USER_MAX_METHODS;
-       if (count > EAP_MAX_METHODS)
-               count = EAP_MAX_METHODS;
-       for (i = 0; i < count; i++) {
+       for (i = 0; i < EAP_MAX_METHODS; i++) {
                user->methods[i].vendor = eap_user->methods[i].vendor;
                user->methods[i].method = eap_user->methods[i].method;
        }
index 41d2644e7870172dd28a4382aac6abf6934e0fa2..dc0c39af9fd461e2370ff7d82071973f3195b823 100644 (file)
@@ -1568,7 +1568,7 @@ static int ieee802_1x_get_eap_user(void *ctx, const u8 *identity,
 {
        struct hostapd_data *hapd = ctx;
        const struct hostapd_eap_user *eap_user;
-       int i, count;
+       int i;
 
        eap_user = hostapd_get_eap_user(hapd->conf, identity,
                                        identity_len, phase2);
@@ -1577,10 +1577,7 @@ static int ieee802_1x_get_eap_user(void *ctx, const u8 *identity,
 
        os_memset(user, 0, sizeof(*user));
        user->phase2 = phase2;
-       count = EAP_USER_MAX_METHODS;
-       if (count > EAP_MAX_METHODS)
-               count = EAP_MAX_METHODS;
-       for (i = 0; i < count; i++) {
+       for (i = 0; i < EAP_MAX_METHODS; i++) {
                user->methods[i].vendor = eap_user->methods[i].vendor;
                user->methods[i].method = eap_user->methods[i].method;
        }
index bfbb4b7a0af5f7a47783c555b7063c66c13305cc..f00cf3aedf40a9d80dccfd174f60bc87adcbc419 100644 (file)
@@ -281,4 +281,7 @@ enum wpa_ctrl_req_type {
        NUM_WPA_CTRL_REQS
 };
 
+/* Maximum number of EAP methods to store for EAP server user information */
+#define EAP_MAX_METHODS 8
+
 #endif /* DEFS_H */
index e1f500a5f25706730ffa459d8ad0e0ff12ce2909..d5f8f1d3ecd4a1700ca0f32491f4f90a50bb02f8 100644 (file)
@@ -22,8 +22,6 @@
 
 struct eap_sm;
 
-#define EAP_MAX_METHODS 8
-
 #define EAP_TTLS_AUTH_PAP 1
 #define EAP_TTLS_AUTH_CHAP 2
 #define EAP_TTLS_AUTH_MSCHAP 4