/* listen mode */ static void listen(bcm_p2p_discovery_t *disc, uint16 timeout) { wl_p2p_state(disc->drv, WL_P2P_DISC_ST_LISTEN, CH20MHZ_CHSPEC(disc->listenChannel), timeout); WL_P2PO(("listen timer started %d msec\n", timeout)); tmrStart(disc->listenTimer, timeout, FALSE); change_state(disc, STATE_LISTEN); }
static int wl_scan(int unit) { wl_scan_results_t *list = (wl_scan_results_t*)scan_result; wl_bss_info_t *bi; wl_bss_info_107_t *old_bi; uint i, ap_count = 0; char ssid_str[128], macstr[18]; if (wl_get_scan_results(unit) == NULL) return 0; memset(ap_list, 0, sizeof(ap_list)); if (list->count == 0) return 0; else if (list->version != WL_BSS_INFO_VERSION && list->version != LEGACY_WL_BSS_INFO_VERSION && list->version != LEGACY2_WL_BSS_INFO_VERSION) { /* fprintf(stderr, "Sorry, your driver has bss_info_version %d " "but this program supports only version %d.\n", list->version, WL_BSS_INFO_VERSION); */ return 0; } bi = list->bss_info; for (i = 0; i < list->count; i++) { /* Convert version 107 to 109 */ if (dtoh32(bi->version) == LEGACY_WL_BSS_INFO_VERSION) { old_bi = (wl_bss_info_107_t *)bi; bi->chanspec = CH20MHZ_CHSPEC(old_bi->channel); bi->ie_length = old_bi->ie_length; bi->ie_offset = sizeof(wl_bss_info_107_t); } if (bi->ie_length) { if (ap_count < WLC_MAX_AP_SCAN_LIST_LEN){ ap_list[ap_count].used = TRUE; memcpy(ap_list[ap_count].BSSID, (uint8 *)&bi->BSSID, 6); strncpy((char *)ap_list[ap_count].ssid, (char *)bi->SSID, bi->SSID_len); ap_list[ap_count].ssid[bi->SSID_len] = '\0'; ap_list[ap_count].ssidLen= bi->SSID_len; ap_list[ap_count].ie_buf = (uint8 *)(((uint8 *)bi) + bi->ie_offset); ap_list[ap_count].ie_buflen = bi->ie_length; ap_list[ap_count].channel = (uint8)(bi->chanspec & WL_CHANSPEC_CHAN_MASK); ap_list[ap_count].wep = bi->capability & DOT11_CAP_PRIVACY; ap_count++; } } bi = (wl_bss_info_t*)((int8*)bi + bi->length); } if (ap_count) { if (psta_debug) dbg("%-4s%-33s%-18s\n", "Ch", "SSID", "BSSID"); for (i = 0; i < ap_count; i++) { memset(ssid_str, 0, sizeof(ssid_str)); char_to_ascii(ssid_str, (const char *) trim_r(ap_list[i].ssid)); ether_etoa((const unsigned char *) &ap_list[i].BSSID, macstr); if (psta_debug) dbg("%-4d%-33s%-18s\n", ap_list[i].channel, ap_list[i].ssid, macstr ); } } return ap_count; }