P2P: Do not save temporary networks
authorJouni Malinen <jouni.malinen@atheros.com>
Sun, 18 Jul 2010 21:30:24 +0000 (14:30 -0700)
committerJouni Malinen <j@w1.fi>
Thu, 9 Sep 2010 14:17:16 +0000 (07:17 -0700)
wpa_supplicant/config_file.c
wpa_supplicant/wps_supplicant.c

index ece027a..1b9cc60 100644 (file)
@@ -708,8 +708,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");
index 8cb9df2..2da1697 100644 (file)
@@ -240,6 +240,8 @@ static int wpa_supplicant_wps_cred(void *ctx,
                ssid->eap.phase1 = NULL;
                os_free(ssid->eap.eap_methods);
                ssid->eap.eap_methods = NULL;
+               if (!ssid->p2p_group)
+                       ssid->temporary = 0;
        } else {
                wpa_printf(MSG_DEBUG, "WPS: Create a new network based on the "
                           "received credential");
@@ -596,6 +598,7 @@ static struct wpa_ssid * wpas_wps_add_network(struct wpa_supplicant *wpa_s,
                return NULL;
        wpas_notify_network_added(wpa_s, ssid);
        wpa_config_set_network_defaults(ssid);
+       ssid->temporary = 1;
        if (wpa_config_set(ssid, "key_mgmt", "WPS", 0) < 0 ||
            wpa_config_set(ssid, "eap", "WSC", 0) < 0 ||
            wpa_config_set(ssid, "identity", registrar ?
@@ -787,6 +790,7 @@ int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
        ssid = wpas_wps_add_network(wpa_s, 1, bssid);
        if (ssid == NULL)
                return -1;
+       ssid->temporary = 1;
        pos = val;
        end = pos + sizeof(val);
        res = os_snprintf(pos, end - pos, "\"pin=%s", pin);