software/drivers/sd8887/src/wlan/mlinux/moal_ioctl.c
/**
 *  @brief Change Adhoc Channel
 *
 *  @param priv         A pointer to moal_private structure
 *  @param channel      The channel to be set.
 *  @param wait_option  wait_option
 *
 *  @return             MLAN_STATUS_SUCCESS--success, MLAN_STATUS_FAILURE--fail
 */
@brief Change Adhoc Channel
@param priv         A pointer to moal_private structure
@param channel      The channel to be set.


@brief Change Adhoc Channel @param priv A pointer to moal_private structure @param channel The channel to be set .
mlan_status
woal_change_adhoc_chan(moal_private *priv, int channel, t_u8 wait_option)
{
	mlan_status ret = MLAN_STATUS_SUCCESS;
	mlan_bss_info bss_info;
	mlan_ds_bss *bss = NULL;
	mlan_ioctl_req *req = NULL;
	ENTER();
	memset(&bss_info, 0, sizeof(bss_info));
	if (MLAN_STATUS_SUCCESS !=
	    woal_get_bss_info(priv, wait_option, &bss_info)) {
		ret = MLAN_STATUS_FAILURE;
		goto done;
	}
	if (bss_info.bss_mode == MLAN_BSS_MODE_INFRA) {
		ret = MLAN_STATUS_SUCCESS;
		goto done;
	}
	req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
	if (req == NULL) {
		ret = MLAN_STATUS_FAILURE;
		goto done;
	}
	bss = (mlan_ds_bss *)req->pbuf;
	bss->sub_command = MLAN_OID_IBSS_CHANNEL;
	req->req_id = MLAN_IOCTL_BSS;
	req->action = MLAN_ACT_GET;
	ret = woal_request_ioctl(priv, req, wait_option);
	if (ret != MLAN_STATUS_SUCCESS)
		goto done;
	if (bss->param.bss_chan.channel == (unsigned int)channel) {
		ret = MLAN_STATUS_SUCCESS;
		goto done;
	}
	PRINTM(MINFO, "Updating Channel from %d to %d\n",
	       (int)bss->param.bss_chan.channel, channel);
	if (bss_info.media_connected != MTRUE) {
		ret = MLAN_STATUS_SUCCESS;
		goto done;
	}
	bss->sub_command = MLAN_OID_BSS_STOP;
	memset((t_u8 *)&bss->param.bssid, 0, ETH_ALEN);
	ret = woal_request_ioctl(priv, req, wait_option);
	if (ret != MLAN_STATUS_SUCCESS)
		goto done;
	if (MLAN_STATUS_SUCCESS !=
	    woal_request_scan(priv, wait_option, &bss_info.ssid)) {
		ret = MLAN_STATUS_FAILURE;
		goto done;
	}
	bss->sub_command = MLAN_OID_BSS_START;
	memset(&bss->param.ssid_bssid, 0, sizeof(mlan_ssid_bssid));
	memcpy(&bss->param.ssid_bssid.ssid, &bss_info.ssid,
	       sizeof(mlan_802_11_ssid));
	ret = woal_request_ioctl(priv, req, wait_option);
done:
	if (ret != MLAN_STATUS_PENDING)
		kfree(req);
	LEAVE();
	return ret;
}
mlan_status woal_change_adhoc_chan ( moal_private * priv , int channel , t_u8 wait_option ) { mlan_status ret = MLAN_STATUS_SUCCESS ; mlan_bss_info bss_info ; mlan_ds_bss * bss = NULL ; mlan_ioctl_req * req = NULL ; ENTER ( ) ; memset ( & bss_info , 0 , sizeof ( bss_info ) ) ; if ( MLAN_STATUS_SUCCESS != woal_get_bss_info ( priv , wait_option , & bss_info ) ) { ret = MLAN_STATUS_FAILURE ; goto done ; } if ( bss_info . bss_mode == MLAN_BSS_MODE_INFRA ) { ret = MLAN_STATUS_SUCCESS ; goto done ; } req = woal_alloc_mlan_ioctl_req ( sizeof ( mlan_ds_bss ) ) ; if ( req == NULL ) { ret = MLAN_STATUS_FAILURE ; goto done ; } bss = ( mlan_ds_bss * ) req -> pbuf ; bss -> sub_command = MLAN_OID_IBSS_CHANNEL ; req -> req_id = MLAN_IOCTL_BSS ; req -> action = MLAN_ACT_GET ; ret = woal_request_ioctl ( priv , req , wait_option ) ; if ( ret != MLAN_STATUS_SUCCESS ) goto done ; if ( bss -> param . bss_chan . channel == ( unsigned int ) channel ) { ret = MLAN_STATUS_SUCCESS ; goto done ; } PRINTM ( MINFO , " \n " , ( int ) bss -> param . bss_chan . channel , channel ) ; if ( bss_info . media_connected != MTRUE ) { ret = MLAN_STATUS_SUCCESS ; goto done ; } bss -> sub_command = MLAN_OID_BSS_STOP ; memset ( ( t_u8 * ) & bss -> param . bssid , 0 , ETH_ALEN ) ; ret = woal_request_ioctl ( priv , req , wait_option ) ; if ( ret != MLAN_STATUS_SUCCESS ) goto done ; if ( MLAN_STATUS_SUCCESS != woal_request_scan ( priv , wait_option , & bss_info . ssid ) ) { ret = MLAN_STATUS_FAILURE ; goto done ; } bss -> sub_command = MLAN_OID_BSS_START ; memset ( & bss -> param . ssid_bssid , 0 , sizeof ( mlan_ssid_bssid ) ) ; memcpy ( & bss -> param . ssid_bssid . ssid , & bss_info . ssid , sizeof ( mlan_802_11_ssid ) ) ; ret = woal_request_ioctl ( priv , req , wait_option ) ; done : if ( ret != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Change Adhoc Channel
  @param priv         A pointer to moal_private structure
  @param channel      The channel to be set.
@brief Change Adhoc Channel @param priv A pointer to moal_private structure @param channel The channel to be set .
/* Get BSS information */ /* Allocate an IOCTL request buffer */ /* Get current channel */ /* Send IOCTL request to MLAN */ /* Do disonnect */ /* Send IOCTL request to MLAN */ /* Do specific SSID scanning */ /* Start/Join Adhoc network */ /* Send IOCTL request to MLAN */