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><REASON_CODE>"
 *
 *  @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_ext(int argc, char *argv[])
{
	int ret = UAP_SUCCESS;
	int opt;
	deauth_param param;
	struct ifreq ifr;
	t_s32 sockfd;
	t_u32 result = 0;
	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 != 2) {
		printf("ERR:wrong arguments! Must provide STA_MAC_ADDRESS, REASON_CODE.\n");
		print_sta_deauth_ext_usage();
		return UAP_FAILURE;
	}
	memset(&param, 0, sizeof(deauth_param));
	if ((ret = mac2raw(argv[0], param.mac_addr)) != UAP_SUCCESS) {
		printf("ERR: %s Address\n", ret == UAP_FAILURE ? "Invalid MAC" :
		       ret ==
		       UAP_RET_MAC_BROADCAST ? "Broadcast" : "Multicast");
		return UAP_FAILURE;
	}
	if ((IS_HEX_OR_DIGIT(argv[1]) == UAP_FAILURE) ||
	    (atoi(argv[1]) > MAX_DEAUTH_REASON_CODE)) {
		printf("ERR: Invalid input for reason code\n");
		return UAP_FAILURE;
	}
	param.reason_code = (t_u16)A2HEXDECIMAL(argv[1]);
	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		printf("ERR:Cannot open socket\n");
		return UAP_FAILURE;
	}
	memset(&ifr, 0, sizeof(ifr));
	strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1);
	ifr.ifr_ifru.ifru_data = (void *)&param;
	errno = 0;
	if (ioctl(sockfd, UAP_STA_DEAUTH, &ifr)) {
		memcpy((void *)&result, (void *)&param, sizeof(result));
		if (result == 1)
			printf("ERR:UAP_STA_DEAUTH fail\n");
		else
			perror("");
		close(sockfd);
		return UAP_FAILURE;
	}
	printf("Station deauth successful\n");
	close(sockfd);
	return ret;
}
int apcmd_sta_deauth_ext ( int argc , char * argv [ ] ) { int ret = UAP_SUCCESS ; int opt ; deauth_param param ; struct ifreq ifr ; t_s32 sockfd ; t_u32 result = 0 ; 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 != 2 ) { printf ( " \n " ) ; print_sta_deauth_ext_usage ( ) ; return UAP_FAILURE ; } memset ( & param , 0 , sizeof ( deauth_param ) ) ; if ( ( ret = mac2raw ( argv [ 0 ] , param . mac_addr ) ) != UAP_SUCCESS ) { printf ( " \n " , ret == UAP_FAILURE ? " " : ret == UAP_RET_MAC_BROADCAST ? " " : " " ) ; return UAP_FAILURE ; } if ( ( IS_HEX_OR_DIGIT ( argv [ 1 ] ) == UAP_FAILURE ) || ( atoi ( argv [ 1 ] ) > MAX_DEAUTH_REASON_CODE ) ) { printf ( " \n " ) ; return UAP_FAILURE ; } param . reason_code = ( t_u16 ) A2HEXDECIMAL ( argv [ 1 ] ) ; if ( ( sockfd = socket ( AF_INET , SOCK_STREAM , 0 ) ) < 0 ) { printf ( " \n " ) ; return UAP_FAILURE ; } memset ( & ifr , 0 , sizeof ( ifr ) ) ; strncpy ( ifr . ifr_ifrn . ifrn_name , dev_name , IFNAMSIZ - 1 ) ; ifr . ifr_ifru . ifru_data = ( void * ) & param ; errno = 0 ; if ( ioctl ( sockfd , UAP_STA_DEAUTH , & ifr ) ) { memcpy ( ( void * ) & result , ( void * ) & param , sizeof ( result ) ) ; if ( result == 1 ) printf ( " \n " ) ; else perror ( " " ) ; close ( sockfd ) ; return UAP_FAILURE ; } printf ( " \n " ) ; close ( sockfd ) ; return ret ; }
@brief Creates a STA deauth request and sends to the driver
   Usage: "sta_deauth <STA_MAC_ADDRESS><REASON_CODE>"
@brief Creates a STA deauth request and sends to the driver Usage : " sta_deauth <STA_MAC_ADDRESS > <REASON_CODE > "
/* Check arguments */ /* Open socket */ /* Initialize the ifr structure */ /* Perform ioctl */ /* Close socket */