Remove src/crypto from default include path
[libeap.git] / hostapd / config.c
index c0381ea..d4ce227 100644 (file)
 #include <grp.h>
 #endif /* CONFIG_NATIVE_WINDOWS */
 
-#include "hostapd.h"
-#include "driver.h"
-#include "sha1.h"
-#include "eap_server/eap.h"
+#include "common.h"
+#include "crypto/sha1.h"
+#include "drivers/driver.h"
 #include "radius/radius_client.h"
-#include "wpa_common.h"
+#include "common/ieee802_11_defs.h"
+#include "common/wpa_common.h"
+#include "eap_common/eap_wsc_common.h"
+#include "eap_server/eap.h"
+#include "hostapd.h"
 #include "wpa.h"
 #include "uuid.h"
-#include "eap_common/eap_wsc_common.h"
+#include "sta_info.h"
+#include "config.h"
 
 
 #define MAX_STA_COUNT 2007
 
-extern struct wpa_driver_ops *hostapd_drivers[];
+extern struct wpa_driver_ops *wpa_drivers[];
 
 
 #ifndef CONFIG_NO_VLAN
@@ -189,28 +193,28 @@ static void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
        bss->assoc_sa_query_max_timeout = 1000;
        bss->assoc_sa_query_retry_timeout = 201;
 #endif /* CONFIG_IEEE80211W */
-#ifdef EAP_FAST
+#ifdef EAP_SERVER_FAST
         /* both anonymous and authenticated provisioning */
        bss->eap_fast_prov = 3;
        bss->pac_key_lifetime = 7 * 24 * 60 * 60;
        bss->pac_key_refresh_time = 1 * 24 * 60 * 60;
-#endif /* EAP_FAST */
+#endif /* EAP_SERVER_FAST */
 }
 
 
