software/drivers/sd8887/src/wlan/mapp/uaputl/uaputl.c
/**
 *  @brief Process host_cmd
 *
 *
 *  @param argc     Number of arguments
 *  @param argv     Pointer to the arguments
 *  @return         N/A
 */
@brief Process host_cmd
@param argc     Number of arguments
@param argv     Pointer to the arguments
@return         N/A
@brief Process host_cmd @param argc Number of arguments @param argv Pointer to the arguments @return N / A
int
apcmd_hostcmd(int argc, char *argv[])
{
	apcmdbuf *hdr;
	t_u8 *buffer = NULL;
	int ret = UAP_SUCCESS;
	t_u16 cmd_len = 0;
	t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER;
	char cmdname[256];
	if (argc <= 2) {
		printf("Error: invalid no of arguments\n");
		printf("Syntax: ./uaputl hostcmd <hostcmd.conf> <cmdname>\n");
		return UAP_FAILURE;
	}
	buffer = (t_u8 *)malloc(buf_len);
	if (!buffer) {
		printf("ERR:Cannot allocate buffer for command!\n");
		return UAP_FAILURE;
	}
	memset(buffer, 0, buf_len);
	sprintf(cmdname, "%s", argv[2]);
	ret = prepare_host_cmd_buffer(argv[1], cmdname, buffer);
	if (ret == UAP_FAILURE)
		goto _exit_;
	hdr = (apcmdbuf *)buffer;
	cmd_len = hdr->size + BUF_HEADER_SIZE;
	ret = uap_ioctl((t_u8 *)buffer, &cmd_len, buf_len);
	if (ret == UAP_SUCCESS) {
		hdr->cmd_code &= HostCmd_CMD_ID_MASK;
		if (!hdr->result) {
			printf("UAPHOSTCMD: CmdCode=%#04x, Size=%#04x, SeqNum=%#04x, Result=%#04x\n", hdr->cmd_code, hdr->size, hdr->seq_num, hdr->result);
			hexdump_data("payload",
				     (void *)(buffer + APCMDHEADERLEN),
				     hdr->size - (APCMDHEADERLEN -
						  BUF_HEADER_SIZE), ' ');
		} else
			printf("UAPHOSTCMD failed: CmdCode=%#04x, Size=%#04x, SeqNum=%#04x, Result=%#04x\n", hdr->cmd_code, hdr->size, hdr->seq_num, hdr->result);
	} else
		printf("ERR:Command sending failed!\n");
_exit_:
	if (buffer)
		free(buffer);
	return ret;
}
int apcmd_hostcmd ( int argc , char * argv [ ] ) { apcmdbuf * hdr ; t_u8 * buffer = NULL ; int ret = UAP_SUCCESS ; t_u16 cmd_len = 0 ; t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER ; char cmdname [ 256 ] ; if ( argc <= 2 ) { printf ( " \n " ) ; printf ( " \n " ) ; return UAP_FAILURE ; } buffer = ( t_u8 * ) malloc ( buf_len ) ; if ( ! buffer ) { printf ( " \n " ) ; return UAP_FAILURE ; } memset ( buffer , 0 , buf_len ) ; sprintf ( cmdname , " " , argv [ 2 ] ) ; ret = prepare_host_cmd_buffer ( argv [ 1 ] , cmdname , buffer ) ; if ( ret == UAP_FAILURE ) goto _exit_ ; hdr = ( apcmdbuf * ) buffer ; cmd_len = hdr -> size + BUF_HEADER_SIZE ; ret = uap_ioctl ( ( t_u8 * ) buffer , & cmd_len , buf_len ) ; if ( ret == UAP_SUCCESS ) { hdr -> cmd_code &= HostCmd_CMD_ID_MASK ; if ( ! hdr -> result ) { printf ( " \n " , hdr -> cmd_code , hdr -> size , hdr -> seq_num , hdr -> result ) ; hexdump_data ( " " , ( void * ) ( buffer + APCMDHEADERLEN ) , hdr -> size - ( APCMDHEADERLEN - BUF_HEADER_SIZE ) , ' ' ) ; } else printf ( " \n " , hdr -> cmd_code , hdr -> size , hdr -> seq_num , hdr -> result ) ; } else printf ( " \n " ) ; _exit_ : if ( buffer ) free ( buffer ) ; return ret ; }
@brief Process host_cmd
  @param argc     Number of arguments
  @param argv     Pointer to the arguments
  @return         N/A
@brief Process host_cmd @param argc Number of arguments @param argv Pointer to the arguments @return N / A
/* Locate headers */ /* Send the command */ /* Process response */