software/drivers/sd8887/src/wlan/mapp/uaputl/uaputl.c
/**
 *  @brief Creates addbaparam request and send to driver
 *
 *
 *  @param argc     Number of arguments
 *  @param argv     Pointer to the arguments
 *  @return         UAP_SUCCESS/UAP_FAILURE
 */
@brief Creates addbaparam request and send to driver
@param argc     Number of arguments
@param argv     Pointer to the arguments
@return         UAP_SUCCESS/UAP_FAILURE
@brief Creates addbaparam request and send to driver @param argc Number of arguments @param argv Pointer to the arguments @return UAP_SUCCESS / UAP_FAILURE
int
apcmd_addbapara(int argc, char *argv[])
{
	int opt;
	addba_param param;
	struct ifreq ifr;
	t_s32 sockfd;
	while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
		switch (opt) {
		default:
			print_addbapara_usage();
			return UAP_SUCCESS;
		}
	}
	argc -= optind;
	argv += optind;
	memset(&param, 0, sizeof(param));
	if ((argc != 0) && (argc != 5)) {
		printf("ERR:wrong arguments. Only support 0 or 5 arguments\n");
		print_addbapara_usage();
		return UAP_FAILURE;
	}
	param.subcmd = UAP_ADDBA_PARA;
	if (argc) {
		if ((IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE)
		    || (IS_HEX_OR_DIGIT(argv[1]) == UAP_FAILURE)
		    || (IS_HEX_OR_DIGIT(argv[2]) == UAP_FAILURE)
		    || (IS_HEX_OR_DIGIT(argv[3]) == UAP_FAILURE)
		    || (IS_HEX_OR_DIGIT(argv[4]) == UAP_FAILURE)
			) {
			printf("ERR: Only Number values are allowed\n");
			print_addbapara_usage();
			return UAP_FAILURE;
		}
		param.action = 1;
		param.timeout = (t_u32)A2HEXDECIMAL(argv[0]);
		if (param.timeout > DEFAULT_BLOCK_ACK_TIMEOUT) {
			printf("ERR: Block Ack timeout should be in range [1-65535]\n");
			print_addbapara_usage();
			return UAP_FAILURE;
		}
		param.txwinsize = (t_u32)A2HEXDECIMAL(argv[1]);
		param.rxwinsize = (t_u32)A2HEXDECIMAL(argv[2]);
		if (param.txwinsize > MAX_TXRX_WINDOW_SIZE ||
		    param.rxwinsize > MAX_TXRX_WINDOW_SIZE) {
			printf("ERR: Tx/Rx window size should not be greater than 1023\n");
			print_addbapara_usage();
			return UAP_FAILURE;
		}
		param.txamsdu = (t_u8)A2HEXDECIMAL(argv[3]);
		param.rxamsdu = (t_u8)A2HEXDECIMAL(argv[4]);
		if (param.txamsdu > 1 || param.rxamsdu > 1) {
			printf("ERR: Tx/Rx amsdu should not be 0 or 1\n");
			print_addbapara_usage();
			return UAP_FAILURE;
		}
	} else {
		param.action = 0;
	}
	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_IOCTL_CMD, &ifr)) {
		perror("");
		printf("ERR:ADDBA PARA failed\n");
		close(sockfd);
		return UAP_FAILURE;
	}
	if (!argc) {
		printf("ADDBA parameters:\n");
		printf("\ttimeout=%d\n", (int)param.timeout);
		printf("\ttxwinsize=%d\n", (int)param.txwinsize);
		printf("\trxwinsize=%d\n", (int)param.rxwinsize);
		printf("\ttxamsdu=%d\n", (int)param.txamsdu);
		printf("\trxamsdu=%d\n", (int)param.rxamsdu);
	}
	close(sockfd);
	return UAP_SUCCESS;
}
int apcmd_addbapara ( int argc , char * argv [ ] ) { int opt ; addba_param param ; struct ifreq ifr ; t_s32 sockfd ; while ( ( opt = getopt_long ( argc , argv , " " , cmd_options , NULL ) ) != -1 ) { switch ( opt ) { default : print_addbapara_usage ( ) ; return UAP_SUCCESS ; } } argc -= optind ; argv += optind ; memset ( & param , 0 , sizeof ( param ) ) ; if ( ( argc != 0 ) && ( argc != 5 ) ) { printf ( " \n " ) ; print_addbapara_usage ( ) ; return UAP_FAILURE ; } param . subcmd = UAP_ADDBA_PARA ; if ( argc ) { if ( ( IS_HEX_OR_DIGIT ( argv [ 0 ] ) == UAP_FAILURE ) || ( IS_HEX_OR_DIGIT ( argv [ 1 ] ) == UAP_FAILURE ) || ( IS_HEX_OR_DIGIT ( argv [ 2 ] ) == UAP_FAILURE ) || ( IS_HEX_OR_DIGIT ( argv [ 3 ] ) == UAP_FAILURE ) || ( IS_HEX_OR_DIGIT ( argv [ 4 ] ) == UAP_FAILURE ) ) { printf ( " \n " ) ; print_addbapara_usage ( ) ; return UAP_FAILURE ; } param . action = 1 ; param . timeout = ( t_u32 ) A2HEXDECIMAL ( argv [ 0 ] ) ; if ( param . timeout > DEFAULT_BLOCK_ACK_TIMEOUT ) { printf ( " \n " ) ; print_addbapara_usage ( ) ; return UAP_FAILURE ; } param . txwinsize = ( t_u32 ) A2HEXDECIMAL ( argv [ 1 ] ) ; param . rxwinsize = ( t_u32 ) A2HEXDECIMAL ( argv [ 2 ] ) ; if ( param . txwinsize > MAX_TXRX_WINDOW_SIZE || param . rxwinsize > MAX_TXRX_WINDOW_SIZE ) { printf ( " \n " ) ; print_addbapara_usage ( ) ; return UAP_FAILURE ; } param . txamsdu = ( t_u8 ) A2HEXDECIMAL ( argv [ 3 ] ) ; param . rxamsdu = ( t_u8 ) A2HEXDECIMAL ( argv [ 4 ] ) ; if ( param . txamsdu > 1 || param . rxamsdu > 1 ) { printf ( " \n " ) ; print_addbapara_usage ( ) ; return UAP_FAILURE ; } } else { param . action = 0 ; } 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_IOCTL_CMD , & ifr ) ) { perror ( " " ) ; printf ( " \n " ) ; close ( sockfd ) ; return UAP_FAILURE ; } if ( ! argc ) { printf ( " \n " ) ; printf ( " \t \n " , ( int ) param . timeout ) ; printf ( " \t \n " , ( int ) param . txwinsize ) ; printf ( " \t \n " , ( int ) param . rxwinsize ) ; printf ( " \t \n " , ( int ) param . txamsdu ) ; printf ( " \t \n " , ( int ) param . rxamsdu ) ; } close ( sockfd ) ; return UAP_SUCCESS ; }
@brief Creates addbaparam request and send to driver
  @param argc     Number of arguments
  @param argv     Pointer to the arguments
  @return         UAP_SUCCESS/UAP_FAILURE
@brief Creates addbaparam request and send to driver @param argc Number of arguments @param argv Pointer to the arguments @return UAP_SUCCESS / UAP_FAILURE
/* Check arguments */ /* Open socket */ /* Initialize the ifr structure */ /* Perform ioctl */ /* Close socket */