WPS 2.0: Disable WPS if ignore_broadcast_ssid or WEP is used
[libeap.git] / hostapd / config_file.c
index 0554f12..a6a3e5c 100644 (file)
  * See README and COPYING for more details.
  */
 
-#include "includes.h"
+#include "utils/includes.h"
 #ifndef CONFIG_NATIVE_WINDOWS
 #include <grp.h>
 #endif /* CONFIG_NATIVE_WINDOWS */
 
-#include "common.h"
-#include "uuid.h"
+#include "utils/common.h"
+#include "utils/uuid.h"
 #include "common/ieee802_11_defs.h"
 #include "drivers/driver.h"
 #include "eap_server/eap.h"
 #include "radius/radius_client.h"
-#include "wpa.h"
-#include "config.h"
+#include "ap/wpa_auth.h"
+#include "ap/ap_config.h"
+#include "config_file.h"
 
 
 extern struct wpa_driver_ops *wpa_drivers[];
@@ -1097,6 +1098,20 @@ static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
        }
 #endif /* CONFIG_IEEE80211N */
 
+#ifdef CONFIG_WPS2
+       if (bss->wps_state && bss->ignore_broadcast_ssid) {
+               wpa_printf(MSG_INFO, "WPS: ignore_broadcast_ssid "
+                          "configuration forced WPS to be disabled");
+               bss->wps_state = 0;
+       }
+
+       if (bss->wps_state && bss->ssid.wep.keys_set && bss->wpa == 0) {
+               wpa_printf(MSG_INFO, "WPS: WEP configuration forced WPS to be "
+                          "disabled");
+               bss->wps_state = 0;
+       }
+#endif /* CONFIG_WPS2 */
+
        return 0;
 }
 
@@ -1148,6 +1163,16 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                fclose(f);
                return NULL;
        }
+
+       /* set default driver based on configuration */
+       conf->driver = wpa_drivers[0];
+       if (conf->driver == NULL) {
+               wpa_printf(MSG_ERROR, "No driver wrappers registered!");
+               hostapd_config_free(conf);
+               fclose(f);
+               return NULL;
+       }
+
        bss = conf->last_bss = conf->bss;
 
        while (fgets(buf, sizeof(buf), f)) {
@@ -1302,6 +1327,8 @@ 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);
+               } else if (os_strcmp(buf, "fragment_size") == 0) {
+                       bss->fragment_size = atoi(pos);
 #ifdef EAP_SERVER_FAST
                } else if (os_strcmp(buf, "pac_opaque_encr_key") == 0) {
                        os_free(bss->pac_opaque_encr_key);
@@ -1356,6 +1383,10 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                } else if (os_strcmp(buf, "tnc") == 0) {
                        bss->tnc = atoi(pos);
 #endif /* EAP_SERVER_TNC */
+#ifdef EAP_SERVER_PWD
+               } else if (os_strcmp(buf, "pwd_group") == 0) {
+                       bss->pwd_group = atoi(pos);
+#endif /* EAP_SERVER_PWD */
 #endif /* EAP_SERVER */
                } else if (os_strcmp(buf, "eap_message") == 0) {
                        char *term;
@@ -1804,6 +1835,8 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                } else if (os_strcmp(buf, "wme_enabled") == 0 ||
                           os_strcmp(buf, "wmm_enabled") == 0) {
                        bss->wmm_enabled = atoi(pos);
+               } else if (os_strcmp(buf, "uapsd_advertisement_enabled") == 0) {
+                       bss->wmm_uapsd = 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)) {
@@ -1973,6 +2006,19 @@ struct hostapd_config * hostapd_config_read(const char *fname)
                        os_free(bss->upc);
                        bss->upc = os_strdup(pos);
 #endif /* CONFIG_WPS */
+#ifdef CONFIG_P2P_MANAGER
+               } else if (os_strcmp(buf, "manage_p2p") == 0) {
+                       int manage = atoi(pos);
+                       if (manage)
+                               bss->p2p |= P2P_MANAGE;
+                       else
+                               bss->p2p &= ~P2P_MANAGE;
+               } else if (os_strcmp(buf, "allow_cross_connection") == 0) {
+                       if (atoi(pos))
+                               bss->p2p |= P2P_ALLOW_CROSS_CONNECTION;
+                       else
+                               bss->p2p &= ~P2P_ALLOW_CROSS_CONNECTION;
+#endif /* CONFIG_P2P_MANAGER */
                } else {
                        wpa_printf(MSG_ERROR, "Line %d: unknown configuration "
                                   "item '%s'", line, buf);