software/drivers/sd8887/src/wlan/mlinux/moal_ioctl.c
/**
 *  @brief set bgscan config
 *
 *  @param priv                 A pointer to moal_private structure
 *  @param buf                  A pointer to scan command buf
 *  @param length               buf length
 *
 *  @return                     MLAN_STATUS_SUCCESS -- success, otherwise fail
 */
@brief set bgscan config
@param priv                 A pointer to moal_private structure
@param buf                  A pointer to scan command buf
@param length               buf length

@return                     MLAN_STATUS_SUCCESS -- success, otherwise fail
@brief set bgscan config @param priv A pointer to moal_private structure @param buf A pointer to scan command buf @param length buf length @return MLAN_STATUS_SUCCESS -- success otherwise fail
mlan_status
woal_set_bg_scan(moal_private *priv, char *buf, int length)
{
	t_u8 *ptr = buf + strlen("BGSCAN-CONFIG") + 1;
	int buf_left = length - (strlen("BGSCAN-CONFIG") + 1);
	int band = 0;
	int num_ssid = 0;
	int ssid_len = 0;
	mlan_status ret = MLAN_STATUS_FAILURE;
	ENTER();
	memset(&priv->scan_cfg, 0, sizeof(priv->scan_cfg));
	priv->scan_cfg.report_condition =
		BG_SCAN_SSID_MATCH | BG_SCAN_WAIT_ALL_CHAN_DONE;
	while (buf_left >= 2) {
		switch (*ptr) {
		case WEXT_CSCAN_SSID_SECTION:
			ssid_len = *(ptr + 1);
			if ((buf_left < (ssid_len + 2)) ||
			    (ssid_len > MLAN_MAX_SSID_LENGTH)) {
				PRINTM(MERROR,
				       "Invalid ssid, buf_left=%d, ssid_len=%d\n",
				       buf_left, ssid_len);
				buf_left = 0;
				break;
			}
			if (ssid_len &&
			    (num_ssid < (MRVDRV_MAX_SSID_LIST_LENGTH - 1))) {
				strncpy(priv->scan_cfg.ssid_list[num_ssid].ssid,
					ptr + 2, ssid_len);
				priv->scan_cfg.ssid_list[num_ssid].max_len = 0;
				PRINTM(MIOCTL, "BG scan: ssid=%s\n",
				       priv->scan_cfg.ssid_list[num_ssid].ssid);
				num_ssid++;
			}
			buf_left -= ssid_len + 2;
			ptr += ssid_len + 2;
			break;
		case WEXT_BGSCAN_RSSI_SECTION:
			priv->scan_cfg.report_condition =
				BG_SCAN_SSID_RSSI_MATCH |
				BG_SCAN_WAIT_ALL_CHAN_DONE;
			priv->scan_cfg.rssi_threshold = ptr[1];
			PRINTM(MIOCTL, "BG scan: rssi_threshold=%d\n",
			       (int)priv->scan_cfg.rssi_threshold);
			ptr += 2;
			buf_left -= 2;
			break;
		case WEXT_BGSCAN_REPEAT_SECTION:
			priv->scan_cfg.repeat_count = (t_u16)ptr[1];
			PRINTM(MIOCTL, "BG scan: repeat_count=%d\n",
			       (int)priv->scan_cfg.repeat_count);
			ptr += 2;
			buf_left -= 2;
			break;
		case WEXT_BGSCAN_INTERVAL_SECTION:
			if (buf_left < 3) {
				PRINTM(MERROR,
				       "Invalid scan_interval, buf_left=%d\n",
				       buf_left);
				buf_left = 0;
				break;
			}
			priv->scan_cfg.scan_interval =
				(ptr[2] << 8 | ptr[1]) * 1000;
			PRINTM(MIOCTL, "BG scan: scan_interval=%d\n",
			       (int)priv->scan_cfg.scan_interval);
			ptr += 3;
			buf_left -= 3;
			break;
		default:
			buf_left = 0;
			break;
		}
	}
	if (num_ssid) {
		if (MLAN_STATUS_SUCCESS != woal_get_band(priv, &band)) {
			ret = MLAN_STATUS_FAILURE;
			goto done;
		}
		switch (band) {
		case WIFI_FREQUENCY_BAND_2GHZ:
			priv->scan_cfg.chan_list[0].radio_type =
				0 | BAND_SPECIFIED;
			break;
		case WIFI_FREQUENCY_BAND_5GHZ:
			priv->scan_cfg.chan_list[0].radio_type =
				1 | BAND_SPECIFIED;
			break;
		default:
			break;
		}
		priv->scan_cfg.bss_type = MLAN_BSS_MODE_INFRA;
		priv->scan_cfg.action = BG_SCAN_ACT_SET;
		priv->scan_cfg.enable = MTRUE;
		ret = woal_request_bgscan(priv, MOAL_IOCTL_WAIT,
					  &priv->scan_cfg);
	}
done:
	LEAVE();
	return ret;
}
mlan_status woal_set_bg_scan ( moal_private * priv , char * buf , int length ) { t_u8 * ptr = buf + strlen ( " " ) + 1 ; int buf_left = length - ( strlen ( " " ) + 1 ) ; int band = 0 ; int num_ssid = 0 ; int ssid_len = 0 ; mlan_status ret = MLAN_STATUS_FAILURE ; ENTER ( ) ; memset ( & priv -> scan_cfg , 0 , sizeof ( priv -> scan_cfg ) ) ; priv -> scan_cfg . report_condition = BG_SCAN_SSID_MATCH | BG_SCAN_WAIT_ALL_CHAN_DONE ; while ( buf_left >= 2 ) { switch ( * ptr ) { case WEXT_CSCAN_SSID_SECTION : ssid_len = * ( ptr + 1 ) ; if ( ( buf_left < ( ssid_len + 2 ) ) || ( ssid_len > MLAN_MAX_SSID_LENGTH ) ) { PRINTM ( MERROR , " \n " , buf_left , ssid_len ) ; buf_left = 0 ; break ; } if ( ssid_len && ( num_ssid < ( MRVDRV_MAX_SSID_LIST_LENGTH - 1 ) ) ) { strncpy ( priv -> scan_cfg . ssid_list [ num_ssid ] . ssid , ptr + 2 , ssid_len ) ; priv -> scan_cfg . ssid_list [ num_ssid ] . max_len = 0 ; PRINTM ( MIOCTL , " \n " , priv -> scan_cfg . ssid_list [ num_ssid ] . ssid ) ; num_ssid ++ ; } buf_left -= ssid_len + 2 ; ptr += ssid_len + 2 ; break ; case WEXT_BGSCAN_RSSI_SECTION : priv -> scan_cfg . report_condition = BG_SCAN_SSID_RSSI_MATCH | BG_SCAN_WAIT_ALL_CHAN_DONE ; priv -> scan_cfg . rssi_threshold = ptr [ 1 ] ; PRINTM ( MIOCTL , " \n " , ( int ) priv -> scan_cfg . rssi_threshold ) ; ptr += 2 ; buf_left -= 2 ; break ; case WEXT_BGSCAN_REPEAT_SECTION : priv -> scan_cfg . repeat_count = ( t_u16 ) ptr [ 1 ] ; PRINTM ( MIOCTL , " \n " , ( int ) priv -> scan_cfg . repeat_count ) ; ptr += 2 ; buf_left -= 2 ; break ; case WEXT_BGSCAN_INTERVAL_SECTION : if ( buf_left < 3 ) { PRINTM ( MERROR , " \n " , buf_left ) ; buf_left = 0 ; break ; } priv -> scan_cfg . scan_interval = ( ptr [ 2 ] << 8 | ptr [ 1 ] ) * 1000 ; PRINTM ( MIOCTL , " \n " , ( int ) priv -> scan_cfg . scan_interval ) ; ptr += 3 ; buf_left -= 3 ; break ; default : buf_left = 0 ; break ; } } if ( num_ssid ) { if ( MLAN_STATUS_SUCCESS != woal_get_band ( priv , & band ) ) { ret = MLAN_STATUS_FAILURE ; goto done ; } switch ( band ) { case WIFI_FREQUENCY_BAND_2GHZ : priv -> scan_cfg . chan_list [ 0 ] . radio_type = 0 | BAND_SPECIFIED ; break ; case WIFI_FREQUENCY_BAND_5GHZ : priv -> scan_cfg . chan_list [ 0 ] . radio_type = 1 | BAND_SPECIFIED ; break ; default : break ; } priv -> scan_cfg . bss_type = MLAN_BSS_MODE_INFRA ; priv -> scan_cfg . action = BG_SCAN_ACT_SET ; priv -> scan_cfg . enable = MTRUE ; ret = woal_request_bgscan ( priv , MOAL_IOCTL_WAIT , & priv -> scan_cfg ) ; } done : LEAVE ( ) ; return ret ; }
@brief set bgscan config
  @param priv                 A pointer to moal_private structure
  @param buf                  A pointer to scan command buf
  @param length               buf length
@brief set bgscan config @param priv A pointer to moal_private structure @param buf A pointer to scan command buf @param length buf length
/** set bgscan when ssid_num > 0 */