software/drivers/sd8887/src/wlan/mapp/uaputl/uaputl.c
/**
 *    @brief Show usage information for the sys_cfg_pmf command
 *
 *    @param argc     Number of arguments
 *    @param argv     Pointer to the arguments
 *
 *    @return         UAP_SUCCESS or UAP_FAILURE
 */
@brief Show usage information for the sys_cfg_pmf command
@param argc     Number of arguments
@param argv     Pointer to the arguments


@brief Show usage information for the sys_cfg_pmf command @param argc Number of arguments @param argv Pointer to the arguments
int
apcmd_sys_cfg_pmf(int argc, char *argv[])
{
	int opt;
	apcmdbuf_pmf_params *cmd_buf = NULL;
	t_u8 *buf = NULL;
	t_u16 cmd_len = 0;
	t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER;
	int ret = UAP_SUCCESS;
	t_u8 mfpc = 0;
	t_u8 mfpr = 0;
	while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
		switch (opt) {
		default:
			print_sys_cfg_pmf();
			return UAP_SUCCESS;
		}
	}
	argc -= optind;
	argv += optind;
	if ((argc > 2)) {
		printf("ERR:wrong arguments.\n");
		print_sys_cfg_pmf();
		return UAP_FAILURE;
	}
	if (argc > 0)
		mfpc = atoi(argv[0]);
	if (mfpc && (argc == 1)) {
		printf("ERR:wrong arguments.\n");
		print_sys_cfg_pmf();
		return UAP_FAILURE;
	}
	if (mfpc && (argc == 2))
		mfpr = atoi(argv[1]);
	buf = (t_u8 *)malloc(buf_len);
	if (!buf) {
		printf("ERR:Cannot allocate buffer from command!\n");
		return UAP_FAILURE;
	}
	memset(buf, 0, buf_len);
	cmd_len = sizeof(apcmdbuf_pmf_params);
	cmd_buf = (apcmdbuf_pmf_params *) buf;
	cmd_buf->size = cmd_len - BUF_HEADER_SIZE;
	cmd_buf->seq_num = 0;
	cmd_buf->result = 0;
	cmd_buf->cmd_code = HostCmd_CMD_PMF_PARAMS;
	if (argc == 0)
		cmd_buf->action = ACTION_GET;
	else
		cmd_buf->action = ACTION_SET;
	cmd_buf->action = uap_cpu_to_le16(cmd_buf->action);
	cmd_buf->params.mfpc = mfpc;
	cmd_buf->params.mfpr = mfpr;
	ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len);
	if (ret == UAP_SUCCESS) {
		if (cmd_buf->result == CMD_SUCCESS) {
			printf("Successfully executed the command\n");
			printf("mfpc: %d, mfpr: %d\n",
			       cmd_buf->params.mfpc, cmd_buf->params.mfpr);
		} else {
			printf("ERR:Command sending failed!\n");
			free(buf);
			return UAP_FAILURE;
		}
	} else {
		printf("ERR:Command sending failed!\n");
		free(buf);
		return UAP_FAILURE;
	}
	free(buf);
	return UAP_SUCCESS;
}
int apcmd_sys_cfg_pmf ( int argc , char * argv [ ] ) { int opt ; apcmdbuf_pmf_params * cmd_buf = NULL ; t_u8 * buf = NULL ; t_u16 cmd_len = 0 ; t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER ; int ret = UAP_SUCCESS ; t_u8 mfpc = 0 ; t_u8 mfpr = 0 ; while ( ( opt = getopt_long ( argc , argv , " " , cmd_options , NULL ) ) != -1 ) { switch ( opt ) { default : print_sys_cfg_pmf ( ) ; return UAP_SUCCESS ; } } argc -= optind ; argv += optind ; if ( ( argc > 2 ) ) { printf ( " \n " ) ; print_sys_cfg_pmf ( ) ; return UAP_FAILURE ; } if ( argc > 0 ) mfpc = atoi ( argv [ 0 ] ) ; if ( mfpc && ( argc == 1 ) ) { printf ( " \n " ) ; print_sys_cfg_pmf ( ) ; return UAP_FAILURE ; } if ( mfpc && ( argc == 2 ) ) mfpr = atoi ( argv [ 1 ] ) ; buf = ( t_u8 * ) malloc ( buf_len ) ; if ( ! buf ) { printf ( " \n " ) ; return UAP_FAILURE ; } memset ( buf , 0 , buf_len ) ; cmd_len = sizeof ( apcmdbuf_pmf_params ) ; cmd_buf = ( apcmdbuf_pmf_params * ) buf ; cmd_buf -> size = cmd_len - BUF_HEADER_SIZE ; cmd_buf -> seq_num = 0 ; cmd_buf -> result = 0 ; cmd_buf -> cmd_code = HostCmd_CMD_PMF_PARAMS ; if ( argc == 0 ) cmd_buf -> action = ACTION_GET ; else cmd_buf -> action = ACTION_SET ; cmd_buf -> action = uap_cpu_to_le16 ( cmd_buf -> action ) ; cmd_buf -> params . mfpc = mfpc ; cmd_buf -> params . mfpr = mfpr ; ret = uap_ioctl ( ( t_u8 * ) cmd_buf , & cmd_len , buf_len ) ; if ( ret == UAP_SUCCESS ) { if ( cmd_buf -> result == CMD_SUCCESS ) { printf ( " \n " ) ; printf ( " \n " , cmd_buf -> params . mfpc , cmd_buf -> params . mfpr ) ; } else { printf ( " \n " ) ; free ( buf ) ; return UAP_FAILURE ; } } else { printf ( " \n " ) ; free ( buf ) ; return UAP_FAILURE ; } free ( buf ) ; return UAP_SUCCESS ; }
@brief Show usage information for the sys_cfg_pmf command
    @param argc     Number of arguments
    @param argv     Pointer to the arguments
@brief Show usage information for the sys_cfg_pmf command @param argc Number of arguments @param argv Pointer to the arguments
/* Check arguments */ /* Alloc buf for command */ /* Locate headers */ /* Fill the command buffer */ /* Send the command */ /* Process response */