Do not add blacklist entries based on normal disconnect request cases
[mech_eap.git] / wpa_supplicant / ctrl_iface.c
index 7a77a7f..7c230dc 100644 (file)
@@ -209,6 +209,7 @@ static int set_disallow_aps(struct wpa_supplicant *wpa_s, char *val)
        wpa_s->sme.prev_bssid_set = 0;
 #endif /* CONFIG_SME */
        wpa_s->reassociate = 1;
+       wpa_s->own_disconnect_req = 1;
        wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
        wpa_supplicant_req_scan(wpa_s, 0, 0);
 
@@ -498,6 +499,8 @@ static int wpa_supplicant_ctrl_iface_get(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_TESTING_GET_GTK */
        } else if (os_strcmp(cmd, "tls_library") == 0) {
                res = tls_get_library_version(buf, buflen);
+       } else {
+               res = wpa_config_get_value(cmd, wpa_s->conf, buf, buflen);
        }
 
        if (os_snprintf_error(buflen, res))
@@ -2833,6 +2836,7 @@ static int wpa_supplicant_ctrl_iface_remove_network(
 #endif /* CONFIG_SME */
                        wpa_sm_set_config(wpa_s->wpa, NULL);
                        eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
+                       wpa_s->own_disconnect_req = 1;
                        wpa_supplicant_deauthenticate(
                                wpa_s, WLAN_REASON_DEAUTH_LEAVING);
                }
@@ -2879,6 +2883,7 @@ static int wpa_supplicant_ctrl_iface_remove_network(
                wpa_sm_set_config(wpa_s->wpa, NULL);
                eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
 
+               wpa_s->own_disconnect_req = 1;
                wpa_supplicant_deauthenticate(wpa_s,
                                              WLAN_REASON_DEAUTH_LEAVING);
        }
@@ -4174,6 +4179,8 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
 #ifdef CONFIG_INTERWORKING
        if ((mask & WPA_BSS_MASK_INTERNETW) && bss->anqp) {
                struct wpa_bss_anqp *anqp = bss->anqp;
+               pos = anqp_add_hex(pos, end, "anqp_capability_list",
+                                  anqp->capability_list);
                pos = anqp_add_hex(pos, end, "anqp_venue_name",
                                   anqp->venue_name);
                pos = anqp_add_hex(pos, end, "anqp_network_auth_type",
@@ -4188,6 +4195,8 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
                pos = anqp_add_hex(pos, end, "anqp_domain_name",
                                   anqp->domain_name);
 #ifdef CONFIG_HS20
+               pos = anqp_add_hex(pos, end, "hs20_capability_list",
+                                  anqp->hs20_capability_list);
                pos = anqp_add_hex(pos, end, "hs20_operator_friendly_name",
                                   anqp->hs20_operator_friendly_name);
                pos = anqp_add_hex(pos, end, "hs20_wan_metrics",
@@ -4212,6 +4221,21 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
        }
 #endif /* CONFIG_MESH */
 
+       if (mask & WPA_BSS_MASK_SNR) {
+               ret = os_snprintf(pos, end - pos, "snr=%d\n", bss->snr);
+               if (os_snprintf_error(end - pos, ret))
+                       return 0;
+               pos += ret;
+       }
+
+       if (mask & WPA_BSS_MASK_EST_THROUGHPUT) {
+               ret = os_snprintf(pos, end - pos, "est_throughput=%d\n",
+                                 bss->est_throughput);
+               if (os_snprintf_error(end - pos, ret))
+                       return 0;
+               pos += ret;
+       }
+
        if (mask & WPA_BSS_MASK_DELIM) {
                ret = os_snprintf(pos, end - pos, "====\n");
                if (os_snprintf_error(end - pos, ret))
@@ -4487,8 +4511,9 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
        u8 dev_type[WPS_DEV_TYPE_LEN], *_dev_type = NULL;
        char *pos;
        unsigned int search_delay;
-       const char *seek[P2P_MAX_QUERY_HASH + 1];
+       const char *_seek[P2P_MAX_QUERY_HASH + 1], **seek = NULL;
        u8 seek_count = 0;
+       int freq = 0;
 
        if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
                wpa_dbg(wpa_s, MSG_INFO,
@@ -4529,27 +4554,28 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
                char *term;
 
                term = os_strchr(pos + 1, ' ');
-               seek[seek_count++] = pos + 6;
+               _seek[seek_count++] = pos + 6;
+               seek = _seek;
                pos = os_strstr(pos + 6, " seek=");
 
                if (term)
                        *term = '\0';
        }
-
-       if (!seek_count)
-               return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL,
-                                    _dev_type, _dev_id,
-                                    search_delay, 0, NULL);
-
        if (seek_count > P2P_MAX_QUERY_HASH) {
                seek[0] = NULL;
-               return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL,
-                                    _dev_type, _dev_id,
-                                    search_delay, 1, seek);
+               seek_count = 1;
+       }
+
+       pos = os_strstr(cmd, "freq=");
+       if (pos) {
+               pos += 5;
+               freq = atoi(pos);
+               if (freq <= 0)
+                       return -1;
        }
 
        return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL, _dev_type,
-                            _dev_id, search_delay, seek_count, seek);
+                            _dev_id, search_delay, seek_count, seek, freq);
 }
 
 