-static struct hostapd_config * hostapd_config_defaults(void)
+struct hostapd_config * hostapd_config_defaults(void)
 {
        struct hostapd_config *conf;
        struct hostapd_bss_config *bss;
        int i;
        const int aCWmin = 15, aCWmax = 1024;
-       const struct hostapd_wme_ac_params ac_bk =
+       const struct hostapd_wmm_ac_params ac_bk =
                { aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */
-       const struct hostapd_wme_ac_params ac_be =
+       const struct hostapd_wmm_ac_params ac_be =
                { aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */
-       const struct hostapd_wme_ac_params ac_vi = /* video traffic */
+       const struct hostapd_wmm_ac_params ac_vi = /* video traffic */
                { aCWmin >> 1, aCWmin, 2, 3000 / 32, 1 };
-       const struct hostapd_wme_ac_params ac_vo = /* voice traffic */
+       const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */
                { aCWmin >> 2, aCWmin >> 1, 2, 1500 / 32, 1 };
 
        conf = os_zalloc(sizeof(*conf));
@@ -224,7 +228,7 @@ static struct hostapd_config * hostapd_config_defaults(void)
        }
 
        /* set default driver based on configuration */
-       conf->driver = hostapd_drivers[0];
+       conf->driver = wpa_drivers[0];
        if (conf->driver == NULL) {
                wpa_printf(MSG_ERROR, "No driver wrappers registered!");
                os_free(conf);
@@ -253,10 +257,10 @@ static struct hostapd_config * hostapd_config_defaults(void)
        for (i = 0; i < NUM_TX_QUEUES; i++)
                conf->tx_queue[i].aifs = -1; /* use hw default */
 
-       conf->wme_ac_params[0] = ac_be;
-       conf->wme_ac_params[1] = ac_bk;
-       conf->wme_ac_params[2] = ac_vi;
-       conf->wme_ac_params[3] = ac_vo;
+       conf->wmm_ac_params[0] = ac_be;
+       conf->wmm_ac_params[1] = ac_bk;
+       conf->wmm_ac_params[2] = ac_vi;
+       conf->wmm_ac_params[3] = ac_vo;
 
 #ifdef CONFIG_IEEE80211N
        conf->ht_capab = HT_CAP_INFO_SMPS_DISABLED;
@@ -1170,14 +1174,14 @@ static int hostapd_config_tx_queue(struct hostapd_config *conf, char *name,
 }
 
 
-static int hostapd_config_wme_ac(struct hostapd_config *conf, char *name,
-                                  char *val)
+static int hostapd_config_wmm_ac(struct hostapd_config *conf, char *name,
+                                char *val)
 {
        int num, v;
        char *pos;
-       struct hostapd_wme_ac_params *ac;
+       struct hostapd_wmm_ac_params *ac;
 
-       /* skip 'wme_ac_' prefix */
+       /* skip 'wme_ac_' or 'wmm_ac_' prefix */
        pos = name + 7;
        if (os_strncmp(pos, "be_", 3) == 0) {
                num = 0;
@@ -1192,11 +1196,11 @@ static int hostapd_config_wme_ac(struct hostapd_config *conf, char *name,
                num = 3;
                pos += 3;
        } else {
-               wpa_printf(MSG_ERROR, "Unknown wme name '%s'", pos);
+               wpa_printf(MSG_ERROR, "Unknown WMM name '%s'", pos);
                return -1;
        }
 
-       ac = &conf->wme_ac_params[num];
+       ac = &conf->wmm_ac_params[num];
 
        if (os_strcmp(pos, "aifs") == 0) {
                v = atoi(val);
@@ -1225,7 +1229,7 @@ static int hostapd_config_wme_ac(struct hostapd_config *conf, char *name,
                        wpa_printf(MSG_ERROR, "Invalid txop value %d", v);
                        return -1;
                }
-               ac->txopLimit = v;
+               ac->txop_limit = v;
        } else if (os_strcmp(pos, "acm") == 0) {
                v = atoi(val);
                if (v < 0 || v > 1) {
@@ -1234,7 +1238,7 @@ static int hostapd_config_wme_ac(struct hostapd_config *conf, char *name,
                }
                ac->admission_control_mandatory = v;
        } else {
-               wpa_printf(MSG_ERROR, "Unknown wme_ac_ field '%s'", pos);
+               wpa_printf(MSG_ERROR, "Unknown wmm_ac_ field '%s'", pos);
                return -1;
        }
 
@@ -1456,13 +1460,13 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                } else if (os_strcmp(buf, "bridge") == 0) {
                        os_strlcpy(bss->bridge, pos, sizeof(bss->bridge));
                } else if (os_strcmp(buf, "driver") == 0) {
-                       int i;
+                       int j;
                        /* clear to get error below if setting is invalid */
                        conf->driver = NULL;
-                       for (i = 0; hostapd_drivers[i]; i++) {
-                               if (os_strcmp(pos, hostapd_drivers[i]->name) ==
-                                   0) {
-                                       conf->driver = hostapd_drivers[i];
+                       for (j = 0; wpa_drivers[j]; j++) {
+                               if (os_strcmp(pos, wpa_drivers[j]->name) == 0)
+                               {
+                                       conf->driver = wpa_drivers[j];
                                        break;
                                }
                        }
@@ -1573,7 +1577,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                } else if (os_strcmp(buf, "dh_file") == 0) {
                        os_free(bss->dh_file);
                        bss->dh_file = os_strdup(pos);
-#ifdef EAP_FAST
+#ifdef EAP_SERVER_FAST
                } else if (os_strcmp(buf, "pac_opaque_encr_key") == 0) {
                        os_free(bss->pac_opaque_encr_key);
                        bss->pac_opaque_encr_key = os_malloc(16);
@@ -1615,18 +1619,18 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                        bss->pac_key_lifetime = atoi(pos);
                } else if (os_strcmp(buf, "pac_key_refresh_time") == 0) {
                        bss->pac_key_refresh_time = atoi(pos);
-#endif /* EAP_FAST */
-#ifdef EAP_SIM
+#endif /* EAP_SERVER_FAST */
+#ifdef EAP_SERVER_SIM
                } else if (os_strcmp(buf, "eap_sim_db") == 0) {
                        os_free(bss->eap_sim_db);
                        bss->eap_sim_db = os_strdup(pos);
                } else if (os_strcmp(buf, "eap_sim_aka_result_ind") == 0) {
                        bss->eap_sim_aka_result_ind = atoi(pos);
-#endif /* EAP_SIM */
-#ifdef EAP_TNC
+#endif /* EAP_SERVER_SIM */
+#ifdef EAP_SERVER_TNC
                } else if (os_strcmp(buf, "tnc") == 0) {
                        bss->tnc = atoi(pos);
-#endif /* EAP_TNC */
+#endif /* EAP_SERVER_TNC */
 #endif /* EAP_SERVER */
                } else if (os_strcmp(buf, "eap_message") == 0) {
                        char *term;
@@ -1755,7 +1759,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                        bss->radius->retry_primary_interval = atoi(pos);
                } else if (os_strcmp(buf, "radius_acct_interim_interval") == 0)
                {
-                       bss->radius->acct_interim_interval = atoi(pos);
+                       bss->acct_interim_interval = atoi(pos);
 #endif /* CONFIG_NO_RADIUS */
                } else if (os_strcmp(buf, "auth_algs") == 0) {
                        bss->auth_algs = atoi(pos);
@@ -2064,12 +2068,6 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                        bss->ssid.vlan_tagged_interface = os_strdup(pos);
 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
 #endif /* CONFIG_NO_VLAN */
-               } else if (os_strcmp(buf, "passive_scan_interval") == 0) {
-                       conf->passive_scan_interval = atoi(pos);
-               } else if (os_strcmp(buf, "passive_scan_listen") == 0) {
-                       conf->passive_scan_listen = atoi(pos);
-               } else if (os_strcmp(buf, "passive_scan_mode") == 0) {
-                       conf->passive_scan_mode = atoi(pos);
                } else if (os_strcmp(buf, "ap_table_max_size") == 0) {
                        conf->ap_table_max_size = atoi(pos);
                } else if (os_strcmp(buf, "ap_table_expiration_time") == 0) {
@@ -2080,11 +2078,13 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                                           "queue item", line);
                                errors++;
                        }
-               } else if (os_strcmp(buf, "wme_enabled") == 0) {
-                       bss->wme_enabled = atoi(pos);
-               } else if (os_strncmp(buf, "wme_ac_", 7) == 0) {
-                       if (hostapd_config_wme_ac(conf, buf, pos)) {
-                               wpa_printf(MSG_ERROR, "Line %d: invalid wme "
+               } else if (os_strcmp(buf, "wme_enabled") == 0 ||
+                          os_strcmp(buf, "wmm_enabled") == 0) {
+                       bss->wmm_enabled = atoi(pos);
+               } else if (os_strncmp(buf, "wme_ac_", 7) == 0 ||
+                          os_strncmp(buf, "wmm_ac_", 7) == 0) {
+                       if (hostapd_config_wmm_ac(conf, buf, pos)) {
+                               wpa_printf(MSG_ERROR, "Line %d: invalid WMM "
                                           "ac item", line);
                                errors++;
                        }
@@ -2095,13 +2095,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                                errors++;
                        }
                } else if (os_strcmp(buf, "bssid") == 0) {
-                       if (bss == conf->bss &&
-                           (!conf->driver || !conf->driver->init_bssid)) {
-                               wpa_printf(MSG_ERROR, "Line %d: bssid item "
-                                          "not allowed for the default "
-                                          "interface and this driver", line);
-                               errors++;
-                       } else if (hwaddr_aton(pos, bss->bssid)) {
+                       if (hwaddr_aton(pos, bss->bssid)) {
                                wpa_printf(MSG_ERROR, "Line %d: invalid bssid "
                                           "item", line);
                                errors++;
@@ -2265,29 +2259,30 @@ struct hostapd_config * hostapd_config_read(const char *fname)
 
        fclose(f);
 
-       if (bss->individual_wep_key_len == 0) {
-               /* individual keys are not use; can use key idx0 for broadcast
-                * keys */
-               bss->broadcast_key_idx_min = 0;
-       }
-
-       /* Select group cipher based on the enabled pairwise cipher suites */
-       pairwise = 0;
-       if (bss->wpa & 1)
-               pairwise |= bss->wpa_pairwise;
-       if (bss->wpa & 2) {
-               if (bss->rsn_pairwise == 0)
-                       bss->rsn_pairwise = bss->wpa_pairwise;
-               pairwise |= bss->rsn_pairwise;
-       }
-       if (pairwise & WPA_CIPHER_TKIP)
-               bss->wpa_group = WPA_CIPHER_TKIP;
-       else
-               bss->wpa_group = WPA_CIPHER_CCMP;
-
        for (i = 0; i < conf->num_bss; i++) {
                bss = &conf->bss[i];
 
+               if (bss->individual_wep_key_len == 0) {
+                       /* individual keys are not use; can use key idx0 for
+                        * broadcast keys */
+                       bss->broadcast_key_idx_min = 0;
+               }
+
+               /* Select group cipher based on the enabled pairwise cipher
+                * suites */
+               pairwise = 0;
+               if (bss->wpa & 1)
+                       pairwise |= bss->wpa_pairwise;
+               if (bss->wpa & 2) {
+                       if (bss->rsn_pairwise == 0)
+                               bss->rsn_pairwise = bss->wpa_pairwise;
+                       pairwise |= bss->rsn_pairwise;
+               }
+               if (pairwise & WPA_CIPHER_TKIP)
+                       bss->wpa_group = WPA_CIPHER_TKIP;
+               else
+                       bss->wpa_group = WPA_CIPHER_CCMP;
+
                bss->radius->auth_server = bss->radius->auth_servers;
                bss->radius->acct_server = bss->radius->acct_servers;