software/drivers/sd8887/src/wlan/mapp/uaputl/uaputl.c
/**
 *  @brief Creates a STA deauth request and sends to the driver
 *
 *   Usage: "sta_deauth <STA_MAC_ADDRESS>"
 *
 *  @param argc     Number of arguments
 *  @param argv     Pointer to the arguments
 *
 *  @return         UAP_SUCCESS/UAP_FAILURE
 */
@brief Creates a STA deauth request and sends to the driver
Usage: "sta_deauth "

@param argc     Number of arguments
@param argv     Pointer to the arguments


@brief Creates a STA deauth request and sends to the driver Usage : " sta_deauth " @param argc Number of arguments @param argv Pointer to the arguments
int
apcmd_sta_deauth(int argc, char *argv[])
{
	APCMDBUF_STA_DEAUTH *cmd_buf = NULL;
	t_u8 *buffer = NULL;
	t_u16 cmd_len = 0;
	t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER;
	int ret = UAP_FAILURE;
	int opt;
	while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
		switch (opt) {
		default:
			print_sta_deauth_usage();
			return UAP_SUCCESS;
		}
	}
	argc -= optind;
	argv += optind;
	if (argc != 1) {
		printf("ERR:wrong arguments! Must provide STA_MAC_ADDRESS.\n");
		print_sta_deauth_usage();
		return UAP_FAILURE;
	}
	cmd_len = sizeof(APCMDBUF_STA_DEAUTH);
	buffer = (t_u8 *)malloc(buf_len);
	if (!buffer) {
		printf("ERR:Cannot allocate buffer for command!\n");
		return UAP_FAILURE;
	}
	memset(buffer, 0, buf_len);
	cmd_buf = (APCMDBUF_STA_DEAUTH *)buffer;
	cmd_buf->cmd_code = APCMD_STA_DEAUTH;
	cmd_buf->size = cmd_len - BUF_HEADER_SIZE;
	cmd_buf->seq_num = 0;
	cmd_buf->result = 0;
	if ((ret = mac2raw(argv[0], cmd_buf->sta_mac_address)) != UAP_SUCCESS) {
		printf("ERR: %s Address\n", ret == UAP_FAILURE ? "Invalid MAC" :
		       ret ==
		       UAP_RET_MAC_BROADCAST ? "Broadcast" : "Multicast");
		free(buffer);
		return UAP_FAILURE;
	}
	ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len);
	if (ret == UAP_SUCCESS) {
		if (cmd_buf->cmd_code != (APCMD_STA_DEAUTH | APCMD_RESP_CHECK)) {
			printf("ERR:Corrupted response!\n");
			free(buffer);
			return UAP_FAILURE;
		}
		if (cmd_buf->result == CMD_SUCCESS) {
			printf("Deauthentication successful!\n");
		} else {
			printf("ERR:Deauthentication unsuccessful!\n");
			ret = UAP_FAILURE;
		}
	} else {
		printf("ERR:Command sending failed!\n");
	}
	if (buffer)
		free(buffer);
	return ret;
}
int apcmd_sta_deauth ( int argc , char * argv [ ] ) { APCMDBUF_STA_DEAUTH * cmd_buf = NULL ; t_u8 * buffer = NULL ; t_u16 cmd_len = 0 ; t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER ; int ret = UAP_FAILURE ; int opt ; while ( ( opt = getopt_long ( argc , argv , " " , cmd_options , NULL ) ) != -1 ) { switch ( opt ) { default : print_sta_deauth_usage ( ) ; return UAP_SUCCESS ; } } argc -= optind ; argv += optind ; if ( argc != 1 ) { printf ( " \n " ) ; print_sta_deauth_usage ( ) ; return UAP_FAILURE ; } cmd_len = sizeof ( APCMDBUF_STA_DEAUTH ) ; buffer = ( t_u8 * ) malloc ( buf_len ) ; if ( ! buffer ) { printf ( " \n " ) ; return UAP_FAILURE ; } memset ( buffer , 0 , buf_len ) ; cmd_buf = ( APCMDBUF_STA_DEAUTH * ) buffer ; cmd_buf -> cmd_code = APCMD_STA_DEAUTH ; cmd_buf -> size = cmd_len - BUF_HEADER_SIZE ; cmd_buf -> seq_num = 0 ; cmd_buf -> result = 0 ; if ( ( ret = mac2raw ( argv [ 0 ] , cmd_buf -> sta_mac_address ) ) != UAP_SUCCESS ) { printf ( " \n " , ret == UAP_FAILURE ? " " : ret == UAP_RET_MAC_BROADCAST ? " " : " " ) ; free ( buffer ) ; return UAP_FAILURE ; } ret = uap_ioctl ( ( t_u8 * ) cmd_buf , & cmd_len , buf_len ) ; if ( ret == UAP_SUCCESS ) { if ( cmd_buf -> cmd_code != ( APCMD_STA_DEAUTH | APCMD_RESP_CHECK ) ) { printf ( " \n " ) ; free ( buffer ) ; return UAP_FAILURE ; } if ( cmd_buf -> result == CMD_SUCCESS ) { printf ( " \n " ) ; } else { printf ( " \n " ) ; ret = UAP_FAILURE ; } } else { printf ( " \n " ) ; } if ( buffer ) free ( buffer ) ; return ret ; }
@brief Creates a STA deauth request and sends to the driver
   Usage: "sta_deauth <STA_MAC_ADDRESS>"
@brief Creates a STA deauth request and sends to the driver Usage : " sta_deauth <STA_MAC_ADDRESS > "
/* Check arguments */ /* Initialize the command length */ /* Initialize the command buffer */ /* Locate headers */ /* Fill the command buffer */ /* Send the command */ /* Process response */ /* Verify response */ /* Print response */