Moved association check from driver_*.c into ieee802_1x_receive()
[wpasupplicant] / hostapd / config.c
index 2e7e04f..c760ee6 100644 (file)
@@ -184,8 +184,8 @@ static void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
        bss->max_listen_interval = 65535;
 
 #ifdef CONFIG_IEEE80211W
-       bss->assoc_ping_timeout = 1000;
-       bss->assoc_ping_attempts = 3;
+       bss->assoc_sa_query_max_timeout = 1000;
+       bss->assoc_sa_query_retry_timeout = 201;
 #endif /* CONFIG_IEEE80211W */
 #ifdef EAP_FAST
         /* both anonymous and authenticated provisioning */
@@ -411,7 +411,7 @@ static int hostapd_config_read_wpa_psk(const char *fname,
                        os_memcpy(psk->addr, addr, ETH_ALEN);
 
                pos = buf + 17;
-               if (pos == '\0') {
+               if (*pos == '\0') {
                        printf("No PSK on line %d in '%s'\n", line, fname);
                        os_free(psk);
                        ret = -1;
@@ -800,7 +800,7 @@ static int hostapd_config_parse_key_mgmt(int line, const char *value)
                return -1;
        start = buf;
 
-       while (start != '\0') {
+       while (*start != '\0') {
                while (*start == ' ' || *start == '\t')
                        start++;
                if (*start == '\0')
@@ -858,7 +858,7 @@ static int hostapd_config_parse_cipher(int line, const char *value)
                return -1;
        start = buf;
 
-       while (start != '\0') {
+       while (*start != '\0') {
                while (*start == ' ' || *start == '\t')
                        start++;
                if (*start == '\0')
@@ -944,6 +944,16 @@ static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
        }
 #endif /* CONFIG_IEEE80211R */
 
+#ifdef CONFIG_IEEE80211N
+       if (conf->ieee80211n && bss->wpa &&
+           !(bss->wpa_pairwise & WPA_CIPHER_CCMP) &&
+           !(bss->rsn_pairwise & WPA_CIPHER_CCMP)) {
+               printf("HT (IEEE 802.11n) with WPA/WPA2 requires CCMP to be "
+                      "enabled\n");
+               return -1;
+       }
+#endif /* CONFIG_IEEE80211N */
+
        return 0;
 }
 
@@ -1367,6 +1377,11 @@ static int hostapd_config_ht_capab(struct hostapd_config *conf,
 #endif /* CONFIG_IEEE80211N */
 
 
+/**
+ * hostapd_config_read - Read and parse a configuration file
+ * @fname: Configuration file name (including path, if needed)
+ * Returns: Allocated configuration data structure
+ */
 struct hostapd_config * hostapd_config_read(const char *fname)
 {
        struct hostapd_config *conf;
@@ -2054,18 +2069,20 @@ struct hostapd_config * hostapd_config_read(const char *fname)
 #ifdef CONFIG_IEEE80211W
                } else if (os_strcmp(buf, "ieee80211w") == 0) {
                        bss->ieee80211w = atoi(pos);
-               } else if (os_strcmp(buf, "assoc_ping_timeout") == 0) {
-                       bss->assoc_ping_timeout = atoi(pos);
-                       if (bss->assoc_ping_timeout == 0) {
-                               printf("Line %d: invalid assoc_ping_timeout\n",
-                                       line);
+               } else if (os_strcmp(buf, "assoc_sa_query_max_timeout") == 0) {
+                       bss->assoc_sa_query_max_timeout = atoi(pos);
+                       if (bss->assoc_sa_query_max_timeout == 0) {
+                               printf("Line %d: invalid "
+                                      "assoc_sa_query_max_timeout\n",
+                                      line);
                                errors++;
                        }
-               } else if (os_strcmp(buf, "assoc_ping_attempts") == 0) {
-                       bss->assoc_ping_timeout = atoi(pos);
-                       if (bss->assoc_ping_timeout == 0) {
-                               printf("Line %d: invalid assoc_ping_attempts "
-                                      "(valid range: 1..255)\n",
+               } else if (os_strcmp(buf, "assoc_sa_query_retry_timeout") == 0)
+               {
+                       bss->assoc_sa_query_retry_timeout = atoi(pos);
+                       if (bss->assoc_sa_query_retry_timeout == 0) {
+                               printf("Line %d: invalid "
+                                      "assoc_sa_query_retry_timeout\n",
                                       line);
                                errors++;
                        }
@@ -2100,14 +2117,39 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                } else if (os_strcmp(buf, "wps_pin_requests") == 0) {
                        bss->wps_pin_requests = os_strdup(pos);
                } else if (os_strcmp(buf, "device_name") == 0) {
+                       if (os_strlen(pos) > 32) {
+                               printf("Line %d: Too long device_name\n",
+                                      line);
+                               errors++;
+                       }
                        bss->device_name = os_strdup(pos);
                } else if (os_strcmp(buf, "manufacturer") == 0) {
+                       if (os_strlen(pos) > 64) {
+                               printf("Line %d: Too long manufacturer\n",
+                                      line);
+                               errors++;
+                       }
                        bss->manufacturer = os_strdup(pos);
                } else if (os_strcmp(buf, "model_name") == 0) {
+                       if (os_strlen(pos) > 32) {
+                               printf("Line %d: Too long model_name\n",
+                                      line);
+                               errors++;
+                       }
                        bss->model_name = os_strdup(pos);
                } else if (os_strcmp(buf, "model_number") == 0) {
+                       if (os_strlen(pos) > 32) {
+                               printf("Line %d: Too long model_number\n",
+                                      line);
+                               errors++;
+                       }
                        bss->model_number = os_strdup(pos);
                } else if (os_strcmp(buf, "serial_number") == 0) {
+                       if (os_strlen(pos) > 32) {
+                               printf("Line %d: Too long serial_number\n",
+                                      line);
+                               errors++;
+                       }
                        bss->serial_number = os_strdup(pos);
                } else if (os_strcmp(buf, "device_type") == 0) {
                        bss->device_type = os_strdup(pos);
@@ -2329,6 +2371,10 @@ static void hostapd_config_free_bss(struct hostapd_bss_config *conf)
 }
 
 
+/**
+ * hostapd_config_free - Free hostapd configuration
+ * @conf: Configuration data from hostapd_config_read().
+ */
 void hostapd_config_free(struct hostapd_config *conf)
 {
        size_t i;
@@ -2344,8 +2390,16 @@ void hostapd_config_free(struct hostapd_config *conf)
 }
 
 
-/* Perform a binary search for given MAC address from a pre-sorted list.
- * Returns 1 if address is in the list or 0 if not. */
+/**
+ * hostapd_maclist_found - Find a MAC address from a list
+ * @list: MAC address list
+ * @num_entries: Number of addresses in the list
+ * @addr: Address to search for
+ * @vlan_id: Buffer for returning VLAN ID or %NULL if not needed
+ * Returns: 1 if address is in the list or 0 if not.
+ *
+ * Perform a binary search for given MAC address from a pre-sorted list.
+ */
 int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
                          const u8 *addr, int *vlan_id)
 {