software/drivers/sd8887/src/wlan/mapp/uaputl/uaputl.c
/**
 *  @brief Creates host sleep parameter request and send to driver
 *
 *
 *  @param argc     Number of arguments
 *  @param argv     Pointer to the arguments
 *  @return         UAP_SUCCESS/UAP_FAILURE
 */
@brief Creates host sleep parameter request and send to driver
@param argc     Number of arguments
@param argv     Pointer to the arguments
@return         UAP_SUCCESS/UAP_FAILURE
@brief Creates host sleep parameter request and send to driver @param argc Number of arguments @param argv Pointer to the arguments @return UAP_SUCCESS / UAP_FAILURE
int
apcmd_hscfg(int argc, char *argv[])
{
	int opt;
	int i = 0;
	ds_hs_cfg hscfg;
	struct ifreq ifr;
	t_s32 sockfd;
	if ((argc == 2) && strstr(argv[1], "-1"))
		strcpy(argv[1], "0xffff");
	while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
		switch (opt) {
		default:
			print_hscfg_usage();
			return UAP_SUCCESS;
		}
	}
	argc -= optind;
	argv += optind;
	memset(&hscfg, 0, sizeof(hscfg));
	hscfg.subcmd = UAP_HS_CFG;
	if (argc > 3) {
		printf("ERR:wrong arguments.\n");
		print_hscfg_usage();
		return UAP_FAILURE;
	}
	if (argc) {
		for (i = 0; i < argc; i++) {
			if (IS_HEX_OR_DIGIT(argv[i]) == UAP_FAILURE) {
				printf("ERR: Invalid argument %s\n", argv[i]);
				print_hscfg_usage();
				return UAP_FAILURE;
			}
		}
	}
	if (argc) {
		hscfg.flags |= HS_CFG_FLAG_SET | HS_CFG_FLAG_CONDITION;
		hscfg.conditions = (t_u32)A2HEXDECIMAL(argv[0]);
		if (hscfg.conditions >= 0xffff)
			hscfg.conditions = HS_CFG_CANCEL;
		if ((hscfg.conditions != HS_CFG_CANCEL) &&
		    (hscfg.conditions & ~HS_CFG_CONDITION_MASK)) {
			printf("ERR:Illegal conditions 0x%x\n",
			       hscfg.conditions);
			print_hscfg_usage();
			return UAP_FAILURE;
		}
		if (argc > 1) {
			hscfg.flags |= HS_CFG_FLAG_GPIO;
			hscfg.gpio = (t_u32)A2HEXDECIMAL(argv[1]);
			if (hscfg.gpio > 255) {
				printf("ERR:Illegal gpio 0x%x\n", hscfg.gpio);
				print_hscfg_usage();
				return UAP_FAILURE;
			}
		}
		if (argc > 2) {
			hscfg.flags |= HS_CFG_FLAG_GAP;
			hscfg.gap = (t_u32)A2HEXDECIMAL(argv[2]);
		}
	} else {
		hscfg.flags = HS_CFG_FLAG_GET;
	}
	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 *)&hscfg;
	errno = 0;
	if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) {
		perror("");
		printf("ERR:UAP_HS_CFG failed\n");
		close(sockfd);
		return UAP_FAILURE;
	}
	if (!argc) {
		printf("Host sleep parameters:\n");
		printf("\tconditions=%d\n", (int)hscfg.conditions);
		printf("\tGPIO=%d\n", (int)hscfg.gpio);
		printf("\tgap=%d\n", (int)hscfg.gap);
	}
	close(sockfd);
	return UAP_SUCCESS;
}
int apcmd_hscfg ( int argc , char * argv [ ] ) { int opt ; int i = 0 ; ds_hs_cfg hscfg ; struct ifreq ifr ; t_s32 sockfd ; if ( ( argc == 2 ) && strstr ( argv [ 1 ] , " " ) ) strcpy ( argv [ 1 ] , " " ) ; while ( ( opt = getopt_long ( argc , argv , " " , cmd_options , NULL ) ) != -1 ) { switch ( opt ) { default : print_hscfg_usage ( ) ; return UAP_SUCCESS ; } } argc -= optind ; argv += optind ; memset ( & hscfg , 0 , sizeof ( hscfg ) ) ; hscfg . subcmd = UAP_HS_CFG ; if ( argc > 3 ) { printf ( " \n " ) ; print_hscfg_usage ( ) ; return UAP_FAILURE ; } if ( argc ) { for ( i = 0 ; i < argc ; i ++ ) { if ( IS_HEX_OR_DIGIT ( argv [ i ] ) == UAP_FAILURE ) { printf ( " \n " , argv [ i ] ) ; print_hscfg_usage ( ) ; return UAP_FAILURE ; } } } if ( argc ) { hscfg . flags |= HS_CFG_FLAG_SET | HS_CFG_FLAG_CONDITION ; hscfg . conditions = ( t_u32 ) A2HEXDECIMAL ( argv [ 0 ] ) ; if ( hscfg . conditions >= 0xffff ) hscfg . conditions = HS_CFG_CANCEL ; if ( ( hscfg . conditions != HS_CFG_CANCEL ) && ( hscfg . conditions & ~ HS_CFG_CONDITION_MASK ) ) { printf ( " \n " , hscfg . conditions ) ; print_hscfg_usage ( ) ; return UAP_FAILURE ; } if ( argc > 1 ) { hscfg . flags |= HS_CFG_FLAG_GPIO ; hscfg . gpio = ( t_u32 ) A2HEXDECIMAL ( argv [ 1 ] ) ; if ( hscfg . gpio > 255 ) { printf ( " \n " , hscfg . gpio ) ; print_hscfg_usage ( ) ; return UAP_FAILURE ; } } if ( argc > 2 ) { hscfg . flags |= HS_CFG_FLAG_GAP ; hscfg . gap = ( t_u32 ) A2HEXDECIMAL ( argv [ 2 ] ) ; } } else { hscfg . flags = HS_CFG_FLAG_GET ; } 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 * ) & hscfg ; 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 ) hscfg . conditions ) ; printf ( " \t \n " , ( int ) hscfg . gpio ) ; printf ( " \t \n " , ( int ) hscfg . gap ) ; } close ( sockfd ) ; return UAP_SUCCESS ; }
@brief Creates host sleep parameter request and send to driver
  @param argc     Number of arguments
  @param argv     Pointer to the arguments
  @return         UAP_SUCCESS/UAP_FAILURE
@brief Creates host sleep parameter 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 */