diff options
Diffstat (limited to 'plugins/wifi.c')
-rwxr-xr-x | plugins/wifi.c | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/plugins/wifi.c b/plugins/wifi.c index 3135484b..a9ffad05 100755 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -2075,7 +2075,7 @@ static int wifi_specific_scan(enum connman_service_type type, return -EALREADY; DBG("scan_type: %d", scan_type); - if (scan_type == 1) { /* ssid based scan */ + if (scan_type == CONNMAN_MULTI_SCAN_SSID) { /* ssid based scan */ scan_params = g_try_malloc0(sizeof(GSupplicantScanParams)); if (!scan_params) { DBG("Failed to allocate memory."); @@ -2101,7 +2101,7 @@ static int wifi_specific_scan(enum connman_service_type type, } scan_params->num_ssids = count; - } else if (scan_type == 2) { /* frequency based scan */ + } else if (scan_type == CONNMAN_MULTI_SCAN_FREQ) { /* frequency based scan */ scan_params = g_try_malloc0(sizeof(GSupplicantScanParams)); if (!scan_params) { @@ -2129,6 +2129,51 @@ static int wifi_specific_scan(enum connman_service_type type, } scan_params->num_freqs = count; + } else if (scan_type == CONNMAN_MULTI_SCAN_SSID_FREQ) { /* SSID & Frequency mixed scan */ + int freq_count, ap_count; + scan_params = g_try_malloc0(sizeof(GSupplicantScanParams)); + if (!scan_params) { + DBG("Failed to allocate memory."); + return -ENOMEM; + } + + guint size = g_slist_length(specific_scan_list); + + scan_params->freqs = g_try_new0(uint16_t, size/2); + if (!scan_params->freqs) { + DBG("Failed to allocate memory."); + g_free(scan_params); + return -ENOMEM; + } + + ap_count = freq_count = 0; + for (list = specific_scan_list; list; list = list->next) { + if (((connman_multi_scan_ap_s *)list->data)->flag == true) { /** ssid */ + ssid = ((connman_multi_scan_ap_s *)list->data)->str; + int ssid_len = strlen(ssid); + + scan_ssid = g_try_new0(struct scan_ssid, 1); + if (!scan_ssid) { + DBG("Failed to allocate memory."); + g_supplicant_free_scan_params(scan_params); + return -ENOMEM; + } + + memcpy(scan_ssid->ssid, ssid, (ssid_len + 1)); + DBG("scan ssid %s len: %d", scan_ssid->ssid, ssid_len); + scan_ssid->ssid_len = ssid_len; + scan_params->ssids = g_slist_prepend(scan_params->ssids, scan_ssid); + ap_count++; + + } else { /* freq */ + freq = atoi(((connman_multi_scan_ap_s *)list->data)->str); + scan_params->freqs[freq_count] = freq; + DBG("scan_params->freqs[%d]: %d", freq_count, scan_params->freqs[freq_count]); + freq_count++; + } + } + scan_params->num_ssids = ap_count; + scan_params->num_freqs = freq_count; } else { DBG("Invalid scan"); return -EINVAL; |