Beispiel #1
0
/*=============================================================================
FUNCTION:		c_rpc_qcsapi_get_ap_properties
DESCRIPTION:		Get the scaned AP properties and print.
ARGUMENTS PASSED:
RETURN VALUE:		0:success, other:error
=============================================================================*/
int c_rpc_qcsapi_get_ap_properties()
{
	int ret,i;
	unsigned int ap_count = 0;
	qcsapi_ap_properties ap_current;

	//Get the scaned AP count
	ret = qcsapi_wifi_get_results_AP_scan(WIFINAME, &ap_count);
	if (ret < 0) {
		printf("Qcsapi qcsapi_wifi_get_results_AP_scan error, return: %d\n", ret);
		return -1;
	}
	if (ap_count == 0) {
		printf("Scaned ap count is 0\n");
		return -1;
	}
	for (i = 0; i < ap_count; i++) {
		ret = qcsapi_wifi_get_properties_AP(WIFINAME, i, &ap_current);
		if (ret < 0) {
			printf("Qcsapi qcsapi_wifi_get_properties_AP error, return: %d\n", ret);
			return -1;
		}
		printf
		    ("AP %02d:\tSSID:%30s\tMAC:%02X:%02X:%02X:%02X:%02X:%02X\tSecurity:%d\tRSSI:%02d\tChannel:%02d\tWPS:%d\n",
		     i, ap_current.ap_name_SSID, ap_current.ap_mac_addr[0], ap_current.ap_mac_addr[1],
		     ap_current.ap_mac_addr[2], ap_current.ap_mac_addr[3], ap_current.ap_mac_addr[4],
		     ap_current.ap_mac_addr[5], ap_current.ap_flags, (ap_current.ap_RSSI-90),
		     ap_current.ap_channel, ap_current.ap_wps);
	}
	return 0;
}
Beispiel #2
0
int wlcscan_core_qtn(char *ofile, char *ifname)
{
	int i;
	int scanstatus = -1;
	uint32_t count;
	qcsapi_ap_properties	params;
	char buff[256];
	FILE *fp_apscan;

	if (!rpc_qtn_ready()) {
		dbG("5 GHz radio is not ready\n");
		return -1;
	}

	logmessage("wlcscan", "start wlcscan scan\n");

	/* clean APSCAN_INFO */
	lock_qtn_apscan = file_lock("sitesurvey");
	if((fp_apscan = fopen(ofile, "a")) != NULL){
		fclose(fp_apscan);
	}
	file_unlock(lock_qtn_apscan);
	
	// start scan AP
	// if(qcsapi_wifi_start_scan(ifname)){
	if(qcsapi_wifi_start_scan_ext(ifname, IEEE80211_PICK_ALL | IEEE80211_PICK_NOPICK_BG)){
		dbg("fail to start AP scan\n");
		return 0;
	}
	fprintf(stderr, "ok to start AP scan\n");

	// loop for check scan status
	while(1){
		if(qcsapi_wifi_get_scan_status(ifname, &scanstatus) < 0){
			dbg("scan error occurs\n");
			return 0;
		}
		
		// if scanstatus = 0 , no scan is running
		if(scanstatus == 0) break;
		else{
			dbg("scan is running...\n");
			sleep(1);
		}
	}

	// check AP scan
	if(qcsapi_wifi_get_results_AP_scan(ifname, &count) < 0){
		dbg("fail to get AP scan results, ifname=%s, count=%d\n", ifname, (int)count);
		return 0;
	}

	if((int)count > 0){
		if((fp_apscan = fopen(ofile, "a")) == NULL){
			dbg("fail to write to [%s]\n", ofile);
			return 0;
		}
		else{
			// for loop
			for(i = 0; i < (int)count; i++){
				// get properties of AP
				if(!qcsapi_wifi_get_properties_AP(ifname, (uint32_t)i, &params)){
					show_ap_properties((uint32_t)i, &params, buff);
					fprintf(fp_apscan, "%s", buff);
				}
				else{
					dbg("fail to get AP properties\n");
					fclose(fp_apscan);
				}

				if (i == (int)count - 1){
					fprintf(fp_apscan, "\n");
				}else{
					fprintf(fp_apscan, "\n");
				}
			}
			// for loop
		}
	}
	fclose(fp_apscan);
	return 1;
}