software/drivers/sd8887/src/wlan/mlinux/moal_priv.c
/**
 *  @brief Set/get IP address
 *
 *  @param priv         A pointer to moal_private structure
 *  @param wrq          A pointer to iwreq structure
 *  @return             0 --success, otherwise fail
 */
@brief Set/get IP address
@param priv         A pointer to moal_private structure
@param wrq          A pointer to iwreq structure
@return             0 --success, otherwise fail
@brief Set / get IP address @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure @return 0 -- success otherwise fail
static int
woal_set_get_ip_addr(moal_private *priv, struct iwreq *wrq)
{
	char buf[IPADDR_MAX_BUF];
	mlan_ioctl_req *ioctl_req = NULL;
	mlan_ds_misc_cfg *misc = NULL;
	int ret = 0, op_code = 0, data_length = wrq->u.data.length;
	mlan_status status = MLAN_STATUS_SUCCESS;
	ENTER();
	memset(buf, 0, IPADDR_MAX_BUF);
	ioctl_req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
	if (ioctl_req == NULL) {
		ret = -ENOMEM;
		goto done;
	}
	misc = (mlan_ds_misc_cfg *)ioctl_req->pbuf;
	if (data_length <= 1) {	
		ioctl_req->action = MLAN_ACT_GET;
	} else {
		if (copy_from_user(buf, wrq->u.data.pointer,
				   MIN(IPADDR_MAX_BUF - 1, data_length))) {
			PRINTM(MERROR, "Copy from user failed\n");
			ret = -EFAULT;
			goto done;
		}
		if (data_length > 2 && buf[1] != ';') {
			PRINTM(MERROR,
			       "No operation argument. Separate with ';'\n");
			ret = -EINVAL;
			goto done;
		} else {
			buf[1] = '\0';
		}
		ioctl_req->action = MLAN_ACT_SET;
		memset(misc->param.ipaddr_cfg.ip_addr[0], 0, IPADDR_LEN);
		in4_pton(&buf[2], MIN((IPADDR_MAX_BUF - 3), (data_length - 2)),
			 misc->param.ipaddr_cfg.ip_addr[0], ' ', NULL);
		misc->param.ipaddr_cfg.ip_addr_num = 1;
		misc->param.ipaddr_cfg.ip_addr_type = IPADDR_TYPE_IPV4;
	}
	if (woal_atoi(&op_code, buf) != MLAN_STATUS_SUCCESS) {
		ret = -EINVAL;
		goto done;
	}
	misc->param.ipaddr_cfg.op_code = (t_u32)op_code;
	ioctl_req->req_id = MLAN_IOCTL_MISC_CFG;
	misc->sub_command = MLAN_OID_MISC_IP_ADDR;
	status = woal_request_ioctl(priv, ioctl_req, MOAL_IOCTL_WAIT);
	if (status != MLAN_STATUS_SUCCESS) {
		ret = -EFAULT;
		goto done;
	}
	if (ioctl_req->action == MLAN_ACT_GET) {
		snprintf(buf, IPADDR_MAX_BUF, "%d;%d.%d.%d.%d",
			 misc->param.ipaddr_cfg.op_code,
			 misc->param.ipaddr_cfg.ip_addr[0][0],
			 misc->param.ipaddr_cfg.ip_addr[0][1],
			 misc->param.ipaddr_cfg.ip_addr[0][2],
			 misc->param.ipaddr_cfg.ip_addr[0][3]);
		wrq->u.data.length = IPADDR_MAX_BUF;
		if (copy_to_user(wrq->u.data.pointer, buf, IPADDR_MAX_BUF)) {
			PRINTM(MERROR, "Copy to user failed\n");
			ret = -EFAULT;
		}
	}
done:
	if (status != MLAN_STATUS_PENDING)
		kfree(ioctl_req);
	LEAVE();
	return ret;
}
static int woal_set_get_ip_addr ( moal_private * priv , struct iwreq * wrq ) { char buf [ IPADDR_MAX_BUF ] ; mlan_ioctl_req * ioctl_req = NULL ; mlan_ds_misc_cfg * misc = NULL ; int ret = 0 , op_code = 0 , data_length = wrq -> u . data . length ; mlan_status status = MLAN_STATUS_SUCCESS ; ENTER ( ) ; memset ( buf , 0 , IPADDR_MAX_BUF ) ; ioctl_req = woal_alloc_mlan_ioctl_req ( sizeof ( mlan_ds_misc_cfg ) ) ; if ( ioctl_req == NULL ) { ret = - ENOMEM ; goto done ; } misc = ( mlan_ds_misc_cfg * ) ioctl_req -> pbuf ; if ( data_length <= 1 ) { ioctl_req -> action = MLAN_ACT_GET ; } else { if ( copy_from_user ( buf , wrq -> u . data . pointer , MIN ( IPADDR_MAX_BUF - 1 , data_length ) ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } if ( data_length > 2 && buf [ 1 ] != ' ' ) { PRINTM ( MERROR , " \n " ) ; ret = - EINVAL ; goto done ; } else { buf [ 1 ] = ' \0 ' ; } ioctl_req -> action = MLAN_ACT_SET ; memset ( misc -> param . ipaddr_cfg . ip_addr [ 0 ] , 0 , IPADDR_LEN ) ; in4_pton ( & buf [ 2 ] , MIN ( ( IPADDR_MAX_BUF - 3 ) , ( data_length - 2 ) ) , misc -> param . ipaddr_cfg . ip_addr [ 0 ] , ' ' , NULL ) ; misc -> param . ipaddr_cfg . ip_addr_num = 1 ; misc -> param . ipaddr_cfg . ip_addr_type = IPADDR_TYPE_IPV4 ; } if ( woal_atoi ( & op_code , buf ) != MLAN_STATUS_SUCCESS ) { ret = - EINVAL ; goto done ; } misc -> param . ipaddr_cfg . op_code = ( t_u32 ) op_code ; ioctl_req -> req_id = MLAN_IOCTL_MISC_CFG ; misc -> sub_command = MLAN_OID_MISC_IP_ADDR ; status = woal_request_ioctl ( priv , ioctl_req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } if ( ioctl_req -> action == MLAN_ACT_GET ) { snprintf ( buf , IPADDR_MAX_BUF , " " , misc -> param . ipaddr_cfg . op_code , misc -> param . ipaddr_cfg . ip_addr [ 0 ] [ 0 ] , misc -> param . ipaddr_cfg . ip_addr [ 0 ] [ 1 ] , misc -> param . ipaddr_cfg . ip_addr [ 0 ] [ 2 ] , misc -> param . ipaddr_cfg . ip_addr [ 0 ] [ 3 ] ) ; wrq -> u . data . length = IPADDR_MAX_BUF ; if ( copy_to_user ( wrq -> u . data . pointer , buf , IPADDR_MAX_BUF ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; } } done : if ( status != MLAN_STATUS_PENDING ) kfree ( ioctl_req ) ; LEAVE ( ) ; return ret ; }
@brief Set/get IP address
  @param priv         A pointer to moal_private structure
  @param wrq          A pointer to iwreq structure
  @return             0 --success, otherwise fail
@brief Set / get IP address @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure @return 0 -- success otherwise fail
/* GET */ /* Make sure we have the operation argument */ /* only one IP is supported in current firmware */ /* only one IP is supported in current firmware */ /* Send ioctl to mlan */