X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=wpa_supplicant%2Fconfig_file.c;h=0f343fd04cb22994582610fd723de31066c7f759;hb=HEAD;hp=acc9ee58084bc34536bba2c5a0f1a247540c96ce;hpb=f855f923a735c38b0ec918f3302173bf3e8e7a7f;p=libeap.git diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index acc9ee5..0f343fd 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -22,7 +22,6 @@ #include "config.h" #include "base64.h" #include "uuid.h" -#include "eap_peer/eap_methods.h" /** @@ -270,243 +269,6 @@ static int wpa_config_process_blob(struct wpa_config *config, FILE *f, #endif /* CONFIG_NO_CONFIG_BLOBS */ -#ifdef CONFIG_CTRL_IFACE -static int wpa_config_process_ctrl_interface(struct wpa_config *config, - char *pos) -{ - os_free(config->ctrl_interface); - config->ctrl_interface = os_strdup(pos); - wpa_printf(MSG_DEBUG, "ctrl_interface='%s'", config->ctrl_interface); - return 0; -} - - -static int wpa_config_process_ctrl_interface_group(struct wpa_config *config, - char *pos) -{ - os_free(config->ctrl_interface_group); - config->ctrl_interface_group = os_strdup(pos); - wpa_printf(MSG_DEBUG, "ctrl_interface_group='%s' (DEPRECATED)", - config->ctrl_interface_group); - return 0; -} -#endif /* CONFIG_CTRL_IFACE */ - - -static int wpa_config_process_eapol_version(struct wpa_config *config, - int line, char *pos) -{ - config->eapol_version = atoi(pos); - if (config->eapol_version < 1 || config->eapol_version > 2) { - wpa_printf(MSG_ERROR, "Line %d: Invalid EAPOL version (%d): " - "'%s'.", line, config->eapol_version, pos); - return -1; - } - wpa_printf(MSG_DEBUG, "eapol_version=%d", config->eapol_version); - return 0; -} - - -static int wpa_config_process_ap_scan(struct wpa_config *config, char *pos) -{ - config->ap_scan = atoi(pos); - wpa_printf(MSG_DEBUG, "ap_scan=%d", config->ap_scan); - return 0; -} - - -static int wpa_config_process_fast_reauth(struct wpa_config *config, char *pos) -{ - config->fast_reauth = atoi(pos); - wpa_printf(MSG_DEBUG, "fast_reauth=%d", config->fast_reauth); - return 0; -} - - -#ifdef EAP_TLS_OPENSSL - -static int wpa_config_process_opensc_engine_path(struct wpa_config *config, - char *pos) -{ - os_free(config->opensc_engine_path); - config->opensc_engine_path = os_strdup(pos); - wpa_printf(MSG_DEBUG, "opensc_engine_path='%s'", - config->opensc_engine_path); - return 0; -} - - -static int wpa_config_process_pkcs11_engine_path(struct wpa_config *config, - char *pos) -{ - os_free(config->pkcs11_engine_path); - config->pkcs11_engine_path = os_strdup(pos); - wpa_printf(MSG_DEBUG, "pkcs11_engine_path='%s'", - config->pkcs11_engine_path); - return 0; -} - - -static int wpa_config_process_pkcs11_module_path(struct wpa_config *config, - char *pos) -{ - os_free(config->pkcs11_module_path); - config->pkcs11_module_path = os_strdup(pos); - wpa_printf(MSG_DEBUG, "pkcs11_module_path='%s'", - config->pkcs11_module_path); - return 0; -} - -#endif /* EAP_TLS_OPENSSL */ - - -static int wpa_config_process_driver_param(struct wpa_config *config, - char *pos) -{ - os_free(config->driver_param); - config->driver_param = os_strdup(pos); - wpa_printf(MSG_DEBUG, "driver_param='%s'", config->driver_param); - return 0; -} - - -static int wpa_config_process_pmk_lifetime(struct wpa_config *config, - char *pos) -{ - config->dot11RSNAConfigPMKLifetime = atoi(pos); - wpa_printf(MSG_DEBUG, "dot11RSNAConfigPMKLifetime=%d", - config->dot11RSNAConfigPMKLifetime); - return 0; -} - - -static int wpa_config_process_pmk_reauth_threshold(struct wpa_config *config, - char *pos) -{ - config->dot11RSNAConfigPMKReauthThreshold = atoi(pos); - wpa_printf(MSG_DEBUG, "dot11RSNAConfigPMKReauthThreshold=%d", - config->dot11RSNAConfigPMKReauthThreshold); - return 0; -} - - -static int wpa_config_process_sa_timeout(struct wpa_config *config, char *pos) -{ - config->dot11RSNAConfigSATimeout = atoi(pos); - wpa_printf(MSG_DEBUG, "dot11RSNAConfigSATimeout=%d", - config->dot11RSNAConfigSATimeout); - return 0; -} - - -#ifndef CONFIG_NO_CONFIG_WRITE -static int wpa_config_process_update_config(struct wpa_config *config, - char *pos) -{ - config->update_config = atoi(pos); - wpa_printf(MSG_DEBUG, "update_config=%d", config->update_config); - return 0; -} -#endif /* CONFIG_NO_CONFIG_WRITE */ - - -static int wpa_config_process_load_dynamic_eap(int line, char *so) -{ - int ret; - wpa_printf(MSG_DEBUG, "load_dynamic_eap=%s", so); - ret = eap_peer_method_load(so); - if (ret == -2) { - wpa_printf(MSG_DEBUG, "This EAP type was already loaded - not " - "reloading."); - } else if (ret) { - wpa_printf(MSG_ERROR, "Line %d: Failed to load dynamic EAP " - "method '%s'.", line, so); - return -1; - } - - return 0; -} - - -#ifdef CONFIG_WPS -static int wpa_config_process_uuid(struct wpa_config *config, int line, - char *pos) -{ - char buf[40]; - if (uuid_str2bin(pos, config->uuid)) { - wpa_printf(MSG_ERROR, "Line %d: invalid UUID", line); - return -1; - } - uuid_bin2str(config->uuid, buf, sizeof(buf)); - wpa_printf(MSG_DEBUG, "uuid=%s", buf); - return 0; -} -#endif /* CONFIG_WPS */ - - -static int wpa_config_process_global(struct wpa_config *config, char *pos, - int line) -{ -#ifdef CONFIG_CTRL_IFACE - if (os_strncmp(pos, "ctrl_interface=", 15) == 0) - return wpa_config_process_ctrl_interface(config, pos + 15); - - if (os_strncmp(pos, "ctrl_interface_group=", 21) == 0) - return wpa_config_process_ctrl_interface_group(config, - pos + 21); -#endif /* CONFIG_CTRL_IFACE */ - - if (os_strncmp(pos, "eapol_version=", 14) == 0) - return wpa_config_process_eapol_version(config, line, - pos + 14); - - if (os_strncmp(pos, "ap_scan=", 8) == 0) - return wpa_config_process_ap_scan(config, pos + 8); - - if (os_strncmp(pos, "fast_reauth=", 12) == 0) - return wpa_config_process_fast_reauth(config, pos + 12); - -#ifdef EAP_TLS_OPENSSL - if (os_strncmp(pos, "opensc_engine_path=", 19) == 0) - return wpa_config_process_opensc_engine_path(config, pos + 19); - - if (os_strncmp(pos, "pkcs11_engine_path=", 19) == 0) - return wpa_config_process_pkcs11_engine_path(config, pos + 19); - - if (os_strncmp(pos, "pkcs11_module_path=", 19) == 0) - return wpa_config_process_pkcs11_module_path(config, pos + 19); -#endif /* EAP_TLS_OPENSSL */ - - if (os_strncmp(pos, "driver_param=", 13) == 0) - return wpa_config_process_driver_param(config, pos + 13); - - if (os_strncmp(pos, "dot11RSNAConfigPMKLifetime=", 27) == 0) - return wpa_config_process_pmk_lifetime(config, pos + 27); - - if (os_strncmp(pos, "dot11RSNAConfigPMKReauthThreshold=", 34) == 0) - return wpa_config_process_pmk_reauth_threshold(config, - pos + 34); - - if (os_strncmp(pos, "dot11RSNAConfigSATimeout=", 25) == 0) - return wpa_config_process_sa_timeout(config, pos + 25); - -#ifndef CONFIG_NO_CONFIG_WRITE - if (os_strncmp(pos, "update_config=", 14) == 0) - return wpa_config_process_update_config(config, pos + 14); -#endif /* CONFIG_NO_CONFIG_WRITE */ - - if (os_strncmp(pos, "load_dynamic_eap=", 17) == 0) - return wpa_config_process_load_dynamic_eap(line, pos + 17); - -#ifdef CONFIG_WPS - if (os_strncmp(pos, "uuid=", 5) == 0) - return wpa_config_process_uuid(config, line, pos + 5); -#endif /* CONFIG_WPS */ - - return -1; -} - - struct wpa_config * wpa_config_read(const char *name) { FILE *f; @@ -843,7 +605,6 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) fprintf(f, "ap_scan=%d\n", config->ap_scan); if (config->fast_reauth != DEFAULT_FAST_REAUTH) fprintf(f, "fast_reauth=%d\n", config->fast_reauth); -#ifdef EAP_TLS_OPENSSL if (config->opensc_engine_path) fprintf(f, "opensc_engine_path=%s\n", config->opensc_engine_path); @@ -853,7 +614,6 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) if (config->pkcs11_module_path) fprintf(f, "pkcs11_module_path=%s\n", config->pkcs11_module_path); -#endif /* EAP_TLS_OPENSSL */ if (config->driver_param) fprintf(f, "driver_param=%s\n", config->driver_param); if (config->dot11RSNAConfigPMKLifetime) @@ -868,12 +628,63 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) if (config->update_config) fprintf(f, "update_config=%d\n", config->update_config); #ifdef CONFIG_WPS - if (is_nil_uuid(config->uuid)) { + if (!is_nil_uuid(config->uuid)) { char buf[40]; uuid_bin2str(config->uuid, buf, sizeof(buf)); fprintf(f, "uuid=%s\n", buf); } + if (config->device_name) + fprintf(f, "device_name=%s\n", config->device_name); + if (config->manufacturer) + fprintf(f, "manufacturer=%s\n", config->manufacturer); + if (config->model_name) + fprintf(f, "model_name=%s\n", config->model_name); + if (config->model_number) + fprintf(f, "model_number=%s\n", config->model_number); + if (config->serial_number) + fprintf(f, "serial_number=%s\n", config->serial_number); + if (config->device_type) + fprintf(f, "device_type=%s\n", config->device_type); + if (WPA_GET_BE32(config->os_version)) + fprintf(f, "os_version=%08x\n", + WPA_GET_BE32(config->os_version)); + if (config->config_methods) + fprintf(f, "config_methods=%s\n", config->config_methods); + if (config->wps_cred_processing) + fprintf(f, "wps_cred_processing=%d\n", + config->wps_cred_processing); #endif /* CONFIG_WPS */ +#ifdef CONFIG_P2P + if (config->p2p_listen_reg_class) + fprintf(f, "p2p_listen_reg_class=%u\n", + config->p2p_listen_reg_class); + if (config->p2p_listen_channel) + fprintf(f, "p2p_listen_channel=%u\n", + config->p2p_listen_channel); + if (config->p2p_oper_reg_class) + fprintf(f, "p2p_oper_reg_class=%u\n", + config->p2p_oper_reg_class); + if (config->p2p_oper_channel) + fprintf(f, "p2p_oper_channel=%u\n", config->p2p_oper_channel); + if (config->p2p_go_intent != DEFAULT_P2P_GO_INTENT) + fprintf(f, "p2p_go_intent=%u\n", config->p2p_go_intent); + if (config->p2p_ssid_postfix) + fprintf(f, "p2p_ssid_postfix=%s\n", config->p2p_ssid_postfix); + if (config->persistent_reconnect) + fprintf(f, "persistent_reconnect=%u\n", + config->persistent_reconnect); + if (config->p2p_intra_bss != DEFAULT_P2P_INTRA_BSS) + fprintf(f, "p2p_intra_bss=%u\n", config->p2p_intra_bss); + +#endif /* CONFIG_P2P */ + if (config->country[0] && config->country[1]) { + fprintf(f, "country=%c%c\n", + config->country[0], config->country[1]); + } + if (config->bss_max_count != DEFAULT_BSS_MAX_COUNT) + fprintf(f, "bss_max_count=%u\n", config->bss_max_count); + if (config->filter_ssids) + fprintf(f, "filter_ssids=%d\n", config->filter_ssids); } #endif /* CONFIG_NO_CONFIG_WRITE */ @@ -900,8 +711,8 @@ int wpa_config_write(const char *name, struct wpa_config *config) wpa_config_write_global(f, config); for (ssid = config->ssid; ssid; ssid = ssid->next) { - if (ssid->key_mgmt == WPA_KEY_MGMT_WPS) - continue; /* do not save temporary WPS networks */ + if (ssid->key_mgmt == WPA_KEY_MGMT_WPS || ssid->temporary) + continue; /* do not save temporary networks */ fprintf(f, "\nnetwork={\n"); wpa_config_write_network(f, ssid); fprintf(f, "}\n");