software/drivers/sd8887/src/wlan/mapp/mlanconfig/mlanconfig.c
/**
 *  @brief Process transmission of mgmt frames
 *  @param argc   number of arguments
 *  @param argv   A pointer to arguments array
 *  @return     MLAN_STATUS_SUCCESS--success, otherwise--fail
 */
@brief Process transmission of mgmt frames
@param argc   number of arguments
@param argv   A pointer to arguments array
@return     MLAN_STATUS_SUCCESS--success, otherwise--fail
@brief Process transmission of mgmt frames @param argc number of arguments @param argv A pointer to arguments array @return MLAN_STATUS_SUCCESS -- success otherwise -- fail
static int
process_mgmt_frame_tx(int argc, char *argv[])
{
	struct ifreq ifr;
	char *line = NULL;
	FILE *config_file = NULL;
	int li = 0, arg_num = 0, ret = 0, i = 0;
	char *args[100] = { NULL }, *pos = NULL, mac_addr[20];
	t_u8 peer_mac[ETH_ALEN];
	t_u16 data_len = 0, subtype = 0;
	wlan_mgmt_frame_tx *pmgmt_frame;
	t_u8 *buffer = NULL;
	pkt_header *hdr = NULL;
	if (argc != 4) {
		printf("ERR:Incorrect number of arguments.\n");
		printf("Syntax: ./mlanconfig mlanX mgmtframetx <config/pkt.conf>\n");
		exit(1);
	}
	data_len = sizeof(wlan_mgmt_frame_tx);
	buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER);
	if (!buffer) {
		printf("ERR:Cannot allocate memory!\n");
		goto done;
	}
	memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER);
	hdr = (pkt_header *)buffer;
	pmgmt_frame = (wlan_mgmt_frame_tx *)(buffer + sizeof(pkt_header));
	config_file = fopen(argv[3], "r");
	if (config_file == NULL) {
		printf("\nERR:Config file can not open.\n");
		goto done;
	}
	line = (char *)malloc(MAX_CONFIG_LINE);
	if (!line) {
		printf("ERR:Cannot allocate memory for line\n");
		goto done;
	}
	memset(line, 0, MAX_CONFIG_LINE);
	while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) {
		arg_num = parse_line(line, args);
		if (strcmp(args[0], "PktSubType") == 0) {
			subtype = (t_u16)A2HEXDECIMAL(args[1]);
			pmgmt_frame->frm_ctl |= subtype << 4;
		} else if (strncmp(args[0], "Addr", 4) == 0) {
			strncpy(mac_addr, args[1], 20);
			if ((ret =
			     mac2raw(mac_addr,
				     peer_mac)) != MLAN_STATUS_SUCCESS) {
				printf("ERR: %s Address \n",
				       ret ==
				       MLAN_STATUS_FAILURE ? "Invalid MAC" : ret
				       ==
				       MAC_BROADCAST ? "Broadcast" :
				       "Multicast");
				goto done;
			}
			i = atoi(args[0] + 4);
			switch (i) {
			case 1:
				memcpy(pmgmt_frame->addr1, peer_mac, ETH_ALEN);
				break;
			case 2:
				memcpy(pmgmt_frame->addr2, peer_mac, ETH_ALEN);
				break;
			case 3:
				memcpy(pmgmt_frame->addr3, peer_mac, ETH_ALEN);
				break;
			case 4:
				memcpy(pmgmt_frame->addr4, peer_mac, ETH_ALEN);
				break;
			}
		} else if (strcmp(args[0], "Data") == 0) {
			for (i = 0; i < arg_num - 1; i++)
				pmgmt_frame->payload[i] =
					(t_u8)A2HEXDECIMAL(args[i + 1]);
			data_len += arg_num - 1;
		}
	}
	pmgmt_frame->frm_len = data_len - sizeof(pmgmt_frame->frm_len);
#define MRVL_PKT_TYPE_MGMT_FRAME 0xE5
	hdr->pkt_len = data_len;
	hdr->TxPktType = MRVL_PKT_TYPE_MGMT_FRAME;
	hdr->TxControl = 0;
	hexdump("Frame Tx", buffer, data_len + sizeof(pkt_header), ' ');
	memset(&ifr, 0, sizeof(ifr));
	strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name));
	ifr.ifr_ifru.ifru_data = (void *)buffer;
	if (ioctl(sockfd, FRAME_TX_IOCTL, &ifr)) {
		perror("");
		printf("ERR:Could not send management frame.\n");
	} else {
		printf("Mgmt Frame sucessfully sent.\n");
	}
