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

@return                     0 -- success, otherwise fail
@brief set combo scan @param priv A pointer to moal_private structure @param buf A pointer to scan command buf @param length buf length @return 0 -- success otherwise fail
int
woal_set_combo_scan(moal_private *priv, char *buf, int length)
{
	int ret = 0;
	wlan_user_scan_cfg scan_cfg;
	t_u8 *ptr = buf + WEXT_CSCAN_HEADER_SIZE;
	int buf_left = length - WEXT_CSCAN_HEADER_SIZE;
	int num_ssid = 0;
	int num_chan = 0;
	int ssid_len = 0;
	int i = 0;
	t_u16 passive_scan_time = 0;
	t_u16 specific_scan_time = 0;
	ENTER();
	memset(&scan_cfg, 0, sizeof(scan_cfg));
	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(scan_cfg.ssid_list[num_ssid].ssid,
					ptr + 2, ssid_len);
				scan_cfg.ssid_list[num_ssid].max_len = 0;
				PRINTM(MIOCTL, "Combo scan: ssid=%s\n",
				       scan_cfg.ssid_list[num_ssid].ssid);
				num_ssid++;
			}
			buf_left -= ssid_len + 2;
			ptr += ssid_len + 2;
			break;
		case WEXT_CSCAN_CHANNEL_SECTION:
			num_chan = ptr[1];
			if ((buf_left < (num_chan + 2)) ||
			    (num_chan > WLAN_USER_SCAN_CHAN_MAX)) {
				PRINTM(MERROR,
				       "Invalid channel list, buf_left=%d, num_chan=%d\n",
				       buf_left, num_chan);
				buf_left = 0;
				break;
			}
			for (i = 0; i < num_chan; i++) {
				scan_cfg.chan_list[i].chan_number = ptr[2 + i];
				PRINTM(MIOCTL, "Combo scan: chan=%d\n",
				       scan_cfg.chan_list[i].chan_number);
			}
			buf_left -= 2 + num_chan;
			ptr += 2 + num_chan;
			break;
		case WEXT_CSCAN_PASV_DWELL_SECTION:
			if (buf_left < 3) {
				PRINTM(MERROR,
				       "Invalid PASV_DWELL_SECTION, buf_left=%d\n",
				       buf_left);
				buf_left = 0;
				break;
			}
			passive_scan_time = ptr[2] << 8 | ptr[1];
			ptr += 3;
			buf_left -= 3;
			break;
		case WEXT_CSCAN_HOME_DWELL_SECTION:
			if (buf_left < 3) {
				PRINTM(MERROR,
				       "Invalid HOME_DWELL_SECTION, buf_left=%d\n",
				       buf_left);
				buf_left = 0;
				break;
			}
			specific_scan_time = ptr[2] << 8 | ptr[1];
			ptr += 3;
			buf_left -= 3;
			break;
		default:
			buf_left = 0;
			break;
		}
	}
	if (passive_scan_time || specific_scan_time) {
		PRINTM(MIOCTL,
		       "Set passive_scan_time=%d specific_scan_time=%d\n",
		       passive_scan_time, specific_scan_time);
		if (MLAN_STATUS_FAILURE ==
		    woal_set_scan_time(priv, 0, passive_scan_time,
				       specific_scan_time)) {
			ret = -EFAULT;
			goto done;
		}
	}
	if (num_ssid || num_chan) {
		if (num_ssid) {
			scan_cfg.ssid_list[num_ssid].max_len = 0xff;
			if (priv->scan_type == MLAN_SCAN_TYPE_PASSIVE)
				woal_set_scan_type(priv, MLAN_SCAN_TYPE_ACTIVE);
		}
		if (MLAN_STATUS_FAILURE == woal_do_scan(priv, &scan_cfg))
			ret = -EFAULT;
		if (num_ssid && (priv->scan_type == MLAN_SCAN_TYPE_PASSIVE))
			woal_set_scan_type(priv, MLAN_SCAN_TYPE_PASSIVE);
	} else {
		if (MLAN_STATUS_FAILURE == woal_do_scan(priv, NULL))
			ret = -EFAULT;
	}