@@ -4718,10 +4744,18 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
        int pd;
        int ht40, vht;
 
+       if (!wpa_s->global->p2p_init_wpa_s)
+               return -1;
+       if (wpa_s->global->p2p_init_wpa_s != wpa_s) {
+               wpa_dbg(wpa_s, MSG_DEBUG, "Direct P2P_CONNECT command to %s",
+                       wpa_s->global->p2p_init_wpa_s->ifname);
+               wpa_s = wpa_s->global->p2p_init_wpa_s;
+       }
+
        /* <addr> <"pbc" | "pin" | PIN> [label|display|keypad|p2ps]
         * [persistent|persistent=<network id>]
         * [join] [auth] [go_intent=<0..15>] [freq=<in MHz>] [provdisc]
-        * [ht40] [vht] */
+        * [ht40] [vht] [auto] */
 
        if (hwaddr_aton(cmd, addr))
                return -1;
@@ -5946,7 +5980,8 @@ static int ctrl_interworking_select(struct wpa_supplicant *wpa_s, char *param)
 }
 
 
-static int ctrl_interworking_connect(struct wpa_supplicant *wpa_s, char *dst)
+static int ctrl_interworking_connect(struct wpa_supplicant *wpa_s, char *dst,
+                                    int only_add)
 {
        u8 bssid[ETH_ALEN];
        struct wpa_bss *bss;
@@ -5984,7 +6019,7 @@ static int ctrl_interworking_connect(struct wpa_supplicant *wpa_s, char *dst)
                           "Found another matching BSS entry with SSID");
        }
 
-       return interworking_connect(wpa_s, bss);
+       return interworking_connect(wpa_s, bss, only_add);
 }
 
 
@@ -6596,6 +6631,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
        wpa_supplicant_stop_countermeasures(wpa_s, NULL);
 
        wpa_s->no_keep_alive = 0;
+       wpa_s->own_disconnect_req = 0;
 
        os_free(wpa_s->disallow_aps_bssid);
        wpa_s->disallow_aps_bssid = NULL;
@@ -7837,6 +7873,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
        } else if (os_strncmp(buf, "SET ", 4) == 0) {
                if (wpa_supplicant_ctrl_iface_set(wpa_s, buf + 4))
                        reply_len = -1;
+       } else if (os_strncmp(buf, "DUMP", 4) == 0) {
+               reply_len = wpa_config_dump_values(wpa_s->conf,
+                                                  reply, reply_size);
        } else if (os_strncmp(buf, "GET ", 4) == 0) {
                reply_len = wpa_supplicant_ctrl_iface_get(wpa_s, buf + 4,
                                                          reply, reply_size);
@@ -8119,8 +8158,19 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
                if (ctrl_interworking_select(wpa_s, buf + 20) < 0)
                        reply_len = -1;
        } else if (os_strncmp(buf, "INTERWORKING_CONNECT ", 21) == 0) {
-               if (ctrl_interworking_connect(wpa_s, buf + 21) < 0)
+               if (ctrl_interworking_connect(wpa_s, buf + 21, 0) < 0)
+                       reply_len = -1;
+       } else if (os_strncmp(buf, "INTERWORKING_ADD_NETWORK ", 25) == 0) {
+               int id;
+
+               id = ctrl_interworking_connect(wpa_s, buf + 25, 1);
+               if (id < 0)
                        reply_len = -1;
+               else {
+                       reply_len = os_snprintf(reply, reply_size, "%d\n", id);
+                       if (os_snprintf_error(reply_size, reply_len))
+                               reply_len = -1;
+               }
        } else if (os_strncmp(buf, "ANQP_GET ", 9) == 0) {
                if (get_anqp(wpa_s, buf + 9) < 0)
                        reply_len = -1;
@@ -8278,6 +8328,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
        } else if (os_strncmp(buf, "CHAN_SWITCH ", 12) == 0) {
                if (ap_ctrl_iface_chanswitch(wpa_s, buf + 12))
                        reply_len = -1;
+       } else if (os_strcmp(buf, "STOP_AP") == 0) {
+               if (wpas_ap_stop_ap(wpa_s))
+                       reply_len = -1;
 #endif /* CONFIG_AP */
        } else if (os_strcmp(buf, "SUSPEND") == 0) {
                wpas_notify_suspend(wpa_s->global);