done:
	if (config_file)
		fclose(config_file);
	if (buffer)
		free(buffer);
	if (line)
		free(line);
	return MLAN_STATUS_SUCCESS;
}
static int process_mgmt_frame_tx ( int argc , char * argv [ ] ) { struct ifreq ifr ; char * line = NULL ; FILE * config_file = NULL ; int li = 0 , arg_num = 0 , ret = 0 , i = 0 ; char * args [ 100 ] = { NULL } , * pos = NULL , mac_addr [ 20 ] ; t_u8 peer_mac [ ETH_ALEN ] ; t_u16 data_len = 0 , subtype = 0 ; wlan_mgmt_frame_tx * pmgmt_frame ; t_u8 * buffer = NULL ; pkt_header * hdr = NULL ; if ( argc != 4 ) { printf ( " \n " ) ; printf ( " \n " ) ; exit ( 1 ) ; } data_len = sizeof ( wlan_mgmt_frame_tx ) ; buffer = ( t_u8 * ) malloc ( MRVDRV_SIZE_OF_CMD_BUFFER ) ; if ( ! buffer ) { printf ( " \n " ) ; goto done ; } memset ( buffer , 0 , MRVDRV_SIZE_OF_CMD_BUFFER ) ; hdr = ( pkt_header * ) buffer ; pmgmt_frame = ( wlan_mgmt_frame_tx * ) ( buffer + sizeof ( pkt_header ) ) ; config_file = fopen ( argv [ 3 ] , " " ) ; if ( config_file == NULL ) { printf ( " \n \n " ) ; goto done ; } line = ( char * ) malloc ( MAX_CONFIG_LINE ) ; if ( ! line ) { printf ( " \n " ) ; goto done ; } memset ( line , 0 , MAX_CONFIG_LINE ) ; while ( config_get_line ( line , MAX_CONFIG_LINE , config_file , & li , & pos ) ) { arg_num = parse_line ( line , args ) ; if ( strcmp ( args [ 0 ] , " " ) == 0 ) { subtype = ( t_u16 ) A2HEXDECIMAL ( args [ 1 ] ) ; pmgmt_frame -> frm_ctl |= subtype << 4 ; } else if ( strncmp ( args [ 0 ] , " " , 4 ) == 0 ) { strncpy ( mac_addr , args [ 1 ] , 20 ) ; if ( ( ret = mac2raw ( mac_addr , peer_mac ) ) != MLAN_STATUS_SUCCESS ) { printf ( " \n " , ret == MLAN_STATUS_FAILURE ? " " : ret == MAC_BROADCAST ? " " : " " ) ; goto done ; } i = atoi ( args [ 0 ] + 4 ) ; switch ( i ) { case 1 : memcpy ( pmgmt_frame -> addr1 , peer_mac , ETH_ALEN ) ; break ; case 2 : memcpy ( pmgmt_frame -> addr2 , peer_mac , ETH_ALEN ) ; break ; case 3 : memcpy ( pmgmt_frame -> addr3 , peer_mac , ETH_ALEN ) ; break ; case 4 : memcpy ( pmgmt_frame -> addr4 , peer_mac , ETH_ALEN ) ; break ; } } else if ( strcmp ( args [ 0 ] , " " ) == 0 ) { for ( i = 0 ; i < arg_num - 1 ; i ++ ) pmgmt_frame -> payload [ i ] = ( t_u8 ) A2HEXDECIMAL ( args [ i + 1 ] ) ; data_len += arg_num - 1 ; } } pmgmt_frame -> frm_len = data_len - sizeof ( pmgmt_frame -> frm_len ) ; #define MRVL_PKT_TYPE_MGMT_FRAME  0xE5 hdr -> pkt_len = data_len ; hdr -> TxPktType = MRVL_PKT_TYPE_MGMT_FRAME ; hdr -> TxControl = 0 ; hexdump ( " " , buffer , data_len + sizeof ( pkt_header ) , ' ' ) ; memset ( & ifr , 0 , sizeof ( ifr ) ) ; strncpy ( ifr . ifr_ifrn . ifrn_name , dev_name , strlen ( dev_name ) ) ; ifr . ifr_ifru . ifru_data = ( void * ) buffer ; if ( ioctl ( sockfd , FRAME_TX_IOCTL , & ifr ) ) { perror ( " " ) ; printf ( " \n " ) ; } else { printf ( " \n " ) ; } done : if ( config_file ) fclose ( config_file ) ; if ( buffer ) free ( buffer ) ; if ( line ) free ( line ) ; return MLAN_STATUS_SUCCESS ; }
@brief Process transmission of mgmt frames
  @param argc   number of arguments
  @param argv   A pointer to arguments array
  @return     MLAN_STATUS_SUCCESS--success, otherwise--fail
@brief Process transmission of mgmt frames @param argc number of arguments @param argv A pointer to arguments array @return MLAN_STATUS_SUCCESS -- success otherwise -- fail
/* Check arguments */ /* Check if file exists */ /* Parse file and process */ /* Send collective command */ /* Perform ioctl */