Fix UNIX domain socket address handling to be more portable
[wpasupplicant] / hostapd / config.c
index dbdee76..8575255 100644 (file)
@@ -204,13 +204,13 @@ static struct hostapd_config * hostapd_config_defaults(void)
        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));
@@ -250,15 +250,13 @@ static struct hostapd_config * hostapd_config_defaults(void)
        conf->send_probe_response = 1;
        conf->bridge_packets = INTERNAL_BRIDGE_DO_NOT_CONTROL;
 
-       os_memcpy(conf->country, "US ", 3);
-
        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;
@@ -476,11 +474,6 @@ int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
                wpa_hexdump(MSG_DEBUG, "PSK (from passphrase)",
                            ssid->wpa_psk->psk, PMK_LEN);
                ssid->wpa_psk->group = 1;
-
-               os_memset(ssid->wpa_passphrase, 0,
-                         os_strlen(ssid->wpa_passphrase));
-               os_free(ssid->wpa_passphrase);
-               ssid->wpa_passphrase = NULL;
        }
 
        if (ssid->wpa_psk_file) {
@@ -975,6 +968,12 @@ static int hostapd_config_check(struct hostapd_config *conf)
 {
        size_t i;
 
+       if (conf->ieee80211d && (!conf->country[0] || !conf->country[1])) {
+               wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without "
+                          "setting the country_code");
+               return -1;
+       }
+
        for (i = 0; i < conf->num_bss; i++) {
                if (hostapd_config_check_bss(&conf->bss[i], conf))
                        return -1;
@@ -1171,14 +1170,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;
@@ -1193,11 +1192,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);
@@ -1226,7 +1225,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) {
@@ -1235,7 +1234,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;
        }
 
@@ -2081,11 +2080,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++;
                        }
@@ -2227,6 +2228,35 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                                           line, pos);
                                errors++;
                        }
+               } else if (os_strcmp(buf, "wps_cred_processing") == 0) {
+                       bss->wps_cred_processing = atoi(pos);
+               } else if (os_strcmp(buf, "ap_settings") == 0) {
+                       os_free(bss->ap_settings);
+                       bss->ap_settings =
+                               (u8 *) os_readfile(pos, &bss->ap_settings_len);
+                       if (bss->ap_settings == NULL) {
+                               wpa_printf(MSG_ERROR, "Line %d: could not "
+                                          "read AP Settings from '%s'",
+                                          line, pos);
+                               errors++;
+                       }
+               } else if (os_strcmp(buf, "upnp_iface") == 0) {
+                       bss->upnp_iface = os_strdup(pos);
+               } else if (os_strcmp(buf, "friendly_name") == 0) {
+                       os_free(bss->friendly_name);
+                       bss->friendly_name = os_strdup(pos);
+               } else if (os_strcmp(buf, "manufacturer_url") == 0) {
+                       os_free(bss->manufacturer_url);
+                       bss->manufacturer_url = os_strdup(pos);
+               } else if (os_strcmp(buf, "model_description") == 0) {
+                       os_free(bss->model_description);
+                       bss->model_description = os_strdup(pos);
+               } else if (os_strcmp(buf, "model_url") == 0) {
+                       os_free(bss->model_url);
+                       bss->model_url = os_strdup(pos);
+               } else if (os_strcmp(buf, "upc") == 0) {
+                       os_free(bss->upc);
+                       bss->upc = os_strdup(pos);
 #endif /* CONFIG_WPS */
                } else {
                        wpa_printf(MSG_ERROR, "Line %d: unknown configuration "
@@ -2432,6 +2462,14 @@ static void hostapd_config_free_bss(struct hostapd_bss_config *conf)
        os_free(conf->device_type);
        os_free(conf->config_methods);
        os_free(conf->ap_pin);
+       os_free(conf->extra_cred);
+       os_free(conf->ap_settings);
+       os_free(conf->upnp_iface);
+       os_free(conf->friendly_name);
+       os_free(conf->manufacturer_url);
+       os_free(conf->model_description);
+       os_free(conf->model_url);
+       os_free(conf->upc);
 #endif /* CONFIG_WPS */
 }