done:
	LEAVE();
	return ret;
}
int woal_set_combo_scan ( moal_private * priv , char * buf , int length ) { int ret = 0 ; wlan_user_scan_cfg scan_cfg ; t_u8 * ptr = buf + WEXT_CSCAN_HEADER_SIZE ; int buf_left = length - WEXT_CSCAN_HEADER_SIZE ; int num_ssid = 0 ; int num_chan = 0 ; int ssid_len = 0 ; int i = 0 ; t_u16 passive_scan_time = 0 ; t_u16 specific_scan_time = 0 ; ENTER ( ) ; memset ( & scan_cfg , 0 , sizeof ( scan_cfg ) ) ; 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 ( scan_cfg . ssid_list [ num_ssid ] . ssid , ptr + 2 , ssid_len ) ; scan_cfg . ssid_list [ num_ssid ] . max_len = 0 ; PRINTM ( MIOCTL , " \n " , scan_cfg . ssid_list [ num_ssid ] . ssid ) ; num_ssid ++ ; } buf_left -= ssid_len + 2 ; ptr += ssid_len + 2 ; break ; case WEXT_CSCAN_CHANNEL_SECTION : num_chan = ptr [ 1 ] ; if ( ( buf_left < ( num_chan + 2 ) ) || ( num_chan > WLAN_USER_SCAN_CHAN_MAX ) ) { PRINTM ( MERROR , " \n " , buf_left , num_chan ) ; buf_left = 0 ; break ; } for ( i = 0 ; i < num_chan ; i ++ ) { scan_cfg . chan_list [ i ] . chan_number = ptr [ 2 + i ] ; PRINTM ( MIOCTL , " \n " , scan_cfg . chan_list [ i ] . chan_number ) ; } buf_left -= 2 + num_chan ; ptr += 2 + num_chan ; break ; case WEXT_CSCAN_PASV_DWELL_SECTION : if ( buf_left < 3 ) { PRINTM ( MERROR , " \n " , buf_left ) ; buf_left = 0 ; break ; } passive_scan_time = ptr [ 2 ] << 8 | ptr [ 1 ] ; ptr += 3 ; buf_left -= 3 ; break ; case WEXT_CSCAN_HOME_DWELL_SECTION : if ( buf_left < 3 ) { PRINTM ( MERROR , " \n " , buf_left ) ; buf_left = 0 ; break ; } specific_scan_time = ptr [ 2 ] << 8 | ptr [ 1 ] ; ptr += 3 ; buf_left -= 3 ; break ; default : buf_left = 0 ; break ; } } if ( passive_scan_time || specific_scan_time ) { PRINTM ( MIOCTL , " \n " , passive_scan_time , specific_scan_time ) ; if ( MLAN_STATUS_FAILURE == woal_set_scan_time ( priv , 0 , passive_scan_time , specific_scan_time ) ) { ret = - EFAULT ; goto done ; } } if ( num_ssid || num_chan ) { if ( num_ssid ) { scan_cfg . ssid_list [ num_ssid ] . max_len = 0xff ; if ( priv -> scan_type == MLAN_SCAN_TYPE_PASSIVE ) woal_set_scan_type ( priv , MLAN_SCAN_TYPE_ACTIVE ) ; } if ( MLAN_STATUS_FAILURE == woal_do_scan ( priv , & scan_cfg ) ) ret = - EFAULT ; if ( num_ssid && ( priv -> scan_type == MLAN_SCAN_TYPE_PASSIVE ) ) woal_set_scan_type ( priv , MLAN_SCAN_TYPE_PASSIVE ) ; } else { if ( MLAN_STATUS_FAILURE == woal_do_scan ( priv , NULL ) ) ret = - EFAULT ; } done : LEAVE ( ) ; return ret ; }
@brief set combo scan
  @param priv                 A pointer to moal_private structure
  @param buf                  A pointer to scan command buf
  @param length               buf length
@brief set combo scan @param priv A pointer to moal_private structure @param buf A pointer to scan command buf @param length buf length
/* Add broadcast scan to ssid_list */ /* request broadcast scan */